creer offre fonctionnel avec gestion image (manque verif mail, site web & numero

offres2
Baptiste D 1 year ago
parent b27f5f5e98
commit 3e12d5be53

@ -1,7 +1,8 @@
{ {
"require": { "require": {
"twig/twig": "^3.0", "twig/twig": "^3.0",
"ext-pdo": "*" "ext-pdo": "*",
"ext-fileinfo": "*"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

@ -1,32 +0,0 @@
// change la possibilité d'entrer une ville pour l'offre
// cas où l'offre est à pourvoir en full remote
document.getElementById("fullRemote").addEventListener("change", function () {
var villeInput = document.getElementById("ville");
villeInput.disabled = this.checked;
//var ville = document.getElementById('')
});
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("form");
const submitButton = document.querySelector('input[type="submit"]');
// Fonction pour vérifier si tous les champs du formulaire sont remplis
function checkFormFields() {
const inputs = form.querySelectorAll('input, textarea, select');
let allFieldsFilled = true;
inputs.forEach(function(input) {
if (!input.value) {
allFieldsFilled = false;
}
});
submitButton.disabled = !allFieldsFilled;
}
// Écoute les événements de saisie dans les champs du formulaire
form.addEventListener("input", checkFormFields);
// Appelle la fonction initiale pour la première vérification
checkFormFields();
});

@ -9,6 +9,7 @@ use App\metier\Image;
use App\modele\OffreModele; use App\modele\OffreModele;
use App\modele\ImageModele; use App\modele\ImageModele;
use App\TwigExtensions; use App\TwigExtensions;
use finfo;
class UtilisateurControleur class UtilisateurControleur
{ {
@ -128,16 +129,30 @@ class UtilisateurControleur
} }
} }
if (isset($_FILES['image'])) { if (isset($_FILES['image'])) {
$typesMime = array('image/jpeg', 'image/png', 'image/gif', 'image/bmp');
$file = $_FILES['image']['tmp_name'];
$mime = mime_content_type($file);
if (in_array($mime, $typesMime)) {
$imgMdl = new ImageModele; $imgMdl = new ImageModele;
$offerMdl = new OffreModele();
$img = $imgMdl->publierImage(); $img = $imgMdl->publierImage();
$offerMdl = new OffreModele();
$offer = $offerMdl->publishOffers($img); $offer = $offerMdl->publishOffers($img);
$id = $offer->getImgId(); $id = $offer->getImgId();
// TO DO Afficher vue succès
//echo $twig->render("index.php?action=displayOffer&id=${id}",[]); //echo $twig->render("index.php?action=displayOffer&id=${id}",[]);
return; return;
} }
//$twig->render("CreerOffre.html", ['errMsg' => 'Inserez une image !']); else
echo $twig->render("CreerOffre.html",['errMsg' => "message erreur test"]); {
$imgName = $_FILES['image']['name'];
echo $twig->render("CreerOffre.html", ['errMsg' => "Image {$imgName} non valide !" ]);
return;
}
}
echo $twig->render("CreerOffre.html",[]);
} }
protected function testAction() protected function testAction()

@ -17,23 +17,25 @@
<form style="background-color: #00DBFF" class="p-4" enctype="multipart/form-data" action="index.php?action=creerOffre" method="post"> <form style="background-color: #00DBFF" class="p-4" enctype="multipart/form-data" action="index.php?action=creerOffre" method="post">
{% if errMsg is defined %}
<p> {{errMsg}}</p> <p> {{errMsg}}</p>
{% endif %}
<p>Les champs contenant des astrérisques * sont obligatoires.</p> <p>Les champs contenant des astrérisques * sont obligatoires.</p>
<div class="form-group"> <div class="form-group">
<label for="name">Intitulé de l'offre*</label> <label for="name">Intitulé de l'offre*</label>
<input type="text" class="form-control" id="name" name="name" placeholder="Intitulé" required> <input type="text" class="form-control" id="name" name="name" placeholder="Intitulé" maxlength="128" required>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="entreprise">Nom de l'entreprise :*</label> <label for="entreprise">Nom de l'entreprise :*</label>
<input type="text" class="form-control" id="entreprise" name="entreprise" placeholder="Entreprise" required> <input type="text" class="form-control" id="entreprise" name="entreprise" placeholder="Entreprise" maxlength="64" required>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="description">Description*</label> <label for="description">Amorce :*</label>
<textarea class="form-control" id="description" name="description" placeholder="Description rapide" required></textarea> <textarea class="form-control" id="description" name="description" placeholder="Description rapide" maxlength="200" required></textarea>
</div> </div>
<div class="form-check"> <div class="form-check">
@ -58,12 +60,12 @@
<div class="form-group"> <div class="form-group">
<label for="descriptPoste">Descriptif du Poste :*</label> <label for="descriptPoste">Descriptif du Poste :*</label>
<textarea class="form-control" id="descriptPoste" name="descriptPoste" placeholder="Description du Poste" required></textarea> <textarea class="form-control" id="descriptPoste" name="descriptPoste" placeholder="Description du Poste" required maxlength="2028"></textarea>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="profilRecherche">Profil Recherché :*</label> <label for="profilRecherche">Profil Recherché :*</label>
<textarea class="form-control" id="profilRecherche" name="profilRecherche" placeholder="Profil recherché" required></textarea> <textarea class="form-control" id="profilRecherche" name="profilRecherche" placeholder="Profil recherché" required maxlength="2028"></textarea>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -98,17 +100,17 @@
<div class="form-group"> <div class="form-group">
<label for="mail">Email de contact :*</label> <label for="mail">Email de contact :*</label>
<input type="text" class="form-control" id="mail" name="mail" placeholder="Adresse de contact" required> <input type="text" class="form-control" id="mail" name="mail" placeholder="Adresse de contact" maxlength="30" required>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="num">Numero de contact :*</label> <label for="num">Numero de contact :*</label>
<input type="text" class="form-control" id="num" name="num" placeholder="Numéro de contact" required> <input type="text" class="form-control" id="num" name="num" placeholder="Numéro de contact" required maxlength="10">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="site">Site web de l'annonce ou entreprise :</label> <label for="site">Site web de l'annonce ou entreprise :</label>
<input type="text" class="form-control" id="site" name="site" placeholder="Adresse web" required> <input type="text" class="form-control" id="site" name="site" placeholder="Adresse web" maxlength="40" required>
</div> </div>
<input type="file" name="image" id="image" required> <input type="file" name="image" id="image" required>
@ -121,8 +123,7 @@
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script> <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://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> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script src="../scripts/creerOffre.js"></script>
</body> </body>
</html> </html>

Loading…
Cancel
Save