Remove debug logging and clean up code

- Removed all error_log debug statements from production code
- Cleaned up hasValidatedDocument method
- Cleaned up declaration list processing
- Code is now production-ready
- PDF detection and generation are working correctly
This commit is contained in:
Frank Cools 2025-10-06 17:43:25 +02:00
parent db0432b502
commit b305c3d90b
2 changed files with 1 additions and 29 deletions

View File

@ -1270,36 +1270,13 @@ class DeclarationTVA
$pattern = $month_dir . 'CA3_' . $obj->declaration_number . '_*.pdf'; $pattern = $month_dir . 'CA3_' . $obj->declaration_number . '_*.pdf';
$files = glob($pattern); $files = glob($pattern);
// Debug: Log the search details
error_log("DeclarationTVA Debug - hasValidatedDocument:");
error_log(" Declaration ID: " . $declaration_id);
error_log(" Declaration Number: " . $obj->declaration_number);
error_log(" Month Dir: " . $month_dir);
error_log(" Pattern 1: " . $pattern);
error_log(" Files found with pattern 1: " . count($files));
if (!empty($files)) {
error_log(" First file: " . $files[0]);
}
// 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 = $month_dir . 'CA3_*' . $obj->declaration_number . '*.pdf'; $pattern = $month_dir . 'CA3_*' . $obj->declaration_number . '*.pdf';
$files = glob($pattern); $files = glob($pattern);
error_log(" Pattern 2: " . $pattern);
error_log(" Files found with pattern 2: " . count($files));
if (!empty($files)) {
error_log(" First file: " . $files[0]);
}
} }
// Also try to list all files in the directory for debugging return !empty($files) && file_exists($files[0]);
$all_files = glob($month_dir . '*.pdf');
error_log(" All PDF files in directory: " . implode(', ', $all_files));
$result = !empty($files) && file_exists($files[0]);
error_log(" Final result: " . ($result ? 'TRUE' : 'FALSE'));
return $result;
} }
/** /**

View File

@ -128,8 +128,6 @@ if (empty($declarations)) {
print '</tr>'; print '</tr>';
foreach ($declarations as $d) { foreach ($declarations as $d) {
error_log("DeclarationTVA List Query Debug - Processing declaration ID: " . $d['rowid'] . ", Status: " . $d['status'] . ", Number: " . $d['declaration_number']);
print '<tr>'; print '<tr>';
print '<td>' . $d['declaration_number'] . '</td>'; print '<td>' . $d['declaration_number'] . '</td>';
print '<td class="center">' . dol_print_date($d['start_date'], 'day') . ' - ' . dol_print_date($d['end_date'], 'day') . '</td>'; print '<td class="center">' . dol_print_date($d['start_date'], 'day') . ' - ' . dol_print_date($d['end_date'], 'day') . '</td>';
@ -150,17 +148,14 @@ if (empty($declarations)) {
if ($d['status'] == 'validated') { if ($d['status'] == 'validated') {
// Check if document exists // Check if document exists
$has_document = $declarationtva->hasValidatedDocument($d['rowid']); $has_document = $declarationtva->hasValidatedDocument($d['rowid']);
error_log("DeclarationTVA List Debug - Declaration ID: " . $d['rowid'] . ", Status: " . $d['status'] . ", Has Document: " . ($has_document ? 'TRUE' : 'FALSE'));
if ($has_document) { if ($has_document) {
$pdf_path = $declarationtva->getValidatedPDFPath($d['rowid']); $pdf_path = $declarationtva->getValidatedPDFPath($d['rowid']);
error_log("DeclarationTVA List Debug - PDF Path: " . ($pdf_path ? $pdf_path : 'NULL'));
if ($pdf_path) { if ($pdf_path) {
// Create a download link // Create a download link
$relative_path = str_replace(DOL_DATA_ROOT, '', $pdf_path); $relative_path = str_replace(DOL_DATA_ROOT, '', $pdf_path);
$download_url = DOL_URL_ROOT . '/documents' . $relative_path; $download_url = DOL_URL_ROOT . '/documents' . $relative_path;
error_log("DeclarationTVA List Debug - Download URL: " . $download_url);
print '<a href="' . $download_url . '" target="_blank" title="' . $langs->trans("DownloadPDF") . '">'; print '<a href="' . $download_url . '" target="_blank" title="' . $langs->trans("DownloadPDF") . '">';
print '<i class="fa fa-file-pdf-o text-success"></i>'; print '<i class="fa fa-file-pdf-o text-success"></i>';
print '</a>'; print '</a>';