<script type="text/javascript">	
$(document).ready(function() {
	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){
				$("#t_tgl_awal").val(data.tanggal);
				$("#t_tgl_akhir").val(data.tanggal);
			}
		});
	}
	
	$('#form_cari_sp').dialog({
		autoOpen: false,
		modal	: true,
		width: 600,
	});
		
	$('#t_namasp').keyup(function(){
		var cari = $("#carisup").val();
		$('#form_cari_sp').dialog('open');
		$("#info_sp").load('modul/report/tampil_data_sup.php?cari='+cari);
		$("#carisup").focus();
	});
	
	$("#carisup").keyup(function(){
		var cari = $("#carisup").val();
		
		$.ajax({
			type	: "POST",
			url		: "modul/report/tampil_data_sup.php",
			data	: "cari="+cari,
			success	: function(data){
				$("#info_sp").html(data);
			}
		});
	});
	
	$("#cari").click(function(){
		var tgl_awal = $("#t_tgl_awal").val();
		var tgl_akhir= $("#t_tgl_akhir").val();
		var kodesp	= $("#t_kodesp").val();
		
		$("#data_pb").show();
		$("#data_pb").load('modul/report/tampil_rekap_pb.php?tgl_awal='+tgl_awal+'&tgl_akhir='+tgl_akhir+'&kodesp='+kodesp);
	});
	
	$("#refresh").click(function() {
		window.location.reload();		
	});
	
	$("#cetak").click(function() {
		var tgl_awal = $("#t_tgl_awal").val();
		var tgl_akhir= $("#t_tgl_akhir").val();
		var kodesp	= $("#t_kodesp").val();
		var namasp	= $("#t_namasp").val();
		
		window.location.href='modul/laporan/rekap_pbl.php?tgl_awal='+tgl_awal+'&tgl_akhir='+tgl_akhir+'&kodesp='+kodesp+'&namasp='+namasp;
	});
	
	$("#tutup").click(function(){
		document.location='?module=home';
	});
	
});
</script>
<style type="text/css">
#info {
	font-size:12px;
	font-weight:bold;
	color:#F00;
}
</style>

<?php
include '../../inc/inc.koneksi.php';
	
echo "<div span='12' style='background-color:white'>";
echo "<div id='form' align='center'><h2>REKAP PEMBELIAN BARANG DAGANGAN<h2></div>";
echo "<div id='filter' align='left'>
	<fieldset>
		<legend>Filter Data </legend>
		<table width='100%' style='font:14px Verdana'>
			<tr>
				<td>Tanggal : <input type='date' id='t_tgl_awal' size='10'> sampai dengan <input type='date' id='t_tgl_akhir' size='10'></td>
				<td>Supplier : <input type='text' id='t_namasp' size='25' class='input' >
					<input type='text' id='t_kodesp' size='3' class='input' class='filter_ds' readonly />
				</td>
				<td>
					<button id='cari'>Cari</button>
					<button id='cetak'>Cetak</button>
					<button id='refresh'>Refresh</button>
					<button id='tutup'>Tutup</button>
				</td>
			</tr>
		</table>
		<table width='100%'>
			<tr>
				
			</tr>
		</table>
	</fieldset>
	</div><br>";

echo "<div id='form_cari_sp' title='Pencarian Data Supplier'>
		<table>
			<tr>
				<td>Cari Supplier : <input type='text' id='carisup' size='40'></td>
			</tr>
		</table>
		<div id='info_sp' align='center' style='overflow-x: auto;height: 400px;scroll-behavior: smooth'></div>
	</div>";
	
echo "<div id='data_pb' align='center' style='overflow-x: auto;height: 400px;scroll-behavior: smooth'></div>";

echo "</div>";
?>