<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_st.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#l_kodest").val(kode);				
				$("#l_namast").val(data.namast);
				$("#l_barcode").val(data.barcode);
				$("#l_kodesp").val(data.kodesp);
				$("#l_satuan").val(data.satuan);
				$("#l_hgjual").val(data.hgjual);
				$("#form_cari_label").dialog('close');
				$("#info_barang").hide();
				$("#l_kali").focus();
			}			
		});
	}
</script>

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

$cari	= $_GET['cari'];

echo "<table id='theList' class='detail' width='100%'>
		<tr>			
			<th>Kode</th>
			<th>Nama Barang</th>
			<th>Barcode</th>
			<th>Satuan</th>
			<th>Kode Sup.</th>
			<th>Harga Jual</th>
			<th>Jml. Stok A</th>
			<th>Pilih</th>
		</tr>";		
		if(!empty($cari))
			$sql= "SELECT * FROM stock WHERE (nama_st LIKE '%$cari%' OR kode_st LIKE '%$cari%' OR barcode LIKE '%$cari%') ORDER by kode_st";
		else
			$sql= "SELECT * FROM stock ORDER BY kode_st";		
		$query = mysql_query($sql);
		$no=1;

		while($r=mysql_fetch_array($query)){
			echo "<tr>				
				<td>$r[kode_st]</td>
				<td>$r[nama_st]</td>
				<td>$r[barcode]</td>
				<td>$r[satuan]</td>
				<td>$r[kode_sp]</td>
				<td align='right'>".number_format($r['hg_jual'],0)."</td>
				<td align='right'>".number_format($r['jml_stok'],2)."</td>
				<td align='center'>						
					<a href='javascript:void(0)' onClick=\"pilih('$r[kode_st]')\">
						<img src='icon/thumb_up.png' border='0' id='edit' title='Ambil' width='12' height='12' >
					</a>
				</td>
			</tr>";
			$no++;
		}
	echo "</table>";	
?>