protected function getChildDataIssue($issue, $options = null) { $data = array(); switch ($options) { case 'tasks': $items = $this->itemLinkService->getLinkedItemsOfType($issue, 'from', 'Task', array('task.complete=' => 0)); foreach ($items as $child) { $item = new stdClass(); $item->id = get_class($child) . '-' . $child->id . ''; ob_start(); $this->view->percentageBar($child->getPercentage()); $bar = ob_get_clean(); $item->text = $bar . $child->title . ' <a href="' . build_url('task', 'edit', array('id' => $child->id)) . '"><img src="' . resource('images/bullet_go.png') . '" /></a>'; $item->expanded = false; $item->classes = "tree-task iconed"; $item->hasChildren = false; $data[] = $item; } break; break; default: break; } return $data; }
/** * Prepare a feature to be edited * * @param Feature $model * @return */ public function prepareForEdit($model) { $project = $this->projectService->getProject((int) $this->_getParam('projectid', $model->projectid)); $parentFeature = $this->projectService->getFeature((int) $this->_getParam('parent')); if ($project == null) { $this->flash("Specified project not found"); $this->renderView('error.php'); return; } $this->view->project = $project; if ($parentFeature) { $this->view->parentfeature = $parentFeature->id; } if ($model->id) { $this->view->linkedToFeatures = $this->itemLinkService->getLinkedItems($model, 'from', 'Feature'); $this->view->linkedFromFeatures = $this->itemLinkService->getLinkedItems($model, 'to', 'Feature'); } else { $model->milestone = $this->_getParam('milestone'); } $this->view->projects = $this->projectService->getProjectsForClient($project->clientid); $this->view->projectFeatures = $this->featureService->getFeatures(array('projectid=' => $project->id)); $this->view->projectTasks = $this->projectService->getTasks(array('projectid=' => $project->id), 'title asc'); $this->view->priorities = array('Must Have', 'Should Have', 'Would Like', 'Nice To Have'); $this->view->statuses = $model->constraints['status']->getValues(); $this->view->linkedTasks = array(); if ($model->id) { $this->view->linkedTasks = $this->itemLinkService->getLinkedItemsOfType($model, 'from', 'Task'); } parent::prepareForEdit($model); }
/** * Load all the child features of a given feature * * @param unknown_type $feature */ private function loadChildFeatures($feature, $milestoneMapping) { if (isset($milestoneMapping[$feature->milestone])) { $feature->setMilestoneTitle($milestoneMapping[$feature->milestone]); } $children = $this->itemLinkService->getLinkedItemsOfType($feature, 'from', 'Feature', array(), 'sortorder asc'); $feature->setChildFeatures($children); foreach ($children as $child) { $this->loadChildFeatures($child, $milestoneMapping); } }
/** * Get a bunch of data prepared for the view */ protected function prepareForEdit() { if ($this->view->model == null) { throw new Exception("Task not found!"); } // check the existence of the client to add this contact to $pid = (int) $this->_getParam('projectid') ? (int) $this->_getParam('projectid') : $this->view->model->projectid; $project = new Project(); if ($pid) { $project = $this->projectService->getProject($pid); } $this->view->project = $project; $this->view->projectUsers = $this->projectService->getProjectUsers($project); $this->view->activeTasks = array(); if ($project->id) { $this->view->projects = $this->projectService->getProjectsForClient($project->clientid); $this->view->activeTasks = $this->projectService->getActiveProjectTasks($project); } else { $this->view->projects = new ArrayObject(); } $this->view->categories = $this->view->model->constraints['category']->getValues(); $this->view->clients = $this->clientService->getClients(); $this->view->model->tags = ""; if ($this->view->model->id) { $this->view->notes = $this->notificationService->getNotesFor($this->view->model); $this->view->existingWatch = $this->notificationService->getWatch(za()->getUser(), $this->view->model->id, 'Task'); $this->view->allUsers = $this->userService->getUserList(); $this->view->subscribers = $this->notificationService->getSubscribers($this->view->model->id, 'Task'); $tags = $this->tagService->getItemTags($this->view->model); $tagStr = ""; $sep = ""; foreach ($tags as $tag) { $tagStr .= $sep . $tag->tag; $sep = ','; } $this->view->model->tags = $tagStr; // get all the issues that triggered this task $this->view->issues = $this->itemLinkService->getLinkedItemsOfType($this->view->model, 'to', 'Issue'); $this->view->features = $this->itemLinkService->getLinkedItemsOfType($this->view->model, 'to', 'Feature'); // get selectable features based on the milestont this project is in. $this->view->selectableFeatures = $project->getFeatures(); $client = $this->clientService->getClient($project->clientid); // get all the requests for the given client $this->view->selectableRequests = $client->getIssues(); } }
/** * Update all linked items to the given task to make sure * their dates are as accurate as possible * */ private function updateAffectedLinkedItems(Task $task) { // first get all issues $issues = $this->itemLinkService->getLinkedItemsOfType($task, 'to', 'Issue'); foreach ($issues as $issue) { $tasks = $this->itemLinkService->getLinkedItemsOfType($issue, 'from', 'Task'); $estimated = 0; $elapsed = 0; foreach ($tasks as $linkedTask) { /* @var $linkedTask Task */ $estimated += $linkedTask->estimated; $elapsed += $linkedTask->timespent; } // Convert elapsed to hours to match estimated time if ($elapsed > 0) { $elapsed = $elapsed / 3600; } // update the issue's time spent, but NOT its estimate - this is // separate from the task estimates. // $issue->estimated = $estimated; $issue->elapsed = $elapsed; $this->dbService->saveObject($issue); } $features = $this->itemLinkService->getLinkedItemsOfType($task, 'to', 'Feature'); foreach ($features as $feature) { $tasks = $this->itemLinkService->getLinkedItemsOfType($feature, 'from', 'Task'); $estimated = 0; $elapsed = 0; foreach ($tasks as $linkedTask) { /* @var $linkedTask Task */ $estimated += $linkedTask->estimated; $elapsed += $linkedTask->timespent; } // Convert elapsed to hours to match estimated time if ($elapsed > 0) { $elapsed = $elapsed / 3600; } // update the feature's elapsed hours $feature->hours = $elapsed; $this->dbService->saveObject($feature); } }