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_type, 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_type     => $row->{'category_type'},
94
            class             => $row->{'class'},
93
        }
95
        }
94
    }
96
    }
95
    return \@results;
97
    return \@results;
(-)a/admin/patron-attr-types.pl (-2 / +39 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
        push @attributes_loop, {
273
            class => $class,
274
            items => \@items
275
        };
276
    }
277
    $template->param(available_attribute_types => \@attributes_loop);
248
    $template->param(display_list => 1);
278
    $template->param(display_list => 1);
249
}
279
}
250
280
Lines 261-263 sub authorised_value_category_list { Link Here
261
    }
291
    }
262
    $template->param(authorised_value_categories => \@list);
292
    $template->param(authorised_value_categories => \@list);
263
}
293
}
294
295
sub pa_classes {
296
    my $template = shift;
297
    my $selected = @_ ? shift : '';
298
299
    $template->param(classes_val_loop => GetAuthorisedValues( 'PA_CLASS', $selected ) );
300
}
(-)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_type` 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 (+10 lines)
Lines 4663-4668 ENDOFRENEWAL Link Here
4663
    print "Upgrade to $DBversion done (Added a system preference to allow renewal of Patron account either from todays date or from existing expiry date in the patrons account.)\n";
4663
    print "Upgrade to $DBversion done (Added a system preference to allow renewal of Patron account either from todays date or from existing expiry date in the patrons account.)\n";
4664
    SetVersion($DBversion);
4664
    SetVersion($DBversion);
4665
}
4665
}
4666
4667
$DBversion = "3.07.00.XXX";
4668
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4669
    $dbh->do("ALTER TABLE borrower_attribute_types ADD COLUMN category_code VARCHAR(10) NULL DEFAULT NULL AFTER `display_checkout`");
4670
    $dbh->do("ALTER TABLE borrower_attribute_types ADD COLUMN class VARCHAR(255)  NOT NULL DEFAULT '' AFTER `category_type`");
4671
    $dbh->do("ALTER TABLE borrower_attribute_types ADD CONSTRAINT category_code_fk FOREIGN KEY (category_code) REFERENCES categories(categorycode)");
4672
    print "Upgrade to $DBversion done (New fields category_type and class in borrower_attribute_types table)\n";
4673
    SetVersion($DBversion);
4674
}
4675
4666
=head1 FUNCTIONS
4676
=head1 FUNCTIONS
4667
4677
4668
=head2 DropAllForeignKeys($table)
4678
=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.class %]</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 (-65 / +107 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 984-1008 Link Here
984
        [% END %]
1014
        [% END %]
985
    <li>
1015
    <li>
986
        <label for="categorycode">Category: </label>
1016
        <label for="categorycode">Category: </label>
987
        <select id="categorycode" name="categorycode">
1017
        <select id="categorycode" name="categorycode" onchange="update_category_code(this);">
988
        [% FOREACH typeloo IN typeloop %]
1018
        [% FOREACH typeloo IN typeloop %]
989
			[% FOREACH categoryloo IN typeloo.categoryloop %]
1019
            [% FOREACH categoryloo IN typeloo.categoryloop %]
990
				[% IF ( loop.first ) %]
1020
                [% IF ( loop.first ) %]
991
					[% IF ( categoryloo.typename_C ) %]<optgroup label="Child">[% END %]
1021
                    [% IF ( categoryloo.typename_C ) %]<optgroup label="Child"        value="C">[% END %]
992
					[% IF ( categoryloo.typename_A ) %]<optgroup label="Adult">[% END %]
1022
                    [% IF ( categoryloo.typename_A ) %]<optgroup label="Adult"        value="A">[% END %]
993
					[% IF ( categoryloo.typename_S ) %]<optgroup label="Staff">[% END %]
1023
                    [% IF ( categoryloo.typename_S ) %]<optgroup label="Staff"        value="S">[% END %]
994
					[% IF ( categoryloo.typename_I ) %]<optgroup label="Organization">[% END %]
1024
                    [% IF ( categoryloo.typename_I ) %]<optgroup label="Organization" value="I">[% END %]
995
					[% IF ( categoryloo.typename_P ) %]<optgroup label="Professional">[% END %]
1025
                    [% IF ( categoryloo.typename_P ) %]<optgroup label="Professional" value="P">[% END %]
996
					[% IF ( categoryloo.typename_X ) %]<optgroup label="Statistical">[% END %]
1026
                    [% IF ( categoryloo.typename_X ) %]<optgroup label="Statistical"  value="X">[% END %]
997
			    [% END %]
1027
                [% END %]
998
				[% IF ( categoryloo.categorycodeselected ) %]
1028
                [% IF ( categoryloo.categorycodeselected ) %]
999
               <option value="[% categoryloo.categorycode %]" selected="selected">[% categoryloo.categoryname %]</option>
1029
                    <option value="[% categoryloo.categorycode %]" selected="selected" data-typename="[% typeloo.typename %]">[% categoryloo.categoryname %]</option>
1000
				[% ELSE %]
1030
                [% ELSE %]
1001
<option value="[% categoryloo.categorycode %]">[% categoryloo.categoryname %]</option>
1031
                    <option value="[% categoryloo.categorycode %]" data-typename="[% typeloo.typename %]">[% categoryloo.categoryname %]</option>
1002
				[% END %]
1032
                [% END %]
1003
				[% IF ( loop.last ) %]
1033
                [% IF ( loop.last ) %]
1004
			        </optgroup>
1034
                    </optgroup>
1005
				[% END %]
1035
                [% END %]
1006
            [% END %]
1036
            [% END %]
1007
       [% END %]
1037
       [% END %]
1008
       </select>
1038
       </select>
Lines 1281-1287 Link Here
1281
			       [% IF ( opduplicate ) %] 
1311
			       [% IF ( opduplicate ) %] 
1282
			           <textarea id="debarredcomment" name="debarredcomment" cols="55" rows="3" onclick="this.value=''">[% debarredcomment %]</textarea>
1312
			           <textarea id="debarredcomment" name="debarredcomment" cols="55" rows="3" onclick="this.value=''">[% debarredcomment %]</textarea>
1283
			       [% ELSE %]
1313
			       [% ELSE %]
1284
				   <textarea id="debarredcomment" name="debarredcomment" cols="55" rows="3" ">[% debarredcomment %]</textarea> 
1314
				   <textarea id="debarredcomment" name="debarredcomment" cols="55" rows="3" >[% debarredcomment %]</textarea>
1285
			       [% END %]
1315
			       [% END %]
1286
	        </li>
1316
	        </li>
1287
1317
Lines 1296-1350 Link Here
1296
  <fieldset class="rows" id="memberentry_patron_attributes">
1326
  <fieldset class="rows" id="memberentry_patron_attributes">
1297
    <input type="hidden" name="setting_extended_patron_attributes" value="1" />
1327
    <input type="hidden" name="setting_extended_patron_attributes" value="1" />
1298
    <legend>Additional attributes and identifiers</legend>
1328
    <legend>Additional attributes and identifiers</legend>
1299
    <table>
1329
    [% FOREACH pa_loo IN patron_attributes %]
1300
        <tr>
1330
        [% IF pa_loo.class %]
1301
            <th>Type</th>
1331
            <h4>[% pa_loo.class %]</h4>
1302
            <th colspan="2">Value</th>
1332
            <table id=aai_[% pa_loo.class %] class="attributes_table">
1303
        </tr>
1333
        [% ELSE %]
1304
        [% FOREACH patron_attribute IN patron_attributes %]
1334
            <table id="aai" class="attributes_table">
1305
        <tr>
1335
        [% END %]
1306
            <td>[% patron_attribute.code %] ([% patron_attribute.description %])
1336
        <thead>
1307
            </td>
1337
            <tr>
1308
            <td>
1338
                <th>Type</th>
1309
                <input type="hidden" id="[% patron_attribute.form_id %]_code" name="[% patron_attribute.form_id %]_code" value="[% patron_attribute.code |html %]" />
1339
                <th colspan="2">Value</th>
1310
                [% IF ( patron_attribute.use_dropdown ) %]
1340
            </tr>
1311
                    <select id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]">
1341
        </thead>
1312
                        <option value="" />
1342
        <tbody>
1313
                        [% FOREACH auth_val_loo IN patron_attribute.auth_val_loop %]
1343
            [% FOREACH patron_attribute IN pa_loo.items %]
1314
                            [% IF ( auth_val_loo.selected ) %]
1344
                <tr data-category_code="[% patron_attribute.category_code %]">
1315
                                <option value="[% auth_val_loo.authorised_value %]" selected="selected">
1345
                    <td>
1316
                                    [% auth_val_loo.lib %]
1346
                        [% patron_attribute.code %] ([% patron_attribute.description %])
1317
                                </option>
1347
                    </td>
1348
                    <td>
1349
                        <input type="hidden" id="[% patron_attribute.form_id %]_code" name="[% patron_attribute.form_id %]_code" value="[% patron_attribute.code |html %]" />
1350
                        [% IF ( patron_attribute.use_dropdown ) %]
1351
                            <select id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]">
1352
                                <option value="" />
1353
                                [% FOREACH auth_val_loo IN patron_attribute.auth_val_loop %]
1354
                                    [% IF ( auth_val_loo.selected ) %]
1355
                                        <option value="[% auth_val_loo.authorised_value %]" selected="selected">
1356
                                            [% auth_val_loo.lib %]
1357
                                        </option>
1358
                                    [% ELSE %]
1359
                                        <option value="[% auth_val_loo.authorised_value %]" >
1360
                                            [% auth_val_loo.lib %]
1361
                                        </option>
1362
                                    [% END %]
1363
                                [% END %]
1364
                            </select>
1365
                        [% ELSE %]
1366
                            [% IF ( opduplicate ) %]
1367
                            <input type="text" maxlength="64" value="[% patron_attribute.value %]"
1368
                                   id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]" onclick="this.value=''" />
1318
                            [% ELSE %]
1369
                            [% ELSE %]
1319
                                <option value="[% auth_val_loo.authorised_value %]" >
1370
                            <input type="text" maxlength="64" value="[% patron_attribute.value %]"
1320
                                    [% auth_val_loo.lib %]
1371
                                   id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]" />
1321
                                </option>
1322
                            [% END %]
1372
                            [% END %]
1323
                        [% END %]
1373
                        [% END %]
1324
                    </select>
1374
                        [% IF ( patron_attribute.password_allowed ) %]
1325
                [% ELSE %]
1375
                            (Password: <input type="password" maxlength="64" value="[% patron_attribute.password %]"
1326
                    [% IF ( opduplicate ) %]
1376
                                   id="[% patron_attribute.form_id %]_password" name="[% patron_attribute.form_id %]_password" />)
1327
                    <input type="text" maxlength="64" value="[% patron_attribute.value %]"
1377
                        [% END %]
1328
                           id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]" onclick="this.value=''" />
1378
                    </td>
1329
                    [% ELSE %]
1379
                    <td>
1330
                    <input type="text" maxlength="64" value="[% patron_attribute.value %]"
1380
                        <a href="#" onclick="clear_entry(this); return false;">Clear</a>
1331
                           id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]" />
1381
                        [% IF ( patron_attribute.repeatable ) %]
1332
                    [% END %]
1382
                        <a href="#" onclick="clone_entry(this); return false;">New</a>
1333
                [% END %]
1383
                        [% END %]
1334
                [% IF ( patron_attribute.password_allowed ) %]
1384
                    </td>
1335
                    (Password: <input type="password" maxlength="64" value="[% patron_attribute.password %]"
1385
                </tr>
1336
                           id="[% patron_attribute.form_id %]_password" name="[% patron_attribute.form_id %]_password" />)
1386
            [% END %]
1337
                [% END %]
1387
        </tbody>
1338
            </td>
1388
        </table>
1339
            <td>
1389
    [% END %]
1340
                <a href="#" onclick="clear_entry(this); return false;">Clear</a>
1341
                [% IF ( patron_attribute.repeatable ) %]
1342
                <a href="#" onclick="clone_entry(this); return false;">New</a>
1343
                [% END %]
1344
            </td>
1345
        </tr>
1346
        [% END %]
1347
    </table>
1348
  </fieldset>
1390
  </fieldset>
1349
[% END %][% END %][% END %]
1391
[% END %][% END %][% END %]
1350
1392
(-)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.class %]</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 414-419 if ($op eq 'add'){ Link Here
414
if ($op eq "modify")  {
415
if ($op eq "modify")  {
415
    $template->param( updtype => 'M',modify => 1 );
416
    $template->param( updtype => 'M',modify => 1 );
416
    $template->param( step_1=>1, step_2=>1, step_3=>1, step_4=>1, step_5 => 1, step_6 => 1) unless $step;
417
    $template->param( step_1=>1, step_2=>1, step_3=>1, step_4=>1, step_5 => 1, step_6 => 1) unless $step;
418
    if ( $step == 4 ) {
419
        $template->param( category_type => $borrower_data->{'categorycode'} );
420
    }
417
}
421
}
418
if ( $op eq "duplicate" ) {
422
if ( $op eq "duplicate" ) {
419
    $template->param( updtype => 'I' );
423
    $template->param( updtype => 'I' );
Lines 755-760 sub patron_attributes_form { Link Here
755
        return;
759
        return;
756
    }
760
    }
757
    my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
761
    my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
762
    my @classes = uniq( map {$_->{class}} @$attributes );
763
    @classes = sort @classes;
758
764
759
    # map patron's attributes into a more convenient structure
765
    # map patron's attributes into a more convenient structure
760
    my %attr_hash = ();
766
    my %attr_hash = ();
Lines 764-777 sub patron_attributes_form { Link Here
764
770
765
    my @attribute_loop = ();
771
    my @attribute_loop = ();
766
    my $i = 0;
772
    my $i = 0;
773
    my %items_by_class;
767
    foreach my $type_code (map { $_->{code} } @types) {
774
    foreach my $type_code (map { $_->{code} } @types) {
768
        my $attr_type = C4::Members::AttributeTypes->fetch($type_code);
775
        my $attr_type = C4::Members::AttributeTypes->fetch($type_code);
769
        my $entry = {
776
        my $entry = {
777
            class             => $attr_type->class(),
770
            code              => $attr_type->code(),
778
            code              => $attr_type->code(),
771
            description       => $attr_type->description(),
779
            description       => $attr_type->description(),
772
            repeatable        => $attr_type->repeatable(),
780
            repeatable        => $attr_type->repeatable(),
773
            password_allowed  => $attr_type->password_allowed(),
781
            password_allowed  => $attr_type->password_allowed(),
774
            category          => $attr_type->authorised_value_category(),
782
            category          => $attr_type->authorised_value_category(),
783
            category_code     => $attr_type->category_code(),
775
            password          => '',
784
            password          => '',
776
        };
785
        };
777
        if (exists $attr_hash{$attr_type->code()}) {
786
        if (exists $attr_hash{$attr_type->code()}) {
Lines 786-793 sub patron_attributes_form { Link Here
786
                }
795
                }
787
                $i++;
796
                $i++;
788
                $newentry->{form_id} = "patron_attr_$i";
797
                $newentry->{form_id} = "patron_attr_$i";
789
                #use Data::Dumper; die Dumper($entry) if  $entry->{use_dropdown};
798
                push @{$items_by_class{$attr_type->class()}}, $newentry;
790
                push @attribute_loop, $newentry;
791
            }
799
            }
792
        } else {
800
        } else {
793
            $i++;
801
            $i++;
Lines 797-805 sub patron_attributes_form { Link Here
797
                $newentry->{auth_val_loop} = GetAuthorisedValues($attr_type->authorised_value_category());
805
                $newentry->{auth_val_loop} = GetAuthorisedValues($attr_type->authorised_value_category());
798
            }
806
            }
799
            $newentry->{form_id} = "patron_attr_$i";
807
            $newentry->{form_id} = "patron_attr_$i";
800
            push @attribute_loop, $newentry;
808
            push @{$items_by_class{$attr_type->class()}}, $newentry;
809
        }
810
    }
811
    while ( my ($class, @items) = each %items_by_class ) {
812
        push @attribute_loop, {
813
            class => $class,
814
            items => @items
801
        }
815
        }
802
    }
816
    }
817
803
    $template->param(patron_attributes => \@attribute_loop);
818
    $template->param(patron_attributes => \@attribute_loop);
804
819
805
}
820
}
(-)a/members/moremember.pl (-4 / +18 lines)
Lines 252-258 my $issuecount = @{$issue}; Link Here
252
my $relissuecount  = @{$relissue};
252
my $relissuecount  = @{$relissue};
253
my $roaddetails = &GetRoadTypeDetails( $data->{'streettype'} );
253
my $roaddetails = &GetRoadTypeDetails( $data->{'streettype'} );
254
my $today       = POSIX::strftime("%Y-%m-%d", localtime);	# iso format
254
my $today       = POSIX::strftime("%Y-%m-%d", localtime);	# iso format
255
my @issuedata;
256
my @borrowers_with_issues;
255
my @borrowers_with_issues;
257
my $overdues_exist = 0;
256
my $overdues_exist = 0;
258
my $totalprice = 0;
257
my $totalprice = 0;
Lines 432-442 my $branch=C4::Context->userenv->{'branch'}; Link Here
432
$template->param(%$data);
431
$template->param(%$data);
433
432
434
if (C4::Context->preference('ExtendedPatronAttributes')) {
433
if (C4::Context->preference('ExtendedPatronAttributes')) {
435
    my $attributes = GetBorrowerAttributes($borrowernumber);
434
    my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
435
    my @classes = uniq( map {$_->{class}} @$attributes );
436
    @classes = sort @classes;
437
438
    my @attributes_loop;
439
    for my $class (@classes) {
440
        my @items;
441
        for my $attr (@$attributes) {
442
            push @items, $attr if $attr->{class} eq $class
443
        }
444
        push @attributes_loop, {
445
            class => $class,
446
            items => \@items
447
        };
448
    }
449
436
    $template->param(
450
    $template->param(
437
        ExtendedPatronAttributes => 1,
451
        ExtendedPatronAttributes => 1,
438
        extendedattributes => $attributes
452
        attributes_loop => \@attributes_loop
439
    );
453
    );
454
440
    my @types = C4::Members::AttributeTypes::GetAttributeTypes();
455
    my @types = C4::Members::AttributeTypes::GetAttributeTypes();
441
    if (scalar(@types) == 0) {
456
    if (scalar(@types) == 0) {
442
        $template->param(no_patron_attribute_types => 1);
457
        $template->param(no_patron_attribute_types => 1);
443
- 

Return to bug 7154