Reputation: 1045
I have a list of doctors and patients, whom have fixed schedules during several months (long treatments) as you can see in the image:
So Clarice will have an appointment with Dr. Fenwick every Monday from 09:00 to 10:00 until the schedule is deleted
I'm saving that info to the table as:
A) How should I generate a list of recurrent events from that table, so I can fill a jQuery fullcalendar component?
B) How much better (or optimal) would be to save the entire list of repeating recurrent events into the table?
The only advantages I see in B) would be the possibility to save a comment to each event, easy to load in fullcalendar, but I'd have lots of records and speed or loading time would be very affected because the data I showed is only 0.00001% of the real situation
Thanks for any idea/opinion you can suggest
Upvotes: 0
Views: 1119
Reputation: 96
As my comment is too long so I am adding my comment as an answer.
ok, While adding the recurring events you should have following inputs on the "Add Recurring Events" -
1) Occurence Type - Daily, Weekly, Month (as radiobuttons)
2) Recurring Days - Mon, Tue, Wed, Thu, Fri, Sat, Sun (as checkboxes)
3) Start Date and End Date
4) From Time and To Time
Now, If you select "Daily" option the "Recurring Days" and "End Date" should be hidden/disabled.
If you select "Weekly" All 3 should be enabled. here you need to calculate all dates between StartDate and EndDate as per the selected days from "Recurring Days" checkboxes eg. you selected
Occurence Type - Weekly
Recurring Days - Mon, Wed
Start Date - 6-July-2014
End Date - 20-July-2014
Write a js function as
GetWeeklyDates(startdate, enddate)
{
// sorry no time write by urself, I had done this at asp.net end
}
your GetWeeklyDates function should return you following Dates:- 7-July-2014,9-July-2014,14-July-2014,16-July-2014
So now it becomes simple, just append From Time and End Time to each date and
run a loop at php end to add the events on these dates.
you can also perform these algorithm at my sql end
just pass start datetime and end datetime to the procedure
write a function in my sql to get Weekly Dates/ Monthly Dates
and loop the insert appointment statement
HOPE it helps you.
Upvotes: 1