Changed the scripts to use format_date
[koha-equinox.git] / opac / opac-account.pl
1 #!/usr/bin/perl
2
3 # wrriten 15/10/2002 by finlay@katipo.oc.nz
4 # script to display borrowers account details in the opac
5
6 use strict;
7 use C4::Output;
8 use CGI;
9 use C4::Search;
10 use C4::Circulation::Circ2;
11 use C4::Auth;
12 use C4::Interface::CGI::Output;
13 use HTML::Template;
14 use C4::Date;
15
16 my $query = new CGI;
17 my ($template, $borrowernumber, $cookie)
18     = get_template_and_user({template_name => "opac-account.tmpl",
19                              query => $query,
20                              type => "opac",
21                              authnotrequired => 0,
22                              flagsrequired => {borrow => 1},
23                              debug => 1,
24                              });
25
26 # get borrower information ....
27 my ($borr, $flags) = getpatroninformation(undef, $borrowernumber);
28
29 my @bordat;
30 $bordat[0] = $borr;
31
32 $template->param( BORROWER_INFO => \@bordat );
33
34
35 #get account details
36 my ($numaccts,$accts,$total) = getboracctrecord(undef,$borr);
37
38 for (my $i=0;$i<$numaccts;$i++){
39     $accts->[$i]{'amount'}+=0.00;
40     $accts->[$i]{'amountoutstanding'}+=0.00;
41     if ($accts->[$i]{'accounttype'} ne 'F' && $accts->[$i]{'accounttype'} ne 'FU'){
42         $accts->[$i]{'print_title'};
43     }
44 }
45
46 # add the row parity
47 my $num = 0;
48 foreach my $row (@$accts) {
49     $row->{'even'} = 1 if $num % 2 == 0;
50     $row->{'odd'} = 1 if $num % 2 == 1;
51     $num++;
52 }
53
54
55 $template->param( ACCOUNT_LINES => $accts );
56
57 $template->param( total => $total );
58
59 #$template->param(loggeninuser => $loggedinuser);
60 output_html_with_http_headers $query, $cookie, $template->output;
61