@@ -, +, @@ and a print message there. If not, run updatedatabase.pl with existing fines. the toolbar, select "Print 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(-) --- a/C4/Members.pm +++ a/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'); --- a/installer/data/mysql/en/mandatory/sample_notices.sql +++ a/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', '<> <>
+<>
+Fines: <> +
    + +
  • <>, <>
    +Bar code: <>
    +<> + +
+Total: <> +', 'print' +); --- a/installer/data/mysql/updatedatabase.pl +++ a/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', '<> <>
+<>
+Fines: <> +
    + +
  • <>, <>
    +Bar code: <>
    +<> + +
+Total: <> +', 'print' +);"); + print "Upgrade to $DBversion done (Bug 12285 - Allow easy printing of patron fines slip)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) --- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc +++ a/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 ) %]
  • Print summary
  • [% END %]
  • Print slip
  • Print quick slip
  • +
  • Print fines
  • Search to hold --- a/members/printslip.pl +++ a/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}; } --