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

$hal	= $_GET['hal'] ? $_GET['hal'] : 0;
$lim	= 10;

$query = "SELECT kode_st FROM faktur_pj WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir' AND batal='' GROUP BY kode_st ";
$data	= mysql_query($query);
$jml 	= mysql_num_rows($data);
$max	= ceil($jml/$lim);

echo "<div id='info'>	
	<table id='theList' width='100%'>
	<tr>
		<th>No.</th>
		<th>Kode Barang</th>
		<th>Nama Barang</th>
		<th>Satuan</th>
		<th>Jumlah Unit</th>		
		<th>Total Harga</th>
	</tr>";
		
	$query	= "SELECT kode_st,nama_st,satuan,sum(jml_unit) as totunit,sum(jumlah) as totjumlah FROM faktur_pj 
		WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir'	AND batal='' GROUP BY kode_st	LIMIT $hal,$lim";
	$data	= mysql_query($query);
	$no=1+$hal;
	$total=0;
	
	while($r_data=mysql_fetch_array($data)){
		echo "<tr>
			<td align='center'>$no</td>
			<td align='center'>$r_data[kode_st]</td>
			<td>$r_data[nama_st]</td>
			<td align='center'>$r_data[satuan]</td>
			<td align='right'>$r_data[totunit]</td>			
			<td align='right'>".number_format($r_data[totjumlah])."</td>
			</tr>";
		$total=$total+$r_data[totjumlah];
		$no++;
	}
	
	echo "<tr>
			<td></td>
			<td></td>
			<td></td>			
			<td></td>
			<td align='right'>Total</td>
			<td align='right'>".number_format($total)."</td>
		</tr>";
		
	echo "</table>";
	echo "<table width='100%'>
		<tr>			
			<td align='right'>Halaman :";
			for ($h = 1; $h <= $max; $h++) {
				$list[$h] = $lim * $h - $lim;
				echo " <a href='javascript:void(0)' ";?> 
                   onClick="$.get('modul/report/tampil_rekap_pj.php?kode1=<?php echo $_GET['kode'];?>                    
                   &hal=<?php echo $list[$h]; ?>', 
                   null, function(data) {$('#info').html(data);})" <?php echo">".$h."</a> ";
			}
	echo "</td>
		</tr>
		</table>";
echo "</div>";
?>
