<title>Edit Menu</title>
<div id="pagetitle">EDIT MENU</div>
<div id="batascontent" class="clearfix">
	<form action="?m=menu_update" method="post" enctype="multipart/form-data">
		<?php
			$id = mysqli_real_escape_string($koneksi, $_GET['id']);
			$db = mysqli_query($koneksi, "SELECT * FROM cmas_menu WHERE menu_id='$id'");
			$dt = mysqli_fetch_array($db);
		?>
		<input name="menu_id" type="hidden" value="<?php echo $dt['menu_id']; ?>"/> 
		
		<div id="wrapgsetting" class="clearfix">
			<div id="gsettingleft">
				<div id="gsettingtitles">GENERAL</div>
				<div id="gsetting" class="clearfix">
					<div id="gsettinglabel">Nama Menu</div>
					<div id="gsettingedit">
						<input name="menu_nama" type="text" value="<?php echo $dt['menu_nama']; ?>" autocomplete="off" required>
					</div>
				</div>	
				<div id="gsetting" class="clearfix">
					<div id="gsettinglabel">Title Page</div>
					<div id="gsettingedit">
						<input name="menu_title" type="text" value="<?php echo $dt['menu_title']; ?>" autocomplete="off" required>
					</div>
				</div>
				<div id="gsetting" class="clearfix">
					<div id="gsettinglabel">Url</div>
					<div id="gsettingedit">
						<input name="menu_seo" type="text" value="<?php echo $dt['menu_seo']; ?>" autocomplete="off" required>
					</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="menu_status">
							<option value="<?php echo $dt["menu_status"]; ?>"><?php echo $dt["menu_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>
				<!-- KATEGORI -->
				<div id="gsetting" class="clearfix">
					<?php
						$id = mysqli_real_escape_string($koneksi, $_GET['id']);
						$sql = "SELECT menucat_id,menucat_nama FROM cmas_menucat WHERE menucat_status='Aktif' ORDER BY menucat_id ASC";
						$getCombo = mysqli_query($koneksi, $sql) or die ('Query Gagal');
					?>
					<script type="text/javascript">
						$(function() {
							$("#KATID").change(function(){
								$("img#imgLoad").show();
								var menucat_id = $(this).val();
								
								$.ajax({
									type: "POST",
									dataType: "html",
									url: "libs/getMenuCat.php",
									data: "menucat_id="+menucat_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">Kategori</div>
					<div id="gsettingedit">
						<select name="menucat_id" id="KATID">
							<option value="<?php echo $dt["menucat_id"]; ?>"><?php echo $dt["menucat_nama"]; ?></option>
							<?php
								while($data = mysqli_fetch_array($getCombo)){
									echo '<option value="'.$data['menucat_id'].'">'.$data['menucat_nama'].'</option>';
								}
							?>
						</select>
						<select name="menucat_nama" id="KATNAME" style="display:none">
							<option value="<?php echo $dt["menucat_nama"]; ?>"><?php echo $dt["menucat_nama"]; ?></option>
						</select>
					</div>
				</div>
				<div id="gsetting" class="clearfix">
					<div id="gsettinglabel">Target</div>
					<div id="gsettingedit">
						<select name="menu_target" required>
							<option value="<?php echo $dt["menu_target"]; ?>"><?php echo $dt["menu_target"]; ?></option>
							<option value="_self">_self</option>
							<option value="_blank">_blank</option>
						</select>
					</div>
				</div>
				<div id="gsetting" class="clearfix">
					<div id="gsettinglabel">Submenu</div>
					<div id="gsettinginput">
						<?php if ($dt['menu_sub'] == 0) { ?>
							<input name="menu_sub" type="radio" value="0" checked /> No
							<input name="menu_sub" type="radio" value="1" /> Yes
						<?php } else { ?>
							<input name="menu_sub" type="radio" value="0" /> No
							<input name="menu_sub" type="radio" value="1" checked /> Yes
						<?php } ?>
					</div>
				</div>
			</div>
		</div>
		<div id="tombolsubmit">
			<a href="?m=menu_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>		