<script type="text/javascript"> 
function setdg(){
	$('#dg').datagrid({
		toolbar:"#toolbar",
		fit:true,
		fitColumns:true,
		rownumbers:true,		
		pagination:true,
		pageSize:100,
		pageList:[100,200,300,400,500],
		columns:[[  
			{field:'KdBarang',title:'Item<br>Code',width:100},
			{field:'NmBarang',title:'Item<br>Name',width:100},
			{field:'Sat',title:'UOM',width:50},
			{field:'Fqty_beg',title:'Begin Stock',width:100,align:"right"},
			{field:'Fqty_in',title:'Part Issue',width:100,align:"right"},
			{field:'Fqty_out',title:'FC * Product',width:100,align:"right"},
			{field:'Fqty_sc',title:'Adjust Scrap',width:100,align:"right"},
			{field:'Fqty_end',title:'End Stock',width:100,align:"right"},
			{field:'Fqty_opn',title:'Stock Opname',width:100,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=$('#kd_cmpy').combobox('getValue');
	q=$("#q").val();
	
	if (dtdari!="" && dtsampai!="" && kd_cmpy!=""){
		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>	