<title>Admin</title>
<div id="pagetitle">ADMIN</div>
<div id="batascontent">
	<?php if ($udt['admincat_id'] != "1") {} else { ?>
		<div id="tomboltambah">
			<a href="?m=admin_input" class="addbutton">+ ADMIN</a>
		</div>
	<?php } ?>
	<div id="tableres">
		<table width="100%" cellpadding="0" cellspacing="0" border="0" class="display" id="example">
			<thead>
				<tr align="left">
					<th>NO</th>
					<th></th>
					<th>NAMA ADMIN</th>
					<th>ALAMAT EMAIL</th>
					<th>USERNAME</th>
					<th>LEVEL</th>
					<th></th>
					<th>ID</th>
				</tr>
			</thead>
			<tbody>
				<?php
					$nomor = 1;
					if ($udt['admincat_id'] == "1") {
						$db = mysqli_query($koneksi, "SELECT * FROM cmas_admin ORDER BY admin_id ASC");
					} elseif ($udt['admincat_id'] == "2") {
						$db = mysqli_query($koneksi, "SELECT * FROM cmas_admin WHERE admincat_id!='1' ORDER BY admin_id ASC");
					} elseif ($udt['admincat_id'] == "3") {
						$db = mysqli_query($koneksi, "SELECT * FROM cmas_admin WHERE admin_id='$udt[admin_id]' ORDER BY admin_id ASC");
					}
					while($dt = mysqli_fetch_array($db)) {
					
					if ($dt['admin_status'] == "Non-Aktif") {
						$admin_status = "<img src='assets/images/icons/icon_no.png' width='20' alt='$dt[admin_status]' title='$dt[admin_status]'>";
					} else {
						$admin_status = "<img src='assets/images/icons/icon_yes.png' width='20' alt='$dt[admin_status]' title='$dt[admin_status]'>";
					}
					
					if ($dt['admin_imageid'] == 0) {
						$admin_image = "<img src='assets/images/noprofile.jpg' width='40' alt='$dt[admin_nama]' title='$dt[admin_nama]' style='border-radius:100%;'>";
					} else {
						$admin_image = "<img src='assets/images/admin/$dt[admin_image]' width='40' alt='$dt[admin_nama]' title='$dt[admin_nama]' style='border-radius:100%;'>";
					}
				?>
					<tr>
						<td align="center" width="1%">
							<?php echo $nomor; ?>
						</td>
						<td align="center" width="1%">
							<a href="?m=admin_edit&id=<?php echo $dt['admin_id']; ?>" title="Edit Data">
								<?php echo $admin_image; ?>
							</a>
						</td>
						<td>
							<a href="?m=admin_edit&id=<?php echo $dt['admin_id']; ?>" title="Edit Data">
								<?php echo $dt["admin_nama"]; ?>
							</a>
						</td>
						<td>
							<?php echo $dt["admin_email"]; ?>
						</td>
						<td>
							<?php echo $dt["admin_username"]; ?>
						</td>
						<td width="1%">
							<?php echo $dt["admincat_nama"]; ?>
						</td>
						<?php if ($udt['admincat_id'] == "1") { ?>
							<td align="center" width="12%">
								<a href="?m=admin_updatestatus&id=<?php echo $dt['admin_id']; ?>">
									<?php echo $admin_status; ?> 
								</a>
								<a href="?m=admin_edit&id=<?php echo $dt['admin_id']; ?>">
									<img src="assets/images/icons/icon_edit.png" width="20" title="Edit Data">
								</a>
								<a href="?m=admin_details&id=<?php echo $dt['admin_id']; ?>">
									<img src="assets/images/icons/icon_view.png" width="20" title="Lihat Data">
								</a>
								<a href="?m=admin_password&id=<?php echo $dt['admin_id']; ?>">
									<img src="assets/images/icons/icon_pass.png" width="20" title="Ubah Password">
								</a>
								<a href="?m=admin_hapus&id=<?php echo $dt['admin_id']; ?>" onclick="return confirm('DATA AKAN DIHAPUS, ANDA YAKIN?');">
									<img src="assets/images/icons/icon_delete.png" width="20" title="Hapus Data">
								</a>
							</td>
						<?php } else { ?>
							<td align="center" width="10%">
								<a href="?m=admin_updatestatus&id=<?php echo $dt['admin_id']; ?>">
									<?php echo $admin_status; ?> 
								</a>
								<a href="?m=admin_edit&id=<?php echo $dt['admin_id']; ?>">
									<img src="assets/images/icons/icon_edit.png" width="20" title="Edit Data">
								</a>
								<a href="?m=admin_details&id=<?php echo $dt['admin_id']; ?>">
									<img src="assets/images/icons/icon_view.png" width="20" title="Lihat Data">
								</a>
								<a href="?m=admin_password&id=<?php echo $dt['admin_id']; ?>">
									<img src="assets/images/icons/icon_pass.png" width="20" title="Ubah Password">
								</a>
							</td>
						<?php } ?>
						<td align="center" width="1%">
							<?php echo $dt["admin_id"]; ?>
						</td>
					</tr>
				<?php $nomor++; } ?> 
			</tbody>
		</table>
	</div>
</div>