public function indexAction() { echo 'Test'; $aa = file_get_contents('/home/zhanghe/code/php/phalcon/app/library/rsa_1024_pub.pem'); echo $aa . '<br/>'; echo Tools::formatDate() . '<br/>'; echo Tools::realIp() . '<br/>'; //echo Tools::validateLogin().'<br/>'; die; }
protected function display() { if (Tools::isConnectedUser()) { // only teamMembers & observers can access this page if (0 == $this->teamid || $this->session_user->isTeamCustomer($this->teamid)) { $this->smartyHelper->assign('accessDenied', TRUE); } else { $team = TeamCache::getInstance()->getTeam($this->teamid); $formatedteamName = str_replace(" ", "_", $team->getName()); // dates $month = date('m'); $year = date('Y'); // The first day of the current month $startdate = Tools::getSecurePOSTStringValue("startdate", Tools::formatDate("%Y-%m-%d", mktime(0, 0, 0, $month, 1, $year))); $this->smartyHelper->assign('startDate', $startdate); $startTimestamp = Tools::date2timestamp($startdate); // The current date plus one year $nbDaysInMonth = date("t", mktime(0, 0, 0, $month, 1, $year)); $enddate = Tools::getSecurePOSTStringValue("enddate", Tools::formatDate("%Y-%m-%d", mktime(23, 59, 59, $month, $nbDaysInMonth, $year))); $this->smartyHelper->assign('endDate', $enddate); $endTimestamp = Tools::date2timestamp($enddate); $endTimestamp += 24 * 60 * 60 - 1; // + 1 day -1 sec. if ('computeCsvMonthly' == $_POST['action']) { $timeTracking = new TimeTracking($startTimestamp, $endTimestamp, $this->teamid); $myFile = Constants::$codevOutputDir . DIRECTORY_SEPARATOR . 'reports' . DIRECTORY_SEPARATOR . $formatedteamName . "_Mantis_" . date("Ymd") . ".csv"; ExportCsvTools::exportManagedIssuesToCSV($this->teamid, $startTimestamp, $endTimestamp, $myFile); $this->smartyHelper->assign('managedIssuesToCSV', basename($myFile)); $myFile = Constants::$codevOutputDir . DIRECTORY_SEPARATOR . 'reports' . DIRECTORY_SEPARATOR . $formatedteamName . "_Projects_" . date("Ymd", $timeTracking->getStartTimestamp()) . "-" . date("Ymd", $timeTracking->getEndTimestamp()) . ".csv"; $this->exportProjectMonthlyActivityToCSV($timeTracking, $myFile); $this->smartyHelper->assign('projectMonthlyActivityToCSV', basename($myFile)); // reduce scope to enhance speed $reports = array(); for ($i = 1; $i <= 12; $i++) { $reports[] = basename(ExportCsvTools::exportHolidaystoCSV($i, $year, $this->teamid, $formatedteamName, Constants::$codevOutputDir . DIRECTORY_SEPARATOR . 'reports')); } $this->smartyHelper->assign('reports', $reports); $this->smartyHelper->assign('reportsDir', Constants::$codevOutputDir . DIRECTORY_SEPARATOR . 'reports'); } } } }
protected function display() { if (Tools::isConnectedUser()) { // only teamMembers & observers can access this page if (0 == $this->teamid || $this->session_user->isTeamCustomer($this->teamid)) { $this->smartyHelper->assign('accessDenied', TRUE); } else { $isManager = $this->session_user->isTeamManager($this->teamid); $isObserver = $this->session_user->isTeamObserver($this->teamid); if ($isManager || $isObserver) { // observers have access to the same info $this->smartyHelper->assign('isManager', true); } // dates $month = date('m'); $year = date('Y'); $startdate = Tools::getSecurePOSTStringValue("startdate", Tools::formatDate("%Y-%m-%d", mktime(0, 0, 0, $month, 1, $year))); $this->smartyHelper->assign('startDate', $startdate); $startTimestamp = Tools::date2timestamp($startdate); $nbDaysInMonth = date("t", $startTimestamp); $enddate = Tools::getSecurePOSTStringValue("enddate", Tools::formatDate("%Y-%m-%d", mktime(0, 0, 0, $month, $nbDaysInMonth, $year))); $this->smartyHelper->assign('endDate', $enddate); $endTimestamp = Tools::date2timestamp($enddate); #$isDetailed = Tools::getSecurePOSTStringValue('cb_detailed',''); #$this->smartyHelper->assign('isDetailed', $isDetailed); if ('computeMonthlyActivityReport' == $_POST['action']) { $timeTracking = new TimeTracking($startTimestamp, $endTimestamp, $this->teamid); $tracks = $timeTracking->getTimeTracks(); $this->smartyHelper->assign('monthlyActivityReport', $this->getMonthlyActivityReport($tracks)); // ConsistencyCheck $consistencyErrors = $this->getConsistencyErrors($timeTracking); if (count($consistencyErrors) > 0) { $this->smartyHelper->assign('ccheckErrList', $consistencyErrors); $this->smartyHelper->assign('ccheckButtonTitle', count($consistencyErrors) . ' ' . T_("Errors")); $this->smartyHelper->assign('ccheckBoxTitle', count($consistencyErrors) . ' ' . T_("days are incomplete or undefined")); } } } } }
protected function display() { if (Tools::isConnectedUser()) { // only teamMembers & observers can access this page if (0 == $this->teamid || $this->session_user->isTeamCustomer($this->teamid)) { $this->smartyHelper->assign('accessDenied', TRUE); } else { // dates $weekDates = Tools::week_dates(date('W'), date('Y')); $startdate = Tools::getSecurePOSTStringValue("startdate", Tools::formatDate("%Y-%m-%d", $weekDates[1])); $this->smartyHelper->assign('startDate', $startdate); $enddate = Tools::getSecurePOSTStringValue("enddate", Tools::formatDate("%Y-%m-%d", $weekDates[5])); $this->smartyHelper->assign('endDate', $enddate); $isDetailed = Tools::getSecurePOSTIntValue('withJobDetails', 0); $this->smartyHelper->assign('isJobDetails', $isDetailed); $isExtTasksPrj = Tools::getSecurePOSTIntValue('withExtTasksPrj', 0); $this->smartyHelper->assign('isExtTasksPrj', $isExtTasksPrj); $isSideTasksPrj = Tools::getSecurePOSTIntValue('withSideTasksPrj', 1); $this->smartyHelper->assign('isSideTasksPrj', $isSideTasksPrj); if ('computeProjectActivityReport' == $_POST['action']) { $startTimestamp = Tools::date2timestamp($startdate); $endTimestamp = Tools::date2timestamp($enddate); $endTimestamp = mktime(23, 59, 59, date('m', $endTimestamp), date('d', $endTimestamp), date('Y', $endTimestamp)); $timeTracking = new TimeTracking($startTimestamp, $endTimestamp, $this->teamid); $this->smartyHelper->assign('projectActivityReport', $this->getProjectActivityReport($timeTracking->getProjectTracks(true), $this->teamid, $isDetailed)); // WorkingDaysPerProjectPerUser $data = $timeTracking->getWorkingDaysPerProjectPerUser($isExtTasksPrj, true, $isSideTasksPrj); foreach ($data as $smartyKey => $smartyVariable) { $this->smartyHelper->assign($smartyKey, $smartyVariable); } $data = $this->getWorkingDaysPerProjectPerUser($startTimestamp, $endTimestamp, $isExtTasksPrj, $isSideTasksPrj); foreach ($data as $smartyKey => $smartyVariable) { $this->smartyHelper->assign($smartyKey, $smartyVariable); } } } } }
protected function display() { if (Tools::isConnectedUser()) { $session_user = UserCache::getInstance()->getUser($_SESSION['userid']); $mTeamList = $session_user->getDevTeamList(); $lTeamList = $session_user->getLeadedTeamList(); $oTeamList = $session_user->getObservedTeamList(); $managedTeamList = $session_user->getManagedTeamList(); $teamList = $mTeamList + $lTeamList + $oTeamList + $managedTeamList; $defaultTeam = isset($_SESSION['teamid']) ? $_SESSION['teamid'] : 0; $teamid = Tools::getSecureGETIntValue('teamid', $defaultTeam); $_SESSION['teamid'] = $teamid; $this->smartyHelper->assign('teams', SmartyTools::getSmartyArray($teamList, $teamid)); // if current team is not in allowed list, do not display if (array_key_exists($teamid, $teamList)) { $team = TeamCache::getInstance()->getTeam($teamid); $start_year = date("Y", $team->getDate()); $start_month = date("m", $team->getDate()); $start_day = date("d", $team->getDate()); $statusNames = Config::getInstance()->getValue("statusNames"); ksort($statusNames); $this->smartyHelper->assign('statusNames', $statusNames); $periodStatsReport = new PeriodStatsReport($start_year, $start_month, $start_day, $teamid); $periodStatsList = $periodStatsReport->computeReport(); $periods = array(); foreach ($periodStatsList as $date => $ps) { $status = array(); foreach ($statusNames as $s => $sname) { $status[$s] = $ps->getStatusCount($s); } $periods[Tools::formatDate("%B %Y", $date)] = $status; } $this->smartyHelper->assign('periods', $periods); } } }
protected function display() { if (Tools::isConnectedUser()) { // only teamMembers & observers can access this page if (0 == $this->teamid || $this->session_user->isTeamCustomer($this->teamid)) { $this->smartyHelper->assign('accessDenied', TRUE); } else { $projects[0] = T_('All projects'); $projects += TeamCache::getInstance()->getTeam($this->teamid)->getProjects(false); $projectid = 0; if (isset($_POST['projectid']) && array_key_exists($_POST['projectid'], $projects)) { $projectid = Tools::getSecurePOSTIntValue('projectid'); $_SESSION['projectid'] = $_POST['projectid']; } else { if (isset($_SESSION['projectid']) && array_key_exists($_SESSION['projectid'], $projects)) { $projectid = $_SESSION['projectid']; } } $this->smartyHelper->assign('projects', SmartyTools::getSmartyArray($projects, $projectid)); // The first day of the current week $weekDates = Tools::week_dates(date('W'), date('Y')); $startdate = Tools::getSecurePOSTStringValue('startdate', Tools::formatDate("%Y-%m-%d", $weekDates[1])); $this->smartyHelper->assign('startDate', $startdate); // The current date plus one year $enddate = Tools::getSecurePOSTStringValue('enddate', Tools::formatDate("%Y-%m-%d", strtotime('+6 month'))); $this->smartyHelper->assign('endDate', $enddate); if ('computeGantt' == $_POST['action']) { $startT = Tools::date2timestamp($startdate); $endT = Tools::date2timestamp($enddate); #$endT += 24 * 60 * 60 -1; // + 1 day -1 sec. // draw graph $this->smartyHelper->assign('urlGraph', 'teamid=' . $this->teamid . '&projects=' . $projectid . '&startT=' . $startT . '&endT=' . $endT); } } } }
public function getSmartyVariables($isAjaxCall = false) { $totalLoad = 0; foreach ($this->execData as $duration) { $totalLoad += $duration; } // table data $tableData = array('projectLoad' => $this->execData, 'totalLoad' => $totalLoad, 'workdays' => Holidays::getInstance()->getWorkdays($this->startTimestamp, $this->endTimestamp)); // ------------------------ // pieChart data $jqplotData = Tools::array2plot($this->execData); $smartyVariables = array('loadPerProjectIndicator_tableData' => $tableData, 'loadPerProjectIndicator_jqplotData' => empty($jqplotData) ? NULL : $jqplotData, 'loadPerProjectIndicator_startDate' => Tools::formatDate("%Y-%m-%d", $this->startTimestamp), 'loadPerProjectIndicator_endDate' => Tools::formatDate("%Y-%m-%d", $this->endTimestamp)); if (false == $isAjaxCall) { $smartyVariables['loadPerProjectIndicator_ajaxFile'] = self::getSmartySubFilename(); $smartyVariables['loadPerProjectIndicator_ajaxPhpURL'] = self::getAjaxPhpURL(); } return $smartyVariables; }
public function getSmartyVariables($isAjaxCall = false) { $loadPerJobs = $this->execData['loadPerJobs']; $data = array(); $formatedColors = array(); foreach ($loadPerJobs as $jobItem) { $data[$jobItem['name']] = $jobItem['nbDays']; $formatedColors[] = '#' . $jobItem['color']; } $seriesColors = '["' . implode('","', $formatedColors) . '"]'; // ["#FFCD85","#C2DFFF"] $startTimestamp = NULL == $this->startTimestamp ? $this->execData['realStartTimestamp'] : $this->startTimestamp; $endTimestamp = NULL == $this->endTimestamp ? $this->execData['realEndTimestamp'] : $this->endTimestamp; $smartyVariables = array('loadPerJobIndicator_tableData' => $loadPerJobs, 'loadPerJobIndicator_jqplotData' => empty($data) ? NULL : Tools::array2json($data), 'loadPerJobIndicator_colors' => $formatedColors, 'loadPerJobIndicator_jqplotSeriesColors' => $seriesColors, 'loadPerJobIndicator_startDate' => Tools::formatDate("%Y-%m-%d", $startTimestamp), 'loadPerJobIndicator_endDate' => Tools::formatDate("%Y-%m-%d", $endTimestamp)); if (false == $isAjaxCall) { $smartyVariables['loadPerJobIndicator_ajaxFile'] = self::getSmartySubFilename(); $smartyVariables['loadPerJobIndicator_ajaxPhpURL'] = self::getAjaxPhpURL(); } return $smartyVariables; }
/** * @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); }
/** * Get days of a month * @param int $nbDaysInMonth The number of days in a month * @param int $month The month * @param int $year The year * @return mixed[int] */ function getDays($nbDaysInMonth, $month, $year) { $today = date("d-m-Y"); $days = array(); for ($i = 1; $i <= $nbDaysInMonth; $i++) { $curDate = mktime(0, 0, 0, $month, $i, $year); if ($today == date("d-m-Y", $curDate)) { $title = T_('today'); } else { $title = Tools::formatDate("%A", $curDate); } $days[sprintf("%02d", $i)] = array('title' => $title, 'selected' => $today == date("d-m-Y", $curDate)); } return $days; }
/** * * @param boolean $isAjaxCall * @return array */ public function getSmartyVariables($isAjaxCall = false) { $team = TeamCache::getInstance()->getTeam($this->teamid); $teamProjects = $team->getProjects(false, true, true); $teamProjects['allSidetasksProjects'] = '-- ' . T_('All Sidetasks Projects') . ' --'; $teamProjects['allProdProjects'] = '-- ' . T_('All Production Projects') . ' --'; $teamProjects['allProjects'] = '-- ' . T_('All Projects') . ' --'; $projects = SmartyTools::getSmartyArray($teamProjects, $this->selectedProject); //self::$logger->error(var_export($projects, true)); $data = array(); foreach ($this->execData as $catInfo) { if (0 != $catInfo['duration']) { $data[$catInfo['catName']] = $catInfo['duration']; } } $jqplotData = empty($data) ? NULL : Tools::array2plot($data); $smartyVariables = array('loadPerProjCategoryIndicator_startDate' => Tools::formatDate("%Y-%m-%d", $this->startTimestamp), 'loadPerProjCategoryIndicator_endDate' => Tools::formatDate("%Y-%m-%d", $this->endTimestamp), 'loadPerProjCategoryIndicator_projects' => $projects, 'loadPerProjCategoryIndicator_tableData' => $this->execData, 'loadPerProjCategoryIndicator_jqplotData' => $jqplotData, 'loadPerProjCategoryIndicator_' . self::OPTION_DISPLAY_TASKS => $this->isDisplayTasks); if (false == $isAjaxCall) { $smartyVariables['loadPerProjCategoryIndicator_ajaxFile'] = self::getSmartySubFilename(); $smartyVariables['loadPerProjCategoryIndicator_ajaxPhpURL'] = self::getAjaxPhpURL(); } return $smartyVariables; }
/** * * @param boolean $isAjaxCall * @return array */ public function getSmartyVariables($isAjaxCall = false) { $availableTeams = SmartyTools::getSmartyArray($this->execData['teamList'], $this->displayedTeam); $smartyVariables = array('timetrackDetailsIndicator_availableTeams' => $availableTeams, 'timetrackDetailsIndicator_startDate' => Tools::formatDate("%Y-%m-%d", $this->execData['startTimestamp']), 'timetrackDetailsIndicator_endDate' => Tools::formatDate("%Y-%m-%d", $this->execData['endTimestamp']), 'timetrackDetailsIndicator_timetracks' => $this->execData['timetracks'], 'timetrackDetailsIndicator_' . self::OPTION_DISPLAYED_TEAM => $this->displayedTeam); if (false == $isAjaxCall) { $smartyVariables['timetrackDetailsIndicator_ajaxFile'] = self::getSmartySubFilename(); $smartyVariables['timetrackDetailsIndicator_ajaxPhpURL'] = self::getAjaxPhpURL(); } return $smartyVariables; }
/** * @param SmartyHelper $smartyHelper * @param CommandSet $commandset */ public static function displayCommandSet(SmartyHelper $smartyHelper, CommandSet $commandset, $isManager, $selectedFilters = '') { #$smartyHelper->assign('commandsetId', $commandset->getId()); $smartyHelper->assign('teamid', $commandset->getTeamid()); $smartyHelper->assign('commandsetName', $commandset->getName()); $smartyHelper->assign('commandsetReference', $commandset->getReference()); $smartyHelper->assign('commandsetDesc', $commandset->getDesc()); $smartyHelper->assign('commandsetBudget', $commandset->getBudgetDays()); $smartyHelper->assign('commandsetCost', $commandset->getCost()); $smartyHelper->assign('commandsetCurrency', $commandset->getCurrency()); if (!is_null($commandset->getDate())) { $smartyHelper->assign('commandsetDate', Tools::formatDate("%Y-%m-%d", $commandset->getDate())); } $smartyHelper->assign('cmdList', self::getCommandSetCommands($commandset->getId(), Command::type_general)); $smartyHelper->assign('cmdsetDetailedMgr', self::getCommandSetDetailedMgr($commandset->getId(), Command::type_general)); // Budget $cmdList = $commandset->getCommands(Command::type_general); $cmdsProvAndMeeCost = 0; foreach ($cmdList as $cmd) { // TODO math should not be in here ! $mgrEE = $cmd->getIssueSelection()->mgrEffortEstim; $cmdProvAndMeeCost = $mgrEE * $cmd->getAverageDailyRate() + $cmd->getProvisionBudget(TRUE); $cmdsProvAndMeeCost += $cmdProvAndMeeCost; } $smartyHelper->assign('cmdsProvAndMeeCost', $cmdsProvAndMeeCost); $color1 = $cmdProvAndMeeCost > $commandset->getCost() ? "fcbdbd" : "bdfcbd"; $smartyHelper->assign('cmdsProvAndMeeCostColor', $color1); //$cmdTotalElapsed = $commandset->getIssueSelection()->getElapsed($cmd->$commandset(), $commandset->getDeadline()); $csetTotalElapsed = $commandset->getIssueSelection(Command::type_general)->getElapsed(); $smartyHelper->assign('commandsetTotalElapsed', $csetTotalElapsed); $smartyHelper->assign('cmdProvisionList', self::getProvisionList($commandset)); $smartyHelper->assign('cmdProvisionTotalList', self::getProvisionTotalList($commandset)); // DetailedChargesIndicator $data = self::getDetailedCharges($commandset, $isManager, $selectedFilters); foreach ($data as $smartyKey => $smartyVariable) { $smartyHelper->assign($smartyKey, $smartyVariable); } }
/** * * @return type */ public function getSmartyVariables($isAjaxCall = false) { $theoBacklog = $this->execData['theo']; $realBacklog = $this->execData['real']; $startTimestamp = $this->startTimestamp; $endTimestamp = strtotime(date("Y-m-d", $this->endTimestamp) . " +1 month"); $interval = ceil($this->interval / 20); // TODO why 20 ? $graphData = "[" . Tools::array2plot($theoBacklog) . ',' . Tools::array2plot($realBacklog) . "]"; $smartyVariables = array('progressHistoryIndicator2_jqplotData' => $graphData, 'progressHistoryIndicator2_plotMinDate' => Tools::formatDate("%Y-%m-%d", $startTimestamp), 'progressHistoryIndicator2_plotMaxDate' => Tools::formatDate("%Y-%m-%d", $endTimestamp), 'progressHistoryIndicator2_plotInterval' => $interval, 'progressHistoryIndicator2_' . self::OPTION_INTERVAL => $this->interval); if (false == $isAjaxCall) { $smartyVariables['progressHistoryIndicator2_ajaxFile'] = self::getSmartySubFilename(); $smartyVariables['progressHistoryIndicator2_ajaxPhpURL'] = self::getAjaxPhpURL(); } return $smartyVariables; }
/** * Get holidays * @static * @return mixed[int] */ public static function getHolidays() { $query = 'SELECT * FROM `codev_holidays_table` ORDER BY date DESC'; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { return NULL; } $holidays = array(); while ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) { $holidays[$row->id] = array("date" => Tools::formatDate("%d %b %Y (%a)", $row->date), "desc" => $row->description, "color" => $row->color); } return $holidays; }
/** * @param TimeTracking $timeTracking * @param bool $isDetailed * @param int[] $weekDates * @return mixed[] */ private function getWeekDetails(TimeTracking $timeTracking, $isDetailed, $weekDates, $session_userid) { $team = TeamCache::getInstance()->getTeam($timeTracking->getTeamid()); $weekDetails = array(); $session_users = $team->getUsers(); foreach ($session_users as $session_user) { // if user was working on the project during the timestamp if ($session_user->isTeamDeveloper($timeTracking->getTeamid(), $timeTracking->getStartTimestamp(), $timeTracking->getEndTimestamp()) || $session_user->isTeamManager($timeTracking->getTeamid(), $timeTracking->getStartTimestamp(), $timeTracking->getEndTimestamp())) { // PERIOD week //$thisWeekId=date("W"); $weekTracks = $timeTracking->getWeekDetails($session_user->getId(), !$isDetailed); $holidays = Holidays::getInstance(); $weekJobDetails = array(); foreach ($weekTracks as $bugid => $jobList) { try { $issue = IssueCache::getInstance()->getIssue($bugid); } catch (Exception $e) { self::$logger->error("getWeekDetails() skip issue {$bugid} : " . $e->getMessage()); $weekJobDetails[] = array("description" => '<span class="error_font">' . $bugid . ' : ' . T_('Error: Task not found in Mantis DB !') . '</span>', "duration" => "!", "progress" => "!", "projectName" => "!", "targetVersion" => "!", "jobName" => "!", "daysDetails" => "!", "totalDuration" => "!"); continue; } $project = ProjectCache::getInstance()->getProject($issue->getProjectId()); if ($isDetailed) { $formatedJobList = implode(', ', array_keys($jobList)); $query = 'SELECT id, name FROM `codev_job_table` WHERE id IN (' . $formatedJobList . ');'; $result2 = SqlWrapper::getInstance()->sql_query($query); if (!$result2) { continue; } while ($row2 = SqlWrapper::getInstance()->sql_fetch_object($result2)) { $jobName = $row2->name; $dayList = $jobList[$row2->id]; $daysDetails = array(); $weekDuration = 0; for ($i = 1; $i <= 7; $i++) { $dayDetails = $this->getDaysDetails($i, $holidays, $weekDates, $dayList[$i]); $weekDuration += $dayDetails['duration']; $daysDetails[] = $dayDetails; } if (!$project->isSideTasksProject(array($team->getId())) && !$project->isExternalTasksProject()) { $tooltipAttr = $issue->getTooltipItems($team->getId(), $session_userid); // force some fields #$tooltipAttr[T_('Elapsed')] = $issue->getElapsed(); #$tooltipAttr[T_('Backlog')] = $issue->getDuration(); #$tooltipAttr[T_('Drift')] = $issue->getDrift(); #$tooltipAttr[T_('DriftColor')] = $issue->getDriftColor(); $infoTooltip = Tools::imgWithTooltip('images/b_info.png', $tooltipAttr); } else { $infoTooltip = NULL; } // prepare json data for the IssueNoteDialogbox $issueNoteData = $this->getIssueNoteTooltip($project, $team, $issue); $weekJobDetails[] = array('description' => SmartyTools::getIssueDescription($bugid, $issue->getTcId(), $issue->getSummary()), 'duration' => $issue->getDuration(), 'progress' => round(100 * $issue->getProgress()), 'projectName' => $issue->getProjectName(), 'targetVersion' => $issue->getTargetVersion(), 'jobName' => $jobName, 'daysDetails' => $daysDetails, 'totalDuration' => $weekDuration, 'infoTooltip' => $infoTooltip, 'issueNoteId' => $issueNoteData['id'], 'noteTooltip' => $issueNoteData['tooltip']); } } else { // for each day, concat jobs duration $daysDetails = array(); $weekDuration = 0; for ($i = 1; $i <= 7; $i++) { $duration = 0; foreach ($jobList as $dayList) { if (array_key_exists($i, $dayList)) { $duration += $dayList[$i]; } } if ($duration == 0) { $duration = ""; } $dayDetails = $this->getDaysDetails($i, $holidays, $weekDates, $duration); $weekDuration += $dayDetails['duration']; $daysDetails[] = $dayDetails; } if (!$project->isSideTasksProject(array($team->getId())) && !$project->isExternalTasksProject()) { $tooltipAttr = $issue->getTooltipItems($team->getId(), $session_userid); // force some fields #$tooltipAttr[T_('Elapsed')] = $issue->getElapsed(); #$tooltipAttr[T_('Backlog')] = $issue->getDuration(); #$tooltipAttr[T_('Drift')] = $issue->getDrift(); #$tooltipAttr[T_('DriftColor')] = $issue->getDriftColor(); $infoTooltip = Tools::imgWithTooltip('images/b_info.png', $tooltipAttr); } else { $infoTooltip = NULL; } // prepare json data for the IssueNoteDialogbox $issueNoteData = $this->getIssueNoteTooltip($project, $team, $issue); $weekJobDetails[] = array('description' => SmartyTools::getIssueDescription($bugid, $issue->getTcId(), $issue->getSummary()), 'duration' => $issue->getDuration(), 'progress' => round(100 * $issue->getProgress()), 'projectName' => $issue->getProjectName(), 'daysDetails' => $daysDetails, 'totalDuration' => $weekDuration, 'infoTooltip' => $infoTooltip, 'issueNoteId' => $issueNoteData['id'], 'noteTooltip' => $issueNoteData['tooltip']); } } if (!empty($weekJobDetails)) { $weekDetails[] = array('name' => $session_user->getName(), 'realname' => $session_user->getRealname(), 'forecastWorkload' => $session_user->getForecastWorkload(), 'weekDates' => array(Tools::formatDate("%A\n%d %b", $weekDates[1]), Tools::formatDate("%A\n%d %b", $weekDates[2]), Tools::formatDate("%A\n%d %b", $weekDates[3]), Tools::formatDate("%A\n%d %b", $weekDates[4]), Tools::formatDate("%A\n%d %b", $weekDates[5])), 'weekEndDates' => array(Tools::formatDate("%A\n%d %b", $weekDates[6]), Tools::formatDate("%A\n%d %b", $weekDates[7])), 'weekJobDetails' => $weekJobDetails); } } } return $weekDetails; }
public function getSmartyVariables($isAjaxCall = false) { $usersActivities = array(); $totalLeave = 0; $totalExternal = 0; $totalElapsed = 0; $totalOther = 0; $totalSidetask = 0; foreach ($this->execData as $userid => $userActivity) { $user = UserCache::getInstance()->getUser($userid); $usersActivities[$user->getName()] = $userActivity; if (array_key_exists('leave', $userActivity)) { $totalLeave += $userActivity['leave']; } if (array_key_exists('external', $userActivity)) { $totalExternal += $userActivity['external']; } if (array_key_exists('elapsed', $userActivity)) { $totalElapsed += $userActivity['elapsed']; } if (array_key_exists('other', $userActivity)) { $totalOther += $userActivity['other']; } if ($this->showSidetasks && array_key_exists('sidetask', $userActivity)) { $totalSidetask += $userActivity['sidetask']; } } $totalActivity = array(); $totalActivity['leave'] = $totalLeave; $totalActivity['external'] = $totalExternal; $totalActivity['elapsed'] = $totalElapsed; $totalActivity['other'] = $totalOther; if ($this->showSidetasks) { $totalActivity['sidetask'] += $totalSidetask; } ksort($usersActivities); // table data $tableData = array('usersActivities' => $usersActivities, 'totalActivity' => $totalActivity, 'workdays' => Holidays::getInstance()->getWorkdays($this->startTimestamp, $this->endTimestamp)); // ------------------------ // pieChart data $jqplotData = array(T_('Elapsed') => $totalActivity['elapsed'], T_('Other') => $totalActivity['other'], T_('External') => $totalActivity['external'], T_('Inactivity') => $totalActivity['leave']); $formatedColors = array("#92C5FC", "#C2DFFF", "#75FFDA", "#A8FFBD"); if ($this->showSidetasks) { $jqplotData[T_('Waste')] = $totalActivity['sidetask']; $formatedColors[] = "#FFF494"; } else { } $seriesColors = '["' . implode('","', $formatedColors) . '"]'; // ["#FFCD85","#C2DFFF"] $smartyVariables = array('loadPerUserIndicator_tableData' => $tableData, 'loadPerUserIndicator_jqplotData' => empty($jqplotData) ? NULL : Tools::array2json($jqplotData), 'loadPerUserIndicator_colors' => $formatedColors, 'loadPerUserIndicator_jqplotSeriesColors' => $seriesColors, 'loadPerUserIndicator_startDate' => Tools::formatDate("%Y-%m-%d", $this->startTimestamp), 'loadPerUserIndicator_endDate' => Tools::formatDate("%Y-%m-%d", $this->endTimestamp)); if (false == $isAjaxCall) { $smartyVariables['loadPerUserIndicator_ajaxFile'] = self::getSmartySubFilename(); $smartyVariables['loadPerUserIndicator_ajaxPhpURL'] = self::getAjaxPhpURL(); } return $smartyVariables; }
/** * REM: select only projectTypes in $projectTypeList * REM: select only projects in $projectList, if $projectList = 0 then ALL projects. */ private function countIssues_other() { $formatedProjectTypes = implode(', ', $this->projectTypeList); // select all but SideTasks & rem 'doublons' $query = "SELECT DISTINCT bug.id " . "FROM `mantis_bug_table` as bug " . "JOIN `codev_team_project_table` as team_project ON bug.project_id = team_project.project_id " . "WHERE team_project.type IN ({$formatedProjectTypes}) "; // Only for specified Projects if (isset($this->projectList) && 0 != count($this->projectList)) { $formatedProjects = implode(', ', $this->projectList); $query .= "AND bug.project_id IN ({$formatedProjects}) "; } $query .= ";"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "<span style='color:red'>ERROR: Query FAILED</span>"; exit; } // For each bugId while ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) { $bugId1 = $row->id; // Find most recent transitions where date < $endTimestamp $query2 = "SELECT bug_id, new_value, old_value, date_modified " . "FROM `mantis_bug_history_table` " . "WHERE field_name='status' " . "AND bug_id ={$bugId1} " . "AND date_modified < {$this->endTimestamp} " . "ORDER BY id DESC"; $result2 = SqlWrapper::getInstance()->sql_query($query2); if (!$result2) { echo "<span style='color:red'>ERROR: Query FAILED</span>"; exit; } if (0 != SqlWrapper::getInstance()->sql_num_rows($result2)) { $row2 = SqlWrapper::getInstance()->sql_fetch_object($result2); $this->statusCountList[$row2->new_value]++; $this->statusIssueList[$row2->new_value][] = $bugId1; } } if (isset($_GET['debug'])) { echo "date < " . Tools::formatDate("%b %y", $this->endTimestamp) . "<br/>"; foreach ($this->statusIssueList as $state => $bugList) { foreach ($bugList as $bug) { echo "#{$bug} ({$state})<br/>"; } } } }
/** * * @param boolean $isAjaxCall * @return array */ public function getSmartyVariables($isAjaxCall = false) { $smartyVariables = array('helloWorldIndicator_greetings' => $this->execData['greetings'], 'helloWorldIndicator_startDate' => Tools::formatDate("%Y-%m-%d", $this->execData['startTimestamp']), 'helloWorldIndicator_' . self::OPTION_IS_DATE_DISPLAYED => $this->isDateDisplayed); if (false == $isAjaxCall) { $smartyVariables['helloWorldIndicator_ajaxFile'] = self::getSmartySubFilename(); $smartyVariables['helloWorldIndicator_ajaxPhpURL'] = self::getAjaxPhpURL(); } return $smartyVariables; }
public function getSmartyObject() { $timestamp = Tools::getStartEndKeys($this->execData['MEE']); $start = Tools::formatDate("%Y-%m-01", Tools::date2timestamp($timestamp[0])); $end = Tools::formatDate("%Y-%m-01", strtotime($timestamp[1] . " +1 month")); $jsonMEE = Tools::array2plot($this->execData['MEE']); $jsonEE = Tools::array2plot($this->execData['EE']); $graphData = "[{$jsonMEE},{$jsonEE}]"; #$graphDataColors = '["#fcbdbd", "#c2dfff"]'; $labels = '["MgrEffortEstim ReliabilityRate", "EffortEstim ReliabilityRate"]'; $tableData = array(); foreach ($this->execData['MEE'] as $date => $prodRateMEE) { $prodRateEE = $this->execData['EE'][$date]; $timestamp = Tools::date2timestamp($date); $formattedDate = Tools::formatDate("%B %Y", $timestamp); $tableData[$formattedDate] = array('prodRateMEE' => round($prodRateMEE, 2), 'prodRateEE' => round($prodRateEE, 2)); } return array('prodRate_history_data' => $graphData, 'prodRate_history_dataLabels' => $labels, 'prodRate_history_plotMinDate' => $start, 'prodRate_history_plotMaxDate' => $end, 'prodRate_tableData' => $tableData); }
/** * get info to display the updateBacklog dialogbox * * Note: this dialogbox is also responsible for validating the addTrack action. * * @param type $bugid * @param type $trackJobid * @param type $teamid * @param type $managedUserid * @param type $trackDate * @param type $trackDuration * @return json encoded data to be displayed in the dialogBox */ public static function getUpdateBacklogJsonData($bugid, $trackJobid, $teamid, $managedUserid, $trackDate = 0, $trackDuration = 0) { try { $issue = IssueCache::getInstance()->getIssue($bugid); $backlog = $issue->getBacklog(); $summary = $issue->getSummary(); $drift = $issue->getDrift(); $effortEstim = $issue->getEffortEstim(); $effortAdd = $issue->getEffortAdd(); $formattedIds = $issue->getFormattedIds(); $mgrEffortEstim = $issue->getMgrEffortEstim(); $elapsed = $issue->getElapsed(); $driftMgr = $issue->getDriftMgr(); $reestimated = $issue->getReestimated(); $driftColor = $issue->getDriftColor($drift); $currentStatus = $issue->getCurrentStatus(); $availableStatusList = $issue->getAvailableStatusList(true); $bugResolvedStatusThreshold = $issue->getBugResolvedStatusThreshold(); $bugStatusNew = Constants::$status_new; $deadline = $issue->getDeadLine(); $handlerId = $issue->getHandlerId(); $handler = UserCache::getInstance()->getUser($handlerId); $handlerName = $handler->getName(); $managedUser = UserCache::getInstance()->getUser($managedUserid); $managedUserName = $managedUser->getName(); } catch (Exception $e) { $backlog = '!'; $summary = '<span class="error_font">' . T_('Error: Task not found in Mantis DB !') . '</span>'; $drift = 0; $effortEstim = 0; $effortAdd = 0; $formattedIds = -1; $mgrEffortEstim = 0; $elapsed = 0; $driftMgr = 0; $reestimated = 0; $driftColor = null; $currentStatus = 0; $availableStatusList = array(); $bugResolvedStatusThreshold = 0; $bugStatusNew = Constants::$status_new; $deadline = null; $handlerId = 0; $handlerName = 'ERROR'; $managedUserName = '******'; } // prepare json data for the BacklogDialogbox $totalEE = $effortEstim + $effortAdd; $issueInfo = array('trackUserid' => $managedUserid, 'trackUserName' => $managedUserName, 'currentBacklog' => $backlog, 'bugid' => $bugid, 'summary' => $summary, 'dialogBoxTitle' => $formattedIds, 'effortEstim' => $totalEE, 'mgrEffortEstim' => $mgrEffortEstim, 'elapsed' => $elapsed, 'drift' => $drift, 'driftMgr' => $driftMgr, 'reestimated' => $reestimated, 'driftColor' => $driftColor, 'currentStatus' => $currentStatus, 'availableStatusList' => $availableStatusList, 'bugResolvedStatusThreshold' => $bugResolvedStatusThreshold, 'bugStatusNew' => $bugStatusNew, 'trackDuration' => $trackDuration, 'trackJobid' => $trackJobid, 'handlerId' => $handlerId, 'handlerName' => $handlerName); if (0 !== $trackDuration) { # fill duration combobox values $issueInfo['availableDurationList'] = self::getDurationList($teamid); $issueInfo['trackDate'] = $trackDate; } // display calculatedBacklog depending on team settings $team = TeamCache::getInstance()->getTeam($teamid); if (1 == $team->getGeneralPreference('displayCalculatedBacklogInDialogbox')) { // Note: if Backlog is NULL, the values to propose in the DialogBox // are not the ones used for ProjectManagement if (!is_null($backlog) && is_numeric($backlog)) { // normal case $calculatedBacklog = $backlog - $trackDuration; } else { // reestimated cannot be used... $calculatedBacklog = $totalEE - $issue->getElapsed() - $trackDuration; } if ($calculatedBacklog < 0) { $calculatedBacklog = 0; } $issueInfo['calculatedBacklog'] = $calculatedBacklog; } if (!is_null($deadline) || 0 != $deadline) { $formatedDate = Tools::formatDate("%Y-%m-%d", $deadline); $issueInfo['deadline'] = $formatedDate; } $jsonIssueInfo = json_encode($issueInfo); return $jsonIssueInfo; }
public function execute() { $backlogList = $this->issue->getBacklogHistory(); $formattedBlList = array(); foreach ($backlogList as $t => $b) { $formattedBlList[Tools::formatDate("%Y-%m-%d", $t)] = $b; } // Graph start/stop dates reset($formattedBlList); $plotMinDate = key($formattedBlList); end($formattedBlList); $plotMaxDate = key($formattedBlList); // Calculate a nice week interval $minTimestamp = Tools::date2timestamp($plotMinDate); $maxTimestamp = Tools::date2timestamp($plotMaxDate); $nbWeeks = ($maxTimestamp - $minTimestamp) / 60 / 60 / 24 / 7; $interval = ceil($nbWeeks / 10); $jqplotData = Tools::array2plot($formattedBlList); $this->execData = array('issueBacklogVariationIndicator_interval' => $interval, 'issueBacklogVariationIndicator_plotMinDate' => $plotMinDate, 'issueBacklogVariationIndicator_plotMaxDate' => $plotMaxDate, 'issueBacklogVariationIndicator_jqplotYaxisLabel' => T_('Backlog (days)'), 'issueBacklogVariationIndicator_jqplotData' => $jqplotData, 'issueBacklogVariationIndicator_tableData' => $formattedBlList); return $this->execData; }
/** * Export week activity * @param int $teamid * @param $weekDates * @param TimeTracking $timeTracking * @param string $myFile * @return string */ private function exportWeekActivityReportToCSV($teamid, $weekDates, $timeTracking, $myFile) { $sepChar = ';'; // create filename & open file $fh = fopen($myFile, 'w'); $stringData = T_("Task") . $sepChar . T_("Job") . $sepChar . T_("Description") . $sepChar . T_("Assigned to") . $sepChar . Tools::formatDate("%A %d/%m", $weekDates[1]) . $sepChar . Tools::formatDate("%A %d/%m", $weekDates[2]) . $sepChar . Tools::formatDate("%A %d/%m", $weekDates[3]) . $sepChar . Tools::formatDate("%A %d/%m", $weekDates[4]) . $sepChar . Tools::formatDate("%A %d/%m", $weekDates[5]) . "\n"; fwrite($fh, $stringData); $query = "SELECT codev_team_user_table.user_id, mantis_user_table.realname " . "FROM `codev_team_user_table`, `mantis_user_table` " . "WHERE codev_team_user_table.team_id = {$teamid} " . "AND codev_team_user_table.user_id = mantis_user_table.id " . "ORDER BY mantis_user_table.realname"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "<span style='color:red'>ERROR: Query FAILED</span>"; exit; } while ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) { // if user was working on the project during the timestamp $user = UserCache::getInstance()->getUser($row->user_id); if ($user->isTeamDeveloper($teamid, $timeTracking->getStartTimestamp(), $timeTracking->getEndTimestamp()) || $user->isTeamManager($teamid, $timeTracking->getStartTimestamp(), $timeTracking->getEndTimestamp())) { $this->exportWeekDetailsToCSV($row->user_id, $timeTracking, $user->getShortname(), $fh); } } fclose($fh); return $myFile; }
/** * Display 'Developers Workload' * nb of days.: (holidays & externalTasks not included, developers only) * @param TimeTracking[] $timeTrackingTable * @return string */ private function generateDevelopersWorkloadGraph($timeTrackingTable) { $formattedTimetracks = array(); foreach ($timeTrackingTable as $startTimestamp => $timeTracking) { // REM: the 'normal' drifts DO include support $formattedTimetracks[$startTimestamp] = $timeTracking->getAvailableWorkload(); } $values = array(); $legend = array(); foreach ($formattedTimetracks as $date => $value) { $values[Tools::formatDate("%Y-%m-01", $date)] = $value; $legend[Tools::formatDate("%B %Y", $date)] = round($value, 1); } $this->smartyHelper->assign('workload_jqplotData', Tools::array2plot($values)); $timestamp = Tools::getStartEndKeys($values); $start = Tools::formatDate("%Y-%m-01", Tools::date2timestamp($timestamp[0])); $end = Tools::formatDate("%Y-%m-01", strtotime($timestamp[1] . " +1 month")); $this->smartyHelper->assign('workload_plotMinDate', $start); $this->smartyHelper->assign('workload_plotMaxDate', $end); $this->smartyHelper->assign('workload_Legend', $legend); }
/** * * @return type */ public function getSmartyVariables($isAjaxCall = false) { $startTimestamp = $this->startTimestamp; $endTimestamp = strtotime(date("Y-m-d", $this->endTimestamp) . " +1 month"); #$graphData = "[".Tools::array2plot($this->execData['nbValidated']).','.Tools::array2plot($this->execData['nbReopened'])."]"; $graphData = "[" . Tools::array2plot($this->execData['validatedPercent']) . ',' . Tools::array2plot($this->execData['reopenedPercent']) . "]"; $interval = ceil($this->interval / 20); // TODO why 20 ? $smartyVariables = array('reopenedRateIndicator2_tableData' => $this->execData['tableData'], 'reopenedRateIndicator2_jqplotData' => $graphData, 'reopenedRateIndicator2_plotMinDate' => Tools::formatDate("%Y-%m-01", $startTimestamp), 'reopenedRateIndicator2_plotMaxDate' => Tools::formatDate("%Y-%m-01", $endTimestamp), 'reopenedRateIndicator2_plotInterval' => $interval, 'reopenedRateIndicator2_' . self::OPTION_INTERVAL => $this->interval); if (false == $isAjaxCall) { $smartyVariables['reopenedRateIndicator2_ajaxFile'] = self::getSmartySubFilename(); $smartyVariables['reopenedRateIndicator2_ajaxPhpURL'] = self::getAjaxPhpURL(); } return $smartyVariables; }
/** * * @return type */ public function getSmartyVariables($isAjaxCall = false) { $startTimestamp = $this->startTimestamp; $endTimestamp = strtotime(date("Y-m-d", $this->endTimestamp) . " +1 month"); $interval = ceil($this->interval / 20); // TODO why 20 ? #$graphDaysData = '['.Tools::array2plot($this->execData['budgetDriftDays']).']'; $graphPercentData = '[' . Tools::array2plot($this->execData['budgetDriftPercent']) . ']'; $smartyVariables = array('budgetDriftHistoryIndicator2_tableData' => $this->execData['budgetDriftTable'], 'budgetDriftHistoryIndicator2_jqplotPercentData' => $graphPercentData, 'budgetDriftHistoryIndicator2_jqplotMinDate' => Tools::formatDate("%Y-%m-%d", $startTimestamp), 'budgetDriftHistoryIndicator2_jqplotMaxDate' => Tools::formatDate("%Y-%m-%d", $endTimestamp), 'budgetDriftHistoryIndicator2_jqplotInterval' => $interval, 'budgetDriftHistoryIndicator2_' . self::OPTION_INTERVAL => $this->interval); if (false == $isAjaxCall) { $smartyVariables['budgetDriftHistoryIndicator2_ajaxFile'] = self::getSmartySubFilename(); $smartyVariables['budgetDriftHistoryIndicator2_ajaxPhpURL'] = self::getAjaxPhpURL(); } return $smartyVariables; }
/** * * @return type */ public function getSmartyVariables($isAjaxCall = false) { $timestamp = Tools::getStartEndKeys($this->execData['MEE']); $start = Tools::formatDate("%Y-%m-01", Tools::date2timestamp($timestamp[0])); $end = Tools::formatDate("%Y-%m-01", strtotime($timestamp[1] . " +1 month")); $jsonMEE = Tools::array2plot($this->execData['MEE']); $jsonEE = Tools::array2plot($this->execData['EE']); $graphData = "[{$jsonMEE},{$jsonEE}]"; #$graphDataColors = '["#fcbdbd", "#c2dfff"]'; $labels = '["MgrEffortEstim ReliabilityRate", "EffortEstim ReliabilityRate"]'; $tableData = array(); foreach ($this->execData['MEE'] as $date => $prodRateMEE) { $prodRateEE = $this->execData['EE'][$date]; $timestamp = Tools::date2timestamp($date); $formattedDate = Tools::formatDate("%Y-%m-%d", $timestamp); $tableData[$formattedDate] = array('prodRateMEE' => round($prodRateMEE, 2), 'prodRateEE' => round($prodRateEE, 2)); } $smartyVariables = array('effortEstimReliabilityIndicator2_tableData' => $tableData, 'effortEstimReliabilityIndicator2_jqplotData' => $graphData, 'effortEstimReliabilityIndicator2_dataLabels' => $labels, 'effortEstimReliabilityIndicator2_plotMinDate' => $start, 'effortEstimReliabilityIndicator2_plotMaxDate' => $end, 'effortEstimReliabilityIndicator2_' . self::OPTION_INTERVAL => $this->interval); if (false == $isAjaxCall) { $smartyVariables['effortEstimReliabilityIndicator2_ajaxFile'] = self::getSmartySubFilename(); $smartyVariables['effortEstimReliabilityIndicator2_ajaxPhpURL'] = self::getAjaxPhpURL(); } return $smartyVariables; }
/** * Drift Stats on a given Issue.class List * * @param Issue[] $issueList * @param bool $withSupport * @return mixed[] driftStats * * TODO move this method to IssueSelection class */ private function getIssuesDriftStats(array $issueList, $withSupport = true) { if (NULL == $issueList) { echo "<div style='color:red'>ERROR getIssuesDriftStats: Issue List is NULL !<br/></div>"; self::$logger->error("getIssuesDriftStats(): Issue List is NULL !"); return 0; } if (0 == count($issueList)) { echo "<div style='color:red'>ERROR getIssuesDriftStats: Issue List is empty !<br/></div>"; self::$logger->error("getIssuesDriftStats(): Issue List is empty !"); return 0; } $derive = 0; $deriveETA = 0; $nbDriftsNeg = 0; $nbDriftsEqual = 0; $nbDriftsPos = 0; $nbDriftsNegETA = 0; $nbDriftsEqualETA = 0; $nbDriftsPosETA = 0; $driftNeg = 0; $driftEqual = 0; $driftPos = 0; $driftNegETA = 0; $driftEqualETA = 0; $driftPosETA = 0; $formatedBugidNegList = ""; $formatedBugidPosList = ""; $formatedBugidEqualList = ""; $bugidEqualList = ""; foreach ($issueList as $issue) { // compute total drift $issueDrift = $issue->getDrift($withSupport); $derive += $issueDrift; $issueDriftMgrEE = $issue->getDriftMgr($withSupport); $deriveETA += $issueDriftMgrEE; if (self::$logger->isDebugEnabled()) { self::$logger->debug("getIssuesDriftStats() Found : bugid=" . $issue->getId() . ", proj=" . $issue->getProjectId() . ", effortEstim=" . $issue->getEffortEstim() . ", BS=" . $issue->getEffortAdd() . ", elapsed = " . $issue->getElapsed() . ", drift={$issueDrift}, DriftMgrEE={$issueDriftMgrEE}"); } // get drift stats. equal is when drif = +-1 if ($issueDrift < -1) { $nbDriftsNeg++; $driftNeg += $issueDrift; if ($formatedBugidNegList != "") { $formatedBugidNegList .= ', '; } $formatedBugidNegList .= Tools::issueInfoURL($issue->getId(), $issue->getSummary()); } elseif ($issueDrift > 1) { $nbDriftsPos++; $driftPos += $issueDrift; if ($formatedBugidPosList != "") { $formatedBugidPosList .= ', '; } $formatedBugidPosList .= Tools::issueInfoURL($issue->getId(), $issue->getSummary()); } else { $nbDriftsEqual++; $driftEqual += $issueDrift; if ($formatedBugidEqualList != "") { $formatedBugidEqualList .= ', '; } $formatedBugidEqualList .= Tools::issueInfoURL($issue->getId(), $issue->getSummary()); if ($bugidEqualList != "") { $bugidEqualList .= ', '; } $bugidEqualList .= $issue->getId(); } if ($issueDriftMgrEE < -1) { $nbDriftsNegETA++; $driftNegETA += $issueDriftMgrEE; } elseif ($issueDriftMgrEE > 1) { $nbDriftsPosETA++; $driftPosETA += $issueDriftMgrEE; } else { $nbDriftsEqualETA++; $driftEqualETA += $issueDriftMgrEE; } } if (self::$logger->isDebugEnabled()) { self::$logger->debug("derive totale (" . Tools::formatDate("%B %Y", $this->startTimestamp) . ") = {$derive}"); self::$logger->debug("derive totale ETA(" . Tools::formatDate("%B %Y", $this->startTimestamp) . ") = {$deriveETA}"); self::$logger->debug("Nbre Bugs en derive : {$nbDriftsPos}"); self::$logger->debug("Nbre Bugs a l'equilibre : {$nbDriftsEqual}"); self::$logger->debug("Nbre Bugs en avance : {$nbDriftsNeg}"); self::$logger->debug("Nbre Bugs en derive ETA: {$nbDriftsPosETA}"); self::$logger->debug("Nbre Bugs a l'equilibre ETA: {$nbDriftsEqualETA}"); self::$logger->debug("Nbre Bugs en avance ETA: {$nbDriftsNegETA}"); } return array("totalDrift" => $derive, "totalDriftETA" => $deriveETA, "driftPos" => $driftPos, "driftEqual" => $driftEqual, "driftNeg" => $driftNeg, "driftPosETA" => $driftPosETA, "driftEqualETA" => $driftEqualETA, "driftNegETA" => $driftNegETA, "nbDriftsPos" => $nbDriftsPos, "nbDriftsEqual" => $nbDriftsEqual, "nbDriftsNeg" => $nbDriftsNeg, "nbDriftsPosETA" => $nbDriftsPosETA, "nbDriftsEqualETA" => $nbDriftsEqualETA, "nbDriftsNegETA" => $nbDriftsNegETA, "formatedBugidPosList" => $formatedBugidPosList, "formatedBugidEqualList" => $formatedBugidEqualList, "formatedBugidNegList" => $formatedBugidNegList, "bugidEqualList" => $bugidEqualList); }
/** * display Timetracking Tuples * @param int $userid * @param TimeTracking $timeTracking * @return mixed[] */ private function getTimetrackingTuples($userid, TimeTracking $timeTracking) { // Display previous entries $query = "SELECT id, bugid, jobid, date, duration" . " FROM `codev_timetracking_table`" . " WHERE userid = {$userid}" . " AND date >= " . $timeTracking->getStartTimestamp() . " ORDER BY date"; $result = SqlWrapper::getInstance()->sql_query($query) or die("Query failed: {$query}"); $jobs = new Jobs(); $timetrackingTuples = array(); while ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) { // get information on this bug try { $issue = IssueCache::getInstance()->getIssue($row->bugid); // get general information $jobName = $jobs->getJobName($row->jobid); $formatedDate = Tools::formatDate("%Y-%m-%d", $row->date); $cosmeticDate = Tools::formatDate("%Y-%m-%d - %A", $row->date); $formatedJobName = str_replace("'", "\\'", $jobName); $formatedSummary = str_replace("'", "\\'", $issue->getSummary()); $formatedSummary = str_replace('"', "\\'", $formatedSummary); $formatedSummary = htmlspecialchars(preg_replace('![\\t\\r\\n]+!', ' ', $formatedSummary)); //$totalEstim = $issue->effortEstim + $issue->effortAdd; $timetrackingTuples[$row->id] = array('timestamp' => $row->date, 'date' => $formatedDate, 'formatedId' => $issue->getFormattedIds(), 'duration' => $row->duration, 'formatedJobName' => $formatedJobName, 'summary' => $formatedSummary, 'cosmeticDate' => $cosmeticDate, 'mantisURL' => Tools::mantisIssueURL($row->bugid, NULL, true), 'issueURL' => Tools::issueInfoURL($row->bugid), 'issueId' => $issue->getTcId(), 'projectName' => $issue->getProjectName(), 'issueSummary' => htmlspecialchars(preg_replace('![\\t\\r\\n]+!', ' ', $issue->getSummary())), 'jobName' => $jobName, 'categoryName' => $issue->getCategoryName(), 'currentStatusName' => $issue->getCurrentStatusName()); } catch (Exception $e) { $summary = T_('Error: Task not found in Mantis DB !'); $timetrackingTuples[$row->id] = array('formatedId' => $row->bugid, 'duration' => $row->duration, 'summary' => $summary, 'mantisURL' => '', 'issueURL' => $row->bugid, 'issueId' => '!', 'projectName' => '!', 'issueSummary' => '<span class="error_font">' . $summary . '</span>', 'categoryName' => '!', 'currentStatusName' => '!'); } } $currentTimeTrackingTuples = array(); $futureTimeTrackingTuples = array(); foreach ($timetrackingTuples as $trackId => $timeTrackingTuple) { if ($timeTrackingTuple['timestamp'] <= $timeTracking->getEndTimestamp()) { $currentTimeTrackingTuples[$trackId] = $timeTrackingTuple; } else { $futureTimeTrackingTuples[$trackId] = $timeTrackingTuple; } unset($timeTrackingTuple['timestamp']); } return array("current" => $currentTimeTrackingTuples, "future" => $futureTimeTrackingTuples); }