added alert flag and variation flag
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class ChangeVariazioniToFlag extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$this->execute("ALTER TABLE `scad_deadlines`
|
||||
CHANGE `variazioni` `variazioni` TINYINT(1) NOT NULL DEFAULT 0
|
||||
COMMENT 'Flag: in caso di variazioni'");
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
$this->execute("ALTER TABLE `scad_deadlines`
|
||||
CHANGE `variazioni` `variazioni` TEXT NULL DEFAULT NULL");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class SetAttivaAlertDefaultOn extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$this->execute("ALTER TABLE `scad_deadlines`
|
||||
CHANGE `attiva_alert` `attiva_alert` TINYINT(1) NOT NULL DEFAULT 1");
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
$this->execute("ALTER TABLE `scad_deadlines`
|
||||
CHANGE `attiva_alert` `attiva_alert` TINYINT(1) NOT NULL DEFAULT 0");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class EnableAttivaAlertOnExisting extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$this->execute("UPDATE `scad_deadlines`
|
||||
SET `attiva_alert` = 1
|
||||
WHERE `status` = 'active'");
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
$this->execute("UPDATE `scad_deadlines`
|
||||
SET `attiva_alert` = 0
|
||||
WHERE `status` = 'active'");
|
||||
}
|
||||
}
|
||||
@@ -50,17 +50,38 @@ try {
|
||||
$documentDate = $deadline['document_date'] ? new DateTime($deadline['document_date']) : null;
|
||||
|
||||
switch ($deadline['recurrence_type']) {
|
||||
case 'monthly': $interval = new DateInterval('P1M'); break;
|
||||
case 'quarterly': $interval = new DateInterval('P3M'); break;
|
||||
case 'semiannual': $interval = new DateInterval('P6M'); break;
|
||||
case 'annual': $interval = new DateInterval('P1Y'); break;
|
||||
case 'biennial': $interval = new DateInterval('P2Y'); break;
|
||||
case 'triennial': $interval = new DateInterval('P3Y'); break;
|
||||
case 'quadriennial': $interval = new DateInterval('P4Y'); break;
|
||||
case 'quinquennial': $interval = new DateInterval('P5Y'); break;
|
||||
case 'decennial': $interval = new DateInterval('P10Y'); break;
|
||||
case 'quindecennial': $interval = new DateInterval('P15Y'); break;
|
||||
default: $interval = null;
|
||||
case 'monthly':
|
||||
$interval = new DateInterval('P1M');
|
||||
break;
|
||||
case 'quarterly':
|
||||
$interval = new DateInterval('P3M');
|
||||
break;
|
||||
case 'semiannual':
|
||||
$interval = new DateInterval('P6M');
|
||||
break;
|
||||
case 'annual':
|
||||
$interval = new DateInterval('P1Y');
|
||||
break;
|
||||
case 'biennial':
|
||||
$interval = new DateInterval('P2Y');
|
||||
break;
|
||||
case 'triennial':
|
||||
$interval = new DateInterval('P3Y');
|
||||
break;
|
||||
case 'quadriennial':
|
||||
$interval = new DateInterval('P4Y');
|
||||
break;
|
||||
case 'quinquennial':
|
||||
$interval = new DateInterval('P5Y');
|
||||
break;
|
||||
case 'decennial':
|
||||
$interval = new DateInterval('P10Y');
|
||||
break;
|
||||
case 'quindecennial':
|
||||
$interval = new DateInterval('P15Y');
|
||||
break;
|
||||
default:
|
||||
$interval = null;
|
||||
}
|
||||
|
||||
if ($interval) {
|
||||
@@ -70,17 +91,27 @@ try {
|
||||
|
||||
$ins = $pdo->prepare("
|
||||
INSERT INTO scad_deadlines
|
||||
(subject_id, function_id, topic, law_regulation, recurrence_type, due_date, check_date,
|
||||
document_date, notification_days, storage_location, notes, created_by, departments)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
(subject_id, function_id, notify_function, topic, law_regulation, recurrence_type, due_date, check_date,
|
||||
document_date, notification_days, storage_location, notes, variazioni, attiva_alert, created_by, departments)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
");
|
||||
$ins->execute([
|
||||
$deadline['subject_id'], $deadline['function_id'], $deadline['topic'], $deadline['law_regulation'],
|
||||
$deadline['recurrence_type'], $dueDate->format('Y-m-d'),
|
||||
$deadline['subject_id'],
|
||||
$deadline['function_id'],
|
||||
$deadline['notify_function'],
|
||||
$deadline['topic'],
|
||||
$deadline['law_regulation'],
|
||||
$deadline['recurrence_type'],
|
||||
$dueDate->format('Y-m-d'),
|
||||
$checkDate ? $checkDate->format('Y-m-d') : null,
|
||||
$documentDate ? $documentDate->format('Y-m-d') : null,
|
||||
$deadline['notification_days'], $deadline['storage_location'],
|
||||
$deadline['notes'], $deadline['created_by'], $deadline['departments']
|
||||
$deadline['notification_days'],
|
||||
$deadline['storage_location'],
|
||||
$deadline['notes'],
|
||||
$deadline['variazioni'],
|
||||
$deadline['attiva_alert'],
|
||||
$deadline['created_by'],
|
||||
$deadline['departments']
|
||||
]);
|
||||
|
||||
$newId = $pdo->lastInsertId();
|
||||
@@ -137,7 +168,6 @@ try {
|
||||
}
|
||||
|
||||
echo json_encode(['success' => true, 'message' => $msg, 'new_id' => $newId]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
if (isset($pdo) && $pdo->inTransaction()) {
|
||||
$pdo->rollBack();
|
||||
|
||||
@@ -20,7 +20,8 @@ try {
|
||||
$notification_days = isset($_POST['notification_days']) && is_numeric($_POST['notification_days']) ? (int)$_POST['notification_days'] : 7;
|
||||
$storage_location = trim($_POST['storage_location'] ?? '') ?: null;
|
||||
$notes = trim($_POST['notes'] ?? '') ?: null;
|
||||
$variazioni = trim($_POST['variazioni'] ?? '') ?: null;
|
||||
$variazioni = !empty($_POST['variazioni']) ? 1 : 0;
|
||||
$attiva_alert = !empty($_POST['attiva_alert']) ? 1 : 0;
|
||||
$employee_ids = $_POST['employee_ids'] ?? [];
|
||||
$department_names = $_POST['department_names'] ?? [];
|
||||
|
||||
@@ -57,7 +58,7 @@ try {
|
||||
UPDATE scad_deadlines SET
|
||||
subject_id = ?, function_id = ?, notify_function = ?, topic = ?, law_regulation = ?, recurrence_type = ?,
|
||||
due_date = ?, check_date = ?, document_date = ?, notification_days = ?,
|
||||
storage_location = ?, notes = ?, variazioni = ?, departments = ?
|
||||
storage_location = ?, notes = ?, variazioni = ?, attiva_alert = ?, departments = ?
|
||||
WHERE id = ?
|
||||
");
|
||||
$stmt->execute([
|
||||
@@ -74,6 +75,7 @@ try {
|
||||
$storage_location,
|
||||
$notes,
|
||||
$variazioni,
|
||||
$attiva_alert,
|
||||
$departmentsStr,
|
||||
$id
|
||||
]);
|
||||
@@ -91,8 +93,8 @@ try {
|
||||
$stmt = $pdo->prepare("
|
||||
INSERT INTO scad_deadlines
|
||||
(subject_id, function_id, notify_function, topic, law_regulation, recurrence_type, due_date, check_date,
|
||||
document_date, notification_days, storage_location, notes, variazioni, created_by, departments)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
document_date, notification_days, storage_location, notes, variazioni, attiva_alert, created_by, departments)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
");
|
||||
$stmt->execute([
|
||||
$subject_id,
|
||||
@@ -108,6 +110,7 @@ try {
|
||||
$storage_location,
|
||||
$notes,
|
||||
$variazioni,
|
||||
$attiva_alert,
|
||||
$currentUserId,
|
||||
$departmentsStr
|
||||
]);
|
||||
|
||||
@@ -57,12 +57,13 @@ $stmt = $pdo->query("
|
||||
LEFT JOIN scad_subjects s ON s.id = d.subject_id
|
||||
LEFT JOIN scad_functions f ON f.id = d.function_id
|
||||
WHERE d.status = 'active'
|
||||
AND d.attiva_alert = 1
|
||||
AND d.due_date <= DATE_ADD(CURDATE(), INTERVAL d.notification_days DAY)
|
||||
");
|
||||
$deadlines = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if (empty($deadlines)) {
|
||||
echo date('Y-m-d H:i:s') . " — Nessuna scadenza da notificare.\n";
|
||||
echo date('Y-m-d H:i:s') . " — Nessuna scadenza da notificare (alert attivo).\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -646,6 +646,24 @@ if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
|
||||
<div class="detail-label">Note</div>
|
||||
<div class="detail-value"><?= nl2br(htmlspecialchars($deadline['notes'], ENT_QUOTES, 'UTF-8')) ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="detail-label">Alert</div>
|
||||
<div class="detail-value">
|
||||
<?php if (!empty($deadline['attiva_alert'])): ?>
|
||||
<i class="fa-solid fa-bell text-warning me-1"></i> Attivo
|
||||
<?php else: ?>
|
||||
<span class="text-muted">Non attivo</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="detail-label">In caso di variazioni</div>
|
||||
<div class="detail-value">
|
||||
<?php if (!empty($deadline['variazioni'])): ?>
|
||||
<i class="fa-solid fa-arrows-rotate text-info me-1"></i> Sì
|
||||
<?php else: ?>
|
||||
<span class="text-muted">No</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -147,8 +147,20 @@
|
||||
<textarea class="form-control" id="dlNotes" name="notes" rows="3" placeholder="es. Scadenza 09/06/2026, Attività in appalto a Ditta specializzata..."></textarea>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label for="dlVariazioni" class="form-label fw-semibold">In caso di variazioni</label>
|
||||
<textarea class="form-control" id="dlVariazioni" name="variazioni" rows="3" placeholder="es. In caso di variazioni normative, aggiornare la procedura..."></textarea>
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" role="switch" id="dlVariazioni" name="variazioni" value="1">
|
||||
<label class="form-check-label fw-semibold" for="dlVariazioni">
|
||||
In caso di variazioni
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" role="switch" id="dlAttivaAlert" name="attiva_alert" value="1">
|
||||
<label class="form-check-label fw-semibold" for="dlAttivaAlert">
|
||||
<i class="fa-solid fa-bell me-1 text-warning"></i> Attiva alert
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -135,6 +135,8 @@
|
||||
$('#dlEmployees').val(null).trigger('change');
|
||||
$('#dlFunction').val('').trigger('change');
|
||||
$('#notify_function').prop('checked', false);
|
||||
$('#dlVariazioni').prop('checked', false);
|
||||
$('#dlAttivaAlert').prop('checked', false);
|
||||
renderAttachments([]);
|
||||
modal.show();
|
||||
};
|
||||
@@ -164,7 +166,8 @@
|
||||
document.getElementById('dlNotifDays').value = d.notification_days || 7;
|
||||
document.getElementById('dlStorage').value = d.storage_location || '';
|
||||
document.getElementById('dlNotes').value = d.notes || '';
|
||||
document.getElementById('dlVariazioni').value = d.variazioni || '';
|
||||
$('#dlVariazioni').prop('checked', Number(d.variazioni) === 1);
|
||||
$('#dlAttivaAlert').prop('checked', Number(d.attiva_alert) === 1);
|
||||
document.getElementById('dlFiles').value = '';
|
||||
document.getElementById('modalTitle').textContent = 'Modifica Scadenza';
|
||||
$('#dlDepartments').val(d.department_names || []).trigger('change');
|
||||
|
||||
@@ -941,6 +941,12 @@ function getContrastTextColor($hexColor)
|
||||
<?php if ((int)$row['attachment_count'] > 0): ?>
|
||||
<span><i class="fa-solid fa-paperclip"></i> <?= (int)$row['attachment_count'] ?></span>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($row['attiva_alert'])): ?>
|
||||
<span><i class="fa-solid fa-bell text-warning"></i> Alert</span>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($row['variazioni'])): ?>
|
||||
<span><i class="fa-solid fa-arrows-rotate text-info"></i> Variazioni</span>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
<?php if (!$row['_isCompleted']): ?>
|
||||
@@ -1010,6 +1016,12 @@ function getContrastTextColor($hexColor)
|
||||
|
||||
<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 (!empty($row['attiva_alert'])): ?>
|
||||
<i class="fa-solid fa-bell text-warning ms-1" title="Alert attivo"></i>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($row['variazioni'])): ?>
|
||||
<i class="fa-solid fa-arrows-rotate text-info ms-1" title="In caso di variazioni"></i>
|
||||
<?php endif; ?>
|
||||
<?php if ((int)$row['attachment_count'] > 0): ?>
|
||||
<span class="text-muted ms-1" title="<?= (int)$row['attachment_count'] ?> allegati"><i class="fa-solid fa-paperclip"></i> <?= (int)$row['attachment_count'] ?></span>
|
||||
<?php endif; ?>
|
||||
|
||||
Reference in New Issue
Block a user