Bug 17792: Add opac_editable and opac_display methods
[koha.git] / catalogue / getitem-ajax.pl
index 6974a8f..99814dc 100755 (executable)
@@ -55,21 +55,21 @@ if($itemnumber) {
         $item->{holdingbranchname} = Koha::Libraries->find($item->{holdingbranch})->branchname;
     }
 
-    my $av;
-    $av = Koha::AuthorisedValues->find_by_koha_field({ frameworkcode => $fw, kohafield => 'items.notforloan', authorised_value => $item->{notforloan} });
-    $item->{notforloan} = $av ? $av->lib : '';
+    my $descriptions;
+    $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $fw, kohafield => 'items.notforloan', authorised_value => $item->{notforloan} });
+    $item->{notforloan} = $descriptions->{lib} // '';
 
-    $av = Koha::AuthorisedValues->find_by_koha_field({ frameworkcode => $fw, kohafield => 'items.restricted', authorised_value => $item->{restricted} });
-    $item->{restricted} = $av ? $av->lib : '';
+    $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $fw, kohafield => 'items.restricted', authorised_value => $item->{restricted} });
+    $item->{restricted} = $descriptions->{lib} // '';
 
-    $av = Koha::AuthorisedValues->find_by_koha_field({ frameworkcode => $fw, kohafield => 'items.location', authorised_value => $item->{location} });
-    $item->{location} = $av ? $av->lib : '';
+    $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $fw, kohafield => 'items.location', authorised_value => $item->{location} });
+    $item->{location} = $descriptions->{lib} // '';
 
-    $av = Koha::AuthorisedValues->find_by_koha_field({ frameworkcode => $fw, kohafield => 'items.collection', authorised_value => $item->{collection} });
-    $item->{collection} = $av ? $av->lib : '';
+    $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $fw, kohafield => 'items.collection', authorised_value => $item->{collection} });
+    $item->{collection} = $descriptions->{lib} // '';
 
-    $av = Koha::AuthorisedValues->find_by_koha_field({ frameworkcode => $fw, kohafield => 'items.materials', authorised_value => $item->{materials} });
-    $item->{materials} = $av ? $av->lib : '';
+    $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $fw, kohafield => 'items.materials', authorised_value => $item->{materials} });
+    $item->{materials} = $descriptions->{lib} // '';
 
     my $itemtype = getitemtypeinfo($item->{itype});
     $item->{itemtype} = $itemtype->{description};