/** * Get detailed mgr * @param IssueSelection $issueSelection * @return mixed[] */ public static function getIssueSelectionDetailedMgr(IssueSelection $issueSelection) { //$formatedList = implode( ',', array_keys($issueSelection->getIssueList())); $valuesMgr = $issueSelection->getDriftMgr(); $driftMgrColor = IssueSelection::getDriftColor($valuesMgr['percent']); $formatteddriftMgrColor = NULL == $driftMgrColor ? "" : "style='background-color: #" . $driftMgrColor . ";' "; $selectionDetailedMgr = array('name' => $issueSelection->name, 'effortEstim' => $issueSelection->mgrEffortEstim + $issueSelection->getProvision(), 'reestimated' => $issueSelection->getReestimated(), 'elapsed' => $issueSelection->elapsed, 'backlog' => $issueSelection->duration, 'driftColor' => $formatteddriftMgrColor, 'drift' => round($valuesMgr['nbDays'], 2), 'progress' => round(100 * $issueSelection->getProgress(), 2)); return $selectionDetailedMgr; }
/** * * returns an array of [user][activity] * activity in (elapsed, sidetask, other, external, leave) * */ public function execute() { $team = TeamCache::getInstance()->getTeam($this->teamid); $members = $team->getActiveMembers(null, null, true); $issueList = $this->inputIssueSel->getIssueList(); // --- $userList = array(); $formattedTaskListPerUser = array(); $iSelPerUser = array(); $iSelOpenTasks = new IssueSelection('nonResolved'); /* @var $issue Issue */ foreach ($issueList as $issue) { try { // for each issue that is not resolved, add reestimated to handler. if (!$issue->isResolved()) { $userId = $issue->getHandlerId(); if (0 != $userId) { $user = UserCache::getInstance()->getUser($userId); $userList[$userId] = $user->getRealname(); } else { $userList[0] = '(unknown 0)'; } if (!$this->isExtRef) { $displayedTaskId = NULL; } else { $displayedTaskId = NULL != $issue->getTcId() && false != trim($issue->getTcId()) ? $issue->getTcId() : 'm-' . $issue->getId(); } $tooltipAttr = $issue->getTooltipItems($this->teamid, $this->sessionUserid, $this->isManager); // add task summary in front $tooltipAttr = array(T_('Summary') => $issue->getSummary()) + $tooltipAttr; $formattedTaskListPerUser[$userId][] = Tools::issueInfoURL($issue->getId(), $tooltipAttr, FALSE, $displayedTaskId); if (!array_key_exists($userId, $iSelPerUser)) { $iSelPerUser[$userId] = new IssueSelection('user_' . $userId); } $iSelPerUser[$userId]->addIssue($issue->getId()); $iSelOpenTasks->addIssue($issue->getId()); } } catch (Exception $e) { self::$logger->error("BacklogPerUserIndicator: " . $e->getMessage()); } } // sort by name, keep key-val association asort($userList); asort($members); // team members $usersActivity = array(); foreach ($members as $userId => $userName) { if (array_key_exists($userId, $iSelPerUser)) { $isel = $iSelPerUser[$userId]; $progress = round($isel->getProgress() * 100); $backlog = $isel->duration; $taskList = implode(', ', $formattedTaskListPerUser[$userId]); $nbTasks = count($formattedTaskListPerUser[$userId]); } else { $progress = 0; $backlog = ''; $taskList = ''; $nbTasks = ''; } $usersActivity[$userId] = array('handlerName' => $userName, 'backlog' => $backlog, 'nbTasks' => $nbTasks, 'progress' => $progress, 'taskList' => $taskList); } // users not in team foreach ($userList as $userId => $userName) { if (!array_key_exists($userId, $members) && 0 != $userId) { $isel = $iSelPerUser[$userId]; $usersActivity[$userId] = array('handlerName' => '<span class="warn_font">' . $userName . '</span>', 'backlog' => $isel->duration, 'nbTasks' => count($formattedTaskListPerUser[$userId]), 'progress' => round($isel->getProgress() * 100), 'taskList' => implode(', ', $formattedTaskListPerUser[$userId])); } } // unassigned tasks if (array_key_exists(0, $userList)) { $isel = $iSelPerUser[0]; $usersActivity[0] = array('handlerName' => '<span class="error_font">' . T_('(unknown 0)') . '</span>', 'backlog' => $isel->duration, 'nbTasks' => count($formattedTaskListPerUser[0]), 'progress' => round($isel->getProgress() * 100), 'taskList' => implode(', ', $formattedTaskListPerUser[0])); } // Total $totalArray = array('handlerName' => T_('TOTAL'), 'backlog' => $iSelOpenTasks->duration, 'nbTasks' => count($iSelOpenTasks->getIssueList()), 'progress' => round($iSelOpenTasks->getProgress() * 100), 'taskList' => ''); #var_dump($usersActivity); $this->execData = array(); $this->execData['userArray'] = $usersActivity; $this->execData['totalArray'] = $totalArray; }
/** * * @param boolean $hasDetail if true, add [Progress, EffortEstim, Elapsed, Backlog, Drift] * @param boolean $isManager * @param int $userid * @return array */ public function getDynatreeData($hasDetail = false, $isManager = false, $teamid = 0) { // TODO AND root_id = $this->getRootId() $query = "SELECT * FROM `codev_wbs_table` WHERE `parent_id` = " . $this->getId() . " ORDER BY `order`"; $result = SqlWrapper::getInstance()->sql_query($query); //file_put_contents('/tmp/loadWBS.txt', "$query \n", FILE_APPEND); if ($result) { $parentArray = array(); while ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) { $wbselement = new WBSElement($row->id, $this->getRootId()); $childArray = array(); if ($wbselement->isFolder()) { $childArray['isFolder'] = true; $childArray['expand'] = $wbselement->isExpand(); $childArray['key'] = $wbselement->getId(); $detail = ''; if ($hasDetail) { $bugids = $this->getBugidList($wbselement->getId()); $isel = new IssueSelection("wbs_" . $wbselement->getId()); foreach ($bugids as $bugid) { try { $isel->addIssue($bugid); } catch (Exception $e) { self::$logger->error("Issue {$bugid} does not exist in Mantis DB."); } } if ($isManager) { $effortEstim = $isel->getMgrEffortEstim(); $driftInfo = $isel->getDriftMgr(); $reestimated = $isel->getReestimated(); } else { $effortEstim = $isel->getEffortEstim(); $driftInfo = $isel->getDrift(); $reestimated = '0'; } $detail = '~' . round(100 * $isel->getProgress()) . '~' . $effortEstim . '~' . $reestimated . '~' . $isel->getElapsed() . '~' . $isel->duration . '~' . $driftInfo['nbDays'] . '~' . $isel->getDriftColor($driftInfo['nbDays']); } $childArray['title'] = $wbselement->getTitle() . $detail; $childArray['children'] = $wbselement->getDynatreeData($hasDetail, $isManager, $teamid); } else { try { // avoid logging an exception... if (!Issue::exists($wbselement->getBugId())) { $e = new Exception("Issue with id=" . $wbselement->getBugId() . " not found."); throw $e; } $issue = IssueCache::getInstance()->getIssue($wbselement->getBugId()); $detail = ''; if ($hasDetail) { if ($isManager) { $effortEstim = $issue->getMgrEffortEstim(); $drift = $issue->getDriftMgr(); $reestimated = $issue->getReestimated(); } else { $effortEstim = $issue->getEffortEstim(); $drift = $issue->getDrift(); $reestimated = '0'; } $detail = '~' . round(100 * $issue->getProgress()) . '~' . $effortEstim . '~' . $reestimated . '~' . $issue->getElapsed() . '~' . $issue->getBacklog() . '~' . $drift . '~' . $issue->getDriftColor($drift); } $formattedSummary = '<b>' . $issue->getId() . '</b> ' . $issue->getSummary(); // if ($hasDetail) { // mb_internal_encoding("UTF-8"); // $formattedSummary = mb_strimwidth($formattedSummary, 0, 70, "..."); // } $childArray['title'] = $formattedSummary . $detail; $childArray['isFolder'] = false; $childArray['key'] = $issue->getId(); // yes, bugid ! // add tooltip $user = UserCache::getInstance()->getUser($issue->getHandlerId()); $titleAttr = array(T_('Project') => $issue->getProjectName(), T_('Category') => $issue->getCategoryName(), T_('Status') => Constants::$statusNames[$issue->getStatus()], T_('Assigned to') => $user->getRealname(), T_('Tags') => implode(',', $issue->getTagList())); $childArray['href'] = Constants::$codevURL . '/reports/issue_info.php?bugid=' . $issue->getId(); #$childArray['htmlTooltip'] = Tools::getTooltip($issue->getTooltipItems($teamid, 0, $isManager)); $childArray['htmlTooltip'] = Tools::getTooltip($titleAttr); #$childArray['icon'] = 'mantis_ico.gif'; } catch (Exception $e) { //$childArray['title'] = $wbselement->getBugId().' - '.T_('Error: Task not found in Mantis DB !'); //$childArray['isFolder'] = false; self::$logger->warn("Issue {$bugid} does not exist in Mantis DB: calling checkWBS()"); $childArray = array(); // remove from WBS self::checkWBS(); } } if (sizeof($childArray) > 0) { array_push($parentArray, $childArray); } } // root element not only has children ! if ($this->id === $this->getRootId()) { $detail = ''; if ($hasDetail) { $bugids = $this->getBugidList($this->id); $isel = new IssueSelection("wbs_" . $this->id); foreach ($bugids as $bugid) { try { $isel->addIssue($bugid); } catch (Exception $e) { self::$logger->error("Issue {$bugid} does not exist in Mantis DB."); } } if ($isManager) { $effortEstim = $isel->getMgrEffortEstim(); $driftInfo = $isel->getDriftMgr(); $reestimated = $isel->getReestimated(); } else { $effortEstim = $isel->getEffortEstim(); $driftInfo = $isel->getDrift(); $reestimated = '0'; } $mgrDriftInfo = $isel->getDriftMgr(); $detail = '~' . round(100 * $isel->getProgress()) . '~' . $effortEstim . '~' . $reestimated . '~' . $isel->getElapsed() . '~' . $isel->duration . '~' . $driftInfo['nbDays'] . '~' . $isel->getDriftColor($driftInfo['nbDays']); } $rootArray = array('title' => $this->getTitle() . $detail, 'isFolder' => true, 'expand' => $this->isExpand(), 'key' => $this->getId(), 'children' => $parentArray); return $rootArray; } else { return $parentArray; } } else { self::$logger->error("Query failed!"); } }