|
@@ -22,6 +22,8 @@ final class PdfGenerator
|
|
|
private SubmissionFormatter $formatter;
|
|
private SubmissionFormatter $formatter;
|
|
|
private FormSchema $schema;
|
|
private FormSchema $schema;
|
|
|
private string $uploadBasePath;
|
|
private string $uploadBasePath;
|
|
|
|
|
+ /** @var array<string, mixed> */
|
|
|
|
|
+ private array $pdfTexts;
|
|
|
|
|
|
|
|
public function __construct(SubmissionFormatter $formatter, FormSchema $schema)
|
|
public function __construct(SubmissionFormatter $formatter, FormSchema $schema)
|
|
|
{
|
|
{
|
|
@@ -30,6 +32,7 @@ final class PdfGenerator
|
|
|
|
|
|
|
|
$app = Bootstrap::config('app');
|
|
$app = Bootstrap::config('app');
|
|
|
$this->uploadBasePath = rtrim((string) ($app['storage']['uploads'] ?? ''), '/');
|
|
$this->uploadBasePath = rtrim((string) ($app['storage']['uploads'] ?? ''), '/');
|
|
|
|
|
+ $this->pdfTexts = is_array($app['pdf_texts'] ?? null) ? $app['pdf_texts'] : [];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/** @param array<string, mixed> $submission */
|
|
/** @param array<string, mixed> $submission */
|
|
@@ -37,14 +40,14 @@ final class PdfGenerator
|
|
|
{
|
|
{
|
|
|
try {
|
|
try {
|
|
|
$pdf = $this->createPdf();
|
|
$pdf = $this->createPdf();
|
|
|
- $pdf->SetTitle($this->enc('Mitgliedsantrag'), true);
|
|
|
|
|
|
|
+ $pdf->SetTitle($this->enc($this->pdfText('form_data.title')), true);
|
|
|
$pdf->AddPage();
|
|
$pdf->AddPage();
|
|
|
|
|
|
|
|
$pdf->SetFont('Helvetica', 'B', 16);
|
|
$pdf->SetFont('Helvetica', 'B', 16);
|
|
|
- $pdf->Cell(0, 10, $this->enc('Mitgliedsantrag'), 0, 1);
|
|
|
|
|
|
|
+ $pdf->Cell(0, 10, $this->enc($this->pdfText('form_data.title')), 0, 1);
|
|
|
$pdf->SetFont('Helvetica', '', 9);
|
|
$pdf->SetFont('Helvetica', '', 9);
|
|
|
- $pdf->Cell(0, 5, $this->enc('Eingereicht: ' . $this->formatTimestamp($submission)), 0, 1);
|
|
|
|
|
- $pdf->Cell(0, 5, $this->enc('E-Mail: ' . (string) ($submission['email'] ?? '')), 0, 1);
|
|
|
|
|
|
|
+ $pdf->Cell(0, 5, $this->enc($this->pdfText('common.submitted_prefix') . $this->formatTimestamp($submission)), 0, 1);
|
|
|
|
|
+ $pdf->Cell(0, 5, $this->enc($this->pdfText('common.email_prefix') . (string) ($submission['email'] ?? '')), 0, 1);
|
|
|
$pdf->Ln(4);
|
|
$pdf->Ln(4);
|
|
|
|
|
|
|
|
$this->renderPortrait($pdf, $submission);
|
|
$this->renderPortrait($pdf, $submission);
|
|
@@ -58,7 +61,7 @@ final class PdfGenerator
|
|
|
if ($uploads !== []) {
|
|
if ($uploads !== []) {
|
|
|
$this->ensureSpace($pdf, 20);
|
|
$this->ensureSpace($pdf, 20);
|
|
|
$pdf->SetFont('Helvetica', 'B', 12);
|
|
$pdf->SetFont('Helvetica', 'B', 12);
|
|
|
- $pdf->Cell(0, 8, $this->enc('Hochgeladene Dateien'), 0, 1);
|
|
|
|
|
|
|
+ $pdf->Cell(0, 8, $this->enc($this->pdfText('common.uploads_heading')), 0, 1);
|
|
|
$pdf->SetFont('Helvetica', '', 10);
|
|
$pdf->SetFont('Helvetica', '', 10);
|
|
|
foreach ($uploads as $group) {
|
|
foreach ($uploads as $group) {
|
|
|
$pdf->SetFont('Helvetica', 'B', 10);
|
|
$pdf->SetFont('Helvetica', 'B', 10);
|
|
@@ -71,7 +74,7 @@ final class PdfGenerator
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $tmpPath = $this->tempPath('antragsdaten');
|
|
|
|
|
|
|
+ $tmpPath = $this->tempPath($this->pdfText('form_data.filename_prefix', 'antragsdaten'));
|
|
|
$pdf->Output('F', $tmpPath);
|
|
$pdf->Output('F', $tmpPath);
|
|
|
return $tmpPath;
|
|
return $tmpPath;
|
|
|
} catch (\Throwable $e) {
|
|
} catch (\Throwable $e) {
|
|
@@ -94,21 +97,21 @@ final class PdfGenerator
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
$pdf = $this->createPdf();
|
|
$pdf = $this->createPdf();
|
|
|
- $pdf->SetTitle($this->enc('Einverstaendniserklaerung Minderjaehrige'), true);
|
|
|
|
|
|
|
+ $pdf->SetTitle($this->enc($this->pdfText('minor_signature.document_title')), true);
|
|
|
$pdf->AddPage();
|
|
$pdf->AddPage();
|
|
|
|
|
|
|
|
$pdf->SetFont('Helvetica', 'B', 15);
|
|
$pdf->SetFont('Helvetica', 'B', 15);
|
|
|
- $pdf->Cell(0, 10, $this->enc('Einverstaendniserklaerung fuer Minderjaehrige'), 0, 1);
|
|
|
|
|
|
|
+ $pdf->Cell(0, 10, $this->enc($this->pdfText('minor_signature.heading')), 0, 1);
|
|
|
$pdf->SetFont('Helvetica', '', 9);
|
|
$pdf->SetFont('Helvetica', '', 9);
|
|
|
- $pdf->Cell(0, 5, $this->enc('Eingereicht: ' . $this->formatTimestamp($submission)), 0, 1);
|
|
|
|
|
- $pdf->Cell(0, 5, $this->enc('E-Mail: ' . (string) ($submission['email'] ?? '')), 0, 1);
|
|
|
|
|
|
|
+ $pdf->Cell(0, 5, $this->enc($this->pdfText('common.submitted_prefix') . $this->formatTimestamp($submission)), 0, 1);
|
|
|
|
|
+ $pdf->Cell(0, 5, $this->enc($this->pdfText('common.email_prefix') . (string) ($submission['email'] ?? '')), 0, 1);
|
|
|
$pdf->Ln(3);
|
|
$pdf->Ln(3);
|
|
|
|
|
|
|
|
$pdf->SetFont('Helvetica', '', 10);
|
|
$pdf->SetFont('Helvetica', '', 10);
|
|
|
$pdf->MultiCell(
|
|
$pdf->MultiCell(
|
|
|
0,
|
|
0,
|
|
|
5,
|
|
5,
|
|
|
- $this->enc('Dieses Dokument ist auszudrucken, handschriftlich zu unterschreiben und persoenlich einzureichen.')
|
|
|
|
|
|
|
+ $this->enc($this->pdfText('minor_signature.instruction'))
|
|
|
);
|
|
);
|
|
|
$pdf->Ln(2);
|
|
$pdf->Ln(2);
|
|
|
|
|
|
|
@@ -121,7 +124,7 @@ final class PdfGenerator
|
|
|
if ($uploads !== []) {
|
|
if ($uploads !== []) {
|
|
|
$this->ensureSpace($pdf, 20);
|
|
$this->ensureSpace($pdf, 20);
|
|
|
$pdf->SetFont('Helvetica', 'B', 12);
|
|
$pdf->SetFont('Helvetica', 'B', 12);
|
|
|
- $pdf->Cell(0, 8, $this->enc('Hochgeladene Dateien'), 0, 1);
|
|
|
|
|
|
|
+ $pdf->Cell(0, 8, $this->enc($this->pdfText('common.uploads_heading')), 0, 1);
|
|
|
$pdf->SetFont('Helvetica', '', 10);
|
|
$pdf->SetFont('Helvetica', '', 10);
|
|
|
foreach ($uploads as $group) {
|
|
foreach ($uploads as $group) {
|
|
|
$pdf->SetFont('Helvetica', 'B', 10);
|
|
$pdf->SetFont('Helvetica', 'B', 10);
|
|
@@ -136,11 +139,11 @@ final class PdfGenerator
|
|
|
|
|
|
|
|
$this->renderMinorSignatureSection($pdf);
|
|
$this->renderMinorSignatureSection($pdf);
|
|
|
|
|
|
|
|
- $tmpPath = $this->tempPath('minderjaehrige_einverstaendnis');
|
|
|
|
|
|
|
+ $tmpPath = $this->tempPath($this->pdfText('minor_signature.filename_prefix', 'minderjaehrige_einverstaendnis'));
|
|
|
$pdf->Output('F', $tmpPath);
|
|
$pdf->Output('F', $tmpPath);
|
|
|
return $tmpPath;
|
|
return $tmpPath;
|
|
|
} catch (\Throwable $e) {
|
|
} catch (\Throwable $e) {
|
|
|
- Bootstrap::log('mail', 'PDF-Erstellung (Minderjaehrigen-Erklaerung) fehlgeschlagen: ' . $e->getMessage());
|
|
|
|
|
|
|
+ Bootstrap::log('mail', 'PDF-Erstellung (Minderjährigen-Erklärung) fehlgeschlagen: ' . $e->getMessage());
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -160,7 +163,7 @@ final class PdfGenerator
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
$pdf = $this->createPdf();
|
|
$pdf = $this->createPdf();
|
|
|
- $pdf->SetTitle($this->enc('Anlagen zum Mitgliedsantrag'), true);
|
|
|
|
|
|
|
+ $pdf->SetTitle($this->enc($this->pdfText('attachments.title')), true);
|
|
|
|
|
|
|
|
foreach ($images as $img) {
|
|
foreach ($images as $img) {
|
|
|
$pdf->AddPage();
|
|
$pdf->AddPage();
|
|
@@ -173,11 +176,11 @@ final class PdfGenerator
|
|
|
$this->embedImage($pdf, $imgPath);
|
|
$this->embedImage($pdf, $imgPath);
|
|
|
} else {
|
|
} else {
|
|
|
$pdf->SetFont('Helvetica', '', 10);
|
|
$pdf->SetFont('Helvetica', '', 10);
|
|
|
- $pdf->Cell(0, 10, $this->enc('[Bild konnte nicht geladen werden]'), 0, 1);
|
|
|
|
|
|
|
+ $pdf->Cell(0, 10, $this->enc($this->pdfText('common.missing_image')), 0, 1);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $tmpPath = $this->tempPath('anlagen');
|
|
|
|
|
|
|
+ $tmpPath = $this->tempPath($this->pdfText('attachments.filename_prefix', 'anlagen'));
|
|
|
$pdf->Output('F', $tmpPath);
|
|
$pdf->Output('F', $tmpPath);
|
|
|
return $tmpPath;
|
|
return $tmpPath;
|
|
|
} catch (\Throwable $e) {
|
|
} catch (\Throwable $e) {
|
|
@@ -310,12 +313,12 @@ final class PdfGenerator
|
|
|
$this->ensureSpace($pdf, 55);
|
|
$this->ensureSpace($pdf, 55);
|
|
|
$pdf->Ln(6);
|
|
$pdf->Ln(6);
|
|
|
$pdf->SetFont('Helvetica', 'B', 11);
|
|
$pdf->SetFont('Helvetica', 'B', 11);
|
|
|
- $pdf->Cell(0, 8, $this->enc('Unterschriften'), 0, 1);
|
|
|
|
|
|
|
+ $pdf->Cell(0, 8, $this->enc($this->pdfText('minor_signature.signature_heading')), 0, 1);
|
|
|
$pdf->SetFont('Helvetica', '', 10);
|
|
$pdf->SetFont('Helvetica', '', 10);
|
|
|
$pdf->MultiCell(
|
|
$pdf->MultiCell(
|
|
|
0,
|
|
0,
|
|
|
5,
|
|
5,
|
|
|
- $this->enc('Hiermit bestaetigen Antragsteller/in und Erziehungsberechtigte/r die Richtigkeit der oben aufgefuehrten Angaben.')
|
|
|
|
|
|
|
+ $this->enc($this->pdfText('minor_signature.signature_confirmation'))
|
|
|
);
|
|
);
|
|
|
$pdf->Ln(10);
|
|
$pdf->Ln(10);
|
|
|
|
|
|
|
@@ -330,9 +333,9 @@ final class PdfGenerator
|
|
|
$pdf->SetY($lineY + 2);
|
|
$pdf->SetY($lineY + 2);
|
|
|
$pdf->SetFont('Helvetica', '', 9);
|
|
$pdf->SetFont('Helvetica', '', 9);
|
|
|
$pdf->SetX($leftX);
|
|
$pdf->SetX($leftX);
|
|
|
- $pdf->Cell($lineWidth, 5, $this->enc('Antragsteller/in (minderjaehrig)'), 0, 0);
|
|
|
|
|
|
|
+ $pdf->Cell($lineWidth, 5, $this->enc($this->pdfText('minor_signature.signature_minor_label')), 0, 0);
|
|
|
$pdf->SetX($rightX);
|
|
$pdf->SetX($rightX);
|
|
|
- $pdf->Cell($lineWidth, 5, $this->enc('Erziehungsberechtigte/r (Eltern)'), 0, 1);
|
|
|
|
|
|
|
+ $pdf->Cell($lineWidth, 5, $this->enc($this->pdfText('minor_signature.signature_guardian_label')), 0, 1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private function embedImage(\FPDF $pdf, string $path): void
|
|
private function embedImage(\FPDF $pdf, string $path): void
|
|
@@ -486,8 +489,8 @@ final class PdfGenerator
|
|
|
$pdf = new \FPDF('P', 'mm', 'A4');
|
|
$pdf = new \FPDF('P', 'mm', 'A4');
|
|
|
$pdf->SetAutoPageBreak(true, 20);
|
|
$pdf->SetAutoPageBreak(true, 20);
|
|
|
$pdf->SetMargins(15, 15, 15);
|
|
$pdf->SetMargins(15, 15, 15);
|
|
|
- $pdf->SetCreator($this->enc('Feuerwehr Freising - Mitgliedsantrag'), true);
|
|
|
|
|
- $pdf->SetAuthor($this->enc('Feuerwehr Freising'), true);
|
|
|
|
|
|
|
+ $pdf->SetCreator($this->enc($this->pdfText('metadata.creator')), true);
|
|
|
|
|
+ $pdf->SetAuthor($this->enc($this->pdfText('metadata.author')), true);
|
|
|
return $pdf;
|
|
return $pdf;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -504,6 +507,24 @@ final class PdfGenerator
|
|
|
return sys_get_temp_dir() . '/antrag_' . $prefix . '_' . bin2hex(random_bytes(8)) . '.pdf';
|
|
return sys_get_temp_dir() . '/antrag_' . $prefix . '_' . bin2hex(random_bytes(8)) . '.pdf';
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private function pdfText(string $path, string $fallback = ''): string
|
|
|
|
|
+ {
|
|
|
|
|
+ $value = $this->pdfTexts;
|
|
|
|
|
+ foreach (explode('.', $path) as $segment) {
|
|
|
|
|
+ if (!is_array($value) || !array_key_exists($segment, $value)) {
|
|
|
|
|
+ return $fallback;
|
|
|
|
|
+ }
|
|
|
|
|
+ $value = $value[$segment];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!is_string($value)) {
|
|
|
|
|
+ return $fallback;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $text = trim($value);
|
|
|
|
|
+ return $text !== '' ? $text : $fallback;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Encode UTF-8 to Windows-1252 for FPDF's built-in fonts.
|
|
* Encode UTF-8 to Windows-1252 for FPDF's built-in fonts.
|
|
|
* Transliterates characters outside the target charset.
|
|
* Transliterates characters outside the target charset.
|