From a72cfdb0ae137e2546e686b06e42fbfbfdf9df7e Mon Sep 17 00:00:00 2001 From: Emmi Takkinen Date: Wed, 19 Feb 2020 10:41:47 +0200 Subject: [PATCH] Bug 12133: Fix issue with modify Child patrons couldn't be modified when guarantor was patron due missing guarantor_id value. This patch fixes that. To test: 1. Add child patron with syspref ChildNeedsGuarantor and GuarantorNeedsToBePatron on. 2. Modify patron and save. 3. Error "Child needs guarantor" is raised even if guarantor exists. 4. Apply patch. 5. Edit again and save. No error should be raised. Sponsored-by: Koha-Suomi Oy --- members/memberentry.pl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/members/memberentry.pl b/members/memberentry.pl index 50de11ce68..75766d2e29 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -106,12 +106,16 @@ my $userenv = C4::Context->userenv; ## Deal with guarantor stuff $template->param( relationships => scalar $patron->guarantor_relationships ) if $patron; -my $guarantorinfo = $input->param('guarantorinfo'); -my $guarantor_id = $input->param('new_guarantor_id'); +#Either use existing guarantor id or new from params +my @guarantors = $patron->guarantor_relationships()->guarantors if $patron; +my $found_guarantor_id; +foreach my $guarantor (@guarantors){ + $found_guarantor_id = $guarantor->id; +}; +my $guarantor_id = $input->param('new_guarantor_id') || $found_guarantor_id; my $guarantor = undef; $guarantor = Koha::Patrons->find( $guarantor_id ) if $guarantor_id; $template->param( guarantor => $guarantor ); - my @delete_guarantor = $input->multi_param('delete_guarantor'); foreach my $id ( @delete_guarantor ) { my $r = Koha::Patron::Relationships->find( $id ); -- 2.17.1