<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);
			}
		});
	}

	$("#cari").click(function(){
		var tgl_awal = $("#t_tgl_awal").val();
		var tgl_akhir = $("#t_tgl_akhir").val();
		
		if(tgl_awal.length==''){
			alert('Maaf, Tanggal awal periode masih kosong.');
			$("#t_tgl_awal").focus();
			return false;
		}
		if(tgl_akhir.length==''){
			alert('Maaf, Tanggal akhir periode belum terisi.');
			$("#t_tgl_akhir").focus();
			return false;
		}
		$("#data_pj").show();
		$("#data_pj").load('modul/report/tampil_rekap_pj.php?tgl_awal='+tgl_awal+'&tgl_akhir='+tgl_akhir);
	});
	
	$("#refresh").click(function() {
		window.location.reload();		
	});
	
	$("#cetak").click(function() {
		var tgl_awal = $("#t_tgl_awal").val();
		var tgl_akhir = $("#t_tgl_akhir").val();
		
		if(tgl_awal.length==''){
			alert('Maaf, Tanggal awal periode belum terisi.');
			$("#t_tgl_awal").focus();
			return false;
		}
		if(tgl_akhir.length==''){
			alert('Maaf, Tanggal akhir periode masih kosong.');
			$("#t_tgl_akhir").focus();
			return false;
		}		
		window.location.href='modul/laporan/rekap_pjl.php?tgl_awal='+tgl_awal+'&tgl_akhir='+tgl_akhir;
	});
	
	$("#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 PENJUALAN BARANG DAGANGAN<h2></div>";
echo "<div id='filter' align='left'>
	<fieldset>
		<legend>Filter Data </legend>
		<table width='100%'>
			<tr>
				<td>Tanggal</td>
				<td>:</td>
				<td><input type='date' name='t_tgl_awal' id='t_tgl_awal' size='10'></td>				
				<td>Sampai dengan</td>
				<td>:</td>
				<td><input type='date' name='t_tgl_akhir' id='t_tgl_akhir' size='10'></td>

				<td align='right'>
					<button name='cari' id='cari'>Cari</button>
					<button name='cetak' id='cetak'>Cetak</button>
					<button name='refresh' id='refresh'>Refresh</button>
					<button name='tutup' id='tutup'>Tutup</button>
				</td>
			</tr>
		</table>
	</fieldset>
	</div><br>";
	
echo "<div id='data_pj' align='center'></div>";

echo "</div>";
?>
