diff --git a/application/models/costcenter_model.php b/application/models/costcenter_model.php index e44184e1..258afd2c 100644 --- a/application/models/costcenter_model.php +++ b/application/models/costcenter_model.php @@ -9,20 +9,23 @@ class costcenter_model extends CI_Model */ function CostListingCount($searchText = '') { - $this->db->select('BaseT.CostCentreID, BaseT.CostName, BaseT.Description, BaseT.CreatedDate'); - $this->db->from('T_CostCentre as BaseT'); - //$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.CostCentreID LIKE '%".$searchText."%' - OR BaseT.CostName LIKE '%".$searchText."%' - OR BaseT.Description LIKE '%".$searchText."%')"; + $this->db->select('Cost.CostCenterCode,Cost.CostCenterName, Cost.ApprovedBy,Emp.FirstName,Emp.Designation '); + $this->db->from('T_CostCenter_Master Cost'); + $this->db->join('T_Employee_Details as Emp', 'Emp.EmpID=Cost.ApprovedBy'); + + if(!empty($searchText)) { + $likeCriteria = "( Cost.CostCenterCode LIKE '%".$searchText."%' + OR Cost.CostCenterName LIKE '%".$searchText."%' + OR Cost.ApprovedBy LIKE '%".$searchText."%' + OR Emp.FirstName LIKE '%".$searchText."%' + OR Emp.Designation LIKE '%".$searchText."%' + )"; $this->db->where($likeCriteria); } //$this->db->where('BaseT.isDeleted', 0); //$this->db->where('BaseT.userId !=', 1); $query = $this->db->get(); - + //print_r($this->db->last_query()); return count($query->result()); } /** @@ -34,23 +37,26 @@ class costcenter_model extends CI_Model */ function CostListing($searchText = '', $page, $segment) { - $this->db->select('BaseT.CostCentreID, BaseT.CostName, BaseT.Description,BaseT.CreatedDate'); - $this->db->from('T_CostCentre as BaseT'); - - if(!empty($searchText)) { - $likeCriteria = "(BaseT.CostCentreID LIKE '%".$searchText."%' - OR BaseT.CostName LIKE '%".$searchText."%' - OR BaseT.CreatedDate LIKE '%".$searchText."%' - OR BaseT.Description LIKE '%".$searchText."%')"; + $this->db->select('Cost.CostCenterCode as code,Cost.CostCenterName as CostCenterName , Cost.ApprovedBy as ApprovedBy,Emp.FirstName as FirstName,Emp.Designation as Designation '); + $this->db->from('T_CostCenter_Master as Cost'); + $this->db->join('T_Employee_Details as Emp', 'Emp.EmpID=Cost.ApprovedBy'); + + if(!empty($searchText)) { + $likeCriteria = "( Cost.CostCenterCode LIKE '%".$searchText."%' + OR Cost.CostCenterName LIKE '%".$searchText."%' + OR Cost.ApprovedBy LIKE '%".$searchText."%' + OR Emp.FirstName LIKE '%".$searchText."%' + OR Emp.Designation 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(); - - $result = $query->result(); - return $result; + $query = $this->db->get(); + $result = $query->result(); + // print_r($this->db->last_query()); + return $result; } /** * This function used to get user information by id