if (!empty($nb_booked)) {
echo "Vous avez déjà réservé ce vol, vous allez être redirigé vers la liste de vos réservations dans 2 secondes. <br>";
redirect("index.php?page=reservations", 2);
+ include('footer.html');
+ exit();
}
$sql_pquery = "insert into RESERVATIONS (NumCl, NumVol, Classe, NbPlaces)
values (?, ?, ?, ?)";
<h1>Mes réservations</h1>
<?php
$client_id = get_client_id($_SESSION['email']);
-//Add teen minutes to permit to show reservations after the end of the flight
+// Add teen minutes to permit to show reservations after the end of the flight
$date_now = date('Y-m-d\TH:i', time() + 600);
+$oDateNow = new Datetime($date_now);
global $connection;
$sql_pquery = "select RESERVATIONS.NumVol as NumVol, VilleD, DateD, VilleA, DateA, RESERVATIONS.Classe, NbPlaces, round(CoutVol*CoeffPrix*NbPlaces, 2) as Prix
from RESERVATIONS join VOLS on RESERVATIONS.NumVol = VOLS.NumVol
echo " <th>Actions</th>\n";
echo " </tr>\n";
foreach ($rows as $row) {
+ $oDepartureDate = new DateTime($row['DateD']);
echo " <tr>\n";
echo " <td>" . $row['NumVol'] . "</td>\n";
echo " <td>" . $row['VilleD'] . "</td>\n";
echo " <td>" . $row['Classe'] . "</td>\n";
echo " <td>" . $row['NbPlaces'] . "</td>\n";
echo " <td>" . $row['Prix'] . "€</td>\n";
- echo " <td>
- <form action=\"index.php\" id=\"reservations\" method=\"post\">
- <input type=\"hidden\" name=\"form\" value=\"reservations\" />
- <input type=\"hidden\" name=\"flight_id\" value=\"" . $row['NumVol'] . "\" />
- <input type=\"hidden\" name=\"class_name\" value=\"" . $row['Classe'] . "\" />
- <input type=\"submit\" name=\"modify\" value=\"Modifier\">
- <input type=\"submit\" name=\"cancel\" value=\"Annuler\">
- </form>
- </td>\n";
+ if ($oDepartureDate > $oDateNow) {
+ echo " <td>
+ <form action=\"index.php\" id=\"reservations\" method=\"post\">
+ <input type=\"hidden\" name=\"form\" value=\"reservations\" />
+ <input type=\"hidden\" name=\"flight_id\" value=\"" . $row['NumVol'] . "\" />
+ <input type=\"hidden\" name=\"class_name\" value=\"" . $row['Classe'] . "\" />
+ <input type=\"submit\" name=\"modify\" value=\"Modifier\">
+ <input type=\"submit\" name=\"cancel\" value=\"Annuler\">
+ </form>
+ </td>\n";
+ } else {
+ echo "Vol en cours";
+ }
echo " </tr>\n";
}
echo "</table>";