From b31e85f00a7863af73e9be255a1e3e68e99448bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 20 Aug 2025 16:59:17 +0200 Subject: [PATCH 1/5] clean code (#35002) --- .../supplier_proposal/class/supplier_proposal.class.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index b833e10c3c6..3ca30943ae5 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -15,7 +15,7 @@ * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2019-2024 Frédéric France * Copyright (C) 2020 Tobias Sekan - * Copyright (C) 2022 Gauthier VERDOL + * Copyright (C) 2022 Gauthier VERDOL * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify @@ -2692,9 +2692,10 @@ class SupplierProposal extends CommonObject $this->lines[$i] = new SupplierProposalLine($this->db); $this->lines[$i]->id = $obj->rowid; // for backward compatibility - $this->lines[$i]->rowid = $obj->rowid; - $this->lines[$i]->label = $obj->custom_label; - $this->lines[$i]->description = $obj->description; + $this->lines[$i]->rowid = $obj->rowid; + $this->lines[$i]->label = $obj->custom_label; + $this->lines[$i]->description = $obj->description; // deprecated + $this->lines[$i]->desc = $obj->description; $this->lines[$i]->fk_product = $obj->fk_product; $this->lines[$i]->ref = $obj->ref; $this->lines[$i]->product_label = $obj->product_label; From 55a4b23217675c99b0b3f795e157b9e1aef9fa7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 20 Aug 2025 17:00:13 +0200 Subject: [PATCH 2/5] clean module subtotal (#35003) * clean module subtotal * Update commonsubtotal.class.php * Update subtotals.php --- htdocs/admin/subtotals.php | 16 +- .../subtotals/class/commonsubtotal.class.php | 148 +++++++++--------- 2 files changed, 85 insertions(+), 79 deletions(-) diff --git a/htdocs/admin/subtotals.php b/htdocs/admin/subtotals.php index 12d2ba229c1..910c29a9a84 100644 --- a/htdocs/admin/subtotals.php +++ b/htdocs/admin/subtotals.php @@ -56,19 +56,19 @@ $formother = new FormOther($db); $default = 'ffffff'; // Constant and translation of the module description -$modules = array( +$modules = [ 'PROPAL' => array('lang' => 'propal', 'key' => 'Proposal', 'old_pdf' => '(azur model)'), 'COMMANDE' => array('lang' => 'orders', 'key' => 'CustomerOrder', 'old_pdf' => '(einstein model)'), 'FACTURE' => array('lang' => 'bills', 'key' => 'CustomerInvoice', 'old_pdf' => '(crabe model)'), 'FACTUREREC' => array('lang' => 'bills', 'key' => 'RecurringInvoiceTemplate'), -); +]; // Conditions for the option to be offered -$conditions = array( - 'PROPAL' => (isModEnabled("propal")), - 'COMMANDE' => (isModEnabled("order")), - 'FACTURE' => (isModEnabled("invoice")), - 'FACTUREREC' => (isModEnabled("invoice")), -); +$conditions = [ + 'PROPAL' => isModEnabled("propal"), + 'COMMANDE' => isModEnabled("order"), + 'FACTURE' => isModEnabled("invoice"), + 'FACTUREREC' => isModEnabled("invoice"), +]; $max_depth = 0; diff --git a/htdocs/subtotals/class/commonsubtotal.class.php b/htdocs/subtotals/class/commonsubtotal.class.php index 5a42d713d63..5f34ee11247 100644 --- a/htdocs/subtotals/class/commonsubtotal.class.php +++ b/htdocs/subtotals/class/commonsubtotal.class.php @@ -493,7 +493,13 @@ trait CommonSubtotal { $current_module = $this->element; // Ensure the object is one of the supported types - $allowed_types = array('propal', 'commande', 'facture', 'facturerec', 'shipping'); + $allowed_types = [ + 'propal', + 'commande', + 'facture', + 'facturerec', + 'shipping', + ]; if (!in_array($current_module, $allowed_types)) { if (isset($this->errors)) { $this->errors[] = $langs->trans("UnsupportedModuleError"); @@ -512,78 +518,78 @@ trait CommonSubtotal return 1; } } else { - if ($current_module == 'facture') { - $result = $this->updateline( // @phpstan-ignore-line - $this->lines[$i]->id, // @phpstan-ignore-line - $this->lines[$i]->desc, // @phpstan-ignore-line - $this->lines[$i]->subprice, // @phpstan-ignore-line - $this->lines[$i]->qty, // @phpstan-ignore-line - $mode == 'discount' ? $value : $this->lines[$i]->remise_percent, // @phpstan-ignore-line - $this->lines[$i]->date_start, // @phpstan-ignore-line - $this->lines[$i]->date_end, // @phpstan-ignore-line - $mode == 'tva' ? $value : $this->lines[$i]->tva_tx, // @phpstan-ignore-line - $this->lines[$i]->localtax1_tx, // @phpstan-ignore-line - $this->lines[$i]->localtax2_tx, // @phpstan-ignore-line - 'HT', // @phpstan-ignore-line - $this->lines[$i]->info_bits, // @phpstan-ignore-line - $this->lines[$i]->product_type, // @phpstan-ignore-line - $this->lines[$i]->fk_parent_line, 0, // @phpstan-ignore-line - $this->lines[$i]->fk_fournprice, // @phpstan-ignore-line - $this->lines[$i]->pa_ht, // @phpstan-ignore-line - $this->lines[$i]->label, // @phpstan-ignore-line - $this->lines[$i]->special_code, // @phpstan-ignore-line - $this->lines[$i]->array_options, // @phpstan-ignore-line - $this->lines[$i]->situation_percent, // @phpstan-ignore-line - $this->lines[$i]->fk_unit, // @phpstan-ignore-line - $this->lines[$i]->multicurrency_subprice // @phpstan-ignore-line + if ($current_module == 'facture' && $this instanceof Facture) { + $result = $this->updateline( + $this->lines[$i]->id, + $this->lines[$i]->desc, + $this->lines[$i]->subprice, + $this->lines[$i]->qty, + $mode == 'discount' ? $value : $this->lines[$i]->remise_percent, + $this->lines[$i]->date_start, + $this->lines[$i]->date_end, + $mode == 'tva' ? $value : $this->lines[$i]->tva_tx, + $this->lines[$i]->localtax1_tx, + $this->lines[$i]->localtax2_tx, + 'HT', + $this->lines[$i]->info_bits, + $this->lines[$i]->product_type, + $this->lines[$i]->fk_parent_line, 0, + $this->lines[$i]->fk_fournprice, + $this->lines[$i]->pa_ht, + $this->lines[$i]->label, + $this->lines[$i]->special_code, + $this->lines[$i]->array_options, + $this->lines[$i]->situation_percent, + $this->lines[$i]->fk_unit, + $this->lines[$i]->multicurrency_subprice ); - } elseif ($current_module == 'commande') { - $result = $this->updateline( // @phpstan-ignore-line - $this->lines[$i]->id, // @phpstan-ignore-line - $this->lines[$i]->desc, // @phpstan-ignore-line - $this->lines[$i]->subprice, // @phpstan-ignore-line - $this->lines[$i]->qty, // @phpstan-ignore-line - $mode == 'discount' ? $value : $this->lines[$i]->remise_percent, // @phpstan-ignore-line - $mode == 'tva' ? $value : $this->lines[$i]->tva_tx, // @phpstan-ignore-line - $this->lines[$i]->localtax1_rate, // @phpstan-ignore-line - $this->lines[$i]->localtax2_rate, // @phpstan-ignore-line - 'HT', // @phpstan-ignore-line - $this->lines[$i]->info_bits, // @phpstan-ignore-line - $this->lines[$i]->date_start, // @phpstan-ignore-line - $this->lines[$i]->date_end, // @phpstan-ignore-line - $this->lines[$i]->product_type, // @phpstan-ignore-line - $this->lines[$i]->fk_parent_line, 0, // @phpstan-ignore-line - $this->lines[$i]->fk_fournprice, // @phpstan-ignore-line - $this->lines[$i]->pa_ht, // @phpstan-ignore-line - $this->lines[$i]->label, // @phpstan-ignore-line - $this->lines[$i]->special_code, // @phpstan-ignore-line - $this->lines[$i]->array_options, // @phpstan-ignore-line - $this->lines[$i]->fk_unit, // @phpstan-ignore-line - $this->lines[$i]->multicurrency_subprice // @phpstan-ignore-line + } elseif ($current_module == 'commande' && $this instanceof Commande) { + $result = $this->updateline( + $this->lines[$i]->id, + $this->lines[$i]->desc, + $this->lines[$i]->subprice, + $this->lines[$i]->qty, + $mode == 'discount' ? $value : $this->lines[$i]->remise_percent, + $mode == 'tva' ? $value : $this->lines[$i]->tva_tx, + $this->lines[$i]->localtax1_rate, + $this->lines[$i]->localtax2_rate, + 'HT', + $this->lines[$i]->info_bits, + $this->lines[$i]->date_start, + $this->lines[$i]->date_end, + $this->lines[$i]->product_type, + $this->lines[$i]->fk_parent_line, 0, + $this->lines[$i]->fk_fournprice, + $this->lines[$i]->pa_ht, + $this->lines[$i]->label, + $this->lines[$i]->special_code, + $this->lines[$i]->array_options, + $this->lines[$i]->fk_unit, + $this->lines[$i]->multicurrency_subprice ); - } elseif ($current_module == 'propal') { - $result = $this->updateline( // @phpstan-ignore-line - $this->lines[$i]->id, // @phpstan-ignore-line - $this->lines[$i]->subprice, // @phpstan-ignore-line - $this->lines[$i]->qty, // @phpstan-ignore-line - $mode == 'discount' ? $value : $this->lines[$i]->remise_percent, // @phpstan-ignore-line - $mode == 'tva' ? $value : $this->lines[$i]->tva_tx, // @phpstan-ignore-line - $this->lines[$i]->localtax1_rate, // @phpstan-ignore-line - $this->lines[$i]->localtax2_rate, // @phpstan-ignore-line - $this->lines[$i]->desc, // @phpstan-ignore-line - 'HT', // @phpstan-ignore-line - $this->lines[$i]->info_bits, // @phpstan-ignore-line - $this->lines[$i]->special_code, // @phpstan-ignore-line - $this->lines[$i]->fk_parent_line, 0, // @phpstan-ignore-line - $this->lines[$i]->fk_fournprice, // @phpstan-ignore-line - $this->lines[$i]->pa_ht, // @phpstan-ignore-line - $this->lines[$i]->label, // @phpstan-ignore-line - $this->lines[$i]->product_type, // @phpstan-ignore-line - $this->lines[$i]->date_start, // @phpstan-ignore-line - $this->lines[$i]->date_end, // @phpstan-ignore-line - $this->lines[$i]->array_options, // @phpstan-ignore-line - $this->lines[$i]->fk_unit, // @phpstan-ignore-line - $this->lines[$i]->multicurrency_subprice // @phpstan-ignore-line + } elseif ($current_module == 'propal' && $this instanceof Propal) { + $result = $this->updateline( + $this->lines[$i]->id, + $this->lines[$i]->subprice, + $this->lines[$i]->qty, + $mode == 'discount' ? $value : $this->lines[$i]->remise_percent, + $mode == 'tva' ? $value : $this->lines[$i]->tva_tx, + $this->lines[$i]->localtax1_rate, + $this->lines[$i]->localtax2_rate, + $this->lines[$i]->desc, + 'HT', + $this->lines[$i]->info_bits, + $this->lines[$i]->special_code, + $this->lines[$i]->fk_parent_line, 0, + $this->lines[$i]->fk_fournprice, + $this->lines[$i]->pa_ht, + $this->lines[$i]->label, + $this->lines[$i]->product_type, + $this->lines[$i]->date_start, + $this->lines[$i]->date_end, + $this->lines[$i]->array_options, + $this->lines[$i]->fk_unit, + $this->lines[$i]->multicurrency_subprice ); } if ($result < 0) { From 8075cb8dba06be2cf303cacb674ffc54590349aa Mon Sep 17 00:00:00 2001 From: Kusco Date: Wed, 20 Aug 2025 17:02:09 +0200 Subject: [PATCH 3/5] FIX Updated rights management in ModuleBuilder Tabs (#34989) * Update modMyModule.class.php Actualisation de la gestion des droits dans les Tabs du ModuleBuilder * Update modMyModule.class.php * Update modMyModule.class.php * Update modMyModule.class.php * Update modMyModule.class.php --------- Co-authored-by: Laurent Destailleur --- .../template/core/modules/modMyModule.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 25b5733b467..5d9ebad18d9 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -188,13 +188,14 @@ class modMyModule extends DolibarrModules // Array to add new pages in new tabs /* BEGIN MODULEBUILDER TABS */ + // Don't forget to deactivate/reactivate your module to test your changes $this->tabs = array(); /* END MODULEBUILDER TABS */ // Example: // To add a new tab identified by code tabname1 - // $this->tabs[] = array('data' => 'objecttype:+tabname1:Title1:mylangfile@mymodule:$user->hasRight(\'mymodule\', \'read\'):/mymodule/mynewtab1.php?id=__ID__'); + // $this->tabs[] = array('data' => 'objecttype:+tabname1:Title1:mylangfile@mymodule:$user->hasRight('mymodule', 'myobject', 'read'):/mymodule/mynewtab1.php?id=__ID__'); // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. - // $this->tabs[] = array('data' => 'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@mymodule:$user->hasRight(\'othermodule\', \'read\'):/mymodule/mynewtab2.php?id=__ID__', + // $this->tabs[] = array('data' => 'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@mymodule:$user->hasRight('othermodule', 'otherobject', 'read'):/mymodule/mynewtab2.php?id=__ID__', // To remove an existing tab identified by code tabname // $this->tabs[] = array('data' => 'objecttype:-tabname:NU:conditiontoremove'); // From 55fb75daddd17c50dde11bde0c22871b3ebeab3a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 20 Aug 2025 17:02:22 +0200 Subject: [PATCH 4/5] PHPStan > Update baseline (#35004) Co-authored-by: Dolibot --- dev/build/phpstan/phpstan-baseline.neon | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/dev/build/phpstan/phpstan-baseline.neon b/dev/build/phpstan/phpstan-baseline.neon index 8524e7ffce4..98d1fd36fa9 100644 --- a/dev/build/phpstan/phpstan-baseline.neon +++ b/dev/build/phpstan/phpstan-baseline.neon @@ -2040,12 +2040,6 @@ parameters: count: 1 path: ../../../htdocs/asset/tpl/depreciation_view.tpl.php - - - message: '#^Variable \$object might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/asset/tpl/linkedobjectblock.tpl.php - - message: '#^Right side of && is always true\.$#' identifier: booleanAnd.rightAlwaysTrue @@ -2184,12 +2178,6 @@ parameters: count: 1 path: ../../../htdocs/bom/class/bom.class.php - - - message: '#^Variable \$object might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../../htdocs/bom/tpl/linkedobjectblock.tpl.php - - message: '#^Call to function is_object\(\) with BOMLine will always evaluate to true\.$#' identifier: function.alreadyNarrowedType From 013d8c6c91f740eff89c0823c8ce1fdc715d1acb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 20 Aug 2025 17:05:35 +0200 Subject: [PATCH 5/5] clean code (#35009) --- htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php b/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php index 3a2f27b6847..adc547c8dbf 100644 --- a/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php @@ -1,8 +1,8 @@ - * Copyright (C) 2014 Marcos García - * Copyright (C) 2015 Charlie Benke - * Copyright (C) 2016 Laurent Destailleur +/* Copyright (C) 2010-2011 Regis Houssin + * Copyright (C) 2014 Marcos García + * Copyright (C) 2015 Charlie Benke + * Copyright (C) 2016 Laurent Destailleur * Copyright (C) 2024 MDW * Copyright (C) 2025 Frédéric France * @@ -53,7 +53,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { } ?> trans("SupplierInvoice"); ?> - trans("ShowBill"), "bill").' '.$objectlink->ref; ?> + getNomUrl(1) ?> ref_supplier; ?> date, 'day'); ?> $objectlink) { if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) { $sign = -1; } - if ($objectlink->statut != 3) { + if ($objectlink->status != 3) { // If not abandoned $total += $sign * $objectlink->total_ht; echo price($objectlink->total_ht);