From c666d70ad1e151c172833d7641d8f57d8ddd35a1 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 20 Apr 2023 14:19:01 +0200 Subject: [PATCH] Bug 24975: Some more fixes --- Koha/UI/Form/Builder/Item.pm | 5 +++-- catalogue/detail.pl | 4 +++- catalogue/search.pl | 8 +++++++- .../prog/en/modules/catalogue/detail.tt | 2 +- .../bootstrap/en/modules/opac-reserve.tt | 4 ++-- opac/opac-reserve.pl | 12 +++++++----- opac/opac-search.pl | 16 ++++++++++++++-- 7 files changed, 37 insertions(+), 14 deletions(-) diff --git a/Koha/UI/Form/Builder/Item.pm b/Koha/UI/Form/Builder/Item.pm index 8ff8363c609..28164c843d4 100644 --- a/Koha/UI/Form/Builder/Item.pm +++ b/Koha/UI/Form/Builder/Item.pm @@ -209,8 +209,9 @@ sub generate_subfield_form { push @authorised_values, ""; my $itemtypes; if ($branch_limit) { - $itemtypes = Koha::ItemTypes->search( - { branchcode => $branch_limit } ); + $itemtypes = + Koha::ItemTypes->search_with_library_limits( undef, undef, + $branch_limit ); } else { $itemtypes = Koha::ItemTypes->search; diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 48bd7998796..fcc7468cbf4 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -50,6 +50,7 @@ use Koha::Biblio::ItemGroup::Items; use Koha::Biblio::ItemGroups; use Koha::CoverImages; use Koha::DateUtils; +use Koha::I18N; use Koha::Illrequests; use Koha::Items; use Koha::ItemTypes; @@ -189,7 +190,8 @@ $template->param( content_identifier_exists => $content_identifier_exists, ); -my $itemtypes = { map { $_->itemtype => $_ } @{ Koha::ItemTypes->search_with_localization->as_list } }; +my $itemtypes = { map { $_->itemtype => $_ } @{ Koha::ItemTypes->search->as_list } }; + my $all_items = $biblio->items->search_ordered; my @items; my $patron = Koha::Patrons->find( $borrowernumber ); diff --git a/catalogue/search.pl b/catalogue/search.pl index 051a9654588..75c0f2bf4bb 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -579,7 +579,13 @@ for (my $i=0;$i<@servers;$i++) { \@sort_by, $scan, $lang, { weighted_fields => $weight_search, whole_record => $whole_record }); my $quoted_results_hashref; eval { - my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } }; + my $itemtypes = { + map { + $_->{itemtype} => + { %$_, description => db_t( 'itemtype', $_->{itemtype} ), } + } @{ Koha::ItemTypes->search->unblessed } + }; + ( $error, $quoted_results_hashref, $facets ) = $searcher->search_compat( $query, $simple_query, \@sort_by, ['biblioserver'], $results_per_page, $offset, undef, $itemtypes, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index e8c92075631..a513851238a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -405,7 +405,7 @@ [% IF !noItemTypeImages && itemtype.image_location('intranet') %] [% ItemTypes.t(itemtype.translation_key) | html %] [% END %] - [% ItemTypes.t(item.translation_key) | html %] + [% ItemTypes.t(itemtype.translation_key) | html %] [% END %] [% UNLESS ( singlebranchmode ) %][% Branches.GetName( item.holdingbranch ) | html %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt index e486da3e249..3d67a2b721b 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt @@ -232,7 +232,7 @@
  • Item type: [% IF ( bibitemloo.imageurl ) %][% END %] - [% ItemTypes.t(bibitemloo.translation_key) | html %] + [% bibitemloo.description | html %]
  • [% END %] @@ -421,7 +421,7 @@ [% END %] [% END %] - [% ItemTypes.t(itemLoo.translation_key) | html %] + [% itemLoo.description | html %] [% END %] diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 981b81c3ded..f3a487fed91 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -35,6 +35,7 @@ use C4::Overdues; use Koha::AuthorisedValues; use Koha::Biblios; use Koha::CirculationRules; +use Koha::I18N; use Koha::Items; use Koha::ItemTypes; use Koha::Checkouts; @@ -72,7 +73,7 @@ unless ( $can_place_hold_if_available_at_pickup ) { } } -my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } }; +my $itemtypes = { map { $_->itemtype => $_ } @{ Koha::ItemTypes->search->as_list } }; # There are two ways of calling this script, with a single biblio num # or multiple biblio nums. @@ -413,8 +414,9 @@ foreach my $biblioNum (@biblionumbers) { $biblioLoopIter{object} = $biblio; if (!$itemLevelTypes && $biblioData->{itemtype}) { - $biblioLoopIter{description} = $itemtypes->{$biblioData->{itemtype}}{description}; - $biblioLoopIter{imageurl} = getitemtypeimagesrc() . "/". $itemtypes->{$biblioData->{itemtype}}{imageurl}; + $biblioLoopIter{description} = + db_t('itemtype', $itemtypes->{$biblioData->{itemtype}}->translation_key); + $biblioLoopIter{imageurl} = getitemtypeimagesrc() . "/". $itemtypes->{$biblioData->{itemtype}}->imageurl; } @@ -435,9 +437,9 @@ foreach my $biblioNum (@biblionumbers) { if ($itemLevelTypes) { my $itemtype = $item->itemtype; $item_info->{'imageurl'} = getitemtypeimagelocation( 'opac', - $itemtypes->{ $itemtype->itemtype }->{'imageurl'} ); + $itemtypes->{ $itemtype->itemtype }->imageurl ); $item_info->{'description'} = - db_t('itemtype', $itemtypes->{ $itemtype->itemtype }->{description}); + db_t('itemtype', $itemtypes->{ $itemtype->itemtype }->translation_key); } # checking for holds diff --git a/opac/opac-search.pl b/opac/opac-search.pl index b2c7cc6992a..b5c73738bdb 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -577,7 +577,13 @@ if ($tag) { $pasarParams .= '&count=' . uri_escape_utf8($results_per_page); $pasarParams .= '&simple_query=' . uri_escape_utf8($simple_query); $pasarParams .= '&query_type=' . uri_escape_utf8($query_type) if ($query_type); - my $itemtypes_nocategory = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } }; + my $itemtypes_nocategory = { + map { + $_->{itemtype} => + { %$_, description => db_t( 'itemtype', $_->{itemtype} ), } + } @{ Koha::ItemTypes->search->unblessed } + }; + eval { ($error, $results_hashref, $facets) = $searcher->search_compat($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,undef,$itemtypes_nocategory,$query_type,$scan,1); }; @@ -638,7 +644,13 @@ for (my $i=0;$i<@servers;$i++) { } ); my $quoted_results_hashref; - my $itemtypes_nocategory = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } }; + my $itemtypes_nocategory = { + map { + $_->{itemtype} => + { %$_, description => db_t( 'itemtype', $_->{itemtype} ), } + } @{ Koha::ItemTypes->search->unblessed } + }; + eval { ($error, $quoted_results_hashref, $facets) = $searcher->search_compat($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,undef,$itemtypes_nocategory,$query_type,$scan,1); }; -- 2.25.1