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

(-)a/Koha/Patron/Attribute/Types.pm (-6 / +5 lines)
Lines 50-60 sub patron_attributes_form { Link Here
50
    my $template   = shift;
50
    my $template   = shift;
51
    my $attributes = shift;
51
    my $attributes = shift;
52
    my $op         = shift;
52
    my $op         = shift;
53
    my $query      = shift // {};
54
53
55
    my $library_id      = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
54
    my $library_id      = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
56
    my $attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits( $query, {}, $library_id );
55
    my @attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits( {}, { order_by => \'display_order IS NULL, display_order ASC , code ASC' }, $library_id) -> as_list();
57
    if ( $attribute_types->count == 0 ) {
56
    if ( !@attribute_types ) {
58
        $template->param( no_patron_attribute_types => 1 );
57
        $template->param( no_patron_attribute_types => 1 );
59
        return;
58
        return;
60
    }
59
    }
Lines 68-74 sub patron_attributes_form { Link Here
68
    my @attribute_loop = ();
67
    my @attribute_loop = ();
69
    my $i              = 0;
68
    my $i              = 0;
70
    my %items_by_class;
69
    my %items_by_class;
71
    while ( my ($attr_type) = $attribute_types->next ) {
70
    for my $attr_type (@attribute_types) {
72
        my $entry = {
71
        my $entry = {
73
            class         => $attr_type->class(),
72
            class         => $attr_type->class(),
74
            code          => $attr_type->code(),
73
            code          => $attr_type->code(),
Lines 87-93 sub patron_attributes_form { Link Here
87
                if ( $attr_type->authorised_value_category() ) {
86
                if ( $attr_type->authorised_value_category() ) {
88
                    $newentry->{use_dropdown} = 1;
87
                    $newentry->{use_dropdown} = 1;
89
                    $newentry->{auth_val_loop} =
88
                    $newentry->{auth_val_loop} =
90
                        C4::Koha::GetAuthorisedValues( $attr_type->authorised_value_category(), $attr->{attribute} );
89
                        GetAuthorisedValues( $attr_type->authorised_value_category(), $attr->{attribute} );
91
                }
90
                }
92
                $i++;
91
                $i++;
93
                undef $newentry->{value} if ( $attr_type->unique_id() && $op eq 'duplicate' );
92
                undef $newentry->{value} if ( $attr_type->unique_id() && $op eq 'duplicate' );
Lines 99-105 sub patron_attributes_form { Link Here
99
            my $newentry = {%$entry};
98
            my $newentry = {%$entry};
100
            if ( $attr_type->authorised_value_category() ) {
99
            if ( $attr_type->authorised_value_category() ) {
101
                $newentry->{use_dropdown}  = 1;
100
                $newentry->{use_dropdown}  = 1;
102
                $newentry->{auth_val_loop} = C4::Koha::GetAuthorisedValues( $attr_type->authorised_value_category() );
101
                $newentry->{auth_val_loop} = GetAuthorisedValues( $attr_type->authorised_value_category() );
103
            }
102
            }
104
            $newentry->{form_id} = "patron_attr_$i";
103
            $newentry->{form_id} = "patron_attr_$i";
105
            push @{ $items_by_class{ $attr_type->class() } }, $newentry;
104
            push @{ $items_by_class{ $attr_type->class() } }, $newentry;
(-)a/admin/patron-attr-types.pl (-1 / +9 lines)
Lines 258-264 sub patron_attribute_type_list { Link Here
258
258
259
    my @classes = uniq( map { $_->class } @attr_types );
259
    my @classes = uniq( map { $_->class } @attr_types );
260
    @classes = sort @classes;
260
    @classes = sort @classes;
261
262
    my @attributes_loop;
261
    my @attributes_loop;
263
262
264
    # FIXME This is not efficient and should be improved
263
    # FIXME This is not efficient and should be improved
Lines 268-273 sub patron_attribute_type_list { Link Here
268
            next if $attr->class ne $class;
267
            next if $attr->class ne $class;
269
            push @items, $attr;
268
            push @items, $attr;
270
        }
269
        }
270
271
        @items = sort {
272
            (defined $a->display_order ? $a->display_order : 9999)
273
            <=>
274
            (defined $b->display_order ? $b->display_order : 9999)
275
            || $a->code cmp $b->code
276
        } @items;
277
278
271
        my $av  = Koha::AuthorisedValues->search( { category => 'PA_CLASS', authorised_value => $class } );
279
        my $av  = Koha::AuthorisedValues->search( { category => 'PA_CLASS', authorised_value => $class } );
272
        my $lib = $av->count ? $av->next->lib : $class;
280
        my $lib = $av->count ? $av->next->lib : $class;
273
        push @attributes_loop, {
281
        push @attributes_loop, {
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/member-attribute-types.inc (+1 lines)
Lines 1-3 Link Here
1
[%- KOHA -%]
1
[% BLOCK 'memberentry_patron_attributes_form' %]
2
[% BLOCK 'memberentry_patron_attributes_form' %]
2
    [% UNLESS ( no_patron_attribute_types ) %]
3
    [% UNLESS ( no_patron_attribute_types ) %]
3
        <fieldset class="rows" id="memberentry_patron_attributes">
4
        <fieldset class="rows" id="memberentry_patron_attributes">
(-)a/members/memberentry.pl (+2 lines)
Lines 1063-1065 sub add_guarantors { Link Here
1063
        }
1063
        }
1064
    }
1064
    }
1065
}
1065
}
1066
1067
1;
(-)a/opac/opac-memberentry.pl (-2 / +1 lines)
Lines 705-711 sub GeneratePatronAttributesForm { Link Here
705
705
706
    # Get all attribute types and the values for this patron (if applicable)
706
    # Get all attribute types and the values for this patron (if applicable)
707
    my @types = grep { $_->opac_editable() or $_->opac_display }    # FIXME filter using DBIC
707
    my @types = grep { $_->opac_editable() or $_->opac_display }    # FIXME filter using DBIC
708
        Koha::Patron::Attribute::Types->search( {}, { order_by => 'display_order' } )->as_list();
708
        Koha::Patron::Attribute::Types->search( {}, { order_by => \'display_order IS NULL, display_order ASC , code ASC' } )->as_list();
709
    if ( scalar(@types) == 0 ) {
709
    if ( scalar(@types) == 0 ) {
710
        return [];
710
        return [];
711
    }
711
    }
712
- 

Return to bug 35145