From c3b40a54992cc856bc3ff6d82c254d0bec896fb7 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 Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- 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 | 7 +++ .../intranet-tmpl/prog/js/members-menu.js | 48 ++++++------------- members/printslip.pl | 30 ++++++++---- tools/letter.pl | 3 ++ 8 files changed, 98 insertions(+), 49 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 673b61348b..99b2ad0d89 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -2538,8 +2538,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 ddb03e62f3..d49e3c15d2 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 f1881c7f6a..f7bee5e5d9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -715,10 +715,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 5b1d098d37..8476cfe0b2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt @@ -168,6 +168,7 @@
  • Interlibrary loans
  • Order acquisition
  • Patrons
  • +
  • Patrons toolbar (slip)
  • Preservation
  • Serials (new issue)
  • Suggestions
  • @@ -227,6 +228,7 @@ [% CASE 'reserves' %]Holds [% CASE 'ill' %]Interlibrary loans [% CASE 'members' %]Patrons + [% CASE 'patron_slip' %]Patrons toolbar (slip) [% CASE 'preservation' %]Preservation [% CASE 'serial' %]Serials (new issue) [% CASE 'suggestions' %]Suggestions @@ -393,6 +395,11 @@ [% ELSE %] [% END %] + [% IF ( module == "patron_slip" ) %] + + [% ELSE %] + + [% END %] [% IF ( module == "preservation" ) %] [% ELSE %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/members-menu.js b/koha-tmpl/intranet-tmpl/prog/js/members-menu.js index 5554a11413..a730bb4732 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/members-menu.js +++ b/koha-tmpl/intranet-tmpl/prog/js/members-menu.js @@ -45,38 +45,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(); @@ -155,12 +142,7 @@ 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 7971f83c67..d693b7e55c 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; @@ -76,7 +76,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, @@ -89,14 +89,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.39.5