Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[candidate_parameters] use DoB and DoD format #9001

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
47 changes: 39 additions & 8 deletions modules/candidate_parameters/ajax/getData.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions modules/candidate_parameters/jsx/CandidateDOB.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class CandidateDOB extends Component {
return <Loader/>;
}

let dateFormat = this.state.data.dobFormat;
let disabled = true;
let updateButton = null;
if (loris.userHasPermission('candidate_dob_edit')) {
Expand Down Expand Up @@ -116,6 +117,7 @@ class CandidateDOB extends Component {
<DateElement
label='Date Of Birth:'
name='dob'
dateFormat={dateFormat}
value={this.state.formData.dob}
onUserInput={this.setFormData}
disabled={disabled}
Expand Down
2 changes: 2 additions & 0 deletions modules/candidate_parameters/jsx/CandidateDOD.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class CandidateDOD extends Component {
return <Loader/>;
}

let dateFormat = this.state.data.dodFormat;
let disabled = true;
let updateButton = null;
if (loris.userHasPermission('candidate_dod_edit')) {
Expand Down Expand Up @@ -114,6 +115,7 @@ class CandidateDOD extends Component {
<DateElement
label='Date Of Death:'
name='dod'
dateFormat={dateFormat}
value={this.state.formData.dod}
onUserInput={this.setFormData}
disabled={disabled}
Expand Down
Loading