<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();
	
	function cari_tgl(){
		var no = 1;
		$.ajax({
			type	: "POST",
			url		: "modul/report/cari_tanggal.php",
			data	: "no="+no,
			dataType: "json",
			success	: function(data){				
				$("#txt_tglaw").val(data.tanggal);
				$("#txt_tglaw").val(data.tanggal);				
			}
		});
	}
	
	$("#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	kodeplg = $("#t_kodeplg").val();
		var	caraby  = $("#t_caraby").val();
		var	total	= $("#t_total").val();
		var	tothpp 	= $("#t_total").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+
					"&kodeplg="+kodeplg+
					"&caraby="+caraby+
					"&total="+total+
					"&tothpp="+tothpp,
				
				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'></div>
			
			<div id='info_retur'>
				<table>
				<tr>
					<td width='11%'>Kode Retur</td>
					<td>:</td>
					<td><input type='text' name='t_koderj' id='t_koderj' size='8' readonly></td>
					<td width='2%'></td>
					<td>Tanggal</td>
					<td>:</td>
					<td><input type='date' name='t_tanggal' id='t_tanggal' size='10' readonly /></td>		
					<td width='1%'></td>
					<td>Pelanggan</td>
					<td>:</td>
					<td>
						<input type='text' name='t_kodeplg' id='t_kodeplg'  size='3' readonly / >			
						<input type='text' name='t_namaplg' id='t_namaplg' readonly />
					</td>
				</tr>
				</table>
	
				<table>
				<tr>
					<td width='11%'>No. Faktur</td>
					<td>:</td>
					<td><input type='text' name='t_nomorfk' id='t_nomorfk' size='8' readonly /></td>	
					<td width='2%'></td>
					<td>Tanggal Faktur</td>
					<td>:</td>
					<td><input type='date' name='t_tanggalfk' id='t_tanggalfk' size='10' readonly />
					<td width='2.71%'></td>
					<td>Cara Pengembalian :</td>
					<td><input type='text' name='t_caraby' id='t_caraby' size='11' readonly /></td>
				</tr>
				</table>
				<hr>
				<table align='center'>
				<tr>
					<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'></div>
		</div>";
		
echo "<div id='info' align='center'></div>";

echo "</div>";
?>