|
|
|
@ -2,23 +2,29 @@
|
|
|
|
|
|
|
|
|
|
namespace App\controleur;
|
|
|
|
|
|
|
|
|
|
use App\config;
|
|
|
|
|
use App\config\Validation;
|
|
|
|
|
use App\gateway\Connection;
|
|
|
|
|
use App\gateway\ImageSaver;
|
|
|
|
|
use App\modele\OffreModele;
|
|
|
|
|
use App\gateway\OffreGateway;
|
|
|
|
|
use App\modele\UtilisateurModele;
|
|
|
|
|
|
|
|
|
|
use App\config;
|
|
|
|
|
|
|
|
|
|
class UtilisateurControleur
|
|
|
|
|
{
|
|
|
|
|
private \App\modele\UtilisateurModele $userModel;
|
|
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
global $twig;
|
|
|
|
|
|
|
|
|
|
$this->userModel = new \App\modele\UtilisateurModele();
|
|
|
|
|
|
|
|
|
|
if (!isset($_REQUEST["action"])) {
|
|
|
|
|
//$action = NULL;
|
|
|
|
|
$action = "listerEvenement";
|
|
|
|
|
$action = "consultOffers";
|
|
|
|
|
} else {
|
|
|
|
|
$action = Validation::nettoyerString($_REQUEST["action"]);
|
|
|
|
|
$action = \App\config\Validation::nettoyerString($_REQUEST["action"]);
|
|
|
|
|
}
|
|
|
|
|
switch ($action) {
|
|
|
|
|
case NULL:
|
|
|
|
@ -33,6 +39,7 @@ class UtilisateurControleur
|
|
|
|
|
break;
|
|
|
|
|
case "inscription":
|
|
|
|
|
$this->inscription();
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "consultOffers":
|
|
|
|
|
$this->consultOffers();
|
|
|
|
@ -49,24 +56,10 @@ class UtilisateurControleur
|
|
|
|
|
case "displayOffer":
|
|
|
|
|
$this->displayOffer();
|
|
|
|
|
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:
|
|
|
|
|
$dVueErreur[] = "Action inconnue ou non autorisée";
|
|
|
|
|
echo $twig->render("erreur.html", ['dVueErreur' => $dVueErreur]);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -115,20 +108,6 @@ class UtilisateurControleur
|
|
|
|
|
}
|
|
|
|
|
$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) {
|
|
|
|
|
header('Location: index.php?action=inscription_success');
|
|
|
|
|
exit();
|
|
|
|
@ -165,17 +144,25 @@ class UtilisateurControleur
|
|
|
|
|
//TODO
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return void
|
|
|
|
|
* @brief Affiche la liste des offres d'emploi
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
protected function consultOffers()
|
|
|
|
|
{
|
|
|
|
|
$offerMdl = new OffreModele();
|
|
|
|
|
|
|
|
|
|
global $twig;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$niveauEtudes=null;
|
|
|
|
|
$typeContrat=null;
|
|
|
|
|
$exp = null;
|
|
|
|
|
|
|
|
|
|
// number of offers by pages
|
|
|
|
|
$nbOffers = 5 ;
|
|
|
|
|
|
|
|
|
|
/** validation of entry's : */
|
|
|
|
|
if(isset($_GET["niveauEtudes"]) && Validation::validateTypeStudies($_GET["niveauEtudes"])) {
|
|
|
|
|
$niveauEtudes = $_GET["niveauEtudes"];
|
|
|
|
|
}
|
|
|
|
@ -189,26 +176,30 @@ class UtilisateurControleur
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($niveauEtudes == null && $typeContrat == null && $exp == null) {
|
|
|
|
|
$totalOffers = $offerMdl->getNbOffers();
|
|
|
|
|
$totalOffers = $this->userModel->getNbOffers();
|
|
|
|
|
} else {
|
|
|
|
|
$params = array(
|
|
|
|
|
'typeContrat' => $typeContrat,
|
|
|
|
|
'exp' => $exp,
|
|
|
|
|
'niveauEtudes' => $niveauEtudes,
|
|
|
|
|
);
|
|
|
|
|
$offers = $offerMdl->getOffersWithFilters($params);
|
|
|
|
|
$offers = $this->userModel->getOffersWithFilters($params);
|
|
|
|
|
$totalOffers = count($offers);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// get the current pages to display
|
|
|
|
|
$numberPages = ceil($totalOffers / 5);
|
|
|
|
|
|
|
|
|
|
if($numberPages == 0 )
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
echo $twig->render("erreur.html",['dVueErreur' => ['Aucune Offre Trouvée']]);
|
|
|
|
|
echo $twig->render("OffersList.html",['dVueErreur' => ['Aucune Offre Trouvée']]);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// validate the page number
|
|
|
|
|
if (isset($_GET["page"]) && intval($_GET["page"]) != null) {
|
|
|
|
|
$page = intval($_GET["page"]);
|
|
|
|
|
if ($page > $numberPages || $page < 1) {
|
|
|
|
@ -220,16 +211,19 @@ class UtilisateurControleur
|
|
|
|
|
$page = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$start = intval(($page - 1) * 5);
|
|
|
|
|
|
|
|
|
|
if ($niveauEtudes == null && $typeContrat == null && $exp == null) {
|
|
|
|
|
$offers = $offerMdl->getOfferLimit($start, $nbOffers);
|
|
|
|
|
$offers = $this->userModel->getOfferLimit($start, $nbOffers);
|
|
|
|
|
} else {
|
|
|
|
|
$params['start'] = $start;
|
|
|
|
|
$params['nbOffers'] = 5;
|
|
|
|
|
$offers = $offerMdl->getOffersWithFilters($params);
|
|
|
|
|
$offers = $this->userModel->getOffersWithFilters($params);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* echo "filtre :".$niveauEtudes."<br>";
|
|
|
|
|
echo "filtre :".$typeContrat."<br>";
|
|
|
|
|
echo "filtre :".$exp."<br>";*/
|
|
|
|
@ -247,12 +241,18 @@ class UtilisateurControleur
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// display the form to create an offer
|
|
|
|
|
protected function createOfferForm()
|
|
|
|
|
{
|
|
|
|
|
global $twig;
|
|
|
|
|
echo $twig->render("CreerOffre.html", []);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// create offer
|
|
|
|
|
protected function createOffer()
|
|
|
|
|
{
|
|
|
|
|
global $twig;
|
|
|
|
@ -260,6 +260,8 @@ class UtilisateurControleur
|
|
|
|
|
|
|
|
|
|
$requiredFields = ['name', 'entreprise', 'description','typeContrat', 'descriptPoste', 'profilRecherche', 'choixExp', 'education', 'mail', 'num'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// validate required fields
|
|
|
|
|
$error = false;
|
|
|
|
|
foreach ($requiredFields as $field) {
|
|
|
|
|
if (empty($_POST[$field])) {
|
|
|
|
@ -273,6 +275,8 @@ class UtilisateurControleur
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// validate entrys
|
|
|
|
|
if(!Validation::verifierEmail($_POST["mail"]))
|
|
|
|
|
{
|
|
|
|
|
//echo $twig->render("CreerOffre.html", ['errMsg' => "Email non valide !" ]);
|
|
|
|
@ -297,6 +301,8 @@ class UtilisateurControleur
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if errors display the form with errors
|
|
|
|
|
if(count($taberror) > 0)
|
|
|
|
|
{
|
|
|
|
|
echo $twig->render("CreerOffre.html", ['tabError' => $taberror ]);
|
|
|
|
@ -306,10 +312,8 @@ class UtilisateurControleur
|
|
|
|
|
$saveImg1 = ImageSaver::SaveImage("image");
|
|
|
|
|
$saveImg2 = ImageSaver::SaveImage("logo");
|
|
|
|
|
if($saveImg1[0] && $saveImg2[0]) {
|
|
|
|
|
$offreMdl = new OffreModele();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$offre = $offreMdl->publishOffer($saveImg1[1], $saveImg2[1]);
|
|
|
|
|
$offre = $this->userModel->publishOffer($saveImg1[1], $saveImg2[1]);
|
|
|
|
|
|
|
|
|
|
echo $twig->render("OffreDetailTest.html", ['offre' => $offre]);
|
|
|
|
|
}
|
|
|
|
@ -321,14 +325,14 @@ class UtilisateurControleur
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// display offers
|
|
|
|
|
public function displayOffer()
|
|
|
|
|
{
|
|
|
|
|
global $twig;
|
|
|
|
|
|
|
|
|
|
if (isset($_GET["id"]) && intval($_GET["id"]) != null)
|
|
|
|
|
{
|
|
|
|
|
$offreMdl = new OffreModele();
|
|
|
|
|
$offre = $offreMdl->getOfferFromId(intval($_GET["id"]));
|
|
|
|
|
$offre = $this->userModel->getOfferFromId(intval($_GET["id"]));
|
|
|
|
|
if($offre != NULL)
|
|
|
|
|
{
|
|
|
|
|
echo $twig->render("OffreDetailTest.html",['offre' => $offre]);
|
|
|
|
@ -339,65 +343,4 @@ class UtilisateurControleur
|
|
|
|
|
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]);
|
|
|
|
|
}
|
|
|
|
|
}
|