Add return flight booking cinematic and personal informations editing.
[Project_webapp.git] / includes / reservations.php
CommitLineData
a96fefe1
JB
1<?php
2global $is_logged_in;
3if (!$is_logged_in) {
a2f7a729 4 echo "Please login first. <br>";
22f1dc64 5 $_SESSION['login_referer'] = $_SERVER['HTTP_REFERER'];
a96fefe1 6 redirect("index.php?page=login", 2);
01135b89 7 include('footer.html');
f78b3417 8 exit();
a96fefe1
JB
9}
10?>
5b8676e8 11<h1>Mes re&#769;servations</h1>
a2f7a729
JB
12<?php
13$client_id = get_client_id($_SESSION['email']);
0a87f453 14// Add teen minutes to permit to show reservations after the end of the flight
a2f7a729 15$date_now = date('Y-m-d\TH:i', time() + 600);
0a87f453 16$oDateNow = new Datetime($date_now);
a2f7a729
JB
17global $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//var_dump($rows);
30if (empty($rows)) {
31 echo "Aucune(s) re&#769;servation(s) en cours pour le moment. <br>";
32} else {
33 echo "<table id=\"reservations\">\n";
34 echo " <tr>\n";
35 echo " <th>Nume&#769;ro de vol</th>\n";
36 echo " <th>Ville de de&#769;part</th>\n";
37 echo " <th>Date de de&#769;part</th>\n";
38 echo " <th>Ville d'arrive&#769;e</th>\n";
39 echo " <th>Date d'arrive&#769;e</th>\n";
40 echo " <th>Classe</th>\n";
41 echo " <th>Nombre de place(s)</th>\n";
42 echo " <th>Prix</th>\n";
43 echo " <th>Actions</th>\n";
44 echo " </tr>\n";
45 foreach ($rows as $row) {
0a87f453 46 $oDepartureDate = new DateTime($row['DateD']);
a2f7a729
JB
47 echo " <tr>\n";
48 echo " <td>" . $row['NumVol'] . "</td>\n";
49 echo " <td>" . $row['VilleD'] . "</td>\n";
50 echo " <td>" . $row['DateD'] . "</td>\n";
51 echo " <td>" . $row['VilleA'] . "</td>\n";
52 echo " <td>" . $row['DateA'] . "</td>\n";
53 echo " <td>" . $row['Classe'] . "</td>\n";
54 echo " <td>" . $row['NbPlaces'] . "</td>\n";
55 echo " <td>" . $row['Prix'] . "&euro;</td>\n";
0a87f453
JB
56 if ($oDepartureDate > $oDateNow) {
57 echo " <td>
58 <form action=\"index.php\" id=\"reservations\" method=\"post\">
59 <input type=\"hidden\" name=\"form\" value=\"reservations\" />
60 <input type=\"hidden\" name=\"flight_id\" value=\"" . $row['NumVol'] . "\" />
61 <input type=\"hidden\" name=\"class_name\" value=\"" . $row['Classe'] . "\" />
62 <input type=\"submit\" name=\"modify\" value=\"Modifier\">
63 <input type=\"submit\" name=\"cancel\" value=\"Annuler\">
64 </form>
65 </td>\n";
66 } else {
22f1dc64 67 echo "Vol en cours\n";
0a87f453 68 }
a2f7a729
JB
69 echo " </tr>\n";
70 }
22f1dc64 71 echo "</table>\n";
a2f7a729
JB
72}
73?>