diff --git a/.DS_Store b/.DS_Store index 62a2dc5..b4acdff 100755 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index e69de29..426c53c 100755 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,479 @@ +##### Windows +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +##### Linux +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +##### MacOS +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +##### Backup +*.bak +*.gho +*.ori +*.orig +*.tmp + +##### GPG +secring.* + +##### Dropbox +# Dropbox settings and caches +.dropbox +.dropbox.attr +.dropbox.cache + +##### SynopsysVCS +# Waveform formats +*.vcd +*.vpd +*.evcd +*.fsdb + +# Default name of the simulation executable. A different name can be +# specified with this switch (the associated daidir database name is +# also taken from here): -o / +simv + +# Generated for Verilog and VHDL top configs +simv.daidir/ +simv.db.dir/ + +# Infrastructure necessary to co-simulate SystemC models with +# Verilog/VHDL models. An alternate directory may be specified with this +# switch: -Mdir= +csrc/ + +# Log file - the following switch allows to specify the file that will be +# used to write all messages from simulation: -l +*.log + +# Coverage results (generated with urg) and database location. The +# following switch can also be used: urg -dir .vdb +simv.vdb/ +urgReport/ + +# DVE and UCLI related files. +DVEfiles/ +ucli.key + +# When the design is elaborated for DirectC, the following file is created +# with declarations for C/C++ functions. +vc_hdrs.h + +##### SVN +.svn/ + +##### Mercurial +.hg/ +.hgignore +.hgsigs +.hgsub +.hgsubstate +.hgtags + +##### Bazaar +.bzr/ +.bzrignore + +##### CVS +/CVS/* +**/CVS/* +.cvsignore +*/.cvsignore + +##### TortoiseGit +# Project-level settings +/.tgitconfig + +##### PuTTY +# Private key +*.ppk + +##### Vim +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +*~ +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + +##### Emacs +# -*- mode: gitignore; -*- +*~ +\#*\# +/.emacs.desktop +/.emacs.desktop.lock +*.elc +auto-save-list +tramp +.\#* + +# Org-mode +.org-id-locations +*_archive + +# flymake-mode +*_flymake.* + +# eshell files +/eshell/history +/eshell/lastdir + +# elpa packages +/elpa/ + +# reftex files +*.rel + +# AUCTeX auto folder +/auto/ + +# cask packages +.cask/ +dist/ + +# Flycheck +flycheck_*.el + +# server auth directory +/server/ + +# projectiles files +.projectile + +# directory configuration +.dir-locals.el + +# network security +/network-security.data + +##### SublimeText +# Cache files for Sublime Text +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache + +# Workspace files are user-specific +*.sublime-workspace + +# Project files should be checked into the repository, unless a significant +# proportion of contributors will probably not be using Sublime Text +# *.sublime-project + +# SFTP configuration file +sftp-config.json +sftp-config-alt*.json + +# Package control specific files +Package Control.last-run +Package Control.ca-list +Package Control.ca-bundle +Package Control.system-ca-bundle +Package Control.cache/ +Package Control.ca-certs/ +Package Control.merged-ca-bundle +Package Control.user-ca-bundle +oscrypto-ca-bundle.crt +bh_unicode_properties.cache + +# Sublime-github package stores a github token in this file +# https://packagecontrol.io/packages/sublime-github +GitHub.sublime-settings + +##### Notepad++ +# Notepad++ backups # +*.bak + +##### TextMate +*.tmproj +*.tmproject +tmtags + +##### VisualStudioCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +##### NetBeans +**/nbproject/private/ +**/nbproject/Makefile-*.mk +**/nbproject/Package-*.bash +build/ +nbbuild/ +dist/ +nbdist/ +.nb-gradle/ + +##### JetBrains +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +##### Eclipse +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# CDT- autotools +.autotools + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ + +# Annotation Processing +.apt_generated/ +.apt_generated_test/ + +# Scala IDE specific (Scala & Java development for Eclipse) +.cache-main +.scala_dependencies +.worksheet + +# Uncomment this line if you wish to ignore the project description file. +# Typically, this file would be tracked if it contains build/dependency configurations: +#.project + +##### Dreamweaver +# DW Dreamweaver added files +_notes +_compareTemp +configs/ +dwsync.xml +dw_php_codehinting.config +*.mno + +##### CodeKit +# General CodeKit files to ignore +config.codekit +config.codekit3 +/min + +##### Gradle +.gradle +**/build/ +!src/**/build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Cache of project +.gradletasknamecache + +# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 +# gradle/wrapper/gradle-wrapper.properties + +##### Composer +composer.phar +/vendor/ + +# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control +# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file +composer.lock + +##### PHP CodeSniffer +# gitignore for the PHP Codesniffer framework +# website: https://github.com/squizlabs/PHP_CodeSniffer +# +# Recommended template: PHP.gitignore + +/wpcs/* + +##### SASS +.sass-cache/ +*.css.map +*.sass.map +*.scss.map + +php/.idea/ + +##### Images : +php/public/uploads/ diff --git a/php/.DS_Store b/php/.DS_Store index e15ad86..ccd016e 100755 Binary files a/php/.DS_Store and b/php/.DS_Store differ diff --git a/php/composer.json b/php/composer.json index 47ef02d..01808c9 100644 --- a/php/composer.json +++ b/php/composer.json @@ -1,7 +1,8 @@ { "require": { "twig/twig": "^3.0", - "ext-pdo": "*" + "ext-pdo": "*", + "ext-fileinfo": "*" }, "autoload": { "psr-4": { diff --git a/php/public/assets/deb.webp b/php/public/assets/deb.webp new file mode 100644 index 0000000..afb0462 Binary files /dev/null and b/php/public/assets/deb.webp differ diff --git a/php/public/assets/devbanner.jpeg b/php/public/assets/devbanner.jpeg new file mode 100644 index 0000000..a43a030 Binary files /dev/null and b/php/public/assets/devbanner.jpeg differ diff --git a/php/public/assets/location.png b/php/public/assets/location.png new file mode 100644 index 0000000..f5018a6 Binary files /dev/null and b/php/public/assets/location.png differ diff --git a/php/public/assets/michelin.png b/php/public/assets/michelin.png new file mode 100644 index 0000000..1bbe06b Binary files /dev/null and b/php/public/assets/michelin.png differ diff --git a/php/public/css/inscription_success.css b/php/public/css/inscription_success.css new file mode 100644 index 0000000..86fa52c --- /dev/null +++ b/php/public/css/inscription_success.css @@ -0,0 +1,102 @@ +.three-body { + --uib-size: 500px; + --uib-speed: 0.8s; + --uib-color: #00DBFF; + position: relative; + display: inline-block; + height: var(--uib-size); + width: var(--uib-size); + animation: spin78236 calc(var(--uib-speed) * 2.5) infinite linear; +} + +.three-body__dot { + position: absolute; + height: 100%; + width: 30%; +} + +.three-body__dot:after { + content: ''; + position: absolute; + height: 0; + width: 100%; + padding-bottom: 100%; + background-color: var(--uib-color); + border-radius: 50%; +} + +.three-body__dot:nth-child(1) { + bottom: 5%; + left: 0; + transform: rotate(60deg); + transform-origin: 50% 85%; +} + +.three-body__dot:nth-child(1)::after { + bottom: 0; + left: 0; + animation: wobble1 var(--uib-speed) infinite ease-in-out; + animation-delay: calc(var(--uib-speed) * -0.3); +} + +.three-body__dot:nth-child(2) { + bottom: 5%; + right: 0; + transform: rotate(-60deg); + transform-origin: 50% 85%; +} + +.three-body__dot:nth-child(2)::after { + bottom: 0; + left: 0; + animation: wobble1 var(--uib-speed) infinite + calc(var(--uib-speed) * -0.15) ease-in-out; +} + +.three-body__dot:nth-child(3) { + bottom: -5%; + left: 0; + transform: translateX(116.666%); +} + +.three-body__dot:nth-child(3)::after { + top: 0; + left: 0; + animation: wobble2 var(--uib-speed) infinite ease-in-out; +} + +@keyframes spin78236 { + 0% { + transform: rotate(0deg); + } + + 100% { + transform: rotate(360deg); + } +} + +@keyframes wobble1 { + 0%, + 100% { + transform: translateY(0%) scale(1); + opacity: 1; + } + + 50% { + transform: translateY(-66%) scale(0.65); + opacity: 0.8; + } +} + +@keyframes wobble2 { + 0%, + 100% { + transform: translateY(0%) scale(1); + opacity: 1; + } + + 50% { + transform: translateY(66%) scale(0.65); + opacity: 0.8; + } +} diff --git a/php/public/css/offreDetail.css b/php/public/css/offreDetail.css new file mode 100644 index 0000000..6acfe84 --- /dev/null +++ b/php/public/css/offreDetail.css @@ -0,0 +1,53 @@ + +img +{ + border-radius: 10px; +} + +body{ + margin: 0; + padding:0; +} + +#titleDiv +{ + background-image:url('../assets/deb.webp'); + width: 100%; + display: flex; + align-items: center; + flex-direction: column; + justify-content: center; + background-position: center; + color :white; +} + +#title p +{ + background-color: grey; + border-radius: 5px; +} + +#title +{ + font-size: 20px; + padding: 20px; + height: 70%; + align-items: center; + color: white; + background-color: #00DBFF; + +} + +#key { + + display: flex; + justify-content: center; + color: black; +} +#key p +{ + background-color: grey; + border-radius: 3px; + padding:10%; + +} \ No newline at end of file diff --git a/php/public/css/offres.css b/php/public/css/offres.css new file mode 100644 index 0000000..de4ce90 --- /dev/null +++ b/php/public/css/offres.css @@ -0,0 +1,51 @@ +.offre-container { + margin-bottom: 5%; +} +.offre-img { + max-width: 100%; +} + +#titrePrincipal { + padding-bottom: 10px; + border-bottom: 1px solid black; + margin-bottom: 30px; +} + +.custom-button { + background-color: #00DBFF; + border-color: #00DBFF; + color: #fff; +} + +.row1 +{ + display: flex; + align-items: center; + +} + +.row1 h4 +{ + margin-left: 20px; +} +.row1 img +{ + width: 20%; +} + +.authorDate +{ + color: #00DBFF; + margin: 1%; +} + +.row3 { + width: 30%; + display: flex; + justify-content: flex-start; + align-items: center; +} + +.row3 img { + align-self: flex-start; +} diff --git a/php/public/index.php b/php/public/index.php index f01c29e..2bce566 100755 --- a/php/public/index.php +++ b/php/public/index.php @@ -4,7 +4,7 @@ /** Chargement config */ require_once __DIR__ . '/../src/config/config.php'; require __DIR__ . '/../vendor/autoload.php'; -require_once __DIR__ . '/../src/TwigExtensions.php'; +require_once __DIR__ . '/../src/TwigExtensions.php'; // utile pour les images à supprimer sinon /** Configuration twig */ $loader = new \Twig\Loader\FilesystemLoader(__DIR__ . '/../templates'); @@ -12,6 +12,5 @@ $twig = new \Twig\Environment($loader, [ 'cache' => false, 'debug' => true ]); - - +$twig->addExtension(new \Twig\Extension\DebugExtension()); $cont = new \App\controleur\FrontControleur(); \ No newline at end of file diff --git a/php/src/TwigExtensions.php b/php/src/TwigExtensions.php index a7e9f11..64fe288 100644 --- a/php/src/TwigExtensions.php +++ b/php/src/TwigExtensions.php @@ -21,4 +21,4 @@ class TwigExtensions extends AbstractExtension } return ''; } -} \ No newline at end of file +} diff --git a/php/src/config/Validation.php b/php/src/config/Validation.php index 1d1e3ae..62d1465 100755 --- a/php/src/config/Validation.php +++ b/php/src/config/Validation.php @@ -1,6 +1,9 @@ = $nbChars; + } + return false; + + + } + } diff --git a/php/src/config/config.php b/php/src/config/config.php index 0fc5d8d..5baebeb 100755 --- a/php/src/config/config.php +++ b/php/src/config/config.php @@ -6,7 +6,13 @@ $rep = __DIR__ . '/php/'; // liste des modules à inclure $dConfig['includes']= array('controleur/Validation.php'); +static $OffersByPage = 5; + +// Variables connexion à la base : à modifier en fonction de la base de chacun +define('DB_HOST', 'mysql:host=localhost;dbname=dbAlica'); +define('DB_USER', 'Dev'); +define('DB_PASS', 'Dev'); //BD -$dsn = 'mysql:host=localhost;dbname=dbAlica'; -$username = 'test'; -$password = 'test'; +// $dsn = 'mysql:host=localhost;dbname=dbAlica'; +// $username = 'test'; +// $password = 'test'; diff --git a/php/src/controleur/FrontControleur.php b/php/src/controleur/FrontControleur.php index b8b503d..594bd18 100755 --- a/php/src/controleur/FrontControleur.php +++ b/php/src/controleur/FrontControleur.php @@ -16,10 +16,11 @@ class FrontControleur //TODO ], "Membre" => [ - "deconnexion","proposerOffre","consulterProfil","modifierProfil","signaler" + "deconnexion","proposerOffre","consulterProfil","modifierProfil","signaler", ], "Utilisateur" => [ - "connection", "inscription", "accueil","consulterProfilLimite","listerEvenement", "creerEvenement", "supprimerEvenement", "avoirDetailEvenement", "rechercherEvenement" + + "connexion", "inscription", "accueil", "consulterProfilLimite", "publierOffre", "listerEvenement", "creerEvenement", "supprimerEvenement", "avoirDetailEvenement", "rechercherEvenement" ] ); @@ -41,7 +42,7 @@ class FrontControleur } } else if(in_array($action,$actions['Membre'])) { - if (!isset($_SESSION["login"])) { + if (!isset($_SESSION["utilisateur"])) { $dVueErreur[] = 'Veuillez vous connecter'; echo $twig->render('erreur.html', ['dVueErreur' => $dVueErreur]); } else{ diff --git a/php/src/controleur/MembreControleur.php b/php/src/controleur/MembreControleur.php index c0b83ff..151c410 100755 --- a/php/src/controleur/MembreControleur.php +++ b/php/src/controleur/MembreControleur.php @@ -34,7 +34,9 @@ class MembreControleur extends UtilisateurControleur protected function deconnexion() { - //TODO + session_destroy(); + header('Location: index.php?action=accueil'); + exit(); } protected function proposerOffre() diff --git a/php/src/controleur/UtilisateurControleur.php b/php/src/controleur/UtilisateurControleur.php index d18585d..cd0bdd1 100755 --- a/php/src/controleur/UtilisateurControleur.php +++ b/php/src/controleur/UtilisateurControleur.php @@ -1,16 +1,16 @@ accueil(); break; + case "inscription_success": + $this->inscription_success(); + break; case "connection": $this->connection(); break; - case "consulterOffres": - $this->consulterOffres(); + case "inscription": + $this->inscription(); + break; + case "consultOffers": + $this->consultOffers(); break; case "consulterProfilLimite": $this->consulterProfilLimite(); break; - case "creerOffre": - $this->creerOffre(); + case "createOffer": + $this->createOffer(); + break; + case "createOfferForm": + $this->createOfferForm(); break; - case "testAction": - $this->testAction(); + case "displayOffer": + $this->displayOffer(); break; case "listerEvenement": $this->listerEvenement(); @@ -56,65 +65,278 @@ class UtilisateurControleur $this->rechercherEvenement(); break; default: - $dVueErreur[] ="Action inconnue ou non autorisée"; - echo $twig->render("erreur.html",['dVueErreur' => $dVueErreur]); - + $dVueErreur[] = "Action inconnue ou non autorisée"; + echo $twig->render("erreur.html", ['dVueErreur' => $dVueErreur]); } } protected function connection() { global $twig; - echo $twig->render('connexion.html', []); + $dVueErreur = []; // Tableau pour stocker les erreurs, le cas échéant + $userModel = new \App\modele\UtilisateurModele(); + + if (isset($_POST['email'], $_POST['password'])) { + $email = \App\config\Validation::nettoyerString($_POST['email']); + $motDePasse = \App\config\Validation::nettoyerString($_POST['password']); + $utilisateur = $userModel->connection($email, $motDePasse); + if ($utilisateur instanceof \App\metier\Alumni) { + $_SESSION['utilisateur'] = $utilisateur; + header('Location: index.php?action=accueil'); + exit(); + } else { + $dVueErreur[] = "L'adresse email ou le mot de passe est incorrect."; + } + } + echo $twig->render('connection.html', ['dVueErreur' => $dVueErreur]); + } + + protected function inscription() + { + global $twig; + $dVueErreur = []; // Tableau pour stocker les erreurs, le cas échéant + $userModel = new \App\modele\UtilisateurModele(); + + if (isset($_POST['firstname'],$_POST['name'], $_POST['email'], $_POST['password'])) { + $nom = \App\config\Validation::nettoyerString($_POST['name']); + $prenom = \App\config\Validation::nettoyerString($_POST['firstname']); + $email = \App\config\Validation::nettoyerString($_POST['email']); + $motDePasse = \App\config\Validation::nettoyerString($_POST['password']); + $hash = password_hash($motDePasse, PASSWORD_DEFAULT); + + // verification que l'email est valide et unique : + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { + $dVueErreur[] = "L'adresse email n'est pas valide ou est déjà utilisée."; + } else { + $utilisateur = $userModel->getUtilisateurByEmail($email); + if ($utilisateur instanceof \App\metier\Alumni) { + $dVueErreur[] = "L'adresse email est déjà utilisée."; + } + } + $nouvelUtilisateur = $userModel->inscription($prenom,$nom,$email, $hash); + +// <<<<<<< HEAD +// // Validez les données d'inscription, par exemple, vérifiez si l'email est unique +// // Vous pouvez également effectuer d'autres validations nécessaires + +// $userModel = new \App\modele\UtilisateurModele(); +// $nouvelUtilisateur = $userModel->inscription($email, $motDePasse); + +// // Si l'inscription a réussi, redirigez l'utilisateur vers une page de confirmation +// // Vous pouvez également gérer les erreurs ici en cas d'échec de l'inscription + +// if ($nouvelUtilisateur instanceof \App\metier\Alumni) { +// // L'inscription a réussi, redirigez l'utilisateur vers une page de confirmation +// // par exemple : +// ======= + if ($nouvelUtilisateur instanceof \App\metier\Alumni) { + header('Location: index.php?action=inscription_success'); + exit(); + } else { + $dVueErreur[] = "L'inscription a échoué, veuillez réessayer."; + } + } + echo $twig->render('inscription.html', ['dVueErreur' => $dVueErreur]); } protected function accueil() { global $twig; - echo $twig->render('accueil.html', []); + // Ajout d'un var_dump pour déboguer + if (isset($_SESSION['utilisateur']) && $_SESSION['utilisateur'] instanceof \App\metier\Alumni) { + $prenom = $_SESSION['utilisateur']->getPrenom(); + $nom = $_SESSION['utilisateur']->getNom(); + } + else{ + $prenom = null; + $nom = null; + } + //aller sur la page d'accueil avec le nom et prenom de l'utilisateur + echo $twig->render('accueil.html', ['prenom' => $prenom, 'nom' => $nom]); } + protected function inscription_success() + { + global $twig; + echo $twig->render('inscription_success.html'); + } protected function consulterProfilLimite() { //TODO } - protected function consulterOffres() + protected function consultOffers() { + $offerMdl = new OffreModele(); global $twig; - echo $twig->render('offres.html', []); + + $niveauEtudes=null; + $typeContrat=null; + $exp = null; + + $nbOffers = 5 ; + + if(isset($_GET["niveauEtudes"]) && Validation::validateTypeStudies($_GET["niveauEtudes"])) { + $niveauEtudes = $_GET["niveauEtudes"]; + } + + if(isset($_GET["typeContrat"]) && Validation::validateTypeContract($_GET["typeContrat"])) { + $typeContrat = $_GET["typeContrat"]; + } + + if(isset($_GET["experience"]) && Validation::validateExperience($_GET["experience"])) { + $exp = $_GET["experience"]; + } + + 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; + } + + 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); + + 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."
";*/ + + echo $twig->render('OffersList.html', [ + 'offres' => $offers, + 'numberPages' => $numberPages, + 'currentPage' => $page, + 'typeContrat' => (($typeContrat != null ? $typeContrat : "")), + 'experience' => (($exp != null ? $exp : "")), + 'niveauEtudes' => (($niveauEtudes != null ? $niveauEtudes : "")), + 'valContrat' => (($typeContrat != null ? "&typeContrat=".$typeContrat : "")), + 'valExp' => (($exp != null ? "&experience=".$exp : "")), + 'valEtudes' => (($niveauEtudes != null ? "&niveauEtudes=".$niveauEtudes : "")) + ]); } - protected function creerOffre() + + protected function createOfferForm() { + global $twig; + echo $twig->render("CreerOffre.html", []); + } + protected function createOffer() + { global $twig; - echo $twig->render('CreerOffre.html', []); + $taberror = []; - // echo 'mon image';*/ + $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; + } - protected function publierOffre() - { - $imgMdl = new ImageModele; - $offreMdl = new OffreModele(); + if(!Validation::verifierEmail($_POST["mail"])) + { + //echo $twig->render("CreerOffre.html", ['errMsg' => "Email non valide !" ]); + $taberror[] = "Email non valide !"; + } - $img = $imgMdl->publierImage(); - $offreMdl->publierOffre($img); + if(!Validation::validateNumber($_POST["num"])) + { + $taberror[] = "Numero non valide !"; + //echo $twig->render("CreerOffre.html", ['errMsg' => "Numero non valide !" ]); + } - global $twig; - echo $twig->render('Offres.html', [$offreMdl->obtenirOffres()]); + + 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]) { + $offreMdl = new OffreModele(); + + + $offre = $offreMdl->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 testAction() + public function displayOffer() { - echo "test action "; - $con = new Connection("mysql:host=localhost;dbname=dbAlica",'test','test'); - $offreGw = new OffreGateway($con); + global $twig; - if($offreGw->getMaxid() == NULL) - echo "max id == NULL"; - else echo "max id != NULL"; + if (isset($_GET["id"]) && intval($_GET["id"]) != null) + { + $offreMdl = new OffreModele(); + $offre = $offreMdl->getOfferFromId(intval($_GET["id"])); + if($offre != NULL) + { + echo $twig->render("OffreDetailTest.html",['offre' => $offre]); + return; + } + } + $dVueErreur[] = "Erreur, Offre introuvable"; + echo $twig->render("erreur.html", ['dVueErreur' => $dVueErreur]); } protected function listerEvenement() @@ -147,7 +369,6 @@ class UtilisateurControleur } } - protected function supprimerEvenement() { $mdl = new UtilisateurModele(); @@ -155,7 +376,7 @@ class UtilisateurControleur $this->listerEvenement(); } - + protected function avoirDetailEvenement() { $mdl = new UtilisateurModele(); diff --git a/php/src/gateway/AlumniGateway.php b/php/src/gateway/AlumniGateway.php index dded848..533dbed 100644 --- a/php/src/gateway/AlumniGateway.php +++ b/php/src/gateway/AlumniGateway.php @@ -4,6 +4,8 @@ use PDO; use App\metier\Alumni; use App\metier\Role; +use App\metier\Alumni; + class AlumniGateway { private \App\gateway\Connection $con; @@ -25,14 +27,6 @@ class AlumniGateway } - public function updateEmail(int $id, string $newEmail){ - $query='UPDATE Alumni SET email=:new WHERE id=:i'; - $this->con->executeQuery($query, array( - ':i' => array($id, PDO::PARAM_INT), - ':new' => array($newEmail, PDO::PARAM_STR) - )); - } - public function updateMotDePasse(int $id, string $password){ $query='UPDATE Alumni SET motDePasse=:new WHERE id=:i'; $this->con->executeQuery($query, array( @@ -41,22 +35,8 @@ class AlumniGateway )); } - public function updateRole(int $id, Role $newRole){ - $query='UPDATE Alumni SET role=:new WHERE id=:i'; - $this->con->executeQuery($query, array( - ':i' => array($id, PDO::PARAM_INT), - ':new' => array($newRole, PDO::PARAM_STR) - )); - } - - public function delete(int $id){ - $query='DELETE FROM Alumni WHERE id=:i'; - $this->con->executeQuery($query, array( - ':i' => array($id, PDO::PARAM_INT) - )); - } - - public function findById(int $id){ + public function ObtenirById(int $id) : array + { $query = 'SELECT * FROM Alumni WHERE id=:i'; $this->con->executeQuery($query, array( ':i' => array($id, PDO::PARAM_INT) @@ -65,14 +45,21 @@ class AlumniGateway } public function findByEmail(string $email){ - $query='SELECT * FROM Alumni WHERE email=:e'; + $query = 'SELECT Alumni.mail, Alumni.mdp, Alumni.role, Profil.nom, Profil.prenom + FROM Alumni + LEFT JOIN Profil ON Alumni.id = Profil.alumni + WHERE Alumni.mail = :e'; $this->con->executeQuery($query, array( ':e' => array($email, PDO::PARAM_STR), )); - $res=$this->con->getResults(); - return new Alumni($res[0]['mail'],$res[0]['id'],$res[0]['mdp'],$res[0]['role']); + $res = $this->con->getResults(); + if (count($res) == 0) { + return null; + } + return new \App\metier\Alumni($res[0]['mail'], $res[0]['mdp'], $res[0]['role'], $res[0]['nom'], $res[0]['prenom']); } + public function getAll(){ $query='SELECT * FROM Alumni'; $this->con->executeQuery($query); @@ -83,4 +70,14 @@ class AlumniGateway } return $array; } + + public function getID(string $email) + { + $query = 'SELECT id FROM Alumni WHERE mail=:e'; + $this->con->executeQuery($query, array( + ':e' => array($email, PDO::PARAM_STR), + )); + $res = $this->con->getResults(); + return $res[0]['id']; + } } \ No newline at end of file diff --git a/php/src/gateway/ImageGateway.php b/php/src/gateway/ImageGateway.php index 575c897..64e94e0 100644 --- a/php/src/gateway/ImageGateway.php +++ b/php/src/gateway/ImageGateway.php @@ -21,16 +21,12 @@ class ImageGateway public function insertImage(Image $img) { $query = "INSERT INTO Image (`nom`, `taille`, `type`, `blob`) VALUES ( :n, :t, :ty, :b)"; - try { - $this->con->executeQuery($query, array( - ':n' => array($img->getName(), PDO::PARAM_STR), - ':t' => array($img->getTaille(), PDO::PARAM_STR), - ':ty' => array($img->getType(), PDO::PARAM_STR), - ':b' => array($img->getBlob(), PDO::PARAM_STR) - )); - } catch (\PDOException $e) { - echo $e->getMessage(); - } + $this->con->executeQuery($query, array( + ':n' => array($img->getName(), PDO::PARAM_STR), + ':t' => array($img->getTaille(), PDO::PARAM_STR), + ':ty' => array($img->getType(), PDO::PARAM_STR), + ':b' => array($img->getBlob(), PDO::PARAM_STR) + )); } public function delete(int $id) @@ -41,7 +37,7 @@ class ImageGateway )); } - public function obtenirParId(int $id) : array + public function getFromId(int $id) : array { $query = 'SELECT * FROM Image WHERE id=:i'; $this->con->executeQuery($query, array( @@ -50,16 +46,6 @@ class ImageGateway return $this->con->getResults(); } - public function trouverParNom(string $nom) - { - $query = 'SELECT * FROM Image WHERE nom=:n'; - $this->con->executeQuery($query, array( - ':n' => array($nom, PDO::PARAM_STR) - )); - return $this->con->getResults(); - - } - public function getNewId() : int { $query = 'SELECT MAX(id) FROM Image'; diff --git a/php/src/gateway/ImageSaver.php b/php/src/gateway/ImageSaver.php index 2e0540b..a6d189d 100644 --- a/php/src/gateway/ImageSaver.php +++ b/php/src/gateway/ImageSaver.php @@ -1,7 +1,7 @@ con = $con; } - public function insert(){ - $query='INSERT INTO Offre VALUES ()'; - $this->con->executeQuery($query, array()); - } - - public function getMaxid() : int + public function getNewId() : int { $query = 'SELECT MAX(id) FROM Offre'; $this->con->executeQuery($query, array()); @@ -30,38 +25,109 @@ class OffreGateway return intval($res[0]['MAX(id)'])+1; } - public function ajouterOffre(Offre $offre) + 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, $nbOffers): array { - $query = 'INSERT INTO Offre VALUES (:i, :o, :t, :d, :img, :ty, :v, :e, :desc, :pro, :exp, :niv, :mail, :num, :web, :remote)'; + $query = 'SELECT * FROM Offre LIMIT :s, :nb'; + $this->con->executeQuery($query, array( + ':s' => array($start, \PDO::PARAM_INT), + ':nb' => array($nbOffers, \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, :date)'; $this->con->executeQuery($query, array( ':i' => array($offre->getId(), \PDO::PARAM_INT), - ':o' => array($offre->getOffreurId(), \PDO::PARAM_STR), + //':o' => array($offre->getOffreurId(), \PDO::PARAM_STR), + ':o' => array(1,\PDO::PARAM_INT), ':t' => array($offre->getNom(), \PDO::PARAM_STR), ':d' => array($offre->getDescription(), \PDO::PARAM_STR), - 'img' => array($offre->getImg(), \PDO::PARAM_STR), + '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), ':desc' => array($offre->getDescriptifPoste(), \PDO::PARAM_STR), - ':pro' => array($offre->getProfil(), \PDO::PARAM_STR), + ':pro' => array($offre->getProfilSearched(), \PDO::PARAM_STR), ':exp' => array($offre->getExperience(), \PDO::PARAM_STR), ':niv' => array($offre->getNiveauEtudes(), \PDO::PARAM_STR), ':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'; + $this->con->executeQuery($query, array()); + return $this->con->getResults(); + } - public function obtenirOffres() : array + public function getOfferFromId($id) : array { - $alGw = new AlumniGateway($this->con); - $imgGw = new ImageGateway($this->con); + $query = "SELECT * FROM offre WHERE id=:id"; + $this->con->executeQuery($query, array( + ':id' => array($id, \PDO::PARAM_INT) + )); + return $this->con->getResults(); + } - $query = 'SELECT * FROM Offre'; - $this->con->executeQuery($query, array()); - $res = $this->con->getResults(); - return $res; + 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['nbOffers'])) + { + $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/gateway/ProfilGateway.php b/php/src/gateway/ProfilGateway.php new file mode 100644 index 0000000..955e308 --- /dev/null +++ b/php/src/gateway/ProfilGateway.php @@ -0,0 +1,36 @@ +con = $con; + } + + public function insert(int $alumni,string $nom, string $prenom, string $email) + { + $query = 'INSERT INTO Profil (alumni,nom, prenom,email) VALUES (:alumni,:nom, :prenom,:email)'; + return $this->con->executeQuery($query, array( + ':alumni' => array($alumni, PDO::PARAM_INT), + ':nom' => array($nom, PDO::PARAM_STR), + ':prenom' => array($prenom, PDO::PARAM_STR), + ':email' => array($email, PDO::PARAM_STR) + )); + } + + + public function getProfilById($id) + { + $query = 'SELECT * FROM Profil WHERE Alumni=:i'; + $this->con->executeQuery($query, array( + ':i' => array($id, PDO::PARAM_INT) + )); + return $this->con->getResults(); + } +} \ No newline at end of file diff --git a/php/src/metier/Alumni.php b/php/src/metier/Alumni.php index b251d94..7b61e8a 100644 --- a/php/src/metier/Alumni.php +++ b/php/src/metier/Alumni.php @@ -3,9 +3,7 @@ namespace App\metier; class Alumni{ - - private int $id; - + /** * @var string Email */ @@ -21,17 +19,21 @@ class Alumni{ */ private String $role; + private Profil $profil; + /** * @param string $email * @param string $motDePasse * @param String $role + * @param Profil $profil */ - public function __construct(int $id,string $email, string $motDePasse, String $role) + + public function __construct(string $email, string $motDePasse, String $role, string $nom, string $prenom) { - $this->id = $id; $this->email = $email; $this->motDePasse = $motDePasse; $this->role = $role; + $this->profil = new Profil($nom, $prenom, $email, "","", "", ""); } /** @@ -42,6 +44,10 @@ class Alumni{ return $this->email; } + public function getProfil() : Profil + { + return $this->profil; + } /** * @return string */ @@ -55,8 +61,19 @@ class Alumni{ return $this->role; } - public function getId() : int + + public function getPassword(): string + { + return $this->motDePasse; + } + + public function getPrenom() + { + return $this->profil->getPrenom(); + } + + public function getNom() { - return $this->id; + return $this->profil->getNom(); } } \ No newline at end of file diff --git a/php/src/metier/Article.php b/php/src/metier/Article.php index db20f77..1c4ca95 100644 --- a/php/src/metier/Article.php +++ b/php/src/metier/Article.php @@ -1,5 +1,5 @@ image; } - - } \ No newline at end of file diff --git a/php/src/metier/Experience.php b/php/src/metier/Experience.php index 0aa093b..9d105ba 100644 --- a/php/src/metier/Experience.php +++ b/php/src/metier/Experience.php @@ -1,5 +1,5 @@ id = $id; $this->offreur = $offreur; $this->nom = $nom; $this->description = $description; $this->img = $img; + $this->logo = $logo; $this->typeContrat = $typeContrat; $this->ville = $ville; $this->entreprise = $entreprise; $this->descriptifPoste = $descriptifPoste; - $this->profil = $profil; + $this->profilSearched = $profil; $this->experience = $experience; $this->niveauEtudes = $niveauEtudes; $this->mailContact = $mailContact; $this->numero = $numero; $this->siteUrl = $siteUrl; $this->remote = $remote; + $this->date = $date; } public function getId(): int @@ -149,6 +181,11 @@ class Offre return $this->offreur->getId(); } + public function getLogo(): string + { + return $this->logo; + } + public function getNom(): string { return $this->nom; @@ -159,19 +196,16 @@ class Offre return $this->description; } - public function getImgId(): int - { - return $this->img->getId(); - } - public function getImg() : Image + public function getImg() : string { return $this->img; } - public function getBlob() : string + + public function getTypeContrat(): string { - return $this->img->getBlob(); + return $this->typeContrat; } public function getVille(): string @@ -189,11 +223,21 @@ class Offre return $this->descriptifPoste; } + public function getProfilSearched(): string + { + return $this->profilSearched; + } + public function getExperience(): string { return $this->experience; } + public function getNiveauEtudes(): string + { + return $this->niveauEtudes; + } + public function getMailContact(): string { return $this->mailContact; @@ -214,8 +258,29 @@ class Offre return $this->siteUrl; } + public function setImgId(int $imgId): void + { + $this->imgId = $imgId; + } + public function toString() : string { 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/metier/Profil.php b/php/src/metier/Profil.php index 69e5bc5..8fef2ee 100644 --- a/php/src/metier/Profil.php +++ b/php/src/metier/Profil.php @@ -1,5 +1,5 @@ id = $id; - $this->alumni = $alumni; - $this->cv = $cv; + $this->nom = $nom; $this->prenom = $prenom; + $this->email = $email; + $this->cv = $cv; $this->linkedinUrl = $linkedinUrl; $this->githubUrl = $githubUrl; $this->portfolioUrl = $portfolioUrl; } - public function getId(): int - { - return $this->id; - } - - public function getAlumni(): Alumni - { - return $this->alumni; - } public function getCv(): string { @@ -100,6 +86,10 @@ class Profil return $this->githubUrl; } + public function getEmail(): string + { + return $this->email; + } public function getPortfolioUrl(): string { return $this->portfolioUrl; diff --git a/php/src/modele/AdminModele.php b/php/src/modele/AdminModele.php index 5cc4474..ac33e99 100755 --- a/php/src/modele/AdminModele.php +++ b/php/src/modele/AdminModele.php @@ -2,13 +2,15 @@ namespace App\modele; +use App\metier\Alumni; + class AdminModele extends MembreModele { /** * @description supprimer un compte * @param Alumni $account compte à supprimer */ - public function deleteAccount(\App\modele\Alumni $account) + public function deleteAccount(\App\metier\Alumni $account) { // TO DO } diff --git a/php/src/modele/ImageModele.php b/php/src/modele/ImageModele.php deleted file mode 100644 index 177fa6a..0000000 --- a/php/src/modele/ImageModele.php +++ /dev/null @@ -1,53 +0,0 @@ -gw = new ImageGateway(new Connection("mysql:host=localhost;dbname=dbAlica","test","test")); - } - - public function publierImage() : Image - { - $img = new Image($this->gw->getNewId(), - $_FILES["image"]["name"], - $_FILES["image"]["size"], - $_FILES["image"]["type"], - file_get_contents($_FILES["image"]["tmp_name"])); - - $this->gw->insertImage($img); - - return $img; - } - - public function insertImage(Image $img) - { - $this->gw->insertImage($img); - } - - public function obtenirParId(int $id) - { - $this->gw->obtenirParId($id); - $res = $this->gw->obtenirToutesImages(); - return new Image($id ,$res[0]['nom'], $res[0]['taille'], $res[0]['type'], $res[0]['blob']); - } - - public function obtenirToutesImages() : array - { - $this->gw->obtenirToutesImages(); - $res = $this->gw->obtenirToutesImages(); - - foreach ($res as $r) { - $array[] = new Image($this->gw->getNewId(),$r['nom'], $r['taille'], $r['type'], $r['blob']); - } - return $array; - } - - -} \ No newline at end of file diff --git a/php/src/modele/OffreModele.php b/php/src/modele/OffreModele.php index 460a5fa..d37c17a 100644 --- a/php/src/modele/OffreModele.php +++ b/php/src/modele/OffreModele.php @@ -6,23 +6,23 @@ use App\gateway\AlumniGateway; use App\gateway\Connection; use App\gateway\ImageGateway; use App\gateway\OffreGateway; +use App\gateway\ProfilGateway; use App\metier\Alumni; use App\metier\Offre; use App\metier\Image; +use mysql_xdevapi\Exception; class OffreModele { - private OffreGateway $offreGw; public function __construct() { - $this->offreGw = new OffreGateway(new Connection("mysql:host=localhost;dbname=dbAlica", "test", "test")); + $this->offreGw = new OffreGateway(new Connection(DB_HOST,DB_USER,DB_PASS)); } - public function publierOffre(Image $img) + public function publishOffer(string $img, string $logo) { - $desc = $_POST["description"]; $descposte = $_POST["descriptPoste"]; $nom = $_POST["name"]; @@ -33,37 +33,23 @@ class OffreModele $num = $_POST["num"]; $site = $_POST["site"]; $exp = $_POST["choixExp"]; - $typeContrat = $_POST["typeContrat"]; - /* $typeContrat = match ($_POST["typeContrat"]) { - "Stage" => TypeContrat::Stage, - "CDI" => TypeContrat::CDI, - "CDD" => TypeContrat::CDD, - "Alternance" => TypeContrat::Alternance, - default => TypeContrat::CDD, - };*/ - $niveauEtudes = $_POST["education"]; - /* $niveauEtudes = match ($_POST["education"]) { - "Bac+2" => NiveauEtudes::Bac2, - "Bac+3" => NiveauEtudes::Bac3, - "Bac+5" => NiveauEtudes::Bac5, - default => NiveauEtudes::Indifferent, - };*/ + $date = new \DateTime(); if(isset($_POST["fullRemote"])) { $remote = true; } - else { - $remote = false; - } + else $remote = false; + // à la place de NULL passer id utilisateur créateur offre - $offre = new Offre($this->offreGw->getMaxid(), - new Alumni(12,"test.mail@icloud.fr","password","admin"), + $offre = new Offre($this->offreGw->getNewId(), + new Alumni("test.mail@icloud.fr","password","admin","prenom","nom"), $nom, $desc, $img, + $logo, $typeContrat, $ville, $entreprise, @@ -74,46 +60,86 @@ class OffreModele $mail, $num, $site, - $remote); - $this->offreGw->ajouterOffre($offre); + $remote, + $date); + + $this->offreGw->addOffers($offre); + + return $offre; + + } + public function getOffers() : array + { + $res = $this->offreGw->getOffers(); + $offers = $this->CreateOffersFromGw($res); + return $offers; + } + + public function getOfferFromId(int $id) : ?Offre + { + $res = $this->offreGw->getOfferFromId($id); + if($res != null) + return $this->CreateOffersFromGw($res)[0]; + return null; } - public function obtenirOffres() : array + + public function CreateOffersFromGw($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")); - $res = $this->offreGw->obtenirOffres(); - $offres=[]; + $alGw = new AlumniGateway(new Connection(DB_HOST,DB_USER,DB_PASS)); + $offers=[]; foreach ($res as $row) { - $res = $imgGw->obtenirParId($row['image']); - $img = new Image(intval($res[0]["id"]),$res[0]['nom'], $res[0]['taille'], $res[0]['type'], $res[0]['blob']); + $resal = $alGw->ObtenirById($row['offreur']); + $profilGw = new ProfilGateway(new Connection(DB_HOST,DB_USER,DB_PASS)); + $resProfl = $profilGw->getProfilById($row['offreur']); + + $alumni = new Alumni($resal[0]['mail'],$resal[0]['mdp'],$resal[0]['role'],$resProfl[0]['nom'],$resProfl[0]["prenom"]); + + $date = \DateTime::createFromFormat('Y-m-d', $row['date']); + + $offers[]=new Offre( + $row['id'], + $alumni, + $row['titre'], + $row['description'], + $row["image"], + $row["logo"], + $row['typeContrat'], + $row['ville'], + $row["entreprise"], + $row['descriptifPoste'], + $row['profil'], + $row['experience'], + $row['niveauEtudes'], + $row['mailContact'], + $row['numero'], + $row['websiteURL'], + $row['remote'], + $date); + } - $resal = $alGw->findById($row['offreur']); - $alumni = new Alumni($resal[0]['id'],$resal[0]['mail'],$resal[0]['mdp'],$resal[0]['role']); - $offres[]= new Offre($row['id'], - $alumni, - $row['titre'], - $row['description'], - $img, - $row['typeContrat'], - $row['ville'], - $row["entreprise"], - $row['descriptifPoste'], - $row['profil'], - $row['experience'], - $row['niveauEtudes'], - $row['mailContact'], - $row['numero'], - $row['websiteURL'], - $row['remote']); - } + return $offers; + } - return $offres; + public function getOfferLimit($start, $nbOffers): array + { + $res = $this->offreGw->getOfferLimit($start, $nbOffers); + return $this->CreateOffersFromGw($res); + } + + public function getNbOffers() : int + { + return $this->offreGw->getNbOffers(); } + public function getOffersWithFilters($params) : array + { + return $this->offreGw->getOffersWithFilters($params); + } + } \ No newline at end of file diff --git a/php/src/modele/UtilisateurModele.php b/php/src/modele/UtilisateurModele.php index ccb9d5c..d4fb1fa 100755 --- a/php/src/modele/UtilisateurModele.php +++ b/php/src/modele/UtilisateurModele.php @@ -12,10 +12,82 @@ class UtilisateurModele public function __construct() { - global $dsn, $username, $password; - $this->con = new Connection($dsn, $username, $password); + $this->con = new Connection(DB_HOST,DB_USER,DB_PASS); } + /** + * @description se connecter + * @param string email + * @param string hash + * @return \App\metier\Alumni + */ + + public function connection(string $email, string $mdp) : ? \App\metier\Alumni + { + $con = new \App\gateway\Connection(DB_HOST,DB_USER,DB_PASS); + $gate = new \App\gateway\AlumniGateway($con); + // Récupérez l'utilisateur avec l'email donné en utilisant AlumniGateway + $utilisateur = $gate->findByEmail($email); + if ($utilisateur instanceof \App\metier\Alumni) { + // L'utilisateur existe, vérifiez le mot de passe + if (password_verify($mdp, $utilisateur->getPassword())) { + // Le mot de passe est correct, retournez l'utilisateur + session_start(); + return $utilisateur; + } else { + // Le mot de passe est incorrect, renvoyez null + return null; + } + } else { + // L'utilisateur n'existe pas, renvoyez null + return null; + } + } + + /** + * @description s'inscrire + * @param string email + * @param string hash + * @param string $pseudo + * @return \Alumni chargé + */ + + public function inscription(string $prenom, string $nom,string $email, string $hashpassword):? \App\metier\Alumni + { + $role = "Membre"; + $con = new \App\gateway\Connection(DB_HOST,DB_USER,DB_PASS); + $gate = new \App\gateway\AlumniGateway($con); + $profilGate = new \App\gateway\ProfilGateway($con); + // Insérez le nouvel utilisateur dans la base de données en utilisant AlumniGateway + if ($gate->insert($email, $hashpassword, $role)) { + $alumni = $gate->getID($email); + if($profilGate->insert($alumni,$nom, $prenom,$email)){ + // L'insertion a réussi, retournez le nouvel utilisateur + $nouvelUtilisateur = new \App\metier\Alumni($email, $hashpassword, $role,$nom,$prenom); + return $nouvelUtilisateur; + } + return null; + } else { + // L'insertion a échoué, renvoyez un utilisateur vide pour indiquer l'échec + return null; + } + } + + public function getUtilisateurByEmail(string $email) + { + $con = new \App\gateway\Connection(DB_HOST,DB_USER,DB_PASS); + $gate = new \App\gateway\AlumniGateway($con); + // Récupérez l'utilisateur avec l'email donné en utilisant AlumniGateway + $utilisateur = $gate->findByEmail($email); + if ($utilisateur instanceof \App\metier\Alumni) { + // L'utilisateur existe, retournez-le + return $utilisateur; + } else { + // L'utilisateur n'existe pas, renvoyez null + return null; + } + } + public function getEvenement() : array { $gate = new EvenementGateway($this->con); diff --git a/php/templates/CreerOffre.html b/php/templates/CreerOffre.html new file mode 100644 index 0000000..8a1e867 --- /dev/null +++ b/php/templates/CreerOffre.html @@ -0,0 +1,125 @@ + + + + + Publier une Offre + + + + + +
+ {% include "menu.html" %} +
+ +
+

Publier Une Offre

+ +
+ + {% if tabError is defined %} + {% for error in tabError %} +

{{ error }}

+ {% endfor %} + {% endif %} + + +

Les champs contenant des astrérisques * sont obligatoires.

+
+ + +
+ +
+ + +
+ + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + + + + + +

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 new file mode 100644 index 0000000..c86f465 --- /dev/null +++ b/php/templates/OffersList.html @@ -0,0 +1,145 @@ + + + + + Alica - Offres + + + + + +
+ {% include "menu.html" %} +
+ +
+ + +
+ +
+
+

Filtrer les offres

+ +
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + +
+ +
+ + +
+
+ + +
+
+ +
+ + +
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+ + +
+ + + +

Offres d'emploi

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

{{ offre.getNom() }}

+
+
+

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

+

{{ offre.getDescription() }}

+
+ +
+ location +

{{offre.getVille()}}

+
+ +
+ + {% endfor %} + + +
+ + + + + + + + + + + diff --git a/php/templates/Offre.html b/php/templates/Offre.html new file mode 100644 index 0000000..7211ce4 --- /dev/null +++ b/php/templates/Offre.html @@ -0,0 +1,10 @@ + + + + + Offre {{ offre.getNom() }} + + + + + \ No newline at end of file diff --git a/php/templates/OffreDetailTest.html b/php/templates/OffreDetailTest.html new file mode 100644 index 0000000..e404b79 --- /dev/null +++ b/php/templates/OffreDetailTest.html @@ -0,0 +1,54 @@ + + + + + Détails de l'Offre {{ offre.getNom() }} + + + + +
+ + + {% include "menu.html" %} +
+
+

Détails de l'Offre

+
    + + +
  • Logo +
  • Offer Image
  • + +
  • Offreur: {{ offre.getOffreur().getNom() }}
  • +
  • Nom de l'offre: {{ offre.getNom() }}
  • +
  • Entreprise : {{ offre.getEntreprise() }}
  • +
  • Description: {{ offre.getDescription() }}
  • +
  • Type de contrat: {{ offre.getTypeContrat() }}
  • +
  • Niveau d'études : {{ offre.getNiveauEtudes() }}
  • +
  • Ville: {{ offre.getVille() }}
  • +
  • Date de publication: {{ offre.getDateStringFr() }}
  • +
  • Descriptif Poste : {{ offre.getDescriptifPoste() }}
  • +
  • Profil recherché : {{ offre.getProfilSearched() }}
  • +
  • Site de L'annonce : {{ offre.getSiteUrl() }}
  • +
  • Mail de Contact : : {{ offre.getMailContact() }}
  • +
  • Numéro de Contact : {{ offre.getNumero() }}
  • + +
  • + Full Remote : + {% if offre.isRemote() %} + Oui + {% else %} + Non + {% endif %} +
  • + + + +
+
+ + + + + diff --git a/php/templates/accueil.html b/php/templates/accueil.html index 1438392..b6118c7 100755 --- a/php/templates/accueil.html +++ b/php/templates/accueil.html @@ -3,21 +3,37 @@ - + Alica - Accueil +
+ {% include 'menu.html' %} +

Accueil

+ +

{% if prenom and nom %} + Bienvenue, {{ prenom }} {{ nom }}! + {% else %} + Bienvenue, invité! + {% endif %}

Vous êtes sur la page d'accueil

-

Vous pouvez vous connecter ou vous inscrire

-

Vous pouvez aussi consulter les articles

-

Vous pouvez aussi consulter les annonces

-

Connexion :

-
- -
+ {% if dVueErreur is not empty %} +
+
+
+
    + {% for erreur in dVueErreur %} +
  • {{ erreur }}
  • + {% endfor %} +
+
+
+
+ {% endif %} + diff --git a/php/templates/connexion.html b/php/templates/connection.html similarity index 79% rename from php/templates/connexion.html rename to php/templates/connection.html index 2dd061a..c199201 100755 --- a/php/templates/connexion.html +++ b/php/templates/connection.html @@ -16,7 +16,7 @@
- +
@@ -42,6 +42,19 @@
+ {% if dVueErreur is not empty %} +
+
+
+
    + {% for erreur in dVueErreur %} +
  • {{ erreur }}
  • + {% endfor %} +
+
+
+
+ {% endif %} diff --git a/php/templates/creerOffre.html b/php/templates/creerOffre.html index f5b4793..8a1e867 100644 --- a/php/templates/creerOffre.html +++ b/php/templates/creerOffre.html @@ -9,43 +9,52 @@
+ {% include "menu.html" %}

Publier Une Offre

-
+ + + {% if tabError is defined %} + {% for error in tabError %} +

{{ error }}

+ {% endfor %} + {% endif %} + +

Les champs contenant des astrérisques * sont obligatoires.

- +
- +
- - + +
- +
- +
+
- +
- + -
- -
- - -
- -
- - -
- -
- - -
- -
- - +
+ +
-
- +
- +
- +
- + + + + - +

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

-
- - - + + diff --git a/php/templates/erreur.html b/php/templates/erreur.html index 740cace..ea207e5 100755 --- a/php/templates/erreur.html +++ b/php/templates/erreur.html @@ -7,8 +7,15 @@ Alica - Erreur + + + {% include "menu.html" %} -

Page d'erreur

+

Erreur

{% if dVueErreur is defined %} {% for value in dVueErreur %}

{{value}}

diff --git a/php/templates/footer.html b/php/templates/footer.html new file mode 100644 index 0000000..0a9dabf --- /dev/null +++ b/php/templates/footer.html @@ -0,0 +1,28 @@ + + + + + Footer + + + + +
+ +
div 1
+ +
+

Association

+
+ +
+

Aide

+
+ +
+ +

© Copyright 2023, All Rights Reserved by Alica

+ + + + \ No newline at end of file diff --git a/php/templates/inscription.html b/php/templates/inscription.html index b86bcea..a22ee4b 100755 --- a/php/templates/inscription.html +++ b/php/templates/inscription.html @@ -11,12 +11,25 @@

S'inscrire

- Identifiant + Prénom :
- + +
+
+
+ Nom : +
+
+ +
+
@@ -25,7 +38,9 @@
- +
@@ -34,7 +49,9 @@
- +
@@ -50,6 +67,19 @@
+ {% if dVueErreur is not empty %} +
+
+
+
    + {% for erreur in dVueErreur %} +
  • {{ erreur }}
  • + {% endfor %} +
+
+
+
+ {% endif %} diff --git a/php/templates/inscription_success.html b/php/templates/inscription_success.html new file mode 100644 index 0000000..3e1f2b3 --- /dev/null +++ b/php/templates/inscription_success.html @@ -0,0 +1,24 @@ + + + + + Success + + + +

Inscription effectuée avec succès, vous pouvez désormais vous connecter

+

Vous allez être redirigé vers la page de connexion dans 5 secondes

+
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/php/templates/menu.html b/php/templates/menu.html index 87f0a45..3e29b53 100644 --- a/php/templates/menu.html +++ b/php/templates/menu.html @@ -2,6 +2,7 @@ + \ No newline at end of file diff --git a/php/templates/offreDetail.html b/php/templates/offreDetail.html new file mode 100644 index 0000000..9998726 --- /dev/null +++ b/php/templates/offreDetail.html @@ -0,0 +1,52 @@ + + + + + Offre Detail + + + + +
+ {% include "menu.html" %} +
+ +
+ Logo +

Developpeur Fullstack

+ +

Paris

+ +
+
+

CDI

+
+
+

Experience: Non spécifié

+
+
+

Etudes: Bac+2

+
+
+
+ +

Offre Proposée par marvin marbout

+

Publiée le 15/17/2023

+ +

Description de l'offre

+ +
+

+ Accompagné(e) par nos experts au sein d'une équipe pluridisciplinaire, tu conçois et développes des solutions innovantes répondant aux besoins de nos clients. + A ce titre, tu utilises les langages, frameworks et outils actuels. + Les méthodes agiles ainsi que les pratiques DevOps, l'intégration et le déploiement continu sont ton quotidien. + Tu interviens dans un environnement technique très riche. Rejoindre CGI dans le cadre de ton stage de fin d’études, + c’est intervenir sur des projets d’envergure et variés en lien avec ta formation tout en bénéficiant d’un accompagnement de proximité pour construire ta carrière. + C’est aussi s’investir auprès d’une entreprise responsable qui propose de nombreux avantages (prise en charge jusqu’à 100% des transports en commun) et partager des moments de convivialité pour ensuite nous rejoindre en CDI ! +

+
+ + + + + diff --git a/php/templates/offres.html b/php/templates/offres.html new file mode 100644 index 0000000..fef2d8e --- /dev/null +++ b/php/templates/offres.html @@ -0,0 +1,88 @@ + + + + + Alica - Offres + + + + +
+ {% include "menu.html" %} +
+ +
+

Offres d'emploi

+ + {% for offre in offers %} +
+
+ +
+ +
+ +
+

{{ offre.getNom() }}

+

Julien Martin

+
+
+
+
+

{{ offre.getDescription() }}

+
+
+ + +
+
+ +
+
+

{{ offre.getVille() }}

+
+
+
+
+ +
+
+
+ {% endfor %} + + {% if pages is defined %} + + {% for page in pages %} + {{page}} + {% endfor %} + + {% endif %} + +
+ + + + + + diff --git a/php/templates/testImage.html b/php/templates/testImage.html new file mode 100644 index 0000000..1214b7e --- /dev/null +++ b/php/templates/testImage.html @@ -0,0 +1,21 @@ + + + + + Test Img + + + +
+ + + + + + +
+ + + + + \ No newline at end of file diff --git a/php/vendor/composer/installed.php b/php/vendor/composer/installed.php index 295225e..6397942 100644 --- a/php/vendor/composer/installed.php +++ b/php/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => '__root__', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => 'ca79f102cff2316dd789a28ba980fe14643acaa0', + 'reference' => '5e0d7c0f8d2b99afe354727af9c141da9b1ae5a1', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -13,7 +13,7 @@ '__root__' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => 'ca79f102cff2316dd789a28ba980fe14643acaa0', + 'reference' => '5e0d7c0f8d2b99afe354727af9c141da9b1ae5a1', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(),