diff --git a/php/src/config/Validation.php b/php/src/config/Validation.php index 942dd54..be22661 100755 --- a/php/src/config/Validation.php +++ b/php/src/config/Validation.php @@ -96,9 +96,9 @@ class Validation return false; } - public static function validerExperience(string $intitule, string $dateDeb, string $dateFin, string $nomEntreprise, bool $currendJob) + public static function validerExperience(int $idProfil, string $intitule, string $dateDeb, string $dateFin, string $nomEntreprise, bool $currendJob) { - if(!empty($intitule) && !empty($dateDeb) && !empty($nomEntreprise) && !empty($currendJob)) + if(!empty($idProfil) && !empty($intitule) && !empty($dateDeb) && !empty($nomEntreprise) && !empty($currendJob)) { return true; } diff --git a/php/src/controleur/FrontControleur.php b/php/src/controleur/FrontControleur.php index d1f6c4e..b2de00f 100755 --- a/php/src/controleur/FrontControleur.php +++ b/php/src/controleur/FrontControleur.php @@ -5,6 +5,7 @@ namespace App\controleur; use App\router\AltoRouter; use App\controleur\Error; +use ErrorException; class FrontControleur { @@ -18,7 +19,7 @@ class FrontControleur $_SESSION['nom'] = NULL; $_SESSION['prenom'] = NULL; $_SESSION['role'] = "guest"; - $_SESSION['id'] = NULL; + $_SESSION['id'] = "ttttttttttttttttttttt"; } else{ $twig->addGlobal('nom', $_SESSION['nom']); @@ -117,14 +118,14 @@ class FrontControleur echo $twig->render('accueil.html'); } - } catch (Error $error) { + } catch (ErrorException $error) { $dVueErreur = ['Erreur : Action inconnue']; echo $twig->render('erreur.html', ['dVueErreur' => $dVueErreur]); } } } - catch(Error $e) + catch(ErrorException $e) { $dVueErreur = ['Erreur : Action inconnue']; diff --git a/php/src/controleur/MembreControleur.php b/php/src/controleur/MembreControleur.php index 2675573..4dc2bd9 100755 --- a/php/src/controleur/MembreControleur.php +++ b/php/src/controleur/MembreControleur.php @@ -11,10 +11,6 @@ class MembreControleur extends UtilisateurControleur {} public function deconnexion() - { - global $twig; - - protected function deconnexion() { session_unset(); session_destroy(); @@ -22,6 +18,7 @@ class MembreControleur extends UtilisateurControleur header("Location: /SAE_2A_FA-Reseau_ALICA/php/"); exit(); } + public function createOfferForm() { global $twig; @@ -104,7 +101,7 @@ class MembreControleur extends UtilisateurControleur $MemberModel->deleteOffer($offre); } - $this->consultOffers(); + $this->consultOffers(null); /*$offre = $MemberModel->getOfferFromId($id); @@ -138,50 +135,44 @@ class MembreControleur extends UtilisateurControleur public function displayExperience() { global $twig; - - if (isset($_GET["id"]) && intval($_GET["id"]) != null) + $experienceModel = new MembreModele(); + $exp = $experienceModel->getExperienceByProfil($_SESSION["id"]); + if($exp != NULL) { - $experienceModel = new MembreModele(); - $exp = $experienceModel->getExperienceFromProfil(intval($_GET["id"])); - if($exp != NULL) - { - echo $twig->render("detailExperience.html",['experience' => $exp]); - return; - } - } - $dVueErreur[] = "Erreur, Expérience(s) introuvable"; - echo $twig->render("erreur.html", ['dVueErreur' => $dVueErreur]); + echo $twig->render("detailExperience.html",['experience' => $exp]); + return; + } } - protected function experienceForm() + public function experienceForm() { global $twig; echo $twig->render("CreerExperience.html", []); } - protected function addExperience() + public function addExperience() { global $twig; - if (!Validation::validerExperience($_POST["intitule"], $_POST["dateDeb"], $_POST["dateFin"], $_POST["nomEntreprise"], $_POST["currentJob"])) { + if (!Validation::validerExperience($_SESSION["id"], $_POST["intitule"], $_POST["dateDeb"], $_POST["dateFin"], $_POST["nomEntreprise"], $_POST["currentJob"])) { $modele = new MembreModele(); - $modele->addExperience($_POST["intitule"], $_POST["dateDeb"], $_POST["dateFin"], $_POST["nomEntreprise"], $_POST["currentJob"]); + $modele->addExperience($_SESSION["id"], $_POST["intitule"], $_POST["dateDeb"], $_POST["dateFin"], $_POST["nomEntreprise"], $_POST["currentJob"]); - $this->listerExperience(); + $this->displayExperience($_SESSION["id"]); + echo $twig->render('creerExperience.html', []); } else { $dVueErreur[] ="Erreur lors de la création de l'évènement"; echo $twig->render("erreur.html",['dVueErreur' => $dVueErreur]); - } else { - echo $twig->render('creerExperience.html', []); - } + } } - protected function deleteEvenement() + + public function deleteExperience(?array $params) { + global $twing; $mdl = new MembreModele(); - $mdl->deleteEvenement($_GET["id"]); - - $this->listerExperience(); + $mdl->deleteExperience($params['id2']); + $this->displayExperience($_SESSION["id"]); } } diff --git a/php/src/controleur/UtilisateurControleur.php b/php/src/controleur/UtilisateurControleur.php index 1156b59..5a06c3f 100755 --- a/php/src/controleur/UtilisateurControleur.php +++ b/php/src/controleur/UtilisateurControleur.php @@ -186,7 +186,7 @@ class UtilisateurControleur { global $twig; - if (isset($params['id']) && intval($params['id']) != null) + if (isset($params['id']) && ($params['id']) != null) { $uttilsMdl = new UtilisateurModele(); $offre = $uttilsMdl->getOfferFromId(intval($params["id"])); diff --git a/php/src/gateway/ExperienceGateway.php b/php/src/gateway/ExperienceGateway.php index ee7ffc1..6505ef5 100644 --- a/php/src/gateway/ExperienceGateway.php +++ b/php/src/gateway/ExperienceGateway.php @@ -42,7 +42,7 @@ class ExperienceGateway public function getExperienceFromProfil(int $profil) : array { - $query = "SELECT * FROM experience WHERE profil=:profil AND " ; + $query = "SELECT * FROM experience WHERE profil=:profil" ; $this->con->executeQuery($query, array( ':profil' => array($profil, \PDO::PARAM_INT) )); @@ -66,7 +66,7 @@ class ExperienceGateway public function deleteExperience(int $id) { - $query = 'DELETE FROM experience WHERE id=:id' + $query = 'DELETE FROM experience WHERE id=:id'; $this->con->executeQuery($query, array( ':id' => array($id, \PDO::PARAM_INT) )); diff --git a/php/src/metier/Experience.php b/php/src/metier/Experience.php index 9d105ba..0d28cec 100644 --- a/php/src/metier/Experience.php +++ b/php/src/metier/Experience.php @@ -11,7 +11,7 @@ class Experience /** * @var Profil profil */ - private Profil $profil; + private int $profil; /** * @var string Intitule @@ -40,14 +40,14 @@ class Experience /** * @param int $id - * @param Profil $profil + * @param int $profil * @param string $intitule * @param string $dateDebut * @param string $dateFin * @param string $nomEntreprise * @param bool $travailActuel */ - public function __construct(int $id, Profil $profil, string $intitule, string $dateDebut, string $dateFin, string $nomEntreprise, bool $travailActuel) + public function __construct(int $id, int $profil, string $intitule, string $dateDebut, string $dateFin, string $nomEntreprise, bool $travailActuel) { $this->id = $id; $this->profil = $profil; @@ -68,6 +68,11 @@ class Experience return $this->profil; } + public function getProfilId(): int + { + return $this->profil->getId(); + } + public function getIntitule(): string { return $this->intitule; diff --git a/php/src/metier/Profil.php b/php/src/metier/Profil.php index bd73ec5..13147d9 100644 --- a/php/src/metier/Profil.php +++ b/php/src/metier/Profil.php @@ -1,6 +1,8 @@ id = $alumni; + $this->id = $idProfil; + $this->nom = $nom; + $this->alumni = $alumni; $this->prenom = $prenom; $this->image = $image; $this->email = $email; @@ -61,6 +79,8 @@ class Profil $this->linkedinUrl = $linkedinUrl; $this->githubUrl = $githubUrl; $this->portfolioUrl = $portfolioUrl; + // $this->listeFormation = null; + // $this->listeExperience = null; } @@ -68,10 +88,17 @@ class Profil { return $this->id; } + + public function getAlmuni(): Alumni + { + return $this->alumni; + } + public function getImage(): ?string { return $this->image ?? 'logo.png'; } + public function getCv(): string { return $this->cv; diff --git a/php/src/modele/MembreModele.php b/php/src/modele/MembreModele.php index 016f6ee..118655d 100755 --- a/php/src/modele/MembreModele.php +++ b/php/src/modele/MembreModele.php @@ -2,28 +2,23 @@ namespace App\modele; -<<<<<<< HEAD -use App\gateway\AlumniGateway; -use App\gateway\Connection; -use App\gateway\ImageGateway; -use App\gateway\OffreGateway; -use App\gateway\ProfilGateway; -use App\metier\Alumni; -use mysql_xdevapi\Exception; -======= use App\gateway\ImageManager; use App\metier\Alumni; use App\metier\Offre; ->>>>>>> master +use App\metier\Experience; +use App\gateway\Connection; +use App\gateway\ExperienceGateway; class MembreModele extends UtilisateurModele { private $con; + protected $experienceGw; public function __construct() - { + { $this->con = new Connection(DB_HOST,DB_USER,DB_PASS); + $this->experienceGw = new ExperienceGateway($this->con); } /** @@ -57,10 +52,9 @@ class MembreModele extends UtilisateurModele /** * @description Récupérer l'expériences en fonction de l'id */ - public function getExperienceById() : array + public function getExperienceById($idProfil) : ?array { - $gate = new ExperiencetGateway($this->con); - $data = $gate->getExperienceFromId(); + $data = $this->experienceGw->getExperienceFromId($idProfil); $experience = array(); foreach($data as $row) @@ -81,22 +75,22 @@ class MembreModele extends UtilisateurModele /** * @description Récupérer les expériences de l'utilisateurs en cours */ - public function getExperienceByProfil() : array + public function getExperienceByProfil($idProfil) : ?array { - $gate = new ExperiencetGateway($this->con); - $data = $gate->getExperienceFromProfil(); + $data = $this->experienceGw->getExperienceFromProfil($idProfil); $experience = array(); + var_dump($data); foreach($data as $row) { $experience[] = new Experience( $row['id'], $row['profil'], $row['intitule'], - $row['dateBegin'], - $row['dateEnd'], - $row['industryName'], - $row['currentJob'] + $row['dateDebut'], + $row['dateFin'], + $row['nomEntreprise'], + $row['currentJob'], ); } return $experience; @@ -105,30 +99,27 @@ class MembreModele extends UtilisateurModele /** * @description ajouter Experience */ - public function addExperience() + public function addExperience($idExperience, string $intitule, string $dateDeb, string $dateFin, string $nomEntreprise, string $currentJob) { - $gate = new ExperienceGateway($this->con); - $exp = new Experience( - $gate->getNewId(), - '1', //TODO : Ajouter l'ID de l'admin connecté - $titre, - $description, - $date, - $nbPlaceMax, - $img + $this->experienceGw->getNewId(), + $idExperience, + $intitule, + $dateDeb, + $dateFin, + $nomEntreprise, + $currentJob ); - $gate->insertEvenement($evenement); + $this->experienceGw->addExperience($exp); } /** * @description supprimer une expérience */ - public function deleteExperience(int $id) + public function deleteExperience($id) { - $gate = new ExperienceGateway($this->con); - $gate->deleteExperience($id); + $this->experienceGw->deleteExperience($id); } /** diff --git a/php/templates/detailExperience.html b/php/templates/detailExperience.html index 2308533..1de2b54 100644 --- a/php/templates/detailExperience.html +++ b/php/templates/detailExperience.html @@ -14,16 +14,16 @@ {% include "menu.html" %} -
nom de l'entreprise : {{ experience.nomEntreprise }}
Date de début : {{ experience.dateDeb }}
Date de fin : {{ experience.dateFin }}
Job en cours ? : {{ experience.travailActuel }}
- Retour + RetourL'expérience n'existe pas ou n'est pas disponible.
diff --git a/php/templates/menu.html b/php/templates/menu.html index 95c4c8e..96372ce 100644 --- a/php/templates/menu.html +++ b/php/templates/menu.html @@ -27,7 +27,7 @@ {% if nom and prenom %} - Mon profil + Mon profil Déconnexion {% else %}