Fix FSF address in directory .
[koha.git] / members / boraccount.pl
blob6233e780841d7556dc6ff3310d4365b799e4fe4b
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 with
22 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
23 # Suite 330, Boston, MA 02111-1307 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,$numaccts)=GetMemberAccountRecords($borrowernumber);
67 my $totalcredit;
68 if($total <= 0){
69 $totalcredit = 1;
71 my @accountrows; # this is for the tmpl-loop
73 my $toggle;
74 for (my $i=0;$i<$numaccts;$i++){
75 if($i%2){
76 $toggle = 0;
77 } else {
78 $toggle = 1;
80 $accts->[$i]{'toggle'} = $toggle;
81 $accts->[$i]{'amount'}+=0.00;
82 if($accts->[$i]{'amount'} <= 0){
83 $accts->[$i]{'amountcredit'} = 1;
85 $accts->[$i]{'amountoutstanding'}+=0.00;
86 if($accts->[$i]{'amountoutstanding'} <= 0){
87 $accts->[$i]{'amountoutstandingcredit'} = 1;
89 my %row = ( 'date' => format_date($accts->[$i]{'date'}),
90 'amountcredit' => $accts->[$i]{'amountcredit'},
91 'amountoutstandingcredit' => $accts->[$i]{'amountoutstandingcredit'},
92 'toggle' => $accts->[$i]{'toggle'},
93 'description' => $accts->[$i]{'description'},
94 'itemnumber' => $accts->[$i]{'itemnumber'},
95 'biblionumber' => $accts->[$i]{'biblionumber'},
96 'amount' => sprintf("%.2f",$accts->[$i]{'amount'}),
97 'amountoutstanding' => sprintf("%.2f",$accts->[$i]{'amountoutstanding'}),
98 'accountno' => $accts->[$i]{'accountno'},
99 'payment' => ( $accts->[$i]{'accounttype'} eq 'Pay' ),
103 if ($accts->[$i]{'accounttype'} ne 'F' && $accts->[$i]{'accounttype'} ne 'FU'){
104 $row{'printtitle'}=1;
105 $row{'title'} = $accts->[$i]{'title'};
108 push(@accountrows, \%row);
111 $template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' );
113 my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'});
114 $template->param( picture => 1 ) if $picture;
116 $template->param(
117 finesview => 1,
118 firstname => $data->{'firstname'},
119 surname => $data->{'surname'},
120 borrowernumber => $borrowernumber,
121 cardnumber => $data->{'cardnumber'},
122 categorycode => $data->{'categorycode'},
123 category_type => $data->{'category_type'},
124 # category_description => $data->{'description'},
125 categoryname => $data->{'description'},
126 address => $data->{'address'},
127 address2 => $data->{'address2'},
128 city => $data->{'city'},
129 zipcode => $data->{'zipcode'},
130 country => $data->{'country'},
131 phone => $data->{'phone'},
132 email => $data->{'email'},
133 branchcode => $data->{'branchcode'},
134 branchname => GetBranchName($data->{'branchcode'}),
135 total => sprintf("%.2f",$total),
136 totalcredit => $totalcredit,
137 is_child => ($data->{'category_type'} eq 'C'),
138 accounts => \@accountrows );
140 output_html_with_http_headers $input, $cookie, $template->output;