Improve debug message visibility during validation

- 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
This commit is contained in:
Frank Cools 2025-10-06 17:35:51 +02:00
parent 943f5e6659
commit 43ffed32bb

View File

@ -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('<br>', $debug_messages);
setEventMessages("Validation Debug Info:<br>" . $full_debug, null, 'mesgs');
} else {
$debug_messages[] = "✗ Declaration validation failed: " . $declarationtva->error;
setEventMessages($langs->trans("ErrorValidatingDeclaration") . ": " . $declarationtva->error, null, 'errors');
}
}