<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%'>
		<tr>			
			<th>No.Faktur</th>
			<th>Tanggal</th>
			<th>Saldo</th>
			<th>Dibayar</th>
			<th>Potongan</th>
			<th>Sisa</th>
		</tr>";
		
		$query = "SELECT * FROM jurppi WHERE kode_ppi='$kode' AND batal=''";
		$sql= mysql_query($query);
		$tpiut=0;
		$ttunai=0;
		$tpot=0;
		$tsisa=0;
		$no=1;
		
		while($r=mysql_fetch_array($sql)){
			echo "<tr>
				<td align='center'>$r[nofak]</td>
				<td align='center'>".jin_date_str($r['tgl_fak'])."</td>
				<td align='right'>".number_format($r['jml_piut'],0)."</td>
				<td align='right'>".number_format($r['tunai'],0)."</td>
				<td align='right'>".number_format($r['potongan'],0)."</td>
				<td align='right'>".number_format($r['sisa'],0)."</td>
			</tr>";
			$no++;
			$tpiut=$tpiut+$r['jml_piut'];
			$ttunai=$ttunai+$r['tunai'];
			$tpot=$tpot+$r['potongan'];
			$tsisa=$tsisa+$r['sisa'];
		}
		echo "<tr>
			<td></td>
			<td>Total</td>
			<td align='right'>".number_format($tpiut,0)."</td>
			<td align='right'>".number_format($ttunai,0)."</td>
			<td align='right'>".number_format($tpot,0)."</td>
			<td align='right'>".number_format($tsisa,0)."</td>
		</tr>
	</table>";
?>