|
|
@ -2,23 +2,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
namespace App\controleur;
|
|
|
|
namespace App\controleur;
|
|
|
|
|
|
|
|
|
|
|
|
use App\config;
|
|
|
|
|
|
|
|
use App\config\Validation;
|
|
|
|
use App\config\Validation;
|
|
|
|
|
|
|
|
use App\gateway\Connection;
|
|
|
|
use App\gateway\ImageSaver;
|
|
|
|
use App\gateway\ImageSaver;
|
|
|
|
use App\modele\OffreModele;
|
|
|
|
use App\gateway\OffreGateway;
|
|
|
|
use App\modele\UtilisateurModele;
|
|
|
|
use App\modele\UtilisateurModele;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use App\config;
|
|
|
|
|
|
|
|
|
|
|
|
class UtilisateurControleur
|
|
|
|
class UtilisateurControleur
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
private \App\modele\UtilisateurModele $userModel;
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
global $twig;
|
|
|
|
global $twig;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->userModel = new \App\modele\UtilisateurModele();
|
|
|
|
|
|
|
|
|
|
|
|
if (!isset($_REQUEST["action"])) {
|
|
|
|
if (!isset($_REQUEST["action"])) {
|
|
|
|
//$action = NULL;
|
|
|
|
//$action = NULL;
|
|
|
|
$action = "listerEvenement";
|
|
|
|
$action = "consultOffers";
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$action = Validation::nettoyerString($_REQUEST["action"]);
|
|
|
|
$action = \App\config\Validation::nettoyerString($_REQUEST["action"]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch ($action) {
|
|
|
|
switch ($action) {
|
|
|
|
case NULL:
|
|
|
|
case NULL:
|
|
|
@ -33,6 +39,7 @@ class UtilisateurControleur
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case "inscription":
|
|
|
|
case "inscription":
|
|
|
|
$this->inscription();
|
|
|
|
$this->inscription();
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case "consultOffers":
|
|
|
|
case "consultOffers":
|
|
|
|
$this->consultOffers();
|
|
|
|
$this->consultOffers();
|
|
|
@ -49,24 +56,10 @@ class UtilisateurControleur
|
|
|
|
case "displayOffer":
|
|
|
|
case "displayOffer":
|
|
|
|
$this->displayOffer();
|
|
|
|
$this->displayOffer();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case "listerEvenement":
|
|
|
|
|
|
|
|
$this->listerEvenement();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "creerEvenement":
|
|
|
|
|
|
|
|
$this->creerEvenement();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "supprimerEvenement":
|
|
|
|
|
|
|
|
$this->supprimerEvenement();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "avoirDetailEvenement":
|
|
|
|
|
|
|
|
$this->avoirDetailEvenement();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "rechercherEvenement":
|
|
|
|
|
|
|
|
$this->rechercherEvenement();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
$dVueErreur[] = "Action inconnue ou non autorisée";
|
|
|
|
$dVueErreur[] = "Action inconnue ou non autorisée";
|
|
|
|
echo $twig->render("erreur.html", ['dVueErreur' => $dVueErreur]);
|
|
|
|
echo $twig->render("erreur.html", ['dVueErreur' => $dVueErreur]);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -115,20 +108,6 @@ class UtilisateurControleur
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$nouvelUtilisateur = $userModel->inscription($prenom,$nom,$email, $hash);
|
|
|
|
$nouvelUtilisateur = $userModel->inscription($prenom,$nom,$email, $hash);
|
|
|
|
|
|
|
|
|
|
|
|
// <<<<<<< HEAD
|
|
|
|
|
|
|
|
// // Validez les données d'inscription, par exemple, vérifiez si l'email est unique
|
|
|
|
|
|
|
|
// // Vous pouvez également effectuer d'autres validations nécessaires
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// $userModel = new \App\modele\UtilisateurModele();
|
|
|
|
|
|
|
|
// $nouvelUtilisateur = $userModel->inscription($email, $motDePasse);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // Si l'inscription a réussi, redirigez l'utilisateur vers une page de confirmation
|
|
|
|
|
|
|
|
// // Vous pouvez également gérer les erreurs ici en cas d'échec de l'inscription
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if ($nouvelUtilisateur instanceof \App\metier\Alumni) {
|
|
|
|
|
|
|
|
// // L'inscription a réussi, redirigez l'utilisateur vers une page de confirmation
|
|
|
|
|
|
|
|
// // par exemple :
|
|
|
|
|
|
|
|
// =======
|
|
|
|
|
|
|
|
if ($nouvelUtilisateur instanceof \App\metier\Alumni) {
|
|
|
|
if ($nouvelUtilisateur instanceof \App\metier\Alumni) {
|
|
|
|
header('Location: index.php?action=inscription_success');
|
|
|
|
header('Location: index.php?action=inscription_success');
|
|
|
|
exit();
|
|
|
|
exit();
|
|
|
@ -165,17 +144,25 @@ class UtilisateurControleur
|
|
|
|
//TODO
|
|
|
|
//TODO
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @return void
|
|
|
|
|
|
|
|
* @brief Affiche la liste des offres d'emploi
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
protected function consultOffers()
|
|
|
|
protected function consultOffers()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$offerMdl = new OffreModele();
|
|
|
|
|
|
|
|
global $twig;
|
|
|
|
global $twig;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$niveauEtudes=null;
|
|
|
|
$niveauEtudes=null;
|
|
|
|
$typeContrat=null;
|
|
|
|
$typeContrat=null;
|
|
|
|
$exp = null;
|
|
|
|
$exp = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// number of offers by pages
|
|
|
|
$nbOffers = 5 ;
|
|
|
|
$nbOffers = 5 ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** validation of entry's : */
|
|
|
|
if(isset($_GET["niveauEtudes"]) && Validation::validateTypeStudies($_GET["niveauEtudes"])) {
|
|
|
|
if(isset($_GET["niveauEtudes"]) && Validation::validateTypeStudies($_GET["niveauEtudes"])) {
|
|
|
|
$niveauEtudes = $_GET["niveauEtudes"];
|
|
|
|
$niveauEtudes = $_GET["niveauEtudes"];
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -189,26 +176,30 @@ class UtilisateurControleur
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($niveauEtudes == null && $typeContrat == null && $exp == null) {
|
|
|
|
if ($niveauEtudes == null && $typeContrat == null && $exp == null) {
|
|
|
|
$totalOffers = $offerMdl->getNbOffers();
|
|
|
|
$totalOffers = $this->userModel->getNbOffers();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$params = array(
|
|
|
|
$params = array(
|
|
|
|
'typeContrat' => $typeContrat,
|
|
|
|
'typeContrat' => $typeContrat,
|
|
|
|
'exp' => $exp,
|
|
|
|
'exp' => $exp,
|
|
|
|
'niveauEtudes' => $niveauEtudes,
|
|
|
|
'niveauEtudes' => $niveauEtudes,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
$offers = $offerMdl->getOffersWithFilters($params);
|
|
|
|
$offers = $this->userModel->getOffersWithFilters($params);
|
|
|
|
$totalOffers = count($offers);
|
|
|
|
$totalOffers = count($offers);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// get the current pages to display
|
|
|
|
$numberPages = ceil($totalOffers / 5);
|
|
|
|
$numberPages = ceil($totalOffers / 5);
|
|
|
|
|
|
|
|
|
|
|
|
if($numberPages == 0 )
|
|
|
|
if($numberPages == 0 )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
echo $twig->render("erreur.html",['dVueErreur' => ['Aucune Offre Trouvée']]);
|
|
|
|
echo $twig->render("OffersList.html",['dVueErreur' => ['Aucune Offre Trouvée']]);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// validate the page number
|
|
|
|
if (isset($_GET["page"]) && intval($_GET["page"]) != null) {
|
|
|
|
if (isset($_GET["page"]) && intval($_GET["page"]) != null) {
|
|
|
|
$page = intval($_GET["page"]);
|
|
|
|
$page = intval($_GET["page"]);
|
|
|
|
if ($page > $numberPages || $page < 1) {
|
|
|
|
if ($page > $numberPages || $page < 1) {
|
|
|
@ -220,16 +211,19 @@ class UtilisateurControleur
|
|
|
|
$page = 1;
|
|
|
|
$page = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$start = intval(($page - 1) * 5);
|
|
|
|
$start = intval(($page - 1) * 5);
|
|
|
|
|
|
|
|
|
|
|
|
if ($niveauEtudes == null && $typeContrat == null && $exp == null) {
|
|
|
|
if ($niveauEtudes == null && $typeContrat == null && $exp == null) {
|
|
|
|
$offers = $offerMdl->getOfferLimit($start, $nbOffers);
|
|
|
|
$offers = $this->userModel->getOfferLimit($start, $nbOffers);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$params['start'] = $start;
|
|
|
|
$params['start'] = $start;
|
|
|
|
$params['nbOffers'] = 5;
|
|
|
|
$params['nbOffers'] = 5;
|
|
|
|
$offers = $offerMdl->getOffersWithFilters($params);
|
|
|
|
$offers = $this->userModel->getOffersWithFilters($params);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* echo "filtre :".$niveauEtudes."<br>";
|
|
|
|
/* echo "filtre :".$niveauEtudes."<br>";
|
|
|
|
echo "filtre :".$typeContrat."<br>";
|
|
|
|
echo "filtre :".$typeContrat."<br>";
|
|
|
|
echo "filtre :".$exp."<br>";*/
|
|
|
|
echo "filtre :".$exp."<br>";*/
|
|
|
@ -247,12 +241,18 @@ class UtilisateurControleur
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// display the form to create an offer
|
|
|
|
protected function createOfferForm()
|
|
|
|
protected function createOfferForm()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
global $twig;
|
|
|
|
global $twig;
|
|
|
|
echo $twig->render("CreerOffre.html", []);
|
|
|
|
echo $twig->render("CreerOffre.html", []);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// create offer
|
|
|
|
protected function createOffer()
|
|
|
|
protected function createOffer()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
global $twig;
|
|
|
|
global $twig;
|
|
|
@ -260,6 +260,8 @@ class UtilisateurControleur
|
|
|
|
|
|
|
|
|
|
|
|
$requiredFields = ['name', 'entreprise', 'description','typeContrat', 'descriptPoste', 'profilRecherche', 'choixExp', 'education', 'mail', 'num'];
|
|
|
|
$requiredFields = ['name', 'entreprise', 'description','typeContrat', 'descriptPoste', 'profilRecherche', 'choixExp', 'education', 'mail', 'num'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// validate required fields
|
|
|
|
$error = false;
|
|
|
|
$error = false;
|
|
|
|
foreach ($requiredFields as $field) {
|
|
|
|
foreach ($requiredFields as $field) {
|
|
|
|
if (empty($_POST[$field])) {
|
|
|
|
if (empty($_POST[$field])) {
|
|
|
@ -273,6 +275,8 @@ class UtilisateurControleur
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// validate entrys
|
|
|
|
if(!Validation::verifierEmail($_POST["mail"]))
|
|
|
|
if(!Validation::verifierEmail($_POST["mail"]))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//echo $twig->render("CreerOffre.html", ['errMsg' => "Email non valide !" ]);
|
|
|
|
//echo $twig->render("CreerOffre.html", ['errMsg' => "Email non valide !" ]);
|
|
|
@ -297,6 +301,8 @@ class UtilisateurControleur
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if errors display the form with errors
|
|
|
|
if(count($taberror) > 0)
|
|
|
|
if(count($taberror) > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
echo $twig->render("CreerOffre.html", ['tabError' => $taberror ]);
|
|
|
|
echo $twig->render("CreerOffre.html", ['tabError' => $taberror ]);
|
|
|
@ -306,10 +312,8 @@ class UtilisateurControleur
|
|
|
|
$saveImg1 = ImageSaver::SaveImage("image");
|
|
|
|
$saveImg1 = ImageSaver::SaveImage("image");
|
|
|
|
$saveImg2 = ImageSaver::SaveImage("logo");
|
|
|
|
$saveImg2 = ImageSaver::SaveImage("logo");
|
|
|
|
if($saveImg1[0] && $saveImg2[0]) {
|
|
|
|
if($saveImg1[0] && $saveImg2[0]) {
|
|
|
|
$offreMdl = new OffreModele();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$offre = $this->userModel->publishOffer($saveImg1[1], $saveImg2[1]);
|
|
|
|
$offre = $offreMdl->publishOffer($saveImg1[1], $saveImg2[1]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo $twig->render("OffreDetailTest.html", ['offre' => $offre]);
|
|
|
|
echo $twig->render("OffreDetailTest.html", ['offre' => $offre]);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -321,14 +325,14 @@ class UtilisateurControleur
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// display offers
|
|
|
|
public function displayOffer()
|
|
|
|
public function displayOffer()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
global $twig;
|
|
|
|
global $twig;
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($_GET["id"]) && intval($_GET["id"]) != null)
|
|
|
|
if (isset($_GET["id"]) && intval($_GET["id"]) != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$offreMdl = new OffreModele();
|
|
|
|
$offre = $this->userModel->getOfferFromId(intval($_GET["id"]));
|
|
|
|
$offre = $offreMdl->getOfferFromId(intval($_GET["id"]));
|
|
|
|
|
|
|
|
if($offre != NULL)
|
|
|
|
if($offre != NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
echo $twig->render("OffreDetailTest.html",['offre' => $offre]);
|
|
|
|
echo $twig->render("OffreDetailTest.html",['offre' => $offre]);
|
|
|
@ -339,65 +343,4 @@ class UtilisateurControleur
|
|
|
|
echo $twig->render("erreur.html", ['dVueErreur' => $dVueErreur]);
|
|
|
|
echo $twig->render("erreur.html", ['dVueErreur' => $dVueErreur]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected function listerEvenement()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$mdl = new UtilisateurModele();
|
|
|
|
|
|
|
|
$evenements = $mdl->getEvenement();
|
|
|
|
|
|
|
|
global $twig;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo $twig->render('evenement.html', ['evenements' => $evenements]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected function creerEvenement()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
global $twig;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($_FILES["image"])) {
|
|
|
|
|
|
|
|
$img = ImageSaver::SaveImage('image');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!Validation::validerEvenement($_POST["titre"], $_POST["description"], $_POST["date"], $_POST["nbPlaceMax"], $img[1])) {
|
|
|
|
|
|
|
|
$mdl = new UtilisateurModele();
|
|
|
|
|
|
|
|
$mdl->ajouterEvenement($_POST["titre"], $_POST["description"], $_POST["date"], $_POST["nbPlaceMax"], $img[1]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->listerEvenement();
|
|
|
|
|
|
|
|
} 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', []);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected function supprimerEvenement()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$mdl = new UtilisateurModele();
|
|
|
|
|
|
|
|
$mdl->deleteEvenement($_GET["id"]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->listerEvenement();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected function avoirDetailEvenement()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$mdl = new UtilisateurModele();
|
|
|
|
|
|
|
|
$evenement = $mdl->getEvenementById($_GET["id"]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
global $twig;
|
|
|
|
|
|
|
|
echo $twig->render('detailEvenement.html', ['evenement' => $evenement]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected function rechercherEvenement()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$mdl = new UtilisateurModele();
|
|
|
|
|
|
|
|
$evenements = $mdl->getEvenement();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(isset($_POST["recherche"]) AND !empty($_POST["recherche"]))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$recherche = Validation::nettoyerString($_POST["recherche"]);
|
|
|
|
|
|
|
|
$evenements = $mdl->getEvenementByTitre($recherche);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
global $twig;
|
|
|
|
|
|
|
|
echo $twig->render('evenement.html', ['evenements' => $evenements]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|