/**
  * @todo Parent store could be partially used
  * @todo Can't delete a task with children
  */
 function delete()
 {
     if (!$this->task_id) {
         return 'invalid task id';
     }
     $q = new DBQuery();
     if (dPgetConfig('check_task_empty_dynamic') && $this->task_parent != $this->task_id) {
         //Check that we are not deleting the only child of a dynamic parent task
         $task_test = new CTask();
         $task_test->load($this->task_parent);
         $siblings = $task_test->getChildren();
         if ($task_test->task_dynamic == 1 && count($siblings) <= 1) {
             return 'BadDyn_NoChild';
         }
     }
     //load task first because we need info on it to update the parent tasks later
     $task = new CTask();
     $task->load($this->task_id);
     //get child tasks so we can delete them too (no orphans)
     $childrenlist = $task->getDeepChildren();
     //delete task (if we're actually allowed to delete this task)
     $err_msg = parent::delete($task->task_id, $task->task_name, $task->task_project);
     if ($err_msg) {
         return $err_msg;
     }
     $this->_action = 'deleted';
     if ($task->task_parent != $task->task_id) {
         //Has parent, run the update sequence, this child will no longer be in the database
         $this->updateDynamics();
     }
     $q->clear();
     //delete children
     if (!empty($childrenlist)) {
         foreach ($childrenlist as $child_id) {
             $ctask = new CTask();
             $ctask->load($child_id);
             //ignore permissions on child tasks by deleteing task directly from the database
             $q->setDelete('tasks');
             $q->addWhere('task_id=' . $ctask->task_id);
             if (!$q->exec()) {
                 return db_error();
             }
             $q->clear();
             addHistory('tasks', $ctask->task_id, 'delete', $ctask->task_name, $ctask->task_project);
             $this->updateDynamics();
             //to update after children are deleted (see above)
         }
         $this->_action = 'deleted with children';
     }
     //delete affiliated task_logs (overrides any task_log permissions)
     $q->setDelete('task_log');
     if (!empty($childrenlist)) {
         $q->addWhere('task_log_task IN (' . implode(', ', $childrenlist) . ', ' . $this->task_id . ')');
     } else {
         $q->addWhere('task_log_task=' . $this->task_id);
     }
     if (!$q->exec()) {
         return db_error();
     }
     $q->clear();
     //delete affiliated task_dependencies
     $q->setDelete('task_dependencies');
     if (!empty($childrenlist)) {
         $q->addWhere('dependencies_task_id IN (' . implode(', ', $childrenlist) . ', ' . $task->task_id . ')');
     } else {
         $q->addWhere('dependencies_task_id=' . $task->task_id);
     }
     if (!$q->exec()) {
         return db_error();
     }
     $q->clear();
     // delete linked user tasks
     $q->setDelete('user_tasks');
     if (!empty($childrenlist)) {
         $q->addWhere('task_id IN (' . implode(', ', $childrenlist) . ', ' . $task->task_id . ')');
     } else {
         $q->addWhere('task_id=' . $task->task_id);
     }
     if (!$q->exec()) {
         return db_error();
     }
     $q->clear();
     return NULL;
 }
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 w2p_Utilities_Date();
    $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 w2p_Utilities_Date($AppUI->formatTZAwareTime($a['task_start_date'], '%Y-%m-%d %T')) : null;
    $end_date = intval($a['task_end_date']) ? new w2p_Utilities_Date($AppUI->formatTZAwareTime($a['task_end_date'], '%Y-%m-%d %T')) : null;
    $last_update = isset($a['last_update']) && intval($a['last_update']) ? new w2p_Utilities_Date($AppUI->formatTZAwareTime($a['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 = new w2p_Utilities_Date('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;
    }
    $jsTaskId = 'task_proj_' . $a['task_project'] . '_level-' . $level . '-task_' . $a['task_id'] . '_';
    if ($expanded) {
        $s = '<tr id="' . $jsTaskId . '" onmouseover="highlight_tds(this, true, ' . $a['task_id'] . ')" onmouseout="highlight_tds(this, false, ' . $a['task_id'] . ')" onclick="select_box(\'selected_task\', \'' . $a['task_id'] . '\', \'' . $jsTaskId . '\',\'frm_tasks\')">';
        // edit icon
    } else {
        $s = '<tr id="' . $jsTaskId . '" onmouseover="highlight_tds(this, true, ' . $a['task_id'] . ')" onmouseout="highlight_tds(this, false, ' . $a['task_id'] . ')" onclick="select_box(\'selected_task\', \'' . $a['task_id'] . '\', \'' . $jsTaskId . '\',\'frm_tasks\')" ' . ($level ? 'style="display:none"' : '') . '>';
        // edit icon
    }
    $s .= '<td>';
    $canEdit = $a['task_represents_project'] ? false : true;
    $canViewLog = true;
    if ($canEdit) {
        $s .= '<a href="?m=tasks&a=addedit&task_id=' . $a['task_id'] . '">' . w2PtoolTip('edit tasks panel', 'click to edit this task') . w2PshowImage('icons/pencil.gif', 12, 12) . w2PendTip() . '</a>';
    }
    $s .= '</td>';
    // percent complete
    $s .= '<td align="right">' . (int) $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" alt="" />';
    } elseif ($a['task_priority'] > 0) {
        $s .= '<img src="' . w2PfindImage('icons/priority+' . $a['task_priority'] . '.gif') . '" width="13" height="16" alt="" />';
    }
    $s .= '</td><td align="center" nowrap="nowrap">';
    if ($a['user_task_priority'] < 0) {
        $s .= '<img src="' . w2PfindImage('icons/priority-' . -$a['user_task_priority'] . '.gif') . '" alt="" />';
    } elseif ($a['user_task_priority'] > 0) {
        $s .= '<img src="' . w2PfindImage('icons/priority+' . $a['user_task_priority'] . '.gif') . '" alt="" />';
    }
    $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 && 0 == $a['task_represents_project']) {
        $s .= '<a href="?m=tasks&a=view&tab=1&project_id=' . $a['task_project'] . '&task_id=' . $a['task_id'] . '">' . w2PtoolTip('tasks', 'add work log to this task') . w2PshowImage('edit_add.png') . w2PendTip() . '</a>';
    }
    $s .= '</td>';
    // dots
    if ($today_view) {
        $s .= '<td>';
    } else {
        $s .= '<td width="20%">';
    }
    for ($y = 0; $y < $level; $y++) {
        if ($y + 1 == $level) {
            $image = w2PfindImage('corner-dots.gif', $m);
        } else {
            $image = w2PfindImage('shim.gif', $m);
        }
        $s .= '<img src="' . $image . '" width="16" height="12"  border="0" alt="" />';
    }
    // name link
    if ($a['task_description']) {
        $s .= w2PtoolTip('Task Description', $a['task_description'], true);
    }
    $jsTaskId = 'task_proj_' . $a['task_project'] . '_level-' . $level . '-task_' . $a['task_id'] . '_';
    $open_link = '<a href="javascript: void(0);"><img onclick="expand_collapse(\'' . $jsTaskId . '\', \'tblProjects\',\'\',' . ($level + 1) . ');" id="' . $jsTaskId . '_collapse" src="' . w2PfindImage('icons/collapse.gif', $m) . '" 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', $m) . '" border="0" align="center" ' . ($expanded ? 'style="display:none"' : '') . ' alt="" /></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" alt="" /></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 && 0 == $a['task_represents_project']) {
        $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>';
    return $s;
}
Example #3
0
 function check()
 {
     global $AppUI;
     if ($this->task_id === NULL) {
         return 'task id is NULL';
     }
     // ensure changes to checkboxes are honoured
     $this->task_milestone = intval($this->task_milestone);
     $this->task_dynamic = intval($this->task_dynamic);
     $this->task_percent_complete = intval($this->task_percent_complete);
     if ($this->task_milestone) {
         $this->task_duration = '0';
     } else {
         if (!$this->task_duration) {
             $this->task_duration = '1';
         }
     }
     if (!$this->task_creator) {
         $this->task_creator = $AppUI->user_id;
     }
     if (!$this->task_duration_type) {
         $this->task_duration_type = 1;
     }
     if (!$this->task_related_url) {
         $this->task_related_url = '';
     }
     if (!$this->task_notify) {
         $this->task_notify = 0;
     }
     /*
      * Check for bad or circular task relationships (dep or child-parent).
      * These checks are definately not exhaustive it is still quite possible
      * to get things in a knot.
      * Note: some of these checks may be problematic and might have to be removed
      */
     static $addedit;
     if (!isset($addedit)) {
         $addedit = dPgetParam($_POST, 'dosql', '') == 'do_task_aed' ? true : false;
     }
     $this_dependencies = array();
     /*
      * If we are called from addedit then we want to use the incoming
      * list of dependencies and attempt to stop bad deps from being created
      */
     if ($addedit) {
         $hdependencies = dPgetParam($_POST, 'hdependencies', '0');
         if ($hdependencies) {
             $this_dependencies = explode(',', $hdependencies);
         }
     } else {
         $this_dependencies = explode(',', $this->getDependencies());
     }
     // Set to false for recursive updateDynamic calls etc.
     $addedit = false;
     // Has a parent
     if ($this->task_id && $this->task_id != $this->task_parent) {
         $this_children = $this->getChildren();
         $this_child_deps = array();
         foreach ($this_children as $child) {
             $child_dep_str = $this->staticGetDependencies($child);
             $this_child_deps = array_unique(array_merge($this_child_deps, explode(',', $child_dep_str)));
         }
         $current_task = $this;
         $parents_children = array();
         //itrative walk through parent tasks
         while ($current_task->task_id != $current_task->task_parent) {
             $current_parent = new CTask();
             $current_parent->load($current_task->task_parent);
             $parents_children = array_unique(array_merge($parents_children, $current_parent->getChildren()));
             // Task parent (of any level) cannot be a child of task or its children
             // extra precaution against any UI bugs allowing otherwise
             if (in_array($current_parent->task_id, $parents_children)) {
                 return $this->task_id == $current_parent->task_parent ? 'BadParent_CircularParent' : array('BadParent_CircularGrandParent', '(' . $current_parent->task_id . ')');
             }
             //Task's children cannot have a parent (of any level) as a dependency
             if (in_array($current_parent->task_id, $this_child_deps)) {
                 return 'BadParent_ChildDepOnParent';
             }
             //Task cannot have a parent (of any level) as a dependency
             if (in_array($current_parent->task_id, $this_dependencies)) {
                 return $current_task == $this ? 'BadDep_CannotDependOnParent' : array('BadDep_CircularGrandParent', '(' . $current_parent->task_id . ')');
             }
             $parents_dependents = explode(',', $current_parent->dependentTasks());
             $this_intersect = array_intersect($this_dependencies, $parents_dependents);
             //Any tasks dependent on a dynamic parent task cannot be dependencies of task
             if (array_sum($this_intersect)) {
                 $ids = '(' . implode(',', $intersect) . ')';
                 return array('BadDep_CircularDepOnParentDependent', $ids);
             }
             $current_task = $current_parent;
         }
     }
     // parent
     // Have deps
     if (array_sum($this_dependencies)) {
         if ($this->task_dynamic == 1) {
             return 'BadDep_DynNoDep';
         }
         $this_dependents = $this->task_id ? explode(',', $this->dependentTasks()) : array();
         // Treat parent task, like a dependent
         if ($this->task_id != $this->task_parent) {
             array_push($this_dependents, $this->task_parent);
             $dep_string = $this->dependentTasks($this->task_parent);
             $this_dependents = array_unique(array_merge($this_dependents, explode(',', $dep_string)));
         }
         $more_dependents = array();
         // Treat dependents' parents them like dependents too and pull parent dependents
         foreach ($this_dependents as $dependent) {
             $dependent_task = new CTask();
             $dependent_task->load($dependent);
             if ($dependent_task->task_id != $dependent_task->task_parent) {
                 $current_task = $dependent_task;
                 while ($current_task->task_id != $current_task->task_parent) {
                     $current_parent_id = $current_task->task_parent;
                     array_push($more_dependents, $current_parent_id);
                     $dep_string = $this->dependentTasks($dependent_task->task_parent);
                     $more_dependents = array_unique(array_merge($more_dependents, explode(',', $dep_string)));
                     $current_task = new CTask();
                     $current_task->load($current_parent_id);
                 }
             }
         }
         $this_dependents = array_unique(array_merge($this_dependents, $more_dependents));
         // Task dependencies can not be dependent on this task
         $intersect = array_intersect($this_dependencies, $this_dependents);
         if (array_sum($intersect)) {
             $ids = '(' . implode(',', $intersect) . ')';
             return array('BadDep_CircularDep', $ids);
         }
     }
     //Is dynamic and no child
     if (dPgetConfig('check_task_empty_dynamic') && $this->task_dynamic == 1) {
         $children_of_dynamic = $this->getChildren();
         if (empty($children_of_dynamic)) {
             return 'BadDyn_NoChild';
         }
     }
     return NULL;
 }
Example #4
0
    $tabBox_show = 1;
    if (canView('task_log')) {
        $tabBox->add(W2P_BASE_DIR . '/modules/tasks/vw_logs', 'Task Logs');
    }
    if ($task_log_id == 0) {
        if (canAdd('task_log')) {
            $tabBox->add(W2P_BASE_DIR . '/modules/tasks/vw_log_update', 'Log');
        }
    } elseif (canEdit('task_log')) {
        $tabBox->add(W2P_BASE_DIR . '/modules/tasks/vw_log_update', 'Edit Log');
    } elseif (canAdd('task_log')) {
        $tabBox_show = 1;
        $tabBox->add(W2P_BASE_DIR . '/modules/tasks/vw_log_update', 'Log');
    }
}
if (count($obj->getChildren()) > 0) {
    // Has children
    // settings for tasks
    $f = 'children';
    $min_view = true;
    $tabBox_show = 1;
    // in the tasks file there is an if that checks
    // $_GET[task_status]; this patch is to be able to see
    // child tasks withing an inactive task
    $_GET['task_status'] = $obj->task_status;
    $tabBox->add(W2P_BASE_DIR . '/modules/tasks/tasks', 'Child Tasks');
}
if (count($tabBox->tabs)) {
    $tabBox_show = 1;
}
if ($tabBox_show == 1) {
function showtask_pd_ed(&$arr, $level = 0, $today_view = false)
{
    global $AppUI, $w2Pconfig, $done, $userAlloc, $showEditCheckbox;
    global $task_access, $PROJDESIGN_CONFIG, $m, $expanded;
    $durnTypes = w2PgetSysVal('TaskDurationType');
    //Check for Tasks Access
    $tmpTask = new CTask();
    $tmpTask->load($arr['task_id']);
    $canAccess = $tmpTask->canAccess();
    if (!$canAccess) {
        return false;
    }
    $htmlHelper = new w2p_Output_HTMLHelper($AppUI);
    $htmlHelper->df .= ' ' . $AppUI->getPref('TIMEFORMAT');
    $htmlHelper->stageRowData($arr);
    $types = w2Pgetsysval('TaskType');
    $show_all_assignees = $w2Pconfig['show_all_task_assignees'] ? true : false;
    $done[] = $arr['task_id'];
    // prepare coloured highlight of task time information
    $class = w2pFindTaskComplete($arr['task_start_date'], $arr['task_end_date'], $arr['task_percent_complete']);
    $jsTaskId = 'task_proj_' . $arr['task_project'] . '_level-' . $level . '-task_' . $arr['task_id'] . '_';
    if ($expanded) {
        $s = '<tr id="' . $jsTaskId . '" class="' . $class . '" onclick="select_row(\'selected_task\', \'' . $arr['task_id'] . '\', \'frm_tasks\')">';
        // edit icon
    } else {
        $s = '<tr id="' . $jsTaskId . '" class="' . $class . '" onclick="select_row(\'selected_task\', \'' . $arr['task_id'] . '\', \'frm_tasks\')" ' . ($level ? 'style="display:none"' : '') . '>';
        // edit icon
    }
    $s .= '<td class="data _edit">';
    $canEdit = $arr['task_represents_project'] ? false : true;
    if ($canEdit) {
        $s .= '<a href="?m=tasks&a=addedit&task_id=' . $arr['task_id'] . '">' . w2PshowImage('icons/pencil.gif', 12, 12) . '</a>';
    }
    $s .= '</td>';
    $s .= $htmlHelper->createCell('task_percent_complete', $arr['task_percent_complete']);
    $s .= $htmlHelper->createCell('task_priority', $arr['task_priority']);
    $s .= $htmlHelper->createCell('user_task_priority', $arr['user_task_priority']);
    $s .= $htmlHelper->createCell('other', mb_substr($task_access[$arr['task_access']], 0, 3));
    $s .= $htmlHelper->createCell('other', mb_substr($types[$arr['task_type']], 0, 3));
    // reminders set
    $s .= $htmlHelper->createCell('other', $arr['queue_id'] ? 'Yes' : '');
    $s .= $htmlHelper->createCell('other', $arr['task_status'] == -1 ? 'Yes' : '');
    // add log
    $s .= '<td align="center" nowrap="nowrap">';
    if ($arr['task_dynamic'] != 1 && 0 == $arr['task_represents_project']) {
        $s .= '<a href="?m=tasks&a=view&tab=1&project_id=' . $arr['task_project'] . '&task_id=' . $arr['task_id'] . '">' . w2PtoolTip('tasks', 'add work log to this task') . w2PshowImage('edit_add.png') . w2PendTip() . '</a>';
    }
    $s .= '</td>';
    // dots
    $s .= '<td style="width: ' . ($today_view ? '20%' : '50%') . '" class="data _name">';
    for ($y = 0; $y < $level; $y++) {
        if ($y + 1 == $level) {
            $image = w2PfindImage('corner-dots.gif', $m);
        } else {
            $image = w2PfindImage('shim.gif', $m);
        }
        $s .= '<img src="' . $image . '" width="16" height="12"  border="0" alt="" />';
    }
    // name link
    if ($arr['task_description']) {
        $s .= w2PtoolTip('Task Description', $arr['task_description'], true);
    }
    $jsTaskId = 'task_proj_' . $arr['task_project'] . '_level-' . $level . '-task_' . $arr['task_id'] . '_';
    $open_link = '<a href="javascript: void(0);" onclick="selected_task_' . $arr['task_id'] . '.checked=true"><img onclick="expand_collapse(\'' . $jsTaskId . '\', \'tblProjects\',\'\',' . ($level + 1) . ');" id="' . $jsTaskId . '_collapse" src="' . w2PfindImage('icons/collapse.gif', $m) . '" 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', $m) . '" border="0" align="center" ' . ($expanded ? 'style="display:none"' : '') . ' alt="" /></a>';
    $taskObj = new CTask();
    $taskObj->load($arr['task_id']);
    if (count($taskObj->getChildren())) {
        $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', $m) . '" border="0" alt="" /></td>';
    } elseif ($arr['task_dynamic'] == '1' || $is_parent) {
        $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();
    }
    // task description
    if ($PROJDESIGN_CONFIG['show_task_descriptions']) {
        $s .= '<td align="justified">' . $arr['task_description'] . '</td>';
    }
    // task owner
    $s .= $htmlHelper->createCell('task_owner', $arr['contact_name']);
    $s .= $htmlHelper->createCell('task_start_datetime', $arr['task_start_date']);
    // duration or milestone
    $s .= $htmlHelper->createCell('task_duration', $arr['task_duration'] . ' ' . mb_substr($AppUI->_($durnTypes[$arr['task_duration_type']]), 0, 1));
    $s .= $htmlHelper->createCell('task_end_datetime', $arr['task_end_date']);
    if (isset($arr['task_assigned_users']) && ($assigned_users = $arr['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=users&a=view&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_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=users&a=view&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_name'] . ' (' . $assigned_users[0]['perc_assignment'] . '%)</a>';
            if ($arr['assignee_count'] > 1) {
                $id = $arr['task_id'];
                $s .= '<a href="javascript: void(0);"  onclick="toggle_users(\'users_' . $id . '\');" title="' . join(', ', $a_u_tmp_array) . '">(+' . ($arr['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=users&a=view&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_name'] . ' (' . $assigned_users[$i]['perc_assignment'] . '%)</a>';
                }
                $s .= '</span>';
            }
            $s .= '</td>';
        }
    } else {
        // No users asigned to task
        $s .= '<td class="data">-</td>';
    }
    // Assignment checkbox
    if ($showEditCheckbox && 0 == $arr['task_represents_project']) {
        $s .= '<td class="data"><input type="checkbox" onclick="select_box(\'multi_check\', ' . $arr['task_id'] . ',\'project_' . $arr['task_project'] . '_level-' . $level . '-task_' . $arr['task_id'] . '_\',\'frm_tasks\')" onfocus="is_check=true;" onblur="is_check=false;" id="selected_task_' . $arr['task_id'] . '" name="selected_task" value="' . $arr['task_id'] . '"/></td>';
    }
    $s .= '</tr>';
    return $s;
}
Example #6
0
function closeOpenedTaskRecursive($task_id)
{
    global $tasks_opened;
    global $tasks_closed;
    $tasks_closed = $tasks_closed ? $tasks_closed : array();
    $tasks_opened = $tasks_opened ? $tasks_opened : array();
    $close_task = new CTask();
    if ($task_id > 0) {
        closeOpenedTask($task_id);
        $close_task->peek($task_id);
        $children_to_close = $close_task->getChildren();
        foreach ($children_to_close as $to_close) {
            closeOpenedTaskRecursive($to_close);
        }
    }
}