in reply to Rostering Staff: Architecture? Not strictly Perl
Or even, a date-oriented structure, since the shifts repeat themselves daily as well. So you'd have a table with shifts and shift IDs, a table with employees and employee IDs, and a table combining the two, mapping date, shift ID and employee ID together. This third table can then continue indefinitely (tho of course you'll probably want to periodically remove old data). It has a double-index of date and shift ID.
Code-wise, you then calculate 'today and next seven days', look up those dates in the table, translating shift IDs to times, and employee IDs to names as you go, and making some sort of hash:
Which you can display and/or work on as required. I hope this makes some sort of sense, Im just thinking as I type (which sometimes has weird results..)%current = ( '2003-12-05' => { { 'time' => '9:00 AM', 'id' => 1, 'employee' => {'id' => 1, 'name => 'Fred Flintst +one', } }, { 'time' => '5:00 PM', 'id' => 2, 'employee' => { 'id' => 4, 'name' => 'Wilma', } { 'time' => '1:00 AM', 'id' => 3, 'employee' => { 'id' => 3, 'name' => 'Barney', } }, '2003-12-06' => { ... }
C.
|
|---|