Tout marche

This commit is contained in:
remi.biette 2019-05-23 13:14:50 +02:00
parent 38bd61a394
commit 9b671fa476
4 changed files with 19 additions and 8 deletions

View File

@ -36,16 +36,22 @@ require_once("../ressources/navbarhtml.php");
<div id="liste">
<table>
<?php
$result = pg_query_params($db, "SELECT * FROM Trajet Where mailproposition = $1 AND estannule = false;", array($mail));
$result = pg_query_params($db, "SELECT * FROM Trajet Where mailproposition = $1 AND estannule = false ORDER BY datedepart DESC;", array($mail));
while ($row = pg_fetch_array($result)) {
$login = getLogin($db, $mail);
$date_depart = $row['datedepart'];
$codetrajet = $row['codetrajet'];
$source = getDepart($db, $codetrajet);
$dest = getFin($db, $codetrajet);
$date = date('Y-m-d H:i:s');
echo "<tr><td class='ligne'><hr class='separation'/></td><td class='info'>";
echo "<p>$date_depart - $source vers $dest proposé par : $login</p></td>";
echo "<td><a href='annulerTrajet.php?codetrajet=$codetrajet'>Annuler le trajet</a></td>";
if ($date <= $row['datearrivee']){
echo "<td><a href='annulerTrajet.php?codetrajet=$codetrajet'>Annuler le trajet</a></td>";
}
else{
echo "<td class='info'><p>Trajet effectué</p></td>";
}
echo "</tr>";
}
?>

View File

@ -34,17 +34,22 @@ require_once("../ressources/navbarhtml.php");
<div id="liste">
<table>
<?php
$result = pg_query_params($db, "SELECT DISTINCT ut.login as login, tr.* FROM utilisateur ut, trajet tr, reserver re WHERE ut.mail = re.mailutilisateur AND re.codetrajet = tr.codetrajet AND re.mailutilisateur = $1 AND tr.estannule = false;", array($mail));
$result = pg_query_params($db, "SELECT DISTINCT ut.login as login, tr.* FROM utilisateur ut, trajet tr, reserver re WHERE ut.mail = re.mailutilisateur AND re.codetrajet = tr.codetrajet AND re.mailutilisateur = $1 AND tr.estannule = false ORDER BY datedepart DESC;", array($mail));
while ($row = pg_fetch_array($result)) {
$login = $row['login'];
$date_depart = $row['datedepart'];
$codetrajet = $row['codetrajet'];
$source = getDepart($db, $codetrajet);
$date = date('Y-m-d H:i:s');
$dest = getFin($db, $codetrajet);
echo "<tr><td class='ligne'><hr class='separation'/></td>";
echo "<td class='info'><p>$date_depart - $source vers $dest proposé par : $login</p></td>";
echo "<td><a href='annulerReservation.php?codetrajet=$codetrajet'>Annuler la reservation</a></td>";
if ($date <= $row['datearrivee']){
echo "<td><a href='annulerReservation.php?codetrajet=$codetrajet'>Annuler la reservation</a></td>";
}
else{
echo "<td class='info'><p>Trajet effectué</p></td>";
}
echo "<td><a href='../deposer_avis/deposer_avis.php?codetrajet=$codetrajet'>Déposer un avis</a></td>";
echo "</tr>";
}

View File

@ -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");

View File

@ -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];