+<?php
+$client_id = get_client_id($_SESSION['email']);
+// 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
+ join DEFCLASSES on DEFCLASSES.NumVol = VOLS.NumVol and RESERVATIONS.Classe = DEFCLASSES.Classe
+ where NumCl = ? and DateD > ?
+ order by DateD, NumVol, Prix";
+$connection->prepare_query($sql_pquery);
+$connection->prepared_query_bind_param("is", array($client_id, $date_now));
+$connection->run_prepared_query();
+$connection->get_pquery_result();
+$rows = $connection->get_result_array();
+$connection->close_prepared_query();
+if (empty($rows)) {
+ echo "Aucune(s) réservation(s) en cours pour le moment. <br>";
+} else {
+ echo "<table id=\"reservations\">\n";
+ echo " <tr>\n";
+ echo " <th>Numéro de vol</th>\n";
+ echo " <th>Ville de départ</th>\n";
+ echo " <th>Date de départ</th>\n";
+ echo " <th>Ville d'arrivée</th>\n";
+ echo " <th>Date d'arrivée</th>\n";
+ echo " <th>Classe</th>\n";
+ echo " <th>Nombre de place(s)</th>\n";
+ echo " <th>Prix</th>\n";
+ 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['DateD'] . "</td>\n";
+ echo " <td>" . $row['VilleA'] . "</td>\n";
+ echo " <td>" . $row['DateA'] . "</td>\n";
+ echo " <td>" . $row['Classe'] . "</td>\n";
+ echo " <td>" . $row['NbPlaces'] . "</td>\n";
+ echo " <td>" . $row['Prix'] . "€</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=\"button\" name=\"modify\" value=\"Modifier\" onClick=\"location.href='index.php?page=modify&flight_id=" . $row['NumVol'] . "&class_name=" . $row['Classe'] . "';\">
+ <input type=\"button\" name=\"cancel\" value=\"Annuler\" onClick=\"ConfirmCancelFlight()\">
+ </form>
+ </td>\n";
+ } else {
+ echo "Vol en cours\n";
+ }
+ echo " </tr>\n";
+ }
+ echo "</table>\n";
+}
+?>