Bug 5480 Some usual UNIMARC cataloguing plugins doesn't work anymore
[koha.git] / members / boraccount.pl
blob5509f3db77d87ef723e0f52941656158bd756a9a
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;
36 my $input=new CGI;
39 my ($template, $loggedinuser, $cookie)
40 = get_template_and_user({template_name => "members/boraccount.tmpl",
41 query => $input,
42 type => "intranet",
43 authnotrequired => 0,
44 flagsrequired => {borrowers => 1, updatecharges => 1},
45 debug => 1,
46 });
48 my $borrowernumber=$input->param('borrowernumber');
49 my $action = $input->param('action') || '';
51 #get borrower details
52 my $data=GetMember('borrowernumber' => $borrowernumber);
54 if ( $action eq 'reverse' ) {
55 ReversePayment( $borrowernumber, $input->param('accountno') );
58 if ( $data->{'category_type'} eq 'C') {
59 my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
60 my $cnt = scalar(@$catcodes);
61 $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
62 $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
65 #get account details
66 my ($total,$accts,undef)=GetMemberAccountRecords($borrowernumber);
67 my $totalcredit;
68 if($total <= 0){
69 $totalcredit = 1;
72 my $reverse_col = 0; # Flag whether we need to show the reverse column
73 foreach my $accountline ( @{$accts}) {
74 $accountline->{amount} += 0.00;
75 if ($accountline->{amount} <= 0 ) {
76 $accountline->{amountcredit} = 1;
78 $accountline->{amountoutstanding} += 0.00;
79 if ( $accountline->{amountoutstanding} <= 0 ) {
80 $accountline->{amountoutstandingcredit} = 1;
83 $accountline->{date} = format_date($accountline->{date});
84 $accountline->{amount} = sprintf '%.2f', $accountline->{amount};
85 $accountline->{amountoutstanding} = sprintf '%.2f', $accountline->{amountoutstanding};
86 if ($accountline->{accounttype} eq 'Pay') {
87 $accountline->{payment} = 1;
88 $reverse_col = 1;
90 if ($accountline->{accounttype} ne 'F' && $accountline->{accounttype} ne 'FU'){
91 $accountline->{printtitle} = 1;
95 $template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' );
97 my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'});
98 $template->param( picture => 1 ) if $picture;
100 $template->param(
101 finesview => 1,
102 firstname => $data->{'firstname'},
103 surname => $data->{'surname'},
104 borrowernumber => $borrowernumber,
105 cardnumber => $data->{'cardnumber'},
106 categorycode => $data->{'categorycode'},
107 category_type => $data->{'category_type'},
108 categoryname => $data->{'description'},
109 address => $data->{'address'},
110 address2 => $data->{'address2'},
111 city => $data->{'city'},
112 zipcode => $data->{'zipcode'},
113 country => $data->{'country'},
114 phone => $data->{'phone'},
115 email => $data->{'email'},
116 branchcode => $data->{'branchcode'},
117 branchname => GetBranchName($data->{'branchcode'}),
118 total => sprintf("%.2f",$total),
119 totalcredit => $totalcredit,
120 is_child => ($data->{'category_type'} eq 'C'),
121 reverse_col => $reverse_col,
122 accounts => $accts );
124 output_html_with_http_headers $input, $cookie, $template->output;