From b90d5e9199bd867e757e4238b57d68b8a12082d2 Mon Sep 17 00:00:00 2001 From: Frank Cools Date: Mon, 6 Oct 2025 17:37:09 +0200 Subject: [PATCH] Fix PDF file pattern matching in document detection - Updated hasValidatedDocument() to use flexible file pattern matching - Updated getValidatedPDFPath() with same flexible pattern - First tries exact pattern: CA3_[declaration_number]_*.pdf - Falls back to flexible pattern: CA3_*[declaration_number]*.pdf - Should now detect PDFs with complex filenames like CA3_CA3-2025-05-20251002184011_2025-10-06.pdf - Declaration list should now show green PDF icons for validated declarations --- core/class/declarationtva.class.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/class/declarationtva.class.php b/core/class/declarationtva.class.php index 6dd1596..24a8868 100644 --- a/core/class/declarationtva.class.php +++ b/core/class/declarationtva.class.php @@ -1270,6 +1270,12 @@ class DeclarationTVA $pattern = $month_dir . 'CA3_' . $obj->declaration_number . '_*.pdf'; $files = glob($pattern); + // 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); + } + return !empty($files) && file_exists($files[0]); } @@ -1306,6 +1312,12 @@ class DeclarationTVA $pattern = $month_dir . 'CA3_' . $obj->declaration_number . '_*.pdf'; $files = glob($pattern); + // 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); + } + if (!empty($files) && file_exists($files[0])) { return $files[0]; }