Commentaire code

This commit is contained in:
PALAFFRE Raphaël 2019-05-25 08:50:09 +00:00
parent 6e0465379e
commit 0d256c60ef

View File

@ -1,73 +1,81 @@
<?php <?php
session_start(); session_start();
require_once("../connexionBD.php");
require_once("../ressources/trajet.php"); //Importation des fichiers necessaires
//Si on est pas connecté redirection vers la page de connexion require_once("../connexionBD.php");
if (!isset($_SESSION['mail'])) { require_once("../ressources/trajet.php");
header('Location: ../index.php');
exit(); //Si on est pas connecté redirection vers la page de connexion
}
$mail = $_SESSION['mail']; if (!isset($_SESSION['mail'])) {
if (!(isset($_POST['lieu_depart']) && isset($_POST['lieu_arrivee']) && isset($_POST['date_heure']))){ header('Location: ../index.php');
header('Location: ../tableauBord/tableauBord.php'); exit();
exit(); }
}
if (isset($_POST['lieu_depart']) && isset($_POST['lieu_arrivee']) && isset($_POST['date_heure'])) { $mail = $_SESSION['mail'];
$source = $_POST['lieu_depart']; if (!(isset($_POST['lieu_depart']) && isset($_POST['lieu_arrivee']) && isset($_POST['date_heure']))){
$dest = $_POST['lieu_arrivee']; header('Location: ../tableauBord/tableauBord.php');
$date_depart = $_POST['date_heure']; exit();
if ($date_depart < date('Y-m-d')){ }
echo "Erreur date</br>";
echo "<a href='../tableauBord/tableauBord.php'>Retour vers le tableau de bord</a>"; if (isset($_POST['lieu_depart']) && isset($_POST['lieu_arrivee']) && isset($_POST['date_heure'])) {
exit(); $source = $_POST['lieu_depart']; //Recuperation des valeurs passé par le form
} $dest = $_POST['lieu_arrivee'];
} $date_depart = $_POST['date_heure'];
if ($date_depart < date('Y-m-d')){ //Verification de date
$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))) echo "Erreur date</br>";
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)); echo "<a href='../tableauBord/tableauBord.php'>Retour vers le tableau de bord</a>";
exit();
?> }
<!DOCTYPE html> }
<html lang="fr">
<head> //Requete de selection des trajets a affiché
<meta charset="UTF-8">
<link rel="stylesheet" href="liste_trajet.css"> $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)))
<link rel="stylesheet" href="../ressources/navbarhtml.css"> 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));
<link rel="icon" href="../ressources/favicon.ico"/>
<title>Liste des trajets</title> ?>
</head> <!DOCTYPE html>
<body> <html lang="fr">
<?php <head>
require_once("../ressources/navbarhtml.php"); <meta charset="UTF-8">
?> <link rel="stylesheet" href="liste_trajet.css">
<div id="container"> <link rel="stylesheet" href="../ressources/navbarhtml.css">
<div id="entete"> <link rel="icon" href="../ressources/favicon.ico"/>
<a href="../tableauBord/tableauBord.php"><img id="bouton_retour" src="../ressources/image/return.png" <title>Liste des trajets</title>
alt="Bouton retour"></a> </head>
<h1 class="float" id="titre">Liste des trajets</h1> <body>
<br> <?php
<h2>Trajets recherchés : <?php echo $source . " vers " . $dest; ?></h2> require_once("../ressources/navbarhtml.php");
</div> ?>
<div id="liste"> <div id="container">
<table> <div id="entete"> <--Entete-->
<?php <a href="../tableauBord/tableauBord.php"><img id="bouton_retour" src="../ressources/image/return.png"
while ($row = pg_fetch_array($result)) { alt="Bouton retour"></a>
$codetrajet = $row['codetrajet']; <h1 class="float" id="titre">Liste des trajets</h1>
$login = $row['login']; <br>
$source = getDepart($db, $codetrajet); <h2>Trajets recherchés : <?php echo $source . " vers " . $dest; ?></h2>
$dest = getFin($db, $codetrajet); </div>
$date_depart = $row['datedepart']; <div id="liste">
if (checkPlacesVoiture($db, $codetrajet) && $date_depart >= date('Y-m-d H:i:s')){ <table>
echo "<tr><td class='ligne'><hr class='separation'/></td><td class='info'>"; <?php
echo "<p>$date_depart - $source vers $dest proposé par : $login</p></td>"; while ($row = pg_fetch_array($result)) { //Recuperation des resultats de la requete
echo "<td><a href='reserver.php?codetrajet=$codetrajet'>Réserver</a></td>"; $codetrajet = $row['codetrajet'];
echo "</tr>"; $login = $row['login'];
} $source = getDepart($db, $codetrajet);
} $dest = getFin($db, $codetrajet);
?> $date_depart = $row['datedepart'];
</table> if (checkPlacesVoiture($db, $codetrajet) && $date_depart >= date('Y-m-d H:i:s')){ //Affichage des resultats sous forme de tableau
</div> echo "<tr><td class='ligne'><hr class='separation'/></td><td class='info'>";
</div> echo "<p>$date_depart - $source vers $dest proposé par : $login</p></td>";
</body> echo "<td><a href='reserver.php?codetrajet=$codetrajet'>Réserver</a></td>";
</html> echo "</tr>";
}
}
?>
</table>
</div>
</div>
</body>
</html>