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
- [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)
- [ ] Commentaires et section du code
- [x] Commentaires et section du code
# Améliorations possibles du formulaire canap.epfl.ch
......
......@@ -34,7 +34,7 @@
}
// kill session
$_SESSION['formError'] = false;
// unset($_SESSION);
// TODO: ENABLE THIS AFTER DEV unset($_SESSION);
include("templates/confirmationText.php");
} else {
$_SESSION['formError'] = true;
......
<?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 --
......@@ -43,7 +43,7 @@
"neSaisPas" => "Pas de filière préférée"
];
// default: \\\\scxdata\\apprentis$\\candidatures\\
// default (production): \\\\scxdata\\apprentis$\\candidatures\\
$FILESERVERPATH = 'D:/formdata/';
// Mettre a false pour pas spammer pendant le dev
......
......@@ -52,10 +52,6 @@ function uploadAllFiles($pathAnnexes, $postedFiles, $candidateData){
return $candidateData;
}
function deleteApplicantFiles ($files) {
}
#endregion
#region [DB Interactions]
......@@ -138,8 +134,8 @@ function insertResponsibles ($pdo, $representants, $applicantId) {
}
// link responsibles
$main_rep_id = $addedRepIds[0] ? $addedRepIds[0] : null;
$sec_rep_id = $addedRepIds[1] ? $addedRepIds[1] : null;
$main_rep_id = isset($addedRepIds[0]) ? $addedRepIds[0] : 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";
$query = $pdo->prepare($sqlreq);
......@@ -302,7 +298,7 @@ function deletePostulation ($pdo, $id, $sciper, $rep1, $rep2) {
$sqlreq = "UPDATE applicant
SET
applicant_formation='',
applicant_formation=null,
applicant_it_section=null,
applicant_formation_location=null,
applicant_maturity=null,
......
......@@ -2,21 +2,10 @@
require_once(__DIR__ . '/../helpers.php');
class PersonnalData {
#region [attributes]
private $postedData;
private $formations = array(
"laborantinBiologie" => "laborantinsBiologie",
"laborantinChimie" => "laborantinsChimie",
"laborantinPhysique" => "laborantinsPhysique",
"polyMecanicien" => "Polymecaniciens",
"informaticien" => "Informaticiens",
"logisticien" => "Logisticiens",
"planificateurElectricien" => "PlanificateurElectriciens",
"employeCommerce" => "EmployesCommerce",
"gardienAnimaux" => "GardiensAnimaux",
"electronicien" => "Electroniciens",
"interactiveMediaDesigner" => "InteractiveMediaDesigners"
);
private $dateNow;
private $formations = ["laborantinBiologie", "laborantinChimie", "laborantinPhysique", "polyMecanicien", "informaticien", "logisticien",
"planificateurElectricien", "employeCommerce", "gardienAnimaux", "electronicien", "interactiveMediaDesigner"];
public $rootpath = '';
public $guest_sciper = "";
public $formation = "";
......@@ -45,12 +34,12 @@ class PersonnalData {
public $stages = [];
public $dejaCandidat = 0;
public $anneeCandidature = "";
public $datePostulation = "";
public $fichiers = [];
#endregion
#region [contructor]
public function __construct($postedData, $postedFiles, $FILESERVERPATH) {
$this->rootpath = $FILESERVERPATH;
$this->dateNow = date('Y-m-d_H-i-s');
// Rempli les infos
$this->postedData = $postedData;
$this->guest_sciper = $postedData['guestSciper'];
......@@ -75,7 +64,7 @@ class PersonnalData {
$this->langueMaternelleApprenti = $postedData['langApp'];
$this->setLanguages($postedData['languesApp']);
$this->majeur = $postedData['maj'] == "true" ? 1 : 0;
if($this->majeur == "false"){
if($this->majeur){
$this->setRepresentants();
}
$this->setScolarite();
......@@ -83,11 +72,12 @@ class PersonnalData {
$this->setStages();
$this->setDejacand();
$this->anneeFinScolarite = $postedData['anneeFin'];
$this->datePostulation = date('j-n-o--'.'h:i:s');
$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']);
$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 {
array_push($this->representants, $rep2);
}
}
private function setScolarite(){
private function setScolarite () {
for ($i = 1; $i <= 5; $i++) {
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]));
}
}
}
private function setActivitesPro(){
private function setActivitesPro () {
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]));
}
}
}
private function setStages(){
private function setStages () {
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]));
}
}
......@@ -132,7 +122,6 @@ class PersonnalData {
$this->connaissancesLinguistiques = [];
}
}
private function setFiles ($postedFiles) {
// Clear empty files
foreach ($postedFiles as $key => $file) {
......@@ -142,17 +131,12 @@ class PersonnalData {
}
return $postedFiles;
}
#endregion
public function getPaths () {
$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];
}
#region [getters]
public function getFormations () {
return $this->formations;
}
#endregion
}
?>
\ No newline at end of file
......@@ -3,14 +3,19 @@ require_once('PersonnalData.php');
require_once(__DIR__ . '/../helpers.php');
class PersonnalDataValidator {
#region [attributes]
private $personnalData;
private $errors = array();
#endregion
#region [contructor]
public function __construct(PersonnalData $personnalData){
$this->personnalData = $personnalData;
}
#endregion
public function errors(){
#region [validation methods]
public function errors () {
return $this->errors;
}
......@@ -79,17 +84,9 @@ class PersonnalDataValidator {
}
private function representantValid () {
if($this->personnalData->majeur == 'false'){
//non majeur
if(count($this->personnalData->representants) < 1){
if ($this->personnalData->majeur) {
if (count($this->personnalData->representants) < 1) {
$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 {
$this->errors['adresseMail'] = "Adresse mail non valide";
}
}
private function isFormationValid(){
if (!array_key_exists($this->personnalData->formation, $this->personnalData->getFormations())) {
private function isFormationValid () {
if (!in_array($this->personnalData->formation, $this->personnalData->getFormations())) {
$this->errors['formation'] = 'Formation non valide';
}
}
private function isEcoleValid(){
if(count($this->personnalData->scolarite) < 2){
private function isEcoleValid () {
if (count($this->personnalData->scolarite) < 2) {
$this->errors['ecole'] = 'Informations école non valides';
}
}
private function anneeFinScolariteValid(){
$dateToCheck = $this->personnalData->anneeFinScolarite;
if(!is_null($dateToCheck) || $dateToCheck==""){
if(!is_null($dateToCheck) || $dateToCheck == ""){
if(!is_numeric($dateToCheck)){
$this->errors['anneeFinScolarite'] = 'Année de fin de scolarité non valide';
}
......@@ -149,5 +146,6 @@ class PersonnalDataValidator {
}
}
}
#endregion
}
?>
\ No newline at end of file
......@@ -18,15 +18,14 @@
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-130041798-1', { 'anonymize_ip': true });
</script>
<?php
ini_set("display_errors", 0);
error_reporting(0);
// ini_set("display_errors", 0);
// error_reporting(0);
// ini_set("display_errors", 1);
// error_reporting(E_ALL);
require_once('configs/config.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