SAE_web/events/list/display/index.php
2024-06-15 00:51:32 +02:00

151 lines
6.5 KiB
PHP

<?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($_GET['location'])) {
$location = htmlspecialchars($_GET['location']);
echo "<h2>Évènements à $location</h2>";
$query = "SELECT * FROM event WHERE location = '$location'";
$result = mysqli_query($db, $query);
echo "<div class='events-flex-container'>";
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$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);
$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) : $role</p>";
echo "<p class='text'>$description</p>";
echo "</div>";
}
} else {
echo "<p class='text'>Aucun évènement trouvé à $location</p>";
}
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'";
$result = mysqli_query($db, $query);
echo "<div class='events-flex-container'>";
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$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);
$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) : $role</p>";
echo "<p class='text'>$description</p>";
echo "</div>";
}
} else {
echo "<p class='text'>Aucun évènement trouvé le" . $date_fr . ".</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'";
$result = mysqli_query($db, $query);
echo "<div class='events-flex-container'>";
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$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);
$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) : $role</p>";
echo "<p class='text'>$description</p>";
echo "<button class='book-button'>S'inscrire</button>"; // Add the button here
echo "</div>";
}
} else {
echo "<p class='text'>Aucun évènement n'est prévu à ce nom.</p>";
}
echo "</div>";
} else {
}
echo "</div>";
?>
<!-- code de la page ici -->
<?php include ($_SERVER['DOCUMENT_ROOT'] . '/views/footer.php') ?>
</body>
</html>