sort days in the schedule

This commit is contained in:
MaZderMind 2016-08-06 12:46:47 +02:00
parent 2bfe55c99c
commit 6250f381d6

View file

@ -85,8 +85,19 @@ class Schedule extends ModelBase
$day['end'] = $dayend; $day['end'] = $dayend;
} }
$dayidx = 0;
$daysSorted = [];
foreach($schedule->day as $day) foreach($schedule->day as $day)
{
$daysSorted[] = $day;
}
usort($daysSorted, function($a, $b) {
return (int)$a['start'] - (int)$b['start'];
});
$dayidx = 0;
foreach($daysSorted as $day)
{ {
$dayidx++; $dayidx++;
$daystart = (int)$day['start']; $daystart = (int)$day['start'];