Finition DisplayExperience / Manque correction profil

Expérience/Formation
thomas muzard 1 year ago
parent dbb002924d
commit e8e947db5e

@ -96,9 +96,9 @@ class Validation
return false; 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; return true;
} }

@ -5,6 +5,7 @@ namespace App\controleur;
use App\router\AltoRouter; use App\router\AltoRouter;
use App\controleur\Error; use App\controleur\Error;
use ErrorException;
class FrontControleur class FrontControleur
{ {
@ -18,7 +19,7 @@ class FrontControleur
$_SESSION['nom'] = NULL; $_SESSION['nom'] = NULL;
$_SESSION['prenom'] = NULL; $_SESSION['prenom'] = NULL;
$_SESSION['role'] = "guest"; $_SESSION['role'] = "guest";
$_SESSION['id'] = NULL; $_SESSION['id'] = "ttttttttttttttttttttt";
} }
else{ else{
$twig->addGlobal('nom', $_SESSION['nom']); $twig->addGlobal('nom', $_SESSION['nom']);
@ -117,14 +118,14 @@ class FrontControleur
echo $twig->render('accueil.html'); echo $twig->render('accueil.html');
} }
} catch (Error $error) { } catch (ErrorException $error) {
$dVueErreur = ['Erreur : Action inconnue']; $dVueErreur = ['Erreur : Action inconnue'];
echo $twig->render('erreur.html', ['dVueErreur' => $dVueErreur]); echo $twig->render('erreur.html', ['dVueErreur' => $dVueErreur]);
} }
} }
} }
catch(Error $e) catch(ErrorException $e)
{ {
$dVueErreur = ['Erreur : Action inconnue']; $dVueErreur = ['Erreur : Action inconnue'];

@ -11,10 +11,6 @@ class MembreControleur extends UtilisateurControleur
{} {}
public function deconnexion() public function deconnexion()
{
global $twig;
protected function deconnexion()
{ {
session_unset(); session_unset();
session_destroy(); session_destroy();
@ -22,6 +18,7 @@ class MembreControleur extends UtilisateurControleur
header("Location: /SAE_2A_FA-Reseau_ALICA/php/"); header("Location: /SAE_2A_FA-Reseau_ALICA/php/");
exit(); exit();
} }
public function createOfferForm() public function createOfferForm()
{ {
global $twig; global $twig;
@ -104,7 +101,7 @@ class MembreControleur extends UtilisateurControleur
$MemberModel->deleteOffer($offre); $MemberModel->deleteOffer($offre);
} }
$this->consultOffers(); $this->consultOffers(null);
/*$offre = $MemberModel->getOfferFromId($id); /*$offre = $MemberModel->getOfferFromId($id);
@ -138,50 +135,44 @@ class MembreControleur extends UtilisateurControleur
public function displayExperience() public function displayExperience()
{ {
global $twig; global $twig;
if (isset($_GET["id"]) && intval($_GET["id"]) != null)
{
$experienceModel = new MembreModele(); $experienceModel = new MembreModele();
$exp = $experienceModel->getExperienceFromProfil(intval($_GET["id"])); $exp = $experienceModel->getExperienceByProfil($_SESSION["id"]);
if($exp != NULL) if($exp != NULL)
{ {
echo $twig->render("detailExperience.html",['experience' => $exp]); echo $twig->render("detailExperience.html",['experience' => $exp]);
return; return;
} }
} }
$dVueErreur[] = "Erreur, Expérience(s) introuvable";
echo $twig->render("erreur.html", ['dVueErreur' => $dVueErreur]);
}
protected function experienceForm() public function experienceForm()
{ {
global $twig; global $twig;
echo $twig->render("CreerExperience.html", []); echo $twig->render("CreerExperience.html", []);
} }
protected function addExperience() public function addExperience()
{ {
global $twig; 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 = 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 { } else {
$dVueErreur[] ="Erreur lors de la création de l'évènement"; $dVueErreur[] ="Erreur lors de la création de l'évènement";
echo $twig->render("erreur.html",['dVueErreur' => $dVueErreur]); 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 = new MembreModele();
$mdl->deleteEvenement($_GET["id"]); $mdl->deleteExperience($params['id2']);
$this->displayExperience($_SESSION["id"]);
$this->listerExperience();
} }
} }

@ -186,7 +186,7 @@ class UtilisateurControleur
{ {
global $twig; global $twig;
if (isset($params['id']) && intval($params['id']) != null) if (isset($params['id']) && ($params['id']) != null)
{ {
$uttilsMdl = new UtilisateurModele(); $uttilsMdl = new UtilisateurModele();
$offre = $uttilsMdl->getOfferFromId(intval($params["id"])); $offre = $uttilsMdl->getOfferFromId(intval($params["id"]));

@ -42,7 +42,7 @@ class ExperienceGateway
public function getExperienceFromProfil(int $profil) : array 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( $this->con->executeQuery($query, array(
':profil' => array($profil, \PDO::PARAM_INT) ':profil' => array($profil, \PDO::PARAM_INT)
)); ));
@ -66,7 +66,7 @@ class ExperienceGateway
public function deleteExperience(int $id) public function deleteExperience(int $id)
{ {
$query = 'DELETE FROM experience WHERE id=:id' $query = 'DELETE FROM experience WHERE id=:id';
$this->con->executeQuery($query, array( $this->con->executeQuery($query, array(
':id' => array($id, \PDO::PARAM_INT) ':id' => array($id, \PDO::PARAM_INT)
)); ));

@ -11,7 +11,7 @@ class Experience
/** /**
* @var Profil profil * @var Profil profil
*/ */
private Profil $profil; private int $profil;
/** /**
* @var string Intitule * @var string Intitule
@ -40,14 +40,14 @@ class Experience
/** /**
* @param int $id * @param int $id
* @param Profil $profil * @param int $profil
* @param string $intitule * @param string $intitule
* @param string $dateDebut * @param string $dateDebut
* @param string $dateFin * @param string $dateFin
* @param string $nomEntreprise * @param string $nomEntreprise
* @param bool $travailActuel * @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->id = $id;
$this->profil = $profil; $this->profil = $profil;
@ -68,6 +68,11 @@ class Experience
return $this->profil; return $this->profil;
} }
public function getProfilId(): int
{
return $this->profil->getId();
}
public function getIntitule(): string public function getIntitule(): string
{ {
return $this->intitule; return $this->intitule;

@ -1,6 +1,8 @@
<?php <?php
namespace App\metier; namespace App\metier;
use App\metier\Alumni;
class Profil class Profil
{ {
/** /**
@ -8,6 +10,10 @@ class Profil
*/ */
private int $id; private int $id;
/**
* @var Alumni Profil lié à l'Alumni
*/
private Alumni $alumni;
/** /**
* @var string CV * @var string CV
@ -42,6 +48,16 @@ class Profil
*/ */
private string $portfolioUrl; private string $portfolioUrl;
/**
*@var array liste des formation d'un profil
*/
// private array $listeFormation;
/**
* @var array liste des expériences d'un profil
*/
// private array $listeExperience;
/** /**
* @param string $cv * @param string $cv
* @param string $nom * @param string $nom
@ -50,10 +66,12 @@ class Profil
* @param string $githubUrl * @param string $githubUrl
* @param string $portfolioUrl * @param string $portfolioUrl
*/ */
public function __construct(int $alumni,string $nom, string $prenom, string $email, ?string $image,string $cv, string $linkedinUrl, string $githubUrl, string $portfolioUrl) public function __construct(int $idProfil, Alumni $alumni,string $nom, string $prenom, string $email, ?string $image,string $cv, string $linkedinUrl, string $githubUrl, string $portfolioUrl)
{ {
$this->id = $alumni; $this->id = $idProfil;
$this->nom = $nom; $this->nom = $nom;
$this->alumni = $alumni;
$this->prenom = $prenom; $this->prenom = $prenom;
$this->image = $image; $this->image = $image;
$this->email = $email; $this->email = $email;
@ -61,6 +79,8 @@ class Profil
$this->linkedinUrl = $linkedinUrl; $this->linkedinUrl = $linkedinUrl;
$this->githubUrl = $githubUrl; $this->githubUrl = $githubUrl;
$this->portfolioUrl = $portfolioUrl; $this->portfolioUrl = $portfolioUrl;
// $this->listeFormation = null;
// $this->listeExperience = null;
} }
@ -68,10 +88,17 @@ class Profil
{ {
return $this->id; return $this->id;
} }
public function getAlmuni(): Alumni
{
return $this->alumni;
}
public function getImage(): ?string public function getImage(): ?string
{ {
return $this->image ?? 'logo.png'; return $this->image ?? 'logo.png';
} }
public function getCv(): string public function getCv(): string
{ {
return $this->cv; return $this->cv;

@ -2,28 +2,23 @@
namespace App\modele; 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\gateway\ImageManager;
use App\metier\Alumni; use App\metier\Alumni;
use App\metier\Offre; use App\metier\Offre;
>>>>>>> master use App\metier\Experience;
use App\gateway\Connection;
use App\gateway\ExperienceGateway;
class MembreModele extends UtilisateurModele class MembreModele extends UtilisateurModele
{ {
private $con; private $con;
protected $experienceGw;
public function __construct() public function __construct()
{ {
$this->con = new Connection(DB_HOST,DB_USER,DB_PASS); $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 * @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 = $this->experienceGw->getExperienceFromId($idProfil);
$data = $gate->getExperienceFromId();
$experience = array(); $experience = array();
foreach($data as $row) foreach($data as $row)
@ -81,22 +75,22 @@ class MembreModele extends UtilisateurModele
/** /**
* @description Récupérer les expériences de l'utilisateurs en cours * @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 = $this->experienceGw->getExperienceFromProfil($idProfil);
$data = $gate->getExperienceFromProfil();
$experience = array(); $experience = array();
var_dump($data);
foreach($data as $row) foreach($data as $row)
{ {
$experience[] = new Experience( $experience[] = new Experience(
$row['id'], $row['id'],
$row['profil'], $row['profil'],
$row['intitule'], $row['intitule'],
$row['dateBegin'], $row['dateDebut'],
$row['dateEnd'], $row['dateFin'],
$row['industryName'], $row['nomEntreprise'],
$row['currentJob'] $row['currentJob'],
); );
} }
return $experience; return $experience;
@ -105,30 +99,27 @@ class MembreModele extends UtilisateurModele
/** /**
* @description ajouter Experience * @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( $exp = new Experience(
$gate->getNewId(), $this->experienceGw->getNewId(),
'1', //TODO : Ajouter l'ID de l'admin connecté $idExperience,
$titre, $intitule,
$description, $dateDeb,
$date, $dateFin,
$nbPlaceMax, $nomEntreprise,
$img $currentJob
); );
$gate->insertEvenement($evenement); $this->experienceGw->addExperience($exp);
} }
/** /**
* @description supprimer une expérience * @description supprimer une expérience
*/ */
public function deleteExperience(int $id) public function deleteExperience($id)
{ {
$gate = new ExperienceGateway($this->con); $this->experienceGw->deleteExperience($id);
$gate->deleteExperience($id);
} }
/** /**

@ -14,16 +14,16 @@
{% include "menu.html" %} {% include "menu.html" %}
</header> </header>
<div class="container mt-4"> <div>
{% if experience %} {% if experience %}
<h1>Détails de l'Événement : {{experience.intitule}}</h1> <h1>Détails de l'Événement : {{experience.intitule}}</h1>
<div class="event-details"> <div>
<p><strong>nom de l'entreprise :</strong> {{ experience.nomEntreprise }}</p> <p><strong>nom de l'entreprise :</strong> {{ experience.nomEntreprise }}</p>
<p><strong>Date de début :</strong> {{ experience.dateDeb }}</p> <p><strong>Date de début :</strong> {{ experience.dateDeb }}</p>
<p><strong>Date de fin :</strong> {{ experience.dateFin }}</p> <p><strong>Date de fin :</strong> {{ experience.dateFin }}</p>
<p><strong>Job en cours ? :</strong> {{ experience.travailActuel }}</p> <p><strong>Job en cours ? :</strong> {{ experience.travailActuel }}</p>
<a href="../public/index.php?action=listerExperience">Retour</a> <a href="{{dir}}/user/displayExperience">Retour</a>
</div> </div>
{% else %} {% else %}
<p>L'expérience n'existe pas ou n'est pas disponible.</p> <p>L'expérience n'existe pas ou n'est pas disponible.</p>

@ -27,7 +27,7 @@
<!-- Afficher boutons de connexion et d'inscription --> <!-- Afficher boutons de connexion et d'inscription -->
{% if nom and prenom %} {% if nom and prenom %}
<!-- Afficher bouton de déconnexion --> <!-- Afficher bouton de déconnexion -->
<a href="index.php?action=displayExperience">Mon profil</a> <a href="{{dir}}/user/displayExperience">Mon profil</a>
<a href="{{dir}}/user/deconnexion" class="button">Déconnexion</a> <a href="{{dir}}/user/deconnexion" class="button">Déconnexion</a>
{% else %} {% else %}
<div class="login-register"> <div class="login-register">

Loading…
Cancel
Save