| 1 | <?php |
| 2 | global $is_logged_in; |
| 3 | if (!$is_logged_in) { |
| 4 | echo "Please login first. <br>"; |
| 5 | $_SESSION['login_referer'] = $_SERVER['HTTP_REFERER']; |
| 6 | redirect("index.php?page=login", 2); |
| 7 | include('footer.html'); |
| 8 | exit(); |
| 9 | } |
| 10 | ?> |
| 11 | <h1>Mes réservations</h1> |
| 12 | <?php |
| 13 | $client_id = get_client_id($_SESSION['email']); |
| 14 | // Add teen minutes to permit to show reservations after the end of the flight |
| 15 | $date_now = date('Y-m-d\TH:i', time() + 600); |
| 16 | $oDateNow = new Datetime($date_now); |
| 17 | global $connection; |
| 18 | $sql_pquery = "select RESERVATIONS.NumVol as NumVol, VilleD, DateD, VilleA, DateA, RESERVATIONS.Classe, NbPlaces, round(CoutVol*CoeffPrix*NbPlaces, 2) as Prix |
| 19 | from RESERVATIONS join VOLS on RESERVATIONS.NumVol = VOLS.NumVol |
| 20 | join DEFCLASSES on DEFCLASSES.NumVol = VOLS.NumVol and RESERVATIONS.Classe = DEFCLASSES.Classe |
| 21 | where NumCl = ? and DateD > ? |
| 22 | order by DateD, NumVol, Prix"; |
| 23 | $connection->prepare_query($sql_pquery); |
| 24 | $connection->prepared_query_bind_param("is", array($client_id, $date_now)); |
| 25 | $connection->run_prepared_query(); |
| 26 | $connection->get_pquery_result(); |
| 27 | $rows = $connection->get_result_array(); |
| 28 | $connection->close_prepared_query(); |
| 29 | if (empty($rows)) { |
| 30 | echo "Aucune(s) réservation(s) en cours pour le moment. <br>"; |
| 31 | } else { |
| 32 | echo "<table id=\"reservations\">\n"; |
| 33 | echo " <tr>\n"; |
| 34 | echo " <th>Numéro de vol</th>\n"; |
| 35 | echo " <th>Ville de départ</th>\n"; |
| 36 | echo " <th>Date de départ</th>\n"; |
| 37 | echo " <th>Ville d'arrivée</th>\n"; |
| 38 | echo " <th>Date d'arrivée</th>\n"; |
| 39 | echo " <th>Classe</th>\n"; |
| 40 | echo " <th>Nombre de place(s)</th>\n"; |
| 41 | echo " <th>Prix</th>\n"; |
| 42 | echo " <th>Actions</th>\n"; |
| 43 | echo " </tr>\n"; |
| 44 | foreach ($rows as $row) { |
| 45 | $oDepartureDate = new DateTime($row['DateD']); |
| 46 | echo " <tr>\n"; |
| 47 | echo " <td>" . $row['NumVol'] . "</td>\n"; |
| 48 | echo " <td>" . $row['VilleD'] . "</td>\n"; |
| 49 | echo " <td>" . $row['DateD'] . "</td>\n"; |
| 50 | echo " <td>" . $row['VilleA'] . "</td>\n"; |
| 51 | echo " <td>" . $row['DateA'] . "</td>\n"; |
| 52 | echo " <td>" . $row['Classe'] . "</td>\n"; |
| 53 | echo " <td>" . $row['NbPlaces'] . "</td>\n"; |
| 54 | echo " <td>" . $row['Prix'] . "€</td>\n"; |
| 55 | if ($oDepartureDate > $oDateNow) { |
| 56 | echo " <td> |
| 57 | <form action=\"index.php\" id=\"reservations\" method=\"post\"> |
| 58 | <input type=\"hidden\" name=\"form\" value=\"reservations\" /> |
| 59 | <input type=\"hidden\" name=\"flight_id\" value=\"" . $row['NumVol'] . "\" /> |
| 60 | <input type=\"hidden\" name=\"class_name\" value=\"" . $row['Classe'] . "\" /> |
| 61 | <input type=\"submit\" name=\"modify\" value=\"Modifier\"> |
| 62 | <input type=\"button\" name=\"cancel\" value=\"Annuler\" onClick=\"ConfirmCancelFlight()\"> |
| 63 | </form> |
| 64 | </td>\n"; |
| 65 | } else { |
| 66 | echo "Vol en cours\n"; |
| 67 | } |
| 68 | echo " </tr>\n"; |
| 69 | } |
| 70 | echo "</table>\n"; |
| 71 | } |
| 72 | ?> |