From 88d9fcf0d92761674750eb26f87cc90553a1b65c Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 28 Apr 2017 14:11:00 -0400 Subject: [PATCH] Bug 18512 - GetAuthorisedValues.GetByCode Template plguin should return code (not empty string) if value not found To test: 1 - Create or edit a borrower with info in Sort1 and Sort2 field, not mapped to authorized values 2 - Note this info does not display on moremember.tt 3 - Apply patch 4 - Note value is passed through Signed-off-by: Mark Tompsett Signed-off-by: Jonathan Druart Signed-off-by: Mason James --- Koha/Template/Plugin/AuthorisedValues.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Koha/Template/Plugin/AuthorisedValues.pm b/Koha/Template/Plugin/AuthorisedValues.pm index 62565e05f7..98efa74594 100644 --- a/Koha/Template/Plugin/AuthorisedValues.pm +++ b/Koha/Template/Plugin/AuthorisedValues.pm @@ -22,10 +22,16 @@ use Template::Plugin; use base qw( Template::Plugin ); use C4::Koha; +use Koha::AuthorisedValues; sub GetByCode { my ( $self, $category, $code, $opac ) = @_; - return GetAuthorisedValueByCode( $category, $code, $opac ); + my $av = Koha::AuthorisedValues->search({ category => $category, authorised_value => $code }); + return $av->count + ? $opac + ? $av->next->opac_description + : $av->next->lib + : $code; } sub Get { -- 2.39.5