function gerer_candidature() { global $page; global $session; global $url; global $message; $page['gabarit'] = "administration"; if (isset($_SESSION['role_user']) && droit_acces($session['gerer_candidature'], $_SESSION['role_user'])) { $page['vue'] = "sessions/candidature_session.vue.php"; $page['colonne'] = "sessions/sidebar_session.vue.php"; $page['sessions'] = liste_session(); $page['motif'] = liste_motif(); $id = ""; if (isset($_GET['id'])) { $id = $_GET['id']; } if (isset($_POST['id_session'])) { $id = $_POST['id_session']; } $page['candidatures'] = liste_candidature($id); $page['session'] = detail_session($id); $page['session'] = $page['session'][0]; $page['candidats'] = liste_candidat_sans_session(); $candidats_json = liste_candidat_sans_session_json(0, 0, $id); if (!isset($_GET['page'])) { $nbpage = 1; } else { $nbpage = $_GET['page']; } if (!isset($_GET['rows'])) { $rows = sizeof($candidats_json); } else { $rows = $_GET['rows']; } $reponse = (object) array('records' => "", 'total' => "", 'page' => "", 'rows' => ""); $count = sizeof($candidats_json); if ($rows == 0) { $rows = 1; } $total = ceil($count / $rows); $reponse->page = $nbpage; $reponse->total = $total; $reponse->records = $count; $i = 0; foreach ($candidats_json as $key => $user) { foreach ($candidats_json[$key] as $k => $v) { $candidats_json[$key][$k] = htmlentities(utf8_encode($v)); } $candidats_json[$key]['nid_candidat'] = $user['nid_candidat'] . "|" . $user['id_candidat']; //$candidats_json[$key]['nid_candidat']="<a href='index.php?controleur=administration&tache=modifier_candidat&id=".$user['id_candidat']."' >".$user['nid_candidat']."</a>"; $candidats_json[$key]['id_candidat'] = "<input type='checkbox' value='" . $user['id_candidat'] . "' name='candidats[]'/>"; } foreach ($candidats_json as $line) { $reponse->rows[$i]['id'] = $line['id_candidat']; $reponse->rows[$i]['cell'] = array($line['id_candidat'], $line['nid_candidat'], $line['nom_usage_candidat'], $line['prenom_candidat']); $i++; } $page['candidats_json'] = json_encode($reponse); if (isset($_POST['ger_session']) && !isset($_GET['id'])) { if (is_current_version_session($_POST['id_session'], $_POST['revision'])) { if (count_candidat_session($_POST['id_session']) + sizeof($_POST['candidats']) <= get_nb_participant_max_session($_POST['id_session'])) { foreach ($_POST['candidats'] as $user) { $id_candidature = creation_candidature($user, $_POST['id_motif']); creation_motif_candidature($id_candidature, $_POST['id_motif']); creation_inscription($id_candidature, $_POST['id_session']); } header("Location: index.php?controleur=session&tache=modifier_session&id=" . $_POST['id_session']); } else { $page['message'] = $message['probleme_nb_max']; } //base(); } else { $page['message'] = $message['session_outdated']; } } else { } } else { $page['vue'] = "erreur_droit.vue.php"; } }
function liste_session_json($page, $limit) { global $db; $cond = ""; if (!in_array('1', $_SESSION['role_user'])) { $cond = "and id_lieu= " . $_SESSION['id_lieu'] . ""; } $sqlc = "select count(id_session) as count from session "; $reqc = $db->prepare($sqlc); if (!$reqc->execute()) { write_log('Erreur SQL:' . $sql . ' sur fonction : ' . __FUNCTION__ . ' ligne : ' . __LINE__); } $resc = $reqc->fetchAll(PDO::FETCH_ASSOC); if ($limit == 0) { $limit = $resc[0]['count']; } $start = $limit * $page - $limit; $sql = "select date_session, rang_session, libelle_court_organisme, duree_session, nb_candidats_max, id_session from session, organisme where session.id_lieu=organisme.id_organisme {$cond} LIMIT {$start}, {$limit};"; $req = $db->prepare($sql); if (!$req->execute()) { write_log('Erreur SQL:' . $sql . ' sur fonction : ' . __FUNCTION__ . ' ligne : ' . __LINE__); } $res = $req->fetchAll(PDO::FETCH_ASSOC); $reponse = (object) array('records' => "", 'total' => "", 'page' => "", 'rows' => ""); $count = $resc[0]['count']; if ($limit == 0) { $limit = 1; } $total = ceil($count / $limit); $reponse->page = $page; $reponse->total = $total; $reponse->records = $count; $i = 0; foreach ($res as $key => $user) { foreach ($res[$key] as $k => $v) { $res[$key][$k] = utf8_encode($v); } $date_array = explode('-', $user['date_session']); $timestamp = mktime("00", "00", "01", $date_array[1], $date_array[2], $date_array[0]); $res[$key]['id_session-a'] = "<a href='index.php?controleur=session&tache=modifier_session&id=" . $user['id_session'] . "'>Modifier</a>"; $res[$key]['id_session-a'] = $res[$key]['id_session-a'] . " | " . "<a href='index.php?controleur=session&tache=supprimer_session&id=" . $user['id_session'] . "'>Supprimer</a>"; $res[$key]['nb_participants'] = count_candidat_session($user['id_session']); $res[$key]['identifiant'] = utf8_encode($date_array[0] . '-' . date('W', $timestamp) . '-' . $res[$key]['rang_session']) . "|" . $user['id_session']; } foreach ($res as $line) { $reponse->rows[$i]['id'] = $line['id_session']; $reponse->rows[$i]['cell'] = array($line['identifiant'], $line['date_session'], $line['rang_session'], $line['libelle_court_organisme'], $line['duree_session'], $line['nb_participants'], $line['nb_candidats_max'], $line['id_session-a']); $i++; } return $reponse; }
<input type="submit" class="disabled btn-suppr " value="Supprimer" onclick="return confirm_suppr_participation()" name="suppr"/> <?php } ?> </form> <?php } else { ?> <p style="padding-left: 8px;">Aucun participant</p> <?php if (droit_acces($session['gerer_candidature'], $_SESSION['role_user'])) { ?> <?php if (count_candidat_session($page["session"]['id_session']) < $page["session"]['nb_candidats_max']) { ?> <a class="btn-info small" href="index.php?controleur=session&tache=gerer_candidature&id=<?php echo $page["session"]['id_session']; ?> ">Gérer participations</a> <?php } else { ?> <a style="pointer-events: none; cursor:default;" class="btn-info small" href="#">La session est pleine</a> <?php } }
foreach ($page['sessions'] as $candidat) { ?> <li id="https_2_localhost_1_Dummy_0_rdf_3_i14207940014180488" class="node-class closed "> <a <?php $date_array = explode('-', $candidat['date_session']); $timestamp = mktime("00", "00", "01", $date_array[1], $date_array[2], $date_array[0]); $id = $date_array[0] . '-' . date('W', $timestamp) . '-' . $candidat['rang_session']; if (isset($_GET['id']) && $candidat['id_session'] == $_GET['id']) { echo 'class="clicked" '; } ?> href="index.php?controleur=session&tache=visualiser_session&id=<?php echo $candidat['id_session']; ?> " style="" class=""><ins class="session"> </ins><?php echo $id . ' ' . $candidat['code_organisme'] . ' ' . count_candidat_session($candidat['id_session']) . '/' . $candidat['nb_candidats_max']; ?> </a></li> <?php } } else { $min = date("Y-m-d", strtotime("-7 days")); $max = date("Y-m-d", strtotime("+14 days")); ?> <li class="node-class closed " style="font-style: normal; font-size: x-small;">Aucune session du <?php echo date_en_to_fr($min); ?> au <?php echo date_en_to_fr($max); ?> </li>