<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");
            }
        );
    });
});	

	function pilih(ID){
		var kode = ID;	
		$.ajax({
			type	: "POST",
			url		: "modul/pener_kas/cari_akun.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#txt_noakun").val(kode);
				$("#txt_naakun").val(data.naakun);
				$("#txt_caribb").val('');
				$("#form_cari_akun").dialog('close');
				cek_bp();
			}
		});
	}
	
	function cek_bp(){
		var kode  = $("#txt_noakun").val();
		var persed= $("#txt_persed").val();
		
		$.ajax({
			type	: "POST",
			url		: "modul/pener_kas/cek_bp.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#txt_noakun").val(kode);
				$("#txt_adabp").val(data.nobp);
			
				var nobp = $("#txt_adabp").val();
				if(!nobp==''){
					cari_nobp();					
				}else{
					if(kode==persed)
						$("#txt_kodest").focus();
					else $("#radio_dk").focus();
				}
			}
		});
	}
		
	$('#form_cari_bp').dialog({
		autoOpen: false,
		modal	: true,
		width: 600,
	});
	
	function cari_nobp(){
		$('#form_cari_bp').dialog('open');		
		var cari	= $("#txt_caribp").val();
		var nobb = $("#txt_noakun").val();
		
		$.ajax({
			type	: "POST",
			url	: "modul/jurnal_umum/tampil_data_bp.php",
			data	: "cari="+cari+
				"&nobb="+nobb,
			timeout	: 3000,
			beforeSend	: function(){		
				$("#info_bp").html("<img src='loading.gif' />");			
			},				  
			success	: function(data){
				$("#info_bp").html(data);
				$("#info_bb").hide();
			}
		});
		return (false);
	}
</script>

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

$cari = $_POST['cari'];

echo "<table id='theList' width='100%'>
		<tr>			
			<th>Nomor Akun</th>
			<th>Nama Akun</th>			
			<th>D/K</th>
			<th>Pilih</th>
		</tr>";
		
		if(!empty($cari))
			$query = "SELECT noakun,naakun,level,kode FROM akun_bb WHERE (noakun LIKE '%$cari%' OR naakun LIKE '%$cari%') AND level='2' ORDER BY noakun ";
		else
			$query = "SELECT noakun,naakun,level,kode FROM akun_bb WHERE level='2' ORDER BY noakun ";
			
		$sql= mysql_query($query);
						
		while($r_data=mysql_fetch_array($sql)){
			echo "<tr>					
					<td align='center'>$r_data[noakun]</td>					
					<td>$r_data[naakun]</td>
					<td align='center'>$r_data[kode]</td>
					<td align='center'><a href='javascript:void(0)' onClick=\"pilih('$r_data[noakun]')\">
						<img src='images/view.png' border='0' id='edit' title='Pilih Kode Akun' width='12' height='12' ></a>
					</td>
				</tr>";
			$no++;								
		}

	echo "</table>";
?>
