added functions

This commit is contained in:
2026-05-22 09:16:46 +02:00
parent 650676037a
commit e74870c8d3
6 changed files with 715 additions and 14 deletions
+58 -2
View File
@@ -37,12 +37,14 @@ $sql = "
SELECT d.*,
s.name AS subject_name,
s.color AS subject_color,
f.name AS function_name,
GROUP_CONCAT(DISTINCT CONCAT(e.first_name, ' ', e.last_name) ORDER BY e.first_name SEPARATOR ', ') as responsabili,
GROUP_CONCAT(DISTINCT dep.name ORDER BY dep.name SEPARATOR ', ') as reparti_persone,
d.departments as reparti_assegnati,
(SELECT COUNT(*) FROM scad_deadline_attachments att WHERE att.deadline_id = d.id) as attachment_count
FROM scad_deadlines d
LEFT JOIN scad_subjects s ON s.id = d.subject_id
LEFT JOIN scad_functions f ON f.id = d.function_id
LEFT JOIN scad_deadline_employee de ON de.deadline_id = d.id
LEFT JOIN employees e ON e.id = de.employee_id
LEFT JOIN departments dep ON dep.id = e.department_id
@@ -91,6 +93,13 @@ $departments = $pdo->query("
$subjects = $pdo->query("SELECT id, name, color FROM scad_subjects ORDER BY name")->fetchAll(PDO::FETCH_ASSOC);
$functions = $pdo->query("
SELECT id, name
FROM scad_functions
WHERE status = 'active'
ORDER BY name ASC
")->fetchAll(PDO::FETCH_ASSOC);
$today = date('Y-m-d');
function getContrastTextColor($hexColor)
@@ -494,7 +503,8 @@ function getContrastTextColor($hexColor)
}
#deadlinesTable td:first-child {
max-width: 150px;
max-width: 110px;
width: 110px;
}
/* Attachment list in modal */
@@ -824,6 +834,9 @@ function getContrastTextColor($hexColor)
<a href="scadenzario/subjects/index.php" class="btn btn-scad-outline d-none d-md-inline-flex align-items-center gap-2">
<i class="fa-solid fa-tags"></i><span>Argomenti</span>
</a>
<a href="scadenzario/functions/index.php" class="btn btn-scad-outline d-none d-md-inline-flex align-items-center gap-2">
<i class="fa-solid fa-briefcase"></i><span>Funzioni</span>
</a>
<a href="scadenzario/calendar.php" class="btn btn-scad-outline d-none d-md-inline-flex align-items-center gap-2">
<i class="fa-solid fa-calendar-days"></i><span>Calendario</span>
</a>
@@ -842,6 +855,7 @@ function getContrastTextColor($hexColor)
</button>
<ul class="dropdown-menu dropdown-menu-end">
<li><a class="dropdown-item d-flex align-items-center gap-2" href="scadenzario/subjects/index.php"><i class="fa-solid fa-tags"></i> Argomenti</a></li>
<li><a class="dropdown-item d-flex align-items-center gap-2" href="scadenzario/functions/index.php"><i class="fa-solid fa-briefcase"></i> Funzioni</a></li>
<li><a class="dropdown-item d-flex align-items-center gap-2" href="scadenzario/calendar.php"><i class="fa-solid fa-calendar-days"></i> Calendario</a></li>
<li><button type="button" class="dropdown-item d-flex align-items-center gap-2" id="btnStampaMobile"><i class="fa-solid fa-print"></i> Stampa</button></li>
</ul>
@@ -972,11 +986,12 @@ function getContrastTextColor($hexColor)
<table id="deadlinesTable" class="table table-hover align-middle mb-0" style="width:100%">
<thead>
<tr>
<th>Argomento</th>
<th style="width:110px">Argomento</th>
<th>Dettaglio</th>
<th class="d-none d-lg-table-cell">Legge/Art.</th>
<th>Scadenza</th>
<th class="d-none d-lg-table-cell">Verifica</th>
<th>Funzione</th>
<th>Responsabili</th>
<th>Stato</th>
<th class="text-center" style="width:120px">Azioni</th>
@@ -1014,6 +1029,7 @@ function getContrastTextColor($hexColor)
<span class="text-muted"></span>
<?php endif; ?>
</td>
<td>
<a href="scadenzario/detail.php?id=<?= (int)$row['id'] ?>" class="fw-semibold text-decoration-none" style="color:var(--scad-heading)"><?= htmlspecialchars($row['topic'], ENT_QUOTES, 'UTF-8') ?></a>
<?php if ((int)$row['attachment_count'] > 0): ?>
@@ -1023,6 +1039,17 @@ function getContrastTextColor($hexColor)
<td class="d-none d-lg-table-cell text-muted"><?= htmlspecialchars($row['law_regulation'] ?? '—', ENT_QUOTES, 'UTF-8') ?></td>
<td><span class="text-nowrap"><?= $row['_dueFmt'] ?></span></td>
<td class="d-none d-lg-table-cell text-muted"><?= $row['_checkFmt'] ?></td>
<td>
<?php if (!empty($row['function_name'])): ?>
<span class="text-muted">
<i class="fa-solid fa-briefcase me-1"></i>
<?= htmlspecialchars($row['function_name'], ENT_QUOTES, 'UTF-8') ?>
</span>
<?php else: ?>
<span class="text-muted"></span>
<?php endif; ?>
</td>
<td>
<?php if ($row['reparti']): ?><span class="text-muted"><i class="fa-regular fa-building me-1"></i><?= htmlspecialchars($row['reparti'], ENT_QUOTES, 'UTF-8') ?></span><?php endif; ?>
<?php if ($row['reparti'] && $row['responsabili']): ?><br><?php endif; ?>
@@ -1084,6 +1111,23 @@ function getContrastTextColor($hexColor)
</a>
</div>
</div>
<div class="col-12 col-md-6">
<label for="dlFunction" class="form-label fw-semibold">Funzione</label>
<div class="d-flex gap-2">
<select class="form-select" id="dlFunction" name="function_id" style="flex:1">
<option value=""> Nessuna </option>
<?php foreach ($functions as $fn): ?>
<option value="<?= (int)$fn['id'] ?>">
<?= htmlspecialchars($fn['name'], ENT_QUOTES, 'UTF-8') ?>
</option>
<?php endforeach; ?>
</select>
<a href="scadenzario/functions/index.php" target="_blank" class="btn btn-scad-outline" title="Gestisci funzioni">
<i class="fa-solid fa-gear"></i>
</a>
</div>
</div>
<div class="col-12 col-md-6">
<label for="dlLaw" class="form-label fw-semibold">Legge / Articolo</label>
<input type="text" class="form-control" id="dlLaw" name="law_regulation" maxlength="500" placeholder="es. D.Lgs. 81/2008, D.M. 10.03.1998...">
@@ -1258,6 +1302,15 @@ function getContrastTextColor($hexColor)
width: '100%'
});
$('#dlFunction').select2({
theme: 'bootstrap-5',
placeholder: 'Seleziona funzione...',
allowClear: true,
dropdownParent: $('#deadlineModal .modal-body'),
language: 'it',
width: '100%'
});
$('#dlDepartments').select2({
theme: 'bootstrap-5',
placeholder: 'Seleziona reparti...',
@@ -1506,6 +1559,7 @@ function getContrastTextColor($hexColor)
fpCheckDate.clear();
$('#dlSubject').val('').trigger('change');
$('#dlFunction').val('').trigger('change');
$('#dlDepartments').val(null).trigger('change');
$('#dlEmployees').val(null).trigger('change');
@@ -1671,6 +1725,7 @@ function getContrastTextColor($hexColor)
document.getElementById('dlId').value = d.id;
$('#dlSubject').val(d.subject_id || '').trigger('change');
$('#dlFunction').val(d.function_id || '').trigger('change');
document.getElementById('dlTopic').value = d.topic || '';
document.getElementById('dlLaw').value = d.law_regulation || '';
document.getElementById('dlRecurrence').value = d.recurrence_type || 'once';
@@ -1797,6 +1852,7 @@ function getContrastTextColor($hexColor)
var d = data.data;
document.getElementById('dlId').value = d.id;
$('#dlSubject').val(d.subject_id || '').trigger('change');
$('#dlFunction').val(d.function_id || '').trigger('change');
document.getElementById('dlTopic').value = d.topic || '';
document.getElementById('dlLaw').value = d.law_regulation || '';
document.getElementById('dlRecurrence').value = d.recurrence_type || 'once';