From 75192d089bc41bdc5805a63816f6fa2293cb93d6 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 | 84 ++++++++++++------- .../prog/en/modules/tools/notices.tt | 83 +++++++++++++++--- 2 files changed, 125 insertions(+), 42 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 50a0dfe6efd..3627988c250 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt @@ -49,15 +49,20 @@

Sent notices for [% INCLUDE 'patron-title.inc' %]

[% IF ( QUEUED_MESSAGES ) %] -
+
+ Select all | Clear all +
+
+ +
+ +
[% ELSE %] -
There is no record of any messages that have been sent to this patron.
+
There is no record of any messages that have been sent to this patron.
[% END %] - @@ -157,8 +156,14 @@ ... @@ -178,26 +183,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 9f0e0d90d7d..ce45c8f4c89 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/notices.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/notices.tt @@ -46,7 +46,7 @@

Notices management

-
Printing a notice will mark it as sent.
+
Printing a notice will mark it as sent.
[% IF notices.count == 0 %] @@ -70,6 +70,7 @@ Type Status Updated on + Delivery note Actions @@ -77,21 +78,63 @@ [% 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.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 [% END %] - +
+ +
@@ -204,16 +247,21 @@ @@ -239,18 +287,27 @@ var title = $(this).text(); var noticeid = $(this).data("noticeid"); var body = $("#notice" + noticeid ).attr("srcdoc"); + 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(); + } $("#noticeModalLabel").text( title ); $("#noticeModal .modal-body").html( body ); $("#noticeModal").modal("show"); }); $("#noticeModal").on("hide.bs.modal", function(){ + $('#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"); + var selected_notices = $("#notices").find("input[name='message_ids']:checked"); if ( selected_notices.length == 0 ) { alert(_("Please select at least one sent notice.")); e.preventDefault(); -- 2.46.2