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

fix birthdate

parent b93fdb94
No related branches found
No related tags found
No related merge requests found
......@@ -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();
......
......@@ -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'];
......
......@@ -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)) {
......
......@@ -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();
......
......@@ -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>
......
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