Ejemplo n.º 1
0
    if ($tsd->before(new CDate($start_min))) {
        $start_min = $row['task_start_date'];
    }
    //Check if end date exists, if not try giving it the start date.
    //If the start date does not exist then set it for today.
    //This avoids jpgraphs internal errors that render the gantt completely useless
    if ($row['task_end_date'] == '0000-00-00 00:00:00') {
        if ($row['task_duration']) {
            $row['task_end_date'] = db_unix2dateTime(db_dateTime2unix($row['task_start_date']) + SECONDS_PER_DAY * convert2days($row['task_duration'], $row['task_duration_type']));
        } else {
            $todaydate = new CDate();
            $row['task_end_date'] = $todaydate->format(FMT_TIMESTAMP_DATE);
        }
    }
    $ted = new CDate($row['task_end_date']);
    if ($ted->after(new CDate($end_max))) {
        $end_max = $row['task_end_date'];
    }
    if ($ted->after(new CDate($projects[$row['task_project']]['project_end_date'])) || $projects[$row['task_project']]['project_end_date'] == '') {
        $projects[$row['task_project']]['project_end_date'] = $row['task_end_date'];
    }
    $projects[$row['task_project']]['tasks'][] = $row;
}
$q->clear();
unset($proTasks);
//consider critical (concerning end date) tasks as well
if ($caller != 'todo') {
    $start_min = $projects[$project_id]['project_start_date'];
    $end_max = $projects[$project_id]['project_end_date'] > $criticalTasks[0]['task_end_date'] ? $projects[$project_id]['project_end_date'] : $criticalTasks[0]['task_end_date'];
}
$width = min(w2PgetParam($_GET, 'width', 600), 1400);
Ejemplo n.º 2
0
function displayWeeks($list, $task, $level, $fromPeriod, $toPeriod)
{
    //start of week
    $sd = new CDate($fromPeriod);
    $days_from_start = $sd->getDayOfWeek();
    for ($i = 0; $i < $days_from_start; $i++) {
        $stmp = $sd->getPrevDay();
        $sd = new CDate($stmp->format('%Y-%m-%d 00:00:00'));
    }
    //end of week
    $ed = new CDate($toPeriod);
    $days_spent = $ed->getDayOfWeek();
    for ($i = 6 - $days_spent; $i > 0; $i--) {
        $etmp = $ed->getNextDay();
        $ed = new CDate($etmp->format('%Y-%m-%d 23:59:59'));
    }
    $st = new CDate($task->task_start_date);
    $et = new CDate($task->task_end_date);
    $row = '';
    while ($sd->before($ed)) {
        $sd_end = new CDate($sd->format('%Y-%m-%d 00:00:00'));
        $sd_end->addSeconds(7 * 24 * 3600);
        //add one week
        if ($sd->after($st) && $sd_end->before($et) || $st->before($sd_end) && !$st->before($sd) || $et->after($sd) && !$et->after($sd_end)) {
            /*
             * generate visually distiguishable colors for up to 12 task levels
             * Color will just be blue (#0000FF) for levels 12th and up. 
             */
            $red_key = 12 - floor($level / 3) * 3;
            $red_key = $red_key > 15 ? 15 : ($red_key < 0 ? 0 : $red_key);
            $green_key_1 = $red_key + 4 - $level % 3 * 4;
            $green_key_1 = $green_key_1 > 15 ? 15 : ($green_key_1 < 0 ? 0 : $green_key_1);
            $green_key_2 = $green_key_1 == $red_key ? 0 : $green_key_1;
            $color_hex = mb_strtoupper('#' . dechex($red_key) . '0' . dechex($green_key_1) . dechex($green_key_2) . 'FF');
            $row .= '<td nowrap="nowrap" style="background:' . $color_hex . ';" >';
        } else {
            $row .= '<td nowrap="nowrap">';
        }
        $row .= '&nbsp;</td>';
        $sd->addSeconds(7 * 24 * 3600);
        //add one week
    }
    return $row;
}
Ejemplo n.º 3
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)
{
    global $a, $AppUI, $dPconfig;
    $tasks = CTask::getTasksForPeriod($startPeriod, $endPeriod, $company_id, $AppUI->user_id, true);
    $durnTypes = dPgetSysVal('TaskDurationType');
    $link = array();
    $sid = 3600 * 24;
    // assemble the links for the tasks
    foreach ($tasks as $row) {
        // the link
        $link['href'] = "?m=tasks&a=view&task_id=" . $row['task_id'];
        $link['alt'] = $row['project_name'] . ":\n" . $row['task_name'];
        // the link text
        if (strlen($row['task_name']) > $strMaxLen) {
            $row['task_name'] = substr($row['task_name'], 0, $strMaxLen) . '...';
        }
        $link['text'] = '<span style="color:' . bestColor($row['color']) . ';background-color:#' . $row['color'] . '">' . $row['task_name'] . '</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;
        $durn = $row['task_duration'];
        $durnType = $row['task_duration_type'];
        if (($start->after($startPeriod) || $start->equals($startPeriod)) && ($start->before($endPeriod) || $start->equals($endPeriod))) {
            $temp = $link;
            $temp['alt'] = "START [" . $row['task_duration'] . ' ' . $AppUI->_($durnTypes[$row['task_duration_type']]) . "]\n" . $link['alt'];
            if ($a != 'day_view') {
                $temp['text'] = dPshowImage(dPfindImage('block-start-16.png')) . $temp['text'];
            }
            $links[$start->format(FMT_TIMESTAMP_DATE)][] = $temp;
        }
        if ($end && $end->after($startPeriod) && $end->before($endPeriod) && $start->before($end)) {
            $temp = $link;
            $temp['alt'] = "FINISH\n" . $link['alt'];
            if ($a != 'day_view') {
                $temp['text'] .= dPshowImage(dPfindImage('block-end-16.png'));
            }
            $links[$end->format(FMT_TIMESTAMP_DATE)][] = $temp;
        }
        // convert duration to days
        if ($durnType < 24.0) {
            if ($durn > $dPconfig['daily_working_hours']) {
                $durn /= $dPconfig['daily_working_hours'];
            } else {
                $durn = 0.0;
            }
        } else {
            $durn *= $durnType / 24.0;
        }
        // fill in between start and finish based on duration
        // notes:
        // start date is not in a future month, must be this or past month
        // start date is counted as one days work
        // business days are not taken into account
        $target = $start;
        $target->addSeconds($durn * $sid);
        if (Date::compare($target, $startPeriod) < 0) {
            continue;
        }
        if (Date::compare($start, $startPeriod) > 0) {
            $temp = $start;
            $temp->addSeconds($sid);
        } else {
            $temp = $startPeriod;
        }
        // Optimised for speed, AJD.
        while (Date::compare($endPeriod, $temp) > 0 && Date::compare($target, $temp) > 0 && ($end == null || $temp->before($end))) {
            $links[$temp->format(FMT_TIMESTAMP_DATE)][] = $link;
            $temp->addSeconds($sid);
        }
    }
}
Ejemplo n.º 4
0
function showtask(&$arr, $level = 0, $is_opened = true, $today_view = false, $hideOpenCloseLink = false, $allowRepeat = false)
{
    global $AppUI, $query_string, $durnTypes, $userAlloc, $showEditCheckbox;
    global $m, $a, $history_active, $expanded;
    //Check for Tasks Access
    $canAccess = canTaskAccess($arr['task_id'], $arr['task_access'], $arr['task_owner']);
    if (!$canAccess) {
        return false;
    }
    $now = new CDate();
    $tf = $AppUI->getPref('TIMEFORMAT');
    $df = $AppUI->getPref('SHDATEFORMAT');
    $perms =& $AppUI->acl();
    $fdf = $df . ' ' . $tf;
    $show_all_assignees = w2PgetConfig('show_all_task_assignees', false);
    $start_date = intval($arr['task_start_date']) ? new CDate($arr['task_start_date']) : null;
    $end_date = intval($arr['task_end_date']) ? new CDate($arr['task_end_date']) : null;
    $last_update = isset($arr['last_update']) && intval($arr['last_update']) ? new CDate($arr['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');
        }
        if ($now->after($start_date) && $arr['task_percent_complete'] == 0) {
            $style = 'background-color:#ffeebb';
        } elseif ($now->after($start_date) && $arr['task_percent_complete'] < 100) {
            $style = 'background-color:#e6eedd';
        }
        if ($now->after($end_date)) {
            $sign = -1;
            $style = 'background-color:#cc6666;color:#ffffff';
        }
        if ($arr['task_percent_complete'] == 100) {
            $style = 'background-color:#aaddaa; color:#00000';
        }
        $days = $now->dateDiff($end_date) * $sign;
    }
    //     $s = "\n<tr id=\"project_".$arr['task_project'].'_level>'.$level.'<task_'.$arr['task_id']."_\" ".((($level>0 && !($m=='tasks' && $a=='view')) || ($m=='tasks' && ($a=='' || $a=='index'))) ? 'style="display:none"' : '').'>';
    if ($expanded) {
        $s = '<tr id="project_' . $arr['task_project'] . '_level>' . $level . '<task_' . $arr['task_id'] . '_" >';
    } else {
        $s = '<tr id="project_' . $arr['task_project'] . '_level>' . $level . '<task_' . $arr['task_id'] . '_" ' . ($level > 0 && !($m == 'tasks' && $a == 'view') ? 'style="display:none"' : '') . '>';
    }
    // edit icon
    $s .= '<td align="center">';
    $canEdit = true;
    $canViewLog = true;
    if ($canEdit) {
        $s .= w2PtoolTip('edit task', 'click to edit this task') . '<a href="?m=tasks&a=addedit&task_id=' . $arr['task_id'] . '">' . w2PshowImage('icons/pencil.gif', 12, 12) . '</a>' . w2PendTip();
    }
    $s .= '</td>';
    // pinned
    $pin_prefix = $arr['task_pinned'] ? '' : 'un';
    $s .= '<td align="center"><a href="?m=tasks&pin=' . ($arr['task_pinned'] ? 0 : 1) . '&task_id=' . $arr['task_id'] . '">' . w2PtoolTip('Pin', 'pin/unpin task') . '<img src="' . w2PfindImage('icons/' . $pin_prefix . 'pin.gif') . '" border="0" />' . w2PendTip() . '</a></td>';
    // New Log
    if ($arr['task_log_problem'] > 0) {
        $s .= '<td align="center" valign="middle"><a href="?m=tasks&a=view&task_id=' . $arr['task_id'] . '&tab=0&problem=1">' . w2PshowImage('icons/dialog-warning5.png', 16, 16, 'Problem', 'Problem!') . '</a></td>';
    } elseif ($canViewLog && $arr['task_dynamic'] != 1) {
        $s .= '<td align="center"><a href="?m=tasks&a=view&task_id=' . $arr['task_id'] . '&tab=1">' . w2PtoolTip('Add Log', 'create a new log record against this task') . w2PshowImage('edit_add.png') . w2PendTip() . '</a></td>';
    } else {
        $s .= '<td align="center">' . $AppUI->_('-') . '</td>';
    }
    // percent complete and priority
    $s .= '<td align="right">' . intval($arr['task_percent_complete']) . '%</td><td align="center" nowrap="nowrap">';
    if ($arr['task_priority'] < 0) {
        $s .= '<img src="' . w2PfindImage('icons/priority-' . -$arr['task_priority'] . '.gif') . '" />';
    } elseif ($arr['task_priority'] > 0) {
        $s .= '<img src="' . w2PfindImage('icons/priority+' . $arr['task_priority'] . '.gif') . '" />';
    }
    $s .= ($arr['file_count'] > 0 ? '<img src="' . w2PfindImage('clip.png') . '" alt="F" />' : '') . '</td>';
    // dots
    $s .= '<td width="' . ($today_view ? '50%' : '90%') . '">';
    //level
    if ($level == -1) {
        $s .= '...';
    }
    for ($y = 0; $y < $level; $y++) {
        if ($y + 1 == $level) {
            $s .= '<img src="' . w2PfindImage('corner-dots.gif') . '" width="16" height="12" border="0">';
        } else {
            $s .= '<img src="' . w2PfindImage('shim.gif') . '" width="16" height="12"  border="0">';
        }
    }
    if ($arr['task_description']) {
        $s .= w2PtoolTip('Task Description', $arr['task_description'], true);
    }
    $open_link = '<a href="javascript: void(0);"><img onclick="expand_collapse(\'project_' . $arr['task_project'] . '_level>' . $level . '<task_' . $arr['task_id'] . '_\', \'tblProjects\',\'\',' . ($level + 1) . ');" id="project_' . $arr['task_project'] . '_level>' . $level . '<task_' . $arr['task_id'] . '__collapse" src="' . w2PfindImage('icons/collapse.gif') . '" border="0" align="center" ' . (!$expanded ? 'style="display:none"' : '') . ' /><img onclick="expand_collapse(\'project_' . $arr['task_project'] . '_level>' . $level . '<task_' . $arr['task_id'] . '_\', \'tblProjects\',\'\',' . ($level + 1) . ');" id="project_' . $arr['task_project'] . '_level>' . $level . '<task_' . $arr['task_id'] . '__expand" src="' . w2PfindImage('icons/expand.gif') . '" border="0" align="center" ' . ($expanded ? 'style="display:none"' : '') . ' /></a>';
    if ($arr['task_nr_of_children']) {
        $is_parent = true;
    } else {
        $is_parent = false;
    }
    if ($arr['task_milestone'] > 0) {
        $s .= '&nbsp;<a href="./index.php?m=tasks&a=view&task_id=' . $arr['task_id'] . '" ><b>' . $arr['task_name'] . '</b></a> <img src="' . w2PfindImage('icons/milestone.gif') . '" border="0" /></td>';
    } elseif ($arr['task_dynamic'] == '1' || $is_parent) {
        if (!$today_view) {
            $s .= $open_link;
        }
        if ($arr['task_dynamic'] == '1') {
            $s .= '&nbsp;<a href="./index.php?m=tasks&a=view&task_id=' . $arr['task_id'] . '" ><b><i>' . $arr['task_name'] . '</i></b></a></td>';
        } else {
            $s .= '&nbsp;<a href="./index.php?m=tasks&a=view&task_id=' . $arr['task_id'] . '" >' . $arr['task_name'] . '</a></td>';
        }
    } else {
        $s .= '&nbsp;<a href="./index.php?m=tasks&a=view&task_id=' . $arr['task_id'] . '" >' . $arr['task_name'] . '</a></td>';
    }
    if ($arr['task_description']) {
        $s .= w2PendTip();
    }
    if ($today_view) {
        // Show the project name
        $s .= '<td width="50%"><a href="./index.php?m=projects&a=view&project_id=' . $arr['task_project'] . '">' . '<span style="padding:2px;background-color:#' . $arr['project_color_identifier'] . ';color:' . bestColor($arr['project_color_identifier']) . '">' . $arr['project_name'] . '</span>' . '</a></td>';
    }
    // task owner
    if (!$today_view) {
        $s .= '<td nowrap="nowrap" align="center">' . '<a href="?m=admin&a=viewuser&user_id=' . $arr['user_id'] . '">' . $arr['owner'] . '</a>' . '</td>';
    }
    if (isset($arr['task_assigned_users']) && ($assigned_users = $arr['task_assigned_users'])) {
        $a_u_tmp_array = array();
        if ($show_all_assignees) {
            $s .= '<td align="center">';
            foreach ($assigned_users as $val) {
                $a_u_tmp_array[] = '<a href="?m=admin&a=viewuser&user_id=' . $val['user_id'] . '"' . 'title="' . (w2PgetConfig('check_overallocation') ? $AppUI->_('Extent of Assignment') . ':' . $userAlloc[$val['user_id']]['charge'] . '%; ' . $AppUI->_('Free Capacity') . ':' . $userAlloc[$val['user_id']]['freeCapacity'] . '%' : '') . '">' . $val['assignee'] . ' (' . $val['perc_assignment'] . '%)</a>';
            }
            $s .= join(', ', $a_u_tmp_array) . '</td>';
        } else {
            $s .= '<td align="center" nowrap="nowrap">' . '<a href="?m=admin&a=viewuser&user_id=' . $assigned_users[0]['user_id'] . '" title="' . (w2PgetConfig('check_overallocation') ? $AppUI->_('Extent of Assignment') . ':' . $userAlloc[$assigned_users[0]['user_id']]['charge'] . '%; ' . $AppUI->_('Free Capacity') . ':' . $userAlloc[$assigned_users[0]['user_id']]['freeCapacity'] . '%' : '') . '">' . $assigned_users[0]['assignee'] . ' (' . $assigned_users[0]['perc_assignment'] . '%)</a>';
            if ($arr['assignee_count'] > 1) {
                $s .= ' <a href="javascript: void(0);" onclick="toggle_users(' . "'users_" . $arr['task_id'] . "'" . ');" title="' . join(', ', $a_u_tmp_array) . '">(+' . ($arr['assignee_count'] - 1) . ')</a>' . '<span style="display: none" id="users_' . $arr['task_id'] . '">';
                $a_u_tmp_array[] = $assigned_users[0]['assignee'];
                for ($i = 1, $i_cmp = count($assigned_users); $i < $i_cmp; $i++) {
                    $a_u_tmp_array[] = $assigned_users[$i]['assignee'];
                    $s .= '<br /><a href="?m=admin&a=viewuser&user_id=' . $assigned_users[$i]['user_id'] . '" title="' . (w2PgetConfig('check_overallocation') ? $AppUI->_('Extent of Assignment') . ':' . $userAlloc[$assigned_users[$i]['user_id']]['charge'] . '%; ' . $AppUI->_('Free Capacity') . ':' . $userAlloc[$assigned_users[$i]['user_id']]['freeCapacity'] . '%' : '') . '">' . $assigned_users[$i]['assignee'] . ' (' . $assigned_users[$i]['perc_assignment'] . '%)</a>';
                }
                $s .= '</span>';
            }
            $s .= '</td>';
        }
    } elseif (!$today_view) {
        // No users asigned to task
        $s .= '<td align="center">-</td>';
    }
    // duration or milestone
    $s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . ($start_date ? $start_date->format($fdf) : '-') . '</td>' . '<td align="right" nowrap="nowrap" style="' . $style . '">' . $arr['task_duration'] . ' ' . mb_substr($AppUI->_($durnTypes[$arr['task_duration_type']]), 0, 1) . '</td>' . '<td nowrap="nowrap" align="center" style="' . $style . '">' . ($end_date ? $end_date->format($fdf) : '-') . '</td>';
    if ($today_view) {
        $s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . $arr['task_due_in'] . '</td>';
    } elseif ($history_active) {
        $s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . ($last_update ? $last_update->format($fdf) : '-') . '</td>';
    }
    // Assignment checkbox
    if ($showEditCheckbox) {
        $s .= '<td align="center">' . '<input type="checkbox" name="selected_task[' . $arr['task_id'] . ']" value="' . $arr['task_id'] . '"/></td>';
    }
    $s .= '</tr>';
    echo $s;
}
Ejemplo n.º 5
0
function showtask(&$a, $level = 0, $is_opened = true, $today_view = false, $hideOpenCloseLink = false, $allowRepeat = false)
{
    global $AppUI, $done, $query_string, $durnTypes, $userAlloc, $showEditCheckbox;
    global $tasks_opened, $tasks_closed, $user_id;
    $tasks_closed = $tasks_closed ? $tasks_closed : array();
    $tasks_opened = $tasks_opened ? $tasks_opened : array();
    $done = $done ? $done : array();
    $now = new CDate();
    $df = $AppUI->getPref('SHDATEFORMAT');
    $df .= ' ' . $AppUI->getPref('TIMEFORMAT');
    $show_all_assignees = dPgetConfig('show_all_task_assignees', false);
    if (!isset($done[$a['task_id']])) {
        $done[$a['task_id']] = 1;
    } else {
        if (!$allowRepeat) {
            //by default, we shouldn't allow repeat displays of the same task
            return;
        }
    }
    $task_obj = new CTask();
    $task_obj->peek($a['task_id']);
    if (!$task_obj->canAccess($user_id ? $user_id : $AppUI->user_id)) {
        //don't show tasks that we can't access
        return;
    }
    if ($is_opened) {
        openClosedTask($a);
    } else {
        closeOpenedTask($a);
    }
    $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
    $style = '';
    if ($start_date) {
        if ($now->after($start_date) && $a['task_percent_complete'] == 0) {
            $style = 'background-color:#ffeebb';
        } else {
            if ($now->after($start_date) && $a['task_percent_complete'] < 100) {
                $style = 'background-color:#e6eedd';
            }
        }
        if (!empty($end_date) && $now->after($end_date)) {
            $style = 'background-color:#cc6666;color:#ffffff';
        }
        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');
        }
        if ($a['task_percent_complete'] == 100) {
            $style = 'background-color:#aaddaa; color:#00000';
        }
        $days = $end_date->dateDiff($now);
    }
    $s = "\n<tr>";
    // edit icon
    $s .= "\n\t<td>";
    $canEdit = getPermission('tasks', 'edit', $a['task_id']);
    $canViewLog = getPermission('task_log', 'view', $a['task_id']);
    if ($canEdit) {
        $s .= "\n\t\t" . '<a href="?m=tasks&amp;a=addedit&amp;task_id=' . $a['task_id'] . '">' . "\n\t\t\t" . '<img src="./images/icons/pencil.gif" alt="' . $AppUI->_('Edit Task') . '" border="0" width="12" height="12" />' . "\n\t\t</a>";
    }
    $s .= "\n\t</td>";
    // pinned
    $pin_prefix = $a['task_pinned'] ? '' : 'un';
    $s .= "\n\t<td>\n\t\t" . '<a href="?m=tasks&amp;pin=' . ($a['task_pinned'] ? 0 : 1) . '&task_id=' . $a['task_id'] . '">' . "\n\t\t\t" . '<img src="./images/icons/' . $pin_prefix . 'pin.gif" alt="' . $AppUI->_($pin_prefix . 'pin Task') . '" border="0" width="12" height="12" />' . "\n\t\t</a>\n\t</td>";
    // New Log
    $s .= "\n\t" . '<td align="center">';
    if ($canViewLog && $a['task_dynamic'] != 1) {
        $s .= '<a href="?m=tasks&amp;a=view&amp;task_id=' . $a['task_id'] . '&tab=1">' . $AppUI->_('Log') . '</a>';
    } else {
        $s .= $AppUI->_('-');
    }
    $s .= '</td>';
    // percent complete and priority
    $s .= "\n\t" . '<td align="right">' . intval($a['task_percent_complete']) . '%</td>' . "\n\t" . '<td align="center" nowrap="nowrap">';
    if (@$a['task_log_problem'] > 0) {
        $s .= '<a href="?m=tasks&amp;a=view&amp;task_id=' . $a['task_id'] . '&amp;tab=0&amp;problem=1">' . dPshowImage('./images/icons/dialog-warning5.png', 16, 16, 'Problem', 'Problem!') . '</a>';
    } else {
        if ($a['task_priority'] != 0) {
            $s .= "\n\t\t" . dPshowImage('./images/icons/priority' . ($a['task_priority'] > 0 ? '+' : '-') . abs($a['task_priority']) . '.gif', 13, 16, '', '');
        }
    }
    $s .= (@$a['file_count'] > 0 ? '<img src="./images/clip.png" alt="F" />' : '') . '</td>';
    // dots
    $s .= '<td width="' . ($today_view ? '50%' : '90%') . '">';
    //level
    if ($level == -1) {
        $s .= '...';
    }
    for ($y = 0; $y < $level; $y++) {
        $s .= '<img src="' . ($y + 1 == $level ? './images/corner-dots.gif' : './images/shim.gif') . '" width="16" height="12" border="0" alt="" />';
    }
    // 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 = str_replace('"', '&quot;', $alt);
    $alt = htmlspecialchars($alt);
    $alt = str_replace("\r", ' ', $alt);
    $alt = str_replace("\n", ' ', $alt);
    */
    $alt = !empty($a['task_description']) ? 'onmouseover="javascript:return overlib(' . "'" . htmlspecialchars('<div><p>' . str_replace(array("\r\n", "\n", "\r"), '</p><p>', addslashes($a['task_description'])), ENT_QUOTES) . '</p></div>' . "', CAPTION, '" . $AppUI->_('Description') . "'" . ', CENTER);" onmouseout="nd();"' : ' ';
    if ($a['task_milestone'] > 0) {
        $s .= '&nbsp;<a href="./index.php?m=tasks&amp;a=view&amp;task_id=' . $a['task_id'] . '" ' . $alt . '>' . '<b>' . $a['task_name'] . '</b></a>' . '<img src="./images/icons/milestone.gif" border="0" alt="Milestone" /></td>';
    } else {
        if ($a['task_dynamic'] == 1 || count($task_obj->getChildren())) {
            if (!($today_view || $hideOpenCloseLink)) {
                $s .= '<a href="index.php' . $query_string . ($is_opened ? '&close_task_id=' . $a['task_id'] . '"><img src="images/icons/collapse.gif" align="center"' : '&open_task_id=' . $a['task_id'] . '"><img src="images/icons/expand.gif"') . ' border="0" alt="" /></a>';
            }
            $s .= '&nbsp;<a href="./index.php?m=tasks&amp;a=view&amp;task_id=' . $a['task_id'] . '" ' . $alt . '>' . ($a['task_dynamic'] == 1 ? '<b><i>' : '') . $a['task_name'] . ($a['task_dynamic'] == 1 ? '</i></b>' : '') . '</a></td>';
        } else {
            $s .= '&nbsp;<a href="./index.php?m=tasks&amp;a=view&amp;task_id=' . $a['task_id'] . '" ' . $alt . '>' . $a['task_name'] . '</a></td>';
        }
    }
    if ($today_view) {
        // Show the project name
        $s .= '<td width="50%"><a href="?m=projects&amp;a=view&amp;project_id=' . $a['task_project'] . '">' . '<span style="padding:2px;background-color:#' . $a['project_color_identifier'] . ';color:' . bestColor($a['project_color_identifier']) . '">' . $a['project_name'] . '</span>' . '</a></td>';
    }
    // task owner
    if (!$today_view) {
        $s .= '<td nowrap="nowrap" align="center">' . '<a href="?m=admin&amp;a=viewuser&amp;user_id=' . $a['user_id'] . '">' . $a['user_username'] . '</a>' . '</td>';
    }
    // $s .= '<td nowrap="nowrap" align="center">' . $a['user_username'] . '</td>';
    if (isset($a['task_assigned_users']) && ($assigned_users = $a['task_assigned_users'])) {
        $a_u_tmp_array = array();
        if ($show_all_assignees) {
            $s .= '<td align="center">';
            foreach ($assigned_users as $val) {
                /*
                $a_u_tmp_array[] = ('<a href="mailto:' . $val['user_email'] . '">' 
                					. $val['user_username'] . '</a>'); 
                */
                $a_u_tmp_array[] = '<a href="?m=admin&amp;a=viewuser&amp;user_id=' . $val['user_id'] . '"' . 'title="' . $AppUI->_('Extent of Assignment') . ':' . $userAlloc[$val['user_id']]['charge'] . '%; ' . $AppUI->_('Free Capacity') . ':' . $userAlloc[$val['user_id']]['freeCapacity'] . '%' . '">' . $val['user_username'] . ' (' . $val['perc_assignment'] . '%)</a>';
            }
            $s .= join(', ', $a_u_tmp_array) . '</td>';
        } else {
            $s .= '<td align="center" nowrap="nowrap">' . '<a href="?m=admin&amp;a=viewuser&amp;user_id=' . $assigned_users[0]['user_id'] . '" title="' . $AppUI->_('Extent of Assignment') . ':' . $userAlloc[$assigned_users[0]['user_id']]['charge'] . '%; ' . $AppUI->_('Free Capacity') . ':' . $userAlloc[$assigned_users[0]['user_id']]['freeCapacity'] . '%">' . $assigned_users[0]['user_username'] . ' (' . $assigned_users[0]['perc_assignment'] . '%)</a>';
            if ($a['assignee_count'] > 1) {
                $s .= ' <a href="javascript: void(0);" onclick="javascript:toggle_users(' . "'users_" . $a['task_id'] . "'" . ');" title="' . join(', ', $a_u_tmp_array) . '">(+' . ($a['assignee_count'] - 1) . ')</a>' . '<span style="display: none" id="users_' . $a['task_id'] . '">';
                $a_u_tmp_array[] = $assigned_users[0]['user_username'];
                for ($i = 1, $xi = count($assigned_users); $i < $xi; $i++) {
                    $a_u_tmp_array[] = $assigned_users[$i]['user_username'];
                    $s .= '<br /><a href="?m=admin&amp;a=viewuser&amp;user_id=' . $assigned_users[$i]['user_id'] . '" title="' . $AppUI->_('Extent of Assignment') . ':' . $userAlloc[$assigned_users[$i]['user_id']]['charge'] . '%; ' . $AppUI->_('Free Capacity') . ':' . $userAlloc[$assigned_users[$i]['user_id']]['freeCapacity'] . '%">' . $assigned_users[$i]['user_username'] . ' (' . $assigned_users[$i]['perc_assignment'] . '%)</a>';
                }
                $s .= '</span>';
            }
            $s .= '</td>';
        }
    } else {
        if (!$today_view) {
            // No users asigned to task
            $s .= '<td align="center">-</td>';
        }
    }
    // duration or milestone
    $s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . ($start_date ? $start_date->format($df) : '-') . '</td>' . '<td align="center" nowrap="nowrap" style="' . $style . '">' . $a['task_duration'] . ' ' . $AppUI->_($durnTypes[$a['task_duration_type']]) . '</td>' . '<td nowrap="nowrap" align="center" style="' . $style . '">' . ($end_date ? $end_date->format($df) : '-') . '</td>';
    if ($today_view) {
        $s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . $a['task_due_in'] . '</td>';
    } else {
        if ($AppUI->isActiveModule('history') && getPermission('history', 'view')) {
            $s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . ($last_update ? $last_update->format($df) : '-') . '</td>';
        }
    }
    // Assignment checkbox
    if ($showEditCheckbox) {
        $s .= "\n\t" . '<td align="center">' . '<input type="checkbox" name="selected_task[' . $a['task_id'] . ']" value="' . $a['task_id'] . '"/></td>';
    }
    $s .= '</tr>';
    echo $s;
}
Ejemplo n.º 6
0
$html .= $cal->_drawBirthdays($this_day->format('%Y%m%d'));
$html .= '<table cellspacing="1" cellpadding="2" border="0" width="100%" class="tbl">';
$this_day->setTime($start, 0, 0);
for ($i = 0, $n = ($end - $start) * 60 / $inc; $i < $n; $i++) {
    $html .= "\n<tr>";
    $tm = $this_day->format($tf);
    $html .= "\n\t" . '<td width="1%" align="right" nowrap="nowrap">' . ($this_day->getMinute() ? $tm : '<b>' . $tm . '</b>') . '</td>';
    $timeStamp = $this_day->format('%H%M%S');
    if (@$events2[$timeStamp]) {
        $count = count($events2[$timeStamp]);
        for ($j = 0; $j < $count; $j++) {
            $row = $events2[$timeStamp][$j];
            $et = new CDate($row['event_end_date']);
            $et_date = new CDate($row['event_end_date']);
            $et_date->setTime(0, 0, 0);
            if ($et_date->after($this_day)) {
                $rows = $n - $i;
            } else {
                $rows = ($et->getHour() * 60 + $et->getMinute() - ($this_day->getHour() * 60 + $this_day->getMinute())) / $inc;
            }
            $href = "?m=calendar&a=view&event_id=" . $row['event_id'];
            $alt = $row['event_description'];
            $html .= "\n\t" . '<td class="event" rowspan="' . $rows . '" valign="top">';
            $html .= "\n" . '<table cellspacing="0" cellpadding="0" border="0"><tr>';
            $html .= "\n<td>" . dPshowImage(dPfindImage('event' . $row['event_type'] . '.png', 'calendar'), 16, 16, '');
            $html .= "</td>\n<td>&nbsp;<b>" . $AppUI->_($types[$row['event_type']]) . '</b></td></tr></table>';
            $html .= $href ? "\n\t\t" . '<a href="' . htmlspecialchars($href) . '" class="event" title="' . htmlspecialchars($alt) . '">' : '';
            $html .= "\n\t\t" . htmlspecialchars($row['event_title']);
            $html .= $href ? "\n\t\t</a>" : '';
            $html .= "\n\t</td>";
        }
Ejemplo n.º 7
0
        $row['task_start_date'] = date('Y-m-d H:i:s');
    }
    $tsd = new CDate($row['task_start_date']);
    if ($tsd->before(new CDate($start_min))) {
        $start_min = $row['task_start_date'];
    }
    // calculate or set blank task_end_date if unset
    if ($row['task_end_date'] == '0000-00-00 00:00:00') {
        if ($row['task_duration']) {
            $row['task_end_date'] = db_unix2dateTime(db_dateTime2unix($row['task_start_date']) + SECONDS_PER_DAY * convert2days($row['task_duration'], $row['task_duration_type']));
        } else {
            $row['task_end_date'] = '';
        }
    }
    $ted = new CDate($row['task_end_date']);
    if ($ted->after(new CDate($end_max))) {
        $end_max = $row['task_end_date'];
    }
    $projects[$row['task_project']]['tasks'][] = $row;
}
$q->clear();
$width = dPgetParam($_GET, 'width', 600);
//consider critical (concerning end date) tasks as well
if ($caller != 'todo') {
    //	$start_min = $projects[$project_id]['project_start_date'];
    $start_min = substr($criticalTasksInverted[0]['task_start_date'], 0, 10);
    //	$end_max = ($projects[$project_id]['project_end_date'] > $criticalTasks[0]['task_end_date']) ? $projects[$project_id]['project_end_date'] : $criticalTasks[0]['task_end_date'];
    $end_max = substr($criticalTasks[0]['task_end_date'], 0, 10);
}
$start_date = dPgetParam($_GET, 'start_date', $start_min);
$end_date = dPgetParam($_GET, 'end_date', $end_max);
	<th width="0">&nbsp;</th>
</tr>

<?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">
Ejemplo n.º 9
0
 /**
 * Calculating if an recurrent date is in the given period
 * @param Date Start date of the period
 * @param Date End date of the period
 * @param Date Start date of the Date Object
 * @param Date End date of the Date Object
 * @param integer Type of Recurrence
 * @param integer Times of Recurrence
 * @param integer Time of Recurrence
 * @return array Calculated Start and End Dates for the recurrent Event for the given Period
 */
 function getRecurrentEventforPeriod($start_date, $end_date, $event_start_date, $event_end_date, $event_recurs, $event_times_recuring, $j)
 {
     //this array will be returned
     $transferredEvent = array();
     //create Date Objects for Event Start and Event End
     $eventStart = new CDate($event_start_date);
     $eventEnd = new CDate($event_end_date);
     //Time of Recurence = 0 (first occurence of event) has to be checked, too.
     if ($j > 0) {
         switch ($event_recurs) {
             case 1:
                 $eventStart->addSpan(new Date_Span(3600 * $j));
                 $eventEnd->addSpan(new Date_Span(3600 * $j));
                 break;
             case 2:
                 $eventStart->addDays($j);
                 $eventEnd->addDays($j);
                 break;
             case 3:
                 $eventStart->addDays(7 * $j);
                 $eventEnd->addDays(7 * $j);
                 break;
             case 4:
                 $eventStart->addDays(14 * $j);
                 $eventEnd->addDays(14 * $j);
                 break;
             case 5:
                 $eventStart->addMonths($j);
                 $eventEnd->addMonths($j);
                 break;
             case 6:
                 $eventStart->addMonths(3 * $j);
                 $eventEnd->addMonths(3 * $j);
                 break;
             case 7:
                 $eventStart->addMonths(6 * $j);
                 $eventEnd->addMonths(6 * $j);
                 break;
             case 8:
                 $eventStart->addMonths(12 * $j);
                 $eventEnd->addMonths(12 * $j);
                 break;
             default:
                 break;
         }
     }
     if ($eventStart->before($end_date) && $eventEnd->after($start_date)) {
         // add temporarily moved Event Start and End dates to returnArray
         $transferredEvent = array($eventStart, $eventEnd);
     }
     // return array with event start and end dates for given period (positive case)
     // or an empty array (negative case)
     return $transferredEvent;
 }
function showtask_pd(&$a, $level = 0, $is_opened = true, $today_view = false)
{
    global $AppUI, $dPconfig, $done, $query_string, $durnTypes, $userAlloc, $showEditCheckbox;
    global $task_access, $task_priority, $PROJDESIGN_CONFIG;
    $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');
        }
        if ($now->after($start_date) && $a["task_percent_complete"] == 0) {
            $style = 'background-color:#ffeebb';
        } else {
            if ($now->after($start_date) && $a["task_percent_complete"] < 100) {
                $style = 'background-color:#e6eedd';
            }
        }
        if ($now->after($end_date)) {
            $sign = -1;
            $style = 'background-color:#cc6666;color:#ffffff';
        }
        if ($a["task_percent_complete"] == 100) {
            $style = 'background-color:#aaddaa; color:#00000';
        }
        $days = $now->dateDiff($end_date) * $sign;
    }
    $s = "\n<tr id=\"row" . $a['task_id'] . "\" onmouseover=\"highlight_tds(this, true, " . $a['task_id'] . ")\" onmouseout=\"highlight_tds(this, false, " . $a['task_id'] . ")\" onclick=\"select_box('selected_task', " . $a['task_id'] . ",'frm_tasks')\">";
    // edit icon
    $s .= "\n\t<td>";
    $canEdit = !getDenyEdit('tasks', $a["task_id"]);
    $canViewLog = $perms->checkModuleItem('task_log', 'view', $a['task_id']);
    if ($canEdit) {
        $s .= "\n\t\t<a href=\"?m=tasks&a=addedit&task_id={$a['task_id']}\">" . "\n\t\t\t" . '<img src="./images/icons/pencil.gif" alt="' . $AppUI->_('Edit Task') . '" border="0" width="12" height="12">' . "\n\t\t</a>";
    }
    $s .= "\n\t</td>";
    // pinned
    /*        $pin_prefix = $a['task_pinned']?'':'un';
            $s .= "\n\t<td>";
            $s .= "\n\t\t<a href=\"?m=tasks&pin=" . ($a['task_pinned']?0:1) . "&task_id={$a['task_id']}\">"
                    . "\n\t\t\t".'<img src="./images/icons/' . $pin_prefix . 'pin.gif" alt="'.$AppUI->_( $pin_prefix . 'pin Task' ).'" border="0" width="12" height="12">'
                    . "\n\t\t</a>";
            $s .= "\n\t</td>";*/
    // New Log
    /*        if (@$a['task_log_problem']>0) {
                    $s .= '<td align="center" valign="middle"><a href="?m=tasks&a=view&task_id='.$a['task_id'].'&tab=0&problem=1">';
                    $s .= dPshowImage( './images/icons/dialog-warning5.png', 16, 16, 'Problem', 'Problem!' );
                    $s .='</a></td>';
            } else if ($canViewLog) {
                    $s .= "\n\t<td><a href=\"?m=tasks&a=view&task_id=" . $a['task_id'] . '&tab=1">' . $AppUI->_('Log') . '</a></td>';
            } else {
                    $s .= "\n\t<td></td>";
                                    }*/
    // percent complete
    $s .= "\n\t<td align=\"right\">" . intval($a["task_percent_complete"]) . '%</td>';
    // priority
    $s .= "\n\t<td align='center' nowrap='nowrap'>";
    if ($a["task_priority"] < 0) {
        $s .= "\n\t\t<img src=\"./images/icons/priority-" . -$a["task_priority"] . '.gif" width=13 height=16>';
    } else {
        if ($a["task_priority"] > 0) {
            $s .= "\n\t\t<img src=\"./images/icons/priority+" . $a["task_priority"] . '.gif" width=13 height=16>';
        }
    }
    $s .= @$a["file_count"] > 0 ? "<img src=\"./images/clip.png\" alt=\"F\">" : "";
    $s .= "</td>";
    // access
    $s .= "\n\t<td nowrap='nowrap'>";
    $s .= '<abbr title="' . $task_access[$a['task_access']] . '">' . substr($task_access[$a["task_access"]], 0, 3) . '</abbr>';
    $s .= "</td>";
    // type
    $s .= "\n\t<td nowrap='nowrap'>";
    $s .= '<abbr title="' . $types[$a['task_type']] . '">' . substr($types[$a["task_type"]], 0, 3) . '</abbr>';
    $s .= "</td>";
    // type
    $s .= "\n\t<td nowrap='nowrap'>";
    $s .= $a["queue_id"] ? 'Yes' : '';
    $s .= "</td>";
    // inactive
    $s .= "\n\t<td nowrap='nowrap'>";
    $s .= $a["task_status"] == '-1' ? 'Yes' : '';
    $s .= "</td>";
    // add log
    $s .= "\n\t<td align='center' nowrap='nowrap'>";
    if ($a['task_dynamic'] != 1) {
        $s .= "\n\t\t<a href=\"?m=tasks&a=view&tab=1&project_id={$a['task_project']}&task_id={$a['task_id']}\">" . "\n\t\t\t" . '<img src="./modules/projectdesigner/images/add.png" alt="' . $AppUI->_('Add Work Log') . '" title="' . $AppUI->_('Add Work Log') . '" border="0" width="16" height="16">' . "\n\t\t</a>";
    }
    $s .= "</td>";
    // dots
    if ($today_view) {
        $s .= '<td>';
    } else {
        $s .= '<td 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']) > intval($PROJDESIGN_CONFIG['chars_task_descriptions']) ? substr($a["task_description"], 0, intval($PROJDESIGN_CONFIG['chars_task_descriptions'])) . '...' : $a['task_description'];
    // instead of the statement below
    $alt = str_replace("\"", "&quot;", $alt);
    //        $alt = htmlspecialchars($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 .= '&nbsp;<a href="./index.php?m=tasks&a=view&task_id=' . $a["task_id"] . '" title="' . $alt . '"><b><i>' . $a["task_name"] . '</i></b></a></td>';
        } else {
            $s .= '&nbsp;<a href="./index.php?m=tasks&a=view&task_id=' . $a["task_id"] . '" title="' . $alt . '">' . $a["task_name"] . '</a></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>';
    }
    // task description
    if ($PROJDESIGN_CONFIG['show_task_descriptions']) {
        $s .= '<td align="justified">' . $a['task_description'] . '</td>';
    }
    // task owner
    $s .= '<td align="center">' . "<a href='?m=admin&a=viewuser&user_id=" . $a['user_id'] . "'>" . $a['contact_first_name'] . ' ' . $a['contact_last_name'] . "</a>" . '</td>';
    if (!$today_view) {
        $s .= '<td  id="ignore_td_' . $a['task_id'] . '" nowrap="nowrap" align="center" style="' . $style . '">' . ($start_date ? $start_date->format($df . ' ' . $tf) : '-') . '</td>';
        //		        $s .= '<td nowrap="nowrap" align="center" style="'.$style.'">'.($start_date ? $start_date->format( $tf ) : '-').'</td>';
    }
    // duration or milestone
    $s .= '<td  id="ignore_td_' . $a['task_id'] . '" align="center" nowrap="nowrap" style="' . $style . '">';
    $s .= $a['task_duration'] . ' ' . $AppUI->_($durnTypes[$a['task_duration_type']]);
    $s .= '</td>';
    $s .= '<td id="ignore_td_' . $a['task_id'] . '" nowrap="nowrap" align="center" style="' . $style . '">' . ($end_date ? $end_date->format($df . ' ' . $tf) : '-') . '</td>';
    if (isset($a['task_assigned_users']) && ($assigned_users = $a['task_assigned_users'])) {
        $a_u_tmp_array = array();
        if ($show_all_assignees) {
            $s .= '<td align="center">';
            foreach ($assigned_users as $val) {
                //$a_u_tmp_array[] = "<A href='mailto:".$val['user_email']."'>".$val['user_username']."</A>";
                $aInfo = "<a href='?m=admin&a=viewuser&user_id=" . $val['user_id'] . "'";
                $aInfo .= 'title="' . $AppUI->_('Extent of Assignment') . ':' . $userAlloc[$val['user_id']]['charge'] . '%; ' . $AppUI->_('Free Capacity') . ':' . $userAlloc[$val['user_id']]['freeCapacity'] . '%' . '">';
                $aInfo .= $val['contact_first_name'] . ' ' . $val['contact_last_name'] . " (" . $val['perc_assignment'] . "%)</a>";
                $a_u_tmp_array[] = $aInfo;
            }
            $s .= join(', ', $a_u_tmp_array);
            $s .= '</td>';
        } else {
            $s .= '<td align="center" nowrap="nowrap">';
            $s .= "<a href='?m=admin&a=viewuser&user_id=" . $assigned_users[0]['user_id'] . "'";
            $s .= 'title="' . $AppUI->_('Extent of Assignment') . ':' . $userAlloc[$assigned_users[0]['user_id']]['charge'] . '%; ' . $AppUI->_('Free Capacity') . ':' . $userAlloc[$assigned_users[0]['user_id']]['freeCapacity'] . '%' . '">';
            $s .= $assigned_users[0]['contact_first_name'] . ' ' . $assigned_users[0]['contact_last_name'] . ' (' . $assigned_users[0]['perc_assignment'] . '%)</a>';
            if ($a['assignee_count'] > 1) {
                $id = $a['task_id'];
                $s .= " <a href=\"javascript: void(0);\"  onClick=\"toggle_users('users_{$id}');\" title=\"" . join(', ', $a_u_tmp_array) . "\">(+" . ($a['assignee_count'] - 1) . ")</a>";
                $s .= '<span style="display: none" id="users_' . $id . '">';
                $a_u_tmp_array[] = $assigned_users[0]['user_username'];
                for ($i = 1; $i < count($assigned_users); $i++) {
                    $a_u_tmp_array[] = $assigned_users[$i]['user_username'];
                    $s .= '<br /><a href="?m=admin&a=viewuser&user_id=';
                    $s .= $assigned_users[$i]['user_id'] . '" title="' . $AppUI->_('Extent of Assignment') . ':' . $userAlloc[$assigned_users[$i]['user_id']]['charge'] . '%; ' . $AppUI->_('Free Capacity') . ':' . $userAlloc[$assigned_users[$i]['user_id']]['freeCapacity'] . '%' . '">';
                    $s .= $assigned_users[$i]['contact_first_name'] . ' ' . $assigned_users[$i]['contact_last_name'] . ' (' . $assigned_users[$i]['perc_assignment'] . '%)</a>';
                }
                $s .= '</span>';
            }
            $s .= '</td>';
        }
    } else {
        if (!$today_view) {
            // No users asigned to task
            $s .= '<td align="center">-</td>';
        }
    }
    // Assignment checkbox
    if ($showEditCheckbox || $perms->checkModule('admin', 'view')) {
        $s .= "\n\t<td align='center'><input type=\"checkbox\" onclick=\"select_box('selected_task', " . $a['task_id'] . ",'frm_tasks')\" onfocus=\"is_check=true;\" onblur=\"is_check=false;\" id=\"selected_task_{$a['task_id']}\" name=\"selected_task[{$a['task_id']}]\" value=\"{$a['task_id']}\"/></td>";
    }
    $s .= '</tr>';
    echo $s;
}
Ejemplo n.º 11
0
function showtask(&$a, $level = 0, $is_opened = true, $today_view = false)
{
    global $AppUI, $dPconfig, $done, $query_string, $durnTypes, $userAlloc, $showEditCheckbox;
    $now = new CDate();
    $df = $AppUI->getPref('SHDATEFORMAT');
    $df .= " " . $AppUI->getPref('TIMEFORMAT');
    $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 = $start_date;
            $end_date->addSeconds(@$a["task_duration"] * $a["task_duration_type"] * SEC_HOUR);
        }
        if ($now->after($start_date) && $a["task_percent_complete"] == 0) {
            $style = 'background-color:#ffeebb';
        } else {
            if ($now->after($start_date) && $a["task_percent_complete"] < 100) {
                $style = 'background-color:#e6eedd';
            }
        }
        if ($now->after($end_date)) {
            $sign = -1;
            $style = 'background-color:#cc6666;color:#ffffff';
        }
        if ($a["task_percent_complete"] == 100) {
            $style = 'background-color:#aaddaa; color:#00000';
        }
        $days = $now->dateDiff($end_date) * $sign;
    }
    $s = "\n<tr>";
    // edit icon
    $s .= "\n\t<td>";
    $canEdit = !getDenyEdit('tasks', $a["task_id"]);
    $canViewLog = $perms->checkModuleItem('task_log', 'view', $a['task_id']);
    if ($canEdit) {
        $s .= "\n\t\t<a href=\"?m=tasks&a=addedit&task_id={$a['task_id']}\">" . "\n\t\t\t" . '<img src="./images/icons/pencil.gif" alt="' . $AppUI->_('Edit Task') . '" border="0" width="12" height="12">' . "\n\t\t</a>";
    }
    $s .= "\n\t</td>";
    // pinned
    $pin_prefix = $a['task_pinned'] ? '' : 'un';
    $s .= "\n\t<td>";
    $s .= "\n\t\t<a href=\"?m=tasks&pin=" . ($a['task_pinned'] ? 0 : 1) . "&task_id={$a['task_id']}\">" . "\n\t\t\t" . '<img src="./images/icons/' . $pin_prefix . 'pin.gif" alt="' . $AppUI->_($pin_prefix . 'pin Task') . '" border="0" width="12" height="12">' . "\n\t\t</a>";
    $s .= "\n\t</td>";
    // New Log
    if (@$a['task_log_problem'] > 0) {
        $s .= '<td align="center" valign="middle"><a href="?m=tasks&a=view&task_id=' . $a['task_id'] . '&tab=0&problem=1">';
        $s .= dPshowImage('./images/icons/dialog-warning5.png', 16, 16, 'Problem', 'Problem!');
        $s .= '</a></td>';
    } else {
        if ($canViewLog) {
            $s .= "\n\t<td><a href=\"?m=tasks&a=view&task_id=" . $a['task_id'] . '&tab=1">' . $AppUI->_('Log') . '</a></td>';
        } else {
            $s .= "\n\t<td></td>";
        }
    }
    // percent complete
    $s .= "\n\t<td align=\"right\">" . intval($a["task_percent_complete"]) . '%</td>';
    // priority
    $s .= "\n\t<td align='center' nowrap='nowrap'>";
    if ($a["task_priority"] < 0) {
        $s .= "\n\t\t<img src=\"./images/icons/priority-" . -$a["task_priority"] . '.gif" width=13 height=16>';
    } else {
        if ($a["task_priority"] > 0) {
            $s .= "\n\t\t<img src=\"./images/icons/priority+" . $a["task_priority"] . '.gif" width=13 height=16>';
        }
    }
    $s .= @$a["file_count"] > 0 ? "<img src=\"./images/clip.png\" alt=\"F\">" : "";
    $s .= "</td>";
    // dots
    if ($today_view) {
        $s .= '<td width="50%">';
    } else {
        $s .= '<td width="90%">';
    }
    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 = htmlspecialchars($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 .= '&nbsp;<a href="./index.php?m=tasks&a=view&task_id=' . $a["task_id"] . '" title="' . $alt . '"><b><i>' . $a["task_name"] . '</i></b></a></td>';
        } else {
            $s .= '&nbsp;<a href="./index.php?m=tasks&a=view&task_id=' . $a["task_id"] . '" title="' . $alt . '">' . $a["task_name"] . '</a></td>';
        }
    }
    if ($today_view) {
        // Show the project name
        $s .= '<td width="50%">';
        $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>';
    }
    // task owner
    if (!$today_view) {
        $s .= '<td nowrap="nowrap" align="center">' . "<a href='?m=admin&a=viewuser&user_id=" . $a['user_id'] . "'>" . $a['user_username'] . "</a>" . '</td>';
    }
    //	$s .= '<td nowrap="nowrap" align="center">'. $a["user_username"] .'</td>';
    if (isset($a['task_assigned_users']) && ($assigned_users = $a['task_assigned_users'])) {
        $a_u_tmp_array = array();
        if ($show_all_assignees) {
            $s .= '<td align="center">';
            foreach ($assigned_users as $val) {
                //$a_u_tmp_array[] = "<A href='mailto:".$val['user_email']."'>".$val['user_username']."</A>";
                $aInfo = "<a href='?m=admin&a=viewuser&user_id=" . $val['user_id'] . "'";
                $aInfo .= 'title="' . $AppUI->_('Extent of Assignment') . ':' . $userAlloc[$val['user_id']]['charge'] . '%; ' . $AppUI->_('Free Capacity') . ':' . $userAlloc[$val['user_id']]['freeCapacity'] . '%' . '">';
                $aInfo .= $val['user_username'] . " (" . $val['perc_assignment'] . "%)</a>";
                $a_u_tmp_array[] = $aInfo;
            }
            $s .= join(', ', $a_u_tmp_array);
            $s .= '</td>';
        } else {
            $s .= '<td align="center" nowrap="nowrap">';
            //			$s .= $a['assignee_username'];
            $s .= "<a href='?m=admin&a=viewuser&user_id=" . $assigned_users[0]['user_id'] . "'";
            $s .= 'title="' . $AppUI->_('Extent of Assignment') . ':' . $userAlloc[$assigned_users[0]['user_id']]['charge'] . '%; ' . $AppUI->_('Free Capacity') . ':' . $userAlloc[$assigned_users[0]['user_id']]['freeCapacity'] . '%' . '">';
            $s .= $assigned_users[0]['user_username'] . ' (' . $assigned_users[0]['perc_assignment'] . '%)</a>';
            if ($a['assignee_count'] > 1) {
                $id = $a['task_id'];
                $s .= " <a href=\"javascript: void(0);\"  onClick=\"toggle_users('users_{$id}');\" title=\"" . join(', ', $a_u_tmp_array) . "\">(+" . ($a['assignee_count'] - 1) . ")</a>";
                $s .= '<span style="display: none" id="users_' . $id . '">';
                $a_u_tmp_array[] = $assigned_users[0]['user_username'];
                for ($i = 1; $i < count($assigned_users); $i++) {
                    $a_u_tmp_array[] = $assigned_users[$i]['user_username'];
                    $s .= '<br /><a href="?m=admin&a=viewuser&user_id=';
                    $s .= $assigned_users[$i]['user_id'] . '" title="' . $AppUI->_('Extent of Assignment') . ':' . $userAlloc[$assigned_users[$i]['user_id']]['charge'] . '%; ' . $AppUI->_('Free Capacity') . ':' . $userAlloc[$assigned_users[$i]['user_id']]['freeCapacity'] . '%' . '">';
                    $s .= $assigned_users[$i]['user_username'] . ' (' . $assigned_users[$i]['perc_assignment'] . '%)</a>';
                }
                $s .= '</span>';
            }
            $s .= '</td>';
        }
    } else {
        if (!$today_view) {
            // No users asigned to task
            $s .= '<td align="center">-</td>';
        }
    }
    $s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . ($start_date ? $start_date->format($df) : '-') . '</td>';
    // duration or milestone
    $s .= '<td align="center" nowrap="nowrap" style="' . $style . '">';
    $s .= $a['task_duration'] . ' ' . $AppUI->_($durnTypes[$a['task_duration_type']]);
    $s .= '</td>';
    $s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . ($end_date ? $end_date->format($df) : '-') . '</td>';
    if ($today_view) {
        $s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . $a['task_due_in'] . '</td>';
    } else {
        $s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . ($last_update ? $last_update->format($df) : '-') . '</td>';
    }
    // Assignment checkbox
    if ($showEditCheckbox) {
        $s .= "\n\t<td align='center'><input type=\"checkbox\" name=\"selected_task[{$a['task_id']}]\" value=\"{$a['task_id']}\"/></td>";
    }
    $s .= '</tr>';
    echo $s;
}
Ejemplo n.º 12
0
function showtask_pd(&$a, $level = 0, $today_view = false)
{
    global $AppUI, $w2Pconfig, $done, $query_string, $durnTypes, $userAlloc, $showEditCheckbox;
    global $task_access, $task_priority, $PROJDESIGN_CONFIG, $m, $expanded;
    $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');
        }
        if ($now->after($start_date) && $a['task_percent_complete'] == 0) {
            $style = 'background-color:#ffeebb';
        } elseif ($now->after($start_date) && $a['task_percent_complete'] < 100) {
            $style = 'background-color:#e6eedd';
        }
        if ($now->after($end_date)) {
            $sign = -1;
            $style = 'background-color:#cc6666;color:#ffffff';
        }
        if ($a['task_percent_complete'] == 100) {
            $style = 'background-color:#aaddaa; color:#00000';
        }
        $days = $now->dateDiff($end_date) * $sign;
    }
    if ($expanded) {
        $s = '<tr id="project_' . $a['task_project'] . '_level>' . $level . '<task_' . $a['task_id'] . '_" onmouseover="highlight_tds(this, true, ' . $a['task_id'] . ')" onmouseout="highlight_tds(this, false, ' . $a['task_id'] . ')" onclick="select_box(\'selected_task\', \'' . $a['task_id'] . '\', \'project_' . $a['task_project'] . '_level>' . $level . '<task_' . $a['task_id'] . '_\',\'frm_tasks\')">';
        // edit icon
    } else {
        $s = '<tr id="project_' . $a['task_project'] . '_level>' . $level . '<task_' . $a['task_id'] . '_" onmouseover="highlight_tds(this, true, ' . $a['task_id'] . ')" onmouseout="highlight_tds(this, false, ' . $a['task_id'] . ')" onclick="select_box(\'selected_task\', \'' . $a['task_id'] . '\', \'project_' . $a['task_project'] . '_level>' . $level . '<task_' . $a['task_id'] . '_\',\'frm_tasks\')" ' . ($level ? 'style="display:none"' : '') . '>';
        // edit icon
    }
    $s .= '<td>';
    $canEdit = true;
    $canViewLog = true;
    if ($canEdit) {
        $s .= w2PtoolTip('edit tasks panel', 'click to edit this task') . '<a href="?m=tasks&a=addedit&task_id=' . $a['task_id'] . '"><img src="' . w2PfindImage('icons/pencil.gif') . '" border="0" width="12" height="12" /></a>' . w2PendTip();
    }
    $s .= '</td>';
    // percent complete
    $s .= '<td align="right">' . intval($a['task_percent_complete']) . '%</td>';
    // priority
    $s .= '<td align="center" nowrap="nowrap">';
    if ($a['task_priority'] < 0) {
        $s .= '<img src="' . w2PfindImage('icons/priority-' . -$a['task_priority'] . '.gif') . '" width="13" height="16" />';
    } elseif ($a['task_priority'] > 0) {
        $s .= '<img src="' . w2PfindImage('icons/priority+' . $a['task_priority'] . '.gif') . '" width="13" height="16" />';
    }
    $s .= $a['file_count'] > 0 ? '<img src="' . w2PfindImage('clip.png') . '" alt="' . $AppUI->_('Files') . '" />' : '';
    $s .= '</td>';
    // access
    $s .= '<td nowrap="nowrap">';
    $s .= mb_substr($task_access[$a['task_access']], 0, 3);
    $s .= '</td>';
    // type
    $s .= '<td nowrap="nowrap">';
    $s .= mb_substr($types[$a['task_type']], 0, 3);
    $s .= '</td>';
    // type
    $s .= '<td nowrap="nowrap">';
    $s .= $a['queue_id'] ? 'Yes' : '';
    $s .= '</td>';
    // inactive
    $s .= '<td nowrap="nowrap">';
    $s .= $a['task_status'] == '-1' ? 'Yes' : '';
    $s .= '</td>';
    // add log
    $s .= '<td align="center" nowrap="nowrap">';
    if ($a['task_dynamic'] != 1) {
        $s .= w2PtoolTip('tasks', 'add work log to this task') . '<a href="?m=tasks&a=view&tab=1&project_id=' . $a['task_project'] . '&task_id=' . $a['task_id'] . '"><img src="' . w2PfindImage('add.png', $m) . '" border="0" width="16" height="16" /></a>' . w2PendTip();
    }
    $s .= '</td>';
    // dots
    if ($today_view) {
        $s .= '<td>';
    } else {
        $s .= '<td 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
    if ($a['task_description']) {
        $s .= w2PtoolTip('Task Description', $a['task_description'], true);
    }
    $open_link = '<a href="javascript: void(0);"><img onclick="expand_collapse(\'project_' . $a['task_project'] . '_level>' . $level . '<task_' . $a['task_id'] . '_\', \'tblProjects\',\'\',' . ($level + 1) . ');" id="project_' . $a['task_project'] . '_level>' . $level . '<task_' . $a['task_id'] . '__collapse" src="' . w2PfindImage('icons/collapse.gif', $m) . '" border="0" align="center" ' . (!$expanded ? 'style="display:none"' : '') . ' /><img onclick="expand_collapse(\'project_' . $a['task_project'] . '_level>' . $level . '<task_' . $a['task_id'] . '_\', \'tblProjects\',\'\',' . ($level + 1) . ');" id="project_' . $a['task_project'] . '_level>' . $level . '<task_' . $a['task_id'] . '__expand" src="' . w2PfindImage('icons/expand.gif', $m) . '" border="0" align="center" ' . ($expanded ? 'style="display:none"' : '') . ' /></a>';
    $taskObj = new CTask();
    $taskObj->load($a['task_id']);
    if (count($taskObj->getChildren())) {
        $is_parent = true;
    } else {
        $is_parent = false;
    }
    if ($a['task_milestone'] > 0) {
        $s .= '&nbsp;<a href="./index.php?m=tasks&a=view&task_id=' . $a['task_id'] . '" ><b>' . $a['task_name'] . '</b></a> <img src="' . w2PfindImage('icons/milestone.gif', $m) . '" border="0" /></td>';
    } elseif ($a['task_dynamic'] == '1' || $is_parent) {
        $s .= $open_link;
        if ($a['task_dynamic'] == '1') {
            $s .= '&nbsp;<a href="./index.php?m=tasks&a=view&task_id=' . $a['task_id'] . '" ><b><i>' . $a['task_name'] . '</i></b></a></td>';
        } else {
            $s .= '&nbsp;<a href="./index.php?m=tasks&a=view&task_id=' . $a['task_id'] . '" >' . $a['task_name'] . '</a></td>';
        }
    } else {
        $s .= '&nbsp;<a href="./index.php?m=tasks&a=view&task_id=' . $a['task_id'] . '" >' . $a['task_name'] . '</a></td>';
    }
    if ($a['task_description']) {
        $s .= w2PendTip();
    }
    // task description
    if ($PROJDESIGN_CONFIG['show_task_descriptions']) {
        $s .= '<td align="justified">' . $a['task_description'] . '</td>';
    }
    // task owner
    $s .= '<td align="left">' . '<a href="?m=admin&a=viewuser&user_id=' . $a['user_id'] . '">' . $a['contact_first_name'] . ' ' . $a['contact_last_name'] . '</a></td>';
    $s .= '<td id="ignore_td_' . $a['task_id'] . '" nowrap="nowrap" align="center" style="' . $style . '">' . ($start_date ? $start_date->format($df . ' ' . $tf) : '-') . '</td>';
    // duration or milestone
    $s .= '<td id="ignore_td_' . $a['task_id'] . '" align="right" nowrap="nowrap" style="' . $style . '">';
    $s .= $a['task_duration'] . ' ' . mb_substr($AppUI->_($durnTypes[$a['task_duration_type']]), 0, 1);
    $s .= '</td>';
    $s .= '<td id="ignore_td_' . $a['task_id'] . '" nowrap="nowrap" align="center" style="' . $style . '">' . ($end_date ? $end_date->format($df . ' ' . $tf) : '-') . '</td>';
    if (isset($a['task_assigned_users']) && ($assigned_users = $a['task_assigned_users'])) {
        $a_u_tmp_array = array();
        if ($show_all_assignees) {
            $s .= '<td align="left">';
            foreach ($assigned_users as $val) {
                $aInfo = '<a href="?m=admin&a=viewuser&user_id=' . $val['user_id'] . '"';
                $aInfo .= 'title="' . (w2PgetConfig('check_overallocation') ? $AppUI->_('Extent of Assignment') . ':' . $userAlloc[$val['user_id']]['charge'] . '%; ' . $AppUI->_('Free Capacity') . ':' . $userAlloc[$val['user_id']]['freeCapacity'] . '%' : '') . '">';
                $aInfo .= $val['contact_first_name'] . ' ' . $val['contact_last_name'] . ' (' . $val['perc_assignment'] . '%)</a>';
                $a_u_tmp_array[] = $aInfo;
            }
            $s .= join(', ', $a_u_tmp_array);
            $s .= '</td>';
        } else {
            $s .= '<td align="left" nowrap="nowrap">';
            $s .= '<a href="?m=admin&a=viewuser&user_id=' . $assigned_users[0]['user_id'] . '"';
            $s .= 'title="' . (w2PgetConfig('check_overallocation') ? $AppUI->_('Extent of Assignment') . ':' . $userAlloc[$assigned_users[0]['user_id']]['charge'] . '%; ' . $AppUI->_('Free Capacity') . ':' . $userAlloc[$assigned_users[0]['user_id']]['freeCapacity'] . '%' : '') . '">';
            $s .= $assigned_users[0]['contact_first_name'] . ' ' . $assigned_users[0]['contact_last_name'] . ' (' . $assigned_users[0]['perc_assignment'] . '%)</a>';
            if ($a['assignee_count'] > 1) {
                $id = $a['task_id'];
                $s .= '<a href="javascript: void(0);"  onclick="toggle_users(\'users_' . $id . '\');" title="' . join(', ', $a_u_tmp_array) . '">(+' . ($a['assignee_count'] - 1) . ')</a>';
                $s .= '<span style="display: none" id="users_' . $id . '">';
                $a_u_tmp_array[] = $assigned_users[0]['user_username'];
                for ($i = 1, $i_cmp = count($assigned_users); $i < $i_cmp; $i++) {
                    $a_u_tmp_array[] = $assigned_users[$i]['user_username'];
                    $s .= '<br /><a href="?m=admin&a=viewuser&user_id=';
                    $s .= $assigned_users[$i]['user_id'] . '" title="' . (w2PgetConfig('check_overallocation') ? $AppUI->_('Extent of Assignment') . ':' . $userAlloc[$assigned_users[$i]['user_id']]['charge'] . '%; ' . $AppUI->_('Free Capacity') . ':' . $userAlloc[$assigned_users[$i]['user_id']]['freeCapacity'] . '%' : '') . '">';
                    $s .= $assigned_users[$i]['contact_first_name'] . ' ' . $assigned_users[$i]['contact_last_name'] . ' (' . $assigned_users[$i]['perc_assignment'] . '%)</a>';
                }
                $s .= '</span>';
            }
            $s .= '</td>';
        }
    } else {
        // No users asigned to task
        $s .= '<td align="center">-</td>';
    }
    // Assignment checkbox
    if ($showEditCheckbox) {
        $s .= '<td align="center"><input type="checkbox" onclick="select_box(\'selected_task\', ' . $a['task_id'] . ',\'project_' . $a['task_project'] . '_level>' . $level . '<task_' . $a['task_id'] . '_\',\'frm_tasks\')" onfocus="is_check=true;" onblur="is_check=false;" id="selected_task_' . $a['task_id'] . '" name="selected_task[' . $a['task_id'] . ']" value="' . $a['task_id'] . '"/></td>';
    }
    $s .= '</tr>';
    echo $s;
}
Ejemplo n.º 13
0
function showtask(&$a, $level = 0, $is_opened = true, $today_view = false)
{
    global $AppUI, $dPconfig, $done, $query_string, $isProjectManager;
    $now = new CDate();
    $show_all_assignees = $dPconfig['show_all_task_assignees'] ? true : false;
    $done[] = $id = $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;
    // 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');
        }
        if ($now->after($start_date) && $a['task_percent_complete'] == 0) {
            $style = 'background-color:#ffeebb';
        } else {
            if ($now->after($start_date) && $a['task_percent_complete'] < 100) {
                $style = 'background-color:#e6eedd';
            }
        }
        if ($now->after($end_date)) {
            $sign = -1;
            $style = 'background-color:#cc6666;color:#ffffff';
        }
        if ($a['task_percent_complete'] == 100) {
            $style = 'background-color:#aaddaa; color:#00000';
        }
        $days = $now->dateDiff($end_date) * $sign;
    }
    $s = '<tr class="second">';
    // edit icon
    $s .= '<td align="center">';
    if ($isProjectManager || $AppUI->user_id == $a['task_owner']) {
        $s .= '<a href="?m=tasks&a=simpleaddedit&task_id=' . $id . '">' . '<img src="images/edit_task.gif" title="' . $AppUI->_('Edit') . '"></a>';
    } else {
        $s .= '<img src="images/noedit_task.gif" title="' . $AppUI->_('No edit') . '">';
    }
    $s .= '</td>';
    // pinned
    if ($a['task_pinned']) {
        $pin_image = 'green.png';
        $pin_text = 'Unpin task';
    } else {
        $pin_image = 'gray.png';
        $pin_text = 'Pin task';
    }
    $s .= '<td align="center">';
    $s .= createIconLink('images/' . $pin_image, 'js:pinTask(this,' . $id . ')', $pin_text);
    $s .= '</td>';
    $mytask = false;
    $members = $a['task_assigned_users'];
    if (!$isProjectManager && isset($members)) {
        foreach ($members as $u) {
            if ($u['user_id'] == $AppUI->user_id) {
                $mytask = true;
                break;
            }
        }
    }
    // New Log
    if ($a['task_log_problem'] > 0) {
        $s .= '<td align="center"><a href="?m=tasks&a=view&task_id=' . $id . '&tab=0&problem=1">';
        $s .= '<img src="images/problem.gif" title="Problem!">';
        $s .= '</a></td>';
    } else {
        if ($isProjectManager || $mytask) {
            $s .= '<td align="center"><a href="?m=tasks&a=view&task_id=' . $id . '&tab=1">';
            $s .= '<img src="images/add_log.gif" title="Add log">';
            $s .= '</a></td>';
        } else {
            $s .= '<td align="center"><a href="?m=tasks&a=view&task_id=' . $id . '&tab=0">' . '<img src="images/log.gif" title="View log">' . '</a></td>';
        }
    }
    // percent complete
    $s .= '<td align="right">' . intval($a['task_percent_complete']) . '%</td>';
    // priority
    $s .= '<td align="center" nowrap="nowrap">';
    if ($a['task_milestone'] > 0) {
        $s .= '<img src="images/milestone.gif" title="Milestone">';
    } else {
        if ($a['task_priority'] < 0) {
            $s .= '<img src="images/icons/priority-' . -$a['task_priority'] . '.gif">';
        } else {
            if ($a['task_priority'] > 0) {
                $s .= '<img src="images/icons/priority+' . $a['task_priority'] . '.gif">';
            }
        }
    }
    $s .= $a['file_count'] > 0 ? '<img src="images/clip.png">' : '';
    $s .= '</td>';
    // dots
    $s .= '<td width="' . ($today_view ? 50 : 90) . '%">';
    for ($y = 0; $y < $level; $y++) {
        if ($y + 1 == $level) {
            $s .= '<img src="images/corner-dots.gif">';
        } else {
            $s .= '<img src="images/blank.gif" width="16" height="12"  border="0">';
        }
    }
    if ($a['task_milestone'] > 0) {
        $task_name = '<b>' . $a['task_name'] . '</b>';
    } else {
        if ($a['task_dynamic'] == '1') {
            if (!$today_view) {
                $s .= $is_opened ? '<a href="index.php' . $query_string . '&close_task_id=' . $id . '">' . '<img src="images/icons/collapse.gif"/></a>' : '<a href="index.php' . $query_string . '&open_task_id=' . $id . '">' . '<img src="images/icons/expand.gif"/></a>';
            }
            $task_name = '<b><i>' . $a['task_name'] . '</i></b>';
        } else {
            $task_name = $a['task_name'];
        }
    }
    $s .= '&nbsp;<a href="javascript:viewTask(' . $id . ')" title="' . $a['task_description'] . '">' . $task_name . '</a></td>';
    // task owner
    if (!$today_view) {
        $s .= '<td align="center"><a href="javascript:User(' . $a['user_id'] . ').show()">' . $a['user_username'] . '</a></td>';
    }
    if (isset($members)) {
        $tmp = array();
        $s .= '<td align="center" nowrap="nowrap">';
        if ($show_all_assignees) {
            foreach ($members as $u) {
                $tmp[] = '<a href="javascript:User(' . $u['user_id'] . ').show()">' . $u['user_username'] . ' (' . $u['perc_assignment'] . '%)</a>';
            }
            $s .= join(', ', $tmp);
        } else {
            $u = array_shift($members);
            $s .= '<a href="javascript:User(' . $u['user_id'] . ').show()">';
            $s .= $u['user_username'] . ' (' . $u['perc_assignment'] . '%)</a>';
            if ($a['assignee_count'] > 1) {
                foreach ($members as $u) {
                    $tmp[] = $u['user_username'] . ' [' . $u['perc_assignment'] . '%]';
                }
                $sid = "'users_" . $id . "'";
                $s .= '&nbsp;<a href="#" onclick="Control(' . $sid . ').toggle()" title="' . join(",\n", $tmp) . '">' . '(+' . ($a['assignee_count'] - 1) . ')</a>';
                $s .= '<span id=' . $sid . '" style="display: none">';
                foreach ($members as $u) {
                    $s .= '<br/><a href="javascript:User(' . $u['user_id'] . ').show()">';
                    $s .= $u['user_username'] . ' (' . $u['perc_assignment'] . '%)</a>';
                }
                $s .= '</span>';
            }
        }
        $s .= '</td>';
    } else {
        if (!$today_view) {
            // No users asigned to task
            $s .= '<td align="center">-</td>';
        }
    }
    // duration or milestone
    $duration = intval($a['task_duration']) / intval($dPconfig['daily_working_hours']);
    if ($duration < 3) {
        $duration = $a['task_duration'] . $AppUI->_('h');
        $alt = '';
    } else {
        $duration = ceil($duration) . $AppUI->_('d');
        $alt = ' title="' . $a['task_duration'] . $AppUI->_('h') . '"';
    }
    $s .= '<td align="right" style="' . $style . '; padding-right: 16px"' . $alt . '>' . $duration . '</td>';
    $df = $AppUI->getPref('SHDATEFORMAT') . ' ' . $AppUI->getPref('TIMEFORMAT');
    $s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . ($start_date ? $start_date->format($df) : '-') . '</td>';
    $s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . ($end_date ? $end_date->format($df) : '-') . '</td>';
    if ($today_view) {
        $s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . $a['task_due_in'] . '</td>';
    }
    echo $s;
}
Ejemplo n.º 14
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;
            }
        }
    }
}