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

class Setting extends CI_Controller {
	public function __construct(){
		parent::__construct();
		$this->load->library('layouts');
		
		checkDashboard();
		$this->session->set_userdata('menu', "setting");
		
	}
	
	public function index(){
		
		$this->lang->load("setting",$this->session->userdata('language'));
		
		$this->load->model('setting_model');
		
		$data['reportsetting'] = $this->setting_model->setting_all();
			
		$this->layouts->view('setting', array(), $data);
		

	}
	
	
	public function saveSetting(){
		
		$this->load->model('Gallery_report');
		
		
		$reportID = $this->input->post('reportID');
		
		$header_report = $this->input->post('header_report');
		$logo_report = $this->input->post('report_picture');
		
		$this->load->model('setting_model');
				
		if($reportID){
			
				$data = array(
					'header_report' => $header_report,
					'projectID' => $this->session->userdata('projectID'),
				);
			
			$updateSetting = $this->setting_model->update('report_setting', $reportID, $data);
			$image_name = $this->Gallery_report->do_upload($reportID);
		}
		else{
			
				$data = array(
					'header_report' => $header_report,
					'projectID' => $this->session->userdata('projectID'),
					'logo_report' => ".jpg"
				);
			
			$insertSetting = $this->setting_model->insert('report_setting', $data);
			$image_name = $this->Gallery_report->do_upload($insertSetting);
		}
		
		redirect('setting', 'refresh');
		

	}
	
	
	
	
	
	
}

?>