Bug 8432 follow-up, fixing error in T::T variable scope
[koha.git] / members / boraccount.pl
blob44db953da51210760d6757b88817736baa249b07
1 #!/usr/bin/perl
4 #writen 11/1/2000 by chris@katipo.oc.nz
5 #script to display borrowers account details
8 # Copyright 2000-2002 Katipo Communications
10 # This file is part of Koha.
12 # Koha is free software; you can redistribute it and/or modify it under the
13 # terms of the GNU General Public License as published by the Free Software
14 # Foundation; either version 2 of the License, or (at your option) any later
15 # version.
17 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
18 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
19 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License along
22 # with Koha; if not, write to the Free Software Foundation, Inc.,
23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 use strict;
26 use warnings;
28 use C4::Auth;
29 use C4::Output;
30 use C4::Dates qw/format_date/;
31 use CGI;
32 use C4::Members;
33 use C4::Branch;
34 use C4::Accounts;
35 use C4::Members::Attributes qw(GetBorrowerAttributes);
37 my $input=new CGI;
40 my ($template, $loggedinuser, $cookie)
41 = get_template_and_user({template_name => "members/boraccount.tmpl",
42 query => $input,
43 type => "intranet",
44 authnotrequired => 0,
45 flagsrequired => {borrowers => 1, updatecharges => 1},
46 debug => 1,
47 });
49 my $borrowernumber=$input->param('borrowernumber');
50 my $action = $input->param('action') || '';
52 #get borrower details
53 my $data=GetMember('borrowernumber' => $borrowernumber);
55 if ( $action eq 'reverse' ) {
56 ReversePayment( $borrowernumber, $input->param('accountno') );
59 if ( $data->{'category_type'} eq 'C') {
60 my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
61 my $cnt = scalar(@$catcodes);
62 $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
63 $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
66 #get account details
67 my ($total,$accts,undef)=GetMemberAccountRecords($borrowernumber);
68 my $totalcredit;
69 if($total <= 0){
70 $totalcredit = 1;
73 my $reverse_col = 0; # Flag whether we need to show the reverse column
74 foreach my $accountline ( @{$accts}) {
75 $accountline->{amount} += 0.00;
76 if ($accountline->{amount} <= 0 ) {
77 $accountline->{amountcredit} = 1;
79 $accountline->{amountoutstanding} += 0.00;
80 if ( $accountline->{amountoutstanding} <= 0 ) {
81 $accountline->{amountoutstandingcredit} = 1;
84 $accountline->{date} = format_date($accountline->{date});
85 $accountline->{amount} = sprintf '%.2f', $accountline->{amount};
86 $accountline->{amountoutstanding} = sprintf '%.2f', $accountline->{amountoutstanding};
87 if ($accountline->{accounttype} eq 'Pay') {
88 $accountline->{payment} = 1;
89 $reverse_col = 1;
93 $template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' );
95 my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'});
96 $template->param( picture => 1 ) if $picture;
98 if (C4::Context->preference('ExtendedPatronAttributes')) {
99 my $attributes = GetBorrowerAttributes($borrowernumber);
100 $template->param(
101 ExtendedPatronAttributes => 1,
102 extendedattributes => $attributes
106 $template->param(
107 finesview => 1,
108 firstname => $data->{'firstname'},
109 surname => $data->{'surname'},
110 othernames => $data->{'othernames'},
111 borrowernumber => $borrowernumber,
112 cardnumber => $data->{'cardnumber'},
113 categorycode => $data->{'categorycode'},
114 category_type => $data->{'category_type'},
115 categoryname => $data->{'description'},
116 address => $data->{'address'},
117 address2 => $data->{'address2'},
118 city => $data->{'city'},
119 state => $data->{'state'},
120 zipcode => $data->{'zipcode'},
121 country => $data->{'country'},
122 phone => $data->{'phone'},
123 email => $data->{'email'},
124 branchcode => $data->{'branchcode'},
125 branchname => GetBranchName($data->{'branchcode'}),
126 total => sprintf("%.2f",$total),
127 totalcredit => $totalcredit,
128 is_child => ($data->{'category_type'} eq 'C'),
129 reverse_col => $reverse_col,
130 accounts => $accts,
131 activeBorrowerRelationship => (C4::Context->preference('borrowerRelationship') ne ''),
134 output_html_with_http_headers $input, $cookie, $template->output;