<script type="text/javascript">
$(document).ready(function() {
    $(function() {
        $("#theList.barang tr:even").addClass("stripe1");
        $("#theList.barang tr:odd").addClass("stripe2");

        $("#theList.barang tr").hover(
            function() {
                $(this).toggleClass("highlight");
            },
            function() {
                $(this).toggleClass("highlight");
            }
        );
    });	
});

	function pilih(ID){
		var kode = ID;
		
		$.ajax({
			type	: "POST",
			url		: "modul/opname/cari_kode.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#t_kode").val(kode);
				$("#t_tanggal").val(data.tgl);		
				$("#form_cari_kodepos").dialog('close');				
			}
		});
	}
</script>

<?php
include '../../inc/inc.koneksi.php';
$no	= $_POST['no'];

echo "<table id='theList' class='barang' width='100%'>
	<tr>
		<th>Kode</th>			
		<th>Tanggal</th>		
		<th>Jml. Item</th>	
		<th>Total Stok</th>	
		<th>Total Fisik</th>	
		<th>Total Selisih</th>
		<th>Nilai Selisih</th>	
		<th>Ambil</th>
	</tr>";
	
	$sql = "SELECT kode_op,tanggal,count(kode_st) as item,sum(jml_stok) as tstok,sum(jml_opn) 	as topn,sum(jml_sls) as tsls,sum(nilai_sls) as tnilai
			FROM st_opname WHERE posting='' GROUP BY kode_op";
				
	$query = mysql_query($sql);
	$jml_data = mysql_num_rows($query);
	$no=1;
	while($r=mysql_fetch_array($query)){
		
		echo "<tr>					
			<td>$r[kode_op]</td>
			<td>$r[tanggal]</td>			
			<td align='center'>$r[item]</td>
			<td align='right'>".number_format($r[tstok],2)."</td>
			<td align='right'>".number_format($r[topn],2)."</td>
			<td align='right'>".number_format($r[tsls],2)."</td>
			<td align='right'>".number_format($r[tnilai],2)."</td>			
			<td align='center'>
				<a href='javascript:void(0)' onClick=\"pilih('$r[kode_op]')\">
				<img src='icon/download.gif' border='0' id='tambah_data' title='Tambah' width='12' height='12' >
				</a>					
			</td>
		</tr>";
		$no++;			
	}
	echo "</table>";
?>