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

(-)a/Koha/Patron.pm (-2 / +2 lines)
Lines 2258-2264 sub extended_attributes { Link Here
2258
                my $interface = C4::Context->interface;
2258
                my $interface = C4::Context->interface;
2259
                my $params = {
2259
                my $params = {
2260
                    mandatory                                        => 1,
2260
                    mandatory                                        => 1,
2261
                    category_code                                    => [ undef, $self->categorycode ],
2261
                    'borrower_attribute_types_categories.categorycode' => [ undef, $self->categorycode ],
2262
                    'borrower_attribute_types_branches.b_branchcode' => undef,
2262
                    'borrower_attribute_types_branches.b_branchcode' => undef,
2263
                };
2263
                };
2264
2264
Lines 2268-2274 sub extended_attributes { Link Here
2268
2268
2269
                my @required_attribute_types = Koha::Patron::Attribute::Types->search(
2269
                my @required_attribute_types = Koha::Patron::Attribute::Types->search(
2270
                    $params,
2270
                    $params,
2271
                    { join => 'borrower_attribute_types_branches' }
2271
                    { join => [ 'borrower_attribute_types_branches', 'borrower_attribute_types_categories' ] }
2272
                )->get_column('code');
2272
                )->get_column('code');
2273
                for my $type (@required_attribute_types) {
2273
                for my $type (@required_attribute_types) {
2274
                    Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute->throw(
2274
                    Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute->throw(
(-)a/Koha/Patron/Attribute/Type.pm (+22 lines)
Lines 60-65 sub attributes { Link Here
60
    Koha::Patron::Attributes->_new_from_dbic($attributes_rs);
60
    Koha::Patron::Attributes->_new_from_dbic($attributes_rs);
61
}
61
}
62
62
63
=head3 categories
64
65
Get or set attribute type's categories
66
67
    my @categories = $attribute_type->categories->as_list;
68
    $attribute_type->categories(\@categories);
69
70
=cut
71
72
sub categories {
73
    my ($self, $categories) = @_;
74
75
    if ($categories) {
76
        my @categorycodes = map { $_->_result } @$categories;
77
        $self->_result->set_categorycodes(\@categorycodes);
78
        return $self;
79
    }
80
81
    my $rs = $self->_result->categorycodes;
82
    return Koha::Patron::Categories->_new_from_dbic($rs);
83
}
84
63
=head2 Internal Methods
85
=head2 Internal Methods
64
86
65
=cut
87
=cut
(-)a/admin/patron-attr-types.pl (-2 / +6 lines)
Lines 118-124 sub add_update_attribute_type { Link Here
118
    my $mandatory                 = $input->param('mandatory') ? 1 : 0;
118
    my $mandatory                 = $input->param('mandatory') ? 1 : 0;
119
    my $authorised_value_category = $input->param('authorised_value_category');
119
    my $authorised_value_category = $input->param('authorised_value_category');
120
    my $display_checkout          = $input->param('display_checkout') ? 1 : 0;
120
    my $display_checkout          = $input->param('display_checkout') ? 1 : 0;
121
    my $category_code             = $input->param('category_code') || undef;
122
    my $class                     = $input->param('class');
121
    my $class                     = $input->param('class');
123
122
124
    my $attr_type = Koha::Patron::Attribute::Types->find($code);
123
    my $attr_type = Koha::Patron::Attribute::Types->find($code);
Lines 155-161 sub add_update_attribute_type { Link Here
155
            mandatory                 => $mandatory,
154
            mandatory                 => $mandatory,
156
            authorised_value_category => $authorised_value_category,
155
            authorised_value_category => $authorised_value_category,
157
            display_checkout          => $display_checkout,
156
            display_checkout          => $display_checkout,
158
            category_code             => $category_code,
159
            class                     => $class,
157
            class                     => $class,
160
        }
158
        }
161
    )->store;
159
    )->store;
Lines 163-168 sub add_update_attribute_type { Link Here
163
    my @branches = grep { ! /^\s*$/ } $input->multi_param('branches');
161
    my @branches = grep { ! /^\s*$/ } $input->multi_param('branches');
164
    $attr_type->library_limits( \@branches );
162
    $attr_type->library_limits( \@branches );
165
163
164
    my @categories = grep { ! /^\s*$/ } $input->multi_param('category_code');
165
    $attr_type->categories([
166
        Koha::Patron::Categories->search({ categorycode => \@categories })->as_list
167
    ]);
168
166
    if ( $op eq 'edit' ) {
169
    if ( $op eq 'edit' ) {
167
        $template->param( edited_attribute_type => $attr_type->code() );
170
        $template->param( edited_attribute_type => $attr_type->code() );
168
    }
171
    }
Lines 235-240 sub edit_attribute_type_form { Link Here
235
        $can_be_set_to_unique = 0 if $@;
238
        $can_be_set_to_unique = 0 if $@;
236
        $attr_type->unique_id(0);
239
        $attr_type->unique_id(0);
237
    }
240
    }
241
238
    $template->param(
242
    $template->param(
239
        attribute_type => $attr_type,
243
        attribute_type => $attr_type,
240
        attribute_type_form => 1,
244
        attribute_type_form => 1,
(-)a/installer/data/mysql/atomicupdate/bug-26573.pl (+45 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => '26573',
5
    description => 'Add table borrower_attribute_types_categories',
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
10
        $dbh->do(q{
11
            CREATE TABLE IF NOT EXISTS `borrower_attribute_types_categories` (
12
                `borrower_attribute_type_code` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
13
                `categorycode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
14
                KEY `borrower_attribute_type_code` (`borrower_attribute_type_code`),
15
                KEY `categorycode` (`categorycode`),
16
                CONSTRAINT `borrower_attribute_types_categories_borrower_attribute_type_code` FOREIGN KEY (`borrower_attribute_type_code`) REFERENCES `borrower_attribute_types` (`code`) ON DELETE CASCADE ON UPDATE CASCADE,
17
                CONSTRAINT `borrower_attribute_types_categories_categorycode` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE,
18
                PRIMARY KEY (`borrower_attribute_type_code`, `categorycode`)
19
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
20
        });
21
22
        say $out "Table 'borrower_attribute_types_categories' created";
23
24
        if (column_exists('borrower_attribute_types', 'category_code')) {
25
            $dbh->do(q{
26
                INSERT IGNORE INTO borrower_attribute_types_categories (borrower_attribute_type_code, categorycode)
27
                SELECT `code`, `category_code` FROM `borrower_attribute_types`
28
                WHERE `category_code` IS NOT NULL
29
            });
30
31
            say $out "Data migrated from 'borrower_attribute_types.category_code' to 'borrower_attribute_types_categories'";
32
33
            $dbh->do(q{
34
                ALTER TABLE `borrower_attribute_types`
35
                DROP FOREIGN KEY `borrower_attribute_types_ibfk_1`
36
            });
37
            $dbh->do(q{
38
                ALTER TABLE `borrower_attribute_types`
39
                DROP COLUMN `category_code`
40
            });
41
42
            say $out "Column 'borrower_attribute_types.category_code' deleted";
43
        }
44
    },
45
};
(-)a/installer/data/mysql/kohastructure.sql (-4 / +19 lines)
Lines 1257-1270 CREATE TABLE `borrower_attribute_types` ( Link Here
1257
  `searched_by_default` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if this field is included in "Standard" patron searches in the staff interface (1 for yes, 0 for no)',
1257
  `searched_by_default` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if this field is included in "Standard" patron searches in the staff interface (1 for yes, 0 for no)',
1258
  `authorised_value_category` varchar(32) DEFAULT NULL COMMENT 'foreign key from authorised_values that links this custom field to an authorized value category',
1258
  `authorised_value_category` varchar(32) DEFAULT NULL COMMENT 'foreign key from authorised_values that links this custom field to an authorized value category',
1259
  `display_checkout` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if this field displays in checkout screens',
1259
  `display_checkout` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if this field displays in checkout screens',
1260
  `category_code` varchar(10) DEFAULT NULL COMMENT 'defines a category for an attribute_type',
1261
  `class` varchar(255) NOT NULL DEFAULT '' COMMENT 'defines a class for an attribute_type',
1260
  `class` varchar(255) NOT NULL DEFAULT '' COMMENT 'defines a class for an attribute_type',
1262
  `keep_for_pseudonymization` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if this field is copied to anonymized_borrower_attributes (1 for yes, 0 for no)',
1261
  `keep_for_pseudonymization` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if this field is copied to anonymized_borrower_attributes (1 for yes, 0 for no)',
1263
  `mandatory` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if the attribute is mandatory or not',
1262
  `mandatory` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if the attribute is mandatory or not',
1264
  PRIMARY KEY (`code`),
1263
  PRIMARY KEY (`code`),
1265
  KEY `auth_val_cat_idx` (`authorised_value_category`),
1264
  KEY `auth_val_cat_idx` (`authorised_value_category`)
1266
  KEY `category_code` (`category_code`),
1267
  CONSTRAINT `borrower_attribute_types_ibfk_1` FOREIGN KEY (`category_code`) REFERENCES `categories` (`categorycode`)
1268
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1265
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1269
/*!40101 SET character_set_client = @saved_cs_client */;
1266
/*!40101 SET character_set_client = @saved_cs_client */;
1270
1267
Lines 1285-1290 CREATE TABLE `borrower_attribute_types_branches` ( Link Here
1285
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1282
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1286
/*!40101 SET character_set_client = @saved_cs_client */;
1283
/*!40101 SET character_set_client = @saved_cs_client */;
1287
1284
1285
--
1286
-- Table structure for table `borrower_attribute_types_categories`
1287
--
1288
1289
DROP TABLE IF EXISTS `borrower_attribute_types_categories`;
1290
/*!40101 SET @saved_cs_client     = @@character_set_client */;
1291
/*!40101 SET character_set_client = utf8 */;
1292
CREATE TABLE `borrower_attribute_types_categories` (
1293
  `borrower_attribute_type_code` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
1294
  `categorycode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
1295
  KEY `borrower_attribute_type_code` (`borrower_attribute_type_code`),
1296
  KEY `categorycode` (`categorycode`),
1297
  CONSTRAINT `borrower_attribute_types_categories_borrower_attribute_type_code` FOREIGN KEY (`borrower_attribute_type_code`) REFERENCES `borrower_attribute_types` (`code`) ON DELETE CASCADE ON UPDATE CASCADE,
1298
  CONSTRAINT `borrower_attribute_types_categories_categorycode` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE,
1299
  PRIMARY KEY (`borrower_attribute_type_code`, `categorycode`)
1300
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1301
/*!40101 SET character_set_client = @saved_cs_client */;
1302
1288
--
1303
--
1289
-- Table structure for table `borrower_attributes`
1304
-- Table structure for table `borrower_attributes`
1290
--
1305
--
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt (-5 / +20 lines)
Lines 240-252 Link Here
240
        </li>
240
        </li>
241
        <li>
241
        <li>
242
            <label for="category">Category: </label>
242
            <label for="category">Category: </label>
243
            <select name="category_code" id="category">
243
            <select name="category_code" id="category" multiple size="10">
244
                <option value=""></option>
244
                <option value="">All categories</option>
245
                [% FOREACH cat IN categories %]
245
                [% FOREACH category IN categories %]
246
                    [% IF ( cat.categorycode == attribute_type.category_code ) %]<option value="[% cat.categorycode | html %]" selected="selected">[% cat.description |html %]</option>[% ELSE %]<option value="[% cat.categorycode | html %]">[% cat.description |html %]</option>[% END %]
246
                    [% SET selected = 0 %]
247
                    [% IF attribute_type %]
248
                        [% FOREACH cat IN attribute_type.categories %]
249
                            [% IF cat.categorycode == category.categorycode %]
250
                                [% SET selected = 1 %]
251
                            [% END %]
252
                        [% END %]
253
                    [% END %]
254
                    [% IF selected %]
255
                        <option value="[% category.categorycode | html %]" selected>[% category.description |html %]</option>
256
                    [% ELSE %]
257
                        <option value="[% category.categorycode | html %]">[% category.description |html %]</option>
258
                    [% END %]
247
                [% END %]
259
                [% END %]
248
            </select>
260
            </select>
249
            <div class="hint">Choose one to limit this attribute to one patron type. Please leave blank if you want these attributes to be available for all types of patrons.</div>
261
            <div class="hint">Select "All categories" if this attribute type should always be displayed. Otherwise select categories you want to associate with this value.</div>
250
        </li>
262
        </li>
251
        <li>
263
        <li>
252
            <label for="class">Class: </label>
264
            <label for="class">Class: </label>
Lines 431-436 Link Here
431
            if ( $("#branches option:selected").length < 1 ) {
443
            if ( $("#branches option:selected").length < 1 ) {
432
                $("#branches option:first").attr("selected", "selected");
444
                $("#branches option:first").attr("selected", "selected");
433
            }
445
            }
446
            if ( $("#category option:selected").length < 1 ) {
447
                $("#category option:first").attr("selected", "selected");
448
            }
434
449
435
            $("#opac_display").change( function() {
450
            $("#opac_display").change( function() {
436
                if ( this.checked ) {
451
                if ( this.checked ) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-1 / +1 lines)
Lines 1659-1665 legend.collapsed i.fa.fa-caret-down::before { Link Here
1659
                                                        <h3 id="[% pa_loo.class | html %]_lgd">[% pa_loo.lib | html %]</h3>
1659
                                                        <h3 id="[% pa_loo.class | html %]_lgd">[% pa_loo.lib | html %]</h3>
1660
                                                    [% END %]
1660
                                                    [% END %]
1661
                                                    [% FOREACH patron_attribute IN pa_loo.items %]
1661
                                                    [% FOREACH patron_attribute IN pa_loo.items %]
1662
                                                        <li data-category_code="[% patron_attribute.category_code | html %]" data-pa_code="[% patron_attribute.code | replace('[^a-zA-Z0-9_-]', '') %]">
1662
                                                        <li data-category_code="[% patron_attribute.categorycodes.join(' ') | html %]" data-pa_code="[% patron_attribute.code | replace('[^a-zA-Z0-9_-]', '') %]">
1663
                                                            [% IF patron_attribute.mandatory %]
1663
                                                            [% IF patron_attribute.mandatory %]
1664
                                                                <label for="[% patron_attribute.form_id | html %]" class="required" required="required">[% patron_attribute.description | html %]: </label>
1664
                                                                <label for="[% patron_attribute.form_id | html %]" class="required" required="required">[% patron_attribute.description | html %]: </label>
1665
                                                            [% ELSE %]
1665
                                                            [% ELSE %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/borrowers_stats.tt (-1 / +1 lines)
Lines 249-255 Link Here
249
                    </tr>
249
                    </tr>
250
                [% END %]
250
                [% END %]
251
            [% FOREACH patron_attribute IN pa_loo.items %]
251
            [% FOREACH patron_attribute IN pa_loo.items %]
252
                <tr data-category_code="[% patron_attribute.category_code | html %]">
252
                <tr>
253
                    <td>
253
                    <td>
254
                        [% patron_attribute.code | html %]
254
                        [% patron_attribute.code | html %]
255
                        ([% patron_attribute.description | html %])
255
                        ([% patron_attribute.description | html %])
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt (-1 / +1 lines)
Lines 595-601 Link Here
595
            information_category_node.html("");
595
            information_category_node.html("");
596
596
597
            if ( category && category.length > 0 ) {
597
            if ( category && category.length > 0 ) {
598
                information_category_node.html(_("This attribute will be only applied to the patron's category %s").format(category));
598
                information_category_node.html(_("This attribute will be only applied to the following patron categories: %s").format(category));
599
            }
599
            }
600
            var disable_input_node = $(li_node).find("input:checkbox[name='disable_input']");
600
            var disable_input_node = $(li_node).find("input:checkbox[name='disable_input']");
601
            if ( type == 'select' ) {
601
            if ( type == 'select' ) {
(-)a/koha-tmpl/intranet-tmpl/prog/js/members.js (-1 / +1 lines)
Lines 73-79 function update_category_code(category_code) { Link Here
73
    }
73
    }
74
    var mytables = $(".attributes_table");
74
    var mytables = $(".attributes_table");
75
    $(mytables).find("li").hide();
75
    $(mytables).find("li").hide();
76
    $(mytables).find(" li[data-category_code='"+category_code+"']").show();
76
    $(mytables).find(" li[data-category_code~='"+category_code+"']").show();
77
    $(mytables).find(" li[data-category_code='']").show();
77
    $(mytables).find(" li[data-category_code='']").show();
78
78
79
    //Change password length hint
79
    //Change password length hint
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt (-1 / +1 lines)
Lines 994-1000 Link Here
994
                                                [% FOREACH pa_value IN pa.values %]
994
                                                [% FOREACH pa_value IN pa.values %]
995
                                                    [% IF loop.first %]<a id="patron-attr-start-[% pa.type.code | html %]"></a>[% END %]
995
                                                    [% IF loop.first %]<a id="patron-attr-start-[% pa.type.code | html %]"></a>[% END %]
996
                                                    [% form_id = 'patron-attr-' _ Math.int( Math.rand(1000000) ) %]
996
                                                    [% form_id = 'patron-attr-' _ Math.int( Math.rand(1000000) ) %]
997
                                                    <li data-category_code="[% pa.type.category_code | html %]">
997
                                                    <li>
998
                                                        [% IF pa.type.mandatory && pa.type.opac_editable %]
998
                                                        [% IF pa.type.mandatory && pa.type.opac_editable %]
999
                                                            <label for="[% form_id | html %]" class="required">[% pa.type.description | html %]: </label>
999
                                                            <label for="[% form_id | html %]" class="required">[% pa.type.description | html %]: </label>
1000
                                                        [% ELSE %]
1000
                                                        [% ELSE %]
(-)a/members/memberentry.pl (-1 / +1 lines)
Lines 950-956 sub patron_attributes_form { Link Here
950
            description       => $attr_type->description(),
950
            description       => $attr_type->description(),
951
            repeatable        => $attr_type->repeatable(),
951
            repeatable        => $attr_type->repeatable(),
952
            category          => $attr_type->authorised_value_category(),
952
            category          => $attr_type->authorised_value_category(),
953
            category_code     => $attr_type->category_code(),
953
            categorycodes     => [ map { $_->categorycode } $attr_type->categories->as_list ],
954
            mandatory         => $attr_type->mandatory(),
954
            mandatory         => $attr_type->mandatory(),
955
            is_date           => $attr_type->is_date(),
955
            is_date           => $attr_type->is_date(),
956
        };
956
        };
(-)a/reports/borrowers_stats.pl (-1 lines)
Lines 485-491 sub patron_attributes_form { Link Here
485
            description       => $attr_type->description(),
485
            description       => $attr_type->description(),
486
            repeatable        => $attr_type->repeatable(),
486
            repeatable        => $attr_type->repeatable(),
487
            category          => $attr_type->authorised_value_category(),
487
            category          => $attr_type->authorised_value_category(),
488
            category_code     => $attr_type->category_code(),
489
        };
488
        };
490
489
491
        my $newentry = { %$entry };
490
        my $newentry = { %$entry };
(-)a/t/db_dependent/Auth_with_ldap.t (-6 lines)
Lines 94-110 my $branchcode = $builder->build( { source => 'Branch' } )->{branchcode}; Link Here
94
my $attr_type    = $builder->build(
94
my $attr_type    = $builder->build(
95
    {
95
    {
96
        source => 'BorrowerAttributeType',
96
        source => 'BorrowerAttributeType',
97
        value  => {
98
            category_code => $categorycode
99
        }
100
    }
97
    }
101
);
98
);
102
my $attr_type2    = $builder->build(
99
my $attr_type2    = $builder->build(
103
    {
100
    {
104
        source => 'BorrowerAttributeType',
101
        source => 'BorrowerAttributeType',
105
        value  => {
106
            category_code => $categorycode
107
        }
108
    }
102
    }
109
);
103
);
110
104
(-)a/t/db_dependent/Koha/Patron/Attribute.t (-1 lines)
Lines 324-330 subtest 'store() tests' => sub { Link Here
324
                    repeatable    => 0,
324
                    repeatable    => 0,
325
                    unique_id     => 1,
325
                    unique_id     => 1,
326
                    is_date       => 0,
326
                    is_date       => 0,
327
                    category_code => undef
328
                }
327
                }
329
            }
328
            }
330
        );
329
        );
(-)a/t/db_dependent/Koha/Patron/Attribute/Type.t (+35 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
5
use Test::More;
6
use Koha::Database;
7
use t::lib::TestBuilder;
8
9
plan tests => 2;
10
11
my $schema  = Koha::Database->new->schema;
12
my $builder = t::lib::TestBuilder->new;
13
14
use_ok('Koha::Patron::Attribute::Type');
15
16
subtest 'categories' => sub {
17
    plan tests => 1;
18
19
    $schema->storage->txn_begin;
20
21
    my $category1 = $builder->build_object( { class => 'Koha::Patron::Categories' } );
22
    my $category2 = $builder->build_object( { class => 'Koha::Patron::Categories' } );
23
    Koha::Patron::Attribute::Types->delete();
24
    my $attribute_type = Koha::Patron::Attribute::Type->new({
25
        code => 'TEST',
26
        description => 'Test attribute type',
27
    });
28
    $attribute_type->store();
29
    $attribute_type->categories([ $category1, $category2 ]);
30
    $attribute_type->store();
31
    my @categories = $attribute_type->categories->as_list;
32
    is (scalar @categories, 2);
33
34
    $schema->storage->txn_rollback;
35
};
(-)a/t/db_dependent/Koha/Patron/Attribute/Types.t (-5 / +1 lines)
Lines 52-64 subtest 'new() tests' => sub { Link Here
52
    is( Koha::Patron::Attribute::Types->search()->count,
52
    is( Koha::Patron::Attribute::Types->search()->count,
53
        1, 'Only one object created' );
53
        1, 'Only one object created' );
54
54
55
    my $cateogory_code
55
    my $attribute_type_2 = Koha::Patron::Attribute::Type->new(
56
        = $builder->build( { source => 'Category' } )->{categorycode};
57
58
    my $attribute_type_with_category = Koha::Patron::Attribute::Type->new(
59
        {   code          => 'code_2',
56
        {   code          => 'code_2',
60
            description   => 'description',
57
            description   => 'description',
61
            category_code => $cateogory_code,
62
            repeatable    => 0
58
            repeatable    => 0
63
        }
59
        }
64
    )->store();
60
    )->store();
(-)a/t/db_dependent/api/v1/patrons.t (-2 lines)
Lines 638-644 subtest 'add() tests' => sub { Link Here
638
                        mandatory     => 0,
638
                        mandatory     => 0,
639
                        repeatable    => 1,
639
                        repeatable    => 1,
640
                        unique_id     => 0,
640
                        unique_id     => 0,
641
                        category_code => 'ST'
642
                    }
641
                    }
643
                }
642
                }
644
            );
643
            );
Lines 649-655 subtest 'add() tests' => sub { Link Here
649
                        mandatory     => 0,
648
                        mandatory     => 0,
650
                        repeatable    => 1,
649
                        repeatable    => 1,
651
                        unique_id     => 0,
650
                        unique_id     => 0,
652
                        category_code => 'ST'
653
                    }
651
                    }
654
                }
652
                }
655
            );
653
            );
(-)a/t/db_dependent/api/v1/patrons_extended_attributes.t (-9 lines)
Lines 116-122 subtest 'add() tests' => sub { Link Here
116
                mandatory     => 1,
116
                mandatory     => 1,
117
                repeatable    => 0,
117
                repeatable    => 0,
118
                unique_id     => 0,
118
                unique_id     => 0,
119
                category_code => undef
120
            }
119
            }
121
        }
120
        }
122
    );
121
    );
Lines 127-133 subtest 'add() tests' => sub { Link Here
127
                mandatory     => 0,
126
                mandatory     => 0,
128
                repeatable    => 1,
127
                repeatable    => 1,
129
                unique_id     => 0,
128
                unique_id     => 0,
130
                category_code => undef
131
            }
129
            }
132
        }
130
        }
133
    );
131
    );
Lines 138-144 subtest 'add() tests' => sub { Link Here
138
                mandatory     => 0,
136
                mandatory     => 0,
139
                repeatable    => 0,
137
                repeatable    => 0,
140
                unique_id     => 1,
138
                unique_id     => 1,
141
                category_code => undef
142
            }
139
            }
143
        }
140
        }
144
    );
141
    );
Lines 245-251 subtest 'overwrite() tests' => sub { Link Here
245
                mandatory     => 1,
242
                mandatory     => 1,
246
                repeatable    => 0,
243
                repeatable    => 0,
247
                unique_id     => 0,
244
                unique_id     => 0,
248
                category_code => undef
249
            }
245
            }
250
        }
246
        }
251
    );
247
    );
Lines 256-262 subtest 'overwrite() tests' => sub { Link Here
256
                mandatory     => 0,
252
                mandatory     => 0,
257
                repeatable    => 1,
253
                repeatable    => 1,
258
                unique_id     => 0,
254
                unique_id     => 0,
259
                category_code => undef
260
            }
255
            }
261
        }
256
        }
262
    );
257
    );
Lines 267-273 subtest 'overwrite() tests' => sub { Link Here
267
                mandatory     => 0,
262
                mandatory     => 0,
268
                repeatable    => 0,
263
                repeatable    => 0,
269
                unique_id     => 1,
264
                unique_id     => 1,
270
                category_code => undef
271
            }
265
            }
272
        }
266
        }
273
    );
267
    );
Lines 393-399 subtest 'delete() tests' => sub { Link Here
393
                mandatory     => 0,
387
                mandatory     => 0,
394
                repeatable    => 1,
388
                repeatable    => 1,
395
                unique_id     => 0,
389
                unique_id     => 0,
396
                category_code => undef
397
            }
390
            }
398
        }
391
        }
399
    );
392
    );
Lines 442-448 subtest 'update() tests' => sub { Link Here
442
                mandatory     => 0,
435
                mandatory     => 0,
443
                repeatable    => 1,
436
                repeatable    => 1,
444
                unique_id     => 0,
437
                unique_id     => 0,
445
                category_code => undef
446
            }
438
            }
447
        }
439
        }
448
    );
440
    );
Lines 453-459 subtest 'update() tests' => sub { Link Here
453
                mandatory     => 0,
445
                mandatory     => 0,
454
                repeatable    => 0,
446
                repeatable    => 0,
455
                unique_id     => 1,
447
                unique_id     => 1,
456
                category_code => undef
457
            }
448
            }
458
        }
449
        }
459
    );
450
    );
(-)a/tools/modborrowers.pl (-8 / +8 lines)
Lines 38-44 use Koha::Libraries; Link Here
38
use Koha::Patron::Categories;
38
use Koha::Patron::Categories;
39
use Koha::Patron::Debarments qw( AddDebarment DelDebarment );
39
use Koha::Patron::Debarments qw( AddDebarment DelDebarment );
40
use Koha::Patrons;
40
use Koha::Patrons;
41
use List::MoreUtils qw(uniq);
41
use List::MoreUtils qw(uniq none);
42
use Koha::Patron::Messages;
42
use Koha::Patron::Messages;
43
43
44
my $input = CGI->new;
44
my $input = CGI->new;
Lines 164-173 if ( $op eq 'cud-show' || $op eq 'show' ) { Link Here
164
            options        => $options,
164
            options        => $options,
165
            };
165
            };
166
166
167
        my $category_code = $attr_type->category_code;
167
        my @categories = $attr_type->categories->as_list;
168
        my ($category_lib) =
168
        my ( $category_lib ) = join(', ',  map { $_->description } @categories);
169
            map { ( defined $category_code and $attr_type->category_code eq $_->categorycode ) ? $_->description : () }
170
            @patron_categories;
171
        push @patron_attributes_codes,
169
        push @patron_attributes_codes,
172
            {
170
            {
173
            attribute_code => $attr_type->code,
171
            attribute_code => $attr_type->code,
Lines 433-440 if ( $op eq 'cud-do' ) { Link Here
433
431
434
            next unless $attr_type;
432
            next unless $attr_type;
435
433
436
            # If this borrower is not in the category of this attribute, we don't want to modify this attribute
434
            # If this borrower is not in one of the categories of this attribute, we don't want to modify this attribute
437
            next if $attr_type->category_code and $attr_type->category_code ne $patron->categorycode;
435
            my @attr_type_categories = $attr_type->categories->as_list;
436
            if (@attr_type_categories) {
437
                next if none { $patron->categorycode eq $_->categorycode } @attr_type_categories;
438
            }
438
439
439
            if ( $attributes->{$code}->{disabled} ) {
440
            if ( $attributes->{$code}->{disabled} ) {
440
441
441
- 

Return to bug 26573