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

(-)a/Koha/Patron.pm (-2 / +1 lines)
Lines 291-298 sub store { Link Here
291
291
292
                    # Clean up guarantors on category change if required
292
                    # Clean up guarantors on category change if required
293
                    $self->guarantor_relationships->delete
293
                    $self->guarantor_relationships->delete
294
                      if ( $self->category->category_type ne 'C'
294
                      unless ( $self->category->canbeguarantee );
295
                        && $self->category->category_type ne 'P' );
296
295
297
                }
296
                }
298
297
(-)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 111-116 elsif ( $op eq 'add_validate' ) { Link Here
111
        $category->hidelostitems($hidelostitems);
112
        $category->hidelostitems($hidelostitems);
112
        $category->overduenoticerequired($overduenoticerequired);
113
        $category->overduenoticerequired($overduenoticerequired);
113
        $category->category_type($category_type);
114
        $category->category_type($category_type);
115
        $category->canbeguarantee($canbeguarantee);
114
        $category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions);
116
        $category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions);
115
        $category->checkprevcheckout($checkPrevCheckout);
117
        $category->checkprevcheckout($checkPrevCheckout);
116
        $category->default_privacy($default_privacy);
118
        $category->default_privacy($default_privacy);
Lines 142-147 elsif ( $op eq 'add_validate' ) { Link Here
142
            hidelostitems => $hidelostitems,
144
            hidelostitems => $hidelostitems,
143
            overduenoticerequired => $overduenoticerequired,
145
            overduenoticerequired => $overduenoticerequired,
144
            category_type => $category_type,
146
            category_type => $category_type,
147
            canbeguarantee => $canbeguarantee,
145
            BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions,
148
            BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions,
146
            checkprevcheckout => $checkPrevCheckout,
149
            checkprevcheckout => $checkPrevCheckout,
147
            default_privacy => $default_privacy,
150
            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 / +3 lines)
Lines 332-337 CREATE TABLE `aqbasket` ( Link Here
332
-- Table structure for table `aqbasketgroups`
332
-- Table structure for table `aqbasketgroups`
333
--
333
--
334
334
335
<<<<<<< HEAD
335
DROP TABLE IF EXISTS `aqbasketgroups`;
336
DROP TABLE IF EXISTS `aqbasketgroups`;
336
/*!40101 SET @saved_cs_client     = @@character_set_client */;
337
/*!40101 SET @saved_cs_client     = @@character_set_client */;
337
/*!40101 SET character_set_client = utf8 */;
338
/*!40101 SET character_set_client = utf8 */;
Lines 1627-1633 CREATE TABLE `categories` ( Link Here
1627
  `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',
1628
  `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',
1628
  `default_privacy` enum('default','never','forever') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'default' COMMENT 'Default privacy setting for this patron category',
1629
  `default_privacy` enum('default','never','forever') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'default' COMMENT 'Default privacy setting for this patron category',
1629
  `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''.',
1630
  `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''.',
1630
  `reset_password` tinyint(1) DEFAULT NULL COMMENT 'if patrons of this category can do the password reset flow,',
1631
`canbeguarantee` tinyint(1) NOT NULL default '0',
1632
`reset_password` tinyint(1) DEFAULT NULL COMMENT 'if patrons of this category can do the password reset flow,',
1631
  `change_password` tinyint(1) DEFAULT NULL COMMENT 'if patrons of this category can change their passwords in the OAPC',
1633
  `change_password` tinyint(1) DEFAULT NULL COMMENT 'if patrons of this category can change their passwords in the OAPC',
1632
  `min_password_length` smallint(6) DEFAULT NULL COMMENT 'set minimum password length for patrons in this category',
1634
  `min_password_length` smallint(6) DEFAULT NULL COMMENT 'set minimum password length for patrons in this category',
1633
  `require_strong_password` tinyint(1) DEFAULT NULL COMMENT 'set required password strength for patrons in this category',
1635
  `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 215-220 Link Here
215
                    </select>
215
                    </select>
216
                    <span class="required">Required</span>
216
                    <span class="required">Required</span>
217
                </li>
217
                </li>
218
                <li>
219
                    <label for="canbeguarantee">Can be guarantee</label>
220
                    <select name="canbeguarantee" id="canbeguarantee">
221
                        [% IF category.canbeguarantee %]
222
                            <option value="1" selected>Yes</option>
223
                            <option value="0">No</option>
224
                        [% ELSE %]
225
                            <option value="1">Yes</option>
226
                            <option value="0" selected>No</option>
227
                        [% END %]
228
                    <select>
229
                </li>
218
                <li><label for="branches">Library limitations: </label>
230
                <li><label for="branches">Library limitations: </label>
219
                    <select id="branches" name="branches" multiple size="10">
231
                    <select id="branches" name="branches" multiple size="10">
220
                        <option value="">All libraries</option>
232
                        <option value="">All libraries</option>
Lines 471-476 Link Here
471
                      </td>
483
                      </td>
472
                  </tr>
484
                  </tr>
473
                [% END %]
485
                [% END %]
486
                <tr><th scope="row">Can be guarantee</th><td>[% IF category.canbeguarantee %]Yes[% ELSE %]No[% END %]</td></tr>
474
                <tr>
487
                <tr>
475
                    <th scope="row">Default privacy: </th>
488
                    <th scope="row">Default privacy: </th>
476
                    <td>
489
                    <td>
Lines 530-535 Link Here
530
                    [% IF ( Koha.Preference('CheckPrevCheckout') == 'softyes' || Koha.Preference('CheckPrevCheckout') == 'softno' ) %]
543
                    [% IF ( Koha.Preference('CheckPrevCheckout') == 'softyes' || Koha.Preference('CheckPrevCheckout') == 'softno' ) %]
531
                    <th scope="col">Check previous checkout?</th>
544
                    <th scope="col">Check previous checkout?</th>
532
                    [% END %]
545
                    [% END %]
546
                    <th scope="col">Can be guarantee</th>
533
                    <th scope="col">Default privacy</th>
547
                    <th scope="col">Default privacy</th>
534
                    <th scope="col">Exclude from local holds priority</th>
548
                    <th scope="col">Exclude from local holds priority</th>
535
                    <th scope="col">Actions</th>
549
                    <th scope="col">Actions</th>
Lines 640-645 Link Here
640
                              [% END %]
654
                              [% END %]
641
                          </td>
655
                          </td>
642
                        [% END %]
656
                        [% END %]
657
                        <td>[% IF category.canbeguarantee %] Yes [% ELSE %] no [% END %]</td>
643
                        <td>
658
                        <td>
644
                            [% SWITCH category.default_privacy %]
659
                            [% SWITCH category.default_privacy %]
645
                            [% CASE 'default' %]
660
                            [% CASE 'default' %]
(-)a/members/memberentry.pl (-1 / +1 lines)
Lines 817-823 if (C4::Context->preference('EnhancedMessagingPreferences')) { Link Here
817
    $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
817
    $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
818
}
818
}
819
819
820
$template->param( "show_guarantor" => ( $category_type =~ /A|I|S|X/ ) ? 0 : 1 ); # associate with step to know where you are
820
$template->param( "show_guarantor" => $categorycode ? Koha::Patron::Categories->find($categorycode)->canbeguarantee : 1); # associate with step to know where you are
821
$debug and warn "memberentry step: $step";
821
$debug and warn "memberentry step: $step";
822
$template->param(%data);
822
$template->param(%data);
823
$template->param( "step_$step"  => 1) if $step;	# associate with step to know where u are
823
$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 => 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