commencement ajout des boutons de création et modification
This commit is contained in:
parent
536c31908b
commit
45fed444e9
2 changed files with 15 additions and 8 deletions
|
|
@ -7,7 +7,7 @@ $page = 'photos';
|
||||||
/* Gestion de la connexion */
|
/* Gestion de la connexion */
|
||||||
session_start();
|
session_start();
|
||||||
if (!isset($_SESSION['connected']) || $_SESSION['connected'] == false) {
|
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']);
|
$events = getEvenements($bdd, $_SESSION['site']);
|
||||||
|
|
@ -19,6 +19,7 @@ $site = $_SESSION['site'];
|
||||||
/* Gestion de l'accès à la page */
|
/* Gestion de l'accès à la page */
|
||||||
$minPoids = 45;
|
$minPoids = 45;
|
||||||
if (!verifyPoids($bdd, $_SESSION['username'], $minPoids)) {
|
if (!verifyPoids($bdd, $_SESSION['username'], $minPoids)) {
|
||||||
|
die("Vous n'avez pas l'autorisation");
|
||||||
header('location: ../index.php');
|
header('location: ../index.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -70,6 +71,9 @@ $uploadDir = "../Photos/INTRANET/";
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
</div>
|
</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>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ include("../Assets/functions.php");
|
||||||
|
|
||||||
$config = json_decode(file_get_contents("../Assets/config.json"), true);
|
$config = json_decode(file_get_contents("../Assets/config.json"), true);
|
||||||
$bdd = connectBDD("localhost", $config["BDD_USER"], $config["BDD_PASSWD"], $config["BDD_NAME"]);
|
$bdd = connectBDD("localhost", $config["BDD_USER"], $config["BDD_PASSWD"], $config["BDD_NAME"]);
|
||||||
$page = 'photos';
|
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
|
|
@ -19,19 +18,16 @@ if (!verifyPoids($bdd, $_SESSION['username'], $minPoids)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$eventId = $_GET['id'] ?? null;
|
$eventId = $_GET['id'] ?? null;
|
||||||
if (!$eventId) {
|
|
||||||
die("ID évènement manquant.");
|
|
||||||
}
|
|
||||||
$titre = getEventName($bdd, $eventId) ?? '';
|
$titre = getEventName($bdd, $eventId) ?? '';
|
||||||
$couverture = getEventBigImage($bdd, $eventId) ?? '';
|
$couverture = getEventBigImage($bdd, $eventId) ?? '';
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && (!$_POST['new'] ?? '')) {
|
||||||
if (!empty($_POST['title'])) {
|
if (!empty($_POST['title'])) {
|
||||||
updateEventTitle($bdd, $eventId, trim($_POST['title']));
|
updateEventTitle($bdd, $eventId, trim($_POST['title']));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($_FILES['couverture']['name'])) {
|
if (!empty($_FILES['couverture']['name'])) {
|
||||||
$uploadDir = "../uploads/";
|
$uploadDir = "../Photos/INTRANET/";
|
||||||
$fileTmpPath = $_FILES["couverture"]["tmp_name"];
|
$fileTmpPath = $_FILES["couverture"]["tmp_name"];
|
||||||
$fileSize = $_FILES["couverture"]["size"];
|
$fileSize = $_FILES["couverture"]["size"];
|
||||||
|
|
||||||
|
|
@ -59,6 +55,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
header("Location: ?id=" . $eventId);
|
header("Location: ?id=" . $eventId);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
if($_POST['new'] ?? ''){
|
||||||
|
//
|
||||||
|
die('test');
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
@ -140,7 +140,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label">Image actuelle</label><br>
|
<label class="form-label">Image actuelle</label><br>
|
||||||
<?php if (!empty($couverture)) : ?>
|
<?php if (!empty($couverture)) : ?>
|
||||||
<img src="../uploads/<?= htmlspecialchars($couverture) ?>"
|
<img src="../Photos/INTRANET/<?= htmlspecialchars($couverture) ?>"
|
||||||
style="max-width:300px; margin-bottom:15px;">
|
style="max-width:300px; margin-bottom:15px;">
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
<p class="text-muted">Aucune image définie</p>
|
<p class="text-muted">Aucune image définie</p>
|
||||||
|
|
@ -160,6 +160,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
class="form-control"
|
class="form-control"
|
||||||
accept="image/*">
|
accept="image/*">
|
||||||
</div>
|
</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">
|
<button type="submit" class="btn btn-primary">
|
||||||
Enregistrer les modifications
|
Enregistrer les modifications
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue