<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		: "modul/akun_bb/cari_gol.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#txt_nogol").val(kode);
				$("#txt_nagol").val(data.nagol);
				$("#txt_kode").val(data.kode);
				$("#form_cari_gol").dialog('close');
				cari_nomor();				
			}
		});
	}
	
	function cari_nomor(){
		var kode = $("#txt_nogol").val();
		
		$.ajax({
			type	: "POST",
			url		: "modul/akun_bb/cari_nomor.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#txt_noakun").val(data.nomor);
				$("#txt_kode").val(data.kode);
				$("#txt_noakun").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 Golongan</th>
			<th>D/K</th>
			<th>Ambil</th>
		</tr>";
		
		if (!empty($cari)){
			$sql= "SELECT * FROM gol_akun WHERE (nagol LIKE '%$cari%' OR nogol LIKE '%$cari%') ORDER by nogol";		
		}
		else{
			$sql= "SELECT * FROM gol_akun ORDER by nogol";
		}
				
		$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[nogol]</td>
					<td>$r_data[nagol]</td>
					<td>$r_data[kode]</td>
					<td align='center'>
					<a href='javascript:void(0)' onClick=\"pilih('$r_data[nogol]')\">
					<img src='icon/download.gif' border='0' id='tambah_data' title='Pilih' width='12' height='12' >
					</a>					
					</td>
					</tr>";
			$no++;
		}
		
	echo "</table>";
?>
