Ajout de la fonctionnalité de vue de tous les évènements. Ajout de la réservation d'un évènement. Fix incomplet de la modification d'un utilisateur. CSS.
Co-authored-by: Charpentier Juliette <juliette.charpentier1@etu.u-pec.fr
This commit is contained in:
@@ -3,8 +3,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/tools/dbConnect.php';
|
||||
session_start();
|
||||
|
||||
if (isset($_COOKIE['userData'])) {
|
||||
$userDataEncoded = $_COOKIE['userData'];
|
||||
$userData = json_decode($userDataEncoded, true); // 'true' pour obtenir un tableau associatif
|
||||
$userData = json_decode($_COOKIE['userData'], true);
|
||||
|
||||
$email = $userData['email'];
|
||||
$name = $userData['name'];
|
||||
@@ -12,12 +11,51 @@ if (isset($_COOKIE['userData'])) {
|
||||
$role = $userData['role'];
|
||||
}
|
||||
|
||||
// un utilisateur a cliqué sur le bouton "S'inscrire" d'un évènement
|
||||
|
||||
|
||||
if (isset($_GET['usermail']) && isset($_GET['event'])) {
|
||||
$userEmail = $_GET['usermail'];
|
||||
$eventId = $_GET['event'];
|
||||
|
||||
$stmt = mysqli_prepare($db, "SELECT * FROM event WHERE id = ?");
|
||||
mysqli_stmt_bind_param($stmt, "i", $eventId);
|
||||
mysqli_stmt_execute($stmt);
|
||||
$result = mysqli_stmt_get_result($stmt);
|
||||
$eventDetails = mysqli_fetch_assoc($result);
|
||||
|
||||
if ($eventDetails) {
|
||||
$eventTitle = $eventDetails["title"];
|
||||
$eventDescription = $eventDetails["description"];
|
||||
$eventType = $eventDetails["event_type"];
|
||||
$eventDate = $eventDetails["date"];
|
||||
$eventLocation = $eventDetails["location"];
|
||||
|
||||
echo "<p class='text'>Vous vous apprêtez à vous inscrire à l'évènement suivant : </p>";
|
||||
echo "<p class='text'>Nom de l'évènement : $eventTitle</p>";
|
||||
echo "<p class='text'>Date de l'évènement : $eventDate</p>";
|
||||
echo "<p class='text'>Lieu de l'évènement : $eventLocation</p>";
|
||||
echo "<p class='text'>Discipline de l'évènement : $eventType</p>";
|
||||
echo "<p class='text'>Description de l'évènement : $eventDescription</p>";
|
||||
echo "<p class='text'>Adresse mail de l'utilisateur : $userEmail</p>";
|
||||
|
||||
$stmt = mysqli_prepare($db, "INSERT INTO booking (id, mail, title, description, event_type, date, location) VALUES (?, ?, ?, ?, ?, ?, ?)");
|
||||
mysqli_stmt_bind_param($stmt, "issssss", $eventId, $userEmail, $eventTitle, $eventDescription, $eventType, $eventDate, $eventLocation);
|
||||
if (mysqli_stmt_execute($stmt)) {
|
||||
echo "<p class='text'>Votre inscription à l'évènement $eventTitle a bien été prise en compte.</p>";
|
||||
|
||||
$stmt = mysqli_prepare($db, "UPDATE event SET guest_count = guest_count + 1 WHERE id = ?");
|
||||
mysqli_stmt_bind_param($stmt, "i", $eventId);
|
||||
if (mysqli_stmt_execute($stmt)) {
|
||||
echo "<p class='text'>Le nombre de participants a été mis à jour.</p>";
|
||||
include $_SERVER['DOCUMENT_ROOT'] . '/tools/discordWebhookBooking.php';
|
||||
header("Location: /account/profile/myevents?res=booking-succeeded");
|
||||
} else {
|
||||
echo "<p class='text'>Erreur lors de la mise à jour du nombre de participants.</p>";
|
||||
}
|
||||
} else {
|
||||
echo "<p class='text'>Une erreur est survenue lors de votre inscription à l'évènement. Erreur : " . mysqli_error($db) . "</p>";
|
||||
header("Location: /account/profile/myevents?res=booking-failed");
|
||||
}
|
||||
} else {
|
||||
echo "<p class='text'>Évènement introuvable.</p>";
|
||||
}
|
||||
}
|
||||
?>
|
61
events/book/cancel.php
Normal file
61
events/book/cancel.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/tools/dbConnect.php';
|
||||
session_start();
|
||||
|
||||
if (isset($_COOKIE['userData'])) {
|
||||
$userData = json_decode($_COOKIE['userData'], true);
|
||||
|
||||
$email = $userData['email'];
|
||||
$name = $userData['name'];
|
||||
$familyName = $userData['familyName'];
|
||||
$role = $userData['role'];
|
||||
}
|
||||
|
||||
if (isset($_GET['usermail']) && isset($_GET['id'])) {
|
||||
$userEmail = $_GET['usermail'];
|
||||
$eventId = $_GET['id'];
|
||||
|
||||
$stmt = mysqli_prepare($db, "SELECT * FROM booking WHERE id = ? AND mail = ?");
|
||||
mysqli_stmt_bind_param($stmt, "is", $eventId, $userEmail);
|
||||
mysqli_stmt_execute($stmt);
|
||||
$result = mysqli_stmt_get_result($stmt);
|
||||
$eventDetails = mysqli_fetch_assoc($result);
|
||||
|
||||
if ($eventDetails) {
|
||||
$eventTitle = $eventDetails["title"];
|
||||
$eventDescription = $eventDetails["description"];
|
||||
$eventType = $eventDetails["event_type"];
|
||||
$eventDate = $eventDetails["date"];
|
||||
$eventLocation = $eventDetails["location"];
|
||||
|
||||
echo "<p class='text'>Vous vous apprêtez à annuler votre inscription à l'évènement suivant : </p>";
|
||||
echo "<p class='text'>Nom de l'évènement : $eventTitle</p>";
|
||||
echo "<p class='text'>Date de l'évènement : $eventDate</p>";
|
||||
echo "<p class='text'>Lieu de l'évènement : $eventLocation</p>";
|
||||
echo "<p class='text'>Discipline de l'évènement : $eventType</p>";
|
||||
echo "<p class='text'>Description de l'évènement : $eventDescription</p>";
|
||||
echo "<p class='text'>Adresse mail de l'utilisateur : $userEmail</p>";
|
||||
|
||||
$stmt = mysqli_prepare($db, "DELETE FROM booking WHERE id = ? AND mail = ?");
|
||||
mysqli_stmt_bind_param($stmt, "is", $eventId, $userEmail);
|
||||
if (mysqli_stmt_execute($stmt)) {
|
||||
|
||||
|
||||
echo "<p class='text'>Votre annulation à l'évènement $eventTitle a bien été prise en compte.</p>";
|
||||
|
||||
$stmt = mysqli_prepare($db, "UPDATE event SET guest_count = guest_count - 1 WHERE id = ?");
|
||||
mysqli_stmt_bind_param($stmt, "i", $eventId);
|
||||
if (mysqli_stmt_execute($stmt)) {
|
||||
echo "<p class='text'>Le nombre de participants a été mis à jour.</p>";
|
||||
include $_SERVER['DOCUMENT_ROOT'] . '/tools/discordWebhookBooking.php';
|
||||
header("Location: /account/profile/myevents?res=cancellation-succeeded&eventtitle=$eventTitle");
|
||||
} else {
|
||||
echo "<p class='text'>Erreur lors de la mise à jour du nombre de participants.</p>";
|
||||
}
|
||||
} else {
|
||||
echo "<p class='text'>Une erreur est survenue lors de votre annulation à l'évènement. Erreur : " . mysqli_error($db) . "</p>";
|
||||
header("Location: /account/profile/myevents?res=cancellation-failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
@@ -34,33 +34,101 @@
|
||||
?>
|
||||
<!-- to do
|
||||
-- Créer un évènement (rôle organisateur ou admin) ✅
|
||||
-- s'inscrire à un évènement (rôle membre ou +)
|
||||
-- participer à un évènement (sportif)
|
||||
-- laisser un commentaire (rôle membre ou +)
|
||||
-- s'inscrire à un évènement (rôle membre ou +)✅
|
||||
-- afficher la liste des évènements (tout le monde) ✅
|
||||
-- Rechercher un évènement par date, lieu, ou nom ✅
|
||||
-- Trier les évènements par date, nombre de participants, personnes y ayant accès, etc...✅
|
||||
-- participer à un évènement (sportif)
|
||||
-- sécuriser les pages avec actions administratives
|
||||
|
||||
-->
|
||||
|
||||
<?php
|
||||
if (isset($_COOKIE['userData'])) {
|
||||
if (($role == 'Administrateur') or ($role == 'Organisateur')) {
|
||||
echo '<button class="new-event" onclick="window.location.href = \'/events/new\';">Créer un évènement</button>';
|
||||
echo '<button class="new-event" onclick="window.location.href = \'/events/list\';">Consulter la liste des évènements</button>';
|
||||
echo '<button class="new-event" onclick="window.location.href = \'/events/list\';">Rechercher un évènement</button>';
|
||||
|
||||
} else if ($role == 'Sportif') {
|
||||
echo '<button class="new-event" onclick="window.location.href = \'/events/participate\';">Participer à un évènement</button>';
|
||||
echo '<button class="new-event" onclick="window.location.href = \'/events/list\';">Consulter la liste des évènements</button>';
|
||||
echo '<button class="new-event" onclick="window.location.href = \'/events/list\';">Rechercher un évènement</button>';
|
||||
echo '<button class="new-event" onclick="window.location.href = \'/events/book\';">Réserver un évènement</button>';
|
||||
|
||||
} else {
|
||||
echo '<button class="new-event" onclick="window.location.href = \'/events/list\';">Consulter la liste des évènements</button>';
|
||||
echo '<button class="new-event" onclick="window.location.href = \'/events/list\';">Rechercher un évènement</button>';
|
||||
}
|
||||
echo '<button class="new-event" onclick="window.location.href = \'/events/book\';">S\'inscrire un évènement</button>';
|
||||
echo '<button class="new-event" onclick="window.location.href = \'/events/book\';">Réserver un évènement</button>';
|
||||
|
||||
} else {
|
||||
echo '<button class="new-event" onclick="window.location.href = \'/events/list\';">Consulter la liste des évènements</button>';
|
||||
echo '<button class="new-event" onclick="window.location.href = \'/events/list\';">Rechercher un évènement</button>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
// faire une requete sql avec mysqli permettant d'afficher tous les évènements
|
||||
// afficher les évènements sous forme de tableau
|
||||
// voici les colonnes disponibles dans la table event
|
||||
// id title description event_type date location role guest_count creator
|
||||
|
||||
|
||||
$query = "SELECT * FROM event";
|
||||
|
||||
if (isset($_GET['sort'])) {
|
||||
$sort = $_GET['sort'];
|
||||
switch ($sort) {
|
||||
case 'date':
|
||||
$query .= " ORDER BY date";
|
||||
break;
|
||||
case 'location':
|
||||
$query .= " ORDER BY location";
|
||||
break;
|
||||
case 'discipline':
|
||||
$query .= " ORDER BY event_type";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Menu déroulant pour sélectionner le tri
|
||||
echo "<form method='GET' action='' class='order-by'>";
|
||||
echo "<label for='sort' class='text'>Trier par:</label>";
|
||||
echo "<select name='sort' id='sort' onchange='this.form.submit()'>";
|
||||
echo "<option value=''>Aucun</option>";
|
||||
echo "<option value='date' " . ($sort == 'date' ? 'selected' : '') . ">Date</option>";
|
||||
echo "<option value='location' " . ($sort == 'location' ? 'selected' : '') . ">Lieu</option>";
|
||||
echo "<option value='discipline' " . ($sort == 'discipline' ? 'selected' : '') . ">Discipline</option>";
|
||||
echo "</select>";
|
||||
echo "</form>";
|
||||
$result = mysqli_query($db, $query);
|
||||
echo "<div class='events-flex-container'>";
|
||||
echo "<div class='scrollable'>";
|
||||
echo "<table class='event-table'>";
|
||||
echo "<thead>"; // En-tête du tableau
|
||||
echo "<tr>";
|
||||
echo "<th class='event-table-header'>Titre</th>"; // Ensure class name matches with the CSS
|
||||
echo "<th class='event-table-header'>Description</th>"; // Ensure class name matches with the CSS
|
||||
echo "<th class='event-table-header'>Discipline</th>"; // Ensure class name matches with the CSS
|
||||
echo "<th class='event-table-header'>Date</th>"; // Ensure class name matches with the CSS
|
||||
echo "<th class='event-table-header'>Lieu</th>"; // Ensure class name matches with the CSS
|
||||
echo "</tr>";
|
||||
echo "</thead>";
|
||||
echo "<tbody>"; // The scrollable body class removed here if not necessary
|
||||
while ($row = mysqli_fetch_array($result)) {
|
||||
echo "<tr>";
|
||||
echo "<td class='event-table-data'>" . htmlspecialchars($row['title']) . "</td>";
|
||||
echo "<td class='event-table-data'>" . htmlspecialchars($row['description']) . "</td>";
|
||||
echo "<td class='event-table-data'>" . htmlspecialchars($row['event_type']) . "</td>";
|
||||
echo "<td class='event-table-data'>" . htmlspecialchars($row['date']) . "</td>";
|
||||
echo "<td class='event-table-data'>" . htmlspecialchars($row['location']) . "</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</tbody>";
|
||||
echo "</table>";
|
||||
echo "</div>";
|
||||
echo "</div>";
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
@@ -37,19 +37,24 @@ if (isset($_COOKIE['userData'])) {
|
||||
<?php include ($_SERVER['DOCUMENT_ROOT'] . '/views/header.php');
|
||||
|
||||
if (isset($_GET['location'])) {
|
||||
$location = htmlspecialchars($_GET['location']);
|
||||
echo "<h2>Évènements à $location</h2>";
|
||||
$query = "SELECT * FROM event WHERE location = '$location'";
|
||||
$location = $_GET['location'];
|
||||
echo "<h2>Évènements à $location pour les $role" . "s" . "</h2>";
|
||||
if ($role == 'Administrateur') {
|
||||
$query = "SELECT * FROM event WHERE location = '$location'";
|
||||
} else {
|
||||
$query = "SELECT * FROM event WHERE location = '$location' AND role LIKE '%$role%'";
|
||||
}
|
||||
$result = mysqli_query($db, $query);
|
||||
echo "<div class='events-flex-container'>";
|
||||
if (mysqli_num_rows($result) > 0) {
|
||||
while ($row = mysqli_fetch_assoc($result)) {
|
||||
$eventID = htmlspecialchars($row['id'], ENT_QUOTES);
|
||||
$title = htmlspecialchars($row['title'], ENT_QUOTES, 'UTF-8');
|
||||
$description = htmlspecialchars($row['description'], ENT_QUOTES);
|
||||
$event_type = htmlspecialchars($row['event_type'], ENT_QUOTES);
|
||||
$date = date('d/m/Y', strtotime(htmlspecialchars($row['date'])));
|
||||
$location = htmlspecialchars($row['location'], ENT_QUOTES);
|
||||
$role = htmlspecialchars($row['role'], ENT_QUOTES);
|
||||
$authorized_roles = htmlspecialchars($row['role'], ENT_QUOTES);
|
||||
$guest_count = htmlspecialchars($row['guest_count'], ENT_QUOTES);
|
||||
$creator = htmlspecialchars($row['creator'], ENT_QUOTES);
|
||||
echo "<div class='event-card'>";
|
||||
@@ -58,33 +63,44 @@ if (isset($_COOKIE['userData'])) {
|
||||
echo "<p class='text'>Date : $date</p>";
|
||||
echo "<p class='text'>Lieu : $location</p>";
|
||||
echo "<p class='text'>Nombre de participants : $guest_count</p>";
|
||||
echo "<p class='text'>(Roles autorisés) : $role</p>";
|
||||
echo "<p class='text'>(Roles autorisés) : $authorized_roles</p>";
|
||||
echo "<p class='text'>$description</p>";
|
||||
|
||||
if ($role != 'Administrateur') {
|
||||
if ($role != 'Administrateur') {
|
||||
echo "<button class='submit-button' onclick=\"window.location.href = '/events/book/book.php?usermail=$email&event=$eventID';\">Réserver une place</button>";
|
||||
}
|
||||
}
|
||||
if ($role == 'Sportif') {
|
||||
echo "<button class='submit-button'>Concourir</button>";
|
||||
}
|
||||
echo "</div>";
|
||||
|
||||
}
|
||||
} else {
|
||||
echo "<p class='text'>Aucun évènement trouvé à $location</p>";
|
||||
echo "<p class='text'>Aucun évènement trouvé à cet endroit.</p>";
|
||||
echo "</div>";
|
||||
}
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
|
||||
if (isset($_GET['date'])) {
|
||||
$date = htmlspecialchars($_GET['date']);
|
||||
$date_fr = date('d/m/Y', strtotime($date));
|
||||
echo "<h2>Évènements le $date_fr</h2>";
|
||||
$query = "SELECT * FROM event WHERE date = '$date'";
|
||||
$date = $_GET['date'];
|
||||
echo "<h2>Évènements le $date pour $role</h2>";
|
||||
if ($role == 'Administrateur') {
|
||||
$query = "SELECT * FROM event WHERE date = '$date'";
|
||||
} else {
|
||||
$query = "SELECT * FROM event WHERE date = '$date' AND role LIKE '%$role%'";
|
||||
}
|
||||
$result = mysqli_query($db, $query);
|
||||
echo "<div class='events-flex-container'>";
|
||||
if (mysqli_num_rows($result) > 0) {
|
||||
while ($row = mysqli_fetch_assoc($result)) {
|
||||
$eventID = htmlspecialchars($row['id'], ENT_QUOTES);
|
||||
$title = htmlspecialchars($row['title'], ENT_QUOTES);
|
||||
$description = htmlspecialchars($row['description'], ENT_QUOTES);
|
||||
$event_type = htmlspecialchars($row['event_type'], ENT_QUOTES);
|
||||
$date = date('d/m/Y', strtotime(htmlspecialchars($row['date'])));
|
||||
$location = htmlspecialchars($row['location'], ENT_QUOTES);
|
||||
$role = htmlspecialchars($row['role'], ENT_QUOTES);
|
||||
$authorized_roles = htmlspecialchars($row['role'], ENT_QUOTES);
|
||||
$guest_count = htmlspecialchars($row['guest_count'], ENT_QUOTES);
|
||||
$creator = htmlspecialchars($row['creator'], ENT_QUOTES);
|
||||
echo "<div class='event-card'>";
|
||||
@@ -93,31 +109,42 @@ if (isset($_COOKIE['userData'])) {
|
||||
echo "<p class='text'>Date : $date</p>";
|
||||
echo "<p class='text'>Lieu : $location</p>";
|
||||
echo "<p class='text'>Nombre de participants : $guest_count</p>";
|
||||
echo "<p class='text'>(Roles autorisés) : $role</p>";
|
||||
echo "<p class='text'>(Roles autorisés) : $authorized_roles</p>";
|
||||
echo "<p class='text'>$description</p>";
|
||||
if ($role != 'Administrateur') {
|
||||
echo "<button class='submit-button' onclick=\"window.location.href = '/events/book/book.php?usermail=$email&event=$eventID';\">Réserver une place</button>";
|
||||
}
|
||||
if ($role == 'Sportif') {
|
||||
echo "<button class='submit-button'>Concourir</button>";
|
||||
}
|
||||
echo "</div>";
|
||||
}
|
||||
} else {
|
||||
echo "<p class='text'>Aucun évènement trouvé le" . $date_fr . ".</p>";
|
||||
echo "<p class='text'>Aucun évènement trouvé à la date recherchée.</p>";
|
||||
}
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
|
||||
if (isset($_GET['title'])) {
|
||||
$title = htmlspecialchars($_GET['title']);
|
||||
echo "<h2>Évènement intitulé " . $title . "</h2>";
|
||||
$query = "SELECT * FROM event WHERE title = '$title'";
|
||||
$title = $_GET['title'];
|
||||
echo "<h2>Évènement intitulé \"$title\"</h2>";
|
||||
if ($role == 'Administrateur') {
|
||||
$query = "SELECT * FROM event WHERE title = '$title'";
|
||||
} else {
|
||||
$query = "SELECT * FROM event WHERE title = '$title' AND role LIKE '%$role%'";
|
||||
}
|
||||
$result = mysqli_query($db, $query);
|
||||
echo "<div class='events-flex-container'>";
|
||||
if (mysqli_num_rows($result) > 0) {
|
||||
while ($row = mysqli_fetch_assoc($result)) {
|
||||
$eventID = htmlspecialchars($row['id'], ENT_QUOTES);
|
||||
$title = htmlspecialchars($row['title'], ENT_QUOTES);
|
||||
$description = htmlspecialchars($row['description'], ENT_QUOTES);
|
||||
$event_type = htmlspecialchars($row['event_type'], ENT_QUOTES);
|
||||
$date = date('d/m/Y', strtotime(htmlspecialchars($row['date'])));
|
||||
$location = htmlspecialchars($row['location'], ENT_QUOTES);
|
||||
$role = htmlspecialchars($row['role'], ENT_QUOTES);
|
||||
$authorized_roles = htmlspecialchars($row['role'], ENT_QUOTES);
|
||||
$guest_count = htmlspecialchars($row['guest_count'], ENT_QUOTES);
|
||||
$creator = htmlspecialchars($row['creator'], ENT_QUOTES);
|
||||
echo "<div class='event-card'>";
|
||||
@@ -126,9 +153,14 @@ if (isset($_COOKIE['userData'])) {
|
||||
echo "<p class='text'>Date : $date</p>";
|
||||
echo "<p class='text'>Lieu : $location</p>";
|
||||
echo "<p class='text'>Nombre de participants : $guest_count</p>";
|
||||
echo "<p class='text'>(Roles autorisés) : $role</p>";
|
||||
echo "<p class='text'>(Roles autorisés) : $authorized_roles</p>";
|
||||
echo "<p class='text'>$description</p>";
|
||||
echo "<button class='book-button'>S'inscrire</button>"; // Add the button here
|
||||
if ($role != 'Administrateur') {
|
||||
echo "<button class='submit-button' onclick=\"window.location.href = '/events/book/book.php?usermail=$email&event=$eventID';\">Réserver une place</button>";
|
||||
}
|
||||
if ($role == 'Sportif') {
|
||||
echo "<button class='submit-button'>Concourir</button>";
|
||||
}
|
||||
echo "</div>";
|
||||
}
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user