Lines 1-11
Link Here
|
1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
2 |
|
2 |
|
3 |
|
3 |
# Copyright Koustubha Kale 2010 |
4 |
#written 3rd May 2010 by kmkale@anantcorp.com adapted from boraccount.pl by chris@katipo.oc.nz |
4 |
# Copyright PTFS Europe 2020 |
5 |
#script to print fee receipts |
|
|
6 |
|
7 |
|
8 |
# Copyright Koustubha Kale |
9 |
# |
5 |
# |
10 |
# This file is part of Koha. |
6 |
# This file is part of Koha. |
11 |
# |
7 |
# |
Lines 27-99
use Modern::Perl;
Link Here
|
27 |
use C4::Auth; |
23 |
use C4::Auth; |
28 |
use C4::Output; |
24 |
use C4::Output; |
29 |
use CGI qw ( -utf8 ); |
25 |
use CGI qw ( -utf8 ); |
30 |
use C4::Members; |
|
|
31 |
use C4::Accounts; |
32 |
use C4::Letters; |
26 |
use C4::Letters; |
33 |
use Koha::Account::Lines; |
27 |
use Koha::Account::Lines; |
34 |
use Koha::DateUtils; |
|
|
35 |
use Koha::Patrons; |
36 |
use Koha::Patron::Categories; |
37 |
|
38 |
my $input=CGI->new; |
39 |
|
40 |
|
41 |
my ($template, $loggedinuser, $cookie) |
42 |
= get_template_and_user({template_name => "members/printfeercpt.tt", |
43 |
query => $input, |
44 |
type => "intranet", |
45 |
flagsrequired => {borrowers => 'edit_borrowers', updatecharges => 'remaining_permissions'}, |
46 |
debug => 1, |
47 |
}); |
48 |
|
49 |
my $borrowernumber=$input->param('borrowernumber'); |
50 |
my $action = $input->param('action') || ''; |
51 |
my $accountlines_id = $input->param('accountlines_id'); |
52 |
my $change_given = $input->param('change_given'); |
53 |
|
28 |
|
54 |
my $logged_in_user = Koha::Patrons->find( $loggedinuser ); |
29 |
my $input = CGI->new; |
55 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
30 |
|
56 |
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); |
31 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
57 |
|
32 |
{ |
58 |
#get account details |
33 |
template_name => "members/printfeercpt.tt", |
59 |
my $total = $patron->account->balance; |
34 |
query => $input, |
60 |
|
35 |
type => "intranet", |
61 |
# FIXME This whole stuff is ugly and should be rewritten |
36 |
flagsrequired => { |
62 |
# FIXME We should pass the $accts iterator to the template and do this formatting part there |
37 |
borrowers => 'edit_borrowers', |
63 |
my $accountline_object = Koha::Account::Lines->find($accountlines_id); |
38 |
updatecharges => 'remaining_permissions' |
64 |
my $accountline = $accountline_object->unblessed; |
39 |
} |
65 |
my $totalcredit; |
40 |
} |
66 |
if($total <= 0){ |
41 |
); |
67 |
$totalcredit = 1; |
|
|
68 |
} |
69 |
|
70 |
$accountline->{'amount'} += 0.00; |
71 |
if ( $accountline->{'amount'} <= 0 ) { |
72 |
$accountline->{'amountcredit'} = 1; |
73 |
$accountline->{'amount'} *= -1.00; |
74 |
} |
75 |
$accountline->{'amountoutstanding'} += 0.00; |
76 |
if ( $accountline->{'amountoutstanding'} <= 0 ) { |
77 |
$accountline->{'amountoutstandingcredit'} = 1; |
78 |
} |
79 |
|
42 |
|
80 |
my $letter = C4::Letters::getletter( 'circulation', 'ACCOUNT_CREDIT', C4::Context::mybranch, 'print', $patron->lang ); |
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 |
); |
81 |
|
57 |
|
82 |
my @account_offsets = Koha::Account::Offsets->search( { credit_id => $accountline_object->id } ); |
58 |
my $letter = C4::Letters::getletter( 'circulation', 'ACCOUNT_CREDIT', |
|
|
59 |
C4::Context::mybranch, 'print', $patron->lang ); |
83 |
|
60 |
|
84 |
$template->param( |
61 |
$template->param( |
85 |
letter => $letter, |
62 |
letter => $letter, |
86 |
patron => $patron, |
63 |
credit => $credit, |
87 |
library => C4::Context::mybranch, |
|
|
88 |
offsets => \@account_offsets, |
89 |
credit => $accountline_object, |
90 |
|
91 |
finesview => 1, |
92 |
total => $total, |
93 |
totalcredit => $totalcredit, |
94 |
accounts => [$accountline], # FIXME There is always only 1 row! |
95 |
|
64 |
|
96 |
change_given => $change_given, |
65 |
tendered => scalar $input->param('tendered'), |
|
|
66 |
change => scalar $input->param('change') |
97 |
); |
67 |
); |
98 |
|
68 |
|
99 |
output_html_with_http_headers $input, $cookie, $template->output; |
69 |
output_html_with_http_headers $input, $cookie, $template->output; |