From 699a1284b243a9a1ec098ba41a3bf9bef9661cad Mon Sep 17 00:00:00 2001 From: Andreas Roussos Date: Sun, 16 Jul 2023 16:19:00 +0000 Subject: [PATCH] Bug 34292: Format the check out date with dt_from_string() In the current master, checking out an item to a patron results in a 'Checked out on' date of the form '2023-07-16 12:44:18' when viewing the patron's 'Checkouts' table. This is due to commit 1000ab402b from Bug 33804 which changed the `mDataProp` property of the 'Checked out on' column from "issuedate_formatted" to plain "issuedate" (for both the issues and relatives' issues DataTables). "issuedate" comes straight from the issues.issuedate DB column (which has `datetime` format), whereas "issuedate_formatted" is formatted using Koha::DateUtils::dt_from_string() which takes into account the `dateformat` System Preference. This patch restores the original behaviour w.r.t. the formatting of the 'Checked out on' column. Note: in `svc/checkouts` we don't pass `as_due_date => 1` for `issuedate_formatted` because we *do* want to show a check out date with a time component of 23:59. Test plan: 1) Without applying this patch, issue an item to a patron and notice that in the 'Checkouts' table the 'Checked out on' date is of the form YYYY-MM-DD HH:MM:SS. 2) Apply this patch, restart Plack if necessary. 3) Refresh the patron 'Checkouts' table: this time the 'Checked out on' date will observe the setting of your `dateformat` System Preference. 4) Extra credit: repeat step 3) for different `dateformat` settings, each time you should get a 'Checked out on' date that matches the date format you chose. --- koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 4 ++-- svc/checkouts | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js index 4920eccb9d..0d0333ef2b 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js @@ -426,7 +426,7 @@ $(document).ready(function() { }, { "iDataSort": 10, // Sort on hidden unformatted issuedate column - "mDataProp": "issuedate", + "mDataProp": "issuedate_formatted", }, { "mDataProp": function ( oObj ) { @@ -823,7 +823,7 @@ $(document).ready(function() { }, { "iDataSort": 7, // Sort on hidden unformatted issuedate column - "mDataProp": "issuedate", + "mDataProp": "issuedate_formatted", }, { "mDataProp": function ( oObj ) { diff --git a/svc/checkouts b/svc/checkouts index 20b1a34460..4163c9616f 100755 --- a/svc/checkouts +++ b/svc/checkouts @@ -288,6 +288,8 @@ while ( my $c = $sth->fetchrow_hashref() ) { return_claim_created_on_formatted => $c->{return_claim_created_on} ? output_pref({ dt => dt_from_string( $c->{return_claim_created_on} ) }) : undef, return_claim_updated_on_formatted => $c->{return_claim_updated_on} ? output_pref({ dt => dt_from_string( $c->{return_claim_updated_on} ) }) : undef, + issuedate_formatted => output_pref({ dt => dt_from_string( $c->{issuedate} ) }), + lost => $lost, claims_returned => $claims_returned, damaged => $damaged, -- 2.30.2