diff --git a/build/phpstan/phpstan-baseline.neon b/build/phpstan/phpstan-baseline.neon index d8806427808..192a9985d69 100644 --- a/build/phpstan/phpstan-baseline.neon +++ b/build/phpstan/phpstan-baseline.neon @@ -228,12 +228,6 @@ parameters: count: 4 path: ../../htdocs/accountancy/bookkeeping/export.php - - - message: '#^Negated boolean expression is always true\.$#' - identifier: booleanNot.alwaysTrue - count: 1 - path: ../../htdocs/accountancy/bookkeeping/list.php - - message: '#^Variable \$contextpage in empty\(\) always exists and is not falsy\.$#' identifier: empty.variable @@ -252,12 +246,6 @@ parameters: count: 3 path: ../../htdocs/accountancy/bookkeeping/list.php - - - message: '#^Negated boolean expression is always true\.$#' - identifier: booleanNot.alwaysTrue - count: 1 - path: ../../htdocs/accountancy/bookkeeping/listbyaccount.php - - message: '#^Variable \$contextpage in empty\(\) always exists and is not falsy\.$#' identifier: empty.variable @@ -312,12 +300,6 @@ parameters: count: 4 path: ../../htdocs/accountancy/class/accountancycategory.class.php - - - message: '#^Property AccountancyCategory\:\:\$sdcpermonth type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: ../../htdocs/accountancy/class/accountancycategory.class.php - - message: '#^Property AccountancyCategory\:\:\$sens \(int\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -1488,18 +1470,6 @@ parameters: count: 1 path: ../../htdocs/admin/mails.php - - - message: '#^Right side of && is always true\.$#' - identifier: booleanAnd.rightAlwaysTrue - count: 3 - path: ../../htdocs/admin/mails.php - - - - message: '#^Ternary operator condition is always false\.$#' - identifier: ternary.alwaysFalse - count: 3 - path: ../../htdocs/admin/mails.php - - message: '#^Variable \$text in empty\(\) always exists and is not falsy\.$#' identifier: empty.variable @@ -4590,12 +4560,6 @@ parameters: count: 1 path: ../../htdocs/comm/propal/class/propal.class.php - - - message: '#^Property CommonObject\:\:\$model_pdf \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 2 - path: ../../htdocs/comm/propal/class/propal.class.php - - message: '#^Property CommonObject\:\:\$ref \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -4992,12 +4956,6 @@ parameters: count: 1 path: ../../htdocs/commande/class/commande.class.php - - - message: '#^Property CommonObject\:\:\$model_pdf \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 2 - path: ../../htdocs/commande/class/commande.class.php - - message: '#^Property CommonObject\:\:\$ref \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -6192,12 +6150,6 @@ parameters: count: 1 path: ../../htdocs/compta/facture/class/facture.class.php - - - message: '#^Property CommonObject\:\:\$model_pdf \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 3 - path: ../../htdocs/compta/facture/class/facture.class.php - - message: '#^Property CommonObject\:\:\$ref \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -17382,24 +17334,6 @@ parameters: count: 2 path: ../../htdocs/core/tpl/list_print_total.tpl.php - - - message: '#^Variable \$action might not be defined\.$#' - identifier: variable.undefined - count: 5 - path: ../../htdocs/core/tpl/object_currency_amount.tpl.php - - - - message: '#^Variable \$object might not be defined\.$#' - identifier: variable.undefined - count: 3 - path: ../../htdocs/core/tpl/object_currency_amount.tpl.php - - - - message: '#^Variable \$usercancreate might not be defined\.$#' - identifier: variable.undefined - count: 4 - path: ../../htdocs/core/tpl/object_currency_amount.tpl.php - - message: '#^Left side of && is always true\.$#' identifier: booleanAnd.leftAlwaysTrue @@ -19404,12 +19338,6 @@ parameters: count: 2 path: ../../htdocs/expedition/class/expedition.class.php - - - message: '#^Property Expedition\:\:\$model_pdf \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 2 - path: ../../htdocs/expedition/class/expedition.class.php - - message: '#^Property Expedition\:\:\$ref_customer \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -20778,12 +20706,6 @@ parameters: count: 1 path: ../../htdocs/fourn/class/fournisseur.commande.class.php - - - message: '#^Property CommonObject\:\:\$model_pdf \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 2 - path: ../../htdocs/fourn/class/fournisseur.commande.class.php - - message: '#^Property CommonObject\:\:\$ref_ext \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -21018,12 +20940,6 @@ parameters: count: 1 path: ../../htdocs/fourn/class/fournisseur.facture.class.php - - - message: '#^Property CommonObject\:\:\$model_pdf \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 2 - path: ../../htdocs/fourn/class/fournisseur.facture.class.php - - message: '#^Property CommonObject\:\:\$ref_ext \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -25026,18 +24942,6 @@ parameters: count: 2 path: ../../htdocs/modulebuilder/template/myobject_agenda.php - - - message: '#^If condition is always false\.$#' - identifier: if.alwaysFalse - count: 1 - path: ../../htdocs/modulebuilder/template/myobject_agenda.php - - - - message: '#^Negated boolean expression is always false\.$#' - identifier: booleanNot.alwaysFalse - count: 1 - path: ../../htdocs/modulebuilder/template/myobject_agenda.php - - message: '#^Negated boolean expression is always true\.$#' identifier: booleanNot.alwaysTrue @@ -25059,19 +24963,7 @@ parameters: - message: '#^If condition is always false\.$#' identifier: if.alwaysFalse - count: 3 - path: ../../htdocs/modulebuilder/template/myobject_card.php - - - - message: '#^If condition is always true\.$#' - identifier: if.alwaysTrue - count: 1 - path: ../../htdocs/modulebuilder/template/myobject_card.php - - - - message: '#^Negated boolean expression is always false\.$#' - identifier: booleanNot.alwaysFalse - count: 1 + count: 2 path: ../../htdocs/modulebuilder/template/myobject_card.php - @@ -25104,30 +24996,6 @@ parameters: count: 1 path: ../../htdocs/modulebuilder/template/myobject_card.php - - - message: '#^Right side of && is always true\.$#' - identifier: booleanAnd.rightAlwaysTrue - count: 5 - path: ../../htdocs/modulebuilder/template/myobject_card.php - - - - message: '#^Variable \$permissiontoadd in empty\(\) always exists and is not falsy\.$#' - identifier: empty.variable - count: 1 - path: ../../htdocs/modulebuilder/template/myobject_card.php - - - - message: '#^If condition is always false\.$#' - identifier: if.alwaysFalse - count: 1 - path: ../../htdocs/modulebuilder/template/myobject_contact.php - - - - message: '#^Negated boolean expression is always false\.$#' - identifier: booleanNot.alwaysFalse - count: 1 - path: ../../htdocs/modulebuilder/template/myobject_contact.php - - message: '#^Negated boolean expression is always true\.$#' identifier: booleanNot.alwaysTrue @@ -25146,24 +25014,6 @@ parameters: count: 1 path: ../../htdocs/modulebuilder/template/myobject_contact.php - - - message: '#^Right side of && is always true\.$#' - identifier: booleanAnd.rightAlwaysTrue - count: 2 - path: ../../htdocs/modulebuilder/template/myobject_contact.php - - - - message: '#^If condition is always false\.$#' - identifier: if.alwaysFalse - count: 1 - path: ../../htdocs/modulebuilder/template/myobject_document.php - - - - message: '#^Negated boolean expression is always false\.$#' - identifier: booleanNot.alwaysFalse - count: 1 - path: ../../htdocs/modulebuilder/template/myobject_document.php - - message: '#^Negated boolean expression is always true\.$#' identifier: booleanNot.alwaysTrue @@ -25194,18 +25044,6 @@ parameters: count: 1 path: ../../htdocs/modulebuilder/template/myobject_list.php - - - message: '#^If condition is always false\.$#' - identifier: if.alwaysFalse - count: 1 - path: ../../htdocs/modulebuilder/template/myobject_list.php - - - - message: '#^Negated boolean expression is always false\.$#' - identifier: booleanNot.alwaysFalse - count: 1 - path: ../../htdocs/modulebuilder/template/myobject_list.php - - message: '#^Negated boolean expression is always true\.$#' identifier: booleanNot.alwaysTrue @@ -25224,24 +25062,6 @@ parameters: count: 1 path: ../../htdocs/modulebuilder/template/myobject_list.php - - - message: '#^Variable \$permissiontodelete in empty\(\) always exists and is not falsy\.$#' - identifier: empty.variable - count: 1 - path: ../../htdocs/modulebuilder/template/myobject_list.php - - - - message: '#^If condition is always false\.$#' - identifier: if.alwaysFalse - count: 1 - path: ../../htdocs/modulebuilder/template/myobject_note.php - - - - message: '#^Negated boolean expression is always false\.$#' - identifier: booleanNot.alwaysFalse - count: 1 - path: ../../htdocs/modulebuilder/template/myobject_note.php - - message: '#^Negated boolean expression is always true\.$#' identifier: booleanNot.alwaysTrue @@ -27870,12 +27690,6 @@ parameters: count: 1 path: ../../htdocs/product/stock/movement_list.php - - - message: '#^Variable \$whClass might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../htdocs/product/stock/movement_list.php - - message: '#^If condition is always false\.$#' identifier: if.alwaysFalse @@ -28896,12 +28710,6 @@ parameters: count: 1 path: ../../htdocs/projet/list.php - - - message: '#^Negated boolean expression is always true\.$#' - identifier: booleanNot.alwaysTrue - count: 1 - path: ../../htdocs/projet/list.php - - message: '#^Ternary operator condition is always false\.$#' identifier: ternary.alwaysFalse @@ -30792,12 +30600,6 @@ parameters: count: 2 path: ../../htdocs/reception/class/reception.class.php - - - message: '#^Property Reception\:\:\$model_pdf \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 2 - path: ../../htdocs/reception/class/reception.class.php - - message: '#^Property Reception\:\:\$ref_supplier \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -32052,12 +31854,6 @@ parameters: count: 2 path: ../../htdocs/salaries/payments.php - - - message: '#^Negated boolean expression is always true\.$#' - identifier: booleanNot.alwaysTrue - count: 1 - path: ../../htdocs/salaries/payments.php - - message: '#^Ternary operator condition is always false\.$#' identifier: ternary.alwaysFalse @@ -32472,12 +32268,6 @@ parameters: count: 1 path: ../../htdocs/societe/class/companybankaccount.class.php - - - message: '#^Property CompanyBankAccount\:\:\$model_pdf \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 2 - path: ../../htdocs/societe/class/companybankaccount.class.php - - message: '#^Call to function method_exists\(\) with \$this\(Societe\) and ''getLibStatut'' will always evaluate to true\.$#' identifier: function.alreadyNarrowedType @@ -32694,24 +32484,6 @@ parameters: count: 1 path: ../../htdocs/societe/paymentmodes.php - - - message: '#^Parameter \#4 \$month of function dol_mktime expects int, array\\|string given\.$#' - identifier: argument.type - count: 3 - path: ../../htdocs/societe/paymentmodes.php - - - - message: '#^Parameter \#5 \$day of function dol_mktime expects int, array\\|string given\.$#' - identifier: argument.type - count: 3 - path: ../../htdocs/societe/paymentmodes.php - - - - message: '#^Parameter \#6 \$year of function dol_mktime expects int, array\\|string given\.$#' - identifier: argument.type - count: 3 - path: ../../htdocs/societe/paymentmodes.php - - message: '#^Ternary operator condition is always true\.$#' identifier: ternary.alwaysTrue @@ -32754,12 +32526,6 @@ parameters: count: 2 path: ../../htdocs/societe/price.php - - - message: '#^Variable \$extrafields might not be defined\.$#' - identifier: variable.undefined - count: 14 - path: ../../htdocs/societe/price.php - - message: '#^Variable \$prodcustprice might not be defined\.$#' identifier: variable.undefined @@ -33900,18 +33666,6 @@ parameters: count: 1 path: ../../htdocs/ticket/class/ticket.class.php - - - message: '#^Property CommonObject\:\:\$entity \(int\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 1 - path: ../../htdocs/ticket/class/ticket.class.php - - - - message: '#^Property CommonObject\:\:\$model_pdf \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 2 - path: ../../htdocs/ticket/class/ticket.class.php - - message: '#^Property CommonObject\:\:\$ref \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -34122,18 +33876,6 @@ parameters: count: 1 path: ../../htdocs/ticket/index.php - - - message: '#^Negated boolean expression is always true\.$#' - identifier: booleanNot.alwaysTrue - count: 3 - path: ../../htdocs/ticket/list.php - - - - message: '#^Variable \$contextpage in empty\(\) always exists and is not falsy\.$#' - identifier: empty.variable - count: 1 - path: ../../htdocs/ticket/list.php - - message: '#^If condition is always false\.$#' identifier: if.alwaysFalse @@ -34482,12 +34224,6 @@ parameters: count: 2 path: ../../htdocs/user/home.php - - - message: '#^Negated boolean expression is always true\.$#' - identifier: booleanNot.alwaysTrue - count: 2 - path: ../../htdocs/user/list.php - - message: '#^Offset ''u\.salary'' on array\{u\.salary\: \(float\|int\)\} in isset\(\) always exists and is not nullable\.$#' identifier: isset.offset @@ -34692,48 +34428,6 @@ parameters: count: 2 path: ../../htdocs/variants/list.php - - - message: '#^Cannot access property \$lines on mixed\.$#' - identifier: property.nonObject - count: 1 - path: ../../htdocs/variants/tpl/productattributevalueline_create.tpl.php - - - - message: '#^Variable \$action might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../htdocs/variants/tpl/productattributevalueline_create.tpl.php - - - - message: '#^Variable \$hookmanager might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../htdocs/variants/tpl/productattributevalueline_create.tpl.php - - - - message: '#^Variable \$langs might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../htdocs/variants/tpl/productattributevalueline_create.tpl.php - - - - message: '#^Variable \$this might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../htdocs/variants/tpl/productattributevalueline_create.tpl.php - - - - message: '#^Variable \$action might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../htdocs/variants/tpl/productattributevalueline_title.tpl.php - - - - message: '#^Variable \$langs might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../htdocs/variants/tpl/productattributevalueline_title.tpl.php - - message: '#^Call to function is_numeric\(\) with int will always evaluate to true\.$#' identifier: function.alreadyNarrowedType diff --git a/dev/initdemo/README.md b/dev/initdemo/README.md index de796d36066..3ec1de227f0 100644 --- a/dev/initdemo/README.md +++ b/dev/initdemo/README.md @@ -10,7 +10,7 @@ Init demo The script `initdemo.sh` will erase the current database with data from `dev/initdemo/mysqldump_dolibarr_x.y.z.sql` and copy files from `documents_demo` to the official document directory. -You many to execute `chmod 700 initdemo.sh` +You may need to execute `chmod 700 initdemo.sh` then run `./initdemo.sh` to launch the Graphical User Interface. After loading the demo files, the admin login may be one of the following: diff --git a/dev/initdemo/initdemo.sh b/dev/initdemo/initdemo.sh index ef30d8686f1..59a11351760 100755 --- a/dev/initdemo/initdemo.sh +++ b/dev/initdemo/initdemo.sh @@ -51,6 +51,13 @@ then fi +# ----------------------------- check if dialog available +command -v dialog >/dev/null 2>&1 || { + echo "Error: command dialog not found. On Linux, you can install it with: apt install dialog" + exit +} + + # ----------------------------- if no params on command line if [ "$passwd" = "" ] then @@ -179,17 +186,19 @@ fi if [ "$passwd" != "" ] then export passwd="-p$passwd" + export passwdshown="-p*****" fi #echo "mysql -P$port -u$admin $passwd $base < $mydir/$dumpfile" #mysql -P$port -u$admin $passwd $base < $mydir/$dumpfile #echo "drop old table" +echo "drop table" echo "drop table if exists llx_accounting_account;" | mysql "-P$port" "-u$admin" "$passwd" "$base" -echo "mysql -P$port -u$admin -p***** $base < '$mydir/$dumpfile'" +echo "mysql -P$port -u$admin $passwdshown $base < '$mydir/$dumpfile'" mysql "-P$port" "-u$admin" "$passwd" "$base" < "$mydir/$dumpfile" export res=$? if [ $res -ne 0 ]; then - echo "Error to load database dump with mysql -P$port -u$admin -p***** $base < '$mydir/$dumpfile'" + echo "Error to load database dump with: mysql -P$port -u$admin $passwdshown $base < '$mydir/$dumpfile'" exit fi diff --git a/dev/setup/pre-commit/README.md b/dev/setup/pre-commit/README.md index 5dd6defd12a..f256cbf26e8 100644 --- a/dev/setup/pre-commit/README.md +++ b/dev/setup/pre-commit/README.md @@ -27,10 +27,10 @@ the project: `pre-commit-config.yaml`. If you do not have python installed, install [python](https://www.python.org) first.\ `sudo apt install python3` - If you do not have [`pip`](https://pypi.org/project/pip), install that as well.\\ - `sudo apt install pip` + If you do not have [`pip`](https://pypi.org/project/pip), install that as well.\ + `sudo apt install pip` - Then you can install pre-commit tool: + Then you can install pre-commit tool:\ `python3 -m pip install pre-commit` 2. In your local git clone of the project, run `pre-commit install` to add the hooks @@ -96,4 +96,6 @@ CI also runs pre-commit to help maintain code quality. Note: Code for precommits are saved into: -.cache/pre-commit/repo*/py_env-python3/lib/python*/site-packages/pre_commit_hooks/no_commit_to_branch.py +.cache/pre-commit/repo.../pre_commit_hooks/php-....sh +and +.cache/pre-commit/repo.../py_env-python3/lib/python.../site-packages/pre_commit_hooks/no_commit_to_branch.py diff --git a/dev/tools/apstats.php b/dev/tools/apstats.php index b6fd7ed4adb..fa27133329a 100755 --- a/dev/tools/apstats.php +++ b/dev/tools/apstats.php @@ -149,7 +149,7 @@ $phpstanversion = $output_arrtd[0]; $output_arrtd = array(); if ($dirphpstan != 'disabled') { - $commandcheck = ($dirphpstan ? $dirphpstan.'/' : '').'phpstan --level='.$PHPSTANLEVEL.' -v analyze -a build/phpstan/bootstrap.php --memory-limit 8G --error-format=github -c ~/preview.dolibarr.org/dolibarr/phpstan.v1.neon'; + $commandcheck = ($dirphpstan ? $dirphpstan.'/' : '').'phpstan --level='.$PHPSTANLEVEL.' -v analyze -a build/phpstan/bootstrap.php --memory-limit 8G --error-format=github -c ~/preview.dolibarr.org/dolibarr/dev/tools/phpstan/phpstan_v1_apstats.neon'; print 'Execute PHPStan to get the technical debt: '.$commandcheck."\n"; $resexectd = 0; exec($commandcheck, $output_arrtd, $resexectd); diff --git a/phpstan.v1.neon b/dev/tools/phpstan/phpstan_v1_apstats.neon similarity index 99% rename from phpstan.v1.neon rename to dev/tools/phpstan/phpstan_v1_apstats.neon index b4c987d2c41..6b599560309 100644 --- a/phpstan.v1.neon +++ b/dev/tools/phpstan/phpstan_v1_apstats.neon @@ -48,6 +48,7 @@ parameters: treatPhpDocTypesAsCertain: false ignoreErrors: - '#.*phan-var#' + - '#is always#' internalErrorsCountLimit: 50 cache: nodesByFileCountMax: 512 diff --git a/dev/translation/ignore_translation_keys.lst b/dev/translation/ignore_translation_keys.lst index d870ff1504b..9a34c97bc3f 100644 --- a/dev/translation/ignore_translation_keys.lst +++ b/dev/translation/ignore_translation_keys.lst @@ -580,7 +580,6 @@ NewProperty NoActiveEstablishmentDefined NoAddMember NoAuthorityURLDefined -NoBankAccountFound NoCurrencyRateSelected NoEntriesToShow NoEstablishmentFound diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index ebf0dec3396..60409e47f0f 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -495,6 +495,8 @@ if (empty($reshook)) { $permissiontodelete = $user->hasRight('societe', 'supprimer'); $permissiontoadd = $user->hasRight('societe', 'creer'); $uploaddir = $conf->societe->dir_output; + + global $error; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; if (!$error && $action == 'deletebookkeepingwriting' && $confirm == "yes" && $user->hasRight('accounting', 'mouvements', 'supprimer')) { diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 62c058fbf95..7834b2a6d0f 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -459,6 +459,8 @@ if (empty($reshook)) { $permissiontodelete = $user->hasRight('societe', 'supprimer'); $permissiontoadd = $user->hasRight('societe', 'creer'); $uploaddir = $conf->societe->dir_output; + + global $error; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; if (!$error && $action == 'deletebookkeepingwriting' && $confirm == "yes" && $user->hasRight('accounting', 'mouvements', 'supprimer')) { diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index d71dc306478..379e2b802e1 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2016 Jamal Elbaz * Copyright (C) 2016-2017 Alexandre Spangaro * Copyright (C) 2018-2024 Frédéric France - * Copyright (C) 2024 MDW + * 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 @@ -129,7 +129,7 @@ class AccountancyCategory // extends CommonObject public $sdc; /** - * @var array Sum debit credit per month + * @var array Sum debit credit per month */ public $sdcpermonth; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 7ad5ee54ee7..eee7fde0377 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -43,7 +43,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonpeople.class.php'; /** - * Class to manage members of a foundation + * Class to manage members of a foundation. */ class Adherent extends CommonObject { @@ -829,7 +829,8 @@ class Adherent extends CommonObject $sql .= ", fk_user_mod = ".($user->id > 0 ? $user->id : 'null'); // Can be null because member can be create by a guest $sql .= " WHERE rowid = ".((int) $this->id); - // If we change the type of membership, we set also label of new type + // If we change the type of membership, we set also label of new type.. + '@phan-var-force Adherent $oldcopy'; if (!empty($this->oldcopy) && $this->typeid != $this->oldcopy->typeid) { $sql2 = "SELECT libelle as label"; $sql2 .= " FROM ".MAIN_DB_PREFIX."adherent_type"; @@ -3104,11 +3105,14 @@ class Adherent extends CommonObject $nbko++; $listofmembersko[$adherent->id] = $adherent->id; } else { - $adherent->fetch_thirdparty(); - - // Language code to use ($languagecodeformember) is default language of thirdparty, if no thirdparty, the language found from country of member then country of thirdparty, and if still not found we use the language of company. - $languagefromcountrycode = getLanguageCodeFromCountryCode($adherent->country_code ? $adherent->country_code : $adherent->thirdparty->country_code); - $languagecodeformember = (empty($adherent->thirdparty->default_lang) ? ($languagefromcountrycode ? $languagefromcountrycode : $mysoc->default_lang) : $adherent->thirdparty->default_lang); + $thirdpartyres = $adherent->fetch_thirdparty(); + if ($thirdpartyres === -1 ) { + $languagecodeformember = $mysoc->default_lang; + } else { + // Language code to use ($languagecodeformember) is default language of thirdparty, if no thirdparty, the language found from country of member then country of thirdparty, and if still not found we use the language of company. + $languagefromcountrycode = getLanguageCodeFromCountryCode($adherent->country_code ? $adherent->country_code : $adherent->thirdparty->country_code); + $languagecodeformember = (empty($adherent->thirdparty->default_lang) ? ($languagefromcountrycode ? $languagefromcountrycode : $mysoc->default_lang) : $adherent->thirdparty->default_lang); + } // Send reminder email $outputlangs = new Translate('', $conf); diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 02714bc87df..c54ca5dc0f4 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -55,7 +55,7 @@ if (!$user->admin) { $usersignature = $user->signature; // For action = test or send, we ensure that content is not html, even for signature, because for this we want a test with NO html. -if ($action == 'test' || ($action == 'send' && $trackid = 'test')) { +if ($action == 'test' || ($action == 'send' && $trackid == 'test')) { $usersignature = dol_string_nohtmltag($usersignature, 2); } @@ -1003,7 +1003,7 @@ if ($action == 'edit') { if (!getDolGlobalString('MAIN_DISABLE_ALL_MAILS')) { if (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') != 'mail' || !$linuxlike) { - if (function_exists('fsockopen') && $port && $server) { + if (function_exists('fsockopen') /* && $port && $server */) { // $port and $server can't be empty print ''.$langs->trans("DoTestServerAvailability").''; } } else { @@ -1044,19 +1044,19 @@ if ($action == 'edit') { // mthode php mail if (getDolGlobalString('MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD')) { // Not defined by default. Depend on platform. // List of string to add in SPF if the setup use the mail method. Example 'include:sendgrid.net include:spf.mydomain.com' - $text .= ($text ? '

' : '').$langs->trans("WarningPHPMailSPFDMARC"); + $text .= /* ($text ? '

' : ''). */$langs->trans("WarningPHPMailSPFDMARC"); } else { // MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS is list of IPs where email is sent from. Example: '1.2.3.4, [aaaa:bbbb:cccc:dddd]'. if (getDolGlobalString('MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS')) { // List of IP shown as record to add in SPF if we use the mail method - $text .= ($text ? '

' : '').$langs->trans("WarningPHPMailSPFDMARC"); + $text .= /* ($text ? '

' : ''). */$langs->trans("WarningPHPMailSPFDMARC"); } } } else { // method smtps or swiftmail if (getDolGlobalString('MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD')) { // Should be required only if you have preset the Dolibarr to use your own SMTP and you want to warn users to update their domain name to match your SMTP server. // List of string to add in SPF if we use the smtp method. Example 'include:spf.mydomain.com' - $text .= ($text ? '

' : '').$langs->trans("WarningPHPMailSPF", getDolGlobalString('MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD')); + $text .= /* ($text ? '

' : ''). */$langs->trans("WarningPHPMailSPF", getDolGlobalString('MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD')); } if (getDolGlobalString('MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS')) { // Not defined by default. Depend on platform. // List of IP shown as record to add as allowed IP if we use the smtp method. Value is '1.2.3.4, [aaaa:bbbb:cccc:dddd]' diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index ca2060ac4b2..6454ef43b84 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -231,12 +231,6 @@ class Asset extends CommonObject */ public $status; - /** - * @var static object oldcopy - */ - public $oldcopy; - - /** * @var AssetDepreciationOptions Used for computed fields of depreciation options class. */ diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 064ca39d86d..475c580400f 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -308,7 +308,7 @@ $title = $langs->trans("Agenda"); llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'bodyforlist'); // Define list of all external calendars -$listofextcals = array(); +// $listofextcals = array(); Not used yet in lists $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { @@ -494,7 +494,7 @@ if (!empty($actioncode)) { } else { if (is_array($actioncode)) { $sql .= " AND c.code IN (".$db->sanitize("'".implode("','", $actioncode)."'", 1).")"; - } else { + } elseif ($actioncode !== '-1') { $sql .= " AND c.code IN (".$db->sanitize("'".implode("','", explode(',', $actioncode))."'", 1).")"; } } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index ac6d62da82c..57e8bb3b0b9 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -122,11 +122,6 @@ class Propal extends CommonObject */ public $ref_customer; - /** - * @var static oldcopy with propal properties - */ - public $oldcopy; - /** * Status of the quote * @var int diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 4a6d220c49c..24532b36ba0 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -947,6 +947,7 @@ class Commande extends CommonOrder $this->fk_multicurrency = 0; $this->multicurrency_tx = 1; } + // setEntity will set entity with the right value if empty or change it for the right value if multicompany module is active $this->entity = setEntity($this); dol_syslog(get_class($this)."::create user=".$user->id); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 251485126bb..027443ade23 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4254,15 +4254,6 @@ if ($action == 'create') { * Show object in view mode */ - $result = $object->fetch($id, $ref); - if ($result <= 0) { - dol_print_error($db, $object->error, $object->errors); - exit(); - } - - // fetch optionals attributes and labels - $extrafields->fetch_name_optionals_label($object->table_element); - if ($user->socid > 0 && $user->socid != $object->socid) { accessforbidden('', 0, 1); } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index e63c86551cc..7f7eb71398b 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -248,11 +248,6 @@ class Facture extends CommonInvoice */ public $tab_next_situation_invoice = array(); - /** - * @var static object oldcopy - */ - public $oldcopy; - /** * @var float percentage of retainage */ diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 25eb5c6f532..503c21af370 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -786,6 +786,7 @@ if ($object->id > 0) { $title = $langs->trans("NewPaymentByBankTransfer"); } + print ''; print '
'; print ''; print ''; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 5fc553e9994..410ea609318 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -343,13 +343,6 @@ class Contact extends CommonObject public $ip; // END MODULEBUILDER PROPERTIES - - /** - * Old copy - * @var static - */ - public $oldcopy; // To contain a clone of this when we need to save old properties of object - /** * @var array roles */ diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index 9316a38927b..bb4027978b1 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -75,7 +75,7 @@ if ($action == 'update' && !GETPOST("cancel") && $user->hasRight('societe', 'con $result = $object->update_perso($id, $user); if ($result > 0) { - $object->oldcopy = dol_clone($object, 2); // @phan-suppres-current-line PhanTypeMismatchProperty + $object->oldcopy = dol_clone($object, 2); // @phan-suppress-current-line PhanTypeMismatchProperty // Logo/Photo save $dir = $conf->societe->dir_output.'/contact/'.get_exdir($object->id, 0, 0, 1, $object, 'contact').'/photos'; diff --git a/htdocs/core/actions_dellink.inc.php b/htdocs/core/actions_dellink.inc.php index cf8b3614617..36959569502 100644 --- a/htdocs/core/actions_dellink.inc.php +++ b/htdocs/core/actions_dellink.inc.php @@ -50,6 +50,7 @@ if ($action == 'addlink' && !empty($permissiondellink) && !$cancellink && $id > foreach ($addlinkids as $addlinkid) { $result = $object->add_object_linked($addlink, $addlinkid); } + $object->clearObjectLinkedCache(); } // Link by reference @@ -69,6 +70,7 @@ if ($action == 'addlinkbyref' && !empty($permissiondellink) && !$cancellink && $ if (isset($_POST['reftolinkto'])) { unset($_POST['reftolinkto']); } + $object->clearObjectLinkedCache(); } elseif ($ret < 0) { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); } else { @@ -81,6 +83,7 @@ if ($action == 'addlinkbyref' && !empty($permissiondellink) && !$cancellink && $ // Delete link in table llx_element_element if ($action == 'dellink' && !empty($permissiondellink) && !$cancellink && $dellinkid > 0) { $result = $object->deleteObjectLinked(0, '', 0, '', $dellinkid); + $object->clearObjectLinkedCache(); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 872aa9ae73a..94964dfae8e 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -59,6 +59,7 @@ * @var string $objectclass * @var string $uploaddir * @var string $confirm + * @var int $error */ ' @phan-var-force ?string $permissiontoread diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index c1e3f61379d..9bb732e0a42 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -76,11 +76,6 @@ class Comment extends CommonObject public $comments = array(); - /** - * @var static Object oldcopy - */ - public $oldcopy; - /** * Constructor diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 8fe7db58b72..7ad7702b9df 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -546,7 +546,7 @@ abstract class CommonObject public $multicurrency_total_localtax2; // not in database /** - * @var string + * @var ?string * @see SetDocModel() */ public $model_pdf; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 218c5822d66..d4157ac59c0 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2630,7 +2630,7 @@ class Form * @param array $ajaxoptions Options for ajax_autocompleter * @param int $socid Thirdparty Id (to get also price dedicated to this customer) * @param string|int<0,1> $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. - * @param int $forcecombo Force to use combo box + * @param int $forcecombo Force to use combo box. * @param string $morecss Add more css on select * @param int<0,1> $hidepriceinlabel 1=Hide prices in label * @param string $warehouseStatus Warehouse status filter to count the quantity in stock. Following comma separated filter options can be used @@ -2641,7 +2641,6 @@ class Form * @param int<0,1> $nooutput No print if 1, return the output into a string * @param int<-1,1> $status_purchase Purchase status: -1=No filter on purchase status, 0=Products not on purchase, 1=Products on purchase * @param int $warehouseId Filter by Warehouses Id where there is real stock - * * @return void|string */ public function select_produits($selected = 0, $htmlname = 'productid', $filtertype = '', $limit = 0, $price_level = 0, $status = 1, $finished = 2, $selected_input_value = '', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '', $selected_combinations = null, $nooutput = 0, $status_purchase = -1, $warehouseId = 0) @@ -2666,7 +2665,7 @@ class Form } if (!empty($conf->use_javascript_ajax) && getDolGlobalString('PRODUIT_USE_SEARCH_TO_SELECT')) { - $placeholder = ''; + $placeholder = (is_numeric($showempty) ? '' : 'placeholder="'.dolPrintHTML($showempty).'"'); if ($selected && empty($selected_input_value)) { require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; @@ -2688,6 +2687,7 @@ class Form if ((int) $warehouseId > 0) { $urloption .= '&warehouseid=' . (int) $warehouseId; } + $out .= ajax_autocompleter((string) $selected, $htmlname, DOL_URL_ROOT . '/product/ajax/products.php', $urloption, getDolGlobalInt('PRODUIT_USE_SEARCH_TO_SELECT'), getDolGlobalInt('PRODUCT_SEARCH_AUTO_SELECT_IF_ONLY_ONE', 1), $ajaxoptions); if (isModEnabled('variants') && is_array($selected_combinations)) { @@ -2774,6 +2774,7 @@ class Form $out .= img_picto($langs->trans("Search"), 'search'); } } + $out .= ''; if ($hidelabel == 3) { $out .= img_picto($langs->trans("Search"), 'search'); @@ -2794,16 +2795,16 @@ class Form /** * Return list of BOM for customer in Ajax if Ajax activated or go to select_produits_list * - * @param string $selected Preselected BOM id - * @param string $htmlname Name of HTML select field (must be unique in page). - * @param int $limit Limit on number of returned lines - * @param int $status Sell status -1=Return all bom, 0=Draft BOM, 1=Validated BOM - * @param int $type type of the BOM (-1=Return all BOM, 0=Return disassemble BOM, 1=Return manufacturing BOM) - * @param string|int<0,1> $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. - * @param string $morecss Add more css on select - * @param string $nooutput No print, return the output into a string - * @param int $forcecombo Force to use combo box - * @param string[] $TProducts Add filter on a defined product + * @param string $selected Preselected BOM id + * @param string $htmlname Name of HTML select field (must be unique in page). + * @param int $limit Limit on number of returned lines + * @param int $status Sell status -1=Return all bom, 0=Draft BOM, 1=Validated BOM + * @param int $type Type of the BOM (-1=Return all BOM, 0=Return disassemble BOM, 1=Return manufacturing BOM) + * @param string|int<0,1> $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. + * @param string $morecss Add more css on select + * @param string $nooutput No print, return the output into a string + * @param int $forcecombo Force to use combo box + * @param string[] $TProducts Add filter on a defined product * @return void|string */ public function select_bom($selected = '', $htmlname = 'bom_id', $limit = 0, $status = 1, $type = 0, $showempty = '1', $morecss = '', $nooutput = '', $forcecombo = 0, $TProducts = []) @@ -5138,7 +5139,7 @@ class Form $out = ''; - $langs->load("admin"); + $langs->loadLangs(array("admin", "banks")); $num = 0; $sql = "SELECT rowid, label, bank, clos as status, currency_code"; @@ -5164,7 +5165,7 @@ class Form if ($status == 0) { $out .= '