<?php 
global $myUser;
User::check_access('dictionnary','configure');
?>
<div class="row">
	<div class="col-md-12">
		<br>
		<h3>Réglages Listes</h3>
		<hr/>
		<div class="panel panel-default lists-settings">
			<div class="form-inline">
				<div class="lists-navigation-block">
					<div id="prev-button" class="btn btn-info hidden" onclick="previous_list_dictionnary(this)">
						<i class="fas fa-angle-left pointer noPrint"></i>
					</div>
					<span>Voir les éléments de la liste &nbsp;&nbsp;</span>
					<select id="parent" class="form-control lists-selector" onchange="search_dictionnary();">
						<span class="hidden"><option value="{{id}}" class="hidden">{{label}}</option></span>
						<option value="" selected>-</option>

						<?php foreach(Dictionnary::loadAll(array('parent'=>0, 'state'=>Dictionnary::ACTIVE), array('id')) as $list): ?>
							<option value="<?php echo $list->id; ?>"><?php echo $list->label; ?></option>
						<?php endforeach; ?>
					</select>

					<?php if($myUser->superadmin == 1): ?>
						<code>Pour ajouter une liste racine, ne rien sélectionner dans cette liste</code><br/>
					<?php endif; ?>
				</div>
			</div>
			<br/>
			<table id="dictionnaries" class="table table-striped  table-dictionaries">
				<thead>
					<tr>
						<th style="width: 5%;">#</th>
						<th>Valeur</th>
						<?php if($myUser->superadmin == 1): ?>
							<th style="width: 15%;">Slug</th>
							<th style="width: 30%;">Libellé de sous-liste</th>
						<?php endif; ?>
						<th style="width: 150px;"></th>
					</tr>
					<tr id="dictionnaryForm" data-action="save_dictionnary">
						<th>#</th>
						<th><input id="label" class="form-control" placeholder="Valeur" type="text"></th>
						<?php if($myUser->superadmin == 1): ?>
							<th><input id="slug" class="form-control" placeholder="slug" type="text"></th>
							<th><input id="sublistlabel" class="form-control" placeholder="Libellé de sous-liste" type="text"></th>
						<?php endif; ?>
						<th class="text-center"><div onclick="save_dictionnary();" class="btn btn-success "><i class="fas fa-check"></i> Enregistrer</div></th>
					</tr>
				</thead>
				<tbody>
					<tr data-id="{{id}}" data-parent="{{parent}}" class="hidden">
						<td>{{id}}</td>
						<td class="itemLabel">{{label}}</td>
						<?php if($myUser->superadmin == 1): ?>
							<td>{{slug}}</td>
							<td>{{sublistlabel}}</td>
						<?php endif; ?>
						<td class="text-center">
							<div onclick="add_sub_dictionnary(this)" class="btn btn-success btn-squarred btn-mini"><i class="fas fa-search-plus"></i></div>
							<div onclick="edit_dictionnary(this)" class="btn btn-info btn-squarred btn-mini"><i class="fas fa-pencil-alt"></i></div>
							<div onclick="delete_dictionnary(this)" class="btn btn-danger btn-squarred btn-mini"><i class="fas fa-times"></i></div>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
	</div>
</div>