<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';
$cari	  = $_GET[cari];

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

echo "<table id='theList' width='100%'>
		<tr>
			<th>No.</th>
			<th>Kode</th>
			<th>Nama Barang</th>
			<th>Satuan</th>			
			<th>Harga Pokok</th>			
			<th>Jumlah Stok</th>
			<th>Hasil Opname</th>
		</tr>";
		
		if (!empty($cari)){
			$query2	= "SELECT * FROM st_group WHERE (nama_gr LIKE '%$cari%' or kode_gr LIKE '%$cari%') ORDER BY kode_gr";
		}
		else{
			$query2	= "SELECT * FROM st_group ORDER BY kode_gr";
		}
		
		$data2	= mysql_query($query2);		
		$jml 	= mysql_num_rows($data2);
		$max	= ceil($jml/$lim);
		
		while($r_data2=mysql_fetch_array($data2)){
			$kodegr=$r_data2[kode_gr];

	echo "<tr>
			<td></td>
			<td><b>$r_data2[kode_gr]</b></td>			
			<td><b>$r_data2[nama_gr]</b></td>
		</tr>";
			
		$sql = "SELECT * FROM stock WHERE kode_gr='$kodegr' ORDER BY kode_st LIMIT $hal,$lim";
		$query = mysql_query($sql);
		
		$no=1+$hal;
		
		while($r_data=mysql_fetch_array($query)){
			$nilai = $r_data[jml_stok]*$r_data[hg_beli];			
			echo "<tr>
					<td>$no</td>
					<td>$r_data[kode_st]</td>
					<td>$r_data[nama_st]</td>
					<td>$r_data[satuan]</td>					
					<td align='right'>".number_format($r_data[hg_beli],0)."</td>					
					<td align='right'>".number_format($r_data[jml_stok],0)."</td>
					<td></td>
				</tr>";			
			$no++;			
		}		
	}
	
	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/opname/tampil_data_blk.php?;
                   &hal=<?php echo $list[$h]; ?>', 
                   null, function(data) {$('#info').html(data);})" <?php echo">".$h."</a> ";
			}
	echo "</td>
		</tr>
		</table>";
echo "</div>";
?>
