<script type="text/javascript">
    $(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';
include '../../inc/fungsi_tanggal.php';

$norek		= $_GET['noakun'];
$tglawal    = $_GET['tglawal'];
$tglakhir   = $_GET['tglakhir'];

$query2 = mysql_query("SELECT * FROM akun_bp WHERE noakun='$norek' ORDER BY noakun");
$r2	    = mysql_fetch_assoc($query2);
$naakun=$r2[naakun];
$kode	=$r2[kode];
if($kode=='D')
	$saldo=$r2[saldo]+$r2[mutasi_db]-$r2[mutasi_kd];
else 
	$saldo=$r2[saldo]+$r2[mutasi_kd]-$r2[mutasi_db];

$query1 = mysql_query("SELECT nobp,sum(debet) as jdebet,sum(kredit) as jkredit FROM rekapjur WHERE tanggal>='$tglawal' AND nobp='$norek' AND batal='' AND (!debet='' OR !kredit='') GROUP BY nobp ");
$jdebet =0;
$jkredit=0;
while($r1=mysql_fetch_array($query1)){
	$jdebet=$r1[jdebet];
	$jkredit=$r1[jkredit];
}
if($kode=='D')
	$sdawal =$saldo-$jdebet+$jkredit;
else
	$sdawal =$saldo-$jkredit+$jdebet;
$sdakhir    =$sdawal;

echo "<table>
		<tr>
			<td>Akun</td>
			<td>:</td>
			<td><b>$norek<b></td>
			<td>-</td>
			<td><b>$naakun</b></td>
			<td width='2%'></td>
			<td>Periode :</td>				
			<td><b>".jin_date_str($tglawal)."</b></td>
			<td>s/d</td>
			<td><b>".jin_date_str($tglakhir)."</b></td>	
		</tr>
		<tr>
			<td>Saldo Awal</td>
			<td>:</td>
			<td><b>".number_format($sdawal,2)." $satuan</b></td>				
		</tr>
	</table>";
	
echo "<table id='theList' width='100%'>
		<tr>				
			<th>Tanggal</th>
			<th>Nomor Bukti</th>
			<th>Kode Trans</th>
			<th>Keterangan</th>
			<th>Debet</th>
		    <th>Kredit</th>
			<th>Saldo</th>
		</tr>";
		
		$jdebet=0;
		$jkredit=0;		
			
		$query	= mysql_query("SELECT * FROM rekapjur WHERE tanggal BETWEEN '$tglawal' AND '$tglakhir' AND nobp='$norek' AND batal='' AND (!debet='' OR !kredit='') ORDER BY tanggal ");
		while($r=mysql_fetch_array($query)){
			if($kode=='D')
				$sdakhir=$sdakhir+$r[debet]-$r[kredit];
			else
				$sdakhir=$sdakhir+$r[kredit]-$r[debet];
		
			echo "<tr>					
				<td>".jin_date_str($r[tanggal])."</td>
				<td>$r[no_bukti]</td>
				<td align='center'>$r[kode_tr]</td>
				<td>$r[keterangan]</td>
				<td align='right'>".number_format($r[debet],2)."</td>
				<td align='right'>".number_format($r[kredit],2)."</td>
				<td align='right'>".number_format($sdakhir,2)."</td>
			</tr>";			
			$jdebet=$jdebet+$r[debet];
			$jkredit=$jkredit+$r[kredit];								
		}
		echo "<tr>
			<td></td>
			<td></td>
			<td></td>
			<td align='right'>Jumlah </td>
			<td align='right'>".number_format($jdebet,2)."</td>
			<td align='right'>".number_format($jkredit,2)."</td>
		</tr>
	</table>";	
?>
