Skip to content

Commit

Permalink
Merge pull request #11024 from ATM-Marc/FIX_7.0_sort_events
Browse files Browse the repository at this point in the history
FIX: actioncomm: sort events by date after external calendars and hook
  • Loading branch information
eldy committed Apr 16, 2019
2 parents 9d81455 + c0defe3 commit 5c53044
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions htdocs/comm/action/index.php
Expand Up @@ -1009,6 +1009,11 @@
}
}

// Sort events
foreach($eventarray as $keyDate => &$dateeventarray)
{
usort($dateeventarray, 'sort_events_by_date');
}


$maxnbofchar=0;
Expand Down Expand Up @@ -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;
}

0 comments on commit 5c53044

Please sign in to comment.