diff --git a/canapEPFL/cible.php b/canapEPFL/cible.php index 68c37f36d48d3409c788beee8eb76db4109f50b9..66c6fd4f2671519aab2f7015a333ef7d9a84fc9e 100644 --- a/canapEPFL/cible.php +++ b/canapEPFL/cible.php @@ -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; diff --git a/canapEPFL/form.php b/canapEPFL/form.php index 04e05ef8242c196d89ddc79d589894892c63fc26..7cedc17687bd56946796ae8baf4a074a080972c0 100644 --- a/canapEPFL/form.php +++ b/canapEPFL/form.php @@ -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 --> diff --git a/canapEPFL/helpers.php b/canapEPFL/helpers.php index 97576e4d468fda62995dd70866804853006ac58b..9d02273c7e33b7c5c098e7c5239e7a45e0a13c77 100644 --- a/canapEPFL/helpers.php +++ b/canapEPFL/helpers.php @@ -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); diff --git a/canapEPFL/models/PersonnalData.php b/canapEPFL/models/PersonnalData.php index cbad02d094f30d20a574bee0143cfe237b42e492..ad5eee18ef5f29857611c865e783e1f468f7812e 100644 --- a/canapEPFL/models/PersonnalData.php +++ b/canapEPFL/models/PersonnalData.php @@ -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) { diff --git a/canapEPFL/templates/formParts/edit/annexes.php b/canapEPFL/templates/formParts/edit/annexes.php index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..d6af62ce1eb307be1ca8a17aa48efb3dfdcf1744 100644 --- a/canapEPFL/templates/formParts/edit/annexes.php +++ b/canapEPFL/templates/formParts/edit/annexes.php @@ -0,0 +1,98 @@ +<?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 diff --git a/canapEPFL/templates/formParts/edit/personnal.php b/canapEPFL/templates/formParts/edit/personnal.php index a1b47c4f7ae0834bee5d59b3508a65d4a69cec6a..3a8f1cd3c1c4d2a1c3be51fda88b674f747a0546 100644 --- a/canapEPFL/templates/formParts/edit/personnal.php +++ b/canapEPFL/templates/formParts/edit/personnal.php @@ -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> diff --git a/canapEPFL/templates/formParts/new/annexes.php b/canapEPFL/templates/formParts/new/annexes.php index 6d15b4ad542dd35e48ced6e16333e89f05f5e760..f6ad19c2cd475a792d0848d4596eec31d0f6f59a 100644 --- a/canapEPFL/templates/formParts/new/annexes.php +++ b/canapEPFL/templates/formParts/new/annexes.php @@ -1,3 +1,6 @@ +<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"> diff --git a/canapEPFL/templates/formParts/new/personnal.php b/canapEPFL/templates/formParts/new/personnal.php index 82fa053bacf85d225a6b3e5f0a1151763b7f46e9..046485b6e4b8890958465f36db8d48020ba88880 100644 --- a/canapEPFL/templates/formParts/new/personnal.php +++ b/canapEPFL/templates/formParts/new/personnal.php @@ -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 diff --git a/canapEPFL/templates/head.php b/canapEPFL/templates/head.php index 1639fee1e890710af5bd45e719291deb740c5fa5..1169763e9f74a6e079bc1f4715b99e895e93022a 100644 --- a/canapEPFL/templates/head.php +++ b/canapEPFL/templates/head.php @@ -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(); }