<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		: "md_dir/log_history/cari_user.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#x_userid").val(kode);
				$("#x_username").val(data.username);
				$("#x_level").val(data.level);
				$("#form_cari_user").dialog('close');
			}
		});
	}
</script>

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

echo "<table id='theList' class='barang' width='100%'>
		<tr>
			<th>No.</th>
			<th>User Id</th>
			<th>User Name</th>
			<th>User Level</th>
			<th>Ambil</th>
		</tr>";
		if (!empty($cari))
			$sql = "SELECT * FROM admins WHERE username LIKE '%$cari%' AND (level='Administrator' OR level='Supervisor' OR level='Direktur')";
		else
			$sql = "SELECT * FROM admins WHERE level='Administrator' OR level='Supervisor' OR level='Direktur' ";		
		$query = mysql_query($sql);
		
		$no=1;
		while($r=mysql_fetch_array($query)){
			echo "<tr>
				<td align='center'>$no</td>
				<td>$r[username]</td>
				<td>$r[nama_lengkap]</td>
				<td>$r[level]</td>					
				<td align='center'>
					<a href='javascript:void(0)' onClick=\"pilih('$r[username]')\">
						<img src='icon/download.gif' border='0' id='Pilih User' title='Tambah' width='12' height='12'>
					</a>
				</td>
			</tr>";
			$no++;
		}
	echo "</table>";
?>