Cost center

This commit is contained in:
gandhimathi Bharathirajan 2017-05-04 18:53:41 +05:30
parent dff4fb7bc7
commit b3cccd4ab5

View File

@ -36,8 +36,7 @@ class costcenter_model extends CI_Model
{
$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."%'
@ -62,15 +61,52 @@ class costcenter_model extends CI_Model
function addNewcost($Cost)
{
$this->db->trans_start();
$this->db->insert('T_CostCentre', $Cost);
$this->db->insert('T_CostCenter_Master', $Cost);
$insert_id = $this->db->insert_id();
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
return $insert_id;
$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
@ -95,18 +131,78 @@ function addNewcost($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)
function DeleteBudget($BudgetType='',$BudgetYear='',$CostCenterCode ='')
{
$this->db->where('CostCentreID', $CostCenterID);
$this->db->update('T_CostCentre', $Cost);
$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 $this->db->affected_rows();
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();
}
}
?>