2021-09-09 16:27:09 +02:00
|
|
|
<?php
|
2022-01-24 15:13:28 +01:00
|
|
|
|
2021-09-09 16:27:09 +02:00
|
|
|
use Cake\Routing\Router;
|
2022-01-25 11:31:17 +01:00
|
|
|
use Cake\Utility\Hash;
|
|
|
|
|
|
|
|
$severity = [
|
|
|
|
'primary' => -1,
|
|
|
|
'info' => 0,
|
|
|
|
'warning' => 1,
|
|
|
|
'danger' => 2,
|
|
|
|
];
|
|
|
|
$maxSeverity = -1;
|
2022-02-09 09:30:59 +01:00
|
|
|
$hasNotification = !empty($notifications);
|
2022-01-25 11:31:17 +01:00
|
|
|
$notificationVariants = Hash::extract($notifications, '{n}.variant');
|
|
|
|
foreach ($notificationVariants as $notifVariant) {
|
|
|
|
$maxSeverity = max($maxSeverity, $severity[$notifVariant] ?? 0);
|
|
|
|
}
|
|
|
|
$variant = array_flip($severity)[$maxSeverity];
|
2021-09-09 16:27:09 +02:00
|
|
|
?>
|
|
|
|
<div class="btn-group">
|
2021-09-17 13:04:37 +02:00
|
|
|
<a class="nav-link px-2 text-decoration-none profile-button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="#" data-bs-offset="10,20">
|
2022-01-24 15:13:28 +01:00
|
|
|
<span class="position-relative">
|
|
|
|
<i class="<?= $this->FontAwesome->getClass('bell') ?> fa-lg"></i>
|
2022-02-09 09:30:59 +01:00
|
|
|
<?php
|
|
|
|
if ($hasNotification) {
|
|
|
|
echo $this->Bootstrap->notificationBubble([
|
|
|
|
'variant' => $variant,
|
2022-11-24 12:50:11 +01:00
|
|
|
'borderVariant' => 'light',
|
2022-02-09 09:30:59 +01:00
|
|
|
]);
|
|
|
|
}
|
2022-02-08 17:57:20 +01:00
|
|
|
?>
|
2022-01-24 15:13:28 +01:00
|
|
|
</span>
|
2021-09-09 16:27:09 +02:00
|
|
|
</a>
|
2022-02-09 09:51:21 +01:00
|
|
|
<div class="dropdown-menu dropdown-menu-end notification-menu">
|
2022-01-24 15:13:28 +01:00
|
|
|
<h6 class="dropdown-header d-flex justify-content-between">
|
|
|
|
<span><?= __n('{0} Notification', '{0} Notifications', count($notifications), count($notifications)) ?></span>
|
|
|
|
</h6>
|
|
|
|
<?php if (empty($notifications)) : ?>
|
2022-02-09 09:30:59 +01:00
|
|
|
<span class="dropdown-item-text text-nowrap user-select-none text-center fs-7">
|
|
|
|
<?= __('You don\'t have notifications at the moment') ?>
|
2022-01-24 15:13:28 +01:00
|
|
|
<span>
|
|
|
|
<?php else : ?>
|
|
|
|
<?php foreach ($notifications as $notification) : ?>
|
|
|
|
<?= $this->element('layouts/header/header-notification-item', ['notification' => $notification]) ?>
|
|
|
|
<?php endforeach; ?>
|
2021-09-09 16:27:09 +02:00
|
|
|
<?php endif; ?>
|
|
|
|
</div>
|
2022-01-24 15:13:28 +01:00
|
|
|
</div>
|