Пример #1
0
 /**
  * @param int $teamid
  * @param int $startTimestamp
  * @param int $endTimestamp
  * @param int[] $projectIds
  * @return GanttGraph
  */
 private function getGanttGraph($teamid, $startTimestamp, $endTimestamp, array $projectIds)
 {
     $graph = new GanttGraph();
     // set graph title
     $team = TeamCache::getInstance()->getTeam($teamid);
     if (0 != count($projectIds)) {
         $pnameList = "";
         foreach ($projectIds as $pid) {
             if ("" != $pnameList) {
                 $pnameList .= ",";
             }
             $project = ProjectCache::getInstance()->getProject($pid);
             $pnameList .= $project->getName();
         }
         $graph->title->Set(T_('Team') . ' ' . $team->getName() . '    ' . T_('Project(s)') . ': ' . $pnameList);
     } else {
         $graph->title->Set(T_('Team') . ' ' . $team->getName() . '    (' . T_('All projects') . ')');
     }
     // Setup scale
     $graph->ShowHeaders(GANTT_HYEAR | GANTT_HMONTH | GANTT_HDAY | GANTT_HWEEK);
     $graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAYWNBR);
     $gantManager = new GanttManager($teamid, $startTimestamp, $endTimestamp);
     $teamActivities = $gantManager->getTeamActivities();
     // mapping to ease constrains building
     // Note: $issueActivityMapping must be completed before calling $a->getJPGraphBar()
     $issueActivityMapping = array();
     $activityIdx = 0;
     foreach ($teamActivities as $a) {
         $a->setActivityIdx($activityIdx);
         $issueActivityMapping[$a->bugid] = $activityIdx;
         ++$activityIdx;
     }
     // Add the specified activities
     foreach ($teamActivities as $a) {
         // FILTER on projects
         if (NULL != $projectIds && 0 != sizeof($projectIds)) {
             $issue = IssueCache::getInstance()->getIssue($a->bugid);
             if (!in_array($issue->getProjectId(), $projectIds)) {
                 // skip activity indexing
                 continue;
             }
         }
         $filterTeamActivities[] = $a;
         // Shorten bar depending on gantt startDate
         if (NULL != $startTimestamp && $a->startTimestamp < $startTimestamp) {
             // leave one day to insert prefixBar
             $newStartTimestamp = $startTimestamp + 60 * 60 * 24;
             if ($newStartTimestamp > $a->endTimestamp) {
                 // there is not enough space for a prefixBar
                 $newStartTimestamp = $startTimestamp;
                 self::$logger->debug("bugid=" . $a->bugid . ": Shorten bar to Gantt start date");
             } else {
                 $formattedStartDate = date('Y-m-d', $startTimestamp);
                 $prefixBar = new GanttBar($a->activityIdx, "", $formattedStartDate, $formattedStartDate, "", 10);
                 $prefixBar->SetBreakStyle(true, 'dotted', 1);
                 $graph->Add($prefixBar);
                 self::$logger->debug("bugid=" . $a->bugid . ": Shorten bar & add prefixBar");
             }
             self::$logger->debug("bugid=" . $a->bugid . ": Shorten bar from " . date('Y-m-d', $a->startTimestamp) . " to " . date('Y-m-d', $newStartTimestamp));
             $a->startTimestamp = $newStartTimestamp;
         }
         $bar = $a->getJPGraphBar($issueActivityMapping);
         $graph->Add($bar);
     }
     return $graph;
 }
Пример #2
0
 /**
  * Initialize complex static variables
  * @static
  */
 public static function staticInit()
 {
     self::$logger = Logger::getLogger(__CLASS__);
 }