// on efface d'eventuel session restante unset($_SESSION['resa']); // on garde l'url d'origine pour la redirection a la fin de l'enregistrement de la resa $_SESSION['resa']['url'] = $_SERVER['REQUEST_URI']; // on stocke la date du jour de la resa $_SESSION['resa']['date'] = $annee . "-" . $mois . "-" . $jour; $row = getHoraire($dayNum, $epn); $table = getPlanning($_SESSION['resa']['date'], $row["hor1_begin_horaire"], $row["hor1_end_horaire"], $row["hor2_begin_horaire"], $row["hor2_end_horaire"], $epn, $salle); if ($table != FALSE) { // affichage du planning echo $table; echo '</div></div>'; // fin du cadre avec les plages horaires et planning // Affichage des reservations par utilisateur pour les admins if ($_SESSION['status'] == 3 or $_SESSION['status'] == 4) { $resultresa = getResa('All', $_SESSION['resa']['date'], $salle); ?> <div class="box box-info"><div class="box-header"><h3 class="box-title">Réservation par utilisateur</h3></div> <div class="box-body no-padding"><table class="table table-condensed"> <thead><tr> <th></th> <th>Nom de l'adhérent</th> <th>Machine</th> <th >Début</th> <th >Fin</th> <th>Durée </th> <th > </th></tr></thead> <tbody> <?php while ($rowresa = mysqli_fetch_array($resultresa)) {
function getPlanning($dotd, $h1begin, $h1end, $h2begin, $h2end, $epn, $salle) { if ($h1begin == 0 and $h2begin > 0) { $h1begin = $h2begin; } if ($h2end == 0 and $h1begin > 0) { $h2end = $h1end; } if ($h1begin == 0 and $h2end == 0) { return FALSE; exit; } // Initialisation des variables $graf = ""; $unit = getConfig("unit_config", "unit_default_config", $epn); // unité dans la table config $unitLabel = 30; // echelle de division du temps pour les labels des heures $h1begin = floor($h1begin / 60) * 60; // on recupere l"heure de debut ex : 9h15 =>9h => 540mn if ($h2end != floor($h2end / 60) * 60) { $h2end = floor($h2end / 60) * 60 + 60; } // on recupere l"heure de fin ex : 19h15 =>20h $nbTotM = $h2end - $h1begin; // nombre total de minute d'ouverture $widthPause = getWidth($h2begin - $h1end, $nbTotM, $unit) * (60 / $unit); $positionPause = getPosition($h1end, $h1begin, getWidthPerUnit($nbTotM, $unit)) * (60 / $unit); // selection des machines par salle $result = getAllMaterielDispo($salle); // affichage du resultat if (mysqli_num_rows($result) < 1) { $graf = "Aucun ordinateur dans la salle sélectionée, veuillez choisir une autre salle"; } else { // Creation du tableau $graf .= "<table class=\"table table-condensed\">"; // ligne des horaires - echelle au dessus des reservations $graf .= "<tr><td></td><td >"; for ($i = 0; $i < $nbTotM / $unitLabel; $i++) { if ($i == $nbTotM / $unitLabel - 1) { $largeur = getWidth(60, $nbTotM, $unitLabel) - 2; if (strlen(getTime($h1begin + $i * $unitLabel)) <= 3) { $graf .= "<div class=\"labelHor\" style=\"width:" . $largeur . "%;\">|" . getTime($h1begin + $i * $unitLabel) . "</div>"; } else { $graf .= "<div class=\"labelHor1\" style=\"width:" . $largeur . "%;\">|30</div>"; } } else { $time = getTime($h1begin + $i * $unitLabel); if (strlen(getTime($h1begin + $i * $unitLabel)) <= 3) { $graf .= "<div class=\"labelHor\" style=\"width:" . getWidth(60, $nbTotM, $unitLabel) . "%;\">|" . $time . "</div>"; } else { $graf .= "<div class=\"labelHor1\" style=\"width:" . getWidth(60, $nbTotM, $unitLabel) . "%;\">|30</div>"; } } } $graf .= "</td></tr>"; //affichage des machines + liste des reservations while ($row = mysqli_fetch_array($result)) { //old function affichage par usage// if ($row['NB'] == "") { $nbCritere = ''; } else { $nbCritere = ' (' . $row['NB'] . ')'; } /// if (strtotime($dotd) < strtotime(date("Y-m-d"))) { $graf .= "<tr><td class=\"computer\" >" . $row["nom_computer"] . "</td>\n <td class=\"horaire\">"; } else { /*if(COUNT($usage)==$row['NB']) // si la recherche est exacte { $graf .= "<tr><td class=\"computer2\"><a href=\"index.php?m=7&idepn=".$epn."&idcomp=".$row["id_computer"]."&nomcomp=".$row["nom_computer"]."&date=".$dotd."\">".$row["nom_computer"]."".$nbCritere."</a></td> <td class=\"horaire\">" ; $lineExist = TRUE ; } else // sinon on affiche les resultats avec les autres criteres de recherche {*/ if (FALSE == checkInter($row["id_computer"])) { //si pas d'intervention $graf .= "<tr><td class=\"computer\"><a href=\"index.php?m=7&idepn=" . $epn . "&idcomp=" . $row["id_computer"] . "&nomcomp=" . $row["nom_computer"] . "&date=" . $dotd . "\">" . $row["nom_computer"] . "" . $nbCritere . "</a></td>\n <td class=\"horaire\">"; } else { $graf .= "<tr><td class=\"computer\"><span data-toggle=\"tooltip\" title=\"Une intervention est en cours sur ce poste, pas de réservation possible !\" class=\"text-red\">" . $row["nom_computer"] . "</span></td>\n <td class=\"horaire\">"; } // } } // affichage des horaires et des occupations $result2 = getResa($row["id_computer"], $dotd); $width = 0; $position = 0; $widthTmp = 0; $widthTmp2 = 0; $i = 0; while ($row2 = mysqli_fetch_array($result2)) { $i = 0; // largeur en % du div representant la resa $width = getWidth($row2["duree_resa"], $nbTotM, $unit) * (60 / $unit); // recupere la position absolue dans le tableau $positionTmp = getPosition($row2["debut_resa"], $h1begin, getWidthPerUnit($nbTotM, $unit)); // position en % du div en cours (represente l'ecart avec celui de devant) $position = ($positionTmp - $widthTmp2) * (60 / $unit) - $unit / 60 * $i; if ($position < 0) { $position = 0; } // Affichage de la ligne d'une machine; $urlGraf = "#p" . $row2["id_user_resa"]; //Ajout lien vers ancre dans la liste//$_SERVER['REQUEST_URI'] ; //."&idResa=".$row2['id_resa']; if ($_SESSION['status'] == 3 or $_SESSION['status'] == 4) { // comment d'admin et d'anim $altGraf = "(" . getUserName($row2["id_user_resa"]) . " - " . getTime($row2["debut_resa"]) . " à " . getTime($row2["debut_resa"] + $row2["duree_resa"]) . ")"; } else { // comment d'utilisateur $altGraf = "(" . getTime($row2["debut_resa"]) . " à " . getTime($row2["debut_resa"] + $row2["duree_resa"]) . ")"; } $graf .= "<div class=\"unitbusy\" style=\"width:" . $width . "%;left:" . $position . "%;\">\n <a href=\"" . $urlGraf . "\" alt=\"" . $altGraf . "\" title=\"" . $altGraf . "\">" . getTime($row2["duree_resa"]) . "</a>\n </div>"; $widthTmp = $widthTmp + $width; $widthTmp2 = $widthTmp / (60 / $unit); ++$i; //echo $position.'% = (PA:'.$positionTmp.'-W'.$widthTmp.')*(60/'.$unit.') -- width:'.$width.'% -- nbTotM:'.$nbTotM.'<br/>'; } // fin de l'affichage des horaires et des occupations $graf .= "</td></tr>"; } // ligne des horaires - echelle en dessous du tableau de reservation 2 $graf .= "<tr><td></td><td >"; for ($i = 0; $i < $nbTotM / $unitLabel; $i++) { if ($i == $nbTotM / $unitLabel - 1) { if (strlen(getTime($h1begin + $i * $unitLabel)) <= 3) { $graf .= "<div class=\"labelHor\" style=\"width:" . (getWidth(60, $nbTotM, $unitLabel) - 2) . "%;\">|" . getTime($h1begin + $i * $unitLabel) . "</div>"; } else { $graf .= "<div class=\"labelHor1\" style=\"width:" . (getWidth(60, $nbTotM, $unitLabel) - 2) . "%;\">|30</div>"; } } else { if (strlen(getTime($h1begin + $i * $unitLabel)) <= 3) { $graf .= "<div class=\"labelHor\" style=\"width:" . getWidth(60, $nbTotM, $unitLabel) . "%;\">|" . getTime($h1begin + $i * $unitLabel) . "</div>"; } else { $graf .= "<div class=\"labelHor1\" style=\"width:" . getWidth(60, $nbTotM, $unitLabel) . "%;\">|30</div>"; } } } $graf .= "</td></tr>"; $graf .= "</table>"; } return $graf; }