+# We try to select the best default tab to show, according to what
+# the user wants, and what's available for display
+my $defaulttab;
+switch (C4::Context->preference('opacSerialDefaultTab')) {
+
+ # If the user wants subscriptions by default
+ case "subscriptions" {
+ # And there are subscriptions, we display them
+ if ($subscriptionsnumber) {
+ $defaulttab = 'subscriptions';
+ } else {
+ # Else, we try next option
+ next;
+ }
+ }
+
+ case "serialcollection" {
+ if (scalar(@serialcollections) > 0) {
+ $defaulttab = 'serialcollection' ;
+ } else {
+ next;
+ }
+ }
+
+ case "holdings" {
+ if ($dat->{'count'} > 0) {
+ $dat->{'defaultholdings'} = 1;
+ } else {
+ # As this is the last option, we try other options if there are no items
+ if ($subscriptionsnumber) {
+ $defaulttab = 'subscriptions';
+ } elsif (scalar(@serialcollections) > 0) {
+ $defaulttab = 'serialcollection' ;
+ }
+ }
+
+ }
+
+}
+$template->param('defaulttab' => $defaulttab);
+
+