@ -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));
$result = pg_query_params($db, "SELECT COUNT(*) From Trajet WHERE mailproposition = $1 AND $2 BETWEEN datedepart AND datearrivee;", array($mail, $dateDepart));
$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));