<script type="text/javascript">	
$(document).ready(function() {	
	$("#tabs").tabs({selected:0});	
	$("#form").load('spv/st_opname/form.php');	
	$("#tampil_data").load('modul/opname/tampil_data.php');
	$("#tampil_data_blk").load('modul/opname/tampil_data_blk.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();
		
		if(tgl_awal.length==''){
			alert('Maaf, Variabel tanggal belum lengkap');
			$("#t_tgl_awal").focus();
			return false;
		}
		if(tgl_akhir.length==''){
			alert('Maaf, Variabel tanggal belum lengkap');
			$("#t_tgl_akhir").focus();
			return false;
		}
		$("#tampil_data").show();
		$("#tampil_data").load('modul/opname/tampil_data.php?tgl_awal='+tgl_awal+'&tgl_akhir='+tgl_akhir);
	});
	
	$('#txt_carist').keyup(function(){		
		var cari	= $("#txt_carist").val();
		
		var akses	= 1; 
		$.ajax({
			type	: "GET",
			url		: "modul/opname/tampil_data_blk.php",
			data	: "cari="+cari,
			timeout	: 3000,
			beforeSend	: function(){		
				$("#tampil_data_blk").html("<img src='loading.gif' />");			
			},				  
			success	: function(data){
				$("#tampil_data_blk").html(data);
			}
		});
	});
	
	$("#cetak_opn").click(function(){
		var tgl_awal = $("#t_tgl_awal").val();
		var tgl_akhir = $("#t_tgl_akhir").val();
		
		if(tgl_awal.length==''){
			alert('Maaf, Variabel tanggal belum lengkap');
			$("#t_tgl_awal").focus();
			return false;
		}
		if(tgl_akhir.length==''){
			alert('Maaf, Variabel tanggal belum lengkap');
			$("#t_tgl_akhir").focus();
			return false;
		}
		window.location.href='modul/laporan/daftar_so.php?tgl_awal='+tgl_awal+'&tgl_akhir='+tgl_akhir;
	});
	
	$("#cetak_blk").click(function(){
		var cari = $("#txt_carist").val();
		
		window.location.href='modul/laporan/blangko_so.php?cari='+cari;
	});
	
	$("#tutup_op").click(function(){
		document.location='?module=home';
	});
	
	$("#tutup_blk").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'>POSTING STOK OPNAME</a></li>
			<li><a href='#data'>DAFTAR STOK OPNAME</a></li>
			<li><a href='#blangko'>BLANGKO STOK OPNAME</a></li>
		</ul>";
	  
	echo "<div id='form'></div>";
	
	echo "<div id='data'>
			<div id='pencarian'>
				<table width='100%'>
				<tr>
					<td width='19%'>Stok opname tanggal</td>					
					<td><input type='date' name='t_tgl_awal' id='t_tgl_awal' size='10'></td>
					<td width='14%'>Sampai dengan</td>
					<td><input type='date' name='t_tgl_akhir' id='t_tgl_akhir' size='10'></td>					
					<td align='right'>
						<button name='cari_tgl' id='cari_tgl'>Cari</button>
						<button name='cetak_opn' id='cetak_opn'>Cetak</button>
						<button name='tutup_op' 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='blangko'>
			<div id='pencarian_st'>
				<fieldset>
				<legend>Filter Data</legend>
				<table width='100%'>
				<tr>
					<td width='10%'>Cari Kata</td>
					<td width='2%'>:</td>
					<td><input type='text' name='txt_carist' id='txt_carist' size='50'></td>
					<td colspan='6' align='right'>
						<button name='cetak_blk' id='cetak_blk'>Cetak</button>
						<button name='tutup_blk' id='tutup_blk'>Tutup</button>
					</td>
				</tr>
			</table>
			</fieldset>
			</div><br>
			
			<div id='tampil_data_blk' align='center' style='overflow-x: auto;height: 400px;scroll-behavior: smooth'></div>
		</div>";
		
	echo "<div id='info' align='center'></div>";

echo "</div>";
?>
