👌 ajout de la fonctionnalité de création d'évènement
Co-authored-by: Charpentier Juliette <juliette.charpentier1@etu.u-pec.fr>
This commit is contained in:
@@ -17,31 +17,52 @@
|
||||
<body>
|
||||
<?php include ($_SERVER['DOCUMENT_ROOT'] . '/views/header.php') ?>
|
||||
|
||||
|
||||
<!-- code de la page ici -->
|
||||
<h1>Évènements</h1>
|
||||
|
||||
|
||||
<!-- <form method="POST"> -->
|
||||
<?php
|
||||
if (isset($_POST['discipline'])) {
|
||||
$selectedDiscipline = $_POST['discipline'];
|
||||
$descriptionResult = mysqli_query($db, "SELECT description FROM `olympic_discipline` WHERE discipline = '$selectedDiscipline'");
|
||||
while ($row = mysqli_fetch_assoc($descriptionResult)) {
|
||||
echo "<p class='text'>" . $row['description'] . "</p>";
|
||||
/*
|
||||
- Sujet:
|
||||
-- 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 +)
|
||||
-- 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...
|
||||
*/
|
||||
|
||||
?>
|
||||
<!-- to do
|
||||
-- s'inscrire à un évènement (rôle membre ou +)
|
||||
-- participer à un évènement (sportif)
|
||||
-- laisser un commentaire (rôle membre ou +)
|
||||
-- afficher la liste des évènements (tout le monde)
|
||||
-- Rechercher un évènement par date, lieu, ou nom
|
||||
-->
|
||||
<div class="searchbar">
|
||||
<form action="search" method="get">
|
||||
</form>
|
||||
<input id="searchbar" name="search" placeholder="Rechercher un évènement" type="text">
|
||||
<button type="submit"><i class="fas fa-search"></i> Rechercher</button>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
if (isset($_COOKIE['userData'])) {
|
||||
if (($role == 'Administrateur') or ($role == 'Organisateur')) {
|
||||
echo "<button class='submit-button new-event' onclick='window.location.href = \'/events/new\';'>Créer un évènement</button>";
|
||||
} else {
|
||||
echo "<p class='text'>Vous n'êtes pas autorisé à créer un évènement.</p>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<form method="POST">
|
||||
<?php
|
||||
$evenement = mysqli_query($db, "SELECT discipline FROM `olympic_discipline` ");
|
||||
echo "<select name='discipline'>";
|
||||
while ($row = mysqli_fetch_assoc($evenement)) {
|
||||
echo "<option>" . $row['discipline'] . "</option>";
|
||||
}
|
||||
echo "</select>";
|
||||
?>
|
||||
<button><input type="submit" value="Afficher la description"></button>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
<?php include ($_SERVER['DOCUMENT_ROOT'] . '/views/footer.php') ?>
|
||||
|
||||
|
52
events/new/eventCreate.php
Normal file
52
events/new/eventCreate.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/tools/dbConnect.php';
|
||||
session_start();
|
||||
|
||||
|
||||
// Traitement des données utilisateur
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$eventName = mysqli_real_escape_string($db, $_POST['eventName']);
|
||||
$eventDate = mysqli_real_escape_string($db, $_POST['eventDate']);
|
||||
$eventLocation = mysqli_real_escape_string($db, $_POST['eventLocation']);
|
||||
$eventDiscipline = mysqli_real_escape_string($db, $_POST['eventDiscipline']);
|
||||
$eventDescription = mysqli_real_escape_string($db, $_POST['eventDescription']);
|
||||
$eventRoles = isset($_POST['eventRole']) ? $_POST['eventRole'] : [];
|
||||
|
||||
// Construction d'une liste de rôles pour l'affichage
|
||||
$rolesText = implode(', ', $eventRoles);
|
||||
|
||||
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'];
|
||||
}
|
||||
// Affichage des informations pour confirmation
|
||||
echo "<p class='text'>Nom de l'évènement : $eventName</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 : $eventDiscipline</p>";
|
||||
echo "<p class='text'>Description de l'évènement : $eventDescription</p>";
|
||||
echo "<p class='text'>Rôles de l'évènement : $rolesText</p>";
|
||||
echo "<p class='text'>Créateur de l'évènement : $email</p>";
|
||||
|
||||
// Requête SQL préparée
|
||||
$stmt = mysqli_prepare($db, "INSERT INTO `event` (title, description, event_type, date, location, role, guest_count, creator) VALUES (?, ?, ?, ?, ?, ?, 0, ?)");
|
||||
mysqli_stmt_bind_param($stmt, 'sssssss', $eventName, $eventDescription, $eventDiscipline, $eventDate, $eventLocation, $rolesText, $email);
|
||||
$result = mysqli_stmt_execute($stmt);
|
||||
|
||||
if ($result) {
|
||||
echo "<p class='text'>L'évènement a bien été créé.</p>";
|
||||
header("Location: /events/new?result=event-creation-succeded");
|
||||
} else {
|
||||
echo "<p class='text'>Une erreur est survenue lors de la création de l'évènement. Erreur : " . mysqli_error($db) . "</p>";
|
||||
header("Location: /events/new?result=event-creation-failed");
|
||||
}
|
||||
} else {
|
||||
echo "<p class='text'>Veuillez remplir tous les champs du formulaire.</p>";
|
||||
}
|
||||
|
||||
?>
|
134
events/new/index.php
Normal file
134
events/new/index.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?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>
|
||||
<script src="/scripts/dateChecker.js" defer></script>
|
||||
<title>Jeux Olympiques - Paris 2024</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php include ($_SERVER['DOCUMENT_ROOT'] . '/views/header.php') ?>
|
||||
|
||||
<?php
|
||||
if (!isset($_COOKIE['userData'])) {
|
||||
echo "<h1>Créer un évènement</h1>";
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
$role = $userData['role'];
|
||||
|
||||
if (($role == 'Administrateur') or ($role == 'Organisateur')) { // Si l'utilisateur est un administrateur : accès à la page
|
||||
echo "<div class='event-create-container'>";
|
||||
echo "<img src='https://cdn-icons-png.flaticon.com/512/2538/2538566.png' alt='Avatar'>";
|
||||
echo "<h2 class='event-create-title'>Créer un nouvel évènement</h2>";
|
||||
echo "<p class='event-create-subtitle'>Remplissez le formulaire suivant afin de créer un nouvel évènement.</p>";
|
||||
echo "<form method='POST' action='/events/new/eventCreate.php'>";
|
||||
echo "<div class='form-group'>";
|
||||
if (isset($_GET['result'])) {
|
||||
if ($_GET['result'] == "event-creation-failed") {
|
||||
echo "<p class='text' style='color:red; padding-left:0; text-align:center;'> ⛔ Une erreur est survenue, l'évènement n'a pas été créé.</p>";
|
||||
} else if ($_GET["result"] == "event-creation-succeded") {
|
||||
echo "<p class='text' style='color:green; padding-left:0; text-align:center;'> ✅ L'évènement a bien été créé.</p>";
|
||||
}
|
||||
}
|
||||
echo "<div class='form-group'>";
|
||||
echo "<label for='eventName'>Nom de l'évènement</label>";
|
||||
echo "<input type='text' name='eventName' id='eventName' required>";
|
||||
echo "</div>";
|
||||
echo "<div class='form-group;
|
||||
<label for='eventDiscipline'>Discipline</label>";
|
||||
echo "<select name='eventDiscipline' id='eventDiscipline'>";
|
||||
$disciplines = mysqli_query($db, "SELECT discipline FROM `olympic_discipline` ");
|
||||
while ($row = mysqli_fetch_assoc($disciplines)) {
|
||||
echo "<option>" . $row['discipline'] . "</option>";
|
||||
}
|
||||
echo "</select>";
|
||||
echo "</div>";
|
||||
echo "<div class='form-group'>;
|
||||
<label for='eventDate'>Date de l'évènement</label>";
|
||||
echo "<input type='date' name='eventDate' id='eventDate' required>";
|
||||
echo "</div>";
|
||||
echo "<div class='form-group'>";
|
||||
echo "<label for='eventLocation'>Lieu de l'évènement<select name='eventLocation' id='eventLocation'>";
|
||||
$locations = mysqli_query($db, "SELECT venue_info FROM `olympic_location` ");
|
||||
while ($row = mysqli_fetch_assoc($locations)) {
|
||||
echo "<option>" . $row['venue_info'] . "</option>";
|
||||
}
|
||||
echo "</select>";
|
||||
echo "</label>";
|
||||
echo "</div>";
|
||||
echo "<div class='form-group'>";
|
||||
echo "<label for='eventDescription'>Description de l'évènement</label>";
|
||||
echo "<input type='textarea' name='eventDescription' id='eventDescription' required>";
|
||||
echo "</div>";
|
||||
echo "<div class='form-group'>";
|
||||
echo "<label for='eventRole'>Rôles pouvant s'inscrire</label>";
|
||||
echo "<div>";
|
||||
echo "<input type='checkbox' name='eventRole[]' id='membre' value='membre'>";
|
||||
echo "<label for='membre'>";
|
||||
echo "<p>Membre</p>";
|
||||
echo "</label>";
|
||||
echo "</div>";
|
||||
echo "<div>";
|
||||
echo "<input type='checkbox' name='eventRole[]' id='sportif' value='sportif'>";
|
||||
echo "<label for='sportif'>";
|
||||
echo "<p>Sportif</p>";
|
||||
echo "</label>";
|
||||
echo "</div>";
|
||||
echo "<div>";
|
||||
echo "<input type='checkbox' name='eventRole[]' id='organisateur' value='organisateur'>";
|
||||
echo "<label for='organisateur'>";
|
||||
echo "<p>Organisateur</p>";
|
||||
echo "</label>";
|
||||
echo "</div>";
|
||||
echo "</div>";
|
||||
echo "<button type='submit' class='submit-button'><i class='fas fa-calendar-plus'></i> Créer</i></button>";
|
||||
echo "</form>";
|
||||
echo "</div>";
|
||||
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=/");
|
||||
include ($_SERVER['DOCUMENT_ROOT'] . '/views/footer.php');
|
||||
die();
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
|
||||
<?php include ($_SERVER['DOCUMENT_ROOT'] . '/views/footer.php') ?>
|
||||
</body>
|
||||
|
||||
</html>
|
116
events/new/indexold.php
Normal file
116
events/new/indexold.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?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') ?>
|
||||
|
||||
|
||||
|
||||
<div class="event-create-container">
|
||||
<img src="https://cdn-icons-png.flaticon.com/512/2538/2538566.png" alt="Avatar">
|
||||
<h2 class="event-create-title">Créer un nouvel évènement</h2>
|
||||
<p class="event-create-subtitle">Remplissez le formulaire suivant afin de créer un nouvel évènement.</p>
|
||||
<form method="POST" action="/events/new/eventCreate.php">
|
||||
<?php
|
||||
if (isset($_GET['result'])) {
|
||||
if ($_GET['result'] == "event-creation-failed") {
|
||||
echo "<p class='text' style='color:red; padding-left:0;'> ⛔ Une erreur est survenue, l'évènement n'a pas été créé.</p>";
|
||||
} else if ($_GET["result"] == "event-creation-succeded") {
|
||||
echo "<p class='text' style='color:green; padding-left:0;'> ✅ L'évènement a bien été créé.</p>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div class="form-group">
|
||||
<label for="eventName">Nom de l'évènement</label>
|
||||
<input type="text" name="eventName" id="eventName" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="eventDiscipline">Discipline</label>
|
||||
<select name="eventDiscipline" id="eventDiscipline">
|
||||
<?php
|
||||
$disciplines = mysqli_query($db, "SELECT discipline FROM `olympic_discipline` ");
|
||||
while ($row = mysqli_fetch_assoc($disciplines)) {
|
||||
echo "<option>" . $row['discipline'] . "</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="eventDate">Date de l'évènement</label>
|
||||
<input type="date" name="eventDate" id="eventDate" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="eventLocation">Lieu de l'évènement<select name="eventLocation" id="eventLocation">
|
||||
<?php
|
||||
$locations = mysqli_query($db, "SELECT venue_info FROM `olympic_location` ");
|
||||
while ($row = mysqli_fetch_assoc($locations)) {
|
||||
echo "<option>" . $row['venue_info'] . "</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="eventDescription">Description de l'évènement</label>
|
||||
<input type="textarea" name="eventDescription" id="eventDescription" required>
|
||||
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="eventRole">Rôles pouvant s'inscrire</label>
|
||||
<div>
|
||||
<input type="checkbox" name="eventRole[]" id="membre" value="membre">
|
||||
<label for="membre">
|
||||
<p>Membre</p>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" name="eventRole[]" id="sportif" value="sportif">
|
||||
<label for="sportif">
|
||||
<p>Sportif</p>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" name="eventRole[]" id="organisateur" value="organisateur">
|
||||
<label for="organisateur">
|
||||
<p>Organisateur</p>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="submit-button"><i class="fas fa-calendar-plus"></i> Créer</i></button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<?php include ($_SERVER['DOCUMENT_ROOT'] . '/views/footer.php') ?>
|
||||
</body>
|
||||
|
||||
</html>
|
Reference in New Issue
Block a user