Commit d35ea2bea07bfda7a09ffabc324c5fd567a3c0fc
1 parent
13809968
feat(main.php): Ajout de la deconnexion immédiate lors de la fin du créneau
Showing
2 changed files
with
21 additions
and
8 deletions
Show diff stats
html/main.php
@@ -30,11 +30,13 @@ | @@ -30,11 +30,13 @@ | ||
30 | <?php | 30 | <?php |
31 | /* Recuperation de l'adresse IP, du type et du nom de l'appareil choisi */ | 31 | /* Recuperation de l'adresse IP, du type et du nom de l'appareil choisi */ |
32 | include("connexion.php"); | 32 | include("connexion.php"); |
33 | - if(isset($_POST['banc'])){ | 33 | + if(isset($_POST['banc']) && isset($_POST['heure'])){ |
34 | /* Methode POST quand on vient des réservations */ | 34 | /* Methode POST quand on vient des réservations */ |
35 | + $heure=$_POST['heure']; | ||
35 | $number=0; | 36 | $number=0; |
36 | $Banc = $_POST['banc']; | 37 | $Banc = $_POST['banc']; |
37 | $_SESSION['banc']=$Banc; | 38 | $_SESSION['banc']=$Banc; |
39 | + $_SESSION['heure']=$heure; | ||
38 | $requete = "SELECT * FROM equipement WHERE | 40 | $requete = "SELECT * FROM equipement WHERE |
39 | num = $Banc"; | 41 | num = $Banc"; |
40 | $exec_requete = mysqli_query($db,$requete); | 42 | $exec_requete = mysqli_query($db,$requete); |
@@ -48,19 +50,20 @@ | @@ -48,19 +50,20 @@ | ||
48 | $Appareil[$number-1]['type'] = $type; | 50 | $Appareil[$number-1]['type'] = $type; |
49 | $Appareil[$number-1]['adresse'] = $adresse; | 51 | $Appareil[$number-1]['adresse'] = $adresse; |
50 | } | 52 | } |
51 | - }else if(isset($_SESSION['App'])){ | 53 | + }else if(isset($_SESSION['banc']) && isset($_SESSION['heure'])){ |
52 | /* Session (quand on vient de la page main) */ | 54 | /* Session (quand on vient de la page main) */ |
53 | $number = 0; | 55 | $number = 0; |
54 | $Banc = $_SESSION['banc']; | 56 | $Banc = $_SESSION['banc']; |
57 | + $heure = $_SESSION['heure']; | ||
55 | $requete = "SELECT * FROM equipement WHERE | 58 | $requete = "SELECT * FROM equipement WHERE |
56 | num =$Banc"; | 59 | num =$Banc"; |
57 | $exec_requete = mysqli_query($db,$requete); | 60 | $exec_requete = mysqli_query($db,$requete); |
58 | $reponse = mysqli_fetch_all($exec_requete); | 61 | $reponse = mysqli_fetch_all($exec_requete); |
59 | - foreach($App as $element){ | 62 | + foreach($reponse as $element){ |
60 | $number++; | 63 | $number++; |
61 | - $nom = $donnees[2]; | ||
62 | - $type = $donnees[3]; | ||
63 | - $adresse = $donnees[1]; | 64 | + $nom = $element[2]; |
65 | + $type = $element[3]; | ||
66 | + $adresse = $element[1]; | ||
64 | $Appareil[$number-1]['nom'] = $nom; | 67 | $Appareil[$number-1]['nom'] = $nom; |
65 | $Appareil[$number-1]['type'] = $type; | 68 | $Appareil[$number-1]['type'] = $type; |
66 | $Appareil[$number-1]['adresse'] = $adresse; | 69 | $Appareil[$number-1]['adresse'] = $adresse; |
@@ -78,6 +81,7 @@ | @@ -78,6 +81,7 @@ | ||
78 | echo "Nom : ".$nom."<br/>"; | 81 | echo "Nom : ".$nom."<br/>"; |
79 | echo "Adresse : ".$adresse."<br/>"; | 82 | echo "Adresse : ".$adresse."<br/>"; |
80 | echo 'Type : '.$type.'<br/>'; | 83 | echo 'Type : '.$type.'<br/>'; |
84 | + echo "Heure = $heure"; | ||
81 | echo "<br/>"; | 85 | echo "<br/>"; |
82 | } | 86 | } |
83 | 87 | ||
@@ -123,8 +127,16 @@ | @@ -123,8 +127,16 @@ | ||
123 | ?> | 127 | ?> |
124 | <script type="text/javascript"> | 128 | <script type="text/javascript"> |
125 | function quitter(){ | 129 | function quitter(){ |
126 | - <?php //TODO : Faire un truc pour des hcoses ?> | ||
127 | - } | 130 | + var horaire = new Date(); |
131 | + var time = horaire.getHours(); | ||
132 | + var heure_reserve = <?php echo "'$heure'" ?>; | ||
133 | + var valHeure = heure_reserve.split(":"); | ||
134 | + var vraieHeure = valHeure[0]; | ||
135 | + if(time>vraieHeure){ | ||
136 | + alert("Votre creneau est terminé, vous allez être redirigé."); | ||
137 | + window.location.href = "menu.php"; | ||
138 | + } | ||
139 | + }; | ||
128 | window.onload = function(){ | 140 | window.onload = function(){ |
129 | setInterval(quitter,1000); | 141 | setInterval(quitter,1000); |
130 | }; | 142 | }; |
html/mesReservations.php
@@ -47,6 +47,7 @@ | @@ -47,6 +47,7 @@ | ||
47 | echo "</form>"; | 47 | echo "</form>"; |
48 | /* Utilisation pour accès aux reservations */ | 48 | /* Utilisation pour accès aux reservations */ |
49 | echo "<form method='POST' action='main.php'>"; | 49 | echo "<form method='POST' action='main.php'>"; |
50 | + echo "<input type='hidden' name='heure' value='$creneau[3]'>"; | ||
50 | date_default_timezone_set('Europe/Paris'); | 51 | date_default_timezone_set('Europe/Paris'); |
51 | $ActualDate = date("d/m/Y",time()); | 52 | $ActualDate = date("d/m/Y",time()); |
52 | if($ActualDate==$creneau[1]){ | 53 | if($ActualDate==$creneau[1]){ |