Bugzilla – Attachment 133952 Details for
Bug 12446
Enable an adult to have a guarantor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12446: Ability to allow guarantor relationship for all patron category types
Bug-12446-Ability-to-allow-guarantor-relationship-.patch (text/plain), 13.88 KB, created by
Owen Leonard
on 2022-04-26 16:21:42 UTC
(
hide
)
Description:
Bug 12446: Ability to allow guarantor relationship for all patron category types
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2022-04-26 16:21:42 UTC
Size:
13.88 KB
patch
obsolete
>From 11eaeec3d0b3a486603cbc873688aaffe74f80f4 Mon Sep 17 00:00:00 2001 >From: Maryse Simard <maryse.simard@inlibro.com> >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 <david@davidnind.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> > >Signed-off-by: David Nind <david@davidnind.com> > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >--- > 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") %] >- <a id="addchild" class="btn btn-default" href="/cgi-bin/koha/members/memberentry.pl?op=add&guarantor_id=[% patron.borrowernumber | html %]&category_type=C"><i class="fa fa-plus"></i> Add guarantee</a> >+ <a id="addchild" class="btn btn-default" href="/cgi-bin/koha/members/memberentry.pl?op=add&guarantor_id=[% patron.borrowernumber | html %]"><i class="fa fa-plus"></i> Add guarantee</a> > [% END %] > <a id="changepassword" class="btn btn-default" href="/cgi-bin/koha/members/member-password.pl?member=[% patron.borrowernumber | html %]"><i class="fa fa-lock"></i> Change password</a> > <a id="duplicate" class="btn btn-default" href="/cgi-bin/koha/members/memberentry.pl?op=duplicate&borrowernumber=[% patron.borrowernumber | html %]"><i class="fa fa-copy"></i> Duplicate</a> >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 @@ > </select> > <span class="required">Required</span> > </li> >+ <li> >+ <label for="canbeguarantee">Can be guarantee</label> >+ <select name="canbeguarantee" id="canbeguarantee"> >+ [% IF category.canbeguarantee %] >+ <option value="1" selected>Yes</option> >+ <option value="0">No</option> >+ [% ELSE %] >+ <option value="1">Yes</option> >+ <option value="0" selected>No</option> >+ [% END %] >+ <select> >+ </li> > <li><label for="branches">Library limitations: </label> > <select id="branches" name="branches" multiple size="10"> > <option value="">All libraries</option> >@@ -473,6 +485,7 @@ > </td> > </tr> > [% END %] >+ <tr><th scope="row">Can be guarantee</th><td>[% IF category.canbeguarantee %]Yes[% ELSE %]No[% END %]</td></tr> > <tr> > <th scope="row">Default privacy: </th> > <td> >@@ -532,6 +545,7 @@ > [% IF ( Koha.Preference('CheckPrevCheckout') == 'softyes' || Koha.Preference('CheckPrevCheckout') == 'softno' ) %] > <th scope="col">Check previous checkout?</th> > [% END %] >+ <th scope="col">Can be guarantee</th> > <th scope="col">Default privacy</th> > <th scope="col">Exclude from local holds priority</th> > <th scope="col">Actions</th> >@@ -644,6 +658,7 @@ > [% END %] > </td> > [% END %] >+ <td>[% IF category.canbeguarantee %] Yes [% ELSE %] no [% END %]</td> > <td> > [% SWITCH category.default_privacy %] > [% CASE 'default' %] >diff --git a/members/memberentry.pl b/members/memberentry.pl >index 4e25891dd0..217b56bc4c 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -814,8 +814,9 @@ if (C4::Context->preference('EnhancedMessagingPreferences')) { > $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification")); > } > >-$template->param( "show_guarantor" => ( $category_type =~ /A|I|S|X/ ) ? 0 : 1 ); # associate with step to know where you are > $template->param( borrower_data => \%data ); >+$template->param( "show_guarantor" => $categorycode ? Koha::Patron::Categories->find($categorycode)->canbeguarantee : 1); # associate with step to know where you are >+$debug and warn "memberentry step: $step"; > $template->param( "step_$step" => 1) if $step; # associate with step to know where u are > $template->param( step => $step ) if $step; # associate with step to know where u are > >diff --git a/t/db_dependent/Patrons.t b/t/db_dependent/Patrons.t >index 8c90f7e8a1..4a5ff218c1 100755 >--- a/t/db_dependent/Patrons.t >+++ b/t/db_dependent/Patrons.t >@@ -106,19 +106,22 @@ foreach my $b ( $patrons->as_list() ) { > } > > subtest "Update patron categories" => sub { >- plan tests => 24; >+ plan tests => 26; > t::lib::Mocks::mock_preference( 'borrowerRelationship', 'test' ); > my $c_categorycode = $builder->build({ source => 'Category', value => { > category_type=>'C', > upperagelimit=>17, > dateofbirthrequired=>5, >+ canbeguarantee=>1, > } })->{categorycode}; > my $c_categorycode_2 = $builder->build({ source => 'Category', value => { > category_type=>'C', > upperagelimit=>17, > dateofbirthrequired=>5, >+ canbeguarantee=>1, > } })->{categorycode}; >- my $a_categorycode = $builder->build({ source => 'Category', value => {category_type=>'A'} })->{categorycode}; >+ my $a_categorycode = $builder->build({ source => 'Category', value => {category_type=>'A', canbeguarantee=>0} })->{categorycode}; >+ my $a_categorycode_2 = $builder->build({ source => 'Category', value => {category_type=>'A', canbeguarantee=>1} })->{categorycode}; > my $p_categorycode = $builder->build({ source => 'Category', value => {category_type=>'P'} })->{categorycode}; > my $i_categorycode = $builder->build({ source => 'Category', value => {category_type=>'I'} })->{categorycode}; > my $branchcode1 = $builder->build({ source => 'Branch' })->{branchcode}; >@@ -198,6 +201,8 @@ subtest "Update patron categories" => sub { > is( Koha::Patrons->search_patrons_to_update_category({from=>$c_categorycode_2,too_young=>1})->next->borrowernumber, $child1->borrowernumber ); > is( Koha::Patrons->search_patrons_to_update_category({from=>$c_categorycode_2,too_young=>1})->update_category_to({category=>$a_categorycode}),1,'One child patron updated to adult category because too young'); > is( Koha::Patrons->find($adult1->borrowernumber)->guarantee_relationships->guarantees->count,2,'Guarantee was removed when made adult'); >+ is( Koha::Patrons->search_patrons_to_update_category({from=>$c_categorycode_2})->update_category_to({category=>$a_categorycode_2}),2,'Two child patrons updated to adult category'); >+ is( Koha::Patrons->find($adult1->borrowernumber)->guarantee_relationships->guarantees->count,2,'Guarantees were not removed when made adult which can be guarantee'); > > is( Koha::Patrons->search_patrons_to_update_category({from=>$c_categorycode_2,too_old=>1})->next->borrowernumber, $child3->borrowernumber ); > is( Koha::Patrons->search_patrons_to_update_category({from=>$c_categorycode_2,too_old=>1})->update_category_to({category=>$a_categorycode}),1,'One child patron updated to adult category because too old'); >-- >2.20.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 12446
:
29278
|
36176
|
39744
|
42469
|
42470
|
42535
|
46277
|
46278
|
46327
|
46328
|
46345
|
46486
|
49793
|
50953
|
53534
|
53535
|
53536
|
53913
|
60929
|
60930
|
60934
|
63148
|
63149
|
63214
|
64793
|
64794
|
64828
|
72295
|
72883
|
77766
|
77767
|
77768
|
79343
|
79344
|
79345
|
79347
|
79348
|
85069
|
88364
|
88365
|
88366
|
88367
|
90389
|
90390
|
90391
|
90392
|
90470
|
90471
|
90472
|
90473
|
93388
|
93389
|
93390
|
93391
|
93392
|
93393
|
93394
|
95411
|
95853
|
95854
|
95855
|
95856
|
95857
|
95858
|
95859
|
95860
|
106753
|
106754
|
106755
|
106756
|
106757
|
107611
|
111052
|
111053
|
111317
|
111318
|
112102
|
112160
|
112161
|
112162
|
112163
|
113583
|
121925
|
121926
|
121927
|
121928
|
121929
|
122084
|
122085
|
122086
|
122087
|
122088
|
122089
|
122090
|
122091
|
122184
|
122185
|
122186
|
122187
|
130398
|
130399
|
130400
|
130401
|
130402
|
131965
|
131966
|
131967
|
131968
|
131969
|
133691
|
133952
|
133953
|
133954
|
133955
|
133956
|
133957
|
134930
|
134931
|
134932
|
134933
|
134934
|
134935
|
134936
|
135506
|
135507
|
135508
|
135509
|
135510
|
135511
|
135512
|
135519
|
135520
|
135521
|
135522
|
135523
|
135544
|
135545
|
142401
|
142408
|
142431
|
142432
|
142433
|
142434
|
142435
|
142436
|
142437
|
142438
|
142439