<style type="text/css">
	body{
		font-family: "Arial";
	}
</style>
<body>
<?php
	if(isset($_SESSION["ses_id_tpk"])){
		$sql="SELECT * FROM m_user WHERE id='$_SESSION[ses_id_tpk]' ORDER BY nama_lengkap ASC";
	}else{
		$sql="SELECT * FROM m_user ORDER BY nama_lengkap ASC";
		echo "<h3 align=\"right\" style=\"padding-right:10px\"><a href='?action=add_user' style=\"color:#FF0066\">Tambah Data Pengguna</a></h3>";
	}

	$query=mysqli_query($mysqli,$sql);
	
	echo "<table width='100%' border='1'>
			<tr bgcolor='#fffccc'>
				<th>No</th>
				<th>ID Pengguna</th>
				<th>Nama Lengkap</th>
				<th>Level Pengguna</th>
				<th>Opsi</th>
			</tr>
	";
	$i=1;
	while($data=mysqli_fetch_array($query)){
		if($data[level]=="TPK"){
			$id_desa=$data[id_desa];
			$qr=mysqli_query($mysqli,"SELECT * FROM m_desa WHERE id_desa='$id_desa'");
			$dt=mysqli_fetch_array($qr);
			$nm_desa=$dt[nama_desa];

			$level="TPK " . $nm_desa;
		}else{
			$level=$data[level];
		}

		if(isset($_SESSION["ses_id_tpk"])){
			$link="<a href='admin.php?action=edit_user&id=$data[id]'>Edit</a>";
		}else{
			$link="<a href='admin.php?action=edit_user&id=$data[id]'>Edit</a> | <a href='_del_pengguna.php?id=$data[id]' onclick=\"return confirm('Yakin akan dihapus?')\">Hapus</a>";
		}
		echo "<tr>
				<td>$i</td>
				<td>$data[username]</td>
				<td>$data[nama_lengkap]</td>
				<td>$level</td>
				<td>$link</td>
		
			</tr>";
		$i++;
	}
	
	echo "</table>";
	
	
	

?>
</body>