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');
}
}