From 33ae2d5fe5ffb93dd5795f4310b74eac8b2cdc4b Mon Sep 17 00:00:00 2001 From: Thibaud Guillot Date: Mon, 12 Sep 2022 11:04:07 +0200 Subject: [PATCH] Bug 31550: Add fields to get opac description on ILSDI web service Test plan 1) Active your ILS-DI syspref 2) Have some authorised values linked to one or more concern fields 3) Choose an item and go to 'cgi-bin/koha/opac/ilsdi.pl?service=GetRecords&id=' 4) The XML file contains item fields with some of them the code associated to the authorized values. 5) Apply this patch 6) Repeat step 3 and see the new fields with specific "_description" suffix added and contains opac description from authorized values https://bugs.koha-community.org/show_bug.cgi?id=31550 Signed-off-by: David Nind --- C4/ILSDI/Services.pm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm index 77243a882a..06c23c26fc 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -253,10 +253,15 @@ sub GetRecords { $item{'homebranchname'} = $home_library ? $home_library->branchname : ''; $item{'holdingbranchname'} = $holding_library ? $holding_library->branchname : ''; - if ($item->location) { - my $authorised_value = Koha::AuthorisedValues->find_by_koha_field({ kohafield => 'items.location', authorised_value => $item->location }); - if ($authorised_value) { - $item{location_description} = $authorised_value->opac_description; + my @item_fields_description = ( 'location', 'ccode', 'permanent_location', 'notforloan', 'itemlost', 'withdrawn', 'damaged', 'restricted' ); + + foreach (@item_fields_description) { + + if ( $item->$_ ) { + my $authorised_value = Koha::AuthorisedValues->find_by_koha_field( { kohafield => 'items.' . $_, authorised_value => $item->$_ } ); + if ($authorised_value) { + $item{ $_ . _description } = $authorised_value->opac_description; + } } } -- 2.30.2