New feature - database update - Number of Returned Items to Show
[koha.git] / opac / opac-readingrecord.pl
blob7377c760fb27b9af29f44b53ebfdc77f8e7b1412
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;
21 use CGI;
23 use C4::Auth;
24 use C4::Koha;
25 use C4::Circulation;
26 use C4::Dates qw/format_date/;
27 use C4::Members;
29 use C4::Output;
31 my $query = new CGI;
32 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
34 template_name => "opac-readingrecord.tmpl",
35 query => $query,
36 type => "opac",
37 authnotrequired => 0,
38 flagsrequired => { borrow => 1 },
39 debug => 1,
43 # get borrower information ....
44 my ( $borr ) = GetMemberDetails( $borrowernumber );
46 $template->param($borr);
48 my $itemtypes = GetItemTypes();
50 # get the record
51 my $order = $query->param('order');
52 my $order2 = $order;
53 if ( $order2 eq '' ) {
54 $order2 = "date_due desc";
55 $template->param( orderbydate => 1 );
58 if ( $order2 eq 'title' ) {
59 $template->param( orderbytitle => 1 );
62 if ( $order2 eq 'author' ) {
63 $template->param( orderbyauthor => 1 );
66 my $limit = $query->param('limit');
67 if ( $limit eq 'full' ) {
68 $limit = 0;
70 else {
71 $limit = 50;
74 my ( $count, $issues ) = GetAllIssues( $borrowernumber, $order2, $limit );
76 my $borr = GetMemberDetails( $borrowernumber );
77 my @bordat;
78 $bordat[0] = $borr;
79 $template->param( BORROWER_INFO => \@bordat );
81 my @loop_reading;
83 for ( my $i = 0 ; $i < $count ; $i++ ) {
84 my %line;
85 if ( $i % 2 ) {
86 $line{'toggle'} = 1;
89 # XISBN Stuff
90 my $isbn = GetNormalizedISBN($issues->[$i]->{'isbn'});
91 $line{normalized_isbn} = $isbn;
92 $line{biblionumber} = $issues->[$i]->{'biblionumber'};
93 $line{title} = $issues->[$i]->{'title'};
94 $line{author} = $issues->[$i]->{'author'};
95 $line{itemcallnumber} = $issues->[$i]->{'itemcallnumber'};
96 $line{date_due} = format_date( $issues->[$i]->{'date_due'} );
97 $line{returndate} = format_date( $issues->[$i]->{'returndate'} );
98 $line{volumeddesc} = $issues->[$i]->{'volumeddesc'};
99 $line{counter} = $i + 1;
100 $line{'description'} = $itemtypes->{ $issues->[$i]->{'itemtype'} }->{'description'};
101 $line{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes->{ $issues->[$i]->{'itemtype'} }->{'imageurl'} );
102 push( @loop_reading, \%line );
105 if (C4::Context->preference('BakerTaylorEnabled')) {
106 $template->param(
107 JacketImages=>1,
108 BakerTaylorEnabled => 1,
109 BakerTaylorImageURL => &image_url(),
110 BakerTaylorLinkURL => &link_url(),
111 BakerTaylorBookstoreURL => C4::Context->preference('BakerTaylorBookstoreURL'),
115 BEGIN {
116 if (C4::Context->preference('BakerTaylorEnabled')) {
117 require C4::External::BakerTaylor;
118 import C4::External::BakerTaylor qw(&image_url &link_url);
122 for(qw(AmazonCoverImages GoogleJackets)) { # BakerTaylorEnabled handled above
123 C4::Context->preference($_) or next;
124 $template->param($_=>1);
125 $template->param(JacketImages=>1);
128 $template->param(
129 count => $count,
130 READING_RECORD => \@loop_reading,
131 limit => $limit,
132 showfulllink => 1,
133 readingrecview => 1
136 output_html_with_http_headers $query, $cookie, $template->output;