-my $authvalcode_items_itemlost = GetAuthValCode('items.itemlost',$fw);
-my $authvalcode_items_damaged = GetAuthValCode('items.damaged', $fw);
+
+my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => { not => undef } });
+if ( $mss->count ) {
+ $template->param( itemlostloop => GetAuthorisedValues( $mss->next->authorised_value ) );
+}
+$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.damaged', authorised_value => { not => undef } });
+if ( $mss->count ) {
+ $template->param( itemdamagedloop => GetAuthorisedValues( $mss->next->authorised_value ) );
+}
+
+$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.materials', authorised_value => { not => undef } });
+my %materials_map;
+if ($mss->count) {
+ my $materials_authvals = GetAuthorisedValues($mss->next->authorised_value);
+ if ($materials_authvals) {
+ foreach my $value (@$materials_authvals) {
+ $materials_map{$value->{authorised_value}} = $value->{lib};
+ }
+ }
+}