Bugzilla – Attachment 129943 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), 8.09 KB, created by
Owen Leonard
on 2022-01-28 14:00:43 UTC
(
hide
)
Description:
Bug 12285: Allow easy printing of patron's fines.
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2022-01-28 14:00:43 UTC
Size:
8.09 KB
patch
obsolete
>From 0c96882321ac4445b48041a4af913df15bbc2d37 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. > >Signed-off-by: Aleisha <aleishaamohia@hotmail.com> > >Rebased-by: Emmi Takkinen <emmi.takkinen@koha-suomi.fi> > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >--- > C4/Members.pm | 60 +++++++++++++++++++ > ...-allow_easy_printing_of_patrons_fines.perl | 10 ++++ > .../mysql/en/mandatory/sample_notices.yml | 23 +++++++ > .../prog/en/includes/members-toolbar.inc | 1 + > .../intranet-tmpl/prog/js/members-menu.js | 5 ++ > members/printslip.pl | 4 ++ > 6 files changed, 103 insertions(+) > create mode 100644 installer/data/mysql/atomicupdate/bug_12285-allow_easy_printing_of_patrons_fines.perl > >diff --git a/C4/Members.pm b/C4/Members.pm >index 143f410a8e..e3f58ee139 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -50,6 +50,7 @@ BEGIN { > GetBorrowersToExpunge > > IssueSlip >+ &FineSlip > > checkuserpassword > get_cardnumber_length >@@ -683,6 +684,65 @@ WHERE borrowernumber = 0 AND DATEDIFF( NOW(), timestamp ) > ?|; > return $cnt eq '0E0'? 0: $cnt; > } > >+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', >+ ); >+} >+ > END { } # module clean-up code here (global destructor) > > 1; >diff --git a/installer/data/mysql/atomicupdate/bug_12285-allow_easy_printing_of_patrons_fines.perl b/installer/data/mysql/atomicupdate/bug_12285-allow_easy_printing_of_patrons_fines.perl >new file mode 100644 >index 0000000000..78970f0cd4 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_12285-allow_easy_printing_of_patrons_fines.perl >@@ -0,0 +1,10 @@ >+$DBversion = 'XXX'; # will be replaced by the RM >+if( CheckVersion( $DBversion ) ) { >+ # you can use $dbh here like: >+ # $dbh->do( "ALTER TABLE biblio ADD COLUMN badtaste int" ); >+ >+ $dbh->do( qq| INSERT IGNORE INTO letter (module, code, branchcode, name, is_html, title, content, message_transport_type) VALUES ( "circulation", "FINESLIP", "", "Patron fines -slip", "1", "Fines and fees slip", "<<borrowers.firstname>> <<borrowers.surname>><br><<borrowers.cardnumber>><br>Fines: <<total.fines>><ul><fines><li><<fines.date_due>>, <<fines.amount>><br>Barcode: <<items.barcode>><br><<fines.description>></li></fines></ul>Total: <<total.amount>>", "print")| ); >+ >+ # Always end with this (adjust the bug info) >+ NewVersion( $DBversion, 12285, "Allow easy printing of patron's fines"); >+} >diff --git a/installer/data/mysql/en/mandatory/sample_notices.yml b/installer/data/mysql/en/mandatory/sample_notices.yml >index 52d0dbd4ce..ac01cb17ef 100644 >--- a/installer/data/mysql/en/mandatory/sample_notices.yml >+++ b/installer/data/mysql/en/mandatory/sample_notices.yml >@@ -1576,3 +1576,26 @@ tables: > - "This item must be renewed at the library." > - "[% END %]" > - "[% END %]" >+ >+ - module: circulation >+ code: FINESLIP >+ branchcode: "" >+ name: "Patron fines -slip" >+ is_html: 1 >+ title: "Fines and fees slip" >+ message_transport_type: pront >+ lang: default >+ content: >+ - "<<borrowers.firstname>> <<borrowers.surname>><br>" >+ - "<<borrowers.cardnumber>><br>" >+ - "Fines: <<total.fines>>" >+ - "<ul>" >+ - "<fines>" >+ - "<li>"" >+ - "<<fines.date_due>>, <<fines.amount>><br>" >+ - "Barcode: <<items.barcode>><br>" >+ - "<<fines.description>>" >+ - "</li>" >+ - "</fines>" >+ - "</ul>" >+ - "Total: <<total.amount>>" >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 6b0d8c12ac..7363202293 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc >@@ -24,6 +24,7 @@ > <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 id="printfineslip" href="#">Print fines</a></li> > [% IF patron.has_overdues %] > <li><a id="print_overdues" href="#">Print overdues</a></li> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/members-menu.js b/koha-tmpl/intranet-tmpl/prog/js/members-menu.js >index def803d274..ed92dacb28 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/members-menu.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/members-menu.js >@@ -78,6 +78,11 @@ $(document).ready(function(){ > $(".btn-group").removeClass("open"); > return false; > }); >+ $("#printfineslip").click(function(){ >+ printx_window("fineslip"); >+ $(".btn-group").removeClass("open"); >+ return false; >+ }); > $("#printclearscreen").click(function(){ > printx_window("slip"); > window.location.replace("/cgi-bin/koha/circ/circulation.pl"); >diff --git a/members/printslip.pl b/members/printslip.pl >index 368d84cc7f..4cdeb0d3de 100755 >--- a/members/printslip.pl >+++ b/members/printslip.pl >@@ -94,6 +94,10 @@ if ( $print eq 'checkinslip' ) { > $slip = $letter->{content}; > $is_html = $letter->{is_html}; > >+} elsif ($print eq 'fineslip') { >+ my $letter = C4::Members::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}; >-- >2.20.1
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