By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,946 Members | 741 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

Inserting alternating event/appointment type using time and date range

P: 41
Hi

I need help.

I know what I want to accomplish, but I do not know how to do it.

WHAT I NEED HELP ACCOMPLISHING:
How to do I insert data into a table for a date range of two or more months,
where every second or third week should be able to have different events/appointments.

POSSIBLE APPROACH:
I would like to choose a 7 day cycle/template, or to allow making the weeks
different with a 14 day or 21 day or 28 day cycle/template.

For example the 14 days cycle represents two weeks where every second week can be different.

Day# Day
1
2 Monday (meetings 1:00pm to 3:00pm)
3 Tuesday
4 Wednesday
5 Thursday (breakfast meeting 8:00AM to 9:00AM)
6 Friday
7
8
9 Monday (breakfast meeting 8:00AM to 9:00AM)
10 Tuesday
11 Wednesday (meetings 1:00pm to 3:00pm)
12 Thursday
13 Friday
14


The current code works well for a week or if every week is the same in the date range.
See below.

The availablity table store different event/appointment types using date and time range.
This event/appointment type information is then displayed to the user using a daily
schedule format.

HOW THE 7 DAY CYCLE DATA IS STORED:
Example: Meetings(event_type_code) between 2:30 PM and 4:30 PM for Monday to Friday
this is stored in the "availablity" table as seen below.

Note: A template group holds the different appointment types for the days of the
week as selected.

|group_id|start_time|end_time| start_date|end_date | week_day|type_code
|26 |14:30:00 |16:30:00| 2007-12-03|2007-12-07| 550 | 201
|26 |14:30:00 |16:30:00| 2007-12-03|2007-12-07| 551 | 201
|26 |14:30:00 |16:30:00| 2007-12-03|2007-12-07| 552 | 201
|26 |14:30:00 |16:30:00| 2007-12-03|2007-12-07| 553 | 201
|26 |14:30:00 |16:30:00| 2007-12-03|2007-12-07| 554 | 201


CODE FOR ONE WEEK CYCLE
[php]
<?
$group_seg = array();

/*get group templates data to apply to schedule. This data contains
event/appointment types*/
$query = "SELECT distinct(s.seg_id), s.model_id, w.group_id, s.event_type_code,
s.time_from, s.time_to, w.weekday
FROM cal_group_week w, cal_day_segment s
WHERE s.model_id = w.model_id
AND w.group_id = '$group_id'
AND s.deleted = 'N'
AND w.deleted = 'N'";
$result = mysqli_query ($mysqli, $query);
while($row = mysqli_fetch_array($result))
{
$group_seg[] = $row;
}


//loop through segment start and end time
foreach($group_seg as $group_segment)
{
//database stored time from daily model segments
$start_time = $group_segment['time_from'];
$end_time = $group_segment['time_to'];
$group_id = $group_segment['group_id'];
$event_type_code = $group_segment['event_type_code'];
$day = $group_segment['weekday'];



/**-----------------------insert event type/appointment---------------------**/

$cal_query = "INSERT INTO availablity(
time_id, group_id, start_time, end_time,
start_date, end_date, week_day,
type_code)
VALUES(
null, '$group_id', '$start_time', '$end_time', '$start_date',
'$end_date', '$day', '$event_type_code')";

mysqli_query($mysqli, $cal_query)or die(mysqli_error($mysqli));

}//apply group


?>
[/php]
Dec 29 '07 #1
Share this Question
Share on Google+
1 Reply


P: 41
Hi

I hope this better explains what I am trying to accomplish.

The events are recurring every month, but not recurring at the same time or on the same day of the week.

Thank
Dec 29 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.