From 31800ba46b2ed03cc2e4431c4d3c56fce678a0ec 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 Signed-off-by: Katrin Fischer Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart --- cataloguing/additem.pl | 2 +- .../prog/en/modules/cataloguing/additem.tt | 14 ++++++++++++-- 2 files changed, 13 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..f8fff0ddd1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt @@ -1,6 +1,7 @@ [% USE raw %] [% USE Asset %] [% USE Koha %] +[% USE KohaDates %] [% USE ColumnsSettings %] [% INCLUDE 'doc-head-open.inc' %] Koha › Cataloging › [% title | html %] [% IF ( author ) %] by [% author | html %][% END %] (Record #[% biblionumber | html %]) › Items @@ -45,6 +46,7 @@
[% IF ( item_loop ) %] + [% SET date_fields = [ 'dateaccessioned', 'onloan', 'datelastseen', 'datelastborrowed', 'replacementpricedate' ] %]
@@ -52,7 +54,11 @@ [% FOREACH item_header IN item_header_loop %] [% IF item_header.column_name %] - + [% IF item_valu.datatype == 'date' %] + + [% ELSE %] + + [% END %] [% END %] [% END %] -- 2.39.5
  + [% IF date_fields.grep(item_header.column_name).size %] + + [% ELSE %] + + [% END %] [% ELSE %] [% END %] @@ -106,7 +112,11 @@ [% END %] [% FOREACH item_valu IN item_loo.item_value %] - [% item_valu.field | html %][% item_valu.field | $KohaDates %][% item_valu.field | html %]