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

(-)a/C4/Members/AttributeTypes.pm (-7 / +76 lines)
Lines 70-76 If $all_fields is true, then each hashref also contains the other fields from bo Link Here
70
70
71
sub GetAttributeTypes {
71
sub GetAttributeTypes {
72
    my ($all) = @_;
72
    my ($all) = @_;
73
    my $select = $all ? '*' : 'code, description';
73
    my $select = $all ? '*' : 'code, description, class';
74
    my $dbh = C4::Context->dbh;
74
    my $dbh = C4::Context->dbh;
75
    my $sth = $dbh->prepare("SELECT $select FROM borrower_attribute_types ORDER by code");
75
    my $sth = $dbh->prepare("SELECT $select FROM borrower_attribute_types ORDER by code");
76
    $sth->execute();
76
    $sth->execute();
Lines 120-125 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_code'} = '';
124
    $self->{'category_description'} = '';
125
    $self->{'class'} = '';
123
126
124
    bless $self, $class;
127
    bless $self, $class;
125
    return $self;
128
    return $self;
Lines 140-150 sub fetch { Link Here
140
    my $self = {};
143
    my $self = {};
141
    my $dbh = C4::Context->dbh();
144
    my $dbh = C4::Context->dbh();
142
145
143
    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 =?");
144
    $sth->execute($code);
151
    $sth->execute($code);
145
    my $row = $sth->fetchrow_hashref;
152
    my $row = $sth->fetchrow_hashref;
146
    $sth->finish();
153
    $sth->finish();
147
    return undef unless defined $row;    
154
    return undef unless defined $row;
148
155
149
    $self->{'code'}                      = $row->{'code'};
156
    $self->{'code'}                      = $row->{'code'};
150
    $self->{'description'}               = $row->{'description'};
157
    $self->{'description'}               = $row->{'description'};
Lines 155-160 sub fetch { Link Here
155
    $self->{'staff_searchable'}          = $row->{'staff_searchable'};
162
    $self->{'staff_searchable'}          = $row->{'staff_searchable'};
156
    $self->{'display_checkout'}          = $row->{'display_checkout'};
163
    $self->{'display_checkout'}          = $row->{'display_checkout'};
157
    $self->{'authorised_value_category'} = $row->{'authorised_value_category'};
164
    $self->{'authorised_value_category'} = $row->{'authorised_value_category'};
165
    $self->{'category_code'}             = $row->{'category_code'};
166
    $self->{'category_description'}      = $row->{'category_description'};
167
    $self->{'class'}                     = $row->{'class'};
158
168
159
    bless $self, $class;
169
    bless $self, $class;
160
    return $self;
170
    return $self;
Lines 185-198 sub store { Link Here
185
                                         password_allowed = ?,
195
                                         password_allowed = ?,
186
                                         staff_searchable = ?,
196
                                         staff_searchable = ?,
187
                                         authorised_value_category = ?,
197
                                         authorised_value_category = ?,
188
                                         display_checkout = ?
198
                                         display_checkout = ?,
199
                                         category_code = ?,
200
                                         class = ?
189
                                     WHERE code = ?");
201
                                     WHERE code = ?");
190
    } else {
202
    } else {
191
        $sth = $dbh->prepare_cached("INSERT INTO borrower_attribute_types 
203
        $sth = $dbh->prepare_cached("INSERT INTO borrower_attribute_types 
192
                                        (description, repeatable, unique_id, opac_display, password_allowed,
204
                                        (description, repeatable, unique_id, opac_display, password_allowed,
193
                                         staff_searchable, authorised_value_category, display_checkout, code)
205
                                         staff_searchable, authorised_value_category, display_checkout, category_code, class, code)
194
                                        VALUES (?, ?, ?, ?, ?,
206
                                        VALUES (?, ?, ?, ?, ?,
195
                                                ?, ?, ?, ?)");
207
                                                ?, ?, ?, ?, ?, ?)");
196
    }
208
    }
197
    $sth->bind_param(1, $self->{'description'});
209
    $sth->bind_param(1, $self->{'description'});
198
    $sth->bind_param(2, $self->{'repeatable'});
210
    $sth->bind_param(2, $self->{'repeatable'});
Lines 202-208 sub store { Link Here
202
    $sth->bind_param(6, $self->{'staff_searchable'});
214
    $sth->bind_param(6, $self->{'staff_searchable'});
203
    $sth->bind_param(7, $self->{'authorised_value_category'});
215
    $sth->bind_param(7, $self->{'authorised_value_category'});
204
    $sth->bind_param(8, $self->{'display_checkout'});
216
    $sth->bind_param(8, $self->{'display_checkout'});
205
    $sth->bind_param(9, $self->{'code'});
217
    $sth->bind_param(9, $self->{'category_code'} || undef);
218
    $sth->bind_param(10, $self->{'class'});
219
    $sth->bind_param(11, $self->{'code'});
206
    $sth->execute;
220
    $sth->execute;
207
221
208
}
222
}
Lines 341-346 sub authorised_value_category { Link Here
341
    @_ ? $self->{'authorised_value_category'} = shift : $self->{'authorised_value_category'};
355
    @_ ? $self->{'authorised_value_category'} = shift : $self->{'authorised_value_category'};
342
}
356
}
343
357
358
=head2 category_code
359
360
=over 4
361
362
my $category_code = $attr_type->category_code();
363
$attr_type->category_code($category_code);
364
365
=back
366
367
Accessor.
368
369
=cut
370
371
sub category_code {
372
    my $self = shift;
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'};
392
}
393
394
=head2 class
395
396
=over 4
397
398
my $class = $attr_type->class();
399
$attr_type->class($class);
400
401
=back
402
403
Accessor.
404
405
=cut
406
407
sub class {
408
    my $self = shift;
409
    @_ ? $self->{'class'} = shift : $self->{'class'};
410
}
411
412
344
=head2 delete
413
=head2 delete
345
414
346
  $attr_type->delete();
415
  $attr_type->delete();
(-)a/C4/Members/Attributes.pm (-1 / +3 lines)
Lines 72-78 sub GetBorrowerAttributes { Link Here
72
    my $opac_only = @_ ? shift : 0;
72
    my $opac_only = @_ ? shift : 0;
73
73
74
    my $dbh = C4::Context->dbh();
74
    my $dbh = C4::Context->dbh();
75
    my $query = "SELECT code, description, attribute, lib, password, display_checkout
75
    my $query = "SELECT code, description, attribute, lib, password, display_checkout, category_code, class
76
                 FROM borrower_attributes
76
                 FROM borrower_attributes
77
                 JOIN borrower_attribute_types USING (code)
77
                 JOIN borrower_attribute_types USING (code)
78
                 LEFT JOIN authorised_values ON (category = authorised_value_category AND attribute = authorised_value)
78
                 LEFT JOIN authorised_values ON (category = authorised_value_category AND attribute = authorised_value)
Lines 90-95 sub GetBorrowerAttributes { Link Here
90
            value_description => $row->{'lib'},  
90
            value_description => $row->{'lib'},  
91
            password          => $row->{'password'},
91
            password          => $row->{'password'},
92
            display_checkout  => $row->{'display_checkout'},
92
            display_checkout  => $row->{'display_checkout'},
93
            category_code     => $row->{'category_code'},
94
            class             => $row->{'class'},
93
        }
95
        }
94
    }
96
    }
95
    return \@results;
97
    return \@results;
(-)a/admin/patron-attr-types.pl (-2 / +41 lines)
Lines 22-31 Link Here
22
use strict;
22
use strict;
23
use warnings;
23
use warnings;
24
use CGI;
24
use CGI;
25
use List::MoreUtils qw/uniq/;
26
25
use C4::Auth;
27
use C4::Auth;
26
use C4::Context;
28
use C4::Context;
27
use C4::Output;
29
use C4::Output;
28
use C4::Koha;
30
use C4::Koha;
31
use C4::Members qw/GetBorrowercategoryList/;
29
use C4::Members::AttributeTypes;
32
use C4::Members::AttributeTypes;
30
33
31
my $script_name = "/cgi-bin/koha/admin/patron-attr-types.pl";
34
my $script_name = "/cgi-bin/koha/admin/patron-attr-types.pl";
Lines 82-89 sub add_attribute_type_form { Link Here
82
    $template->param(
85
    $template->param(
83
        attribute_type_form => 1,
86
        attribute_type_form => 1,
84
        confirm_op => 'add_attribute_type_confirmed',
87
        confirm_op => 'add_attribute_type_confirmed',
88
        categories => GetBorrowercategoryList,
85
    );
89
    );
86
    authorised_value_category_list($template);
90
    authorised_value_category_list($template);
91
    pa_classes($template);
87
}
92
}
88
93
89
sub error_add_attribute_type_form {
94
sub error_add_attribute_type_form {
Lines 110-115 sub error_add_attribute_type_form { Link Here
110
        $template->param(display_checkout_checked => 'checked="checked"');
115
        $template->param(display_checkout_checked => 'checked="checked"');
111
    }
116
    }
112
117
118
    $template->param( category_code => $input->param('category_code') );
119
    $template->param( class => $input->param('class') );
120
113
    $template->param(
121
    $template->param(
114
        attribute_type_form => 1,
122
        attribute_type_form => 1,
115
        confirm_op => 'add_attribute_type_confirmed',
123
        confirm_op => 'add_attribute_type_confirmed',
Lines 152-157 sub add_update_attribute_type { Link Here
152
    $attr_type->password_allowed($password_allowed);
160
    $attr_type->password_allowed($password_allowed);
153
    my $display_checkout = $input->param('display_checkout');
161
    my $display_checkout = $input->param('display_checkout');
154
    $attr_type->display_checkout($display_checkout);
162
    $attr_type->display_checkout($display_checkout);
163
    $attr_type->category_code($input->param('category_code'));
164
    $attr_type->class($input->param('class'));
155
165
156
    if ($op eq 'edit') {
166
    if ($op eq 'edit') {
157
        $template->param(edited_attribute_type => $attr_type->code());
167
        $template->param(edited_attribute_type => $attr_type->code());
Lines 209-214 sub edit_attribute_type_form { Link Here
209
219
210
    $template->param(code => $code);
220
    $template->param(code => $code);
211
    $template->param(description => $attr_type->description());
221
    $template->param(description => $attr_type->description());
222
    $template->param(class => $attr_type->class());
212
223
213
    if ($attr_type->repeatable()) {
224
    if ($attr_type->repeatable()) {
214
        $template->param(repeatable_checked => 1);
225
        $template->param(repeatable_checked => 1);
Lines 231-250 sub edit_attribute_type_form { Link Here
231
        $template->param(display_checkout_checked => 'checked="checked"');
242
        $template->param(display_checkout_checked => 'checked="checked"');
232
    }
243
    }
233
    authorised_value_category_list($template, $attr_type->authorised_value_category());
244
    authorised_value_category_list($template, $attr_type->authorised_value_category());
245
    pa_classes( $template, $attr_type->class );
246
247
    $template->param ( category_code => $attr_type->category_code );
248
    $template->param ( category_description => $attr_type->category_description );
234
249
235
    $template->param(
250
    $template->param(
236
        attribute_type_form => 1,
251
        attribute_type_form => 1,
237
        edit_attribute_type => 1,
252
        edit_attribute_type => 1,
238
        confirm_op => 'edit_attribute_type_confirmed',
253
        confirm_op => 'edit_attribute_type_confirmed',
254
        categories => GetBorrowercategoryList,
239
    );
255
    );
240
256
241
}
257
}
242
258
243
sub patron_attribute_type_list {
259
sub patron_attribute_type_list {
244
    my $template = shift;
260
    my $template = shift;
245
    
261
246
    my @attr_types = C4::Members::AttributeTypes::GetAttributeTypes();
262
    my @attr_types = C4::Members::AttributeTypes::GetAttributeTypes();
247
    $template->param(available_attribute_types => \@attr_types);
263
    my @classes = uniq( map {$_->{class}} @attr_types );
264
    @classes = sort @classes;
265
266
    my @attributes_loop;
267
    for my $class (@classes) {
268
        my @items;
269
        for my $attr (@attr_types) {
270
            push @items, $attr if $attr->{class} eq $class
271
        }
272
        my $lib = GetAuthorisedValueByCode( 'PA_CLASS', $class ) || $class;
273
        push @attributes_loop, {
274
            class => $class,
275
            items => \@items,
276
            lib   => $lib,
277
        };
278
    }
279
    $template->param(available_attribute_types => \@attributes_loop);
248
    $template->param(display_list => 1);
280
    $template->param(display_list => 1);
249
}
281
}
250
282
Lines 261-263 sub authorised_value_category_list { Link Here
261
    }
293
    }
262
    $template->param(authorised_value_categories => \@list);
294
    $template->param(authorised_value_categories => \@list);
263
}
295
}
296
297
sub pa_classes {
298
    my $template = shift;
299
    my $selected = @_ ? shift : '';
300
301
    $template->param(classes_val_loop => GetAuthorisedValues( 'PA_CLASS', $selected ) );
302
}
(-)a/installer/data/mysql/kohastructure.sql (+2 lines)
Lines 286-291 CREATE TABLE `borrower_attribute_types` ( -- definitions for custom patron field Link Here
286
  `staff_searchable` tinyint(1) NOT NULL default 0, -- defines if this field is searchable via the patron search in the staff client (1 for yes, 0 for no)
286
  `staff_searchable` tinyint(1) NOT NULL default 0, -- defines if this field is searchable via the patron search in the staff client (1 for yes, 0 for no)
287
  `authorised_value_category` varchar(10) default NULL, -- foreign key from authorised_values that links this custom field to an authorized value category
287
  `authorised_value_category` varchar(10) default NULL, -- foreign key from authorised_values that links this custom field to an authorized value category
288
  `display_checkout` tinyint(1) NOT NULL default 0,-- defines if this field displays in checkout screens
288
  `display_checkout` tinyint(1) NOT NULL default 0,-- defines if this field displays in checkout screens
289
  `category_code` VARCHAR(1) NOT NULL DEFAULT '',-- defines a category for an attribute_type
290
  `class` VARCHAR(255) NOT NULL DEFAULT '',-- defines a class for an attribute_type
289
  PRIMARY KEY  (`code`),
291
  PRIMARY KEY  (`code`),
290
  KEY `auth_val_cat_idx` (`authorised_value_category`)
292
  KEY `auth_val_cat_idx` (`authorised_value_category`)
291
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
293
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
(-)a/installer/data/mysql/updatedatabase.pl (+12 lines)
Lines 4944-4949 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
4944
}
4944
}
4945
4945
4946
4946
4947
4948
4949
4950
$DBversion = "3.07.00.XXX";
4951
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4952
    $dbh->do("ALTER TABLE borrower_attribute_types ADD COLUMN category_code VARCHAR(10) NULL DEFAULT NULL AFTER `display_checkout`");
4953
    $dbh->do("ALTER TABLE borrower_attribute_types ADD COLUMN class VARCHAR(255)  NOT NULL DEFAULT '' AFTER `category_code`");
4954
    $dbh->do("ALTER TABLE borrower_attribute_types ADD CONSTRAINT category_code_fk FOREIGN KEY (category_code) REFERENCES categories(categorycode)");
4955
    print "Upgrade to $DBversion done (New fields category_code and class in borrower_attribute_types table)\n";
4956
    SetVersion($DBversion);
4957
}
4958
4947
=head1 FUNCTIONS
4959
=head1 FUNCTIONS
4948
4960
4949
=head2 DropAllForeignKeys($table)
4961
=head2 DropAllForeignKeys($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt (-16 / +57 lines)
Lines 186-191 function CheckAttributeTypeForm(f) { Link Here
186
                  to be chosen from the authorized value list.  However, an authorized value list is not 
186
                  to be chosen from the authorized value list.  However, an authorized value list is not 
187
                  enforced during batch patron import.</span>
187
                  enforced during batch patron import.</span>
188
        </li>
188
        </li>
189
        <li>
190
            <label for="category">Category: </label>
191
            <select name="category_code" id="category">
192
                <option value=""></option>
193
                [% FOREACH cat IN categories %]
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
                [% END %]
196
            </select>
197
            <span>Please let blank if you want these attributs to be for all types of patron. Else, select one type.</span>
198
        </li>
199
        <li>
200
            <label for="class">Class: </label>
201
            <select name="class">
202
                <option value="" />
203
                [% FOREACH class IN classes_val_loop %]
204
                    [% IF ( class.selected ) %]
205
                        <option value="[% class.authorised_value %]" selected="selected">
206
                            [% class.lib %]
207
                        </option>
208
                    [% ELSE %]
209
                        <option value="[% class.authorised_value %]" >
210
                            [% class.lib %]
211
                        </option>
212
                    [% END %]
213
                [% END %]
214
            </select>
215
            <span>Group attributes types with a block title (based on Authorised values category 'PA_CLASS')</span>
216
        </li>
189
    </ol>
217
    </ol>
190
  </fieldset>
218
  </fieldset>
191
  <fieldset class="action">
219
  <fieldset class="action">
Lines 248-270 function CheckAttributeTypeForm(f) { Link Here
248
<div class="dialog message">Could not delete patron attribute type &quot;[% ERROR_delete_not_found %]&quot; 
276
<div class="dialog message">Could not delete patron attribute type &quot;[% ERROR_delete_not_found %]&quot; 
249
    &mdash; it was already absent from the database.</div>
277
    &mdash; it was already absent from the database.</div>
250
[% END %]
278
[% END %]
251
[% IF ( available_attribute_types ) %]<table>
279
[% IF ( available_attribute_types ) %]
252
  <tr>
280
  [% FOREACH attribute IN available_attribute_types %]
253
    <th>Code</th>
281
    [% IF attribute.class %]
254
    <th>Description</th>
282
        <h4>[% attribute.lib %]</h4>
255
    <th>Actions</th>
283
    [% END %]
256
  </tr>
284
    <table class="patron_attributes_types">
257
  [% FOREACH available_attribute_type IN available_attribute_types %]
285
      <thead>
258
  <tr>
286
        <tr>
259
    <td>[% available_attribute_type.code |html %]</td>
287
          <th>Code</th>
260
    <td>[% available_attribute_type.description %]</td>
288
          <th>Description</th>
261
    <td>
289
          <th>Actions</th>
262
      <a href="[% available_attribute_type.script_name %]?op=edit_attribute_type&amp;code=[% available_attribute_type.code |html %]">Edit</a>
290
        </tr>
263
      <a href="[% available_attribute_type.script_name %]?op=delete_attribute_type&amp;code=[% available_attribute_type.code |html %]">Delete</a>
291
      </thead>
264
    </td>
292
      <tbody>
265
  </tr>
293
        [% FOREACH item IN attribute.items %]
294
          <tr>
295
            <td>[% item.code |html %]</td>
296
            <td>[% item.description %]</td>
297
            <td>
298
              <a href="[% item.script_name %]?op=edit_attribute_type&amp;code=[% item.code |html %]">Edit</a>
299
              <a href="[% item.script_name %]?op=delete_attribute_type&amp;code=[% item.code |html %]">Delete</a>
300
            </td>
301
          </tr>
302
        [% END %]
303
      </tbody>
304
    </table>
266
  [% END %]
305
  [% END %]
267
</table>[% ELSE %]<p>There are no saved patron attribute types.</p>[% END %]
306
[% ELSE %]
307
  <p>There are no saved patron attribute types.</p>
308
[% END %]
268
309
269
<div class="pages">[% pagination_bar %]</div>
310
<div class="pages">[% pagination_bar %]</div>
270
311
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-64 / +106 lines)
Lines 23-28 Link Here
23
            document.form.state.value=RegExp.$3;
23
            document.form.state.value=RegExp.$3;
24
            document.form.country.value=RegExp.$4;
24
            document.form.country.value=RegExp.$4;
25
        });
25
        });
26
27
        [% IF categorycode %]
28
            update_category_code( "[% categorycode %]" );
29
        [% ELSE %]
30
            if ( $("#categorycode").length > 0 ){
31
                var category_code = $("#categorycode").find("option:selected").val();
32
                update_category_code( category_code );
33
            }
34
        [% END %]
35
26
    });
36
    });
27
37
28
    function clear_entry(node) {
38
    function clear_entry(node) {
Lines 51-56 Link Here
51
        $("select#patron_attr_" + newId, clone).attr('value','');
61
        $("select#patron_attr_" + newId, clone).attr('value','');
52
        original.parentNode.insertBefore(clone, original.nextSibling);
62
        original.parentNode.insertBefore(clone, original.nextSibling);
53
    }
63
    }
64
65
    function update_category_code(category_code) {
66
        if ( $(category_code).is("select") ) {
67
            category_code = $("#categorycode").find("option:selected").val();
68
        }
69
        var mytables = $(".attributes_table>tbody");
70
71
        mytables.find("tr").each(function(){
72
            $(this).hide()
73
        });
74
75
        mytables.find("tr[data-category_code="+category_code+"]").each(function(){
76
            $(this).show();
77
        });
78
        mytables.find("tr[data-category_code='']").each(function(){
79
            $(this).show();
80
        });
81
82
    }
83
54
		var MSG_SEPARATOR = _("Separator must be / in field ");
84
		var MSG_SEPARATOR = _("Separator must be / in field ");
55
        var MSG_INCORRECT_DAY = _("Invalid day entered in field ");
85
        var MSG_INCORRECT_DAY = _("Invalid day entered in field ");
56
        var MSG_INCORRECT_MONTH = _("Invalid month entered in field ");
86
        var MSG_INCORRECT_MONTH = _("Invalid month entered in field ");
Lines 999-1023 Link Here
999
        [% END %]
1029
        [% END %]
1000
    <li>
1030
    <li>
1001
        <label for="categorycode">Category: </label>
1031
        <label for="categorycode">Category: </label>
1002
        <select id="categorycode" name="categorycode">
1032
        <select id="categorycode" name="categorycode" onchange="update_category_code(this);">
1003
        [% FOREACH typeloo IN typeloop %]
1033
        [% FOREACH typeloo IN typeloop %]
1004
			[% FOREACH categoryloo IN typeloo.categoryloop %]
1034
            [% FOREACH categoryloo IN typeloo.categoryloop %]
1005
				[% IF ( loop.first ) %]
1035
                [% IF ( loop.first ) %]
1006
					[% IF ( typeloo.typename_C ) %]<optgroup label="Child">[% END %]
1036
                    [% IF ( typeloo.typename_C ) %]<optgroup label="Child"        value="C">[% END %]
1007
					[% IF ( typeloo.typename_A ) %]<optgroup label="Adult">[% END %]
1037
                    [% IF ( typeloo.typename_A ) %]<optgroup label="Adult"        value="A">[% END %]
1008
					[% IF ( typeloo.typename_S ) %]<optgroup label="Staff">[% END %]
1038
                    [% IF ( typeloo.typename_S ) %]<optgroup label="Staff"        value="S">[% END %]
1009
					[% IF ( typeloo.typename_I ) %]<optgroup label="Organization">[% END %]
1039
                    [% IF ( typeloo.typename_I ) %]<optgroup label="Organization" value="I">[% END %]
1010
					[% IF ( typeloo.typename_P ) %]<optgroup label="Professional">[% END %]
1040
                    [% IF ( typeloo.typename_P ) %]<optgroup label="Professional" value="P">[% END %]
1011
					[% IF ( typeloo.typename_X ) %]<optgroup label="Statistical">[% END %]
1041
                    [% IF ( typeloo.typename_X ) %]<optgroup label="Statistical"  value="X">[% END %]
1012
			    [% END %]
1042
                [% END %]
1013
				[% IF ( categoryloo.categorycodeselected ) %]
1043
                [% IF ( categoryloo.categorycodeselected ) %]
1014
               <option value="[% categoryloo.categorycode %]" selected="selected">[% categoryloo.categoryname %]</option>
1044
                    <option value="[% categoryloo.categorycode %]" selected="selected" data-typename="[% typeloo.typename %]">[% categoryloo.categoryname %]</option>
1015
				[% ELSE %]
1045
                [% ELSE %]
1016
<option value="[% categoryloo.categorycode %]">[% categoryloo.categoryname %]</option>
1046
                    <option value="[% categoryloo.categorycode %]" data-typename="[% typeloo.typename %]">[% categoryloo.categoryname %]</option>
1017
				[% END %]
1047
                [% END %]
1018
				[% IF ( loop.last ) %]
1048
                [% IF ( loop.last ) %]
1019
			        </optgroup>
1049
                    </optgroup>
1020
				[% END %]
1050
                [% END %]
1021
            [% END %]
1051
            [% END %]
1022
       [% END %]
1052
       [% END %]
1023
       </select>
1053
       </select>
Lines 1352-1406 Link Here
1352
  <fieldset class="rows" id="memberentry_patron_attributes">
1382
  <fieldset class="rows" id="memberentry_patron_attributes">
1353
    <input type="hidden" name="setting_extended_patron_attributes" value="1" />
1383
    <input type="hidden" name="setting_extended_patron_attributes" value="1" />
1354
    <legend>Additional attributes and identifiers</legend>
1384
    <legend>Additional attributes and identifiers</legend>
1355
    <table>
1385
    [% FOREACH pa_loo IN patron_attributes %]
1356
        <tr>
1386
        [% IF pa_loo.class %]
1357
            <th>Type</th>
1387
            <h4>[% pa_loo.class %]</h4>
1358
            <th colspan="2">Value</th>
1388
            <table id=aai_[% pa_loo.class %] class="attributes_table">
1359
        </tr>
1389
        [% ELSE %]
1360
        [% FOREACH patron_attribute IN patron_attributes %]
1390
            <table id="aai" class="attributes_table">
1361
        <tr>
1391
        [% END %]
1362
            <td>[% patron_attribute.code %] ([% patron_attribute.description %])
1392
        <thead>
1363
            </td>
1393
            <tr>
1364
            <td>
1394
                <th>Type</th>
1365
                <input type="hidden" id="[% patron_attribute.form_id %]_code" name="[% patron_attribute.form_id %]_code" value="[% patron_attribute.code |html %]" />
1395
                <th colspan="2">Value</th>
1366
                [% IF ( patron_attribute.use_dropdown ) %]
1396
            </tr>
1367
                    <select id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]">
1397
        </thead>
1368
                        <option value="" />
1398
        <tbody>
1369
                        [% FOREACH auth_val_loo IN patron_attribute.auth_val_loop %]
1399
            [% FOREACH patron_attribute IN pa_loo.items %]
1370
                            [% IF ( auth_val_loo.selected ) %]
1400
                <tr data-category_code="[% patron_attribute.category_code %]">
1371
                                <option value="[% auth_val_loo.authorised_value %]" selected="selected">
1401
                    <td>
1372
                                    [% auth_val_loo.lib %]
1402
                        [% patron_attribute.code %] ([% patron_attribute.description %])
1373
                                </option>
1403
                    </td>
1404
                    <td>
1405
                        <input type="hidden" id="[% patron_attribute.form_id %]_code" name="[% patron_attribute.form_id %]_code" value="[% patron_attribute.code |html %]" />
1406
                        [% IF ( patron_attribute.use_dropdown ) %]
1407
                            <select id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]">
1408
                                <option value="" />
1409
                                [% FOREACH auth_val_loo IN patron_attribute.auth_val_loop %]
1410
                                    [% IF ( auth_val_loo.selected ) %]
1411
                                        <option value="[% auth_val_loo.authorised_value %]" selected="selected">
1412
                                            [% auth_val_loo.lib %]
1413
                                        </option>
1414
                                    [% ELSE %]
1415
                                        <option value="[% auth_val_loo.authorised_value %]" >
1416
                                            [% auth_val_loo.lib %]
1417
                                        </option>
1418
                                    [% END %]
1419
                                [% END %]
1420
                            </select>
1421
                        [% ELSE %]
1422
                            [% IF ( opduplicate ) %]
1423
                            <input type="text" maxlength="64" value="[% patron_attribute.value %]"
1424
                                   id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]" onclick="this.value=''" />
1374
                            [% ELSE %]
1425
                            [% ELSE %]
1375
                                <option value="[% auth_val_loo.authorised_value %]" >
1426
                            <input type="text" maxlength="64" value="[% patron_attribute.value %]"
1376
                                    [% auth_val_loo.lib %]
1427
                                   id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]" />
1377
                                </option>
1378
                            [% END %]
1428
                            [% END %]
1379
                        [% END %]
1429
                        [% END %]
1380
                    </select>
1430
                        [% IF ( patron_attribute.password_allowed ) %]
1381
                [% ELSE %]
1431
                            (Password: <input type="password" maxlength="64" value="[% patron_attribute.password %]"
1382
                    [% IF ( opduplicate ) %]
1432
                                   id="[% patron_attribute.form_id %]_password" name="[% patron_attribute.form_id %]_password" />)
1383
                    <input type="text" maxlength="64" value="[% patron_attribute.value %]"
1433
                        [% END %]
1384
                           id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]" onclick="this.value=''" />
1434
                    </td>
1385
                    [% ELSE %]
1435
                    <td>
1386
                    <input type="text" maxlength="64" value="[% patron_attribute.value %]"
1436
                        <a href="#" onclick="clear_entry(this); return false;">Clear</a>
1387
                           id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]" />
1437
                        [% IF ( patron_attribute.repeatable ) %]
1388
                    [% END %]
1438
                        <a href="#" onclick="clone_entry(this); return false;">New</a>
1389
                [% END %]
1439
                        [% END %]
1390
                [% IF ( patron_attribute.password_allowed ) %]
1440
                    </td>
1391
                    (Password: <input type="password" maxlength="64" value="[% patron_attribute.password %]"
1441
                </tr>
1392
                           id="[% patron_attribute.form_id %]_password" name="[% patron_attribute.form_id %]_password" />)
1442
            [% END %]
1393
                [% END %]
1443
        </tbody>
1394
            </td>
1444
        </table>
1395
            <td>
1445
    [% END %]
1396
                <a href="#" onclick="clear_entry(this); return false;">Clear</a>
1397
                [% IF ( patron_attribute.repeatable ) %]
1398
                <a href="#" onclick="clone_entry(this); return false;">New</a>
1399
                [% END %]
1400
            </td>
1401
        </tr>
1402
        [% END %]
1403
    </table>
1404
  </fieldset>
1446
  </fieldset>
1405
[% END %][% END %][% END %]
1447
[% END %][% END %][% END %]
1406
1448
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (-15 / +28 lines)
Lines 285-306 function validate1(date) { Link Here
285
[% UNLESS ( no_patron_attribute_types ) %]
285
[% UNLESS ( no_patron_attribute_types ) %]
286
<div id="patron-extended-attributes" style="padding-top: 1em;">
286
<div id="patron-extended-attributes" style="padding-top: 1em;">
287
<h3>Additional attributes and identifiers</h3>
287
<h3>Additional attributes and identifiers</h3>
288
<table>
288
[% FOREACH attribute IN attributes_loop %]
289
    <tr>
289
    [% IF attribute.class %]
290
        <th>Type</th>
290
        <h4>[% attribute.lib %]</h4>
291
        <th>Value</th>
291
        <table id=aai_[% attribute.class %]>
292
    </tr>
292
    [% ELSE %]
293
    [% FOREACH extendedattribute IN extendedattributes %]
293
        <table id="aai">
294
    <tr>
295
        <td>[% extendedattribute.code %] ([% extendedattribute.description %])</td>
296
        <td>[% extendedattribute.value %]
297
            [% IF ( extendedattribute.value_description ) %]
298
                ([% extendedattribute.value_description %])
299
            [% END %]
300
        </td>
301
    </tr>
302
    [% END %]
294
    [% END %]
303
</table>
295
        <thead>
296
            <tr>
297
                <th>Type</th>
298
                <th>Description</th>
299
                <th>Value</th>
300
            </tr>
301
        </thead>
302
        <tbody>
303
        [% FOREACH item IN attribute.items %]
304
            <tr>
305
                <td>[% item.code %]</td>
306
                <td>[% item.description %]</td>
307
                <td>[% item.value %]
308
                    [% IF ( item.value_description ) %]
309
                        ([% item.value_description %])
310
                    [% END %]
311
                </td>
312
            </tr>
313
        [% END %]
314
        </tbody>
315
    </table>
316
[% END %]
304
</div>
317
</div>
305
<div class="action"><a href="memberentry.pl?op=modify&amp;borrowernumber=[% borrowernumber %]&amp;step=4">Edit</a></div>
318
<div class="action"><a href="memberentry.pl?op=modify&amp;borrowernumber=[% borrowernumber %]&amp;step=4">Edit</a></div>
306
[% END %]
319
[% END %]
(-)a/members/memberentry.pl (-3 / +18 lines)
Lines 25-30 use warnings; Link Here
25
# external modules
25
# external modules
26
use CGI;
26
use CGI;
27
# use Digest::MD5 qw(md5_base64);
27
# use Digest::MD5 qw(md5_base64);
28
use List::MoreUtils qw/uniq/;
28
29
29
# internal modules
30
# internal modules
30
use C4::Auth;
31
use C4::Auth;
Lines 423-428 if ($op eq 'add'){ Link Here
423
if ($op eq "modify")  {
424
if ($op eq "modify")  {
424
    $template->param( updtype => 'M',modify => 1 );
425
    $template->param( updtype => 'M',modify => 1 );
425
    $template->param( step_1=>1, step_2=>1, step_3=>1, step_4=>1, step_5 => 1, step_6 => 1) unless $step;
426
    $template->param( step_1=>1, step_2=>1, step_3=>1, step_4=>1, step_5 => 1, step_6 => 1) unless $step;
427
    if ( $step == 4 ) {
428
        $template->param( categorycode => $borrower_data->{'categorycode'} );
429
    }
426
}
430
}
427
if ( $op eq "duplicate" ) {
431
if ( $op eq "duplicate" ) {
428
    $template->param( updtype => 'I' );
432
    $template->param( updtype => 'I' );
Lines 764-769 sub patron_attributes_form { Link Here
764
        return;
768
        return;
765
    }
769
    }
766
    my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
770
    my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
771
    my @classes = uniq( map {$_->{class}} @$attributes );
772
    @classes = sort @classes;
767
773
768
    # map patron's attributes into a more convenient structure
774
    # map patron's attributes into a more convenient structure
769
    my %attr_hash = ();
775
    my %attr_hash = ();
Lines 773-786 sub patron_attributes_form { Link Here
773
779
774
    my @attribute_loop = ();
780
    my @attribute_loop = ();
775
    my $i = 0;
781
    my $i = 0;
782
    my %items_by_class;
776
    foreach my $type_code (map { $_->{code} } @types) {
783
    foreach my $type_code (map { $_->{code} } @types) {
777
        my $attr_type = C4::Members::AttributeTypes->fetch($type_code);
784
        my $attr_type = C4::Members::AttributeTypes->fetch($type_code);
778
        my $entry = {
785
        my $entry = {
786
            class             => $attr_type->class(),
779
            code              => $attr_type->code(),
787
            code              => $attr_type->code(),
780
            description       => $attr_type->description(),
788
            description       => $attr_type->description(),
781
            repeatable        => $attr_type->repeatable(),
789
            repeatable        => $attr_type->repeatable(),
782
            password_allowed  => $attr_type->password_allowed(),
790
            password_allowed  => $attr_type->password_allowed(),
783
            category          => $attr_type->authorised_value_category(),
791
            category          => $attr_type->authorised_value_category(),
792
            category_code     => $attr_type->category_code(),
784
            password          => '',
793
            password          => '',
785
        };
794
        };
786
        if (exists $attr_hash{$attr_type->code()}) {
795
        if (exists $attr_hash{$attr_type->code()}) {
Lines 795-802 sub patron_attributes_form { Link Here
795
                }
804
                }
796
                $i++;
805
                $i++;
797
                $newentry->{form_id} = "patron_attr_$i";
806
                $newentry->{form_id} = "patron_attr_$i";
798
                #use Data::Dumper; die Dumper($entry) if  $entry->{use_dropdown};
807
                push @{$items_by_class{$attr_type->class()}}, $newentry;
799
                push @attribute_loop, $newentry;
800
            }
808
            }
801
        } else {
809
        } else {
802
            $i++;
810
            $i++;
Lines 806-814 sub patron_attributes_form { Link Here
806
                $newentry->{auth_val_loop} = GetAuthorisedValues($attr_type->authorised_value_category());
814
                $newentry->{auth_val_loop} = GetAuthorisedValues($attr_type->authorised_value_category());
807
            }
815
            }
808
            $newentry->{form_id} = "patron_attr_$i";
816
            $newentry->{form_id} = "patron_attr_$i";
809
            push @attribute_loop, $newentry;
817
            push @{$items_by_class{$attr_type->class()}}, $newentry;
818
        }
819
    }
820
    while ( my ($class, @items) = each %items_by_class ) {
821
        push @attribute_loop, {
822
            class => $class,
823
            items => @items
810
        }
824
        }
811
    }
825
    }
826
812
    $template->param(patron_attributes => \@attribute_loop);
827
    $template->param(patron_attributes => \@attribute_loop);
813
828
814
}
829
}
(-)a/members/moremember.pl (-4 / +20 lines)
Lines 251-257 my $issuecount = @{$issue}; Link Here
251
my $relissuecount  = @{$relissue};
251
my $relissuecount  = @{$relissue};
252
my $roaddetails = &GetRoadTypeDetails( $data->{'streettype'} );
252
my $roaddetails = &GetRoadTypeDetails( $data->{'streettype'} );
253
my $today       = POSIX::strftime("%Y-%m-%d", localtime);	# iso format
253
my $today       = POSIX::strftime("%Y-%m-%d", localtime);	# iso format
254
my @issuedata;
255
my @borrowers_with_issues;
254
my @borrowers_with_issues;
256
my $overdues_exist = 0;
255
my $overdues_exist = 0;
257
my $totalprice = 0;
256
my $totalprice = 0;
Lines 431-441 my $branch=C4::Context->userenv->{'branch'}; Link Here
431
$template->param(%$data);
430
$template->param(%$data);
432
431
433
if (C4::Context->preference('ExtendedPatronAttributes')) {
432
if (C4::Context->preference('ExtendedPatronAttributes')) {
434
    my $attributes = GetBorrowerAttributes($borrowernumber);
433
    my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
434
    my @classes = uniq( map {$_->{class}} @$attributes );
435
    @classes = sort @classes;
436
437
    my @attributes_loop;
438
    for my $class (@classes) {
439
        my @items;
440
        for my $attr (@$attributes) {
441
            push @items, $attr if $attr->{class} eq $class
442
        }
443
        my $lib = GetAuthorisedValueByCode( 'PA_CLASS', $class ) || $class;
444
        push @attributes_loop, {
445
            class => $class,
446
            items => \@items,
447
            lib   => $lib,
448
        };
449
    }
450
435
    $template->param(
451
    $template->param(
436
        ExtendedPatronAttributes => 1,
452
        ExtendedPatronAttributes => 1,
437
        extendedattributes => $attributes
453
        attributes_loop => \@attributes_loop
438
    );
454
    );
455
439
    my @types = C4::Members::AttributeTypes::GetAttributeTypes();
456
    my @types = C4::Members::AttributeTypes::GetAttributeTypes();
440
    if (scalar(@types) == 0) {
457
    if (scalar(@types) == 0) {
441
        $template->param(no_patron_attribute_types => 1);
458
        $template->param(no_patron_attribute_types => 1);
442
- 

Return to bug 7154