You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
3.3 KiB
PHP
74 lines
3.3 KiB
PHP
<?php
|
|
session_start();
|
|
require_once("../connexionBD.php");
|
|
require_once("../ressources/trajet.php");
|
|
|
|
//Si on est pas connecté redirection vers la page de connexion
|
|
if (!isset($_SESSION['mail'])) {
|
|
header('Location: ../index.php');
|
|
exit();
|
|
}
|
|
$mail = $_SESSION['mail'];
|
|
if (!(isset($_POST['lieu_depart']) && isset($_POST['lieu_arrivee']) && isset($_POST['date_heure']))){
|
|
header('Location: ../tableauBord/tableauBord.php');
|
|
exit();
|
|
}
|
|
if (isset($_POST['lieu_depart']) && isset($_POST['lieu_arrivee']) && isset($_POST['date_heure'])) {
|
|
$source = $_POST['lieu_depart'];
|
|
$dest = $_POST['lieu_arrivee'];
|
|
$date_depart = $_POST['date_heure'];
|
|
if ($date_depart < date('Y-m-d')){
|
|
echo "Erreur date</br>";
|
|
echo "<a href='../tableauBord/tableauBord.php'>Retour vers le tableau de bord</a>";
|
|
exit();
|
|
}
|
|
}
|
|
|
|
$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));
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<link rel="stylesheet" href="liste_trajet.css">
|
|
<link rel="stylesheet" href="../ressources/navbarhtml.css">
|
|
<link rel="icon" href="../ressources/favicon.ico"/>
|
|
<title>Liste des trajets</title>
|
|
</head>
|
|
<body>
|
|
<?php
|
|
require_once("../ressources/navbarhtml.php");
|
|
?>
|
|
<div id="container">
|
|
<div id="entete">
|
|
<a href="../tableauBord/tableauBord.php"><img id="bouton_retour" src="../ressources/image/return.png"
|
|
alt="Bouton retour"></a>
|
|
<h1 class="float" id="titre">Liste des trajets</h1>
|
|
<br>
|
|
<h2>Trajets recherchés : <?php echo $source . " vers " . $dest; ?></h2>
|
|
</div>
|
|
<div id="liste">
|
|
<table>
|
|
<?php
|
|
while ($row = pg_fetch_array($result)) {
|
|
$codetrajet = $row['codetrajet'];
|
|
$login = $row['login'];
|
|
$source = getDepart($db, $codetrajet);
|
|
$dest = getFin($db, $codetrajet);
|
|
$date_depart = $row['datedepart'];
|
|
if (checkPlacesVoiture($db, $codetrajet) && $date_depart >= 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='reserver.php?codetrajet=$codetrajet'>Réserver</a></td>";
|
|
echo "</tr>";
|
|
}
|
|
}
|
|
?>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|