ria/application/models/configmodel.php
venbatechnologies@gmail.com b1c8fe52a4 issues fixes
2018-07-12 12:34:06 +05:30

208 lines
6.7 KiB
PHP
Executable File

<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class configmodel extends CI_Model
{
/**
* To get the Config listing
* @return array $result : result of the query(returns config information)
*/
function Configlisting()
{
$this->db->select('Config.Config_ID, Config.ConfigName ,Config.Comments,Config.CreatedDate');
$this->db->from('T_ConfigMaster as Config');
$this->db->order_by('Config.CreatedDate','desc');
$query = $this->db->get();
$result = $query->result();
return $result;
}
/**
* To store config master information by configid
* @param number $config : This will have all the config information
* @var $insert_id : This will return how many value are inserted (return as count in numbers)
* @return array $res->result_array() :This will return maximum of Configid for config lineitem table
*/
function addconfigmaster($config)
{
$this->db->trans_start();
$this->db->insert('T_ConfigMaster', $config);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
$sql='SELECT MAX(Config_ID) as Config_ID FROM T_ConfigMaster';
$res = $this->db->query($sql);
return $res->result_array();
}
/**
* To store config details information
* @param number $configvalue : This will have all the config information
* @return number $insert_id : This will return how many value are inserted (return as count in numbers)
*/
function addconfigdetails($configvalue)
{
$this->db->insert('T_ConfigDetails', $configvalue);
$insert_id = $this->db->affected_rows();
return $insert_id;
}
/**
* To get department list which is not available in the Costcenter master
* @param number $CostCenterCode : This is CostCode
* @return array $query->result() : This is result of the query
*/
function GetBudgetTypeNotinCostCenter($CostCenterCode,$ConfigID)
{
$subQuery = 'select ConfigValue from T_ConfigDetails Bud where ConfigValue not in
(select BudgetType from T_CostCenter_Budget where CostCenterCode=? and BudgetYear=(select max(BudgetYear) from T_CostCenter_Budget)) and Config_ID=?';
$query = $this->db->query($subQuery, array($CostCenterCode,$ConfigID));
return $query->result();
}
/**
* To get the config master values
* @param number $ConfigID : This is ConfigID
* @return array $query->result() : This is result of the query
*/
function GetConfigCenterMaster($ConfigID='')
{
$this->db->select('*' );
$this->db->from('T_ConfigMaster ');
$this->db->where('Config_ID', $ConfigID);
$query = $this->db->get();
return $query->result();
}
/**
* To get the config detail values
* @param number $ConfigID : This is ConfigID
* @return array $query->result() : This is result of the query (config master information)
*/
function GetConfigCenterDetails($ConfigID='')
{
$this->db->select('*' );
$this->db->from('T_ConfigMaster COM');
$this->db->join('T_ConfigDetails con','con.Config_ID = COM.Config_ID','left');
$this->db->where('COM.Config_ID', $ConfigID);
$query = $this->db->get();
return $query->result();
}
/**
* To update the config master information
* @param number $configid : This is ConfigID
* @param array $Config : This will have all the edited config information
*/
function updateconfig($config,$Configid)
{
$this->db->where('Config_ID', $Configid);
$this->db->update('T_ConfigMaster', $config);
return TRUE;
}
/**
* To update the config detail information
* @param number $Key : This is key value
* @param array $Configval : This will have all the edited config information
*/
function updateconfigvalue($configval,$Key)
{
$this->db->where('Key', $Key);
$this->db->update('T_ConfigDetails', $configval);
return TRUE;
}
/**
* To store the costcenters budget detail
* @param number $Budget : This will have all edited budget datas
* @return number $insert_id : This will return how many value are inserted (return as number/count)
*/
function EditBudget($Budget)
{
$this->db->trans_start();
$this->db->insert('T_CostCenter_Budget', $Budget);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
return $insert_id;
}
/**
* To delete costcenter's budget information by using budget type , budget year and costcenter id
* @param number $BudgetType : This is budget type
* @param number $BudgetYear : This is budget year
* @param number $CostCenterCode : This is cost code
*/
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');
}
/**
* To delete costcenter's department information by using department code and costcenter id
* @param number $Depcode : Optional : This is department code
* @param number $CostCode : Optional :This is costcenter code
*/
function DeleteDepartment($DepCode='',$CostCode='')
{
$this->db->where("DEPCode", $DepCode);
$this->db->where("CostCenterCode", $CostCode);
$this->db->delete('T_CostCenter_Departments');
}
/**
* To get costcenter department information by using department code and costcenter id
* @param number $Depcode : Optional : This is department code
* @param number $CostCode : Optional : This is cost code
* @return array $query->result_array() : result of the query (returns cost master information)
*/
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();
}
}
/**
* To get the Config value from configuration table
* @param number @ConfigID : This is ConfigID
* @return array $result : result of the query (returns config information)
*/
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();
}
}
?>