SAE_web/events/index.php

145 lines
5.8 KiB
PHP
Raw Normal View History

2024-05-28 15:40:57 +02:00
<!DOCTYPE html>
2024-05-28 19:47:51 +02:00
<html lang="fr">
2024-05-28 15:40:57 +02:00
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
2024-05-29 14:13:05 +02:00
<link rel="stylesheet" href="../styles/main.css" />
<link rel="stylesheet" href="../styles/header.css" />
<link rel="stylesheet" href="../styles/footer.css" />
2024-05-28 15:40:57 +02:00
<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" />
<title>Évènements | Jeux Olympiques - Paris 2024</title>
</head>
<body>
<?php include ($_SERVER['DOCUMENT_ROOT'] . '/views/header.php') ?>
2024-05-28 15:40:57 +02:00
<!-- code de la page ici -->
<h1>Évènements</h1>
<?php
/*
- Sujet:
-- Créer un évènement (rôle organisateur ou admin)
-- afficher la liste des évènements (tout le monde)
-- Rechercher un évènement par date, lieu, ou nom
-- s'inscrire à un évènement (rôle membre ou +)
-- participer à un évènement (sportif)
-- laisser un commentaire (rôle membre ou +)
-- Trier les évènements par date, nombre de participants, personnes y ayant accès, etc...
*/
?>
<!-- to do
-- Créer un évènement (rôle organisateur ou admin)
-- 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\';">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>';
} 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
// 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>";
?>
2024-05-28 15:40:57 +02:00
<?php include ($_SERVER['DOCUMENT_ROOT'] . '/views/footer.php') ?>
2024-05-28 15:40:57 +02:00
2024-05-28 15:40:57 +02:00
</body>
</html>