'reservations',
'booking',
'search',
- 'account'
+ 'account',
+ 'modify'
)
);
--- /dev/null
+<?php
+$form_flight_id = filter_input(INPUT_POST, "flight_id", FILTER_SANITIZE_STRING);
+$form_nb_place = filter_input(INPUT_POST, "nb_place", FILTER_VALIDATE_INT);
+$form_class_name = filter_input(INPUT_POST, "class_name", FILTER_SANITIZE_STRING);
+
+global $connection;
+$client_id = get_client_id($_SESSION['email']);
+$sql_pquery = "update RESERVATIONS
+ set NbPlaces = ?, Classe = ?
+ where NumCl = ? and NumVol = ?";
+$connection->prepare_query($sql_pquery);
+$connection->prepared_query_bind_param("isis", array($form_nb_place, $form_class_name, $client_id, $form_flight_id));
+$connection->run_prepared_query();
+$connection->close_prepared_query();
+echo "Modifications enregistrées. <br>";
+redirect("index.php?page=reservations", 3);
+?>
<?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)) {
+if (isset($form_cancel) && isset($form_flight_id) && isset($form_class_name)) {
$client_id = get_client_id($_SESSION['email']);
global $connection;
$sql_pquery = "delete from RESERVATIONS
--- /dev/null
+<?php
+$flight_id = filter_input(INPUT_GET, "flight_id", FILTER_SANITIZE_STRING);
+$class_name = filter_input(INPUT_GET, "class_name", FILTER_SANITIZE_STRING);
+$client_id = get_client_id($_SESSION['email']);
+echo "<h1> Modification de la réservation sur le vol $flight_id</h2>\n";
+global $connection;
+$sql_pquery = "select NumCl, NumVol, Classe, NbPlaces
+ from RESERVATIONS
+ where NumCl = ? and NumVol = ? and Classe = ?";
+$connection->prepare_query($sql_pquery);
+$connection->prepared_query_bind_param("iss", array($client_id, $flight_id, $class_name));
+$connection->run_prepared_query();
+$connection->get_pquery_result();
+$rows = $connection->get_result_array();
+$connection->close_prepared_query();
+?>
+<form action="index.php" id="modify" method="post">
+ <input type="hidden" name="form" value="modify" />
+ <input type="hidden" name="flight_id" value="<?php echo $rows[0]['NumVol'] ?>" />
+ <label> Nombre de place(s) : </label>
+ <input type="number" name="nb_place" min="1" max="9" value="<?php echo $rows[0]['NbPlaces'] ?>" required/>
+ <label> Classe : </label>
+ <select size="1" name="class_name" required>
+ <optgroup label="Sélectionner une classe">
+ <?php
+ $sql_pquery = "select distinct Classe from DEFCLASSES where NumVol = ?";
+ global $connection;
+ $connection->prepare_query($sql_pquery);
+ $connection->prepared_query_bind_param("s", array($flight_id));
+ $connection->run_prepared_query();
+ $connection->get_pquery_result();
+ $classes = $connection->get_result_array();
+ $connection->close_prepared_query();
+ foreach ($classes as $class) {
+ if (strcmp($class[0], $rows[0]['Classe']) === 0) {
+ echo "<option value=\"$class[0]\" selected>$class[0]</option>\n";
+ } else {
+ echo "<option value=\"$class[0]\">$class[0]</option>\n";
+ }
+ }
+ ?>
+ </optgroup>
+ </select>
+ <input type="submit" value="Valider">
+</form>
<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=\"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";
function ConfirmCancelFlight() {
var oFormObject = document.forms['reservations'];
- if (confirm("Voulez-vous vraiment annuler votre réservation sur le vol " + oFormObject.elements['flight_id'].value + " ?")) {
+ if (confirm("Voulez-vous vraiment annuler votre réservation sur le vol " + oFormObject.elements['flight_id'].value + " ?")) {
var input = document.createElement("input");
input.setAttribute("type", "hidden");
input.setAttribute("name", "cancel");