Ejemplo n.º 1
0
 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);
             }
         }
     }
 }