2020)) { exit_error(_('Invalid year'), _('Not between 1990 and 2000')); } if ($month && ($month < 1 || $month > 12)) { exit_error(_('Invalid month'), _('Not between 1 and 12')); } if ($day && ($day < 1 || $day > 31)) { exit_error(_('Invalid day'), _('Not between 1 and 31')); } if ($year && isset($month) && isset($day)) { if (!checkdate($month, $day, $year)) { exit_error(_('Invalid date'), sprintf(_('Date not valid'), "$year-$month-$day")); } } if ($type && $type != 'onemonth' && $type != 'threemonth' && $type != 'currentyear' && $type != 'comingyear') { exit_error(_('Invalid type'), _('Type not in onemonth, threemonth, currentyear, comingyear')); } // Fill in defaults if (!$type) { $type = 'threemonth'; } $today = getdate(time()); if (!$year) { $year = $today['year']; } if (!$month) { $month = $today['mon']; } if (!$day) { $day = $today['mday']; } $months = array(1 => _('January'), _('February'), _('March'), _('April'), _('May'), _('June'), _('July'), _('August'), _('September'), _('October'), _('November'), _('December')); if ($group_id && $group_project_id) { require_once $gfcommon.'pm/ProjectTaskFactory.class.php'; require_once $gfcommon.'pm/ProjectGroup.class.php'; $g =& group_get_object($group_id); if (!$g || !is_object($g)) { exit_no_group(); } elseif ($g->isError()) { exit_error(_('ERROR'), $g->getErrorMessage()); } $pg = new ProjectGroup($g, $group_project_id); if (!$pg || !is_object($pg)) { exit_error(_('ERROR'), 'BUG: Could Not Get Factory'); } elseif ($pg->isError()) { exit_error(_('ERROR'), $pg->getErrorMessage()); } $ptf = new ProjectTaskFactory($pg); if (!$ptf || !is_object($ptf)) { exit_error(_('ERROR'), 'BUG: Could Not Get ProjectTaskFactory'); } elseif ($ptf->isError()) { exit_error(_('ERROR'), $ptf->getErrorMessage()); } // Violate all known laws about OOP here $ptf->offset=0; $ptf->order='start_date'; $ptf->max_rows=50; $ptf->status=1; $ptf->assigned_to=0; $ptf->category=0; $pt_arr =& $ptf->getTasks(); if ($ptf->isError()) { exit_error(_('ERROR'), $ptf->getErrorMessage()); } } $HTML->header(array('title'=>_('Calendar'),'group'=>$group_id)); /** * Create link to a task. * This returns a string that is a link to a particular task. * * @author Ryan T. Sammartino * @param $task the task to make a link for. * @param $type either 'begin' for beginning of a task or 'end' for * end of a task. * @date 2002-01-04 * */ function make_task_link($task, $type) { global $HTML, $group_id, $group_project_id; return '' . ($type == 'begin' ? sprintf(_('Task %d begins'), $task->getID()) : sprintf(_('Task %d ends'), $task->getID()) ) . ''; } /** * Display one month. * This displays one month. m may be less than 0 and greater than 12: display_month * uses mktime() to readjust it and the year in such cases. * * @author Ryan T. Sammartino * @param m month * @param y year * @date 2002-12-29 * */ function display_month($m, $y) { global $months, $today, $month, $day, $year, $HTML, $pt_arr, $group_id, $group_project_id; $dow = array(_('Sunday'), _('Monday'), _('Tuesday'), _('Wednesday'), _('Thursday'), _('Friday'), _('Saturday')); $tstamp = mktime(0, 0, 0, $m + 1, 0, $y) ; $date = getdate($tstamp); $days_in_month = $date['mday']; $date = getdate($tstamp); $first_dow = $date['wday']; $m = $date['mon']; $y = $date['year']; ?> $val\n"; } ?> \n"; while ($curr_dow != $first_dow) { print "\t\t\t\n"; $curr_dow++; } while ($curr_date <= $days_in_month) { while ($curr_dow < 7) { if ($curr_date <= $days_in_month) { $colour = ""; if ($curr_date == $today['mday'] && $y == $today['year'] && $m == $today['mon']) { $colour = " today"; } elseif ($curr_date == $day && $y == $year && $m == $month) { $colour = " day"; } print "\t\t\t\n"; } else { print "\t\t\t\n"; } $curr_dow++; $curr_date++; } print "\t\t\n"; if ($curr_date <= $days_in_month) { print "\t\t\n"; } $curr_dow = 0; } ?>
$curr_date"; $cell_contents = ''; $rows = count($pt_arr); for ($i = 0; $i < $rows; $i++) { $start_date = getdate($pt_arr[$i]->getStartDate()); $end_date = getdate($pt_arr[$i]->getEndDate()); if ($curr_date == $start_date['mday'] && $y == $start_date['year'] && $m == $start_date['mon']) { $cell_contents .= make_task_link($pt_arr[$i], 'begin'); } elseif ($curr_date == $end_date['mday'] && $y == $end_date['year'] && $m == $end_date['mon']) { $cell_contents .= make_task_link($pt_arr[$i], 'end'); } } if ($cell_contents == '') { $cell_contents = '


'; } print "$cell_contents


'; } ?>
\n\n"; display_month($month, $year); print "\t
\n\n"; display_month($month + 1, $year); } elseif ($type == 'currentyear') { for ($i = 1; $i <= 12; $i++) { display_month($i, $year); print "\t
\n\n"; } } elseif ($type == 'comingyear') { for ($i = 0; $i < 12; $i++) { display_month($month + $i, $year); print "\t
\n\n"; } } $HTML->footer(array()); // Local Variables: // mode: php // c-file-style: "bsd" // End: ?>