Bug 26008: Remove the use of jquery.checkboxes plugin from OPAC cart
[koha.git] / opac / opac-detail.pl
blobb6a5b0b1ffd10bd0ca3eda39df2d5ddf75e1d054
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::BakerTaylor qw( image_url link_url );
38 use C4::External::Syndetics qw(get_syndetics_index get_syndetics_summary get_syndetics_toc get_syndetics_excerpt get_syndetics_reviews get_syndetics_anotes );
39 use C4::Members;
40 use C4::XSLT;
41 use C4::ShelfBrowser;
42 use C4::Reserves;
43 use C4::Charset;
44 use C4::Letters;
45 use MARC::Record;
46 use MARC::Field;
47 use List::MoreUtils qw/any none/;
48 use C4::Images;
49 use Koha::DateUtils;
50 use C4::HTML5Media;
51 use C4::CourseReserves qw(GetItemCourseReservesInfo);
53 use Koha::Biblios;
54 use Koha::RecordProcessor;
55 use Koha::AuthorisedValues;
56 use Koha::CirculationRules;
57 use Koha::Items;
58 use Koha::ItemTypes;
59 use Koha::Acquisition::Orders;
60 use Koha::Virtualshelves;
61 use Koha::Patrons;
62 use Koha::Plugins;
63 use Koha::Ratings;
64 use Koha::Reviews;
66 use Try::Tiny;
68 my $query = CGI->new();
70 my $biblionumber = $query->param('biblionumber') || $query->param('bib') || 0;
71 $biblionumber = int($biblionumber);
73 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
75 template_name => "opac-detail.tt",
76 query => $query,
77 type => "opac",
78 authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
82 my @all_items = GetItemsInfo($biblionumber);
83 my @hiddenitems;
84 my $patron = Koha::Patrons->find( $borrowernumber );
85 our $borcat= q{};
86 if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
87 $borcat = $patron ? $patron->categorycode : q{};
90 my $record = GetMarcBiblio({
91 biblionumber => $biblionumber,
92 opac => 1 });
93 if ( ! $record ) {
94 print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
95 exit;
98 if ( scalar @all_items >= 1 ) {
99 push @hiddenitems,
100 GetHiddenItemnumbers( { items => \@all_items, borcat => $borcat } );
102 if (scalar @hiddenitems == scalar @all_items ) {
103 print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
104 exit;
108 my $biblio = Koha::Biblios->find( $biblionumber );
109 my $framework = $biblio ? $biblio->frameworkcode : q{};
110 my $record_processor = Koha::RecordProcessor->new({
111 filters => 'ViewPolicy',
112 options => {
113 interface => 'opac',
114 frameworkcode => $framework
117 $record_processor->process($record);
119 # redirect if opacsuppression is enabled and biblio is suppressed
120 if (C4::Context->preference('OpacSuppression')) {
121 # FIXME hardcoded; the suppression flag ought to be materialized
122 # as a column on biblio or the like
123 my $opacsuppressionfield = '942';
124 my $opacsuppressionfieldvalue = $record->field($opacsuppressionfield);
125 # redirect to opac-blocked info page or 404?
126 my $opacsuppressionredirect;
127 if ( C4::Context->preference("OpacSuppressionRedirect") ) {
128 $opacsuppressionredirect = "/cgi-bin/koha/opac-blocked.pl";
129 } else {
130 $opacsuppressionredirect = "/cgi-bin/koha/errors/404.pl";
132 if ( $opacsuppressionfieldvalue &&
133 $opacsuppressionfieldvalue->subfield("n") &&
134 $opacsuppressionfieldvalue->subfield("n") == 1) {
135 # if OPAC suppression by IP address
136 if (C4::Context->preference('OpacSuppressionByIPRange')) {
137 my $IPAddress = $ENV{'REMOTE_ADDR'};
138 my $IPRange = C4::Context->preference('OpacSuppressionByIPRange');
139 if ($IPAddress !~ /^$IPRange/) {
140 print $query->redirect($opacsuppressionredirect);
141 exit;
143 } else {
144 print $query->redirect($opacsuppressionredirect);
145 exit;
150 $template->param(
151 biblio => $biblio
154 # get biblionumbers stored in the cart
155 my @cart_list;
157 if($query->cookie("bib_list")){
158 my $cart_list = $query->cookie("bib_list");
159 @cart_list = split(/\//, $cart_list);
160 if ( grep {$_ eq $biblionumber} @cart_list) {
161 $template->param( incart => 1 );
166 SetUTF8Flag($record);
167 my $marcflavour = C4::Context->preference("marcflavour");
168 my $ean = GetNormalizedEAN( $record, $marcflavour );
170 # XSLT processing of some stuff
171 my $xslfile = C4::Context->preference('OPACXSLTDetailsDisplay');
172 my $lang = $xslfile ? C4::Languages::getlanguage() : undef;
173 my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef;
175 if ( $xslfile ) {
177 my $variables = {
178 anonymous_session => ($borrowernumber) ? 0 : 1
181 if ( C4::Context->config("enable_plugins") ) {
183 my @plugins = Koha::Plugins->new->GetPlugins({
184 method => 'opac_detail_xslt_variables',
187 if (@plugins) {
188 foreach my $plugin ( @plugins ) {
189 try {
190 my $plugin_variables = $plugin->opac_detail_xslt_variables(
192 biblio_id => $biblionumber,
193 lang => $lang,
194 patron_id => $borrowernumber
197 $variables = { %$variables, %$plugin_variables };
199 catch {
200 warn "$_";
206 $template->param(
207 XSLTBloc => XSLTParse4Display(
208 $biblionumber, $record, "OPACXSLTDetailsDisplay", 1, undef,
209 $sysxml, $xslfile, $lang, $variables
214 my $OpacBrowseResults = C4::Context->preference("OpacBrowseResults");
216 # We look for the busc param to build the simple paging from the search
217 if ($OpacBrowseResults) {
218 my $session = get_session($query->cookie("CGISESSID"));
219 my %paging = (previous => {}, next => {});
220 if ($session->param('busc')) {
221 use C4::Search;
222 use URI::Escape;
224 # Rebuild the string to store on session
225 # param value is URI encoded and params separator is HTML encode (&amp;)
226 sub rebuildBuscParam
228 my $arrParamsBusc = shift;
230 my $pasarParams = '';
231 my $j = 0;
232 for (keys %$arrParamsBusc) {
233 if ($_ =~ /^(?:query|listBiblios|newlistBiblios|query_type|simple_query|total|offset|offsetSearch|next|previous|count|expand|scan)/) {
234 if (defined($arrParamsBusc->{$_})) {
235 $pasarParams .= '&amp;' if ($j);
236 $pasarParams .= $_ . '=' . Encode::decode('UTF-8', uri_escape_utf8( $arrParamsBusc->{$_} ));
237 $j++;
239 } else {
240 for my $value (@{$arrParamsBusc->{$_}}) {
241 next if !defined($value);
242 $pasarParams .= '&amp;' if ($j);
243 $pasarParams .= $_ . '=' . Encode::decode('UTF-8', uri_escape_utf8($value));
244 $j++;
248 return $pasarParams;
249 }#rebuildBuscParam
251 # Search given the current values from the busc param
252 sub searchAgain
254 my ($arrParamsBusc, $offset, $results_per_page) = @_;
256 my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
257 my @servers;
258 @servers = @{$arrParamsBusc->{'server'}} if $arrParamsBusc->{'server'};
259 @servers = ("biblioserver") unless (@servers);
261 my ($default_sort_by, @sort_by);
262 $default_sort_by = C4::Context->preference('OPACdefaultSortField')."_".C4::Context->preference('OPACdefaultSortOrder') if (C4::Context->preference('OPACdefaultSortField') && C4::Context->preference('OPACdefaultSortOrder'));
263 @sort_by = @{$arrParamsBusc->{'sort_by'}} if $arrParamsBusc->{'sort_by'};
264 $sort_by[0] = $default_sort_by if !$sort_by[0] && defined($default_sort_by);
265 my ($error, $results_hashref, $facets);
266 eval {
267 ($error, $results_hashref, $facets) = getRecords($arrParamsBusc->{'query'},$arrParamsBusc->{'simple_query'},\@sort_by,\@servers,$results_per_page,$offset,undef,$itemtypes,$arrParamsBusc->{'query_type'},$arrParamsBusc->{'scan'});
269 my $hits;
270 my @newresults;
271 my $search_context = {
272 'interface' => 'opac',
273 'category' => $borcat
275 for (my $i=0;$i<@servers;$i++) {
276 my $server = $servers[$i];
277 $hits = $results_hashref->{$server}->{"hits"};
278 @newresults = searchResults( $search_context, '', $hits, $results_per_page, $offset, $arrParamsBusc->{'scan'}, $results_hashref->{$server}->{"RECORDS"});
280 return \@newresults;
281 }#searchAgain
283 # Build the current list of biblionumbers in this search
284 sub buildListBiblios
286 my ($newresultsRef, $results_per_page) = @_;
288 my $listBiblios = '';
289 my $j = 0;
290 foreach (@$newresultsRef) {
291 my $bibnum = ($_->{biblionumber})?$_->{biblionumber}:0;
292 $listBiblios .= $bibnum . ',';
293 $j++;
294 last if ($j == $results_per_page);
296 chop $listBiblios if ($listBiblios =~ /,$/);
297 return $listBiblios;
298 }#buildListBiblios
300 my $busc = $session->param("busc");
301 my @arrBusc = split(/\&(?:amp;)?/, $busc);
302 my ($key, $value);
303 my %arrParamsBusc = ();
304 for (@arrBusc) {
305 ($key, $value) = split(/=/, $_, 2);
306 if ($key =~ /^(?:query|listBiblios|newlistBiblios|query_type|simple_query|next|previous|total|offset|offsetSearch|count|expand|scan)/) {
307 $arrParamsBusc{$key} = uri_unescape($value);
308 } else {
309 unless (exists($arrParamsBusc{$key})) {
310 $arrParamsBusc{$key} = [];
312 push @{$arrParamsBusc{$key}}, uri_unescape($value);
315 my $searchAgain = 0;
316 my $count = C4::Context->preference('OPACnumSearchResults') || 20;
317 my $results_per_page = ($arrParamsBusc{'count'} && $arrParamsBusc{'count'} =~ /^[0-9]+?/)?$arrParamsBusc{'count'}:$count;
318 $arrParamsBusc{'count'} = $results_per_page;
319 my $offset = ($arrParamsBusc{'offset'} && $arrParamsBusc{'offset'} =~ /^[0-9]+?/)?$arrParamsBusc{'offset'}:0;
320 # The value OPACnumSearchResults has changed and the search has to be rebuild
321 if ($count != $results_per_page) {
322 if (exists($arrParamsBusc{'listBiblios'}) && $arrParamsBusc{'listBiblios'} =~ /^[0-9]+(?:,[0-9]+)*$/) {
323 my $indexBiblio = 0;
324 my @arrBibliosAux = split(',', $arrParamsBusc{'listBiblios'});
325 for (@arrBibliosAux) {
326 last if ($_ == $biblionumber);
327 $indexBiblio++;
329 $indexBiblio += $offset;
330 $offset = int($indexBiblio / $count) * $count;
331 $arrParamsBusc{'offset'} = $offset;
333 $arrParamsBusc{'count'} = $count;
334 $results_per_page = $count;
335 my $newresultsRef = searchAgain(\%arrParamsBusc, $offset, $results_per_page);
336 $arrParamsBusc{'listBiblios'} = buildListBiblios($newresultsRef, $results_per_page);
337 delete $arrParamsBusc{'previous'} if (exists($arrParamsBusc{'previous'}));
338 delete $arrParamsBusc{'next'} if (exists($arrParamsBusc{'next'}));
339 delete $arrParamsBusc{'offsetSearch'} if (exists($arrParamsBusc{'offsetSearch'}));
340 delete $arrParamsBusc{'newlistBiblios'} if (exists($arrParamsBusc{'newlistBiblios'}));
341 my $newbusc = rebuildBuscParam(\%arrParamsBusc);
342 $session->param("busc" => $newbusc);
343 @arrBusc = split(/\&(?:amp;)?/, $newbusc);
344 } else {
345 my $modifyListBiblios = 0;
346 # We come from a previous click
347 if (exists($arrParamsBusc{'previous'})) {
348 $modifyListBiblios = 1 if ($biblionumber == $arrParamsBusc{'previous'});
349 delete $arrParamsBusc{'previous'};
350 } elsif (exists($arrParamsBusc{'next'})) { # We come from a next click
351 $modifyListBiblios = 2 if ($biblionumber == $arrParamsBusc{'next'});
352 delete $arrParamsBusc{'next'};
354 if ($modifyListBiblios) {
355 if (exists($arrParamsBusc{'newlistBiblios'})) {
356 my $listBibliosAux = $arrParamsBusc{'listBiblios'};
357 $arrParamsBusc{'listBiblios'} = $arrParamsBusc{'newlistBiblios'};
358 my @arrAux = split(',', $listBibliosAux);
359 $arrParamsBusc{'newlistBiblios'} = $listBibliosAux;
360 if ($modifyListBiblios == 1) {
361 $arrParamsBusc{'next'} = $arrAux[0];
362 $paging{'next'}->{biblionumber} = $arrAux[0];
363 }else {
364 $arrParamsBusc{'previous'} = $arrAux[$#arrAux];
365 $paging{'previous'}->{biblionumber} = $arrAux[$#arrAux];
367 } else {
368 delete $arrParamsBusc{'listBiblios'};
370 my $offsetAux = $arrParamsBusc{'offset'};
371 $arrParamsBusc{'offset'} = $arrParamsBusc{'offsetSearch'};
372 $arrParamsBusc{'offsetSearch'} = $offsetAux;
373 $offset = $arrParamsBusc{'offset'};
374 my $newbusc = rebuildBuscParam(\%arrParamsBusc);
375 $session->param("busc" => $newbusc);
376 @arrBusc = split(/\&(?:amp;)?/, $newbusc);
379 my $buscParam = '';
380 my $j = 0;
381 # Rebuild the query for the button "back to results"
382 for (@arrBusc) {
383 unless ($_ =~ /^(?:query|listBiblios|newlistBiblios|query_type|simple_query|next|previous|total|count|offsetSearch)/) {
384 $buscParam .= '&amp;' unless ($j == 0);
385 $buscParam .= $_; # string already URI encoded
386 $j++;
389 $template->param('busc' => $buscParam);
390 my $offsetSearch;
391 my @arrBiblios;
392 # We are inside the list of biblios and we don't have to search
393 if (exists($arrParamsBusc{'listBiblios'}) && $arrParamsBusc{'listBiblios'} =~ /^[0-9]+(?:,[0-9]+)*$/) {
394 @arrBiblios = split(',', $arrParamsBusc{'listBiblios'});
395 if (@arrBiblios) {
396 # We are at the first item of the list
397 if ($arrBiblios[0] == $biblionumber) {
398 if (@arrBiblios > 1) {
399 for (my $j = 1; $j < @arrBiblios; $j++) {
400 next unless ($arrBiblios[$j]);
401 $paging{'next'}->{biblionumber} = $arrBiblios[$j];
402 last;
405 # search again if we are not at the first searching list
406 if ($offset && !$arrParamsBusc{'previous'}) {
407 $searchAgain = 1;
408 $offsetSearch = $offset - $results_per_page;
410 # we are at the last item of the list
411 } elsif ($arrBiblios[$#arrBiblios] == $biblionumber) {
412 for (my $j = $#arrBiblios - 1; $j >= 0; $j--) {
413 next unless ($arrBiblios[$j]);
414 $paging{'previous'}->{biblionumber} = $arrBiblios[$j];
415 last;
417 if (!$offset) {
418 # search again if we are at the first list and there is more results
419 $searchAgain = 1 if (!$arrParamsBusc{'next'} && $arrParamsBusc{'total'} != @arrBiblios);
420 } else {
421 # search again if we aren't at the first list and there is more results
422 $searchAgain = 1 if (!$arrParamsBusc{'next'} && $arrParamsBusc{'total'} > ($offset + @arrBiblios));
424 $offsetSearch = $offset + $results_per_page if ($searchAgain);
425 } else {
426 for (my $j = 1; $j < $#arrBiblios; $j++) {
427 if ($arrBiblios[$j] == $biblionumber) {
428 for (my $z = $j - 1; $z >= 0; $z--) {
429 next unless ($arrBiblios[$z]);
430 $paging{'previous'}->{biblionumber} = $arrBiblios[$z];
431 last;
433 for (my $z = $j + 1; $z < @arrBiblios; $z++) {
434 next unless ($arrBiblios[$z]);
435 $paging{'next'}->{biblionumber} = $arrBiblios[$z];
436 last;
438 last;
443 $offsetSearch = 0 if (defined($offsetSearch) && $offsetSearch < 0);
445 if ($searchAgain) {
446 my $newresultsRef = searchAgain(\%arrParamsBusc, $offsetSearch, $results_per_page);
447 my @newresults = @$newresultsRef;
448 # build the new listBiblios
449 my $listBiblios = buildListBiblios(\@newresults, $results_per_page);
450 unless (exists($arrParamsBusc{'listBiblios'})) {
451 $arrParamsBusc{'listBiblios'} = $listBiblios;
452 @arrBiblios = split(',', $arrParamsBusc{'listBiblios'});
453 } else {
454 $arrParamsBusc{'newlistBiblios'} = $listBiblios;
456 # From the new list we build again the next and previous result
457 if (@arrBiblios) {
458 if ($arrBiblios[0] == $biblionumber) {
459 for (my $j = $#newresults; $j >= 0; $j--) {
460 next unless ($newresults[$j]);
461 $paging{'previous'}->{biblionumber} = $newresults[$j]->{biblionumber};
462 $arrParamsBusc{'previous'} = $paging{'previous'}->{biblionumber};
463 $arrParamsBusc{'offsetSearch'} = $offsetSearch;
464 last;
466 } elsif ($arrBiblios[$#arrBiblios] == $biblionumber) {
467 for (my $j = 0; $j < @newresults; $j++) {
468 next unless ($newresults[$j]);
469 $paging{'next'}->{biblionumber} = $newresults[$j]->{biblionumber};
470 $arrParamsBusc{'next'} = $paging{'next'}->{biblionumber};
471 $arrParamsBusc{'offsetSearch'} = $offsetSearch;
472 last;
476 # build new busc param
477 my $newbusc = rebuildBuscParam(\%arrParamsBusc);
478 $session->param("busc" => $newbusc);
480 my ($numberBiblioPaging, $dataBiblioPaging);
481 # Previous biblio
482 $numberBiblioPaging = $paging{'previous'}->{biblionumber};
483 if ($numberBiblioPaging) {
484 $template->param( 'previousBiblionumber' => $numberBiblioPaging );
485 $dataBiblioPaging = Koha::Biblios->find( $numberBiblioPaging );
486 $template->param('previousTitle' => $dataBiblioPaging->title) if $dataBiblioPaging;
488 # Next biblio
489 $numberBiblioPaging = $paging{'next'}->{biblionumber};
490 if ($numberBiblioPaging) {
491 $template->param( 'nextBiblionumber' => $numberBiblioPaging );
492 $dataBiblioPaging = Koha::Biblios->find( $numberBiblioPaging );
493 $template->param('nextTitle' => $dataBiblioPaging->title) if $dataBiblioPaging;
495 # Partial list of biblio results
496 my @listResults;
497 for (my $j = 0; $j < @arrBiblios; $j++) {
498 next unless ($arrBiblios[$j]);
499 $dataBiblioPaging = Koha::Biblios->find( $arrBiblios[$j] ) if ($arrBiblios[$j] != $biblionumber);
500 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]};
502 $template->param('listResults' => \@listResults) if (@listResults);
503 $template->param('indexPag' => 1 + $offset, 'totalPag' => $arrParamsBusc{'total'}, 'indexPagEnd' => scalar(@arrBiblios) + $offset);
504 $template->param( 'offset' => $offset );
508 $template->param(
509 OPACShowCheckoutName => C4::Context->preference("OPACShowCheckoutName"),
512 if ( C4::Context->preference('EasyAnalyticalRecords') ) {
513 # adding items linked via host biblios
514 my $analyticfield = '773';
515 if ($marcflavour eq 'MARC21' || $marcflavour eq 'NORMARC'){
516 $analyticfield = '773';
517 } elsif ($marcflavour eq 'UNIMARC') {
518 $analyticfield = '461';
520 foreach my $hostfield ( $record->field($analyticfield)) {
521 my $hostbiblionumber = $hostfield->subfield("0");
522 my $linkeditemnumber = $hostfield->subfield("9");
523 my @hostitemInfos = GetItemsInfo($hostbiblionumber);
524 foreach my $hostitemInfo (@hostitemInfos){
525 if ($hostitemInfo->{itemnumber} eq $linkeditemnumber){
526 push(@all_items, $hostitemInfo);
532 my @items;
534 # Are there items to hide?
535 my $hideitems;
536 $hideitems = 1 if C4::Context->preference('hidelostitems') or scalar(@hiddenitems) > 0;
538 # Hide items
539 if ($hideitems) {
540 for my $itm (@all_items) {
541 if ( C4::Context->preference('hidelostitems') ) {
542 push @items, $itm unless $itm->{itemlost} or any { $itm->{'itemnumber'} eq $_ } @hiddenitems;
543 } else {
544 push @items, $itm unless any { $itm->{'itemnumber'} eq $_ } @hiddenitems;
547 } else {
548 # Or not
549 @items = @all_items;
552 my $branch = '';
553 if (C4::Context->userenv){
554 $branch = C4::Context->userenv->{branch};
556 if ( C4::Context->preference('HighlightOwnItemsOnOPAC') ) {
557 if (
558 ( ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) && $branch )
560 C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch'
562 my $branchcode;
563 if ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) {
564 $branchcode = $branch;
566 elsif ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch' ) {
567 $branchcode = $ENV{'BRANCHCODE'};
570 my @our_items;
571 my @other_items;
573 foreach my $item ( @items ) {
574 if ( $item->{branchcode} eq $branchcode ) {
575 $item->{'this_branch'} = 1;
576 push( @our_items, $item );
577 } else {
578 push( @other_items, $item );
582 @items = ( @our_items, @other_items );
586 my $dat = &GetBiblioData($biblionumber);
587 my $HideMARC = $record_processor->filters->[0]->should_hide_marc(
589 frameworkcode => $dat->{'frameworkcode'},
590 interface => 'opac',
591 } );
593 my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
594 # imageurl:
595 my $itemtype = $dat->{'itemtype'};
596 if ( $itemtype ) {
597 $dat->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} );
598 $dat->{'description'} = $itemtypes->{$itemtype}->{translated_description};
601 my $shelflocations =
602 { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.location' } ) };
603 my $collections =
604 { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.ccode' } ) };
605 my $copynumbers =
606 { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.copynumber' } ) };
608 #coping with subscriptions
609 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
610 my @subscriptions = SearchSubscriptions({ biblionumber => $biblionumber, orderby => 'title' });
612 my @subs;
613 $dat->{'serial'}=1 if $subscriptionsnumber;
614 foreach my $subscription (@subscriptions) {
615 my $serials_to_display;
616 my %cell;
617 $cell{subscriptionid} = $subscription->{subscriptionid};
618 $cell{subscriptionnotes} = $subscription->{notes};
619 $cell{missinglist} = $subscription->{missinglist};
620 $cell{opacnote} = $subscription->{opacnote};
621 $cell{histstartdate} = $subscription->{histstartdate};
622 $cell{histenddate} = $subscription->{histenddate};
623 $cell{branchcode} = $subscription->{branchcode};
624 $cell{callnumber} = $subscription->{callnumber};
625 $cell{location} = $subscription->{location};
626 $cell{closed} = $subscription->{closed};
627 $cell{letter} = $subscription->{letter};
628 $cell{biblionumber} = $subscription->{biblionumber};
629 #get the three latest serials.
630 $serials_to_display = $subscription->{opacdisplaycount};
631 $serials_to_display = C4::Context->preference('OPACSerialIssueDisplayCount') unless $serials_to_display;
632 $cell{opacdisplaycount} = $serials_to_display;
633 $cell{latestserials} =
634 GetLatestSerials( $subscription->{subscriptionid}, $serials_to_display );
635 if ( $borrowernumber ) {
636 my $subscription_object = Koha::Subscriptions->find( $subscription->{subscriptionid} );
637 my $subscriber = $subscription_object->subscribers->find( $borrowernumber );
638 $cell{hasalert} = 1 if $subscriber;
640 push @subs, \%cell;
643 $dat->{'count'} = scalar(@items);
646 my (%item_reserves, %priority);
647 my ($show_holds_count, $show_priority);
648 for ( C4::Context->preference("OPACShowHoldQueueDetails") ) {
649 m/holds/o and $show_holds_count = 1;
650 m/priority/ and $show_priority = 1;
652 my $has_hold;
653 if ( $show_holds_count || $show_priority) {
654 my $holds = $biblio->holds;
655 $template->param( holds_count => $holds->count );
656 while ( my $hold = $holds->next ) {
657 $item_reserves{ $hold->itemnumber }++ if $hold->itemnumber;
658 if ($show_priority && $hold->borrowernumber == $borrowernumber) {
659 $has_hold = 1;
660 $hold->itemnumber
661 ? ($priority{ $hold->itemnumber } = $hold->priority)
662 : ($template->param( priority => $hold->priority ));
666 $template->param( show_priority => $has_hold ) ;
668 my $norequests = 1;
669 my %itemfields;
670 my (@itemloop, @otheritemloop);
671 my $currentbranch = C4::Context->userenv ? C4::Context->userenv->{branch} : undef;
672 if ($currentbranch and C4::Context->preference('OpacSeparateHoldings')) {
673 $template->param(SeparateHoldings => 1);
675 my $separatebranch = C4::Context->preference('OpacSeparateHoldingsBranch');
676 my $viewallitems = $query->param('viewallitems');
677 my $max_items_to_display = C4::Context->preference('OpacMaxItemsToDisplay') // 50;
679 # Get items on order
680 my ( @itemnumbers_on_order );
681 if ( C4::Context->preference('OPACAcquisitionDetails' ) ) {
682 my $orders = C4::Acquisition::SearchOrders({
683 biblionumber => $biblionumber,
684 ordered => 1,
686 my $total_quantity = 0;
687 for my $order ( @$orders ) {
688 my $order = Koha::Acquisition::Orders->find( $order->{ordernumber} );
689 my $basket = $order->basket;
690 if ( $basket->effective_create_items eq 'ordering' ) {
691 @itemnumbers_on_order = $order->items->get_column('itemnumber');
693 $total_quantity += $order->quantity;
695 $template->{VARS}->{acquisition_details} = {
696 total_quantity => $total_quantity,
700 my $allow_onshelf_holds;
701 if ( not $viewallitems and @items > $max_items_to_display ) {
702 $template->param(
703 too_many_items => 1,
704 items_count => scalar( @items ),
706 } else {
707 for my $itm (@items) {
708 my $item = Koha::Items->find( $itm->{itemnumber} );
709 $itm->{holds_count} = $item_reserves{ $itm->{itemnumber} };
710 $itm->{priority} = $priority{ $itm->{itemnumber} };
711 $norequests = 0
712 if $norequests
713 && !$itm->{'withdrawn'}
714 && !$itm->{'itemlost'}
715 && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'})
716 && !$itemtypes->{$itm->{'itype'}}->{notforloan}
717 && $itm->{'itemnumber'};
719 $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } )
720 unless $allow_onshelf_holds;
722 # get collection code description, too
723 my $ccode = $itm->{'ccode'};
724 $itm->{'ccode'} = $collections->{$ccode} if defined($ccode) && $collections && exists( $collections->{$ccode} );
725 my $copynumber = $itm->{'copynumber'};
726 $itm->{'copynumber'} = $copynumbers->{$copynumber} if ( defined($copynumbers) && defined($copynumber) && exists( $copynumbers->{$copynumber} ) );
727 if ( defined $itm->{'location'} ) {
728 $itm->{'location_description'} = $shelflocations->{ $itm->{'location'} };
730 if (exists $itm->{itype} && defined($itm->{itype}) && exists $itemtypes->{ $itm->{itype} }) {
731 $itm->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{ $itm->{itype} }->{'imageurl'} );
732 $itm->{'description'} = $itemtypes->{ $itm->{itype} }->{translated_description};
734 foreach (qw(ccode materials enumchron copynumber itemnotes location_description uri)) {
735 $itemfields{$_} = 1 if ($itm->{$_});
738 my $reserve_status = C4::Reserves::GetReserveStatus($itm->{itemnumber});
739 if( $reserve_status eq "Waiting"){ $itm->{'waiting'} = 1; }
740 if( $reserve_status eq "Reserved"){ $itm->{'onhold'} = 1; }
742 my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($itm->{itemnumber});
743 if ( defined( $transfertwhen ) && $transfertwhen ne '' ) {
744 $itm->{transfertwhen} = $transfertwhen;
745 $itm->{transfertfrom} = $transfertfrom;
746 $itm->{transfertto} = $transfertto;
749 if ( C4::Context->preference('OPACAcquisitionDetails') ) {
750 $itm->{on_order} = 1
751 if grep { $_ eq $itm->{itemnumber} } @itemnumbers_on_order;
754 my $itembranch = $itm->{$separatebranch};
755 if ($currentbranch and C4::Context->preference('OpacSeparateHoldings')) {
756 if ($itembranch and $itembranch eq $currentbranch) {
757 push @itemloop, $itm;
758 } else {
759 push @otheritemloop, $itm;
761 } else {
762 push @itemloop, $itm;
767 if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) {
768 $template->param( ReservableItems => 1 );
771 # Display only one tab if one items list is empty
772 if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) {
773 $template->param(SeparateHoldings => 0);
774 if (scalar(@itemloop) == 0) {
775 @itemloop = @otheritemloop;
779 ## get notes and subjects from MARC record
780 if (!C4::Context->preference("OPACXSLTDetailsDisplay") ) {
781 my $marcisbnsarray = GetMarcISBN ($record,$marcflavour);
782 my $marcauthorsarray = GetMarcAuthors ($record,$marcflavour);
783 my $marcsubjctsarray = GetMarcSubjects($record,$marcflavour);
784 my $marcseriesarray = GetMarcSeries ($record,$marcflavour);
785 my $marcurlsarray = GetMarcUrls ($record,$marcflavour);
787 $template->param(
788 MARCSUBJCTS => $marcsubjctsarray,
789 MARCAUTHORS => $marcauthorsarray,
790 MARCSERIES => $marcseriesarray,
791 MARCURLS => $marcurlsarray,
792 MARCISBNS => $marcisbnsarray,
796 my $marcnotesarray = GetMarcNotes ($record,$marcflavour,1);
798 if( C4::Context->preference('ArticleRequests') ) {
799 my $patron = $borrowernumber ? Koha::Patrons->find($borrowernumber) : undef;
800 my $itemtype = Koha::ItemTypes->find($biblio->itemtype);
801 my $artreqpossible = $patron
802 ? $biblio->can_article_request( $patron )
803 : $itemtype
804 ? $itemtype->may_article_request
805 : q{};
806 $template->param( artreqpossible => $artreqpossible );
809 $template->param(
810 MARCNOTES => $marcnotesarray,
811 norequests => $norequests,
812 RequestOnOpac => C4::Context->preference("RequestOnOpac"),
813 itemdata_ccode => $itemfields{ccode},
814 itemdata_materials => $itemfields{materials},
815 itemdata_enumchron => $itemfields{enumchron},
816 itemdata_uri => $itemfields{uri},
817 itemdata_copynumber => $itemfields{copynumber},
818 itemdata_itemnotes => $itemfields{itemnotes},
819 itemdata_location => $itemfields{location_description},
820 OpacStarRatings => C4::Context->preference("OpacStarRatings"),
823 if (C4::Context->preference("AlternateHoldingsField") && scalar @items == 0) {
824 my $fieldspec = C4::Context->preference("AlternateHoldingsField");
825 my $subfields = substr $fieldspec, 3;
826 my $holdingsep = C4::Context->preference("AlternateHoldingsSeparator") || ' ';
827 my @alternateholdingsinfo = ();
828 my @holdingsfields = $record->field(substr $fieldspec, 0, 3);
830 for my $field (@holdingsfields) {
831 my %holding = ( holding => '' );
832 my $havesubfield = 0;
833 for my $subfield ($field->subfields()) {
834 if ((index $subfields, $$subfield[0]) >= 0) {
835 $holding{'holding'} .= $holdingsep if (length $holding{'holding'} > 0);
836 $holding{'holding'} .= $$subfield[1];
837 $havesubfield++;
840 if ($havesubfield) {
841 push(@alternateholdingsinfo, \%holding);
845 $template->param(
846 ALTERNATEHOLDINGS => \@alternateholdingsinfo,
850 # FIXME: The template uses this hash directly. Need to filter.
851 foreach ( keys %{$dat} ) {
852 next if ( $HideMARC->{$_} );
853 $template->param( "$_" => defined $dat->{$_} ? $dat->{$_} : '' );
856 # some useful variables for enhanced content;
857 # in each case, we're grabbing the first value we find in
858 # the record and normalizing it
859 my $upc = GetNormalizedUPC($record,$marcflavour);
860 my $oclc = GetNormalizedOCLCNumber($record,$marcflavour);
861 my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
862 my $content_identifier_exists;
863 if ( $isbn or $ean or $oclc or $upc ) {
864 $content_identifier_exists = 1;
866 $template->param(
867 normalized_upc => $upc,
868 normalized_ean => $ean,
869 normalized_oclc => $oclc,
870 normalized_isbn => $isbn,
871 content_identifier_exists => $content_identifier_exists,
874 # Catch the exception as Koha::Biblio::Metadata->record can explode if the MARCXML is invalid
875 # COinS format FIXME: for books Only
876 my $coins = eval { $biblio->get_coins };
877 $template->param( ocoins => $coins );
879 my ( $loggedincommenter, $reviews );
880 if ( C4::Context->preference('reviewson') ) {
881 $reviews = Koha::Reviews->search(
883 biblionumber => $biblionumber,
884 -or => { approved => 1, borrowernumber => $borrowernumber }
887 order_by => { -desc => 'datereviewed' }
889 )->unblessed;
890 my $libravatar_enabled = 0;
891 if ( C4::Context->preference('ShowReviewer') and C4::Context->preference('ShowReviewerPhoto') ) {
892 eval {
893 require Libravatar::URL;
894 Libravatar::URL->import();
896 if ( !$@ ) {
897 $libravatar_enabled = 1;
900 for my $review (@$reviews) {
901 my $review_patron = Koha::Patrons->find( $review->{borrowernumber} ); # FIXME Should be Koha::Review->reviewer or similar
903 # setting some borrower info into this hash
904 if ( $review_patron ) {
905 $review->{patron} = $review_patron;
906 if ( $libravatar_enabled and $review_patron->email ) {
907 $review->{avatarurl} = libravatar_url( email => $review_patron->email, https => $ENV{HTTPS} );
910 if ( $review_patron->borrowernumber eq $borrowernumber ) {
911 $loggedincommenter = 1;
917 if ( C4::Context->preference("OPACISBD") ) {
918 $template->param( ISBD => 1 );
921 $template->param(
922 itemloop => \@itemloop,
923 otheritemloop => \@otheritemloop,
924 biblionumber => $biblionumber,
925 subscriptions => \@subs,
926 subscriptionsnumber => $subscriptionsnumber,
927 reviews => $reviews,
928 loggedincommenter => $loggedincommenter
931 # Lists
932 if (C4::Context->preference("virtualshelves") ) {
933 my $shelves = Koha::Virtualshelves->search(
935 biblionumber => $biblionumber,
936 category => 2,
939 join => 'virtualshelfcontents',
942 $template->param( shelves => $shelves );
945 # XISBN Stuff
946 if (C4::Context->preference("OPACFRBRizeEditions")==1) {
947 eval {
948 $template->param(
949 XISBNS => scalar get_xisbns($isbn, $biblionumber)
952 if ($@) { warn "XISBN Failed $@"; }
955 # Serial Collection
956 my @sc_fields = $record->field(955);
957 my @lc_fields = $marcflavour eq 'UNIMARC'
958 ? $record->field(930)
959 : $record->field(852);
960 my @serialcollections = ();
962 foreach my $sc_field (@sc_fields) {
963 my %row_data;
965 $row_data{text} = $sc_field->subfield('r');
966 $row_data{branch} = $sc_field->subfield('9');
967 foreach my $lc_field (@lc_fields) {
968 $row_data{itemcallnumber} = $marcflavour eq 'UNIMARC'
969 ? $lc_field->subfield('a') # 930$a
970 : $lc_field->subfield('h') # 852$h
971 if ($sc_field->subfield('5') eq $lc_field->subfield('5'));
974 if ($row_data{text} && $row_data{branch}) {
975 push (@serialcollections, \%row_data);
979 if (scalar(@serialcollections) > 0) {
980 $template->param(
981 serialcollection => 1,
982 serialcollections => \@serialcollections);
985 # Local cover Images stuff
986 if (C4::Context->preference("OPACLocalCoverImages")){
987 $template->param(OPACLocalCoverImages => 1);
990 # HTML5 Media
991 if ( (C4::Context->preference("HTML5MediaEnabled") eq 'both') or (C4::Context->preference("HTML5MediaEnabled") eq 'opac') ) {
992 $template->param( C4::HTML5Media->gethtml5media($record));
995 my $syndetics_elements;
997 if ( C4::Context->preference("SyndeticsEnabled") ) {
998 $template->param("SyndeticsEnabled" => 1);
999 $template->param("SyndeticsClientCode" => C4::Context->preference("SyndeticsClientCode"));
1000 eval {
1001 $syndetics_elements = &get_syndetics_index($isbn,$upc,$oclc);
1002 for my $element (values %$syndetics_elements) {
1003 $template->param("Syndetics$element"."Exists" => 1 );
1004 #warn "Exists: "."Syndetics$element"."Exists";
1007 warn $@ if $@;
1010 if ( C4::Context->preference("SyndeticsEnabled")
1011 && C4::Context->preference("SyndeticsSummary")
1012 && ( exists($syndetics_elements->{'SUMMARY'}) || exists($syndetics_elements->{'AVSUMMARY'}) ) ) {
1013 eval {
1014 my $syndetics_summary = &get_syndetics_summary($isbn,$upc,$oclc, $syndetics_elements);
1015 $template->param( SYNDETICS_SUMMARY => $syndetics_summary );
1017 warn $@ if $@;
1021 if ( C4::Context->preference("SyndeticsEnabled")
1022 && C4::Context->preference("SyndeticsTOC")
1023 && exists($syndetics_elements->{'TOC'}) ) {
1024 eval {
1025 my $syndetics_toc = &get_syndetics_toc($isbn,$upc,$oclc);
1026 $template->param( SYNDETICS_TOC => $syndetics_toc );
1028 warn $@ if $@;
1031 if ( C4::Context->preference("SyndeticsEnabled")
1032 && C4::Context->preference("SyndeticsExcerpt")
1033 && exists($syndetics_elements->{'DBCHAPTER'}) ) {
1034 eval {
1035 my $syndetics_excerpt = &get_syndetics_excerpt($isbn,$upc,$oclc);
1036 $template->param( SYNDETICS_EXCERPT => $syndetics_excerpt );
1038 warn $@ if $@;
1041 if ( C4::Context->preference("SyndeticsEnabled")
1042 && C4::Context->preference("SyndeticsReviews")) {
1043 eval {
1044 my $syndetics_reviews = &get_syndetics_reviews($isbn,$upc,$oclc,$syndetics_elements);
1045 $template->param( SYNDETICS_REVIEWS => $syndetics_reviews );
1047 warn $@ if $@;
1050 if ( C4::Context->preference("SyndeticsEnabled")
1051 && C4::Context->preference("SyndeticsAuthorNotes")
1052 && exists($syndetics_elements->{'ANOTES'}) ) {
1053 eval {
1054 my $syndetics_anotes = &get_syndetics_anotes($isbn,$upc,$oclc);
1055 $template->param( SYNDETICS_ANOTES => $syndetics_anotes );
1057 warn $@ if $@;
1060 # LibraryThingForLibraries ID Code and Tabbed View Option
1061 if( C4::Context->preference('LibraryThingForLibrariesEnabled') )
1063 $template->param(LibraryThingForLibrariesID =>
1064 C4::Context->preference('LibraryThingForLibrariesID') );
1065 $template->param(LibraryThingForLibrariesTabbedView =>
1066 C4::Context->preference('LibraryThingForLibrariesTabbedView') );
1069 # Novelist Select
1070 if( C4::Context->preference('NovelistSelectEnabled') )
1072 $template->param(NovelistSelectProfile => C4::Context->preference('NovelistSelectProfile') );
1073 $template->param(NovelistSelectPassword => C4::Context->preference('NovelistSelectPassword') );
1074 $template->param(NovelistSelectView => C4::Context->preference('NovelistSelectView') );
1078 # Babelthèque
1079 if ( C4::Context->preference("Babeltheque") ) {
1080 $template->param(
1081 Babeltheque => 1,
1082 Babeltheque_url_js => C4::Context->preference("Babeltheque_url_js"),
1086 # Social Networks
1087 if ( C4::Context->preference( "SocialNetworks" ) ) {
1088 $template->param( current_url => C4::Context->preference('OPACBaseURL') . "/cgi-bin/koha/opac-detail.pl?biblionumber=$biblionumber" );
1089 $template->param( SocialNetworks => 1 );
1092 # Shelf Browser Stuff
1093 if (C4::Context->preference("OPACShelfBrowser")) {
1094 my $starting_itemnumber = $query->param('shelfbrowse_itemnumber');
1095 if (defined($starting_itemnumber)) {
1096 $template->param( OpenOPACShelfBrowser => 1) if $starting_itemnumber;
1097 my $nearby = GetNearbyItems($starting_itemnumber);
1099 $template->param(
1100 starting_itemnumber => $starting_itemnumber,
1101 starting_homebranch => $nearby->{starting_homebranch}->{description},
1102 starting_location => $nearby->{starting_location}->{description},
1103 starting_ccode => $nearby->{starting_ccode}->{description},
1104 shelfbrowser_prev_item => $nearby->{prev_item},
1105 shelfbrowser_next_item => $nearby->{next_item},
1106 shelfbrowser_items => $nearby->{items},
1109 # in which tab shelf browser should open ?
1110 if (grep { $starting_itemnumber == $_->{itemnumber} } @itemloop) {
1111 $template->param(shelfbrowser_tab => 'holdings');
1112 } else {
1113 $template->param(shelfbrowser_tab => 'otherholdings');
1118 $template->param( AmazonTld => get_amazon_tld() ) if ( C4::Context->preference("OPACAmazonCoverImages"));
1120 if (C4::Context->preference("BakerTaylorEnabled")) {
1121 $template->param(
1122 BakerTaylorEnabled => 1,
1123 BakerTaylorImageURL => &image_url(),
1124 BakerTaylorLinkURL => &link_url(),
1125 BakerTaylorBookstoreURL => C4::Context->preference('BakerTaylorBookstoreURL'),
1127 my ($bt_user, $bt_pass);
1128 if ($isbn and
1129 $bt_user = C4::Context->preference('BakerTaylorUsername') and
1130 $bt_pass = C4::Context->preference('BakerTaylorPassword') )
1132 $template->param(
1133 BakerTaylorContentURL =>
1134 sprintf("https://contentcafe2.btol.com/ContentCafeClient/ContentCafe.aspx?UserID=%s&Password=%s&ItemKey=%s&Options=Y",
1135 $bt_user,$bt_pass,$isbn)
1140 my $tag_quantity;
1141 if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->preference('TagsShowOnDetail')) {
1142 $template->param(
1143 TagsEnabled => 1,
1144 TagsShowOnDetail => $tag_quantity,
1145 TagsInputOnDetail => C4::Context->preference('TagsInputOnDetail')
1147 $template->param(TagLoop => get_tags({biblionumber=>$biblionumber, approved=>1,
1148 'sort'=>'-weight', limit=>$tag_quantity}));
1151 if (C4::Context->preference("OPACURLOpenInNewWindow")) {
1152 # These values are going to be read by Javascript, at least in the case
1153 # of the google covers
1154 $template->param(covernewwindow => 'true');
1155 } else {
1156 $template->param(covernewwindow => 'false');
1159 $template->param(borrowernumber => $borrowernumber);
1161 if ( C4::Context->preference('OpacStarRatings') !~ /disable/ ) {
1162 my $ratings = Koha::Ratings->search({ biblionumber => $biblionumber });
1163 my $my_rating = $borrowernumber ? $ratings->search({ borrowernumber => $borrowernumber })->next : undef;
1164 $template->param(
1165 ratings => $ratings,
1166 my_rating => $my_rating,
1170 #Search for title in links
1171 my $marccontrolnumber = GetMarcControlnumber ($record, $marcflavour);
1172 my $marcissns = GetMarcISSN ( $record, $marcflavour );
1173 my $issn = $marcissns->[0] || '';
1175 if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
1176 $dat->{title} =~ s/\/+$//; # remove trailing slash
1177 $dat->{title} =~ s/\s+$//; # remove trailing space
1178 $search_for_title = parametrized_url(
1179 $search_for_title,
1181 TITLE => $dat->{title},
1182 AUTHOR => $dat->{author},
1183 ISBN => $isbn,
1184 ISSN => $issn,
1185 CONTROLNUMBER => $marccontrolnumber,
1186 BIBLIONUMBER => $biblionumber,
1189 $template->param('OPACSearchForTitleIn' => $search_for_title);
1192 #IDREF
1193 if ( C4::Context->preference("IDREF") ) {
1194 # If the record comes from the SUDOC
1195 if ( $record->field('009') ) {
1196 my $unimarc3 = $record->field("009")->data;
1197 if ( $unimarc3 =~ /^\d+$/ ) {
1198 $template->param(
1199 IDREF => 1,
1205 # We try to select the best default tab to show, according to what
1206 # the user wants, and what's available for display
1207 my $opac_serial_default = C4::Context->preference('opacSerialDefaultTab');
1208 my $defaulttab =
1209 $viewallitems
1210 ? 'holdings' :
1211 $opac_serial_default eq 'subscriptions' && $subscriptionsnumber
1212 ? 'subscriptions' :
1213 $opac_serial_default eq 'serialcollection' && @serialcollections > 0
1214 ? 'serialcollection' :
1215 $opac_serial_default eq 'holdings' && scalar (@itemloop) > 0
1216 ? 'holdings' :
1217 scalar (@itemloop) == 0
1218 ? 'media' :
1219 $subscriptionsnumber
1220 ? 'subscriptions' :
1221 @serialcollections > 0
1222 ? 'serialcollection' : 'subscriptions';
1223 $template->param('defaulttab' => $defaulttab);
1225 if (C4::Context->preference('OPACLocalCoverImages') == 1) {
1226 my @images = ListImagesForBiblio($biblionumber);
1227 $template->{VARS}->{localimages} = \@images;
1230 $template->{VARS}->{OPACPopupAuthorsSearch} = C4::Context->preference('OPACPopupAuthorsSearch');
1232 if (C4::Context->preference('OpacHighlightedWords')) {
1233 $template->{VARS}->{query_desc} = $query->param('query_desc');
1235 $template->{VARS}->{'trackclicks'} = C4::Context->preference('TrackClicks');
1237 if ( C4::Context->preference('UseCourseReserves') ) {
1238 foreach my $i ( @items ) {
1239 $i->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $i->{'itemnumber'} );
1243 $template->param(
1244 'OpacLocationBranchToDisplay' => C4::Context->preference('OpacLocationBranchToDisplay'),
1247 output_html_with_http_headers $query, $cookie, $template->output;