resolution bug deco

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

@ -18,12 +18,20 @@ class FrontControleur
global $twig; global $twig;
session_start(); session_start();
if($_SESSION["utilisateur"]){
$twig->addGlobal('nom', $_SESSION["utilisateur"]->getNom()); //var_dump($_SESSION['utilisateur']);
$twig->addGlobal('prenom', $_SESSION["utilisateur"]->getPrenom());
$twig->addGlobal('role', $_SESSION["utilisateur"]->getRole());
$twig->addGlobal('id', $_SESSION["utilisateur"]->getId());
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 = new AltoRouter();
$router->setBasePath('/SAE_2A_FA-Reseau_ALICA/php'); $router->setBasePath('/SAE_2A_FA-Reseau_ALICA/php');

@ -1,20 +1,99 @@
<?php <?php
namespace App\controleur; namespace App\controleur;
use App\config\Validation;
use App\gateway\ImageSaver;
class MembreControleur extends UtilisateurControleur class MembreControleur extends UtilisateurControleur
{ {
public function __construct() public function __construct()
{ {
} }
protected function deconnexion() public function deconnexion()
{ {
session_destroy(); session_destroy();
echo "on est passes ici"; echo "on est passes ici";
header('Location: index.php?action=accueil'); //header('Location: index.php?action=accueil');
global $twig;
$twig->render('accueil.html',[]);
exit(); 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() protected function proposerOffre()
{ {
//TODO //TODO

@ -185,80 +185,8 @@ 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) public function displayOffer(?array $params)
{ {
global $twig; global $twig;

@ -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="{{dir}}/deconnexion" class="button">Déconnexion</a> <a href="{{dir}}/user/{{id}}/deconnexion" class="button">Déconnexion</a>
{% else %} {% else %}
<div class="login-register"> <div class="login-register">
<a href="{{dir}}/connection" class="button">Connexion</a> <a href="{{dir}}/connection" class="button">Connexion</a>

Loading…
Cancel
Save