Bugzilla – Attachment 134014 Details for
Bug 12133
Guarantor requirements when registering a patron
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12133: Fix issues with modifying child patron and adding guarantors
0002-Bug-12133-Fix-issues-with-modifying-child-patron-and.patch (text/plain), 5.26 KB, created by
Emmi Takkinen
on 2022-04-27 09:40:45 UTC
(
hide
)
Description:
Bug 12133: Fix issues with modifying child patron and adding guarantors
Filename:
MIME Type:
Creator:
Emmi Takkinen
Created:
2022-04-27 09:40:45 UTC
Size:
5.26 KB
patch
obsolete
>From bb1482fcefa53da5ea283f5798f6ef41e9f48d0c Mon Sep 17 00:00:00 2001 >From: Emmi Takkinen <emmi.takkinen@outlook.com> >Date: Tue, 3 Nov 2020 15:03:11 +0200 >Subject: [PATCH 2/3] Bug 12133: Fix issues with modifying child patron and > adding guarantors > >Child patrons couldn't be modified when guarantor was >patron due missing guarantor_id value. Also if multiple >guarantors were added one could easily add child patron >as a guarantor. > >This patch adds Instead of one guarantor id all new and >existing guarantor ids are checked in case of child patron. > >To test: >1. Add child patron with syspref ChildNeedsGuarantor and >GuarantorNeedsToBePatron on. >2. Add two guarantors for the patron, first one should be >an adult patron and second a child. >3. Save patron. >=> Error "A guarantor cannot be a guarantee." should be >raised but isn't. >4. Modify patron and save. >=> Error "Child needs guarantor" is raised even if (valid) >guarantor exists. >5. Apply patch. >6. Repeat steps 1 to 4. >=> This time while saving a new patron error "A guarantor >cannot be a guarantee." is raised but modifying is >successful. > >Sponsored-by: Koha-Suomi Oy >--- > .../prog/en/modules/members/memberentrygen.tt | 4 ++-- > members/memberentry.pl | 23 ++++++++++++------- > 2 files changed, 17 insertions(+), 10 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >index 18a6e0ad66..016d041904 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >@@ -597,7 +597,7 @@ legend:hover { > </fieldset> <!-- /#memberentry_guarantor --> > </div> <!-- #/memberentry_guarantor_anchor --> > >- [% UNLESS nocontactname && nocontactfirstname && norelationship %] >+ [% UNLESS nocontactname && nocontactfirstname && norelationship || Koha.Preference('GuarantorHasToBePatron') %] > <fieldset class="rows" id="non_patron_guarantor"> > <legend>Non-patron guarantor</legend> > <ol> >@@ -661,7 +661,7 @@ legend:hover { > [% PROCESS 'main-address-style' %] > [% END # /UNLESS nostreet && nocity etc group%] > >- [% UNLESS nophone && nophonepro && nomobile && noemail && noemailpro && nofax || Koha.Preference('GuarantorHasToBePatron') %] >+ [% UNLESS nophone && nophonepro && nomobile && noemail && noemailpro && nofax %] > <fieldset class="rows" id="memberentry_contact"> > <legend id="contact_lgd">Contact information</legend> > <ol> >diff --git a/members/memberentry.pl b/members/memberentry.pl >index e2ebcc6644..2c833d1aca 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -102,19 +102,25 @@ my @relations = split /\|/, C4::Context->preference('borrowerRelationship'), -1; > @relations = ('') unless @relations; > my $empty_relationship_allowed = grep {$_ eq ""} @relations; > $template->param( empty_relationship_allowed => $empty_relationship_allowed ); >- >-my $guarantorinfo = $input->param('guarantorinfo'); > my $guarantor_id = $input->param('new_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 ); > $r->delete() if $r; > } > >+#Search existing guarantor id(s) and new ones from params >+my @guarantor_ids; >+my @guarantors = $patron->guarantor_relationships()->guarantors unless !$patron; >+foreach my $guarantor (@guarantors){ >+ push @guarantor_ids, $guarantor->id; >+}; >+my @new_guarantor_ids = grep { $_ ne '' } $input->multi_param('new_guarantor_id'); >+push (@guarantor_ids, @new_guarantor_ids); >+ > ## Deal with debarments > $template->param( > debarments => scalar GetDebarments( { borrowernumber => $borrowernumber } ) ); >@@ -280,15 +286,16 @@ if ( ( $op eq 'insert' ) and !$nodouble ) { > } > } > >-if ( $guarantor_id ) { >- if (my $guarantor = Koha::Patrons->find( $guarantor_id )) { >- my $guarantor_category = $guarantor->category->category_type; >- push @errors, 'ERROR_guarantor_is_guarantee' if ( ($guarantor_category eq 'C') && >+if ( @guarantor_ids ) { >+ foreach my $guarantor_id ( @guarantor_ids ){ >+ if (my $guarantor = Koha::Patrons->find( $guarantor_id )){ >+ push @errors, 'ERROR_guarantor_is_guarantee' if ( ($guarantor->is_child) && > ($op eq 'save' || $op eq 'insert') ); >+ } > } > } > >-my $valid_guarantor = $guarantor_id ? $guarantor_id : $newdata{'contactname'}; >+my $valid_guarantor = @guarantor_ids || $newdata{'contactname'} ? 1 : 0; > > if($category_type eq 'C' && ($op eq 'save' || $op eq 'insert') && C4::Context->preference('ChildNeedsGuarantor')){ > if(!$valid_guarantor){ >-- >2.25.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12133
:
27517
|
27584
|
33459
|
91482
|
94371
|
94538
|
94544
|
99629
|
113099
|
113100
|
134013
|
134014
|
134015
|
146827
|
147440
|
148058
|
148070
|
152706
|
153082
|
153154
|
154300
|
154316
|
156387
|
156446
|
156447
|
158344
|
158345
|
158346
|
158919
|
158979