<script type="text/javascript">	
$(document).ready(function() {	
	$("#tabs").tabs({selected:0});
	$("#tampil_data").load('spv/returjual/tampil_data.php');
	$("#data").load('modul/report/daftar_rj.php');		
	$("#tampil_data").hide();
	$("#info_retur").hide();
	
	$("#cari_tgl").click(function(){
		var tgl_awal = $("#txt_tglaw").val();
		var tgl_akhir = $("#txt_tglak").val();
		
		if(tgl_awal.length==''){
			alert('Maaf, Variabel tanggal belum lengkap');
			$("#txt_tglaw").focus();
			return false;
		}
		if(tgl_akhir.length==''){
			alert('Maaf, Variabel tanggal belum lengkap');
			$("#txt_tglak").focus();
			return false;
		}
		$("#info_retur").hide();
		$("#tampil_data").show();
		$("#tampil_data").load('spv/returjual/tampil_data.php?tgl_awal='+tgl_awal+'&tgl_akhir='+tgl_akhir);
	});
	
	$("#batal_rj").click(function(){
		var kode		= $("#t_koderj").val();
		var pilih = confirm('Apakah Anda sungguh-sungguh ingin batalkan '+kode+' ?');
		
		if (pilih==true) {			
			var tgl_awal = $("#txt_tglaw").val();
			var tgl_akhir = $("#txt_tglak").val();
				
			$.ajax({
				type		: "POST",
				url		: "spv/returjual/batal.php",
				data		: "kode="+kode,
				timeout: 2000,
				beforeSend	: function(){		
					$("#info").html("<img src='loading.gif' />");			
				},
				success	: function(data){
					$("#info").html(data);					
					$("#info_retur").hide();
					$("#tampil_detail").hide();
					$("#pencarian").show();
					$("#tampil_data").show();
					$("#tampil_data").load('spv/returjual/tampil_data.php?tgl_awal='+tgl_awal+'&tgl_akhir='+tgl_akhir);
				}
			});
		}
		return false; 		
	});
		
	$("#tutup_detail").click(function(){
		$("#pencarian").show();
		$("#info_retur").hide();
		$("#tampil_detail").hide();
		$("#tampil_data").show();		
	});
	
	$("#tutup").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 RETUR PENJUALAN</a></li>
		   <li><a href='#form_batal'>BATAL RETUR PENJUALAN</a></li>
      </ul>";
	  
echo "<div id='data'></div>";
	
echo "<div id='form_batal'>
			<div id='pencarian'>
				<table width='100%'>
				<tr>
					<td width='13%'>Tanggal retur</td>
					<td width='2%'>:</td>
					<td><input type='date' name='txt_tglaw' id='txt_tglaw' size='10'></td>
					<td width='15%'>Sampai dengan</td>
					<td><input type='date' name='txt_tglak' id='txt_tglak' size='10'></td>
					<td width='10%'></td>
					<td align='right'>
						<button name='cari_tgl' id='cari_tgl'>Cari</button>
						<button name='tutup' id='tutup'>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_retur'>
				<table>
				<tr>
					<td width='12.5%'>Kode Retur</td>
					<td>:</td>
					<td><input type='text' name='t_koderj' id='t_koderj' size='8' readonly></td>
					<td width='2.5%'></td>
					<td width='13.6%'>Tanggal</td>
					<td>:</td>
					<td><input type='date' name='t_tanggal' id='t_tanggal' size='10' readonly></td>
					<td width='1.5%'>
					<td>Pelanggan</td>
					<td>:</td>
					<td>
						<input type='text' name='t_kodeplg' id='t_kodeplg' size='4' readonly>
						<input type='text' name='t_namaplg' id='t_namaplg' size='15' readonly>
					</td>
				</tr>
				</table>
				
				<table>
				<tr>
					<td>Nomor Faktur</td>
					<td>:</td>
					<td><input type='text' name='t_nomorfk' id='t_nomorfk' size='10' readonly></td>
					<td></td>
					<td>Tanggal Faktur</td>
					<td>:</td>
					<td><input type='date' name='t_tanggalfk' id='t_tanggalfk' size='10' readonly></td>
					<td width='15.5%'></td>
					<td align='right'>
						<button name='batal_rj' id='batal_rj'>Batal</button>
						<button name='tutup_detail' id='tutup_detail'>Tutup Detail</button>
					</td>					
				</tr>
				</table>						
			</div>
			
			<div id='tampil_detail' align='center' style='overflow-x: auto;height: 400px;scroll-behavior: smooth'></div>
		</div>";
		
echo "<div id='info' align='center'></div>";

echo "</div>";
?>