<script type="text/javascript">
$(document).ready(function() {
    $(function() {
        $("#theList tr:even").addClass("stripe1");
        $("#theList tr:odd").addClass("stripe2");

        $("#theList tr").hover(
            function() {
                $(this).toggleClass("highlight");
            },
            function() {
                $(this).toggleClass("highlight");
            }
        );
    });	
});
</script>

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

$cari	  = $_GET['cari'];

echo "<table id='theList' width='100%'>
		<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 ON b.nobb=a.noakun GROUP BY b.nobb";
		
		$data1	= mysql_query($query1);
		$jml=1;		
		while($r_data1=mysql_fetch_array($data1)){
			$nobb=$r_data1['nobb'];

			echo "<tr>
				<td></td>
				<td><b>$r_data1[nobb]</b></td>	
				<td><b>$r_data1[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>$no</td>
					<td>$r_data[noakun]</td>
					<td>$r_data[naakun]</td>					
					<td align='center'>$r_data[kode]</td>					
				</tr>";			
				$no++;
				$jml++;
			}
		}	
	echo "</table>";

	echo "<table width='100%'>
		<tr>
			<td>Jumlah Data : $jml</td>
		</tr>
		</table>";
?>