<script type="text/javascript">
$(function(){

$('#po_date').datebox('setValue',"<?=date('d/m/Y')?>");	

$('#tl2Sim').click(function(){
	$('#dlg').dialog('close');
	$('#dg').datagrid('appendRow',{		
		KdBarang2: $('#KdBarang2').combogrid('getValue'),
		NmBarang2: $('#NmBarang2').val(),
		color: $('#color').combobox('getValue'),
		Sat2: $('#Sat2').combobox('getValue'),
		qty: nformat2($('#qty').val(),0),
		weight: nformat2($('#weight').val(),3),
		price: nformat2($('#price').val(),4),
		amount: nformat2($('#amount').val(),2),
		ket_order: $('#ket_order').val()
	});
});

$('#tl2Ubh2').click(function(){
	$('#dlg').dialog('close');
	var row = $('#dg').datagrid('getSelected');
	if (row){
		var index = $('#dg').datagrid('getRowIndex', row);
		$('#dg').datagrid('updateRow',{
			index: index, 
			row: { 
				KdBarang2: $('#KdBarang2').combogrid('getValue'),
				NmBarang2: $('#NmBarang2').val(),
				color: $('#color').combobox('getValue'),
				Sat2: $('#Sat2').combobox('getValue'),
				qty: nformat2($('#qty').val(),0),
				weight: nformat2($('#weight').val(),3),
				price: nformat2($('#price').val(),4),
				amount: nformat2($('#amount').val(),2),
				ket_order: $('#ket_order').val()
				}
		});
	}
});

$('#tl2Hps').click(function(){
	var row = $('#dg').datagrid('getSelected');
	if (row){		
		$.messager.confirm('Confirm','Apakah anda yakin akan menghapus data ini?',function(r){
			if (r){
				var index = $('#dg').datagrid('getRowIndex', row);
				$('#dg').datagrid('deleteRow', index);
			}
		});		
	}
});


});//Akhir Document Ready
</script>