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

class Rmonwip1 extends MY_Controller {
	
	function __construct()
	{
		parent::__construct();
		
		$this->modul = "rmonwip1";
		$this->title = "WIP SB";
		$this->mat_type = "1";
		$this->tp_barang = '1';
		
		$this->load->model($this->modul.'_mdl','mdl');
	}
	
	public function index()
	{		
		$data = array(
			'content' 	=> 	$this->modul.'/'.$this->modul,
			);		
		$this->load('tpl',$data['content'], $data);
		$this->load->view($this->modul.'/'.$this->modul.'_cjs');
		$this->load->view($this->modul.'/'.$this->modul.'_mjs');
		
	}
	
	function aksi($cmd)
	{
		ini_set('memory_limit', '-1');
		
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$dtdari = $_REQUEST["dtdari"];
		$dtsampai = $_REQUEST["dtsampai"];
		$kd_cmpy = $_REQUEST["kd_cmpy"];
		$rs = $this->mdl->getAll2($page,$rows,$key,$dtdari,$dtsampai,$kd_cmpy);
		
		if ($cmd=='cari'){
			echo json_encode($rs);
		} else {
			$data = array(
				'title' => 	$this->title,
				'dtdari' => $dtdari,
				'dtsampai' => $dtsampai,
				'rs' 	=> 	$rs
			);	
			
			if ($cmd=='excel'){
				$filename ="Laporan ".$this->title.".xls";
				header('Content-type: application/ms-excel');
				header('Content-Disposition: attachment; filename='.$filename);
			}
			$this->load->view($this->modul.'/print',$data);
		}
		
	}
}