<?php
	include '../../inc/inc.koneksi.php';	
		
	$cari	= $_GET[cari];
	$tgllap	= date('d-m-Y');
		
	$content = "<b><li>DAFTAR AKUN BUKU PEMBANTU</li>		
		<li>PER TANGGAL $tgllap</li></b>
		<br>
	
		<table width='390' 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];
			
			$content .= "<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)){
				
				$content .= "<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++;
			}
		}
		
		$content .= "</table>";
		
		$content .= "<li>Jumlah Data : $jml</li>";
				
		header("Content-type: application/x-msdownload");
		header("Content-Disposition: attachment; filename=daftar_akunbp.xls");
		header("Pragma: no-cache");
		header("Expires: 0");
		echo $content;
?>
