<?php
global $is_logged_in;
if (!$is_logged_in) {
- echo "Please login first.";
+ echo "Please login first. <br>";
redirect("index.php?page=login", 2);
include('footer.html');
exit();
global $is_logged_in;
if (!$is_logged_in) {
- echo "Please login first.";
+ echo "Please login first. <br>";
redirect("index.php?page=login", 2);
}
--- /dev/null
+<?php
+$form_flight_id = filter_input(INPUT_POST, "flight_id", FILTER_SANITIZE_STRING);
+$form_class_name = filter_input(INPUT_POST, "class_name", FILTER_SANITIZE_STRING);
+$form_modify = filter_input(INPUT_POST, "modify", FILTER_SANITIZE_STRING);
+$form_cancel = filter_input(INPUT_POST, "cancel", FILTER_SANITIZE_STRING);
+
+if (isset($form_modify) && isset($form_flight_id) && isset($form_class_name)) {
+ echo $form_modify;
+} elseif (isset($form_cancel) && isset($form_flight_id) && isset($form_class_name)) {
+ //FIXME: Add a confirmation step
+ $client_id = get_client_id($_SESSION['email']);
+ global $connection;
+ $sql_pquery = "delete from RESERVATIONS
+ where NumCl = ? and NumVol = ? and Classe = ?";
+ $connection->prepare_query($sql_pquery);
+ $connection->prepared_query_bind_param("iss", array($client_id, $form_flight_id, $form_class_name));
+ $connection->run_prepared_query();
+ $connection->close_prepared_query();
+ echo "Votre réservation a été annulée. <br>";
+ redirect("index.php?page=reservations", 3);
+} else {
+ echo "Make an error message. <br>";
+}
+
+?>
<?php
-
$form_departure_city = filter_input(INPUT_POST, "departure_city", FILTER_SANITIZE_STRING);
$form_departure_date = filter_input(INPUT_POST, "departure_date", FILTER_SANITIZE_STRING);
$form_arrival_city = filter_input(INPUT_POST, "arrival_city", FILTER_SANITIZE_STRING);
$input_failure = true;
}
+if (empty($form_arrival_date)) {
+ // Limit to a 6 months interval from the departure date.
+ $oArrivalDate = $oDepartureDate;
+ $oArrivalDate->add(new DateInterval("P6M"));
+ $form_arrival_date = $oArrivalDate->format('Y-m-d\TH:i');
+}
+
?>
<h1> Rechercher un vol </h1>
<input type="hidden" name="form" value="search" />
<input type="hidden" name="date_now" value="<?php echo $form_date_now; ?>" />
<label> Départ : Ville -> </label>
- <input type="text" size="15" name="departure_city" value="<?php echo $form_departure_city; ?>" required/>
+ <select size="1" name="departure_city" required>
+ <optgroup label="Sélectionner une ville">
+ <?php
+ $sql_pquery = "select distinct VilleD from VOLS";
+ global $connection;
+ $connection->prepare_query($sql_pquery);
+ $connection->run_prepared_query();
+ $connection->get_pquery_result();
+ $cities = $connection->get_result_array();
+ $connection->close_prepared_query();
+ foreach ($cities as $city) {
+ if (strcmp($city[0], $form_departure_city) === 0) {
+ echo "<option value=\"$city[0]\" selected>$city[0]</option>\n";
+ } else {
+ echo "<option value=\"$city[0]\">$city[0]</option>\n";
+ }
+ }
+ ?>
+ </optgroup>
+ </select>
<label> Date -> </label>
<input type="datetime-local" name="departure_date" value="<?php echo $form_departure_date; ?>" required/>
<label> Arrivée : Ville -> </label>
- <input type="text" size="15" name="arrival_city" value="<?php echo $form_arrival_city; ?>" required/>
+ <select size="1" name="arrival_city" required>
+ <optgroup label="Sélectionner une ville">
+ <?php
+ $sql_pquery = "select distinct VilleA from VOLS";
+ global $connection;
+ $connection->prepare_query($sql_pquery);
+ $connection->run_prepared_query();
+ $connection->get_pquery_result();
+ $cities = $connection->get_result_array();
+ $connection->close_prepared_query();
+ foreach ($cities as $city) {
+ if (strcmp($city[0], $form_arrival_city) === 0) {
+ echo "<option value=\"$city[0]\" selected>$city[0]</option>\n";
+ } else {
+ echo "<option value=\"$city[0]\">$city[0]</option>\n";
+ }
+ }
+ ?>
+ </optgroup>
+ </select>
<label> Date -> </label>
- <input type="datetime-local" name="arrival_date" value="<?php echo $form_arrival_date; ?>" required/>
+ <input type="datetime-local" name="arrival_date" <?php if (isset($form_arrival_date)) echo "value=\"$form_arrival_date\"";?> />
<input type="submit" value="Valider">
</form>
<br>
<input type=\"number\" name=\"nb_place\" min=\"1\" max=\"9\" value=\"1\" required/>
<label> Vol retour : </label>
<input type=\"checkbox\" name=\"return_flight\" checked required/>
- <input type=\"submit\" value=\"Reserver\">
+ <input type=\"submit\" value=\"Réserver\">
</form>
</td>\n";
echo " </tr>\n";
<?php
global $is_logged_in;
if (!$is_logged_in) {
- echo "Please login first.";
+ echo "Please login first. <br>";
redirect("index.php?page=login", 2);
include('footer.html');
exit();
}
?>
<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
+$date_now = date('Y-m-d\TH:i', time() + 600);
+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();
+//var_dump($rows);
+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) {
+ 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";
+ 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";
+ echo " </tr>\n";
+ }
+ echo "</table>";
+}
+?>
<form action="index.php" id="search" method="post">
<input type="hidden" name="form" value="search" />
- <input type="hidden" name="date_now" value="<?php echo date('Y-m-d\TH:i'); ?>" />
+ <input type="hidden" name="date_now" value="<?php echo date('Y-m-d\TH:i', time() - 600); ?>" />
<label> Départ : Ville -> </label>
- <input type="text" size="15" name="departure_city" required/>
+ <select size="1" name="departure_city" required>
+ <optgroup label="Sélectionner une ville">
+ <?php
+ $sql_pquery = "select distinct VilleD from VOLS";
+ global $connection;
+ $connection->prepare_query($sql_pquery);
+ $connection->run_prepared_query();
+ $connection->get_pquery_result();
+ $cities = $connection->get_result_array();
+ $connection->close_prepared_query();
+ foreach ($cities as $city) {
+ echo "<option value=\"$city[0]\">$city[0]</option>\n";
+ }
+ ?>
+ </optgroup>
+ </select>
<label> Date -> </label>
<input type="datetime-local" name="departure_date" value="<?php echo date('Y-m-d\TH:i'); ?>" required/>
<label> Arrivée : Ville -> </label>
- <input type="text" size="15" name="arrival_city" required/>
+ <select size="1" name="arrival_city" required>
+ <optgroup label="Sélectionner une ville">
+ <?php
+ $sql_pquery = "select distinct VilleA from VOLS";
+ global $connection;
+ $connection->prepare_query($sql_pquery);
+ $connection->run_prepared_query();
+ $connection->get_pquery_result();
+ $cities = $connection->get_result_array();
+ $connection->close_prepared_query();
+ foreach ($cities as $city) {
+ echo "<option value=\"$city[0]\">$city[0]</option>\n";
+ }
+ ?>
+ </optgroup>
+ </select>
<label> Date -> </label>
- <input type="datetime-local" name="arrival_date" value="<?php echo date('Y-m-d\TH:i', time() + 86400); ?>" required/>
+ <input type="datetime-local" name="arrival_date" />
<input type="submit" value="Valider">
</form>
<br>
width: 250px;
}
-label, input {
+form#reservations {
+ width: 130px;
+}
+
+label, input, select {
/* in order to define widths */
display: inline-block;
}
margin: 0 30% 0 4%;
}
+label + select {
+ width: 30%;
+ /* large margin-right to force the next element to the new-line
+ and margin-left to create a gutter between the label and select */
+ margin: 0 30% 0 4%;
+}
+
/* only the submit button is matched by this selector,
but to be sure you could use an id or class for that button */
input + input {
background-color: #474343;
}
+table#reservations {
+ border: none;
+}
+
+table#reservations tr:nth-child(even) {
+ background-color: #675b5b;
+}
+
+table#reservations tr:nth-child(odd) {
+ background-color: #474343;
+}
+
#header {
font-size: 4em;
text-align: center;