2024-01-04 09:45:35 +01:00
|
|
|
<?php
|
2023-12-20 14:36:45 +01:00
|
|
|
$seed = mt_rand();
|
2023-12-21 09:28:43 +01:00
|
|
|
|
2024-01-25 20:01:04 +01:00
|
|
|
$notes = $analyst_data['notes'] ?? [];
|
|
|
|
$opinions = $analyst_data['opinions'] ?? [];
|
|
|
|
$relationships = $analyst_data['relationships'] ?? [];
|
|
|
|
|
|
|
|
$notesOpinions = array_merge($notes, $opinions);
|
2024-01-26 16:25:09 +01:00
|
|
|
$notesOpinionsRelationships = array_merge($notesOpinions, $relationships);
|
2024-01-24 21:48:53 +01:00
|
|
|
|
2024-01-04 10:48:13 +01:00
|
|
|
if(!function_exists("countNotes")) {
|
2024-01-25 20:01:04 +01:00
|
|
|
function countNotes($notesOpinions) {
|
|
|
|
$notesTotalCount = count($notesOpinions);
|
2024-01-11 08:48:27 +01:00
|
|
|
$notesCount = 0;
|
|
|
|
$relationsCount = 0;
|
2024-01-25 20:01:04 +01:00
|
|
|
foreach ($notesOpinions as $notesOpinion) {
|
|
|
|
if ($notesOpinion['note_type'] == 2) { // relationship
|
2024-01-11 08:48:27 +01:00
|
|
|
$relationsCount += 1;
|
|
|
|
} else {
|
|
|
|
$notesCount += 1;
|
|
|
|
}
|
2024-01-25 20:01:04 +01:00
|
|
|
if (!empty($notesOpinion['Note'])) {
|
|
|
|
$nestedCounts = countNotes($notesOpinion['Note']);
|
2024-01-24 21:48:53 +01:00
|
|
|
$notesTotalCount += $nestedCounts['total'];
|
2024-01-25 20:01:04 +01:00
|
|
|
$notesCount += $nestedCounts['notesOpinions'];
|
2024-01-24 21:48:53 +01:00
|
|
|
$relationsCount += $nestedCounts['relations'];
|
|
|
|
}
|
2024-01-25 20:01:04 +01:00
|
|
|
if (!empty($notesOpinion['Opinion'])) {
|
|
|
|
$nestedCounts = countNotes($notesOpinion['Opinion']);
|
2024-01-11 08:48:27 +01:00
|
|
|
$notesTotalCount += $nestedCounts['total'];
|
2024-01-25 20:01:04 +01:00
|
|
|
$notesCount += $nestedCounts['notesOpinions'];
|
2024-01-11 08:48:27 +01:00
|
|
|
$relationsCount += $nestedCounts['relations'];
|
2024-01-04 10:48:13 +01:00
|
|
|
}
|
|
|
|
}
|
2024-01-25 20:01:04 +01:00
|
|
|
return ['total' => $notesTotalCount, 'notesOpinions' => $notesCount, 'relations' => $relationsCount];
|
2024-01-04 10:48:13 +01:00
|
|
|
}
|
|
|
|
}
|
2024-01-25 20:01:04 +01:00
|
|
|
$counts = countNotes($notesOpinions);
|
|
|
|
$notesOpinionCount = $counts['notesOpinions'];
|
|
|
|
$relationshipsCount = count($relationships);
|
2023-12-20 14:36:45 +01:00
|
|
|
?>
|
|
|
|
|
2024-01-26 16:25:09 +01:00
|
|
|
<?php if (empty($notesOpinions) && empty($relationshipsCount)): ?>
|
2024-01-24 21:48:53 +01:00
|
|
|
<i class="<?= $this->FontAwesome->getClass('sticky-note') ?> useCursorPointer node-opener-<?= $seed ?>" title="<?= __('Notes and opinions for this UUID') ?>"></i>
|
2024-01-04 10:48:13 +01:00
|
|
|
<?php else: ?>
|
2024-01-24 21:48:53 +01:00
|
|
|
<span class="label label-info useCursorPointer node-opener-<?= $seed ?>">
|
2024-01-04 11:15:43 +01:00
|
|
|
<i class="<?= $this->FontAwesome->getClass('sticky-note') ?> useCursorPointer" title="<?= __('Notes and opinions for this UUID') ?>"></i>
|
2024-01-25 20:01:04 +01:00
|
|
|
<?= $notesOpinionCount; ?>
|
2024-01-11 08:48:27 +01:00
|
|
|
<i class="<?= $this->FontAwesome->getClass('project-diagram') ?> useCursorPointer" title="<?= __('Relationships for this UUID') ?>"></i>
|
|
|
|
<?= $relationshipsCount; ?>
|
2024-01-04 10:48:13 +01:00
|
|
|
</span>
|
|
|
|
<?php endif; ?>
|
2023-12-20 14:36:45 +01:00
|
|
|
|
|
|
|
<script>
|
2024-01-24 21:48:53 +01:00
|
|
|
|
|
|
|
|
2024-01-30 08:58:47 +01:00
|
|
|
$(document).ready(function() {
|
|
|
|
$('.node-opener-<?= $seed ?>').click(function() {
|
|
|
|
openNotes(this)
|
|
|
|
})
|
2024-01-25 20:01:04 +01:00
|
|
|
|
2024-01-30 08:58:47 +01:00
|
|
|
function adjustPopoverPosition() {
|
|
|
|
var $popover = $('.popover:last');
|
|
|
|
$popover.css('top', Math.max($popover.position().top, 50) + 'px')
|
2024-01-25 20:01:04 +01:00
|
|
|
}
|
2024-01-26 15:16:36 +01:00
|
|
|
|
2023-12-20 14:36:45 +01:00
|
|
|
function openNotes(clicked) {
|
2024-01-24 21:48:53 +01:00
|
|
|
openPopover(clicked, renderedNotes<?= $seed ?>, undefined, undefined, function() {
|
2024-01-11 08:48:27 +01:00
|
|
|
adjustPopoverPosition()
|
2023-12-21 09:28:43 +01:00
|
|
|
$(clicked).removeClass('have-a-popover') // avoid closing the popover if a confirm popover (like the delete one) is called
|
2023-12-20 14:36:45 +01:00
|
|
|
})
|
|
|
|
}
|
2024-01-30 08:58:47 +01:00
|
|
|
})
|
2023-12-20 14:36:45 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<?php
|
2024-01-30 08:58:47 +01:00
|
|
|
echo $this->element('genericElements/Analyst_data/thread', [
|
|
|
|
'seed' => $seed,
|
|
|
|
'notes' => $notes,
|
|
|
|
'opinions' => $opinions,
|
|
|
|
'relationships' => $relationships,
|
|
|
|
'object_type' => $object_type,
|
|
|
|
'object_uuid' => $object_uuid,
|
|
|
|
'shortDist' => $shortDist,
|
|
|
|
]);
|
|
|
|
?>
|