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
@@ -9,6 +9,7 @@ try {
$id = isset($_POST['id']) && is_numeric($_POST['id']) ? (int)$_POST['id'] : null;
$subject_id = isset($_POST['subject_id']) && is_numeric($_POST['subject_id']) && (int)$_POST['subject_id'] > 0 ? (int)$_POST['subject_id'] : null;
$function_id = isset($_POST['function_id']) && is_numeric($_POST['function_id']) && (int)$_POST['function_id'] > 0 ? (int)$_POST['function_id'] : null;
$topic = trim($_POST['topic'] ?? '');
$law_regulation = trim($_POST['law_regulation'] ?? '') ?: null;
$recurrence_type = $_POST['recurrence_type'] ?? 'once';
@@ -51,16 +52,26 @@ try {
if ($id) {
$stmt = $pdo->prepare("
UPDATE scad_deadlines SET
subject_id = ?, topic = ?, law_regulation = ?, recurrence_type = ?,
UPDATE scad_deadlines SET
subject_id = ?, function_id = ?, topic = ?, law_regulation = ?, recurrence_type = ?,
due_date = ?, check_date = ?, document_date = ?, notification_days = ?,
storage_location = ?, notes = ?, departments = ?
WHERE id = ?
");
$stmt->execute([
$subject_id, $topic, $law_regulation, $recurrence_type,
$due_date, $check_date, $document_date, $notification_days,
$storage_location, $notes, $departmentsStr, $id
$subject_id,
$function_id,
$topic,
$law_regulation,
$recurrence_type,
$due_date,
$check_date,
$document_date,
$notification_days,
$storage_location,
$notes,
$departmentsStr,
$id
]);
// Re-link employees
@@ -75,14 +86,24 @@ try {
// INSERT
$stmt = $pdo->prepare("
INSERT INTO scad_deadlines
(subject_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, topic, law_regulation, recurrence_type, due_date, check_date,
document_date, notification_days, storage_location, notes, created_by, departments)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
");
$stmt->execute([
$subject_id, $topic, $law_regulation, $recurrence_type,
$due_date, $check_date, $document_date, $notification_days,
$storage_location, $notes, $currentUserId, $departmentsStr
$subject_id,
$function_id,
$topic,
$law_regulation,
$recurrence_type,
$due_date,
$check_date,
$document_date,
$notification_days,
$storage_location,
$notes,
$currentUserId,
$departmentsStr
]);
$deadlineId = $pdo->lastInsertId();
@@ -107,7 +128,6 @@ try {
'message' => $id ? 'Scadenza aggiornata con successo.' : 'Scadenza creata con successo.',
'id' => $deadlineId
]);
} catch (Exception $e) {
if (isset($pdo) && $pdo->inTransaction()) {
$pdo->rollBack();