ria/application/models/assetdetails_model.php
venbatechnologies@gmail.com b1c8fe52a4 issues fixes
2018-07-12 12:34:06 +05:30

310 lines
12 KiB
PHP
Executable File

<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class assetdetails_model extends CI_Model
{
/**
* To get the Asset data for listing
* @return array $result : result of the query (returns asset information)
*/
function assetListing()
{
$this->db->select('asd.*,dep.DepartmentName,sup.SupplierName');
$this->db->from('T_Asset_Details asd');
$this->db->join('T_DepartmentDetails dep', ' dep.DEPCode = asd.DEPCode','left');
$this->db->join ('T_SupplierDetailsN sup','sup.SupplierID = asd.SupplierCode','left');
$query = $this->db->get();
$result = $query->result();
return $result;
}
/**
* To get the actived department information
* @param $Department : Optional : This is department code
* @return $query->result() : result of the query (returns department information)
*
* Note : This function Temporary not in use
*/
function getDepartment($Department = '')
{
$this->db->select('DEPCode,DepartmentName');
$this->db->from('T_DepartmentDetails');
$this->db->where('IsActive',1 );
if($Department != '')
{
$this->db->where('DEPCode !=',$Department );
}
$query = $this->db->get();
return $query->result();
}
/**
* To get the actived supplier information
* @param $SupplierID : Optional : This is Supplier id
* @return $query->result() : result of the query (returns supplier information)
*/
function getSupplierName($SupplierID = '')
{
$this->db->select('SupplierID, SupplierName');
$this->db->from('T_SupplierDetailsN');
$this->db->where('IsActive',1 );
if($SupplierID != '')
{
$this->db->where('SupplierID !=',$SupplierID );
}
$query = $this->db->get();
return $query->result();
}
/**
* To get the MRIR Approved PO details
* @param $PO : This is PO number
* @return $query->result() : result of the query (returns po details)
*/
function getpodetails($PO)
{
$this->db->distinct();
$this->db->select('POM.PONO,POM.SupplierID,POL.MaterialCode,DeliveryDate,PODate,sup.SupplierName,POL.LineItemNo');
$this->db->from('T_PurchaseOrder_Master POM');
$this->db->join('T_PurchaseOrder_LineItem POL', 'POL.PONO = POM.PONO');
$this->db->join('T_SupplierDetailsN sup', 'sup.SupplierID = POM.SupplierID');
$this->db->where('POM.status',MRIR_APPROVED);
if(!empty($PO)){
$this->db->where('POM.PONO',$PO);
}
$query = $this->db->get();
return $query->result();
}
/**
* To get the MRIR Approved PO (listed on dropdown)
* @param $PO :Optional : This is PO number
* @return $query->result() : result of the query (returns po number)
*/
function getPO($PO='')
{
$this->db->distinct();
$this->db->select(' POM.PONO');
$this->db->from('T_PurchaseOrder_Master POM');
$this->db->where('POM.status',MRIR_APPROVED);
$this->db->where('POM.POType','CAPITAL');
if(!empty($PO)){
$this->db->where('POM.PONO',$PO);
}
$query = $this->db->get();
return $query->result();
}
/**
* To get the PO lineitem details for revenue po.
* @param $line : This is PO lineitem number
* @return $result : result of the query (returns revenue po lineitem details)
*/
function getlineitemre($line){
$this->db->select('POL.LineItemNo,POL.MaterialCode,MM.MaterialName,MM.UOM,POL.Quantity,POM.POType,re.TotalValue,req.ReqNo,emp.firstname,emp.Departmentcode,dep.DepartmentName,sup.SupplierName,date(POM.DeliveryDate) as DeliveryDate,POM.PODate,POM.SupplierID');
$this->db->from('T_PurchaseOrder_LineItem POL');
$this->db->join('T_Requestion_Master req','req.ReqNo = POL.ReqNo','left');
$this->db->join('T_PurchaseOrder_Master POM','POM.PONO=POL.PONO','left');
$this->db->join('T_MaterialMaster MM','MM.MaterialCode = POL.MaterialCode','left');
$this->db->join('T_Employee_Details emp','emp.EmpID = req.Requestedby','left');
$this->db->join('T_DepartmentDetails dep','dep.DEPCode = emp.Departmentcode','left');
$this->db->join('T_Revenue_Tax re','re.LineItemNo = POL.LineItemNo','left');
$this->db->join('T_SupplierDetailsN sup','sup.SupplierID = POM.SupplierID','left');
$this->db->where('POL.LineItemNo',$line);
$query = $this->db->get();
$result = $query->result();
return $result;
}
/**
* To get the PO lineitem details for service po.
* @param $line : This is PO lineitem number
* @return $result : This is result of the query (returns service po lineitem details)
*/
function getlineitemser($line){
$this->db->select('POL.LineItemNo,POL.MaterialCode,MM.MaterialName,MM.UOM,POM.POType,POL.Quantity,ser.TotalValue,req.ReqNo,emp.firstname,dep.DepartmentName,emp.Departmentcode,sup.SupplierName,date(POM.DeliveryDate) as DeliveryDate,POM.PODate,POM.SupplierID');
$this->db->from('T_PurchaseOrder_LineItem POL');
$this->db->join('T_Requestion_Master req','req.ReqNo = POL.ReqNo','left');
$this->db->join('T_PurchaseOrder_Master POM','POM.PONO=POL.PONO','left');
$this->db->join ('T_MaterialMaster MM','MM.MaterialCode = POL.MaterialCode','left');
$this->db->join('T_Employee_Details emp','emp.EmpID = req.Requestedby','left');
$this->db->join('T_DepartmentDetails dep','dep.DEPCode = emp.Departmentcode','left');
$this->db->join ('T_Service_Tax ser','ser.LineItemNo = POL.LineItemNo','left');
$this->db->join('T_SupplierDetailsN sup','sup.SupplierID = POM.SupplierID','left');
$this->db->where('POL.LineItemNo',$line);
$query = $this->db->get();
$result = $query->result();
return $result;
}
/**
* To get the PO lineitem details for import po.
* @param $line : This is PO lineitem number
* @return $result : result of the query (returns import po lineitem details)
*/
function getlineitemimport($line){
$this->db->select('POL.LineItemNo,POL.MaterialCode,MM.MaterialName,MM.UOM,POM.POType,POL.Quantity,ser.TotalValue,req.ReqNo,emp.firstname,dep.DepartmentName,emp.Departmentcode,sup.SupplierName,date(POM.DeliveryDate) as DeliveryDate,POM.PODate,POM.SupplierID');
$this->db->from('T_PurchaseOrder_LineItem POL');
$this->db->join('T_Requestion_Master req','req.ReqNo = POL.ReqNo','left');
$this->db->join('T_PurchaseOrder_Master POM','POM.PONO=POL.PONO','left');
$this->db->join ('T_MaterialMaster MM','MM.MaterialCode = POL.MaterialCode','left');
$this->db->join('T_Employee_Details emp','emp.EmpID = req.Requestedby','left');
$this->db->join('T_DepartmentDetails dep','dep.DEPCode = emp.Departmentcode','left');
$this->db->join ('T_Import_Tax ser','ser.LineItemNo = POL.LineItemNo','left');
$this->db->join('T_SupplierDetailsN sup','sup.SupplierID = POM.SupplierID','left');
$this->db->where('POL.LineItemNo',$line);
$query = $this->db->get();
$result = $query->result();
return $result;
}
/**
* To get the PO lineitem details for capital po.
* @param $line : This is PO lineitem number
* @return $result : result of the query (returns po capital lineitem details)
*/
function getlineitemcap($line){
$sql="SELECT POL.LineItemNo,POL.MaterialCode,MM.MaterialName,MM.UOM,POM.POType,POL.Quantity,sum(coalesce(ser.TotalValue,0) + coalesce((POL.Quantity*POL.Rate*POM.ExchangeRate),0)) as TotalValue,req.ReqNo,emp.firstname,dep.DepartmentName,emp.Departmentcode,sup.SupplierName,date(POM.DeliveryDate) as DeliveryDate,POM.PODate,POM.SupplierID
from T_PurchaseOrder_LineItem POL
left join T_Requestion_Master req on req.ReqNo = POL.ReqNo
left join T_PurchaseOrder_Master POM on POM.PONO= POL.PONO
left join T_MaterialMaster MM on MM.MaterialCode = POL.MaterialCode
left join T_Employee_Details emp on emp.EmpID = req.Requestedby
left join T_DepartmentDetails dep on dep.DEPCode = emp.Departmentcode
left join T_Service_Tax ser on ser.LineItemNo = POL.LineItemNo
left join T_Import_Tax imp on imp.LineItemNo = POL.LineItemNo
left join T_SupplierDetailsN sup on sup.SupplierID = POM.SupplierID
where POL.LineItemNo = ? ";
$query = $this->db->query($sql,array($line));
return $query->result();
}
/**
* To get the PO lineitem details revalant po.
* @param $type : This is PO type
* @return $result : result of the query (returns po type and lineitem no)
*/
function gettyp($type)
{
$this->db->select('POM.POType,POL.LineItemNo');
$this->db->from('T_PurchaseOrder_LineItem POL');
$this->db->join('T_PurchaseOrder_Master POM','POM.PONO=POL.PONO');
$this->db->where('POL.LineItemNo',$type);
$query = $this->db->get();
$result = $query->result();
return $result;
}
/**
* To get the Config value from configuration table
* @param $ConfigID : This is Configid
* @param $ConfigValue : Optional : This is PO type
* @return array $query->result() : result of the query(returns config details)
*/
function getConfigValue($ConfigID ,$ConfigValue = '')
{
$this->db->select('ConfigValue');
$this->db->from('T_ConfigDetails');
$this->db->where('Config_id ',$ConfigID );
if($ConfigValue != '')
{
$this->db->where('ConfigValue != ',$ConfigValue );
}
$query = $this->db->get();
return $query->result();
}
/**
* To Store the asset information
* @param $asset : This will have all asset datas
* @return $Asset_Code : This will return how many value are inserted (return as number(counts))
*/
function addNewasset($asset)
{
$this->db->trans_start();
$this->db->insert('T_Asset_Details', $asset);
$Asset_Code = $this->db->affected_rows();
$this->db->trans_complete();
return $Asset_Code;
}
/**
* To get Asset details from respective Asset Code
* @param number $Asset_Code : This is asset code
* @return array $query->result() : result of the query(returns asset details)
*/
function getAssetDetails($Asset_Code)
{
$this->db->select('Asset.*,POM.DeliveryDate,Dep.DepartmentName as DepartmentName,MM.MaterialName,MM.UOM,Supp.SupplierName as SupplierName');
$this->db->from('T_Asset_Details Asset');
$this->db->join('T_DepartmentDetails Dep', 'Asset.DEPCode = Dep.DEPCode','left');
$this->db->join('T_SupplierDetailsN Supp', 'Asset.SupplierCode = Supp.SupplierID','left');
$this->db->join('T_MaterialMaster MM ', 'MM.MaterialCode = Asset.MaterialCode','left');
$this->db->join('T_PurchaseOrder_Master POM','POM.PONO = Asset.PONO','left');
$this->db->where('Asset.AssetCode', $Asset_Code);
$query = $this->db->get();
return $query->result();
}
/**
* To Stored edited Asset details from respective Asset Code
* @param $asset : This will have all the edited asset information
* @param $Asset_Code : This is asset code
*/
function editasset($asset, $Asset_Code)
{
$this->db->where('AssetCode', $Asset_Code);
$this->db->update('T_Asset_Details', $asset);
return TRUE;
}
/**
* To Store edited Asset details in respective Asset Code
* @param $asset : This will have all edited aseet information
* @param $Asset_Code : This is asset code
*
* Note : This function Temporary not in use
*/
function viewasset($asset, $Asset_Code)
{
$this->db->where('AssetCode', $Asset_Code);
$this->db->update('T_Asset_Details', $asset);
return TRUE;
}
/**
* To get Asset's information for export xl
*/
function export_excel(){
$this->db->select('det.*,dep.DepartmentName as DEPCode,sup.SupplierName,MM.MaterialName,emp.firstname,emp1.firstname as Updated_By');
$this->db->join('tbl_users as tbl',' det.createdby = tbl.userid','left');
$this->db->join('T_DepartmentDetails as dep','dep.DEPCode=det.DEPCode','left');
$this->db->join('T_Employee_Details as emp', 'emp.empid=tbl.empid','left');
$this->db->join('T_SupplierDetailsN as sup', 'sup.SupplierID=det.SupplierCode','left');
$this->db->join('T_MaterialMaster MM ', 'MM.MaterialCode = det.MaterialCode','left');
$this->db->join('tbl_users as tbl1',' det.UpdatedBy = tbl1.userid','left');
$this->db->join('T_Employee_Details as emp1', 'emp1.empid=tbl1.empid','left');
return $this->db->get('T_Asset_Details as det')->result_array();
}
}
?>