<script type="text/javascript">
$(function(){
window.parent.$('#content_title').panel('setTitle', '<?=$this->title?>');
theight=window.parent.$('#content').height()-30;	
$('#tb').tabs({
	width:'100%',	
	height:theight,
	fit:true,
	border:false,
	plain:true,
	onSelect:function(title,index){
		if(index==1){
			setDgHdrDet();
		}
	}
});
$('#matin_type').combobox({
	mode:'remote', 
	url:'<?=site_url('general/gridInType'); ?>',  
	valueField:'matin_type',  
	textField:'matin_name'  
});
$('#Kurs').numberbox({  
    min:-1000, 
	precision:2, 
	groupSeparator:',',
	decimalSeparator:'.'
});
$('#supplier').combobox({
	panelWidth:250,
	mode:'remote', 
	url: '<?=site_url('company_customer/gridAll')?>',  
	valueField:'KdPrshn',  
	textField:'NmPrshn',
	fitColumns: true,
	onSelect:function(rowdata){
		//console.log(rowdata.Valuta);
		$('#currency').combobox('setValue',rowdata.Valuta);
		$('#Kurs').numberbox('setValue',rowdata.Kurs);
		// $('#currency2').combobox('setValue',rowdata.Valuta);
	},
});
$('#currency').combobox({ 
	mode:'remote', 
	url:'<?=site_url('general/gridValuta'); ?>',  
	valueField:'KdVal',  
	textField:'KdVal'  
});
$('#currency2').combobox({ 
	mode:'remote', 
	url:'<?=site_url('general/gridValuta2'); ?>',  
	valueField:'KdVal',  
	textField:'KdVal',
	onSelect:function(rowdata){
		//console.log(rowdata.Valuta);
		$('#kurs').textbox('setValue',rowdata.rate);
	},  
});
$('#KdJnsDok').combobox({  
	width:100,
	mode:'remote', 
	url:'<?=site_url('general/gridJnsDokIn'); ?>',  
	valueField:'KdJnsDok',  
	textField:'UrJnsDok'  
});
$('#mat_id').combogrid({  
	width:150,
	panelWidth:500,  	
	url: '<?=site_url('general/gridBarang/'.$this->tp_barang)?>',  
	idField:'KdBarang',  
	textField:'KdBarang',  
	mode:'remote',  
	rownumbers:true,
	fitColumns:true,
	pagination:true,
	columns:[[  
		{field:'KdBarang',title:'Item Code',width:60},
		{field:'NmBarang',title:'Item Description',width:150},
		{field:'Sat',title:'UOM',width:50}
	]],
	onClickRow:function(index,row){
		//console.log(row);
		insert_det(row)
	}  
}); 

$('#mat_idMSO').combogrid({  
	panelWidth:500,  	
    url: '<?=site_url('general/gridBarangMSO/')?>',  
	idField:'KdBarang',  
	textField:'KdBarang',  
	mode:'remote',  
	rownumbers:true,
	fitColumns:true,
	pagination:true,
	columns:[[  
		{field:'KdBarang',title:'Item Code',width:60},
		{field:'PartNo',title:'Size',width:100},
		{field:'CF',title:'CF',width:100},
		{field:'FG-P',title:'FG-P',width:100},
		{field:'custPartNo',title:'Part No Customer',width:100},
		{field:'NmBarang',title:'Item Description',width:60},
		{field:'Sat',title:'UOM',width:50}
	]],
	onClickRow:function(index,row){
		//console.log(row);
		insert_det(row)
	}  
}); 

$('#Sat').combobox({   
	mode:'remote', 
	url:'<?=site_url('uom/gridAll'); ?>',  
	valueField:'KdSat',  
	textField:'KdSat',
	pagination:true   
});
$('#qty').numberbox({  
	min:-1000, 
	precision:2, 
	groupSeparator:',',
	decimalSeparator:'.',
	onChange:function(newValue,oldValue){
		price=$('#price').numberbox('getValue');
		amount = newValue*price;
		$('#amount').numberbox('setValue',amount);
	}
});
$('#price').numberbox({  
    min:-1000, 
	precision:4, 
	groupSeparator:',',
	decimalSeparator:'.',
	onChange:function(newValue,oldValue){
		qty=$('#qty').numberbox('getValue');
		amount = newValue*qty;
		$('#amount').numberbox('setValue',amount);
	}
});
$('#amount').numberbox({  
    min:-10000, 
	precision:2, 
	groupSeparator:',',
	decimalSeparator:'.',
});
$('#npo_id').textbox({
	panelWidth:250
});
setDgHdr();
setDgDet();
$('#toolbar_det').hide();
$('#q').searchbox({
	width:200,
	searcher:function(value,name){  
		///alert(value + "," + name)  
		cari(value);
	},
	prompt:'Cari...'  
});
$('#q2').searchbox({
	width:200,
	searcher:function(value,name){  
		///alert(value + "," + name)  
		cari2(value);
	},
	prompt:'Cari...'  
});  
$('#q_det').searchbox({
	width:200,
	searcher:function(value,name){  
		///alert(value + "," + name)  
		cari_det(value);
	},
	prompt:'Cari...'  
});  
/*Button Event*/
$('#btnBarScan').click(function(){
	barScan();
});
// $('#btnTbh').click(function(){
// 	tambah();
// });

$('#btnUpload').click(function(){
	upload();
});

// $('#btnTbh').click(function(){
//     $.messager.progress({
//         title: 'Processing',   // Title of the loading dialog
//         msg: 'Please wait...', // Message displayed in the loading dialog
//     });

//     $.ajax({
//         url: 'https://'+window.location.hostname+':8080/processCSVSo',
//         type: 'GET',  // Assuming it's a GET request, you can change it to POST if needed
//         success: function() {
// 			$('#dg_hdr').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) {
// 			$.messager.progress('close');
// 			$('#dg_hdr').datagrid('reload');
//         }
//     });
// })
$('#btnUbh').click(function(){	
	ubah();
});
$('#btnHps').click(function(){
	hapus();
});
$('#btnSim').click(function(){
	simpan();
});
$('#btnPrint').click(function(){
	printSlip();
});
$('#btnPrint2').click(function(){
	aksi('print');
});
$('.panel-tool-close').click(function(){
	$('#dialog-blocker').hide();
	$('.blurred-background').remove(); // Remove the blur overlay
            $('.content').removeClass('disable-interaction'); // Re-enable interaction with content
    
});

$('#btnExcel').click(function(){
	aksi('xls');
});
$('#btnSubmit').click(function(){
	simpan();
});
$('#btnReset').click(function(){
	$('#fm').form('clear');
});
/*Button2 Event*/
$('#btnTbh2').click(function(){
	tambah2();
});
$('#btnUbh2').click(function(){	
	ubah2();
});
$('#btnHps2').click(function(){
	hapus2();
});
$('#btnSim2').click(function(){
	simpan2();
});
$('#btnSubmit2').click(function(){
	simpan2();
});
$('#btnReset2').click(function(){
	$('#fm2').form('clear');
});
$('#btnSim3').click(function(){
	simpan3();
});
$('#btnSubmit2').click(function(){
	simpan3();
});
$('#btnReset2').click(function(){
	$('#fm3').form('clear');
});
});//Akhir Document Ready
</script>