<script type="text/javascript">  
theight=$( document ).height()-50; 
function setdg(){
	$('#dg').datagrid({  	
		height:theight,
		toolbar:"#toolbar",
		fitColumns:true,
		fit:true,
		rownumbers:true,		
		pagination:true,
		pageSize:100,
		pageList:[100,200,300,400,500],
		columns:[[  
			{field:'UrJnsDok',title:'Jenis<br>Dokumen',rowspan:2,width:20},  			
			{title:'Dokumen Pabean',colspan:2,width:45},
			{title:'Bukti Penerimaan<br>Barang',colspan:2,width:55,align:"center"},
			{field:'NmPrshn',title:'Pemasok/Pengirim',rowspan:2,width:40}, 
			{field:'KdBarang',title:'Kode<br>Barang',rowspan:2,width:25},
			{field:'NmBarang',title:'Nama<br>Barang',rowspan:2,width:40},
			{field:'Sat',title:'Sat',rowspan:2,width:15},
			{field:'Fqty',title:'Jumlah',rowspan:2,width:20,align:"right"},
			{field:'Famount',title:'Nilai Barang',rowspan:2,width:30,align:"right"}
		],[						
			{field:'NoDaf',title:'Nomor',width:20,align:"center"},
			{field:'FTgDaf',title:'Tanggal',width:25,align:'center'},
			{field:'matin_no',title:'Nomor',width:30,align:"center"},
			{field:'Fmatin_date',title:'Tanggal',width:25,align:'center'}			
		]],
		onBeforeLoad: function (data) {
		  var panel = $(this).datagrid("getPanel");
		  // here is to add the css style
		  panel.css("border","0");
		},
	});
}

function cari(q){
	// $('#dg').datagrid({
	// 	queryParams:{			
	// 		KdJnsDok:$('#KdJnsDok').combobox('getValue'),
	// 		dtdari:$('#dtdari').datebox('getValue'),
	// 		dtsampai:$('#dtsampai').datebox('getValue'),
	// 		q:q
	// 	}		
	// });
	// $('#dg').datagrid('reload'); 
	$('#dg').datagrid({
		url: '<?=site_url('brpt_masukrm/grid'); ?>',
		queryParams:{			
			KdJnsDok:$('#KdJnsDok').combobox('getValue'),
			dtdari:$('#dtdari').datebox('getValue'),
			dtsampai:$('#dtsampai').datebox('getValue'),
			q:q
		}		
	});
}

function toprint(){
	var opts = $('#dg').datagrid('options');
	KdJnsDok=$('#KdJnsDok').combobox('getValue');
	dtdari=$('#dtdari').datebox('getValue');
	dtsampai=$('#dtsampai').datebox('getValue');
	q=$("#q").val();
	
	var win = window.open("<?=site_url()?>brpt_masukrm/cetak?KdJnsDok="+KdJnsDok+"&dtdari="+dtdari+"&dtsampai="+dtsampai+"&q="+q+"&page="+opts.pageNumber+"&rows="+opts.pageSize,"Popup","toolbar=no, location=no,status=no,menubar=no,scrollbars=yes,resizable=no");
	win.print();
}

function toxls(){
	var opts = $('#dg').datagrid('options');
	KdJnsDok=$('#KdJnsDok').combobox('getValue');
	dtdari=$('#dtdari').datebox('getValue');
	dtsampai=$('#dtsampai').datebox('getValue');
	q=$("#q").val();
	
	openurl("<?=site_url();?>brpt_masukrm/excel?KdJnsDok="+KdJnsDok+"&dtdari="+dtdari+"&dtsampai="+dtsampai+"&q="+q+"&page="+opts.pageNumber+"&rows="+opts.pageSize);
}
</script>	