From 6e651fa7ade0c6da7e08735f77e83bda684d134e Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Fri, 28 Jun 2019 02:05:52 +0000 Subject: [PATCH] Bug 12949: Added syspref to control display of unlinked guarantor When upgrading a child to adult patron the guarantor details are still displayed on the new adult patrons record. This is because upgrading a child to an adult patron involves clearing the borrowers.guarantorid value but not the borrowers.contactname, borrowers.contactfirstname Bug 15928 introduced functionality to display contactname and contactfirstname when no guarantorid exists. This was so unlinked guarantors (non-librart patrons) could be set. The display of guarantor information when the guarantorid has been cleared following upgrading to an adult patron category is confusing, as it appears that the guarantor relationship already exists even though the child has been upgraded to an adult. In this patch we introduce a sytem preference GuarantorsMustBeLinkedToPatronAccount (enabled by default) - which keeps the default Koha functionality introduced by 15928 when the syspref is disabled - to only display gurantor information if a guarantorid exists. Test plan: 1. Create an adult patron (make sure to set a first and last name) and select 'Add child' and save the child record 2. Run the following database query, and notice there are values for guarantorid, contactname, contactfirstname: SELECT guarantorid, contactname, contactfirstname FROM borrowers WHERE borrowernumber=; 3. On the child record select More > Update child to adult patron. 4. Select a new adult patron category and save 5. Notice guarantor information is still displayed on the new adults record 6. Repeat step 2 and notice guarantorid is empty/NULL and contactname and contactfirstname are unchanged 7. Now create a child record with an unlinked guarantor: In the patron home page select 'New patron'. Note: Make sure the patron category you select is of category type 'Child' 8. In the guarantor area of the patron creation page input a firstname and surname and don't select 'Set to patron' and save/submit the page 9. Repeat step 2 making the borrowernumber you enter the borrowernumber of the patron you made in step 8 and notice guarantorid is empty and contactname and contactfirstname are not empty. i.e. our guarantor is not linked to a Koha patron 10. Notice guarantor information is shown on the patron summary page of our user 11. Repeat step 3,4,5 and notice guarantor information is still displayed 12. Apply patch 13. Navigate to installer/data/mysql directory Enter the Koha shell: sudo koha-shell Run: ./updatedatabase.pl 14. In staff client visit Administration > Global System preferences and search for GuarantorsMustBeLinkedToPatronAccount syspref and confirm it is enabled 15. Repeat steps 1-5 and notice that the guarantor information is not displayed on the new adult's record 16. Repeat steps 7-10 and notice that the guarantor information is not displayed on the new adult's record 17. Set GuarantorsMustBeLinkedToPatronAccount syspref to disabled 18. Repeat steps 1-5 and confirm the guarantor information is displayed on the new adult's record (i.e. setting GuarantorsMustBeLinkedToPatronAccount syspref to disabled keeps the current Koha behaviour) 19. Repeat steps 7-10 and confirm the guarantor information is displayed 20. Sign off Sponsored-By: Brimbank Library, Australia Signed-off-by: Nadine Pierre --- ...add_syspref_to_control_display_of_unlinked_guarantor.sql | 1 + installer/data/mysql/sysprefs.sql | 1 + .../prog/en/modules/admin/preferences/patrons.pref | 6 ++++++ members/moremember.pl | 2 +- 4 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_12949-add_syspref_to_control_display_of_unlinked_guarantor.sql diff --git a/installer/data/mysql/atomicupdate/bug_12949-add_syspref_to_control_display_of_unlinked_guarantor.sql b/installer/data/mysql/atomicupdate/bug_12949-add_syspref_to_control_display_of_unlinked_guarantor.sql new file mode 100644 index 0000000000..bfe39a0474 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_12949-add_syspref_to_control_display_of_unlinked_guarantor.sql @@ -0,0 +1 @@ +INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('GuarantorsMustBeLinkedToPatronAccount', 1, NULL, 'When adding a guarantor to a borrower Koha will enforce that the guarantor must be linked to a patron account', 'YesNo'); diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index a0d1132d25..4555258049 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -199,6 +199,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('GoogleOpenIDConnectDefaultBranch', '','','This branch code will be used to create Google OpenID Connect patrons.','Textarea'), ('GoogleOpenIDConnectDefaultCategory','','','This category code will be used to create Google OpenID Connect patrons.','Textarea'), ('GoogleOpenIDConnectDomain', '', NULL, 'Restrict Google OpenID Connect to this domain (or subdomains of this domain). Leave blank for all Google domains', 'Free'), +('GuarantorsMustBeLinkedToPatronAccount', 1, NULL, 'When adding a guarantor to a borrower Koha will enforce that the guarantor must be linked to a patron account', 'YesNo'), ('hidelostitems','0','','If ON, disables display of\"lost\" items in OPAC.','YesNo'), ('HidePatronName','0','','If this is switched on, patron\'s cardnumber will be shown instead of their name on the holds and catalog screens','YesNo'), ('hide_marc','0',NULL,'If ON, disables display of MARC fields, subfield codes & indicators (still shows data)','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref index 9007da96a4..617524d0ca 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref @@ -227,6 +227,12 @@ Patrons: no: Allow all permitted users - "to access/change superlibrarian privileges." - "
NOTE: A permitted user needs to have the 'permissions' flag (if no superlibrarian)." + - + - pref: GuarantorsMustBeLinkedToPatronAccount + choices: + yes: 'Enable' + no: 'Disable' + - When adding a guarantor to a borrower Koha will enforce that the guarantor must be linked to a patron account Privacy: - diff --git a/members/moremember.pl b/members/moremember.pl index 1f63180e58..1d4e751d7b 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -103,7 +103,7 @@ if ( my $guarantor = $patron->guarantor ) { $template->param( guarantor => $guarantor ); push @relatives, $guarantor->borrowernumber; push @relatives, $_->borrowernumber for $patron->siblings; -} elsif ( $patron->contactname || $patron->contactfirstname ) { +} elsif (( !C4::Context->preference('GuarantorsMustBeLinkedToPatronAccount')) && ( $patron->contactname || $patron->contactfirstname )) { $template->param( guarantor => { firstname => $patron->contactfirstname, -- 2.17.1