<script type="text/javascript">	
$(document).ready(function() {	
	$("#tabs").tabs({selected:0});	
	$("#form").load('spv/st_opname/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){				
				$("#t_tgl_awal").val(data.tanggal);
				$("#t_tgl_akhir").val(data.tanggal);				
			}
		});
	}
	
	$("#cari_tgl").click(function(){
		var tgl_awal 	= $("#t_tgl_awal").val();
		var tgl_akhir 	= $("#t_tgl_akhir").val();
		var gudang		= $("#t_gudang").val();
		
		$("#tampil_data").show();
		$("#tampil_data").load('modul/opname/tampil_data.php?tgl_awal='+tgl_awal+'&tgl_akhir='+tgl_akhir+'&gudang='+gudang);
	});
	
	$("#cetak_opn").click(function(){
		var tgl_awal 	= $("#t_tgl_awal").val();
		var tgl_akhir 	= $("#t_tgl_akhir").val();
		var gudang		= $("#t_gudang").val();
		
		window.location.href='modul/laporan/daftar_so.php?tgl_awal='+tgl_awal+'&tgl_akhir='+tgl_akhir+'&gudang='+gudang;
	});
	
	$("#tutup_op").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 id='tabs'>";
	echo "<ul >
			<li><a href='#form'>POSTING STOK OPNAME</a></li>
			<li><a href='#data'>DAFTAR STOK OPNAME</a></li>			
		</ul>";
	  
	echo "<div id='form'></div>";
	
	echo "<div id='data'>
		<div id='pencarian'>
			<table width='100%'>
				<tr>
					<td>Tanggal : <input type='date' name='t_tgl_awal' id='t_tgl_awal' size='10'> sampai dengan <input type='date' name='t_tgl_akhir' id='t_tgl_akhir' size='10'></td>
					<td>Gudang : <select id='t_gudang'>
				        <option value='Gudang'>Gudang Pusat</option>";
				        $sql=mysql_query("SELECT * FROM cabang WHERE 1 ORDER BY kode_cab");
				        while($r=mysql_fetch_array($sql)){
				            $kodecab=$r[kode_cab];
				            echo "<option value='$kodecab'>$r[nama_cab]</option>";
				        }
			            echo "</select>
		            </td>
					<td>
						<button id='cari_tgl'>Cari</button>
						<button id='cetak_opn'>Cetak</button>
						<button id='tutup_op'>Tutup</button>
					</td>
				</tr>
			</table>
		</div>
			
		<div id='tampil_data' align='center' style='overflow-x: auto;height: 400px;scroll-behavior: smooth'></div>
	</div>";
	
	echo "<div id='info' align='center'></div>";

echo "</div>";
?>