<div id="container_repot_produksi" style="height:100%; margin:0px; padding:0px;overflow:'hidden'; border: 0px solid #cd0a0a">
	<div class="pane-header ui-state-active" id="ReportPabeanIN_bar" >   

			 <label style="margin-right:10px;">JENIS PRODUKSI</label> 
			<select id="cb_jenis_produksi" style="margin-right:10px;width:80px" >
			  <option value="RDD">RDD</option>
	 
		    <option value="MDD">MDD</option>
			  <option value="DBC">DBC</option>
		  	</select>
			 <label style="margin-right:10px;">TANGGAL:</label>
			 <input id="txttanggaldari" type="text" value='<?php echo $start_date; ?>' style="margin-right:10px;width:80px" />
<!--			 <label style="margin-right:10px;">S/D</label>
			 <input id="txttanggalsampai" type="text" value='<?php echo $end_date; ?>' style="margin-right:10px;width:80px" />
-->			
			 <button id="btnsearchreport" >SEARCH</button>
			 <button id="btnprintexcel" >PRINT XLSX</button>  
	</div>
	 <table id="tblrepotproduksi"  /><div id="ptblrepotproduksi"/> 
</div> 
 
<script> 
  $(document).ready(function(){ 
	$(window).bind('resize', function() {   
		 setTimeout(function(){
		 setGridHight($("#tblrepotproduksi"),$("#container_repot_produksi"),$("#ReportPabeanIN_bar")); 
  		},10); 
	}) ;
	 
	$("#btnsearchreport").button();
	$("#btnprintexcel").button(); 

	$( "#txttanggaldari" ).datepicker({
		dateFormat:'yy-mm-dd',
		defaultDate: "+1w",
		changeMonth: true,
		changeYear: true,
		numberOfMonths: 4,
		onClose: function( selectedDate ) {
		$( "#txttanggalsampai" ).datepicker( "option", "minDate", selectedDate );
		}
    });
	
    $( "#txttanggalsampai" ).datepicker({
		dateFormat:'yy-mm-dd',
		defaultDate: "+1w",
		changeMonth: true,
		changeYear: true,
		numberOfMonths: 4,
		onClose: function( selectedDate ) {
		$( "#txttanggaldari" ).datepicker( "option", "maxDate", selectedDate );
		}
    });
	 
	$("#btnsearchreport").click(function(){  
		var	start_date 	=	$.datepicker.formatDate('yymmdd', new Date($("#txttanggaldari").val())) ;
		var posisi_proses 	= $("#cb_jenis_produksi").val();
		jQuery('#tblrepotproduksi').jqGrid('clearGridData')
		jQuery("#tblrepotproduksi").jqGrid('setGridParam', { postData: {posisi_proses : posisi_proses , start_date : start_date} });
            
		$('#tblrepotproduksi').trigger( 'reloadGrid' );
	});
	
	
	function reportPrintrdd(format){
		var	start_date 	=	$.datepicker.formatDate('yymmdd', new Date($("#txttanggaldari").val())) ;
		var mypostdata = $('#tblrepotproduksi').getGridParam("postData").filters;
 		var tipe_bc='';
		if(mypostdata){ 
			pabean_tipe_bc = JSON.parse(mypostdata);  
			 if (pabean_tipe_bc['rules'].length>0){
					pabean_tipe_bc['rules'].forEach(function(entry) { 
						 if (entry.field=='r1');
							tipe_bc	=entry.data 
					}); 
			 }
		}
		
		var dialog = jQuery('<div />')
					 .html('<div class="ui-layout-content ui-widget-content-panel">\
									<p >Are u want to print report?</p>\
								   </div>\
									<div class="pane-footer ui-state-default"></div>\
									<form hidden id="frmPrintPabeanIN" method="POST" action="<?php echo base_url().'reports_new/CT_report_load/exportexcelrdd'; ?>"/>');  
		dialog.dialog({
				modal:true,
				width : 300, 
				height : 150,
				title :'Report Pabean Pemasukan',
				buttons: { 
					"CLOSE": function(){
						dialog.dialog("close");  
					},
					"PRINT": function() { 
					
					$("#frmPrintPabeanIN").append($("<input>").attr({"value":start_date , "name":'start_date'})); 
					$("#frmPrintPabeanIN").append($("<input>").attr({"value":end_date , "name":'end_date'})); 
					$("#frmPrintPabeanIN").append($("<input>").attr({"value":format , "name":'format'})); 
					$("#frmPrintPabeanIN").append($("<input>").attr({"value":tipe_bc , "name":'tipe_bc'}));
					$("#frmPrintPabeanIN").append($("<input>").attr({"value":$("#cb_jenis_produksi").val() , "name":'bc_type'})); 
					$("#frmPrintPabeanIN").append($("<input>").attr({"value":'aw' , "name":'source'})); 
 					$("#frmPrintPabeanIN").submit();  
					
					dialog.dialog("close");  
					}
				},
				close : function(){
					dialog.dialog('destroy').remove(); 
				},
				open: function(){
					$("body").unblock(); 
				}
			}); 
	
	} 

	
	function reportPrintmdd(format){
		var	start_date 	=	$.datepicker.formatDate('yymmdd', new Date($("#txttanggaldari").val())) ;
		var mypostdata = $('#tblrepotproduksi').getGridParam("postData").filters;
 		var tipe_bc='';
		if(mypostdata){ 
			pabean_tipe_bc = JSON.parse(mypostdata);  
			 if (pabean_tipe_bc['rules'].length>0){
					pabean_tipe_bc['rules'].forEach(function(entry) { 
						 if (entry.field=='r1');
							tipe_bc	=entry.data 
					}); 
			 }
		}
		
		var dialog = jQuery('<div />')
					 .html('<div class="ui-layout-content ui-widget-content-panel">\
									<p >Are u want to print report?</p>\
								   </div>\
									<div class="pane-footer ui-state-default"></div>\
									<form hidden id="frmPrintPabeanIN" method="POST" action="<?php echo base_url().'reports_new/CT_report_load/exportexcelin'; ?>"/>');  
		dialog.dialog({
				modal:true,
				width : 300, 
				height : 150,
				title :'Report Pabean Pemasukan',
				buttons: { 
					"CLOSE": function(){
						dialog.dialog("close");  
					},
					"PRINT": function() { 
					
					$("#frmPrintPabeanIN").append($("<input>").attr({"value":start_date , "name":'start_date'})); 
					$("#frmPrintPabeanIN").append($("<input>").attr({"value":end_date , "name":'end_date'})); 
					$("#frmPrintPabeanIN").append($("<input>").attr({"value":format , "name":'format'})); 
					$("#frmPrintPabeanIN").append($("<input>").attr({"value":tipe_bc , "name":'tipe_bc'}));
					$("#frmPrintPabeanIN").append($("<input>").attr({"value":$("#cb_jenis_produksi").val() , "name":'bc_type'})); 
					$("#frmPrintPabeanIN").append($("<input>").attr({"value":'aw' , "name":'source'})); 
 					$("#frmPrintPabeanIN").submit();  
					
					dialog.dialog("close");  
					}
				},
				close : function(){
					dialog.dialog('destroy').remove(); 
				},
				open: function(){
					$("body").unblock(); 
				}
			}); 
	
	} 

	
	

	function reportPrintdbc(format){
		var	start_date 	=	$.datepicker.formatDate('yymmdd', new Date($("#txttanggaldari").val())) ;
		var mypostdata = $('#tblrepotproduksi').getGridParam("postData").filters;
 		var tipe_bc='';
		if(mypostdata){ 
			pabean_tipe_bc = JSON.parse(mypostdata);  
			 if (pabean_tipe_bc['rules'].length>0){
					pabean_tipe_bc['rules'].forEach(function(entry) { 
						 if (entry.field=='r1');
							tipe_bc	=entry.data 
					}); 
			 }
		}
		
		var dialog = jQuery('<div />')
					 .html('<div class="ui-layout-content ui-widget-content-panel">\
									<p >Are u want to print report?</p>\
								   </div>\
									<div class="pane-footer ui-state-default"></div>\
									<form hidden id="frmPrintPabeanIN" method="POST" action="<?php echo base_url().'reports_new/CT_report_load/exportexceldbc'; ?>"/>');  
		dialog.dialog({
				modal:true,
				width : 300, 
				height : 150,
				title :'Report Pabean Pemasukan',
				buttons: { 
					"CLOSE": function(){
						dialog.dialog("close");  
					},
					"PRINT": function() { 
					
					$("#frmPrintPabeanIN").append($("<input>").attr({"value":start_date , "name":'start_date'})); 
					$("#frmPrintPabeanIN").append($("<input>").attr({"value":end_date , "name":'end_date'})); 
					$("#frmPrintPabeanIN").append($("<input>").attr({"value":format , "name":'format'})); 
					$("#frmPrintPabeanIN").append($("<input>").attr({"value":tipe_bc , "name":'tipe_bc'}));
					$("#frmPrintPabeanIN").append($("<input>").attr({"value":$("#cb_jenis_produksi").val() , "name":'bc_type'})); 
					$("#frmPrintPabeanIN").append($("<input>").attr({"value":'aw' , "name":'source'})); 
 					$("#frmPrintPabeanIN").submit();  
					
					dialog.dialog("close");  
					}
				},
				close : function(){
					dialog.dialog('destroy').remove(); 
				},
				open: function(){
					$("body").unblock(); 
				}
			}); 
	
	} 

	

	$("#btnPrintReportPabeanINPDF").button().click(function(){	 
		reportPrint('pdf');
 	})	
 	$("#btnPrintReportPabeanINXLX").button().click(function(){	
		reportPrint('xls');
 	})	
 	$("#btnprintexcel").button().click(function(){	
		var posisi_proses 	= $("#cb_jenis_produksi").val();
		alert(posisi_proses);
		if (posisi_proses == 'RDD'){
			reportPrintrdd('xlsx');
		}
		if (posisi_proses == 'MDD'){
			reportPrintmdd('xlsx');
		}
		if (posisi_proses == 'DBC'){
			reportPrintdbc('xlsx');
		}	
		
 	})	
   var arr = <?php echo json_encode($rID); ?>;
	var pabean_in_invoice = ((arr.indexOf("3110")==-1) ? '0' : '1');  
  
	jQuery("#tblrepotproduksi").jqGrid({
	    url:'<?php echo base_url().'reports_new/ct_report_data/loaddata_report_produksi'; ?>',
		mtype : "post",
		postData:{'q':'1','kode_bc':'<?php echo $kode_bc;?>','start_date':'<?php echo $start_date_grid;?>','end_date':'<?php echo $end_date_grid;?>'},
		datatype: "json",
		colNames:['JENIS', 'NOMOR', 'TANGGAL', 'NOMOR', 'TANGGAL', 'SUPPLIER', 'KODE BARANG', 'URAIAN BARANG', 'SAT', 'JUMLAH', 'NOMOR', 'TANGGAL','JUMLAH','SAT','SISA','SAT','KODE FG','NAMA FG','JUMLAH FG','SAT FG','DOKUMEN PENGELUARAN','TOTAL PENGELUARAN','SISA'],
		colModel:[
			{name:'r1',index:'r1', width:60, stype: 'select', search:true, searchoptions:{searchhidden: true, value: <?php echo json_encode($from_sub); ?>}},
	 		{name:'r2',index:'r2', width:120},  //tgldaftar
			{name:'r3',index:'r3', width:120, search: false},  // nodaftar
			{name:'r4',index:'r4', width:120},  //noinvoice
			{name:'r5',index:'r5', width:120, search: false},  //tglinvoice
			{name:'r6',index:'r6', width:140}, //supplier
			{name:'r7',index:'r7', width:70}, //kode
			{name:'r8',index:'r8', width:240},  //nama
			{name:'r9',index:'r9', width:60},  //nama
			{name:'r10',index:'r10', width:80,align:'center'}, //qty
			{name:'r11',index:'r11', width:120}, // satuan
			{name:'r12',index:'r12', width:120},  // noproduksi
			{name:'r13',index:'r13', width:120 ,align:'left'}, //tanggal produksi
			{name:'r14',index:'r14', width:60},  // jumlah 
			{name:'r15',index:'r15', width:100 ,align:'center'}, // satuan
			{name:'r16',index:'r16', width:60 ,align:'center'}, // satuan
			{name:'r17',index:'r17', width:120},  // kode finishgood
			{name:'r18',index:'r18', width:120 ,align:'left'}, //nama finishgood
			{name:'r19',index:'r19', width:120},  // jumlah 
			{name:'r21',index:'r21', width:60 ,align:'left'}, // satuan	 	   
			{name:'r21',index:'r21', width:120,hidden:true},  
			{name:'r22',index:'r22', width:120,hidden:true}, 
			{name:'r23',index:'r23', width:240,hidden:true},  //nama 
		],
		rowNum:10,
		rowList:[10,20,30],
		pager: '#ptblrepotproduksi',
		sortname: 'r5',
	 	sortorder: "asc",
		shrinkToFit:false,
		autowidth: false,           
		width: '',
		height:'100',
		rownumbers:true,
		jsonReader: { repeatitems : false }, 
		viewrecords : true, 
		gridview:true
	}); 
	$("#tblrepotproduksi").jqGrid("setColProp", "rn", {hidedlg: false});
	
	jQuery("#tblrepotproduksi").jqGrid('setGroupHeaders', 
		{ useColSpanStyle: true, groupHeaders:[
		{startColumnName: 'r1', numberOfColumns: 3, titleText: '<em><center>DOKUMEN PABEAN</center></em>'}
		,{startColumnName: 'r4', numberOfColumns: 2, titleText: '<em><center>BUKTI PENERIMAAN BARANG</center></em>'}
		, {startColumnName: 'r11', numberOfColumns: 4, titleText: '<em><center>RINCIAN PENGELUARAN</center></em>'}
		, {startColumnName: 'r17', numberOfColumns: 7, titleText: '<em><center>HASIL</center></em>'} 

		] });
 
	jQuery("#tblrepotproduksi").jqGrid('navGrid','#ptblrepotproduksi',{edit:false,add:false,del:false,view:false, search: false});  
	jQuery("#tblrepotproduksi").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false, defaultSearch: 'cn', ignoreCase: false});  
	
	setTimeout(function(){
		setGridHight($("#tblrepotproduksi"),$("#container_repot_produksi"),$("#ReportPabeanIN_bar")); 
	},10); 
		
});

</script> 

  