modify input parameter for GetOrder function.
[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::Members;
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]{'date'} = format_date($accts->[$i]{'date'});
40     $accts->[$i]{'amount'} = sprintf("%.2f", $accts->[$i]{'amount'});
41         if($accts->[$i]{'amount'} >= 0){
42                 $accts->[$i]{'amountcredit'} = 1;
43         }
44     $accts->[$i]{'amountoutstanding'} =sprintf("%.2f", $accts->[$i]{'amountoutstanding'});
45         if($accts->[$i]{'amountoutstanding'} >= 0){
46                 $accts->[$i]{'amountoutstandingcredit'} = 1;
47         }
48     if ($accts->[$i]{'accounttype'} ne 'F' && $accts->[$i]{'accounttype'} ne 'FU'){
49         $accts->[$i]{'print_title'};
50     }
51 }
52
53 # add the row parity
54 my $num = 0;
55 foreach my $row (@$accts) {
56     $row->{'even'} = 1 if $num % 2 == 0;
57     $row->{'odd'} = 1 if $num % 2 == 1;
58     $num++;
59 }
60
61
62 $template->param( ACCOUNT_LINES => $accts,
63 );
64
65 $template->param( total => sprintf("%.2f",$total) );
66
67 #$template->param(loggeninuser => $loggedinuser);
68 output_html_with_http_headers $query, $cookie, $template->output;
69