<script type="text/javascript">
$(document).ready(function(){
	$("#detail_posting").load("spv/st_opname/tampil_data_post.php");
	
	$('#form_cari_kodeop').dialog({
		autoOpen: false,
		modal	: true,
		width: 600,
	});
		
	$('#cari_kodeop').click(function(){
		$('#form_cari_kodeop').dialog('open');
		no=1
		$.ajax({
			type	: "POST",
			url		: "spv/st_opname/tampil_op_post.php",
			data	: "no="+no,
			timeout	: 3000,
			beforeSend	: function(){
				$("#info_kodeop").html("<img src='loading.gif' />");		
			},				  
			success	: function(data){				
				$("#info_kodeop").html(data);
			}
		});
	});
	
	$("#post_so").click(function(){
		posting_so();
	});
		
	function posting_so(){
		var	kode	= $("#t_kode").val();
		var	tanggal	= $("#t_tanggal").val();
		var	gudang 	= $("#t_gudang").val();
		
		var error = false;
		if(kode.length == 0){
           var error = true;
			alert("Maaf, Kode stok opname masih kosong, klik icon di samping Kode opname untuk mencari.");
		   return (false);
        }
			
		if(error == false){		
		$.ajax({
			type	: "POST",
			url		: "spv/st_opname/posting.php",
			data	: "kode="+kode+
				"&tanggal="+tanggal+
				"&gudang="+gudang,
			timeout	: 3000,
			beforeSend	: function(){		
				$("#info").html("<img src='loading.gif' />");			
			},				  
			success	: function(data){
				$("#info").html(data);
				$("#t_kode").val('');				
				$("#detail_posting").load("spv/st_opname/tampil_data_post.php");
			}
		});
		}
		return false;
	}
		
	$("#tutup_post").click(function(){
		document.location='?module=home';
	});
});
</script>

<style type="text/css">
#txt_kode {
	background:#CCC;
}
#cari_produk{
	cursor:pointer;
}
#cari_buyer{
	cursor:pointer;
}
.input_detail readonly {
	background:#666;
}
</style>

<?php
include '../../inc/fungsi_tanggal.php';

echo "<table width='100%'>	
	<tr>
		<td>Kode Opname</td>
		<td>:</td>
		<td>
			<input type='text' name='t_kode' id='t_kode' size='9' class='input_header' readonly />
			<img src='images/view.png' width='18' height='18' title='Cari Kode Opname' id='cari_kodeop'>
		</td>
		<td>Tanggal</td>
		<td>:</td>
		<td><input type='date' name='t_tanggal' id='t_tanggal' size='9' class='input_header' readonly /></td>
		<td>Tanki</td>
		<td>:</td>
		<td><input type='text' name='t_gudang' id='t_gudang' size='1' class='input_header' readonly /></td>
		<td align='right'>
			<button name='post_so' id='post_so'>Posting</button>
			<button name='tutup_post' id='tutup_post'>Tutup</button>
		</td>
	</tr>
	</table>
	<div id='detail_posting'></div>";

echo "<div id='form_cari_kodeop' title='Pencarian Kode Opname'>	
		<div id='info_kodeop' align='center'></div>
	</div>";
?>