 <div id="container_ReportStockCardMesin" style="height:100%; margin:0px; padding:0px;overflow:'hidden'; border: 0px solid #cd0a0a">
	<div class="pane-header ui-state-active" id="ReportStockCardMesin_bar" >   
		<label style="margin-right:10px;">PERIODE:</label>
		<input id="txtStartReportStockCardMesin" type="text" value='<?php echo $start_date; ?>' style="margin-right:10px;width:80px" />
		<label style="margin-right:10px;">S/D</label>
		<input id="txtEndReportStockCardMesin" type="text" value='<?php echo $end_date; ?>' style="margin-right:10px;width:80px" />

		<button id="btnSearchReportStockCardMesin" >SEARCH</button>
		<button id="btnPrintReportStockCardMesinPDF" >PRINT PDF</button> 
		<button id="btnPrintReportStockCardMesinXLS" >PRINT XLS</button> 
		<button id="btnPrintReportStockCardMesinXLSX" >PRINT XLSX</button>  
	</div>
	<table id="tblReportStockCardMesin"  /><div id="ptblReportStockCardMesin"/> 
</div> 

<script> 
	$(document).ready(function(){ 
		$(window).bind('resize', function() {   
			setTimeout(function(){
				setGridHight($("#tblReportStockCardMesin"),$("#container_ReportStockCardMesin"),$("#ReportStockCardMesin_bar")); 
			},10); 
		}) ;
	
		$("#btnSearchReportStockCardMesin").button();
		$("#btnPrintReportStockCardMesinPDF").button();
		$("#btnPrintReportStockCardMesinXLS").button(); 
		$("#btnPrintReportStockCardMesinXLSX").button(); 

		$( "#txtStartReportStockCardMesin" ).datepicker({
			dateFormat:'yy-mm-dd',
			defaultDate: "+1w",
			changeMonth: true,
			changeYear: true,
			numberOfMonths: 4,
			onClose: function( selectedDate ) {
				$( "#txtEndReportStockCardMesin" ).datepicker( "option", "minDate", selectedDate );
			}
		});
	
		$( "#txtEndReportStockCardMesin" ).datepicker({
			dateFormat:'yy-mm-dd',
			defaultDate: "+1w",
			changeMonth: true,
			changeYear: true,
			numberOfMonths: 4,
			onClose: function( selectedDate ) {
				$( "#txtStartReportStockCardMesin" ).datepicker( "option", "maxDate", selectedDate );
			}
		});
	 
		$("#btnSearchReportStockCardMesin").click(function(){ 
			var	start_date 	=	$.datepicker.formatDate('yymmdd', new Date($("#txtStartReportStockCardMesin").val())) ;
			var end_date	=	$.datepicker.formatDate('yymmdd', new Date($("#txtEndReportStockCardMesin").val())) ; 
			jQuery("#tblReportStockCardMesin").jqGrid('setGridParam', { postData: {start_date : start_date,end_date : end_date  } });
			$('#tblReportStockCardMesin').trigger( 'reloadGrid' );
		});
	
		function reportPrint(format){
			var	start_date 	=	$.datepicker.formatDate('yymmdd', new Date($("#txtStartReportStockCardMesin").val())) ;
			var end_date	=	$.datepicker.formatDate('yymmdd', new Date($("#txtEndReportStockCardMesin").val())) ;
			var mypostdata = $('#tblReportStockCardMesin').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_aw_2340/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(); 
				}
			}); 
		} 

		$("#btnPrintReportStockCardMesinPDF").button().click(function(){	
			reportPrint('pdf');
		})	
		
		$("#btnPrintReportStockCardMesinXLS").button().click(function(){	
			reportPrint('xls');
		})	
		
		$("#btnPrintReportStockCardMesinXLSX").button().click(function(){	
			reportPrint('xlsx');
		})
		
		var arr = <?php echo json_encode($rID); ?>;
		var pabean_out_invoice = ((arr.indexOf("3111")==-1) ? '0' : '1');
		
		jQuery("#tblReportStockCardMesin").jqGrid({
			url:'<?php echo base_url().'ms_report/CT_reportstockcard_mesin/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','PENGANGKUTAN'],
			colModel:[
				{name:'r1',index:'r1', width:80, stype: 'select', search:true, searchoptions:{searchhidden: true, value: <?php echo json_encode($from_sub); ?>}, hidden:true},
				{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:100},
			],
			rowNum:10,
			rowList:[10,20,30],
			pager: '#ptblReportStockCardMesin',
			sortname: 'r5',
			sortorder: "asc",
			shrinkToFit:false,
			autowidth: false,           
			width: '',
			height: 100,
			rownumbers:true, 
			jsonReader: { repeatitems : false }, 
			viewrecords : true, 
			gridview:true
		}); 
		
		$("#tblReportStockCardMesin").jqGrid("setColProp", "rn", {hidedlg: false});
	
		jQuery("#tblReportStockCardMesin").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("#tblReportStockCardMesin").jqGrid('navGrid','#ptblReportStockCardMesin',{edit:false,add:false,del:false,view:false, search: false});  
		jQuery("#tblReportStockCardMesin").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false, defaultSearch: 'cn', ignoreCase: false});  
	
		setTimeout(function(){
		setGridHight($("#tblReportStockCardMesin"),$("#container_ReportStockCardMesin"),$("#ReportStockCardMesin_bar")); 
  		},10); 
});

</script> 

  