allow to configure timezone for the lockdown period (#2593)
This commit is contained in:
@@ -22,6 +22,7 @@ use App\Form\Type\LanguageType;
|
||||
use App\Form\Type\MinuteIncrementType;
|
||||
use App\Form\Type\RoundingModeType;
|
||||
use App\Form\Type\SkinType;
|
||||
use App\Form\Type\TimezoneType;
|
||||
use App\Form\Type\TrackingModeType;
|
||||
use App\Form\Type\WeekDaysType;
|
||||
use App\Form\Type\YesNoType;
|
||||
@@ -37,7 +38,6 @@ use Symfony\Component\Form\Extension\Core\Type\CountryType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CurrencyType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TimezoneType;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
@@ -232,18 +232,32 @@ final class SystemConfigurationController extends AbstractController
|
||||
$dateFormat = 'D, d M Y H:i:s';
|
||||
|
||||
if ($this->configurations->isTimesheetLockdownActive()) {
|
||||
$userTimezone = $this->getDateTimeFactory()->getTimezone();
|
||||
$timezone = $this->configurations->getTimesheetLockdownTimeZone();
|
||||
|
||||
if ($timezone !== null) {
|
||||
$timezone = new \DateTimeZone($timezone);
|
||||
}
|
||||
|
||||
if ($timezone === null) {
|
||||
$timezone = $userTimezone;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!empty($this->configurations->getTimesheetLockdownPeriodStart())) {
|
||||
$lockdownStartHelp = $this->getDateTimeFactory()->createDateTime($this->configurations->getTimesheetLockdownPeriodStart());
|
||||
$lockdownStartHelp = new \DateTime($this->configurations->getTimesheetLockdownPeriodStart(), $timezone);
|
||||
$lockdownStartHelp->setTimezone($userTimezone);
|
||||
$lockdownStartHelp = $lockdownStartHelp->format($dateFormat);
|
||||
}
|
||||
if (!empty($this->configurations->getTimesheetLockdownPeriodEnd())) {
|
||||
$lockdownEndHelp = $this->getDateTimeFactory()->createDateTime($this->configurations->getTimesheetLockdownPeriodEnd());
|
||||
$lockdownEndHelp = new \DateTime($this->configurations->getTimesheetLockdownPeriodEnd(), $timezone);
|
||||
if (!empty($this->configurations->getTimesheetLockdownGracePeriod())) {
|
||||
$lockdownGraceHelp = clone $lockdownEndHelp;
|
||||
$lockdownGraceHelp->modify($this->configurations->getTimesheetLockdownGracePeriod());
|
||||
$lockdownGraceHelp->setTimezone($userTimezone);
|
||||
$lockdownGraceHelp = $lockdownGraceHelp->format($dateFormat);
|
||||
}
|
||||
$lockdownEndHelp->setTimezone($userTimezone);
|
||||
$lockdownEndHelp = $lockdownEndHelp->format($dateFormat);
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
@@ -276,27 +290,6 @@ final class SystemConfigurationController extends AbstractController
|
||||
->setName('timesheet.rules.allow_overbooking_budget')
|
||||
->setType(CheckboxType::class)
|
||||
->setTranslationDomain('system-configuration'),
|
||||
(new Configuration())
|
||||
->setName('timesheet.rules.lockdown_period_start')
|
||||
->setOptions(['help' => $lockdownStartHelp])
|
||||
->setType(TextType::class)
|
||||
->setRequired(false)
|
||||
->setConstraints([new DateTimeFormat()])
|
||||
->setTranslationDomain('system-configuration'),
|
||||
(new Configuration())
|
||||
->setName('timesheet.rules.lockdown_period_end')
|
||||
->setOptions(['help' => $lockdownEndHelp])
|
||||
->setType(TextType::class)
|
||||
->setRequired(false)
|
||||
->setConstraints([new DateTimeFormat()])
|
||||
->setTranslationDomain('system-configuration'),
|
||||
(new Configuration())
|
||||
->setName('timesheet.rules.lockdown_grace_period')
|
||||
->setOptions(['help' => $lockdownGraceHelp])
|
||||
->setType(TextType::class)
|
||||
->setRequired(false)
|
||||
->setConstraints([new DateTimeFormat()])
|
||||
->setTranslationDomain('system-configuration'),
|
||||
(new Configuration())
|
||||
->setName('timesheet.active_entries.hard_limit')
|
||||
->setType(IntegerType::class)
|
||||
@@ -327,6 +320,36 @@ final class SystemConfigurationController extends AbstractController
|
||||
new GreaterThanOrEqual(['value' => 0])
|
||||
]),
|
||||
]),
|
||||
(new SystemConfigurationModel())
|
||||
->setSection(SystemConfigurationModel::SECTION_LOCKDOWN)
|
||||
->setConfiguration([
|
||||
(new Configuration())
|
||||
->setName('timesheet.rules.lockdown_period_start')
|
||||
->setOptions(['help' => $lockdownStartHelp])
|
||||
->setType(TextType::class)
|
||||
->setRequired(false)
|
||||
->setConstraints([new DateTimeFormat()])
|
||||
->setTranslationDomain('system-configuration'),
|
||||
(new Configuration())
|
||||
->setName('timesheet.rules.lockdown_period_end')
|
||||
->setOptions(['help' => $lockdownEndHelp])
|
||||
->setType(TextType::class)
|
||||
->setRequired(false)
|
||||
->setConstraints([new DateTimeFormat()])
|
||||
->setTranslationDomain('system-configuration'),
|
||||
(new Configuration())
|
||||
->setName('timesheet.rules.lockdown_period_timezone')
|
||||
->setType(TimezoneType::class)
|
||||
->setRequired(false)
|
||||
->setTranslationDomain('system-configuration'),
|
||||
(new Configuration())
|
||||
->setName('timesheet.rules.lockdown_grace_period')
|
||||
->setOptions(['help' => $lockdownGraceHelp])
|
||||
->setType(TextType::class)
|
||||
->setRequired(false)
|
||||
->setConstraints([new DateTimeFormat()])
|
||||
->setTranslationDomain('system-configuration'),
|
||||
]),
|
||||
(new SystemConfigurationModel())
|
||||
->setSection(SystemConfigurationModel::SECTION_ROUNDING)
|
||||
->setConfiguration([
|
||||
|
||||
Reference in New Issue
Block a user