diff --git a/app/Http/Requests/TaskScheduler/StoreSchedulerRequest.php b/app/Http/Requests/TaskScheduler/StoreSchedulerRequest.php index 1c132dbb9b06..c0fc0c9d6061 100644 --- a/app/Http/Requests/TaskScheduler/StoreSchedulerRequest.php +++ b/app/Http/Requests/TaskScheduler/StoreSchedulerRequest.php @@ -57,7 +57,7 @@ class StoreSchedulerRequest extends Request $input = $this->all(); if (array_key_exists('next_run', $input) && is_string($input['next_run'])) { - $this->merge(['next_run_client' => $input['next_run']]); + $input['next_run_client'] = $input['next_run']; } if($input['template'] == 'email_record'){ diff --git a/app/Http/Requests/TaskScheduler/UpdateSchedulerRequest.php b/app/Http/Requests/TaskScheduler/UpdateSchedulerRequest.php index 74d011722ca2..24dea23f0ac9 100644 --- a/app/Http/Requests/TaskScheduler/UpdateSchedulerRequest.php +++ b/app/Http/Requests/TaskScheduler/UpdateSchedulerRequest.php @@ -54,7 +54,7 @@ class UpdateSchedulerRequest extends Request $input = $this->all(); if (array_key_exists('next_run', $input) && is_string($input['next_run'])) { - $this->merge(['next_run_client' => $input['next_run']]); + $input['next_run_client'] = $input['next_run']; } if($input['template'] == 'email_record') { diff --git a/app/Models/Scheduler.php b/app/Models/Scheduler.php index 5210914723ce..ed58d0bea43f 100644 --- a/app/Models/Scheduler.php +++ b/app/Models/Scheduler.php @@ -202,5 +202,16 @@ class Scheduler extends BaseModel $this->save(); } + public function adjustOffset(): void + { + if (! $this->next_run) { + return; + } + $offset = $this->company->timezone_offset(); + + $this->next_run = $this->next_run->copy()->addSeconds($offset); + $this->save(); + + } } diff --git a/app/Repositories/SchedulerRepository.php b/app/Repositories/SchedulerRepository.php index 2f2f314cb5c4..92e0ccd2d36a 100644 --- a/app/Repositories/SchedulerRepository.php +++ b/app/Repositories/SchedulerRepository.php @@ -31,7 +31,7 @@ class SchedulerRepository extends BaseRepository $scheduler->save(); /** 18-5-2023 set client specific send times. */ - $scheduler->calculateNextRun(); + $scheduler->adjustOffset(); return $scheduler->fresh(); }