function print_date_entries_timebar($date, $user, $ssi) { global $DISPLAY_UNAPPROVED, $events, $is_admin, $PUBLIC_ACCESS, $PUBLIC_ACCESS_CAN_ADD, $readonly, $totalSlots; $ret = ''; $cnt = 0; $get_unapproved = $DISPLAY_UNAPPROVED == 'Y'; $year = substr($date, 0, 4); $month = substr($date, 4, 2); $day = substr($date, 6, 2); $can_add = $readonly == 'N' || $is_admin; if ($PUBLIC_ACCESS == 'Y' && $PUBLIC_ACCESS_CAN_ADD != 'Y' && $GLOBALS['login'] == '__public__') { $can_add = false; } $cur_rep = 0; // Combine and sort the event arrays. $ev = combine_and_sort_events(get_entries($date, $get_unapproved), get_repeating_entries($user, $date)); $evcnt = count($ev); for ($i = 0; $i < $evcnt; $i++) { if ($get_unapproved || $ev[$i]->getStatus() == 'A') { $ret .= print_entry_timebar($ev[$i], $date); $cnt++; } } return $ret . ($cnt == 0 ? ' <tr> <td colspan="' . $totalSlots . '"> </td> </tr>' : ''); }
function print_date_entries_timebar($date, $user, $hide_icons, $ssi) { global $events, $readonly, $is_admin, $public_access, $public_access_can_add; $cnt = 0; $get_unapproved = $GLOBALS["DISPLAY_UNAPPROVED"] == "Y"; // public access events always must be approved before being displayed if ($GLOBALS["login"] == "__public__") { $get_unapproved = false; } $year = substr($date, 0, 4); $month = substr($date, 4, 2); $day = substr($date, 6, 2); $dateu = mktime(3, 0, 0, $month, $day, $year); $can_add = $readonly == "N" || $is_admin; if ($public_access == "Y" && $public_access_can_add != "Y" && $GLOBALS["login"] == "__public__") { $can_add = false; } // get all the repeating events for this date and store in array $rep $rep = get_repeating_entries($users[$i], $date); $cur_rep = 0; // get all the non-repeating events for this date and store in $ev $ev = get_entries($users[$i], $date); for ($i = 0; $i < count($ev); $i++) { // print out any repeating events that are before this one... while ($cur_rep < count($rep) && $rep[$cur_rep]['cal_time'] < $ev[$i]['cal_time']) { if ($get_unapproved || $rep[$cur_rep]['cal_status'] == 'A') { print_entry_timebar($rep[$cur_rep]['cal_id'], $date, $rep[$cur_rep]['cal_time'], $rep[$cur_rep]['cal_duration'], $rep[$cur_rep]['cal_name'], $rep[$cur_rep]['cal_description'], $rep[$cur_rep]['cal_status'], $rep[$cur_rep]['cal_priority'], $rep[$cur_rep]['cal_access'], $rep[$cur_rep]['cal_login'], $hide_icons); $cnt++; } $cur_rep++; } if ($get_unapproved || $ev[$i]['cal_status'] == 'A') { print_entry_timebar($ev[$i]['cal_id'], $date, $ev[$i]['cal_time'], $ev[$i]['cal_duration'], $ev[$i]['cal_name'], $ev[$i]['cal_description'], $ev[$i]['cal_status'], $ev[$i]['cal_priority'], $ev[$i]['cal_access'], $ev[$i]['cal_login'], $hide_icons); $cnt++; } } // print out any remaining repeating events while ($cur_rep < count($rep)) { if ($get_unapproved || $rep[$cur_rep]['cal_status'] == 'A') { print_entry_timebar($rep[$cur_rep]['cal_id'], $date, $rep[$cur_rep]['cal_time'], $rep[$cur_rep]['cal_duration'], $rep[$cur_rep]['cal_name'], $rep[$cur_rep]['cal_description'], $rep[$cur_rep]['cal_status'], $rep[$cur_rep]['cal_priority'], $rep[$cur_rep]['cal_access'], $rep[$cur_rep]['cal_login'], $hide_icons); $cnt++; } $cur_rep++; } if ($cnt == 0) { echo " "; } // so the table cell has at least something }
$date = date('Ymd', time() + $d * 86400); // echo "Date: $date\n"; // Get non-repeating events for this date. // An event will be included one time for each participant. $ev = get_entries($date); // Keep track of duplicates. $completed_ids = array(); for ($i = 0, $evCnt = count($ev); $i < $evCnt; $i++) { $id = $ev[$i]->getID(); if (!empty($completed_ids[$id])) { continue; } $completed_ids[$id] = 1; $out .= process_event($id, $ev[$i]->getName(), $date, $ev[$i]->getTime()); } $rep = get_repeating_entries($user, $date); for ($i = 0, $repCnt = count($rep); $i < $repCnt; $i++) { $id = $rep[$i]->getID(); if (!empty($completed_ids[$id])) { continue; } $completed_ids[$id] = 1; $out .= process_event($id, $rep[$i]->getName(), $date, $rep[$i]->getTime()); } } $out .= ' </reminders> '; // If web service debugging is on... if (!empty($WS_DEBUG) && $WS_DEBUG) { ws_log_message($out);
$startdate = time(); // today for ($d = 0; $d < $DAYS_IN_ADVANCE; $d++) { $date = date("Ymd", time() + $d * 24 * 3600); //echo "Date: $date\n"; // Get non-repeating events for this date. // An event will be included one time for each participant. $ev = get_entries("", $date); // Keep track of duplicates $completed_ids = array(); for ($i = 0; $i < count($ev); $i++) { $id = $ev[$i]['cal_id']; if (!empty($completed_ids[$id])) { continue; } $completed_ids[$id] = 1; process_event($id, $ev[$i]['cal_name'], $date, $ev[$i]['cal_time']); } $rep = get_repeating_entries("", $date); for ($i = 0; $i < count($rep); $i++) { $id = $rep[$i]['cal_id']; if (!empty($completed_ids[$id])) { continue; } $completed_ids[$id] = 1; process_event($id, $rep[$i]['cal_name'], $date, $rep[$i]['cal_time']); } } if ($debug) { echo "Done.<br />\n"; }
function print_det_date_entries($date, $user, $ssi) { global $events, $readonly, $is_admin; $year = substr($date, 0, 4); $month = substr($date, 4, 2); $day = substr($date, 6, 2); $dateu = mktime(2, 0, 0, $month, $day, $year); // get all the repeating events for this date and store in array $rep $rep = get_repeating_entries($user, $date); $cur_rep = 0; // get all the non-repeating events for this date and store in $ev $ev = get_entries($user, $date); for ($i = 0; $i < count($ev); $i++) { // print out any repeating events that are before this one... while ($cur_rep < count($rep) && $rep[$cur_rep]['cal_time'] < $ev[$i]['cal_time']) { if ($GLOBALS["DISPLAY_UNAPPROVED"] != "N" || $rep[$cur_rep]['cal_status'] == 'A') { print_detailed_entry($rep[$cur_rep]['cal_id'], $date, $rep[$cur_rep]['cal_time'], $rep[$cur_rep]['cal_duration'], $rep[$cur_rep]['cal_name'], $rep[$cur_rep]['cal_description'], $rep[$cur_rep]['cal_status'], $rep[$cur_rep]['cal_priority'], $rep[$cur_rep]['cal_access'], $rep[$cur_rep]['cal_login']); } $cur_rep++; } if ($GLOBALS["DISPLAY_UNAPPROVED"] != "N" || $ev[$i]['cal_status'] == 'A') { print_detailed_entry($ev[$i]['cal_id'], $date, $ev[$i]['cal_time'], $ev[$i]['cal_duration'], $ev[$i]['cal_name'], $ev[$i]['cal_description'], $ev[$i]['cal_status'], $ev[$i]['cal_priority'], $ev[$i]['cal_access'], $ev[$i]['cal_login']); } } // print out any remaining repeating events while ($cur_rep < count($rep)) { if ($GLOBALS["DISPLAY_UNAPPROVED"] != "N" || $rep[$cur_rep]['cal_status'] == 'A') { print_detailed_entry($rep[$cur_rep]['cal_id'], $date, $rep[$cur_rep]['cal_time'], $rep[$cur_rep]['cal_duration'], $rep[$cur_rep]['cal_name'], $rep[$cur_rep]['cal_description'], $rep[$cur_rep]['cal_status'], $rep[$cur_rep]['cal_priority'], $rep[$cur_rep]['cal_access'], $rep[$cur_rep]['cal_login']); } $cur_rep++; } }
$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); $entries = get_entries($username, $d); $rentries = get_repeating_entries($username, $d); print "<!-- {$d} " . count($entries) . "/" . count($rentries) . " -->\n"; if (count($entries) > 0 || count($rentries) > 0) { print "<!-- XXX -->\n"; print "<dt>" . date_to_str($d) . "</dt>\n<dd>"; for ($j = 0; $j < count($entries) && $numEvents < $maxEvents; $j++) { print_upcoming_event($entries[$j]); $numEvents++; } for ($j = 0; $j < count($rentries) && $numEvents < $maxEvents; $j++) { print_upcoming_event($rentries[$j]); $numEvents++; } print "</dd>\n"; } }
function print_day_at_a_glance($date, $user, $can_add = 0) { global $CELLBG, $DISPLAY_TASKS_IN_GRID, $DISPLAY_UNAPPROVED, $first_slot, $hour_arr, $last_slot, $rowspan, $rowspan_arr, $TABLEBG, $THBG, $THFG, $TIME_SLOTS, $today, $TODAYCELLBG, $WORK_DAY_END_HOUR, $WORK_DAY_START_HOUR; if (empty($TIME_SLOTS)) { return translate('Error TIME_SLOTS undefined!') . "<br />\n"; } $get_unapproved = $DISPLAY_UNAPPROVED == 'Y'; // Get, combine and sort the events for this date. $ev = combine_and_sort_events(get_entries($date, $get_unapproved), get_repeating_entries($user, $date)); if ($date >= date('Ymd') && (empty($DISPLAY_TASKS_IN_GRID) || $DISPLAY_TASKS_IN_GRID == 'Y')) { $ev = combine_and_sort_events($ev, get_tasks($date, $get_unapproved)); } $hour_arr = $rowspan_arr = array(); $interval = 1440 / $TIME_SLOTS; // Number of minutes per slot $first_slot = intval($WORK_DAY_START_HOUR * 60 / $interval); $last_slot = intval($WORK_DAY_END_HOUR * 60 / $interval); for ($i = 0, $cnt = count($ev); $i < $cnt; $i++) { if ($get_unapproved || $ev[$i]->getStatus() == 'A') { html_for_event_day_at_a_glance($ev[$i], $date); } } $last_row = -1; $ret = ''; $rowspan = 0; // Squish events that use the same cell into the same cell. // For example, an event from 8:00-9:15 and another from 9:30-9:45 both // want to show up in the 8:00-9:59 cell. for ($i = $first_slot < 0 ? $first_slot : 0; $i < $TIME_SLOTS; $i++) { if ($rowspan > 1) { if (!empty($hour_arr[$i])) { $diff_start_time = $i - $last_row; if (!empty($rowspan_arr[$i])) { if ($rowspan_arr[$i] > 1 && $rowspan_arr[$i] + $diff_start_time > $rowspan_arr[$last_row]) { $rowspan_arr[$last_row] = $rowspan_arr[$i] + $diff_start_time; } $rowspan += $rowspan_arr[$i] - 1; } else { $rowspan_arr[$last_row] += $rowspan_arr[$i]; } // This will move entries apart that appear in one field, // yet start on different hours. for ($u = $diff_start_time; $u > 0; $u--) { $hour_arr[$last_row] .= "<br />\n"; } $hour_arr[$last_row] .= $hour_arr[$i]; $hour_arr[$i] = ''; $rowspan_arr[$i] = 0; } $rowspan--; } else { if (!empty($rowspan_arr[$i]) && $rowspan_arr[$i] > 1) { $last_row = $i; $rowspan = $rowspan_arr[$i]; } } } $ret .= ' <table class="main glance" cellspacing="0" cellpadding="0">' . (empty($hour_arr[9999]) ? '' : ' <tr> <th class="empty"> </th> <td class="hasevents">' . $hour_arr[9999] . '</td> </tr>'); $rowspan = 0; for ($i = $first_slot; $i <= $last_slot; $i++) { $time_h = intval($i * $interval / 60); $time_m = $i * $interval % 60; $addIcon = $can_add ? html_for_add_icon($date, $time_h, $time_m, $user) : ''; $ret .= ' <tr> <th class="row">' . display_time(($time_h * 100 + $time_m) * 100) . '</th>'; if ($rowspan > 1) { // This might mean there's an overlap, or it could mean one event // ends at 11:15 and another starts at 11:30. if (!empty($hour_arr[$i])) { $ret .= ' <td class="hasevents">' . $addIcon . $hour_arr[$i] . '</td>'; } $rowspan--; } else { $ret .= ' <td '; if (empty($hour_arr[$i])) { $ret .= ($date == date('Ymd', $today) ? ' class="today"' : '') . '>' . ($can_add ? $addIcon : ' '); } else { $rowspan = empty($rowspan_arr[$i]) ? '' : $rowspan_arr[$i]; $ret .= ($rowspan > 1 ? 'rowspan="' . $rowspan . '"' : '') . 'class="hasevents">' . $addIcon . $hour_arr[$i]; } $ret .= '</td>'; } $ret .= ' </tr>'; } return $ret . ' </table>'; }
$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); $day_str = ''; // 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_time; $cur_time <= $end_time; $cur_time += $ONE_DAY) { $event_str = ''; $dateYmd = date("Ymd", $cur_time); $rep = get_repeating_entries(empty($user) ? $login : $user, $dateYmd); $ev = get_entries(empty($user) ? $login : $user, $dateYmd); $cur_rep = 0; //echo "DATE: $dateYmd <br />\n"; for ($i = 0; $i < count($ev); $i++) { // print out any repeating events that are before this one... while ($cur_rep < count($rep) && $rep[$cur_rep]['cal_time'] < $ev[$i]['cal_time']) { if ($get_unapproved || $rep[$cur_rep]['cal_status'] == 'A') { if (!empty($rep[$cur_rep]['cal_ext_for_id'])) { $viewid = $rep[$cur_rep]['cal_ext_for_id']; $viewname = $rep[$cur_rep]['cal_name'] . " (" . translate("cont.") . ")"; } else { $viewid = $rep[$cur_rep]['cal_id']; $viewname = $rep[$cur_rep]['cal_name']; } $event_str .= event_to_text($viewid, $dateYmd, $rep[$cur_rep]['cal_time'], $rep[$cur_rep]['cal_duration'], $viewname, $rep[$cur_rep]['cal_description'], $rep[$cur_rep]['cal_status'], $rep[$cur_rep]['cal_priority'], $rep[$cur_rep]['cal_access'], $rep[$cur_rep]['cal_login']);
?> </head> <body> <?php if (!empty($error)) { echo "<h2>" . translate("Error") . "</h2>\n" . $error; echo "\n<br /><br />\n</body></html>"; exit; } print "<dl>\n"; print "<!-- \nstartTime: {$startTime}\nendTime: {$endTime}\nstartDate: " . "{$date}\nnumDays: {$numDays}\nuser: {$username}\nevents: " . count($events) . "\nrepeated_events: " . count($repeated_events) . " -->\n"; $numEvents = 0; for ($i = $startTime; date("Ymd", $i) <= date("Ymd", $endTime) && $numEvents < $maxEvents; $i += 24 * 3600) { $d = date("Ymd", $i); $entries = get_entries($username, $d, $get_unapproved); $rentries = get_repeating_entries($username, $d, $get_unapproved); print "<!-- {$d} " . count($entries) . "/" . count($rentries) . " -->\n"; if (count($entries) > 0 || count($rentries) > 0) { print "<!-- XXX -->\n"; print "<dt>" . date_to_str($d) . "</dt>\n<dd>"; for ($j = 0; $j < count($entries) && $numEvents < $maxEvents; $j++) { print_upcoming_event($entries[$j]); $numEvents++; } for ($j = 0; $j < count($rentries) && $numEvents < $maxEvents; $j++) { print_upcoming_event($rentries[$j]); $numEvents++; } print "</dd>\n"; } }
/** * 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"; }
$navStr = display_navigation('week'); for ($i = $start_ind; $i <= $end_ind; $i++) { $days[$i] = $wkstart + 86400 * $i + 43200; $weekdays[$i] = weekday_name(($i + $WEEK_START) % 7, $DISPLAY_LONG_DAYS); $dateYmd = date('Ymd', $days[$i]); $header[$i] = $weekdays[$i] . '<br />' . date_to_str($dateYmd, $DATE_FORMAT_MD, false, true); // . // Generate header row. $class = $dateYmd == date('Ymd', $today) ? ' class="today"' : (is_weekend($days[$i]) ? ' class="weekend"' : ''); $headerStr .= ' <th ' . $class . '>' . ($can_add ? html_for_add_icon($dateYmd, '', '', $user) : '') . '<p style="margin:.75em 0 0 0"><a href="day.php?' . $u_url . 'date=' . $dateYmd . $caturl . '">' . $header[$i] . '</a></p></th>'; $date = date('Ymd', $days[$i]); $hour_arr = $rowspan_arr = $tk = array(); // . // Get, combine and sort, static and repeating events for this date. $ev = combine_and_sort_events(get_entries($date, $get_unapproved), get_repeating_entries($user, $date)); // . // Then sort in any tasks due for this day and before. $ev = combine_and_sort_events($ev, $date >= date('Ymd') ? get_tasks($date, $get_unapproved) : $tk); for ($j = 0, $cnt = count($ev); $j < $cnt; $j++) { if ($get_unapproved || $ev[$j]->getStatus() == 'A') { html_for_event_week_at_a_glance($ev[$j], $date); } } // . // Squish events that use the same cell into the same cell. // For example, an event from 8:00-9:15 and another from 9:30-9:45 // both want to show up in the 8:00-9:59 cell. $last_row = -1; $rowspan = 0; for ($j = 0; $j < $TIME_SLOTS; $j++) {
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) { $date_str = date_to_str($dateYmd, '', false); $date_full_str = date_to_str($dateYmd); $day_str .= str_replace(array('${date}', '${events}', '${fulldate}', '${report_id}'), array($date_str, $event_str, $date_full_str, $report_id), $day_template); } } } if (!empty($error)) { echo print_error($error) . print_trailer(); exit;
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"; }
$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'); } } header('Content-Type: text/calendar'); header('Content-Disposition: attachment; filename="' . $login . '.ifb"'); echo 'BEGIN:VCALENDAR' . "\r\n" . 'X-WR-CALNAME;VALUE=TEXT:' . str_replace(',', '\\,', empty($publish_fullname) ? $user : translate($publish_fullname)) . "\r\n" . generate_prodid() . 'VERSION:2.0' . "\r\n" . 'METHOD:PUBLISH' . "\r\n" . 'BEGIN:VFREEBUSY' . "\r\n" . 'DTSTART:' . export_get_utc_date(date('Ymd', $startdate), 0) . "\r\n" . 'DTEND:' . export_get_utc_date(date('Ymd', $enddate), '235959') . "\r\n" . $event_text . 'URL:' . $GLOBALS['SERVER_URL'] . 'freebusy.php/' . $user . '.ifb' . "\r\n" . 'END:VFREEBUSY' . "\r\n" . 'END:VCALENDAR' . "\r\n"; exit;
function print_det_date_entries($date, $user, $ssi) { global $events, $is_admin, $readonly; $date = mktime(0, 0, 0, substr($date, 4, 2), substr($date, 6, 2), substr($date, 0, 4)); // . // Get and sort all the repeating and non-repeating events for this date. $ev = combine_and_sort_events(get_entries($date), get_repeating_entries($user, $date)); for ($i = 0, $cnt = count($ev); $i < $cnt; $i++) { if (!empty($DISPLAY_UNAPPROVED) && $DISPLAY_UNAPPROVED != 'N' || $ev[$i]->getStatus() == 'A') { print_detailed_entry($ev[$i], $date); } } }