258 lines
11 KiB
PHP
Executable File
258 lines
11 KiB
PHP
Executable File
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class assetdetails_model extends CI_Model
|
|
{
|
|
|
|
/**
|
|
* This function is used to get the user listing count
|
|
* @param string $searchText : This is optional search text
|
|
* @param number $page : This is pagination offset
|
|
* @param number $segment : This is pagination limit
|
|
* @return array $result : This is result
|
|
*/
|
|
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;
|
|
}
|
|
|
|
|
|
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();
|
|
}
|
|
|
|
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();
|
|
}
|
|
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();
|
|
//print_r($this->db->last_query());
|
|
return $query->result();
|
|
|
|
}
|
|
function getPO($PO='')
|
|
{
|
|
$this->db->distinct();
|
|
$this->db->select(' POM.PONO');//,DeliveryDate,PODate,sup.SupplierName,POM.SupplierID');
|
|
$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();
|
|
//print_r($this->db->last_query());
|
|
return $query->result();
|
|
}
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
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;
|
|
}
|
|
|
|
function getlineitemcap($line){
|
|
$this->db->select('POL.LineItemNo,POL.MaterialCode,MM.MaterialName,MM.UOM,POM.POType,POL.Quantity,sum(ser.TotalValue+imp.TotalValue) as 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 imp','imp.LineItemNo = POL.LineItemNo','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;
|
|
}
|
|
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;
|
|
}
|
|
/**
|
|
* This function is used to get the Config value from configuration table
|
|
* @return array $result : This is result of the query
|
|
*/
|
|
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();
|
|
}
|
|
|
|
/**
|
|
* This function used to get user information by id
|
|
* @param number $userId : This is user id
|
|
* @return array $result : This is user information
|
|
*/
|
|
|
|
function addNewasset($asset)
|
|
{
|
|
$this->db->trans_start();
|
|
$this->db->insert('T_Asset_Details', $asset);
|
|
|
|
//$Asset_Code = $this->db->insert_id();
|
|
$Asset_Code = $this->db->affected_rows();
|
|
|
|
$this->db->trans_complete();
|
|
|
|
return $Asset_Code;
|
|
}
|
|
|
|
/**
|
|
* This function used to get Asset details by Asset Code
|
|
* @param number $Asset_Code : This is AssetCode
|
|
* @return array $result : This is Asset information
|
|
*/
|
|
function getAssetDetails($Asset_Code)
|
|
{
|
|
//echo $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();
|
|
//print_r($this->db->last_query());
|
|
return $query->result();
|
|
}
|
|
function editasset($asset, $Asset_Code)
|
|
{
|
|
$this->db->where('AssetCode', $Asset_Code);
|
|
$this->db->update('T_Asset_Details', $asset);
|
|
//print_r($this->db->last_query());
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
function viewasset($asset, $Asset_Code)
|
|
{
|
|
$this->db->where('AssetCode', $Asset_Code);
|
|
$this->db->update('T_Asset_Details', $asset);
|
|
|
|
return TRUE;
|
|
}
|
|
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();
|
|
}
|
|
}
|
|
?>
|