<script type="text/javascript">   
function setdg(){
	$('#dg').datagrid({  	
		title:"",
		toolbar:"#toolbar",
		fit:true,
		fitColumns:true,
		singleSelect:true,
		rownumbers:true,
		pagination:true,
		columns:[[  			
			{field:'trans_no',title:'Transaction No.',width:80},
			{field:'dmy',title:'Date',width:60,align:'center'},
			{field:'fqty_receive',title:'Qty. Receive',width:60},
			{field:'fqty_product',title:'Qty. Product',width:60,align:'center'},
			{field:'fqty_bom',title:'Qty. Product BOM',width:70,align:'right'},
			{field:'fqty_convert',title:'Qty. Convertion/TOR',width:70,align:'right'},
			{field:'line',title:'Line',width:70,align:'center'},
			{field:'po_no',title:'PO',width:70,align:'right'},
			{field:'saldo',title:'Qty. Balance',width:70,align:'right'}
		]],
		onBeforeLoad: function (data) {
		  var panel = $(this).datagrid("getPanel");
		  // here is to add the css style
		  panel.css("border","0");
		}
	});
}

function aksi(cmd){
	dtdari=$('#dtdari').datebox('getValue');
	dtsampai=$('#dtsampai').datebox('getValue');
	kd_cmpy=$('#kd_cmpy').combobox('getValue');
	q=$('#KdBarang').combogrid('getValue');
	NmBarang=$('#KdBarang').combogrid('getText');
	line=$('#line').textbox('getValue');
	
	if (q!="" && dtdari!="" && dtsampai!="" && kd_cmpy!=""){
		if (cmd=='cari'){
			$('#dg').datagrid({
				url: '<?=site_url($this->modul)?>/grid',
				queryParams:{			
					dtdari:dtdari,
					dtsampai:dtsampai,
					kd_cmpy:kd_cmpy,
					q:q,
					NmBarang:NmBarang,
					line:line
				}		
			});		
		} else if (cmd=='print'){
			var win = window.open("<?=base_url($this->modul)?>/aksi/cetak?dtdari="+dtdari+"&dtsampai="+dtsampai+"&kd_cmpy="+kd_cmpy+"&q="+q+"&NmBarang="+NmBarang+"&line="+line);
			win.print();
		} else if (cmd=='xls'){
			openurl("<?=base_url($this->modul)?>/aksi/excel?dtdari="+dtdari+"&dtsampai="+dtsampai+"&kd_cmpy="+kd_cmpy+"&q="+q+"&NmBarang="+NmBarang+"&line="+line);
		}
			
	}
	
	
}


</script>