diff --git a/canapEPFL/helpers.php b/canapEPFL/helpers.php index 22a8609326b2edc1d1c33047edffb8803551b6b5..7bdc9d782d0036d703f96b3b9a51d5e0e6aecd9d 100644 --- a/canapEPFL/helpers.php +++ b/canapEPFL/helpers.php @@ -286,6 +286,7 @@ function deletePostulation ($pdo, $id, $sciper, $rep1, $rep2) { $query->execute(); // delete files from server + // TODO: check this $filesToRemove = getFilesById($pdo, $id); foreach ($filesToRemove as $key => $file) { unlink($file['file_path']); @@ -317,8 +318,6 @@ function updatePostulation ($pdo, $id, $posted_data) { echo "<pre>"; print_r($posted_data); - // update applicant data - // -- applicant_birthdate= :applicant_birthdate, $sqlreq = "UPDATE applicant SET applicant_maturity= :applicant_maturity, @@ -327,6 +326,7 @@ function updatePostulation ($pdo, $id, $posted_data) { applicant_address_npa= :applicant_address_npa, applicant_home_phone= :applicant_home_phone, applicant_personal_phone= :applicant_personal_phone, + applicant_birthdate= :applicant_birthdate, applicant_origin= :applicant_origin, applicant_nationality= :applicant_nationality, applicant_foreign_authorization= :applicant_foreign_authorization, @@ -343,28 +343,31 @@ function updatePostulation ($pdo, $id, $posted_data) { applicant_application_updated_date= :applicant_application_updated_date WHERE applicant_id=:id"; + $datetime_now = date("Y-m-d H:i:s"); + $query = $pdo->prepare($sqlreq); $query->bindParam(':id', $id, PDO::PARAM_STR); - $query->bindParam(':applicant_maturity', $posted_data['applicant_maturity'], PDO::PARAM_STR); + $query->bindParam(':applicant_maturity', $posted_data['applicant_maturity'], PDO::PARAM_BOOL); $query->bindParam(':applicant_gender', $posted_data['applicant_gender'], PDO::PARAM_STR); $query->bindParam(':applicant_address_street', $posted_data['applicant_address_street'], PDO::PARAM_STR); $query->bindParam(':applicant_address_npa', $posted_data['applicant_address_npa'], PDO::PARAM_STR); $query->bindParam(':applicant_home_phone', $posted_data['applicant_home_phone'], PDO::PARAM_STR); $query->bindParam(':applicant_personal_phone', $posted_data['applicant_personal_phone'], PDO::PARAM_STR); + $query->bindParam(':applicant_birthdate', $posted_data['applicant_birthdate'], PDO::PARAM_STR); $query->bindParam(':applicant_origin', $posted_data['applicant_origin'], PDO::PARAM_STR); $query->bindParam(':applicant_nationality', $posted_data['applicant_nationality'], PDO::PARAM_STR); $query->bindParam(':applicant_foreign_authorization', $posted_data['applicant_foreign_authorization'], PDO::PARAM_STR); $query->bindParam(':applicant_avs', $posted_data['applicant_avs'], PDO::PARAM_STR); $query->bindParam(':applicant_main_language', $posted_data['applicant_main_language'], PDO::PARAM_STR); - $query->bindParam(':applicant_speaks_french', $posted_data['applicant_speaks_french'], PDO::PARAM_STR); - $query->bindParam(':applicant_speaks_german', $posted_data['applicant_speaks_german'], PDO::PARAM_STR); - $query->bindParam(':applicant_speaks_english', $posted_data['applicant_speaks_english'], PDO::PARAM_STR); - $query->bindParam(':applicant_speaks_other', $posted_data['applicant_speaks_other'], PDO::PARAM_STR); - $query->bindParam(':applicant_has_majority', $posted_data['applicant_has_majority'], PDO::PARAM_STR); - $query->bindParam(':applicant_already_applicant', $posted_data['applicant_already_applicant'], PDO::PARAM_STR); + $query->bindParam(':applicant_speaks_french', $posted_data['applicant_speaks_french'], PDO::PARAM_BOOL); + $query->bindParam(':applicant_speaks_german', $posted_data['applicant_speaks_german'], PDO::PARAM_BOOL); + $query->bindParam(':applicant_speaks_english', $posted_data['applicant_speaks_english'], PDO::PARAM_BOOL); + $query->bindParam(':applicant_speaks_other', $posted_data['applicant_speaks_other'], PDO::PARAM_BOOL); + $query->bindParam(':applicant_has_majority', $posted_data['applicant_has_majority'], PDO::PARAM_BOOL); + $query->bindParam(':applicant_already_applicant', $posted_data['applicant_already_applicant'], PDO::PARAM_BOOL); $query->bindParam(':applicant_already_applicant_year', $posted_data['applicant_already_applicant_year'], PDO::PARAM_STR); $query->bindParam(':applicant_scolarity_end', $posted_data['applicant_scolarity_end'], PDO::PARAM_STR); - $query->bindParam(':applicant_application_updated_date', date("Y-m-d H:i:s"), PDO::PARAM_STR); + $query->bindParam(':applicant_application_updated_date', $datetime_now, PDO::PARAM_STR); $query->execute(); diff --git a/canapEPFL/models/PersonnalData.php b/canapEPFL/models/PersonnalData.php index 684d754c2bdc2c9b73fafba94fa3c1da9f6bf075..cbad02d094f30d20a574bee0143cfe237b42e492 100644 --- a/canapEPFL/models/PersonnalData.php +++ b/canapEPFL/models/PersonnalData.php @@ -56,7 +56,7 @@ class PersonnalData { $this->telFixeApprenti = $postedData['telApp']; $this->telMobileApprenti = $postedData['phoneApp']; $this->mailApprenti = $postedData['mailApp']; - $this->dateNaissanceApprenti = date('Y-m-d', strtotime($postedData['birthApp'])); + $this->dateNaissanceApprenti = $postedData['birthApp']; $this->origineApprenti = $postedData['originApp']; $this->nationaliteApprenti = $postedData['nationApp']; $this->permisEtranger = $postedData['permisEtrangerApp']; diff --git a/canapEPFL/models/PersonnalDataValidator.php b/canapEPFL/models/PersonnalDataValidator.php index 3248efe14132d7919083732279d792ab095e0c75..7399717211bedec4433bde68c8aefd5191e86367 100644 --- a/canapEPFL/models/PersonnalDataValidator.php +++ b/canapEPFL/models/PersonnalDataValidator.php @@ -67,7 +67,7 @@ class PersonnalDataValidator { } private function isBirthDateValid ($birthDate) { - $birthYear = date('Y', strtotime($birthDate)); + $birthYear = explode('/', $birthDate)[2]; $actualYear = date('Y'); if (($birthYear > $actualYear - 60) && ($birthYear <= $actualYear - 13)) { diff --git a/canapEPFL/script.js b/canapEPFL/script.js index f8560e2e50b4c051bf8bdecb730c3374200538a1..8ccfcba8fea31e48a285a92a19839e6fccaf2a9a 100644 --- a/canapEPFL/script.js +++ b/canapEPFL/script.js @@ -262,6 +262,9 @@ function initEdits() { } }); + $.datepicker.setDefaults($.datepicker.regional["fr"]); + $("#applicant_birthdate").datepicker({ minDate: '-60y', maxDate: '-13y', dateFormat: "dd/mm/yy" }); + $('#editPost').click(function () { $('#editPost').prop('disabled', true); $('#confirmEditPost').show(); diff --git a/canapEPFL/templates/viewPostulationTables/personnalInfosTable.php b/canapEPFL/templates/viewPostulationTables/personnalInfosTable.php index 6c08dd61c57cbb7f853632fbf0a01eec2be2c377..1f8869777baa1048212387ca9b255c867320fdb7 100644 --- a/canapEPFL/templates/viewPostulationTables/personnalInfosTable.php +++ b/canapEPFL/templates/viewPostulationTables/personnalInfosTable.php @@ -65,7 +65,10 @@ </tr> <tr> <td>Date de naissance</td> - <td><?= date('d/m/Y', strtotime($postulation['applicant_birthdate'])) ?></td> + <td> + <span class="postulationDataSpans"><?= $postulation['applicant_birthdate'] ?></span> + <input type="text" autocomplete="none" placeholder="jj/mm/aaaa" name="applicant_birthdate" id="applicant_birthdate" class="form-control editPostInputs" value="<?= $postulation['applicant_birthdate'] ?>" /> + </td> </tr> <tr> <td>Origine</td>