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

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

	$tanggal 	= date('Y-m-d');
	$kodesp  	= $_GET['kodesp'];
	
	$sql 	= mysql_query("SELECT * FROM supplier WHERE kode_sp='$kodesp' ORDER BY kode_sp");
	$r 	= mysql_fetch_assoc($sql);
	$namasp	= $r[nama];
	
	$query2	= mysql_query("SELECT * FROM company");
	$r2			= mysql_fetch_assoc($query2);
	$kop1 		= $r2[nama1];
	$kop2 		= $r2[nama2];
	$kop3 		= $r2[nama3];
	
	echo "<table width='100%'>
		<tr>
			<td style='font:arial 11px'><b>$kop1</b></td>
		</tr>
		<tr>
			<td style='font:arial 11px'>$kop2</td>
		</tr>
		<tr>
			<td style='font:arial 11px'>$kop3</td>
		</tr>
	</table>
		
	<table width='100%'>
		<tr>
			<td align='center' style='font:arial 14px'><b>DAFTAR OUTSTANDING DO LPG</b></td>
		</tr>
		<tr>
			<td align='center' style='font:arial 14px'><b>PER TANGGAL ".jin_date_str($tanggal)."</b></td>
		</tr>";
		if(!$kodesp==''){
			echo "<tr>
				<td align='center' style='font:arial 14px'><b>SPBE : $kodesp - $namasp</b></td>
			</tr>";
		}
	echo "</table>
	<br>
	
	<table width='100%' border='1' style='border-collapse:collapse;font:11px arial'>
		<tr>
			<th>No.</th>
			<th>Kode Trans.</th>
			<th>Tanggal</th>
			<th>Nomor SA</th>
			<th>Bank</th>
			<th>SPBE</th>
			<th>Jumlah Unit</th>
			<th>Harga Beli</th>
			<th>Jumlah hg_beli</th>
			<th>Pembulatan</th>
			<th>Jumlah Setor</th>
		</tr>";
		
		if($kodesp=='')
			$query = mysql_query("SELECT * FROM tebus_do WHERE jml_real<jml_unit AND batal='' ORDER BY kode_tb ");
		else
			$query = mysql_query("SELECT * FROM tebus_do WHERE jml_real<jml_unit AND kode_sp='$kodesp' AND batal='' ORDER BY kode_tb ");
			
		$tunit=0;
		$tjumlah=0;
		$tbulat=0;
		$tsetor=0;
		while($r_data=mysql_fetch_array($query)){
			$tjumlah= $tjumlah+$r_data[jumlah];
			$tbulat	= $tbulat+$r_data[bulat];
			$tunit	= $tunit+$r_data[jml_unit];
			$tsetor	= $tsetor+$r_data[setor];
			
			echo "<tr>
				<td align='center'>$no</td>
				<td>$r_data[kode_tb]</td>
				<td>".jin_date_str($r_data[tanggal])."</td>
				<td>$r_data[nomor_sa]</td>
				<td>$r_data[namabank]</td>
				<td>$r_data[nama_sp]</td>
				<td align='right'>$r_data[jml_unit]</td>
				<td align='right'>".number_format($r_data[hg_beli],2)."</td>
				<td align='right'>".number_format($r_data[jumlah],0)."</td>
				<td align='right'>".number_format($r_data[bulat],0)."</td>
				<td align='right'>".number_format($setor,0)."</td>
			</tr>";
			$no++;			
		}
		echo "<tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td align='right'>Total </td>
			<td align='right'>$tunit</td>
			<td></td>
			<td align='right'>".number_format($tjumlah,0)."</td>
			<td align='right'>".number_format($tbulat,0)."</td>
			<td align='right'>".number_format($tsetor,0)."</td>
		</tr>
	</table>";
?>
<script type="text/javascript">	
	history.back();
</script>