本文整理汇总了PHP中Tools::date2timestamp方法的典型用法代码示例。如果您正苦于以下问题:PHP Tools::date2timestamp方法的具体用法?PHP Tools::date2timestamp怎么用?PHP Tools::date2timestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tools
的用法示例。
在下文中一共展示了Tools::date2timestamp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
protected function display()
{
if (Tools::isConnectedUser()) {
$threshold = 0.5;
// for Deviation filters
// only teamMembers & observers can access this page
if (0 == $this->teamid || $this->session_user->isTeamCustomer($this->teamid)) {
$this->smartyHelper->assign('accessDenied', TRUE);
} else {
$withSupport = TRUE;
$weekDates = Tools::week_dates(date('W'), date('Y'));
// The first day of the current week
$startDate = date("Y-m-d", $weekDates[1]);
$startTimestamp = Tools::date2timestamp($startDate);
#echo "DEBUG startTimestamp ".date("Y-m-d H:i:s", $startTimestamp)."<br/>";
// The last day of the current week
$endDate = date("Y-m-d", $weekDates[5]);
$endTimestamp = Tools::date2timestamp($endDate);
$endTimestamp += 24 * 60 * 60 - 1;
// + 1 day -1 sec.
#echo "DEBUG endTimestamp ".date("Y-m-d H:i:s", $endTimestamp)."<br/>";
#$managedTeamList = $this->session_user->getManagedTeamList();
#$isManager = array_key_exists($this->teamid, $managedTeamList);
$isManager = $this->session_user->isTeamManager($this->teamid);
$isObserver = $this->session_user->isTeamObserver($this->teamid);
$this->smartyHelper->assign('manager', $isManager || $isObserver);
$this->smartyHelper->assign('threshold', $threshold);
$this->smartyHelper->assign('currentDeviationStats', $this->getCurrentDeviationStats($this->teamid, $threshold));
$this->smartyHelper->assign('issuesInDrift', $this->getIssuesInDrift($this->teamid, $withSupport));
}
}
}
示例2: display
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());
}
}
}
示例3: display
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.'));
}
}
示例4: display
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');
}
}
}
}
示例5: display
protected function display()
{
if (Tools::isConnectedUser()) {
// Admins only
$userid = $_SESSION['userid'];
//$session_user = UserCache::getInstance()->getUser($userid);
$teamid = 9;
// ASF_OVA_Internet
$cmdid = 16;
// ASF Commande Internet
$cmd = CommandCache::getInstance()->getCommand($cmdid);
$startTimestamp = Tools::date2timestamp('2013-11-22');
$endTimestamp = Tools::date2timestamp('2014-06-22');
// ------ START TESTS
//if (FALSE == Tools::createClassMap()) { echo "ERROR createClassMap";}
//$pm = PluginManager::getInstance();
//$pm->discoverNewPlugins();
// ------ END TESTS
// feed the PluginDataProvider
$pluginDataProvider = PluginDataProvider::getInstance();
$pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_ISSUE_SELECTION, $cmd->getIssueSelection());
$pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_TEAM_ID, $teamid);
$pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_START_TIMESTAMP, $startTimestamp);
$pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_END_TIMESTAMP, $endTimestamp);
$pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_PROVISION_DAYS, $cmd->getProvisionDays());
$pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_SESSION_USER_ID, $userid);
// save the DataProvider for Ajax calls
$_SESSION[PluginDataProviderInterface::SESSION_ID] = serialize($pluginDataProvider);
// create the Dashboard
$dashboard = new Dashboard('myDashboardId');
$dashboard->setDomain(IndicatorPluginInterface::DOMAIN_COMMAND);
$dashboard->setCategories(array(IndicatorPluginInterface::CATEGORY_QUALITY, IndicatorPluginInterface::CATEGORY_ACTIVITY, IndicatorPluginInterface::CATEGORY_ROADMAP, IndicatorPluginInterface::CATEGORY_PLANNING, IndicatorPluginInterface::CATEGORY_RISK, IndicatorPluginInterface::CATEGORY_TEAM));
$dashboard->setTeamid($teamid);
$dashboard->setUserid($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 in the admin-team to access this page.'));
}
}
示例6: display
protected function display()
{
if (Tools::isConnectedUser()) {
// only teamMembers & observers can access this page
if (0 == $this->teamid || $this->session_user->isTeamCustomer($this->teamid)) {
$this->smartyHelper->assign('accessDenied', TRUE);
} else {
$isManager = $this->session_user->isTeamManager($this->teamid);
$isObserver = $this->session_user->isTeamObserver($this->teamid);
if ($isManager || $isObserver) {
// observers have access to the same info
$this->smartyHelper->assign('isManager', true);
}
// dates
$month = date('m');
$year = date('Y');
$startdate = Tools::getSecurePOSTStringValue("startdate", Tools::formatDate("%Y-%m-%d", mktime(0, 0, 0, $month, 1, $year)));
$this->smartyHelper->assign('startDate', $startdate);
$startTimestamp = Tools::date2timestamp($startdate);
$nbDaysInMonth = date("t", $startTimestamp);
$enddate = Tools::getSecurePOSTStringValue("enddate", Tools::formatDate("%Y-%m-%d", mktime(0, 0, 0, $month, $nbDaysInMonth, $year)));
$this->smartyHelper->assign('endDate', $enddate);
$endTimestamp = Tools::date2timestamp($enddate);
#$isDetailed = Tools::getSecurePOSTStringValue('cb_detailed','');
#$this->smartyHelper->assign('isDetailed', $isDetailed);
if ('computeMonthlyActivityReport' == $_POST['action']) {
$timeTracking = new TimeTracking($startTimestamp, $endTimestamp, $this->teamid);
$tracks = $timeTracking->getTimeTracks();
$this->smartyHelper->assign('monthlyActivityReport', $this->getMonthlyActivityReport($tracks));
// ConsistencyCheck
$consistencyErrors = $this->getConsistencyErrors($timeTracking);
if (count($consistencyErrors) > 0) {
$this->smartyHelper->assign('ccheckErrList', $consistencyErrors);
$this->smartyHelper->assign('ccheckButtonTitle', count($consistencyErrors) . ' ' . T_("Errors"));
$this->smartyHelper->assign('ccheckBoxTitle', count($consistencyErrors) . ' ' . T_("days are incomplete or undefined"));
}
}
}
}
}
示例7: display
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);
}
}
}
}
}
示例8: display
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);
}
}
}
}
示例9: generateDevelopersWorkloadGraph
/**
* Display 'Developers Workload'
* nb of days.: (holidays & externalTasks not included, developers only)
* @param TimeTracking[] $timeTrackingTable
* @return string
*/
private function generateDevelopersWorkloadGraph($timeTrackingTable)
{
$formattedTimetracks = array();
foreach ($timeTrackingTable as $startTimestamp => $timeTracking) {
// REM: the 'normal' drifts DO include support
$formattedTimetracks[$startTimestamp] = $timeTracking->getAvailableWorkload();
}
$values = array();
$legend = array();
foreach ($formattedTimetracks as $date => $value) {
$values[Tools::formatDate("%Y-%m-01", $date)] = $value;
$legend[Tools::formatDate("%B %Y", $date)] = round($value, 1);
}
$this->smartyHelper->assign('workload_jqplotData', Tools::array2plot($values));
$timestamp = Tools::getStartEndKeys($values);
$start = Tools::formatDate("%Y-%m-01", Tools::date2timestamp($timestamp[0]));
$end = Tools::formatDate("%Y-%m-01", strtotime($timestamp[1] . " +1 month"));
$this->smartyHelper->assign('workload_plotMinDate', $start);
$this->smartyHelper->assign('workload_plotMaxDate', $end);
$this->smartyHelper->assign('workload_Legend', $legend);
}
示例10: getSmartyObject
public function getSmartyObject()
{
$timestamp = Tools::getStartEndKeys($this->execData['MEE']);
$start = Tools::formatDate("%Y-%m-01", Tools::date2timestamp($timestamp[0]));
$end = Tools::formatDate("%Y-%m-01", strtotime($timestamp[1] . " +1 month"));
$jsonMEE = Tools::array2plot($this->execData['MEE']);
$jsonEE = Tools::array2plot($this->execData['EE']);
$graphData = "[{$jsonMEE},{$jsonEE}]";
#$graphDataColors = '["#fcbdbd", "#c2dfff"]';
$labels = '["MgrEffortEstim ReliabilityRate", "EffortEstim ReliabilityRate"]';
$tableData = array();
foreach ($this->execData['MEE'] as $date => $prodRateMEE) {
$prodRateEE = $this->execData['EE'][$date];
$timestamp = Tools::date2timestamp($date);
$formattedDate = Tools::formatDate("%B %Y", $timestamp);
$tableData[$formattedDate] = array('prodRateMEE' => round($prodRateMEE, 2), 'prodRateEE' => round($prodRateEE, 2));
}
return array('prodRate_history_data' => $graphData, 'prodRate_history_dataLabels' => $labels, 'prodRate_history_plotMinDate' => $start, 'prodRate_history_plotMaxDate' => $end, 'prodRate_tableData' => $tableData);
}
示例11: execute
public function execute()
{
$backlogList = $this->issue->getBacklogHistory();
$formattedBlList = array();
foreach ($backlogList as $t => $b) {
$formattedBlList[Tools::formatDate("%Y-%m-%d", $t)] = $b;
}
// Graph start/stop dates
reset($formattedBlList);
$plotMinDate = key($formattedBlList);
end($formattedBlList);
$plotMaxDate = key($formattedBlList);
// Calculate a nice week interval
$minTimestamp = Tools::date2timestamp($plotMinDate);
$maxTimestamp = Tools::date2timestamp($plotMaxDate);
$nbWeeks = ($maxTimestamp - $minTimestamp) / 60 / 60 / 24 / 7;
$interval = ceil($nbWeeks / 10);
$jqplotData = Tools::array2plot($formattedBlList);
$this->execData = array('issueBacklogVariationIndicator_interval' => $interval, 'issueBacklogVariationIndicator_plotMinDate' => $plotMinDate, 'issueBacklogVariationIndicator_plotMaxDate' => $plotMaxDate, 'issueBacklogVariationIndicator_jqplotYaxisLabel' => T_('Backlog (days)'), 'issueBacklogVariationIndicator_jqplotData' => $jqplotData, 'issueBacklogVariationIndicator_tableData' => $formattedBlList);
return $this->execData;
}
示例12:
if ($mgrEffortEstim) {
$issue->setMgrEffortEstim($mgrEffortEstim);
}
if ($effortEstim) {
$issue->setEffortEstim($effortEstim);
}
if ($targetversionid) {
$issue->setTargetVersion($targetversionid);
}
if ($userid) {
$issue->setHandler($userid);
}
if ($type) {
$issue->setType($type);
}
if ($formatedDeadline) {
$timestamp = Tools::date2timestamp($formatedDeadline);
$issue->setDeadline($timestamp);
}
if ($commandid) {
$command = CommandCache::getInstance()->getCommand($commandid);
$command->addIssue($bugid, true);
// DBonly
}
if ($logger->isDebugEnabled()) {
$logger->debug("Import bugid={$bugid} {$extRef} - {$summary} - {$mgrEffortEstim} - {$effortEstim} - {$commandid} - {$categoryid} - {$targetversionid} - {$userid}");
}
// RETURN VALUE
echo Tools::mantisIssueURL($bugid, NULL, TRUE) . " " . Tools::issueInfoURL($bugid, NULL);
}
}
示例13: display
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));
//.........这里部分代码省略.........
示例14: display
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') {
//.........这里部分代码省略.........
示例15: set
$action = Tools::getSecureGETStringValue('action');
$dashboardId = Tools::getSecureGETStringValue('dashboardId');
if (!isset($_SESSION[PluginDataProviderInterface::SESSION_ID . $dashboardId])) {
$logger->error("PluginDataProvider not set (dashboardId = {$dashboardId}");
Tools::sendBadRequest("PluginDataProvider not set");
}
$pluginDataProvider = unserialize($_SESSION[PluginDataProviderInterface::SESSION_ID . $dashboardId]);
if (FALSE == $pluginDataProvider) {
$logger->error("PluginDataProvider unserialize error (dashboardId = {$dashboardId}");
Tools::sendBadRequest("PluginDataProvider unserialize error");
}
$smartyHelper = new SmartyHelper();
if ('getLoadPerUserIndicator' == $action) {
// TODO do not log exception if date = 01-01-1970
$startTimestamp = Tools::date2timestamp(Tools::getSecureGETStringValue("loadPerUser_startdate"));
$endTimestamp = Tools::date2timestamp(Tools::getSecureGETStringValue("loadPerUser_enddate"));
$attributesJsonStr = Tools::getSecureGETStringValue('attributesJsonStr');
$attributesArray = json_decode(stripslashes($attributesJsonStr), true);
$showSidetasks = 'on' != $attributesArray[LoadPerUserIndicator::OPTION_SHOW_SIDETASKS] ? false : true;
//$logger->error("showSidetasks = ".var_export($showSidetasks, true).' attr '.$attributesArray[LoadPerUserIndicator::OPTION_SHOW_SIDETASKS]);
// update dataProvider
$pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_START_TIMESTAMP, $startTimestamp);
$pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_END_TIMESTAMP, $endTimestamp);
$indicator = new LoadPerUserIndicator($pluginDataProvider);
// override plugin settings with current attributes
$indicator->setPluginSettings(array(LoadPerUserIndicator::OPTION_SHOW_SIDETASKS => $showSidetasks));
$indicator->execute();
$data = $indicator->getSmartyVariablesForAjax();
// construct the html table
foreach ($data as $smartyKey => $smartyVariable) {
$smartyHelper->assign($smartyKey, $smartyVariable);