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

$tgl_awal	= $_GET['tgl_awal'];
$tgl_akhir	= $_GET['tgl_akhir'];

echo "<table id='theList' width='100%'>
		<tr>
			<th>No.</th>
			<th>No. Faktur</th>
			<th>Tgl. Faktur</th>
			<th>No. Polisi</th>
			<th>Nominal</th>
			<th>Dibayar</th>
			<th>Sisa</th>
		</tr>";
		
		$query1 = "SELECT kode_ppi,tanggal,kode_pl,nama_pl,tanggal_aw,tanggal_ak FROM jurppi WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir' AND batal='' GROUP BY kode_ppi ";
		$data1	= mysql_query($query1);
		
		$tbayar=0;
		$jdata=1;
		while($r_data1=mysql_fetch_array($data1)){
			$kodeppi = $r_data1[kode_ppi];
			
			echo "<tr>
				<td></td>
				<td>No.PPI : $r_data1[kode_km]</td>
				<td>".jin_date_str($r_data1[tanggal])."</td>
				<td>$r_data1[kode_pl] - $r_data1[nama_pl]</td>
				<td>Periode : $r_data1[tanggal_aw]</td>
				<td>s/d $r_data1[tanggal_ak]</td>
				</tr>";
				
			$sql = "SELECT kode_ppi,nofak,tgl_fak,nopol,jml_piut,dibayar,sisa FROM jurppi WHERE kode_ppi='$kodeppi' ";
			$query = mysql_query($sql);
		
			$no=1;
			$sbayar=0;
			while($r_data=mysql_fetch_array($query)){
				$sbayar=$sbatar+$r_data[dibayar];
				echo "<tr>					
					<td align='center'>$no</td>
					<td align='center'>$r_data[nofak]</td>
					<td align='center'>".jin_date_str($r_data1[tgl_fak])."</td>
					<td align='center'>$r_data[nopol]</td>
					<td align='right'>".number_format($r_data[jml_piut],0)."</td>
					<td align='right'>".number_format($r_data[dibayar],0)."</td>
					<td align='right'>".number_format($r_data[sisa],0)."</td>
					</tr>";
				$no++;
				$jdata++;				
			}
			
			echo "<tr>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td align='right'>Jumlah</td>
					<td align='right'>".number_format($sbayar,0)."</td>
				</tr>";
			$tbayar=$tbayar+$sbayar;
		}
		echo "<tr></tr>
				<tr>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>					
					<td align='right'>Total</td>
					<td align='right'>".number_format($tbayar,0)."</td>
				</tr>";
		
	echo "</table>";
	
	echo "<table width='100%'>
		<tr>
			<td>Jumlah Data : $jdata</td>
		</tr>
	</table>";
?>