Cost center

This commit is contained in:
gandhimathi Bharathirajan 2017-05-05 16:16:50 +05:30
parent f75cbb9f87
commit d7df68dd70

View File

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