Bug 20772: Display and edit of price_paid
[koha.git] / opac / opac-detail.pl
blob6f10c6bde380cf62da420964863177e45f66f7fe
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);
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 C4::Letters;
44 use MARC::Record;
45 use MARC::Field;
46 use List::MoreUtils qw/any none/;
47 use C4::Images;
48 use Koha::DateUtils;
49 use C4::HTML5Media;
50 use C4::CourseReserves qw(GetItemCourseReservesInfo);
52 use Koha::Biblios;
53 use Koha::RecordProcessor;
54 use Koha::AuthorisedValues;
55 use Koha::IssuingRules;
56 use Koha::Items;
57 use Koha::ItemTypes;
58 use Koha::Acquisition::Orders;
59 use Koha::Virtualshelves;
60 use Koha::Patrons;
61 use Koha::Ratings;
62 use Koha::Reviews;
64 BEGIN {
65 if (C4::Context->preference('BakerTaylorEnabled')) {
66 require C4::External::BakerTaylor;
67 import C4::External::BakerTaylor qw(&image_url &link_url);
71 my $query = new CGI;
72 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
74 template_name => "opac-detail.tt",
75 query => $query,
76 type => "opac",
77 authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
81 my $biblionumber = $query->param('biblionumber') || $query->param('bib') || 0;
82 $biblionumber = int($biblionumber);
84 my @all_items = GetItemsInfo($biblionumber);
85 my @hiddenitems;
86 if (scalar @all_items >= 1) {
87 push @hiddenitems, GetHiddenItemnumbers(@all_items);
89 if (scalar @hiddenitems == scalar @all_items ) {
90 print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
91 exit;
95 my $record = GetMarcBiblio({ biblionumber => $biblionumber });
96 if ( ! $record ) {
97 print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
98 exit;
101 my $biblio = Koha::Biblios->find( $biblionumber );
102 my $framework = &GetFrameworkCode( $biblionumber );
103 my $record_processor = Koha::RecordProcessor->new({
104 filters => 'ViewPolicy',
105 options => {
106 interface => 'opac',
107 frameworkcode => $framework
110 $record_processor->process($record);
112 # redirect if opacsuppression is enabled and biblio is suppressed
113 if (C4::Context->preference('OpacSuppression')) {
114 # FIXME hardcoded; the suppression flag ought to be materialized
115 # as a column on biblio or the like
116 my $opacsuppressionfield = '942';
117 my $opacsuppressionfieldvalue = $record->field($opacsuppressionfield);
118 # redirect to opac-blocked info page or 404?
119 my $opacsuppressionredirect;
120 if ( C4::Context->preference("OpacSuppressionRedirect") ) {
121 $opacsuppressionredirect = "/cgi-bin/koha/opac-blocked.pl";
122 } else {
123 $opacsuppressionredirect = "/cgi-bin/koha/errors/404.pl";
125 if ( $opacsuppressionfieldvalue &&
126 $opacsuppressionfieldvalue->subfield("n") &&
127 $opacsuppressionfieldvalue->subfield("n") == 1) {
128 # if OPAC suppression by IP address
129 if (C4::Context->preference('OpacSuppressionByIPRange')) {
130 my $IPAddress = $ENV{'REMOTE_ADDR'};
131 my $IPRange = C4::Context->preference('OpacSuppressionByIPRange');
132 if ($IPAddress !~ /^$IPRange/) {
133 print $query->redirect($opacsuppressionredirect);
134 exit;
136 } else {
137 print $query->redirect($opacsuppressionredirect);
138 exit;
143 $template->param( biblio => $biblio );
145 # get biblionumbers stored in the cart
146 my @cart_list;
148 if($query->cookie("bib_list")){
149 my $cart_list = $query->cookie("bib_list");
150 @cart_list = split(/\//, $cart_list);
151 if ( grep {$_ eq $biblionumber} @cart_list) {
152 $template->param( incart => 1 );
157 SetUTF8Flag($record);
158 my $marcflavour = C4::Context->preference("marcflavour");
159 my $ean = GetNormalizedEAN( $record, $marcflavour );
161 # XSLT processing of some stuff
162 my $xslfile = C4::Context->preference('OPACXSLTDetailsDisplay');
163 my $lang = $xslfile ? C4::Languages::getlanguage() : undef;
164 my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef;
166 if ( $xslfile ) {
167 $template->param(
168 XSLTBloc => XSLTParse4Display(
169 $biblionumber, $record, "OPACXSLTDetailsDisplay",
170 1, undef, $sysxml, $xslfile, $lang
175 my $OpacBrowseResults = C4::Context->preference("OpacBrowseResults");
177 # We look for the busc param to build the simple paging from the search
178 if ($OpacBrowseResults) {
179 my $session = get_session($query->cookie("CGISESSID"));
180 my %paging = (previous => {}, next => {});
181 if ($session->param('busc')) {
182 use C4::Search;
183 use URI::Escape;
185 # Rebuild the string to store on session
186 # param value is URI encoded and params separator is HTML encode (&amp;)
187 sub rebuildBuscParam
189 my $arrParamsBusc = shift;
191 my $pasarParams = '';
192 my $j = 0;
193 for (keys %$arrParamsBusc) {
194 if ($_ =~ /^(?:query|listBiblios|newlistBiblios|query_type|simple_query|total|offset|offsetSearch|next|previous|count|expand|scan)/) {
195 if (defined($arrParamsBusc->{$_})) {
196 $pasarParams .= '&amp;' if ($j);
197 $pasarParams .= $_ . '=' . Encode::decode('UTF-8', uri_escape_utf8( $arrParamsBusc->{$_} ));
198 $j++;
200 } else {
201 for my $value (@{$arrParamsBusc->{$_}}) {
202 next if !defined($value);
203 $pasarParams .= '&amp;' if ($j);
204 $pasarParams .= $_ . '=' . Encode::decode('UTF-8', uri_escape_utf8($value));
205 $j++;
209 return $pasarParams;
210 }#rebuildBuscParam
212 # Search given the current values from the busc param
213 sub searchAgain
215 my ($arrParamsBusc, $offset, $results_per_page) = @_;
217 my $expanded_facet = $arrParamsBusc->{'expand'};
218 my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
219 my @servers;
220 @servers = @{$arrParamsBusc->{'server'}} if $arrParamsBusc->{'server'};
221 @servers = ("biblioserver") unless (@servers);
223 my ($default_sort_by, @sort_by);
224 $default_sort_by = C4::Context->preference('OPACdefaultSortField')."_".C4::Context->preference('OPACdefaultSortOrder') if (C4::Context->preference('OPACdefaultSortField') && C4::Context->preference('OPACdefaultSortOrder'));
225 @sort_by = @{$arrParamsBusc->{'sort_by'}} if $arrParamsBusc->{'sort_by'};
226 $sort_by[0] = $default_sort_by if !$sort_by[0] && defined($default_sort_by);
227 my ($error, $results_hashref, $facets);
228 eval {
229 ($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'});
231 my $hits;
232 my @newresults;
233 for (my $i=0;$i<@servers;$i++) {
234 my $server = $servers[$i];
235 $hits = $results_hashref->{$server}->{"hits"};
236 @newresults = searchResults('opac', '', $hits, $results_per_page, $offset, $arrParamsBusc->{'scan'}, $results_hashref->{$server}->{"RECORDS"});
238 return \@newresults;
239 }#searchAgain
241 # Build the current list of biblionumbers in this search
242 sub buildListBiblios
244 my ($newresultsRef, $results_per_page) = @_;
246 my $listBiblios = '';
247 my $j = 0;
248 foreach (@$newresultsRef) {
249 my $bibnum = ($_->{biblionumber})?$_->{biblionumber}:0;
250 $listBiblios .= $bibnum . ',';
251 $j++;
252 last if ($j == $results_per_page);
254 chop $listBiblios if ($listBiblios =~ /,$/);
255 return $listBiblios;
256 }#buildListBiblios
258 my $busc = $session->param("busc");
259 my @arrBusc = split(/\&(?:amp;)?/, $busc);
260 my ($key, $value);
261 my %arrParamsBusc = ();
262 for (@arrBusc) {
263 ($key, $value) = split(/=/, $_, 2);
264 if ($key =~ /^(?:query|listBiblios|newlistBiblios|query_type|simple_query|next|previous|total|offset|offsetSearch|count|expand|scan)/) {
265 $arrParamsBusc{$key} = uri_unescape($value);
266 } else {
267 unless (exists($arrParamsBusc{$key})) {
268 $arrParamsBusc{$key} = [];
270 push @{$arrParamsBusc{$key}}, uri_unescape($value);
273 my $searchAgain = 0;
274 my $count = C4::Context->preference('OPACnumSearchResults') || 20;
275 my $results_per_page = ($arrParamsBusc{'count'} && $arrParamsBusc{'count'} =~ /^[0-9]+?/)?$arrParamsBusc{'count'}:$count;
276 $arrParamsBusc{'count'} = $results_per_page;
277 my $offset = ($arrParamsBusc{'offset'} && $arrParamsBusc{'offset'} =~ /^[0-9]+?/)?$arrParamsBusc{'offset'}:0;
278 # The value OPACnumSearchResults has changed and the search has to be rebuild
279 if ($count != $results_per_page) {
280 if (exists($arrParamsBusc{'listBiblios'}) && $arrParamsBusc{'listBiblios'} =~ /^[0-9]+(?:,[0-9]+)*$/) {
281 my $indexBiblio = 0;
282 my @arrBibliosAux = split(',', $arrParamsBusc{'listBiblios'});
283 for (@arrBibliosAux) {
284 last if ($_ == $biblionumber);
285 $indexBiblio++;
287 $indexBiblio += $offset;
288 $offset = int($indexBiblio / $count) * $count;
289 $arrParamsBusc{'offset'} = $offset;
291 $arrParamsBusc{'count'} = $count;
292 $results_per_page = $count;
293 my $newresultsRef = searchAgain(\%arrParamsBusc, $offset, $results_per_page);
294 $arrParamsBusc{'listBiblios'} = buildListBiblios($newresultsRef, $results_per_page);
295 delete $arrParamsBusc{'previous'} if (exists($arrParamsBusc{'previous'}));
296 delete $arrParamsBusc{'next'} if (exists($arrParamsBusc{'next'}));
297 delete $arrParamsBusc{'offsetSearch'} if (exists($arrParamsBusc{'offsetSearch'}));
298 delete $arrParamsBusc{'newlistBiblios'} if (exists($arrParamsBusc{'newlistBiblios'}));
299 my $newbusc = rebuildBuscParam(\%arrParamsBusc);
300 $session->param("busc" => $newbusc);
301 @arrBusc = split(/\&(?:amp;)?/, $newbusc);
302 } else {
303 my $modifyListBiblios = 0;
304 # We come from a previous click
305 if (exists($arrParamsBusc{'previous'})) {
306 $modifyListBiblios = 1 if ($biblionumber == $arrParamsBusc{'previous'});
307 delete $arrParamsBusc{'previous'};
308 } elsif (exists($arrParamsBusc{'next'})) { # We come from a next click
309 $modifyListBiblios = 2 if ($biblionumber == $arrParamsBusc{'next'});
310 delete $arrParamsBusc{'next'};
312 if ($modifyListBiblios) {
313 if (exists($arrParamsBusc{'newlistBiblios'})) {
314 my $listBibliosAux = $arrParamsBusc{'listBiblios'};
315 $arrParamsBusc{'listBiblios'} = $arrParamsBusc{'newlistBiblios'};
316 my @arrAux = split(',', $listBibliosAux);
317 $arrParamsBusc{'newlistBiblios'} = $listBibliosAux;
318 if ($modifyListBiblios == 1) {
319 $arrParamsBusc{'next'} = $arrAux[0];
320 $paging{'next'}->{biblionumber} = $arrAux[0];
321 }else {
322 $arrParamsBusc{'previous'} = $arrAux[$#arrAux];
323 $paging{'previous'}->{biblionumber} = $arrAux[$#arrAux];
325 } else {
326 delete $arrParamsBusc{'listBiblios'};
328 my $offsetAux = $arrParamsBusc{'offset'};
329 $arrParamsBusc{'offset'} = $arrParamsBusc{'offsetSearch'};
330 $arrParamsBusc{'offsetSearch'} = $offsetAux;
331 $offset = $arrParamsBusc{'offset'};
332 my $newbusc = rebuildBuscParam(\%arrParamsBusc);
333 $session->param("busc" => $newbusc);
334 @arrBusc = split(/\&(?:amp;)?/, $newbusc);
337 my $buscParam = '';
338 my $j = 0;
339 # Rebuild the query for the button "back to results"
340 for (@arrBusc) {
341 unless ($_ =~ /^(?:query|listBiblios|newlistBiblios|query_type|simple_query|next|previous|total|count|offsetSearch)/) {
342 $buscParam .= '&amp;' unless ($j == 0);
343 $buscParam .= $_; # string already URI encoded
344 $j++;
347 $template->param('busc' => $buscParam);
348 my $offsetSearch;
349 my @arrBiblios;
350 # We are inside the list of biblios and we don't have to search
351 if (exists($arrParamsBusc{'listBiblios'}) && $arrParamsBusc{'listBiblios'} =~ /^[0-9]+(?:,[0-9]+)*$/) {
352 @arrBiblios = split(',', $arrParamsBusc{'listBiblios'});
353 if (@arrBiblios) {
354 # We are at the first item of the list
355 if ($arrBiblios[0] == $biblionumber) {
356 if (@arrBiblios > 1) {
357 for (my $j = 1; $j < @arrBiblios; $j++) {
358 next unless ($arrBiblios[$j]);
359 $paging{'next'}->{biblionumber} = $arrBiblios[$j];
360 last;
363 # search again if we are not at the first searching list
364 if ($offset && !$arrParamsBusc{'previous'}) {
365 $searchAgain = 1;
366 $offsetSearch = $offset - $results_per_page;
368 # we are at the last item of the list
369 } elsif ($arrBiblios[$#arrBiblios] == $biblionumber) {
370 for (my $j = $#arrBiblios - 1; $j >= 0; $j--) {
371 next unless ($arrBiblios[$j]);
372 $paging{'previous'}->{biblionumber} = $arrBiblios[$j];
373 last;
375 if (!$offset) {
376 # search again if we are at the first list and there is more results
377 $searchAgain = 1 if (!$arrParamsBusc{'next'} && $arrParamsBusc{'total'} != @arrBiblios);
378 } else {
379 # search again if we aren't at the first list and there is more results
380 $searchAgain = 1 if (!$arrParamsBusc{'next'} && $arrParamsBusc{'total'} > ($offset + @arrBiblios));
382 $offsetSearch = $offset + $results_per_page if ($searchAgain);
383 } else {
384 for (my $j = 1; $j < $#arrBiblios; $j++) {
385 if ($arrBiblios[$j] == $biblionumber) {
386 for (my $z = $j - 1; $z >= 0; $z--) {
387 next unless ($arrBiblios[$z]);
388 $paging{'previous'}->{biblionumber} = $arrBiblios[$z];
389 last;
391 for (my $z = $j + 1; $z < @arrBiblios; $z++) {
392 next unless ($arrBiblios[$z]);
393 $paging{'next'}->{biblionumber} = $arrBiblios[$z];
394 last;
396 last;
401 $offsetSearch = 0 if (defined($offsetSearch) && $offsetSearch < 0);
403 if ($searchAgain) {
404 my $newresultsRef = searchAgain(\%arrParamsBusc, $offsetSearch, $results_per_page);
405 my @newresults = @$newresultsRef;
406 # build the new listBiblios
407 my $listBiblios = buildListBiblios(\@newresults, $results_per_page);
408 unless (exists($arrParamsBusc{'listBiblios'})) {
409 $arrParamsBusc{'listBiblios'} = $listBiblios;
410 @arrBiblios = split(',', $arrParamsBusc{'listBiblios'});
411 } else {
412 $arrParamsBusc{'newlistBiblios'} = $listBiblios;
414 # From the new list we build again the next and previous result
415 if (@arrBiblios) {
416 if ($arrBiblios[0] == $biblionumber) {
417 for (my $j = $#newresults; $j >= 0; $j--) {
418 next unless ($newresults[$j]);
419 $paging{'previous'}->{biblionumber} = $newresults[$j]->{biblionumber};
420 $arrParamsBusc{'previous'} = $paging{'previous'}->{biblionumber};
421 $arrParamsBusc{'offsetSearch'} = $offsetSearch;
422 last;
424 } elsif ($arrBiblios[$#arrBiblios] == $biblionumber) {
425 for (my $j = 0; $j < @newresults; $j++) {
426 next unless ($newresults[$j]);
427 $paging{'next'}->{biblionumber} = $newresults[$j]->{biblionumber};
428 $arrParamsBusc{'next'} = $paging{'next'}->{biblionumber};
429 $arrParamsBusc{'offsetSearch'} = $offsetSearch;
430 last;
434 # build new busc param
435 my $newbusc = rebuildBuscParam(\%arrParamsBusc);
436 $session->param("busc" => $newbusc);
438 my ($numberBiblioPaging, $dataBiblioPaging);
439 # Previous biblio
440 $numberBiblioPaging = $paging{'previous'}->{biblionumber};
441 if ($numberBiblioPaging) {
442 $template->param( 'previousBiblionumber' => $numberBiblioPaging );
443 $dataBiblioPaging = Koha::Biblios->find( $numberBiblioPaging );
444 $template->param('previousTitle' => $dataBiblioPaging->title) if $dataBiblioPaging;
446 # Next biblio
447 $numberBiblioPaging = $paging{'next'}->{biblionumber};
448 if ($numberBiblioPaging) {
449 $template->param( 'nextBiblionumber' => $numberBiblioPaging );
450 $dataBiblioPaging = Koha::Biblios->find( $numberBiblioPaging );
451 $template->param('nextTitle' => $dataBiblioPaging->title) if $dataBiblioPaging;
453 # Partial list of biblio results
454 my @listResults;
455 for (my $j = 0; $j < @arrBiblios; $j++) {
456 next unless ($arrBiblios[$j]);
457 $dataBiblioPaging = Koha::Biblios->find( $arrBiblios[$j] ) if ($arrBiblios[$j] != $biblionumber);
458 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]};
460 $template->param('listResults' => \@listResults) if (@listResults);
461 $template->param('indexPag' => 1 + $offset, 'totalPag' => $arrParamsBusc{'total'}, 'indexPagEnd' => scalar(@arrBiblios) + $offset);
462 $template->param( 'offset' => $offset );
466 $template->param(
467 OPACShowCheckoutName => C4::Context->preference("OPACShowCheckoutName"),
470 # adding items linked via host biblios
472 my $analyticfield = '773';
473 if ($marcflavour eq 'MARC21' || $marcflavour eq 'NORMARC'){
474 $analyticfield = '773';
475 } elsif ($marcflavour eq 'UNIMARC') {
476 $analyticfield = '461';
478 foreach my $hostfield ( $record->field($analyticfield)) {
479 my $hostbiblionumber = $hostfield->subfield("0");
480 my $linkeditemnumber = $hostfield->subfield("9");
481 my @hostitemInfos = GetItemsInfo($hostbiblionumber);
482 foreach my $hostitemInfo (@hostitemInfos){
483 if ($hostitemInfo->{itemnumber} eq $linkeditemnumber){
484 push(@all_items, $hostitemInfo);
489 my @items;
491 # Are there items to hide?
492 my $hideitems;
493 $hideitems = 1 if C4::Context->preference('hidelostitems') or scalar(@hiddenitems) > 0;
495 # Hide items
496 if ($hideitems) {
497 for my $itm (@all_items) {
498 if ( C4::Context->preference('hidelostitems') ) {
499 push @items, $itm unless $itm->{itemlost} or any { $itm->{'itemnumber'} eq $_ } @hiddenitems;
500 } else {
501 push @items, $itm unless any { $itm->{'itemnumber'} eq $_ } @hiddenitems;
504 } else {
505 # Or not
506 @items = @all_items;
509 my $branch = '';
510 if (C4::Context->userenv){
511 $branch = C4::Context->userenv->{branch};
513 if ( C4::Context->preference('HighlightOwnItemsOnOPAC') ) {
514 if (
515 ( ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) && $branch )
517 C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch'
519 my $branchcode;
520 if ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) {
521 $branchcode = $branch;
523 elsif ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch' ) {
524 $branchcode = $ENV{'BRANCHCODE'};
527 my @our_items;
528 my @other_items;
530 foreach my $item ( @items ) {
531 if ( $item->{branchcode} eq $branchcode ) {
532 $item->{'this_branch'} = 1;
533 push( @our_items, $item );
534 } else {
535 push( @other_items, $item );
539 @items = ( @our_items, @other_items );
543 my $dat = &GetBiblioData($biblionumber);
544 my $HideMARC = $record_processor->filters->[0]->should_hide_marc(
546 frameworkcode => $dat->{'frameworkcode'},
547 interface => 'opac',
548 } );
550 my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
551 # imageurl:
552 my $itemtype = $dat->{'itemtype'};
553 if ( $itemtype ) {
554 $dat->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} );
555 $dat->{'description'} = $itemtypes->{$itemtype}->{translated_description};
558 my $shelflocations =
559 { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.location' } ) };
560 my $collections =
561 { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.ccode' } ) };
562 my $copynumbers =
563 { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.copynumber' } ) };
565 #coping with subscriptions
566 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
567 my @subscriptions = SearchSubscriptions({ biblionumber => $biblionumber, orderby => 'title' });
569 my @subs;
570 $dat->{'serial'}=1 if $subscriptionsnumber;
571 foreach my $subscription (@subscriptions) {
572 my $serials_to_display;
573 my %cell;
574 $cell{subscriptionid} = $subscription->{subscriptionid};
575 $cell{subscriptionnotes} = $subscription->{notes};
576 $cell{missinglist} = $subscription->{missinglist};
577 $cell{opacnote} = $subscription->{opacnote};
578 $cell{histstartdate} = $subscription->{histstartdate};
579 $cell{histenddate} = $subscription->{histenddate};
580 $cell{branchcode} = $subscription->{branchcode};
581 $cell{callnumber} = $subscription->{callnumber};
582 $cell{closed} = $subscription->{closed};
583 $cell{letter} = $subscription->{letter};
584 $cell{biblionumber} = $subscription->{biblionumber};
585 #get the three latest serials.
586 $serials_to_display = $subscription->{opacdisplaycount};
587 $serials_to_display = C4::Context->preference('OPACSerialIssueDisplayCount') unless $serials_to_display;
588 $cell{opacdisplaycount} = $serials_to_display;
589 $cell{latestserials} =
590 GetLatestSerials( $subscription->{subscriptionid}, $serials_to_display );
591 if ( $borrowernumber ) {
592 my $subscription_object = Koha::Subscriptions->find( $subscription->{subscriptionid} );
593 my $subscriber = $subscription_object->subscribers->find( $borrowernumber );
594 $cell{hasalert} = 1 if $subscriber;
596 push @subs, \%cell;
599 $dat->{'count'} = scalar(@items);
602 my (%item_reserves, %priority);
603 my ($show_holds_count, $show_priority);
604 for ( C4::Context->preference("OPACShowHoldQueueDetails") ) {
605 m/holds/o and $show_holds_count = 1;
606 m/priority/ and $show_priority = 1;
608 my $has_hold;
609 if ( $show_holds_count || $show_priority) {
610 my $holds = $biblio->holds;
611 $template->param( holds_count => $holds->count );
612 while ( my $hold = $holds->next ) {
613 $item_reserves{ $hold->itemnumber }++ if $hold->itemnumber;
614 if ($show_priority && $hold->borrowernumber == $borrowernumber) {
615 $has_hold = 1;
616 $hold->itemnumber
617 ? ($priority{ $hold->itemnumber } = $hold->priority)
618 : ($template->param( priority => $hold->priority ));
622 $template->param( show_priority => $has_hold ) ;
624 my $norequests = 1;
625 my %itemfields;
626 my (@itemloop, @otheritemloop);
627 my $currentbranch = C4::Context->userenv ? C4::Context->userenv->{branch} : undef;
628 if ($currentbranch and C4::Context->preference('OpacSeparateHoldings')) {
629 $template->param(SeparateHoldings => 1);
631 my $separatebranch = C4::Context->preference('OpacSeparateHoldingsBranch');
632 my $viewallitems = $query->param('viewallitems');
633 my $max_items_to_display = C4::Context->preference('OpacMaxItemsToDisplay') // 50;
635 # Get items on order
636 my ( @itemnumbers_on_order );
637 if ( C4::Context->preference('OPACAcquisitionDetails' ) ) {
638 my $orders = C4::Acquisition::SearchOrders({
639 biblionumber => $biblionumber,
640 ordered => 1,
642 my $total_quantity = 0;
643 for my $order ( @$orders ) {
644 my $basket = Koha::Acquisition::Orders->find( $order->{ordernumber} )->basket;
645 if ( $basket->effective_create_items eq 'ordering' ) {
646 for my $itemnumber ( C4::Acquisition::GetItemnumbersFromOrder( $order->{ordernumber} ) ) {
647 push @itemnumbers_on_order, $itemnumber;
650 $total_quantity += $order->{quantity};
652 $template->{VARS}->{acquisition_details} = {
653 total_quantity => $total_quantity,
657 my $allow_onshelf_holds;
658 if ( not $viewallitems and @items > $max_items_to_display ) {
659 $template->param(
660 too_many_items => 1,
661 items_count => scalar( @items ),
663 } else {
664 my $patron = Koha::Patrons->find( $borrowernumber );
665 for my $itm (@items) {
666 my $item = Koha::Items->find( $itm->{itemnumber} );
667 $itm->{holds_count} = $item_reserves{ $itm->{itemnumber} };
668 $itm->{priority} = $priority{ $itm->{itemnumber} };
669 $norequests = 0
670 if $norequests
671 && !$itm->{'withdrawn'}
672 && !$itm->{'itemlost'}
673 && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'})
674 && !$itemtypes->{$itm->{'itype'}}->{notforloan}
675 && $itm->{'itemnumber'};
677 $allow_onshelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } )
678 unless $allow_onshelf_holds;
680 # get collection code description, too
681 my $ccode = $itm->{'ccode'};
682 $itm->{'ccode'} = $collections->{$ccode} if defined($ccode) && $collections && exists( $collections->{$ccode} );
683 my $copynumber = $itm->{'copynumber'};
684 $itm->{'copynumber'} = $copynumbers->{$copynumber} if ( defined($copynumbers) && defined($copynumber) && exists( $copynumbers->{$copynumber} ) );
685 if ( defined $itm->{'location'} ) {
686 $itm->{'location_description'} = $shelflocations->{ $itm->{'location'} };
688 if (exists $itm->{itype} && defined($itm->{itype}) && exists $itemtypes->{ $itm->{itype} }) {
689 $itm->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{ $itm->{itype} }->{'imageurl'} );
690 $itm->{'description'} = $itemtypes->{ $itm->{itype} }->{translated_description};
692 foreach (qw(ccode enumchron copynumber itemnotes location_description uri)) {
693 $itemfields{$_} = 1 if ($itm->{$_});
696 my $reserve_status = C4::Reserves::GetReserveStatus($itm->{itemnumber});
697 if( $reserve_status eq "Waiting"){ $itm->{'waiting'} = 1; }
698 if( $reserve_status eq "Reserved"){ $itm->{'onhold'} = 1; }
700 my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($itm->{itemnumber});
701 if ( defined( $transfertwhen ) && $transfertwhen ne '' ) {
702 $itm->{transfertwhen} = $transfertwhen;
703 $itm->{transfertfrom} = $transfertfrom;
704 $itm->{transfertto} = $transfertto;
707 if ( C4::Context->preference('OPACAcquisitionDetails') ) {
708 $itm->{on_order} = 1
709 if grep /^$itm->{itemnumber}$/, @itemnumbers_on_order;
712 my $itembranch = $itm->{$separatebranch};
713 if ($currentbranch and C4::Context->preference('OpacSeparateHoldings')) {
714 if ($itembranch and $itembranch eq $currentbranch) {
715 push @itemloop, $itm;
716 } else {
717 push @otheritemloop, $itm;
719 } else {
720 push @itemloop, $itm;
725 if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) {
726 $template->param( ReservableItems => 1 );
729 # Display only one tab if one items list is empty
730 if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) {
731 $template->param(SeparateHoldings => 0);
732 if (scalar(@itemloop) == 0) {
733 @itemloop = @otheritemloop;
737 ## get notes and subjects from MARC record
738 if (!C4::Context->preference("OPACXSLTDetailsDisplay") ) {
739 my $marcisbnsarray = GetMarcISBN ($record,$marcflavour);
740 my $marcauthorsarray = GetMarcAuthors ($record,$marcflavour);
741 my $marcsubjctsarray = GetMarcSubjects($record,$marcflavour);
742 my $marcseriesarray = GetMarcSeries ($record,$marcflavour);
743 my $marcurlsarray = GetMarcUrls ($record,$marcflavour);
744 my $marchostsarray = GetMarcHosts($record,$marcflavour);
746 $template->param(
747 MARCSUBJCTS => $marcsubjctsarray,
748 MARCAUTHORS => $marcauthorsarray,
749 MARCSERIES => $marcseriesarray,
750 MARCURLS => $marcurlsarray,
751 MARCISBNS => $marcisbnsarray,
752 MARCHOSTS => $marchostsarray,
756 my $marcnotesarray = GetMarcNotes ($record,$marcflavour);
757 my $subtitle = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber));
759 if( C4::Context->preference('ArticleRequests') ) {
760 my $patron = $borrowernumber ? Koha::Patrons->find($borrowernumber) : undef;
761 my $artreqpossible = $patron
762 ? $biblio->can_article_request( $patron )
763 : Koha::ItemTypes->find($biblio->itemtype)->may_article_request;
764 $template->param( artreqpossible => $artreqpossible );
767 $template->param(
768 MARCNOTES => $marcnotesarray,
769 norequests => $norequests,
770 RequestOnOpac => C4::Context->preference("RequestOnOpac"),
771 itemdata_ccode => $itemfields{ccode},
772 itemdata_enumchron => $itemfields{enumchron},
773 itemdata_uri => $itemfields{uri},
774 itemdata_copynumber => $itemfields{copynumber},
775 itemdata_itemnotes => $itemfields{itemnotes},
776 itemdata_location => $itemfields{location_description},
777 subtitle => $subtitle,
778 OpacStarRatings => C4::Context->preference("OpacStarRatings"),
781 if (C4::Context->preference("AlternateHoldingsField") && scalar @items == 0) {
782 my $fieldspec = C4::Context->preference("AlternateHoldingsField");
783 my $subfields = substr $fieldspec, 3;
784 my $holdingsep = C4::Context->preference("AlternateHoldingsSeparator") || ' ';
785 my @alternateholdingsinfo = ();
786 my @holdingsfields = $record->field(substr $fieldspec, 0, 3);
788 for my $field (@holdingsfields) {
789 my %holding = ( holding => '' );
790 my $havesubfield = 0;
791 for my $subfield ($field->subfields()) {
792 if ((index $subfields, $$subfield[0]) >= 0) {
793 $holding{'holding'} .= $holdingsep if (length $holding{'holding'} > 0);
794 $holding{'holding'} .= $$subfield[1];
795 $havesubfield++;
798 if ($havesubfield) {
799 push(@alternateholdingsinfo, \%holding);
803 $template->param(
804 ALTERNATEHOLDINGS => \@alternateholdingsinfo,
808 # FIXME: The template uses this hash directly. Need to filter.
809 foreach ( keys %{$dat} ) {
810 next if ( $HideMARC->{$_} );
811 $template->param( "$_" => defined $dat->{$_} ? $dat->{$_} : '' );
814 # some useful variables for enhanced content;
815 # in each case, we're grabbing the first value we find in
816 # the record and normalizing it
817 my $upc = GetNormalizedUPC($record,$marcflavour);
818 my $oclc = GetNormalizedOCLCNumber($record,$marcflavour);
819 my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
820 my $content_identifier_exists;
821 if ( $isbn or $ean or $oclc or $upc ) {
822 $content_identifier_exists = 1;
824 $template->param(
825 normalized_upc => $upc,
826 normalized_ean => $ean,
827 normalized_oclc => $oclc,
828 normalized_isbn => $isbn,
829 content_identifier_exists => $content_identifier_exists,
832 # COinS format FIXME: for books Only
833 $template->param(
834 ocoins => GetCOinSBiblio($record),
837 my ( $loggedincommenter, $reviews );
838 if ( C4::Context->preference('reviewson') ) {
839 $reviews = Koha::Reviews->search(
841 biblionumber => $biblionumber,
842 -or => { approved => 1, borrowernumber => $borrowernumber }
845 order_by => { -desc => 'datereviewed' }
847 )->unblessed;
848 my $libravatar_enabled = 0;
849 if ( C4::Context->preference('ShowReviewer') and C4::Context->preference('ShowReviewerPhoto') ) {
850 eval {
851 require Libravatar::URL;
852 Libravatar::URL->import();
854 if ( !$@ ) {
855 $libravatar_enabled = 1;
858 for my $review (@$reviews) {
859 my $patron = Koha::Patrons->find( $review->{borrowernumber} ); # FIXME Should be Koha::Review->reviewer or similar
861 # setting some borrower info into this hash
862 if ( $patron ) {
863 $review->{patron} = $patron;
864 if ( $libravatar_enabled and $patron->email ) {
865 $review->{avatarurl} = libravatar_url( email => $patron->email, https => $ENV{HTTPS} );
868 if ( $patron->borrowernumber eq $borrowernumber ) {
869 $loggedincommenter = 1;
875 if ( C4::Context->preference("OPACISBD") ) {
876 $template->param( ISBD => 1 );
879 $template->param(
880 itemloop => \@itemloop,
881 otheritemloop => \@otheritemloop,
882 biblionumber => $biblionumber,
883 subscriptions => \@subs,
884 subscriptionsnumber => $subscriptionsnumber,
885 reviews => $reviews,
886 loggedincommenter => $loggedincommenter
889 # Lists
890 if (C4::Context->preference("virtualshelves") ) {
891 my $shelves = Koha::Virtualshelves->search(
893 biblionumber => $biblionumber,
894 category => 2,
897 join => 'virtualshelfcontents',
900 $template->param( shelves => $shelves );
903 # XISBN Stuff
904 if (C4::Context->preference("OPACFRBRizeEditions")==1) {
905 eval {
906 $template->param(
907 XISBNS => scalar get_xisbns($isbn)
910 if ($@) { warn "XISBN Failed $@"; }
913 # Serial Collection
914 my @sc_fields = $record->field(955);
915 my @lc_fields = $marcflavour eq 'UNIMARC'
916 ? $record->field(930)
917 : $record->field(852);
918 my @serialcollections = ();
920 foreach my $sc_field (@sc_fields) {
921 my %row_data;
923 $row_data{text} = $sc_field->subfield('r');
924 $row_data{branch} = $sc_field->subfield('9');
925 foreach my $lc_field (@lc_fields) {
926 $row_data{itemcallnumber} = $marcflavour eq 'UNIMARC'
927 ? $lc_field->subfield('a') # 930$a
928 : $lc_field->subfield('h') # 852$h
929 if ($sc_field->subfield('5') eq $lc_field->subfield('5'));
932 if ($row_data{text} && $row_data{branch}) {
933 push (@serialcollections, \%row_data);
937 if (scalar(@serialcollections) > 0) {
938 $template->param(
939 serialcollection => 1,
940 serialcollections => \@serialcollections);
943 # Local cover Images stuff
944 if (C4::Context->preference("OPACLocalCoverImages")){
945 $template->param(OPACLocalCoverImages => 1);
948 # HTML5 Media
949 if ( (C4::Context->preference("HTML5MediaEnabled") eq 'both') or (C4::Context->preference("HTML5MediaEnabled") eq 'opac') ) {
950 $template->param( C4::HTML5Media->gethtml5media($record));
953 my $syndetics_elements;
955 if ( C4::Context->preference("SyndeticsEnabled") ) {
956 $template->param("SyndeticsEnabled" => 1);
957 $template->param("SyndeticsClientCode" => C4::Context->preference("SyndeticsClientCode"));
958 eval {
959 $syndetics_elements = &get_syndetics_index($isbn,$upc,$oclc);
960 for my $element (values %$syndetics_elements) {
961 $template->param("Syndetics$element"."Exists" => 1 );
962 #warn "Exists: "."Syndetics$element"."Exists";
965 warn $@ if $@;
968 if ( C4::Context->preference("SyndeticsEnabled")
969 && C4::Context->preference("SyndeticsSummary")
970 && ( exists($syndetics_elements->{'SUMMARY'}) || exists($syndetics_elements->{'AVSUMMARY'}) ) ) {
971 eval {
972 my $syndetics_summary = &get_syndetics_summary($isbn,$upc,$oclc, $syndetics_elements);
973 $template->param( SYNDETICS_SUMMARY => $syndetics_summary );
975 warn $@ if $@;
979 if ( C4::Context->preference("SyndeticsEnabled")
980 && C4::Context->preference("SyndeticsTOC")
981 && exists($syndetics_elements->{'TOC'}) ) {
982 eval {
983 my $syndetics_toc = &get_syndetics_toc($isbn,$upc,$oclc);
984 $template->param( SYNDETICS_TOC => $syndetics_toc );
986 warn $@ if $@;
989 if ( C4::Context->preference("SyndeticsEnabled")
990 && C4::Context->preference("SyndeticsExcerpt")
991 && exists($syndetics_elements->{'DBCHAPTER'}) ) {
992 eval {
993 my $syndetics_excerpt = &get_syndetics_excerpt($isbn,$upc,$oclc);
994 $template->param( SYNDETICS_EXCERPT => $syndetics_excerpt );
996 warn $@ if $@;
999 if ( C4::Context->preference("SyndeticsEnabled")
1000 && C4::Context->preference("SyndeticsReviews")) {
1001 eval {
1002 my $syndetics_reviews = &get_syndetics_reviews($isbn,$upc,$oclc,$syndetics_elements);
1003 $template->param( SYNDETICS_REVIEWS => $syndetics_reviews );
1005 warn $@ if $@;
1008 if ( C4::Context->preference("SyndeticsEnabled")
1009 && C4::Context->preference("SyndeticsAuthorNotes")
1010 && exists($syndetics_elements->{'ANOTES'}) ) {
1011 eval {
1012 my $syndetics_anotes = &get_syndetics_anotes($isbn,$upc,$oclc);
1013 $template->param( SYNDETICS_ANOTES => $syndetics_anotes );
1015 warn $@ if $@;
1018 # LibraryThingForLibraries ID Code and Tabbed View Option
1019 if( C4::Context->preference('LibraryThingForLibrariesEnabled') )
1021 $template->param(LibraryThingForLibrariesID =>
1022 C4::Context->preference('LibraryThingForLibrariesID') );
1023 $template->param(LibraryThingForLibrariesTabbedView =>
1024 C4::Context->preference('LibraryThingForLibrariesTabbedView') );
1027 # Novelist Select
1028 if( C4::Context->preference('NovelistSelectEnabled') )
1030 $template->param(NovelistSelectProfile => C4::Context->preference('NovelistSelectProfile') );
1031 $template->param(NovelistSelectPassword => C4::Context->preference('NovelistSelectPassword') );
1032 $template->param(NovelistSelectView => C4::Context->preference('NovelistSelectView') );
1036 # Babelthèque
1037 if ( C4::Context->preference("Babeltheque") ) {
1038 $template->param(
1039 Babeltheque => 1,
1040 Babeltheque_url_js => C4::Context->preference("Babeltheque_url_js"),
1044 # Social Networks
1045 if ( C4::Context->preference( "SocialNetworks" ) ) {
1046 $template->param( current_url => C4::Context->preference('OPACBaseURL') . "/cgi-bin/koha/opac-detail.pl?biblionumber=$biblionumber" );
1047 $template->param( SocialNetworks => 1 );
1050 # Shelf Browser Stuff
1051 if (C4::Context->preference("OPACShelfBrowser")) {
1052 my $starting_itemnumber = $query->param('shelfbrowse_itemnumber');
1053 if (defined($starting_itemnumber)) {
1054 $template->param( OpenOPACShelfBrowser => 1) if $starting_itemnumber;
1055 my $nearby = GetNearbyItems($starting_itemnumber);
1057 $template->param(
1058 starting_itemnumber => $starting_itemnumber,
1059 starting_homebranch => $nearby->{starting_homebranch}->{description},
1060 starting_location => $nearby->{starting_location}->{description},
1061 starting_ccode => $nearby->{starting_ccode}->{description},
1062 shelfbrowser_prev_item => $nearby->{prev_item},
1063 shelfbrowser_next_item => $nearby->{next_item},
1064 shelfbrowser_items => $nearby->{items},
1067 # in which tab shelf browser should open ?
1068 if (grep { $starting_itemnumber == $_->{itemnumber} } @itemloop) {
1069 $template->param(shelfbrowser_tab => 'holdings');
1070 } else {
1071 $template->param(shelfbrowser_tab => 'otherholdings');
1076 $template->param( AmazonTld => get_amazon_tld() ) if ( C4::Context->preference("OPACAmazonCoverImages"));
1078 if (C4::Context->preference("BakerTaylorEnabled")) {
1079 $template->param(
1080 BakerTaylorEnabled => 1,
1081 BakerTaylorImageURL => &image_url(),
1082 BakerTaylorLinkURL => &link_url(),
1083 BakerTaylorBookstoreURL => C4::Context->preference('BakerTaylorBookstoreURL'),
1085 my ($bt_user, $bt_pass);
1086 if ($isbn and
1087 $bt_user = C4::Context->preference('BakerTaylorUsername') and
1088 $bt_pass = C4::Context->preference('BakerTaylorPassword') )
1090 $template->param(
1091 BakerTaylorContentURL =>
1092 sprintf("https://contentcafe2.btol.com/ContentCafeClient/ContentCafe.aspx?UserID=%s&Password=%s&ItemKey=%s&Options=Y",
1093 $bt_user,$bt_pass,$isbn)
1098 my $tag_quantity;
1099 if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->preference('TagsShowOnDetail')) {
1100 $template->param(
1101 TagsEnabled => 1,
1102 TagsShowOnDetail => $tag_quantity,
1103 TagsInputOnDetail => C4::Context->preference('TagsInputOnDetail')
1105 $template->param(TagLoop => get_tags({biblionumber=>$biblionumber, approved=>1,
1106 'sort'=>'-weight', limit=>$tag_quantity}));
1109 if (C4::Context->preference("OPACURLOpenInNewWindow")) {
1110 # These values are going to be read by Javascript, at least in the case
1111 # of the google covers
1112 $template->param(covernewwindow => 'true');
1113 } else {
1114 $template->param(covernewwindow => 'false');
1117 $template->param(borrowernumber => $borrowernumber);
1119 if ( C4::Context->preference('OpacStarRatings') !~ /disable/ ) {
1120 my $ratings = Koha::Ratings->search({ biblionumber => $biblionumber });
1121 my $my_rating = $borrowernumber ? $ratings->search({ borrowernumber => $borrowernumber })->next : undef;
1122 $template->param(
1123 ratings => $ratings,
1124 my_rating => $my_rating,
1128 #Search for title in links
1129 my $marccontrolnumber = GetMarcControlnumber ($record, $marcflavour);
1130 my $marcissns = GetMarcISSN ( $record, $marcflavour );
1131 my $issn = $marcissns->[0] || '';
1133 if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
1134 $dat->{title} =~ s/\/+$//; # remove trailing slash
1135 $dat->{title} =~ s/\s+$//; # remove trailing space
1136 $search_for_title = parametrized_url(
1137 $search_for_title,
1139 TITLE => $dat->{title},
1140 AUTHOR => $dat->{author},
1141 ISBN => $isbn,
1142 ISSN => $issn,
1143 CONTROLNUMBER => $marccontrolnumber,
1144 BIBLIONUMBER => $biblionumber,
1147 $template->param('OPACSearchForTitleIn' => $search_for_title);
1150 #IDREF
1151 if ( C4::Context->preference("IDREF") ) {
1152 # If the record comes from the SUDOC
1153 if ( $record->field('009') ) {
1154 my $unimarc3 = $record->field("009")->data;
1155 if ( $unimarc3 =~ /^\d+$/ ) {
1156 $template->param(
1157 IDREF => 1,
1163 # We try to select the best default tab to show, according to what
1164 # the user wants, and what's available for display
1165 my $opac_serial_default = C4::Context->preference('opacSerialDefaultTab');
1166 my $defaulttab =
1167 $viewallitems
1168 ? 'holdings' :
1169 $opac_serial_default eq 'subscriptions' && $subscriptionsnumber
1170 ? 'subscriptions' :
1171 $opac_serial_default eq 'serialcollection' && @serialcollections > 0
1172 ? 'serialcollection' :
1173 $opac_serial_default eq 'holdings' && scalar (@itemloop) > 0
1174 ? 'holdings' :
1175 scalar (@itemloop) == 0
1176 ? 'media' :
1177 $subscriptionsnumber
1178 ? 'subscriptions' :
1179 @serialcollections > 0
1180 ? 'serialcollection' : 'subscriptions';
1181 $template->param('defaulttab' => $defaulttab);
1183 if (C4::Context->preference('OPACLocalCoverImages') == 1) {
1184 my @images = ListImagesForBiblio($biblionumber);
1185 $template->{VARS}->{localimages} = \@images;
1188 $template->{VARS}->{IDreamBooksReviews} = C4::Context->preference('IDreamBooksReviews');
1189 $template->{VARS}->{IDreamBooksReadometer} = C4::Context->preference('IDreamBooksReadometer');
1190 $template->{VARS}->{IDreamBooksResults} = C4::Context->preference('IDreamBooksResults');
1191 $template->{VARS}->{OPACPopupAuthorsSearch} = C4::Context->preference('OPACPopupAuthorsSearch');
1193 if (C4::Context->preference('OpacHighlightedWords')) {
1194 $template->{VARS}->{query_desc} = $query->param('query_desc');
1196 $template->{VARS}->{'trackclicks'} = C4::Context->preference('TrackClicks');
1198 if ( C4::Context->preference('UseCourseReserves') ) {
1199 foreach my $i ( @items ) {
1200 $i->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $i->{'itemnumber'} );
1204 $template->param(
1205 'OpacLocationBranchToDisplay' => C4::Context->preference('OpacLocationBranchToDisplay'),
1208 output_html_with_http_headers $query, $cookie, $template->output;