|
@@ -27,6 +27,7 @@ class EmailComunications extends Component
|
|
|
|
|
|
|
|
public string $mode = 'now'; // 'now' | 'schedule'
|
|
public string $mode = 'now'; // 'now' | 'schedule'
|
|
|
public ?string $schedule_at = null;
|
|
public ?string $schedule_at = null;
|
|
|
|
|
+ public ?string $timezone = 'UTC';
|
|
|
|
|
|
|
|
public $records;
|
|
public $records;
|
|
|
public $categories;
|
|
public $categories;
|
|
@@ -55,7 +56,7 @@ class EmailComunications extends Component
|
|
|
$this->courses = [];
|
|
$this->courses = [];
|
|
|
$this->getCourses(\App\Models\Course::select('id', 'name')->where('parent_id', null)->orderBy('name', 'ASC')->get(), 0);
|
|
$this->getCourses(\App\Models\Course::select('id', 'name')->where('parent_id', null)->orderBy('name', 'ASC')->get(), 0);
|
|
|
|
|
|
|
|
- $this->schedule_at = now()->addHour()->format('Y-m-d\TH:i');
|
|
|
|
|
|
|
+ $this->schedule_at = now($this->timezone)->addHour()->format('Y-m-d\TH:i');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function render()
|
|
public function render()
|
|
@@ -108,7 +109,7 @@ class EmailComunications extends Component
|
|
|
{
|
|
{
|
|
|
$this->reset(['messageId', 'subject', 'content_html', 'recipients', 'newAttachments', 'mode', 'schedule_at']);
|
|
$this->reset(['messageId', 'subject', 'content_html', 'recipients', 'newAttachments', 'mode', 'schedule_at']);
|
|
|
$this->mode = 'now';
|
|
$this->mode = 'now';
|
|
|
- $this->schedule_at = now()->addHour()->format('Y-m-d\TH:i');
|
|
|
|
|
|
|
+ $this->schedule_at = now($this->timezone)->addHour()->format('Y-m-d\TH:i');
|
|
|
$this->existingAttachments = [];
|
|
$this->existingAttachments = [];
|
|
|
|
|
|
|
|
$this->showForm = true;
|
|
$this->showForm = true;
|
|
@@ -137,7 +138,7 @@ class EmailComunications extends Component
|
|
|
'last_name' => optional($r->member)->last_name,
|
|
'last_name' => optional($r->member)->last_name,
|
|
|
])->toArray();
|
|
])->toArray();
|
|
|
$this->mode = $msg->status === 'scheduled' ? 'schedule' : 'now';
|
|
$this->mode = $msg->status === 'scheduled' ? 'schedule' : 'now';
|
|
|
- $this->schedule_at = optional($msg->schedule_at)?->format('Y-m-d\TH:i');
|
|
|
|
|
|
|
+ $this->schedule_at = optional($msg->schedule_at)?->setTimezone($this->timezone)?->format('Y-m-d\TH:i');
|
|
|
$this->existingAttachments = $msg->attachments->map(fn($a) => [
|
|
$this->existingAttachments = $msg->attachments->map(fn($a) => [
|
|
|
'id' => $a->id,
|
|
'id' => $a->id,
|
|
|
'name' => $a->name ?: basename($a->path),
|
|
'name' => $a->name ?: basename($a->path),
|
|
@@ -239,8 +240,10 @@ class EmailComunications extends Component
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- DB::transaction(function () {
|
|
|
|
|
- $msg = $this->upsertMessage(status: 'scheduled', scheduleAt: \Carbon\Carbon::parse($this->schedule_at));
|
|
|
|
|
|
|
+ $scheduledAt = \Carbon\Carbon::parse($this->schedule_at, $this->timezone)->setTimezone('UTC');
|
|
|
|
|
+
|
|
|
|
|
+ DB::transaction(function () use ($scheduledAt) {
|
|
|
|
|
+ $msg = $this->upsertMessage(status: 'scheduled', scheduleAt: $scheduledAt);
|
|
|
$this->upsertRecipients($msg, true);
|
|
$this->upsertRecipients($msg, true);
|
|
|
$this->upsertAttachments($msg, true);
|
|
$this->upsertAttachments($msg, true);
|
|
|
$this->messageId = $msg->id;
|
|
$this->messageId = $msg->id;
|
|
@@ -265,7 +268,8 @@ class EmailComunications extends Component
|
|
|
'content_html' => $this->content_html,
|
|
'content_html' => $this->content_html,
|
|
|
'status' => $status,
|
|
'status' => $status,
|
|
|
'schedule_at' => $scheduleAt,
|
|
'schedule_at' => $scheduleAt,
|
|
|
- 'created_by' => auth()->id(),
|
|
|
|
|
|
|
+ // 'created_by' => auth()->id(),
|
|
|
|
|
+ 'created_by' => 8,
|
|
|
]
|
|
]
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
@@ -310,7 +314,7 @@ class EmailComunications extends Component
|
|
|
$this->showForm = false;
|
|
$this->showForm = false;
|
|
|
$this->reset(['messageId', 'subject', 'content_html', 'recipients', 'newAttachments', 'mode', 'schedule_at']);
|
|
$this->reset(['messageId', 'subject', 'content_html', 'recipients', 'newAttachments', 'mode', 'schedule_at']);
|
|
|
$this->mode = 'now';
|
|
$this->mode = 'now';
|
|
|
- $this->schedule_at = now()->addHour()->format('Y-m-d\TH:i');
|
|
|
|
|
|
|
+ $this->schedule_at = now($this->timezone)->addHour()->format('Y-m-d\TH:i');
|
|
|
|
|
|
|
|
$this->dispatchBrowserEvent('init-archive-table');
|
|
$this->dispatchBrowserEvent('init-archive-table');
|
|
|
}
|
|
}
|