From 03c86755d4a0f2b1ba4c68256c26a2c007e3297e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Mon, 13 Jan 2025 16:27:39 +0100 Subject: [PATCH] feat: send disposition reminder email on contract confirmation --- .../EmailNotificationSubscriber.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/EventListener/EmailNotificationSubscriber.php b/src/EventListener/EmailNotificationSubscriber.php index 2d26f47..639fc2e 100644 --- a/src/EventListener/EmailNotificationSubscriber.php +++ b/src/EventListener/EmailNotificationSubscriber.php @@ -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 */