I’m going to represent a week schedule of worktime for employees, with IN and OUT time for morning and afternoon shift. The schedules could vary from one month another.
IDEA #1:
An UGLY solution could be:
tbl_schedules:
ID
employee_id
start_date
end_date
monday_morning_in
monday_morning_out
monday_afternoon_in
monday_afternoon_out
tuesday ...
This works perfectly with ActiveRecords but it’s not elegant, and then if an employee does 3 shifts per day there’s no way to represent it.
IDEA #2:
tbl_schedules:
ID
employee_id
start_date
end_date
tbl_ranges:
ID
in
out
tbl_shifts: (two or more records per working day)
ID
schedule_id
range_id
day_of_week (1 = monday, 2 = tuesday, ..)
In this case, how would it work in terms of form (ActiveForm or just Cform? which names give to fields? would it be a nested form?) and controller (would the saving be automatic - it means no code and ActiveRecords does the job? or would the controller contain a big routine for creating all the necessary Schedule, Range and Shift model objects and saving them?) ?