<script type="text/javascript">
    $(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';

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

echo "<div id='info'>	
	<table id='theList' width='100%'>
	<tr>		
		<th>Tanggal</th>
		<th>Premium</th>
		<th>Bio Solar</th>
		<th>Pertamax</th>
		<th>Pertamax Turbo</th>
		<th>Pertalite</th>
		<th>Pertamina Dex</th>
		<th>Dexlite</th>
		<th>Solar Keekonomian</th>
		<th>Jumlah</th>
		<th>Nilai Penjualan</th>
	</tr>";

	$data	= mysql_query("SELECT * FROM setor_bbm WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir' AND batal='' GROUP BY tanggal");
	
	$no=1;
	$tpremium=0;
	$tsolar=0;
	$tpertamax=0;
	$tptmplus=0;
	$tptlite=0;
	$tdex=0;
	$tdexlite=0;
	$tsoleko=0;
	$tjual=0;
	$tnilai=0;
	
	while($r_data=mysql_fetch_array($data)){
		$tanggal=$r_data[tanggal];
		
		$sql = mysql_query("SELECT jenis,jml_bon,jml_tunai,nilai_tunai,nilai_nopol FROM setor_bbm WHERE tanggal='$tanggal' AND batal='' ORDER BY jenis");
		$premium=0;
		$solar=0;
		$pertamax=0;
		$ptmplus=0;
		$ptlite=0;
		$dex=0;
		$dexlite=0;
		$soleko=0;
		$jual=0;
		$nilai=0;
		
		while($r=mysql_fetch_array($sql)){
			$jenis=$r[jenis];
			if($jenis=='Premium')
				$premium=$premium+$r[jml_bon]+$r[jml_tunai];
			else if($jenis=='Bio Solar')
				$solar=$solar+$r[jml_bon]+$r[jml_tunai];
			else if($jenis=='Pertamax')
				$pertamax=$pertamax+$r[jml_bon]+$r[jml_tunai];
			else if($jenis=='Pertamax Turbo')
				$ptmplus=$ptmplus+$r[jml_bon]+$r[jml_tunai];
			else if($jenis=='Pertalite')
				$ptlite=$ptlite+$r[jml_bon]+$r[jml_tunai];
			else if($jenis=='Pertamina Dex')
				$dex=$dex+$r[jml_bon]+$r[jml_tunai];
			else if($jenis=='Dexlite')
				$dexlite=$dexlite+$r[jml_bon]+$r[jml_tunai];
			else
				$soleko=$soleko+$r[jml_bon]+$r[jml_tunai];
			$nilai=$nilai+$r[nilai_tunai]+$r[nilai_nopol];
		}
		$jual=$premium+$solar+$pertamax+$ptmplus+$ptlite+$dex+$dexlite+$soleko;
		
		echo "<tr>
			<td align='center'>".jin_date_str($r_data[tanggal])."</td>
			<td align='right'>".number_format($premium,2)."</td>
			<td align='right'>".number_format($solar,2)."</td>
			<td align='right'>".number_format($pertamax,2)."</td>			
			<td align='right'>".number_format($ptmplus,2)."</td>
			<td align='right'>".number_format($ptlite,2)."</td>
			<td align='right'>".number_format($dex,2)."</td>
			<td align='right'>".number_format($dexlite,2)."</td>
			<td align='right'>".number_format($soleko,2)."</td>
			<td align='right'>".number_format($jual,2)."</td>
			<td align='right'>".number_format($nilai,0)."</td>
		</tr>";
		$tpremium=$tpremium+$premium;
		$tsolar=$tsolar+$solar;
		$tpertamax=$tpertamax+$pertamax;
		$tptmplus=$tptmplus+$ptmplus;
		$tptlite=$tptlite+$ptlite;
		$tdex=$tdex+$dex;
		$tdexlite=$tdexlite+$dexlite;
		$tsoleko=$tsoleko+$soleko;
		$tjual=$tjual+$jual;
		$tnilai=$tnilai+$nilai;
	}
	
	echo "<tr>
			<td align='right'>Total</td>
			<td align='right'>".number_format($tpremium,2)."</td>
			<td align='right'>".number_format($tsolar,2)."</td>
			<td align='right'>".number_format($tpertamax,2)."</td>			
			<td align='right'>".number_format($tptmplus,2)."</td>
			<td align='right'>".number_format($tptlite,2)."</td>
			<td align='right'>".number_format($tdex,2)."</td>
			<td align='right'>".number_format($tdexlite,2)."</td>
			<td align='right'>".number_format($tsoleko,2)."</td>
			<td align='right'>".number_format($tjual,2)."</td>
			<td align='right'>".number_format($tnilai,0)."</td>
		</tr>";
		
	echo "</table>";	
echo "</div>";
?>
