<?php 
global $myUser;
if(!$myUser->can('user','configure')) throw new Exception("Permissions insuffisantes",403);
?>
<div class="row">
	<div class="col-md-12">
		<br>
		<h3>Utilisateurs</h3>
		<hr/>

		<div id="userFormAdmin" data-action="save_user">
			
			<div class="row">
				<div class="col-md-6">
					<label for="login">Identifiant :</label>
					<input id="login" required class="form-control" placeholder="Identifiant" type="text">
				</div>
				<div class="col-md-6">
					<label for="mail">Mail :</label>
					<input id="mail" required class="form-control" placeholder="Mail" type="text">
				</div>
			</div>
			<div class="row">
				<div class="col-md-6">
					<label for="password">Mot de passe :</label>
					<input required type="password" data-show-strength data-generator data-type="password" placeholder="Mot de passe" class="form-control" id="password"/>
				</div>
				<div class="col-md-6">
					<label for="password2">Mot de passe (confirmation) :</label>
					<input required type="password" data-type="password" placeholder="Mot de passe (confirmation)" class="form-control" id="password2"/>
				</div>
			</div>
			<div class="row">
				<div class="col-md-6">
					<label for="name">Nom :</label>
					<input id="name" class="form-control" placeholder="Nom" type="text">
				</div>
				<div class="col-md-6">
					<label for="firstname">Prénom :</label>
					<input id="firstname" class="form-control" placeholder="Prénom" type="text">
				</div>
			</div>
			<div class="row">
				<div class="col-md-6">
					<label for="manager">Manager :</label>
					<input id="manager" data-type="user" class="form-control" placeholder="Manager" type="text">
				</div>
			
				<div class="col-md-6 pt-4">
					<div onclick="save_user();" class="btn btn-success float-right"><i class="fas fa-check"></i> Enregistrer</div>
				</div>
			</div>

		</div>
		<hr><br>
		<div class="panel panel-default">
			<div class="panel-heading">Liste des utilisateurs existants :</div><br>
			<table id="users" class="table table-users table-striped ">
				<thead>
					<tr>
						<th class="avatar-head"></th>
						<th>Nom</th>
						<th>Mail</th>
						<th>Identifiant</th>
						<th>Origine</th>
						<th></th>
					</tr>
				</thead>
				<tbody>
					<tr data-user="{{login}}" class="noDisplay">
						<td class="text-center avatar-cell"><img class="avatar-medium avatar-rounded" data-src="{{avatar}}"/></td>
						<td>{{firstname}} {{name}}</td>
						<td>{{mail}}</td>
						<td><code>{{login}}</code></td>
						<td>{{origin}}</td>
						<td class="text-right">
							<?php if($myUser->can('user','edit')): ?>
								{{#id}}<div onclick="edit_user(this)" class="btn btn-info btn-squarred btn-mini" title="Modifier"><i class="fas fa-pencil-alt"></i></div>{{/id}}
							<?php endif; ?>
							<?php if($myUser->superadmin): ?>
								<div onclick="window.location='action.php?action=user_impersonation&login={{login}}';" title="Se connecter en tant que {{login}}" class="btn btn-warning btn-squarred btn-mini"><i class="far fa-meh-blank"></i></div>
							<?php endif; ?>
							<div onclick="delete_user(this)" class="btn btn-danger btn-squarred btn-mini"><i class="fas fa-times"></i></div>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
	</div>
</div>

