<script type="text/javascript">	
$(document).ready(function() {
	$("#tabs").tabs({selected:0});
	$("#tampil_data").load('modul/hutang_dg/tampil_data.php');
	$("#form").load('spv/hutang_dg/form.php');
	
	cari_tgl();

	function cari_tgl(){
		var no = 1;
		$.ajax({
			type	: "POST",
			url		: "modul/report/cari_tanggal.php",
			data	: "no="+no,
			dataType: "json",
			success	: function(data){				
				$("#txt_tgljt1").val(data.tanggal);
				$("#txt_tgljt2").val(data.tanggal);				
			}
		});
	}
	
	$("#txt_caridat").keyup(function() {
		var cari 	= $("#txt_caridat").val()
		var akses	= 1; 
		$.ajax({
			type	: "GET",
			url		: "modul/hutang_dg/tampil_data.php",
			data	: "cari="+cari,
			timeout	: 3000,
			beforeSend	: function(){		
				$("#tampil_data").html("<img src='loading.gif' />");			
			},				  
			success	: function(data){
				$("#tampil_data").html(data);
			}
		});
	});
	
	$("#cetak_pd").click(function(){
		var cari = $("#txt_carisup").val()
		window.location.href='modul/laporan/hutang_dg.php?cari='+cari;		
	});
	
	$("#tutup_pd").click(function(){
		document.location='?module=home';
	});
	
	$("#cari_jt").click(function() {
		var tgljt1	= $("#txt_tgljt1").val();
		var tgljt2	= $("#txt_tgljt2").val();
		var cari 	= $("#txt_carispjt").val();		
		
		if(tgljt1.length==0){
			alert('Maaf, tanggal jatuh tempo awal masih kosong.')
			return (false);
		}
		
		if(tgljt2.length==0){
			alert('Maaf, tanggal jatuh tempo akhir masih kosong.')
			return (false);
		}
				
		$.ajax({
			type	: "GET",
			url		: "modul/hutang_dg/tampil_data_jt.php",
			data	: "cari="+cari+
					"&tgljt1="+tgljt1+
					"&tgljt2="+tgljt2,
			timeout	: 2000,
			beforeSend	: function(){		
				$("#tampil_data_jt").html("<img src='loading.gif' />");			
			},				  
			success	: function(data){
				$("#tampil_data_jt").html(data);
				$("#tampil_data_jt").show();				
			}
		});
	});
		
	$("#cetak_jt").click(function(){
		var tgljt1	= $("#txt_tgljt1").val();
		var tgljt2	= $("#txt_tgljt2").val();
		var cari 	= $("#txt_carispjt").val();
		
		window.location.href='modul/laporan/hutang_jt.php?tgljt1='+tgljt1+'&tgljt2='+tgljt2+'&cari='+cari;
	});
	
	$("#tutup_jt").click(function(){
		document.location='?module=home';
	});
});
</script>

<style type="text/css">
#info {
	font-size:12px;
	font-weight:bold;
	color:#F00;
}
</style>
<?php
echo "<div id='tabs'>";
echo "<ul >
			<li><a href='#form'>INPUT DATA AWAL</a></li>
			<li><a href='#data'>HUTANG KESELURUHAN</a></li>
			<li><a href='#data_jt'>HUTANG JATUH TEMPO</a></li>
     </ul>";

	echo "<div id='form'></div>";
	
	echo "<div id='data'>
			<div id='pencarian'>
			<fieldset>
			<legend>Filter Data</legend>
			<table width='100%'>
				<tr>
					<td width='15%'>Cari Supplier</td>
					<td width='2%'>:</td>
					<td><input type='text' name='txt_caridat' id='txt_caridat' size='40'></td>
					<td colspan='6' align='right'>
						<button name='cetak_pd' id='cetak_pd'>Cetak</button>
						<button name='tutup_pd' id='tutup_pd'>Tutup</button>
					</td>
				</tr>
			</table>
			</fieldset>
			</div><br>
			<div id='tampil_data' align='center' style='overflow-x: auto;height: 400px;scroll-behavior: smooth'></div>
		</div>";
	
	echo "<div id='data_jt'>
			<div id='pencarian_jt'>
			<fieldset>
			<legend>Filter Data</legend>
			<table width='100%'>
				<tr>
					<td>Supplier</td>
					<td>:</td>
					<td><input type='text' name='txt_carispjt' id='txt_carispjt' size='20'></td>
					<td>Jatuh Tempo</td>
					<td>:</td>
					<td><input type='date' name='txt_tgljt1' id='txt_tgljt1'></td>
					<td>s/d</td>
					<td><input type='date' name='txt_tgljt2' id='txt_tgljt2'></td>
				</tr>
				<tr>
					<td colspan='12' align='center'>						
						<button name='cari_jt' id='cari_jt'>Cari</button>
						<button name='cetak_jt' id='cetak_jt'>Cetak</button>
						<button name='tutup_jt' id='tutup_jt'>Tutup</button>
					</td>
				</tr>
			</table>
			</fieldset>
			</div><br>
			<div id='tampil_data_jt' align='center' style='overflow-x: auto;height: 400px;scroll-behavior: smooth'></div>
	</div>";
	
	echo "<div id='info' align='center'></div>";
echo "</div>";
?>
