bug_2830: Remove reserve when checking out if the borrower is not the first one in...
[koha.git] / opac / opac-readingrecord.pl
blob00a91db39bca1d02f65a5c38ee3a69467b91cedd
1 #!/usr/bin/perl
3 # This file is part of Koha.
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.
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.
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
19 use strict;
20 use warnings;
22 use CGI;
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;
31 use C4::Output;
33 my $query = new CGI;
34 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
36 template_name => "opac-readingrecord.tmpl",
37 query => $query,
38 type => "opac",
39 authnotrequired => 0,
40 flagsrequired => { borrow => 1 },
41 debug => 1,
45 # get borrower information ....
46 my ( $borr ) = GetMemberDetails( $borrowernumber );
48 $template->param(%{$borr});
50 my $itemtypes = GetItemTypes();
52 # get the record
53 my $order = $query->param('order') || '';
54 if ( $order eq '' ) {
55 $order = "date_due desc";
56 $template->param( orderbydate => 1 );
59 if ( $order eq 'title' ) {
60 $template->param( orderbytitle => 1 );
63 if ( $order eq 'author' ) {
64 $template->param( orderbyauthor => 1 );
67 my $limit = $query->param('limit') || 50;
68 if ( $limit eq 'full' ) {
69 $limit = 0;
71 else {
72 $limit = 50;
75 my ( $issues ) = GetAllIssues( $borrowernumber, $order, $limit );
78 my @loop_reading;
80 foreach my $issue (@{$issues} ) {
81 my %line;
83 my $record = GetMarcBiblio($issue->{'biblionumber'});
85 # XISBN Stuff
86 my $isbn = GetNormalizedISBN($issue->{'isbn'});
87 $line{normalized_isbn} = $isbn;
88 $line{biblionumber} = $issue->{'biblionumber'};
89 $line{title} = $issue->{'title'};
90 $line{author} = $issue->{'author'};
91 $line{itemcallnumber} = $issue->{'itemcallnumber'};
92 $line{date_due} = format_date( $issue->{'date_due'} );
93 $line{returndate} = format_date( $issue->{'returndate'} );
94 $line{volumeddesc} = $issue->{'volumeddesc'};
95 $issue->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $issue->{'itype'} : $issue->{'itemtype'};
96 if($issue->{'itemtype'}) {
97 $line{'description'} = $itemtypes->{ $issue->{'itemtype'} }->{'description'};
98 $line{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes->{ $issue->{'itemtype'} }->{'imageurl'} );
100 push( @loop_reading, \%line );
101 $line{subtitle} = GetRecordValue('subtitle', $record, GetFrameworkCode($issue->{'biblionumber'}));
104 if (C4::Context->preference('BakerTaylorEnabled')) {
105 $template->param(
106 JacketImages=>1,
107 BakerTaylorEnabled => 1,
108 BakerTaylorImageURL => &image_url(),
109 BakerTaylorLinkURL => &link_url(),
110 BakerTaylorBookstoreURL => C4::Context->preference('BakerTaylorBookstoreURL'),
114 BEGIN {
115 if (C4::Context->preference('BakerTaylorEnabled')) {
116 require C4::External::BakerTaylor;
117 import C4::External::BakerTaylor qw(&image_url &link_url);
121 for(qw(AmazonCoverImages GoogleJackets)) { # BakerTaylorEnabled handled above
122 C4::Context->preference($_) or next;
123 $template->param($_=>1);
124 $template->param(JacketImages=>1);
127 $template->param(
128 READING_RECORD => \@loop_reading,
129 limit => $limit,
130 showfulllink => 1,
131 readingrecview => 1,
132 count => scalar @loop_reading,
135 output_html_with_http_headers $query, $cookie, $template->output;