From 24059b0b8db2dcc64ea7b133f17ff4a5258834af Mon Sep 17 00:00:00 2001 From: ATM john Date: Wed, 6 Mar 2024 17:24:23 +0100 Subject: [PATCH 01/60] get rows security --- htdocs/core/db/DoliDB.class.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 3b1184c7f85..4c0bfcbd0f3 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -385,6 +385,7 @@ abstract class DoliDB implements Database if ($res) { $obj = $this->fetch_object($res); if ($obj) { + $this->free($res); return $obj; } else { return 0; @@ -399,12 +400,17 @@ abstract class DoliDB implements Database * Note : This method executes a given SQL query and retrieves all row of results as an array of objects. It should only be used with SELECT queries * be careful with this method use it only with some limit of results to avoid performances loss. * - * @param string $sql The sql query string - * @return bool|array Result - * @deprecated + * @param string $sql The sql query string + * @param bool $noLimitCheck set it to true to disable sql query check of limit + * @return bool|array Result */ - public function getRows($sql) + public function getRows($sql, $noLimitCheck = false) { + + if (!$noLimitCheck && strpos($sql, 'LIMIT') === false) { + return false; + } + $res = $this->query($sql); if ($res) { $results = array(); @@ -413,6 +419,7 @@ abstract class DoliDB implements Database $results[] = $obj; } } + $this->free($res); return $results; } From 302ea702e68fc7c5f7196f1ef5261f81c70a4e8f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 9 Mar 2024 02:55:25 +0100 Subject: [PATCH 02/60] Add v19 in stats --- dev/tools/github_commits_byversion.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dev/tools/github_commits_byversion.sh b/dev/tools/github_commits_byversion.sh index bd3405376cf..eafca6b2e01 100755 --- a/dev/tools/github_commits_byversion.sh +++ b/dev/tools/github_commits_byversion.sh @@ -4,7 +4,7 @@ # # shellcheck disable=1113,2002,2006,2086,2164,2219 -Releases=("3.9" "4.0" "5.0" "6.0" "7.0" "8.0" "9.0" "10.0" "11.0" "12.0" "13.0" "14.0" "15.0" "16.0" "17.0" "18.0" "develop") +Releases=("3.9" "4.0" "5.0" "6.0" "7.0" "8.0" "9.0" "10.0" "11.0" "12.0" "13.0" "14.0" "15.0" "16.0" "17.0" "18.0" "19.0" "develop") let "counter = 0" echo "Copy script into /tmp/github_commits_byversion.sh" @@ -49,4 +49,3 @@ do echo let "counter +=1" done - From c6fa4e49453e9e90a7f0411c93701ba231b900cd Mon Sep 17 00:00:00 2001 From: MDW Date: Sat, 9 Mar 2024 20:44:47 +0100 Subject: [PATCH 03/60] Qual: Enable reporting PhanTypeMismatchDimAssignment --- dev/tools/phan/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tools/phan/config.php b/dev/tools/phan/config.php index ee9cde2603f..f2fe12ea94c 100644 --- a/dev/tools/phan/config.php +++ b/dev/tools/phan/config.php @@ -448,7 +448,7 @@ return [ 'PhanRedefineClass', 'PhanRedefineFunction', 'PhanTypeInvalidLeftOperandOfBitwiseOp', - 'PhanTypeMismatchDimAssignment', + // 'PhanTypeMismatchDimAssignment', // 'PhanPluginDescriptionlessCommentOnProtectedMethod', 'PhanPluginPrintfIncompatibleArgumentTypeWeak', 'PhanUndeclaredVariableAssignOp', From 101d56a2c1ae4c919a20381d2a796e9a5acfcb32 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 10 Mar 2024 15:17:58 +0100 Subject: [PATCH 04/60] Fix: Ob buffer cleanup on exception # Fix: Ob buffer cleanup on exception The OB buffer capture was incorrectly cleaned up on exception. This fixes that. Also modified the SecurityTest to enable running it standalone --- htdocs/core/lib/functions.lib.php | 10 ++++++++++ test/phpunit/CommonClassTest.class.php | 5 +++++ test/phpunit/SecurityTest.php | 7 ++++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c43dd851c78..57f785261ea 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -9839,6 +9839,7 @@ function dol_eval($s, $returnvalue = 1, $hideerrors = 1, $onlysimplestring = '1' global $object; global $obj; // To get $obj used into list when dol_eval() is used for computed fields and $obj is not yet $object + $isObBufferActive = false; // When true, the ObBuffer must be cleaned in the exception handler if (!in_array($onlysimplestring, array('0', '1', '2'))) { return "Bad call of dol_eval. Parameter onlysimplestring must be '0' (deprecated), '1' or '2'"; } @@ -9957,16 +9958,20 @@ function dol_eval($s, $returnvalue = 1, $hideerrors = 1, $onlysimplestring = '1' if ($returnvalue) { if ($hideerrors) { ob_start(); // An evaluation has no reason to output data + $isObBufferActive = true; $tmps = @eval('return '.$s.';'); $tmpo = ob_get_clean(); + $isObBufferActive = false; if ($tmpo) { print 'Bad string syntax to evaluate. Some data were output when it should not when evaluating: '.$s; } return $tmps; } else { ob_start(); // An evaluation has no reason to output data + $isObBufferActive = true; $tmps = eval('return '.$s.';'); $tmpo = ob_get_clean(); + $isObBufferActive = false; if ($tmpo) { print 'Bad string syntax to evaluate. Some data were output when it should not when evaluating: '.$s; } @@ -9981,6 +9986,11 @@ function dol_eval($s, $returnvalue = 1, $hideerrors = 1, $onlysimplestring = '1' } } } catch (Error $e) { + if ($isObBufferActive) { + // Clean up buffer which was left behind due to exception. + $tmpo = ob_get_clean(); + $isObBufferActive = false; + } $error = 'dol_eval try/catch error : '; $error .= $e->getMessage(); dol_syslog($error, LOG_WARNING); diff --git a/test/phpunit/CommonClassTest.class.php b/test/phpunit/CommonClassTest.class.php index 2be3f58362f..a7c793ed9bf 100644 --- a/test/phpunit/CommonClassTest.class.php +++ b/test/phpunit/CommonClassTest.class.php @@ -26,11 +26,16 @@ * \remarks Class that extends all PHPunit tests. To share similare code between each test. */ +// Workaround for false security issue with main.inc.php in tests: +$_SERVER['PHP_SELF'] = "phpunit"; + global $conf,$user,$langs,$db; //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver //require_once 'PHPUnit/Autoload.php'; require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; + + if (empty($user->id)) { print "Load permissions for admin user nb 1\n"; $user->fetch(1); diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index 8a154897acb..42455c49cef 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -53,10 +53,11 @@ if (! defined("NOSESSION")) { define("NOSESSION", '1'); } -require_once dirname(__FILE__).'/../../htdocs/main.inc.php'; +// Implements workaround for PHP_SELF & includes common files: +require_once dirname(__FILE__).'/CommonClassTest.class.php'; + require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php'; -require_once dirname(__FILE__).'/CommonClassTest.class.php'; if (empty($user->id)) { print "Load permissions for admin user nb 1\n"; @@ -988,7 +989,7 @@ class SecurityTest extends CommonClassTest include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; - $result=dol_eval('1==1', 1, 0); + $result = dol_eval('1==1', 1, 0); print "result1 = ".$result."\n"; $this->assertTrue($result); From 29216f3d4e7293fcf4f02a821b4e80248ca52131 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Mar 2024 12:49:15 +0100 Subject: [PATCH 05/60] Update CommonClassTest.class.php --- test/phpunit/CommonClassTest.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/phpunit/CommonClassTest.class.php b/test/phpunit/CommonClassTest.class.php index a7c793ed9bf..701dccc6e63 100644 --- a/test/phpunit/CommonClassTest.class.php +++ b/test/phpunit/CommonClassTest.class.php @@ -26,8 +26,10 @@ * \remarks Class that extends all PHPunit tests. To share similare code between each test. */ -// Workaround for false security issue with main.inc.php in tests: -$_SERVER['PHP_SELF'] = "phpunit"; +// Workaround for false security issue with main.inc.php on Windows in tests: +if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { + $_SERVER['PHP_SELF'] = "phpunit"; +} global $conf,$user,$langs,$db; //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver From 41a57c05c53a93e68b82d480724dc559359ae829 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Mar 2024 12:51:27 +0100 Subject: [PATCH 06/60] Update SecurityTest.php --- test/phpunit/SecurityTest.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index 42455c49cef..81b21909e5f 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -53,9 +53,7 @@ if (! defined("NOSESSION")) { define("NOSESSION", '1'); } -// Implements workaround for PHP_SELF & includes common files: -require_once dirname(__FILE__).'/CommonClassTest.class.php'; - +require_once dirname(__FILE__).'/../../htdocs/main.inc.php'; // We force include of main.inc.php instead of master.inc.php even if we are in CLI mode because it contains a lot of security components we want to test. require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php'; From 1aa16476068b7234d96ce0d228b23b4a4ae941ad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Mar 2024 12:53:03 +0100 Subject: [PATCH 07/60] Update SecurityTest.php --- test/phpunit/SecurityTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index 81b21909e5f..5ff98738cd2 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -56,6 +56,7 @@ if (! defined("NOSESSION")) { require_once dirname(__FILE__).'/../../htdocs/main.inc.php'; // We force include of main.inc.php instead of master.inc.php even if we are in CLI mode because it contains a lot of security components we want to test. require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php'; +require_once dirname(__FILE__).'/CommonClassTest.class.php'; if (empty($user->id)) { print "Load permissions for admin user nb 1\n"; From c33307577603d701722c01138da8779ec84b881b Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 11 Mar 2024 10:49:26 +0100 Subject: [PATCH 08/60] Fix: getChildrenOfLine's use of includealltree as array # Fix: getChildrenOfLine's use of includealltree as array includealltree of getChildrenOfLine was used as an array, fixed --- htdocs/core/class/commonobject.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 32b758792c6..b8878b38900 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3280,8 +3280,8 @@ abstract class CommonObject if ($this->db->num_rows($resql) > 0) { while ($row = $this->db->fetch_row($resql)) { $rows[] = $row[0]; - if (!empty($includealltree)) { - $rows = array_merge($rows, $this->getChildrenOfLine($row[0]), $includealltree); + if ($includealltree) { + $rows = array_merge($rows, $this->getChildrenOfLine($row[0])); } } } From 674e668b78a78b431e1359b70561f96cf633fb4d Mon Sep 17 00:00:00 2001 From: Florent Poinsaut <1256948+FlorentPoinsaut@users.noreply.github.com> Date: Mon, 4 Mar 2024 08:57:52 +0000 Subject: [PATCH 09/60] FIX cloned supplier order creation date as now --- .../class/fournisseur.commande.class.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 2e128bcd7ec..2ab1ce0ef0d 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -5,14 +5,15 @@ * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2010-2020 Juanjo Menent * Copyright (C) 2010-2018 Philippe Grand - * Copyright (C) 2012-2015 Marcos García - * Copyright (C) 2013 Florian Henry - * Copyright (C) 2013 Cédric Salvador - * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (C) 2018-2024 Frédéric France - * Copyright (C) 2018-2022 Ferran Marcet - * Copyright (C) 2021 Josep Lluís Amador - * Copyright (C) 2022 Gauthier VERDOL + * Copyright (C) 2012-2015 Marcos García + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2018 Nicolas ZABOURI + * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2018-2022 Ferran Marcet + * Copyright (C) 2021 Josep Lluís Amador + * Copyright (C) 2022 Gauthier VERDOL + * Copyright (C) 2024 Solution Libre SAS * * 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 @@ -1863,8 +1864,10 @@ class CommandeFournisseur extends CommonOrder // Clear fields $this->user_author_id = $user->id; $this->user_validation_id = 0; + $this->date = dol_now(); $this->date_creation = 0; $this->date_validation = 0; + $this->date_commande = 0; $this->ref_supplier = ''; $this->user_approve_id = 0; $this->user_approve_id2 = 0; From e0cf910f49b91a50b8b3b257f0d01a87fbf0b056 Mon Sep 17 00:00:00 2001 From: Hystepik Date: Mon, 11 Mar 2024 15:01:39 +0100 Subject: [PATCH 10/60] Fix unable to delete file medias --- htdocs/ecm/index_medias.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/ecm/index_medias.php b/htdocs/ecm/index_medias.php index 1fa0e03a1a7..3527523b49c 100644 --- a/htdocs/ecm/index_medias.php +++ b/htdocs/ecm/index_medias.php @@ -37,6 +37,7 @@ $langs->loadLangs(array('ecm', 'companies', 'other', 'users', 'orders', 'propal' // Get parameters $action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); $socid = GETPOST('socid', 'int'); From 5e2a06a177c6eb11eaf5d03bf6f63e2cb3951963 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Mon, 11 Mar 2024 15:23:26 +0100 Subject: [PATCH 11/60] Add layout and prompt ai on create emmailing --- htdocs/comm/mailing/card.php | 57 ++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index f44f53071bd..e6f33c8e8cd 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -845,6 +845,63 @@ if ($action == 'create') { print $htmlother->selectColor(GETPOST('bgcolor'), 'bgcolor', '', 0); print ''; + $formmail = new FormMail($db); + $formmail->withfckeditor = 1; + $formmail->withaiprompt = 1; + $formmail->withlayout = 1; + + print ''; + $out = ''; + // Add link to add layout + if ($formmail->withlayout && $formmail->withfckeditor) { + $out .= ''; + $out .= img_picto($langs->trans("FillMessageWithALayout"), 'layout', 'class="paddingrightonly"'); + $out .= $langs->trans("FillMessageWithALayout").'...'; + $out .= '     '; + + $out .= ' + '; + } + + // Add link to add AI content + if ($formmail->withaiprompt && isModEnabled('ai')) { + $out .= ''; + $out .= img_picto($langs->trans("FillMessageWithAIContent"), 'ai', 'class="paddingrightonly"'); + $out .= $langs->trans("FillMessageWithAIContent").'...'; + $out .= ''; + $out .= ''; + } + if ($formmail->withfckeditor) { + $out .= $formmail->getModelEmailTemplate(); + } + if ($formmail->withaiprompt && isModEnabled('ai')) { + $out .= $formmail->getSectionForAIPrompt(); + } + print $out; + print ''; print ''; print '
'; From 769b682fd3690214216be2a11dd6e189209cb00e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Mar 2024 16:13:11 +0100 Subject: [PATCH 12/60] Update commonobject.class.php --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index bbdb8183fe2..a693c31ff2d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3281,7 +3281,7 @@ abstract class CommonObject while ($row = $this->db->fetch_row($resql)) { $rows[] = $row[0]; if ($includealltree) { - $rows = array_merge($rows, $this->getChildrenOfLine($row[0])); + $rows = array_merge($rows, $this->getChildrenOfLine($row[0], $includealltree)); } } } From 5b921d0dc4326c38e8b8cdd36cf3bca420b88603 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Mar 2024 16:26:17 +0100 Subject: [PATCH 13/60] Update DoliDB.class.php --- htdocs/core/db/DoliDB.class.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 4c0bfcbd0f3..1a21fb5c527 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -396,18 +396,16 @@ abstract class DoliDB implements Database } /** - * Return all results from query as an array of objects - * Note : This method executes a given SQL query and retrieves all row of results as an array of objects. It should only be used with SELECT queries - * be careful with this method use it only with some limit of results to avoid performances loss. + * Return all results from query as an array of objects. Using this is a bad practice and is discouraged. + * Note : It should only be used with SELECT queries and with a limit. If you are not able to defined/know what can be the limit, it + * just means this function is not what you need. Do not use it. * - * @param string $sql The sql query string - * @param bool $noLimitCheck set it to true to disable sql query check of limit - * @return bool|array Result + * @param string $sql The sql query string. Must end with "... LIMIT x" + * @return bool|array Result */ - public function getRows($sql, $noLimitCheck = false) + public function getRows($sql) { - - if (!$noLimitCheck && strpos($sql, 'LIMIT') === false) { + if (! preg_match('/LIMIT \d+$/', $sql)) { return false; } From 553587b6606f6f956883fba7be163315526f23c5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Mar 2024 16:27:46 +0100 Subject: [PATCH 14/60] Update DoliDB.class.php --- htdocs/core/db/DoliDB.class.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 1a21fb5c527..90cb227db73 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -381,11 +381,11 @@ abstract class DoliDB implements Database { $sql .= ' LIMIT 1'; - $res = $this->query($sql); - if ($res) { - $obj = $this->fetch_object($res); + $resql = $this->query($sql); + if ($resql) { + $obj = $this->fetch_object($resql); if ($obj) { - $this->free($res); + $this->free($resql); return $obj; } else { return 0; @@ -409,15 +409,15 @@ abstract class DoliDB implements Database return false; } - $res = $this->query($sql); - if ($res) { + $resql = $this->query($sql); + if ($resql) { $results = array(); - if ($this->num_rows($res) > 0) { - while ($obj = $this->fetch_object($res)) { + if ($this->num_rows($resql) > 0) { + while ($obj = $this->fetch_object($resql)) { $results[] = $obj; } } - $this->free($res); + $this->free($resql); return $results; } From b963a9ab368a02cff7c68b3304dfb4bba8d40ecd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Mar 2024 16:30:33 +0100 Subject: [PATCH 15/60] Fix phpunit --- htdocs/core/db/DoliDB.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 90cb227db73..b839770410f 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -397,8 +397,8 @@ abstract class DoliDB implements Database /** * Return all results from query as an array of objects. Using this is a bad practice and is discouraged. - * Note : It should only be used with SELECT queries and with a limit. If you are not able to defined/know what can be the limit, it - * just means this function is not what you need. Do not use it. + * Note : It should only be used with SELECT queries and with a limit. If you are not able to defined/know what can be the limit, it + * just means this function is not what you need. Do not use it. * * @param string $sql The sql query string. Must end with "... LIMIT x" * @return bool|array Result From 404d594f24aa51b9e49a6d7c3113b471f530895f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Mar 2024 16:39:44 +0100 Subject: [PATCH 16/60] Removed not used file --- htdocs/langs/fr_FR/ai.lang | 1 - 1 file changed, 1 deletion(-) delete mode 100644 htdocs/langs/fr_FR/ai.lang diff --git a/htdocs/langs/fr_FR/ai.lang b/htdocs/langs/fr_FR/ai.lang deleted file mode 100644 index f6eb575e977..00000000000 --- a/htdocs/langs/fr_FR/ai.lang +++ /dev/null @@ -1 +0,0 @@ -AI_KEY_API_CHATGPT= Clé pour l'api IA \ No newline at end of file From b7acea0ec4c160cfb11bc44e3e2295bd02155717 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 11 Mar 2024 16:47:38 +0100 Subject: [PATCH 17/60] Fix: PhanTypeMismatchDeclaredParamNullable notices # Fix: PhanTypeMismatchDeclaredParamNullable notices PHPDoc must indicate param is nullable if the default is null with explicit typing. (+Improved some other typing from generic Object to CommonObject). --- htdocs/core/lib/bank.lib.php | 13 +++++++------ .../modules/fichinter/doc/pdf_soleil.modules.php | 3 ++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php index 75788627cec..ffde1206773 100644 --- a/htdocs/core/lib/bank.lib.php +++ b/htdocs/core/lib/bank.lib.php @@ -5,6 +5,7 @@ * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2021 Ferran Marcet + * Copyright (C) 2024 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 @@ -228,8 +229,8 @@ function account_statement_prepare_head($object, $num) /** * Prepare array with list of tabs * - * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @param CommonObject $object Object related to tabs + * @return array Array of tabs to shoc */ function various_payment_prepare_head($object) { @@ -275,8 +276,8 @@ function various_payment_prepare_head($object) /** * Check SWIFT information for a bank account * - * @param Account $account A bank account (used to get BIC/SWIFT) - * @param string $swift Swift value (used to get BIC/SWIFT, param $account non used if provided) + * @param ?Account $account A bank account (used to get BIC/SWIFT) + * @param ?string $swift Swift value (used to get BIC/SWIFT, param $account non used if provided) * @return boolean True if information are valid, false otherwise */ function checkSwiftForAccount(Account $account = null, $swift = null) @@ -296,8 +297,8 @@ function checkSwiftForAccount(Account $account = null, $swift = null) /** * Check IBAN number information for a bank account. * - * @param Account $account A bank account - * @param string $ibantocheck Bank account number (used to get BAN, $account not used if provided) + * @param ?Account $account A bank account + * @param ?string $ibantocheck Bank account number (used to get BAN, $account not used if provided) * @return boolean True if information are valid, false otherwise */ function checkIbanForAccount(Account $account = null, $ibantocheck = null) diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 8c2b45055fc..82871ffae52 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -6,6 +6,7 @@ * Copyright (C) 2011 Fabrice CHERRIER * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2015 Marcos García + * Copyright (C) 2024 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 @@ -449,7 +450,7 @@ class pdf_soleil extends ModelePDFFicheinter * @param Translate $outputlangs Langs object * @param int $hidetop Hide top bar of array * @param int $hidebottom Hide bottom bar of array - * @param Fichinter $object FichInter Object + * @param ?Fichinter $object FichInter Object * @return void */ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, FichInter $object = null) From 200bc042bd239912de7825a682c6717165704ad5 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 11 Mar 2024 16:48:55 +0100 Subject: [PATCH 18/60] Qual: Enable PhanTypeMismatchDeclaredParamNullable # Qual: Enable PhanTypeMismatchDeclaredParamNullable The few cases for PhanTypeMismatchDeclaredParamNullable were fixed, so the notification can be enabled --- dev/tools/phan/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tools/phan/config.php b/dev/tools/phan/config.php index 0bb240128f8..609f2cc267c 100644 --- a/dev/tools/phan/config.php +++ b/dev/tools/phan/config.php @@ -475,7 +475,7 @@ return [ // 'PhanPluginUnknownFunctionReturnType', // 'PhanPluginDescriptionlessCommentOnProtectedProperty', 'PhanPluginRedundantAssignmentInGlobalScope', - 'PhanTypeMismatchDeclaredParamNullable', + // 'PhanTypeMismatchDeclaredParamNullable', 'PhanTypeInvalidRightOperandOfAdd', // 'PhanPluginDescriptionlessCommentOnPrivateProperty', // 'PhanUndeclaredVariableDim', // Array initialisation on undeclared var: $abc['x']='ab' From 087390b44e4e8e8563797c3baa81f68f094a67dc Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 11 Mar 2024 17:15:54 +0100 Subject: [PATCH 19/60] Change logic to help static tool analysis --- htdocs/admin/modulehelp.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index 50e83f65fcb..22165d2c305 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -2,6 +2,7 @@ /* Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2017 Regis Houssin * Copyright (C) 2022 Charlene Benke + * Copyright (C) 2024 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 @@ -167,7 +168,10 @@ foreach ($modulesdir as $dir) { $familyinfo = array_merge($familyinfo, $objMod->familyinfo); $familykey = key($objMod->familyinfo); } else { - $familykey = empty($objMod->family) ? 'other' : $objMod->family; + $familykey = $objMod->family; + if (empty($familykey)) { + $familykey = 'other'; + } } $moduleposition = ($objMod->module_position ? $objMod->module_position : '50'); From 831aee8fa2f10da172915cf129d9fb8d5b3a0d07 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Mon, 11 Mar 2024 17:31:01 +0100 Subject: [PATCH 20/60] add link for redirect in setup module --- htdocs/ai/ajax/generate_content.php | 8 +++++++- htdocs/ai/class/ai.class.php | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/ai/ajax/generate_content.php b/htdocs/ai/ajax/generate_content.php index 9b1adf13b84..c476a0b09f4 100644 --- a/htdocs/ai/ajax/generate_content.php +++ b/htdocs/ai/ajax/generate_content.php @@ -67,7 +67,13 @@ $function = 'textgeneration'; $generatedContent = $ai->generateContent($instructions, 'auto', $function); if (is_array($generatedContent) && $generatedContent['error']) { - print "Error : " . $generatedContent['message']; + // client errors + if ($generatedContent['code'] >= 400) { + print "Error : " . $generatedContent['message']; + print '
'.$langs->trans('Check Config of Module').''; + } else { + print "Error : " . $generatedContent['message']; + } } else { print $generatedContent; } diff --git a/htdocs/ai/class/ai.class.php b/htdocs/ai/class/ai.class.php index 399b3adb1ee..d3baf33421c 100644 --- a/htdocs/ai/class/ai.class.php +++ b/htdocs/ai/class/ai.class.php @@ -131,7 +131,7 @@ class Ai $response = curl_exec($ch); if (curl_errno($ch)) { - throw new Exception('cURL error: ' . curl_error($ch)); + throw new Exception('Wrong configuration !' . curl_error($ch)); } $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); @@ -146,7 +146,7 @@ class Ai return $generatedEmailContent; } catch (Exception $e) { - return array('error' => true, 'message' => $e->getMessage()); + return array('error' => true, 'message' => $e->getMessage(), 'code' => $statusCode); } finally { curl_close($ch); } From 6b34b8757f9a7821e1cde07420a2602920e2987e Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 11 Mar 2024 17:43:57 +0100 Subject: [PATCH 21/60] fixup! Change logic to help static tool analysis --- htdocs/admin/modulehelp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index 22165d2c305..8116316dfa1 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -169,7 +169,7 @@ foreach ($modulesdir as $dir) { $familykey = key($objMod->familyinfo); } else { $familykey = $objMod->family; - if (empty($familykey)) { + if (empty($familykey) || $familykey === null) { $familykey = 'other'; } } From 8e422f15e38b5d65ec0d88c216b5a85074c2ea65 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Mon, 11 Mar 2024 18:00:43 +0100 Subject: [PATCH 22/60] New update in generate_content in module Ai --- htdocs/ai/class/ai.class.php | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/htdocs/ai/class/ai.class.php b/htdocs/ai/class/ai.class.php index 399b3adb1ee..5b4f4003248 100644 --- a/htdocs/ai/class/ai.class.php +++ b/htdocs/ai/class/ai.class.php @@ -20,6 +20,8 @@ * or see https://www.gnu.org/ */ require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; + /** * Class for AI @@ -116,30 +118,27 @@ class Ai $fullInstructions = $prePrompt.' '.$instructions.' .'.$postPrompt; // TODO Replace this with a simple call of getDolURLContent(); - $ch = curl_init($this->apiEndpoint); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([ + // $ch = curl_init($this->apiEndpoint); + // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + //curl_setopt($ch, CURLOPT_HTTPHEADER, [ + $payload = json_encode([ 'messages' => [ ['role' => 'user', 'content' => $fullInstructions] ], 'model' => $model - ])); - curl_setopt($ch, CURLOPT_HTTPHEADER, [ + ]); + + $headers = ([ 'Authorization: Bearer ' . $this->apiKey, 'Content-Type: application/json' ]); + $response = getURLContent($this->apiEndpoint, 'POST', $payload, $headers); - $response = curl_exec($ch); - if (curl_errno($ch)) { - throw new Exception('cURL error: ' . curl_error($ch)); - } - - $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); - if ($statusCode != 200) { - throw new Exception('API request failed with status code ' . $statusCode); + if ($response['http_code'] != 200) { + throw new Exception('API request failed with status code ' . $response['http_code']); } // Decode JSON response - $decodedResponse = json_decode($response, true); + $decodedResponse = json_decode($response['content'], true); // Extraction content $generatedEmailContent = $decodedResponse['choices'][0]['message']['content']; @@ -147,8 +146,6 @@ class Ai return $generatedEmailContent; } catch (Exception $e) { return array('error' => true, 'message' => $e->getMessage()); - } finally { - curl_close($ch); } } } From fc6c93877b369d6974c0732072882de70c071971 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 11 Mar 2024 18:02:19 +0100 Subject: [PATCH 23/60] fixup! Change logic to help static tool analysis --- htdocs/admin/modulehelp.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index 8116316dfa1..e076187e563 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -169,9 +169,9 @@ foreach ($modulesdir as $dir) { $familykey = key($objMod->familyinfo); } else { $familykey = $objMod->family; - if (empty($familykey) || $familykey === null) { - $familykey = 'other'; - } + } + if (empty($familykey) || $familykey === null) { + $familykey = 'other'; } $moduleposition = ($objMod->module_position ? $objMod->module_position : '50'); From d916a70acff5eb14cb20c564a6d8014e056dd5e4 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Mon, 11 Mar 2024 18:03:33 +0100 Subject: [PATCH 24/60] Remove comments --- htdocs/ai/class/ai.class.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/htdocs/ai/class/ai.class.php b/htdocs/ai/class/ai.class.php index 5b4f4003248..ee3970912b6 100644 --- a/htdocs/ai/class/ai.class.php +++ b/htdocs/ai/class/ai.class.php @@ -117,10 +117,7 @@ class Ai } $fullInstructions = $prePrompt.' '.$instructions.' .'.$postPrompt; - // TODO Replace this with a simple call of getDolURLContent(); - // $ch = curl_init($this->apiEndpoint); - // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - //curl_setopt($ch, CURLOPT_HTTPHEADER, [ + $payload = json_encode([ 'messages' => [ ['role' => 'user', 'content' => $fullInstructions] From 8e1b6543b8e9d0f5ea24abd8afddc05247feda5a Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 11 Mar 2024 17:57:54 +0100 Subject: [PATCH 25/60] Qual: Typing : make all $module_parts fields optional and add missing # Qual: Typing : make all $module_parts fields optional and add missing According to the initialisations of the modules all fields for $module_parts are optional and some keys were missing in the definition. This is updated. --- htdocs/core/modules/DolibarrModules.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 2994a5c58b0..15fbe56aa32 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -8,6 +8,7 @@ * Copyright (C) 2014 Raphaël Doursenaud * Copyright (C) 2018 Josep Lluís Amador * Copyright (C) 2019-2024 Frédéric France + * Copyright (C) 2024 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 @@ -140,7 +141,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it public $menu = array(); /** - * @var array{triggers:int,login:int,substitutions:int,menus:int,theme:int,tpl:int,barcode:int,models:int,css:string,js:string,hooks:string[]} Module parts + * @var array{triggers?:int<0,1>,login?:int<0,1>,substitutions?:int<0,1>,menus?:int<0,1>,theme?:int<0,1>,tpl?:int<0,1>,barcode?:int<0,1>,models?:int<0,1>,printing?:int<0,1>,css?:string[],js?:string[],hooks?:array{data:string[],entity:string},moduleforexternal?:int<0,1>,websitetemplates?:int<0,1>,contactelement?:int<0,1>} Module parts * array( * // Set this to 1 if module has its own trigger directory (/mymodule/core/triggers) * 'triggers' => 0, From 7bcb635a4e1de8b3a5e38af195d51825eb8aed04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Mon, 11 Mar 2024 18:13:48 +0100 Subject: [PATCH 26/60] clean code and phpdoc --- .../core/modules/asset/mod_asset_standard.php | 6 +++--- .../barcode/mod_barcode_product_standard.php | 4 ++-- .../mod_barcode_thirdparty_standard.php | 2 +- htdocs/core/modules/bom/mod_bom_advanced.php | 4 ++-- htdocs/core/modules/bom/mod_bom_standard.php | 11 +++++----- .../modules/cheque/mod_chequereceipt_mint.php | 18 ++--------------- .../cheque/mod_chequereceipt_thyme.php | 17 +--------------- .../modules/commande/mod_commande_marbre.php | 20 +++---------------- .../modules/commande/mod_commande_saphir.php | 19 ++---------------- .../modules/contract/mod_contract_magre.php | 16 +-------------- .../modules/contract/mod_contract_serpis.php | 19 ++---------------- .../modules/delivery/mod_delivery_jade.php | 20 +++---------------- .../modules/delivery/mod_delivery_saphir.php | 20 +++---------------- .../expedition/mod_expedition_ribera.php | 18 ++--------------- .../expedition/mod_expedition_safor.php | 19 +++--------------- .../expensereport/mod_expensereport_jade.php | 5 +++-- .../expensereport/mod_expensereport_sand.php | 5 +++-- .../core/modules/facture/mod_facture_mars.php | 5 +++-- .../modules/facture/mod_facture_mercure.php | 3 ++- .../modules/facture/mod_facture_terre.php | 5 +++-- .../societe/mod_codeclient_elephant.php | 2 +- .../societe/mod_codeclient_leopard.php | 4 ++-- .../modules/societe/mod_codeclient_monkey.php | 2 +- 23 files changed, 54 insertions(+), 190 deletions(-) diff --git a/htdocs/core/modules/asset/mod_asset_standard.php b/htdocs/core/modules/asset/mod_asset_standard.php index 7c34cc27931..1c957de8724 100644 --- a/htdocs/core/modules/asset/mod_asset_standard.php +++ b/htdocs/core/modules/asset/mod_asset_standard.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2022 Frédéric France + * Copyright (C) 2022-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 @@ -78,7 +78,7 @@ class mod_asset_standard extends ModeleNumRefAsset * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param Object $object Object we need next value for + * @param Asset $object Object we need next value for * @return boolean false if conflict, true if ok */ public function canBeActivated($object) @@ -118,7 +118,7 @@ class mod_asset_standard extends ModeleNumRefAsset /** * Return next free value * - * @param Object $object Object we need next value for + * @param Asset $object Object we need next value for * @return string|-1 Next value if OK, -1 if KO */ public function getNextValue($object) diff --git a/htdocs/core/modules/barcode/mod_barcode_product_standard.php b/htdocs/core/modules/barcode/mod_barcode_product_standard.php index c2df3f7c3a0..2190150ec62 100644 --- a/htdocs/core/modules/barcode/mod_barcode_product_standard.php +++ b/htdocs/core/modules/barcode/mod_barcode_product_standard.php @@ -127,8 +127,8 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode /** * Return literal barcode type code from numerical rowid type of barcode * - * @param Database $db Database - * @param int $type Type of barcode (EAN, ISBN, ...) as rowid + * @param DoliDB $db Database + * @param int $type Type of barcode (EAN, ISBN, ...) as rowid * @return string */ public function literalBarcodeType($db, $type = 0) diff --git a/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php b/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php index 118e87cbc3a..6825c1e53bb 100644 --- a/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php +++ b/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php @@ -139,7 +139,7 @@ class mod_barcode_thirdparty_standard extends ModeleNumRefBarCode /** * Return literal barcode type code from numerical rowid type of barcode * - * @param Database $db Database + * @param DoliDB $db Database * @param int $type Type of barcode (EAN, ISBN, ...) as rowid * @return string */ diff --git a/htdocs/core/modules/bom/mod_bom_advanced.php b/htdocs/core/modules/bom/mod_bom_advanced.php index 0e9f3d4f977..2428e79595d 100644 --- a/htdocs/core/modules/bom/mod_bom_advanced.php +++ b/htdocs/core/modules/bom/mod_bom_advanced.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-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 @@ -119,7 +119,7 @@ class mod_bom_advanced extends ModeleNumRefBoms * Return next free value * * @param Product $objprod Object product - * @param Object $object Object we need next value for + * @param Bom $object Object we need next value for * @return string|0 Next value if OK, 0 if KO */ public function getNextValue($objprod, $object) diff --git a/htdocs/core/modules/bom/mod_bom_standard.php b/htdocs/core/modules/bom/mod_bom_standard.php index 1e26ba2254a..f4ba8293423 100644 --- a/htdocs/core/modules/bom/mod_bom_standard.php +++ b/htdocs/core/modules/bom/mod_bom_standard.php @@ -1,6 +1,7 @@ * Copyright (C) 2005-2009 Regis Houssin + * 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 @@ -76,8 +77,8 @@ class mod_bom_standard extends ModeleNumRefBoms * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param Object $object Object we need next value for - * @return boolean false if conflict, true if ok + * @param Bom $object Object we need next value for + * @return boolean false if conflict, true if ok */ public function canBeActivated($object) { @@ -112,9 +113,9 @@ class mod_bom_standard extends ModeleNumRefBoms /** * Return next free value * - * @param Product $objprod Object product - * @param Object $object Object we need next value for - * @return string|-1 Next value if OK, -1 if KO + * @param Product $objprod Object product + * @param Bom $object Object we need next value for + * @return string|-1 Next value if OK, -1 if KO */ public function getNextValue($objprod, $object) { diff --git a/htdocs/core/modules/cheque/mod_chequereceipt_mint.php b/htdocs/core/modules/cheque/mod_chequereceipt_mint.php index 5106697211d..c42806e603e 100644 --- a/htdocs/core/modules/cheque/mod_chequereceipt_mint.php +++ b/htdocs/core/modules/cheque/mod_chequereceipt_mint.php @@ -1,5 +1,6 @@ + * 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 @@ -73,7 +74,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param Object $object Object we need next value for + * @param RemiseCheque $object Object we need next value for * @return boolean false if conflict, true if ok */ public function canBeActivated($object) @@ -150,19 +151,4 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return next free value - * - * @param Societe $objsoc Object third party - * @param string $objforref Object for number to search - * @return string Next free value - */ - public function chequereceipt_get_num($objsoc, $objforref) - { - // phpcs:enable - return $this->getNextValue($objsoc, $objforref); - } } diff --git a/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php b/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php index 5a2ae083d2f..44eff63035d 100644 --- a/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php +++ b/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php @@ -1,6 +1,6 @@ - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-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 @@ -131,19 +131,4 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts return $numFinal; } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return next free value - * - * @param Societe $objsoc Object third party - * @param string $objforref Object for number to search - * @return string Next free value - */ - public function chequereceipt_get_num($objsoc, $objforref) - { - // phpcs:enable - return $this->getNextValue($objsoc, $objforref); - } } diff --git a/htdocs/core/modules/commande/mod_commande_marbre.php b/htdocs/core/modules/commande/mod_commande_marbre.php index ad664e10e3a..8583d30d46c 100644 --- a/htdocs/core/modules/commande/mod_commande_marbre.php +++ b/htdocs/core/modules/commande/mod_commande_marbre.php @@ -1,6 +1,7 @@ * Copyright (C) 2005-2009 Regis Houssin + * 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 @@ -88,7 +89,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param Object $object Object we need next value for + * @param Commande $object Object we need next value for * @return boolean false if conflict, true if ok */ public function canBeActivated($object) @@ -125,7 +126,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes * Return next free value * * @param Societe $objsoc Object thirdparty - * @param Object $object Object we need next value for + * @param Commande $object Object we need next value for * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($objsoc, $object) @@ -165,19 +166,4 @@ class mod_commande_marbre extends ModeleNumRefCommandes dol_syslog("mod_commande_marbre::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return next free value - * - * @param Societe $objsoc Object third party - * @param string $objforref Object for number to search - * @return string|-1 Next free value, -1 if KO - */ - public function commande_get_num($objsoc, $objforref) - { - // phpcs:enable - return $this->getNextValue($objsoc, $objforref); - } } diff --git a/htdocs/core/modules/commande/mod_commande_saphir.php b/htdocs/core/modules/commande/mod_commande_saphir.php index 2cc4331e98e..f727b9dff70 100644 --- a/htdocs/core/modules/commande/mod_commande_saphir.php +++ b/htdocs/core/modules/commande/mod_commande_saphir.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-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 @@ -119,7 +119,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes * Return next free value * * @param Societe $objsoc Object thirdparty - * @param Object $object Object we need next value for + * @param Commande $object Object we need next value for * @return string|0 Next value if OK, 0 if KO */ public function getNextValue($objsoc, $object) @@ -149,19 +149,4 @@ class mod_commande_saphir extends ModeleNumRefCommandes return $numFinal; } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return next free value - * - * @param Societe $objsoc Object third party - * @param string $objforref Object for number to search - * @return string Next free value - */ - public function commande_get_num($objsoc, $objforref) - { - // phpcs:enable - return $this->getNextValue($objsoc, $objforref); - } } diff --git a/htdocs/core/modules/contract/mod_contract_magre.php b/htdocs/core/modules/contract/mod_contract_magre.php index f68e180a65c..ebd7957780f 100644 --- a/htdocs/core/modules/contract/mod_contract_magre.php +++ b/htdocs/core/modules/contract/mod_contract_magre.php @@ -105,7 +105,7 @@ class mod_contract_magre extends ModelNumRefContracts * Return next value * * @param Societe $objsoc third party object - * @param Object $contract contract object + * @param Contrat $contract contract object * @return string|0 Next value if OK, 0 if KO */ public function getNextValue($objsoc, $contract) @@ -125,18 +125,4 @@ class mod_contract_magre extends ModelNumRefContracts return $numFinal; } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return next value - * - * @param Societe $objsoc third party object - * @param Object $objforref contract object - * @return string|0 Value if OK, 0 if KO - */ - public function contract_get_num($objsoc, $objforref) - { - // phpcs:enable - return $this->getNextValue($objsoc, $objforref); - } } diff --git a/htdocs/core/modules/contract/mod_contract_serpis.php b/htdocs/core/modules/contract/mod_contract_serpis.php index fe155099ac7..d78c6ebbf89 100644 --- a/htdocs/core/modules/contract/mod_contract_serpis.php +++ b/htdocs/core/modules/contract/mod_contract_serpis.php @@ -76,7 +76,7 @@ class mod_contract_serpis extends ModelNumRefContracts /** * Test if existing numbers make problems with numbering * - * @param Object $object Object we need next value for + * @param Contrat $object Object we need next value for * @return boolean false if conflict, true if ok */ public function canBeActivated($object) @@ -113,7 +113,7 @@ class mod_contract_serpis extends ModelNumRefContracts * Return next value * * @param Societe $objsoc third party object - * @param Object $contract contract object + * @param Contrat $contract contract object * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($objsoc, $contract) @@ -151,19 +151,4 @@ class mod_contract_serpis extends ModelNumRefContracts dol_syslog("mod_contract_serpis::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return next value - * - * @param Societe $objsoc third party object - * @param Object $objforref contract object - * @return string|-1 Value if OK, -1 if KO - */ - public function contract_get_num($objsoc, $objforref) - { - // phpcs:enable - return $this->getNextValue($objsoc, $objforref); - } } diff --git a/htdocs/core/modules/delivery/mod_delivery_jade.php b/htdocs/core/modules/delivery/mod_delivery_jade.php index c29a5f7f4bd..95e3e0ff18e 100644 --- a/htdocs/core/modules/delivery/mod_delivery_jade.php +++ b/htdocs/core/modules/delivery/mod_delivery_jade.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin + * 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 @@ -86,7 +87,7 @@ class mod_delivery_jade extends ModeleNumRefDeliveryOrder * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param Object $object Object we need next value for + * @param Delivery $object Object we need next value for * @return boolean false if conflict, true if ok */ public function canBeActivated($object) @@ -126,7 +127,7 @@ class mod_delivery_jade extends ModeleNumRefDeliveryOrder * Return next free value * * @param Societe $objsoc Object thirdparty - * @param Object $object Object we need next value for + * @param Delivery $object Object we need next value for * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($objsoc, $object) @@ -168,19 +169,4 @@ class mod_delivery_jade extends ModeleNumRefDeliveryOrder dol_syslog("mod_delivery_jade::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return next free ref - * - * @param Societe $objsoc Object thirdparty - * @param Object $object Object livraison - * @return string|-1 Value if OK, -1 if KO - */ - public function delivery_get_num($objsoc = 0, $object = '') - { - // phpcs:enable - return $this->getNextValue($objsoc, $object); - } } diff --git a/htdocs/core/modules/delivery/mod_delivery_saphir.php b/htdocs/core/modules/delivery/mod_delivery_saphir.php index 209d848ec31..4d6bdb7c716 100644 --- a/htdocs/core/modules/delivery/mod_delivery_saphir.php +++ b/htdocs/core/modules/delivery/mod_delivery_saphir.php @@ -2,6 +2,7 @@ /* Copyright (C) 2003-2007 Rodolphe Quiedeville * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2005-2007 Regis Houssin + * 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 @@ -121,7 +122,7 @@ class mod_delivery_saphir extends ModeleNumRefDeliveryOrder * Return next value * * @param Societe $objsoc Object third party - * @param Object $object Object delivery + * @param Delivery $object Object delivery * @return string|0 Value if OK, 0 if KO */ public function getNextValue($objsoc, $object) @@ -148,26 +149,11 @@ class mod_delivery_saphir extends ModeleNumRefDeliveryOrder * Return next free value * * @param Societe $objsoc Object third party - * @param string $objforref Object for number to search + * @param Delivery $objforref Object for number to search * @return string|0 Next free value, 0 if KO */ public function getNumRef($objsoc, $objforref) { return $this->getNextValue($objsoc, $objforref); } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return next free ref - * - * @param Societe $objsoc Object thirdparty - * @param Object $object Object livraison - * @return string|0 Value if OK, 0 if KO - */ - public function delivery_get_num($objsoc = 0, $object = '') - { - // phpcs:enable - return $this->getNextValue($objsoc, $object); - } } diff --git a/htdocs/core/modules/expedition/mod_expedition_ribera.php b/htdocs/core/modules/expedition/mod_expedition_ribera.php index 2d8c5f7f138..4d85f303169 100644 --- a/htdocs/core/modules/expedition/mod_expedition_ribera.php +++ b/htdocs/core/modules/expedition/mod_expedition_ribera.php @@ -1,6 +1,6 @@ - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-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 @@ -117,7 +117,7 @@ class mod_expedition_ribera extends ModelNumRefExpedition * Return next value * * @param Societe $objsoc Third party object - * @param Object $shipment Shipment object + * @param Expedition $shipment Shipment object * @return string|0 Value if OK, 0 if KO */ public function getNextValue($objsoc, $shipment) @@ -139,18 +139,4 @@ class mod_expedition_ribera extends ModelNumRefExpedition return $numFinal; } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return next free value - * - * @param Societe $objsoc Third party object - * @param Object $objforref Shipment object - * @return string|0 Next free value, 0 if KO - */ - public function expedition_get_num($objsoc, $objforref) - { - // phpcs:enable - return $this->getNextValue($objsoc, $objforref); - } } diff --git a/htdocs/core/modules/expedition/mod_expedition_safor.php b/htdocs/core/modules/expedition/mod_expedition_safor.php index 579ba6a4d4f..98f20203fa2 100644 --- a/htdocs/core/modules/expedition/mod_expedition_safor.php +++ b/htdocs/core/modules/expedition/mod_expedition_safor.php @@ -1,5 +1,6 @@ + * 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 @@ -81,7 +82,7 @@ class mod_expedition_safor extends ModelNumRefExpedition /** * Test if existing numbers make problems with numbering * - * @param Object $object Object we need next value for + * @param Expedition $object Object we need next value for * @return boolean false if conflict, true if ok */ public function canBeActivated($object) @@ -118,7 +119,7 @@ class mod_expedition_safor extends ModelNumRefExpedition * Return next value * * @param Societe $objsoc Third party object - * @param Object $shipment Shipment object + * @param Expedition $shipment Shipment object * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($objsoc, $shipment) @@ -156,18 +157,4 @@ class mod_expedition_safor extends ModelNumRefExpedition dol_syslog("mod_expedition_safor::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return next free value - * - * @param Societe $objsoc Third party object - * @param Object $objforref Shipment object - * @return string|-1 Next free value, -1 if KO - */ - public function expedition_get_num($objsoc, $objforref) - { - // phpcs:enable - return $this->getNextValue($objsoc, $objforref); - } } diff --git a/htdocs/core/modules/expensereport/mod_expensereport_jade.php b/htdocs/core/modules/expensereport/mod_expensereport_jade.php index 60de9d22014..ddac61f46c5 100644 --- a/htdocs/core/modules/expensereport/mod_expensereport_jade.php +++ b/htdocs/core/modules/expensereport/mod_expensereport_jade.php @@ -1,5 +1,6 @@ + * 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,8 +83,8 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param Object $object Object we need next value for - * @return boolean false if conflict, true if ok + * @param ExpenseReport $object Object we need next value for + * @return boolean false if conflict, true if ok */ public function canBeActivated($object) { diff --git a/htdocs/core/modules/expensereport/mod_expensereport_sand.php b/htdocs/core/modules/expensereport/mod_expensereport_sand.php index 8a0165e3799..5bb216e5f65 100644 --- a/htdocs/core/modules/expensereport/mod_expensereport_sand.php +++ b/htdocs/core/modules/expensereport/mod_expensereport_sand.php @@ -1,5 +1,6 @@ + * 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 @@ -120,8 +121,8 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport /** * Return next free value * - * @param Object $object Object we need next value for - * @return string|0 Next value if OK, 0 if KO + * @param ExpenseReport $object Object we need next value for + * @return string|0 Next value if OK, 0 if KO */ public function getNextValue($object) { diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index 10d42804a9c..71f9fb27eec 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2008 Laurent Destailleur * Copyright (C) 2005-2018 Regis Houssin * Copyright (C) 2013 Juanjo Menent + * 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 @@ -96,7 +97,7 @@ class mod_facture_mars extends ModeleNumRefFactures * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param Object $object Object we need next value for + * @param Facture $object Object we need next value for * @return boolean false if conflict, true if ok */ public function canBeActivated($object) @@ -243,7 +244,7 @@ class mod_facture_mars extends ModeleNumRefFactures * Return next free value * * @param Societe $objsoc Object third party - * @param string $objforref Object for number to search + * @param Facture $objforref Object for number to search * @param string $mode 'next' for next value or 'last' for last value * @return string Next free value */ diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php index 1aae660c1a9..8d1194b7d4a 100644 --- a/htdocs/core/modules/facture/mod_facture_mercure.php +++ b/htdocs/core/modules/facture/mod_facture_mercure.php @@ -5,6 +5,7 @@ * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2013 uanjo Menent * Copyright (C) 2022 Anthony Berton + * 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 @@ -178,7 +179,7 @@ class mod_facture_mercure extends ModeleNumRefFactures * Return next free value * * @param Societe $objsoc Object third party - * @param string $objforref Object for number to search + * @param Facture $objforref Object for number to search * @param string $mode 'next' for next value or 'last' for last value * @return string|0 Next free value, 0 if KO */ diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php index 3336340cd63..bf116118024 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -1,6 +1,7 @@ * Copyright (C) 2005-2015 Regis Houssin + * 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 @@ -112,7 +113,7 @@ class mod_facture_terre extends ModeleNumRefFactures * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param Object $object Object we need next value for + * @param Facture $object Object we need next value for * @return boolean false if conflict, true if ok */ public function canBeActivated($object) @@ -283,7 +284,7 @@ class mod_facture_terre extends ModeleNumRefFactures * Return next free value * * @param Societe $objsoc Object third party - * @param string $objforref Object for number to search + * @param Facture $objforref Object for number to search * @param string $mode 'next' for next value or 'last' for last value * @return string|int<-1,0> Next free value, -1 or 0 if error */ diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php index 9039c9a2907..c0787d83fe9 100644 --- a/htdocs/core/modules/societe/mod_codeclient_elephant.php +++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php @@ -125,7 +125,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode * Return an example of result returned by getNextValue * * @param Translate $langs Object langs - * @param societe $objsoc Object thirdparty + * @param Societe $objsoc Object thirdparty * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Return string example */ diff --git a/htdocs/core/modules/societe/mod_codeclient_leopard.php b/htdocs/core/modules/societe/mod_codeclient_leopard.php index 9729c15e7d7..4d4870a3f35 100644 --- a/htdocs/core/modules/societe/mod_codeclient_leopard.php +++ b/htdocs/core/modules/societe/mod_codeclient_leopard.php @@ -77,7 +77,7 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode * Return an example of result returned by getNextValue * * @param Translate $langs Object langs - * @param societe $objsoc Object thirdparty + * @param Societe $objsoc Object thirdparty * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Return string example */ @@ -89,7 +89,7 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode /** * Return an example of result returned by getNextValue * - * @param societe $objsoc Object thirdparty + * @param Societe $objsoc Object thirdparty * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Return next value */ diff --git a/htdocs/core/modules/societe/mod_codeclient_monkey.php b/htdocs/core/modules/societe/mod_codeclient_monkey.php index 1d843fd007e..7c9457bd904 100644 --- a/htdocs/core/modules/societe/mod_codeclient_monkey.php +++ b/htdocs/core/modules/societe/mod_codeclient_monkey.php @@ -77,7 +77,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode * Return an example of result returned by getNextValue * * @param Translate $langs Object langs - * @param societe $objsoc Object thirdparty + * @param Societe $objsoc Object thirdparty * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Return string example */ From f19fc5c70ce7bc70f116e186fa5d6fadfb76ed7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Mon, 11 Mar 2024 18:18:59 +0100 Subject: [PATCH 27/60] clean code and phpdoc --- htdocs/core/modules/fichinter/mod_arctic.php | 5 +++-- htdocs/core/modules/fichinter/mod_pacific.php | 11 ++++++----- .../holiday/mod_holiday_immaculate.php | 16 +--------------- .../modules/holiday/mod_holiday_madonna.php | 19 ++----------------- .../modules/hrm/mod_evaluation_advanced.php | 4 ++-- .../modules/hrm/mod_evaluation_standard.php | 5 +++-- 6 files changed, 17 insertions(+), 43 deletions(-) diff --git a/htdocs/core/modules/fichinter/mod_arctic.php b/htdocs/core/modules/fichinter/mod_arctic.php index 4e23b6cb1e3..54362d39bd4 100644 --- a/htdocs/core/modules/fichinter/mod_arctic.php +++ b/htdocs/core/modules/fichinter/mod_arctic.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2013 Juanjo Menent + * 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 @@ -121,7 +122,7 @@ class mod_arctic extends ModeleNumRefFicheinter * Return next free value * * @param Societe $objsoc Object thirdparty - * @param Object $object Object we need next value for + * @param Fichinter $object Object we need next value for * @return string|0 Value if OK, 0 if KO */ public function getNextValue($objsoc = 0, $object = '') @@ -148,7 +149,7 @@ class mod_arctic extends ModeleNumRefFicheinter * Return next free value * * @param Societe $objsoc Object third party - * @param Object $objforref Object for number to search + * @param Fichinter $objforref Object for number to search * @return string|0 Next free value, 0 if KO */ public function getNumRef($objsoc, $objforref) diff --git a/htdocs/core/modules/fichinter/mod_pacific.php b/htdocs/core/modules/fichinter/mod_pacific.php index 1892d9f3759..a1f90012125 100644 --- a/htdocs/core/modules/fichinter/mod_pacific.php +++ b/htdocs/core/modules/fichinter/mod_pacific.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2008 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2013 Juanjo Menent + * 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,7 +83,7 @@ class mod_pacific extends ModeleNumRefFicheinter * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param Object $object Object we need next value for + * @param Fichinter $object Object we need next value for * @return boolean false if conflict, true if ok */ public function canBeActivated($object) @@ -121,7 +122,7 @@ class mod_pacific extends ModeleNumRefFicheinter * Return next free value * * @param Societe $objsoc Object thirdparty - * @param Object $object Object we need next value for + * @param Fichinter $object Object we need next value for * @return string Value if KO, <0 if KO */ public function getNextValue($objsoc = 0, $object = '') @@ -161,9 +162,9 @@ class mod_pacific extends ModeleNumRefFicheinter /** * Return next free value * - * @param Societe $objsoc Object third party - * @param Object $objforref Object for number to search - * @return string Next free value + * @param Societe $objsoc Object third party + * @param Fichinter $objforref Object for number to search + * @return string Next free value */ public function getNumRef($objsoc, $objforref) { diff --git a/htdocs/core/modules/holiday/mod_holiday_immaculate.php b/htdocs/core/modules/holiday/mod_holiday_immaculate.php index ca246324929..434b9614985 100644 --- a/htdocs/core/modules/holiday/mod_holiday_immaculate.php +++ b/htdocs/core/modules/holiday/mod_holiday_immaculate.php @@ -105,7 +105,7 @@ class mod_holiday_immaculate extends ModelNumRefHolidays * Return next value * * @param Societe $objsoc third party object - * @param Object $holiday holiday object + * @param Holiday $holiday holiday object * @return string|0 Value if OK, 0 if KO */ public function getNextValue($objsoc, $holiday) @@ -125,18 +125,4 @@ class mod_holiday_immaculate extends ModelNumRefHolidays return $numFinal; } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return next value - * - * @param User $fuser User object - * @param Object $objforref Holiday object - * @return string|0 Value if OK, 0 if KO - */ - public function holiday_get_num($fuser, $objforref) - { - // phpcs:enable - return $this->getNextValue($fuser, $objforref); - } } diff --git a/htdocs/core/modules/holiday/mod_holiday_madonna.php b/htdocs/core/modules/holiday/mod_holiday_madonna.php index d2eeceeafc2..636ee4269d3 100644 --- a/htdocs/core/modules/holiday/mod_holiday_madonna.php +++ b/htdocs/core/modules/holiday/mod_holiday_madonna.php @@ -77,7 +77,7 @@ class mod_holiday_madonna extends ModelNumRefHolidays /** * Test if existing numbers make problems with numbering * - * @param Object $object Object we need next value for + * @param Holiday $object Object we need next value for * @return boolean false if conflict, true if ok */ public function canBeActivated($object) @@ -114,7 +114,7 @@ class mod_holiday_madonna extends ModelNumRefHolidays * Return next value * * @param Societe $objsoc third party object - * @param Object $holiday Holiday object + * @param Holiday $holiday Holiday object * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($objsoc, $holiday) @@ -152,19 +152,4 @@ class mod_holiday_madonna extends ModelNumRefHolidays dol_syslog("mod_holiday_madonna::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return next value - * - * @param User $fuser User object - * @param Object $objforref Holiday object - * @return string|-1 Value if OK, -1 if KO - */ - public function holiday_get_num($fuser, $objforref) - { - // phpcs:enable - return $this->getNextValue($fuser, $objforref); - } } diff --git a/htdocs/core/modules/hrm/mod_evaluation_advanced.php b/htdocs/core/modules/hrm/mod_evaluation_advanced.php index 2c89930a5ab..78d396d909b 100644 --- a/htdocs/core/modules/hrm/mod_evaluation_advanced.php +++ b/htdocs/core/modules/hrm/mod_evaluation_advanced.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-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 @@ -123,7 +123,7 @@ class mod_evaluation_advanced extends ModeleNumRefEvaluation /** * Return next free value * - * @param Object $object Object we need next value for + * @param Evaluation $object Object we need next value for * @return string|0 Value if OK, 0 if KO */ public function getNextValue($object) diff --git a/htdocs/core/modules/hrm/mod_evaluation_standard.php b/htdocs/core/modules/hrm/mod_evaluation_standard.php index 17cb75ad4ea..418b7b1e5ba 100644 --- a/htdocs/core/modules/hrm/mod_evaluation_standard.php +++ b/htdocs/core/modules/hrm/mod_evaluation_standard.php @@ -1,6 +1,7 @@ * Copyright (C) 2005-2009 Regis Houssin + * 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 @@ -77,7 +78,7 @@ class mod_evaluation_standard extends ModeleNumRefEvaluation * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param Object $object Object we need next value for + * @param Evaluation $object Object we need next value for * @return boolean false if conflict, true if ok */ public function canBeActivated($object) @@ -117,7 +118,7 @@ class mod_evaluation_standard extends ModeleNumRefEvaluation /** * Return next free value * - * @param Object $object Object we need next value for + * @param Evaluation $object Object we need next value for * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($object) From 9cc32d70d29ea48bedecf85ebeba0e6b0a06cfdf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Mar 2024 18:25:48 +0100 Subject: [PATCH 28/60] Clean code --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index eedaa168c37..8565e7260e1 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4951,7 +4951,7 @@ class Societe extends CommonObject */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { - global $conf, $user, $langs; + global $langs; if (!empty($moreparams) && !empty($moreparams['use_companybankid'])) { $modelpath = "core/modules/bank/doc/"; From 330abe14fe8568cfa499d59c44f5107580e6028a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Mar 2024 18:28:20 +0100 Subject: [PATCH 29/60] FIX Option MAIN_DOC_USE_TIMING can be a string with date format --- .../core/modules/asset/doc/doc_generic_asset_odt.modules.php | 4 ++-- htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php | 4 ++-- .../modules/commande/doc/doc_generic_order_odt.modules.php | 4 ++-- .../modules/contract/doc/doc_generic_contract_odt.modules.php | 4 ++-- .../expedition/doc/doc_generic_shipment_odt.modules.php | 4 ++-- .../modules/facture/doc/doc_generic_invoice_odt.modules.php | 4 ++-- .../core/modules/member/doc/doc_generic_member_odt.class.php | 4 ++-- htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php | 4 ++-- .../modules/product/doc/doc_generic_product_odt.modules.php | 4 ++-- .../modules/project/doc/doc_generic_project_odt.modules.php | 4 ++-- .../modules/propale/doc/doc_generic_proposal_odt.modules.php | 4 ++-- .../reception/doc/doc_generic_reception_odt.modules.php | 4 ++-- htdocs/core/modules/societe/doc/doc_generic_odt.modules.php | 4 ++-- .../core/modules/stock/doc/doc_generic_stock_odt.modules.php | 4 ++-- .../doc/doc_generic_supplier_invoice_odt.modules.php | 4 ++-- .../doc/doc_generic_supplier_order_odt.modules.php | 4 ++-- .../doc/doc_generic_supplier_proposal_odt.modules.php | 4 ++-- .../modules/ticket/doc/doc_generic_ticket_odt.modules.php | 4 ++-- htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php | 4 ++-- .../usergroup/doc/doc_generic_usergroup_odt.modules.php | 4 ++-- .../doc/doc_generic_recruitmentjobposition_odt.modules.php | 4 ++-- 21 files changed, 42 insertions(+), 42 deletions(-) diff --git a/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php b/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php index 15d95bde92e..ca77c6f13d0 100644 --- a/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php +++ b/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php @@ -262,8 +262,8 @@ class doc_generic_asset_odt extends ModelePDFAsset //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { - $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); + if (getDolGlobalString('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalString('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php index 1fcc55446a8..9e3df7965fb 100644 --- a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php +++ b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php @@ -274,8 +274,8 @@ class doc_generic_bom_odt extends ModelePDFBom //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { - $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); + if (getDolGlobalString('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalString('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index e8d7abfe0d7..63884795307 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -280,8 +280,8 @@ class doc_generic_order_odt extends ModelePDFCommandes // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { - $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); + if (getDolGlobalString('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalString('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index 515109c4f20..dffded55555 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -278,8 +278,8 @@ class doc_generic_contract_odt extends ModelePDFContract // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { - $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); + if (getDolGlobalString('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalString('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php index 219c0f47029..a678d8265c5 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -278,8 +278,8 @@ class doc_generic_shipment_odt extends ModelePdfExpedition //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { - $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); + if (getDolGlobalString('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalString('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index b74934d96a4..6b28da3e1e1 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -278,8 +278,8 @@ class doc_generic_invoice_odt extends ModelePDFFactures // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { - $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); + if (getDolGlobalString('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalString('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php index 2076e156bac..bff58b2737f 100644 --- a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php +++ b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php @@ -268,8 +268,8 @@ class doc_generic_member_odt extends ModelePDFMember // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { - $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); + if (getDolGlobalString('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalString('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php index fe18e6eb6ea..fe33eec3bba 100644 --- a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php +++ b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php @@ -267,8 +267,8 @@ class doc_generic_mo_odt extends ModelePDFMo //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { - $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); + if (getDolGlobalString('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalString('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php index 2728bf266c2..8f799be03ae 100644 --- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php +++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php @@ -276,8 +276,8 @@ class doc_generic_product_odt extends ModelePDFProduct // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { - $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); + if (getDolGlobalString('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalString('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index e8c1357e7a2..d3cf5e7440c 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -559,8 +559,8 @@ class doc_generic_project_odt extends ModelePDFProjects //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { - $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); + if (getDolGlobalString('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalString('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index 734ebdc5137..0c6ef9df011 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -312,8 +312,8 @@ class doc_generic_proposal_odt extends ModelePDFPropales // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { - $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); + if (getDolGlobalString('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalString('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php index 2bc493eb580..71fcf65b197 100644 --- a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php +++ b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php @@ -271,8 +271,8 @@ class doc_generic_reception_odt extends ModelePdfReception //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { - $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); + if (getDolGlobalString('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalString('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index 261aeef9ad5..374c44c7a25 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -252,8 +252,8 @@ class doc_generic_odt extends ModeleThirdPartyDoc $newfiletmp = dol_sanitizeFileName(dol_string_nospecial($object->name)) . '-' . $newfiletmp; $newfiletmp = preg_replace('/__+/', '_', $newfiletmp); // Replace repeated _ into one _ (to avoid string with substitution syntax) } - if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { - $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); + if (getDolGlobalString('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalString('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php index 5aae143fc2b..a0e89ad1d76 100644 --- a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php +++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php @@ -278,8 +278,8 @@ class doc_generic_stock_odt extends ModelePDFStock // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { - $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); + if (getDolGlobalString('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalString('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php b/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php index 6031907b305..27cb836e420 100644 --- a/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php @@ -271,8 +271,8 @@ class doc_generic_supplier_invoice_odt extends ModelePDFSuppliersInvoices //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { - $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); + if (getDolGlobalString('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalString('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php index 285be7c2799..ff7a4f33d36 100644 --- a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php +++ b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php @@ -266,8 +266,8 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { - $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); + if (getDolGlobalString('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalString('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php index bbc0fdb583a..35bf81667f8 100644 --- a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php @@ -300,8 +300,8 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { - $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); + if (getDolGlobalString('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalString('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php index 7aa6b4a07e4..9b6646c313b 100644 --- a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php +++ b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php @@ -266,8 +266,8 @@ class doc_generic_ticket_odt extends ModelePDFTicket // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { - $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); + if (getDolGlobalString('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalString('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php index d6e52e2f21e..6e671eadae0 100644 --- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php +++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php @@ -300,8 +300,8 @@ class doc_generic_user_odt extends ModelePDFUser // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { - $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); + if (getDolGlobalString('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalString('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php index 74ad5902966..666a7945e2d 100644 --- a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php +++ b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php @@ -282,8 +282,8 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { - $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); + if (getDolGlobalString('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalString('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php index a93a724fbd9..da7640d708a 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php @@ -267,8 +267,8 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { - $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); + if (getDolGlobalString('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalString('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } From e160ba6ba441a42aa96bdd8044f48d86c4b9bcd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Mon, 11 Mar 2024 18:29:41 +0100 Subject: [PATCH 30/60] clean code and phpdoc --- .../modules/member/mod_member_advanced.php | 2 +- .../core/modules/member/mod_member_simple.php | 2 +- htdocs/core/modules/mrp/mod_mo_advanced.php | 4 ++-- htdocs/core/modules/mrp/mod_mo_standard.php | 5 +++-- .../product_batch/mod_lot_standard.php | 3 ++- .../modules/product_batch/mod_sn_standard.php | 3 ++- .../modules/project/mod_project_simple.php | 3 ++- .../modules/project/mod_project_universal.php | 16 +--------------- .../modules/propale/mod_propale_marbre.php | 5 +++-- .../modules/reception/mod_reception_beryl.php | 19 +++---------------- .../reception/mod_reception_moonstone.php | 18 ++---------------- .../societe/mod_codecompta_aquarium.php | 3 ++- .../mod_stocktransfer_advanced.php | 6 +++--- .../mod_stocktransfer_standard.php | 9 +++++---- 14 files changed, 32 insertions(+), 66 deletions(-) diff --git a/htdocs/core/modules/member/mod_member_advanced.php b/htdocs/core/modules/member/mod_member_advanced.php index 2147961ea82..4ed9bb1740c 100644 --- a/htdocs/core/modules/member/mod_member_advanced.php +++ b/htdocs/core/modules/member/mod_member_advanced.php @@ -79,7 +79,7 @@ class mod_member_advanced extends ModeleNumRefMembers * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param Object $object Object we need next value for + * @param Adherent $object Object we need next value for * @return boolean false if conflict, true if ok */ public function canBeActivated($object) diff --git a/htdocs/core/modules/member/mod_member_simple.php b/htdocs/core/modules/member/mod_member_simple.php index c76d7a38c38..77b1bd8632d 100644 --- a/htdocs/core/modules/member/mod_member_simple.php +++ b/htdocs/core/modules/member/mod_member_simple.php @@ -79,7 +79,7 @@ class mod_member_simple extends ModeleNumRefMembers * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param Object $object Object we need next value for + * @param Adherent $object Object we need next value for * @return boolean false if KO (there is a conflict), true if OK */ public function canBeActivated($object) diff --git a/htdocs/core/modules/mrp/mod_mo_advanced.php b/htdocs/core/modules/mrp/mod_mo_advanced.php index b04001e84d3..fe2948e1ea5 100644 --- a/htdocs/core/modules/mrp/mod_mo_advanced.php +++ b/htdocs/core/modules/mrp/mod_mo_advanced.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-2024 Frédéric France * Copyright (C) 2020 Josep Lluís Amador * * This program is free software; you can redistribute it and/or modify @@ -120,7 +120,7 @@ class mod_mo_advanced extends ModeleNumRefMos * Return next free value * * @param Product $objprod Object product - * @param Object $object Object we need next value for + * @param Mo $object Object we need next value for * @return string|0 Value if OK, 0 if KO */ public function getNextValue($objprod, $object) diff --git a/htdocs/core/modules/mrp/mod_mo_standard.php b/htdocs/core/modules/mrp/mod_mo_standard.php index d1e294fd3d3..191bf3439d6 100644 --- a/htdocs/core/modules/mrp/mod_mo_standard.php +++ b/htdocs/core/modules/mrp/mod_mo_standard.php @@ -1,6 +1,7 @@ * Copyright (C) 2005-2009 Regis Houssin + * 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 @@ -76,7 +77,7 @@ class mod_mo_standard extends ModeleNumRefMos * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param Object $object Object we need next value for + * @param Mo $object Object we need next value for * @return boolean false if conflict, true if ok */ public function canBeActivated($object) @@ -113,7 +114,7 @@ class mod_mo_standard extends ModeleNumRefMos * Return next free value * * @param Product $objprod Object product - * @param Object $object Object we need next value for + * @param Mo $object Object we need next value for * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($objprod, $object) diff --git a/htdocs/core/modules/product_batch/mod_lot_standard.php b/htdocs/core/modules/product_batch/mod_lot_standard.php index 82e4098a246..43a33dbba67 100644 --- a/htdocs/core/modules/product_batch/mod_lot_standard.php +++ b/htdocs/core/modules/product_batch/mod_lot_standard.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2021 Christophe Battarel + * 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 @@ -77,7 +78,7 @@ class mod_lot_standard extends ModeleNumRefBatch * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param Object $object Object we need next value for + * @param Productlot $object Object we need next value for * @return boolean false if KO (there is a conflict), true if OK */ public function canBeActivated($object) diff --git a/htdocs/core/modules/product_batch/mod_sn_standard.php b/htdocs/core/modules/product_batch/mod_sn_standard.php index 42986330cf8..474b6531c65 100644 --- a/htdocs/core/modules/product_batch/mod_sn_standard.php +++ b/htdocs/core/modules/product_batch/mod_sn_standard.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2021 Christophe Battarel + * 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 @@ -77,7 +78,7 @@ class mod_sn_standard extends ModeleNumRefBatch * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param Object $object Object we need next value for + * @param Productlot $object Object we need next value for * @return boolean false if KO (there is a conflict), true if OK */ public function canBeActivated($object) diff --git a/htdocs/core/modules/project/mod_project_simple.php b/htdocs/core/modules/project/mod_project_simple.php index 69229dcf77f..8dac1238ab2 100644 --- a/htdocs/core/modules/project/mod_project_simple.php +++ b/htdocs/core/modules/project/mod_project_simple.php @@ -1,6 +1,7 @@ * Copyright (C) 2010 Laurent Destailleur + * 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 @@ -85,7 +86,7 @@ class mod_project_simple extends ModeleNumRefProjects * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param Object $object Object we need next value for + * @param Project $object Object we need next value for * @return boolean false if KO (there is a conflict), true if OK */ public function canBeActivated($object) diff --git a/htdocs/core/modules/project/mod_project_universal.php b/htdocs/core/modules/project/mod_project_universal.php index e4b280cf226..6ed05b3e728 100644 --- a/htdocs/core/modules/project/mod_project_universal.php +++ b/htdocs/core/modules/project/mod_project_universal.php @@ -1,5 +1,6 @@ + * 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 @@ -150,19 +151,4 @@ class mod_project_universal extends ModeleNumRefProjects return $numFinal; } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return next reference not yet used as a reference - * - * @param Societe $objsoc Object third party - * @param Project $project Object project - * @return string|0 Next not used reference, 0 if KO - */ - public function project_get_num($objsoc = 0, $project = '') - { - // phpcs:enable - return $this->getNextValue($objsoc, $project); - } } diff --git a/htdocs/core/modules/propale/mod_propale_marbre.php b/htdocs/core/modules/propale/mod_propale_marbre.php index e5a8c1a0d9d..e38d8076604 100644 --- a/htdocs/core/modules/propale/mod_propale_marbre.php +++ b/htdocs/core/modules/propale/mod_propale_marbre.php @@ -1,6 +1,7 @@ * Copyright (C) 2005-2012 Regis Houssin + * 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 @@ -85,7 +86,7 @@ class mod_propale_marbre extends ModeleNumRefPropales * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param Object $object Object we need next value for + * @param Propal $object Object we need next value for * @return boolean false if KO (there is a conflict), true if OK */ public function canBeActivated($object) @@ -167,7 +168,7 @@ class mod_propale_marbre extends ModeleNumRefPropales * Return next free value * * @param Societe $objsoc Object third party - * @param Object $objforref Object for number to search + * @param Propal $objforref Object for number to search * @return string|-1 Next free value, -1 if KO */ public function getNumRef($objsoc, $objforref) diff --git a/htdocs/core/modules/reception/mod_reception_beryl.php b/htdocs/core/modules/reception/mod_reception_beryl.php index 164732886a3..896d8f86fb6 100644 --- a/htdocs/core/modules/reception/mod_reception_beryl.php +++ b/htdocs/core/modules/reception/mod_reception_beryl.php @@ -1,5 +1,6 @@ + * 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 @@ -61,7 +62,7 @@ class mod_reception_beryl extends ModelNumRefReception /** * Test if existing numbers make problems with numbering * - * @param Object $object Object we need next value for + * @param Reception $object Object we need next value for * @return boolean false if KO (there is a conflict), true if OK */ public function canBeActivated($object) @@ -98,7 +99,7 @@ class mod_reception_beryl extends ModelNumRefReception * Return next value * * @param Societe $objsoc Third party object - * @param Object $reception Reception object + * @param Reception $reception Reception object * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($objsoc, $reception) @@ -136,18 +137,4 @@ class mod_reception_beryl extends ModelNumRefReception dol_syslog("mod_reception_beryl::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return next free value - * - * @param Societe $objsoc Third party object - * @param Object $objforref Shipment object - * @return string|-1 Next free value, -1 if KO - */ - public function reception_get_num($objsoc, $objforref) - { - // phpcs:enable - return $this->getNextValue($objsoc, $objforref); - } } diff --git a/htdocs/core/modules/reception/mod_reception_moonstone.php b/htdocs/core/modules/reception/mod_reception_moonstone.php index 8742dede043..0ccf7ff1328 100644 --- a/htdocs/core/modules/reception/mod_reception_moonstone.php +++ b/htdocs/core/modules/reception/mod_reception_moonstone.php @@ -1,6 +1,6 @@ - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-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 @@ -98,7 +98,7 @@ class mod_reception_moonstone extends ModelNumRefReception * Return next value * * @param Societe $objsoc Third party object - * @param Object|null $reception Reception object + * @param Receptiont|null $reception Reception object * @return string|0 Value if OK, 0 if KO */ public function getNextValue($objsoc, $reception) @@ -124,18 +124,4 @@ class mod_reception_moonstone extends ModelNumRefReception return $numFinal; } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return next free value - * - * @param Societe $objsoc Third party object - * @param Object $objforref Reception object - * @return string|0 Next free value, 0 if KO - */ - public function reception_get_num($objsoc, $objforref) - { - // phpcs:enable - return $this->getNextValue($objsoc, $objforref); - } } diff --git a/htdocs/core/modules/societe/mod_codecompta_aquarium.php b/htdocs/core/modules/societe/mod_codecompta_aquarium.php index cd73e6a0473..264ee51741b 100644 --- a/htdocs/core/modules/societe/mod_codecompta_aquarium.php +++ b/htdocs/core/modules/societe/mod_codecompta_aquarium.php @@ -3,6 +3,7 @@ * Copyright (C) 2005 Eric Seigne * Copyright (C) 2006-2011 Laurent Destailleur * 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 @@ -130,7 +131,7 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode * Return an example of result returned by getNextValue * * @param Translate $langs Object langs - * @param societe $objsoc Object thirdparty + * @param Societe $objsoc Object thirdparty * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Return string example */ diff --git a/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php b/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php index 21da56af6bc..5860b120342 100644 --- a/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php +++ b/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-2024 Frédéric France * Copyright (C) 2021 Gauthier VERDOL * * This program is free software; you can redistribute it and/or modify @@ -124,8 +124,8 @@ class mod_stocktransfer_advanced extends ModeleNumRefStockTransfer /** * Return next free value * - * @param Object $object Object we need next value for - * @return string|0 Value if OK, 0 if KO + * @param StockTransfer $object Object we need next value for + * @return string|0 Value if OK, 0 if KO */ public function getNextValue($object) { diff --git a/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php b/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php index c1e16da016b..35e02b76fa4 100644 --- a/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php +++ b/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2021 Gauthier VERDOL + * 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 @@ -78,8 +79,8 @@ class mod_stocktransfer_standard extends ModeleNumRefStockTransfer * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param Object $object Object we need next value for - * @return boolean false if conflict, true if ok + * @param StockTransfer $object Object we need next value for + * @return boolean false if conflict, true if ok */ public function canBeActivated($object) { @@ -118,8 +119,8 @@ class mod_stocktransfer_standard extends ModeleNumRefStockTransfer /** * Return next free value * - * @param Object $object Object we need next value for - * @return string|-1 Value if OK, -1 if KO + * @param StockTransfer $object Object we need next value for + * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($object) { From 6f3ba871e0ecc80d243c528c6e4c448ddbdd8825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Mon, 11 Mar 2024 18:33:41 +0100 Subject: [PATCH 31/60] clean code and phpdoc --- .../mod_facture_fournisseur_cactus.php | 19 +++++++++-------- .../mod_facture_fournisseur_tulip.php | 21 ++++++++++--------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php index 418db94b07e..95612da93f0 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2013-2018 Philippe Grand * Copyright (C) 2016 Alexandre Spangaro + * 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 @@ -91,7 +92,7 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices /** * Tests if the numbers already in the database do not cause conflicts that would prevent this numbering. * - * @param Object $object Object we need next value for + * @param FactureFournisseur $object Object we need next value for * @return boolean false if KO (there is a conflict), true if OK */ public function canBeActivated($object) @@ -173,10 +174,10 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices /** * Return next value * - * @param Societe $objsoc Object third party - * @param Object $object Object invoice - * @param string $mode 'next' for next value or 'last' for last value - * @return string|-1 Value if OK, -1 if KO + * @param Societe $objsoc Object third party + * @param FactureFournisseur $object Object invoice + * @param string $mode 'next' for next value or 'last' for last value + * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($objsoc, $object, $mode = 'next') { @@ -256,10 +257,10 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices /** * Return next free value * - * @param Societe $objsoc Object third party - * @param string $objforref Object for number to search - * @param string $mode 'next' for next value or 'last' for last value - * @return string Next free value + * @param Societe $objsoc Object third party + * @param FactureFournisseur $objforref Object for number to search + * @param string $mode 'next' for next value or 'last' for last value + * @return string Next free value */ public function getNumRef($objsoc, $objforref, $mode = 'next') { diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php index b567b7e5522..39643722cf5 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php @@ -5,6 +5,7 @@ * Copyright (C) 2013-2018 Philippe Grand * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2016-2021 Alexandre Spangaro + * 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 @@ -31,8 +32,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_invoice/modules_facturefo /** - \class mod_facture_fournisseur_tulip - \brief Tulip Class of numbering models of suppliers invoices references + * \class mod_facture_fournisseur_tulip + * \brief Tulip Class of numbering models of suppliers invoices references */ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices { @@ -146,10 +147,10 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices /** * Return next value * - * @param Societe $objsoc Object third party - * @param Object $object Object invoice - * @param string $mode 'next' for next value or 'last' for last value - * @return string|0 Value if OK, 0 if KO + * @param Societe $objsoc Object third party + * @param FactureFournisseur $object Object invoice + * @param string $mode 'next' for next value or 'last' for last value + * @return string|0 Value if OK, 0 if KO */ public function getNextValue($objsoc, $object, $mode = 'next') { @@ -185,10 +186,10 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices /** * Return next free value * - * @param Societe $objsoc Object third party - * @param string $objforref Object for number to search - * @param string $mode 'next' for next value or 'last' for last value - * @return string Next free value + * @param Societe $objsoc Object third party + * @param FactureFournisseur $objforref Object for number to search + * @param string $mode 'next' for next value or 'last' for last value + * @return string Next free value */ public function getNumRef($objsoc, $objforref, $mode = 'next') { From 71a65557bb8e81e4c80941a5c90549d49cf7c232 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Mon, 11 Mar 2024 18:36:05 +0100 Subject: [PATCH 32/60] clean code and phpdoc --- .../reception/mod_reception_moonstone.php | 2 +- .../mod_commande_fournisseur_muguet.php | 24 ++++--------------- .../mod_commande_fournisseur_orchidee.php | 22 ++++------------- 3 files changed, 10 insertions(+), 38 deletions(-) diff --git a/htdocs/core/modules/reception/mod_reception_moonstone.php b/htdocs/core/modules/reception/mod_reception_moonstone.php index 0ccf7ff1328..9acf2cfd161 100644 --- a/htdocs/core/modules/reception/mod_reception_moonstone.php +++ b/htdocs/core/modules/reception/mod_reception_moonstone.php @@ -98,7 +98,7 @@ class mod_reception_moonstone extends ModelNumRefReception * Return next value * * @param Societe $objsoc Third party object - * @param Receptiont|null $reception Reception object + * @param Reception|null $reception Reception object * @return string|0 Value if OK, 0 if KO */ public function getNextValue($objsoc, $reception) diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php index 35aec96e909..1ff309bdcdf 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php @@ -1,6 +1,7 @@ * Copyright (C) 2005-2009 Regis Houssin + * 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 @@ -95,7 +96,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param Object $object Object we need next value for + * @param CommandeFournisseur $object Object we need next value for * @return boolean false if KO (there is a conflict), true if OK */ public function canBeActivated($object) @@ -130,9 +131,9 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders /** * Return next value * - * @param Societe $objsoc Object third party - * @param Object $object Object - * @return string Value if OK, 0 if KO + * @param Societe $objsoc Object third party + * @param CommandeFournisseur $object Object + * @return string Value if OK, 0 if KO */ public function getNextValue($objsoc = 0, $object = '') { @@ -170,19 +171,4 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders return $this->prefix.$yymm."-".$num; } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Renvoie la reference de commande suivante non utilisee - * - * @param Societe $objsoc Object third party - * @param Object $object Object - * @return string Descriptive text - */ - public function commande_get_num($objsoc = 0, $object = '') - { - // phpcs:enable - return $this->getNextValue($objsoc, $object); - } } diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php index a0322ab2956..db138369a53 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php @@ -2,6 +2,7 @@ /* Copyright (C) 2003-2007 Rodolphe Quiedeville * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin + * 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 @@ -121,9 +122,9 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders /** * Return next value * - * @param Societe $objsoc Object third party - * @param Object $object Object - * @return string|0 Value if OK, 0 if KO + * @param Societe $objsoc Object third party + * @param CommandeFournisseur $object Object + * @return string|0 Value if OK, 0 if KO */ public function getNextValue($objsoc = 0, $object = '') { @@ -143,19 +144,4 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders return $numFinal; } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Renvoie la reference de commande suivante non utilisee - * - * @param Societe $objsoc Object third party - * @param Object $object Object - * @return string Descriptive text - */ - public function commande_get_num($objsoc = 0, $object = '') - { - // phpcs:enable - return $this->getNextValue($objsoc, $object); - } } From 50e8c19b7e630a7e8492ea065d31cfa1b948ee62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Mon, 11 Mar 2024 18:50:18 +0100 Subject: [PATCH 33/60] clean code and phpdoc --- .../mod_supplier_payment_brodator.php | 22 +++------------- .../mod_supplier_payment_bronan.php | 26 +++++-------------- .../mod_supplier_proposal_marbre.php | 11 ++++---- .../takepos/mod_takepos_ref_simple.php | 5 ++-- .../takepos/mod_takepos_ref_universal.php | 3 ++- .../core/modules/ticket/mod_ticket_simple.php | 3 ++- .../workstation/mod_workstation_advanced.php | 4 +-- .../workstation/mod_workstation_standard.php | 5 ++-- 8 files changed, 28 insertions(+), 51 deletions(-) diff --git a/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php b/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php index b2a26199a32..6790389a328 100644 --- a/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php +++ b/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php @@ -1,5 +1,6 @@ + * 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 @@ -118,9 +119,9 @@ class mod_supplier_payment_brodator extends ModeleNumRefSupplierPayments /** * Return next free value * - * @param Societe $objsoc Object thirdparty - * @param Object $object Object we need next value for - * @return string|0 Next value if OK, 0 if KO + * @param Societe $objsoc Object thirdparty + * @param PaiementFourn $object Object we need next value for + * @return string|0 Next value if OK, 0 if KO */ public function getNextValue($objsoc, $object) { @@ -140,19 +141,4 @@ class mod_supplier_payment_brodator extends ModeleNumRefSupplierPayments return $numFinal; } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return next free value - * - * @param Societe $objsoc Object third party - * @param string $objforref Object for number to search - * @return string Next free value - */ - public function commande_get_num($objsoc, $objforref) - { - // phpcs:enable - return $this->getNextValue($objsoc, $objforref); - } } diff --git a/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php b/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php index 38d41158f04..710369855b8 100644 --- a/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php +++ b/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php @@ -1,5 +1,6 @@ + * 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 @@ -83,8 +84,8 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param Object $object Object we need next value for - * @return boolean false if KO (there is a conflict), true if OK + * @param PaiementFourn $object Object we need next value for + * @return boolean false if KO (there is a conflict), true if OK */ public function canBeActivated($object) { @@ -119,9 +120,9 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments /** * Return next free value * - * @param Societe $objsoc Object thirdparty - * @param Object $object Object we need next value for - * @return string|-1 Value if OK, -1 if KO + * @param Societe $objsoc Object thirdparty + * @param PaiementFourn $object Object we need next value for + * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($objsoc, $object) { @@ -160,19 +161,4 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return next free value - * - * @param Societe $objsoc Object third party - * @param string $objforref Object for number to search - * @return string Next free value - */ - public function payment_get_num($objsoc, $objforref) - { - // phpcs:enable - return $this->getNextValue($objsoc, $objforref); - } } diff --git a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php index 97a3507ff3b..d1a638345d3 100644 --- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php +++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php @@ -1,6 +1,7 @@ * Copyright (C) 2005-2012 Regis Houssin + * 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 @@ -85,8 +86,8 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param Object $object Object we need next value for - * @return boolean false if KO (there is a conflict), true if OK + * @param SupplierProposal $object Object we need next value for + * @return boolean false if KO (there is a conflict), true if OK */ public function canBeActivated($object) { @@ -166,9 +167,9 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal /** * Return next free value * - * @param Societe $objsoc Object third party - * @param Object $objforref Object for number to search - * @return string Next free value + * @param Societe $objsoc Object third party + * @param SupplierProposal $objforref Object for number to search + * @return string Next free value */ public function getNumRef($objsoc, $objforref) { diff --git a/htdocs/core/modules/takepos/mod_takepos_ref_simple.php b/htdocs/core/modules/takepos/mod_takepos_ref_simple.php index af9b41f3f97..616c43513dd 100644 --- a/htdocs/core/modules/takepos/mod_takepos_ref_simple.php +++ b/htdocs/core/modules/takepos/mod_takepos_ref_simple.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2020 Open-DSI + * 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 @@ -85,7 +86,7 @@ class mod_takepos_ref_simple extends ModeleNumRefTakepos * Test if the numbers already in the database do not cause any conflicts that will prevent this * of conflicts that will prevent this numbering from working. * - * @param Object $object Object we need next value for + * @param Facture $object Object we need next value for * @return boolean false if KO (there is a conflict), true if OK */ public function canBeActivated($object) @@ -208,7 +209,7 @@ class mod_takepos_ref_simple extends ModeleNumRefTakepos * Return next free value * * @param Societe $objsoc Object third party - * @param Object $objforref Object for number to search + * @param Facture $objforref Object for number to search * @return string Next free value */ public function getNumRef($objsoc, $objforref) diff --git a/htdocs/core/modules/takepos/mod_takepos_ref_universal.php b/htdocs/core/modules/takepos/mod_takepos_ref_universal.php index 35a02f4823c..1c06bfdd16a 100644 --- a/htdocs/core/modules/takepos/mod_takepos_ref_universal.php +++ b/htdocs/core/modules/takepos/mod_takepos_ref_universal.php @@ -5,6 +5,7 @@ * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2020 Open-DSI + * 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 @@ -151,7 +152,7 @@ class mod_takepos_ref_universal extends ModeleNumRefTakepos * Return next free value * * @param Societe $objsoc Object third party - * @param Object $objforref Object for number to search + * @param Facture $objforref Object for number to search * @return string Next free value */ public function getNumRef($objsoc, $objforref) diff --git a/htdocs/core/modules/ticket/mod_ticket_simple.php b/htdocs/core/modules/ticket/mod_ticket_simple.php index 943f26c2c50..eca05a8e700 100644 --- a/htdocs/core/modules/ticket/mod_ticket_simple.php +++ b/htdocs/core/modules/ticket/mod_ticket_simple.php @@ -1,6 +1,7 @@ * Copyright (C) 2010 Laurent Destailleur + * 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 @@ -81,7 +82,7 @@ class mod_ticket_simple extends ModeleNumRefTicket * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param Object $object Object we need next value for + * @param Ticket $object Object we need next value for * @return boolean false if conflict, true if ok */ public function canBeActivated($object) diff --git a/htdocs/core/modules/workstation/mod_workstation_advanced.php b/htdocs/core/modules/workstation/mod_workstation_advanced.php index 3081519dad1..032083ba641 100644 --- a/htdocs/core/modules/workstation/mod_workstation_advanced.php +++ b/htdocs/core/modules/workstation/mod_workstation_advanced.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-2024 Frédéric France * Copyright (C) 2020 Gauthier VERDOL * * This program is free software; you can redistribute it and/or modify @@ -124,7 +124,7 @@ class mod_workstation_advanced extends ModeleNumRefWorkstation /** * Return next free value * - * @param Object $object Object we need next value for + * @param Workstation $object Object we need next value for * @return string|0 Next value if OK, 0 if KO */ public function getNextValue($object) diff --git a/htdocs/core/modules/workstation/mod_workstation_standard.php b/htdocs/core/modules/workstation/mod_workstation_standard.php index bb8938e6440..5d2b3cbde0e 100644 --- a/htdocs/core/modules/workstation/mod_workstation_standard.php +++ b/htdocs/core/modules/workstation/mod_workstation_standard.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2020 Gauthier VERDOL + * 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 @@ -77,7 +78,7 @@ class mod_workstation_standard extends ModeleNumRefWorkstation * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param Object $object Object we need next value for + * @param Workstation $object Object we need next value for * @return boolean false if conflict, true if ok */ public function canBeActivated($object) @@ -115,7 +116,7 @@ class mod_workstation_standard extends ModeleNumRefWorkstation /** * Return next free value * - * @param Object $object Object we need next value for + * @param Workstation $object Object we need next value for * @return string|-1 Next value if OK, -1 if KO */ public function getNextValue($object) From 56a4dd46db7d489759af538cd1b301fd51bdc747 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Mar 2024 20:41:56 +0100 Subject: [PATCH 34/60] Add a log --- htdocs/ai/ajax/generate_content.php | 2 +- htdocs/ai/class/ai.class.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/ai/ajax/generate_content.php b/htdocs/ai/ajax/generate_content.php index 9b1adf13b84..f60cef9ee09 100644 --- a/htdocs/ai/ajax/generate_content.php +++ b/htdocs/ai/ajax/generate_content.php @@ -67,7 +67,7 @@ $function = 'textgeneration'; $generatedContent = $ai->generateContent($instructions, 'auto', $function); if (is_array($generatedContent) && $generatedContent['error']) { - print "Error : " . $generatedContent['message']; + print "Error returned by API call: " . $generatedContent['message']; } else { print $generatedContent; } diff --git a/htdocs/ai/class/ai.class.php b/htdocs/ai/class/ai.class.php index 399b3adb1ee..fd1c7ca17c5 100644 --- a/htdocs/ai/class/ai.class.php +++ b/htdocs/ai/class/ai.class.php @@ -64,6 +64,10 @@ class Ai */ public function generateContent($instructions, $model = 'auto', $function = 'textgeneration') { + if (empty($this->apiKey)) { + return array('error' => true, 'message' => 'API key is no defined'); + } + if (empty($this->apiEndpoint)) { if ($function == 'textgeneration') { $this->apiEndpoint = 'https://api.openai.com/v1/chat/completions'; @@ -97,6 +101,8 @@ class Ai } } + dol_syslog("Call API for apiEndpoint=".$this->apiEndpoint." apiKey=".substr($this->apiKey, 0, 3).'***********, model='.$model); + try { $configurationsJson = getDolGlobalString('AI_CONFIGURATIONS_PROMPT'); $configurations = json_decode($configurationsJson, true); From 325cb587f62d50e255b51336ba8c196de9786b87 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 11 Mar 2024 20:46:21 +0100 Subject: [PATCH 35/60] Qual: Exclude some tests from windows-ci until fixed # Qual: Exclude some tests from windows-ci until fixed Until #28598 and #28264 find some way to the develop branch, this update will skip the tests that currently fail on windows so that the results of other tests have an effect on the CI status and github annotations --- .github/workflows/windows-ci.yaml | 4 ++-- test/phpunit/FilesLibTest.php | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows-ci.yaml b/.github/workflows/windows-ci.yaml index c0e44dbb74f..f8441c438fc 100644 --- a/.github/workflows/windows-ci.yaml +++ b/.github/workflows/windows-ci.yaml @@ -114,7 +114,7 @@ jobs: curl "http://${{ env.PHPSERVER_DOMAIN_PORT }}" shell: powershell - name: Run PHPUnit tests - continue-on-error: true + # continue-on-error: true shell: cmd # setting up php.ini, starting the php server are currently in this step run: |- @@ -143,7 +143,7 @@ jobs: cat htdocs/conf/conf.php curl "http://${{ env.PHPSERVER_DOMAIN_PORT }}" REM 'DOSKEY' USED to recover error code (no pipefile equivalent in windows?) - ( php "%PHPROOT%\phpunit" -d memory_limit=-1 -c %CD%\test\phpunit\phpunittest.xml "test\phpunit\AllTests.php" & call doskey /exename=err err=%%^^errorlevel%% ) | "${{ env.TEE }}" "${{ env.PHPUNIT_LOG }}" + ( php "%PHPROOT%\phpunit" -d memory_limit=-1 -c %CD%\test\phpunit\phpunittest.xml "test\phpunit\AllTests.php" --exclude-group WindowsWaitingForFix & call doskey /exename=err err=%%^^errorlevel%% ) | "${{ env.TEE }}" "${{ env.PHPUNIT_LOG }}" for /f "tokens=2 delims==" %%A in ('doskey /m:err') do EXIT /B %%A - name: Convert Raw Log to Annotations uses: mdeweerd/logToCheckStyle@v2024.2.9 diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index 91cdcc816bd..32616542c2a 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -247,6 +247,7 @@ class FilesLibTest extends CommonClassTest * testDolCopyMoveDelete * * @return void + * @group WindowsWaitingForFix */ public function testDolCopyMoveDelete() { @@ -490,6 +491,7 @@ class FilesLibTest extends CommonClassTest * testDolDirMove * * @return void + * @group WindowsWaitingForFix */ public function testDolDirMove() { From 23ae21958b828c0bfb2564cb33c1a90738002045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Mon, 11 Mar 2024 20:57:48 +0100 Subject: [PATCH 36/60] clean code and phpdoc --- htdocs/core/modules/delivery/mod_delivery_saphir.php | 1 + htdocs/core/modules/facture/mod_facture_mars.php | 1 + htdocs/core/modules/facture/mod_facture_mercure.php | 1 + htdocs/core/modules/facture/mod_facture_terre.php | 1 + htdocs/core/modules/fichinter/mod_arctic.php | 1 + htdocs/core/modules/fichinter/mod_pacific.php | 1 + htdocs/core/modules/propale/mod_propale_marbre.php | 1 + .../modules/supplier_invoice/mod_facture_fournisseur_cactus.php | 1 + .../modules/supplier_invoice/mod_facture_fournisseur_tulip.php | 1 + .../modules/supplier_proposal/mod_supplier_proposal_marbre.php | 1 + htdocs/core/modules/takepos/mod_takepos_ref_simple.php | 1 + htdocs/core/modules/takepos/mod_takepos_ref_universal.php | 1 + htdocs/fourn/class/fournisseur.facture.class.php | 2 +- 13 files changed, 13 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/delivery/mod_delivery_saphir.php b/htdocs/core/modules/delivery/mod_delivery_saphir.php index 4d6bdb7c716..b6669961cd0 100644 --- a/htdocs/core/modules/delivery/mod_delivery_saphir.php +++ b/htdocs/core/modules/delivery/mod_delivery_saphir.php @@ -151,6 +151,7 @@ class mod_delivery_saphir extends ModeleNumRefDeliveryOrder * @param Societe $objsoc Object third party * @param Delivery $objforref Object for number to search * @return string|0 Next free value, 0 if KO + * @deprecated see getNextValue */ public function getNumRef($objsoc, $objforref) { diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index 71f9fb27eec..94c45e0ce37 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -247,6 +247,7 @@ class mod_facture_mars extends ModeleNumRefFactures * @param Facture $objforref Object for number to search * @param string $mode 'next' for next value or 'last' for last value * @return string Next free value + * @deprecated see getNextValue */ public function getNumRef($objsoc, $objforref, $mode = 'next') { diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php index 8d1194b7d4a..1043808be3a 100644 --- a/htdocs/core/modules/facture/mod_facture_mercure.php +++ b/htdocs/core/modules/facture/mod_facture_mercure.php @@ -182,6 +182,7 @@ class mod_facture_mercure extends ModeleNumRefFactures * @param Facture $objforref Object for number to search * @param string $mode 'next' for next value or 'last' for last value * @return string|0 Next free value, 0 if KO + * @deprecated see getNextValue */ public function getNumRef($objsoc, $objforref, $mode = 'next') { diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php index bf116118024..07c6173a17b 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -287,6 +287,7 @@ class mod_facture_terre extends ModeleNumRefFactures * @param Facture $objforref Object for number to search * @param string $mode 'next' for next value or 'last' for last value * @return string|int<-1,0> Next free value, -1 or 0 if error + * @deprecated see getNextValue */ public function getNumRef($objsoc, $objforref, $mode = 'next') { diff --git a/htdocs/core/modules/fichinter/mod_arctic.php b/htdocs/core/modules/fichinter/mod_arctic.php index 54362d39bd4..e8f79c9c084 100644 --- a/htdocs/core/modules/fichinter/mod_arctic.php +++ b/htdocs/core/modules/fichinter/mod_arctic.php @@ -151,6 +151,7 @@ class mod_arctic extends ModeleNumRefFicheinter * @param Societe $objsoc Object third party * @param Fichinter $objforref Object for number to search * @return string|0 Next free value, 0 if KO + * @deprecated see getNextValue */ public function getNumRef($objsoc, $objforref) { diff --git a/htdocs/core/modules/fichinter/mod_pacific.php b/htdocs/core/modules/fichinter/mod_pacific.php index a1f90012125..2e7dfe34792 100644 --- a/htdocs/core/modules/fichinter/mod_pacific.php +++ b/htdocs/core/modules/fichinter/mod_pacific.php @@ -165,6 +165,7 @@ class mod_pacific extends ModeleNumRefFicheinter * @param Societe $objsoc Object third party * @param Fichinter $objforref Object for number to search * @return string Next free value + * @deprecated see getNextValue */ public function getNumRef($objsoc, $objforref) { diff --git a/htdocs/core/modules/propale/mod_propale_marbre.php b/htdocs/core/modules/propale/mod_propale_marbre.php index e38d8076604..c649f1139cb 100644 --- a/htdocs/core/modules/propale/mod_propale_marbre.php +++ b/htdocs/core/modules/propale/mod_propale_marbre.php @@ -170,6 +170,7 @@ class mod_propale_marbre extends ModeleNumRefPropales * @param Societe $objsoc Object third party * @param Propal $objforref Object for number to search * @return string|-1 Next free value, -1 if KO + * @deprecated see getNextValue */ public function getNumRef($objsoc, $objforref) { diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php index 95612da93f0..a3a4c321bf3 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php @@ -261,6 +261,7 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices * @param FactureFournisseur $objforref Object for number to search * @param string $mode 'next' for next value or 'last' for last value * @return string Next free value + * @deprecated see getNextValue */ public function getNumRef($objsoc, $objforref, $mode = 'next') { diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php index 39643722cf5..7fb38484e21 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php @@ -190,6 +190,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices * @param FactureFournisseur $objforref Object for number to search * @param string $mode 'next' for next value or 'last' for last value * @return string Next free value + * @deprecated see getNextValue */ public function getNumRef($objsoc, $objforref, $mode = 'next') { diff --git a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php index d1a638345d3..71949409f92 100644 --- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php +++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php @@ -170,6 +170,7 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal * @param Societe $objsoc Object third party * @param SupplierProposal $objforref Object for number to search * @return string Next free value + * @deprecated see getNextValue */ public function getNumRef($objsoc, $objforref) { diff --git a/htdocs/core/modules/takepos/mod_takepos_ref_simple.php b/htdocs/core/modules/takepos/mod_takepos_ref_simple.php index 616c43513dd..a4757350a57 100644 --- a/htdocs/core/modules/takepos/mod_takepos_ref_simple.php +++ b/htdocs/core/modules/takepos/mod_takepos_ref_simple.php @@ -211,6 +211,7 @@ class mod_takepos_ref_simple extends ModeleNumRefTakepos * @param Societe $objsoc Object third party * @param Facture $objforref Object for number to search * @return string Next free value + * @deprecated see getNextValue */ public function getNumRef($objsoc, $objforref) { diff --git a/htdocs/core/modules/takepos/mod_takepos_ref_universal.php b/htdocs/core/modules/takepos/mod_takepos_ref_universal.php index 1c06bfdd16a..8eb7c341643 100644 --- a/htdocs/core/modules/takepos/mod_takepos_ref_universal.php +++ b/htdocs/core/modules/takepos/mod_takepos_ref_universal.php @@ -154,6 +154,7 @@ class mod_takepos_ref_universal extends ModeleNumRefTakepos * @param Societe $objsoc Object third party * @param Facture $objforref Object for number to search * @return string Next free value + * @deprecated see getNextValue */ public function getNumRef($objsoc, $objforref) { diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index dc1f44735d7..5130c4ad2bd 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2972,7 +2972,7 @@ class FactureFournisseur extends CommonInvoice $obj = new $classname(); $numref = ""; - $numref = $obj->getNumRef($soc, $this, $mode); + $numref = $obj->getNextValue($soc, $this, $mode); if ($numref != "") { return $numref; From aaf173a0d22266c8b7f0eebe10e0721c3a0b3357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Mon, 11 Mar 2024 21:01:20 +0100 Subject: [PATCH 37/60] clean code and phpdoc --- htdocs/core/class/commonnumrefgenerator.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonnumrefgenerator.class.php b/htdocs/core/class/commonnumrefgenerator.class.php index c4edb202031..60104d09cd7 100644 --- a/htdocs/core/class/commonnumrefgenerator.class.php +++ b/htdocs/core/class/commonnumrefgenerator.class.php @@ -132,7 +132,7 @@ abstract class CommonNumRefGenerator * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param Object $object Object we need next value for + * @param CommonObject $object Object we need next value for * @return boolean false if conflict, true if ok */ public function canBeActivated($object) From a300206c28e264f0d572bbe4a9d624ebc1422550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Mon, 11 Mar 2024 21:59:48 +0100 Subject: [PATCH 38/60] clean code and phpdoc --- htdocs/core/modules/facture/mod_facture_mercure.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php index 1043808be3a..123ced406da 100644 --- a/htdocs/core/modules/facture/mod_facture_mercure.php +++ b/htdocs/core/modules/facture/mod_facture_mercure.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2007 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2013 uanjo Menent + * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2022 Anthony Berton * Copyright (C) 2024 Frédéric France * From 7a7d342aaadb7fd7421c31416bcbfccb42d87da5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Mon, 11 Mar 2024 22:14:39 +0100 Subject: [PATCH 39/60] clean code and phpdoc --- dev/tools/phan/config.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/tools/phan/config.php b/dev/tools/phan/config.php index 0bb240128f8..ae33dadbb32 100644 --- a/dev/tools/phan/config.php +++ b/dev/tools/phan/config.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France */ define('DOL_PROJECT_ROOT', __DIR__.'/../../..'); define('DOL_DOCUMENT_ROOT', DOL_PROJECT_ROOT.'/htdocs'); @@ -535,7 +536,7 @@ return [ // 'PhanTypeInvalidThrowsIsInterface', // 'PhanPluginRedundantAssignmentInLoop', // 'PhanInvalidCommentForDeclarationType', - //'PhanParamSignatureMismatchInternal', + 'PhanParamSignatureMismatchInternal', // 'PhanPluginEmptyStatementForeachLoop', // 'PhanCompatibleDimAlternativeSyntax', 'PhanInvalidFQSENInClasslike', @@ -656,5 +657,4 @@ return [ 'sockets' => PHAN_DIR . '/stubs/sockets.phan_php', 'zip' => PHAN_DIR . '/stubs/zip.phan_php', ], - ]; From e60db40fa4421f59a2da72214c71f38a2604ca51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Mon, 11 Mar 2024 22:20:29 +0100 Subject: [PATCH 40/60] clean code and phpdoc --- dev/tools/phan/config.php | 3 ++- dev/tools/phan/config_fixer.php | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/dev/tools/phan/config.php b/dev/tools/phan/config.php index ae33dadbb32..36aca92b25e 100644 --- a/dev/tools/phan/config.php +++ b/dev/tools/phan/config.php @@ -536,7 +536,8 @@ return [ // 'PhanTypeInvalidThrowsIsInterface', // 'PhanPluginRedundantAssignmentInLoop', // 'PhanInvalidCommentForDeclarationType', - 'PhanParamSignatureMismatchInternal', + // 'PhanParamSignatureMismatchInternal', + 'PhanParamSignatureMismatch', // 'PhanPluginEmptyStatementForeachLoop', // 'PhanCompatibleDimAlternativeSyntax', 'PhanInvalidFQSENInClasslike', diff --git a/dev/tools/phan/config_fixer.php b/dev/tools/phan/config_fixer.php index a588483e3bf..8033331240b 100644 --- a/dev/tools/phan/config_fixer.php +++ b/dev/tools/phan/config_fixer.php @@ -1,4 +1,7 @@ + * Copyright (C) 2024 Frédéric France + */ // Uncomment require_once to enable corresponding fixer @@ -7,8 +10,6 @@ //require_once __DIR__.'/plugins/UrlEncodeStringifyFixer.php'; require_once __DIR__.'/plugins/SelectDateFixer.php'; -/* Copyright (C) 2024 MDW - */ define('DOL_PROJECT_ROOT', __DIR__.'/../../..'); define('DOL_DOCUMENT_ROOT', DOL_PROJECT_ROOT.'/htdocs'); define('PHAN_DIR', __DIR__); From 7fabf59b46cfc90d9a6b773cafa1ec69b47a7fe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Mon, 11 Mar 2024 23:13:30 +0100 Subject: [PATCH 41/60] clean code and phpdoc --- htdocs/comm/remx.php | 5 +++-- htdocs/core/lib/usergroups.lib.php | 32 ++++++++++++++---------------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 994e30fb9f1..f1584aa8b30 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2004 Rodolphe Quiedeville * Copyright (C) 2004-2019 Laurent Destailleur * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-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 @@ -45,6 +45,7 @@ $backtopage = GETPOST('backtopage', 'alpha'); // Security check $socid = GETPOSTINT('id') ? GETPOSTINT('id') : GETPOSTINT('socid'); +/** @var User $user */ if ($user->socid > 0) { $socid = $user->socid; } @@ -55,7 +56,7 @@ if ($user->socid > 0) { } $result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0); -$permissiontocreate = ($user->rights->societe->creer || $user->rights->facture->creer); +$permissiontocreate = ($user->hasRight('societe', 'creer') || $user->hasRight('facture', 'creer')); diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 30db640ed07..87e6e367cb3 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -4,6 +4,7 @@ * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2021-2023 Anthony Berton + * 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 @@ -237,7 +238,7 @@ function group_prepare_head($object) $canreadperms = true; if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) { - $canreadperms = ($user->admin || $user->rights->user->group_advance->readperms); + $canreadperms = ($user->admin || $user->hasRight('user', 'group_advance', 'readperms')); } $h = 0; @@ -504,17 +505,17 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) //Nothing } else { $listofdarkmodes = array( - '0' => $langs->trans("AlwaysDisabled"), - '1' => $langs->trans("AccordingToBrowser"), - '2' => $langs->trans("AlwaysEnabled") + $langs->trans("AlwaysDisabled"), + $langs->trans("AccordingToBrowser"), + $langs->trans("AlwaysEnabled") ); print ''; print ''.$langs->trans("DarkThemeMode").''; print ''; if ($edit) { - print $form->selectarray('THEME_DARKMODEENABLED', $listofdarkmodes, isset($conf->global->THEME_DARKMODEENABLED) ? $conf->global->THEME_DARKMODEENABLED : 0); + print $form->selectarray('THEME_DARKMODEENABLED', $listofdarkmodes, getDolGlobalInt('THEME_DARKMODEENABLED')); } else { - print $listofdarkmodes[isset($conf->global->THEME_DARKMODEENABLED) ? $conf->global->THEME_DARKMODEENABLED : 0]; + print $listofdarkmodes[getDolGlobalInt('THEME_DARKMODEENABLED')]; } print $form->textwithpicto('', $langs->trans("DoesNotWorkWithAllThemes")); print ''; @@ -545,11 +546,11 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print '';*/ } else { $listoftopmenumodes = array( - '0' => $langs->transnoentitiesnoconv("IconAndText"), - '1' => $langs->transnoentitiesnoconv("TextOnly"), - '2' => $langs->transnoentitiesnoconv("IconOnlyAllTextsOnHover"), - '3' => $langs->transnoentitiesnoconv("IconOnlyTextOnHover"), - '4' => $langs->transnoentitiesnoconv("IconOnly"), + $langs->transnoentitiesnoconv("IconAndText"), + $langs->transnoentitiesnoconv("TextOnly"), + $langs->transnoentitiesnoconv("IconOnlyAllTextsOnHover"), + $langs->transnoentitiesnoconv("IconOnlyTextOnHover"), + $langs->transnoentitiesnoconv("IconOnly"), ); print ''; print ''.$langs->trans("TopMenuDisableImages").''; @@ -637,13 +638,10 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo print '> '.$langs->trans("UsePersonalValue").''; print ''; - if ($edit) - { + if ($edit) { print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1,array()),''),'THEME_ELDY_TOPMENU_BACK1','',1).' '; - } - else - { - $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1,array()),''); + } else { + $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1,array()),''); if ($color) print ''; else print ''; } From 7ad8f6b074180984bbb7685095fc70f7f59a7deb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Mon, 11 Mar 2024 23:18:01 +0100 Subject: [PATCH 42/60] clean code and phpdoc --- htdocs/core/lib/functions2.lib.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 1335da5649a..f5e95da450c 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -7,6 +7,7 @@ * Copyright (C) 2015-2016 Raphaël Doursenaud * Copyright (C) 2017 Juanjo Menent * 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 @@ -892,7 +893,7 @@ function array2table($data, $tableMarkup = 1, $tableoptions = '', $troptions = ' * @param string $table Table containing field with counter * @param string $field Field containing already used values of counter * @param string $where To add a filter on selection (for example to filter on invoice types) - * @param Societe $objsoc The company that own the object we need a counter for + * @param Societe|string $objsoc The company that own the object we need a counter for * @param string $date Date to use for the {y},{m},{d} tags. * @param string $mode 'next' for next value or 'last' for last value * @param bool $bentityon Activate the entity filter. Default is true (for modules not compatible with multicompany) @@ -2511,16 +2512,16 @@ function colorLighten($hex, $percent) /** - * @param string $hex color in hex - * @param float $alpha 0 to 1 to add alpha channel - * @param bool $returnArray true=return an array instead, false=return string - * @return string|array String or array + * @param string $hex color in hex + * @param float|false $alpha 0 to 1 to add alpha channel + * @param bool $returnArray true=return an array instead, false=return string + * @return string|array String or array */ function colorHexToRgb($hex, $alpha = false, $returnArray = false) { $string = ''; - $hex = str_replace('#', '', $hex); - $length = strlen($hex); + $hex = str_replace('#', '', $hex); + $length = strlen($hex); $rgb = array(); $rgb['r'] = hexdec($length == 6 ? substr($hex, 0, 2) : ($length == 3 ? str_repeat(substr($hex, 0, 1), 2) : 0)); $rgb['g'] = hexdec($length == 6 ? substr($hex, 2, 2) : ($length == 3 ? str_repeat(substr($hex, 1, 1), 2) : 0)); From c8c003a437e7bbd3311eaab5b8842002ec66571d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Mon, 11 Mar 2024 23:46:48 +0100 Subject: [PATCH 43/60] restore rule --- dev/tools/phan/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tools/phan/config.php b/dev/tools/phan/config.php index 36aca92b25e..53982aaee7f 100644 --- a/dev/tools/phan/config.php +++ b/dev/tools/phan/config.php @@ -537,7 +537,7 @@ return [ // 'PhanPluginRedundantAssignmentInLoop', // 'PhanInvalidCommentForDeclarationType', // 'PhanParamSignatureMismatchInternal', - 'PhanParamSignatureMismatch', + // 'PhanParamSignatureMismatch', // 'PhanPluginEmptyStatementForeachLoop', // 'PhanCompatibleDimAlternativeSyntax', 'PhanInvalidFQSENInClasslike', From 8b79cfa0956be7a7de55b42e7983ab5ba47dc2f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Tue, 12 Mar 2024 00:16:06 +0100 Subject: [PATCH 44/60] clean --- htdocs/core/modules/barcode/modules_barcode.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/barcode/modules_barcode.class.php b/htdocs/core/modules/barcode/modules_barcode.class.php index f8026af15e1..ed2326edafb 100644 --- a/htdocs/core/modules/barcode/modules_barcode.class.php +++ b/htdocs/core/modules/barcode/modules_barcode.class.php @@ -62,11 +62,11 @@ abstract class ModeleNumRefBarCode extends CommonNumRefGenerator /** * Return next value available * - * @param Product $objproduct Object Product - * @param string $type Type of barcode (EAN, ISBN, ...) - * @return string Value + * @param CommonObject $objcommon CommonObject + * @param string $type Type of barcode (EAN, ISBN, ...) + * @return string Value */ - public function getNextValue($objproduct, $type = '') + public function getNextValue($objcommon, $type = '') { global $langs; return $langs->trans("Function_getNextValue_InModuleNotWorking"); From 4f64c683ee2525dff91d1099fa2e44f14cfa6eb1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Mar 2024 01:55:26 +0100 Subject: [PATCH 45/60] Better support for MAIN_OPTIMIZEFORTEXTBROWSER --- htdocs/core/class/conf.class.php | 11 ++++-- htdocs/core/lib/security2.lib.php | 2 +- htdocs/core/menus/standard/auguria.lib.php | 2 +- htdocs/core/menus/standard/eldy.lib.php | 2 +- htdocs/core/menus/standard/empty.php | 2 +- htdocs/core/search_page.php | 39 ++++++++++++---------- htdocs/core/tpl/login.tpl.php | 4 +-- htdocs/index.php | 8 ++--- htdocs/main.inc.php | 9 +++-- 9 files changed, 47 insertions(+), 32 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 647354ef247..9f73b069950 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -1,4 +1,6 @@ * Copyright (C) 2003 Xavier Dutoit * Copyright (C) 2004-2020 Laurent Destailleur @@ -41,9 +43,14 @@ class Conf extends stdClass */ public $db; - //! To store properties found into database + /** + * @var Object To store global setup found into database + */ public $global; - //! To store browser info (->name, ->os, ->version, ->ua, ->layout, ...) + + /** + * @var Object To store browser info (->name, ->os, ->version, ->ua, ->layout, ...) + */ public $browser; //! To store some setup of generic modules diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index d08912c169e..33157cde1ce 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -149,7 +149,7 @@ if (!function_exists('dol_loginfunction')) { // Title $appli = constant('DOL_APPLICATION_TITLE'); - $title = $appli.' '.constant('DOL_VERSION'); + $title = $appli.(getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? '' : ' '.constant('DOL_VERSION')); if (getDolGlobalString('MAIN_APPLICATION_TITLE')) { $title = getDolGlobalString('MAIN_APPLICATION_TITLE'); } diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index d727967222e..8509416d4fc 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -178,7 +178,7 @@ function print_auguria_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout } $showmode = 1; - if (empty($noout)) { + if (empty($noout) && !getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) { print_start_menu_entry_auguria('', 'class="tmenuend"', $showmode); print_end_menu_entry_auguria($showmode); print_end_menu_array_auguria(); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index b5de6584a85..8ef3b8c9b90 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -590,7 +590,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = } $showmode = 1; - if (empty($noout)) { + if (empty($noout) && !getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) { print_start_menu_entry('', 'class="tmenuend"', $showmode); print_end_menu_entry($showmode); print_end_menu_array(); diff --git a/htdocs/core/menus/standard/empty.php b/htdocs/core/menus/standard/empty.php index 16809c89405..0b925551848 100644 --- a/htdocs/core/menus/standard/empty.php +++ b/htdocs/core/menus/standard/empty.php @@ -139,7 +139,7 @@ class MenuManager } $showmode = 1; - if (empty($noout)) { + if (empty($noout) && !getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) { print_start_menu_entry_empty('', 'class="tmenuend"', $showmode); } if (empty($noout)) { diff --git a/htdocs/core/search_page.php b/htdocs/core/search_page.php index adaa198087d..0f91b78b9ed 100644 --- a/htdocs/core/search_page.php +++ b/htdocs/core/search_page.php @@ -165,25 +165,28 @@ if (empty($reshook)) { $searchform .= '
'; -// Add search on URL -$ret = ''; -$ret .= '
'; -$ret .= ''; -$ret .= ''; -$ret .= ''; -$ret .= '
'; -$ret .= img_picto('', 'url', '', false, 0, 0, '', 'paddingright width20'); -$ret .= 'trans("OrPasteAnURL")).'"'; -$ret .= ' name="url" id="url" />'; -$ret .= ''; -$ret .= '
'; -$ret .= "
\n"; -$searchform .= $ret; +// Add search on URL +if ($conf->dol_use_jmobile) { + $ret = ''; + $ret .= '
'; + $ret .= ''; + $ret .= ''; + $ret .= ''; + $ret .= '
'; + $ret .= img_picto('', 'url', '', false, 0, 0, '', 'paddingright width20'); + $ret .= 'trans("OrPasteAnURL")).'"'; + $ret .= ' name="url" id="url" />'; + $ret .= ''; + $ret .= '
'; + $ret .= "
\n"; + + $searchform .= $ret; +} // Show all forms diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 4d5dc2833dc..b2072e48eed 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -402,9 +402,9 @@ if (!empty($_SESSION['dol_loginmesg'])) { $message = $_SESSION['dol_loginmesg']; // By default this is an error message if (preg_match('//', $message)) { // if it contains this comment, this is a warning message $message = str_replace('', '', $message); - print '
'; + print '