Bug 10856: Improve the previous and next items on the shelf browser
[koha.git] / opac / opac-ISBDdetail.pl
index 94055a9..2579a8b 100755 (executable)
@@ -84,6 +84,17 @@ $template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHo
 $template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
 
 my $marcflavour      = C4::Context->preference("marcflavour");
+
+my @items = GetItemsInfo($biblionumber);
+if (scalar @items >= 1) {
+    my @hiddenitems = GetHiddenItemnumbers(@items);
+
+    if (scalar @hiddenitems == scalar @items ) {
+        print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
+        exit;
+    }
+}
+
 my $record = GetMarcBiblio($biblionumber);
 if ( ! $record ) {
     print $query->redirect("/cgi-bin/koha/errors/404.pl");
@@ -138,12 +149,11 @@ $template->param(
 
 my $norequests = 1;
 my $res = GetISBDView($biblionumber, "opac");
-my @items = GetItemsInfo( $biblionumber );
 
 my $itemtypes = GetItemTypes();
 for my $itm (@items) {
     $norequests = 0
-       if ( (not $itm->{'wthdrawn'} )
+       if ( (not $itm->{'withdrawn'} )
          && (not $itm->{'itemlost'} )
          && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'} )
                 && (not $itemtypes->{$itm->{'itype'}}->{notforloan} )