public function execute(IssueSelection $inputIssueSel, array $params = NULL) { $this->checkParams($inputIssueSel, $params); if (is_null($this->outputList)) { $privateIssueSel = new IssueSelection(IssuePublicPrivateFilter::tag_private); $publicIssueSel = new IssueSelection(IssuePublicPrivateFilter::tag_public); $issueList = $inputIssueSel->getIssueList(); foreach ($issueList as $issue) { $isPrivate = $issue->isPrivate(); if ($isPrivate) { $privateIssueSel->addIssue($issue->getId()); } else { $publicIssueSel->addIssue($issue->getId()); } } $this->outputList = array(); $this->outputList[IssuePublicPrivateFilter::tag_private] = $privateIssueSel; $this->outputList[IssuePublicPrivateFilter::tag_public] = $publicIssueSel; if (self::$logger->isDebugEnabled()) { self::$logger->debug('input Nb Issues =' . $inputIssueSel->getNbIssues()); foreach ($this->outputList as $tag => $iSel) { self::$logger->debug('Tag {' . $tag . '} Nb Issues =' . $iSel->getNbIssues()); } } } return $this->outputList; }
protected function display() { if (Tools::isConnectedUser()) { if (0 != $this->teamid) { $team = TeamCache::getInstance()->getTeam($this->teamid); $action = filter_input(INPUT_GET, 'action'); if ('setDateRange' === $action) { $startdate = filter_input(INPUT_GET, 'startdate'); $startTimestamp = Tools::date2timestamp($startdate); $enddate = filter_input(INPUT_GET, 'enddate'); $endTimestamp = Tools::date2timestamp($enddate); $endTimestamp += 24 * 60 * 60 - 1; // + 1 day -1 sec. } else { //$startTimestamp = $team->getDate(); // creationDate //$endTimestamp = time(); $startTimestamp = strtotime("first day of this month"); $endTimestamp = strtotime("last day of this month"); } $this->smartyHelper->assign('startDate', date("Y-m-d", $startTimestamp)); $this->smartyHelper->assign('endDate', date("Y-m-d", $endTimestamp)); // create issueSelection with issues from team projects $teamIssues = $team->getTeamIssueList(true, true); // with disabledProjects ? $teamIssueSelection = new IssueSelection('Team' . $this->teamid . 'ISel'); $teamIssueSelection->addIssueList($teamIssues); // feed the PluginDataProvider $pluginDataProvider = PluginDataProvider::getInstance(); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_ISSUE_SELECTION, $teamIssueSelection); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_TEAM_ID, $this->teamid); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_START_TIMESTAMP, $startTimestamp); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_END_TIMESTAMP, $endTimestamp); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_SESSION_USER_ID, $this->session_userid); $dashboardName = 'Team' . $this->teamid; // save the DataProvider for Ajax calls $_SESSION[PluginDataProviderInterface::SESSION_ID . $dashboardName] = serialize($pluginDataProvider); // create the Dashboard $dashboard = new Dashboard($dashboardName); $dashboard->setDomain(IndicatorPluginInterface::DOMAIN_TEAM); $dashboard->setCategories(array(IndicatorPluginInterface::CATEGORY_QUALITY, IndicatorPluginInterface::CATEGORY_ACTIVITY, IndicatorPluginInterface::CATEGORY_ROADMAP, IndicatorPluginInterface::CATEGORY_PLANNING, IndicatorPluginInterface::CATEGORY_RISK, IndicatorPluginInterface::CATEGORY_TEAM)); $dashboard->setTeamid($this->teamid); $dashboard->setUserid($this->session_userid); $data = $dashboard->getSmartyVariables($this->smartyHelper); foreach ($data as $smartyKey => $smartyVariable) { $this->smartyHelper->assign($smartyKey, $smartyVariable); } } else { $this->smartyHelper->assign('error', T_('Please select a team to access this page.')); } } else { $this->smartyHelper->assign('error', T_('Sorry, you need to be identified.')); } }
/** * @param IssueSelection $inputIssueSel * @param int[] $timestampList */ private function getStatusData(IssueSelection $inputIssueSel, array $timestampList) { $this->statusData = array(); $historyStatusNew = array(); // timestamp => nbIssues $historyStatusFeedback = array(); // timestamp => nbIssues $historyStatusOngoing = array(); // timestamp => nbIssues $historyStatusResolved = array(); // timestamp => nbIssues $historyStatusTotal = array(); // timestamp => nbIssues // get a snapshot of the Status at each timestamp $issues = $inputIssueSel->getIssueList(); foreach ($timestampList as $timestamp) { $midnight_timestamp = mktime(0, 0, 0, date('m', $timestamp), date('d', $timestamp), date('Y', $timestamp)); // all timestamps must be defined, even if empty $historyStatusNew["{$midnight_timestamp}"] = 0; $historyStatusFeedback["{$midnight_timestamp}"] = 0; $historyStatusOngoing["{$midnight_timestamp}"] = 0; $historyStatusResolved["{$midnight_timestamp}"] = 0; $historyStatusTotal["{$midnight_timestamp}"] = 0; foreach ($issues as $issue) { $issueStatus = $issue->getStatus($timestamp); // if issue exists at this date if (-1 != $issueStatus) { if ($issueStatus >= $issue->getBugResolvedStatusThreshold()) { $historyStatusResolved["{$midnight_timestamp}"] += 1; } else { if ($issueStatus == Constants::$status_feedback) { $historyStatusFeedback["{$midnight_timestamp}"] += 1; } else { if ($issueStatus == Constants::$status_new) { $historyStatusNew["{$midnight_timestamp}"] += 1; } else { $historyStatusOngoing["{$midnight_timestamp}"] += 1; } } } $historyStatusTotal["{$midnight_timestamp}"] += 1; #echo date('Y-m-d', $timestamp)." issue ".$issue->getId()." status ".$issueStatus."<br>"; } } if (self::$logger->isDebugEnabled()) { self::$logger->debug('Y-m-d', $midnight_timestamp) . ' new ' . $historyStatusNew["{$midnight_timestamp}"] . 'feedback ' . $historyStatusFeedback["{$midnight_timestamp}"] . 'ongoing ' . $historyStatusOngoing["{$midnight_timestamp}"] . 'resolved ' . $historyStatusResolved["{$midnight_timestamp}"] . 'total ' . $historyStatusTotal["{$midnight_timestamp}"]; } } $this->statusData = array('new' => $historyStatusNew, 'feedback' => $historyStatusFeedback, 'ongoing' => $historyStatusOngoing, 'resolved' => $historyStatusResolved, 'total' => $historyStatusTotal); return $this->statusData; }
/** * @return IssueSelection */ public function getIssueSelection() { if (is_null($this->issueSelection)) { $this->issueSelection = new IssueSelection($this->name); $issueList = $this->getIssues(); foreach ($issueList as $issue) { try { $this->issueSelection->addIssue($issue->getId()); } catch (Exception $e) { self::$logger->warn("getIssueSelection: " . $e->getMessage()); } } } return $this->issueSelection; }
private function getResolvedIssues($teamid, $userid = 0, $projects = NULL) { $team = TeamCache::getInstance()->getTeam($teamid); if (is_null($projects)) { $projects = $team->getProjects(false, false, false); $formattedProjects = implode(',', array_keys($projects)); } else { $formattedProjects = implode(',', array_values($projects)); } $formattedUsers = 0 != $userid ? $userid : implode(',', array_keys($team->getActiveMembers())); $query = "SELECT id FROM `mantis_bug_table` " . "WHERE project_id IN ({$formattedProjects}) " . "AND handler_id IN ({$formattedUsers}) " . "AND status >= get_project_resolved_status_threshold(project_id) "; $result = SqlWrapper::getInstance()->sql_query($query); echo "query = {$query}<br>"; if (!$result) { echo "<span style='color:red'>ERROR: Query FAILED</span>"; exit; } $isel = new IssueSelection('resolvedIssues'); while ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) { $isel->addIssue($row->id); } echo implode(',', array_keys($isel->getIssueList())); return $isel; }
private function getDetailedMgr($explodeResults, $filterList) { $iselIdx = count($explodeResults[0]) - 1; $smartyObj = array(); foreach ($explodeResults as $line) { $isel = $line[$iselIdx]; $valuesMgr = $isel->getDriftMgr(); $detailedMgr = array('name' => $isel->name, 'effortEstim' => $isel->mgrEffortEstim, 'reestimated' => $isel->getReestimated(), 'elapsed' => $isel->elapsed, 'backlog' => $isel->duration, 'driftColor' => IssueSelection::getDriftColor($valuesMgr['percent']), 'drift' => round($valuesMgr['nbDays'], 2)); $line[$iselIdx] = $detailedMgr; $smartyObj[] = $line; } // add TitleLine $titles = $filterList; $titles[] = T_("MgrEffortEstim"); $titles[] = T_("Reestimated"); $titles[] = T_("Elapsed"); $titles[] = T_("Backlog"); $titles[] = T_("Drift Mgr"); $smartyObj[] = $titles; return $smartyObj; }
/** * display Drifts for Issues that have NOT been marked as 'Resolved' until now * @param int $teamid * @param int $threshold * @return mixed[] */ private function getCurrentDeviationStats($teamid, $threshold = 1) { $issueList = TeamCache::getInstance()->getTeam($teamid)->getCurrentIssueList(TRUE, FALSE, FALSE); if (NULL == $issueList || 0 == count($issueList)) { self::$logger->info("getCurrentDeviationStats: No opened issues for team {$teamid}"); return NULL; } $issueSelection = new IssueSelection("current issues"); $issueSelection->addIssueList($issueList); $deviationGroups = $issueSelection->getDeviationGroups($threshold); $deviationGroupsMgr = $issueSelection->getDeviationGroupsMgr($threshold); $currentDeviationStats = array(); $currentDeviationStats['totalDeviationMgr'] = $issueSelection->getDriftMgr(); $currentDeviationStats['totalDeviation'] = $issueSelection->getDrift(); $posDriftMgr = $deviationGroupsMgr['positive']->getDriftMgr(); $posDrift = $deviationGroups['positive']->getDrift(); $currentDeviationStats['nbIssuesPosMgr'] = $deviationGroupsMgr['positive']->getNbIssues(); $currentDeviationStats['nbIssuesPos'] = $deviationGroups['positive']->getNbIssues(); $currentDeviationStats['nbDaysPosMgr'] = $posDriftMgr['nbDays']; $currentDeviationStats['nbDaysPos'] = $posDrift['nbDays']; $currentDeviationStats['issuesPosMgr'] = $deviationGroupsMgr['positive']->getFormattedIssueList(); $currentDeviationStats['issuesPos'] = $deviationGroups['positive']->getFormattedIssueList(); $equalDriftMgr = $deviationGroupsMgr['equal']->getDriftMgr(); $equalDrift = $deviationGroups['equal']->getDrift(); $currentDeviationStats['nbIssuesEqualMgr'] = $deviationGroupsMgr['equal']->getNbIssues(); $currentDeviationStats['nbIssuesEqual'] = $deviationGroups['equal']->getNbIssues(); $currentDeviationStats['nbDaysEqualMgr'] = $equalDriftMgr['nbDays']; $currentDeviationStats['nbDaysEqual'] = $equalDrift['nbDays']; $currentDeviationStats['issuesEqualMgr'] = $deviationGroupsMgr['equal']->getFormattedIssueList(); $currentDeviationStats['issuesEqual'] = $deviationGroups['equal']->getFormattedIssueList(); $negDriftMgr = $deviationGroupsMgr['negative']->getDriftMgr(); $negDrift = $deviationGroups['negative']->getDrift(); $currentDeviationStats['nbIssuesNegMgr'] = $deviationGroupsMgr['negative']->getNbIssues(); $currentDeviationStats['nbIssuesNeg'] = $deviationGroups['negative']->getNbIssues(); $currentDeviationStats['nbDaysNegMgr'] = $negDriftMgr['nbDays']; $currentDeviationStats['nbDaysNeg'] = $negDrift['nbDays']; $currentDeviationStats['issuesNegMgr'] = $deviationGroupsMgr['negative']->getFormattedIssueList(); $currentDeviationStats['issuesNeg'] = $deviationGroups['negative']->getFormattedIssueList(); return $currentDeviationStats; }
public function __construct($projectId, $version) { parent::__construct($version); $this->projectId = $projectId; }
/** * @param int $servicecontractid * @return mixed[] */ private static function getContractTotalDetailedMgr($servicecontractid, $provDaysByType) { $detailledMgr = NULL; if (0 != $servicecontractid) { $contract = ServiceContractCache::getInstance()->getServiceContract($servicecontractid); $issueSelection = new IssueSelection("Total"); // sidetasks $sidetasksPerCategory = $contract->getSidetasksPerCategoryType(true); foreach ($sidetasksPerCategory as $id => $iSel) { if (is_numeric($id) && Project::cat_st_inactivity == $id) { continue; } $issueSelection->addIssueList($iSel->getIssueList()); } // tasks $cmdsetsIssueSelection = $contract->getIssueSelection(CommandSet::type_general, Command::type_general); $issueSelection->addIssueList($cmdsetsIssueSelection->getIssueList()); // provisions foreach ($provDaysByType as $nbDays) { $issueSelection->addProvision($nbDays); } #echo 'TotalSideTasks provision = '.$issueSelection->getProvision().'<br>'; $detailledMgr = SmartyTools::getIssueSelectionDetailedMgr($issueSelection); $detailledMgr['name'] = $issueSelection->name; } return $detailledMgr; }
/** * * @param IssueSelection $inputIssueSel * @param array $timestampList */ private function getElapsedData(IssueSelection $inputIssueSel, array $timestampList) { $this->elapsedData = array(); // there is no elapsed on first date $this->elapsedData[] = 0; for ($i = 1, $size = count($timestampList); $i < $size; ++$i) { $start = $timestampList[$i - 1]; //$start = mktime(0, 0, 0, date('m', $timestampList[$i-1]), date('d',$timestampList[$i-1]), date('Y', $timestampList[$i-1])); $lastDay = $i + 1 < $size ? strtotime("-1 day", $timestampList[$i]) : $timestampList[$i]; $end = mktime(23, 59, 59, date('m', $lastDay), date('d', $lastDay), date('Y', $lastDay)); # echo "nb issues = ".count($inputIssueSel->getIssueList()); $elapsed = $inputIssueSel->getElapsed($start, $end); $midnight_timestamp = mktime(0, 0, 0, date('m', $timestampList[$i]), date('d', $timestampList[$i]), date('Y', $timestampList[$i])); $this->elapsedData[$midnight_timestamp] += $elapsed; // Note: += is important //self::$logger->error("elapsed[".date('Y-m-d H:i:s', $midnight_timestamp)."] (".date('Y-m-d H:i:s', $start)." - ".date('Y-m-d H:i:s', $end).") = ".$this->elapsedData[$midnight_timestamp]); } }
private function generateStatusHistoryGraph($teamid) { $team = TeamCache::getInstance()->getTeam($teamid); $issueList = $team->getTeamIssueList(true, false); $issueSel = new IssueSelection('Team ' . $team->getName() . ' issues'); $issueSel->addIssueList($issueList); $startTimestamp = $team->getDate(); $endTimestamp = time(); $params = array('startTimestamp' => $startTimestamp, 'endTimestamp' => $endTimestamp, 'interval' => 10); $statusHistoryIndicator = new StatusHistoryIndicator(); $statusHistoryIndicator->execute($issueSel, $params); $smartyobj = $statusHistoryIndicator->getSmartyObject(); foreach ($smartyobj as $smartyKey => $smartyVariable) { $this->smartyHelper->assign($smartyKey, $smartyVariable); } }
/** * * @param SmartyHelper $smartyHelper * @param Issue $issue * @param int $userid * @param int $teamid */ public static function dashboardSettings(SmartyHelper $smartyHelper, Issue $issue, $userid, $teamid) { $isel = new IssueSelection(); $isel->addIssue($issue->getId()); $pluginDataProvider = PluginDataProvider::getInstance(); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_ISSUE_SELECTION, $isel); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_TEAM_ID, $teamid); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_SESSION_USER_ID, $userid); // start date is min(1st_timetrack, issue_creation_date) $startT = $issue->getDateSubmission(); $firstTT = $issue->getFirstTimetrack(); if (NULL != $firstTT) { $startT = min(array($issue->getDateSubmission(), $firstTT->getDate())); } // end date is last_timetrack or now if none $eTs = NULL == $firstTT ? time() : $issue->getLatestTimetrack()->getDate(); $endT = mktime(23, 59, 59, date('m', $eTs), date('d', $eTs), date('Y', $eTs)); //echo "start $startT end $endT<br>"; // Calculate a nice day interval $nbWeeks = ($endT - $startT) / 60 / 60 / 24; $interval = ceil($nbWeeks / 20); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_START_TIMESTAMP, $startT); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_END_TIMESTAMP, $endT); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_INTERVAL, $interval); $dashboardName = 'Tasks_prj' . $issue->getProjectId(); // save the DataProvider for Ajax calls $_SESSION[PluginDataProviderInterface::SESSION_ID . $dashboardName] = serialize($pluginDataProvider); // create the Dashboard $dashboard = new Dashboard($dashboardName); // settings are common all tasks of a project $dashboard->setDomain(IndicatorPluginInterface::DOMAIN_TASK); $dashboard->setCategories(array(IndicatorPluginInterface::CATEGORY_QUALITY, IndicatorPluginInterface::CATEGORY_ACTIVITY, IndicatorPluginInterface::CATEGORY_ROADMAP, IndicatorPluginInterface::CATEGORY_PLANNING, IndicatorPluginInterface::CATEGORY_RISK)); $dashboard->setTeamid($teamid); $dashboard->setUserid($userid); $data = $dashboard->getSmartyVariables($smartyHelper); foreach ($data as $smartyKey => $smartyVariable) { $smartyHelper->assign($smartyKey, $smartyVariable); } }
/** * * Deux courbes: * * RAF Theorique = charge initiale - cumul consomé * * RAF Reel = cumul consomé / (cumul consomé + RAF) * * */ public function execute() { $startTimestamp = mktime(23, 59, 59, date('m', $this->startTimestamp), date('d', $this->startTimestamp), date('Y', $this->startTimestamp)); $endTimestamp = mktime(23, 59, 59, date('m', $this->endTimestamp), date('d', $this->endTimestamp), date('Y', $this->endTimestamp)); #echo "Backlog start ".date('Y-m-d H:i:s', $startTimestamp)." end ".date('Y-m-d H:i:s', $endTimestamp)." interval ".$this->interval."<br>"; $timestampList = Tools::createTimestampList($startTimestamp, $endTimestamp, $this->interval); // -------- elapsed in the period $startTimestamp = mktime(0, 0, 0, date('m', $startTimestamp), date('d', $startTimestamp), date('Y', $startTimestamp)); $endTimestamp = mktime(23, 59, 59, date('m', $endTimestamp), date('d', $endTimestamp), date('Y', $endTimestamp)); //echo "Elapsed start ".date('Y-m-d H:i:s', $startTimestamp)." end ".date('Y-m-d H:i:s', $endTimestamp)." interval ".$this->interval."<br>"; $timestampList2 = Tools::createTimestampList($startTimestamp, $endTimestamp, $this->interval); $this->getBacklogData($this->inputIssueSel, $timestampList); $this->getElapsedData($this->inputIssueSel, $timestampList2); // ------ compute $theoBacklog = array(); $realBacklog = array(); $iselMaxEE = max(array($this->inputIssueSel->mgrEffortEstim, $this->inputIssueSel->effortEstim + $this->inputIssueSel->effortAdd)); $sumElapsed = 0; $nbZeroDivErrors1 = 0; $nbZeroDivErrors2 = 0; foreach ($timestampList as $timestamp) { $midnight_timestamp = mktime(0, 0, 0, date('m', $timestamp), date('d', $timestamp), date('Y', $timestamp)); // ========= RAF theorique // Indicateur = charge initiale - cumul consomé if (array_key_exists($midnight_timestamp, $this->elapsedData)) { #echo "sumElapsed += ".$this->elapsedData[$midnight_timestamp]." from ".date('Y-m-d H:i:s', $midnight_timestamp)."<br>"; $sumElapsed += $this->elapsedData[$midnight_timestamp]; } if (0 != $iselMaxEE) { $val1 = $sumElapsed / $iselMaxEE; } else { // TODO $val1 = 0; $nbZeroDivErrors1 += 1; //self::$logger->error("Division by zero ! (mgrEffortEstim)"); } if ($val1 > 1) { $val1 = 1; } $theoBacklog[Tools::formatDate("%Y-%m-%d", $midnight_timestamp)] = round($val1 * 100, 2); // ========= RAF reel // Indicateur = Conso. Cumulé / (Conso. Cumulé + RAF) $tmp = $sumElapsed + $this->backlogData[$midnight_timestamp]; if (0 != $tmp) { $val2 = $sumElapsed / $tmp; } else { // TODO $val2 = 0; $nbZeroDivErrors2 += 1; //self::$logger->error("Division by zero ! (elapsed + realBacklog)"); } $realBacklog[Tools::formatDate("%Y-%m-%d", $midnight_timestamp)] = round($val2 * 100, 2); #echo "(".date('Y-m-d', $midnight_timestamp).") sumElapsed = $sumElapsed BacklogData = ".$this->backlogData[$midnight_timestamp]." MaxEE = ".$iselMaxEE.'<br>'; #echo "(".date('Y-m-d', $midnight_timestamp).") theoBacklog = ".$theoBacklog[Tools::formatDate("%Y-%m-%d", $midnight_timestamp)]." realBacklog = ".$realBacklog[Tools::formatDate("%Y-%m-%d", $midnight_timestamp)].'<br>'; } // foreach timestamp if (count($this->inputIssueSel->getIssueList()) > 0) { // PERF logging is slow, factorize errors if ($nbZeroDivErrors1 > 0) { self::$logger->error("{$nbZeroDivErrors1} Division by zero ! (mgrEffortEstim)"); } if ($nbZeroDivErrors2 > 0) { self::$logger->error("{$nbZeroDivErrors2} Division by zero ! (elapsed + realBacklog)"); } } $this->execData = array(); $this->execData['theo'] = $theoBacklog; $this->execData['real'] = $realBacklog; }
/** * get issues attributes * @param IssueSelection $issueSelection * @return mixed[] */ public static function getIssueListInfo(IssueSelection $issueSelection) { $issueArray = array(); $issues = $issueSelection->getIssueList(); foreach ($issues as $id => $issue) { $driftMgr = $issue->getDriftMgr(); $driftMgrColor = $issue->getDriftColor($driftMgr); $issueArray[$id] = array("bugid" => Tools::issueInfoURL(sprintf("%07d\n", $issue->getId())), "project" => $issue->getProjectName(), "target" => $issue->getTargetVersion(), "effortEstim" => $issue->getMgrEffortEstim(), "elapsed" => $issue->getElapsed(), "summary" => $issue->getSummary(), "category" => $issue->getCategoryName()); } return $issueArray; }
protected function display() { if (Tools::isConnectedUser()) { $teamList = $this->session_user->getTeamList(); // only teamMembers & observers can access this page if (0 == $this->teamid || $this->session_user->isTeamCustomer($this->teamid)) { $this->smartyHelper->assign('accessDenied', TRUE); } else { $pageWidth = Tools::getSecurePOSTIntValue('width', Tools::getSecureGETIntValue('width', 0)); $this->smartyHelper->assign('width', $pageWidth); if (array_key_exists($this->teamid, $teamList)) { $this->smartyHelper->assign('consistencyErrors', $this->getConsistencyErrors($this->teamid)); $team = TeamCache::getInstance()->getTeam($this->teamid); $isManager = $this->session_user->isTeamManager($this->teamid); $isObserver = $this->session_user->isTeamObserver($this->teamid); $this->smartyHelper->assign('isManager', $isManager || $isObserver); // display backlog (unassigned tasks) $unassignedIssues = $team->getUnassignedTasks(); $unassigendSel = new IssueSelection("unassigned from team {$this->teamid}"); $unassigendSel->addIssueList($unassignedIssues); $this->smartyHelper->assign('unassigned_nbIssues', $unassigendSel->getNbIssues()); $this->smartyHelper->assign('unassigned_MEE', $unassigendSel->mgrEffortEstim); $this->smartyHelper->assign('unassigned_EE', $unassigendSel->effortEstim + $unassigendSel->effortAdd); // get planningOptions $keyvalue = Tools::getSecurePOSTStringValue('planningOptions', ''); if (!empty($keyvalue)) { $planningOptions = Tools::doubleExplode(':', ',', $keyvalue); $this->session_user->setPlanningOptions($this->teamid, $planningOptions); } $this->smartyHelper->assign('planningOptions', $this->getPlanningOptions()); $today = mktime(0, 0, 0, date("m"), date("d"), date("Y")); $graphSize = "undefined" != $pageWidth ? $pageWidth - 150 : 800; $allTasksLists = array(); $workloads = array(); $teamMembers = $team->getUsers(); $nbDaysToDisplay = 0; foreach ($teamMembers as $user) { $workload = 0; // show only developper's & manager's tasks if (!$user->isTeamDeveloper($this->teamid) && !$user->isTeamManager($this->teamid)) { if (self::$logger->isDebugEnabled()) { self::$logger->debug("user " . $user->getId() . " excluded from scheduled users on team {$this->teamid}"); } continue; } if (NULL != $user->getDepartureDate($this->teamid) && $user->getDepartureDate($this->teamid) < $today) { continue; } $scheduledTaskList = ScheduledTask::scheduleUser($user, $today, $this->teamid, TRUE); foreach ($scheduledTaskList as $scheduledTask) { $workload += $scheduledTask->getDuration(); } $nbDaysToDisplay = $nbDaysToDisplay < $workload ? $workload : $nbDaysToDisplay; $allTasksLists[$user->getName()] = $scheduledTaskList; $workloads[$user->getName()] = $workload; } $dayPixSize = 0 != $nbDaysToDisplay ? $graphSize / $nbDaysToDisplay : 0; $dayPixSize = round($dayPixSize); #echo "DEBUG dayPixSize = $dayPixSize<br/>\n"; $this->smartyHelper->assign('planning', $this->getPlanning($nbDaysToDisplay, $dayPixSize, $allTasksLists, $workloads, $this->teamid, $this->session_userid, $isManager)); $this->smartyHelper->assign('colors', array("green" => T_("onTime"), "red" => T_("NOT onTime"), "blue" => T_("no deadLine"), "grey" => T_("monitored"))); $this->smartyHelper->assign('dayPixSize', $dayPixSize - 1); } } } }
/** * * @param IssueSelection $iSel * @param type $projectid * @param type $odtTemplate * @return string filepath complete path to generated ODT file */ private function generateODT(IssueSelection $iSel, $projectid, $odtTemplate) { self::$logger->debug("genProjectODT(): project {$projectid} template {$odtTemplate}"); $project = ProjectCache::getInstance()->getProject($projectid); $odf = new odf($odtTemplate); try { $odf->setVars('today', date('Y-m-d')); } catch (Exception $e) { } try { $odf->setVars('selectionName', $project->getName()); } catch (Exception $e) { } try { $session_user = UserCache::getInstance()->getUser($this->session_userid); $odf->setVars('sessionUser', $session_user->getRealname()); } catch (Exception $e) { } $issueList = $iSel->getIssueList(); if (self::$logger->isDebugEnabled()) { self::$logger->debug("nb issues = " . count($issueList)); } $q_id = 0; try { $issueSegment = $odf->setSegment('issueSelection'); } catch (Exception $e) { self::$logger->error("generateODT: TAG 'issueSelection'"); self::$logger->error("generateODT: " + $e->getMessage()); return "FAILED: error on segment 'issueSelection'."; } if (self::$logger->isDebugEnabled()) { self::$logger->debug('XML=' . $issueSegment->getXml()); } foreach ($issueList as $issue) { $q_id += 1; if (0 == $issue->getHandlerId()) { $userName = T_('unknown'); } else { $user = UserCache::getInstance()->getUser($issue->getHandlerId()); $userName = utf8_decode($user->getRealname()); if (empty($userName)) { $userName = "******" . $issue->getHandlerId(); } } if (self::$logger->isDebugEnabled()) { self::$logger->debug("issue " . $issue->getId() . ": handlerName = " . $userName); } if (0 == $issue->getReporterId()) { $reporterName = T_('unknown'); } else { $reporter = UserCache::getInstance()->getUser($issue->getReporterId()); $reporterName = utf8_decode($reporter->getRealname()); if (empty($reporterName)) { $reporterName = "user_" . $issue->getReporterId(); } } if (self::$logger->isDebugEnabled()) { self::$logger->debug("issue " . $issue->getId() . ": reporterName = " . $reporterName); } // add issue try { $issueSegment->setVars('q_id', $q_id); } catch (Exception $e) { } try { $issueSegment->setVars('bugId', $issue->getId()); } catch (Exception $e) { $this->logException($e); } try { $issueSegment->setVars('summary', utf8_decode($issue->getSummary())); } catch (Exception $e) { $this->logException($e); } try { $issueSegment->setVars('dateSubmission', date('d/m/Y', $issue->getDateSubmission())); } catch (Exception $e) { } try { $timestamp = $issue->getLatestStatusOccurrence($issue->getBugResolvedStatusThreshold()); if (is_null($timestamp)) { $issueSegment->setVars('dateResolved', ''); } else { $issueSegment->setVars('dateResolved', date('d/m/Y', $timestamp)); } } catch (Exception $e) { } try { $timestamp = $issue->getDeadLine(); $deadline = 0 == $timestamp ? '' : date('d/m/Y', $issue->getDeadLine()); $issueSegment->setVars('deadline', $deadline); } catch (Exception $e) { $this->logException($e); } try { $issueSegment->setVars('currentStatus', Constants::$statusNames[$issue->getCurrentStatus()]); } catch (Exception $e) { } try { $issueSegment->setVars('handlerId', $userName); } catch (Exception $e) { } try { $issueSegment->setVars('reporterId', $reporterName); } catch (Exception $e) { } try { $issueSegment->setVars('reporterName', $reporterName); } catch (Exception $e) { } try { $issueSegment->setVars('description', utf8_decode($issue->getDescription())); } catch (Exception $e) { } #try { $issueSegment->setVars('description', utf8_decode(Tools::convertToUTF8($issue->getDescription()))); } catch (Exception $e) { }; try { $issueSegment->setVars('category', $issue->getCategoryName()); } catch (Exception $e) { } try { $issueSegment->setVars('severity', $issue->getSeverityName()); } catch (Exception $e) { } try { $issueSegment->setVars('status', Constants::$statusNames[$issue->getStatus()]); } catch (Exception $e) { } try { $issueSegment->setVars('extId', $issue->getTcId()); } catch (Exception $e) { } // add issueNotes $issueNotes = $issue->getIssueNoteList(); $noteId = 0; foreach ($issueNotes as $id => $issueNote) { $noteId += 1; if (self::$logger->isDebugEnabled()) { self::$logger->debug("issue " . $issue->getId() . ": note {$id} = " . $issueNote->getNote()); } $noteReporter = UserCache::getInstance()->getUser($issueNote->getReporterId()); try { $noteReporterName = utf8_decode($noteReporter->getRealname()); } catch (Exception $e) { } try { $issueSegment->bugnotes->noteId($noteId); } catch (Exception $e) { } try { $issueSegment->bugnotes->noteReporter($noteReporterName); } catch (Exception $e) { } try { $issueSegment->bugnotes->noteDateSubmission(date('d/m/Y', $issueNote->getDateSubmitted())); } catch (Exception $e) { } try { $issueSegment->bugnotes->note(utf8_decode($issueNote->getNote())); } catch (Exception $e) { } try { $issueSegment->bugnotes->merge(); } catch (Exception $e) { } } $issueSegment->merge(); } $odf->mergeSegment($issueSegment); // INFO: the following line is MANDATORY and fixes the following error: // "wrong .odt file encoding" #ob_end_clean(); #$odf->exportAsAttachedFile(); // 2nd solution : show link in page $odtFilename = basename($odtTemplate, ".odt") . '_' . $project->getName() . '_' . date('Ymd') . '.odt'; $filepath = Constants::$codevOutputDir . '/reports/' . $odtFilename; if (self::$logger->isDebugEnabled()) { self::$logger->debug("save odt file " . $filepath); } $odf->saveToDisk($filepath); return $filepath; }
/** * * 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; }
/** * Collect the Issues of all the CommandSets (of a given type) * * @param int $cset_type CommandSet::type_general * @param int $cmd_type Command::type_general * @return IssueSelection */ public function getIssueSelection($cset_type, $cmd_type) { // TODO: if type==NULL return for all types $issueSelection = new IssueSelection(); $cmdsetidList = $this->getCommandSetIds($cset_type); if ($cmdsetidList && 0 != count($cmdsetidList)) { foreach ($cmdsetidList as $commandset_id) { $cmdset = CommandSetCache::getInstance()->getCommandSet($commandset_id); $cmdsetIS = $cmdset->getIssueSelection($cmd_type); $issueSelection->addIssueList($cmdsetIS->getIssueList()); } } return $issueSelection; }
/** * Split selection in 3 selection, sorted on issue drift. * * Note: this is a replacement for Timetracking::getIssuesDriftStats() * * @param int $threshold * @param bool $withSupport * * @return IssueSelection[] array of 3 IssueSelection instances ('negative', 'equal', 'positive') */ public function getDeviationGroupsMgr($threshold = 1, $withSupport = true) { if (0 == count($this->issueList)) { echo "<div style='color:red'>ERROR getDeviationGroupsMgr: Issue List is empty !<br/></div>"; self::$logger->error("getDeviationGroupsMgr(): Issue List is empty !"); return NULL; } $negSubList = new IssueSelection("ahead Mgr"); $equalSubList = new IssueSelection("in time Mgr"); $posSubList = new IssueSelection("in drift Mgr"); foreach ($this->issueList as $bugId => $issue) { $issueDrift = $issue->getDriftMgr($withSupport); // get drift stats. equal is when drif = +-threshold if ($issueDrift < -$threshold) { $negSubList->addIssue($bugId); } elseif ($issueDrift > $threshold) { $posSubList->addIssue($bugId); } else { $equalSubList->addIssue($bugId); } } return array("negative" => $negSubList, "equal" => $equalSubList, "positive" => $posSubList); }
/** * Collect the Issues of all the Commands (of a given type) * * @param int $type Command::type_general * * @return IssueSelection */ public function getIssueSelection($type) { // TODO: if type==NULL return for all types $issueSelection = new IssueSelection(); $cmdidList = $this->getCommandIds($type); if ($cmdidList && 0 != count($cmdidList)) { foreach ($cmdidList as $cmdid) { $cmd = CommandCache::getInstance()->getCommand($cmdid); $mcdIS = $cmd->getIssueSelection(); $issueSelection->addIssueList($mcdIS->getIssueList()); } } return $issueSelection; }
/** * $explodeResults contains a list of filterNames + an IssueSelection on the last column. * This function will replace the IssueSelection with a smarty comprehensible array * containing the info to be displayed. * * @param type $explodeResults * @param type $filterDisplayNames */ private function getDetailed($explodeResults, $filterDisplayNames, $smartyVariables) { $iselIdx = count($explodeResults[0]) - 1; $smartyObj = array(); foreach ($explodeResults as $line) { $isel = $line[$iselIdx]; $valuesMgr = $isel->getDriftMgr(); $values = $isel->getDrift(); $smartyElem = array('progress' => round(100 * $isel->getProgress()), 'effortEstimMgr' => $isel->mgrEffortEstim, 'effortEstim' => $isel->effortEstim + $isel->effortAdd, 'reestimated' => $isel->getReestimated(), 'elapsed' => $isel->elapsed, 'backlog' => $isel->duration, 'driftColorMgr' => IssueSelection::getDriftColor($valuesMgr['percent']), 'driftMgr' => round($valuesMgr['nbDays'], 2), 'driftColor' => IssueSelection::getDriftColor($values['percent']), 'drift' => round($values['nbDays'], 2)); $line[$iselIdx] = $smartyElem; $smartyObj[] = $line; } // add TitleLine $titles = $filterDisplayNames; $titles[] = T_("Progress"); $titles[] = T_("MgrEffortEstim"); $titles[] = T_("EffortEstim"); $titles[] = T_("Reestimated"); $titles[] = T_("Elapsed"); $titles[] = T_("Backlog"); $titles[] = T_("Drift Mgr"); $titles[] = T_("Drift"); // set Smarty $totalLine = array_shift($smartyObj); // first line is rootElem (TOTAL) $smartyVariables['detailedMgrTitles'] = $titles; $smartyVariables['detailedMgrLines'] = $smartyObj; $smartyVariables['detailedMgrTotal'] = $totalLine; return $smartyVariables; }
/** * * @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!"); } }