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

(-)a/Koha/Patron.pm (-1 / +1 lines)
Lines 309-315 sub store { Link Here
309
309
310
                    # Clean up guarantors on category change if required
310
                    # Clean up guarantors on category change if required
311
                    $self->guarantor_relationships->delete
311
                    $self->guarantor_relationships->delete
312
                      unless ( $self->category->can_be_guarantee );
312
                      unless ( $self->category->canbeguarantee );
313
313
314
                }
314
                }
315
315
(-)a/admin/categories.pl (-3 / +3 lines)
Lines 79-85 elsif ( $op eq 'add_validate' ) { Link Here
79
    my $min_password_length = $input->param('min_password_length');
79
    my $min_password_length = $input->param('min_password_length');
80
    my $require_strong_password = $input->param('require_strong_password');
80
    my $require_strong_password = $input->param('require_strong_password');
81
    my @branches = grep { $_ ne q{} } $input->multi_param('branches');
81
    my @branches = grep { $_ ne q{} } $input->multi_param('branches');
82
    my $can_be_guarantee = $input->param('can_be_guarantee');
82
    my $canbeguarantee = $input->param('canbeguarantee');
83
83
84
    $reset_password = undef if $reset_password eq -1;
84
    $reset_password = undef if $reset_password eq -1;
85
    $change_password = undef if $change_password eq -1;
85
    $change_password = undef if $change_password eq -1;
Lines 102-108 elsif ( $op eq 'add_validate' ) { Link Here
102
        $category->hidelostitems($hidelostitems);
102
        $category->hidelostitems($hidelostitems);
103
        $category->overduenoticerequired($overduenoticerequired);
103
        $category->overduenoticerequired($overduenoticerequired);
104
        $category->category_type($category_type);
104
        $category->category_type($category_type);
105
        $category->can_be_guarantee($can_be_guarantee);
105
        $category->canbeguarantee($canbeguarantee);
106
        $category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions);
106
        $category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions);
107
        $category->checkprevcheckout($checkPrevCheckout);
107
        $category->checkprevcheckout($checkPrevCheckout);
108
        $category->default_privacy($default_privacy);
108
        $category->default_privacy($default_privacy);
Lines 135-141 elsif ( $op eq 'add_validate' ) { Link Here
135
            hidelostitems => $hidelostitems,
135
            hidelostitems => $hidelostitems,
136
            overduenoticerequired => $overduenoticerequired,
136
            overduenoticerequired => $overduenoticerequired,
137
            category_type => $category_type,
137
            category_type => $category_type,
138
            can_be_guarantee => $can_be_guarantee,
138
            canbeguarantee => $canbeguarantee,
139
            BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions,
139
            BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions,
140
            checkprevcheckout => $checkPrevCheckout,
140
            checkprevcheckout => $checkPrevCheckout,
141
            default_privacy => $default_privacy,
141
            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 (-2 / +2 lines)
Lines 1672-1679 CREATE TABLE `categories` ( Link Here
1672
  `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',
1672
  `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',
1673
  `default_privacy` enum('default','never','forever') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'default' COMMENT 'Default privacy setting for this patron category',
1673
  `default_privacy` enum('default','never','forever') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'default' COMMENT 'Default privacy setting for this patron category',
1674
  `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''.',
1674
  `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''.',
1675
  `can_be_guarantee` tinyint(1) NOT NULL default 0 COMMENT 'if patrons of this category can be guarantees',
1675
`canbeguarantee` tinyint(1) NOT NULL default '0',
1676
  `reset_password` tinyint(1) DEFAULT NULL COMMENT 'if patrons of this category can do the password reset flow,',
1676
`reset_password` tinyint(1) DEFAULT NULL COMMENT 'if patrons of this category can do the password reset flow,',
1677
  `change_password` tinyint(1) DEFAULT NULL COMMENT 'if patrons of this category can change their passwords in the OAPC',
1677
  `change_password` tinyint(1) DEFAULT NULL COMMENT 'if patrons of this category can change their passwords in the OAPC',
1678
  `min_password_length` smallint(6) DEFAULT NULL COMMENT 'set minimum password length for patrons in this category',
1678
  `min_password_length` smallint(6) DEFAULT NULL COMMENT 'set minimum password length for patrons in this category',
1679
  `require_strong_password` tinyint(1) DEFAULT NULL COMMENT 'set required password strength for patrons in this category',
1679
  `require_strong_password` tinyint(1) DEFAULT NULL COMMENT 'set required password strength for patrons in this category',
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt (-5 / +5 lines)
Lines 239-247 Link Here
239
                    <span class="required">Required</span>
239
                    <span class="required">Required</span>
240
                </li>
240
                </li>
241
                <li>
241
                <li>
242
                    <label for="can_be_guarantee">Can be guarantee</label>
242
                    <label for="canbeguarantee">Can be guarantee</label>
243
                    <select name="can_be_guarantee" id="can_be_guarantee">
243
                    <select name="canbeguarantee" id="canbeguarantee">
244
                        [% IF category.can_be_guarantee %]
244
                        [% IF category.canbeguarantee %]
245
                            <option value="1" selected>Yes</option>
245
                            <option value="1" selected>Yes</option>
246
                            <option value="0">No</option>
246
                            <option value="0">No</option>
247
                        [% ELSE %]
247
                        [% ELSE %]
Lines 509-515 Link Here
509
                      </td>
509
                      </td>
510
                  </tr>
510
                  </tr>
511
                [% END %]
511
                [% END %]
512
                <tr><th scope="row">Can be guarantee</th><td>[% IF category.can_be_guarantee %]Yes[% ELSE %]No[% END %]</td></tr>
512
                <tr><th scope="row">Can be guarantee</th><td>[% IF category.canbeguarantee %]Yes[% ELSE %]No[% END %]</td></tr>
513
                <tr>
513
                <tr>
514
                    <th scope="row">Default privacy: </th>
514
                    <th scope="row">Default privacy: </th>
515
                    <td>
515
                    <td>
Lines 689-695 Link Here
689
                              [% END %]
689
                              [% END %]
690
                          </td>
690
                          </td>
691
                        [% END %]
691
                        [% END %]
692
                        <td>[% IF category.can_be_guarantee %] Yes [% ELSE %] no [% END %]</td>
692
                        <td>[% IF category.canbeguarantee %] Yes [% ELSE %] no [% END %]</td>
693
                        <td>
693
                        <td>
694
                            [% SWITCH category.default_privacy %]
694
                            [% SWITCH category.default_privacy %]
695
                            [% CASE 'default' %]
695
                            [% CASE 'default' %]
(-)a/members/memberentry.pl (-1 / +2 lines)
Lines 755-761 if (C4::Context->preference('EnhancedMessagingPreferences')) { Link Here
755
}
755
}
756
756
757
$template->param( borrower_data => \%data );
757
$template->param( borrower_data => \%data );
758
$template->param( "show_guarantor" => $category ? $category->can_be_guarantee : 1); # associate with step to know where you are
758
$template->param( "show_guarantor" => $categorycode ? Koha::Patron::Categories->find($categorycode)->canbeguarantee : 1); # associate with step to know where you are
759
$debug and warn "memberentry step: $step";
759
$template->param( "step_$step"  => 1) if $step;	# associate with step to know where u are
760
$template->param( "step_$step"  => 1) if $step;	# associate with step to know where u are
760
$template->param(  step  => $step   ) if $step;	# associate with step to know where u are
761
$template->param(  step  => $step   ) if $step;	# associate with step to know where u are
761
762
(-)a/t/db_dependent/Patrons.t (-5 / +6 lines)
Lines 112-127 subtest "Update patron categories" => sub { Link Here
112
            category_type=>'C',
112
            category_type=>'C',
113
            upperagelimit=>17,
113
            upperagelimit=>17,
114
            dateofbirthrequired=>5,
114
            dateofbirthrequired=>5,
115
            can_be_guarantee=>1,
115
            canbeguarantee=>1,
116
        } })->{categorycode};
116
        } })->{categorycode};
117
    my $c_categorycode_2 = $builder->build({ source => 'Category', value => {
117
    my $c_categorycode_2 = $builder->build({ source => 'Category', value => {
118
            category_type=>'C',
118
            category_type=>'C',
119
            upperagelimit=>17,
119
            upperagelimit=>17,
120
            dateofbirthrequired=>5,
120
            dateofbirthrequired=>5,
121
            can_be_guarantee=>1,
121
            canbeguarantee=>1,
122
        } })->{categorycode};
122
        } })->{categorycode};
123
    my $a_categorycode = $builder->build({ source => 'Category', value => {category_type=>'A', can_be_guarantee=>0} })->{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', can_be_guarantee=>1} })->{categorycode};
124
    my $a_categorycode_2 = $builder->build({ source => 'Category', value => {category_type=>'A', canbeguarantee=>1} })->{categorycode};
125
    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};
126
    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};
127
    my $branchcode1 = $builder->build({ source => 'Branch' })->{branchcode};
127
    my $branchcode1 = $builder->build({ source => 'Branch' })->{branchcode};
Lines 201-206 subtest "Update patron categories" => sub { Link Here
201
    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 );
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');
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');
203
    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');
204
206
205
    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 );
206
    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');
207
- 

Return to bug 12446