From e750436a82da91205540e98a08e7228df3559cec Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Wed, 20 Jul 2022 20:02:15 +0200 Subject: [PATCH] Fix worklog input validation error and default to current day during buildup --- includes/controller/user_worklog_controller.php | 4 ++-- includes/model/UserWorkLog_model.php | 4 +++- resources/lang/de_DE/default.po | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/includes/controller/user_worklog_controller.php b/includes/controller/user_worklog_controller.php index a9b02a4b..6ba99ed4 100644 --- a/includes/controller/user_worklog_controller.php +++ b/includes/controller/user_worklog_controller.php @@ -87,9 +87,9 @@ function user_worklog_from_request(Worklog $worklog) } $worklog->hours = $request->input('work_hours'); - if (!preg_match("/^\d+(\.\d{0,2})?$/", $worklog->hours)) { + if (!preg_match("/^\d+(\.\d{0,2})?$/", $request->input('work_hours'))) { $valid = false; - error(__('Please enter work hours in format ##[.##].')); + error(__('Please enter work hours in format ##[.##]')); } $worklog->comment = $request->input('comment'); diff --git a/includes/model/UserWorkLog_model.php b/includes/model/UserWorkLog_model.php index e00a4c03..ef167afe 100644 --- a/includes/model/UserWorkLog_model.php +++ b/includes/model/UserWorkLog_model.php @@ -125,9 +125,11 @@ function UserWorkLog_new($userId) { /** @var Carbon $buildup */ $buildup = config('buildup_start'); + /** @var Carbon $event */ + $event = config('event_start'); $work_date = Carbon::today(); - if (!empty($buildup)) { + if (!empty($buildup) && (empty($event) || $event->lessThan(Carbon::now()))) { $work_date = $buildup; } diff --git a/resources/lang/de_DE/default.po b/resources/lang/de_DE/default.po index 7976c528..28fea16c 100644 --- a/resources/lang/de_DE/default.po +++ b/resources/lang/de_DE/default.po @@ -777,8 +777,8 @@ msgid "Please enter work date." msgstr "Bitte Einsatzdatum angeben." #: includes/controller/user_worklog_controller.php:87 -msgid "Please enter work hours in format ##[.##]." -msgstr "Bitte Stunden im Format ##[.##| eingeben." +msgid "Please enter work hours in format ##[.##]" +msgstr "Bitte Stunden im Format ##[.##] eingeben." #: includes/controller/user_worklog_controller.php:93 msgid "Please enter a comment."