I am coding some kind of graph and am stuck in iteration by dates.
I have a timeline generated within 5 business days, starting from 6:00 to 18:30. It's not a problem. I have a table with users and a table with dates. Users can have several tasks during the week.
This is an array:
Array ( [0] => Array ( [dateStart] => 2011-09-14 13:00:00 [dateEnd] => 2011-09-15 11:00:00 [eventType] => 1 [data] => test [taskDescription] => Vakantieverlof [taskColor] => ff6600 ) [1] => Array ( [dateStart] => 2011-09-14 15:00:00 [dateEnd] => 2011-09-14 18:00:00 [eventType] => 3 [data] => [taskDescription] => ADV [taskColor] => 336600 ) [2] => Array ( [dateStart] => 2011-09-15 16:00:00 [dateEnd] => 2011-09-16 10:00:00 [eventType] => 2 [data] => [taskDescription] => Ziek [taskColor] => ff0000 ) )
And this is a loop through the array:
$dat=0; while($dat<count($row->dates)) { $color = "cccccc"; if(!empty($row->dates[$dat]['taskColor'])) { $color = $row->dates[$dat]['taskColor']; $desc = $row->dates[$dat]['taskDescription']; } else { $color = "cccccc"; } $datNext = $dat+1; if($datNext >= count($row->dates)) $datNext = $dat; if($row->dates[$datNext]['dateStart'] >= $hourCons AND $dat >= count($row->dates)) { $dat++; } else { if( $row->dates[$dat]['dateStart'] < $hourConsEnd AND $row->dates[$dat]['dateEnd'] > $hourCons ) { $wpcal .= "<div class=\"fullCell\" style=\"".$transparent." background-color: #".$color.";\"></div>"; } else { $wpcal .= "<div class=\"emptyCell\" style=\"\"></div>"; } } $dat++; }
Now I get 3 timelines representing each scheduled task. eg:
Screen shot
But I want 1 timeline containing each of these tasks ... The green task in this case may overlap the orange.
Please help, I will do this a couple of days ...
source share