<script type="text/javascript">
    $(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'];
$kodesp   = $_GET['kodesp'];

echo "<div id='info'>	
<table id='theList' width='100%'>
	<tr>
		<th>No.</th>
		<th>Kode Barang</th>
		<th>Nama Barang</th>
		<th>Barcode</th>
		<th>Satuan</th>
		<th>Jumlah Unit</th>		
		<th>Total Harga</th>
	</tr>";
	If(!($kodesp==''))
		$query= "SELECT kode_st,nama_st,barcode,satuan,sum(jml_unit) as totunit,sum(jumlah) as totjumlah FROM faktur_pb WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir' AND batal='' AND kode_sup='$kodesp' GROUP BY kode_st";
	else
		$query= "SELECT kode_st,nama_st,barcode,satuan,sum(jml_unit) as totunit,sum(jumlah) as totjumlah FROM faktur_pb WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir' AND batal='' GROUP BY kode_st";
	$data= mysql_query($query);
	$no=1;
	$total=0;
	
	while($r=mysql_fetch_array($data)){
		echo "<tr>
			<td align='center'>$no</td>
			<td align='center'>$r[kode_st]</td>
			<td>$r[nama_st]</td>
			<td>$r[barcode]</td>
			<td align='center'>$r[satuan]</td>
			<td align='right'>$r[totunit]</td>
			<td align='right'>".number_format($r['totjumlah'])."</td>
		</tr>";
		$total=$total+$r['totjumlah'];
		$no++;
	}
	
	echo "<tr>
		<td></td>
		<td></td>
		<td></td>			
		<td></td>
		<td></td>
		<td align='right'>Total</td>
		<td align='right'>".number_format($total)."</td>
	</tr>
</table>";

echo "</div>";
?>