3 # Copyright Koustubha Kale 2010
4 # Copyright PTFS Europe 2020
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # Koha is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with Koha; if not, see <http://www.gnu.org/licenses>.
23 use C4::Auth qw( get_template_and_user );
24 use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers );
27 use Koha::Account::Lines;
31 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
33 template_name => "members/printinvoice.tt",
37 borrowers => 'edit_borrowers',
38 updatecharges => 'remaining_permissions'
43 my $debit_id = $input->param('accountlines_id');
44 my $debit = Koha::Account::Lines->find($debit_id);
45 my $patron = $debit->patron;
47 my $logged_in_user = Koha::Patrons->find($loggedinuser) or die "Not logged in";
48 output_and_exit_if_error(
53 logged_in_user => $logged_in_user,
54 current_patron => $patron
58 my $letter = C4::Letters::GetPreparedLetter(
59 module => 'circulation',
60 letter_code => 'DEBIT_' . $debit->debit_type_code,
61 branchcode => C4::Context::mybranch,
62 message_transport_type => 'print',
63 lang => $patron->lang,
66 borrowers => $patron->borrowernumber
70 $letter //= C4::Letters::GetPreparedLetter(
71 module => 'circulation',
72 letter_code => 'ACCOUNT_DEBIT',
73 branchcode => C4::Context::mybranch,
74 message_transport_type => 'print',
75 lang => $patron->lang,
78 borrowers => $patron->borrowernumber
83 slip => $letter->{content},
84 plain => !$letter->{is_html},
88 output_html_with_http_headers $input, $cookie, $template->output;