ENH: 3525 - Link to OPAC View from Staff Bib
[koha_fer] / catalogue / detail.pl
index 1f5a291..a24031e 100755 (executable)
@@ -34,6 +34,7 @@ use C4::Members;
 use C4::Serials;
 use C4::XISBN qw(get_xisbns get_biblionumber_from_isbn);
 use C4::External::Amazon;
+use C4::Search;                # enabled_staff_search_views
 
 # use Smart::Comments;
 
@@ -147,7 +148,7 @@ foreach my $item (@items) {
     $item->{'location'} = $shelflocations->{$shelfcode} if ( defined( $shelfcode ) && defined($shelflocations) && exists( $shelflocations->{$shelfcode} ) );
     my $ccode = $item->{'ccode'};
     $item->{'ccode'} = $collections->{$ccode} if ( defined( $ccode ) && defined($collections) && exists( $collections->{$ccode} ) );
-    foreach (qw(ccode enumchron copynumber)) {
+    foreach (qw(ccode enumchron copynumber uri)) {
         $itemfields{$_} = 1 if ( $item->{$_} );
     }
 
@@ -193,8 +194,11 @@ $template->param(
        subtitle    => $subtitle,
        itemdata_ccode      => $itemfields{ccode},
        itemdata_enumchron  => $itemfields{enumchron},
+       itemdata_uri        => $itemfields{uri},
        itemdata_copynumber => $itemfields{copynumber},
        volinfo                         => $itemfields{enumchron} || $dat->{'serial'} ,
+       z3950_search_params     => C4::Search::z3950_search_args($dat),
+       C4::Search::enabled_staff_search_views,
 );
 
 my @results = ( $dat, );
@@ -202,6 +206,9 @@ foreach ( keys %{$dat} ) {
     $template->param( "$_" => defined $dat->{$_} ? $dat->{$_} : '' );
 }
 
+# does not work: my %views_enabled = map { $_ => 1 } $template->query(loop => 'EnableViews');
+# method query not found?!?!
+
 $template->param(
     itemloop        => \@itemloop,
     biblionumber        => $biblionumber,
@@ -239,7 +246,7 @@ if ( C4::Context->preference("AmazonEnabled") == 1 ) {
     if ( $amazon_similars ) {
         my $similar_products_exist;
         my @similar_products;
-        for my $similar_product (@{$amazon_details->{Items}->{Item}->{SimilarProducts}->{SimilarProduct}}) {
+        for my $similar_product (@{$amazon_details->{Items}->{Item}->[0]->{SimilarProducts}->{SimilarProduct}}) {
             # do we have any of these isbns in our collection?
             my $similar_biblionumbers = get_biblionumber_from_isbn($similar_product->{ASIN});
             # verify that there is at least one similar item
@@ -252,13 +259,19 @@ if ( C4::Context->preference("AmazonEnabled") == 1 ) {
         $template->param( AMAZON_SIMILAR_PRODUCTS  => \@similar_products      );
     }
     if ( $amazon_reviews ) {
-        my $item = $amazon_details->{Items}->{Item};
+        my $item = $amazon_details->{Items}->{Item}->[0];
         my $editorial_reviews = \@{ $item->{EditorialReviews}->{EditorialReview} };
-        #my $customer_reviews  = \@{$amazon_details->{Items}->{Item}->{CustomerReviews}->{Review}};
-        #my $average_rating = $amazon_details->{Items}->{Item}->{CustomerReviews}->{AverageRating} || 0;
+        #my $customer_reviews  = \@{$amazon_details->{Items}->{Item}->[0]->{CustomerReviews}->{Review}};
+        #my $average_rating = $amazon_details->{Items}->{Item}->[0]->{CustomerReviews}->{AverageRating} || 0;
         #$template->param( amazon_average_rating    => $average_rating * 20    );
         #$template->param( AMAZON_CUSTOMER_REVIEWS  => $customer_reviews       );
         $template->param( AMAZON_EDITORIAL_REVIEWS => $editorial_reviews      );
     }
 }
+
+# Get OPAC URL
+if (C4::Context->preference('OPACBaseURL')){
+     $template->param( OpacUrl => C4::Context->preference('OPACBaseURL') );
+}
+
 output_html_with_http_headers $query, $cookie, $template->output;