From 8afefba2dba295e28fc255885eefcae70932fa64 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Tue, 31 Oct 2023 17:12:13 +0000 Subject: [PATCH] Bug 34234: Add template plugin for listing and sorting ItemGroups This patch adds a template plugin to handle the retreiving and sorting of ItemGroups. 1. EnableItemGroups 2. Find a record and add some new item groups with display orders that are different from the order in which the groups were added 3. Check the checkbox next to one or more items and click the link to "Add/move to item group" 4. Notice that the values in the dropdown do not respect the display order. 5. Apply patch, restart all 6. Check again, sorting should be correct. --- Koha/Template/Plugin/ItemGroups.pm | 53 +++++++++++++++++++ .../prog/en/modules/catalogue/detail.tt | 3 +- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 Koha/Template/Plugin/ItemGroups.pm diff --git a/Koha/Template/Plugin/ItemGroups.pm b/Koha/Template/Plugin/ItemGroups.pm new file mode 100644 index 00000000000..eda845d154d --- /dev/null +++ b/Koha/Template/Plugin/ItemGroups.pm @@ -0,0 +1,53 @@ +package Koha::Template::Plugin::ItemGroups; + +# Copyright ByWater Solutions 2023 + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use Template::Plugin; +use base qw( Template::Plugin ); + +use Koha::Biblio::ItemGroups; + +=head1 NAME + +Koha::Template::Plugin::ItemGroups - A module for dealing with item groups in templates + +=head1 DESCRIPTION + +This plugin contains functions for getting all of the item groups for a particular bibliographic record, sorted by display order. + +=head2 Methods + +=head3 listGroups + +[% ItemGroups.listGroups %] + +returns all item groups + +=cut + +sub listGroups { + my ( $self, $biblionumber ) = @_; + return Koha::Biblio::ItemGroups->search( + { biblio_id => $biblionumber }, + { order_by => 'display_order' }, + ); +} + +1; 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 88630069da2..010a38dce9f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -9,6 +9,7 @@ [% USE Frameworks %] [% USE Price %] [% USE TablesSettings %] +[% USE ItemGroups %] [% PROCESS 'i18n.inc' %] [% SET CoverImagePlugins = KohaPlugins.get_plugins_intranet_cover_images %] @@ -1248,7 +1249,7 @@

-- 2.30.2