From 29f9462f47e03909919bfbed324b7ef4c054f510 Mon Sep 17 00:00:00 2001 From: Frank Cools Date: Mon, 6 Oct 2025 17:38:09 +0200 Subject: [PATCH] Add detailed debugging to hasValidatedDocument method - Added comprehensive error_log statements to track PDF detection - Logs declaration ID, number, directory paths, and search patterns - Shows all PDF files found in the directory - Will help identify why PDF detection is failing - Debug info will appear in PHP error logs --- core/class/declarationtva.class.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/core/class/declarationtva.class.php b/core/class/declarationtva.class.php index 24a8868..85e9084 100644 --- a/core/class/declarationtva.class.php +++ b/core/class/declarationtva.class.php @@ -1270,13 +1270,36 @@ class DeclarationTVA $pattern = $month_dir . 'CA3_' . $obj->declaration_number . '_*.pdf'; $files = glob($pattern); + // Debug: Log the search details + error_log("DeclarationTVA Debug - hasValidatedDocument:"); + error_log(" Declaration ID: " . $declaration_id); + error_log(" Declaration Number: " . $obj->declaration_number); + error_log(" Month Dir: " . $month_dir); + error_log(" Pattern 1: " . $pattern); + error_log(" Files found with pattern 1: " . count($files)); + if (!empty($files)) { + error_log(" First file: " . $files[0]); + } + // If no files found with the exact pattern, try a more flexible search if (empty($files)) { $pattern = $month_dir . 'CA3_*' . $obj->declaration_number . '*.pdf'; $files = glob($pattern); + error_log(" Pattern 2: " . $pattern); + error_log(" Files found with pattern 2: " . count($files)); + if (!empty($files)) { + error_log(" First file: " . $files[0]); + } } - return !empty($files) && file_exists($files[0]); + // Also try to list all files in the directory for debugging + $all_files = glob($month_dir . '*.pdf'); + error_log(" All PDF files in directory: " . implode(', ', $all_files)); + + $result = !empty($files) && file_exists($files[0]); + error_log(" Final result: " . ($result ? 'TRUE' : 'FALSE')); + + return $result; } /**