/** * * @param SmartyHelper $smartyHelper * @param Command $prj * @param int $userid */ public static function dashboardSettings(SmartyHelper $smartyHelper, Project $prj, $userid, $teamid) { $pluginDataProvider = PluginDataProvider::getInstance(); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_ISSUE_SELECTION, $prj->getIssueSelection()); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_TEAM_ID, $teamid); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_SESSION_USER_ID, $userid); $team = TeamCache::getInstance()->getTeam($teamid); $startT = $team->getDate(); $now = time(); $endT = mktime(23, 59, 59, date('m', $now), date('d', $now), date('Y', $now)); if ($startT > $endT) { $startT = strtotime('today midnight'); } //echo "start $startT end $endT<br>"; // Calculate a nice day interval $nbWeeks = ($endT - $startT) / 60 / 60 / 24; $interval = ceil($nbWeeks / 20); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_START_TIMESTAMP, $startT); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_END_TIMESTAMP, $endT); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_INTERVAL, $interval); // save the DataProvider for Ajax calls $_SESSION[PluginDataProviderInterface::SESSION_ID] = serialize($pluginDataProvider); // create the Dashboard $dashboard = new Dashboard('Project' . $prj->getId()); $dashboard->setDomain(IndicatorPluginInterface::DOMAIN_PROJECT); $dashboard->setCategories(array(IndicatorPluginInterface::CATEGORY_QUALITY, IndicatorPluginInterface::CATEGORY_ACTIVITY, IndicatorPluginInterface::CATEGORY_ROADMAP, IndicatorPluginInterface::CATEGORY_PLANNING, IndicatorPluginInterface::CATEGORY_RISK)); $dashboard->setTeamid($teamid); $dashboard->setUserid($userid); $data = $dashboard->getSmartyVariables($smartyHelper); foreach ($data as $smartyKey => $smartyVariable) { $smartyHelper->assign($smartyKey, $smartyVariable); } }
protected function display() { if (Tools::isConnectedUser()) { $team = TeamCache::getInstance()->getTeam($this->teamid); $action = filter_input(INPUT_GET, 'action'); // feed the PluginDataProvider $pluginDataProvider = PluginDataProvider::getInstance(); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_SESSION_USER_ID, $this->session_userid); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_TEAM_ID, $this->teamid); $weekDates = Tools::week_dates(date('W'), date('Y')); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_START_TIMESTAMP, $weekDates[1]); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_END_TIMESTAMP, $weekDates[5]); $dashboardName = 'Admin' . $this->teamid; // save the DataProvider for Ajax calls $_SESSION[PluginDataProviderInterface::SESSION_ID . $dashboardName] = serialize($pluginDataProvider); // create the Dashboard $dashboard = new Dashboard($dashboardName); $dashboard->setDomain(IndicatorPluginInterface::DOMAIN_ADMIN); $dashboard->setCategories(array(IndicatorPluginInterface::CATEGORY_QUALITY, IndicatorPluginInterface::CATEGORY_ACTIVITY, IndicatorPluginInterface::CATEGORY_ROADMAP, IndicatorPluginInterface::CATEGORY_PLANNING, IndicatorPluginInterface::CATEGORY_RISK, IndicatorPluginInterface::CATEGORY_ADMIN)); $dashboard->setTeamid($this->teamid); $dashboard->setUserid($this->session_userid); $data = $dashboard->getSmartyVariables($this->smartyHelper); foreach ($data as $smartyKey => $smartyVariable) { $this->smartyHelper->assign($smartyKey, $smartyVariable); } } else { $this->smartyHelper->assign('error', T_('Sorry, you need to be identified.')); } }
protected function display() { if (Tools::isConnectedUser()) { if (0 != $this->teamid) { $team = TeamCache::getInstance()->getTeam($this->teamid); $action = filter_input(INPUT_GET, 'action'); if ('setDateRange' === $action) { $startdate = filter_input(INPUT_GET, 'startdate'); $startTimestamp = Tools::date2timestamp($startdate); $enddate = filter_input(INPUT_GET, 'enddate'); $endTimestamp = Tools::date2timestamp($enddate); $endTimestamp += 24 * 60 * 60 - 1; // + 1 day -1 sec. } else { //$startTimestamp = $team->getDate(); // creationDate //$endTimestamp = time(); $startTimestamp = strtotime("first day of this month"); $endTimestamp = strtotime("last day of this month"); } $this->smartyHelper->assign('startDate', date("Y-m-d", $startTimestamp)); $this->smartyHelper->assign('endDate', date("Y-m-d", $endTimestamp)); // create issueSelection with issues from team projects $teamIssues = $team->getTeamIssueList(true, true); // with disabledProjects ? $teamIssueSelection = new IssueSelection('Team' . $this->teamid . 'ISel'); $teamIssueSelection->addIssueList($teamIssues); // feed the PluginDataProvider $pluginDataProvider = PluginDataProvider::getInstance(); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_ISSUE_SELECTION, $teamIssueSelection); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_TEAM_ID, $this->teamid); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_START_TIMESTAMP, $startTimestamp); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_END_TIMESTAMP, $endTimestamp); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_SESSION_USER_ID, $this->session_userid); $dashboardName = 'Team' . $this->teamid; // save the DataProvider for Ajax calls $_SESSION[PluginDataProviderInterface::SESSION_ID . $dashboardName] = serialize($pluginDataProvider); // create the Dashboard $dashboard = new Dashboard($dashboardName); $dashboard->setDomain(IndicatorPluginInterface::DOMAIN_TEAM); $dashboard->setCategories(array(IndicatorPluginInterface::CATEGORY_QUALITY, IndicatorPluginInterface::CATEGORY_ACTIVITY, IndicatorPluginInterface::CATEGORY_ROADMAP, IndicatorPluginInterface::CATEGORY_PLANNING, IndicatorPluginInterface::CATEGORY_RISK, IndicatorPluginInterface::CATEGORY_TEAM)); $dashboard->setTeamid($this->teamid); $dashboard->setUserid($this->session_userid); $data = $dashboard->getSmartyVariables($this->smartyHelper); foreach ($data as $smartyKey => $smartyVariable) { $this->smartyHelper->assign($smartyKey, $smartyVariable); } } else { $this->smartyHelper->assign('error', T_('Please select a team to access this page.')); } } else { $this->smartyHelper->assign('error', T_('Sorry, you need to be identified.')); } }
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); return; } $year = Tools::getSecurePOSTIntValue('year', date('Y')); $displayed_teamid = 0; if (isset($_POST['displayed_teamid'])) { $displayed_teamid = Tools::getSecurePOSTIntValue('displayed_teamid', 0); } else { $displayed_teamid = $this->teamid; } // --- Filters $filtersStr = Tools::getSecurePOSTStringValue('checkedFilters', ''); if (!empty($filtersStr)) { $filters = Tools::doubleExplode(':', ',', $filtersStr); } else { $filters = array('isExternalTasks' => 1, 'isSidetasksInactivity' => 1); } $filterInfo = array(); $filterInfo[] = array('filterId' => 'isExternalTasks', 'filterName' => T_('External Tasks'), 'isChecked' => $filters['isExternalTasks']); $filterInfo[] = array('filterId' => 'isSidetasksInactivity', 'filterName' => T_('Sidetasks Inactivity'), 'isChecked' => $filters['isSidetasksInactivity']); $this->smartyHelper->assign('filterInfo', $filterInfo); $this->smartyHelper->assign('checkedFilters', $filtersStr); // --- $teams = SmartyTools::getSmartyArray($this->teamList, $displayed_teamid); #$teams = SmartyTools::getSmartyArray(Team::getTeams(),$displayed_teamid); $this->smartyHelper->assign('availableTeams', $teams); $this->smartyHelper->assign('years', SmartyTools::getYears($year, 2)); if ($displayed_teamid == 0 && count($teams) > 0) { $teamids = array_keys($teams); $displayed_teamid = $teamids[0]; } $team = TeamCache::getInstance()->getTeam($displayed_teamid); $users = $team->getUsers(); $months = array(); for ($i = 1; $i <= 12; $i++) { $monthTimestamp = mktime(0, 0, 0, $i, 1, $year); $nbDaysInMonth = date("t", $monthTimestamp); $endMonthTimestamp = strtotime("last day of this month", $monthTimestamp); $months[$i] = array("name" => Tools::formatDate("%B %Y", $monthTimestamp), "idcaption" => Tools::formatDate("%B", $monthTimestamp), "days" => $this->getDays($nbDaysInMonth, $i, $year), "users" => $this->getDaysUsers($i, $year, $displayed_teamid, $users, $nbDaysInMonth, $filters), "workdays" => Holidays::getInstance()->getWorkdays($monthTimestamp, $endMonthTimestamp), "filename_csv" => date("Ym", $monthTimestamp) . '_' . str_replace(' ', '_', $team->getName()) . '_holidays.csv'); } $this->smartyHelper->assign('months', $months); } }
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'); } } } }
/** * @param BlogPost[] $postList * @return mixed[] */ private function getBlogPosts(array $postList) { $blogPosts = array(); foreach ($postList as $id => $bpost) { $srcUser = UserCache::getInstance()->getUser($bpost->src_user_id); $item = array(); // TODO $item['category'] = Config::getVariableValueFromKey(Config::id_blogCategories, $bpost->category); $item['severity'] = BlogPost::getSeverityName($bpost->severity); $item['summary'] = $bpost->summary; $item['content'] = $bpost->content; $item['date_submitted'] = date('Y-m-d G:i', $bpost->date_submitted); $item['from'] = $srcUser->getRealname(); // find receiver if (0 != $bpost->dest_user_id) { $destUser = UserCache::getInstance()->getUser($bpost->dest_user_id); $item['to'] = $destUser->getRealname(); } else { if (0 != $bpost->dest_team_id) { $team = TeamCache::getInstance()->getTeam($bpost->dest_team_id); $item['to'] = $team->getName(); } else { if (0 != $bpost->dest_project_id) { $destProj = ProjectCache::getInstance()->getProject($bpost->dest_project_id); $item['to'] = $destProj->getName(); } else { $item['to'] = '?'; } } } $item['activity'] = 'activities...'; $item['buttons'] = "<input type='button' value='" . T_('Ack') . "' onclick='javascript: ackPost(" . $bpost->id . ")' />"; $item['buttons'] .= "<input type='button' value='" . T_('Hide') . "' onclick='javascript: hidePost(" . $bpost->id . ")' />"; // TODO only if i'm the owner $item['buttons'] .= "<input type='button' value='" . T_('Delete') . "' onclick='javascript: deletePost(" . $bpost->id . ")' />"; $item['isHidden'] = '0'; $blogPosts[$id] = $item; } return $blogPosts; }
/** * Get consistency errors * @param int $teamid * @return mixed[] */ private function getTeamConsistencyErrors($teamid) { if (self::$logger->isDebugEnabled()) { self::$logger->debug("getTeamConsistencyErrors teamid={$teamid}"); } // get team projects $issueList = TeamCache::getInstance()->getTeam($teamid)->getTeamIssueList(true, false); if (self::$logger->isDebugEnabled()) { self::$logger->debug("getTeamConsistencyErrors nbIssues=" . count($issueList)); } #$ccheck = new ConsistencyCheck2($issueList); $ccheck = new ConsistencyCheck2($issueList, $teamid); $cerrList = $ccheck->check(); $cerrs = NULL; if (count($cerrList) > 0) { $i = 0; foreach ($cerrList as $cerr) { $i += 1; if (NULL != $cerr->userId) { $user = UserCache::getInstance()->getUser($cerr->userId); } else { $user = NULL; } if (Issue::exists($cerr->bugId)) { $issue = IssueCache::getInstance()->getIssue($cerr->bugId); $summary = $issue->getSummary(); $projName = $issue->getProjectName(); $refExt = $issue->getTcId(); } else { $summary = ''; $projName = ''; } $cerrs[$i] = array('userName' => isset($user) ? $user->getName() : '', 'issueURL' => NULL == $cerr->bugId ? '' : Tools::issueInfoURL($cerr->bugId, $summary), 'mantisURL' => NULL == $cerr->bugId ? '' : Tools::mantisIssueURL($cerr->bugId, $summary, true), 'extRef' => NULL == $refExt ? '' : $refExt, 'date' => NULL == $cerr->timestamp ? '' : date("Y-m-d", $cerr->timestamp), 'status' => NULL == $cerr->status ? '' : Constants::$statusNames[$cerr->status], 'severity' => $cerr->getLiteralSeverity(), 'project' => $projName, 'desc' => $cerr->desc, 'summary' => $summary); } } return $cerrs; }
private function getResolvedIssues($teamid, $userid = 0, $projects = NULL) { $team = TeamCache::getInstance()->getTeam($teamid); if (is_null($projects)) { $projects = $team->getProjects(false, false, false); $formattedProjects = implode(',', array_keys($projects)); } else { $formattedProjects = implode(',', array_values($projects)); } $formattedUsers = 0 != $userid ? $userid : implode(',', array_keys($team->getActiveMembers())); $query = "SELECT id FROM `mantis_bug_table` " . "WHERE project_id IN ({$formattedProjects}) " . "AND handler_id IN ({$formattedUsers}) " . "AND status >= get_project_resolved_status_threshold(project_id) "; $result = SqlWrapper::getInstance()->sql_query($query); echo "query = {$query}<br>"; if (!$result) { echo "<span style='color:red'>ERROR: Query FAILED</span>"; exit; } $isel = new IssueSelection('resolvedIssues'); while ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) { $isel->addIssue($row->id); } echo implode(',', array_keys($isel->getIssueList())); return $isel; }
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); } } } }
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); } } }
/** * * @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; }
protected function display() { if (Tools::isConnectedUser()) { // except Observed teams $dTeamList = $this->session_user->getDevTeamList(); $lTeamList = $this->session_user->getLeadedTeamList(); $managedTeamList = $this->session_user->getManagedTeamList(); $teamList = $dTeamList + $lTeamList + $managedTeamList; if (0 == $this->teamid || !array_key_exists($this->teamid, $teamList) || $this->session_user->isTeamCustomer($this->teamid)) { $this->smartyHelper->assign('accessDenied', TRUE); } else { #if ((0 != $this->teamid) && array_key_exists($this->teamid, $teamList)) { $team = TeamCache::getInstance()->getTeam($this->teamid); $this->smartyHelper->assign('teamid', $this->teamid); if (0 != $this->teamid) { $this->smartyHelper->assign('teamName', $team->getName()); } // use the projectid set in the form, if not defined (first page call) use session projectid if (isset($_POST['projectid'])) { $projectid = Tools::getSecurePOSTIntValue('projectid'); $_SESSION['projectid'] = $projectid; } else { $projectid = isset($_SESSION['projectid']) ? $_SESSION['projectid'] : 0; } $this->smartyHelper->assign('projectid', $projectid); if (0 != $projectid) { $proj = ProjectCache::getInstance()->getProject($projectid); $this->smartyHelper->assign('projectName', $proj->getName()); } $this->smartyHelper->assign('teams', SmartyTools::getSmartyArray($teamList, $this->teamid)); // exclude noStatsProjects and disabled projects $this->smartyHelper->assign('projects', SmartyTools::getSmartyArray($team->getProjects(false, false), $projectid)); if (isset($_FILES['uploaded_csv'])) { $filename = $_FILES['uploaded_csv']['name']; $tmpFilename = $_FILES['uploaded_csv']['tmp_name']; $err_msg = NULL; if ($_FILES['uploaded_csv']['error']) { $err_id = $_FILES['uploaded_csv']['error']; switch ($err_id) { case 1: $err_msg = "UPLOAD_ERR_INI_SIZE ({$err_id}) on file : " . $filename; //echo"Le fichier dépasse la limite autorisée par le serveur (fichier php.ini) !"; break; case 2: $err_msg = "UPLOAD_ERR_FORM_SIZE ({$err_id}) on file : " . $filename; //echo "Le fichier dépasse la limite autorisée dans le formulaire HTML !"; break; case 3: $err_msg = "UPLOAD_ERR_PARTIAL ({$err_id}) on file : " . $filename; //echo "L'envoi du fichier a été interrompu pendant le transfert !"; break; case 4: $err_msg = "UPLOAD_ERR_NO_FILE ({$err_id}) on file : " . $filename; //echo "Le fichier que vous avez envoyé a une taille nulle !"; break; } self::$logger->error($err_msg); } else { // $_FILES['nom_du_fichier']['error'] vaut 0 soit UPLOAD_ERR_OK // ce qui signifie qu'il n'y a eu aucune erreur } $extensions = array('.csv', '.CSV'); $extension = strrchr($filename, '.'); if (!in_array($extension, $extensions)) { $err_msg = T_('Please upload files with the following extension: ') . implode(', ', $extensions); self::$logger->error($err_msg); } // --- READ CSV FILE --- #$smartyHelper->assign('newIssues', getFakeNewIssues()); $this->smartyHelper->assign('newIssues', $this->getIssuesFromCSV($tmpFilename)); if (!$err_msg) { $this->smartyHelper->assign('filename', $filename); $commands = $this->getCommands($team); $projectCategories = $this->getProjectCategories($projectid); $projectTargetVersion = $this->getProjectTargetVersion($projectid); $activeMembers = $team->getActiveMembers(); $smartyCmdList = array(); foreach ($commands as $id => $name) { $smartyCmdList[$id] = array('id' => $id, 'name' => $name, 'selected' => $id == 0); } $this->smartyHelper->assign('commandList', $smartyCmdList); $this->smartyHelper->assign('categoryList', SmartyTools::getSmartyArray($projectCategories, 0)); $this->smartyHelper->assign('targetversionList', SmartyTools::getSmartyArray($projectTargetVersion, 0)); $this->smartyHelper->assign('userList', SmartyTools::getSmartyArray($activeMembers, 0)); $this->smartyHelper->assign('jed_commandList', Tools::array2json($commands)); $this->smartyHelper->assign('jed_categoryList', Tools::array2json($projectCategories)); $this->smartyHelper->assign('jed_targetVersionList', Tools::array2json($projectTargetVersion)); $this->smartyHelper->assign('jed_userList', Tools::array2json($activeMembers)); } else { $this->smartyHelper->assign('errorMsg', $err_msg); } } } } }
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); // if first call to this page if (!array_key_exists('nextForm', $_POST)) { $activeMembers = $team->getActiveMembers(); if ($this->session_user->isTeamManager($this->teamid)) { $this->smartyHelper->assign('users', SmartyTools::getSmartyArray($activeMembers, $this->session_userid)); } else { // developper & manager can add timeTracks if (array_key_exists($this->session_userid, $activeMembers)) { $_POST['userid'] = $this->session_userid; $_POST['nextForm'] = "addHolidaysForm"; //$_POST['days'] = 'dayid'; } } } $nextForm = Tools::getSecurePOSTStringValue('nextForm', ''); if ($nextForm == "addHolidaysForm") { $userid = Tools::getSecurePOSTIntValue('userid', $this->session_userid); $managed_user = UserCache::getInstance()->getUser($userid); // dates $startdate = Tools::getSecurePOSTStringValue('startdate', date("Y-m-d")); $enddate = Tools::getSecurePOSTStringValue('enddate', ''); $defaultBugid = Tools::getSecurePOSTIntValue('bugid', 0); $action = Tools::getSecurePOSTStringValue('action', ''); $duration = Tools::getSecurePOSTNumberValue('duree', 0); if ("addHolidays" == $action) { // TODO add tracks ! $job = Tools::getSecurePOSTStringValue('job'); $duration = Tools::getSecurePOSTNumberValue('duree'); $holydays = Holidays::getInstance(); $keyvalue = Tools::getSecurePOSTStringValue('checkedDays'); $checkedDaysList = Tools::doubleExplode(':', ',', $keyvalue); $startTimestamp = Tools::date2timestamp($startdate); $endTimestamp = Tools::date2timestamp($enddate); // save to DB $weekday = date('l', strtotime($startdate)); $timestamp = $startTimestamp; while ($timestamp <= $endTimestamp) { // check if not a fixed holiday if (!$holydays->isHoliday($timestamp)) { // check existing timetracks on $timestamp and adjust duration $availabletime = $managed_user->getAvailableTime($timestamp); // not imput more than possible if ($duration >= $availabletime) { $imput = $availabletime; } else { $imput = $duration; } // check if weekday checkbox is checked if (1 == $checkedDaysList[$weekday]) { if ($duration > 0) { if (self::$logger->isDebugEnabled()) { self::$logger->debug(date("Y-m-d", $timestamp) . " duration {$imput} job {$job}"); } TimeTrack::create($managed_user->getId(), $defaultBugid, $job, $timestamp, $imput, $this->session_userid); } } } $timestamp = strtotime("+1 day", $timestamp); $weekday = date('l', strtotime(date("Y-m-d", $timestamp))); } // We redirect to holidays report, so the user can verify his holidays header('Location:holidays_report.php'); } $this->smartyHelper->assign('startDate', $startdate); $this->smartyHelper->assign('endDate', $enddate); if ($this->session_userid != $managed_user->getId()) { $this->smartyHelper->assign('otherrealname', $managed_user->getRealname()); } // Get Team SideTasks Project List $projList = $team->getProjects(true, false); foreach ($projList as $pid => $pname) { // we want only SideTasks projects try { if (!$team->isSideTasksProject($pid)) { unset($projList[$pid]); } } catch (Exception $e) { self::$logger->error("project {$pid}: " . $e->getMessage()); } } $extproj_id = Config::getInstance()->getValue(Config::id_externalTasksProject); $extProj = ProjectCache::getInstance()->getProject($extproj_id); $projList[$extproj_id] = $extProj->getName(); $defaultProjectid = Tools::getSecurePOSTIntValue('projectid', 0); if ($defaultBugid != 0 && $action == 'setBugId') { // find ProjectId to update categories $issue = IssueCache::getInstance()->getIssue($defaultBugid); $defaultProjectid = $issue->getProjectId(); } $this->smartyHelper->assign('projects', SmartyTools::getSmartyArray($projList, $defaultProjectid)); $this->smartyHelper->assign('issues', $this->getIssues($defaultProjectid, $projList, $extproj_id, $defaultBugid)); $this->smartyHelper->assign('jobs', $this->getJobs($defaultProjectid, $projList)); $this->smartyHelper->assign('duration', SmartyTools::getSmartyArray(TimeTrackingTools::getDurationList($team->getId()), $duration)); $this->smartyHelper->assign('userid', $managed_user->getId()); } } } }
$allProject[0] = T_('(all)'); $dTeamList = $user->getDevTeamList(); $devProjList = count($dTeamList) > 0 ? $user->getProjectList($dTeamList, true, $withDisabled) : array(); $managedTeamList = $user->getManagedTeamList(); $managedProjList = count($managedTeamList) > 0 ? $user->getProjectList($managedTeamList, true, $withDisabled) : array(); $oTeamList = $user->getObservedTeamList(); $observedProjList = count($oTeamList) > 0 ? $user->getProjectList($oTeamList, true, $withDisabled) : array(); $projList = $allProject + $devProjList + $managedProjList + $observedProjList; // WORKAROUND if ($_GET['bugid'] == 'null') { $_GET['bugid'] = 0; } $smartyHelper->assign('bugs', SmartyTools::getBugs(Tools::getSecureGETIntValue('projectid'), Tools::getSecureGETIntValue('bugid', 0), $projList)); $smartyHelper->display('form/bugSelector'); } elseif ($_GET['action'] == 'getYearsToNow') { $team = TeamCache::getInstance()->getTeam(Tools::getSecureGETIntValue('teamid')); $min_year = date("Y", $team->getDate()); $year = isset($_POST['year']) && $_POST['year'] > $min_year ? $_POST['year'] : $min_year; $smartyHelper->assign('years', SmartyTools::getYearsToNow($min_year, $year)); $smartyHelper->display('form/yearSelector'); } else { Tools::sendNotFoundAccess(); } } else { if ($_POST['action']) { if ($_POST['action'] == 'updateBacklogAction') { $issue = IssueCache::getInstance()->getIssue(Tools::getSecurePOSTIntValue('bugid')); $issue->setBacklog(Tools::getSecurePOSTNumberValue('backlog')); } else { Tools::sendNotFoundAccess(); }
/** * code factorisation * * returns the input params for some indicators. * * @param Command $cmd * @return array [startTimestamp, endTimestamp, interval] */ private static function computeTimestampsAndInterval(Command $cmd) { $cmdIssueSel = $cmd->getIssueSelection(); $startTT = $cmdIssueSel->getFirstTimetrack(); if (NULL != $startTT && 0 != $startTT->getDate()) { $startTimestamp = $startTT->getDate(); } else { $startTimestamp = $cmd->getStartDate(); #echo "cmd getStartDate ".date("Y-m-d", $startTimestamp).'<br>'; if (0 == $startTimestamp) { $team = TeamCache::getInstance()->getTeam($cmd->getTeamid()); $startTimestamp = $team->getDate(); #echo "team Date ".date("Y-m-d", $startTimestamp).'<br>'; } } // endTimestamp = max(latest_timetrack, latest_update) $latestTrack = $cmdIssueSel->getLatestTimetrack(); $latestTrackTimestamp = !is_null($latestTrack) ? $latestTrack->getDate() : 0; $lastUpdatedTimestamp = $cmdIssueSel->getLastUpdated(); $endTimestamp = max(array($latestTrackTimestamp, $lastUpdatedTimestamp)); #echo "getLatestTimetrack = ".date('Y-m-d', $latestTrackTimestamp)." getLastUpdated = ".date('Y-m-d', $lastUpdatedTimestamp).' endDate = '.date('Y-m-d', $endTimestamp).'<br>'; if (0 == $endTimestamp) { $endTimestamp = $startTimestamp; } // Calculate a nice day interval $nbWeeks = ($endTimestamp - $startTimestamp) / 60 / 60 / 24; $interval = ceil($nbWeeks / 20); $params = array('startTimestamp' => $startTimestamp, 'endTimestamp' => $endTimestamp, 'interval' => $interval); return $params; }
/** * create Admin team & add to codev_config_table * @param string $name * @param int $leader_id * @return int */ function createAdminTeam($name, $leader_id) { $now = time(); $formatedDate = date("Y-m-d", $now); $today = Tools::date2timestamp($formatedDate); // create admin team $teamId = Team::getIdFromName($name); if (-1 == $teamId) { $teamId = Team::create($name, T_("CodevTT Administrators team"), $leader_id, $today); } if (-1 != $teamId) { // --- add to codev_config_table Config::getInstance()->setQuiet(true); Config::getInstance()->setValue(Config::id_adminTeamId, $teamId, Config::configType_int); Config::getInstance()->setQuiet(false); // add leader as member $adminTeam = TeamCache::getInstance()->getTeam($teamId); $adminTeam->addMember($leader_id, $today, Team::accessLevel_dev); $adminTeam->setEnabled(false); // add default ExternalTasksProject // TODO does Admin team needs ExternalTasksProject ? $adminTeam->addExternalTasksProject(); // NOTE: CodevTT Admin team does not need any side task project. } else { echo "ERROR: {$name} team creation failed</br>"; } return $teamId; }
/** * * * @param IssueSelection $inputIssueSel * @param array $params */ public function execute(IssueSelection $inputIssueSel, array $params = NULL) { $this->checkParams($inputIssueSel, $params); $team = TeamCache::getInstance()->getTeam($this->teamid); $projects = array_keys($team->getProjects(FALSE, TRUE, FALSE)); // TODO $reliabilityTableMEE = array(); $reliabilityTableEE = array(); foreach ($this->timeTrackingTable as $date => $timeTracking) { $prodRate = $this->getEffortEstimReliabilityRate($projects, $timeTracking->getStartTimestamp(), $timeTracking->getEndTimestamp()); $timestamp = Tools::formatDate("%Y-%m-01", $timeTracking->getStartTimestamp()); $reliabilityTableMEE[$timestamp] = $prodRate['MEE']; $reliabilityTableEE[$timestamp] = $prodRate['EE']; } $this->execData = array(); $this->execData['MEE'] = $reliabilityTableMEE; $this->execData['EE'] = $reliabilityTableEE; }
/** * */ 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; }
/** * @param string $userName * @param int $dayPixSize * @param ScheduledTask[] $scheduledTaskList * @param int $teamid * @return mixed[][] */ private function getScheduledTasks($userName, $dayPixSize, array $scheduledTaskList, $teamid, $session_userid, $isManager) { $totalPix = 0; $projList = TeamCache::getInstance()->getTeam($teamid)->getProjects(); $scheduledTasks = array(); foreach ($scheduledTaskList as $scheduledTask) { $taskPixSize = $scheduledTask->getPixSize($dayPixSize); $totalPix += $taskPixSize; // set color if (NULL != $scheduledTask->getDeadline()) { if (!$scheduledTask->isOnTime()) { $color = "red"; } else { $color = $scheduledTask->isMonitored() ? "grey" : "green"; } } else { $color = $scheduledTask->isMonitored() ? "grey" : "blue"; } // hide tasks not in team projects $issue = IssueCache::getInstance()->getIssue($scheduledTask->getIssueId()); $taskTitle = $scheduledTask->getDescription(); $formatedTitle = str_replace("'", ' ', $taskTitle); $formatedTitle = str_replace('"', ' ', $formatedTitle); $drawnTaskPixSize = $taskPixSize - 1; $optDisplayExtRef = $this->session_user->getPlanningOption($teamid, 'displayExtRef'); $displayedId = 1 == $optDisplayExtRef ? $issue->getTcId() : $scheduledTask->getIssueId(); $taskTooltip = $this->getTaskTooltip($issue, $scheduledTask, $teamid, $session_userid, $isManager); $sTask = array("bugid" => $scheduledTask->getIssueId(), "extRef" => $issue->getTcId(), "displayedId" => $displayedId, "title" => $formatedTitle, "width" => $drawnTaskPixSize, "color" => $color, "strike" => !array_key_exists($issue->getProjectId(), $projList), "taskTooltip" => $taskTooltip); if ($scheduledTask->isMonitored()) { $sTask["handlerName"] = $scheduledTask->getHandlerName(); } if ($scheduledTask->getDeadline() > 0) { $sTask["deadLine"] = date(T_("Y-m-d"), $scheduledTask->getDeadline()); } $scheduledTasks[$scheduledTask->getIssueId()] = $sTask; } return $scheduledTasks; }
/** * * returns an array of [user][activity] * activity in (elapsed, sidetask, other, external, leave) * */ public function execute() { $team = TeamCache::getInstance()->getTeam($this->teamid); $members = $team->getActiveMembers($this->startTimestamp, $this->endTimestamp); $formatedUseridString = implode(', ', array_keys($members)); //$extProjId = Config::getInstance()->getValue(Config::id_externalTasksProject); $issueList = $this->inputIssueSel->getIssueList(); $formatedBugidString = implode(', ', array_keys($issueList)); $query = "SELECT ROUND(SUM(tt.duration), 2) as duration, prj.name as prjName\n FROM codev_timetracking_table as tt, mantis_project_table as prj, mantis_bug_table as bug \n WHERE tt.bugid = bug.id\n AND bug.project_id = prj.id\n AND bug.id IN ({$formatedBugidString})\n AND tt.userid IN ({$formatedUseridString}) "; if (isset($this->startTimestamp)) { $query .= " AND tt.date >= {$this->startTimestamp} "; } if (isset($this->endTimestamp)) { $query .= " AND tt.date <= {$this->endTimestamp} "; } $query .= " GROUP BY prj.id\n ORDER BY `prj`.`name` ASC"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "<span style='color:red'>ERROR: Query FAILED</span>"; exit; } $projectLoad = array(); while ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) { $projectLoad["{$row->prjName}"] = (double) $row->duration; } // --- $this->execData = $projectLoad; }
/** * return TimeTracks created by the team during the timestamp * @param bool $isTeamProjOnly * @return array[][] : $projectTracks[projectid][bugid][jobid] = duration */ public function getProjectTracks($isTeamProjOnly = false) { $accessLevel_dev = Team::accessLevel_dev; $accessLevel_manager = Team::accessLevel_manager; // For all bugs in timestamp $query = "SELECT bug.id as bugid, bug.project_id, timetracking.jobid, SUM(timetracking.duration) as duration " . "FROM `codev_timetracking_table` as timetracking, `codev_team_user_table` as team_user, `mantis_bug_table` as bug, `codev_job_table` as job, `mantis_project_table` as project " . "WHERE team_user.user_id = timetracking.userid " . "AND bug.id = timetracking.bugid " . "AND project.id = bug.project_id " . "AND job.id = timetracking.jobid " . "AND timetracking.date >= {$this->startTimestamp} AND timetracking.date < {$this->endTimestamp} " . "AND team_user.team_id = {$this->team_id} " . "AND team_user.access_level IN ({$accessLevel_dev}, {$accessLevel_manager}) "; if (false != $isTeamProjOnly) { $projList = TeamCache::getInstance()->getTeam($this->team_id)->getProjects(); $formatedProjList = implode(', ', array_keys($projList)); $query .= "AND bug.project_id in ({$formatedProjList}) "; } $query .= "GROUP BY bug.id, job.id, bug.project_id ORDER BY project.name, bug.id DESC;"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "<span style='color:red'>ERROR: Query FAILED</span>"; exit; } $projectTracks = array(); while ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) { if (!array_key_exists($row->project_id, $projectTracks)) { $projectTracks[$row->project_id] = array(); // create array for bug_id $projectTracks[$row->project_id][$row->bugid] = array(); // create array for jobs } if (!array_key_exists($row->bugid, $projectTracks[$row->project_id])) { $projectTracks[$row->project_id][$row->bugid] = array(); // create array for new jobs } $projectTracks[$row->project_id][$row->bugid][$row->jobid] = round($row->duration, 2); } return $projectTracks; }
/** * for all users of the team, return incomplete/missing days in the period * * @param TimeTracking $timeTracking * @return ConsistencyError2[] */ public static function checkIncompleteDays(TimeTracking $timeTracking, $userid = NULL) { $cerrList = array(); $now = time(); if (is_null($userid)) { $mList = TeamCache::getInstance()->getTeam($timeTracking->getTeamid())->getActiveMembers(); $useridList = array_keys($mList); } else { $useridList = array($userid); } foreach ($useridList as $userid) { $incompleteDays = $timeTracking->checkCompleteDays($userid, TRUE); foreach ($incompleteDays as $date => $value) { if ($date > $now) { continue; } // skip dates in the future $label = NULL; if ($value < 1) { $label = T_("incomplete (missing ") . (1 - $value) . T_(" days") . ")"; } else { $label = T_("inconsistent") . " (" . $value . " " . T_("days") . ")"; } $cerr = new ConsistencyError2(NULL, $userid, NULL, $date, $label); $cerr->severity = ConsistencyError2::severity_error; $cerrList[] = $cerr; } $missingDays = $timeTracking->checkMissingDays($userid); foreach ($missingDays as $date) { if ($date > $now) { continue; } // skip dates in the future $cerr = new ConsistencyError2(0, $userid, NULL, $date, T_("not defined.")); $cerr->severity = ConsistencyError2::severity_error; $cerrList[] = $cerr; } } return $cerrList; }
private function getWorkingDaysPerProjectPerUser($startTimestamp, $endTimestamp, $isExtTasksPrj, $isSideTasksPrj) { $team = TeamCache::getInstance()->getTeam($this->teamid); $activeMembers = $team->getActiveMembers($startTimestamp, $endTimestamp, TRUE); $activeMembersIds = array_keys($activeMembers); $usersData = array(); // Time spend by user for each project (depending on the chosen Timestamp) foreach ($activeMembersIds as $user_id) { $user = UserCache::getInstance()->getUser($user_id); $timeTracks = $user->getTimeTracks($startTimestamp, $endTimestamp); $userElapsedPerProject = array(); foreach ($timeTracks as $timeTrack) { $userElapsedPerProject[$timeTrack->getProjectId()] += $timeTrack->getDuration(); } $usersData[$user_id] = $userElapsedPerProject; } // Check SideTask & ExternalTask $projList = $team->getProjects(true, true, $isSideTasksPrj); if (!$isExtTasksPrj) { if (array_key_exists(Config::getInstance()->getValue(Config::id_externalTasksProject), $projList)) { unset($projList[Config::getInstance()->getValue(Config::id_externalTasksProject)]); } } // Time elapsed per user and per project (plus total per user) $usersSmartyData = array(); foreach ($activeMembers as $user_id => $realName) { $elapsedPerProject = array(); $userTotal = 0; foreach (array_keys($projList) as $projId) { $val = $usersData[$user_id][$projId]; $elapsedPerProject[$projId] = $val; $userTotal += $val; } // Formatting for Smarty $usersSmartyData[] = array('id' => $user_id, 'name' => $realName, 'elapsedPerProject' => $elapsedPerProject, 'total' => $userTotal); } // Time elapsed per project plus total for all the projects $totalAllProj = 0; $totalPerProj = array(); foreach (array_keys($projList) as $projId) { foreach ($activeMembersIds as $userId) { $totalAllProj += $usersData[$userId][$projId]; $totalPerProj[$projId] += $usersData[$userId][$projId]; } } $totalPerProj['total'] = $totalAllProj; $data = array('usersData' => $usersSmartyData, 'projList' => $projList, 'totalPerProj' => $totalPerProj); return $data; }
private function generateStatusHistoryGraph($teamid) { $team = TeamCache::getInstance()->getTeam($teamid); $issueList = $team->getTeamIssueList(true, false); $issueSel = new IssueSelection('Team ' . $team->getName() . ' issues'); $issueSel->addIssueList($issueList); $startTimestamp = $team->getDate(); $endTimestamp = time(); $params = array('startTimestamp' => $startTimestamp, 'endTimestamp' => $endTimestamp, 'interval' => 10); $statusHistoryIndicator = new StatusHistoryIndicator(); $statusHistoryIndicator->execute($issueSel, $params); $smartyobj = $statusHistoryIndicator->getSmartyObject(); foreach ($smartyobj as $smartyKey => $smartyVariable) { $this->smartyHelper->assign($smartyKey, $smartyVariable); } }
/** * @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; }
/** * team members (exept Observers) working on this team at that timestamp * @param int $teamid * @param int $timestamp date (if NULL, today) * @return string[] * @deprecated Use TeamCache::getInstance()->getTeam($teamid)->getActiveMembers($startTimestamp, $endTimestamp) */ public static function getActiveMemberList($teamid, $startTimestamp = NULL, $endTimestamp = NULL) { return TeamCache::getInstance()->getTeam($teamid)->getActiveMembers($startTimestamp, $endTimestamp); }
/** * * @param array $selectedUseridList * @return type */ private function getTeamMembers(array $selectedUseridList = array(0)) { $team = TeamCache::getInstance()->getTeam($this->teamid); #$memberList = $team->getActiveMembers(); $memberList = $team->getMembers(); $members = array(); $members[0] = array('id' => 0, 'name' => T_('(all)'), 'selected' => in_array(0, $selectedUseridList)); foreach ($memberList as $id => $name) { // we want ActiveMembers + Customers $user = UserCache::getInstance()->getUser($id); if ($user->isTeamObserver($this->teamid)) { continue; } $selected = in_array($id, $selectedUseridList); $members[] = array('id' => $id, 'name' => $name, 'selected' => $selected); } return $members; }
// Note: i18n is included by the Controler class, but Ajax dos not use it... require_once 'i18n/i18n.inc.php'; if (Tools::isConnectedUser() && (isset($_GET['action']) || isset($_POST['action']))) { $logger = Logger::getLogger("TimeTrackingAjax"); $teamid = isset($_SESSION['teamid']) ? $_SESSION['teamid'] : 0; $session_user = $_SESSION['userid']; // TODO check $session_user & teamid ? #$action = $_POST['action']; $action = Tools::getSecurePOSTStringValue('action'); if (isset($action)) { $smartyHelper = new SmartyHelper(); if ("getIssuesAndDurations" == $action) { // TODO check session_user is allowed to manage user ( & get issue list...) $defaultProjectid = Tools::getSecurePOSTIntValue('projectid'); $managedUserid = Tools::getSecurePOSTIntValue('managedUserid'); $team = TeamCache::getInstance()->getTeam($teamid); $projList = $team->getProjects(true, false); $managedUser = UserCache::getInstance()->getUser($managedUserid); $isOnlyAssignedTo = '0' == $managedUser->getTimetrackingFilter('onlyAssignedTo') ? false : true; $isHideResolved = '0' == $managedUser->getTimetrackingFilter('hideResolved') ? false : true; $availableIssues = TimeTrackingTools::getIssues($teamid, $defaultProjectid, $isOnlyAssignedTo, $managedUserid, $projList, $isHideResolved, 0); $jobs = TimeTrackingTools::getJobs($defaultProjectid, $teamid); $durations = TimeTrackingTools::getDurationList($teamid); // return data $data = array('availableIssues' => $availableIssues, 'availableJobs' => $jobs, 'availableDurations' => $durations); $jsonData = json_encode($data); // return data echo $jsonData; } elseif ($action == 'getUpdateBacklogData') { // get info to display the updateBacklog dialogbox // (when clicking on the backlog value in WeekTaskDetails)
/** * @param int $teamid * @param int $selectedCmdId * @return mixed[] */ private function getCommands($teamid, $selectedCmdId, $cmdStateFilters) { $commands = array(); if (0 != $teamid) { $team = TeamCache::getInstance()->getTeam($teamid); $cmdList = $team->getCommands(); foreach ($cmdList as $id => $cmd) { // skip if state filter is set to 0 (if 1 or unset, cmd is visible) $state = $cmd->getState(); if (array_key_exists($state, $cmdStateFilters)) { if (0 == $cmdStateFilters[$state]) { continue; } } $commands[$id] = array('id' => $id, 'name' => $cmd->getName(), 'reference' => $cmd->getReference(), 'selected' => $id == $selectedCmdId); } } return $commands; }
/** * creates for each project a table with the following fields: * TaskName | RAF | <Jobs> * @param TimeTracking $timeTracking * @param string $myFile * @return string */ private function exportProjectActivityToCSV(TimeTracking $timeTracking, $myFile) { $sepChar = ';'; $team = TeamCache::getInstance()->getTeam($timeTracking->getTeamid()); if (!is_dir(Constants::$codevOutputDir . DIRECTORY_SEPARATOR . 'reports')) { mkdir(Constants::$codevOutputDir . DIRECTORY_SEPARATOR . 'reports', 0755); } $fh = fopen($myFile, 'w'); // $projectTracks[projectid][bugid][jobid] = duration $projectTracks = $timeTracking->getProjectTracks(); foreach ($projectTracks as $projectId => $bugList) { // write table header $project = ProjectCache::getInstance()->getProject($projectId); $stringData = $project->getName() . "\n"; $stringData .= T_("Task") . $sepChar; $stringData .= T_("BL") . $sepChar; $jobList = $project->getJobList($team->getProjectType($projectId)); foreach ($jobList as $jobName) { $stringData .= $jobName . $sepChar; } $stringData .= "\n"; // write table content (by bugid) foreach ($bugList as $bugid => $jobs) { $issue = IssueCache::getInstance()->getIssue($bugid); // remove sepChar from summary text $formatedSummary = str_replace($sepChar, " ", $issue->getSummary()); $stringData .= "{$bugid} / " . $issue->getTcId() . " : " . $formatedSummary . $sepChar; $stringData .= $issue->getBacklog() . $sepChar; foreach ($jobList as $jobId => $jobName) { $stringData .= $jobs[$jobId] . $sepChar; } $stringData .= "\n"; } $stringData .= "\n"; fwrite($fh, $stringData); } fclose($fh); return $myFile; }