diff --git a/.gitignore b/.gitignore
index 2608b43..426c53c 100755
--- a/.gitignore
+++ b/.gitignore
@@ -474,3 +474,6 @@ composer.lock
*.scss.map
php/.idea/
+
+##### Images :
+php/public/uploads/
diff --git a/php/public/css/menu.css b/php/public/css/menu.css
index 6ab9e3d..4acceb6 100644
--- a/php/public/css/menu.css
+++ b/php/public/css/menu.css
@@ -39,6 +39,7 @@ a {
padding: 10px;
text-transform: uppercase;
transition: 0.2s;
+ text-decoration: none;
}
.navbar-container .nav-items .nav-link:after {
@@ -65,12 +66,15 @@ a {
text-transform: uppercase;
border-radius: 15px;
border: #fff 2px solid;
+ text-decoration: none;
}
.navbar-container .nav-items .login-register .button2{
background: #00DBFF;
color: #fff;
border-radius: 15px;
+ text-decoration: none;
+
}
.navbar-container .nav-items .login-register .button:hover {
diff --git a/php/src/config/Validation.php b/php/src/config/Validation.php
index 10901a9..59cb150 100755
--- a/php/src/config/Validation.php
+++ b/php/src/config/Validation.php
@@ -71,7 +71,7 @@ class Validation
$file = $_FILES[$img]["tmp_name"];
$mime = mime_content_type($file);
- $maxFileSize = 10 * 1024 * 1024; // 10MB
+ $maxFileSize = 10 * 1024 * 1024; // 10MB Taille max acceptée
if (in_array($mime, $typesMime) && $_FILES[$img]["size"] <= $maxFileSize) {
return true;
}
@@ -80,7 +80,7 @@ class Validation
}
- public static function checkNumber($number) : bool
+ public static function validateNumber($number) : bool
{
if(preg_match("/^[0-9]{10}$/", $number))
{
@@ -98,4 +98,22 @@ class Validation
return false;
}
+ public static function validateTypeContract($typeContrat) : bool
+ {
+ $contrats = ["CDI","CDD","Stage","Alternance"];
+ return in_array($typeContrat,$contrats);
+ }
+
+ public static function validateExperience($exp): bool
+ {
+ $experiences = ["Junior","Senior","Indifférent"];
+ return in_array($exp,$experiences);
+ }
+
+ public static function validateTypeStudies($level) : bool
+ {
+ $studies = ["Bac+2","Bac+3","Bac+5","Indifférent"];
+ return in_array($level,$studies);
+ }
+
}
diff --git a/php/src/config/config.php b/php/src/config/config.php
index 5b6e343..51f5581 100755
--- a/php/src/config/config.php
+++ b/php/src/config/config.php
@@ -10,3 +10,5 @@ $dConfig['includes']= array('controleur/Validation.php');
$base = 'mysql:host=localhost;dbname=dbAlica';
$login = 'test';
$mdp = 'test';
+
+static $OffersByPage = 5;
\ No newline at end of file
diff --git a/php/src/controleur/UtilisateurControleur.php b/php/src/controleur/UtilisateurControleur.php
index 2b02cf3..c1ad0bb 100755
--- a/php/src/controleur/UtilisateurControleur.php
+++ b/php/src/controleur/UtilisateurControleur.php
@@ -12,6 +12,8 @@ use App\modele\OffreModele;
use App\modele\ImageModele;
use App\TwigExtensions;
+use APp\config;
+
class UtilisateurControleur
{
@@ -20,7 +22,7 @@ class UtilisateurControleur
global $twig;
if (!isset($_REQUEST["action"])) {
//$action = NULL;
- $action = "createOfferForm";
+ $action = "consultOffers";
} else {
$action = \App\config\Validation::nettoyerString($_REQUEST["action"]);
}
@@ -113,10 +115,45 @@ class UtilisateurControleur
$offerMdl = new OffreModele();
global $twig;
- // Nombre total de pages
- $numberPages = ceil($offerMdl->getNbOffers() / 5);
+ $niveauEtudes=null;
+ $typeContrat=null;
+ $exp = null;
+
+ $nbOffers = 5 ;
+
+ if(isset($_GET["education"]) && Validation::validateTypeStudies($_GET["education"])) {
+ $niveauEtudes = $_GET["education"];
+ }
+
+ if(isset($_GET["typeContrat"]) && Validation::validateTypeContract($_GET["typeContrat"])) {
+ $typeContrat = $_GET["typeContrat"];
+ }
+
+ if(isset($_GET["exp"]) && Validation::validateExperience($_GET["exp"])) {
+ $exp = $_GET["exp"];
+ }
+
+ if ($niveauEtudes == null && $typeContrat == null && $exp == null) {
+ $totalOffers = $offerMdl->getNbOffers();
+ } else {
+ $params = array(
+ 'typeContrat' => $typeContrat,
+ 'exp' => $exp,
+ 'niveauEtudes' => $niveauEtudes,
+ );
+ $offers = $offerMdl->getOffersWithFilters($params);
+ $totalOffers = count($offers);
+ }
+
+ $numberPages = ceil($totalOffers / 5);
+
+ if($numberPages == 0 )
+ {
+
+ echo $twig->render("erreur.html",['dVueErreur' => ['Aucune Offre Trouvée']]);
+ return;
+ }
- // Gestion de la page actuelle
if (isset($_GET["page"]) && intval($_GET["page"]) != null) {
$page = intval($_GET["page"]);
if ($page > $numberPages || $page < 1) {
@@ -125,14 +162,23 @@ class UtilisateurControleur
return;
}
} else {
- $page = 1;}
+ $page = 1;
+ }
$start = intval(($page - 1) * 5);
- $end = 5;
- $offers = $offerMdl->getOfferLimit($start, $end);
+ if ($niveauEtudes == null && $typeContrat == null && $exp == null) {
+ $offers = $offerMdl->getOfferLimit($start, $nbOffers);
+ } else {
+ $params['start'] = $start;
+ $params['nbOffers'] = 5;
+ $offers = $offerMdl->getOffersWithFilters($params);
+ }
+
+ echo "filtre :".$niveauEtudes."
";
+ echo "filtre :".$typeContrat."
";
+ echo "filtre :".$exp."
";
- // Affichage du template avec les données
echo $twig->render('OffersList.html', [
'offres' => $offers,
'numberPages' => $numberPages,
@@ -175,7 +221,7 @@ class UtilisateurControleur
$taberror[] = "Email non valide !";
}
- if(!Validation::checkNumber($_POST["num"]))
+ if(!Validation::validateNumber($_POST["num"]))
{
$taberror[] = "Numero non valide !";
//echo $twig->render("CreerOffre.html", ['errMsg' => "Numero non valide !" ]);
@@ -204,10 +250,9 @@ class UtilisateurControleur
if($saveImg1[0] && $saveImg2[0]) {
$offreMdl = new OffreModele();
- for($i=0;$i<100;$i++)
- {
- $offre = $offreMdl->publishOffers($saveImg1[1], $saveImg2[1]);
- }
+
+ $offre = $offreMdl->publishOffer($saveImg1[1], $saveImg2[1]);
+
echo $twig->render("OffreDetailTest.html", ['offre' => $offre]);
}
else
diff --git a/php/src/gateway/OffreGateway.php b/php/src/gateway/OffreGateway.php
index f67296c..89eb006 100755
--- a/php/src/gateway/OffreGateway.php
+++ b/php/src/gateway/OffreGateway.php
@@ -33,12 +33,12 @@ class OffreGateway
return intval($res[0]['COUNT(*)']);
}
- public function getOfferLimit($start, $end): array
+ public function getOfferLimit($start, $nbOffers): array
{
- $query = 'SELECT * FROM Offre LIMIT :s, :e';
+ $query = 'SELECT * FROM Offre LIMIT :s, :nb';
$this->con->executeQuery($query, array(
':s' => array($start, \PDO::PARAM_INT),
- ':e' => array($end, \PDO::PARAM_INT)
+ ':nb' => array($nbOffers, \PDO::PARAM_INT)
));
//echo "start : " . $start . "
end : " . $end . "
";
@@ -88,4 +88,44 @@ class OffreGateway
));
return $this->con->getResults();
}
+
+ public function getOffersWithFilters($filters) : array
+ {
+ $typeContrat = $filters['typeContrat'];
+ $exp = $filters['exp'];
+ $niveauEtudes = $filters['niveauEtudes'];
+
+ $query = "SELECT * FROM Offre WHERE";
+
+ $params = array();
+
+ if ($typeContrat != null) {
+ $query .= " typeContrat = :type";
+ $params[':type'] = array($typeContrat, \PDO::PARAM_STR);
+ }
+
+ if ($exp != null) {
+ $query .= ($typeContrat != null ? " AND" : "") . " experience = :exp";
+ $params[':exp'] = array($exp, \PDO::PARAM_STR);
+ }
+
+ if ($niveauEtudes != null) {
+ $query .= (($typeContrat != null || $exp != null) ? " AND" : "") . " niveauEtudes = :lvl";
+ $params[':lvl'] = array($niveauEtudes, \PDO::PARAM_STR);
+ }
+
+ if(isset($filters['start']) && isset($filters['end']))
+ {
+ $query .= " LIMIT :s, :nb";
+ $params[':s'] = array($filters['start'], \PDO::PARAM_INT);
+ $params[':nb'] = array($filters['nbOffers'], \PDO::PARAM_INT);
+ }
+
+ $this->con->executeQuery($query, $params);
+
+ return $this->con->getResults();
+ }
+
+
+
}
\ No newline at end of file
diff --git a/php/src/modele/OffreModele.php b/php/src/modele/OffreModele.php
index aed6494..dbeb385 100644
--- a/php/src/modele/OffreModele.php
+++ b/php/src/modele/OffreModele.php
@@ -20,7 +20,7 @@ class OffreModele
$this->offreGw = new OffreGateway(new Connection("mysql:host=localhost;dbname=dbAlica", "test", "test"));
}
- public function publishOffers(string $img,string $logo)
+ public function publishOffer(string $img, string $logo)
{
$desc = $_POST["description"];
$descposte = $_POST["descriptPoste"];
@@ -42,6 +42,9 @@ class OffreModele
}
else $remote = false;
+ echo "education :".$_POST['education'];
+ echo '
';
+
// à la place de NULL passer id utilisateur créateur offre
$offre = new Offre($this->offreGw->getNewId(),
new Alumni(12,"test.mail@icloud.fr","password","admin"),
@@ -70,7 +73,7 @@ class OffreModele
public function getOffers() : array
{
$res = $this->offreGw->getOffers();
- $offers = $this->CreateOffers($res);
+ $offers = $this->CreateOffersFromGw($res);
return $offers;
}
@@ -79,11 +82,11 @@ class OffreModele
{
$res = $this->offreGw->getOfferFromId($id);
if($res != null)
- return $this->CreateOffers($res)[0];
+ return $this->CreateOffersFromGw($res)[0];
return null;
}
- public function CreateOffers($res) : array
+ public function CreateOffersFromGw($res) : array
{
$alGw = new AlumniGateway(new Connection("mysql:host=localhost;dbname=dbAlica", "test", "test"));
@@ -120,10 +123,10 @@ class OffreModele
return $offers;
}
- public function getOfferLimit($start, $end): array
+ public function getOfferLimit($start, $nbOffers): array
{
- $res = $this->offreGw->getOfferLimit($start, $end);
- return $this->CreateOffers($res);
+ $res = $this->offreGw->getOfferLimit($start, $nbOffers);
+ return $this->CreateOffersFromGw($res);
}
public function getNbOffers() : int
@@ -131,4 +134,9 @@ class OffreModele
return $this->offreGw->getNbOffers();
}
+ public function getOffersWithFilters($params) : array
+ {
+ return $this->offreGw->getOffersWithFilters($params);
+ }
+
}
\ No newline at end of file
diff --git a/php/templates/CreerOffre.html b/php/templates/CreerOffre.html
index 5dd1631..e20aaf3 100644
--- a/php/templates/CreerOffre.html
+++ b/php/templates/CreerOffre.html
@@ -80,25 +80,14 @@
-
-