I have some data in the database that represents the schedule for some workers at my company. It looks something like this:
Name In Out
Williams 00:00 8:00
Flores 8:00 15:00
Chernova 16:00 22:00
...
I need to display it like in the screenshot attached. I wanted to get your input for the algorithm. This is my idea, I'm sure it can be improved.
Create a row
for each day{
for each record{
for each row{
if space available in row{
put agent in space and mark used
}else if no more rows{
create new row and place agent and mark used
}else{
continue;
}
}
}
}
There might be more than one record for an agent each day (sometimes they can come in early in the morning for a little bit and then come back in the afternoon/evening). I have to be able to mark 30mins lunch breaks for longer shifts. I have to be able to mark when a user takes a shorter break. Also, shifts won't necessarily start/end every half hour.
This algorithm could take a lot of time to run if I have a lot of users and want to display the schedule for one whole week (7 = max number of days I'm going to allow to display).
All these constraints make me think about a good way to represent the data. A table would seem to be the logical way, but it might need a lot of calculations and html.
In sum, could you give me your opinion on:
1. my algorithm. How would you improve it? What other algorithm would you use?
2. How would display the actual schedule? table/css/other? (is there any cool html5 thing that could help?)
I'll really appreciate your help!😕