112 lines
4.0 KiB
PHP
112 lines
4.0 KiB
PHP
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class costcenter_model extends CI_Model
|
|
{
|
|
/**
|
|
* This function is used to get the user listing count
|
|
* @param string $searchText : This is optional search text
|
|
* @return number $count : This is row count
|
|
*/
|
|
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->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');
|
|
//$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.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_CostCentre', $Cost);
|
|
|
|
$insert_id = $this->db->insert_id();
|
|
|
|
$this->db->trans_complete();
|
|
|
|
return $insert_id;
|
|
}
|
|
|
|
/**
|
|
* 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;
|
|
}
|
|
|
|
/**
|
|
* This function is used to delete the user information
|
|
* @param number $userId : This is user id
|
|
* @return boolean $result : TRUE / FALSE
|
|
*/
|
|
function deletecost($Cost, $CostCenterID)
|
|
{
|
|
$this->db->where('CostCentreID', $CostCenterID);
|
|
$this->db->update('T_CostCentre', $Cost);
|
|
|
|
return $this->db->affected_rows();
|
|
}
|
|
}
|
|
?>
|