fix initial+refresher
This commit is contained in:
@@ -103,6 +103,15 @@ if ($employee) {
|
||||
$stmt->execute(['eid' => $employeeId]);
|
||||
$trainings = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Mark the most recent record per topic — older ones are history, not "expired".
|
||||
$seenTopics = [];
|
||||
foreach ($trainings as &$t) {
|
||||
$tid = (int)$t['training_topic_id'];
|
||||
$t['_is_latest'] = !isset($seenTopics[$tid]);
|
||||
$seenTopics[$tid] = true;
|
||||
}
|
||||
unset($t);
|
||||
|
||||
if ($canEdit) {
|
||||
$trainingTopicsAll = $pdo->query("
|
||||
SELECT id, name, default_frequency_months, default_reminder_days
|
||||
@@ -270,6 +279,7 @@ function fmtFileSize(?int $bytes): string {
|
||||
.pill-status-success { background: #d1fae5; color: #065f46; }
|
||||
.pill-status-secondary { background: #e5e7eb; color: #374151; }
|
||||
.pill-status-warning { background: #fef3c7; color: #92400e; }
|
||||
.pill-status-danger { background: #fee2e2; color: #991b1b; }
|
||||
|
||||
.nav-tabs {
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
@@ -871,9 +881,11 @@ function fmtFileSize(?int $bytes): string {
|
||||
<?php foreach ($trainings as $t): ?>
|
||||
<?php
|
||||
$tid = (int)$t['id'];
|
||||
$s = trainingStatus($t['next_due_date'] ?: null,
|
||||
$s = !empty($t['_is_latest'])
|
||||
? trainingStatus($t['next_due_date'] ?: null,
|
||||
$t['reminder_days'] !== null ? (int)$t['reminder_days'] : null,
|
||||
$t['topic_default_rem'] !== null ? (int)$t['topic_default_rem'] : null);
|
||||
$t['topic_default_rem'] !== null ? (int)$t['topic_default_rem'] : null)
|
||||
: ['code' => 'storico', 'label' => 'Storico', 'class' => 'secondary'];
|
||||
$typeLabel = $t['training_type'] === 'refresher' ? 'Aggiornamento' : 'Iniziale';
|
||||
?>
|
||||
<tr>
|
||||
@@ -918,9 +930,11 @@ function fmtFileSize(?int $bytes): string {
|
||||
<?php foreach ($trainings as $t): ?>
|
||||
<?php
|
||||
$tid = (int)$t['id'];
|
||||
$s = trainingStatus($t['next_due_date'] ?: null,
|
||||
$s = !empty($t['_is_latest'])
|
||||
? trainingStatus($t['next_due_date'] ?: null,
|
||||
$t['reminder_days'] !== null ? (int)$t['reminder_days'] : null,
|
||||
$t['topic_default_rem'] !== null ? (int)$t['topic_default_rem'] : null);
|
||||
$t['topic_default_rem'] !== null ? (int)$t['topic_default_rem'] : null)
|
||||
: ['code' => 'storico', 'label' => 'Storico', 'class' => 'secondary'];
|
||||
$typeLabel = $t['training_type'] === 'refresher' ? 'Aggiornamento' : 'Iniziale';
|
||||
?>
|
||||
<div class="doc-card">
|
||||
|
||||
Reference in New Issue
Block a user