|
@@ -61,10 +61,12 @@ final class Mailer
|
|
|
$formDataPdf = $this->pdfGenerator->generateFormDataPdf($submission);
|
|
$formDataPdf = $this->pdfGenerator->generateFormDataPdf($submission);
|
|
|
$attachmentsPdf = $this->pdfGenerator->generateAttachmentsPdf($submission);
|
|
$attachmentsPdf = $this->pdfGenerator->generateAttachmentsPdf($submission);
|
|
|
$pdfAttachments = $this->pdfGenerator->collectPdfAttachments($submission);
|
|
$pdfAttachments = $this->pdfGenerator->collectPdfAttachments($submission);
|
|
|
|
|
+ $minorSignaturePdf = $this->pdfGenerator->generateMinorSignaturePdf($submission);
|
|
|
|
|
+ $isMinorSubmission = $this->isMinorSubmission($submission);
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- $this->sendAdminMails($submission, $formDataPdf, $attachmentsPdf, $pdfAttachments);
|
|
|
|
|
- $this->sendApplicantMail($submission);
|
|
|
|
|
|
|
+ $this->sendAdminMails($submission, $formDataPdf, $attachmentsPdf, $pdfAttachments, $isMinorSubmission);
|
|
|
|
|
+ $this->sendApplicantMail($submission, $minorSignaturePdf);
|
|
|
} finally {
|
|
} finally {
|
|
|
if ($formDataPdf !== null) {
|
|
if ($formDataPdf !== null) {
|
|
|
@unlink($formDataPdf);
|
|
@unlink($formDataPdf);
|
|
@@ -72,6 +74,9 @@ final class Mailer
|
|
|
if ($attachmentsPdf !== null) {
|
|
if ($attachmentsPdf !== null) {
|
|
|
@unlink($attachmentsPdf);
|
|
@unlink($attachmentsPdf);
|
|
|
}
|
|
}
|
|
|
|
|
+ if ($minorSignaturePdf !== null) {
|
|
|
|
|
+ @unlink($minorSignaturePdf);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -84,12 +89,13 @@ final class Mailer
|
|
|
?string $formDataPdf,
|
|
?string $formDataPdf,
|
|
|
?string $attachmentsPdf,
|
|
?string $attachmentsPdf,
|
|
|
array $pdfAttachments,
|
|
array $pdfAttachments,
|
|
|
|
|
+ bool $isMinorSubmission,
|
|
|
): void {
|
|
): void {
|
|
|
$recipients = (array) ($this->mailConfig['recipients'] ?? []);
|
|
$recipients = (array) ($this->mailConfig['recipients'] ?? []);
|
|
|
$subject = (string) ($this->mailConfig['subjects']['admin'] ?? 'Neuer Mitgliedsantrag');
|
|
$subject = (string) ($this->mailConfig['subjects']['admin'] ?? 'Neuer Mitgliedsantrag');
|
|
|
|
|
|
|
|
- $htmlBody = $this->renderAdminHtml($submission);
|
|
|
|
|
- $textBody = $this->renderAdminText($submission);
|
|
|
|
|
|
|
+ $htmlBody = $this->renderAdminHtml($submission, $isMinorSubmission);
|
|
|
|
|
+ $textBody = $this->renderAdminText($submission, $isMinorSubmission);
|
|
|
|
|
|
|
|
foreach ($recipients as $recipient) {
|
|
foreach ($recipients as $recipient) {
|
|
|
if (!is_string($recipient) || $recipient === '') {
|
|
if (!is_string($recipient) || $recipient === '') {
|
|
@@ -123,16 +129,17 @@ final class Mailer
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/** @param array<string, mixed> $submission */
|
|
/** @param array<string, mixed> $submission */
|
|
|
- private function sendApplicantMail(array $submission): void
|
|
|
|
|
|
|
+ private function sendApplicantMail(array $submission, ?string $minorSignaturePdf): void
|
|
|
{
|
|
{
|
|
|
$email = (string) ($submission['email'] ?? '');
|
|
$email = (string) ($submission['email'] ?? '');
|
|
|
if ($email === '') {
|
|
if ($email === '') {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ $isMinorSubmission = $this->isMinorSubmission($submission);
|
|
|
$subject = (string) ($this->mailConfig['subjects']['applicant'] ?? 'Bestätigung Mitgliedsantrag');
|
|
$subject = (string) ($this->mailConfig['subjects']['applicant'] ?? 'Bestätigung Mitgliedsantrag');
|
|
|
- $htmlBody = $this->renderApplicantHtml($submission);
|
|
|
|
|
- $textBody = $this->renderApplicantText($submission);
|
|
|
|
|
|
|
+ $htmlBody = $this->renderApplicantHtml($submission, $isMinorSubmission);
|
|
|
|
|
+ $textBody = $this->renderApplicantText($submission, $isMinorSubmission);
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
$mail = $this->createMailBuilder();
|
|
$mail = $this->createMailBuilder();
|
|
@@ -141,6 +148,10 @@ final class Mailer
|
|
|
->setHtmlBody($htmlBody)
|
|
->setHtmlBody($htmlBody)
|
|
|
->setTextBody($textBody);
|
|
->setTextBody($textBody);
|
|
|
|
|
|
|
|
|
|
+ if ($minorSignaturePdf !== null && is_file($minorSignaturePdf)) {
|
|
|
|
|
+ $mail->addAttachment($minorSignaturePdf, 'Einverstaendniserklaerung-Minderjaehrige.pdf', 'application/pdf');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (!$mail->send()) {
|
|
if (!$mail->send()) {
|
|
|
Bootstrap::log('mail', 'Versand an Antragsteller fehlgeschlagen: ' . $email . ' - ' . $mail->getErrorInfo());
|
|
Bootstrap::log('mail', 'Versand an Antragsteller fehlgeschlagen: ' . $email . ' - ' . $mail->getErrorInfo());
|
|
|
}
|
|
}
|
|
@@ -166,7 +177,7 @@ final class Mailer
|
|
|
// ---------------------------------------------------------------
|
|
// ---------------------------------------------------------------
|
|
|
|
|
|
|
|
/** @param array<string, mixed> $submission */
|
|
/** @param array<string, mixed> $submission */
|
|
|
- private function renderAdminHtml(array $submission): string
|
|
|
|
|
|
|
+ private function renderAdminHtml(array $submission, bool $isMinorSubmission): string
|
|
|
{
|
|
{
|
|
|
$steps = $this->formatter->formatSteps($submission);
|
|
$steps = $this->formatter->formatSteps($submission);
|
|
|
$uploads = $this->formatter->formatUploads($submission);
|
|
$uploads = $this->formatter->formatUploads($submission);
|
|
@@ -175,6 +186,9 @@ final class Mailer
|
|
|
$h .= '<h2 style="color:#c0392b">Neuer Mitgliedsantrag</h2>';
|
|
$h .= '<h2 style="color:#c0392b">Neuer Mitgliedsantrag</h2>';
|
|
|
$h .= '<p>Eingereicht: ' . $this->esc($this->formatTimestamp($submission)) . '<br>';
|
|
$h .= '<p>Eingereicht: ' . $this->esc($this->formatTimestamp($submission)) . '<br>';
|
|
|
$h .= 'E-Mail: ' . $this->esc((string) ($submission['email'] ?? '')) . '</p>';
|
|
$h .= 'E-Mail: ' . $this->esc((string) ($submission['email'] ?? '')) . '</p>';
|
|
|
|
|
+ if ($isMinorSubmission) {
|
|
|
|
|
+ $h .= $this->renderMinorAdminNoticeHtml();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
foreach ($steps as $step) {
|
|
foreach ($steps as $step) {
|
|
|
$h .= '<h3 style="border-bottom:2px solid #c0392b;padding-bottom:4px">' . $this->esc($step['title']) . '</h3>';
|
|
$h .= '<h3 style="border-bottom:2px solid #c0392b;padding-bottom:4px">' . $this->esc($step['title']) . '</h3>';
|
|
@@ -203,7 +217,7 @@ final class Mailer
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/** @param array<string, mixed> $submission */
|
|
/** @param array<string, mixed> $submission */
|
|
|
- private function renderAdminText(array $submission): string
|
|
|
|
|
|
|
+ private function renderAdminText(array $submission, bool $isMinorSubmission): string
|
|
|
{
|
|
{
|
|
|
$steps = $this->formatter->formatSteps($submission);
|
|
$steps = $this->formatter->formatSteps($submission);
|
|
|
$uploads = $this->formatter->formatUploads($submission);
|
|
$uploads = $this->formatter->formatUploads($submission);
|
|
@@ -211,6 +225,9 @@ final class Mailer
|
|
|
$t = "NEUER MITGLIEDSANTRAG\n";
|
|
$t = "NEUER MITGLIEDSANTRAG\n";
|
|
|
$t .= 'Eingereicht: ' . $this->formatTimestamp($submission) . "\n";
|
|
$t .= 'Eingereicht: ' . $this->formatTimestamp($submission) . "\n";
|
|
|
$t .= 'E-Mail: ' . (string) ($submission['email'] ?? '') . "\n\n";
|
|
$t .= 'E-Mail: ' . (string) ($submission['email'] ?? '') . "\n\n";
|
|
|
|
|
+ if ($isMinorSubmission) {
|
|
|
|
|
+ $t .= $this->renderMinorAdminNoticeText() . "\n\n";
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
foreach ($steps as $step) {
|
|
foreach ($steps as $step) {
|
|
|
$t .= strtoupper($step['title']) . "\n" . str_repeat('-', 40) . "\n";
|
|
$t .= strtoupper($step['title']) . "\n" . str_repeat('-', 40) . "\n";
|
|
@@ -237,7 +254,7 @@ final class Mailer
|
|
|
// ---------------------------------------------------------------
|
|
// ---------------------------------------------------------------
|
|
|
|
|
|
|
|
/** @param array<string, mixed> $submission */
|
|
/** @param array<string, mixed> $submission */
|
|
|
- private function renderApplicantHtml(array $submission): string
|
|
|
|
|
|
|
+ private function renderApplicantHtml(array $submission, bool $isMinorSubmission): string
|
|
|
{
|
|
{
|
|
|
$steps = $this->formatter->formatSteps($submission);
|
|
$steps = $this->formatter->formatSteps($submission);
|
|
|
$uploads = $this->formatter->formatUploads($submission);
|
|
$uploads = $this->formatter->formatUploads($submission);
|
|
@@ -245,6 +262,11 @@ final class Mailer
|
|
|
$h = '<!DOCTYPE html><html><head><meta charset="UTF-8"></head><body style="font-family:Arial,sans-serif;color:#333;max-width:700px;margin:0 auto">';
|
|
$h = '<!DOCTYPE html><html><head><meta charset="UTF-8"></head><body style="font-family:Arial,sans-serif;color:#333;max-width:700px;margin:0 auto">';
|
|
|
$h .= '<h2 style="color:#c0392b">Vielen Dank für Ihren Mitgliedsantrag!</h2>';
|
|
$h .= '<h2 style="color:#c0392b">Vielen Dank für Ihren Mitgliedsantrag!</h2>';
|
|
|
$h .= '<p>Ihre Daten wurden erfolgreich übermittelt. Nachfolgend finden Sie eine Zusammenfassung.</p>';
|
|
$h .= '<p>Ihre Daten wurden erfolgreich übermittelt. Nachfolgend finden Sie eine Zusammenfassung.</p>';
|
|
|
|
|
+ if ($isMinorSubmission) {
|
|
|
|
|
+ $h .= '<p><strong>Hinweis für Minderjährige:</strong> '
|
|
|
|
|
+ . 'Das angehängte Formular ist auszudrucken, von Antragsteller/in und Erziehungsberechtigten zu unterschreiben '
|
|
|
|
|
+ . 'und persönlich einzureichen.</p>';
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
foreach ($steps as $step) {
|
|
foreach ($steps as $step) {
|
|
|
$h .= '<h3>' . $this->esc($step['title']) . '</h3>';
|
|
$h .= '<h3>' . $this->esc($step['title']) . '</h3>';
|
|
@@ -274,13 +296,17 @@ final class Mailer
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/** @param array<string, mixed> $submission */
|
|
/** @param array<string, mixed> $submission */
|
|
|
- private function renderApplicantText(array $submission): string
|
|
|
|
|
|
|
+ private function renderApplicantText(array $submission, bool $isMinorSubmission): string
|
|
|
{
|
|
{
|
|
|
$steps = $this->formatter->formatSteps($submission);
|
|
$steps = $this->formatter->formatSteps($submission);
|
|
|
$uploads = $this->formatter->formatUploads($submission);
|
|
$uploads = $this->formatter->formatUploads($submission);
|
|
|
|
|
|
|
|
$t = "Vielen Dank für Ihren Mitgliedsantrag!\n\n";
|
|
$t = "Vielen Dank für Ihren Mitgliedsantrag!\n\n";
|
|
|
$t .= "Ihre Daten wurden erfolgreich übermittelt. Nachfolgend finden Sie eine Zusammenfassung.\n\n";
|
|
$t .= "Ihre Daten wurden erfolgreich übermittelt. Nachfolgend finden Sie eine Zusammenfassung.\n\n";
|
|
|
|
|
+ if ($isMinorSubmission) {
|
|
|
|
|
+ $t .= "Hinweis für Minderjährige: Das angehängte Formular ist auszudrucken, von Antragsteller/in und "
|
|
|
|
|
+ . "Erziehungsberechtigten zu unterschreiben und persönlich einzureichen.\n\n";
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
foreach ($steps as $step) {
|
|
foreach ($steps as $step) {
|
|
|
$t .= strtoupper($step['title']) . "\n";
|
|
$t .= strtoupper($step['title']) . "\n";
|
|
@@ -321,6 +347,53 @@ final class Mailer
|
|
|
return htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
|
return htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private function renderMinorAdminNoticeHtml(): string
|
|
|
|
|
+ {
|
|
|
|
|
+ return '<div style="background:#fff3cd;border:1px solid #f0c36d;padding:10px 12px;margin:12px 0">'
|
|
|
|
|
+ . '<strong>Wichtiger Hinweis (Minderjaehrig):</strong> '
|
|
|
|
|
+ . 'Die Unterschrift eines Erziehungsberechtigten liegt digital noch nicht vor. '
|
|
|
|
|
+ . 'Bitte die Bearbeitung erst nach Eingang des handschriftlich unterschriebenen Formulars fortsetzen.'
|
|
|
|
|
+ . '</div>';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private function renderMinorAdminNoticeText(): string
|
|
|
|
|
+ {
|
|
|
|
|
+ return "WICHTIGER HINWEIS (MINDERJAEHRIG)\n"
|
|
|
|
|
+ . 'Die Unterschrift eines Erziehungsberechtigten liegt digital noch nicht vor. '
|
|
|
|
|
+ . 'Bitte die Bearbeitung erst nach Eingang des handschriftlich unterschriebenen Formulars fortsetzen.';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /** @param array<string, mixed> $submission */
|
|
|
|
|
+ private function isMinorSubmission(array $submission): bool
|
|
|
|
|
+ {
|
|
|
|
|
+ if (array_key_exists('is_minor_submission', $submission)) {
|
|
|
|
|
+ return (bool) $submission['is_minor_submission'];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $formData = (array) ($submission['form_data'] ?? []);
|
|
|
|
|
+ return $this->deriveIsMinorFromBirthdate((string) ($formData['geburtsdatum'] ?? ''));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private function deriveIsMinorFromBirthdate(string $birthdate): bool
|
|
|
|
|
+ {
|
|
|
|
|
+ $birthdate = trim($birthdate);
|
|
|
|
|
+ if ($birthdate === '') {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $date = \DateTimeImmutable::createFromFormat('!Y-m-d', $birthdate);
|
|
|
|
|
+ if (!$date || $date->format('Y-m-d') !== $birthdate) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $today = new \DateTimeImmutable('today');
|
|
|
|
|
+ if ($date > $today) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return $date->diff($today)->y < 18;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private function renderOtpText(string $code, int $ttlSeconds): string
|
|
private function renderOtpText(string $code, int $ttlSeconds): string
|
|
|
{
|
|
{
|
|
|
$configured = (string) ($this->mailConfig['otp']['text_template'] ?? '');
|
|
$configured = (string) ($this->mailConfig['otp']['text_template'] ?? '');
|