<script type="text/javascript">	
	window.print();
</script>

<?php
	include '../../inc/inc.koneksi.php';	
	include '../../inc/fungsi_tanggal.php';
	include '../../inc/fungsi_indotgl.php';
	
	$sql=mysql_query("SELECT * FROM company");
	$r=mysql_fetch_assoc($sql);
	$company=$r[nama1];
	
	$tanggal= $_GET['tanggal'];
	
	$sql=mysql_query("SELECT * FROM company");
	$r	=mysql_fetch_assoc($sql);	
	$kop1 = $r[nama1];
	$kop2 = $r[nama2];
	$kop3 = $r[alamat];
	
	echo "<table style='font:11px arial'>
		<tr>
			<td>$kop1</td>
		</tr>
		<tr>
			<td>$kop2</td>
		</tr>
		<tr>
			<td>$kop3</td>
		</tr>
	</table>
		
	<table width='600'>
		<tr>
			<td align='center' style='font:14px arial'><b>LAPORAN HARIAN GLOBAL</b></td>
		</tr>
		<tr>
			<td align='center' style='font:14px arial'><b>TANGGAL : ".tgl_indo($tanggal)."</b></td>
		</tr>
	</table>
	<br>
	
	<table width='600' border='1' style='font:11px arial;border-collapse:collapse'>
		<tr>
			<th>No.</th>
			<th>Jenis BBM</th>
			<th>Liter Keluar</th>
			<th>Liter Tera</th>
			<th>Liter Bon</th>
			<th>Rupiah Bon</th>
			<th>Liter Tunai</th>
			<th>Rupiah Tunai</th>
		</tr>";
		
		$data	= mysql_query("SELECT jenis,sum(jml_keluar) as jkel,sum(jml_tera) as jtera,sum(jml_bon) as jbon,sum(nilai_nopol) as nilbon,sum(jml_tunai) as jtunai,sum(nilai_tunai) as niltun FROM setor_bbm WHERE tanggal='$tanggal' AND batal='' GROUP BY jenis");
		$setor	= 0;	
		$tkeluar= 0;
		$ttera	= 0;
		$tbon	= 0;
		$ttunai	= 0;
		$tniltun= 0;
		$tnilbon= 0;
		$no		= 1;
		
		while($r=mysql_fetch_array($data)){

			echo "<tr>
				<td align='center'>$no</td>
				<td>$r[jenis]</td>
				<td align='right'>".number_format($r[jkel],2)."</td>
				<td align='right'>".number_format($r[jtera],2)."</td>
				<td align='right'>".number_format($r[jbon],2)."</td>
				<td align='right'>".number_format($r[nilbon],2)."</td>
				<td align='right'>".number_format($r[jtunai],2)."</td>
				<td align='right'>".number_format($r[niltun],2)."</td>
			</tr>";
			$no++;
			$tkeluar=$tkeluar+$r[jkel];
			$ttera=$ttera+$r[jtera];
			$tbon=$tbon+$r[jbon];
			$tnilbon=$tnilbon+$r[nilbon];
			$ttunai=$ttunai+$r[jtunai];
			$tniltun=$tniltun+$r[niltun];
		}
	
		echo "<tr>
			<td></td>
			<td align='right'>Total</td>
			<td align='right'>".number_format($tkeluar,2)."</td>
			<td align='right'>".number_format($ttera,2)."</td>
			<td align='right'>".number_format($tbon,2)."</td>
			<td align='right'>".number_format($tnilbon,2)."</td>
			<td align='right'>".number_format($ttunai,2)."</td>
			<td align='right'>".number_format($tniltun,2)."</td>
		</tr>
	</table>
	<br>";
	$setor=$setor+$tniltun;
	
	echo "<table>
		<tr>
			<td style='font:11px arial'><b>PENGELUARAN</b></td>
		</tr>
	</table>
		
	<table width='400' border='1' style='font:11px arial;border-collapse:collapse'>
		<tr>
			<th>No.</th>
			<th>Keterangan</th>			
			<th>Jumlah</th>				
		</tr>";
		
		$sql = mysql_query("SELECT * FROM jurkk WHERE tanggal='$tanggal'");
		
		$no=1;
		$tjumlah=0;
		while($r=mysql_fetch_array($sql)){
			echo "<tr>
				<td align='center'>$no</td>
				<td>$r[keterangan]</td>					
				<td align='right'>".number_format($r[jumlah],2)."</td>					
			</tr>";
			$no++;			
			$tjumlah=$tjumlah+$r[jumlah];
		}
		$setor=$setor-$tjumlah;
		
	echo "<tr>
			<td></td>			
			<td align='right'>Total</td>				
			<td align='right'>".number_format($tjumlah,2)."</td>
		</tr>
	</table>
	<br>
	
	<table>
		<tr>
			<td><b>PENERIMAAN BANK :</b></td>
		</tr>
	</table>
		
	<table width='400' border='1' style='font:11px arial;border-collapse:collapse'>
		<tr>
			<th>No.</th>
			<th>Keterangan</th>			
			<th>Jumlah</th>
		</tr>";
		
		$sql = mysql_query("SELECT * FROM jurbm WHERE tanggal='$tanggal'");
		
		$no=1;
		$tjumlah=0;
		while($r=mysql_fetch_array($sql)){
			echo "<tr>
				<td align='center'>$no</td>
				<td>$r[keterangan]</td>					
				<td align='right'>".number_format($r[jumlah],2)."</td>
			</tr>";
			$no++;			
			$tjumlah=$tjumlah+$r[jumlah];
		}
		$setor=$setor-$tjumlah;
		
		echo "<tr>
			<td></td>			
			<td align='right'>Total</td>				
			<td align='right'>".number_format($tjumlah,2)."</td>
		</tr>
	</table>
	<br>
	<table>
		<tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td align='right'><b>Jumlah Uang Disetor :</td>
			<td align='right'>".number_format($setor,2)."</b></td>
		</tr>
	</table>";
?>