offres 100% fonctionnelles

alexis-rendu
Baptiste D 1 year ago
parent ef2ff36190
commit 03371c34ad

@ -43,6 +43,8 @@ class FrontControleur
$router->map('GET|POST', '/user/[a:action]?', 'MembreControleur');
$router->map('GET|POST', '/user/[i:id]/[a:action]?', 'MembreControleur');
$router->map('GET|POST', '/user/[i:id]/[a:action]/[i:id2]?', 'MembreControleur');
$router->map('GET|POST', '/admin/[i:id]/[a:action]?', 'AdminControleur');
@ -130,6 +132,6 @@ class FrontControleur
}
}
}
}

@ -8,8 +8,7 @@ use App\modele\MembreModele;
class MembreControleur extends UtilisateurControleur
{
public function __construct()
{
}
{}
public function deconnexion()
{
@ -23,7 +22,7 @@ class MembreControleur extends UtilisateurControleur
public function createOfferForm()
{
global $twig;
echo $twig->render("CreerOffre.html", []);
echo $twig->render("CreateOffer.html", []);
}
public function createOffer()
@ -42,46 +41,41 @@ class MembreControleur extends UtilisateurControleur
}
if($error)
{
echo $twig->render("CreerOffre.html", ['tabError' => $taberror ]);
echo $twig->render("CreateOffer.html", ['tabError' => $taberror ]);
return;
}
if(!Validation::verifierEmail($_POST["mail"]))
{
//echo $twig->render("CreerOffre.html", ['errMsg' => "Email non valide !" ]);
$taberror[] = "Email non valide !";
}
if(!Validation::validateNumber($_POST["num"]))
{
$taberror[] = "Numero non valide !";
//echo $twig->render("CreerOffre.html", ['errMsg' => "Numero non valide !" ]);
}
if (!Validation::validateImage("image"))
{
if(isset($_FILES['image']['name'])) {$taberror[] = "Image non valide !";}
else {$taberror[] = "Inserez une image !";}
$taberror[] = "Image non valide !";
}
if(!Validation::validateImage("logo")) {
if(isset($_FILES['logo']['name'])) {$taberror[] = "Logo non valide !";}
else {$taberror[] = "Inserez un logo !";}
return;
$taberror[] = "Logo non valide !";
}
if(count($taberror) > 0)
{
echo $twig->render("CreerOffre.html", ['tabError' => $taberror ]);
echo $twig->render("CreateOffer.html", ['tabError' => $taberror ]);
}
else{
$saveImg1 = ImageManager::SaveImage("image");
$saveImg2 = ImageManager::SaveImage("logo");
if($saveImg1[0] && $saveImg2[0]) {
if($saveImg1[0] != NULL && $saveImg2[0] != NULL)
{
$mbrModel = new MembreModele();
$offre = $mbrModel->publishOffer($saveImg1[1], $saveImg2[1]);
echo $twig->render("OffreDetailTest.html", ['offre' => $offre]);
@ -89,27 +83,51 @@ class MembreControleur extends UtilisateurControleur
else
{
$taberror[] = "Erreur lors de l'upload des images";
echo $twig->render("CreerOffre.html", ['tabError' => $taberror ]);
echo $twig->render("CreateOffer.html", ['tabError' => $taberror ]);
}
}
}
protected function proposerOffre()
public function deleteOffer(?array $params)
{
//TODO
global $twig;
$id = $params['id2'];
$MemberModel = new MembreModele();
$offre = $MemberModel->getOfferFromId($id);
if($offre != NULL)
{
$MemberModel->deleteOffer($offre);
}
$this->consultOffers();
/*$offre = $MemberModel->getOfferFromId($id);
if($offre->getOffreur()->getId() == $_SESSION['id']
|| $_SESSION['role'] == "admin")
{
$MemberModel = new MembreModele();
$MemberModel->deleteOffer($offre);
$this->consultOffers();
}*/
}
protected function consulterProfil()
public function proposerOffre()
{
//TODO
}
protected function modifierProfil()
public function consulterProfil()
{
//TODO
}
protected function signaler()
public function modifierProfil()
{
//TODO
}
public function signaler()
{
//TODO
}

@ -104,33 +104,28 @@ class UtilisateurControleur
echo 'not implemented yet';
}
public function consultOffers()
public function consultOffers(?array $params)
{
$userMdl = new UtilisateurModele();
global $twig;
$niveauEtudes=null;
$typeContrat=null;
$exp = null;
$role = NULL;
if(isset($_SESSION['utilisateur']))
{
$role = $_SESSION['utilisateur']->getRole() ;
}
$niveauEtudes = NULL;
$typeContrat = NULL;
$exp = NULL;
$msg = NULL;
$nbOffers = 5 ;
if(isset($_GET["niveauEtudes"]) && Validation::validateTypeStudies($_GET["niveauEtudes"])) {
$niveauEtudes = $_GET["niveauEtudes"];
if(isset($_POST["niveauEtudes"]) && Validation::validateTypeStudies($_POST["niveauEtudes"])) {
$niveauEtudes = $_POST["niveauEtudes"];
}
if(isset($_GET["typeContrat"]) && Validation::validateTypeContract($_GET["typeContrat"])) {
$typeContrat = $_GET["typeContrat"];
if(isset($_POST["typeContrat"]) && Validation::validateTypeContract($_POST["typeContrat"])) {
$typeContrat = $_POST["typeContrat"];
}
if(isset($_GET["experience"]) && Validation::validateExperience($_GET["experience"])) {
$exp = $_GET["experience"];
if(isset($_POST["experience"]) && Validation::validateExperience($_POST["experience"])) {
$exp = $_POST["experience"];
}
if ($niveauEtudes == null && $typeContrat == null && $exp == null) {
@ -141,15 +136,14 @@ class UtilisateurControleur
'exp' => $exp,
'niveauEtudes' => $niveauEtudes
);
$offers = $userMdl->getOffersWithFilters($params);
$totalOffers = count($offers);
//$offers = $userMdl->getOffersWithFilters($params);
//var_dump($offers);
//$totalOffers = count($offers);
$totalOffers = count($userMdl->getOffersWithFilters($params));
}
$numberPages = ceil($totalOffers / 5);
$msg = NULL;
if (isset($_GET["page"]) && intval($_GET["page"]) != null) {
$page = intval($_GET["page"]);
if ($page > $numberPages || $page < 1) {
@ -163,17 +157,16 @@ class UtilisateurControleur
$start = intval(($page - 1) * 5);
$offers = [];
if ($niveauEtudes == null && $typeContrat == null && $exp == null) {
$offers = $userMdl->getOfferLimit($start, $nbOffers);
} else {
$params['start'] = $start;
$params['nbOffers'] = 5;
$offers = $userMdl->getOffersWithFilters($params);
}
/* echo "filtre :".$niveauEtudes."<br>";
echo "filtre :".$typeContrat."<br>";
echo "filtre :".$exp."<br>";*/
}
echo $twig->render('OffersList.html', [
'msg' => $msg,

@ -1,74 +0,0 @@
<?php
namespace App\gateway;
use App\metier\Image;
use PDO;
class ImageGateway
{
private Connection $con;
/**
* @param $con
*/
public function __construct(Connection $con)
{
$this->con = $con;
}
public function insertImage(Image $img)
{
$query = "INSERT INTO Image (`nom`, `taille`, `type`, `blob`) VALUES ( :n, :t, :ty, :b)";
$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)
{
$query = 'DELETE FROM Image WHERE id=:i';
$this->con->executeQuery($query, array(
':i' => array($id, PDO::PARAM_INT)
));
}
public function getFromId(int $id) : array
{
$query = 'SELECT * FROM Image WHERE id=:i';
$this->con->executeQuery($query, array(
':i' => array($id, PDO::PARAM_INT)
));
return $this->con->getResults();
}
public function getNewId() : int
{
$query = 'SELECT MAX(id) FROM Image';
$this->con->executeQuery($query);
$res = $this->con->getResults();
if ($res[0]['MAX(id)'] === null) {
return 1;
}
return intval($res[0]['MAX(id)'])+1;
}
public function obtenirToutesImages()
{
$query = 'SELECT * FROM Image';
$this->con->executeQuery($query);
$res = $this->con->getResults();
$array = [];
foreach ($res as $r) {
$array[] = new Image($this->getNewId(),$r['nom'], $r['taille'], $r['type'], $r['blob']);
}
return $array;
}
}
?>

@ -28,7 +28,7 @@ class ImageManager
}
}
public function deleteImg(string $img) : bool
public static function deleteImg(string $img) : bool
{
$path = "public/uploads/$img";
if (file_exists($path)) {

@ -2,6 +2,7 @@
namespace App\modele;
use App\gateway\ImageManager;
use App\metier\Alumni;
use App\metier\Offre;
@ -90,8 +91,6 @@ class MembreModele extends UtilisateurModele
}
else $remote = false;
echo "session id".$_SESSION['id'];
// à la place de NULL passer id utilisateur créateur offre
$offre = new Offre($this->offreGw->getNewId(),
new Alumni(intval($_SESSION['id']),"test.mail@icloud.fr","",$_SESSION['role'],$_SESSION['nom'],$_SESSION['prenom']),
@ -115,11 +114,13 @@ class MembreModele extends UtilisateurModele
$this->offreGw->addOffers($offre);
return $offre;
}
public function deleteOffer(Offre $o)
public function deleteOffer(Offre $offre)
{
$this->offreGw->deleteOffer($offre->getId());
ImageManager::deleteImg($offre->getImg());
ImageManager::deleteImg($offre->getLogo());
}

@ -257,7 +257,7 @@ class UtilisateurModele
public function getOffersWithFilters($params) : array
{
return $this->offreGw->getOffersWithFilters($params);
return $this->CreateOffersFromGw($this->offreGw->getOffersWithFilters($params));
}
public function getOffers() : array

@ -1,125 +0,0 @@
<!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>

@ -19,7 +19,6 @@
{% endif %}
</div>
<div class="container mt-4">
<div class="d-flex flex-column align-items-center">
@ -46,8 +45,6 @@
</div>
</div>
<div class="form-group mr-3 flex-column">
<label for="experience">Expérience :</label>
<div class="form-check">
@ -113,14 +110,19 @@
<img src="public/assets/location.png" alt="location">
<p>{{offre.getVille()}}</p>
</div>
<div class="d-flex justify-content-around">
<button type="button" class="btn btn-outline-primary btn-sm mb-2 custom-button"
onclick="window.location.href = '{{dir}}/displayOffer/{{offre.getId()}}'">En savoir plus</button>
</article>
{% if role == 'Admin' or id == offre.getOffreur().getId() %}
<button class="btn btn-outline-danger mb-2" onclick="window.location.href='{{dir}}/user/{{id}}/deleteOffer/{{offre.getId()}}'">Supprimer</button>
{% endif %}
</div>
</article>
{% endfor %}
{% else %}
<li class="list-group-item">Aucune offre trouvée.</li>
{% endif %}
<nav style="text-align: center;">
<nav style="text-align: center;">
{% if numberPages is defined %}

@ -9,15 +9,19 @@
<header>
<!-- Add your logo here -->
{% include "menu.html" %}
</header>
<div class="container mt-5">
<h1 class="display-4">Détails de l'Offre</h1>
<ul class="list-group">
<!-- Add an image related to the offer -->
<li class="list-group-item"></li><img src="{{dir}}/public/uploads/{{offre.getLogo()}}" alt="Logo" class="img-thumbnail" style="max-height: 50px; max-width: 50px;"></li>
{% if role == 'Admin' or id == offre.getOffreur().getId() %}
<button class="btn btn-outline-danger mb-2" onclick="window.location.href='{{dir}}/user/{{id}}/deleteOffer/{{offre.getId()}}'">Supprimer</button>
{% endif %}
<img src="{{dir}}/public/uploads/{{offre.getLogo()}}" alt="Logo" class="img-thumbnail" style="max-height: 50px; max-width: 50px;"></li>
<li class="list-group-item"><img src="{{dir}}/public/uploads/{{offre.getImg()}}" alt="Offer Image" class="img-fluid"></li>
<!--<li class="list-group-item"><strong>ID:</strong> {{ offre.getId() }}</li> -->
<li class="list-group-item"><strong>Offreur:</strong> {{offre.getOffreur().Prenom()}} {{offre.getOffreur().getNom() }}</li>
@ -26,6 +30,7 @@
<li class="list-group-item"><strong>Description:</strong> {{ offre.getDescription() }}</li>
<li class="list-group-item"><strong>Type de contrat:</strong> {{ offre.getTypeContrat() }}</li>
<li class="list-group-item"><strong>Niveau d'études :</strong> {{ offre.getNiveauEtudes() }}</li>
<li class="list-group-item"><strong>Experience Recherchée :</strong> {{ offre.getExperience() }}</li>
<li class="list-group-item"><strong>Ville:</strong> {{ offre.getVille() }}</li>
<li class="list-group-item"><strong>Date de publication:</strong> {{ offre.getDateStringFr() }}</li>
<li class="list-group-item"><strong>Descriptif Poste :</strong> {{ offre.getDescriptifPoste() }}</li>
@ -33,7 +38,6 @@
<li class="list-group-item"><strong>Site de L'annonce :</strong> {{ offre.getSiteUrl() }}</li>
<li class="list-group-item"><strong>Mail de Contact : :</strong> {{ offre.getMailContact() }}</li>
<li class="list-group-item"><strong>Numéro de Contact :</strong> {{ offre.getNumero() }}</li>
<li class="list-group-item">
<strong>Full Remote :</strong>
{% if offre.isRemote() %}

Loading…
Cancel
Save