Commit 13809968203d709115505d592c7e23f145d9aec7

Authored by lwadbled
1 parent 5aaa2b1b

fix(gestionReservation.php): Correction des redirections pour ajouter/supprimer …

…des reservations par l'administrateur
html/ajoutReservation.php
... ... @@ -49,6 +49,13 @@
49 49 $requete = "INSERT INTO reservation VALUES($banc,'$date','$login','$heure','$heurefin')";
50 50 $exec_requete = mysqli_query($db,$requete);
51 51 echo "<meta http-equiv=\"refresh\" content=\"0;url=mesReservations.php\">";
  52 + }elseif(isset($_GET['txtDate']) && isset($_GET['banc']) && isset($_GET['heure'])){
  53 + $date = $_GET['txtDate'];
  54 + $banc = $_GET['banc'];
  55 + $heure = $_GET['heure'];
  56 + $requete = "INSERT INTO reservation VALUES($banc,'$date','$login','$heure','$heurefin')";
  57 + $exec_requete = mysqli_query($db,$requete);
  58 + echo "<meta http-equiv=\"refresh\" content=\"0;url=gestionReservation.php\">";
52 59 }else{
53 60 //echo "L'ajout n'a pas fonctionné";
54 61 echo "<meta http-equiv=\"refresh\" content=\"0;url=reservation.php?erreur=1\">";
... ...
html/gestionReservation.php
... ... @@ -71,6 +71,7 @@
71 71 $exec_requete = mysqli_query($db,$requete);
72 72 $reponse = mysqli_fetch_all($exec_requete);
73 73 /* Affichage des reservations */
  74 + /* TODO : Si date déjà passée = Seulement consultation */
74 75 echo "<table class='table table-striped'>";
75 76 echo "<thead>";
76 77 echo "<tr>";
... ... @@ -99,14 +100,14 @@
99 100 $requete = "SELECT personne FROM reservation WHERE moment='$new_date' AND reserve=$banc AND HEUREDEBUT='$heure'";
100 101 $exec_requete = mysqli_query($db,$requete);
101 102 $reponse = mysqli_fetch_all($exec_requete);
102   - echo "<td>".$reponse[0][0]."</td>";
  103 + $personne = $reponse[0][0];
  104 + echo "<td>$personne</td>";
103 105 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 + echo "<td><form method='POST' action='ajoutReservation.php?txtDate=$new_date&banc=$banc&heure=$heure'><button class='btn-lg btn-danger' type='submit'>Bloquer le créneau</button></form>";
106 107 }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 + echo "<td><form method='POST' action='supprReservation.php?banc=$banc&moment=$new_date&personne=$personne&heuredebut=$heure'><button class='btn-lg btn-success' type='submit'>Débloquer le créneau</button></form>";
108 109 }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 + echo "<td><form method='POST' action='supprReservation.php?banc=$banc&moment=$new_date&personne=$personne&heuredebut=$heure'><button class='btn-lg btn-warning' type='submit'>Supprimer la réservation</button></form>";
110 111 }
111 112 echo "</tr>";
112 113 }
... ...
html/mesReservations.php
... ... @@ -42,7 +42,7 @@
42 42 foreach($reponse as $creneau){
43 43 echo "<div class='px-4 py-4 my-5 text-center border-top'>";
44 44 echo "Banc : $creneau[0] | Date : $creneau[1] $creneau[3]-$creneau[4]";
45   - echo "<form method='POST' action='supprReservation.php?banc=$creneau[0]&moment=$creneau[1]&personne=$identifiant&heuredebut=$creneau[3]&heurefin=$creneau[4]'>";
  45 + echo "<form method='POST' action='supprReservation.php?banc=$creneau[0]&moment=$creneau[1]&personne=$identifiant&heuredebut=$creneau[3]'>";
46 46 echo "<button class='btn-lg btn-danger' type='submit'>Supprimer la reservation</button>";
47 47 echo "</form>";
48 48 /* Utilisation pour accès aux reservations */
... ...
html/supprReservation.php
1 1 <?php
2   -if(isset($_GET['banc']) && isset($_GET['moment']) && isset($_GET['personne']) && isset($_GET['heuredebut']) && isset($_GET['heurefin'])){
  2 +if(isset($_GET['banc']) && isset($_GET['moment']) && isset($_GET['personne']) && isset($_GET['heuredebut'])){
  3 + session_start();
  4 + if(isset($_SESSION['identifiant'])){
  5 + $identifiant = $_SESSION['identifiant'];
  6 + }
3 7 include("connexion.php");
4 8 $banc = $_GET['banc'];
5 9 $moment = $_GET['moment'];
6 10 $personne = $_GET['personne'];
7 11 $heuredebut = $_GET['heuredebut'];
8   - $heurefin = $_GET['heurefin'];
9   - $requete =
  12 + echo "Banc = $banc moment = $moment personne = $personne heuredebut = $heuredebut";
10 13 include("connexion.php");
11 14 $requete = "DELETE FROM reservation WHERE
12   - reserve=$banc and moment='$moment' and personne = '$personne' and heuredebut='$heuredebut' and heurefin='$heurefin'";
  15 + reserve=$banc and moment='$moment' and personne = '$personne' and heuredebut='$heuredebut'";
13 16 $exec_requete = mysqli_query($db,$requete);
14 17 $reponse = mysqli_fetch_array($exec_requete);
15   - echo "<meta http-equiv=\"refresh\" content=\"0;url=mesReservations.php\">";
  18 + if($identifiant=="admin"){
  19 + echo "<meta http-equiv=\"refresh\" content=\"0;url=gestionReservation.php\">";
  20 + }else{
  21 + echo "<meta http-equiv=\"refresh\" content=\"0;url=mesReservations.php\">";
  22 + }
16 23 mysqli_close($db);
17 24 }
18 25 ?>
... ...