From ee67d86081b854d3a8fc91b7ab710f63fe3a648a Mon Sep 17 00:00:00 2001 From: Maryse Simard Date: Tue, 20 Oct 2020 20:39:51 -0400 Subject: [PATCH] Bug 12446: Limit available categories when using "Add guarantee" button Test plan: 1) Have some patron categories that can and cannot be guarantee 2) Visit a patron's account and click the "Add guarantee" button 3) In the "category" dropdown, note that all categories are available 4) Apply this patch 5) Repeat step 2 and 3; the dropdown now only contains the categories for which "can be guarantee" is set to "Yes". Signed-off-by: Kyle M Hall Signed-off-by: David Nind Signed-off-by: Owen Leonard Signed-off-by: Jonathan Druart --- members/memberentry.pl | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/members/memberentry.pl b/members/memberentry.pl index dcb6d9fd6d..567458642f 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -649,18 +649,14 @@ if(!defined($data{'sex'})){ ##Now all the data to modify a member. -my $patron_categories = Koha::Patron::Categories->search_with_library_limits( - { - category_type => [qw(C A S P I X)], - ( $guarantor_id ? ( can_be_guarantee => 1 ) : () ) - }, - { order_by => ['categorycode'] } -); -my $no_categories = ! $patron_categories->count; -my $categories = {}; -foreach my $patron_category ($patron_categories->as_list ) { - push @{ $categories->{ $patron_category->category_type } }, $patron_category; -} +my @typeloop; +my $no_categories = 1; +my $no_add; +foreach my $category_type (qw(C A S P I X)) { + my $categories_limits = { category_type => $category_type }; + $categories_limits->{canbeguarantee} = 1 if ($guarantor_id); + my $patron_categories = Koha::Patron::Categories->search_with_library_limits( $categories_limits, {order_by => ['categorycode']} ); + $no_categories = 0 if $patron_categories->count > 0; $template->param( patron_categories => $categories, -- 2.34.1