diff --git a/.DS_Store b/.DS_Store index 241613c..69c6f7e 100755 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/php/.DS_Store b/php/.DS_Store index 701de55..4813d6c 100755 Binary files a/php/.DS_Store and b/php/.DS_Store differ diff --git a/php/public/uploads/10329logo.png b/php/public/uploads/10329logo.png new file mode 100644 index 0000000..d272825 Binary files /dev/null and b/php/public/uploads/10329logo.png differ diff --git a/php/public/uploads/10640offre_cgi.webp b/php/public/uploads/10640offre_cgi.webp new file mode 100644 index 0000000..4876665 Binary files /dev/null and b/php/public/uploads/10640offre_cgi.webp differ diff --git a/php/public/uploads/10865offre_cgi.webp b/php/public/uploads/10865offre_cgi.webp new file mode 100644 index 0000000..4876665 Binary files /dev/null and b/php/public/uploads/10865offre_cgi.webp differ diff --git a/php/public/uploads/12013offre_cgi.webp b/php/public/uploads/12013offre_cgi.webp new file mode 100644 index 0000000..4876665 Binary files /dev/null and b/php/public/uploads/12013offre_cgi.webp differ diff --git a/php/public/uploads/12231GIB-e0c1f0d7.png b/php/public/uploads/12231GIB-e0c1f0d7.png new file mode 100644 index 0000000..2bc507a Binary files /dev/null and b/php/public/uploads/12231GIB-e0c1f0d7.png differ diff --git a/php/public/uploads/12311LOGO-CGI-1993-1998.svg.png b/php/public/uploads/12311LOGO-CGI-1993-1998.svg.png new file mode 100644 index 0000000..b02459b Binary files /dev/null and b/php/public/uploads/12311LOGO-CGI-1993-1998.svg.png differ diff --git a/php/public/uploads/12323Image-blob.png b/php/public/uploads/12323Image-blob.png new file mode 100644 index 0000000..637af31 Binary files /dev/null and b/php/public/uploads/12323Image-blob.png differ diff --git a/php/public/uploads/12664GIB-e0c1f0d7.png b/php/public/uploads/12664GIB-e0c1f0d7.png new file mode 100644 index 0000000..2bc507a Binary files /dev/null and b/php/public/uploads/12664GIB-e0c1f0d7.png differ diff --git a/php/public/uploads/12675GIB-e0c1f0d7.png b/php/public/uploads/12675GIB-e0c1f0d7.png new file mode 100644 index 0000000..2bc507a Binary files /dev/null and b/php/public/uploads/12675GIB-e0c1f0d7.png differ diff --git a/php/public/uploads/13524GIB-e0c1f0d7.png b/php/public/uploads/13524GIB-e0c1f0d7.png new file mode 100644 index 0000000..2bc507a Binary files /dev/null and b/php/public/uploads/13524GIB-e0c1f0d7.png differ diff --git a/php/public/uploads/13584GIB-e0c1f0d7.png b/php/public/uploads/13584GIB-e0c1f0d7.png new file mode 100644 index 0000000..2bc507a Binary files /dev/null and b/php/public/uploads/13584GIB-e0c1f0d7.png differ diff --git a/php/public/uploads/14479offre_cgi.webp b/php/public/uploads/14479offre_cgi.webp new file mode 100644 index 0000000..4876665 Binary files /dev/null and b/php/public/uploads/14479offre_cgi.webp differ diff --git a/php/public/uploads/14524Image-blob.png b/php/public/uploads/14524Image-blob.png new file mode 100644 index 0000000..637af31 Binary files /dev/null and b/php/public/uploads/14524Image-blob.png differ diff --git a/php/public/uploads/14609offre_cgi.webp b/php/public/uploads/14609offre_cgi.webp new file mode 100644 index 0000000..4876665 Binary files /dev/null and b/php/public/uploads/14609offre_cgi.webp differ diff --git a/php/public/uploads/14945Image-blob.png b/php/public/uploads/14945Image-blob.png new file mode 100644 index 0000000..637af31 Binary files /dev/null and b/php/public/uploads/14945Image-blob.png differ diff --git a/php/public/uploads/15505GIB-e0c1f0d7.png b/php/public/uploads/15505GIB-e0c1f0d7.png new file mode 100644 index 0000000..2bc507a Binary files /dev/null and b/php/public/uploads/15505GIB-e0c1f0d7.png differ diff --git a/php/public/uploads/15641Image-blob.png b/php/public/uploads/15641Image-blob.png new file mode 100644 index 0000000..637af31 Binary files /dev/null and b/php/public/uploads/15641Image-blob.png differ diff --git a/php/public/uploads/16452Modèles_Données.png b/php/public/uploads/16452Modèles_Données.png new file mode 100644 index 0000000..a7499e5 Binary files /dev/null and b/php/public/uploads/16452Modèles_Données.png differ diff --git a/php/public/uploads/16811GIB-e0c1f0d7.png b/php/public/uploads/16811GIB-e0c1f0d7.png new file mode 100644 index 0000000..2bc507a Binary files /dev/null and b/php/public/uploads/16811GIB-e0c1f0d7.png differ diff --git a/php/public/uploads/17883GIB-e0c1f0d7.png b/php/public/uploads/17883GIB-e0c1f0d7.png new file mode 100644 index 0000000..2bc507a Binary files /dev/null and b/php/public/uploads/17883GIB-e0c1f0d7.png differ diff --git a/php/public/uploads/18029Image-blob.png b/php/public/uploads/18029Image-blob.png new file mode 100644 index 0000000..637af31 Binary files /dev/null and b/php/public/uploads/18029Image-blob.png differ diff --git a/php/public/uploads/18188Image-blob.png b/php/public/uploads/18188Image-blob.png new file mode 100644 index 0000000..637af31 Binary files /dev/null and b/php/public/uploads/18188Image-blob.png differ diff --git a/php/public/uploads/18312Image-blob.png b/php/public/uploads/18312Image-blob.png new file mode 100644 index 0000000..637af31 Binary files /dev/null and b/php/public/uploads/18312Image-blob.png differ diff --git a/php/public/uploads/18373imgbin-cgi-group-business-process-information b/php/public/uploads/18373imgbin-cgi-group-business-process-information new file mode 100644 index 0000000..e284619 Binary files /dev/null and b/php/public/uploads/18373imgbin-cgi-group-business-process-information differ diff --git a/php/public/uploads/18801logo.png b/php/public/uploads/18801logo.png new file mode 100644 index 0000000..d272825 Binary files /dev/null and b/php/public/uploads/18801logo.png differ diff --git a/php/public/uploads/18852pexels-christian-heitz-842711.jpg b/php/public/uploads/18852pexels-christian-heitz-842711.jpg new file mode 100644 index 0000000..637af31 Binary files /dev/null and b/php/public/uploads/18852pexels-christian-heitz-842711.jpg differ diff --git a/php/public/uploads/19294GIB-e0c1f0d7.png b/php/public/uploads/19294GIB-e0c1f0d7.png new file mode 100644 index 0000000..2bc507a Binary files /dev/null and b/php/public/uploads/19294GIB-e0c1f0d7.png differ diff --git a/php/public/uploads/19712offre_cgi.webp b/php/public/uploads/19712offre_cgi.webp new file mode 100644 index 0000000..4876665 Binary files /dev/null and b/php/public/uploads/19712offre_cgi.webp differ diff --git a/php/src/config/Validation.php b/php/src/config/Validation.php index bc22c4f..10901a9 100755 --- a/php/src/config/Validation.php +++ b/php/src/config/Validation.php @@ -67,17 +67,19 @@ class Validation { if(isset($_FILES[$img])) { - $typesMime = array('image/jpeg', 'image/png','image/jpg','image/gif', 'image/bmp','image/webp'); + $typesMime = array('image/jpeg', 'image/png','image/jpg', 'image/bmp','image/webp'); $file = $_FILES[$img]["tmp_name"]; - $mime = mime_content_type($file); - if (in_array($mime, $typesMime)) { + $mime = mime_content_type($file); + $maxFileSize = 10 * 1024 * 1024; // 10MB + if (in_array($mime, $typesMime) && $_FILES[$img]["size"] <= $maxFileSize) { return true; } } return false; } + public static function checkNumber($number) : bool { if(preg_match("/^[0-9]{10}$/", $number)) diff --git a/php/src/controleur/UtilisateurControleur.php b/php/src/controleur/UtilisateurControleur.php index 6e6ca15..2b02cf3 100755 --- a/php/src/controleur/UtilisateurControleur.php +++ b/php/src/controleur/UtilisateurControleur.php @@ -5,6 +5,7 @@ namespace App\controleur; use App\config\Validation; use App\gateway\Connection; use App\gateway\ImageGateway; +use App\gateway\ImageSaver; use App\gateway\OffreGateway; use App\metier\Image; use App\modele\OffreModele; @@ -13,6 +14,7 @@ use App\TwigExtensions; class UtilisateurControleur { + public function __construct() { global $twig; @@ -110,13 +112,37 @@ class UtilisateurControleur { $offerMdl = new OffreModele(); 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() { global $twig; @@ -126,16 +152,23 @@ class UtilisateurControleur protected function createOffer() { global $twig; - if ($_SERVER['REQUEST_METHOD'] === 'POST') { - $requiredFields = ['name', 'entreprise', 'description','typeContrat', 'descriptPoste', 'profilRecherche', 'choixExp', 'education', 'mail', 'num']; + $taberror = []; - foreach ($requiredFields as $field) { - if (empty($_POST[$field])) { - echo $twig->render("creerOffre.html", ['errMsg' => $field]); - } + $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 !"; } } - $taberror = []; + if($error) + { + echo $twig->render("CreerOffre.html", ['tabError' => $taberror ]); + return; + } + if(!Validation::verifierEmail($_POST["mail"])) { //echo $twig->render("CreerOffre.html", ['errMsg' => "Email non valide !" ]); @@ -151,45 +184,38 @@ class UtilisateurControleur if (!Validation::validateImage("image")) { - if(isset($_FILES['image']['name'])) - { - $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(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 !"; - //echo $twig->render("CreerOffre.html", ['errMsg' => "Image {$imgName} non valide !" ]); - } - else - { - $taberror[] = "Inserez un logo !"; - //echo $twig->render("CreerOffre.html", ['errMsg' => "Inserez un 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{ - $imgMdl = new ImageModele(); - $img = $imgMdl->publierImage("image"); - $logo = $imgMdl->publierImage("logo"); - $offreMdl = new OffreModele(); - $offre = $offreMdl->publishOffers($img, $logo); - echo $twig->render("OffreDetailTest.html", ['offre' => $offre]); + $saveImg1 = ImageSaver::SaveImage("image"); + $saveImg2 = ImageSaver::SaveImage("logo"); + if($saveImg1[0] && $saveImg2[0]) { + $offreMdl = new OffreModele(); + + 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() @@ -199,7 +225,6 @@ class UtilisateurControleur if (isset($_GET["id"]) && intval($_GET["id"]) != null) { $offreMdl = new OffreModele(); - $offre = $offreMdl->getOfferFromId(intval($_GET["id"])); if($offre != NULL) { @@ -210,4 +235,5 @@ class UtilisateurControleur $dVueErreur[] = "Erreur, Offre introuvable"; echo $twig->render("erreur.html", ['dVueErreur' => $dVueErreur]); } + } \ No newline at end of file diff --git a/php/src/gateway/ImageSaver.php b/php/src/gateway/ImageSaver.php new file mode 100644 index 0000000..4e5671c --- /dev/null +++ b/php/src/gateway/ImageSaver.php @@ -0,0 +1,30 @@ +con = $con; } - public function getMaxid() : int + public function getNewId() : int { $query = 'SELECT MAX(id) FROM Offre'; $this->con->executeQuery($query, array()); @@ -25,16 +25,39 @@ class OffreGateway return intval($res[0]['MAX(id)'])+1; } + public function getNbOffers(): int + { + $query = 'SELECT COUNT(*) FROM Offre'; + $this->con->executeQuery($query, array()); + $res = $this->con->getResults(); + return intval($res[0]['COUNT(*)']); + } + + public function getOfferLimit($start, $end): array + { + $query = 'SELECT * FROM Offre LIMIT :s, :e'; + $this->con->executeQuery($query, array( + ':s' => array($start, \PDO::PARAM_INT), + ':e' => array($end, \PDO::PARAM_INT) + )); + + //echo "start : " . $start . "
end : " . $end . "
"; + //echo "Number of results: " . count($this->con->getResults()) . "
"; + return $this->con->getResults(); + } + + + public function addOffers(Offre $offre) { - $query = 'INSERT INTO Offre VALUES (:i, :o, :t, :d, :img, :logo, :ty, :v, :e, :desc, :pro, :exp, :niv, :mail, :num, :web, :remote)'; + $query = 'INSERT INTO Offre VALUES (:i, :o, :t, :d, :img, :logo, :ty, :v, :e, :desc, :pro, :exp, :niv, :mail, :num, :web, :remote, :date)'; $this->con->executeQuery($query, array( ':i' => array($offre->getId(), \PDO::PARAM_INT), ':o' => array($offre->getOffreurId(), \PDO::PARAM_STR), ':t' => array($offre->getNom(), \PDO::PARAM_STR), ':d' => array($offre->getDescription(), \PDO::PARAM_STR), - 'img' => array($offre->getImgId(), \PDO::PARAM_INT), - 'logo' => array($offre->getLogoId(), \PDO::PARAM_INT), + 'img' => array($offre->getImg(), \PDO::PARAM_STR), + 'logo' => array($offre->getLogo(), \PDO::PARAM_STR), ':ty' => array($offre->getTypeContrat(), \PDO::PARAM_STR), ':v' => array($offre->getVille(), \PDO::PARAM_STR), ':e' => array($offre->getEntreprise(), \PDO::PARAM_STR), @@ -45,11 +68,11 @@ class OffreGateway ':mail' => array($offre->getMailContact(), \PDO::PARAM_STR), ':num' => array($offre->getNumero(), \PDO::PARAM_STR), ':web' => array($offre->getSiteUrl(), \PDO::PARAM_STR), - ':remote' => array($offre->isRemote(), \PDO::PARAM_BOOL) + ':remote' => array($offre->isRemote(), \PDO::PARAM_BOOL), + ':date' => array($offre->getDateString(), \PDO::PARAM_STR) )); } - public function getOffers() : array { $query = 'SELECT * FROM offre'; diff --git a/php/src/metier/Offre.php b/php/src/metier/Offre.php index 4860e93..c5b9cc6 100755 --- a/php/src/metier/Offre.php +++ b/php/src/metier/Offre.php @@ -3,7 +3,7 @@ namespace App\metier; use App\metier\Alumni; use App\metier\Profil; - +use DateTime; class TypeContrat { const CDI = "CDI"; const CDD = "CDD"; @@ -88,9 +88,11 @@ class Offre //private \App\metier\NiveauEtudes $niveauEtudes; private string $niveauEtudes; - private Image $img; + private string $img; + + private string $logo; - private Image $logo; + private DateTime $date; /** * @var string Email de contact @@ -129,8 +131,8 @@ class Offre Alumni $offreur, string $nom, string $description, - Image $img, - Image $logo, + string $img, + string $logo, string $typeContrat, string $ville, string $entreprise, @@ -138,11 +140,11 @@ class Offre string $profil, string $experience, string $niveauEtudes, - //\App\metier\NiveauEtudes $niveauEtudes, string $mailContact, string $numero, string $siteUrl, - bool $remote) + bool $remote, + DateTime $date) { $this->id = $id; $this->offreur = $offreur; @@ -161,6 +163,7 @@ class Offre $this->numero = $numero; $this->siteUrl = $siteUrl; $this->remote = $remote; + $this->date = $date; } public function getId(): int @@ -178,16 +181,11 @@ class Offre return $this->offreur->getId(); } - public function getLogo(): Image + public function getLogo(): string { return $this->logo; } - public function setLogo(Image $logo): void - { - $this->logo = $logo; - } - public function getNom(): string { return $this->nom; @@ -203,24 +201,11 @@ class Offre return $this->img->getId(); } - public function getImg() : Image + public function getImg() : string { return $this->img; } - public function getImgId() : int - { - return $this->img->getId(); - } - - public function getLogoId() : int - { - return $this->logo->getId(); - } - public function getBlob() : string - { - return $this->img->getBlob(); - } public function getTypeContrat(): string { @@ -286,4 +271,20 @@ class Offre { return "Offre :,{$this->nom}, {$this->typeContrat},{$this->ville} {$this->entreprise}"; } + + public function getDate(): DateTime + { + return $this->date; + } + + public function getDateString() : string + { + return $this->date->format('Y-m-d'); + } + + public function getDateStringFr() + { + return $this->date->format('d/m/Y'); + } + } \ No newline at end of file diff --git a/php/src/modele/OffreModele.php b/php/src/modele/OffreModele.php index 0f72cdf..aed6494 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(Image $img,Image $logo) + public function publishOffers(string $img,string $logo) { $desc = $_POST["description"]; $descposte = $_POST["descriptPoste"]; @@ -34,6 +34,7 @@ class OffreModele $exp = $_POST["choixExp"]; $typeContrat = $_POST["typeContrat"]; $niveauEtudes = $_POST["education"]; + $date = new \DateTime(); if(isset($_POST["fullRemote"])) { @@ -42,7 +43,7 @@ class OffreModele else $remote = false; // à la place de NULL passer id utilisateur créateur offre - $offre = new Offre($this->offreGw->getMaxid(), + $offre = new Offre($this->offreGw->getNewId(), new Alumni(12,"test.mail@icloud.fr","password","admin"), $nom, $desc, @@ -58,7 +59,9 @@ class OffreModele $mail, $num, $site, - $remote); + $remote, + $date); + $this->offreGw->addOffers($offre); return $offre; @@ -83,24 +86,22 @@ class OffreModele public function CreateOffers($res) : array { $alGw = new AlumniGateway(new Connection("mysql:host=localhost;dbname=dbAlica", "test", "test")); - $imgGw = new ImageGateway(new Connection("mysql:host=localhost;dbname=dbAlica", "test", "test")); $offers=[]; foreach ($res as $row) { - $imgRaw = $imgGw->getFromId($row['image']); - $logoRaw = $imgGw->getFromId($row['logo']); - $img = new Image(intval($imgRaw[0]["id"]),$imgRaw[0]['nom'], $imgRaw[0]['taille'], $imgRaw[0]['type'], $imgRaw[0]['blob']); - $logo = new Image(intval($logoRaw[0]["id"]),$logoRaw[0]['nom'], $logoRaw[0]['taille'], $logoRaw[0]['type'], $logoRaw[0]['blob']); $resal = $alGw->ObtenirParId($row['offreur']); $alumni = new Alumni($resal[0]['id'],$resal[0]['mail'],$resal[0]['mdp'],$resal[0]['role']); - $offers[]=new Offre($row['id'], + $date = \DateTime::createFromFormat('Y-m-d', $row['date']); + + $offers[]=new Offre( + $row['id'], $alumni, $row['titre'], $row['description'], - $img, - $logo, + $row["image"], + $row["logo"], $row['typeContrat'], $row['ville'], $row["entreprise"], @@ -111,15 +112,23 @@ class OffreModele $row['mailContact'], $row['numero'], $row['websiteURL'], - $row['remote']); + $row['remote'], + $date); } return $offers; } + public function getOfferLimit($start, $end): array + { + $res = $this->offreGw->getOfferLimit($start, $end); + return $this->CreateOffers($res); + } - - + public function getNbOffers() : int + { + return $this->offreGw->getNbOffers(); + } } \ No newline at end of file diff --git a/php/templates/CreerOffre.html b/php/templates/CreerOffre.html index 2aeae96..5dd1631 100644 --- a/php/templates/CreerOffre.html +++ b/php/templates/CreerOffre.html @@ -116,11 +116,12 @@ - + - + +

Les images doivent être de type png, jpg, jpeg, bmp, webp & inférieures à 10MB

diff --git a/php/templates/OffersList.html b/php/templates/OffersList.html index 6d9feab..b85b5fa 100644 --- a/php/templates/OffersList.html +++ b/php/templates/OffersList.html @@ -4,6 +4,7 @@ Alica - Offres + @@ -15,13 +16,13 @@

Offres d'emploi

{% for offre in offres %} -
+
- + logo

{{ offre.getNom() }}

-

Julien Martin | 15/11/23

+

Julien Martin | {{ offre.getDateStringFr()}}

{{ offre.getDescription() }}

@@ -35,9 +36,29 @@
{% endfor %} + + + + - + + + diff --git a/php/templates/OffreDetailTest.html b/php/templates/OffreDetailTest.html index 40539eb..f6ee760 100644 --- a/php/templates/OffreDetailTest.html +++ b/php/templates/OffreDetailTest.html @@ -19,7 +19,7 @@
  • Description: {{ offre.getDescription() }}
  • Type de contrat: {{ offre.getTypeContrat() }}
  • Ville: {{ offre.getVille() }}
  • - +
  • Date de publication: {{ offre.getDateString() }}
  • diff --git a/php/templates/erreur.html b/php/templates/erreur.html index c1b55c0..242ab90 100755 --- a/php/templates/erreur.html +++ b/php/templates/erreur.html @@ -21,7 +21,6 @@

    {{value}}

    {% endfor %} {% endif %} -
    diff --git a/php/templates/offres.html b/php/templates/offres.html index 47d1781..fef2d8e 100644 --- a/php/templates/offres.html +++ b/php/templates/offres.html @@ -34,7 +34,7 @@

    Offres d'emploi

    - {% for offre in offres %} + {% for offre in offers %}
    @@ -70,6 +70,15 @@
    {% endfor %} + + {% if pages is defined %} + + {% for page in pages %} + {{page}} + {% endfor %} + + {% endif %} +