fixing syntax error in sysprefs.sql
[koha.git] / opac / opac-readingrecord.pl
1 #!/usr/bin/perl
2
3 # This file is part of Koha.
4 #
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
8 # version.
9 #
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License along with
15 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16 # Suite 330, Boston, MA  02111-1307 USA
17
18
19 use strict;
20 require Exporter;
21 use CGI;
22
23 use C4::Auth;
24 use C4::Koha;
25 use C4::Circulation;
26 use C4::Date;
27 use C4::Members;
28
29 use C4::Output;
30
31 my $query = new CGI;
32 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
33     {
34         template_name   => "opac-readingrecord.tmpl",
35         query           => $query,
36         type            => "opac",
37         authnotrequired => 0,
38         flagsrequired   => { borrow => 1 },
39         debug           => 1,
40     }
41 );
42
43 # get borrower information ....
44 my ( $borr, $flags ) = GetMemberDetails( $borrowernumber );
45
46 $template->param($borr);
47
48 # get the record
49 my $order  = $query->param('order');
50 my $order2 = $order;
51 if ( $order2 eq '' ) {
52     $order2 = "date_due desc";
53     $template->param( orderbydate => 1 );
54 }
55
56 if ( $order2 eq 'title' ) {
57     $template->param( orderbytitle => 1 );
58 }
59
60 if ( $order2 eq 'author' ) {
61     $template->param( orderbyauthor => 1 );
62 }
63
64 my $limit = $query->param('limit');
65 if ( $limit eq 'full' ) {
66     $limit = 0;
67 }
68 else {
69     $limit = 50;
70 }
71 my ( $count, $issues ) = GetAllIssues( $borrowernumber, $order2, $limit );
72
73 # add the row parity
74 #my $num = 0;
75 #foreach my $row (@$issues) {
76 #    $row->{'even'} = 1 if $num % 2 == 0;
77 #    $row->{'odd'} = 1 if $num % 2 == 1;
78 #    $num++;
79 #}
80
81 my @loop_reading;
82
83 for ( my $i = 0 ; $i < $count ; $i++ ) {
84     my %line;
85     if ( $i % 2 ) {
86         $line{'toggle'} = 1;
87     }
88     $line{biblionumber}   = $issues->[$i]->{'biblionumber'};
89     $line{title}          = $issues->[$i]->{'title'};
90     $line{author}         = $issues->[$i]->{'author'};
91     $line{classification} = $issues->[$i]->{'classification'};
92     $line{date_due}       = format_date( $issues->[$i]->{'date_due'} );
93     $line{returndate}     = format_date( $issues->[$i]->{'returndate'} );
94     $line{volumeddesc}    = $issues->[$i]->{'volumeddesc'};
95     $line{counter}        = $i + 1;
96     push( @loop_reading, \%line );
97 }
98
99 $template->param(
100     count          => $count,
101     READING_RECORD => \@loop_reading,
102     limit          => $limit,
103     showfulllink   => ( $count > 50 ),
104 );
105
106 output_html_with_http_headers $query, $cookie, $template->output;
107