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 957-962 sub parse_extended_patron_attributes { Link Here
957
    return \@attr;
957
    return \@attr;
958
}
958
}
959
959
960
sub patron_attributes_form {
961
    my $template   = shift;
962
    my $attributes = shift;
963
    my $op         = shift;
964
965
    my $library_id      = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
966
    my $attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits( {}, { order_by => 'display_order' }, $library_id);
967
    if ( $attribute_types->count == 0 ) {
968
        $template->param( no_patron_attribute_types => 1 );
969
        return;
970
    }
971
972
    # map patron's attributes into a more convenient structure
973
    my %attr_hash = ();
974
    foreach my $attr (@$attributes) {
975
        push @{ $attr_hash{ $attr->{code} } }, $attr;
976
    }
977
978
    my @attribute_loop = ();
979
    my $i              = 0;
980
    my %items_by_class;
981
    while ( my ($attr_type) = $attribute_types->next ) {
982
        my $entry = {
983
            class         => $attr_type->class(),
984
            code          => $attr_type->code(),
985
            description   => $attr_type->description(),
986
            repeatable    => $attr_type->repeatable(),
987
            category      => $attr_type->authorised_value_category(),
988
            category_code => $attr_type->category_code(),
989
            mandatory     => $attr_type->mandatory(),
990
            is_date       => $attr_type->is_date(),
991
        };
992
        if ( exists $attr_hash{ $attr_type->code() } ) {
993
            foreach my $attr ( @{ $attr_hash{ $attr_type->code() } } ) {
994
                my $newentry = {%$entry};
995
                $newentry->{value}        = $attr->{attribute};
996
                $newentry->{use_dropdown} = 0;
997
                if ( $attr_type->authorised_value_category() ) {
998
                    $newentry->{use_dropdown} = 1;
999
                    $newentry->{auth_val_loop} =
1000
                        GetAuthorisedValues( $attr_type->authorised_value_category(), $attr->{attribute} );
1001
                }
1002
                $i++;
1003
                undef $newentry->{value} if ( $attr_type->unique_id() && $op eq 'duplicate' );
1004
                $newentry->{form_id} = "patron_attr_$i";
1005
                push @{ $items_by_class{ $attr_type->class() } }, $newentry;
1006
            }
1007
        } else {
1008
            $i++;
1009
            my $newentry = {%$entry};
1010
            if ( $attr_type->authorised_value_category() ) {
1011
                $newentry->{use_dropdown}  = 1;
1012
                $newentry->{auth_val_loop} = GetAuthorisedValues( $attr_type->authorised_value_category() );
1013
            }
1014
            $newentry->{form_id} = "patron_attr_$i";
1015
            push @{ $items_by_class{ $attr_type->class() } }, $newentry;
1016
        }
1017
    }
1018
    for my $class ( sort keys %items_by_class ) {
1019
        my $av  = Koha::AuthorisedValues->search( { category => 'PA_CLASS', authorised_value => $class } );
1020
        my $lib = $av->count ? $av->next->lib : $class;
1021
        push @attribute_loop, {
1022
            class => $class,
1023
            items => $items_by_class{$class},
1024
            lib   => $lib,
1025
        };
1026
    }
1027
1028
    $template->param( patron_attributes => \@attribute_loop );
1029
1030
}
1031
960
sub add_guarantors {
1032
sub add_guarantors {
961
    my ( $patron, $input ) = @_;
1033
    my ( $patron, $input ) = @_;
962
1034
(-)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