fixe widget

This commit is contained in:
2026-08-14 08:05:24 +02:00
parent 5f2137d8ec
commit 5a4a39fb3c
+6 -8
View File
@@ -1,4 +1,5 @@
<?php <?php
/** /**
* Training reminders widget for the production dashboard. * Training reminders widget for the production dashboard.
* Visible to HR / manager / Admin / User / Superuser. * Visible to HR / manager / Admin / User / Superuser.
@@ -9,10 +10,6 @@ if (!isset($pdo)) {
$pdo = DBHandlerSelect::getInstance()->getConnection(); $pdo = DBHandlerSelect::getInstance()->getConnection();
} }
if (!isset($pdo)) {
$pdo = DBHandlerSelect::getInstance()->getConnection();
}
/* Check user webapp notification preference */ /* Check user webapp notification preference */
$__notifyStmt = $pdo->prepare("SELECT notify_webapp FROM auth_users WHERE id = ? LIMIT 1"); $__notifyStmt = $pdo->prepare("SELECT notify_webapp FROM auth_users WHERE id = ? LIMIT 1");
$__notifyStmt->execute([(int)$iduserlogin]); $__notifyStmt->execute([(int)$iduserlogin]);
@@ -20,8 +17,6 @@ if ((int)$__notifyStmt->fetchColumn() !== 1) {
return; return;
} }
$__trWidgetHr = isset($user)
$__trWidgetHr = isset($user) $__trWidgetHr = isset($user)
&& ($user->hasRole('Admin') && ($user->hasRole('Admin')
|| $user->hasRole('Superuser') || $user->hasRole('Superuser')
@@ -60,8 +55,11 @@ foreach ($__trRows as $__r) {
$__due = DateTime::createFromFormat('Y-m-d', $__r['next_due_date']); $__due = DateTime::createFromFormat('Y-m-d', $__r['next_due_date']);
if (!$__due) continue; if (!$__due) continue;
$__days = (int)$__today->diff($__due)->format('%r%a'); $__days = (int)$__today->diff($__due)->format('%r%a');
if ($__days < 0) { $__expiredCount++; } if ($__days < 0) {
elseif ($__days <= $__rem) { $__dueSoonCount++; } $__expiredCount++;
} elseif ($__days <= $__rem) {
$__dueSoonCount++;
}
} }
/* Missing mandatory trainings (status = not_present) */ /* Missing mandatory trainings (status = not_present) */