@@ -, +, @@ --- opac/opac-MARCdetail.pl | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) --- a/opac/opac-MARCdetail.pl +++ a/opac/opac-MARCdetail.pl @@ -52,14 +52,33 @@ use MARC::Record; use C4::Biblio; use C4::Acquisition; use C4::Koha; +use C4::Items; +use List::MoreUtils qw/any/; my $query = new CGI; my $dbh = C4::Context->dbh; my $biblionumber = $query->param('biblionumber'); +if ( ! $biblionumber ) { + print $query->redirect("/cgi-bin/koha/errors/404.pl"); + exit; +} + +my @all_items = GetItemsInfo($biblionumber); +my @items2hide; +if (scalar @all_items >= 1) { + push @items2hide, GetHiddenItemnumbers(@all_items); + + if (scalar @items2hide == scalar @all_items ) { + print $query->redirect("/cgi-bin/koha/errors/404.pl"); + exit; + } +} + my $itemtype = &GetFrameworkCode($biblionumber); my $tagslib = &GetMarcStructure( 0, $itemtype ); +my ($tag_itemnumber,$subtag_itemnumber) = &GetMarcFromKohaField('items.itemnumber',$itemtype); my $biblio = GetBiblioData($biblionumber); $biblionumber = $biblio->{biblionumber}; my $record = GetMarcBiblio($biblionumber, 1); @@ -209,7 +228,6 @@ for ( my $tabloop = 0 ; $tabloop <= 9 ; $tabloop++ ) { $template->param( "tab" . $tabloop . "XX" => \@loop_data ); } - # now, build item tab ! # the main difference is that datas are in lines and not in columns : thus, we build the first, then the values... # loop through each tag @@ -223,6 +241,9 @@ foreach my $field (@fields) { next if ( $field->tag() < 10 ); my @subf = $field->subfields; my %this_row; + next if ( ($field->tag() eq $tag_itemnumber) && + (any { $field->subfield($subtag_itemnumber) eq $_ } + @items2hide) ); # loop through each subfield for my $i ( 0 .. $#subf ) { --