From ee3238fa6bf80f62756019be9c9b0c580bcc2507 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 19 Apr 2017 16:15:36 -0300 Subject: [PATCH] Bug 18433: Add new subroutine GetDescriptionByKohaField to AuthorisedValues TT plugin To allow quick access to AV description --- Koha/Template/Plugin/AuthorisedValues.pm | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Koha/Template/Plugin/AuthorisedValues.pm b/Koha/Template/Plugin/AuthorisedValues.pm index 603f5a9..0ab30cb 100644 --- a/Koha/Template/Plugin/AuthorisedValues.pm +++ b/Koha/Template/Plugin/AuthorisedValues.pm @@ -69,12 +69,19 @@ sub GetCategories { ]; } -sub GetCategoryByKohaField { - my ($self, $kohafield, $frameworkcode) = @_; - - my $category = Koha::AuthorisedValueCategories->find_by_koha_field($kohafield, $frameworkcode); - - return $category ? $category->category_name : undef; +sub GetDescriptionByKohaField { + my ( $self, $params ) = @_; + my $frameworkcode = $params->{frameworkcode} || ''; + my $kohafield = $params->{kohafield}; + my $authorised_value = $params->{authorised_value}; + my $description = Koha::AuthorisedValues->get_description_by_koha_field( + { + frameworkcode => $frameworkcode, + kohafield => $kohafield, + authorised_value => $authorised_value + } + ); + return $description ? $description->{lib} : $authorised_value; } 1; -- 2.9.3