From 183451c607cda9842dcb752c7ec537b2c0d85076 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Jan 2026 09:56:10 +0100 Subject: [PATCH] Clean code --- htdocs/barcode/printsheet.php | 18 +++++++++++++++++- .../core/modules/dons/html_cerfafr.modules.php | 4 ++-- .../pdf_standard_supplierpayment.modules.php | 6 +----- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index 554d2fd61e6..4d05d5c15ac 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -229,8 +229,10 @@ if (empty($reshook)) { } if (!$error) { + global $dolibarr_main_url_root; // List of values to scan for a replacement $substitutionarray = array( + // old '%LOGIN%' => $user->login, '%COMPANY%' => $mysoc->name, '%ADDRESS%' => $mysoc->address, @@ -243,7 +245,21 @@ if (empty($reshook)) { '%MONTH%' => $month, '%DAY%' => $day, '%DOL_MAIN_URL_ROOT%' => DOL_MAIN_URL_ROOT, - '%SERVER%' => "http://".$_SERVER["SERVER_NAME"]."/", + '%SERVER%' => $dolibarr_main_url_root, + // new + '__LOGIN__' => $user->login, + '__COMPANY__' => $mysoc->name, + '__ADDRESS__' => $mysoc->address, + '__ZIP__' => $mysoc->zip, + '__TOWN__' => $mysoc->town, + '__COUNTRY__' => $mysoc->country, + '__COUNTRY_CODE__' => $mysoc->country_code, + '__EMAIL__' => $mysoc->email, + '__YEAR__' => $year, + '__MONTH__' => $month, + '__DAY__' => $day, + '__DOL_MAIN_URL_ROOT__' => DOL_MAIN_URL_ROOT, + '__SERVER__' => $dolibarr_main_url_root, ); complete_substitutions_array($substitutionarray, $langs); diff --git a/htdocs/core/modules/dons/html_cerfafr.modules.php b/htdocs/core/modules/dons/html_cerfafr.modules.php index 1895da6efd1..270c168ccc0 100644 --- a/htdocs/core/modules/dons/html_cerfafr.modules.php +++ b/htdocs/core/modules/dons/html_cerfafr.modules.php @@ -162,11 +162,11 @@ class html_cerfafr extends ModeleDon $form = str_replace('__AMOUNTLETTERS__', $this->amountToLetters($don->amount), $form); $form = str_replace('__CURRENCY__', $outputlangs->transnoentitiesnoconv("Currency".$currency), $form); $form = str_replace('__CURRENCYCODE__', $conf->currency, $form); - $form = str_replace('__MAIN_INFO_SOCIETE_NOM__', $mysoc->name, $form); + $form = str_replace('__MAIN_INFO_SOCIETE_NOM__', (string) $mysoc->name, $form); $form = str_replace('__MAIN_INFO_SOCIETE_ADDRESS__', (string) $mysoc->address, $form); $form = str_replace('__MAIN_INFO_SOCIETE_ZIP__', (string) $mysoc->zip, $form); $form = str_replace('__MAIN_INFO_SOCIETE_TOWN__', (string) $mysoc->town, $form); - $form = str_replace('__MAIN_INFO_SOCIETE_OBJECT__', $mysoc->socialobject, $form); + $form = str_replace('__MAIN_INFO_SOCIETE_OBJECT__', (string) $mysoc->socialobject, $form); $form = str_replace('__DONATOR_FIRSTNAME__', (string) $don->firstname, $form); $form = str_replace('__DONATOR_LASTNAME__', (string) $don->lastname, $form); $form = str_replace('__DONATOR_SOCIETE__', (string) $don->societe, $form); diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard_supplierpayment.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard_supplierpayment.modules.php index a759c652f7c..0c6de2f5cce 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard_supplierpayment.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard_supplierpayment.modules.php @@ -567,7 +567,7 @@ class pdf_standard_supplierpayment extends ModelePDFSuppliersPayments // City $pdf->SetXY($this->page_largeur - $this->marge_droite - 30, $posy); - $pdf->MultiCell(150, 4, $mysoc->town, 0, 'L', true); + $pdf->MultiCell(150, 4, (string) $mysoc->town, 0, 'L', true); $posy += 4; // Date @@ -607,10 +607,6 @@ class pdf_standard_supplierpayment extends ModelePDFSuppliersPayments $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - /*$titre = strtoupper($mysoc->town).' - '.dol_print_date(dol_now(), 'day', 'tzserver', $outputlangs); - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3) - 60, $tab_top - 6); - $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);*/ - $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top); $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);