From efa984359741890f40d35de26d8074e3d203812a Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 2 Oct 2024 14:44:19 +0100 Subject: [PATCH] Bug 33260: (follow-up) Sync functionality and ordering of display This patch syncs up the functionality and order of the notice displays. We allow for resending of notices via the modal in the new tools page and we add print in bulk to the members notices page. We also fix the modal on the tools page to work with bootstrap 5 correctly. --- .../prog/en/modules/members/notices.tt | 255 ++++++++++-------- .../prog/en/modules/tools/notices.tt | 105 +++++++- 2 files changed, 234 insertions(+), 126 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt index 815389a40a3..0ceb75b4cbc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt @@ -49,117 +49,117 @@ [% IF ( QUEUED_MESSAGES ) %]
- - - - - - - - - - [% IF CAN_user_tools_view_generated_notices %] - - [% END %] - - - - [% FOREACH QUEUED_MESSAGE IN QUEUED_MESSAGES %] + Select all | Clear all + + [% INCLUDE 'csrf-token.inc' %] + +
NoticeTypeStatusUpdated onTime createdDelivery noteActions
+ - - - - - - + + + + + + + + + + + [% FOREACH QUEUED_MESSAGE IN QUEUED_MESSAGES %] + + + + + + + + - [% IF CAN_user_tools_view_generated_notices %] + - [% END %] - - [% END %] - -
- [% QUEUED_MESSAGE.subject | html %] - - - [% IF ( QUEUED_MESSAGE.message_transport_type == 'email' ) %] - email - [% ELSIF ( QUEUED_MESSAGE.message_transport_type == 'print' ) %] - print - [% ELSIF ( QUEUED_MESSAGE.message_transport_type == 'feed' ) %] - feed - [% ELSIF ( QUEUED_MESSAGE.message_transport_type == 'sms' ) %] - sms - [% ELSE %] - [% QUEUED_MESSAGE.message_transport_type | html %] - [% END %] - - [% IF ( QUEUED_MESSAGE.status == 'sent' ) %] - sent - [% ELSIF ( QUEUED_MESSAGE.status == 'pending' ) %] - pending - [% ELSIF ( QUEUED_MESSAGE.status == 'failed' ) %] - failed - [% ELSIF ( QUEUED_MESSAGE.status == 'deleted' ) %] - deleted - [% ELSE %] - [% QUEUED_MESSAGE.status | html %] - [% END %] - [% IF ( QUEUED_MESSAGE.status != 'pending' ) %] -
- - [% INCLUDE 'csrf-token.inc' %] - - - - -
- [% END %] -
[% QUEUED_MESSAGE.updated_on | $KohaDates with_hours => 1 %][% QUEUED_MESSAGE.time_queued | $KohaDates with_hours => 1 %] - [% IF ( QUEUED_MESSAGE.failure_code ) %] - [% IF ( QUEUED_MESSAGE.failure_code == "INVALID_BORNUMBER" ) %] - Invalid borrowernumber [% borrowernumber | html %] - [% ELSIF ( QUEUED_MESSAGE.failure_code == 'NO_EMAIL' ) %] - Unable to find an email address for this patron - [% ELSIF (matches = QUEUED_MESSAGE.failure_code.match('INVALID_EMAIL:(\w+)') ) %] - Invalid [% matches.0 | html %] email address found [% borrowernumber | html %] - [% ELSIF ( QUEUED_MESSAGE.failure_code == 'NO_FROM' ) %] - Missing from email address - [% ELSIF ( QUEUED_MESSAGE.failure_code == 'MISSING_SMS' ) %] - Missing SMS number - [% ELSIF ( QUEUED_MESSAGE.failure_code == 'DUPLICATE_MESSAGE' ) %] - Message is duplicate - [% ELSIF ( QUEUED_MESSAGE.failure_code == 'NO_NOTES' ) %] - No notes from SMS driver - [% ELSIF ( QUEUED_MESSAGE.failure_code == 'SMS_SEND_DRIVER_MISSING' ) %] - The SMS driver could not be loaded - [% ELSIF ( QUEUED_MESSAGE.failure_code == 'SENDMAIL' ) %] - Unhandled email failure, check the logs for further details - [% ELSIF ( QUEUED_MESSAGE.failure_code == "UNKNOWN_ERROR" ) %] - Unknown error +  Time createdNoticeTypeStatusUpdated onDelivery noteActions
[% QUEUED_MESSAGE.time_queued | $KohaDates with_hours => 1 %] + [% QUEUED_MESSAGE.subject | html %] + + + [% IF ( QUEUED_MESSAGE.message_transport_type == 'email' ) %] + email + [% ELSIF ( QUEUED_MESSAGE.message_transport_type == 'print' ) %] + print + [% ELSIF ( QUEUED_MESSAGE.message_transport_type == 'feed' ) %] + feed + [% ELSIF ( QUEUED_MESSAGE.message_transport_type == 'sms' ) %] + sms [% ELSE %] - Message failed to send with the following error: [% QUEUED_MESSAGE.failure_code | html %] + [% QUEUED_MESSAGE.message_transport_type | html %] [% END %] - [% END %] - [% IF ( QUEUED_MESSAGE.status == 'sent' ) %] - [% IF ( QUEUED_MESSAGE.from_address ) %] - From: [% QUEUED_MESSAGE.from_address | html %] + + [% IF ( QUEUED_MESSAGE.status == 'sent' ) %] + sent + [% ELSIF ( QUEUED_MESSAGE.status == 'pending' ) %] + pending + [% ELSIF ( QUEUED_MESSAGE.status == 'failed' ) %] + failed + [% ELSIF ( QUEUED_MESSAGE.status == 'deleted' ) %] + deleted + [% ELSE %] + [% QUEUED_MESSAGE.status | html %] [% END %] - [% IF ( QUEUED_MESSAGE.to_address ) %] - To: [% QUEUED_MESSAGE.to_address | html %] + [% QUEUED_MESSAGE.updated_on | $KohaDates with_hours => 1 %] + [% IF ( QUEUED_MESSAGE.failure_code ) %] + [% IF ( QUEUED_MESSAGE.failure_code == "INVALID_BORNUMBER" ) %] + Invalid borrowernumber [% borrowernumber | html %] + [% ELSIF ( QUEUED_MESSAGE.failure_code == 'NO_EMAIL' ) %] + Unable to find an email address for this patron + [% ELSIF (matches = QUEUED_MESSAGE.failure_code.match('INVALID_EMAIL:(\w+)') ) %] + Invalid [% matches.0 | html %] email address found [% borrowernumber | html %] + [% ELSIF ( QUEUED_MESSAGE.failure_code == 'NO_FROM' ) %] + Missing from email address + [% ELSIF ( QUEUED_MESSAGE.failure_code == 'MISSING_SMS' ) %] + Missing SMS number + [% ELSIF ( QUEUED_MESSAGE.failure_code == 'DUPLICATE_MESSAGE' ) %] + Message is duplicate + [% ELSIF ( QUEUED_MESSAGE.failure_code == 'NO_NOTES' ) %] + No notes from SMS driver + [% ELSIF ( QUEUED_MESSAGE.failure_code == 'SMS_SEND_DRIVER_MISSING' ) %] + The SMS driver could not be loaded + [% ELSIF ( QUEUED_MESSAGE.failure_code == 'SENDMAIL' ) %] + Unhandled email failure, check the logs for further details + [% ELSIF ( QUEUED_MESSAGE.failure_code == "UNKNOWN_ERROR" ) %] + Unknown error + [% ELSE %] + Message failed to send with the following error: [% QUEUED_MESSAGE.failure_code | html %] + [% END %] [% END %] - [% IF ( QUEUED_MESSAGE.cc_address ) %] - CC: [% QUEUED_MESSAGE.cc_address | html %] + [% IF ( QUEUED_MESSAGE.status != 'pending' ) %] + [% IF ( QUEUED_MESSAGE.from_address ) %] + From: [% QUEUED_MESSAGE.from_address | html %] + [% END %] + [% IF ( QUEUED_MESSAGE.to_address ) %] + To: [% QUEUED_MESSAGE.to_address | html %] + [% END %] + [% IF ( QUEUED_MESSAGE.cc_address ) %] + CC: [% QUEUED_MESSAGE.cc_address | html %] + [% END %] [% END %] - [% END %] - Print
+ + [% END %] + + +
+ +
+
[% ELSE %] @@ -176,8 +176,14 @@ @@ -200,26 +206,47 @@ var title = $(this).text(); var noticeid = $(this).data("noticeid"); var body = $("#notice" + noticeid).attr("srcdoc"); - if ($("#resend_notice" + noticeid).length) { - $("#resend-notice").show(); + if ($(this).data("status") !== "pending") { + let borrowerNumber = $(this).data("borrowernumber"); + $('#resend_notice input[name="borrowernumber"]').val(borrowerNumber); + $('#resend_notice input[name="message_id"]').val(noticeid); + $("#resend_notice").show(); } - $("#resend-notice").data("noticeid", noticeid); $("#noticeModalLabel").text(title); $("#noticeModal .modal-body").html(body); $("#noticeModal").modal("show"); }); - $("#resend-notice").on("click", function (e) { - e.preventDefault(); - var noticeid = $(this).data("noticeid"); - $("#resend_notice" + noticeid).submit(); - }); - $("#noticeModal").on("hide.bs.modal", function () { - $("#resend-notice").removeData("noticeid").hide(); + $('#resend_notice input[name="borrowernumber"]').val(""); + $('#resend_notice input[name="message_id"]').val(""); + $("#resend_notice").hide(); $("#noticeModalLabel").text(""); $("#noticeModal .modal-body").html(""); }); + + $("#print_multiple_button").click(function (e) { + var selected_notices = $("#print_multiple").find("input[name='message_ids']:checked"); + if (selected_notices.length == 0) { + alert(_("Please select at least one sent notice.")); + e.preventDefault(); + return false; + } + }); + + $(".select_all").click(function (e) { + e.preventDefault(); + $("input[name='message_ids']").each(function () { + $(this).prop("checked", true); + }); + }); + + $(".clear_all").click(function (e) { + e.preventDefault(); + $("input[name='message_ids']").each(function () { + $(this).prop("checked", false); + }); + }); }); [% INCLUDE 'str/members-menu.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/notices.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/notices.tt index e8a5fc8e6bd..125d8046633 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/notices.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/notices.tt @@ -47,7 +47,7 @@

Notices management

-
Printing a notice will mark it as sent.
+
Printing a notice will mark it as sent.
[% IF notices.count == 0 %]
No sent notices were found with those search parameters.
@@ -68,6 +68,7 @@ Type Status Updated on + Delivery note Actions @@ -75,20 +76,84 @@ [% FOREACH notice IN notices %] - [% notice.time_queued | $KohaDates with_hours = 1 %] + [% notice.time_queued | $KohaDates with_hours = 1 %] [% INCLUDE 'patron-title.inc' patron=notice.patron hide_patron_infos_if_needed=1 %] [% notice.subject | html %] - [% notice.message_transport_type | html %] - [% notice.status | html %] - [% notice.updated_on | $KohaDates with_hours = 1 %] + + [% IF ( notice.message_transport_type == 'email' ) %] + email + [% ELSIF ( notice.message_transport_type == 'print' ) %] + print + [% ELSIF ( notice.message_transport_type == 'feed' ) %] + feed + [% ELSIF ( notice.message_transport_type == 'sms' ) %] + sms + [% ELSE %] + [% notice.message_transport_type | html %] + [% END %] + + + [% IF ( notice.status == 'sent' ) %] + sent + [% ELSIF ( notice.status == 'pending' ) %] + pending + [% ELSIF ( notice.status == 'failed' ) %] + failed + [% ELSIF ( notice.status == 'deleted' ) %] + deleted + [% ELSE %] + [% notice.status | html %] + [% END %] + + [% notice.updated_on | $KohaDates with_hours = 1 %] + + [% IF ( notice.failure_code ) %] + [% IF ( notice.failure_code == "INVALID_BORNUMBER" ) %] + Invalid borrowernumber [% notice.borrowernumber | html %] + [% ELSIF ( notice.failure_code == 'NO_EMAIL' ) %] + Unable to find an email address for this patron + [% ELSIF ( matches = notice.failure_code.match('INVALID_EMAIL:(\w+)') ) %] + Invalid [% matches.0 | html %] email address found [% borrowernumber | html %] + [% ELSIF ( notice.failure_code == 'NO_FROM' ) %] + Missing from email address + [% ELSIF ( notice.failure_code == 'MISSING_SMS' ) %] + Missing SMS number + [% ELSIF ( notice.failure_code == 'DUPLICATE_MESSAGE' ) %] + Message is duplicate + [% ELSIF ( notice.failure_code == 'NO_NOTES' ) %] + No notes from SMS driver + [% ELSIF ( notice.failure_code == 'SMS_SEND_DRIVER_MISSING' ) %] + The SMS driver could not be loaded + [% ELSIF ( notice.failure_code == 'SENDMAIL' ) %] + Unhandled email failure, check the logs for further details + [% ELSIF ( notice.failure_code == "UNKNOWN_ERROR" ) %] + Unknown error + [% ELSE %] + Message failed to send with the following error: [% notice.failure_code | html %] + [% END %] + [% END %] + [% IF ( notice.status == 'sent' ) %] + [% IF ( notice.from_address ) %] + From: [% notice.from_address | html %] + [% END %] + [% IF ( notice.to_address ) %] + To: [% notice.to_address | html %] + [% END %] + [% IF ( notice.cc_address ) %] + CC: [% notice.cc_address | html %] + [% END %] + [% END %] + Print @@ -96,7 +161,9 @@ [% END %] - +
+ +
[% END %] @@ -210,14 +277,19 @@