Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Consent] Group consents + Improve UI #6044

Merged
merged 4 commits into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ requesting a new account and will be displayed in the User Accounts module (PR #
### Modules
#### Issue Tracker
- Readability of comments and history was improved. (PR #6138)
#### Candidate Parameters
- Consent grouping added to SQL schema and Consent Status tab UI (PR #6042, PR #6044)
zaliqarosli marked this conversation as resolved.
Show resolved Hide resolved
### Clean Up
- *Add item here*
### Notes For Existing Projects
Expand Down
35 changes: 18 additions & 17 deletions modules/candidate_parameters/ajax/getData.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,9 @@ function getConsentStatusFields()
$date = [];
$withdrawalDate = [];

// Get consent groups
$consentGroups = \Utility::getConsentGroups();

// Get list of all consent types
$consentDetails = \Utility::getConsentList();
// Get list of consents for candidate
Expand All @@ -431,6 +434,10 @@ function getConsentStatusFields()
foreach ($consentDetails as $consentID=>$consent) {
$consentName = $consent['Name'];
$consentList[$consentName] = $consent['Label'];
$groupID = $consent['ConsentGroupID'];

// Append consent as a child to its group
$consentGroups[$groupID]['Children'][] = $consentName;

if (isset($candidateConsent[$consentID])) {
$candidateConsentID = $candidateConsent[$consentID];
Expand All @@ -453,6 +460,7 @@ function getConsentStatusFields()
'withdrawals' => $withdrawalDate,
'consents' => $consentList,
'history' => $history,
'consentGroups' => $consentGroups,
];

return $result;
Expand All @@ -469,7 +477,7 @@ function getConsentStatusFields()
*/
function getConsentStatusHistory($pscid)
{
$db = \Database::singleton();
$db = (\NDB_Factory::singleton())->database();

$historyData = $db->pselect(
"SELECT EntryDate, DateGiven, DateWithdrawn, PSCID,
Expand All @@ -481,23 +489,16 @@ function getConsentStatusHistory($pscid)
);

$formattedHistory = [];
foreach ($historyData as $key => $entry) {
$consentName = $entry['ConsentName'];
$consentLabel = $entry['ConsentLabel'];

$history = [
'data_entry_date' => $entry['EntryDate'],
'entry_staff' => $entry['EntryStaff'],
$consentName => $entry['Status'],
$consentName . '_date' => $entry['DateGiven'],
$consentName . '_withdrawal' => $entry['DateWithdrawn'],
];
$consentHistory = [
$key => $history,
'label' => $consentLabel,
'consentType' => $consentName,
foreach ($historyData as $entry) {
$formattedHistory[] = [
'data_entry_date' => $entry['EntryDate'],
'entry_staff' => $entry['EntryStaff'],
'consentStatus' => $entry['Status'],
'date' => $entry['DateGiven'],
'withdrawal' => $entry['DateWithdrawn'],
'label' => $entry['ConsentLabel'],
'consentType' => $entry['ConsentName'],
];
$formattedHistory[$key] = $consentHistory;
}
return $formattedHistory;
}
Expand Down
Loading