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

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

	function edit_data(ID){
		var kode = ID;
						
		$.ajax({
			type	: "POST",
			url		: "spv/pener_bank/edit.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#txt_nourut").val(data.nourut);
				$("#txt_noakun").val(data.noakun);
				$("#txt_nobp").val(data.nobp);
				$("#txt_naakun").val(data.naakun);
				$("#txt_namabp").val(data.namabp);
				$("#txt_ket").val(data.ket);				
				$("#txt_jumlah").val(data.jumlah);
			}
		});		
	}

	function hapus_data(ID){
		var pilih = confirm('Data yang akan dihapus kode = '+ID+ '?');
		if (pilih==true) {
		var kode = ID;
		$.ajax({
			type	: "POST",
			url		: "spv/pener_bank/hapus.php",
			data	: "kode="+kode,
			success	: function(data){
				$("#info").html(data);
				cek_nourut();
				tampil_data_detail();
			}
		});
		}
	}
	
	function cek_nourut(){
		var kode 	= $("#txt_kode").val();
		
		$.ajax({
			type	: "POST",
			url		: "spv/pener_bank/cari_nourut.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#txt_nourut").val(data.nourut);
			}
		});
	}
	
	function tampil_data_detail(){
		var	kode=$("#txt_kode").val();
		$("#data_detail").load("spv/pener_bank/tampil_data_detail.php?kode="+kode);		
	}
</script>

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

$kode= $_GET[kode];

echo "<table id='theList' class='detail' width='100%'>
		<tr>
			<th>No.</th>
			<th>Kode Akun</th>
			<th>Nama Akun</th>
			<th>Kode BP</th>
			<th>Nama Buku Pembantu</th>	
			<th>Keterangan</th>
			<th>Jumlah</th>
			<th>Aksi</th>
		</tr>";
						
		$query = mysql_query("SELECT * FROM jurbm WHERE kode_bm='$kode' ORDER BY no_urut");
		
		$no=1;
		$total=0;
		while($r_data=mysql_fetch_array($query)){
			$kodebm= $r_data[kode_bm].';'.$r_data[no_urut];
			$total = $total+$r_data[jumlah];
			echo "<tr>
				<td align='center'>$no</td>
				<td align='center'>$r_data[noakun]</td>
				<td>$r_data[naakun]</td>
				<td align='center'>$r_data[nobp]</td>
				<td>$r_data[namabp]</td>					
				<td>$r_data[keterangan]</td>
				<td align='right'>".number_format($r_data[jumlah],2)."</td>
				<td align='center'>
					<a href='javascript:void(0)' onClick=\"edit_data('$kodebm')\">
						<img src='icon/thumb_up.png' border='0' id='edit' title='Edit' width='12' height='12' ></a>					
					<a href='javascript:void(0)' onClick=\"hapus_data('$kodebm')\">
						<img src='icon/thumb_down.png' border='0' id='hapus' title='Hapus' width='12' height='12' ></a>
				</td>
			</tr>";
			$no++;			
		}
		echo "<tr>				
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>				
			<td align='right'>Total </td>
			<td align='right'>".number_format($total,2)."</td>
		</tr>
	</table>";	
?>