Bug 14537: Renaming OverdueNoticeBcc to NoticeBcc
[koha.git] / opac / opac-detail.pl
blob1336ae1905767cb8e1fdbca7912d5c2296d65a4b
1 #!/usr/bin/perl
3 # Copyright 2000-2002 Katipo Communications
4 # Copyright 2010 BibLibre
5 # Copyright 2011 KohaAloha, NZ
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
14 # Koha is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with Koha; if not, see <http://www.gnu.org/licenses>.
23 use Modern::Perl;
25 use CGI qw ( -utf8 );
26 use C4::Acquisition qw( SearchOrders );
27 use C4::Auth qw(:DEFAULT get_session);
28 use C4::Koha;
29 use C4::Serials; #uses getsubscriptionfrom biblionumber
30 use C4::Output;
31 use C4::Biblio;
32 use C4::Items;
33 use C4::Circulation;
34 use C4::Tags qw(get_tags);
35 use C4::XISBN qw(get_xisbns get_biblionumber_from_isbn);
36 use C4::External::Amazon;
37 use C4::External::Syndetics qw(get_syndetics_index get_syndetics_summary get_syndetics_toc get_syndetics_excerpt get_syndetics_reviews get_syndetics_anotes );
38 use C4::Members;
39 use C4::XSLT;
40 use C4::ShelfBrowser;
41 use C4::Reserves;
42 use C4::Charset;
43 use MARC::Record;
44 use MARC::Field;
45 use List::MoreUtils qw/any none/;
46 use C4::Images;
47 use Koha::DateUtils;
48 use C4::HTML5Media;
49 use C4::CourseReserves qw(GetItemCourseReservesInfo);
50 use Koha::RecordProcessor;
51 use Koha::AuthorisedValues;
52 use Koha::Biblios;
53 use Koha::Virtualshelves;
54 use Koha::Ratings;
55 use Koha::Reviews;
57 BEGIN {
58 if (C4::Context->preference('BakerTaylorEnabled')) {
59 require C4::External::BakerTaylor;
60 import C4::External::BakerTaylor qw(&image_url &link_url);
64 my $query = new CGI;
65 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
67 template_name => "opac-detail.tt",
68 query => $query,
69 type => "opac",
70 authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
74 my $biblionumber = $query->param('biblionumber') || $query->param('bib') || 0;
75 $biblionumber = int($biblionumber);
77 my @all_items = GetItemsInfo($biblionumber);
78 my @hiddenitems;
79 if (scalar @all_items >= 1) {
80 push @hiddenitems, GetHiddenItemnumbers(@all_items);
82 if (scalar @hiddenitems == scalar @all_items ) {
83 print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
84 exit;
88 my $record = GetMarcBiblio($biblionumber);
89 if ( ! $record ) {
90 print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
91 exit;
93 my $framework = &GetFrameworkCode( $biblionumber );
94 my $record_processor = Koha::RecordProcessor->new({
95 filters => 'ViewPolicy',
96 options => {
97 interface => 'opac',
98 frameworkcode => $framework
101 $record_processor->process($record);
103 # redirect if opacsuppression is enabled and biblio is suppressed
104 if (C4::Context->preference('OpacSuppression')) {
105 # FIXME hardcoded; the suppression flag ought to be materialized
106 # as a column on biblio or the like
107 my $opacsuppressionfield = '942';
108 my $opacsuppressionfieldvalue = $record->field($opacsuppressionfield);
109 # redirect to opac-blocked info page or 404?
110 my $opacsuppressionredirect;
111 if ( C4::Context->preference("OpacSuppressionRedirect") ) {
112 $opacsuppressionredirect = "/cgi-bin/koha/opac-blocked.pl";
113 } else {
114 $opacsuppressionredirect = "/cgi-bin/koha/errors/404.pl";
116 if ( $opacsuppressionfieldvalue &&
117 $opacsuppressionfieldvalue->subfield("n") &&
118 $opacsuppressionfieldvalue->subfield("n") == 1) {
119 # if OPAC suppression by IP address
120 if (C4::Context->preference('OpacSuppressionByIPRange')) {
121 my $IPAddress = $ENV{'REMOTE_ADDR'};
122 my $IPRange = C4::Context->preference('OpacSuppressionByIPRange');
123 if ($IPAddress !~ /^$IPRange/) {
124 print $query->redirect($opacsuppressionredirect);
125 exit;
127 } else {
128 print $query->redirect($opacsuppressionredirect);
129 exit;
134 $template->param( biblionumber => $biblionumber );
136 # get biblionumbers stored in the cart
137 my @cart_list;
139 if($query->cookie("bib_list")){
140 my $cart_list = $query->cookie("bib_list");
141 @cart_list = split(/\//, $cart_list);
142 if ( grep {$_ eq $biblionumber} @cart_list) {
143 $template->param( incart => 1 );
148 SetUTF8Flag($record);
149 my $marcflavour = C4::Context->preference("marcflavour");
150 my $ean = GetNormalizedEAN( $record, $marcflavour );
152 # XSLT processing of some stuff
153 my $xslfile = C4::Context->preference('OPACXSLTDetailsDisplay');
154 my $lang = $xslfile ? C4::Languages::getlanguage() : undef;
155 my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef;
157 if ( $xslfile ) {
158 $template->param(
159 XSLTBloc => XSLTParse4Display(
160 $biblionumber, $record, "OPACXSLTDetailsDisplay",
161 1, undef, $sysxml, $xslfile, $lang
166 my $OpacBrowseResults = C4::Context->preference("OpacBrowseResults");
167 $template->{VARS}->{'OpacBrowseResults'} = $OpacBrowseResults;
169 # We look for the busc param to build the simple paging from the search
170 if ($OpacBrowseResults) {
171 my $session = get_session($query->cookie("CGISESSID"));
172 my %paging = (previous => {}, next => {});
173 if ($session->param('busc')) {
174 use C4::Search;
175 use URI::Escape;
177 # Rebuild the string to store on session
178 # param value is URI encoded and params separator is HTML encode (&amp;)
179 sub rebuildBuscParam
181 my $arrParamsBusc = shift;
183 my $pasarParams = '';
184 my $j = 0;
185 for (keys %$arrParamsBusc) {
186 if ($_ =~ /^(?:query|listBiblios|newlistBiblios|query_type|simple_query|total|offset|offsetSearch|next|previous|count|expand|scan)/) {
187 if (defined($arrParamsBusc->{$_})) {
188 $pasarParams .= '&amp;' if ($j);
189 $pasarParams .= $_ . '=' . Encode::decode('UTF-8', uri_escape_utf8( $arrParamsBusc->{$_} ));
190 $j++;
192 } else {
193 for my $value (@{$arrParamsBusc->{$_}}) {
194 $pasarParams .= '&amp;' if ($j);
195 $pasarParams .= $_ . '=' . Encode::decode('UTF-8', uri_escape_utf8($value));
196 $j++;
200 return $pasarParams;
201 }#rebuildBuscParam
203 # Search given the current values from the busc param
204 sub searchAgain
206 my ($arrParamsBusc, $offset, $results_per_page) = @_;
208 my $expanded_facet = $arrParamsBusc->{'expand'};
209 my $itemtypes = GetItemTypes;
210 my @servers;
211 @servers = @{$arrParamsBusc->{'server'}} if $arrParamsBusc->{'server'};
212 @servers = ("biblioserver") unless (@servers);
214 my ($default_sort_by, @sort_by);
215 $default_sort_by = C4::Context->preference('OPACdefaultSortField')."_".C4::Context->preference('OPACdefaultSortOrder') if (C4::Context->preference('OPACdefaultSortField') && C4::Context->preference('OPACdefaultSortOrder'));
216 @sort_by = @{$arrParamsBusc->{'sort_by'}} if $arrParamsBusc->{'sort_by'};
217 $sort_by[0] = $default_sort_by if !$sort_by[0] && defined($default_sort_by);
218 my ($error, $results_hashref, $facets);
219 eval {
220 ($error, $results_hashref, $facets) = getRecords($arrParamsBusc->{'query'},$arrParamsBusc->{'simple_query'},\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,undef,$itemtypes,$arrParamsBusc->{'query_type'},$arrParamsBusc->{'scan'});
222 my $hits;
223 my @newresults;
224 for (my $i=0;$i<@servers;$i++) {
225 my $server = $servers[$i];
226 $hits = $results_hashref->{$server}->{"hits"};
227 @newresults = searchResults('opac', '', $hits, $results_per_page, $offset, $arrParamsBusc->{'scan'}, $results_hashref->{$server}->{"RECORDS"});
229 return \@newresults;
230 }#searchAgain
232 # Build the current list of biblionumbers in this search
233 sub buildListBiblios
235 my ($newresultsRef, $results_per_page) = @_;
237 my $listBiblios = '';
238 my $j = 0;
239 foreach (@$newresultsRef) {
240 my $bibnum = ($_->{biblionumber})?$_->{biblionumber}:0;
241 $listBiblios .= $bibnum . ',';
242 $j++;
243 last if ($j == $results_per_page);
245 chop $listBiblios if ($listBiblios =~ /,$/);
246 return $listBiblios;
247 }#buildListBiblios
249 my $busc = $session->param("busc");
250 my @arrBusc = split(/\&(?:amp;)?/, $busc);
251 my ($key, $value);
252 my %arrParamsBusc = ();
253 for (@arrBusc) {
254 ($key, $value) = split(/=/, $_, 2);
255 if ($key =~ /^(?:query|listBiblios|newlistBiblios|query_type|simple_query|next|previous|total|offset|offsetSearch|count|expand|scan)/) {
256 $arrParamsBusc{$key} = uri_unescape($value);
257 } else {
258 unless (exists($arrParamsBusc{$key})) {
259 $arrParamsBusc{$key} = [];
261 push @{$arrParamsBusc{$key}}, uri_unescape($value);
264 my $searchAgain = 0;
265 my $count = C4::Context->preference('OPACnumSearchResults') || 20;
266 my $results_per_page = ($arrParamsBusc{'count'} && $arrParamsBusc{'count'} =~ /^[0-9]+?/)?$arrParamsBusc{'count'}:$count;
267 $arrParamsBusc{'count'} = $results_per_page;
268 my $offset = ($arrParamsBusc{'offset'} && $arrParamsBusc{'offset'} =~ /^[0-9]+?/)?$arrParamsBusc{'offset'}:0;
269 # The value OPACnumSearchResults has changed and the search has to be rebuild
270 if ($count != $results_per_page) {
271 if (exists($arrParamsBusc{'listBiblios'}) && $arrParamsBusc{'listBiblios'} =~ /^[0-9]+(?:,[0-9]+)*$/) {
272 my $indexBiblio = 0;
273 my @arrBibliosAux = split(',', $arrParamsBusc{'listBiblios'});
274 for (@arrBibliosAux) {
275 last if ($_ == $biblionumber);
276 $indexBiblio++;
278 $indexBiblio += $offset;
279 $offset = int($indexBiblio / $count) * $count;
280 $arrParamsBusc{'offset'} = $offset;
282 $arrParamsBusc{'count'} = $count;
283 $results_per_page = $count;
284 my $newresultsRef = searchAgain(\%arrParamsBusc, $offset, $results_per_page);
285 $arrParamsBusc{'listBiblios'} = buildListBiblios($newresultsRef, $results_per_page);
286 delete $arrParamsBusc{'previous'} if (exists($arrParamsBusc{'previous'}));
287 delete $arrParamsBusc{'next'} if (exists($arrParamsBusc{'next'}));
288 delete $arrParamsBusc{'offsetSearch'} if (exists($arrParamsBusc{'offsetSearch'}));
289 delete $arrParamsBusc{'newlistBiblios'} if (exists($arrParamsBusc{'newlistBiblios'}));
290 my $newbusc = rebuildBuscParam(\%arrParamsBusc);
291 $session->param("busc" => $newbusc);
292 @arrBusc = split(/\&(?:amp;)?/, $newbusc);
293 } else {
294 my $modifyListBiblios = 0;
295 # We come from a previous click
296 if (exists($arrParamsBusc{'previous'})) {
297 $modifyListBiblios = 1 if ($biblionumber == $arrParamsBusc{'previous'});
298 delete $arrParamsBusc{'previous'};
299 } elsif (exists($arrParamsBusc{'next'})) { # We come from a next click
300 $modifyListBiblios = 2 if ($biblionumber == $arrParamsBusc{'next'});
301 delete $arrParamsBusc{'next'};
303 if ($modifyListBiblios) {
304 if (exists($arrParamsBusc{'newlistBiblios'})) {
305 my $listBibliosAux = $arrParamsBusc{'listBiblios'};
306 $arrParamsBusc{'listBiblios'} = $arrParamsBusc{'newlistBiblios'};
307 my @arrAux = split(',', $listBibliosAux);
308 $arrParamsBusc{'newlistBiblios'} = $listBibliosAux;
309 if ($modifyListBiblios == 1) {
310 $arrParamsBusc{'next'} = $arrAux[0];
311 $paging{'next'}->{biblionumber} = $arrAux[0];
312 }else {
313 $arrParamsBusc{'previous'} = $arrAux[$#arrAux];
314 $paging{'previous'}->{biblionumber} = $arrAux[$#arrAux];
316 } else {
317 delete $arrParamsBusc{'listBiblios'};
319 my $offsetAux = $arrParamsBusc{'offset'};
320 $arrParamsBusc{'offset'} = $arrParamsBusc{'offsetSearch'};
321 $arrParamsBusc{'offsetSearch'} = $offsetAux;
322 $offset = $arrParamsBusc{'offset'};
323 my $newbusc = rebuildBuscParam(\%arrParamsBusc);
324 $session->param("busc" => $newbusc);
325 @arrBusc = split(/\&(?:amp;)?/, $newbusc);
328 my $buscParam = '';
329 my $j = 0;
330 # Rebuild the query for the button "back to results"
331 for (@arrBusc) {
332 unless ($_ =~ /^(?:query|listBiblios|newlistBiblios|query_type|simple_query|next|previous|total|count|offsetSearch)/) {
333 $buscParam .= '&amp;' unless ($j == 0);
334 $buscParam .= $_; # string already URI encoded
335 $j++;
338 $template->param('busc' => $buscParam);
339 my $offsetSearch;
340 my @arrBiblios;
341 # We are inside the list of biblios and we don't have to search
342 if (exists($arrParamsBusc{'listBiblios'}) && $arrParamsBusc{'listBiblios'} =~ /^[0-9]+(?:,[0-9]+)*$/) {
343 @arrBiblios = split(',', $arrParamsBusc{'listBiblios'});
344 if (@arrBiblios) {
345 # We are at the first item of the list
346 if ($arrBiblios[0] == $biblionumber) {
347 if (@arrBiblios > 1) {
348 for (my $j = 1; $j < @arrBiblios; $j++) {
349 next unless ($arrBiblios[$j]);
350 $paging{'next'}->{biblionumber} = $arrBiblios[$j];
351 last;
354 # search again if we are not at the first searching list
355 if ($offset && !$arrParamsBusc{'previous'}) {
356 $searchAgain = 1;
357 $offsetSearch = $offset - $results_per_page;
359 # we are at the last item of the list
360 } elsif ($arrBiblios[$#arrBiblios] == $biblionumber) {
361 for (my $j = $#arrBiblios - 1; $j >= 0; $j--) {
362 next unless ($arrBiblios[$j]);
363 $paging{'previous'}->{biblionumber} = $arrBiblios[$j];
364 last;
366 if (!$offset) {
367 # search again if we are at the first list and there is more results
368 $searchAgain = 1 if (!$arrParamsBusc{'next'} && $arrParamsBusc{'total'} != @arrBiblios);
369 } else {
370 # search again if we aren't at the first list and there is more results
371 $searchAgain = 1 if (!$arrParamsBusc{'next'} && $arrParamsBusc{'total'} > ($offset + @arrBiblios));
373 $offsetSearch = $offset + $results_per_page if ($searchAgain);
374 } else {
375 for (my $j = 1; $j < $#arrBiblios; $j++) {
376 if ($arrBiblios[$j] == $biblionumber) {
377 for (my $z = $j - 1; $z >= 0; $z--) {
378 next unless ($arrBiblios[$z]);
379 $paging{'previous'}->{biblionumber} = $arrBiblios[$z];
380 last;
382 for (my $z = $j + 1; $z < @arrBiblios; $z++) {
383 next unless ($arrBiblios[$z]);
384 $paging{'next'}->{biblionumber} = $arrBiblios[$z];
385 last;
387 last;
392 $offsetSearch = 0 if (defined($offsetSearch) && $offsetSearch < 0);
394 if ($searchAgain) {
395 my $newresultsRef = searchAgain(\%arrParamsBusc, $offsetSearch, $results_per_page);
396 my @newresults = @$newresultsRef;
397 # build the new listBiblios
398 my $listBiblios = buildListBiblios(\@newresults, $results_per_page);
399 unless (exists($arrParamsBusc{'listBiblios'})) {
400 $arrParamsBusc{'listBiblios'} = $listBiblios;
401 @arrBiblios = split(',', $arrParamsBusc{'listBiblios'});
402 } else {
403 $arrParamsBusc{'newlistBiblios'} = $listBiblios;
405 # From the new list we build again the next and previous result
406 if (@arrBiblios) {
407 if ($arrBiblios[0] == $biblionumber) {
408 for (my $j = $#newresults; $j >= 0; $j--) {
409 next unless ($newresults[$j]);
410 $paging{'previous'}->{biblionumber} = $newresults[$j]->{biblionumber};
411 $arrParamsBusc{'previous'} = $paging{'previous'}->{biblionumber};
412 $arrParamsBusc{'offsetSearch'} = $offsetSearch;
413 last;
415 } elsif ($arrBiblios[$#arrBiblios] == $biblionumber) {
416 for (my $j = 0; $j < @newresults; $j++) {
417 next unless ($newresults[$j]);
418 $paging{'next'}->{biblionumber} = $newresults[$j]->{biblionumber};
419 $arrParamsBusc{'next'} = $paging{'next'}->{biblionumber};
420 $arrParamsBusc{'offsetSearch'} = $offsetSearch;
421 last;
425 # build new busc param
426 my $newbusc = rebuildBuscParam(\%arrParamsBusc);
427 $session->param("busc" => $newbusc);
429 my ($numberBiblioPaging, $dataBiblioPaging);
430 # Previous biblio
431 $numberBiblioPaging = $paging{'previous'}->{biblionumber};
432 if ($numberBiblioPaging) {
433 $template->param( 'previousBiblionumber' => $numberBiblioPaging );
434 $dataBiblioPaging = GetBiblioData($numberBiblioPaging);
435 $template->param('previousTitle' => $dataBiblioPaging->{'title'}) if ($dataBiblioPaging);
437 # Next biblio
438 $numberBiblioPaging = $paging{'next'}->{biblionumber};
439 if ($numberBiblioPaging) {
440 $template->param( 'nextBiblionumber' => $numberBiblioPaging );
441 $dataBiblioPaging = GetBiblioData($numberBiblioPaging);
442 $template->param('nextTitle' => $dataBiblioPaging->{'title'}) if ($dataBiblioPaging);
444 # Partial list of biblio results
445 my @listResults;
446 for (my $j = 0; $j < @arrBiblios; $j++) {
447 next unless ($arrBiblios[$j]);
448 $dataBiblioPaging = GetBiblioData($arrBiblios[$j]) if ($arrBiblios[$j] != $biblionumber);
449 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]};
451 $template->param('listResults' => \@listResults) if (@listResults);
452 $template->param('indexPag' => 1 + $offset, 'totalPag' => $arrParamsBusc{'total'}, 'indexPagEnd' => scalar(@arrBiblios) + $offset);
457 $template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
458 $template->param('OPACShowCheckoutName' => C4::Context->preference("OPACShowCheckoutName") );
459 $template->param('OPACShowBarcode' => C4::Context->preference("OPACShowBarcode") );
461 # adding items linked via host biblios
463 my $analyticfield = '773';
464 if ($marcflavour eq 'MARC21' || $marcflavour eq 'NORMARC'){
465 $analyticfield = '773';
466 } elsif ($marcflavour eq 'UNIMARC') {
467 $analyticfield = '461';
469 foreach my $hostfield ( $record->field($analyticfield)) {
470 my $hostbiblionumber = $hostfield->subfield("0");
471 my $linkeditemnumber = $hostfield->subfield("9");
472 my @hostitemInfos = GetItemsInfo($hostbiblionumber);
473 foreach my $hostitemInfo (@hostitemInfos){
474 if ($hostitemInfo->{itemnumber} eq $linkeditemnumber){
475 push(@all_items, $hostitemInfo);
480 my @items;
482 # Are there items to hide?
483 my $hideitems;
484 $hideitems = 1 if C4::Context->preference('hidelostitems') or scalar(@hiddenitems) > 0;
486 # Hide items
487 if ($hideitems) {
488 for my $itm (@all_items) {
489 if ( C4::Context->preference('hidelostitems') ) {
490 push @items, $itm unless $itm->{itemlost} or any { $itm->{'itemnumber'} eq $_ } @hiddenitems;
491 } else {
492 push @items, $itm unless any { $itm->{'itemnumber'} eq $_ } @hiddenitems;
495 } else {
496 # Or not
497 @items = @all_items;
500 my $branch = '';
501 if (C4::Context->userenv){
502 $branch = C4::Context->userenv->{branch};
504 if ( C4::Context->preference('HighlightOwnItemsOnOPAC') ) {
505 if (
506 ( ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) && $branch )
508 C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch'
510 my $branchcode;
511 if ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) {
512 $branchcode = $branch;
514 elsif ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch' ) {
515 $branchcode = $ENV{'BRANCHCODE'};
518 my @our_items;
519 my @other_items;
521 foreach my $item ( @items ) {
522 if ( $item->{branchcode} eq $branchcode ) {
523 $item->{'this_branch'} = 1;
524 push( @our_items, $item );
525 } else {
526 push( @other_items, $item );
530 @items = ( @our_items, @other_items );
534 my $dat = &GetBiblioData($biblionumber);
535 my $HideMARC = $record_processor->filters->[0]->should_hide_marc(
537 frameworkcode => $dat->{'frameworkcode'},
538 interface => 'opac',
539 } );
541 my $itemtypes = GetItemTypes();
542 # imageurl:
543 my $itemtype = $dat->{'itemtype'};
544 if ( $itemtype ) {
545 $dat->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} );
546 $dat->{'description'} = $itemtypes->{$itemtype}->{translated_description};
549 my $shelflocations =
550 { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.location' } ) };
551 my $collections =
552 { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.ccode' } ) };
553 my $copynumbers =
554 { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.copynumber' } ) };
556 #coping with subscriptions
557 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
558 my @subscriptions = SearchSubscriptions({ biblionumber => $biblionumber, orderby => 'title' });
560 my @subs;
561 $dat->{'serial'}=1 if $subscriptionsnumber;
562 foreach my $subscription (@subscriptions) {
563 my $serials_to_display;
564 my %cell;
565 $cell{subscriptionid} = $subscription->{subscriptionid};
566 $cell{subscriptionnotes} = $subscription->{notes};
567 $cell{missinglist} = $subscription->{missinglist};
568 $cell{opacnote} = $subscription->{opacnote};
569 $cell{histstartdate} = $subscription->{histstartdate};
570 $cell{histenddate} = $subscription->{histenddate};
571 $cell{branchcode} = $subscription->{branchcode};
572 $cell{hasalert} = $subscription->{hasalert};
573 $cell{callnumber} = $subscription->{callnumber};
574 $cell{closed} = $subscription->{closed};
575 #get the three latest serials.
576 $serials_to_display = $subscription->{opacdisplaycount};
577 $serials_to_display = C4::Context->preference('OPACSerialIssueDisplayCount') unless $serials_to_display;
578 $cell{opacdisplaycount} = $serials_to_display;
579 $cell{latestserials} =
580 GetLatestSerials( $subscription->{subscriptionid}, $serials_to_display );
581 push @subs, \%cell;
584 $dat->{'count'} = scalar(@items);
587 my (%item_reserves, %priority);
588 my ($show_holds_count, $show_priority);
589 for ( C4::Context->preference("OPACShowHoldQueueDetails") ) {
590 m/holds/o and $show_holds_count = 1;
591 m/priority/ and $show_priority = 1;
593 my $has_hold;
594 if ( $show_holds_count || $show_priority) {
595 my $biblio = Koha::Biblios->find( $biblionumber );
596 my $holds = $biblio->holds;
597 $template->param( holds_count => $holds->count );
598 while ( my $hold = $holds->next ) {
599 $item_reserves{ $hold->itemnumber }++ if $hold->itemnumber;
600 if ($show_priority && $hold->borrowernumber == $borrowernumber) {
601 $has_hold = 1;
602 $hold->itemnumber
603 ? ($priority{ $hold->itemnumber } = $hold->priority)
604 : ($template->param( priority => $hold->priority ));
608 $template->param( show_priority => $has_hold ) ;
610 my $norequests = 1;
611 my %itemfields;
612 my (@itemloop, @otheritemloop);
613 my $currentbranch = C4::Context->userenv ? C4::Context->userenv->{branch} : undef;
614 if ($currentbranch and C4::Context->preference('OpacSeparateHoldings')) {
615 $template->param(SeparateHoldings => 1);
617 my $separatebranch = C4::Context->preference('OpacSeparateHoldingsBranch');
618 my $viewallitems = $query->param('viewallitems');
619 my $max_items_to_display = C4::Context->preference('OpacMaxItemsToDisplay') // 50;
621 # Get items on order
622 my ( @itemnumbers_on_order );
623 if ( C4::Context->preference('OPACAcquisitionDetails' ) ) {
624 my $orders = C4::Acquisition::SearchOrders({
625 biblionumber => $biblionumber,
626 ordered => 1,
628 my $total_quantity = 0;
629 for my $order ( @$orders ) {
630 if ( C4::Context->preference('AcqCreateItem') eq 'ordering' ) {
631 for my $itemnumber ( C4::Acquisition::GetItemnumbersFromOrder( $order->{ordernumber} ) ) {
632 push @itemnumbers_on_order, $itemnumber;
635 $total_quantity += $order->{quantity};
637 $template->{VARS}->{acquisition_details} = {
638 total_quantity => $total_quantity,
642 if ( not $viewallitems and @items > $max_items_to_display ) {
643 $template->param(
644 too_many_items => 1,
645 items_count => scalar( @items ),
647 } else {
648 my $allow_onshelf_holds;
649 my $borrower = GetMember( 'borrowernumber' => $borrowernumber );
650 for my $itm (@items) {
651 $itm->{holds_count} = $item_reserves{ $itm->{itemnumber} };
652 $itm->{priority} = $priority{ $itm->{itemnumber} };
653 $norequests = 0
654 if $norequests
655 && !$itm->{'withdrawn'}
656 && !$itm->{'itemlost'}
657 && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'})
658 && !$itemtypes->{$itm->{'itype'}}->{notforloan}
659 && $itm->{'itemnumber'};
661 $allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed( $itm, $borrower )
662 unless $allow_onshelf_holds;
664 # get collection code description, too
665 my $ccode = $itm->{'ccode'};
666 $itm->{'ccode'} = $collections->{$ccode} if defined($ccode) && $collections && exists( $collections->{$ccode} );
667 my $copynumber = $itm->{'copynumber'};
668 $itm->{'copynumber'} = $copynumbers->{$copynumber} if ( defined($copynumbers) && defined($copynumber) && exists( $copynumbers->{$copynumber} ) );
669 if ( defined $itm->{'location'} ) {
670 $itm->{'location_description'} = $shelflocations->{ $itm->{'location'} };
672 if (exists $itm->{itype} && defined($itm->{itype}) && exists $itemtypes->{ $itm->{itype} }) {
673 $itm->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{ $itm->{itype} }->{'imageurl'} );
674 $itm->{'description'} = $itemtypes->{ $itm->{itype} }->{translated_description};
676 foreach (qw(ccode enumchron copynumber itemnotes uri)) {
677 $itemfields{$_} = 1 if ($itm->{$_});
680 my $reserve_status = C4::Reserves::GetReserveStatus($itm->{itemnumber});
681 if( $reserve_status eq "Waiting"){ $itm->{'waiting'} = 1; }
682 if( $reserve_status eq "Reserved"){ $itm->{'onhold'} = 1; }
684 my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($itm->{itemnumber});
685 if ( defined( $transfertwhen ) && $transfertwhen ne '' ) {
686 $itm->{transfertwhen} = $transfertwhen;
687 $itm->{transfertfrom} = $transfertfrom;
688 $itm->{transfertto} = $transfertto;
691 if ( C4::Context->preference('OPACAcquisitionDetails')
692 and C4::Context->preference('AcqCreateItem') eq 'ordering' )
694 $itm->{on_order} = 1
695 if grep /^$itm->{itemnumber}$/, @itemnumbers_on_order;
698 my $itembranch = $itm->{$separatebranch};
699 if ($currentbranch and C4::Context->preference('OpacSeparateHoldings')) {
700 if ($itembranch and $itembranch eq $currentbranch) {
701 push @itemloop, $itm;
702 } else {
703 push @otheritemloop, $itm;
705 } else {
706 push @itemloop, $itm;
709 $template->param( 'AllowOnShelfHolds' => $allow_onshelf_holds );
712 # Display only one tab if one items list is empty
713 if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) {
714 $template->param(SeparateHoldings => 0);
715 if (scalar(@itemloop) == 0) {
716 @itemloop = @otheritemloop;
720 ## get notes and subjects from MARC record
721 if (!C4::Context->preference("OPACXSLTDetailsDisplay") ) {
722 my $marcisbnsarray = GetMarcISBN ($record,$marcflavour);
723 my $marcauthorsarray = GetMarcAuthors ($record,$marcflavour);
724 my $marcsubjctsarray = GetMarcSubjects($record,$marcflavour);
725 my $marcseriesarray = GetMarcSeries ($record,$marcflavour);
726 my $marcurlsarray = GetMarcUrls ($record,$marcflavour);
727 my $marchostsarray = GetMarcHosts($record,$marcflavour);
729 $template->param(
730 MARCSUBJCTS => $marcsubjctsarray,
731 MARCAUTHORS => $marcauthorsarray,
732 MARCSERIES => $marcseriesarray,
733 MARCURLS => $marcurlsarray,
734 MARCISBNS => $marcisbnsarray,
735 MARCHOSTS => $marchostsarray,
739 my $marcnotesarray = GetMarcNotes ($record,$marcflavour);
740 my $subtitle = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber));
742 $template->param(
743 MARCNOTES => $marcnotesarray,
744 norequests => $norequests,
745 RequestOnOpac => C4::Context->preference("RequestOnOpac"),
746 itemdata_ccode => $itemfields{ccode},
747 itemdata_enumchron => $itemfields{enumchron},
748 itemdata_uri => $itemfields{uri},
749 itemdata_copynumber => $itemfields{copynumber},
750 itemdata_itemnotes => $itemfields{itemnotes},
751 subtitle => $subtitle,
752 OpacStarRatings => C4::Context->preference("OpacStarRatings"),
755 if (C4::Context->preference("AlternateHoldingsField") && scalar @items == 0) {
756 my $fieldspec = C4::Context->preference("AlternateHoldingsField");
757 my $subfields = substr $fieldspec, 3;
758 my $holdingsep = C4::Context->preference("AlternateHoldingsSeparator") || ' ';
759 my @alternateholdingsinfo = ();
760 my @holdingsfields = $record->field(substr $fieldspec, 0, 3);
762 for my $field (@holdingsfields) {
763 my %holding = ( holding => '' );
764 my $havesubfield = 0;
765 for my $subfield ($field->subfields()) {
766 if ((index $subfields, $$subfield[0]) >= 0) {
767 $holding{'holding'} .= $holdingsep if (length $holding{'holding'} > 0);
768 $holding{'holding'} .= $$subfield[1];
769 $havesubfield++;
772 if ($havesubfield) {
773 push(@alternateholdingsinfo, \%holding);
777 $template->param(
778 ALTERNATEHOLDINGS => \@alternateholdingsinfo,
782 # FIXME: The template uses this hash directly. Need to filter.
783 foreach ( keys %{$dat} ) {
784 next if ( $HideMARC->{$_} );
785 $template->param( "$_" => defined $dat->{$_} ? $dat->{$_} : '' );
788 # some useful variables for enhanced content;
789 # in each case, we're grabbing the first value we find in
790 # the record and normalizing it
791 my $upc = GetNormalizedUPC($record,$marcflavour);
792 my $oclc = GetNormalizedOCLCNumber($record,$marcflavour);
793 my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
794 my $content_identifier_exists;
795 if ( $isbn or $ean or $oclc or $upc ) {
796 $content_identifier_exists = 1;
798 $template->param(
799 normalized_upc => $upc,
800 normalized_ean => $ean,
801 normalized_oclc => $oclc,
802 normalized_isbn => $isbn,
803 content_identifier_exists => $content_identifier_exists,
806 # COinS format FIXME: for books Only
807 $template->param(
808 ocoins => GetCOinSBiblio($record),
811 my ( $loggedincommenter, $reviews );
812 if ( C4::Context->preference('reviewson') ) {
813 $reviews = Koha::Reviews->search(
815 biblionumber => $biblionumber,
816 -or => { approved => 1, borrowernumber => $borrowernumber }
819 order_by => { -desc => 'datereviewed' }
821 )->unblessed;
822 my $libravatar_enabled = 0;
823 if ( C4::Context->preference('ShowReviewer') and C4::Context->preference('ShowReviewerPhoto') ) {
824 eval {
825 require Libravatar::URL;
826 Libravatar::URL->import();
828 if ( !$@ ) {
829 $libravatar_enabled = 1;
832 for my $review (@$reviews) {
833 my $borrowerData = GetMember( 'borrowernumber' => $review->{borrowernumber} );
835 # setting some borrower info into this hash
836 $review->{title} = $borrowerData->{'title'};
837 $review->{surname} = $borrowerData->{'surname'};
838 $review->{firstname} = $borrowerData->{'firstname'};
839 if ( $libravatar_enabled and $borrowerData->{'email'} ) {
840 $review->{avatarurl} = libravatar_url( email => $borrowerData->{'email'}, https => $ENV{HTTPS} );
842 $review->{userid} = $borrowerData->{'userid'};
843 $review->{cardnumber} = $borrowerData->{'cardnumber'};
845 if ( $borrowerData->{'borrowernumber'} eq $borrowernumber ) {
846 $review->{your_comment} = 1;
847 $loggedincommenter = 1;
852 if ( C4::Context->preference("OPACISBD") ) {
853 $template->param( ISBD => 1 );
856 $template->param(
857 itemloop => \@itemloop,
858 otheritemloop => \@otheritemloop,
859 biblionumber => $biblionumber,
860 subscriptions => \@subs,
861 subscriptionsnumber => $subscriptionsnumber,
862 reviews => $reviews,
863 loggedincommenter => $loggedincommenter
866 # Lists
867 if (C4::Context->preference("virtualshelves") ) {
868 my $shelves = Koha::Virtualshelves->search(
870 biblionumber => $biblionumber,
871 category => 2,
874 join => 'virtualshelfcontents',
877 $template->param( shelves => $shelves );
880 # XISBN Stuff
881 if (C4::Context->preference("OPACFRBRizeEditions")==1) {
882 eval {
883 $template->param(
884 XISBNS => get_xisbns($isbn)
887 if ($@) { warn "XISBN Failed $@"; }
890 # Serial Collection
891 my @sc_fields = $record->field(955);
892 my @lc_fields = $marcflavour eq 'UNIMARC'
893 ? $record->field(930)
894 : $record->field(852);
895 my @serialcollections = ();
897 foreach my $sc_field (@sc_fields) {
898 my %row_data;
900 $row_data{text} = $sc_field->subfield('r');
901 $row_data{branch} = $sc_field->subfield('9');
902 foreach my $lc_field (@lc_fields) {
903 $row_data{itemcallnumber} = $marcflavour eq 'UNIMARC'
904 ? $lc_field->subfield('a') # 930$a
905 : $lc_field->subfield('h') # 852$h
906 if ($sc_field->subfield('5') eq $lc_field->subfield('5'));
909 if ($row_data{text} && $row_data{branch}) {
910 push (@serialcollections, \%row_data);
914 if (scalar(@serialcollections) > 0) {
915 $template->param(
916 serialcollection => 1,
917 serialcollections => \@serialcollections);
920 # Local cover Images stuff
921 if (C4::Context->preference("OPACLocalCoverImages")){
922 $template->param(OPACLocalCoverImages => 1);
925 # HTML5 Media
926 if ( (C4::Context->preference("HTML5MediaEnabled") eq 'both') or (C4::Context->preference("HTML5MediaEnabled") eq 'opac') ) {
927 $template->param( C4::HTML5Media->gethtml5media($record));
930 my $syndetics_elements;
932 if ( C4::Context->preference("SyndeticsEnabled") ) {
933 $template->param("SyndeticsEnabled" => 1);
934 $template->param("SyndeticsClientCode" => C4::Context->preference("SyndeticsClientCode"));
935 eval {
936 $syndetics_elements = &get_syndetics_index($isbn,$upc,$oclc);
937 for my $element (values %$syndetics_elements) {
938 $template->param("Syndetics$element"."Exists" => 1 );
939 #warn "Exists: "."Syndetics$element"."Exists";
942 warn $@ if $@;
945 if ( C4::Context->preference("SyndeticsEnabled")
946 && C4::Context->preference("SyndeticsSummary")
947 && ( exists($syndetics_elements->{'SUMMARY'}) || exists($syndetics_elements->{'AVSUMMARY'}) ) ) {
948 eval {
949 my $syndetics_summary = &get_syndetics_summary($isbn,$upc,$oclc, $syndetics_elements);
950 $template->param( SYNDETICS_SUMMARY => $syndetics_summary );
952 warn $@ if $@;
956 if ( C4::Context->preference("SyndeticsEnabled")
957 && C4::Context->preference("SyndeticsTOC")
958 && exists($syndetics_elements->{'TOC'}) ) {
959 eval {
960 my $syndetics_toc = &get_syndetics_toc($isbn,$upc,$oclc);
961 $template->param( SYNDETICS_TOC => $syndetics_toc );
963 warn $@ if $@;
966 if ( C4::Context->preference("SyndeticsEnabled")
967 && C4::Context->preference("SyndeticsExcerpt")
968 && exists($syndetics_elements->{'DBCHAPTER'}) ) {
969 eval {
970 my $syndetics_excerpt = &get_syndetics_excerpt($isbn,$upc,$oclc);
971 $template->param( SYNDETICS_EXCERPT => $syndetics_excerpt );
973 warn $@ if $@;
976 if ( C4::Context->preference("SyndeticsEnabled")
977 && C4::Context->preference("SyndeticsReviews")) {
978 eval {
979 my $syndetics_reviews = &get_syndetics_reviews($isbn,$upc,$oclc,$syndetics_elements);
980 $template->param( SYNDETICS_REVIEWS => $syndetics_reviews );
982 warn $@ if $@;
985 if ( C4::Context->preference("SyndeticsEnabled")
986 && C4::Context->preference("SyndeticsAuthorNotes")
987 && exists($syndetics_elements->{'ANOTES'}) ) {
988 eval {
989 my $syndetics_anotes = &get_syndetics_anotes($isbn,$upc,$oclc);
990 $template->param( SYNDETICS_ANOTES => $syndetics_anotes );
992 warn $@ if $@;
995 # LibraryThingForLibraries ID Code and Tabbed View Option
996 if( C4::Context->preference('LibraryThingForLibrariesEnabled') )
998 $template->param(LibraryThingForLibrariesID =>
999 C4::Context->preference('LibraryThingForLibrariesID') );
1000 $template->param(LibraryThingForLibrariesTabbedView =>
1001 C4::Context->preference('LibraryThingForLibrariesTabbedView') );
1004 # Novelist Select
1005 if( C4::Context->preference('NovelistSelectEnabled') )
1007 $template->param(NovelistSelectProfile => C4::Context->preference('NovelistSelectProfile') );
1008 $template->param(NovelistSelectPassword => C4::Context->preference('NovelistSelectPassword') );
1009 $template->param(NovelistSelectView => C4::Context->preference('NovelistSelectView') );
1013 # Babelthèque
1014 if ( C4::Context->preference("Babeltheque") ) {
1015 $template->param(
1016 Babeltheque => 1,
1017 Babeltheque_url_js => C4::Context->preference("Babeltheque_url_js"),
1021 # Social Networks
1022 if ( C4::Context->preference( "SocialNetworks" ) ) {
1023 $template->param( current_url => C4::Context->preference('OPACBaseURL') . "/cgi-bin/koha/opac-detail.pl?biblionumber=$biblionumber" );
1024 $template->param( SocialNetworks => 1 );
1027 # Shelf Browser Stuff
1028 if (C4::Context->preference("OPACShelfBrowser")) {
1029 my $starting_itemnumber = $query->param('shelfbrowse_itemnumber');
1030 if (defined($starting_itemnumber)) {
1031 $template->param( OpenOPACShelfBrowser => 1) if $starting_itemnumber;
1032 my $nearby = GetNearbyItems($starting_itemnumber);
1034 $template->param(
1035 starting_itemnumber => $starting_itemnumber,
1036 starting_homebranch => $nearby->{starting_homebranch}->{description},
1037 starting_location => $nearby->{starting_location}->{description},
1038 starting_ccode => $nearby->{starting_ccode}->{description},
1039 shelfbrowser_prev_item => $nearby->{prev_item},
1040 shelfbrowser_next_item => $nearby->{next_item},
1041 shelfbrowser_items => $nearby->{items},
1044 # in which tab shelf browser should open ?
1045 if (grep { $starting_itemnumber == $_->{itemnumber} } @itemloop) {
1046 $template->param(shelfbrowser_tab => 'holdings');
1047 } else {
1048 $template->param(shelfbrowser_tab => 'otherholdings');
1053 $template->param( AmazonTld => get_amazon_tld() ) if ( C4::Context->preference("OPACAmazonCoverImages"));
1055 if (C4::Context->preference("BakerTaylorEnabled")) {
1056 $template->param(
1057 BakerTaylorEnabled => 1,
1058 BakerTaylorImageURL => &image_url(),
1059 BakerTaylorLinkURL => &link_url(),
1060 BakerTaylorBookstoreURL => C4::Context->preference('BakerTaylorBookstoreURL'),
1062 my ($bt_user, $bt_pass);
1063 if ($isbn and
1064 $bt_user = C4::Context->preference('BakerTaylorUsername') and
1065 $bt_pass = C4::Context->preference('BakerTaylorPassword') )
1067 $template->param(
1068 BakerTaylorContentURL =>
1069 sprintf("http://contentcafe2.btol.com/ContentCafeClient/ContentCafe.aspx?UserID=%s&Password=%s&ItemKey=%s&Options=Y",
1070 $bt_user,$bt_pass,$isbn)
1075 my $tag_quantity;
1076 if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->preference('TagsShowOnDetail')) {
1077 $template->param(
1078 TagsEnabled => 1,
1079 TagsShowOnDetail => $tag_quantity,
1080 TagsInputOnDetail => C4::Context->preference('TagsInputOnDetail')
1082 $template->param(TagLoop => get_tags({biblionumber=>$biblionumber, approved=>1,
1083 'sort'=>'-weight', limit=>$tag_quantity}));
1086 if (C4::Context->preference("OPACURLOpenInNewWindow")) {
1087 # These values are going to be read by Javascript, at least in the case
1088 # of the google covers
1089 $template->param(covernewwindow => 'true');
1090 } else {
1091 $template->param(covernewwindow => 'false');
1094 if ( C4::Context->preference('OpacStarRatings') !~ /disable/ ) {
1095 my $ratings = Koha::Ratings->search({ biblionumber => $biblionumber });
1096 my $my_rating = $borrowernumber ? $ratings->search({ borrowernumber => $borrowernumber })->next : undef;
1097 $template->param(
1098 ratings => $ratings,
1099 my_rating => $my_rating,
1100 borrowernumber => $borrowernumber
1104 #Search for title in links
1105 my $marccontrolnumber = GetMarcControlnumber ($record, $marcflavour);
1106 my $marcissns = GetMarcISSN ( $record, $marcflavour );
1107 my $issn = $marcissns->[0] || '';
1109 if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
1110 $dat->{title} =~ s/\/+$//; # remove trailing slash
1111 $dat->{title} =~ s/\s+$//; # remove trailing space
1112 $search_for_title = parametrized_url(
1113 $search_for_title,
1115 TITLE => $dat->{title},
1116 AUTHOR => $dat->{author},
1117 ISBN => $isbn,
1118 ISSN => $issn,
1119 CONTROLNUMBER => $marccontrolnumber,
1120 BIBLIONUMBER => $biblionumber,
1123 $template->param('OPACSearchForTitleIn' => $search_for_title);
1126 #IDREF
1127 if ( C4::Context->preference("IDREF") ) {
1128 # If the record comes from the SUDOC
1129 if ( $record->field('009') ) {
1130 my $unimarc3 = $record->field("009")->data;
1131 if ( $unimarc3 =~ /^\d+$/ ) {
1132 $template->param(
1133 IDREF => 1,
1139 # We try to select the best default tab to show, according to what
1140 # the user wants, and what's available for display
1141 my $opac_serial_default = C4::Context->preference('opacSerialDefaultTab');
1142 my $defaulttab =
1143 $viewallitems
1144 ? 'holdings' :
1145 $opac_serial_default eq 'subscriptions' && $subscriptionsnumber
1146 ? 'subscriptions' :
1147 $opac_serial_default eq 'serialcollection' && @serialcollections > 0
1148 ? 'serialcollection' :
1149 $opac_serial_default eq 'holdings' && scalar (@itemloop) > 0
1150 ? 'holdings' :
1151 scalar (@itemloop) == 0
1152 ? 'media' :
1153 $subscriptionsnumber
1154 ? 'subscriptions' :
1155 @serialcollections > 0
1156 ? 'serialcollection' : 'subscriptions';
1157 $template->param('defaulttab' => $defaulttab);
1159 if (C4::Context->preference('OPACLocalCoverImages') == 1) {
1160 my @images = ListImagesForBiblio($biblionumber);
1161 $template->{VARS}->{localimages} = \@images;
1164 $template->{VARS}->{IDreamBooksReviews} = C4::Context->preference('IDreamBooksReviews');
1165 $template->{VARS}->{IDreamBooksReadometer} = C4::Context->preference('IDreamBooksReadometer');
1166 $template->{VARS}->{IDreamBooksResults} = C4::Context->preference('IDreamBooksResults');
1167 $template->{VARS}->{OPACPopupAuthorsSearch} = C4::Context->preference('OPACPopupAuthorsSearch');
1169 if (C4::Context->preference('OpacHighlightedWords')) {
1170 $template->{VARS}->{query_desc} = $query->param('query_desc');
1172 $template->{VARS}->{'trackclicks'} = C4::Context->preference('TrackClicks');
1174 if ( C4::Context->preference('UseCourseReserves') ) {
1175 foreach my $i ( @items ) {
1176 $i->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $i->{'itemnumber'} );
1180 $template->param(
1181 'OpacLocationBranchToDisplay' => C4::Context->preference('OpacLocationBranchToDisplay') ,
1182 'OpacLocationBranchToDisplayShelving' => C4::Context->preference('OpacLocationBranchToDisplayShelving'),
1185 output_html_with_http_headers $query, $cookie, $template->output;