|
@@ -1517,14 +1517,7 @@ class Report extends Component
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $separatorPageCount = 0;
|
|
|
|
|
- if ($hasPdfAttachments) {
|
|
|
|
|
- $separatorPageCount = 1;
|
|
|
|
|
- Log::info("Separator page count: {$separatorPageCount}");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- $totalAttachmentPagesWithSeparator = $totalAttachmentPages + $separatorPageCount;
|
|
|
|
|
- Log::info("Total attachment pages (including separator): {$totalAttachmentPagesWithSeparator}");
|
|
|
|
|
|
|
+ Log::info("Total attachment pages: {$totalAttachmentPages}");
|
|
|
|
|
|
|
|
$data['total_pages'] = 0;
|
|
$data['total_pages'] = 0;
|
|
|
$initialPdf = Pdf::loadView('pdf.verbale', array('data' => $data));
|
|
$initialPdf = Pdf::loadView('pdf.verbale', array('data' => $data));
|
|
@@ -1532,9 +1525,9 @@ class Report extends Component
|
|
|
$mainPageCount = $initialPdf->getDomPDF()->getCanvas()->get_page_count();
|
|
$mainPageCount = $initialPdf->getDomPDF()->getCanvas()->get_page_count();
|
|
|
Log::info("Main PDF has {$mainPageCount} pages");
|
|
Log::info("Main PDF has {$mainPageCount} pages");
|
|
|
|
|
|
|
|
- $totalPages = $mainPageCount + $totalAttachmentPages + $separatorPageCount;
|
|
|
|
|
- Log::info("Total pages breakdown: Main={$mainPageCount}, Attachments={$totalAttachmentPages}, Separator={$separatorPageCount}");
|
|
|
|
|
- Log::info("Total pages (main + attachments + separator): {$totalPages}");
|
|
|
|
|
|
|
+ $totalPages = $mainPageCount + $totalAttachmentPages;
|
|
|
|
|
+ Log::info("Total pages breakdown: Main={$mainPageCount}, Attachments={$totalAttachmentPages}");
|
|
|
|
|
+ Log::info("Total pages (main + attachments): {$totalPages}");
|
|
|
|
|
|
|
|
$data['total_pages'] = $totalPages;
|
|
$data['total_pages'] = $totalPages;
|
|
|
$pdf = Pdf::loadView('pdf.verbale', array('data' => $data));
|
|
$pdf = Pdf::loadView('pdf.verbale', array('data' => $data));
|
|
@@ -1554,15 +1547,6 @@ class Report extends Component
|
|
|
|
|
|
|
|
$pdfFiles = [$tempMainPdf];
|
|
$pdfFiles = [$tempMainPdf];
|
|
|
|
|
|
|
|
- try {
|
|
|
|
|
- $separatorPath = $this->createSeparatorPage($tempDir, "DOCUMENTI ALLEGATI");
|
|
|
|
|
- if ($separatorPath) {
|
|
|
|
|
- $pdfFiles[] = $separatorPath;
|
|
|
|
|
- }
|
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
|
- Log::warning("Failed to create separator page: " . $e->getMessage());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
foreach ($pdfAttachments as $attachmentPath) {
|
|
foreach ($pdfAttachments as $attachmentPath) {
|
|
|
if (file_exists($attachmentPath)) {
|
|
if (file_exists($attachmentPath)) {
|
|
|
$pdfFiles[] = $attachmentPath;
|
|
$pdfFiles[] = $attachmentPath;
|
|
@@ -1584,9 +1568,6 @@ class Report extends Component
|
|
|
|
|
|
|
|
@unlink($tempMainPdf);
|
|
@unlink($tempMainPdf);
|
|
|
@unlink($outputPath);
|
|
@unlink($outputPath);
|
|
|
- if (isset($separatorPath)) {
|
|
|
|
|
- @unlink($separatorPath);
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
return response($pdfContent)
|
|
return response($pdfContent)
|
|
|
->header('Content-Type', 'application/pdf')
|
|
->header('Content-Type', 'application/pdf')
|
|
@@ -1594,9 +1575,6 @@ class Report extends Component
|
|
|
} else {
|
|
} else {
|
|
|
Log::warning("PDF merge failed, falling back to main PDF only");
|
|
Log::warning("PDF merge failed, falling back to main PDF only");
|
|
|
@unlink($tempMainPdf);
|
|
@unlink($tempMainPdf);
|
|
|
- if (isset($separatorPath)) {
|
|
|
|
|
- @unlink($separatorPath);
|
|
|
|
|
- }
|
|
|
|
|
return $pdf->stream($pdfName);
|
|
return $pdf->stream($pdfName);
|
|
|
}
|
|
}
|
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
@@ -1661,59 +1639,7 @@ class Report extends Component
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private function createSeparatorPage($tempDir, $title)
|
|
|
|
|
- {
|
|
|
|
|
- try {
|
|
|
|
|
- Log::info("Creating separator page with title: $title");
|
|
|
|
|
- $separatorPath = $tempDir . '/separator_' . uniqid() . '.pdf';
|
|
|
|
|
- Log::info("Separator path: $separatorPath");
|
|
|
|
|
-
|
|
|
|
|
- $html = '
|
|
|
|
|
- <!DOCTYPE html>
|
|
|
|
|
- <html>
|
|
|
|
|
- <head>
|
|
|
|
|
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
|
|
|
|
- <style>
|
|
|
|
|
- body {
|
|
|
|
|
- font-family: Helvetica, sans-serif;
|
|
|
|
|
- color: rgb(80, 80, 80);
|
|
|
|
|
- text-align: center;
|
|
|
|
|
- }
|
|
|
|
|
- .separator-title {
|
|
|
|
|
- margin-top: 300px;
|
|
|
|
|
- font-size: 24px;
|
|
|
|
|
- font-weight: bold;
|
|
|
|
|
- text-transform: uppercase;
|
|
|
|
|
- }
|
|
|
|
|
- </style>
|
|
|
|
|
- </head>
|
|
|
|
|
- <body>
|
|
|
|
|
- <div class="separator-title">' . $title . '</div>
|
|
|
|
|
- </body>
|
|
|
|
|
- </html>
|
|
|
|
|
- ';
|
|
|
|
|
-
|
|
|
|
|
- $separatorPdf = Pdf::loadHTML($html);
|
|
|
|
|
-
|
|
|
|
|
- Log::info("Generating separator PDF");
|
|
|
|
|
- $separatorContent = $separatorPdf->output();
|
|
|
|
|
- $bytesWritten = file_put_contents($separatorPath, $separatorContent);
|
|
|
|
|
-
|
|
|
|
|
- if ($bytesWritten === false) {
|
|
|
|
|
- Log::error("Failed to write separator PDF to file");
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- Log::info("Separator PDF created successfully: $bytesWritten bytes written");
|
|
|
|
|
- Log::info("Separator file exists: " . (file_exists($separatorPath) ? 'Yes' : 'No'));
|
|
|
|
|
|
|
|
|
|
- return $separatorPath;
|
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
|
- Log::error("Failed to create separator page: " . $e->getMessage());
|
|
|
|
|
- Log::error("Stack trace: " . $e->getTraceAsString());
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
public function updated($property, $value)
|
|
public function updated($property, $value)
|
|
|
{
|
|
{
|
|
|
if ($property === 'verificatosi_in_data' && !preg_match('/^\d{4}-\d{2}-\d{2}$/', $value)) {
|
|
if ($property === 'verificatosi_in_data' && !preg_match('/^\d{4}-\d{2}-\d{2}$/', $value)) {
|