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

		$("#theList.barang tr").hover(
            function() {
                $(this).toggleClass("highlight");
            },
            function() {
                $(this).toggleClass("highlight");
            }
        );
    });	
});

	function pilih(ID){
		var kode = ID;
		
		$.ajax({
			type	: "POST",
			url	    : "spv/aktiva/cari_bb.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#txt_kodebb").val(kode);
				$("#txt_namabb").val(data.nabb);
				$("#form_cari_bb").dialog('close');
				$("#txt_kodeak").focus();
			}
		});
	}
	
	function cari_nomor(){
		var kode = $("#txt_kodebb").val();
		
		$.ajax({
			type	: "POST",
			url	: "spv/aktiva/cari_nomor.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#txt_kodeak").val(data.nomor);
				$("#txt_namaak").focus();
			}
		});
	}
</script>

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

$cari = $_GET['cari'];

echo "<table id='theList' class='barang' width='100%'>
		<tr>
			<th>No.</th>
			<th>Kode</th>
			<th>Nama Akun</th>
			<th>D/K</th>
			<th>Ambil</th>
		</tr>";
		
		if (!empty($cari)){
			$sql	= "SELECT * FROM akun_bb WHERE (naakun LIKE '%$cari%' OR noakun LIKE '%$cari%') AND nogol BETWEEN '13' AND '14' AND level='2' ORDER by noakun";		
		}
		else{
			$sql	= "SELECT * FROM akun_bb WHERE nogol BETWEEN '13' AND '14' AND level='2' ORDER by noakun";
		}
				
		$query = mysql_query($sql);
		$jml_data = mysql_num_rows($query);
		$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>$r_data[kode]</td>
					<td align='center'>
					<a href='javascript:void(0)' onClick=\"pilih('$r_data[noakun]')\">
					<img src='icon/download.gif' border='0' id='tambah_data' title='Pilih' width='12' height='12' >
					</a>					
					</td>
					</tr>";
			$no++;
		}
		
	echo "</table>";
?>
