Bug 33804: Use as_due_date to display due dates

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Jonathan Druart 2023-05-23 12:16:55 +02:00 committed by Tomas Cohen Arazi
parent fb040a330f
commit 1000ab402b
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
4 changed files with 13 additions and 22 deletions

View file

@ -42,9 +42,10 @@
*/
window.$date = function(value, options) {
if(!value) return '';
var tz = (options&&options.tz)||def_tz;
let tz = (options&&options.tz)||def_tz;
let no_tz_adjust = (options&&options.no_tz_adjust)||false;
var m = dayjs(value);
if ( ! value.match(/^\d{4}-\d{2}-\d{2}$/ ) ) {
if ( !no_tz_adjust && ! value.match(/^\d{4}-\d{2}-\d{2}$/ ) ) {
m = m.tz(tz);
}

View file

@ -870,6 +870,7 @@
[% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
[% PROCESS 'modal-claims.inc' %]
[% PROCESS 'modal-claims-js' %]
[% INCLUDE 'js-date-format.inc' %]
<script>
/* Set some variable needed in circulation.js */

View file

@ -308,10 +308,10 @@ $(document).ready(function() {
{
"iDataSort": 2, // Sort on hidden unformatted date due column
"mDataProp": function( oObj ) {
var due = oObj.date_due_formatted;
if ( oObj.date_due_overdue ) {
due = "<span class='overdue'>" + due + "</span>";
}
let date_due_formatted = $datetime(oObj.date_due, { as_due_date: true, no_tz_adjust: true });
var due = oObj.date_due_overdue
? "<span class='overdue'>" + date_due_formatted + "</span>"
: date_due_formatted;
due = "<span id='date_due_" + oObj.itemnumber + "' class='date_due'>" + due + "</span>";
@ -426,7 +426,7 @@ $(document).ready(function() {
},
{
"iDataSort": 10, // Sort on hidden unformatted issuedate column
"mDataProp": "issuedate_formatted",
"mDataProp": "issuedate",
},
{
"mDataProp": function ( oObj ) {
@ -729,10 +729,11 @@ $(document).ready(function() {
"mDataProp": function( oObj ) {
var today = new Date();
var due = new Date( oObj.date_due );
let date_due_formatted = $datetime(oObj.date_due, { as_due_date: true, no_tz_adjust: true });
if ( today > due ) {
return "<span class='overdue'>" + oObj.date_due_formatted + "</span>";
return "<span class='overdue'>" + date_due_formatted + "</span>";
} else {
return oObj.date_due_formatted;
return date_due_formatted;
}
}
},
@ -822,7 +823,7 @@ $(document).ready(function() {
},
{
"iDataSort": 7, // Sort on hidden unformatted issuedate column
"mDataProp": "issuedate_formatted",
"mDataProp": "issuedate",
},
{
"mDataProp": function ( oObj ) {

View file

@ -288,18 +288,6 @@ 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} ),
as_due_date => 1
}
),
date_due_formatted => output_pref(
{
dt => dt_from_string( $c->{date_due} ),
as_due_date => 1
}
),
lost => $lost,
claims_returned => $claims_returned,
damaged => $damaged,