db->select('*'); $this->db->from('T_Asset_Details'); 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); } //$this->db->where('BaseT.userId !=', 1); $query = $this->db->get(); return count($query->result()); } /** * 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($searchText = '', $page, $segment) { $this->db->select('*'); $this->db->from('T_Asset_Details'); 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); } $this->db->limit($page, $segment); $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; } } ?>