<script type="text/javascript">	
$(document).ready(function() {	
	$("#tabs").tabs({selected:0});
	$("#form").load('modul/ubah_status/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){				
				$("#tgl_awal").val(data.tanggal);
				$("#tgl_akhir").val(data.tanggal);		
			}
		});
	}
	
	$("#cari_psb").click(function(){
		var tgl_awal = $("#tgl_awal").val();
		var tgl_akhir= $("#tgl_akhir").val();
		var cari	 = $("#txt_carist").val();
		var gudang   = $("#t_gudang").val();
		
		$("#tampil_daftar").show();
		$("#tampil_daftar").load('modul/ubah_status/tampil_daftar.php?tgl_awal='+tgl_awal+'&tgl_akhir='+tgl_akhir+'&cari='+cari+'&gudang='+gudang);
	});
	
	$("#txt_carist").keyup(function(){
		var tgl_awal = $("#tgl_awal").val();
		var tgl_akhir= $("#tgl_akhir").val();
		var cari	 = $("#txt_carist").val();
		var gudang   = $("#t_gudang").val();
		
		$.ajax({
			type	: "GET",
			url	    : "modul/ubah_status/tampil_daftar.php",
			data	: "tgl_awal="+tgl_awal+
					"&tgl_akhir="+tgl_akhir+
					"&gudang="+gudang+
					"&cari="+cari,
			success	: function(data){
				$("#tampil_daftar").html(data);
			}
		});
	});
	
	$("#cetak_psb").click(function(){
		var tgl_awal = $("#tgl_awal").val();
		var tgl_akhir= $("#tgl_akhir").val();
		var cari	 = $("#txt_carist").val();
		var gudang   = $("#t_gudang").val();
		
		window.location.href='modul/laporan/daftar_psb.php?tgl_awal='+tgl_awal+'&tgl_akhir='+tgl_akhir+'&cari='+cari+'&gudang='+gudang;
	});

	$("#tutup_psb").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'>INPUT PERUBAHAN STATUS BARANG</a></li>
	    <li><a href='#daftar'>DAFTAR PERUBAHAN STATUS BARANG</a></li>
	</ul>";
	  
echo "<div id='form'></div>";
	
echo "<div id='daftar'>
		<div id='pencarian'>
			<table width='100%'>
				<tr>
					<td>Tanggal transaksi : <input type='date' id='tgl_awal' size='10'> sampai dengan <input type='date' id='tgl_akhir' size='10'></td>
					<td>Gudang : <select id='t_gudang'>
			            	<option value=''></option>
				            <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>Cari barang : <input type='text' id='txt_carist' class='input' size='40'></td>
					<td>
						<button id='cari_psb'>Cari</button>
						<button id='cetak_psb'>Cetak</button>
						<button id='tutup_psb'>Tutup</button>
					</td>
				</tr>
			</table>
		</div>
			
		<div id='tampil_daftar' align='center' style='overflow-x: auto;height: 400px;scroll-behavior: smooth'></div>
	</div>";

echo "<div id='info' align='center'></div>";

echo "</div>";
?>