Bugzilla – Attachment 28327 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]
Add a printing option to the staff client patron details page to print a slip of patron's fines.
0001-Bug-12285-Allow-easy-printing-of-patron-s-fines.patch (text/plain), 7.06 KB, created by
paxed
on 2014-05-19 10:34:44 UTC
(
hide
)
Description:
Add a printing option to the staff client patron details page to print a slip of patron's fines.
Filename:
MIME Type:
Creator:
paxed
Created:
2014-05-19 10:34:44 UTC
Size:
7.06 KB
patch
obsolete
>From d04044963731094f27761fe099ea13743f7120f5 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. >--- > 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 f832495..abd82e0 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -100,6 +100,7 @@ BEGIN { > &GetMessagesCount > > &IssueSlip >+ &FineSlip > GetBorrowersWithEmail > > HasOverdues >@@ -2394,6 +2395,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..cf79aa2 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' >+); >\ No newline at end of file >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 3b1718c..7ec111d 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -8465,6 +8465,27 @@ if ( CheckVersion($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "3.15.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.8.3.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 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