<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_gr(ID){
		var kode = ID;
				
		$.ajax({
			type	: "POST",
			url	: "modul/inventory/cari_grup.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#txt_kodegr").val(kode);
				$("#txt_namagr").val(data.namagr);
				$("#form_cari_gr").dialog('close');				
				tampil_data_detail();
				cari_nomor();
			}
		});
	}
	
	function tampil_data_detail(kode){
		var kode = $("#txt_kodegr").val();
		
		$("#data_detail").show();		
		$("#data_detail").load("modul/inventory/tampil_data_detail.php?kode="+kode);				
	}

	function cari_nomor(){
		var kode = $("#txt_kodegr").val();
				
		$.ajax({
			type	: "POST",
			url	: "modul/inventory/cari_nomor.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){				
				$("#txt_kodest").val(data.nomor);
				$("#txt_namast").focus();
			}
		});
	}
	
</script>
<?php
include '../../inc/inc.koneksi.php';
$cari = $_GET['cari'];

echo "<table id='theList' class='barang' width='100%'>
		<tr>
			<th>No.</th>
			<th>Kode </th>
			<th>Nama Kelompok</th>
			<th>Ambil</th>
		</tr>";		
		if(!empty($cari))
			$sql	= "SELECT * FROM st_group WHERE (nama_gr LIKE '%$cari%' OR kode_gr LIKE '%$cari%') ORDER by kode_gr";		
		else
			$sql	= "SELECT * FROM st_group ORDER by kode_gr";
	
		$query = mysql_query($sql);
		$no=1;
		while($r=mysql_fetch_array($query)){
			echo "<tr>
				<td align='center'>$no</td>
				<td>$r[kode_gr]</td>
				<td>$r[nama_gr]</td>
				<td align='center'>
				<a href='javascript:void(0)' onClick=\"pilih_gr('$r[kode_gr]')\">
				<img src='icon/download.gif' border='0' id='tambah_data' title='Pilih' width='12' height='12' >
				</a>					
				</td>
			</tr>";
			$no++;
		}		
	echo "</table>";
?>