ajout de la fonctionnalité de participation d'un sportif. Fix du header et footer en conséquence.

Co-authored-by: Charpentier Juliette <juliette.charpentier1@etu.u-pec.fr>
This commit is contained in:
Loris BALOCCHI 2024-06-16 12:14:04 +02:00
parent f959cf865f
commit fbe4db848e
11 changed files with 512 additions and 192 deletions

View File

@ -0,0 +1,111 @@
<?php
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
$email = $userData['email'];
$name = $userData['name'];
$familyName = $userData['familyName'];
$role = $userData['role'];
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="/styles/main.css" />
<link rel="stylesheet" href="/styles/header.css" />
<link rel="stylesheet" href="/styles/footer.css" />
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet" />
<link rel="icon" type="image/png" sizes="32x32"
href="https://tickets.paris2024.org/obj/media/FR-Paris2024/specialLogos/favicons/favicon-32x32.png" />
<script src="https://kit.fontawesome.com/f16a36bad3.js" crossorigin="anonymous"></script>
<title>Jeux Olympiques - Paris 2024</title>
</head>
<body>
<?php include $_SERVER['DOCUMENT_ROOT'] . '/views/header.php';
if (!isset($_COOKIE['userData'])) {
echo "<p class='text'>Vous n'êtes pas autorisé à accéder à cette page.</p>";
echo "<p class='text'>Redirection vers l'accueil dans 5 secondes...</p>";
header("refresh:5; url=/");
include $_SERVER['DOCUMENT_ROOT'] . '/views/footer.php';
die();
} ?>
<h1>Mes participations</h1>
<?php echo "<p class='text'>Bienvenue <span>" . $name . " " . $familyName . ".</span></p>";
?>
<!-- code de la page ici -->
<?php
if (isset($_GET['res'])) {
if ($_GET['res'] == "entry-succeeded") {
echo "<p class='text'>✅ Votre participation a bien été prise en compte.</p>";
} else if ($_GET['res'] == "entry-failed") {
echo "<p class='text'>❌ La participation a échoué. Veuillez réessayer.</p>";
} else if ($_GET['res'] == "entry-cancellation-failed") {
echo "<p class='text'>❌ La participation a échoué. Veuillez réessayer.</p>";
} else if ($_GET['res'] == "entry-cancellation-succeeded") {
$eventTitleFetched = $_GET['eventtitle'];
echo "<p class='text'>✅ L'annulation de votre participation à l'évènement \"$eventTitleFetched\" a bien été prise en compte.</p>";
}
}
//afficher la liste des évènements auxquels l'utilisateur est inscrit (avec mysqli) (table booking)
$stmt = mysqli_prepare($db, "SELECT * FROM event_entries WHERE mail = ?");
mysqli_stmt_bind_param($stmt, "s", $email);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
if (mysqli_num_rows($result) == 0) {
echo "<p class='text'>Vous ne participez à aucun évènement.</p>";
} else {
echo "<p class='text'>Voici la liste des évènements auxquels vous êtes inscrit :</p>";
echo "<div class='events-flex-container'>";
echo "<div class='scrollable'>";
echo "<table class='event-table'>";
echo "<thead>";
echo "<tr>";
echo "<th scope='col'>Nom de l'évènement</th>";
echo "<th scope='col'>Date</th>";
;
echo "<th scope='col'>Lieu</th>";
echo "<th scope='col'>Action</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
// sélectionner les évènements auxquels l'utilisateur est inscrit (avec mysqli et à l'aide de $email) (utiliser cette requete ? SELECT * FROM booking WHERE mail="$email";)
while ($booking = mysqli_fetch_assoc($result)) {
$eventID = $booking['id'];
$stmt = mysqli_prepare($db, "SELECT * FROM event WHERE id = ?");
mysqli_stmt_bind_param($stmt, "i", $eventID);
mysqli_stmt_execute($stmt);
$eventResult = mysqli_stmt_get_result($stmt);
$event = mysqli_fetch_assoc($eventResult);
echo "<tr>";
echo "<td>" . $event['title'] . "</td>";
echo "<td>" . date('d/m/Y', strtotime($event['date'])) . "</td>";
echo "<td>" . $event['location'] . "</td>";
echo "<td><a href='/events/book/cancel.php?usermail=$email&id=" . $event['id'] . "'>Annuler</a></td>";
echo "</tr>";
}
echo "</table>";
echo "</div>";
echo "</div>";
}
//echo "<td><a href='/events/book/cancel.php?id=" . $event['id'] . "'>Annuler</a></td>";
?>
<?php include ($_SERVER['DOCUMENT_ROOT'] . '/views/footer.php') ?>
</body>
</html>

View File

@ -1,3 +1,16 @@
<?php
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
$email = $userData['email'];
$name = $userData['name'];
$familyName = $userData['familyName'];
$role = $userData['role'];
}
?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="fr"> <html lang="fr">
@ -44,25 +57,10 @@
--> -->
<?php <?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\';">Rechercher un évènement</button>';
} else if ($role == 'Sportif') { 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/participate\';">Participer à un évènement</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\';">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\';">Rechercher un évènement</button>';
}
// faire une requete sql avec mysqli permettant d'afficher tous les évènements // faire une requete sql avec mysqli permettant d'afficher tous les évènements
@ -106,21 +104,28 @@
echo "<table class='event-table'>"; echo "<table class='event-table'>";
echo "<thead>"; // En-tête du tableau echo "<thead>"; // En-tête du tableau
echo "<tr>"; echo "<tr>";
echo "<th class='event-table-header'>Titre</th>"; // Ensure class name matches with the CSS echo "<th class='event-table-header'>Titre</th>";
echo "<th class='event-table-header'>Description</th>"; // Ensure class name matches with the CSS echo "<th class='event-table-header'>Description</th>";
echo "<th class='event-table-header'>Discipline</th>"; // Ensure class name matches with the CSS echo "<th class='event-table-header'>Discipline</th>";
echo "<th class='event-table-header'>Date</th>"; // Ensure class name matches with the CSS echo "<th class='event-table-header'>Date</th>";
echo "<th class='event-table-header'>Lieu</th>"; // Ensure class name matches with the CSS echo "<th class='event-table-header'>Lieu</th>";
echo "<th class='event-table-header'>Action</th>";
echo "</tr>"; echo "</tr>";
echo "</thead>"; echo "</thead>";
echo "<tbody>"; // The scrollable body class removed here if not necessary echo "<tbody>";
while ($row = mysqli_fetch_array($result)) { while ($row = mysqli_fetch_array($result)) {
echo "<tr>"; echo "<tr>";
echo "<td class='event-table-data'>" . htmlspecialchars($row['title']) . "</td>"; 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['description']) . "</td>";
echo "<td class='event-table-data'>" . htmlspecialchars($row['event_type']) . "</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'>" . date('d/m/Y', strtotime($row['date'])) . "</td>";
echo "<td class='event-table-data'>" . htmlspecialchars($row['location']) . "</td>"; echo "<td class='event-table-data'>" . htmlspecialchars($row['location']) . "</td>";
// mettre un bouton réserver si l'utilisateur est connecté et un bouton participer si l'utilisateur est un sportif
if (isset($_COOKIE['userData'])) {
if ($role == 'Sportif') {
echo "<td class='event-table-data'><button class='submit-button' onclick='window.location.href=\"/events/participate/participate.php?usermail=$email&id=" . $row['id'] . "\"'>Participer</button></td>";
}
}
echo "</tr>"; echo "</tr>";
} }
echo "</tbody>"; echo "</tbody>";

View File

@ -35,143 +35,149 @@ if (isset($_COOKIE['userData'])) {
<body> <body>
<?php include ($_SERVER['DOCUMENT_ROOT'] . '/views/header.php'); <?php include ($_SERVER['DOCUMENT_ROOT'] . '/views/header.php');
if (isset($_COOKIE['userData'])) {
if (isset($_GET['location'])) { if (isset($_GET['location'])) {
$location = $_GET['location']; $location = $_GET['location'];
echo "<h2>Évènements à $location pour les $role" . "s" . "</h2>"; echo "<h2>Évènements à $location pour les $role" . "s" . "</h2>";
if ($role == 'Administrateur') { if ($role == 'Administrateur') {
$query = "SELECT * FROM event WHERE location = '$location'"; $query = "SELECT * FROM event WHERE location = '$location'";
} else { } else {
$query = "SELECT * FROM event WHERE location = '$location' AND role LIKE '%$role%'"; $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);
$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'>";
echo "<h3>$title</h3>";
echo "<p class='text'>Type d'évènement : $event_type</p>";
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) : $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' onclick=\"window.location.href = '/events/participate/participate.php?usermail=$email&event=$eventID';\">Concourir</button>";
}
echo "</div>";
}
} else {
echo "<p class='text'>Aucun évènement trouvé à cet endroit.</p>";
echo "</div>";
}
} }
$result = mysqli_query($db, $query);
echo "<div class='events-flex-container'>";
if (mysqli_num_rows($result) > 0) { if (isset($_GET['date'])) {
while ($row = mysqli_fetch_assoc($result)) { $date = $_GET['date'];
$eventID = htmlspecialchars($row['id'], ENT_QUOTES); echo "<h2>Évènements le $date pour $role</h2>";
$title = htmlspecialchars($row['title'], ENT_QUOTES, 'UTF-8'); if ($role == 'Administrateur') {
$description = htmlspecialchars($row['description'], ENT_QUOTES); $query = "SELECT * FROM event WHERE date = '$date'";
$event_type = htmlspecialchars($row['event_type'], ENT_QUOTES); } else {
$date = date('d/m/Y', strtotime(htmlspecialchars($row['date']))); $query = "SELECT * FROM event WHERE date = '$date' AND role LIKE '%$role%'";
$location = htmlspecialchars($row['location'], ENT_QUOTES); }
$authorized_roles = htmlspecialchars($row['role'], ENT_QUOTES); $result = mysqli_query($db, $query);
$guest_count = htmlspecialchars($row['guest_count'], ENT_QUOTES); echo "<div class='events-flex-container'>";
$creator = htmlspecialchars($row['creator'], ENT_QUOTES); if (mysqli_num_rows($result) > 0) {
echo "<div class='event-card'>"; while ($row = mysqli_fetch_assoc($result)) {
echo "<h3>$title</h3>"; $eventID = htmlspecialchars($row['id'], ENT_QUOTES);
echo "<p class='text'>Type d'évènement : $event_type</p>"; $title = htmlspecialchars($row['title'], ENT_QUOTES);
echo "<p class='text'>Date : $date</p>"; $description = htmlspecialchars($row['description'], ENT_QUOTES);
echo "<p class='text'>Lieu : $location</p>"; $event_type = htmlspecialchars($row['event_type'], ENT_QUOTES);
echo "<p class='text'>Nombre de participants : $guest_count</p>"; $date = date('d/m/Y', strtotime(htmlspecialchars($row['date'])));
echo "<p class='text'>(Roles autorisés) : $authorized_roles</p>"; $location = htmlspecialchars($row['location'], ENT_QUOTES);
echo "<p class='text'>$description</p>"; $authorized_roles = htmlspecialchars($row['role'], ENT_QUOTES);
if ($role != 'Administrateur') { $guest_count = htmlspecialchars($row['guest_count'], ENT_QUOTES);
$creator = htmlspecialchars($row['creator'], ENT_QUOTES);
echo "<div class='event-card'>";
echo "<h3>$title</h3>";
echo "<p class='text'>Type d'évènement : $event_type</p>";
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) : $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>"; 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' onclick=\"window.location.href = '/events/participate/participate.php?usermail=$email&event=$eventID';\">Concourir</button>";
}
echo "</div>";
} }
if ($role == 'Sportif') { } else {
echo "<button class='submit-button'>Concourir</button>"; echo "<p class='text'>Aucun évènement trouvé à la date recherchée.</p>";
}
echo "</div>";
} }
} else {
echo "<p class='text'>Aucun évènement trouvé à cet endroit.</p>";
echo "</div>"; echo "</div>";
} }
}
if (isset($_GET['date'])) { if (isset($_GET['title'])) {
$date = $_GET['date']; $title = $_GET['title'];
echo "<h2>Évènements le $date pour $role</h2>"; echo "<h2>Évènement intitulé \"$title\"</h2>";
if ($role == 'Administrateur') { if ($role == 'Administrateur') {
$query = "SELECT * FROM event WHERE date = '$date'"; $query = "SELECT * FROM event WHERE title = '$title'";
} else { } else {
$query = "SELECT * FROM event WHERE date = '$date' AND role LIKE '%$role%'"; $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);
$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'>";
echo "<h3>$title</h3>";
echo "<p class='text'>Type d'évènement : $event_type</p>";
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) : $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 { $result = mysqli_query($db, $query);
echo "<p class='text'>Aucun évènement trouvé à la date recherchée.</p>"; echo "<div class='events-flex-container'>";
} if (mysqli_num_rows($result) > 0) {
echo "</div>"; while ($row = mysqli_fetch_assoc($result)) {
} $eventID = htmlspecialchars($row['id'], ENT_QUOTES);
$title = htmlspecialchars($row['title'], ENT_QUOTES);
$description = htmlspecialchars($row['description'], ENT_QUOTES);
if (isset($_GET['title'])) { $event_type = htmlspecialchars($row['event_type'], ENT_QUOTES);
$title = $_GET['title']; $date = date('d/m/Y', strtotime(htmlspecialchars($row['date'])));
echo "<h2>Évènement intitulé \"$title\"</h2>"; $location = htmlspecialchars($row['location'], ENT_QUOTES);
if ($role == 'Administrateur') { $authorized_roles = htmlspecialchars($row['role'], ENT_QUOTES);
$query = "SELECT * FROM event WHERE title = '$title'"; $guest_count = htmlspecialchars($row['guest_count'], ENT_QUOTES);
} else { $creator = htmlspecialchars($row['creator'], ENT_QUOTES);
$query = "SELECT * FROM event WHERE title = '$title' AND role LIKE '%$role%'"; echo "<div class='event-card'>";
} echo "<h3>$title</h3>";
$result = mysqli_query($db, $query); echo "<p class='text'>Type d'évènement : $event_type</p>";
echo "<div class='events-flex-container'>"; echo "<p class='text'>Date : $date</p>";
if (mysqli_num_rows($result) > 0) { echo "<p class='text'>Lieu : $location</p>";
while ($row = mysqli_fetch_assoc($result)) { echo "<p class='text'>Nombre de participants : $guest_count</p>";
$eventID = htmlspecialchars($row['id'], ENT_QUOTES); echo "<p class='text'>(Roles autorisés) : $authorized_roles</p>";
$title = htmlspecialchars($row['title'], ENT_QUOTES); echo "<p class='text'>$description</p>";
$description = htmlspecialchars($row['description'], ENT_QUOTES); if ($role != 'Administrateur') {
$event_type = htmlspecialchars($row['event_type'], ENT_QUOTES); echo "<button class='submit-button' onclick=\"window.location.href = '/events/book/book.php?usermail=$email&event=$eventID';\">Réserver une place</button>";
$date = date('d/m/Y', strtotime(htmlspecialchars($row['date']))); }
$location = htmlspecialchars($row['location'], ENT_QUOTES); if ($role == 'Sportif') {
$authorized_roles = htmlspecialchars($row['role'], ENT_QUOTES); echo "<button class='submit-button' onclick=\"window.location.href = '/events/participate/participate.php?usermail=$email&event=$eventID';\">Concourir</button>";
$guest_count = htmlspecialchars($row['guest_count'], ENT_QUOTES); }
$creator = htmlspecialchars($row['creator'], ENT_QUOTES); echo "</div>";
echo "<div class='event-card'>";
echo "<h3>$title</h3>";
echo "<p class='text'>Type d'évènement : $event_type</p>";
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) : $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') { } else {
echo "<button class='submit-button'>Concourir</button>"; echo "<p class='text'>Aucun évènement n'est prévu à ce nom.</p>";
}
echo "</div>";
} }
echo "</div>";
} else { } else {
echo "<p class='text'>Aucun évènement n'est prévu à ce nom.</p>";
} }
echo "</div>"; echo "</div>";
} else { } else {
echo "<p class='text'>Vous n'êtes pas autorisé à accéder à cette page.</p>";
echo "<p class='text'>Redirection vers l'accueil dans 5 secondes...</p>";
header("refresh:5; url=/");
die();
} }
echo "</div>";
?> ?>

View File

@ -34,6 +34,17 @@ if (isset($_COOKIE['userData'])) {
<body> <body>
<?php include $_SERVER['DOCUMENT_ROOT'] . '/views/header.php' ?> <?php include $_SERVER['DOCUMENT_ROOT'] . '/views/header.php' ?>
<?php
if (!isset($_COOKIE['userData'])) {
echo "<p class='text'>Vous n'êtes pas autorisé à accéder à cette page.</p>";
echo "<p class='text'>Redirection vers l'accueil dans 5 secondes...</p>";
header("refresh:5; url=/");
include $_SERVER['DOCUMENT_ROOT'] . '/views/footer.php';
die();
}
?>
<div class="event-container"> <div class="event-container">
<img src="https://cdn-icons-png.flaticon.com/512/2538/2538566.png" alt="Avatar"> <img src="https://cdn-icons-png.flaticon.com/512/2538/2538566.png" alt="Avatar">
<h2 class="event-title">Afficher les évènements</h2> <h2 class="event-title">Afficher les évènements</h2>

View File

@ -0,0 +1,58 @@
<?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 event_entries 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 participation à 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>";
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");
}
}
?>

View File

@ -1,49 +0,0 @@
<?php
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
$email = $userData['email'];
$name = $userData['name'];
$familyName = $userData['familyName'];
$role = $userData['role'];
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="/styles/main.css" />
<link rel="stylesheet" href="/styles/header.css" />
<link rel="stylesheet" href="/styles/footer.css" />
<link
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
rel="stylesheet"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="https://tickets.paris2024.org/obj/media/FR-Paris2024/specialLogos/favicons/favicon-32x32.png"
/>
<script
src="https://kit.fontawesome.com/f16a36bad3.js"
crossorigin="anonymous"
></script>
<title>Jeux Olympiques - Paris 2024</title>
</head>
<body>
<?php include ($_SERVER['DOCUMENT_ROOT'] . '/views/header.php') ?>
<!-- code de la page ici -->
<?php include($_SERVER['DOCUMENT_ROOT'].'/views/footer.php')?>
</body>
</html>

View File

@ -0,0 +1,63 @@
<?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'];
} else {
echo "<p class='text'>Vous n'êtes pas autorisé à accéder à cette page.</p>";
echo "<p class='text'>Redirection vers l'accueil dans 5 secondes...</p>";
header("refresh:5; url=/");
die();
}
if (isset($_GET['usermail']) && isset($_GET['id'])) {
$userEmail = $_GET['usermail'];
$eventId = $_GET['id'];
$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 à participer à 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 event_entries (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>";
header("Location: /account/profile/myentries?res=entry-succeeded");
die();
} 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/myentries?res=entry-failed");
die();
}
} else {
echo "<p class='text'>Évènement introuvable.</p>";
}
}
?>

View File

@ -481,7 +481,6 @@ button.new-event:hover {
width: 100%; /* Full width of its container */ width: 100%; /* Full width of its container */
border-collapse: collapse; /* Collapse borders */ border-collapse: collapse; /* Collapse borders */
table-layout: fixed; /* Fixed layout for consistent column sizing */ table-layout: fixed; /* Fixed layout for consistent column sizing */
font-size: 0.9em; font-size: 0.9em;
min-width: 400px; min-width: 400px;
} }

View File

@ -0,0 +1,108 @@
<?php
// Code fork depuis https://stackoverflow.com/a/51748785
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
$email = $userData['email'];
$name = $userData['name'];
$familyName = $userData['familyName'];
$role = $userData['role'];
}
$url = "https://ptb.discord.com/api/webhooks/1251837084176748544/0ja_5_UgSHxkrtWwW5b4ViduBuBVbX5-OSPwigE5jQD6XRFH0Kwv6qKaNhDd1lKLMS_v";
$hookObject = json_encode([
"content" => "## ✅ Nouvelle participation à un évènement ! \n@here",
"username" => "Jeux Olympiques - Paris 2024",
"avatar_url" => "https://i.imgur.com/gg5xPa1.png",
"tts" => false,
"embeds" => [
[
"title" => "Jeux Olympiques - Paris 2024",
"type" => "rich",
"description" => "",
"url" => "https://but.lbalocchi.fr/",
"timestamp" => date('c', time()),
"color" => hexdec("F4B400"),
"footer" => [
"text" => "© Juliette & Loris - 2024",
"icon_url" => "https://tickets.paris2024.org/obj/media/FR-Paris2024/specialLogos/favicons/favicon-32x32.png"
],
"image" => [
"url" => "https://www.fromagersdefrance.com/wp-content/uploads/2023/03/1200px-Logo_JO_dete_-_Paris_2024.svg__0.png"
],
"author" => [
"name" => "Juliette & Loris",
"url" => "https://stackoverflow.com/a/51748785",
],
// Field array of objects
"fields" => [
[
"name" => "Nom",
"value" => $name,
"inline" => true
],
[
"name" => "Prénom",
"value" => $familyName,
"inline" => true
],
[
"name" => "Email",
"value" => $email,
"inline" => true
],
[
"name" => "Rôle",
"value" => $role,
"inline" => true
],
[
"name" => "Évènement",
"value" => $eventTitle,
"inline" => true
],
[
"name" => "Date",
"value" => $eventDate,
"inline" => true
],
[
"name" => "Lieu",
"value" => $eventLocation,
"inline" => true
],
[
"name" => "Type",
"value" => $eventType,
"inline" => true
],
[
"name" => "Description",
"value" => $eventDescription,
"inline" => true
]
]
]
]
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $hookObject,
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
]
]);
$response = curl_exec($ch);
curl_close($ch);
?>

View File

@ -42,6 +42,9 @@ if (isset($_COOKIE['userData'])) {
if ($role != 'Administrateur') { if ($role != 'Administrateur') {
echo "<li><a href='/account/profile/myevents'>Mes réservations</a></li>"; echo "<li><a href='/account/profile/myevents'>Mes réservations</a></li>";
} }
if ($role == 'Sportif') {
echo "<li><a href='/account/profile/myentries'>Mes participations</a></li>";
}
} }
?> ?>
</ul> </ul>
@ -68,7 +71,9 @@ if (isset($_COOKIE['userData'])) {
<div class="row"> <div class="row">
<div class="col-md-8 col-sm-6 col-xs-12"> <div class="col-md-8 col-sm-6 col-xs-12">
<p class="copyright-text">Copyright &copy; 2024 <p class="copyright-text">Copyright &copy; 2024
<a href="#">Juliette & Loris</a>. <a href="https://grond.iut-fbleau.fr/charpentj">Juliette</a>
<a> & </a>
<a href="https://grond.iut-fbleau.fr/balocchi">Loris</a>
</p> </p>
</div> </div>
</div> </div>

View File

@ -85,6 +85,9 @@ if (isset($_COOKIE['userData'])) {
if ($role != 'Administrateur') { if ($role != 'Administrateur') {
echo "<li><a href='/account/profile/myevents'>Mes réservations</a></li>"; echo "<li><a href='/account/profile/myevents'>Mes réservations</a></li>";
} }
if ($role == 'Sportif') {
echo "<li><a href='/account/profile/myentries'>Mes participations</a></li>";
}
} }
?> ?>
</ul> </ul>