-
- my @attr_types = C4::Members::AttributeTypes::GetAttributeTypes();
- $template->param(available_attribute_types => \@attr_types);
+
+ my @attr_types = C4::Members::AttributeTypes::GetAttributeTypes( 1, 1 );
+
+ my @classes = uniq( map { $_->{class} } @attr_types );
+ @classes = sort @classes;
+
+ my @attributes_loop;
+ for my $class (@classes) {
+ my ( @items, $branches );
+ for my $attr (@attr_types) {
+ next if $attr->{class} ne $class;
+ my $attr_type = C4::Members::AttributeTypes->fetch($attr->{code});
+ $attr->{branches} = $attr_type->branches;
+ push @items, $attr;
+ }
+ my $lib = GetAuthorisedValueByCode( 'PA_CLASS', $class ) || $class;
+ push @attributes_loop, {
+ class => $class,
+ items => \@items,
+ lib => $lib,
+ branches => $branches,
+ };
+ }
+ $template->param(available_attribute_types => \@attributes_loop);