X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=includes%2Fformsearch.php;h=dc682dafb80803829b58db91d0d27805ab9853e2;hb=e14003dc40dec3eb928a58cdff78fddd31990907;hp=7796f0691ae75452042e1ee02ae7906e228a46bf;hpb=a2f7a7290d0b54650c249a0bf59e66d8d7691135;p=Project_webapp.git
diff --git a/includes/formsearch.php b/includes/formsearch.php
index 7796f06..dc682da 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,16 +40,17 @@ if (empty($form_arrival_date)) {
?>
-
Numéro de vol | \n"; - echo "Ville de départ | \n"; - echo "Date de départ | \n"; - echo "Ville d'arrivée | \n"; - echo "Date d'arrivée | \n"; - echo "Classe | \n"; - echo "Prix d'une place | \n"; - echo "Réserver | \n"; - echo "||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
" . $row['NumVol'] . " | \n"; - echo "" . $row['VilleD'] . " | \n"; - echo "" . $row['DateD'] . " | \n"; - echo "" . $row['VilleA'] . " | \n"; - echo "" . $row['DateA'] . " | \n"; - echo "" . $row['Classe'] . " | \n"; - echo "" . $row['Prix'] . "€ | \n"; - echo "
+ global $connection;
+ $sql_pquery = "select VOLS.NumVol as NumVol, VilleD, DateD, VilleA, DateA, DEFCLASSES.Classe, round(CoutVol*CoeffPrix, 2) as Prix, CapAv
+ from VOLS join DEFCLASSES on DEFCLASSES.NumVol = VOLS.NumVol
+ join AVIONS on AVIONS.NumAv = VOLS.NumAv
+ where DateD >= ? and VilleD = ? and DateA <= ? and VilleA = ?
+ order by DateD, NumVol, Prix";
+ $connection->prepare_query($sql_pquery);
+ $connection->prepared_query_bind_param("ssss", array($form_departure_date, $form_departure_city, $form_arrival_date, $form_arrival_city));
+ $connection->run_prepared_query();
+ $connection->get_pquery_result();
+ $flights = $connection->get_result_array();
+ $connection->close_prepared_query();
+ //var_dump($flights);
+ if (empty($flights)) {
+ 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 "