From fac22fd16fbfc6b250df2720dc2c3d0f09c7070a Mon Sep 17 00:00:00 2001 From: noec764 <58433943+noec764@users.noreply.github.com> Date: Fri, 9 Feb 2024 16:53:36 +0100 Subject: [PATCH] NEW: Hook after total Table on PDF (#28092) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: NoƩ --- .../modules/commande/doc/pdf_eratosthene.modules.php | 8 ++++++++ htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 8 ++++++++ htdocs/core/modules/propale/doc/pdf_cyan.modules.php | 8 ++++++++ .../supplier_invoice/doc/pdf_canelle.modules.php | 10 +++++++++- .../modules/supplier_order/doc/pdf_cornas.modules.php | 10 +++++++++- 5 files changed, 42 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 2b051a87d75..8e03580481b 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -1320,6 +1320,14 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetTextColor(0, 0, 0); } + $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index); + + $reshook = $hookmanager->executeHooks('afterPDFTotalTable', $parameters, $this); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + $this->error = $hookmanager->error; + $this->errors = $hookmanager->errors; + } + $index++; return ($tab2_top + ($tab2_hl * $index)); } diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 7f54da1fd99..67687780c01 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1946,6 +1946,14 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetTextColor(0, 0, 0); } + $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index); + + $reshook = $hookmanager->executeHooks('afterPDFTotalTable', $parameters, $this); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + $this->error = $hookmanager->error; + $this->errors = $hookmanager->errors; + } + $index++; return ($tab2_top + ($tab2_hl * $index)); } diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index a770ae1819f..051a8d1a675 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -1417,6 +1417,14 @@ class pdf_cyan extends ModelePDFPropales $pdf->SetTextColor(0, 0, 0); } + $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index); + + $reshook = $hookmanager->executeHooks('afterPDFTotalTable', $parameters, $this); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + $this->error = $hookmanager->error; + $this->errors = $hookmanager->errors; + } + $index++; return ($tab2_top + ($tab2_hl * $index)); } diff --git a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php index 0fdea1e01fe..ef6c0ece605 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -616,7 +616,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { // phpcs:enable - global $conf, $mysoc; + global $conf, $mysoc, $hookmanager; $sign = 1; if ($object->type == 2 && getDolGlobalString('INVOICE_POSITIVE_CREDIT_NOTE')) { @@ -815,6 +815,14 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetTextColor(0, 0, 0); } + $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index); + + $reshook = $hookmanager->executeHooks('afterPDFTotalTable', $parameters, $this); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + $this->error = $hookmanager->error; + $this->errors = $hookmanager->errors; + } + $index++; return ($tab2_top + ($tab2_hl * $index)); } diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 4b5f44bad9b..03b1e311c68 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -916,7 +916,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { // phpcs:enable - global $conf, $mysoc; + global $conf, $mysoc, $hookmanager; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -1102,6 +1102,14 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetTextColor(0, 0, 0); } + $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index); + + $reshook = $hookmanager->executeHooks('afterPDFTotalTable', $parameters, $this); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + $this->error = $hookmanager->error; + $this->errors = $hookmanager->errors; + } + $index++; return ($tab2_top + ($tab2_hl * $index)); }