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

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

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

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

$tjumlah=0;

echo "<div id='info'>	
	<table id='theList' width='100%'>
	<tr>
		<th>No.</th>
		<th>Kode</th>
		<th>Nama Barang</th>
		<th>Satuan</th>
		<th>Jml.Kirim</th>
		<th>Jml.Retur</th>
		<th>Harga Jual</th>
		<th>Nilai Retur</th>
		<th>Keterangan</th>
	</tr>";
		
	$query2	= "SELECT kode_rj,tanggal,kode_plg,nama_plg,nomor_fk,tanggal_fk,cara_by FROM retur_pj WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir' AND batal='' GROUP BY kode_rj";
	$data2	= mysql_query($query2);
	while($r_data2=mysql_fetch_array($data2)){
		$koderj=$r_data2[kode_rj];

		echo "<tr>
				<td></td>
				<td><b>Nomor:</b></td>
				<td><b>$r_data2[kode_rj] ".jin_date_str($r_data2[tanggal])."</b></td>
				<td><b>Faktur:</td>
				<td><b>$r_data2[nomor_fk]</b></td>
				<td><b>Plg. :</td>
				<td><b>$r_data2[kode_plg]-$r_data2[nama_plg]</b></td>
				<td><b>$r_data2[cara_by]</b></td>
			</tr>";
			
		$sql = "SELECT * FROM retur_pj WHERE kode_rj='$koderj' ";		
		$query = mysql_query($sql);
		
		$no=1;
		$sjumlah=0;
		while($r_data=mysql_fetch_array($query)){
			
			echo "<tr>
				<td align='center'>$no</td>
				<td align='center'>$r_data[kode_st]</td>
				<td>$r_data[nama_st]</td>
				<td align='center'>$r_data[satuan]</td>
				<td align='center'>$r_data[jml_kirim]</td>
				<td align='center'>$r_data[jml_retur]</td>
				<td align='right'>".number_format($r_data[hg_jual])."</td>
				<td align='right'>".number_format($r_data[jumlah])."</td>
				<td>$r_data[keterangan]</td>
			</tr>";
			$sjumlah=$sjumlah+$r_data[jumlah];
			$no++;			
		}
		echo "<tr>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td align='right'>Jumlah</td>
				<td align='right'>".number_format($sjumlah)."</td>
			</tr>";
			$tjumlah=$tjumlah+$sjumlah;
	}
	echo "<tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td align='right'>Total </td>
			<td align='right'>".number_format($tjumlah)."</td>
		</tr>
	</table>";
echo "</div>";
?>
