Add OpacBrowser preference to opac.pref
[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 use warnings;
21
22 use CGI;
23
24 use C4::Auth;
25 use C4::Koha;
26 use C4::Biblio;
27 use C4::Circulation;
28 use C4::Dates qw/format_date/;
29 use C4::Members;
30
31 use C4::Output;
32
33 my $query = new CGI;
34 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
35     {
36         template_name   => "opac-readingrecord.tmpl",
37         query           => $query,
38         type            => "opac",
39         authnotrequired => 0,
40         flagsrequired   => { borrow => 1 },
41         debug           => 1,
42     }
43 );
44
45 # get borrower information ....
46 my ( $borr ) = GetMemberDetails( $borrowernumber );
47
48 $template->param($borr);
49
50 my $itemtypes = GetItemTypes();
51
52 # get the record
53 my $order  = $query->param('order') || '';
54 if ( $order eq '' ) {
55     $order = "date_due desc";
56     $template->param( orderbydate => 1 );
57 }
58
59 if ( $order eq 'title' ) {
60     $template->param( orderbytitle => 1 );
61 }
62
63 if ( $order eq 'author' ) {
64     $template->param( orderbyauthor => 1 );
65 }
66
67 my $limit = $query->param('limit') || 50;
68 if ( $limit eq 'full' ) {
69     $limit = 0;
70 }
71 else {
72     $limit = 50;
73 }
74
75 my ( $count, $issues ) = GetAllIssues( $borrowernumber, $order, $limit );
76
77 my @bordat;
78 $bordat[0] = $borr;
79 $template->param( BORROWER_INFO => \@bordat );
80
81 my @loop_reading;
82
83 for ( my $i = 0 ; $i < $count ; $i++ ) {
84     my %line;
85         
86     my $record = GetMarcBiblio($issues->[$i]->{'biblionumber'});
87
88         # XISBN Stuff
89         my $isbn = GetNormalizedISBN($issues->[$i]->{'isbn'});
90         $line{normalized_isbn} = $isbn;
91     $line{biblionumber}   = $issues->[$i]->{'biblionumber'};
92     $line{title}          = $issues->[$i]->{'title'};
93     $line{author}         = $issues->[$i]->{'author'};
94     $line{itemcallnumber} = $issues->[$i]->{'itemcallnumber'};
95     $line{date_due}       = format_date( $issues->[$i]->{'date_due'} );
96     $line{returndate}     = format_date( $issues->[$i]->{'returndate'} );
97     $line{volumeddesc}    = $issues->[$i]->{'volumeddesc'};
98     $line{counter}        = $i + 1;
99     if($issues->[$i]->{'itemtype'}) {
100         $line{'itypedescription'} = $itemtypes->{ $issues->[$i]->{'itemtype'} }->{'description'};
101         $line{imageurl}       = getitemtypeimagelocation( 'opac', $itemtypes->{ $issues->[$i]->{'itemtype'}  }->{'imageurl'} );
102     }
103     push( @loop_reading, \%line );
104     $line{subtitle} = GetRecordValue('subtitle', $record, GetFrameworkCode($issues->[$i]->{'biblionumber'}));
105 }
106
107 if (C4::Context->preference('BakerTaylorEnabled')) {
108         $template->param(
109                 JacketImages=>1,
110                 BakerTaylorEnabled  => 1,
111                 BakerTaylorImageURL => &image_url(),
112                 BakerTaylorLinkURL  => &link_url(),
113                 BakerTaylorBookstoreURL => C4::Context->preference('BakerTaylorBookstoreURL'),
114         );
115 }
116
117 BEGIN {
118         if (C4::Context->preference('BakerTaylorEnabled')) {
119                 require C4::External::BakerTaylor;
120                 import C4::External::BakerTaylor qw(&image_url &link_url);
121         }
122 }
123
124 for(qw(AmazonCoverImages GoogleJackets)) {      # BakerTaylorEnabled handled above
125         C4::Context->preference($_) or next;
126         $template->param($_=>1);
127         $template->param(JacketImages=>1);
128 }
129
130 $template->param(
131     count          => $count,
132     READING_RECORD => \@loop_reading,
133     limit          => $limit,
134     showfulllink   => 1,
135         readingrecview => 1
136 );
137
138 output_html_with_http_headers $query, $cookie, $template->output;