Improve Z39.50 result checking and display a little:
[koha.git] / members / boraccount.pl
blob8d94adbfa6fc1d46f44ace07219ff3c5b6e1524d
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 C4::Auth;
27 use C4::Output;
28 use C4::Dates qw/format_date/;
29 use CGI;
30 use C4::Members;
31 use C4::Branch;
33 my $input=new CGI;
36 my ($template, $loggedinuser, $cookie)
37 = get_template_and_user({template_name => "members/boraccount.tmpl",
38 query => $input,
39 type => "intranet",
40 authnotrequired => 0,
41 flagsrequired => {borrowers => 1},
42 debug => 1,
43 });
45 my $borrowernumber=$input->param('borrowernumber');
46 #get borrower details
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;
56 #get account details
57 my ($total,$accts,$numaccts)=GetMemberAccountRecords($borrowernumber);
58 my $totalcredit;
59 if($total <= 0){
60 $totalcredit = 1;
62 my @accountrows; # this is for the tmpl-loop
64 my $toggle;
65 for (my $i=0;$i<$numaccts;$i++){
66 if($i%2){
67 $toggle = 0;
68 } else {
69 $toggle = 1;
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 'amount' => sprintf("%.2f",$accts->[$i]{'amount'}),
86 'amountoutstanding' => sprintf("%.2f",$accts->[$i]{'amountoutstanding'}) );
88 if ($accts->[$i]{'accounttype'} ne 'F' && $accts->[$i]{'accounttype'} ne 'FU'){
89 $row{'printtitle'}=1;
90 $row{'title'} = $accts->[$i]{'title'};
93 push(@accountrows, \%row);
96 $template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' );
98 my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'});
99 $template->param( picture => 1 ) if $picture;
101 $template->param(
102 finesview => 1,
103 firstname => $data->{'firstname'},
104 surname => $data->{'surname'},
105 borrowernumber => $borrowernumber,
106 cardnumber => $data->{'cardnumber'},
107 categorycode => $data->{'categorycode'},
108 category_type => $data->{'category_type'},
109 # category_description => $data->{'description'},
110 categoryname => $data->{'description'},
111 address => $data->{'address'},
112 address2 => $data->{'address2'},
113 city => $data->{'city'},
114 zipcode => $data->{'zipcode'},
115 phone => $data->{'phone'},
116 email => $data->{'email'},
117 branchcode => $data->{'branchcode'},
118 branchname => GetBranchName($data->{'branchcode'}),
119 total => sprintf("%.2f",$total),
120 totalcredit => $totalcredit,
121 is_child => ($data->{'category_type'} eq 'C'),
122 accounts => \@accountrows );
124 output_html_with_http_headers $input, $cookie, $template->output;