diff --git a/WEB/listeTrajetPublie/liste_trajet_publie.php b/WEB/listeTrajetPublie/liste_trajet_publie.php index 6a4ab08..3080e05 100644 --- a/WEB/listeTrajetPublie/liste_trajet_publie.php +++ b/WEB/listeTrajetPublie/liste_trajet_publie.php @@ -36,16 +36,22 @@ require_once("../ressources/navbarhtml.php");
";
echo " $date_depart - $source vers $dest proposé par : $login | ";
- echo "Annuler le trajet | "; + if ($date <= $row['datearrivee']){ + echo "Annuler le trajet | "; + } + else{ + echo "Trajet effectué | ";
+ }
echo "";
}
?>
diff --git a/WEB/listeTrajetReserve/liste_trajet_reserve.php b/WEB/listeTrajetReserve/liste_trajet_reserve.php
index a56399f..2a52dcf 100644
--- a/WEB/listeTrajetReserve/liste_trajet_reserve.php
+++ b/WEB/listeTrajetReserve/liste_trajet_reserve.php
@@ -34,17 +34,22 @@ require_once("../ressources/navbarhtml.php");
$date_depart - $source vers $dest proposé par : $login | ";
- echo "Annuler la reservation | "; + if ($date <= $row['datearrivee']){ + echo "Annuler la reservation | "; + } + else{ + echo "Trajet effectué | ";
+ }
echo "Déposer un avis | "; echo ""; } diff --git a/WEB/liste_trajets/reserver.php b/WEB/liste_trajets/reserver.php index ec40708..a204c9d 100644 --- a/WEB/liste_trajets/reserver.php +++ b/WEB/liste_trajets/reserver.php @@ -5,7 +5,7 @@ function verifierTrajet($db, $mail, $codetrajet){ if (!$trajet){ return false; } - return checkReservations($db, $mail, $codetrajet) && checkPlacesVoiture($db, $codetrajet) && strcmp($mail, $trajet['mailproposition'])!=0; + return checkReservations($db, $mail, $codetrajet) && checkPlacesVoiture($db, $codetrajet) && !strcmp($mail, $trajet['mailproposition']); } require_once("../connexionBD.php"); diff --git a/WEB/ressources/trajet.php b/WEB/ressources/trajet.php index 738e2fa..b7900ab 100644 --- a/WEB/ressources/trajet.php +++ b/WEB/ressources/trajet.php @@ -88,7 +88,7 @@ function checkVoiture($db, $mail, $matricule) function getTrajetsProposes($db, $mail) { - $result = pg_query_params($db, "SELECT COUNT(*) from Trajet WHERE mailProposition = $1 AND estAnnule = false AND datedepart >= current_date;", array($mail)); + $result = pg_query_params($db, "SELECT COUNT(*) from Trajet WHERE mailProposition = $1 AND estAnnule = false AND datearrivee >= $2;", array($mail, date('Y-m-d H:i:s'))); if ($result) { $row = pg_fetch_array($result); return $row[0]; @@ -98,7 +98,7 @@ function getTrajetsProposes($db, $mail) function getTrajetsReserves($db, $mail) { - $result = pg_query_params($db, "SELECT COUNT(*) FROM trajet tr, reserver re WHERE re.codetrajet = tr.codetrajet AND mailutilisateur = $1 AND estannule = false AND tr.datedepart >= current_timestamp;", array($mail)); + $result = pg_query_params($db, "SELECT COUNT(*) FROM trajet tr, reserver re WHERE re.codetrajet = tr.codetrajet AND mailutilisateur = $1 AND tr.estannule = false AND re.estannule = false AND tr.datearrivee >= $2;", array($mail, date('Y-m-d H:i:s'))); if ($result) { $row = pg_fetch_array($result); return $row[0];