Fix release notes typo
[koha.git] / opac / opac-detail.pl
1 #!/usr/bin/perl
2
3 # Copyright 2000-2002 Katipo Communications
4 # Copyright 2010 BibLibre
5 # Copyright 2011 KohaAloha, NZ
6 #
7 # This file is part of Koha.
8 #
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
12 # version.
13 #
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License along
19 # with Koha; if not, write to the Free Software Foundation, Inc.,
20 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
22
23 use strict;
24 use warnings;
25
26 use CGI;
27 use C4::Auth qw(:DEFAULT get_session);
28 use C4::Branch;
29 use C4::Koha;
30 use C4::Serials;    #uses getsubscriptionfrom biblionumber
31 use C4::Output;
32 use C4::Biblio;
33 use C4::Items;
34 use C4::Circulation;
35 use C4::Tags qw(get_tags);
36 use C4::XISBN qw(get_xisbns get_biblionumber_from_isbn);
37 use C4::External::Amazon;
38 use C4::External::Syndetics qw(get_syndetics_index get_syndetics_summary get_syndetics_toc get_syndetics_excerpt get_syndetics_reviews get_syndetics_anotes );
39 use C4::Review;
40 use C4::Ratings;
41 use C4::Members;
42 use C4::VirtualShelves;
43 use C4::XSLT;
44 use C4::ShelfBrowser;
45 use C4::Reserves;
46 use C4::Charset;
47 use MARC::Record;
48 use MARC::Field;
49 use List::MoreUtils qw/any none/;
50 use C4::Images;
51 use Koha::DateUtils;
52 use C4::HTML5Media;
53 use C4::CourseReserves qw(GetItemCourseReservesInfo);
54
55 BEGIN {
56         if (C4::Context->preference('BakerTaylorEnabled')) {
57                 require C4::External::BakerTaylor;
58                 import C4::External::BakerTaylor qw(&image_url &link_url);
59         }
60 }
61
62 my $query = new CGI;
63 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
64     {
65         template_name   => "opac-detail.tmpl",
66         query           => $query,
67         type            => "opac",
68         authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
69         flagsrequired   => { borrow => 1 },
70     }
71 );
72
73 my $biblionumber = $query->param('biblionumber') || $query->param('bib') || 0;
74 $biblionumber = int($biblionumber);
75
76 my @all_items = GetItemsInfo($biblionumber);
77 my @hiddenitems;
78 if (scalar @all_items >= 1) {
79     push @hiddenitems, GetHiddenItemnumbers(@all_items);
80
81     if (scalar @hiddenitems == scalar @all_items ) {
82         print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
83         exit;
84     }
85 }
86
87 my $record       = GetMarcBiblio($biblionumber);
88 if ( ! $record ) {
89     print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
90     exit;
91 }
92
93 # redirect if opacsuppression is enabled and biblio is suppressed
94 if (C4::Context->preference('OpacSuppression')) {
95     # FIXME hardcoded; the suppression flag ought to be materialized
96     # as a column on biblio or the like
97     my $opacsuppressionfield = '942';
98     my $opacsuppressionfieldvalue = $record->field($opacsuppressionfield);
99     # redirect to opac-blocked info page or 404?
100     my $opacsuppressionredirect;
101     if ( C4::Context->preference("OpacSuppressionRedirect") ) {
102         $opacsuppressionredirect = "/cgi-bin/koha/opac-blocked.pl";
103     } else {
104         $opacsuppressionredirect = "/cgi-bin/koha/errors/404.pl";
105     }
106     if ( $opacsuppressionfieldvalue &&
107          $opacsuppressionfieldvalue->subfield("n") &&
108          $opacsuppressionfieldvalue->subfield("n") == 1) {
109         # if OPAC suppression by IP address
110         if (C4::Context->preference('OpacSuppressionByIPRange')) {
111             my $IPAddress = $ENV{'REMOTE_ADDR'};
112             my $IPRange = C4::Context->preference('OpacSuppressionByIPRange');
113             if ($IPAddress !~ /^$IPRange/)  {
114                 print $query->redirect($opacsuppressionredirect);
115                 exit;
116             }
117         } else {
118             print $query->redirect($opacsuppressionredirect);
119             exit;
120         }
121     }
122 }
123
124 $template->param( biblionumber => $biblionumber );
125
126 # get biblionumbers stored in the cart
127 my @cart_list;
128
129 if($query->cookie("bib_list")){
130     my $cart_list = $query->cookie("bib_list");
131     @cart_list = split(/\//, $cart_list);
132     if ( grep {$_ eq $biblionumber} @cart_list) {
133         $template->param( incart => 1 );
134     }
135 }
136
137
138 SetUTF8Flag($record);
139 my $marcflavour      = C4::Context->preference("marcflavour");
140 my $ean = GetNormalizedEAN( $record, $marcflavour );
141
142 # XSLT processing of some stuff
143 if (C4::Context->preference("OPACXSLTDetailsDisplay") ) {
144     $template->param( 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, "OPACXSLTDetailsDisplay" ) );
145 }
146
147 my $OpacBrowseResults = C4::Context->preference("OpacBrowseResults");
148 $template->{VARS}->{'OpacBrowseResults'} = $OpacBrowseResults;
149
150 # We look for the busc param to build the simple paging from the search
151 if ($OpacBrowseResults) {
152 my $session = get_session($query->cookie("CGISESSID"));
153 my %paging = (previous => {}, next => {});
154 if ($session->param('busc')) {
155     use C4::Search;
156
157     # Rebuild the string to store on session
158     sub rebuildBuscParam
159     {
160         my $arrParamsBusc = shift;
161
162         my $pasarParams = '';
163         my $j = 0;
164         for (keys %$arrParamsBusc) {
165             if ($_ =~ /^(?:query|listBiblios|newlistBiblios|query_type|simple_query|total|offset|offsetSearch|next|previous|count|expand|scan)/) {
166                 if (defined($arrParamsBusc->{$_})) {
167                     $pasarParams .= '&' if ($j);
168                     $pasarParams .= $_ . '=' . $arrParamsBusc->{$_};
169                     $j++;
170                 }
171             } else {
172                 for my $value (@{$arrParamsBusc->{$_}}) {
173                     $pasarParams .= '&' if ($j);
174                     $pasarParams .= $_ . '=' . $value;
175                     $j++;
176                 }
177             }
178         }
179         return $pasarParams;
180     }#rebuildBuscParam
181
182     # Search given the current values from the busc param
183     sub searchAgain
184     {
185         my ($arrParamsBusc, $offset, $results_per_page) = @_;
186
187         my $expanded_facet = $arrParamsBusc->{'expand'};
188         my $branches = GetBranches();
189         my $itemtypes = GetItemTypes;
190         my @servers;
191         @servers = @{$arrParamsBusc->{'server'}} if $arrParamsBusc->{'server'};
192         @servers = ("biblioserver") unless (@servers);
193
194         my ($default_sort_by, @sort_by);
195         $default_sort_by = C4::Context->preference('OPACdefaultSortField')."_".C4::Context->preference('OPACdefaultSortOrder') if (C4::Context->preference('OPACdefaultSortField') && C4::Context->preference('OPACdefaultSortOrder'));
196         @sort_by = @{$arrParamsBusc->{'sort_by'}} if $arrParamsBusc->{'sort_by'};
197         $sort_by[0] = $default_sort_by if !$sort_by[0] && defined($default_sort_by);
198         my ($error, $results_hashref, $facets);
199         eval {
200             ($error, $results_hashref, $facets) = getRecords($arrParamsBusc->{'query'},$arrParamsBusc->{'simple_query'},\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$itemtypes,$arrParamsBusc->{'query_type'},$arrParamsBusc->{'scan'});
201         };
202         my $hits;
203         my @newresults;
204         for (my $i=0;$i<@servers;$i++) {
205             my $server = $servers[$i];
206             $hits = $results_hashref->{$server}->{"hits"};
207             @newresults = searchResults('opac', '', $hits, $results_per_page, $offset, $arrParamsBusc->{'scan'}, $results_hashref->{$server}->{"RECORDS"});
208         }
209         return \@newresults;
210     }#searchAgain
211
212     # Build the current list of biblionumbers in this search
213     sub buildListBiblios
214     {
215         my ($newresultsRef, $results_per_page) = @_;
216
217         my $listBiblios = '';
218         my $j = 0;
219         foreach (@$newresultsRef) {
220             my $bibnum = ($_->{biblionumber})?$_->{biblionumber}:0;
221             $listBiblios .= $bibnum . ',';
222             $j++;
223             last if ($j == $results_per_page);
224         }
225         chop $listBiblios if ($listBiblios =~ /,$/);
226         return $listBiblios;
227     }#buildListBiblios
228
229     my $busc = $session->param("busc");
230     my @arrBusc = split(/\&(?:amp;)?/, $busc);
231     my ($key, $value);
232     my %arrParamsBusc = ();
233     for (@arrBusc) {
234         ($key, $value) = split(/=/, $_, 2);
235         if ($key =~ /^(?:query|listBiblios|newlistBiblios|query_type|simple_query|next|previous|total|offset|offsetSearch|count|expand|scan)/) {
236             $arrParamsBusc{$key} = $value;
237         } else {
238             unless (exists($arrParamsBusc{$key})) {
239                 $arrParamsBusc{$key} = [];
240             }
241             push @{$arrParamsBusc{$key}}, $value;
242         }
243     }
244     my $searchAgain = 0;
245     my $count = C4::Context->preference('OPACnumSearchResults') || 20;
246     my $results_per_page = ($arrParamsBusc{'count'} && $arrParamsBusc{'count'} =~ /^[0-9]+?/)?$arrParamsBusc{'count'}:$count;
247     $arrParamsBusc{'count'} = $results_per_page;
248     my $offset = ($arrParamsBusc{'offset'} && $arrParamsBusc{'offset'} =~ /^[0-9]+?/)?$arrParamsBusc{'offset'}:0;
249     # The value OPACnumSearchResults has changed and the search has to be rebuild
250     if ($count != $results_per_page) {
251         if (exists($arrParamsBusc{'listBiblios'}) && $arrParamsBusc{'listBiblios'} =~ /^[0-9]+(?:,[0-9]+)*$/) {
252             my $indexBiblio = 0;
253             my @arrBibliosAux = split(',', $arrParamsBusc{'listBiblios'});
254             for (@arrBibliosAux) {
255                 last if ($_ == $biblionumber);
256                 $indexBiblio++;
257             }
258             $indexBiblio += $offset;
259             $offset = int($indexBiblio / $count) * $count;
260             $arrParamsBusc{'offset'} = $offset;
261         }
262         $arrParamsBusc{'count'} = $count;
263         $results_per_page = $count;
264         my $newresultsRef = searchAgain(\%arrParamsBusc, $offset, $results_per_page);
265         $arrParamsBusc{'listBiblios'} = buildListBiblios($newresultsRef, $results_per_page);
266         delete $arrParamsBusc{'previous'} if (exists($arrParamsBusc{'previous'}));
267         delete $arrParamsBusc{'next'} if (exists($arrParamsBusc{'next'}));
268         delete $arrParamsBusc{'offsetSearch'} if (exists($arrParamsBusc{'offsetSearch'}));
269         delete $arrParamsBusc{'newlistBiblios'} if (exists($arrParamsBusc{'newlistBiblios'}));
270         my $newbusc = rebuildBuscParam(\%arrParamsBusc);
271         $session->param("busc" => $newbusc);
272         @arrBusc = split(/\&(?:amp;)?/, $newbusc);
273     } else {
274         my $modifyListBiblios = 0;
275         # We come from a previous click
276         if (exists($arrParamsBusc{'previous'})) {
277             $modifyListBiblios = 1 if ($biblionumber == $arrParamsBusc{'previous'});
278             delete $arrParamsBusc{'previous'};
279         } elsif (exists($arrParamsBusc{'next'})) { # We come from a next click
280             $modifyListBiblios = 2 if ($biblionumber == $arrParamsBusc{'next'});
281             delete $arrParamsBusc{'next'};
282         }
283         if ($modifyListBiblios) {
284             if (exists($arrParamsBusc{'newlistBiblios'})) {
285                 my $listBibliosAux = $arrParamsBusc{'listBiblios'};
286                 $arrParamsBusc{'listBiblios'} = $arrParamsBusc{'newlistBiblios'};
287                 my @arrAux = split(',', $listBibliosAux);
288                 $arrParamsBusc{'newlistBiblios'} = $listBibliosAux;
289                 if ($modifyListBiblios == 1) {
290                     $arrParamsBusc{'next'} = $arrAux[0];
291                     $paging{'next'}->{biblionumber} = $arrAux[0];
292                 }else {
293                     $arrParamsBusc{'previous'} = $arrAux[$#arrAux];
294                     $paging{'previous'}->{biblionumber} = $arrAux[$#arrAux];
295                 }
296             } else {
297                 delete $arrParamsBusc{'listBiblios'};
298             }
299             my $offsetAux = $arrParamsBusc{'offset'};
300             $arrParamsBusc{'offset'} = $arrParamsBusc{'offsetSearch'};
301             $arrParamsBusc{'offsetSearch'} = $offsetAux;
302             $offset = $arrParamsBusc{'offset'};
303             my $newbusc = rebuildBuscParam(\%arrParamsBusc);
304             $session->param("busc" => $newbusc);
305             @arrBusc = split(/\&(?:amp;)?/, $newbusc);
306         }
307     }
308     my $buscParam = '';
309     my $j = 0;
310     # Rebuild the query for the button "back to results"
311     for (@arrBusc) {
312         unless ($_ =~ /^(?:query|listBiblios|newlistBiblios|query_type|simple_query|next|previous|total|count|offsetSearch)/) {
313             $buscParam .= '&amp;' unless ($j == 0);
314             $buscParam .= $_;
315             $j++;
316         }
317     }
318     $template->param('busc' => $buscParam);
319     my $offsetSearch;
320     my @arrBiblios;
321     # We are inside the list of biblios and we don't have to search
322     if (exists($arrParamsBusc{'listBiblios'}) && $arrParamsBusc{'listBiblios'} =~ /^[0-9]+(?:,[0-9]+)*$/) {
323         @arrBiblios = split(',', $arrParamsBusc{'listBiblios'});
324         if (@arrBiblios) {
325             # We are at the first item of the list
326             if ($arrBiblios[0] == $biblionumber) {
327                 if (@arrBiblios > 1) {
328                     for (my $j = 1; $j < @arrBiblios; $j++) {
329                         next unless ($arrBiblios[$j]);
330                         $paging{'next'}->{biblionumber} = $arrBiblios[$j];
331                         last;
332                     }
333                 }
334                 # search again if we are not at the first searching list
335                 if ($offset && !$arrParamsBusc{'previous'}) {
336                     $searchAgain = 1;
337                     $offsetSearch = $offset - $results_per_page;
338                 }
339             # we are at the last item of the list
340             } elsif ($arrBiblios[$#arrBiblios] == $biblionumber) {
341                 for (my $j = $#arrBiblios - 1; $j >= 0; $j--) {
342                     next unless ($arrBiblios[$j]);
343                     $paging{'previous'}->{biblionumber} = $arrBiblios[$j];
344                     last;
345                 }
346                 if (!$offset) {
347                     # search again if we are at the first list and there is more results
348                     $searchAgain = 1 if (!$arrParamsBusc{'next'} && $arrParamsBusc{'total'} != @arrBiblios);
349                 } else {
350                     # search again if we aren't at the first list and there is more results
351                     $searchAgain = 1 if (!$arrParamsBusc{'next'} && $arrParamsBusc{'total'} > ($offset + @arrBiblios));
352                 }
353                 $offsetSearch = $offset + $results_per_page if ($searchAgain);
354             } else {
355                 for (my $j = 1; $j < $#arrBiblios; $j++) {
356                     if ($arrBiblios[$j] == $biblionumber) {
357                         for (my $z = $j - 1; $z >= 0; $z--) {
358                             next unless ($arrBiblios[$z]);
359                             $paging{'previous'}->{biblionumber} = $arrBiblios[$z];
360                             last;
361                         }
362                         for (my $z = $j + 1; $z < @arrBiblios; $z++) {
363                             next unless ($arrBiblios[$z]);
364                             $paging{'next'}->{biblionumber} = $arrBiblios[$z];
365                             last;
366                         }
367                         last;
368                     }
369                 }
370             }
371         }
372         $offsetSearch = 0 if (defined($offsetSearch) && $offsetSearch < 0);
373     }
374     if ($searchAgain) {
375         my $newresultsRef = searchAgain(\%arrParamsBusc, $offsetSearch, $results_per_page);
376         my @newresults = @$newresultsRef;
377         # build the new listBiblios
378         my $listBiblios = buildListBiblios(\@newresults, $results_per_page);
379         unless (exists($arrParamsBusc{'listBiblios'})) {
380             $arrParamsBusc{'listBiblios'} = $listBiblios;
381             @arrBiblios = split(',', $arrParamsBusc{'listBiblios'});
382         } else {
383             $arrParamsBusc{'newlistBiblios'} = $listBiblios;
384         }
385         # From the new list we build again the next and previous result
386         if (@arrBiblios) {
387             if ($arrBiblios[0] == $biblionumber) {
388                 for (my $j = $#newresults; $j >= 0; $j--) {
389                     next unless ($newresults[$j]);
390                     $paging{'previous'}->{biblionumber} = $newresults[$j]->{biblionumber};
391                     $arrParamsBusc{'previous'} = $paging{'previous'}->{biblionumber};
392                     $arrParamsBusc{'offsetSearch'} = $offsetSearch;
393                    last;
394                 }
395             } elsif ($arrBiblios[$#arrBiblios] == $biblionumber) {
396                 for (my $j = 0; $j < @newresults; $j++) {
397                     next unless ($newresults[$j]);
398                     $paging{'next'}->{biblionumber} = $newresults[$j]->{biblionumber};
399                     $arrParamsBusc{'next'} = $paging{'next'}->{biblionumber};
400                     $arrParamsBusc{'offsetSearch'} = $offsetSearch;
401                     last;
402                 }
403             }
404         }
405         # build new busc param
406         my $newbusc = rebuildBuscParam(\%arrParamsBusc);
407         $session->param("busc" => $newbusc);
408     }
409     my ($numberBiblioPaging, $dataBiblioPaging);
410     # Previous biblio
411     $numberBiblioPaging = $paging{'previous'}->{biblionumber};
412     if ($numberBiblioPaging) {
413         $template->param( 'previousBiblionumber' => $numberBiblioPaging );
414         $dataBiblioPaging = GetBiblioData($numberBiblioPaging);
415         $template->param('previousTitle' => $dataBiblioPaging->{'title'}) if ($dataBiblioPaging);
416     }
417     # Next biblio
418     $numberBiblioPaging = $paging{'next'}->{biblionumber};
419     if ($numberBiblioPaging) {
420         $template->param( 'nextBiblionumber' => $numberBiblioPaging );
421         $dataBiblioPaging = GetBiblioData($numberBiblioPaging);
422         $template->param('nextTitle' => $dataBiblioPaging->{'title'}) if ($dataBiblioPaging);
423     }
424     # Partial list of biblio results
425     my @listResults;
426     for (my $j = 0; $j < @arrBiblios; $j++) {
427         next unless ($arrBiblios[$j]);
428         $dataBiblioPaging = GetBiblioData($arrBiblios[$j]) if ($arrBiblios[$j] != $biblionumber);
429         push @listResults, {index => $j + 1 + $offset, biblionumber => $arrBiblios[$j], title => ($arrBiblios[$j] == $biblionumber)?'':$dataBiblioPaging->{title}, author => ($arrBiblios[$j] != $biblionumber && $dataBiblioPaging->{author})?$dataBiblioPaging->{author}:'', url => ($arrBiblios[$j] == $biblionumber)?'':'opac-detail.pl?biblionumber=' . $arrBiblios[$j]};
430     }
431     $template->param('listResults' => \@listResults) if (@listResults);
432     $template->param('indexPag' => 1 + $offset, 'totalPag' => $arrParamsBusc{'total'}, 'indexPagEnd' => scalar(@arrBiblios) + $offset);
433 }
434 }
435
436
437
438 $template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHolds') );
439 $template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
440
441
442
443 $template->param('OPACShowCheckoutName' => C4::Context->preference("OPACShowCheckoutName") );
444 $template->param('OPACShowBarcode' => C4::Context->preference("OPACShowBarcode") );
445
446 # adding items linked via host biblios
447
448 my $analyticfield = '773';
449 if ($marcflavour eq 'MARC21' || $marcflavour eq 'NORMARC'){
450     $analyticfield = '773';
451 } elsif ($marcflavour eq 'UNIMARC') {
452     $analyticfield = '461';
453 }
454 foreach my $hostfield ( $record->field($analyticfield)) {
455     my $hostbiblionumber = $hostfield->subfield("0");
456     my $linkeditemnumber = $hostfield->subfield("9");
457     my @hostitemInfos = GetItemsInfo($hostbiblionumber);
458     foreach my $hostitemInfo (@hostitemInfos){
459         if ($hostitemInfo->{itemnumber} eq $linkeditemnumber){
460             push(@all_items, $hostitemInfo);
461         }
462     }
463 }
464
465 my @items;
466
467 # Are there items to hide?
468 my $hideitems;
469 $hideitems = 1 if C4::Context->preference('hidelostitems') or scalar(@hiddenitems) > 0;
470
471 # Hide items
472 if ($hideitems) {
473     for my $itm (@all_items) {
474         if  ( C4::Context->preference('hidelostitems') ) {
475             push @items, $itm unless $itm->{itemlost} or any { $itm->{'itemnumber'} eq $_ } @hiddenitems;
476         } else {
477             push @items, $itm unless any { $itm->{'itemnumber'} eq $_ } @hiddenitems;
478     }
479 }
480 } else {
481     # Or not
482     @items = @all_items;
483 }
484
485 my $branches = GetBranches();
486 my $branch = '';
487 if (C4::Context->userenv){
488     $branch = C4::Context->userenv->{branch};
489 }
490 if ( C4::Context->preference('HighlightOwnItemsOnOPAC') ) {
491     if (
492         ( ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) && $branch )
493         ||
494         C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch'
495     ) {
496         my $branchname;
497         if ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) {
498             $branchname = $branches->{$branch}->{'branchname'};
499         }
500         elsif (  C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch' ) {
501             $branchname = $branches->{ $ENV{'BRANCHCODE'} }->{'branchname'};
502         }
503
504         my @our_items;
505         my @other_items;
506
507         foreach my $item ( @items ) {
508            if ( $item->{'branchname'} eq $branchname ) {
509                $item->{'this_branch'} = 1;
510                push( @our_items, $item );
511            } else {
512                push( @other_items, $item );
513            }
514         }
515
516         @items = ( @our_items, @other_items );
517     }
518 }
519
520 my $dat = &GetBiblioData($biblionumber);
521
522 my $itemtypes = GetItemTypes();
523 # imageurl:
524 my $itemtype = $dat->{'itemtype'};
525 if ( $itemtype ) {
526     $dat->{'imageurl'}    = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} );
527     $dat->{'description'} = $itemtypes->{$itemtype}->{'description'};
528 }
529 my $shelflocations =GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'}, 'opac');
530 my $collections =  GetKohaAuthorisedValues('items.ccode',$dat->{'frameworkcode'}, 'opac');
531 my $copynumbers = GetKohaAuthorisedValues('items.copynumber',$dat->{'frameworkcode'}, 'opac');
532
533 #coping with subscriptions
534 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
535 my @subscriptions       = GetSubscriptions($dat->{'title'}, $dat->{'issn'}, $ean, $biblionumber );
536
537 my @subs;
538 $dat->{'serial'}=1 if $subscriptionsnumber;
539 foreach my $subscription (@subscriptions) {
540     my $serials_to_display;
541     my %cell;
542     $cell{subscriptionid}    = $subscription->{subscriptionid};
543     $cell{subscriptionnotes} = $subscription->{notes};
544     $cell{missinglist}       = $subscription->{missinglist};
545     $cell{opacnote}          = $subscription->{opacnote};
546     $cell{histstartdate}     = $subscription->{histstartdate};
547     $cell{histenddate}       = $subscription->{histenddate};
548     $cell{branchcode}        = $subscription->{branchcode};
549     $cell{branchname}        = GetBranchName($subscription->{branchcode});
550     $cell{hasalert}          = $subscription->{hasalert};
551     $cell{callnumber}        = $subscription->{callnumber};
552     $cell{closed}            = $subscription->{closed};
553     #get the three latest serials.
554     $serials_to_display = $subscription->{opacdisplaycount};
555     $serials_to_display = C4::Context->preference('OPACSerialIssueDisplayCount') unless $serials_to_display;
556         $cell{opacdisplaycount} = $serials_to_display;
557     $cell{latestserials} =
558       GetLatestSerials( $subscription->{subscriptionid}, $serials_to_display );
559     push @subs, \%cell;
560 }
561
562 $dat->{'count'} = scalar(@items);
563
564
565 my $biblio_authorised_value_images = C4::Items::get_authorised_value_images( C4::Biblio::get_biblio_authorised_values( $biblionumber, $record ) );
566
567 my (%item_reserves, %priority);
568 my ($show_holds_count, $show_priority);
569 for ( C4::Context->preference("OPACShowHoldQueueDetails") ) {
570     m/holds/o and $show_holds_count = 1;
571     m/priority/ and $show_priority = 1;
572 }
573 my $has_hold;
574 if ( $show_holds_count || $show_priority) {
575     my $reserves = GetReservesFromBiblionumber({ biblionumber => $biblionumber, all_dates => 1 });
576     $template->param( holds_count  => scalar( @$reserves ) ) if $show_holds_count;
577     foreach (@$reserves) {
578         $item_reserves{ $_->{itemnumber} }++ if $_->{itemnumber};
579         if ($show_priority && $_->{borrowernumber} == $borrowernumber) {
580             $has_hold = 1;
581             $_->{itemnumber}
582                 ? ($priority{ $_->{itemnumber} } = $_->{priority})
583                 : ($template->param( priority => $_->{priority} ));
584         }
585     }
586 }
587 $template->param( show_priority => $has_hold ) ;
588
589 my $norequests = 1;
590 my %itemfields;
591 my (@itemloop, @otheritemloop);
592 my $currentbranch = C4::Context->userenv ? C4::Context->userenv->{branch} : undef;
593 if ($currentbranch and C4::Context->preference('OpacSeparateHoldings')) {
594     $template->param(SeparateHoldings => 1);
595 }
596 my $separatebranch = C4::Context->preference('OpacSeparateHoldingsBranch');
597 my $viewallitems = $query->param('viewallitems');
598 my $max_items_to_display = C4::Context->preference('OpacMaxItemsToDisplay') // 50;
599 if ( not $viewallitems and @items > $max_items_to_display ) {
600     $template->param(
601         too_many_items => 1,
602         items_count => scalar( @items ),
603     );
604 } else {
605   for my $itm (@items) {
606     $itm->{holds_count} = $item_reserves{ $itm->{itemnumber} };
607     $itm->{priority} = $priority{ $itm->{itemnumber} };
608     $norequests = 0
609        if ( (not $itm->{'withdrawn'} )
610          && (not $itm->{'itemlost'} )
611          && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'} )
612                  && (not $itemtypes->{$itm->{'itype'}}->{notforloan} )
613          && ($itm->{'itemnumber'} ) );
614
615     # get collection code description, too
616     my $ccode = $itm->{'ccode'};
617     $itm->{'ccode'} = $collections->{$ccode} if defined($ccode) && $collections && exists( $collections->{$ccode} );
618     my $copynumber = $itm->{'copynumber'};
619     $itm->{'copynumber'} = $copynumbers->{$copynumber} if ( defined($copynumbers) && defined($copynumber) && exists( $copynumbers->{$copynumber} ) );
620     if ( defined $itm->{'location'} ) {
621         $itm->{'location_description'} = $shelflocations->{ $itm->{'location'} };
622     }
623     if (exists $itm->{itype} && defined($itm->{itype}) && exists $itemtypes->{ $itm->{itype} }) {
624         $itm->{'imageurl'}    = getitemtypeimagelocation( 'opac', $itemtypes->{ $itm->{itype} }->{'imageurl'} );
625         $itm->{'description'} = $itemtypes->{ $itm->{itype} }->{'description'};
626     }
627     foreach (qw(ccode enumchron copynumber itemnotes uri)) {
628         $itemfields{$_} = 1 if ($itm->{$_});
629     }
630
631      # walk through the item-level authorised values and populate some images
632      my $item_authorised_value_images = C4::Items::get_authorised_value_images( C4::Items::get_item_authorised_values( $itm->{'itemnumber'} ) );
633      # warn( Data::Dumper->Dump( [ $item_authorised_value_images ], [ 'item_authorised_value_images' ] ) );
634
635      if ( $itm->{'itemlost'} ) {
636          my $lostimageinfo = List::Util::first { $_->{'category'} eq 'LOST' } @$item_authorised_value_images;
637          $itm->{'lostimageurl'}   = $lostimageinfo->{ 'imageurl' };
638          $itm->{'lostimagelabel'} = $lostimageinfo->{ 'label' };
639      }
640      my $reserve_status = C4::Reserves::GetReserveStatus($itm->{itemnumber});
641       if( $reserve_status eq "Waiting"){ $itm->{'waiting'} = 1; }
642       if( $reserve_status eq "Reserved"){ $itm->{'onhold'} = 1; }
643     
644      my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($itm->{itemnumber});
645      if ( defined( $transfertwhen ) && $transfertwhen ne '' ) {
646         $itm->{transfertwhen} = $transfertwhen;
647         $itm->{transfertfrom} = $branches->{$transfertfrom}{branchname};
648         $itm->{transfertto}   = $branches->{$transfertto}{branchname};
649      }
650     my $itembranch = $itm->{$separatebranch};
651     if ($currentbranch and C4::Context->preference('OpacSeparateHoldings')) {
652         if ($itembranch and $itembranch eq $currentbranch) {
653             push @itemloop, $itm;
654         } else {
655             push @otheritemloop, $itm;
656         }
657     } else {
658         push @itemloop, $itm;
659     }
660   }
661 }
662
663 # Display only one tab if one items list is empty
664 if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) {
665     $template->param(SeparateHoldings => 0);
666     if (scalar(@itemloop) == 0) {
667         @itemloop = @otheritemloop;
668     }
669 }
670
671 ## get notes and subjects from MARC record
672 if (!C4::Context->preference("OPACXSLTDetailsDisplay") ) {
673     my $marcisbnsarray   = GetMarcISBN    ($record,$marcflavour);
674     my $marcauthorsarray = GetMarcAuthors ($record,$marcflavour);
675     my $marcsubjctsarray = GetMarcSubjects($record,$marcflavour);
676     my $marcseriesarray  = GetMarcSeries  ($record,$marcflavour);
677     my $marcurlsarray    = GetMarcUrls    ($record,$marcflavour);
678     my $marchostsarray   = GetMarcHosts($record,$marcflavour);
679
680     $template->param(
681         MARCSUBJCTS => $marcsubjctsarray,
682         MARCAUTHORS => $marcauthorsarray,
683         MARCSERIES  => $marcseriesarray,
684         MARCURLS    => $marcurlsarray,
685         MARCISBNS   => $marcisbnsarray,
686         MARCHOSTS   => $marchostsarray,
687     );
688 }
689
690 my $marcnotesarray   = GetMarcNotes   ($record,$marcflavour);
691 my $subtitle         = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber));
692
693     $template->param(
694                      MARCNOTES               => $marcnotesarray,
695                      norequests              => $norequests,
696                      RequestOnOpac           => C4::Context->preference("RequestOnOpac"),
697                      itemdata_ccode          => $itemfields{ccode},
698                      itemdata_enumchron      => $itemfields{enumchron},
699                      itemdata_uri            => $itemfields{uri},
700                      itemdata_copynumber     => $itemfields{copynumber},
701                      itemdata_itemnotes          => $itemfields{itemnotes},
702                      authorised_value_images => $biblio_authorised_value_images,
703                      subtitle                => $subtitle,
704                      OpacStarRatings         => C4::Context->preference("OpacStarRatings"),
705     );
706
707 if (C4::Context->preference("AlternateHoldingsField") && scalar @items == 0) {
708     my $fieldspec = C4::Context->preference("AlternateHoldingsField");
709     my $subfields = substr $fieldspec, 3;
710     my $holdingsep = C4::Context->preference("AlternateHoldingsSeparator") || ' ';
711     my @alternateholdingsinfo = ();
712     my @holdingsfields = $record->field(substr $fieldspec, 0, 3);
713
714     for my $field (@holdingsfields) {
715         my %holding = ( holding => '' );
716         my $havesubfield = 0;
717         for my $subfield ($field->subfields()) {
718             if ((index $subfields, $$subfield[0]) >= 0) {
719                 $holding{'holding'} .= $holdingsep if (length $holding{'holding'} > 0);
720                 $holding{'holding'} .= $$subfield[1];
721                 $havesubfield++;
722             }
723         }
724         if ($havesubfield) {
725             push(@alternateholdingsinfo, \%holding);
726         }
727     }
728
729     $template->param(
730         ALTERNATEHOLDINGS   => \@alternateholdingsinfo,
731         );
732 }
733
734 foreach ( keys %{$dat} ) {
735     $template->param( "$_" => defined $dat->{$_} ? $dat->{$_} : '' );
736 }
737
738 # some useful variables for enhanced content;
739 # in each case, we're grabbing the first value we find in
740 # the record and normalizing it
741 my $upc = GetNormalizedUPC($record,$marcflavour);
742 my $oclc = GetNormalizedOCLCNumber($record,$marcflavour);
743 my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
744 my $content_identifier_exists;
745 if ( $isbn or $ean or $oclc or $upc ) {
746     $content_identifier_exists = 1;
747 }
748 $template->param(
749         normalized_upc => $upc,
750         normalized_ean => $ean,
751         normalized_oclc => $oclc,
752         normalized_isbn => $isbn,
753         content_identifier_exists =>  $content_identifier_exists,
754 );
755
756 # COinS format FIXME: for books Only
757 $template->param(
758     ocoins => GetCOinSBiblio($record),
759 );
760
761 my $libravatar_enabled = 0;
762 if ( C4::Context->preference('ShowReviewer') and C4::Context->preference('ShowReviewerPhoto')) {
763     eval {
764         require Libravatar::URL;
765         Libravatar::URL->import();
766     };
767     if (!$@ ) {
768         $libravatar_enabled = 1;
769     }
770 }
771
772 my $reviews = getreviews( $biblionumber, 1 );
773 my $loggedincommenter;
774
775
776
777
778 foreach ( @$reviews ) {
779     my $borrowerData   = GetMember('borrowernumber' => $_->{borrowernumber});
780     # setting some borrower info into this hash
781     $_->{title}     = $borrowerData->{'title'};
782     $_->{surname}   = $borrowerData->{'surname'};
783     $_->{firstname} = $borrowerData->{'firstname'};
784     if ($libravatar_enabled and $borrowerData->{'email'}) {
785         $_->{avatarurl} = libravatar_url(email => $borrowerData->{'email'}, https => $ENV{HTTPS});
786     }
787     $_->{userid}    = $borrowerData->{'userid'};
788     $_->{cardnumber}    = $borrowerData->{'cardnumber'};
789
790     if ($borrowerData->{'borrowernumber'} eq $borrowernumber) {
791                 $_->{your_comment} = 1;
792                 $loggedincommenter = 1;
793         }
794 }
795
796
797 if(C4::Context->preference("ISBD")) {
798         $template->param(ISBD => 1);
799 }
800
801 $template->param(
802     itemloop            => \@itemloop,
803     otheritemloop       => \@otheritemloop,
804     subscriptionsnumber => $subscriptionsnumber,
805     biblionumber        => $biblionumber,
806     subscriptions       => \@subs,
807     subscriptionsnumber => $subscriptionsnumber,
808     reviews             => $reviews,
809     loggedincommenter   => $loggedincommenter
810 );
811
812 # Lists
813
814 if (C4::Context->preference("virtualshelves") ) {
815    $template->param( 'GetShelves' => GetBibliosShelves( $biblionumber ) );
816 }
817
818
819 # XISBN Stuff
820 if (C4::Context->preference("OPACFRBRizeEditions")==1) {
821     eval {
822         $template->param(
823             XISBNS => get_xisbns($isbn)
824         );
825     };
826     if ($@) { warn "XISBN Failed $@"; }
827 }
828
829 # Serial Collection
830 my @sc_fields = $record->field(955);
831 my @lc_fields = $marcflavour eq 'UNIMARC'
832     ? $record->field(930)
833     : $record->field(852);
834 my @serialcollections = ();
835
836 foreach my $sc_field (@sc_fields) {
837     my %row_data;
838
839     $row_data{text}    = $sc_field->subfield('r');
840     $row_data{branch}  = $sc_field->subfield('9');
841     foreach my $lc_field (@lc_fields) {
842         $row_data{itemcallnumber} = $marcflavour eq 'UNIMARC'
843             ? $lc_field->subfield('a') # 930$a
844             : $lc_field->subfield('h') # 852$h
845             if ($sc_field->subfield('5') eq $lc_field->subfield('5'));
846     }
847
848     if ($row_data{text} && $row_data{branch}) { 
849         push (@serialcollections, \%row_data);
850     }
851 }
852
853 if (scalar(@serialcollections) > 0) {
854     $template->param(
855         serialcollection  => 1,
856         serialcollections => \@serialcollections);
857 }
858
859 # Local cover Images stuff
860 if (C4::Context->preference("OPACLocalCoverImages")){
861                 $template->param(OPACLocalCoverImages => 1);
862 }
863
864 # HTML5 Media
865 if ( (C4::Context->preference("HTML5MediaEnabled") eq 'both') or (C4::Context->preference("HTML5MediaEnabled") eq 'opac') ) {
866     $template->param( C4::HTML5Media->gethtml5media($record));
867 }
868
869 my $syndetics_elements;
870
871 if ( C4::Context->preference("SyndeticsEnabled") ) {
872     $template->param("SyndeticsEnabled" => 1);
873     $template->param("SyndeticsClientCode" => C4::Context->preference("SyndeticsClientCode"));
874         eval {
875             $syndetics_elements = &get_syndetics_index($isbn,$upc,$oclc);
876             for my $element (values %$syndetics_elements) {
877                 $template->param("Syndetics$element"."Exists" => 1 );
878                 #warn "Exists: "."Syndetics$element"."Exists";
879         }
880     };
881     warn $@ if $@;
882 }
883
884 if ( C4::Context->preference("SyndeticsEnabled")
885         && C4::Context->preference("SyndeticsSummary")
886         && ( exists($syndetics_elements->{'SUMMARY'}) || exists($syndetics_elements->{'AVSUMMARY'}) ) ) {
887         eval {
888             my $syndetics_summary = &get_syndetics_summary($isbn,$upc,$oclc, $syndetics_elements);
889             $template->param( SYNDETICS_SUMMARY => $syndetics_summary );
890         };
891         warn $@ if $@;
892
893 }
894
895 if ( C4::Context->preference("SyndeticsEnabled")
896         && C4::Context->preference("SyndeticsTOC")
897         && exists($syndetics_elements->{'TOC'}) ) {
898         eval {
899     my $syndetics_toc = &get_syndetics_toc($isbn,$upc,$oclc);
900     $template->param( SYNDETICS_TOC => $syndetics_toc );
901         };
902         warn $@ if $@;
903 }
904
905 if ( C4::Context->preference("SyndeticsEnabled")
906     && C4::Context->preference("SyndeticsExcerpt")
907     && exists($syndetics_elements->{'DBCHAPTER'}) ) {
908     eval {
909     my $syndetics_excerpt = &get_syndetics_excerpt($isbn,$upc,$oclc);
910     $template->param( SYNDETICS_EXCERPT => $syndetics_excerpt );
911     };
912         warn $@ if $@;
913 }
914
915 if ( C4::Context->preference("SyndeticsEnabled")
916     && C4::Context->preference("SyndeticsReviews")) {
917     eval {
918     my $syndetics_reviews = &get_syndetics_reviews($isbn,$upc,$oclc,$syndetics_elements);
919     $template->param( SYNDETICS_REVIEWS => $syndetics_reviews );
920     };
921         warn $@ if $@;
922 }
923
924 if ( C4::Context->preference("SyndeticsEnabled")
925     && C4::Context->preference("SyndeticsAuthorNotes")
926         && exists($syndetics_elements->{'ANOTES'}) ) {
927     eval {
928     my $syndetics_anotes = &get_syndetics_anotes($isbn,$upc,$oclc);
929     $template->param( SYNDETICS_ANOTES => $syndetics_anotes );
930     };
931     warn $@ if $@;
932 }
933
934 # LibraryThingForLibraries ID Code and Tabbed View Option
935 if( C4::Context->preference('LibraryThingForLibrariesEnabled') ) 
936
937 $template->param(LibraryThingForLibrariesID =>
938 C4::Context->preference('LibraryThingForLibrariesID') ); 
939 $template->param(LibraryThingForLibrariesTabbedView =>
940 C4::Context->preference('LibraryThingForLibrariesTabbedView') );
941
942
943 # Novelist Select
944 if( C4::Context->preference('NovelistSelectEnabled') ) 
945
946 $template->param(NovelistSelectProfile => C4::Context->preference('NovelistSelectProfile') ); 
947 $template->param(NovelistSelectPassword => C4::Context->preference('NovelistSelectPassword') ); 
948 $template->param(NovelistSelectView => C4::Context->preference('NovelistSelectView') ); 
949
950
951
952 # Babelthèque
953 if ( C4::Context->preference("Babeltheque") ) {
954     $template->param( 
955         Babeltheque => 1,
956         Babeltheque_url_js => C4::Context->preference("Babeltheque_url_js"),
957     );
958 }
959
960 # Social Networks
961 if ( C4::Context->preference( "SocialNetworks" ) ) {
962     $template->param( current_url => C4::Context->preference('OPACBaseURL') . "/cgi-bin/koha/opac-detail.pl?biblionumber=$biblionumber" );
963     $template->param( SocialNetworks => 1 );
964 }
965
966 # Shelf Browser Stuff
967 if (C4::Context->preference("OPACShelfBrowser")) {
968     my $starting_itemnumber = $query->param('shelfbrowse_itemnumber');
969     if (defined($starting_itemnumber)) {
970         $template->param( OpenOPACShelfBrowser => 1) if $starting_itemnumber;
971         my $nearby = GetNearbyItems($starting_itemnumber);
972
973         $template->param(
974             starting_itemnumber => $starting_itemnumber,
975             starting_homebranch => $nearby->{starting_homebranch}->{description},
976             starting_location => $nearby->{starting_location}->{description},
977             starting_ccode => $nearby->{starting_ccode}->{description},
978             shelfbrowser_prev_item => $nearby->{prev_item},
979             shelfbrowser_next_item => $nearby->{next_item},
980             shelfbrowser_items => $nearby->{items},
981         );
982
983         # in which tab shelf browser should open ?
984         if (grep { $starting_itemnumber == $_->{itemnumber} } @itemloop) {
985             $template->param(shelfbrowser_tab => 'holdings');
986         } else {
987             $template->param(shelfbrowser_tab => 'otherholdings');
988         }
989     }
990 }
991
992 $template->param( AmazonTld => get_amazon_tld() ) if ( C4::Context->preference("OPACAmazonCoverImages"));
993
994 if (C4::Context->preference("BakerTaylorEnabled")) {
995         $template->param(
996                 BakerTaylorEnabled  => 1,
997                 BakerTaylorImageURL => &image_url(),
998                 BakerTaylorLinkURL  => &link_url(),
999                 BakerTaylorBookstoreURL => C4::Context->preference('BakerTaylorBookstoreURL'),
1000         );
1001         my ($bt_user, $bt_pass);
1002         if ($isbn and
1003                 $bt_user = C4::Context->preference('BakerTaylorUsername') and
1004                 $bt_pass = C4::Context->preference('BakerTaylorPassword')    )
1005         {
1006                 $template->param(
1007                 BakerTaylorContentURL   =>
1008                 sprintf("http://contentcafe2.btol.com/ContentCafeClient/ContentCafe.aspx?UserID=%s&Password=%s&ItemKey=%s&Options=Y",
1009                                 $bt_user,$bt_pass,$isbn)
1010                 );
1011         }
1012 }
1013
1014 my $tag_quantity;
1015 if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->preference('TagsShowOnDetail')) {
1016         $template->param(
1017                 TagsEnabled => 1,
1018                 TagsShowOnDetail => $tag_quantity,
1019                 TagsInputOnDetail => C4::Context->preference('TagsInputOnDetail')
1020         );
1021         $template->param(TagLoop => get_tags({biblionumber=>$biblionumber, approved=>1,
1022                                                                 'sort'=>'-weight', limit=>$tag_quantity}));
1023 }
1024
1025 if (C4::Context->preference("OPACURLOpenInNewWindow")) {
1026     # These values are going to be read by Javascript, at least in the case
1027     # of the google covers
1028     $template->param(covernewwindow => 'true');
1029 } else {
1030     $template->param(covernewwindow => 'false');
1031 }
1032
1033 #Export options
1034 my $OpacExportOptions=C4::Context->preference("OpacExportOptions");
1035 my @export_options = split(/\|/,$OpacExportOptions);
1036 $template->{VARS}->{'export_options'} = \@export_options;
1037
1038 if ( C4::Context->preference('OpacStarRatings') !~ /disable/ ) {
1039     my $rating = GetRating( $biblionumber, $borrowernumber );
1040     $template->param(
1041         rating_value   => $rating->{'rating_value'},
1042         rating_total   => $rating->{'rating_total'},
1043         rating_avg     => $rating->{'rating_avg'},
1044         rating_avg_int => $rating->{'rating_avg_int'},
1045         borrowernumber => $borrowernumber
1046     );
1047 }
1048
1049 #Search for title in links
1050 my $marccontrolnumber   = GetMarcControlnumber ($record, $marcflavour);
1051 my $marcissns = GetMarcISSN ( $record, $marcflavour );
1052 my $issn = $marcissns->[0] || '';
1053
1054 if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
1055     $dat->{title} =~ s/\/+$//; # remove trailing slash
1056     $dat->{title} =~ s/\s+$//; # remove trailing space
1057     $search_for_title = parametrized_url(
1058         $search_for_title,
1059         {
1060             TITLE         => $dat->{title},
1061             AUTHOR        => $dat->{author},
1062             ISBN          => $isbn,
1063             ISSN          => $issn,
1064             CONTROLNUMBER => $marccontrolnumber,
1065             BIBLIONUMBER  => $biblionumber,
1066         }
1067     );
1068     $template->param('OPACSearchForTitleIn' => $search_for_title);
1069 }
1070
1071 # We try to select the best default tab to show, according to what
1072 # the user wants, and what's available for display
1073 my $opac_serial_default = C4::Context->preference('opacSerialDefaultTab');
1074 my $defaulttab = 
1075     $opac_serial_default eq 'subscriptions' && $subscriptionsnumber
1076         ? 'subscriptions' :
1077     $opac_serial_default eq 'serialcollection' && @serialcollections > 0
1078         ? 'serialcollection' :
1079     $opac_serial_default eq 'holdings' && scalar (@itemloop) > 0
1080         ? 'holdings' :
1081     $subscriptionsnumber
1082         ? 'subscriptions' :
1083     @serialcollections > 0 
1084         ? 'serialcollection' : 'subscriptions';
1085 $template->param('defaulttab' => $defaulttab);
1086
1087 if (C4::Context->preference('OPACLocalCoverImages') == 1) {
1088     my @images = ListImagesForBiblio($biblionumber);
1089     $template->{VARS}->{localimages} = \@images;
1090 }
1091
1092 $template->{VARS}->{IDreamBooksReviews} = C4::Context->preference('IDreamBooksReviews');
1093 $template->{VARS}->{IDreamBooksReadometer} = C4::Context->preference('IDreamBooksReadometer');
1094 $template->{VARS}->{IDreamBooksResults} = C4::Context->preference('IDreamBooksResults');
1095 $template->{VARS}->{OPACPopupAuthorsSearch} = C4::Context->preference('OPACPopupAuthorsSearch');
1096
1097 if (C4::Context->preference('OpacHighlightedWords')) {
1098     $template->{VARS}->{query_desc} = $query->param('query_desc');
1099 }
1100 $template->{VARS}->{'trackclicks'} = C4::Context->preference('TrackClicks');
1101
1102 if ( C4::Context->preference('UseCourseReserves') ) {
1103     foreach my $i ( @items ) {
1104         $i->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $i->{'itemnumber'} );
1105     }
1106 }
1107
1108 output_html_with_http_headers $query, $cookie, $template->output;