<script type="text/javascript">
	$(document).ready(function(){
	$("#data_detail").load("spv/pengel_kas/tampil_data.php");
	$("#form_cari_kode").hide();
		
	$('#form_cari_kode').dialog({
		autoOpen: false,
		modal	: true,
		width: 750,
	});
		
	$('#cari_kodeaw').click(function(){
		$('#form_cari_kode').dialog('open');
		no=1;
		
		$.ajax({
			type	: "POST",
			url	    : "spv/pengel_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/pengel_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_kk();
	});
		
	function posting_kk(){
		var	kodeaw  = $("#txt_kodeaw").val();
		var	kodeak  = $("#txt_kodeak").val();
		
		var error = false;
		if(kodeaw.length == 0){
           var error = true;
			alert("Maaf, Kode BKK awal masih kosong, klik icon di samping Kode BKK awal untuk mencari.");
		   return (false);
        }
		
		if(kodeak.length == 0){
           var error = true;
			alert("Maaf, Kode BKK akhir masih kosong, klik icon di samping Kode BKK akhir untuk mencari.");
		   return (false);
        }
			
		if(error == false){		
		$.ajax({
			type	: "POST",
			url		: "spv/pengel_kas/postkk.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/pengel_kas/tampil_data.php");				
			}
		});
		}
	}
	
	$("#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 BKK : <input type='text' name='txt_kodeaw' id='txt_kodeaw' size='12' class='input_header' readonly/>
			<img src='images/view.png' width='18' height='18' title='Cari Nomor BKK' id='cari_kodeaw'> sampai dengan 
			<input type='text' name='txt_kodeak' id='txt_kodeak' size='12' class='input_header' readonly/>
			<img src='images/view.png' width='18' height='18' title='Cari Nomor BKK' 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 BKK'>		
		<div id='info_kode' align='center'></div>
	</div>";
?>
