Fixes for schedules

This commit is contained in:
David Bomba 2023-06-25 12:38:15 +10:00
parent 86338ce548
commit 32d435d8d7
4 changed files with 14 additions and 3 deletions

View File

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

View File

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

View File

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

View File

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