From 31d6f445aa96dc8acf9a7aff29b9518df9b775e7 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 PA amended: Fix commit title Signed-off-by: Pedro Amorim --- 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 d591383e48..fc3d391bf0 100755 --- a/admin/patron-attr-types.pl +++ b/admin/patron-attr-types.pl @@ -125,6 +125,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' ) { @@ -162,6 +163,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 452103bfb3..15656b2037 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1262,6 +1262,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 6c87a2fe0c..896bfd57d2 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 @@ -105,6 +105,14 @@ Required +
  • + + [% IF ( attribute_type.display_order ) %] + + [% ELSE %] + + [% END %] +
  • [% IF attribute_type AND attribute_type.repeatable AND NOT can_be_set_to_nonrepeatable %]
  • @@ -326,6 +334,7 @@ Authorized value category Mandatory Searching + Display order Actions @@ -376,6 +385,7 @@ Not searchable [% END %] + [% item.display_order | html %] Edit Delete diff --git a/members/memberentry.pl b/members/memberentry.pl index fe0d1beff0..d1d9a29a75 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -856,7 +856,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 279417431d..3b2e2314ee 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -657,7 +657,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.39.2