diff --git a/functions/listProject.php b/functions/listProject.php index 42422e7..daa1983 100644 --- a/functions/listProject.php +++ b/functions/listProject.php @@ -11,7 +11,7 @@ function listeProjets() { // Essayer try { // Requête SQL qui récupère titre, tags, description, image_url - $stmt = $dbh->prepare('SELECT title, tags, description, image_url FROM projects'); + $stmt = $dbh->prepare('SELECT id, title, tags, description, image_url FROM projects ORDER BY id DESC'); // Execution de la requête SQL $stmt->execute(); // Retourne toutes les données collectés dans un ARRAY @@ -22,6 +22,22 @@ function listeProjets() { } } +// Fonction qui permet de récupérer les projets par id et donc de modifier une xp en particulier en ciblant l'id +function recupererProjetParId($id) { + global $dbh; + + try { + $stmt = $dbh->prepare('SELECT id, title, tags, description, image_url FROM projects WHERE id = :id'); + $stmt->bindValue(':id', $id, PDO::PARAM_INT); + $stmt->execute(); + return $stmt->fetch(PDO::FETCH_ASSOC); + // En cas d'erreur retourner false et envoyer un message d'erreur avec l'erreur + } catch (PDOException $e) { + die("Erreur de connexion à la base de donnée portfolio :" . $e->getMessage()); + return false; + } +} + // Fonction qui va afficher les projets function afficherProjets() { // Récupération de la liste des projets @@ -74,4 +90,56 @@ function afficherProjets() { } echo ''; -} \ No newline at end of file +} + +// Fonction identique à celle en haut mais ajout de bouton +function afficherProjetsAdmin() { + $projets = listeProjets(); + + echo '
Type : ' . $xptype . '
'; + echo 'Durée : ' . $duration . '
'; + + if (!empty($tags)) { + echo ''; + } + + echo '' . $description . '
'; + + // Boutons qui vont permettrent la modification / Suppresion + echo ''; + + echo 'Vous êtes administrateur, vous pouvez modifier les projets ici.
"; +} // Affichages des projets ?> diff --git a/pages/xp.php b/pages/xp.php index df8ca4f..c6f1703 100644 --- a/pages/xp.php +++ b/pages/xp.php @@ -5,6 +5,11 @@ // On ajoute le header require_once('../elements/header.php'); +// Ajout d'un message indiquant si l'utilisateur est admin qu'il peut modifier ces expériences +if (isset($_SESSION['role']) && $_SESSION['role'] === 'admin') { + echo "Vous êtes administrateur, vous pouvez modifier les experiences ici.
"; +} + // Affichages des projets ?> diff --git a/scripts/removeProject.php b/scripts/removeProject.php new file mode 100644 index 0000000..9dd4c15 --- /dev/null +++ b/scripts/removeProject.php @@ -0,0 +1,31 @@ +prepare('DELETE FROM projects WHERE id = :id'); + $stmt->bindValue(':id', $id, PDO::PARAM_INT); + $stmt->execute(); // Sinon on renvoie l'erreur +} catch (PDOException $e) { + die("Erreur lors de la suppression du projet :" . $e->getMessage()); +} +// On renvoie l'utilisateur sur admin.php +header('Location: ../pages/admin.php'); +exit; \ No newline at end of file diff --git a/scripts/removeXP.php b/scripts/removeXP.php new file mode 100644 index 0000000..6949a7a --- /dev/null +++ b/scripts/removeXP.php @@ -0,0 +1,31 @@ +prepare('DELETE FROM experiences WHERE id = :id'); + $stmt->bindValue(':id', $id, PDO::PARAM_INT); + $stmt->execute(); // Sinon on renvoie l'erreur +} catch (PDOException $e) { + die("Erreur lors de la suppression de l experience :" . $e->getMessage()); +} +// On renvoie l'utilisateur sur admin.php +header('Location: ../pages/admin.php'); +exit; \ No newline at end of file diff --git a/scripts/updateProject.php b/scripts/updateProject.php new file mode 100644 index 0000000..5458127 --- /dev/null +++ b/scripts/updateProject.php @@ -0,0 +1,47 @@ +prepare(' + UPDATE projects + SET title = :title, tags = :tags, description = :description, image_url = :image_url + WHERE id = :id + '); + $stmt->bindValue(':title', $title, PDO::PARAM_STR); + $stmt->bindValue(':tags', $tags, PDO::PARAM_STR); + $stmt->bindValue(':description', $description, PDO::PARAM_STR); + $stmt->bindValue(':image_url', $imageurl, PDO::PARAM_STR); + $stmt->bindValue(':id', $id, PDO::PARAM_INT); + $stmt->execute(); // Sinon on renvoie l'erreur +} catch (PDOException $e) { + die("Erreur lors de la modification du projet :" . $e->getMessage()); +} +// On renvoie l'utilisateur sur admin.php +header('Location: ../pages/admin.php'); +exit; \ No newline at end of file diff --git a/scripts/updateXP.php b/scripts/updateXP.php new file mode 100644 index 0000000..618a1a6 --- /dev/null +++ b/scripts/updateXP.php @@ -0,0 +1,54 @@ +prepare(' + UPDATE experiences + SET title = :title, xptype = :xptype, tags = :tags, description = :description, duration = :duration, image_url = :image_url + WHERE id = :id + '); + $stmt->bindValue(':title', $title, PDO::PARAM_STR); + $stmt->bindValue(':xptype', $xptype, PDO::PARAM_STR); + $stmt->bindValue(':tags', $tags, PDO::PARAM_STR); + $stmt->bindValue(':description', $description, PDO::PARAM_STR); + $stmt->bindValue(':duration', $duration, PDO::PARAM_STR); + $stmt->bindValue(':image_url', $imageurl, PDO::PARAM_STR); + $stmt->bindValue(':id', $id, PDO::PARAM_INT); + $stmt->execute(); // Sinon on renvoie l'erreur +} catch (PDOException $e) { + die("Erreur lors de la modification de l experience :" . $e->getMessage()); +} +// On renvoie l'utilisateur sur admin.php +header('Location: ../pages/admin.php'); +exit; \ No newline at end of file diff --git a/styles/primary_css.css b/styles/primary_css.css index b46fabd..0853663 100644 --- a/styles/primary_css.css +++ b/styles/primary_css.css @@ -38,6 +38,11 @@ nav a { border-radius: 8px; } +nav a:hover { + background-color: #1a1a24; + color: white; +} + /* ---- PAGE LOGIN ---- */ /* Centre la carte au milieu de la page */ @@ -117,7 +122,7 @@ nav a { .project-container { display: flex; justify-content: center; - padding: 40px 20px; + padding: 10px 20px; } .project-form-card { @@ -126,10 +131,12 @@ nav a { border-radius: 12px; padding: 30px; width: 800px; + max-width: 100%; } .project-header h2 { margin-top: 0; + margin-bottom: 20px; font-size: 20px; display: flex; align-items: center; @@ -173,10 +180,12 @@ nav a { border-radius: 6px; color: white; padding: 12px; + margin-bottom: 16px; box-sizing: border-box; } -.project-card textarea { +/* Correction ici : project-form-card au lieu de project-card */ +.project-form-card textarea { min-height: 100px; resize: vertical; } @@ -278,4 +287,30 @@ nav a { border-radius: 999px; font-size: 13px; font-weight: bold; +} + +/* ---- Panel admin ---- */ + +.admin-actions { + display: flex; + gap: 12px; + margin-top: 20px; + flex-wrap: wrap; +} + +.admin-actions .btn-submit { + display: inline-block; + text-decoration: none; +} + +.btn-edit { + background-color: #6c63ff; +} + +.btn-delete { + background-color: #a12c2f; +} + +.btn-delete:hover { + background-color: #7e2023; } \ No newline at end of file