added alert flag and variation flag
This commit is contained in:
@@ -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
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user