Merge pull request #12243 from TobiasSekan/FixEventSortNonNumeric

Fix non-numeric error in sort event function
This commit is contained in:
Laurent Destailleur 2019-10-30 02:57:00 +01:00 committed by GitHub
commit 6073692654
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
}