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