<script type="text/javascript">
	$(document).ready(function(){
	$("#detail_posting").load("spv/jurnal_umum/tampil_data_post.php");
	$("#form_cari_kode").hide();	
		
	$('#form_cari_kode').dialog({
		autoOpen: false,
		modal	: true,
		width: 600,
	});
	
	$('#form_cari_kode').dialog({
		autoOpen: false,
		modal	: true,
		width: 600,
	});
		
	$('#cari_kodeaw').click(function(){
		$('#form_cari_kode').dialog('open');
		no=1;
		
		$.ajax({
			type	: "POST",
			url		: "spv/jurnal_umum/tampil_data_aw.php",
			data	: "no="+no,
			timeout	: 3000,
			beforeSend	: function(){
				$("#info_kode").html("<img src='loading.gif' />");			
			},				  
			success	: function(data){				
				$("#info_kode").html(data);
			}
		});
	});
	
	$('#cari_kodeak').click(function(){
		$('#form_cari_kode').dialog('open');
		no=1;
		
		$.ajax({
			type	: "POST",
			url		: "spv/jurnal_umum/tampil_data_ak.php",
			data	: "no="+no,
			timeout	: 3000,
			beforeSend	: function(){
				$("#info_kode").html("<img src='loading.gif' />");			
			},				  
			success	: function(data){				
				$("#info_kode").html(data);
			}
		});
	});
	
	$("#postju").click(function(){
		hitung_total();
		posting_ju();
	});
	
	function hitung_total(){
		var	kodeaw = $("#txt_kodeaw").val();
		var	kodeak = $("#txt_kodeak").val();
		
		$.ajax({
			type	: "POST",
			url		: "spv/jurnal_umum/hitung_total.php",
			data	: "kodeaw="+kodeaw+
				"&kodeak="+kodeak,
			dataType: "json",
			success	: function(data){
				$("#t_tdebet").val(data.tdebet);
				$("#t_tkredit").val(data.tkredit);
			}
		});
	}
	
		
	function posting_ju(){
		var	kodeaw = $("#txt_kodeaw").val();
		var	kodeak = $("#txt_kodeak").val();
		
		var error = false;
		if(kodeaw.length == 0){
			var error = true;
			alert("Maaf, Nomor Bukti awal masih kosong, klik icon di samping Nomor Bukti awal untuk mencari.");
		   return (false);
        }
		
		if(kodeak.length == 0){
           var error = true;
			alert("Maaf, Nomor Bukti akhir masih kosong, klik icon di samping Nomor Bukti akhir untuk mencari.");
		   return (false);
        }
			
		if(error == false){		
		$.ajax({
			type	: "POST",
			url		: "spv/jurnal_umum/postju.php",
			data	: "kodeaw="+kodeaw+
				"&kodeak="+kodeak,
								
			timeout	: 3000,
			beforeSend	: function(){		
				$("#info").html("<img src='loading.gif' />");			
			},				  
			success	: function(data){
				$("#info").html(data);
				$("#txt_kodeaw").val('');
				$("#txt_kodeak").val('');
				$("#detail_posting").load("spv/jurnal_umum/tampil_data_post.php");
			}
		});
		}
		return false;
	}
	
	$("#tutup_post").click(function(){
		document.location='?module=home';
	});
});
</script>

<style type="text/css">
#txt_kode {
	background:#CCC;
}
#cari_produk{
	cursor:pointer;
}
#cari_buyer{
	cursor:pointer;
}
.input_detail readonly {
	background:#666;
}
</style>

<?php
include '../../inc/fungsi_tanggal.php';

echo "<table width='100%'>	
	<tr>
		<input type='text' name='t_tdebet' id='t_tdebet' size='9' hidden/>
		<input type='text' name='t_tkredit' id='t_tkredit' size='9' hidden/>
		<td>Nomor Bukti</td>
		<td>:</td>
		<td>
			<input type='text' name='txt_kodeaw' id='txt_kodeaw' size='9' class='input_header' readonly />
			<img src='images/view.png' width='18' height='18' title='Cari Nomor Bukti' id='cari_kodeaw'>
		</td>
		<td>sampai dengan</td>
		<td>:</td>
		<td>
			<input type='text' name='txt_kodeak' id='txt_kodeak' size='9' class='input_header' readonly />
			<img src='images/view.png' width='18' height='18' title='Cari Nomor Bukti' id='cari_kodeak'>
		</td>
		<td width='20%'></td>
		
		<td colspan='6' align='right'>
			<button name='postju' id='postju'>Posting</button>
			<button name='tutup_post' id='tutup_post'>Tutup</button>
		</td>
	</tr>
	</table>
	<div id='detail_posting'></div>";

echo "<div id='form_cari_kode' title='Pencarian Nomor Bukti'>
		<div id='info_kode' align='center'></div>
	</div>";
?>
