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:
parent
f959cf865f
commit
fbe4db848e
111
account/profile/myentries/index.php
Normal file
111
account/profile/myentries/index.php
Normal 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>
|
@ -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>
|
||||
<html lang="fr">
|
||||
|
||||
@ -44,25 +57,10 @@
|
||||
-->
|
||||
|
||||
<?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/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>';
|
||||
echo '<button class="new-event" onclick="window.location.href = \'/events/list\';">Rechercher 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
|
||||
@ -106,21 +104,28 @@
|
||||
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 "<th class='event-table-header'>Titre</th>";
|
||||
echo "<th class='event-table-header'>Description</th>";
|
||||
echo "<th class='event-table-header'>Discipline</th>";
|
||||
echo "<th class='event-table-header'>Date</th>";
|
||||
echo "<th class='event-table-header'>Lieu</th>";
|
||||
echo "<th class='event-table-header'>Action</th>";
|
||||
echo "</tr>";
|
||||
echo "</thead>";
|
||||
echo "<tbody>"; // The scrollable body class removed here if not necessary
|
||||
echo "<tbody>";
|
||||
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'>" . date('d/m/Y', strtotime($row['date'])) . "</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 "</tbody>";
|
||||
|
@ -35,143 +35,149 @@ if (isset($_COOKIE['userData'])) {
|
||||
<body>
|
||||
|
||||
<?php include ($_SERVER['DOCUMENT_ROOT'] . '/views/header.php');
|
||||
|
||||
if (isset($_GET['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%'";
|
||||
if (isset($_COOKIE['userData'])) {
|
||||
if (isset($_GET['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);
|
||||
$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) {
|
||||
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 (isset($_GET['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);
|
||||
$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' onclick=\"window.location.href = '/events/participate/participate.php?usermail=$email&event=$eventID';\">Concourir</button>";
|
||||
}
|
||||
echo "</div>";
|
||||
}
|
||||
if ($role == 'Sportif') {
|
||||
echo "<button class='submit-button'>Concourir</button>";
|
||||
}
|
||||
echo "</div>";
|
||||
} else {
|
||||
echo "<p class='text'>Aucun évènement trouvé à la date recherchée.</p>";
|
||||
}
|
||||
} else {
|
||||
echo "<p class='text'>Aucun évènement trouvé à cet endroit.</p>";
|
||||
echo "</div>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isset($_GET['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);
|
||||
$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>";
|
||||
if (isset($_GET['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%'";
|
||||
}
|
||||
} else {
|
||||
echo "<p class='text'>Aucun évènement trouvé à la date recherchée.</p>";
|
||||
}
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
|
||||
if (isset($_GET['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);
|
||||
$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>";
|
||||
$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' onclick=\"window.location.href = '/events/participate/participate.php?usermail=$email&event=$eventID';\">Concourir</button>";
|
||||
}
|
||||
echo "</div>";
|
||||
}
|
||||
if ($role == 'Sportif') {
|
||||
echo "<button class='submit-button'>Concourir</button>";
|
||||
}
|
||||
echo "</div>";
|
||||
} else {
|
||||
echo "<p class='text'>Aucun évènement n'est prévu à ce nom.</p>";
|
||||
}
|
||||
echo "</div>";
|
||||
} else {
|
||||
echo "<p class='text'>Aucun évènement n'est prévu à ce nom.</p>";
|
||||
|
||||
}
|
||||
echo "</div>";
|
||||
} 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>";
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
@ -34,6 +34,17 @@ if (isset($_COOKIE['userData'])) {
|
||||
|
||||
<body>
|
||||
<?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">
|
||||
<img src="https://cdn-icons-png.flaticon.com/512/2538/2538566.png" alt="Avatar">
|
||||
<h2 class="event-title">Afficher les évènements</h2>
|
||||
|
58
events/participate/cancel.php
Normal file
58
events/participate/cancel.php
Normal 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");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -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>
|
63
events/participate/participate.php
Normal file
63
events/participate/participate.php
Normal 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>";
|
||||
}
|
||||
}
|
||||
?>
|
@ -481,7 +481,6 @@ button.new-event:hover {
|
||||
width: 100%; /* Full width of its container */
|
||||
border-collapse: collapse; /* Collapse borders */
|
||||
table-layout: fixed; /* Fixed layout for consistent column sizing */
|
||||
|
||||
font-size: 0.9em;
|
||||
min-width: 400px;
|
||||
}
|
||||
|
108
tools/discordWebhookEntry.php
Normal file
108
tools/discordWebhookEntry.php
Normal 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);
|
||||
?>
|
@ -42,6 +42,9 @@ if (isset($_COOKIE['userData'])) {
|
||||
if ($role != 'Administrateur') {
|
||||
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>
|
||||
@ -68,7 +71,9 @@ if (isset($_COOKIE['userData'])) {
|
||||
<div class="row">
|
||||
<div class="col-md-8 col-sm-6 col-xs-12">
|
||||
<p class="copyright-text">Copyright © 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>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -85,6 +85,9 @@ if (isset($_COOKIE['userData'])) {
|
||||
if ($role != 'Administrateur') {
|
||||
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>
|
||||
|
Loading…
Reference in New Issue
Block a user