From 5edb85872b1d10a61f0d49f996c7e16ab6f8753d Mon Sep 17 00:00:00 2001 From: Frank Cools Date: Wed, 8 Oct 2025 12:49:03 +0200 Subject: [PATCH] v2.5.13: Fixed class definition order for TCPDF dependency - Moved custom PDF class definition after TCPDF include - Custom class now extends TCPDF after it's properly loaded - Fixed 'Class TCPDF not found' error by correct class definition order - Custom PDF class now works with proper dependency loading - Updated module version to 2.5.13 --- ChangeLog.md | 8 ++++++ core/class/declarationtva_pdf.class.php | 33 ++++++++++++------------ core/modules/modDeclarationTVA.class.php | 2 +- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 1dd7fd3..2402bde 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,13 @@ # CHANGELOG MODULE DECLARATIONTVA FOR [DOLIBARR ERP CRM](https://www.dolibarr.org) +## 2.5.13 + +### Bug Fixes +- **Fixed Class Definition Order**: Moved custom PDF class definition after TCPDF include +- **Proper Class Loading**: Custom class now extends TCPDF after it's loaded +- **Error Resolution**: Fixed "Class TCPDF not found" error by correct class definition order +- **Stable Implementation**: Custom PDF class now works with proper dependency loading + ## 2.5.12 ### Bug Fixes diff --git a/core/class/declarationtva_pdf.class.php b/core/class/declarationtva_pdf.class.php index db3ace6..ea43f2f 100644 --- a/core/class/declarationtva_pdf.class.php +++ b/core/class/declarationtva_pdf.class.php @@ -16,6 +16,23 @@ */ + +/** + * \file core/class/declarationtva_pdf.class.php + * \ingroup declarationtva + * \brief PDF generation for CA-3 declarations + */ + +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + +// Load TCPDF for PDF support (Dolibarr's standard) +require_once DOL_DOCUMENT_ROOT.'/includes/tecnickcom/tcpdf/tcpdf.php'; + +// Load FPDI-TCPDF for fillable PDF support +require_once DOL_DOCUMENT_ROOT.'/custom/declarationtva/vendor/autoload.php'; + /** * Custom PDF class with footer functionality */ @@ -51,22 +68,6 @@ class DeclarationTVA_CustomPDF extends TCPDF } } -/** - * \file core/class/declarationtva_pdf.class.php - * \ingroup declarationtva - * \brief PDF generation for CA-3 declarations - */ - -require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - -// Load TCPDF for PDF support (Dolibarr's standard) -require_once DOL_DOCUMENT_ROOT.'/includes/tecnickcom/tcpdf/tcpdf.php'; - -// Load FPDI-TCPDF for fillable PDF support -require_once DOL_DOCUMENT_ROOT.'/custom/declarationtva/vendor/autoload.php'; - /** * Class to generate CA-3 declaration PDF */ diff --git a/core/modules/modDeclarationTVA.class.php b/core/modules/modDeclarationTVA.class.php index f0d8fce..9dc778a 100644 --- a/core/modules/modDeclarationTVA.class.php +++ b/core/modules/modDeclarationTVA.class.php @@ -76,7 +76,7 @@ class modDeclarationTVA extends DolibarrModules $this->editor_squarred_logo = ''; // Must be image filename into the module/img directory followed with @modulename. Example: 'myimage.png@declarationtva' // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated', 'experimental_deprecated' or a version string like 'x.y.z' - $this->version = '2.5.12'; + $this->version = '2.5.13'; // Url to the file with your last numberversion of this module //$this->url_last_version = 'http://www.example.com/versionmodule.txt';