From 99a27050d84281643f40bbdb5d0adb4edbf32e15 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 (cherry picked from commit 31800ba46b2ed03cc2e4431c4d3c56fce678a0ec) Signed-off-by: Lucas Gass (cherry picked from commit ca74f037d83a7c406f187bdfe77cbed7b2f4aade) Signed-off-by: Aleisha Amohia --- 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 108010f2e6..3b5f2b7ef0 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -868,7 +868,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 a84689e853..9e6d939fdf 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 @@ -44,6 +45,7 @@
[% IF ( item_loop ) %] + [% SET date_fields = [ 'dateaccessioned', 'onloan', 'datelastseen', 'datelastborrowed', 'replacementpricedate' ] %]
@@ -51,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.39.5
  + [% IF date_fields.grep(item_header.column_name).size %] + + [% ELSE %] + + [% END %] [% ELSE %] [% END %] @@ -105,7 +111,11 @@ [% END %] [% FOREACH item_valu IN item_loo.item_value %] - [% item_valu.field | html %][% item_valu.field | $KohaDates %][% item_valu.field | html %]