From 16a6198dff81db26ab07adf5e069a8be97b0e1a1 Mon Sep 17 00:00:00 2001 From: Frank Cools Date: Wed, 8 Oct 2025 14:10:29 +0200 Subject: [PATCH] Restore export to use fillable template, validation uses improved layout --- core/class/declarationtva_pdf.class.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/core/class/declarationtva_pdf.class.php b/core/class/declarationtva_pdf.class.php index d67c828..c5aa9e0 100644 --- a/core/class/declarationtva_pdf.class.php +++ b/core/class/declarationtva_pdf.class.php @@ -190,18 +190,20 @@ class DeclarationTVA_PDF // Debug logging error_log("generateCompleteCA3PDF: Status=" . $status); - // Both export and validation should use the same logic - error_log("generateCompleteCA3PDF: Status is " . $status . ", checking for fillable template"); - $template_file = $this->getTemplatePath(); - if ($template_file && file_exists($template_file) && $this->isFillablePDF($template_file)) { - // Use fillable PDF template for both export and validation - error_log("generateCompleteCA3PDF: Using fillable PDF template"); - $result = $this->fillFillablePDF($template_file, $output_path, $declaration, $ca3_data, $mysoc); - return $result ? $output_path : false; + // For export, check if we have a custom fillable template + if ($status === 'export') { + error_log("generateCompleteCA3PDF: Status is export, checking for fillable template"); + $template_file = $this->getTemplatePath(); + if ($template_file && file_exists($template_file) && $this->isFillablePDF($template_file)) { + // Use fillable PDF template for export + error_log("generateCompleteCA3PDF: Using fillable PDF template for export"); + $result = $this->fillFillablePDF($template_file, $output_path, $declaration, $ca3_data, $mysoc); + return $result ? $output_path : false; + } } - // When no fillable template exists, use improved layout for both - error_log("generateCompleteCA3PDF: No fillable template found, using improved layout"); + // For validation or when no fillable template exists, use improved layout + error_log("generateCompleteCA3PDF: Using improved layout for validation"); $result = $this->generateImprovedPDF($output_path, $declaration, $ca3_data, $mysoc); error_log("generateCompleteCA3PDF: generateImprovedPDF result=" . ($result ? 'true' : 'false')); return $result ? $output_path : false; @@ -1394,8 +1396,7 @@ class DeclarationTVA_PDF // Create a temporary detailed PDF $temp_detailed_path = tempnam(sys_get_temp_dir(), 'ca3_detailed_') . '.pdf'; - // Use the improved layout for detailed pages - $result = $this->generateImprovedPDF($temp_detailed_path, $declaration, $ca3_data, $mysoc); + $result = $this->generateDetailedPDF($temp_detailed_path, $declaration, $ca3_data, $mysoc); if (!$result) { return false;