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 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/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); 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'); // 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) { 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;