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
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
28 use C4::Serials; #uses getsubscriptionfrom biblionumber
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 );
41 use C4::VirtualShelves;
46 if (C4::Context->preference('BakerTaylorEnabled')) {
47 require C4::External::BakerTaylor;
48 import C4::External::BakerTaylor qw(&image_url &link_url);
53 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
55 template_name => "opac-detail.tmpl",
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") ) {
73 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, 'Detail'),'opac' );
76 $template->param('OPACShowCheckoutName' => C4::Context->preference("OPACShowCheckoutName") );
77 # change back when ive fixed request.pl
78 my @all_items = &GetItemsInfo( $biblionumber, 'opac' );
80 @items = @all_items unless C4::Context->preference('hidelostitems');
82 if (C4::Context->preference('hidelostitems')) {
84 for my $itm (@all_items) {
85 push @items, $itm unless $itm->{itemlost};
88 my $dat = &GetBiblioData($biblionumber);
91 print $query->redirect("/cgi-bin/koha/errors/404.pl");
94 my $itemtypes = GetItemTypes();
96 my $itemtype = $dat->{'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 );
109 $dat->{'serial'}=1 if $subscriptionsnumber;
110 foreach my $subscription (@subscriptions) {
111 my $serials_to_display;
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 );
127 $dat->{'count'} = scalar(@items);
129 # If there is a lot of items, and the user has not decided
130 # to view them all yet, we first warn him
131 # TODO: The limit of 50 could be a syspref
132 my $viewallitems = $query->param('viewallitems');
133 if ($dat->{'count'} >= 50 && !$viewallitems) {
134 $template->param('lotsofitems' => 1);
137 my $biblio_authorised_value_images = C4::Items::get_authorised_value_images( C4::Biblio::get_biblio_authorised_values( $biblionumber, $record ) );
140 my $branches = GetBranches();
142 for my $itm (@items) {
144 if ( (not $itm->{'wthdrawn'} )
145 && (not $itm->{'itemlost'} )
146 && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'} )
147 && (not $itemtypes->{$itm->{'itype'}}->{notforloan} )
148 && ($itm->{'itemnumber'} ) );
150 if ( defined $itm->{'publictype'} ) {
151 # I can't actually find any case in which this is defined. --amoore 2008-12-09
152 $itm->{ $itm->{'publictype'} } = 1;
154 $itm->{datedue} = format_date($itm->{datedue});
155 $itm->{datelastseen} = format_date($itm->{datelastseen});
157 # get collection code description, too
158 if ( my $ccode = $itm->{'ccode'} ) {
159 $itm->{'ccode'} = $collections->{$ccode} if ( defined($collections) && exists( $collections->{$ccode} ) );
161 if ( defined $itm->{'location'} ) {
162 $itm->{'location_description'} = $shelflocations->{ $itm->{'location'} };
164 if (exists $itm->{itype} && defined($itm->{itype}) && exists $itemtypes->{ $itm->{itype} }) {
165 $itm->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{ $itm->{itype} }->{'imageurl'} );
166 $itm->{'description'} = $itemtypes->{ $itm->{itype} }->{'description'};
168 foreach (qw(ccode enumchron copynumber itemnotes uri)) {
169 $itemfields{$_} = 1 if ($itm->{$_});
172 # walk through the item-level authorised values and populate some images
173 my $item_authorised_value_images = C4::Items::get_authorised_value_images( C4::Items::get_item_authorised_values( $itm->{'itemnumber'} ) );
174 # warn( Data::Dumper->Dump( [ $item_authorised_value_images ], [ 'item_authorised_value_images' ] ) );
176 if ( $itm->{'itemlost'} ) {
177 my $lostimageinfo = List::Util::first { $_->{'category'} eq 'LOST' } @$item_authorised_value_images;
178 $itm->{'lostimageurl'} = $lostimageinfo->{ 'imageurl' };
179 $itm->{'lostimagelabel'} = $lostimageinfo->{ 'label' };
182 if( $itm->{'count_reserves'}){
183 if( $itm->{'count_reserves'} eq "Waiting"){ $itm->{'waiting'} = 1; }
184 if( $itm->{'count_reserves'} eq "Reserved"){ $itm->{'onhold'} = 1; }
187 my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($itm->{itemnumber});
188 if ( defined( $transfertwhen ) && $transfertwhen ne '' ) {
189 $itm->{transfertwhen} = format_date($transfertwhen);
190 $itm->{transfertfrom} = $branches->{$transfertfrom}{branchname};
191 $itm->{transfertto} = $branches->{$transfertto}{branchname};
195 ## get notes and subjects from MARC record
196 my $dbh = C4::Context->dbh;
197 my $marcflavour = C4::Context->preference("marcflavour");
198 my $marcnotesarray = GetMarcNotes ($record,$marcflavour);
199 my $marcauthorsarray = GetMarcAuthors ($record,$marcflavour);
200 my $marcsubjctsarray = GetMarcSubjects($record,$marcflavour);
201 my $marcseriesarray = GetMarcSeries ($record,$marcflavour);
202 my $marcurlsarray = GetMarcUrls ($record,$marcflavour);
203 my $subtitle = C4::Biblio::get_koha_field_from_marc('bibliosubtitle', 'subtitle', $record, '');
206 MARCNOTES => $marcnotesarray,
207 MARCSUBJCTS => $marcsubjctsarray,
208 MARCAUTHORS => $marcauthorsarray,
209 MARCSERIES => $marcseriesarray,
210 MARCURLS => $marcurlsarray,
211 norequests => $norequests,
212 RequestOnOpac => C4::Context->preference("RequestOnOpac"),
213 itemdata_ccode => $itemfields{ccode},
214 itemdata_enumchron => $itemfields{enumchron},
215 itemdata_uri => $itemfields{uri},
216 itemdata_copynumber => $itemfields{copynumber},
217 itemdata_itemnotes => $itemfields{itemnotes},
218 authorised_value_images => $biblio_authorised_value_images,
219 subtitle => $subtitle,
222 foreach ( keys %{$dat} ) {
223 $template->param( "$_" => defined $dat->{$_} ? $dat->{$_} : '' );
226 # some useful variables for enhanced content;
227 # in each case, we're grabbing the first value we find in
228 # the record and normalizing it
229 my $upc = GetNormalizedUPC($record,$marcflavour);
230 my $ean = GetNormalizedEAN($record,$marcflavour);
231 my $oclc = GetNormalizedOCLCNumber($record,$marcflavour);
232 my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
233 my $content_identifier_exists = 1 if ($isbn or $ean or $oclc or $upc);
235 normalized_upc => $upc,
236 normalized_ean => $ean,
237 normalized_oclc => $oclc,
238 normalized_isbn => $isbn,
239 content_identifier_exists => $content_identifier_exists,
242 # COinS format FIXME: for books Only
244 ocoins => GetCOinSBiblio($biblionumber),
247 my $reviews = getreviews( $biblionumber, 1 );
248 my $loggedincommenter;
249 foreach ( @$reviews ) {
250 my $borrowerData = GetMember('borrowernumber' => $_->{borrowernumber});
251 # setting some borrower info into this hash
252 $_->{title} = $borrowerData->{'title'};
253 $_->{surname} = $borrowerData->{'surname'};
254 $_->{firstname} = $borrowerData->{'firstname'};
255 $_->{userid} = $borrowerData->{'userid'};
256 $_->{cardnumber} = $borrowerData->{'cardnumber'};
257 $_->{datereviewed} = format_date($_->{datereviewed});
258 if ($borrowerData->{'borrowernumber'} eq $borrowernumber) {
259 $_->{your_comment} = 1;
260 $loggedincommenter = 1;
265 if(C4::Context->preference("ISBD")) {
266 $template->param(ISBD => 1);
270 ITEM_RESULTS => \@items,
271 subscriptionsnumber => $subscriptionsnumber,
272 biblionumber => $biblionumber,
273 subscriptions => \@subs,
274 subscriptionsnumber => $subscriptionsnumber,
276 loggedincommenter => $loggedincommenter
281 if (C4::Context->preference("virtualshelves") ) {
282 $template->param( 'GetShelves' => GetBibliosShelves( $biblionumber ) );
287 if (C4::Context->preference("OPACFRBRizeEditions")==1) {
290 XISBNS => get_xisbns($isbn)
293 if ($@) { warn "XISBN Failed $@"; }
297 my @sc_fields = $record->field(955);
298 my @serialcollections = ();
300 foreach my $sc_field (@sc_fields) {
303 $row_data{text} = $sc_field->subfield('r');
304 $row_data{branch} = $sc_field->subfield('9');
306 if ($row_data{text} && $row_data{branch}) {
307 push (@serialcollections, \%row_data);
311 if (scalar(@serialcollections) > 0) {
313 serialcollection => 1,
314 serialcollections => \@serialcollections);
318 if ( C4::Context->preference("OPACAmazonEnabled") ) {
319 $template->param( AmazonTld => get_amazon_tld() );
320 my $amazon_reviews = C4::Context->preference("OPACAmazonReviews");
321 my $amazon_similars = C4::Context->preference("OPACAmazonSimilarItems");
323 if ( $amazon_reviews ) {
324 $template->param( OPACAmazonReviews => 1 );
325 push( @services, 'EditorialReview', 'Reviews' );
327 if ( $amazon_similars ) {
328 $template->param( OPACAmazonSimilarItems => 1 );
329 push( @services, 'Similarities' );
331 my $amazon_details = &get_amazon_details( $isbn, $record, $marcflavour, \@services );
332 my $similar_products_exist;
333 if ( $amazon_reviews ) {
334 my $item = $amazon_details->{Items}->{Item}->[0];
335 my $customer_reviews = \@{ $item->{CustomerReviews}->{Review} };
336 for my $one_review ( @$customer_reviews ) {
337 $one_review->{Date} = format_date($one_review->{Date});
339 my $editorial_reviews = \@{ $item->{EditorialReviews}->{EditorialReview} };
340 my $average_rating = $item->{CustomerReviews}->{AverageRating} || 0;
341 $template->param( amazon_average_rating => $average_rating * 20);
342 $template->param( AMAZON_CUSTOMER_REVIEWS => $customer_reviews );
343 $template->param( AMAZON_EDITORIAL_REVIEWS => $editorial_reviews );
345 if ( $amazon_similars ) {
346 my $item = $amazon_details->{Items}->{Item}->[0];
347 my @similar_products;
348 for my $similar_product (@{ $item->{SimilarProducts}->{SimilarProduct} }) {
349 # do we have any of these isbns in our collection?
350 my $similar_biblionumbers = get_biblionumber_from_isbn($similar_product->{ASIN});
351 # verify that there is at least one similar item
352 if (scalar(@$similar_biblionumbers)){
353 $similar_products_exist++ if ($similar_biblionumbers && $similar_biblionumbers->[0]);
354 push @similar_products, +{ similar_biblionumbers => $similar_biblionumbers, title => $similar_product->{Title}, ASIN => $similar_product->{ASIN} };
357 $template->param( OPACAmazonSimilarItems => $similar_products_exist );
358 $template->param( AMAZON_SIMILAR_PRODUCTS => \@similar_products );
362 my $syndetics_elements;
364 if ( C4::Context->preference("SyndeticsEnabled") ) {
366 $syndetics_elements = &get_syndetics_index($isbn,$upc,$oclc);
367 for my $element (values %$syndetics_elements) {
368 $template->param("Syndetics$element"."Exists" => 1 );
369 #warn "Exists: "."Syndetics$element"."Exists";
375 if ( C4::Context->preference("SyndeticsEnabled")
376 && C4::Context->preference("SyndeticsSummary")
377 && ( exists($syndetics_elements->{'SUMMARY'}) || exists($syndetics_elements->{'AVSUMMARY'}) ) ) {
379 my $syndetics_summary = &get_syndetics_summary($isbn,$upc,$oclc, $syndetics_elements);
380 $template->param( SYNDETICS_SUMMARY => $syndetics_summary );
386 if ( C4::Context->preference("SyndeticsEnabled")
387 && C4::Context->preference("SyndeticsTOC")
388 && exists($syndetics_elements->{'TOC'}) ) {
390 my $syndetics_toc = &get_syndetics_toc($isbn,$upc,$oclc);
391 $template->param( SYNDETICS_TOC => $syndetics_toc );
396 if ( C4::Context->preference("SyndeticsEnabled")
397 && C4::Context->preference("SyndeticsExcerpt")
398 && exists($syndetics_elements->{'DBCHAPTER'}) ) {
400 my $syndetics_excerpt = &get_syndetics_excerpt($isbn,$upc,$oclc);
401 $template->param( SYNDETICS_EXCERPT => $syndetics_excerpt );
406 if ( C4::Context->preference("SyndeticsEnabled")
407 && C4::Context->preference("SyndeticsReviews")) {
409 my $syndetics_reviews = &get_syndetics_reviews($isbn,$upc,$oclc,$syndetics_elements);
410 $template->param( SYNDETICS_REVIEWS => $syndetics_reviews );
415 if ( C4::Context->preference("SyndeticsEnabled")
416 && C4::Context->preference("SyndeticsAuthorNotes")
417 && exists($syndetics_elements->{'ANOTES'}) ) {
419 my $syndetics_anotes = &get_syndetics_anotes($isbn,$upc,$oclc);
420 $template->param( SYNDETICS_ANOTES => $syndetics_anotes );
425 # LibraryThingForLibraries ID Code and Tabbed View Option
426 if( C4::Context->preference('LibraryThingForLibrariesEnabled') )
428 $template->param(LibraryThingForLibrariesID =>
429 C4::Context->preference('LibraryThingForLibrariesID') );
430 $template->param(LibraryThingForLibrariesTabbedView =>
431 C4::Context->preference('LibraryThingForLibrariesTabbedView') );
436 if ( C4::Context->preference("Babeltheque") ) {
442 # Shelf Browser Stuff
443 if (C4::Context->preference("OPACShelfBrowser")) {
444 # pick the first itemnumber unless one was selected by the user
445 my $starting_itemnumber = $query->param('shelfbrowse_itemnumber'); # || $items[0]->{itemnumber};
446 $template->param( OpenOPACShelfBrowser => 1) if $starting_itemnumber;
447 # find the right cn_sort value for this item
448 my ($starting_cn_sort, $starting_homebranch, $starting_location);
449 my $sth_get_cn_sort = $dbh->prepare("SELECT cn_sort,homebranch,location from items where itemnumber=?");
450 $sth_get_cn_sort->execute($starting_itemnumber);
451 while (my $result = $sth_get_cn_sort->fetchrow_hashref()) {
452 $starting_cn_sort = $result->{'cn_sort'};
453 $starting_homebranch->{code} = $result->{'homebranch'};
454 $starting_homebranch->{description} = $branches->{$result->{'homebranch'}}{branchname};
455 $starting_location->{code} = $result->{'location'};
456 $starting_location->{description} = GetAuthorisedValueDesc('','', $result->{'location'} ,'','','LOC', 'opac');
460 ## List of Previous Items
461 # order by cn_sort, which should include everything we need for ordering purposes (though not
462 # for limits, those need to be handled separately
463 my $sth_shelfbrowse_previous;
464 if (defined $starting_location->{code}) {
465 $sth_shelfbrowse_previous = $dbh->prepare("
469 ((cn_sort = ? AND itemnumber < ?) OR cn_sort < ?) AND
470 homebranch = ? AND location = ?
471 ORDER BY cn_sort DESC, itemnumber LIMIT 3
473 $sth_shelfbrowse_previous->execute($starting_cn_sort, $starting_itemnumber, $starting_cn_sort, $starting_homebranch->{code}, $starting_location->{code});
475 $sth_shelfbrowse_previous = $dbh->prepare("
479 ((cn_sort = ? AND itemnumber < ?) OR cn_sort < ?) AND
481 ORDER BY cn_sort DESC, itemnumber LIMIT 3
483 $sth_shelfbrowse_previous->execute($starting_cn_sort, $starting_itemnumber, $starting_cn_sort, $starting_homebranch->{code});
486 while (my $this_item = $sth_shelfbrowse_previous->fetchrow_hashref()) {
487 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=?");
488 $sth_get_biblio->execute($this_item->{biblionumber});
489 while (my $this_biblio = $sth_get_biblio->fetchrow_hashref()) {
490 $this_item->{'title'} = $this_biblio->{'title'};
491 my $this_record = GetMarcBiblio($this_biblio->{'biblionumber'});
492 $this_item->{'browser_normalized_upc'} = GetNormalizedUPC($this_record,$marcflavour);
493 $this_item->{'browser_normalized_oclc'} = GetNormalizedOCLCNumber($this_record,$marcflavour);
494 $this_item->{'browser_normalized_isbn'} = GetNormalizedISBN(undef,$this_record,$marcflavour);
496 unshift @previous_items, $this_item;
499 ## List of Next Items; this also intentionally catches the current item
500 my $sth_shelfbrowse_next;
501 if (defined $starting_location->{code}) {
502 $sth_shelfbrowse_next = $dbh->prepare("
506 ((cn_sort = ? AND itemnumber >= ?) OR cn_sort > ?) AND
507 homebranch = ? AND location = ?
508 ORDER BY cn_sort, itemnumber LIMIT 3
510 $sth_shelfbrowse_next->execute($starting_cn_sort, $starting_itemnumber, $starting_cn_sort, $starting_homebranch->{code}, $starting_location->{code});
512 $sth_shelfbrowse_next = $dbh->prepare("
516 ((cn_sort = ? AND itemnumber >= ?) OR cn_sort > ?) AND
518 ORDER BY cn_sort, itemnumber LIMIT 3
520 $sth_shelfbrowse_next->execute($starting_cn_sort, $starting_itemnumber, $starting_cn_sort, $starting_homebranch->{code});
523 while (my $this_item = $sth_shelfbrowse_next->fetchrow_hashref()) {
524 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=?");
525 $sth_get_biblio->execute($this_item->{biblionumber});
526 while (my $this_biblio = $sth_get_biblio->fetchrow_hashref()) {
527 $this_item->{'title'} = $this_biblio->{'title'};
528 my $this_record = GetMarcBiblio($this_biblio->{'biblionumber'});
529 $this_item->{'browser_normalized_upc'} = GetNormalizedUPC($this_record,$marcflavour);
530 $this_item->{'browser_normalized_oclc'} = GetNormalizedOCLCNumber($this_record,$marcflavour);
531 $this_item->{'browser_normalized_isbn'} = GetNormalizedISBN(undef,$this_record,$marcflavour);
533 push @next_items, $this_item;
536 # alas, these won't auto-vivify, see http://www.perlmonks.org/?node_id=508481
537 my $shelfbrowser_next_itemnumber = $next_items[-1]->{itemnumber} if @next_items;
538 my $shelfbrowser_next_biblionumber = $next_items[-1]->{biblionumber} if @next_items;
541 starting_homebranch => $starting_homebranch->{description},
542 starting_location => $starting_location->{description},
543 starting_itemnumber => $starting_itemnumber,
544 shelfbrowser_prev_itemnumber => (@previous_items ? $previous_items[0]->{itemnumber} : 0),
545 shelfbrowser_next_itemnumber => $shelfbrowser_next_itemnumber,
546 shelfbrowser_prev_biblionumber => (@previous_items ? $previous_items[0]->{biblionumber} : 0),
547 shelfbrowser_next_biblionumber => $shelfbrowser_next_biblionumber,
548 PREVIOUS_SHELF_BROWSE => \@previous_items,
549 NEXT_SHELF_BROWSE => \@next_items,
553 if (C4::Context->preference("BakerTaylorEnabled")) {
555 BakerTaylorEnabled => 1,
556 BakerTaylorImageURL => &image_url(),
557 BakerTaylorLinkURL => &link_url(),
558 BakerTaylorBookstoreURL => C4::Context->preference('BakerTaylorBookstoreURL'),
560 my ($bt_user, $bt_pass);
562 $bt_user = C4::Context->preference('BakerTaylorUsername') and
563 $bt_pass = C4::Context->preference('BakerTaylorPassword') )
566 BakerTaylorContentURL =>
567 sprintf("http://contentcafe2.btol.com/ContentCafeClient/ContentCafe.aspx?UserID=%s&Password=%s&ItemKey=%s&Options=Y",
568 $bt_user,$bt_pass,$isbn)
574 if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->preference('TagsShowOnDetail')) {
577 TagsShowOnDetail => $tag_quantity,
578 TagsInputOnDetail => C4::Context->preference('TagsInputOnDetail')
580 $template->param(TagLoop => get_tags({biblionumber=>$biblionumber, approved=>1,
581 'sort'=>'-weight', limit=>$tag_quantity}));
584 #Search for title in links
585 if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
586 $search_for_title =~ s/{AUTHOR}/$dat->{author}/g;
587 $search_for_title =~ s/{TITLE}/$dat->{title}/g;
588 $search_for_title =~ s/{ISBN}/$isbn/g;
589 $template->param('OPACSearchForTitleIn' => $search_for_title);
592 # We try to select the best default tab to show, according to what
593 # the user wants, and what's available for display
595 switch (C4::Context->preference('opacSerialDefaultTab')) {
597 # If the user wants subscriptions by default
598 case "subscriptions" {
599 # And there are subscriptions, we display them
600 if ($subscriptionsnumber) {
601 $defaulttab = 'subscriptions';
603 # Else, we try next option
608 case "serialcollection" {
609 if (scalar(@serialcollections) > 0) {
610 $defaulttab = 'serialcollection' ;
617 if ($dat->{'count'} > 0) {
618 $defaulttab = 'holdings';
620 # As this is the last option, we try other options if there are no items
621 if ($subscriptionsnumber) {
622 $defaulttab = 'subscriptions';
623 } elsif (scalar(@serialcollections) > 0) {
624 $defaulttab = 'serialcollection' ;
631 $template->param('defaulttab' => $defaulttab);
635 output_html_with_http_headers $query, $cookie, $template->output;