<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';

$tanggal= $_GET[tanggal];

echo "<table id='theList' width='100%'>
		<tr>			
			<th>Kode</th>
			<th>Nama Akun</th>
			<th>Debet</th>
			<th>Kredit</th>
		</tr>";
		
		$sql2= mysql_query("SELECT * FROM gol_akun ORDER BY nogol");
		
		$jml=1;
		$tdebet=0;
		$tkredit=0;
		while($r2=mysql_fetch_array($sql2)){
			$nogol=$r2[nogol];

			echo "<tr>				
				<td><b>$r2[nogol]</b></td>			
				<td><b>$r2[nagol]</b></td>
			</tr>";
			
			$query = mysql_query("SELECT nogol,noakun,naakun,nosub,kode,sum(saldo) as jsaldo,sum(mutasi_db) as mtsdb,sum(mutasi_kd) as mtskd FROM akun_bb WHERE nogol='$nogol' AND level='2' GROUP BY noakun");
					
			$sdebet=0;
			$skredit=0;
			while($r=mysql_fetch_array($query)){
				if($r[kode]=='D'){
					$debet=$r[jsaldo]+$r[mtsdb]-$r[mtskd];
					$kredit='';
				}else{
					$kredit=$r[jsaldo]+$r[mtskd]-$r[mtsdb];
					$debet='';
				}				
				$kode=$r[kode];								
				$noakun=$r[noakun];
				
				$sql1	=mysql_query("SELECT sum(debet) as jdebet,sum(kredit) as jkredit FROM rekapjur WHERE tanggal>'$tanggal' AND noakun='$noakun'");		
				$r1		=mysql_fetch_assoc($sql1);
			
				if($kode=='D'){					
					$mutasi	=$r1[jdebet]-$r1[jkredit];
					$debet	=$debet-$mutasi;
					$sdebet	=$sdebet+$debet;
				}else{
					$mutasi	=$r1[jkredit]-$r1[jdebet];
					$kredit	=$kredit-$mutasi;
					$skredit	=$skredit+$kredit;
				}
				
				echo "<tr>					
					<td>$r[noakun]</td>
					<td>$r[naakun]</td>					
					<td align='right'>".number_format($debet,2)."</td>
					<td align='right'>".number_format($kredit,2)."</td>
				</tr>";
			}
			echo "<tr>				
				<td></td>
				<td>Jumlah</td>
				<td align='right'>".number_format($sdebet,2)."</td>
				<td align='right'>".number_format($skredit,2)."</td>
			</tr>";
			$tdebet=$tdebet+$sdebet;
			$tkredit=$tkredit+$skredit;
		}
		echo "<tr>			
		<tr>			
			<td></td>
			<td>Total</td>
			<td align='right'>".number_format($tdebet,2)."</td>
			<td align='right'>".number_format($tkredit,2)."</td>
		</tr>
	</table>";
?>