I have search over php mysql recurring events but didnt find anything exactly like i want.
I want to develop event sheduler in php mysql in which user add reccuring events based on daily,weekly,montly,yearly patterns using html form which is stored in mysql using php.
Like for example
user will enter start date,end date, what time event will happen(like 4:30pm) and duration of the event(like 2 hrs so it will make 430pm to 630pm event) with repeating patterns.For example event will repeat after 3 days , on monday and wednesday every week or after every two weeks, every 10th day of month or every 10th day after two months, on specific date every year or without any repeating patterns just add event for any specific date .
This information will be taken from user using html form and will be stored in mysql database and than it needs to display user upcoming events(e.g consider today is 13th july 2013 if recurring event is sheduled for 15th july 2013 it will consider as upcoming events) or events in the past(e.g consider today is 13th july 2013 if event is sheduled for 10th july 2013 it will be consider as past event) using php in two different ways using html table and arshaw full calendar.
I need help how i store event information in mysql database and than pull it using php and display upcoming or past events in html table and also be to integrate it arshaw full calendar.
This sort of stuff is already working in musicteacherhelper.com which also used php and mysql for implementing so i need to know is there any open source code available to implement this functionality.
Any help in this regard will be highly appreciated.
Thanks
Talha
use industry standard RRULE to store the informaton and some metadata of event in some mysql table for search purpose (example : date range)
http://www.kanzaki.com/docs/ical/rrule.html
demo : http://jkbr.github.io/rrule/
there are js and php libraries available for the same.
Related
I have two columns in my MySql database
activeAt(timestamp)
activeAtTime(time)
I want to fetch data that are less than activeAtTime(timestamp) and activeAt(time)
The problem I'm facing in my code is
if activeAt is 25th may & activeAtTime is 5pm of an particular post
and If the fetch the data with below code at 26th may 2pm it is not getting listed, but if i fetch at 26th may 5:30 pm the post is getting listed
(i used medoo, but you can suggest any query)
"activeAt[<=]" => date("Y-m-d"),
"activeAtTime[<=]" => date("H:i")
eg a post with activeAt and activeAtTime
If i make a fetch request at 25th may, 8 am this post is not getting listed
I'm trying to make a blogs that posts based on scheduled time and date
i tried bootstrap datetime picker but it didn't work
Is there any way i can combine activeAt and ActiveATtime
So that the above logic works
What will be the most efficient way to do it?.
I want to create a website with an scheduling calendar.
My first idea is to use some free calendar template or download some free scheduling calendar. Then in my scheduling form, when someone request for an schedule, I will get the date he/she input and save it into the database then show it to the scheduling calendar.
But someone told me that, in my database, I should create a calendar table.
Which is the best way around?
The first one with only one table for schedule on my database or the second one with two tables for schedule and calendar?
I hope you get my idea.
It could be first one. One of option is to keep data by day of year.
you can draw your own calendar by counting day of year
actual day of yaer - date('z') + 1; //+ 1 because it is an array it starts from 0
then you can get number of days in each month
cal_days_in_month
and loop it x 12 with
here will be day of month with css style so it looks like calendar field
your i++ will bee number of days in month of course.
Keep records in database by year and day of year. you can do so much things this way
What I am trying/wanting to do is changing the output of this JS calendar to become the same output format as PHP's date('W').
So for example, I am using the JS calendar pop up found here: http://www.mattkruse.com/javascript/calendarpopup/
When you choose a date from the calendar, an output is automatically generated and filled into the textbox in the format day/month/year
However, I dont want the output in the datebox to be generated as day month year....instead I want the generated output to be the week number user has chosen in the calendar...
So say I choose 8th January 2011 in the calendar pop up. Currently it will fill into the textbox 08/01/11...BUT what SHOULD happen is it puts into that textbox 2 as January 8th is the 2nd week in that year...How can I do this? I am stuck because if a user's current date is end of december and End date is january of the next year PHP's date command will think we are at a new year and it will mess up...I hope I am being clear...
This is what is happening...
User interface they have 2 textboxes,
each text box is associated to a calendar pop up. The output somehow wont be day/month/ear but instead the week of the year...
Once user chooses their options php in the backend will see what time gap the user has chosen using the function PHP's date ('W')
I am stuck on how to change the calendar date format into php's date('W') format.
Jacob Wrights Date.format supports 'W', which gives this:
ISO-8601 week number of year, weeks starting on Monday (added in PHP
4.1.0)
In order to do what you want you are going to have to write your own function, theres no magic built in way to do it in JavaScript like there is in php
http://techblog.procurios.nl/k/n618/news/view/33796/14863/Calculate-ISO-8601-week-and-year-in-javascript.html
http://www.irt.org/script/914.htm
http://javascript.about.com/library/blweekyear.htm
http://www.codeproject.com/KB/cs/gregorianwknum.aspx
http://www.onlineconversion.com/day_week_number.htm - working example, you can see how they do it by viewing their source
TLDR: Need to understand the best way for a user to be able to add a date(s) & time(s) for an event, and how to structure database
Explanation:
When a user adds an event, they need to be able to choose the date of the event, whether or not it will repeat daily/weekly/monthly, start and end time of the event or "all-day", if it's weekdays only or weekend...etc. Basically everything you can do w/ Google calendar when you create an event and they need to be able to edit it too (if that matters). But ALSO, they need to be able to add another date/time - for instance:
Add an event where on Monday and Wednesday of this week and three weeks from now, it goes from 8-10pm. On Tuesday and Thursday this week only, it goes from 6-9pm.
My thoughts so far:
Create a "dates" table with a HABTM relationship w/ my "events" table. When a user adds a date (with all the options of repeat..etc etc., it runs a function to process those repeats/limits...etc and adds all the dates into the dates table w/ their start/end times.
But - then how do I manage it if they want to edit that - since it just created multiple fields.
Question / Help?:
Am I even on the right track with this? I'm new to CakePHP, and it's hard for me to wrap my head around the best ways to do things... I'm not yet looking for technical help (would not turn it down though) - for now, I just need to get the idea for the best way to structure everything to be able to manage this. Maybe I need a "dates" table AND a "times" table? Maybe a "dates" table with an id that references many individual rows in a "dates_data" table?
Thank you very much ahead of time for any help / direction!
You're doing great. Let me just share my thoughts.
If I would design this, I'd have 3 models:
Event
id
user_id
description
created (datetime)
updated (datetime)
Schedule
id
event_id
description
start (datetime)
end (datetime)
duration (time, if empty(NULL) it means this is a whole day event)
repeat_time (e.g. 3:00pm means 3pm daily)
repeat_day (for weekly/monthly, e.g. Monday, Monday & Tuesday, Monday to Friday)
repeat_date (for monthly, e.g. 1 means every 1st day of month, 31 means every 31st or end of the month)
repeat_anniversary (for specific date every year, e.g. every December 25th)
Date
id
schedule_id
start (datetime)
end (datetime)
Now let's have an example of an event. Let's say we want an event that will repeat every Saturday and Sunday of May & June 2011 at 1:00pm until 3:00pm (two hours):
The events table contains the basic detail of an event. One record will be saved here.
The schedules table is separated so that you could add multiple schedules. One record will also be saved in schedule with the following fields:
duration: 02:00
start: 2011-05-01
end: 2011-06-30
repeat_time: 13:00:00
repeat_day: 01,07 (Sunday & Saturday)
Now on dates table, there will be 17 records, one for each occurrence of the schedule. The reason why I separated this is that it will be easier for me know when will the event fall. This will be useful, for example, when creating the calendar. One of the records for the dates table will look like this:
start: 2011-05-01 13:00:00
end: 2011-05-01 15:00:00
Now what if the user edits the schedule? The schedule record would be edited. All dates record would also be edited. You don't wanna delete and recreate the dates, since you might use each record for another model (e.g. user might want to tag other users as attendees for each date of the event).
I hope this helps. Goodluck on your project!
I want to create a php calender application. What is the optimal database design for this software if I want to create normal, weekly, monthly and yearly events.
I would just create an entry for each recurrence of the event, out to some horizon. However, it means that you'll need another table that you can use to project out the dates if they scan past your horizon date. I.e., you'll need an events table that contains one record for each occurrence of a repeated event (Jan 1, Jan 8, Jan 15, ... through December), and a table with each record available to seed future years (start date: Jan 1; repeat: 7; through: 2011) so that at the start of 2012 (or as soon as the user requests a view of a 2012+ month) you can generate the future events.
This has two big disadvantages:
Your database has data for a full year. However, if adding a full year's worth of data ruins your performance, your system is probably underpowered. (It seems a requirement that a calendar app be able to handle many years' worth of dates)
At the end of the event horizon, you need to generate the future dates for recurring events.
The advantages (IMO) that outweigh the disadvantages:
Easier math when displaying the calendar. Using Tim's method, above, if the user loads Dec 18, 2011, how are you going to calculate which recurring events should be placed on that day? You'll be forced to loop through EVERY recurring event every time you display a date. The tradeoff is disadvantage #1, which I think is the better solution that having to redo these calculations.
You can edit specific instances of an event. Using Tim's method, if a meeting occurred on a holiday and the user changed it to the previous day, how would you even do it? Using the one-entry-per-event method described here, you could just modify that record for the event, easily moving single occurrences around in the calendar.
You could have a column in the EVENT table for RECURRENCE_STATUS which tracks 4 values, does not recur, weekly, monthly, yearly. The query of the day's events would be a union of those that are set to occur on that day and which do not recur with the set of those that do recur and whose initial date's difference from today is a modulo 0 for week, month, and a year differences. The date-math calculations are a little more nuanced than that (because of the varying number of days in the month) but the structure should suffice.