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 <andrewfh@dubcolib.org>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Nick Clemens 2023-02-16 19:50:49 +00:00 committed by Tomas Cohen Arazi
parent 5ef8eac364
commit c3b40a5499
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
8 changed files with 98 additions and 49 deletions

View File

@ -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 <http://www.gnu.org/licenses>.
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;

View File

@ -2538,8 +2538,7 @@ td.bundle {
}
}
#printclearscreen,
#printclearscreenq {
.printclearscreen {
position: absolute;
right: 43px;
top: 0;

View File

@ -2,6 +2,7 @@
[% USE Koha %]
[% USE Branches %]
[% USE Categories %]
[% USE Notices %]
[% USE AuthorisedValues %]
[% USE scalar %]
<div id="toolbar" class="btn-toolbar">
@ -21,16 +22,20 @@
<div class="btn-group">
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-print"></i> Print <span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a id="printsummary" href="#">Print summary</a></li>
<li><a id="printslip" href="#">Print slip</a></li>
<li><a id="printquickslip" href="#">Print quick slip</a></li>
<li><a class="printslip" data-code="printsummary" href="#">Print summary</a></li>
<li><a class="printslip" data-code="issueslip" href="#">Print slip</a></li>
<li><a class="printslip" data-code="issueqslip" href="#">Print quick slip</a></li>
[% IF patron.account_balance != 0 %]
<li><a id="printfineslip" target="_blank" href="/cgi-bin/koha/members/printnotice.pl?notice=ACCOUNTS_SUMMARY&borrowernumber=[% patron.borrowernumber | uri %]">Print account balance</a></li>
[% END %]
[% IF patron.has_overdues %]
<li><a id="print_overdues" href="#">Print overdues</a></li>
[% END %]
<li><a id="printcheckinslip" href="#">Print checkin slip</a></li>
<li><a class="printslip" data-code="checkinslip" href="#">Print checkin slip</a></li>
[% FOREACH notice IN Notices.GetTemplates( 'patron_slip' ) %]
<li><a class="printslip" data-code="[% notice.code %]" href="#">Print [% notice.name %] slip</a></li>
[% END %]
</ul>
</div>
[% END %]

View File

@ -715,10 +715,10 @@
[% IF Koha.Preference('DisplayClearScreenButton') == 'issueslip' %]
<span id="clearscreen"><a href="/cgi-bin/koha/circ/circulation.pl" title="Clear screen">x</a></span>
<span id="printclearscreen"><a href="#" title="Print slip and clear screen"><i class="fa fa-print"></i></a></span>
<span class="printslip printclearscreen" data-clear="true" data-code="issueslip"><a href="#" title="Print slip and clear screen"><i class="fa fa-print"></i></a></span>
[% ELSIF Koha.Preference('DisplayClearScreenButton') == 'issueqslip' %]
<span id="clearscreen"><a href="/cgi-bin/koha/circ/circulation.pl" title="Clear screen">x</a></span>
<span id="printclearscreenq"><a href="#" title="Print quick slip and clear screen"><i class="fa fa-print"></i></a></span>
<span class="printslip printclearscreen" data-clear="true" data-code="issueqslip"><a href="#" title="Print quick slip and clear screen"><i class="fa fa-print"></i></a></span>
[% END %]
[% IF (forceallow) %]<input type="hidden" name="forceallow" value="1">[% END %]

View File

@ -168,6 +168,7 @@
<li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&amp;module=ill">Interlibrary loans</a></li>
<li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&amp;module=orderacquisition">Order acquisition</a></li>
<li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&amp;module=members">Patrons</a></li>
<li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&amp;module=patron_slip">Patrons toolbar (slip)</a></li>
<li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&amp;module=preservation">Preservation</a></li>
<li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&amp;module=serial">Serials (new issue)</a></li>
<li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&amp;module=suggestions">Suggestions</a></li>
@ -227,6 +228,7 @@
[% CASE 'reserves' %]<span>Holds</span>
[% CASE 'ill' %]<span>Interlibrary loans</span>
[% CASE 'members' %]<span>Patrons</span>
[% CASE 'patron_slip' %]<span>Patrons toolbar (slip)</span>
[% CASE 'preservation' %]<span>Preservation</span>
[% CASE 'serial' %]<span>Serials (new issue)</span>
[% CASE 'suggestions' %]<span>Suggestions</span>
@ -393,6 +395,11 @@
[% ELSE %]
<option value="members">Patrons</option>
[% END %]
[% IF ( module == "patron_slip" ) %]
<option value="patron_slip" selected="selected">Patron toolbar (slip)</option>
[% ELSE %]
<option value="patron_slip">Patron toolbar (slip)</option>
[% END %]
[% IF ( module == "preservation" ) %]
<option value="preservation" selected="selected">Preservation</option>
[% ELSE %]

View File

@ -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 + "&amp;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));

View File

@ -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,

View File

@ -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');
}