<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_uh(ID){
	var pilih = confirm('Apakah Anda sungguh-sungguh ingin membatalkan data '+ID+ '?');
		
	if (pilih==true){
		var kode = ID;
		
		$.ajax({
			type	: "POST",
			url		: "spv/ubah_harga/batal.php",
			data	: "kode="+kode,
			success	: function(data){
				$("#info").html(data);
				tampil_data();
			}
		});
	}
}
	
function tampil_data(){
	var tgl_awal = $("#t_tglaw_bt").val();
	var tgl_akhir = $("#t_tglak_bt").val();
	var cari = $("#caribbm_bt").val();
	
	$("#tampil_data_bt").load('spv/ubah_harga/tampil_data_bt.php?tgl_awal='+tgl_awal+'&tgl_akhir='+tgl_akhir+'&cari='+cari);
}
</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 Transaksi</th>
			<th>Tanggal</th>
			<th>Jenis BBM</th>
			<th>Jumlah Stok</th>
			<th>Hg.Jual Sebelumnya</th>
			<th>Hg.Jual Sekarang</th>
			<th>Hg.Beli Sebelumnya</th>
			<th>Hg.Beli Sekarang</th>
			<th>Total Selisih</th>
			<th>Batal</th>
		</tr>";
		
		$query = mysql_query("SELECT * FROM ubah_hg WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir' AND batal='' ORDER BY kode_uh ");
		$no=1;
		$tsls=0;

		while($r_data=mysql_fetch_array($query)){
			$tsls= $tsls+$r_data[selisih];
			
			echo "<tr>
				<td align='center'>$no</td>
				<td align='center'>$r_data[kode_uh]</td>
				<td align='center'>".jin_date_str($r_data[tanggal])."</td>
				<td>$r_data[jenis]</td>
				<td align='right'>$r_data[jml_stok]</td>					
				<td align='right'>".number_format($r_data[hj_lama])."</td>
				<td align='right'>".number_format($r_data[hj_baru])."</td>
				<td align='right'>".number_format($r_data[hb_lama],2)."</td>
				<td align='right'>".number_format($r_data[hb_baru],2)."</td>
				<td align='right'>".number_format($r_data[selisih])."</td>
				<td align='center'>						
					<a href='javascript:void(0)' onClick=\"batal_uh('$r_data[kode_uh]')\">
					<img src='icon/thumb_down.png' border='0' id='batal' title='Batal' 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 align='right'>Total </td>
			<td align='right'>".number_format($r_data[tsls])."</td>
		</tr>";
	echo "</table>";
?>