ria/application/controllers/configurationctrl.php
gandhimathi Bharathirajan e2ec75f3f6 ALL
2017-11-16 18:34:33 +05:30

173 lines
5.3 KiB
PHP

<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
require APPPATH . '/libraries/BaseController.php';
/**
* Class : Supplier Controller (supplier)
* User Class to control all user related operations.
* @author : Surendar
* @version : 1.1
* @since : 26 July 2017
*/
class configurationctrl extends BaseController
{
/**
* This is default constructor of the class
*/
public function __construct()
{
parent::__construct();
$this->load->library('form_validation');
$this->load->model('configmodel');
$this->isLoggedIn();
}
public function index()
{
$this->global['pageTitle'] = 'Siddharth : Supplier';
$this->loadViews("configlisting", $this->global, NULL , NULL);
}
function configlisting()
{
$this->load->model('configmodel');
$searchText = $this->input->post('searchText');
$data['searchText'] = $searchText;
//$count = $this->configmodel->departmentListingCount($searchText);
//$returns = $this->paginationCompress ( "configlisting/", $count, 20 );
$data['userRecords'] = $this->configmodel->configlisting();
$this->global['pageTitle'] = 'Siddharth Industries : config Listing';
$this->loadViews("configlisting", $this->global, $data, NULL);
}
function addconfig()
{
$this->global['pageTitle'] = 'siddharth : AddNew Department';
$this->loadViews("addconfig", $this->global,NULL, NULL);
}
function addNewconfig()
{
// $Configid = $this->input->post('Configid');
$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('Config_ID'=>$Configid,'ConfigName'=>$ConfigName, 'Comments'=>$Comments);
$config = array('ConfigName'=>$ConfigName, 'Comments'=>$Comments);
$result = $this->configmodel->addconfigmaster($config);
//print_r($result);
//echo $id;die();
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
//echo "successfully created:".$ConfigID;
if($result > 0)
{
redirect('configurationctrl/configlisting','refresh');
echo "<script>alert('New Supplier Created successfully!');</script>";
}
else
{
redirect('configurationctrl/configlisting','refresh');
echo "<script>alert('department Record Not Created!');</script>";
}
}
function editOldconfig($ConfigID = '')
{
$ConfigID = $_GET['ConfigID'];
$data['master'] = $this->configmodel->GetConfigCenterMaster($ConfigID);
$data['child'] = $this->configmodel->GetConfigCenterDetails($ConfigID);
$index = 1;
// $index = $index + 1;
$this->global['pageTitle'] = 'Siddharth : Edit Cost';
$this->loadViews("editconfig", $this->global, $data,NULL);
//}
}
function configedit()
{
$Configid = $this->input->post('Configid');
$ConfigName = $this->input->post('ConfigName');
$Comments = $this->input->post('Remarks');
$Rowcount = $this->input->post('txtRowCount');
//echo $Rowcount;die();
//$ConfigValue = $this->input->post('ConfigValue');
$config = array('Config_ID'=>$Configid,'ConfigName'=>$ConfigName, 'Comments'=>$Comments);
//print_r($config);die();
$result = $this->configmodel->updateconfig($config,$Configid);
// if(count($config)>0)
// {
for($i=1;$i<=$Rowcount;$i++)
{
// echo $i;
$Key = $this->input->post('DbKey'.$i);
$conid = $this->input->post('configID'.$i);
$ConfigValue = $this->input->post('configVal'.$i);
//print_r($Key);die();
// echo $conid . "-" . $ConfigValue;
$configval = array('ConfigValue'=>$ConfigValue);
// print_r($configval);die();
$result = $this->configmodel->updateconfigvalue($configval,$Key);
}
//}
//$print_r($result);die();
if($result == True)
{
redirect('configlisting','refresh');
echo "<script>alert('Supplier department successfully!');</script>";
}
else
{
redirect('configlisting','refresh');
echo "<script>alert('department Record Not updated!');</script>";
}
}
}
?>