Fixlets to today coding session.
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 17 Jan 2018 15:41:44 +0000 (16:41 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 17 Jan 2018 15:41:44 +0000 (16:41 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
includes/booking.php [new file with mode: 0644]
includes/formbooking.php
includes/formsearch.php
includes/reservations.php
includes/search.php

diff --git a/includes/booking.php b/includes/booking.php
new file mode 100644 (file)
index 0000000..e69de29
index 3d55c5013e1936880f83dd2fa65e5791e0540260..2d47f81da68e34b41cac7afc58a7471444dcab89 100644 (file)
@@ -35,6 +35,8 @@ if (!$input_failure && $is_logged_in && !empty($form_nb_place) && !empty($form_c
     if (!empty($nb_booked)) {
         echo "Vous avez de&#769;ja&#768; re&#769;serve&#769; ce vol, vous allez e&#770;tre redirige&#769; vers la liste de vos re&#769;servations dans 2 secondes. <br>";
         redirect("index.php?page=reservations", 2);
+        include('footer.html');
+        exit();
     }
     $sql_pquery = "insert into RESERVATIONS (NumCl, NumVol, Classe, NbPlaces)
                    values (?, ?, ?, ?)";
index 7796f0691ae75452042e1ee02ae7906e228a46bf..e40ab128e046423e4e81ff62d902e78a601fcd78 100644 (file)
@@ -90,7 +90,7 @@ if (empty($form_arrival_date)) {
  </select>
  <label> Date -> </label>
  <input type="datetime-local" name="arrival_date" <?php if (isset($form_arrival_date)) echo "value=\"$form_arrival_date\"";?> />
- <input type="submit" value="Valider">
+ <input type="submit" value="Rechercher">
 </form>
 <br>
 
index f560b9a1dd776ce60f4d14cf8aa4f947704062be..15beeacb5777c9442114277e9bd3a21b885ce332 100644 (file)
@@ -10,8 +10,9 @@ if (!$is_logged_in) {
 <h1>Mes re&#769;servations</h1>
 <?php
 $client_id = get_client_id($_SESSION['email']);
-//Add teen minutes to permit to show reservations after the end of the flight
+// Add teen minutes to permit to show reservations after the end of the flight
 $date_now = date('Y-m-d\TH:i', time() + 600);
+$oDateNow = new Datetime($date_now);
 global $connection;
 $sql_pquery = "select RESERVATIONS.NumVol as NumVol, VilleD, DateD, VilleA, DateA, RESERVATIONS.Classe, NbPlaces, round(CoutVol*CoeffPrix*NbPlaces, 2) as Prix
                from RESERVATIONS join VOLS on RESERVATIONS.NumVol = VOLS.NumVol
@@ -41,6 +42,7 @@ if (empty($rows)) {
     echo "    <th>Actions</th>\n";
     echo "  </tr>\n";
     foreach ($rows as $row) {
+        $oDepartureDate = new DateTime($row['DateD']);
         echo "  <tr>\n";
         echo "    <td>" . $row['NumVol'] . "</td>\n";
         echo "    <td>" . $row['VilleD'] . "</td>\n";
@@ -50,15 +52,19 @@ if (empty($rows)) {
         echo "    <td>" . $row['Classe'] . "</td>\n";
         echo "    <td>" . $row['NbPlaces'] . "</td>\n";
         echo "    <td>" . $row['Prix'] . "&euro;</td>\n";
-        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=\"submit\" name=\"modify\" value=\"Modifier\">
-                      <input type=\"submit\" name=\"cancel\" value=\"Annuler\">
-                    </form>
-                  </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=\"submit\" name=\"modify\" value=\"Modifier\">
+                          <input type=\"submit\" name=\"cancel\" value=\"Annuler\">
+                        </form>
+                      </td>\n";
+        } else {
+            echo "Vol en cours";
+        }
         echo "  </tr>\n";
     }
     echo "</table>";
index 3365090f26c9cef10a04b08fe0331af73b554863..c7e761f5104eea28ab5d096f149fc48222ea0559 100644 (file)
@@ -43,6 +43,6 @@
  </select>
  <label> Date -> </label>
  <input type="datetime-local" name="arrival_date" />
- <input type="submit" value="Valider">
+ <input type="submit" value="Rechercher">
 </form>
 <br>