Bug 26734: Ratify account slip printing
[koha.git] / members / printfeercpt.pl
1 #!/usr/bin/perl
2
3 # Copyright Koustubha Kale 2010
4 # Copyright PTFS Europe 2020
5 #
6 # This file is part of Koha.
7 #
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.
12 #
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.
17 #
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>.
20
21 use Modern::Perl;
22
23 use C4::Auth;
24 use C4::Output;
25 use CGI qw ( -utf8 );
26 use C4::Letters;
27 use Koha::Account::Lines;
28
29 my $input = CGI->new;
30
31 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
32     {
33         template_name   => "members/printfeercpt.tt",
34         query           => $input,
35         type            => "intranet",
36         flagsrequired   => {
37             borrowers     => 'edit_borrowers',
38             updatecharges => 'remaining_permissions'
39         }
40     }
41 );
42
43 my $credit_id = $input->param('accountlines_id');
44 my $credit    = Koha::Account::Lines->find($credit_id);
45 my $patron    = $credit->patron;
46
47 my $logged_in_user = Koha::Patrons->find($loggedinuser) or die "Not logged in";
48 output_and_exit_if_error(
49     $input, $cookie,
50     $template,
51     {
52         module         => 'members',
53         logged_in_user => $logged_in_user,
54         current_patron => $patron
55     }
56 );
57
58 my $letter = C4::Letters::getletter( 'circulation', 'ACCOUNT_CREDIT',
59     C4::Context::mybranch, 'print', $patron->lang );
60
61 $template->param(
62     letter => $letter,
63     credit => $credit,
64
65     tendered => scalar $input->param('tendered'),
66     change   => scalar $input->param('change')
67 );
68
69 output_html_with_http_headers $input, $cookie, $template->output;