Bug 11217: The # in accountlines descriptions makes them un-writeoffable
[koha.git] / opac / opac-detail.pl
blob6a68a528736bb0c8b2649666a5afd0ebae33c829
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::Virtualshelves;
52 use Koha::Ratings;
53 use Koha::Reviews;
55 BEGIN {
56 if (C4::Context->preference('BakerTaylorEnabled')) {
57 require C4::External::BakerTaylor;
58 import C4::External::BakerTaylor qw(&image_url &link_url);
62 my $query = new CGI;
63 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
65 template_name => "opac-detail.tt",
66 query => $query,
67 type => "opac",
68 authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
72 my $biblionumber = $query->param('biblionumber') || $query->param('bib') || 0;
73 $biblionumber = int($biblionumber);
75 my @all_items = GetItemsInfo($biblionumber);
76 my @hiddenitems;
77 if (scalar @all_items >= 1) {
78 push @hiddenitems, GetHiddenItemnumbers(@all_items);
80 if (scalar @hiddenitems == scalar @all_items ) {
81 print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
82 exit;
86 my $record = GetMarcBiblio($biblionumber);
87 if ( ! $record ) {
88 print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
89 exit;
91 my $framework = &GetFrameworkCode( $biblionumber );
92 my $record_processor = Koha::RecordProcessor->new({
93 filters => 'ViewPolicy',
94 options => {
95 interface => 'opac',
96 frameworkcode => $framework
98 });
99 $record_processor->process($record);
101 # redirect if opacsuppression is enabled and biblio is suppressed
102 if (C4::Context->preference('OpacSuppression')) {
103 # FIXME hardcoded; the suppression flag ought to be materialized
104 # as a column on biblio or the like
105 my $opacsuppressionfield = '942';
106 my $opacsuppressionfieldvalue = $record->field($opacsuppressionfield);
107 # redirect to opac-blocked info page or 404?
108 my $opacsuppressionredirect;
109 if ( C4::Context->preference("OpacSuppressionRedirect") ) {
110 $opacsuppressionredirect = "/cgi-bin/koha/opac-blocked.pl";
111 } else {
112 $opacsuppressionredirect = "/cgi-bin/koha/errors/404.pl";
114 if ( $opacsuppressionfieldvalue &&
115 $opacsuppressionfieldvalue->subfield("n") &&
116 $opacsuppressionfieldvalue->subfield("n") == 1) {
117 # if OPAC suppression by IP address
118 if (C4::Context->preference('OpacSuppressionByIPRange')) {
119 my $IPAddress = $ENV{'REMOTE_ADDR'};
120 my $IPRange = C4::Context->preference('OpacSuppressionByIPRange');
121 if ($IPAddress !~ /^$IPRange/) {
122 print $query->redirect($opacsuppressionredirect);
123 exit;
125 } else {
126 print $query->redirect($opacsuppressionredirect);
127 exit;
132 $template->param( biblionumber => $biblionumber );
134 # get biblionumbers stored in the cart
135 my @cart_list;
137 if($query->cookie("bib_list")){
138 my $cart_list = $query->cookie("bib_list");
139 @cart_list = split(/\//, $cart_list);
140 if ( grep {$_ eq $biblionumber} @cart_list) {
141 $template->param( incart => 1 );
146 SetUTF8Flag($record);
147 my $marcflavour = C4::Context->preference("marcflavour");
148 my $ean = GetNormalizedEAN( $record, $marcflavour );
150 # XSLT processing of some stuff
151 my $xslfile = C4::Context->preference('OPACXSLTDetailsDisplay');
152 my $lang = $xslfile ? C4::Languages::getlanguage() : undef;
153 my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef;
155 if ( $xslfile ) {
156 $template->param(
157 XSLTBloc => XSLTParse4Display(
158 $biblionumber, $record, "OPACXSLTDetailsDisplay",
159 1, undef, $sysxml, $xslfile, $lang
164 my $OpacBrowseResults = C4::Context->preference("OpacBrowseResults");
165 $template->{VARS}->{'OpacBrowseResults'} = $OpacBrowseResults;
167 # We look for the busc param to build the simple paging from the search
168 if ($OpacBrowseResults) {
169 my $session = get_session($query->cookie("CGISESSID"));
170 my %paging = (previous => {}, next => {});
171 if ($session->param('busc')) {
172 use C4::Search;
173 use URI::Escape;
175 # Rebuild the string to store on session
176 # param value is URI encoded and params separator is HTML encode (&amp;)
177 sub rebuildBuscParam
179 my $arrParamsBusc = shift;
181 my $pasarParams = '';
182 my $j = 0;
183 for (keys %$arrParamsBusc) {
184 if ($_ =~ /^(?:query|listBiblios|newlistBiblios|query_type|simple_query|total|offset|offsetSearch|next|previous|count|expand|scan)/) {
185 if (defined($arrParamsBusc->{$_})) {
186 $pasarParams .= '&amp;' if ($j);
187 $pasarParams .= $_ . '=' . Encode::decode('UTF-8', uri_escape_utf8( $arrParamsBusc->{$_} ));
188 $j++;
190 } else {
191 for my $value (@{$arrParamsBusc->{$_}}) {
192 $pasarParams .= '&amp;' if ($j);
193 $pasarParams .= $_ . '=' . Encode::decode('UTF-8', uri_escape_utf8($value));
194 $j++;
198 return $pasarParams;
199 }#rebuildBuscParam
201 # Search given the current values from the busc param
202 sub searchAgain
204 my ($arrParamsBusc, $offset, $results_per_page) = @_;
206 my $expanded_facet = $arrParamsBusc->{'expand'};
207 my $itemtypes = GetItemTypes;
208 my @servers;
209 @servers = @{$arrParamsBusc->{'server'}} if $arrParamsBusc->{'server'};
210 @servers = ("biblioserver") unless (@servers);
212 my ($default_sort_by, @sort_by);
213 $default_sort_by = C4::Context->preference('OPACdefaultSortField')."_".C4::Context->preference('OPACdefaultSortOrder') if (C4::Context->preference('OPACdefaultSortField') && C4::Context->preference('OPACdefaultSortOrder'));
214 @sort_by = @{$arrParamsBusc->{'sort_by'}} if $arrParamsBusc->{'sort_by'};
215 $sort_by[0] = $default_sort_by if !$sort_by[0] && defined($default_sort_by);
216 my ($error, $results_hashref, $facets);
217 eval {
218 ($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'});
220 my $hits;
221 my @newresults;
222 for (my $i=0;$i<@servers;$i++) {
223 my $server = $servers[$i];
224 $hits = $results_hashref->{$server}->{"hits"};
225 @newresults = searchResults('opac', '', $hits, $results_per_page, $offset, $arrParamsBusc->{'scan'}, $results_hashref->{$server}->{"RECORDS"});
227 return \@newresults;
228 }#searchAgain
230 # Build the current list of biblionumbers in this search
231 sub buildListBiblios
233 my ($newresultsRef, $results_per_page) = @_;
235 my $listBiblios = '';
236 my $j = 0;
237 foreach (@$newresultsRef) {
238 my $bibnum = ($_->{biblionumber})?$_->{biblionumber}:0;
239 $listBiblios .= $bibnum . ',';
240 $j++;
241 last if ($j == $results_per_page);
243 chop $listBiblios if ($listBiblios =~ /,$/);
244 return $listBiblios;
245 }#buildListBiblios
247 my $busc = $session->param("busc");
248 my @arrBusc = split(/\&(?:amp;)?/, $busc);
249 my ($key, $value);
250 my %arrParamsBusc = ();
251 for (@arrBusc) {
252 ($key, $value) = split(/=/, $_, 2);
253 if ($key =~ /^(?:query|listBiblios|newlistBiblios|query_type|simple_query|next|previous|total|offset|offsetSearch|count|expand|scan)/) {
254 $arrParamsBusc{$key} = uri_unescape($value);
255 } else {
256 unless (exists($arrParamsBusc{$key})) {
257 $arrParamsBusc{$key} = [];
259 push @{$arrParamsBusc{$key}}, uri_unescape($value);
262 my $searchAgain = 0;
263 my $count = C4::Context->preference('OPACnumSearchResults') || 20;
264 my $results_per_page = ($arrParamsBusc{'count'} && $arrParamsBusc{'count'} =~ /^[0-9]+?/)?$arrParamsBusc{'count'}:$count;
265 $arrParamsBusc{'count'} = $results_per_page;
266 my $offset = ($arrParamsBusc{'offset'} && $arrParamsBusc{'offset'} =~ /^[0-9]+?/)?$arrParamsBusc{'offset'}:0;
267 # The value OPACnumSearchResults has changed and the search has to be rebuild
268 if ($count != $results_per_page) {
269 if (exists($arrParamsBusc{'listBiblios'}) && $arrParamsBusc{'listBiblios'} =~ /^[0-9]+(?:,[0-9]+)*$/) {
270 my $indexBiblio = 0;
271 my @arrBibliosAux = split(',', $arrParamsBusc{'listBiblios'});
272 for (@arrBibliosAux) {
273 last if ($_ == $biblionumber);
274 $indexBiblio++;
276 $indexBiblio += $offset;
277 $offset = int($indexBiblio / $count) * $count;
278 $arrParamsBusc{'offset'} = $offset;
280 $arrParamsBusc{'count'} = $count;
281 $results_per_page = $count;
282 my $newresultsRef = searchAgain(\%arrParamsBusc, $offset, $results_per_page);
283 $arrParamsBusc{'listBiblios'} = buildListBiblios($newresultsRef, $results_per_page);
284 delete $arrParamsBusc{'previous'} if (exists($arrParamsBusc{'previous'}));
285 delete $arrParamsBusc{'next'} if (exists($arrParamsBusc{'next'}));
286 delete $arrParamsBusc{'offsetSearch'} if (exists($arrParamsBusc{'offsetSearch'}));
287 delete $arrParamsBusc{'newlistBiblios'} if (exists($arrParamsBusc{'newlistBiblios'}));
288 my $newbusc = rebuildBuscParam(\%arrParamsBusc);
289 $session->param("busc" => $newbusc);
290 @arrBusc = split(/\&(?:amp;)?/, $newbusc);
291 } else {
292 my $modifyListBiblios = 0;
293 # We come from a previous click
294 if (exists($arrParamsBusc{'previous'})) {
295 $modifyListBiblios = 1 if ($biblionumber == $arrParamsBusc{'previous'});
296 delete $arrParamsBusc{'previous'};
297 } elsif (exists($arrParamsBusc{'next'})) { # We come from a next click
298 $modifyListBiblios = 2 if ($biblionumber == $arrParamsBusc{'next'});
299 delete $arrParamsBusc{'next'};
301 if ($modifyListBiblios) {
302 if (exists($arrParamsBusc{'newlistBiblios'})) {
303 my $listBibliosAux = $arrParamsBusc{'listBiblios'};
304 $arrParamsBusc{'listBiblios'} = $arrParamsBusc{'newlistBiblios'};
305 my @arrAux = split(',', $listBibliosAux);
306 $arrParamsBusc{'newlistBiblios'} = $listBibliosAux;
307 if ($modifyListBiblios == 1) {
308 $arrParamsBusc{'next'} = $arrAux[0];
309 $paging{'next'}->{biblionumber} = $arrAux[0];
310 }else {
311 $arrParamsBusc{'previous'} = $arrAux[$#arrAux];
312 $paging{'previous'}->{biblionumber} = $arrAux[$#arrAux];
314 } else {
315 delete $arrParamsBusc{'listBiblios'};
317 my $offsetAux = $arrParamsBusc{'offset'};
318 $arrParamsBusc{'offset'} = $arrParamsBusc{'offsetSearch'};
319 $arrParamsBusc{'offsetSearch'} = $offsetAux;
320 $offset = $arrParamsBusc{'offset'};
321 my $newbusc = rebuildBuscParam(\%arrParamsBusc);
322 $session->param("busc" => $newbusc);
323 @arrBusc = split(/\&(?:amp;)?/, $newbusc);
326 my $buscParam = '';
327 my $j = 0;
328 # Rebuild the query for the button "back to results"
329 for (@arrBusc) {
330 unless ($_ =~ /^(?:query|listBiblios|newlistBiblios|query_type|simple_query|next|previous|total|count|offsetSearch)/) {
331 $buscParam .= '&amp;' unless ($j == 0);
332 $buscParam .= $_; # string already URI encoded
333 $j++;
336 $template->param('busc' => $buscParam);
337 my $offsetSearch;
338 my @arrBiblios;
339 # We are inside the list of biblios and we don't have to search
340 if (exists($arrParamsBusc{'listBiblios'}) && $arrParamsBusc{'listBiblios'} =~ /^[0-9]+(?:,[0-9]+)*$/) {
341 @arrBiblios = split(',', $arrParamsBusc{'listBiblios'});
342 if (@arrBiblios) {
343 # We are at the first item of the list
344 if ($arrBiblios[0] == $biblionumber) {
345 if (@arrBiblios > 1) {
346 for (my $j = 1; $j < @arrBiblios; $j++) {
347 next unless ($arrBiblios[$j]);
348 $paging{'next'}->{biblionumber} = $arrBiblios[$j];
349 last;
352 # search again if we are not at the first searching list
353 if ($offset && !$arrParamsBusc{'previous'}) {
354 $searchAgain = 1;
355 $offsetSearch = $offset - $results_per_page;
357 # we are at the last item of the list
358 } elsif ($arrBiblios[$#arrBiblios] == $biblionumber) {
359 for (my $j = $#arrBiblios - 1; $j >= 0; $j--) {
360 next unless ($arrBiblios[$j]);
361 $paging{'previous'}->{biblionumber} = $arrBiblios[$j];
362 last;
364 if (!$offset) {
365 # search again if we are at the first list and there is more results
366 $searchAgain = 1 if (!$arrParamsBusc{'next'} && $arrParamsBusc{'total'} != @arrBiblios);
367 } else {
368 # search again if we aren't at the first list and there is more results
369 $searchAgain = 1 if (!$arrParamsBusc{'next'} && $arrParamsBusc{'total'} > ($offset + @arrBiblios));
371 $offsetSearch = $offset + $results_per_page if ($searchAgain);
372 } else {
373 for (my $j = 1; $j < $#arrBiblios; $j++) {
374 if ($arrBiblios[$j] == $biblionumber) {
375 for (my $z = $j - 1; $z >= 0; $z--) {
376 next unless ($arrBiblios[$z]);
377 $paging{'previous'}->{biblionumber} = $arrBiblios[$z];
378 last;
380 for (my $z = $j + 1; $z < @arrBiblios; $z++) {
381 next unless ($arrBiblios[$z]);
382 $paging{'next'}->{biblionumber} = $arrBiblios[$z];
383 last;
385 last;
390 $offsetSearch = 0 if (defined($offsetSearch) && $offsetSearch < 0);
392 if ($searchAgain) {
393 my $newresultsRef = searchAgain(\%arrParamsBusc, $offsetSearch, $results_per_page);
394 my @newresults = @$newresultsRef;
395 # build the new listBiblios
396 my $listBiblios = buildListBiblios(\@newresults, $results_per_page);
397 unless (exists($arrParamsBusc{'listBiblios'})) {
398 $arrParamsBusc{'listBiblios'} = $listBiblios;
399 @arrBiblios = split(',', $arrParamsBusc{'listBiblios'});
400 } else {
401 $arrParamsBusc{'newlistBiblios'} = $listBiblios;
403 # From the new list we build again the next and previous result
404 if (@arrBiblios) {
405 if ($arrBiblios[0] == $biblionumber) {
406 for (my $j = $#newresults; $j >= 0; $j--) {
407 next unless ($newresults[$j]);
408 $paging{'previous'}->{biblionumber} = $newresults[$j]->{biblionumber};
409 $arrParamsBusc{'previous'} = $paging{'previous'}->{biblionumber};
410 $arrParamsBusc{'offsetSearch'} = $offsetSearch;
411 last;
413 } elsif ($arrBiblios[$#arrBiblios] == $biblionumber) {
414 for (my $j = 0; $j < @newresults; $j++) {
415 next unless ($newresults[$j]);
416 $paging{'next'}->{biblionumber} = $newresults[$j]->{biblionumber};
417 $arrParamsBusc{'next'} = $paging{'next'}->{biblionumber};
418 $arrParamsBusc{'offsetSearch'} = $offsetSearch;
419 last;
423 # build new busc param
424 my $newbusc = rebuildBuscParam(\%arrParamsBusc);
425 $session->param("busc" => $newbusc);
427 my ($numberBiblioPaging, $dataBiblioPaging);
428 # Previous biblio
429 $numberBiblioPaging = $paging{'previous'}->{biblionumber};
430 if ($numberBiblioPaging) {
431 $template->param( 'previousBiblionumber' => $numberBiblioPaging );
432 $dataBiblioPaging = GetBiblioData($numberBiblioPaging);
433 $template->param('previousTitle' => $dataBiblioPaging->{'title'}) if ($dataBiblioPaging);
435 # Next biblio
436 $numberBiblioPaging = $paging{'next'}->{biblionumber};
437 if ($numberBiblioPaging) {
438 $template->param( 'nextBiblionumber' => $numberBiblioPaging );
439 $dataBiblioPaging = GetBiblioData($numberBiblioPaging);
440 $template->param('nextTitle' => $dataBiblioPaging->{'title'}) if ($dataBiblioPaging);
442 # Partial list of biblio results
443 my @listResults;
444 for (my $j = 0; $j < @arrBiblios; $j++) {
445 next unless ($arrBiblios[$j]);
446 $dataBiblioPaging = GetBiblioData($arrBiblios[$j]) if ($arrBiblios[$j] != $biblionumber);
447 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]};
449 $template->param('listResults' => \@listResults) if (@listResults);
450 $template->param('indexPag' => 1 + $offset, 'totalPag' => $arrParamsBusc{'total'}, 'indexPagEnd' => scalar(@arrBiblios) + $offset);
455 $template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
456 $template->param('OPACShowCheckoutName' => C4::Context->preference("OPACShowCheckoutName") );
457 $template->param('OPACShowBarcode' => C4::Context->preference("OPACShowBarcode") );
459 # adding items linked via host biblios
461 my $analyticfield = '773';
462 if ($marcflavour eq 'MARC21' || $marcflavour eq 'NORMARC'){
463 $analyticfield = '773';
464 } elsif ($marcflavour eq 'UNIMARC') {
465 $analyticfield = '461';
467 foreach my $hostfield ( $record->field($analyticfield)) {
468 my $hostbiblionumber = $hostfield->subfield("0");
469 my $linkeditemnumber = $hostfield->subfield("9");
470 my @hostitemInfos = GetItemsInfo($hostbiblionumber);
471 foreach my $hostitemInfo (@hostitemInfos){
472 if ($hostitemInfo->{itemnumber} eq $linkeditemnumber){
473 push(@all_items, $hostitemInfo);
478 my @items;
480 # Are there items to hide?
481 my $hideitems;
482 $hideitems = 1 if C4::Context->preference('hidelostitems') or scalar(@hiddenitems) > 0;
484 # Hide items
485 if ($hideitems) {
486 for my $itm (@all_items) {
487 if ( C4::Context->preference('hidelostitems') ) {
488 push @items, $itm unless $itm->{itemlost} or any { $itm->{'itemnumber'} eq $_ } @hiddenitems;
489 } else {
490 push @items, $itm unless any { $itm->{'itemnumber'} eq $_ } @hiddenitems;
493 } else {
494 # Or not
495 @items = @all_items;
498 my $branch = '';
499 if (C4::Context->userenv){
500 $branch = C4::Context->userenv->{branch};
502 if ( C4::Context->preference('HighlightOwnItemsOnOPAC') ) {
503 if (
504 ( ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) && $branch )
506 C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch'
508 my $branchcode;
509 if ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) {
510 $branchcode = $branch;
512 elsif ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch' ) {
513 $branchcode = $ENV{'BRANCHCODE'};
516 my @our_items;
517 my @other_items;
519 foreach my $item ( @items ) {
520 if ( $item->{branchcode} eq $branchcode ) {
521 $item->{'this_branch'} = 1;
522 push( @our_items, $item );
523 } else {
524 push( @other_items, $item );
528 @items = ( @our_items, @other_items );
532 my $dat = &GetBiblioData($biblionumber);
533 my $HideMARC = $record_processor->filters->[0]->should_hide_marc(
535 frameworkcode => $dat->{'frameworkcode'},
536 interface => 'opac',
537 } );
539 my $itemtypes = GetItemTypes();
540 # imageurl:
541 my $itemtype = $dat->{'itemtype'};
542 if ( $itemtype ) {
543 $dat->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} );
544 $dat->{'description'} = $itemtypes->{$itemtype}->{translated_description};
546 my $shelflocations =GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'}, 'opac');
547 my $collections = GetKohaAuthorisedValues('items.ccode',$dat->{'frameworkcode'}, 'opac');
548 my $copynumbers = GetKohaAuthorisedValues('items.copynumber',$dat->{'frameworkcode'}, 'opac');
550 #coping with subscriptions
551 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
552 my @subscriptions = SearchSubscriptions({ biblionumber => $biblionumber, orderby => 'title' });
554 my @subs;
555 $dat->{'serial'}=1 if $subscriptionsnumber;
556 foreach my $subscription (@subscriptions) {
557 my $serials_to_display;
558 my %cell;
559 $cell{subscriptionid} = $subscription->{subscriptionid};
560 $cell{subscriptionnotes} = $subscription->{notes};
561 $cell{missinglist} = $subscription->{missinglist};
562 $cell{opacnote} = $subscription->{opacnote};
563 $cell{histstartdate} = $subscription->{histstartdate};
564 $cell{histenddate} = $subscription->{histenddate};
565 $cell{branchcode} = $subscription->{branchcode};
566 $cell{hasalert} = $subscription->{hasalert};
567 $cell{callnumber} = $subscription->{callnumber};
568 $cell{closed} = $subscription->{closed};
569 #get the three latest serials.
570 $serials_to_display = $subscription->{opacdisplaycount};
571 $serials_to_display = C4::Context->preference('OPACSerialIssueDisplayCount') unless $serials_to_display;
572 $cell{opacdisplaycount} = $serials_to_display;
573 $cell{latestserials} =
574 GetLatestSerials( $subscription->{subscriptionid}, $serials_to_display );
575 push @subs, \%cell;
578 $dat->{'count'} = scalar(@items);
581 my (%item_reserves, %priority);
582 my ($show_holds_count, $show_priority);
583 for ( C4::Context->preference("OPACShowHoldQueueDetails") ) {
584 m/holds/o and $show_holds_count = 1;
585 m/priority/ and $show_priority = 1;
587 my $has_hold;
588 if ( $show_holds_count || $show_priority) {
589 my $reserves = GetReservesFromBiblionumber({ biblionumber => $biblionumber, all_dates => 1 });
590 $template->param( holds_count => scalar( @$reserves ) ) if $show_holds_count;
591 foreach (@$reserves) {
592 $item_reserves{ $_->{itemnumber} }++ if $_->{itemnumber};
593 if ($show_priority && $_->{borrowernumber} == $borrowernumber) {
594 $has_hold = 1;
595 $_->{itemnumber}
596 ? ($priority{ $_->{itemnumber} } = $_->{priority})
597 : ($template->param( priority => $_->{priority} ));
601 $template->param( show_priority => $has_hold ) ;
603 my $norequests = 1;
604 my %itemfields;
605 my (@itemloop, @otheritemloop);
606 my $currentbranch = C4::Context->userenv ? C4::Context->userenv->{branch} : undef;
607 if ($currentbranch and C4::Context->preference('OpacSeparateHoldings')) {
608 $template->param(SeparateHoldings => 1);
610 my $separatebranch = C4::Context->preference('OpacSeparateHoldingsBranch');
611 my $viewallitems = $query->param('viewallitems');
612 my $max_items_to_display = C4::Context->preference('OpacMaxItemsToDisplay') // 50;
614 # Get items on order
615 my ( @itemnumbers_on_order );
616 if ( C4::Context->preference('OPACAcquisitionDetails' ) ) {
617 my $orders = C4::Acquisition::SearchOrders({
618 biblionumber => $biblionumber,
619 ordered => 1,
621 my $total_quantity = 0;
622 for my $order ( @$orders ) {
623 if ( C4::Context->preference('AcqCreateItem') eq 'ordering' ) {
624 for my $itemnumber ( C4::Acquisition::GetItemnumbersFromOrder( $order->{ordernumber} ) ) {
625 push @itemnumbers_on_order, $itemnumber;
628 $total_quantity += $order->{quantity};
630 $template->{VARS}->{acquisition_details} = {
631 total_quantity => $total_quantity,
635 if ( not $viewallitems and @items > $max_items_to_display ) {
636 $template->param(
637 too_many_items => 1,
638 items_count => scalar( @items ),
640 } else {
641 my $allow_onshelf_holds;
642 my $borrower = GetMember( 'borrowernumber' => $borrowernumber );
643 for my $itm (@items) {
644 $itm->{holds_count} = $item_reserves{ $itm->{itemnumber} };
645 $itm->{priority} = $priority{ $itm->{itemnumber} };
646 $norequests = 0
647 if $norequests
648 && !$itm->{'withdrawn'}
649 && !$itm->{'itemlost'}
650 && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'})
651 && !$itemtypes->{$itm->{'itype'}}->{notforloan}
652 && $itm->{'itemnumber'};
654 $allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed( $itm, $borrower )
655 unless $allow_onshelf_holds;
657 # get collection code description, too
658 my $ccode = $itm->{'ccode'};
659 $itm->{'ccode'} = $collections->{$ccode} if defined($ccode) && $collections && exists( $collections->{$ccode} );
660 my $copynumber = $itm->{'copynumber'};
661 $itm->{'copynumber'} = $copynumbers->{$copynumber} if ( defined($copynumbers) && defined($copynumber) && exists( $copynumbers->{$copynumber} ) );
662 if ( defined $itm->{'location'} ) {
663 $itm->{'location_description'} = $shelflocations->{ $itm->{'location'} };
665 if (exists $itm->{itype} && defined($itm->{itype}) && exists $itemtypes->{ $itm->{itype} }) {
666 $itm->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{ $itm->{itype} }->{'imageurl'} );
667 $itm->{'description'} = $itemtypes->{ $itm->{itype} }->{translated_description};
669 foreach (qw(ccode enumchron copynumber itemnotes uri)) {
670 $itemfields{$_} = 1 if ($itm->{$_});
673 my $reserve_status = C4::Reserves::GetReserveStatus($itm->{itemnumber});
674 if( $reserve_status eq "Waiting"){ $itm->{'waiting'} = 1; }
675 if( $reserve_status eq "Reserved"){ $itm->{'onhold'} = 1; }
677 my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($itm->{itemnumber});
678 if ( defined( $transfertwhen ) && $transfertwhen ne '' ) {
679 $itm->{transfertwhen} = $transfertwhen;
680 $itm->{transfertfrom} = $transfertfrom;
681 $itm->{transfertto} = $transfertto;
684 if ( C4::Context->preference('OPACAcquisitionDetails')
685 and C4::Context->preference('AcqCreateItem') eq 'ordering' )
687 $itm->{on_order} = 1
688 if grep /^$itm->{itemnumber}$/, @itemnumbers_on_order;
691 my $itembranch = $itm->{$separatebranch};
692 if ($currentbranch and C4::Context->preference('OpacSeparateHoldings')) {
693 if ($itembranch and $itembranch eq $currentbranch) {
694 push @itemloop, $itm;
695 } else {
696 push @otheritemloop, $itm;
698 } else {
699 push @itemloop, $itm;
702 $template->param( 'AllowOnShelfHolds' => $allow_onshelf_holds );
705 # Display only one tab if one items list is empty
706 if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) {
707 $template->param(SeparateHoldings => 0);
708 if (scalar(@itemloop) == 0) {
709 @itemloop = @otheritemloop;
713 ## get notes and subjects from MARC record
714 if (!C4::Context->preference("OPACXSLTDetailsDisplay") ) {
715 my $marcisbnsarray = GetMarcISBN ($record,$marcflavour);
716 my $marcauthorsarray = GetMarcAuthors ($record,$marcflavour);
717 my $marcsubjctsarray = GetMarcSubjects($record,$marcflavour);
718 my $marcseriesarray = GetMarcSeries ($record,$marcflavour);
719 my $marcurlsarray = GetMarcUrls ($record,$marcflavour);
720 my $marchostsarray = GetMarcHosts($record,$marcflavour);
722 $template->param(
723 MARCSUBJCTS => $marcsubjctsarray,
724 MARCAUTHORS => $marcauthorsarray,
725 MARCSERIES => $marcseriesarray,
726 MARCURLS => $marcurlsarray,
727 MARCISBNS => $marcisbnsarray,
728 MARCHOSTS => $marchostsarray,
732 my $marcnotesarray = GetMarcNotes ($record,$marcflavour);
733 my $subtitle = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber));
735 $template->param(
736 MARCNOTES => $marcnotesarray,
737 norequests => $norequests,
738 RequestOnOpac => C4::Context->preference("RequestOnOpac"),
739 itemdata_ccode => $itemfields{ccode},
740 itemdata_enumchron => $itemfields{enumchron},
741 itemdata_uri => $itemfields{uri},
742 itemdata_copynumber => $itemfields{copynumber},
743 itemdata_itemnotes => $itemfields{itemnotes},
744 subtitle => $subtitle,
745 OpacStarRatings => C4::Context->preference("OpacStarRatings"),
748 if (C4::Context->preference("AlternateHoldingsField") && scalar @items == 0) {
749 my $fieldspec = C4::Context->preference("AlternateHoldingsField");
750 my $subfields = substr $fieldspec, 3;
751 my $holdingsep = C4::Context->preference("AlternateHoldingsSeparator") || ' ';
752 my @alternateholdingsinfo = ();
753 my @holdingsfields = $record->field(substr $fieldspec, 0, 3);
755 for my $field (@holdingsfields) {
756 my %holding = ( holding => '' );
757 my $havesubfield = 0;
758 for my $subfield ($field->subfields()) {
759 if ((index $subfields, $$subfield[0]) >= 0) {
760 $holding{'holding'} .= $holdingsep if (length $holding{'holding'} > 0);
761 $holding{'holding'} .= $$subfield[1];
762 $havesubfield++;
765 if ($havesubfield) {
766 push(@alternateholdingsinfo, \%holding);
770 $template->param(
771 ALTERNATEHOLDINGS => \@alternateholdingsinfo,
775 # FIXME: The template uses this hash directly. Need to filter.
776 foreach ( keys %{$dat} ) {
777 next if ( $HideMARC->{$_} );
778 $template->param( "$_" => defined $dat->{$_} ? $dat->{$_} : '' );
781 # some useful variables for enhanced content;
782 # in each case, we're grabbing the first value we find in
783 # the record and normalizing it
784 my $upc = GetNormalizedUPC($record,$marcflavour);
785 my $oclc = GetNormalizedOCLCNumber($record,$marcflavour);
786 my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
787 my $content_identifier_exists;
788 if ( $isbn or $ean or $oclc or $upc ) {
789 $content_identifier_exists = 1;
791 $template->param(
792 normalized_upc => $upc,
793 normalized_ean => $ean,
794 normalized_oclc => $oclc,
795 normalized_isbn => $isbn,
796 content_identifier_exists => $content_identifier_exists,
799 # COinS format FIXME: for books Only
800 $template->param(
801 ocoins => GetCOinSBiblio($record),
804 my ( $loggedincommenter, $reviews );
805 if ( C4::Context->preference('reviewson') ) {
806 $reviews = Koha::Reviews->search(
808 biblionumber => $biblionumber,
809 -or => { approved => 1, borrowernumber => $borrowernumber }
812 order_by => { -desc => 'datereviewed' }
814 )->unblessed;
815 my $libravatar_enabled = 0;
816 if ( C4::Context->preference('ShowReviewer') and C4::Context->preference('ShowReviewerPhoto') ) {
817 eval {
818 require Libravatar::URL;
819 Libravatar::URL->import();
821 if ( !$@ ) {
822 $libravatar_enabled = 1;
825 for my $review (@$reviews) {
826 my $borrowerData = GetMember( 'borrowernumber' => $review->{borrowernumber} );
828 # setting some borrower info into this hash
829 $review->{title} = $borrowerData->{'title'};
830 $review->{surname} = $borrowerData->{'surname'};
831 $review->{firstname} = $borrowerData->{'firstname'};
832 if ( $libravatar_enabled and $borrowerData->{'email'} ) {
833 $review->{avatarurl} = libravatar_url( email => $borrowerData->{'email'}, https => $ENV{HTTPS} );
835 $review->{userid} = $borrowerData->{'userid'};
836 $review->{cardnumber} = $borrowerData->{'cardnumber'};
838 if ( $borrowerData->{'borrowernumber'} eq $borrowernumber ) {
839 $review->{your_comment} = 1;
840 $loggedincommenter = 1;
845 if ( C4::Context->preference("OPACISBD") ) {
846 $template->param( ISBD => 1 );
849 $template->param(
850 itemloop => \@itemloop,
851 otheritemloop => \@otheritemloop,
852 subscriptionsnumber => $subscriptionsnumber,
853 biblionumber => $biblionumber,
854 subscriptions => \@subs,
855 subscriptionsnumber => $subscriptionsnumber,
856 reviews => $reviews,
857 loggedincommenter => $loggedincommenter
860 # Lists
861 if (C4::Context->preference("virtualshelves") ) {
862 my $shelves = Koha::Virtualshelves->search(
864 biblionumber => $biblionumber,
865 category => 2,
868 join => 'virtualshelfcontents',
871 $template->param( shelves => $shelves );
874 # XISBN Stuff
875 if (C4::Context->preference("OPACFRBRizeEditions")==1) {
876 eval {
877 $template->param(
878 XISBNS => get_xisbns($isbn)
881 if ($@) { warn "XISBN Failed $@"; }
884 # Serial Collection
885 my @sc_fields = $record->field(955);
886 my @lc_fields = $marcflavour eq 'UNIMARC'
887 ? $record->field(930)
888 : $record->field(852);
889 my @serialcollections = ();
891 foreach my $sc_field (@sc_fields) {
892 my %row_data;
894 $row_data{text} = $sc_field->subfield('r');
895 $row_data{branch} = $sc_field->subfield('9');
896 foreach my $lc_field (@lc_fields) {
897 $row_data{itemcallnumber} = $marcflavour eq 'UNIMARC'
898 ? $lc_field->subfield('a') # 930$a
899 : $lc_field->subfield('h') # 852$h
900 if ($sc_field->subfield('5') eq $lc_field->subfield('5'));
903 if ($row_data{text} && $row_data{branch}) {
904 push (@serialcollections, \%row_data);
908 if (scalar(@serialcollections) > 0) {
909 $template->param(
910 serialcollection => 1,
911 serialcollections => \@serialcollections);
914 # Local cover Images stuff
915 if (C4::Context->preference("OPACLocalCoverImages")){
916 $template->param(OPACLocalCoverImages => 1);
919 # HTML5 Media
920 if ( (C4::Context->preference("HTML5MediaEnabled") eq 'both') or (C4::Context->preference("HTML5MediaEnabled") eq 'opac') ) {
921 $template->param( C4::HTML5Media->gethtml5media($record));
924 my $syndetics_elements;
926 if ( C4::Context->preference("SyndeticsEnabled") ) {
927 $template->param("SyndeticsEnabled" => 1);
928 $template->param("SyndeticsClientCode" => C4::Context->preference("SyndeticsClientCode"));
929 eval {
930 $syndetics_elements = &get_syndetics_index($isbn,$upc,$oclc);
931 for my $element (values %$syndetics_elements) {
932 $template->param("Syndetics$element"."Exists" => 1 );
933 #warn "Exists: "."Syndetics$element"."Exists";
936 warn $@ if $@;
939 if ( C4::Context->preference("SyndeticsEnabled")
940 && C4::Context->preference("SyndeticsSummary")
941 && ( exists($syndetics_elements->{'SUMMARY'}) || exists($syndetics_elements->{'AVSUMMARY'}) ) ) {
942 eval {
943 my $syndetics_summary = &get_syndetics_summary($isbn,$upc,$oclc, $syndetics_elements);
944 $template->param( SYNDETICS_SUMMARY => $syndetics_summary );
946 warn $@ if $@;
950 if ( C4::Context->preference("SyndeticsEnabled")
951 && C4::Context->preference("SyndeticsTOC")
952 && exists($syndetics_elements->{'TOC'}) ) {
953 eval {
954 my $syndetics_toc = &get_syndetics_toc($isbn,$upc,$oclc);
955 $template->param( SYNDETICS_TOC => $syndetics_toc );
957 warn $@ if $@;
960 if ( C4::Context->preference("SyndeticsEnabled")
961 && C4::Context->preference("SyndeticsExcerpt")
962 && exists($syndetics_elements->{'DBCHAPTER'}) ) {
963 eval {
964 my $syndetics_excerpt = &get_syndetics_excerpt($isbn,$upc,$oclc);
965 $template->param( SYNDETICS_EXCERPT => $syndetics_excerpt );
967 warn $@ if $@;
970 if ( C4::Context->preference("SyndeticsEnabled")
971 && C4::Context->preference("SyndeticsReviews")) {
972 eval {
973 my $syndetics_reviews = &get_syndetics_reviews($isbn,$upc,$oclc,$syndetics_elements);
974 $template->param( SYNDETICS_REVIEWS => $syndetics_reviews );
976 warn $@ if $@;
979 if ( C4::Context->preference("SyndeticsEnabled")
980 && C4::Context->preference("SyndeticsAuthorNotes")
981 && exists($syndetics_elements->{'ANOTES'}) ) {
982 eval {
983 my $syndetics_anotes = &get_syndetics_anotes($isbn,$upc,$oclc);
984 $template->param( SYNDETICS_ANOTES => $syndetics_anotes );
986 warn $@ if $@;
989 # LibraryThingForLibraries ID Code and Tabbed View Option
990 if( C4::Context->preference('LibraryThingForLibrariesEnabled') )
992 $template->param(LibraryThingForLibrariesID =>
993 C4::Context->preference('LibraryThingForLibrariesID') );
994 $template->param(LibraryThingForLibrariesTabbedView =>
995 C4::Context->preference('LibraryThingForLibrariesTabbedView') );
998 # Novelist Select
999 if( C4::Context->preference('NovelistSelectEnabled') )
1001 $template->param(NovelistSelectProfile => C4::Context->preference('NovelistSelectProfile') );
1002 $template->param(NovelistSelectPassword => C4::Context->preference('NovelistSelectPassword') );
1003 $template->param(NovelistSelectView => C4::Context->preference('NovelistSelectView') );
1007 # Babelthèque
1008 if ( C4::Context->preference("Babeltheque") ) {
1009 $template->param(
1010 Babeltheque => 1,
1011 Babeltheque_url_js => C4::Context->preference("Babeltheque_url_js"),
1015 # Social Networks
1016 if ( C4::Context->preference( "SocialNetworks" ) ) {
1017 $template->param( current_url => C4::Context->preference('OPACBaseURL') . "/cgi-bin/koha/opac-detail.pl?biblionumber=$biblionumber" );
1018 $template->param( SocialNetworks => 1 );
1021 # Shelf Browser Stuff
1022 if (C4::Context->preference("OPACShelfBrowser")) {
1023 my $starting_itemnumber = $query->param('shelfbrowse_itemnumber');
1024 if (defined($starting_itemnumber)) {
1025 $template->param( OpenOPACShelfBrowser => 1) if $starting_itemnumber;
1026 my $nearby = GetNearbyItems($starting_itemnumber);
1028 $template->param(
1029 starting_itemnumber => $starting_itemnumber,
1030 starting_homebranch => $nearby->{starting_homebranch}->{description},
1031 starting_location => $nearby->{starting_location}->{description},
1032 starting_ccode => $nearby->{starting_ccode}->{description},
1033 shelfbrowser_prev_item => $nearby->{prev_item},
1034 shelfbrowser_next_item => $nearby->{next_item},
1035 shelfbrowser_items => $nearby->{items},
1038 # in which tab shelf browser should open ?
1039 if (grep { $starting_itemnumber == $_->{itemnumber} } @itemloop) {
1040 $template->param(shelfbrowser_tab => 'holdings');
1041 } else {
1042 $template->param(shelfbrowser_tab => 'otherholdings');
1047 $template->param( AmazonTld => get_amazon_tld() ) if ( C4::Context->preference("OPACAmazonCoverImages"));
1049 if (C4::Context->preference("BakerTaylorEnabled")) {
1050 $template->param(
1051 BakerTaylorEnabled => 1,
1052 BakerTaylorImageURL => &image_url(),
1053 BakerTaylorLinkURL => &link_url(),
1054 BakerTaylorBookstoreURL => C4::Context->preference('BakerTaylorBookstoreURL'),
1056 my ($bt_user, $bt_pass);
1057 if ($isbn and
1058 $bt_user = C4::Context->preference('BakerTaylorUsername') and
1059 $bt_pass = C4::Context->preference('BakerTaylorPassword') )
1061 $template->param(
1062 BakerTaylorContentURL =>
1063 sprintf("http://contentcafe2.btol.com/ContentCafeClient/ContentCafe.aspx?UserID=%s&Password=%s&ItemKey=%s&Options=Y",
1064 $bt_user,$bt_pass,$isbn)
1069 my $tag_quantity;
1070 if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->preference('TagsShowOnDetail')) {
1071 $template->param(
1072 TagsEnabled => 1,
1073 TagsShowOnDetail => $tag_quantity,
1074 TagsInputOnDetail => C4::Context->preference('TagsInputOnDetail')
1076 $template->param(TagLoop => get_tags({biblionumber=>$biblionumber, approved=>1,
1077 'sort'=>'-weight', limit=>$tag_quantity}));
1080 if (C4::Context->preference("OPACURLOpenInNewWindow")) {
1081 # These values are going to be read by Javascript, at least in the case
1082 # of the google covers
1083 $template->param(covernewwindow => 'true');
1084 } else {
1085 $template->param(covernewwindow => 'false');
1088 if ( C4::Context->preference('OpacStarRatings') !~ /disable/ ) {
1089 my $ratings = Koha::Ratings->search({ biblionumber => $biblionumber });
1090 my $my_rating = $borrowernumber ? $ratings->search({ borrowernumber => $borrowernumber })->next : undef;
1091 $template->param(
1092 ratings => $ratings,
1093 my_rating => $my_rating,
1094 borrowernumber => $borrowernumber
1098 #Search for title in links
1099 my $marccontrolnumber = GetMarcControlnumber ($record, $marcflavour);
1100 my $marcissns = GetMarcISSN ( $record, $marcflavour );
1101 my $issn = $marcissns->[0] || '';
1103 if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
1104 $dat->{title} =~ s/\/+$//; # remove trailing slash
1105 $dat->{title} =~ s/\s+$//; # remove trailing space
1106 $search_for_title = parametrized_url(
1107 $search_for_title,
1109 TITLE => $dat->{title},
1110 AUTHOR => $dat->{author},
1111 ISBN => $isbn,
1112 ISSN => $issn,
1113 CONTROLNUMBER => $marccontrolnumber,
1114 BIBLIONUMBER => $biblionumber,
1117 $template->param('OPACSearchForTitleIn' => $search_for_title);
1120 #IDREF
1121 if ( C4::Context->preference("IDREF") ) {
1122 # If the record comes from the SUDOC
1123 if ( $record->field('009') ) {
1124 my $unimarc3 = $record->field("009")->data;
1125 if ( $unimarc3 =~ /^\d+$/ ) {
1126 $template->param(
1127 IDREF => 1,
1133 # We try to select the best default tab to show, according to what
1134 # the user wants, and what's available for display
1135 my $opac_serial_default = C4::Context->preference('opacSerialDefaultTab');
1136 my $defaulttab =
1137 $opac_serial_default eq 'subscriptions' && $subscriptionsnumber
1138 ? 'subscriptions' :
1139 $opac_serial_default eq 'serialcollection' && @serialcollections > 0
1140 ? 'serialcollection' :
1141 $opac_serial_default eq 'holdings' && scalar (@itemloop) > 0
1142 ? 'holdings' :
1143 scalar (@itemloop) == 0
1144 ? 'media' :
1145 $subscriptionsnumber
1146 ? 'subscriptions' :
1147 @serialcollections > 0
1148 ? 'serialcollection' : 'subscriptions';
1149 $template->param('defaulttab' => $defaulttab);
1151 if (C4::Context->preference('OPACLocalCoverImages') == 1) {
1152 my @images = ListImagesForBiblio($biblionumber);
1153 $template->{VARS}->{localimages} = \@images;
1156 $template->{VARS}->{IDreamBooksReviews} = C4::Context->preference('IDreamBooksReviews');
1157 $template->{VARS}->{IDreamBooksReadometer} = C4::Context->preference('IDreamBooksReadometer');
1158 $template->{VARS}->{IDreamBooksResults} = C4::Context->preference('IDreamBooksResults');
1159 $template->{VARS}->{OPACPopupAuthorsSearch} = C4::Context->preference('OPACPopupAuthorsSearch');
1161 if (C4::Context->preference('OpacHighlightedWords')) {
1162 $template->{VARS}->{query_desc} = $query->param('query_desc');
1164 $template->{VARS}->{'trackclicks'} = C4::Context->preference('TrackClicks');
1166 if ( C4::Context->preference('UseCourseReserves') ) {
1167 foreach my $i ( @items ) {
1168 $i->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $i->{'itemnumber'} );
1172 $template->param(
1173 'OpacLocationBranchToDisplay' => C4::Context->preference('OpacLocationBranchToDisplay') ,
1174 'OpacLocationBranchToDisplayShelving' => C4::Context->preference('OpacLocationBranchToDisplayShelving'),
1177 output_html_with_http_headers $query, $cookie, $template->output;