diff --git a/ChangeLog.md b/ChangeLog.md index 996e7b2..8861552 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,13 @@ # CHANGELOG MODULE DECLARATIONTVA FOR [DOLIBARR ERP CRM](https://www.dolibarr.org) +## 2.5.24 + +### Bug Fixes +- **Fixed Footer Page Count Implementation**: Now properly sets total pages after all pages are generated +- **Correct Page Display**: Footer now shows proper "Page X/Y" format with accurate total pages +- **Professional PDF Layout**: Fixed issue where {nb} placeholder wasn't being processed +- **Accurate Page Information**: Footer now displays correct total page count using custom implementation + ## 2.5.23 ### Bug Fixes diff --git a/core/class/declarationtva_pdf.class.php b/core/class/declarationtva_pdf.class.php index e24de94..cf3cea1 100644 --- a/core/class/declarationtva_pdf.class.php +++ b/core/class/declarationtva_pdf.class.php @@ -39,12 +39,18 @@ require_once DOL_DOCUMENT_ROOT.'/custom/declarationtva/vendor/autoload.php'; class DeclarationTVA_CustomPDF extends TCPDF { private $company_name = ''; + private $total_pages = 0; public function setCompanyName($company_name) { $this->company_name = $company_name; } + public function setTotalPages($total_pages) + { + $this->total_pages = $total_pages; + } + public function Footer() { // Set font size 7 (same as summary information) @@ -62,9 +68,10 @@ class DeclarationTVA_CustomPDF extends TCPDF $this->SetXY($margin_left, $this->GetY()); $this->Cell(0, 6, $this->company_name, 0, 0, 'L'); - // Page number with total pages on the right using TCPDF's {nb} placeholder + // Page number with total pages on the right + $total_pages = $this->total_pages > 0 ? $this->total_pages : $this->getNumPages(); $this->SetXY($page_width - $margin_right - 30, $this->GetY()); - $this->Cell(30, 6, 'Page ' . $page_number . '/{nb}', 0, 0, 'R'); + $this->Cell(30, 6, 'Page ' . $page_number . '/' . $total_pages, 0, 0, 'R'); } } @@ -898,6 +905,9 @@ class DeclarationTVA_PDF // Add detailed breakdown pages $this->addDetailPages($pdf, $declaration, $ca3_data); + // Set total pages for footer after all pages are generated + $pdf->setTotalPages($pdf->getNumPages()); + // Output PDF $pdf->Output($output_path, 'F'); @@ -1548,6 +1558,9 @@ class DeclarationTVA_PDF // Add detailed breakdown pages starting on page 2 $this->addDetailPages($pdf, $declaration, $ca3_data); + // Set total pages for footer after all pages are generated + $pdf->setTotalPages($pdf->getNumPages()); + // Output PDF $pdf->Output($output_path, 'F'); diff --git a/core/modules/modDeclarationTVA.class.php b/core/modules/modDeclarationTVA.class.php index d35046d..3a2f354 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.23'; + $this->version = '2.5.24'; // Url to the file with your last numberversion of this module //$this->url_last_version = 'http://www.example.com/versionmodule.txt';