<?php require_once(__DIR__ . '/../helpers.php'); class PersonnalData { #region [attributes] private $postedData; private $formations = ["laborantinBiologie", "laborantinChimie", "laborantinPhysique", "polyMecanicien", "informaticien", "logisticien", "planificateurElectricien", "employeCommerce", "gardienAnimaux", "electronicien", "interactiveMediaDesigner"]; public $rootpath = ''; public $guest_sciper = ""; public $formation = ""; public $lieu = ""; public $filiere = ""; public $maturite = 0; public $genreApprenti = ""; public $nomApprenti = ""; public $prenomApprenti = ""; public $addresseApprentiComplete = []; public $telFixeApprenti = ""; public $telMobileApprenti = ""; public $mailApprenti = ""; public $dateNaissanceApprenti = ""; public $origineApprenti = ""; public $nationaliteApprenti = ""; public $permisEtranger = ""; public $numeroAVS = ""; public $langueMaternelleApprenti = ""; public $connaissancesLinguistiques = ""; public $majeur = 0; public $representants = []; public $scolarite = []; public $anneeFinScolarite; public $activitesProfessionnelles = []; public $stages = []; public $dejaCandidat = 0; public $anneeCandidature = ""; public $fichiers = []; #endregion #region [contructor] public function __construct($postedData, $postedFiles, $FILESERVERPATH) { $this->rootpath = $FILESERVERPATH; // Rempli les infos $this->postedData = $postedData; $this->guest_sciper = $postedData['guestSciper']; $this->formation = $postedData['job']; $this->lieu = $postedData['lieu']; if($this->formation =="informaticien"){ $this->filiere = $postedData['filInfo']; } $this->maturite = $postedData['mpt'] == "true" ? 1 : 0; $this->genreApprenti = $postedData['genreApp']; $this->nomApprenti = $postedData['nameApp']; $this->prenomApprenti = $postedData['surnameApp']; $this->addresseApprentiComplete = array("rue"=>$postedData['adrApp'],"NPA"=>$postedData['NPAApp']); $this->telFixeApprenti = $postedData['telApp']; $this->telMobileApprenti = $postedData['phoneApp']; $this->mailApprenti = $postedData['mailApp']; $this->dateNaissanceApprenti = $postedData['birthApp']; $this->origineApprenti = $postedData['originApp']; $this->nationaliteApprenti = $postedData['nationApp']; $this->permisEtranger = $postedData['permisEtrangerApp']; $this->numeroAVS = $postedData['avsNumber']; $this->speaksFrench = $postedData['applicant_speaks_french']; $this->speaksGerman = $postedData['applicant_speaks_german']; $this->speaksEnglish = $postedData['applicant_speaks_english']; $this->speaksOther = $postedData['applicant_speaks_other']; $this->langueMaternelleApprenti = $postedData['langApp']; $this->majeur = $postedData['maj'] == "true" ? 1 : 0; if (!$this->majeur) { $this->setRepresentants(); } $this->setScolarite(); $this->setActivitesPro(); $this->setStages(); $this->setDejacand(); $this->anneeFinScolarite = $postedData['anneeFin']; $this->fichiers = $this->setFiles($postedFiles); } #endregion #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']); if ($rep1) { array_push($this->representants, $rep1); } if ($rep2) { array_push($this->representants, $rep2); } } 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 () { for ($i = 1; $i <= 3; $i++) { 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 () { for ($i = 1; $i <= 4; $i++) { if (array_key_exists('activiteStage'.$i, $this->postedData)) { array_push($this->stages,array("metier"=>$this->postedData['activiteStage'.$i],"employeur"=>$this->postedData['entrepriseStage'.$i])); } } } private function setDejacand () { $this->dejaCandidat = $this->postedData['dejaCand'] == "true"; if ($this->dejaCandidat) { $this->anneeCandidature = $this->postedData['dejaCandAnnee']; } } // public function setLanguages ($languages) { // if (isset($languages) && is_array($languages)) { // $this->connaissancesLinguistiques = $languages; // } else { // $this->connaissancesLinguistiques = []; // } // } private function setFiles ($postedFiles) { // Clear empty files foreach ($postedFiles as $key => $file) { if ($file['error'] != 0) { unset($postedFiles[$key]); } } return $postedFiles; } #endregion #region [getters] public function getFormations () { return $this->formations; } #endregion } ?>