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": {
"twig/twig": "^3.0",
"ext-pdo": "*"
"ext-pdo": "*",
"ext-fileinfo": "*"
},
"autoload": {
"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\ImageModele;
use App\TwigExtensions;
use finfo;
class UtilisateurControleur
{
@ -128,16 +129,30 @@ class UtilisateurControleur
}
}
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;
$offerMdl = new OffreModele();
$img = $imgMdl->publierImage();
$offerMdl = new OffreModele();
$offer = $offerMdl->publishOffers($img);
$id = $offer->getImgId();
// TO DO Afficher vue succès
//echo $twig->render("index.php?action=displayOffer&id=${id}",[]);
return;
}
//$twig->render("CreerOffre.html", ['errMsg' => 'Inserez une image !']);
echo $twig->render("CreerOffre.html",['errMsg' => "message erreur test"]);
else
{
$imgName = $_FILES['image']['name'];
echo $twig->render("CreerOffre.html", ['errMsg' => "Image {$imgName} non valide !" ]);
return;
}
}
echo $twig->render("CreerOffre.html",[]);
}
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">
{% if errMsg is defined %}
<p> {{errMsg}}</p>
{% 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é" required>
<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" required>
<input type="text" class="form-control" id="entreprise" name="entreprise" placeholder="Entreprise" maxlength="64" required>
</div>
<div class="form-group">
<label for="description">Description*</label>
<textarea class="form-control" id="description" name="description" placeholder="Description rapide" required></textarea>
<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">
@ -58,12 +60,12 @@
<div class="form-group">
<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 class="form-group">
<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 class="form-group">
@ -98,17 +100,17 @@
<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" required>
<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>
<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" required>
<input type="text" class="form-control" id="site" name="site" placeholder="Adresse web" maxlength="40" required>
</div>
<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://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="../scripts/creerOffre.js"></script>
</body>
</html>

Loading…
Cancel
Save