Fix PDF path lookup to use correct documents directory
This commit is contained in:
parent
1cb9837ae7
commit
c1d1f122fa
@ -1273,16 +1273,24 @@ class DeclarationTVA
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if PDF file exists in the VAT declarations directory
|
||||
$vat_declarations_dir = DOL_DATA_ROOT . '/declarationtva/validated/';
|
||||
// Check if PDF file exists in the VAT declarations documents directory
|
||||
$vat_declarations_dir = DOL_DATA_ROOT . '/documents/declarationtva/';
|
||||
$year_dir = $vat_declarations_dir . date('Y') . '/';
|
||||
$month_dir = $year_dir . date('m') . '/';
|
||||
|
||||
// Look for PDF files with the declaration number
|
||||
$pattern = $vat_declarations_dir . 'CA3_' . $obj->declaration_number . '_*.pdf';
|
||||
// Look for PDF files with the declaration number in the current month directory
|
||||
$pattern = $month_dir . 'CA3_' . $obj->declaration_number . '_*.pdf';
|
||||
$files = glob($pattern);
|
||||
|
||||
// If no files found with the exact pattern, try a more flexible search
|
||||
if (empty($files)) {
|
||||
$pattern = $vat_declarations_dir . 'CA3_*' . $obj->declaration_number . '*.pdf';
|
||||
$pattern = $month_dir . 'CA3_*' . $obj->declaration_number . '*.pdf';
|
||||
$files = glob($pattern);
|
||||
}
|
||||
|
||||
// If still no files found, search in the year directory
|
||||
if (empty($files)) {
|
||||
$pattern = $year_dir . 'CA3_' . $obj->declaration_number . '_*.pdf';
|
||||
$files = glob($pattern);
|
||||
}
|
||||
|
||||
@ -1313,16 +1321,24 @@ class DeclarationTVA
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if PDF file exists in the VAT declarations directory
|
||||
$vat_declarations_dir = DOL_DATA_ROOT . '/declarationtva/validated/';
|
||||
// Check if PDF file exists in the VAT declarations documents directory
|
||||
$vat_declarations_dir = DOL_DATA_ROOT . '/documents/declarationtva/';
|
||||
$year_dir = $vat_declarations_dir . date('Y') . '/';
|
||||
$month_dir = $year_dir . date('m') . '/';
|
||||
|
||||
// Look for PDF files with the declaration number
|
||||
$pattern = $vat_declarations_dir . 'CA3_' . $obj->declaration_number . '_*.pdf';
|
||||
// Look for PDF files with the declaration number in the current month directory
|
||||
$pattern = $month_dir . 'CA3_' . $obj->declaration_number . '_*.pdf';
|
||||
$files = glob($pattern);
|
||||
|
||||
// If no files found with the exact pattern, try a more flexible search
|
||||
if (empty($files)) {
|
||||
$pattern = $vat_declarations_dir . 'CA3_*' . $obj->declaration_number . '*.pdf';
|
||||
$pattern = $month_dir . 'CA3_*' . $obj->declaration_number . '*.pdf';
|
||||
$files = glob($pattern);
|
||||
}
|
||||
|
||||
// If still no files found, search in the year directory
|
||||
if (empty($files)) {
|
||||
$pattern = $year_dir . 'CA3_' . $obj->declaration_number . '_*.pdf';
|
||||
$files = glob($pattern);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user