From 223ce3fb84624e37c2b133f092286caf5af13d58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 8 Nov 2025 11:31:09 +0100 Subject: [PATCH 1/6] clean code (#36157) * clean code * clean code --- dev/build/phpstan/phpstan-baseline.neon | 150 ------------------------ htdocs/mrp/index.php | 11 +- htdocs/recruitment/index.php | 68 +++++------ htdocs/supplier_proposal/index.php | 11 +- htdocs/ticket/index.php | 11 ++ 5 files changed, 66 insertions(+), 185 deletions(-) diff --git a/dev/build/phpstan/phpstan-baseline.neon b/dev/build/phpstan/phpstan-baseline.neon index 2f748665dd9..da315d3f2dc 100644 --- a/dev/build/phpstan/phpstan-baseline.neon +++ b/dev/build/phpstan/phpstan-baseline.neon @@ -11490,36 +11490,6 @@ parameters: count: 1 path: ../../../htdocs/mrp/index.php - - - message: '#^Variable \$badgeStatus0 might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/mrp/index.php - - - - message: '#^Variable \$badgeStatus1 might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/mrp/index.php - - - - message: '#^Variable \$badgeStatus4 might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/mrp/index.php - - - - message: '#^Variable \$badgeStatus6 might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/mrp/index.php - - - - message: '#^Variable \$badgeStatus9 might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/mrp/index.php - - message: '#^Variable \$contextpage in empty\(\) always exists and is not falsy\.$#' identifier: empty.variable @@ -14658,54 +14628,6 @@ parameters: count: 1 path: ../../../htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php - - - message: '#^If condition is always true\.$#' - identifier: if.alwaysTrue - count: 1 - path: ../../../htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php - - - - message: '#^If condition is always true\.$#' - identifier: if.alwaysTrue - count: 2 - path: ../../../htdocs/recruitment/index.php - - - - message: '#^Variable \$badgeStatus0 might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../../htdocs/recruitment/index.php - - - - message: '#^Variable \$badgeStatus1 might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/recruitment/index.php - - - - message: '#^Variable \$badgeStatus4 might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../../htdocs/recruitment/index.php - - - - message: '#^Variable \$badgeStatus5 might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/recruitment/index.php - - - - message: '#^Variable \$badgeStatus6 might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/recruitment/index.php - - - - message: '#^Variable \$badgeStatus9 might not be defined\.$#' - identifier: variable.undefined - count: 3 - path: ../../../htdocs/recruitment/index.php - - message: '#^If condition is always true\.$#' identifier: if.alwaysTrue @@ -15426,36 +15348,6 @@ parameters: count: 1 path: ../../../htdocs/supplier_proposal/class/supplier_proposal.class.php - - - message: '#^Variable \$badgeStatus0 might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/supplier_proposal/index.php - - - - message: '#^Variable \$badgeStatus1 might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/supplier_proposal/index.php - - - - message: '#^Variable \$badgeStatus4 might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/supplier_proposal/index.php - - - - message: '#^Variable \$badgeStatus6 might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/supplier_proposal/index.php - - - - message: '#^Variable \$badgeStatus9 might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/supplier_proposal/index.php - - message: '#^If condition is always false\.$#' identifier: if.alwaysFalse @@ -15870,48 +15762,6 @@ parameters: count: 2 path: ../../../htdocs/ticket/class/ticket.class.php - - - message: '#^Variable \$badgeStatus0 might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/ticket/index.php - - - - message: '#^Variable \$badgeStatus1 might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/ticket/index.php - - - - message: '#^Variable \$badgeStatus3 might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../../htdocs/ticket/index.php - - - - message: '#^Variable \$badgeStatus4 might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../../htdocs/ticket/index.php - - - - message: '#^Variable \$badgeStatus6 might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/ticket/index.php - - - - message: '#^Variable \$badgeStatus9 might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/ticket/index.php - - - - message: '#^Variable \$shownb might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/ticket/index.php - - message: '#^If condition is always true\.$#' identifier: if.alwaysTrue diff --git a/htdocs/mrp/index.php b/htdocs/mrp/index.php index 355273ac213..1c046fb9f28 100644 --- a/htdocs/mrp/index.php +++ b/htdocs/mrp/index.php @@ -4,7 +4,7 @@ * Copyright (C) 2004-2019 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2019 Nicolas ZABOURI - * Copyright (C) 2019-2024 Frédéric France + * Copyright (C) 2019-2025 Frédéric France * Copyright (C) 2024 Alexandre Spangaro * Copyright (C) 2025 MDW * @@ -95,6 +95,15 @@ if (isModEnabled('mrp') && $conf->use_javascript_ajax) { $colorseries = array(); $vals = array(); + /** + * @var string $badgeStatus0 + * @var string $badgeStatus1 + * @var string $badgeStatus4 + * @var string $badgeStatus5 + * @var string $badgeStatus6 + * @var string $badgeStatus8 + * @var string $badgeStatus9 + */ include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; while ($i < $num) { diff --git a/htdocs/recruitment/index.php b/htdocs/recruitment/index.php index 406e18a7389..614d32f898e 100644 --- a/htdocs/recruitment/index.php +++ b/htdocs/recruitment/index.php @@ -97,6 +97,16 @@ if ($conf->use_javascript_ajax) { $sql .= " ORDER BY t.status ASC"; $resql = $db->query($sql); + /** + * @var string $badgeStatus0 + * @var string $badgeStatus1 + * @var string $badgeStatus4 + * @var string $badgeStatus5 + * @var string $badgeStatus6 + * @var string $badgeStatus8 + * @var string $badgeStatus9 + */ + include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -106,7 +116,6 @@ if ($conf->use_javascript_ajax) { $colorseries = array(); $vals = array(); - include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; while ($i < $num) { $obj = $db->fetch_object($resql); @@ -145,22 +154,20 @@ if ($conf->use_javascript_ajax) { print "\n"; } } - if ($conf->use_javascript_ajax) { - print ''; + print ''; - include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; - $dolgraph = new DolGraph(); - $dolgraph->SetData($dataseries); - $dolgraph->SetDataColor(array_values($colorseries)); - $dolgraph->setShowLegend(2); - $dolgraph->setShowPercent(1); - $dolgraph->SetType(array('pie')); - $dolgraph->SetHeight('200'); - $dolgraph->draw('idgraphstatus'); - print $dolgraph->show($totalnb ? 0 : 1); + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->SetDataColor(array_values($colorseries)); + $dolgraph->setShowLegend(2); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->SetHeight('200'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($totalnb ? 0 : 1); - print ''; - } + print ''; print ""; print ""; @@ -184,8 +191,6 @@ if ($conf->use_javascript_ajax) { $colorseries = array(); $vals = array(); - include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; - while ($i < $num) { $obj = $db->fetch_object($resql); if ($obj) { @@ -229,22 +234,20 @@ if ($conf->use_javascript_ajax) { print "\n"; } } - if ($conf->use_javascript_ajax) { - print ''; + print ''; - include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; - $dolgraph = new DolGraph(); - $dolgraph->SetData($dataseries); - $dolgraph->SetDataColor(array_values($colorseries)); - $dolgraph->setShowLegend(2); - $dolgraph->setShowPercent(1); - $dolgraph->SetType(array('pie')); - $dolgraph->SetHeight('200'); - $dolgraph->draw('idgraphstatuscandidature'); - print $dolgraph->show($totalnb ? 0 : 1); + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->SetDataColor(array_values($colorseries)); + $dolgraph->setShowLegend(2); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->SetHeight('200'); + $dolgraph->draw('idgraphstatuscandidature'); + print $dolgraph->show($totalnb ? 0 : 1); - print ''; - } + print ''; print ""; print ""; @@ -258,8 +261,7 @@ print '
'; /* BEGIN MODULEBUILDER DRAFT MYOBJECT // Draft MyObject -if (isModEnabled('recruitment') && $user->rights->recruitment->read) -{ +if (isModEnabled('recruitment') && $user->rights->recruitment->read) { $langs->load("orders"); $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; diff --git a/htdocs/supplier_proposal/index.php b/htdocs/supplier_proposal/index.php index 3e9d6fe4d79..3e1873e5087 100644 --- a/htdocs/supplier_proposal/index.php +++ b/htdocs/supplier_proposal/index.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2024 Alexandre Spangaro - * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024-2025 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -115,6 +115,15 @@ if ($resql) { } $db->free($resql); + /** + * @var string $badgeStatus0 + * @var string $badgeStatus1 + * @var string $badgeStatus4 + * @var string $badgeStatus5 + * @var string $badgeStatus6 + * @var string $badgeStatus8 + * @var string $badgeStatus9 + */ include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; print '
'; diff --git a/htdocs/ticket/index.php b/htdocs/ticket/index.php index 0bffff2fcb4..3e152eeb123 100644 --- a/htdocs/ticket/index.php +++ b/htdocs/ticket/index.php @@ -112,6 +112,7 @@ $param_shownb = 'DOLUSERCOOKIE_ticket_by_status_shownb'; $param_showtot = 'DOLUSERCOOKIE_ticket_by_status_showtot'; $autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); $showtot = 0; +$shownb = 0; if (in_array('DOLUSERCOOKIE_ticket_by_status', $autosetarray)) { $endyear = GETPOSTINT($param_year); $shownb = GETPOST($param_shownb, 'alpha'); @@ -218,6 +219,16 @@ if ($result) { } } + /** + * @var string $badgeStatus0 + * @var string $badgeStatus1 + * @var string $badgeStatus3 + * @var string $badgeStatus4 + * @var string $badgeStatus5 + * @var string $badgeStatus6 + * @var string $badgeStatus8 + * @var string $badgeStatus9 + */ include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; // This define $badgeStatusX $colorseries = array(); From b54fd5ab026d158b5c835a6acedce6458fcca2e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 8 Nov 2025 11:39:24 +0100 Subject: [PATCH 2/6] clean code (#36162) --- htdocs/supplier_proposal/card.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index eb3c5930c4f..44773f6791d 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -492,9 +492,7 @@ if (empty($reshook)) { if ($id > 0) { if (isModEnabled('category')) { $categories = GETPOST('categories', 'array'); - if (method_exists($object, 'setCategories')) { - $object->setCategories($categories); - } + $object->setCategories($categories); } if (!$error) { $db->commit(); From d4d06084a5d0af7600131f75f8a7e46f5d40556f Mon Sep 17 00:00:00 2001 From: MDW Date: Sat, 8 Nov 2025 11:40:01 +0100 Subject: [PATCH 3/6] Qual: Add Typing, update language in CommonStickerGenerator class (#36161) - Added type hints for phpstan - Updated comments to English - Improved some comments --- .../class/commonstickergenerator.class.php | 170 ++++++++++++------ 1 file changed, 112 insertions(+), 58 deletions(-) diff --git a/htdocs/core/class/commonstickergenerator.class.php b/htdocs/core/class/commonstickergenerator.class.php index 85d5cd6817c..6479c58f00f 100644 --- a/htdocs/core/class/commonstickergenerator.class.php +++ b/htdocs/core/class/commonstickergenerator.class.php @@ -22,12 +22,12 @@ * along with this program. If not, see . */ -/* Inspire de PDF_Label +/* Inspired by PDF_Label * PDF_Label - PDF label editing * @package PDF_Label * @author Laurent PASSEBECQ * @copyright 2003 Laurent PASSEBECQ - * disponible ici : http://www.fpdf.org/fr/script/script29.php + * available here : http://www.fpdf.org/fr/script/script29.php */ //------------------------------------------------------------------- @@ -60,7 +60,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; /** - * Class to generate stick sheet with format Avery or other personalised + * Class to generate stick sheet with format Avery or other personalised format */ abstract class CommonStickerGenerator extends CommonDocGenerator { @@ -70,50 +70,104 @@ abstract class CommonStickerGenerator extends CommonDocGenerator public $db; /** - * @var string + * @var string Code of format */ - public $code; // Code of format + public $code; // phpcs:disable PEAR.NamingConventions.ValidVariableName.PublicUnderscore // protected - // Name of stick - protected $_Avery_Name = ''; - // Code of stick - protected $_Avery_Code = ''; - // Marge de gauche de l'etiquette - protected $_Margin_Left = 0; - // marge en haut de la page avant la premiere etiquette - protected $_Margin_Top = 0; - // Espace horizontal entre 2 bandes d'etiquettes - protected $_X_Space = 0; - // Espace vertical entre 2 bandes d'etiquettes - protected $_Y_Space = 0; - // NX Nombre d'etiquettes sur la largeur de la page - protected $_X_Number = 0; - // NY Number of labels on the height of a page - protected $_Y_Number = 0; - // width of label - protected $_Width = 0; - // Height of label - protected $_Height = 0; - // Height of characters - protected $_Char_Size = 10; - // Height by default of a line - protected $_Line_Height = 10; - // Type of metric.. Will help to calculate good values - protected $_Metric = 'mm'; - // Type of metric for the doc.. - protected $_Metric_Doc = 'mm'; - protected $_COUNTX = 1; - protected $_COUNTY = 1; - protected $_First = 1; /** - * @var ?array{name:string,paper-size:'custom'|array{0:float,1:float},orientation:string,metric:string,marginLeft:float,marginTop:float,NX:int,NY:int,SpaceX:float,SpaceY:float,width:float,height:float,font-size:int,custom_x:float,custom_y:float} + * @var string Name of the label sheet + */ + protected $_Avery_Name = ''; + + /** + * @var string Code of the labal sheet + */ + protected $_Avery_Code = ''; + + /** + * @var float Left margin of the label + */ + protected $_Margin_Left = 0; + + /** + * @var float top margin of the page before the first label + */ + protected $_Margin_Top = 0; + + /** + * @var float Horizontal space between 2 columns of labels + */ + protected $_X_Space = 0; + + /** + * @var float Vertical space between 2 rows of labels + */ + protected $_Y_Space = 0; + + /** + * @var int<0,max> NX Number of labels on the width of the page + */ + protected $_X_Number = 0; + + /** + * @var int<0,max> NY Number of labels on the height of a page + */ + protected $_Y_Number = 0; + + /** + * @var float Label Width + */ + protected $_Width = 0; + + /** + * @var float Label Height + */ + protected $_Height = 0; + + /** + * @var float Character Height + */ + protected $_Char_Size = 10; + + /** + * @var float Default Height of a line + */ + protected $_Line_Height = 10; + + /** + * @var 'in'|'mm' Type of metric.. Will help to calculate good values + */ + protected $_Metric = 'mm'; + + /** + * @var 'in'|'mm' Type of metric for the doc.. + */ + protected $_Metric_Doc = 'mm'; + + /** + * @var int<0,max> + */ + protected $_COUNTX = 1; + + /** + * @var int<0,max> + */ + protected $_COUNTY = 1; + + /** + * @var int<0,max> + */ + protected $_First = 1; + + /** + * @var ?array{name:string,paper-size:'custom'|array{0:float,1:float},orientation:string,metric:'in'|'mm',marginLeft:float,marginTop:float,NX:int<0,max>,NY:int<0,max>,SpaceX:float,SpaceY:float,width:float,height:float,font-size:int,custom_x:float,custom_y:float} */ public $Tformat; /** - * @var ?array + * @var ?array,NY:int<0,max>,SpaceX:float,SpaceY:float,width:float,height:float,font-size:int,custom_x:float,custom_y:float}> */ public $_Avery_Labels; // phpcs:enable @@ -181,8 +235,8 @@ abstract class CommonStickerGenerator extends CommonDocGenerator * @param int $y1 Y1 * @param int $x2 X2 * @param int $y2 Y2 - * @param int $epaisseur Epaisseur - * @param int $nbPointilles Nb pointilles + * @param int $epaisseur Thickness + * @param int $nbPointilles Nb of dots * @return void */ protected function _Pointille(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $nbPointilles = 15) @@ -192,7 +246,7 @@ abstract class CommonStickerGenerator extends CommonDocGenerator $length = abs($x1 - $x2); $hauteur = abs($y1 - $y2); if ($length > $hauteur) { - $Pointilles = ($length / $nbPointilles) / 2; // taille des pointilles + $Pointilles = ($length / $nbPointilles) / 2; // size of the dots } else { $Pointilles = ($hauteur / $nbPointilles) / 2; } @@ -200,9 +254,9 @@ abstract class CommonStickerGenerator extends CommonDocGenerator for ($j = $i; $j <= ($i + $Pointilles); $j++) { if ($j <= ($x2 - 1)) { // @phan-suppress-next-line PhanPluginSuspiciousParamPosition - $pdf->Line($j, $y1, $j + 1, $y1); // on trace le pointill? du haut, point par point + $pdf->Line($j, $y1, $j + 1, $y1); // we trace the top dot, point by point // @phan-suppress-next-line PhanPluginSuspiciousParamPosition - $pdf->Line($j, $y2, $j + 1, $y2); // on trace le pointill? du bas, point par point + $pdf->Line($j, $y2, $j + 1, $y2); // we trace the bottom dot, point by point } } } @@ -210,9 +264,9 @@ abstract class CommonStickerGenerator extends CommonDocGenerator for ($j = $i; $j <= ($i + $Pointilles); $j++) { if ($j <= ($y2 - 1)) { // @phan-suppress-next-line PhanPluginSuspiciousParamPosition - $pdf->Line($x1, $j, $x1, $j + 1); // on trace le pointill? du haut, point par point + $pdf->Line($x1, $j, $x1, $j + 1); // we trace the top dot, point by point // @phan-suppress-next-line PhanPluginSuspiciousParamPosition - $pdf->Line($x2, $j, $x2, $j + 1); // on trace le pointill? du bas, point par point + $pdf->Line($x2, $j, $x2, $j + 1); // we trace the bottom dot, point by point } } } @@ -221,14 +275,14 @@ abstract class CommonStickerGenerator extends CommonDocGenerator // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** - * protected Function realisant une croix aux 4 coins des cartes + * protected Function making a cross at the 4 corners of the labels * * @param TCPDF $pdf PDF reference - * @param int $x1 X1 - * @param int $y1 Y1 - * @param int $x2 X2 - * @param int $y2 Y2 - * @param float $epaisseur Epaisseur + * @param float $x1 X1 + * @param float $y1 Y1 + * @param float $x2 X2 + * @param float $y2 Y2 + * @param float $epaisseur Thickness * @param int $taille Size * @return void * @@ -241,16 +295,16 @@ abstract class CommonStickerGenerator extends CommonDocGenerator $pdf->SetLineWidth($epaisseur); $lg = $taille / 2; - // croix haut gauche + // top left cross $pdf->Line($x1, $y1 - $lg, $x1, $y1 + $lg); $pdf->Line($x1 - $lg, $y1, $x1 + $lg, $y1); - // croix bas gauche + // bottom left cross $pdf->Line($x1, $y2 - $lg, $x1, $y2 + $lg); $pdf->Line($x1 - $lg, $y2, $x1 + $lg, $y2); - // croix haut droit + // top right cross $pdf->Line($x2, $y1 - $lg, $x2, $y1 + $lg); $pdf->Line($x2 - $lg, $y1, $x2 + $lg, $y1); - // croix bas droit + // bottom right cross $pdf->Line($x2, $y2 - $lg, $x2, $y2 + $lg); $pdf->Line($x2 - $lg, $y2, $x2 + $lg, $y2); @@ -262,8 +316,8 @@ abstract class CommonStickerGenerator extends CommonDocGenerator * $src and $dest must be 'in' or 'mm' * * @param float $value value - * @param string $src from ('in' or 'mm') - * @param string $dest to ('in' or 'mm') + * @param 'in'|'mm' $src from ('in' or 'mm') + * @param 'in'|'mm' $dest to ('in' or 'mm') * @return float value value after conversion */ private function convertMetric($value, $src, $dest) @@ -305,7 +359,7 @@ abstract class CommonStickerGenerator extends CommonDocGenerator * protected Set format * * @param TCPDF $pdf PDF reference - * @param array{metric:string,name:string,code?:string,marginLeft:float,marginTop:float,SpaceX:float,SpaceY:float,NX:int,NY:int,width:float,height:float,font-size:int} $format Format + * @param array{metric:'in'|'mm',name:string,code?:string,marginLeft:float,marginTop:float,SpaceX:float,SpaceY:float,NX:int<0,max>,NY:int<0,max>,width:float,height:float,font-size:int} $format Format * @return void */ protected function _Set_Format(&$pdf, $format) From cbaf4e3791fdeba1b05450107605f7fee64c9f90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 8 Nov 2025 11:40:51 +0100 Subject: [PATCH 4/6] clean code (#36163) --- htdocs/partnership/partnership_card.php | 72 ++++++++++++------------- 1 file changed, 34 insertions(+), 38 deletions(-) diff --git a/htdocs/partnership/partnership_card.php b/htdocs/partnership/partnership_card.php index b466b5b0808..b348d2d7743 100644 --- a/htdocs/partnership/partnership_card.php +++ b/htdocs/partnership/partnership_card.php @@ -151,28 +151,26 @@ if (empty($reshook)) { if ($result >= 0) { // Define output language if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { - if (method_exists($object, 'generateDocument')) { - $outputlangs = $langs; - $newlang = ''; - if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) { - $newlang = GETPOST('lang_id', 'aZ09'); - } - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { - $newlang = $object->thirdparty->default_lang; - } - if (!empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } + $outputlangs = $langs; + $newlang = ''; + if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } - $ret = $object->fetch($id); // Reload to get new records + $ret = $object->fetch($id); // Reload to get new records - $model = $object->model_pdf; + $model = $object->model_pdf; - $retgen = $object->generateDocument($model, $outputlangs, 0, 0, 0); - if ($retgen < 0) { - setEventMessages($object->error, $object->errors, 'warnings'); - } + $retgen = $object->generateDocument($model, $outputlangs, 0, 0, 0); + if ($retgen < 0) { + setEventMessages($object->error, $object->errors, 'warnings'); } } } else { @@ -183,28 +181,26 @@ if (empty($reshook)) { if ($result >= 0) { // Define output language if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { - if (method_exists($object, 'generateDocument')) { - $outputlangs = $langs; - $newlang = ''; - if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) { - $newlang = GETPOST('lang_id', 'aZ09'); - } - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { - $newlang = $object->thirdparty->default_lang; - } - if (!empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } + $outputlangs = $langs; + $newlang = ''; + if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } - $ret = $object->fetch($id); // Reload to get new records + $ret = $object->fetch($id); // Reload to get new records - $model = $object->model_pdf; + $model = $object->model_pdf; - $retgen = $object->generateDocument($model, $outputlangs, 0, 0, 0); - if ($retgen < 0) { - setEventMessages($object->error, $object->errors, 'warnings'); - } + $retgen = $object->generateDocument($model, $outputlangs, 0, 0, 0); + if ($retgen < 0) { + setEventMessages($object->error, $object->errors, 'warnings'); } } } else { From 4ee6aebbbf029fcfc6de57d54ebc4a063c8e74c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 8 Nov 2025 11:41:07 +0100 Subject: [PATCH 5/6] clean code (#36164) --- htdocs/don/card.php | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 61eeb500220..4720930b009 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -151,26 +151,24 @@ if (empty($reshook)) { if ($result >= 0) { // Define output language if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { - if (method_exists($object, 'generateDocument')) { - $outputlangs = $langs; - $newlang = ''; - if (getDolGlobalInt('MAIN_MULTILANGS') && GETPOST('lang_id', 'aZ09')) { - $newlang = GETPOST('lang_id', 'aZ09'); - } - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { - $newlang = $object->thirdparty->default_lang; - } - if (!empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model = $object->model_pdf; - $ret = $object->fetch($id); // Reload to get new records - $hidedetails = 0; - $hidedesc = 0; - $hideref = 0; - $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + $outputlangs = $langs; + $newlang = ''; + if (getDolGlobalInt('MAIN_MULTILANGS') && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); } + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model = $object->model_pdf; + $ret = $object->fetch($id); // Reload to get new records + $hidedetails = 0; + $hidedesc = 0; + $hideref = 0; + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } header("Location: ".$_SERVER["PHP_SELF"].'?id='.$object->id); From 936b3cddfbd9f65e314f1311a0082e2aca17d422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 8 Nov 2025 11:57:22 +0100 Subject: [PATCH 6/6] fix common delete (#36167) --- htdocs/core/class/commonobject.class.php | 1 + htdocs/core/lib/functions.lib.php | 3 +++ 2 files changed, 4 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a723d3e6a47..1b306e41960 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -11054,6 +11054,7 @@ abstract class CommonObject if (!$error) { $dir = getMultidirOutput($this)."/".dol_sanitizeFileName($this->ref); // For remove dir + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; if (dol_is_dir($dir)) { if (!dol_delete_dir_recursive($dir)) { $this->errors[] = 'ErrorFailToDeleteDir'; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 366afdaaae1..85ecaa63815 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -158,6 +158,9 @@ function getMultidirOutput($object, $module = '', $forobject = 0, $mode = 'outpu } elseif ($module == 'recruitmentcandidature') { $module = 'recruitment'; $subdirectory = '/recruitmentcandidature'; + } elseif ($module == 'knowledgerecord') { + $module = 'knowledgemanagement'; + $subdirectory = '/knowledgerecord'; } // Get the relative path of directory