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

refactor

parent 05131d07
No related branches found
No related tags found
No related merge requests found
# Améliorations en cours # Améliorations en cours
- [x] Utiliser la nouvelle charte 2018 - [x] Utiliser la nouvelle charte 2018
- [ ] Adapter pour ajouter les postulations dans une DB - [x] Adapter pour ajouter les postulations dans une DB
- [x] Ajouter une page pour voir / supprimer sa / ses postulation(s) - [x] Ajouter une page pour voir / supprimer sa / ses postulation(s)
- [ ] Commentaires et section du code - [x] Commentaires et section du code
# Améliorations possibles du formulaire canap.epfl.ch # Améliorations possibles du formulaire canap.epfl.ch
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
} }
// kill session // kill session
$_SESSION['formError'] = false; $_SESSION['formError'] = false;
// unset($_SESSION); // TODO: ENABLE THIS AFTER DEV unset($_SESSION);
include("templates/confirmationText.php"); include("templates/confirmationText.php");
} else { } else {
$_SESSION['formError'] = true; $_SESSION['formError'] = true;
......
<?php <?php
if(count(get_included_files()) == 1) exit("Direct access not permitted."); if (count(get_included_files()) == 1) exit("Direct access not permitted.");
/* /*
-- DO NOT DELETE -- -- DO NOT DELETE --
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
"neSaisPas" => "Pas de filière préférée" "neSaisPas" => "Pas de filière préférée"
]; ];
// default: \\\\scxdata\\apprentis$\\candidatures\\ // default (production): \\\\scxdata\\apprentis$\\candidatures\\
$FILESERVERPATH = 'D:/formdata/'; $FILESERVERPATH = 'D:/formdata/';
// Mettre a false pour pas spammer pendant le dev // Mettre a false pour pas spammer pendant le dev
......
...@@ -52,10 +52,6 @@ function uploadAllFiles($pathAnnexes, $postedFiles, $candidateData){ ...@@ -52,10 +52,6 @@ function uploadAllFiles($pathAnnexes, $postedFiles, $candidateData){
return $candidateData; return $candidateData;
} }
function deleteApplicantFiles ($files) {
}
#endregion #endregion
#region [DB Interactions] #region [DB Interactions]
...@@ -138,8 +134,8 @@ function insertResponsibles ($pdo, $representants, $applicantId) { ...@@ -138,8 +134,8 @@ function insertResponsibles ($pdo, $representants, $applicantId) {
} }
// link responsibles // link responsibles
$main_rep_id = $addedRepIds[0] ? $addedRepIds[0] : null; $main_rep_id = isset($addedRepIds[0]) ? $addedRepIds[0] : null;
$sec_rep_id = $addedRepIds[1] ? $addedRepIds[1] : null; $sec_rep_id = isset($addedRepIds[1]) ? $addedRepIds[1] : null;
$sqlreq = "UPDATE applicant SET fk_applicant_main_responsible=:fk_applicant_main_responsible, fk_applicant_sec_responsible=:fk_applicant_sec_responsible WHERE applicant_id=:applicant_id"; $sqlreq = "UPDATE applicant SET fk_applicant_main_responsible=:fk_applicant_main_responsible, fk_applicant_sec_responsible=:fk_applicant_sec_responsible WHERE applicant_id=:applicant_id";
$query = $pdo->prepare($sqlreq); $query = $pdo->prepare($sqlreq);
...@@ -302,7 +298,7 @@ function deletePostulation ($pdo, $id, $sciper, $rep1, $rep2) { ...@@ -302,7 +298,7 @@ function deletePostulation ($pdo, $id, $sciper, $rep1, $rep2) {
$sqlreq = "UPDATE applicant $sqlreq = "UPDATE applicant
SET SET
applicant_formation='', applicant_formation=null,
applicant_it_section=null, applicant_it_section=null,
applicant_formation_location=null, applicant_formation_location=null,
applicant_maturity=null, applicant_maturity=null,
......
...@@ -2,21 +2,10 @@ ...@@ -2,21 +2,10 @@
require_once(__DIR__ . '/../helpers.php'); require_once(__DIR__ . '/../helpers.php');
class PersonnalData { class PersonnalData {
#region [attributes]
private $postedData; private $postedData;
private $formations = array( private $formations = ["laborantinBiologie", "laborantinChimie", "laborantinPhysique", "polyMecanicien", "informaticien", "logisticien",
"laborantinBiologie" => "laborantinsBiologie", "planificateurElectricien", "employeCommerce", "gardienAnimaux", "electronicien", "interactiveMediaDesigner"];
"laborantinChimie" => "laborantinsChimie",
"laborantinPhysique" => "laborantinsPhysique",
"polyMecanicien" => "Polymecaniciens",
"informaticien" => "Informaticiens",
"logisticien" => "Logisticiens",
"planificateurElectricien" => "PlanificateurElectriciens",
"employeCommerce" => "EmployesCommerce",
"gardienAnimaux" => "GardiensAnimaux",
"electronicien" => "Electroniciens",
"interactiveMediaDesigner" => "InteractiveMediaDesigners"
);
private $dateNow;
public $rootpath = ''; public $rootpath = '';
public $guest_sciper = ""; public $guest_sciper = "";
public $formation = ""; public $formation = "";
...@@ -45,12 +34,12 @@ class PersonnalData { ...@@ -45,12 +34,12 @@ class PersonnalData {
public $stages = []; public $stages = [];
public $dejaCandidat = 0; public $dejaCandidat = 0;
public $anneeCandidature = ""; public $anneeCandidature = "";
public $datePostulation = "";
public $fichiers = []; public $fichiers = [];
#endregion
#region [contructor]
public function __construct($postedData, $postedFiles, $FILESERVERPATH) { public function __construct($postedData, $postedFiles, $FILESERVERPATH) {
$this->rootpath = $FILESERVERPATH; $this->rootpath = $FILESERVERPATH;
$this->dateNow = date('Y-m-d_H-i-s');
// Rempli les infos // Rempli les infos
$this->postedData = $postedData; $this->postedData = $postedData;
$this->guest_sciper = $postedData['guestSciper']; $this->guest_sciper = $postedData['guestSciper'];
...@@ -75,7 +64,7 @@ class PersonnalData { ...@@ -75,7 +64,7 @@ class PersonnalData {
$this->langueMaternelleApprenti = $postedData['langApp']; $this->langueMaternelleApprenti = $postedData['langApp'];
$this->setLanguages($postedData['languesApp']); $this->setLanguages($postedData['languesApp']);
$this->majeur = $postedData['maj'] == "true" ? 1 : 0; $this->majeur = $postedData['maj'] == "true" ? 1 : 0;
if($this->majeur == "false"){ if($this->majeur){
$this->setRepresentants(); $this->setRepresentants();
} }
$this->setScolarite(); $this->setScolarite();
...@@ -83,11 +72,12 @@ class PersonnalData { ...@@ -83,11 +72,12 @@ class PersonnalData {
$this->setStages(); $this->setStages();
$this->setDejacand(); $this->setDejacand();
$this->anneeFinScolarite = $postedData['anneeFin']; $this->anneeFinScolarite = $postedData['anneeFin'];
$this->datePostulation = date('j-n-o--'.'h:i:s');
$this->fichiers = $this->setFiles($postedFiles); $this->fichiers = $this->setFiles($postedFiles);
} }
#endregion
private function setRepresentants(){ #region [setters]
private function setRepresentants () {
$rep1 = array("genre"=>$this->postedData['genreRep1'],"nom"=>$this->postedData['nameRep1'],"prenom"=>$this->postedData['surnameRep1'],"addresse"=> array("rue"=>$this->postedData['adrRep1'],"NPA"=>$this->postedData['NPARep1']),"telephone"=>$this->postedData['telRep1']); $rep1 = array("genre"=>$this->postedData['genreRep1'],"nom"=>$this->postedData['nameRep1'],"prenom"=>$this->postedData['surnameRep1'],"addresse"=> array("rue"=>$this->postedData['adrRep1'],"NPA"=>$this->postedData['NPARep1']),"telephone"=>$this->postedData['telRep1']);
$rep2 = array("genre"=>$this->postedData['genreRep2'],"nom"=>$this->postedData['nameRep2'],"prenom"=>$this->postedData['surnameRep2'],"addresse"=> array("rue"=>$this->postedData['adrRep2'],"NPA"=>$this->postedData['NPARep2']),"telephone"=>$this->postedData['telRep2']); $rep2 = array("genre"=>$this->postedData['genreRep2'],"nom"=>$this->postedData['nameRep2'],"prenom"=>$this->postedData['surnameRep2'],"addresse"=> array("rue"=>$this->postedData['adrRep2'],"NPA"=>$this->postedData['NPARep2']),"telephone"=>$this->postedData['telRep2']);
...@@ -98,23 +88,23 @@ class PersonnalData { ...@@ -98,23 +88,23 @@ class PersonnalData {
array_push($this->representants, $rep2); array_push($this->representants, $rep2);
} }
} }
private function setScolarite(){ private function setScolarite () {
for ($i = 1; $i <= 5; $i++) { for ($i = 1; $i <= 5; $i++) {
if (array_key_exists('ecole'.$i, $this->postedData)) { if (array_key_exists('ecole'.$i, $this->postedData)) {
array_push($this->scolarite, array("ecole"=>$this->postedData['ecole'.$i],"lieu"=>$this->postedData['lieuEcole'.$i],"niveau"=>$this->postedData['niveauEcole'.$i],"annees"=>$this->postedData['anneesEcole'.$i])); array_push($this->scolarite, array("ecole"=>$this->postedData['ecole'.$i],"lieu"=>$this->postedData['lieuEcole'.$i],"niveau"=>$this->postedData['niveauEcole'.$i],"annees"=>$this->postedData['anneesEcole'.$i]));
} }
} }
} }
private function setActivitesPro(){ private function setActivitesPro () {
for ($i = 1; $i <= 3; $i++) { for ($i = 1; $i <= 3; $i++) {
if(array_key_exists('employeurPro'.$i, $this->postedData)){ if (array_key_exists('employeurPro'.$i, $this->postedData)) {
array_push($this->activitesProfessionnelles,array("employeur"=>$this->postedData['employeurPro'.$i],"lieu"=>$this->postedData['lieuPro'.$i],"activite"=>$this->postedData['activitePro'.$i],"annees"=>$this->postedData['anneesPro'.$i])); array_push($this->activitesProfessionnelles,array("employeur"=>$this->postedData['employeurPro'.$i],"lieu"=>$this->postedData['lieuPro'.$i],"activite"=>$this->postedData['activitePro'.$i],"annees"=>$this->postedData['anneesPro'.$i]));
} }
} }
} }
private function setStages(){ private function setStages () {
for ($i = 1; $i <= 4; $i++) { for ($i = 1; $i <= 4; $i++) {
if(array_key_exists('activiteStage'.$i, $this->postedData)){ if (array_key_exists('activiteStage'.$i, $this->postedData)) {
array_push($this->stages,array("metier"=>$this->postedData['activiteStage'.$i],"employeur"=>$this->postedData['entrepriseStage'.$i])); array_push($this->stages,array("metier"=>$this->postedData['activiteStage'.$i],"employeur"=>$this->postedData['entrepriseStage'.$i]));
} }
} }
...@@ -132,7 +122,6 @@ class PersonnalData { ...@@ -132,7 +122,6 @@ class PersonnalData {
$this->connaissancesLinguistiques = []; $this->connaissancesLinguistiques = [];
} }
} }
private function setFiles ($postedFiles) { private function setFiles ($postedFiles) {
// Clear empty files // Clear empty files
foreach ($postedFiles as $key => $file) { foreach ($postedFiles as $key => $file) {
...@@ -142,17 +131,12 @@ class PersonnalData { ...@@ -142,17 +131,12 @@ class PersonnalData {
} }
return $postedFiles; return $postedFiles;
} }
#endregion
public function getPaths () { #region [getters]
$folderName = $this->dateNow."_".$this->mailApprenti;
$path = $this->rootpath.$this->formations[$this->formation].'/'.$folderName.'/';
$pathInfos = $path."informations/";
$pathAnnexes = $path."annexes/";
return ["pathInfos"=>$pathInfos, "pathAnnexes"=>$pathAnnexes, "path"=> $path];
}
public function getFormations () { public function getFormations () {
return $this->formations; return $this->formations;
} }
#endregion
} }
?> ?>
\ No newline at end of file
...@@ -3,14 +3,19 @@ require_once('PersonnalData.php'); ...@@ -3,14 +3,19 @@ require_once('PersonnalData.php');
require_once(__DIR__ . '/../helpers.php'); require_once(__DIR__ . '/../helpers.php');
class PersonnalDataValidator { class PersonnalDataValidator {
#region [attributes]
private $personnalData; private $personnalData;
private $errors = array(); private $errors = array();
#endregion
#region [contructor]
public function __construct(PersonnalData $personnalData){ public function __construct(PersonnalData $personnalData){
$this->personnalData = $personnalData; $this->personnalData = $personnalData;
} }
#endregion
public function errors(){ #region [validation methods]
public function errors () {
return $this->errors; return $this->errors;
} }
...@@ -79,17 +84,9 @@ class PersonnalDataValidator { ...@@ -79,17 +84,9 @@ class PersonnalDataValidator {
} }
private function representantValid () { private function representantValid () {
if($this->personnalData->majeur == 'false'){ if ($this->personnalData->majeur) {
//non majeur if (count($this->personnalData->representants) < 1) {
if(count($this->personnalData->representants) < 1){
$this->errors['representants'] = 'Représentants non valides'; $this->errors['representants'] = 'Représentants non valides';
} else {
// Check les valeurs rentrée par representants
}
} else {
//majeur
if(count($this->personnalData->representants) != 0){
$this->errors['representants'] = 'Trop de représentants';
} }
} }
} }
...@@ -107,20 +104,20 @@ class PersonnalDataValidator { ...@@ -107,20 +104,20 @@ class PersonnalDataValidator {
$this->errors['adresseMail'] = "Adresse mail non valide"; $this->errors['adresseMail'] = "Adresse mail non valide";
} }
} }
private function isFormationValid(){ private function isFormationValid () {
if (!array_key_exists($this->personnalData->formation, $this->personnalData->getFormations())) { if (!in_array($this->personnalData->formation, $this->personnalData->getFormations())) {
$this->errors['formation'] = 'Formation non valide'; $this->errors['formation'] = 'Formation non valide';
} }
} }
private function isEcoleValid(){ private function isEcoleValid () {
if(count($this->personnalData->scolarite) < 2){ if (count($this->personnalData->scolarite) < 2) {
$this->errors['ecole'] = 'Informations école non valides'; $this->errors['ecole'] = 'Informations école non valides';
} }
} }
private function anneeFinScolariteValid(){ private function anneeFinScolariteValid(){
$dateToCheck = $this->personnalData->anneeFinScolarite; $dateToCheck = $this->personnalData->anneeFinScolarite;
if(!is_null($dateToCheck) || $dateToCheck==""){ if(!is_null($dateToCheck) || $dateToCheck == ""){
if(!is_numeric($dateToCheck)){ if(!is_numeric($dateToCheck)){
$this->errors['anneeFinScolarite'] = 'Année de fin de scolarité non valide'; $this->errors['anneeFinScolarite'] = 'Année de fin de scolarité non valide';
} }
...@@ -149,5 +146,6 @@ class PersonnalDataValidator { ...@@ -149,5 +146,6 @@ class PersonnalDataValidator {
} }
} }
} }
#endregion
} }
?> ?>
\ No newline at end of file
...@@ -18,15 +18,14 @@ ...@@ -18,15 +18,14 @@
window.dataLayer = window.dataLayer || []; window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);} function gtag(){dataLayer.push(arguments);}
gtag('js', new Date()); gtag('js', new Date());
gtag('config', 'UA-130041798-1', { 'anonymize_ip': true }); gtag('config', 'UA-130041798-1', { 'anonymize_ip': true });
</script> </script>
<?php <?php
ini_set("display_errors", 0); // ini_set("display_errors", 0);
error_reporting(0); // error_reporting(0);
// ini_set("display_errors", 1); // ini_set("display_errors", 1);
// error_reporting(E_ALL); // error_reporting(E_ALL);
require_once('configs/config.php'); require_once('configs/config.php');
require('configs/db.php'); require('configs/db.php');
session_start(); if (!isset($_SESSION)) { session_start(); }
?> ?>
\ No newline at end of file
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