<script type="text/javascript">
$(function(){	
	
window.parent.$('#content_title').panel('setTitle', '<?=$this->title?>');	
setdg();
$('.validatebox-text').bind('blur', function(){
	$(this).validatebox('enableValidation').validatebox('validate');
});
$('#TpPrshn').combobox({  
	width:100,
	url:'<?=site_url('general/gridTpPrshn'); ?>',  
	valueField:'id_tp_prshn',  
	textField:'nm_tp_prshn'  
});
$('#Negara').combobox({  
	width:250,
	url:'<?=site_url('general/gridNegara'); ?>',  
	valueField:'KdNegara',  
	textField:'NmNegara'   
});
$('#Valuta').combobox({  
	width:80,
	mode:'remote', 
	url:'<?=site_url('general/gridValuta'); ?>',  
	valueField:'KdVal',  
	textField:'KdVal',
	onSelect:function(rowdata){
		$('#Kurs').numberbox('setValue',rowdata.Kurs);
	}, 
});
$('#Kurs').numberbox({  
    min:-1000, 
	precision:4, 
	groupSeparator:',',
	decimalSeparator:'.'
});
	
// $('#btnTbh').click(function(){
// 	tambah();
// });


$('#btnTbh').click(function(){
    $.ajax({
        url: 'https://'+window.location.hostname+':8080/processCSVSupplier',
        type: 'GET',  // Assuming it's a GET request, you can change it to POST if needed
        success: function() {
			$('#dg').datagrid('reload');
           Alert('Cron job triggered successfully:');
		   $.ajax({
        url: 'https://'+window.location.hostname+':8080/processCSVMstCostumer',
        type: 'GET',  // Assuming it's a GET request, you can change it to POST if needed
        success: function() {
			$('#dg').datagrid('reload');
           Alert('Cron job triggered successfully:');

            // You can add further actions after the cron job is triggered if needed
        },
        error: function(xhr, status, error) {
			$('#dg').datagrid('reload');
        }
    });

            // You can add further actions after the cron job is triggered if needed
        },
        error: function(xhr, status, error) {
			$('#dg_hdr').datagrid('reload');
			$.ajax({
        url: 'https://'+window.location.hostname+':8080/processCSVMstCostumer',
        type: 'GET',  // Assuming it's a GET request, you can change it to POST if needed
        success: function() {
			$('#dg').datagrid('reload');
           Alert('Cron job triggered successfully:');

            // You can add further actions after the cron job is triggered if needed
        },
        error: function(xhr, status, error) {
			$('#dg').datagrid('reload');
        }
    });
        }
    });
})
$('#btnUbh').click(function(){	
	ubah();
});
$('#btnHps').click(function(){
	hapus();
});
$('#btnSim').click(function(){
	simpan();
});
$('#btnPrint').click(function(){
	toprint();
});
$('#btnExcel').click(function(){
	toxls();
});
$('#btnSubmit').click(function(){
	simpan();
});
$('#btnUpload').click(function(){
	tambahUpload();
});

$('#btnReset').click(function(){
	$('#fm').form('clear');
});
$('#q').searchbox({
	width:200,
	searcher:function(value,name){  
		///alert(value + "," + name)  
		cari(value);
	},
	prompt:'Cari Kode & Nama'  
});  
});//Akhir Document Ready
// $('#btnUpload').click(function() {
//     $('#mstUpload').dialog('open');
// });
</script>