<script type="text/javascript">	
$(document).ready(function() {	
	$("#tabs").tabs({selected:0});	
	$("#data").load('modul/report/daftar_pjimp.php');
	$("#info_jual").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){				
				$("#t_tglaw").val(data.tanggal);
				$("#t_tglak").val(data.tanggal);				
			}
		});
	}
	
	$("#cari_data").click(function(){
		var tgl_awal 	= $("#t_tglaw").val();
		var tgl_akhir	= $("#t_tglak").val();
		
		$("#info_jual").hide();
		$("#tampil_data").show();
		$("#tampil_data").load('spv/import_sop/tampil_data.php?tgl_awal='+tgl_awal+'&tgl_akhir='+tgl_akhir);
	});

	$("#batal_pj").click(function(){
		var kode	 	= $("#t_kode").val();
		var tgl_awal 	= $("#t_tglaw").val();
		var tgl_akhir	= $("#t_tglak").val();
		
		var pilih = confirm('Apakah Anda sungguh-sungguh ingin batalkan import SOP '+kode+' ini ?');
		
		if(pilih==true) {
			var kodesop	= $("#t_kodesop").val();
			var kodeplg	= $("#t_kodeplg").val();			
			var total	= $("#t_total").val();
			var potong	= $("#t_potong").val();
			var bayar	= $("#t_bayar").val();
			var kurang	= $("#t_kurang").val();
			var thpp	= $("#t_thpp").val();
			
			$.ajax({
				type	: "POST",
				url		: "spv/import_sop/batal.php",
				data	: "kode="+kode+
					"&kodesop="+kodesop+
					"&kodeplg="+kodeplg+
					"&total="+total+
					"&potong="+potong+
					"&bayar="+bayar+
					"&kurang="+kurang+					
					"&thpp="+thpp,
				timeout	: 2000,
				beforeSend	: function(){		
					$("#info").html("<img src='loading.gif' />");			
				},
				success	: function(data){
					$("#info").html(data);					
					$("#info_jual").hide();
					$("#tampil_detail").hide();
					$("#pencarian").show();
					$("#tampil_data").show();
					$("#tampil_data").load('spv/import_sop/tampil_data.php?tgl_awal='+tgl_awal+'&tgl_akhir='+tgl_akhir);
				}
			});
		}		
	});
	
	$("#tutup_detail").click(function(){
		$("#pencarian").show();
		$("#info_jual").hide();
		$("#tampil_detail").hide();
		$("#tampil_data").show();		
	});
	
	$("#tutup_pj").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='#data'>DAFTAR IMPORT SOP</a></li>
	       <li><a href='#form_batal'>BATAL IMPORT SOP</a></li>
      </ul>";
	  
echo "<div id='data'></div>";
	  
echo "<div id='form_batal'>
		<div id='pencarian'>
			<table width='100%'>
				<tr>
					<td>Penjualan tanggal : <input type='date' id='t_tglaw' size='10'> sampai dengan <input type='date' id='t_tglak' size='10'></td>
					<td>
						<button id='cari_data'>Cari</button>
						<button id='tutup_pj'>Tutup</button>
					</td>
				</tr>
			</table>
		</div>
			
		<div id='tampil_data' align='center' style='overflow-x: auto;height: 400px;scroll-behavior: smooth'></div>
			
		<div id='info_jual'>
			<table width='100%'>
				<tr>					
					<td>No. Faktur : <input type='text' id='t_kode' size='14' readonly/></td>
					<td>Tanggal : <input type='date' id='t_tanggal' size='10' readonly/></td>
					<td>Nomor SOP : <input type='text' id='t_kodesop' size='14' readonly/></td>
					<td>Pelanggan : <input type='text' id='t_namaplg' size='25' readonly/> <input type='text' id='t_kodeplg' size='4' readonly/></td>
					<td>Jatuh Tempo : <input type='date' id='t_tanggaljt' size='10' class='input_header' readonly/></td>
				</tr>
			</table>
				
			<table>
				<tr>
					<input type='text' name='t_thpp' id='t_thpp' class='input_header' size='9' hidden />
					<td>Total : <input type='text' name='t_total' id='t_total' class='input_header' size='9' readonly/></td>
					<td>Potongan : <input type='text' name='t_potong' id='t_potong' class='input_header' size='9' readonly/></td>
					<td>Dibayar : <input type='text' name='t_bayar' id='t_bayar' class='input_header' size='9' readonly/></td>
					<td>Terhutang : <input type='text' name='t_kurang' id='t_kurang' class='input_header' size='9' readonly /></td>
					<td>
						<button id='batal_pj'>Batal</button>
						<button id='tutup_detail'>Tutup</button>
					</td>
				</tr>
			</table>						
		</div>
			
		<div id='tampil_detail' align='center' style='overflow-x: auto;height: 650px;scroll-behavior: smooth'></div>
	</div>";
		
echo "<div id='info' align='center'></div>";

echo "</div>";
?>