 <div id="container_ReportPabeanInAW" style="height:100%; margin:0px; padding:0px;overflow:'hidden'; border: 0px solid #cd0a0a">
	<div class="pane-header ui-state-active" id="ReportPabeanInAW_bar" >   
			<!--<label style="margin-right:10px;">SOURCE</label>
			<select id="cb_datadok_out" style="margin-right:10px;width:80px" >
			  <option value="" selected>ALL</option>
			  <option value="aw">AW</option>
			  <option value="wh">WH</option>
		  	</select>
			<label style="margin-right:10px;">BC TYPE</label>
			<select id="jenisdok_out" style="margin-right:10px;width:80px" >
				<option value="" selected>ALL</option>
				<option value="BC30">BC 3.0</option>
				<option value="BC261">BC 2.6.1</option>
				<option value="BC27">BC 2.7</option>
				<option value="BC25">BC 2.5</option>
				<option value="BC41">BC 4.1</option>
		  	</select>!-->
			 <label style="margin-right:10px;">PERIODE:</label>
			 <input id="txtStartReportPabeanInAW" type="text" value='<?php echo $start_date; ?>' style="margin-right:10px;width:80px" />
			 <label style="margin-right:10px;">S/D</label>
			 <input id="txtEndReportPabeanInAW" type="text" value='<?php echo $end_date; ?>' style="margin-right:10px;width:80px" />
	
		 <button id="btnSearchReportPabeanInAW" >SEARCH</button>
			 <button id="btnPrintReportPabeanInAWPDF" >PRINT PDF</button> 
			 <button id="btnPrintReportPabeanInAWXLX" >PRINT XLS</button> 
			 <button id="btnPrintReportPabeanInAWXLXS" >PRINT XLSX</button>  
	</div>
	 <table id="tblReportPabeanInAW2340"  /><div id="ptblReportPabeanInAW2340"/> 
</div> 

<script> 
  $(document).ready(function(){ 
	$(window).bind('resize', function() {   
		 setTimeout(function(){
		 setGridHight($("#tblReportPabeanInAW2340"),$("#container_ReportPabeanInAW"),$("#ReportPabeanInAW_bar")); 
  		},10); 
	}) ;
	
	$("#btnSearchReportPabeanInAW").button();
	$("#btnPrintReportPabeanInAWPDF").button();
	$("#btnPrintReportPabeanInAWXLX").button(); 
	$("#btnPrintReportPabeanInAWXLXS").button(); 

	$( "#txtStartReportPabeanInAW" ).datepicker({
		dateFormat:'yy-mm-dd',
		defaultDate: "+1w",
		changeMonth: true,
		changeYear: true,
		numberOfMonths: 4,
		onClose: function( selectedDate ) {
		$( "#txtEndReportPabeanInAW" ).datepicker( "option", "minDate", selectedDate );
		}
    });
	
    $( "#txtEndReportPabeanInAW" ).datepicker({
		dateFormat:'yy-mm-dd',
		defaultDate: "+1w",
		changeMonth: true,
		changeYear: true,
		numberOfMonths: 4,
		onClose: function( selectedDate ) {
		$( "#txtStartReportPabeanInAW" ).datepicker( "option", "maxDate", selectedDate );
		}
    });
	 
	$("#btnSearchReportPabeanInAW").click(function(){ 
		var	start_date 	=	$.datepicker.formatDate('yymmdd', new Date($("#txtStartReportPabeanInAW").val())) ;
		var end_date	=	$.datepicker.formatDate('yymmdd', new Date($("#txtEndReportPabeanInAW").val())) ; 
		jQuery("#tblReportPabeanInAW2340").jqGrid('setGridParam', { postData: {start_date : start_date,end_date : end_date  } });
		$('#tblReportPabeanInAW2340').trigger( 'reloadGrid' );
	});
	
	function reportPrint(format){
		var	start_date 	=	$.datepicker.formatDate('yymmdd', new Date($("#txtStartReportPabeanInAW").val())) ;
		var end_date	=	$.datepicker.formatDate('yymmdd', new Date($("#txtEndReportPabeanInAW").val())) ;
 		var mypostdata = $('#tblReportPabeanInAW2340').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="frmPrintPabeanOut" method="POST" action="<?php echo base_url().'reports/CT_report_in_aw2wh/printReport'; ?>"/>');  
		dialog.dialog({
				modal:true,
				width : 300,
				height : 150,
				title :'Report Pabean Pemasukan',
				buttons: { 
					"CLOSE": function(){
						dialog.dialog("close");  
					},
					"PRINT": function() { 
					
					$("#frmPrintPabeanOut").append($("<input>").attr({"value":start_date , "name":'start_date'})); 
					$("#frmPrintPabeanOut").append($("<input>").attr({"value":end_date , "name":'end_date'})); 
					$("#frmPrintPabeanOut").append($("<input>").attr({"value":format , "name":'format'})); 
					$("#frmPrintPabeanOut").append($("<input>").attr({"value":tipe_bc , "name":'tipe_bc'})); 
 					$("#frmPrintPabeanOut").append($("<input>").attr({"value":$("#jenisdok_out").val() , "name":'bc_type'})); 
					$("#frmPrintPabeanOut").append($("<input>").attr({"value":$("#cb_datadok_out").val() , "name":'source'})); 
 					$("#frmPrintPabeanOut").submit();  
					
					dialog.dialog("close");  
					}
				},
				close : function(){
					dialog.dialog('destroy').remove(); 
				},
				open: function(){
					$("body").unblock(); 
				}
			}); 
	
	} 

	$("#btnPrintReportPabeanInAWPDF").button().click(function(){	
		reportPrint('pdf');
 	})	
 	$("#btnPrintReportPabeanInAWXLX").button().click(function(){	
		reportPrint('xls');
 	})	
 	$("#btnPrintReportPabeanInAWXLXS").button().click(function(){	
		reportPrint('xlsx');
 	})	
	var arr = <?php echo json_encode($rID); ?>;
	var pabean_out_invoice = ((arr.indexOf("3111")==-1) ? '0' : '1');
	jQuery("#tblReportPabeanInAW2340").jqGrid({
	   url:'<?php echo base_url().'reports/CT_report_in_aw2340/loadreport'; ?>',
		mtype : "post",
		postData:{'q':'1','start_date':'<?php echo $start_date_grid;?>','end_date':'<?php echo $end_date_grid;?>'},
		datatype: "json",
		colNames:['TIPE BC', 'NO', 'DATE','NO', 'DATE', 'NO', 'DATE', 'BUYER NAME', 'CODE', 'NAME', 'SAT', 'QTY','VAL','TOTAL PRICE', 'AJU ( 6 DIGIT)', 'KEMASAN','BRUTO','NETTO','KPBAC BONGKAR','B/L','KONTAINER','PENGANKUTAN'],
		colModel:[
			{name:'r1',index:'r1', width:80, stype: 'select', search:true, searchoptions:{searchhidden: true, value: <?php echo json_encode($from_sub); ?>}, hidden:true},
			// {name:'r1',index:'r1', width:50},
			{name:'r2',index:'r2', width:60},  
			{name:'r3',index:'r3', width:120, search: false},  
			{name:'r13',index:'r13', width:60 , hidden:pabean_out_invoice=='1'?false:true},  
			{name:'r14',index:'r14', width:120, search: false,hidden:pabean_out_invoice=='1'?false:true},  
			{name:'r4',index:'r4', width:100},  
			{name:'r5',index:'r5', width:120, search: false},  
			{name:'r6',index:'r6', width:140},
			{name:'r7',index:'r7', width:70},
			{name:'r8',index:'r8', width:140},  
			{name:'r9',index:'r9', width:40},
			{name:'r10',index:'r10', width:80,align:'right'},
			{name:'r11',index:'r11', width:40},  
			{name:'r12',index:'r12', width:120 ,align:'right'},
			{name:'r15',index:'r15', width:70},
			{name:'r16',index:'r16', width:70},
			{name:'r17',index:'r17', width:70},
			{name:'r18',index:'r18', width:70},
			{name:'r19',index:'r19', width:70},
			{name:'r20',index:'r20', width:70},
			{name:'r21',index:'r21', width:70},
			{name:'r22',index:'r22', width:70},
		   
		],
		rowNum:10,
		rowList:[10,20,30],
		pager: '#ptblReportPabeanInAW2340',
		sortname: 'r5',
	 	sortorder: "asc",
		shrinkToFit:false,
		autowidth: false,           
		width: '',
		height: 100,
 		rownumbers:true, 
		jsonReader: { repeatitems : false }, 
		viewrecords : true, 
		gridview:true
	}); 
	$("#tblReportPabeanInAW2340").jqGrid("setColProp", "rn", {hidedlg: false});
	
	jQuery("#tblReportPabeanInAW2340").jqGrid('setGroupHeaders', 
		{ useColSpanStyle: true, groupHeaders:[
		{startColumnName: 'r2', numberOfColumns: 2, titleText: '<em><center>DOC</center></em>'}
		, {startColumnName: 'r13', numberOfColumns: 2, titleText: '<em><center>INVOICE</center></em>'}
		, {startColumnName: 'r4', numberOfColumns: 2, titleText: '<em><center>SURAT JALAN</center></em>'}
		, {startColumnName: 'r7', numberOfColumns: 2, titleText: '<em><center>ITEM</center></em>'} ] });
 
	jQuery("#tblReportPabeanInAW2340").jqGrid('navGrid','#ptblReportPabeanInAW2340',{edit:false,add:false,del:false,view:false, search: false});  
	jQuery("#tblReportPabeanInAW2340").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false, defaultSearch: 'cn', ignoreCase: false});  
	
 		 setTimeout(function(){
		 setGridHight($("#tblReportPabeanInAW2340"),$("#container_ReportPabeanInAW"),$("#ReportPabeanInAW_bar")); 
  		},10); 
	 
	
	
});

</script> 

  