From be693be91ea16d8dd5f8f95a98fb52fe5853a26a Mon Sep 17 00:00:00 2001 From: thomas muzard Date: Sat, 18 Nov 2023 16:23:14 +0100 Subject: [PATCH] =?UTF-8?q?fin=20exp=C3=A9rience=20->=20test=20en=20cours?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- php/src/controleur/FrontControleur.php | 2 +- php/src/controleur/MembreControleur.php | 31 +++++++++++---- php/src/gateway/ExperienceGateway.php | 8 ++-- php/src/modele/MembreModele.php | 11 +++++- php/templates/creerExperience.html | 16 ++++---- php/templates/detailExperience.html | 2 +- php/templates/experience.html | 51 +++++++++++++++++++++++++ 7 files changed, 98 insertions(+), 23 deletions(-) create mode 100644 php/templates/experience.html 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 @@ - + @@ -18,26 +18,26 @@
- +
- +
- +
-
- - +
+ +
-
+
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 @@ - + 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 @@ + + + + + + Mes Expérience(s) + + + + + +
+ {% include "menu.html" %} +
+ +
+
+

Mes Expériences

+ Ajouter une expérience +
+ +
    + {% if experience is not empty %} + {% for experience in experiences %} +
  • +
    +

    {{ experience.intitule }}

    +

    nom de l'entreprise : {{ experience.getNomEntreprise() }}

    +

    Date début : {{ experience.getDateDebut }}

    +

    Date de fin: {{ experience.getDateFin }}

    +

    Travail actuel : {{ experience.isTravailActuel }}

    +
    + +
    + +
    +
  • + {% endfor %} + {% else %} +
  • Aucun événement trouvé.
  • + {% endif %} +
+
+ + + + + +