Exemple #1
0
    for ($i = 0; $i < count($viewusers); $i++) {
        echo "\n<tr>\n";
        $user = $viewusers[$i];
        user_load_variables($user, "temp");
        echo "<th class=\"row\" style=\"width:{$tdw}%;\">{$tempfullname}</th>";
        for ($date = $wkstart, $h = 0; date("Ymd", $date) <= date("Ymd", $wkend); $date += 24 * 3600, $h++) {
            $wday = strftime("%w", $date);
            if ($wday == 0 || $wday == 6) {
                echo "<td class=\"weekend\" style=\"width:{$tdw}%;\">";
            } else {
                echo "<td style=\"width:{$tdw}%;\">";
            }
            $events = $e_save[$i];
            $repeated_events = $re_save[$i];
            if (empty($add_link_in_views) || $add_link_in_views != "N") {
                echo html_for_add_icon(date("Ymd", $date), "", "", $user);
            }
            print_date_entries(date("Ymd", $date), $user, true);
            echo "</td>";
        }
        echo "</tr>\n";
    }
    echo "</table>\n<br /><br />\n";
}
$user = "";
// reset
if (!empty($eventinfo)) {
    echo $eventinfo;
}
echo "<a title=\"" . translate("Generate printer-friendly version") . "\" class=\"printer\" href=\"view_v.php?id={$id}&amp;date=" . "{$thisdate}&amp;friendly=1\" " . "target=\"cal_printer_friendly\" onmouseover=\"window.status='" . translate("Generate printer-friendly version") . "'\">[" . translate("Printer Friendly") . "]</a>\n";
print_trailer();
function print_day_at_a_glance($date, $user, $hide_icons, $can_add = 0)
{
    global $first_slot, $last_slot, $hour_arr, $rowspan_arr, $rowspan;
    global $CELLBG, $TODAYCELLBG, $THFG, $THBG, $TIME_SLOTS, $TZ_OFFSET;
    global $WORK_DAY_START_HOUR, $WORK_DAY_END_HOUR;
    global $repeated_events;
    $get_unapproved = $GLOBALS["DISPLAY_UNAPPROVED"] == "Y";
    if ($user == "__public__") {
        $get_unapproved = false;
    }
    if (empty($TIME_SLOTS)) {
        echo "Error: TIME_SLOTS undefined!<P>";
        return;
    }
    // $interval is number of minutes per slot
    $interval = 24 * 60 / $TIME_SLOTS;
    $rowspan_arr = array();
    for ($i = 0; $i < $TIME_SLOTS; $i++) {
        $rowspan_arr[$i] = 0;
    }
    // get all the repeating events for this date and store in array $rep
    $rep = get_repeating_entries($user, $date);
    $cur_rep = 0;
    // Get static non-repeating events
    $ev = get_entries($user, $date);
    $hour_arr = array();
    $interval = 24 * 60 / $TIME_SLOTS;
    $first_slot = (int) (($WORK_DAY_START_HOUR - $TZ_OFFSET) * 60 / $interval);
    $last_slot = (int) (($WORK_DAY_END_HOUR - $TZ_OFFSET) * 60 / $interval);
    //echo "first_slot = $first_slot <BR> last_slot = $last_slot <BR> interval = $interval <BR> TIME_SLOTS = $TIME_SLOTS <BR>";
    $rowspan_arr = array();
    $all_day = 0;
    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'];
                }
                if ($rep['cal_duration'] == 24 * 60) {
                    $all_day = 1;
                }
                html_for_event_day_at_a_glance($viewid, $date, $rep[$cur_rep]['cal_time'], $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_duration'], $rep[$cur_rep]['cal_login'], $hide_icons);
            }
            $cur_rep++;
        }
        if ($get_unapproved || $ev[$i]['cal_status'] == 'A') {
            if (!empty($ev[$i]['cal_ext_for_id'])) {
                $viewid = $ev[$i]['cal_ext_for_id'];
                $viewname = $ev[$i]['cal_name'] . " (" . translate("cont.") . ")";
            } else {
                $viewid = $ev[$i]['cal_id'];
                $viewname = $ev[$i]['cal_name'];
            }
            if ($ev[$i]['cal_duration'] == 24 * 60) {
                $all_day = 1;
            }
            html_for_event_day_at_a_glance($viewid, $date, $ev[$i]['cal_time'], $viewname, $ev[$i]['cal_description'], $ev[$i]['cal_status'], $ev[$i]['cal_priority'], $ev[$i]['cal_access'], $ev[$i]['cal_duration'], $ev[$i]['cal_login'], $hide_icons);
        }
    }
    // print out any remaining repeating events
    while ($cur_rep < count($rep)) {
        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'];
            }
            if ($rep['cal_duration'] == 24 * 60) {
                $all_day = 1;
            }
            html_for_event_day_at_a_glance($viewid, $date, $rep[$cur_rep]['cal_time'], $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_duration'], $rep[$cur_rep]['cal_login'], $hide_icons);
        }
        $cur_rep++;
    }
    // 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.
    $rowspan = 0;
    $last_row = -1;
    //echo "First SLot: $first_slot; Last Slot: $last_slot <BR>";
    $i = 0;
    if ($first_slot < 0) {
        $i = $first_slot;
    }
    for (; $i < $TIME_SLOTS; $i++) {
        if ($rowspan > 1) {
            if (!empty($hour_arr[$i])) {
                if ($rowspan_arr[$i] > 1) {
                    $rowspan_arr[$last_row] += $rowspan_arr[$i] - 1;
                    $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
                $start_time = $i;
                $diff_start_time = $start_time - $last_row;
                for ($u = $diff_start_time; $u > 0; $u--) {
                    $hour_arr[$last_row] .= "<BR>";
                }
                $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) {
                $rowspan = $rowspan_arr[$i];
                $last_row = $i;
            }
        }
    }
    if (!empty($hour_arr[9999])) {
        echo "<TR><TD HEIGHT=\"40\" BGCOLOR=\"{$TODAYCELLBG}\">&nbsp;</TD><TD VALIGN=\"top\" HEIGHT=\"40\" BGCOLOR=\"{$TODAYCELLBG}\">{$hour_arr['9999']}</TD></TR>\n";
    }
    $rowspan = 0;
    //echo "first_slot = $first_slot <BR> last_slot = $last_slot <BR> interval = $interval <BR>";
    for ($i = $first_slot; $i <= $last_slot; $i++) {
        $time_h = (int) ($i * $interval / 60);
        $time_m = $i * $interval % 60;
        $time = display_time(($time_h * 100 + $time_m) * 100);
        echo "<TR><TH VALIGN=\"top\" HEIGHT=\"40\" WIDTH=\"14%\" BGCOLOR=\"{$THBG}\" CLASS=\"tableheader\">" . "<FONT COLOR=\"{$THFG}\">" . $time . "</FONT></TH>\n";
        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 (strlen($hour_arr[$i])) {
                echo "<TD VALIGN=\"top\" HEIGHT=\"40\" BGCOLOR=\"{$TODAYCELLBG}\">";
                if ($can_add && !$hide_icons) {
                    echo html_for_add_icon($date, $time_h, $time_m);
                }
                echo "{$hour_arr[$i]}</TD>";
            }
            $rowspan--;
        } else {
            $color = $all_day ? $TODAYCELLBG : $CELLBG;
            if (empty($hour_arr[$i])) {
                echo "<TD HEIGHT=\"40\" BGCOLOR=\"{$color}\">";
                if ($can_add && !$hide_icons) {
                    echo html_for_add_icon($date, $time_h, $time_m);
                }
                echo "&nbsp;</TD></TR>\n";
            } else {
                $rowspan = $rowspan_arr[$i];
                if ($rowspan > 1) {
                    echo "<TD VALIGN=\"top\" BGCOLOR=\"{$TODAYCELLBG}\" ROWSPAN=\"{$rowspan}\">";
                    if ($can_add && !$hide_icons) {
                        echo html_for_add_icon($date, $time_h, $time_m);
                    }
                    echo "{$hour_arr[$i]}</TD></TR>\n";
                } else {
                    echo "<TD VALIGN=\"top\" HEIGHT=\"40\" BGCOLOR=\"{$TODAYCELLBG}\">";
                    if ($can_add && !$hide_icons) {
                        echo html_for_add_icon($date, $time_h, $time_m);
                    }
                    echo "{$hour_arr[$i]}</TD></TR>\n";
                }
            }
        }
    }
}
Exemple #3
0
        for ($date = $wkstart; $date < $wkend; $date += 86400) {
            $is_weekend = is_weekend($date);
            if ($is_weekend && $DISPLAY_WEEKENDS == 'N') {
                continue;
            }
            $dateYmd = date('Ymd', $date);
            $entryStr = print_date_entries($dateYmd, $user, true);
            $class = ($dateYmd == $todayYmd ? ' class="today"' : (!empty($entryStr) && $entryStr != '&nbsp;' ? ' class="hasevents"' : ($is_weekend ? ' class="weekend"' : ''))) . ' style="width:' . $tdw . '%;">';
            // .
            // Build header row.
            if ($i == 0) {
                $header .= '
        <th' . $class . weekday_name(date('w', $date), $DISPLAY_LONG_DAYS) . ' ' . date('d', $date) . '</th>';
            }
            $body .= '
        <td' . $class . (empty($ADD_LINK_IN_VIEWS) || $ADD_LINK_IN_VIEWS != 'N' ? html_for_add_icon($dateYmd, '', '', $user) . "\n" : '') . $entryStr . '
        </td>';
        }
        $body .= '
      </tr>';
    }
    // .
    // Output all.
    echo $header . '
      </tr>' . $body . '
    </table>';
}
// .
$user = '';
// reset
// .
Exemple #4
0
    /* Pre-load the non-repeating events for quicker access
       subtracting ONE_WEEK to allow cross-day events to display*/
    $events = read_events($viewusers[$i], $wkstart - 604800, $wkend);
    $e_save = array_merge($e_save, $events);
}
$events = $e_save;
$repeated_events = $re_save;
$timeBarHeader = print_header_timebar();
echo '
    <table class="main">';
for ($date = $wkstart; $date <= $wkend; $date += 86400) {
    $dateYmd = date('Ymd', $date);
    $is_weekend = is_weekend($date);
    if ($is_weekend && $DISPLAY_WEEKENDS == 'N') {
        continue;
    }
    echo '
      <tr' . ($dateYmd == date('Ymd', $today) ? '>
        <th class="today">' : ($is_weekend ? ' class="weekend">
        <th class="weekend">' : '>
        <th class="row">')) . (empty($ADD_LINK_IN_VIEWS) || $ADD_LINK_IN_VIEWS != 'N' ? html_for_add_icon($dateYmd, '', '', $user) : '') . weekday_name(date('w', $date), $DISPLAY_LONG_DAYS) . '&nbsp;' . date('d', $date) . '</th>
        <td class="timebar">' . $timeBarHeader . print_date_entries_timebar($dateYmd, $login, true) . '
          </table>
        </td>
      </tr>';
}
$user = '';
// reset
ob_end_flush();
echo '
    </table>' . (empty($eventinfo) ? '' : $eventinfo) . $printerStr . print_trailer();
Exemple #5
0
            $repeated_events = $re_save[$i];
            $entryStr = print_date_entries($dateYmd, $user, true);
            // Unset class from above if needed.
            if ($class == 'class="row"' || $class == 'class="hasevents"') {
                $class = '';
            }
            if (!empty($entryStr) && $entryStr != '&nbsp;') {
                $class = 'class="hasevents"';
            } else {
                if ($dateYmd == $todayYmd) {
                    $class = 'class="today"';
                } else {
                    if ($is_weekend) {
                        $class = 'class="weekend"';
                    }
                }
            }
            echo '
        <td ' . $class . ' style="width:' . $tdw . '%;">' . (empty($ADD_LINK_IN_VIEWS) || $ADD_LINK_IN_VIEWS != 'N' ? html_for_add_icon(date('Ymd', $date), '', '', $user) : '') . $entryStr . '
        </td>';
        }
        echo '
      </tr>';
    }
    echo '
    </table>';
}
ob_end_flush();
$user = '';
// reset
echo (empty($eventinfo) ? '' : $eventinfo) . $printerStr . print_trailer();
                if (empty($friendly) && $can_add) {
                    echo html_for_add_icon(date("Ymd", $days[$d]), $time_h, $time_m);
                }
                echo "&nbsp;</TD>\n";
            } else {
                $rowspan_day[$d] = $save_rowspan_arr[$d][$i];
                if ($rowspan_day[$d] > 1) {
                    echo "<TD VALIGN=\"top\" WIDTH=\"12%\" VALIGN=\"top\" BGCOLOR=\"{$TODAYCELLBG}\" ROWSPAN=\"{$rowspan_day[$d]}\">";
                    if (empty($friendly) && $can_add) {
                        echo html_for_add_icon(date("Ymd", $days[$d]), $time_h, $time_m);
                    }
                    echo "<FONT SIZE=\"-1\">" . $save_hour_arr[$d][$i] . "</FONT></TD>\n";
                } else {
                    echo "<TD VALIGN=\"top\" WIDTH=\"12%\" BGCOLOR=\"{$TODAYCELLBG}\"><FONT SIZE=\"-1\">";
                    if (empty($friendly) && $can_add) {
                        echo html_for_add_icon(date("Ymd", $days[$d]), $time_h, $time_m);
                    }
                    echo $save_hour_arr[$d][$i] . "</FONT></TD>\n";
                }
            }
        }
    }
    echo "</TR>\n";
}
?>

<?php 
if (empty($friendly) || !$friendly) {
    ?>
</TABLE>
</TD></TR></TABLE>
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">&nbsp;</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 : '&nbsp;');
            } 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>';
}
Exemple #8
0
        if ($rowspan_day[$d] > 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($save_hour_arr[$d][$i])) {
                $eventsStr .= '
              <td' . $class . '>' . $save_hour_arr[$d][$i] . '</td>';
            }
            $rowspan_day[$d]--;
        } else {
            $eventsStr .= '
              <td' . $class;
            if (empty($save_hour_arr[$d][$i])) {
                $eventsStr .= '>' . ($can_add ? html_for_add_icon($dateYmd, $time_h, $time_m, $user) : '') . '&nbsp;';
            } else {
                $rowspan_day[$d] = $save_rowspan_arr[$d][$i];
                $eventsStr .= ($rowspan_day[$d] > 1 ? ' rowspan="' . $rowspan_day[$d] . '"' : '') . '>' . ($can_add ? html_for_add_icon($dateYmd, $time_h, $time_m, $user) : '') . $save_hour_arr[$d][$i];
            }
            $eventsStr .= '</td>';
        }
    }
    $eventsStr .= '
            </tr>';
}
$eventinfo = empty($eventinfo) ? '' : $eventinfo;
$tableWidth = '100%';
$unapprovedStr = $printerStr = '';
if (empty($friendly)) {
    $unapprovedStr = display_unapproved_events($is_assistant || $is_nonuser_admin ? $user : $login);
    $printerStr = generate_printer_friendly('month.php');
}
$trailerStr = print_trailer();