Bug 17250: Do not retrieve marc subfield structure when the authorised value is not...
[koha.git] / catalogue / moredetail.pl
index b18d857..1a1adec 100755 (executable)
@@ -194,17 +194,17 @@ foreach my $item (@items){
 
 }
 
-my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost' });
+my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => { not => undef } });
 if ( $mss->count ) {
-    $template->param( itemlostloop => GetAuthorisedValues( $mss->next->authorisedvalue ) );
+    $template->param( itemlostloop => GetAuthorisedValues( $mss->next->authorised_value ) );
 }
-$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.damaged' });
+$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.damaged', authorised_value => { not => undef } });
 if ( $mss->count ) {
-    $template->param( itemdamagedloop => GetAuthorisedValues( $mss->next->authorisedvalue ) );
+    $template->param( itemdamagedloop => GetAuthorisedValues( $mss->next->authorised_value ) );
 }
-$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.withdrawn' });
+$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.withdrawn', authorised_value => { not => undef } });
 if ( $mss->count ) {
-    $template->param( itemwithdrawnloop => GetAuthorisedValues( $mss->next->authorisedvalue) );
+    $template->param( itemwithdrawnloop => GetAuthorisedValues( $mss->next->authorised_value) );
 }
 
 $template->param(count => $data->{'count'},