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 */