Bugzilla – Attachment 29144 Details for
Bug 12285
Allow easy printing of patron's fines
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12285: Allow easy printing of patron's fines.
Bug-12285-Allow-easy-printing-of-patrons-fines.patch (text/plain), 7.19 KB, created by
Marc Véron
on 2014-06-22 14:21:10 UTC
(
hide
)
Description:
Bug 12285: Allow easy printing of patron's fines.
Filename:
MIME Type:
Creator:
Marc Véron
Created:
2014-06-22 14:21:10 UTC
Size:
7.19 KB
patch
obsolete
>From 1d058290825745f8ab43a6a4327667bb7773c6ba Mon Sep 17 00:00:00 2001 >From: Pasi Kallinen <pasi.kallinen@pttk.fi> >Date: Fri, 16 May 2014 10:43:53 +0300 >Subject: [PATCH] Bug 12285: Allow easy printing of patron's fines. > >Add a printing option to the staff client patron details page >to print a slip of patron's fines. > >To test: >1) Apply patch. >2) Check in tools > Notices & Slips that you have FINESLIP slip, > and a print message there. If not, run updatedatabase.pl >3) Either create some fines for a patron, or look up a patron > with existing fines. >4) From that patron's detail page, and the Print-menu in > the toolbar, select "Print fines" >5) You should get a slip of the patron's fines. > >I removed superfluous $ signs in sample_notices.sql and updatedatabase.pl >Patch works now as expected. However, it needs now a Sign-off by somebody else. >--- > C4/Members.pm | 62 ++++++++++++++++++++ > .../data/mysql/en/mandatory/sample_notices.sql | 15 +++++ > installer/data/mysql/updatedatabase.pl | 21 +++++++ > .../prog/en/includes/members-toolbar.inc | 6 ++ > members/printslip.pl | 6 +- > 5 files changed, 109 insertions(+), 1 deletion(-) > >diff --git a/C4/Members.pm b/C4/Members.pm >index 33106cf..b6d2a2e 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -101,6 +101,7 @@ BEGIN { > &GetMessagesCount > > &IssueSlip >+ &FineSlip > GetBorrowersWithEmail > > HasOverdues >@@ -2405,6 +2406,67 @@ sub IssueSlip { > ); > } > >+ >+sub GetBorrowerFines { >+ my ($borrowernumber) = @_; >+ my $dbh = C4::Context->dbh; >+ my $query = qq{ >+ SELECT * FROM accountlines >+ LEFT JOIN borrowers ON borrowers.borrowernumber = accountlines.borrowernumber >+ LEFT JOIN items ON accountlines.itemnumber = items.itemnumber >+ WHERE accountlines.borrowernumber = ? >+ ORDER BY accountlines.timestamp >+ }; >+ my $sth = $dbh->prepare( $query ); >+ $sth->execute( $borrowernumber ); >+ my $data = $sth->fetchall_arrayref({}); >+ return $data; >+} >+ >+sub FineSlip { >+ my ($borrowernumber, $branch) = @_; >+ >+ #my $now = POSIX::strftime("%Y-%m-%d", localtime); >+ >+ my $issueslist = GetBorrowerFines($borrowernumber); >+ >+ my $total = 0.0; >+ >+ foreach my $it (@$issueslist){ >+ my $dt = dt_from_string( $it->{'date'} ); >+ $it->{'date_due'} = output_pref({ dt => $dt, dateonly => 1 }); >+ $it->{'amount'} = sprintf('%.2f', $it->{'amount'}); >+ $total = $total + $it->{'amount'}; >+ $it->{'barcode'} = '-' if (!defined($it->{'barcode'})); >+ } >+ my @issues = sort { $b->{'timestamp'} <=> $a->{'timestamp'} } @$issueslist; >+ >+ my %repeat = ( >+ 'fines' => [ map { >+ 'fines' => $_, >+ 'borrowers' => $_, >+ 'items' => $_ >+ }, @issues ], >+ ); >+ >+ return C4::Letters::GetPreparedLetter ( >+ module => 'circulation', >+ letter_code => 'FINESLIP', >+ branchcode => $branch, >+ tables => { >+ 'branches' => $branch, >+ 'borrowers' => $borrowernumber, >+ }, >+ substitute => { >+ 'total.amount' => sprintf('%.2f', $total), >+ 'total.fines' => scalar(@issues) >+ }, >+ repeat => \%repeat, >+ message_transport_type => 'print', >+ ); >+} >+ >+ > =head2 GetBorrowersWithEmail > > ([$borrnum,$userid], ...) = GetBorrowersWithEmail('me@example.com'); >diff --git a/installer/data/mysql/en/mandatory/sample_notices.sql b/installer/data/mysql/en/mandatory/sample_notices.sql >index 2281739..a887580 100644 >--- a/installer/data/mysql/en/mandatory/sample_notices.sql >+++ b/installer/data/mysql/en/mandatory/sample_notices.sql >@@ -142,3 +142,18 @@ Thank you. > > Your library.' > ); >+ >+INSERT INTO letter (module, code, branchcode, name, is_html, title, content, message_transport_type) >+VALUES ( 'circulation', 'FINESLIP', '', 'Patron fines -slip', '1', 'Fines', '<<borrowers.firstname>> <<borrowers.surname>><br> >+<<borrowers.cardnumber>><br> >+Fines: <<total.fines>> >+<ul> >+<fines> >+<li><<fines.date_due>>, <<fines.amount>><br> >+Bar code: <<items.barcode>><br> >+<<fines.description>> >+</fines> >+</ul> >+Total: <<total.amount>> >+', 'print' >+); >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index c68ba51..09cd422 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -8560,6 +8560,27 @@ if ( CheckVersion($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "3.17.00.XXX"; >+if ( CheckVersion($DBversion) ) { >+ $dbh->do(" >+INSERT INTO letter (module, code, branchcode, name, is_html, title, content, message_transport_type) >+VALUES ( 'circulation', 'FINESLIP', '', 'Patron fines -slip', '1', 'Fines', '<<borrowers.firstname>> <<borrowers.surname>><br> >+<<borrowers.cardnumber>><br> >+Fines: <<total.fines>> >+<ul> >+<fines> >+<li><<fines.date_due>>, <<fines.amount>><br> >+Bar code: <<items.barcode>><br> >+<<fines.description>> >+</fines> >+</ul> >+Total: <<total.amount>> >+', 'print' >+);"); >+ print "Upgrade to $DBversion done (Bug 12285 - Allow easy printing of patron fines slip)\n"; >+ SetVersion($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >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 caa2fbf..8113c99 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc >@@ -38,6 +38,11 @@ $(document).ready(function(){ > $(".btn-group").removeClass("open"); > return false; > }); >+ $("#printfineslip").click(function(){ >+ printx_window("fineslip"); >+ $(".btn-group").removeClass("open"); >+ return false; >+ }); > $("#searchtohold").click(function(){ > searchToHold(); > return false; >@@ -124,6 +129,7 @@ function searchToHold(){ > [% 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="printfineslip" href="#">Print fines</a></li> > </ul> > </div> > <a id="searchtohold" class="btn btn-small" href="#"><i class="icon-search"></i> Search to hold</a> >diff --git a/members/printslip.pl b/members/printslip.pl >index 71fdda2..0c23442 100755 >--- a/members/printslip.pl >+++ b/members/printslip.pl >@@ -76,7 +76,11 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > my $borrowernumber = $input->param('borrowernumber'); > my $branch=C4::Context->userenv->{'branch'}; > my ($slip, $is_html); >-if (my $letter = IssueSlip ($session->param('branch') || $branch, $borrowernumber, $print eq "qslip")) { >+if ($print eq 'fineslip') { >+ my $letter = FineSlip($borrowernumber, $session->param('branch') || $branch); >+ $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}; > } >-- >1.7.10.4
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 12285
:
28327
|
29144
|
29692
|
123202
|
123203
|
123243
|
129723
|
129724
|
129922
|
129923
|
129937
|
129943
|
129944
|
129945
|
129946
|
129947
|
133112
|
133147
|
139037
|
139038
|
139039
|
139040
|
139041
|
139042
|
140795
|
140796
|
140797
|
140798
|
140799
|
140800