807 lines
32 KiB
PHP
807 lines
32 KiB
PHP
<?php include('../include/headscript.php'); ?>
|
|
<?php
|
|
$db = DBHandlerSelect::getInstance();
|
|
$pdo = $db->getConnection();
|
|
$error = null;
|
|
$deadline = null;
|
|
|
|
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
|
|
$error = 'ID non valido.';
|
|
} else {
|
|
$id = (int)$_GET['id'];
|
|
$stmt = $pdo->prepare("
|
|
SELECT d.*, s.name AS subject_name, s.color AS subject_color
|
|
FROM scad_deadlines d
|
|
LEFT JOIN scad_subjects s ON s.id = d.subject_id
|
|
WHERE d.id = ?
|
|
");
|
|
$stmt->execute([$id]);
|
|
$deadline = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
if (!$deadline) {
|
|
$error = 'Scadenza non trovata.';
|
|
} else {
|
|
$empStmt = $pdo->prepare("
|
|
SELECT e.first_name, e.last_name, e.department
|
|
FROM scad_deadline_employee de
|
|
JOIN employees e ON e.id = de.employee_id
|
|
WHERE de.deadline_id = ?
|
|
ORDER BY e.first_name
|
|
");
|
|
$empStmt->execute([$id]);
|
|
$employees = $empStmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
$attStmt = $pdo->prepare("SELECT * FROM scad_deadline_attachments WHERE deadline_id = ? ORDER BY created_at DESC");
|
|
$attStmt->execute([$id]);
|
|
$attachments = $attStmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
$histStmt = $pdo->prepare("
|
|
SELECT h.*, au.first_name as user_fname, au.last_name as user_lname
|
|
FROM scad_deadline_histories h
|
|
LEFT JOIN auth_users au ON au.id = h.user_id
|
|
WHERE h.deadline_id = ?
|
|
ORDER BY h.created_at DESC
|
|
");
|
|
$histStmt->execute([$id]);
|
|
$history = $histStmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
$today = date('Y-m-d');
|
|
$isCompleted = $deadline['status'] === 'completed';
|
|
$isOverdue = !$isCompleted && $deadline['due_date'] < $today;
|
|
$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';
|
|
}
|
|
|
|
$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) . '/';
|
|
?>
|
|
<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>
|
|
<style>
|
|
:root {
|
|
--scad-primary: #5a8fd8;
|
|
--scad-primary-hover: #4578c0;
|
|
--scad-heading: #2c3e6b;
|
|
--scad-card-bg: linear-gradient(135deg, #f0f4ff 0%, #e8eeff 100%);
|
|
--scad-card-border: #dde4f0;
|
|
--scad-red: #dc3545;
|
|
--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;
|
|
}
|
|
|
|
.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;
|
|
}
|
|
|
|
.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;
|
|
}
|
|
|
|
.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;
|
|
}
|
|
|
|
.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;
|
|
}
|
|
|
|
.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;
|
|
}
|
|
|
|
.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;
|
|
}
|
|
|
|
.detail-value {
|
|
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;
|
|
}
|
|
|
|
.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);
|
|
}
|
|
|
|
.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;
|
|
}
|
|
|
|
.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;
|
|
}
|
|
|
|
.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-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;
|
|
box-shadow: 0 0 0 3px #fff;
|
|
}
|
|
|
|
.timeline-header {
|
|
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;
|
|
}
|
|
|
|
@media (max-width: 575.98px) {
|
|
.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;
|
|
}
|
|
}
|
|
|
|
.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'); ?>
|
|
<?php include('../include/topbar.php'); ?>
|
|
<div class="page-wrapper">
|
|
<div class="page-content">
|
|
|
|
<?php if ($error): ?>
|
|
<div class="alert alert-danger">
|
|
<i class="fa-solid fa-triangle-exclamation me-2"></i><?= htmlspecialchars($error, ENT_QUOTES, 'UTF-8') ?>
|
|
<a href="scadenzario/index.php" class="alert-link ms-2">Torna alla lista</a>
|
|
</div>
|
|
<?php else: ?>
|
|
|
|
<!-- Breadcrumb -->
|
|
<nav class="scad-breadcrumb" aria-label="breadcrumb">
|
|
<ol class="breadcrumb mb-0">
|
|
<li class="breadcrumb-item"><a href="scadenzario/index.php">Scadenzario</a></li>
|
|
<li class="breadcrumb-item"><a href="scadenzario/index.php">Lista Scadenze</a></li>
|
|
<li class="breadcrumb-item active" aria-current="page"><?= htmlspecialchars($deadline['topic'], ENT_QUOTES, 'UTF-8') ?></li>
|
|
</ol>
|
|
</nav>
|
|
|
|
<!-- Action Bar -->
|
|
<div class="action-bar d-flex gap-2 mb-3 flex-wrap">
|
|
<a href="scadenzario/index.php" class="btn btn-scad-outline d-inline-flex align-items-center gap-2">
|
|
<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>
|
|
<?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>
|
|
</button>
|
|
</div>
|
|
|
|
<!-- Main Detail Card -->
|
|
<div class="card scad-card mb-3">
|
|
<div class="card-header">
|
|
<h5><i class="fa-solid fa-file-lines me-2"></i>Dettagli Scadenza</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<!-- 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>
|
|
<?php endif; ?>
|
|
|
|
<div class="detail-label">Dettaglio</div>
|
|
<div class="detail-value" style="font-size:1.15rem; font-weight:700;">
|
|
<?= htmlspecialchars($deadline['topic'], ENT_QUOTES, 'UTF-8') ?>
|
|
</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') ?>
|
|
|
|
<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>
|
|
<div class="detail-value"><?= htmlspecialchars($recurrenceLabels[$deadline['recurrence_type']] ?? $deadline['recurrence_type'], ENT_QUOTES, 'UTF-8') ?></div>
|
|
</div>
|
|
|
|
<!-- Right Column -->
|
|
<div class="col-12 col-md-6">
|
|
<div class="detail-label">Stato</div>
|
|
<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>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="detail-label">Data scadenza</div>
|
|
<div class="detail-value <?= $isOverdue ? 'text-danger-date' : ($isApproaching ? 'text-warning-date' : '') ?>">
|
|
<i class="fa-regular fa-calendar me-1"></i><?= date('d/m/Y', strtotime($deadline['due_date'])) ?>
|
|
<?php if ($isOverdue): ?><span class="ms-1" style="font-size:0.8rem">(scaduta)</span><?php endif; ?>
|
|
</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>
|
|
<?php endif; ?>
|
|
|
|
<div class="detail-label">Data ultimo controllo</div>
|
|
<div class="detail-value"><?= $deadline['check_date'] ? date('d/m/Y', strtotime($deadline['check_date'])) : '—' ?></div>
|
|
|
|
<div class="detail-label">Giorni preavviso notifica</div>
|
|
<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>
|
|
<?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>
|
|
<?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; ?>
|
|
|
|
<?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>
|
|
<?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>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php endif; ?>
|
|
|
|
</div>
|
|
</div>
|
|
<?php include('../include/footer.php'); ?>
|
|
</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'] ?>';
|
|
});
|
|
|
|
$('#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>
|
|
<?php endif; ?>
|
|
</body>
|
|
|
|
</html>
|