From bfe7ad211f5b6bc46377133781b5c19f5a55e01f Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Mon, 28 Oct 2019 09:53:27 +0100 Subject: [PATCH] Fix non-numeric error in sort event function Fix non-numeric error in sort event function and fix mixed space and tab indent, use spaces --- htdocs/comm/action/index.php | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index d503c1bc71d..b56910bb89d 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1729,11 +1729,24 @@ function dol_color_minus($color, $minus, $minusunit = 16) */ function sort_events_by_date($a, $b) { - if($a->datep != $b->datep) - { - return $a->datep - $b->datep; - } + if($a->datep != $b->datep) + { + return $a->datep - $b->datep; + } - // If both events have the same start time, longest first - return $b->datef - $a->datef; + // If both events have the same start time, longest first + + if(! is_numeric($b->datef)) + { + // when event B have no end timestamp, event B should sort be before event A (All day events on top) + return 1; + } + + if(! is_numeric($a->datef)) + { + // when event A have no end timestamp , event A should sort be before event B (All day events on top) + return -1; + } + + return $b->datef - $a->datef; }