137 lines
4.1 KiB
PHP
137 lines
4.1 KiB
PHP
<?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('*');
|
|
$this->db->from('T_Asset_Details');
|
|
|
|
|
|
$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();
|
|
}
|
|
|
|
/**
|
|
* 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();
|
|
|
|
$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.*,Dep.DepartmentName as DepartmentName,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->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,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');
|
|
$this->db->join('T_Employee_Details as emp', 'emp.empid=tbl.empid','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();
|
|
}
|
|
}
|
|
?>
|