MT 1713 : Updated opacSerialDefaultTab syspref
[koha.git] / opac / opac-detail.pl
blob2eb819b949cc93e5fc478726b9d8c23ca5fc74fa
1 #!/usr/bin/perl
3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
21 use strict;
22 use warnings;
24 use CGI;
25 use C4::Auth;
26 use C4::Branch;
27 use C4::Koha;
28 use C4::Serials; #uses getsubscriptionfrom biblionumber
29 use C4::Output;
30 use C4::Biblio;
31 use C4::Items;
32 use C4::Circulation;
33 use C4::Tags qw(get_tags);
34 use C4::Dates qw/format_date/;
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::Review;
39 use C4::Serials;
40 use C4::Members;
41 use C4::VirtualShelves;
42 use C4::XSLT;
43 use Switch;
45 BEGIN {
46 if (C4::Context->preference('BakerTaylorEnabled')) {
47 require C4::External::BakerTaylor;
48 import C4::External::BakerTaylor qw(&image_url &link_url);
52 my $query = new CGI;
53 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
55 template_name => "opac-detail.tmpl",
56 query => $query,
57 type => "opac",
58 authnotrequired => 1,
59 flagsrequired => { borrow => 1 },
63 my $biblionumber = $query->param('biblionumber') || $query->param('bib');
65 $template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHolds') );
66 $template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
68 my $record = GetMarcBiblio($biblionumber);
69 $template->param( biblionumber => $biblionumber );
70 # XSLT processing of some stuff
71 if (C4::Context->preference("XSLTDetailsDisplay") ) {
72 $template->param(
73 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, 'Detail') );
76 $template->param('OPACShowCheckoutName' => C4::Context->preference("OPACShowCheckoutName") );
77 # change back when ive fixed request.pl
78 my @all_items = &GetItemsInfo( $biblionumber, 'opac' );
79 my @items;
80 @items = @all_items unless C4::Context->preference('hidelostitems');
82 if (C4::Context->preference('hidelostitems')) {
83 # Hide host items
84 for my $itm (@all_items) {
85 push @items, $itm unless $itm->{itemlost};
88 my $dat = &GetBiblioData($biblionumber);
90 if (!$dat) {
91 print $query->redirect("/cgi-bin/koha/errors/404.pl");
92 exit;
94 my $itemtypes = GetItemTypes();
95 # imageurl:
96 my $itemtype = $dat->{'itemtype'};
97 if ( $itemtype ) {
98 $dat->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} );
99 $dat->{'description'} = $itemtypes->{$itemtype}->{'description'};
101 my $shelflocations =GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'}, 'opac');
102 my $collections = GetKohaAuthorisedValues('items.ccode',$dat->{'frameworkcode'}, 'opac');
104 #coping with subscriptions
105 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
106 my @subscriptions = GetSubscriptions( $dat->{title}, $dat->{issn}, $biblionumber );
108 my @subs;
109 $dat->{'serial'}=1 if $subscriptionsnumber;
110 foreach my $subscription (@subscriptions) {
111 my $serials_to_display;
112 my %cell;
113 $cell{subscriptionid} = $subscription->{subscriptionid};
114 $cell{subscriptionnotes} = $subscription->{notes};
115 $cell{branchcode} = $subscription->{branchcode};
116 $cell{branchname} = GetBranchName($subscription->{branchcode});
117 $cell{hasalert} = $subscription->{hasalert};
118 #get the three latest serials.
119 $serials_to_display = $subscription->{opacdisplaycount};
120 $serials_to_display = C4::Context->preference('OPACSerialIssueDisplayCount') unless $serials_to_display;
121 $cell{opacdisplaycount} = $serials_to_display;
122 $cell{latestserials} =
123 GetLatestSerials( $subscription->{subscriptionid}, $serials_to_display );
124 push @subs, \%cell;
127 $dat->{'count'} = scalar(@items);
129 my $biblio_authorised_value_images = C4::Items::get_authorised_value_images( C4::Biblio::get_biblio_authorised_values( $biblionumber, $record ) );
131 my $norequests = 1;
132 my $branches = GetBranches();
133 my %itemfields;
134 for my $itm (@items) {
135 $norequests = 0
136 if ( (not $itm->{'wthdrawn'} )
137 && (not $itm->{'itemlost'} )
138 && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'} )
139 && (not $itemtypes->{$itm->{'itype'}}->{notforloan} )
140 && ($itm->{'itemnumber'} ) );
142 if ( defined $itm->{'publictype'} ) {
143 # I can't actually find any case in which this is defined. --amoore 2008-12-09
144 $itm->{ $itm->{'publictype'} } = 1;
146 $itm->{datedue} = format_date($itm->{datedue});
147 $itm->{datelastseen} = format_date($itm->{datelastseen});
149 # get collection code description, too
150 if ( my $ccode = $itm->{'ccode'} ) {
151 $itm->{'ccode'} = $collections->{$ccode} if ( defined($collections) && exists( $collections->{$ccode} ) );
153 if ( defined $itm->{'location'} ) {
154 $itm->{'location_description'} = $shelflocations->{ $itm->{'location'} };
156 if (exists $itm->{itype} && defined($itm->{itype}) && exists $itemtypes->{ $itm->{itype} }) {
157 $itm->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{ $itm->{itype} }->{'imageurl'} );
158 $itm->{'description'} = $itemtypes->{ $itm->{itype} }->{'description'};
160 foreach (qw(ccode enumchron copynumber itemnotes uri)) {
161 $itemfields{$_} = 1 if ($itm->{$_});
164 # walk through the item-level authorised values and populate some images
165 my $item_authorised_value_images = C4::Items::get_authorised_value_images( C4::Items::get_item_authorised_values( $itm->{'itemnumber'} ) );
166 # warn( Data::Dumper->Dump( [ $item_authorised_value_images ], [ 'item_authorised_value_images' ] ) );
168 if ( $itm->{'itemlost'} ) {
169 my $lostimageinfo = List::Util::first { $_->{'category'} eq 'LOST' } @$item_authorised_value_images;
170 $itm->{'lostimageurl'} = $lostimageinfo->{ 'imageurl' };
171 $itm->{'lostimagelabel'} = $lostimageinfo->{ 'label' };
174 if( $itm->{'count_reserves'}){
175 if( $itm->{'count_reserves'} eq "Waiting"){ $itm->{'waiting'} = 1; }
176 if( $itm->{'count_reserves'} eq "Reserved"){ $itm->{'onhold'} = 1; }
179 my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($itm->{itemnumber});
180 if ( defined( $transfertwhen ) && $transfertwhen ne '' ) {
181 $itm->{transfertwhen} = format_date($transfertwhen);
182 $itm->{transfertfrom} = $branches->{$transfertfrom}{branchname};
183 $itm->{transfertto} = $branches->{$transfertto}{branchname};
187 ## get notes and subjects from MARC record
188 my $dbh = C4::Context->dbh;
189 my $marcflavour = C4::Context->preference("marcflavour");
190 my $marcnotesarray = GetMarcNotes ($record,$marcflavour);
191 my $marcauthorsarray = GetMarcAuthors ($record,$marcflavour);
192 my $marcsubjctsarray = GetMarcSubjects($record,$marcflavour);
193 my $marcseriesarray = GetMarcSeries ($record,$marcflavour);
194 my $marcurlsarray = GetMarcUrls ($record,$marcflavour);
195 my $subtitle = C4::Biblio::get_koha_field_from_marc('bibliosubtitle', 'subtitle', $record, '');
197 $template->param(
198 MARCNOTES => $marcnotesarray,
199 MARCSUBJCTS => $marcsubjctsarray,
200 MARCAUTHORS => $marcauthorsarray,
201 MARCSERIES => $marcseriesarray,
202 MARCURLS => $marcurlsarray,
203 norequests => $norequests,
204 RequestOnOpac => C4::Context->preference("RequestOnOpac"),
205 itemdata_ccode => $itemfields{ccode},
206 itemdata_enumchron => $itemfields{enumchron},
207 itemdata_uri => $itemfields{uri},
208 itemdata_copynumber => $itemfields{copynumber},
209 itemdata_itemnotes => $itemfields{itemnotes},
210 authorised_value_images => $biblio_authorised_value_images,
211 subtitle => $subtitle,
214 foreach ( keys %{$dat} ) {
215 $template->param( "$_" => defined $dat->{$_} ? $dat->{$_} : '' );
218 # some useful variables for enhanced content;
219 # in each case, we're grabbing the first value we find in
220 # the record and normalizing it
221 my $upc = GetNormalizedUPC($record,$marcflavour);
222 my $ean = GetNormalizedEAN($record,$marcflavour);
223 my $oclc = GetNormalizedOCLCNumber($record,$marcflavour);
224 my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
225 my $content_identifier_exists = 1 if ($isbn or $ean or $oclc or $upc);
226 $template->param(
227 normalized_upc => $upc,
228 normalized_ean => $ean,
229 normalized_oclc => $oclc,
230 normalized_isbn => $isbn,
231 content_identifier_exists => $content_identifier_exists,
234 # COinS format FIXME: for books Only
235 $template->param(
236 ocoins => GetCOinSBiblio($biblionumber),
239 my $reviews = getreviews( $biblionumber, 1 );
240 my $loggedincommenter;
241 foreach ( @$reviews ) {
242 my $borrowerData = GetMember('borrowernumber' => $_->{borrowernumber});
243 # setting some borrower info into this hash
244 $_->{title} = $borrowerData->{'title'};
245 $_->{surname} = $borrowerData->{'surname'};
246 $_->{firstname} = $borrowerData->{'firstname'};
247 $_->{userid} = $borrowerData->{'userid'};
248 $_->{cardnumber} = $borrowerData->{'cardnumber'};
249 $_->{datereviewed} = format_date($_->{datereviewed});
250 if ($borrowerData->{'borrowernumber'} eq $borrowernumber) {
251 $_->{your_comment} = 1;
252 $loggedincommenter = 1;
257 if(C4::Context->preference("ISBD")) {
258 $template->param(ISBD => 1);
261 $template->param(
262 ITEM_RESULTS => \@items,
263 subscriptionsnumber => $subscriptionsnumber,
264 biblionumber => $biblionumber,
265 subscriptions => \@subs,
266 subscriptionsnumber => $subscriptionsnumber,
267 reviews => $reviews,
268 loggedincommenter => $loggedincommenter
271 # Lists
273 if (C4::Context->preference("virtualshelves") ) {
274 $template->param( 'GetShelves' => GetBibliosShelves( $biblionumber ) );
278 # XISBN Stuff
279 if (C4::Context->preference("OPACFRBRizeEditions")==1) {
280 eval {
281 $template->param(
282 XISBNS => get_xisbns($isbn)
285 if ($@) { warn "XISBN Failed $@"; }
288 # Serial Collection
289 my @sc_fields = $record->field(955);
290 my @serialcollections = ();
292 foreach my $sc_field (@sc_fields) {
293 my %row_data;
295 $row_data{text} = $sc_field->subfield('r');
296 $row_data{branch} = $sc_field->subfield('9');
298 if ($row_data{text} && $row_data{branch}) {
299 push (@serialcollections, \%row_data);
303 if (scalar(@serialcollections) > 0) {
304 $template->param(
305 serialcollection => 1,
306 serialcollections => \@serialcollections);
309 # Amazon.com Stuff
310 if ( C4::Context->preference("OPACAmazonEnabled") ) {
311 $template->param( AmazonTld => get_amazon_tld() );
312 my $amazon_reviews = C4::Context->preference("OPACAmazonReviews");
313 my $amazon_similars = C4::Context->preference("OPACAmazonSimilarItems");
314 my @services;
315 if ( $amazon_reviews ) {
316 $template->param( OPACAmazonReviews => 1 );
317 push( @services, 'EditorialReview', 'Reviews' );
319 if ( $amazon_similars ) {
320 $template->param( OPACAmazonSimilarItems => 1 );
321 push( @services, 'Similarities' );
323 my $amazon_details = &get_amazon_details( $isbn, $record, $marcflavour, \@services );
324 my $similar_products_exist;
325 if ( $amazon_reviews ) {
326 my $item = $amazon_details->{Items}->{Item}->[0];
327 my $customer_reviews = \@{ $item->{CustomerReviews}->{Review} };
328 for my $one_review ( @$customer_reviews ) {
329 $one_review->{Date} = format_date($one_review->{Date});
331 my $editorial_reviews = \@{ $item->{EditorialReviews}->{EditorialReview} };
332 my $average_rating = $item->{CustomerReviews}->{AverageRating} || 0;
333 $template->param( amazon_average_rating => $average_rating * 20);
334 $template->param( AMAZON_CUSTOMER_REVIEWS => $customer_reviews );
335 $template->param( AMAZON_EDITORIAL_REVIEWS => $editorial_reviews );
337 if ( $amazon_similars ) {
338 my $item = $amazon_details->{Items}->{Item}->[0];
339 my @similar_products;
340 for my $similar_product (@{ $item->{SimilarProducts}->{SimilarProduct} }) {
341 # do we have any of these isbns in our collection?
342 my $similar_biblionumbers = get_biblionumber_from_isbn($similar_product->{ASIN});
343 # verify that there is at least one similar item
344 if (scalar(@$similar_biblionumbers)){
345 $similar_products_exist++ if ($similar_biblionumbers && $similar_biblionumbers->[0]);
346 push @similar_products, +{ similar_biblionumbers => $similar_biblionumbers, title => $similar_product->{Title}, ASIN => $similar_product->{ASIN} };
349 $template->param( OPACAmazonSimilarItems => $similar_products_exist );
350 $template->param( AMAZON_SIMILAR_PRODUCTS => \@similar_products );
354 my $syndetics_elements;
356 if ( C4::Context->preference("SyndeticsEnabled") ) {
357 eval {
358 $syndetics_elements = &get_syndetics_index($isbn,$upc,$oclc);
359 for my $element (values %$syndetics_elements) {
360 $template->param("Syndetics$element"."Exists" => 1 );
361 #warn "Exists: "."Syndetics$element"."Exists";
364 warn $@ if $@;
367 if ( C4::Context->preference("SyndeticsEnabled")
368 && C4::Context->preference("SyndeticsSummary")
369 && ( exists($syndetics_elements->{'SUMMARY'}) || exists($syndetics_elements->{'AVSUMMARY'}) ) ) {
370 eval {
371 my $syndetics_summary = &get_syndetics_summary($isbn,$upc,$oclc, $syndetics_elements);
372 $template->param( SYNDETICS_SUMMARY => $syndetics_summary );
374 warn $@ if $@;
378 if ( C4::Context->preference("SyndeticsEnabled")
379 && C4::Context->preference("SyndeticsTOC")
380 && exists($syndetics_elements->{'TOC'}) ) {
381 eval {
382 my $syndetics_toc = &get_syndetics_toc($isbn,$upc,$oclc);
383 $template->param( SYNDETICS_TOC => $syndetics_toc );
385 warn $@ if $@;
388 if ( C4::Context->preference("SyndeticsEnabled")
389 && C4::Context->preference("SyndeticsExcerpt")
390 && exists($syndetics_elements->{'DBCHAPTER'}) ) {
391 eval {
392 my $syndetics_excerpt = &get_syndetics_excerpt($isbn,$upc,$oclc);
393 $template->param( SYNDETICS_EXCERPT => $syndetics_excerpt );
395 warn $@ if $@;
398 if ( C4::Context->preference("SyndeticsEnabled")
399 && C4::Context->preference("SyndeticsReviews")) {
400 eval {
401 my $syndetics_reviews = &get_syndetics_reviews($isbn,$upc,$oclc,$syndetics_elements);
402 $template->param( SYNDETICS_REVIEWS => $syndetics_reviews );
404 warn $@ if $@;
407 if ( C4::Context->preference("SyndeticsEnabled")
408 && C4::Context->preference("SyndeticsAuthorNotes")
409 && exists($syndetics_elements->{'ANOTES'}) ) {
410 eval {
411 my $syndetics_anotes = &get_syndetics_anotes($isbn,$upc,$oclc);
412 $template->param( SYNDETICS_ANOTES => $syndetics_anotes );
414 warn $@ if $@;
417 # LibraryThingForLibraries ID Code and Tabbed View Option
418 if( C4::Context->preference('LibraryThingForLibrariesEnabled') )
420 $template->param(LibraryThingForLibrariesID =>
421 C4::Context->preference('LibraryThingForLibrariesID') );
422 $template->param(LibraryThingForLibrariesTabbedView =>
423 C4::Context->preference('LibraryThingForLibrariesTabbedView') );
427 # Babelthèque
428 if ( C4::Context->preference("Babeltheque") ) {
429 $template->param(
430 Babeltheque => 1,
434 # Shelf Browser Stuff
435 if (C4::Context->preference("OPACShelfBrowser")) {
436 # pick the first itemnumber unless one was selected by the user
437 my $starting_itemnumber = $query->param('shelfbrowse_itemnumber'); # || $items[0]->{itemnumber};
438 $template->param( OpenOPACShelfBrowser => 1) if $starting_itemnumber;
439 # find the right cn_sort value for this item
440 my ($starting_cn_sort, $starting_homebranch, $starting_location);
441 my $sth_get_cn_sort = $dbh->prepare("SELECT cn_sort,homebranch,location from items where itemnumber=?");
442 $sth_get_cn_sort->execute($starting_itemnumber);
443 while (my $result = $sth_get_cn_sort->fetchrow_hashref()) {
444 $starting_cn_sort = $result->{'cn_sort'};
445 $starting_homebranch->{code} = $result->{'homebranch'};
446 $starting_homebranch->{description} = $branches->{$result->{'homebranch'}}{branchname};
447 $starting_location->{code} = $result->{'location'};
448 $starting_location->{description} = GetAuthorisedValueDesc('','', $result->{'location'} ,'','','LOC', 'opac');
452 ## List of Previous Items
453 # order by cn_sort, which should include everything we need for ordering purposes (though not
454 # for limits, those need to be handled separately
455 my $sth_shelfbrowse_previous;
456 if (defined $starting_location->{code}) {
457 $sth_shelfbrowse_previous = $dbh->prepare("
458 SELECT *
459 FROM items
460 WHERE
461 ((cn_sort = ? AND itemnumber < ?) OR cn_sort < ?) AND
462 homebranch = ? AND location = ?
463 ORDER BY cn_sort DESC, itemnumber LIMIT 3
465 $sth_shelfbrowse_previous->execute($starting_cn_sort, $starting_itemnumber, $starting_cn_sort, $starting_homebranch->{code}, $starting_location->{code});
466 } else {
467 $sth_shelfbrowse_previous = $dbh->prepare("
468 SELECT *
469 FROM items
470 WHERE
471 ((cn_sort = ? AND itemnumber < ?) OR cn_sort < ?) AND
472 homebranch = ?
473 ORDER BY cn_sort DESC, itemnumber LIMIT 3
475 $sth_shelfbrowse_previous->execute($starting_cn_sort, $starting_itemnumber, $starting_cn_sort, $starting_homebranch->{code});
477 my @previous_items;
478 while (my $this_item = $sth_shelfbrowse_previous->fetchrow_hashref()) {
479 my $sth_get_biblio = $dbh->prepare("SELECT biblio.*,biblioitems.isbn AS isbn FROM biblio LEFT JOIN biblioitems ON biblio.biblionumber=biblioitems.biblionumber WHERE biblio.biblionumber=?");
480 $sth_get_biblio->execute($this_item->{biblionumber});
481 while (my $this_biblio = $sth_get_biblio->fetchrow_hashref()) {
482 $this_item->{'title'} = $this_biblio->{'title'};
483 my $this_record = GetMarcBiblio($this_biblio->{'biblionumber'});
484 $this_item->{'browser_normalized_upc'} = GetNormalizedUPC($this_record,$marcflavour);
485 $this_item->{'browser_normalized_oclc'} = GetNormalizedOCLCNumber($this_record,$marcflavour);
486 $this_item->{'browser_normalized_isbn'} = GetNormalizedISBN(undef,$this_record,$marcflavour);
488 unshift @previous_items, $this_item;
491 ## List of Next Items; this also intentionally catches the current item
492 my $sth_shelfbrowse_next;
493 if (defined $starting_location->{code}) {
494 $sth_shelfbrowse_next = $dbh->prepare("
495 SELECT *
496 FROM items
497 WHERE
498 ((cn_sort = ? AND itemnumber >= ?) OR cn_sort > ?) AND
499 homebranch = ? AND location = ?
500 ORDER BY cn_sort, itemnumber LIMIT 3
502 $sth_shelfbrowse_next->execute($starting_cn_sort, $starting_itemnumber, $starting_cn_sort, $starting_homebranch->{code}, $starting_location->{code});
503 } else {
504 $sth_shelfbrowse_next = $dbh->prepare("
505 SELECT *
506 FROM items
507 WHERE
508 ((cn_sort = ? AND itemnumber >= ?) OR cn_sort > ?) AND
509 homebranch = ?
510 ORDER BY cn_sort, itemnumber LIMIT 3
512 $sth_shelfbrowse_next->execute($starting_cn_sort, $starting_itemnumber, $starting_cn_sort, $starting_homebranch->{code});
514 my @next_items;
515 while (my $this_item = $sth_shelfbrowse_next->fetchrow_hashref()) {
516 my $sth_get_biblio = $dbh->prepare("SELECT biblio.*,biblioitems.isbn AS isbn FROM biblio LEFT JOIN biblioitems ON biblio.biblionumber=biblioitems.biblionumber WHERE biblio.biblionumber=?");
517 $sth_get_biblio->execute($this_item->{biblionumber});
518 while (my $this_biblio = $sth_get_biblio->fetchrow_hashref()) {
519 $this_item->{'title'} = $this_biblio->{'title'};
520 my $this_record = GetMarcBiblio($this_biblio->{'biblionumber'});
521 $this_item->{'browser_normalized_upc'} = GetNormalizedUPC($this_record,$marcflavour);
522 $this_item->{'browser_normalized_oclc'} = GetNormalizedOCLCNumber($this_record,$marcflavour);
523 $this_item->{'browser_normalized_isbn'} = GetNormalizedISBN(undef,$this_record,$marcflavour);
525 push @next_items, $this_item;
528 # alas, these won't auto-vivify, see http://www.perlmonks.org/?node_id=508481
529 my $shelfbrowser_next_itemnumber = $next_items[-1]->{itemnumber} if @next_items;
530 my $shelfbrowser_next_biblionumber = $next_items[-1]->{biblionumber} if @next_items;
532 $template->param(
533 starting_homebranch => $starting_homebranch->{description},
534 starting_location => $starting_location->{description},
535 starting_itemnumber => $starting_itemnumber,
536 shelfbrowser_prev_itemnumber => (@previous_items ? $previous_items[0]->{itemnumber} : 0),
537 shelfbrowser_next_itemnumber => $shelfbrowser_next_itemnumber,
538 shelfbrowser_prev_biblionumber => (@previous_items ? $previous_items[0]->{biblionumber} : 0),
539 shelfbrowser_next_biblionumber => $shelfbrowser_next_biblionumber,
540 PREVIOUS_SHELF_BROWSE => \@previous_items,
541 NEXT_SHELF_BROWSE => \@next_items,
545 if (C4::Context->preference("BakerTaylorEnabled")) {
546 $template->param(
547 BakerTaylorEnabled => 1,
548 BakerTaylorImageURL => &image_url(),
549 BakerTaylorLinkURL => &link_url(),
550 BakerTaylorBookstoreURL => C4::Context->preference('BakerTaylorBookstoreURL'),
552 my ($bt_user, $bt_pass);
553 if ($isbn and
554 $bt_user = C4::Context->preference('BakerTaylorUsername') and
555 $bt_pass = C4::Context->preference('BakerTaylorPassword') )
557 $template->param(
558 BakerTaylorContentURL =>
559 sprintf("http://contentcafe2.btol.com/ContentCafeClient/ContentCafe.aspx?UserID=%s&Password=%s&ItemKey=%s&Options=Y",
560 $bt_user,$bt_pass,$isbn)
565 my $tag_quantity;
566 if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->preference('TagsShowOnDetail')) {
567 $template->param(
568 TagsEnabled => 1,
569 TagsShowOnDetail => $tag_quantity,
570 TagsInputOnDetail => C4::Context->preference('TagsInputOnDetail')
572 $template->param(TagLoop => get_tags({biblionumber=>$biblionumber, approved=>1,
573 'sort'=>'-weight', limit=>$tag_quantity}));
576 #Search for title in links
577 if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
578 $search_for_title =~ s/{AUTHOR}/$dat->{author}/g;
579 $search_for_title =~ s/{TITLE}/$dat->{title}/g;
580 $search_for_title =~ s/{ISBN}/$isbn/g;
581 $template->param('OPACSearchForTitleIn' => $search_for_title);
584 # We try to select the best default tab to show, according to what
585 # the user wants, and what's available for display
586 my $defaulttab;
587 switch (C4::Context->preference('opacSerialDefaultTab')) {
589 # If the user wants subscriptions by default
590 case "subscriptions" {
591 # And there are subscriptions, we display them
592 if ($subscriptionsnumber) {
593 $defaulttab = 'subscriptions';
594 } else {
595 # Else, we try next option
596 next;
600 case "serialcollection" {
601 if (scalar(@serialcollections) > 0) {
602 $defaulttab = 'serialcollection' ;
603 } else {
604 next;
608 case "holdings" {
609 if ($dat->{'count'} > 0) {
610 $dat->{'defaultholdings'} = 1;
611 } else {
612 # As this is the last option, we try other options if there are no items
613 if ($subscriptionsnumber) {
614 $defaulttab = 'subscriptions';
615 } elsif (scalar(@serialcollections) > 0) {
616 $defaulttab = 'serialcollection' ;
623 $template->param('defaulttab' => $defaulttab);
627 output_html_with_http_headers $query, $cookie, $template->output;