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 | 30 | <?php |
31 | 31 | /* Recuperation de l'adresse IP, du type et du nom de l'appareil choisi */ |
32 | 32 | include("connexion.php"); |
33 | - if(isset($_POST['banc'])){ | |
33 | + if(isset($_POST['banc']) && isset($_POST['heure'])){ | |
34 | 34 | /* Methode POST quand on vient des réservations */ |
35 | + $heure=$_POST['heure']; | |
35 | 36 | $number=0; |
36 | 37 | $Banc = $_POST['banc']; |
37 | 38 | $_SESSION['banc']=$Banc; |
39 | + $_SESSION['heure']=$heure; | |
38 | 40 | $requete = "SELECT * FROM equipement WHERE |
39 | 41 | num = $Banc"; |
40 | 42 | $exec_requete = mysqli_query($db,$requete); |
... | ... | @@ -48,19 +50,20 @@ |
48 | 50 | $Appareil[$number-1]['type'] = $type; |
49 | 51 | $Appareil[$number-1]['adresse'] = $adresse; |
50 | 52 | } |
51 | - }else if(isset($_SESSION['App'])){ | |
53 | + }else if(isset($_SESSION['banc']) && isset($_SESSION['heure'])){ | |
52 | 54 | /* Session (quand on vient de la page main) */ |
53 | 55 | $number = 0; |
54 | 56 | $Banc = $_SESSION['banc']; |
57 | + $heure = $_SESSION['heure']; | |
55 | 58 | $requete = "SELECT * FROM equipement WHERE |
56 | 59 | num =$Banc"; |
57 | 60 | $exec_requete = mysqli_query($db,$requete); |
58 | 61 | $reponse = mysqli_fetch_all($exec_requete); |
59 | - foreach($App as $element){ | |
62 | + foreach($reponse as $element){ | |
60 | 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 | 67 | $Appareil[$number-1]['nom'] = $nom; |
65 | 68 | $Appareil[$number-1]['type'] = $type; |
66 | 69 | $Appareil[$number-1]['adresse'] = $adresse; |
... | ... | @@ -78,6 +81,7 @@ |
78 | 81 | echo "Nom : ".$nom."<br/>"; |
79 | 82 | echo "Adresse : ".$adresse."<br/>"; |
80 | 83 | echo 'Type : '.$type.'<br/>'; |
84 | + echo "Heure = $heure"; | |
81 | 85 | echo "<br/>"; |
82 | 86 | } |
83 | 87 | |
... | ... | @@ -123,8 +127,16 @@ |
123 | 127 | ?> |
124 | 128 | <script type="text/javascript"> |
125 | 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 | 140 | window.onload = function(){ |
129 | 141 | setInterval(quitter,1000); |
130 | 142 | }; | ... | ... |
html/mesReservations.php
... | ... | @@ -47,6 +47,7 @@ |
47 | 47 | echo "</form>"; |
48 | 48 | /* Utilisation pour accès aux reservations */ |
49 | 49 | echo "<form method='POST' action='main.php'>"; |
50 | + echo "<input type='hidden' name='heure' value='$creneau[3]'>"; | |
50 | 51 | date_default_timezone_set('Europe/Paris'); |
51 | 52 | $ActualDate = date("d/m/Y",time()); |
52 | 53 | if($ActualDate==$creneau[1]){ | ... | ... |