Asset module

This commit is contained in:
gandhimathi Bharathirajan 2017-04-17 10:32:10 +05:30
parent 0a47a51109
commit e91410220a

View File

@ -9,27 +9,23 @@ class assetdetails_model extends CI_Model
*/
function assetListingCount($searchText = ''){
$this->db->select('BaseT.Asset_Code, BaseT.Asset_Name, BaseT.Description, ID.SupplierName,BaseT.Department, BaseT.Location,BaseT.User,BaseT.DateOfCommission,BaseT.AssetValue,BaseT.DateOfPurchase');
$this->db->from('T_AssetDetails as BaseT');
$this->db->select('*');
$this->db->from('T_Asset_Details');
$this->db->join('T_SupplierDetailsN as ID', 'ID.SupplierName = BaseT.SupplierName','left');
//$this->db->join('T_PurchaseOrderDetails as PO', 'PO.PODate = BaseT.PODate','left');
//$this->db->join('tbl_users as users', 'users.userId = BaseT.userId','left');
//$this->db->join('T_SupplierDetails as ID', 'ID.SupplierID = BaseT.SupplierID','left');
if(!empty($searchText)) {
$likeCriteria = "(BaseT.Asset_Code LIKE '%".$searchText."%'
OR BaseT.Asset_Name LIKE '%".$searchText."%'
OR BaseT.Description LIKE '%".$searchText."%'
OR BaseT.SupplierName LIKE '%".$searchText."%'
OR BaseT.Department LIKE '%".$searchText."%'
OR BaseT.DateOfPurchase LIKE '%".$searchText."%'
OR BaseT.Location LIKE '%".$searchText."%'
OR BaseT.User LIKE '%".$searchText."%'
OR BaseT.DateOfCommission LIKE '%".$searchText."%'
OR BaseT.DateOfPurchase LIKE '%".$searchText."%'
OR BaseT.AssetValue LIKE '%".$searchText."%'
OR BaseT.AssetValue LIKE '%".$searchText."%'
OR BaseT.CreatedDate LIKE '%".$searchText."%'
if(!empty($searchText)) {
$likeCriteria = "(AssetCode LIKE '%".$searchText."%'
OR AssetName LIKE '%".$searchText."%'
OR Description LIKE '%".$searchText."%'
OR Description LIKE '%".$searchText."%'
OR DEPCode LIKE '%".$searchText."%'
OR Location LIKE '%".$searchText."%'
OR UserName LIKE '%".$searchText."%'
OR SupplierCode LIKE '%".$searchText."%'
OR DateOfPurchase LIKE '%".$searchText."%'
OR DateOfCommison LIKE '%".$searchText."%'
OR AssetStatus LIKE '%".$searchText."%'
)";
$this->db->where($likeCriteria);
}
@ -47,30 +43,27 @@ class assetdetails_model extends CI_Model
*/
function assetListing($searchText = '', $page, $segment)
{
$this->db->select('BaseT.Asset_Code, BaseT.Asset_Name, BaseT.Description, BaseT.Department, BaseT.Location,BaseT.User,BaseT.DateOfCommission,BaseT.DateOfPurchase,BaseT.AssetValue,BaseT.CreatedDate,BaseT.SupplierName');
$this->db->from('T_AssetDetails as BaseT');
//$this->db->join('T_SupplierDetailsN as ID', 'ID.SupplierName = BaseT.SupplierName','left');
$this->db->select('*');
$this->db->from('T_Asset_Details');
if(!empty($searchText)) {
$likeCriteria = "(BaseT.Asset_Code LIKE '%".$searchText."%'
OR BaseT.Asset_Name LIKE '%".$searchText."%'
OR BaseT.Description LIKE '%".$searchText."%'
OR BaseT.SupplierName LIKE '%".$searchText."%'
OR BaseT.Department LIKE '%".$searchText."%'
OR BaseT.DateOfPurchase LIKE '%".$searchText."%'
OR BaseT.Location LIKE '%".$searchText."%'
OR BaseT.User LIKE '%".$searchText."%'
OR BaseT.DateOfCommission LIKE '%".$searchText."%'
OR BaseT.DateOfPurchase LIKE '%".$searchText."%'
OR BaseT.AssetValue LIKE '%".$searchText."%'
$likeCriteria = "(AssetCode LIKE '%".$searchText."%'
OR AssetName LIKE '%".$searchText."%'
OR Description LIKE '%".$searchText."%'
OR Description LIKE '%".$searchText."%'
OR DEPCode LIKE '%".$searchText."%'
OR Location LIKE '%".$searchText."%'
OR UserName LIKE '%".$searchText."%'
OR SupplierCode LIKE '%".$searchText."%'
OR DateOfPurchase LIKE '%".$searchText."%'
OR DateOfCommison LIKE '%".$searchText."%'
OR AssetStatus LIKE '%".$searchText."%'
OR BaseT.CreatedDate LIKE '%".$searchText."%'
)";
)";
$this->db->where($likeCriteria);
}
//$this->db->where('BaseT.isDeleted', 0);
//$this->db->where('BaseT.userId !=', 1);
$this->db->limit($page, $segment);
$query = $this->db->get();
@ -79,29 +72,52 @@ class assetdetails_model extends CI_Model
}
function getDepartment()
function getDepartment($Department = '')
{
$ConfigID = 'C005';
$this->db->select('ConfigValue');
$this->db->from('T_ConfigDetails');
$this->db->where('Config_id ',$ConfigID );
$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()
function getSupplierName($SupplierID = '')
{
$this->db->select('SupplierID, SupplierName');
$this->db->from('T_SupplierDetailsN');
// $this->db->where('Address');
//$this->db->where('roleId !=', 1);
$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
@ -112,7 +128,7 @@ class assetdetails_model extends CI_Model
function addNewasset($asset)
{
$this->db->trans_start();
$this->db->insert('T_AssetDetails', $asset);
$this->db->insert('T_Asset_Details', $asset);
$Asset_Code = $this->db->insert_id();
@ -122,48 +138,40 @@ function addNewasset($asset)
}
/**
* This function used to get user information by id
* @param number $userId : This is user id
* @return array $result : This is user information
* 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 getuserInfo($Asset_Code)
function getAssetDetails($Asset_Code)
{
$this->db->select('Asset_Code, Asset_Name,Description,Department,Location,User,SupplierName,DateOfPurchase,DateOfCommission,AssetValue,Createdby,CreatedDate');
$this->db->from('T_AssetDetails');
//$this->db->where('isDeleted', 0);
//$this->db->where('roleId !=', 1);
$this->db->where('Asset_Code', $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('Asset_Code', $Asset_Code);
$this->db->update('T_AssetDetails', $asset);
$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('Asset_Code', $Asset_Code);
$this->db->update('T_AssetDetails', $asset);
$this->db->where('AssetCode', $Asset_Code);
$this->db->update('T_Asset_Details', $asset);
return TRUE;
}
/**
* This function is used to delete the user information
* @param number $userId : This is user id
* @return boolean $result : TRUE / FALSE
function deletePO($PO, $POinfo)
{
$this->db->where('PO', $PO);
$this->db->update('T_PurchaseOrderDetails', $POInfo);
return $this->db->affected_rows();
}*/
}
?>