From 5035580e56c0e062cdddeac2f5835bd47c064602 Mon Sep 17 00:00:00 2001 From: MDW Date: Sat, 15 Feb 2025 17:44:33 +0100 Subject: [PATCH] Qual: Fix phan notices (societe) --- dev/tools/phan/baseline.txt | 34 ++---- htdocs/compta/bank/class/account.class.php | 4 +- htdocs/core/class/html.form.class.php | 22 ++-- htdocs/core/class/html.formcompany.class.php | 22 ++-- .../societe/mod_codeclient_elephant.php | 6 +- .../societe/mod_codeclient_leopard.php | 6 +- .../modules/societe/mod_codeclient_monkey.php | 8 +- .../societe/mod_codecompta_aquarium.php | 8 +- .../societe/mod_codecompta_digitaria.php | 10 +- .../societe/mod_codecompta_panicum.php | 8 +- .../modules/societe/modules_societe.class.php | 38 +++--- htdocs/societe/admin/societe.php | 8 +- htdocs/societe/ajax/company.php | 10 +- .../canvas/actions_card_common.class.php | 4 +- .../company/actions_card_company.class.php | 7 +- htdocs/societe/card.php | 58 ++++----- htdocs/societe/checkvat/checkVatPopup.php | 4 +- .../class/companybankaccount.class.php | 16 +-- htdocs/societe/class/societe.class.php | 50 ++++---- htdocs/societe/consumption.php | 18 ++- htdocs/societe/contact.php | 6 +- htdocs/societe/list.php | 111 +++++++++--------- htdocs/societe/paymentmodes.php | 53 +++++---- htdocs/societe/price.php | 26 ++-- .../tpl/linesalesrepresentative.tpl.php | 7 +- htdocs/societe/website.php | 9 +- 26 files changed, 282 insertions(+), 271 deletions(-) diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index e4bac1868cc..be05dc5d762 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -9,22 +9,22 @@ */ return [ // # Issue statistics: - // PhanTypeMismatchArgument : 1690+ occurrences + // PhanTypeMismatchArgument : 1580+ occurrences // PhanUndeclaredProperty : 500+ occurrences - // PhanTypeMismatchArgumentNullable : 350+ occurrences + // PhanTypeMismatchArgumentNullable : 330+ occurrences // PhanPluginUnknownArrayMethodReturnType : 170+ occurrences // PhanUndeclaredGlobalVariable : 160+ occurrences // PhanTypeMismatchProperty : 120+ occurrences // PhanPluginUnknownArrayMethodParamType : 110+ occurrences - // PhanTypeMismatchArgumentProbablyReal : 75+ occurrences - // PhanPossiblyUndeclaredGlobalVariable : 65+ occurrences - // PhanTypeExpectedObjectPropAccess : 40+ occurrences + // PhanPossiblyUndeclaredGlobalVariable : 55+ occurrences + // PhanTypeMismatchArgumentProbablyReal : 55+ occurrences + // PhanTypeExpectedObjectPropAccess : 35+ occurrences // PhanTypeInvalidDimOffset : 25+ occurrences // PhanTypeMismatchDimFetch : 20+ occurrences // PhanPluginUndeclaredVariableIsset : 15+ occurrences // PhanUndeclaredConstant : 15+ occurrences // PhanTypeMismatchArgumentNullableInternal : 10+ occurrences - // PhanUndeclaredMethod : 10+ occurrences + // PhanUndeclaredMethod : 9 occurrences // PhanTypeComparisonFromArray : 8 occurrences // PhanPluginDuplicateExpressionBinaryOp : 6 occurrences // PhanTypeArraySuspiciousNull : 6 occurrences @@ -101,7 +101,6 @@ return [ 'htdocs/admin/eventorganization.php' => ['PhanTypeMismatchArgument'], 'htdocs/admin/expensereport_rules.php' => ['PhanTypeMismatchArgument'], 'htdocs/admin/external_rss.php' => ['PhanTypeMismatchArgument'], - 'htdocs/admin/fckeditor.php' => ['PhanTypeMismatchArgument'], 'htdocs/admin/hrm.php' => ['PhanTypeMismatchArgument'], 'htdocs/admin/knowledgemanagement.php' => ['PhanTypeMismatchArgument'], 'htdocs/admin/mails.php' => ['PhanTypeMismatchArgument'], @@ -609,7 +608,6 @@ return [ 'htdocs/projet/class/api_tasks.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgument'], 'htdocs/projet/tasks/time.php' => ['PhanTypeInvalidDimOffset', 'PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], 'htdocs/projet/tasks/tpl/linkedobjectblock.tpl.php' => ['PhanUndeclaredProperty'], - 'htdocs/public/company/new.php' => ['PhanTypeMismatchArgument'], 'htdocs/public/eventorganization/subscriptionok.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/public/members/new.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/public/payment/newpayment.php' => ['PhanUndeclaredProperty'], @@ -636,26 +634,13 @@ return [ 'htdocs/recruitment/recruitmentjobposition_card.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/recruitment/recruitmentjobposition_document.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/recruitment/recruitmentjobposition_note.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], - 'htdocs/resource/class/dolresource.class.php' => ['PhanTypeMismatchArgumentNullable'], 'htdocs/salaries/class/api_salaries.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], 'htdocs/salaries/paiement_salary.php' => ['PhanUndeclaredProperty'], 'htdocs/salaries/virement_request.php' => ['PhanUndeclaredProperty'], - 'htdocs/societe/admin/societe.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod'], - 'htdocs/societe/ajax/company.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], - 'htdocs/societe/canvas/actions_card_common.class.php' => ['PhanTypeMismatchArgument'], - 'htdocs/societe/canvas/company/actions_card_company.class.php' => ['PhanTypeMismatchArgument'], - 'htdocs/societe/card.php' => ['PhanTypeMismatchArgument'], - 'htdocs/societe/checkvat/checkVatPopup.php' => ['PhanPossiblyUndeclaredGlobalVariable'], + 'htdocs/societe/ajax/company.php' => ['PhanUndeclaredProperty'], 'htdocs/societe/class/api_thirdparties.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'], - 'htdocs/societe/class/companybankaccount.class.php' => ['PhanTypeMismatchArgumentNullable'], - 'htdocs/societe/class/societe.class.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchProperty'], - 'htdocs/societe/consumption.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/societe/contact.php' => ['PhanTypeMismatchArgument'], - 'htdocs/societe/list.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/societe/paymentmodes.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanUndeclaredGlobalVariable'], - 'htdocs/societe/price.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/societe/tpl/linesalesrepresentative.tpl.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/societe/website.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], + 'htdocs/societe/class/societe.class.php' => ['PhanTypeMismatchProperty'], + 'htdocs/societe/paymentmodes.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument'], 'htdocs/stripe/admin/stripe.php' => ['PhanTypeMismatchArgument'], 'htdocs/stripe/charge.php' => ['PhanTypeMismatchArgument'], 'htdocs/stripe/class/actions_stripe.class.php' => ['PhanPluginBothLiteralsBinaryOp', 'PhanPluginSuspiciousParamPosition', 'PhanTypeMismatchArgument'], @@ -714,7 +699,6 @@ return [ 'htdocs/user/group/card.php' => ['PhanTypeMismatchArgument'], 'htdocs/user/list.php' => ['PhanTypeMismatchArgument'], 'htdocs/user/param_ihm.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'], - 'htdocs/user/virtualcard.php' => ['PhanTypeMismatchArgument'], 'htdocs/variants/ajax/get_attribute_values.php' => ['PhanTypeComparisonFromArray'], 'htdocs/variants/card.php' => ['PhanTypeMismatchArgument'], 'htdocs/variants/class/ProductAttribute.class.php' => ['PhanTypeMismatchArgumentNullable'], diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 050e4267f95..994a47ccd73 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1206,11 +1206,11 @@ class Account extends CommonObject /** * Delete bank account from database * - * @param ?User $user User deleting + * @param User $user User deleting * @param int<0,1> $notrigger 1=Disable triggers * @return int Return integer <0 if KO, >0 if OK */ - public function delete($user = null, $notrigger = 0) + public function delete($user, $notrigger = 0) { $error = 0; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index dee4f0b3b71..79c10768e76 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -412,13 +412,13 @@ class Form /** * Output edit in place form * - * @param string $fieldname Name of the field - * @param CommonObject $object Object - * @param boolean $perm Permission to allow button to edit parameter. Set it to 0 to have a not edited field. - * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'datepicker' ('day' do not work, don't know why), 'ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...) - * @param string $check Same coe than $check parameter of GETPOST() - * @param string $morecss More CSS - * @return string HTML code for the edit of alternative language + * @param string $fieldname Name of the field + * @param CommonObject $object Object + * @param bool|int<0,1> $perm Permission to allow button to edit parameter. Set it to 0 to have a not edited field. + * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'datepicker' ('day' do not work, don't know why), 'ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...) + * @param string $check Same coe than $check parameter of GETPOST() + * @param string $morecss More CSS + * @return string HTML code for the edit of alternative language */ public function widgetForTranslation($fieldname, $object, $perm, $typeofdata = 'string', $check = '', $morecss = '') { @@ -4616,7 +4616,7 @@ class Form * @param int $addempty Add an empty entry * @param int $noinfoadmin 0=Add admin info, 1=Disable admin info * @param string $morecss Add more CSS on select tag - * @param int $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) + * @param float $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) * 0 : use default deposit percentage from entry * > 0 : force deposit percentage (for example, from company object) * @param int $noprint if set to one we return the html to print, if 0 (default) we print it @@ -4646,7 +4646,7 @@ class Form * @param int $addempty Add an empty entry * @param int $noinfoadmin 0=Add admin info, 1=Disable admin info * @param string $morecss Add more CSS on select tag - * @param int $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) + * @param float $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) * 0 : use default deposit percentage from entry * > 0 : force deposit percentage (for example, from company object) * @return string String for the HTML select component @@ -6153,7 +6153,7 @@ class Form * @param int<0,1> $addempty Add empty entry * @param ''|'direct-debit'|'bank-transfer' $type Type ('direct-debit' or 'bank-transfer') * @param int $filtertype If > 0, include payment terms with deposit percentage (for objects other than invoices and invoice templates) - * @param int $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) + * @param float $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) * 0 : use default deposit percentage from entry * > 0 : force deposit percentage (for example, from company object) * @param int<0,1> $nooutput No print is done. String is returned. @@ -11704,7 +11704,7 @@ class Form * @param string $save_label Alternative label for save button * @param string $cancel_label Alternative label for cancel button * @param array $morebuttons Add additional buttons between save and cancel - * @param bool $withoutdiv Option to remove enclosing centered div + * @param bool|int<0,1> $withoutdiv Option to remove enclosing centered div * @param string $morecss More CSS * @param string $dol_openinpopup If the button are shown in a context of a page shown inside a popup, we put here the string name of popup. * @return string Html code with the buttons diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 800913719ee..cf42ba4b738 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -1052,7 +1052,7 @@ class FormCompany extends Form /** * Return a HTML select for thirdparty type * - * @param int $selected Selected value + * @param int<0,4>|'0'|'2,3'|'1,3'|'4' $selected Selected value * @param string $htmlname HTML select name * @param string $htmlidname HTML select id * @param string $typeinput HTML output @@ -1117,11 +1117,11 @@ class FormCompany extends Form /** * Output html select to select third-party type * - * @param string $page Page - * @param string $selected Id preselected - * @param string $htmlname Name of HTML select - * @param string $filter optional filters criteras - * @param int $nooutput No print output. Return it only. + * @param string $page Page + * @param string $selected Id preselected + * @param string $htmlname Name of HTML select + * @param string $filter optional filters criteras + * @param int<0,1> $nooutput No print output. Return it only. * @return void|string */ public function formThirdpartyType($page, $selected = '', $htmlname = 'socid', $filter = '', $nooutput = 0) @@ -1158,11 +1158,11 @@ class FormCompany extends Form /** * Output html select to select prospect status * - * @param string $htmlname Name of HTML select - * @param Contact|null $prospectstatic Prospect object - * @param int $statusprospect status of prospect - * @param int $idprospect id of prospect - * @param string $mode select if we want activate de html part or js + * @param string $htmlname Name of HTML select + * @param Contact|Client|null $prospectstatic Prospect object + * @param int $statusprospect status of prospect + * @param int $idprospect id of prospect + * @param 'html'|'js' $mode select if we want activate de html part or js * @return void */ public function selectProspectStatus($htmlname, $prospectstatic, $statusprospect, $idprospect, $mode = "html") diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php index b01fcafb6db..ad558c7e950 100644 --- a/htdocs/core/modules/societe/mod_codeclient_elephant.php +++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php @@ -5,7 +5,7 @@ * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2013-2018 Philippe Grand * Copyright (C) 2020-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Eric Seigne * * This program is free software; you can redistribute it and/or modify @@ -219,8 +219,8 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode /** * Return next value * - * @param Societe|string $objsoc Object third party - * @param int $type Client ou fournisseur (0:customer, 1:supplier) + * @param Societe|string|null $objsoc Object third party + * @param int<-1,2> $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string|-1 Value if OK, '' if module not configured, -1 if KO */ public function getNextValue($objsoc = '', $type = -1) diff --git a/htdocs/core/modules/societe/mod_codeclient_leopard.php b/htdocs/core/modules/societe/mod_codeclient_leopard.php index e7509a07e3b..b5699c9440c 100644 --- a/htdocs/core/modules/societe/mod_codeclient_leopard.php +++ b/htdocs/core/modules/societe/mod_codeclient_leopard.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004 Rodolphe Quiedeville * Copyright (C) 2006-2014 Laurent Destailleur * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -90,8 +90,8 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode /** * Return an example of result returned by getNextValue * - * @param Societe|string $objsoc Object thirdparty - * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) + * @param Societe|string|null $objsoc Object third party + * @param int<-1,2> $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Return next value */ public function getNextValue($objsoc = '', $type = -1) diff --git a/htdocs/core/modules/societe/mod_codeclient_monkey.php b/htdocs/core/modules/societe/mod_codeclient_monkey.php index 159f9114faf..d12833d958d 100644 --- a/htdocs/core/modules/societe/mod_codeclient_monkey.php +++ b/htdocs/core/modules/societe/mod_codeclient_monkey.php @@ -3,7 +3,7 @@ * Copyright (C) 2006-2007 Laurent Destailleur * Copyright (C) 2006-2012 Regis Houssin * Copyright (C) 2024-2025 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -96,9 +96,9 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode /** * Return next value * - * @param Societe|string $objsoc Object third party - * @param int $type Client ou fournisseur (1:client, 2:fournisseur) - * @return string|-1 Value if OK, '' if module not configured, -1 if KO + * @param Societe|string|null $objsoc Object third party + * @param int<-1,2> $type Type of third party (1:customer, 2:supplier, -1:autodetect) + * @return string|-1 Value if OK, '' if module not configured, -1 if KO */ public function getNextValue($objsoc = '', $type = -1) { diff --git a/htdocs/core/modules/societe/mod_codecompta_aquarium.php b/htdocs/core/modules/societe/mod_codecompta_aquarium.php index ce5cfb5466b..fd15395e2ec 100644 --- a/htdocs/core/modules/societe/mod_codecompta_aquarium.php +++ b/htdocs/core/modules/societe/mod_codecompta_aquarium.php @@ -3,7 +3,7 @@ /* Copyright (C) 2004-2007 Rodolphe Quiedeville * Copyright (C) 2005 Eric Seigne * Copyright (C) 2006-2011 Laurent Destailleur - * Copyright (C) 2024-2025 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -158,8 +158,8 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode * Set accountancy account code for a third party into this->code * * @param DoliDB $db Database handler - * @param Societe $societe Third party object - * @param string $type 'customer' or 'supplier' + * @param ?Societe $societe Third party object + * @param 'customer'|'supplier'|'' $type 'customer' or 'supplier' * @return int >=0 if OK, <0 if KO */ public function get_code($db, $societe, $type = '') @@ -213,7 +213,7 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode * * @param DoliDB $db Database handler * @param string $code Code of third party - * @param Societe $societe Object third party + * @param ?Societe $societe Object third party * @param string $type 'supplier' or 'customer' * @return int 0 if OK but not available, >0 if OK and available, <0 if KO */ diff --git a/htdocs/core/modules/societe/mod_codecompta_digitaria.php b/htdocs/core/modules/societe/mod_codecompta_digitaria.php index 4ccb0c151a4..87bb764a27d 100644 --- a/htdocs/core/modules/societe/mod_codecompta_digitaria.php +++ b/htdocs/core/modules/societe/mod_codecompta_digitaria.php @@ -4,7 +4,7 @@ * Copyright (C) 2010 Laurent Destailleur * Copyright (C) 2019 Alexandre Spangaro * Copyright (C) 2019-2024 Frédéric France - * Copyright (C) 2024-2025 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -201,10 +201,10 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode /** * Set accountancy account code for a third party into this->code * - * @param DoliDB $db Database handler - * @param Societe $societe Third party object - * @param string $type 'customer' or 'supplier' - * @return int >=0 if OK, <0 if KO + * @param DoliDB $db Database handler + * @param ?Societe $societe Third party object + * @param 'customer'|'supplier'|'' $type 'customer' or 'supplier' + * @return int >=0 if OK, <0 if KO */ public function get_code($db, $societe, $type = '') { diff --git a/htdocs/core/modules/societe/mod_codecompta_panicum.php b/htdocs/core/modules/societe/mod_codecompta_panicum.php index 41c6a65a46f..adb2e3ce6e7 100644 --- a/htdocs/core/modules/societe/mod_codecompta_panicum.php +++ b/htdocs/core/modules/societe/mod_codecompta_panicum.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004 Rodolphe Quiedeville * Copyright (C) 2010 Laurent Destailleur * Copyright (C) 2024-2025 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -91,9 +91,9 @@ class mod_codecompta_panicum extends ModeleAccountancyCode /** * Set accountancy account code for a third party into this->code * - * @param DoliDB $db Database handler - * @param Societe $societe Third party object - * @param string $type 'customer' or 'supplier' + * @param DoliDB $db Database handler + * @param ?Societe $societe Third party object + * @param 'customer'|'supplier'|'' $type 'customer' or 'supplier' * @return int >=0 if OK, <0 if KO */ public function get_code($db, $societe, $type = '') diff --git a/htdocs/core/modules/societe/modules_societe.class.php b/htdocs/core/modules/societe/modules_societe.class.php index 82551e436ae..b4bb7bbdcf0 100644 --- a/htdocs/core/modules/societe/modules_societe.class.php +++ b/htdocs/core/modules/societe/modules_societe.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -93,15 +93,15 @@ abstract class ModeleThirdPartyCode extends CommonNumRefGenerator * @param int<-1,2> $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Return string example */ - //abstract public function getExample($langs = null, $objsoc = '', $type = -1); + abstract public function getExample($langs = null, $objsoc = '', $type = -1); /** * Return next value available * - * @param Societe|string $objsoc Object thirdparty - * @param int $type Type - * @return string Value + * @param Societe|string|null $objsoc Object thirdparty + * @param int<-1,2> $type Type + * @return string Value */ public function getNextValue($objsoc = '', $type = -1) { @@ -144,8 +144,8 @@ abstract class ModeleThirdPartyCode extends CommonNumRefGenerator * Return description of module parameters * * @param Translate $langs Output language - * @param Societe $soc Third party object - * @param int $type -1=Nothing, 0=Customer, 1=Supplier + * @param ?Societe $soc Third party object + * @param int<-1,1> $type -1=Nothing, 0=Customer, 1=Supplier * @return string HTML translated description */ public function getToolTip($langs, $soc, $type) @@ -212,7 +212,7 @@ abstract class ModeleThirdPartyCode extends CommonNumRefGenerator /** * Check if mask/numbering use prefix * - * @return int 0=no, 1=yes + * @return int<0,1> 0=no, 1=yes */ public function verif_prefixIsUsed() { @@ -253,8 +253,8 @@ abstract class ModeleAccountancyCode extends CommonNumRefGenerator * Return description of module parameters * * @param Translate $langs Output language - * @param Societe $soc Third party object - * @param int $type -1=Nothing, 0=Customer, 1=Supplier + * @param ?Societe $soc Third party object + * @param int<-1,1> $type -1=Nothing, 0=Customer, 1=Supplier * @return string HTML translated description */ public function getToolTip($langs, $soc, $type) @@ -294,9 +294,9 @@ abstract class ModeleAccountancyCode extends CommonNumRefGenerator /** * Set accountancy account code for a third party into this->code * - * @param DoliDB $db Database handler - * @param Societe $societe Third party object - * @param string $type 'customer' or 'supplier' + * @param DoliDB $db Database handler + * @param ?Societe $societe Third party object + * @param 'customer'|'supplier'|'' $type 'customer' or 'supplier' * @return int<-1,1> >=0 if success, -1 if failure */ public function get_code($db, $societe, $type = '') @@ -304,7 +304,17 @@ abstract class ModeleAccountancyCode extends CommonNumRefGenerator // phpcs:enable global $langs; - dol_syslog(get_class($this)."::get_code".$langs->trans("NotAvailable"), LOG_ERR); + dol_syslog(__METHOD__." ".$langs->trans("NotAvailable"), LOG_ERR); return -1; } + + /** + * Return an example of result returned by getNextValue + * + * @param ?Translate $langs Object langs + * @param Societe|string $objsoc Object thirdparty + * @param int<-1,2> $type Type of third party (1:customer, 2:supplier, -1:autodetect) + * @return string Return string example + */ + abstract public function getExample($langs = null, $objsoc = '', $type = -1); } diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index e4e0925f5b1..d36aeb1222e 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011-2012 Juanjo Menent - * Copyright (C) 2024-2025 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -440,7 +440,7 @@ foreach ($dirsociete as $dirroot) { } $arrayofmodules = dol_sort_array($arrayofmodules, 'position'); -'@phan-var-force array $arrayofmodules'; // Repeat type because of dol_sort_array +// '@phan-var-force array $arrayofmodules'; // Repeat type because of dol_sort_array foreach ($arrayofmodules as $file => $modCodeTiers) { print ''."\n"; @@ -448,7 +448,7 @@ foreach ($arrayofmodules as $file => $modCodeTiers) { print ''.$modCodeTiers->info($langs).''."\n"; print ''.$modCodeTiers->getExample($langs).''."\n"; - if ($conf->global->SOCIETE_CODECLIENT_ADDON == "$file") { + if ($conf->global->SOCIETE_CODECLIENT_ADDON == (string) $file) { print ''."\n"; print img_picto($langs->trans("Activated"), 'switch_on'); print "\n"; @@ -988,7 +988,7 @@ if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTSCUSTOMERS')) { print ''; print ''.$langs->trans("DefaultCustomerType").''; print ''; - print $formcompany->selectProspectCustomerType(getDolGlobalString('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT'), 'defaultcustomertype', 'defaultcustomertype', 'admin'); + print $formcompany->selectProspectCustomerType(getDolGlobalInt('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT'), 'defaultcustomertype', 'defaultcustomertype', 'admin'); print ''; print ''; print ''; diff --git a/htdocs/societe/ajax/company.php b/htdocs/societe/ajax/company.php index 51f33f87f6f..fc1ef0621bc 100644 --- a/htdocs/societe/ajax/company.php +++ b/htdocs/societe/ajax/company.php @@ -2,7 +2,7 @@ /* Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2007-2019 Laurent Destailleur - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -53,7 +53,7 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; * @var User $user */ -$htmlname = GETPOST('htmlname', 'aZ09'); +$htmlname = (string) GETPOST('htmlname', 'aZ09'); $filter = GETPOST('filter', 'alpha'); $outjson = (GETPOSTINT('outjson') ? GETPOSTINT('outjson') : 0); $action = GETPOST('action', 'aZ09'); @@ -102,7 +102,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id) && $user->hasRight('soc } else { require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; - if (empty($htmlname)) { + if ($htmlname === '') { return; } @@ -115,7 +115,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id) && $user->hasRight('soc $id = (!empty($match[0]) ? $match[0] : ''); // Take first key found into GET array with matching $htmlname123 // When used from jQuery, the search term is added as GET param $htmlname. - $searchkey = (($id && GETPOST($id, 'alpha')) ? GETPOST($id, 'alpha') : (($htmlname && GETPOST($htmlname, 'alpha')) ? GETPOST($htmlname, 'alpha') : '')); + $searchkey = (($id && GETPOST($id, 'alpha')) ? GETPOST($id, 'alpha') : (($htmlname && GETPOST($htmlname, 'alpha')) ? (string) GETPOST($htmlname, 'alpha') : '')); if (!$searchkey) { return; } @@ -134,7 +134,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id) && $user->hasRight('soc // If SOCIETE_USE_SEARCH_TO_SELECT is set, check that nb of chars in $filter is >= to avoid DOS attack - $arrayresult = $form->select_thirdparty_list(0, $htmlname, $filter, 1, $showtype, 0, null, $searchkey, $outjson, 0, 'minwidth100', '', false, $excludeids, $showcode); + $arrayresult = $form->select_thirdparty_list('0', (string) $htmlname, $filter, 1, $showtype, 0, array(), $searchkey, $outjson, 0, 'minwidth100', '', false, $excludeids, $showcode); if ($outjson) { print json_encode($arrayresult); diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index ef113ba10da..860c3e071f6 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -258,7 +258,7 @@ abstract class ActionsCardCommon // Country $this->object->country_id = ($this->object->country_id ? $this->object->country_id : $mysoc->country_id); $this->object->country_code = ($this->object->country_code ? $this->object->country_code : $mysoc->country_code); - $this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id'); + $this->tpl['select_country'] = $form->select_country((string) $this->object->country_id, 'country_id'); $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; if ($user->admin) { @@ -281,7 +281,7 @@ abstract class ActionsCardCommon $this->tpl['yn_assujtva'] = $form->selectyesno('assujtva_value', $this->tpl['tva_assuj'], 1); // Assujeti par default en creation // Select users - $this->tpl['select_users'] = $form->select_dolusers($this->object->commercial_id, 'commercial_id', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + $this->tpl['select_users'] = $form->select_dolusers($this->object->commercial_id, 'commercial_id', 1, null, 0, '', '', '0', 0, 0, '', 0, '', 'maxwidth300'); // Local Tax // TODO Implement country specific action in country specific class diff --git a/htdocs/societe/canvas/company/actions_card_company.class.php b/htdocs/societe/canvas/company/actions_card_company.class.php index f5d533ceeab..955f6faa638 100644 --- a/htdocs/societe/canvas/company/actions_card_company.class.php +++ b/htdocs/societe/canvas/company/actions_card_company.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2011 Laurent Destailleur + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -122,7 +123,7 @@ class ActionsCardCompany extends ActionsCardCommon $this->tpl['select_companytype'] = $form->selectarray("typent_id", $formcompany->typent_array(0), $this->object->typent_id); // Juridical Status - $this->tpl['select_juridicalstatus'] = $formcompany->select_juridicalstatus($this->object->forme_juridique_code, $this->object->country_code); + $this->tpl['select_juridicalstatus'] = $formcompany->select_juridicalstatus($this->object->forme_juridique_code, $this->object->country_id); // Workforce $this->tpl['select_workforce'] = $form->selectarray("effectif_id", $formcompany->effectif_array(0), $this->object->effectif_id); @@ -136,7 +137,7 @@ class ActionsCardCompany extends ActionsCardCommon $s .= ''.$langs->trans("VATIntraCheck").''; $this->tpl['tva_intra'] = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); } else { - $this->tpl['tva_intra'] = $s.'object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; + $this->tpl['tva_intra'] = $s.'object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; } } else { $this->tpl['tva_intra'] = $s; @@ -164,7 +165,7 @@ class ActionsCardCompany extends ActionsCardCommon $s .= ''.$langs->trans("VATIntraCheck").''; $this->tpl['tva_intra'] = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); } else { - $this->tpl['tva_intra'] = $s.'object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; + $this->tpl['tva_intra'] = $s.'object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; } } else { $this->tpl['tva_intra'] = $s; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index b2fee95952e..4c45dc785c3 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -16,7 +16,7 @@ * Copyright (C) 2022-2023 George Gkantinas * Copyright (C) 2023 Nick Fragoulis * Copyright (C) 2023 Alexandre Janniaux - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Charlene Benke * * This program is free software; you can redistribute it and/or modify @@ -1677,7 +1677,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ''.img_picto('', 'globe', 'class="pictofixedwidth"').' '; // Email - print ''.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', getDolGlobalString('SOCIETE_EMAIL_MANDATORY')).''; + print ''.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', getDolGlobalInt('SOCIETE_EMAIL_MANDATORY')).''; print 'browser->layout == 'phone') || !isModEnabled('mailing') ? ' colspan="3"' : '').'>'.img_picto('', 'object_email', 'class="pictofixedwidth"').' '; // Unsubscribe @@ -1740,7 +1740,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio $NBPROFIDMIN = getDolGlobalInt('THIRDPARTY_MIN_NB_PROF_ID', 2); $NBPROFIDMAX = getDolGlobalInt('THIRDPARTY_MAX_NB_PROF_ID', 6); while ($i <= $NBPROFIDMAX) { - $idprof = $langs->transcountry('ProfId'.$i, $object->country_code); + $idprof = $langs->transcountry('ProfId'.$i, (string) $object->country_code); if ($idprof != '-' && ($i <= $NBPROFIDMIN || !empty($langs->tab_translate['ProfId'.$i.$object->country_code]))) { $key = 'idprof'.$i; @@ -1799,7 +1799,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio $s .= ''.$langs->trans("VATIntraCheck").''; $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); } else { - $s .= 'country_id).'" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; + $s .= 'country_id).'" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; } } print $s; @@ -1861,7 +1861,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ''.$form->editfieldkey('JuridicalStatus', 'forme_juridique_code', '', $object, 0).''; print ''; if ($object->country_id) { - print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code, '', 'forme_juridique_code'); + print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_id, '', 'forme_juridique_code'); } else { print $countrynotdefined; } @@ -1892,14 +1892,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ''; print ''.$form->editfieldkey('PaymentConditions', 'cond_reglement_id', '', $object, 0).''; print ''; - print $form->getSelectConditionsPaiements($object->cond_reglement_id, 'cond_reglement_id', 1, 1, 1, '', $object->deposit_percent); + print $form->getSelectConditionsPaiements($object->cond_reglement_id, 'cond_reglement_id', 1, 1, 1, '', (float) $object->deposit_percent); print ''; // Payment mode print ''; print ''.$form->editfieldkey('PaymentMode', 'mode_reglement_id', '', $object, 0).''; print ''; - print $form->select_types_paiements($object->mode_reglement_id, 'mode_reglement_id', '', 0, 1, 1, 0, 1); + print $form->select_types_paiements((string) $object->mode_reglement_id, 'mode_reglement_id', '', 0, 1, 1, 0, 1); print ''; // Incoterms @@ -2292,7 +2292,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio // Name print ''.$form->editfieldkey('ThirdPartyName', 'name', '', $object, 0, 'string', '', 1).''; print ''; - print $form->widgetForTranslation("name", $object, $permissiontoadd, 'string', 'alphanohtml', 'minwidth300'); + print $form->widgetForTranslation("name", $object, (int) $permissiontoadd, 'string', 'alphanohtml', 'minwidth300'); print ''; // Alias names (commercial, trademark or alias names) @@ -2456,7 +2456,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ''; - print $form->widgetForTranslation("address", $object, $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent'); + print $form->widgetForTranslation("address", $object, (int) $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent'); print ''; // Zip / Town @@ -2468,7 +2468,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio } print ''.$form->editfieldkey('Town', 'town', '', $object, 0).'browser->layout == 'phone' ? ' colspan="3"' : '').'>'; print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); - print $form->widgetForTranslation("town", $object, $permissiontoadd, 'string', 'alphanohtml', 'maxwidth100 quatrevingtpercent'); + print $form->widgetForTranslation("town", $object, (int) $permissiontoadd, 'string', 'alphanohtml', 'maxwidth100 quatrevingtpercent'); print ''; // Country @@ -2511,7 +2511,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ''.img_picto('', 'globe', 'class="pictofixedwidth"').' '; // EMail - print ''.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (getDolGlobalString('SOCIETE_EMAIL_MANDATORY'))).''; + print ''.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (getDolGlobalInt('SOCIETE_EMAIL_MANDATORY'))).''; print 'browser->layout == 'phone') || !isModEnabled('mailing') ? ' colspan="3"' : '').'>'; print img_picto('', 'object_email', 'class="pictofixedwidth"'); print ''; @@ -2549,8 +2549,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio } print ''; print ''; - $useempty = (getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2); - print $form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOSTINT("no_email") : $object->no_email), 1, false, $useempty); + $useempty = (int) (getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2); + print $form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOSTINT("no_email") : $object->no_email), 1, 0, $useempty); print ''; } print ''; @@ -2581,7 +2581,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio } $idprof_mandatory = 'SOCIETE_IDPROF'.($i).'_MANDATORY'; - print ''.$form->editfieldkey($idprof, $key, '', $object, 0, 'string', '', !(empty($conf->global->$idprof_mandatory) || !$object->isACompany())).''; + print ''.$form->editfieldkey($idprof, $key, '', $object, 0, 'string', '', (int) !(empty($conf->global->$idprof_mandatory) || !$object->isACompany())).''; print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code); print ''; if (($j % $NBCOLS) == ($NBCOLS - 1)) { @@ -2607,7 +2607,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print 'localtax1_assuj ? 'checked="checked"' : '') . ' value="1">'; if (!isOnlyOneLocalTax(1)) { print ' '.$langs->transcountry("Type", $mysoc->country_code).': '; - $formcompany->select_localtax(1, $object->localtax1_value, "lt1"); + $formcompany->select_localtax(1, (float) $object->localtax1_value, "lt1"); print ''; } print ''; @@ -2616,7 +2616,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print 'localtax2_assuj ? 'checked="checked"' : '') . ' value="1">'; if (!isOnlyOneLocalTax(2)) { print ' '.$langs->transcountry("Type", $mysoc->country_code).': '; - $formcompany->select_localtax(2, $object->localtax2_value, "lt2"); + $formcompany->select_localtax(2, (float) $object->localtax2_value, "lt2"); print ''; } print ''; @@ -2625,7 +2625,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print 'localtax1_assuj ? 'checked="checked"' : '') . ' value="1">'; if (!isOnlyOneLocalTax(1)) { print ' '.$langs->transcountry("Type", $mysoc->country_code).': '; - $formcompany->select_localtax(1, $object->localtax1_value, "lt1"); + $formcompany->select_localtax(1, (float) $object->localtax1_value, "lt1"); print ''; } print ''; @@ -2634,7 +2634,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print 'localtax2_assuj ? 'checked="checked"' : '') . ' value="1">'; if (!isOnlyOneLocalTax(2)) { print ' '.$langs->transcountry("Type", $mysoc->country_code).': '; - $formcompany->select_localtax(2, $object->localtax2_value, "lt2"); + $formcompany->select_localtax(2, (float) $object->localtax2_value, "lt2"); print ''; } print ''; @@ -2675,7 +2675,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio $s .= ''.$langs->trans("VATIntraCheck").''; $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); } else { - $s .= 'country_id).'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; + $s .= 'country_id).'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; } } print $s; @@ -2705,7 +2705,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio // Juridical type print ''.$form->editfieldkey('JuridicalStatus', 'forme_juridique_code', '', $object, 0).''; - print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code, '', 'forme_juridique_code'); + print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_id, '', 'forme_juridique_code'); print ''; // Capital @@ -2824,7 +2824,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ''; print ''.$form->editfieldkey('AllocateCommercial', 'commercial_id', '', $object, 0).''; print ''; - $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, 'u.statut:=:1', 0, '', '', 0, 1); + $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', '0', 0, 0, 'u.statut:=:1', 0, '', '', 0, 1); $arrayselected = GETPOST('commercial', 'array'); if (empty($arrayselected)) { $arrayselected = $object->getSalesRepresentatives($user, 1); @@ -3069,7 +3069,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ''.$langs->transcountry("Localtax1", $mysoc->country_code).' id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; if ($action == 'editRE') { print ''; - $formcompany->select_localtax(1, $object->localtax1_value, "lt1"); + $formcompany->select_localtax(1, (float) $object->localtax1_value, "lt1"); print ''; } else { print ''.$object->localtax1_value.''; @@ -3083,7 +3083,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ''.$langs->transcountry("Localtax2", $mysoc->country_code).'id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; if ($action == 'editIRPF') { print ''; - $formcompany->select_localtax(2, $object->localtax2_value, "lt2"); + $formcompany->select_localtax(2, (float) $object->localtax2_value, "lt2"); print ''; } else { print ''.$object->localtax2_value.''; @@ -3101,7 +3101,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ' '.$langs->transcountry("Localtax1", $mysoc->country_code).'id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; if ($action == 'editRE') { print ''; - $formcompany->select_localtax(1, $object->localtax1_value, "lt1"); + $formcompany->select_localtax(1, (float) $object->localtax1_value, "lt1"); print ''; } else { print ''.$object->localtax1_value.''; @@ -3119,7 +3119,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ' '.$langs->transcountry("Localtax2", $mysoc->country_code).' id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; if ($action == 'editIRPF') { print ''; - $formcompany->select_localtax(2, $object->localtax2_value, "lt2"); + $formcompany->select_localtax(2, (float) $object->localtax2_value, "lt2"); print ''; } else { print ''.$object->localtax2_value.''; @@ -3160,7 +3160,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio $s .= ''.$langs->trans("VATIntraCheck").''; $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); } else { - $s .= 'country_id).'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; + $s .= 'country_id).'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; } } print $s; @@ -3227,7 +3227,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ''; print ''; $html_name = ($action == 'editthirdpartytype') ? 'typent_id' : 'none'; - $formcompany->formThirdpartyType($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->typent_id, $html_name, ''); + $formcompany->formThirdpartyType($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->typent_id, $html_name, ''); print ''; // Workforce/Staff @@ -3358,7 +3358,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ''; print ''; $html_name = ($action == 'editparentcompany') ? 'parent_id' : 'none'; - $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->parent, $html_name, '', 1, 0, 0, array(), 0, array($object->id)); + $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->parent, $html_name, '', 1, 0, 0, array(), 0, array($object->id)); print ''; } @@ -3486,7 +3486,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio $genallowed = $user->hasRight('societe', 'lire'); $delallowed = $user->hasRight('societe', 'creer'); - print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); + print $formfile->showdocuments('company', (string) $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, '', '', $object->default_lang); } // Subsidiaries list diff --git a/htdocs/societe/checkvat/checkVatPopup.php b/htdocs/societe/checkvat/checkVatPopup.php index 5abc5048814..451f77fa51e 100644 --- a/htdocs/societe/checkvat/checkVatPopup.php +++ b/htdocs/societe/checkvat/checkVatPopup.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -54,6 +55,8 @@ print '
'; print load_fiche_titre($langs->trans("VATIntraCheckableOnEUSite"), '', 'title_setup'); +$messagetoshow = ''; + $vatNumber = GETPOST("vatNumber", 'alpha'); if (!$vatNumber) { @@ -96,7 +99,6 @@ if (!$vatNumber) { dol_syslog("Call method ".$WS_METHOD); $result = $soapclient->call($WS_METHOD, $parameters); - $messagetoshow = ''; print ''.$langs->trans("Response").':
'; $faultstring = $result['faultstring'] ?? ''; // Service indisponible diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index bfdbf8c7920..c6832d92084 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -5,7 +5,7 @@ * Copyright (C) 2013 Peter Fontaine * Copyright (C) 2016 Marcos García * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -212,7 +212,7 @@ class CompanyBankAccount extends Account public $country_code; /** - * @var int $default_rib 1 = this object is the third party's default bank information, 0 if not + * @var int 1 = this object is the third party's default bank information, 0 if not */ public $default_rib; @@ -356,11 +356,11 @@ class CompanyBankAccount extends Account /** * Create bank information record. * - * @param ?User $user User + * @param User $user User * @param int<0,1> $notrigger 1=Disable triggers * @return int Return integer <0 if KO, > 0 if OK (ID of newly created company bank account information) */ - public function create($user = null, $notrigger = 0) + public function create($user, $notrigger = 0) { $now = dol_now(); @@ -431,11 +431,11 @@ class CompanyBankAccount extends Account /** * Update bank account * - * @param ?User $user Object user + * @param User $user Object user * @param int<0,1> $notrigger 1=Disable triggers * @return int Return integer <=0 if KO, >0 if OK */ - public function update($user = null, $notrigger = 0) + public function update($user, $notrigger = 0) { global $langs; @@ -599,11 +599,11 @@ class CompanyBankAccount extends Account /** * Delete a rib from database * - * @param ?User $user User deleting + * @param User $user User deleting * @param int<0,1> $notrigger 1=Disable triggers * @return int Return integer <0 if KO, >0 if OK */ - public function delete($user = null, $notrigger = 0) + public function delete($user, $notrigger = 0) { $error = 0; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index f734c3b7612..2a70b11d5d4 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1644,16 +1644,16 @@ class Societe extends CommonObject $sql .= ",idprof5 = '".$this->db->escape($this->idprof5)."'"; $sql .= ",idprof6 = '".$this->db->escape($this->idprof6)."'"; - $sql .= ",tva_assuj = ".($this->tva_assuj != '' ? "'".$this->db->escape($this->tva_assuj)."'" : "null"); + $sql .= ",tva_assuj = ".($this->tva_assuj != '' ? "'".$this->db->escape((string) $this->tva_assuj)."'" : "null"); $sql .= ",tva_intra = '".$this->db->escape($this->tva_intra)."'"; if (!getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) { - $sql .= ",vat_reverse_charge = " . ($this->vat_reverse_charge != '' ? "'" . $this->db->escape($this->vat_reverse_charge) . "'" : 0); + $sql .= ",vat_reverse_charge = " . ($this->vat_reverse_charge != '' ? "'" . $this->db->escape((string) $this->vat_reverse_charge) . "'" : 0); } $sql .= ",status = ".((int) $this->status); // Local taxes - $sql .= ",localtax1_assuj = ".($this->localtax1_assuj != '' ? "'".$this->db->escape($this->localtax1_assuj)."'" : "null"); - $sql .= ",localtax2_assuj = ".($this->localtax2_assuj != '' ? "'".$this->db->escape($this->localtax2_assuj)."'" : "null"); + $sql .= ",localtax1_assuj = ".($this->localtax1_assuj != '' ? "'".$this->db->escape((string) $this->localtax1_assuj)."'" : "null"); + $sql .= ",localtax2_assuj = ".($this->localtax2_assuj != '' ? "'".$this->db->escape((string) $this->localtax2_assuj)."'" : "null"); if ($this->localtax1_assuj == 1) { if ($this->localtax1_value != '') { $sql .= ",localtax1_value =".$this->localtax1_value; @@ -1686,16 +1686,16 @@ class Societe extends CommonObject $sql .= ",fk_typent = ".($this->typent_id > 0 ? ((int) $this->typent_id) : "0"); } - $sql .= ",fk_forme_juridique = ".(!empty($this->forme_juridique_code) ? "'".$this->db->escape($this->forme_juridique_code)."'" : "null"); + $sql .= ",fk_forme_juridique = ".(!empty($this->forme_juridique_code) ? "'".$this->db->escape((string) $this->forme_juridique_code)."'" : "null"); - $sql .= ",mode_reglement = ".(!empty($this->mode_reglement_id) ? "'".$this->db->escape($this->mode_reglement_id)."'" : "null"); - $sql .= ",cond_reglement = ".(!empty($this->cond_reglement_id) ? "'".$this->db->escape($this->cond_reglement_id)."'" : "null"); - $sql .= ",deposit_percent = ".(!empty($this->deposit_percent) ? "'".$this->db->escape($this->deposit_percent)."'" : "null"); - $sql .= ",transport_mode = ".(!empty($this->transport_mode_id) ? "'".$this->db->escape($this->transport_mode_id)."'" : "null"); - $sql .= ",mode_reglement_supplier = ".(!empty($this->mode_reglement_supplier_id) ? "'".$this->db->escape($this->mode_reglement_supplier_id)."'" : "null"); - $sql .= ",cond_reglement_supplier = ".(!empty($this->cond_reglement_supplier_id) ? "'".$this->db->escape($this->cond_reglement_supplier_id)."'" : "null"); - $sql .= ",transport_mode_supplier = ".(!empty($this->transport_mode_supplier_id) ? "'".$this->db->escape($this->transport_mode_supplier_id)."'" : "null"); - $sql .= ",fk_shipping_method = ".(!empty($this->shipping_method_id) ? "'".$this->db->escape($this->shipping_method_id)."'" : "null"); + $sql .= ",mode_reglement = ".(!empty($this->mode_reglement_id) ? "'".$this->db->escape((string) $this->mode_reglement_id)."'" : "null"); + $sql .= ",cond_reglement = ".(!empty($this->cond_reglement_id) ? "'".$this->db->escape((string) $this->cond_reglement_id)."'" : "null"); + $sql .= ",deposit_percent = ".(!empty($this->deposit_percent) ? "'".$this->db->escape((string) $this->deposit_percent)."'" : "null"); + $sql .= ",transport_mode = ".(!empty($this->transport_mode_id) ? "'".$this->db->escape((string) $this->transport_mode_id)."'" : "null"); + $sql .= ",mode_reglement_supplier = ".(!empty($this->mode_reglement_supplier_id) ? "'".$this->db->escape((string) $this->mode_reglement_supplier_id)."'" : "null"); + $sql .= ",cond_reglement_supplier = ".(!empty($this->cond_reglement_supplier_id) ? "'".$this->db->escape((string) $this->cond_reglement_supplier_id)."'" : "null"); + $sql .= ",transport_mode_supplier = ".(!empty($this->transport_mode_supplier_id) ? "'".$this->db->escape((string) $this->transport_mode_supplier_id)."'" : "null"); + $sql .= ",fk_shipping_method = ".(!empty($this->shipping_method_id) ? "'".$this->db->escape((string) $this->shipping_method_id)."'" : "null"); $sql .= ",client = ".(!empty($this->client) ? $this->client : 0); $sql .= ",fournisseur = ".(!empty($this->fournisseur) ? $this->fournisseur : 0); @@ -1768,7 +1768,7 @@ class Societe extends CommonObject dol_syslog(get_class($this)."::update update linked member"); $lmember = new Adherent($this->db); - $result = $lmember->fetch(0, 0, $this->id); + $result = $lmember->fetch(0, '0', $this->id); if ($result > 0) { $lmember->company = $this->name; @@ -2469,7 +2469,7 @@ class Societe extends CommonObject // Position current discount $sql = "UPDATE ".MAIN_DB_PREFIX."societe "; - $sql .= " SET remise_client = '".$this->db->escape($remise)."'"; + $sql .= " SET remise_client = '".$this->db->escape((string) $remise)."'"; $sql .= " WHERE rowid = ".((int) $this->id); $resql = $this->db->query($sql); if (!$resql) { @@ -2481,7 +2481,7 @@ class Societe extends CommonObject // Writes trace in discount history $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise"; $sql .= " (entity, datec, fk_soc, remise_client, note, fk_user_author)"; - $sql .= " VALUES (".((int) $conf->entity).", '".$this->db->idate($now)."', ".((int) $this->id).", '".$this->db->escape($remise)."',"; + $sql .= " VALUES (".((int) $conf->entity).", '".$this->db->idate($now)."', ".((int) $this->id).", '".$this->db->escape((string) $remise)."',"; $sql .= " '".$this->db->escape($note)."',"; $sql .= " ".((int) $user->id); $sql .= ")"; @@ -2627,7 +2627,7 @@ class Societe extends CommonObject $discount->multicurrency_amount_ht = price2num($remise * (float) $discount->multicurrency_tx, 'MT'); $discount->multicurrency_amount_tva = price2num(((float) $remise * (float) $vatrate / 100) * (float) $discount->multicurrency_tx, 'MT'); - $discount->multicurrency_amount_ttc= price2num(((float) $discount->amount_ht + (float) $discount->amount_tva) * (float) $discount->multicurrency_tx, 'MT'); + $discount->multicurrency_amount_ttc = price2num(((float) $discount->amount_ht + (float) $discount->amount_tva) * (float) $discount->multicurrency_tx, 'MT'); } $discount->tva_tx = (float) price2num($vatrate); @@ -2692,13 +2692,15 @@ class Societe extends CommonObject if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) { $sql .= " WHERE u.rowid IN (SELECT ug.fk_user FROM ".$this->db->prefix()."usergroup_user as ug WHERE ug.entity IN (".getEntity('usergroup')."))"; } else { - $sql .= " WHERE entity IN (0, ".$this->db->sanitize($conf->entity).")"; + $sql .= " WHERE entity IN (0, ".$this->db->sanitize((string) $conf->entity).")"; } $sql .= " AND u.rowid = sc.fk_user AND sc.fk_soc = ".((int) $this->id); - if (empty($sortfield) && empty($sortorder)) { + if (empty($sortfield)) { $sortfield = 'u.lastname,u.firstname'; - $sortorder = 'ASC,ASC'; + } + if (empty($sortorder)) { + $sortorder = str_repeat('ASC,', count(explode(',', $sortfield)) - 1) . 'ASC'; } $sql .= $this->db->order($sortfield, $sortorder); @@ -3161,7 +3163,7 @@ class Societe extends CommonObject $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (' class="'.(($withpicto != 2) ? 'paddingright' : '').'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { - $result .= dol_escape_htmltag($maxlen ? dol_trunc($name, $maxlen) : $name); + $result .= dol_escape_htmltag($maxlen ? dol_trunc((string) $name, $maxlen) : $name); } $result .= $linkend; @@ -3512,7 +3514,7 @@ class Societe extends CommonObject require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; $prelevement = new BonPrelevement($this->db); $bac->fetch_thirdparty(); - $bac->rum = $prelevement->buildRumNumber($bac->thirdparty->code_client, $bac->datec, $bac->id); + $bac->rum = $prelevement->buildRumNumber($bac->thirdparty->code_client, $bac->datec, (string) $bac->id); } return $bac->rum; } elseif ($mode == 'format') { @@ -4969,7 +4971,7 @@ class Societe extends CommonObject /** * Return amount of order not yet paid and total and list of all orders * - * @param 'customer'|'supplier' $mode 'customer' or 'supplier' + * @param 'customer'|'supplier'|'' $mode 'customer' or 'supplier' * @return array{opened:float,total_ht:float,total_ttc:float}|array{} array('opened'=>Amount including tax that remains to pay, 'total_ht'=>Total amount without tax of all objects paid or not, 'total_ttc'=>Total amount including tax of all object paid or not) */ public function getOutstandingOrders($mode = 'customer') @@ -5012,7 +5014,7 @@ class Societe extends CommonObject /** * Return amount of bill not yet paid and total of all invoices * - * @param 'customer'|'supplier' $mode 'customer' or 'supplier' + * @param 'customer'|'supplier'|'' $mode 'customer' or 'supplier' * @param int<0,1> $late 0 => all invoice, 1=> only late * @return array{opened:float,total_ht:float,total_ttc:float}|array{} array('opened'=>Amount including tax that remains to pay, 'total_ht'=>Total amount without tax of all objects paid or not, 'total_ttc'=>Total amount including tax of all object paid or not) */ diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index a84b221ab06..e3570e90aa1 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -244,6 +244,9 @@ print ''; $sql_select = ''; $documentstaticline = ''; +$tables_from = ''; +$dateprint = ''; +$doc_number = ''; /*if ($type_element == 'action') { // Customer : show products from invoices require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; @@ -254,6 +257,7 @@ $documentstaticline = ''; $dateprint = 'f.datep'; $doc_number='f.id'; }*/ +$documentstatic = null; if ($type_element == 'fichinter') { // Customer : show products from invoices require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; $documentstatic = new Fichinter($db); @@ -382,6 +386,7 @@ if ($type_element == 'contract') { // Order } $parameters = array(); +$totalnboflines = 0; $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook if (!empty($sql_select)) { @@ -453,6 +458,7 @@ $total_qty = 0; $total_ht = 0; $param = ''; +$num = 0; if ($sql_select) { $resql = $db->query($sql); @@ -496,8 +502,8 @@ if ($sql_select) { print ''; print ''; print ''; // date - print $formother->select_month($month ? $month : -1, 'month', 1, 0, 'valignmiddle'); - print $formother->selectyear($year ? $year : -1, 'year', 1, 20, 1, 0, 0, '', 'valignmiddle maxwidth75imp marginleftonly'); + print $formother->select_month($month ? (string) $month : '-1', 'month', 1, 0, 'valignmiddle'); + print $formother->selectyear($year ? (string) $year : '-1', 'year', 1, 20, 1, 0, 0, '', 'valignmiddle maxwidth75imp marginleftonly'); print ''; // delivery planned date if ($type_element == 'order' || $type_element == 'supplier_order' || $type_element == 'shipment') { @@ -565,6 +571,8 @@ if ($sql_select) { print ''; if ($type_element == 'contract') { print $documentstaticline->getLibStatut(5); + } elseif ($documentstatic == null) { + // Do noting - for static analysis } elseif ($type_element == 'invoice') { // @phan-suppress-next-line PhanParamTooMany print $documentstatic->getLibStatut(5, $objp->paid); @@ -670,7 +678,7 @@ if ($sql_select) { } } else { if ($objp->fk_product > 0) { - echo $form->textwithtooltip($text, $description, 3, '', '', $i, 0, ''); + echo $form->textwithtooltip($text, $description, 3, 0, '', (string) $i, 0, ''); // Show range echo get_date_range($objp->date_start, $objp->date_end); @@ -689,7 +697,7 @@ if ($sql_select) { if (!empty($objp->label)) { $text .= ' '.$objp->label.''; - echo $form->textwithtooltip($text, dol_htmlentitiesbr($objp->description), 3, '', '', $i, 0, ''); + echo $form->textwithtooltip($text, dol_htmlentitiesbr($objp->description), 3, 0, '', (string) $i, 0, ''); } else { echo $text.' '.dol_htmlentitiesbr($objp->description); } @@ -755,7 +763,7 @@ if ($sql_select) { } $db->free($resql); } elseif (empty($type_element) || $type_element == -1) { - print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', (!empty($num) ? $num : 0), '', ''); + print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); print ''."\n"; // Titles with sort buttons diff --git a/htdocs/societe/contact.php b/htdocs/societe/contact.php index 990c6730061..98e814ea288 100644 --- a/htdocs/societe/contact.php +++ b/htdocs/societe/contact.php @@ -11,7 +11,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -146,8 +146,8 @@ if (empty($reshook)) { } if ($action == 'confirm_delete' && $user->hasRight('societe', 'contact', 'delete')) { - $id = GETPOST('id', 'int'); - if (!empty($id) && $socid > 0) { + $id = GETPOSTINT('id'); + if ($id > 0 && $socid > 0) { $contact = new Contact($db); $ret = $contact->fetch($id); if ($ret > 0) { diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 449a7b02a9b..1bb811ceb8e 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -208,6 +208,7 @@ if ($type == 't') { $contextpage = 'poslist'; } if ($search_type == '') { + // TODO: This case does not seem to be handled by FormCompany::selectProspectCustomerType. $search_type = '1,2,3'; } } @@ -268,78 +269,77 @@ if (getDolGlobalString('THIRDPARTY_QUICKSEARCH_ON_FIELDS')) { // Define list of fields to show into list -$checkedcustomercode = (in_array($contextpage, array('thirdpartylist', 'customerlist', 'prospectlist', 'poslist')) ? 1 : 0); -$checkedsuppliercode = (in_array($contextpage, array('supplierlist')) ? 1 : 0); -$checkedcustomeraccountcode = (in_array($contextpage, array('customerlist')) ? 1 : 0); -$checkedsupplieraccountcode = (in_array($contextpage, array('supplierlist')) ? 1 : 0); -$checkedtypetiers = 1; -$checkedprofid1 = 0; -$checkedprofid2 = 0; -$checkedprofid3 = 0; -$checkedprofid4 = 0; -$checkedprofid5 = 0; -$checkedprofid6 = 0; -//$checkedprofid4=((($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') ? 1 : 0); -//$checkedprofid5=((($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') ? 1 : 0); -//$checkedprofid6=((($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') ? 1 : 0); -$checkprospectlevel = (in_array($contextpage, array('prospectlist')) ? 1 : 0); -$checkstcomm = (in_array($contextpage, array('prospectlist')) ? 1 : 0); +$checkedcustomercode = (in_array($contextpage, array('thirdpartylist', 'customerlist', 'prospectlist', 'poslist')) ? '1' : '0'); +$checkedsuppliercode = (in_array($contextpage, array('supplierlist')) ? '1' : '0'); +$checkedcustomeraccountcode = (in_array($contextpage, array('customerlist')) ? '1' : '0'); +$checkedsupplieraccountcode = (in_array($contextpage, array('supplierlist')) ? '1' : '0'); +$checkedtypetiers = '1'; +$checkedprofid1 = '0'; +$checkedprofid2 = '0'; +$checkedprofid3 = '0'; +$checkedprofid4 = '0'; +$checkedprofid5 = '0'; +$checkedprofid6 = '0'; +//$checkedprofid4=((($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') ? '1' : '0'); +//$checkedprofid5=((($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') ? '1' : '0'); +//$checkedprofid6=((($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') ? '1' : '0'); +$checkprospectlevel = (in_array($contextpage, array('prospectlist')) ? '1' : '0'); +$checkstcomm = (in_array($contextpage, array('prospectlist')) ? '1' : '0'); $arrayfields = array( - 's.rowid' => array('label' => "TechnicalID", 'position' => 1, 'checked' => -1, 'enabled' => 1), - 's.nom' => array('label' => "ThirdPartyName", 'position' => 2, 'checked' => 1), - 's.name_alias' => array('label' => "AliasNameShort", 'position' => 3, 'checked' => 1), - 's.ref_ext' => array('label' => "RefExt", 'position' => 4, 'checked' => -1, 'enabled' => getDolGlobalInt('MAIN_LIST_SHOW_REF_EXT')), - 's.barcode' => array('label' => "Gencod", 'position' => 5, 'checked' => 1, 'enabled' => isModEnabled('barcode')), + 's.rowid' => array('label' => "TechnicalID", 'position' => 1, 'checked' => '-1', 'enabled' => '1'), + 's.nom' => array('label' => "ThirdPartyName", 'position' => 2, 'checked' => '1'), + 's.name_alias' => array('label' => "AliasNameShort", 'position' => 3, 'checked' => '1'), + 's.ref_ext' => array('label' => "RefExt", 'position' => 4, 'checked' => '-1', 'enabled' => (string) getDolGlobalInt('MAIN_LIST_SHOW_REF_EXT')), + 's.barcode' => array('label' => "Gencod", 'position' => 5, 'checked' => '1', 'enabled' => (string) (int) isModEnabled('barcode')), 's.code_client' => array('label' => "CustomerCodeShort", 'position' => 10, 'checked' => $checkedcustomercode), - 's.code_fournisseur' => array('label' => "SupplierCodeShort", 'position' => 11, 'checked' => $checkedsuppliercode, 'enabled' => (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), + 's.code_fournisseur' => array('label' => "SupplierCodeShort", 'position' => 11, 'checked' => $checkedsuppliercode, 'enabled' => (string) (int) (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), 's.code_compta' => array('label' => "CustomerAccountancyCodeShort", 'position' => 13, 'checked' => $checkedcustomeraccountcode), - 's.code_compta_fournisseur' => array('label' => "SupplierAccountancyCodeShort", 'position' => 14, 'checked' => $checkedsupplieraccountcode, 'enabled' => (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), - 's.address' => array('label' => "Address", 'position' => 19, 'checked' => 0), - 's.zip' => array('label' => "Zip", 'position' => 20, 'checked' => 1), - 's.town' => array('label' => "Town", 'position' => 21, 'checked' => 0), - 'state.nom' => array('label' => "State", 'position' => 22, 'checked' => 0), - 'region.nom' => array('label' => "Region", 'position' => 23, 'checked' => 0), - 'country.code_iso' => array('label' => "Country", 'position' => 24, 'checked' => 0), - 's.email' => array('label' => "Email", 'position' => 25, 'checked' => 0), - 's.url' => array('label' => "Url", 'position' => 26, 'checked' => 0), - 's.phone' => array('label' => "Phone", 'position' => 27, 'checked' => 1), - 's.fax' => array('label' => "Fax", 'position' => 28, 'checked' => 0), + 's.code_compta_fournisseur' => array('label' => "SupplierAccountancyCodeShort", 'position' => 14, 'checked' => $checkedsupplieraccountcode, 'enabled' => (string) (int) (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), + 's.address' => array('label' => "Address", 'position' => 19, 'checked' => '0'), + 's.zip' => array('label' => "Zip", 'position' => 20, 'checked' => '1'), + 's.town' => array('label' => "Town", 'position' => 21, 'checked' => '0'), + 'state.nom' => array('label' => "State", 'position' => 22, 'checked' => '0'), + 'region.nom' => array('label' => "Region", 'position' => 23, 'checked' => '0'), + 'country.code_iso' => array('label' => "Country", 'position' => 24, 'checked' => '0'), + 's.email' => array('label' => "Email", 'position' => 25, 'checked' => '0'), + 's.url' => array('label' => "Url", 'position' => 26, 'checked' => '0'), + 's.phone' => array('label' => "Phone", 'position' => 27, 'checked' => '1'), + 's.fax' => array('label' => "Fax", 'position' => 28, 'checked' => '0'), 'typent.code' => array('label' => "ThirdPartyType", 'position' => 29, 'checked' => $checkedtypetiers), - 'staff.code' => array('label' => "Workforce", 'position' => 31, 'checked' => 0), - 'legalform.code' => array('label' => 'JuridicalStatus', 'position' => 32, 'checked' => 0), - 's.phone_mobile' => array('label' => "PhoneMobile", 'position' => 35, 'checked' => 0), + 'staff.code' => array('label' => "Workforce", 'position' => 31, 'checked' => '0'), + 'legalform.code' => array('label' => 'JuridicalStatus', 'position' => 32, 'checked' => '0'), + 's.phone_mobile' => array('label' => "PhoneMobile", 'position' => 35, 'checked' => '0'), 's.siren' => array('label' => "ProfId1Short", 'position' => 40, 'checked' => $checkedprofid1), 's.siret' => array('label' => "ProfId2Short", 'position' => 41, 'checked' => $checkedprofid2), 's.ape' => array('label' => "ProfId3Short", 'position' => 42, 'checked' => $checkedprofid3), 's.idprof4' => array('label' => "ProfId4Short", 'position' => 43, 'checked' => $checkedprofid4), 's.idprof5' => array('label' => "ProfId5Short", 'position' => 44, 'checked' => $checkedprofid5), 's.idprof6' => array('label' => "ProfId6Short", 'position' => 45, 'checked' => $checkedprofid6), - 's.tva_intra' => array('label' => "VATIntraShort", 'position' => 50, 'checked' => 0), - 'customerorsupplier' => array('label' => 'NatureOfThirdParty', 'position' => 61, 'checked' => 1), + 's.tva_intra' => array('label' => "VATIntraShort", 'position' => 50, 'checked' => '0'), + 'customerorsupplier' => array('label' => 'NatureOfThirdParty', 'position' => 61, 'checked' => '1'), 's.fk_prospectlevel' => array('label' => "ProspectLevel", 'position' => 62, 'checked' => $checkprospectlevel), 's.fk_stcomm' => array('label' => "StatusProsp", 'position' => 63, 'checked' => $checkstcomm), - 's2.nom' => array('label' => 'ParentCompany', 'position' => 64, 'checked' => 0), - 's.ip' => array('type' => 'ip', 'label' => "IPAddress", 'checked' => -2, 'position' => 500), - 's.datec' => array('label' => "DateCreation", 'checked' => 0, 'position' => 501), - 's.tms' => array('label' => "DateModificationShort", 'checked' => 0, 'position' => 505), - 's.note_public' => array('label' => 'NotePublic', 'checked' => 0, 'position' => 520, 'enabled' => (!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES'))), - 's.note_private' => array('label' => 'NotePrivate', 'checked' => 0, 'position' => 521, 'enabled' => (!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES'))), - 's.status' => array('label' => "Status", 'checked' => 1, 'position' => 1000), - 's.import_key' => array('label' => "ImportId", 'checked' => 0, 'position' => 1100), + 's2.nom' => array('label' => 'ParentCompany', 'position' => 64, 'checked' => '0'), + 's.ip' => array('type' => 'ip', 'label' => "IPAddress", 'checked' => '-2', 'position' => 500), + 's.datec' => array('label' => "DateCreation", 'checked' => '0', 'position' => 501), + 's.tms' => array('label' => "DateModificationShort", 'checked' => '0', 'position' => 505), + 's.note_public' => array('label' => 'NotePublic', 'checked' => '0', 'position' => 520, 'enabled' => (string) (int) (!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES'))), + 's.note_private' => array('label' => 'NotePrivate', 'checked' => '0', 'position' => 521, 'enabled' => (string) (int) (!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES'))), + 's.status' => array('label' => "Status", 'checked' => '1', 'position' => 1000), + 's.import_key' => array('label' => "ImportId", 'checked' => '0', 'position' => 1100), ); if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) { - $arrayfields['s.price_level'] = array('label' => "PriceLevel", 'position' => 30, 'checked' => 0); + $arrayfields['s.price_level'] = array('label' => "PriceLevel", 'position' => 30, 'checked' => '0'); } // Add non object fields to fields for list -$arrayfields['sales.representative'] = array('label' => $langs->trans("SalesRepresentatives"), 'checked' => 1, 'position' => 12); +$arrayfields['sales.representative'] = array('label' => $langs->trans("SalesRepresentatives"), 'checked' => '1', 'position' => 12); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan // Security check $socid = GETPOSTINT('socid'); @@ -490,7 +490,7 @@ if (empty($reshook)) { if (!$error && $action == 'setstcomm' && $permissiontoadd) { $object = new Client($db); - $result = $object->fetch(GETPOST('stcommsocid')); + $result = $object->fetch(GETPOSTINT('stcommsocid')); $object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcomm'); $result = $object->update($object->id, $user); if ($result < 0) { @@ -1189,6 +1189,8 @@ if ($contextpage == 'poslist' && $type == 't' && (getDolGlobalString('PRODUIT_MU print get_htmloutput_mesg(img_warning('default').' '.$langs->trans("BecarefullChangeThirdpartyBeforeAddProductToInvoice"), [], 'warning', 1); } +$newcardbutton = ''; + // Show the new button only when this page is not opened from the Extended POS (pop-up window) // but allow it too, when a user has the rights to create a new customer if ($contextpage != 'poslist') { @@ -1196,7 +1198,6 @@ if ($contextpage != 'poslist') { if (!empty($socid)) { $url .= '&socid='.$socid; } - $newcardbutton = ''; $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition')); $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition')); $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url, '', $user->hasRight('societe', 'creer')); @@ -1291,7 +1292,7 @@ if (empty($type) || $type == 'f') { } // If the user can view prospects other than his' -$userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, 'u.statut:=:1', 0, '', '', 0, 1); +$userlist = $form->select_dolusers('', '', 0, null, 0, '', '', '0', 0, 0, 'u.statut:=:1', 0, '', '', 0, 1); $userlist[-2] = $langs->trans("NoSalesRepresentativeAffected"); if ($user->hasRight("societe", "client", "voir") || $socid) { $moreforfilter .= '
'; @@ -2064,9 +2065,7 @@ while ($i < $imaxinloop) { } // Type ent if (!empty($arrayfields['typent.code']['checked'])) { - if (!isset($typenArray) || !is_array($typenArray) || count($typenArray) == 0) { - $typenArray = $formcompany->typent_array(1); - } + $typenArray = $formcompany->typent_array(1); $labeltypeofcompany = empty($typenArray[$obj->typent_code]) ? '' : $typenArray[$obj->typent_code]; print '
'; @@ -2348,7 +2347,7 @@ print '
'."\n"; print '
'."\n"; // Line that calls the select_status function by passing it js as the 5th parameter in order to activate the js script -$formcompany->selectProspectStatus('status_prospect', $prospectstatic, null, null, "js"); +$formcompany->selectProspectStatus('status_prospect', $prospectstatic, 0, 0, "js"); print ''."\n"; diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index acf931e6d84..c8d00a1559f 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -8,7 +8,7 @@ * Copyright (C) 2017 Ferran Marcet * Copyright (C) 2018-2023 Thibault FOUCART * Copyright (C) 2021 Alexandre Spangaro - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -201,7 +201,7 @@ if (empty($reshook)) { $companybankaccount->rum = GETPOST('rum', 'alpha'); $companybankaccount->date_rum = GETPOSTDATE('date_rum', '00:00:00'); if (empty($companybankaccount->rum)) { - $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id); + $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, (string) $companybankaccount->id); } if (GETPOST('stripe_card_ref', 'alpha') && GETPOST('stripe_card_ref', 'alpha') != $companypaymentmode->stripe_card_ref) { @@ -370,7 +370,7 @@ if (empty($reshook)) { } if (empty($companybankaccount->rum)) { - $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id); + $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, (string) $companybankaccount->id); } } @@ -581,7 +581,7 @@ if (empty($reshook)) { } } } - if ($action == 'synccardtostripe' && $permissiontoaddupdatepaymentinformation) { + if ($action == 'synccardtostripe' && $permissiontoaddupdatepaymentinformation && $stripeacc !== null) { // Create the credit card on current Stripe env $companypaymentmode = new CompanyPaymentMode($db); $companypaymentmode->fetch($id); @@ -598,6 +598,7 @@ if (empty($reshook)) { } if (!$error) { + '@phan-var-force \Stripe\Customer $cu'; // Creation of Stripe card + update of llx_societe_rib // Note that with the new Stripe API, option to create a card is no more available, instead an error message will be returned to // ask to create the crdit card from Stripe backoffice. @@ -609,7 +610,7 @@ if (empty($reshook)) { } } } - if ($action == 'syncsepatostripe' && $permissiontoaddupdatepaymentinformation) { + if ($action == 'syncsepatostripe' && $permissiontoaddupdatepaymentinformation && $stripeacc !== null) { // Create the bank account on current Stripe env $companypaymentmode = new CompanyPaymentMode($db); // Get record in llx_societe_rib $companypaymentmode->fetch($id); @@ -628,6 +629,7 @@ if (empty($reshook)) { setEventMessages($langs->trans("ErrorStripeCustomerNotFoundCreateFirst"), null, 'errors'); } if (!$error) { + '@phan-var-force \Stripe\Customer $cu'; // Creation of Stripe SEPA + update of llx_societe_rib $card = $stripe->sepaStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1); if (!$card) { @@ -791,7 +793,7 @@ if (empty($reshook)) { $error++; setEventMessages($e->getMessage(), null, 'errors'); } - } elseif ($action == 'setassourcedefault' && $permissiontoaddupdatepaymentinformation) { // Set as default when payment mode defined remotely only + } elseif ($action == 'setassourcedefault' && $permissiontoaddupdatepaymentinformation && $stripeacc !== null) { // Set as default when payment mode defined remotely only try { $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); if (preg_match('/pm_|src_/', $source)) { @@ -809,7 +811,7 @@ if (empty($reshook)) { $error++; setEventMessages($e->getMessage(), null, 'errors'); } - } elseif ($action == 'deletecard' && $source && $permissiontoaddupdatepaymentinformation) { + } elseif ($action == 'deletecard' && $source && $permissiontoaddupdatepaymentinformation && $stripeacc !== null) { // Delete the credit card on Stripe side try { if (preg_match('/pm_/', $source)) { @@ -842,7 +844,7 @@ if (empty($reshook)) { $error++; setEventMessages($e->getMessage(), null, 'errors'); } - } elseif ($action == 'deletebank' && $source && $permissiontoaddupdatepaymentinformation) { + } elseif ($action == 'deletebank' && $source && $permissiontoaddupdatepaymentinformation && $stripeacc !== null) { // Delete the bank account on Stripe side try { if (preg_match('/pm_/', $source)) { @@ -852,7 +854,7 @@ if (empty($reshook)) { } } else { $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); - $card = $cu->sources->retrieve("$source"); + $card = $cu->sources->retrieve((string) $source); if ($card) { // $card->detach(); Does not work with card_, only with src_ if (method_exists($card, 'detach')) { @@ -1017,12 +1019,12 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $tmpservice = 0; $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice]['publishable_key']; - $tmpstripeacc = $stripe->getStripeAccount($tmpservice); // Get Stripe OAuth connect account (no remote access to Stripe here) + $tmpstripeacc = $stripe->getStripeAccount((string) $tmpservice); // Get Stripe OAuth connect account (no remote access to Stripe here) $tmpstripecu = $stripe->getStripeCustomerAccount($object->id, $tmpservice, $tmpsite_account); // Get remote Stripe customer 'cus_...' (no remote access to Stripe here) // Stripe customer key 'cu_....' stored into llx_societe_account print ''; - print $form->editfieldkey($langs->trans("StripeCustomerId").' (Test)', 'key_accounttest', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid'); + print $form->editfieldkey($langs->trans("StripeCustomerId").' (Test)', 'key_accounttest', $tmpstripecu, $object, (int) $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid'); print ''; print $form->editfieldval($langs->trans("StripeCustomerId").' (Test)', 'key_accounttest', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', null, null, '', 2, '', 'socid'); if ($tmpstripecu && $action != 'editkey_accounttest') { @@ -1047,12 +1049,12 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $tmpservice = 1; $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice]['publishable_key']; - $tmpstripeacc = $stripe->getStripeAccount($tmpservice); // Get Stripe OAuth connect account (no remote access to Stripe here) + $tmpstripeacc = $stripe->getStripeAccount((string) $tmpservice); // Get Stripe OAuth connect account (no remote access to Stripe here) $tmpstripecu = $stripe->getStripeCustomerAccount($object->id, $tmpservice, $tmpsite_account); // Get remote Stripe customer 'cus_...' (no remote access to Stripe here) // Stripe customer key 'cu_....' stored into llx_societe_account print ''; - print $form->editfieldkey($langs->trans("StripeCustomerId").' (Live)', 'key_account', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid'); + print $form->editfieldkey($langs->trans("StripeCustomerId").' (Live)', 'key_account', $tmpstripecu, $object, (int) $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid'); print ''; print $form->editfieldval($langs->trans("StripeCustomerId").' (Live)', 'key_account', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', null, null, '', 2, '', 'socid'); if ($tmpstripecu && $action != 'editkey_account') { @@ -1109,12 +1111,12 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' } // Stripe connect - if (isModEnabled('stripe') && !empty($conf->stripeconnect->enabled) && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { + if (isModEnabled('stripe') && !empty($conf->stripeconnect->enabled) && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2 && $service !== null) { $stripesupplieracc = $stripe->getStripeAccount($service, $object->id); // Get Stripe OAuth connect account (no network access here) // Stripe customer key 'cu_....' stored into llx_societe_account print ''; - print $form->editfieldkey("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid'); + print $form->editfieldkey("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, (int) $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid'); print ''; print $form->editfieldval("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation, 'string', '', null, null, '', 2, '', 'socid'); if (isModEnabled('stripe') && $stripesupplieracc && $action != 'editkey_account_supplier') { @@ -1132,7 +1134,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print ''; print ''; print ''; - print ''; + print ''; //print ''; print ''; } @@ -1155,7 +1157,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $listofsources = array(); $customerstripe = null; - if (isset($stripe) && is_object($stripe)) { + if (isset($stripe) && is_object($stripe) && $stripeacc !== null) { try { $customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus); if (!empty($customerstripe->id)) { @@ -1545,8 +1547,8 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' } if (is_array($currencybalance)) { - foreach ($currencybalance as $cpt) { - print ''.$langs->trans("Currency".strtoupper($cpt['currency'])).''.price($cpt['available'], 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price(isset($cpt->pending) ? $cpt->pending : 0, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt['available'] + (isset($cpt->pending) ? $cpt->pending : 0), 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''; + foreach ($currencybalance as $cpt_arr) { + print ''.$langs->trans("Currency".strtoupper($cpt_arr['currency'])).''.price($cpt_arr['available'], 0, '', 1, - 1, - 1, strtoupper($cpt_arr['currency'])).''.price(isset($cpt_arr['pending']) ? $cpt_arr['pending'] : 0, 0, '', 1, - 1, - 1, strtoupper($cpt_arr['currency'])).''.price($cpt_arr['available'] + (isset($cpt_arr['pending']) ? $cpt_arr['pending'] : 0), 0, '', 1, - 1, - 1, strtoupper($cpt_arr['currency'])).''; } } @@ -1882,6 +1884,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' } // Fields from hook + // TODO: No longer in foreach -> using last rib of for each which may be undeclared! $parameters = array('arrayfields' => array(), 'stripe_card_ref' => $rib->stripe_card_ref, 'stripe_account' => $rib->stripe_account, 'linetype' => 'stripebanremoteonly'); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -1932,7 +1935,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $filedir = $conf->societe->multidir_output[$object->entity].'/'.$object->id; $urlsource = $_SERVER["PHP_SELF"]."?socid=".$object->id; - print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $permissiontoread, $permissiontoaddupdatepaymentinformation, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); + print $formfile->showdocuments('company', (string) $object->id, $filedir, $urlsource, $permissiontoread, (int) $permissiontoaddupdatepaymentinformation, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, '', '', $object->default_lang); // Show direct download link if (getDolGlobalString('BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD')) { @@ -2082,7 +2085,7 @@ if ($socid && $action == 'edit' && $permissiontoaddupdatepaymentinformation) { print ''; if (empty($companybankaccount->rum)) { - $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id); + $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, (string) $companybankaccount->id); } // RUM @@ -2140,8 +2143,8 @@ if ($socid && $action == 'editcard' && $permissiontoaddupdatepaymentinformation) print ''; print ''; print ''; @@ -2317,8 +2320,8 @@ if ($socid && $action == 'createcard' && $permissiontoaddupdatepaymentinformatio print ''; print ''; print ''; diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index e06605e8a66..1e89a156e66 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -106,7 +106,7 @@ if (empty($reshook)) { } if (!$error) { - $update_child_soc = GETPOST('updatechildprice'); + $update_child_soc = GETPOSTINT('updatechildprice'); // add price by customer $prodcustprice->fk_soc = $socid; @@ -204,7 +204,7 @@ if (empty($reshook)) { if ($action == 'update_customer_price_confirm' && !$cancel && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { $prodcustprice->fetch(GETPOSTINT('lineid')); - $update_child_soc = GETPOST('updatechildprice'); + $update_child_soc = GETPOSTINT('updatechildprice'); // update price by customer $prodcustprice->ref_customer = GETPOST('ref_customer', 'alpha'); @@ -329,25 +329,25 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT $sortfield = "soc.nom"; } - // Build filter to display only concerned lines + // Build filter to display only related lines $filter = array( - 't.fk_soc' => $object->id + 't.fk_soc' => (string) $object->id ); if (!empty($search_prod)) { - $filter ['prod.ref'] = $search_prod; + $filter ['prod.ref'] = (string) $search_prod; } if (!empty($search_label)) { - $filter ['prod.label'] = $search_label; + $filter ['prod.label'] = (string) $search_label; } if (!empty($search_price)) { - $filter ['t.price'] = $search_price; + $filter ['t.price'] = (string) $search_price; } if (!empty($search_price_ttc)) { - $filter ['t.price_ttc'] = $search_price_ttc; + $filter ['t.price_ttc'] = (string) $search_price_ttc; } if ($action == 'add_customer_price') { @@ -368,7 +368,7 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT print ''; print ''; print ''; print ''; @@ -378,7 +378,7 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT // VAT print ''; // Price base @@ -471,7 +471,7 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT // VAT print ''; // Price base @@ -581,8 +581,8 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT print ''."\n"; $filter = array( - 't.fk_product' => GETPOSTINT('prodid'), - 't.fk_soc' => $socid + 't.fk_product' => (string) GETPOSTINT('prodid'), + 't.fk_soc' => (string) $socid ); // Count total nb of records diff --git a/htdocs/societe/tpl/linesalesrepresentative.tpl.php b/htdocs/societe/tpl/linesalesrepresentative.tpl.php index 66412a151cd..1da3c51d555 100644 --- a/htdocs/societe/tpl/linesalesrepresentative.tpl.php +++ b/htdocs/societe/tpl/linesalesrepresentative.tpl.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,14 +56,14 @@ if ($action == 'editsalesrepresentatives') { if (empty($arrayselected)) { $arrayselected = $object->getSalesRepresentatives($user, 1); } - print $form->multiselectarray('commercial', $userlist, $arrayselected, null, null, null, null, "90%"); + print $form->multiselectarray('commercial', $userlist, $arrayselected, 0, 0, '', 0, "90%"); print ''; print ''; } else { $listsalesrepresentatives = $object->getSalesRepresentatives($user); - $nbofsalesrepresentative = count($listsalesrepresentatives); - if ($nbofsalesrepresentative > 0 && is_array($listsalesrepresentatives)) { + $nbofsalesrepresentative = is_array($listsalesrepresentatives) ? count($listsalesrepresentatives) : 0; + if ($nbofsalesrepresentative > 0) { $userstatic = new User($db); foreach ($listsalesrepresentatives as $val) { $userstatic->id = $val['id']; diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index e245f49d91b..00a5624dc94 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -8,6 +8,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -272,10 +273,10 @@ foreach ($search as $key => $val) { $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key); if (preg_match('/^(date|timestamp|datetime)/', $objectwebsiteaccount->fields[$columnName]['type'])) { if (preg_match('/_dtstart$/', $key)) { - $sql .= " AND t.".$db->sanitize($columnName)." >= '".$db->idate($search[$key])."'"; + $sql .= " AND t.".$db->sanitize($columnName)." >= '".$db->idate((int) $search[$key])."'"; } if (preg_match('/_dtend$/', $key)) { - $sql .= " AND t.".$db->sanitize($columnName)." <= '".$db->idate($search[$key])."'"; + $sql .= " AND t.".$db->sanitize($columnName)." <= '".$db->idate((int) $search[$key])."'"; } } } @@ -547,7 +548,7 @@ foreach ($objectwebsiteaccount->fields as $key => $val) { } elseif ($key == 'lang') { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $formadmin = new FormAdmin($db); - print $formadmin->select_language((isset($search[$key]) ? $search[$key] : ''), 'search_lang', 0, null, 1, 0, 0, 'minwidth100imp maxwidth125', 2); + print $formadmin->select_language((isset($search[$key]) ? $search[$key] : ''), 'search_lang', 0, array(), 1, 0, 0, 'minwidth100imp maxwidth125', 2); } else { print ''; } @@ -682,7 +683,7 @@ while ($i < $imaxinloop) { if (!empty($arrayfields['t.'.$key]['checked'])) { print '$key)) { - print ' title="'.dol_escape_htmltag($object->$key).'"'; + print ' title="'.dol_escape_htmltag((string) $object->$key).'"'; } print '>'; if ($key == 'login') {
'.$langs->trans("ExpiryDate").''; - print $formother->select_month($companypaymentmode->exp_date_month, 'exp_date_month', 1); - print $formother->selectyear($companypaymentmode->exp_date_year, 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly'); + print $formother->select_month((string) $companypaymentmode->exp_date_month, 'exp_date_month', 1); + print $formother->selectyear((string) $companypaymentmode->exp_date_year, 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly'); print '
'.$langs->trans("CVN").'
'.$langs->trans("ExpiryDate").''; - print $formother->select_month(GETPOSTINT('exp_date_month'), 'exp_date_month', 1); - print $formother->selectyear(GETPOSTINT('exp_date_year'), 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly'); + print $formother->select_month((string) GETPOSTINT('exp_date_month'), 'exp_date_month', 1); + print $formother->selectyear((string) GETPOSTINT('exp_date_year'), 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly'); print '
'.$langs->trans("CVN").'
'.$langs->trans('Product').''; - $form->select_produits('', 'prodid', '', 0); + $form->select_produits(0, 'prodid', '', 0); print '
'.$langs->trans("VATRate").''; - print $form->load_tva("tva_tx", GETPOST("tva_tx", "alpha"), $mysoc, '', $object->id, 0, '', false, 1); + print $form->load_tva("tva_tx", GETPOST("tva_tx", "alpha"), $mysoc, null, $object->id, 0, '', false, 1); print '
'.$langs->trans("VATRate").''; - print $form->load_tva("tva_tx", $prodcustprice->tva_tx, $mysoc, '', $staticprod->id, $prodcustprice->recuperableonly); + print $form->load_tva("tva_tx", $prodcustprice->tva_tx, $mysoc, null, $staticprod->id, $prodcustprice->recuperableonly); print '