2020-05-29 13:41:58 +02:00
|
|
|
<?php
|
|
|
|
$alignments = '';
|
2020-06-19 00:43:11 +02:00
|
|
|
$extracted = $data;
|
|
|
|
if (!empty($field['path'])) {
|
|
|
|
if (strpos('.', $field['path']) !== false) {
|
|
|
|
$extracted = Cake\Utility\Hash::extract($data, empty($field['path']) ? 'individual' : $field['path']);
|
|
|
|
} else {
|
|
|
|
$extracted = $data[$field['path']];
|
|
|
|
}
|
|
|
|
}
|
2020-05-29 13:41:58 +02:00
|
|
|
if ($field['scope'] === 'individuals') {
|
2020-06-19 00:43:11 +02:00
|
|
|
foreach ($extracted['alignments'] as $alignment) {
|
2020-05-29 13:41:58 +02:00
|
|
|
$alignments .= sprintf(
|
2021-09-17 13:04:37 +02:00
|
|
|
'<div><span class="fw-bold">%s</span> @ %s <a href="#" class="fas fa-trash" onClick="%s"></a></div>',
|
2020-05-29 13:41:58 +02:00
|
|
|
h($alignment['type']),
|
|
|
|
sprintf(
|
2022-09-19 01:59:23 +02:00
|
|
|
'<a href="%s/organisations/view/%s">%s</a>',
|
2021-02-09 22:10:26 +01:00
|
|
|
$baseurl,
|
2020-05-29 13:41:58 +02:00
|
|
|
h($alignment['organisation']['id']),
|
|
|
|
h($alignment['organisation']['name'])
|
|
|
|
),
|
|
|
|
sprintf(
|
2021-03-10 14:54:52 +01:00
|
|
|
"UI.submissionModalForSinglePage(%s);",
|
2020-05-29 13:41:58 +02:00
|
|
|
sprintf(
|
|
|
|
"'/alignments/delete/%s'",
|
|
|
|
$alignment['id']
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else if ($field['scope'] === 'organisations') {
|
2020-06-19 00:43:11 +02:00
|
|
|
foreach ($extracted['alignments'] as $alignment) {
|
2020-05-29 13:41:58 +02:00
|
|
|
$alignments .= sprintf(
|
2021-09-17 13:04:37 +02:00
|
|
|
'<div>[<span class="fw-bold">%s</span>] %s <a href="#" class="fas fa-trash" onClick="%s"></a></div>',
|
2020-05-29 13:41:58 +02:00
|
|
|
h($alignment['type']),
|
|
|
|
sprintf(
|
2022-09-19 01:59:23 +02:00
|
|
|
'<a href="%s/individuals/view/%s">%s</a>',
|
2021-02-09 22:10:26 +01:00
|
|
|
$baseurl,
|
2020-05-29 13:41:58 +02:00
|
|
|
h($alignment['individual']['id']),
|
|
|
|
h($alignment['individual']['email'])
|
|
|
|
),
|
|
|
|
sprintf(
|
2021-03-10 14:54:52 +01:00
|
|
|
"UI.submissionModalForSinglePage(%s);",
|
2020-05-29 13:41:58 +02:00
|
|
|
sprintf(
|
|
|
|
"'/alignments/delete/%s'",
|
|
|
|
$alignment['id']
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo sprintf(
|
2020-12-08 09:07:00 +01:00
|
|
|
'<div class="alignments-list">%s</div><div class="alignments-add-container"><button class="alignments-add-button btn btn-primary btn-sm" onclick="%s">%s</button></div>',
|
2020-05-29 13:41:58 +02:00
|
|
|
$alignments,
|
|
|
|
sprintf(
|
2021-03-10 14:54:52 +01:00
|
|
|
"UI.submissionModalForSinglePage('/alignments/add/%s/%s');",
|
2020-05-29 13:41:58 +02:00
|
|
|
h($field['scope']),
|
2020-06-19 00:43:11 +02:00
|
|
|
h($extracted['id'])
|
2020-05-29 13:41:58 +02:00
|
|
|
),
|
|
|
|
$field['scope'] === 'individuals' ? __('Add organisation') : __('Add individual')
|
|
|
|
);
|