fixe widget
This commit is contained in:
@@ -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]);
|
||||||
@@ -21,9 +18,7 @@ if ((int)$__notifyStmt->fetchColumn() !== 1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$__trWidgetHr = isset($user)
|
$__trWidgetHr = isset($user)
|
||||||
|
&& ($user->hasRole('Admin')
|
||||||
$__trWidgetHr = isset($user)
|
|
||||||
&& ( $user->hasRole('Admin')
|
|
||||||
|| $user->hasRole('Superuser')
|
|| $user->hasRole('Superuser')
|
||||||
|| $user->hasRole('employee-hr')
|
|| $user->hasRole('employee-hr')
|
||||||
|| $user->hasRole('manager'));
|
|| $user->hasRole('manager'));
|
||||||
@@ -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) */
|
||||||
@@ -81,34 +79,34 @@ if ($__expiredCount === 0 && $__dueSoonCount === 0 && $__notPresentCount === 0)
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<div class="my-deadlines-widgets">
|
<div class="my-deadlines-widgets">
|
||||||
<?php if ($__expiredCount > 0): ?>
|
<?php if ($__expiredCount > 0): ?>
|
||||||
<a class="mdw mdw-red" href="trainings.php?status=expired">
|
<a class="mdw mdw-red" href="trainings.php?status=expired">
|
||||||
<span class="mdw-icon"><i class="fa-solid fa-graduation-cap"></i></span>
|
<span class="mdw-icon"><i class="fa-solid fa-graduation-cap"></i></span>
|
||||||
<span class="mdw-body">
|
<span class="mdw-body">
|
||||||
<span class="mdw-count"><?= (int)$__expiredCount ?></span>
|
<span class="mdw-count"><?= (int)$__expiredCount ?></span>
|
||||||
<span class="mdw-label d-block">Formazion<?= $__expiredCount === 1 ? 'e scaduta' : 'i scadute' ?></span>
|
<span class="mdw-label d-block">Formazion<?= $__expiredCount === 1 ? 'e scaduta' : 'i scadute' ?></span>
|
||||||
</span>
|
</span>
|
||||||
<span class="mdw-arrow"><i class="fa-solid fa-arrow-right"></i></span>
|
<span class="mdw-arrow"><i class="fa-solid fa-arrow-right"></i></span>
|
||||||
</a>
|
</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($__dueSoonCount > 0): ?>
|
<?php if ($__dueSoonCount > 0): ?>
|
||||||
<a class="mdw mdw-orange" href="trainings.php?status=due_soon">
|
<a class="mdw mdw-orange" href="trainings.php?status=due_soon">
|
||||||
<span class="mdw-icon"><i class="fa-solid fa-hourglass-half"></i></span>
|
<span class="mdw-icon"><i class="fa-solid fa-hourglass-half"></i></span>
|
||||||
<span class="mdw-body">
|
<span class="mdw-body">
|
||||||
<span class="mdw-count"><?= (int)$__dueSoonCount ?></span>
|
<span class="mdw-count"><?= (int)$__dueSoonCount ?></span>
|
||||||
<span class="mdw-label d-block">Formazion<?= $__dueSoonCount === 1 ? 'e da aggiornare' : 'i da aggiornare' ?></span>
|
<span class="mdw-label d-block">Formazion<?= $__dueSoonCount === 1 ? 'e da aggiornare' : 'i da aggiornare' ?></span>
|
||||||
</span>
|
</span>
|
||||||
<span class="mdw-arrow"><i class="fa-solid fa-arrow-right"></i></span>
|
<span class="mdw-arrow"><i class="fa-solid fa-arrow-right"></i></span>
|
||||||
</a>
|
</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($__notPresentCount > 0): ?>
|
<?php if ($__notPresentCount > 0): ?>
|
||||||
<a class="mdw mdw-gray" href="trainings.php?status=not_present">
|
<a class="mdw mdw-gray" href="trainings.php?status=not_present">
|
||||||
<span class="mdw-icon"><i class="fa-solid fa-circle-question"></i></span>
|
<span class="mdw-icon"><i class="fa-solid fa-circle-question"></i></span>
|
||||||
<span class="mdw-body">
|
<span class="mdw-body">
|
||||||
<span class="mdw-count"><?= (int)$__notPresentCount ?></span>
|
<span class="mdw-count"><?= (int)$__notPresentCount ?></span>
|
||||||
<span class="mdw-label d-block">Obbligator<?= $__notPresentCount === 1 ? 'ia non presente' : 'ie non presenti' ?></span>
|
<span class="mdw-label d-block">Obbligator<?= $__notPresentCount === 1 ? 'ia non presente' : 'ie non presenti' ?></span>
|
||||||
</span>
|
</span>
|
||||||
<span class="mdw-arrow"><i class="fa-solid fa-arrow-right"></i></span>
|
<span class="mdw-arrow"><i class="fa-solid fa-arrow-right"></i></span>
|
||||||
</a>
|
</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
Reference in New Issue
Block a user