diff --git a/src/Controller/SystemConfigurationController.php b/src/Controller/SystemConfigurationController.php
index ffbaf1ab..50d7cedb 100644
--- a/src/Controller/SystemConfigurationController.php
+++ b/src/Controller/SystemConfigurationController.php
@@ -14,12 +14,14 @@ use App\Event\SystemConfigurationEvent;
use App\Form\Model\Configuration;
use App\Form\Model\SystemConfiguration as SystemConfigurationModel;
use App\Form\SystemConfigurationForm;
+use App\Form\Type\DateTimeTextType;
use App\Form\Type\LanguageType;
use App\Form\Type\RoundingModeType;
use App\Form\Type\SkinType;
use App\Form\Type\TrackingModeType;
use App\Form\Type\WeekDaysType;
use App\Repository\ConfigurationRepository;
+use App\Validator\Constraints\DateTimeFormat;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
@@ -216,6 +218,11 @@ final class SystemConfigurationController extends AbstractController
->setName('timesheet.mode')
->setType(TrackingModeType::class)
->setTranslationDomain('system-configuration'),
+ (new Configuration())
+ ->setName('timesheet.default_begin')
+ ->setType(DateTimeTextType::class)
+ ->setConstraints([new DateTimeFormat(), new NotNull()])
+ ->setTranslationDomain('system-configuration'),
(new Configuration())
->setName('timesheet.rules.allow_future_times')
->setType(CheckboxType::class)
diff --git a/src/Form/Type/DateTimeTextType.php b/src/Form/Type/DateTimeTextType.php
new file mode 100644
index 00000000..58939e71
--- /dev/null
+++ b/src/Form/Type/DateTimeTextType.php
@@ -0,0 +1,24 @@
+ 'The given value is not a valid datetime format.',
+ ];
+
+ public $message = 'This datetime format is invalid.';
+
+ public function getTargets()
+ {
+ return self::PROPERTY_CONSTRAINT;
+ }
+}
diff --git a/src/Validator/Constraints/DateTimeFormatValidator.php b/src/Validator/Constraints/DateTimeFormatValidator.php
new file mode 100644
index 00000000..7e179713
--- /dev/null
+++ b/src/Validator/Constraints/DateTimeFormatValidator.php
@@ -0,0 +1,43 @@
+context->buildViolation('The given value is not a valid datetime format.')
+ ->setTranslationDomain('validators')
+ ->setCode(DateTimeFormat::INVALID_FORMAT)
+ ->addViolation();
+ }
+ }
+}
diff --git a/tests/Controller/SystemConfigurationControllerTest.php b/tests/Controller/SystemConfigurationControllerTest.php
index e95237c0..240a959a 100644
--- a/tests/Controller/SystemConfigurationControllerTest.php
+++ b/tests/Controller/SystemConfigurationControllerTest.php
@@ -93,6 +93,7 @@ class SystemConfigurationControllerTest extends ControllerBaseTest
'system_configuration_form_timesheet' => [
'configuration' => [
['name' => 'timesheet.mode', 'value' => 'duration_only'],
+ ['name' => 'timesheet.active_entries.default_begin', 'value' => '23:59'],
['name' => 'timesheet.rules.allow_future_times', 'value' => false],
['name' => 'timesheet.active_entries.hard_limit', 'value' => 99],
['name' => 'timesheet.active_entries.soft_limit', 'value' => 77],
@@ -122,6 +123,7 @@ class SystemConfigurationControllerTest extends ControllerBaseTest
'system_configuration_form_timesheet' => [
'configuration' => [
['name' => 'timesheet.mode', 'value' => 'foo'],
+ ['name' => 'timesheet.active_entries.default_begin', 'value' => '23:59'],
['name' => 'timesheet.rules.allow_future_times', 'value' => 1],
['name' => 'timesheet.active_entries.hard_limit', 'value' => -1],
['name' => 'timesheet.active_entries.soft_limit', 'value' => -1],
@@ -130,8 +132,8 @@ class SystemConfigurationControllerTest extends ControllerBaseTest
],
[
'#system_configuration_form_timesheet_configuration_0_value', // mode
- '#system_configuration_form_timesheet_configuration_2_value', // hard_limit
- '#system_configuration_form_timesheet_configuration_3_value', // soft_limit
+ '#system_configuration_form_timesheet_configuration_3_value', // hard_limit
+ '#system_configuration_form_timesheet_configuration_4_value', // soft_limit
],
true
);
diff --git a/tests/Validator/Constraints/DateTimeFormatValidatorTest.php b/tests/Validator/Constraints/DateTimeFormatValidatorTest.php
new file mode 100644
index 00000000..bf6b2c25
--- /dev/null
+++ b/tests/Validator/Constraints/DateTimeFormatValidatorTest.php
@@ -0,0 +1,85 @@
+expectException(UnexpectedTypeException::class);
+
+ $this->validator->validate('foo', new NotBlank());
+ }
+
+ /**
+ * @dataProvider getValidData
+ * @param string $input
+ */
+ public function testConstraintWithValidData($input)
+ {
+ $constraint = new DateTimeFormat();
+ $this->validator->validate($input, $constraint);
+ $this->assertNoViolation();
+ }
+
+ public function getInvalidData()
+ {
+ return [
+ ['13-13'],
+ ['3127::00'],
+ ['3127:00:'],
+ [':3127:00'],
+ ['::3127'],
+ ];
+ }
+
+ /**
+ * @dataProvider getInvalidData
+ * @param mixed $input
+ */
+ public function testValidationError($input)
+ {
+ $constraint = new DateTimeFormat();
+
+ $this->validator->validate($input, $constraint);
+
+ $expectedFormat = is_string($input) ? '"' . $input . '"' : $input;
+
+ $this->buildViolation('The given value is not a valid datetime format.')
+ ->setCode(DateTimeFormat::INVALID_FORMAT)
+ ->assertRaised();
+ }
+}
diff --git a/translations/system-configuration.de.xlf b/translations/system-configuration.de.xlf
index f7ac9b4b..ade9f5aa 100644
--- a/translations/system-configuration.de.xlf
+++ b/translations/system-configuration.de.xlf
@@ -190,6 +190,10 @@
Floor
Floor: Start, Ende und Dauer werden nach unten gerundet
+
+ label.timesheet.default_begin
+ Standard Startzeit (wird nicht in jedem Zeiterfassungs Modus verwendet)
+