<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';

$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>Jumlah Unit</th>
			<th>Harga Beli</th>
			<th>Jumlah hg_beli</th>
			<th>Pembulatan</th>
			<th>Jumlah Setor</th>
		</tr>";
		
		if($kodesp=='')
			$query = mysql_query("SELECT * FROM tebus_do WHERE jml_real<jml_unit AND batal='' ORDER BY kode_tb ");
		else
			$query = mysql_query("SELECT * FROM tebus_do WHERE jml_real<jml_unit AND kode_sp='$kodesp' AND batal='' ORDER BY kode_tb ");
			
		$tunit=0;
		$tjumlah=0;
		$tbulat=0;
		$tsetor=0;
		while($r_data=mysql_fetch_array($query)){
			$tjumlah= $tjumlah+$r_data[jumlah];
			$tbulat	= $tbulat+$r_data[bulat];
			$tunit	= $tunit+$r_data[jml_unit];
			$tsetor	= $tsetor+$r_data[setor];
			
			echo "<tr>
				<td align='center'>$no</td>
				<td>$r_data[kode_tb]</td>
				<td>".jin_date_str($r_data[tanggal])."</td>
				<td>$r_data[nomor_sa]</td>
				<td>$r_data[namabank]</td>
				<td>$r_data[nama_sp]</td>
				<td align='right'>$r_data[jml_unit]</td>
				<td align='right'>".number_format($r_data[hg_beli],2)."</td>
				<td align='right'>".number_format($r_data[jumlah],0)."</td>
				<td align='right'>".number_format($r_data[bulat],0)."</td>
				<td align='right'>".number_format($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>";
?>