当前位置: 首页>>代码示例>>PHP>>正文


PHP Jobs::getJobColor方法代码示例

本文整理汇总了PHP中Jobs::getJobColor方法的典型用法代码示例。如果您正苦于以下问题:PHP Jobs::getJobColor方法的具体用法?PHP Jobs::getJobColor怎么用?PHP Jobs::getJobColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Jobs的用法示例。


在下文中一共展示了Jobs::getJobColor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  *
  */
 public function execute()
 {
     $extProjId = Config::getInstance()->getValue(Config::id_externalTasksProject);
     $issueList = $this->inputIssueSel->getIssueList();
     $team = TeamCache::getInstance()->getTeam($this->teamid);
     $teamMembers = $team->getMembers();
     $jobs = new Jobs();
     $realStartTimestamp = $this->endTimestamp;
     // note: inverted intentionnaly
     $realEndTimestamp = $this->startTimestamp;
     // note: inverted intentionnaly
     $loadPerJobs = array();
     foreach ($issueList as $issue) {
         if ($extProjId == $issue->getProjectId()) {
             continue;
         }
         $issueTimetracks = $issue->getTimeTracks(NULL, $this->startTimestamp, $this->endTimestamp);
         foreach ($issueTimetracks as $tt) {
             // check if user in team
             if (!array_key_exists($tt->getUserId(), $teamMembers)) {
                 continue;
             }
             // find real date range
             if (NULL == $realStartTimestamp || $tt->getDate() < $realStartTimestamp) {
                 $realStartTimestamp = $tt->getDate();
             }
             if (NULL == $realEndTimestamp || $tt->getDate() > $realEndTimestamp) {
                 $realEndTimestamp = $tt->getDate();
             }
             if ($issue->isProjManagement(array($this->teamid))) {
                 $jobid = '999_Management';
                 if (!array_key_exists($jobid, $loadPerJobs)) {
                     // create job if not exist in jobList
                     $loadPerJobs[$jobid] = array('name' => T_('Management'), 'color' => 'A3A3A3', 'nbDays' => floatval($tt->getDuration()));
                 } else {
                     $loadPerJobs[$jobid]['nbDays'] += floatval($tt->getDuration());
                 }
             } else {
                 if ($team->isSideTasksProject($issue->getProjectId())) {
                     // TODO check category (detail all sidetasks categories)
                     $jobid = '999_SideTasks';
                     if (!array_key_exists($jobid, $loadPerJobs)) {
                         // create job if not exist in jobList
                         $loadPerJobs[$jobid] = array('name' => T_('SideTasks'), 'color' => 'C2C2C2', 'nbDays' => floatval($tt->getDuration()));
                     } else {
                         $loadPerJobs[$jobid]['nbDays'] += floatval($tt->getDuration());
                     }
                 } else {
                     $jobid = $tt->getJobId();
                     if (!array_key_exists($jobid, $loadPerJobs)) {
                         // create job if not exist in jobList
                         $loadPerJobs[$jobid] = array('name' => htmlentities($jobs->getJobName($jobid), ENT_QUOTES | ENT_HTML401, "UTF-8"), 'color' => $jobs->getJobColor($jobid), 'nbDays' => floatval($tt->getDuration()));
                     } else {
                         $loadPerJobs[$jobid]['nbDays'] += floatval($tt->getDuration());
                     }
                 }
             }
         }
     }
     //self::$logger->error("date range: ".date('Y-m-d', $this->startTimestamp).'-'.date('Y-m-d', $this->endTimestamp));
     //self::$logger->error("real date range: ".date('Y-m-d', $realStartTimestamp).'-'.date('Y-m-d', $realEndTimestamp));
     // array sort to put sideTasks categories at the bottom
     ksort($loadPerJobs);
     $this->execData = array('loadPerJobs' => $loadPerJobs, 'realStartTimestamp' => $realStartTimestamp, 'realEndTimestamp' => $realEndTimestamp);
     return $this->execData;
 }
开发者ID:fg-ok,项目名称:codev,代码行数:69,代码来源:LoadPerJobIndicator2.class.php

示例2: getMonth

 /**
  * @param int $month
  * @param int $year
  * @param Issue $issue The issue
  * @param TimeTrack[] $trackList
  * @return mixed[]
  */
 private function getMonth($month, $year, Issue $issue, array $trackList)
 {
     $totalDuration = 0;
     // if no work done this month, do not display month
     $found = 0;
     foreach ($trackList as $tt) {
         if ($month == date('m', $tt->getDate()) && $year == date('Y', $tt->getDate())) {
             $found += 1;
             $totalDuration += $tt->getDuration();
         }
     }
     if (0 == $found) {
         return NULL;
     }
     $monthTimestamp = mktime(0, 0, 0, $month, 1, $year);
     $monthFormated = Tools::formatDate("%B %Y", $monthTimestamp);
     $nbDaysInMonth = date("t", $monthTimestamp);
     $months = array();
     for ($i = 1; $i <= $nbDaysInMonth; $i++) {
         if ($i < 10) {
             $months[] = "0" . $i;
         } else {
             $months[] = $i;
         }
     }
     $jobs = new Jobs();
     $userList = $issue->getInvolvedUsers();
     $users = NULL;
     $timeTracks = $issue->getTimeTracks();
     foreach ($userList as $uid => $username) {
         $userTotalDuration = 0;
         // build $durationByDate[] for this user
         $durationByDate = array();
         $jobColorByDate = array();
         foreach ($timeTracks as $tt) {
             if ($tt->getUserId() == $uid) {
                 $date = $tt->getDate();
                 if (array_key_exists($date, $durationByDate)) {
                     $durationByDate[$date] += $tt->getDuration();
                 } else {
                     $durationByDate[$date] = $tt->getDuration();
                 }
                 $jobColorByDate[$date] = $jobs->getJobColor($tt->getJobId());
             }
         }
         $usersDetails = NULL;
         for ($i = 1; $i <= $nbDaysInMonth; $i++) {
             $todayTimestamp = mktime(0, 0, 0, $month, $i, $year);
             if (array_key_exists($todayTimestamp, $durationByDate)) {
                 $userTotalDuration += $durationByDate[$todayTimestamp];
                 $usersDetails[] = array("jobColor" => $jobColorByDate[$todayTimestamp], "jobDuration" => $durationByDate[$todayTimestamp]);
             } else {
                 // if weekend or holiday, display gray
                 $holidays = Holidays::getInstance();
                 $h = $holidays->isHoliday($todayTimestamp);
                 if (NULL != $h) {
                     $usersDetails[] = array("jobColor" => Holidays::$defaultColor, "jobDescription" => $h->description);
                 } else {
                     $usersDetails[] = array();
                 }
             }
         }
         $users[] = array("username" => $username, "jobs" => $usersDetails, 'totalDuration' => 0 == $userTotalDuration ? '' : $userTotalDuration);
     }
     return array("monthFormated" => $monthFormated, "totalDuration" => $totalDuration, "months" => $months, "users" => $users);
 }
开发者ID:dfuzeau,项目名称:codev,代码行数:73,代码来源:issue_info.php


注:本文中的Jobs::getJobColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。