test ajout expérience + gateway expérience

Expérience/Formation
thomas muzard 1 year ago
parent be622c2be6
commit 12f1078968

@ -95,6 +95,15 @@ class Validation
return false;
}
public static function validerExperience(string $intitule, string $dateDeb, string $dateFin, string $nomEntreprise, bool $currendJob)
{
if(!empty($intitule) && !empty($dateDeb) && !empty($nomEntreprise), && !empty($currendJob))
{
return true;
}
return false;
}
public static function validateNumber($number) : bool
{
if(preg_match("/^[0-9]{10}$/", $number))

@ -16,7 +16,7 @@ class FrontControleur
//TODO
],
"Membre" => [
"deconnexion","proposerOffre","consulterProfil","modifierProfil","signaler",
"deconnexion","proposerOffre","consulterProfil","modifierProfil","signaler","ajouterExperience","supprimerExperience"
],
"Utilisateur" => [

@ -27,6 +27,9 @@ class MembreControleur extends UtilisateurControleur
case "signaler":
$this->signaler();
break;
case "ajouterExperience":
$this->ajouterExperience();
break;
default:
parent::__construct();
}
@ -58,4 +61,46 @@ class MembreControleur extends UtilisateurControleur
{
//TODO
}
public function listerExperience()
{
global $twig;
if (isset($_GET["id"]) && intval($_GET["id"]) != null)
{
$experienceModel = new MembreModele();
$exp = $experienceModel->getExperienceFromProfil(intval($_GET["id"]));
if($exp != NULL)
{
echo $twig->render("detailExperience.html",['experience' => $exp]);
return;
}
}
$dVueErreur[] = "Erreur, Expérience(s) introuvable";
echo $twig->render("erreur.html", ['dVueErreur' => $dVueErreur]);
}
protected function experienceForm()
{
global $twig;
echo $twig->render("CreerExperience.html", []);
}
protected function ajouterExperience()
{
global $twig;
if (!Validation::validerExperience($_POST["titre"], $_POST["description"], $_POST["date"], $_POST["nbPlaceMax"], $img[1])) {
$modele = new MembreModele();
$modele->addExperience($_POST["titre"], $_POST["description"], $_POST["date"], $_POST["nbPlaceMax"], $img[1]);
$this->listerExperience();
} 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', []);
}
}
}

@ -0,0 +1,76 @@
<?php
namespace App\gateway;
use App\metier\Profil;
use App\metier\Experience;
class ExperienceGateway
{
private \App\gateway\Connection $con;
/**
* @param $con
*/
public function __construct(\App\gateway\Connection $con){
$this->con = $con;
}
public function getMaxId() : int
{
$query='SELECT MAX(id) FROM Experience';
$this->con->executeQuery($query);
$res=$this->con->getResults();
return $res[0]['MAX(id)']+1;
}
public function getNbExperience(): int
{
$query = 'SELECT COUNT(*) FROM Experience';
$this->con->executeQuery($query, array());
$res = $this->con->getResults();
return intval($res[0]['COUNT(*)']);
}
public function getExperienceFromId($id) : array
{
$query = "SELECT * FROM experience WHERE id=:id";
$this->con->executeQuery($query, array(
':id' => array($id, \PDO::PARAM_INT)
));
return $this->con->getResults();
}
public function getExperienceFromProfil($profil) : array
{
$query = "SELECT * FROM experience WHERE profil=:profil AND " ;
$this->con->executeQuery($query, array(
':profil' => array($profil, \PDO::PARAM_INT)
));
return $this->con->getResults();
}
public function addExperience(Experience $exp)
{
$query = 'INSERT INTO experience VALUES (:id, :profil, :intitule, :dateBegin, :dateEnd, :nameIndustry, :currentJobb)';
$this->con->executeQuery($query, array(
':id' => array($exp->getId(), \PDO::PARAM_INT),
//':profil' => array($exp->getProfil(), \PDO::PARAM_INT),
':profil' => array(1,\PDO::PARAM_INT),
':intitule' => array($exp->getIntitule(), \PDO::PARAM_STR),
':dateBegin' => array($exp->getDateDebut(), \PDO::PARAM_STR),
':dateEnd' => array($exp->getDateFin(), \PDO::PARAM_STR),
':nameIndustry' => array($exp->getNomEntreprise(), \PDO::PARAM_STR),
':currentJobb' => array($exp->isTravailActuel(), \PDO::PARAM_BOOL),
));
}
public function deleteExperience($id)
{
$query = 'DELETE FROM experience WHERE id=:id'
$this->con->executeQuery($query, array(
':id' => array($id, \PDO::PARAM_INT)
));
}
}

@ -2,9 +2,23 @@
namespace App\modele;
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 mysql_xdevapi\Exception;
class MembreModele extends UtilisateurModele
{
private $con;
public function __construct()
{
$this->con = new Connection(DB_HOST,DB_USER,DB_PASS);
}
/**
* @description modifier photo de profil
@ -34,13 +48,72 @@ class MembreModele extends UtilisateurModele
return false;
}
/**
* @description Récupérer l'expériences en fonction de l'id
*/
public function getExperienceById() : array
{
$gate = new ExperiencetGateway($this->con);
$data = $gate->getExperienceFromId();
$experience = array();
foreach($data as $row)
{
$experience[] = new Experience(
$row['id'],
$row['profil'],
$row['intitule'],
$row['dateBegin'],
$row['dateEnd'],
$row['industryName'],
$row['currentJob']
);
}
return $experience;
}
/**
* @description Récupérer les expériences de l'utilisateurs en cours
*/
public function getExperienceByProfil() : array
{
$gate = new ExperiencetGateway($this->con);
$data = $gate->getExperienceFromProfil();
$experience = array();
foreach($data as $row)
{
$experience[] = new Experience(
$row['id'],
$row['profil'],
$row['intitule'],
$row['dateBegin'],
$row['dateEnd'],
$row['industryName'],
$row['currentJob']
);
}
return $experience;
}
/**
* @description ajouter Experience
*/
public function addExperience() : bool
public function addExperience()
{
// TO DO
return false;
$gate = new ExperienceGateway($this->con);
$exp = new Experience(
$gate->getNewId(),
'1', //TODO : Ajouter l'ID de l'admin connecté
$titre,
$description,
$date,
$nbPlaceMax,
$img
);
$gate->insertEvenement($evenement);
}
/**

@ -0,0 +1,50 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ajouter une expérience</title>
<link rel="stylesheet" href="">
</head>
<body>
<div>
<h1>Ajouter une expérience</h1>
<form action="index.php?action=ajouterExperience" method="POST" enctype="multipart/form-data">
<div>
<label for="intitule">Intitule :</label>
<input type="text" id="intitule" name="intitule" required>
</div>
<div>
<label for="date">Date de début :</label>
<input type="date" id="dateDeb" name="dateDeb" required>
</div>
<div>
<label for="date">Date de fin :</label>
<input type="date" id="dateFin" name="dateFin">
</div>
<div>
<label for="intitule">Nom de l'entreprise :</label>
<input type="text" id="nomEntreprise" name="nomEntreprise" required>
</div>
<div class="form-group">
<label for="image">Job en cours ? :</label>
<input type="radio" name="image" id="image" required>
</div>
<div class="form-group">
<input type="submit" value="ajouter_Experience">
</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,37 @@
<!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 experience %}
<title>{{experience.intitule}}</title>
{% endif %}
<link rel="stylesheet" href="">
</head>
<body>
<header>
{% include "menu.html" %}
</header>
<div class="container mt-4">
{% if experience %}
<h1>Détails de l'Événement : {{experience.intitule}}</h1>
<div class="event-details">
<p><strong>nom de l'entreprise :</strong> {{ experience.nomEntreprise }}</p>
<p><strong>Date de début :</strong> {{ experience.dateDeb }}</p>
<p><strong>Date de fin :</strong> {{ experience.dateFin }}</p>
<p><strong>Job en cours ? :</strong> {{ experience.travailActuel }}</p>
<a href="../public/index.php?action=listerExperience">Retour</a>
</div>
{% else %}
<p>L'expérience 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>
Loading…
Cancel
Save