@@ -, +, @@ --- Koha/Template/Plugin/ItemGroups.pm | 15 +++++++++++++++ cataloguing/additem.pl | 3 --- .../prog/en/modules/cataloguing/additem.tt | 10 +++++----- 3 files changed, 20 insertions(+), 8 deletions(-) --- a/Koha/Template/Plugin/ItemGroups.pm +++ a/Koha/Template/Plugin/ItemGroups.pm @@ -50,4 +50,19 @@ sub listGroups { ); } +=head3 count + +[% ItemGroups.count %] + +returns count of item groups on a particular bibliographic record + +=cut + +sub count { + my ( $self, $biblionumber ) = @_; + return Koha::Biblio::ItemGroups->search( + { biblio_id => $biblionumber }, + )->count; +} + 1; --- a/cataloguing/additem.pl +++ a/cataloguing/additem.pl @@ -752,14 +752,11 @@ if( my $default_location = C4::Context->preference('NewItemsDefaultLocation') ) $location_field->{marc_value}->{value} ||= $default_location; } -my @ig = Koha::Biblio::ItemGroups->search({ biblio_id => $biblionumber })->as_list(); #sort by display order -my @sorted_ig = sort { $a->display_order <=> $b->display_order } @ig; # what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit. $template->param( biblio => $biblio, items => \@items, - item_groups => \@sorted_ig, item_header_loop => \@header_value_loop, subfields => $subfields, itemnumber => $itemnumber, --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt @@ -4,6 +4,7 @@ [% USE Branches %] [% USE KohaDates %] [% USE Price %] +[% USE ItemGroups %] [% USE TablesSettings %] [% PROCESS 'i18n.inc' %] [% INCLUDE 'doc-head-open.inc' %] @@ -36,7 +37,7 @@ [% INCLUDE 'str/cataloging_additem.inc' %] [% Asset.js("js/cataloging_additem.js") | $raw %] @@ -249,18 +250,17 @@ [% IF op != 'add_item' %] [% END %] - -[% IF item_groups.size && op != 'saveitem' && CAN_user_editcatalogue_manage_item_groups %] +[% IF ItemGroups.count(biblio.biblionumber) && op != 'saveitem' && CAN_user_editcatalogue_manage_item_groups %]
Add to item group - [% FOREACH ig IN item_groups %] + [% FOREACH ig IN ItemGroups.listGroups(biblio.biblionumber) %] [% END %]