Skip to content
Snippets Groups Projects
Commit dd2fde61 authored by nicrausaz's avatar nicrausaz
Browse files

form, fix show errors

parent a8fd9dfd
No related branches found
No related tags found
No related merge requests found
......@@ -16,13 +16,10 @@
include('templates/header.php');
//Init personnalData with postedData
$candidateData = new PersonnalData($_POST);
debuglog("personnalData initiallised");
//Init dataValidator
$validator = new PersonnalDataValidator($candidateData);
debuglog("PersonnalDataValitor initiallised");
if($validator->isValid()){
debuglog("validator->isValid");
//Create folders
createCandidateFolders($candidateData);
//Upload files
......@@ -31,7 +28,8 @@
$encodedJson = (json_encode($candidateData,JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT));
file_put_contents($candidateData->getPaths()["pathInfos"].'/informations.json', $encodedJson);
//Send mails
mailToResp($candidateData->prenomApprenti, $candidateData->nomApprenti, $candidateData->formation);
// mailToResp($candidateData->prenomApprenti, $candidateData->nomApprenti, $candidateData->formation);
mailToApprenti($candidateData->mailApprenti, $candidateData->formation);
// kill session
$_SESSION['formError'] = false;
......@@ -41,7 +39,6 @@
$_SESSION['formError'] = true;
$_SESSION['postedForm'] = $_POST;
$_SESSION['files'] = $_FILES;
debuglog("!validator->isValid");
include("templates/errorText.php");
}
?>
......
......@@ -4,7 +4,7 @@
// by default, labo can't apply by this formular, in case, add some of these these values in the array:
/*
-- PLEASE DO NOT DELETE --
-- DO NOT DELETE --
"laborantinBiologie" => "Laborantin-e CFC; option biologie",
"laborantinChimie" => "Laborantin-e CFC; option chimie",
......
......@@ -258,7 +258,7 @@
<div class="form-group mt-3">
<label for="anneeFin">Année de fin de scolarité*</label>
<input type="text" name="anneeFin" id="anneeFin" class="form-control" placeholder="Année de fin de scolarité" value="<?php echo $_SESSION['postedForm']['anneeFin'] != '' ? $_SESSION['postedForm']['anneeFin'] : ''; ?>" maxlength="4" data-required/>
<small id="anneeFinError" class="form-text text-muted"></small>
<small id="anneeFinError" class="error form-text text-muted"></small>
</div>
<h5>3.2 Activités professionnelles</h5>
<small>Formations / apprentissages après la scolarité.</small>
......@@ -337,7 +337,7 @@
<div class="form-group" id="dejaCandAnnee" style="display: none;">
<label for="dejaCandAnneeInput">Année de candidature *</label>
<input type="text" name="dejaCandAnnee" id="dejaCandAnneeInput" class="form-control" placeholder="Année de candidature" value="<?php echo $_SESSION['postedForm']['dejaCandAnnee'] != '' ? $_SESSION['postedForm']['dejaCandAnnee'] : ''; ?>" maxlength="4"/>
<small id="dejaCandError" class="form-text text-muted"></small>
<small id="dejaCandError" class="form-text text-muted error"></small>
</div>
<!-- / Activités pro -->
<hr>
......
......@@ -22,12 +22,11 @@ function uploadFile(&$candidateData, $pathAnnexes, $file, $name){
$extension = strtolower(strrchr($file['name'], '.'));
$validExt = ['.pdf', '.jpeg', '.png', '.jpg'];
$filename = $name . $extension;
//-> dataValidator
if(!in_array($extension, $validExt)){
$erreur = "uploadError";
}
if(!isset($erreur)){
$filename = checkChars($filename);
move_uploaded_file($file['tmp_name'], $pathAnnexes . $filename);
......@@ -68,8 +67,4 @@ function uploadAllFiles($pathAnnexes, $postedFiles, $candidateData){
}
return $candidateData;
}
function debuglog($message){
//echo $message;
}
?>
\ No newline at end of file
......@@ -17,7 +17,7 @@ class PersonnalData {
"interactiveMediaDesigner" => "InteractiveMediaDesigners"
);
private $dateNow;
private $rootpath = '\\\\scxdata\\apprentis$\\candidatures\\nouvelles\\';
private $rootpath = 'D:/Formdata/'; // \\\\scxdata\\apprentis$\\candidatures\\nouvelles\\
public $formation = "";
public $lieu = "";
public $filiere = "";
......
......@@ -15,7 +15,6 @@ class PersonnalDataValidator {
}
public function isValid(){
$this->filiereValid();
$this->dataRequiredIsValid();
$this->representantValid();
......@@ -57,8 +56,8 @@ class PersonnalDataValidator {
$this->isBirthDateValid(date($this->personnalData->dateNaissanceApprenti));
foreach ($toValid as $valid) {
$this->isRequired($valid);
foreach ($toValid as $key => $valid) {
$this->isRequired($key, $valid);
}
}
......@@ -73,9 +72,9 @@ class PersonnalDataValidator {
}
}
private function isRequired ($dataToCheck) {
if (is_null($dataToCheck) || $dataToCheck=="") {
$this->errors[$dataNameToCheck] = $dataNameToCheck . " manquant(e)";
private function isRequired ($key, $dataToCheck) {
if (is_null($dataToCheck) || $dataToCheck == "") {
$this->errors[$key] = $key . " manquant(e)";
}
}
......
<h1><?php echo $candidateData->prenomApprenti," ", $candidateData->nomApprenti,"," ?></h1>
<h4>Votre demande à bien été enregistrée, vous allez bientôt recevoir un e-mail confirmant votre postulation.</h4>
<footer>
<button type="button" id="retourHome" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent">
Retour à l'accueil
</button>
</footer>
\ No newline at end of file
<main id="main" role="main" class="content container-grid">
<p>Votre demande à bien été enregistrée, vous allez bientôt recevoir un e-mail confirmant votre postulation.</p>
<button type="button" class="btn btn-primary btn-sm mt-3 mb-2" id="retourHome">Retour à l'acceuil</button>
</main>
\ No newline at end of file
......@@ -8,6 +8,7 @@
<script src="./style/epfl2018/js/vendors.min.js"></script>
<script src="./style/epfl2018/js/vendors.bundle.js"></script>
<script src="./script.js"></script>
<style>.error { color: red!important; }</style>
<noscript>Veuillez Activer JavaScript pour utiliser le service de postulation</noscript>
<?php
ini_set("display_errors",0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment