Bugzilla – Attachment 148376 Details for
Bug 32986
Add ability to generate custom slips for patrons
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32986: Add patron_slip module to letters and allow printing on members account
Bug-32986-Add-patronslip-module-to-letters-and-all.patch (text/plain), 15.53 KB, created by
ByWater Sandboxes
on 2023-03-17 16:06:15 UTC
(
hide
)
Description:
Bug 32986: Add patron_slip module to letters and allow printing on members account
Filename:
MIME Type:
Creator:
ByWater Sandboxes
Created:
2023-03-17 16:06:15 UTC
Size:
15.53 KB
patch
obsolete
>From d95590cdc3ee1d129bd61b1b71de4a32b97616ff Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >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 <andrewfh@dubcolib.org> >--- > 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 <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; >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 %] > <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 %] >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' %] > <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 %] >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 @@ > <li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&module=ill">Interlibrary loans</a></li> > <li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&module=orderacquisition">Order acquisition</a></li> > <li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&module=members">Patrons</a></li> >+ <li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&module=patron_slip">Patrons toolbar (slip)</a></li> > <li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&module=serial">Serials (new issue)</a></li> > <li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&module=suggestions">Suggestions</a></li> > <li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&module=pos">Point of sale</a></li> >@@ -232,7 +233,8 @@ > [% CASE 'claimissues' %]<span>Claim serial issue</span> > [% CASE 'reserves' %]<span>Holds</span> > [% CASE 'ill' %]<span>Interlibrary loans</span> >- [% CASE 'members' %]<span>Patrons</span> >+ [% CASE 'members' %]<span>Patrons</span> >+ [% CASE 'patron_slip' %]<span>Patrons toolbar (slip)</span> > [% CASE 'serial' %]<span>Serials (new issue)</span> > [% CASE 'suggestions' %]<span>Suggestions</span> > [% CASE 'pos' %]<span>Point of sale</span> >@@ -391,6 +393,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 == "serial" ) %] > <option value="serial" selected="selected">Serials (new issue)</option> > [% 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
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 32986
:
146750
|
148267
|
148361
|
148374
|
148376
|
149506
|
149507
|
153479
|
153480
|
153481
|
153482
|
156800
|
158399
|
158400
|
158401
|
158402
|
158403
|
158404
|
158405
|
158523