<script type="text/javascript">   
function setdg(){
	$('#dg').datagrid({  	
		title:"",
		height:515,	
		toolbar:"#toolbar",
		fitColumns:"true",
		rownumbers:"true",
		columns:[[  			
			{field:'trans_no',title:'No. Transaksi',width:80},
			{field:'dmy',title:'Tanggal',width:60,align:'center'},
			{field:'tipe',title:'Tipe',width:60},
			{field:'buspart',title:'Pengirim/Penerima',width:60,align:'center'},
			{field:'fdebit',title:'Pemasukan',width:70,align:'right'},
			{field:'fcredit',title:'Pengeluaran',width:70,align:'right'},
			{field:'saldo',title:'Saldo',width:70,align:'right'}
		]]
	});
}

function setdgCari(){
	dtdari=$('#dtdari').datebox('getValue');
	dtsampai=$('#dtsampai').datebox('getValue');
	q=$('#KdBarang').combogrid('getValue');
	prodcard_id=$('#prodcard_id').combobox('getValue');
	lot_no=$('#lot_no').textbox('getValue');
	
	if (q!="" && dtdari!="" && dtsampai!=""){
		$('#dg').datagrid({
			url: '<?=site_url('erpt_kstok_rm/grid'); ?> ',
			queryParams:{			
				dtdari:dtdari,
				dtsampai:dtsampai,
				q:q,
				prodcard_id:prodcard_id,
				lot_no:lot_no
			}		
		});
	}
}

function aksi(cmd){	
	prodcard_id=$('#prodcard_id').combobox('getValue');
	lot_no=$('#lot_no').textbox('getValue');
	
	if (cmd=='print'){
		var win = window.open("<?=base_url($this->modul)?>aksi/cetak?dtdari="+$('#dtdari').datebox('getValue')+"&dtsampai="+$('#dtsampai').datebox('getValue')+"&q="+$('#KdBarang').combogrid('getValue')+"&prodcard_id="+prodcard_id+"&lot_no="+lot_no);
		win.print();
	} else if (cmd=='xls'){
		openurl("<?=base_url($this->modul)?>aksi/excel?dtdari="+$('#dtdari').datebox('getValue')+"&dtsampai="+$('#dtsampai').datebox('getValue')+"&q="+$('#KdBarang').combogrid('getValue')+"&prodcard_id="+prodcard_id+"&lot_no="+lot_no);
	}
	
}

</script>