Bugzilla – Attachment 192411 Details for
Bug 35145
Add ability to order patron attributes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35145: Fix patron attribute type ordering
Bug-35145-Fix-patron-attribute-type-ordering.patch (text/plain), 5.39 KB, created by
Ayoub Glizi-Vicioso
on 2026-02-03 22:47:17 UTC
(
hide
)
Description:
Bug 35145: Fix patron attribute type ordering
Filename:
MIME Type:
Creator:
Ayoub Glizi-Vicioso
Created:
2026-02-03 22:47:17 UTC
Size:
5.39 KB
patch
obsolete
>From 3fe72285e97596cffe862a5ed3bcb5e845709748 Mon Sep 17 00:00:00 2001 >From: Ayoub Glizi-Vicioso <ayoub.glizi-vicioso@inLibro.com> >Date: Tue, 3 Feb 2026 17:44:39 -0500 >Subject: [PATCH] Bug 35145: Fix patron attribute type ordering > >--- > Koha/Patron/Attribute/Types.pm | 11 +++++------ > admin/patron-attr-types.pl | 10 +++++++++- > .../prog/en/includes/member-attribute-types.inc | 1 + > members/memberentry.pl | 2 ++ > opac/opac-memberentry.pl | 2 +- > 5 files changed, 18 insertions(+), 8 deletions(-) > >diff --git a/Koha/Patron/Attribute/Types.pm b/Koha/Patron/Attribute/Types.pm >index dd0eb93e36..4a677db0d2 100644 >--- a/Koha/Patron/Attribute/Types.pm >+++ b/Koha/Patron/Attribute/Types.pm >@@ -50,11 +50,10 @@ sub patron_attributes_form { > my $template = shift; > my $attributes = shift; > my $op = shift; >- my $query = shift // {}; > > my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; >- my $attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits( $query, {}, $library_id ); >- if ( $attribute_types->count == 0 ) { >+ 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(); >+ if ( !@attribute_types ) { > $template->param( no_patron_attribute_types => 1 ); > return; > } >@@ -68,7 +67,7 @@ sub patron_attributes_form { > my @attribute_loop = (); > my $i = 0; > my %items_by_class; >- while ( my ($attr_type) = $attribute_types->next ) { >+ for my $attr_type (@attribute_types) { > my $entry = { > class => $attr_type->class(), > code => $attr_type->code(), >@@ -87,7 +86,7 @@ sub patron_attributes_form { > if ( $attr_type->authorised_value_category() ) { > $newentry->{use_dropdown} = 1; > $newentry->{auth_val_loop} = >- C4::Koha::GetAuthorisedValues( $attr_type->authorised_value_category(), $attr->{attribute} ); >+ GetAuthorisedValues( $attr_type->authorised_value_category(), $attr->{attribute} ); > } > $i++; > undef $newentry->{value} if ( $attr_type->unique_id() && $op eq 'duplicate' ); >@@ -99,7 +98,7 @@ sub patron_attributes_form { > my $newentry = {%$entry}; > if ( $attr_type->authorised_value_category() ) { > $newentry->{use_dropdown} = 1; >- $newentry->{auth_val_loop} = C4::Koha::GetAuthorisedValues( $attr_type->authorised_value_category() ); >+ $newentry->{auth_val_loop} = GetAuthorisedValues( $attr_type->authorised_value_category() ); > } > $newentry->{form_id} = "patron_attr_$i"; > push @{ $items_by_class{ $attr_type->class() } }, $newentry; >diff --git a/admin/patron-attr-types.pl b/admin/patron-attr-types.pl >index 9e2734d258..520f2dca59 100755 >--- a/admin/patron-attr-types.pl >+++ b/admin/patron-attr-types.pl >@@ -258,7 +258,6 @@ sub patron_attribute_type_list { > > my @classes = uniq( map { $_->class } @attr_types ); > @classes = sort @classes; >- > my @attributes_loop; > > # FIXME This is not efficient and should be improved >@@ -268,6 +267,15 @@ sub patron_attribute_type_list { > next if $attr->class ne $class; > push @items, $attr; > } >+ >+ @items = sort { >+ (defined $a->display_order ? $a->display_order : 9999) >+ <=> >+ (defined $b->display_order ? $b->display_order : 9999) >+ || $a->code cmp $b->code >+ } @items; >+ >+ > my $av = Koha::AuthorisedValues->search( { category => 'PA_CLASS', authorised_value => $class } ); > my $lib = $av->count ? $av->next->lib : $class; > push @attributes_loop, { >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/member-attribute-types.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/member-attribute-types.inc >index c1f7540fd0..7b7bd9cd02 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/member-attribute-types.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/member-attribute-types.inc >@@ -1,3 +1,4 @@ >+[%- KOHA -%] > [% BLOCK 'memberentry_patron_attributes_form' %] > [% UNLESS ( no_patron_attribute_types ) %] > <fieldset class="rows" id="memberentry_patron_attributes"> >diff --git a/members/memberentry.pl b/members/memberentry.pl >index 34932e4a4c..9c166ae2d6 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -1062,3 +1062,5 @@ sub add_guarantors { > } > } > } >+ >+1; >\ No newline at end of file >diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl >index dcd149347a..bd08bd3c61 100755 >--- a/opac/opac-memberentry.pl >+++ b/opac/opac-memberentry.pl >@@ -705,7 +705,7 @@ sub GeneratePatronAttributesForm { > > # Get all attribute types and the values for this patron (if applicable) > my @types = grep { $_->opac_editable() or $_->opac_display } # FIXME filter using DBIC >- Koha::Patron::Attribute::Types->search( {}, { order_by => 'display_order' } )->as_list(); >+ Koha::Patron::Attribute::Types->search( {}, { order_by => \'display_order IS NULL, display_order ASC , code ASC' } )->as_list(); > if ( scalar(@types) == 0 ) { > return []; > } >-- >2.52.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 35145
:
159182
|
159193
|
159344
|
159345
|
162347
|
162348
|
162619
|
162620
|
162621
|
162622
|
162676
|
166473
|
166519
|
166520
|
166521
|
169256
|
169257
|
169258
|
170330
|
170331
|
170332
|
170627
|
170628
|
170629
|
176756
|
176757
|
176758
|
176760
|
176761
|
176762
|
176763
|
176764
|
176765
|
177119
|
181885
|
181886
|
181887
|
181888
|
181889
|
181890
|
182241
|
182242
|
182243
|
182244
|
182245
|
182246
|
189172
|
189173
|
189174
|
189175
|
189176
|
189177
|
192399
|
192400
|
192401
|
192402
|
192403
|
192404
|
192405
|
192406
|
192407
|
192408
|
192409
|
192410
|
192411
|
192654
|
192655
|
192656
|
192657
|
192658
|
192659
|
192660