<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_ls(ID){
	var pilih = confirm('Apakah Anda sungguh-sungguh ingin membatalkan penguapan '+ID+ '?');
	
	if (pilih==true){
		var kode = ID;
		
		$.ajax({
			type	: "POST",
			url		: "spv/penguapan/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();
	
	if(tgl_awal.length==''){
		alert('Maaf, Variabel tanggal belum lengkap');
		$("#t_tglaw_bt").focus();
		return false;
	}
	if(tgl_akhir.length==''){
		alert('Maaf, Variabel tanggal belum lengkap');
		$("#t_tglak_bt").focus();
		return false;
	}
	$("#tampil_data_bt").load('spv/penguapan/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'];
$cari= $_GET['cari'];

echo "<table id='theList' width='100%'>
		<tr>
			<th>No.</th>
			<th>Kode Penguapan</th>
			<th>Tanggal</th>
			<th>Jenis BBM</th>
			<th>Tanki</th>
			<th>Jumlah Stok</th>
			<th>Hasil Stik</th>
			<th>Penguapan</th>
			<th>Harga Beli</th>
			<th>Nilai Penguapan</th>
			<th>Batal</th>
		</tr>";
		
		if(!empty($cari))
			$sql = "SELECT * FROM penguapan WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir' AND jenis LIKE '%$cari%' AND batal='' ORDER BY kode_ls ";
		else
			$sql = "SELECT * FROM penguapan WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir' AND batal='' ORDER BY kode_ls ";
		$query = mysql_query($sql);
		
		$no=1;
		$tsls=0;
		$tnilai=0;
		
		while($r_data=mysql_fetch_array($query)){
			$tsls = $tsls+$r_data[jml_sls];
			$tnilai= $tnilai+$r_data[nilai_sls];
			
			echo "<tr>
					<td align='center'>$no</td>
					<td align='center'>$r_data[kode_ls]</td>
					<td align='center'>".jin_date_str($r_data[tanggal])."</td>
					<td>$r_data[jenis]</td>
					<td align='center'>$r_data[tanki]</td>
					<td align='right'>$r_data[jml_stok]</td>
					<td align='right'>$r_data[jml_stik]</td>
					<td align='right'>$r_data[jml_sls]</td>
					<td align='right'>".number_format($r_data[hg_beli])."</td>
					<td align='right'>".number_format($r_data[nilai_sls])."</td>
					<td align='center'>						
						<a href='javascript:void(0)' onClick=\"batal_ls('$r_data[kode_ls]')\">
						<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 align='right'>Total</td>
				<td align='right'>$tsls</td>
				<td></td>
				<td align='right'>".number_format($tnilai)."</td>
			</tr>";
	echo "</table>";
?>