Exemple #1
0
 public function getAllowedTaskList($AppUI, $task_project = 0)
 {
     $results = array();
     $q = new w2p_Database_Query();
     $q->addQuery('task_id, task_name, task_parent, task_access, task_owner');
     $q->addQuery('task_start_date, task_end_date, task_percent_complete');
     $q->addOrder('task_parent, task_parent = task_id desc');
     $q->addTable('tasks', 't');
     if ($task_project) {
         $q->addWhere('task_project = ' . (int) $task_project);
     }
     if ($orderby == '') {
         $q->addOrder('task_parent, task_parent = task_id desc');
     } else {
         $q->addOrder($orderby);
     }
     $task_list = $q->loadList();
     foreach ($task_list as $task) {
         if (canTaskAccess($task['task_id'], $task['task_access'], $task['task_owner'])) {
             $results[] = $task;
         }
     }
     return $results;
 }
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 w2p_Utilities_Date();
    $tf = $AppUI->getPref('TIMEFORMAT');
    $df = $AppUI->getPref('SHDATEFORMAT');
    $fdf = $df . ' ' . $tf;
    $show_all_assignees = w2PgetConfig('show_all_task_assignees', false);
    $start_date = intval($arr['task_start_date']) ? new w2p_Utilities_Date($AppUI->formatTZAwareTime($arr['task_start_date'], '%Y-%m-%d %T')) : null;
    $end_date = intval($arr['task_end_date']) ? new w2p_Utilities_Date($AppUI->formatTZAwareTime($arr['task_end_date'], '%Y-%m-%d %T')) : null;
    $last_update = isset($arr['last_update']) && intval($arr['last_update']) ? new w2p_Utilities_Date($AppUI->formatTZAwareTime($arr['last_update'], '%Y-%m-%d %T')) : 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 w2p_Utilities_Date('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;
    }
    $jsTaskId = 'project_' . $arr['task_project'] . '_level-' . $level . '-task_' . $arr['task_id'] . '_';
    if ($expanded) {
        $s = '<tr id="' . $jsTaskId . '" >';
    } else {
        $s = '<tr id="' . $jsTaskId . '" ' . ($level > 0 && !($m == 'tasks' && $a == 'view') ? 'style="display:none"' : '') . '>';
    }
    // edit icon
    $s .= '<td align="center">';
    $canEdit = $arr['task_represents_project'] ? false : true;
    $canViewLog = true;
    if ($canEdit) {
        $s .= '<a href="?m=tasks&a=addedit&task_id=' . $arr['task_id'] . '">' . w2PtoolTip('edit task', 'click to edit this task') . w2PshowImage('icons/pencil.gif', 12, 12) . w2PendTip() . '</a>';
    }
    $s .= '</td>';
    // pinned
    $pin_prefix = $arr['task_pinned'] ? '' : 'un';
    $s .= '<td><a href="?m=tasks&amp;pin=' . ($arr['task_pinned'] ? 0 : 1) . '&amp;task_id=' . $arr['task_id'] . '">' . w2PtoolTip('Pin', 'pin/unpin task') . '<img src="' . w2PfindImage('icons/' . $pin_prefix . 'pin.gif') . '" border="0" alt="" />' . w2PendTip() . '</a></td>';
    // New Log
    if ($arr['task_log_problem'] > 0) {
        $s .= '<td valign="middle"><a href="?m=tasks&amp;a=view&amp;task_id=' . $arr['task_id'] . '&amp;tab=0&amp;problem=1">' . w2PshowImage('icons/dialog-warning5.png', 16, 16, 'Problem', 'Problem!') . '</a></td>';
    } elseif ($canViewLog && $arr['task_dynamic'] != 1 && 0 == $arr['task_represents_project']) {
        $s .= '<td align="center"><a href="?m=tasks&amp;a=view&amp;task_id=' . $arr['task_id'] . '&amp;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">' . (int) $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') . '" alt="" />';
    } elseif ($arr['task_priority'] > 0) {
        $s .= '<img src="' . w2PfindImage('icons/priority+' . $arr['task_priority'] . '.gif') . '" alt="" />';
    }
    $s .= '</td><td align="center" nowrap="nowrap">';
    if (isset($arr['user_task_priority'])) {
        if ($arr['user_task_priority'] < 0) {
            $s .= '<img src="' . w2PfindImage('icons/priority-' . -$arr['user_task_priority'] . '.gif') . '" alt="" />';
        } elseif ($arr['user_task_priority'] > 0) {
            $s .= '<img src="' . w2PfindImage('icons/priority+' . $arr['user_task_priority'] . '.gif') . '" alt="" />';
        }
    }
    $s .= '</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" alt="">';
        } else {
            $s .= '';
        }
    }
    if ($arr['task_description']) {
        $s .= w2PtoolTip('Task Description', $arr['task_description'], true);
    }
    $open_link = '<a href="javascript: void(0);"><img onclick="expand_collapse(\'' . $jsTaskId . '\', \'tblProjects\',\'\',' . ($level + 1) . ');" id="' . $jsTaskId . '_collapse" src="' . w2PfindImage('icons/collapse.gif') . '" border="0" align="center" ' . (!$expanded ? 'style="display:none"' : '') . ' alt="" /><img onclick="expand_collapse(\'' . $jsTaskId . '\', \'tblProjects\',\'\',' . ($level + 1) . ');" id="' . $jsTaskId . '_expand" src="' . w2PfindImage('icons/expand.gif') . '" border="0" align="center" ' . ($expanded ? 'style="display:none"' : '') . ' alt="" /></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&amp;a=view&amp;task_id=' . $arr['task_id'] . '" ><b>' . $arr['task_name'] . '</b></a> <img src="' . w2PfindImage('icons/milestone.gif') . '" border="0" alt="" /></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&amp;a=view&amp;task_id=' . $arr['task_id'] . '" ><b><i>' . $arr['task_name'] . '</i></b></a>' . w2PendTip() . '</td>';
        } else {
            $s .= '&nbsp;<a href="./index.php?m=tasks&amp;a=view&amp;task_id=' . $arr['task_id'] . '" >' . $arr['task_name'] . '</a>' . w2PendTip() . '</td>';
        }
    } else {
        $s .= '&nbsp;<a href="./index.php?m=tasks&amp;a=view&amp;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&amp;a=view&amp;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>';
    } else {
        $s .= '<td nowrap="nowrap" align="center">' . '<a href="?m=admin&amp;a=viewuser&amp;user_id=' . $arr['user_id'] . '">' . $arr['owner'] . '</a>' . '</td>';
    }
    if (count($arr['task_assigned_users'])) {
        $assigned_users = $arr['task_assigned_users'];
        $a_u_tmp_array = array();
        if ($show_all_assignees) {
            $s .= '<td align="center" nowrap="nowrap">';
            foreach ($assigned_users as $val) {
                $a_u_tmp_array[] = '<a href="?m=admin&amp;a=viewuser&amp;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(', <br />', $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="' . (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&amp;a=viewuser&amp;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>';
    $s .= '<td align="right" nowrap="nowrap" style="' . $style . '">' . $arr['task_duration'] . ' ' . mb_substr($AppUI->_($durnTypes[$arr['task_duration_type']]), 0, 1) . '</td>';
    $s .= '<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>' . "\n";
    return $s;
}
Exemple #3
0
 public function getAllowedTaskList($AppUI, $task_project = 0)
 {
     $q = new DBQuery();
     $q->addQuery('task_id, task_name, task_parent, task_access, task_owner');
     $q->addOrder('task_parent, task_parent = task_id desc');
     $q->addTable('tasks', 't');
     if ($task_project) {
         $q->addWhere('task_project = ' . (int) $task_project);
     }
     $task_list = $q->loadList();
     foreach ($task_list as $task) {
         if (canTaskAccess($task['task_id'], $task['task_access'], $task['task_owner'])) {
             $results[] = $task;
         }
     }
     return $results;
 }
Exemple #4
0
if ($hide_task_groups) {
    for ($i = 0, $i_cmp = count($gantt_arr); $i < $i_cmp; $i++) {
        // remove task groups
        if ($i != count($gantt_arr) - 1 && $gantt_arr[$i + 1][1] > $gantt_arr[$i][1]) {
            // it's not a leaf => remove
            array_splice($gantt_arr, $i, 1);
            continue;
        }
    }
}
$gantt->loadTaskArray($gantt_arr);
$row = 0;
for ($i = 0, $i_cmp = count($gantt_arr); $i < $i_cmp; $i++) {
    $a = $gantt_arr[$i][0];
    $level = $gantt_arr[$i][1];
    $canAccess = canTaskAccess($a['task_id'], $a['task_access'], $a['task_owner']);
    if ($canAccess) {
        if ($hide_task_groups) {
            $level = 0;
        }
        $name = $a['task_name'];
        $name = mb_strlen($name) > 35 ? mb_substr($name, 0, 30) . '...' : $name;
        $name = str_repeat(' ', $level) . $name;
        $pname = $a['project_name'];
        $pname = mb_strlen($pname) > 25 ? mb_substr($pname, 0, 20) . '...' : $pname;
        //using new jpGraph determines using Date object instead of string
        $start = (int) $a['task_start_date'] ? new w2p_Utilities_Date($AppUI->formatTZAwareTime($a['task_start_date'], '%Y-%m-%d %T')) : new w2p_Utilities_Date();
        $start = $start->getDate();
        $end = (int) $a['task_end_date'] ? new w2p_Utilities_Date($AppUI->formatTZAwareTime($a['task_end_date'], '%Y-%m-%d %T')) : new w2p_Utilities_Date();
        $end = $end->getDate();
        $progress = (int) $a['task_percent_complete'];