fixed color

This commit is contained in:
Claudio 2026-04-28 11:48:35 +02:00
parent 2bbeb11726
commit a1bcab3188
2 changed files with 1580 additions and 831 deletions

View File

@ -51,32 +51,46 @@ if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
$approachDate = date('Y-m-d', strtotime($today . ' + ' . (int)$deadline['notification_days'] . ' days'));
$isApproaching = !$isCompleted && !$isOverdue && $deadline['due_date'] <= $approachDate;
if ($isCompleted) { $statusLabel = 'Completata'; $statusClass = 'badge-completata'; }
elseif ($isOverdue) { $statusLabel = 'Scaduta'; $statusClass = 'badge-scaduta'; }
elseif ($isApproaching) { $statusLabel = 'In scadenza'; $statusClass = 'badge-in-scadenza'; }
else { $statusLabel = 'Attiva'; $statusClass = 'badge-attiva'; }
if ($isCompleted) {
$statusLabel = 'Completata';
$statusClass = 'badge-completata';
} elseif ($isOverdue) {
$statusLabel = 'Scaduta';
$statusClass = 'badge-scaduta';
} elseif ($isApproaching) {
$statusLabel = 'In scadenza';
$statusClass = 'badge-in-scadenza';
} else {
$statusLabel = 'Attiva';
$statusClass = 'badge-attiva';
}
$recurrenceLabels = ['once'=>'Una tantum','monthly'=>'Mensile','quarterly'=>'Trimestrale','semiannual'=>'Semestrale','annual'=>'Annuale','biennial'=>'Biennale','triennial'=>'Triennale','quadriennial'=>'Quadriennale','quinquennial'=>'Quinquennale','decennial'=>'Decennale','quindecennial'=>'Quindicennale'];
$actionLabels = ['created'=>'Creata','updated'=>'Modificata','completed'=>'Completata','attachment_added'=>'Allegato aggiunto','attachment_removed'=>'Allegato rimosso','notification_sent'=>'Notifica inviata'];
$actionColors = ['created'=>'#198754','updated'=>'#5a8fd8','completed'=>'#6f42c1','attachment_added'=>'#e8930c','attachment_removed'=>'#e8930c','notification_sent'=>'#adb5bd'];
$actionIcons = ['created'=>'fa-plus','updated'=>'fa-pen','completed'=>'fa-check','attachment_added'=>'fa-paperclip','attachment_removed'=>'fa-trash','notification_sent'=>'fa-bell'];
$recurrenceLabels = ['once' => 'Una tantum', 'monthly' => 'Mensile', 'quarterly' => 'Trimestrale', 'semiannual' => 'Semestrale', 'annual' => 'Annuale', 'biennial' => 'Biennale', 'triennial' => 'Triennale', 'quadriennial' => 'Quadriennale', 'quinquennial' => 'Quinquennale', 'decennial' => 'Decennale', 'quindecennial' => 'Quindicennale'];
$actionLabels = ['created' => 'Creata', 'updated' => 'Modificata', 'completed' => 'Completata', 'attachment_added' => 'Allegato aggiunto', 'attachment_removed' => 'Allegato rimosso', 'notification_sent' => 'Notifica inviata'];
$actionColors = ['created' => '#198754', 'updated' => '#5a8fd8', 'completed' => '#6f42c1', 'attachment_added' => '#e8930c', 'attachment_removed' => '#e8930c', 'notification_sent' => '#adb5bd'];
$actionIcons = ['created' => 'fa-plus', 'updated' => 'fa-pen', 'completed' => 'fa-check', 'attachment_added' => 'fa-paperclip', 'attachment_removed' => 'fa-trash', 'notification_sent' => 'fa-bell'];
}
}
?>
<!doctype html>
<html lang="it">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php
$scriptDir = dirname($_SERVER['SCRIPT_NAME']);
$baseHref = dirname($scriptDir) . '/';
$scriptDir = dirname($_SERVER['SCRIPT_NAME']);
$baseHref = dirname($scriptDir) . '/';
?>
<base href="<?= $baseHref ?>">
<?php include('../cssinclude.php'); ?>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<title><?= $deadline ? htmlspecialchars($deadline['topic'], ENT_QUOTES, 'UTF-8') . ' — ' : '' ?>Scadenzario</title>
<script>if(window.innerWidth>1024)document.addEventListener('DOMContentLoaded',function(){document.getElementById('appWrapper').classList.add('toggled')})</script>
<script>
if (window.innerWidth > 1024) document.addEventListener('DOMContentLoaded', function() {
document.getElementById('appWrapper').classList.add('toggled')
})
</script>
<style>
:root {
--scad-primary: #5a8fd8;
@ -88,136 +102,426 @@ if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
--scad-orange: #e8930c;
--scad-green: #198754;
}
.scad-card {
border: none; border-radius: 0.75rem;
box-shadow: 0 2px 12px rgba(0,0,0,0.06); overflow: hidden;
border: none;
border-radius: 0.75rem;
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
overflow: hidden;
}
.scad-card .card-header {
background: var(--scad-card-bg);
border-bottom: 1px solid var(--scad-card-border);
padding: 1rem 1.25rem;
}
.scad-card .card-header h5 {
font-weight: 700; color: var(--scad-heading);
margin: 0; font-size: 1.05rem;
font-weight: 700;
color: var(--scad-heading);
margin: 0;
font-size: 1.05rem;
}
.scad-card .card-body {
padding: 1.25rem;
}
.scad-card .card-body { padding: 1.25rem; }
.btn-scad-primary {
background: var(--scad-primary); border: none; color: #fff;
font-weight: 600; font-size: 0.85rem; padding: 0.5rem 1rem;
border-radius: 0.5rem; transition: all 0.2s;
background: var(--scad-primary);
border: none;
color: #fff;
font-weight: 600;
font-size: 0.85rem;
padding: 0.5rem 1rem;
border-radius: 0.5rem;
transition: all 0.2s;
}
.btn-scad-primary:hover { background: var(--scad-primary-hover); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(90,143,216,0.35); }
.btn-scad-primary:hover {
background: var(--scad-primary-hover);
color: #fff;
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(90, 143, 216, 0.35);
}
.btn-scad-outline {
background: transparent; border: 1.5px solid var(--scad-primary); color: var(--scad-primary);
font-weight: 600; font-size: 0.85rem; padding: 0.45rem 1rem; border-radius: 0.5rem; transition: all 0.2s;
background: transparent;
border: 1.5px solid var(--scad-primary);
color: var(--scad-primary);
font-weight: 600;
font-size: 0.85rem;
padding: 0.45rem 1rem;
border-radius: 0.5rem;
transition: all 0.2s;
}
.btn-scad-outline:hover { background: var(--scad-primary); color: #fff; transform: translateY(-1px); }
.btn-scad-outline:hover {
background: var(--scad-primary);
color: #fff;
transform: translateY(-1px);
}
.btn-scad-green {
background: var(--scad-green); border: none; color: #fff;
font-weight: 600; font-size: 0.85rem; padding: 0.5rem 1rem;
border-radius: 0.5rem; transition: all 0.2s;
background: var(--scad-green);
border: none;
color: #fff;
font-weight: 600;
font-size: 0.85rem;
padding: 0.5rem 1rem;
border-radius: 0.5rem;
transition: all 0.2s;
}
.btn-scad-green:hover {
background: #157347;
color: #fff;
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(25, 135, 84, 0.35);
}
.btn-scad-green:hover { background: #157347; color: #fff; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(25,135,84,0.35); }
.badge-status {
font-weight: 600; font-size: 0.8rem; padding: 0.4em 0.75em;
border-radius: 2rem; display: inline-block;
font-weight: 600;
font-size: 0.8rem;
padding: 0.4em 0.75em;
border-radius: 2rem;
display: inline-block;
}
.badge-attiva {
background: #e8eeff;
color: #3a6bb5;
}
.badge-scaduta {
background: #fde8e8;
color: #b91c1c;
}
.badge-in-scadenza {
background: #fef3cd;
color: #92600a;
}
.badge-completata {
background: #d1f2e0;
color: #0f5132;
}
.badge-attiva { background: #e8eeff; color: #3a6bb5; }
.badge-scaduta { background: #fde8e8; color: #b91c1c; }
.badge-in-scadenza{ background: #fef3cd; color: #92600a; }
.badge-completata { background: #d1f2e0; color: #0f5132; }
.detail-label {
font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
letter-spacing: 0.04em; color: #8e99b0; margin-bottom: 0.2rem;
font-size: 0.75rem;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.04em;
color: #8e99b0;
margin-bottom: 0.2rem;
}
.detail-value {
font-size: 0.95rem; color: var(--scad-heading); margin-bottom: 1rem;
font-size: 0.95rem;
color: var(--scad-heading);
margin-bottom: 1rem;
line-height: 1.5;
}
.detail-value.text-danger-date { color: var(--scad-red); font-weight: 600; }
.detail-value.text-warning-date { color: var(--scad-orange); font-weight: 600; }
.detail-value.text-danger-date {
color: var(--scad-red);
font-weight: 600;
}
.detail-value.text-warning-date {
color: var(--scad-orange);
font-weight: 600;
}
.person-chip {
display: inline-flex; align-items: center; gap: 0.4rem;
background: #f0f4ff; border: 1px solid #dde4f0; border-radius: 2rem;
padding: 0.3rem 0.75rem 0.3rem 0.5rem; font-size: 0.85rem;
margin: 0.2rem 0.15rem; color: var(--scad-heading);
display: inline-flex;
align-items: center;
gap: 0.4rem;
background: #f0f4ff;
border: 1px solid #dde4f0;
border-radius: 2rem;
padding: 0.3rem 0.75rem 0.3rem 0.5rem;
font-size: 0.85rem;
margin: 0.2rem 0.15rem;
color: var(--scad-heading);
}
.person-chip i { color: var(--scad-primary); font-size: 0.75rem; }
.person-chip .chip-dept { color: #8e99b0; font-size: 0.78rem; }
.person-chip i {
color: var(--scad-primary);
font-size: 0.75rem;
}
.person-chip .chip-dept {
color: #8e99b0;
font-size: 0.78rem;
}
.dept-chip {
display: inline-flex; align-items: center; gap: 0.4rem;
background: #eef6ee; border: 1px solid #c8e6c9; border-radius: 2rem;
padding: 0.3rem 0.75rem 0.3rem 0.5rem; font-size: 0.85rem;
margin: 0.2rem 0.15rem; color: #2e5e2e;
display: inline-flex;
align-items: center;
gap: 0.4rem;
background: #eef6ee;
border: 1px solid #c8e6c9;
border-radius: 2rem;
padding: 0.3rem 0.75rem 0.3rem 0.5rem;
font-size: 0.85rem;
margin: 0.2rem 0.15rem;
color: #2e5e2e;
}
.dept-chip i {
color: #4caf50;
font-size: 0.75rem;
}
.dept-chip i { color: #4caf50; font-size: 0.75rem; }
/* Attachments */
.att-row {
display: flex; align-items: center; gap: 0.75rem;
padding: 0.65rem 0; border-bottom: 1px solid #f0f2f5;
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.65rem 0;
border-bottom: 1px solid #f0f2f5;
}
.att-row:last-child {
border-bottom: none;
}
.att-icon {
width: 36px;
height: 36px;
border-radius: 0.4rem;
display: flex;
align-items: center;
justify-content: center;
font-size: 1rem;
flex-shrink: 0;
}
.att-icon-pdf {
background: #fde8e8;
color: #b91c1c;
}
.att-icon-img {
background: #e8f5e9;
color: #2e7d32;
}
.att-icon-file {
background: #e8eeff;
color: #3a6bb5;
}
.att-info {
flex: 1;
min-width: 0;
}
.att-name {
font-weight: 600;
color: var(--scad-heading);
font-size: 0.9rem;
text-decoration: none;
word-break: break-all;
}
.att-name:hover {
color: var(--scad-primary);
}
.att-meta {
font-size: 0.78rem;
color: #8e99b0;
}
.att-row:last-child { border-bottom: none; }
.att-icon { width: 36px; height: 36px; border-radius: 0.4rem; display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; }
.att-icon-pdf { background: #fde8e8; color: #b91c1c; }
.att-icon-img { background: #e8f5e9; color: #2e7d32; }
.att-icon-file { background: #e8eeff; color: #3a6bb5; }
.att-info { flex: 1; min-width: 0; }
.att-name { font-weight: 600; color: var(--scad-heading); font-size: 0.9rem; text-decoration: none; word-break: break-all; }
.att-name:hover { color: var(--scad-primary); }
.att-meta { font-size: 0.78rem; color: #8e99b0; }
/* Timeline */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before {
content: ''; position: absolute; left: 0.55rem; top: 0.5rem; bottom: 0.5rem;
width: 2px; background: #e2e8f0;
.timeline {
position: relative;
padding-left: 2rem;
}
.timeline-item { position: relative; padding-bottom: 1.25rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline::before {
content: '';
position: absolute;
left: 0.55rem;
top: 0.5rem;
bottom: 0.5rem;
width: 2px;
background: #e2e8f0;
}
.timeline-item {
position: relative;
padding-bottom: 1.25rem;
}
.timeline-item:last-child {
padding-bottom: 0;
}
.timeline-dot {
position: absolute; left: -1.7rem; top: 0.15rem;
width: 22px; height: 22px; border-radius: 50%;
display: flex; align-items: center; justify-content: center;
font-size: 0.6rem; color: #fff; z-index: 1;
position: absolute;
left: -1.7rem;
top: 0.15rem;
width: 22px;
height: 22px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 0.6rem;
color: #fff;
z-index: 1;
box-shadow: 0 0 0 3px #fff;
}
.timeline-header {
display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
display: flex;
align-items: center;
gap: 0.5rem;
flex-wrap: wrap;
margin-bottom: 0.15rem;
}
.timeline-action { font-weight: 700; font-size: 0.88rem; color: var(--scad-heading); }
.timeline-user { font-size: 0.82rem; color: #6c757d; }
.timeline-date { font-size: 0.78rem; color: #adb5bd; }
.timeline-notes { font-size: 0.83rem; color: #6c757d; margin-top: 0.15rem; }
.timeline-changes { font-size: 0.82rem; margin-top: 0.3rem; background: #f8f9fb; border-radius: 0.4rem; padding: 0.5rem 0.75rem; }
.timeline-changes .change-field { font-weight: 600; color: var(--scad-heading); }
.timeline-changes .change-old { color: var(--scad-red); text-decoration: line-through; }
.timeline-changes .change-new { color: var(--scad-green); }
.scad-breadcrumb { background: transparent; padding: 0; margin-bottom: 1rem; }
.scad-breadcrumb .breadcrumb-item a { color: var(--scad-primary); text-decoration: none; font-weight: 500; transition: color 0.2s; }
.scad-breadcrumb .breadcrumb-item a:hover { color: var(--scad-primary-hover); }
.scad-breadcrumb .breadcrumb-item.active { color: #6c757d; font-weight: 600; }
.timeline-action {
font-weight: 700;
font-size: 0.88rem;
color: var(--scad-heading);
}
.timeline-user {
font-size: 0.82rem;
color: #6c757d;
}
.timeline-date {
font-size: 0.78rem;
color: #adb5bd;
}
.timeline-notes {
font-size: 0.83rem;
color: #6c757d;
margin-top: 0.15rem;
}
.timeline-changes {
font-size: 0.82rem;
margin-top: 0.3rem;
background: #f8f9fb;
border-radius: 0.4rem;
padding: 0.5rem 0.75rem;
}
.timeline-changes .change-field {
font-weight: 600;
color: var(--scad-heading);
}
.timeline-changes .change-old {
color: var(--scad-red);
text-decoration: line-through;
}
.timeline-changes .change-new {
color: var(--scad-green);
}
.scad-breadcrumb {
background: transparent;
padding: 0;
margin-bottom: 1rem;
}
.scad-breadcrumb .breadcrumb-item a {
color: var(--scad-primary);
text-decoration: none;
font-weight: 500;
transition: color 0.2s;
}
.scad-breadcrumb .breadcrumb-item a:hover {
color: var(--scad-primary-hover);
}
.scad-breadcrumb .breadcrumb-item.active {
color: #6c757d;
font-weight: 600;
}
@media (max-width: 575.98px) {
.action-bar { flex-direction: column; }
.action-bar .btn { width: 100%; justify-content: center; }
.action-bar {
flex-direction: column;
}
.action-bar .btn {
width: 100%;
justify-content: center;
}
}
@media print {
.sidebar-wrapper, .topbar, .page-footer, .action-bar, .scad-breadcrumb { display: none !important; }
.page-wrapper { margin: 0 !important; }
.scad-card { box-shadow: none; border: 1px solid #ddd; }
@page { size: portrait; margin: 1cm; }
.sidebar-wrapper,
.topbar,
.page-footer,
.action-bar,
.scad-breadcrumb {
display: none !important;
}
.page-wrapper {
margin: 0 !important;
}
.scad-card {
box-shadow: none;
border: 1px solid #ddd;
}
@page {
size: portrait;
margin: 1cm;
}
}
.ai-law-btn {
display: inline-flex;
align-items: center;
gap: 0.45rem;
margin-left: 0.65rem;
padding: 0.42rem 0.85rem;
border-radius: 999px;
border: 1px solid rgba(90, 143, 216, 0.45);
background: linear-gradient(135deg, #5a8fd8 0%, #6f42c1 100%);
color: #ffffff !important;
font-size: 0.82rem;
font-weight: 800;
line-height: 1;
vertical-align: middle;
cursor: default;
user-select: none;
box-shadow: 0 4px 14px rgba(90, 143, 216, 0.35);
letter-spacing: 0.02em;
white-space: nowrap;
}
.ai-law-btn i {
font-size: 0.82rem;
color: #ffffff;
}
.ai-law-btn:hover {
color: #ffffff !important;
background: linear-gradient(135deg, #4578c0 0%, #5b35a5 100%);
box-shadow: 0 6px 18px rgba(90, 143, 216, 0.45);
transform: translateY(-1px);
}
</style>
</head>
<body>
<div class="wrapper" id="appWrapper">
<?php include('../include/navbar.php'); ?>
@ -247,12 +551,12 @@ if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
<i class="fa-solid fa-arrow-left"></i><span>Torna alla lista</span>
</a>
<?php if (!$isCompleted): ?>
<button class="btn btn-scad-primary d-inline-flex align-items-center gap-2" id="btnModifica">
<i class="fa-solid fa-pen"></i><span>Modifica</span>
</button>
<button class="btn btn-scad-green d-inline-flex align-items-center gap-2" id="btnCompleta">
<i class="fa-solid fa-check"></i><span>Completa</span>
</button>
<button class="btn btn-scad-primary d-inline-flex align-items-center gap-2" id="btnModifica">
<i class="fa-solid fa-pen"></i><span>Modifica</span>
</button>
<button class="btn btn-scad-green d-inline-flex align-items-center gap-2" id="btnCompleta">
<i class="fa-solid fa-check"></i><span>Completa</span>
</button>
<?php endif; ?>
<button class="btn btn-scad-outline d-inline-flex align-items-center gap-2" onclick="window.print()">
<i class="fa-solid fa-print"></i><span>Stampa</span>
@ -269,12 +573,12 @@ if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
<!-- Left Column -->
<div class="col-12 col-md-6">
<?php if (!empty($deadline['subject_name'])): ?>
<div class="detail-label">Argomento</div>
<div class="detail-value">
<span style="display:inline-block;padding:0.25rem 0.7rem;border-radius:1rem;color:#fff;font-weight:600;font-size:0.85rem;background: <?= htmlspecialchars($deadline['subject_color'] ?: '#6c757d', ENT_QUOTES, 'UTF-8') ?>">
<?= htmlspecialchars($deadline['subject_name'], ENT_QUOTES, 'UTF-8') ?>
</span>
</div>
<div class="detail-label">Argomento</div>
<div class="detail-value">
<span style="display:inline-block;padding:0.25rem 0.7rem;border-radius:1rem;color:#fff;font-weight:600;font-size:0.85rem;background: <?= htmlspecialchars($deadline['subject_color'] ?: '#6c757d', ENT_QUOTES, 'UTF-8') ?>">
<?= htmlspecialchars($deadline['subject_name'], ENT_QUOTES, 'UTF-8') ?>
</span>
</div>
<?php endif; ?>
<div class="detail-label">Dettaglio</div>
@ -283,8 +587,15 @@ if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
</div>
<?php if ($deadline['law_regulation']): ?>
<div class="detail-label">Legge / Articolo</div>
<div class="detail-value"><?= htmlspecialchars($deadline['law_regulation'], ENT_QUOTES, 'UTF-8') ?></div>
<div class="detail-label">Legge / Articolo</div>
<div class="detail-value">
<?= htmlspecialchars($deadline['law_regulation'], ENT_QUOTES, 'UTF-8') ?>
<span class="ai-law-btn" title="Funzione AI disponibile prossimamente">
<i class="fa-solid fa-wand-magic-sparkles"></i>
AI
</span>
</div>
<?php endif; ?>
<div class="detail-label">Periodicità</div>
@ -297,7 +608,7 @@ if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
<div class="detail-value">
<span class="badge-status <?= $statusClass ?>"><?= $statusLabel ?></span>
<?php if ($isCompleted && $deadline['completed_at']): ?>
<span class="text-muted ms-2" style="font-size:0.82rem"><?= date('d/m/Y H:i', strtotime($deadline['completed_at'])) ?></span>
<span class="text-muted ms-2" style="font-size:0.82rem"><?= date('d/m/Y H:i', strtotime($deadline['completed_at'])) ?></span>
<?php endif; ?>
</div>
@ -308,8 +619,8 @@ if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
</div>
<?php if ($deadline['document_date']): ?>
<div class="detail-label">Data documento</div>
<div class="detail-value"><?= date('d/m/Y', strtotime($deadline['document_date'])) ?></div>
<div class="detail-label">Data documento</div>
<div class="detail-value"><?= date('d/m/Y', strtotime($deadline['document_date'])) ?></div>
<?php endif; ?>
<div class="detail-label">Data ultimo controllo</div>
@ -319,116 +630,123 @@ if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
<div class="detail-value"><?= (int)$deadline['notification_days'] ?> giorni</div>
<?php if ($deadline['storage_location']): ?>
<div class="detail-label">Luogo archiviazione</div>
<div class="detail-value"><i class="fa-regular fa-folder-open me-1"></i><?= htmlspecialchars($deadline['storage_location'], ENT_QUOTES, 'UTF-8') ?></div>
<div class="detail-label">Luogo archiviazione</div>
<div class="detail-value"><i class="fa-regular fa-folder-open me-1"></i><?= htmlspecialchars($deadline['storage_location'], ENT_QUOTES, 'UTF-8') ?></div>
<?php endif; ?>
<?php if ($deadline['notes']): ?>
<div class="detail-label">Note</div>
<div class="detail-value"><?= nl2br(htmlspecialchars($deadline['notes'], ENT_QUOTES, 'UTF-8')) ?></div>
<div class="detail-label">Note</div>
<div class="detail-value"><?= nl2br(htmlspecialchars($deadline['notes'], ENT_QUOTES, 'UTF-8')) ?></div>
<?php endif; ?>
</div>
</div>
<!-- Responsabili -->
<?php if ($deadline['departments'] || !empty($employees)): ?>
<hr class="my-3" style="border-color:#e8eeff">
<?php if ($deadline['departments']): ?>
<div class="detail-label">Reparti responsabili</div>
<div class="detail-value">
<?php foreach (array_map('trim', explode(',', $deadline['departments'])) as $dept): ?>
<span class="dept-chip"><i class="fa-solid fa-building"></i><?= htmlspecialchars($dept, ENT_QUOTES, 'UTF-8') ?></span>
<?php endforeach; ?>
</div>
<?php endif; ?>
<hr class="my-3" style="border-color:#e8eeff">
<?php if ($deadline['departments']): ?>
<div class="detail-label">Reparti responsabili</div>
<div class="detail-value">
<?php foreach (array_map('trim', explode(',', $deadline['departments'])) as $dept): ?>
<span class="dept-chip"><i class="fa-solid fa-building"></i><?= htmlspecialchars($dept, ENT_QUOTES, 'UTF-8') ?></span>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if (!empty($employees)): ?>
<div class="detail-label">Singoli responsabili</div>
<div class="detail-value">
<?php foreach ($employees as $emp): ?>
<span class="person-chip">
<i class="fa-solid fa-user"></i>
<?= htmlspecialchars(trim($emp['first_name'] . ' ' . $emp['last_name']), ENT_QUOTES, 'UTF-8') ?>
<?php if ($emp['department']): ?>
<span class="chip-dept">(<?= htmlspecialchars($emp['department'], ENT_QUOTES, 'UTF-8') ?>)</span>
<?php endif; ?>
</span>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if (!empty($employees)): ?>
<div class="detail-label">Singoli responsabili</div>
<div class="detail-value">
<?php foreach ($employees as $emp): ?>
<span class="person-chip">
<i class="fa-solid fa-user"></i>
<?= htmlspecialchars(trim($emp['first_name'] . ' ' . $emp['last_name']), ENT_QUOTES, 'UTF-8') ?>
<?php if ($emp['department']): ?>
<span class="chip-dept">(<?= htmlspecialchars($emp['department'], ENT_QUOTES, 'UTF-8') ?>)</span>
<?php endif; ?>
</span>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
</div>
<!-- Attachments Card -->
<?php if (!empty($attachments)): ?>
<div class="card scad-card mb-3">
<div class="card-header">
<h5><i class="fa-solid fa-paperclip me-2"></i>Allegati (<?= count($attachments) ?>)</h5>
</div>
<div class="card-body">
<?php foreach ($attachments as $att):
$mime = $att['mime_type'] ?? '';
if (strpos($mime, 'pdf') !== false) { $iconClass = 'att-icon-pdf'; $icon = 'fa-file-pdf'; }
elseif (strpos($mime, 'image') !== false) { $iconClass = 'att-icon-img'; $icon = 'fa-file-image'; }
else { $iconClass = 'att-icon-file'; $icon = 'fa-file'; }
$sizeKB = round(($att['size'] ?? 0) / 1024, 1);
$sizeStr = $sizeKB >= 1024 ? round($sizeKB / 1024, 1) . ' MB' : $sizeKB . ' KB';
?>
<div class="att-row">
<div class="att-icon <?= $iconClass ?>"><i class="fa-solid <?= $icon ?>"></i></div>
<div class="att-info">
<a href="scadenzario/ajax/download_attachment.php?id=<?= (int)$att['id'] ?>" class="att-name"><?= htmlspecialchars($att['original_name'], ENT_QUOTES, 'UTF-8') ?></a>
<div class="att-meta"><?= $sizeStr ?> · <?= date('d/m/Y', strtotime($att['created_at'])) ?></div>
</div>
<div class="card scad-card mb-3">
<div class="card-header">
<h5><i class="fa-solid fa-paperclip me-2"></i>Allegati (<?= count($attachments) ?>)</h5>
</div>
<div class="card-body">
<?php foreach ($attachments as $att):
$mime = $att['mime_type'] ?? '';
if (strpos($mime, 'pdf') !== false) {
$iconClass = 'att-icon-pdf';
$icon = 'fa-file-pdf';
} elseif (strpos($mime, 'image') !== false) {
$iconClass = 'att-icon-img';
$icon = 'fa-file-image';
} else {
$iconClass = 'att-icon-file';
$icon = 'fa-file';
}
$sizeKB = round(($att['size'] ?? 0) / 1024, 1);
$sizeStr = $sizeKB >= 1024 ? round($sizeKB / 1024, 1) . ' MB' : $sizeKB . ' KB';
?>
<div class="att-row">
<div class="att-icon <?= $iconClass ?>"><i class="fa-solid <?= $icon ?>"></i></div>
<div class="att-info">
<a href="scadenzario/ajax/download_attachment.php?id=<?= (int)$att['id'] ?>" class="att-name"><?= htmlspecialchars($att['original_name'], ENT_QUOTES, 'UTF-8') ?></a>
<div class="att-meta"><?= $sizeStr ?> · <?= date('d/m/Y', strtotime($att['created_at'])) ?></div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<!-- History Card -->
<?php if (!empty($history)): ?>
<div class="card scad-card mb-3">
<div class="card-header">
<h5><i class="fa-solid fa-clock-rotate-left me-2"></i>Cronologia</h5>
</div>
<div class="card-body">
<div class="timeline">
<?php foreach ($history as $h):
$color = $actionColors[$h['action']] ?? '#adb5bd';
$iconCls = $actionIcons[$h['action']] ?? 'fa-circle';
$label = $actionLabels[$h['action']] ?? $h['action'];
$userName = trim(($h['user_fname'] ?? '') . ' ' . ($h['user_lname'] ?? '')) ?: 'Sistema';
$changes = $h['changes'] ? json_decode($h['changes'], true) : null;
?>
<div class="timeline-item">
<div class="timeline-dot" style="background:<?= $color ?>"><i class="fa-solid <?= $iconCls ?>"></i></div>
<div class="timeline-header">
<span class="timeline-action"><?= htmlspecialchars($label, ENT_QUOTES, 'UTF-8') ?></span>
<span class="timeline-user">da <?= htmlspecialchars($userName, ENT_QUOTES, 'UTF-8') ?></span>
<span class="timeline-date"><?= date('d/m/Y H:i', strtotime($h['created_at'])) ?></span>
</div>
<?php if ($h['notes']): ?>
<div class="timeline-notes"><i class="fa-regular fa-comment me-1"></i><?= htmlspecialchars($h['notes'], ENT_QUOTES, 'UTF-8') ?></div>
<?php endif; ?>
<?php if ($changes && is_array($changes)): ?>
<div class="timeline-changes">
<?php foreach ($changes as $field => $vals): ?>
<div>
<span class="change-field"><?= htmlspecialchars($field, ENT_QUOTES, 'UTF-8') ?>:</span>
<span class="change-old"><?= htmlspecialchars($vals['old'] ?? '—', ENT_QUOTES, 'UTF-8') ?></span>
<span class="change-new"><?= htmlspecialchars($vals['new'] ?? '—', ENT_QUOTES, 'UTF-8') ?></span>
<div class="card scad-card mb-3">
<div class="card-header">
<h5><i class="fa-solid fa-clock-rotate-left me-2"></i>Cronologia</h5>
</div>
<div class="card-body">
<div class="timeline">
<?php foreach ($history as $h):
$color = $actionColors[$h['action']] ?? '#adb5bd';
$iconCls = $actionIcons[$h['action']] ?? 'fa-circle';
$label = $actionLabels[$h['action']] ?? $h['action'];
$userName = trim(($h['user_fname'] ?? '') . ' ' . ($h['user_lname'] ?? '')) ?: 'Sistema';
$changes = $h['changes'] ? json_decode($h['changes'], true) : null;
?>
<div class="timeline-item">
<div class="timeline-dot" style="background:<?= $color ?>"><i class="fa-solid <?= $iconCls ?>"></i></div>
<div class="timeline-header">
<span class="timeline-action"><?= htmlspecialchars($label, ENT_QUOTES, 'UTF-8') ?></span>
<span class="timeline-user">da <?= htmlspecialchars($userName, ENT_QUOTES, 'UTF-8') ?></span>
<span class="timeline-date"><?= date('d/m/Y H:i', strtotime($h['created_at'])) ?></span>
</div>
<?php if ($h['notes']): ?>
<div class="timeline-notes"><i class="fa-regular fa-comment me-1"></i><?= htmlspecialchars($h['notes'], ENT_QUOTES, 'UTF-8') ?></div>
<?php endif; ?>
<?php if ($changes && is_array($changes)): ?>
<div class="timeline-changes">
<?php foreach ($changes as $field => $vals): ?>
<div>
<span class="change-field"><?= htmlspecialchars($field, ENT_QUOTES, 'UTF-8') ?>:</span>
<span class="change-old"><?= htmlspecialchars($vals['old'] ?? '—', ENT_QUOTES, 'UTF-8') ?></span>
<span class="change-new"><?= htmlspecialchars($vals['new'] ?? '—', ENT_QUOTES, 'UTF-8') ?></span>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php endforeach; ?>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
<?php endif; ?>
<?php endif; ?>
@ -439,38 +757,51 @@ if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
</div>
<?php include('../jsinclude.php'); ?>
<?php if ($deadline && !$isCompleted): ?>
<script>
$(document).ready(function() {
$('#btnModifica').on('click', function() {
window.location.href = 'scadenzario/index.php?edit=<?= (int)$deadline['id'] ?>';
});
<script>
$(document).ready(function() {
$('#btnModifica').on('click', function() {
window.location.href = 'scadenzario/index.php?edit=<?= (int)$deadline['id'] ?>';
});
$('#btnCompleta').on('click', function() {
Swal.fire({
title: 'Completare la scadenza?',
icon: 'question',
showCancelButton: true,
confirmButtonColor: '#198754',
cancelButtonText: 'Annulla',
confirmButtonText: 'Completa'
}).then(function(result) {
if (result.isConfirmed) {
fetch('scadenzario/ajax/complete_deadline.php?id=<?= (int)$deadline['id'] ?>')
.then(function(r) { return r.json(); })
.then(function(data) {
if (data.success) {
Swal.fire({ icon: 'success', title: 'Completata', text: data.message, timer: 2500, showConfirmButton: false })
.then(function() { window.location.href = 'scadenzario/index.php'; });
} else {
Swal.fire('Errore', data.message, 'error');
}
})
.catch(function() { Swal.fire('Errore', 'Errore di connessione.', 'error'); });
}
$('#btnCompleta').on('click', function() {
Swal.fire({
title: 'Completare la scadenza?',
icon: 'question',
showCancelButton: true,
confirmButtonColor: '#198754',
cancelButtonText: 'Annulla',
confirmButtonText: 'Completa'
}).then(function(result) {
if (result.isConfirmed) {
fetch('scadenzario/ajax/complete_deadline.php?id=<?= (int)$deadline['id'] ?>')
.then(function(r) {
return r.json();
})
.then(function(data) {
if (data.success) {
Swal.fire({
icon: 'success',
title: 'Completata',
text: data.message,
timer: 2500,
showConfirmButton: false
})
.then(function() {
window.location.href = 'scadenzario/index.php';
});
} else {
Swal.fire('Errore', data.message, 'error');
}
})
.catch(function() {
Swal.fire('Errore', 'Errore di connessione.', 'error');
});
}
});
});
});
});
});
</script>
</script>
<?php endif; ?>
</body>
</html>
</html>

File diff suppressed because it is too large Load Diff