caa793e0e6b58df168d555c04ce4c6cfb5b9dcec
[koha_fer] / catalogue / imageviewer.pl
1 #!/usr/bin/perl
2
3 # Copyright 2011 C & P Bibliography Services
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
11 #
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20 use strict;
21 use warnings;
22
23 use CGI;
24 use C4::Auth;
25 use C4::Biblio;
26 use C4::Items;
27 use C4::Output;
28 use C4::Images;
29 use C4::Search;
30
31 my $query = new CGI;
32 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
33     {
34         template_name   => "catalogue/imageviewer.tmpl",
35         query           => $query,
36         type            => "intranet",
37         authnotrequired => 0,
38         flagsrequired   => { catalogue => 1 },
39     }
40 );
41
42 my $biblionumber = $query->param('biblionumber') || $query->param('bib');
43 my $imagenumber = $query ->param('imagenumber');
44 my ($count, $biblio) = GetBiblio($biblionumber);
45 my $itemcount = GetItemsCount($biblionumber);
46
47 my @items = GetItemsInfo( $biblionumber );
48
49 my $norequests = 1;
50 foreach my $item (@items) {
51     # can place holds defaults to yes
52     $norequests = 0 unless ( ( $item->{'notforloan_per_itemtype'} > 0 ) || ( $item->{'itemnotforloan'} > 0 ) );
53 }
54
55 if($query->cookie("holdfor")){
56     my $holdfor_patron = GetMember('borrowernumber' => $query->cookie("holdfor"));
57     $template->param(
58         holdfor => $query->cookie("holdfor"),
59         holdfor_surname => $holdfor_patron->{'surname'},
60         holdfor_firstname => $holdfor_patron->{'firstname'},
61         holdfor_cardnumber => $holdfor_patron->{'cardnumber'},
62     );
63 }
64
65 if (C4::Context->preference("LocalCoverImages")) {
66     my @images = ListImagesForBiblio($biblionumber);
67     $template->{VARS}->{'LocalCoverImages'} = 1;
68     $template->{VARS}->{'images'} = \@images;
69     $template->{VARS}->{'imagenumber'} = $imagenumber || $images[0] || '';
70 }
71     $template->{VARS}->{'count'} = $itemcount;
72     $template->{VARS}->{'biblionumber'} = $biblionumber;
73     $template->{VARS}->{'norequests'} = $norequests;
74     $template->param( C4::Search::enabled_staff_search_views );
75     $template->{VARS}->{'biblio'} = $biblio;
76
77 output_html_with_http_headers $query, $cookie, $template->output;