Add detailed debugging for PDF generation during validation
- Added step-by-step debug messages to track validation process - Added file existence verification in generateDetailedCA3PDF - Added detailed error reporting for PDF generation failures - Will help identify exactly where PDF generation is failing - Debug messages will show: validation start, PDF generator load, PDF generation, file existence check
This commit is contained in:
parent
7a3cfd1237
commit
943f5e6659
@ -205,8 +205,15 @@ class DeclarationTVA_PDF
|
||||
$result = $this->generateDetailedPDF($filepath, $declaration, $ca3_data, $company);
|
||||
|
||||
if ($result) {
|
||||
// Verify file was actually created
|
||||
if (file_exists($filepath)) {
|
||||
return $filepath;
|
||||
} else {
|
||||
$this->error = "PDF file was not created at expected path: " . $filepath;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$this->error = "PDF generation failed: " . $this->error;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,16 +100,24 @@ if ($action == 'export_pdf_detailed') {
|
||||
|
||||
if ($action == 'validate' && $token) {
|
||||
// Validate the declaration
|
||||
setEventMessages("Starting validation process...", null, 'mesgs');
|
||||
|
||||
if ($declarationtva->validateDeclaration($id)) {
|
||||
setEventMessages($langs->trans("DeclarationValidated"), null, 'mesgs');
|
||||
|
||||
// Generate and save detailed PDF to Dolibarr documents
|
||||
setEventMessages("Loading PDF generator...", null, 'mesgs');
|
||||
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');
|
||||
$pdf_path = $pdf_generator->generateDetailedCA3PDF($id);
|
||||
|
||||
if ($pdf_path && file_exists($pdf_path)) {
|
||||
setEventMessages("PDF generated successfully: " . $pdf_path, null, 'mesgs');
|
||||
|
||||
// Save PDF to Dolibarr documents
|
||||
setEventMessages("Saving PDF to documents...", null, 'mesgs');
|
||||
$save_result = $declarationtva->saveValidatedPDF($id, $pdf_path);
|
||||
if (!$save_result) {
|
||||
setEventMessages("Warning: Declaration validated but PDF save failed: " . $declarationtva->error, null, 'warnings');
|
||||
@ -118,6 +126,8 @@ if ($action == 'validate' && $token) {
|
||||
}
|
||||
} else {
|
||||
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');
|
||||
}
|
||||
} else {
|
||||
setEventMessages($langs->trans("ErrorValidatingDeclaration") . ": " . $declarationtva->error, null, 'errors');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user