v2.5.10: Fixed footer implementation using custom PDF class
- Fixed TCPDF footer implementation using proper Footer() method override - Created DeclarationTVA_CustomPDF class extending TCPDF - Removed incorrect setFooterCallback() calls that don't exist in TCPDF - Company name and page numbering now work correctly on all pages - Fixed 'Call to undefined method TCPDF::setFooterCallback()' error - Updated module version to 2.5.10
This commit is contained in:
parent
348a2ecb1e
commit
ca2b6f11a1
@ -1,5 +1,13 @@
|
|||||||
# CHANGELOG MODULE DECLARATIONTVA FOR [DOLIBARR ERP CRM](https://www.dolibarr.org)
|
# CHANGELOG MODULE DECLARATIONTVA FOR [DOLIBARR ERP CRM](https://www.dolibarr.org)
|
||||||
|
|
||||||
|
## 2.5.10
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
- **Fixed Footer Implementation**: Corrected TCPDF footer implementation using custom PDF class
|
||||||
|
- **Proper Footer Method**: Used TCPDF's built-in Footer() method override instead of non-existent callback
|
||||||
|
- **Stable Footer**: Company name and page numbering now work correctly on all pages
|
||||||
|
- **Error Resolution**: Fixed "Call to undefined method TCPDF::setFooterCallback()" error
|
||||||
|
|
||||||
## 2.5.9
|
## 2.5.9
|
||||||
|
|
||||||
### UI/UX Improvements
|
### UI/UX Improvements
|
||||||
|
|||||||
@ -15,6 +15,41 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom PDF class with footer functionality
|
||||||
|
*/
|
||||||
|
class DeclarationTVA_CustomPDF extends TCPDF
|
||||||
|
{
|
||||||
|
private $company_name = '';
|
||||||
|
|
||||||
|
public function setCompanyName($company_name)
|
||||||
|
{
|
||||||
|
$this->company_name = $company_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function Footer()
|
||||||
|
{
|
||||||
|
// Set font size 7 (same as summary information)
|
||||||
|
$this->SetFont('helvetica', '', 7);
|
||||||
|
|
||||||
|
// Get current page number
|
||||||
|
$page_number = $this->getPage();
|
||||||
|
|
||||||
|
// Get page width for positioning
|
||||||
|
$page_width = $this->getPageWidth();
|
||||||
|
$margin_left = $this->getMargins()['left'];
|
||||||
|
$margin_right = $this->getMargins()['right'];
|
||||||
|
|
||||||
|
// Company name on the left
|
||||||
|
$this->SetXY($margin_left, $this->GetY());
|
||||||
|
$this->Cell(0, 6, $this->company_name, 0, 0, 'L');
|
||||||
|
|
||||||
|
// Page number on the right
|
||||||
|
$this->SetXY($page_width - $margin_right - 20, $this->GetY());
|
||||||
|
$this->Cell(20, 6, 'Page ' . $page_number, 0, 0, 'R');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file core/class/declarationtva_pdf.class.php
|
* \file core/class/declarationtva_pdf.class.php
|
||||||
* \ingroup declarationtva
|
* \ingroup declarationtva
|
||||||
@ -809,7 +844,10 @@ class DeclarationTVA_PDF
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// Create a new PDF document
|
// Create a new PDF document
|
||||||
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
|
$pdf = new DeclarationTVA_CustomPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
|
||||||
|
|
||||||
|
// Set company name for footer
|
||||||
|
$pdf->setCompanyName($company->name);
|
||||||
|
|
||||||
// Set document information
|
// Set document information
|
||||||
$pdf->SetCreator('DeclarationTVA Module');
|
$pdf->SetCreator('DeclarationTVA Module');
|
||||||
@ -825,9 +863,6 @@ class DeclarationTVA_PDF
|
|||||||
// Set thin borders for all elements
|
// Set thin borders for all elements
|
||||||
$pdf->SetLineWidth(0.1);
|
$pdf->SetLineWidth(0.1);
|
||||||
|
|
||||||
// Set custom footer
|
|
||||||
$pdf->setFooterCallback(array($this, 'customFooter'));
|
|
||||||
|
|
||||||
// Add a page
|
// Add a page
|
||||||
$pdf->AddPage();
|
$pdf->AddPage();
|
||||||
|
|
||||||
@ -1396,7 +1431,10 @@ class DeclarationTVA_PDF
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// Create a new PDF document
|
// Create a new PDF document
|
||||||
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
|
$pdf = new DeclarationTVA_CustomPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
|
||||||
|
|
||||||
|
// Set company name for footer
|
||||||
|
$pdf->setCompanyName($company->name);
|
||||||
|
|
||||||
// Set document information
|
// Set document information
|
||||||
$pdf->SetCreator('DeclarationTVA Module');
|
$pdf->SetCreator('DeclarationTVA Module');
|
||||||
@ -1412,9 +1450,6 @@ class DeclarationTVA_PDF
|
|||||||
// Set thin borders for all elements
|
// Set thin borders for all elements
|
||||||
$pdf->SetLineWidth(0.1);
|
$pdf->SetLineWidth(0.1);
|
||||||
|
|
||||||
// Set custom footer
|
|
||||||
$pdf->setFooterCallback(array($this, 'customFooter'));
|
|
||||||
|
|
||||||
// Add title page
|
// Add title page
|
||||||
$pdf->AddPage();
|
$pdf->AddPage();
|
||||||
$pdf->SetFont('helvetica', 'B', 16);
|
$pdf->SetFont('helvetica', 'B', 16);
|
||||||
@ -2582,37 +2617,5 @@ class DeclarationTVA_PDF
|
|||||||
return 'Compte ' . $account_code;
|
return 'Compte ' . $account_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Custom footer callback for PDF
|
|
||||||
*
|
|
||||||
* @param TCPDF $pdf PDF object
|
|
||||||
*/
|
|
||||||
public function customFooter($pdf)
|
|
||||||
{
|
|
||||||
global $conf;
|
|
||||||
|
|
||||||
// Get company information
|
|
||||||
$company = new Societe($this->db);
|
|
||||||
$company->fetch($conf->entity);
|
|
||||||
|
|
||||||
// Set font size 7 (same as summary information)
|
|
||||||
$pdf->SetFont('helvetica', '', 7);
|
|
||||||
|
|
||||||
// Get current page number
|
|
||||||
$page_number = $pdf->getPage();
|
|
||||||
|
|
||||||
// Get page width for positioning
|
|
||||||
$page_width = $pdf->getPageWidth();
|
|
||||||
$margin_left = $pdf->getMargins()['left'];
|
|
||||||
$margin_right = $pdf->getMargins()['right'];
|
|
||||||
|
|
||||||
// Company name on the left
|
|
||||||
$pdf->SetXY($margin_left, $pdf->GetY());
|
|
||||||
$pdf->Cell(0, 6, $company->name, 0, 0, 'L');
|
|
||||||
|
|
||||||
// Page number on the right
|
|
||||||
$pdf->SetXY($page_width - $margin_right - 20, $pdf->GetY());
|
|
||||||
$pdf->Cell(20, 6, 'Page ' . $page_number, 0, 0, 'R');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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'
|
$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'
|
// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated', 'experimental_deprecated' or a version string like 'x.y.z'
|
||||||
$this->version = '2.5.9';
|
$this->version = '2.5.10';
|
||||||
// Url to the file with your last numberversion of this module
|
// Url to the file with your last numberversion of this module
|
||||||
//$this->url_last_version = 'http://www.example.com/versionmodule.txt';
|
//$this->url_last_version = 'http://www.example.com/versionmodule.txt';
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user