Bugfix 2339 - Place hold button display with AllowOnShelfHolds OFF
[koha.git] / opac / opac-detail.pl
1 #!/usr/bin/perl
2
3 # Copyright 2000-2002 Katipo Communications
4 #
5 # This file is part of Koha.
6 #
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.
11 #
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.
15 #
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
19
20
21 use strict;
22 use warnings;
23
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::XSLT;
42
43 BEGIN {
44         if (C4::Context->preference('BakerTaylorEnabled')) {
45                 require C4::External::BakerTaylor;
46                 import C4::External::BakerTaylor qw(&image_url &link_url);
47         }
48 }
49
50 my $query = new CGI;
51 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
52     {
53         template_name   => "opac-detail.tmpl",
54         query           => $query,
55         type            => "opac",
56         authnotrequired => 1,
57         flagsrequired   => { borrow => 1 },
58     }
59 );
60
61 my $biblionumber = $query->param('biblionumber') || $query->param('bib');
62
63 $template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHolds') );
64 $template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
65
66 my $record       = GetMarcBiblio($biblionumber);
67 $template->param( biblionumber => $biblionumber );
68 # XSLT processing of some stuff
69 if (C4::Context->preference("XSLTDetailsDisplay") ) {
70     $template->param(
71         'XSLTBloc' => XSLTParse4Display($biblionumber, $record, 'Detail') );
72 }
73
74 $template->param('OPACShowCheckoutName' => C4::Context->preference("OPACShowCheckoutName") ); 
75 # change back when ive fixed request.pl
76 my @all_items = &GetItemsInfo( $biblionumber, 'opac' );
77 my @items;
78 @items = @all_items unless C4::Context->preference('hidelostitems');
79
80 if (C4::Context->preference('hidelostitems')) {
81     # Hide host items
82     for my $itm (@all_items) {
83         push @items, $itm unless $itm->{itemlost};
84     }
85 }
86 my $dat = &GetBiblioData($biblionumber);
87
88 if (!$dat) {
89     print $query->redirect("/cgi-bin/koha/errors/404.pl");
90     exit;
91 }
92 my $itemtypes = GetItemTypes();
93 # imageurl:
94 my $itemtype = $dat->{'itemtype'};
95 if ( $itemtype ) {
96     $dat->{'imageurl'}    = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} );
97     $dat->{'description'} = $itemtypes->{$itemtype}->{'description'};
98 }
99 my $shelflocations =GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'});
100 my $collections =  GetKohaAuthorisedValues('items.ccode',$dat->{'frameworkcode'} );
101
102 #coping with subscriptions
103 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
104 my @subscriptions       = GetSubscriptions( $dat->{title}, $dat->{issn}, $biblionumber );
105
106 my @subs;
107 $dat->{'serial'}=1 if $subscriptionsnumber;
108 foreach my $subscription (@subscriptions) {
109     my $serials_to_display;
110     my %cell;
111     $cell{subscriptionid}    = $subscription->{subscriptionid};
112     $cell{subscriptionnotes} = $subscription->{notes};
113     $cell{branchcode}        = $subscription->{branchcode};
114     $cell{branchname}        = GetBranchName($subscription->{branchcode});
115     $cell{hasalert}          = $subscription->{hasalert};
116     #get the three latest serials.
117     $serials_to_display = $subscription->{opacdisplaycount};
118     $serials_to_display = C4::Context->preference('OPACSerialIssueDisplayCount') unless $serials_to_display;
119         $cell{opacdisplaycount} = $serials_to_display;
120     $cell{latestserials} =
121       GetLatestSerials( $subscription->{subscriptionid}, $serials_to_display );
122     push @subs, \%cell;
123 }
124
125 $dat->{'count'} = scalar(@items);
126
127 my $biblio_authorised_value_images = C4::Items::get_authorised_value_images( C4::Biblio::get_biblio_authorised_values( $biblionumber, $record ) );
128
129 my $norequests = 1;
130 my $branches = GetBranches();
131 my %itemfields;
132 for my $itm (@items) {
133     $norequests = 0
134        if ( (not $itm->{'wthdrawn'} )
135          && (not $itm->{'itemlost'} )
136          && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'} )
137                  && (not $itemtypes->{$itm->{'itype'}}->{notforloan} )
138          && ($itm->{'itemnumber'} ) );
139
140     if ( defined $itm->{'publictype'} ) {
141         # I can't actually find any case in which this is defined. --amoore 2008-12-09
142         $itm->{ $itm->{'publictype'} } = 1;
143     }
144     $itm->{datedue}      = format_date($itm->{datedue});
145     $itm->{datelastseen} = format_date($itm->{datelastseen});
146
147     # get collection code description, too
148     if ( my $ccode = $itm->{'ccode'} ) {
149         $itm->{'ccode'} = $collections->{$ccode} if ( defined($collections) && exists( $collections->{$ccode} ) );
150     }
151     if ( defined $itm->{'location'} ) {
152         $itm->{'location_description'} = $shelflocations->{ $itm->{'location'} };
153     }
154     if (exists $itm->{itype} && defined($itm->{itype}) && exists $itemtypes->{ $itm->{itype} }) {
155         $itm->{'imageurl'}    = getitemtypeimagelocation( 'opac', $itemtypes->{ $itm->{itype} }->{'imageurl'} );
156         $itm->{'description'} = $itemtypes->{ $itm->{itype} }->{'description'};
157     }
158     foreach (qw(ccode enumchron copynumber itemnotes uri)) {
159         $itemfields{$_} = 1 if ($itm->{$_});
160     }
161
162      # walk through the item-level authorised values and populate some images
163      my $item_authorised_value_images = C4::Items::get_authorised_value_images( C4::Items::get_item_authorised_values( $itm->{'itemnumber'} ) );
164      # warn( Data::Dumper->Dump( [ $item_authorised_value_images ], [ 'item_authorised_value_images' ] ) );
165
166      if ( $itm->{'itemlost'} ) {
167          my $lostimageinfo = List::Util::first { $_->{'category'} eq 'LOST' } @$item_authorised_value_images;
168          $itm->{'lostimageurl'}   = $lostimageinfo->{ 'imageurl' };
169          $itm->{'lostimagelabel'} = $lostimageinfo->{ 'label' };
170      }
171
172      if( $itm->{'count_reserves'}){
173           if( $itm->{'count_reserves'} eq "Waiting"){ $itm->{'waiting'} = 1; }
174           if( $itm->{'count_reserves'} eq "Reserved"){ $itm->{'onhold'} = 1; }
175      }
176     
177      my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($itm->{itemnumber});
178      if ( defined( $transfertwhen ) && $transfertwhen ne '' ) {
179         $itm->{transfertwhen} = format_date($transfertwhen);
180         $itm->{transfertfrom} = $branches->{$transfertfrom}{branchname};
181         $itm->{transfertto}   = $branches->{$transfertto}{branchname};
182      }
183 }
184
185 ## get notes and subjects from MARC record
186 my $dbh              = C4::Context->dbh;
187 my $marcflavour      = C4::Context->preference("marcflavour");
188 my $marcnotesarray   = GetMarcNotes   ($record,$marcflavour);
189 my $marcauthorsarray = GetMarcAuthors ($record,$marcflavour);
190 my $marcsubjctsarray = GetMarcSubjects($record,$marcflavour);
191 my $marcseriesarray  = GetMarcSeries  ($record,$marcflavour);
192 my $marcurlsarray    = GetMarcUrls    ($record,$marcflavour);
193 my $subtitle         = C4::Biblio::get_koha_field_from_marc('bibliosubtitle', 'subtitle', $record, '');
194
195     $template->param(
196                      MARCNOTES               => $marcnotesarray,
197                      MARCSUBJCTS             => $marcsubjctsarray,
198                      MARCAUTHORS             => $marcauthorsarray,
199                      MARCSERIES              => $marcseriesarray,
200                      MARCURLS                => $marcurlsarray,
201                      norequests              => $norequests,
202                      RequestOnOpac           => C4::Context->preference("RequestOnOpac"),
203                      itemdata_ccode          => $itemfields{ccode},
204                      itemdata_enumchron      => $itemfields{enumchron},
205                      itemdata_uri            => $itemfields{uri},
206                      itemdata_copynumber     => $itemfields{copynumber},
207                      itemdata_itemnotes          => $itemfields{itemnotes},
208                      authorised_value_images => $biblio_authorised_value_images,
209                      subtitle                => $subtitle,
210     );
211
212 foreach ( keys %{$dat} ) {
213     $template->param( "$_" => defined $dat->{$_} ? $dat->{$_} : '' );
214 }
215
216 # some useful variables for enhanced content;
217 # in each case, we're grabbing the first value we find in
218 # the record and normalizing it
219 my $upc = GetNormalizedUPC($record,$marcflavour);
220 my $ean = GetNormalizedEAN($record,$marcflavour);
221 my $oclc = GetNormalizedOCLCNumber($record,$marcflavour);
222 my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
223 my $content_identifier_exists = 1 if ($isbn or $ean or $oclc or $upc);
224 $template->param(
225         normalized_upc => $upc,
226         normalized_ean => $ean,
227         normalized_oclc => $oclc,
228         normalized_isbn => $isbn,
229         content_identifier_exists =>  $content_identifier_exists,
230 );
231
232 # COinS format FIXME: for books Only
233 $template->param(
234     ocoins => GetCOinSBiblio($biblionumber),
235 );
236
237 my $reviews = getreviews( $biblionumber, 1 );
238 my $loggedincommenter;
239 foreach ( @$reviews ) {
240     my $borrowerData   = GetMember($_->{borrowernumber},'borrowernumber');
241     # setting some borrower info into this hash
242     $_->{title}     = $borrowerData->{'title'};
243     $_->{surname}   = $borrowerData->{'surname'};
244     $_->{firstname} = $borrowerData->{'firstname'};
245     $_->{userid}    = $borrowerData->{'userid'};
246     $_->{cardnumber}    = $borrowerData->{'cardnumber'};
247     $_->{datereviewed} = format_date($_->{datereviewed});
248     if ($borrowerData->{'borrowernumber'} eq $borrowernumber) {
249                 $_->{your_comment} = 1;
250                 $loggedincommenter = 1;
251         }
252 }
253
254
255 if(C4::Context->preference("ISBD")) {
256         $template->param(ISBD => 1);
257 }
258
259 $template->param(
260     ITEM_RESULTS        => \@items,
261     subscriptionsnumber => $subscriptionsnumber,
262     biblionumber        => $biblionumber,
263     subscriptions       => \@subs,
264     subscriptionsnumber => $subscriptionsnumber,
265     reviews             => $reviews,
266     loggedincommenter   => $loggedincommenter
267 );
268
269 # XISBN Stuff
270 if (C4::Context->preference("OPACFRBRizeEditions")==1) {
271     eval {
272         $template->param(
273             XISBNS => get_xisbns($isbn)
274         );
275     };
276     if ($@) { warn "XISBN Failed $@"; }
277 }
278 # Amazon.com Stuff
279 if ( C4::Context->preference("OPACAmazonEnabled") ) {
280     $template->param( AmazonTld => get_amazon_tld() );
281     my $amazon_reviews  = C4::Context->preference("OPACAmazonReviews");
282     my $amazon_similars = C4::Context->preference("OPACAmazonSimilarItems");
283     my @services;
284     if ( $amazon_reviews ) {
285         $template->param( OPACAmazonReviews => 1 );
286         push( @services, 'EditorialReview', 'Reviews' );
287     }
288     if ( $amazon_similars ) {
289         $template->param( OPACAmazonSimilarItems => 1 );
290         push( @services, 'Similarities' );
291     }
292     my $amazon_details = &get_amazon_details( $isbn, $record, $marcflavour, \@services );
293     my $similar_products_exist;
294     if ( $amazon_reviews ) {
295         my $item = $amazon_details->{Items}->{Item}->[0];
296         my $customer_reviews = \@{ $item->{CustomerReviews}->{Review} };
297         for my $one_review ( @$customer_reviews ) {
298             $one_review->{Date} = format_date($one_review->{Date});
299         }
300         my $editorial_reviews = \@{ $item->{EditorialReviews}->{EditorialReview} };
301         my $average_rating = $item->{CustomerReviews}->{AverageRating} || 0;
302         $template->param( amazon_average_rating    => $average_rating * 20);
303         $template->param( AMAZON_CUSTOMER_REVIEWS  => $customer_reviews );
304         $template->param( AMAZON_EDITORIAL_REVIEWS => $editorial_reviews );
305     }
306     if ( $amazon_similars ) {
307         my $item = $amazon_details->{Items}->{Item}->[0];
308         my @similar_products;
309         for my $similar_product (@{ $item->{SimilarProducts}->{SimilarProduct} }) {
310             # do we have any of these isbns in our collection?
311             my $similar_biblionumbers = get_biblionumber_from_isbn($similar_product->{ASIN});
312             # verify that there is at least one similar item
313             if (scalar(@$similar_biblionumbers)){
314                 $similar_products_exist++ if ($similar_biblionumbers && $similar_biblionumbers->[0]);
315                 push @similar_products, +{ similar_biblionumbers => $similar_biblionumbers, title => $similar_product->{Title}, ASIN => $similar_product->{ASIN}  };
316             }
317         }
318         $template->param( OPACAmazonSimilarItems => $similar_products_exist );
319         $template->param( AMAZON_SIMILAR_PRODUCTS => \@similar_products );
320     }
321 }
322
323 my $syndetics_elements;
324
325 if ( C4::Context->preference("SyndeticsEnabled") ) {
326         eval {
327     $syndetics_elements = &get_syndetics_index($isbn,$upc,$oclc);
328         for my $element (values %$syndetics_elements) {
329                 $template->param("Syndetics$element"."Exists" => 1 );
330                 #warn "Exists: "."Syndetics$element"."Exists";
331         }
332     };
333     warn $@ if $@;
334 }
335
336 if ( C4::Context->preference("SyndeticsEnabled")
337         && C4::Context->preference("SyndeticsSummary")
338         && ( exists($syndetics_elements->{'SUMMARY'}) || exists($syndetics_elements->{'AVSUMMARY'}) ) ) {
339         eval {
340         my $syndetics_summary = &get_syndetics_summary($isbn,$upc,$oclc, $syndetics_elements);
341         $template->param( SYNDETICS_SUMMARY => $syndetics_summary );
342         };
343         warn $@ if $@;
344
345 }
346
347 if ( C4::Context->preference("SyndeticsEnabled")
348         && C4::Context->preference("SyndeticsTOC")
349         && exists($syndetics_elements->{'TOC'}) ) {
350         eval {
351     my $syndetics_toc = &get_syndetics_toc($isbn,$upc,$oclc);
352     $template->param( SYNDETICS_TOC => $syndetics_toc );
353         };
354         warn $@ if $@;
355 }
356
357 if ( C4::Context->preference("SyndeticsEnabled")
358     && C4::Context->preference("SyndeticsExcerpt")
359     && exists($syndetics_elements->{'DBCHAPTER'}) ) {
360     eval {
361     my $syndetics_excerpt = &get_syndetics_excerpt($isbn,$upc,$oclc);
362     $template->param( SYNDETICS_EXCERPT => $syndetics_excerpt );
363     };
364         warn $@ if $@;
365 }
366
367 if ( C4::Context->preference("SyndeticsEnabled")
368     && C4::Context->preference("SyndeticsReviews")) {
369     eval {
370     my $syndetics_reviews = &get_syndetics_reviews($isbn,$upc,$oclc,$syndetics_elements);
371     $template->param( SYNDETICS_REVIEWS => $syndetics_reviews );
372     };
373         warn $@ if $@;
374 }
375
376 if ( C4::Context->preference("SyndeticsEnabled")
377     && C4::Context->preference("SyndeticsAuthorNotes")
378         && exists($syndetics_elements->{'ANOTES'}) ) {
379     eval {
380     my $syndetics_anotes = &get_syndetics_anotes($isbn,$upc,$oclc);
381     $template->param( SYNDETICS_ANOTES => $syndetics_anotes );
382     };
383     warn $@ if $@;
384 }
385
386 # LibraryThingForLibraries ID Code and Tabbed View Option
387 if( C4::Context->preference('LibraryThingForLibrariesEnabled') ) 
388
389 $template->param(LibraryThingForLibrariesID =>
390 C4::Context->preference('LibraryThingForLibrariesID') ); 
391 $template->param(LibraryThingForLibrariesTabbedView =>
392 C4::Context->preference('LibraryThingForLibrariesTabbedView') );
393
394
395
396 # Babelthèque
397 if ( C4::Context->preference("Babeltheque") ) {
398     $template->param( 
399         Babeltheque => 1,
400     );
401 }
402
403 # Shelf Browser Stuff
404 if (C4::Context->preference("OPACShelfBrowser")) {
405     # pick the first itemnumber unless one was selected by the user
406     my $starting_itemnumber = $query->param('shelfbrowse_itemnumber'); # || $items[0]->{itemnumber};
407     $template->param( OpenOPACShelfBrowser => 1) if $starting_itemnumber;
408     # find the right cn_sort value for this item
409     my ($starting_cn_sort, $starting_homebranch, $starting_location);
410     my $sth_get_cn_sort = $dbh->prepare("SELECT cn_sort,homebranch,location from items where itemnumber=?");
411     $sth_get_cn_sort->execute($starting_itemnumber);
412     while (my $result = $sth_get_cn_sort->fetchrow_hashref()) {
413         $starting_cn_sort = $result->{'cn_sort'};
414         $starting_homebranch->{code} = $result->{'homebranch'};
415         $starting_homebranch->{description} = $branches->{$result->{'homebranch'}}{branchname};
416         $starting_location->{code} = $result->{'location'};
417         $starting_location->{description} = GetAuthorisedValueDesc('','',   $result->{'location'} ,'','','LOC');
418     
419     }
420     
421     ## List of Previous Items
422     # order by cn_sort, which should include everything we need for ordering purposes (though not
423     # for limits, those need to be handled separately
424     my $sth_shelfbrowse_previous;
425     if (defined $starting_location->{code}) {
426       $sth_shelfbrowse_previous = $dbh->prepare("
427         SELECT *
428         FROM items
429         WHERE
430             ((cn_sort = ? AND itemnumber < ?) OR cn_sort < ?) AND
431             homebranch = ? AND location = ?
432         ORDER BY cn_sort DESC, itemnumber LIMIT 3
433         ");
434       $sth_shelfbrowse_previous->execute($starting_cn_sort, $starting_itemnumber, $starting_cn_sort, $starting_homebranch->{code}, $starting_location->{code});
435     } else {
436       $sth_shelfbrowse_previous = $dbh->prepare("
437         SELECT *
438         FROM items
439         WHERE
440             ((cn_sort = ? AND itemnumber < ?) OR cn_sort < ?) AND
441             homebranch = ?
442         ORDER BY cn_sort DESC, itemnumber LIMIT 3
443         ");
444       $sth_shelfbrowse_previous->execute($starting_cn_sort, $starting_itemnumber, $starting_cn_sort, $starting_homebranch->{code});
445     }
446     my @previous_items;
447     while (my $this_item = $sth_shelfbrowse_previous->fetchrow_hashref()) {
448         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=?");
449         $sth_get_biblio->execute($this_item->{biblionumber});
450         while (my $this_biblio = $sth_get_biblio->fetchrow_hashref()) {
451                         $this_item->{'title'} = $this_biblio->{'title'};
452                         my $this_record = GetMarcBiblio($this_biblio->{'biblionumber'});
453                         $this_item->{'browser_normalized_upc'} = GetNormalizedUPC($this_record,$marcflavour);
454                         $this_item->{'browser_normalized_oclc'} = GetNormalizedOCLCNumber($this_record,$marcflavour);
455                         $this_item->{'browser_normalized_isbn'} = GetNormalizedISBN(undef,$this_record,$marcflavour);
456         }
457         unshift @previous_items, $this_item;
458     }
459     
460     ## List of Next Items; this also intentionally catches the current item
461     my $sth_shelfbrowse_next;
462     if (defined $starting_location->{code}) {
463       $sth_shelfbrowse_next = $dbh->prepare("
464         SELECT *
465         FROM items
466         WHERE
467             ((cn_sort = ? AND itemnumber >= ?) OR cn_sort > ?) AND
468             homebranch = ? AND location = ?
469         ORDER BY cn_sort, itemnumber LIMIT 3
470         ");
471       $sth_shelfbrowse_next->execute($starting_cn_sort, $starting_itemnumber, $starting_cn_sort, $starting_homebranch->{code}, $starting_location->{code});
472     } else {
473       $sth_shelfbrowse_next = $dbh->prepare("
474         SELECT *
475         FROM items
476         WHERE
477             ((cn_sort = ? AND itemnumber >= ?) OR cn_sort > ?) AND
478             homebranch = ?
479         ORDER BY cn_sort, itemnumber LIMIT 3
480         ");
481       $sth_shelfbrowse_next->execute($starting_cn_sort, $starting_itemnumber, $starting_cn_sort, $starting_homebranch->{code});
482     }
483     my @next_items;
484     while (my $this_item = $sth_shelfbrowse_next->fetchrow_hashref()) {
485         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=?");
486         $sth_get_biblio->execute($this_item->{biblionumber});
487         while (my $this_biblio = $sth_get_biblio->fetchrow_hashref()) {
488             $this_item->{'title'} = $this_biblio->{'title'};
489                         my $this_record = GetMarcBiblio($this_biblio->{'biblionumber'});
490             $this_item->{'browser_normalized_upc'} = GetNormalizedUPC($this_record,$marcflavour);
491             $this_item->{'browser_normalized_oclc'} = GetNormalizedOCLCNumber($this_record,$marcflavour);
492             $this_item->{'browser_normalized_isbn'} = GetNormalizedISBN(undef,$this_record,$marcflavour);
493         }
494         push @next_items, $this_item;
495     }
496     
497     # alas, these won't auto-vivify, see http://www.perlmonks.org/?node_id=508481
498     my $shelfbrowser_next_itemnumber = $next_items[-1]->{itemnumber} if @next_items;
499     my $shelfbrowser_next_biblionumber = $next_items[-1]->{biblionumber} if @next_items;
500     
501     $template->param(
502         starting_homebranch => $starting_homebranch->{description},
503         starting_location => $starting_location->{description},
504         starting_itemnumber => $starting_itemnumber,
505         shelfbrowser_prev_itemnumber => (@previous_items ? $previous_items[0]->{itemnumber} : 0),
506         shelfbrowser_next_itemnumber => $shelfbrowser_next_itemnumber,
507         shelfbrowser_prev_biblionumber => (@previous_items ? $previous_items[0]->{biblionumber} : 0),
508         shelfbrowser_next_biblionumber => $shelfbrowser_next_biblionumber,
509         PREVIOUS_SHELF_BROWSE => \@previous_items,
510         NEXT_SHELF_BROWSE => \@next_items,
511     );
512 }
513
514 if (C4::Context->preference("BakerTaylorEnabled")) {
515         $template->param(
516                 BakerTaylorEnabled  => 1,
517                 BakerTaylorImageURL => &image_url(),
518                 BakerTaylorLinkURL  => &link_url(),
519                 BakerTaylorBookstoreURL => C4::Context->preference('BakerTaylorBookstoreURL'),
520         );
521         my ($bt_user, $bt_pass);
522         if ($isbn and
523                 $bt_user = C4::Context->preference('BakerTaylorUsername') and
524                 $bt_pass = C4::Context->preference('BakerTaylorPassword')    )
525         {
526                 $template->param(
527                 BakerTaylorContentURL   =>
528                 sprintf("http://contentcafe2.btol.com/ContentCafeClient/ContentCafe.aspx?UserID=%s&Password=%s&ItemKey=%s&Options=Y",
529                                 $bt_user,$bt_pass,$isbn)
530                 );
531         }
532 }
533
534 my $tag_quantity;
535 if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->preference('TagsShowOnDetail')) {
536         $template->param(
537                 TagsEnabled => 1,
538                 TagsShowOnDetail => $tag_quantity,
539                 TagsInputOnDetail => C4::Context->preference('TagsInputOnDetail')
540         );
541         $template->param(TagLoop => get_tags({biblionumber=>$biblionumber, approved=>1,
542                                                                 'sort'=>'-weight', limit=>$tag_quantity}));
543 }
544
545 output_html_with_http_headers $query, $cookie, $template->output;