From 022dbe32e5c8e54338ed3bd65fa1def1745720d4 Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Tue, 31 Dec 2019 20:24:47 +0100 Subject: [PATCH] allow empty date in export (#1338) --- .editorconfig | 3 ++- src/Controller/ExportController.php | 8 ++++++-- src/Form/Toolbar/AbstractToolbarForm.php | 4 ++-- templates/export/index.html.twig | 2 +- templates/invoice/index.html.twig | 2 +- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.editorconfig b/.editorconfig index a0e669a2..b978680c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -3,7 +3,8 @@ root = true ; Unix-style newlines [*] -end_of_line = LF +end_of_line = lf +charset = utf-8 [*.php] indent_style = space diff --git a/src/Controller/ExportController.php b/src/Controller/ExportController.php index 0cead365..a2f11d9b 100644 --- a/src/Controller/ExportController.php +++ b/src/Controller/ExportController.php @@ -143,8 +143,12 @@ class ExportController extends AbstractController */ protected function getEntries(ExportQuery $query): array { - $query->getBegin()->setTime(0, 0, 0); - $query->getEnd()->setTime(23, 59, 59); + if (null !== $query->getBegin()) { + $query->getBegin()->setTime(0, 0, 0); + } + if (null !== $query->getEnd()) { + $query->getEnd()->setTime(23, 59, 59); + } return $this->timesheetRepository->getTimesheetsForQuery($query, true); } diff --git a/src/Form/Toolbar/AbstractToolbarForm.php b/src/Form/Toolbar/AbstractToolbarForm.php index 65bf3804..ea417f8c 100644 --- a/src/Form/Toolbar/AbstractToolbarForm.php +++ b/src/Form/Toolbar/AbstractToolbarForm.php @@ -122,10 +122,10 @@ abstract class AbstractToolbarForm extends AbstractType ]); } - protected function addDateRangeChoice(FormBuilderInterface $builder, $allowEmpty = true) + protected function addDateRangeChoice(FormBuilderInterface $builder, $allowEmpty = true, $required = false) { $builder->add('daterange', DateRangeType::class, [ - 'required' => false, + 'required' => $required, 'allow_empty' => $allowEmpty, ]); } diff --git a/templates/export/index.html.twig b/templates/export/index.html.twig index a78f286e..16e7699f 100644 --- a/templates/export/index.html.twig +++ b/templates/export/index.html.twig @@ -83,7 +83,7 @@ {{ rate|money(currency) }} - + {{ duration }} diff --git a/templates/invoice/index.html.twig b/templates/invoice/index.html.twig index 0f85d39e..d6862701 100644 --- a/templates/invoice/index.html.twig +++ b/templates/invoice/index.html.twig @@ -83,7 +83,7 @@ {{ rate|money(model.calculator.currency) }} {{ amount }} - {{ duration }} + {{ duration }} {{ entry.rate|money(model.calculator.currency) }} {% endfor %}