Skip to content
Snippets Groups Projects
Commit 734404c2 authored by nicrausaz's avatar nicrausaz
Browse files

updated form lang

parent 8df1993f
No related branches found
No related tags found
No related merge requests found
......@@ -12,30 +12,35 @@
<body>
<?php
include('templates/header.php');
// Init personnalData with postedData
$candidateData = new PersonnalData($_POST, $_FILES, $FILESERVERPATH);
// Init dataValidator
$validator = new PersonnalDataValidator($candidateData);
if ($validator->isValid()) {
// write infos in DB
$candidateId = insertDataIntoDB($pdo, $candidateData);
if (isset($_GET['edit'])) {
// update data
} else {
// write infos in DB
$candidateId = insertDataIntoDB($pdo, $candidateData);
// create dir + move files in it
$filesPath = createFilesFolder($candidateData->rootpath, $candidateId);
$candidateData = uploadAllFiles($filesPath, $candidateData->fichiers, $candidateData);
// create dir + move files in it
$filesPath = createFilesFolder($candidateData->rootpath, $candidateId);
$candidateData = uploadAllFiles($filesPath, $candidateData->fichiers, $candidateData);
// insert files in DB
insertFiles($pdo, $candidateData->fichiers, $candidateId, $candidateData->rootpath);
// insert files in DB
insertFiles($pdo, $candidateData->fichiers, $candidateId, $candidateData->rootpath);
if ($SENDEMAILS) {
mailToResp($candidateData->prenomApprenti, $candidateData->nomApprenti, $candidateData->formation);
mailToApprenti($candidateData->mailApprenti, $candidateData->formation);
if ($SENDEMAILS) {
mailToResp($candidateData->prenomApprenti, $candidateData->nomApprenti, $candidateData->formation);
mailToApprenti($candidateData->mailApprenti, $candidateData->formation);
}
// kill session
$_SESSION['formError'] = false;
unset($_SESSION);
include("templates/confirmationText.php");
}
// kill session
$_SESSION['formError'] = false;
unset($_SESSION);
include("templates/confirmationText.php");
} else {
$_SESSION['formError'] = true;
$_SESSION['postedForm'] = $_POST;
......
......@@ -33,7 +33,11 @@
<h3 class="mb-5">Candidature pour un apprentissage</h3>
<?php echo isset($_GET['edit']) ? "<small class='mb-3'>Les champs notés d'un * doivent être obligatoirement remplis.</small>" : "" ?>
<form method="post" action="cible.php" enctype="multipart/form-data">
<?php if (isset($_GET['edit'])) {?>
<form method="post" action="cible.php?edit" enctype="multipart/form-data">
<?php } else { ?>
<form method="post" action="cible.php" enctype="multipart/form-data">
<?php } ?>
<h3>1. Apprentissage</h3>
<!-- Choix formation -->
<div class="form-group">
......@@ -90,9 +94,6 @@
<!-- Annexes -->
<h3>4. Annexes</h3>
<small>Merci de joindre tous les fichiers demandés, en respectant les formats (si les formats ne sont pas respectés, les fichiers ne seront pas pris en compte).</small>
<br>
<small>Formats autorisés: <b>PDF, JPG, JPEG, PNG</b></small>
<?php isset($_GET['edit']) ? include('templates/formParts/edit/annexes.php') : include('templates/formParts/new/annexes.php'); ?>
<!-- / Annexes -->
......@@ -104,7 +105,6 @@
</div>
</div>
<!-- / Conditions -->
<button type="submit" class="btn btn-primary btn-block" type="submit">Terminer</button>
</div>
<!-- / div all -->
......
......@@ -93,16 +93,10 @@ function insertPersonalInfos ($pdo, $candidateData) {
$query->bindParam(':applicant_avs', $candidateData->numeroAVS, PDO::PARAM_STR);
$query->bindParam(':applicant_main_language', $candidateData->langueMaternelleApprenti, PDO::PARAM_STR);
// languages
$speaks_fr = in_array("fr", $candidateData->connaissancesLinguistiques);
$speaks_de = in_array("de", $candidateData->connaissancesLinguistiques);
$speaks_en = in_array("en", $candidateData->connaissancesLinguistiques);
$speaks_other = in_array("others", $candidateData->connaissancesLinguistiques);
$query->bindParam(':applicant_speaks_french', $speaks_fr, PDO::PARAM_BOOL);
$query->bindParam(':applicant_speaks_german', $speaks_de, PDO::PARAM_BOOL);
$query->bindParam(':applicant_speaks_english', $speaks_en, PDO::PARAM_BOOL);
$query->bindParam(':applicant_speaks_other', $speaks_other, PDO::PARAM_BOOL);
$query->bindParam(':applicant_speaks_french', $candidateData->speaksFrench, PDO::PARAM_BOOL);
$query->bindParam(':applicant_speaks_german', $candidateData->speaksGerman, PDO::PARAM_BOOL);
$query->bindParam(':applicant_speaks_english', $candidateData->speaksEnglish, PDO::PARAM_BOOL);
$query->bindParam(':applicant_speaks_other', $candidateData->speaksOther, PDO::PARAM_BOOL);
$query->bindParam(':applicant_has_majority', $candidateData->majeur, PDO::PARAM_BOOL);
$query->bindParam(':applicant_scolarity_end', $candidateData->anneeFinScolarite, PDO::PARAM_STR);
......
......@@ -61,8 +61,11 @@ class PersonnalData {
$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->setLanguages($postedData['languesApp']);
$this->majeur = $postedData['maj'] == "true" ? 1 : 0;
if (!$this->majeur) { $this->setRepresentants(); }
$this->setScolarite();
......@@ -113,13 +116,13 @@ class PersonnalData {
$this->anneeCandidature = $this->postedData['dejaCandAnnee'];
}
}
public function setLanguages ($languages) {
if (isset($languages) && is_array($languages)) {
$this->connaissancesLinguistiques = $languages;
} else {
$this->connaissancesLinguistiques = [];
}
}
// 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) {
......
<?php
$files = getFilesById($pdo, $current_post['applicant_id']);
echo "<pre>";
print_r($files);
echo "</pre>";
?>
<small>Remplacez ou ajouter des annexes (le fichier actuel est conservé si il n'est pas remplacé)</small>
<br>
<small>Formats autorisés: <b>PDF, JPG, JPEG, PNG</b></small>
<!-- 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)"/>
<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>
<!-- / Annexes obligatoires -->
<!-- Annexes spécifiques -->
<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>
<label for="gimch" 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" id="griTest">
<label for="griTestInput">Attestation de tests d'aptitudes GRI (informaticien):</label>
<input type="file" name="griTestInput" class="upload-input" id="griTestInput" onchange="changeTitleFile(this)"/>
<br>
<label for="griTestInput" class="btn btn-secondary btn-sm icon-right">
Remplacer...
</label>
<br>
<small class="error" class="form-text text-muted"></small>
</div>
<!-- / Annexes spécifiques -->
<!-- Annexes supplémentaires -->
<div class="form-group">
<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)"/>
<br>
<label for="certifs1" class="btn btn-secondary btn-sm icon-right">
Remplacer...
</label>
<br>
<small class="error" class="form-text text-muted"></small>
</td>
</tr>
</table>
</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
......@@ -50,18 +50,22 @@
<label>Connaissances linguistiques</label>
<div class="custom-control custom-checkbox">
<input hidden value="0" name="applicant_speaks_french">
<input type="checkbox" class="custom-control-input" value="1" id="french" name="applicant_speaks_french" <?php echo $current_post['applicant_speaks_french'] == 1 ? 'checked="checked"' : ''; ?>>
<label class="custom-control-label" for="french">Français</label>
</div>
<div class="custom-control custom-checkbox">
<div class="custom-control custom-checkbox">
<input hidden value="0" name="applicant_speaks_german">
<input type="checkbox" class="custom-control-input" value="1" id="german" name="applicant_speaks_german" <?php echo $current_post['applicant_speaks_german'] == 1 ? 'checked="checked"' : ''; ?>>
<label class="custom-control-label" for="german">Allemand</label>
</div>
<div class="custom-control custom-checkbox">
<input hidden value="0" name="applicant_speaks_english">
<input type="checkbox" class="custom-control-input" value="1" id="english" name="applicant_speaks_english" <?php echo $current_post['applicant_speaks_english'] == 1 ? 'checked="checked"' : ''; ?>>
<label class="custom-control-label" for="english">Anglais</label>
</div>
<div class="custom-control custom-checkbox">
<input hidden value="0" name="applicant_speaks_other">
<input type="checkbox" class="custom-control-input" value="1" id="other" name="applicant_speaks_other" <?php echo $current_post['applicant_speaks_other'] == 1 ? 'checked="checked"' : ''; ?>>
<label class="custom-control-label" for="other">Autres</label>
</div>
......
<small>Merci de joindre tous les fichiers demandés, en respectant les formats (si les formats ne sont pas respectés, les fichiers ne seront pas pris en compte).</small>
<br>
<small>Formats autorisés: <b>PDF, JPG, JPEG, PNG</b></small>
<!-- Annexes obligatoires -->
<div class="form-group mt-3" id="files">
<div class="form-group">
......
......@@ -51,19 +51,23 @@
<label>Connaissances linguistiques *</label>
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" value="fr" id="french" name="languesApp[]" <?php echo (is_int(array_search('fr', $_SESSION['postedForm']['languesApp']))) ? 'checked="checked"' : ''; ?>>
<input hidden value="0" name="applicant_speaks_french">
<input type="checkbox" class="custom-control-input" value="1" id="french" name="applicant_speaks_french" <?php echo $_SESSION['postedForm']['applicant_speaks_french'] == 1 ? 'checked="checked"' : ''; ?>>
<label class="custom-control-label" for="french">Français</label>
</div>
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" value="de" id="german" name="languesApp[]" <?php echo (is_int(array_search('de', $_SESSION['postedForm']['languesApp']))) ? 'checked="checked"' : ''; ?>>
<input hidden value="0" name="applicant_speaks_german">
<input type="checkbox" class="custom-control-input" value="1" id="german" name="applicant_speaks_german" <?php echo $_SESSION['postedForm']['applicant_speaks_german'] == 1 ? 'checked="checked"' : ''; ?>>
<label class="custom-control-label" for="german">Allemand</label>
</div>
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" value="en" id="english" name="languesApp[]" <?php echo (is_int(array_search('en', $_SESSION['postedForm']['languesApp']))) ? 'checked="checked"' : ''; ?>>
<input hidden value="0" name="applicant_speaks_english">
<input type="checkbox" class="custom-control-input" value="1" id="english" name="applicant_speaks_english" <?php echo $_SESSION['postedForm']['applicant_speaks_english'] == 1 ? 'checked="checked"' : ''; ?>>
<label class="custom-control-label" for="english">Anglais</label>
</div>
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" value="others" id="other" name="languesApp[]" <?php echo (is_int(array_search('others', $_SESSION['postedForm']['languesApp']))) ? 'checked="checked"' : ''; ?>>
<input hidden value="0" name="applicant_speaks_other">
<input type="checkbox" class="custom-control-input" value="1" id="other" name="applicant_speaks_other" <?php echo $_SESSION['postedForm']['applicant_speaks_other'] == 1 ? 'checked="checked"' : ''; ?>>
<label class="custom-control-label" for="other">Autres</label>
</div>
</div>
\ No newline at end of file
......@@ -23,8 +23,8 @@
<?php
ini_set("display_errors", 0);
error_reporting(0);
// ini_set("display_errors", 1);
// error_reporting(E_ALL);
ini_set("display_errors", 1);
error_reporting(E_ALL);
require_once('configs/config.php');
require('configs/db.php');
if (!isset($_SESSION)) { session_start(); }
......
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