From 11eaeec3d0b3a486603cbc873688aaffe74f80f4 Mon Sep 17 00:00:00 2001 From: Maryse Simard Date: Fri, 2 Oct 2020 00:02:38 -0400 Subject: [PATCH] Bug 12446: Ability to allow guarantor relationship for all patron category types This adds a new field "Can be guarantee" to patron categories so it becomes possible for any category type to have a guarantor. To test: 1) Have a patron category of type 'Adult' and one of type 'Child' 2) Confirm, by searching for the "Patron guarantor" fieldset in the edit/create form, that: => a patron of the first category can't have a guarantor => a patron from the second category can 3) Apply patch and run updatedatabase.pl 4) Edit the categories and note the new "Can be guarantee" field 5) It should have been set to "yes" for the "Child" and to "no" for the "Adult" 5) Repeat step 2. It should behave in the same way. 6) Edit the "Can be guarantee" for any of the category and check that the fieldset only appears when "Can be guarantee" is set to "yes" 7) prove t/db_dependent/Patrons.t => tests should still pass Signed-off-by: David Nind Signed-off-by: Kyle M Hall Signed-off-by: David Nind Signed-off-by: Owen Leonard --- Koha/Patron.pm | 3 +-- admin/categories.pl | 3 +++ installer/data/mysql/atomicupdate/bug_12446.perl | 10 ++++++++++ installer/data/mysql/kohastructure.sql | 4 +++- .../prog/en/includes/members-toolbar.inc | 2 +- .../prog/en/modules/admin/categories.tt | 15 +++++++++++++++ members/memberentry.pl | 3 ++- t/db_dependent/Patrons.t | 9 +++++++-- 8 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_12446.perl diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 266e60846c..26337e33dc 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -303,8 +303,7 @@ sub store { # Clean up guarantors on category change if required $self->guarantor_relationships->delete - if ( $self->category->category_type ne 'C' - && $self->category->category_type ne 'P' ); + unless ( $self->category->canbeguarantee ); } diff --git a/admin/categories.pl b/admin/categories.pl index 368960f9cd..13a8458651 100755 --- a/admin/categories.pl +++ b/admin/categories.pl @@ -79,6 +79,7 @@ elsif ( $op eq 'add_validate' ) { my $min_password_length = $input->param('min_password_length'); my $require_strong_password = $input->param('require_strong_password'); my @branches = grep { $_ ne q{} } $input->multi_param('branches'); + my $canbeguarantee = $input->param('canbeguarantee'); $reset_password = undef if $reset_password eq -1; $change_password = undef if $change_password eq -1; @@ -110,6 +111,7 @@ elsif ( $op eq 'add_validate' ) { $category->hidelostitems($hidelostitems); $category->overduenoticerequired($overduenoticerequired); $category->category_type($category_type); + $category->canbeguarantee($canbeguarantee); $category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions); $category->checkprevcheckout($checkPrevCheckout); $category->default_privacy($default_privacy); @@ -141,6 +143,7 @@ elsif ( $op eq 'add_validate' ) { hidelostitems => $hidelostitems, overduenoticerequired => $overduenoticerequired, category_type => $category_type, + canbeguarantee => $canbeguarantee, BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions, checkprevcheckout => $checkPrevCheckout, default_privacy => $default_privacy, diff --git a/installer/data/mysql/atomicupdate/bug_12446.perl b/installer/data/mysql/atomicupdate/bug_12446.perl new file mode 100644 index 0000000000..9f9e4e5160 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_12446.perl @@ -0,0 +1,10 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + if ( !column_exists( 'categories', 'canbeguarantee') ){ + $dbh->do("ALTER TABLE categories ADD COLUMN `canbeguarantee` tinyint(1) NOT NULL default '0' AFTER `checkprevcheckout`"); + $dbh->do("UPDATE categories SET canbeguarantee = 1 WHERE category_type = 'P' OR category_type = 'C'"); + } + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 12446 - Ability to allow guarantor relationship for all patron category types)\n"; +} \ No newline at end of file diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 8f5f7b438f..6ab17cc316 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -347,6 +347,7 @@ CREATE TABLE `aqbasket` ( -- Table structure for table `aqbasketgroups` -- +<<<<<<< HEAD DROP TABLE IF EXISTS `aqbasketgroups`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -1654,7 +1655,8 @@ CREATE TABLE `categories` ( `BlockExpiredPatronOpacActions` tinyint(1) NOT NULL DEFAULT -1 COMMENT 'wheither or not a patron of this category can renew books or place holds once their card has expired. 0 means they can, 1 means they cannot, -1 means use syspref BlockExpiredPatronOpacActions', `default_privacy` enum('default','never','forever') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'default' COMMENT 'Default privacy setting for this patron category', `checkprevcheckout` varchar(7) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'inherit' COMMENT 'produce a warning for this patron category if this item has previously been checked out to this patron if ''yes'', not if ''no'', defer to syspref setting if ''inherit''.', - `reset_password` tinyint(1) DEFAULT NULL COMMENT 'if patrons of this category can do the password reset flow,', +`canbeguarantee` tinyint(1) NOT NULL default '0', +`reset_password` tinyint(1) DEFAULT NULL COMMENT 'if patrons of this category can do the password reset flow,', `change_password` tinyint(1) DEFAULT NULL COMMENT 'if patrons of this category can change their passwords in the OAPC', `min_password_length` smallint(6) DEFAULT NULL COMMENT 'set minimum password length for patrons in this category', `require_strong_password` tinyint(1) DEFAULT NULL COMMENT 'set required password strength for patrons in this category', diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc index 0466779a60..8773bd2f5b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc @@ -11,7 +11,7 @@ [% IF CAN_user_borrowers_edit_borrowers %] [% IF patron.is_adult AND Koha.Preference("borrowerRelationship") %] - Add guarantee + Add guarantee [% END %] Change password Duplicate diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt index d3f0916d1d..bbbb34a1bb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt @@ -215,6 +215,18 @@ Required +
  • + + +