Bugzilla – Attachment 43514 Details for
Bug 12933
Add ability to print overdue slip from staff intranet
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12933 - Add ability to print overdue slip from staff intranet
Bug-12933---Add-ability-to-print-overdue-slip-from.patch (text/plain), 13.67 KB, created by
Kyle M Hall (khall)
on 2015-10-16 14:32:04 UTC
(
hide
)
Description:
Bug 12933 - Add ability to print overdue slip from staff intranet
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2015-10-16 14:32:04 UTC
Size:
13.67 KB
patch
obsolete
>From db9a50edb5d3ab3b8cea32866174e19d9055222f Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 16 Sep 2014 12:51:13 -0400 >Subject: [PATCH] Bug 12933 - Add ability to print overdue slip from staff intranet > >Some librarians would like to be able to print an overdues slip from the >staff intranet. This slip would be defined as the print transport >version of the ODUE slip. > >Test Plan: >1) Apply this patch >2) Locate a patron with overdues >3) Define a print version of the OVERDUES_SLIP slip >4) Try Print > Print overdues > >Signed-off-by: Amy Purvis <APurvis@galencollege.edu> >Signed-off-by: Laurie McKee <lmckee@littleelm.org> >--- > C4/Members.pm | 20 ++++++ > C4/Overdues.pm | 71 ++++++++++++++++++++ > Koha/Template/Plugin/Borrowers.pm | 12 +++- > .../prog/en/includes/members-toolbar.inc | 11 +++- > .../prog/en/modules/circ/printslip.tt | 4 +- > members/print_overdues.pl | 67 ++++++++++++++++++ > misc/cronjobs/overdue_notices.pl | 71 +------------------- > 7 files changed, 183 insertions(+), 73 deletions(-) > create mode 100755 members/print_overdues.pl > >diff --git a/C4/Members.pm b/C4/Members.pm >index 5fb1764..55d4166 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -108,6 +108,7 @@ BEGIN { > GetBorrowersWithEmail > > HasOverdues >+ GetOverdues > ); > > #Modify data >@@ -2552,6 +2553,25 @@ WHERE borrowernumber = 0 AND DATEDIFF( NOW(), timestamp ) > ?|; > return $cnt eq '0E0'? 0: $cnt; > } > >+sub GetOverdues { >+ my ( $borrowernumber ) = @_; >+ >+ my $sql = " >+ SELECT * >+ FROM issues, items, biblio, biblioitems >+ WHERE items.itemnumber=issues.itemnumber >+ AND biblio.biblionumber = items.biblionumber >+ AND biblio.biblionumber = biblioitems.biblionumber >+ AND issues.borrowernumber = ? >+ AND date_due < NOW() >+ "; >+ >+ my $sth = C4::Context->dbh->prepare( $sql ); >+ $sth->execute( $borrowernumber ); >+ >+ return $sth->fetchall_arrayref({}); >+} >+ > END { } # module clean-up code here (global destructor) > > 1; >diff --git a/C4/Overdues.pm b/C4/Overdues.pm >index 6eeb6cf..14cba96 100644 >--- a/C4/Overdues.pm >+++ b/C4/Overdues.pm >@@ -24,12 +24,14 @@ use strict; > use Date::Calc qw/Today Date_to_Days/; > use Date::Manip qw/UnixDate/; > use List::MoreUtils qw( uniq ); >+use Locale::Currency::Format 1.28; > > use C4::Circulation; > use C4::Context; > use C4::Accounts; > use C4::Log; # logaction > use C4::Debug; >+use C4::Budgets qw(GetCurrency); > > use vars qw($VERSION @ISA @EXPORT); > >@@ -53,6 +55,7 @@ BEGIN { > &RemoveNotifyLine > &AddNotifyLine > &GetOverdueMessageTransportTypes >+ &parse_letter > ); > # subs to remove > push @EXPORT, qw( >@@ -949,6 +952,74 @@ sub GetOverdueMessageTransportTypes { > return \@mtts; > } > >+=head2 parse_letter >+ >+parses the letter template, replacing the placeholders with data >+specific to this patron, biblio, or item for overdues >+ >+named parameters: >+ letter - required hashref >+ borrowernumber - required integer >+ substitute - optional hashref of other key/value pairs that should >+ be substituted in the letter content >+ >+returns the C<letter> hashref, with the content updated to reflect the >+substituted keys and values. >+ >+=cut >+ >+sub parse_letter { >+ my $params = shift; >+ foreach my $required (qw( letter_code borrowernumber )) { >+ return unless ( exists $params->{$required} && $params->{$required} ); >+ } >+ >+ my $substitute = $params->{'substitute'} || {}; >+ $substitute->{today} ||= C4::Dates->new()->output("syspref"); >+ >+ my %tables = ( 'borrowers' => $params->{'borrowernumber'} ); >+ if ( my $p = $params->{'branchcode'} ) { >+ $tables{'branches'} = $p; >+ } >+ >+ my $currencies = GetCurrency(); >+ my $currency_format; >+ $currency_format = $currencies->{currency} if defined($currencies); >+ >+ my @item_tables; >+ if ( my $i = $params->{'items'} ) { >+ my $item_format = ''; >+ foreach my $item (@$i) { >+ my $fine = GetFine($item->{'itemnumber'}, $params->{'borrowernumber'}); >+ if ( !$item_format and defined $params->{'letter'}->{'content'} ) { >+ $params->{'letter'}->{'content'} =~ m/(<item>.*<\/item>)/; >+ $item_format = $1; >+ } >+ >+ $item->{'fine'} = currency_format($currency_format, "$fine", FMT_SYMBOL); >+ # if active currency isn't correct ISO code fallback to sprintf >+ $item->{'fine'} = sprintf('%.2f', $fine) unless $item->{'fine'}; >+ >+ push @item_tables, { >+ 'biblio' => $item->{'biblionumber'}, >+ 'biblioitems' => $item->{'biblionumber'}, >+ 'items' => $item, >+ 'issues' => $item->{'itemnumber'}, >+ }; >+ } >+ } >+ >+ return C4::Letters::GetPreparedLetter ( >+ module => 'circulation', >+ letter_code => $params->{'letter_code'}, >+ branchcode => $params->{'branchcode'}, >+ tables => \%tables, >+ substitute => $substitute, >+ repeat => { item => \@item_tables }, >+ message_transport_type => $params->{message_transport_type}, >+ ); >+} >+ > 1; > __END__ > >diff --git a/Koha/Template/Plugin/Borrowers.pm b/Koha/Template/Plugin/Borrowers.pm >index b8f3de5..3e2c59b 100644 >--- a/Koha/Template/Plugin/Borrowers.pm >+++ b/Koha/Template/Plugin/Borrowers.pm >@@ -22,7 +22,8 @@ use Modern::Perl; > > use base qw( Template::Plugin ); > >-use Koha::Borrower::Debarments qw//; >+use Koha::Borrower::Debarments qw(); >+use C4::Members qw(HasOverdues); > > =pod > >@@ -48,4 +49,13 @@ sub IsDebarred { > return Koha::Borrower::Debarments::IsDebarred($borrower->{borrowernumber}); > } > >+sub HasOverdues { >+ my ( $self, $borrowernumber ) = @_; >+ >+ return unless $borrowernumber; >+ >+ return C4::Members::HasOverdues($borrowernumber); >+} >+ >+ > 1; >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 318f690..1ace189 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc >@@ -1,4 +1,5 @@ > [% USE Koha %] >+[% USE Borrowers %] > [% SET NorwegianPatronDBEnable = Koha.Preference( 'NorwegianPatronDBEnable' ) %] > <script type="text/javascript"> > //<![CDATA[ >@@ -58,6 +59,11 @@ $(document).ready(function(){ > $(".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; >+ }); > $("#searchtohold").click(function(){ > searchToHold(); > return false; >@@ -153,7 +159,10 @@ function searchToHold(){ > <ul class="dropdown-menu"> > [% IF ( CAN_user_borrowers ) %]<li><a id="printsummary" href="#">Print summary</a></li>[% END %] > <li><a id="printslip" href="#">Print slip</a></li> >- <li><a id="printquickslip" href="#">Print quick slip</a></li> >+ <li><a id="printquickslip" href="#">Print quick slip[% Borrowers.HasOverdues( borrowernumber ) %]</a></li> >+ [% IF Borrowers.HasOverdues( borrowernumber ) %] >+ <li><a id="print_overdues" href="#">Print overdues</a></li> >+ [% END %] > </ul> > </div> > <a id="searchtohold" class="btn btn-small" href="#"><i class="icon-search"></i> Search to hold</a> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt >index b14ed28..e6c3f2b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt >@@ -1,11 +1,13 @@ > [% USE Koha %] > [% INCLUDE 'doc-head-open.inc' %] >-[% IF ( caller = 'hold-transfer' ) %] >+[% IF ( caller == 'hold-transfer' ) %] > <title>Koha › Circulation › Hold transfer print receipt</title> > [% ELSIF ( caller == 'transfer' ) %] > <title>Koha › Circulation › Transfers print receipt</title> > [% ELSIF ( caller == 'members' ) %] > <title>Koha › Members › Print receipt for [% borrowernumber %]</title> >+[% ELSIF ( title ) %] >+<title>Koha › Members › [% title %]</title> > [% END %] > > <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> >diff --git a/members/print_overdues.pl b/members/print_overdues.pl >new file mode 100755 >index 0000000..3cc204b >--- /dev/null >+++ b/members/print_overdues.pl >@@ -0,0 +1,67 @@ >+#!/usr/bin/perl >+ >+# Copyright 2014 ByWater Solutions >+# >+# 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, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use CGI; >+ >+use C4::Context; >+use C4::Auth; >+use C4::Output; >+use C4::Members qw(GetOverdues); >+use C4::Overdues qw(parse_letter); >+ >+my $input = new CGI; >+ >+my $flagsrequired = { circulate => "circulate_remaining_permissions" }; >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "circ/printslip.tt", >+ query => $input, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => $flagsrequired, >+ debug => 1, >+ } >+); >+ >+my $borrowernumber = $input->param('borrowernumber'); >+my $branchcode = C4::Context->userenv->{'branch'}; >+ >+my $overdues = GetOverdues($borrowernumber); >+ >+my $letter = parse_letter( >+ { >+ letter_code => 'OVERDUES_SLIP', >+ borrowernumber => $borrowernumber, >+ branchcode => $branchcode, >+ items => $overdues, >+ message_transport_type => 'print', >+ } >+); >+ >+$template->param( >+ slip => $letter->{content}, >+ title => $letter->{name}, >+ plain => !$letter->{is_html}, >+ borrowernumber => $borrowernumber, >+); >+ >+output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl >index 482be02..b9c0767 100755 >--- a/misc/cronjobs/overdue_notices.pl >+++ b/misc/cronjobs/overdue_notices.pl >@@ -43,10 +43,10 @@ use C4::Debug; > use C4::Letters; > use C4::Overdues qw(GetFine GetOverdueMessageTransportTypes); > use C4::Budgets qw(GetCurrency); >+use C4::Log; > use Koha::Borrower::Debarments qw(AddUniqueDebarment); > use Koha::DateUtils; > use Koha::Calendar; >-use C4::Log; > > =head1 NAME > >@@ -829,75 +829,6 @@ if ( defined $htmlfilename ) { > > These methods are internal to the operation of overdue_notices.pl. > >-=head2 parse_letter >- >-parses the letter template, replacing the placeholders with data >-specific to this patron, biblio, or item >- >-named parameters: >- letter - required hashref >- borrowernumber - required integer >- substitute - optional hashref of other key/value pairs that should >- be substituted in the letter content >- >-returns the C<letter> hashref, with the content updated to reflect the >-substituted keys and values. >- >- >-=cut >- >-sub parse_letter { >- my $params = shift; >- foreach my $required (qw( letter_code borrowernumber )) { >- return unless ( exists $params->{$required} && $params->{$required} ); >- } >- >- my $substitute = $params->{'substitute'} || {}; >- $substitute->{today} ||= C4::Dates->new()->output("syspref"); >- >- my %tables = ( 'borrowers' => $params->{'borrowernumber'} ); >- if ( my $p = $params->{'branchcode'} ) { >- $tables{'branches'} = $p; >- } >- >- my $currencies = GetCurrency(); >- my $currency_format; >- $currency_format = $currencies->{currency} if defined($currencies); >- >- my @item_tables; >- if ( my $i = $params->{'items'} ) { >- my $item_format = ''; >- foreach my $item (@$i) { >- my $fine = GetFine($item->{'itemnumber'}, $params->{'borrowernumber'}); >- if ( !$item_format and defined $params->{'letter'}->{'content'} ) { >- $params->{'letter'}->{'content'} =~ m/(<item>.*<\/item>)/; >- $item_format = $1; >- } >- >- $item->{'fine'} = currency_format($currency_format, "$fine", FMT_SYMBOL); >- # if active currency isn't correct ISO code fallback to sprintf >- $item->{'fine'} = sprintf('%.2f', $fine) unless $item->{'fine'}; >- >- push @item_tables, { >- 'biblio' => $item->{'biblionumber'}, >- 'biblioitems' => $item->{'biblionumber'}, >- 'items' => $item, >- 'issues' => $item->{'itemnumber'}, >- }; >- } >- } >- >- return C4::Letters::GetPreparedLetter ( >- module => 'circulation', >- letter_code => $params->{'letter_code'}, >- branchcode => $params->{'branchcode'}, >- tables => \%tables, >- substitute => $substitute, >- repeat => { item => \@item_tables }, >- message_transport_type => $params->{message_transport_type}, >- ); >-} >- > =head2 prepare_letter_for_printing > > returns a string of text appropriate for printing in the event that an >-- >1.7.2.5
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 12933
:
31638
|
31667
|
34456
|
34457
|
34467
|
34468
|
34469
|
34470
|
34471
|
34474
|
34475
|
34884
|
34885
|
34886
|
34887
|
34888
|
34889
|
35533
|
35534
|
35535
|
35536
|
35537
|
35538
|
35918
|
41606
|
41607
|
41608
|
41609
|
41610
|
41611
|
43514
|
43515
|
43516
|
43517
|
43518
|
43519
|
43520
|
43521
|
43522
|
43523
|
43904
|
43905
|
43906
|
43907
|
43908
|
43925
|
43926
|
43927
|
43928
|
43929
|
43930
|
43953