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->where($likeCriteria); } //$this->db->where('BaseT.isDeleted', 0); //$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 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->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; } /** * This function used to get user information by id * @param number $userId : This is user id * @return array $result : This is user information */ function addNewcost($Cost) { $this->db->trans_start(); $this->db->insert('T_CostCenter_Master', $Cost); $insert_id = $this->db->affected_rows(); $this->db->trans_complete(); return $insert_id; } function addCostCenterDepartment($Dept) { $this->db->trans_start(); $this->db->insert('T_CostCenter_Departments', $Dept); $insert_id = $this->db->affected_rows(); $this->db->trans_complete(); // print_r( $this->db->last_query()); return $insert_id; } function addBudget($Budget) { $this->db->trans_start(); $this->db->insert('T_CostCenter_Budget', $Budget); $insert_id = $this->db->affected_rows(); $this->db->trans_complete(); // print_r( $this->db->last_query()); return $insert_id; } function getApproverName() { $this->db->select('EmpID,FirstName,LastName,Designation'); $this->db->from('T_Employee_Details'); $this->db->where('Departmentcode ', 'DEP13'); $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 getuserInfo($CostCenterID) { $this->db->select('CostCentreID, CostName,Description,CreatedDate'); $this->db->from('T_CostCentre'); $this->db->where('CostCentreID', $CostCenterID); $query = $this->db->get(); return $query->result(); } function editcost($Cost, $CostCenterID) { $this->db->where('CostCentreID', $CostCenterID); $this->db->update('T_CostCentre', $Cost); return TRUE; } function DeleteBudget($BudgetType='',$BudgetYear='',$CostCenterCode ='') { $this->db->where("BudgetType", $BudgetType); $this->db->where("BudgetYear", $BudgetYear); $this->db->where("CostCenterCode", $CostCenterCode); $this->db->delete('T_CostCenter_Budget'); //print_r( $this->db->last_query()); } function DeleteDepartment($DepCode='',$CostCode='') { $this->db->where("DEPCode", $DepCode); $this->db->where("CostCenterCode", $CostCode); $this->db->delete('T_CostCenter_Departments'); //print_r( $this->db->last_query()); } function checkDeptCostExists($DepCode='',$CostCode='') { $this->db->select('CostCenterCode,DEPCode'); $this->db->from('T_CostCenter_Departments'); $this->db->where('DEPCode',$DepCode); $this->db->where('CostCenterCode',$CostCode); $query = $this->db->get(); if ($query->num_rows > 0) { return $query->result_array(); } } function checkCostDetailsExists($Code='',$CostName='') { $this->db->select('CostCenterCode'); $this->db->from('T_CostCenter_Master'); $this->db->where('CostCenterCode',$Code); if ($CostName != '') { $this->db->where('CostCenterName !=',$CostName); } $query = $this->db->get(); if ($query->num_rows > 0) { return $query->result_array(); } } /* *//** * This function is used to get the Department details from T_DepartmentDetails * @return array $result : This is result of the query */ function getDepartment() { $this->db->select('DEPCode, DepartmentName'); $this->db->from('T_DepartmentDetails'); $this->db->where('IsActive =', 1); $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 ) { $this->db->select('ConfigValue'); $this->db->from('T_ConfigDetails'); $this->db->where('Config_id ',$ConfigID ); $query = $this->db->get(); return $query->result(); } } ?>