From 3ba7a318ccae17d952faa2215c916e7a21b3d1dd Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 22 May 2020 11:02:39 +0200 Subject: [PATCH] Bug 25553: Make date columns sortable on the edit items table When editing items, the table at the top contain several columns that have date values, but they cannot be sorted by dates correctly. Test plan: Have several items with different dates in columns that contain dates, like items.dateaccessioned, items.datelastseen) Sort the column and confirm that with this patch the lines are sorted correctly --- cataloguing/additem.pl | 2 +- .../prog/en/modules/cataloguing/additem.tt | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index b0ce8b58c5..130ff0a3f2 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -872,7 +872,7 @@ for my $row ( @big_array ) { { my ( undef, $subfield ) = GetMarcFromKohaField($kohafield); next unless $key eq $subfield; - $item_field->{field} = output_pref( { str => $row->{$key}, dateonly => 1 } ); + $item_field->{datatype} = 'date'; } push @item_fields, $item_field; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt index 463edf4e08..b688effbf9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt @@ -45,6 +45,7 @@
[% IF ( item_loop ) %] + [% SET date_fields = [ 'dateaccessioned', 'onloan', 'datelastseen', 'datelastborrowed', 'replacementpricedate' ] %]
@@ -52,7 +53,11 @@ [% FOREACH item_header IN item_header_loop %] [% IF item_header.column_name %] - + [% IF item_valu.datatype == 'date' %] + + [% ELSE %] + + [% END %] [% END %] [% END %] -- 2.20.1
  + [% IF date_fields.grep(item_header.column_name).size %] + + [% ELSE %] + + [% END %] [% ELSE %] [% END %] @@ -106,7 +111,11 @@ [% END %] [% FOREACH item_valu IN item_loo.item_value %] - [% item_valu.field | html %][% item_valu.field | $KohaDates %][% item_valu.field | html %]