<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class General extends MY_Controller {	
	function __construct()
	{
		parent::__construct();
		
		$this->load->model('general_mdl','mdl');
	}
	
	function getMenuId(){
		$data=array(
			'menu_id'=>$_REQUEST['menu_id'],
			'l'=>$_REQUEST['l'],
			't'=>$_REQUEST['t'],
			'u'=>$_REQUEST['u'],
			'h'=>$_REQUEST['h']
		);
		$this->session->set_userdata($data);
		
		if ($this->session->userdata('l')=='1'){
			echo 1;
		}
	}
	
	function genBarcode($str)
	{		
		$this->load->library('pdf');
		require_once(dirname(dirname(dirname(dirname(__FILE__)))).'/libraries/tcpdf_barcodes_1d_includek.php');
		// set the barcode content and type
		$barcodeobj = new TCPDFBarcode($str, 'C39');
		
		// output the barcode as PNG image
		$barcodeobj->getBarcodePNG(2, 30, array(0,0,0));
		
	}
	
	function getTabName(){
		$this->session->set_flashdata('tabname', $_REQUEST['tabname']);
	}
	function gridTpPrshn(){
		$rs = $this->mdl->getTpPrshn();
		echo json_encode($rs);
	}
	
	function gridNegara(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getNegara($key);
		echo json_encode($rs);
	}
	function gridGroupId(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getGroupId($key);
		echo json_encode($rs);
	}
	
	function gridValuta(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getValuta($key);
		echo json_encode($rs);
	}
	function gridValuta2(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getValuta2($key);
		echo json_encode($rs);
	}
	function gridAR(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getAR($key);
		echo json_encode($rs);
	}
	function gridARList(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getARList($key);
		echo json_encode($rs);
	}
	function gridAP(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getAP($key);
		echo json_encode($rs);
	}
	function gridAPList(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getAPList($key);
		echo json_encode($rs);
	}
	function gridBR(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getBR($key);
		echo json_encode($rs);
	}
	function gridCR(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getCR($key);
		echo json_encode($rs);
	}
	function gridBP(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getBP($key);
		echo json_encode($rs);
	}
	function gridCP(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getCP($key);
		echo json_encode($rs);
	}
	function gridAPCash(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getAPCash($key);
		echo json_encode($rs);
	}
	function gridCash(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getCash($key);
		echo json_encode($rs);
	}
	
	function gridInv(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getInv($key);
		echo json_encode($rs);
	}
	
	function gridIncFgJournalC(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getIncFgJournalC($key);
		echo json_encode($rs);
	}
	
	function gridIncFgJournalD(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getIncFgJournalD($key);
		echo json_encode($rs);
	}
	function gridWipJournalC(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getWipJournalC($key);
		echo json_encode($rs);
	}
	
	function gridWipJournalD(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getWipJournalD($key);
		echo json_encode($rs);
	}
	
	function gridOutFgJournalC(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getOutFgJournalC($key);
		echo json_encode($rs);
	}
	function gridOutFgJournalD(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getOutFgJournalD($key);
		echo json_encode($rs);
	}
	function gridOutMatJournalC(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getOutMatJournalC($key);
		echo json_encode($rs);
	}
	function gridOutMatJournalD(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getOutMatJournalD($key);
		echo json_encode($rs);
	}
	function gridJnsDok(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getJnsDok($key);
		echo json_encode($rs);
	}
	
	function gridJnsDokIn(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getJnsDokIn($key);
		echo json_encode($rs);
	}

	function gridTipeKon(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getTipeKon($key);
		echo json_encode($rs);
	}



	function gridkantor(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getgridkantor($key);
		echo json_encode($rs);
	}

	function gridBendera(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getgridbendera($key);
		echo json_encode($rs);
	}

	function gridDok(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getDok($key);
		echo json_encode($rs);
	}

	function gridJenisKon(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getJenisKon($key);
		echo json_encode($rs);
	}
	function gridUkuranKon(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getUkuranKon($key);
		echo json_encode($rs);
	}
	
	function gridJnsDokOut(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getJnsDokOut($key);
		echo json_encode($rs);
	}
	
	function gridInTypeAll($id = null){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getInTypeAll($key, $id);
		echo json_encode($rs);
	}
	
	function gridInType($id = null){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getInType($key, $id);
		echo json_encode($rs);
	}
	function gridInTypeSk(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getInTypeSk($key);
		echo json_encode($rs);
	}
	
	function gridInTypeScrap(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getInTypeScrap($key);
		echo json_encode($rs);
	}
	
	function gridInTypeWh(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getInTypeWh($key);
		echo json_encode($rs);
	}
	
	function gridInTypeProd(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getInTypeProd($key);
		echo json_encode($rs);
	}
	
	function gridInTypeQc(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getInTypeQc($key);
		echo json_encode($rs);
	}
	
	function gridInTypeFg(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getInTypeFg($key);
		echo json_encode($rs);
	}
	
	function gridOutTypeAll($id = null){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getOutTypeAll($key, $id);
		echo json_encode($rs);
	}
	function gridOutType($id = null){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getOutType($key,$id);
		echo json_encode($rs);
	}
	
	function gridOutTypeScrap(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getOutTypeScrap($key);
		echo json_encode($rs);
	}
	
	function gridOutTypeWh(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getOutTypeWh($key);
		echo json_encode($rs);
	}
	
	function gridOutTypeProd(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getOutTypeProd($key);
		echo json_encode($rs);
	}
	
	function gridOutTypeDo(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getOutTypeDo($key);
		echo json_encode($rs);
	}
	
	function gridPacking(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getPacking($key);
		echo json_encode($rs);
	}
	function gridColor($key){
		if ($key==""){
			$key=$_REQUEST['q'];
		}
		$rs = $this->mdl->getColor($key);
		echo json_encode($rs);
	}
	
	function gridSize(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getSize($key);
		echo json_encode($rs);
	}
	
	function gridProd(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getProd($key);
		echo json_encode($rs);
	}
	
	function gridProdGudang(){
		$key=$_REQUEST['q'];
		$rs = $this->mdl->getProdGudang($key);
		echo json_encode($rs);
	}
	
	function getProdTo(){
		$key=$_REQUEST['q'];
		$fgout_type=$_REQUEST['fgout_type'];
		$prod_from=$_REQUEST['prod_from'];
		$rs = $this->mdl->getProdTo($key,$fgout_type,$prod_from);
		echo $rs;
	}
	function gridBom($bom_type){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getBom($page,$rows,$key,$bom_type);
		
		echo json_encode($rs);
	}
	function gridBomAll(){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getBomAll($page,$rows,$key);
		
		echo json_encode($rs);
	}
	
	function gridBarang($tp_barang){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getBarang($page,$rows,$key,$tp_barang);
		
		echo json_encode($rs);
	}

		
	function gridBarang2(){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getBarang2($page,$rows,$key);
		
		echo json_encode($rs);
	}

	function gridBarangMatsup(){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getBarangMatsupOpn($page,$rows,$key);
		
		echo json_encode($rs);
	}
	function gridBarangBOMFG(){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getBarangBOMFG($page,$rows,$key);
		
		echo json_encode($rs);
	}
	function gridBarangDETBOMFGP(){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getBarangDETBOMFGP($page,$rows,$key);
		
		echo json_encode($rs);
	}
	function gridBarangBOMWIP(){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getBarangBOMWIP($page,$rows,$key);
		
		echo json_encode($rs);
	}
	function gridBarangMSO(){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getBarangMSO($page,$rows,$key);
		
		echo json_encode($rs);
	}
	function gridBarangNGOUT(){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getBarangNGOUT($page,$rows,$key);
		
		echo json_encode($rs);
	}
	function gridBarangNGOUTMAT(){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getBarangNGOUTMAT($page,$rows,$key);
		
		echo json_encode($rs);
	}
	function gridBarangFGIN(){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getBarangFGIN($page,$rows,$key);
		
		echo json_encode($rs);
	}
	function gridBarangFGIN_NP(){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getBarangFGIN_NP($page,$rows,$key);
		
		echo json_encode($rs);
	}
	function gridBarangFGINP(){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getBarangFGINP($page,$rows,$key);
		
		echo json_encode($rs);
	}
	function gridBarangScrap(){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getBarangScrap($page,$rows,$key);
		
		echo json_encode($rs);
	}
	function gridBarangPoAll(){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getBarangPoAll($page,$rows,$key);
		
		echo json_encode($rs);
	}
	function gridBarangSMT($tp_barang){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getBarangSMT($page,$rows,$key,$tp_barang);
		
		echo json_encode($rs);
	}
	function gridBarangCB($tp_barang){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getBarangCB($page,$rows,$key,$tp_barang);
		
		echo json_encode($rs);
	}
	function gridBomSMT(){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getBomSMT($page,$rows,$key);
		
		echo json_encode($rs);
	}
	function gridBarangML($tp_barang){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getBarangML($page,$rows,$key,$tp_barang);
		
		echo json_encode($rs);
	}
	function gridBomCB(){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getBomCB($page,$rows,$key);
		
		echo json_encode($rs);
	}
	function gridMaterialML(){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getMaterialML($page,$rows,$key);
		
		echo json_encode($rs);
	}
	function gridBarangDO($do_id){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getBarangDO($page,$rows,$key,$do_id);
		
		echo json_encode($rs);
	}
	function gridBarangPO($po_id){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getBarangPO($page,$rows,$key,$do_id);
		
		echo json_encode($rs);
	}
	function gridBarangSO($ref_id){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getBarangPO($page,$rows,$key,$ref_id);
		
		echo json_encode($rs);
	}
	function gridBarangIN($ref_id){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getBarangIN($page,$rows,$key,$ref_id);
		
		echo json_encode($rs);
	}
	function gridPO($po_type = '0'){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getPO($page,$rows,$key,$po_type);
		
		echo json_encode($rs);
	}
	function gridPOmc(){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getPOmc($page,$rows,$key);
		
		echo json_encode($rs);
	}
	function gridPOrms(){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getPOrms($page,$rows,$key);
		
		echo json_encode($rs);
	}
	function gridPOSc(){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getPOSc($page,$rows,$key);
		
		echo json_encode($rs);
	}
	function gridDO(){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getDO($page,$rows,$key);
		
		echo json_encode($rs);
	}
	function gridIN(){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getIN($page,$rows,$key);
		
		echo json_encode($rs);
	}
	function gridBomWipIn($ref_type = '0'){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;	
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getBomWipIn($page,$rows,$key,$ref_type);
		
		echo json_encode($rs);
	}
	
	function getStockLot(){
		$post_data=$_REQUEST;
		$rs = $this->mdl->getStockLot($post_data);
		echo $rs;
	}
	function gridLine(){
		$rs = $this->mdl->getLine();
		echo json_encode($rs);
	}

	function gridOpname(){
		$rs = $this->mdl->getOpname();
		echo json_encode($rs);
	}

	function gridInco(){
		$rs = $this->mdl->getInco();
		echo json_encode($rs);
	}
	function dataOutHdr(){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 100;
		$key = $_REQUEST["q"];
		$rs = $this->mdl->getOutHdr($page,$rows,$key);
		echo json_encode($rs);
	}
}
