<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Setting extends MY_Controller {

	public function index()
	{
		if($this->session->userdata('user_type') && ($this->session->userdata('user_type') == SUPERADMIN || $this->session->userdata('user_type') == ADMIN)) {
			redirect('setting/service_setting', 'refresh');
		}
		else {
			redirect('login', 'refresh');
		}
	}
	
	public function service_setting()
	{
		save_current_url(base_url() . 'setting/service_setting/');
		
		if($this->session->userdata('user_type') && ($this->session->userdata('user_type') == SUPERADMIN || $this->session->userdata('user_type') == ADMIN)) {
			$this->lang->load('account_general', get_language());
			
			$this->load->model('user_model');
				
			$data = $this->user_model->get_service_setting();
			
			$data['page_title'] = $this->lang->line('website_name') . ' | ' . $this->lang->line('hf_setting') . ' - ' .$this->lang->line('hf_service_setting');
			
			$this->load->view('service_setting', $data);
		}
		else {
			redirect('login', 'refresh');
		}
	}
	
	public function service_setting_submit()
	{
		if($this->session->userdata('user_type') && ($this->session->userdata('user_type') == SUPERADMIN || $this->session->userdata('user_type') == ADMIN)) {
			if($_POST) {
				$this->lang->load('account_general', get_language());
			
				$_POST['page_title'] = $this->lang->line('website_name') . ' | ' . $this->lang->line('hf_setting') . ' - ' .$this->lang->line('hf_service_setting');
			
				$this->load->model('user_model');
				
				$rs = $this->user_model->set_service_setting();
					
				if($rs) {
					redirect('setting/service_setting/', 'refresh');
				}
				else {
					$this->load->view('service_setting', $_POST);
				}
			}
			else {
				redirect('setting/service_setting/', 'refresh');
			}	
		}
		else {
			redirect('login', 'refresh');
		}
	}
}

/* End of file setting.php */
/* Location: ./application/controllers/setting.php */