From a380bed825f38b8df42417c6a97ea3cfc48a1878 Mon Sep 17 00:00:00 2001 From: Phan Tung Bui Date: Thu, 29 Feb 2024 15:05:55 -0500 Subject: [PATCH] Bug 35145 : (follow-up) Rename number to display_order --- admin/patron-attr-types.pl | 2 ++ .../bug_35145_order_patron_attributes.pl | 22 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 1 + .../en/modules/admin/patron-attr-types.tt | 10 +++++++++ members/memberentry.pl | 2 +- opac/opac-memberentry.pl | 2 +- 6 files changed, 37 insertions(+), 2 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_35145_order_patron_attributes.pl diff --git a/admin/patron-attr-types.pl b/admin/patron-attr-types.pl index ca5d2fca47..dff581876a 100755 --- a/admin/patron-attr-types.pl +++ b/admin/patron-attr-types.pl @@ -124,6 +124,7 @@ sub add_update_attribute_type { my $display_checkout = $input->param('display_checkout') ? 1 : 0; my $category_code = $input->param('category_code') || undef; my $class = $input->param('class'); + my $display_order = $input->param('display_order') || undef; my $attr_type = Koha::Patron::Attribute::Types->find($code); if ( $op eq 'edit' ) { @@ -160,6 +161,7 @@ sub add_update_attribute_type { display_checkout => $display_checkout, category_code => $category_code, class => $class, + display_order => $display_order, } )->store; diff --git a/installer/data/mysql/atomicupdate/bug_35145_order_patron_attributes.pl b/installer/data/mysql/atomicupdate/bug_35145_order_patron_attributes.pl new file mode 100755 index 0000000000..b1650cd378 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_35145_order_patron_attributes.pl @@ -0,0 +1,22 @@ +use Modern::Perl; + +return { + bug_number => "35145", + description => "Add display_order column to borrower_attribute_types table", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + # Do you stuffs here + $dbh->do( + q{ + ALTER TABLE borrower_attribute_types + ADD display_order int(11); + } + ); + + # Print useful stuff here + # tables + say $out "Added column 'borrower_attribute_types.number'"; + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 16310f0f44..65c3a45ed3 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1242,6 +1242,7 @@ CREATE TABLE `borrower_attribute_types` ( `class` varchar(255) NOT NULL DEFAULT '' COMMENT 'defines a class for an attribute_type', `keep_for_pseudonymization` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if this field is copied to anonymized_borrower_attributes (1 for yes, 0 for no)', `mandatory` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if the attribute is mandatory or not', + `display_order` int(11) DEFAULT NULL COMMENT 'the order in which this attribute type appears in patron form', PRIMARY KEY (`code`), KEY `auth_val_cat_idx` (`authorised_value_category`), KEY `category_code` (`category_code`), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt index bad4257539..2600e9ec1c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt @@ -104,6 +104,14 @@ Required +
  • + + [% IF ( attribute_type.display_order ) %] + + [% ELSE %] + + [% END %] +
  • [% IF attribute_type AND attribute_type.repeatable AND NOT can_be_set_to_nonrepeatable %]
  • @@ -317,6 +325,7 @@ Authorized value category Mandatory Searching + Display order Actions @@ -367,6 +376,7 @@ Not searchable [% END %] + [% item.display_order | html %] Edit Delete diff --git a/members/memberentry.pl b/members/memberentry.pl index 57e780cfec..1eff46b46d 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -866,7 +866,7 @@ sub patron_attributes_form { my $op = shift; my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; - my $attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits({}, {}, $library_id); + my $attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits({}, { order_by => 'display_order' }, $library_id); if ( $attribute_types->count == 0 ) { $template->param(no_patron_attribute_types => 1); return; diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index 51f03fca19..53964222bc 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -672,7 +672,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()->as_list(); + Koha::Patron::Attribute::Types->search( {}, { order_by => 'display_order' } )->as_list(); if ( scalar(@types) == 0 ) { return []; } -- 2.34.1