Esempio n. 1
0
 public static function get_list($_FORM)
 {
     $current_user =& singleton("current_user");
     /*
      * This is the definitive method of getting a list of tasks that need a sophisticated level of filtering
      *
      */
     list($filter, $having) = task::get_list_filter($_FORM);
     $debug = $_FORM["debug"];
     $debug and print "\n<pre>_FORM: " . print_r($_FORM, 1) . "</pre>";
     $debug and print "\n<pre>filter: " . print_r($filter, 1) . "</pre>";
     $_FORM["taskView"] or $_FORM["taskView"] = 'prioritised';
     // Zero is a valid limit
     if ($_FORM["limit"] || $_FORM["limit"] === 0 || $_FORM["limit"] === "0") {
         $limit = prepare("limit %d", $_FORM["limit"]);
     }
     $_FORM["return"] or $_FORM["return"] = "html";
     $_FORM["people_cache"] =& get_cached_table("person");
     $_FORM["timeUnit_cache"] =& get_cached_table("timeUnit");
     $_FORM["taskType_cache"] =& get_cached_table("taskType");
     if ($_FORM["taskView"] == "prioritised") {
         unset($filter["parentTaskID"]);
         $order_limit = " " . $limit;
     } else {
         $order_limit = " ORDER BY projectName,taskName " . $limit;
     }
     // Get a hierarchical list of tasks
     if (is_array($filter) && count($filter)) {
         $f = " WHERE " . implode(" AND ", $filter);
     }
     $uid = sprintf("%d", $current_user->get_id());
     $spread = sprintf("%d", config::get_config_item("taskPrioritySpread"));
     $scale = sprintf("%d", config::get_config_item("taskPriorityScale"));
     $scale_halved = sprintf("%d", config::get_config_item("taskPriorityScale") / 2);
     $q = "SELECT task.*\n                ,projectName\n                ,projectShortName\n                ,clientID\n                ,projectPriority\n                ,project.currencyTypeID as currency\n                ,rate\n                ,rateUnitID\n                ,GROUP_CONCAT(pendingTask.pendingTaskID) as pendingTaskIDs\n                ,GROUP_CONCAT(DISTINCT alltag.name SEPARATOR ', ') as tags\n            FROM task\n       LEFT JOIN project ON project.projectID = task.projectID\n       LEFT JOIN projectPerson ON project.projectID = projectPerson.projectID AND projectPerson.personID = '" . $uid . "'\n       LEFT JOIN pendingTask ON pendingTask.taskID = task.taskID\n       LEFT JOIN tag alltag ON alltag.taskID = task.taskID\n       LEFT JOIN tag seltag ON seltag.taskID = task.taskID\n                 " . $f . "\n        GROUP BY task.taskID\n                 " . $having . "\n                 " . $order_limit;
     $debug and print "\n<br>QUERY: " . $q;
     $_FORM["debug"] and print "\n<br>QUERY: " . $q;
     $db = new db_alloc();
     $db->query($q);
     while ($row = $db->next_record()) {
         $task = new task();
         $task->read_db_record($db);
         $row["taskURL"] = $task->get_url();
         $row["taskName"] = $task->get_name($_FORM);
         $row["taskLink"] = $task->get_task_link($_FORM);
         $row["project_name"] = $row["projectShortName"] or $row["project_name"] = $row["projectName"];
         $row["projectPriority"] = $db->f("projectPriority");
         has("project") and $row["projectPriorityLabel"] = project::get_priority_label($db->f("projectPriority"));
         has("project") and list($row["priorityFactor"], $row["daysUntilDue"]) = $task->get_overall_priority($row["projectPriority"], $row["priority"], $row["dateTargetCompletion"]);
         $row["taskTypeImage"] = $task->get_task_image();
         $row["taskTypeSeq"] = $_FORM["taskType_cache"][$row["taskTypeID"]]["taskTypeSeq"];
         $row["taskStatusLabel"] = $task->get_task_status("label");
         $row["taskStatusColour"] = $task->get_task_status("colour");
         $row["creator_name"] = $_FORM["people_cache"][$row["creatorID"]]["name"];
         $row["manager_name"] = $_FORM["people_cache"][$row["managerID"]]["name"];
         $row["assignee_name"] = $_FORM["people_cache"][$row["personID"]]["name"];
         $row["closer_name"] = $_FORM["people_cache"][$row["closerID"]]["name"];
         $row["estimator_name"] = $_FORM["people_cache"][$row["estimatorID"]]["name"];
         $row["creator_username"] = $_FORM["people_cache"][$row["creatorID"]]["username"];
         $row["manager_username"] = $_FORM["people_cache"][$row["managerID"]]["username"];
         $row["assignee_username"] = $_FORM["people_cache"][$row["personID"]]["username"];
         $row["closer_username"] = $_FORM["people_cache"][$row["closerID"]]["username"];
         $row["estimator_username"] = $_FORM["people_cache"][$row["estimatorID"]]["username"];
         $row["newSubTask"] = $task->get_new_subtask_link();
         $_FORM["showPercent"] and $row["percentComplete"] = $task->get_percentComplete();
         $_FORM["showTimes"] and $row["timeActual"] = $task->get_time_billed() / 60 / 60;
         $row["rate"] = page::money($row["currency"], $row["rate"], "%mo");
         $row["rateUnit"] = $_FORM["timeUnit_cache"][$row["rateUnitID"]]["timeUnitName"];
         $row["priorityLabel"] = $task->get_priority_label();
         if (!$_FORM["skipObject"]) {
             $_FORM["return"] == "array" and $row["object"] = $task;
         }
         $row["padding"] = $_FORM["padding"];
         $row["taskID"] = $task->get_id();
         $row["parentTaskID"] = $task->get_value("parentTaskID");
         $row["parentTaskID_link"] = "<a href='" . $task->get_url(false, $task->get_value("parentTaskID")) . "'>" . $task->get_value("parentTaskID") . "</a>";
         $row["timeLimitLabel"] = $row["timeBestLabel"] = $row["timeWorstLabel"] = $row["timeExpectedLabel"] = $row["timeActualLabel"] = "";
         $row["timeLimit"] !== NULL and $row["timeLimitLabel"] = seconds_to_display_format($row["timeLimit"] * 60 * 60);
         $row["timeBest"] !== NULL and $row["timeBestLabel"] = seconds_to_display_format($row["timeBest"] * 60 * 60);
         $row["timeWorst"] !== NULL and $row["timeWorstLabel"] = seconds_to_display_format($row["timeWorst"] * 60 * 60);
         $row["timeExpected"] !== NULL and $row["timeExpectedLabel"] = seconds_to_display_format($row["timeExpected"] * 60 * 60);
         $row["timeActual"] !== NULL and $row["timeActualLabel"] = seconds_to_display_format($row["timeActual"] * 60 * 60);
         if ($_FORM["showComments"] && ($comments = comment::util_get_comments("task", $row["taskID"]))) {
             $row["comments"] = $comments;
         }
         if ($_FORM["taskView"] == "byProject") {
             $rows[$task->get_id()] = array("parentTaskID" => $row["parentTaskID"], "row" => $row);
         } else {
             if ($_FORM["taskView"] == "prioritised") {
                 $rows[$row["taskID"]] = $row;
                 if (is_array($rows) && count($rows)) {
                     uasort($rows, array("task", "priority_compare"));
                 }
             }
         }
     }
     if ($_FORM["taskView"] == "byProject") {
         $parentTaskID = $_FORM["parentTaskID"] or $parentTaskID = 0;
         $t = task::get_recursive_child_tasks($parentTaskID, (array) $rows);
         list($tasks, $done) = task::build_recursive_task_list($t, $_FORM);
         // This bit appends the orphan tasks onto the end..
         foreach ((array) $rows as $taskID => $r) {
             $row = $r["row"];
             $row["padding"] = 0;
             if (!$done[$taskID]) {
                 $tasks += array($taskID => $row);
             }
         }
     } else {
         if ($_FORM["taskView"] == "prioritised") {
             $tasks =& $rows;
         }
     }
     return (array) $tasks;
 }
Esempio n. 2
0
        $TPL["message_help_no_esc"][] = 'This task is set to
                                    <a href="' . $TPL["url_alloc_reminder"] . 'step=3&reminderID=' . $r["rID"] . '&returnToParent=task">
				    automatically reopen at ' . $r["reminderTime"] . '</a>';
        // Which date gets plugged in is arbitrary, but it would be unusual for there to be more than one
        $TPL['reopen_task'] = strftime("%Y-%m-%d", strtotime($r['reminderTime']));
    }
}
if ($task->get_id()) {
    $TPL["task_taskType"] = $task->get_value("taskTypeID");
} else {
    $TPL["task_children_summary"] = "";
    $TPL["task_taskType"] = "Task";
}
if ($taskID) {
    $TPL["taskTypeImage"] = $task->get_task_image();
    $TPL["taskSelfLink"] = "<a href=\"" . $task->get_url() . "\">" . $task->get_id() . " " . $task->get_name(array("return" => "html")) . "</a>";
    $TPL["main_alloc_title"] = "Task " . $task->get_id() . ": " . $task->get_name() . " - " . APPLICATION_NAME;
    $TPL["task_exists"] = true;
    $q = prepare("SELECT GROUP_CONCAT(pendingTaskID) as pendingTaskIDs FROM pendingTask WHERE taskID = %d", $task->get_id());
    $db->query($q);
    $row = $db->row();
    $TPL["task_pendingTaskIDs"] = $row["pendingTaskIDs"];
    $TPL["task_tags"] = implode(", ", $task->get_tags());
} else {
    $TPL["taskSelfLink"] = "New Task";
    $TPL["main_alloc_title"] = "New Task - " . APPLICATION_NAME;
}
$TPL["tagOptions"] = page::select_options($task->get_tags(true), $task->get_tags(), 300);
if (!$task->get_id()) {
    $TPL["message_help"][] = "Enter a Task Name and click the Save button to create a new Task.";
    $TPL["task_dateTargetStart"] or $TPL["task_dateTargetStart"] = date("Y-m-d");
Esempio n. 3
0
function import_planner_tasks($parentNode, $parentTaskId, $depth, $task_allocation, $resource_people, $project_manager_ID)
{
    //Recursively imports tasks from GNOME Planner, given the parentNode.
    global $projectID;
    $current_user =& singleton("current_user");
    $result = array();
    // our dodgy DOM_NodeList doesn't support foreach....
    for ($i = 0; $i < $parentNode->childNodes->length; $i++) {
        $taskXML = $parentNode->childNodes->item($i);
        if ($taskXML->nodeType == XML_ELEMENT_NODE && $taskXML->tagName == "task") {
            $task = new task();
            $task->set_value('taskName', trim($taskXML->getAttribute("name")));
            $task->set_value('projectID', $projectID);
            // We can find the task assignee's id in the $task_allocation array, and that person's Person record in the $resource_people array
            $planner_taskid = $taskXML->getAttribute("id");
            // Dates we guess at (i.e., set to now)
            $task->set_value('dateCreated', date("Y-m-d H:i:s"));
            $task->set_value('dateAssigned', date("Y-m-d H:i:s"));
            if ($taskXML->hasAttribute("work-start")) {
                $task->set_value('dateTargetStart', import_planner_date($taskXML->getAttribute("work-start")));
            } else {
                $task->set_value('dateTargetStart', import_planner_date($taskXML->getAttribute("start")));
                $result[] = "Resorting to work value for " . $task->get_value('taskName');
            }
            $task->set_value('dateTargetCompletion', import_planner_date($taskXML->getAttribute("end")));
            if ($taskXML->hasAttribute("note")) {
                $task->set_value('taskDescription', $taskXML->getAttribute("note"));
            }
            $task->set_value('creatorID', $current_user->get_id());
            $task->set_value('managerID', $project_manager_ID);
            if ($taskXML->hasAttribute("type") and $taskXML->getAttribute("type") == "milestone") {
                $task->set_value('taskTypeID', 'Milestone');
            } else {
                $task->set_value('taskTypeID', 'Task');
            }
            $task->set_value('taskStatus', 'open_notstarted');
            $task->set_value('priority', '3');
            $task->set_value('parentTaskID', $parentTaskId == 0 ? "" : $parentTaskId);
            // The following fields we leave at their default values: duplicateTaskID, dateActualCompletion, dateActualStart, closerID, timeExpected, dateClosed, parentTaskID, taskModifiedUser
            // Handle task assignment
            if (isset($task_allocation[$planner_taskid])) {
                if (is_array($task_allocation[$planner_taskid])) {
                    // This task was assigned to more than one person. Assign it to the project manager and make a comment about it.
                    $task->set_value('personID', $project_manager_ID);
                    // Save the task so we have a task ID
                    $task->save();
                    // Make a comment about this task
                    $comment = new comment();
                    $comment->set_value("commentType", "task");
                    $comment->set_value("commentLinkID", $task->get_id());
                    $comment->set_value("commentCreatedTime", date("Y-m-d H:i:s"));
                    // The user doing the import is (implicitly) the user creating the comment
                    $comment->set_value("commentCreatedUser", $current_user->get_id());
                    // Get the relevant usernames
                    $names = array();
                    foreach ($task_allocation[$planner_taskid] as $assignee) {
                        $names[] = person::get_fullname($assignee);
                    }
                    $comment->set_value("comment", "Import notice: This task was originally assigned to " . implode($names, ', ') . ".");
                    $comment->save();
                    $result[] = sprintf("<li>Note: multiple people were assigned to the task %d %s</li>", $task->get_id(), $task->get_value("taskName"));
                } else {
                    $task->set_value('personID', $resource_people[$task_allocation[$taskXML->getAttribute("id")]]->get_id());
                }
            } else {
                // Task not assigned to anyone, assign the task to the nominated manager
                $task->set_value('personID', $project_manager_ID);
            }
            $task->save();
            $result[] = sprintf('<li>%sCreated task <a href="%s">%d %s</a>.</li>', str_repeat("&gt;", $depth), $task->get_url(), $task->get_id(), $task->get_value('taskName'));
            // Do child nodes
            if ($taskXML->hasChildNodes()) {
                $result = array_merge($result, import_planner_tasks($taskXML, $task->get_id(), $depth + 1, $task_allocation, $resource_people, $project_manager_ID));
            }
        }
    }
    return $result;
}