<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';
include '../../inc/fungsi_tanggal.php';

$kode = $_GET['kode'];

echo "<table id='theList' width='100%'>";
	echo "<tr>
		<th>No.</th> 
		<th>Kode Aktiva</th>
		<th>Nama Aktiva</th>
		<th>Tgl.Pembelian</th>
		<th>Hrg.Perolehan</th>
		<th>U/E (Bln)</th>
		<th>Depresiasi</th>
		<th>Akum.Depres.</th>
		<th>Nilai Buku</th>
	</tr>";
		
	$query = mysql_query("SELECT * FROM depres_akt WHERE kode_dp='$kode' GROUP BY kode_bb");
	$tharga=0;
	$tdepres=0;
	$takumdep=0;
	$tnilai=0;
	
	while($r=mysql_fetch_array($query)){
	    $kodebb = $r[kode_bb];
	    
	    $sql1 = mysql_query("SELECT * FROM akun_bb WHERE noakun='$kodebb'");
	    $r1   = mysql_fetch_assoc($sql1);
	    $namabb = $r1[naakun];
	    
	    echo "<tr>
	        <td></td>
	        <td>Bk.Besar :</td>
	        <td>$kodebb - $namabb</td>
        <tr>";
	    
	    $sql = mysql_query("SELECT * FROM depres_akt WHERE kode_dp='$kode' AND kode_bb='$kodebb' ORDER BY kode_ak");
	    $sharga=0;
	    $sdepres=0;
	    $sakumdep=0;
	    $snilai=0;
	    $no=1;
	    
	    while($r1=mysql_fetch_array($sql)){
	        $nilai=$r1[harga_bl]-$r1[akum_dep];
	        
	        echo "<tr>
		        <td align='center'>$no</td>
		        <td>$r1[kode_ak]</td>
		        <td>$r1[nama_ak]</td>
	            <td>".jin_date_str($r1[tanggal_bl])."</td>
		        <td align='right'>".number_format($r1[harga_bl],0)."</td>
		        <td align='right'>".number_format($r1[umur_ek],0)."</td>
		        <td align='right'>".number_format($r1[depresiasi],2)."</td>
		        <td align='right'>".number_format($r1[akum_dep],2)."</td>
		        <td align='right'>".number_format($nilai,2)."</td>
		    </tr>";
        
            $no++;
		    $sharga  =$sharga+$r1[harga_bl];
		    $sdepres =$sdepres+$r1[depresiasi];
		    $sakumdep=$sakumdep+$r1[akum_dep];
		    $snilai  =$snilai+$nilai;
	    }
	    
	    echo "<tr></tr>
	    <tr>
		    <td></td>
		    <td></td>
		    <td></td>
		    <td>Jumlah</td>
		    <td align='right'>".number_format($sharga,0)."</td>
		    <td></td>
		    <td align='right'>".number_format($sdepres,2)."</td>
		    <td align='right'>".number_format($sakumdep,2)."</td>
		    <td align='right'>".number_format($snilai,2)."</td>
		</tr>";
		$tharga  =$tharga+$sharga;
		$tdepres =$tdepres+$sdepres;
		$takumdep=$takumdep+$sakumdep;
		$tnilai  =$tnilai+$snilai;
    }
    
    echo "<tr></tr>
	<tr>
	    <td></td>
	    <td></td>
	    <td></td>
	    <td>Total</td>
	    <td align='right'>".number_format($tharga,0)."</td>
	    <td></td>
	    <td align='right'>".number_format($tdepres,2)."</td>
	    <td align='right'>".number_format($takumdep,2)."</td>
	    <td align='right'>".number_format($tnilai,2)."</td>
	</tr>
</table>";
?>