Example #1
0
 protected function display()
 {
     // Admins only
     if (Tools::isConnectedUser()) {
         $session_user = UserCache::getInstance()->getUser($_SESSION['userid']);
         if ($session_user->isTeamMember(Config::getInstance()->getValue(Config::id_adminTeamId))) {
             $this->smartyHelper->assign('defaultColor', Holidays::$defaultColor);
             if (isset($_POST['hol_color'])) {
                 $formatedDate = Tools::getSecurePOSTStringValue('date');
                 $timestamp = Tools::date2timestamp($formatedDate);
                 $hol_desc = Tools::getSecurePOSTStringValue('hol_desc');
                 $hol_color = Tools::getSecurePOSTStringValue('hol_color');
                 if (!Holidays::save($timestamp, $hol_desc, $hol_color)) {
                     $this->smartyHelper->assign('error', T_("Couldn't add the holiday"));
                 }
             } elseif (isset($_POST['hol_id'])) {
                 $hol_id = Tools::getSecurePOSTIntValue('hol_id');
                 if (!Holidays::delete($hol_id)) {
                     $this->smartyHelper->assign('error', T_("Couldn't remove the holiday"));
                 }
             }
             $this->smartyHelper->assign('holidays', Holidays::getHolidays());
         }
     }
 }
Example #2
0
 protected function display()
 {
     if (Tools::isConnectedUser()) {
         // TODO SECURITY check array_key_exists($this->teamid, $this->teamList)
         // only teamMembers & observers can access this page
         if (0 == $this->teamid || $this->session_user->isTeamCustomer($this->teamid)) {
             $this->smartyHelper->assign('accessDenied', TRUE);
         } else {
             $year = Tools::getSecurePOSTIntValue('year', date('Y'));
             $weekid = Tools::getSecurePOSTIntValue('weekid', date('W'));
             $this->smartyHelper->assign('weeks', SmartyTools::getWeeks($weekid, $year));
             $this->smartyHelper->assign('years', SmartyTools::getYears($year, 1));
             $isDetailed = isset($_POST['cb_detailed']) ? TRUE : FALSE;
             $this->smartyHelper->assign('isChecked', $isDetailed);
             $weekDates = Tools::week_dates($weekid, $year);
             $startTimestamp = $weekDates[1];
             $endTimestamp = mktime(23, 59, 59, date("m", $weekDates[7]), date("d", $weekDates[7]), date("Y", $weekDates[7]));
             $timeTracking = new TimeTracking($startTimestamp, $endTimestamp, $this->teamid);
             $this->smartyHelper->assign('weekDetails', $this->getWeekDetails($timeTracking, $isDetailed, $weekDates, $this->session_user->getId()));
             // 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"));
             }
             // IssueNotes
             $timeTracks = $timeTracking->getTimeTracks();
             $issueNotes = array();
             foreach ($timeTracks as $tt) {
                 $bug_id = $tt->getIssueId();
                 if (!array_key_exists($bug_id, $issueNotes)) {
                     $issueNote = IssueNote::getTimesheetNote($bug_id);
                     if (!is_null($issueNote)) {
                         $issue = IssueCache::getInstance()->getIssue($bug_id);
                         $user = UserCache::getInstance()->getUser($issueNote->getReporterId());
                         $issueNoteText = trim(IssueNote::removeAllReadByTags($issueNote->getText()));
                         $isManager = $this->session_user->isTeamManager($this->teamid);
                         // only Managers can markAsRead
                         $isRead = TRUE;
                         if ($isManager) {
                             $isRead = 0 != $issueNote->isReadBy($this->session_userid);
                         }
                         // Delete allowed by owner & managers
                         if ($this->session_userid == $issueNote->getReporterId() || $isManager) {
                             $isDeleteGranted = TRUE;
                         } else {
                             $isDeleteGranted = FALSE;
                         }
                         $issueNoteInfo = array('taskDesc' => SmartyTools::getIssueDescription($bug_id, $issue->getTcId(), htmlspecialchars($issue->getSummary())), 'note' => nl2br(htmlspecialchars($issueNoteText)), 'reporter' => $user->getRealname(), 'date' => date('Y-m-d H:i', $issueNote->getLastModified()), 'readBy' => implode(',<br>', array_keys($issueNote->getReadByList(TRUE))), 'issueNoteId' => $issueNote->getId(), 'isRead' => $isRead, 'isDeleteGranted' => $isDeleteGranted);
                         $issueNotes[$bug_id] = $issueNoteInfo;
                     }
                 }
             }
             if (count($issueNotes) > 0) {
                 $this->smartyHelper->assign('issueNotes', $issueNotes);
             }
         }
     }
 }
Example #3
0
 protected function display()
 {
     if (Tools::isConnectedUser()) {
         // Admins only
         $session_user = UserCache::getInstance()->getUser($_SESSION['userid']);
         if ($session_user->isTeamMember(Config::getInstance()->getValue(Config::id_adminTeamId))) {
             $projectList = $this->getProjectList(false);
             if (isset($_POST['projectid']) && array_key_exists($_POST['projectid'], $projectList)) {
                 $projectid = Tools::getSecurePOSTIntValue('projectid');
                 $_SESSION['projectid'] = $projectid;
             } elseif (isset($_SESSION['projectid']) && array_key_exists($_SESSION['projectid'], $projectList)) {
                 $projectid = $_SESSION['projectid'];
             } else {
                 $projectIds = array_keys($projectList);
                 if (count($projectIds) > 0) {
                     $projectid = $projectIds[0];
                 } else {
                     $projectid = 0;
                 }
             }
             $this->smartyHelper->assign('projects', SmartyTools::getSmartyArray($projectList, $projectid));
             // display current workflow
             if (0 != $projectid) {
                 $clone_projectid = Tools::getSecurePOSTIntValue('clone_projectid', 0);
                 if ($clone_projectid == $projectid || !array_key_exists($clone_projectid, $projectList)) {
                     $clone_projectid = 0;
                 }
                 $action = Tools::getSecurePOSTStringValue('action', '');
                 if ("cloneToProject" == $action) {
                     #echo "Clone $projectid ---> $clone_projectid<br>";
                     $errMsg = Project::cloneAllProjectConfig($projectid, $clone_projectid);
                     $this->smartyHelper->assign('msg', 'Clone to project : ' . $errMsg);
                 } elseif ("cloneFromProject" == $action) {
                     #echo "Clone $clone_projectid ---> $projectid<br>";
                     $errMsg = Project::cloneAllProjectConfig($clone_projectid, $projectid);
                     $this->smartyHelper->assign('msg', 'Clone from project : ' . $errMsg);
                 }
                 unset($projectList[$projectid]);
                 $this->smartyHelper->assign('cloneProjects', SmartyTools::getSmartyArray($projectList, $clone_projectid));
                 $proj = ProjectCache::getInstance()->getProject($projectid);
                 $this->smartyHelper->assign('currentProjectId', $projectid);
                 $this->smartyHelper->assign('defaultProjectId', $clone_projectid);
                 $this->smartyHelper->assign('currentProjectName', $proj->getName());
                 $this->smartyHelper->assign('disabled', 0 == $clone_projectid);
                 $projectsInfo = array();
                 $projectsInfo[] = $this->getProjectInfo($proj, "tabsProject");
                 if (0 != $clone_projectid) {
                     $cproj = ProjectCache::getInstance()->getProject($clone_projectid);
                     $this->smartyHelper->assign('defaultProjectName', $cproj->getName());
                     $projectsInfo[] = $this->getProjectInfo($cproj, "tabsCloneProject");
                 }
                 $this->smartyHelper->assign('projectsInfo', $projectsInfo);
             }
         }
     }
 }
Example #4
0
 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);
     }
 }
Example #5
0
 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);
                 }
             }
         }
     }
 }
Example #6
0
 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);
             }
         }
     }
 }
            if (!is_null($issueNote)) {
                $userid = $_SESSION['userid'];
                $issueNote->markAsRead($userid);
                $data = 'OK';
            } else {
                $data = 'ERROR';
                // TODO return ERROR
                Tools::sendBadRequest("Could not mark as read.");
            }
            // return data
            echo $data;
        } else {
            if ($_POST['action'] == 'deleteNote') {
                $userid = $_SESSION['userid'];
                $bugid = Tools::getSecurePOSTIntValue('bugid');
                $bugnoteid = Tools::getSecurePOSTIntValue('bugnote_id');
                $retCode = IssueNote::delete($bugnoteid, $bugid, $userid);
                if ($retCode) {
                    $data = 'OK';
                } else {
                    $data = 'ERROR';
                    // TODO return ERROR
                    Tools::sendBadRequest("Could not delete note.");
                }
                // return data
                echo $data;
            }
        }
    }
} else {
    Tools::sendUnauthorizedAccess();
Example #8
0
 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);
                 }
             }
         }
     }
 }
Example #9
0
File: date.php Project: fg-ok/codev
    echo 'jQuery("#datepicker").datepicker("setDate" ,"' . $defaultDate1 . '");';
    echo '});';
    echo '</script>';
    echo '<input type="text" id="datepicker" class="datepicker" name="date" maxlength="10" size="10" title="Date" />';
    echo "&nbsp;<input type=submit value='Convert to Timestamp' />\n";
    echo "</form>\n";
    echo "</div>";
}
function setTimestampToDateForm($timestamp)
{
    echo "<div class=left>";
    // Create form
    echo "<form id='form2' name='form2' method='post' action='{$_SERVER['PHP_SELF']}'>\n";
    echo "Timestamp: <input name='timestamp' type='text' id='timestamp' value='{$timestamp}'>\n";
    echo "&nbsp;<input type=submit value='Convert to Date'>\n";
    echo "</form>\n";
    echo "</div>";
}
// =========== MAIN ==========
echo '<html><head><base href="' . Tools::getServerRootURL() . '/" /></head><body>';
$date1 = Tools::getSecurePOSTStringValue("date", date("Y-m-d", time()));
setCalendarToDateForm($date1);
echo "<br/>";
$timestamp = Tools::getSecurePOSTIntValue("timestamp", 0);
setTimestampToDateForm($timestamp);
if (isset($_POST["date"])) {
    $timestamp = Tools::date2timestamp($date1);
    echo "<br/>{$formatedDate} => {$timestamp}<br/>";
} elseif (isset($_POST["timestamp"])) {
    echo "<br/>{$timestamp} => " . date("Y-m-d H:i:s", $timestamp) . "<br/>";
}
Example #10
0
 protected function display()
 {
     if (Tools::isConnectedUser()) {
         $teamList = $this->session_user->getTeamList();
         // only teamMembers & observers can access this page
         if (0 == $this->teamid || $this->session_user->isTeamCustomer($this->teamid)) {
             $this->smartyHelper->assign('accessDenied', TRUE);
         } else {
             $pageWidth = Tools::getSecurePOSTIntValue('width', Tools::getSecureGETIntValue('width', 0));
             $this->smartyHelper->assign('width', $pageWidth);
             if (array_key_exists($this->teamid, $teamList)) {
                 $this->smartyHelper->assign('consistencyErrors', $this->getConsistencyErrors($this->teamid));
                 $team = TeamCache::getInstance()->getTeam($this->teamid);
                 $isManager = $this->session_user->isTeamManager($this->teamid);
                 $isObserver = $this->session_user->isTeamObserver($this->teamid);
                 $this->smartyHelper->assign('isManager', $isManager || $isObserver);
                 // display backlog (unassigned tasks)
                 $unassignedIssues = $team->getUnassignedTasks();
                 $unassigendSel = new IssueSelection("unassigned from team {$this->teamid}");
                 $unassigendSel->addIssueList($unassignedIssues);
                 $this->smartyHelper->assign('unassigned_nbIssues', $unassigendSel->getNbIssues());
                 $this->smartyHelper->assign('unassigned_MEE', $unassigendSel->mgrEffortEstim);
                 $this->smartyHelper->assign('unassigned_EE', $unassigendSel->effortEstim + $unassigendSel->effortAdd);
                 // get planningOptions
                 $keyvalue = Tools::getSecurePOSTStringValue('planningOptions', '');
                 if (!empty($keyvalue)) {
                     $planningOptions = Tools::doubleExplode(':', ',', $keyvalue);
                     $this->session_user->setPlanningOptions($this->teamid, $planningOptions);
                 }
                 $this->smartyHelper->assign('planningOptions', $this->getPlanningOptions());
                 $today = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
                 $graphSize = "undefined" != $pageWidth ? $pageWidth - 150 : 800;
                 $allTasksLists = array();
                 $workloads = array();
                 $teamMembers = $team->getUsers();
                 $nbDaysToDisplay = 0;
                 foreach ($teamMembers as $user) {
                     $workload = 0;
                     // show only developper's & manager's tasks
                     if (!$user->isTeamDeveloper($this->teamid) && !$user->isTeamManager($this->teamid)) {
                         if (self::$logger->isDebugEnabled()) {
                             self::$logger->debug("user " . $user->getId() . " excluded from scheduled users on team {$this->teamid}");
                         }
                         continue;
                     }
                     if (NULL != $user->getDepartureDate($this->teamid) && $user->getDepartureDate($this->teamid) < $today) {
                         continue;
                     }
                     $scheduledTaskList = ScheduledTask::scheduleUser($user, $today, $this->teamid, TRUE);
                     foreach ($scheduledTaskList as $scheduledTask) {
                         $workload += $scheduledTask->getDuration();
                     }
                     $nbDaysToDisplay = $nbDaysToDisplay < $workload ? $workload : $nbDaysToDisplay;
                     $allTasksLists[$user->getName()] = $scheduledTaskList;
                     $workloads[$user->getName()] = $workload;
                 }
                 $dayPixSize = 0 != $nbDaysToDisplay ? $graphSize / $nbDaysToDisplay : 0;
                 $dayPixSize = round($dayPixSize);
                 #echo "DEBUG dayPixSize = $dayPixSize<br/>\n";
                 $this->smartyHelper->assign('planning', $this->getPlanning($nbDaysToDisplay, $dayPixSize, $allTasksLists, $workloads, $this->teamid, $this->session_userid, $isManager));
                 $this->smartyHelper->assign('colors', array("green" => T_("onTime"), "red" => T_("NOT onTime"), "blue" => T_("no deadLine"), "grey" => T_("monitored")));
                 $this->smartyHelper->assign('dayPixSize', $dayPixSize - 1);
             }
         }
     }
 }
Example #11
0
                    // return data
                    $data = array('bugid' => $bugid, 'issuenoteid' => $issueNoteId, 'issuenote_text' => $issueNoteText);
                    $jsonData = json_encode($data);
                    // return data
                    echo $jsonData;
                } else {
                    if ($action == 'saveIssueNote') {
                        $bugid = Tools::getSecurePOSTIntValue('bugid');
                        $reporter_id = $session_user;
                        $issueNoteText = filter_input(INPUT_POST, 'issuenote_text');
                        IssueNote::setTimesheetNote($bugid, $issueNoteText, $reporter_id);
                        // return data
                        // the complete WeekTaskDetails Div must be updated
                        $weekid = Tools::getSecurePOSTIntValue('weekid');
                        $year = Tools::getSecurePOSTIntValue('year');
                        $userid = Tools::getSecurePOSTIntValue('userid', $session_user);
                        setWeekTaskDetails($smartyHelper, $weekid, $year, $userid, $teamid);
                        $smartyHelper->display('ajax/weekTaskDetails');
                    }
                }
            }
        }
    }
} else {
    Tools::sendUnauthorizedAccess();
}
/**
 * set smarty variables needed to display the WeekTaskDetails table
 *
 * @param type $smartyHelper
 * @param type $weekid
Example #12
0
 protected function display()
 {
     if (Tools::isConnectedUser()) {
         $teamList = NULL;
         // leadedTeams only, except Admins: they can edit all teams
         if ($this->session_user->isTeamMember(Config::getInstance()->getValue(Config::id_adminTeamId))) {
             $teamList = Team::getTeams(true);
         } else {
             $teamList = $this->session_user->getLeadedTeamList(true);
         }
         if (count($teamList) > 0) {
             if (isset($_POST['deletedteam'])) {
                 $teamidToDelete = Tools::getSecurePOSTIntValue("deletedteam");
                 if (array_key_exists($teamidToDelete, $teamList)) {
                     $retCode = Team::delete($teamidToDelete);
                     if (!$retCode) {
                         $this->smartyHelper->assign('error', T_("Couldn't delete the team"));
                     } else {
                         if ($teamidToDelete == $_SESSION['teamid']) {
                             unset($_SESSION['teamid']);
                             $this->updateTeamSelector();
                         }
                         unset($teamList[$teamidToDelete]);
                     }
                 }
             }
             // use the teamid set in the form, if not defined (first page call) use session teamid
             if (isset($_POST['displayed_teamid'])) {
                 $displayed_teamid = Tools::getSecurePOSTIntValue('displayed_teamid');
             } else {
                 if (isset($_SESSION['teamid']) && array_key_exists($_SESSION['teamid'], $teamList)) {
                     $displayed_teamid = $_SESSION['teamid'];
                 } else {
                     $teamIds = array_keys($teamList);
                     if (count($teamIds) > 0) {
                         $displayed_teamid = $teamIds[0];
                     } else {
                         $displayed_teamid = 0;
                     }
                 }
             }
             $this->smartyHelper->assign('availableTeams', SmartyTools::getSmartyArray($teamList, $displayed_teamid));
             if (array_key_exists($displayed_teamid, $teamList)) {
                 $team = TeamCache::getInstance()->getTeam($displayed_teamid);
                 if ($displayed_teamid != Config::getInstance()->getValue(Config::id_adminTeamId)) {
                     $this->smartyHelper->assign('allowDeleteTeam', 1);
                 }
                 // ----------- actions ----------
                 $action = isset($_POST['action']) ? $_POST['action'] : '';
                 if ($action == "updateTeamLeader") {
                     $teamleader_id = Tools::getSecurePOSTIntValue('leaderid');
                     if (!$team->setLeader($teamleader_id)) {
                         $this->smartyHelper->assign('error', T_("Couldn't update the team leader"));
                     } else {
                         // --- add teamLeader as Mantis manager of the SideTaskProject
                         //$leader = UserCache::getInstance()->getUser($teamleader_id);
                         //$access_level = 70; // TODO mantis manager
                         //$leader->setProjectAccessLevel($stproj_id, $access_level);
                     }
                 } elseif ($action == "updateTeamCreationDate") {
                     $formatedDate = Tools::getSecurePOSTStringValue("date_createTeam");
                     $date_create = Tools::date2timestamp($formatedDate);
                     if (!$team->setCreationDate($date_create)) {
                         $this->smartyHelper->assign('error', T_("Couldn't update the creation date"));
                     }
                 } elseif ($action == "setTeamEnabled") {
                     $isTeamEnabled = 0 == Tools::getSecurePOSTIntValue("isTeamEnabled") ? false : true;
                     if (!$team->setEnabled($isTeamEnabled)) {
                         $this->smartyHelper->assign('error', T_("Couldn't enable/disable team"));
                     }
                 } elseif ($action == "addTeamMember") {
                     $memberid = Tools::getSecurePOSTIntValue('memberid');
                     $memberAccess = Tools::getSecurePOSTIntValue('member_access');
                     $formatedDate = Tools::getSecurePOSTStringValue("date1");
                     $arrivalTimestamp = Tools::date2timestamp($formatedDate);
                     try {
                         // save to DB
                         $team->addMember($memberid, $arrivalTimestamp, $memberAccess);
                         // CodevTT administrators can manage ExternalTasksProject in Mantis
                         if (Config::getInstance()->getValue(Config::id_adminTeamId) == $team->getId()) {
                             $newUser = UserCache::getInstance()->getUser($memberid);
                             $extProjId = Config::getInstance()->getValue(Config::id_externalTasksProject);
                             $access_level = 70;
                             // TODO mantis manager
                             $newUser->setProjectAccessLevel($extProjId, $access_level);
                         }
                     } catch (Exception $e) {
                         $this->smartyHelper->assign('error', "Couldn't add user {$memberid} to the team");
                     }
                 } elseif ($action == "setMemberDepartureDate") {
                     $formatedDate = Tools::getSecurePOSTStringValue("date2");
                     $departureTimestamp = Tools::date2timestamp($formatedDate);
                     $memberid = Tools::getSecurePOSTIntValue('memberid');
                     $team->setMemberDepartureDate($memberid, $departureTimestamp);
                 } elseif ($action == 'addMembersFrom') {
                     $src_teamid = Tools::getSecurePOSTIntValue('f_src_teamid');
                     // add all members declared in Team $src_teamid (same dates, same access)
                     // except if already declared
                     $team->addMembersFrom($src_teamid);
                 } elseif ($action == 'removeIssueTooltip') {
                     $projectid = Tools::getSecurePOSTIntValue('projectid');
                     $project = ProjectCache::getInstance()->getProject($projectid);
                     $project->setIssueTooltipFields(NULL, $displayed_teamid);
                 } elseif ($action == 'setConsistencyCheck') {
                     $keyvalue = Tools::getSecurePOSTStringValue('checkItems');
                     $checkList = Tools::doubleExplode(':', ',', $keyvalue);
                     $team->setConsistencyCheckList($checkList);
                 } elseif ($action == 'setGeneralPrefs') {
                     $keyvalue = Tools::getSecurePOSTStringValue('checkItems');
                     $checkList = Tools::doubleExplode(':', ',', $keyvalue);
                     $team->setGeneralPrefsList($checkList);
                 } elseif ($action == 'createSideTaskProject') {
                     $stprojName = Tools::getSecurePOSTStringValue('stprojName');
                     $stproj_id = $team->createSideTaskProject($stprojName);
                     if ($stproj_id > 0) {
                         $stproj = ProjectCache::getInstance()->getProject($stproj_id);
                         // add teamLeader as Mantis manager of the SideTaskProject
                         $leader = UserCache::getInstance()->getUser($team->getLeaderId());
                         $access_level = 70;
                         // TODO mantis manager
                         $leader->setProjectAccessLevel($stproj_id, $access_level);
                         // add SideTaskProject Categories
                         $stproj->addCategoryProjManagement(T_("Project Management"));
                         $stproj->addCategoryInactivity(T_("Inactivity"));
                         $stproj->addCategoryIncident(T_("Incident"));
                         $stproj->addCategoryTools(T_("Tools"));
                         $stproj->addCategoryWorkshop(T_("Team Workshop"));
                     }
                 } elseif (isset($_POST["deleteValue"])) {
                     $duration = TimeTrackingTools::getDurationList($displayed_teamid);
                     $duration_value = Tools::getSecurePOSTStringValue('deleteValue');
                     unset($duration[$duration_value]);
                     if (count($duration) == 0) {
                         Config::deleteValue(Config::id_durationList, array(0, 0, $displayed_teamid, 0, 0, 0));
                     } else {
                         Config::setValue(Config::id_durationList, Tools::doubleImplode(":", ",", $duration), Config::configType_keyValue, NULL, 0, 0, $displayed_teamid);
                     }
                 } elseif (isset($_POST["addValue"])) {
                     $duration = TimeTrackingTools::getDurationList($displayed_teamid);
                     $duration_value = Tools::getSecurePOSTStringValue('addValue');
                     $duration_display = Tools::getSecurePOSTStringValue('addDisplay');
                     $duration[$duration_value] = $duration_display;
                     Config::setValue(Config::id_durationList, Tools::doubleImplode(":", ",", $duration), Config::configType_keyValue, NULL, 0, 0, $displayed_teamid);
                 } elseif (isset($_POST["updateValue"])) {
                     $duration = TimeTrackingTools::getDurationList($displayed_teamid);
                     $duration_value = Tools::getSecurePOSTStringValue('updateValue');
                     $duration_display = Tools::getSecurePOSTStringValue('updateDisplay');
                     $duration[$duration_value] = $duration_display;
                     Config::setValue(Config::id_durationList, Tools::doubleImplode(":", ",", $duration), Config::configType_keyValue, NULL, 0, 0, $displayed_teamid);
                 } elseif (isset($_POST["deletememberid"])) {
                     $memberid = Tools::getSecurePOSTIntValue('deletememberid');
                     $query = "DELETE FROM `codev_team_user_table` WHERE id = {$memberid};";
                     $result = SqlWrapper::getInstance()->sql_query($query);
                     if (!$result) {
                         $this->smartyHelper->assign('error', T_("Couldn't delete the member of the team"));
                     }
                 } elseif (isset($_POST['addedprojectid'])) {
                     $projectid = Tools::getSecurePOSTIntValue('addedprojectid');
                     if (0 != $projectid) {
                         $projecttype = Tools::getSecurePOSTIntValue('project_type');
                         try {
                             // prepare Project to CoDev (associate with CoDev customFields if needed)
                             // WARN: Project constructor cannot be used in here.
                             Project::prepareProjectToCodev($projectid);
                             // save to DB
                             if (!$team->addProject($projectid, $projecttype)) {
                                 $this->smartyHelper->assign('error', T_("Couldn't add the project to the team"));
                             }
                         } catch (Exception $e) {
                             $this->smartyHelper->assign('error', T_("Couldn't add the project to the team"));
                         }
                     }
                 } elseif (isset($_POST['deletedprojectid'])) {
                     $projectid = Tools::getSecurePOSTIntValue('deletedprojectid');
                     if (!$team->removeProject($projectid)) {
                         $this->smartyHelper->assign('error', T_("Could NOT remove the project from the team"));
                     }
                 } elseif (isset($_POST['addedastreinte_id'])) {
                     $onduty_id = Tools::getSecurePOSTIntValue('addedastreinte_id');
                     if (0 != $onduty_id) {
                         $team->addOnDutyTask($onduty_id);
                     }
                 } elseif (isset($_POST['deletedastreinte_id'])) {
                     $onduty_id = Tools::getSecurePOSTIntValue('deletedastreinte_id');
                     $team->removeOnDutyTask($onduty_id);
                 }
                 $this->smartyHelper->assign('team', $team);
                 $smartyUserList = array();
                 $userList = User::getUsers();
                 $selectedUserid = $team->getLeaderId();
                 foreach ($userList as $id => $name) {
                     $u = UserCache::getInstance()->getUser($id);
                     $uname = $u->getRealname();
                     if (empty($uname)) {
                         $uname = $name;
                     }
                     $smartyUserList[$id] = array('id' => $id, 'name' => $uname, 'selected' => $id == $selectedUserid);
                 }
                 $this->smartyHelper->assign('users', $smartyUserList);
                 $this->smartyHelper->assign('date', date("Y-m-d", $team->getDate()));
                 $this->smartyHelper->assign('accessLevel', Team::$accessLevelNames);
                 $this->smartyHelper->assign('arrivalDate', date("Y-m-d", time()));
                 $this->smartyHelper->assign('departureDate', date("Y-m-d", time()));
                 $this->smartyHelper->assign('teamMembers', $this->getTeamMembers($displayed_teamid));
                 $this->smartyHelper->assign('teamEnabled', $team->isEnabled());
                 $this->smartyHelper->assign('otherProjects', $team->getOtherProjects());
                 $this->smartyHelper->assign('typeNames', Project::$typeNames);
                 $this->smartyHelper->assign('teamProjects', $this->getTeamProjects($displayed_teamid));
                 $this->smartyHelper->assign('onDutyCandidates', $this->getOnDutyCandidates($team, $team->getTrueProjects()));
                 $this->smartyHelper->assign('onDutyTasks', $this->getOnDutyTasks($team));
                 $this->smartyHelper->assign('duration', TimeTrackingTools::getDurationList($displayed_teamid));
                 $projectList = $this->getTooltipProjectCandidates($team);
                 $this->smartyHelper->assign('tooltipProjectCandidates', $projectList);
                 $this->smartyHelper->assign('issueTooltips', $this->getIssueTooltips($projectList, $displayed_teamid));
                 $this->smartyHelper->assign('itemSelection_openDialogBtLabel', T_('Configure Tooltips'));
                 $consistencyChecks = $this->getConsistencyChecks($team);
                 $this->smartyHelper->assign('consistencyChecks', $consistencyChecks);
                 $teamGeneralPrefs = $this->getTeamGeneralPrefs($team);
                 $this->smartyHelper->assign('teamGeneralPrefs', $teamGeneralPrefs);
             }
         }
     }
 }
Example #13
0
 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 {
             // use the servicecontractid set in the form, if not defined (first page call) use session servicecontractid
             $servicecontractid = 0;
             if (isset($_POST['servicecontractid'])) {
                 $servicecontractid = Tools::getSecurePOSTIntValue('servicecontractid');
                 $_SESSION['servicecontractid'] = $servicecontractid;
             } else {
                 if (isset($_GET['servicecontractid'])) {
                     $servicecontractid = Tools::getSecureGETIntValue('servicecontractid');
                     $_SESSION['servicecontractid'] = $servicecontractid;
                 } else {
                     if (isset($_SESSION['servicecontractid'])) {
                         $servicecontractid = $_SESSION['servicecontractid'];
                     }
                 }
             }
             // set TeamList (including observed teams)
             $oTeamList = $this->session_user->getObservedTeamList();
             $mTeamList = $this->session_user->getManagedTeamList();
             $teamList = $oTeamList + $mTeamList;
             // array_merge does not work ?!
             if (empty($teamList) || !array_key_exists($this->teamid, $teamList)) {
                 // only managers (and observers) can access this page.
                 return;
             }
             $isManager = $this->session_user->isTeamManager($this->teamid);
             $isObserver = $this->session_user->isTeamObserver($this->teamid);
             if ($isManager || $isObserver) {
                 $this->smartyHelper->assign('isManager', true);
             }
             $this->smartyHelper->assign('servicecontracts', ServiceContractTools::getServiceContracts($this->teamid, $servicecontractid));
             if (0 != $servicecontractid) {
                 $servicecontract = ServiceContractCache::getInstance()->getServiceContract($servicecontractid);
                 if ($this->teamid == $servicecontract->getTeamid()) {
                     $this->smartyHelper->assign('servicecontractid', $servicecontractid);
                     // get selected filters
                     $selectedFilters = "";
                     if (isset($_GET['selectedFilters'])) {
                         $selectedFilters = Tools::getSecureGETStringValue('selectedFilters');
                     } else {
                         $selectedFilters = $this->session_user->getServiceContractFilters($servicecontractid);
                     }
                     ServiceContractTools::displayServiceContract($this->smartyHelper, $servicecontract, $isManager || $isObserver, $selectedFilters);
                     // ConsistencyCheck
                     $consistencyErrors = $this->getConsistencyErrors($servicecontract);
                     if (0 != $consistencyErrors) {
                         $this->smartyHelper->assign('ccheckButtonTitle', count($consistencyErrors) . ' ' . T_("Errors"));
                         $this->smartyHelper->assign('ccheckBoxTitle', count($consistencyErrors) . ' ' . T_("Errors"));
                         $this->smartyHelper->assign('ccheckErrList', $consistencyErrors);
                     }
                     // access rights
                     if ($isManager || $this->session_user->isTeamLeader($servicecontract->getTeamid())) {
                         $this->smartyHelper->assign('isEditGranted', true);
                     }
                     // old-style plugins (deprecated)
                     $this->smartyHelper->assign('detailedChargesIndicatorFile', DetailedChargesIndicator::getSmartyFilename());
                     // Dashboard
                     ServiceContractTools::dashboardSettings($this->smartyHelper, $servicecontract, $this->session_userid);
                 }
             } else {
                 unset($_SESSION['cmdid']);
                 unset($_SESSION['commandsetid']);
                 $action = filter_input(INPUT_POST, 'action');
                 if ('displayServiceContract' == $action) {
                     header('Location:servicecontract_edit.php?servicecontractid=0');
                 }
             }
         }
     }
 }
Example #14
0
            $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();
            }
        }
    }
} else {
    Tools::sendUnauthorizedAccess();
}
Example #15
0
             } catch (Exception $e) {
                 // happens if user moved children AND deleted the node.
                 // The node will not be deleted, but at least the rest of the WBS changes
                 // have a chance to be proceeded.
                 $logger->error("Node {$folder_id} not deleted : " . $e->getMessage());
                 $logger->warn("EXCEPTION stack-trace:\n" . $e->getTraceAsString());
             }
         }
     }
     WBSElement::updateFromDynatree($rootArray, $root_id);
     echo $jsonDynatreeDict;
 } else {
     if ($_POST['action'] == 'loadWBS') {
         try {
             $root_id = Tools::getSecurePOSTIntValue('wbsRootId');
             $hasDetail = 1 === Tools::getSecurePOSTIntValue('hasDetail') ? true : false;
             $userid = $_SESSION['userid'];
             $teamid = isset($_SESSION['teamid']) ? $_SESSION['teamid'] : 0;
             $session_user = UserCache::getInstance()->getUser($userid);
             // Managers & Observers have the same view (MEE,Reestimated, ...)
             $isManager = $session_user->isTeamManager($teamid);
             $isObserver = $session_user->isTeamObserver($teamid);
             $isManager = $isManager || $isObserver;
             $rootElement = new WBSElement($root_id);
             $dynatreeDict = $rootElement->getDynatreeData($hasDetail, $isManager, $teamid);
             if ($logger->isDebugEnabled()) {
                 $aa = var_export($dynatreeDict, true);
                 $logger->debug("loadWBS (root={$root_id}, hasDetail=" . $_POST['hasDetail'] . ") : \n{$aa}");
             }
             $jsonDynatreeDict = json_encode($dynatreeDict);
             echo $jsonDynatreeDict;
Example #16
0
 protected function display()
 {
     if (Tools::isConnectedUser()) {
         // Admins only
         $session_user = UserCache::getInstance()->getUser($_SESSION['userid']);
         if ($session_user->isTeamMember(Config::getInstance()->getValue(Config::id_adminTeamId))) {
             $this->smartyHelper->assign('jobType', Job::$typeNames);
             $action = Tools::getSecurePOSTStringValue('action', 'none');
             if ('addJob' == $action) {
                 $job_name = Tools::getSecurePOSTStringValue('job_name');
                 $job_type = Tools::getSecurePOSTStringValue('job_type');
                 $job_color = Tools::getSecurePOSTStringValue('job_color');
                 // TODO check if not already in table !
                 // save to DB
                 Jobs::create($job_name, $job_type, $job_color);
             } elseif ('addAssociationProject' == $action) {
                 // Add Job to selected projects
                 $job_id = Tools::getSecurePOSTIntValue('job_id');
                 $proj = explode(",", Tools::getSecurePOSTStringValue('formattedProjects'));
                 foreach ($proj as $project_id) {
                     // TODO check if not already in table !
                     // save to DB
                     $query = "INSERT INTO `codev_project_job_table`  (`project_id`, `job_id`) VALUES ('" . $project_id . "','" . $job_id . "');";
                     $result = SqlWrapper::getInstance()->sql_query($query);
                     if (!$result) {
                         $this->smartyHelper->assign('error', T_("Couldn't add the job association"));
                     }
                 }
             } elseif ('deleteJob' == $action) {
                 $job_id = Tools::getSecurePOSTIntValue('job_id');
                 if (Jobs::JOB_NA == $job_id || Jobs::JOB_SUPPORT == $job_id) {
                     $this->smartyHelper->assign('error', T_("This job must not be deleted."));
                 } else {
                     $query = "DELETE FROM `codev_project_job_table` WHERE job_id = " . $job_id . ';';
                     $result = SqlWrapper::getInstance()->sql_query($query);
                     if (!$result) {
                         $this->smartyHelper->assign('error', T_("Couldn't remove the job association"));
                     }
                     $query = "DELETE FROM `codev_job_table` WHERE id = {$job_id};";
                     $result = SqlWrapper::getInstance()->sql_query($query);
                     if (!$result) {
                         $this->smartyHelper->assign('error', T_("Couldn't delete the job"));
                     }
                 }
             } elseif ('deleteJobProjectAssociation' == $action) {
                 $asso_id = Tools::getSecurePOSTIntValue('asso_id');
                 $query = "DELETE FROM `codev_project_job_table` WHERE id = " . $asso_id . ';';
                 $result = SqlWrapper::getInstance()->sql_query($query);
                 if (!$result) {
                     $this->smartyHelper->assign('error', T_("Couldn't remove the job association"));
                 }
             }
             $jobs = $this->getJobs();
             $this->smartyHelper->assign('jobs', $jobs);
             //$this->smartyHelper->assign('assignedJobs', $this->getAssignedJobs($jobs));
             $this->smartyHelper->assign('assignedJobs', $jobs);
             $projects = Project::getProjects();
             $this->smartyHelper->assign('projects', $projects);
             $this->smartyHelper->assign('tuples', $this->getAssignedJobTuples($projects));
         }
     }
 }
Example #17
0
 /**
  * Action on 'Save' button
  *
  * @param CommandSet $cmdset
  */
 private function updateCommandSetInfo($cmdset)
 {
     // TODO check sc_teamid in grantedTeams
     $cset_teamid = Tools::getSecurePOSTIntValue('cset_teamid');
     if ($cset_teamid != $this->teamid) {
         // switch team (because you won't find the SC in current team's contract list)
         $_SESSION['teamid'] = $cset_teamid;
         $this->updateTeamSelector();
     }
     $cmdset->setTeamid($cset_teamid);
     $formattedValue = Tools::escape_string($_POST['commandsetName']);
     $cmdset->setName($formattedValue);
     $formattedValue = Tools::escape_string($_POST['commandsetReference']);
     $cmdset->setReference($formattedValue);
     $formattedValue = Tools::escape_string($_POST['commandsetDesc']);
     $cmdset->setDesc($formattedValue);
     $formattedValue = Tools::escape_string($_POST['commandsetDate']);
     if ('' != $formattedValue) {
         $cmdset->setDate(Tools::date2timestamp($formattedValue));
     }
     $cmdset->setCost(SmartyTools::checkNumericValue($_POST['commandsetCost'], true));
     $cmdset->setBudgetDays(SmartyTools::checkNumericValue($_POST['commandsetBudget'], true));
 }
Example #18
0
 /**
  * Action on 'Save' button
  *
  * @param ServiceContract $contract
  */
 private function updateServiceContractInfo($contract)
 {
     // TODO check sc_teamid in grantedTeams
     $sc_teamid = Tools::getSecurePOSTIntValue('sc_teamid');
     if ($sc_teamid != $this->teamid) {
         // switch team (because you won't find the SC in current team's contract list)
         $_SESSION['teamid'] = $sc_teamid;
         $this->updateTeamSelector();
     }
     $contract->setTeamid($sc_teamid);
     $formattedValue = Tools::getSecurePOSTStringValue('servicecontractName');
     $contract->setName($formattedValue);
     $formattedValue = Tools::getSecurePOSTStringValue('servicecontractReference', '');
     $contract->setReference($formattedValue);
     $formattedValue = Tools::getSecurePOSTStringValue('servicecontractVersion', '');
     $contract->setVersion($formattedValue);
     $formattedValue = Tools::getSecurePOSTStringValue('servicecontractReporter', '');
     $contract->setReporter($formattedValue);
     $formattedValue = Tools::getSecurePOSTStringValue('servicecontractDesc', '');
     $contract->setDesc($formattedValue);
     $formattedValue = Tools::getSecurePOSTStringValue('serviceContractStartDate', '');
     if ('' != $formattedValue) {
         $contract->setStartDate(Tools::date2timestamp($formattedValue));
     }
     $formattedValue = Tools::getSecurePOSTStringValue('serviceContractEndDate', '');
     if ('' != $formattedValue) {
         $contract->setEndDate(Tools::date2timestamp($formattedValue));
     }
     $contract->setState(SmartyTools::checkNumericValue($_POST['servicecontractState'], true));
 }
Example #19
0
 /**
  * @param Command $cmd
  */
 private function updateCmdInfo(Command $cmd)
 {
     // TODO check cmd_teamid in grantedTeams
     $cmd_teamid = Tools::getSecurePOSTIntValue('cmd_teamid');
     if ($cmd_teamid != $this->teamid) {
         // switch team (because you won't find the cmd in current team's contract list)
         $_SESSION['teamid'] = $cmd_teamid;
         $this->updateTeamSelector();
     }
     $cmd->setTeamid($cmd_teamid);
     $formattedValue = Tools::getSecurePOSTStringValue('cmdName');
     // TODO UGLY WORKAROUND: command name cannot contain commas (,) because it is used as field separator in FilterManager
     $formattedValue = str_replace(",", ' ', $formattedValue);
     $cmd->setName($formattedValue);
     $formattedValue = Tools::getSecurePOSTStringValue('cmdReference', '');
     $cmd->setReference($formattedValue);
     $formattedValue = Tools::getSecurePOSTStringValue('cmdVersion', '');
     $cmd->setVersion($formattedValue);
     $formattedValue = Tools::getSecurePOSTStringValue('cmdReporter', '');
     $cmd->setReporter($formattedValue);
     $formattedValue = Tools::getSecurePOSTStringValue('cmdDesc', '');
     $cmd->setDesc($formattedValue);
     $formattedValue = Tools::getSecurePOSTStringValue('cmdStartDate', '');
     if ('' != $formattedValue) {
         $cmd->setStartDate(Tools::date2timestamp($formattedValue));
     }
     $formattedValue = Tools::getSecurePOSTStringValue('cmdDeadline', '');
     if ('' != $formattedValue) {
         $cmd->setDeadline(Tools::date2timestamp($formattedValue));
     }
     $cmd->setState(SmartyTools::checkNumericValue($_POST['cmdState'], true));
     $cmd->setAverageDailyRate(SmartyTools::checkNumericValue($_POST['cmdAverageDailyRate'], true));
     $cmd->setTotalSoldDays(SmartyTools::checkNumericValue($_POST['cmdTotalSoldDays'], true));
 }
Example #20
0
File: odt.php Project: fg-ok/codev
    echo "<span style='padding-left: 3em'><a tatget='blank' href='../include/download.php?f=" . basename($myFile) . "'>" . basename($myFile) . "</a></span>";
}
#==== MAIN =====
$session_userid = isset($_POST['userid']) ? $_POST['userid'] : $_SESSION['userid'];
if ($logger->isDebugEnabled()) {
    $logger->debug("session_userid = {$session_userid}");
}
if (isset($session_userid)) {
    $session_user = UserCache::getInstance()->getUser($session_userid);
    // exclude disabled projects
    $projList = $session_user->getProjectList(NULL, true, false);
    if (0 == count($projList)) {
        echo "<div style='text-align: center'>";
        echo T_("Sorry, there are no projects defined for your team.");
        echo "</div>";
    } else {
        $defaultProject = isset($_SESSION['projectid']) ? $_SESSION['projectid'] : 0;
        $projectid = Tools::getSecurePOSTIntValue('projectid', $defaultProject);
        $_SESSION['projectid'] = $projectid;
        if ($logger->isDebugEnabled()) {
            $logger->debug("projectid = {$projectid}");
        }
        displayProjectSelectionForm("odt.php", $projList, $projectid);
        $action = Tools::getSecurePOSTStringValue('action', 'none');
        if ('genODT' == $action) {
            $project = ProjectCache::getInstance()->getProject($projectid);
            genProjectODT($project, "../odt_templates/atos_dinf_01.odt", $session_userid, 0);
            #genProjectODT($project, "../odt_templates/test_01.odt", $session_userid, 0);
        }
    }
}
Example #21
0
 /**
  * Display HTML page
  */
 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);
             #$this->smartyHelper->assign('isManager', $isManager);
             $tmpTeamList = array($this->teamid => $this->teamList[$this->teamid]);
             $projList = $this->session_user->getProjectList($tmpTeamList, true, false);
             reset($projList);
             $projectid = key($projList);
             $odtTemplate = NULL;
             $action = Tools::getSecurePOSTStringValue('action', '');
             if ('downloadODT' == $action) {
                 $projectid = Tools::getSecurePOSTIntValue('projectid', NULL);
                 $formattedCategories = Tools::getSecurePOSTStringValue('categoryList', NULL);
                 $formattedStatuses = Tools::getSecurePOSTStringValue('statusList', NULL);
                 $formattedReporters = Tools::getSecurePOSTStringValue('reporterList', NULL);
                 $formattedHandlers = Tools::getSecurePOSTStringValue('handlerList', NULL);
                 $odtBasename = Tools::getSecurePOSTStringValue('templateFile', NULL);
                 $odtTemplate = Constants::$codevRootDir . '/odt_templates/' . $odtBasename;
             }
             $this->smartyHelper->assign('odtTemplates', $this->getTemplates(NULL, basename($odtTemplate)));
             $this->smartyHelper->assign('projects', SmartyTools::getSmartyArray($projList, $projectid));
             $selectedCategories = empty($formattedCategories) ? array(0) : explode(',', $formattedCategories);
             $this->smartyHelper->assign('categories', $this->getProjectCategories($projectid, $selectedCategories));
             $selectedStatusList = empty($formattedStatuses) ? array(0) : explode(',', $formattedStatuses);
             $this->smartyHelper->assign('statuses', $this->getProjectStatusList($projectid, $selectedStatusList));
             $selectedReporters = empty($formattedReporters) ? array(0) : explode(',', $formattedReporters);
             $this->smartyHelper->assign('reporters', $this->getTeamMembers($selectedReporters));
             $selectedHandlers = empty($formattedHandlers) ? array(0) : explode(',', $formattedHandlers);
             $this->smartyHelper->assign('handlers', $this->getTeamMembers($selectedHandlers));
             if ('downloadODT' == $action) {
                 $iSel = $this->getIssueSelection($projectid, $formattedCategories, $formattedReporters, $formattedHandlers, $formattedStatuses);
                 #echo implode(',', array_keys($iSel->getIssueList())).'<br>';
                 $odfFilepath = $this->generateODT($iSel, $projectid, $odtTemplate);
                 $this->smartyHelper->assign('odtFilename', basename($odfFilepath));
             }
         }
     }
 }
Example #22
0
 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());
             }
         }
     }
 }
Example #23
0
 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 {
             // if cmdid set in URL, use it. else:
             // use the commandsetid set in the form, if not defined (first page call) use session commandsetid
             $cmdid = 0;
             if (isset($_POST['cmdid'])) {
                 $cmdid = Tools::getSecurePOSTIntValue('cmdid');
                 $_SESSION['cmdid'] = $cmdid;
             } else {
                 if (isset($_GET['cmdid'])) {
                     $cmdid = Tools::getSecureGETIntValue('cmdid');
                     $_SESSION['cmdid'] = $cmdid;
                 } else {
                     if (isset($_SESSION['cmdid'])) {
                         $cmdid = $_SESSION['cmdid'];
                     }
                 }
             }
             if (!array_key_exists($this->teamid, $this->teamList)) {
                 $this->teamid = 0;
                 $cmdid = 0;
             } 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);
                 }
             }
             $action = Tools::getSecurePOSTStringValue('action', '');
             // --- CmdStateFilters
             if ('setCmdStateFilters' == $action) {
                 $cmdStateFiltersStr = Tools::getSecurePOSTStringValue('checkedCmdStateFilters');
                 $this->session_user->setCmdStateFilters($cmdStateFiltersStr, $this->teamid);
             } else {
                 $cmdStateFiltersStr = $this->session_user->getCmdStateFilters($this->teamid);
             }
             if (!empty($cmdStateFiltersStr)) {
                 $cmdStateFilters = Tools::doubleExplode(':', ',', $cmdStateFiltersStr);
                 $this->smartyHelper->assign('isCmdStateFilter', true);
             } else {
                 $cmdStateFilters = array();
             }
             $cmdStateFilterInfo = array();
             foreach (Command::$stateNames as $stateId => $stateName) {
                 $cmdStateFilterInfo[$stateId] = array('stateId' => $stateId, 'stateName' => $stateName, 'isChecked' => array_key_exists($stateId, $cmdStateFilters) ? $cmdStateFilters[$stateId] : 1);
             }
             $this->smartyHelper->assign('cmdStateFilterInfo', $cmdStateFilterInfo);
             // --- commands combobox
             $commands = $this->getCommands($this->teamid, $cmdid, $cmdStateFilters);
             $this->smartyHelper->assign('commands', $commands);
             // check if current cmd should be hidden
             if (!array_key_exists($cmdid, $commands)) {
                 $cmdid = 0;
             }
             // ------ Display Command
             if (0 != $cmdid) {
                 $cmd = CommandCache::getInstance()->getCommand($cmdid);
                 if ($cmd->getTeamid() == $this->teamid) {
                     $this->smartyHelper->assign('commandid', $cmdid);
                     // get selected filters
                     if (isset($_GET['selectedFilters'])) {
                         $selectedFilters = Tools::getSecureGETStringValue('selectedFilters');
                     } else {
                         $selectedFilters = $this->session_user->getCommandFilters($cmdid);
                     }
                     // cleanup filters (remove empty lines)
                     $filterList = explode(',', $selectedFilters);
                     $filterList = array_filter($filterList, create_function('$a', 'return $a!="";'));
                     $selectedFilters = implode(',', $filterList);
                     CommandTools::displayCommand($this->smartyHelper, $cmd, $isManager || $isObserver, $selectedFilters);
                     // ConsistencyCheck
                     $consistencyErrors = $this->getConsistencyErrors($cmd);
                     if (count($consistencyErrors) > 0) {
                         $this->smartyHelper->assign('ccheckButtonTitle', count($consistencyErrors) . ' ' . T_("Errors"));
                         $this->smartyHelper->assign('ccheckBoxTitle', count($consistencyErrors) . ' ' . T_("Errors"));
                         $this->smartyHelper->assign('ccheckErrList', $consistencyErrors);
                     }
                     // check if sold days warning should be displayed
                     if (0 != $cmd->getTotalSoldDays()) {
                         $checkTotalSoldDays = $cmd->getTotalSoldDays() - $cmd->getIssueSelection()->mgrEffortEstim - $cmd->getProvisionDays();
                         $checkTotalSoldDays = round($checkTotalSoldDays, 2);
                         if (0 !== checkTotalSoldDays) {
                             $this->smartyHelper->assign('checkTotalSoldDays', $checkTotalSoldDays);
                         }
                     }
                     // access rights
                     if ($isManager || $this->session_user->isTeamLeader($cmd->getTeamid())) {
                         $this->smartyHelper->assign('isEditGranted', true);
                     }
                     // WBS
                     $this->smartyHelper->assign('wbsRootId', $cmd->getWbsid());
                     // indicator_plugins (old style plugins - deprecated)
                     $this->smartyHelper->assign('detailedChargesIndicatorFile', DetailedChargesIndicator::getSmartyFilename());
                     // Dashboard
                     CommandTools::dashboardSettings($this->smartyHelper, $cmd, $this->session_userid);
                 }
             } else {
                 unset($_SESSION['commandsetid']);
                 unset($_SESSION['servicecontractid']);
                 if ('displayCommand' == $action) {
                     header('Location:command_edit.php?cmdid=0');
                 }
             }
         }
     }
 }
Example #24
0
 protected function display()
 {
     if (Tools::isConnectedUser()) {
         // only teamMembers can access this page
         if (0 == $this->teamid || $this->session_user->isTeamCustomer($this->teamid) || $this->session_user->isTeamObserver($this->teamid) || !$this->session_user->isTeamMember($this->teamid)) {
             $this->smartyHelper->assign('accessDenied', TRUE);
         } else {
             $team = TeamCache::getInstance()->getTeam($this->teamid);
             $teamMembers = $team->getActiveMembers(NULL, NULL, TRUE);
             $managed_userid = Tools::getSecurePOSTIntValue('userid', $this->session_userid);
             if ($this->session_user->isTeamManager($this->teamid)) {
                 // session_user is Manager, let him choose the teamMember he wants to manage
                 $this->smartyHelper->assign('users', $teamMembers);
                 $this->smartyHelper->assign('selectedUser', $managed_userid);
                 $this->smartyHelper->assign("isManager", true);
             }
             // display AddTrack Page
             $year = Tools::getSecurePOSTIntValue('year', date('Y'));
             $managed_user = UserCache::getInstance()->getUser($managed_userid);
             // Need to be Manager to handle other users
             if ($managed_userid != $this->session_userid) {
                 if (!$this->session_user->isTeamManager($this->teamid) || !array_key_exists($managed_userid, $teamMembers)) {
                     self::$logger->error(' SECURITY ALERT changeManagedUser: session_user ' . $this->session_userid . " is not allowed to manage user {$managed_userid}");
                     Tools::sendForbiddenAccess();
                 }
             }
             // developper & manager can add timeTracks
             $mTeamList = $managed_user->getDevTeamList();
             $managedTeamList = $managed_user->getManagedTeamList();
             $teamList = $mTeamList + $managedTeamList;
             $action = Tools::getSecurePOSTStringValue('action', '');
             $weekid = Tools::getSecurePOSTIntValue('weekid', date('W'));
             $defaultDate = Tools::getSecurePOSTStringValue('date', date("Y-m-d", time()));
             $defaultBugid = Tools::getSecurePOSTIntValue('bugid', 0);
             $defaultProjectid = Tools::getSecurePOSTIntValue('projectid', 0);
             $job = Tools::getSecurePOSTIntValue('job', 0);
             $duration = Tools::getSecurePOSTNumberValue('duree', 0);
             if ("addTrack" == $action) {
                 self::$logger->debug("addTrack: called from form1");
                 // TODO merge addTrack & addTimetrack actions !
                 // called by form1 when no backlog has to be set.
                 // updateBacklogDialogBox must not raise up,
                 // track must be added, backlog & status must NOT be updated
                 $timestamp = Tools::date2timestamp($defaultDate);
                 $defaultBugid = Tools::getSecurePOSTIntValue('bugid');
                 $job = Tools::getSecurePOSTStringValue('job');
                 $duration = Tools::getSecurePOSTNumberValue('duree');
                 // dialogBox is not called, then track must be saved to DB
                 $trackid = TimeTrack::create($managed_userid, $defaultBugid, $job, $timestamp, $duration, $this->session_userid);
                 if (self::$logger->isDebugEnabled()) {
                     self::$logger->debug("Track {$trackid} added  : userid={$managed_userid} bugid={$defaultBugid} job={$job} duration={$duration} timestamp={$timestamp}");
                 }
                 // Don't show job and duration after add track
                 $job = 0;
                 $duration = 0;
                 $defaultProjectid = Tools::getSecurePOSTIntValue('projectid');
             } elseif ("addTimetrack" == $action) {
                 // updateBacklogDialogbox with 'addTimetrack' action
                 // add track AND update backlog & status & handlerId
                 // TODO merge addTrack & addTimetrack actions !
                 self::$logger->debug("addTimetrack: called from the updateBacklogDialogBox");
                 // add timetrack (all values mandatory)
                 $defaultDate = Tools::getSecurePOSTStringValue('trackDate');
                 $defaultBugid = Tools::getSecurePOSTIntValue('bugid');
                 $job = Tools::getSecurePOSTIntValue('trackJobid');
                 $duration = Tools::getSecurePOSTNumberValue('timeToAdd');
                 $handlerId = Tools::getSecurePOSTNumberValue('handlerid');
                 // check jobid (bug happens sometime...
                 if (0 == $job) {
                     $this->smartyHelper->assign('error', T_("Timetrack not added: Job has not specified."));
                     self::$logger->error("Add track : FAILED. issue={$defaultBugid}, jobid={$job}, duration={$duration} date={$defaultDate}");
                 }
                 // check bug_id (this happens when user uses the 'back' button of the browser ?)
                 if (0 == $defaultBugid) {
                     self::$logger->error("Add track : FAILED. issue=0, jobid={$job}, duration={$duration} date={$defaultDate}");
                 } else {
                     $timestamp = 0 !== $defaultDate ? Tools::date2timestamp($defaultDate) : 0;
                     $trackid = TimeTrack::create($managed_userid, $defaultBugid, $job, $timestamp, $duration, $this->session_userid);
                     if (self::$logger->isDebugEnabled()) {
                         self::$logger->debug("Track {$trackid} added  : userid={$managed_userid} bugid={$defaultBugid} job={$job} duration={$duration} timestamp={$timestamp}");
                     }
                     $issue = IssueCache::getInstance()->getIssue($defaultBugid);
                     // setBacklog
                     $formattedBacklog = Tools::getSecurePOSTNumberValue('backlog');
                     $issue->setBacklog($formattedBacklog);
                     // setStatus
                     $newStatus = Tools::getSecurePOSTIntValue('statusid');
                     $issue->setStatus($newStatus);
                     // set handlerId
                     if ($handlerId != $issue->getHandlerId()) {
                         // TODO security check (userid exists/valid ?)
                         $issue->setHandler($handlerId);
                     }
                     $defaultProjectid = $issue->getProjectId();
                 }
                 // Don't show job and duration after add track
                 $job = 0;
                 $duration = 0;
             } elseif ("deleteTrack" == $action) {
                 $trackid = Tools::getSecurePOSTIntValue('trackid');
                 $timeTrack = TimeTrackCache::getInstance()->getTimeTrack($trackid);
                 $defaultBugid = $timeTrack->getIssueId();
                 $duration = $timeTrack->getDuration();
                 $job = $timeTrack->getJobId();
                 $defaultDate = date("Y-m-d", $timeTrack->getDate());
                 // delete track
                 if (!$timeTrack->remove()) {
                     $this->smartyHelper->assign('error', T_("Failed to delete the timetrack !"));
                     self::$logger->error("Delete track {$trackid}  : FAILED.");
                 }
                 if (0 == $defaultBugid) {
                     self::$logger->error("Delete track : bug_id=0");
                     $defaultProjectid = 0;
                 } else {
                     try {
                         // pre-set form fields
                         $issue = IssueCache::getInstance()->getIssue($defaultBugid);
                         $defaultProjectid = $issue->getProjectId();
                         // if project not defined for current team, do not pre-set form fields.
                         if (!in_array($defaultProjectid, array_keys($team->getProjects()))) {
                             $defaultProjectid = 0;
                             $defaultBugid = 0;
                         }
                     } catch (Exception $e) {
                         $defaultProjectid = 0;
                         $defaultBugid = 0;
                     }
                 }
             } elseif ("setBugId" == $action) {
                 // pre-set form fields
                 // find ProjectId to update categories
                 $defaultBugid = Tools::getSecurePOSTIntValue('bugid');
                 $issue = IssueCache::getInstance()->getIssue($defaultBugid);
                 $defaultProjectid = $issue->getProjectId();
             } elseif ("setFiltersAction" == $action) {
                 $isFilter_onlyAssignedTo = isset($_POST["cb_onlyAssignedTo"]) ? '1' : '0';
                 $isFilter_hideResolved = isset($_POST["cb_hideResolved"]) ? '1' : '0';
                 $managed_user->setTimetrackingFilter('onlyAssignedTo', $isFilter_onlyAssignedTo);
                 $managed_user->setTimetrackingFilter('hideResolved', $isFilter_hideResolved);
                 if ($defaultBugid != 0) {
                     $issue = IssueCache::getInstance()->getIssue($defaultBugid);
                     $defaultProjectid = $issue->getProjectId();
                 }
             }
             // Display user name
             $this->smartyHelper->assign('managedUser_realname', $managed_user->getRealname());
             $this->smartyHelper->assign('userid', $managed_userid);
             // display Track Form
             $this->smartyHelper->assign('date', $defaultDate);
             // All projects except disabled
             $projList = $team->getProjects(true, false);
             $this->smartyHelper->assign('projects', SmartyTools::getSmartyArray($projList, $defaultProjectid));
             $this->smartyHelper->assign('defaultProjectid', $defaultProjectid);
             $this->smartyHelper->assign('defaultBugid', $defaultBugid);
             $this->smartyHelper->assign('weekid', $weekid);
             $this->smartyHelper->assign('year', $year);
             $isOnlyAssignedTo = '0' == $managed_user->getTimetrackingFilter('onlyAssignedTo') ? false : true;
             $this->smartyHelper->assign('isOnlyAssignedTo', $isOnlyAssignedTo);
             $isHideResolved = '0' == $managed_user->getTimetrackingFilter('hideResolved') ? false : true;
             $this->smartyHelper->assign('isHideResolved', $isHideResolved);
             $availableIssues = TimeTrackingTools::getIssues($this->teamid, $defaultProjectid, $isOnlyAssignedTo, $managed_user->getId(), $projList, $isHideResolved, $defaultBugid);
             $this->smartyHelper->assign('issues', $availableIssues);
             $this->smartyHelper->assign('jobs', SmartyTools::getSmartyArray(TimeTrackingTools::getJobs($defaultProjectid, $this->teamid), $job));
             $this->smartyHelper->assign('duration', SmartyTools::getSmartyArray(TimeTrackingTools::getDurationList($this->teamid), $duration));
             $this->smartyHelper->assign('weeks', SmartyTools::getWeeks($weekid, $year));
             $this->smartyHelper->assign('years', SmartyTools::getYears($year, 1));
             $weekDates = Tools::week_dates($weekid, $year);
             $startTimestamp = $weekDates[1];
             $endTimestamp = mktime(23, 59, 59, date("m", $weekDates[7]), date("d", $weekDates[7]), date("Y", $weekDates[7]));
             $timeTracking = new TimeTracking($startTimestamp, $endTimestamp, $this->teamid);
             $incompleteDays = array_keys($timeTracking->checkCompleteDays($managed_userid, TRUE));
             $missingDays = $timeTracking->checkMissingDays($managed_userid);
             $errorDays = array_merge($incompleteDays, $missingDays);
             $smartyWeekDates = TimeTrackingTools::getSmartyWeekDates($weekDates, $errorDays);
             // UTF8 problems in smarty, date encoding needs to be done in PHP
             $this->smartyHelper->assign('weekDates', array($smartyWeekDates[1], $smartyWeekDates[2], $smartyWeekDates[3], $smartyWeekDates[4], $smartyWeekDates[5]));
             $this->smartyHelper->assign('weekEndDates', array($smartyWeekDates[6], $smartyWeekDates[7]));
             $weekTasks = TimeTrackingTools::getWeekTask($weekDates, $this->teamid, $managed_userid, $timeTracking, $errorDays);
             $this->smartyHelper->assign('weekTasks', $weekTasks["weekTasks"]);
             $this->smartyHelper->assign('dayTotalElapsed', $weekTasks["totalElapsed"]);
             $timeTrackingTuples = $this->getTimetrackingTuples($managed_userid, $timeTracking);
             $this->smartyHelper->assign('weekTimetrackingTuples', $timeTrackingTuples['current']);
             $this->smartyHelper->assign('timetrackingTuples', $timeTrackingTuples['future']);
             // ConsistencyCheck
             $consistencyErrors = $this->getConsistencyErrors($managed_userid, $this->teamid);
             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"));
             }
             $this->smartyHelper->assign('isForbidAddTimetracksOnClosed', 1 == $team->getGeneralPreference('forbidAddTimetracksOnClosed') ? true : false);
         }
     }
 }