home *** CD-ROM | disk | FTP | other *** search
- <?php
-
-
- //show_days is the number of days to show (defined in index.php)
- //max_columns (defined in index.php)
- //day_start is the first day of the week (defined in index.php)
-
- if ($show_days > 29)
- {
- $day = 1;
- }
- if ($show_days > 4)
- {
- //calculate the first day to display in the week view.
- $weekday = date("w", $local_browse_time);
- $tmpday = $day - $weekday + $_SESSION['GO_SESSION']['first_weekday'];
- if ($tmpday > $day)
- {
- $tmpday = $tmpday -7;
- }
- $new_time = mktime(0,0,0,$month, $tmpday, $year);
- $day = date("j", $new_time);
- $month = date('m', $new_time);
- $year = date('Y', $new_time);
- }
-
- $interval_start_time = mktime(0,0,0,$month, $day, $year)-($_SESSION['GO_SESSION']['timezone']*3600);
- $interval_end_time = mktime(0,0,0,$month, $day+$show_days, $year)-($_SESSION['GO_SESSION']['timezone']*3600)-1;
-
- $events = $cal->get_events_in_array($calendar_id, 0, $interval_start_time, $interval_end_time, $day, $month, $year, $_SESSION['GO_SESSION']['timezone'], $calendar['start_hour']);
-
- //var_dump($events);
- //display the calendar
-
- echo '<table border="0"><tr><td><h3>';
- echo $sc_view.': </h3></td><td>';
- $dropbox = new dropbox();
- $dropbox->add_value('1', '1 '.$sc_day);
- $dropbox->add_value('2', '2 '.$sc_days);
- $dropbox->add_value('5', '5 '.$sc_days);
- $dropbox->add_value('7', '1 '.$sc_week);
- $dropbox->add_value('14', '2 '.$sc_weeks);
- $dropbox->add_value('21', '3 '.$sc_weeks);
- $dropbox->add_value('35', '1 '.$sc_month);
- $dropbox->print_dropbox("show_days", $show_days, 'onchange="javascript:document.forms[0].submit()"');
-
- echo '</td><td><h3><a href="javascript:goto_date('.($day-$show_days).', '.$month.', '.$year.');"><<</a> ';
- echo date($_SESSION['GO_SESSION']['date_format'], $interval_start_time+($_SESSION['GO_SESSION']['timezone']*3600)).' - '.date($_SESSION['GO_SESSION']['date_format'], $interval_end_time+($_SESSION['GO_SESSION']['timezone']*3600));
- echo ' <a href="javascript:goto_date('.($day+$show_days).', '.$month.', '.$year.');">>></a>';
- echo '</h3></td></tr></table>';
-
-
- echo '<table id="cal" width="100%">';
- $rows = $show_days/$max_columns;
- for($row=0;$row<$rows;$row++)
- {
- $start_day = $row*$max_columns;
- $end_day = $start_day+$max_columns;
-
- if ($end_day > $show_days)
- {
- $end_day = $show_days;
- }
-
- $weeknumber = date("W", mktime(0,0,0,$month,$day+$start_day,$year));
-
- echo '<tr><td colspan="99" align="center" class="cal_title">';
- echo $sc_week.' '.$weeknumber;
- echo '</td></tr>';
- //create table headings
- echo '<tr>';
- echo '<th width="40"></th>';
-
- for ($day_offset=$start_day;$day_offset<$end_day;$day_offset++)
- {
- $day_to_display = $day+$day_offset;
- $new_time = mktime(0,0, 0, $month, $day_to_display, $year);
- $new_date = date(DB_DATE_FORMAT, $new_time);
- $new_day = date('j', $new_time);
- $new_month = date('m', $new_time);
- $new_year = date('Y', $new_time);
-
- //get holiday name if ever
- $holiday_name = "";
- if($holidays->get_holiday($GO_SECURITY->user_id, $calendar_id, $new_time))
- {
- $holiday_name = $holidays->f("name");
- }
-
- if ($new_date == $current_date)
- {
- $class="HoverLinkSelected";
- }else
- {
- $class="HoverLink";
- }
- $weekday = date('w', $new_time);
- echo '<th><a href="index.php?calendar_id='.$calendar_id.'&year='.$new_year.'&month='.$new_month.'&day='.$new_day.'&show_days=1" class="'.$class.'">'.$full_days[$weekday].'<br />'.date($_SESSION['GO_SESSION']['date_format'],$new_time).'<br />'.$holiday_name.'</a>';
- //$update_reminder = $cal->get_next_recurrence_time(47, $new_time);
-
- //echo date(DB_DATETIME_FORMAT, $update_reminder);
- echo '</th>';
- }
- echo '</tr>';
-
- //process the all day events
-
- if (count($events['all_day']))
- {
- echo '<tr id="cal_all_day_events">';
- echo '<td class="cal_hour"></td>';
-
- for ($day_offset=$start_day;$day_offset<$end_day;$day_offset++)
- {
- echo '<td>';
- $day_to_display = $day+$day_offset;
- $new_time = mktime(0,0, 0, $month, $day_to_display, $year);
- $new_date = date('Ymd', $new_time);
- if (isset($events['all_day'][$new_date]))
- {
- $all_day_event_count = count($events['all_day'][$new_date]);
-
- $height = round(100/$all_day_event_count,1);
- $height .= '%';
-
- while ($event = array_shift($events['all_day'][$new_date]))
- {
- echo '<table id="cal_event" width="100%" style="background-color: #'.$event['background'].'" height="'.$height.'"><tr><td width="100%">';
- $link = $event['write_permission'] ? 'event.php' : 'show_event.php';
- echo '<a class="calendar_event_link" href="'.$link.'?event_id='.$event['id'].'">'.$event['name'].'</a>';
- echo'<br />';
- if (date($_SESSION['GO_SESSION']['date_format'], $event['start_time']) != date($_SESSION['GO_SESSION']['date_format'], $event['end_time']))
- {
- echo date($_SESSION['GO_SESSION']['date_format'], $event['start_time']).' - '.date($_SESSION['GO_SESSION']['date_format'], $event['end_time']).'<br />';
- }
- echo show_profile($event['user_id'], '', 'small_underline');
- if (($calendar['write_permission'] || $event['write_permission']) && !$print)
- {
- echo '</td><td valign="top" width="16" style="background-color: #'.$event['background'].'">';
- echo '<a href="delete_event.php?event_id='.$event['id'].'&return_to='.rawurlencode($_SERVER['REQUEST_URI']).'" title="'.$strDeleteItem.' "\''.$cal->f("name").'\'"><img src="'.$GO_THEME->images['delete'].'" border="0"></a>';
-
- }
- echo '</td></tr></table>';
- }
- echo '</td>';
- }
- }
- echo '</tr>';
- }
-
- for ($hour_of_day=$calendar['start_hour'];$hour_of_day<=$calendar['end_hour'];$hour_of_day++)
- {
- echo '<tr id="'.$row.'_'.$hour_of_day.'"><td width="40" align="right" class="cal_hour">'.$hour_of_day.':00</td>';
-
- //display the days row by row
- for ($day_offset=$start_day;$day_offset<$end_day;$day_offset++)
- {
- $day_to_display = $day+$day_offset;
-
- //make a valid date
- $new_time = mktime(0,0, 0, $month, $day_to_display, $year);
- $new_date = date('Ymd', $new_time);
- $new_day = date("j", $new_time);
- $new_month = date('m', $new_time);
- $new_year = date('Y', $new_time);
-
-
- if(isset($events['timed'][$new_date][$hour_of_day]))
- {
- echo '<td height="100%">';
- $hour_event_count = count($events['timed'][$new_date][$hour_of_day]);
-
- $height = round(100/$hour_event_count,1);
- $height .= '%';
- while($event = array_shift($events['timed'][$new_date][$hour_of_day]))
- {
- echo '<table id="cal_event" width="100%" height="'.$height.'" style="background-color: #'.$event['background'].'"><tr><td width="100%">';
- $link = $event['write_permission'] ? 'event.php' : 'show_event.php';
- echo '<a class="calendar_event_link" href="'.$link.'?event_id='.$event['id'].'&return_to='.rawurlencode($_SERVER['REQUEST_URI']).'">'.$event['name'].'</a>';
- echo'<br />';
- if (date($_SESSION['GO_SESSION']['date_format'], $event['start_time']) != date($_SESSION['GO_SESSION']['date_format'], $event['end_time']))
- {
- $date_format = $_SESSION['GO_SESSION']['date_format'].' '.$_SESSION['GO_SESSION']['time_format'];
- }else
- {
- $date_format = $_SESSION['GO_SESSION']['time_format'];
- }
- echo date($date_format, $event['start_time']).' - '.date($date_format, $event['end_time']).'<br />';
-
- echo show_profile($event['user_id'], '', 'small_underline');
- if (($calendar['write_permission'] || $event['write_permission']) && !$print)
- {
- echo '</td><td valign="top" width="16">';
- echo '<a href="delete_event.php?event_id='.$event['id'].'&return_to='.rawurlencode($_SERVER['REQUEST_URI']).'" title="'.$strDeleteItem.' "\''.$cal->f("name").'\'"><img src="'.$GO_THEME->images['delete'].'" border="0"></a>';
- }
- echo '</td></tr></table>';
-
- }
- }else
- {
- if (isset($events['backgrounds'][$new_date][$hour_of_day]))
- {
- $style = ' style="background-color: #'.$events['backgrounds'][$new_date][$hour_of_day].'"';
- }else
- {
- $style = '';
- }
- echo '<td height="100%"'.$style.'>';
- if(!$print && $calendar['write_permission'])
- {
- echo '<a onmouseover="javascript:glow_row(\''.$row.'_'.$hour_of_day.'\');" onmouseout="javascript:unglow_row(\''.$row.'_'.$hour_of_day.'\');" href="event.php?calendar_id='.$calendar_id.'&day='.$new_day.'&month='.$new_month.'&year='.$new_year.'&hour='.$hour_of_day.'"><img border="0" width="100%" height="12" src="'.$GO_THEME->images['blank'].'" /></a>';
- }
-
- }
- echo '</td>';
- }
- echo '</tr>';
- }
-
- }
- echo '</table>';
- ?>
- <script type="text/javascript">
-
- function glow_row(hour)
- {
- table_row = get_object(hour);
- table_row.style.backgroundColor = '#FFFFCC';
- }
-
- function unglow_row(hour)
- {
- table_row = get_object(hour);
- table_row.style.backgroundColor = '';
- }
- </script>
-