<script type="text/javascript">	
$(document).ready(function() {
	$("#tabs").tabs({selected:0});
	var level = $(".cari_level:checked").val();
	var kodecab = $("#t_kodecab").val();
	
	$("#form").load('md_dir/users/form.php');
	$("#tampil_data").load('md_dir/users/tampil_data.php?level='+level+'&kodecab='+kodecab);
	
	$("#cari").click(function() {
		var level   = $(".cari_level:checked").val();
	    var kodecab = $("#t_kodecab").val();
		
		$.ajax({
			type	: "GET",
			url	    : "md_dir/users/tampil_data.php",
			data	: "level="+level+
			        "&kodecab="+kodecab,
			success	: function(data){
				$("#tampil_data").html(data);
				$("#cari_txt_all").attr("checked","checked");
				$("#cari_txt_all").attr("checked","checked");
			}
		});
	});
	
	$("#tutup").click(function(){
		document.location='?module=home';
	});
});
</script>

<style type="text/css">
#info {
	font-size:12px;
	font-weight:bold;
	color:#F00;
}
</style>

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

echo "<div id='tabs'>";
echo "<ul>
	    <li><a href='#form'>INPUT PENGGUNA</a></li>
	    <li><a href='#data'>DAFTAR PENGGUNA</a></li>
    </ul>";
      
	echo "<div id='form'></div>";
	
	echo "<div id='data'>
	    <div id='pencarian'>
			<fieldset>
    			<legend>Filter Data</legend>
	    		<table width='100%'>
		    		<tr>
			    		<td width='6%'>Cabang</td>
				    	<td>: <select id='t_kodecab' class='input'>
		                        <option value=''></option>";
		                        $sql=mysql_query("SELECT * FROM cabang WHERE 1");
		                        while($r=mysql_fetch_array($sql)){
		                            $kodecab=$r['kode_cab'];
		                            echo "<option value='$kodecab'>$r[kode_cab] - $r[nama_cab]</option>";
		                        }
		                    echo "</select>
		                </td>
				    </tr>
				    <tr>
					    <td>Level</td>
					    <td>: <input type='radio' name='cari_txt_level' id='cari_txt_level' value='Direktur' class='cari_level'>Direktur
						    <input type='radio' name='cari_txt_level' id='cari_txt_level' value='Supervisor' class='cari_level'>Supervisor
						    <input type='radio' name='cari_txt_level' id='cari_txt_level' value='Admin' class='cari_level'>Admin
						    <input type='radio' name='cari_txt_level' id='cari_txt_level' value='Kepala Toko' class='cari_level'>Kepala Toko
						    <input type='radio' name='cari_txt_level' id='cari_txt_level' value='Kasir' class='cari_level'>Kasir
						    <input type='radio' name='cari_txt_level' id='cari_txt_level' value='Gudang' class='cari_level'>Gudang
						    <input type='radio' name='cari_txt_level' id='cari_txt_level' value='All' class='cari_level' >All
					    </td>
					    <td>
					        <button id='cari'>Cari</button>
					        <button id='tutup'>Keluar</button>
					    </td>
				    </tr>	
			    </table>
			</fieldset>
		</div><br>
		<div id='tampil_data' align='center' style='overflow-x: auto;height: 400px;scroll-behavior: smooth'></div>
	</div>";
echo "</div>";

echo "<div id='info' align='center'></div>";
?>