diff --git a/php/src/controleur/FrontControleur.php b/php/src/controleur/FrontControleur.php index 79b3a09..d447374 100755 --- a/php/src/controleur/FrontControleur.php +++ b/php/src/controleur/FrontControleur.php @@ -16,7 +16,7 @@ class FrontControleur //TODO ], "Membre" => [ - "deconnexion","proposerOffre","consulterProfil","modifierProfil","signaler","ajouterExperience","supprimerExperience" + "deconnexion","proposerOffre","consulterProfil","modifierProfil","signaler","ajouterExperience","supprimerExperience", "listerExperience" ], "Utilisateur" => [ diff --git a/php/src/controleur/MembreControleur.php b/php/src/controleur/MembreControleur.php index f71cec8..e941bda 100755 --- a/php/src/controleur/MembreControleur.php +++ b/php/src/controleur/MembreControleur.php @@ -28,7 +28,13 @@ class MembreControleur extends UtilisateurControleur $this->signaler(); break; case "ajouterExperience": - $this->ajouterExperience(); + $this->addExperience(); + break; + case "supprimerExperience": + $this->deleteExperience(); + break; + case "listerExperience": + $this->displayExperience(); break; default: parent::__construct(); @@ -62,7 +68,7 @@ class MembreControleur extends UtilisateurControleur //TODO } - public function listerExperience() + public function displayExperience() { global $twig; @@ -86,21 +92,30 @@ class MembreControleur extends UtilisateurControleur echo $twig->render("CreerExperience.html", []); } - protected function ajouterExperience() + protected function addExperience() { global $twig; - if (!Validation::validerExperience($_POST["titre"], $_POST["description"], $_POST["date"], $_POST["nbPlaceMax"], $img[1])) { + if (!Validation::validerExperience($_POST["intitule"], $_POST["dateDeb"], $_POST["dateFin"], $_POST["nomEntreprise"], $_POST["currentJob"])) { $modele = new MembreModele(); - $modele->addExperience($_POST["titre"], $_POST["description"], $_POST["date"], $_POST["nbPlaceMax"], $img[1]); + $modele->addExperience($_POST["intitule"], $_POST["dateDeb"], $_POST["dateFin"], $_POST["nomEntreprise"], $_POST["currentJob"]); $this->listerExperience(); } else { $dVueErreur[] ="Erreur lors de la création de l'évènement"; echo $twig->render("erreur.html",['dVueErreur' => $dVueErreur]); - } } else { - echo $twig->render('creerEvenement.html', []); + echo $twig->render('creerExperience.html', []); } } -} \ No newline at end of file + + protected function deleteEvenement() + { + $mdl = new MembreModele(); + $mdl->deleteEvenement($_GET["id"]); + + $this->listerExperience(); + } +} + + diff --git a/php/src/gateway/ExperienceGateway.php b/php/src/gateway/ExperienceGateway.php index 6171ad4..ee7ffc1 100644 --- a/php/src/gateway/ExperienceGateway.php +++ b/php/src/gateway/ExperienceGateway.php @@ -15,7 +15,7 @@ class ExperienceGateway $this->con = $con; } - public function getMaxId() : int + public function getNewId() : int { $query='SELECT MAX(id) FROM Experience'; $this->con->executeQuery($query); @@ -31,7 +31,7 @@ class ExperienceGateway return intval($res[0]['COUNT(*)']); } - public function getExperienceFromId($id) : array + public function getExperienceFromId(int $id) : array { $query = "SELECT * FROM experience WHERE id=:id"; $this->con->executeQuery($query, array( @@ -40,7 +40,7 @@ class ExperienceGateway return $this->con->getResults(); } - public function getExperienceFromProfil($profil) : array + public function getExperienceFromProfil(int $profil) : array { $query = "SELECT * FROM experience WHERE profil=:profil AND " ; $this->con->executeQuery($query, array( @@ -64,7 +64,7 @@ class ExperienceGateway )); } - public function deleteExperience($id) + public function deleteExperience(int $id) { $query = 'DELETE FROM experience WHERE id=:id' $this->con->executeQuery($query, array( diff --git a/php/src/modele/MembreModele.php b/php/src/modele/MembreModele.php index eb37100..b84f102 100755 --- a/php/src/modele/MembreModele.php +++ b/php/src/modele/MembreModele.php @@ -116,10 +116,19 @@ class MembreModele extends UtilisateurModele $gate->insertEvenement($evenement); } + /** + * @description supprimer une expérience + */ + public function deleteExperience(int $id) + { + $gate = new ExperienceGateway($this->con); + $gate->deleteExperience($id); + } + /** * @description modifier experience */ - public function updateExpereience() : bool + public function updateExperience() : bool { // TO DO return false; diff --git a/php/templates/creerExperience.html b/php/templates/creerExperience.html index 579583b..308edae 100644 --- a/php/templates/creerExperience.html +++ b/php/templates/creerExperience.html @@ -1,5 +1,5 @@ <!DOCTYPE html> - <html lang="en"> + <html lang="fr"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> @@ -18,26 +18,26 @@ </div> <div> - <label for="date">Date de début :</label> + <label for="dateDeb">Date de début :</label> <input type="date" id="dateDeb" name="dateDeb" required> </div> <div> - <label for="date">Date de fin :</label> + <label for="dateFin">Date de fin :</label> <input type="date" id="dateFin" name="dateFin"> </div> <div> - <label for="intitule">Nom de l'entreprise :</label> + <label for="nomEntreprise">Nom de l'entreprise :</label> <input type="text" id="nomEntreprise" name="nomEntreprise" required> </div> - <div class="form-group"> - <label for="image">Job en cours ? :</label> - <input type="radio" name="image" id="image" required> + <div> + <label for="currentJob">Job en cours ? :</label> + <input type="radio" name="currentJob" id="currentJob" required> </div> - <div class="form-group"> + <div> <input type="submit" value="ajouter_Experience"> </div> </form> diff --git a/php/templates/detailExperience.html b/php/templates/detailExperience.html index cf72b8a..2308533 100644 --- a/php/templates/detailExperience.html +++ b/php/templates/detailExperience.html @@ -1,5 +1,5 @@ <!DOCTYPE html> - <html lang="en"> + <html lang="fr"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> diff --git a/php/templates/experience.html b/php/templates/experience.html new file mode 100644 index 0000000..0c6f98f --- /dev/null +++ b/php/templates/experience.html @@ -0,0 +1,51 @@ +<!DOCTYPE html> + <html lang="fr"> + <head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> + <title>Mes Expérience(s)</title> + <link rel="stylesheet" href=""> + </head> + + <body> + + <header> + {% include "menu.html" %} + </header> + + <div> + <div> + <h1>Mes Expériences</h1> + <a href="../public/index.php?action=ajouterExperience">Ajouter une expérience</a> + </div> + + <ul> + {% if experience is not empty %} + {% for experience in experiences %} + <li> + <div> + <h2>{{ experience.intitule }}</h2> + <p> <strong>nom de l'entreprise :</strong> {{ experience.getNomEntreprise() }}</p> + <p><strong>Date début :</strong> {{ experience.getDateDebut }}</p> + <p><strong>Date de fin:</strong> {{ experience.getDateFin }}</p> + <p><strong>Travail actuel :</strong> {{ experience.isTravailActuel }}</p> + </div> + + <form action="../public/index.php?action=supprimerExperience&id={{ experience.id }}" method="POST"> + <button type="submit" id="deleteButton"> + <img src="assets/close.png" alt="Supprimer" width="20px"> + </button> + </form> + </li> + {% endfor %} + {% else %} + <li>Aucun événement trouvé.</li> + {% endif %} + </ul> + </div> + + <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script> + <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.3/dist/umd/popper.min.js"></script> + <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script> + </body> + </html>