<?php 
global $myUser;
User::check_access('user','configure');

?>
<div class="row">
	<div class="col-md-12">
		<br>
		<h3>Établissement / Utilisateur / Rang</h3>
		<hr/>

		<div id="userfirmrankForm" data-action="save_userfirmrank">
			<div class="form-row">
				<div class="form-group col-md-3">
			     	<label for="firm">Établissement :</label>
			     	<select class="form-control" id="firm" placeholder="Etablissement" onchange="search_userfirmrank();">
			     			<option value="0">Tous</option>
			     		<?php foreach (Firm::loadAll() as $firm) : ?>
							<option value="<?php echo $firm->id; ?>"><?php echo $firm->label; ?></option>
						<?php endforeach; ?>
					</select>
			    </div>
			    <div class="form-group col-md-3">
			     	<label for="firm">Utilisateur :</label>
			     	<input type="text" data-type="user" placeholder="Nom, prénom..." class="form-control" id="user" name="user"/>
			    </div>
			    <div class="form-group col-md-3">
			     	<label for="rank">Rang :</label>
			     	<select class="form-control" id="rank" placeholder="Rang">
			     		<?php foreach(Rank::loadAll() as $rank):  ?>
							<option value="<?php echo $rank->id; ?>"><?php echo $rank->label; ?></option>
						<?php endforeach; ?>
					</select>
			    </div>
				<div class="form-group col-md-3 text-right">
			     	<div class="btn btn-success noLabel " onclick="save_userfirmrank()"><i class="fas fa-check"></i> Enregistrer</div>
			    </div>
			</div>
		</div>
		<br/>
		<div class="panel panel-default">
			<legend class="panel-heading">Utilisateurs de l'établissement :</legend>
			<table id="userfirmranks" class="table table-striped">
				<thead>
					<tr>
						<th></th>
						<th>Nom</th>
						<th>Prénom</th>
						<th>Établissement</th>
						<th>Fonction</th>
						<th>Rang</th>
						<th class="text-right"></th>
					</tr>
				</thead>
				<tbody>
					<tr data-id="{{id}}" class="hidden">
						<td class="text-center">{{#avatar}}<img class="avatar-mini avatar-rounded" data-src="{{avatar}}"/>{{/avatar}}</td>
						<td>{{user.name}}</td>
						<td>{{user.firstname}}</td>
						<td>{{firm}}</td>
						<td>{{user.function}}</td>
						<td>{{rank}} {{#superadmin}}<span class="label label-info">Super Admin</span>{{/superadmin}}</td>
						<td class="text-right">
							<div onclick="edit_userfirmrank(this)" class="btn btn-info btn-squarred btn-mini"><i class="fas fa-pencil-alt"></i></div>
							<div onclick="delete_userfirmrank(this)" class="btn btn-danger btn-squarred btn-mini"><i class="fas fa-times"></i></div>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
	</div>
</div>

