Newer
Older
<?php
include("templates/head.php");
include('templates/isPostulationOpen.php');
require_once("helpers.php");
require_once("models/PersonnalData.php");
require_once("models/PersonnalDataValidator.php");
?>
<title>Postulation Apprentis | Confirmation</title>
<?php
include('templates/header.php');
// Init personnalData with postedData
$candidateData = new PersonnalData($_POST, $_FILES);
// Init dataValidator
$validator = new PersonnalDataValidator($candidateData);
if($validator->isValid()){
// Create folders
createCandidateFolders($candidateData);
// Upload files
$candidateData = uploadAllFiles($candidateData->getPaths()["pathAnnexes"], $candidateData->tmp_fichiers, $candidateData);
// Create JSON file and upload it
$encodedJson = (json_encode($candidateData,JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT));
file_put_contents($candidateData->getPaths()["pathInfos"].'/informations.json', $encodedJson);
// write in DB
insertDataIntoDB($pdo, $candidateData);
// mailToResp($candidateData->prenomApprenti, $candidateData->nomApprenti, $candidateData->formation);
// mailToApprenti($candidateData->mailApprenti, $candidateData->formation);
// $_SESSION['formError'] = false;
// unset($_SESSION);
// include("templates/confirmationText.php");
} else {
$_SESSION['formError'] = true;
$_SESSION['postedForm'] = $_POST;
$_SESSION['files'] = $_FILES;
include("templates/errorText.php");
}
?>