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

<?php
	include '../../inc/inc.koneksi.php';	
		
	$cari	= $_GET['cari'];
	$tgllap = date('d-m-Y');
		
	$sql2   = mysql_query("SELECT * FROM company");
	$r2		= mysql_fetch_assoc($sql2);
	$kop1   = $r2['nama1'];
	$kop2   = $r2['nama2'];
	$kop3   = $r2['alamat'];
	
	echo "<table width='600' style='font:11px arial'><b>
		<tr>
			<td>$kop1</td>
		</tr>
		<tr>
			<td>$kop2</td>
		</tr>
		<tr>
			<td>$kop3</td>
		</tr>
	</table>
		
	<table width='600'><b>
		<tr>
			<td align='center' style='font:14px arial'><b>DAFTAR AKUN BUKU PEMBANTU</b></td>
		</tr>
		<tr>
			<td align='center' style='font:14px arial'><b>PER TANGGAL $tgllap</b></td>
		</tr>
	</table>
	<br>
	
	<table width='600' border='1' style='border-collapse:collapse;font:12px arial'>
		<tr>
			<th>No.</th>
			<th>Kode</th>
			<th>Nama Akun</th>
			<th>D/K</th>
		</tr>";
		$data1= mysql_query("SELECT a.noakun,a.naakun,b.nobb FROM akun_bb as a JOIN akun_bp as b GROUP BY b.nobb");
		
		$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=mysql_fetch_array($query)){
				
				echo "<tr>
					<td align='center'>$no</td>
					<td>$r[noakun]</td>
					<td>$r[naakun]</td>
					<td align='center'>$r[kode]</td>
				</tr>";
				$no++;
				$jml++;
			}
		}		
	echo "</table>
	<table style='font:12px arial'>
		<tr>
			<td>Jumlah data : $jml</td>
		</tr>
	</table>";
?>
<script type="text/javascript">
	history.back();
</script>