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

$kodepl	= $_GET['kodepl'];
$cari	= $_GET['cari'];

echo "<table id='theList' width='100%'>		
		<tr>
			<th>No.</th>
			<th>Tanggal</th>
			<th>Nomor Nota</th>
			<th>Kode Brg.</th>
			<th>Nama Barang</th>
			<th>Jml. Unit</th>
			<th>Satuan</th>
			<th>Harga Jual</th>
			<th>Jumlah Harga</th>
			<th>HPP</th>
		</tr>";
		if(!empty($cari))
			$sql= "SELECT * FROM faktur_pj WHERE kode_pl='$kodepl' AND (nama_st LIKE '%$cari%' OR kode_st LIKE '%$cari%') ORDER BY tanggal";
		else
			$sql= "SELECT * FROM faktur_pj WHERE kode_pl='$kodepl' ORDER BY tanggal";
		$query = mysql_query($sql);
		
		$no=1;
		$tjumlah=0;
		$thpp=0;
		while($r=mysql_fetch_array($query)){
			$hgjual=$r['jumlah']/$r['jml_unit'];
			$hgbeli=$r['hpp']/$r['jml_unit'];
			echo "<tr>
				<td align='center'>$no</td>
				<td>".jin_date_str($r['tanggal'])."</td>
				<td>$r[kode_pj]</td>
				<td>$r[kode_st]</td>
				<td>$r[nama_st]</td>
				<td align='right'>$r[jml_unit]</td>
				<td>$r[satuan]</td>
				<td align='right'>".number_format($hgjual)."</td>
				<td align='right'>".number_format($r['jumlah'])."</td>
				<td align='right'>".number_format($hgbeli)."</td>
			</tr>";
			$no++;
			$tjumlah=$tjumlah+$r['jumlah'];
			$thpp=$thpp+$r['hpp'];
		}
		echo "<tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td align='right'>Jumlah </td>
			<td align='right'>".number_format($tjumlah)."</td>
			<td align='right'>".number_format($thpp)."</td>
		</tr>
	</table>";
?>