/** * Get time drift of an issue * @param Issue $issue The issue * @return mixed[] */ private function getTimeDrift(Issue $issue) { $timeDriftSmarty = array(); $deadline = $issue->getDeadLine(); if (!is_null($deadline) && 0 != $deadline) { $timeDriftSmarty["deadLine"] = Tools::formatDate("%d %b %Y", $deadline); } $tooltipAttr = array(); if (NULL != $issue->getDeliveryDate()) { //$timeDriftSmarty["deliveryDate"] = Tools::formatDate("%d %b %Y", $issue->getDeliveryDate()); $tooltipAttr[T_('DeliveryDate')] = Tools::formatDate("%d %b %Y", $issue->getDeliveryDate()); $btImage = 'images/b_markAsRead.png'; } $timeDrift = $issue->getTimeDrift(); if (!is_string($timeDrift)) { $tooltipAttr[T_('DriftColor')] = $issue->getDriftColor($timeDrift); $tooltipAttr[T_('Drift')] = round($timeDrift); if (round($timeDrift) > 0) { $btImage = 'images/b_error.png'; } } if (0 !== count($tooltipAttr)) { $tooltip = Tools::imgWithTooltip($btImage, $tooltipAttr); $timeDriftSmarty["tooltip"] = $tooltip; } return $timeDriftSmarty; }
private function getMonthlyActivityReport(array $tracks) { $userList = array(); // first is 'All', then one per user #$userList['0'] = array(); // All users together foreach ($tracks as $t) { $userid = $t->getUserId(); $bugid = $t->getIssueId(); if (!array_key_exists($userid, $userList)) { $user = UserCache::getInstance()->getUser($userid); $userList["{$userid}"] = array('name' => $user->getName(), 'realname' => $user->getRealname(), 'elapsedInPeriod' => 0, 'tasks' => array()); #echo "new user $userid<br>"; } if (!array_key_exists($bugid, $userList["{$userid}"]['tasks'])) { try { $issue = IssueCache::getInstance()->getIssue($bugid); $project = ProjectCache::getInstance()->getProject($issue->getProjectId()); if (!$project->isSideTasksProject(array($this->teamid)) && !$project->isExternalTasksProject()) { $tooltipAttr = $issue->getTooltipItems($this->teamid, $this->session_userid); $infoTooltip = Tools::imgWithTooltip('images/b_info.png', $tooltipAttr); $progress = round(100 * $issue->getProgress()); $backlog = $issue->getBacklog(); } else { $infoTooltip = NULL; $progress = NULL; $backlog = NULL; } $projectName = $issue->getProjectName(); $summary = SmartyTools::getIssueDescription($bugid, $issue->getTcId(), $issue->getSummary()); } catch (Exception $e) { $infoTooltip = NULL; $progress = NULL; $backlog = NULL; $projectName = '<span class="error_font">' . T_('Error') . '</span>'; $summary = $bugid . ' : <span class="error_font">' . T_('Error: Task not found in Mantis DB !') . '</span>'; } $userList["{$userid}"]['tasks']["{$bugid}"] = array('id' => $bugid, 'infoTooltip' => $infoTooltip, 'projectName' => $projectName, 'summary' => $summary, 'progress' => $progress, 'backlog' => $backlog, 'elapsedInPeriod' => 0); #echo "new UserTask $bugid : ".$issue->getSummary()."<br>"; } $userList["{$userid}"]['tasks']["{$bugid}"]['elapsedInPeriod'] += $t->getDuration(); $userList["{$userid}"]['elapsedInPeriod'] += $t->getDuration(); #echo "user $userid task $bugid elapsedInPeriod = ".$userList["$userid"]['tasks']["$bugid"]['elapsedInPeriod'].'<br>'; } #var_dump($userList); return $userList; }
private function getIssueNoteTooltip($project, $team, $issue) { // prepare json data for the IssueNoteDialogbox if (!$project->isSideTasksProject(array($team->getId())) && !$project->isExternalTasksProject()) { $issueNote = IssueNote::getTimesheetNote($issue->getId()); if (!is_null($issueNote)) { $issueNoteId = $issueNote->getId(); $user = UserCache::getInstance()->getUser($issueNote->getReporterId()); $rawNote = $issueNote->getText(); $note = trim(IssueNote::removeAllReadByTags($rawNote)); // used for the tooltip NOT the dialoBox $tooltipAttr = array('reporter' => $user->getRealname(), 'date' => date('Y-m-d H:i', $issueNote->getLastModified()), 'Note' => $note); $readByList = $issueNote->getReadByList(TRUE); if (0 != count($readByList)) { $tooltipAttr['Read by'] = implode(', ', array_keys($readByList)); } $noteTooltip = Tools::imgWithTooltip('images/b_note.png', $tooltipAttr, "bugNote_" . $issueNote->getBugId()); } else { $issueNoteId = 0; $noteTooltip = ''; } } else { $issueNoteId = 0; $noteTooltip = ''; } return array('id' => $issueNoteId, 'tooltip' => $noteTooltip); }
/** * @param int[] $weekDates * @param int $userid * @param TimeTracking $timeTracking * @param array $incompleteDays * @return mixed[] */ public static function getWeekTask(array $weekDates, $teamid, $userid, TimeTracking $timeTracking, array $incompleteDays) { $totalElapsed = array(); $todayAtMidnight = mktime(0, 0, 0); for ($i = 1; $i <= 7; $i++) { $weekDate = $weekDates[$i]; $totalElapsed[$weekDate] = array("elapsed" => 0, "class" => in_array($weekDate, $incompleteDays) && $weekDate < $todayAtMidnight ? "incompleteDay" : ""); } $jobs = new Jobs(); $weekTasks = NULL; $holidays = Holidays::getInstance(); $weekTracks = $timeTracking->getWeekDetails($userid); foreach ($weekTracks as $bugid => $jobList) { try { $issue = IssueCache::getInstance()->getIssue($bugid); $backlog = $issue->getBacklog(); $extRef = $issue->getTcId(); $summary = $issue->getSummary(); $description = SmartyTools::getIssueDescription($bugid, $extRef, $summary); $projectId = $issue->getProjectId(); } catch (Exception $e) { $backlog = '!'; $extRef = ''; $summary = '<span class="error_font">' . T_('Error: Task not found in Mantis DB !') . '</span>'; //$description = SmartyTools::getIssueDescription($bugid,$extRef,$summary); $description = Tools::mantisIssueURL($bugid, NULL, TRUE) . ' ' . $bugid . ' : ' . $summary; $projectId = -1; } foreach ($jobList as $jobid => $dayList) { // if no backlog set, display a '?' to allow Backlog edition if (is_numeric($backlog)) { $formattedBacklog = $backlog; // prepare json data for the BacklogDialogbox $jsonIssueInfo = self::getUpdateBacklogJsonData($bugid, $jobid, $teamid, $userid); } else { #if (($team->isSideTasksProject($issue->projectId)) || # ($team->isNoStatsProject($issue->projectId))) { // do not allow to edit sideTasks Backlog $formattedBacklog = ''; $jsonIssueInfo = ''; #} else { # $formattedBacklog = '?'; #} // } $dayTasks = ""; for ($i = 1; $i <= 7; $i++) { $title = NULL; $bgColor = NULL; if ($i <= 5) { $h = $holidays->isHoliday($weekDates[$i]); if ($h) { $bgColor = $h->color; #$bgColor = Holidays::$defaultColor; $title = $h->description; } } else { $bgColor = Holidays::$defaultColor; } $day = 0; if (array_key_exists($i, $dayList)) { $day = $dayList[$i]; } $dayTasks[] = array('bgColor' => $bgColor, 'title' => $title, 'day' => $day); $totalElapsed[$weekDates[$i]]['elapsed'] += $day; } /* $deadline = $issue->getDeadLine(); if (!is_null($deadline) || (0 != $deadline)) { $formatedDate = Tools::formatDate(T_("%Y-%m-%d"), $deadline); } */ try { $project = ProjectCache::getInstance()->getProject($projectId); } catch (Exception $e) { $project = null; } if ($project != null) { if (!$project->isSideTasksProject(array($teamid)) && !$project->isExternalTasksProject()) { // TODO does $issue belong to current team's project ? what if not ? $tooltipAttr = $issue->getTooltipItems($teamid, $userid); $infoTooltip = Tools::imgWithTooltip('images/b_info.png', $tooltipAttr); } else { $infoTooltip = ''; } } else { $infoTooltip = ''; } // prepare json data for the IssueNoteDialogbox if ($project != null) { if (!$project->isSideTasksProject(array($teamid)) && !$project->isExternalTasksProject()) { $issueNote = IssueNote::getTimesheetNote($issue->getId()); if (!is_null($issueNote)) { $issueNoteId = $issueNote->getId(); $user = UserCache::getInstance()->getUser($issueNote->getReporterId()); $rawNote = $issueNote->getText(); $note = trim(IssueNote::removeAllReadByTags($rawNote)); // used for the tooltip NOT the dialoBox $tooltipAttr = array('reporter' => $user->getRealname(), 'date' => date('Y-m-d H:i:s', $issueNote->getLastModified()), 'Note' => $note); $readByList = $issueNote->getReadByList(TRUE); if (0 != count($readByList)) { $tooltipAttr['Read by'] = implode(', ', array_keys($readByList)); } $noteTooltip = Tools::imgWithTooltip('images/b_note.png', $tooltipAttr, NULL, 'js-add-note-link', ' style="cursor: pointer;" data-bugId="' . $issueNote->getBugId() . '"'); } else { $issueNoteId = 0; $noteTooltip = Tools::imgWithTooltip('images/b_note_grey.png', T_('Click to add a note'), NULL, 'js-add-note-link', ' style="cursor: pointer;" data-bugId="' . $issue->getId() . '"'); } } else { $noteTooltip = ''; } } else { $noteTooltip = ''; } // if project not declared in current team, then // user cannot add a timetrack by clicking in the weekTasks table // Note: (this would generate an error on addTimetrack) $team = TeamCache::getInstance()->getTeam($teamid); $isTeamProject = !is_null($team->getProjectType($projectId)); $weekTasks[$bugid . "_" . $jobid] = array('bugid' => $bugid, 'description' => $description, 'formattedBacklog' => $formattedBacklog, 'jobid' => $jobid, 'jobName' => $jobs->getJobName($jobid), 'dayTasks' => $dayTasks, 'infoTooltip' => $infoTooltip, 'summary' => addslashes(htmlspecialchars($summary)), 'updateBacklogJsonData' => $jsonIssueInfo, 'issueNoteId' => $issueNoteId, 'noteTooltip' => $noteTooltip, 'isTeamProject' => $isTeamProject); } } return array("weekTasks" => $weekTasks, "totalElapsed" => $totalElapsed); }