Tout marche

avisTrajet
remi.biette 6 years ago
parent 38bd61a394
commit 9b671fa476

@ -36,16 +36,22 @@ require_once("../ressources/navbarhtml.php");
<div id="liste"> <div id="liste">
<table> <table>
<?php <?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)) { while ($row = pg_fetch_array($result)) {
$login = getLogin($db, $mail); $login = getLogin($db, $mail);
$date_depart = $row['datedepart']; $date_depart = $row['datedepart'];
$codetrajet = $row['codetrajet']; $codetrajet = $row['codetrajet'];
$source = getDepart($db, $codetrajet); $source = getDepart($db, $codetrajet);
$dest = getFin($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 "<tr><td class='ligne'><hr class='separation'/></td><td class='info'>";
echo "<p>$date_depart - $source vers $dest proposé par : $login</p></td>"; 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>"; echo "</tr>";
} }
?> ?>

@ -34,17 +34,22 @@ require_once("../ressources/navbarhtml.php");
<div id="liste"> <div id="liste">
<table> <table>
<?php <?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)) { while ($row = pg_fetch_array($result)) {
$login = $row['login']; $login = $row['login'];
$date_depart = $row['datedepart']; $date_depart = $row['datedepart'];
$codetrajet = $row['codetrajet']; $codetrajet = $row['codetrajet'];
$source = getDepart($db, $codetrajet); $source = getDepart($db, $codetrajet);
$date = date('Y-m-d H:i:s');
$dest = getFin($db, $codetrajet); $dest = getFin($db, $codetrajet);
echo "<tr><td class='ligne'><hr class='separation'/></td>"; 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 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 "<td><a href='../deposer_avis/deposer_avis.php?codetrajet=$codetrajet'>Déposer un avis</a></td>";
echo "</tr>"; echo "</tr>";
} }

@ -5,7 +5,7 @@ function verifierTrajet($db, $mail, $codetrajet){
if (!$trajet){ if (!$trajet){
return false; 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"); require_once("../connexionBD.php");

@ -88,7 +88,7 @@ function checkVoiture($db, $mail, $matricule)
function getTrajetsProposes($db, $mail) 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) { if ($result) {
$row = pg_fetch_array($result); $row = pg_fetch_array($result);
return $row[0]; return $row[0];
@ -98,7 +98,7 @@ function getTrajetsProposes($db, $mail)
function getTrajetsReserves($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) { if ($result) {
$row = pg_fetch_array($result); $row = pg_fetch_array($result);
return $row[0]; return $row[0];

Loading…
Cancel
Save