Commentaire code

master
PALAFFRE Raphaël 6 years ago
parent 6e0465379e
commit 0d256c60ef

@ -1,29 +1,37 @@
<?php <?php
session_start(); session_start();
//Importation des fichiers necessaires
require_once("../connexionBD.php"); require_once("../connexionBD.php");
require_once("../ressources/trajet.php"); require_once("../ressources/trajet.php");
//Si on est pas connecté redirection vers la page de connexion //Si on est pas connecté redirection vers la page de connexion
if (!isset($_SESSION['mail'])) { if (!isset($_SESSION['mail'])) {
header('Location: ../index.php'); header('Location: ../index.php');
exit(); exit();
} }
$mail = $_SESSION['mail']; $mail = $_SESSION['mail'];
if (!(isset($_POST['lieu_depart']) && isset($_POST['lieu_arrivee']) && isset($_POST['date_heure']))){ if (!(isset($_POST['lieu_depart']) && isset($_POST['lieu_arrivee']) && isset($_POST['date_heure']))){
header('Location: ../tableauBord/tableauBord.php'); header('Location: ../tableauBord/tableauBord.php');
exit(); exit();
} }
if (isset($_POST['lieu_depart']) && isset($_POST['lieu_arrivee']) && isset($_POST['date_heure'])) { if (isset($_POST['lieu_depart']) && isset($_POST['lieu_arrivee']) && isset($_POST['date_heure'])) {
$source = $_POST['lieu_depart']; $source = $_POST['lieu_depart']; //Recuperation des valeurs passé par le form
$dest = $_POST['lieu_arrivee']; $dest = $_POST['lieu_arrivee'];
$date_depart = $_POST['date_heure']; $date_depart = $_POST['date_heure'];
if ($date_depart < date('Y-m-d')){ if ($date_depart < date('Y-m-d')){ //Verification de date
echo "Erreur date</br>"; echo "Erreur date</br>";
echo "<a href='../tableauBord/tableauBord.php'>Retour vers le tableau de bord</a>"; echo "<a href='../tableauBord/tableauBord.php'>Retour vers le tableau de bord</a>";
exit(); exit();
} }
} }
//Requete de selection des trajets a affiché
$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))) $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 tr.codepostal = v.codepostal AND tr.numeroetape = (SELECT MAX(numeroetape) FROM traverser WHERE LOWER(nomVille) = LOWER($2)));", array($source, $dest, $date_depart));
@ -42,7 +50,7 @@ INTERSECT (SELECT DISTINCT ut.login, ta.codetrajet, ta.datedepart FROM ville v,
require_once("../ressources/navbarhtml.php"); require_once("../ressources/navbarhtml.php");
?> ?>
<div id="container"> <div id="container">
<div id="entete"> <div id="entete"> <--Entete-->
<a href="../tableauBord/tableauBord.php"><img id="bouton_retour" src="../ressources/image/return.png" <a href="../tableauBord/tableauBord.php"><img id="bouton_retour" src="../ressources/image/return.png"
alt="Bouton retour"></a> alt="Bouton retour"></a>
<h1 class="float" id="titre">Liste des trajets</h1> <h1 class="float" id="titre">Liste des trajets</h1>
@ -52,13 +60,13 @@ require_once("../ressources/navbarhtml.php");
<div id="liste"> <div id="liste">
<table> <table>
<?php <?php
while ($row = pg_fetch_array($result)) { while ($row = pg_fetch_array($result)) { //Recuperation des resultats de la requete
$codetrajet = $row['codetrajet']; $codetrajet = $row['codetrajet'];
$login = $row['login']; $login = $row['login'];
$source = getDepart($db, $codetrajet); $source = getDepart($db, $codetrajet);
$dest = getFin($db, $codetrajet); $dest = getFin($db, $codetrajet);
$date_depart = $row['datedepart']; $date_depart = $row['datedepart'];
if (checkPlacesVoiture($db, $codetrajet) && $date_depart >= date('Y-m-d H:i:s')){ if (checkPlacesVoiture($db, $codetrajet) && $date_depart >= date('Y-m-d H:i:s')){ //Affichage des resultats sous forme de tableau
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='reserver.php?codetrajet=$codetrajet'>Réserver</a></td>"; echo "<td><a href='reserver.php?codetrajet=$codetrajet'>Réserver</a></td>";

Loading…
Cancel
Save