From d019f86f671771a36006f8847712317e0337c02f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 10 Aug 2016 13:35:13 +0100 Subject: [PATCH] Bug 17250 - Koha::AuthorisedValues - Remove GetAuthValCode MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The subroutine C4::Koha::GetAuthValCode returned the authorised value category for a given kohafield. This can be acchieve easily using a new Koha::AuthorisedValues->search_by_koha_field method which will mimic search_by_marc_field. Test plan: Confirm that the description is correctly displayed on the following pages: - detail and moredetail of a bibliographic page (itemlost, damaged, materials) - Set AcqCreateItem=ordering and receiving items. The description for notforloan, restricted, location, ccode, etc. field should be displayed. - Items search form - On the checkout list from the circulation.pl and returns.pl pages, the description for "materials" should be displayed Note that GetKohaAuthorisedValuesMapping is going to be removed on bug 17251. Followed test plan, works as expected. Signed-off-by: Marc Véron Signed-off-by: Martin Renvoize Signed-off-by: Kyle M Hall --- C4/Circulation.pm | 1 - C4/Items.pm | 27 ++++++++----------- C4/Koha.pm | 44 +++++++++---------------------- C4/Search.pm | 3 ++- Koha/AuthorisedValues.pm | 22 ++++++++++++++++ acqui/orderreceive.pl | 36 +++++++++++-------------- catalogue/detail.pl | 17 +++++++----- catalogue/getitem-ajax.pl | 31 ++++++++-------------- catalogue/itemsearch.pl | 13 +++++---- catalogue/moredetail.pl | 16 ++++++----- circ/circulation.pl | 12 ++++----- circ/returns.pl | 7 ++--- t/db_dependent/AuthorisedValues.t | 11 +++++++- tools/inventory.pl | 6 +++-- 14 files changed, 123 insertions(+), 123 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 0cac5edfb7..6c08a99910 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -36,7 +36,6 @@ use C4::Debug; use C4::Log; # logaction use C4::Koha qw( GetAuthorisedValueByCode - GetAuthValCode ); use C4::Overdues qw(CalcFine UpdateFine get_chargeable_units); use C4::RotatingCollections qw(GetCollectionItemBranches); diff --git a/C4/Items.pm b/C4/Items.pm index c31c022a1f..ca5e5186db 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -1379,27 +1379,22 @@ sub GetItemsInfo { $serial ||= $data->{'serial'}; + my $av; # get notforloan complete status if applicable - if ( my $code = C4::Koha::GetAuthValCode( 'items.notforloan', $data->{frameworkcode} ) ) { - my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $data->{itemnotforloan} }); - $av = $av->count ? $av->next : undef; - $data->{notforloanvalue} = $av ? $av->lib : ''; - $data->{notforloanvalueopac} = $av ? $av->opac_description : ''; - } + $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.notforloan', authorised_value => $data->{itemnotforloan} }); + $av = $av->count ? $av->next : undef; + $data->{notforloanvalue} = $av ? $av->lib : ''; + $data->{notforloanvalueopac} = $av ? $av->opac_description : ''; # get restricted status and description if applicable - if ( my $code = C4::Koha::GetAuthValCode( 'items.restricted', $data->{frameworkcode} ) ) { - my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $data->{restricted} }); - $av = $av->count ? $av->next : undef; - $data->{restricted} = $av ? $av->lib : ''; - $data->{restrictedopac} = $av ? $av->opac_description : ''; - } + $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.restricted', authorised_value => $data->{restricted} }); + $av = $av->count ? $av->next : undef; + $data->{restricted} = $av ? $av->lib : ''; + $data->{restrictedopac} = $av ? $av->opac_description : ''; # my stack procedures - if ( my $code = C4::Koha::GetAuthValCode( 'items.stack', $data->{frameworkcode} ) ) { - my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $data->{stack} }); - $data->{stack} = $av->count ? $av->next->lib : ''; - } + $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.stack', authorised_value => $data->{stack} }); + $data->{stack} = $av->count ? $av->next->lib : ''; # Find the last 3 people who borrowed this item. my $sth2 = $dbh->prepare("SELECT * FROM old_issues,borrowers diff --git a/C4/Koha.pm b/C4/Koha.pm index a455039540..fa8245f59f 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -56,7 +56,6 @@ BEGIN { &GetKohaAuthorisedValues &GetKohaAuthorisedValuesMapping &GetAuthorisedValueByCode - &GetAuthValCode &GetNormalizedUPC &GetNormalizedISBN &GetNormalizedEAN @@ -880,22 +879,6 @@ SELECT lib, return \%notforloan_label_of; } -=head2 GetAuthValCode - - $authvalcode = GetAuthValCode($kohafield,$frameworkcode); - -=cut - -sub GetAuthValCode { - my ($kohafield,$fwcode) = @_; - my $dbh = C4::Context->dbh; - $fwcode='' unless $fwcode; - my $sth = $dbh->prepare('select authorised_value from marc_subfield_structure where kohafield=? and frameworkcode=?'); - $sth->execute($kohafield,$fwcode); - my ($authvalcode) = $sth->fetchrow_array; - return $authvalcode; -} - =head2 GetAuthorisedValues $authvalues = GetAuthorisedValues([$category]); @@ -1017,21 +1000,18 @@ Returns undef if no authorised value category is defined for the kohafield. =cut sub GetKohaAuthorisedValues { - my ($kohafield,$fwcode,$opac) = @_; - $fwcode='' unless $fwcode; - my %values; - my $dbh = C4::Context->dbh; - my $avcode = GetAuthValCode($kohafield,$fwcode); - if ($avcode) { - my $sth = $dbh->prepare("select authorised_value, lib, lib_opac from authorised_values where category=? "); - $sth->execute($avcode); - while ( my ($val, $lib, $lib_opac) = $sth->fetchrow_array ) { - $values{$val} = ($opac && $lib_opac) ? $lib_opac : $lib; - } - return \%values; - } else { - return; - } + my ( $kohafield, $fwcode, $opac ) = @_; + $fwcode = '' unless $fwcode; + my %values; + my $dbh = C4::Context->dbh; + + my $avs = Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $fwcode, kohafield => $kohafield } ); + return {} unless $avs->count; + my $values; + while ( my $av = $avs->next ) { + $values->{ $av->authorised_value } = $opac ? $av->opac_description : $av->lib; + } + return $values; } =head2 GetKohaAuthorisedValuesMapping diff --git a/C4/Search.pm b/C4/Search.pm index ef61338aef..2583f90458 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1852,7 +1852,8 @@ sub searchResults { my $shelflocations =GetKohaAuthorisedValues('items.location',''); # get notforloan authorised value list (see $shelflocations FIXME) - my $notforloan_authorised_value = GetAuthValCode('items.notforloan',''); + my $av = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.notforloan' }); + my $notforloan_authorised_value = $av->count ? $av->next->authorised_value : undef; #Get itemtype hash my %itemtypes = %{ GetItemTypes() }; diff --git a/Koha/AuthorisedValues.pm b/Koha/AuthorisedValues.pm index cbab8deb39..44740300cf 100644 --- a/Koha/AuthorisedValues.pm +++ b/Koha/AuthorisedValues.pm @@ -80,6 +80,28 @@ sub search_by_marc_field { ); } +sub search_by_koha_field { + my ( $self, $params ) = @_; + my $frameworkcode = $params->{frameworkcode} || ''; + my $kohafield = $params->{kohafield}; + my $category = $params->{category}; + my $authorised_value = $params->{authorised_value}; + + return unless $kohafield; + + return $self->SUPER::search( + { 'marc_subfield_structures.frameworkcode' => $frameworkcode, + 'marc_subfield_structures.kohafield' => $kohafield, + ( defined $category ? ( category_name => $category ) : () ), + ( $authorised_value ? ( authorised_value => $authorised_value ) : () ), + }, + { join => { category => 'marc_subfield_structures' }, + select => ['authorised_value'], + distinct => 1, + } + ); +} + sub categories { my ( $self ) = @_; my $rs = $self->_resultset->search( diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl index 33c07cd5cc..7b05013424 100755 --- a/acqui/orderreceive.pl +++ b/acqui/orderreceive.pl @@ -128,26 +128,22 @@ if ($AcqCreateItem eq 'receiving') { my @items; foreach (@itemnumbers) { my $item = GetItem($_); - if(my $code = GetAuthValCode("items.notforloan", $fw)) { - my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{notforloan} }); - $item->{notforloan} = $av->count ? $av->next->lib : ''; - } - if(my $code = GetAuthValCode("items.restricted", $fw)) { - my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{restricted} }); - $item->{restricted} = $av->count ? $av->next->lib : ''; - } - if(my $code = GetAuthValCode("items.location", $fw)) { - my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{location} }); - $item->{location} = $av->count ? $av->next->lib : ''; - } - if(my $code = GetAuthValCode("items.ccode", $fw)) { - my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{collection} }); - $item->{collection} = $av->count ? $av->next->lib : ''; - } - if(my $code = GetAuthValCode("items.materials", $fw)) { - my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{materials} }); - $item->{materials} = $av->count ? $av->next->lib : ''; - } + my $av; + $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => $fw, kohafield => 'items.notforloan', authorised_value => $item->{notforloan} }); + $item->{notforloan} = $av->count ? $av->next->lib : ''; + + $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => $fw, kohafield => 'items.restricted', authorised_value => $item->{restricted} }); + $item->{restricted} = $av->count ? $av->next->lib : ''; + + $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => $fw, kohafield => 'items.location', authorised_value => $item->{location} }); + $item->{location} = $av->count ? $av->next->lib : ''; + + $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => $fw, kohafield => 'items.collection', authorised_value => $item->{collection} }); + $item->{collection} = $av->count ? $av->next->lib : ''; + + $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => $fw, kohafield => 'items.materials', authorised_value => $item->{materials} }); + $item->{materials} = $av->count ? $av->next->lib : ''; + my $itemtype = getitemtypeinfo($item->{itype}); $item->{itemtype} = $itemtype->{description}; push @items, $item; diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 72bb36017d..b022c56364 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -41,6 +41,7 @@ use Koha::DateUtils; use C4::HTML5Media; use C4::CourseReserves qw(GetItemCourseReservesInfo); use C4::Acquisition qw(GetOrdersByBiblionumber); +use Koha::AuthorisedValues; use Koha::Virtualshelves; my $query = CGI->new(); @@ -194,17 +195,19 @@ my $copynumbers = GetKohaAuthorisedValues('items.copynumber', $fw); my (@itemloop, @otheritemloop, %itemfields); my $norequests = 1; -if ( my $lost_av = GetAuthValCode('items.itemlost', $fw) ) { - $template->param( itemlostloop => GetAuthorisedValues( $lost_av ) ); +my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost' }); +if ( $mss->count ) { + $template->param( itemlostloop => GetAuthorisedValues( $mss->next->authorised_value ) ); } -if ( my $damaged_av = GetAuthValCode('items.damaged', $fw) ) { - $template->param( itemdamagedloop => GetAuthorisedValues( $damaged_av ) ); +$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.damaged' }); +if ( $mss->count ) { + $template->param( itemdamagedloop => GetAuthorisedValues( $mss->next->authorised_value ) ); } -my $materials_authvalcode = GetAuthValCode('items.materials', $fw); +$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.materials' }); my %materials_map; -if ($materials_authvalcode) { - my $materials_authvals = GetAuthorisedValues($materials_authvalcode); +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}; diff --git a/catalogue/getitem-ajax.pl b/catalogue/getitem-ajax.pl index f79e4ad3b2..c296257ea6 100755 --- a/catalogue/getitem-ajax.pl +++ b/catalogue/getitem-ajax.pl @@ -55,30 +55,21 @@ if($itemnumber) { $item->{holdingbranchname} = Koha::Libraries->find($item->{holdingbranch})->branchname; } - if(my $code = GetAuthValCode("items.notforloan", $fw)) { - my $av = Koha::AuthorisedValues->search({ category => $code, authorised_values => $item->{notforloan} }); - $item->{notforloan} = $av->count ? $av->next->lib : ''; - } + my $av; + $av = Koha::AuthorisedValues->search_by_koha_field({ frameworkcode => $fw, kohafield => 'items.notforloan', authorised_value => $item->{notforloan} }); + $item->{notforloan} = $av->count ? $av->next->lib : ''; - if(my $code = GetAuthValCode("items.restricted", $fw)) { - my $av = Koha::AuthorisedValues->search({ category => $code, authorised_values => $item->{restricted} }); - $item->{restricted} = $av->count ? $av->next->lib : ''; - } + $av = Koha::AuthorisedValues->search_by_koha_field({ frameworkcode => $fw, kohafield => 'items.restricted', authorised_value => $item->{restricted} }); + $item->{restricted} = $av->count ? $av->next->lib : ''; - if(my $code = GetAuthValCode("items.location", $fw)) { - my $av = Koha::AuthorisedValues->search({ category => $code, authorised_values => $item->{location} }); - $item->{location} = $av->count ? $av->next->lib : ''; - } + $av = Koha::AuthorisedValues->search_by_koha_field({ frameworkcode => $fw, kohafield => 'items.location', authorised_value => $item->{location} }); + $item->{location} = $av->count ? $av->next->lib : ''; - if(my $code = GetAuthValCode("items.ccode", $fw)) { - my $av = Koha::AuthorisedValues->search({ category => $code, authorised_values => $item->{collection} }); - $item->{collection} = $av->count ? $av->next->lib : ''; - } + $av = Koha::AuthorisedValues->search_by_koha_field({ frameworkcode => $fw, kohafield => 'items.collection', authorised_value => $item->{collection} }); + $item->{collection} = $av->count ? $av->next->lib : ''; - if(my $code = GetAuthValCode("items.materials", $fw)) { - my $av = Koha::AuthorisedValues->search({ category => $code, authorised_values => $item->{materials} }); - $item->{materials} = $av->count ? $av->next->lib : ''; - } + $av = Koha::AuthorisedValues->search_by_koha_field({ frameworkcode => $fw, kohafield => 'items.materials', authorised_value => $item->{materials} }); + $item->{materials} = $av->count ? $av->next->lib : ''; my $itemtype = getitemtypeinfo($item->{itype}); $item->{itemtype} = $itemtype->{description}; diff --git a/catalogue/itemsearch.pl b/catalogue/itemsearch.pl index 3a5f0d95e3..001cf2876b 100755 --- a/catalogue/itemsearch.pl +++ b/catalogue/itemsearch.pl @@ -27,6 +27,7 @@ use C4::Items; use C4::Biblio; use C4::Koha; +use Koha::AuthorisedValues; use Koha::Item::Search::Field qw(GetItemSearchFields); use Koha::ItemTypes; use Koha::Libraries; @@ -87,11 +88,11 @@ my ($template, $borrowernumber, $cookie) = get_template_and_user({ flagsrequired => { catalogue => 1 }, }); -my $notforloan_avcode = GetAuthValCode('items.notforloan'); -my $notforloan_values = GetAuthorisedValues($notforloan_avcode); +my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.notforloan' }); +my $notforloan_values = $mss->count ? GetAuthorisedValues($mss->next->authorised_value) : []; -my $location_avcode = GetAuthValCode('items.location'); -my $location_values = GetAuthorisedValues($location_avcode); +$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.location' }); +my $location_values = $mss->count ? GetAuthorisedValues($mss->next->authorised_value) : []; if (scalar keys %params > 0) { # Parameters given, it's a search @@ -262,7 +263,9 @@ if ($format eq 'html') { label => $itemtype->translated_description, }; } - my $ccode_avcode = GetAuthValCode('items.ccode') || 'CCODE'; + + my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.ccode' }); + my $ccode_avcode = $mss->count ? $mss->next->authorised_value : 'CCODE'; my $ccodes = GetAuthorisedValues($ccode_avcode); my @ccodes; foreach my $ccode (@$ccodes) { diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl index f663f85d08..b18d8573d9 100755 --- a/catalogue/moredetail.pl +++ b/catalogue/moredetail.pl @@ -36,6 +36,7 @@ use C4::Members qw/GetHideLostItemsPreference/; use C4::Reserves qw(GetReservesFromBiblionumber); use Koha::Acquisition::Bookseller; +use Koha::AuthorisedValues; use Koha::DateUtils; use Koha::Items; @@ -193,14 +194,17 @@ foreach my $item (@items){ } -if ( my $lost_av = GetAuthValCode('items.itemlost', $fw) ) { - $template->param( itemlostloop => GetAuthorisedValues( $lost_av ) ); +my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost' }); +if ( $mss->count ) { + $template->param( itemlostloop => GetAuthorisedValues( $mss->next->authorisedvalue ) ); } -if ( my $damaged_av = GetAuthValCode('items.damaged', $fw) ) { - $template->param( itemdamagedloop => GetAuthorisedValues( $damaged_av ) ); +$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.damaged' }); +if ( $mss->count ) { + $template->param( itemdamagedloop => GetAuthorisedValues( $mss->next->authorisedvalue ) ); } -if ( my $withdrawn_av = GetAuthValCode('items.withdrawn', $fw) ) { - $template->param( itemwithdrawnloop => GetAuthorisedValues( $withdrawn_av ) ); +$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.withdrawn' }); +if ( $mss->count ) { + $template->param( itemwithdrawnloop => GetAuthorisedValues( $mss->next->authorisedvalue) ); } $template->param(count => $data->{'count'}, diff --git a/circ/circulation.pl b/circ/circulation.pl index 848f0d41a1..787d501de8 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -340,8 +340,9 @@ if (@$barcodes) { # Get the item title for more information my $getmessageiteminfo = GetBiblioFromItemNumber(undef,$barcode); - $template_params->{authvalcode_notforloan} = - C4::Koha::GetAuthValCode('items.notforloan', $getmessageiteminfo->{'frameworkcode'}); + + my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $getmessageiteminfo->{frameworkcode}, kohafield => 'items.notforloan' }); + $template_params->{authvalcode_notforloan} = $mss->count ? $mss->next->authorisedvalue : undef; # Fix for bug 7494: optional checkout-time fallback search for a book @@ -390,11 +391,8 @@ if (@$barcodes) { unless($issueconfirmed){ # Get the item title for more information my $materials = $iteminfo->{'materials'}; - my $avcode = GetAuthValCode('items.materials'); - if ($avcode) { - my $av = Koha::AuthorisedValues->search({ category => $avcode, authorised_value => $materials }); - $materials = $av->count ? $av->next->lib : ''; - } + my $av = Koha::AuthorisedValues->search_by_koha_field({ frameworkcode => $getmessageiteminfo->{frameworkcode}, kohafield => 'items.materials', authorised_value => $materials }); + $materials = $av->count ? $av->next->lib : ''; $template_params->{additional_materials} = $materials; $template_params->{itemhomebranch} = $iteminfo->{'homebranch'}; diff --git a/circ/returns.pl b/circ/returns.pl index ec13c047f0..1d2340d4ab 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -279,11 +279,8 @@ if ($barcode) { $returnbranch = $biblio->{$hbr}; my $materials = $biblio->{'materials'}; - my $avcode = GetAuthValCode('items.materials'); - if ($avcode) { - my $av = Koha::AuthorisedValues->search({ category => $avcode, authorised_value => $materials }); - $materials = $av->count ? $av->next->lib : ''; - } + my $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => '', kohafield =>'items.materials', authorised_value => $materials }); + $materials = $av->count ? $av->next->lib : ''; $template->param( title => $biblio->{'title'}, diff --git a/t/db_dependent/AuthorisedValues.t b/t/db_dependent/AuthorisedValues.t index 21231e69de..82adaa9755 100644 --- a/t/db_dependent/AuthorisedValues.t +++ b/t/db_dependent/AuthorisedValues.t @@ -102,7 +102,7 @@ is( $categories[0], $av4->category, 'The first category should be correct (order is( $categories[1], $av1->category, 'The second category should be correct (ordered by category name)' ); subtest 'search_by_*_field' => sub { - plan tests => 1; + plan tests => 2; my $loc_cat = Koha::AuthorisedValueCategories->find('LOC'); $loc_cat->delete if $loc_cat; my $mss = Koha::MarcSubfieldStructures->search( { tagfield => 952, tagsubfield => 'c', frameworkcode => '' } ); @@ -130,4 +130,13 @@ subtest 'search_by_*_field' => sub { is( $avs->count, 3, 'default fk'); is( $avs->next->authorised_value, 'location_1', ); }; + subtest 'search_by_koha_field' => sub { + plan tests => 3; + my $avs; + $avs = Koha::AuthorisedValues->search_by_koha_field(); + is ( $avs, undef ); + $avs = Koha::AuthorisedValues->search_by_koha_field( { kohafield => 'items.location', tagfield => 952, tagsubfield => 'c' } ); + is( $avs->count, 3, ); + is( $avs->next->authorised_value, 'location_1', ); + }; }; diff --git a/tools/inventory.pl b/tools/inventory.pl index 6531e8db0e..1ad8116fb0 100755 --- a/tools/inventory.pl +++ b/tools/inventory.pl @@ -72,7 +72,8 @@ $frameworks->{''} = {frameworkcode => ''}; # Add the default framework for my $fwk (keys %$frameworks){ my $fwkcode = $frameworks->{$fwk}->{'frameworkcode'}; - my $authcode = GetAuthValCode('items.location', $fwkcode); + my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fwkcode, kohafield => 'items.location' }); + my $authcode = $mss->count ? $mss->next->authorised_value : undef; if ($authcode && $authorisedvalue_categories!~/\b$authcode\W/){ $authorisedvalue_categories.="$authcode "; my $data=GetAuthorisedValues($authcode); @@ -87,7 +88,8 @@ my $statuses = []; for my $statfield (qw/items.notforloan items.itemlost items.withdrawn items.damaged/){ my $hash = {}; $hash->{fieldname} = $statfield; - $hash->{authcode} = GetAuthValCode($statfield); + my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => $statfield }); + $hash->{authcode} = $mss->count ? $mss->next->authorised_value : undef; if ($hash->{authcode}){ my $arr = GetAuthorisedValues($hash->{authcode}); $hash->{values} = $arr; -- 2.39.2