<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 batal_tb(ID){
		var kode = ID;
		$.ajax({
			type	: "POST",
			url	    : "spv/tebus_do/cari_kode.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#bt_kode").val(kode);
				$("#bt_tanggal").val(data.tgl);
				$("#bt_nomorsa").val(data.nomorsa);
				$("#bt_nobank").val(data.nobank);
				$("#bt_namabank").val(data.namabank);
				$("#bt_kodesp").val(data.kodesp);
				$("#bt_namasp").val(data.namasp);
				$("#bt_jmlunit").val(data.jmlunit);
				$("#bt_hgbeli").val(data.hgbeli);
				$("#bt_jumlah").val(data.jumlah);
				$("#bt_setor").val(data.setor);
				$("#bt_bulat").val(data.bulat);
				$("#pencarian_batal").hide();
				$("#tampil_data_batal").hide();
				$("#info_tebus").show();
			}
		});
	}
</script>

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

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

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>
			<th>Pilih</th>
		</tr>";
		
		$query = mysql_query("SELECT * FROM tebus_do WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir' 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>
				<td align='center'>
					<a href='javascript:void(0)' onClick=\"batal_tb('$r_data[kode_tb]')\">
						<img src='icon/thumb_down.png' border='0' id='edit' title='Batal' width='12' height='12' >
					</a>
					</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>";
?>