Ajout reservation / annulation debug admin

avisTrajet
remi.biette 6 years ago
parent 5d6c29070f
commit c8308b0504

@ -41,6 +41,8 @@ if (isset($_POST['dateDepart']) && isset($_POST['dateArrivee']) && isset($_POST[
$codeTrajet = pg_fetch_array($result)[0];
//Creer les etapes en bd
$result = creerEtapes($db, $codeTrajet, $arrEtapes);
header('Location: ../tableauBord/tableauBord.php');
exit();
}
if (!$result){
header('Location: depotTrajet.php?error=4');
@ -103,7 +105,7 @@ if (isset($_POST['dateDepart']) && isset($_POST['dateArrivee']) && isset($_POST[
</div>
<?php
if (isset($_GET['error'])){
getErrorDepotTrajet($_GET['error']);
echo "<p class='error'>".getErrorDepotTrajet($_GET['error'])."</p>";
}
?>
<div class="line">

@ -9,7 +9,7 @@ function checkAvis($db, $mail, $codetrajet)
function checkCodeTrajetAvis($db, $mail, $codetrajet)
{
$result = pg_query_params($db, "SELECT COUNT(*) FROM avis av, trajet tr, reserver re WHERE av.codetrajet = $2 AND av.codetrajet = tr.codetrajet AND tr.codetrajet = re.codetrajet AND re.mailutilisateur = $1;", array($mail, $codetrajet));
$result = pg_query_params($db, "SELECT COUNT(*) FROM trajet tr, reserver re WHERE tr.codetrajet = $1 AND tr.codetrajet = re.codetrajet AND re.mailutilisateur = $2;", array($codetrajet, $mail));
$row = pg_fetch_array($result);
return $row[0] >= 1;
}
@ -25,7 +25,6 @@ if (!isset($_SESSION['mail'])) {
}
$mail = $_SESSION['mail'];
if (isset($_POST['codetrajet']) && isset($_POST['avislaisse']) && isset($_POST['note'])) {
$avis = $_POST['avislaisse'];
$note = $_POST['note'];
@ -36,9 +35,10 @@ if (isset($_POST['codetrajet']) && isset($_POST['avislaisse']) && isset($_POST['
$envoi = pg_query_params($db, $requete, array($mail, $codetrajet, $avis, $date, $note));
if (!$envoi) {
echo "Erreur d'ecriture dans la BD";
echo "<br><a href='../tableauBord/tableauBord.php'>Retour vers le tableau de bord</a>";
exit();
} else {
header('Location: ../index.php');
header('Location: ../tableauBord/tableauBord.php');
exit();
}
}

@ -0,0 +1,18 @@
<?php
require_once ("../connexionBD.php");
require_once ("../ressources/trajet.php");
session_start();
//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($_GET['codetrajet'])){
$codetrajet = $_GET['codetrajet'];
annulerTrajet($db, $codetrajet);
}
header('Location: ../tableauBord/tableauBord.php');
exit();

@ -0,0 +1,49 @@
body {
color:black;
background-color:white;
background-image:url("../ressources/image/background.jpg");
background-repeat:no-repeat;
background-size:104%;
margin: 0;
font-family: Ubuntu,Helvetica,sans-serif;
}
#container{
margin : 5% 5% 5% 5%;
background-color : white;
border : 2px solid black;
}
h1{
text-align : center;
font-size : 250%;
font-weight: bold;
}
h2{
text-align : center;
font-size : 150%;
font-weight: bold;
}
#bouton_retour{
transform : rotate(45deg);
}
.separation{
margin-top : 5%;
margin-left : 20%;
min-height: 2em;
width : 5px;
background: black;
}
td{
padding-left: 1.5em;
padding-right: 1.5em;
width: 33%;
}
#info{
width: 60%;
}

@ -0,0 +1,56 @@
<?php
session_start();
require_once("../connexionBD.php");
require_once("../ressources/trajet.php");
require_once("../ressources/user.php");
//Si on est pas connecté redirection vers la page de connexion
if (!isset($_SESSION['mail'])) {
header('Location: ../index.php');
exit();
}
$mail = $_SESSION['mail'];
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="liste_trajet_publie.css">
<link rel="stylesheet" href="../ressources/navbarhtml.css">
<link rel="icon" href="../ressources/favicon.ico"/>
<title>Liste des trajets publiés</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 publiés</h1>
<br>
<h2>Trajets publiés : </h2>
</div>
<div id="liste">
<table>
<?php
$result = pg_query_params($db, "SELECT * FROM Trajet Where mailproposition = $1 AND estannule = false;", 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);
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>";
echo "</tr>";
}
?>
</table>
</div>
</div>
</body>
</html>

@ -0,0 +1,18 @@
<?php
require_once ("../connexionBD.php");
require_once ("../ressources/trajet.php");
session_start();
//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($_GET['codetrajet'])){
$codetrajet = $_GET['codetrajet'];
annulerReservation($db, $mail, $codetrajet);
}
header('Location: ../tableauBord/tableauBord.php');
exit();

@ -1,13 +1,7 @@
/*
Crée par PALAFFRE Raphael
Fonction: Lister les trajets recherché
Page PHP : liste.php
*/
body {
color:black;
background-color:white;
background-image:url(../resources/background.jpg);
background-image:url("../ressources/image/background.jpg");
background-repeat:no-repeat;
background-size:104%;
margin: 0;
@ -39,16 +33,13 @@ h2{
.separation{
margin-top : 5%;
margin-left : 20%;
height: 200px;
min-height: 2em;
width : 5px;
background: black;
}
#ligne{
padding-left:10%;
width: 33%;
}
#info{
width: 60%;
td{
padding-left: 1.5em;
padding-right: 1.5em;
width: 25%;
}

@ -1,7 +1,7 @@
<?php
session_start();
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
if (!isset($_SESSION['mail'])) {
@ -16,13 +16,17 @@ $mail = $_SESSION['mail'];
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="liste_trajet_reserve.css">
<link rel="stylesheet" href="../ressources/navbarhtml.css">
<link rel="icon" href="../ressources/favicon.ico"/>
<title>Liste des trajets</title>
<title>Liste des trajets réservés</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="../resources/return.png"
<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 réservés</h1>
<br>
@ -30,15 +34,17 @@ $mail = $_SESSION['mail'];
<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;", 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;", array($mail));
while ($row = pg_fetch_array($result)) {
$login = $row['login'];
$date_depart = $row['datedepart'];
$codetrajet = $row['codetrajet'];
$source = getDepart($db, $codetrajet);
$dest = getFin($db, $codetrajet);
echo "<tr><td class='ligne'><hr class='separation'/></td><td class='info'>";
echo "<p>$date_depart - $source --> $dest : $login</p></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><a href='annulerReservation.php?codetrajet=$codetrajet'>Annuler la reservation</a></td>";
echo "<td><a href='../deposer_avis/deposer_avis.php?codetrajet=$codetrajet'>Déposer un avis</a></td>";
echo "</tr>";
}
?>

@ -1,9 +1,3 @@
/*
Crée par PALAFFRE Raphael
Fonction: Lister les trajets recherché
Page PHP : liste.php
*/
body {
color:black;
background-color:white;

@ -9,11 +9,19 @@ if (!isset($_SESSION['mail'])) {
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)))
@ -50,7 +58,7 @@ require_once("../ressources/navbarhtml.php");
$source = getDepart($db, $codetrajet);
$dest = getFin($db, $codetrajet);
$date_depart = $row['datedepart'];
if (checkPlacesVoiture($db, $codetrajet)){
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>";

@ -1,11 +1,11 @@
<?php
session_start();
function verifierTrajet($db, $mail, $codetrajet){
$trajet = getTrajet($db, $codetrajet);
if (!$trajet){
return false;
}
return checkDatesReserve($db, $mail, $trajet['datedepart']) && checkPlacesVoiture($db, $codetrajet) && strcmp($trajet['mailproposition'], $mail) != 0;
return checkReservations($db, $mail, $codetrajet) && checkDatesReserve($db, $mail, $trajet['datedepart']) && checkPlacesVoiture($db, $codetrajet) && strcmp($trajet['mailproposition'], $mail) != 0;
}
require_once("../connexionBD.php");
@ -23,6 +23,8 @@ if (isset($_GET['codetrajet'])){
reserver($db, $mail, $codetrajet);
}
}
header('Location: ../tableauBord/tableauBord.php');
exit();

@ -4,7 +4,7 @@ require_once('../connexionBD.php');
require_once ('../ressources/verifconnecte.php');
require_once ('../ressources/user.php');
$user = getUser($mail);
$user = getUser($db, $mail);
if(!$user['estadmin']){
header('Location: ../index.php');
exit();
@ -16,9 +16,8 @@ $delmail = isset($_POST['delmail']) ? $_POST['delmail'] : NULL;
<html lang="fr">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="admin.css">
<link rel="stylesheet" href="profil.css">
<link rel="stylesheet" href="../ressources/navbaradminhtml.css">
<link rel="stylesheet" href="../index.css">
<script src="../inscription/inscription.js"></script>
<title>Administration</title>
</head>
@ -39,7 +38,7 @@ $delmail = isset($_POST['delmail']) ? $_POST['delmail'] : NULL;
<td><p><input type="submit" name="deluserbutton" value="supprimer l'utilisateur"></td>
</tr>
<tr>
<td><?php if (isset($_POST['delmail'])) { deluser($delmail); }?></td>
<td><?php if (isset($_POST['delmail'])) { if (deluser($db, $delmail)){ echo "Utilisateur supprimé"; }}?></td>
</tr>
</table>
</form>

@ -1,18 +1,12 @@
<?php
$path = "..";
if (file_exists("./inscription.php")) {
$path = ".";
}
?>
<div id="menuDiv">
<nav id="menu">
<div id="divFlex"><div id="divlogo"><img src="../ressources/logo.png" alt="logo Upssi'Covoit" id="logo"/></div></div>
<a class="menuItem" href="<?php echo $path ; ?>../tableauBord/tableauBord.php">Tableau de bord</a>
<a class="menuItem" href="<?php echo $path ; ?>/inscription.php">Trajets publiés</a>
<a class="menuItem" href="<?php echo $path ; ?>/inscription.php">Trajets réservés</a>
<a class="menuItem" href="<?php echo $path ; ?>../avis_recus/avis_recus.php">Avis reçus</a>
<a class="menuItem" href="<?php echo $path ; ?>../avis_laisses/avis_laisses.php">Avis laissés</a>
<a id="colorAdmin" class="menuItem" href="<?php echo $path ; ?>../profil/admin.php">Administration</a>
<a class="menuItem" href="<?php echo $path ; ?>../deconnexion.php">Se déconnecter</a>
<a class="menuItem" href="../tableauBord/tableauBord.php">Tableau de bord</a>
<a class="menuItem" href="../listeTrajetPublie/liste_trajet_publie.php">Trajets publiés</a>
<a class="menuItem" href="../listeTrajetReserve/liste_trajet_reserve.php">Trajets réservés</a>
<a class="menuItem" href="../avis_recus/avis_recus.php">Avis reçus</a>
<a class="menuItem" href="../avis_laisses/avis_laisses.php">Avis laissés</a>
<a id="colorAdmin" class="menuItem" href="../profil/admin.php">Administration</a>
<a class="menuItem" href="../deconnexion.php">Se déconnecter</a>
</nav>
</div>

@ -1,12 +1,23 @@
<div id="menuDiv">
<nav id="menu">
<div id="divFlex"><div id="divlogo"><img src="../ressources/logo.png" alt="logo Upssi'Covoit" id="logo"/></div></div>
<a class="menuItem" href="../tableauBord/tableauBord.php">Tableau de bord</a>
<a class="menuItem" href="/inscription.php">Trajets publiés</a>
<a class="menuItem" href="../listeTrajetReserve/liste_trajet_reserve.php">Trajets réservés</a>
<a class="menuItem" href="../avis_recus/avis_recus.php">Avis reçus</a>
<a class="menuItem" href="../avis_laisses/avis_laisses.php">Avis laissés</a>
<a class="menuItem" href="../profil/profil.php">Profil</a>
<a class="menuItem" href="../deconnexion.php">Se déconnecter</a>
<?php
require_once ('../connexionBD.php');
require_once ('../ressources/user.php');
require_once ('verifconnecte.php');
if (getUser($db, $mail)['estadmin']){
require_once ('../ressources/navbaradminhtml.php');
}
else {
echo"
<div id='menuDiv'>
<nav id='menu'>
<div id='divFlex'><div id='divlogo'><img src='../ressources/logo.png' alt='logo Upssi'Covoit' id='logo'/></div></div>
<a class='menuItem' href='../tableauBord/tableauBord.php''>Tableau de bord</a>
<a class='menuItem' href='../listeTrajetPublie/liste_trajet_publie.php'>Trajets publiés</a>
<a class='menuItem' href='../listeTrajetReserve/liste_trajet_reserve.php'>Trajets réservés</a>
<a class='menuItem' href='../avis_recus/avis_recus.php'>Avis reçus</a>
<a class='menuItem' href='../avis_laisses/avis_laisses.php'>Avis laissés</a>
<a class='menuItem' href='../profil/profil.php'>Profil</a>
<a class='menuItem' href='../deconnexion.php'>Se déconnecter</a>
</nav>
</div>
</div>";
}
?>

@ -46,20 +46,28 @@ function checkDates($db, $mail, $dateDepart, $dateArrivee)
//Vérifier le nombre de places restantes
function checkPlacesVoiture($db, $codetrajet)
{
$result = pg_query_params($db, "SELECT nbplaces FROM Voiture vo, Trajet ta WHERE vo.mail = ta.mailproposition AND ta.codeTrajet = $1 LIMIT 1;", array($codetrajet));
$result2 = pg_query_params($db, "SELECT COUNT(*) FROM Reserver re, Trajet ta WHERE re.codetrajet.mail = ta.codetrajet AND ta.codetrajet = $1;", array($codetrajet));
$result = pg_query_params($db, "SELECT nbplaces FROM Voiture vo, Trajet ta WHERE vo.matricule = ta.matricule AND ta.codeTrajet = $1;", array($codetrajet));
$result2 = pg_query_params($db, "SELECT COUNT(*) FROM Reserver re, Trajet ta WHERE re.codetrajet = ta.codetrajet AND ta.codetrajet = $1;", array($codetrajet));
if(!$result || !$result2){
return false;
}
$nbplaces = pg_fetch_array($result);
$nbreservations = pg_fetch_array($result);
return $nbplaces-1>$nbreservations;
$nbplaces = pg_fetch_array($result)[0];
$nbreservations = pg_fetch_array($result)[0];
return $nbplaces-1 > $nbreservations;
}
//Vérifier la cohérence des dates
function checkDatesReserve($db, $mail, $dateDepart)
{
$result = pg_query_params($db, "SELECT COUNT(*) From Trajet ta, reserve re WHERE re.mailutilisateur = $1 AND re.codetrajet = ta.codetrajet AND $2 BETWEEN datedepart AND datearrivee;", array($mail, $dateDepart));
$result = pg_query_params($db, "SELECT COUNT(*) From Trajet ta, reserver re WHERE re.mailutilisateur = $1 AND re.codetrajet = ta.codetrajet AND $2 BETWEEN datedepart AND datearrivee;", array($mail, $dateDepart));
$row = pg_fetch_array($result);
return $row[0] == 0;
}
//Verifier reservations
function checkReservations($db, $mail, $codetrajet)
{
$result = pg_query_params($db, "SELECT COUNT(*) From reserver WHERE mailutilisateur = $1 AND codetrajet = $2;", array($mail, $codetrajet));
$row = pg_fetch_array($result);
return $row[0] == 0;
}
@ -84,7 +92,7 @@ function getTrajetsProposes($db, $mail)
function getTrajetsReserves($db, $mail)
{
$result = pg_query_params($db, "SELECT COUNT(*) FROM trajet tr, reserver r WHERE r.codetrajet = tr.codetrajet AND mailutilisateur = $1 AND estAnnule = false AND datedepart >= current_date;", array($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 datedepart >= current_date;", array($mail));
if ($result) {
$row = pg_fetch_array($result);
return $row[0];
@ -162,6 +170,16 @@ function getFin($db, $codetajet)
return $return;
}
function annulerTrajet($db, $codetrajet){
$result = pg_query_params($db, "UPDATE Trajet SET estannule = true WHERE codetrajet = $1;", array($codetrajet));
return $result;
}
function annulerReservation($db, $mail,$codetrajet){
$result = pg_query_params($db, "DELETE FROM reserver WHERE codetrajet = $1 AND mailutilisateur = $2;", array($codetrajet, $mail));
return $result;
}
function getErrorDepotTrajet($code)
{
switch ($code) {

@ -188,27 +188,17 @@ function uploadAvatar($mail, $fic)
function deluser($db, $delmail)
{
/*
$requete = "UPDATE public.utilisateur SET (mail, passwd, prenom, nom, login, telephone, datenaissance, estadmin) = ('utilisateur_supprime@local', '', '', '', 'utilisateur_supprime', '', to_date('1970/01/01','YYYY/MM/DD'), false) WHERE mail = '".$delmail."';";
marche pas
ERROR: duplicate key value violates unique constraint "pk_utilisateur"
DETAIL: Key (mail)=(utilisateur_supprime@local) already exists.
*/
/*
a faire = array('' => , );Delete l'utilisateur du reste de la base
*/
$requete = "UPDATE trajet SET mailproposition = 'utilisateur_supprime@local' WHERE mailproposition = $delmail;";
pg_query($db, $requete);
$requete = "UPDATE reserver SET mailutilisateur = 'utilisateur_supprime@local' WHERE mailutilisateur = $delmail;";
pg_query($db, $requete);
$requete = "DELETE FROM avis WHERE mailemetteur = $delmail;";
pg_query($db, $requete);
$requete = "DELETE FROM voiture WHERE mail = $delmail;";
pg_query($db, $requete);
$requete = "DELETE FROM utilisateur WHERE mail = $delmail;";
pg_query($db, $requete);
$requete = "UPDATE trajet SET mailproposition = $1 WHERE mailproposition = $2;";
$result1 = pg_query_params($db, $requete, array('utilisateur_supprime@local', $delmail));
$requete = "UPDATE reserver SET mailutilisateur = $1 WHERE mailutilisateur = $2;";
$result2 = pg_query_params($db, $requete, array('utilisateur_supprime@local', $delmail));
$requete = "DELETE FROM avis WHERE mailemetteur = $1;";
$result3 = pg_query_params($db, $requete, array($delmail));
$requete = "UPDATE voiture SET mail = $1 WHERE mail = $2;";
$result4 = pg_query_params($db, $requete, array('utilisateur_supprime@local', $delmail));
$requete = "DELETE FROM utilisateur WHERE mail = $1;";
$result5 = pg_query_params($db, $requete, array($delmail));
return $result1 && $result2 && $result3 && $result4 && $result5;
}
?>

Loading…
Cancel
Save