From a0e7c679474abba8e61aa6241f7a5293ab631cc1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 20 Jan 2018 14:49:58 +0100 Subject: [PATCH] Fix the flight reservation with a return cinematic. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit And also fix the reservation modification code. Signed-off-by: Jérôme Benoit --- includes/formbooking.php | 1 + includes/formmodify.php | 20 +++++++++++++++----- includes/formsearch.php | 13 ++++++++++--- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/includes/formbooking.php b/includes/formbooking.php index be30b87..8699109 100644 --- a/includes/formbooking.php +++ b/includes/formbooking.php @@ -66,6 +66,7 @@ if (!$input_failure && $is_logged_in && !empty($form_nb_place) && !empty($form_c $_SESSION['return_flight_departure_city'] = $row['VilleA']; $_SESSION['return_flight_arrival_city'] = $row['VilleD']; $_SESSION['return_flight_departure_date'] = $row['DateA']; + $_SESSION['return_flight_nb_place'] = $form_nb_place; redirect("index.php?page=search&action=return_flight", 3); } else { redirect("index.php?page=reservations", 3); diff --git a/includes/formmodify.php b/includes/formmodify.php index 6b64906..a09debe 100644 --- a/includes/formmodify.php +++ b/includes/formmodify.php @@ -18,14 +18,24 @@ if (!$form_nb_place) { $input_failure = true; } -if (!$input_failure && $is_logged_in && !empty($form_nb_place) && !empty($form_class_name)) { +if (!$input_failure && $is_logged_in && !empty($form_nb_place) && !empty($form_class_name) && !empty($form_previous_class_name)) { global $connection; $client_id = get_client_id($_SESSION['email']); - $sql_pquery = "update RESERVATIONS - set NbPlaces = ?, Classe = ? - where NumCl = ? and NumVol = ? and Classe = ?"; + if (strcmp($form_class_name, $form_previous_class_name) === 0) { + $sql_pquery = "update RESERVATIONS + set NbPlaces = ? + where NumCl = ? and NumVol = ? and Classe = ?"; + } else { + $sql_pquery = "update RESERVATIONS + set NbPlaces = ?, Classe = ? + where NumCl = ? and NumVol = ? and Classe = ?"; + } $connection->prepare_query($sql_pquery); - $connection->prepared_query_bind_param("isiss", array($form_nb_place, $form_class_name, $client_id, $form_flight_id, $form_previous_class_name)); + if (strcmp($form_class_name, $form_previous_class_name) === 0) { + $connection->prepared_query_bind_param("iiss", array($form_nb_place, $client_id, $form_flight_id, $form_previous_class_name)); + } else { + $connection->prepared_query_bind_param("isiss", array($form_nb_place, $form_class_name, $client_id, $form_flight_id, $form_previous_class_name)); + } $connection->run_prepared_query(); $connection->close_prepared_query(); echo "Modifications enregistrées.
"; diff --git a/includes/formsearch.php b/includes/formsearch.php index 6bd0fa1..3c6e0ea 100644 --- a/includes/formsearch.php +++ b/includes/formsearch.php @@ -99,7 +99,8 @@ if (empty($form_arrival_date)) { = ? and VilleD = ? and DateA <= ? and VilleA = ? order by DateD, NumVol, Prix"; @@ -114,6 +115,12 @@ if (!$input_failure) { if (empty($rows)) { echo "Aucun vol ne correspond aux critères de recherche.
"; } else { + if ($action === "return_flight" && isset($_SESSION['return_flight_nb_place'])) { + $nb_places = $_SESSION['return_flight_nb_place']; + unset($_SESSION['return_flight_nb_place']); + } else { + $nb_places = 1; + } echo "\n"; echo " \n"; echo " \n"; @@ -141,9 +148,9 @@ if (!$input_failure) { - - \n"; + \n"; if (!($action === "return_flight")) { + echo " \n"; echo " \n"; } echo " \n"; -- 2.34.1
Numéro de vol