<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");
            }
        );
    });
});
</script>

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

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

echo "<table id='theList' width='100%'>
		<tr>
			<th>No.</th>
			<th>Kode Trans.</th>
			<th>Tanggal</th>
			<th>Nomor SA</th>
			<th>Bank</th>
			<th>SPBE</th>
			<th>Jml. Unit</th>
			<th>Harga Beli</th>
			<th>Jumlah Harga</th>
			<th>Pembulatan</th>
			<th>Jumlah Setor</th>
		</tr>";
		
		if($kodesp=='')
			$query = mysql_query("SELECT * FROM tebus_do WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir' AND batal='' ORDER BY kode_tb ");
		else
			$query = mysql_query("SELECT * FROM tebus_do WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir' AND kode_sp='$kodesp' AND batal='' ORDER BY kode_tb ");
		
		$tunit=0;
		$tjumlah=0;
		$tbulat=0;
		$tsetor=0;
		$no=1;
		while($r=mysql_fetch_array($query)){
			$tjumlah= $tjumlah+$r[jumlah];
			$tbulat	= $tbulat+$r[bulat];
			$tunit	= $tunit+$r[jml_unit];
			$tsetor	= $tsetor+$r[setor];
			
			echo "<tr>
				<td align='center'>$no</td>
				<td>$r[kode_tb]</td>
				<td>".jin_date_str($r[tanggal])."</td>
				<td>$r[nomor_sa]</td>
				<td>$r[namabank]</td>
				<td>$r[nama_sp]</td>
				<td align='right'>$r[jml_unit]</td>
				<td align='right'>".number_format($r[hg_beli],2)."</td>
				<td align='right'>".number_format($r[jumlah],0)."</td>
				<td align='right'>".number_format($r[bulat],0)."</td>
				<td align='right'>".number_format($r[setor],0)."</td>
			</tr>";
			$no++;			
		}
		echo "<tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td align='right'>Total </td>
			<td align='right'>$tunit</td>
			<td></td>
			<td align='right'>".number_format($tjumlah,0)."</td>
			<td align='right'>".number_format($tbulat,0)."</td>
			<td align='right'>".number_format($tsetor,0)."</td>
		</tr>
	</table>";
?>