<?php 

global $myUser;
User::check_access('rank','configure');
$rank = Rank::getById($_['rank']);
?>
<div class="row">
	<div class="col-md-12">
		<br>
		<h3 id="rank" data-rank="<?php echo $rank->id ?>">Droits pour le rang <span class="text-success"><?php echo $rank->label ?></span> :</h3>
		<hr>

		<div class="row">
			<div class="col-md-12">
				<label>Etablissement concerné :</label>
				<select onchange="search_right('update_checkboxes');" class="form-control" id="firm">
					<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>
		<br>		

		<div class="panel panel-default">
			<table id="ranks" class="table table-striped">
				<thead>
					<tr>
						<th>Libellé</th>
						<th>Description</th>
						<th></th>
						<th class="text-center">Consultation</th>
						<th class="text-center">Édition</th>
						<th class="text-center">Suppression</th>
						<th class="text-center">Configuration</th>
					</tr>
				</thead>
				<tbody>
					<tr class="hidden" data-section="{{section}}">
						<td>{{section}}</td>
						<td>{{description}}</td>
						<td class="text-center"><div class="btn btn-warning" onclick="right_switch(this);"><i class="fas fa-redo"></i> Tout switcher</div></td>
						<td class="text-center">
							<input data-right="read" data-result={{read}} onchange="toggle_right(this)"  type="checkbox" autocomplete="off" name="read-{{section}}" id="read-{{section}}" data-type="checkbox">
						</td>
						<td class="text-center">
							<input data-right="edit" data-result={{edit}} onchange="toggle_right(this)" type="checkbox" autocomplete="off" name="edit-{{section}}" id="edit-{{section}}" data-type="checkbox">
						</td>
						<td class="text-center">
							<input data-right="delete" data-result={{delete}} onchange="toggle_right(this)" type="checkbox" autocomplete="off" name="delete-{{section}}" id="delete-{{section}}" data-type="checkbox">
						</td>
						<td class="text-center">
							<input data-right="configure" data-result={{configure}} onchange="toggle_right(this)" type="checkbox" autocomplete="off" name="configure-{{section}}" id="configure-{{section}}" data-type="checkbox">
						</td>
					</tr>
				</tbody>
			</table>
		</div>
	</div>
</div>