From 7289bd1692a45e4f00ecca97aa6465a63fb15d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20K=C5=82opotek=20-=20INTERDUO?= Date: Fri, 8 Aug 2025 10:55:48 +0200 Subject: [PATCH 1/2] enhancement: allow to add note directly from rtticketview --- js/locale/pl_PL.js | 4 ++ js/templates/rt/rtticketfastnote.js | 51 ++++++++++++++++++++++ lib/locale/pl_PL/strings.php | 4 ++ modules/rtticketedit.php | 8 ++++ templates/default/rt/rtticketfastnote.html | 48 ++++++++++++++++++++ templates/default/rt/rtticketview.html | 1 + 6 files changed, 116 insertions(+) create mode 100644 js/templates/rt/rtticketfastnote.js create mode 100644 templates/default/rt/rtticketfastnote.html diff --git a/js/locale/pl_PL.js b/js/locale/pl_PL.js index 58bde23ff4..0efbf4101a 100644 --- a/js/locale/pl_PL.js +++ b/js/locale/pl_PL.js @@ -30,6 +30,10 @@ $_LANG['Unexpected empty reply from PESEL Reservation Registry API server!'] = ' $_LANG['Malformed reply from PESEL Reservation Registry API server!'] = 'Błędna odpowiedź serwera API Rejestru Zastrzeżeń PESEL!'; $_LANG['telecommunication service contract'] = 'umowa na usługi telekomunikacyjne'; +$_LANG['Note added'] = 'Notatka dodana'; +$_LANG['Adding note'] = 'Dodaję notatkę'; +$_LANG['Adding note Error'] = 'Błąd dodawania notatki'; + $_LANG['Show sensible data'] = 'Pokaż dane wrażliwe'; $_LANG['customer sensitive data view'] = 'podgląd danych wrażliwych klientów'; diff --git a/js/templates/rt/rtticketfastnote.js b/js/templates/rt/rtticketfastnote.js new file mode 100644 index 0000000000..fafbab720a --- /dev/null +++ b/js/templates/rt/rtticketfastnote.js @@ -0,0 +1,51 @@ +const $input = $('#quick-note-input'); +const $button = $('#quick-message-send'); +const $overlay = $('#quick-message-overlay'); + +function updateButtonState(disabled = null) { + if (disabled === null) { + disabled = !$input.val().trim(); + } + $button.prop('disabled', disabled); +} + +function showStatus(message, color) { + $overlay + .html(`${message}`) + .css('display', 'flex'); + + setTimeout(() => { + $overlay.fadeOut(); + }, 4000); +} + +function sendQuickMessage(ticketId) { + const messageText = $input.val().trim(); + updateButtonState(true); + + showStatus($t('Sending message'), 'orange'); + + $.ajax({ + url: "?m=rtticketedit&id=" + ticketId + "&action=fastnote", + type: 'POST', + data: { fastnote: messageText }, + success: () => { + showStatus($t('Note added'), 'green'); + $input.val(''); + setTimeout(() => { + const cleanUrl = window.location.origin + window.location.pathname + window.location.search; + window.location.href = cleanUrl; + }, 1500 + ); + }, + error: (xhr, status, error) => { + showStatus(`$t('Adding note Error'): ${error}"`, 'red'); + console.error(trans('AJAX Error:'), xhr.responseText); + }, + complete: () => { + updateButtonState(); + } + }); +} + +$input.on('input', () => updateButtonState()); diff --git a/lib/locale/pl_PL/strings.php b/lib/locale/pl_PL/strings.php index e175c2f3a1..c9886b60e4 100644 --- a/lib/locale/pl_PL/strings.php +++ b/lib/locale/pl_PL/strings.php @@ -31,6 +31,10 @@ $_LANG['Malformed reply from PESEL Reservation Registry API server!'] = 'Błędna odpowiedź serwera API Rejestru Zastrzeżeń PESEL!'; $_LANG['telecommunication service contract'] = 'umowa na usługi telekomunikacyjne'; +$_LANG['Note added'] = 'Notatka dodana'; +$_LANG['Adding note'] = 'Dodaję notatkę'; +$_LANG['Adding note Error'] = 'Błąd dodawania notatki'; + $_LANG['Show sensitive data'] = 'Pokaż dane wrażliwe'; $_LANG['customer sensitive data view'] = 'podgląd danych wrażliwych klientów'; diff --git a/modules/rtticketedit.php b/modules/rtticketedit.php index ab8e3b7361..2ad6d7c322 100644 --- a/modules/rtticketedit.php +++ b/modules/rtticketedit.php @@ -232,6 +232,14 @@ function ($contact) { $SESSION->redirect('?m=rtqueueview' . ($SESSION->is_set('backid') ? '#' . $SESSION->get('backid') : '')); break; + case 'fastnote': + $message = array( + 'ticketid' => $id, + 'body' => $_POST['fastnote'], + 'type' => RTMESSAGE_NOTE, + ); + $LMS->TicketMessageAdd($message); + break; case 'resolve': $notification_options_by_division_ids = array( 0 => array( diff --git a/templates/default/rt/rtticketfastnote.html b/templates/default/rt/rtticketfastnote.html new file mode 100644 index 0000000000..ff38496e55 --- /dev/null +++ b/templates/default/rt/rtticketfastnote.html @@ -0,0 +1,48 @@ + + + + + + + + +
+
+
{icon name="note"} + + {button id="quick-message-send" label="Add" icon="add" onclick="javascript:sendQuickMessage({$ticket.ticketid});"} +
+
+
+
+ +{js} diff --git a/templates/default/rt/rtticketview.html b/templates/default/rt/rtticketview.html index fc8fc3883c..41d031445f 100644 --- a/templates/default/rt/rtticketview.html +++ b/templates/default/rt/rtticketview.html @@ -6,6 +6,7 @@

{$layout.pagetitle|escape}

{include file="rt/rtticketinfobox.html"} {include file="rt/rtticketmessagesbox.html"} +{include file="rt/rtticketfastnote.html"} From a9647e03b782f95f2b868c2bf00143fa2c732f76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20K=C5=82opotek=20-=20INTERDUO?= Date: Mon, 11 Aug 2025 15:22:42 +0200 Subject: [PATCH 2/2] improvement: add {speech recognision} instead of note icon and some padding --- templates/default/rt/rtticketfastnote.html | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/templates/default/rt/rtticketfastnote.html b/templates/default/rt/rtticketfastnote.html index ff38496e55..bcd0d3a15b 100644 --- a/templates/default/rt/rtticketfastnote.html +++ b/templates/default/rt/rtticketfastnote.html @@ -12,11 +12,12 @@ pointer-events: none; z-index: 10; padding: 0.5em; - text-align: center;" + text-align: center; } #quick-note-input { width:100%; height: 5em; + padding: 0.5em; } #quick-message-container { position: relative; @@ -34,9 +35,10 @@
-
{icon name="note"} +
+ {speech_recognition target="#quick-note-input"} - {button id="quick-message-send" label="Add" icon="add" onclick="javascript:sendQuickMessage({$ticket.ticketid});"} + {button id="quick-message-send" label="Add" icon="note" onclick="javascript:sendQuickMessage({$ticket.ticketid});"}
@@ -45,4 +47,5 @@
+ {js}