Bugzilla – Attachment 171277 Details for
Bug 37528
Using borrowerRelationship while guarantor relationship is unchecked from BorrowerMandatoryField results in error
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37528: check if selected relationship is valid
Bug-37528-check-if-selected-relationship-is-valid.patch (text/plain), 4.17 KB, created by
Olivier Vezina
on 2024-09-10 16:51:47 UTC
(
hide
)
Description:
Bug 37528: check if selected relationship is valid
Filename:
MIME Type:
Creator:
Olivier Vezina
Created:
2024-09-10 16:51:47 UTC
Size:
4.17 KB
patch
obsolete
>From 280383f28977d116a86319ebdc07bdfeb00d54fa Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Johanna=20R=C3=A4is=C3=A4?= <johanna.raisa@gmail.com> >Date: Thu, 1 Aug 2024 08:46:09 +0300 >Subject: [PATCH] Bug 37528: check if selected relationship is valid > >This patch checks if the selected relationship is valid before trying to save the patron record. >It takes the list of valid relationships from borrowerRelationships syspref and checks if the selected relationship is in the list. > >Also this patch fixes relationship field required message when BorrowerMandatoryField is not set. >The required message is shown when adding the guarantee from guarantor's detail page. > >Test plan: >1) Add at least one option to borrowerRelationships syspref. >2) Leave the relationship unchecked from BorrowerMandatoryField syspref. >3) Create a new guarantee patron. >4) Add a guarantor to the guarantee patron. >5) Leave the relationship field empty and try to save the patron record. >6) Notice the 500 error page. >7) Apply the patch. >8) Repeat steps 3-5. >9) Notice the error message "Guarantor relationship is invalid". > >Sponsored-by: Koha-Suomi Oy >Signed-off-by: Olivier V <olivier.vezina@inLibro.com> >--- > .../prog/en/modules/members/memberentrygen.tt | 5 ++++- > members/memberentry.pl | 16 ++++++++++++++++ > 2 files changed, 20 insertions(+), 1 deletion(-) > >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 ca4a298717..d9cc2931aa 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >@@ -217,6 +217,9 @@ legend.collapsed i.fa.fa-caret-down::before { > [% IF ( ERROR_cannot_delete_guarantor ) %] > <li id="ERROR_cannot_delete_guarantor">Cannot delete guarantor(s). A child patron needs a guarantor.</li> > [% END %] >+ [% IF ( ERROR_invalid_relationship ) %] >+ <li id="ERROR_invalid_relationship">Guarantor relationship is invalid.</li> >+ [% END %] > </ul> > </div> > [% END %] >@@ -556,7 +559,7 @@ legend.collapsed i.fa.fa-caret-down::before { > [% END %] > [% END %] > </select> >- [% UNLESS mandatoryrelationship %] >+ [% IF mandatoryrelationship %] > <span class="required">Required</span> > [% END %] > </li> >diff --git a/members/memberentry.pl b/members/memberentry.pl >index 2fa5447e4d..dfaa283906 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -290,6 +290,22 @@ foreach my $guarantor (@guarantors) { > } > } > >+my @valid_relationships = split(/\|/, C4::Context->preference('borrowerRelationship'), -1); >+if (@valid_relationships) { >+ my @new_guarantor_id = $input->multi_param('new_guarantor_id'); >+ my @new_guarantor_relationship = $input->multi_param('new_guarantor_relationship'); >+ >+ for ( my $i = 0 ; $i < scalar @new_guarantor_id; $i++ ) { >+ my $guarantor_id = $new_guarantor_id[$i]; >+ my $relationship = $new_guarantor_relationship[$i]; >+ >+ next unless $guarantor_id; >+ unless ( grep { $_ eq $relationship } @valid_relationships ) { >+ push @errors, 'ERROR_invalid_relationship'; >+ } >+ } >+} >+ > ###############test to take the right zipcode, country and city name ############## > # set only if parameter was passed from the form > $newdata{'city'} = $input->param('city') if defined($input->param('city')); >-- >2.34.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 37528
:
169925
|
171277
|
171541
|
171542
|
172560