Remove debug messages from PDF generation and validation
This commit is contained in:
parent
9aeb09cc5c
commit
2fefe384b7
@ -1260,28 +1260,17 @@ class DeclarationTVA
|
|||||||
// Check if PDF file exists in the VAT declarations validated directory
|
// Check if PDF file exists in the VAT declarations validated directory
|
||||||
$vat_declarations_dir = DOL_DATA_ROOT . '/declarationtva/validated/';
|
$vat_declarations_dir = DOL_DATA_ROOT . '/declarationtva/validated/';
|
||||||
|
|
||||||
// Debug: Log the search
|
|
||||||
error_log("hasValidatedDocument: Searching in " . $vat_declarations_dir . " for declaration " . $obj->declaration_number);
|
|
||||||
|
|
||||||
// Look for PDF files with the declaration ID (not declaration number)
|
// Look for PDF files with the declaration ID (not declaration number)
|
||||||
$pattern = $vat_declarations_dir . 'CA3_' . $declaration_id . '_*.pdf';
|
$pattern = $vat_declarations_dir . 'CA3_' . $declaration_id . '_*.pdf';
|
||||||
$files = glob($pattern);
|
$files = glob($pattern);
|
||||||
|
|
||||||
// Debug: Log the pattern and results
|
|
||||||
error_log("hasValidatedDocument: Pattern: " . $pattern);
|
|
||||||
error_log("hasValidatedDocument: Files found: " . print_r($files, true));
|
|
||||||
|
|
||||||
// If no files found with the exact pattern, try a more flexible search
|
// If no files found with the exact pattern, try a more flexible search
|
||||||
if (empty($files)) {
|
if (empty($files)) {
|
||||||
$pattern = $vat_declarations_dir . 'CA3_*' . $declaration_id . '*.pdf';
|
$pattern = $vat_declarations_dir . 'CA3_*' . $declaration_id . '*.pdf';
|
||||||
$files = glob($pattern);
|
$files = glob($pattern);
|
||||||
error_log("hasValidatedDocument: Flexible pattern: " . $pattern);
|
|
||||||
error_log("hasValidatedDocument: Flexible files found: " . print_r($files, true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = !empty($files) && file_exists($files[0]);
|
return !empty($files) && file_exists($files[0]);
|
||||||
error_log("hasValidatedDocument: Final result: " . ($result ? 'true' : 'false'));
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -336,25 +336,16 @@ class DeclarationTVA_PDF
|
|||||||
// First generate the PDF using the same method as export
|
// First generate the PDF using the same method as export
|
||||||
$temp_pdf = $this->generateCA3PDF($declaration_id, $outputlangs);
|
$temp_pdf = $this->generateCA3PDF($declaration_id, $outputlangs);
|
||||||
|
|
||||||
if (!$temp_pdf) {
|
if ($temp_pdf && file_exists($temp_pdf)) {
|
||||||
$this->error = 'Failed to generate temporary PDF: ' . $this->error;
|
// Copy the generated PDF to the validation location
|
||||||
return false;
|
if (copy($temp_pdf, $filepath)) {
|
||||||
|
// Clean up the temporary file
|
||||||
|
unlink($temp_pdf);
|
||||||
|
return $filepath;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_exists($temp_pdf)) {
|
return false;
|
||||||
$this->error = 'Temporary PDF file does not exist: ' . $temp_pdf;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy the generated PDF to the validation location
|
|
||||||
if (copy($temp_pdf, $filepath)) {
|
|
||||||
// Clean up the temporary file
|
|
||||||
unlink($temp_pdf);
|
|
||||||
return $filepath;
|
|
||||||
} else {
|
|
||||||
$this->error = 'Failed to copy PDF to validation location: ' . $filepath;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user