From 2f3ca4cbde990c197b3567a6970da7d13a6f5216 Mon Sep 17 00:00:00 2001 From: Baptiste Date: Thu, 16 Jun 2022 22:52:20 +0200 Subject: [PATCH] admin planning --- admin/gestion_des_acces.php | 2 +- admin/planning.php | 137 ++++++++++++++++++++++++++++++++++++ admin/stats.php | 2 +- 3 files changed, 139 insertions(+), 2 deletions(-) diff --git a/admin/gestion_des_acces.php b/admin/gestion_des_acces.php index 3f47d5c..8dcf744 100644 --- a/admin/gestion_des_acces.php +++ b/admin/gestion_des_acces.php @@ -5,7 +5,7 @@ if($user['perm'] < 2) { header('Location: deco.php'); } -if(isset($_GET['del']) AND !empty(['del'])) +if(isset($_GET['del']) AND !empty($_GET['del'])) { if($user['perm'] >= 2) { $del = (int) htmlspecialchars($_GET['del']); diff --git a/admin/planning.php b/admin/planning.php index 3e88607..bddeb24 100644 --- a/admin/planning.php +++ b/admin/planning.php @@ -5,6 +5,54 @@ if($user['perm'] < 1) { header('Location: deco.php'); } +$req = $db->query('SELECT * FROM planning_insa'); + +if(isset($_GET['del']) AND !empty($_GET['del'])) +{ + if($user['perm'] >= 1) { + $del = (int) htmlspecialchars($_GET['del']); + + $req = $db->prepare('DELETE FROM planning_insa WHERE id =?'); + $req->execute(array($del)); + header('Location: planning.php'); + } +} + +if(isset($_GET['select']) AND !empty($_GET['select'])) +{ + $select = (int) htmlspecialchars($_GET['select']); + $req = $db->prepare('SELECT * FROM planning_insa WHERE num_planning = ?'); + $req->execute(array($select)); +} + +$req2 = $db->query('SELECT num_planning FROM planning_insa'); +$tab = []; +$length = 0; +while($h = $req2->fetch()) { + array_push($tab, $h['num_planning']); + $length++; +} +$tab = array_unique($tab); //supprimer les doublons + +if(isset($_POST['send'])) { + if($user['perm'] >= 1) { + if(isset($_POST['day']) AND !empty($_POST['day']) AND isset($_POST['title']) AND !empty($_POST['title']) AND isset($_POST['description']) AND !empty($_POST['description']) AND isset($_POST['color']) AND !empty($_POST['color']) AND isset($_POST['order_start']) AND !empty($_POST['order_start']) AND isset($_POST['length']) AND !empty($_POST['length']) AND isset($_POST['num_planning']) AND !empty($_POST['num_planning'])) { + $day = (int) htmlspecialchars($_POST['day']); + $title = htmlspecialchars($_POST['title']); + $desc = htmlspecialchars($_POST['description']); + $color = htmlspecialchars($_POST['color']); + $order_start = (int) htmlspecialchars($_POST['order_start']); + $len = (int) htmlspecialchars($_POST['length']); + $num_planning = (int) htmlspecialchars($_POST['num_planning']); + + $req = $db->prepare("INSERT INTO planning_insa(day, title, description, color, order_start, length, num_planning) VALUES(?, ?, ?, ?, ?, ?, ?)"); + $req->execute(array($day, $title, $desc, $color, $order_start, $len, $num_planning)); + header('refresh:0'); + } else { + $error = "Tout les champs doivent être complétés"; + } + } +} ?> @@ -15,6 +63,95 @@ if($user['perm'] < 1) {
+
+ + + + + + + + +


+ + '; + } + } + ?> +

+ + + + + + + + + + + + + fetch()) { + ?> + + + + + + + + + + + + +
ID (db)JourTitreDescriptionCouleurOrdre d'apparitiontaille (%)Planning n°Action
%X
\ No newline at end of file diff --git a/admin/stats.php b/admin/stats.php index b5d4f8a..1249bf4 100644 --- a/admin/stats.php +++ b/admin/stats.php @@ -4,7 +4,7 @@ include "script.php"; $req = $db->query('SELECT id, texte, points, team, id_staff FROM scores'); -if(isset($_GET['del']) AND !empty(['del'])) +if(isset($_GET['del']) AND !empty($_GET['del'])) { $del = (int) htmlspecialchars($_GET['del']);