From fd970ed5a9646fb1757d7cb6d95db9711722b6f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 15 Aug 2025 17:27:18 +0200 Subject: [PATCH 1/6] add doc (#34960) --- htdocs/commande/tpl/linkedobjectblock.tpl.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php index befaf531bfb..ad8e85c9095 100644 --- a/htdocs/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php @@ -3,6 +3,7 @@ * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2014 Marcos García * Copyright (C) 2024 MDW + * Copyright (C) 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 @@ -31,13 +32,16 @@ global $noMoreLinkedObjectBlockAfter; $langs = $GLOBALS['langs']; '@phan-var-force Translate $langs'; +/** @var Translate $langs */ $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; +/** @var Commande[] $linkedObjectBlock */ // Load translation files required by the page $langs->load("orders"); $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1); -'@phan-var-force CommonObject[] $linkedObjectBlock'; // Repeat because type lost after dol_sort_array) +'@phan-var-force Commande[] $linkedObjectBlock'; // Repeat because type lost after dol_sort_array) +/** @var Commande[] $linkedObjectBlock */ $total = 0; $ilink = 0; From 03c63525058aa1b780c57cd0eaa1b7124d5d363f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 15 Aug 2025 17:27:37 +0200 Subject: [PATCH 2/6] clean code (#34961) --- htdocs/product/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 3dfae650581..b2c5fb613b2 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -716,7 +716,7 @@ if (empty($reshook)) { $produit_multiprices_limit = getDolGlobalString('PRODUIT_MULTIPRICES_LIMIT'); for ($i = 2; $i <= $produit_multiprices_limit; $i++) { if (GETPOSTISSET("price_".$i)) { - $object->multiprices["$i"] = price2num(GETPOST("price_".$i), 'MU'); + $object->multiprices["$i"] = (float) price2num(GETPOST("price_".$i), 'MU'); $object->multiprices_base_type["$i"] = GETPOST("multiprices_base_type_".$i); } else { $object->multiprices["$i"] = ""; @@ -792,7 +792,7 @@ if (empty($reshook)) { $object->oldcopy = dol_clone($object, 1); // @phan-suppress-current-line PhanTypeMismatchProperty if (!getDolGlobalString('PRODUCT_GENERATE_REF_AFTER_FORM')) { - $object->ref = (string) $ref; + $object->ref = (string) $ref; } $object->label = GETPOST('label', $label_security_check); From 18ddceb65f7f71043d4cefb784ea161abade087c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 15 Aug 2025 17:28:21 +0200 Subject: [PATCH 3/6] fix doc (#34962) * fix doc * ref_client doesn't exists on Ticket * no lines in Ticket --- htdocs/ticket/tpl/linkedobjectblock.tpl.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/htdocs/ticket/tpl/linkedobjectblock.tpl.php b/htdocs/ticket/tpl/linkedobjectblock.tpl.php index 92ce54da930..8ba2d58a586 100644 --- a/htdocs/ticket/tpl/linkedobjectblock.tpl.php +++ b/htdocs/ticket/tpl/linkedobjectblock.tpl.php @@ -31,13 +31,14 @@ global $noMoreLinkedObjectBlockAfter; $langs = $GLOBALS['langs']; '@phan-var-force Translate $langs'; $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; -'@phan-var-force CommonObject[] $linkedObjectBlock'; +'@phan-var-force Ticket[] $linkedObjectBlock'; // Load translation files required by the page $langs->load('ticket'); $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'datec', 'desc', 0, 0, 1); -'@phan-var-force CommonObject[] $linkedObjectBlock'; // Repeat because type lost after dol_sort_array) +'@phan-var-force Ticket[] $linkedObjectBlock'; // Repeat because type lost after dol_sort_array) +/** @var Ticket[] $linkedObjectBlock */ $total = 0; $ilink = 0; @@ -50,12 +51,9 @@ foreach ($linkedObjectBlock as $key => $objectlink) { } ?> trans("Ticket"); ?> - getNomUrl(0, '', 0, 1).'&action=selectlines&token='.newToken().'" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" > getNomUrl(1); ?> - ref_client; ?> + track_id; ?> datec, 'day'); ?> socid = $objectlink->fk_soc; From ab546b123fe369bb0d1fbadd3c743be71e1b1301 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 17:28:33 +0200 Subject: [PATCH 4/6] PHPStan > Update baseline (#34963) Co-authored-by: Dolibot --- dev/build/phpstan/phpstan-baseline.neon | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/dev/build/phpstan/phpstan-baseline.neon b/dev/build/phpstan/phpstan-baseline.neon index 164ae2a6aa0..666246a35eb 100644 --- a/dev/build/phpstan/phpstan-baseline.neon +++ b/dev/build/phpstan/phpstan-baseline.neon @@ -11088,12 +11088,6 @@ parameters: count: 2 path: ../../../htdocs/core/tpl/extrafields_view.tpl.php - - - message: '#^Variable \$hookmanager might not be defined\.$#' - identifier: variable.undefined - count: 4 - path: ../../../htdocs/core/tpl/extrafields_view.tpl.php - - message: '#^Ternary operator condition is always true\.$#' identifier: ternary.alwaysTrue @@ -11532,24 +11526,6 @@ parameters: count: 1 path: ../../../htdocs/debugbar/class/autoloader.php - - - message: '#^Variable \$hidedesc might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/delivery/card.php - - - - message: '#^Variable \$hidedetails might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/delivery/card.php - - - - message: '#^Variable \$hideref might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/delivery/card.php - - message: '#^Variable \$objectsrc might not be defined\.$#' identifier: variable.undefined From 51034c05f926007080475b7d3ba3e248ac515ce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 15 Aug 2025 17:31:07 +0200 Subject: [PATCH 5/6] clean code (#34966) --- htdocs/core/class/objectlink.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/objectlink.class.php b/htdocs/core/class/objectlink.class.php index d90a0c1d3f0..c4e61a910ae 100644 --- a/htdocs/core/class/objectlink.class.php +++ b/htdocs/core/class/objectlink.class.php @@ -17,12 +17,12 @@ */ /** - * \file htdocs/core/class/commonobject.class.php + * \file htdocs/core/class/objectlink.class.php * \ingroup core * \brief File of parent class of all other business classes (invoices, contracts, proposals, orders, ...) */ -require_once DOL_DOCUMENT_ROOT.'/core/class/doldeprecationhandler.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; /** * Parent class of all other business classes (invoices, contracts, proposals, orders, ...) From e98fc8feb99511b94484e274ee391d098d218910 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 15 Aug 2025 17:31:44 +0200 Subject: [PATCH 6/6] deprecate contact statut for status (#34967) --- htdocs/contact/card.php | 7 +++--- htdocs/contact/class/contact.class.php | 31 +++++++++++++++++++------- htdocs/contact/list.php | 3 ++- htdocs/core/lib/company.lib.php | 3 ++- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index d72bfa65870..d9e66b48161 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -8,7 +8,7 @@ * Copyright (C) 2013-2024 Alexandre Spangaro * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2018-2025 Frédéric France * Copyright (C) 2019 Josep Lluís Amador * Copyright (C) 2020 Open-Dsi * Copyright (C) 2024-2025 MDW @@ -251,6 +251,7 @@ if (empty($reshook)) { $object->note_private = (string) GETPOST("note_private", 'restricthtml'); $object->roles = GETPOST("roles", 'array'); + $object->status = 1; //Default status to Actif $object->statut = 1; //Default status to Actif // Note: Correct date should be completed with location to have exact GM time of birth. @@ -1546,11 +1547,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } // Activer - if ($object->statut == 0 && $user->hasRight('societe', 'contact', 'creer')) { + if ($object->status == 0 && $user->hasRight('societe', 'contact', 'creer')) { print ''.$langs->trans("Reactivate").''; } // Desactiver - if ($object->statut == 1 && $user->hasRight('societe', 'contact', 'creer')) { + if ($object->status == 1 && $user->hasRight('societe', 'contact', 'creer')) { print ''.$langs->trans("DisableUser").''; } diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index eeaacbe0e48..fd9c9042dba 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -220,6 +220,7 @@ class Contact extends CommonObject /** * @var int Status 0=inactive, 1=active + * @deprecated Use $status */ public $statut; @@ -378,6 +379,7 @@ class Contact extends CommonObject { $this->db = $db; $this->statut = 1; // By default, status is enabled + $this->status = 1; // By default, status is enabled $this->ismultientitymanaged = 1; $this->isextrafieldmanaged = 1; @@ -498,7 +500,11 @@ class Contact extends CommonObject if (empty($this->priv)) { $this->priv = 0; } - if (empty($this->statut)) { + if (!empty($this->statut) && empty($this->status)) { + $this->status = 1; + } + if (empty($this->status)) { + $this->status = 0; // This is to convert '' into '0' to avoid bad sql request $this->statut = 0; // This is to convert '' into '0' to avoid bad sql request } @@ -533,7 +539,7 @@ class Contact extends CommonObject $sql .= " ".($user->id > 0 ? ((int) $user->id) : "null").","; $sql .= " ".((int) $this->priv).","; $sql .= " 0,"; - $sql .= " ".((int) $this->statut).","; + $sql .= " ".((int) $this->status).","; $sql .= " ".(!empty($this->canvas) ? "'".$this->db->escape($this->canvas)."'" : "null").","; $sql .= " ".((int) $this->entity).","; $sql .= "'".$this->db->escape($this->ref_ext)."',"; @@ -627,7 +633,11 @@ class Contact extends CommonObject $this->zip = (empty($this->zip) ? '' : trim($this->zip)); $this->town = (empty($this->town) ? '' : trim($this->town)); $this->country_id = (empty($this->country_id) || $this->country_id < 0) ? 0 : $this->country_id; - if (empty($this->statut)) { + if (!empty($this->statut) && empty($this->status)) { + $this->status = 1; + } + if (empty($this->status)) { + $this->status = 0; $this->statut = 0; } if (empty($this->civility_code) && !is_numeric($this->civility_id)) { @@ -669,7 +679,7 @@ class Contact extends CommonObject if (isset($this->stcomm_id)) { $sql .= ", fk_stcommcontact = ".($this->stcomm_id > 0 || $this->stcomm_id == -1 ? $this->stcomm_id : "0"); } - $sql .= ", statut = ".((int) $this->statut); + $sql .= ", statut = ".((int) $this->status); $sql .= ", fk_user_modif=".($user->id > 0 ? "'".$this->db->escape((string) $user->id)."'" : "NULL"); $sql .= ", default_lang=".($this->default_lang ? "'".$this->db->escape($this->default_lang)."'" : "NULL"); $sql .= ", entity = ".((int) $this->entity); @@ -1093,6 +1103,7 @@ class Contact extends CommonObject $this->socid = $obj->fk_soc; // Both fk_soc and socid are used $this->socname = $obj->socname; $this->poste = $obj->poste; + $this->status = $obj->statut; $this->statut = $obj->statut; $this->fk_prospectlevel = $obj->fk_prospectlevel; @@ -1645,7 +1656,7 @@ class Contact extends CommonObject */ public function getLibStatut($mode) { - return $this->LibStatut($this->statut, $mode); + return $this->LibStatut($this->status, $mode); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -1752,7 +1763,7 @@ class Contact extends CommonObject $this->note_private = 'This is a comment (private)'; $this->socid = $socid; - $this->statut = 1; + $this->status = 1; return 1; } @@ -1770,9 +1781,13 @@ class Contact extends CommonObject $error = 0; // Check parameters - if ($this->statut == $status) { + if (!empty($this->statut) && empty($this->status)) { + $this->status = 1; + } + if ($this->status == $status) { return 0; } else { + $this->status = $status; $this->statut = $status; } @@ -1780,7 +1795,7 @@ class Contact extends CommonObject // User disable $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople"; - $sql .= " SET statut = ".((int) $this->statut); + $sql .= " SET statut = ".((int) $this->status); $sql .= ", fk_user_modif = ".((int) $user->id); $sql .= " WHERE rowid = ".((int) $this->id); $result = $this->db->query($sql); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index b4bb8df325d..5c75a431500 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -9,7 +9,7 @@ * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018 Juanjo Menent - * Copyright (C) 2019-2024 Frédéric France + * Copyright (C) 2019-2025 Frédéric France * Copyright (C) 2019 Josep Lluís Amador * Copyright (C) 2020 Open-Dsi * Copyright (C) 2024-2025 MDW @@ -1436,6 +1436,7 @@ while ($i < $imaxinloop) { $contactstatic->ref_ext = $obj->ref_ext; $contactstatic->lastname = $obj->lastname; $contactstatic->firstname = $obj->firstname; + $contactstatic->status = $obj->statut; $contactstatic->statut = $obj->statut; $contactstatic->poste = $obj->poste; $contactstatic->email = $obj->email; diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 27be41de1d8..d6bccb6c5f4 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -7,7 +7,7 @@ * Copyright (C) 2013-2014 Juanjo Menent * Copyright (C) 2013 Christophe Battarel * Copyright (C) 2013-2018 Alexandre Spangaro - * Copyright (C) 2015-2024 Frédéric France + * Copyright (C) 2015-2025 Frédéric France * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2017 Rui Strecht * Copyright (C) 2018-2024 Ferran Marcet @@ -1583,6 +1583,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl $contactstatic->id = $obj->rowid; $contactstatic->ref = $obj->rowid; + $contactstatic->status = $obj->statut; $contactstatic->statut = $obj->statut; $contactstatic->lastname = $obj->lastname; $contactstatic->firstname = $obj->firstname;