@@ -, +, @@ wih AV - FIX display/hide attr on memberentry.pl when category changes - Attr classes filled with AV 'PA_CLASS' category (you have to create AV with a new category 'PA_CLASS' to fill class list) - Use tables (classes separation) on member modification and attr management (admin). Theses array are sorted by name. --- admin/patron-attr-types.pl | 28 +++++- .../prog/en/modules/admin/patron-attr-types.tt | 62 +++++++---- .../prog/en/modules/members/memberentrygen.tt | 108 +++++++++++--------- members/memberentry.pl | 17 +++- members/moremember.pl | 2 +- 5 files changed, 136 insertions(+), 81 deletions(-) --- a/admin/patron-attr-types.pl +++ a/admin/patron-attr-types.pl @@ -22,6 +22,8 @@ use strict; use warnings; use CGI; +use List::MoreUtils qw/uniq/; + use C4::Auth; use C4::Context; use C4::Output; @@ -84,6 +86,7 @@ sub add_attribute_type_form { confirm_op => 'add_attribute_type_confirmed', ); authorised_value_category_list($template); + pa_classes($template); } sub error_add_attribute_type_form { @@ -237,9 +240,9 @@ sub edit_attribute_type_form { $template->param(display_checkout_checked => 'checked="checked"'); } authorised_value_category_list($template, $attr_type->authorised_value_category()); + pa_classes( $template, $attr_type->class ); $template->param ( category_type => $attr_type->category_type ); - $template->param ( class => $attr_type->class ); $template->param( attribute_type_form => 1, @@ -251,9 +254,21 @@ sub edit_attribute_type_form { sub patron_attribute_type_list { my $template = shift; - + my @attr_types = C4::Members::AttributeTypes::GetAttributeTypes(); - $template->param(available_attribute_types => \@attr_types); + my @classes = sort uniq( map {$_->{class}} @attr_types ); + my @attributes_loop; + for my $class (@classes) { + my @items; + for my $attr (@attr_types) { + push @items, $attr if $attr->{class} eq $class + } + push @attributes_loop, { + class => $class, + items => \@items + }; + } + $template->param(available_attribute_types => \@attributes_loop); $template->param(display_list => 1); } @@ -270,3 +285,10 @@ sub authorised_value_category_list { } $template->param(authorised_value_categories => \@list); } + +sub pa_classes { + my $template = shift; + my $selected = @_ ? shift : ''; + + $template->param(classes_val_loop => GetAuthorisedValues( 'PA_CLASS', $selected ) ); +} --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt @@ -201,8 +201,21 @@ function CheckAttributeTypeForm(f) {
  • - - Group attributes types with a block title + + Group attributes types with a block title (based on Authorised values category 'PA_CLASS')
  • @@ -267,29 +280,32 @@ function CheckAttributeTypeForm(f) { — it was already absent from the database. [% END %] [% IF ( available_attribute_types ) %] - - - - - - - - - - - [% FOREACH available_attribute_type IN available_attribute_types %] + [% FOREACH attribute IN available_attribute_types %] + [% IF attribute.class %] +

    [% attribute.class %]

    + [% END %] +
    ClassCodeDescriptionActions
    + - - - - + + + - [% END %] - -
    [% available_attribute_type.class |html %][% available_attribute_type.code |html %][% available_attribute_type.description %] - Edit - Delete - CodeDescriptionActions
    + + + [% FOREACH item IN attribute.items %] + + [% item.code |html %] + [% item.description %] + + Edit + Delete + + + [% END %] + + + [% END %] [% ELSE %]

    There are no saved patron attribute types.

    [% END %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -63,16 +63,19 @@ } function update_category_code(category_type) { - var mytable = $("#attributes_table>tbody"); + if ( $(category_type).is("select") ) { + category_type = $("#categorycode").find("option:selected").attr("data-typename"); + } + var mytables = $(".attributes_table>tbody"); - mytable.find("tr").each(function(){ + mytables.find("tr").each(function(){ $(this).hide() }); - mytable.find("tr[data-category_type="+category_type+"]").each(function(){ + mytables.find("tr[data-category_type="+category_type+"]").each(function(){ $(this).show(); }); - mytable.find("tr[data-category_type='']").each(function(){ + mytables.find("tr[data-category_type='']").each(function(){ $(this).show(); }); @@ -1192,7 +1195,7 @@ [% IF ( opduplicate ) %] [% ELSE %] - + [% END %] @@ -1207,62 +1210,67 @@
    Additional attributes and identifiers - + [% FOREACH pa_loo IN patron_attributes %] + [% IF pa_loo.class %] +

    [% pa_loo.class %]

    +
    + [% ELSE %] +
    + [% END %] - - [% FOREACH patron_attribute IN patron_attributes %] - - - - + + - - - [% END %] + [% IF ( patron_attribute.password_allowed ) %] + (Password: ) + [% END %] + + + + [% END %] -
    Class Type Value
    [% patron_attribute.class %] - [% patron_attribute.code %] ([% patron_attribute.description %]) - - - [% IF ( patron_attribute.use_dropdown ) %] -
    + [% patron_attribute.code %] ([% patron_attribute.description %]) + + + [% IF ( patron_attribute.use_dropdown ) %] + + [% ELSE %] + [% IF ( opduplicate ) %] + [% ELSE %] - + [% END %] [% END %] - - [% ELSE %] - [% IF ( opduplicate ) %] - - [% ELSE %] - - [% END %] - [% END %] - [% IF ( patron_attribute.password_allowed ) %] - (Password: ) - [% END %] - - Clear - [% IF ( patron_attribute.repeatable ) %] - New - [% END %] -
    + Clear + [% IF ( patron_attribute.repeatable ) %] + New + [% END %] +
    + + [% END %]
    [% END %][% END %][% END %] --- a/members/memberentry.pl +++ a/members/memberentry.pl @@ -25,6 +25,7 @@ use warnings; # external modules use CGI; # use Digest::MD5 qw(md5_base64); +use List::MoreUtils qw/uniq/; # internal modules use C4::Auth; @@ -407,7 +408,7 @@ if ($op eq 'add'){ if ($op eq "modify") { $template->param( updtype => 'M',modify => 1 ); $template->param( step_1=>1, step_2=>1, step_3=>1, step_4=>1, step_5 => 1, step_6 => 1) unless $step; - if ( $step = 4 ) { + if ( $step == 4 ) { $template->param( category_type => $borrower_data->{'categorycode'} ); } } @@ -751,6 +752,7 @@ sub patron_attributes_form { return; } my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber); + my @classes = sort uniq( map {$_->{class}} @$attributes ); # map patron's attributes into a more convenient structure my %attr_hash = (); @@ -760,6 +762,7 @@ sub patron_attributes_form { my @attribute_loop = (); my $i = 0; + my %items_by_class; foreach my $type_code (map { $_->{code} } @types) { my $attr_type = C4::Members::AttributeTypes->fetch($type_code); my $entry = { @@ -784,8 +787,7 @@ sub patron_attributes_form { } $i++; $newentry->{form_id} = "patron_attr_$i"; - #use Data::Dumper; die Dumper($entry) if $entry->{use_dropdown}; - push @attribute_loop, $newentry; + push @{$items_by_class{$attr_type->class()}}, $newentry; } } else { $i++; @@ -795,9 +797,16 @@ sub patron_attributes_form { $newentry->{auth_val_loop} = GetAuthorisedValues($attr_type->authorised_value_category()); } $newentry->{form_id} = "patron_attr_$i"; - push @attribute_loop, $newentry; + push @{$items_by_class{$attr_type->class()}}, $newentry; } } + while ( my ($class, @items) = each %items_by_class ) { + push @attribute_loop, { + class => $class, + items => @items + } + } + $template->param(patron_attributes => \@attribute_loop); } --- a/members/moremember.pl +++ a/members/moremember.pl @@ -432,7 +432,7 @@ $template->param(%$data); if (C4::Context->preference('ExtendedPatronAttributes')) { my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber); - my @classes = uniq( map {$_->{class}} @$attributes ); + my @classes = sort uniq( map {$_->{class}} @$attributes ); my @attributes_loop; for my $class (@classes) { my @items; --