<title>Edit Admin</title>
<div id="pagetitle">EDIT ADMIN</div>
<div id="batascontent">
	<form action="?m=admin_update" method="post" enctype="multipart/form-data">
		<?php
			$id = mysqli_real_escape_string($koneksi, $_GET['id']);
			$db	= mysqli_query($koneksi, "SELECT * FROM cmas_admin WHERE admin_id='$id'");
			$dt	= mysqli_fetch_array($db);
		?>
		<input name="admin_id" type="hidden" value="<?php echo $dt['admin_id']; ?>">

		<div id="wrapgsetting" class="clearfix">
			<div id="gsettingleft">
				<div id="gsettingtitles">GENERAL</div>
				<div id="gsetting" class="clearfix">
					<?php
						$sql = "SELECT admincat_id,admincat_nama FROM cmas_admincat";
						$getCombo = mysqli_query($koneksi, $sql) or die ('Query Gagal');
					?>
					<script type="text/javascript">
						$(function() {
							$("#KATID").change(function(){
								$("img#imgLoad").show();
								var admincat_id = $(this).val();
								
								$.ajax({
									type: "POST",
									dataType: "html",
									url: "libs/getAdminCat.php",
									data: "admincat_id="+admincat_id,
									success: function(msg){
										if(msg == ''){
											$("select#KATNAME").html('<option value="">- Pilih -</option>');
											}else{
											$("select#KATNAME").html(msg);                                                       
										}
										$("img#imgLoad").hide();
									}
								});                    
							});
						});
					</script>
					<div id="gsettinglabel">Level</div>
					<div id="gsettingedit">
						<select name="admincat_id" id="KATID">
							<option value="<?php echo $dt['admincat_id']; ?>"><?php echo $dt['admincat_nama']; ?></option>
							<?php
								while($data = mysqli_fetch_array($getCombo)){
									echo '<option value="'.$data['admincat_id'].'">'.$data['admincat_nama'].'</option>';
								}
							?>
						</select>
						<select name="admincat_nama" id="KATNAME" style="display:none">
							<option value="<?php echo $dt['admincat_nama']; ?>"><?php echo $dt['admincat_nama']; ?></option>
						</select>
					</div>
				</div>
				<div id="gsetting" class="clearfix">
					<div id="gsettinglabel">Nama Lengkap</div>
					<div id="gsettingedit">
						<input name="admin_nama" type="text" value="<?php echo $dt['admin_nama']; ?>" autocomplete="off">
					</div>
				</div>
				<div id="gsetting" class="clearfix">
					<div id="gsettinglabel">Alamat Email</div>
					<div id="gsettingedit">
						<input name="admin_email" type="email" value="<?php echo $dt['admin_email']; ?>" autocomplete="off">
					</div>
				</div>
				<div id="gsetting" class="clearfix">
					<div id="gsettinglabel">Username</div>
					<div id="gsettingedit">
						<input name="admin_username" type="text" value="<?php echo $dt['admin_username']; ?>" autocomplete="off">
					</div>
				</div>
			</div>
			
			<div id="gsettingrite">
				<div id="gsettingtitles">ATTRIBUTE</div>
				<div id="gsetting" class="clearfix">
					<div id="gsettinglabel">Status</div>
					<div id="gsettingedit">
						<select name="admin_status">
							<option value="<?php echo $dt['admin_status']; ?>"><?php echo $dt['admin_status']; ?></option>
							<?php $stdb=mysqli_query($koneksi, "SELECT * FROM cmas_status ORDER BY status_id ASC"); while($stdt=mysqli_fetch_array($stdb)) { ?>
								<option value="<?php echo $stdt['status_nama']; ?>"><?php echo $stdt['status_nama']; ?></option>
							<?php } ?>
						</select>
					</div>
				</div>
				<div id="gsetting" class="clearfix">
					<div id="gsettinglabel">Upload</div>
					<div id="gsettingimage">
						<input name="admin_image" type="file" />
					</div>
				</div>
				<div id="gsetting" class="clearfix">
					<div id="gsettinglabel">Profil</div>
					<div id="gsettingimgsml">
						<?php if ($dt['admin_imageid'] == 0) { ?>
							<img src="assets/images/noprofile.jpg" alt="<?php echo $dt['admin_nama']; ?>" title="<?php echo $dt['admin_nama']; ?>" style="border-radius:100%;">
						<?php } else { ?>
							<img src="assets/images/admin/<?php echo $dt['admin_image']; ?>" alt="<?php echo $dt['admin_nama']; ?>" title="<?php echo $dt['admin_nama']; ?>" style="border-radius:100%;">
							
							<a href="?m=admin_hapusfile&id=<?php echo $dt['admin_id']; ?>" onclick="return confirm('DATA AKAN DIHAPUS, ANDA YAKIN?');">
								<span><img src="assets/images/icons/icon_tidak.png" title="Hapus File"></span>
							</a>
						<?php } ?>
					</div>
				</div>
			</div>
		</div>
		<div id="tombolsubmit">
			<a href="?m=admin_index"><input name="button" type="button" value="KEMBALI" class="myButton" /></a>
			<input name="submit" type="submit" value="SIMPAN" class="submitbutton"/>
		</div>
	</form>
	<div id="infobottom" class="clearfix">
		<div class="infobottomleft">
			Posted by <b><?php echo $dt['posted_nama']; ?></b> on <b><?php echo date_format(date_create($dt['postdated']), 'd/m/Y H:i:s'); ?></b>
		</div>
		<div class="infobottomrite">
			Updated by <b><?php echo $dt['updated_nama']; ?></b> on <b><?php echo date_format(date_create($dt['updated']), 'd/m/Y H:i:s'); ?></b>
		</div>
	</div>
</div>