Commit 5aaa2b1bc321b57c23e56c07991d7d53925ccbbd

Authored by lwadbled
1 parent c1606691

feat(gestionReservation.php): Ajout de la gestion des reservations par l'administrateur

Showing 2 changed files with 125 additions and 0 deletions   Show diff stats
html/gestionReservation.php 0 → 100644
... ... @@ -0,0 +1,122 @@
  1 +<!DOCTYPE html>
  2 +<html>
  3 + <head>
  4 + <meta charset="utf-8"/>
  5 + <title>Gestion des reservations</title>
  6 + <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css"
  7 + rel="stylesheet"
  8 + integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x"
  9 + crossorigin="anonymous">
  10 + <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js"
  11 + integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//E1J19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4"
  12 + crossorigin="anonymous">
  13 + </script>
  14 + </head>
  15 + <body>
  16 + <form method="POST" action="menu.php">
  17 + <button class="btn-lg btn-secondary" type="submit">Retour au menu</button>
  18 + </form>
  19 + <?php
  20 + session_start();
  21 + if(isset($_SESSION['identifiant'])){
  22 + $identifiant = $_SESSION['identifiant'];
  23 + }else{
  24 + echo "<meta http-equiv=\"refresh\" content=\"0;url=index.html\">";
  25 + }
  26 + include("connexion.php");
  27 + $requete = "SELECT * FROM banc ORDER BY numero";
  28 + $exec_requete = mysqli_query($db,$requete);
  29 + $reponse = mysqli_fetch_all($exec_requete);
  30 + if(isset($_POST['txtDate']) && isset($_POST['banc'])){
  31 + $txtDate = $_POST['txtDate'];
  32 + $banc = $_POST['banc'];
  33 + }else{
  34 + $txtDate = date("Y-n-j");
  35 + $banc = $reponse[0][0];
  36 + /* Verification de la syntaxe de la date */
  37 + $explosion_date = explode("-",$txtDate);
  38 + $jour = $explosion_date[2];
  39 + if($jour<10){
  40 + $jour = "0$jour";
  41 + $mois = $explosion_date[1];
  42 + $annee = $explosion_date[0];
  43 + $txtDate = "$annee-$mois-$jour";
  44 + }
  45 + }
  46 + ?>
  47 +
  48 + <form method="POST" action="gestionReservation.php">
  49 + <div class="text-center">
  50 + <input type="date" name="txtDate" id="txtDate" onchange="this.form.submit();" <?php echo "value=\"$txtDate\""; ?> required>
  51 + </div>
  52 +
  53 + <div class="text-center" style="padding-left: 40rem!important; padding-right: 40rem!important;">
  54 + Banc choisi :
  55 + <select class="form-select" name="banc" id="banc" onchange="this.form.submit();" required>
  56 + <?php
  57 + foreach($reponse as $value){
  58 + echo '<option value="'.$value[0].'"';
  59 + if($banc==$value[0]){
  60 + echo "selected";
  61 + }
  62 + echo '>'.$value[0].'</option>';
  63 + }
  64 + ?>
  65 + </select>
  66 + </div>
  67 + </form>
  68 + <div class="text-center">
  69 + <?php
  70 + $requete = "SELECT * FROM reservation";
  71 + $exec_requete = mysqli_query($db,$requete);
  72 + $reponse = mysqli_fetch_all($exec_requete);
  73 + /* Affichage des reservations */
  74 + echo "<table class='table table-striped'>";
  75 + echo "<thead>";
  76 + echo "<tr>";
  77 + echo "<th>Heure de début</th>";
  78 + echo "<th>Reservé par</th>";
  79 + echo "<th></th>";
  80 + echo "</tr>";
  81 + echo "</thead>";
  82 + echo "<tbody>";
  83 + for($i=0;$i<24;$i++){
  84 + if($i<10){
  85 + $heure = "0".$i.":00";
  86 + }else{
  87 + $heure = $i.":00";
  88 + }
  89 + echo "<tr>";
  90 + echo "<td>$heure</td>";
  91 + /* Requete pour connaitre l'utilisateur reservant le creneau s'il y en a un */
  92 + /* Reecriture de la date */
  93 + $explosion_date = explode("-",$txtDate);
  94 + $jour = $explosion_date[2];
  95 + $mois = $explosion_date[1];
  96 + $annee = $explosion_date[0];
  97 + $new_date = "$jour/$mois/$annee";
  98 + /* Fin reecriture date */
  99 + $requete = "SELECT personne FROM reservation WHERE moment='$new_date' AND reserve=$banc AND HEUREDEBUT='$heure'";
  100 + $exec_requete = mysqli_query($db,$requete);
  101 + $reponse = mysqli_fetch_all($exec_requete);
  102 + echo "<td>".$reponse[0][0]."</td>";
  103 + if($reponse[0][0]==""){
  104 + /* TODO : Bonnes redirections vers les bons fichiers */
  105 + echo "<td><form method='POST' action='supprAppareil.php'><button class='btn-lg btn-danger' type='submit'>Bloquer le créneau</button></form>";
  106 + }else if($reponse[0][0]=="admin"){
  107 + echo "<td><form method='POST' action='supprAppareil.php'><button class='btn-lg btn-success' type='submit'>Débloquer le créneau</button></form>";
  108 + }else{
  109 + echo "<td><form method='POST' action='supprAppareil.php'><button class='btn-lg btn-danger' type='submit'>Supprimer et bloquer le créneau</button></form>";
  110 + }
  111 + echo "</tr>";
  112 + }
  113 + echo "</tbody>";
  114 + echo "</table>";
  115 + echo "</form>";
  116 + mysqli_close($db);
  117 + ?>
  118 + </div>
  119 + </body>
  120 +</html>
  121 +
  122 +
... ...
html/menu.php
... ... @@ -46,6 +46,9 @@
46 46 echo "<form method='POST' action='gestionAppareil.php'>";
47 47 echo "<button class='btn-lg btn-warning' type='submit'>Gestion des appareils</button>";
48 48 echo "</form>";
  49 + echo "<form method='POST' action='gestionReservation.php'>";
  50 + echo "<button class='btn-lg btn-warning' type='submit'>Gestion des reservations</button>";
  51 + echo "</form>";
49 52 }
50 53 ?>
51 54 </div>
... ...