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

class Brpt_rekapbcp extends MY_Controller {
	
	function __construct()
	{
		parent::__construct();

		$this->module = 'brpt_rekapbcp';
		
		$this->load->model($this->module.'_mdl','mdl');
		$this->title = 'Laporan Pengeluaran Barang Per Dokumen Pabean';
		$this->title2 = 'Pemasukan RM';
	}
	
	public function index()
	{		
		$data = array(
			'title' 	=> 	$this->title,
			'content' 	=> 	'index',
			);		
		$this->load('tpl',$data['content'], $data);
		$this->load->view($this->module.'/_cjs');
		$this->load->view($this->module.'/_mjs');
		
	}
	
	function grid(){
		$dtdari = $_REQUEST["dtdari"];
		$dtsampai = $_REQUEST["dtsampai"];
		$rs = $this->mdl->getAll($dtdari,$dtsampai);
		
		echo json_encode($rs);
	}
	
	function cetak()
	{
		ini_set('memory_limit', '-1');
		
		$dtdari = $_REQUEST["dtdari"];
		$dtsampai = $_REQUEST["dtsampai"];
		
		$data = array(
			'title' => 	$this->title,
			'dtdari' => $dtdari,
			'dtsampai' => $dtsampai,
			'rs' 	=> 	$this->mdl->getAll($dtdari,$dtsampai),
		);	
		
		$this->load->view($this->module.'/print',$data);
		
	}
	
	function excel()
	{
		ini_set('memory_limit', '-1');
		
		$dtdari = $_REQUEST["dtdari"];
		$dtsampai = $_REQUEST["dtsampai"];
		
		$data = array(
			'title' => 	$this->title,
			'dtdari' => $dtdari,
			'dtsampai' => $dtsampai,
			'rs' 	=> 	$this->mdl->getAll($dtdari,$dtsampai),
		);
		
		$filename =$this->title.date('Ymd').".xls";
		header('Content-type: application/ms-excel');
		header('Content-Disposition: attachment; filename='.$filename);
		$this->load->view($this->module.'/print',$data);
	}
}