feat: send disposition reminder emails
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use App\Service\Cron\DispositionReminderService;
|
||||
use App\Service\Cron\DispositionStatusService;
|
||||
use App\Service\Cron\FeedbackReminderService;
|
||||
use App\Service\Cron\FlushLogsService;
|
||||
@@ -22,7 +23,8 @@ class CronCommand extends Command
|
||||
private readonly FlushLogsService $flushLogsService,
|
||||
private readonly UploadReminderService $uploadReminderService,
|
||||
private readonly FeedbackReminderService $feedbackReminderService,
|
||||
private readonly DispositionStatusService $dispositionStatusService
|
||||
private readonly DispositionStatusService $dispositionStatusService,
|
||||
private readonly DispositionReminderService $dispositionReminderService,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
@@ -50,6 +52,9 @@ class CronCommand extends Command
|
||||
$message = $this->dispositionStatusService->setEndedStatus();
|
||||
$io->info($message);
|
||||
|
||||
$message = $this->dispositionReminderService->sendDispositionReminders();
|
||||
$io->info($message);
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service\Cron;
|
||||
|
||||
use App\Email\Mailer;
|
||||
use App\Entity\Disposition;
|
||||
use App\Repository\DispositionRepository;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class DispositionReminderService
|
||||
{
|
||||
public function __construct(
|
||||
private readonly DispositionRepository $dispositionRepository,
|
||||
private readonly Mailer $mailer,
|
||||
private readonly LoggerInterface $logger
|
||||
) {
|
||||
}
|
||||
|
||||
public function sendDispositionReminders(): string
|
||||
{
|
||||
// find dispositions starting in five days from now
|
||||
$dateFrom = (new \DateTimeImmutable())->modify('+5 days');
|
||||
$qb = $this->dispositionRepository->createQueryBuilder('disposition');
|
||||
|
||||
$dispositions = $qb
|
||||
->select('disposition', 'assignment', 'destination')
|
||||
->innerJoin('disposition.assignment', 'assignment')
|
||||
->innerJoin('assignment.destination', 'destination')
|
||||
->where($qb->expr()->eq('destination.dateFrom', ':dateFrom'))
|
||||
->setParameter('dateFrom', $dateFrom->format('Y-m-d'))
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
|
||||
if (0 === $count = count($dispositions)) {
|
||||
$message = 'No disposition reminders to be sent to teamers';
|
||||
$this->logger->info($message);
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
foreach ($dispositions as $disposition) {
|
||||
/** @var Disposition $disposition */
|
||||
$teamer = $disposition->getTeamer();
|
||||
$assignment = $disposition->getAssignment();
|
||||
$destination = $assignment->getDestination();
|
||||
|
||||
$this->mailer->createAndSendEmail([
|
||||
'disposition' => $disposition,
|
||||
], [
|
||||
'to' => $teamer->getCommunication()->getEmail(),
|
||||
'subject' => 'Reminder: Dein Einsatz '.$destination,
|
||||
'template' => 'email/reminder_pre_disposition.html.twig',
|
||||
]);
|
||||
}
|
||||
|
||||
$message = 'Sent '.$count.' disposition reminders to teamers';
|
||||
$this->logger->info($message);
|
||||
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
{% extends 'email/layout.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
{% set destination = disposition.assignment.destination %}
|
||||
<h1>
|
||||
Hallo aus Köln,
|
||||
</h1>
|
||||
<p>
|
||||
dein Einsatz als {{ disposition.assignment.jobProfile.name }}, {{ destination.product }} vom
|
||||
{{ destination.dateFrom | date('d.m.Y') }} bis {{ destination.dateTo | date('d.m.Y') }} beginnt <strong>in fünf
|
||||
Tagen</strong>.
|
||||
</p>
|
||||
<p>
|
||||
Wir hoffen, dass du ich schon freust und wünschen dir viel Spaß und Erfolg! Finale Infos erhältst du, falls noch
|
||||
nicht geschehen, ein paar Tage vor deinem Einsatz von deinen zuständigen Haus- oder Reisemanager:innen.
|
||||
</p>
|
||||
<p>
|
||||
Bitte denk daran, deine <strong>ausgefüllte Honorarnote bis zu 14 Tage nach deinem Einsatz</strong> in My
|
||||
E&P Team hochzuladen.
|
||||
</p>
|
||||
<p>
|
||||
Liebe Grüße,
|
||||
<br>
|
||||
dein Team Personalabteilung
|
||||
</p>
|
||||
<p>
|
||||
<a href="{{ url('app_teamer_index') }}" class="button">
|
||||
Zum Portal
|
||||
</a>
|
||||
</p>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user