155 lines
4.6 KiB
PHP
155 lines
4.6 KiB
PHP
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
require APPPATH . '/libraries/BaseController.php';
|
|
|
|
/**
|
|
* Class : configurationctrl (Configuration Details - Controller)
|
|
* configurationctrl Class to control all configuration related operations.
|
|
* @author :Venba Info Tech - Surendar
|
|
* @version : 1.1
|
|
* @since : 18 November 2017
|
|
*/
|
|
class configurationctrl extends BaseController
|
|
{
|
|
/**
|
|
* default constructor of the class
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
|
|
$this->load->library('form_validation');
|
|
$this->load->model('configmodel');
|
|
$this->isLoggedIn();
|
|
}
|
|
|
|
/**
|
|
* Index Page for this controller(default function of the class)
|
|
*/
|
|
public function index()
|
|
{
|
|
$this->global['pageTitle'] = 'Resico : Config Details';
|
|
$this->loadViews("configlisting", $this->global, NULL , NULL);
|
|
}
|
|
|
|
/**
|
|
* To load the configuration details as list
|
|
*/
|
|
function configlisting()
|
|
{
|
|
|
|
$this->load->model('configmodel');
|
|
$this->global['pageTitle'] = 'Resico : 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->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 "<script>alert('Config Value Created successfully!');</script>";
|
|
}
|
|
|
|
else
|
|
{
|
|
redirect('configurationctrl/configlisting','refresh');
|
|
echo "<script>alert('Config Value Not Created!');</script>";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 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->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 "<script>alert('Config Value Successfully Updated!');</script>";
|
|
}
|
|
else
|
|
{
|
|
redirect('configlisting','refresh');
|
|
echo "<script>alert('Config Value Not Updated!');</script>";
|
|
}
|
|
}
|
|
}
|
|
?>
|