View | Details | Raw Unified | Return to bug 12446
Collapse All | Expand All

(-)a/Koha/Patron.pm (-2 / +1 lines)
Lines 307-314 sub store { Link Here
307
307
308
                    # Clean up guarantors on category change if required
308
                    # Clean up guarantors on category change if required
309
                    $self->guarantor_relationships->delete
309
                    $self->guarantor_relationships->delete
310
                      if ( $self->category->category_type ne 'C'
310
                      unless ( $self->category->canbeguarantee );
311
                        && $self->category->category_type ne 'P' );
312
311
313
                }
312
                }
314
313
(-)a/admin/categories.pl (+3 lines)
Lines 80-85 elsif ( $op eq 'add_validate' ) { Link Here
80
    my $min_password_length = $input->param('min_password_length');
80
    my $min_password_length = $input->param('min_password_length');
81
    my $require_strong_password = $input->param('require_strong_password');
81
    my $require_strong_password = $input->param('require_strong_password');
82
    my @branches = grep { $_ ne q{} } $input->multi_param('branches');
82
    my @branches = grep { $_ ne q{} } $input->multi_param('branches');
83
    my $canbeguarantee = $input->param('canbeguarantee');
83
84
84
    $reset_password = undef if $reset_password eq -1;
85
    $reset_password = undef if $reset_password eq -1;
85
    $change_password = undef if $change_password eq -1;
86
    $change_password = undef if $change_password eq -1;
Lines 112-117 elsif ( $op eq 'add_validate' ) { Link Here
112
        $category->hidelostitems($hidelostitems);
113
        $category->hidelostitems($hidelostitems);
113
        $category->overduenoticerequired($overduenoticerequired);
114
        $category->overduenoticerequired($overduenoticerequired);
114
        $category->category_type($category_type);
115
        $category->category_type($category_type);
116
        $category->canbeguarantee($canbeguarantee);
115
        $category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions);
117
        $category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions);
116
        $category->checkprevcheckout($checkPrevCheckout);
118
        $category->checkprevcheckout($checkPrevCheckout);
117
        $category->default_privacy($default_privacy);
119
        $category->default_privacy($default_privacy);
Lines 144-149 elsif ( $op eq 'add_validate' ) { Link Here
144
            hidelostitems => $hidelostitems,
146
            hidelostitems => $hidelostitems,
145
            overduenoticerequired => $overduenoticerequired,
147
            overduenoticerequired => $overduenoticerequired,
146
            category_type => $category_type,
148
            category_type => $category_type,
149
            canbeguarantee => $canbeguarantee,
147
            BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions,
150
            BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions,
148
            checkprevcheckout => $checkPrevCheckout,
151
            checkprevcheckout => $checkPrevCheckout,
149
            default_privacy => $default_privacy,
152
            default_privacy => $default_privacy,
(-)a/installer/data/mysql/atomicupdate/bug_12446.perl (+10 lines)
Line 0 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
    if ( !column_exists( 'categories', 'canbeguarantee') ){
4
        $dbh->do("ALTER TABLE categories ADD COLUMN `canbeguarantee` tinyint(1) NOT NULL default '0' AFTER `checkprevcheckout`");
5
        $dbh->do("UPDATE categories SET canbeguarantee = 1 WHERE category_type = 'P' OR category_type = 'C'");
6
    }
7
8
    SetVersion( $DBversion );
9
    print "Upgrade to $DBversion done (Bug 12446 - Ability to allow guarantor relationship for all patron category types)\n";
10
}
(-)a/installer/data/mysql/kohastructure.sql (-1 / +2 lines)
Lines 1664-1670 CREATE TABLE `categories` ( Link Here
1664
  `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',
1664
  `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',
1665
  `default_privacy` enum('default','never','forever') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'default' COMMENT 'Default privacy setting for this patron category',
1665
  `default_privacy` enum('default','never','forever') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'default' COMMENT 'Default privacy setting for this patron category',
1666
  `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''.',
1666
  `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''.',
1667
  `reset_password` tinyint(1) DEFAULT NULL COMMENT 'if patrons of this category can do the password reset flow,',
1667
`canbeguarantee` tinyint(1) NOT NULL default '0',
1668
`reset_password` tinyint(1) DEFAULT NULL COMMENT 'if patrons of this category can do the password reset flow,',
1668
  `change_password` tinyint(1) DEFAULT NULL COMMENT 'if patrons of this category can change their passwords in the OAPC',
1669
  `change_password` tinyint(1) DEFAULT NULL COMMENT 'if patrons of this category can change their passwords in the OAPC',
1669
  `min_password_length` smallint(6) DEFAULT NULL COMMENT 'set minimum password length for patrons in this category',
1670
  `min_password_length` smallint(6) DEFAULT NULL COMMENT 'set minimum password length for patrons in this category',
1670
  `require_strong_password` tinyint(1) DEFAULT NULL COMMENT 'set required password strength for patrons in this category',
1671
  `require_strong_password` tinyint(1) DEFAULT NULL COMMENT 'set required password strength for patrons in this category',
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc (-1 / +1 lines)
Lines 11-17 Link Here
11
11
12
    [% IF CAN_user_borrowers_edit_borrowers %]
12
    [% IF CAN_user_borrowers_edit_borrowers %]
13
        [% IF patron.is_adult AND Koha.Preference("borrowerRelationship") %]
13
        [% IF patron.is_adult AND Koha.Preference("borrowerRelationship") %]
14
            <a id="addchild" class="btn btn-default" href="/cgi-bin/koha/members/memberentry.pl?op=add&amp;guarantor_id=[% patron.borrowernumber | html %]&amp;category_type=C"><i class="fa fa-plus"></i> Add guarantee</a>
14
            <a id="addchild" class="btn btn-default" href="/cgi-bin/koha/members/memberentry.pl?op=add&amp;guarantor_id=[% patron.borrowernumber | html %]"><i class="fa fa-plus"></i> Add guarantee</a>
15
        [% END %]
15
        [% END %]
16
        <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>
16
        <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>
17
        <a id="duplicate" class="btn btn-default" href="/cgi-bin/koha/members/memberentry.pl?op=duplicate&amp;borrowernumber=[% patron.borrowernumber | html %]"><i class="fa fa-copy"></i> Duplicate</a>
17
        <a id="duplicate" class="btn btn-default" href="/cgi-bin/koha/members/memberentry.pl?op=duplicate&amp;borrowernumber=[% patron.borrowernumber | html %]"><i class="fa fa-copy"></i> Duplicate</a>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt (+15 lines)
Lines 219-224 Link Here
219
                    </select>
219
                    </select>
220
                    <span class="required">Required</span>
220
                    <span class="required">Required</span>
221
                </li>
221
                </li>
222
                <li>
223
                    <label for="canbeguarantee">Can be guarantee</label>
224
                    <select name="canbeguarantee" id="canbeguarantee">
225
                        [% IF category.canbeguarantee %]
226
                            <option value="1" selected>Yes</option>
227
                            <option value="0">No</option>
228
                        [% ELSE %]
229
                            <option value="1">Yes</option>
230
                            <option value="0" selected>No</option>
231
                        [% END %]
232
                    <select>
233
                </li>
222
                <li><label for="branches">Library limitations: </label>
234
                <li><label for="branches">Library limitations: </label>
223
                    <select id="branches" name="branches" multiple size="10">
235
                    <select id="branches" name="branches" multiple size="10">
224
                        <option value="">All libraries</option>
236
                        <option value="">All libraries</option>
Lines 478-483 Link Here
478
                      </td>
490
                      </td>
479
                  </tr>
491
                  </tr>
480
                [% END %]
492
                [% END %]
493
                <tr><th scope="row">Can be guarantee</th><td>[% IF category.canbeguarantee %]Yes[% ELSE %]No[% END %]</td></tr>
481
                <tr>
494
                <tr>
482
                    <th scope="row">Default privacy: </th>
495
                    <th scope="row">Default privacy: </th>
483
                    <td>
496
                    <td>
Lines 538-543 Link Here
538
                    [% IF ( Koha.Preference('CheckPrevCheckout') == 'softyes' || Koha.Preference('CheckPrevCheckout') == 'softno' ) %]
551
                    [% IF ( Koha.Preference('CheckPrevCheckout') == 'softyes' || Koha.Preference('CheckPrevCheckout') == 'softno' ) %]
539
                    <th scope="col">Check previous checkout?</th>
552
                    <th scope="col">Check previous checkout?</th>
540
                    [% END %]
553
                    [% END %]
554
                    <th scope="col">Can be guarantee</th>
541
                    <th scope="col">Default privacy</th>
555
                    <th scope="col">Default privacy</th>
542
                    <th scope="col">Exclude from local holds priority</th>
556
                    <th scope="col">Exclude from local holds priority</th>
543
                    <th scope="col">Actions</th>
557
                    <th scope="col">Actions</th>
Lines 655-660 Link Here
655
                              [% END %]
669
                              [% END %]
656
                          </td>
670
                          </td>
657
                        [% END %]
671
                        [% END %]
672
                        <td>[% IF category.canbeguarantee %] Yes [% ELSE %] no [% END %]</td>
658
                        <td>
673
                        <td>
659
                            [% SWITCH category.default_privacy %]
674
                            [% SWITCH category.default_privacy %]
660
                            [% CASE 'default' %]
675
                            [% CASE 'default' %]
(-)a/members/memberentry.pl (-1 / +2 lines)
Lines 819-826 if (C4::Context->preference('EnhancedMessagingPreferences')) { Link Here
819
    $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
819
    $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
820
}
820
}
821
821
822
$template->param( "show_guarantor" => ( $category_type =~ /A|I|S|X/ ) ? 0 : 1 ); # associate with step to know where you are
823
$template->param( borrower_data => \%data );
822
$template->param( borrower_data => \%data );
823
$template->param( "show_guarantor" => $categorycode ? Koha::Patron::Categories->find($categorycode)->canbeguarantee : 1); # associate with step to know where you are
824
$debug and warn "memberentry step: $step";
824
$template->param( "step_$step"  => 1) if $step;	# associate with step to know where u are
825
$template->param( "step_$step"  => 1) if $step;	# associate with step to know where u are
825
$template->param(  step  => $step   ) if $step;	# associate with step to know where u are
826
$template->param(  step  => $step   ) if $step;	# associate with step to know where u are
826
827
(-)a/t/db_dependent/Patrons.t (-3 / +7 lines)
Lines 106-124 foreach my $b ( $patrons->as_list() ) { Link Here
106
}
106
}
107
107
108
subtest "Update patron categories" => sub {
108
subtest "Update patron categories" => sub {
109
    plan tests => 24;
109
    plan tests => 26;
110
    t::lib::Mocks::mock_preference( 'borrowerRelationship', 'test' );
110
    t::lib::Mocks::mock_preference( 'borrowerRelationship', 'test' );
111
    my $c_categorycode = $builder->build({ source => 'Category', value => {
111
    my $c_categorycode = $builder->build({ source => 'Category', value => {
112
            category_type=>'C',
112
            category_type=>'C',
113
            upperagelimit=>17,
113
            upperagelimit=>17,
114
            dateofbirthrequired=>5,
114
            dateofbirthrequired=>5,
115
            canbeguarantee=>1,
115
        } })->{categorycode};
116
        } })->{categorycode};
116
    my $c_categorycode_2 = $builder->build({ source => 'Category', value => {
117
    my $c_categorycode_2 = $builder->build({ source => 'Category', value => {
117
            category_type=>'C',
118
            category_type=>'C',
118
            upperagelimit=>17,
119
            upperagelimit=>17,
119
            dateofbirthrequired=>5,
120
            dateofbirthrequired=>5,
121
            canbeguarantee=>1,
120
        } })->{categorycode};
122
        } })->{categorycode};
121
    my $a_categorycode = $builder->build({ source => 'Category', value => {category_type=>'A'} })->{categorycode};
123
    my $a_categorycode = $builder->build({ source => 'Category', value => {category_type=>'A', canbeguarantee=>0} })->{categorycode};
124
    my $a_categorycode_2 = $builder->build({ source => 'Category', value => {category_type=>'A', canbeguarantee=>1} })->{categorycode};
122
    my $p_categorycode = $builder->build({ source => 'Category', value => {category_type=>'P'} })->{categorycode};
125
    my $p_categorycode = $builder->build({ source => 'Category', value => {category_type=>'P'} })->{categorycode};
123
    my $i_categorycode = $builder->build({ source => 'Category', value => {category_type=>'I'} })->{categorycode};
126
    my $i_categorycode = $builder->build({ source => 'Category', value => {category_type=>'I'} })->{categorycode};
124
    my $branchcode1 = $builder->build({ source => 'Branch' })->{branchcode};
127
    my $branchcode1 = $builder->build({ source => 'Branch' })->{branchcode};
Lines 198-203 subtest "Update patron categories" => sub { Link Here
198
    is( Koha::Patrons->search_patrons_to_update_category({from=>$c_categorycode_2,too_young=>1})->next->borrowernumber, $child1->borrowernumber );
201
    is( Koha::Patrons->search_patrons_to_update_category({from=>$c_categorycode_2,too_young=>1})->next->borrowernumber, $child1->borrowernumber );
199
    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');
202
    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');
200
    is( Koha::Patrons->find($adult1->borrowernumber)->guarantee_relationships->guarantees->count,2,'Guarantee was removed when made adult');
203
    is( Koha::Patrons->find($adult1->borrowernumber)->guarantee_relationships->guarantees->count,2,'Guarantee was removed when made adult');
204
    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');
205
    is( Koha::Patrons->find($adult1->borrowernumber)->guarantee_relationships->guarantees->count,2,'Guarantees were not removed when made adult which can be guarantee');
201
206
202
    is( Koha::Patrons->search_patrons_to_update_category({from=>$c_categorycode_2,too_old=>1})->next->borrowernumber, $child3->borrowernumber );
207
    is( Koha::Patrons->search_patrons_to_update_category({from=>$c_categorycode_2,too_old=>1})->next->borrowernumber, $child3->borrowernumber );
203
    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');
208
    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');
204
- 

Return to bug 12446