<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;
$jml = 0;
$tjumlah=0;

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>Harga Satuan</th>
		<th>Total Harga</th>
	</tr>";
		
	$query2	= "SELECT kode_pb,tanggal,nomor_fk,count(kode_st) as totitem FROM faktur_pb 
		WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir'	AND batal='' GROUP BY kode_pb	LIMIT $hal,$lim";
	$data2	= mysql_query($query2);
	while($r_data2=mysql_fetch_array($data2)){
		$kodepb=$r_data2['kode_pb'];

		echo "<tr>
				<td></td>
				<td align='center'><b>No.Faktur :</b></td>
				<td><b>$r_data2[nomor_fk]</b></td>
				<td align='center'><b>".jin_date_str($r_data2['tanggal'])."</b></td>				
			</tr>";
			
		$sql = "SELECT * FROM faktur_pb WHERE kode_pb='$kodepb' LIMIT $hal,$lim";		
		$query = mysql_query($sql);
		
		$no=1+$hal;
		$sjumlah=0;
		while($r_data=mysql_fetch_array($query)){
			
			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[jml_unit]</td>
				<td align='right'>".number_format($r_data['hg_beli'])."</td>
				<td align='right'>".number_format($r_data['jumlah'])."</td>
				</tr>";
			$sjumlah=$sjumlah+$r_data['jumlah'];
			$no++;
			$jml++;			
		}
		echo "<tr>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td align='right'>Jumlah</td>
				<td align='right'>".number_format($sjumlah)."</td>
			</tr>";
			$tjumlah=$tjumlah+$sjumlah;
	}
	echo "<tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td align='right'>Total </td>
			<td align='right'>".number_format($tjumlah)."</td>
		</tr>";
	
	echo "</table>";
	echo "<table width='100%'>
		<tr>
			<td>Jumlah Data : $jml</td>
			<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_data_pb.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>";
?>