Code to allow the associated borrowers to work
[koha.git] / opac / opac-readingrecord.pl
1 #!/usr/bin/perl
2 use strict;
3 require Exporter;
4 use CGI;
5
6 use C4::Auth;
7 use C4::Koha;
8 use C4::Circulation::Circ2;
9 use C4::Date;
10 use C4::Members;
11 use HTML::Template;
12 use C4::Interface::CGI::Output;
13
14 my $query = new CGI;
15 my ($template, $borrowernumber, $cookie) 
16     = get_template_and_user({template_name => "opac-readingrecord.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
28 $template->param($borr);
29
30 # get the record
31 my $order=$query->param('order');
32 my $order2=$order;
33 if ($order2 eq ''){
34   $order2="date_due desc";
35   $template->param(orderbydate => 1);
36 }
37
38 if($order2 eq 'title'){
39         $template->param(orderbytitle => 1);
40         }
41
42 if($order2 eq 'author'){
43         $template->param(orderbyauthor => 1);
44 }
45
46 my $limit=$query->param('limit');
47 if ($limit eq 'full'){
48   $limit=0;
49 } else {
50   $limit=50;
51 }
52 my ($count,$issues)=allissues($borrowernumber,$order2,$limit);
53
54 # add the row parity
55 #my $num = 0;
56 #foreach my $row (@$issues) {
57 #    $row->{'even'} = 1 if $num % 2 == 0;
58 #    $row->{'odd'} = 1 if $num % 2 == 1;
59 #    $num++;
60 #}
61
62 my @loop_reading;
63
64 for (my $i=0;$i<$count;$i++){
65         my %line;
66         if($i%2){
67                 $line{'toggle'} = 1;
68         }
69         $line{biblionumber}=$issues->[$i]->{'biblionumber'};
70         $line{title}=$issues->[$i]->{'title'};
71         $line{author}=$issues->[$i]->{'author'};
72         $line{classification} = $issues->[$i]->{'classification'};
73         $line{date_due}=format_date($issues->[$i]->{'date_due'});
74         $line{returndate}=format_date($issues->[$i]->{'returndate'});
75         $line{volumeddesc}=$issues->[$i]->{'volumeddesc'};
76         $line{counter} = $i + 1;
77         push(@loop_reading,\%line);
78 }
79
80 $template->param(count => $count,
81                                 READING_RECORD => \@loop_reading,
82                                 limit => $limit,
83                                 showfulllink => ($count > 50),          
84 );
85
86
87 output_html_with_http_headers $query, $cookie, $template->output;
88