show calculated lockdown date in config screen (#2274)
This commit is contained in:
@@ -223,6 +223,31 @@ final class SystemConfigurationController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
protected function getConfigurationTypes()
|
protected function getConfigurationTypes()
|
||||||
{
|
{
|
||||||
|
$lockdownStartHelp = null;
|
||||||
|
$lockdownEndHelp = null;
|
||||||
|
$lockdownGraceHelp = null;
|
||||||
|
$dateFormat = 'D, d M Y H:i:s';
|
||||||
|
|
||||||
|
if ($this->configurations->isTimesheetLockdownActive()) {
|
||||||
|
try {
|
||||||
|
if (!empty($this->configurations->getTimesheetLockdownPeriodStart())) {
|
||||||
|
$lockdownStartHelp = $this->getDateTimeFactory()->createDateTime($this->configurations->getTimesheetLockdownPeriodStart());
|
||||||
|
$lockdownStartHelp = $lockdownStartHelp->format($dateFormat);
|
||||||
|
}
|
||||||
|
if (!empty($this->configurations->getTimesheetLockdownPeriodEnd())) {
|
||||||
|
$lockdownEndHelp = $this->getDateTimeFactory()->createDateTime($this->configurations->getTimesheetLockdownPeriodEnd());
|
||||||
|
if (!empty($this->configurations->getTimesheetLockdownGracePeriod())) {
|
||||||
|
$lockdownGraceHelp = clone $lockdownEndHelp;
|
||||||
|
$lockdownGraceHelp->modify($this->configurations->getTimesheetLockdownGracePeriod());
|
||||||
|
$lockdownGraceHelp = $lockdownGraceHelp->format($dateFormat);
|
||||||
|
}
|
||||||
|
$lockdownEndHelp = $lockdownEndHelp->format($dateFormat);
|
||||||
|
}
|
||||||
|
} catch (\Exception $ex) {
|
||||||
|
$lockdownStartHelp = 'invalid';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
(new SystemConfigurationModel())
|
(new SystemConfigurationModel())
|
||||||
->setSection(SystemConfigurationModel::SECTION_TIMESHEET)
|
->setSection(SystemConfigurationModel::SECTION_TIMESHEET)
|
||||||
@@ -246,18 +271,21 @@ final class SystemConfigurationController extends AbstractController
|
|||||||
->setTranslationDomain('system-configuration'),
|
->setTranslationDomain('system-configuration'),
|
||||||
(new Configuration())
|
(new Configuration())
|
||||||
->setName('timesheet.rules.lockdown_period_start')
|
->setName('timesheet.rules.lockdown_period_start')
|
||||||
|
->setOptions(['help' => $lockdownStartHelp])
|
||||||
->setType(TextType::class)
|
->setType(TextType::class)
|
||||||
->setRequired(false)
|
->setRequired(false)
|
||||||
->setConstraints([new DateTimeFormat()])
|
->setConstraints([new DateTimeFormat()])
|
||||||
->setTranslationDomain('system-configuration'),
|
->setTranslationDomain('system-configuration'),
|
||||||
(new Configuration())
|
(new Configuration())
|
||||||
->setName('timesheet.rules.lockdown_period_end')
|
->setName('timesheet.rules.lockdown_period_end')
|
||||||
|
->setOptions(['help' => $lockdownEndHelp])
|
||||||
->setType(TextType::class)
|
->setType(TextType::class)
|
||||||
->setRequired(false)
|
->setRequired(false)
|
||||||
->setConstraints([new DateTimeFormat()])
|
->setConstraints([new DateTimeFormat()])
|
||||||
->setTranslationDomain('system-configuration'),
|
->setTranslationDomain('system-configuration'),
|
||||||
(new Configuration())
|
(new Configuration())
|
||||||
->setName('timesheet.rules.lockdown_grace_period')
|
->setName('timesheet.rules.lockdown_grace_period')
|
||||||
|
->setOptions(['help' => $lockdownGraceHelp])
|
||||||
->setType(TextType::class)
|
->setType(TextType::class)
|
||||||
->setRequired(false)
|
->setRequired(false)
|
||||||
->setConstraints([new DateTimeFormat()])
|
->setConstraints([new DateTimeFormat()])
|
||||||
|
|||||||
@@ -54,16 +54,15 @@ final class LockdownService
|
|||||||
|
|
||||||
$lockedStart = $this->configuration->getTimesheetLockdownPeriodStart();
|
$lockedStart = $this->configuration->getTimesheetLockdownPeriodStart();
|
||||||
$lockedEnd = $this->configuration->getTimesheetLockdownPeriodEnd();
|
$lockedEnd = $this->configuration->getTimesheetLockdownPeriodEnd();
|
||||||
|
|
||||||
$gracePeriod = $this->configuration->getTimesheetLockdownGracePeriod();
|
$gracePeriod = $this->configuration->getTimesheetLockdownGracePeriod();
|
||||||
if (!empty($gracePeriod)) {
|
|
||||||
$gracePeriod = $gracePeriod . ' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$lockdownStart = new \DateTime($lockedStart, $timesheetStart->getTimezone());
|
$lockdownStart = new \DateTime($lockedStart, $timesheetStart->getTimezone());
|
||||||
$lockdownEnd = new \DateTime($lockedEnd, $timesheetStart->getTimezone());
|
$lockdownEnd = new \DateTime($lockedEnd, $timesheetStart->getTimezone());
|
||||||
$lockdownGrace = new \DateTime($gracePeriod . $lockdownEnd->format('Y-m-d'), $timesheetStart->getTimezone());
|
$lockdownGrace = clone $lockdownEnd;
|
||||||
|
if (!empty($gracePeriod)) {
|
||||||
|
$lockdownGrace->modify($gracePeriod);
|
||||||
|
}
|
||||||
} catch (\Exception $ex) {
|
} catch (\Exception $ex) {
|
||||||
// should not happen, but ... if parsing of datetimes fails: skip validation
|
// should not happen, but ... if parsing of datetimes fails: skip validation
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user