Ajout de la modifications des XP/Projets en admin (fonctionnel)
This commit is contained in:
+67
-37
@@ -5,82 +5,112 @@ require_once('./../elements/header.php');
|
||||
// Ajout de la base de donnée
|
||||
require_once '../functions/databaseConnection.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
|
||||
?>
|
||||
|
||||
<?php if (isset($message)) { echo "<p style='color: white; text-align: center;'>$message</p>"; } ?>
|
||||
<div class="admin-forms">
|
||||
|
||||
<!-- Formulaire de création de projet -->
|
||||
<div class="project-container">
|
||||
<div class="project-form-card">
|
||||
|
||||
<div class="project-header">
|
||||
<h2>Nouveau projet</h2>
|
||||
<h2><?php echo $projetAModifier ? 'Modifier le projet' : 'Nouveau projet'; ?></h2>
|
||||
</div>
|
||||
|
||||
<!-- en envoie les données à addProject.php -->
|
||||
<form method="POST" action="../scripts/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>
|
||||
|
||||
<label>Tags (virgules)</label>
|
||||
<input type="text" name="tags">
|
||||
|
||||
<label>Description *</label>
|
||||
<textarea name="description" required></textarea>
|
||||
|
||||
<label>Lien de l'image *</label>
|
||||
<!-- URL Pour un potentiel Lien image/CDN -->
|
||||
<input type="url" name="image_url" placeholder="https://..." required>
|
||||
|
||||
<!-- Le bouton qui déclenche le PHP en haut de page -->
|
||||
<input type="submit" name="submit_project" value="+ Ajouter le projet" class="btn-submit">
|
||||
<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>
|
||||
|
||||
<div class="project-container">
|
||||
<!-- Formulaire de création d'expérience -->
|
||||
<div class="project-container">
|
||||
<div class="project-form-card">
|
||||
|
||||
<div class="project-header">
|
||||
<h2>Nouvelle expérience</h2>
|
||||
<h2><?php echo $xpAModifier ? 'Modifier l\'experience' : 'Nouvelle expérience'; ?></h2>
|
||||
</div>
|
||||
|
||||
<!-- en envoie les données à addXP.php -->
|
||||
<form method="POST" action="../scripts/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>
|
||||
<input type="text" name="title" required value="<?php echo $xpAModifier ? htmlspecialchars($xpAModifier['title']) : ''; ?>">
|
||||
|
||||
<!-- type : stage alternance ou autre -->
|
||||
<label>Type *</label>
|
||||
<textarea name="xptype" required></textarea>
|
||||
|
||||
<textarea name="xptype" required><?php echo $xpAModifier ? htmlspecialchars($xpAModifier['xptype']) : ''; ?></textarea>
|
||||
|
||||
<label>Tags (virgules)</label>
|
||||
<input type="text" name="tags">
|
||||
|
||||
<input type="text" name="tags" value="<?php echo $xpAModifier ? htmlspecialchars($xpAModifier['tags']) : ''; ?>">
|
||||
|
||||
<label>Description *</label>
|
||||
<textarea name="description" required></textarea>
|
||||
<textarea name="description" required><?php echo $xpAModifier ? htmlspecialchars($xpAModifier['description']) : ''; ?></textarea>
|
||||
|
||||
<!-- durée par exemple date - 2 semaines -->
|
||||
<label>Durée *</label>
|
||||
<textarea name="duration" required></textarea>
|
||||
|
||||
<textarea name="duration" required><?php echo $xpAModifier ? htmlspecialchars($xpAModifier['duration']) : ''; ?></textarea>
|
||||
|
||||
<label>Lien de l'image *</label>
|
||||
<!-- URL Pour un potentiel Lien image/CDN -->
|
||||
<input type="url" name="image_url" placeholder="https://..." required>
|
||||
|
||||
<!-- Le bouton qui déclenche le PHP en haut de page -->
|
||||
<input type="submit" name="submit_xp" value="+ Ajouter l'experience" class="btn-submit">
|
||||
<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>
|
||||
|
||||
</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(); ?>
|
||||
Reference in New Issue
Block a user