From 2fefe384b78d0873de2edbb6d1f1cdf0a65963e6 Mon Sep 17 00:00:00 2001 From: Frank Cools Date: Wed, 8 Oct 2025 14:58:13 +0200 Subject: [PATCH] Remove debug messages from PDF generation and validation --- core/class/declarationtva.class.php | 13 +------------ core/class/declarationtva_pdf.class.php | 25 ++++++++----------------- 2 files changed, 9 insertions(+), 29 deletions(-) diff --git a/core/class/declarationtva.class.php b/core/class/declarationtva.class.php index c4ed6f5..415bf74 100644 --- a/core/class/declarationtva.class.php +++ b/core/class/declarationtva.class.php @@ -1260,28 +1260,17 @@ class DeclarationTVA // Check if PDF file exists in the VAT declarations validated directory $vat_declarations_dir = DOL_DATA_ROOT . '/declarationtva/validated/'; - // Debug: Log the search - error_log("hasValidatedDocument: Searching in " . $vat_declarations_dir . " for declaration " . $obj->declaration_number); - // Look for PDF files with the declaration ID (not declaration number) $pattern = $vat_declarations_dir . 'CA3_' . $declaration_id . '_*.pdf'; $files = glob($pattern); - // Debug: Log the pattern and results - error_log("hasValidatedDocument: Pattern: " . $pattern); - error_log("hasValidatedDocument: Files found: " . print_r($files, true)); - // If no files found with the exact pattern, try a more flexible search if (empty($files)) { $pattern = $vat_declarations_dir . 'CA3_*' . $declaration_id . '*.pdf'; $files = glob($pattern); - error_log("hasValidatedDocument: Flexible pattern: " . $pattern); - error_log("hasValidatedDocument: Flexible files found: " . print_r($files, true)); } - $result = !empty($files) && file_exists($files[0]); - error_log("hasValidatedDocument: Final result: " . ($result ? 'true' : 'false')); - return $result; + return !empty($files) && file_exists($files[0]); } /** diff --git a/core/class/declarationtva_pdf.class.php b/core/class/declarationtva_pdf.class.php index 7a1cd7c..9bf6b48 100644 --- a/core/class/declarationtva_pdf.class.php +++ b/core/class/declarationtva_pdf.class.php @@ -336,25 +336,16 @@ class DeclarationTVA_PDF // First generate the PDF using the same method as export $temp_pdf = $this->generateCA3PDF($declaration_id, $outputlangs); - if (!$temp_pdf) { - $this->error = 'Failed to generate temporary PDF: ' . $this->error; - return false; + if ($temp_pdf && file_exists($temp_pdf)) { + // Copy the generated PDF to the validation location + if (copy($temp_pdf, $filepath)) { + // Clean up the temporary file + unlink($temp_pdf); + return $filepath; + } } - if (!file_exists($temp_pdf)) { - $this->error = 'Temporary PDF file does not exist: ' . $temp_pdf; - return false; - } - - // Copy the generated PDF to the validation location - if (copy($temp_pdf, $filepath)) { - // Clean up the temporary file - unlink($temp_pdf); - return $filepath; - } else { - $this->error = 'Failed to copy PDF to validation location: ' . $filepath; - return false; - } + return false; } /**