Make the reservation(s) code more readable.
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 20 Jan 2018 16:38:57 +0000 (17:38 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 20 Jan 2018 16:38:57 +0000 (17:38 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
includes/formsearch.php
includes/reservations.php

index cd12ee4a5b988b8aff76f592022ed64c1f77cd3e..5cdca0cc4322af26d8bfe9402bc0d26a009aa11f 100644 (file)
@@ -132,7 +132,7 @@ if (!$input_failure) {
          echo "    <th>Re&#769;server</th>\n";
          echo "  </tr>\n";
          foreach ($fligths as $fligth) {
-             $sql_pquery = "select sum(NbPlaces) from RESERVATIONS where NumVol = ?";
+             $sql_pquery = "select sum(NbPlaces) as BookedPlaces from RESERVATIONS where NumVol = ?";
              $connection->prepare_query($sql_pquery);
              $connection->prepared_query_bind_param("s", array($fligth['NumVol']));
              $connection->run_prepared_query();
@@ -157,7 +157,7 @@ if (!$input_failure) {
              echo "    <td>" . $fligth['Classe'] . "</td>\n";
              echo "    <td>" . $fligth['Prix'] . "&euro;</td>\n";
              echo "    <td>
-                        Places libres : " . $free_places . "
+                        Nombre de places libres : " . $free_places . "
                         <form action=\"index.php\" id=\"booking\" method=\"post\">
                           <input type=\"hidden\" name=\"form\" value=\"booking\" />
                           <input type=\"hidden\" name=\"flight_id\" value=\"" . $fligth['NumVol'] . "\" />
index 0d32077720b46e5c5271580c0ad8461c44a3833b..9458dc77e98f76eb96f245db05d8c950aa701584 100644 (file)
@@ -24,9 +24,9 @@ $connection->prepare_query($sql_pquery);
 $connection->prepared_query_bind_param("is", array($client_id, $date_now));
 $connection->run_prepared_query();
 $connection->get_pquery_result();
-$rows = $connection->get_result_array();
+$reservations = $connection->get_result_array();
 $connection->close_prepared_query();
-if (empty($rows)) {
+if (empty($reservations)) {
     echo "Aucune(s) re&#769;servation(s) en cours pour le moment. <br>";
 } else {
     echo "<table id=\"reservations\">\n";
@@ -41,24 +41,24 @@ if (empty($rows)) {
     echo "    <th>Prix</th>\n";
     echo "    <th>Actions</th>\n";
     echo "  </tr>\n";
-    foreach ($rows as $row) {
-        $oDepartureDate = new DateTime($row['DateD']);
+    foreach ($reservations as $reservation) {
+        $oDepartureDate = new DateTime($reservation['DateD']);
         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['NbPlaces'] . "</td>\n";
-        echo "    <td>" . $row['Prix'] . "&euro;</td>\n";
+        echo "    <td>" . $reservation['NumVol'] . "</td>\n";
+        echo "    <td>" . $reservation['VilleD'] . "</td>\n";
+        echo "    <td>" . $reservation['DateD'] . "</td>\n";
+        echo "    <td>" . $reservation['VilleA'] . "</td>\n";
+        echo "    <td>" . $reservation['DateA'] . "</td>\n";
+        echo "    <td>" . $reservation['Classe'] . "</td>\n";
+        echo "    <td>" . $reservation['NbPlaces'] . "</td>\n";
+        echo "    <td>" . $reservation['Prix'] . "&euro;</td>\n";
         if ($oDepartureDate > $oDateNow) {
             echo "    <td>
                         <form action=\"index.php\" id=\"reservations\" method=\"post\">
                           <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=\"button\" name=\"modify\" value=\"Modifier\" onClick=\"location.href='index.php?page=modify&flight_id=" . $row['NumVol'] . "&class_name=" . $row['Classe'] . "';\">
+                          <input type=\"hidden\" name=\"flight_id\" value=\"" . $reservation['NumVol'] . "\" />
+                          <input type=\"hidden\" name=\"class_name\" value=\"" . $reservation['Classe'] . "\" />
+                          <input type=\"button\" name=\"modify\" value=\"Modifier\" onClick=\"location.href='index.php?page=modify&flight_id=" . $reservation['NumVol'] . "&class_name=" . $reservation['Classe'] . "';\">
                           <input type=\"button\" name=\"cancel\" value=\"Annuler\" onClick=\"ConfirmCancelFlight()\">
                         </form>
                       </td>\n";