From d736adc289a5500ab5fff4b822ac61aadf99fb8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Jacquin?= <1536771+remyj38@users.noreply.github.com> Date: Thu, 8 Nov 2018 23:01:46 +0100 Subject: [PATCH] Added alerts schedule notes into device notes (#9258) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add alerts schedule notes into device notes Signed-off-by: Rémy Jacquin * Update preferences.inc.php --- .../forms/schedule-maintenance.inc.php | 5 +++ html/pages/preferences.inc.php | 38 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/html/includes/forms/schedule-maintenance.inc.php b/html/includes/forms/schedule-maintenance.inc.php index 7187ae3e9e..8ef953edbd 100644 --- a/html/includes/forms/schedule-maintenance.inc.php +++ b/html/includes/forms/schedule-maintenance.inc.php @@ -129,6 +129,11 @@ if ($sub_type == 'new-maintenance') { foreach ($_POST['maps'] as $target) { $target = target_to_id($target); $item = dbInsert(array('schedule_id' => $schedule_id, 'target' => $target), 'alert_schedule_items'); + if ($notes && get_user_pref('add_schedule_note_to_device', false)) { + $device_notes = dbFetchCell('SELECT `notes` FROM `devices` WHERE `device_id` = ?;', array($target)); + $device_notes.= ((empty($device_notes)) ? '' : PHP_EOL) . date("Y-m-d H:i") . ' Alerts delayed: ' . $notes; + dbUpdate(array('notes' => $device_notes), 'devices', '`device_id` = ?', array($target)); + } if ($item > 0) { array_push($items, $item); } else { diff --git a/html/pages/preferences.inc.php b/html/pages/preferences.inc.php index ef1e42777f..6195cf2841 100644 --- a/html/pages/preferences.inc.php +++ b/html/pages/preferences.inc.php @@ -33,6 +33,14 @@ if (LegacyAuth::user()->isDemoUser()) { $updatedashboard_message = "User default dashboard updated"; } } + if ($vars['action'] === 'changenote') { + set_user_pref('add_schedule_note_to_device', (bool)$vars['notetodevice']); + if ($vars['notetodevice']) { + $updatenote_message = "Schedule notes will now be added to device notes"; + } else { + $updatenote_message = "Schedule notes will no longer be added to device notes"; + } + } include 'includes/update-preferences-password.inc.php'; @@ -163,6 +171,34 @@ echo " "; +echo "

Add schedule notes to devices notes

+
+
"; +if (!empty($updatenote_message)) { + print_message($updatenote_message); +} +echo " +
+
+ +
+ +
+ +
+
+
+
+ +
+
+
+
+
+
"; + + + echo "

Device Permissions

"; echo "
"; echo '
'; @@ -183,3 +219,5 @@ if (LegacyAuth::user()->hasGlobalAdmin()) { } echo '
'; + +echo "";