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

class Main extends MY_Controller
{

	function __construct()
	{
		parent::__construct();

		$this->title = "-";
		$this->auth->auth_main();
		$this->load->model('main_mdl', 'mdl');
	}

	// public function index()
	// {
	//   $this->load->view("main"); 
	// }

	public function index()
	{
		$data = array(
			'content' => 'main/warning'
		);
		$this->load('main', $data['content'], $data);
		$this->load->view('main/_cjs');
		$this->load->view('main/_mjs');
	}

	// public function warning()
	 function warning()
	{
		$data = array(
			'content' => 'main/warning'
		);

		// $data['so'] = $this->mdl->PendingSoGrafik();
		// $data['po'] = $this->mdl->PendingPoGrafik();
		// $data['ig'] = $this->mdl->IncomingGrafik();
		// $data['og'] = $this->mdl->OutgoingGrafik();
		// $data['bc'] = $this->mdl->getDataBC();
		$this->load('tpl', $data['content'], $data);
		// $this->load->view('main/_cjs');
		// $this->load->view('main/_mjs');
	
	}

	function datacombotop()
	{
		$rs = $this->mdl->getDataTopAll();
		echo json_encode($rs);
	}

	function datagridpo()
	{
		$rs = $this->mdl->getDataPo();
		echo json_encode($rs);
	}

	function datagridso()
	{
		$rs = $this->mdl->getDataSo();
		echo json_encode($rs);
	}

	function datagridbc()
	{
		$rs = $this->mdl->getDataBeacukai();
		echo json_encode($rs);
	}


	function logout()
	{
		$username = $this->session->userdata('username');
		$ketlog="$username logout.";
		$this->mdl->addLog('',$ketlog);
		$this->session->sess_destroy();
		echo "<SCRIPT>parent.location='" . site_url('login') . "'</SCRIPT>";
	}
}
