$erreur = array ();
$entites = $base->meta_entite_liste ($_SESSION['token']);
+$statuts = array(
+ array("id" => 1, "statut" => "Sorti"),
+ array("id" => 2, "statut" => "Pré-admission"),
+ array("id" => 3, "statut" => "Admission"),
+ array("id" => 4, "statut" => "Présent")
+);
$pagination = new Pagination ($base);
$pagination->setImagesPath ('/Images/navig');
}
}
+$lis_statuts = array ();
if (isset ($_GET['lis'])) {
$lis_id = (int)$_GET['lis'];
if (count ($erreur)) {
$lis['lis_code'] = $_POST['ed_code'];
$lis['lis_inverse'] = $_POST['ed_inverse'];
$lis['lis_pagination_tout'] = $_POST['ed_tout'];
+ if (count ($_POST['ed_statut'])) {
+ foreach ($_POST['ed_statut'] as $s) {
+ $lis_statuts[] = array ('sta_id' => $s);
+ }
+ }
} else {
$lis = $base->liste_liste_get ($_SESSION['token'], $lis_id);
+ $lis_statuts = $base->liste_liste_statuts_get($_SESSION['token'], $lis_id);
}
} else {
if (count ($erreur)) {
$lis['lis_code'] = $_POST['ed_code'];
$lis['lis_inverse'] = $_POST['ed_inverse'];
$lis['lis_pagination_tout'] = $_POST['ed_tout'];
+ if (count ($_POST['ed_statut'])) {
+ foreach ($_POST['ed_statut'] as $s) {
+ $lis_statuts[] = array ('sta_id' => $s);
+ }
+ }
} else {
$lis = array ();
}
<script type="text/javascript">
$(document).ready (function () {
$("#dupliquer").click (on_dupliquer_click);
+ $("#ed_statut_lock").change(function (e) {
+ $(".ed_statut_cb").prop('disabled', !e.target.checked);
+ });
+ $("#ed_ent_id").change (function (e) {
+ if (e.target.selectedOptions[0].text == 'Famille')
+ $("#ed_statut_tr").show();
+ else {
+ $("#ed_statut_tr").hide();
+ $("#ed_statut_lock").prop('checked', false);
+ $(".ed_statut_cb").prop('disabled', !e.target.checked);
+ $(".ed_statut_cb").prop('checked', false);
+ }
+ });
});
function on_dupliquer_click () {
<tr class="impair">
<td>Type de personne</td>
- <td><select name="ed_ent_id"><option value=""></option>
+ <td><select name="ed_ent_id" id="ed_ent_id"><option value=""></option>
<?php liste_entites($lis) ?>
</select> <?= arrval ($erreur, 'ed_ent_id', '') ?>
</td>
</tr>
+ <tr class="impair" <?php echo ($entites[array_search($lis['ent_id'], array_column($entites, 'ent_id'))]['ent_libelle'] == 'Famille') ? '' : 'style="display: none"' ?>>
+ <td>Statut usager</td>
+ <td>
+ <input type="checkbox" id="ed_statut_lock" name="ed_statut_lock" value="lock" <?php echo ($lis['lis_locked'] ? 'checked' : '') ?>><label for="ed_statut_lock">Verrouiller sur statut</label><br>
+ <?php liste_statuts_usager ($lis_statuts, $lis['lis_locked']) ?>
+ </td>
+ </tr>
+
<tr class="pair">
<td>Affichage inversé</td>
<td><input type="checkbox" name="ed_inverse"<?= $lis['lis_inverse'] ? ' checked' : ''?>></input>
<?php
+function liste_statuts_usager($lis_statuts, $locked) {
+ global $base, $statuts;
+ foreach ($statuts as $statut) {
+ $checked = false;
+ if (count ($lis_statuts)) {
+ foreach ($lis_statuts as $lis_statut) {
+ if ($lis_statut['sta_id'] == $statut['id']) $checked = true;
+ }
+ }
+ echo '<input class="ed_statut_cb" type="checkbox" id="ed_statut_'.$statut['id'].'" name="ed_statut[]" value="'.$statut['id'].'"'.($checked ? ' checked' : '').($locked ? '' : ' disabled').'><label for="ed_statut_'.$statut['id'].'">'.$statut['statut'].'</label><br>';
+ }
+}
+
function liste_entites ($lis) {
global $entites;
foreach ($entites as $entite) {
global $base;
$lis_id = $_GET['lis'];
- $base->liste_liste_update ($_SESSION['token'], $lis_id, $post['ed_nom'], $post['ed_code'], $post['ed_ent_id'], $post['ed_inverse'] == 'on', $post['ed_tout'] == 'on');
+ $base->liste_liste_update ($_SESSION['token'], $lis_id, $post['ed_nom'], $post['ed_code'], $post['ed_ent_id'], $post['ed_inverse'] == 'on', $post['ed_tout'] == 'on', $post['ed_statut_lock'] ? true : false);
+
+ // Sauve les lens statut d'usager
+ if (isset ($post['ed_statut']) && count ($post['ed_statut'])) {
+ $statuts = array ();
+ foreach ($post['ed_statut'] as $statut) {
+ $statuts[] = $statut;
+ }
+ } else {
+ $statuts = NULL;
+ }
+
+ $base->liste_liste_statuts_set ($_SESSION['token'], $lis_id, $statuts);
return true;
}