Skip to content
Snippets Groups Projects
Commit 0dffa29f authored by nicrausaz's avatar nicrausaz
Browse files

update files working

parent 7b8a0786
No related branches found
No related tags found
No related merge requests found
......@@ -474,28 +474,14 @@ foreach ($posted_data->stages as $training) {
}
insertTrainings($pdo, $to_add, $posted_data->id);
// TODO: files
echo "<pre>";
// Update files
foreach ($posted_files as $key => $file) {
if ($file['name'] != '') {
print_r($file);
$file_data = getOneFile($pdo, $file['id'], $posted_data->id);
if (!move_uploaded_file($file['tmp_name'], $file_data['file_path'])) {
// Erreur: Le fichier est ouvert
$_SESSION['edit_error']['files'] = "Erreur lors du remplacement du fichier" . $_FILES['file'.$i]['name'] . ", réessayez plus tard.";
}
}
// $i = 1;
// while (isset($posted_data['file_id'.$i])) {
// // remplace le fichier sur le serveur
// if ($_FILES['file'.$i]['name']) {
// $file_data = getOneFile($pdo, $posted_data['file_id'.$i], $id);
// if (move_uploaded_file($_FILES['file'.$i]['tmp_name'], $file_data['file_path'])) {
// } else {
// // Le fichier est ouvert
// $_SESSION['edit_error']['files'] = "Erreur lors du remplacement du fichier" . $_FILES['file'.$i]['name'] . ", réessayez plus tard.";
// }
// }
// $i++;
// }
// header('Location: viewpostulation.php');
}
#endregion
......
......@@ -74,7 +74,7 @@ class PersonnalData {
$this->setStages();
$this->setDejacand();
$this->anneeFinScolarite = $postedData['anneeFin'];
$this->fichiers = $this->setFiles($postedFiles);
$this->fichiers = $this->setFiles($postedFiles, $postedData['files']);
}
#endregion
......@@ -134,11 +134,13 @@ class PersonnalData {
$this->anneeCandidature = $this->postedData['dejaCandAnnee'];
}
}
private function setFiles ($postedFiles) {
private function setFiles ($postedFiles, $ids) {
// Clear empty files
foreach ($postedFiles as $key => $file) {
if ($file['error'] != 0) {
unset($postedFiles[$key]);
} else {
$postedFiles[$key]['id'] = $ids[$key];
}
}
return $postedFiles;
......
......@@ -10,64 +10,24 @@
<!-- Annexes obligatoires -->
<div class="form-group mt-3" id="files">
<!-- <?php foreach ($files as $key => $file) { ?>
<?php foreach ($files as $key => $file) {
$name = preg_replace('/\\.[^.\\s]{3,4}$/', '', $file['file_name']);
?>
<div class="form-group">
<label for="photo"></label>
<input type="file" name="photo" class="upload-input" id="photo" onchange="changeTitleFile(this)"/>
<input value="<?= $file['file_id'] ?>" name="files[<?=$name?>]" readonly hidden/>
<label for="file<?= $file['file_id'] ?>">Remplacer: <?= $file['file_name'] ?></label>
<input type="file" name="<?=$name?>" class="upload-input" id="<?=$name?>" onchange="changeTitleFile(this)"/>
<br>
<label for="photo" class="btn btn-secondary btn-sm icon-right">
Remplacer: <?= $file['file_name'] ?>
<label for="<?=$name?>" class="btn btn-secondary btn-sm icon-right">
Remplacer...
</label>
<br>
<small class="error" class="form-text text-muted"></small>
</div>
<?php } ?> -->
<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)"/>
<br>
<label for="photo" class="btn btn-secondary btn-sm icon-right">
Remplacer...
</label>
<br>
<small class="error" class="form-text text-muted"></small>
</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)"/>
<br>
<label for="idCard" class="btn btn-secondary btn-sm icon-right">
Remplacer...
</label>
<br>
<small class="error" class="form-text text-muted"></small>
</div>
<div class="form-group">
<label for="cv">Curriculum Vitae: *</label>
<input type="file" name="cv" class="upload-input" id="cv" onchange="changeTitleFile(this)"/>
<br>
<label for="cv" class="btn btn-secondary btn-sm icon-right">
Remplacer...
</label>
<br>
<small class="error" class="form-text text-muted"></small>
</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)"/>
<br>
<label for="lettre" class="btn btn-secondary btn-sm icon-right">
Remplacer...
</label>
<br>
<small class="error" class="form-text text-muted"></small>
</div>
<?php } ?>
<!-- / Annexes obligatoires -->
<!-- Annexes spécifiques -->
<div class="form-group" id="polyOnly">
<!-- <div class="form-group" id="polyOnly">
<label for="gimch">Attestation de tests d'aptitudes GIM-CH (polymécanicien):</label>
<input type="file" name="gimch" class="upload-input" id="gimch" onchange="changeTitleFile(this)"/>
<br>
......@@ -87,10 +47,10 @@
</label>
<br>
<small class="error" class="form-text text-muted"></small>
</div>
</div> -->
<!-- / Annexes spécifiques -->
<!-- Annexes supplémentaires -->
<div class="form-group">
<!-- <div class="form-group">
<table id="newCertifZone">
<tr>
<td>
......@@ -106,6 +66,6 @@
</tr>
</table>
</div>
<button type="button" class="btn btn-primary btn-sm mt-3 mb-2" id="addInputFile">Ajouter une annexe</button>
<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
<?php
$main_resp = getResponsibleById($pdo, $current_post['fk_applicant_main_responsible'])[0];
$sec_resp = getResponsibleById($pdo, $current_post['fk_applicant_sec_responsible'])[0];
if ($current_post['applicant_has_majority'] == 0) {
$main_resp = getResponsibleById($pdo, $current_post['fk_applicant_main_responsible'])[0];
$sec_resp = getResponsibleById($pdo, $current_post['fk_applicant_sec_responsible'])[0];
}
?>
<label>Avez vous plus de 18 ans ?*:</label>
......@@ -9,7 +11,7 @@
<label class="custom-control-label" for="maj1">Non</label>
</div>
<div class="custom-control custom-radio">
<input type="radio" name="maj" id="maj2" class="custom-control-input" value="true" <?php echo $current_post['applicant_has_majority'] == 0 ? "checked=\"checked\"" : ''; ?>>
<input type="radio" name="maj" id="maj2" class="custom-control-input" value="true" <?php echo $current_post['applicant_has_majority'] == 1 ? "checked=\"checked\"" : ''; ?>>
<label class="custom-control-label" for="maj2">Oui</label>
</div>
......
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