3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
23 use C4::Auth qw( get_template_and_user );
25 use C4::External::BakerTaylor qw( image_url link_url );
28 use C4::Output qw( output_html_with_http_headers );
35 # if opacreadinghistory is disabled, leave immediately
36 if ( ! C4::Context->preference('opacreadinghistory') ) {
37 print $query->redirect("/cgi-bin/koha/errors/404.pl");
41 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
43 template_name => "opac-readingrecord.tt",
49 my $patron = Koha::Patrons->find( $borrowernumber );
50 my @itemtypes = Koha::ItemTypes->search_with_localization->as_list;
51 my %item_types = map {
54 $template->param(item_types => \%item_types);
57 my $order = $query->param('order') || '';
58 if ( $order eq 'title' ) {
59 $template->param( orderbytitle => 1 );
61 elsif ( $order eq 'author' ) {
62 $template->param( orderbyauthor => 1 );
65 $order = "date_due desc";
66 $template->param( orderbydate => 1 );
70 my $limit = $query->param('limit');
72 $limit = ( $limit eq 'full' ) ? 0 : 50;
79 prefetch => { item => { biblio => 'biblioitems' } },
80 ( $limit ? ( limit => $limit ) : () ),
84 $limit -= scalar(@$checkouts) if $limit;
86 $patron->old_checkouts(
90 prefetch => { item => { biblio => 'biblioitems' } },
91 ( $limit ? ( limit => $limit ) : () ),
96 if (C4::Context->preference('BakerTaylorEnabled')) {
99 BakerTaylorEnabled => 1,
100 BakerTaylorImageURL => &image_url(),
101 BakerTaylorLinkURL => &link_url(),
102 BakerTaylorBookstoreURL => C4::Context->preference('BakerTaylorBookstoreURL'),
106 for(qw(AmazonCoverImages GoogleJackets)) { # BakerTaylorEnabled handled above
107 C4::Context->preference($_) or next;
108 $template->param($_=>1);
109 $template->param(JacketImages=>1);
112 my $saving_display = C4::Context->preference('OPACShowSavings');
113 if ( $saving_display =~ /checkouthistory/ ) {
114 $template->param( savings => $patron->get_savings );
118 checkouts => $checkouts,
119 old_checkouts => $old_checkouts,
124 output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };