73941e05ea6012cd68d54e407c27209f4f4da11c
[koha.git] / opac / opac-detail.pl
1 #!/usr/bin/perl
2
3 # Copyright 2000-2002 Katipo Communications
4 # Copyright 2010 BibLibre
5 #
6 # This file is part of Koha.
7 #
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
11 # version.
12 #
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License along
18 # with Koha; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21
22 use strict;
23 use warnings;
24
25 use CGI;
26 use C4::Auth;
27 use C4::Branch;
28 use C4::Koha;
29 use C4::Serials;    #uses getsubscriptionfrom biblionumber
30 use C4::Output;
31 use C4::Biblio;
32 use C4::Items;
33 use C4::Circulation;
34 use C4::Tags qw(get_tags);
35 use C4::Dates qw/format_date/;
36 use C4::XISBN qw(get_xisbns get_biblionumber_from_isbn);
37 use C4::External::Amazon;
38 use C4::External::Syndetics qw(get_syndetics_index get_syndetics_summary get_syndetics_toc get_syndetics_excerpt get_syndetics_reviews get_syndetics_anotes );
39 use C4::Review;
40 use C4::Members;
41 use C4::VirtualShelves;
42 use C4::XSLT;
43 use C4::ShelfBrowser;
44
45 BEGIN {
46         if (C4::Context->preference('BakerTaylorEnabled')) {
47                 require C4::External::BakerTaylor;
48                 import C4::External::BakerTaylor qw(&image_url &link_url);
49         }
50 }
51
52 my $query = new CGI;
53 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
54     {
55         template_name   => "opac-detail.tmpl",
56         query           => $query,
57         type            => "opac",
58         authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
59         flagsrequired   => { borrow => 1 },
60     }
61 );
62
63 my $biblionumber = $query->param('biblionumber') || $query->param('bib');
64
65 $template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHolds') );
66 $template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
67
68 my $record       = GetMarcBiblio($biblionumber);
69 if ( ! $record ) {
70     print $query->redirect("/cgi-bin/koha/errors/404.pl");
71     exit;
72 }
73 $template->param( biblionumber => $biblionumber );
74         use C4::Charset;
75         SetUTF8Flag($record);
76 # XSLT processing of some stuff
77 if (C4::Context->preference("OPACXSLTDetailsDisplay") ) {
78     $template->param( 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, 'Detail', 'opac') );
79 }
80
81 $template->param('OPACShowCheckoutName' => C4::Context->preference("OPACShowCheckoutName") ); 
82 # change back when ive fixed request.pl
83 my @all_items = &GetItemsInfo( $biblionumber, 'opac' );
84 my @items;
85 @items = @all_items unless C4::Context->preference('hidelostitems');
86
87 if (C4::Context->preference('hidelostitems')) {
88     # Hide host items
89     for my $itm (@all_items) {
90         push @items, $itm unless $itm->{itemlost};
91     }
92 }
93 my $dat = &GetBiblioData($biblionumber);
94
95 my $itemtypes = GetItemTypes();
96 # imageurl:
97 my $itemtype = $dat->{'itemtype'};
98 if ( $itemtype ) {
99     $dat->{'imageurl'}    = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} );
100     $dat->{'description'} = $itemtypes->{$itemtype}->{'description'};
101 }
102 my $shelflocations =GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'}, 'opac');
103 my $collections =  GetKohaAuthorisedValues('items.ccode',$dat->{'frameworkcode'}, 'opac');
104
105 #coping with subscriptions
106 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
107 my @subscriptions       = GetSubscriptions( undef, undef, $biblionumber );
108
109 my @subs;
110 $dat->{'serial'}=1 if $subscriptionsnumber;
111 foreach my $subscription (@subscriptions) {
112     my $serials_to_display;
113     my %cell;
114     $cell{subscriptionid}    = $subscription->{subscriptionid};
115     $cell{subscriptionnotes} = $subscription->{notes};
116     $cell{missinglist}       = $subscription->{missinglist};
117     $cell{opacnote}          = $subscription->{opacnote};
118     $cell{histstartdate}     = format_date($subscription->{histstartdate});
119     $cell{histenddate}       = format_date($subscription->{histenddate});
120     $cell{branchcode}        = $subscription->{branchcode};
121     $cell{branchname}        = GetBranchName($subscription->{branchcode});
122     $cell{hasalert}          = $subscription->{hasalert};
123     #get the three latest serials.
124     $serials_to_display = $subscription->{opacdisplaycount};
125     $serials_to_display = C4::Context->preference('OPACSerialIssueDisplayCount') unless $serials_to_display;
126         $cell{opacdisplaycount} = $serials_to_display;
127     $cell{latestserials} =
128       GetLatestSerials( $subscription->{subscriptionid}, $serials_to_display );
129     push @subs, \%cell;
130 }
131
132 $dat->{'count'} = scalar(@items);
133
134 # If there is a lot of items, and the user has not decided
135 # to view them all yet, we first warn him
136 # TODO: The limit of 50 could be a syspref
137 my $viewallitems = $query->param('viewallitems');
138 if ($dat->{'count'} >= 50 && !$viewallitems) {
139     $template->param('lotsofitems' => 1);
140 }
141
142 my $biblio_authorised_value_images = C4::Items::get_authorised_value_images( C4::Biblio::get_biblio_authorised_values( $biblionumber, $record ) );
143
144 my $norequests = 1;
145 my $branches = GetBranches();
146 my %itemfields;
147 for my $itm (@items) {
148     $norequests = 0
149        if ( (not $itm->{'wthdrawn'} )
150          && (not $itm->{'itemlost'} )
151          && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'} )
152                  && (not $itemtypes->{$itm->{'itype'}}->{notforloan} )
153          && ($itm->{'itemnumber'} ) );
154
155     if ( defined $itm->{'publictype'} ) {
156         # I can't actually find any case in which this is defined. --amoore 2008-12-09
157         $itm->{ $itm->{'publictype'} } = 1;
158     }
159     $itm->{datedue}      = format_date($itm->{datedue});
160     $itm->{datelastseen} = format_date($itm->{datelastseen});
161
162     # get collection code description, too
163     if ( my $ccode = $itm->{'ccode'} ) {
164         $itm->{'ccode'} = $collections->{$ccode} if ( defined($collections) && exists( $collections->{$ccode} ) );
165     }
166     if ( defined $itm->{'location'} ) {
167         $itm->{'location_description'} = $shelflocations->{ $itm->{'location'} };
168     }
169     if (exists $itm->{itype} && defined($itm->{itype}) && exists $itemtypes->{ $itm->{itype} }) {
170         $itm->{'imageurl'}    = getitemtypeimagelocation( 'opac', $itemtypes->{ $itm->{itype} }->{'imageurl'} );
171         $itm->{'description'} = $itemtypes->{ $itm->{itype} }->{'description'};
172     }
173     foreach (qw(ccode enumchron copynumber itemnotes uri)) {
174         $itemfields{$_} = 1 if ($itm->{$_});
175     }
176
177      # walk through the item-level authorised values and populate some images
178      my $item_authorised_value_images = C4::Items::get_authorised_value_images( C4::Items::get_item_authorised_values( $itm->{'itemnumber'} ) );
179      # warn( Data::Dumper->Dump( [ $item_authorised_value_images ], [ 'item_authorised_value_images' ] ) );
180
181      if ( $itm->{'itemlost'} ) {
182          my $lostimageinfo = List::Util::first { $_->{'category'} eq 'LOST' } @$item_authorised_value_images;
183          $itm->{'lostimageurl'}   = $lostimageinfo->{ 'imageurl' };
184          $itm->{'lostimagelabel'} = $lostimageinfo->{ 'label' };
185      }
186
187      if( $itm->{'count_reserves'}){
188           if( $itm->{'count_reserves'} eq "Waiting"){ $itm->{'waiting'} = 1; }
189           if( $itm->{'count_reserves'} eq "Reserved"){ $itm->{'onhold'} = 1; }
190      }
191     
192      my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($itm->{itemnumber});
193      if ( defined( $transfertwhen ) && $transfertwhen ne '' ) {
194         $itm->{transfertwhen} = format_date($transfertwhen);
195         $itm->{transfertfrom} = $branches->{$transfertfrom}{branchname};
196         $itm->{transfertto}   = $branches->{$transfertto}{branchname};
197      }
198 }
199
200 ## get notes and subjects from MARC record
201 my $dbh              = C4::Context->dbh;
202 my $marcflavour      = C4::Context->preference("marcflavour");
203 my $marcnotesarray   = GetMarcNotes   ($record,$marcflavour);
204 my $marcisbnsarray   = GetMarcISBN    ($record,$marcflavour);
205 my $marcauthorsarray = GetMarcAuthors ($record,$marcflavour);
206 my $marcsubjctsarray = GetMarcSubjects($record,$marcflavour);
207 my $marcseriesarray  = GetMarcSeries  ($record,$marcflavour);
208 my $marcurlsarray    = GetMarcUrls    ($record,$marcflavour);
209 my $subtitle         = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber));
210
211     $template->param(
212                      MARCNOTES               => $marcnotesarray,
213                      MARCSUBJCTS             => $marcsubjctsarray,
214                      MARCAUTHORS             => $marcauthorsarray,
215                      MARCSERIES              => $marcseriesarray,
216                      MARCURLS                => $marcurlsarray,
217                      norequests              => $norequests,
218                      RequestOnOpac           => C4::Context->preference("RequestOnOpac"),
219                      itemdata_ccode          => $itemfields{ccode},
220                      itemdata_enumchron      => $itemfields{enumchron},
221                      itemdata_uri            => $itemfields{uri},
222                      itemdata_copynumber     => $itemfields{copynumber},
223                      itemdata_itemnotes          => $itemfields{itemnotes},
224                      authorised_value_images => $biblio_authorised_value_images,
225                      subtitle                => $subtitle,
226     );
227
228 foreach ( keys %{$dat} ) {
229     $template->param( "$_" => defined $dat->{$_} ? $dat->{$_} : '' );
230 }
231
232 # some useful variables for enhanced content;
233 # in each case, we're grabbing the first value we find in
234 # the record and normalizing it
235 my $upc = GetNormalizedUPC($record,$marcflavour);
236 my $ean = GetNormalizedEAN($record,$marcflavour);
237 my $oclc = GetNormalizedOCLCNumber($record,$marcflavour);
238 my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
239 my $content_identifier_exists = 1 if ($isbn or $ean or $oclc or $upc);
240 $template->param(
241         normalized_upc => $upc,
242         normalized_ean => $ean,
243         normalized_oclc => $oclc,
244         normalized_isbn => $isbn,
245         content_identifier_exists =>  $content_identifier_exists,
246 );
247
248 # COinS format FIXME: for books Only
249 $template->param(
250     ocoins => GetCOinSBiblio($biblionumber),
251 );
252
253 my $reviews = getreviews( $biblionumber, 1 );
254 my $loggedincommenter;
255 foreach ( @$reviews ) {
256     my $borrowerData   = GetMember('borrowernumber' => $_->{borrowernumber});
257     # setting some borrower info into this hash
258     $_->{title}     = $borrowerData->{'title'};
259     $_->{surname}   = $borrowerData->{'surname'};
260     $_->{firstname} = $borrowerData->{'firstname'};
261     $_->{userid}    = $borrowerData->{'userid'};
262     $_->{cardnumber}    = $borrowerData->{'cardnumber'};
263     $_->{datereviewed} = format_date($_->{datereviewed});
264     if ($borrowerData->{'borrowernumber'} eq $borrowernumber) {
265                 $_->{your_comment} = 1;
266                 $loggedincommenter = 1;
267         }
268 }
269
270
271 if(C4::Context->preference("ISBD")) {
272         $template->param(ISBD => 1);
273 }
274
275 $template->param(
276     ITEM_RESULTS        => \@items,
277     subscriptionsnumber => $subscriptionsnumber,
278     biblionumber        => $biblionumber,
279     subscriptions       => \@subs,
280     subscriptionsnumber => $subscriptionsnumber,
281     reviews             => $reviews,
282     loggedincommenter   => $loggedincommenter
283 );
284
285 # Lists
286
287 if (C4::Context->preference("virtualshelves") ) {
288    $template->param( 'GetShelves' => GetBibliosShelves( $biblionumber ) );
289 }
290
291
292 # XISBN Stuff
293 if (C4::Context->preference("OPACFRBRizeEditions")==1) {
294     eval {
295         $template->param(
296             XISBNS => get_xisbns($isbn)
297         );
298     };
299     if ($@) { warn "XISBN Failed $@"; }
300 }
301
302 # Serial Collection
303 my @sc_fields = $record->field(955);
304 my @serialcollections = ();
305
306 foreach my $sc_field (@sc_fields) {
307     my %row_data;
308
309     $row_data{text}    = $sc_field->subfield('r');
310     $row_data{branch}  = $sc_field->subfield('9');
311
312     if ($row_data{text} && $row_data{branch}) { 
313         push (@serialcollections, \%row_data);
314     }
315 }
316
317 if (scalar(@serialcollections) > 0) {
318     $template->param(
319         serialcollection  => 1,
320         serialcollections => \@serialcollections);
321 }
322
323 # Amazon.com Stuff
324 if ( C4::Context->preference("OPACAmazonEnabled") ) {
325     $template->param( AmazonTld => get_amazon_tld() );
326     my $amazon_reviews  = C4::Context->preference("OPACAmazonReviews");
327     my $amazon_similars = C4::Context->preference("OPACAmazonSimilarItems");
328     my @services;
329     if ( $amazon_reviews ) {
330         push( @services, 'EditorialReview', 'Reviews' );
331     }
332     if ( $amazon_similars ) {
333         push( @services, 'Similarities' );
334     }
335     my $amazon_details = &get_amazon_details( $isbn, $record, $marcflavour, \@services );
336     my $similar_products_exist;
337     if ( $amazon_reviews ) {
338         my $item = $amazon_details->{Items}->{Item}->[0];
339         my $customer_reviews = \@{ $item->{CustomerReviews}->{Review} };
340         for my $one_review ( @$customer_reviews ) {
341             $one_review->{Date} = format_date($one_review->{Date});
342         }
343         my $editorial_reviews = \@{ $item->{EditorialReviews}->{EditorialReview} };
344         my $average_rating = $item->{CustomerReviews}->{AverageRating} || 0;
345         $template->param( amazon_average_rating    => $average_rating * 20);
346         $template->param( AMAZON_CUSTOMER_REVIEWS  => $customer_reviews );
347         $template->param( AMAZON_EDITORIAL_REVIEWS => $editorial_reviews );
348     }
349     if ( $amazon_similars ) {
350         my $item = $amazon_details->{Items}->{Item}->[0];
351         my @similar_products;
352         for my $similar_product (@{ $item->{SimilarProducts}->{SimilarProduct} }) {
353             # do we have any of these isbns in our collection?
354             my $similar_biblionumbers = get_biblionumber_from_isbn($similar_product->{ASIN});
355             # verify that there is at least one similar item
356             if (scalar(@$similar_biblionumbers)){
357                 $similar_products_exist++ if ($similar_biblionumbers && $similar_biblionumbers->[0]);
358                 push @similar_products, +{ similar_biblionumbers => $similar_biblionumbers, title => $similar_product->{Title}, ASIN => $similar_product->{ASIN}  };
359             }
360         }
361         $template->param( OPACAmazonSimilarItems => $similar_products_exist );
362         $template->param( AMAZON_SIMILAR_PRODUCTS => \@similar_products );
363     }
364 }
365
366 my $syndetics_elements;
367
368 if ( C4::Context->preference("SyndeticsEnabled") ) {
369     $template->param("SyndeticsEnabled" => 1);
370     $template->param("SyndeticsClientCode" => C4::Context->preference("SyndeticsClientCode"));
371         eval {
372             $syndetics_elements = &get_syndetics_index($isbn,$upc,$oclc);
373             for my $element (values %$syndetics_elements) {
374                 $template->param("Syndetics$element"."Exists" => 1 );
375                 #warn "Exists: "."Syndetics$element"."Exists";
376         }
377     };
378     warn $@ if $@;
379 }
380
381 if ( C4::Context->preference("SyndeticsEnabled")
382         && C4::Context->preference("SyndeticsSummary")
383         && ( exists($syndetics_elements->{'SUMMARY'}) || exists($syndetics_elements->{'AVSUMMARY'}) ) ) {
384         eval {
385             my $syndetics_summary = &get_syndetics_summary($isbn,$upc,$oclc, $syndetics_elements);
386             $template->param( SYNDETICS_SUMMARY => $syndetics_summary );
387         };
388         warn $@ if $@;
389
390 }
391
392 if ( C4::Context->preference("SyndeticsEnabled")
393         && C4::Context->preference("SyndeticsTOC")
394         && exists($syndetics_elements->{'TOC'}) ) {
395         eval {
396     my $syndetics_toc = &get_syndetics_toc($isbn,$upc,$oclc);
397     $template->param( SYNDETICS_TOC => $syndetics_toc );
398         };
399         warn $@ if $@;
400 }
401
402 if ( C4::Context->preference("SyndeticsEnabled")
403     && C4::Context->preference("SyndeticsExcerpt")
404     && exists($syndetics_elements->{'DBCHAPTER'}) ) {
405     eval {
406     my $syndetics_excerpt = &get_syndetics_excerpt($isbn,$upc,$oclc);
407     $template->param( SYNDETICS_EXCERPT => $syndetics_excerpt );
408     };
409         warn $@ if $@;
410 }
411
412 if ( C4::Context->preference("SyndeticsEnabled")
413     && C4::Context->preference("SyndeticsReviews")) {
414     eval {
415     my $syndetics_reviews = &get_syndetics_reviews($isbn,$upc,$oclc,$syndetics_elements);
416     $template->param( SYNDETICS_REVIEWS => $syndetics_reviews );
417     };
418         warn $@ if $@;
419 }
420
421 if ( C4::Context->preference("SyndeticsEnabled")
422     && C4::Context->preference("SyndeticsAuthorNotes")
423         && exists($syndetics_elements->{'ANOTES'}) ) {
424     eval {
425     my $syndetics_anotes = &get_syndetics_anotes($isbn,$upc,$oclc);
426     $template->param( SYNDETICS_ANOTES => $syndetics_anotes );
427     };
428     warn $@ if $@;
429 }
430
431 # LibraryThingForLibraries ID Code and Tabbed View Option
432 if( C4::Context->preference('LibraryThingForLibrariesEnabled') ) 
433
434 $template->param(LibraryThingForLibrariesID =>
435 C4::Context->preference('LibraryThingForLibrariesID') ); 
436 $template->param(LibraryThingForLibrariesTabbedView =>
437 C4::Context->preference('LibraryThingForLibrariesTabbedView') );
438
439
440
441 # Babelthèque
442 if ( C4::Context->preference("Babeltheque") ) {
443     $template->param( 
444         Babeltheque => 1,
445     );
446 }
447
448 # Shelf Browser Stuff
449 if (C4::Context->preference("OPACShelfBrowser")) {
450     # pick the first itemnumber unless one was selected by the user
451     my $starting_itemnumber = $query->param('shelfbrowse_itemnumber'); # || $items[0]->{itemnumber};
452     if (defined($starting_itemnumber)) {
453         $template->param( OpenOPACShelfBrowser => 1) if $starting_itemnumber;
454         my $nearby = GetNearbyItems($starting_itemnumber,3);
455
456         $template->param(
457             starting_homebranch => $nearby->{starting_homebranch}->{description},
458             starting_location => $nearby->{starting_location}->{description},
459             starting_ccode => $nearby->{starting_ccode}->{description},
460             starting_itemnumber => $nearby->{starting_itemnumber},
461             shelfbrowser_prev_itemnumber => $nearby->{prev_itemnumber},
462             shelfbrowser_next_itemnumber => $nearby->{next_itemnumber},
463             shelfbrowser_prev_biblionumber => $nearby->{prev_biblionumber},
464             shelfbrowser_next_biblionumber => $nearby->{next_biblionumber},
465             PREVIOUS_SHELF_BROWSE => $nearby->{prev},
466             NEXT_SHELF_BROWSE => $nearby->{next},
467         );
468     }
469 }
470
471 if (C4::Context->preference("BakerTaylorEnabled")) {
472         $template->param(
473                 BakerTaylorEnabled  => 1,
474                 BakerTaylorImageURL => &image_url(),
475                 BakerTaylorLinkURL  => &link_url(),
476                 BakerTaylorBookstoreURL => C4::Context->preference('BakerTaylorBookstoreURL'),
477         );
478         my ($bt_user, $bt_pass);
479         if ($isbn and
480                 $bt_user = C4::Context->preference('BakerTaylorUsername') and
481                 $bt_pass = C4::Context->preference('BakerTaylorPassword')    )
482         {
483                 $template->param(
484                 BakerTaylorContentURL   =>
485                 sprintf("http://contentcafe2.btol.com/ContentCafeClient/ContentCafe.aspx?UserID=%s&Password=%s&ItemKey=%s&Options=Y",
486                                 $bt_user,$bt_pass,$isbn)
487                 );
488         }
489 }
490
491 my $tag_quantity;
492 if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->preference('TagsShowOnDetail')) {
493         $template->param(
494                 TagsEnabled => 1,
495                 TagsShowOnDetail => $tag_quantity,
496                 TagsInputOnDetail => C4::Context->preference('TagsInputOnDetail')
497         );
498         $template->param(TagLoop => get_tags({biblionumber=>$biblionumber, approved=>1,
499                                                                 'sort'=>'-weight', limit=>$tag_quantity}));
500 }
501
502 if (C4::Context->preference("OPACURLOpenInNewWindow")) {
503     # These values are going to be read by Javascript, at least in the case
504     # of the google covers
505     $template->param(covernewwindow => 'true');
506 } else {
507     $template->param(covernewwindow => 'false');
508 }
509
510 #Search for title in links
511 my $marccontrolnumber   = GetMarcControlnumber   ($record, $marcflavour);
512
513 if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
514     $dat->{author} ? $search_for_title =~ s/{AUTHOR}/$dat->{author}/g : $search_for_title =~ s/{AUTHOR}//g;
515     $dat->{title} =~ s/\/+$//; # remove trailing slash
516     $dat->{title} =~ s/\s+$//; # remove trailing space
517     $dat->{title} ? $search_for_title =~ s/{TITLE}/$dat->{title}/g : $search_for_title =~ s/{TITLE}//g;
518     $isbn ? $search_for_title =~ s/{ISBN}/$isbn/g : $search_for_title =~ s/{ISBN}//g;
519     $marccontrolnumber ? $search_for_title =~ s/{CONTROLNUMBER}/$marccontrolnumber/g : $search_for_title =~ s/{CONTROLNUMBER}//g;
520  $template->param('OPACSearchForTitleIn' => $search_for_title);
521 }
522
523 # We try to select the best default tab to show, according to what
524 # the user wants, and what's available for display
525 my $opac_serial_default = C4::Context->preference('opacSerialDefaultTab');
526 my $defaulttab = 
527     $opac_serial_default eq 'subscriptions' && $subscriptionsnumber
528         ? 'subscriptions' :
529     $opac_serial_default eq 'serialcollection' && @serialcollections > 0
530         ? 'serialcollection' :
531     $opac_serial_default eq 'holdings' && $dat->{'count'} > 0
532         ? 'holdings' :
533     $subscriptionsnumber
534         ? 'subscriptions' :
535     @serialcollections > 0 
536         ? 'serialcollection' : 'subscription';
537 $template->param('defaulttab' => $defaulttab);
538
539 output_html_with_http_headers $query, $cookie, $template->output;