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

(-)a/admin/patron-attr-types.pl (+2 lines)
Lines 121-126 sub add_update_attribute_type { Link Here
121
    my $display_checkout          = $input->param('display_checkout') ? 1 : 0;
121
    my $display_checkout          = $input->param('display_checkout') ? 1 : 0;
122
    my $category_code             = $input->param('category_code') || undef;
122
    my $category_code             = $input->param('category_code') || undef;
123
    my $class                     = $input->param('class');
123
    my $class                     = $input->param('class');
124
    my $display_order             = $input->param('display_order') || undef;
124
125
125
    my $attr_type = Koha::Patron::Attribute::Types->find($code);
126
    my $attr_type = Koha::Patron::Attribute::Types->find($code);
126
    if ( $op eq 'edit' ) {
127
    if ( $op eq 'edit' ) {
Lines 158-163 sub add_update_attribute_type { Link Here
158
            display_checkout          => $display_checkout,
159
            display_checkout          => $display_checkout,
159
            category_code             => $category_code,
160
            category_code             => $category_code,
160
            class                     => $class,
161
            class                     => $class,
162
            display_order             => $display_order,
161
        }
163
        }
162
    )->store;
164
    )->store;
163
165
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt (+10 lines)
Lines 105-110 Link Here
105
                        <input type="text" id="description" name="description" required="required" class="required" size="50" maxlength="250" value="[% attribute_type.description |html %]" />
105
                        <input type="text" id="description" name="description" required="required" class="required" size="50" maxlength="250" value="[% attribute_type.description |html %]" />
106
                        <span class="required">Required</span>
106
                        <span class="required">Required</span>
107
                    </li>
107
                    </li>
108
                    <li>
109
                        <label for="display_order">Appear in position: </label>
110
                        [% IF ( attribute_type.display_order ) %]
111
                            <input id="display_order" size="3" name="display_order" type="text" value="[% attribute_type.display_order | html %]" />
112
                        [% ELSE %]
113
                            <input id="display_order" size="3" name="display_order" type="text" />
114
                        [% END %]
115
                    </li>
108
116
109
                    <li [% IF attribute_type AND attribute_type.repeatable AND NOT can_be_set_to_nonrepeatable %]aria-disabled="true"[% END %]>
117
                    <li [% IF attribute_type AND attribute_type.repeatable AND NOT can_be_set_to_nonrepeatable %]aria-disabled="true"[% END %]>
110
                        <label for="repeatable">Repeatable: </label>
118
                        <label for="repeatable">Repeatable: </label>
Lines 330-335 Link Here
330
                                <th>Mandatory in staff interface</th>
338
                                <th>Mandatory in staff interface</th>
331
                                <th>Mandatory in OPAC</th>
339
                                <th>Mandatory in OPAC</th>
332
                                <th>Searching</th>
340
                                <th>Searching</th>
341
                                <th>Display order</th>
333
                                <th class="no-sort no-export">Actions</th>
342
                                <th class="no-sort no-export">Actions</th>
334
                            </tr>
343
                            </tr>
335
                        </thead>
344
                        </thead>
Lines 388-393 Link Here
388
                                            <span>Not searchable</span>
397
                                            <span>Not searchable</span>
389
                                        [% END %]
398
                                        [% END %]
390
                                    </td>
399
                                    </td>
400
                                    <td>[% item.display_order | html %]</td>
391
                                    <td class="actions">
401
                                    <td class="actions">
392
                                        <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/patron-attr-types.pl?op=edit_attribute_type&amp;code=[% item.code | uri %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
402
                                        <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/patron-attr-types.pl?op=edit_attribute_type&amp;code=[% item.code | uri %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
393
                                        <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/patron-attr-types.pl?op=delete_attribute_type&amp;code=[% item.code | uri %]"><i class="fa fa-trash-can"></i> Delete</a>
403
                                        <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/patron-attr-types.pl?op=delete_attribute_type&amp;code=[% item.code | uri %]"><i class="fa fa-trash-can"></i> Delete</a>
(-)a/members/memberentry.pl (+72 lines)
Lines 958-963 sub parse_extended_patron_attributes { Link Here
958
    return \@attr;
958
    return \@attr;
959
}
959
}
960
960
961
sub patron_attributes_form {
962
    my $template   = shift;
963
    my $attributes = shift;
964
    my $op         = shift;
965
966
    my $library_id      = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
967
    my $attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits( {}, { order_by => 'display_order' }, $library_id);
968
    if ( $attribute_types->count == 0 ) {
969
        $template->param( no_patron_attribute_types => 1 );
970
        return;
971
    }
972
973
    # map patron's attributes into a more convenient structure
974
    my %attr_hash = ();
975
    foreach my $attr (@$attributes) {
976
        push @{ $attr_hash{ $attr->{code} } }, $attr;
977
    }
978
979
    my @attribute_loop = ();
980
    my $i              = 0;
981
    my %items_by_class;
982
    while ( my ($attr_type) = $attribute_types->next ) {
983
        my $entry = {
984
            class         => $attr_type->class(),
985
            code          => $attr_type->code(),
986
            description   => $attr_type->description(),
987
            repeatable    => $attr_type->repeatable(),
988
            category      => $attr_type->authorised_value_category(),
989
            category_code => $attr_type->category_code(),
990
            mandatory     => $attr_type->mandatory(),
991
            is_date       => $attr_type->is_date(),
992
        };
993
        if ( exists $attr_hash{ $attr_type->code() } ) {
994
            foreach my $attr ( @{ $attr_hash{ $attr_type->code() } } ) {
995
                my $newentry = {%$entry};
996
                $newentry->{value}        = $attr->{attribute};
997
                $newentry->{use_dropdown} = 0;
998
                if ( $attr_type->authorised_value_category() ) {
999
                    $newentry->{use_dropdown} = 1;
1000
                    $newentry->{auth_val_loop} =
1001
                        GetAuthorisedValues( $attr_type->authorised_value_category(), $attr->{attribute} );
1002
                }
1003
                $i++;
1004
                undef $newentry->{value} if ( $attr_type->unique_id() && $op eq 'duplicate' );
1005
                $newentry->{form_id} = "patron_attr_$i";
1006
                push @{ $items_by_class{ $attr_type->class() } }, $newentry;
1007
            }
1008
        } else {
1009
            $i++;
1010
            my $newentry = {%$entry};
1011
            if ( $attr_type->authorised_value_category() ) {
1012
                $newentry->{use_dropdown}  = 1;
1013
                $newentry->{auth_val_loop} = GetAuthorisedValues( $attr_type->authorised_value_category() );
1014
            }
1015
            $newentry->{form_id} = "patron_attr_$i";
1016
            push @{ $items_by_class{ $attr_type->class() } }, $newentry;
1017
        }
1018
    }
1019
    for my $class ( sort keys %items_by_class ) {
1020
        my $av  = Koha::AuthorisedValues->search( { category => 'PA_CLASS', authorised_value => $class } );
1021
        my $lib = $av->count ? $av->next->lib : $class;
1022
        push @attribute_loop, {
1023
            class => $class,
1024
            items => $items_by_class{$class},
1025
            lib   => $lib,
1026
        };
1027
    }
1028
1029
    $template->param( patron_attributes => \@attribute_loop );
1030
1031
}
1032
961
sub add_guarantors {
1033
sub add_guarantors {
962
    my ( $patron, $input ) = @_;
1034
    my ( $patron, $input ) = @_;
963
1035
(-)a/members/moremember.pl (-2 / +5 lines)
Lines 143-156 unless ( Koha::Patron::Categories->search_with_library_limits( { 'me.categorycod Link Here
143
143
144
if ( C4::Context->preference('ExtendedPatronAttributes') ) {
144
if ( C4::Context->preference('ExtendedPatronAttributes') ) {
145
    my @attributes = $patron->extended_attributes->as_list;         # FIXME Must be improved!
145
    my @attributes = $patron->extended_attributes->as_list;         # FIXME Must be improved!
146
    my $attribute_types = Koha::Patron::Attribute::Types->search({}, { order_by => 'display_order' });
146
    my @classes    = uniq( map { $_->type->class } @attributes );
147
    my @classes    = uniq( map { $_->type->class } @attributes );
147
    @classes = sort @classes;
148
    @classes = sort @classes;
148
149
149
    my @attributes_loop;
150
    my @attributes_loop;
150
    for my $class (@classes) {
151
    for my $class (@classes) {
151
        my @items;
152
        my @items;
152
        for my $attr (@attributes) {
153
        while ( my ( $attr_type ) = $attribute_types->next ) {
153
            push @items, $attr if $attr->type->class eq $class;
154
            for my $attr (@attributes) {
155
                push @items, $attr if ($attr->type->class eq $class && $attr_type->code() eq $attr->type->code)
156
            }
154
        }
157
        }
155
        my $av  = Koha::AuthorisedValues->search( { category => 'PA_CLASS', authorised_value => $class } );
158
        my $av  = Koha::AuthorisedValues->search( { category => 'PA_CLASS', authorised_value => $class } );
156
        my $lib = $av->count ? $av->next->lib : $class;
159
        my $lib = $av->count ? $av->next->lib : $class;
(-)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()->as_list();
708
        Koha::Patron::Attribute::Types->search( {}, { order_by => 'display_order' } )->as_list();
709
    if ( scalar(@types) == 0 ) {
709
    if ( scalar(@types) == 0 ) {
710
        return [];
710
        return [];
711
    }
711
    }
712
- 

Return to bug 35145