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