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

(-)a/C4/Members/AttributeTypes.pm (-13 / +37 lines)
Lines 120-126 sub new { Link Here
120
    $self->{'staff_searchable'} = 0;
120
    $self->{'staff_searchable'} = 0;
121
    $self->{'display_checkout'} = 0;
121
    $self->{'display_checkout'} = 0;
122
    $self->{'authorised_value_category'} = '';
122
    $self->{'authorised_value_category'} = '';
123
    $self->{'category_type'} = '';
123
    $self->{'category_code'} = '';
124
    $self->{'category_description'} = '';
124
    $self->{'class'} = '';
125
    $self->{'class'} = '';
125
126
126
    bless $self, $class;
127
    bless $self, $class;
Lines 142-152 sub fetch { Link Here
142
    my $self = {};
143
    my $self = {};
143
    my $dbh = C4::Context->dbh();
144
    my $dbh = C4::Context->dbh();
144
145
145
    my $sth = $dbh->prepare_cached("SELECT * FROM borrower_attribute_types WHERE code = ?");
146
    my $sth = $dbh->prepare_cached("
147
        SELECT borrower_attribute_types.*, categories.description AS category_description
148
        FROM borrower_attribute_types
149
        LEFT JOIN categories ON borrower_attribute_types.category_code=categories.categorycode
150
        WHERE code =?");
146
    $sth->execute($code);
151
    $sth->execute($code);
147
    my $row = $sth->fetchrow_hashref;
152
    my $row = $sth->fetchrow_hashref;
148
    $sth->finish();
153
    $sth->finish();
149
    return undef unless defined $row;    
154
    return undef unless defined $row;
150
155
151
    $self->{'code'}                      = $row->{'code'};
156
    $self->{'code'}                      = $row->{'code'};
152
    $self->{'description'}               = $row->{'description'};
157
    $self->{'description'}               = $row->{'description'};
Lines 157-163 sub fetch { Link Here
157
    $self->{'staff_searchable'}          = $row->{'staff_searchable'};
162
    $self->{'staff_searchable'}          = $row->{'staff_searchable'};
158
    $self->{'display_checkout'}          = $row->{'display_checkout'};
163
    $self->{'display_checkout'}          = $row->{'display_checkout'};
159
    $self->{'authorised_value_category'} = $row->{'authorised_value_category'};
164
    $self->{'authorised_value_category'} = $row->{'authorised_value_category'};
160
    $self->{'category_type'}             = $row->{'category_type'};
165
    $self->{'category_code'}             = $row->{'category_code'};
166
    $self->{'category_description'}      = $row->{'category_description'};
161
    $self->{'class'}                     = $row->{'class'};
167
    $self->{'class'}                     = $row->{'class'};
162
168
163
    bless $self, $class;
169
    bless $self, $class;
Lines 190-202 sub store { Link Here
190
                                         staff_searchable = ?,
196
                                         staff_searchable = ?,
191
                                         authorised_value_category = ?,
197
                                         authorised_value_category = ?,
192
                                         display_checkout = ?,
198
                                         display_checkout = ?,
193
                                         category_type = ?,
199
                                         category_code = ?,
194
                                         class = ?
200
                                         class = ?
195
                                     WHERE code = ?");
201
                                     WHERE code = ?");
196
    } else {
202
    } else {
197
        $sth = $dbh->prepare_cached("INSERT INTO borrower_attribute_types 
203
        $sth = $dbh->prepare_cached("INSERT INTO borrower_attribute_types 
198
                                        (description, repeatable, unique_id, opac_display, password_allowed,
204
                                        (description, repeatable, unique_id, opac_display, password_allowed,
199
                                         staff_searchable, authorised_value_category, display_checkout, category_type, class, code)
205
                                         staff_searchable, authorised_value_category, display_checkout, category_code, class, code)
200
                                        VALUES (?, ?, ?, ?, ?,
206
                                        VALUES (?, ?, ?, ?, ?,
201
                                                ?, ?, ?, ?, ?, ?)");
207
                                                ?, ?, ?, ?, ?, ?)");
202
    }
208
    }
Lines 208-214 sub store { Link Here
208
    $sth->bind_param(6, $self->{'staff_searchable'});
214
    $sth->bind_param(6, $self->{'staff_searchable'});
209
    $sth->bind_param(7, $self->{'authorised_value_category'});
215
    $sth->bind_param(7, $self->{'authorised_value_category'});
210
    $sth->bind_param(8, $self->{'display_checkout'});
216
    $sth->bind_param(8, $self->{'display_checkout'});
211
    $sth->bind_param(9, $self->{'category_type'});
217
    $sth->bind_param(9, $self->{'category_code'} || undef);
212
    $sth->bind_param(10, $self->{'class'});
218
    $sth->bind_param(10, $self->{'class'});
213
    $sth->bind_param(11, $self->{'code'});
219
    $sth->bind_param(11, $self->{'code'});
214
    $sth->execute;
220
    $sth->execute;
Lines 349-360 sub authorised_value_category { Link Here
349
    @_ ? $self->{'authorised_value_category'} = shift : $self->{'authorised_value_category'};
355
    @_ ? $self->{'authorised_value_category'} = shift : $self->{'authorised_value_category'};
350
}
356
}
351
357
352
=head2 category_type
358
=head2 category_code
353
359
354
=over 4
360
=over 4
355
361
356
my $category_type = $attr_type->category_type();
362
my $category_code = $attr_type->category_code();
357
$attr_type->category_type($category_type);
363
$attr_type->category_code($category_code);
358
364
359
=back
365
=back
360
366
Lines 362-377 Accessor. Link Here
362
368
363
=cut
369
=cut
364
370
365
sub category_type {
371
sub category_code {
366
    my $self = shift;
372
    my $self = shift;
367
    @_ ? $self->{'category_type'} = shift : $self->{'category_type'};
373
    @_ ? $self->{'category_code'} = shift : $self->{'category_code'};
374
}
375
376
=head2 category_description
377
378
=over 4
379
380
my $category_description = $attr_type->category_description();
381
$attr_type->category_description($category_description);
382
383
=back
384
385
Accessor.
386
387
=cut
388
389
sub category_description {
390
    my $self = shift;
391
    @_ ? $self->{'category_description'} = shift : $self->{'category_description'};
368
}
392
}
369
393
370
=head2 class
394
=head2 class
371
395
372
=over 4
396
=over 4
373
397
374
my $category_type = $attr_type->class();
398
my $class = $attr_type->class();
375
$attr_type->class($class);
399
$attr_type->class($class);
376
400
377
=back
401
=back
(-)a/admin/patron-attr-types.pl (-4 / +10 lines)
Lines 28-33 use C4::Auth; Link Here
28
use C4::Context;
28
use C4::Context;
29
use C4::Output;
29
use C4::Output;
30
use C4::Koha;
30
use C4::Koha;
31
use C4::Members qw/GetBorrowercategoryList/;
31
use C4::Members::AttributeTypes;
32
use C4::Members::AttributeTypes;
32
33
33
my $script_name = "/cgi-bin/koha/admin/patron-attr-types.pl";
34
my $script_name = "/cgi-bin/koha/admin/patron-attr-types.pl";
Lines 84-89 sub add_attribute_type_form { Link Here
84
    $template->param(
85
    $template->param(
85
        attribute_type_form => 1,
86
        attribute_type_form => 1,
86
        confirm_op => 'add_attribute_type_confirmed',
87
        confirm_op => 'add_attribute_type_confirmed',
88
        categories => GetBorrowercategoryList,
87
    );
89
    );
88
    authorised_value_category_list($template);
90
    authorised_value_category_list($template);
89
    pa_classes($template);
91
    pa_classes($template);
Lines 113-119 sub error_add_attribute_type_form { Link Here
113
        $template->param(display_checkout_checked => 'checked="checked"');
115
        $template->param(display_checkout_checked => 'checked="checked"');
114
    }
116
    }
115
117
116
    $template->param( category_type => $input->param('category_type') );
118
    $template->param( category_code => $input->param('category_code') );
117
    $template->param( class => $input->param('class') );
119
    $template->param( class => $input->param('class') );
118
120
119
    $template->param(
121
    $template->param(
Lines 158-164 sub add_update_attribute_type { Link Here
158
    $attr_type->password_allowed($password_allowed);
160
    $attr_type->password_allowed($password_allowed);
159
    my $display_checkout = $input->param('display_checkout');
161
    my $display_checkout = $input->param('display_checkout');
160
    $attr_type->display_checkout($display_checkout);
162
    $attr_type->display_checkout($display_checkout);
161
    $attr_type->category_type($input->param('category_type'));
163
    $attr_type->category_code($input->param('category_code'));
162
    $attr_type->class($input->param('class'));
164
    $attr_type->class($input->param('class'));
163
165
164
    if ($op eq 'edit') {
166
    if ($op eq 'edit') {
Lines 242-253 sub edit_attribute_type_form { Link Here
242
    authorised_value_category_list($template, $attr_type->authorised_value_category());
244
    authorised_value_category_list($template, $attr_type->authorised_value_category());
243
    pa_classes( $template, $attr_type->class );
245
    pa_classes( $template, $attr_type->class );
244
246
245
    $template->param ( category_type => $attr_type->category_type );
247
    $template->param ( category_code => $attr_type->category_code );
248
    $template->param ( category_description => $attr_type->category_description );
246
249
247
    $template->param(
250
    $template->param(
248
        attribute_type_form => 1,
251
        attribute_type_form => 1,
249
        edit_attribute_type => 1,
252
        edit_attribute_type => 1,
250
        confirm_op => 'edit_attribute_type_confirmed',
253
        confirm_op => 'edit_attribute_type_confirmed',
254
        categories => GetBorrowercategoryList,
251
    );
255
    );
252
256
253
}
257
}
Lines 256-262 sub patron_attribute_type_list { Link Here
256
    my $template = shift;
260
    my $template = shift;
257
261
258
    my @attr_types = C4::Members::AttributeTypes::GetAttributeTypes();
262
    my @attr_types = C4::Members::AttributeTypes::GetAttributeTypes();
259
    my @classes = sort uniq( map {$_->{class}} @attr_types );
263
    my @classes = uniq( map {$_->{class}} @attr_types );
264
    @classes = sort @classes;
265
260
    my @attributes_loop;
266
    my @attributes_loop;
261
    for my $class (@classes) {
267
    for my $class (@classes) {
262
        my @items;
268
        my @items;
(-)a/installer/data/mysql/updatedatabase.pl (-1 / +2 lines)
Lines 4587-4594 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
4587
4587
4588
$DBversion = "3.06.00.XXX";
4588
$DBversion = "3.06.00.XXX";
4589
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4589
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4590
    $dbh->do("ALTER TABLE borrower_attribute_types ADD COLUMN category_type VARCHAR(1)  NOT NULL DEFAULT '' AFTER `display_checkout`");
4590
    $dbh->do("ALTER TABLE borrower_attribute_types ADD COLUMN category_code VARCHAR(10) NULL DEFAULT NULL AFTER `display_checkout`");
4591
    $dbh->do("ALTER TABLE borrower_attribute_types ADD COLUMN class VARCHAR(255)  NOT NULL DEFAULT '' AFTER `category_type`");
4591
    $dbh->do("ALTER TABLE borrower_attribute_types ADD COLUMN class VARCHAR(255)  NOT NULL DEFAULT '' AFTER `category_type`");
4592
    $dbh->do("ALTER TABLE borrower_attribute_types ADD CONSTRAINT category_code_fk FOREIGN KEY (category_code) REFERENCES categories(categorycode)");
4592
    print "Upgrade to $DBversion done (New fields category_type and class in borrower_attribute_types table)\n";
4593
    print "Upgrade to $DBversion done (New fields category_type and class in borrower_attribute_types table)\n";
4593
    SetVersion($DBversion);
4594
    SetVersion($DBversion);
4594
}
4595
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt (-8 / +5 lines)
Lines 187-201 function CheckAttributeTypeForm(f) { Link Here
187
                  enforced during batch patron import.</span>
187
                  enforced during batch patron import.</span>
188
        </li>
188
        </li>
189
        <li>
189
        <li>
190
            <label for="category_type">Category type: </label>
190
            <label for="category">Category: </label>
191
            <select name="category_type" id="category_type">
191
            <select name="category_code" id="category">
192
                <option value=""></option>
192
                <option value=""></option>
193
                [% IF category_type == 'A' %]<option value="A" selected="selected">Adult</option>[% ELSE %]<option value="A">Adult</option>[% END %]
193
                [% FOREACH cat IN categories %]
194
                [% IF category_type == 'C' %]<option value="C" selected="selected">Child</option>[% ELSE %]<option value="C">Child</option>[% END %]
194
                    [% IF ( cat.categorycode == category_code ) %]<option value="[% cat.categorycode %]" selected="selected">[% cat.description %]</option>[% ELSE %]<option value="[% cat.categorycode %]">[% cat.description %]</option>[% END %]
195
                [% IF category_type == 'S' %]<option value="S" selected="selected">Staff</option>[% ELSE %]<option value="S">Staff</option>[% END %]
195
                [% END %]
196
                [% IF category_type == 'I' %]<option value="I" selected="selected">Organization</option>[% ELSE %]<option value="I">Organization</option>[% END %]
197
                [% IF category_type == 'P' %]<option value="P" selected="selected">Professional</option>[% ELSE %]<option value="P">Professional</option>[% END %]
198
                [% IF category_type == 'X' %]<option value="X" selected="selected">Statistical</option>[% ELSE %]<option value="X">Statistical</option>[% END %]
199
            </select>
196
            </select>
200
            <span>Please let blank if you want these attributs to be for all types of patron. Else, select one type.</span>
197
            <span>Please let blank if you want these attributs to be for all types of patron. Else, select one type.</span>
201
        </li>
198
        </li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-10 / +10 lines)
Lines 24-35 Link Here
24
            document.form.country.value=RegExp.$4;
24
            document.form.country.value=RegExp.$4;
25
        });
25
        });
26
26
27
        [% IF category_type %]
27
        [% IF categorycode %]
28
            update_category_code( "[% category_type %]" );
28
            update_category_code( "[% categorycode %]" );
29
        [% ELSE %]
29
        [% ELSE %]
30
            if ( $("#categorycode").length > 0 ){
30
            if ( $("#categorycode").length > 0 ){
31
                var category_type = $("#categorycode").find("option:selected").attr("data-typename");
31
                var category_code = $("#categorycode").find("option:selected").val();
32
                update_category_code( category_type );
32
                update_category_code( category_code );
33
            }
33
            }
34
        [% END %]
34
        [% END %]
35
35
Lines 62-70 Link Here
62
        original.parentNode.insertBefore(clone, original.nextSibling);
62
        original.parentNode.insertBefore(clone, original.nextSibling);
63
    }
63
    }
64
64
65
    function update_category_code(category_type) {
65
    function update_category_code(category_code) {
66
        if ( $(category_type).is("select") ) {
66
        if ( $(category_code).is("select") ) {
67
            category_type = $("#categorycode").find("option:selected").attr("data-typename");
67
            category_code = $("#categorycode").find("option:selected").val();
68
        }
68
        }
69
        var mytables = $(".attributes_table>tbody");
69
        var mytables = $(".attributes_table>tbody");
70
70
Lines 72-81 Link Here
72
            $(this).hide()
72
            $(this).hide()
73
        });
73
        });
74
74
75
        mytables.find("tr[data-category_type="+category_type+"]").each(function(){
75
        mytables.find("tr[data-category_code="+category_code+"]").each(function(){
76
            $(this).show();
76
            $(this).show();
77
        });
77
        });
78
        mytables.find("tr[data-category_type='']").each(function(){
78
        mytables.find("tr[data-category_code='']").each(function(){
79
            $(this).show();
79
            $(this).show();
80
        });
80
        });
81
81
Lines 1225-1231 Link Here
1225
        </thead>
1225
        </thead>
1226
        <tbody>
1226
        <tbody>
1227
            [% FOREACH patron_attribute IN pa_loo.items %]
1227
            [% FOREACH patron_attribute IN pa_loo.items %]
1228
                <tr data-category_type="[% patron_attribute.category_type %]">
1228
                <tr data-category_code="[% patron_attribute.category_code %]">
1229
                    <td>
1229
                    <td>
1230
                        [% patron_attribute.code %] ([% patron_attribute.description %])
1230
                        [% patron_attribute.code %] ([% patron_attribute.description %])
1231
                    </td>
1231
                    </td>
(-)a/members/memberentry.pl (-2 / +3 lines)
Lines 752-758 sub patron_attributes_form { Link Here
752
        return;
752
        return;
753
    }
753
    }
754
    my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
754
    my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
755
    my @classes = sort uniq( map {$_->{class}} @$attributes );
755
    my @classes = uniq( map {$_->{class}} @$attributes );
756
    @classes = sort @classes;
756
757
757
    # map patron's attributes into a more convenient structure
758
    # map patron's attributes into a more convenient structure
758
    my %attr_hash = ();
759
    my %attr_hash = ();
Lines 772-778 sub patron_attributes_form { Link Here
772
            repeatable        => $attr_type->repeatable(),
773
            repeatable        => $attr_type->repeatable(),
773
            password_allowed  => $attr_type->password_allowed(),
774
            password_allowed  => $attr_type->password_allowed(),
774
            category          => $attr_type->authorised_value_category(),
775
            category          => $attr_type->authorised_value_category(),
775
            category_type     => $attr_type->category_type(),
776
            category_code     => $attr_type->category_code(),
776
            password          => '',
777
            password          => '',
777
        };
778
        };
778
        if (exists $attr_hash{$attr_type->code()}) {
779
        if (exists $attr_hash{$attr_type->code()}) {
(-)a/members/moremember.pl (-2 / +3 lines)
Lines 432-438 $template->param(%$data); Link Here
432
432
433
if (C4::Context->preference('ExtendedPatronAttributes')) {
433
if (C4::Context->preference('ExtendedPatronAttributes')) {
434
    my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
434
    my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
435
    my @classes = sort uniq( map {$_->{class}} @$attributes );
435
    my @classes = uniq( map {$_->{class}} @$attributes );
436
    @classes = sort @classes;
437
436
    my @attributes_loop;
438
    my @attributes_loop;
437
    for my $class (@classes) {
439
    for my $class (@classes) {
438
        my @items;
440
        my @items;
439
- 

Return to bug 7154