Fix worklog input validation error and default to current day during buildup

This commit is contained in:
Igor Scheller 2022-07-20 20:02:15 +02:00
parent 9e0c7180d7
commit e750436a82
3 changed files with 7 additions and 5 deletions

View File

@ -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');

View File

@ -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;
}

View File

@ -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."