feat: send disposition reminder email on contract confirmation

This commit is contained in:
Björn Fromme
2025-01-13 16:27:39 +01:00
parent 39f34673fa
commit 03c86755d4
@@ -8,6 +8,7 @@ use App\Entity\Upload;
use App\Event\ApplicationStatusEvent;
use App\Event\AssignmentCalledOffEvent;
use App\Event\DispositionCreatedEvent;
use App\Event\DocumentConfirmedEvent;
use App\Event\DocumentRejectedEvent;
use App\Event\DocumentUploadedEvent;
use App\Model\EmailAttachmentDto;
@@ -32,6 +33,7 @@ class EmailNotificationSubscriber implements EventSubscriberInterface
DocumentRejectedEvent::NAME => 'onDocumentRejected',
ApplicationStatusEvent::NAME => 'onApplicationStatus',
AssignmentCalledOffEvent::NAME => 'onAssignmentCalledOff',
DocumentConfirmedEvent::NAME => 'onDocumentConfirmed',
];
}
@@ -64,6 +66,34 @@ class EmailNotificationSubscriber implements EventSubscriberInterface
]);
}
public function onDocumentConfirmed(DocumentConfirmedEvent $event): void
{
$document = $event->getDocument();
if (Upload::TYPE_CONTRACT !== $document->getType()) {
return;
}
$disposition = $document->getDisposition();
$teamer = $disposition->getTeamer();
$assignment = $disposition->getAssignment();
$destination = $assignment->getDestination();
$dueDate = (new \DateTimeImmutable())->modify('+5 days');
if ($destination->getDateFrom() > $dueDate) {
return;
}
$this->mailer->createAndSendEmail([
'disposition' => $disposition,
], [
'to' => $teamer->getCommunication()->getEmail(),
'subject' => 'Reminder: Dein Einsatz '.$destination,
'template' => 'email/reminder_pre_disposition.html.twig',
]);
}
/**
* Notify managers about uploaded documents
*/