From d6ead9ca096f106e3ba52ec12b8046d8388fb473 Mon Sep 17 00:00:00 2001 From: CamilleBeau Date: Fri, 8 Dec 2023 10:05:14 -0500 Subject: [PATCH 1/2] [candidate_parameters] use DoB and DoD format --- modules/candidate_parameters/ajax/getData.php | 47 +++++++++++++++---- .../candidate_parameters/jsx/CandidateDOB.js | 2 + .../candidate_parameters/jsx/CandidateDOD.js | 2 + 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/modules/candidate_parameters/ajax/getData.php b/modules/candidate_parameters/ajax/getData.php index 9c5f213c4cb..4ae4eac3f22 100644 --- a/modules/candidate_parameters/ajax/getData.php +++ b/modules/candidate_parameters/ajax/getData.php @@ -521,10 +521,22 @@ function getDOBFields(): array ); $pscid = $candidateData['PSCID'] ?? null; $dob = $candidateData['DoB'] ?? null; - $result = [ - 'pscid' => $pscid, - 'candID' => $candID->__toString(), - 'dob' => $dob, + + // Get DoB format + $factory = \NDB_Factory::singleton(); + $config = $factory->config(); + + $dobFormat = $config->getSetting('dobFormat'); + + $dobProcessedFormat = implode("-", str_split($dobFormat, 1)); + $dobDate = DateTime::createFromFormat('Y-m-d', $dob); + $formattedDate = $dobDate ? $dobDate->format($dobProcessedFormat) : null; + + $result = [ + 'pscid' => $pscid, + 'candID' => $candID->__toString(), + 'dob' => $formattedDate, + 'dobFormat' => $dobFormat, ]; return $result; } @@ -546,11 +558,30 @@ function getDODFields(): array if ($candidateData === null) { throw new \LorisException("Invalid candidate"); } + + $factory = \NDB_Factory::singleton(); + $config = $factory->config(); + + // Get formatted dod + $dodFormat = $config->getSetting('dodFormat'); + + $dodProcessedFormat = implode("-", str_split($dodFormat, 1)); + $dodDate = DateTime::createFromFormat('Y-m-d', $candidateData['DoD']); + $dod = $dodDate ? $dodDate->format($dodProcessedFormat) : null; + + // Get formatted dob + $dobFormat = $config->getSetting('dobFormat'); + + $dobProcessedFormat = implode("-", str_split($dobFormat, 1)); + $dobDate = DateTime::createFromFormat('Y-m-d', $candidateData['DoB']); + $dob = $dobDate ? $dobDate->format($dobProcessedFormat) : null; + $result = [ - 'pscid' => $candidateData['PSCID'], - 'candID' => $candID->__toString(), - 'dod' => $candidateData['DoD'], - 'dob' => $candidateData['DoB'], + 'pscid' => $candidateData['PSCID'], + 'candID' => $candID->__toString(), + 'dod' => $dod, + 'dob' => $dob, + 'dodFormat' => $config->getSetting('dodFormat'), ]; return $result; } diff --git a/modules/candidate_parameters/jsx/CandidateDOB.js b/modules/candidate_parameters/jsx/CandidateDOB.js index 2cda15a7c06..e0914da8a7d 100644 --- a/modules/candidate_parameters/jsx/CandidateDOB.js +++ b/modules/candidate_parameters/jsx/CandidateDOB.js @@ -85,6 +85,7 @@ class CandidateDOB extends Component { return ; } + let dateFormat = this.state.data.dobFormat; let disabled = true; let updateButton = null; if (loris.userHasPermission('candidate_dob_edit')) { @@ -116,6 +117,7 @@ class CandidateDOB extends Component { ; } + let dateFormat = this.state.data.dodFormat; let disabled = true; let updateButton = null; if (loris.userHasPermission('candidate_dod_edit')) { @@ -114,6 +115,7 @@ class CandidateDOD extends Component { Date: Fri, 8 Dec 2023 10:08:23 -0500 Subject: [PATCH 2/2] Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c238378954..ad468b3cb59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ changes in the following format: PR #1234*** #### Bug Fixes - bvl_feedback updates in real-time (PR #8966) +- DoB and DoD format respected in candidate parameters (PR #9001) ## LORIS 25.0 (Release Date: ????-??-??) ### Core