Beispiel #1
0
 * Must have "allow view others" enabled ($ALLOW_VIEW_OTHER) in System Settings
 * unless the user is an admin user ($is_admin). If the view is not global, the
 * user must be owner of the view. If the view is global, then and
 * user_sees_only_his_groups is enabled, then we remove users not in this user's
 * groups (except for nonuser calendars... which we allow regardless of group).
 */
include_once 'includes/init.php';
include_once 'includes/views.php';
$DAYS_PER_TABLE = 7;
$error = '';
view_init($id);
$printerStr = generate_printer_friendly('view_v.php');
set_today($date);
$nextdate = date('Ymd', mktime(0, 0, 0, $thismonth, $thisday + 7, $thisyear));
$prevdate = date('Ymd', mktime(0, 0, 0, $thismonth, $thisday - 7, $thisyear));
$wkstart = get_weekday_before($thisyear, $thismonth, $thisday + 1);
$wkend = $wkstart + 86400 * ($DISPLAY_WEEKENDS == 'N' ? 5 : 7);
$thisdate = date('Ymd', $wkstart);
$nextStr = translate('Next');
$prevStr = translate('Previous');
print_header(array('js/popups.php/true'));
ob_start();
echo '
    <div style="width:99%;">
      <a title="' . $prevStr . '" class="prev" href="view_v.php?id=' . $id . '&amp;date=' . $prevdate . '"><img src="images/leftarrow.gif" alt="' . $prevStr . '" /></a>
      <a title="' . $nextStr . '" class="next" href="view_v.php?id=' . $id . '&amp;date=' . $nextdate . '"><img src="images/rightarrow.gif" alt="' . $nextStr . '" /></a>
      <div class="title">
        <span class="date">' . date_to_str($thisdate, '', false) . '&nbsp;&nbsp;&nbsp; - &nbsp;&nbsp;&nbsp;' . date_to_str(date('Ymd', $wkend), '', false) . '</span><br />
        <span class="viewname">' . htmlspecialchars($view_name) . '</span>
      </div>
    </div><br />';
function display_small_month($thismonth, $thisyear, $showyear, $show_weeknums = false, $minical_id = '', $month_link = 'month.php?')
{
    global $boldDays, $caturl, $DATE_FORMAT_MY, $DISPLAY_ALL_DAYS_IN_MONTH, $DISPLAY_TASKS, $DISPLAY_WEEKNUMBER, $get_unapproved, $login, $MINI_TARGET, $SCRIPT, $SHOW_EMPTY_WEEKENDS, $thisday, $today, $use_http_auth, $user, $WEEK_START;
    $nextStr = translate('Next');
    $prevStr = translate('Previous');
    $u_url = $user != $login && !empty($user) ? 'user='******'&amp;' : '';
    $weekStr = translate('Week');
    // Start the minical table for each month.
    $ret = '
    <table class="minical"' . ($minical_id != '' ? ' id="' . $minical_id . '"' : '') . '>';
    $monthstart = date('Ymd', mktime(0, 0, 0, $thismonth, 1, $thisyear));
    $monthend = date('Ymd', mktime(0, 0, 0, $thismonth + 1, 0, $thisyear));
    // Determine if the week starts on Sunday or Monday.
    // TODO:  We need to be able to start a week on ANY day.
    $wkstart = get_weekday_before($thisyear, $thismonth);
    if ($SCRIPT == 'day.php') {
        $month_ago = date('Ymd', mktime(0, 0, 0, $thismonth - 1, 1, $thisyear));
        $month_ahead = date('Ymd', mktime(0, 0, 0, $thismonth + 1, 1, $thisyear));
        $ret .= '<caption>' . $thisday . '</caption>
      <thead>
        <tr class="monthnav">
          <th colspan="' . ($DISPLAY_WEEKNUMBER == true ? 8 : 7) . '">
            <a title="' . $prevStr . '" class="prev" href="day.php?' . $u_url . 'date=' . $month_ago . $caturl . '"><img src="images/leftarrowsmall.gif" alt="' . $prevStr . '" /></a>
            <a title="' . $nextStr . '" class="next" href="day.php?' . $u_url . 'date=' . $month_ahead . $caturl . '"><img src="images/rightarrowsmall.gif" alt="' . $nextStr . '" /></a>' . date_to_str(sprintf("%04d%02d%02d", $thisyear, $thismonth, 1), $showyear != '' ? $DATE_FORMAT_MY : '__month__', false) . '
          </th>
        </tr>';
    } elseif ($SCRIPT == 'minical.php') {
        $month_ago = date('Ymd', mktime(0, 0, 0, $thismonth - 1, $thisday, $thisyear));
        $month_ahead = date('Ymd', mktime(0, 0, 0, $thismonth + 1, $thisday, $thisyear));
        $ret .= '
      <thead>
        <tr class="monthnav">
          <th colspan="7">
            <a title="' . $prevStr . '" class="prev" href="minical.php?' . $u_url . 'date=' . $month_ago . '"><img src="images/leftarrowsmall.gif" alt="' . $prevStr . '" /></a>
            <a title="' . $nextStr . '" class="next" href="minical.php?' . $u_url . 'date=' . $month_ahead . '"><img src="images/rightarrowsmall.gif" alt="' . $nextStr . '" /></a>' . date_to_str(sprintf("%04d%02d%02d", $thisyear, $thismonth, 1), $showyear != '' ? $DATE_FORMAT_MY : '__month__', false) . '
          </th>
        </tr>';
    } else {
        // Not day or minical script. Print the month name.
        $ret .= '
      <caption><a href="' . $month_link . $u_url . 'year=' . $thisyear . '&amp;month=' . $thismonth . '">' . date_to_str(sprintf("%04d%02d%02d", $thisyear, $thismonth, 1), $showyear != '' ? $DATE_FORMAT_MY : '__month__', false) . '</a></caption>
      <thead>';
    }
    $ret .= '
        <tr>' . ($show_weeknums && $DISPLAY_WEEKNUMBER == 'Y' ? '
          <th class="empty">&nbsp;</th>' : '');
    for ($i = 0; $i < 7; $i++) {
        $thday = ($i + $WEEK_START) % 7;
        $ret .= '
          <th' . (is_weekend($thday) ? ' class="weekend"' : '') . '>' . weekday_name($thday, 'D') . '</th>';
    }
    // End the header row.
    $ret .= '
        </tr>
      </thead>
      <tbody>';
    for ($i = $wkstart; date('Ymd', $i) <= $monthend; $i += 604800) {
        $tmp = $i + 172800;
        // 48 hours.
        $ret .= '
        <tr>' . ($show_weeknums && $DISPLAY_WEEKNUMBER == 'Y' ? '
          <td><a class="weeknumber" ' . 'title="' . $weekStr . '&nbsp;' . date('W', $i + 86400) . '" ' . 'href="week.php?' . $u_url . 'date=' . date('Ymd', $tmp) . '">(' . date('W', $tmp) . ')</a></td>' : '');
        for ($j = 0; $j < 7; $j++) {
            // Add 12 hours just so we don't have DST problems.
            $date = $i + ($j * 86400 + 43200);
            $dateYmd = date('Ymd', $date);
            $hasEvents = false;
            $title = '';
            $ret .= '
          <td';
            if ($boldDays) {
                $ev = get_entries($dateYmd, $get_unapproved, true, true);
                if (count($ev) > 0) {
                    $hasEvents = true;
                    $title = $ev[0]->getName();
                } else {
                    $rep = get_repeating_entries($user, $dateYmd, $get_unapproved);
                    if (count($rep) > 0) {
                        $hasEvents = true;
                        $title = $rep[0]->getName();
                    }
                }
            }
            if ($dateYmd >= $monthstart && $dateYmd <= $monthend || !empty($DISPLAY_ALL_DAYS_IN_MONTH) && $DISPLAY_ALL_DAYS_IN_MONTH == 'Y') {
                $class = (is_weekend($date) ? 'weekend' : '') . ($dateYmd == $thisyear . $thismonth . $thisday && $SCRIPT == 'day.php' ? ' selectedday' : '') . ($hasEvents ? ' hasevents' : '');
                $ret .= ($class != '' ? ' class="' . $class . '"' : '') . ($dateYmd == date('Ymd', $today) ? ' id="today"' : '') . '><a href="';
                if ($SCRIPT == 'minical.php') {
                    $ret .= ($use_http_auth ? 'day.php?user='******'nulogin.php?login='******'&amp;return_path=day.php') . '&amp;date=' . $dateYmd . '"' . (empty($MINI_TARGET) ? '' : ' target="' . $MINI_TARGET . '"') . (empty($title) ? '' : ' title="' . $title . '"');
                } else {
                    $ret .= 'day.php?' . $u_url . 'date=' . $dateYmd . '"';
                }
                $ret .= '>' . date('j', $date) . '</a></td>';
            } else {
                $ret .= ' class="empty' . (!empty($SHOW_EMPTY_WEEKENDS) && is_weekend($date) ? ' weekend' : '') . '">&nbsp;</td>';
            }
        }
        // end for $j
        $ret .= '
        </tr>';
    }
    // end for $i
    return $ret . '
      </tbody>
    </table>';
}
Beispiel #3
0
$include_header = !empty($report_include_header) && $report_include_header == 'Y';
if ($include_header || !empty($list) || !empty($error)) {
    $printerStr = empty($report_id) ? '' : generate_printer_friendly('report.php');
    print_header();
}
if (empty($offset) || empty($report_allow_nav) || $report_allow_nav != 'Y') {
    $offset = 0;
}
// Set time range based on cal_time_range field.
$dated = date('d');
$datem = date('m');
$dateY = date('Y');
$DISPLAY_WEEKENDS = 'Y';
$next = $offset + 1;
$prev = $offset - 1;
$wkstart = get_weekday_before($dateY, $datem, $dated + 1);
if (!isset($report_time_range)) {
    // Manage reports.
} else {
    if ($report_time_range >= 0 && $report_time_range < 10) {
        $today = mktime(0, 0, 0, $datem, $dated, $dateY);
        $days_offset = 1 - $report_time_range + $offset;
        $end_date = $start_date = $today + $days_offset * 86400;
    } else {
        if ($report_time_range > 9 && $report_time_range < 20) {
            $week_offset = 11 - $report_time_range + $offset;
            $start_date = $wkstart + $week_offset * 604800;
            $end_date = $start_date + 86400 * 6;
        } else {
            if ($report_time_range > 19 && $report_time_range < 30) {
                $week_offset = 21 - $report_time_range + $offset;
Beispiel #4
0
    //Set to Monday.
} else {
    $end_ind = 6;
}
if (empty($TIME_SLOTS)) {
    $TIME_SLOTS = 24;
}
$interval = 1440 / $TIME_SLOTS;
$first_slot = intval($WORK_DAY_START_HOUR * 60 / $interval);
$last_slot = intval($WORK_DAY_END_HOUR * 60 / $interval);
$untimed_found = false;
$get_unapproved = $DISPLAY_UNAPPROVED == 'Y';
// .
// Make sure all days with events are bold if mini cal is displayed.
if ($DISPLAY_SM_MONTH == 'Y' && $BOLD_DAYS_IN_YEAR == 'Y') {
    $evStart = get_weekday_before($thisyear, $thismonth);
    $evEnd = mktime(23, 59, 59, $thismonth + 2, 0, $thisyear);
} else {
    $evStart = $wkstart;
    $evEnd = $wkend;
}
/* Pre-Load the repeated events for quickier access. */
$repeated_events = read_repeated_events(strlen($user) ? $user : $login, $evStart, $evEnd, $cat_id);
/* Pre-load the non-repeating events for quicker access. */
// Start the search ONE_WEEK early to account for cross-day events.
$events = read_events(strlen($user) ? $user : $login, $evStart - 604800, $evEnd, $cat_id);
if (empty($DISPLAY_TASKS_IN_GRID) || $DISPLAY_TASKS_IN_GRID == 'Y') {
    /* Pre-load tasks for quicker access. */
    $tasks = read_tasks(!empty($user) && strlen($user) && $is_assistant ? $user : $login, $wkend, $cat_id);
}
$eventsStr = $filler = $headerStr = $minical_tasks = $untimedStr = '';
function print_menu_dates($menu = false)
{
    global $cat_id, $CATEGORIES_ENABLED, $custom_view, $DATE_FORMAT_MD, $DATE_FORMAT_MY, $DISPLAY_WEEKENDS, $id, $login, $SCRIPT, $thisday, $thismonth, $thisyear, $user, $WEEK_START;
    $goStr = translate('Go');
    $ret = $urlArgs = $include_id = '';
    // TODO add this to admin and pref.
    // Change this value to 'Y' to enable staying in custom views.
    $STAY_IN_VIEW = 'N';
    $selected = ' selected="selected"';
    if ($STAY_IN_VIEW == 'Y' && !empty($custom_view)) {
        $include_id = true;
        $monthUrl = $SCRIPT;
    } else {
        if (access_can_view_page('month.php')) {
            $monthUrl = 'month.php';
        } else {
            $monthUrl = $GLOBALS['STARTVIEW'];
            if (preg_match('/[?&](\\S+)=(\\S+)/', $monthUrl, $match)) {
                $monthUrl = $match[0];
                $urlArgs = '
              <input type="hidden" name="' . $match[1] . '" value="' . $match[2] . '" />';
            }
        }
    }
    if (access_can_access_function(ACCESS_MONTH)) {
        $ret .= '
            <form action="' . $monthUrl . '" method="get" name="SelectMonth" id="month' . ($menu ? 'menu' : 'form') . '"> ' . $urlArgs . (!empty($user) && $user != $login ? '
              <input type="hidden" name="user" value="' . $user . '" />' : '') . (!empty($id) && $include_id ? '
              <input type="hidden" name="id" value="' . $id . '" />' : '') . (!empty($cat_id) && $CATEGORIES_ENABLED == 'Y' && (!$user || $user == $login) ? '
              <input type="hidden" name="cat_id" value="' . $cat_id . '" />' : '') . '
              <label for="monthselect"><a ' . 'href="javascript:document.SelectMonth.submit()">' . translate('Month') . '</a>:&nbsp;</label>
              <select name="date" id="monthselect" ' . 'onchange="document.SelectMonth.submit()">';
        if (!empty($thisyear) && !empty($thismonth)) {
            $m = $thismonth;
            $y = $thisyear;
        } else {
            $m = date('m');
            $y = date('Y');
        }
        $d_time = mktime(0, 0, 0, $m, 1, $y);
        $thisdate = date('Ymd', $d_time);
        // $y--;
        $m -= 7;
        for ($i = 0; $i < 25; $i++) {
            $m++;
            if ($m > 12) {
                $m = 1;
                $y++;
            }
            if ($y >= 1970 && $y < 2038) {
                $d = mktime(0, 0, 0, $m, 1, $y);
                $dateYmd = date('Ymd', $d);
                $ret .= '
                  <option value="' . $dateYmd . '"' . ($dateYmd == $thisdate ? $selected : '') . '>' . date_to_str($dateYmd, $DATE_FORMAT_MY, false, true, 0) . '</option>';
            }
        }
    }
    if (access_can_access_function(ACCESS_WEEK)) {
        $ret .= '
              </select>' . ($menu ? '' : '
              <input type="submit" value="' . $goStr . '" />') . '
            </form>' . ($menu ? '
          </td>
          <td class="ThemeMenubackgr ThemeMenu">' : '');
        if ($STAY_IN_VIEW == 'Y' && !empty($custom_view)) {
            $weekUrl = $SCRIPT;
        } else {
            if (access_can_view_page('week.php')) {
                $urlArgs = '';
                $weekUrl = 'week.php';
            } else {
                $weekUrl = $GLOBALS['STARTVIEW'];
                if (preg_match('/[?&](\\S+)=(\\S+)/', $weekUrl, $match)) {
                    $weekUrl = $match[0];
                    $urlArgs = '
                <input type="hidden" name="' . $match[1] . '" value="' . $match[2] . '" />';
                }
            }
        }
        $ret .= '
            <form action="' . $weekUrl . '" method="get" name="SelectWeek" id="week' . ($menu ? 'menu' : 'form') . '">' . $urlArgs . (!empty($user) && $user != $login ? '
              <input type="hidden" name="user" value="' . $user . '" />' : '') . (!empty($id) && $include_id ? '
              <input type="hidden" name="id" value="' . $id . '" />' : '') . (!empty($cat_id) && $CATEGORIES_ENABLED == 'Y' && (!$user || $user == $login) ? '
              <input type="hidden" name="cat_id" value="' . $cat_id . '" />' : '') . '
              <label for="weekselect"><a ' . 'href="javascript:document.SelectWeek.submit()">' . translate('Week') . '</a>:&nbsp;</label>
              <select name="date" id="weekselect" ' . 'onchange="document.SelectWeek.submit()">';
        if (!empty($thisyear) && !empty($thismonth)) {
            $m = $thismonth;
            $y = $thisyear;
        } else {
            $m = date('m');
            $y = date('Y');
        }
        $d = empty($thisday) ? date('d') : $thisday;
        $d_time = mktime(0, 0, 0, $m, $d, $y);
        $thisweek = date('W', $d_time);
        $wkstart = get_weekday_before($y, $m, $d);
        $lastDay = $DISPLAY_WEEKENDS == 'N' ? 4 : 6;
        for ($i = -5; $i <= 9; $i++) {
            $twkstart = $wkstart + 604800 * $i;
            $twkend = $twkstart + 86400 * $lastDay;
            $dateSYmd = date('Ymd', $twkstart);
            $dateEYmd = date('Ymd', $twkend);
            $dateW = date('W', $twkstart + 86400);
            if ($twkstart > 0 && $twkend < 2146021200) {
                $ret .= '
                <option value="' . $dateSYmd . '"' . ($dateW == $thisweek ? $selected : '') . '>' . (!empty($GLOBALS['PULLDOWN_WEEKNUMBER']) && $GLOBALS['PULLDOWN_WEEKNUMBER'] == 'Y' ? '( ' . $dateW . ' )&nbsp;&nbsp;' : '') . sprintf("%s - %s", date_to_str($dateSYmd, $DATE_FORMAT_MD, false, true, 0), date_to_str($dateEYmd, $DATE_FORMAT_MD, false, true, 0)) . '</option>';
            }
        }
    }
    if (access_can_access_function(ACCESS_YEAR)) {
        $ret .= '
                </select>' . ($menu ? '' : '
              <input type="submit" value="' . $goStr . '" />') . '
            </form>' . ($menu ? '
          </td>
          <td class="ThemeMenubackgr ThemeMenu" align="right">' : '');
        if ($STAY_IN_VIEW == 'Y' && !empty($custom_view)) {
            $yearUrl = $SCRIPT;
        } else {
            if (access_can_view_page('year.php')) {
                $urlArgs = '';
                $yearUrl = 'year.php';
            } else {
                $yearUrl = $GLOBALS['STARTVIEW'];
                if (preg_match('/[?&](\\S+)=(\\S+)/', $yearUrl, $match)) {
                    $yearUrl = $match[0];
                    $urlArgs = '
              <input type="hidden" name="' . $match[1] . '" value="' . $match[2] . '" />';
                }
            }
        }
        $ret .= '
            <form action="' . $yearUrl . '" method="get" name="SelectYear" id="year' . ($menu ? 'menu' : 'form') . '">' . $urlArgs . (!empty($user) && $user != $login ? '
              <input type="hidden" name="user" value="' . $user . '" />' : '') . (!empty($id) && $include_id ? '
              <input type="hidden" name="id" value="' . $id . '" />' : '') . (!empty($cat_id) && $CATEGORIES_ENABLED == 'Y' && (!$user || $user == $login) ? '
              <input type="hidden" name="cat_id" value="' . $cat_id . '" />' : '') . '
              <label for="yearselect"><a ' . 'href="javascript:document.SelectYear.submit()">' . translate('Year') . '</a>:&nbsp;</label>
              <select name="year" id="yearselect" ' . 'onchange="document.SelectYear.submit()">';
        $y = empty($thisyear) ? date('Y') : $thisyear;
        for ($i = $y - 2; $i < $y + 6; $i++) {
            if ($i >= 1970 && $i < 2038) {
                $ret .= '
                <option value="' . $i . '"' . ($i == $y ? $selected : '') . ">{$i}" . '</option>';
            }
        }
        $ret .= '
              </select>' . ($menu ? '' : '
              <input type="submit" value="' . $goStr . '" />') . '
            </form>';
    }
    return $ret;
}