@@ -, +, @@ and a print message there. If not, run updatedatabase.pl with existing fines. the toolbar, select "Print fines" --- 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 --- a/C4/Members.pm +++ a/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; --- a/installer/data/mysql/atomicupdate/bug_12285 +++ a/installer/data/mysql/atomicupdate/bug_12285 @@ -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 INTO letter (module, code, branchcode, name, is_html, title, content, message_transport_type) VALUES ( "circulation", "FINESLIP", "", "Patron fines -slip", "1", "Fines and fees slip", "<> <>
<>
Fines: <>
  • <>, <>
    Barcode: <>
    <>
Total: <>", "print")| ); + + # Always end with this (adjust the bug info) + NewVersion( $DBversion, 12285, "Allow easy printing of patron's fines"); +} --- a/installer/data/mysql/en/mandatory/sample_notices.yml +++ a/installer/data/mysql/en/mandatory/sample_notices.yml @@ -1576,3 +1576,26 @@ tables: - "This item must be renewed at the library." - "[% END %]" - "[% END %]" + + - module: + code: FINESLIP + branchcode: "" + name: "Patron fines -slip" + is_html: 1 + title: "Fines and fees slip" + message_transport_type: pront + lang: default + content: + - "<> <>
" + - "<>
" + - "Fines: <>" + - "
    " + - "" + - "
  • "" + - "<>, <>
    " + - "Barcode: <>
    " + - "<>" + - "
  • " + - "
    " + - "
" + - "Total: <>" --- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc @@ -24,6 +24,7 @@
  • Print summary
  • Print slip
  • Print quick slip
  • +
  • Print fines
  • [% IF patron.has_overdues %]
  • Print overdues
  • [% END %] --- a/koha-tmpl/intranet-tmpl/prog/js/members-menu.js +++ a/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"); --- a/members/printslip.pl +++ a/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}; --