From 38bd61a39429b87e85e8b898ac256996f75a7279 Mon Sep 17 00:00:00 2001 From: "remi.biette" Date: Thu, 23 May 2019 12:05:13 +0200 Subject: [PATCH] debug --- WEB/listeTrajetReserve/liste_trajet_reserve.php | 1 + WEB/liste_trajets/liste_trajet.php | 2 +- WEB/liste_trajets/reserver.php | 13 ++++++++----- WEB/profil/profil.php | 6 +++++- WEB/recherche/recherche.css | 9 +++++++++ WEB/recherche/recherche.php | 16 ++++++++++++++-- WEB/ressources/trajet.php | 14 ++++++++++---- 7 files changed, 48 insertions(+), 13 deletions(-) diff --git a/WEB/listeTrajetReserve/liste_trajet_reserve.php b/WEB/listeTrajetReserve/liste_trajet_reserve.php index 4d84b9b..a56399f 100644 --- a/WEB/listeTrajetReserve/liste_trajet_reserve.php +++ b/WEB/listeTrajetReserve/liste_trajet_reserve.php @@ -40,6 +40,7 @@ require_once("../ressources/navbarhtml.php"); $date_depart = $row['datedepart']; $codetrajet = $row['codetrajet']; $source = getDepart($db, $codetrajet); + $dest = getFin($db, $codetrajet); echo "
"; echo "

$date_depart - $source vers $dest proposé par : $login

"; diff --git a/WEB/liste_trajets/liste_trajet.php b/WEB/liste_trajets/liste_trajet.php index 8979275..63466f0 100755 --- a/WEB/liste_trajets/liste_trajet.php +++ b/WEB/liste_trajets/liste_trajet.php @@ -25,7 +25,7 @@ if (isset($_POST['lieu_depart']) && isset($_POST['lieu_arrivee']) && isset($_POS } $result = pg_query_params($db, "(SELECT DISTINCT ut.login, ta.codetrajet, ta.datedepart FROM ville v, traverser tr, utilisateur ut, trajet ta WHERE DATE(ta.datedepart) = DATE($3) AND ta.estannule = false AND ta.codetrajet = tr.codetrajet AND ta.mailproposition = ut.mail AND tr.nomVille = v.nomVille AND tr.codepostal = v.codepostal AND tr.numeroetape = (SELECT MIN(numeroetape) FROM traverser WHERE LOWER(nomVille) = LOWER($1))) -INTERSECT (SELECT DISTINCT ut.login, ta.codetrajet, ta.datedepart FROM ville v, traverser tr, utilisateur ut, trajet ta WHERE DATE(ta.datedepart) = DATE($3) AND ta.estannule = false AND ta.codetrajet = tr.codetrajet AND ta.mailproposition = ut.mail AND tr.nomVille = v.nomVille AND tr.codepostal = v.codepostal AND tr.numeroetape = (SELECT MAX(numeroetape) FROM traverser WHERE LOWER(nomVille) = LOWER($2)));", array($source, $dest, $date_depart)); +INTERSECT (SELECT DISTINCT ut.login, ta.codetrajet, ta.datedepart FROM ville v, traverser tr, utilisateur ut, trajet ta WHERE DATE(ta.datedepart) = DATE($3) AND ta.estannule = false AND ta.codetrajet = tr.codetrajet AND ta.mailproposition = ut.mail AND tr.nomVille = v.nomVille AND LOWER(v.nomville) = LOWER($2) AND tr.codepostal = v.codepostal AND tr.numeroetape != 1);", array($source, $dest, $date_depart)); ?> diff --git a/WEB/liste_trajets/reserver.php b/WEB/liste_trajets/reserver.php index 87c08b9..ec40708 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) && checkDatesReserve($db, $mail, $trajet['datedepart']) && checkPlacesVoiture($db, $codetrajet) && strcmp($trajet['mailproposition'], $mail) != 0; + return checkReservations($db, $mail, $codetrajet) && checkPlacesVoiture($db, $codetrajet) && strcmp($mail, $trajet['mailproposition'])!=0; } require_once("../connexionBD.php"); @@ -19,12 +19,15 @@ $mail = $_SESSION['mail']; if (isset($_GET['codetrajet'])){ $codetrajet = $_GET['codetrajet']; - if (verifierTrajet($db, $mail, $codetrajet)){ - reserver($db, $mail, $codetrajet); + if (verifierTrajet($db, $mail, $codetrajet) && reserver($db, $mail, $codetrajet)){ + header('Location: ../tableauBord/tableauBord.php'); + exit(); + } + else{ + header('Location: ../recherche/recherche.php?error=1'); + exit(); } } -header('Location: ../tableauBord/tableauBord.php'); -exit(); diff --git a/WEB/profil/profil.php b/WEB/profil/profil.php index 0c478c8..0695e1b 100644 --- a/WEB/profil/profil.php +++ b/WEB/profil/profil.php @@ -170,7 +170,11 @@ if (isset($_POST['login']) || isset($_FILES['avatar'])){ - + ".getErrorProfil($_GET['error'])."

"; + } + ?> diff --git a/WEB/recherche/recherche.css b/WEB/recherche/recherche.css index cb02c7f..fbc186d 100644 --- a/WEB/recherche/recherche.css +++ b/WEB/recherche/recherche.css @@ -1,3 +1,7 @@ +*{ + font-family: "Arial"; +} + .centrage { text-align: center; font-size: 20px; @@ -37,4 +41,9 @@ h1 { text-align: center; } +.error{ + color: red; + text-align: center; +} + diff --git a/WEB/recherche/recherche.php b/WEB/recherche/recherche.php index 99f7a5e..5454213 100644 --- a/WEB/recherche/recherche.php +++ b/WEB/recherche/recherche.php @@ -1,4 +1,13 @@ @@ -46,9 +55,12 @@ require_once("../ressources/navbarhtml.php"); + " . getError($_GET['error']) . "

"; + } + ?> - - diff --git a/WEB/ressources/trajet.php b/WEB/ressources/trajet.php index ae69778..738e2fa 100644 --- a/WEB/ressources/trajet.php +++ b/WEB/ressources/trajet.php @@ -7,7 +7,7 @@ function getListeVilles($db) } function reserver($db, $mail, $codetrajet){ - return pg_query_params($db, "INSERT INTO Reserver VALUES ($1, $2, $3);", array($mail, $codetrajet, date('Y-m-d H:i:s'))); + return pg_query_params($db, "INSERT INTO Reserver VALUES ($1, $2, false, $3);", array($mail, $codetrajet, date('Y-m-d H:i:s'))); } function getTrajet($db, $codetrajet) @@ -37,12 +37,18 @@ function creerEtapes($db, $codeTrajet, $etapes) //Vérifier la cohérence des dates function checkDates($db, $mail, $dateDepart, $dateArrivee) { - $valide = $dateDepart < $dateArrivee && $dateDepart > date('Y-m-d H:i:s'); - $result = pg_query_params($db, "SELECT COUNT(*) From Trajet WHERE mailproposition = $1 AND $2 BETWEEN datedepart AND datearrivee;", array($mail, $dateDepart)); + $valide = $dateDepart <= $dateArrivee && $dateDepart >= date('Y-m-d H:i:s'); + $result = pg_query_params($db, "SELECT COUNT(*) From Trajet WHERE mailproposition = $1 AND estannule = false AND $2 BETWEEN datedepart AND datearrivee;", array($mail, $dateDepart)); $row = pg_fetch_array($result); return $row[0] == 0 && $valide; } +//Récupérer les étapes d'un trajet +function getEtapesTrajet($db, $codetrajet){ + $result = pg_query_params($db, "SELECT * FROM Traverser WHERE codetrajet = $1 ;", array($codetrajet)); + return $result; +} + //Vérifier le nombre de places restantes function checkPlacesVoiture($db, $codetrajet) { @@ -92,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 datedepart >= current_date;", array($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)); if ($result) { $row = pg_fetch_array($result); return $row[0];