From e8c51e8802f88fa38907b9236659b6ba5f33b7ac Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 12 Nov 2024 00:32:59 +0100 Subject: [PATCH 01/19] Qual: fix ci phpstan by removing useless test (#31772) # Qual: fix phpstan by removing useless test !$error && $champdatefin && ($champdatefin > 0) has useless tests. - $error is still 0. - $champdatefin is also not 0 when it is >0 - By casting $champdatefin to int, we ensure that '' (error) is converted to 0. --- htdocs/opensurvey/wizard/create_survey.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/opensurvey/wizard/create_survey.php b/htdocs/opensurvey/wizard/create_survey.php index a498ab0cf67f2..6df9d1ec060b0 100644 --- a/htdocs/opensurvey/wizard/create_survey.php +++ b/htdocs/opensurvey/wizard/create_survey.php @@ -3,6 +3,7 @@ * Copyright (C) 2014 Marcos García * Copyright (C) 2015-2016 Alexandre Spangaro * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -90,9 +91,9 @@ } $testdate = false; - $champdatefin = dol_mktime(23, 59, 59, GETPOSTINT('champdatefinmonth'), GETPOSTINT('champdatefinday'), GETPOSTINT('champdatefinyear')); + $champdatefin = (int) dol_mktime(23, 59, 59, GETPOSTINT('champdatefinmonth'), GETPOSTINT('champdatefinday'), GETPOSTINT('champdatefinyear')); - if (! $error && $champdatefin && ($champdatefin > 0)) { // A date was provided + if ($champdatefin > 0) { // A date was provided, $error still 0 here // Expire date is not before today if ($champdatefin >= dol_now()) { $testdate = true; From cf0782d96d2f4e9202edd864e208bca31ae80f83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 12 Nov 2024 00:33:28 +0100 Subject: [PATCH 02/19] fix sql (#31769) --- htdocs/contrat/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 9c5798c4a3d87..be2f81dc20ff2 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -334,7 +334,7 @@ $sql .= " sum(".$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now - $conf->contrat->services->expires->warning_delay)."')", 1, 0).') as nb_late,'; $sql .= " sum(".$db->ifsql("cd.statut=5", 1, 0).') as nb_closed,'; $sql .= " c.rowid as cid, c.ref, c.datec, c.tms, c.statut,"; -$sql .= " s.nom as name, s.name_alias, s.logo, s.rowid as socid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; +$sql .= " s.nom as name, s.name_alias, s.logo, s.rowid as socid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,"; if (!$user->hasRight('societe', 'client', 'voir')) { $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,"; @@ -351,7 +351,7 @@ $sql .= " AND s.rowid = ".((int) $socid); } $sql .= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.statut,"; -$sql .= " s.nom, s.name_alias, s.logo, s.rowid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur"; +$sql .= " s.nom, s.name_alias, s.logo, s.rowid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; $sql .= " ORDER BY c.tms DESC"; $sql .= $db->plimit($max); From 56dc321665c172dd57f152db9d4624485a752151 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 12 Nov 2024 00:35:14 +0100 Subject: [PATCH 03/19] Qual: Fix phan notices (in order of appearance) (#31768) * Qual: Fix phan notices (in order of appearance) * Qual: Fix phan notices (in order of appearance)/2 --- build/phpstan/phpstan-baseline.neon | 105 ++---------------- dev/tools/phan/baseline.txt | 57 +++------- dev/tools/phan/config_extended.php | 2 +- htdocs/asset/admin/setup.php | 2 +- htdocs/asset/depreciation.php | 3 + htdocs/asset/disposal.php | 3 + htdocs/asset/list.php | 24 ++-- htdocs/asset/model/list.php | 4 +- htdocs/barcode/printsheet.php | 2 +- htdocs/blockedlog/ajax/block-info.php | 3 +- htdocs/bom/bom_list.php | 2 +- htdocs/bookcal/availabilities_list.php | 9 +- htdocs/bookcal/calendar_list.php | 9 +- htdocs/categories/viewcat.php | 2 +- htdocs/comm/action/card.php | 26 +++-- .../comm/action/class/cactioncomm.class.php | 2 +- htdocs/comm/action/document.php | 5 +- htdocs/comm/action/index.php | 2 + htdocs/comm/action/list.php | 4 +- htdocs/comm/mailing/cibles.php | 1 + htdocs/commande/list_det.php | 6 +- htdocs/compta/accounting-files.php | 28 ++--- htdocs/compta/bank/annuel.php | 4 +- htdocs/compta/bank/bankentries_list.php | 3 +- htdocs/compta/bank/card.php | 16 ++- htdocs/compta/bank/graph.php | 7 ++ htdocs/compta/bank/line.php | 4 +- htdocs/compta/bank/releve.php | 2 + htdocs/compta/bank/transfer.php | 4 +- htdocs/compta/bank/treso.php | 3 +- htdocs/compta/bank/various_payment/card.php | 12 +- .../modules/mailings/modules_mailings.php | 16 +++ 32 files changed, 160 insertions(+), 212 deletions(-) diff --git a/build/phpstan/phpstan-baseline.neon b/build/phpstan/phpstan-baseline.neon index 2252487db5785..48e5c9f8c08bf 100644 --- a/build/phpstan/phpstan-baseline.neon +++ b/build/phpstan/phpstan-baseline.neon @@ -2050,11 +2050,6 @@ parameters: count: 1 path: ../../htdocs/blockedlog/admin/blockedlog_list.php - - - message: "#^Parameter \\#1 \\$objtoshow of function formatObject expects object, array given\\.$#" - count: 1 - path: ../../htdocs/blockedlog/ajax/block-info.php - - message: "#^Dead catch \\- Exception is never thrown in the try block\\.$#" count: 1 @@ -2355,6 +2350,11 @@ parameters: count: 1 path: ../../htdocs/bookcal/availabilities_document.php + - + message: "#^Empty array passed to foreach\\.$#" + count: 1 + path: ../../htdocs/bookcal/availabilities_list.php + - message: "#^If condition is always false\\.$#" count: 1 @@ -2475,6 +2475,11 @@ parameters: count: 1 path: ../../htdocs/bookcal/calendar_document.php + - + message: "#^Empty array passed to foreach\\.$#" + count: 1 + path: ../../htdocs/bookcal/calendar_list.php + - message: "#^If condition is always false\\.$#" count: 1 @@ -3130,11 +3135,6 @@ parameters: count: 1 path: ../../htdocs/comm/mailing/cibles.php - - - message: "#^Variable \\$mesgs might not be defined\\.$#" - count: 1 - path: ../../htdocs/comm/mailing/cibles.php - - message: "#^Negated boolean expression is always true\\.$#" count: 2 @@ -3835,36 +3835,16 @@ parameters: count: 1 path: ../../htdocs/commande/list_det.php - - - message: "#^Variable \\$oldref might not be defined\\.$#" - count: 1 - path: ../../htdocs/commande/list_det.php - - message: "#^Variable \\$permissiontoadd might not be defined\\.$#" count: 1 path: ../../htdocs/commande/list_det.php - - - message: "#^Variable \\$permissiontoread might not be defined\\.$#" - count: 1 - path: ../../htdocs/commande/list_det.php - - message: "#^Variable \\$searchCategoryProductOperator might not be defined\\.$#" count: 3 path: ../../htdocs/commande/list_det.php - - - message: "#^Variable \\$search_product_category_array might not be defined\\.$#" - count: 2 - path: ../../htdocs/commande/list_det.php - - - - message: "#^Variable \\$text_icon might not be defined\\.$#" - count: 1 - path: ../../htdocs/commande/list_det.php - - message: "#^If condition is always false\\.$#" count: 1 @@ -3910,16 +3890,6 @@ parameters: count: 2 path: ../../htdocs/compta/bank/account_statement_document.php - - - message: "#^Variable \\$max might not be defined\\.$#" - count: 1 - path: ../../htdocs/compta/bank/annuel.php - - - - message: "#^Variable \\$min might not be defined\\.$#" - count: 1 - path: ../../htdocs/compta/bank/annuel.php - - message: "#^If condition is always false\\.$#" count: 2 @@ -3945,21 +3915,6 @@ parameters: count: 1 path: ../../htdocs/compta/bank/bankentries_list.php - - - message: "#^Variable \\$numr might not be defined\\.$#" - count: 1 - path: ../../htdocs/compta/bank/bankentries_list.php - - - - message: "#^Variable \\$css might not be defined\\.$#" - count: 1 - path: ../../htdocs/compta/bank/card.php - - - - message: "#^Variable \\$name might not be defined\\.$#" - count: 4 - path: ../../htdocs/compta/bank/card.php - - message: "#^Variable \\$noback in empty\\(\\) always exists and is always falsy\\.$#" count: 1 @@ -4080,36 +4035,6 @@ parameters: count: 3 path: ../../htdocs/compta/bank/graph.php - - - message: "#^Variable \\$morehtml might not be defined\\.$#" - count: 1 - path: ../../htdocs/compta/bank/graph.php - - - - message: "#^Variable \\$show1 might not be defined\\.$#" - count: 1 - path: ../../htdocs/compta/bank/graph.php - - - - message: "#^Variable \\$show2 might not be defined\\.$#" - count: 1 - path: ../../htdocs/compta/bank/graph.php - - - - message: "#^Variable \\$show3 might not be defined\\.$#" - count: 1 - path: ../../htdocs/compta/bank/graph.php - - - - message: "#^Variable \\$show4 might not be defined\\.$#" - count: 1 - path: ../../htdocs/compta/bank/graph.php - - - - message: "#^Variable \\$show5 might not be defined\\.$#" - count: 1 - path: ../../htdocs/compta/bank/graph.php - - message: "#^Right side of && is always true\\.$#" count: 2 @@ -4170,11 +4095,6 @@ parameters: count: 1 path: ../../htdocs/compta/bank/releve.php - - - message: "#^Variable \\$total might not be defined\\.$#" - count: 3 - path: ../../htdocs/compta/bank/releve.php - - message: "#^Negated boolean expression is always true\\.$#" count: 1 @@ -4215,11 +4135,6 @@ parameters: count: 1 path: ../../htdocs/compta/bank/various_payment/card.php - - - message: "#^Variable \\$formproject might not be defined\\.$#" - count: 1 - path: ../../htdocs/compta/bank/various_payment/card.php - - message: "#^Variable \\$ref might not be defined\\.$#" count: 1 diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index eec86c9aaf528..17ec6e02e8b60 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -10,11 +10,11 @@ return [ // # Issue statistics: // PhanUndeclaredProperty : 560+ occurrences - // PhanPossiblyUndeclaredGlobalVariable : 520+ occurrences - // PhanUndeclaredGlobalVariable : 350+ occurrences - // PhanTypeMismatchArgumentProbablyReal : 310+ occurrences + // PhanPossiblyUndeclaredGlobalVariable : 500+ occurrences + // PhanUndeclaredGlobalVariable : 340+ occurrences + // PhanTypeMismatchArgumentProbablyReal : 270+ occurrences // PhanPluginUnknownArrayMethodReturnType : 180+ occurrences - // PhanTypeMismatchProperty : 160+ occurrences + // PhanTypeMismatchProperty : 140+ occurrences // PhanPluginUnknownPropertyType : 130+ occurrences // PhanPluginUnknownArrayMethodParamType : 120+ occurrences // PhanPossiblyUndeclaredVariable : 110+ occurrences @@ -22,9 +22,9 @@ return [ // PhanRedefineFunction : 45+ occurrences // PhanTypeExpectedObjectPropAccess : 45+ occurrences // PhanTypeMismatchArgumentNullableInternal : 45+ occurrences - // PhanTypeMismatchDimFetch : 40+ occurrences - // PhanPluginEmptyStatementIf : 35+ occurrences // PhanTypeInvalidDimOffset : 35+ occurrences + // PhanPluginEmptyStatementIf : 30+ occurrences + // PhanTypeMismatchDimFetch : 30+ occurrences // PhanUndeclaredConstant : 15+ occurrences // PhanEmptyForeach : 10+ occurrences // PhanPluginUnknownObjectMethodCall : 10+ occurrences @@ -62,51 +62,34 @@ return [ 'htdocs/api/class/api_login.class.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/api/class/api_setup.class.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/api/class/api_status.class.php' => ['PhanPluginUnknownArrayMethodReturnType'], - 'htdocs/asset/admin/setup.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/asset/class/asset.class.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanTypeInvalidDimOffset'], 'htdocs/asset/class/assetdepreciationoptions.class.php' => ['PhanTypeInvalidDimOffset'], 'htdocs/asset/class/assetmodel.class.php' => ['PhanUndeclaredProperty'], - 'htdocs/asset/depreciation.php' => ['PhanPluginEmptyStatementIf'], - 'htdocs/asset/disposal.php' => ['PhanPluginEmptyStatementIf'], - 'htdocs/asset/list.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/asset/model/list.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/asset/tpl/accountancy_codes_edit.tpl.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/asset/tpl/depreciation_options_edit.tpl.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], 'htdocs/asset/tpl/linkedobjectblock.tpl.php' => ['PhanUndeclaredProperty'], 'htdocs/asterisk/wrapper.php' => ['PhanRedefineFunction'], - 'htdocs/barcode/printsheet.php' => ['PhanPluginDuplicateExpressionBinaryOp', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/blockedlog/ajax/block-info.php' => ['PhanTypeMismatchArgumentProbablyReal'], + 'htdocs/barcode/printsheet.php' => ['PhanPluginDuplicateExpressionBinaryOp'], 'htdocs/bom/bom_card.php' => ['PhanUndeclaredProperty'], - 'htdocs/bom/bom_list.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/bom/class/api_boms.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], 'htdocs/bom/tpl/objectline_edit.tpl.php' => ['PhanUndeclaredProperty'], 'htdocs/bom/tpl/objectline_view.tpl.php' => ['PhanUndeclaredProperty'], 'htdocs/bookcal/availabilities_card.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], - 'htdocs/bookcal/availabilities_list.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/bookcal/calendar_card.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], - 'htdocs/bookcal/calendar_list.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/bookcal/class/availabilities.class.php' => ['PhanUndeclaredMethod', 'PhanUndeclaredProperty'], 'htdocs/bookcal/class/calendar.class.php' => ['PhanUndeclaredMethod', 'PhanUndeclaredProperty'], 'htdocs/categories/class/api_categories.class.php' => ['PhanAccessMethodProtected', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], - 'htdocs/categories/class/categorie.class.php' => ['PhanTypeMismatchProperty'], - 'htdocs/categories/edit.php' => ['PhanTypeMismatchDimFetch'], - 'htdocs/categories/index.php' => ['PhanTypeMismatchDimFetch'], - 'htdocs/categories/info.php' => ['PhanTypeMismatchDimFetch'], - 'htdocs/categories/photos.php' => ['PhanTypeMismatchDimFetch'], - 'htdocs/categories/traduction.php' => ['PhanTypeMismatchDimFetch'], - 'htdocs/categories/viewcat.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch', 'PhanUndeclaredProperty'], + 'htdocs/categories/viewcat.php' => ['PhanUndeclaredProperty'], 'htdocs/collab/index.php' => ['PhanParamTooMany', 'PhanUndeclaredProperty'], - 'htdocs/comm/action/card.php' => ['PhanPluginBothLiteralsBinaryOp', 'PhanPluginEmptyStatementIf', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal'], + 'htdocs/comm/action/card.php' => ['PhanPluginBothLiteralsBinaryOp'], 'htdocs/comm/action/class/api_agendaevents.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchProperty'], 'htdocs/comm/action/class/cactioncomm.class.php' => ['PhanPluginUnknownArrayPropertyType'], - 'htdocs/comm/action/document.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/comm/action/index.php' => ['PhanPluginEmptyStatementIf', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty'], + 'htdocs/comm/action/index.php' => ['PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty'], 'htdocs/comm/action/info.php' => ['PhanUndeclaredProperty'], - 'htdocs/comm/action/list.php' => ['PhanTypeMismatchProperty'], 'htdocs/comm/action/pertype.php' => ['PhanTypeComparisonFromArray', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchDimFetch'], 'htdocs/comm/action/peruser.php' => ['PhanTypeComparisonFromArray'], 'htdocs/comm/mailing/card.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/comm/mailing/cibles.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'], + 'htdocs/comm/mailing/cibles.php' => ['PhanUndeclaredProperty'], 'htdocs/comm/mailing/index.php' => ['PhanUndeclaredProperty'], 'htdocs/comm/propal/card.php' => ['PhanTypeMismatchProperty'], 'htdocs/comm/propal/class/api_proposals.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], @@ -116,21 +99,13 @@ return [ 'htdocs/commande/class/commande.class.php' => ['PhanUndeclaredProperty'], 'htdocs/commande/customer.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/commande/list.php' => ['PhanUndeclaredProperty'], - 'htdocs/commande/list_det.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeInvalidDimOffset', 'PhanTypeMismatchArgumentProbablyReal'], + 'htdocs/commande/list_det.php' => ['PhanTypeInvalidDimOffset'], 'htdocs/commande/tpl/linkedobjectblock.tpl.php' => ['PhanUndeclaredProperty'], - 'htdocs/compta/accounting-files.php' => ['PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty'], 'htdocs/compta/bank/account_statement_document.php' => ['PhanUndeclaredGlobalVariable'], - 'htdocs/compta/bank/annuel.php' => ['PhanPossiblyUndeclaredGlobalVariable'], - 'htdocs/compta/bank/bankentries_list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/compta/bank/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/compta/bank/class/account.class.php' => ['PhanUndeclaredProperty'], 'htdocs/compta/bank/class/api_bankaccounts.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/compta/bank/graph.php' => ['PhanPossiblyUndeclaredGlobalVariable'], - 'htdocs/compta/bank/line.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'], - 'htdocs/compta/bank/releve.php' => ['PhanPossiblyUndeclaredGlobalVariable'], - 'htdocs/compta/bank/transfer.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/compta/bank/treso.php' => ['PhanTypeMismatchProperty'], - 'htdocs/compta/bank/various_payment/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], + 'htdocs/compta/bank/line.php' => ['PhanUndeclaredGlobalVariable'], + 'htdocs/compta/bank/various_payment/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/compta/bank/various_payment/document.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/compta/bank/various_payment/info.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/compta/bank/various_payment/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchProperty'], @@ -374,7 +349,6 @@ return [ 'htdocs/don/payment/card.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/don/payment/payment.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/don/tpl/linkedobjectblock.tpl.php' => ['PhanPossiblyUndeclaredGlobalVariable'], - 'htdocs/ecm/class/ecmdirectory.class.php' => ['PhanTypeMismatchProperty'], 'htdocs/ecm/dir_card.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/ecm/index.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/emailcollector/class/emailcollector.class.php' => ['PhanUndeclaredProperty'], @@ -404,7 +378,7 @@ return [ 'htdocs/expensereport/tpl/expensereport_linktofile.tpl.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/expensereport/tpl/linkedobjectblock.tpl.php' => ['PhanUndeclaredProperty'], 'htdocs/externalsite/frames.php' => ['PhanUndeclaredGlobalVariable'], - 'htdocs/fichinter/card-rec.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], + 'htdocs/fichinter/card-rec.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/fichinter/class/api_interventions.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanUndeclaredProperty'], 'htdocs/fichinter/class/fichinterrec.class.php' => ['PhanUndeclaredProperty'], 'htdocs/fichinter/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], @@ -637,7 +611,6 @@ return [ 'htdocs/supplier_proposal/class/api_supplier_proposals.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanUndeclaredProperty'], 'htdocs/supplier_proposal/class/supplier_proposal.class.php' => ['PhanUndeclaredProperty'], 'htdocs/supplier_proposal/list.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/takepos/admin/orderprinters.php' => ['PhanTypeMismatchDimFetch'], 'htdocs/takepos/ajax/ajax.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], 'htdocs/takepos/floors.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/takepos/freezone.php' => ['PhanTypeMismatchArgumentProbablyReal'], diff --git a/dev/tools/phan/config_extended.php b/dev/tools/phan/config_extended.php index 226ee55c444a2..0d0abaa19b8b2 100644 --- a/dev/tools/phan/config_extended.php +++ b/dev/tools/phan/config_extended.php @@ -67,7 +67,7 @@ 'PhanCompatibleNegativeStringOffset', // return false positive 'PhanPluginConstantVariableBool', // a lot of false positive, in most cases, we want to keep the code as it is // 'PhanPluginUnknownArrayPropertyType', // Helps find missing array keys or mismatches, remaining occurrences are likely unused properties - // 'PhanTypeArraySuspiciousNullable', // All fixed. + 'PhanTypeArraySuspiciousNullable', // About 400 cases // 'PhanTypeInvalidDimOffset', // Helps identify missing array indexes in types or reference to unset indexes 'PhanTypeObjectUnsetDeclaredProperty', 'PhanTypePossiblyInvalidDimOffset', // a lot of false positive, in most cases, we want to keep the code as it is diff --git a/htdocs/asset/admin/setup.php b/htdocs/asset/admin/setup.php index 42deaac7c71d2..963f783731406 100644 --- a/htdocs/asset/admin/setup.php +++ b/htdocs/asset/admin/setup.php @@ -542,7 +542,7 @@ if (isModEnabled('accounting')) { require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; $formaccounting = new FormAccounting($db); - print $formaccounting->select_account($selected, $constname, 1, null, 1, 1, 'minwidth150 maxwidth300', 1); + print $formaccounting->select_account($selected, $constname, 1, array(), 1, 1, 'minwidth150 maxwidth300', 1); } else { print ''; } diff --git a/htdocs/asset/depreciation.php b/htdocs/asset/depreciation.php index bc448c098e617..76e0aba71fe0b 100644 --- a/htdocs/asset/depreciation.php +++ b/htdocs/asset/depreciation.php @@ -96,8 +96,11 @@ if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } + +/* if (empty($reshook)) { } +*/ /* diff --git a/htdocs/asset/disposal.php b/htdocs/asset/disposal.php index fe6101d034f10..4d97ffc353bd0 100644 --- a/htdocs/asset/disposal.php +++ b/htdocs/asset/disposal.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007-2017 Laurent Destailleur * Copyright (C) 2018 Alexandre Spangaro * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -86,8 +87,10 @@ if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } +/* if (empty($reshook)) { } +*/ /* diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php index 55fc1683cc185..649f436b2e018 100644 --- a/htdocs/asset/list.php +++ b/htdocs/asset/list.php @@ -3,6 +3,7 @@ * Copyright (C) 2018-2024 Alexandre Spangaro * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -116,11 +117,11 @@ if (!empty($val['visible'])) { $visible = (int) dol_eval((string) $val['visible'], 1); $arrayfields['t.'.$key] = array( - 'label'=>$val['label'], - 'checked'=>(($visible < 0) ? 0 : 1), - 'enabled'=>(abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)), - 'position'=>$val['position'], - 'help'=> isset($val['help']) ? $val['help'] : '' + 'label' => $val['label'], + 'checked' => (($visible < 0) ? 0 : 1), + 'enabled' => (abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)), + 'position' => $val['position'], + 'help' => isset($val['help']) ? $val['help'] : '' ); } } @@ -143,7 +144,8 @@ if ($user->socid > 0) { accessforbidden(); } -$socid = 0; if ($user->socid > 0) { +$socid = 0; +if ($user->socid > 0) { $socid = $user->socid; } $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); @@ -498,7 +500,7 @@ } elseif ($key == 'lang') { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $formadmin = new FormAdmin($db); - print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth100imp maxwidth125', 2); + print $formadmin->select_language($search[$key], 'search_lang', 0, array(), 1, 0, 0, 'minwidth100imp maxwidth125', 2); } else { print ''; } @@ -509,7 +511,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters = array('arrayfields'=>$arrayfields); +$parameters = array('arrayfields' => $arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column @@ -541,7 +543,7 @@ // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column @@ -625,7 +627,7 @@ // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column @@ -664,7 +666,7 @@ $db->free($resql); -$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; diff --git a/htdocs/asset/model/list.php b/htdocs/asset/model/list.php index 13c8c77331089..762a5122d7550 100644 --- a/htdocs/asset/model/list.php +++ b/htdocs/asset/model/list.php @@ -495,7 +495,7 @@ print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1); } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { print '
'; - print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); print '
'; print '
'; print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); @@ -503,7 +503,7 @@ } elseif ($key == 'lang') { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $formadmin = new FormAdmin($db); - print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth100imp maxwidth125', 2); + print $formadmin->select_language($search[$key], 'search_lang', 0, array(), 1, 0, 0, 'minwidth100imp maxwidth125', 2); } else { print ''; } diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index 541ea6fc52e04..ba3c994fcf7ce 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -441,7 +441,7 @@ function init_gendoc_button() print ''; print '
'; print '
'; - $form->select_produits(GETPOSTINT('productid'), 'productid', '', '', 0, -1, 2, '', 0, array(), 0, '1', 0, 'minwidth400imp', 1); + $form->select_produits(GETPOSTINT('productid'), 'productid', '', 0, 0, -1, 2, '', 0, array(), 0, '1', 0, 'minwidth400imp', 1); print '   '; print '
'; } diff --git a/htdocs/blockedlog/ajax/block-info.php b/htdocs/blockedlog/ajax/block-info.php index 9f32aec003c33..31394eeb53594 100644 --- a/htdocs/blockedlog/ajax/block-info.php +++ b/htdocs/blockedlog/ajax/block-info.php @@ -2,6 +2,7 @@ /* Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2017 ATM Consulting * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -85,7 +86,7 @@ /** * formatObject * - * @param Object $objtoshow Object to show + * @param Object|array $objtoshow Object to show * @param string $prefix Prefix of key * @return string String formatted */ diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index 210a26bb9b128..a2936616224ba 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -596,7 +596,7 @@ } elseif ($key == 'lang') { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $formadmin = new FormAdmin($db); - print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth100imp maxwidth125', 2); + print $formadmin->select_language($search[$key], 'search_lang', 0, array(), 1, 0, 0, 'minwidth100imp maxwidth125', 2); } else { print ''; } diff --git a/htdocs/bookcal/availabilities_list.php b/htdocs/bookcal/availabilities_list.php index 8f80da1b2db20..f819fdf81bcda 100644 --- a/htdocs/bookcal/availabilities_list.php +++ b/htdocs/bookcal/availabilities_list.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007-2017 Laurent Destailleur * Copyright (C) 2022 Alice Adminson * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -105,7 +106,7 @@ } // List of fields to search into when doing a "search in all" -// $fieldstosearchall = array(); +$fieldstosearchall = array(); // foreach ($object->fields as $key => $val) { // if (!empty($val['searchall'])) { // $fieldstosearchall['t.'.$key] = $val['label']; @@ -120,10 +121,6 @@ // } -// $fieldstosearchall is supposedly defined further below, ensure that it is. -if (!isset($fieldstosearchall) || !is_array($fieldstosearchall)) { - $fieldstosearchall = array(); -} ' @phan-var-force array $fieldstosearchall '; @@ -566,7 +563,7 @@ } elseif ($key == 'lang') { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $formadmin = new FormAdmin($db); - print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth100imp maxwidth125', 2); + print $formadmin->select_language($search[$key], 'search_lang', 0, array(), 1, 0, 0, 'minwidth100imp maxwidth125', 2); } else { print ''; } diff --git a/htdocs/bookcal/calendar_list.php b/htdocs/bookcal/calendar_list.php index 54cccd94510e2..3aa7f6a2d893a 100644 --- a/htdocs/bookcal/calendar_list.php +++ b/htdocs/bookcal/calendar_list.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007-2017 Laurent Destailleur * Copyright (C) 2023 Alice Adminson * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -105,7 +106,7 @@ } // List of fields to search into when doing a "search in all" -// $fieldstosearchall = array(); +$fieldstosearchall = array(); // foreach ($object->fields as $key => $val) { // if (!empty($val['searchall'])) { // $fieldstosearchall['t.'.$key] = $val['label']; @@ -119,10 +120,6 @@ // $fieldstosearchall = array_merge($fieldstosearchall, empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall']); // } -// $fieldstosearchall is supposedly defined further below, ensure that it is. -if (!isset($fieldstosearchall) || !is_array($fieldstosearchall)) { - $fieldstosearchall = array(); -} ' @phan-var-force array $fieldstosearchall '; @@ -549,7 +546,7 @@ } elseif ($key == 'lang') { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $formadmin = new FormAdmin($db); - print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth100imp maxwidth125', 2); + print $formadmin->select_language($search[$key], 'search_lang', 0, array(), 1, 0, 0, 'minwidth100imp maxwidth125', 2); } else { print ''; } diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 3156ccf89b28e..99e8c805056d7 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -549,7 +549,7 @@ print ''; print ''; print ''; print '
'; print $langs->trans("AddProductServiceIntoCategory").'  '; - $form->select_produits('', 'elemid', '', 0, 0, -1, 2, '', 1, array(), 0, 1, 0, '', 0, '', null); + $form->select_produits(0, 'elemid', '', 0, 0, -1, 2, '', 1, array(), 0, 1, 0, '', 0, '', null); print '
'; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 0c4d89411c11f..5cff3073b8bc6 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -340,7 +340,7 @@ $datef = dol_mktime(GETPOSTINT("p2hour"), GETPOSTINT("p2min"), GETPOSTINT("apsec"), GETPOSTINT("p2month"), GETPOSTINT("p2day"), GETPOSTINT("p2year"), 'tzuserrel'); } //set end date to now if percentage is set to 100 and end date not set - $datef = (!$datef && $percentage == 100)?dol_now():$datef; + $datef = (!$datef && $percentage == 100) ? dol_now() : $datef; // Check parameters if (!$datef && $percentage == 100) { @@ -1463,13 +1463,16 @@ function init_repeat() if (!empty($_SESSION['assignedtouser'])) { $listofuserid = json_decode($_SESSION['assignedtouser'], true); } + if (!is_array($listofuserid)) { + $listofuserid = array(); + } $firstelem = reset($listofuserid); if (isset($listofuserid[$firstelem['id']])) { $listofuserid[$firstelem['id']]['transparency'] = (GETPOSTISSET('transparency') ? GETPOST('transparency', 'alpha') : 0); // 0 by default when refreshing } } print '
'; - print $form->select_dolusers_forevent(($action == 'create' ? 'add' : 'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid); + print $form->select_dolusers_forevent(($action == 'create' ? 'add' : 'update'), 'assignedtouser', 1, array(), 0, '', array(), 0, 0, 0, 'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid); print '
'; print ''; @@ -1482,7 +1485,7 @@ function init_repeat() // Categories print ''.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM, '', 'parent', 64, 0, 3); - print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, 'minwidth300 quatrevingtpercent widthcentpercentminusx', 0, 0); + print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), 0, 0, 'minwidth300 quatrevingtpercent widthcentpercentminusx', 0, 0); print ""; } @@ -1501,13 +1504,16 @@ function init_repeat() if (!empty($_SESSION['assignedtoresource'])) { $listofresourceid = json_decode($_SESSION['assignedtoresource'], true); } + if (!is_array($listofresourceid)) { + $listofresourceid = array(); + } $firstelem = reset($listofresourceid); if (isset($listofresourceid[$firstelem['id']])) { $listofresourceid[$firstelem['id']]['transparency'] = (GETPOSTISSET('transparency') ? GETPOST('transparency', 'alpha') : 0); // 0 by default when refreshing } } print '
'; - print $form->select_dolresources_forevent(($action == 'create' ? 'add' : 'update'), 'assignedtoresource', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0', 1, $listofresourceid); + print $form->select_dolresources_forevent(($action == 'create' ? 'add' : 'update'), 'assignedtoresource', 1, array(), 0, '', array(), 0, 0, 0, 'AND u.statut != 0', 1, $listofresourceid); print '
'; print ''; } @@ -1584,10 +1590,10 @@ function init_repeat() */ $sav = getDolGlobalString('CONTACT_USE_SEARCH_TO_SELECT'); $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0; - print $form->selectcontacts(GETPOSTISSET('socid') ? GETPOSTINT('socid') : $select_contact_default, $preselectedids, 'socpeopleassigned[]', 1, '', '', 0, 'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, array(), false, 'multiple', 'contactid'); + print $form->selectcontacts(GETPOSTISSET('socid') ? GETPOSTINT('socid') : $select_contact_default, $preselectedids, 'socpeopleassigned[]', 1, '', '', 0, 'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, 0, array(), 'multiple', 'contactid'); $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav; } else { - print $form->selectcontacts(GETPOSTISSET('socid') ? GETPOSTINT('socid') : $select_contact_default, $preselectedids, 'socpeopleassigned[]', 1, '', '', 0, 'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, array(), false, 'multiple', 'contactid'); + print $form->selectcontacts(GETPOSTISSET('socid') ? GETPOSTINT('socid') : $select_contact_default, $preselectedids, 'socpeopleassigned[]', 1, '', '', 0, 'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, 0, array(), 'multiple', 'contactid'); } print ''; @@ -2083,7 +2089,7 @@ function setdatefields() print ''.$langs->trans("ActionAssignedTo").''; print '
'; - print $form->select_dolusers_forevent(($action == 'create' ? 'add' : 'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid); + print $form->select_dolusers_forevent(($action == 'create' ? 'add' : 'update'), 'assignedtouser', 1, array(), 0, '', array(), 0, 0, 0, 'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid); print '
'; /*if (in_array($user->id,array_keys($listofuserid))) { @@ -2114,7 +2120,7 @@ function setdatefields() foreach ($cats as $cat) { $arrayselected[] = $cat->id; } - print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); + print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); print ""; } @@ -2264,9 +2270,11 @@ function setdatefields() $actionCommReminder->typeremind = 'email'; } $disabled = ''; + /* if ($object->datep < dol_now()) { //$disabled = 'disabled title="'.dol_escape_htmltag($langs->trans("EventExpired")).'"'; } + */ print '
'; @@ -2559,7 +2567,7 @@ function setdatefields() $listofcontactid = array(); // not used yet $listofotherid = array(); // not used yet print '
'; - print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid); + print $form->select_dolusers_forevent('view', 'assignedtouser', 1, array(), 0, '', array(), 0, 0, 0, '', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid); print '
'; /* if ($object->datep != $object->datef && in_array($user->id,array_keys($listofuserid))) diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php index 8c2476b973946..9c28468c1c74f 100644 --- a/htdocs/comm/action/class/cactioncomm.class.php +++ b/htdocs/comm/action/class/cactioncomm.class.php @@ -82,7 +82,7 @@ class CActionComm public $picto; /** - * @var array array of type_actions + * @var array array of type_actions // TODO: Remove or explain */ public $type_actions = array(); diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index b1b37b1661d86..8eb19ae19cd74 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -6,6 +6,7 @@ * Copyright (C) 2005 Simon TOSSER * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -278,7 +279,7 @@ $listofuserid = array(); if (empty($donotclearsession)) { if ($object->userownerid > 0) { - $listofuserid[$object->userownerid] = array('id'=>$object->userownerid, 'transparency'=>$object->transparency); // Owner first + $listofuserid[$object->userownerid] = array('id' => $object->userownerid, 'transparency' => $object->transparency); // Owner first } if (!empty($object->userassigned)) { // Now concat assigned users // Restore array with key with same value than param 'id' @@ -298,7 +299,7 @@ $listofcontactid = array(); // not used yet $listofotherid = array(); // not used yet print '
'; - print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid); + print $form->select_dolusers_forevent('view', 'assignedtouser', 1, array(), 0, '', array(), 0, 0, 0, '', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid); print '
'; /*if (in_array($user->id,array_keys($listofuserid))) { diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 53bc33241f85d..63048fefeb938 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -2158,9 +2158,11 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa '@phan-var-force ActionComm $event'; if (empty($reshook)) { // Other calendar + /* if (empty($event->fulldayevent)) { //print $event->getNomUrl(2).' '; } + */ // Date if (empty($event->fulldayevent)) { diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 7bce264617dde..064ca39d86dfb 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -1149,8 +1149,8 @@ print ''; if ($obj->socid > 0) { $societestatic->id = $obj->socid; - $societestatic->client = $obj->client; - $societestatic->name = $obj->societe; + $societestatic->client = (int) $obj->client; + $societestatic->name = (string) $obj->societe; $societestatic->email = $obj->socemail; print $societestatic->getNomUrl(1, '', 28); diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 0e9b5bbbaf1a0..d5d99d1c8da3f 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -93,6 +93,7 @@ $hookmanager->initHooks(array('ciblescard', 'globalcard')); $sqlmessage = ''; +$mesgs = array(); // List of sending methods $listofmethods = array(); diff --git a/htdocs/commande/list_det.php b/htdocs/commande/list_det.php index b501d46313595..92147f8bc63c4 100644 --- a/htdocs/commande/list_det.php +++ b/htdocs/commande/list_det.php @@ -91,6 +91,7 @@ $search_datedelivery_start = dol_mktime(0, 0, 0, GETPOSTINT('search_datedelivery_start_month'), GETPOSTINT('search_datedelivery_start_day'), GETPOSTINT('search_datedelivery_start_year')); $search_datedelivery_end = dol_mktime(23, 59, 59, GETPOSTINT('search_datedelivery_end_month'), GETPOSTINT('search_datedelivery_end_day'), GETPOSTINT('search_datedelivery_end_year')); +$search_product_category_array = array(); if (isModEnabled('category')) { $search_product_category_array = GETPOST("search_category_".Categorie::TYPE_PRODUCT."_list", "array"); $searchCategoryProductOperator = 0; @@ -255,6 +256,7 @@ } $result = restrictedArea($user, 'commande', $id, ''); +$permissiontoread = false; /* * Actions @@ -1498,6 +1500,7 @@ // Détail commande $totalqty = 0; + $oldref = null; $totalarray = array(); $totalarray['nbfield'] = 0; @@ -1816,7 +1819,7 @@ // Channel if (!empty($arrayfields['c.fk_input_reason']['checked'])) { print ''; - $form->formInputReason($_SERVER['PHP_SELF'], $obj->fk_input_reason, 'none', ''); + $form->formInputReason($_SERVER['PHP_SELF'], $obj->fk_input_reason, 'none', 0); print ''; if (!$i) { $totalarray['nbfield']++; @@ -2101,6 +2104,7 @@ if (!empty($arrayfields['shippable']['checked'])) { print ''; if (!empty($show_shippable_command) && isModEnabled('stock')) { + $text_icon = ''; if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) { $generic_commande->loadExpeditions(); // Load array ->expeditions diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index c423ee3e42efa..2005e7d0fb2bd 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -417,11 +417,11 @@ //var_dump($files); if (count($files) < 1) { $nofile = array(); - $nofile['id'] = $objd->id; - $nofile['entity'] = $objd->entity; + $nofile['id'] = (int) $objd->id; + $nofile['entity'] = (int) $objd->entity; $nofile['date'] = $db->jdate($objd->date); $nofile['date_due'] = $db->jdate($objd->date_due); - $nofile['paid'] = $objd->paid; + $nofile['paid'] = (int) $objd->paid; $nofile['amount_ht'] = $objd->total_ht; $nofile['amount_ttc'] = $objd->total_ttc; $nofile['amount_vat'] = $objd->total_vat; @@ -444,11 +444,11 @@ $filesarray[$nofile['item'].'_'.$nofile['id']] = $nofile; } else { foreach ($files as $key => $file) { - $file['id'] = $objd->id; - $file['entity'] = $objd->entity; + $file['id'] = (int) $objd->id; + $file['entity'] = (int) $objd->entity; $file['date'] = $db->jdate($objd->date); $file['date_due'] = $db->jdate($objd->date_due); - $file['paid'] = $objd->paid; + $file['paid'] = (int) $objd->paid; $file['amount_ht'] = $objd->total_ht; $file['amount_ttc'] = $objd->total_ttc; $file['amount_vat'] = $objd->total_vat; @@ -816,7 +816,7 @@ print ''; if ($data['item'] == 'Invoice') { - $invoice->id = $data['id']; + $invoice->id = (int) $data['id']; $invoice->ref = $data['ref']; $invoice->total_ht = $data['amount_ht']; $invoice->total_ttc = $data['amount_ttc']; @@ -827,7 +827,7 @@ $invoice->multicurrency_code = $data['currency']; print $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); } elseif ($data['item'] == 'SupplierInvoice') { - $supplier_invoice->id = $data['id']; + $supplier_invoice->id = (int) $data['id']; $supplier_invoice->ref = $data['ref']; $supplier_invoice->total_ht = $data['amount_ht']; $supplier_invoice->total_ttc = $data['amount_ttc']; @@ -838,27 +838,27 @@ $supplier_invoice->multicurrency_code = $data['currency']; print $supplier_invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); } elseif ($data['item'] == 'ExpenseReport') { - $expensereport->id = $data['id']; + $expensereport->id = (int) $data['id']; $expensereport->ref = $data['ref']; print $expensereport->getNomUrl(1, 0, 0, 0, 0, 0); } elseif ($data['item'] == 'SalaryPayment') { - $salary_payment->id = $data['id']; + $salary_payment->id = (int) $data['id']; $salary_payment->ref = $data['ref']; print $salary_payment->getNomUrl(1); } elseif ($data['item'] == 'Donation') { - $don->id = $data['id']; + $don->id = (int) $data['id']; $don->ref = $data['ref']; print $don->getNomUrl(1, 0, '', 0); } elseif ($data['item'] == 'SocialContributions') { - $charge_sociales->id = $data['id']; + $charge_sociales->id = (int) $data['id']; $charge_sociales->ref = $data['ref']; print $charge_sociales->getNomUrl(1, 0, 0, 0, 0); } elseif ($data['item'] == 'VariousPayment') { - $various_payment->id = $data['id']; + $various_payment->id = (int) $data['id']; $various_payment->ref = $data['ref']; print $various_payment->getNomUrl(1, '', 0, 0); } elseif ($data['item'] == 'LoanPayment') { - $payment_loan->id = $data['id']; + $payment_loan->id = (int) $data['id']; $payment_loan->ref = $data['ref']; print $payment_loan->getNomUrl(1, 0, 0, '', 0); } else { diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index 8299965fc17ca..8132b0729a767 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -305,11 +305,11 @@ $obj = $db->fetch_object($resql); $min = $db->jdate($obj->min); $max = $db->jdate($obj->max); + $log = "graph.php: min=".$min." max=".$max; + dol_syslog($log); } else { dol_print_error($db); } - $log = "graph.php: min=".$min." max=".$max; - dol_syslog($log); // CRED PART // Chargement du tableau des années diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index ea8b2bd39a478..6f4e4a946f3aa 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -974,6 +974,7 @@ $last_receipts = array(); $last_releve = ''; $last_ok = 0; + $numr = 0; $resqlr = $db->query($sql); if ($resqlr) { @@ -1101,7 +1102,7 @@ // Bank line $moreforfilter .= '
'; $tmptitle = $langs->trans('RubriquesTransactions'); - $cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, $search_bid, 'parent', null, null, 1); + $cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, $search_bid, 'parent', 0, 0, 1); $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_bid', $cate_arbo, $search_bid, $tmptitle, 0, 0, '', 0, 0, 0, '', '', 1); $moreforfilter .= '
'; } diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index f78e9d08befc6..31f7fc7ca20f1 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -505,7 +505,7 @@ $arrayselected[] = $cat->id; } } - print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); + print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); print ""; } @@ -594,6 +594,10 @@ $name = 'cle_rib'; $sizecss = 'minwidth50'; $content = $object->cle_rib; + } else { + $name = 'undefined'; + $sizecss = 'undefined'; + $content = 'undefined'; } print ''.$langs->trans($val).''; @@ -651,7 +655,7 @@ print ''.$langs->trans("AccountancyCode").''; print ''; print img_picto('', 'accounting_account', 'class="pictofixedwidth"'); - print $formaccounting->select_account($object->account_number, 'account_number', 1, '', 1, 1); + print $formaccounting->select_account($object->account_number, 'account_number', 1, array(), 1, 1); if ($formaccounting->nbaccounts == 0) { $langs->load("errors"); $htmltext = $langs->transnoentitiesnoconv("WarningGoOnAccountancySetupToAddAccounts", $langs->transnoentitiesnoconv("MenuAccountancy"), $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Chartofaccounts")); @@ -1069,7 +1073,7 @@ $arrayselected[] = $cat->id; } } - print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); + print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); print ""; } @@ -1110,7 +1114,7 @@ if (isModEnabled('accounting')) { /** @var FormAccounting $formaccounting */ print img_picto('', 'accounting_account', 'class="pictofixedwidth"'); - print $formaccounting->select_account($object->account_number, 'account_number', 1, '', 1, 1); + print $formaccounting->select_account($object->account_number, 'account_number', 1, array(), 1, 1); if ($formaccounting->nbaccounts == 0) { $langs->load("errors"); $htmltext = $langs->transnoentitiesnoconv("WarningGoOnAccountancySetupToAddAccounts", $langs->transnoentitiesnoconv("MenuAccountancy"), $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Chartofaccounts")); @@ -1182,6 +1186,10 @@ $name = 'cle_rib'; $css = 'width50'; $content = $object->cle_rib; + } else { + $name = 'undefined'; + $css = 'undefined'; + $content = 'undefined'; } print ''.$langs->trans($val).''; diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index 20a1be491c9ed..be7ff72baf170 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -94,6 +94,13 @@ $title = $object->ref.' - '.$langs->trans("Graph"); $helpurl = ""; +$show1 = ''; +$show2 = ''; +$show3 = ''; +$show4 = ''; +$show5 = ''; +$morehtml = ''; + llxHeader('', $title, $helpurl); $result = dol_mkdir($conf->bank->dir_temp); diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index 1e9a8a4080fc9..511b2b52a22c5 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -636,7 +636,7 @@ // Bank line print ''.$form->editfieldkey('RubriquesTransactions', 'custcats', '', $object, 0).''; - $cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, null, 'parent', null, null, 1); + $cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, '', 'parent', 0, 0, 1); $arrayselected = array(); @@ -647,7 +647,7 @@ $arrayselected[] = $cat->id; } } - print img_picto('', 'category', 'class="paddingright"').$form->multiselectarray('custcats', $cate_arbo, $arrayselected, null, null, null, null, "90%"); + print img_picto('', 'category', 'class="paddingright"').$form->multiselectarray('custcats', $cate_arbo, $arrayselected, 0, 0, '', 0, "90%"); print ""; } diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index d65c44e88373e..f1d3523c3368e 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -495,6 +495,8 @@ $obj = $db->fetch_object($resql); $total = $obj->amount; $db->free($resql); + } else { + $total = 0; } $totalc = $totald = 0; diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index 80101b1b9e8db..6150abc0cf3df 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -173,13 +173,13 @@ } if (!$error) { - $bank_line_id_from = $tmpaccountfrom->addline($dateo[$n], $typefrom, $label[$n], price2num(-1 * (float) $amount[$n]), '', '', $user); + $bank_line_id_from = $tmpaccountfrom->addline($dateo[$n], $typefrom, $label[$n], price2num(-1 * (float) $amount[$n]), '', 0, $user); } if (!($bank_line_id_from > 0)) { $error++; } if (!$error) { - $bank_line_id_to = $tmpaccountto->addline($dateo[$n], $typeto, $label[$n], $amountto[$n], '', '', $user); + $bank_line_id_to = $tmpaccountto->addline($dateo[$n], $typeto, $label[$n], $amountto[$n], '', 0, $user); } if (!($bank_line_id_to > 0)) { $error++; diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index be77fa1b9c9c3..69c859037b29f 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -5,6 +5,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2022 Alexandre Spangaro + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -283,7 +284,7 @@ if ($tmpobj->family == 'invoice') { $facturestatic->ref = $tmpobj->ref; $facturestatic->id = $tmpobj->objid; - $facturestatic->type = $tmpobj->type; + $facturestatic->type = (int) $tmpobj->type; $ref = $facturestatic->getNomUrl(1, ''); $societestatic->id = $tmpobj->socid; diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 8e5a6c41a5770..a8dfc070bd4db 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -226,6 +226,8 @@ if ($result > 0) { $result = $accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) } + } else { + $account_line = null; } if ($result >= 0) { @@ -233,7 +235,7 @@ header("Location: ".DOL_URL_ROOT.'/compta/bank/various_payment/list.php'); exit; } else { - $object->error = $accountline->error; + $object->error = $accountline ? $accountline->error : 'No AccountLine'; $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } @@ -356,9 +358,13 @@ $form = new Form($db); if (isModEnabled('accounting')) { $formaccounting = new FormAccounting($db); +} else { + $formaccounting = null; } if (isModEnabled('project')) { $formproject = new FormProjets($db); +} else { + $formproject = null; } if ($id) { @@ -531,7 +537,7 @@ function setPaymentType() // TODO Remove the fieldrequired and allow instead to edit a various payment to enter accounting code print ''.$langs->trans("AccountAccounting").''; print ''; - print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1); + print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, array(), 1, 1); print ''; } else { // For external software print ''.$langs->trans("AccountAccounting").''; @@ -606,7 +612,7 @@ function setPaymentType() $morehtmlref = '
'; // Project - if (isModEnabled('project')) { + if (isModEnabled('project') && $formproject !== null) { $langs->load("projects"); //$morehtmlref .= '
'; if ($permissiontoadd) { diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index 8aa20523f7de8..e45bd655ef3f6 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -449,4 +449,20 @@ public function getSqlArrayForStats() dol_syslog($msg, LOG_ERR); return array(); } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Add destinations in the targets table + * + * @param int $mailing_id Id of emailing + * @return int Return integer < 0 on error, count of added when ok + */ + public function add_to_target($mailing_id) + { + // phpcs:enable + // Needs to be implemented in child class + $msg = get_class($this)."::".__FUNCTION__." not implemented"; + dol_syslog($msg, LOG_ERR); + return -1; + } } From 75ce3e85136113a73b60f8fecda92a110614e570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20H=C3=B6dl?= <27991923+f-hoedl@users.noreply.github.com> Date: Tue, 12 Nov 2024 00:36:34 +0100 Subject: [PATCH 04/19] [FIX] Update ticket create form to hide contracts from other thirdparties for external users (#31762) Co-authored-by: fhoedl --- htdocs/core/class/html.formticket.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 4f8b20293f184..482e6af0088aa 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -769,7 +769,8 @@ function(response) { $formcontract = new FormContract($this->db); print ''; print img_picto('', 'contract', 'class="pictofixedwidth"'); - print $formcontract->select_contract(-1, GETPOSTINT('contactid'), 'contractid', 0, 1, 1, 1); + // socid is for internal users null and not 0 or -1 + print $formcontract->select_contract($user->socid ?? -1, GETPOSTINT('contactid'), 'contractid', 0, 1, 1, 1); print ''; } } From 07c3690bb75e0f7886e770f95e113f6afa455464 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Nov 2024 01:26:08 +0100 Subject: [PATCH 05/19] FIX the style not visible in combo using autocomplete --- htdocs/core/class/html.form.class.php | 6 ++++-- htdocs/core/lib/ajax.lib.php | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c87b0e6cb79c0..be5c3028b4e86 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3757,7 +3757,7 @@ public function select_produits_fournisseurs_list($socid, $selected = '', $htmln // Add criteria on ref/label if ($filterkey != '') { $sql .= ' AND ('; - $prefix = !getDolGlobalString('PRODUCT_DONOTSEARCH_ANYWHERE') ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on + $prefix = getDolGlobalString('PRODUCT_DONOTSEARCH_ANYWHERE') ? '' : '%'; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on // For natural search $search_crit = explode(' ', $filterkey); $i = 0; @@ -4041,10 +4041,12 @@ public function select_produits_fournisseurs_list($socid, $selected = '', $htmln } $optstart .= ' data-description="' . dol_escape_htmltag($objp->description, 0, 1) . '"'; + // set $parameters to call hook $outarrayentry = array( 'key' => $outkey, 'value' => $outref, 'label' => $outvallabel, + 'labelhtml' => $optlabel, 'qty' => $outqty, 'price_qty_ht' => price2num($objp->fprice, 'MU'), // Keep higher resolution for price for the min qty 'price_unit_ht' => price2num($objp->unitprice, 'MU'), // This is used to fill the Unit Price @@ -4064,7 +4066,6 @@ public function select_produits_fournisseurs_list($socid, $selected = '', $htmln $outarrayentry['multicurrency_code'] = $objp->multicurrency_code; $outarrayentry['multicurrency_unitprice'] = price2num($objp->multicurrency_unitprice, 'MU'); } - $parameters = array( 'objp' => &$objp, 'optstart' => &$optstart, @@ -4084,6 +4085,7 @@ public function select_produits_fournisseurs_list($socid, $selected = '', $htmln 'key' => $outkey, 'value' => $outref, 'label' => $outvallabel, + 'labelhtml' => $optlabel, 'qty' => $outqty, 'price_qty_ht' => price2num($objp->fprice, 'MU'), // Keep higher resolution for price for the min qty 'price_qty_ht_locale' => price($objp->fprice), diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index f573fa9360d45..1bf6c6f207f82 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -127,12 +127,15 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen if (data != null) { response($.map( data, function(item) { + console.log("Received answer from ajax GET, we populate array to return to the jquery autocomplete"); if (autoselect == 1 && data.length == 1) { $("#search_'.$htmlnamejquery.'").val(item.value); $("#'.$htmlnamejquery.'").val(item.key).trigger("change"); } var label = ""; - if (item.label != null) { + if (item.labelhtml != null) { + label = item.labelhtml.toString(); + } else if (item.label != null) { label = item.label.toString(); } var update = {}; @@ -148,7 +151,6 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen }); } - console.log("Return value from GET to the rest of code"); return { label: label, value: item.value, id: item.key, From 960413db0f5b72894e06ebce44a8e7b40bc88c66 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Nov 2024 01:57:51 +0100 Subject: [PATCH 06/19] Close #24389 --- htdocs/product/class/product.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index f7a21500f8513..b0536fb239c18 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -6189,6 +6189,7 @@ public function load_stock($option = '', $includedraftpoforvirtual = null, $date $this->stock_reel += $row->reel; $i++; } + $this->stock_reel = price2num($this->stock_reel, 'MS'); } $this->db->free($result); From 66ee2a2cfe81782da1bda8a949ae239a17efd55b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Nov 2024 02:24:25 +0100 Subject: [PATCH 07/19] Close #24828 --- htdocs/takepos/invoice.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 21681ef27b412..72056dbda4cfa 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -1523,6 +1523,8 @@ function SetNote() { $s .= " - " . $contact->getFullName($langs); } } + } elseif (getDolGlobalInt("TAKEPOS_NO_GENERIC_THIRDPARTY")) { + print '$("#idcustomer").val("");'; } ?> From 22eec4ba8a406730229a8d7785a815a4c084ed43 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Nov 2024 02:38:34 +0100 Subject: [PATCH 08/19] Doc --- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 2 +- htdocs/core/modules/facture/doc/pdf_octopus.modules.php | 2 +- htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index b5d7a29c7c6d4..255aa356a7327 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -2232,7 +2232,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output // @phan-suppress-next-line PhanPluginSuspiciousParamOrder $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection); - // Show shipping address + // Show shipping/delivery address if (getDolGlobalInt('INVOICE_SHOW_SHIPPING_ADDRESS')) { $idaddressshipping = $object->getIdContact('external', 'SHIPPING'); diff --git a/htdocs/core/modules/facture/doc/pdf_octopus.modules.php b/htdocs/core/modules/facture/doc/pdf_octopus.modules.php index 85f85c194a080..9ec9d52a63e1c 100644 --- a/htdocs/core/modules/facture/doc/pdf_octopus.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_octopus.modules.php @@ -2397,7 +2397,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output // @phan-suppress-next-line PhanPluginSuspiciousParamOrder $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection); - // Show shipping address + // Show shipping/delivery address if (getDolGlobalInt('INVOICE_SHOW_SHIPPING_ADDRESS')) { $idaddressshipping = $object->getIdContact('external', 'SHIPPING'); diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 4d97c877705dc..9a361ab0ce4f3 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -2479,7 +2479,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output // @phan-suppress-next-line PhanPluginSuspiciousParamOrder $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection); - // Show shipping address + // Show shipping/delivery address if (getDolGlobalInt('INVOICE_SHOW_SHIPPING_ADDRESS')) { $idaddressshipping = $object->getIdContact('external', 'SHIPPING'); From e5caa2170ead07a06b934facb530612b5fdfff01 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 12 Nov 2024 02:43:46 +0100 Subject: [PATCH 09/19] Update workstation_list.php (#25707) * Update workstation_list.php * Update workstation_list.php --------- Co-authored-by: Laurent Destailleur --- htdocs/workstation/workstation_list.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/workstation/workstation_list.php b/htdocs/workstation/workstation_list.php index 2003d6802559d..254036c594522 100644 --- a/htdocs/workstation/workstation_list.php +++ b/htdocs/workstation/workstation_list.php @@ -55,6 +55,8 @@ $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...) + +// Load variables for pagination $id = GETPOSTINT('id'); $ref = GETPOST('ref', 'alpha'); @@ -159,6 +161,7 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); '@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan +// Permissions $permissiontoread = $user->hasRight('workstation', 'workstation', 'read'); $permissiontoadd = $user->hasRight('workstation', 'workstation', 'write'); $permissiontodelete = $user->hasRight('workstation', 'workstation', 'delete'); @@ -167,6 +170,7 @@ restrictedArea($user, $object->element, 0, $object->table_element, 'workstation'); + /* * Actions */ @@ -229,6 +233,7 @@ $help_url = 'EN:Module_Workstation'; $morejs = array(); $morecss = array(); +// llxHeader -> look down at section Output page // Build and execute select @@ -242,6 +247,7 @@ $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); } } + // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -260,6 +266,7 @@ if (!empty($resources)) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'workstation_workstation_resource wr ON (wr.fk_workstation = t.rowid)'; } + // Add table from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -796,10 +803,12 @@ // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; + // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; From d395924150dfec624fd6927473d122c212c1090b Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 12 Nov 2024 02:54:18 +0100 Subject: [PATCH 10/19] Update /datapolicy/admin/setup.php (#25709) * Update /datapolicy/admin/setup.php * Update setup.php --------- Co-authored-by: Laurent Destailleur --- htdocs/datapolicy/admin/setup.php | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/htdocs/datapolicy/admin/setup.php b/htdocs/datapolicy/admin/setup.php index 1d19a9d2fede8..ea3ae94a6d5b3 100644 --- a/htdocs/datapolicy/admin/setup.php +++ b/htdocs/datapolicy/admin/setup.php @@ -50,13 +50,15 @@ } $arrayofparameters = array(); +// ThirdParty $arrayofparameters['ThirdParty'] = array( - 'DATAPOLICY_TIERS_CLIENT' => array('css' => 'minwidth200', 'picto' => img_picto('', 'company', 'class="pictofixedwidth"')), - 'DATAPOLICY_TIERS_PROSPECT' => array('css' => 'minwidth200', 'picto' => img_picto('', 'company', 'class="pictofixedwidth"')), - 'DATAPOLICY_TIERS_PROSPECT_CLIENT' => array('css' => 'minwidth200', 'picto' => img_picto('', 'company', 'class="pictofixedwidth"')), - 'DATAPOLICY_TIERS_NIPROSPECT_NICLIENT' => array('css' => 'minwidth200', 'picto' => img_picto('', 'company', 'class="pictofixedwidth"')), - 'DATAPOLICY_TIERS_FOURNISSEUR' => array('css' => 'minwidth200', 'picto' => img_picto('', 'supplier', 'class="pictofixedwidth"')), -); + 'DATAPOLICY_TIERS_CLIENT'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'company', 'class="pictofixedwidth"')), + 'DATAPOLICY_TIERS_PROSPECT'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'company', 'class="pictofixedwidth"')), + 'DATAPOLICY_TIERS_PROSPECT_CLIENT'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'company', 'class="pictofixedwidth"')), + 'DATAPOLICY_TIERS_NIPROSPECT_NICLIENT'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'company', 'class="pictofixedwidth"')), + 'DATAPOLICY_TIERS_FOURNISSEUR'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'supplier', 'class="pictofixedwidth"')), + ); +// Contact if (getDolGlobalString('DATAPOLICY_USE_SPECIFIC_DELAY_FOR_CONTACT')) { $arrayofparameters['Contact'] = array( 'DATAPOLICY_CONTACT_CLIENT' => array('css' => 'minwidth200', 'picto' => img_picto('', 'contact', 'class="pictofixedwidth"')), @@ -66,6 +68,7 @@ 'DATAPOLICY_CONTACT_FOURNISSEUR' => array('css' => 'minwidth200', 'picto' => img_picto('', 'contact', 'class="pictofixedwidth"')), ); } +// Member if (isModEnabled('member')) { $arrayofparameters['Member'] = array( 'DATAPOLICY_ADHERENT' => array('css' => 'minwidth200', 'picto' => img_picto('', 'member', 'class="pictofixedwidth"')), @@ -73,13 +76,13 @@ } $valTab = array( - '' => $langs->trans('Never'), - '6' => $langs->trans('NB_MONTHS', 6), - '12' => $langs->trans('ONE_YEAR'), - '24' => $langs->trans('NB_YEARS', 2), - '36' => $langs->trans('NB_YEARS', 3), - '48' => $langs->trans('NB_YEARS', 4), - '60' => $langs->trans('NB_YEARS', 5), + '' => $langs->trans('Never'), + '6' => $langs->trans('NB_MONTHS', 6), + '12' => $langs->trans('ONE_YEAR'), + '24' => $langs->trans('NB_YEARS', 2), + '36' => $langs->trans('NB_YEARS', 3), + '48' => $langs->trans('NB_YEARS', 4), + '60' => $langs->trans('NB_YEARS', 5), '120' => $langs->trans('NB_YEARS', 10), '180' => $langs->trans('NB_YEARS', 15), '240' => $langs->trans('NB_YEARS', 20), From f35fd7c1f0ca30e003c75c264b269247ec209d69 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Nov 2024 03:17:55 +0100 Subject: [PATCH 11/19] Clean code --- htdocs/core/class/commonobject.class.php | 56 +++++++++++--------- htdocs/core/class/html.formcompany.class.php | 10 ++-- htdocs/expedition/contact.php | 2 +- 3 files changed, 36 insertions(+), 32 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 97ef613a1cfbc..9c2d7b10aa7d4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1627,11 +1627,11 @@ public function swapContactStatus($rowid) * Return array with list of possible values for type of contacts * * @param 'internal'|'external'|'all' $source 'internal', 'external' or 'all' - * @param string $order Sort order by : 'position', 'code', 'rowid'... - * @param int<0,1> $option 0=Return array id->label, 1=Return array code->label - * @param int<0,1> $activeonly 0=all status of contact, 1=only the active - * @param string $code Type of contact (Example: 'CUSTOMER', 'SERVICE') - * @return array|array|null Array list of type of contacts (id->label if option=0, code->label if option=1), or null if error + * @param string $order Sort order by : 'position', 'code', 'rowid'... + * @param int<0,1> $option 0=Return array id->label, 1=Return array code->label, 2=Return complete array + * @param int<0,1> $activeonly 0=all status of contact, 1=only the active + * @param string $code Type of contact (Example: 'CUSTOMER', 'SERVICE') + * @return array|array|null Array list of type of contacts (id->label if option=0, code->label if option=1), or null if error */ public function liste_type_contact($source = 'internal', $order = 'position', $option = 0, $activeonly = 0, $code = '') { @@ -1646,43 +1646,47 @@ public function liste_type_contact($source = 'internal', $order = 'position', $o } $tab = array(); + $sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle as type_label, tc.position"; $sql .= " FROM ".$this->db->prefix()."c_type_contact as tc"; - $sql .= " WHERE tc.element='".$this->db->escape($this->element)."'"; + $sql .= " WHERE tc.element = '".$this->db->escape($this->element)."'"; if ($activeonly == 1) { - $sql .= " AND tc.active=1"; // only the active types + $sql .= " AND tc.active = 1"; // only the active types } if (!empty($source) && $source != 'all') { - $sql .= " AND tc.source='".$this->db->escape($source)."'"; + $sql .= " AND tc.source = '".$this->db->escape($source)."'"; } if (!empty($code)) { - $sql .= " AND tc.code='".$this->db->escape($code)."'"; + $sql .= " AND tc.code = '".$this->db->escape($code)."'"; } $sql .= $this->db->order($order, 'ASC'); //print "sql=".$sql; $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < $num) { - $obj = $this->db->fetch_object($resql); - - $transkey = "TypeContact_".$this->element."_".$source."_".$obj->code; - $libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->type_label); - if (empty($option)) { - $tab[$obj->rowid] = $libelle_type; - } else { - $tab[$obj->code] = $libelle_type; - } - $i++; - } - return $tab; - } else { + if (!$resql) { $this->error = $this->db->lasterror(); //dol_print_error($this->db); return null; } + + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) { + $obj = $this->db->fetch_object($resql); + + $transkey = "TypeContact_".$this->element."_".$source."_".$obj->code; + $libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->type_label); + if (empty($option)) { + $tab[$obj->rowid] = $libelle_type; + } elseif ($option == 1) { + $tab[$obj->code] = $libelle_type; + } else { + $tab[$obj->rowid] = array('id' => $obj->rowid, 'code' => $obj->code, 'label' => $libelle_type); + } + $i++; + } + + return $tab; } /** diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index ae973c799022f..39c0ff94ec2f9 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -828,22 +828,22 @@ public function selectTypeContact($object, $selected, $htmlname = 'type', $sourc $out = ''; if (is_object($object) && method_exists($object, 'liste_type_contact')) { '@phan-var-force CommonObject $object'; // CommonObject has the method. - $lesTypes = $object->liste_type_contact($source, $sortorder, 0, 1); // List of types into c_type_contact for element=$object->element + $lesTypes = $object->liste_type_contact($source, $sortorder, 2, 1); // List of types into c_type_contact for element=$object->element $out .= '"; if ($user->admin && empty($forcehidetooltip)) { - $out .= ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } $out .= ajax_combobox($htmlname); diff --git a/htdocs/expedition/contact.php b/htdocs/expedition/contact.php index 939c6649535a5..058cf08489470 100644 --- a/htdocs/expedition/contact.php +++ b/htdocs/expedition/contact.php @@ -22,7 +22,7 @@ /** * \file htdocs/expedition/contact.php * \ingroup expedition - * \brief Onglet de gestion des contacts de expedition + * \brief Tab to manage addresses of shipments */ // Load Dolibarr environment From 353696b3ba35db9771319e9abfa0ade22037d0b2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Nov 2024 03:22:51 +0100 Subject: [PATCH 12/19] Doc --- htdocs/install/mysql/tables/llx_expedition.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_expedition.sql b/htdocs/install/mysql/tables/llx_expedition.sql index 25d22b9bbf09f..5743e9b454371 100644 --- a/htdocs/install/mysql/tables/llx_expedition.sql +++ b/htdocs/install/mysql/tables/llx_expedition.sql @@ -38,7 +38,7 @@ create table llx_expedition date_valid datetime, -- date of validation fk_user_valid integer, -- user that validate date_delivery datetime DEFAULT NULL, -- date planned of delivery - date_expedition datetime, -- not used (deprecated) + date_expedition datetime, -- date real shipment (to implement) fk_address integer DEFAULT NULL, -- delivery address (deprecated) fk_shipping_method integer, tracking_number varchar(50), From c9972f1dd9321d28bc4f10841f5fbf789264d69d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Nov 2024 03:32:57 +0100 Subject: [PATCH 13/19] Fix phan --- htdocs/core/class/commonobject.class.php | 2 +- htdocs/product/class/product.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9c2d7b10aa7d4..620dbb57c6103 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1631,7 +1631,7 @@ public function swapContactStatus($rowid) * @param int<0,1> $option 0=Return array id->label, 1=Return array code->label, 2=Return complete array * @param int<0,1> $activeonly 0=all status of contact, 1=only the active * @param string $code Type of contact (Example: 'CUSTOMER', 'SERVICE') - * @return array|array|null Array list of type of contacts (id->label if option=0, code->label if option=1), or null if error + * @return array|array|array|null Array list of type of contacts (id->label if option=0, code->label if option=1), or null if error */ public function liste_type_contact($source = 'internal', $order = 'position', $option = 0, $activeonly = 0, $code = '') { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index b0536fb239c18..eb4e784b8e67f 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -6189,7 +6189,7 @@ public function load_stock($option = '', $includedraftpoforvirtual = null, $date $this->stock_reel += $row->reel; $i++; } - $this->stock_reel = price2num($this->stock_reel, 'MS'); + $this->stock_reel = (float) price2num($this->stock_reel, 'MS'); } $this->db->free($result); From 3b0ccddaea5bf75c332a75344601d5abe904fa3d Mon Sep 17 00:00:00 2001 From: iLLixM <162678117+iLLixM@users.noreply.github.com> Date: Tue, 12 Nov 2024 03:37:48 +0100 Subject: [PATCH 14/19] set payment method information on new membership subscriptions (#31750) When creating new membership subscriptions and choosing to create an invoice (for linked thirdparty), existing payment method information of the customer should be used. Co-authored-by: Laurent Destailleur --- htdocs/adherents/class/adherent.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 4c5703e454006..a113d6f097079 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1836,13 +1836,17 @@ public function subscriptionComplementaryActions($subscriptionid, $option, $acco } } $invoice->socid = $this->fk_soc; - // set customer's bank account on the invoice + // set customer's payment bank account on the invoice if (!empty($customer->fk_account)) { $invoice->fk_account = $customer->fk_account; } elseif (getDolGlobalString('FACTURE_RIB_NUMBER')) { // set default bank account from invoice module settings $invoice->fk_account = (int) getDolGlobalString('FACTURE_RIB_NUMBER'); } + //set customer's payment method on the invoice + if (!empty($customer->mode_reglement_id)) { + $invoice->mode_reglement_id = $customer->mode_reglement_id; + } //$invoice->date = $datesubscription; $invoice->date = dol_now(); From 836bb71303c767c29bb0e2694ee180e31d797d01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 12 Nov 2024 03:38:38 +0100 Subject: [PATCH 15/19] fix customreports.lib.php (#31771) * fix customreports.lib.php * Update commondict.class.php * Update ctyperesource.class.php * fix * CommonDict is not a business class * Update ctyperesource.class.php * Update ctyperesource.class.php --------- Co-authored-by: Laurent Destailleur --- build/phpstan/phpstan-baseline.neon | 15 --------------- htdocs/core/lib/customreports.lib.php | 4 ++-- htdocs/opensurvey/wizard/create_survey.php | 2 +- 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/build/phpstan/phpstan-baseline.neon b/build/phpstan/phpstan-baseline.neon index 48e5c9f8c08bf..6616e9c1b8743 100644 --- a/build/phpstan/phpstan-baseline.neon +++ b/build/phpstan/phpstan-baseline.neon @@ -17930,21 +17930,6 @@ parameters: count: 1 path: ../../htdocs/opensurvey/results.php - - - message: "#^Parameter \\#4 \\$month of function dol_mktime expects int, array\\|string given\\.$#" - count: 1 - path: ../../htdocs/opensurvey/wizard/create_survey.php - - - - message: "#^Parameter \\#5 \\$day of function dol_mktime expects int, array\\|string given\\.$#" - count: 1 - path: ../../htdocs/opensurvey/wizard/create_survey.php - - - - message: "#^Parameter \\#6 \\$year of function dol_mktime expects int, array\\|string given\\.$#" - count: 1 - path: ../../htdocs/opensurvey/wizard/create_survey.php - - message: "#^Variable \\$allow_comments might not be defined\\.$#" count: 1 diff --git a/htdocs/core/lib/customreports.lib.php b/htdocs/core/lib/customreports.lib.php index a94891c00d7b3..ac3cab1aa642c 100644 --- a/htdocs/core/lib/customreports.lib.php +++ b/htdocs/core/lib/customreports.lib.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2024 Laurent Destailleur * Copyright (C) 2024 Frédéric France * Copyright (C) 2024 MDW * @@ -591,7 +591,7 @@ function fillArrayOfFilterFields($object, $tablealias, $labelofobject, &$arrayof 'position' => 1000 + (int) $extrafields->attributes[$object->table_element]['pos'][$key] + ($count * 100000), 'table' => $object->table_element, 'tablefromt' => $tablepath, - 'type' => $val['type'] // TODO: Check this, seems a copy/paste error + 'type' => $extrafields->attributes[$object->table_element]['type'][$key], ); } } diff --git a/htdocs/opensurvey/wizard/create_survey.php b/htdocs/opensurvey/wizard/create_survey.php index 6df9d1ec060b0..0cf7deab04fdc 100644 --- a/htdocs/opensurvey/wizard/create_survey.php +++ b/htdocs/opensurvey/wizard/create_survey.php @@ -93,7 +93,7 @@ $testdate = false; $champdatefin = (int) dol_mktime(23, 59, 59, GETPOSTINT('champdatefinmonth'), GETPOSTINT('champdatefinday'), GETPOSTINT('champdatefinyear')); - if ($champdatefin > 0) { // A date was provided, $error still 0 here + if ($champdatefin > 0) { // A date was provided // Expire date is not before today if ($champdatefin >= dol_now()) { $testdate = true; From 34b4b07fe21c35d476d2f7a3e1fb8023021c805b Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Tue, 12 Nov 2024 04:40:38 +0200 Subject: [PATCH 16/19] New: prepare for e-shipment (SQL part) (#31773) * Add issue date * Add field fk_unit * Add shipment contacts * New Add is_delivery_note SQL part * New fields for e-shipment SQL part * Update llx_facture.sql * Update 20.0.0-21.0.0.sql * Update 20.0.0-21.0.0.sql * Update llx_expedition.sql --------- Co-authored-by: Laurent Destailleur --- htdocs/install/mysql/data/llx_c_type_contact.sql | 5 +++++ htdocs/install/mysql/migration/20.0.0-21.0.0.sql | 5 +++++ htdocs/install/mysql/tables/llx_expedition.sql | 3 +-- htdocs/install/mysql/tables/llx_expeditiondet.sql | 13 +++++++------ 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_type_contact.sql b/htdocs/install/mysql/data/llx_c_type_contact.sql index 07178dacdcd64..b7e649559e949 100644 --- a/htdocs/install/mysql/data/llx_c_type_contact.sql +++ b/htdocs/install/mysql/data/llx_c_type_contact.sql @@ -73,6 +73,11 @@ insert into llx_c_type_contact (element, source, code, libelle, active ) values insert into llx_c_type_contact (element, source, code, libelle, active ) values ('commande', 'external', 'CUSTOMER', 'Contact client suivi commande', 1); insert into llx_c_type_contact (element, source, code, libelle, active ) values ('commande', 'external', 'SHIPPING', 'Contact client livraison commande', 1); +-- Shipment / Expedition +insert into llx_c_type_contact (element, source, code, libelle, active ) values ('expedition', 'external', 'SHIPPING', 'Loading facility', 1); +insert into llx_c_type_contact (element, source, code, libelle, active ) values ('expedition', 'external', 'SHIPPING', 'Delivery facility', 1); +insert into llx_c_type_contact (element, source, code, libelle, active ) values ('expedition', 'external', 'SHIPPING', 'Customer shipping contact', 1); + -- Intervention / Fichinter insert into llx_c_type_contact (element, source, code, libelle, active ) values ('fichinter', 'internal', 'INTERREPFOLL', 'Responsable suivi de l''intervention', 1); insert into llx_c_type_contact (element, source, code, libelle, active ) values ('fichinter', 'internal', 'INTERVENING', 'Intervenant', 1); diff --git a/htdocs/install/mysql/migration/20.0.0-21.0.0.sql b/htdocs/install/mysql/migration/20.0.0-21.0.0.sql index 5d8523c0dac74..6cc7b0bfa76b8 100644 --- a/htdocs/install/mysql/migration/20.0.0-21.0.0.sql +++ b/htdocs/install/mysql/migration/20.0.0-21.0.0.sql @@ -320,4 +320,9 @@ ALTER TABLE llx_c_tva ADD COLUMN fk_department_buyer integer DEFAULT NULL AFTER ALTER TABLE llx_c_tva ADD INDEX idx_tva_fk_department_buyer (fk_department_buyer); ALTER TABLE llx_c_tva ADD CONSTRAINT fk_tva_fk_department_buyer FOREIGN KEY (fk_department_buyer) REFERENCES llx_c_departements (rowid); +ALTER TABLE llx_expeditiondet ADD COLUMN fk_unit integer AFTER qty; +INSERT INTO llx_c_type_contact (element, source, code, libelle, active ) values ('expedition', 'external', 'SHIPPING', 'Loading facility', 1); +INSERT INTO llx_c_type_contact (element, source, code, libelle, active ) values ('expedition', 'external', 'SHIPPING', 'Delivery facility', 1); +INSERT INTO llx_c_type_contact (element, source, code, libelle, active ) values ('expedition', 'external', 'SHIPPING', 'Customer shipping contact', 1); + ALTER TABLE llx_facture_rec ADD COLUMN fk_societe_rib integer DEFAULT NULL; diff --git a/htdocs/install/mysql/tables/llx_expedition.sql b/htdocs/install/mysql/tables/llx_expedition.sql index 5743e9b454371..3c4cfb545f6ca 100644 --- a/htdocs/install/mysql/tables/llx_expedition.sql +++ b/htdocs/install/mysql/tables/llx_expedition.sql @@ -27,11 +27,10 @@ create table llx_expedition ref varchar(30) NOT NULL, entity integer DEFAULT 1 NOT NULL, -- multi company id fk_soc integer NOT NULL, - fk_projet integer DEFAULT NULL, + fk_projet integer DEFAULT NULL, ref_ext varchar(255), -- reference into an external system (not used by dolibarr) ref_customer varchar(255), -- customer number - date_creation datetime, -- date of creation fk_user_author integer, -- author of creation fk_user_modif integer, -- author of last change diff --git a/htdocs/install/mysql/tables/llx_expeditiondet.sql b/htdocs/install/mysql/tables/llx_expeditiondet.sql index 3fdda0c344289..be3cd6163186e 100644 --- a/htdocs/install/mysql/tables/llx_expeditiondet.sql +++ b/htdocs/install/mysql/tables/llx_expeditiondet.sql @@ -22,12 +22,13 @@ create table llx_expeditiondet ( rowid integer AUTO_INCREMENT PRIMARY KEY, - fk_expedition integer NOT NULL, -- ID of parent object - fk_element integer, -- ID of main source object - fk_elementdet integer, -- ID of line of source object (proposal, sale order) + fk_expedition integer NOT NULL, -- ID of parent object + fk_element integer, -- ID of main source object + fk_elementdet integer, -- ID of line of source object (proposal, sale order) element_type varchar(50) DEFAULT 'commande' NOT NULL, -- Type of source object ('commande', ...) - fk_product integer, -- ID of product. If empy, you can retreive it using fk_element/element_type link - qty real, -- Quantity - fk_entrepot integer, -- Warehouse for departure of product + fk_product integer, -- ID of product. If empy, you can retreive it using fk_element/element_type link + qty real, -- Quantity + fk_unit integer, -- ID of unit code + fk_entrepot integer, -- Warehouse for departure of product rang integer DEFAULT 0 )ENGINE=innodb; From 4a97adfc62c1aee046f47d6ed999bfdd3d649486 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Nov 2024 03:52:08 +0100 Subject: [PATCH 17/19] Add column is_also_delivery_note --- htdocs/install/mysql/migration/20.0.0-21.0.0.sql | 6 ++++-- htdocs/install/mysql/tables/llx_expedition.sql | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/install/mysql/migration/20.0.0-21.0.0.sql b/htdocs/install/mysql/migration/20.0.0-21.0.0.sql index 6cc7b0bfa76b8..d4d36ba7da46e 100644 --- a/htdocs/install/mysql/migration/20.0.0-21.0.0.sql +++ b/htdocs/install/mysql/migration/20.0.0-21.0.0.sql @@ -114,7 +114,7 @@ ALTER TABLE llx_bank_categ RENAME TO llx_category_bank; -- TODO Move content in ALTER TABLE llx_bank_class RENAME TO llx_category_bankline; -create table llx_paymentexpensereport_expensereport +CREATE TABLE llx_paymentexpensereport_expensereport ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_payment integer, @@ -257,7 +257,7 @@ ALTER TABLE llx_c_accounting_category ADD COLUMN fk_report integer NOT NULL DEFA ALTER TABLE llx_c_accounting_category DROP INDEX uk_c_accounting_category; ALTER TABLE llx_c_accounting_category ADD UNIQUE INDEX uk_c_accounting_category (code,entity,fk_report); -create table llx_accounting_category_account +CREATE TABLE llx_accounting_category_account ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_accounting_category integer, @@ -326,3 +326,5 @@ INSERT INTO llx_c_type_contact (element, source, code, libelle, active ) values INSERT INTO llx_c_type_contact (element, source, code, libelle, active ) values ('expedition', 'external', 'SHIPPING', 'Customer shipping contact', 1); ALTER TABLE llx_facture_rec ADD COLUMN fk_societe_rib integer DEFAULT NULL; + +ALTER TABLE llx_facture ADD COLUMN is_also_delivery_note tinyint DEFAULT 0 NOT NULL; diff --git a/htdocs/install/mysql/tables/llx_expedition.sql b/htdocs/install/mysql/tables/llx_expedition.sql index 3c4cfb545f6ca..f9ea867ee3176 100644 --- a/htdocs/install/mysql/tables/llx_expedition.sql +++ b/htdocs/install/mysql/tables/llx_expedition.sql @@ -63,6 +63,8 @@ create table llx_expedition fk_incoterms integer, -- for incoterms location_incoterms varchar(255), -- for incoterms - import_key varchar(14), - extraparams varchar(255) -- for other parameters with json format + is_also_delivery_note tinyint DEFAULT 0 NOT NULL, -- 0=default, 1=can act also as a delivery note (for countries that accept invoices as delivery notes) + + import_key varchar(14), -- import id when line is imported + extraparams varchar(255) -- for other parameters with json format )ENGINE=innodb; From 71a47c6555617eb9404d554f7c37cccdd2c64b64 Mon Sep 17 00:00:00 2001 From: JonathanBtq <99287239+Jonathanbtq@users.noreply.github.com> Date: Tue, 12 Nov 2024 04:00:37 +0100 Subject: [PATCH 18/19] add custom tpl to note (#31736) * add custom tpl to note * Update note.php --------- Co-authored-by: Laurent Destailleur --- htdocs/commande/note.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/commande/note.php b/htdocs/commande/note.php index dc22f09deea0c..572e741348fe6 100644 --- a/htdocs/commande/note.php +++ b/htdocs/commande/note.php @@ -146,7 +146,13 @@ $cssclass = "titlefield"; - include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; + $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); + foreach ($dirtpls as $reldir) { + $res = @include dol_buildpath($reldir.'/notes.tpl.php'); + if ($res) { + break; + } + } print '
'; From 5312bd80b926ff43040f27c057e98ef9a2159863 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Nov 2024 04:04:31 +0100 Subject: [PATCH 19/19] Doc --- htdocs/core/class/conf.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index cb5a97f8c7bd5..a86f0551bab29 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -378,7 +378,8 @@ public function __construct() 'hooks' => array(), 'dir' => array(), 'syslog' => array(), - 'websitetemplates' => array() + 'websitetemplates' => array(), + //'captcha' => array() // Can be removed,this does not generates warning ); // First level object that are modules.