resolution bug deco

alexis-rendu
Baptiste D 1 year ago
parent ed00c99894
commit 43729cfd59

@ -18,12 +18,20 @@ class FrontControleur
global $twig;
session_start();
if($_SESSION["utilisateur"]){
$twig->addGlobal('nom', $_SESSION["utilisateur"]->getNom());
$twig->addGlobal('prenom', $_SESSION["utilisateur"]->getPrenom());
$twig->addGlobal('role', $_SESSION["utilisateur"]->getRole());
$twig->addGlobal('id', $_SESSION["utilisateur"]->getId());
//var_dump($_SESSION['utilisateur']);
if ($_SESSION['utilisateur'] != NULL) {
// echo on y passe
$twig->addGlobal('nom', $_SESSION['utilisateur']->getNom());
$twig->addGlobal('prenom', $_SESSION['utilisateur']->getPrenom());
$twig->addGlobal('role', $_SESSION['utilisateur']->getRole());
$twig->addGlobal('id', $_SESSION['utilisateur']->getId());
}
$router = new AltoRouter();
$router->setBasePath('/SAE_2A_FA-Reseau_ALICA/php');

@ -1,20 +1,99 @@
<?php
namespace App\controleur;
use App\config\Validation;
use App\gateway\ImageSaver;
class MembreControleur extends UtilisateurControleur
{
public function __construct()
{
}
protected function deconnexion()
public function deconnexion()
{
session_destroy();
echo "on est passes ici";
header('Location: index.php?action=accueil');
//header('Location: index.php?action=accueil');
global $twig;
$twig->render('accueil.html',[]);
exit();
}
public function createOfferForm()
{
global $twig;
echo $twig->render("CreerOffre.html", []);
}
public function createOffer()
{
global $twig;
$taberror = [];
$requiredFields = ['name', 'entreprise', 'description','typeContrat', 'descriptPoste', 'profilRecherche', 'choixExp', 'education', 'mail', 'num'];
$error = false;
foreach ($requiredFields as $field) {
if (empty($_POST[$field])) {
$error = true;
$taberror[] = "Le champ {$field} est requis !";
}
}
if($error)
{
echo $twig->render("CreerOffre.html", ['tabError' => $taberror ]);
return;
}
if(!Validation::verifierEmail($_POST["mail"]))
{
//echo $twig->render("CreerOffre.html", ['errMsg' => "Email non valide !" ]);
$taberror[] = "Email non valide !";
}
if(!Validation::validateNumber($_POST["num"]))
{
$taberror[] = "Numero non valide !";
//echo $twig->render("CreerOffre.html", ['errMsg' => "Numero non valide !" ]);
}
if (!Validation::validateImage("image"))
{
if(isset($_FILES['image']['name'])) {$taberror[] = "Image non valide !";}
else {$taberror[] = "Inserez une image !";}
}
if(!Validation::validateImage("logo")) {
if(isset($_FILES['logo']['name'])) {$taberror[] = "Logo non valide !";}
else {$taberror[] = "Inserez un logo !";}
return;
}
if(count($taberror) > 0)
{
echo $twig->render("CreerOffre.html", ['tabError' => $taberror ]);
}
else{
$saveImg1 = ImageSaver::SaveImage("image");
$saveImg2 = ImageSaver::SaveImage("logo");
if($saveImg1[0] && $saveImg2[0]) {
$mbrModel = new MembreModele();
$offre = $mbrModel->publishOffer($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 ]);
}
}
}
protected function proposerOffre()
{
//TODO

@ -185,79 +185,7 @@ class UtilisateurControleur
]);
}
public function createOfferForm()
{
global $twig;
echo $twig->render("CreerOffre.html", []);
}
public function createOffer()
{
global $twig;
$taberror = [];
$requiredFields = ['name', 'entreprise', 'description','typeContrat', 'descriptPoste', 'profilRecherche', 'choixExp', 'education', 'mail', 'num'];
$error = false;
foreach ($requiredFields as $field) {
if (empty($_POST[$field])) {
$error = true;
$taberror[] = "Le champ {$field} est requis !";
}
}
if($error)
{
echo $twig->render("CreerOffre.html", ['tabError' => $taberror ]);
return;
}
if(!Validation::verifierEmail($_POST["mail"]))
{
//echo $twig->render("CreerOffre.html", ['errMsg' => "Email non valide !" ]);
$taberror[] = "Email non valide !";
}
if(!Validation::validateNumber($_POST["num"]))
{
$taberror[] = "Numero non valide !";
//echo $twig->render("CreerOffre.html", ['errMsg' => "Numero non valide !" ]);
}
if (!Validation::validateImage("image"))
{
if(isset($_FILES['image']['name'])) {$taberror[] = "Image non valide !";}
else {$taberror[] = "Inserez une image !";}
}
if(!Validation::validateImage("logo")) {
if(isset($_FILES['logo']['name'])) {$taberror[] = "Logo non valide !";}
else {$taberror[] = "Inserez un logo !";}
return;
}
if(count($taberror) > 0)
{
echo $twig->render("CreerOffre.html", ['tabError' => $taberror ]);
}
else{
$saveImg1 = ImageSaver::SaveImage("image");
$saveImg2 = ImageSaver::SaveImage("logo");
if($saveImg1[0] && $saveImg2[0]) {
$mbrModel = new MembreModele();
$offre = $mbrModel->publishOffer($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(?array $params)
{

@ -27,7 +27,7 @@
<!-- Afficher boutons de connexion et d'inscription -->
{% if nom and prenom %}
<!-- Afficher bouton de déconnexion -->
<a href="{{dir}}/deconnexion" class="button">Déconnexion</a>
<a href="{{dir}}/user/{{id}}/deconnexion" class="button">Déconnexion</a>
{% else %}
<div class="login-register">
<a href="{{dir}}/connection" class="button">Connexion</a>

Loading…
Cancel
Save