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

(-)a/Koha/Patron.pm (-2 / +1 lines)
Lines 290-297 sub store { Link Here
290
290
291
                    # Clean up guarantors on category change if required
291
                    # Clean up guarantors on category change if required
292
                    $self->guarantor_relationships->delete
292
                    $self->guarantor_relationships->delete
293
                      if ( $self->category->category_type ne 'C'
293
                      unless ( $self->category->canbeguarantee );
294
                        && $self->category->category_type ne 'P' );
295
294
296
                }
295
                }
297
296
(-)a/admin/categories.pl (+3 lines)
Lines 97-102 elsif ( $op eq 'add_validate' ) { Link Here
97
    my $min_password_length = $input->param('min_password_length');
97
    my $min_password_length = $input->param('min_password_length');
98
    my $require_strong_password = $input->param('require_strong_password');
98
    my $require_strong_password = $input->param('require_strong_password');
99
    my @branches = grep { $_ ne q{} } $input->multi_param('branches');
99
    my @branches = grep { $_ ne q{} } $input->multi_param('branches');
100
    my $canbeguarantee = $input->param('canbeguarantee');
100
101
101
    $reset_password = undef if $reset_password eq -1;
102
    $reset_password = undef if $reset_password eq -1;
102
    $change_password = undef if $change_password eq -1;
103
    $change_password = undef if $change_password eq -1;
Lines 128-133 elsif ( $op eq 'add_validate' ) { Link Here
128
        $category->hidelostitems($hidelostitems);
129
        $category->hidelostitems($hidelostitems);
129
        $category->overduenoticerequired($overduenoticerequired);
130
        $category->overduenoticerequired($overduenoticerequired);
130
        $category->category_type($category_type);
131
        $category->category_type($category_type);
132
        $category->canbeguarantee($canbeguarantee);
131
        $category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions);
133
        $category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions);
132
        $category->checkprevcheckout($checkPrevCheckout);
134
        $category->checkprevcheckout($checkPrevCheckout);
133
        $category->default_privacy($default_privacy);
135
        $category->default_privacy($default_privacy);
Lines 159-164 elsif ( $op eq 'add_validate' ) { Link Here
159
            hidelostitems => $hidelostitems,
161
            hidelostitems => $hidelostitems,
160
            overduenoticerequired => $overduenoticerequired,
162
            overduenoticerequired => $overduenoticerequired,
161
            category_type => $category_type,
163
            category_type => $category_type,
164
            canbeguarantee => $canbeguarantee,
162
            BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions,
165
            BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions,
163
            checkprevcheckout => $checkPrevCheckout,
166
            checkprevcheckout => $checkPrevCheckout,
164
            default_privacy => $default_privacy,
167
            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 lines)
Lines 325-330 CREATE TABLE `categories` ( -- this table shows information related to Koha patr Link Here
325
  `BlockExpiredPatronOpacActions` tinyint(1) NOT NULL default '-1', -- 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
325
  `BlockExpiredPatronOpacActions` tinyint(1) NOT NULL default '-1', -- 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
326
  `default_privacy` ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default', -- Default privacy setting for this patron category
326
  `default_privacy` ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default', -- Default privacy setting for this patron category
327
  `checkprevcheckout` varchar(7) NOT NULL default 'inherit', -- 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'.
327
  `checkprevcheckout` varchar(7) NOT NULL default 'inherit', -- 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'.
328
  `canbeguarantee` tinyint(1) NOT NULL default '0',
328
  `reset_password` TINYINT(1) NULL DEFAULT NULL, -- if patrons of this category can do the password reset flow,
329
  `reset_password` TINYINT(1) NULL DEFAULT NULL, -- if patrons of this category can do the password reset flow,
329
  `change_password` TINYINT(1) NULL DEFAULT NULL, -- if patrons of this category can change their passwords in the OAPC
330
  `change_password` TINYINT(1) NULL DEFAULT NULL, -- if patrons of this category can change their passwords in the OAPC
330
  `min_password_length` smallint(6) NULL DEFAULT NULL, -- set minimum password length for patrons in this category
331
  `min_password_length` smallint(6) NULL DEFAULT NULL, -- set minimum password length 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 151-156 Link Here
151
                    </select>
151
                    </select>
152
                    <span class="required">Required</span>
152
                    <span class="required">Required</span>
153
                </li>
153
                </li>
154
                <li>
155
                    <label for="canbeguarantee">Can be guarantee</label>
156
                    <select name="canbeguarantee" id="canbeguarantee">
157
                        [% IF category.canbeguarantee %]
158
                            <option value="1" selected>Yes</option>
159
                            <option value="0">No</option>
160
                        [% ELSE %]
161
                            <option value="1">Yes</option>
162
                            <option value="0" selected>No</option>
163
                        [% END %]
164
                    <select>
165
                </li>
154
                <li><label for="branches">Library limitations: </label>
166
                <li><label for="branches">Library limitations: </label>
155
                    <select id="branches" name="branches" multiple size="10">
167
                    <select id="branches" name="branches" multiple size="10">
156
                        <option value="">All libraries</option>
168
                        <option value="">All libraries</option>
Lines 413-418 Link Here
413
                      </td>
425
                      </td>
414
                  </tr>
426
                  </tr>
415
                [% END %]
427
                [% END %]
428
                <tr><th scope="row">Can be guarantee</th><td>[% IF category.canbeguarantee %]Yes[% ELSE %]No[% END %]</td></tr>
416
                <tr>
429
                <tr>
417
                    <th scope="row">Default privacy: </th>
430
                    <th scope="row">Default privacy: </th>
418
                    <td>
431
                    <td>
Lines 472-477 Link Here
472
                    [% IF ( Koha.Preference('CheckPrevCheckout') == 'softyes' || Koha.Preference('CheckPrevCheckout') == 'softno' ) %]
485
                    [% IF ( Koha.Preference('CheckPrevCheckout') == 'softyes' || Koha.Preference('CheckPrevCheckout') == 'softno' ) %]
473
                    <th scope="col">Check previous checkout?</th>
486
                    <th scope="col">Check previous checkout?</th>
474
                    [% END %]
487
                    [% END %]
488
                    <th scope="col">Can be guarantee</th>
475
                    <th scope="col">Default privacy</th>
489
                    <th scope="col">Default privacy</th>
476
                    <th scope="col">Exclude from local holds priority</th>
490
                    <th scope="col">Exclude from local holds priority</th>
477
                    <th scope="col">Actions</th>
491
                    <th scope="col">Actions</th>
Lines 577-582 Link Here
577
                              [% END %]
591
                              [% END %]
578
                          </td>
592
                          </td>
579
                        [% END %]
593
                        [% END %]
594
                        <td>[% IF category.canbeguarantee %] Yes [% ELSE %] no [% END %]</td>
580
                        <td>
595
                        <td>
581
                            [% SWITCH category.default_privacy %]
596
                            [% SWITCH category.default_privacy %]
582
                            [% CASE 'default' %]
597
                            [% CASE 'default' %]
(-)a/members/memberentry.pl (-1 / +1 lines)
Lines 822-828 if (C4::Context->preference('EnhancedMessagingPreferences')) { Link Here
822
    $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
822
    $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
823
}
823
}
824
824
825
$template->param( "show_guarantor" => ( $category_type =~ /A|I|S|X/ ) ? 0 : 1 ); # associate with step to know where you are
825
$template->param( "show_guarantor" => $categorycode ? Koha::Patron::Categories->find($categorycode)->canbeguarantee : 1); # associate with step to know where you are
826
$debug and warn "memberentry step: $step";
826
$debug and warn "memberentry step: $step";
827
$template->param(%data);
827
$template->param(%data);
828
$template->param( "step_$step"  => 1) if $step;	# associate with step to know where u are
828
$template->param( "step_$step"  => 1) if $step;	# associate with step to know where u are
(-)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 => 20;
109
    plan tests => 22;
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 195-200 subtest "Update patron categories" => sub { Link Here
195
    is( Koha::Patrons->find($adult1->borrowernumber)->guarantee_relationships->guarantees->count,3,'Guarantees not removed when made changing child categories');
198
    is( Koha::Patrons->find($adult1->borrowernumber)->guarantee_relationships->guarantees->count,3,'Guarantees not removed when made changing child categories');
196
    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');
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');
197
    is( Koha::Patrons->find($adult1->borrowernumber)->guarantee_relationships->guarantees->count,2,'Guarantee was removed when made adult');
200
    is( Koha::Patrons->find($adult1->borrowernumber)->guarantee_relationships->guarantees->count,2,'Guarantee was removed when made adult');
201
    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');
202
    is( Koha::Patrons->find($adult1->borrowernumber)->guarantee_relationships->guarantees->count,2,'Guarantees were not removed when made adult which can be guarantee');
198
203
199
    is( Koha::Patrons->find($inst->borrowernumber)->guarantee_relationships->guarantees->count,1,'Guarantor has 1 guarantees');
204
    is( Koha::Patrons->find($inst->borrowernumber)->guarantee_relationships->guarantees->count,1,'Guarantor has 1 guarantees');
200
    is( Koha::Patrons->search_patrons_to_update_category({from=>$p_categorycode})->update_category_to({category=>$a_categorycode}),1,'One professional patron updated to adult category');
205
    is( Koha::Patrons->search_patrons_to_update_category({from=>$p_categorycode})->update_category_to({category=>$a_categorycode}),1,'One professional patron updated to adult category');
201
- 

Return to bug 12446