<script type="text/javascript"> 
function setdg(){
	$('#dg').datagrid({  	
		height:theight,
		toolbar:"#toolbar",
		fit:true,
		fitColumns:true,
		rownumbers:true,		
		pagination:true,
		pageSize:100,
		pageList:[100,200,300,400,500],
		columns:[[  
			{field:'KdBarang',title:'Kode Barang',width:20,rowspan:2},
			{field:'PartNo',title:'Size',width:40,rowspan:2},
			{field:'NmBarang',title:'Nama Barang',width:20,rowspan:2},
			{field:'Sat',title:'Satuan',width:15,rowspan:2},
			{title:'Stok WIP',align:"center",colspan:2}
		],[
			{field:'MatGroup',title:'Proses',width:40,align:"right"},
			{field:'Fqty_pr',title:'Qty',width:40,align:"right"},
		]],
		onBeforeLoad: function (data) {
		  var panel = $(this).datagrid("getPanel");
		  // here is to add the css style
		  panel.css("border","0");
		}		
	});
}
function aksi(cmd){
	var opts = $('#dg').datagrid('options');
	dtdari=$('#dtdari').datebox('getValue');
	dtsampai=$('#dtsampai').datebox('getValue');
	kd_cmpy="";
	q=$("#q").val();
	
	if (dtdari!="" && dtsampai!=""){
		if (cmd=='cari'){		
			$('#dg').datagrid({
				url: '<?=site_url($this->modul.'/aksi/cari')?>',
				queryParams:{			
					dtdari:$('#dtdari').datebox('getValue'),
					dtsampai:$('#dtsampai').datebox('getValue'),
					kd_cmpy:kd_cmpy,
					q:q
				}		
			});
		} else if (cmd=='print'){
			var win = window.open("<?=site_url($this->modul)?>/aksi/cetak?dtdari="+dtdari+"&dtsampai="+dtsampai+"&kd_cmpy="+kd_cmpy+"&q="+q+"&page="+opts.pageNumber+"&rows="+opts.pageSize,"Popup","toolbar=no, location=no,status=no,menubar=no,scrollbars=yes,resizable=no");
			win.print();
		} else if (cmd=='xls'){
			openurl("<?=site_url($this->modul)?>/aksi/excel?dtdari="+dtdari+"&dtsampai="+dtsampai+"&kd_cmpy="+kd_cmpy+"$q="+q+"&page="+opts.pageNumber+"&rows="+opts.pageSize);
		}
	}
}
</script>	
