-use HTML::Template;
-
-my $query=new CGI;
-
-my $dbh=C4::Context->dbh;
-
-my $biblionumber=$query->param('bib');
-my $bibid = $query->param('bibid');
-$bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$biblionumber) unless $bibid;
-$biblionumber = &MARCfind_oldbiblionumber_from_MARCbibid($dbh,$bibid) unless $biblionumber;
-my $itemtype = &MARCfind_frameworkcode($dbh,$bibid);
-my $tagslib = &MARCgettagslib($dbh,1,$itemtype);
-
-my $record =MARCgetbiblio($dbh,$bibid);
-# open template
-my ($template, $loggedinuser, $cookie)
- = get_template_and_user({template_name => "opac-ISBDdetail.tmpl",
- query => $query,
- type => "opac",
- authnotrequired => 1,
- debug => 1,
- });
-$template->param(LibraryName => C4::Context->preference("LibraryName"),
- suggestion => C4::Context->preference("suggestion"),
- virtualshelves => C4::Context->preference("virtualshelves"),
+use C4::Review;
+use C4::Serials; # uses getsubscriptionfrom biblionumber
+use C4::Koha;
+use C4::Members; # GetMember
+use C4::External::Amazon;
+
+my $query = CGI->new();
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name => "opac-ISBDdetail.tmpl",
+ query => $query,
+ type => "opac",
+ authnotrequired => 1,
+ debug => 1,
+ }
+);
+
+my $biblionumber = $query->param('biblionumber');
+
+$template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHolds') );
+$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
+
+my $marcflavour = C4::Context->preference("marcflavour");
+my $record = GetMarcBiblio($biblionumber);
+
+# some useful variables for enhanced content;
+# in each case, we're grabbing the first value we find in
+# the record and normalizing it
+my $upc = GetNormalizedUPC($record,$marcflavour);
+my $ean = GetNormalizedEAN($record,$marcflavour);
+my $oclc = GetNormalizedOCLCNumber($record,$marcflavour);
+my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
+my $content_identifier_exists = 1 if ($isbn or $ean or $oclc or $upc);
+$template->param(
+ normalized_upc => $upc,
+ normalized_ean => $ean,
+ normalized_oclc => $oclc,
+ normalized_isbn => $isbn,
+ content_identifier_exists => $content_identifier_exists,
+);
+
+#coping with subscriptions
+my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
+my $dbh = C4::Context->dbh;
+my $dat = TransformMarcToKoha( $dbh, $record );
+my @subscriptions =
+ GetSubscriptions( $dat->{title}, $dat->{issn}, $biblionumber );
+my @subs;
+foreach my $subscription (@subscriptions) {
+ my %cell;
+ my $serials_to_display;
+ $cell{subscriptionid} = $subscription->{subscriptionid};
+ $cell{subscriptionnotes} = $subscription->{notes};
+ $cell{branchcode} = $subscription->{branchcode};
+
+ #get the three latest serials.
+ $serials_to_display = $subscription->{opacdisplaycount};
+ $serials_to_display = C4::Context->preference('OPACSerialIssueDisplayCount') unless $serials_to_display;
+ $cell{opacdisplaycount} = $serials_to_display;
+ $cell{latestserials} =
+ GetLatestSerials( $subscription->{subscriptionid}, $serials_to_display );
+ push @subs, \%cell;
+}
+
+$template->param(
+ subscriptions => \@subs,
+ subscriptionsnumber => $subscriptionsnumber,