From: Jérôme Benoit Date: Thu, 18 Jan 2018 16:21:18 +0000 (+0100) Subject: Add return flight booking cinematic and personal informations editing. X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=22f1dc6402dbc9a9c5d2ed2f17ef54044d35ec2a;p=Project_webapp.git Add return flight booking cinematic and personal informations editing. And fix a couple of bugs. Signed-off-by: Jérôme Benoit --- diff --git a/includes/account.php b/includes/account.php index 073d5ad..7b2c366 100644 --- a/includes/account.php +++ b/includes/account.php @@ -2,11 +2,98 @@ global $is_logged_in; if (!$is_logged_in) { echo "Please login first.
"; + $_SESSION['login_referer'] = $_SERVER['HTTP_REFERER']; redirect("index.php?page=login", 2); include('footer.html'); exit(); } -?> -

Mes informations

-

Mes réservations

+$action = filter_input(INPUT_GET, "action", FILTER_SANITIZE_STRING); + +global $connection; +$sql_pquery = "select NomCl, PrenomCl, EmailCl, NumRueCl, NomRueCl, CodePosteCl, VilleCl from CLIENTS where EmailCl = ?"; +$connection->prepare_query($sql_pquery); +$connection->prepared_query_bind_param("s", array($_SESSION['email'])); +$connection->run_prepared_query(); +$connection->get_pquery_result(); +$rows = $connection->get_result_array(); +$connection->close_prepared_query(); + +if (empty($action)) { + echo "

Mes informations

\n"; + + echo "\n"; + foreach ($rows as $row) { + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + } + echo "
Nom : " . htmlentities($row['NomCl']) . "
Prénom : " . htmlentities($row['PrenomCl']) . "
Email : " . htmlentities($row['EmailCl']) . "
Adresse :
Numéro de rue : " . htmlentities($row['NumRueCl']) . "
Rue : " . htmlentities($row['NomRueCl']) . "
Code postal : " . htmlentities($row['CodePosteCl']) . "
Ville : " . htmlentities($row['VilleCl']) . "
\n"; + + echo "| Modifier vos informations | Modifier votre mot de passe |\n"; + echo "

Mes réservations

\n"; +} elseif ($action === "modifyaccount") { + echo " +
+ + + + + + + + + + + + + + + + +
+
\n"; +} elseif ($action === "modifypassword") { + echo "Work in progress.
\n"; + redirect("index.php?page=account", 3); +} else { + echo "Unknown account action.
\n"; +} + +?> diff --git a/includes/formaccount.php b/includes/formaccount.php new file mode 100644 index 0000000..37acd6d --- /dev/null +++ b/includes/formaccount.php @@ -0,0 +1,44 @@ +" ; + $input_failure = true; +} +if (!$form_postalcode) { + echo "The postal code is not valid.
"; + $input_failure = true; +} +if (!$form_email) { + echo "The email is not valid.
"; + $input_failure = true; +} + +if (!empty($form_name) && !empty($form_firstname) && !empty($form_numstreet) && !empty($form_street) && + !empty($form_postalcode) && !empty($form_city) && !empty($form_email) && + !$input_failure) { + global $connection; + $client_id = get_client_id($_SESSION['email']); + $sql_pquery = "update CLIENTS + set NomCl = ?, PrenomCl = ?, EmailCl = ?, NumRueCl = ?, NomRueCl = ?, CodePosteCl = ?, VilleCl = ? + where NumCl = ?"; + $connection->prepare_query($sql_pquery); + $connection->prepared_query_bind_param("sssisisi", array($form_name, $form_firstname, $form_email, $form_numstreet, $form_street, $form_postalcode, $form_city, $client_id)); + $connection->run_prepared_query(); + $connection->close_prepared_query(); + echo "You've updated your personal informations, you will be redirected to your account in 3 seconds.
"; + redirect("index.php?page=account", 3); + +} else { + echo "There's a required non filled field or the input in a field do not match the required pattern.
"; + echo "Retour"; +} +?> diff --git a/includes/formbooking.php b/includes/formbooking.php index 2d47f81..be30b87 100644 --- a/includes/formbooking.php +++ b/includes/formbooking.php @@ -8,6 +8,7 @@ $form_return_flight = filter_input(INPUT_POST, "return_flight", FILTER_VALIDATE_ global $is_logged_in; if (!$is_logged_in) { echo "Please login first.
"; + $_SESSION['login_referer'] = $_SERVER['HTTP_REFERER']; redirect("index.php?page=login", 2); } @@ -23,7 +24,9 @@ if (!$form_nb_place) { $input_failure = true; } -if (!$form_return_flight) { +if (is_null($form_return_flight)) { + $form_return_flight = false; +} elseif (!$form_return_flight) { echo "Vol retour invalide.
"; $input_failure = true; } @@ -31,7 +34,7 @@ if (!$form_return_flight) { if (!$input_failure && $is_logged_in && !empty($form_nb_place) && !empty($form_class_name)) { global $connection; $client_id = get_client_id($_SESSION['email']); - $nb_booked = nb_booked($client_id, $form_flight_id); + $nb_booked = nb_booked($client_id, $form_flight_id, $form_class_name); if (!empty($nb_booked)) { echo "Vous avez déjà réservé ce vol, vous allez être redirigé vers la liste de vos réservations dans 2 secondes.
"; redirect("index.php?page=reservations", 2); @@ -54,15 +57,16 @@ if (!$input_failure && $is_logged_in && !empty($form_nb_place) && !empty($form_c $rows = $connection->get_result_array(); $connection->close_prepared_query(); foreach ($rows as $row) { - echo "(Simulation de paiement d'une réservation)
"; + echo "(Simulation de validation et paiement d'une réservation)
"; echo "Vous avez réservé et payé " . $form_nb_place . " place(s) sur le vol " .$form_flight_id . " au départ de " . $row['VilleD']. " à " . $row['DateD'] . " arrivant à " . $row['VilleA'] . " à " . $row['DateA'] . " pour un montant total de " . $form_place_price * $form_nb_place . "€.
"; } if ($form_return_flight) { - redirect("index.php?page=search", 3); - $_SESSION['current_flight_id'] = $form_flight_id; - $_SESSION['return_flight'] = $form_return_flight; + $_SESSION['return_flight_departure_city'] = $row['VilleA']; + $_SESSION['return_flight_arrival_city'] = $row['VilleD']; + $_SESSION['return_flight_departure_date'] = $row['DateA']; + redirect("index.php?page=search&action=return_flight", 3); } else { redirect("index.php?page=reservations", 3); } diff --git a/includes/formsearch.php b/includes/formsearch.php index e40ab12..66c57c9 100644 --- a/includes/formsearch.php +++ b/includes/formsearch.php @@ -4,6 +4,7 @@ $form_departure_date = filter_input(INPUT_POST, "departure_date", FILTER_SANITIZ $form_arrival_city = filter_input(INPUT_POST, "arrival_city", FILTER_SANITIZE_STRING); $form_arrival_date = filter_input(INPUT_POST, "arrival_date", FILTER_SANITIZE_STRING); $form_date_now = filter_input(INPUT_POST, "date_now", FILTER_SANITIZE_STRING); +$action = filter_input(INPUT_POST, "action", FILTER_SANITIZE_STRING); $oDepartureDate = new DateTime($form_departure_date); $oArrivalDate = new DateTime($form_arrival_date); @@ -25,7 +26,7 @@ if ($oDepartureDate < $oDateNow) { $input_failure = true; } -if ($oArrivalDate <= $oDepartureDate) { +if (!($action === "return_flight") && $oArrivalDate <= $oDepartureDate) { echo "Arrival date is before departure date.
"; $input_failure = true; } @@ -39,10 +40,11 @@ if (empty($form_arrival_date)) { ?> -

Rechercher un vol

+

Rechercher un vol

- \n"; + \n"; + if (!($action === "return_flight")) { + echo " \n"; + } + echo " \n"; + echo " + \n"; echo " \n"; } - echo ""; + echo "\n"; } } diff --git a/includes/header.php b/includes/header.php index 4dae576..13ce88c 100644 --- a/includes/header.php +++ b/includes/header.php @@ -37,7 +37,7 @@ $is_logged_in = chk_logged_in(); | Mes réservations |"; + echo "Mes réservations |\n"; } ?> diff --git a/includes/register.php b/includes/register.php index 09918a4..20ad699 100644 --- a/includes/register.php +++ b/includes/register.php @@ -15,7 +15,7 @@ - + diff --git a/includes/reservations.php b/includes/reservations.php index 15beeac..3230f34 100644 --- a/includes/reservations.php +++ b/includes/reservations.php @@ -2,6 +2,7 @@ global $is_logged_in; if (!$is_logged_in) { echo "Please login first.
"; + $_SESSION['login_referer'] = $_SERVER['HTTP_REFERER']; redirect("index.php?page=login", 2); include('footer.html'); exit(); @@ -63,10 +64,10 @@ if (empty($rows)) { \n"; } else { - echo "Vol en cours"; + echo "Vol en cours\n"; } echo " \n"; } - echo ""; + echo "\n"; } ?> diff --git a/includes/search.php b/includes/search.php index c7e761f..b35c762 100644 --- a/includes/search.php +++ b/includes/search.php @@ -1,9 +1,29 @@ -

Rechercher un vol

+ +

Rechercher un vol

- +
+ + diff --git a/index.php b/index.php index 9dc9e0b..5c12c9e 100644 --- a/index.php +++ b/index.php @@ -22,6 +22,8 @@ if (!isset($form)) { $form = ""; } +//var_dump($_SESSION); + function get_action_type() { global $is_page, $is_form; diff --git a/lib/utils.php b/lib/utils.php index 9955458..5ab99b5 100644 --- a/lib/utils.php +++ b/lib/utils.php @@ -95,12 +95,12 @@ function get_client_id($email) * @param [type] $flight_id [description] * @return [type] [description] */ -function nb_booked($client_id, $flight_id) +function nb_booked($client_id, $flight_id, $class_name) { global $connection; - $sql_pquery = "select SUM(NbPlaces) from RESERVATIONS where NumCl = ? and NumVol = ?"; + $sql_pquery = "select SUM(NbPlaces) from RESERVATIONS where NumCl = ? and NumVol = ? and Classe = ?"; $connection->prepare_query($sql_pquery); - $connection->prepared_query_bind_param("is", array($client_id, $flight_id)); + $connection->prepared_query_bind_param("iss", array($client_id, $flight_id, $class_name)); $connection->run_prepared_query(); $connection->get_pquery_result(); $row = $connection->get_result_array(); diff --git a/styles/airpolytech.css b/styles/airpolytech.css index fbbb3cc..c425d29 100644 --- a/styles/airpolytech.css +++ b/styles/airpolytech.css @@ -60,14 +60,14 @@ label { text-align: right; } -label + input { +label+input { 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 input */ margin: 0 30% 0 4%; } -label + select { +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 */ @@ -76,13 +76,18 @@ label + select { /* 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 { +input+input { float: right; } table { margin: 0px auto; width: 100%; + vertical-align: middle; +} + +table#account { + width: 40%; } table#home {