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

fix files ok

parent 175c791f
No related branches found
No related tags found
No related merge requests found
......@@ -28,8 +28,11 @@
// create dir + move files in it
$filesPath = createFilesFolder($candidateData->rootpath, $candidateId);
// TODO: check if i can pass only candidateData
$candidateData = uploadAllFiles($filesPath, $candidateData->fichiers, $candidateData);
// print_r($candidateData->fichiers);
// insert files in DB
insertFiles($pdo, $candidateData->fichiers, $candidateId, $candidateData->rootpath);
......
......@@ -108,7 +108,9 @@
</div>
<!-- / Conditions -->
<button class="btn btn-primary btn-block" type="submit">Terminer</button>
<button class="btn btn-secondary btn-block" id="cancelEditBtn" type="button">Annuler</button>
<?php if (isset($_GET['edit'])) { ?>
<button class="btn btn-secondary btn-block" id="cancelEditBtn" type="button">Annuler</button>
<?php } ?>
</div>
<!-- / div all -->
</form>
......
......@@ -25,20 +25,20 @@ function uploadFile(&$candidateData, $pathAnnexes, $file, $key, $name){
$extension = strtolower(strrchr($file['name'], '.'));
$file['name'] = $name . $extension;
move_uploaded_file($file['tmp_name'], $pathAnnexes . $file['name']);
$candidateData->fichiers[$name] = $file['name'];
unset($candidateData->fichiers[$key]);
$candidateData->fichiers[$name]['name'] = $file['name'];
// unset($candidateData->fichiers[$key]);
}
function uploadAllFiles($pathAnnexes, $postedFiles, $candidateData){
uploadFile($candidateData, $pathAnnexes, $postedFiles['photo'], 'photo', "photo-passeport");
uploadFile($candidateData, $pathAnnexes, $postedFiles['idCard'], 'idCard', "carte-identite");
uploadFile($candidateData, $pathAnnexes, $postedFiles['cv'], 'cv', "curriculum-vitae");
uploadFile($candidateData, $pathAnnexes, $postedFiles['lettre'], 'lettre', "lettre-motivation");
function uploadAllFiles($pathAnnexes, $postedFiles, $candidateData) {
uploadFile($candidateData, $pathAnnexes, $postedFiles['photo-passeport'], 'photo-passeport', "photo-passeport");
uploadFile($candidateData, $pathAnnexes, $postedFiles['carte-identite'], 'carte-identite', "carte-identite");
uploadFile($candidateData, $pathAnnexes, $postedFiles['curriculum-vitae'], 'curriculum-vitae', "curriculum-vitae");
uploadFile($candidateData, $pathAnnexes, $postedFiles['lettre-motivation'], 'lettre-motivation', "lettre-motivation");
for ($i = 1; $i <= 9; $i++){
if (array_key_exists('certifs'.$i, $postedFiles)){
if (!($postedFiles['certifs'.$i]['name'] == "")) {
uploadFile($candidateData, $pathAnnexes, $postedFiles['certifs'.$i], 'certifs'.$i, "annexe".$i);
if (array_key_exists('annexe'.$i, $postedFiles)){
if (!($postedFiles['annexe'.$i]['name'] == "")) {
uploadFile($candidateData, $pathAnnexes, $postedFiles['annexe'.$i], 'annexe'.$i, "annexe".$i);
}
}
}
......@@ -194,9 +194,9 @@ function insertFiles ($pdo, $files, $applicantId, $filesPath) {
$sqlreq = "INSERT INTO file (file_name, file_path, fk_applicant_id)
VALUES (:file_name, :file_path, :fk_applicant_id)";
foreach ($files as $file) {
$filePath = $userPath . $file;
$filePath = $userPath . $file['name'];
$query = $pdo->prepare($sqlreq);
$query->bindParam(':file_name', $file, PDO::PARAM_STR);
$query->bindParam(':file_name', $file['name'], PDO::PARAM_STR);
$query->bindParam(':file_path', $filePath, PDO::PARAM_STR);
$query->bindParam(':fk_applicant_id', $applicantId, PDO::PARAM_INT);
$query->execute();
......@@ -353,7 +353,7 @@ function updatePostulation ($pdo, $posted_data) {
$query = $pdo->prepare($sqlreq);
$query->bindParam(':id', $posted_data->id, PDO::PARAM_STR);
$query->bindParam(':applicant_maturity', $posted_data->maturite, PDO::PARAM_BOOL);
$query->bindParam(':applicant_it_section', $posted_data->filiere, PDO::PARAM_BOOL);
$query->bindParam(':applicant_it_section', $posted_data->filiere, PDO::PARAM_STR);
$query->bindParam(':applicant_gender', $posted_data->genreApprenti, PDO::PARAM_STR);
$query->bindParam(':applicant_address_street', $posted_data->addresseApprentiComplete['rue'], PDO::PARAM_STR);
$query->bindParam(':applicant_address_npa', $posted_data->addresseApprentiComplete['NPA'], PDO::PARAM_STR);
......@@ -412,6 +412,7 @@ function updatePostulation ($pdo, $posted_data) {
$query->bindParam(':responsible_phone', $sec_rep['telephone'], PDO::PARAM_STR);
$query->execute();
}
// TODO: si nouveau, insert
// update scolarities
$to_add = [];
......@@ -460,19 +461,19 @@ function updatePostulation ($pdo, $posted_data) {
$sqlreq = "UPDATE training SET training_job=:training_job, training_company=:training_company
WHERE fk_applicant_id=:applicant_id AND training_id=:training_id";
foreach ($posted_data->stages as $training) {
if (isset($training['id'])) {
$query = $pdo->prepare($sqlreq);
$query->bindParam(':applicant_id', $posted_data->id, PDO::PARAM_INT);
$query->bindParam(':training_id', $training['id'], PDO::PARAM_INT);
$query->bindParam(':training_company', $training['metier'], PDO::PARAM_STR);
$query->bindParam(':training_job', $training['employeur'], PDO::PARAM_STR);
$query->execute();
} else {
array_push($to_add, $training);
foreach ($posted_data->stages as $training) {
if (isset($training['id'])) {
$query = $pdo->prepare($sqlreq);
$query->bindParam(':applicant_id', $posted_data->id, PDO::PARAM_INT);
$query->bindParam(':training_id', $training['id'], PDO::PARAM_INT);
$query->bindParam(':training_company', $training['metier'], PDO::PARAM_STR);
$query->bindParam(':training_job', $training['employeur'], PDO::PARAM_STR);
$query->execute();
} else {
array_push($to_add, $training);
}
}
}
insertTrainings($pdo, $to_add, $posted_data->id);
insertTrainings($pdo, $to_add, $posted_data->id);
// Update files
foreach ($posted_files as $key => $file) {
......
......@@ -135,7 +135,6 @@ class PersonnalData {
}
}
private function setFiles ($postedFiles, $ids) {
// Clear empty files
foreach ($postedFiles as $key => $file) {
if ($file['error'] != 0) {
unset($postedFiles[$key]);
......
......@@ -126,7 +126,7 @@ class PersonnalDataValidator {
private function filesValid () {
$filesToCheck = $this->personnalData->fichiers;
$validExt = ['.pdf', '.jpeg', '.png', '.jpg'];
$requiredKeys = ['photo', 'idCard', 'cv', 'lettre', 'certifs1'];
$requiredKeys = ['photo-passeport', 'carte-identite', 'curriculum-vitae', 'lettre-motivation'];
foreach($filesToCheck as $key => $file) {
// Pour les fichiers obligatoire
......
......@@ -152,9 +152,9 @@ function initAddChildButtons() {
$('#addInputFile').click(function () {
var nextIndex = $('#newCertifZone > tbody').children().length + 1;
if (nextIndex < 10) {
$('#newCertifZone').append('<tr><td><label for="certifs' + nextIndex + '">Annexe supplémentaire</label><br>'
+ '<input type="file" name="certifs' + nextIndex + '" class="upload-input" id="certifs' + nextIndex + '" onchange="changeTitleFile(this)"/>'
+ '<label for="certifs' + nextIndex + '" class="btn btn-secondary btn-sm icon-right">Choisir...</label><br>'
$('#newCertifZone').append('<tr><td><label for="annexe' + nextIndex + '">Annexe supplémentaire</label><br>'
+ '<input type="file" name="annexe' + nextIndex + '" class="upload-input" id="annexe' + nextIndex + '" onchange="changeTitleFile(this)"/>'
+ '<label for="annexe' + nextIndex + '" class="btn btn-secondary btn-sm icon-right">Choisir...</label><br>'
+ '<small class="error" class="form-text text-muted"></small></td></tr>');
if (nextIndex == 9) {
$('#addInputFile').hide(750);
......
......@@ -62,7 +62,7 @@
</td>
</tr>
</table>
</div>
<button type="button" class="btn btn-primary btn-sm mt-3 mb-2" id="addInputFile">Ajouter une annexe</button> -->
</div> -->
<button type="button" class="btn btn-primary btn-sm mt-3 mb-2" id="addInputFile">Ajouter une annexe</button>
<!-- region/ Annexes supplémentaires -->
</div>
\ No newline at end of file
<div class="form-group">
<?= $current_post['applicant_it_section'] ?>
<label>Filières informatiques:*</label>
<div class="custom-control custom-radio">
<input type="radio" name="filInfo" id="fill1" class="custom-control-input" value="developpementApplications" <?php echo ($current_post['applicant_it_section'] == "developpementApplications") ? "checked=\"checked\"" : ''; ?>>
......
......@@ -4,10 +4,10 @@
<!-- Annexes obligatoires -->
<div class="form-group mt-3" id="files">
<div class="form-group">
<label for="photo">Photo passeport <strong>couleur: *</strong></label>
<input type="file" name="photo" class="upload-input" id="photo" onchange="changeTitleFile(this)" data-required/>
<label for="photo-passeport">Photo passeport <strong>couleur: *</strong></label>
<input type="file" name="photo-passeport" class="upload-input" id="photo-passeport" onchange="changeTitleFile(this)" data-required/>
<br>
<label for="photo" class="btn btn-secondary btn-sm icon-right">
<label for="photo-passeport" class="btn btn-secondary btn-sm icon-right">
Choisir...
</label>
<br>
......@@ -15,10 +15,10 @@
</div>
<div class="form-group">
<label for="idCard">Copie carte d'indentité / passeport: *</label>
<input type="file" name="idCard" class="upload-input" id="idCard" onchange="changeTitleFile(this)" data-required/>
<label for="carte-identite">Copie carte d'indentité / passeport: *</label>
<input type="file" name="carte-identite" class="upload-input" id="carte-identite" onchange="changeTitleFile(this)" data-required/>
<br>
<label for="idCard" class="btn btn-secondary btn-sm icon-right">
<label for="carte-identite" class="btn btn-secondary btn-sm icon-right">
Choisir...
</label>
<br>
......@@ -26,10 +26,10 @@
</div>
<div class="form-group">
<label for="cv">Curriculum Vitae: *</label>
<input type="file" name="cv" class="upload-input" id="cv" onchange="changeTitleFile(this)" data-required/>
<label for="curriculum-vitae">Curriculum Vitae: *</label>
<input type="file" name="curriculum-vitae" class="upload-input" id="curriculum-vitae" onchange="changeTitleFile(this)" data-required/>
<br>
<label for="cv" class="btn btn-secondary btn-sm icon-right">
<label for="curriculum-vitae" class="btn btn-secondary btn-sm icon-right">
Choisir...
</label>
<br>
......@@ -37,10 +37,10 @@
</div>
<div class="form-group">
<label for="lettre">Lettre de motivation: *</label>
<input type="file" name="lettre" class="upload-input" id="lettre" onchange="changeTitleFile(this)" data-required/>
<label for="lettre-motivation">Lettre de motivation: *</label>
<input type="file" name="lettre-motivation" class="upload-input" id="lettre-motivation" onchange="changeTitleFile(this)" data-required/>
<br>
<label for="lettre" class="btn btn-secondary btn-sm icon-right">
<label for="lettre-motivation" class="btn btn-secondary btn-sm icon-right">
Choisir...
</label>
<br>
......@@ -75,10 +75,10 @@
<table id="newCertifZone">
<tr>
<td>
<label for="certifs1">Certificats, diplômes et bulletins de notes des derniers 3-4 semestres:</label>
<input type="file" name="certifs1" class="upload-input" id="certifs1" onchange="changeTitleFile(this)"/>
<label for="annexe1">Certificats, diplômes et bulletins de notes des derniers 3-4 semestres:</label>
<input type="file" name="annexe1" class="upload-input" id="annexe1" onchange="changeTitleFile(this)"/>
<br>
<label for="certifs1" class="btn btn-secondary btn-sm icon-right">
<label for="annexe1" class="btn btn-secondary btn-sm icon-right">
Choisir...
</label>
<br>
......
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