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

<?php
	include '../../inc/inc.koneksi.php';	
		
	$cari	= $_GET[cari];
	$tgllap	= date('d-m-Y');
	
	$query2	= mysql_query("SELECT * FROM company");
	$r2			= mysql_fetch_assoc($query2);
	$kop1 		= $r2[nama1];
	$kop2 		= $r2[nama2];
	$kop3 		= $r2[nama3];
	
	echo "<table width='500'>
		<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='500'>
		<tr>
			<td align='center' style='font:arial 14px'><b>DAFTAR AKUN BUKU PEMBANTU</b></td>
		</tr>
		<tr>
			<td align='center' style='font:arial 14px'><b>PER TANGGAL $tgllap</b></td>
		</tr>
	</table>
	<br>
	
	<table width='500' border='1' style='border-collapse:collapse'>
		<tr>			
			<th>No.</th>
			<th>Kode</th>
			<th>Nama Akun</th>			
			<th>D/K</th>
		</tr>";
		
		$query1= "SELECT a.noakun,a.naakun,b.nobb FROM akun_bb as a JOIN akun_bp as b GROUP BY b.nobb";
	
		$data1	= mysql_query($query1);
		$jml=1;		
		while($r1=mysql_fetch_array($data1)){
			$nobb=$r1[nobb];
			
			echo "<tr>	
				<td></td>
				<td align='left'><b>$r1[nobb]</b></td>
				<td align='left'><b>$r1[naakun]</b></td>
			</tr>";
		
			if (!empty($cari)){
				$sql	= "SELECT * FROM akun_bp WHERE (naakun LIKE '%$cari%' or noakun LIKE '%$cari%') AND nobb='$nobb' ORDER BY noakun";
			}else{
				$sql	= "SELECT * FROM akun_bp WHERE nobb='$nobb' ORDER BY noakun";
			}
			$query = mysql_query($sql);
			$no=1;
			
			while($r_data=mysql_fetch_array($query)){
				
				echo "<tr>
					<td align='center'>$no</td>
					<td>$r_data[noakun]</td>
					<td>$r_data[naakun]</td>
					<td align='center'>$r_data[kode]</td>
				</tr>";
				$no++;
				$jml++;
			}
		}
		echo "</table>
		<table>
			<tr>
				<td>Jumlah Data : $jml</td>
			</tr>
		</table>";
?>
<script type="text/javascript">	
	history.back();
</script>