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(
|
2020-06-23 14:26:41 +02:00
|
|
|
'<div><span class="font-weight-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(
|
|
|
|
'<a href="/organisations/view/%s">%s</a>',
|
|
|
|
h($alignment['organisation']['id']),
|
|
|
|
h($alignment['organisation']['name'])
|
|
|
|
),
|
|
|
|
sprintf(
|
|
|
|
"populateAndLoadModal(%s);",
|
|
|
|
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(
|
2020-06-23 14:26:41 +02:00
|
|
|
'<div>[<span class="font-weight-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(
|
|
|
|
'<a href="/individuals/view/%s">%s</a>',
|
|
|
|
h($alignment['individual']['id']),
|
|
|
|
h($alignment['individual']['email'])
|
|
|
|
),
|
|
|
|
sprintf(
|
|
|
|
"populateAndLoadModal(%s);",
|
|
|
|
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(
|
|
|
|
"populateAndLoadModal('/alignments/add/%s/%s');",
|
|
|
|
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')
|
|
|
|
);
|