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

class Log extends MY_Controller {
	
	function __construct()
	{
		parent::__construct();
		
		$this->title = 'USER ACTIVITY';
		$this->load->model('log_mdl','mdl');
	}
	
	public function index()
	{		
		$data = array(
			'content' 	=> 	'log/log_frm',
			);		
		$this->load('tpl',$data['content'], $data);
		$this->load->view('log/log_frm_cjs');
		$this->load->view('log/log_frm_mjs');
		
	}
	
	function grid(){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getAll($page,$rows,$key);
		
		echo json_encode($rs);
	}
	
	function cetak()
	{
		ini_set('memory_limit', '-1');
		
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		
		$data = array(
			'rs' 	=> 	$this->mdl->getAll($page,$rows,$key),
		);	
		
		$this->load->view('log/print',$data);
		
	}
	
	function excel()
	{
		ini_set('memory_limit', '-1');
		
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		
		$data = array(
			'rs' 	=> 	$this->mdl->getAll($page,$rows,$key),
		);
		
		$filename ="User Activity.xls";
		header('Content-type: application/ms-excel');
		header('Content-Disposition: attachment; filename='.$filename);
		$this->load->view('log/print',$data);
	}
}