Fix PDF file paths to use /documents/declarationtva/validated/ directory
- Updated generateDetailedCA3PDF to save PDFs in /documents/declarationtva/validated/ - Updated hasValidatedDocument to look in /documents/declarationtva/validated/ - Updated getValidatedPDFPath to look in /documents/declarationtva/validated/ - Removed year/month directory structure - Should now match the actual file location where PDFs are saved - URLs should now work correctly
This commit is contained in:
parent
519f5e3be2
commit
d6de5c6c0b
@ -1262,17 +1262,15 @@ class DeclarationTVA
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if PDF file exists in the VAT declarations directory
|
// Check if PDF file exists in the VAT declarations directory
|
||||||
$vat_declarations_dir = DOL_DATA_ROOT . '/documents/declarationtva/';
|
$vat_declarations_dir = DOL_DATA_ROOT . '/documents/declarationtva/validated/';
|
||||||
$year_dir = $vat_declarations_dir . date('Y') . '/';
|
|
||||||
$month_dir = $year_dir . date('m') . '/';
|
|
||||||
|
|
||||||
// Look for PDF files with the declaration number
|
// Look for PDF files with the declaration number
|
||||||
$pattern = $month_dir . 'CA3_' . $obj->declaration_number . '_*.pdf';
|
$pattern = $vat_declarations_dir . 'CA3_' . $obj->declaration_number . '_*.pdf';
|
||||||
$files = glob($pattern);
|
$files = glob($pattern);
|
||||||
|
|
||||||
// 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 = $vat_declarations_dir . 'CA3_*' . $obj->declaration_number . '*.pdf';
|
||||||
$files = glob($pattern);
|
$files = glob($pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1304,17 +1302,15 @@ class DeclarationTVA
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if PDF file exists in the VAT declarations directory
|
// Check if PDF file exists in the VAT declarations directory
|
||||||
$vat_declarations_dir = DOL_DATA_ROOT . '/documents/declarationtva/';
|
$vat_declarations_dir = DOL_DATA_ROOT . '/documents/declarationtva/validated/';
|
||||||
$year_dir = $vat_declarations_dir . date('Y') . '/';
|
|
||||||
$month_dir = $year_dir . date('m') . '/';
|
|
||||||
|
|
||||||
// Look for PDF files with the declaration number
|
// Look for PDF files with the declaration number
|
||||||
$pattern = $month_dir . 'CA3_' . $obj->declaration_number . '_*.pdf';
|
$pattern = $vat_declarations_dir . 'CA3_' . $obj->declaration_number . '_*.pdf';
|
||||||
$files = glob($pattern);
|
$files = glob($pattern);
|
||||||
|
|
||||||
// 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 = $vat_declarations_dir . 'CA3_*' . $obj->declaration_number . '*.pdf';
|
||||||
$files = glob($pattern);
|
$files = glob($pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -184,22 +184,14 @@ class DeclarationTVA_PDF
|
|||||||
$filename = 'CA3_' . $declaration->declaration_number . '_' . date('Y-m-d') . '.pdf';
|
$filename = 'CA3_' . $declaration->declaration_number . '_' . date('Y-m-d') . '.pdf';
|
||||||
|
|
||||||
// Create VAT declarations documents directory structure
|
// Create VAT declarations documents directory structure
|
||||||
$vat_declarations_dir = DOL_DATA_ROOT . '/documents/declarationtva/';
|
$vat_declarations_dir = DOL_DATA_ROOT . '/documents/declarationtva/validated/';
|
||||||
$year_dir = $vat_declarations_dir . date('Y') . '/';
|
|
||||||
$month_dir = $year_dir . date('m') . '/';
|
|
||||||
|
|
||||||
// Create directories if they don't exist
|
// Create directory if it doesn't exist
|
||||||
if (!is_dir($vat_declarations_dir)) {
|
if (!is_dir($vat_declarations_dir)) {
|
||||||
dol_mkdir($vat_declarations_dir);
|
dol_mkdir($vat_declarations_dir);
|
||||||
}
|
}
|
||||||
if (!is_dir($year_dir)) {
|
|
||||||
dol_mkdir($year_dir);
|
|
||||||
}
|
|
||||||
if (!is_dir($month_dir)) {
|
|
||||||
dol_mkdir($month_dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
$filepath = $month_dir . $filename;
|
$filepath = $vat_declarations_dir . $filename;
|
||||||
|
|
||||||
// Generate detailed PDF with breakdown pages
|
// Generate detailed PDF with breakdown pages
|
||||||
$result = $this->generateDetailedPDF($filepath, $declaration, $ca3_data, $company);
|
$result = $this->generateDetailedPDF($filepath, $declaration, $ca3_data, $company);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user