<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({
	panelWidth:120,
	mode:'remote', 
	url:'<?=site_url('general/gridInTypeScrap'); ?>',
	valueField:'matin_type',  
	textField:'matin_name'  
});

	$('#KdJnsDok').combobox({
		mode:'remote',
		url:'<?=site_url('general/gridJnsDokIn'); ?>',
		valueField:'KdJnsDok',
		textField:'UrJnsDok'
	});

$('#line').combobox({
	mode:'remote',
	url:'<?=site_url('general/dataLine'); ?>',
	valueField:'id_line',
	textField:'nm_line'
});

$('#supplier').combobox({
	panelWidth:250,
	mode:'remote', 
	url: '<?=site_url('company/gridAll')?>',  
	valueField:'KdPrshn',  
	textField:'NmPrshn',
	fitColumns: true,
	onSelect:function(rowdata){
		//console.log(rowdata.Valuta);
		$('#currency').combobox('setValue',rowdata.Valuta);
	},
});

	$('#matout_id').combogrid({
		width:150,
		panelWidth:500,
		url: '<?=site_url('general/dataOutHdr/')?>',
		idField:'matout_id',
		textField:'matout_no',
		mode:'remote',
		rownumbers:true,
		fitColumns:true,
		pagination:true,
		columns:[[
			{field:'matout_no',title:'Matout No.',width:100},
			{field:'matout_date',title:'Matout Name',width:100}
		]],
		onClickRow:function(index,row){
			//console.log(row);
			insert_det(row)
		}
	});

$('#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)
	}  
});

$('#Sat').combobox({  
	mode:'remote', 
	url:'<?=site_url('uom/gridAll'); ?>',  
	valueField:'KdSat',  
	textField:'KdSat',
	pagination:true   
});

$('#qty').numberbox({  
	min:-1000, 
	precision:2, 
	groupSeparator:',',
	decimalSeparator:'.'
});

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...'  
}); 

/*Button Event*/
$('#btnTbh').click(function(){
	tambah();
});

$('#btnUbh').click(function(){	
	ubah();
});

$('#btnHps').click(function(){
	hapus();
});

$('#btnSim').click(function(){
	simpan();
});

$('#btnPrint').click(function(){
	printSlip();
});

$('#btnPrint2').click(function(){
	aksi('print');
});

$('#btnExcel').click(function(){
	aksi('xls');
});


$('#btnSubmit').click(function(){
	simpan();
});

$('#btnReset').click(function(){
	$('#fm').form('clear');
});

/*Button2 Event*/
$('#btnBarScan').click(function(){
	barScan();
});

$('#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();
});

$('#btnSubmit3').click(function(){
	simpan3();
});

$('#btnReset3').click(function(){
	$('#fm3').form('clear');
});


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