Compare commits
No commits in common. 'master' and 'AffichageProfil' have entirely different histories.
master
...
AffichageP
Before Width: | Height: | Size: 100 KiB |
Before Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 45 KiB |
After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 2.5 MiB |
Before Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 80 KiB |
After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 9.7 KiB |
Before Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 8.0 KiB |
Before Width: | Height: | Size: 2.5 MiB |
Before Width: | Height: | Size: 162 KiB |
Before Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 2.5 MiB |
Before Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 2.5 MiB |
Before Width: | Height: | Size: 124 KiB |
Before Width: | Height: | Size: 2.5 MiB |
Before Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 164 KiB |
Before Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 2.5 MiB |
Before Width: | Height: | Size: 149 KiB |
Before Width: | Height: | Size: 2.5 MiB |
Before Width: | Height: | Size: 2.5 MiB |
After Width: | Height: | Size: 467 KiB |
Before Width: | Height: | Size: 2.5 MiB |
Before Width: | Height: | Size: 34 KiB |
@ -1,123 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\controleur;
|
||||
use App\config\Validation;
|
||||
use App\gateway\ImageManager;
|
||||
use App\modele\MembreModele;
|
||||
|
||||
class MembreControleur extends UtilisateurControleur
|
||||
{
|
||||
public function __construct()
|
||||
{}
|
||||
|
||||
public function deconnexion()
|
||||
{
|
||||
global $twig;
|
||||
session_unset();
|
||||
session_destroy();
|
||||
|
||||
header("Location: /SAE_2A_FA-Reseau_ALICA/php/");
|
||||
exit();
|
||||
}
|
||||
public function createOfferForm()
|
||||
{
|
||||
global $twig;
|
||||
echo $twig->render("CreateOffer.html", []);
|
||||
}
|
||||
|
||||
public function createOffer()
|
||||
protected function deconnexion()
|
||||
{
|
||||
global $twig;
|
||||
$taberror = [];
|
||||
|
||||
$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("CreateOffer.html", ['tabError' => $taberror ]);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!Validation::verifierEmail($_POST["mail"]))
|
||||
{
|
||||
$taberror[] = "Email non valide !";
|
||||
}
|
||||
|
||||
if(!Validation::validateNumber($_POST["num"]))
|
||||
{
|
||||
$taberror[] = "Numero non valide !";
|
||||
}
|
||||
|
||||
if (!Validation::validateImage("image"))
|
||||
{
|
||||
$taberror[] = "Image non valide !";
|
||||
|
||||
}
|
||||
if(!Validation::validateImage("logo")) {
|
||||
$taberror[] = "Logo non valide !";
|
||||
}
|
||||
|
||||
if(count($taberror) > 0)
|
||||
{
|
||||
echo $twig->render("CreateOffer.html", ['tabError' => $taberror ]);
|
||||
|
||||
}
|
||||
else{
|
||||
$saveImg1 = ImageManager::SaveImage("image");
|
||||
$saveImg2 = ImageManager::SaveImage("logo");
|
||||
if($saveImg1[0] != NULL && $saveImg2[0] != NULL)
|
||||
{
|
||||
$mbrModel = new MembreModele();
|
||||
|
||||
$offre = $mbrModel->publishOffer($saveImg1[1], $saveImg2[1]);
|
||||
|
||||
echo $twig->render("OffreDetail.html", ['offre' => $offre]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$taberror[] = "Erreur lors de l'upload des images";
|
||||
echo $twig->render("CreateOffer.html", ['tabError' => $taberror ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function deleteOffer(?array $params)
|
||||
{
|
||||
global $twig;
|
||||
$id = $params['id2'];
|
||||
|
||||
$MemberModel = new MembreModele();
|
||||
$offre = $MemberModel->getOfferFromId($id);
|
||||
if($offre != NULL)
|
||||
{
|
||||
$MemberModel->deleteOffer($offre);
|
||||
|
||||
}
|
||||
$this->consultOffers(NULL);
|
||||
|
||||
session_destroy();
|
||||
echo "on est passes ici";
|
||||
header('Location: index.php?action=accueil');
|
||||
exit();
|
||||
}
|
||||
|
||||
public function proposerOffre()
|
||||
protected function proposerOffre()
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
public function consulterProfil()
|
||||
|
||||
protected function consulterProfil()
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
public function modifierProfil()
|
||||
|
||||
protected function modifierProfil()
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
public function signaler()
|
||||
|
||||
protected function signaler()
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
@ -0,0 +1,74 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -1,62 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\gateway;
|
||||
class ImageManager
|
||||
{
|
||||
|
||||
/**
|
||||
* @return int id aléatoire
|
||||
* @description générer un id aléatoire
|
||||
*/
|
||||
public static function getId() : int
|
||||
{
|
||||
return rand(10000,19999);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description sauvegarder une image
|
||||
* @param string $filename
|
||||
* @return array [bool,string] tableau de retour avec le booléen et le nom de l'image
|
||||
*/
|
||||
public static function SaveImage(string $filename) : array
|
||||
{
|
||||
try {
|
||||
$return=[];
|
||||
|
||||
$name = $_FILES[$filename]["name"];
|
||||
$path = "public/uploads/".$name;
|
||||
while(file_exists($path))
|
||||
{
|
||||
$name = substr($_FILES[$filename]["name"], 0, 45);
|
||||
$name = self::getId().$name;
|
||||
$path = "public/uploads/".$name;
|
||||
}
|
||||
|
||||
|
||||
move_uploaded_file($_FILES[$filename]['tmp_name'], "public/uploads/$name");
|
||||
$return[]=true;
|
||||
$return[]=$name;
|
||||
return $return;
|
||||
} catch (\Exception $e) {
|
||||
$return[] = false;
|
||||
$return[] = "";
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $img
|
||||
* @return bool true si l'image a été supprimée, false sinon
|
||||
* @description supprimer une image
|
||||
*/
|
||||
public static function deleteImg(string $img) : bool
|
||||
{
|
||||
$path = "public/uploads/$img";
|
||||
if (file_exists($path)) {
|
||||
unlink($path);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\gateway;
|
||||
class ImageSaver
|
||||
{
|
||||
|
||||
public static function getId() : int
|
||||
{
|
||||
return rand(10000,19999);
|
||||
}
|
||||
|
||||
public static function SaveImage(string $filename) : array
|
||||
{
|
||||
try {
|
||||
$return=[];
|
||||
|
||||
$name = substr($_FILES[$filename]["name"], 0, 45);
|
||||
$name = self::getId().$name;
|
||||
|
||||
move_uploaded_file($_FILES[$filename]['tmp_name'], "public/uploads/$name");
|
||||
$return[]=true;
|
||||
$return[]=$name;
|
||||
return $return;
|
||||
} catch (\Exception $e) {
|
||||
$return[] = false;
|
||||
$return[] = "";
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
}
|
@ -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="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>
|
||||
|
||||
|