|
|
@ -5,6 +5,7 @@ namespace App\controleur;
|
|
|
|
use App\config\Validation;
|
|
|
|
use App\config\Validation;
|
|
|
|
use App\gateway\Connection;
|
|
|
|
use App\gateway\Connection;
|
|
|
|
use App\gateway\ImageGateway;
|
|
|
|
use App\gateway\ImageGateway;
|
|
|
|
|
|
|
|
use App\gateway\ImageSaver;
|
|
|
|
use App\gateway\OffreGateway;
|
|
|
|
use App\gateway\OffreGateway;
|
|
|
|
use App\metier\Image;
|
|
|
|
use App\metier\Image;
|
|
|
|
use App\modele\OffreModele;
|
|
|
|
use App\modele\OffreModele;
|
|
|
@ -13,6 +14,7 @@ use App\TwigExtensions;
|
|
|
|
|
|
|
|
|
|
|
|
class UtilisateurControleur
|
|
|
|
class UtilisateurControleur
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
global $twig;
|
|
|
|
global $twig;
|
|
|
@ -110,13 +112,37 @@ class UtilisateurControleur
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$offerMdl = new OffreModele();
|
|
|
|
$offerMdl = new OffreModele();
|
|
|
|
global $twig;
|
|
|
|
global $twig;
|
|
|
|
$twig->addExtension(new TwigExtensions()); // Ajouter l'extension personnalisée à l'environnement Twig
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$offers = $offerMdl->getOffers();
|
|
|
|
// Nombre total de pages
|
|
|
|
|
|
|
|
$numberPages = ceil($offerMdl->getNbOffers() / 5);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Gestion de la page actuelle
|
|
|
|
|
|
|
|
if (isset($_GET["page"]) && intval($_GET["page"]) != null) {
|
|
|
|
|
|
|
|
$page = intval($_GET["page"]);
|
|
|
|
|
|
|
|
if ($page > $numberPages || $page < 1) {
|
|
|
|
|
|
|
|
$dVueErreur[] = "Page introuvable";
|
|
|
|
|
|
|
|
echo $twig->render("erreur.html", ['dVueErreur' => $dVueErreur]);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$page = 1;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$start = intval(($page - 1) * 5);
|
|
|
|
|
|
|
|
$end = 5;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$offers = $offerMdl->getOfferLimit($start, $end);
|
|
|
|
|
|
|
|
|
|
|
|
echo $twig->render('OffersList.html', ['offres' => $offers]);
|
|
|
|
// Affichage du template avec les données
|
|
|
|
|
|
|
|
echo $twig->render('OffersList.html', [
|
|
|
|
|
|
|
|
'offres' => $offers,
|
|
|
|
|
|
|
|
'numberPages' => $numberPages,
|
|
|
|
|
|
|
|
'currentPage' => $page
|
|
|
|
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected function createOfferForm()
|
|
|
|
protected function createOfferForm()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
global $twig;
|
|
|
|
global $twig;
|
|
|
@ -126,16 +152,23 @@ class UtilisateurControleur
|
|
|
|
protected function createOffer()
|
|
|
|
protected function createOffer()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
global $twig;
|
|
|
|
global $twig;
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
|
|
$taberror = [];
|
|
|
|
$requiredFields = ['name', 'entreprise', 'description','typeContrat', 'descriptPoste', 'profilRecherche', 'choixExp', 'education', 'mail', 'num'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($requiredFields as $field) {
|
|
|
|
$requiredFields = ['name', 'entreprise', 'description','typeContrat', 'descriptPoste', 'profilRecherche', 'choixExp', 'education', 'mail', 'num'];
|
|
|
|
if (empty($_POST[$field])) {
|
|
|
|
|
|
|
|
echo $twig->render("creerOffre.html", ['errMsg' => $field]);
|
|
|
|
$error = false;
|
|
|
|
}
|
|
|
|
foreach ($requiredFields as $field) {
|
|
|
|
|
|
|
|
if (empty($_POST[$field])) {
|
|
|
|
|
|
|
|
$error = true;
|
|
|
|
|
|
|
|
$taberror[] = "Le champ {$field} est requis !";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$taberror = [];
|
|
|
|
if($error)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
echo $twig->render("CreerOffre.html", ['tabError' => $taberror ]);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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 !" ]);
|
|
|
@ -151,45 +184,38 @@ class UtilisateurControleur
|
|
|
|
|
|
|
|
|
|
|
|
if (!Validation::validateImage("image"))
|
|
|
|
if (!Validation::validateImage("image"))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(isset($_FILES['image']['name']))
|
|
|
|
if(isset($_FILES['image']['name'])) {$taberror[] = "Image non valide !";}
|
|
|
|
{
|
|
|
|
else {$taberror[] = "Inserez une image !";}
|
|
|
|
$taberror[] = "Image non valide !";
|
|
|
|
|
|
|
|
//echo $twig->render("CreerOffre.html", ['errMsg' => "Image {$imgName} non valide !" ]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
//echo $twig->render("CreerOffre.html", ['errMsg' => "Inserez une image" ]);
|
|
|
|
|
|
|
|
$taberror[] = "Inserez une image !";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!Validation::validateImage("logo")) {
|
|
|
|
if(!Validation::validateImage("logo")) {
|
|
|
|
if(isset($_FILES['logo']['name']))
|
|
|
|
if(isset($_FILES['logo']['name'])) {$taberror[] = "Logo non valide !";}
|
|
|
|
{
|
|
|
|
else {$taberror[] = "Inserez un logo !";}
|
|
|
|
$taberror[] = "Logo non valide !";
|
|
|
|
|
|
|
|
//echo $twig->render("CreerOffre.html", ['errMsg' => "Image {$imgName} non valide !" ]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$taberror[] = "Inserez un logo !";
|
|
|
|
|
|
|
|
//echo $twig->render("CreerOffre.html", ['errMsg' => "Inserez un logo" ]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(count($taberror) > 0)
|
|
|
|
if(count($taberror) > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
echo $twig->render("CreerOffre.html", ['tabError' => $taberror ]);
|
|
|
|
echo $twig->render("CreerOffre.html", ['tabError' => $taberror ]);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
$imgMdl = new ImageModele();
|
|
|
|
$saveImg1 = ImageSaver::SaveImage("image");
|
|
|
|
$img = $imgMdl->publierImage("image");
|
|
|
|
$saveImg2 = ImageSaver::SaveImage("logo");
|
|
|
|
$logo = $imgMdl->publierImage("logo");
|
|
|
|
if($saveImg1[0] && $saveImg2[0]) {
|
|
|
|
$offreMdl = new OffreModele();
|
|
|
|
$offreMdl = new OffreModele();
|
|
|
|
$offre = $offreMdl->publishOffers($img, $logo);
|
|
|
|
|
|
|
|
echo $twig->render("OffreDetailTest.html", ['offre' => $offre]);
|
|
|
|
for($i=0;$i<100;$i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$offre = $offreMdl->publishOffers($saveImg1[1], $saveImg2[1]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
echo $twig->render("OffreDetailTest.html", ['offre' => $offre]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$taberror[] = "Erreur lors de l'upload des images";
|
|
|
|
|
|
|
|
echo $twig->render("CreerOffre.html", ['tabError' => $taberror ]);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function displayOffer()
|
|
|
|
public function displayOffer()
|
|
|
@ -199,7 +225,6 @@ class UtilisateurControleur
|
|
|
|
if (isset($_GET["id"]) && intval($_GET["id"]) != null)
|
|
|
|
if (isset($_GET["id"]) && intval($_GET["id"]) != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$offreMdl = new OffreModele();
|
|
|
|
$offreMdl = new OffreModele();
|
|
|
|
|
|
|
|
|
|
|
|
$offre = $offreMdl->getOfferFromId(intval($_GET["id"]));
|
|
|
|
$offre = $offreMdl->getOfferFromId(intval($_GET["id"]));
|
|
|
|
if($offre != NULL)
|
|
|
|
if($offre != NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -210,4 +235,5 @@ class UtilisateurControleur
|
|
|
|
$dVueErreur[] = "Erreur, Offre introuvable";
|
|
|
|
$dVueErreur[] = "Erreur, Offre introuvable";
|
|
|
|
echo $twig->render("erreur.html", ['dVueErreur' => $dVueErreur]);
|
|
|
|
echo $twig->render("erreur.html", ['dVueErreur' => $dVueErreur]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|