feat: calculate number of days for email reminder

This commit is contained in:
Björn Fromme
2025-01-14 08:40:37 +01:00
parent 029029db11
commit 7ee94fa193
3 changed files with 9 additions and 6 deletions
@@ -79,18 +79,20 @@ class EmailNotificationSubscriber implements EventSubscriberInterface
$assignment = $disposition->getAssignment(); $assignment = $disposition->getAssignment();
$destination = $assignment->getDestination(); $destination = $assignment->getDestination();
$dueDate = (new \DateTimeImmutable())->modify('+5 days'); $today = new \DateTimeImmutable();
$diffInDays = $destination->getDateFrom()->diff($today)->days;
if ($destination->getDateFrom() > $dueDate) { if ($diffInDays < 1 || $diffInDays > 5) {
return; return;
} }
$this->mailer->createAndSendEmail([ $this->mailer->createAndSendEmail([
'disposition' => $disposition, 'disposition' => $disposition,
'diffInDays' => $diffInDays,
], [ ], [
'to' => $teamer->getCommunication()->getEmail(), 'to' => $teamer->getCommunication()->getEmail(),
'subject' => 'Reminder: Dein Einsatz '.$destination, 'subject' => 'Reminder: Dein Einsatz '.$destination,
'template' => 'email/reminder_pre_disposition.html.twig', 'template' => 'email/reminder_disposition.html.twig',
]); ]);
} }
@@ -55,10 +55,11 @@ class DispositionReminderService
$this->mailer->createAndSendEmail([ $this->mailer->createAndSendEmail([
'disposition' => $disposition, 'disposition' => $disposition,
'diffInDays' => 5,
], [ ], [
'to' => $teamer->getCommunication()->getEmail(), 'to' => $teamer->getCommunication()->getEmail(),
'subject' => 'Reminder: Dein Einsatz '.$destination, 'subject' => 'Reminder: Dein Einsatz '.$destination,
'template' => 'email/reminder_pre_disposition.html.twig', 'template' => 'email/reminder_disposition.html.twig',
]); ]);
} }
@@ -7,8 +7,8 @@
</h1> </h1>
<p> <p>
dein Einsatz als {{ disposition.assignment.jobProfile.name }}, {{ destination.product }} vom 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 {{ destination.dateFrom | date('d.m.Y') }} bis {{ destination.dateTo | date('d.m.Y') }} beginnt
Tagen</strong>. <strong>in {{ diffInDays }} Tagen</strong>.
</p> </p>
<p> <p>
Wir hoffen, dass du ich schon freust und wünschen dir viel Spaß und Erfolg! Finale Infos erhältst du, falls noch Wir hoffen, dass du ich schon freust und wünschen dir viel Spaß und Erfolg! Finale Infos erhältst du, falls noch