From 7e794aacca2b1c8071dd8c442266a2d2e145e660 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 16 Feb 2023 19:50:49 +0000 Subject: [PATCH] Bug 32986: Add patron_slip module to letters and allow printing on members account This patch adds a new module to letters 'patron_slip' / Patrons toolbar (slip) This also combines some of the slip printing JS to make things more direct To test: 1 - Apply patch 2 - restart_all 3 - yarn build 4 - Confirm you can print slip, summary, quickslip, and checkin slip when viewing a patron's account 5 - Enable DisplayClearScreenButton syspref, and test that it works with both values 6 - Go to Tools->Notices and slips 7 - Define a new notice in the 'Patron toolbar (slip)' module 8 - Enter content like below in the 'Print' transport: Patron has [% borrower.holds.count %] holds List of holds: [% FOREACH hold IN borrower.holds %] =============================== Reserve id: [% hold.reserve_id %] Title [% hold.biblio.title %] [% END %] 9 - Go to patron scree 10 - Note new option under 'Print' 11 - Print the new slip and confirm it works (try with and without placing holds for patron --- Koha/Template/Plugin/Notices.pm | 39 +++++++++++++++ .../prog/css/src/staff-global.scss | 3 +- .../prog/en/includes/members-toolbar.inc | 13 +++-- .../prog/en/modules/circ/circulation.tt | 4 +- .../prog/en/modules/tools/letter.tt | 9 +++- .../intranet-tmpl/prog/js/members-menu.js | 47 ++++++------------- members/printslip.pl | 30 ++++++++---- tools/letter.pl | 3 ++ 8 files changed, 98 insertions(+), 50 deletions(-) create mode 100644 Koha/Template/Plugin/Notices.pm diff --git a/Koha/Template/Plugin/Notices.pm b/Koha/Template/Plugin/Notices.pm new file mode 100644 index 0000000000..7e997483a6 --- /dev/null +++ b/Koha/Template/Plugin/Notices.pm @@ -0,0 +1,39 @@ +package Koha::Template::Plugin::Notices; + +# Copyright ByWater Solutions 2023 + +# 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 Template::Plugin; +use base qw( Template::Plugin ); + +use C4::Koha; +use C4::Context; +use Koha::Notice::Templates; + +sub GetTemplates { + my ( $self, $module ) = @_; + my $params = {}; + $params->{module} = $module if $module; + + my @letters = Koha::Notice::Templates->search($params)->as_list; + + return \@letters; +} + +1; diff --git a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss index 9b1534fdbd..82d51e86a0 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -2520,8 +2520,7 @@ td.bundle { } } -#printclearscreen, -#printclearscreenq { +.printclearscreen { position: absolute; right: 43px; top: 0; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc index 311044ad71..df26293f09 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc @@ -2,6 +2,7 @@ [% USE Koha %] [% USE Branches %] [% USE Categories %] +[% USE Notices %] [% USE AuthorisedValues %] [% USE scalar %]
@@ -21,16 +22,20 @@
[% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index ffb0a930d8..c735c863c9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -649,10 +649,10 @@ [% IF Koha.Preference('DisplayClearScreenButton') == 'issueslip' %] x - + [% ELSIF Koha.Preference('DisplayClearScreenButton') == 'issueqslip' %] x - + [% END %] [% IF (forceallow) %][% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt index 1dc23f228e..2a11246d32 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt @@ -176,6 +176,7 @@
  • Interlibrary loans
  • Order acquisition
  • Patrons
  • +
  • Patrons toolbar (slip)
  • Serials (new issue)
  • Suggestions
  • Point of sale
  • @@ -232,7 +233,8 @@ [% CASE 'claimissues' %]Claim serial issue [% CASE 'reserves' %]Holds [% CASE 'ill' %]Interlibrary loans - [% CASE 'members' %]Patrons + [% CASE 'members' %]Patrons + [% CASE 'patron_slip' %]Patrons toolbar (slip) [% CASE 'serial' %]Serials (new issue) [% CASE 'suggestions' %]Suggestions [% CASE 'pos' %]Point of sale @@ -391,6 +393,11 @@ [% ELSE %] [% END %] + [% IF ( module == "patron_slip" ) %] + + [% ELSE %] + + [% END %] [% IF ( module == "serial" ) %] [% ELSE %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/members-menu.js b/koha-tmpl/intranet-tmpl/prog/js/members-menu.js index b020966e58..92c2266031 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/members-menu.js +++ b/koha-tmpl/intranet-tmpl/prog/js/members-menu.js @@ -41,38 +41,25 @@ $(document).ready(function(){ $(".btn-group").removeClass("open"); return false; }); - $("#printsummary").click(function(){ - printx_window("page"); - $(".btn-group").removeClass("open"); - return false; - }); - $("#printslip").click(function(){ - printx_window("slip"); - $(".btn-group").removeClass("open"); - return false; - }); - $("#printquickslip").click(function(){ - printx_window("qslip"); - $(".btn-group").removeClass("open"); - return false; - }); $("#print_overdues").click(function(){ window.open("/cgi-bin/koha/members/print_overdues.pl?borrowernumber=" + borrowernumber, "printwindow"); $(".btn-group").removeClass("open"); return false; }); - $("#printcheckinslip").click(function(){ - printx_window("checkinslip"); - $(".btn-group").removeClass("open"); - return false; - }); - $("#printclearscreen").click(function(){ - printx_window("slip"); - window.location.replace("/cgi-bin/koha/circ/circulation.pl"); - }); - $("#printclearscreenq").click(function(){ - printx_window("qslip"); - window.location.replace("/cgi-bin/koha/circ/circulation.pl"); + $(".printslip").click(function(){ + let slip_code = $(this).data('code'); + let clear_screen = $(this).data('clear'); + if( slip_code == 'printsummary' ){ + window.open("/cgi-bin/koha/members/summary-print.pl?borrowernumber=" + borrowernumber, "printwindow"); + } else { + window.open("/cgi-bin/koha/members/printslip.pl?borrowernumber=" + borrowernumber + "&print=" + slip_code, "printwindow"); + } + if( clear_screen ){ + window.location.replace("/cgi-bin/koha/circ/circulation.pl"); + } else { + $(".btn-group").removeClass("open"); + return false; + } }); $("#searchtohold").click(function(){ searchToHold(); @@ -151,12 +138,6 @@ function confirm_reregistration() { function export_barcodes() { window.open('/cgi-bin/koha/members/readingrec.pl?borrowernumber=' + borrowernumber + '&op=export_barcodes'); } -var slip_re = /slip/; -function printx_window(print_type) { - var handler = print_type.match(slip_re) ? "printslip" : "summary-print"; - window.open("/cgi-bin/koha/members/" + handler + ".pl?borrowernumber=" + borrowernumber + "&print=" + print_type, "printwindow"); - return false; -} function searchToHold(){ var date = new Date(); date.setTime(date.getTime() + (10 * 60 * 1000)); diff --git a/members/printslip.pl b/members/printslip.pl index 368d84cc7f..c609efda71 100755 --- a/members/printslip.pl +++ b/members/printslip.pl @@ -66,7 +66,7 @@ my $patron = Koha::Patrons->find( $borrowernumber ); output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); my $branch=C4::Context->userenv->{'branch'}; -my ($slip, $is_html); +my ($letter, $slip, $is_html); if ( $print eq 'checkinslip' ) { my $checkinslip_branch = $session->param('branch') ? $session->param('branch') : $branch; @@ -78,7 +78,7 @@ if ( $print eq 'checkinslip' ) { old_issues => \@issue_ids, ); - my $letter = C4::Letters::GetPreparedLetter( + $letter = C4::Letters::GetPreparedLetter( module => 'circulation', letter_code => 'CHECKINSLIP', branchcode => $checkinslip_branch, @@ -91,14 +91,28 @@ if ( $print eq 'checkinslip' ) { message_transport_type => 'print' ); - $slip = $letter->{content}; - $is_html = $letter->{is_html}; - -} elsif (my $letter = IssueSlip ($session->param('branch') || $branch, $borrowernumber, $print eq "qslip")) { - $slip = $letter->{content}; - $is_html = $letter->{is_html}; +} elsif ( $print eq 'issueslip' ){ + $letter = IssueSlip ($session->param('branch') || $branch, $borrowernumber, 0); +} elsif ( $print eq 'issueqslip' ){ + $letter = IssueSlip ($session->param('branch') || $branch, $borrowernumber, 1); +} else { + $letter = C4::Letters::GetPreparedLetter( + module => 'patron_slip', + letter_code => $print, + branchcode => $branch, + lang => $patron->lang, + tables => { + branches => $branch, + borrowers => $borrowernumber + }, + message_transport_type => 'print' + ); } +$slip = $letter->{content}; +$is_html = $letter->{is_html}; + + $template->param( slip => $slip, plain => !$is_html, diff --git a/tools/letter.pl b/tools/letter.pl index c00cc6de3d..85452aa531 100755 --- a/tools/letter.pl +++ b/tools/letter.pl @@ -252,6 +252,9 @@ sub add_form { elsif ($module eq 'claimissues') { push @{$field_selection}, add_fields('aqbooksellers', 'serial', 'subscription', 'biblio', 'biblioitems'); } + elsif ($module eq 'patron_slip') { + push @{$field_selection}, add_fields('borrowers'); + } elsif ($module eq 'serial') { push @{$field_selection}, add_fields('branches', 'biblio', 'biblioitems', 'borrowers', 'subscription', 'serial'); } -- 2.30.2