From fe975cfaa0e2dfcf32dfcfa47a8f20562140832d Mon Sep 17 00:00:00 2001 From: wajasu Date: Fri, 7 Mar 2014 21:44:39 -0600 Subject: [PATCH] Bug 2946 - Lost items (hidden in Normal View) still show up in the MARC View in OPAC Hides the Holdings that are "Lost" and the entire Holdings table if all items are lost, when the hidelostitems syspref is "Don't Show". Should work in plain text view as well. For the OPAC MARC view of a biblio details. --- opac/opac-MARCdetail.pl | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl index aaa565d..7cb4c4f 100755 --- a/opac/opac-MARCdetail.pl +++ b/opac/opac-MARCdetail.pl @@ -255,12 +255,15 @@ foreach my $field (@fields) { @items2hide) ); my @subf = $field->subfields; my %this_row; + my $hideitem=0; # loop through each subfield for my $i ( 0 .. $#subf ) { my $sf_def = $tagslib->{ $field->tag() }->{ $subf[$i][0] }; + #warn "subf:$i $sf_def->{kohafield} $sf_def->{lib} $subf[$i][0]"; # see errlog to learn the mappings next if ( ($sf_def->{tab}||0) != 10 ); next if ( ($sf_def->{hidden}||0) > 0 ); + ( $hideitem=1) if (C4::Context->preference("hidelostitems") && ($sf_def->{kohafield} eq 'items.itemlost') && ($subf[$i][0] > 0) ); $witness{ $subf[$i][0] } = $sf_def->{lib}; if ( $sf_def->{isurl} ) { @@ -274,7 +277,7 @@ foreach my $field (@fields) { $subf[$i][1], '', $tagslib, '', 'opac' ); } } - if (%this_row) { + if (%this_row && !$hideitem) { push( @big_array, \%this_row ); } } @@ -304,10 +307,13 @@ for ( my $i = 0 ; $i <= $#big_array ; $i++ ) { push( @item_value_loop, \%row_data ); } -foreach my $subfield_code ( keys(%witness) ) { - my %header_value; - $header_value{header_value} = $witness{$subfield_code}; - push( @header_value_loop, \%header_value ); + +if (@item_value_loop > 0) { # prevent display of header if no items to display + foreach my $subfield_code ( keys(%witness) ) { + my %header_value; + $header_value{header_value} = $witness{$subfield_code}; + push( @header_value_loop, \%header_value ); + } } if(C4::Context->preference("ISBD")) { -- 1.8.5.3