Simplify: Both export and validation use the exact same PDF generation method

This commit is contained in:
Frank Cools 2025-10-08 14:14:05 +02:00
parent 16a6198dff
commit bc0b23441f

View File

@ -187,25 +187,17 @@ class DeclarationTVA_PDF
// Get company information from Dolibarr's company configuration
global $mysoc;
// Debug logging
error_log("generateCompleteCA3PDF: Status=" . $status);
// For export, check if we have a custom fillable template
if ($status === 'export') {
error_log("generateCompleteCA3PDF: Status is export, checking for fillable template");
// Both export and validation use the EXACT SAME method
// Check if we have a custom 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");
// Use fillable PDF template (same for both export and validation)
$result = $this->fillFillablePDF($template_file, $output_path, $declaration, $ca3_data, $mysoc);
return $result ? $output_path : false;
}
}
// For validation or when no fillable template exists, use improved layout
error_log("generateCompleteCA3PDF: Using improved layout for validation");
// When no fillable template exists, use improved layout (same for both)
$result = $this->generateImprovedPDF($output_path, $declaration, $ca3_data, $mysoc);
error_log("generateCompleteCA3PDF: generateImprovedPDF result=" . ($result ? 'true' : 'false'));
return $result ? $output_path : false;
}
@ -349,16 +341,8 @@ class DeclarationTVA_PDF
$filepath = $month_dir . $filename;
// Debug logging
error_log("generateDetailedCA3PDF: Calling generateCompleteCA3PDF with status='validation'");
error_log("generateDetailedCA3PDF: Output path=" . $filepath);
// Use the new unified method for validation
$result = $this->generateCompleteCA3PDF($declaration_id, $filepath, 'validation', $outputlangs);
error_log("generateDetailedCA3PDF: Result=" . ($result ? $result : 'false'));
return $result;
// Use the same method as export
return $this->generateCompleteCA3PDF($declaration_id, $filepath, 'validation', $outputlangs);
}
/**