From 9246b04bc588b1c05b8425d795dd64a7edf88403 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Tue, 21 Mar 2023 02:49:45 +0000 Subject: [PATCH] Bug 33260: Add Notice management tool This enhancement makes it easy for the library to view sent notices and filter by various search parameters. You can also print sent notices, individually or in a batch. This enhancement uses a new system preference NoticesManagement and a new view_generated_notices user permission. This enhancement has been built on top of Bug 33478 so print format settings are taken into account when printing notices. To test: 1. Apply patches, install database updates, restart services 2. Make sure your logged in user has the view_generated_notices permission checked 3. Enable the NoticesManagement system preference 4. Generate a few notices. There are a few ways to do this including: - place holds, check in items and confirm the holds - place recalls, check in items and confirm the recalls 5. Go to Tools -> Notices management 6. There are two search functions on the left navigation. Confirm the patron search box works by searching for one of the patrons you generated a notice for, you should be redirected to their Notice history. 7. Go back to Notices management. Use the set of search filters to search for notices. Leaving the search filters empty will return all notices generated. Confirm the filters work as expected by using different combinations of filters. 8. Conduct a search so your notices show in a table. Confirm the information fetched about the notices is correct. 9. Click on a notice title. Confirm the contents of the notice show in a pop-up box. 10. Click one of the Print buttons next to a notice. Confirm the notice is opened to be printed. 11. Redo your notices search. Confirm the status of the notice you just printed has now been updated to 'sent'. 12. Use the 'Select all' and 'Clear all' buttons to select or clear the checkboxes. 13. Select a few checkboxes and click the button at the bottom of the table to 'Print selected notices'. Confirm the notices have been collated into one document, separated by horizontal lines, and prints successfully. The statuses for the notices should all be updated to 'sent'. 14. Confirm the Notices management page is not visible without the view_generated_notices permission 15. Confirm the Notices management page is not visible without the NoticesManagement system preference being enabled. 16. Go to a patron's Notices history. If the view_generated_notices user permission is checked for your logged in patron, you should see a Print button for each notice. Confirm this works. Confirm this button doesn't show if your logged in patron does not have the view_generated_notices user permission. It does not require the NoticesManagement system preference. 17. Go to Tools -> Notices & slips 18. Edit the format settings of a few different notices i.e. HOLD and WELCOME 19. Generate these notices by filling a hold for a patron and sending a welcome email 20. Search for all notices under Tools -> Notices management 21. Select all notices and print selected notices 22. Confirm the notices different format settings are taken into account in the printed PDF Sponsored-by: Colorado Library Consortium Signed-off-by: kelly Signed-off-by: David Nind --- .../prog/en/includes/tools-menu.inc | 5 +- .../prog/en/modules/members/notices.tt | 4 + .../prog/en/modules/tools/notices.tt | 310 ++++++++++++++++++ .../prog/en/modules/tools/tools-home.tt | 7 +- .../intranet-tmpl/prog/js/staff-global.js | 4 +- tools/notices.pl | 95 ++++++ tools/print_notice.pl | 60 ++++ 7 files changed, 482 insertions(+), 3 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/tools/notices.tt create mode 100755 tools/notices.pl create mode 100755 tools/print_notice.pl diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc index b106cffbea..22d3ecd6f1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc @@ -7,7 +7,7 @@ - [% IF ( CAN_user_tools_manage_patron_lists || CAN_user_clubs || CAN_user_tools_moderate_comments || CAN_user_tools_import_patrons || CAN_user_tools_edit_notices || CAN_user_tools_edit_notice_status_triggers || CAN_user_tools_label_creator || CAN_user_tools_delete_anonymize_patrons || CAN_user_tools_edit_patrons || CAN_user_tools_moderate_tags || ( CAN_user_tools_batch_upload_patron_images && Koha.Preference('patronimages') ) || CAN_user_tools_rotating_collections ) %] + [% IF ( CAN_user_tools_manage_patron_lists || CAN_user_clubs || CAN_user_tools_moderate_comments || CAN_user_tools_import_patrons || CAN_user_tools_edit_notices || CAN_user_tools_edit_notice_status_triggers || CAN_user_tools_label_creator || CAN_user_tools_delete_anonymize_patrons || CAN_user_tools_edit_patrons || CAN_user_tools_moderate_tags || ( CAN_user_tools_batch_upload_patron_images && Koha.Preference('patronimages') ) || CAN_user_tools_rotating_collections ) || ( CAN_user_tools_view_generated_notices && Koha.Preference('NoticesManagement') ) %]
Patrons and circulation
    [% IF ( CAN_user_tools_manage_patron_lists ) %] @@ -28,6 +28,9 @@ [% IF ( CAN_user_tools_edit_notice_status_triggers ) %]
  • Overdue notice/status triggers
  • [% END %] + [% IF ( CAN_user_tools_view_generated_notices && Koha.Preference('NoticesManagement') ) %] +
  • Notices management
  • + [% END %] [% IF ( CAN_user_tools_label_creator ) %]
  • Patron card creator
  • [% END %] 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 d9e5e569e7..b50027b7cc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt @@ -60,6 +60,9 @@ Updated on Time created Delivery note + [% IF CAN_user_tools_view_generated_notices %] + Actions + [% END %] @@ -127,6 +130,7 @@ [% END %] [% END %] + [% IF CAN_user_tools_view_generated_notices %] Print[% END %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/notices.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/notices.tt new file mode 100644 index 0000000000..5052028ddc --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/notices.tt @@ -0,0 +1,310 @@ +[% USE raw %] +[% USE Asset %] +[% USE KohaDates %] +[% USE Branches %] +[% USE Categories %] +[% USE TablesSettings %] +[% SET footerjs = 1 %] +[% INCLUDE 'doc-head-open.inc' %] +Notices management › Tools › Koha +[% PROCESS "patron-search.inc" %] +[% SET libraries = Branches.all %] +[% SET categories = Categories.all.unblessed %] +[% SET columns = ['name', 'cardnumber', 'dateofbirth', 'category', 'branch', 'address', 'phone'] %] +[% INCLUDE 'doc-head-close.inc' %] + + + + +[% WRAPPER 'header.inc' %] + [% INCLUDE 'circ-search.inc' %] +[% END %] + +[% WRAPPER 'sub-header.inc' %] + +[% END %] + +
    +
    +
    +
    + +

    Notices management

    + + [% IF notices && notices.count > 0 %] + +
    Printing a notice will mark it as sent.
    + + Select all | Clear all + + + + [% ELSE %] + +
    + Use the search form on the left to find sent notices. +
    + + [% IF notices && notices.count == 0 %] + +
    + No sent notices were found with those search parameters. +
    + + [% END %] + + [% END %] + +
    +
    + +
    + +
    +
    + + + + +[% MACRO jsinclude BLOCK %] + [% Asset.js("js/tools-menu.js") | $raw %] + [% INCLUDE 'calendar.inc' %] + [% INCLUDE 'datatables.inc' %] + [% PROCESS patron_search_js table_id => 'table_borrowers', categories => categories, libraries => libraries, extended_attribute_types => attribute_type_codes, columns => columns, open_on_row_click => 1, on_click_url => '/cgi-bin/koha/tools/notices.pl?', redirect_if_one_result => 1, redirect_url => '/cgi-bin/koha/tools/notices.pl?', redirect_if_attribute_equal => 'cardnumber' %] + + + +[% END %] + +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt index 86ee4426f6..4e3bbcd48a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt @@ -30,7 +30,7 @@

    Tools

    - [% IF ( CAN_user_tools_manage_patron_lists || CAN_user_clubs || CAN_user_tools_moderate_comments || CAN_user_tools_import_patrons || CAN_user_tools_edit_notices || CAN_user_tools_edit_notice_status_triggers || CAN_user_tools_label_creator || CAN_user_tools_delete_anonymize_patrons || CAN_user_tools_edit_patrons || CAN_user_tools_batch_extend_due_dates || CAN_user_tools_moderate_tags || CAN_user_tools_rotating_collections || ( CAN_user_tools_batch_upload_patron_images && Koha.Preference('patronimages') ) ) %] + [% IF ( CAN_user_tools_manage_patron_lists || CAN_user_clubs || CAN_user_tools_moderate_comments || CAN_user_tools_import_patrons || CAN_user_tools_edit_notices || CAN_user_tools_edit_notice_status_triggers || CAN_user_tools_label_creator || CAN_user_tools_delete_anonymize_patrons || CAN_user_tools_edit_patrons || CAN_user_tools_batch_extend_due_dates || CAN_user_tools_moderate_tags || CAN_user_tools_rotating_collections || ( CAN_user_tools_batch_upload_patron_images && Koha.Preference('patronimages') ) || ( CAN_user_tools_view_generated_notices && Koha.Preference('NoticesManagement') ) ) %]

    Patrons and circulation

    [% END %]
    @@ -69,6 +69,11 @@
    Set notice/status triggers for overdue items
    [% END %] + [% IF ( CAN_user_tools_view_generated_notices && Koha.Preference('NoticesManagement') ) %] +
    Notices management
    +
    View and print generated notices
    + [% END %] + [% IF ( CAN_user_tools_label_creator ) %]
    Patron card creator
    Create printable patron cards
    diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js index 71db55ae88..916de2ae2a 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js +++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js @@ -579,7 +579,9 @@ function patron_autocomplete(node, options) { ? "/cgi-bin/koha/circ/circulation.pl" : link_to == "reserve" ? "/cgi-bin/koha/reserve/request.pl" - : "/cgi-bin/koha/members/moremember.pl"; + : link_to == 'notices' + ? "/cgi-bin/koha/members/notices.pl" + : "/cgi-bin/koha/members/moremember.pl"; item.link += (url_params ? "?" + url_params + "&" : "?") + "borrowernumber=" + diff --git a/tools/notices.pl b/tools/notices.pl new file mode 100755 index 0000000000..432046d1d8 --- /dev/null +++ b/tools/notices.pl @@ -0,0 +1,95 @@ +#!/usr/bin/perl + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use CGI qw ( -utf8 ); +use C4::Auth qw( get_template_and_user ); +use C4::Output qw( output_html_with_http_headers ); +use Koha::Notice::Messages; +use Koha::DateUtils qw( dt_from_string ); + +my $query = CGI->new; +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "tools/notices.tt", + query => $query, + type => "intranet", + flagsrequired => { tools => 'view_generated_notices' }, + } +); + +unless ( C4::Context->preference('NoticesManagement') ) { + print $query->redirect('/cgi-bin/koha/tools/tools-home.pl'); +} + +my $op = $query->param('op'); + +if ( $op and $op eq 'search' ) { + my $letter_code = $query->param('letter_code') || undef; + my $categorycode = $query->param('categorycode') || undef; + my $branchcode = $query->param('branchcode') || undef; + my $from = $query->param('from') || undef; + my $to = $query->param('to') || undef; + my $status = $query->param('status') || undef; + + my %where = (); + $where{'me.letter_code'} = $letter_code if ($letter_code); + $where{'borrowernumber.categorycode'} = $categorycode if ($categorycode); + $where{'borrowernumber.branchcode'} = $branchcode if ($branchcode); + if ($from) { + if ($to) { + $where{'me.time_queued'} = [ + -and => { '<=', $to }, + { '>=', $from } + ]; + } else { + $where{'me.time_queued'} = { '>=', $from }; + } + } elsif ($to) { + $where{'me.time_queued'} = { '<=', $to }; + } + $where{'me.status'} = $status if ($status); + + my $notices = Koha::Notice::Messages->search( + {%where}, + { join => 'borrowernumber', order_by => { -desc => 'time_queued' } } + ); + + $template->param( + notices => $notices, + letter_code => $letter_code, + categorycode => $categorycode, + branchcode => $branchcode, + from => $from, + to => $to, + status => $status, + ); +} + +$template->param( + letters => Koha::Notice::Templates->search( + {}, { select => [ 'name', 'code' ], group_by => [ 'name', 'code' ], order_by => { -asc => 'code' } } + ), + attribute_type_codes => ( + C4::Context->preference('ExtendedPatronAttributes') + ? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ] + : [] + ), +); + +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/tools/print_notice.pl b/tools/print_notice.pl new file mode 100755 index 0000000000..74f2fd059b --- /dev/null +++ b/tools/print_notice.pl @@ -0,0 +1,60 @@ +#!/usr/bin/perl + +# Copyright 2023 Aleisha Amohia +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use CGI qw ( -utf8 ); +use C4::Context; +use C4::Output qw( output_html_with_http_headers ); +use C4::Auth qw( get_template_and_user ); + +my $input = CGI->new; + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "circ/printslip.tt", + query => $input, + type => "intranet", + flagsrequired => { tools => 'view_generated_notices' }, + } +); + +my @message_ids = $input->multi_param('message_ids'); +my @slips; +foreach my $message_id (@message_ids) { + my $message = Koha::Notice::Messages->find($message_id); + + my $template = Koha::Notice::Templates->find( $message->letter_id )->unblessed; + + push @slips, { + content => $message->content, + is_html => $template->{is_html}, + style => $template->{style}, + id => $message_id, + }; + + $message->update( { status => 'sent' } ); +} +$template->param( + slips => \@slips, + caller => 'notice_mgmt', + stylesheet => C4::Context->preference("SlipCSS"), + IntranetSlipPrinterJS => C4::Context->preference('IntranetSlipPrinterJS'), +); + +output_html_with_http_headers $input, $cookie, $template->output; -- 2.39.2