include "includes/js.php"; if ($auto_refresh == "Y" && !empty($auto_refresh_time)) { $refresh = $auto_refresh_time * 60; // convert to seconds echo "<META HTTP-EQUIV=\"refresh\" content=\"{$refresh}; URL=week.php?{$u_url}" . "date={$startdate}{$caturl}\" TARGET=\"_self\">\n"; } ?> </HEAD> <BODY BGCOLOR=<?php echo "\"{$BGCOLOR}\""; ?> CLASS="defaulttext"> <?php /* Pre-Load the repeated events for quckier access */ $repeated_events = read_repeated_events(strlen($user) ? $user : $login, $cat_id); /* Pre-load the non-repeating events for quicker access */ $events = read_events(strlen($user) ? $user : $login, $startdate, $enddate, $cat_id); for ($i = 0; $i < 7; $i++) { $days[$i] = $wkstart + 24 * 3600 * $i; $weekdays[$i] = weekday_short_name(($i + $WEEK_START) % 7); $header[$i] = $weekdays[$i] . "<BR>" . date_to_str(date("Ymd", $days[$i]), $DATE_FORMAT_MD, false); } ?> <TABLE BORDER="0" WIDTH="100%"> <TR> <?php if (empty($friendly) || !$friendly) { ?> <TD ALIGN="left"><A HREF="week.php?<?php
$start_date = date("Ymd", $start); $end_date = date("Ymd", $end); } else { // Programmer's bug (no translation needed) echo "Invalid cal_time_range setting for report id {$report_id}"; exit; } } } } } } } if (empty($error) && empty($list)) { $cat_id = empty($report_cat_id) ? "" : $report_cat_id; $repeated_events = read_repeated_events($report_user, $cat_id, $start_date); $events = read_events($report_user, $start_date, $end_date, $cat_id); $get_unapproved = $DISPLAY_UNAPPROVED == 'Y'; if ($report_user == "__public__") { $get_unapproved = false; } //echo "User: $report_user <br />\n"; //echo "Date Range: $start_date - $end_date <br /><br />\n"; $start_year = substr($start_date, 0, 4); $start_month = substr($start_date, 4, 2); $start_day = substr($start_date, 6, 2); $start_time = mktime(3, 0, 0, $start_month, $start_day, $start_year); $end_year = substr($end_date, 0, 4); $end_month = substr($end_date, 4, 2); $end_day = substr($end_date, 6, 2); $end_time = mktime(3, 0, 0, $end_month, $end_day, $end_year);
} } $next = mktime(3, 0, 0, $thismonth, $thisday + 7, $thisyear); $prev = mktime(3, 0, 0, $thismonth, $thisday - 7, $thisyear); // We add 2 hours on to the time so that the switch to DST doesn't // throw us off. So, all our dates are 2AM for that day. if ($WEEK_START == 1) { $wkstart = get_monday_before($thisyear, $thismonth, $thisday); } else { $wkstart = get_sunday_before($thisyear, $thismonth, $thisday); } $wkend = $wkstart + 3600 * 24 * 6; $startdate = date("Ymd", $wkstart); $enddate = date("Ymd", $wkend); /* Pre-Load the repeated events for quckier access */ $repeated_events = read_repeated_events($login, "", $startdate); /* Pre-load the non-repeating events for quicker access */ $events = read_events($login, $startdate, $enddate); for ($i = 0; $i < 7; $i++) { $days[$i] = $wkstart + 24 * 3600 * $i; $weekdays[$i] = weekday_short_name(($i + $WEEK_START) % 7); $header[$i] = $weekdays[$i] . "<br />" . month_short_name(date("m", $days[$i]) - 1) . " " . date("d", $days[$i]); } ?> <table style="border-width:0px; width:100%;" cellspacing="0" cellpadding="0"> <tr><td style="background-color:<?php echo $TABLEBG; ?> ;">
// Additionally, we only want to put at most 6 users in one table since // any more than that doesn't really fit in the page. // get users in this view $res = dbi_query("SELECT cal_login FROM webcal_view_user WHERE cal_view_id = {$id}"); $viewusers = array(); if ($res) { while ($row = dbi_fetch_row($res)) { $viewusers[] = $row[0]; } dbi_free_result($res); } $e_save = array(); $re_save = array(); for ($i = 0; $i < count($viewusers); $i++) { /* Pre-Load the repeated events for quckier access */ $repeated_events = read_repeated_events($viewusers[$i]); $re_save[$i] = $repeated_events; /* Pre-load the non-repeating events for quicker access */ $events = read_events($viewusers[$i], $startdate, $enddate); $e_save[$i] = $events; } for ($j = 0; $j < count($viewusers); $j += $USERS_PER_TABLE) { // since print_date_entries is rather stupid, we can swap the event data // around for users by changing what $events points to. // Calculate width of columns in this table. $num_left = count($viewusers) - $j; if ($num_left > $USERS_PER_TABLE) { $num_left = $USERS_PER_TABLE; } if ($num_left > 0) { if ($num_left < $USERS_PER_TABLE) {
$end_ind = 6; } } else { $start_ind = 0; $end_ind = 7; } $HeadX = ''; if ($auto_refresh == "Y" && !empty($auto_refresh_time)) { $refresh = $auto_refresh_time * 60; // convert to seconds $HeadX = "<meta http-equiv=\"refresh\" content=\"{$refresh}; url=week_details.php?{$u_url}" . "date={$startdate}{$caturl}\" />\n"; } $INC = array('js/popups.php'); print_header($INC, $HeadX); /* Pre-Load the repeated events for quckier access */ $repeated_events = read_repeated_events(strlen($user) ? $user : $login, $cat_id, $startdate); /* Pre-load the non-repeating events for quicker access */ $events = read_events(strlen($user) ? $user : $login, $startdate, $enddate, $cat_id); for ($i = 0; $i < 7; $i++) { $days[$i] = $wkstart + 24 * 3600 * $i; $weekdays[$i] = weekday_short_name(($i + $WEEK_START) % 7); $header[$i] = $weekdays[$i] . " " . date_to_str(date("Ymd", $days[$i]), $DATE_FORMAT_MD, false); } ?> <div class="title"> <a title="Previous" class="prev" href="week_details.php?<?php echo $u_url; ?> date=<?php echo date("Ymd", $prev) . $caturl;
// Get users in this view. $viewusers = view_get_user_list($id); $viewusercnt = count($viewusers); if ($viewusercnt == 0) { // This could happen if user_sees_only_his_groups = Y and // this user is not a member of any group assigned to this view. $error = translate('No users for this view'); } if (!empty($error)) { echo print_error($error) . print_trailer(); exit; } $e_save = $re_save = array(); for ($i = 0; $i < $viewusercnt; $i++) { /* Pre-Load the repeated events for quicker access */ $re_save[$i] = read_repeated_events($viewusers[$i], $wkstart, $wkend, ''); /* Pre-load the non-repeating events for quicker access subtracting ONE_WEEK to allow cross-dat events to display*/ $e_save[$i] = read_events($viewusers[$i], $wkstart - 604800, $wkend); } for ($j = 0; $j < 7; $j += $DAYS_PER_TABLE) { // Since print_date_entries is rather stupid, we can swap the event data // around for users by changing what $events points to. // . $tdw = 12; // Column width percent. echo ' <table class="main"> <tr> <th class="empty"> </th>'; $body = $header = '';
function TimeMatrix($date, $participants) { global $CELLBG, $TODAYCELLBG, $THFG, $THBG, $TABLEBG; global $user_fullname, $nowYmd, $repeated_events, $events; global $thismonth, $thisday, $thisyear; $increment = 15; $interval = 4; $cell_pix = 6; $participant_pix = '170'; //$interval = (int)(60 / $increment); $first_hour = $GLOBALS["WORK_DAY_START_HOUR"]; $last_hour = $GLOBALS["WORK_DAY_END_HOUR"]; $hours = $last_hour - $first_hour; $cols = $hours * $interval + 1; $total_pix = (int) ($cell_pix * $interval * $hours + $participant_pix); ?> <br /> <table class="matrixd" style="width:<?php echo $total_pix; ?> px;" cellspacing="0" cellpadding="0"> <tr><td class="matrix" colspan="<?php echo $cols; ?> "> <img src="pix.gif" alt="spacer" /> </td></tr> <tr><th style="width:<?php echo $participant_pix; ?> px;"> <?php etranslate("Participants"); ?> </th> <?php $str = ''; $MouseOut = "onmouseout=\"window.status=''; this.style.backgroundColor='" . $CELLBG . "';\""; $CC = 1; for ($i = $first_hour; $i < $last_hour; $i++) { for ($j = 0; $j < $interval; $j++) { $str .= ' <td style="width:' . $cell_pix . 'px;" id="C' . $CC . '" class="dailymatrix" '; switch ($j) { case 0: if ($interval == 4) { $k = $i <= 9 ? '0' : substr($i, 0, 1); } $str .= 'onmousedown="schedule_event(' . $i . ',' . $increment * $j . ");\" onmouseover=\"window.status='Schedule a " . $i . ':' . ($increment * $j <= 9 ? '0' : '') . $increment * $j . " appointment.'; this.style.backgroundColor='#CCFFCC'; return true;\" " . $MouseOut . " title=\"Schedule an appointment for " . $i . ':' . ($increment * $j <= 9 ? '0' : '') . $increment * $j . ".\">"; $str .= $k . "</td>\n"; break; case 1: if ($interval == 4) { $k = $i <= 9 ? substr($i, 0, 1) : substr($i, 1, 2); } $str .= 'onmousedown="schedule_event(' . $i . ',' . $increment * $j . ");\" onmouseover=\"window.status='Schedule a " . $i . ':' . $increment * $j . " appointment.'; this.style.backgroundColor='#CCFFCC'; return true;\" " . $MouseOut . " title=\"Schedule an appointment for " . $i . ':' . ($increment * $j <= 9 ? '0' : '') . $increment * $j . ".\">"; $str .= $k . "</td>\n"; break; default: $str .= 'onmousedown="schedule_event(' . $i . ',' . $increment * $j . ");\" onmouseover=\"window.status='Schedule a " . $i . ':' . $increment * $j . " appointment.'; this.style.backgroundColor='#CCFFCC'; return true;\" " . $MouseOut . " title=\"Schedule an appointment for " . $i . ':' . ($increment * $j <= 9 ? '0' : '') . $increment * $j . ".\">"; $str .= " </td>\n"; break; } $CC++; } } echo $str . "</tr>\n<tr><td class=\"matrix\" colspan=\"{$cols}\">\n<img src=\"pix.gif\" alt=\"spacer\" />\n</td></tr>\n"; // Display each participant for ($i = 0; $i < count($participants); $i++) { user_load_variables($participants[$i], "user_"); /* Pre-Load the repeated events for quckier access */ $repeated_events = read_repeated_events($participants[$i], "", $nowYmd); /* Pre-load the non-repeating events for quicker access */ $events = read_events($participants[$i], $nowYmd, $nowYmd); // get all the repeating events for this date and store in array $rep $rep = get_repeating_entries($participants[$i], $nowYmd); // get all the non-repeating events for this date and store in $ev $ev = get_entries($participants[$i], $nowYmd); // combine into a single array for easy processing $ALL = array_merge($rep, $ev); $all_events = array(); // exchange space for to keep from breaking $user_nospace = preg_replace('/\\s/', ' ', $user_fullname); foreach ($ALL as $E) { $E['cal_time'] = sprintf("%06d", $E['cal_time']); $Tmp['START'] = mktime(substr($E['cal_time'], 0, 2), substr($E['cal_time'], 2, 2), 0, $thismonth, $thisday, $thisyear); $Tmp['END'] = $Tmp['START'] + $E['cal_duration'] * 60; $Tmp['ID'] = $E['cal_id']; $all_events[] = $Tmp; } echo "<tr>\n<th class=\"row\" style=\"width:{$participant_pix}px;\">" . $user_nospace . "</th>\n"; $col = 1; for ($j = $first_hour; $j < $last_hour; $j++) { for ($k = 0; $k < $interval; $k++) { $border = $k == '0' ? ' border-left: 1px solid #000000;' : ""; $RC = $CELLBG; $TIME = mktime(sprintf("%02d", $j), $increment * $k, 0, $thismonth, $thisday, $thisyear); $space = " "; foreach ($all_events as $ET) { if ($TIME >= $ET['START'] && $TIME < $ET['END']) { $space = "<a class=\"matrix\" href=\"view_entry.php?id={$ET['ID']}\"><img src=\"pix.gif\" alt=\"spacer\" /></a>"; } } echo "\t<td class=\"matrixappts\" style=\"width:{$cell_pix}px;{$border}\">{$space}</td>\n"; $col++; } } echo "</tr><tr>\n<td class=\"matrix\" colspan=\"{$cols}\"><img src=\"pix.gif\" alt=\"spacer\" /></td></tr>\n"; } // End foreach participant echo "</table>\n"; }
$thisyear = substr($date, 0, 4); $thismonth = substr($date, 4, 2); $thisday = substr($date, 6, 2); } else { $thisday = empty($day) || $day == 0 ? date('d', $today) : $day; $thismonth = empty($month) || $month == 0 ? date('m', $today) : $month; $thisyear = empty($year) || $year == 0 ? date('Y', $today) : $year; } $next = mktime(0, 0, 0, $thismonth, $thisday + 7, $thisyear); $prev = mktime(0, 0, 0, $thismonth, $thisday - 7, $thisyear); $wkstart = get_weekday_before($thisyear, $thismonth, $thisday + 1); $wkend = $wkstart + 86400 * 6; $startdate = date('Ymd', $wkstart); $enddate = date('Ymd', $wkend); /* Pre-Load the repeated events for quckier access */ $repeated_events = read_repeated_events($login, $startdate, $enddate, ''); /* Pre-load the non-repeating events for quicker access */ $events = read_events($login, $startdate, $enddate); $first_hour = $WORK_DAY_START_HOUR; $last_hour = $WORK_DAY_END_HOUR; $untimed_found = false; $tmpOut1 = $tmpOut2 = ''; for ($i = 0; $i < 7; $i++) { $days[$i] = $wkstart + 86400 * $i; $date = date('Ymd', $days[$i]); $tmpOut1 .= ' <th style="width: 13%; background: ' . (date('Ymd', $days[$i]) == date('Ymd', $today) ? $TODAYCELLBG : $THBG) . ';">' . weekday_name(($i + $WEEK_START) % 7, $DISPLAY_LONG_DAYS) . '<br />' . month_name(date('m', $days[$i]) - 1, 'M') . ' ' . date('d', $days[$i]) . '</th>'; $tmpOut2 .= ' <td style="vertical-align: top; width: 75px; height: 75px; ' . 'background: ' . ($date == date('Ymd') ? $TODAYCELLBG : $CELLBG) . print_date_entries($date, $login, true, true) . ' </td>'; } echo '
} // Make sure they specified a username. $no_user = translate('No user specified.'); if (empty($user)) { die_miserable_death($no_user); } $get_unapproved = false; $datem = date('m'); $dateY = date('Y'); // Start date is beginning of this month. $startdate = mktime(0, 0, 0, $datem, 0, $dateY); // End date is one year from now. // Seems kind of arbitrary, eh? $enddate = mktime(0, 0, 0, $datem, 1, $dateY + 1); /* Pre-Load the repeated events for quicker access. */ $repeated_events = read_repeated_events($user, $startdate, $enddate, ''); /* Pre-load the non-repeating events for quicker access. */ $events = read_events($user, $startdate, $enddate); // Loop from start date until we reach end date... $event_text = ''; for ($d = $startdate; $d <= $enddate; $d += 86400) { $dYmd = date('Ymd', $d); $ev = get_entries($dYmd, $get_unapproved); $evcnt = count($ev); for ($i = 0; $i < $evcnt; $i++) { $event_text .= fb_export_time($dYmd, $ev[$i]->getDuration(), $ev[$i]->getTime(), 'ical'); } $revents = get_repeating_entries($user, $dYmd, $get_unapproved); $recnt = count($revents); for ($i = 0; $i < $recnt; $i++) { $event_text .= fb_export_time($dYmd, $revents[$i]->getDuration(), $revents[$i]->getTime(), 'ical');
// Get all users timezone settings. $res = dbi_query("SELECT cal_login, cal_value FROM webcal_user_pref " . "WHERE cal_setting = 'TZ_OFFSET'"); $tzoffset = array(); if ($res) { while ($row = dbi_fetch_row($res)) { $user = $row[0]; $user_tzoffset = $row[1]; $tzoffset[$user] = $user_tzoffset; if ($debug) { echo "TZ OFFSET for {$user} is \"{$user_tzoffset}\" <br>\n"; } } dbi_free_result($res); } // Now read events all the repeating events (for all users) $repeated_events = read_repeated_events(""); // Read non-repeating events (for all users) $startdate = date("Ymd"); $enddate = date("Ymd", time() + $DAYS_IN_ADVANCE * 24 * 3600); if ($debug) { echo "Checking for events from date {$startdate} to date {$enddate} <br>\n"; } $events = read_events("", $startdate, $enddate); if ($debug) { echo "Found " . count($events) . " events in time range. <br>\n"; } function indent($str) { return " " . str_replace("\n", "\n ", $str); } // Send a reminder for a single event for a single day to all
if (!empty($x)) { $numDays = $x; } // Don't let a malicious user specify more than 365 days if ($numDays > 365) { $numDays = 365; } $endDate = mktime(23, 59, 59, $thismonth, $thisday + $numDays, $thisyear); // If 'showEvents=0' is in URL, then just include tasks in list $show_events = getGetValue('showEvents', "[01]", true); $tasks_only = $show_events == '0'; if ($tasks_only) { $repeated_events = $events = array(); } else { /* Pre-Load the repeated events for quckier access */ $repeated_events = read_repeated_events($username, $startDate, $endDate, $cat_id); /* Pre-load the non-repeating events for quicker access */ $events = read_events($username, $startDate, $endDate, $cat_id); } // Pre-load tasks for quicker access */ if (empty($DISPLAY_TASKS_IN_GRID) || $DISPLAY_TASKS_IN_GRID == 'Y' || $showTasks) { /* Pre-load tasks for quicker access */ $tasks = read_tasks($username, $endDate, $cat_id); } } // Determine if this script is being called directly, or via an include. if (empty($PHP_SELF) && !empty($_SERVER) && !empty($_SERVER['PHP_SELF'])) { $PHP_SELF = $_SERVER['PHP_SELF']; } // If called directly print header stuff. if (!empty($PHP_SELF) && preg_match($name_of_this_file, $PHP_SELF)) {
// . // Get users in this view. $viewusers = view_get_user_list($id); if (count($viewusers) == 0) { // This could happen if user_sees_only_his_groups = Y and // this user is not a member of any group assigned to this view. $error = translate('No users for this view'); } if (!empty($error)) { echo print_error($error) . print_trailer(); exit; } $e_save = $re_save = array(); for ($i = 0, $cnt = count($viewusers); $i < $cnt; $i++) { /* Pre-Load the repeated events for quckier access */ $repeated_events = read_repeated_events($viewusers[$i], $startdate, $enddate, ''); $re_save = array_merge($re_save, $repeated_events); /* Pre-load the non-repeating events for quicker access */ $events = read_events($viewusers[$i], $startdate, $enddate); $e_save = array_merge($e_save, $events); } $events = $repeated_events = array(); for ($i = 0, $cnt = count($e_save); $i < $cnt; $i++) { $should_add = 1; for ($j = 0, $cnt_j = count($events); $j < $cnt_j && $should_add; $j++) { if (!$e_save[$i]->getClone() && $e_save[$i]->getID() == $events[$j]->getID()) { $should_add = 0; } } if ($should_add) { array_push($events, $e_save[$i]);
} load_user_preferences(); user_load_variables($login, 'minical_'); if ($user != '__public__' && !nonuser_load_variables($login, 'minica_')) { die_miserable_death(str_replace('XXX', $login, translate('No such nonuser calendar XXX.'))); } if ($user != '__public__' && (empty($minical_is_public) || $minical_is_public != 'Y')) { die_miserable_death(translate('This Calendar is not Public.')); } $next = mktime(0, 0, 0, $thismonth + 1, 1, $thisyear); $nextmonth = date('m', $next); $nextyear = date('Y', $next); $prev = mktime(0, 0, 0, $thismonth - 1, 1, $thisyear); $prevmonth = date('m', $prev); $prevyear = date('Y', $prev); $boldDays = true; $startdate = mktime(0, 0, 0, $thismonth, 0, $thisyear); $enddate = mktime(23, 59, 59, $thismonth + 1, 0, $thisyear); // Don't display custom header. print_header('', generate_refresh_meta(), '', true); /* Pre-Load the repeated events for quicker access. */ $repeated_events = read_repeated_events($user, $startdate, $enddate, $cat_id); /* Pre-load the non-repeating events for quicker access. */ $events = read_events($user, $startdate, $enddate, $cat_id); echo display_small_month($thismonth, $thisyear, true, false); // Reset...just in case. $login = ''; ?> </body> </html>
$nextmonth = substr($nextYmd, 4, 2); $prev = mktime(0, 0, 0, $thismonth - 1, 1, $thisyear); $prevYmd = date('Ymd', $prev); $prevyear = substr($prevYmd, 0, 4); $prevmonth = substr($prevYmd, 4, 2); if ($BOLD_DAYS_IN_YEAR == 'Y') { $boldDays = true; $startdate = mktime(0, 0, 0, $prevmonth, 0, $prevyear); $enddate = mktime(23, 59, 59, $nextmonth + 1, 0, $nextyear); } else { $boldDays = false; $startdate = mktime(0, 0, 0, $thismonth, 0, $thisyear); $enddate = mktime(23, 59, 59, $thismonth + 1, 0, $thisyear); } /* Pre-Load the repeated events for quicker access */ $repeated_events = read_repeated_events(!empty($user) && strlen($user) ? $user : $login, $startdate, $enddate, $cat_id); /* Pre-load the non-repeating events for quicker access */ $events = read_events(!empty($user) && strlen($user) ? $user : $login, $startdate, $enddate, $cat_id); if ($DISPLAY_TASKS_IN_GRID == 'Y') { /* Pre-load tasks for quicker access */ $tasks = read_tasks(!empty($user) && strlen($user) && $is_assistant ? $user : $login, $enddate, $cat_id); } $tableWidth = '100%'; $monthURL = 'month.php?' . (!empty($cat_id) ? 'cat_id=' . $cat_id . '&' : ''); $nextMonth1 = $nextMonth2 = $prevMonth1 = $prevMonth2 = ''; $printerStr = $smallTasks = $unapprovedStr = ''; if (empty($DISPLAY_TASKS) || $DISPLAY_TASKS == 'N' && $DISPLAY_SM_MONTH != 'N') { $nextMonth1 = display_small_month($nextmonth, $nextyear, true, true, 'nextmonth', $monthURL); $prevMonth1 = display_small_month($prevmonth, $prevyear, true, true, 'prevmonth', $monthURL); } if ($DISPLAY_TASKS == 'Y' && $friendly != 1) {
include "includes/js.php"; if ($auto_refresh == "Y" && !empty($auto_refresh_time)) { $refresh = $auto_refresh_time * 60; // convert to seconds echo "<META HTTP-EQUIV=\"refresh\" content=\"{$refresh}; URL=day.php?{$u_url}" . "date={$nowYmd}{$caturl}\" TARGET=\"_self\">\n"; } ?> </HEAD> <BODY BGCOLOR=<?php echo "\"{$BGCOLOR}\""; ?> CLASS="defaulttext"> <?php /* Pre-Load the repeated events for quckier access */ $repeated_events = read_repeated_events(empty($user) ? $login : $user, $cat_id); /* Pre-load the non-repeating events for quicker access */ $events = read_events(empty($user) ? $login : $user, $nowYmd, $nowYmd, $cat_id); ?> <TABLE BORDER="0" WIDTH="100%"> <TR><TD VALIGN="top" WIDTH="70%"><TR><TD> <TABLE BORDER="0" WIDTH="100%"> <TR> <?php if (empty($friendly)) { ?> <TD VALIGN="left"><A HREF="day.php?<?php echo $u_url; ?> date=<?php
$thisyear = substr($date, 0, 4); $thismonth = substr($date, 4, 2); $thisday = substr($date, 6, 2); $startTime = mktime(3, 0, 0, $thismonth, $thisday, $thisyear); $x = getIntValue("days", true); if (!empty($x)) { $numDays = $x; } // Don't let a malicious user specify more than 365 days if ($numDays > 365) { $numDays = 365; } $endTime = mktime(3, 0, 0, $thismonth, $thisday + $numDays, $thisyear); $endDate = date("Ymd", $endTime); /* Pre-Load the repeated events for quckier access */ $repeated_events = read_repeated_events($username, $cat_id, $date); /* Pre-load the non-repeating events for quicker access */ $events = read_events($username, $date, $endDate, $cat_id); // Print header without custom header and no style sheet ?> <html> <head> <title>Upcoming Events</title> </head> <body> <?php print "<dl>\n"; print "<!-- \nstartTime: {$startTime}\nendTime: {$endTime}\nstartDate: {$date}\nnumDays: {$numDays}\nuser: {$username}\nevents: " . count($events) . "\nrevents: " . count($revents) . " -->\n"; $numEvents = 0; for ($i = $startTime; date("Ymd", $i) <= date("Ymd", $endTime) && $numEvents < $maxEvents; $i += 24 * 3600) { $d = date("Ymd", $i);
} } } } } } } // The read_repeated_events calculates all event repeat dates for // some time period after the values of $thismonth and $thisyear. if (!empty($end_date)) { $thismonth = date('m', $end_date); $thisyear = date('Y', $end_date); } if (empty($error) && empty($list)) { $cat_id = empty($report_cat_id) ? '' : $report_cat_id; $repeated_events = read_repeated_events($report_user, $start_date, $end_date, $cat_id); $events = read_events($report_user, $start_date, $end_date, $cat_id); $get_unapproved = $DISPLAY_UNAPPROVED == 'Y'; // Loop through each day. // Get events for each day (both normal and repeating). // (Most of this code was copied from week.php.) for ($cur_time = $start_date; $cur_time <= $end_date; $cur_time += 86400) { $event_str = ''; $dateYmd = date('Ymd', $cur_time); $ev = combine_and_sort_events(get_entries($dateYmd), get_repeating_entries($report_user, $dateYmd)); for ($i = 0, $cnt = count($ev); $i < $cnt; $i++) { if ($get_unapproved || $ev[$i]->getStatus() == 'A') { $event_str .= event_to_text($ev[$i], $dateYmd); } } if (!empty($event_str) || $report_include_empty == 'Y' || $report_time_range < 10) {
if ($year != date("Y")) { $thismonth = 1; } if ($year > "1903") { $prevYear = $year - 1; } else { $prevYear = $year; } $nextYear = $year + 1; if ($allow_view_other != "Y" && !$is_admin) { $user = ""; } $boldDays = false; if (!empty($bold_days_in_year) && $bold_days_in_year == 'Y') { /* Pre-Load the repeated events for quckier access */ $repeated_events = read_repeated_events(!empty($user) && strlen($user) ? $user : $login, $cat_id, $year . "0101"); /* Pre-load the non-repeating events for quicker access */ $events = read_events(!empty($user) && strlen($user) ? $user : $login, $year . "0101", $year . "1231", $cat_id); $boldDays = true; } // Include unapproved events? $get_unapproved = $DISPLAY_UNAPPROVED == 'Y'; if ($user == "__public__") { $get_unapproved = false; } print_header(); ?> <div class="title"> <a title="<?php etranslate("Previous");
/** * Draws a daily outlook style availability grid showing events that are * approved and awaiting approval. * * @param string $date Date to show the grid for * @param array $participants Which users should be included in the grid * @param string $popup Not used */ function daily_matrix($date, $participants, $popup = '') { global $CELLBG, $TODAYCELLBG, $THFG, $THBG, $TABLEBG; global $user_fullname, $repeated_events, $events; global $WORK_DAY_START_HOUR, $WORK_DAY_END_HOUR, $TZ_OFFSET, $ignore_offset; $increment = 15; $interval = 4; $participant_pct = '20%'; //use percentage $first_hour = $WORK_DAY_START_HOUR; $last_hour = $WORK_DAY_END_HOUR; $hours = $last_hour - $first_hour; $cols = $hours * $interval + 1; $total_pct = '80%'; $cell_pct = 80 / ($hours * $interval); $master = array(); // Build a master array containing all events for $participants for ($i = 0; $i < count($participants); $i++) { /* Pre-Load the repeated events for quckier access */ $repeated_events = read_repeated_events($participants[$i], "", $date); /* Pre-load the non-repeating events for quicker access */ $events = read_events($participants[$i], $date, $date); // get all the repeating events for this date and store in array $rep $rep = get_repeating_entries($participants[$i], $date); // get all the non-repeating events for this date and store in $ev $ev = get_entries($participants[$i], $date); // combine into a single array for easy processing $ALL = array_merge($rep, $ev); foreach ($ALL as $E) { if ($E['cal_time'] == 0) { $E['cal_time'] = $first_hour . "0000"; $E['cal_duration'] = 60 * ($last_hour - $first_hour); } else { $E['cal_time'] = sprintf("%06d", $E['cal_time']); } $hour = substr($E['cal_time'], 0, 2); $mins = substr($E['cal_time'], 2, 2); // Timezone Offset if (!$ignore_offset) { $hour += $TZ_OFFSET; } while ($hour < 0) { $hour += 24; } while ($hour > 23) { $hour -= 24; } // Make sure hour is 2 digits $hour = sprintf("%02d", $hour); // convert cal_time to slot if ($mins < 15) { $slot = $hour . ''; } elseif ($mins >= 15 && $mins < 30) { $slot = $hour . '.25'; } elseif ($mins >= 30 && $mins < 45) { $slot = $hour . '.5'; } elseif ($mins >= 45) { $slot = $hour . '.75'; } // convert cal_duration to bars $bars = $E['cal_duration'] / $increment; // never replace 'A' with 'W' for ($q = 0; $bars > $q; $q++) { $slot = sprintf("%02.2f", $slot); if (strlen($slot) == 4) { $slot = '0' . $slot; } // add leading zeros $slot = $slot . ''; // convert to a string if (empty($master['_all_'][$slot]) || $master['_all_'][$slot]['stat'] != 'A') { $master['_all_'][$slot]['stat'] = $E['cal_status']; } if (empty($master[$participants[$i]][$slot]) || $master[$participants[$i]][$slot]['stat'] != 'A') { $master[$participants[$i]][$slot]['stat'] = $E['cal_status']; $master[$participants[$i]][$slot]['ID'] = $E['cal_id']; } $slot = $slot + '0.25'; } } } ?> <br /> <table align="center" class="matrixd" style="width:<?php echo $total_pct; ?> ;" cellspacing="0" cellpadding="0"> <tr><td class="matrix" colspan="<?php echo $cols; ?> "></td></tr> <tr><th style="width:<?php echo $participant_pct; ?> ;"> <?php etranslate("Participants"); ?> </th> <?php $str = ''; $MouseOut = "onmouseout=\"window.status=''; this.style.backgroundColor='" . $THBG . "';\""; $CC = 1; for ($i = $first_hour; $i < $last_hour; $i++) { $hour = $i; if ($GLOBALS["TIME_FORMAT"] == "12") { $hour %= 12; if ($hour == 0) { $hour = 12; } } for ($j = 0; $j < $interval; $j++) { $str .= ' <td id="C' . $CC . '" class="dailymatrix" '; $MouseDown = 'onmousedown="schedule_event(' . $i . ',' . sprintf("%02d", $increment * $j) . ');"'; switch ($j) { case 1: if ($interval == 4) { $k = $hour <= 9 ? '0' : substr($hour, 0, 1); } $str .= 'style="width:' . $cell_pct . '%; text-align:right;" ' . $MouseDown . " onmouseover=\"window.status='Schedule a " . $hour . ':' . ($increment * $j <= 9 ? '0' : '') . $increment * $j . " appointment.'; this.style.backgroundColor='#CCFFCC'; return true;\" " . $MouseOut . " title=\"Schedule an appointment for " . $hour . ':' . ($increment * $j <= 9 ? '0' : '') . $increment * $j . ".\">"; $str .= $k . "</td>\n"; break; case 2: if ($interval == 4) { $k = $hour <= 9 ? substr($hour, 0, 1) : substr($hour, 1, 2); } $str .= 'style="width:' . $cell_pct . '%; text-align:left;" ' . $MouseDown . " onmouseover=\"window.status='Schedule a " . $hour . ':' . $increment * $j . " appointment.'; this.style.backgroundColor='#CCFFCC'; return true;\" " . $MouseOut . " title=\"Schedule an appointment for " . $hour . ':' . ($increment * $j <= 9 ? '0' : '') . $increment * $j . ".\">"; $str .= $k . "</td>\n"; break; default: $str .= 'style="width:' . $cell_pct . '%;" ' . $MouseDown . " onmouseover=\"window.status='Schedule a " . $hour . ':' . ($increment * $j <= 9 ? '0' : '') . $increment * $j . " appointment.'; this.style.backgroundColor='#CCFFCC'; return true;\" " . $MouseOut . " title=\"Schedule an appointment for " . $hour . ':' . ($increment * $j <= 9 ? '0' : '') . $increment * $j . ".\">"; $str .= " </td>\n"; break; } $CC++; } } echo $str . "</tr>\n<tr><td class=\"matrix\" colspan=\"{$cols}\"></td></tr>\n"; // Add user _all_ to beginning of $participants array array_unshift($participants, '_all_'); // Javascript for cells $MouseOver = "onmouseover=\"this.style.backgroundColor='#CCFFCC';\""; $MouseOut = "onmouseout=\"this.style.backgroundColor='" . $CELLBG . "';\""; // Display each participant for ($i = 0; $i < count($participants); $i++) { if ($participants[$i] != '_all_') { // Load full name of user user_load_variables($participants[$i], "user_"); // exchange space for to keep from breaking $user_nospace = preg_replace('/\\s/', ' ', $user_fullname); } else { $user_nospace = translate("All Attendees"); $user_nospace = preg_replace('/\\s/', ' ', $user_nospace); } echo "<tr>\n<th class=\"row\" style=\"width:{$participant_pct};\">" . $user_nospace . "</th>\n"; $col = 1; $viewMsg = translate("View this entry"); // check each timebar for ($j = $first_hour; $j < $last_hour; $j++) { for ($k = 0; $k < $interval; $k++) { $border = $k == '0' ? ' border-left: 1px solid #000000;' : ""; $MouseDown = 'onmousedown="schedule_event(' . $j . ',' . sprintf("%02d", $increment * $k) . ');"'; $RC = $CELLBG; //$space = ''; $space = " "; $r = sprintf("%02d", $j) . '.' . sprintf("%02d", 25 * $k) . ''; if (empty($master[$participants[$i]][$r])) { // ignore this.. } else { if (empty($master[$participants[$i]][$r]['ID'])) { // This is the first line for 'all' users. No event here. $space = "<span class=\"matrix\"><img src=\"pix.gif\" alt=\"\" style=\"height: 8px\" /></span>"; } else { if ($master[$participants[$i]][$r]['stat'] == "A") { $space = "<a class=\"matrix\" href=\"view_entry.php?id={$master[$participants[$i]][$r]['ID']}\"><img src=\"pix.gif\" title=\"{$viewMsg}\" alt=\"{$viewMsg}\" /></a>"; } else { if ($master[$participants[$i]][$r]['stat'] == "W") { $space = "<a class=\"matrix\" href=\"view_entry.php?id={$master[$participants[$i]][$r]['ID']}\"><img src=\"pixb.gif\" title=\"{$viewMsg}\" alt=\"{$viewMsg}\" /></a>"; } } } } echo "<td class=\"matrixappts\" style=\"width:{$cell_pct}%;{$border}\" "; if ($space == " ") { echo "{$MouseDown} {$MouseOver} {$MouseOut}"; } echo ">{$space}</td>\n"; $col++; } } echo "</tr><tr>\n<td class=\"matrix\" colspan=\"{$cols}\">" . "<img src=\"pix.gif\" alt=\"-\" /></td></tr>\n"; } // End foreach participant echo "</table><br />\n"; $busy = translate("Busy"); $tentative = translate("Tentative"); echo "<table align=\"center\"><tr><td class=\"matrixlegend\" >\n"; echo "<img src=\"pix.gif\" title=\"{$busy}\" alt=\"{$busy}\" /> {$busy} \n"; echo "<img src=\"pixb.gif\" title=\"{$tentative}\" alt=\"{$tentative}\" /> {$tentative}\n"; echo "</td></tr></table>\n"; }
} $startdate = sprintf("%04d%02d01", $thisyear, $thismonth); $enddate = sprintf("%04d%02d31", $thisyear, $thismonth); $HeadX = ''; if ($auto_refresh == "Y" && !empty($auto_refresh_time)) { $refresh = $auto_refresh_time * 60; // convert to seconds $HeadX = "<meta http-equiv=\"refresh\" content=\"{$refresh}; url=day.php?{$u_url}" . "date={$nowYmd}{$caturl}" . (!empty($friendly) ? "&friendly=1" : "") . "\" />\n"; } $INC = array('js/popups.php'); print_header($INC, $HeadX); ?> <?php /* Pre-Load the repeated events for quckier access */ $repeated_events = read_repeated_events(empty($user) ? $login : $user, $cat_id, $startdate); /* Pre-load the non-repeating events for quicker access */ $events = read_events(empty($user) ? $login : $user, $startdate, $enddate, $cat_id); ?> <table> <tr><td style="vertical-align:top; width:82%;"> <div style="border-width:0px;"> <a title="<?php etranslate("Next"); ?> " class="next" href="day.php?<?php echo $u_url; ?> date=<?php echo $nextYmd . $caturl;
function daily_matrix($date, $participants, $popup = '') { global $CELLBG, $ENTRY_SLOTS, $events, $repeated_events, $TABLEBG, $THBG, $THFG, $thismonth, $thisyear, $TIME_FORMAT, $TODAYCELLBG, $user_fullname, $WORK_DAY_END_HOUR, $WORK_DAY_START_HOUR; $allAttendeesStr = translate('All Attendees'); $busy = translate('Busy'); $cnt = count($participants); $dateTS = date_to_epoch($date); $first_hour = $WORK_DAY_START_HOUR; $increment = intval(1440 / ($ENTRY_SLOTS > 288 ? 288 : ($ENTRY_SLOTS < 72 ? 72 : $ENTRY_SLOTS))); $last_hour = $WORK_DAY_END_HOUR; $master = array(); $MouseOut = $MouseOver = $str = ''; $participant_pct = '20%'; //Use percentage. $tentative = translate('Tentative'); // translate ( 'Schedule an appointment for' ) $titleStr = ' title="' . translate('Schedule an appointment for XXX.') . '">'; $viewMsg = translate('View this entry'); $hours = $last_hour - $first_hour; $interval = intval(60 / $increment); $cell_pct = intval(80 / ($hours * $interval)); $style_width = $cell_pct > 0 ? 'style="width:' . $cell_pct . '%;"' : ''; $thismonth = date('m', $dateTS); $thisyear = date('Y', $dateTS); $cols = $hours * $interval + 1; $ret = <<<EOT <br /> <table align="center" class="matrixd" style="width:'80%';" cellspacing="0" cellpadding="0"> <tr> <td class="matrix" colspan="{$cols}"></td> </tr> <tr> <th style="width:{$participant_pct};"> EOT; $ret .= translate('Participants') . '</th>'; $tentative = translate('Tentative'); // translate ( 'Schedule an appointment for' ) $titleStr = ' title="' . translate('Schedule an appointment for XXX.') . '">'; $viewMsg = translate('View this entry'); $hours = $last_hour - $first_hour; $interval = intval(60 / $increment); $cell_pct = intval(80 / ($hours * $interval)); $cols = $hours * $interval + 1; $style_width = $cell_pct > 0 ? 'style="width:' . $cell_pct . '%;"' : ''; $thismonth = date('m', $dateTS); $thisyear = date('Y', $dateTS); // Build a master array containing all events for $participants. for ($i = 0; $i < $cnt; $i++) { /* Pre-Load the repeated events for quckier access. */ $repeated_events = read_repeated_events($participants[$i], $dateTS, $dateTS, ''); /* Pre-load the non-repeating events for quicker access. */ $events = read_events($participants[$i], $dateTS, $dateTS); // Combine events for this date into a single array for easy processing. $ALL = array_merge(get_repeating_entries($participants[$i], $date), get_entries($date)); foreach ($ALL as $E) { if ($E->getTime() == 0) { $duration = 60 * $hours; $time = $first_hour . '0000'; } else { $duration = $E->getDuration(); $time = date('His', $E->getDateTimeTS()); } $hour = substr($time, 0, 2); $mins = substr($time, 2, 2); // Convert cal_time to slot. $slot = $hour + substr($mins, 0, 1); // Convert cal_duration to bars. $bars = $duration / $increment; // Never replace 'A' with 'W'. for ($q = 0; $bars > $q; $q++) { $slot = sprintf("%02.2f", $slot); if (strlen($slot) == 4) { $slot = '0' . $slot; } // Add leading zeros. $slot = $slot . ''; // Convert to a string. if (empty($master['_all_'][$slot]) || $master['_all_'][$slot]['stat'] != 'A') { $master['_all_'][$slot]['stat'] = $E->getStatus(); } if (empty($master[$participants[$i]][$slot]) || $master[$participants[$i]][$slot]['stat'] != 'A') { $master[$participants[$i]][$slot]['stat'] = $E->getStatus(); $master[$participants[$i]][$slot]['ID'] = $E->getID(); } $slot = $slot + $increment * 0.01; if ($slot - (int) $slot >= 0.59) { $slot = (int) $slot + 1; } } } } for ($i = $first_hour; $i < $last_hour; $i++) { $hour = $i; if ($TIME_FORMAT == '12') { $hour %= 12; if ($hour == 0) { $hour = 12; } $hourfmt = '%d'; } else { $hourfmt = '%02d'; } $halfway = intval($interval / 2 - 1); for ($j = 0; $j < $interval; $j++) { $inc_x_j = $increment * $j; $str .= ' <td id="C' . ($j + 1) . '" class="dailymatrix" '; $tmpTitle = 'onmousedown="schedule_event( ' . $i . ',' . sprintf("%02d", $inc_x_j) . ' );"' . $MouseOver . $MouseOut . str_replace('XXX', sprintf($hourfmt, $hour) . ':' . ($inc_x_j <= 9 ? '0' : '') . $inc_x_j, $titleStr); switch ($j) { case $halfway: $k = $hour <= 9 ? '0' : substr($hour, 0, 1); $str .= 'style="width:' . $cell_pct . '%; text-align:right;" ' . $tmpTitle . $k . '</td>'; break; case $halfway + 1: $k = $hour <= 9 ? substr($hour, 0, 1) : substr($hour, 1, 2); $str .= 'style="width:' . $cell_pct . '%; text-align:left;" ' . $tmpTitle . $k . '</td>'; break; default: $str .= $style_width . $tmpTitle . ' </td>'; } } } $ret .= $str . ' </tr> <tr> <td class="matrix" colspan="' . $cols . '"></td> </tr>'; // Add user _all_ to beginning of $participants array. array_unshift($participants, '_all_'); // Javascript for cells. // Display each participant. for ($i = 0; $i <= $cnt; $i++) { if ($participants[$i] != '_all_') { // Load full name of user. user_load_variables($participants[$i], 'user_'); // Exchange space for to keep from breaking. $user_nospace = preg_replace('/\\s/', ' ', $user_fullname); } else { $user_nospace = preg_replace('/\\s/', ' ', $allAttendeesStr); } $ret .= ' <tr> <th class="row" style="width:' . $participant_pct . ';">' . $user_nospace . '</th>'; $col = 1; // Check each timebar. for ($j = $first_hour; $j < $last_hour; $j++) { for ($k = 0; $k < $interval; $k++) { $r = sprintf("%02d", $j) . '.' . sprintf("%02d", $increment * $k) . ''; $space = ' '; if (empty($master[$participants[$i]][$r])) { // Ignore this.. } else { if (empty($master[$participants[$i]][$r]['ID'])) { // This is the first line for 'all' users. No event here. $space = ' <span class="matrix"><img src="images/pix.gif" alt="" /></span>'; } else { $tmpMast = $master[$participants[$i]][$r]['stat']; if (strpos('AW', $tmpMast) !== false) { $space = ' <a class="matrix" href="view_entry.php?id=' . $master[$participants[$i]][$r]['ID'] . '&friendly=1"><img src="images/pix' . ($tmpMast = 'A' ? '' : 'b') . '.gif" title="' . $viewMsg . '" alt="' . $viewMsg . '" /></a>'; } } } $ret .= ' <td class="matrixappts' . ($k == '0' ? ' matrixledge' : '') . '" ' . $style_width . ($space == ' ' ? ' ' . 'onmousedown="schedule_event( ' . $j . ',' . sprintf("%02d", $increment * $k) . ' );"' . " {$MouseOver} {$MouseOut}" : '') . '>' . $space . '</td>'; $col++; } } $ret .= ' </tr> <tr> <td class="matrix" colspan="' . $cols . '"><img src="images/pix.gif" alt="-" /></td> </tr>'; } // End foreach participant. return $ret . <<<EOT </table><br /> <table align="center"> <tr> <td class="matrixlegend" ><img src="images/pix.gif" title="{$busy}" alt="{$busy}" />{$busy} <img src="images/pixb.gif" title="{$tentative}" alt="{$tentative}" />{$tentative}</td> </tr> </table> EOT; }
} if (count($viewusers) == 0) { // This could happen if user_sees_only_his_groups = Y and // this user is not a member of any group assigned to this view $error = translate("No users for this view"); } if (!empty($error)) { echo "<h2>" . translate("Error") . "</h2>\n" . $error; print_trailer(); exit; } $e_save = array(); $re_save = array(); for ($i = 0; $i < count($viewusers); $i++) { /* Pre-Load the repeated events for quckier access */ $repeated_events = read_repeated_events($viewusers[$i], "", $startdate); $re_save[$i] = $repeated_events; /* Pre-load the non-repeating events for quicker access */ $events = read_events($viewusers[$i], $startdate, $enddate); $e_save[$i] = $events; } for ($j = 0; $j < 7; $j += $DAYS_PER_TABLE) { // since print_date_entries is rather stupid, we can swap the event data // around for users by changing what $events points to. $tdw = 12; // column width percent ?> <table class="main" cellspacing="0" cellpadding="0"> <tr><th class="empty"> </th> <?php
} $next = mktime(3, 0, 0, $thismonth, $thisday + 7, $thisyear); $prev = mktime(3, 0, 0, $thismonth, $thisday - 7, $thisyear); $today = mktime(3, 0, 0, date("m"), date("d"), date("Y")); // We add 2 hours on to the time so that the switch to DST doesn't // throw us off. So, all our dates are 2AM for that day. if ($WEEK_START == 1) { $wkstart = get_monday_before($thisyear, $thismonth, $thisday); } else { $wkstart = get_sunday_before($thisyear, $thismonth, $thisday); } $wkend = $wkstart + 3600 * 24 * 6; $startdate = date("Ymd", $wkstart); $enddate = date("Ymd", $wkend); /* Pre-Load the repeated events for quckier access */ $repeated_events = read_repeated_events($login); /* Pre-load the non-repeating events for quicker access */ $events = read_events($login, $startdate, $enddate); for ($i = 0; $i < 7; $i++) { $days[$i] = $wkstart + 24 * 3600 * $i; $weekdays[$i] = weekday_short_name(($i + $WEEK_START) % 7); $header[$i] = $weekdays[$i] . "<BR>" . month_short_name(date("m", $days[$i]) - 1) . " " . date("d", $days[$i]); } ?> <TABLE BORDER="0" WIDTH="100%" CELLSPACING="0" CELLPADDING="0"> <TR><TD BGCOLOR="<?php echo $TABLEBG; ?> ">