Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
/**
* 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 <*****@*****.**>
*/
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();
        }
    }
}
Ejemplo n.º 3
0
/**
 * 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 <*****@*****.**>
 */
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>&nbsp;' . '<a href="' . $url . '"><span class="event">' . $row['event_title'] . '</span></a>' . w2PendTip();
                }
                $links[$date->format(FMT_TIMESTAMP_DATE)][] = $link;
            }
            $date = $date->getNextDay();
        }
    }
}
Ejemplo n.º 4
0
/**
* 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 <*****@*****.**>
*/
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();
        }
    }
}
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 .= "&#160";
    }
    if ($task->task_milestone == true) {
        $tmp .= "<B>";
    }
    if ($level >= 1) {
        $tmp .= dPshowImage(dPfindImage('corner-dots.gif', 'tasks'), 16, 12, 'Subtask') . "&nbsp;";
    }
    $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 .= "&nbsp;(<img src=\"./images/icons/priority-" . -$task->task_priority . ".gif\" width=13 height=16>)";
    } elseif ($task->task_priority > 0) {
        $tmp .= "&nbsp;(<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 . "&nbsp;" . $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 .= "&#160&#160&#160</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'] . "&nbsp;\n                        \t(" . $row['perc_assignment'] . "%)</a>";
            } else {
                $us .= $sep . $row['contact_last_name'] . "&nbsp;(" . $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;
}
Ejemplo n.º 6
0
 /**	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
 }
Ejemplo n.º 7
0
 /**
  * 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) {
         if ($mail->ValidEmail($contact['contact_email'])) {
             $mail->To($contact['contact_email']);
         }
     }
     $mail->From('"' . $owner_first_name . ' ' . $owner_last_name . '" <' . $owner_email . '>');
     $mail->Subject($subject, $locale_char_set);
     $mail->Body($body, $locale_char_set);
     return $mail->Send();
 }
Ejemplo n.º 8
0
 /**	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);
             }
             $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
 }
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("\"", "&quot;", $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 .= '&nbsp;<!--<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;
}
Ejemplo n.º 10
0
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 .= "&#160&#160</td>";
    }
    return $row;
}
Ejemplo n.º 11
0
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 .= '&#160&#160</td>';
    }
    return $row;
}
Ejemplo n.º 12
0
 /**
  * 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;
 }
Ejemplo n.º 13
0
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('"', "&quot;", $alt);
    $alt = mb_str_replace("\r", ' ', $alt);
    $alt = mb_str_replace("\n", ' ', $alt);
    $open_link = w2PshowImage('collapse.gif');
    if ($a['task_milestone'] > 0) {
        $s .= '&nbsp;<!--<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;
}
Ejemplo n.º 14
0
//$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;
Ejemplo n.º 15
0
 /**	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
 }
Ejemplo n.º 16
0
$task->check();
$task_end_date = new CDate($task->task_end_date);
$task->task_percent_complete = dPgetParam($_POST, 'task_percent_complete', null);
if (dPgetParam($_POST, 'task_end_date', '') != '') {
    $new_date = new CDate($_POST['task_end_date']);
    $new_date->setTime($task_end_date->hour, $task_end_date->minute, $task_end_date->second);
    $task->task_end_date = $new_date->format(FMT_DATETIME_MYSQL);
}
if ($task->task_percent_complete >= 100 && (!$task->task_end_date || $task->task_end_date == '0000-00-00 00:00:00')) {
    $task->task_end_date = $obj->task_log_date;
}
if ($msg = $task->store()) {
    $AppUI->setMsg($msg, UI_MSG_ERROR, true);
}
$new_task_end = new CDate($task->task_end_date);
if ($new_task_end->dateDiff($task_end_date)) {
    $task->addReminder();
}
if ($notify_owner && ($msg = $task->notifyOwner())) {
    $AppUI->setMsg($msg, UI_MSG_ERROR);
}
// Check if we need to email the task log to anyone.
$email_assignees = dPgetParam($_POST, 'email_assignees', null);
$email_task_contacts = dPgetParam($_POST, 'email_task_contacts', null);
$email_project_contacts = dPgetParam($_POST, 'email_project_contacts', null);
$email_others = dPgetParam($_POST, 'email_others', '');
$email_extras = dPgetParam($_POST, 'email_extras', null);
if ($task->email_log($obj, $email_assignees, $email_task_contacts, $email_project_contacts, $email_others, $email_extras)) {
    $obj->store();
    // Save the updated message. It is not an error if this fails.
}
<?php 
/*** Tasks listing ***/
$now = new CDate();
$df = $AppUI->getPref('SHDATEFORMAT');
foreach ($tasks as $task) {
    $sign = 1;
    $start = intval(@$task["task_start_date"]) ? new CDate($task["task_start_date"]) : null;
    $end = intval(@$task["task_end_date"]) ? new CDate($task["task_end_date"]) : null;
    if (!$end && $start) {
        $end = $start;
        $end->addSeconds(@$task["task_duration"] * $task["task_duration_type"] * SEC_HOUR);
    }
    if ($end && $now->after($end)) {
        $sign = -1;
    }
    $days = $end ? $now->dateDiff($end) * $sign : null;
    $task['task_due_in'] = $days;
    showtask($task, 0, false, true);
}
?>
<tr>
	<td colspan="9" align="right" height="30">
		<input type="submit" class="button" value="<?php 
echo $AppUI->_('update task');
?>
">
	</td>
	<td colspan="3" align="center">
<?php 
foreach ($priorities as $k => $v) {
    $options[$k] = $AppUI->_('set priority to ' . $v, UI_OUTPUT_RAW);
Ejemplo n.º 18
0
 if ($result) {
     $task_parent = (int) w2PgetParam($_POST, 'task_parent', 0);
     $old_task_parent = (int) w2PgetParam($_POST, 'old_task_parent', 0);
     if ($task_parent != $old_task_parent) {
         $oldTask = new CTask();
         $oldTask->load($old_task_parent);
         $oldTask->updateDynamics(false);
     }
     $custom_fields = new CustomFields($m, 'addedit', $obj->task_id, 'edit');
     $custom_fields->bind($_POST);
     $sql = $custom_fields->store($obj->task_id);
     // Store Custom Fields
     // Now add any task reminders
     // If there wasn't a task, but there is one now, and
     // that task date is set, we need to set a reminder.
     if (empty($task_end_date) || !empty($end_date) && $task_end_date->dateDiff($end_date)) {
         $obj->addReminder();
     }
     $AppUI->setMsg($task_id ? 'Task updated' : 'Task added', UI_MSG_OK);
     if (isset($hassign)) {
         $obj->updateAssigned($hassign, $hperc_assign_ar);
     }
     if (isset($hdependencies)) {
         // && !empty($hdependencies)) {
         // there are dependencies set!
         // backup initial start and end dates
         $tsd = new CDate($obj->task_start_date);
         $ted = new CDate($obj->task_end_date);
         // updating the table recording the
         // dependency relations with this task
         $obj->updateDependencies($hdependencies);
Ejemplo n.º 19
0
</a>
		</span>
	</td>
	<td bgcolor="#dddddd" width="10%"><?php 
        echo $row['contact_first_name'] . ' ' . $row['contact_last_name'];
        ?>
</td>
	<td align="center" width="10%"><?php 
        echo $row['replies'];
        ?>
</td>
	<td bgcolor="#dddddd" width="150" nowrap="nowrap">
<?php 
        if ($row['latest_reply']) {
            echo $last->format($df . ' ' . $tf) . '<br /><font color="#999966">(';
            $diff = $now->dateDiff($last);
            echo (int) $diff . ' ' . $AppUI->_('days ago');
            echo ')</font>';
        } else {
            echo $AppUI->_('No replies');
        }
        ?>
	</td>
</tr>
<?php 
    }
}
?>
</table>

<table width="100%" border="0" cellpadding="0" cellspacing="1" class="std">
Ejemplo n.º 20
0
}
$task = new CTask();
$task->load($obj->task_log_task);
$task->check();
$task->task_percent_complete = dPgetParam($_POST, 'task_percent_complete', null);
if (dPgetParam($_POST, "task_end_date", "") != "") {
    $task->task_end_date = $_POST["task_end_date"];
}
if ($task->task_percent_complete >= 100 && (!$task->task_end_date || $task->task_end_date == '0000-00-00 00:00:00')) {
    $task->task_end_date = $obj->task_log_date;
}
if ($msg = $task->store()) {
    $AppUI->setMsg($msg, UI_MSG_ERROR, true);
}
$new_task_end = new CDate($task->task_end_date);
if ($new_task_end->dateDiff($new_task_end)) {
    $task->addReminder();
}
if ($notify_owner) {
    if ($msg = $task->notifyOwner()) {
        $AppUI->setMsg($msg, UI_MSG_ERROR);
    }
}
// Check if we need to email the task log to anyone.
$email_assignees = dPgetParam($_POST, 'email_assignees', null);
$email_task_contacts = dPgetParam($_POST, 'email_task_contacts', null);
$email_project_contacts = dPgetParam($_POST, 'email_project_contacts', null);
$email_others = dPgetParam($_POST, 'email_others', '');
$email_extras = dPgetParam($_POST, 'email_extras', null);
if ($task->email_log($obj, $email_assignees, $email_task_contacts, $email_project_contacts, $email_others, $email_extras)) {
    $obj->store();
Ejemplo n.º 21
0
        $fetched_projects[$task->task_project] = $task_data["project_name"];
    }
    $user_usage = array();
    $task_dates = array();
    $actual_date = $start_date;
    $days_header = "";
    // we will save days title here
    $user_tasks_counted_in = array();
    $user_names = array();
    if (count($task_list) == 0) {
        echo "<p>" . $AppUI->_('No data available') . "</p>";
    } else {
        foreach ($task_list as $task) {
            $task_start_date = new CDate($task->task_start_date);
            $task_end_date = new CDate($task->task_end_date);
            $day_difference = $task_end_date->dateDiff($task_start_date);
            $actual_date = $task_start_date;
            $users = $task->getAssignedUsers();
            if ($coarseness == 1) {
                userUsageDays();
            } elseif ($coarseness == 7) {
                userUsageWeeks();
            }
        }
        if ($coarseness == 1) {
            showDays();
        } elseif ($coarseness == 7) {
            showWeeks();
        }
        ?>
			<center><table class="list">
Ejemplo n.º 22
0
/**
 * Sub-function to collect tasks 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
 * @param int the company id to filter by
 * @author Andrew Eddie <*****@*****.**>
 */
function getTaskLinks($startPeriod, $endPeriod, &$links, $strMaxLen, $company_id = 0, $minical = false)
{
    global $a, $AppUI, $w2Pconfig;
    $tasks = CTask::getTasksForPeriod($startPeriod, $endPeriod, $company_id, 0);
    $df = $AppUI->getPref('SHDATEFORMAT');
    $tf = $AppUI->getPref('TIMEFORMAT');
    //subtract one second so we don't have to compare the start dates for exact matches with the startPeriod which is 00:00 of a given day.
    $startPeriod->subtractSeconds(1);
    $link = array();
    $sid = 3600 * 24;
    // assemble the links for the tasks
    foreach ($tasks as $row) {
        // the link
        $link['task'] = true;
        if (!$minical) {
            $link['href'] = '?m=tasks&a=view&task_id=' . $row['task_id'];
            // the link text
            if (mb_strlen($row['task_name']) > $strMaxLen) {
                $row['short_name'] = mb_substr($row['task_name'], 0, $strMaxLen) . '...';
            } else {
                $row['short_name'] = $row['task_name'];
            }
            $link['text'] = '<span style="color:' . bestColor($row['color']) . ';background-color:#' . $row['color'] . '">' . $row['short_name'] . ($row['task_milestone'] ? '&nbsp;' . w2PshowImage('icons/milestone.gif') : '') . '</span>';
        }
        // determine which day(s) to display the task
        $start = new CDate($row['task_start_date']);
        $end = $row['task_end_date'] ? new CDate($row['task_end_date']) : null;
        // First we test if the Tasks Starts and Ends are on the same day, if so we don't need to go any further.
        if ($start->after($startPeriod) && ($end && $end->after($startPeriod) && $end->before($endPeriod) && !$start->dateDiff($end))) {
            if ($minical) {
                $temp = array('task' => true);
            } else {
                $temp = $link;
                if ($a != 'day_view') {
                    $temp['text'] = w2PtoolTip($row['task_name'], getTaskTooltip($row['task_id'], true, true, $tasks), true) . w2PshowImage('block-start-16.png') . $start->format($tf) . ' ' . $temp['text'] . ' ' . $end->format($tf) . w2PshowImage('block-end-16.png') . w2PendTip();
                }
            }
            $links[$end->format(FMT_TIMESTAMP_DATE)][] = $temp;
        } else {
            // If they aren't, we will now need to see if the Tasks Start date is between the requested period
            if ($start->after($startPeriod) && $start->before($endPeriod)) {
                if ($minical) {
                    $temp = array('task' => true);
                } else {
                    $temp = $link;
                    if ($a != 'day_view') {
                        $temp['text'] = w2PtoolTip($row['task_name'], getTaskTooltip($row['task_id'], true, false, $tasks), true) . w2PshowImage('block-start-16.png') . $start->format($tf) . ' ' . $temp['text'] . w2PendTip();
                    }
                }
                $links[$start->format(FMT_TIMESTAMP_DATE)][] = $temp;
            }
            // And now the Tasks End date is checked if it is between the requested period too.
            if ($end && $end->after($startPeriod) && $end->before($endPeriod) && $start->before($end)) {
                if ($minical) {
                    $temp = array('task' => true);
                } else {
                    $temp = $link;
                    if ($a != 'day_view') {
                        $temp['text'] = w2PtoolTip($row['task_name'], getTaskTooltip($row['task_id'], false, true, $tasks), true) . ' ' . $temp['text'] . ' ' . $end->format($tf) . w2PshowImage('block-end-16.png') . w2PendTip();
                    }
                }
                $links[$end->format(FMT_TIMESTAMP_DATE)][] = $temp;
            }
        }
    }
}