commencement ajout des boutons de création et modification

This commit is contained in:
Erwann PHILIPPE 2026-03-05 17:26:45 +01:00
parent 536c31908b
commit 45fed444e9
2 changed files with 15 additions and 8 deletions

View file

@ -7,7 +7,7 @@ $page = 'photos';
/* Gestion de la connexion */
session_start();
if (!isset($_SESSION['connected']) || $_SESSION['connected'] == false) {
header('location: login.php?redirect_to=./admin/');
header('location: ../login.php?redirect_to=./admin/');
}
$events = getEvenements($bdd, $_SESSION['site']);
@ -19,6 +19,7 @@ $site = $_SESSION['site'];
/* Gestion de l'accès à la page */
$minPoids = 45;
if (!verifyPoids($bdd, $_SESSION['username'], $minPoids)) {
die("Vous n'avez pas l'autorisation");
header('location: ../index.php');
}
@ -70,6 +71,9 @@ $uploadDir = "../Photos/INTRANET/";
<?php endforeach ?>
</div>
<button type="button" class="btn btn-primary" style="position: fixed; bottom: 20px; right: 20px;" onclick="window.location.href='./modifyEvent.php'">Créer évènement</button>
<button type="button" class="btn btn-danger" style="position: fixed; bottom: 20px;" onclick="window.location.href=''">Supprimer</button>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body>

View file

@ -3,7 +3,6 @@ include("../Assets/functions.php");
$config = json_decode(file_get_contents("../Assets/config.json"), true);
$bdd = connectBDD("localhost", $config["BDD_USER"], $config["BDD_PASSWD"], $config["BDD_NAME"]);
$page = 'photos';
session_start();
@ -19,19 +18,16 @@ if (!verifyPoids($bdd, $_SESSION['username'], $minPoids)) {
}
$eventId = $_GET['id'] ?? null;
if (!$eventId) {
die("ID évènement manquant.");
}
$titre = getEventName($bdd, $eventId) ?? '';
$couverture = getEventBigImage($bdd, $eventId) ?? '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if ($_SERVER['REQUEST_METHOD'] === 'POST' && (!$_POST['new'] ?? '')) {
if (!empty($_POST['title'])) {
updateEventTitle($bdd, $eventId, trim($_POST['title']));
}
if (!empty($_FILES['couverture']['name'])) {
$uploadDir = "../uploads/";
$uploadDir = "../Photos/INTRANET/";
$fileTmpPath = $_FILES["couverture"]["tmp_name"];
$fileSize = $_FILES["couverture"]["size"];
@ -59,6 +55,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
header("Location: ?id=" . $eventId);
exit;
}
if($_POST['new'] ?? ''){
//
die('test');
}
?>
<!DOCTYPE html>
@ -140,7 +140,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
<div class="mb-3">
<label class="form-label">Image actuelle</label><br>
<?php if (!empty($couverture)) : ?>
<img src="../uploads/<?= htmlspecialchars($couverture) ?>"
<img src="../Photos/INTRANET/<?= htmlspecialchars($couverture) ?>"
style="max-width:300px; margin-bottom:15px;">
<?php else : ?>
<p class="text-muted">Aucune image définie</p>
@ -160,6 +160,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
class="form-control"
accept="image/*">
</div>
<?php if(!($_POST['new'] ?? '')):?>
<input type="text" name="new" id="new" value="new" disabled style="display: none;">
<?php endif?>
<button type="submit" class="btn btn-primary">
Enregistrer les modifications