<script type="text/javascript">
$(document).ready(function() {
    $(function() {
        $("#theList.detail tr:even").addClass("stripe1");
        $("#theList.detail tr:odd").addClass("stripe2");

        $("#theList.detail tr").hover(
            function() {
                $(this).toggleClass("highlight");
            },
            function() {
                $(this).toggleClass("highlight");
            }
        );
    });	
});
</script>

<style type="text/css">
.detail{
	font-size:14px;	
}
</style>
<?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' class='detail' width='100%' >
		<tr>
			<th>No.</th>
			<th>Kode</th>
			<th>Nama Pangkalan</th>
			<th>Harga Jual</th>
			<th>Jml.Unit</th>
			<th>Jumlah Harga</th>
			<th>Bank</th>
		</tr>";
		
		$query1 = mysql_query("SELECT * FROM faktur_sj WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir' AND batal='' AND posting='P' GROUP BY kode_pj");
		         
		$tjumlah=0;
		$tunit=0;
		$jml=0;
		while($r1=mysql_fetch_array($query1)){
			$kodepj	= $r1[kode_pj];
			echo "<tr>
				<td></td>
				<td>No.Faktur :</td>
				<td><b>$r1[kode_pj]</b> - Tanggal : <b>".jin_date_str($r1[tanggal])."</b></td>
				<td><b>$r1[nopol]</b></td>
				<td></td>
				<td><b>$r1[nama_dv]</b></td>
				<td><b>$r1[nama_sp]</b></td>
			</tr>";
			
			$query = mysql_query("SELECT * FROM faktur_sj WHERE kode_pj='$kodepj' ORDER BY no_urut");
			$no=1;
			$skirim=0;
			$sjumlah=0;
			$sunit=0;
			
			while($r=mysql_fetch_array($query)){
				echo "<tr>
					<td align='center'>$no</td>
					<td>$r[kode_pl]</td>
					<td>$r[nama_pl]</td>
					<td align='right'>".number_format($r[hg_jual],0)."</td>
					<td align='center'>".number_format($r[jml_unit],0)."</td>
					<td align='right'>".number_format($r[jumlah],0)."</td>
					<td>$r[nabank]</td>
				</tr>";
				$sunit  = $sunit+$r[jml_unit];
				$sjumlah= $sjumlah+$r[jumlah];
				$no++;
			}
			echo "<tr>
				<td></td>
				<td></td>
				<td></td>
				<td align='right'>Jumlah :</td>
				<td align='center'>".number_format($sunit,0)."</td>
				<td align='right'>".number_format($sjumlah,0)."</td>
			</tr>";
			$tunit	= $tunit+$sunit;
			$tjumlah= $tjumlah+$sjumlah;
			$jml++;
		}
		echo "<tr></tr>
		<tr>
			<td></td>
			<td></td>
			<td></td>
			<td align='right'>Total :</td>
			<td align='center'>".number_format($tunit,0)."</td>
			<td align='right'>".number_format($tjumlah,0)."</td>
		</tr>
	</table>";
?>