From 1669d497b43f08143791d81c93cc593be32c45d4 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Tue, 16 Apr 2019 17:36:03 +0200 Subject: [PATCH 1/2] FIX: actioncomm: sort events by date after external calendars and hook --- htdocs/comm/action/index.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 4a909f1adeb..3145fc649ef 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1001,6 +1001,11 @@ if (! empty($hookmanager->resArray['eventarray'])) { } } +// Sort events +foreach($eventarray as $keyDate => &$dateeventarray) +{ + usort($dateeventarray, 'sort_events_by_date'); +} $maxnbofchar=0; @@ -1630,3 +1635,22 @@ function dol_color_minus($color, $minus, $minusunit = 16) } return $newcolor; } + + +/** + * Sort events by date + * + * @param object $a Event A + * @param object $b Event B + * @return int < 0 if event A should be before event B, > 0 otherwise, 0 if they have the exact same time slot + */ +function sort_events_by_date($a, $b) +{ + 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; +} \ No newline at end of file From c0defe3965a7b65607d89e3e55b8dc7f162238b1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 16 Apr 2019 23:27:45 +0200 Subject: [PATCH 2/2] Update index.php --- htdocs/comm/action/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 3145fc649ef..358da27b07b 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1653,4 +1653,4 @@ function sort_events_by_date($a, $b) // If both events have the same start time, longest first return $b->datef - $a->datef; -} \ No newline at end of file +}