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

(-)a/admin/patron-attr-types.pl (-3 / +25 lines)
Lines 22-27 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;
Lines 84-89 sub add_attribute_type_form { Link Here
84
        confirm_op => 'add_attribute_type_confirmed',
86
        confirm_op => 'add_attribute_type_confirmed',
85
    );
87
    );
86
    authorised_value_category_list($template);
88
    authorised_value_category_list($template);
89
    pa_classes($template);
87
}
90
}
88
91
89
sub error_add_attribute_type_form {
92
sub error_add_attribute_type_form {
Lines 237-245 sub edit_attribute_type_form { Link Here
237
        $template->param(display_checkout_checked => 'checked="checked"');
240
        $template->param(display_checkout_checked => 'checked="checked"');
238
    }
241
    }
239
    authorised_value_category_list($template, $attr_type->authorised_value_category());
242
    authorised_value_category_list($template, $attr_type->authorised_value_category());
243
    pa_classes( $template, $attr_type->class );
240
244
241
    $template->param ( category_type => $attr_type->category_type );
245
    $template->param ( category_type => $attr_type->category_type );
242
    $template->param ( class => $attr_type->class );
243
246
244
    $template->param(
247
    $template->param(
245
        attribute_type_form => 1,
248
        attribute_type_form => 1,
Lines 251-259 sub edit_attribute_type_form { Link Here
251
254
252
sub patron_attribute_type_list {
255
sub patron_attribute_type_list {
253
    my $template = shift;
256
    my $template = shift;
254
    
257
255
    my @attr_types = C4::Members::AttributeTypes::GetAttributeTypes();
258
    my @attr_types = C4::Members::AttributeTypes::GetAttributeTypes();
256
    $template->param(available_attribute_types => \@attr_types);
259
    my @classes = sort uniq( map {$_->{class}} @attr_types );
260
    my @attributes_loop;
261
    for my $class (@classes) {
262
        my @items;
263
        for my $attr (@attr_types) {
264
            push @items, $attr if $attr->{class} eq $class
265
        }
266
        push @attributes_loop, {
267
            class => $class,
268
            items => \@items
269
        };
270
    }
271
    $template->param(available_attribute_types => \@attributes_loop);
257
    $template->param(display_list => 1);
272
    $template->param(display_list => 1);
258
}
273
}
259
274
Lines 270-272 sub authorised_value_category_list { Link Here
270
    }
285
    }
271
    $template->param(authorised_value_categories => \@list);
286
    $template->param(authorised_value_categories => \@list);
272
}
287
}
288
289
sub pa_classes {
290
    my $template = shift;
291
    my $selected = @_ ? shift : '';
292
293
    $template->param(classes_val_loop => GetAuthorisedValues( 'PA_CLASS', $selected ) );
294
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt (-23 / +39 lines)
Lines 201-208 function CheckAttributeTypeForm(f) { Link Here
201
        </li>
201
        </li>
202
        <li>
202
        <li>
203
            <label for="class">Class: </label>
203
            <label for="class">Class: </label>
204
            <input type="text" id="class" name="class"  size="20" value="[% class | html %]"/>
204
            <select name="class">
205
            <span>Group attributes types with a block title</span>
205
                <option value="" />
206
                [% FOREACH class IN classes_val_loop %]
207
                    [% IF ( class.selected ) %]
208
                        <option value="[% class.authorised_value %]" selected="selected">
209
                            [% class.lib %]
210
                        </option>
211
                    [% ELSE %]
212
                        <option value="[% class.authorised_value %]" >
213
                            [% class.lib %]
214
                        </option>
215
                    [% END %]
216
                [% END %]
217
            </select>
218
            <span>Group attributes types with a block title (based on Authorised values category 'PA_CLASS')</span>
206
        </li>
219
        </li>
207
    </ol>
220
    </ol>
208
  </fieldset>
221
  </fieldset>
Lines 267-295 function CheckAttributeTypeForm(f) { Link Here
267
    &mdash; it was already absent from the database.</div>
280
    &mdash; it was already absent from the database.</div>
268
[% END %]
281
[% END %]
269
[% IF ( available_attribute_types ) %]
282
[% IF ( available_attribute_types ) %]
270
  <table id="patron_attributes_types">
283
  [% FOREACH attribute IN available_attribute_types %]
271
    <thead>
284
    [% IF attribute.class %]
272
      <tr>
285
        <h4>[% attribute.class %]</h4>
273
        <th>Class</th>
286
    [% END %]
274
        <th>Code</th>
287
    <table class="patron_attributes_types">
275
        <th>Description</th>
288
      <thead>
276
        <th>Actions</th>
277
      </tr>
278
    </thead>
279
    <tbody>
280
      [% FOREACH available_attribute_type IN available_attribute_types %]
281
        <tr>
289
        <tr>
282
          <td>[% available_attribute_type.class |html %]</td>
290
          <th>Code</th>
283
          <td>[% available_attribute_type.code |html %]</td>
291
          <th>Description</th>
284
          <td>[% available_attribute_type.description %]</td>
292
          <th>Actions</th>
285
          <td>
286
            <a href="[% available_attribute_type.script_name %]?op=edit_attribute_type&amp;code=[% available_attribute_type.code |html %]">Edit</a>
287
            <a href="[% available_attribute_type.script_name %]?op=delete_attribute_type&amp;code=[% available_attribute_type.code |html %]">Delete</a>
288
          </td>
289
        </tr>
293
        </tr>
290
      [% END %]
294
      </thead>
291
    </tbody>
295
      <tbody>
292
  </table>
296
        [% FOREACH item IN attribute.items %]
297
          <tr>
298
            <td>[% item.code |html %]</td>
299
            <td>[% item.description %]</td>
300
            <td>
301
              <a href="[% item.script_name %]?op=edit_attribute_type&amp;code=[% item.code |html %]">Edit</a>
302
              <a href="[% item.script_name %]?op=delete_attribute_type&amp;code=[% item.code |html %]">Delete</a>
303
            </td>
304
          </tr>
305
        [% END %]
306
      </tbody>
307
    </table>
308
  [% END %]
293
[% ELSE %]
309
[% ELSE %]
294
  <p>There are no saved patron attribute types.</p>
310
  <p>There are no saved patron attribute types.</p>
295
[% END %]
311
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-50 / +58 lines)
Lines 63-78 Link Here
63
    }
63
    }
64
64
65
    function update_category_code(category_type) {
65
    function update_category_code(category_type) {
66
        var mytable = $("#attributes_table>tbody");
66
        if ( $(category_type).is("select") ) {
67
            category_type = $("#categorycode").find("option:selected").attr("data-typename");
68
        }
69
        var mytables = $(".attributes_table>tbody");
67
70
68
        mytable.find("tr").each(function(){
71
        mytables.find("tr").each(function(){
69
            $(this).hide()
72
            $(this).hide()
70
        });
73
        });
71
74
72
        mytable.find("tr[data-category_type="+category_type+"]").each(function(){
75
        mytables.find("tr[data-category_type="+category_type+"]").each(function(){
73
            $(this).show();
76
            $(this).show();
74
        });
77
        });
75
        mytable.find("tr[data-category_type='']").each(function(){
78
        mytables.find("tr[data-category_type='']").each(function(){
76
            $(this).show();
79
            $(this).show();
77
        });
80
        });
78
81
Lines 1192-1198 Link Here
1192
			       [% IF ( opduplicate ) %] 
1195
			       [% IF ( opduplicate ) %] 
1193
			           <textarea id="debarredcomment" name="debarredcomment" cols="55" rows="3" onclick="this.value=''">[% debarredcomment %]</textarea>
1196
			           <textarea id="debarredcomment" name="debarredcomment" cols="55" rows="3" onclick="this.value=''">[% debarredcomment %]</textarea>
1194
			       [% ELSE %]
1197
			       [% ELSE %]
1195
				   <textarea id="debarredcomment" name="debarredcomment" cols="55" rows="3" ">[% debarredcomment %]</textarea> 
1198
				   <textarea id="debarredcomment" name="debarredcomment" cols="55" rows="3" >[% debarredcomment %]</textarea>
1196
			       [% END %]
1199
			       [% END %]
1197
	        </li>
1200
	        </li>
1198
1201
Lines 1207-1268 Link Here
1207
  <fieldset class="rows" id="memberentry_patron_attributes">
1210
  <fieldset class="rows" id="memberentry_patron_attributes">
1208
    <input type="hidden" name="setting_extended_patron_attributes" value="1" />
1211
    <input type="hidden" name="setting_extended_patron_attributes" value="1" />
1209
    <legend>Additional attributes and identifiers</legend>
1212
    <legend>Additional attributes and identifiers</legend>
1210
    <table id="attributes_table">
1213
    [% FOREACH pa_loo IN patron_attributes %]
1214
        [% IF pa_loo.class %]
1215
            <h4>[% pa_loo.class %]</h4>
1216
            <table id=aai_[% pa_loo.class %] class="attributes_table">
1217
        [% ELSE %]
1218
            <table id="aai" class="attributes_table">
1219
        [% END %]
1211
        <thead>
1220
        <thead>
1212
            <tr>
1221
            <tr>
1213
                <th>Class</th>
1214
                <th>Type</th>
1222
                <th>Type</th>
1215
                <th colspan="2">Value</th>
1223
                <th colspan="2">Value</th>
1216
            </tr>
1224
            </tr>
1217
        </thead>
1225
        </thead>
1218
        <tbody>
1226
        <tbody>
1219
        [% FOREACH patron_attribute IN patron_attributes %]
1227
            [% FOREACH patron_attribute IN pa_loo.items %]
1220
        <tr data-category_type="[% patron_attribute.category_type %]">
1228
                <tr data-category_type="[% patron_attribute.category_type %]">
1221
            <td>[% patron_attribute.class %]</td>
1229
                    <td>
1222
            <td>
1230
                        [% patron_attribute.code %] ([% patron_attribute.description %])
1223
                [% patron_attribute.code %] ([% patron_attribute.description %])
1231
                    </td>
1224
            </td>
1232
                    <td>
1225
            <td>
1233
                        <input type="hidden" id="[% patron_attribute.form_id %]_code" name="[% patron_attribute.form_id %]_code" value="[% patron_attribute.code |html %]" />
1226
                <input type="hidden" id="[% patron_attribute.form_id %]_code" name="[% patron_attribute.form_id %]_code" value="[% patron_attribute.code |html %]" />
1234
                        [% IF ( patron_attribute.use_dropdown ) %]
1227
                [% IF ( patron_attribute.use_dropdown ) %]
1235
                            <select id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]">
1228
                    <select id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]">
1236
                                <option value="" />
1229
                        <option value="" />
1237
                                [% FOREACH auth_val_loo IN patron_attribute.auth_val_loop %]
1230
                        [% FOREACH auth_val_loo IN patron_attribute.auth_val_loop %]
1238
                                    [% IF ( auth_val_loo.selected ) %]
1231
                            [% IF ( auth_val_loo.selected ) %]
1239
                                        <option value="[% auth_val_loo.authorised_value %]" selected="selected">
1232
                                <option value="[% auth_val_loo.authorised_value %]" selected="selected">
1240
                                            [% auth_val_loo.lib %]
1233
                                    [% auth_val_loo.lib %]
1241
                                        </option>
1234
                                </option>
1242
                                    [% ELSE %]
1243
                                        <option value="[% auth_val_loo.authorised_value %]" >
1244
                                            [% auth_val_loo.lib %]
1245
                                        </option>
1246
                                    [% END %]
1247
                                [% END %]
1248
                            </select>
1249
                        [% ELSE %]
1250
                            [% IF ( opduplicate ) %]
1251
                            <input type="text" maxlength="64" value="[% patron_attribute.value %]"
1252
                                   id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]" onclick="this.value=''" />
1235
                            [% ELSE %]
1253
                            [% ELSE %]
1236
                                <option value="[% auth_val_loo.authorised_value %]" >
1254
                            <input type="text" maxlength="64" value="[% patron_attribute.value %]"
1237
                                    [% auth_val_loo.lib %]
1255
                                   id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]" />
1238
                                </option>
1239
                            [% END %]
1256
                            [% END %]
1240
                        [% END %]
1257
                        [% END %]
1241
                    </select>
1258
                        [% IF ( patron_attribute.password_allowed ) %]
1242
                [% ELSE %]
1259
                            (Password: <input type="password" maxlength="64" value="[% patron_attribute.password %]"
1243
                    [% IF ( opduplicate ) %]
1260
                                   id="[% patron_attribute.form_id %]_password" name="[% patron_attribute.form_id %]_password" />)
1244
                    <input type="text" maxlength="64" value="[% patron_attribute.value %]"
1261
                        [% END %]
1245
                           id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]" onclick="this.value=''" />
1262
                    </td>
1246
                    [% ELSE %]
1263
                    <td>
1247
                    <input type="text" maxlength="64" value="[% patron_attribute.value %]"
1264
                        <a href="#" onclick="clear_entry(this); return false;">Clear</a>
1248
                           id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]" />
1265
                        [% IF ( patron_attribute.repeatable ) %]
1249
                    [% END %]
1266
                        <a href="#" onclick="clone_entry(this); return false;">New</a>
1250
                [% END %]
1267
                        [% END %]
1251
                [% IF ( patron_attribute.password_allowed ) %]
1268
                    </td>
1252
                    (Password: <input type="password" maxlength="64" value="[% patron_attribute.password %]"
1269
                </tr>
1253
                           id="[% patron_attribute.form_id %]_password" name="[% patron_attribute.form_id %]_password" />)
1270
            [% END %]
1254
                [% END %]
1255
            </td>
1256
            <td>
1257
                <a href="#" onclick="clear_entry(this); return false;">Clear</a>
1258
                [% IF ( patron_attribute.repeatable ) %]
1259
                <a href="#" onclick="clone_entry(this); return false;">New</a>
1260
                [% END %]
1261
            </td>
1262
        </tr>
1263
        [% END %]
1264
        </tbody>
1271
        </tbody>
1265
    </table>
1272
        </table>
1273
    [% END %]
1266
  </fieldset>
1274
  </fieldset>
1267
[% END %][% END %][% END %]
1275
[% END %][% END %][% END %]
1268
1276
(-)a/members/memberentry.pl (-4 / +13 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 407-413 if ($op eq 'add'){ Link Here
407
if ($op eq "modify")  {
408
if ($op eq "modify")  {
408
    $template->param( updtype => 'M',modify => 1 );
409
    $template->param( updtype => 'M',modify => 1 );
409
    $template->param( step_1=>1, step_2=>1, step_3=>1, step_4=>1, step_5 => 1, step_6 => 1) unless $step;
410
    $template->param( step_1=>1, step_2=>1, step_3=>1, step_4=>1, step_5 => 1, step_6 => 1) unless $step;
410
    if ( $step = 4 ) {
411
    if ( $step == 4 ) {
411
        $template->param( category_type => $borrower_data->{'categorycode'} );
412
        $template->param( category_type => $borrower_data->{'categorycode'} );
412
    }
413
    }
413
}
414
}
Lines 751-756 sub patron_attributes_form { Link Here
751
        return;
752
        return;
752
    }
753
    }
753
    my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
754
    my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
755
    my @classes = sort uniq( map {$_->{class}} @$attributes );
754
756
755
    # map patron's attributes into a more convenient structure
757
    # map patron's attributes into a more convenient structure
756
    my %attr_hash = ();
758
    my %attr_hash = ();
Lines 760-765 sub patron_attributes_form { Link Here
760
762
761
    my @attribute_loop = ();
763
    my @attribute_loop = ();
762
    my $i = 0;
764
    my $i = 0;
765
    my %items_by_class;
763
    foreach my $type_code (map { $_->{code} } @types) {
766
    foreach my $type_code (map { $_->{code} } @types) {
764
        my $attr_type = C4::Members::AttributeTypes->fetch($type_code);
767
        my $attr_type = C4::Members::AttributeTypes->fetch($type_code);
765
        my $entry = {
768
        my $entry = {
Lines 784-791 sub patron_attributes_form { Link Here
784
                }
787
                }
785
                $i++;
788
                $i++;
786
                $newentry->{form_id} = "patron_attr_$i";
789
                $newentry->{form_id} = "patron_attr_$i";
787
                #use Data::Dumper; die Dumper($entry) if  $entry->{use_dropdown};
790
                push @{$items_by_class{$attr_type->class()}}, $newentry;
788
                push @attribute_loop, $newentry;
789
            }
791
            }
790
        } else {
792
        } else {
791
            $i++;
793
            $i++;
Lines 795-803 sub patron_attributes_form { Link Here
795
                $newentry->{auth_val_loop} = GetAuthorisedValues($attr_type->authorised_value_category());
797
                $newentry->{auth_val_loop} = GetAuthorisedValues($attr_type->authorised_value_category());
796
            }
798
            }
797
            $newentry->{form_id} = "patron_attr_$i";
799
            $newentry->{form_id} = "patron_attr_$i";
798
            push @attribute_loop, $newentry;
800
            push @{$items_by_class{$attr_type->class()}}, $newentry;
799
        }
801
        }
800
    }
802
    }
803
    while ( my ($class, @items) = each %items_by_class ) {
804
        push @attribute_loop, {
805
            class => $class,
806
            items => @items
807
        }
808
    }
809
801
    $template->param(patron_attributes => \@attribute_loop);
810
    $template->param(patron_attributes => \@attribute_loop);
802
811
803
}
812
}
(-)a/members/moremember.pl (-2 / +1 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 = uniq( map {$_->{class}} @$attributes );
435
    my @classes = sort uniq( map {$_->{class}} @$attributes );
436
    my @attributes_loop;
436
    my @attributes_loop;
437
    for my $class (@classes) {
437
    for my $class (@classes) {
438
        my @items;
438
        my @items;
439
- 

Return to bug 7154