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

        $("#theList.detail tr").hover(
            function() {
                $(this).toggleClass("highlight");
            },
            function() {
                $(this).toggleClass("highlight");
            }
        );
    });	
});
		
	function pilih(ID){
		var kode = ID;
						
		$.ajax({
			type	: "POST",
			url	: "modul/inventory/cari_stup.php",
			data	: "kode="+kode,
			dataType	: "json",
			success	: function(data){
				$("#u_kodest").val(data.kodest);
				$("#u_namast").val(data.namast);
				$("#u_barcode").val(data.barcode);
				$('#form_cari_brup').dialog('close');
				tampil_gambar();
			}			
		});
	}
	
	function tampil_gambar(){
		var kode= $("#u_kodest").val();
		$("#data_gambar").load("modul/inventory/tampil_gambar.php?kode="+kode);
	}
</script>

<?php
include '../../inc/inc.koneksi.php';

$cari	= $_GET['cari'];

echo "<table id='theList' class='detail' width='100%'>
		<tr>
			<th>No.</th>
			<th>Kode</th>
			<th>Nama Barang</th>
			<th>Barcode</th>
			<th>Foto</th>
			<th>Ambil</th>
		</tr>";
		
		if (!empty($cari)) $sql= "SELECT * FROM stock WHERE nama_st LIKE '%$cari%' ORDER by kode_st";
		else $sql= "SELECT * FROM stock ORDER BY kode_st";
		
		$query = mysql_query($sql);
		$no=1;
		
		while($r_data=mysql_fetch_array($query)){
			echo "<tr>
				<td>$no</td>
				<td>$r_data[kode_st]</td>
				<td>$r_data[nama_st]</td>
				<td>$r_data[barcode]</td>
				<td>$r_data[foto]</td>
				<td align='center'>						
					<a href='javascript:void(0)' onClick=\"pilih('$r_data[kode_st]')\">
						<img src='icon/download.gif' border='0' id='tambah_data' title='Pilih' width='12' height='12'>
					</a>
				</td>
			</tr>";
			$no++;
		}
	echo "</table>";	
?>