本文整理汇总了PHP中CDate::dateDiff方法的典型用法代码示例。如果您正苦于以下问题:PHP CDate::dateDiff方法的具体用法?PHP CDate::dateDiff怎么用?PHP CDate::dateDiff使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDate
的用法示例。
在下文中一共展示了CDate::dateDiff方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setDateRange
public function setDateRange($start_date, $end_date)
{
$min_d_start = new CDate($start_date);
$max_d_end = new CDate($end_date);
// check day_diff and modify Headers
$day_diff = $min_d_start->dateDiff($max_d_end);
//-----------------------------------------
// nice Gantt image
// if diff(end_date,start_date) > 90 days it shows only
//week number
// if diff(end_date,start_date) > 240 days it shows only
//month number
//-----------------------------------------
if ($day_diff > 240) {
//more than 240 days
$this->graph->ShowHeaders(GANTT_HYEAR | GANTT_HMONTH);
} else {
if ($day_diff > 90) {
//more than 90 days and less of 241
$this->graph->ShowHeaders(GANTT_HYEAR | GANTT_HMONTH | GANTT_HWEEK);
$this->graph->scale->week->SetStyle(WEEKSTYLE_WNBR);
}
}
$this->graph->SetDateRange($start_date, $end_date);
}
示例2: getEventLinks
/**
* Sub-function to collect events within a period
* @param Date the starting date of the period
* @param Date the ending date of the period
* @param array by-ref an array of links to append new items to
* @param int the length to truncate entries by
* @author Andrew Eddie <eddieajau@users.sourceforge.net>
*/
function getEventLinks($startPeriod, $endPeriod, &$links, $strMaxLen)
{
global $AppUI, $event_filter;
$events = CEvent::getEventsForPeriod($startPeriod, $endPeriod, $event_filter);
// assemble the links for the events
foreach ($events as $row) {
$start = new CDate($row['event_start_date']);
$end = new CDate($row['event_end_date']);
$date = $start;
$date->setTime(0, 0, 0);
$cwd = explode(',', $GLOBALS['dPconfig']['cal_working_days']);
for ($i = 0, $x = $end->dateDiff($start); $i <= $x; $i++) {
// the link
// optionally do not show events on non-working days
if ($row['event_cwd'] && in_array($date->getDayOfWeek(), $cwd) || !$row['event_cwd']) {
$link['href'] = '?m=calendar&a=view&event_id=' . $row['event_id'];
$link['alt'] = $row['event_description'];
$link['text'] = dPshowImage(dPfindImage('event' . $row['event_type'] . '.png', 'calendar'), 16, 16) . htmlspecialchars($row['event_title']);
if ($i == 0) {
$link['alt'] .= ' [' . $AppUI->_('START') . ']';
}
if ($i == $x) {
$link['alt'] .= ' [' . $AppUI->_('END') . ']';
}
$links[$date->format(FMT_TIMESTAMP_DATE)][] = $link;
}
$date = $date->getNextDay();
}
}
}
示例3: getEventLinks
/**
* Sub-function to collect events within a period
* @param Date the starting date of the period
* @param Date the ending date of the period
* @param array by-ref an array of links to append new items to
* @param int the length to truncate entries by
* @author Andrew Eddie <eddieajau@users.sourceforge.net>
*/
function getEventLinks($startPeriod, $endPeriod, &$links, $strMaxLen, $minical = false)
{
global $event_filter;
$events = CEvent::getEventsForPeriod($startPeriod, $endPeriod, $event_filter);
$cwd = explode(',', w2PgetConfig('cal_working_days'));
// assemble the links for the events
foreach ($events as $row) {
$start = new CDate($row['event_start_date']);
$end = new CDate($row['event_end_date']);
$date = $start;
for ($i = 0, $i_cmp = $start->dateDiff($end); $i <= $i_cmp; $i++) {
// the link
// optionally do not show events on non-working days
if ($row['event_cwd'] && in_array($date->getDayOfWeek(), $cwd) || !$row['event_cwd']) {
if ($minical) {
$link = array();
} else {
$url = '?m=calendar&a=view&event_id=' . $row['event_id'];
$link['href'] = '';
$link['alt'] = '';
$link['text'] = w2PtoolTip($row['event_title'], getEventTooltip($row['event_id']), true) . w2PshowImage('event' . $row['event_type'] . '.png', 16, 16, '', '', 'calendar') . '</a> ' . '<a href="' . $url . '"><span class="event">' . $row['event_title'] . '</span></a>' . w2PendTip();
}
$links[$date->format(FMT_TIMESTAMP_DATE)][] = $link;
}
$date = $date->getNextDay();
}
}
}
示例4: getEventLinks
/**
* Sub-function to collect events within a period
* @param Date the starting date of the period
* @param Date the ending date of the period
* @param array by-ref an array of links to append new items to
* @param int the length to truncate entries by
* @author Andrew Eddie <eddieajau@users.sourceforge.net>
*/
function getEventLinks($startPeriod, $endPeriod, &$links, $strMaxLen)
{
global $event_filter;
$events = CEvent::getEventsForPeriod($startPeriod, $endPeriod, $event_filter);
// assemble the links for the events
foreach ($events as $row) {
$start = new CDate($row['event_start_date']);
$end = new CDate($row['event_end_date']);
$date = $start;
$cwd = explode(",", $GLOBALS["dPconfig"]['cal_working_days']);
for ($i = 0; $i <= $start->dateDiff($end); $i++) {
// the link
// optionally do not show events on non-working days
if ($row['event_cwd'] && in_array($date->getDayOfWeek(), $cwd) || !$row['event_cwd']) {
$url = '?m=calendar&a=view&event_id=' . $row['event_id'];
$link['href'] = '';
$link['alt'] = $row['event_description'];
$link['text'] = '<table cellspacing="0" cellpadding="0" border="0"><tr>' . '<td><a href=' . $url . '>' . dPshowImage(dPfindImage('event' . $row['event_type'] . '.png', 'calendar'), 16, 16, '') . '</a></td>' . '<td><a href="' . $url . '" title="' . $row['event_description'] . '"><span class="event">' . $row['event_title'] . '</span></a>' . '</td></tr></table>';
$links[$date->format(FMT_TIMESTAMP_DATE)][] = $link;
}
$date = $date->getNextDay();
}
}
}
示例5: displayTask
function displayTask($list, $task, $level, $display_week_hours, $fromPeriod, $toPeriod, $user_id, $canEditINA)
{
global $AppUI, $df, $durnTypes, $log_userfilter_users, $priority, $system_users, $z, $zi, $x, $userAlloc;
$zi++;
$users = $task->task_assigned_users;
$task->userPriority = $task->getUserSpecificTaskPriority($user_id);
$projects = $task->getProject();
$tmp = "<tr>";
$tmp .= "<td align=\"center\" nowrap=\"nowrap\">";
$tmp .= "<input type=\"checkbox\" name=\"selected_task[{$task->task_id}]\" value=\"{$task->task_id}\"/>";
$tmp .= "</td>";
/*ina
*/
$tmp .= "<td>";
for ($i = 0; $i < $level; $i++) {
$tmp .= " ";
}
if ($task->task_milestone == true) {
$tmp .= "<B>";
}
if ($level >= 1) {
$tmp .= dPshowImage(dPfindImage('corner-dots.gif', 'tasks'), 16, 12, 'Subtask') . " ";
}
$tmp .= "<a href='?m=tasks&a=view&task_id={$task->task_id}'>" . $task->task_name . "</a>";
if ($task->task_milestone == true) {
$tmp .= "</B>";
}
if ($task->task_priority < 0) {
$tmp .= " (<img src=\"./images/icons/priority-" . -$task->task_priority . ".gif\" width=13 height=16>)";
} elseif ($task->task_priority > 0) {
$tmp .= " (<img src=\"./images/icons/priority+" . $task->task_priority . ".gif\" width=13 height=16>)";
}
$tmp .= "</td>";
$tmp .= "<td align=\"center\">";
$tmp .= "<a href='?m=projects&a=view&project_id={$task->task_project}' style='background-color:#" . @$projects["project_color_identifier"] . "; color:" . bestColor(@$projects['project_color_identifier']) . "'>" . $projects['project_short_name'] . "</a>";
$tmp .= "</td>";
$tmp .= "<td align=\"center\" nowrap=\"nowrap\">";
$tmp .= $task->task_duration . " " . $AppUI->_($durnTypes[$task->task_duration_type]);
$tmp .= "</td>";
$tmp .= "<td align=\"center\" nowrap=\"nowrap\">";
$dt = new CDate($task->task_start_date);
$tmp .= $dt->format($df);
$tmp .= "   </td>";
$tmp .= "<td align=\"center\" nowrap=\"nowrap\">";
$ed = new CDate($task->task_end_date);
$now = new CDate();
$dt = $now->dateDiff($ed);
$sgn = $now->compare($ed, $now);
$tmp .= $dt * $sgn;
$tmp .= "</td>";
if ($display_week_hours) {
$tmp .= displayWeeks($list, $task, $level, $fromPeriod, $toPeriod);
}
$tmp .= "<td>";
$sep = $us = "";
foreach ($users as $row) {
if ($row["user_id"]) {
if ($canEditINA) {
$us .= "<a href='?m=admin&a=viewuser&user_id={$row['0']}'>" . $sep . $row['contact_last_name'] . " \n \t(" . $row['perc_assignment'] . "%)</a>";
} else {
$us .= $sep . $row['contact_last_name'] . " (" . $row['perc_assignment'] . "%)";
}
/*ina*/
$sep = ", ";
}
}
$tmp .= $us;
$tmp .= "</td>";
// create the list of possible assignees
if ($zi == 1) {
// selectbox may not have a size smaller than 2, use 5 here as minimum
$zz = $z < 5 ? 5 : $z * 1.5;
if (sizeof($users) >= 7) {
$zz = $zz * 2;
}
$zm1 = $z - 2;
if ($zm1 == 0) {
$zm1 = 1;
}
$assUser = $userAlloc[$user_id]['userFC'];
if ($user_id == 0) {
// need to handle orphaned tasks different from tasks with existing assignees
$zm1++;
}
if ($canEditINA) {
$tmp .= "<td valign=\"top\" align=\"center\" nowrap=\"nowrap\" rowspan=\"{$zm1}\">";
$tmp .= '<select name="add_users" style="width:200px" size="' . ($zz - 1) . '" class="text" multiple="multiple" ondblclick="javascript:chAssignment(' . $user_id . ', 0, false)">';
foreach ($userAlloc as $v => $u) {
$tmp .= "\n\t<option value=\"" . $u['user_id'] . "\">" . dPformSafe($u['userFC']) . "</option>";
}
$tmp .= '</select>';
//$tmp.= arraySelect( $user_list, 'add_users', 'class="text" STYLE="width: 200px" size="'.($zz-1).'" multiple="multiple"',NULL );
$tmp .= "</td>";
}
}
$tmp .= "</tr>\n";
return $tmp;
}
示例6: importTasks
/** Import tasks from another project
*
* @param int Project ID of the tasks come from.
* @return bool
**/
function importTasks($from_project_id)
{
// Load the original
$origProject = new CProject();
$origProject->load($from_project_id);
$q = new DBQuery();
$q->addTable('tasks');
$q->addQuery('task_id');
$q->addWhere('task_project =' . $from_project_id);
$sql = $q->prepare();
$q->clear();
$tasks = array_flip(db_loadColumn($sql));
$origDate = new CDate($origProject->project_start_date);
$destDate = new CDate($this->project_start_date);
$dateOffset = $destDate->dateDiff($origDate);
// Old dependencies array from imported tasks
$deps = array();
// New dependencies array for new copies of imported tasks
$newDeps = array();
// Old2New task ID array
$taskXref = array();
// New task ID to old parent array
$nid2op = array();
// Copy each task into this project and get their deps
foreach ($tasks as $orig => $void) {
$objTask = new CTask();
$objTask->load($orig);
// Grab the old parent id
$oldParent = (int) $objTask->task_parent;
$deps[$orig] = $objTask->getDependencies();
$destTask = $objTask->copy($this->project_id, 0);
$nid2op[$destTask->task_id] = $oldParent;
$tasks[$orig] = $destTask;
$taskXref[$orig] = (int) $destTask->task_id;
}
// Build new dependencies array
foreach ($deps as $odkey => $od) {
$ndt = '';
$ndkey = $taskXref[$odkey];
$odep = explode(',', $od);
foreach ($odep as $odt) {
$ndt = $ndt . $taskXref[$odt] . ',';
}
$ndt = rtrim($ndt, ',');
$newDeps[$ndkey] = $ndt;
}
$q->addTable('tasks');
$q->addQuery('task_id');
$q->addWhere('task_project =' . $this->project_id);
$tasks = $q->loadColumn();
// Update dates based on new project's start date.
foreach ($tasks as $task_id) {
$newTask = new CTask();
$newTask->load($task_id);
if (in_array($task_id, $taskXref)) {
// Fix task start date from project start date offset
$origDate->setDate($newTask->task_start_date);
$destDate->setDate($newTask->task_start_date);
$destDate->addDays($dateOffset);
$destDate = $destDate->next_working_day();
$newTask->task_start_date = $destDate->format(FMT_DATETIME_MYSQL);
// Fix task end date from start date + work duration
//$newTask->calc_task_end_date();
if (!empty($newTask->task_end_date) && $newTask->task_end_date != '0000-00-00 00:00:00') {
$origDate->setDate($newTask->task_end_date);
$destDate->setDate($newTask->task_end_date);
$destDate->addDays($dateOffset);
$destDate = $destDate->next_working_day();
$newTask->task_end_date = $destDate->format(FMT_DATETIME_MYSQL);
}
$newTask->task_parent = $taskXref[$nid2op[$newTask->task_id]];
$newTask->store();
$newTask->updateDependencies($newDeps[$task_id]);
}
// end check if imported task
$newTask->store();
}
// end Fix record integrity
}
示例7: remind
/**
* Called by the Event Queue processor to process a reminder
* on a task.
* @access public
* @param string $module Module name (not used)
* @param string $type Type of event (not used)
* @param integer $id ID of task being reminded
* @param integer $owner Originator of event
* @param mixed $args event-specific arguments.
* @return mixed true, dequeue event, false, event stays in queue.
-1, event is destroyed.
*/
function remind($module, $type, $id, $owner, &$args)
{
global $locale_char_set, $AppUI;
$q = new DBQuery();
$df = $AppUI->getPref('SHDATEFORMAT');
$tf = $AppUI->getPref('TIMEFORMAT');
// If we don't have preferences set for these, use ISO defaults.
if (!$df) {
$df = '%Y-%m-%d';
}
if (!$tf) {
$tf = '%H:%m';
}
$df .= ' ' . $tf;
// At this stage we won't have an object yet
if (!$this->load($id)) {
return -1;
// No point it trying again later.
}
$this->htmlDecode();
// Only remind on working days.
$today = new CDate();
if (!$today->isWorkingDay()) {
return true;
}
// Check if the task is completed
if ($this->task_percent_complete == 100) {
return -1;
}
// Grab the assignee list
$q->addTable('user_tasks', 'ut');
$q->leftJoin('users', 'u', 'u.user_id = ut.user_id');
$q->leftJoin('contacts', 'c', 'c.contact_id = u.user_contact');
$q->addQuery('c.contact_id, contact_first_name, contact_last_name, contact_email');
$q->addWhere('ut.task_id = ' . $id);
$contacts = $q->loadHashList('contact_id');
$q->clear();
// Now we also check the owner of the task, as we will need
// to notify them as well.
$owner_is_not_assignee = false;
$q->addTable('users', 'u');
$q->leftJoin('contacts', 'c', 'c.contact_id = u.user_contact');
$q->addQuery('c.contact_id, contact_first_name, contact_last_name, contact_email');
$q->addWhere('u.user_id = ' . $this->task_owner);
if ($q->exec(ADODB_FETCH_NUM)) {
list($owner_contact, $owner_first_name, $owner_last_name, $owner_email) = $q->fetchRow();
if (!isset($contacts[$owner_contact])) {
$owner_is_not_assignee = true;
$contacts[$owner_contact] = array('contact_id' => $owner_contact, 'contact_first_name' => $owner_first_name, 'contact_last_name' => $owner_last_name, 'contact_email' => $owner_email);
}
}
$q->clear();
// build the subject line, based on how soon the
// task will be overdue.
$starts = new CDate($this->task_start_date);
$expires = new CDate($this->task_end_date);
$now = new CDate();
$diff = $expires->dateDiff($now);
$prefix = $AppUI->_('Task Due', UI_OUTPUT_RAW);
if ($diff == 0) {
$msg = $AppUI->_('TODAY', UI_OUTPUT_RAW);
} else {
if ($diff == 1) {
$msg = $AppUI->_('TOMORROW', UI_OUTPUT_RAW);
} else {
if ($diff < 0) {
$msg = $AppUI->_(array('OVERDUE', abs($diff), 'DAYS'));
$prefix = $AppUI->_('Task', UI_OUTPUT_RAW);
} else {
$msg = $AppUI->_(array($diff, 'DAYS'));
}
}
}
$q->addTable('projects');
$q->addQuery('project_name');
$q->addWhere('project_id = ' . $this->task_project);
$project_name = htmlspecialchars_decode($q->loadResult());
$q->clear();
$subject = $prefix . ' ' . $msg . ' ' . $this->task_name . '::' . $project_name;
$body = $AppUI->_('Task Due', UI_OUTPUT_RAW) . ': ' . $msg . "\n" . $AppUI->_('Project', UI_OUTPUT_RAW) . ': ' . $project_name . "\n" . $AppUI->_('Task', UI_OUTPUT_RAW) . ': ' . $this->task_name . "\n" . $AppUI->_('Start Date', UI_OUTPUT_RAW) . ': ' . $starts->format($df) . "\n" . $AppUI->_('Finish Date', UI_OUTPUT_RAW) . ': ' . $expires->format($df) . "\n" . $AppUI->_('URL', UI_OUTPUT_RAW) . ': ' . DP_BASE_URL . '/index.php?m=tasks&a=view&task_id=' . $this->task_id . '&reminded=1' . "\n\n" . $AppUI->_('Resources', UI_OUTPUT_RAW) . ":\n";
foreach ($contacts as $contact) {
if ($owner_is_not_assignee || $contact['contact_id'] != $owner_contact) {
$body .= $contact['contact_first_name'] . ' ' . $contact['contact_last_name'] . ' <' . $contact['contact_email'] . ">\n";
}
}
$body .= "\n" . $AppUI->_('Description', UI_OUTPUT_RAW) . ":\n" . $this->task_description . "\n";
$mail = new Mail();
foreach ($contacts as $contact) {
//.........这里部分代码省略.........
示例8: importTasks
/** Import tasks from another project
*
* @param int Project ID of the tasks come from.
* @return bool
**/
function importTasks($from_project_id, $scale_project = false)
{
// Load the original
$origProject = new CProject();
$origProject->load($from_project_id);
$q = new DBQuery();
$q->addTable('tasks');
$q->addQuery('task_id');
$q->addWhere('task_project =' . $from_project_id);
$sql = $q->prepare();
$q->clear();
$tasks = array_flip(db_loadColumn($sql));
//Pristine Start and End Dates of Source and Destination Projects
$origStartDate = new CDate($origProject->project_start_date);
$origEndDate = new CDate($origProject->project_end_date);
$destStartDate = new CDate($this->project_start_date);
$destEndDate = new CDate($this->project_end_date);
$dateOffset = $destStartDate->dateDiff($origStartDate);
//Check that we have enough information to scale properly
//(i.e. no information is missing or "zero")
if (empty($origProject->project_start_date) || empty($origProject->project_end_date) || empty($this->project_start_date) || empty($this->project_end_date) || $origProject->project_start_date == '0000-00-00 00:00:00' || $origProject->project_end_date == '0000-00-00 00:00:00' || $this->project_start_date == '0000-00-00 00:00:00' || $this->project_end_date == '0000-00-00 00:00:00') {
$scale_project = false;
}
if ($scale_project) {
//get ratio for scaling, protect from division by 0
$ratio = (abs($destEndDate->dateDiff($destStartDate)) + 1) / (abs($origEndDate->dateDiff($origStartDate)) + 1);
}
// Old dependencies array from imported tasks
$deps = array();
// New dependencies array for new copies of imported tasks
$newDeps = array();
// Old2New task ID array
$taskXref = array();
// New task ID to old parent array
$nid2op = array();
// Copy each task into this project and get their deps
foreach ($tasks as $orig => $void) {
$objTask = new CTask();
$objTask->load($orig);
// Grab the old parent id
$oldParent = (int) $objTask->task_parent;
$deps[$orig] = $objTask->getDependencies();
$destTask = $objTask->copy($this->project_id, 0);
$nid2op[$destTask->task_id] = $oldParent;
$tasks[$orig] = $destTask;
$taskXref[$orig] = (int) $destTask->task_id;
}
// Build new dependencies array
foreach ($deps as $odkey => $od) {
$ndt = '';
$ndkey = $taskXref[$odkey];
$odep = explode(',', $od);
foreach ($odep as $odt) {
$ndt = $ndt . $taskXref[$odt] . ',';
}
$ndt = rtrim($ndt, ',');
$newDeps[$ndkey] = $ndt;
}
$q->addTable('tasks');
$q->addQuery('task_id');
$q->addWhere('task_project =' . $this->project_id);
$tasks = $q->loadColumn();
// Update dates based on new project's start date.
$origDate = new CDate($origProject->project_start_date);
$origStartHour = new CDate($this->project_start_date);
$destDate = new CDate($this->project_start_date);
foreach ($tasks as $task_id) {
$newTask = new CTask();
$newTask->load($task_id);
if (in_array($task_id, $taskXref)) {
$task_date_vars = array('task_start_date', 'task_end_date');
//Adjust task dates based on calculated offsets
foreach ($task_date_vars as $my_date) {
if (!empty($newTask->{$my_date}) && $newTask->{$my_date} != '0000-00-00 00:00:00') {
$origDate->setDate($newTask->{$my_date});
$origStartHour->setDate($newTask->{$my_date});
$origStartHour->setTime(intval(dPgetConfig('cal_day_start')));
$destDate->setDate($newTask->{$my_date});
$destDate->addDays($dateOffset);
if ($scale_project) {
$offsetAdd = round($origDate->dateDiff($origStartDate) * $ratio) - $origDate->dateDiff($origStartDate);
$destDate->addDays($offsetAdd);
$hours_in = $origStartHour->calcDuration($origDate);
$offsetAddHours = round($hours_in * $ratio) - $hours_in;
if ($offsetAddHours % dPgetConfig('daily_working_hours')) {
$destDate->addDuration($offsetAddHours);
}
}
$destDate = $destDate->next_working_day();
$newTask->{$my_date} = $destDate->format(FMT_DATETIME_MYSQL);
}
}
//Adjust durration to scale
if ($scale_project) {
$newTask->task_duration = round($newTask->task_duration * $ratio, 2);
//.........这里部分代码省略.........
示例9: showtask_pr
function showtask_pr(&$a, $level = 0, $is_opened = true, $today_view = false)
{
global $AppUI, $dPconfig, $done, $query_string, $durnTypes, $userAlloc, $showEditCheckbox;
global $task_access, $task_priority;
$types = dPgetsysval('TaskType');
$now = new CDate();
$tf = $AppUI->getPref('TIMEFORMAT');
$df = $AppUI->getPref('SHDATEFORMAT');
$fdf = $df . " " . $tf;
$perms =& $AppUI->acl();
$show_all_assignees = @$dPconfig['show_all_task_assignees'] ? true : false;
$done[] = $a['task_id'];
$start_date = intval($a["task_start_date"]) ? new CDate($a["task_start_date"]) : null;
$end_date = intval($a["task_end_date"]) ? new CDate($a["task_end_date"]) : null;
$last_update = isset($a['last_update']) && intval($a['last_update']) ? new CDate($a['last_update']) : null;
// prepare coloured highlight of task time information
$sign = 1;
$style = "";
if ($start_date) {
if (!$end_date) {
/*
** end date calc has been moved to calcEndByStartAndDuration()-function
** called from array_csort and tasks.php
** perhaps this fallback if-clause could be deleted in the future,
** didn't want to remove it shortly before the 2.0.2
*/
$end_date = new CDate('0000-00-00 00:00:00');
}
$days = $now->dateDiff($end_date) * $sign;
}
$s = "\n<tr>";
// dots
if ($today_view) {
$s .= '<td nowrap>';
} else {
$s .= '<td nowrap width="20%">';
}
for ($y = 0; $y < $level; $y++) {
if ($y + 1 == $level) {
$s .= '<img src="./images/corner-dots.gif" width="16" height="12" border="0">';
} else {
$s .= '<img src="./images/shim.gif" width="16" height="12" border="0">';
}
}
// name link
$alt = strlen($a['task_description']) > 80 ? substr($a["task_description"], 0, 80) . '...' : $a['task_description'];
// instead of the statement below
$alt = str_replace("\"", """, $alt);
$alt = str_replace("\r", ' ', $alt);
$alt = str_replace("\n", ' ', $alt);
$open_link = $is_opened ? "<!--<a href='index.php{$query_string}&close_task_id=" . $a["task_id"] . "'>--><img src='images/icons/collapse.gif' border='0' align='center' /><!--</a>-->" : "<!--<a href='index.php{$query_string}&open_task_id=" . $a["task_id"] . "'>--><img src='images/icons/expand.gif' border='0' /><!--</a>-->";
if ($a["task_milestone"] > 0) {
$s .= ' <!--<a href="./index.php?m=tasks&a=view&task_id=' . $a["task_id"] . '" title="' . $alt . '">--><b>' . $a["task_name"] . '</b><!--</a>--> <img src="./images/icons/milestone.gif" border="0"></td>';
} else {
if ($a["task_dynamic"] == '1') {
if (!$today_view) {
$s .= $open_link;
}
$s .= $a["task_name"];
} else {
$s .= $a["task_name"];
}
}
// percent complete
$s .= "\n\t<td align=\"right\">" . intval($a["task_percent_complete"]) . '%</td>';
if ($today_view) {
// Show the project name
$s .= '<td>';
$s .= '<a href="./index.php?m=projects&a=view&project_id=' . $a['task_project'] . '">';
$s .= '<span style="padding:2px;background-color:#' . $a['project_color_identifier'] . ';color:' . bestColor($a['project_color_identifier']) . '">' . $a['project_name'] . '</span>';
$s .= '</a></td>';
}
if (!$today_view) {
$s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . ($start_date ? $start_date->format($df . ' ' . $tf) : '-') . '</td>';
}
$s .= '</td>';
$s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . ($end_date ? $end_date->format($df . ' ' . $tf) : '-') . '</td>';
$s .= '</td>';
$s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . ($last_update ? $last_update->format($df . ' ' . $tf) : '-') . '</td>';
echo $s;
}
示例10: displayWeeks
function displayWeeks($list, $task, $level, $fromPeriod, $toPeriod)
{
if ($fromPeriod == -1) {
return "";
}
$s = new CDate($fromPeriod);
$e = new CDate($toPeriod);
$sw = getBeginWeek($s);
//intval($s->Format("%U"));
//$ew=getEndWeek($e); //intval($e->Format("%U"));
$dw = ceil($e->dateDiff($s) / 7);
$ew = $sw + $dw;
$st = new CDate($task->task_start_date);
$et = new CDate($task->task_end_date);
$stw = getBeginWeek($st);
//intval($st->Format("%U"));
//$etw=getEndWeek($et); //intval($et->Format("%U"));
$dtw = ceil($et->dateDiff($st) / 7);
$etw = $stw + $dtw;
//print "week from: $stw, to: $etw<br>\n";
$row = "";
for ($i = $sw; $i <= $ew; $i++) {
if ($i >= $stw and $i < $etw) {
$color = "blue";
if ($level == 0 and hasChildren($list, $task)) {
$color = "#C0C0FF";
} else {
if ($level == 1 and hasChildren($list, $task)) {
$color = "#9090FF";
}
}
$row .= "<td nowrap=\"nowrap\" bgcolor=\"{$color}\">";
} else {
$row .= "<td nowrap=\"nowrap\">";
}
$row .= "  </td>";
}
return $row;
}
示例11: displayWeeks
function displayWeeks($list, $task, $level, $fromPeriod, $toPeriod)
{
if ($fromPeriod == -1) {
return '';
}
$s = new CDate($fromPeriod);
$e = new CDate($toPeriod);
$sw = getBeginWeek($s);
$dw = ceil($e->dateDiff($s) / 7);
$ew = $sw + $dw;
$st = new CDate($task->task_start_date);
$et = new CDate($task->task_end_date);
$stw = getBeginWeek($st);
$dtw = ceil($et->dateDiff($st) / 7);
$etw = $stw + $dtw;
//print "week from: $stw, to: $etw<br>\n";
$row = '';
for ($i = $sw; $i <= $ew; $i++) {
if ($i >= $stw and $i < $etw) {
$color = 'blue';
if ($level == 0 and hasChildren($list, $task)) {
$color = '#C0C0FF';
} elseif ($level == 1 and hasChildren($list, $task)) {
$color = '#9090FF';
}
$row .= '<td nowrap="nowrap" bgcolor="' . $color . '">';
} else {
$row .= '<td nowrap="nowrap">';
}
$row .= '  </td>';
}
return $row;
}
示例12: getTaskDurationPerDay
/**
* Function that returns the amount of hours this
* task consumes per user each day
*/
function getTaskDurationPerDay($use_percent_assigned = false)
{
$duration = $this->task_duration * $this->task_duration_type;
$task_start_date = new CDate($this->task_start_date);
$task_finish_date = new CDate($this->task_end_date);
$assigned_users = $this->getAssignedUsers();
if ($use_percent_assigned) {
$number_assigned_users = 0;
foreach ($assigned_users as $u) {
$number_assigned_users += $u['perc_assignment'] / 100;
}
} else {
$number_assigned_users = count($assigned_users);
}
$day_diff = $task_finish_date->dateDiff($task_start_date);
$number_of_days_worked = 0;
$actual_date = $task_start_date;
for ($i = 0; $i <= $day_diff; $i++) {
if ($actual_date->isWorkingDay()) {
$number_of_days_worked++;
}
$actual_date->addDays(1);
}
// May be it was a Sunday task
if ($number_of_days_worked == 0) {
$number_of_days_worked = 1;
}
if ($number_assigned_users == 0) {
$number_assigned_users = 1;
}
return $duration / $number_assigned_users / $number_of_days_worked;
}
示例13: showtask_pr
function showtask_pr(&$a, $level = 0, $today_view = false)
{
global $AppUI, $w2Pconfig, $done, $query_string, $durnTypes, $userAlloc, $showEditCheckbox;
global $task_access, $task_priority;
$types = w2Pgetsysval('TaskType');
$now = new CDate();
$tf = $AppUI->getPref('TIMEFORMAT');
$df = $AppUI->getPref('SHDATEFORMAT');
$fdf = $df . ' ' . $tf;
$perms =& $AppUI->acl();
$show_all_assignees = $w2Pconfig['show_all_task_assignees'] ? true : false;
$done[] = $a['task_id'];
$start_date = intval($a['task_start_date']) ? new CDate($a['task_start_date']) : null;
$end_date = intval($a['task_end_date']) ? new CDate($a['task_end_date']) : null;
$last_update = isset($a['last_update']) && intval($a['last_update']) ? new CDate($a['last_update']) : null;
// prepare coloured highlight of task time information
$sign = 1;
$style = '';
if ($start_date) {
if (!$end_date) {
$end_date = new CDate('0000-00-00 00:00:00');
}
$days = $now->dateDiff($end_date) * $sign;
}
$s = '<tr>';
// dots
$s .= '<td nowrap width="20%">';
for ($y = 0; $y < $level; $y++) {
if ($y + 1 == $level) {
$s .= '<img src="' . w2PfindImage('corner-dots.gif', $m) . '" width="16" height="12" border="0" />';
} else {
$s .= '<img src="' . w2PfindImage('shim.gif', $m) . '" width="16" height="12" border="0" />';
}
}
// name link
$alt = mb_strlen($a['task_description']) > 80 ? mb_substr($a['task_description'], 0, 80) . '...' : $a['task_description'];
// instead of the statement below
$alt = mb_str_replace('"', """, $alt);
$alt = mb_str_replace("\r", ' ', $alt);
$alt = mb_str_replace("\n", ' ', $alt);
$open_link = w2PshowImage('collapse.gif');
if ($a['task_milestone'] > 0) {
$s .= ' <!--<a href="./index.php?m=tasks&a=view&task_id=' . $a["task_id"] . '" title="' . $alt . '">--><b>' . $a["task_name"] . '</b><!--</a>--> <img src="' . w2PfindImage('icons/milestone.gif', $m) . '" border="0" /></td>';
} elseif ($a['task_dynamic'] == '1') {
$s .= $open_link;
$s .= '<strong>' . $a['task_name'] . '</strong>';
} else {
$s .= $a['task_name'];
}
// percent complete
$s .= '<td align="right">' . intval($a['task_percent_complete']) . '%</td>';
$s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . ($start_date ? $start_date->format($df . ' ' . $tf) : '-') . '</td>';
$s .= '</td>';
$s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . ($end_date ? $end_date->format($df . ' ' . $tf) : '-') . '</td>';
$s .= '</td>';
$s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . ($last_update ? $last_update->format($df . ' ' . $tf) : '-') . '</td>';
echo $s;
}
示例14: isset
//$start_date_g = dPgetParam($_REQUEST, 'start_date', $start_min);
//$end_date_g = dPgetParam($_REQUEST, 'end_date', $end_max);
if ($display_option != 'all') {
$start_date_g = isset($start_date) ? $start_date : $start_min;
$end_date_g = isset($end_date) ? $end_date : $end_max;
} else {
$start_date_g = $start_min;
$end_date_g = $end_max;
}
//echo $start_date_g.'>'.$start_min;
//echo $end_date_g.'>'.$end_max;
//die;
$count = 0;
$min_d_start = new CDate($start_date_g);
$max_d_end = new CDate($end_date_g);
$day_diff = $max_d_end->dateDiff($min_d_start);
//echo '<pre> $day_diff = ' . $day_diff . '</pre>';
//die;
if ($printpdfhr == '1') {
$length = 25;
} else {
$length = 23;
}
if ($showNoMilestones == '1') {
$length = $length + 1;
}
if ($day_diff < 90) {
$length = $length - 2;
} else {
if ($day_diff >= 90 && $day_diff < 1096) {
$length = $length;
示例15: importTasks
/** Import tasks from another project
*
* @param int Project ID of the tasks come from.
* @return bool
**/
public function importTasks($from_project_id)
{
global $AppUI;
// Load the original
$origProject = new CProject();
$origProject->load($from_project_id);
$q = new DBQuery();
$q->addTable('tasks');
$q->addQuery('task_id');
$q->addWhere('task_project =' . (int) $from_project_id);
$tasks = array_flip($q->loadColumn());
$q->clear();
$origDate = new CDate($origProject->project_start_date);
$destDate = new CDate($this->project_start_date);
$timeOffset = $origDate->dateDiff($destDate);
if ($origDate->compare($origDate, $destDate) > 0) {
$timeOffset = -1 * $timeOffset;
}
// Dependencies array
$deps = array();
// Copy each task into this project and get their deps
foreach ($tasks as $orig => $void) {
$objTask = new CTask();
$objTask->load($orig);
$destTask = $objTask->copy($this->project_id);
$tasks[$orig] = $destTask;
$deps[$orig] = $objTask->getDependencies();
}
// Fix record integrity
foreach ($tasks as $old_id => $newTask) {
// Fix parent Task
// This task had a parent task, adjust it to new parent task_id
if ($newTask->task_id != $newTask->task_parent) {
$newTask->task_parent = $tasks[$newTask->task_parent]->task_id;
}
// Fix task start date from project start date offset
$origDate->setDate($newTask->task_start_date);
$origDate->addDays($timeOffset);
$destDate = $origDate;
$newTask->task_start_date = $destDate->format(FMT_DATETIME_MYSQL);
// Fix task end date from start date + work duration
if (!empty($newTask->task_end_date) && $newTask->task_end_date != '0000-00-00 00:00:00') {
$origDate->setDate($newTask->task_end_date);
$origDate->addDays($timeOffset);
$destDate = $origDate;
$newTask->task_end_date = $destDate->format(FMT_DATETIME_MYSQL);
}
// Dependencies
if (!empty($deps[$old_id])) {
$oldDeps = explode(',', $deps[$old_id]);
// New dependencies array
$newDeps = array();
foreach ($oldDeps as $dep) {
$newDeps[] = $tasks[$dep]->task_id;
}
// Update the new task dependencies
$csList = implode(',', $newDeps);
$newTask->updateDependencies($csList);
}
// end of update dependencies
$newTask->store($AppUI);
}
// end Fix record integrity
}