<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class System_configuration extends MY_Controller{
	public function index(){
		$this->load->model("setting_model");
		
		$data = array();
		
		$setting_array = $this->setting_model->get_data(array(
			'additional_select' => "CREATE_USER.CODE AS CREATE_USER_CODE, CREATE_USER.NAME AS CREATE_USER_NAME, MODIFY_USER.CODE AS MODIFY_USER_CODE, MODIFY_USER.NAME AS MODIFY_USER_NAME",
			'' => "",
		));
		if(count($setting_array) > 0) $data['setting'] = $setting_array[0];
		
		$this->load->view($this->router->fetch_class()."/index", $data);
	}
	
	public function update(){
		$this->load->model("setting_model");
		$post = $this->input->post();
		
		//To prevent loss---
		$this->fm->keep_all_page_filter();
		//------------------
		
		if($this->setting_model->edit($post)){
			$this->session->set_flashdata('success', "Update Successful!");
		}
		else{
			$this->session->set_flashdata('error', "Update Failed!");
		}
		
		redirect(base_url($this->router->fetch_class()));
	}
}