db->select('Config.Config_ID, Config.ConfigName ,Config.Comments,Config.CreatedDate'); $this->db->from('T_ConfigMaster as Config'); // $this->db->join('t_configdetails as Con','Con.Config_ID=Config.Config_ID'); $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 addconfigmaster($config) { $this->db->trans_start(); $this->db->insert('T_ConfigMaster', $config); $insert_id = $this->db->affected_rows(); $this->db->trans_complete(); //return $insert_id; $sql='SELECT MAX(Config_ID) as Config_ID FROM T_ConfigMaster'; $res = $this->db->query($sql); return $res->result_array(); } function addconfigdetails($configvalue) { //print_r($configvalue); // $this->db->trans_start(); $this->db->insert('T_ConfigDetails', $configvalue); $insert_id = $this->db->affected_rows(); // $this->db->trans_complete(); // print_r( $this->db->last_query()); //print_r ($insert_id);die(); return $insert_id; } /* This function used to Department list which is not available in the Costcenter master * @param number $CostCenterCode : CostCenterCode as Parameter * @return array $result : This is user information */ 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)); // print_r($this->db->last_query()); return $query->result(); } function GetConfigCenterMaster($ConfigID='') { //echo $ConfigID ;die(); $this->db->select('*' ); $this->db->from('T_ConfigMaster '); //$this->db->join('T_ConfigDetails con','con.Config_ID = COM.Config_ID','left'); $this->db->where('Config_ID', $ConfigID); $query = $this->db->get(); return $query->result(); } function GetConfigCenterDetails($ConfigID='') { //echo $ConfigID ;die(); $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(); } function updateconfig($config,$Configid) { $this->db->where('Config_ID', $Configid); $this->db->update('T_ConfigMaster', $config); return TRUE; } function updateconfigvalue($configval,$Key) { $this->db->where('Key', $Key); $this->db->update('T_ConfigDetails', $configval); return TRUE; } function EditBudget($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 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(); } } /** * 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(); } } ?>