<script type="text/javascript">
$(document).ready(function() {
    $(function() {
        $("#theList tr:even").addClass("stripe1");
        $("#theList tr:odd").addClass("stripe2");

        $("#theList tr").hover(
            function() {
                $(this).toggleClass("highlight");
            },
            function() {
                $(this).toggleClass("highlight");
            }
        );
    });
});

	function tampil_rb(ID){
		var kode = ID;	
		$.ajax({
			type	: "POST",
			url	    : "modul/returbeli/cari_kode.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#t_koderb").val(kode);
				$("#t_tanggal").val(data.tgl);
				$("#t_nomorfk").val(data.nomorfk);
				$("#t_tanggalfk").val(data.tanggalfk);				
				$("#pencarian").hide();
				$("#tampil_data").hide();
				$("#info_retur").show();
				$("#tampil_detail").show();
				$("#tampil_detail").load('modul/returbeli/tampil_data_batal.php?kode='+kode);
			}
		});		
	}
</script>

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

$tgl_awalb= $_GET['tgl_awal'];
$tgl_akhir= $_GET['tgl_akhir'];

echo "<table id='theList' width='100%'>
		<tr>
			<th>No.</th>
			<th>Kode Retur</th>
			<th>Tanggal</th>
			<th>Nomor Faktur</th>
			<th>Tanggal Faktur</th>
			<th>Total Item</th>
			<th>Total Retur</th>
			<th>Total Nilai</th>
			<th>View</th>
		</tr>";
		$query = mysql_query("SELECT kode_rb,tanggal,nomor_fk,tanggal_fk,count(kode_st) as totitem,sum(jml_retur) as totretur,sum(jumlah) as totnilai FROM retur_pb
			WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir'	AND batal='' GROUP BY kode_rb");
		
		$no=1;
		while($r=mysql_fetch_array($query)){			
			echo "<tr>
				<td align='center'>$no</td>
				<td align='center'>$r[kode_rb]</td>
				<td align='center'>".jin_date_str($r['tanggal'])."</td>
				<td>$r[nomor_fk]</td>
				<td align='center'>".jin_date_str($r['tanggal_fk'])."</td>
				<td align='center'>$r[totitem]</td>
				<td align='center'>$r[totretur]</td>
				<td align='right'>".number_format($r['totnilai'])."</td>
				<td align='center'>
					<a href='javascript:void(0)' onClick=\"tampil_rb('$r[kode_rb]')\">
						<img src='images/view.png' border='0' id='edit' title='Lihat detail' width='12' height='12' >
					</a>
				</td>
			</tr>";
			$no++;			
		}		
	echo "</table>";	
?>