load->library('form_validation'); $this->load->model('configmodel'); $this->isLoggedIn(); $this->CompanyName = $this->global['CompanyName']; } /** * Index Page for this controller(default function of the class) */ public function index() { //$this->global['pageTitle'] = 'Resico : Config Details'; $this->global['pageTitle'] = $this->CompanyName.' : Config Details'; $this->loadViews("configlisting", $this->global, NULL , NULL); } /** * To load the configuration details as list */ function configlisting() { $this->load->model('configmodel'); $data['userRecords'] = $this->configmodel->configlisting(); //$this->global['pageTitle'] = 'Resico : Config Listing'; $this->global['pageTitle'] = $this->CompanyName.' : Config Listing'; $this->loadViews("configlisting", $this->global, $data, NULL); } /** * To load the add new config */ function addconfig() { //$this->global['pageTitle'] = 'Resico : Add New Config'; $this->global['pageTitle'] = $this->CompanyName.' : Add New Config'; $data['userRecords'] = $this->configmodel->configlisting(); $this->loadViews("addconfig", $this->global,NULL, NULL); } /** * To add new config */ function addNewconfig() { $ConfigName = $this->input->post('configurationname'); $Rowcount = $this->input->post('txtRowCount'); $Comments = $this->input->post('Comments'); $Createdby = $this->session->userdata ( 'userId' ); $chked = $this->input->post('IsActive'); if( $chked != '') { $IsActive = '1'; } else { $IsActive = '0'; } $config = array('ConfigName'=>$ConfigName, 'Comments'=>$Comments); $result = $this->configmodel->addconfigmaster($config); if(count($config)>0) { $id=$result[0]['Config_ID']; for($i=1;$i<=$Rowcount;$i++) { $ConfigValue = $this->input->post('ConfigValue'.$i); $configvalue = array('Config_ID'=>$id,'ConfigValue'=>$ConfigValue); $result = $this->configmodel->addconfigdetails($configvalue); } }//if closed if($result > 0) { redirect('configurationctrl/configlisting','refresh'); echo ""; } else { redirect('configurationctrl/configlisting','refresh'); echo ""; } } /** * For editing purpose and it has oldest values only. */ function editOldconfig($ConfigID = '') { $ConfigID = $_GET['ConfigID']; $data['master'] = $this->configmodel->GetConfigCenterMaster($ConfigID); $data['child'] = $this->configmodel->GetConfigCenterDetails($ConfigID); $index = 1; //$this->global['pageTitle'] = 'Resico : Edit Config'; $this->global['pageTitle'] = $this->CompanyName.' : Edit Config'; $this->loadViews("editconfig", $this->global, $data,NULL); } /** * To store edited config information into DB */ function configedit() { $Configid = $this->input->post('Configid'); $ConfigName = $this->input->post('ConfigName'); $Comments = $this->input->post('Remarks'); $Rowcount = $this->input->post('txtRowCount'); $config = array('Config_ID'=>$Configid,'ConfigName'=>$ConfigName, 'Comments'=>$Comments); $result = $this->configmodel->updateconfig($config,$Configid); for($i=1;$i<=$Rowcount;$i++) { $Key = $this->input->post('DbKey'.$i); $conid = $this->input->post('configID'.$i); $ConfigValue = $this->input->post('configVal'.$i); $configval = array('ConfigValue'=>$ConfigValue); $result = $this->configmodel->updateconfigvalue($configval,$Key); } if($result == True) { redirect('configlisting','refresh'); echo ""; } else { redirect('configlisting','refresh'); echo ""; } } } ?>