Moved C4/Charset.pm to C4/Interface/CGI/Output.pm
[koha.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 HTML::Template;
13
14 my $query = new CGI;
15 my ($template, $borrowernumber, $cookie)
16     = get_template_and_user({template_name => "opac-account.tmpl",
17                              query => $query,
18                              type => "opac",
19                              authnotrequired => 0,
20                              flagsrequired => {borrow => 1},
21                              debug => 1,
22                              });
23
24 # get borrower information ....
25 my ($borr, $flags) = getpatroninformation(undef, $borrowernumber);
26
27 my @bordat;
28 $bordat[0] = $borr;
29
30 $template->param( BORROWER_INFO => \@bordat );
31
32
33 #get account details
34 my ($numaccts,$accts,$total) = getboracctrecord(undef,$borr);
35
36 for (my $i=0;$i<$numaccts;$i++){
37     $accts->[$i]{'amount'}+=0.00;
38     $accts->[$i]{'amountoutstanding'}+=0.00;
39     if ($accts->[$i]{'accounttype'} ne 'F' && $accts->[$i]{'accounttype'} ne 'FU'){
40         $accts->[$i]{'print_title'};
41     }
42 }
43
44 # add the row parity
45 my $num = 0;
46 foreach my $row (@$accts) {
47     $row->{'even'} = 1 if $num % 2 == 0;
48     $row->{'odd'} = 1 if $num % 2 == 1;
49     $num++;
50 }
51
52
53 $template->param( ACCOUNT_LINES => $accts );
54
55 $template->param( total => $total );
56
57 #$template->param(loggeninuser => $loggedinuser);
58 output_html_with_http_headers $query, $cookie, $template->output;
59