Merge pull request 'evenements' (#39) from evenements into master

Reviewed-on: #39
offres2
Leo TUAILLON 1 year ago
commit a0a4f139e4

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/php.iml" filepath="$PROJECT_DIR$/.idea/php.iml" />
</modules>
</component>
</project>

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="App\" />
<excludeFolder url="file://$MODULE_DIR$/vendor/composer" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-ctype" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-mbstring" />
<excludeFolder url="file://$MODULE_DIR$/vendor/twig/twig" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MessDetectorOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PHPCSFixerOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PHPCodeSnifferOptionsConfiguration">
<option name="highlightLevel" value="WARNING" />
<option name="transferred" value="true" />
</component>
<component name="PhpIncludePathManager">
<include_path>
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-mbstring" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-ctype" />
<path value="$PROJECT_DIR$/vendor/composer" />
<path value="$PROJECT_DIR$/vendor/twig/twig" />
</include_path>
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="8.1">
<option name="suggestChangeDefaultLanguageLevel" value="false" />
</component>
<component name="PhpStanOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PsalmOptionsConfiguration">
<option name="transferred" value="true" />
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 B

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M782.87-98.52 526.913-354.478q-29.435 21.739-68.152 34.608-38.718 12.87-83.283 12.87-114.087 0-193.544-79.457Q102.477-465.913 102.477-580q0-114.087 79.457-193.544 79.457-79.457 193.544-79.457 114.087 0 193.544 79.457Q648.479-694.087 648.479-580q0 45.13-12.87 83.283-12.869 38.152-34.608 67.021l256.522 257.087-74.653 74.088ZM375.478-413.002q69.913 0 118.456-48.543Q542.477-510.087 542.477-580q0-69.913-48.543-118.456-48.543-48.543-118.456-48.543-69.913 0-118.456 48.543Q208.479-649.913 208.479-580q0 69.913 48.543 118.456 48.543 48.543 118.456 48.543Z"/></svg>

After

Width:  |  Height:  |  Size: 657 B

@ -0,0 +1,54 @@
/* styles.css */
/* Reset CSS pour normaliser le rendu sur tous les navigateurs */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Arial', sans-serif;
background-color: #f8f9fa;
color: #333;
}
.container {
margin-top: 20px;
}
.div_titres {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.div_titres a {
width: 20%;
}
.div_titres h1 {
width: 50%;
color: #00DBFF;
}
.div_titres a img {
margin-left: 40px;
}
h1 {
display: flex;
justify-content: center;
color: #00DBFF;
}
.list-group-item {
display: flex;
flex-direction: row;
justify-content: space-between;
margin-top: 20px;
padding: 15px;
border: 1px solid #dee2e6;
border-radius: 5px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 KiB

@ -63,6 +63,7 @@ class Validation
return filter_var($str, FILTER_VALIDATE_EMAIL); return filter_var($str, FILTER_VALIDATE_EMAIL);
} }
public static function validateImage($img) : bool public static function validateImage($img) : bool
{ {
if(isset($_FILES[$img])) if(isset($_FILES[$img]))
@ -79,6 +80,20 @@ class Validation
return false; return false;
} }
public static function validerEvenement(string $titre, string $description, string $date, int $nbPlaceMax, string $img) : bool
{
if(!empty($titre) && !empty($description) && !empty($date) && !empty($nbPlaceMax) && !empty($img))
{
if(self::validerIntPossitif($nbPlaceMax))
{
if(self::validateImage($img))
{
return true;
}
}
}
return false;
}
public static function validateNumber($number) : bool public static function validateNumber($number) : bool
{ {

@ -12,3 +12,7 @@ static $OffersByPage = 5;
define('DB_HOST', 'mysql:host=localhost;dbname=dbAlica'); define('DB_HOST', 'mysql:host=localhost;dbname=dbAlica');
define('DB_USER', 'Dev'); define('DB_USER', 'Dev');
define('DB_PASS', 'Dev'); define('DB_PASS', 'Dev');
//BD
// $dsn = 'mysql:host=localhost;dbname=dbAlica';
// $username = 'test';
// $password = 'test';

@ -10,7 +10,7 @@ class FrontControleur
$dVueErreur = []; $dVueErreur = [];
$actions = array( $actions = array(
"Admin" => [ "Admin" => [
"supprimerCompte", "consulterSignalement", "creerEvenement", "supprimerEvenement","supprimerOffre" "supprimerCompte", "consulterSignalement","supprimerOffre"
], ],
"Moderateur" => [ "Moderateur" => [
//TODO //TODO
@ -20,8 +20,7 @@ class FrontControleur
], ],
"Utilisateur" => [ "Utilisateur" => [
"connexion", "inscription", "accueil","consulterProfilLimite","publierOffre" "connexion", "inscription", "accueil", "consulterProfilLimite", "publierOffre", "listerEvenement", "creerEvenement", "supprimerEvenement", "avoirDetailEvenement", "rechercherEvenement"
] ]
); );

@ -2,17 +2,11 @@
namespace App\controleur; namespace App\controleur;
use App\config;
use App\config\Validation; use App\config\Validation;
use App\gateway\Connection;
use App\gateway\ImageGateway;
use App\gateway\ImageSaver; use App\gateway\ImageSaver;
use App\gateway\OffreGateway;
use App\metier\Image;
use App\modele\OffreModele; use App\modele\OffreModele;
use App\modele\ImageModele; use App\modele\UtilisateurModele;
use App\TwigExtensions;
use APp\config;
class UtilisateurControleur class UtilisateurControleur
{ {
@ -21,10 +15,10 @@ class UtilisateurControleur
{ {
global $twig; global $twig;
if (!isset($_REQUEST["action"])) { if (!isset($_REQUEST["action"])) {
//$action = NULL; //$action = NULL;
$action = "consultOffers"; $action = "listerEvenement";
} else { } else {
$action = \App\config\Validation::nettoyerString($_REQUEST["action"]); $action = Validation::nettoyerString($_REQUEST["action"]);
} }
switch ($action) { switch ($action) {
case NULL: case NULL:
@ -39,7 +33,6 @@ class UtilisateurControleur
break; break;
case "inscription": case "inscription":
$this->inscription(); $this->inscription();
break; break;
case "consultOffers": case "consultOffers":
$this->consultOffers(); $this->consultOffers();
@ -56,10 +49,24 @@ class UtilisateurControleur
case "displayOffer": case "displayOffer":
$this->displayOffer(); $this->displayOffer();
break; break;
case "listerEvenement":
$this->listerEvenement();
break;
case "creerEvenement":
$this->creerEvenement();
break;
case "supprimerEvenement":
$this->supprimerEvenement();
break;
case "avoirDetailEvenement":
$this->avoirDetailEvenement();
break;
case "rechercherEvenement":
$this->rechercherEvenement();
break;
default: default:
$dVueErreur[] = "Action inconnue ou non autorisée"; $dVueErreur[] = "Action inconnue ou non autorisée";
echo $twig->render("erreur.html", ['dVueErreur' => $dVueErreur]); echo $twig->render("erreur.html", ['dVueErreur' => $dVueErreur]);
} }
} }
@ -163,7 +170,6 @@ class UtilisateurControleur
$offerMdl = new OffreModele(); $offerMdl = new OffreModele();
global $twig; global $twig;
$niveauEtudes=null; $niveauEtudes=null;
$typeContrat=null; $typeContrat=null;
$exp = null; $exp = null;
@ -241,9 +247,6 @@ class UtilisateurControleur
]); ]);
} }
protected function createOfferForm() protected function createOfferForm()
{ {
global $twig; global $twig;
@ -336,4 +339,65 @@ class UtilisateurControleur
echo $twig->render("erreur.html", ['dVueErreur' => $dVueErreur]); echo $twig->render("erreur.html", ['dVueErreur' => $dVueErreur]);
} }
protected function listerEvenement()
{
$mdl = new UtilisateurModele();
$evenements = $mdl->getEvenement();
global $twig;
echo $twig->render('evenement.html', ['evenements' => $evenements]);
}
protected function creerEvenement()
{
global $twig;
if (isset($_FILES["image"])) {
$img = ImageSaver::SaveImage('image');
if (!Validation::validerEvenement($_POST["titre"], $_POST["description"], $_POST["date"], $_POST["nbPlaceMax"], $img[1])) {
$mdl = new UtilisateurModele();
$mdl->ajouterEvenement($_POST["titre"], $_POST["description"], $_POST["date"], $_POST["nbPlaceMax"], $img[1]);
$this->listerEvenement();
} else {
$dVueErreur[] ="Erreur lors de la création de l'évènement";
echo $twig->render("erreur.html",['dVueErreur' => $dVueErreur]);
}
} else {
echo $twig->render('creerEvenement.html', []);
}
}
protected function supprimerEvenement()
{
$mdl = new UtilisateurModele();
$mdl->deleteEvenement($_GET["id"]);
$this->listerEvenement();
}
protected function avoirDetailEvenement()
{
$mdl = new UtilisateurModele();
$evenement = $mdl->getEvenementById($_GET["id"]);
global $twig;
echo $twig->render('detailEvenement.html', ['evenement' => $evenement]);
}
protected function rechercherEvenement()
{
$mdl = new UtilisateurModele();
$evenements = $mdl->getEvenement();
if(isset($_POST["recherche"]) AND !empty($_POST["recherche"]))
{
$recherche = Validation::nettoyerString($_POST["recherche"]);
$evenements = $mdl->getEvenementByTitre($recherche);
}
global $twig;
echo $twig->render('evenement.html', ['evenements' => $evenements]);
}
} }

@ -1,6 +1,8 @@
<?php <?php
namespace App\gateway; namespace App\gateway;
use PDO; use PDO;
use App\metier\Alumni;
use App\metier\Role;
use App\metier\Alumni; use App\metier\Alumni;

@ -1,5 +1,7 @@
<?php <?php
namespace App\gateway; namespace App\gateway;
use App\metier\Evenement;
class EvenementGateway class EvenementGateway
{ {
private \App\gateway\Connection $con; private \App\gateway\Connection $con;
@ -11,8 +13,65 @@ class EvenementGateway
$this->con = $con; $this->con = $con;
} }
public function insert(){ public function getNewId()
$query='INSERT INTO Evenement VALUES ()'; {
$this->con->executeQuery($query, array()); $query='SELECT MAX(id) FROM Evenement';
$this->con->executeQuery($query);
$res=$this->con->getResults();
return $res[0]['MAX(id)']+1;
}
public function insertEvenement(Evenement $evenement)
{
$query = 'INSERT INTO Evenement VALUES (:i, :o, :t, :d, :img, :date, :nb)';
$this->con->executeQuery($query,$params = array(
':i' => array($evenement->getId(), \PDO::PARAM_INT),
':o' => array($evenement->getOrganisateurId(), \PDO::PARAM_INT),
':t' => array($evenement->getTitre(), \PDO::PARAM_STR),
':d' => array($evenement->getDescription(), \PDO::PARAM_STR),
':img' => array($evenement->getImage(), \PDO::PARAM_STR),
':date' => array($evenement->getDate(), \PDO::PARAM_STR),
':nb' => array($evenement->getNbPlaceMax(), \PDO::PARAM_INT),
));
}
public function getAllEvenement()
{
$query = 'SELECT * FROM Evenement ORDER BY id DESC';
$this->con->executeQuery($query);
$res = $this->con->getResults();
return $res;
} }
public function deleteEvenement($id)
{
$query='DELETE FROM Evenement WHERE id=:id';
$this->con->executeQuery($query, array(
':id' => array($id, \PDO::PARAM_INT)
));
}
public function findById($id)
{
$query='SELECT * FROM Evenement WHERE id=:id';
$this->con->executeQuery($query, array(
':id' => array($id, \PDO::PARAM_INT)
));
$res=$this->con->getResults();
return $res;
}
public function findByTitle($titre)
{
$query = 'SELECT * FROM Evenement WHERE titre LIKE :titre';
$this->con->executeQuery($query, array(
':titre' => array("%$titre%", \PDO::PARAM_STR)
));
$res = $this->con->getResults();
return $res;
}
} }

@ -3,8 +3,7 @@
namespace App\metier; namespace App\metier;
class Alumni{ class Alumni{
/** /**
* @var string Email * @var string Email
*/ */

@ -1,5 +1,6 @@
<?php <?php
namespace App\metier; namespace App\metier;
use App\metier\Alumni;
class Evenement class Evenement
{ {
@ -9,87 +10,109 @@ class Evenement
private int $id; private int $id;
/** /**
* @var string Nom Evenement * @var int Organisateur
*/ */
private string $nom; private int $organisateur;
/** /**
* @var string Date de l'evenement * @var string Titre Evenement
*/ */
private string $date; private string $titre;
/** /**
* @var Alumni Organisateur * @var string Description de l'evenement
*/ */
private Alumni $organisateur; private string $description;
/** /**
* @var array Liste des Participants * @var string Date de l'evenement
*/ */
private array $participants; private string $date;
/** /**
* @var int Nombre maximal d'inscrits * @var int Nombre maximal d'inscrits
*/ */
private int $nbInscriptionMax; private int $nbPlaceMax;
/** /**
* @var string Url de l'image * @var string Image de l'evenement
*/ */
private string $imageUrl; private string $image;
/** /**
* @param int $id * @param int $id
* @param string $nom * @param int $organisateur
* @param string $titre
* @param string $description
* @param string $date * @param string $date
* @param Alumni $organisateur * @param int $nbPlaceMax
* @param array $participants * @param string $image
* @param int $nbInscriptionMax
* @param string $imageUrl
*/ */
public function __construct(int $id, string $nom, string $date, Alumni $organisateur, array $participants, int $nbInscriptionMax, string $imageUrl) public function __construct(int $id, int $organisateur, string $titre, string $description, string $date, int $nbPlaceMax, string $image)
{ {
$this->id = $id; $this->id = $id;
$this->nom = $nom;
$this->date = $date;
$this->organisateur = $organisateur; $this->organisateur = $organisateur;
$this->participants = $participants; $this->titre = $titre;
$this->nbInscriptionMax = $nbInscriptionMax; $this->description = $description;
$this->imageUrl = $imageUrl; $this->date = $date;
$this->nbPlaceMax = $nbPlaceMax;
$this->image = $image;
} }
/**
* @return int
*/
public function getId(): int public function getId(): int
{ {
return $this->id; return $this->id;
} }
public function getNom() : string /**
* @return string
*/
public function getTitre(): string
{ {
return $this->nom; return $this->titre;
} }
public function getDate() : string /**
* @return int
*/
public function getOrganisateurId(): int
{ {
return $this->date; return $this->organisateur;
} }
public function getParticipants() : array /**
* @return string
*/
public function getDescription(): string
{ {
return $this->participants; return $this->description;
} }
public function getOrganisateur(): Alumni /**
* @return string
*/
public function getDate(): string
{ {
return $this->organisateur; return $this->date;
} }
public function getNbInscriptionMax(): int /**
* @return int
*/
public function getNbPlaceMax(): int
{ {
return $this->nbInscriptionMax; return $this->nbPlaceMax;
} }
public function getImageUrl(): string /**
* @return int
*/
public function getImage(): string
{ {
return $this->imageUrl; return $this->image;
} }
} }

@ -1,52 +0,0 @@
<?php
namespace App\modele;
use App\gateway\Connection;
use App\metier\Image;
use App\gateway\ImageGateway;
class ImageModele
{
private ImageGateway $gw;
public function __construct()
{
$this->gw = new ImageGateway(new Connection(DB_HOST,DB_USER,DB_PASS));
}
public function publierImage(string $file) : Image
{
$img = new Image($this->gw->getNewId(),
$_FILES[$file]["name"],
$_FILES[$file]["size"],
$_FILES[$file]["type"],
file_get_contents($_FILES[$file]["tmp_name"]));
$this->insertImage($img);
return $img;
}
public function insertImage(Image $img)
{
$this->gw->insertImage($img);
}
public function obtenirParId(int $id)
{
$this->gw->getFromId($id);
$res = $this->gw->getResults();
return new Image($this->gw->getNewId(),$res[0]['nom'], $res[0]['taille'], $res[0]['type'], $res[0]['blob']);
}
public function obtenirToutesImages() : array
{
$this->gw->obtenirToutesImages();
$res = $this->gw->getResults();
foreach ($res as $r) {
$array[] = new Image($this->gw->getNewId(),$r['nom'], $r['taille'], $r['type'], $r['blob']);
}
return $array;
}
}

@ -1,15 +1,18 @@
<?php <?php
namespace App\modele; namespace App\modele;
use App\gateway\Connection;
use App\gateway\EvenementGateway;
use App\metier\Evenement;
class UtilisateurModele class UtilisateurModele
{ {
/** private $con;
* @description Charger le flux d'activiter
* @return array flux public function __construct()
*/
public function LoadFeed() : array
{ {
// TO DO $this->con = new Connection(DB_HOST,DB_USER,DB_PASS);
return [];
} }
/** /**
@ -19,27 +22,27 @@ class UtilisateurModele
* @return \App\metier\Alumni * @return \App\metier\Alumni
*/ */
public function connection(string $email, string $mdp) : ? \App\metier\Alumni public function connection(string $email, string $mdp) : ? \App\metier\Alumni
{ {
$con = new \App\gateway\Connection(DB_HOST,DB_USER,DB_PASS); $con = new \App\gateway\Connection(DB_HOST,DB_USER,DB_PASS);
$gate = new \App\gateway\AlumniGateway($con); $gate = new \App\gateway\AlumniGateway($con);
// Récupérez l'utilisateur avec l'email donné en utilisant AlumniGateway // Récupérez l'utilisateur avec l'email donné en utilisant AlumniGateway
$utilisateur = $gate->findByEmail($email); $utilisateur = $gate->findByEmail($email);
if ($utilisateur instanceof \App\metier\Alumni) { if ($utilisateur instanceof \App\metier\Alumni) {
// L'utilisateur existe, vérifiez le mot de passe // L'utilisateur existe, vérifiez le mot de passe
if (password_verify($mdp, $utilisateur->getPassword())) { if (password_verify($mdp, $utilisateur->getPassword())) {
// Le mot de passe est correct, retournez l'utilisateur // Le mot de passe est correct, retournez l'utilisateur
session_start(); session_start();
return $utilisateur; return $utilisateur;
} else { } else {
// Le mot de passe est incorrect, renvoyez null // Le mot de passe est incorrect, renvoyez null
return null; return null;
} }
} else { } else {
// L'utilisateur n'existe pas, renvoyez null // L'utilisateur n'existe pas, renvoyez null
return null; return null;
} }
} }
/** /**
* @description s'inscrire * @description s'inscrire
@ -49,47 +52,128 @@ class UtilisateurModele
* @return \Alumni chargé * @return \Alumni chargé
*/ */
public function inscription(string $prenom, string $nom,string $email, string $hashpassword):? \App\metier\Alumni 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
{ {
$role = "Membre"; $gate = new EvenementGateway($this->con);
$con = new \App\gateway\Connection(DB_HOST,DB_USER,DB_PASS);
$gate = new \App\gateway\AlumniGateway($con); $data = $gate->getAllEvenement();
$profilGate = new \App\gateway\ProfilGateway($con);
// Insérez le nouvel utilisateur dans la base de données en utilisant AlumniGateway $evenement = array();
if ($gate->insert($email, $hashpassword, $role)) {
// <<<<<<< HEAD foreach($data as $row)
// // L'insertion a réussi, retournez le nouvel utilisateur {
// $nouvelUtilisateur = new \App\metier\Alumni($email, $hashpassword, $role); $evenement[] = new Evenement(
// return $nouvelUtilisateur; $row['id'],
// } else { $row['organisateur'],
// // L'insertion a échoué, renvoyez un utilisateur vide pour indiquer l'échec $row['titre'],
// return new \App\metier\Alumni(null, null, null); $row['description'],
// ======= $row['date'],
$alumni = $gate->getID($email); $row['nbPlaceMax'],
if($profilGate->insert($alumni,$nom, $prenom,$email)){ $row['image']
// 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;
} }
return $evenement;
} }
public function getUtilisateurByEmail(string $email) public function ajouterEvenement(string $titre, string $description, string $date, int $nbPlaceMax, string $img)
{ {
$con = new \App\gateway\Connection(DB_HOST,DB_USER,DB_PASS); $gate = new EvenementGateway($this->con);
$gate = new \App\gateway\AlumniGateway($con);
// Récupérez l'utilisateur avec l'email donné en utilisant AlumniGateway $evenement = new Evenement(
$utilisateur = $gate->findByEmail($email); $gate->getNewId(),
if ($utilisateur instanceof \App\metier\Alumni) { '1', //TODO : Ajouter l'ID de l'admin connecté
// L'utilisateur existe, retournez-le $titre,
return $utilisateur; $description,
} else { $date,
// L'utilisateur n'existe pas, renvoyez null $nbPlaceMax,
return null; $img
);
$gate->insertEvenement($evenement);
}
public function deleteEvenement(int $id)
{
$gate = new EvenementGateway($this->con);
$gate->deleteEvenement($id);
}
public function getEvenementById(int $id) : Evenement
{
$gate = new EvenementGateway($this->con);
$data = $gate->findById($id);
$evenement = new Evenement(
$data[0]['id'],
$data[0]['organisateur'],
$data[0]['titre'],
$data[0]['description'],
$data[0]['date'],
$data[0]['nbPlaceMax'],
$data[0]['image']
);
return $evenement;
}
public function getEvenementByTitre(string $titre) : array
{
$gate = new EvenementGateway($this->con);
$data = $gate->findByTitle($titre);
$evenement = array();
foreach($data as $row)
{
$evenement[] = new Evenement(
$row['id'],
$row['organisateur'],
$row['titre'],
$row['description'],
$row['date'],
$row['nbPlaceMax'],
$row['image']
);
} }
return $evenement;
} }
} }

@ -0,0 +1,49 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Créer un Événement</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<div class="container mt-5">
<h1 class="text-center">Créer un Événement</h1>
<form action="index.php?action=creerEvenement" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="titre">Titre de l'Événement :</label>
<input type="text" class="form-control" id="titre" name="titre" required>
</div>
<div class="form-group">
<label for="description">Description de l'Événement :</label>
<textarea class="form-control" id="description" name="description" rows="4" required></textarea>
</div>
<div class="form-group">
<label for="date">Date de l'Événement :</label>
<input type="date" class="form-control" id="date" name="date" required>
</div>
<div class="form-group">
<label for="nbPlaceMax">Nombre maximal d'inscrits :</label>
<input type="number" class="form-control" id="nbPlaceMax" name="nbPlaceMax" required>
</div>
<div class="form-group">
<label for="image">Image de l'Événement :</label>
<input type="file" class="form-control-file" name="image" id="image" required>
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary" value="Créer l'Événement">
</div>
</form>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.3/dist/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>

@ -0,0 +1,125 @@
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
<meta charset="UTF-8">
<title>Publier une Offre</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<header>
{% include "menu.html" %}
</header>
<main class="container mt-4">
<h1>Publier Une Offre</h1>
<form style="background-color: #00DBFF" class="p-4" enctype="multipart/form-data" action="index.php?action=createOffer" method="post">
{% if tabError is defined %}
{% for error in tabError %}
<p style="color: red">{{ error }}</p>
{% endfor %}
{% endif %}
<p>Les champs contenant des astrérisques * sont obligatoires.</p>
<div class="form-group">
<label for="name">Intitulé de l'offre*</label>
<input type="text" class="form-control" id="name" name="name" placeholder="Intitulé" maxlength="128" required>
</div>
<div class="form-group">
<label for="entreprise">Nom de l'entreprise :*</label>
<input type="text" class="form-control" id="entreprise" name="entreprise" placeholder="Entreprise" maxlength="64" required>
</div>
<div class="form-group">
<label for="description">Amorce :*</label>
<textarea class="form-control" id="description" name="description" placeholder="Description rapide" maxlength="200" required></textarea>
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="fullRemote" name="fullRemote" >
<label class="form-check-label" for="fullRemote">Full Remote</label>
</div>
<div class="form-group">
<label for="ville">Ville</label>
<input type="text" class="form-control" id="ville" name="ville" placeholder="Ville" required maxlength="100">
</div>
<div class="form-group">
<label for="choixContrat">Choisissez un type de contrat :*</label>
<select class="form-control" id="choixContrat" name="typeContrat">
<option value="CDI" selected>CDI</option>
<option value="CDD">CDD</option>
<option value="Alternance">Alternance</option>
<option value="Stage">Stage</option>
</select>
</div>
<div class="form-group">
<label for="descriptPoste">Descriptif du Poste :*</label>
<textarea class="form-control" id="descriptPoste" name="descriptPoste" placeholder="Description du Poste" required maxlength="2028"></textarea>
</div>
<div class="form-group">
<label for="profilRecherche">Profil Recherché :*</label>
<textarea class="form-control" id="profilRecherche" name="profilRecherche" placeholder="Profil recherché" required maxlength="2028"></textarea>
</div>
<div class="form-group">
<label for="choixExp">Experience Recherchée :*</label>
<select class="form-control" id="choixExp" name="choixExp" required>
<option value="Indifférent" selected>Indifferent</option>
<option value="Junior">Junior</option>
<option value="Senior">Senior</option>
</select>
</div>
<div class="form-group">
<label for="nivEtudes">Niveau d'études :*</label>
<select class="form-control" id="nivEtudes" name="education" required>
<option value="Indifférent" selected>Indifferent</option>
<option value="Bac+2">Bac+2</option>
<option value="Bac+3">Bac+3</option>
<option value="Bac+5">Bac+5</option>
</select>
</div>
<div class="form-group">
<label for="mail">Email de contact :*</label>
<input type="text" class="form-control" id="mail" name="mail" placeholder="Adresse de contact" maxlength="30" required>
</div>
<div class="form-group">
<label for="num">Numero de contact :*</label>
<input type="text" class="form-control" id="num" name="num" placeholder="Numéro de contact" required maxlength="10">
</div>
<div class="form-group">
<label for="site">Site web de l'annonce ou entreprise :</label>
<input type="text" class="form-control" id="site" name="site" placeholder="Adresse web" maxlength="40" required>
</div>
<label for="image">Image*</label>
<input type="file" name="image" id="image" required>
<label for="logo">Logo d'entreprise*</label>
<input type="file" name="logo" id="logo" required>
<input type="submit" value="Publier L'annonce" name="submit" id="submit">
<p><i>Les images doivent être de type png, jpg, jpeg, bmp, webp & inférieures à 10MB</i></p>
</form>
</main>
<!-- scripts : -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.3/dist/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>

@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
{% if evenement %}
<title>{{evenement.titre}}</title>
{% endif %}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link rel="stylesheet" href="css/evenement_details.css"> <!-- You can create a separate CSS file for event details -->
</head>
<body>
<header>
{% include "menu.html" %}
</header>
<div class="container mt-4">
{% if evenement %}
<h1>Détails de l'Événement : {{evenement.titre}}</h1>
<div class="event-details">
<p><strong>Organisateur:</strong> {{ evenement.organisateurId }}</p>
<p><strong>Date:</strong> {{ evenement.date }}</p>
<p><strong>Description:</strong> {{ evenement.description }}</p>
<img src="uploads/{{ evenement.getImage() }}" width="250px" class="img-fluid" alt="Event Image">
<p><strong>Places disponibles:</strong> {{ evenement.nbPlaceMax }}</p>
<a href="../public/index.php?action=listerEvenement" class="btn btn-primary">Retour</a>
</div>
{% else %}
<p>L'événement n'existe pas ou n'est pas disponible.</p>
{% endif %}
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.3/dist/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>

@ -0,0 +1,58 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Liste des Événements</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link rel="stylesheet" href="css/evenement.css">
</head>
<body>
<header>
{% include "menu.html" %}
</header>
<div class="container mt-4">
<div class="div_titres">
<form action="../public/index.php?action=rechercherEvenement" method="post">
<input type="text" name="recherche" id="recherche" placeholder="Rechercher un événement">
<button type="submit">
<img src="assets/search.svg" alt="rechercher" width="30px">
</button>
</form>
<h1>Liste des Événements</h1>
<a href="../public/index.php?action=creerEvenement" class="btn btn-primary">Publier événement</a>
</div>
<ul class="list-group">
{% if evenements is not empty %}
{% for evenement in evenements %}
<li class="list-group-item">
<div class="infos">
<h2>{{ evenement.titre }}</h2>
<p><strong>Organisateur:</strong> {{ evenement.getNomOrganisateur() }}</p>
<p><strong>Date:</strong> {{ evenement.date }}</p>
<p><strong>Description:</strong> {{ evenement.description }}</p>
<img src="uploads/{{ evenement.getImage() }}" width="250px" class="img-fluid" alt="{{ evenement.titre }}">
<p><strong>Places disponibles:</strong> {{ evenement.nbPlaceMax }}</p>
<a href="../public/index.php?action=avoirDetailEvenement&id={{ evenement.id }}" class="btn btn-primary">Détails</a>
</div>
<form action="../public/index.php?action=supprimerEvenement&id={{ evenement.id }}" method="post">
<button type="submit" class="btn btn-primary" id="deleteButton">
<img src="assets/close.png" alt="Supprimer" width="20px">
</button>
</form>
</li>
{% endfor %}
{% else %}
<li class="list-group-item">Aucun événement trouvé.</li>
{% endif %}
</ul>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.3/dist/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>
Loading…
Cancel
Save