From 1cafc092df989eb35b94815b3ec68bef74188cec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 19 Aug 2026 02:37:18 +0200 Subject: [PATCH] pdf logo header mutualization (#39503) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * FIX: Restore PHPUnit 11 compatibility in CommonClassTest onNotSuccessfulTest() overrode PHPUnit\Framework\TestCase's method with an incompatible return type (void vs never), and the assertMatchesRegularExpression back-compat shim for PHPUnit <8 now illegally overrides that method, which PHPUnit 11 declares final. Both faults made every test extending CommonClassTest fatal immediately on this environment's PHPUnit 11.5.55. Pre-existing breakage, unrelated to the PDF mutualization work in this branch — fixed here because Task 1's plan requires a passing BuildDocTest.php baseline before any implementer is dispatched. * NEW: Mutualize PDF header logo block into pdf_writeLogoOrCompanyName() (sponge, einstein, azur, muscadet) * NEW: Mutualize PDF header logo block into pdf_writeLogoOrCompanyName() (cornas, standard, cyan, octopus, strato) * FIX: Resolve $logodir before calling pdf_writeLogoOrCompanyName() in cornas, standard, cyan, octopus, strato * NEW: Mutualize PDF header logo block into pdf_writeLogoOrCompanyName() (eratosthene, eagle_proforma, standard_asset) Co-Authored-By: Claude Sonnet 5 * NEW: Mutualize PDF header logo block into pdf_writeLogoOrCompanyName() (aurore, zenith) * FIX: Complete PHPUnit 11 compatibility fix in CommonClassTest::onNotSuccessfulTest The prior compatibility fix (f29129aae43) resolved the two class-load fatals but left onNotSuccessfulTest() calling getName()/getDataSetAsString(), neither of which exists on PHPUnit 11's TestCase (renamed to name() and dataSetAsStringWithData()/dataSetAsString()). The undefined-method error was silently absorbed by PHPUnit's own exception handling, so every test failure across the suite still ran and reported correctly, but the method's entire diagnostic block (log tail, backtrace, DB info dump) never executed. Verified with a throwaway reproduction test before and after: the diagnostic ##[group] output was empty before this fix and complete after it. Found during the final whole-branch review of the PDF logo-block mutualization branch; unrelated to that refactor but touches the same file already modified by the earlier compatibility commit. * FIX: Drop unneeded by-ref $pdf and rename $ltrdirection to $align in pdf_writeLogoOrCompanyName() TCPDF objects are handles, so passing $pdf by reference bought nothing and was inconsistent with every sibling function in this file (pdf_pagehead, pdf_watermark, pdf_bank, pdf_pagefoot, ...), all of which take $pdf by value. $ltrdirection was also a misnomer: three of the 14 callers pass the literal 'L' and one passes 'J' (justify) - none of those is a text direction, it's an alignment. Renaming is call-site-transparent (all 14 callers use positional arguments). Found during the final whole-branch review of the PDF logo-block mutualization branch. * NEW: Document pdf_writeLogoOrCompanyName() helper in ChangeLog Per repo convention (CLAUDE.md: "Always update ChangeLog for significant changes"). Flagged during the final whole-branch review of the PDF logo-block mutualization branch: a new reusable pdf_lib.php function is part of the surface third-party PDF document-model modules build against. * restore commonclasstest * fix --------- Co-authored-by: Claude Sonnet 5 Co-authored-by: Laurent Destailleur --- ChangeLog | 1 + htdocs/core/lib/pdf.lib.php | 41 +++++++++++++++++++ .../asset/doc/pdf_standard_asset.modules.php | 28 ++----------- .../commande/doc/pdf_einstein.modules.php | 28 ++----------- .../commande/doc/pdf_eratosthene.modules.php | 29 +++---------- .../contract/doc/pdf_strato.modules.php | 29 +++---------- .../facture/doc/pdf_octopus.modules.php | 28 ++----------- .../facture/doc/pdf_sponge.modules.php | 28 ++----------- .../product/doc/pdf_standard.modules.php | 28 ++----------- .../modules/propale/doc/pdf_azur.modules.php | 28 ++----------- .../modules/propale/doc/pdf_cyan.modules.php | 28 ++----------- .../doc/pdf_eagle_proforma.modules.php | 28 ++----------- .../supplier_order/doc/pdf_cornas.modules.php | 28 ++----------- .../doc/pdf_muscadet.modules.php | 28 ++----------- .../doc/pdf_aurore.modules.php | 28 ++----------- .../doc/pdf_zenith.modules.php | 28 ++----------- 16 files changed, 100 insertions(+), 336 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2149b7515af..2b2fd430e4a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -189,6 +189,7 @@ NEW: API get country: load region and load states now an option (#37715) NEW: Add MAIN_FORCE_SYSTEM_MESSAGE Renamed hook "info_admin" into "messageOfTheDay" NEW: Category - API - Add type list (#38207) NEW: Add method calculateVATNumberFromProperties() +NEW: Add pdf_writeLogoOrCompanyName() helper in pdf.lib.php to mutualize PDF header logo rendering across document generators NEW: Add method dolOutputDates() FIX: Security permission on payment instead of create to create payment with API (credit Santosh Kumar Puppala) in commit ad8cd7c0e1800636302517e42fcdcafa393524b3 diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 95dd345b642..6fe9e56e264 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -330,6 +330,47 @@ function pdf_getHeightForLogo($logo, $url = false) return $height; } +/** + * Output company logo on top-left of a PDF page header, or the company name as fallback text if no logo is + * set, or an error message if the logo file is missing/unreadable. Shared by the page headers of the various + * document generators (invoices, orders, proposals, ...). + * + * @param TCPDF $pdf PDF object + * @param Translate $outputlangs Object lang for output + * @param Societe $emetteur Emitting company (the PDF generator's $this->emetteur) + * @param string $logodir Directory containing the logos subfolder (already resolved by the caller) + * @param float $posx X position to place the logo image + * @param float $posy Y position to place the logo image + * @param float $w Cell width used for the fallback company name / error message text + * @param float $default_font_size Default font size (used to size the error message font) + * @param string $align Alignment ('L', 'R', or 'J') for the fallback company name text + * @return void + */ +function pdf_writeLogoOrCompanyName($pdf, $outputlangs, $emetteur, $logodir, $posx, $posy, $w, $default_font_size, $align) +{ + if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) { + if ($emetteur->logo) { + if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { + $logo = $logodir.'/logos/thumbs/'.$emetteur->logo_small; + } else { + $logo = $logodir.'/logos/'.$emetteur->logo; + } + if (is_readable($logo)) { + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, $posx, $posy, 0, $height); // width=0 (auto) + } else { + $pdf->SetTextColor(200, 0, 0); + $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); + } + } else { + $text = (string) $emetteur->name; + $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $align); + } + } +} + /** * Function to try to calculate height of a HTML Content. * WARNING: Do not use this function inside a TCPDF transaction. diff --git a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php index a4b8433db2f..c34f36d7981 100644 --- a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php +++ b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php @@ -818,31 +818,11 @@ class pdf_standard_asset extends ModelePDFAsset $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) { - if ($this->emetteur->logo) { - $logodir = $conf->mycompany->dir_output; - if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) { - $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity]; - } - if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { - $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; - } else { - $logo = $logodir.'/logos/'.$this->emetteur->logo; - } - if (is_readable($logo)) { - $height = pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) - } else { - $pdf->SetTextColor(200, 0, 0); - $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); - } - } else { - $text = (string) $this->emetteur->name; - $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); - } + $logodir = $conf->mycompany->dir_output; + if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) { + $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity]; } + pdf_writeLogoOrCompanyName($pdf, $outputlangs, $this->emetteur, $logodir, $this->marge_gauche, $posy, $w, $default_font_size, 'L'); $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 98545c3cfc6..c41440c1128 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -1374,31 +1374,11 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) { - if ($this->emetteur->logo) { - $logodir = $conf->mycompany->dir_output; - if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) { - $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity]; - } - if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { - $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; - } else { - $logo = $logodir.'/logos/'.$this->emetteur->logo; - } - if (is_readable($logo)) { - $height = pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) - } else { - $pdf->SetTextColor(200, 0, 0); - $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); - } - } else { - $text = $this->emetteur->name; - $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection); - } + $logodir = $conf->mycompany->dir_output; + if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) { + $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity]; } + pdf_writeLogoOrCompanyName($pdf, $outputlangs, $this->emetteur, $logodir, $this->marge_gauche, $posy, $w, $default_font_size, $ltrdirection); $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index b627bd220ad..a07a1dbfb21 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -1641,31 +1641,12 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) { - if ($this->emetteur->logo) { - $logodir = $conf->mycompany->dir_output; - if (!empty(getMultidirOutput($mysoc, 'mycompany'))) { - $logodir = getMultidirOutput($mysoc, 'mycompany'); - } - if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { - $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; - } else { - $logo = $logodir.'/logos/'.$this->emetteur->logo; - } - if (is_readable($logo)) { - $height = pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) - } else { - $pdf->SetTextColor(200, 0, 0); - $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); - } - } else { - $text = $this->emetteur->name; - $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); - } + $logodir = $conf->mycompany->dir_output; + $multidiroutput = getMultidirOutput($mysoc, 'mycompany'); + if (!empty($multidiroutput)) { + $logodir = $multidiroutput; } + pdf_writeLogoOrCompanyName($pdf, $outputlangs, $this->emetteur, $logodir, $this->marge_gauche, $posy, $w, $default_font_size, 'L'); $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index 32f93edfea8..41ef69d9393 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -674,31 +674,12 @@ class pdf_strato extends ModelePDFContract $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (!getDolGlobalString('PDF_DISABLE_MYCOMPANY_LOGO')) { - if ($this->emetteur->logo) { - $logodir = $conf->mycompany->dir_output; - if (getMultidirOutput($object, 'mycompany')) { - $logodir = getMultidirOutput($object, 'mycompany'); - } - if (!getDolGlobalString('MAIN_PDF_USE_LARGE_LOGO')) { - $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; - } else { - $logo = $logodir.'/logos/'.$this->emetteur->logo; - } - if (is_readable($logo)) { - $height = pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) - } else { - $pdf->SetTextColor(200, 0, 0); - $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); - } - } else { - $text = $this->emetteur->name; - $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection); - } + $logodir = $conf->mycompany->dir_output; + $multidiroutput = getMultidirOutput($object, 'mycompany'); + if (!empty($multidiroutput)) { + $logodir = $multidiroutput; } + pdf_writeLogoOrCompanyName($pdf, $outputlangs, $this->emetteur, $logodir, $this->marge_gauche, $posy, $w, $default_font_size, $ltrdirection); $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); diff --git a/htdocs/core/modules/facture/doc/pdf_octopus.modules.php b/htdocs/core/modules/facture/doc/pdf_octopus.modules.php index a3dce874819..1f265f1b259 100644 --- a/htdocs/core/modules/facture/doc/pdf_octopus.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_octopus.modules.php @@ -2026,31 +2026,11 @@ class pdf_octopus extends ModelePDFFactures $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) { - if ($this->emetteur->logo) { - $logodir = $conf->mycompany->dir_output; - if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) { - $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity]; - } - if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { - $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; - } else { - $logo = $logodir.'/logos/'.$this->emetteur->logo; - } - if (is_readable($logo)) { - $height = pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) - } else { - $pdf->SetTextColor(200, 0, 0); - $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); - } - } else { - $text = $this->emetteur->name; - $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection); - } + $logodir = $conf->mycompany->dir_output; + if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) { + $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity]; } + pdf_writeLogoOrCompanyName($pdf, $outputlangs, $this->emetteur, $logodir, $this->marge_gauche, $posy, $w, $default_font_size, $ltrdirection); $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index e3df6b24535..51e4dfb92c5 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -2231,31 +2231,11 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) { - if ($this->emetteur->logo) { - $logodir = $conf->mycompany->dir_output; - if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) { - $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity]; - } - if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { - $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; - } else { - $logo = $logodir.'/logos/'.$this->emetteur->logo; - } - if (is_readable($logo)) { - $height = pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) - } else { - $pdf->SetTextColor(200, 0, 0); - $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); - } - } else { - $text = $this->emetteur->name; - $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection); - } + $logodir = $conf->mycompany->dir_output; + if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) { + $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity]; } + pdf_writeLogoOrCompanyName($pdf, $outputlangs, $this->emetteur, $logodir, $this->marge_gauche, $posy, $w, $default_font_size, $ltrdirection); $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php index 42f9bbb4464..02326bba12c 100644 --- a/htdocs/core/modules/product/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php @@ -756,31 +756,11 @@ class pdf_standard extends ModelePDFProduct $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) { - if ($this->emetteur->logo) { - $logodir = $conf->mycompany->dir_output; - if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) { - $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity]; - } - if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { - $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; - } else { - $logo = $logodir.'/logos/'.$this->emetteur->logo; - } - if (is_readable($logo)) { - $height = pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) - } else { - $pdf->SetTextColor(200, 0, 0); - $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); - } - } else { - $text = $this->emetteur->name; - $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection); - } + $logodir = $conf->mycompany->dir_output; + if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) { + $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity]; } + pdf_writeLogoOrCompanyName($pdf, $outputlangs, $this->emetteur, $logodir, $this->marge_gauche, $posy, $w, $default_font_size, $ltrdirection); $pdf->SetFont('', 'B', $default_font_size + 3); diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 6ff7527d2d8..9b4022cd9dd 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -1582,31 +1582,11 @@ class pdf_azur extends ModelePDFPropales $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) { - if ($this->emetteur->logo) { - $logodir = $conf->mycompany->dir_output; - if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) { - $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity]; - } - if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { - $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; - } else { - $logo = $logodir.'/logos/'.$this->emetteur->logo; - } - if (is_readable($logo)) { - $height = pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) - } else { - $pdf->SetTextColor(200, 0, 0); - $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); - } - } else { - $text = $this->emetteur->name; - $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection); - } + $logodir = $conf->mycompany->dir_output; + if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) { + $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity]; } + pdf_writeLogoOrCompanyName($pdf, $outputlangs, $this->emetteur, $logodir, $this->marge_gauche, $posy, $w, $default_font_size, $ltrdirection); $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index b9a1a39bd53..79d572c224a 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -1726,31 +1726,11 @@ class pdf_cyan extends ModelePDFPropales $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) { - if ($this->emetteur->logo) { - $logodir = $conf->mycompany->dir_output; - if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) { - $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity]; - } - if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { - $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; - } else { - $logo = $logodir.'/logos/'.$this->emetteur->logo; - } - if (is_readable($logo)) { - $height = pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) - } else { - $pdf->SetTextColor(200, 0, 0); - $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); - } - } else { - $text = $this->emetteur->name; - $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection); - } + $logodir = $conf->mycompany->dir_output; + if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) { + $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity]; } + pdf_writeLogoOrCompanyName($pdf, $outputlangs, $this->emetteur, $logodir, $this->marge_gauche, $posy, $w, $default_font_size, $ltrdirection); $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php index 2fdbe416247..738c4b9af11 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php @@ -1225,31 +1225,11 @@ class pdf_eagle_proforma extends ModelePDFStockTransfer $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) { - if ($this->emetteur->logo) { - $logodir = $conf->mycompany->dir_output; - if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) { - $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity]; - } - if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { - $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; - } else { - $logo = $logodir.'/logos/'.$this->emetteur->logo; - } - if (is_readable($logo)) { - $height = pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) - } else { - $pdf->SetTextColor(200, 0, 0); - $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); - } - } else { - $text = $this->emetteur->name; - $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); - } + $logodir = $conf->mycompany->dir_output; + if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) { + $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity]; } + pdf_writeLogoOrCompanyName($pdf, $outputlangs, $this->emetteur, $logodir, $this->marge_gauche, $posy, $w, $default_font_size, 'L'); $pdf->SetDrawColor(128, 128, 128); 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 a0dc7cd48d6..a994fc20764 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -1265,31 +1265,11 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) { - if ($this->emetteur->logo) { - $logodir = $conf->mycompany->dir_output; - if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) { - $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity]; - } - if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { - $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; - } else { - $logo = $logodir.'/logos/'.$this->emetteur->logo; - } - if (is_readable($logo)) { - $height = pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) - } else { - $pdf->SetTextColor(200, 0, 0); - $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); - } - } else { - $text = $this->emetteur->name; - $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection); - } + $logodir = $conf->mycompany->dir_output; + if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) { + $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity]; } + pdf_writeLogoOrCompanyName($pdf, $outputlangs, $this->emetteur, $logodir, $this->marge_gauche, $posy, $w, $default_font_size, $ltrdirection); $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index cfb50edbd39..8f7d0976149 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -1133,31 +1133,11 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) { - if ($this->emetteur->logo) { - $logodir = $conf->mycompany->dir_output; - if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) { - $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity]; - } - if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { - $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; - } else { - $logo = $logodir.'/logos/'.$this->emetteur->logo; - } - if (is_readable($logo)) { - $height = pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) - } else { - $pdf->SetTextColor(200, 0, 0); - $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); - } - } else { - $text = $this->emetteur->name; - $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection); - } + $logodir = $conf->mycompany->dir_output; + if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) { + $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity]; } + pdf_writeLogoOrCompanyName($pdf, $outputlangs, $this->emetteur, $logodir, $this->marge_gauche, $posy, $w, $default_font_size, $ltrdirection); $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 55a5b5b5da5..442e82a2dcb 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -1228,31 +1228,11 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) { - if ($this->emetteur->logo) { - $logodir = $conf->mycompany->dir_output; - if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) { - $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity]; - } - if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { - $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; - } else { - $logo = $logodir.'/logos/'.$this->emetteur->logo; - } - if (is_readable($logo)) { - $height = pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) - } else { - $pdf->SetTextColor(200, 0, 0); - $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); - } - } else { - $text = $this->emetteur->name; - $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0); - } + $logodir = $conf->mycompany->dir_output; + if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) { + $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity]; } + pdf_writeLogoOrCompanyName($pdf, $outputlangs, $this->emetteur, $logodir, $this->marge_gauche, $posy, 100, $default_font_size, 'J'); $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php index a9ec360bdd3..1c5c1063785 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php @@ -1244,31 +1244,11 @@ class pdf_zenith extends ModelePDFSupplierProposal $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) { - if ($this->emetteur->logo) { - $logodir = $conf->mycompany->dir_output; - if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) { - $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity]; - } - if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { - $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; - } else { - $logo = $logodir.'/logos/'.$this->emetteur->logo; - } - if (is_readable($logo)) { - $height = pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) - } else { - $pdf->SetTextColor(200, 0, 0); - $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); - } - } else { - $text = $this->emetteur->name; - $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection); - } + $logodir = $conf->mycompany->dir_output; + if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) { + $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity]; } + pdf_writeLogoOrCompanyName($pdf, $outputlangs, $this->emetteur, $logodir, $this->marge_gauche, $posy, 100, $default_font_size, $ltrdirection); $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy);