From 43ffed32bb47910342c9186ebe304272bf3ec719 Mon Sep 17 00:00:00 2001 From: Frank Cools Date: Mon, 6 Oct 2025 17:35:51 +0200 Subject: [PATCH] Improve debug message visibility during validation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Collect all debug messages in an array instead of showing them individually - Display all debug info in a single message with line breaks - Added checkmarks (✓) for success and X marks (✗) for failures - Messages now persist longer and are easier to read - All validation steps are now visible in one consolidated message --- declarationtva_view.php | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/declarationtva_view.php b/declarationtva_view.php index 72b4463..2c326d4 100644 --- a/declarationtva_view.php +++ b/declarationtva_view.php @@ -100,36 +100,46 @@ if ($action == 'export_pdf_detailed') { if ($action == 'validate' && $token) { // Validate the declaration - setEventMessages("Starting validation process...", null, 'mesgs'); + $debug_messages = array(); + $debug_messages[] = "Starting validation process..."; if ($declarationtva->validateDeclaration($id)) { - setEventMessages($langs->trans("DeclarationValidated"), null, 'mesgs'); + $debug_messages[] = "✓ Declaration validated successfully"; // Generate and save detailed PDF to Dolibarr documents - setEventMessages("Loading PDF generator...", null, 'mesgs'); + $debug_messages[] = "Loading PDF generator..."; require_once DOL_DOCUMENT_ROOT . '/custom/declarationtva/core/class/declarationtva_pdf.class.php'; $pdf_generator = new DeclarationTVA_PDF($db); - setEventMessages("Generating detailed PDF...", null, 'mesgs'); + $debug_messages[] = "Generating detailed PDF..."; $pdf_path = $pdf_generator->generateDetailedCA3PDF($id); if ($pdf_path && file_exists($pdf_path)) { - setEventMessages("PDF generated successfully: " . $pdf_path, null, 'mesgs'); + $debug_messages[] = "✓ PDF generated successfully: " . $pdf_path; // Save PDF to Dolibarr documents - setEventMessages("Saving PDF to documents...", null, 'mesgs'); + $debug_messages[] = "Saving PDF to documents..."; $save_result = $declarationtva->saveValidatedPDF($id, $pdf_path); if (!$save_result) { + $debug_messages[] = "✗ PDF save failed: " . $declarationtva->error; setEventMessages("Warning: Declaration validated but PDF save failed: " . $declarationtva->error, null, 'warnings'); } else { + $debug_messages[] = "✓ PDF generated and saved successfully: " . $pdf_path; setEventMessages("PDF generated and saved successfully: " . $pdf_path, null, 'mesgs'); } } else { + $debug_messages[] = "✗ PDF generation failed: " . $pdf_generator->error; + $debug_messages[] = "PDF path returned: " . ($pdf_path ? $pdf_path : 'NULL'); + $debug_messages[] = "File exists: " . ($pdf_path && file_exists($pdf_path) ? 'YES' : 'NO'); setEventMessages("Warning: Declaration validated but PDF generation failed: " . $pdf_generator->error, null, 'warnings'); - setEventMessages("PDF path returned: " . ($pdf_path ? $pdf_path : 'NULL'), null, 'warnings'); - setEventMessages("File exists: " . ($pdf_path && file_exists($pdf_path) ? 'YES' : 'NO'), null, 'warnings'); } + + // Show all debug messages in a single message + $full_debug = implode('
', $debug_messages); + setEventMessages("Validation Debug Info:
" . $full_debug, null, 'mesgs'); + } else { + $debug_messages[] = "✗ Declaration validation failed: " . $declarationtva->error; setEventMessages($langs->trans("ErrorValidatingDeclaration") . ": " . $declarationtva->error, null, 'errors'); } }