<script type="text/javascript">
$(document).ready(function(){
	$("#detail_posting").load('spv/st_opname/tampil_data.php');
	
	$('#form_cari_kodepos').dialog({
		autoOpen: false,
		modal	: true,
		width: 600,
	});
		
	$('#cari_kodepos').click(function(){
		$('#form_cari_kodepos').dialog('open');
		no=1
		
		$.ajax({
			type	: "POST",
			url		: "spv/st_opname/tampil_data_op.php",
			data	: "no="+no,
			timeout	: 3000,
			beforeSend	: function(){
				$("#info_kodepos").html("<img src='loading.gif' />");			
			},				  
			success	: function(data){				
				$("#info_kodepos").html(data);
			}
		});
	});
	
	$("#posting").click(function(){
		posting_so();
	});
		
	function posting_so(){
		var	kode	= $("#t_kode").val();
		var	tanggal	= $("#t_tanggal").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,
								
			timeout	: 3000,
			beforeSend	: function(){		
				$("#info").html("<img src='loading.gif' />");			
			},				  
			success	: function(data){
				$("#info").html(data);
				$("#t_kode").val('');
				$("#t_tanggal").val('');
				$("#detail_posting").load("spv/st_opname/tampil_data.php");				
			}
		});
		}
		return false;
	}
		
	$("#tutup_pos").click(function(){
		document.location='?module=home';
	});
});
</script>

<style type="text/css">
#txt_kode {
	background:#CCC;
}
</style>

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

echo "<table width='100%'>	
	<tr>
		<td>Kode Opname : <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_kodepos'>
		</td>
		<td>Tanggal : <input type='date' name='t_tanggal' id='t_tanggal' size='9' class='input_header' readonly /></td>
		<td align='right'>
			<button name='posting' id='posting'>Posting</button>
			<button name='tutup_pos' id='tutup_pos'>Tutup</button>
		</td>
	</tr>
	</table>
	<div id='detail_posting' style='overflow-x: auto;height: 400px;scroll-behavior: smooth'></div>";

echo "<div id='form_cari_kodepos' title='Pencarian Kode Opname'>		
		<div id='info_kodepos' align='center' style='overflow-x: auto;height: 400px;scroll-behavior: smooth'></div>
	</div>";
?>