From 9535baf6d2ebb4fbb02c533b59da5afc5c066a15 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 9 Jan 2025 18:33:26 +0100 Subject: [PATCH 01/20] Fix : getRights has been replaced by loadRights in V20 --- dev/initdata/generate-invoice.php | 2 +- dev/initdata/generate-order.php | 2 +- dev/initdata/generate-proposal.php | 2 +- test/phpunit/SupplierProposalTest.php | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dev/initdata/generate-invoice.php b/dev/initdata/generate-invoice.php index 3f4a701b0c4..2cd9ecbcae5 100755 --- a/dev/initdata/generate-invoice.php +++ b/dev/initdata/generate-invoice.php @@ -150,7 +150,7 @@ while ($i < GEN_NUMBER_FACTURE && $result >= 0) { $fuser = new User($db); $fuser->fetch(mt_rand(1, 2)); - $fuser->getRights(); + $fuser->loadRights(); $result=$object->create($fuser); if ($result >= 0) { diff --git a/dev/initdata/generate-order.php b/dev/initdata/generate-order.php index fc110907ce5..c08675468c1 100755 --- a/dev/initdata/generate-order.php +++ b/dev/initdata/generate-order.php @@ -180,7 +180,7 @@ for ($s = 0; $s < GEN_NUMBER_COMMANDE; $s++) { $fuser = new User($db); $fuser->fetch($listofuserid[mt_rand(0, 2)]); - $fuser->getRights(); + $fuser->loadRights(); $db->begin(); diff --git a/dev/initdata/generate-proposal.php b/dev/initdata/generate-proposal.php index 59298a44e69..7d7f5f59161 100755 --- a/dev/initdata/generate-proposal.php +++ b/dev/initdata/generate-proposal.php @@ -171,7 +171,7 @@ while ($i < GEN_NUMBER_PROPAL && $result >= 0) { $fuser = new User($db); $fuser->fetch(mt_rand(1, 2)); - $fuser->getRights(); + $fuser->loadRights(); $object->contactid = $contids[$socids[$socid]][0]; $object->socid = $socids[$socid]; diff --git a/test/phpunit/SupplierProposalTest.php b/test/phpunit/SupplierProposalTest.php index 437857d8381..213938f4a38 100644 --- a/test/phpunit/SupplierProposalTest.php +++ b/test/phpunit/SupplierProposalTest.php @@ -88,7 +88,7 @@ class SupplierProposalTest extends CommonClassTest // Set permission not set by default sql sample $user->addrights(0, 'supplier_proposal'); - $user->getrights('supplier_proposal', 1); + $user->loadRights('supplier_proposal', 1); } /** @@ -183,7 +183,7 @@ class SupplierProposalTest extends CommonClassTest $result = $user->addrights(0, 'supplier_proposal'); $this->assertLessThan($result, 0); - $result = $user->getrights('supplier_proposal', 1); + $result = $user->loadRights('supplier_proposal', 1); //$this->assertLessThan($result, 0); $result = $localobject->valid($user); From ba2dab2a443bb0b1e94780aaf524d4ce1b22cec3 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 10 Jan 2025 16:56:14 +0100 Subject: [PATCH 02/20] =?UTF-8?q?NEW=20:=20auto-detect=20country=20from=20?= =?UTF-8?q?code=20in=20creation=09(follow-up=E2=81=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/adherents/class/adherent.class.php | 5 +++++ htdocs/compta/bank/class/account.class.php | 10 ++++++++++ htdocs/contact/class/contact.class.php | 5 +++++ htdocs/product/class/product.class.php | 4 ++++ htdocs/product/stock/class/entrepot.class.php | 9 +++++++++ htdocs/societe/class/societe.class.php | 10 +++++----- htdocs/user/class/user.class.php | 5 +++++ 7 files changed, 43 insertions(+), 5 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 0e168adddb2..78d9e15da87 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -761,6 +761,11 @@ class Adherent extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } + $nbrowsaffected = 0; $error = 0; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index d3d0c3c2ddf..45a30fdef82 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -760,6 +760,11 @@ class Account extends CommonObject $this->status = $this->clos; } + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } + // Load the library to validate/check a BAN account require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; @@ -900,6 +905,11 @@ class Account extends CommonObject { global $langs, $conf; + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } + $error = 0; $this->db->begin(); diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index f6acb419e47..83693e150ae 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -605,6 +605,11 @@ class Contact extends CommonObject { global $conf; + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } + $error = 0; $this->id = $id; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 0862b6b1d93..bc6f1df89f2 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1423,6 +1423,10 @@ class Product extends CommonObject if (empty($this->country_id)) { $this->country_id = 0; } + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } if (empty($this->state_id)) { $this->state_id = 0; diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 3ca48bbd39d..76ddc84ecfb 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -255,6 +255,10 @@ class Entrepot extends CommonObject $this->error = "ErrorFieldRequired"; return 0; } + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } $now = dol_now(); @@ -325,6 +329,11 @@ class Entrepot extends CommonObject */ public function update($id, $user, $notrigger = 0) { + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } + $error = 0; if (empty($id)) { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 1d7278399d1..26ec7f44992 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1010,11 +1010,6 @@ class Societe extends CommonObject $this->fk_multicurrency = 0; } - if (empty($this->country_id) && !empty($this->country_code)) { - $country_id = getCountry($this->country_code, '3'); - $this->country_id = is_int($country_id) ? $country_id : 0; - } - dol_syslog(get_class($this)."::create ".$this->name); $now = dol_now(); @@ -1441,6 +1436,11 @@ class Societe extends CommonObject $id = $this->id; } + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } + $error = 0; dol_syslog(get_class($this)."::Update id=".$id." call_trigger=".$call_trigger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 1ea16d01c17..549bbb4454d 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2096,6 +2096,11 @@ class User extends CommonObject { global $conf, $langs; + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } + $nbrowsaffected = 0; $error = 0; From 9cd495438aea12bcee9c72806942b6d2d39af67c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 14 Jan 2025 08:35:48 +0100 Subject: [PATCH 03/20] FIX split data and rename files (Multicompany compatibility) --- .../mysql/data/llx_accounting_journal.sql | 57 +++++++++++++++++++ ...ting_abc.sql => llx_accounting_system.sql} | 13 +---- 2 files changed, 58 insertions(+), 12 deletions(-) create mode 100644 htdocs/install/mysql/data/llx_accounting_journal.sql rename htdocs/install/mysql/data/{llx_accounting_abc.sql => llx_accounting_system.sql} (91%) diff --git a/htdocs/install/mysql/data/llx_accounting_journal.sql b/htdocs/install/mysql/data/llx_accounting_journal.sql new file mode 100644 index 00000000000..fd5e634d66f --- /dev/null +++ b/htdocs/install/mysql/data/llx_accounting_journal.sql @@ -0,0 +1,57 @@ +-- Copyright (C) 2001-2004 Rodolphe Quiedeville +-- Copyright (C) 2003 Jean-Louis Bergamo +-- Copyright (C) 2004-2009 Laurent Destailleur +-- Copyright (C) 2004 Benoit Mortier +-- Copyright (C) 2004 Guillaume Delecourt +-- Copyright (C) 2005-2025 Regis Houssin +-- Copyright (C) 2007 Patrick Raguin +-- Copyright (C) 2011-2022 Alexandre Spangaro +-- Copyright (C) 2015-2017 Juanjo Menent +-- Copyright (C) 2018 Abbes bahfir +-- Copyright (C) 2020 Udo Tamm +-- Copyright (C) 2023 Nick Fragoulis +-- Copyright (C) 2023 Santiago Payà +-- +-- +-------------------------------------------------------------------------------------- +-- License +-- ####### +-- 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 +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-------------------------------------------------------------------------------------- + +-- Comment +-- ####### +-- (EN) +-- Do not place a comment at the end of the line, this file is parsed at the end of the line. +-- from the install and all '--' are removed. +-- +-- (FR) +-- Ne pas placer de commentaire en fin de ligne, ce fichier est parsé lors +-- de l'install et tous les sigles '--' sont supprimés. +-- +-------------------------------------------------------------------------------------- +-- PCG = Plan Comptable Général (FR) - General Accounting Plan (EN) +-------------------------------------------------------------------------------------- + + +-- Accounting Journals + +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('VT', 'ACCOUNTING_SELL_JOURNAL', 2, 1, __ENTITY__); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('AC', 'ACCOUNTING_PURCHASE_JOURNAL', 3, 1, __ENTITY__); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('BQ', 'FinanceJournal', 4, 1, __ENTITY__); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('OD', 'ACCOUNTING_MISCELLANEOUS_JOURNAL', 1, 1, __ENTITY__); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('AN', 'ACCOUNTING_HAS_NEW_JOURNAL', 9, 1, __ENTITY__); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('ER', 'ExpenseReportsJournal', 5, 1, __ENTITY__); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('INV', 'InventoryJournal', 8, 1, __ENTITY__); diff --git a/htdocs/install/mysql/data/llx_accounting_abc.sql b/htdocs/install/mysql/data/llx_accounting_system.sql similarity index 91% rename from htdocs/install/mysql/data/llx_accounting_abc.sql rename to htdocs/install/mysql/data/llx_accounting_system.sql index d748aa7f4fa..2def811073e 100644 --- a/htdocs/install/mysql/data/llx_accounting_abc.sql +++ b/htdocs/install/mysql/data/llx_accounting_system.sql @@ -3,7 +3,7 @@ -- Copyright (C) 2004-2009 Laurent Destailleur -- Copyright (C) 2004 Benoit Mortier -- Copyright (C) 2004 Guillaume Delecourt --- Copyright (C) 2005-2009 Regis Houssin +-- Copyright (C) 2005-2025 Regis Houssin -- Copyright (C) 2007 Patrick Raguin -- Copyright (C) 2011-2022 Alexandre Spangaro -- Copyright (C) 2015-2017 Juanjo Menent @@ -46,17 +46,6 @@ -------------------------------------------------------------------------------------- --- Accounting Journals - -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('VT', 'ACCOUNTING_SELL_JOURNAL', 2, 1, 1); -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('AC', 'ACCOUNTING_PURCHASE_JOURNAL', 3, 1, 1); -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('BQ', 'FinanceJournal', 4, 1, 1); -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('OD', 'ACCOUNTING_MISCELLANEOUS_JOURNAL', 1, 1, 1); -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('AN', 'ACCOUNTING_HAS_NEW_JOURNAL', 9, 1, 1); -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('ER', 'ExpenseReportsJournal', 5, 1, 1); -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('INV', 'InventoryJournal', 8, 1, 1); - - -- Accounting Charts / Plans (Templates) for Countries -- Description of chart of account FR PCG25-DEV From 5d6c8690b948aea562b26bfffa1b82928a4f61be Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 14 Jan 2025 09:14:55 +0100 Subject: [PATCH 04/20] FIX to avoid postgresql error --- htdocs/install/mysql/tables/llx_blockedlog.key.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_blockedlog.key.sql b/htdocs/install/mysql/tables/llx_blockedlog.key.sql index 065be82aba1..811a1b1d2b0 100644 --- a/htdocs/install/mysql/tables/llx_blockedlog.key.sql +++ b/htdocs/install/mysql/tables/llx_blockedlog.key.sql @@ -22,4 +22,6 @@ ALTER TABLE llx_blockedlog ADD INDEX entity (entity); ALTER TABLE llx_blockedlog ADD INDEX fk_user (fk_user); ALTER TABLE llx_blockedlog ADD INDEX entity_action_certified (entity,action,certified); -ALTER TABLE llx_blockedlog ADD INDEX entity_rowid (entity, rowid); -- for the "SELECT rowid, signature FROM llx_blockedlog FORCE INDEX entity_rowid WHERE entity = x AND rowid < z ORDER BY rowid DESC" +-- for the "SELECT rowid, signature FROM llx_blockedlog FORCE INDEX entity_rowid WHERE entity = x AND rowid < z ORDER BY rowid DESC" + +ALTER TABLE llx_blockedlog ADD INDEX entity_rowid (entity, rowid); From d39ef7b75203bdf8613d5f9bfa559c8795d378e9 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 19 Jan 2025 13:18:36 +0100 Subject: [PATCH 05/20] NEW add creditnotelist var in fetch --- htdocs/compta/facture/card.php | 11 +++++------ htdocs/compta/facture/class/facture.class.php | 4 ++++ htdocs/compta/facture/prelevement.php | 13 ++++++------- htdocs/core/class/commoninvoice.class.php | 5 +++++ htdocs/fourn/class/fournisseur.facture.class.php | 4 ++++ htdocs/fourn/facture/card.php | 11 +++++------ htdocs/fourn/facture/contact.php | 11 +++++------ htdocs/fourn/facture/document.php | 11 +++++------ htdocs/fourn/facture/note.php | 11 +++++------ 9 files changed, 44 insertions(+), 37 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index b9b152943ab..a5feab87d9b 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4743,19 +4743,18 @@ if ($action == 'create') { print ' '.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1, '', 32)).''; } - $facidavoir = $object->getListIdAvoirFromInvoice(); - if (count($facidavoir) > 0) { + if (!empty($object->creditnotelist)) { print ' '.$langs->transnoentities("InvoiceHasAvoir"); $i = 0; - foreach ($facidavoir as $id) { + foreach ($object->creditnotelist as $invoiceid) { if ($i == 0) { print ' '; } else { print ','; } - $facavoir = new Facture($db); - $facavoir->fetch($id); - print $facavoir->getNomUrl(1, '', 32); + $creditnote = new Facture($db); + $creditnote->fetch($id); + print $creditnote->getNomUrl(1, '', 32); } print ''; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 179385b1aba..d48dc07bf53 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2300,6 +2300,10 @@ class Facture extends CommonInvoice $this->multicurrency_total_tva = $obj->multicurrency_total_tva; $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; + if ($this->type != self::TYPE_CREDIT_NOTE) { + $this->creditnotelist = $this->getListIdAvoirFromInvoice(); + } + if (($this->type == self::TYPE_SITUATION || ($this->type == self::TYPE_CREDIT_NOTE && $this->situation_cycle_ref > 0)) && $fetch_situation) { $this->fetchPreviousNextSituationInvoice(); } diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 50a513a994f..b9b060ccc96 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -439,17 +439,16 @@ if ($object->id > 0) { print ' '.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).''; } - $facidavoir = $object->getListIdAvoirFromInvoice(); - if (count($facidavoir) > 0) { + if (!empty($object->creditnotelist)) { $invoicecredits = array(); - foreach ($facidavoir as $facid) { + foreach (!empty($object->creditnotelist) as $invoiceid) { if ($type == 'bank-transfer') { - $facavoir = new FactureFournisseur($db); + $creditnote = new FactureFournisseur($db); } else { - $facavoir = new Facture($db); + $creditnote = new Facture($db); } - $facavoir->fetch($facid); - $invoicecredits[] = $facavoir->getNomUrl(1); + $creditnote->fetch($invoiceid); + $invoicecredits[] = $creditnote->getNomUrl(1); } print ' '.$langs->transnoentities("InvoiceHasAvoir"); print ' '. (count($invoicecredits) ? ' ' : '') . implode(',', $invoicecredits); diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 321533eb28d..bd2fec6d460 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -162,6 +162,11 @@ abstract class CommonInvoice extends CommonObject */ public $nbofopendirectdebitorcredittransfer; + /** + * @var string[] return of getListIdAvoirFromInvoice() + */ + public $creditnotelist; + /** * @var int */ diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index dab5dea6d6c..128694f0f0d 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1013,6 +1013,10 @@ class FactureFournisseur extends CommonInvoice $this->socid = $obj->socid; + if ($this->type != self::TYPE_CREDIT_NOTE) { + $this->creditnotelist = $this->getListIdAvoirFromInvoice(); + } + // Retrieve all extrafield // fetch optionals attributes and labels $this->fetch_optionals(); diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 39d971bba99..0ed41bb4682 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -3339,13 +3339,12 @@ if ($action == 'create') { } } - $facidavoir = $object->getListIdAvoirFromInvoice(); - if (count($facidavoir) > 0) { + if (!empty($object->creditnotelist)) { $invoicecredits = array(); - foreach ($facidavoir as $id) { - $facavoir = new FactureFournisseur($db); - $facavoir->fetch($id); - $invoicecredits[] = $facavoir->getNomUrl(1); + foreach ($object->creditnotelist as $invoiceid) { + $creditnote = new FactureFournisseur($db); + $creditnote->fetch($invoiceid); + $invoicecredits[] = $creditnote->getNomUrl(1); } print ' '.$langs->transnoentities("InvoiceHasAvoir") . (count($invoicecredits) ? ' ' : '') . implode(',', $invoicecredits); print ''; diff --git a/htdocs/fourn/facture/contact.php b/htdocs/fourn/facture/contact.php index d15646059f3..fe65695eb20 100644 --- a/htdocs/fourn/facture/contact.php +++ b/htdocs/fourn/facture/contact.php @@ -211,13 +211,12 @@ if ($id > 0 || !empty($ref)) { print ' '.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)); } - $facidavoir = $object->getListIdAvoirFromInvoice(); - if (count($facidavoir) > 0) { + if (!empty($object->creditnotelist)) { $invoicecredits = array(); - foreach ($facidavoir as $facid) { - $facavoir = new FactureFournisseur($db); - $facavoir->fetch($facid); - $invoicecredits[] = $facavoir->getNomUrl(1); + foreach ($object->creditnotelist as $invoiceid) { + $creditnote = new FactureFournisseur($db); + $creditnote->fetch($invoiceid); + $invoicecredits[] = $creditnote->getNomUrl(1); } print ' '.$langs->transnoentities("InvoiceHasAvoir") . (count($invoicecredits) ? ' ' : '') . implode(',', $invoicecredits); } diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index ddbf73ccf39..d4f22a9a4f7 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -187,13 +187,12 @@ if ($object->id > 0) { print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')'; } - $facidavoir = $object->getListIdAvoirFromInvoice(); - if (count($facidavoir) > 0) { + if (!empty($object->creditnotelist)) { $invoicecredits = array(); - foreach ($facidavoir as $facid) { - $facavoir = new FactureFournisseur($db); - $facavoir->fetch($facid); - $invoicecredits[] = $facavoir->getNomUrl(1); + foreach ($object->creditnotelist as $invoiceid) { + $creditnote = new FactureFournisseur($db); + $creditnote->fetch($invoiceid); + $invoicecredits[] = $creditnote->getNomUrl(1); } print ' ('.$langs->transnoentities("InvoiceHasAvoir") . (count($invoicecredits) ? ' ' : '') . implode(',', $invoicecredits) . ')'; } diff --git a/htdocs/fourn/facture/note.php b/htdocs/fourn/facture/note.php index 0f9d53b18d3..fb0f024afb6 100644 --- a/htdocs/fourn/facture/note.php +++ b/htdocs/fourn/facture/note.php @@ -169,13 +169,12 @@ if ($object->id > 0) { print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')'; } - $facidavoir = $object->getListIdAvoirFromInvoice(); - if (count($facidavoir) > 0) { + if (!empty($object->creditnotelist)) { $invoicecredits = array(); - foreach ($facidavoir as $facid) { - $facavoir = new FactureFournisseur($db); - $facavoir->fetch($facid); - $invoicecredits[] = $facavoir->getNomUrl(1); + foreach ($object->creditnotelist as $invoiceid) { + $creditnote = new FactureFournisseur($db); + $creditnote->fetch($invoiceid); + $invoicecredits[] = $creditnote->getNomUrl(1); } print ' ('.$langs->transnoentities("InvoiceHasAvoir") . implode(',', $invoicecredits) . ')'; } From 313716a027bf41df0d00ea6cf5b608b93f11dba3 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 19 Jan 2025 13:21:21 +0100 Subject: [PATCH 06/20] FIX syntax error --- htdocs/compta/facture/prelevement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index b9b060ccc96..fe3b93cc597 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -441,7 +441,7 @@ if ($object->id > 0) { if (!empty($object->creditnotelist)) { $invoicecredits = array(); - foreach (!empty($object->creditnotelist) as $invoiceid) { + foreach ($object->creditnotelist as $invoiceid) { if ($type == 'bank-transfer') { $creditnote = new FactureFournisseur($db); } else { From 62b5964462185938af43bb0035fe771140aa1459 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 19 Jan 2025 13:30:09 +0100 Subject: [PATCH 07/20] FIX wrong var type --- htdocs/core/class/commoninvoice.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index bd2fec6d460..983c35512b8 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -163,7 +163,7 @@ abstract class CommonInvoice extends CommonObject public $nbofopendirectdebitorcredittransfer; /** - * @var string[] return of getListIdAvoirFromInvoice() + * @var int[] return of getListIdAvoirFromInvoice() */ public $creditnotelist; From 0f83ffe24b14ab247736b5bfe42bdfeb7d6f6185 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 19 Jan 2025 13:39:34 +0100 Subject: [PATCH 08/20] FIX phan error --- htdocs/societe/class/societeaccount.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societeaccount.class.php b/htdocs/societe/class/societeaccount.class.php index 2a6447d6ca1..b8502557547 100644 --- a/htdocs/societe/class/societeaccount.class.php +++ b/htdocs/societe/class/societeaccount.class.php @@ -346,7 +346,7 @@ class SocieteAccount extends CommonObject * @param string $site Site (example: 'stripe', '...') * @param int $status Status (0=test, 1=live, -1=we don't mind) * @param string $site_account Value to use to identify with account to use on site when site can offer several accounts. For example: 'pk_live_123456' when using Stripe service. - * @param string $fk_website Id website + * @param int $fk_website Id website * @return string Stripe customer ref 'cu_xxxxxxxxxxxxx' or '' * @see getThirdPartyID() */ From 8623166d59d22fbb5d7e5a7b244df32c9073d150 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 20 Jan 2025 06:53:03 +0100 Subject: [PATCH 09/20] FIX remove from CRUD --- htdocs/compta/facture/card.php | 9 ++++++--- htdocs/compta/facture/class/api_invoices.class.php | 6 ++++++ htdocs/compta/facture/class/facture.class.php | 4 ---- htdocs/compta/facture/prelevement.php | 7 +++++-- htdocs/core/class/commoninvoice.class.php | 5 ++++- htdocs/fourn/class/api_supplier_invoices.class.php | 13 ++++++++----- htdocs/fourn/class/fournisseur.facture.class.php | 4 ---- htdocs/fourn/facture/card.php | 7 +++++-- htdocs/fourn/facture/contact.php | 7 +++++-- htdocs/fourn/facture/document.php | 7 +++++-- htdocs/fourn/facture/note.php | 7 +++++-- 11 files changed, 49 insertions(+), 27 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index a5feab87d9b..2b6251167a8 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4743,17 +4743,20 @@ if ($action == 'create') { print ' '.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1, '', 32)).''; } - if (!empty($object->creditnotelist)) { + // Retrieve credit note ids + $object->getListIdAvoirFromInvoice(); + + if (!empty($object->creditnote_ids)) { print ' '.$langs->transnoentities("InvoiceHasAvoir"); $i = 0; - foreach ($object->creditnotelist as $invoiceid) { + foreach ($object->creditnote_ids as $invoiceid) { if ($i == 0) { print ' '; } else { print ','; } $creditnote = new Facture($db); - $creditnote->fetch($id); + $creditnote->fetch($invoiceid); print $creditnote->getNomUrl(1, '', 32); } print ''; diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 1476eb8e764..6a3171be197 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -149,6 +149,9 @@ class Invoices extends DolibarrApi throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } + // Retrieve credit note ids + $this->getListIdAvoirFromInvoice(); + // Add external contacts ids if ($contact_list > -1) { $tmparray = $this->invoice->liste_contact(-1, 'external', $contact_list); @@ -268,6 +271,9 @@ class Invoices extends DolibarrApi $invoice_static->totaldeposits = $invoice_static->getSumDepositsUsed(); $invoice_static->remaintopay = price2num($invoice_static->total_ttc - $invoice_static->totalpaid - $invoice_static->totalcreditnotes - $invoice_static->totaldeposits, 'MT'); + // Retrieve credit note ids + $invoice_static->getListIdAvoirFromInvoice(); + // Add external contacts ids $tmparray = $invoice_static->liste_contact(-1, 'external', 1); if (is_array($tmparray)) { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index d48dc07bf53..179385b1aba 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2300,10 +2300,6 @@ class Facture extends CommonInvoice $this->multicurrency_total_tva = $obj->multicurrency_total_tva; $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - if ($this->type != self::TYPE_CREDIT_NOTE) { - $this->creditnotelist = $this->getListIdAvoirFromInvoice(); - } - if (($this->type == self::TYPE_SITUATION || ($this->type == self::TYPE_CREDIT_NOTE && $this->situation_cycle_ref > 0)) && $fetch_situation) { $this->fetchPreviousNextSituationInvoice(); } diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index fe3b93cc597..fd22234a7a9 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -439,9 +439,12 @@ if ($object->id > 0) { print ' '.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).''; } - if (!empty($object->creditnotelist)) { + // Retrieve credit note ids + $object->getListIdAvoirFromInvoice(); + + if (!empty($object->creditnote_ids)) { $invoicecredits = array(); - foreach ($object->creditnotelist as $invoiceid) { + foreach ($object->creditnote_ids as $invoiceid) { if ($type == 'bank-transfer') { $creditnote = new FactureFournisseur($db); } else { diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 983c35512b8..13561f2de64 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -165,7 +165,7 @@ abstract class CommonInvoice extends CommonObject /** * @var int[] return of getListIdAvoirFromInvoice() */ - public $creditnotelist; + public $creditnote_ids; /** * @var int @@ -455,6 +455,9 @@ abstract class CommonInvoice extends CommonObject } else { dol_print_error($this->db); } + + $this->creditnote_ids = $idarray; + return $idarray; } diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index 06d9efaee2a..401ee44743a 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -1,9 +1,9 @@ - * Copyright (C) 2016 Laurent Destailleur - * Copyright (C) 2023 Joachim Kueter - * Copyright (C) 2024 MDW - * Copyright (C) 2024 Frédéric France +/* Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2023 Joachim Kueter + * Copyright (C) 2024 MDW + * Copyright (C) 2024 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 @@ -82,6 +82,9 @@ class SupplierInvoices extends DolibarrApi throw new RestException(404, 'Supplier invoice not found'); } + // Retrieve credit note ids + $this->getListIdAvoirFromInvoice(); + $this->invoice->fetchObjectLinked(); return $this->_cleanObjectDatas($this->invoice); } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 128694f0f0d..dab5dea6d6c 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1013,10 +1013,6 @@ class FactureFournisseur extends CommonInvoice $this->socid = $obj->socid; - if ($this->type != self::TYPE_CREDIT_NOTE) { - $this->creditnotelist = $this->getListIdAvoirFromInvoice(); - } - // Retrieve all extrafield // fetch optionals attributes and labels $this->fetch_optionals(); diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 0ed41bb4682..ab1ce229e1f 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -3339,9 +3339,12 @@ if ($action == 'create') { } } - if (!empty($object->creditnotelist)) { + // Retrieve credit note ids + $object->getListIdAvoirFromInvoice(); + + if (!empty($object->creditnote_ids)) { $invoicecredits = array(); - foreach ($object->creditnotelist as $invoiceid) { + foreach ($object->creditnote_ids as $invoiceid) { $creditnote = new FactureFournisseur($db); $creditnote->fetch($invoiceid); $invoicecredits[] = $creditnote->getNomUrl(1); diff --git a/htdocs/fourn/facture/contact.php b/htdocs/fourn/facture/contact.php index fe65695eb20..5fd19773108 100644 --- a/htdocs/fourn/facture/contact.php +++ b/htdocs/fourn/facture/contact.php @@ -211,9 +211,12 @@ if ($id > 0 || !empty($ref)) { print ' '.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)); } - if (!empty($object->creditnotelist)) { + // Retrieve credit note ids + $object->getListIdAvoirFromInvoice(); + + if (!empty($object->creditnote_ids)) { $invoicecredits = array(); - foreach ($object->creditnotelist as $invoiceid) { + foreach ($object->creditnote_ids as $invoiceid) { $creditnote = new FactureFournisseur($db); $creditnote->fetch($invoiceid); $invoicecredits[] = $creditnote->getNomUrl(1); diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index d4f22a9a4f7..75d961308b0 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -187,9 +187,12 @@ if ($object->id > 0) { print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')'; } - if (!empty($object->creditnotelist)) { + // Retrieve credit note ids + $object->getListIdAvoirFromInvoice(); + + if (!empty($object->creditnote_ids)) { $invoicecredits = array(); - foreach ($object->creditnotelist as $invoiceid) { + foreach ($object->creditnote_ids as $invoiceid) { $creditnote = new FactureFournisseur($db); $creditnote->fetch($invoiceid); $invoicecredits[] = $creditnote->getNomUrl(1); diff --git a/htdocs/fourn/facture/note.php b/htdocs/fourn/facture/note.php index fb0f024afb6..001797dc5a6 100644 --- a/htdocs/fourn/facture/note.php +++ b/htdocs/fourn/facture/note.php @@ -169,9 +169,12 @@ if ($object->id > 0) { print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')'; } - if (!empty($object->creditnotelist)) { + // Retrieve credit note ids + $object->getListIdAvoirFromInvoice(); + + if (!empty($object->creditnote_ids)) { $invoicecredits = array(); - foreach ($object->creditnotelist as $invoiceid) { + foreach ($object->creditnote_ids as $invoiceid) { $creditnote = new FactureFournisseur($db); $creditnote->fetch($invoiceid); $invoicecredits[] = $creditnote->getNomUrl(1); From bf5e6ac88ba12122b864ca81f213cae936b5867a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 20 Jan 2025 07:00:55 +0100 Subject: [PATCH 10/20] FIX wrong API object --- htdocs/compta/facture/class/api_invoices.class.php | 2 +- htdocs/fourn/class/api_supplier_invoices.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 6a3171be197..d58000dd683 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -150,7 +150,7 @@ class Invoices extends DolibarrApi } // Retrieve credit note ids - $this->getListIdAvoirFromInvoice(); + $this->invoice->getListIdAvoirFromInvoice(); // Add external contacts ids if ($contact_list > -1) { diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index 401ee44743a..71408521d4b 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -83,7 +83,7 @@ class SupplierInvoices extends DolibarrApi } // Retrieve credit note ids - $this->getListIdAvoirFromInvoice(); + $this->invoice->getListIdAvoirFromInvoice(); $this->invoice->fetchObjectLinked(); return $this->_cleanObjectDatas($this->invoice); From e49c37106b624bcc0fbc6e67fe224172727261e5 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Mon, 20 Jan 2025 12:17:39 +0100 Subject: [PATCH 11/20] Confirmation useless --- htdocs/projet/card.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 0eb947f56a6..4fc99beac08 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1658,7 +1658,8 @@ if ($action == 'create' && $user->hasRight('projet', 'creer')) { // Validate if ($object->status == Project::STATUS_DRAFT && $user->hasRight('projet', 'creer')) { if ($userWrite > 0) { - print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER["PHP_SELF"].'?action=validate&token='.newToken().'&id='.$object->id, ''); + //print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER["PHP_SELF"].'?action=validate&token='.newToken().'&id='.$object->id, ''); + print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER["PHP_SELF"].'?action=confirm_validate&confirm=yes&token='.newToken().'&id='.$object->id, ''); } else { print dolGetButtonAction($langs->trans('NotOwnerOfProject'), $langs->trans('Validate'), 'default', $_SERVER['PHP_SELF']. '#', '', false); } @@ -1667,7 +1668,8 @@ if ($action == 'create' && $user->hasRight('projet', 'creer')) { // Close if ($object->status == Project::STATUS_VALIDATED && $user->hasRight('projet', 'creer')) { if ($userWrite > 0) { - print dolGetButtonAction('', $langs->trans('Close'), 'default', $_SERVER["PHP_SELF"].'?action=close&token='.newToken().'&id='.$object->id, ''); + //print dolGetButtonAction('', $langs->trans('Close'), 'default', $_SERVER["PHP_SELF"].'?action=close&token='.newToken().'&id='.$object->id, ''); + print dolGetButtonAction('', $langs->trans('Close'), 'default', $_SERVER["PHP_SELF"].'?action=confirm_close&confirm=yes&token='.newToken().'&id='.$object->id, ''); } else { print dolGetButtonAction($langs->trans('NotOwnerOfProject'), $langs->trans('Close'), 'default', $_SERVER['PHP_SELF']. '#', '', false); } From f7838a9459b8847e037578bed7cbcf96f47b19df Mon Sep 17 00:00:00 2001 From: Dolibot Date: Mon, 20 Jan 2025 12:06:56 +0000 Subject: [PATCH 12/20] PHPStan > Update baseline --- dev/build/phpstan/phpstan-baseline.neon | 38 +------------------------ 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/dev/build/phpstan/phpstan-baseline.neon b/dev/build/phpstan/phpstan-baseline.neon index 4e98d2d655e..3d3697f4d16 100644 --- a/dev/build/phpstan/phpstan-baseline.neon +++ b/dev/build/phpstan/phpstan-baseline.neon @@ -6576,12 +6576,6 @@ parameters: count: 1 path: ../../../htdocs/compta/sociales/card.php - - - message: '#^Variable \$resteapayer might not be defined\.$#' - identifier: variable.undefined - count: 3 - path: ../../../htdocs/compta/sociales/card.php - - message: '#^Negated boolean expression is always true\.$#' identifier: booleanNot.alwaysTrue @@ -19593,13 +19587,7 @@ parameters: - message: '#^Variable \$begin might not be defined\.$#' identifier: variable.undefined - count: 5 - path: ../../../htdocs/fourn/contact.php - - - - message: '#^Variable \$contactname might not be defined\.$#' - identifier: variable.undefined - count: 1 + count: 3 path: ../../../htdocs/fourn/contact.php - @@ -19608,12 +19596,6 @@ parameters: count: 4 path: ../../../htdocs/fourn/contact.php - - - message: '#^Variable \$stcomm might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../../htdocs/fourn/contact.php - - message: '#^If condition is always false\.$#' identifier: if.alwaysFalse @@ -22290,12 +22272,6 @@ parameters: count: 2 path: ../../../htdocs/loan/class/loanschedule.class.php - - - message: '#^Negated boolean expression is always true\.$#' - identifier: booleanNot.alwaysTrue - count: 1 - path: ../../../htdocs/loan/class/paymentloan.class.php - - message: '#^Property PaymentLoan\:\:\$amount_capital \(float\|int\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -32628,21 +32604,9 @@ parameters: count: 4 path: ../../../htdocs/website/index.php - - - message: '#^Comparison operation "\>\=" between 1 and 0 is always true\.$#' - identifier: greaterOrEqual.alwaysTrue - count: 1 - path: ../../../htdocs/website/samples/wrapper.php - - message: '#^If condition is always false\.$#' identifier: if.alwaysFalse - count: 3 - path: ../../../htdocs/website/samples/wrapper.php - - - - message: '#^If condition is always true\.$#' - identifier: if.alwaysTrue count: 1 path: ../../../htdocs/website/samples/wrapper.php From a6baef68d26a794fcd738eced7a6ec5031b71e2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Mon, 20 Jan 2025 16:18:33 +0100 Subject: [PATCH 13/20] Add ecc field on fetch for expose on api --- htdocs/core/class/ccountry.class.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php index 1d798698e84..4dca978ab64 100644 --- a/htdocs/core/class/ccountry.class.php +++ b/htdocs/core/class/ccountry.class.php @@ -1,6 +1,7 @@ - * Copyright (C) 2024 MDW + * Copyright (C) 2024 MDW + * Copyright (C) 2025 Charlene Benke * * 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 @@ -45,6 +46,12 @@ class Ccountry extends CommonDict */ public $code_iso; + /** + * @var string + */ + public $ecc; + + /** * @var array|string,position:int,notnull?:int,visible:int<-5,5>|string,alwayseditable?:int<0,1>,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,4>,disabled?:int<0,1>,arrayofkeyval?:array,autofocusoncreate?:int<0,1>,comment?:string,copytoclipboard?:int<1,2>,validate?:int<0,1>,showonheader?:int<0,1>}> */ @@ -149,6 +156,7 @@ class Ccountry extends CommonDict $sql .= " t.rowid,"; $sql .= " t.code,"; $sql .= " t.code_iso,"; + $sql .= " t.ecc,"; $sql .= " t.label,"; $sql .= " t.active"; $sql .= " FROM ".$this->db->prefix()."c_country as t"; @@ -171,6 +179,7 @@ class Ccountry extends CommonDict $this->code = $obj->code; $this->code_iso = $obj->code_iso; $this->label = $obj->label; + $this->ecc = $obj->ecc; $this->active = $obj->active; } From 3418887436503711e375b9240a3704653c231166 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Mon, 20 Jan 2025 16:40:05 +0100 Subject: [PATCH 14/20] Clean code --- htdocs/core/class/ccountry.class.php | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php index 5d75eea9fd1..81be08a78b8 100644 --- a/htdocs/core/class/ccountry.class.php +++ b/htdocs/core/class/ccountry.class.php @@ -51,30 +51,25 @@ class Ccountry extends CommonDict */ public $ecc; - - /** - * @var array|string,position:int,notnull?:int,visible:int<-5,5>|string,alwayseditable?:int<0,1>,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,4>,disabled?:int<0,1>,arrayofkeyval?:array,autofocusoncreate?:int<0,1>,comment?:string,copytoclipboard?:int<1,2>,validate?:int<0,1>,showonheader?:int<0,1>}> - */ - public $fields = array( - 'label' => array('type' => 'varchar(250)', 'label' => 'Label', 'enabled' => 1, 'visible' => 1, 'position' => 15, 'notnull' => -1, 'showoncombobox' => 1) - ); - /** * @var int */ public $favorite; - /** - * @var int - */ - public $eec; - /** * @var string */ public $numeric_code; + /** + * @var array|string,position:int,notnull?:int,visible:int<-5,5>|string,alwayseditable?:int<0,1>,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,4>,disabled?:int<0,1>,arrayofkeyval?:array,autofocusoncreate?:int<0,1>,comment?:string,copytoclipboard?:int<1,2>,validate?:int<0,1>,showonheader?:int<0,1>}> + */ + public $fields = array( + 'label' => array('type' => 'varchar(250)', 'label' => 'Label', 'enabled' => 1, 'visible' => 1, 'position' => 15, 'notnull' => -1, 'showoncombobox' => 1) + ); + + /** * Constructor * @@ -171,7 +166,6 @@ class Ccountry extends CommonDict $sql .= " t.rowid,"; $sql .= " t.code,"; $sql .= " t.code_iso,"; - $sql .= " t.ecc,"; $sql .= " t.label,"; $sql .= " t.eec,"; $sql .= " t.active,"; @@ -201,7 +195,6 @@ class Ccountry extends CommonDict $this->ecc = $obj->ecc; $this->active = $obj->active; $this->favorite = $obj->favorite; - $this->eec = $obj->eec; $this->numeric_code = $obj->numeric_code; } From adb1c58d059f991a204c42718493c2ca9f25ae8a Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 20 Jan 2025 15:55:19 +0100 Subject: [PATCH 15/20] Qual: Fix ci for new api_memberstypes.class # Qual: Fix ci for new api_memberstypes.class This fixes the notifications for the new api_memberstypes.class --- htdocs/adherents/class/api_members.class.php | 10 ++++---- .../class/api_memberstypes.class.php | 23 +++++++++++++------ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 6a65bc99ced..db18500629c 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2017 Regis Houssin * Copyright (C) 2020 Thibault FOUCART * Copyright (C) 2020-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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 @@ -37,7 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; class Members extends DolibarrApi { /** - * @var string[] $FIELDS Mandatory fields, checked when create and update object + * @var string[] Mandatory fields, checked when create and update object */ public static $FIELDS = array( 'morphy', @@ -159,7 +159,7 @@ class Members extends DolibarrApi throw new RestException(404, 'member not found'); } } else { - throw new RestException(404, 'This account have many thirdparties attached or does not exist.'); + throw new RestException(404, 'This account have many thirdparties attached or does not exist.'); } if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) { @@ -355,7 +355,9 @@ class Members extends DolibarrApi /** * Create member object * - * @param array $request_data Request data + * @param array $request_data Request data + * @phan-param ?array $request_data + * @phpstan-param ?array $request_data * @return int ID of member * * @throws RestException 403 Access denied diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index 32e9e105fa2..c96967f79ff 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2025 MDW * * 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 @@ -28,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; class MembersTypes extends DolibarrApi { /** - * @var array $FIELDS Mandatory fields, checked when create and update object + * @var string[] Mandatory fields, checked when create and update object */ public static $FIELDS = array( 'label', @@ -84,6 +85,8 @@ class MembersTypes extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.libelle:like:'SO-%') and (t.subscription:=:'1')" * @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names * @return array Array of member type objects + * @phan-return AdherentType[] + * @phpstan-return AdherentType[] * * @throws RestException */ @@ -143,7 +146,9 @@ class MembersTypes extends DolibarrApi /** * Create member type object * - * @param array $request_data Request data + * @param array $request_data Request data + * @phan-param ?array $request_data + * @phpstan-param ?array $request_data * @return int ID of member type */ public function post($request_data = null) @@ -175,7 +180,9 @@ class MembersTypes extends DolibarrApi * * @param int $id ID of member type to update * @param array $request_data Datas - * @return int + * @phan-param ?array $request_data + * @phpstan-param ?array $request_data + * @return Object */ public function put($id, $request_data = null) { @@ -227,6 +234,8 @@ class MembersTypes extends DolibarrApi * * @param int $id member type ID * @return array + * @phan-return array + * @phpstan-return array */ public function delete($id) { @@ -261,8 +270,8 @@ class MembersTypes extends DolibarrApi /** * Validate fields before creating an object * - * @param array|null $data Data to validate - * @return array + * @param ?array $data Data to validate + * @return array * * @throws RestException */ @@ -282,8 +291,8 @@ class MembersTypes extends DolibarrApi /** * Clean sensible object datas * - * @param Object $object Object to clean - * @return Object Object with cleaned properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { From c720370a9cc528225e76b968151ef563639b3615 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 20 Jan 2025 16:20:56 +0100 Subject: [PATCH 16/20] Qual: Fix phpstan notice about undefined copy --- .../triggers/interface_50_modTicket_TicketEmail.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php index 40cd8f49827..d518d284c8e 100644 --- a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php +++ b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2014-2016 Jean-François Ferry * 2016 Christophe Battarel * Copyright (C) 2023 Benjamin Falière - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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 @@ -178,6 +178,7 @@ class InterfaceTicketEmail extends DolibarrTriggers if (!getDolGlobalString('TICKET_DISABLE_ALL_MAILS')) { // Send email to assigned user $sendto = $userstat->email; + $old_MAIN_MAIL_AUTOCOPY_TO = null; if (!getDolGlobalString('TICKET_DISABLE_MAIL_AUTOCOPY_TO')) { $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; @@ -206,6 +207,7 @@ class InterfaceTicketEmail extends DolibarrTriggers if (!getDolGlobalString('TICKET_DISABLE_ALL_MAILS')) { // Send email to assigned user $sendto = $userstat->email; + $old_MAIN_MAIL_AUTOCOPY_TO = null; if (!getDolGlobalString('TICKET_DISABLE_MAIL_AUTOCOPY_TO')) { $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; From 133c67510cdb8cd740061584e6c237bfcfd9b607 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 20 Jan 2025 16:23:29 +0100 Subject: [PATCH 17/20] Qual: Fix phpstan, remove useless test that price_var_percent is array --- htdocs/variants/class/ProductCombination.class.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index db82c86747a..6b6524028fb 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2016 Marcos García * Copyright (C) 2018 Juanjo Menent * Copyright (C) 2022 Open-Dsi - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -884,11 +884,7 @@ class ProductCombination $productCombinationLevel->fk_price_level = $i; $productCombinationLevel->variation_price = $price_impact[$i]; - if (is_array($price_var_percent)) { - $productCombinationLevel->variation_price_percentage = (bool) $price_var_percent[$i] ; - } else { - $productCombinationLevel->variation_price_percentage = $price_var_percent; - } + $productCombinationLevel->variation_price_percentage = (bool) $price_var_percent[$i] ; $newcomb->combination_price_levels[$i] = $productCombinationLevel; } From 297e9316a84294a29d49b5c0cfdf0bf94a15ced2 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Mon, 20 Jan 2025 19:30:24 +0100 Subject: [PATCH 18/20] Clean code --- htdocs/adherents/class/api_memberstypes.class.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index 32e9e105fa2..a110c4992ac 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -39,7 +39,7 @@ class MembersTypes extends DolibarrApi */ public function __construct() { - global $db, $conf; + global $db; $this->db = $db; } @@ -89,8 +89,6 @@ class MembersTypes extends DolibarrApi */ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '') { - global $db, $conf; - $obj_ret = array(); if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) { @@ -151,8 +149,8 @@ class MembersTypes extends DolibarrApi if (!DolibarrApiAccess::$user->hasRight('adherent', 'configurer')) { throw new RestException(401); } - // Check mandatory fields - $result = $this->_validate($request_data); + // Check mandatory fields. Throw exception on error. + $this->_validate($request_data); $membertype = new AdherentType($this->db); foreach ($request_data as $field => $value) { From 69b59561197f6730f8acde3ee86108257ff3825b Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Tue, 21 Jan 2025 13:00:18 +0100 Subject: [PATCH 19/20] Fix warning --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index a5e89c8e988..6795862ee26 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -3174,7 +3174,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $original_file = $conf->fckeditor->dir_output.'/'.$original_file; } elseif ($modulepart == 'user' && !empty($conf->user->dir_output)) { // Wrapping for users - $canreaduser = (!empty($fuser->admin) || $fuser->rights->user->user->{$lire}); + $canreaduser = (!empty($fuser->admin) || $fuser->hasRight('user', 'user', 'lire')); if ($fuser->id == (int) $refname) { $canreaduser = 1; } // A user can always read its own card From d0399fdb325f87f23aa07c050b785ddb7b239330 Mon Sep 17 00:00:00 2001 From: Dolibot Date: Tue, 21 Jan 2025 12:07:00 +0000 Subject: [PATCH 20/20] PHPStan > Update baseline --- 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 3d3697f4d16..02bff396fb4 100644 --- a/dev/build/phpstan/phpstan-baseline.neon +++ b/dev/build/phpstan/phpstan-baseline.neon @@ -16164,12 +16164,6 @@ parameters: count: 2 path: ../../../htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php - - - message: '#^Variable \$old_MAIN_MAIL_AUTOCOPY_TO might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php - - message: '#^Call to function method_exists\(\) with Contact and ''getContactRoles'' will always evaluate to true\.$#' identifier: function.alreadyNarrowedType @@ -31902,12 +31896,6 @@ parameters: count: 1 path: ../../../htdocs/variants/class/ProductCombination.class.php - - - message: '#^Negated boolean expression is always false\.$#' - identifier: booleanNot.alwaysFalse - count: 1 - path: ../../../htdocs/variants/class/ProductCombination.class.php - - message: '#^Property ProductCombination\:\:\$variation_price_percentage type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue