Add password change feature.
[Project_webapp.git] / includes / formsearch.php
index 66c57c94b8412c8c0bbe6d654acaff78b6a5ad8b..ba1572a904bc4273ada71b5f8a49de9f1cc50fa1 100644 (file)
@@ -40,11 +40,11 @@ if (empty($form_arrival_date)) {
 
 ?>
 
-<h1> Rechercher un vol <?php if ($action === "return_flight") { echo "retour"; } ?></h1>
+<h1> Rechercher un vol <?php if ($action === "return_flight") { echo "retour"; } ?> </h1>
 
 <form action="index.php" id="search" method="post">
  <input type="hidden" name="form" value="search" />
- <?php if ($action === "return_flight") echo "<input type=\"hidden\" name=\"action\" value=\"return_flight\" />" ?>
+ <?php if ($action === "return_flight") { echo "<input type=\"hidden\" name=\"action\" value=\"return_flight\" />"; } ?>
  <input type="hidden" name="date_now" value="<?php echo $form_date_now; ?>" />
  <label> De&#769;part : Ville -> </label>
  <select size="1" name="departure_city" required>
@@ -91,50 +91,50 @@ if (empty($form_arrival_date)) {
   </optgroup>
  </select>
  <label> Date -> </label>
- <input type="datetime-local" name="arrival_date" <?php if (isset($form_arrival_date)) echo "value=\"$form_arrival_date\"";?> />
+ <input type="datetime-local" name="arrival_date" <?php if (isset($form_arrival_date)) { echo "value=\"$form_arrival_date\""; } ?> />
  <input type="submit" value="Rechercher">
 </form>
 <br>
 
 <?php
 if (!$input_failure) {
-    global $connection;
-    $sql_pquery = "select VOLS.NumVol as NumVol, VilleD, DateD, VilleA, DateA, Classe, round(CoutVol*CoeffPrix, 2) as Prix, NumAv from VOLS, DEFCLASSES
-                   where DEFCLASSES.NumVol = VOLS.NumVol and
-                   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();
-    $rows = $connection->get_result_array();
-    $connection->close_prepared_query();
-    //FIXME: Use NumAv to see if a flight is fully booked.
-    //var_dump($rows);
-    if (empty($rows)) {
-        echo "Aucun vol ne correspond aux crite&#768;res de recherche. <br>";
-    } else {
-        echo "<table id=\"search\">\n";
-        echo "  <tr>\n";
-        echo "    <th>Nume&#769;ro de vol</th>\n";
-        echo "    <th>Ville de de&#769;part</th>\n";
-        echo "    <th>Date de de&#769;part</th>\n";
-        echo "    <th>Ville d'arrive&#769;e</th>\n";
-        echo "    <th>Date d'arrive&#769;e</th>\n";
-        echo "    <th>Classe</th>\n";
-        echo "    <th>Prix d'une place</th>\n";
-        echo "    <th>Re&#769;server</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['Prix'] . "&euro;</td>\n";
-            echo "    <td>
+     global $connection;
+     $sql_pquery = "select VOLS.NumVol as NumVol, VilleD, DateD, VilleA, DateA, Classe, round(CoutVol*CoeffPrix, 2) as Prix, NumAv from VOLS, DEFCLASSES
+                    where DEFCLASSES.NumVol = VOLS.NumVol and
+                    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();
+     $rows = $connection->get_result_array();
+     $connection->close_prepared_query();
+     //FIXME: Use NumAv to see if a flight is fully booked.
+     //var_dump($rows);
+     if (empty($rows)) {
+         echo "Aucun vol ne correspond aux crite&#768;res de recherche. <br>";
+     } else {
+         echo "<table id=\"search\">\n";
+         echo "  <tr>\n";
+         echo "    <th>Nume&#769;ro de vol</th>\n";
+         echo "    <th>Ville de de&#769;part</th>\n";
+         echo "    <th>Date de de&#769;part</th>\n";
+         echo "    <th>Ville d'arrive&#769;e</th>\n";
+         echo "    <th>Date d'arrive&#769;e</th>\n";
+         echo "    <th>Classe</th>\n";
+         echo "    <th>Prix d'une place</th>\n";
+         echo "    <th>Re&#769;server</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['Prix'] . "&euro;</td>\n";
+             echo "    <td>
                         <form action=\"index.php\" id=\"booking\" method=\"post\">
                           <input type=\"hidden\" name=\"form\" value=\"booking\" />
                           <input type=\"hidden\" name=\"flight_id\" value=\"" . $row['NumVol'] . "\" />
@@ -143,16 +143,16 @@ if (!$input_failure) {
                           <label> Place(s) : </label>
                           <input type=\"number\" name=\"nb_place\" min=\"1\" max=\"9\" value=\"1\" required/>
                           <label> Vol retour : </label>\n";
-                          if (!($action === "return_flight")) {
-                              echo "        <input type=\"checkbox\" name=\"return_flight\" checked/>\n";
-                          }
-            echo "        <input type=\"submit\" value=\"Re&#769;server\">\n";
-            echo "      </form>
-                     </td>\n";
-            echo "  </tr>\n";
-        }
-        echo "</table>\n";
-    }
-}
+             if (!($action === "return_flight")) {
+                 echo "       <input type=\"checkbox\" name=\"return_flight\" checked/>\n";
+             }
+             echo "       <input type=\"submit\" value=\"Re&#769;server\">\n";
+             echo "     </form>
+                       </td>\n";
+             echo "  </tr>\n";
+         }
+         echo "</table>\n";
+     }
+ }
 
 ?>