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&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>\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>\n\t</td>"; // New Log $s .= "\n\t" . '<td align="center">'; if ($canViewLog && $a['task_dynamic'] != 1) { $s .= '<a href="?m=tasks&a=view&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&a=view&task_id=' . $a['task_id'] . '&tab=0&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('"', '"', $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 .= ' <a href="./index.php?m=tasks&a=view&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 .= ' <a href="./index.php?m=tasks&a=view&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 .= ' <a href="./index.php?m=tasks&a=view&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&a=view&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&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>'); */ $a_u_tmp_array[] = '<a href="?m=admin&a=viewuser&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&a=viewuser&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&a=viewuser&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; }
// Closing and opening tasks only applies to dynamic tasks or tasks with children $open_task_id = dPGetParam($_GET, 'open_task_id', 0); $close_task_id = dPGetParam($_GET, 'close_task_id', 0); if ($open_task_all) { $tasks_opened = array_unique($tasks_closed); $tasks_closed = array(); } else { if ($close_task_all) { $tasks_closed = array_unique(array_merge($tasks_closed, $tasks_opened)); $tasks_opened = array(); } else { if ($open_task_id) { openClosedTask($open_task_id); } else { if ($close_task_id) { closeOpenedTask($close_task_id); } } } } $durnTypes = dPgetSysVal('TaskDurationType'); $taskPriority = dPgetSysVal('TaskPriority'); $task_project = intval(dPgetParam($_GET, 'task_project', null)); $task_sort_item1 = dPgetParam($_GET, 'task_sort_item1', ''); $task_sort_type1 = dPgetParam($_GET, 'task_sort_type1', 0); $task_sort_order1 = intval(dPgetParam($_GET, 'task_sort_order1', 0)); $task_sort_item2 = dPgetParam($_GET, 'task_sort_item2', ''); $task_sort_type2 = dPgetParam($_GET, 'task_sort_type2', 0); $task_sort_order2 = intval(dPgetParam($_GET, 'task_sort_order2', 0)); if (isset($_POST['show_task_options'])) { $AppUI->setState('TaskListShowIncomplete', dPgetParam($_POST, 'show_incomplete', 0));
** are shown in the 'inactive view'; their parents are for instance not listed with them. */ if ($t["task_parent"] == $t["task_id"] || $p['tasks'][$i]["task_status"] != 0) { $is_opened = in_array($t["task_id"], $tasks_opened); showtask($t, 0, $is_opened, '', $_GET["impr"]); if ($is_opened || !$t["task_dynamic"]) { findchild($p['tasks'], $t["task_id"]); } } // else showtask( $t, 0, $is_opened ); } // check that any 'orphaned' user tasks are also display for ($i = 0; $i < $tnums; $i++) { if (!in_array($p['tasks'][$i]["task_id"], $done)) { if ($p['tasks'][$i]["task_dynamic"] && in_array($p['tasks'][$i]["task_parent"], $tasks_closed)) { closeOpenedTask($p['tasks'][$i]["task_id"]); } if (in_array($p['tasks'][$i]["task_parent"], $tasks_opened)) { showtask($p['tasks'][$i], 1, false, '', $_GET["impr"]); } } } if ($tnums && $dPconfig['enable_gantt_charts'] && !$min_view) { ?> <?php if ($_GET["impr"] != 1) { ?> <tr> <td colspan="<?php echo $cols; ?>
if ($t['task_parent'] == $t['task_id']) { $is_opened = $open_task_all || in_array($t['task_id'], $tasks_opened); showtask($t, 0, $is_opened); if ($is_opened || $t['task_dynamic'] == 0) { findchild($p['tasks'], $t['task_id']); } } if ($search_text && (strpos($t['task_name'], $search_text) !== false || strpos($t['task_description'], $search_text) !== false)) { showtask($t, 1, false); } } // check that any 'orphaned' user tasks are also display for ($i = 0; $i < $tnums; $i++) { if (!in_array($p['tasks'][$i]['task_id'], $done)) { if ($p['tasks'][$i]['task_dynamic'] && in_array($p['tasks'][$i]['task_parent'], $tasks_closed)) { closeOpenedTask($p['tasks'][$i]['task_id']); } if (in_array($p['tasks'][$i]['task_parent'], $tasks_opened)) { showtask($p['tasks'][$i], 1, false); } } } if ($tnums && $dPconfig['enable_gantt_charts'] && !$min_view) { ?> <tr> <td colspan="11" align="right"> <?php if ($p['project_owner'] == $AppUI->user_id || $AppUI->user_type <= 5) { showButton($AppUI->_('Reports'), 'index.php?m=projects&a=reports&project_id=' . $k); } showButton($AppUI->_('Gantt chart'), 'index.php?m=tasks&a=viewgantt&project_id=' . $k);