<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 lihat_detail(ID){
		var kode = ID;	
		$.ajax({
			type		: "POST",
			url		: "modul/setor_bbm/cari_kode.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#t_kodesb").val(kode);
				$("#t_tanggal").val(data.tgl);
				$("#t_shift").val(data.shift);
				$("#t_kodetl").val(data.kodetl);
				$("#t_jenis").val(data.jenis);
				$("#t_petugas").val(data.petugas);
				$("#t_telleraw").val(data.telleraw);
				$("#t_tellerak").val(data.tellerak);
				$("#t_jmlkeluar").val(data.jmlkeluar);
				$("#t_jmltera").val(data.jmltera);
				$("#t_jmlbon").val(data.jmlbon);
				$("#t_jmltunai").val(data.jmltunai);
				$("#t_niltunai").val(data.niltunai);
				$("#pencarian").hide();
				$("#tampil_data").hide();
				$("#info_bbm").show();
				$("#tampil_detail").show();
				$("#tampil_detail").load('modul/setor_bbm/tampil_data_bon.php?kode='+kode);
			}
		});		
	}
</script>

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

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

echo "<table id='theList' width='100%'>
		<tr>
			<th>No.</th>
			<th>Kode Setoran</th>
			<th>Tanggal</th>
			<th>Shift</th>
			<th>No.Teller</th>
			<th>Jenis BBM</th>
			<th>Petugas</th>
			<th>Teller Awal</th>
			<th>Teller Akhir</th>
			<th>Liter Tera</th>
			<th>Liter Bon</th>
			<th>Liter Tunai</th>
			<th>Setor Tunai</th>
			<th>Lihat</th>
		</tr>";
		
		if(!empty($cari))
			$sql = "SELECT * FROM setor_bbm WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir'	AND batal='' AND (jenis LIKE '%$cari%') GROUP BY kode_sb ";
		else
			$sql = "SELECT * FROM setor_bbm WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir'	AND batal='' GROUP BY kode_sb ";
		$query = mysql_query($sql);
		
		$no=1;
		$ttunai=0;
		while($r_data=mysql_fetch_array($query)){
			$ttunai = $ttunai+$r_data[nilai_tunai];
			echo "<tr>
					<td align='center'>$no</td>
					<td align='center'>$r_data[kode_sb]</td>
					<td align='center'>".jin_date_str($r_data[tanggal])."</td>
					<td align='center'>$r_data[shift]</td>
					<td align='center'>$r_data[kode_tl]</td>
					<td>$r_data[jenis]</td>
					<td>$r_data[petugas]</td>
					<td align='right'>$r_data[teller_aw]</td>
					<td align='right'>$r_data[teller_ak]</td>
					<td align='right'>$r_data[jml_tera]</td>
					<td align='right'>$r_data[jml_bon]</td>
					<td align='right'>$r_data[jml_tunai]</td>
					<td align='right'>".number_format($r_data[nilai_tunai])."</td>
					<td align='center'>
					<a href='javascript:void(0)' onClick=\"lihat_detail('$r_data[kode_sb]')\">
						<img src='images/view.png' border='0' id='edit' title='Lihat detail' width='12' height='12' >
					</a>
					</td>
				</tr>";
			$no++;
		}
		
		echo "<tr>								
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td align='right'>Total</td>
				<td align='right'>".number_format($ttunai)."</td>
			</tr>";
	echo "</table>";
?>