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
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
28 use C4
::Dates qw
/format_date/;
36 my ($template, $loggedinuser, $cookie)
37 = get_template_and_user
({template_name
=> "members/boraccount.tmpl",
41 flagsrequired
=> {borrowers
=> 1},
45 my $borrowernumber=$input->param('borrowernumber');
47 my $data=GetMember
($borrowernumber,'borrowernumber');
49 if ( $data->{'category_type'} eq 'C') {
50 my ( $catcodes, $labels ) = GetborCatFromCatType
( 'A', 'WHERE category_type = ?' );
51 my $cnt = scalar(@
$catcodes);
52 $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
53 $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
57 my ($total,$accts,$numaccts)=GetMemberAccountRecords
($borrowernumber);
62 my @accountrows; # this is for the tmpl-loop
65 for (my $i=0;$i<$numaccts;$i++){
71 $accts->[$i]{'toggle'} = $toggle;
72 $accts->[$i]{'amount'}+=0.00;
73 if($accts->[$i]{'amount'} <= 0){
74 $accts->[$i]{'amountcredit'} = 1;
76 $accts->[$i]{'amountoutstanding'}+=0.00;
77 if($accts->[$i]{'amountoutstanding'} <= 0){
78 $accts->[$i]{'amountoutstandingcredit'} = 1;
80 my %row = ( 'date' => format_date
($accts->[$i]{'date'}),
81 'amountcredit' => $accts->[$i]{'amountcredit'},
82 'amountoutstandingcredit' => $accts->[$i]{'amountoutstandingcredit'},
83 'toggle' => $accts->[$i]{'toggle'},
84 'description' => $accts->[$i]{'description'},
85 'itemnumber' => $accts->[$i]{'itemnumber'},
86 'biblionumber' => $accts->[$i]{'biblionumber'},
87 'amount' => sprintf("%.2f",$accts->[$i]{'amount'}),
88 'amountoutstanding' => sprintf("%.2f",$accts->[$i]{'amountoutstanding'}) );
90 if ($accts->[$i]{'accounttype'} ne 'F' && $accts->[$i]{'accounttype'} ne 'FU'){
92 $row{'title'} = $accts->[$i]{'title'};
95 push(@accountrows, \
%row);
98 $template->param( adultborrower
=> 1 ) if ( $data->{'category_type'} eq 'A' );
100 my ($picture, $dberror) = GetPatronImage
($data->{'cardnumber'});
101 $template->param( picture
=> 1 ) if $picture;
105 firstname
=> $data->{'firstname'},
106 surname
=> $data->{'surname'},
107 borrowernumber
=> $borrowernumber,
108 cardnumber
=> $data->{'cardnumber'},
109 categorycode
=> $data->{'categorycode'},
110 category_type
=> $data->{'category_type'},
111 # category_description => $data->{'description'},
112 categoryname
=> $data->{'description'},
113 address
=> $data->{'address'},
114 address2
=> $data->{'address2'},
115 city
=> $data->{'city'},
116 zipcode
=> $data->{'zipcode'},
117 phone
=> $data->{'phone'},
118 email
=> $data->{'email'},
119 branchcode
=> $data->{'branchcode'},
120 branchname
=> GetBranchName
($data->{'branchcode'}),
121 total
=> sprintf("%.2f",$total),
122 totalcredit
=> $totalcredit,
123 is_child
=> ($data->{'category_type'} eq 'C'),
124 accounts
=> \
@accountrows );
126 output_html_with_http_headers
$input, $cookie, $template->output;