<script type="text/javascript">	
$(document).ready(function() {
	$("#tabs").tabs({selected:0});
	$("#form").load('modul/inventory/form.php');
	$("#tampil_data_st").load('modul/inventory/tampil_data_st.php');	
	$("#info_ks").hide();
	$("#tampil_data_ks").hide();
	$("#tampil_detail_ks").hide();
	
	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){				
				$("#mb_tglawal").val(data.tanggal);
				$("#mb_tglakhir").val(data.tanggal);
				$("#ks_tglawal").val(data.tanggal);
				$("#ks_tglakhir").val(data.tanggal);
			}
		});
	}
	
	$('#txt_carist').keyup(function(){		
		var cari	= $("#txt_carist").val();
		
		var akses	= 1; 
		$.ajax({
			type	: "GET",
			url		: "modul/inventory/tampil_data_st.php",
			data	: "cari="+cari,
			timeout	: 3000,
			beforeSend	: function(){		
				$("#tampil_data_st").html("<img src='loading.gif' />");			
			},				  
			success	: function(data){
				$("#tampil_data_st").html(data);
			}
		});
	});
	
	$("#cetak_ds").click(function(){
		var cari= $("#txt_carist").val();
		
		window.location.href='modul/laporan/daftar_st.php?cari='+cari;
	});
	
	$("#cari_mb").click(function(){
		var cari= $("#txt_carist").val();
		var tglawal = $("#mb_tglawal").val();
		var tglakhir = $("#mb_tglakhir").val();
		var gudang	= $("#mb_tanki").val();
		
		if(tglawal.length == 0){			
			alert("Maaf, Tanggal awal pencarian masih kosong.");
			$("#mb_tglawal").focus();
			return (false);
         }
		 
		if(tglakhir.length == 0){
			alert("Maaf, Tanggal akhir pencarian masih kosong.");
			$("#mb_tglakhir").focus();
		   return (false);
        }
		 
		$("#tampil_data_mb").show();
		$("#tampil_data_mb").load('modul/inventory/tampil_data_mb.php?cari='+cari+'&tglawal='+tglawal+'&tglakhir='+tglakhir+'&gudang='+gudang);
	});
	
	$('#txt_carimb').keyup(function(){		
		var cari	= $("#txt_carimb").val();
		var tglawal = $("#mb_tglawal").val();
		var tglakhir = $("#mb_tglakhir").val();
		var gudang	= $("#mb_tanki").val();
		
		var akses	= 1; 
		$.ajax({
			type	: "GET",
			url		: "modul/inventory/tampil_data_mb.php",
			data	: "cari="+cari+
				"&tglawal="+tglawal+
				"&tglakhir="+tglakhir+
				"&gudang="+gudang,
			timeout	: 3000,
			beforeSend	: function(){		
				$("#tampil_data_mb").html("<img src='loading.gif' />");
			},				  
			success	: function(data){
				$("#tampil_data_mb").html(data);
			}
		});
	});
	
	$("#cetak_mb").click(function(){
		var cari= $("#txt_carimb").val();
		var tglawal = $("#mb_tglawal").val();
		var tglakhir = $("#mb_tglakhir").val();
		var gudang	= $("#mb_tanki").val();
		
		if(tglawal.length == 0){			
			alert("Maaf, Tanggal awal pencarian masih kosong.");
			$("#mb_tglawal").focus();
			return (false);
         }
		 
		if(tglakhir.length == 0){
			alert("Maaf, Tanggal akhir pencarian masih kosong.");
			$("#mb_tglakhir").focus();
		   return (false);
        }		
		window.location.href='modul/laporan/rekap_mb.php?cari='+cari+'&tglawal='+tglawal+'&tglakhir='+tglakhir+'&gudang='+gudang;
	});
	
	$("#cari_ks").click(function(){
		var cari= $("#txt_cariks").val();
		var tglawal = $("#ks_tglawal").val();
		var tglakhir = $("#ks_tglakhir").val();
		var gudang	= $("#ks_tanki").val();
		
		if(tglawal.length == 0){			
			alert("Maaf, Tanggal awal pencarian masih kosong.");
			$("#ks_tglawal").focus();
			return (false);
         }
		 
		if(tglakhir.length == 0){
			alert("Maaf, Tanggal akhir pencarian masih kosong.");
			$("#ks_tglakhir").focus();
		   return (false);
        }
		
		$.ajax({
			type	: "POST",
			url		: "modul/inventory/ubah_tgl.php",
			data	: "cari="+cari+
				"&tglawal="+tglawal+
				"&tglakhir="+tglakhir,
			timeout	: 3000,
			beforeSend	: function(){		
				$("#tampil_data_ks").html("<img src='loading.gif' />");			
			},				  
			success	: function(data){				
				$("#tampil_data_ks").html(data);
			}
		}); 
		 
		$.ajax({
			type	: "GET",
			url		: "modul/inventory/tampil_data_ks.php",
			data	: "cari="+cari+
					"&tglawal="+tglawal+
					"&tglakhir="+tglakhir+
					"&gudang="+gudang,
			timeout	: 3000,
			beforeSend	: function(){		
				$("#tampil_data_ks").html("<img src='loading.gif' />");			
			},				  
			success	: function(data){				
				$("#tampil_data_ks").html(data);
				$("#tampil_data_ks").show();
			}
		}); 
	});
	
	$("#refresh").click(function() {
		$("#tampil_data_ks").hide();
		$(".input_cari").val('');
	});
	
	$('#txt_cariks').keyup(function(){		
		var cari	= $("#txt_cariks").val();
		var tglawal = $("#ks_tglawal").val();
		var tglakhir= $("#ks_tglakhir").val();
		var gudang	= $("#ks_tanki").val();
		
		var akses	= 1; 
		$.ajax({
			type	: "GET",
			url		: "modul/inventory/tampil_data_ks.php",
			data	: "cari="+cari+
				"&tglawal="+tglawal+
				"&tglakhir="+tglakhir+
				"&gudang="+gudang,
			timeout	: 3000,
			beforeSend	: function(){		
				$("#tampil_data_ks").html("<img src='loading.gif' />");			
			},				  
			success	: function(data){
				$("#tampil_data_ks").html(data);
			}
		});
	});
	
	$("#cetak_ks").click(function(){
		var kode	= $("#t_kodest").val();				
		var tglawal = $("#ks_tglawal").val();
		var tglakhir = $("#ks_tglakhir").val();
		var gudang	= $("#ks_tanki").val();
		
		window.location.href='modul/laporan/kartu_st.php?kode='+kode+'&tglawal='+tglawal+'&tglakhir='+tglakhir+'&gudang='+gudang;
	});
		
	$("#tutup_ds").click(function(){
		document.location='?module=home';
	});
	
	$("#tutup_mb").click(function(){
		document.location='?module=home';
	});

	$("#tutup_detail").click(function(){
		var cari	= $("#txt_cariks").val();
		var tglawal = $("#ks_tglawal").val();
		var tglakhir= $("#ks_tglakhir").val();
		var gudang	= $("#ks_tanki").val();
		
		$("#info_ks").hide();
		$("#tampil_detail_ks").hide();
		$("#pencarian_ks").show();
		$("#tampil_data_ks").show();
		$("#tampil_data_ks").load('modul/inventory/tampil_data_ks.php?cari='+cari+'&tglawal='+tglawal+'&tglakhir='+tglakhir+'&gudang='+gudang);
	});
	
	$("#tutup_ks").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'>Update Data Barang</a></li>
	       <li><a href='#data_st'>Daftar Persediaan</a></li>		   
		   <li><a href='#data_mb'>Rekap Mutasi Barang</a></li>
		   <li><a href='#data_ks'>Kartu Persediaan</a></li>
		</ul>";
		
	echo "<div id='form'></div>";
		
	echo "<div id='data_st'>
			<div id='pencarian_st'>
			<fieldset>
			<legend>Filter Data</legend>
			<table width='100%'>
				<tr>
					<td>Cari data : <input type='text' name='txt_carist' id='txt_carist' size='50'></td>
					<td>
						<button name='cetak_ds' id='cetak_ds'>Cetak</button>
						<button name='tutup_ds' id='tutup_ds'>Tutup</button>
					</td>
				</tr>
			</table>
			</fieldset>
			</div><br>
			<div id='tampil_data_st' align='center'></div>
		</div>";
		
	echo "<div id='data_mb'>
			<div id='pencarian_mb'>
			<fieldset>
			<legend>Filter Data</legend>
			<table width='100%'>
				<tr>					
					<td>Tanggal : <input type='date' name='mb_tglawal' id='mb_tglawal' size='10' > s/d <input type='date' name='mb_tglakhir' id='mb_tglakhir' size='10' ></td>
					<td>Tanki : <select name='mb_tanki' id='mb_tanki' class='input' >
						<option>1</option>
						<option>2</option>
						<option>3</option></select>
					</td>
					<td>Cari Barang : <input type='text' name='txt_carimb' id='txt_carimb' size='30'></td>
					<td>
						<button name='cari_mb' id='cari_mb'>Cari</button>
						<button name='cetak_mb' id='cetak_mb'>Cetak</button>
						<button name='tutup_mb' id='tutup_mb'>Tutup</button>
					</td>
				</tr>
			</table>
			</fieldset>
			</div><br>
			<div id='tampil_data_mb' align='center'></div>
		</div>";
	
	echo "<div id='data_ks'>
			<input type='text' name='t_kodest' id='t_kodest' hidden />
			<input type='text' name='t_namast' id='t_namast' hidden />
			<input type='text' name='t_satuan' id='t_satuan' hidden />
			<input type='text' name='t_jmlstok' id='t_jmlstok' hidden />
			<input type='text' name='t_stawal' id='t_stawal' hidden />
			<input type='text' name='t_tglawal' id='t_tglawal' hidden />
			<input type='text' name='t_tglakhir' id='t_tglakhir' hidden />
			
			<div id='pencarian_ks'>
				<fieldset>
					<legend>Filter Data</legend>
					<table width='100%'>
						<tr>							
							<td>Tanggal : <input type='date' name='ks_tglawal' id='ks_tglawal' size='10' class='input_cari'> s/d <input type='date' name='ks_tglakhir' id='ks_tglakhir' size='10' class='input_cari'></td>
							<td>Tanki : <select name='ks_tanki' id='ks_tanki' class='input' >
								<option>1</option>
								<option>2</option>
								<option>3</option></select>
							</td>
							<td>Cari Barang : <input type='text' name='txt_cariks' id='txt_cariks' size='30' class='input_cari'></td>
							<td>
								<button name='cari_ks' id='cari_ks'>Cari Data</button>
								<button name='refresh' id='refresh'>Refresh</button>
								<button name='tutup_ks' id='tutup_ks'>Tutup</button>
							</td>									
						</tr>				
					</table>
				</fieldset>
			</div><br>
			
			<div id='tampil_data_ks' align='center'></div>
			
			<div id='info_ks'>
				<table width='100%'>					
					<tr>
						<td align='right'>
							<button name='cetak_ks' id='cetak_ks'>Cetak</button>
							<button name='tutup_detail' id='tutup_detail'>Tutup Detail</button>
						</td>					
					</tr>
				</table>							
			</div>
			<div id='tampil_detail_ks' align='center'></div>
		</div>";
		
	echo "<div id='info' align='center'></div>";
echo "</div>";
?>
