150 lines
5.8 KiB
PHP
150 lines
5.8 KiB
PHP
<?php
|
|
// On ajoute ici le header
|
|
require_once('./../elements/header.php');
|
|
|
|
// Ajout de la base de donnée
|
|
require_once '../functions/databaseConnection.php';
|
|
require_once("../functions/listUser.php");
|
|
require_once('../functions/listProject.php');
|
|
require_once('../functions/listXP.php');
|
|
|
|
|
|
// L'utilisateur doit être administrateur
|
|
if (!isset($_SESSION['role']) || $_SESSION['role'] !== 'admin') {
|
|
header('Location: ../pages/home.php');
|
|
exit;
|
|
}
|
|
|
|
// On met les variables à null ici pour éviter qu'il garde les options en premier chargement
|
|
$projetAModifier = null;
|
|
$xpAModifier = null;
|
|
|
|
|
|
// Si on modifie XP ou Projets
|
|
if (isset($_GET['edit_project']) && is_numeric($_GET['edit_project'])) {
|
|
$projetAModifier = recupererProjetParId((int) $_GET['edit_project']);
|
|
}
|
|
if (isset($_GET['edit_xp']) && is_numeric($_GET['edit_xp'])) {
|
|
$xpAModifier = recupererXPParId((int) $_GET['edit_xp']);
|
|
}
|
|
|
|
// Page du panneau d'administration
|
|
?>
|
|
|
|
<div class="admin-forms">
|
|
|
|
<!-- Formulaire de création de projet -->
|
|
<div class="project-container">
|
|
<div class="project-form-card">
|
|
|
|
<div class="project-header">
|
|
<h2><?php echo $projetAModifier ? 'Modifier le projet' : 'Nouveau projet'; ?></h2>
|
|
</div>
|
|
|
|
<!-- en envoie les données à addProject.php -->
|
|
<form method="POST" action="<?php echo $projetAModifier ? '../scripts/updateProject.php' : '../scripts/addProject.php'; ?>">
|
|
|
|
<?php if ($projetAModifier): ?>
|
|
<input type="hidden" name="id" value="<?php echo (int) $projetAModifier['id']; ?>">
|
|
<?php endif; ?>
|
|
|
|
<label>Titre *</label>
|
|
<input type="text" name="title" required value="<?php echo $projetAModifier ? htmlspecialchars($projetAModifier['title']) : ''; ?>">
|
|
|
|
<label>Tags (virgules)</label>
|
|
<input type="text" name="tags" value="<?php echo $projetAModifier ? htmlspecialchars($projetAModifier['tags']) : ''; ?>">
|
|
|
|
<label>Description *</label>
|
|
<textarea name="description" required><?php echo $projetAModifier ? htmlspecialchars($projetAModifier['description']) : ''; ?></textarea>
|
|
|
|
<label>Lien de l'image *</label>
|
|
<input type="url" name="imageurl" placeholder="https://..." required value="<?php echo $projetAModifier ? htmlspecialchars($projetAModifier['image_url']) : ''; ?>">
|
|
|
|
<input type="submit" name="submitproject" value="<?php echo $projetAModifier ? 'Modifier le projet' : '+ Ajouter le projet'; ?>" class="btn-submit">
|
|
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Formulaire de création d'expérience -->
|
|
<div class="project-container">
|
|
<div class="project-form-card">
|
|
|
|
<div class="project-header">
|
|
<h2><?php echo $xpAModifier ? 'Modifier l\'experience' : 'Nouvelle expérience'; ?></h2>
|
|
</div>
|
|
|
|
<!-- en envoie les données à addXP.php -->
|
|
<form method="POST" action="<?php echo $xpAModifier ? '../scripts/updateXP.php' : '../scripts/addXP.php'; ?>">
|
|
|
|
<?php if ($xpAModifier): ?>
|
|
<input type="hidden" name="id" value="<?php echo (int) $xpAModifier['id']; ?>">
|
|
<?php endif; ?>
|
|
|
|
<label>Titre *</label>
|
|
<input type="text" name="title" required value="<?php echo $xpAModifier ? htmlspecialchars($xpAModifier['title']) : ''; ?>">
|
|
|
|
<label>Type *</label>
|
|
<textarea name="xptype" required><?php echo $xpAModifier ? htmlspecialchars($xpAModifier['xptype']) : ''; ?></textarea>
|
|
|
|
<label>Tags (virgules)</label>
|
|
<input type="text" name="tags" value="<?php echo $xpAModifier ? htmlspecialchars($xpAModifier['tags']) : ''; ?>">
|
|
|
|
<label>Description *</label>
|
|
<textarea name="description" required><?php echo $xpAModifier ? htmlspecialchars($xpAModifier['description']) : ''; ?></textarea>
|
|
|
|
<label>Durée *</label>
|
|
<textarea name="duration" required><?php echo $xpAModifier ? htmlspecialchars($xpAModifier['duration']) : ''; ?></textarea>
|
|
|
|
<label>Lien de l'image *</label>
|
|
<input type="url" name="imageurl" placeholder="https://..." required value="<?php echo $xpAModifier ? htmlspecialchars($xpAModifier['image_url']) : ''; ?>">
|
|
|
|
<input type="submit" name="submitxp" value="<?php echo $xpAModifier ? 'Modifier l\'experience' : '+ Ajouter l\'experience'; ?>" class="btn-submit">
|
|
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
// Liste des projets / xps => en gros on pourra supprimer, et modifier à la vollée sans aller dans la bdd
|
|
?>
|
|
<h2 class="projects-title">Gérer les projets</h2>
|
|
<?php afficherProjetsAdmin(); ?>
|
|
<h2 class="projects-title">Gérer les experiences</h2>
|
|
<?php afficherXPAdmin();
|
|
|
|
// Création de compte
|
|
?>
|
|
|
|
<!-- Formulaire de création de compte -->
|
|
<div class="project-container">
|
|
<div class="project-form-card">
|
|
<div class="project-header">
|
|
<h2>Nouveau compte</h2>
|
|
</div>
|
|
|
|
<!-- en envoie les données addUser.php -->
|
|
<form method="POST" action="../scripts/addUser.php">
|
|
<label>Nom du compte</label>
|
|
<input type="text" name="user" required>
|
|
|
|
<!-- role admin ou user -->
|
|
<label>Rôle (admin/user)</label>
|
|
<textarea name="role" required></textarea>
|
|
|
|
<label>Mot de passe</label>
|
|
<input type="password" name="passwd" required>
|
|
|
|
<!-- Le bouton qui déclenche le PHP en haut de page -->
|
|
<input type="submit" name="submituser" value="Ajouter l'utilisateur" class="btn-submit">
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<h2 class="projects-title">Gérer les utilisateurs</h2>
|
|
|
|
<?php afficherUsersAdmin();
|
|
|
|
require_once('../elements/footer.php'); ?>
|