<script type="text/javascript">
	$(document).ready(function(){
	$("#data_detail").load("spv/pener_kas/tampil_data.php");
	$("#form_cari_kode").hide();
		
	$('#form_cari_kode').dialog({
		autoOpen: false,
		modal	: true,
		width: 800,
	});
		
	$('#cari_kodeaw').click(function(){
		$('#form_cari_kode').dialog('open');
		no=1;
		
		$.ajax({
			type	: "POST",
			url		: "spv/pener_kas/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/pener_kas/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);
			}
		});
	});
	
	$("#posting").click(function(){
		posting_km();
	});
		
	function posting_km(){
		var	kodeaw = $("#txt_kodeaw").val();
		var	kodeak	= $("#txt_kodeak").val();
		
		var 	error = false;
		if(kodeaw.length == 0){
           var error = true;
			alert("Maaf, Kode BKM awal masih kosong, klik icon di samping Kode BKM awal untuk mencari.");
		   return (false);
        }
		
		if(kodeak.length == 0){
           var error = true;
			alert("Maaf, Kode BKM akhir masih kosong, klik icon di samping Kode BKM akhir untuk mencari.");
		   return (false);
        }
			
		if(error == false){		
		$.ajax({
			type	: "POST",
			url	: "spv/pener_kas/postkm.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('');
				$("#data_detail").load("spv/pener_kas/tampil_data.php");				
			}
		});
		}
		return false;
	}
	
	$("#tutup").click(function(){		
		document.location='?module=home';
	});
});
</script>

<style type="text/css">
#txt_kode {
	background:#CCC;
}
</style>

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

echo "<table width='100%'>	
	<tr>
		<td>Kode BKM : <input type='text' name='txt_kodeaw' id='txt_kodeaw' size='13' class='input_header' readonly />
			<img src='images/view.png' width='18' height='18' title='Cari Nomor BKM' id='cari_kodeaw'> sampai dengan <input type='text' name='txt_kodeak' id='txt_kodeak' size='13' class='input_header' readonly/>
			<img src='images/view.png' width='18' height='18' title='Cari Nomor BKM' id='cari_kodeak'>
		</td>		
		<td>
			<button name='posting' id='posting'>Posting</button>
			<button name='tutup' id='tutup'>Tutup</button>
		</td>
	</tr>
	</table>
	<div id='data_detail'></div>";

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