<script type="text/javascript">
$(document).ready(function(){
	$("#tabs").tabs({selected:0});	
	$("#form").load('modul/ubahstatus/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);
				$("#t_kodetk").val(data.kodetk);
			}
		});
	}
	
	$('#cari_tgl').click(function(){
		var tglawal = $("#t_tgl_awal").val();
		var tglakhir= $("#t_tgl_akhir").val();
		var cari    = $("#txt_caribrg").val();
		var kodetk  = $("#txt_kodetk").val();
	
		if(tglawal==''){
			alert('Maaf, tanggal awal belum diisi');
			return (false);
		}
		if(tglakhir==''){
			alert('Maaf, tanggal akhir belum diisi');
			return (false);
		}		
		$("#tampil_data_psb").show();
		$("#tampil_data_psb").load('modul/ubahstatus/tampil_data.php?tglawal='+tglawal+'&tglakhir='+tglakhir+'&cari='+cari+'&kodetk='+kodetk);
	});
		
	$("#cetak_psb").click(function(){
		var tglawal = $("#t_tgl_awal").val();
		var tglakhir= $("#t_tgl_akhir").val();
		var cari    = $("#txt_caripm").val();
		var kodetk  = $("#txt_kodetk").val();
		
		if(tglawal==''){
			alert('Maaf, tanggal awal belum diisi');
			return (false);
		}
		if(tglakhir==''){
			alert('Maaf, tanggal akhir belum diisi');
			return (false);
		}
		
		window.location.href='modul/laporan/daftar_psb.php?tglawal='+tglawal+'&tglakhir='+tglakhir+'&cari='+cari+'&kodetk='+kodetk;
	});
		
	$("#tutup_psb").click(function(){
		document.location='?module=home';
	});
});
</script>

<style type="text/css">
#info {
	font-size:12px;
	font-weight:bold;
	color:#F00;
}
</style>

<?php
$sql = mysql_query("SELECT * FROM pakai_bhn WHERE posting= ''");
$row = mysql_num_rows($sql);
if ($row>0){
	$input = "DELETE FROM pakai_bhn WHERE posting = ''";
	mysql_query($input);	
}

echo "<div id='tabs'>";
echo "<ul>
		<li><a href='#form'>INPUT PERUBAHAN STATUS</a></li>
		<li><a href='#data_psb'>DAFTAR PERUBAHAN STATUS</a></li>
	</ul>";
	
	echo "<div id='form'></div>";
		
	echo "<div id='data_psb'>
			<div id='pencarian_psb'>
				<fieldset>
				<legend>Filter Data</legend>
				<table>
				<tr>
					<input type='text' name='t_kodetk' id='t_kodetk' hidden/>
					<td>Cari Barang</td>
					<td>:</td>
					<td><input type='text' name='txt_caribrg' id='txt_caribrg' size='17'></td>
					<td>Tanggal</td>
					<td>:</td>
					<td><input type='date' name='t_tgl_awal' id='t_tgl_awal' size='10'></td>
					<td>s/d</td>
					<td><input type='date' name='t_tgl_akhir' id='t_tgl_akhir' size='10'></td>
				</tr>
				</table>
				
				<table align='center'>
				<tr>
					<td align='center'>
						<button name='cari_tgl' id='cari_tgl'>Cari</button>
						<button name='cetak_psb' id='cetak_psb'>Cetak</button>
						<button name='tutup_psb' id='tutup_psb'>Tutup</button>
					</td>
				</tr>
				</table>
				
				</fieldset>
			</div><br>
			
			<div id='tampil_data_psb' align='center'></div>
		</div>";
			
	echo "<div id='info' align='center'></div>";
	
echo "</div>";
?>
