diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index de7c43092b6..84719bc8673 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1009,6 +1009,11 @@ if (! empty($hookmanager->resArray['eventarray'])) { } } +// Sort events +foreach($eventarray as $keyDate => &$dateeventarray) +{ + usort($dateeventarray, 'sort_events_by_date'); +} $maxnbofchar=0; @@ -1701,3 +1706,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; +} diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 8893447ebf3..01efe621dc8 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -28,6 +28,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; // Load translation files required by the page $langs->loadLangs(array('compta', 'banks', 'bills'));