<?php 
require_once('../../common.php');
if(!$myUser->can('navigation','read')) throw new Exception("Vous n'avez pas la permission pour executer cette fonctionnalité",403);
require_once('MenuItem.class.php');
$menuItem = MenuItem::provide();
?>
<div class="navigation">
	<div id="menuitem-form" class="row menuitem-form" data-action="navigation_menuitem_save" data-id="<?php echo $menuItem->id; ?>">
		<div class="col-md-12">
			<h3>Élement de menu</h3>

			<label for="label">Libellé :</label>
			<div class="input-group mb-3">
				<div class="input-group-prepend">
					<span class="icon-chooser" id="basic-addon-icon-navigation"><input id="icon" data-type="icon" name="icon" class="form-control" placeholder="" value="<?php echo $menuItem->icon==''? 'fas fa-question': $menuItem->icon; ?>" type="text"></span>
				</div>
				<input id="label" name="label" class="form-control" placeholder="Mon menu" value="<?php echo $menuItem->label; ?>" type="text">
			</div>

			<label for="url">Adresse web / Lien :</label>
			<div class="input-group mb-3">
				<input id="url" name="url" class="form-control" placeholder="http://www.monadresse.com" value="<?php echo $menuItem->url; ?>" type="text">
				<div class="input-group-append">
					<span class="input-group-text btn" id="url-btn">
						<i class="fas fa-globe"></i>
					</span>
				</div>
			</div>
			<div class="row navigation-options">
				<div class="col-md-4">
					<?php if($myUser->can('navigation','configure')): ?>
					<div class="nav-option-container">
						<input id="public" class="form-control" <?php echo $menuItem->user == '' ? 'checked' : ''; ?> type="checkbox" data-type="checkbox">
						<label for="public">Menu public</label>
					</div>
					<?php endif; ?>
					<div class="nav-option-container">
						<input id="target" class="form-control" <?php echo $menuItem->target == 1 ? 'checked' : ''; ?> type="checkbox" data-type="checkbox">
						<label for="target">Ouvrir dans un nouvel onglet</label>
					</div>
				</div>
				<div class="col-md-2">
				</div>
				<div class="col-md-6">
					<!-- <div class="nav-select-container">
						<label for="parent">Menu parent : </label>
						<select id="parent" name="parent" class="form-control" placeholder="" type="text">
							<option value="0"> - </option>
							<?php foreach(MenuItem::loadAll(array('parent'=>0), array(' label ASC ')) as $parentItem){
								if($parentItem->id == $menuItem->id) continue;
								$selected = ($parentItem->id == $menuItem->parent) ? 'selected' : '';
								echo '<option value="'.$parentItem->id.'" '.$selected.'>'.$parentItem->label.'</option>';
							} ?>
						</select>
					</div> -->
				</div>
			</div>
		</div>
	</div>
</div>
