fix timezone for timesheets created by other users (#1509)
This commit is contained in:
@@ -148,6 +148,7 @@ final class TimesheetService
|
||||
$this->repository->begin();
|
||||
try {
|
||||
$this->validateTimesheet($timesheet);
|
||||
$this->fixTimezone($timesheet);
|
||||
|
||||
$this->dispatcher->dispatch(new TimesheetCreatePreEvent($timesheet));
|
||||
$this->repository->save($timesheet);
|
||||
@@ -187,6 +188,8 @@ final class TimesheetService
|
||||
}
|
||||
*/
|
||||
|
||||
$this->fixTimezone($timesheet);
|
||||
|
||||
$this->dispatcher->dispatch(new TimesheetUpdatePreEvent($timesheet));
|
||||
$this->repository->save($timesheet);
|
||||
$this->dispatcher->dispatch(new TimesheetUpdatePostEvent($timesheet));
|
||||
@@ -263,6 +266,21 @@ final class TimesheetService
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes sure, that the timesheet record has the timezone of the user.
|
||||
*
|
||||
* This fixes #1442 and prevents a wrong time if a teamlead edits the
|
||||
* timesheet for an employee living in another timezone.
|
||||
*
|
||||
* @param Timesheet $timesheet
|
||||
*/
|
||||
private function fixTimezone(Timesheet $timesheet)
|
||||
{
|
||||
if (null !== ($timezone = $timesheet->getTimezone()) && $timezone !== $timesheet->getUser()->getTimezone()) {
|
||||
$timesheet->setTimezone($timesheet->getUser()->getTimezone());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops active records if more than allowed are running for the timesheet user.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user