diff --git a/dev/build/phpstan/phpstan-baseline.neon b/dev/build/phpstan/phpstan-baseline.neon index 60134c6002a..8e8123cefb0 100644 --- a/dev/build/phpstan/phpstan-baseline.neon +++ b/dev/build/phpstan/phpstan-baseline.neon @@ -13302,12 +13302,6 @@ parameters: count: 1 path: ../../../htdocs/core/modules/mrp/doc/pdf_vinci.modules.php - - - message: '#^Parameter \#4 \$columnText of method CommonDocGenerator\:\:printStdColumnContent\(\) expects string, float given\.$#' - identifier: argument.type - count: 2 - path: ../../../htdocs/core/modules/mrp/doc/pdf_vinci.modules.php - - message: '#^Property CommonDocGenerator\:\:\$cols \(array\\) does not accept non\-empty\-array\\.$#' identifier: assign.propertyType @@ -14262,18 +14256,6 @@ parameters: count: 1 path: ../../../htdocs/core/tpl/extrafields_list_search_title.tpl.php - - - message: '#^Variable \$sortfield might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/core/tpl/extrafields_list_search_title.tpl.php - - - - message: '#^Variable \$sortorder might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/core/tpl/extrafields_list_search_title.tpl.php - - message: '#^Left side of && is always true\.$#' identifier: booleanAnd.leftAlwaysTrue @@ -17556,24 +17538,6 @@ parameters: count: 1 path: ../../../htdocs/fourn/commande/dispatch.php - - - message: '#^Parameter \#4 \$month of function dol_mktime expects int, array\\|string given\.$#' - identifier: argument.type - count: 2 - path: ../../../htdocs/fourn/commande/dispatch.php - - - - message: '#^Parameter \#5 \$day of function dol_mktime expects int, array\\|string given\.$#' - identifier: argument.type - count: 2 - path: ../../../htdocs/fourn/commande/dispatch.php - - - - message: '#^Parameter \#6 \$year of function dol_mktime expects int, array\\|string given\.$#' - identifier: argument.type - count: 2 - path: ../../../htdocs/fourn/commande/dispatch.php - - message: '#^Right side of && is always false\.$#' identifier: booleanAnd.rightAlwaysFalse @@ -20928,54 +20892,6 @@ parameters: count: 3 path: ../../../htdocs/mrp/class/api_mos.class.php - - - message: '#^Method Mos\:\:_validate\(\) has parameter \$data with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: ../../../htdocs/mrp/class/api_mos.class.php - - - - message: '#^Method Mos\:\:_validate\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: ../../../htdocs/mrp/class/api_mos.class.php - - - - message: '#^Method Mos\:\:delete\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: ../../../htdocs/mrp/class/api_mos.class.php - - - - message: '#^Method Mos\:\:index\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: ../../../htdocs/mrp/class/api_mos.class.php - - - - message: '#^Method Mos\:\:post\(\) has parameter \$request_data with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: ../../../htdocs/mrp/class/api_mos.class.php - - - - message: '#^Method Mos\:\:produceAndConsume\(\) has parameter \$request_data with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: ../../../htdocs/mrp/class/api_mos.class.php - - - - message: '#^Method Mos\:\:produceAndConsumeAll\(\) has parameter \$request_data with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: ../../../htdocs/mrp/class/api_mos.class.php - - - - message: '#^Method Mos\:\:put\(\) has parameter \$request_data with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: ../../../htdocs/mrp/class/api_mos.class.php - - message: '#^Negated boolean expression is always true\.$#' identifier: booleanNot.alwaysTrue @@ -21150,12 +21066,6 @@ parameters: count: 1 path: ../../../htdocs/mrp/mo_card.php - - - message: '#^Variable \$titlelist might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/mrp/mo_card.php - - message: '#^If condition is always false\.$#' identifier: if.alwaysFalse @@ -21186,12 +21096,6 @@ parameters: count: 1 path: ../../../htdocs/mrp/mo_movements.php - - - message: '#^Variable \$movement might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/mrp/mo_movements.php - - message: '#^Variable \$text might not be defined\.$#' identifier: variable.undefined @@ -21324,41 +21228,12 @@ parameters: count: 1 path: ../../../htdocs/opcachepreload.php - - - message: '#^Parameter \#4 \$month of function dol_mktime expects int, array\\|string given\.$#' - identifier: argument.type - count: 1 - path: ../../../htdocs/opensurvey/card.php - - - - message: '#^Parameter \#5 \$day of function dol_mktime expects int, array\\|string given\.$#' - identifier: argument.type - count: 1 - path: ../../../htdocs/opensurvey/card.php - - - - message: '#^Parameter \#6 \$year of function dol_mktime expects int, array\\|string given\.$#' - identifier: argument.type - count: 1 - path: ../../../htdocs/opensurvey/card.php - - message: '#^Variable \$id might not be defined\.$#' identifier: variable.undefined count: 1 path: ../../../htdocs/opensurvey/card.php - - - message: '#^Variable \$userstatic might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../../htdocs/opensurvey/card.php - - - - message: '#^PHPDoc type .* is not covariant with PHPDoc type array of overridden property CommonObject::\$lines\.$#' - count: 1 - path: ../../../htdocs/opensurvey/class/opensurveysondage.class.php - - message: '#^If condition is always false\.$#' identifier: if.alwaysFalse @@ -21372,14 +21247,14 @@ parameters: path: ../../../htdocs/opensurvey/class/opensurveysondage.class.php - - message: '#^Method Opensurveysondage\:\:fetchAll\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Negated boolean expression is always true\.$#' + identifier: booleanNot.alwaysTrue count: 1 path: ../../../htdocs/opensurvey/class/opensurveysondage.class.php - - message: '#^Negated boolean expression is always true\.$#' - identifier: booleanNot.alwaysTrue + message: '#^PHPDoc type array\\> of property Opensurveysondage\:\:\$lines is not covariant with PHPDoc type array\ of overridden property CommonObject\:\:\$lines\.$#' + identifier: property.phpDocType count: 1 path: ../../../htdocs/opensurvey/class/opensurveysondage.class.php @@ -21443,12 +21318,6 @@ parameters: count: 1 path: ../../../htdocs/opensurvey/results.php - - - message: '#^Variable \$cleinsertion might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../../htdocs/opensurvey/results.php - - message: '#^Variable \$erreur_ajout_date in isset\(\) always exists and is not nullable\.$#' identifier: isset.variable @@ -21461,42 +21330,6 @@ parameters: count: 1 path: ../../../htdocs/opensurvey/results.php - - - message: '#^Variable \$meilleurecolonne might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/opensurvey/results.php - - - - message: '#^Variable \$modifier might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/opensurvey/results.php - - - - message: '#^Variable \$userstatic might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/opensurvey/results.php - - - - message: '#^Variable \$allow_comments might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/opensurvey/wizard/create_survey.php - - - - message: '#^Variable \$allow_spy might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/opensurvey/wizard/create_survey.php - - - - message: '#^Variable \$champdatefin might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/opensurvey/wizard/create_survey.php - - message: '#^Left side of && is always false\.$#' identifier: booleanAnd.leftAlwaysFalse @@ -23597,24 +23430,6 @@ parameters: count: 1 path: ../../../htdocs/product/stock/tpl/extrafields_add.tpl.php - - - message: '#^Parameter \#4 \$month of function dol_mktime expects int, array\\|string given\.$#' - identifier: argument.type - count: 2 - path: ../../../htdocs/product/stock/tpl/stockcorrection.tpl.php - - - - message: '#^Parameter \#5 \$day of function dol_mktime expects int, array\\|string given\.$#' - identifier: argument.type - count: 2 - path: ../../../htdocs/product/stock/tpl/stockcorrection.tpl.php - - - - message: '#^Parameter \#6 \$year of function dol_mktime expects int, array\\|string given\.$#' - identifier: argument.type - count: 2 - path: ../../../htdocs/product/stock/tpl/stockcorrection.tpl.php - - message: '#^Ternary operator condition is always false\.$#' identifier: ternary.alwaysFalse @@ -24143,30 +23958,6 @@ parameters: count: 1 path: ../../../htdocs/projet/element.php - - - message: '#^PHPDoc tag @var has invalid value \(\$loanSchedule LoanSchedule\)\: Unexpected token "\$loanSchedule", expected type at offset 20 on line 2$#' - identifier: phpDoc.parseError - count: 1 - path: ../../../htdocs/projet/element.php - - - - message: '#^Parameter \#4 \$month of function dol_mktime expects int, array\\|string given\.$#' - identifier: argument.type - count: 2 - path: ../../../htdocs/projet/element.php - - - - message: '#^Parameter \#5 \$day of function dol_mktime expects int, array\\|string given\.$#' - identifier: argument.type - count: 2 - path: ../../../htdocs/projet/element.php - - - - message: '#^Parameter \#6 \$year of function dol_mktime expects int, array\\|string given\.$#' - identifier: argument.type - count: 2 - path: ../../../htdocs/projet/element.php - - message: '#^Variable \$margin in isset\(\) always exists and is not nullable\.$#' identifier: isset.variable @@ -26141,24 +25932,6 @@ parameters: count: 1 path: ../../../htdocs/reception/dispatch.php - - - message: '#^Parameter \#4 \$month of function dol_mktime expects int, array\\|string given\.$#' - identifier: argument.type - count: 4 - path: ../../../htdocs/reception/dispatch.php - - - - message: '#^Parameter \#5 \$day of function dol_mktime expects int, array\\|string given\.$#' - identifier: argument.type - count: 4 - path: ../../../htdocs/reception/dispatch.php - - - - message: '#^Parameter \#6 \$year of function dol_mktime expects int, array\\|string given\.$#' - identifier: argument.type - count: 4 - path: ../../../htdocs/reception/dispatch.php - - message: '#^Variable \$modebatch might not be defined\.$#' identifier: variable.undefined diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 3f0f9365f25..e4d6b885ce3 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -9,35 +9,35 @@ */ return [ // # Issue statistics: - // PhanTypeMismatchArgument : 2300+ occurrences - // PhanUndeclaredProperty : 530+ occurrences - // PhanTypeMismatchArgumentNullable : 430+ occurrences - // PhanUndeclaredGlobalVariable : 190+ occurrences + // PhanTypeMismatchArgument : 2050+ occurrences + // PhanUndeclaredProperty : 520+ occurrences + // PhanTypeMismatchArgumentNullable : 410+ occurrences + // PhanUndeclaredGlobalVariable : 180+ occurrences // PhanPluginUnknownArrayMethodReturnType : 170+ occurrences - // PhanPossiblyUndeclaredGlobalVariable : 150+ occurrences // PhanTypeMismatchProperty : 130+ occurrences - // PhanTypeMismatchArgumentProbablyReal : 120+ occurrences + // PhanPossiblyUndeclaredGlobalVariable : 120+ occurrences // PhanPluginUnknownArrayMethodParamType : 110+ occurrences + // PhanTypeMismatchArgumentProbablyReal : 110+ occurrences // PhanRedefineFunction : 40+ occurrences // PhanTypeExpectedObjectPropAccess : 40+ occurrences // PhanTypeInvalidDimOffset : 25+ occurrences // PhanPluginUndeclaredVariableIsset : 20+ occurrences // PhanTypeMismatchDimFetch : 20+ occurrences // PhanUndeclaredConstant : 15+ occurrences - // PhanTypeComparisonFromArray : 10+ occurrences // PhanTypeMismatchArgumentNullableInternal : 10+ occurrences // PhanUndeclaredMethod : 10+ occurrences + // PhanTypeComparisonFromArray : 9 occurrences // PhanPluginSuspiciousParamPosition : 7 occurrences - // PhanPluginUnknownObjectMethodCall : 7 occurrences // PhanPluginDuplicateExpressionBinaryOp : 6 occurrences - // PhanPluginEmptyStatementIf : 6 occurrences + // PhanPluginUnknownObjectMethodCall : 6 occurrences // PhanTypeArraySuspiciousNull : 6 occurrences // PhanParamTooMany : 5 occurrences // PhanEmptyForeach : 4 occurrences - // PhanPluginBothLiteralsBinaryOp : 4 occurrences // PhanPluginDuplicateArrayKey : 4 occurrences + // PhanPluginEmptyStatementIf : 4 occurrences // PhanEmptyFQSENInClasslike : 3 occurrences // PhanInvalidFQSENInClasslike : 3 occurrences + // PhanPluginBothLiteralsBinaryOp : 3 occurrences // PhanTypeMismatchDimAssignment : 2 occurrences // PhanTypeMismatchDimFetchNullable : 2 occurrences // PhanTypeSuspiciousStringExpression : 2 occurrences @@ -305,7 +305,6 @@ return [ 'htdocs/contrat/class/contratligne.class.php' => ['PhanTypeMismatchArgument'], 'htdocs/contrat/contact.php' => ['PhanTypeMismatchArgument'], 'htdocs/contrat/document.php' => ['PhanTypeMismatchArgument'], - 'htdocs/contrat/index.php' => ['PhanTypeMismatchArgument'], 'htdocs/contrat/list.php' => ['PhanTypeMismatchArgument'], 'htdocs/contrat/messaging.php' => ['PhanTypeMismatchArgument'], 'htdocs/contrat/note.php' => ['PhanTypeMismatchArgument'], @@ -350,7 +349,7 @@ return [ 'htdocs/core/class/hookmanager.class.php' => ['PhanUndeclaredProperty'], 'htdocs/core/class/html.form.class.php' => ['PhanTypeMismatchArgumentNullable'], 'htdocs/core/class/html.formcompany.class.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], - 'htdocs/core/class/html.formfile.class.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], + 'htdocs/core/class/html.formfile.class.php' => ['PhanTypeMismatchArgument'], 'htdocs/core/class/html.formmail.class.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], 'htdocs/core/class/html.formother.class.php' => ['PhanTypeMismatchArgument'], 'htdocs/core/class/html.formprojet.class.php' => ['PhanTypeMismatchArgument'], @@ -593,52 +592,18 @@ return [ 'htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php' => ['PhanUndeclaredProperty'], 'htdocs/partnership/partnership_card.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/partnership/partnership_list.php' => ['PhanUndeclaredProperty'], - 'htdocs/product/admin/price_rules.php' => ['PhanTypeMismatchArgument'], - 'htdocs/product/admin/product.php' => ['PhanPluginEmptyStatementIf', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/product/admin/product_tools.php' => ['PhanTypeMismatchArgument'], - 'htdocs/product/ajax/products.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/product/canvas/product/actions_card_product.class.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'], - 'htdocs/product/canvas/service/actions_card_service.class.php' => ['PhanTypeMismatchArgument'], - 'htdocs/product/card.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanUndeclaredGlobalVariable'], 'htdocs/product/class/api_products.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], 'htdocs/product/class/html.formproduct.class.php' => ['PhanUndeclaredProperty'], - 'htdocs/product/class/product.class.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'], - 'htdocs/product/class/productcustomerprice.class.php' => ['PhanTypeMismatchArgument'], 'htdocs/product/class/productfournisseurprice.class.php' => ['PhanUndeclaredMethod', 'PhanUndeclaredProperty'], - 'htdocs/product/composition/card.php' => ['PhanTypeMismatchArgument'], - 'htdocs/product/document.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullable'], - 'htdocs/product/dynamic_price/class/price_parser.class.php' => ['PhanTypeMismatchArgument'], - 'htdocs/product/index.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanTypeMismatchArgument'], - 'htdocs/product/inventory/ajax/searchfrombarcode.php' => ['PhanTypeMismatchArgument'], - 'htdocs/product/inventory/card.php' => ['PhanPluginEmptyStatementIf', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullable'], 'htdocs/product/inventory/class/inventory.class.php' => ['PhanUndeclaredProperty'], - 'htdocs/product/inventory/inventory.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/product/inventory/list.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/product/list.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'], - 'htdocs/product/price.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], - 'htdocs/product/price_suppliers.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'], + 'htdocs/product/price.php' => ['PhanUndeclaredProperty'], 'htdocs/product/reassort.php' => ['PhanTypeExpectedObjectPropAccessButGotNull'], - 'htdocs/product/stats/card.php' => ['PhanTypeComparisonFromArray', 'PhanTypeMismatchArgument'], - 'htdocs/product/stats/commande.php' => ['PhanTypeMismatchArgument'], - 'htdocs/product/stats/commande_fournisseur.php' => ['PhanTypeMismatchArgument'], - 'htdocs/product/stats/contrat.php' => ['PhanTypeMismatchArgument'], - 'htdocs/product/stats/expedition.php' => ['PhanTypeMismatchArgument'], - 'htdocs/product/stats/facture_fournisseur.php' => ['PhanTypeMismatchArgument'], - 'htdocs/product/stats/facturerec.php' => ['PhanTypeMismatchArgument'], - 'htdocs/product/stats/mo.php' => ['PhanTypeMismatchArgument'], - 'htdocs/product/stats/propal.php' => ['PhanTypeMismatchArgument'], - 'htdocs/product/stats/reception.php' => ['PhanTypeMismatchArgument'], - 'htdocs/product/stats/supplier_proposal.php' => ['PhanTypeMismatchArgument'], - 'htdocs/product/stock/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'], 'htdocs/product/stock/class/api_stockmovements.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgument'], 'htdocs/product/stock/class/api_warehouses.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], - 'htdocs/product/stock/class/entrepot.class.php' => ['PhanUndeclaredProperty'], - 'htdocs/product/stock/class/mouvementstock.class.php' => ['PhanTypeMismatchArgument'], - 'htdocs/product/stock/info.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanTypeMismatchArgument', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], - 'htdocs/product/stock/list.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], - 'htdocs/product/stock/massstockmove.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'], - 'htdocs/product/stock/movement_card.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], - 'htdocs/product/stock/movement_list.php' => ['PhanPluginBothLiteralsBinaryOp', 'PhanPluginUndeclaredVariableIsset', 'PhanTypeMismatchArgument', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], + 'htdocs/product/stock/info.php' => ['PhanUndeclaredProperty'], + 'htdocs/product/stock/list.php' => ['PhanUndeclaredProperty'], + 'htdocs/product/stock/movement_card.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], + 'htdocs/product/stock/movement_list.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/product/stock/product.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'], 'htdocs/product/stock/productlot_card.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], 'htdocs/product/stock/productlot_list.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], diff --git a/dev/tools/phan/config_fixer.php b/dev/tools/phan/config_fixer.php index e9a0fa36763..521cbcbedbf 100644 --- a/dev/tools/phan/config_fixer.php +++ b/dev/tools/phan/config_fixer.php @@ -15,7 +15,8 @@ $config = include __DIR__.DIRECTORY_SEPARATOR."config.php"; //require_once __DIR__.'/plugins/UrlEncodeStringifyFixer.php'; //require_once __DIR__.'/plugins/SelectDateFixer.php'; //require_once __DIR__.'/plugins/setPageOrientationFixer.php'; -require_once __DIR__.'/plugins/textwithpictoFixer.php'; +//require_once __DIR__.'/plugins/textwithpictoFixer.php'; +require_once __DIR__.'/plugins/ifsqlFixer.php'; //require_once __DIR__.'/plugins/MultiCellFixer.php'; //require_once __DIR__.'/plugins/setAutoPageBreakFixer.php'; //require_once __DIR__.'/plugins/CellFixer.php'; diff --git a/dev/tools/phan/plugins/ifsqlFixer.php b/dev/tools/phan/plugins/ifsqlFixer.php new file mode 100644 index 00000000000..ba97b719c24 --- /dev/null +++ b/dev/tools/phan/plugins/ifsqlFixer.php @@ -0,0 +1,177 @@ + + * + * For 'price()', replace $form parameter that is '' with 0. + */ + +declare(strict_types=1); + +use ast\flags; +use Microsoft\PhpParser\Node\Expression\CallExpression; +use Microsoft\PhpParser\Node\QualifiedName; +use Phan\AST\TolerantASTConverter\NodeUtils; +use Phan\CodeBase; +use Phan\IssueInstance; +use Phan\Library\FileCacheEntry; +use Phan\Plugin\Internal\IssueFixingPlugin\FileEdit; +use Phan\Plugin\Internal\IssueFixingPlugin\FileEditSet; +use Phan\Plugin\Internal\IssueFixingPlugin\IssueFixer; +use Microsoft\PhpParser\Node\Expression\ArgumentExpression; +use Microsoft\PhpParser\Node\DelimitedList\ArgumentExpressionList; +use Microsoft\PhpParser\Node\StringLiteral; +use Microsoft\PhpParser\Node\NumericLiteral; +use Microsoft\PhpParser\Node\ReservedWord; +use Microsoft\PhpParser\Token; + +/** + * This is a prototype, there are various features it does not implement. + */ + +call_user_func(static function (): void { + /** + * @param $code_base @unused-param + * @return ?FileEditSet a representation of the edit to make to replace a call to a function alias with a call to the original function + */ + $fix = static function (CodeBase $code_base, FileCacheEntry $contents, IssueInstance $instance): ?FileEditSet { + + // Argument {INDEX} (${PARAMETER}) is {CODE} of type {TYPE}{DETAILS} but + // {FUNCTIONLIKE} takes {TYPE}{DETAILS} defined at {FILE}:{LINE} (the inferred real argument type has nothing in common with the parameter's phpdoc type) + + //htdocs\supplier_proposal\card.php:1705 PhanTypeMismatchArgumentProbablyReal Argument 3 ($h) is '' of type '' but \Form::selectDate() takes int (no real type) defined at htdocs\core\class\html.form.class.php:6799 (the inferred real argument type has nothing in common with the parameter's phpdoc type) + //htdocs\supplier_proposal\card.php:1705 PhanTypeMismatchArgumentProbablyReal Argument 4 ($m) is '' of type '' but \Form::selectDate() takes int (no real type) defined at htdocs\core\class\html.form.class.php:6799 (the inferred real argument type has nothing in common with the parameter's phpdoc type) + // var_dump($instance->getTemplateParameters()); + $argument_index = (string) $instance->getTemplateParameters()[0]; + $argument_name = (string) $instance->getTemplateParameters()[1]; + $argument_code = (string) $instance->getTemplateParameters()[2]; + $argument_type = (string) $instance->getTemplateParameters()[3]; + $functionlike = (string) $instance->getTemplateParameters()[4]; + $functiontype = (string) $instance->getTemplateParameters()[5]; + + $expected_functionlike = "\\DoliDB::ifsql()"; + $expected_name = "ifsql"; + if ($functionlike !== $expected_functionlike) { + //print "$functionlike != '$expected_functionlike'".PHP_EOL; + return null; + } + + $toBoolReplaceArray = array("0" => "'0'","1" => "'1'","-1" => "'-1'"); + // Check if we fix any of this + if ( + (in_array($argument_name, ['resok','resko']) && in_array($argument_code, array_keys($toBoolReplaceArray))) + //|| ($argument_name === 'm' && $argument_code === "''") + //|| ($argument_name === 'empty' && $argument_code === "''") + ) { + $replacement = $toBoolReplaceArray[$argument_code]; + $argIdx = ($argument_index - 1) * 2; + $expectedStringValue = $argument_code; + } else { + print "ARG$argument_index:$argument_name CODE:$argument_name".PHP_EOL; + return null; + } + + // At this point we established that the notification + // matches some we fix. + + $line = $instance->getLine(); + + $edits = []; + foreach ($contents->getNodesAtLine($line) as $node) { + if (!$node instanceof ArgumentExpressionList) { + continue; + } + $arguments = $node->children; + if (count($arguments) <= $argIdx) { + // print "Arg Count is ".count($arguments)." - Skip $instance".PHP_EOL; + continue; + } + + $is_actual_call = $node->parent instanceof CallExpression; + if (!$is_actual_call) { + // print "Not actual call - Skip $instance".PHP_EOL; + continue; + } + + print "Actual call - $instance".PHP_EOL; + $callable = $node->parent; + + $callableExpression = $callable->callableExpression; + + if ($callableExpression instanceof Microsoft\PhpParser\Node\QualifiedName) { + $actual_name = $callableExpression->getResolvedName(); + } elseif ($callableExpression instanceof Microsoft\PhpParser\Node\Expression\MemberAccessExpression) { + $memberNameToken = $callableExpression->memberName; + $actual_name = (new NodeUtils($contents->getContents()))->tokenToString($memberNameToken); + } else { + print "Callable expression is ".get_class($callableExpression)."- Skip $instance".PHP_EOL; + continue; + } + + if ((string) $actual_name !== (string) $expected_name) { + // print "Name unexpected '$actual_name'!='$expected_name' - Skip $instance".PHP_EOL; + continue; + } + + foreach ($arguments as $i => $argument) { + if ($argument instanceof ArgumentExpression) { + // print "Type$i: ".get_class($argument->expression).PHP_EOL; + } + } + + $fieldValue = null; + + + $arg = $arguments[$argIdx]; + + if ( + $arg instanceof ArgumentExpression + && $arg->expression instanceof NumericLiteral + ) { + // Get the string value of the NumericLiteral + $fieldValue = (string) $arg->expression; + //print "Field is '$fieldValue'".PHP_EOL; + } elseif ($arg instanceof ArgumentExpression && $arg->expression instanceof ReservedWord) { + $child = $arg->expression->children; + if (!$child instanceof Token) { + continue; + } + $token_str = (new NodeUtils($contents->getContents()))->tokenToString($child); + print "$token_str KIND:".($child->kind ?? 'no kind')." ".get_class($child).PHP_EOL; + + if ($token_str !== 'null') { + continue; + } + + $fieldValue = ''; // Fake empty + } else { + // print "Expression is not expected type ".get_class($arg)."/".get_class($arg->expression)."- Skip $instance".PHP_EOL; + continue; + } + + if ($fieldValue !== $expectedStringValue) { + // print "Not replacing '$argument_name' which is '$fieldValue'/".get_class($arg)."/".get_class($arg->expression)."- Skip $instance".PHP_EOL; + continue; + } + + print "Fixture elem on $line - $actual_name(...'$fieldValue'...) - $instance".PHP_EOL; + + + + // Get the first argument (delimiter) + $argument_to_replace = $arg; + + $arg_start_pos = $argument_to_replace->getStartPosition(); + $arg_end_pos = $argument_to_replace->getEndPosition(); + + // Set edit instruction + $edits[] = new FileEdit($arg_start_pos, $arg_end_pos, $replacement); + } + if ($edits) { + return new FileEditSet($edits); + } + return null; + }; + IssueFixer::registerFixerClosure( + 'PhanTypeMismatchArgument', + $fix + ); +}); diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index e1934a31b0e..d2217e62654 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -5,6 +5,7 @@ * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -429,10 +430,10 @@ if ($resql) { $cursoryear = ($cursormonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y; $tmp = dol_getdate(dol_get_last_day($cursoryear, $cursormonth, 'gmt'), false, 'gmt'); - print ''; - print price($row[2*$i - 2]); + print ''; + print price($row[2 * $i - 2]); // Add link to make binding - if (!empty(price2num($row[2*$i - 2])) || !empty($row[2*$i - 1])) { + if (!empty(price2num($row[2 * $i - 2])) || !empty($row[2 * $i - 1])) { print ''; print img_picto($langs->trans("ValidateHistory").' ('.$langs->trans('Month'.str_pad((string) $cursormonth, 2, '0', STR_PAD_LEFT)).' '.$cursoryear.')', 'link', 'class="marginleft2"'); print ''; @@ -672,7 +673,7 @@ if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This pa " (-1 * (abs(fd.total_ht) - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100))))", // TODO This is bugged, we must use the percent for the invoice and fd.situation_percent is cumulated percent ! " (fd.total_ht - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100)))" ).")", - 0 + '0' ).") AS month".str_pad((string) $j, 2, '0', STR_PAD_LEFT).","; } $sql .= " SUM(".$db->ifsql( @@ -694,7 +695,7 @@ if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This pa " (-1 * (abs(fd.total_ht) - (fd.buy_price_ht * fd.qty)))", " (fd.total_ht - (fd.buy_price_ht * fd.qty))" ).")", - 0 + '0' ).") AS month".str_pad((string) $j, 2, '0', STR_PAD_LEFT).","; } $sql .= " SUM(".$db->ifsql( diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 13c6119e9f8..44eb8af5724 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2018-2024 Alexandre Spangaro * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Jose MARTINEZ * * This program is free software; you can redistribute it and/or modify @@ -713,7 +713,7 @@ class Asset extends CommonObject */ $sql = "SELECT ad.rowid, ad.depreciation_mode, ad.ref, ad.depreciation_date, ad.depreciation_ht, ad.cumulative_depreciation_ht"; - $sql .= ", " . $this->db->ifsql('iab.fk_docdet IS NOT NULL', 1, 0) . " AS bookkeeping"; + $sql .= ", " . $this->db->ifsql('iab.fk_docdet IS NOT NULL', '1', '0') . " AS bookkeeping"; $sql .= " FROM " . MAIN_DB_PREFIX . "asset_depreciation AS ad"; $sql .= " LEFT JOIN (SELECT DISTINCT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE doc_type = 'asset') AS iab ON iab.fk_docdet = ad.rowid"; $sql .= " WHERE ad.fk_asset = " . (int) $this->id; diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index def20558866..1ce3201aa9c 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -6,7 +6,7 @@ * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2013 Florian Henry * Copyright (C) 2017 Juanjo Menent - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -153,7 +153,7 @@ print ''; if ($filtertype != 1) { // Product if (getDolGlobalInt('PRODUCT_USE_UNITS')) { // For product, unit is shown only if option PRODUCT_USE_UNITS is on print ''; - $label = measuringUnitString($line->fk_unit, '', '', 1); + $label = measuringUnitString((int) $line->fk_unit, '', null, 1); if ($label !== '') { print $langs->trans($label); } @@ -359,7 +359,7 @@ if ($resql) { $total_cost += $sub_bom->total_cost * $sub_bom_line->qty * (float) $line->qty; } elseif ($sub_bom_product->type == Product::TYPE_SERVICE && isModEnabled('workstation') && !empty($sub_bom_product->fk_default_workstation)) { //Convert qty to hour - $unit = measuringUnitString($sub_bom_line->fk_unit, '', '', 1); + $unit = measuringUnitString($sub_bom_line->fk_unit, '', null, 1); $qty = convertDurationtoHour($sub_bom_line->qty, $unit); $workstation = new Workstation($this->db); $res = $workstation->fetch($sub_bom_product->fk_default_workstation); diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index be2f81dc20f..1906560455c 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2019 Nicolas ZABOURI - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Alexandre Spangaro * Copyright (C) 2024 Frédéric France * @@ -328,11 +328,11 @@ print '
'; // Last modified contracts $sql = 'SELECT '; -$sql .= " sum(".$db->ifsql("cd.statut=0", 1, 0).') as nb_initial,'; -$sql .= " sum(".$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite >= '".$db->idate($now)."')", 1, 0).') as nb_running,'; -$sql .= " sum(".$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now)."')", 1, 0).') as nb_expired,'; -$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 .= " sum(".$db->ifsql("cd.statut=0", '1', '0').') as nb_initial,'; +$sql .= " sum(".$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite >= '".$db->idate($now)."')", '1', '0').') as nb_running,'; +$sql .= " sum(".$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now)."')", '1', '0').') as nb_expired,'; +$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 as code_compta_client, s.code_compta_fournisseur"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,"; diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 5dc7e793af9..52557b35668 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -9,7 +9,7 @@ * Copyright (C) 2016-2018 Ferran Marcet * Copyright (C) 2019 Nicolas Zabouri * Copyright (C) 2021-2024 Alexandre Spangaro - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * Copyright (C) 2024 Benjamin Falière * @@ -325,11 +325,11 @@ $sql .= " state.code_departement as state_code, state.nom as state_name,"; // TODO Add a denormalized field "denormalized_lower_planned_end_date" so we can remove the HAVING and then, // remove completely the SUM and GROUP BY (faster). Status of each service can be read into the loop that build the list. $sql .= " MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") as lower_planned_end_date,"; // lowest expiration date among open service lines -$sql .= " SUM(".$db->ifsql("cd.statut=0", 1, 0).') as nb_initial,'; -$sql .= " SUM(".$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite >= '".$db->idate($now)."')", 1, 0).') as nb_running,'; -$sql .= " SUM(".$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now)."')", 1, 0).') as nb_expired,'; -$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 .= " SUM(".$db->ifsql("cd.statut=0", '1', '0').') as nb_initial,'; +$sql .= " SUM(".$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite >= '".$db->idate($now)."')", '1', '0').') as nb_running,'; +$sql .= " SUM(".$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now)."')", '1', '0').') as nb_expired,'; +$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'; // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 65f87ed9870..4bb9a8fbb08 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -7,7 +7,7 @@ * Copyright (C) 2016-2023 Charlene Benke * Copyright (C) 2018-2025 Frédéric France * Copyright (C) 2020 Josep Lluís Amador - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Mélina Joum * Copyright (C) 2024 Nick Fragoulis * @@ -1055,7 +1055,7 @@ abstract class CommonDocGenerator $array_key.'_tracking_number' => $object->tracking_number, $array_key.'_tracking_url' => $object->tracking_url, $array_key.'_shipping_method' => $object->listmeths[0]['libelle'], - $array_key.'_weight' => $object->trueWeight.' '.measuringUnitString(0, 'weight', (string) $object->weight_units), + $array_key.'_weight' => $object->trueWeight.' '.measuringUnitString(0, 'weight', $object->weight_units), $array_key.'_width' => $object->trueWidth.' '.measuringUnitString(0, 'size', $object->width_units), $array_key.'_height' => $object->trueHeight.' '.measuringUnitString(0, 'size', $object->height_units), $array_key.'_depth' => $object->trueDepth.' '.measuringUnitString(0, 'size', $object->depth_units), @@ -1092,31 +1092,31 @@ abstract class CommonDocGenerator // Set trueVolume and volume_units not currently stored into database if ($object->trueWidth && $object->trueHeight && $object->trueDepth) { - $object->trueVolume = $object->trueWidth * $object->trueHeight * $object->trueDepth; - $object->volume_units = $object->size_units * 3; + $object->trueVolume = $object->trueWidth * $object->trueHeight * $object->trueDepth; + $object->volume_units = $object->size_units * 3; } $array_shipment[$array_key.'_total_ordered'] = (string) $totalOrdered; $array_shipment[$array_key.'_total_toship'] = (string) $totalToShip; if ($object->trueWeight) { - $array_shipment[$array_key.'_total_weight'] = (empty($totalWeight)) ? '' : showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); + $array_shipment[$array_key.'_total_weight'] = (empty($totalWeight)) ? '' : showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); } elseif (!empty($totalWeight)) { - $array_shipment[$array_key.'_total_weight'] = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs, -1, 'no', 1); + $array_shipment[$array_key.'_total_weight'] = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs, -1, 'no', 1); } else { - $array_shipment[$array_key.'_total_weight'] = ""; + $array_shipment[$array_key.'_total_weight'] = ""; } if (!empty($object->trueVolume)) { if ($object->volume_units < 50) { - $array_shipment[$array_key.'_total_volume'] = (empty($totalVolume)) ? '' : showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); + $array_shipment[$array_key.'_total_volume'] = (empty($totalVolume)) ? '' : showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); } else { - $array_shipment[$array_key.'_total_volume'] = (empty($totalVolume)) ? '' : price($object->trueVolume, 0, $outputlangs, 0, 0).' '.measuringUnitString(0, "volume", $object->volume_units); + $array_shipment[$array_key.'_total_volume'] = (empty($totalVolume)) ? '' : price($object->trueVolume, 0, $outputlangs, 0, 0).' '.measuringUnitString(0, "volume", $object->volume_units); } } elseif (!empty($totalVolume)) { - $array_shipment[$array_key.'_total_volume'] = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1); + $array_shipment[$array_key.'_total_volume'] = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1); } else { - $array_shipment[$array_key.'_total_volume'] = ""; + $array_shipment[$array_key.'_total_volume'] = ""; } return $array_shipment; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 3758c0c3d6c..b8b04f032aa 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4558,10 +4558,11 @@ abstract class CommonObject $deletetarget = true; } + $element = $this->getElementType(); $sourceid = (!empty($sourceid) ? $sourceid : $this->id); - $sourcetype = (!empty($sourcetype) ? $sourcetype : $this->element); + $sourcetype = (!empty($sourcetype) ? $sourcetype : $element); $targetid = (!empty($targetid) ? $targetid : $this->id); - $targettype = (!empty($targettype) ? $targettype : $this->element); + $targettype = (!empty($targettype) ? $targettype : $element); $this->db->begin(); $error = 0; @@ -4587,14 +4588,14 @@ abstract class CommonObject } else { if ($deletesource) { $sql .= " fk_source = " . ((int) $sourceid) . " AND sourcetype = '" . $this->db->escape($sourcetype) . "'"; - $sql .= " AND fk_target = " . ((int) $this->id) . " AND targettype = '" . $this->db->escape($this->element) . "'"; + $sql .= " AND fk_target = " . ((int) $this->id) . " AND targettype = '" . $this->db->escape($element) . "'"; } elseif ($deletetarget) { $sql .= " fk_target = " . ((int) $targetid) . " AND targettype = '" . $this->db->escape($targettype) . "'"; - $sql .= " AND fk_source = " . ((int) $this->id) . " AND sourcetype = '" . $this->db->escape($this->element) . "'"; + $sql .= " AND fk_source = " . ((int) $this->id) . " AND sourcetype = '" . $this->db->escape($element) . "'"; } else { - $sql .= " (fk_source = " . ((int) $this->id) . " AND sourcetype = '" . $this->db->escape($this->element) . "')"; + $sql .= " (fk_source = " . ((int) $this->id) . " AND sourcetype = '" . $this->db->escape($element) . "')"; $sql .= " OR"; - $sql .= " (fk_target = " . ((int) $this->id) . " AND targettype = '" . $this->db->escape($this->element) . "')"; + $sql .= " (fk_target = " . ((int) $this->id) . " AND targettype = '" . $this->db->escape($element) . "')"; } } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 149e23b3f9f..ac2eb622bd2 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -81,6 +81,7 @@ class Form public $cache_types_paiements = array(); public $cache_conditions_paiements = array(); public $cache_transport_mode = array(); + /** @var array */ public $cache_availability = array(); public $cache_demand_reason = array(); public $cache_types_fees = array(); @@ -204,7 +205,7 @@ class Form * @param string $text Text of label (not used in this function) * @param string $htmlname Name of select field * @param string|int $value Value to show/edit - * @param CommonObject $object Object (that we want to show) + * @param CommonObject|ActionsCardProduct|ActionsCardService $object Object (that we want to show) * @param bool|int<0,1> $perm Permission to allow button to edit parameter * @param string $typeofdata Type of data ('string' by default, 'checkbox', 'email', 'phone', 'amount:99', 'numeric:99', * 'text' or 'textarea:rows:cols%', 'safehtmlstring', 'restricthtml', @@ -2563,7 +2564,7 @@ class Form * * @param string $action Value for $action * @param string $htmlname Field name in form - * @param int $show_empty 0=list without the empty value, 1=add empty value + * @param int<0,1> $show_empty 0=list without the empty value, 1=add empty value * @param int[] $exclude Array list of users id to exclude * @param int<0,1> $disabled If select list must be disabled * @param int[]|string $include Array list of users id to include or 'hierarchy' to have only supervised users @@ -2572,7 +2573,7 @@ class Form * @param int $maxlength Maximum length of string into list (0=no limit) * @param int<-1,1> $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status * @param string $morefilter Add more filters into sql request - * @param int $showproperties Show properties of each attendees + * @param int<0,1> $showproperties Show properties of each attendees * @param array}> $listofresourceid Array with properties of each resource * @return string HTML select string */ @@ -2661,14 +2662,14 @@ class Form * @param int|string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) * @param int $limit Limit on number of returned lines * @param int $price_level Level of price to show - * @param int $status Sell status: -1=No filter on sell status, 0=Products not on sell, 1=Products on sell - * @param int $finished 2=all, 1=finished, 0=raw material + * @param int<-1,1> $status Sell status: -1=No filter on sell status, 0=Products not on sell, 1=Products on sell + * @param int<0,2> $finished 2=all, 1=finished, 0=raw material * @param string $selected_input_value Value of preselected input text (for use with ajax) - * @param int $hidelabel Hide label (0=no, 1=yes, 2=show search icon (before) and placeholder, 3 search icon after) + * @param int<0,3> $hidelabel Hide label (0=no, 1=yes, 2=show search icon (before) and placeholder, 3 search icon after) * @param array $ajaxoptions Options for ajax_autocompleter * @param int $socid Thirdparty Id (to get also price dedicated to this customer) - * @param string|int<0,1> $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. - * @param int $forcecombo Force to use combo box. + * @param string|int<0,1> $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. + * @param int<0,1> $forcecombo Force to use combo box. * @param string $morecss Add more css on select * @param int<0,1> $hidepriceinlabel 1=Hide prices in label * @param string $warehouseStatus Warehouse status filter to count the quantity in stock. Following comma separated filter options can be used @@ -3734,7 +3735,7 @@ class Form * @param int $socid Id of supplier thirdparty (0 = no filter) * @param string $selected Product price preselected (must be 'id' in product_fournisseur_price or 'idprod_IDPROD') * @param string $htmlname Name of HTML select - * @param string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) + * @param ''|int<0,1> $filtertype Filter on product type (''=nofilter, 0=product, 1=service) * @param string $filtre Generic filter. Data must not come from user input. * @param string $filterkey Filter of produdts * @param int $statut -1=Return all products, 0=Products not on buy, 1=Products on buy @@ -4392,9 +4393,9 @@ class Form // Si traduction existe, on l'utilise, sinon on prend le libelle par default $label = ($langs->trans("AvailabilityType" . $obj->code) != "AvailabilityType" . $obj->code ? $langs->trans("AvailabilityType" . $obj->code) : ($obj->label != '-' ? $obj->label : '')); - $this->cache_availability[$obj->rowid]['code'] = $obj->code; - $this->cache_availability[$obj->rowid]['label'] = $label; - $this->cache_availability[$obj->rowid]['position'] = $obj->position; + $this->cache_availability[$obj->rowid]['code'] = (string) $obj->code; + $this->cache_availability[$obj->rowid]['label'] = (string) $label; + $this->cache_availability[$obj->rowid]['position'] = (int) $obj->position; $i++; } @@ -4410,11 +4411,11 @@ class Form /** * Return the list of type of delay available. * - * @param string $selected Id du type de delais pre-selectionne - * @param string $htmlname Nom de la zone select - * @param string $filtertype To add a filter - * @param int $addempty Add empty entry - * @param string $morecss More CSS + * @param ''|int $selected Id du type de delais pre-selectionne + * @param string $htmlname Nom de la zone select + * @param string|int<0,1> $filtertype To add a filter + * @param int<0,1> $addempty Add empty entry + * @param string $morecss More CSS * @return void */ public function selectAvailabilityDelay($selected = '', $htmlname = 'availid', $filtertype = '', $addempty = 0, $morecss = '') diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 948907ff469..800913719ee 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -5,7 +5,7 @@ * Copyright (C) 2017 Rui Strecht * Copyright (C) 2020 Open-Dsi * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -249,9 +249,9 @@ class FormCompany extends Form * The key of the list is the code (there can be several entries for a given code but in this case, the country field differs). * Thus the links with the departments are done on a department independently of its name. * - * @param string $selected Code state preselected - * @param int $country_codeid 0=list for all countries, otherwise country code or country rowid to show - * @param string $htmlname Id of department + * @param string $selected Code state preselected + * @param int|string $country_codeid 0=list for all countries, otherwise country code or country rowid to show + * @param string $htmlname Id of department * @return void */ public function select_departement($selected = '', $country_codeid = 0, $htmlname = 'state_id') @@ -267,11 +267,11 @@ class FormCompany extends Form * The key of the list is the code (there can be several entries for a given code but in this case, the country field differs). * Thus the links with the departments are done on a department independently of its name. * - * @param int $selected Code state preselected (must be state id) - * @param int $country_codeid Country code or id: 0=list for all countries, otherwise country code or country rowid to show - * @param string $htmlname Id of department. If '', we want only the string with
'; diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 50efd47aee2..d3aeeb8d17d 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2008-2009 Laurent Destailleur * Copyright (C) 2015-2017 Francis Appels * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -292,7 +292,7 @@ class FormProduct * @param array}> $events Events to add to select2 * @param string $morecss Add more css classes to HTML select * @param int[] $exclude Warehouses ids to exclude - * @param int $showfullpath 1=Show full path of name (parent ref into label), 0=Show only ref of current warehouse + * @param int<0,1> $showfullpath 1=Show full path of name (parent ref into label), 0=Show only ref of current warehouse * @param bool|int $stockMin [=false] Value of minimum stock to filter (only warehouse with stock > stockMin are loaded) or false not not filter by minimum stock * @param string $orderBy [='e.ref'] Order by * @param int<0,1> $multiselect 1=Allow multiselect @@ -307,7 +307,7 @@ class FormProduct dol_syslog(get_class($this)."::selectWarehouses " . (is_array($selected) ? 'selected is array' : $selected) . ", $htmlname, $filterstatus, $empty, $disabled, $fk_product, $empty_label, $showstock, $forcecombo, $morecss", LOG_DEBUG); $out = ''; - if ((!getDolGlobalString('ENTREPOT_EXTRA_STATUS')) && ($filterstatus==="warehouseinternal")) { + if ((!getDolGlobalString('ENTREPOT_EXTRA_STATUS')) && ($filterstatus === "warehouseinternal")) { $filterstatus = ''; } if (!empty($fk_product) && $fk_product > 0) { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 807acd3ce95..b406d67b761 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -246,7 +246,7 @@ class Product extends CommonObject public $level; /** - * @var ?array Array for multilangs + * @var ?array Array for multilangs */ public $multilangs = array(); @@ -509,7 +509,7 @@ class Product extends CommonObject public $weight; /** - * @var int|string + * @var ?int */ public $weight_units; // scale -3, 0, 3, 6 /** @@ -517,7 +517,7 @@ class Product extends CommonObject */ public $length; /** - * @var int|string + * @var ?int */ public $length_units; // scale -3, 0, 3, 6 /** @@ -525,7 +525,7 @@ class Product extends CommonObject */ public $width; /** - * @var int|string + * @var ?int */ public $width_units; // scale -3, 0, 3, 6 /** @@ -533,7 +533,7 @@ class Product extends CommonObject */ public $height; /** - * @var int|string|null + * @var ?int */ public $height_units; // scale -3, 0, 3, 6 /** @@ -541,7 +541,7 @@ class Product extends CommonObject */ public $surface; /** - * @var int|string|null + * @var ?int */ public $surface_units; // scale -3, 0, 3, 6 /** @@ -549,7 +549,7 @@ class Product extends CommonObject */ public $volume; /** - * @var int|string|null + * @var ?int */ public $volume_units; // scale -3, 0, 3, 6 @@ -558,7 +558,7 @@ class Product extends CommonObject */ public $net_measure; /** - * @var ?string + * @var ?int */ public $net_measure_units; // scale -3, 0, 3, 6 @@ -1151,7 +1151,7 @@ class Product extends CommonObject $sql .= ", ".((empty($this->sell_or_eat_by_mandatory) || $this->sell_or_eat_by_mandatory < 0) ? 0 : ((int) $this->sell_or_eat_by_mandatory)); $sql .= ", '".$this->db->escape($this->batch_mask)."'"; $sql .= ", ".($this->fk_unit > 0 ? ((int) $this->fk_unit) : 'NULL'); - $sql .= ", '".$this->db->escape($this->mandatory_period)."'"; + $sql .= ", '".$this->db->escape((string) $this->mandatory_period)."'"; $sql .= ")"; dol_syslog(get_class($this)."::Create", LOG_DEBUG); @@ -1368,19 +1368,19 @@ class Product extends CommonObject $this->note_private = (isset($this->note_private) ? trim($this->note_private) : null); $this->note_public = (isset($this->note_public) ? trim($this->note_public) : null); $this->net_measure = price2num($this->net_measure); - $this->net_measure_units = (is_null($this->net_measure_units) ? '' : trim((string) $this->net_measure_units)); + $this->net_measure_units = (!is_numeric($this->net_measure_units) ? null : (int) $this->net_measure_units); $this->weight = price2num($this->weight); - $this->weight_units = (is_null($this->weight_units) ? '' : trim((string) $this->weight_units)); + $this->weight_units = (!is_numeric($this->weight_units) ? null : (int) $this->weight_units); $this->length = price2num($this->length); - $this->length_units = (is_null($this->length_units) ? '' : trim((string) $this->length_units)); + $this->length_units = (!is_numeric($this->length_units) ? null : (int) $this->length_units); $this->width = price2num($this->width); - $this->width_units = (is_null($this->width_units) ? '' : trim((string) $this->width_units)); + $this->width_units = (!is_numeric($this->width_units) ? null : (int) $this->width_units); $this->height = price2num($this->height); - $this->height_units = (is_null($this->height_units) ? '' : trim((string) $this->height_units)); + $this->height_units = (!is_numeric($this->height_units) ? null : (int) $this->height_units); $this->surface = price2num($this->surface); - $this->surface_units = (is_null($this->surface_units) ? '' : trim((string) $this->surface_units)); + $this->surface_units = (!is_numeric($this->surface_units) ? null : (int) $this->surface_units); $this->volume = price2num($this->volume); - $this->volume_units = (is_null($this->volume_units) ? '' : trim((string) $this->volume_units)); + $this->volume_units = (!is_numeric($this->volume_units) ? null : (int) $this->volume_units); // set unit not defined if (is_numeric($this->length_units)) { @@ -1511,7 +1511,7 @@ class Product extends CommonObject $ObjLot->entity = $this->entity; $ObjLot->fk_user_creat = $user->id; $ObjLot->batch = $valueforundefinedlot; - if ($ObjLot->create($user, true) < 0) { + if ($ObjLot->create($user, 1) < 0) { $error++; $this->errors = $ObjLot->errors; } @@ -1544,7 +1544,7 @@ class Product extends CommonObject $sql .= ", localtax2_type = ".($this->localtax2_type != '' ? "'".$this->db->escape($this->localtax2_type)."'" : "'0'"); $sql .= ", barcode = ".(empty($this->barcode) ? "null" : "'".$this->db->escape($this->barcode)."'"); - $sql .= ", fk_barcode_type = ".(empty($this->barcode_type) ? "null" : $this->db->escape($this->barcode_type)); + $sql .= ", fk_barcode_type = ".(empty($this->barcode_type) ? "null" : $this->db->escape((string) $this->barcode_type)); $sql .= ", tosell = ".(int) $this->status; $sql .= ", tobuy = ".(int) $this->status_buy; @@ -1555,19 +1555,19 @@ class Product extends CommonObject $sql .= ", finished = ".((!isset($this->finished) || $this->finished < 0 || $this->finished === '') ? "null" : (int) $this->finished); $sql .= ", fk_default_bom = ".((!isset($this->fk_default_bom) || $this->fk_default_bom < 0 || $this->fk_default_bom == '') ? "null" : (int) $this->fk_default_bom); $sql .= ", net_measure = ".($this->net_measure != '' ? "'".$this->db->escape($this->net_measure)."'" : 'null'); - $sql .= ", net_measure_units = ".($this->net_measure_units != '' ? "'".$this->db->escape($this->net_measure_units)."'" : 'null'); + $sql .= ", net_measure_units = ".((string) $this->net_measure_units != '' ? ((int) $this->net_measure_units) : 'null'); $sql .= ", weight = ".($this->weight != '' ? "'".$this->db->escape($this->weight)."'" : 'null'); - $sql .= ", weight_units = ".($this->weight_units != '' ? "'".$this->db->escape($this->weight_units)."'" : 'null'); + $sql .= ", weight_units = ".((string) $this->weight_units != '' ? ((int) $this->weight_units) : 'null'); $sql .= ", length = ".($this->length != '' ? "'".$this->db->escape($this->length)."'" : 'null'); - $sql .= ", length_units = ".($this->length_units != '' ? "'".$this->db->escape($this->length_units)."'" : 'null'); + $sql .= ", length_units = ".((string) $this->length_units != '' ? ((int) $this->length_units) : 'null'); $sql .= ", width= ".($this->width != '' ? "'".$this->db->escape($this->width)."'" : 'null'); - $sql .= ", width_units = ".($this->width_units != '' ? "'".$this->db->escape($this->width_units)."'" : 'null'); + $sql .= ", width_units = ".((string) $this->width_units != '' ? ((int) $this->width_units) : 'null'); $sql .= ", height = ".($this->height != '' ? "'".$this->db->escape($this->height)."'" : 'null'); - $sql .= ", height_units = ".($this->height_units != '' ? "'".$this->db->escape($this->height_units)."'" : 'null'); + $sql .= ", height_units = ".((string) $this->height_units != '' ? ((int) $this->height_units) : 'null'); $sql .= ", surface = ".($this->surface != '' ? "'".$this->db->escape($this->surface)."'" : 'null'); - $sql .= ", surface_units = ".($this->surface_units != '' ? "'".$this->db->escape($this->surface_units)."'" : 'null'); + $sql .= ", surface_units = ".((string) $this->surface_units != '' ? ((int) $this->surface_units) : 'null'); $sql .= ", volume = ".($this->volume != '' ? "'".$this->db->escape($this->volume)."'" : 'null'); - $sql .= ", volume_units = ".($this->volume_units != '' ? "'".$this->db->escape($this->volume_units)."'" : 'null'); + $sql .= ", volume_units = ".((string) $this->volume_units != '' ? ((int) $this->volume_units) : 'null'); $sql .= ", fk_default_warehouse = ".($this->fk_default_warehouse > 0 ? ((int) $this->fk_default_warehouse) : 'null'); $sql .= ", fk_default_workstation = ".($this->fk_default_workstation > 0 ? ((int) $this->fk_default_workstation) : 'null'); $sql .= ", seuil_stock_alerte = ".((isset($this->seuil_stock_alerte) && is_numeric($this->seuil_stock_alerte)) ? (float) $this->seuil_stock_alerte : 'null'); @@ -2346,7 +2346,7 @@ class Product extends CommonObject $prodcustprice = new ProductCustomerPrice($this->db); - $filter = array('t.fk_product' => $this->id, 't.fk_soc' => $thirdparty_buyer->id); + $filter = array('t.fk_product' => (string) $this->id, 't.fk_soc' => (string) $thirdparty_buyer->id); // If a price per customer exist $pricebycustomerexist = false; @@ -2409,7 +2409,7 @@ class Product extends CommonObject $prodcustprice = new ProductCustomerPrice($this->db); - $filter = array('t.fk_product' => $this->id, 't.fk_soc' => $thirdparty_buyer->id); + $filter = array('t.fk_product' => (string) $this->id, 't.fk_soc' => (string) $thirdparty_buyer->id); $result = $prodcustprice->fetchAll('', '', 0, 0, $filter); if ($result) { @@ -2783,7 +2783,7 @@ class Product extends CommonObject $sql .= " default_vat_code = ".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").","; $sql .= " price_label = ".(!empty($price_label) ? "'".$this->db->escape($price_label)."'" : "null").","; $sql .= " tva_tx = ".(float) price2num($newvat).","; - $sql .= " recuperableonly = '".$this->db->escape($newnpr)."'"; + $sql .= " recuperableonly = '".$this->db->escape((string) $newnpr)."'"; $sql .= " WHERE rowid = ".((int) $id); dol_syslog(get_class($this)."::update_price", LOG_DEBUG); @@ -3616,7 +3616,7 @@ class Product extends CommonObject if (getDolGlobalString('DECREASE_ONLY_UNINVOICEDPRODUCTS')) { // If option DECREASE_ONLY_UNINVOICEDPRODUCTS is on, we make a compensation but only if order not yet invoice. $adeduire = 0; - $sql = "SELECT SUM(".$this->db->ifsql('f.type=2', -1, 1)." * fd.qty) as count FROM ".$this->db->prefix()."facturedet as fd "; + $sql = "SELECT SUM(".$this->db->ifsql('f.type=2', '-1', '1')." * fd.qty) as count FROM ".$this->db->prefix()."facturedet as fd "; $sql .= " JOIN ".$this->db->prefix()."facture as f ON fd.fk_facture = f.rowid"; $sql .= " JOIN ".$this->db->prefix()."element_element as el ON ((el.fk_target = f.rowid AND el.targettype = 'facture' AND sourcetype = 'commande') OR (el.fk_source = f.rowid AND el.targettype = 'commande' AND sourcetype = 'facture'))"; $sql .= " JOIN ".$this->db->prefix()."commande as c ON el.fk_source = c.rowid"; @@ -3638,7 +3638,7 @@ class Product extends CommonObject // For every order having invoice already validated we need to decrease stock cause it's in physical stock $adeduire = 0; - $sql = "SELECT sum(".$this->db->ifsql('f.type=2', -1, 1)." * fd.qty) as count FROM ".MAIN_DB_PREFIX."facturedet as fd "; + $sql = "SELECT sum(".$this->db->ifsql('f.type=2', '-1', '1')." * fd.qty) as count FROM ".MAIN_DB_PREFIX."facturedet as fd "; $sql .= " JOIN ".MAIN_DB_PREFIX."facture as f ON fd.fk_facture = f.rowid"; $sql .= " JOIN ".MAIN_DB_PREFIX."element_element as el ON ((el.fk_target = f.rowid AND el.targettype = 'facture' AND sourcetype = 'commande') OR (el.fk_source = f.rowid AND el.targettype = 'commande' AND sourcetype = 'facture'))"; $sql .= " JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid"; @@ -5342,7 +5342,7 @@ class Product extends CommonObject * @param int $multiply Because each sublevel must be multiplicated by parent nb * @param int $level Init level * @param int $id_parent Id parent - * @param int $ignore_stock_load Ignore stock load + * @param int<0,1> $ignore_stock_load Ignore stock load * @return void */ public function fetch_prod_arbo($prod, $compl_path = '', $multiply = 1, $level = 1, $id_parent = 0, $ignore_stock_load = 0) @@ -5350,6 +5350,11 @@ class Product extends CommonObject // phpcs:enable $tmpproduct = null; + if ($multiply < 1) { + dol_syslog(get_class($this).'::'.__FUNCTION__.' Product quantity rounded up to 1 from '.$multiply.'. May result in unexpected end quantity for product children of '.$id_parent, LOG_WARNING); + $multiply = 1; + } + //var_dump($prod); foreach ($prod as $id_product => $desc_pere) { // $id_product is 0 (first call starting with root top) or an id of a sub_product if (is_array($desc_pere)) { // If desc_pere is an array, this means it's a child @@ -5359,10 +5364,6 @@ class Product extends CommonObject $label = (!empty($desc_pere[3]) ? $desc_pere[3] : ''); $incdec = (!empty($desc_pere[4]) ? $desc_pere[4] : 0); - if ($multiply < 1) { - $multiply = 1; - } - //print "XXX We add id=".$id." - label=".$label." - nb=".$nb." - multiply=".$multiply." fullpath=".$compl_path.$label."\n"; if (is_null($tmpproduct)) { $tmpproduct = new Product($this->db); // So we initialize tmpproduct only once for all loop. @@ -5392,8 +5393,12 @@ class Product extends CommonObject // Recursive call if there child has children of its own if (isset($desc_pere['childs']) && is_array($desc_pere['childs'])) { + if (!is_int($desc_pere[1] * $multiply)) { + dol_syslog(get_class($this).'::'.__FUNCTION__.' Source product quantity and multiplier may result in unexpected end quantity for '.$label.'/'.$multiply.' Child product:'.json_encode($desc_pere), LOG_WARNING); + } + //print 'YYY We go down for '.$desc_pere[3]." -> \n"; - $this->fetch_prod_arbo($desc_pere['childs'], $compl_path.$desc_pere[3]." -> ", $desc_pere[1] * $multiply, $level + 1, $id, $ignore_stock_load); + $this->fetch_prod_arbo($desc_pere['childs'], $compl_path.$desc_pere[3]." -> ", (int) ceil($desc_pere[1] * $multiply), $level + 1, $id, $ignore_stock_load); } } } @@ -5405,7 +5410,7 @@ class Product extends CommonObject * this->sousprods must have been loaded by this->get_sousproduits_arbo() * * @param int $multiply Because each sublevel must be multiplicated by parent nb - * @param int $ignore_stock_load Ignore stock load + * @param int<0,1> $ignore_stock_load Ignore stock load * @return array,entity:CommonObject}> Array with tree */ public function get_arbo_each_prod($multiply = 1, $ignore_stock_load = 0) @@ -5426,8 +5431,8 @@ class Product extends CommonObject /** * Count all parent and children products for current product (first level only) * - * @param int $mode 0=Both parent and child, -1=Parents only, 1=Children only - * @return int Nb of father + child + * @param int<-1,1> $mode 0=Both parent and child, -1=Parents only, 1=Children only + * @return int Nb of father + child * @see getFather(), get_sousproduits_arbo() */ public function hasFatherOrChild($mode = 0) @@ -6075,6 +6080,8 @@ class Product extends CommonObject include_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; + // Ensure $nbpiece is a number and positive + $nbpiece = (float) $nbpiece; if ($nbpiece < 0) { if (!$movement) { $movement = 1; @@ -6082,11 +6089,11 @@ class Product extends CommonObject $nbpiece = abs($nbpiece); } $op = array(); - $op[0] = "+".trim((string) $nbpiece); - $op[1] = "-".trim((string) $nbpiece); + $op[0] = $nbpiece; + $op[1] = -$nbpiece; $movementstock = new MouvementStock($this->db); - $movementstock->setOrigin($origin_element, $origin_id); // Set ->origin_type and ->origin_id + $movementstock->setOrigin($origin_element, (int) $origin_id); // Set ->origin_type and ->origin_id $result = $movementstock->_create($user, $this->id, $id_entrepot, $op[$movement], $movement, $price, $label, $inventorycode, '', '', '', '', false, 0, $disablestockchangeforsubproduct); if ($result >= 0) { @@ -6138,6 +6145,8 @@ class Product extends CommonObject include_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; + // Ensure $nbpiece is a number and positive + $nbpiece = (float) $nbpiece; if ($nbpiece < 0) { if (!$movement) { $movement = 1; @@ -6146,11 +6155,11 @@ class Product extends CommonObject } $op = array(); - $op[0] = "+".trim((string) $nbpiece); - $op[1] = "-".trim((string) $nbpiece); + $op[0] = $nbpiece; + $op[1] = -$nbpiece; $movementstock = new MouvementStock($this->db); - $movementstock->setOrigin($origin_element, $origin_id); // Set ->origin_type and ->fk_origin + $movementstock->setOrigin($origin_element, (int) $origin_id); // Set ->origin_type and ->fk_origin $result = $movementstock->_create($user, $this->id, $id_entrepot, $op[$movement], $movement, $price, $label, $inventorycode, '', $dlc, $dluo, $lot, false, 0, $disablestockchangeforsubproduct, 0, $force_update_batch); if ($result >= 0) { diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index ccd7510b6de..4838885cb07 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2007-2012 Laurent Destailleur * Copyright (C) 2014 Florian Henry * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -282,8 +282,8 @@ class ProductCustomerPrice extends CommonObject $sql .= ") VALUES ("; $sql .= " ".((int) $conf->entity).","; $sql .= " '".$this->db->idate(dol_now())."',"; - $sql .= " ".(!isset($this->fk_product) ? 'NULL' : "'".$this->db->escape($this->fk_product)."'").","; - $sql .= " ".(!isset($this->fk_soc) ? 'NULL' : "'".$this->db->escape($this->fk_soc)."'").","; + $sql .= " ".(!isset($this->fk_product) ? 'NULL' : ((int) $this->fk_product)).","; + $sql .= " ".(!isset($this->fk_soc) ? 'NULL' : ((int) $this->fk_soc)).","; $sql .= " ".(!isset($this->ref_customer) ? 'NULL' : "'".$this->db->escape($this->ref_customer)."'").","; $sql .= " ".(empty($this->price) ? '0' : "'".$this->db->escape($this->price)."'").","; $sql .= " ".(empty($this->price_ttc) ? '0' : "'".$this->db->escape($this->price_ttc)."'").","; @@ -918,7 +918,7 @@ class ProductCustomerPrice extends CommonObject $prodsocprice = new ProductCustomerPrice($this->db); $filter = array( - 't.fk_product' => $this->fk_product, 't.fk_soc' => $obj->rowid + 't.fk_product' => (string) $this->fk_product, 't.fk_soc' => (string) $obj->rowid ); $result = $prodsocprice->fetchAll('', '', 0, 0, $filter); diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index 2c7fd107a9d..6bbc5a45006 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -8,7 +8,7 @@ * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2023 Benjamin Falière * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -113,7 +113,7 @@ if (empty($reshook)) { for ($i = 0; $i < $maxprod; $i++) { $qty = price2num(GETPOST("prod_qty_" . $i, 'alpha'), 'MS'); if ($qty > 0) { - if ($object->add_sousproduit($id, GETPOSTINT("prod_id_" . $i), $qty, GETPOSTINT("prod_incdec_" . $i)) > 0) { + if ($object->add_sousproduit($id, GETPOSTINT("prod_id_" . $i), (float) $qty, GETPOSTINT("prod_incdec_" . $i)) > 0) { //var_dump($i.' '.GETPOST("prod_id_".$i, 'int'), $qty, GETPOST("prod_incdec_".$i, 'int')); $action = 'edit'; } else { @@ -262,7 +262,7 @@ if ($id > 0 || !empty($ref)) { if (isModEnabled("product") && isModEnabled("service")) { $typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service"); print ''; - print (!getDolGlobalString('PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, $usercancreate, $typeformat) : $langs->trans('Type'); + print (!getDolGlobalString('PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey("Type", 'fk_product_type', (string) $object->type, $object, (int) $usercancreate, $typeformat) : $langs->trans('Type'); print ''; print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, $usercancreate, $typeformat); print ''; diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 35e3ab0610d..82b361962f5 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -9,7 +9,7 @@ * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2017 Ferran Marcet * Copyright (C) 2024 Frédéric France - * Copyright (C) 2025 MDW + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -89,6 +89,8 @@ if (!$sortfield) { $sortfield = "position_name"; } +$upload_dir = ''; +$upload_dirold = ''; // Initialize objects $object = new Product($db); if ($id > 0 || !empty($ref)) { @@ -172,7 +174,7 @@ if ($action == 'filemerge' && $permissiontoadd) { // Delete all file already associated $filetomerge = new Propalmergepdfproduct($db); - if (getDolGlobalInt('MAIN_MULTILANGS')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && $lang_id !== null) { $result = $filetomerge->delete_by_product($user, $object->id, $lang_id); } else { $result = $filetomerge->delete_by_product($user, $object->id); @@ -338,6 +340,7 @@ if ($object->id > 0) { print ''; + $default_lang = null; // Get language if (getDolGlobalInt('MAIN_MULTILANGS')) { $langs->load("languages"); @@ -363,7 +366,7 @@ if ($object->id > 0) { $checked = ''; $filename = $filetoadd['name']; - if (getDolGlobalInt('MAIN_MULTILANGS')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && $default_lang !== null) { if (array_key_exists($filetoadd['name'].'_'.$default_lang, $filetomerge->lines)) { $filename = $filetoadd['name'].' - '.$langs->trans('Language_'.$default_lang); $checked = ' checked '; diff --git a/htdocs/product/dynamic_price/class/price_parser.class.php b/htdocs/product/dynamic_price/class/price_parser.class.php index f69d63391e0..9aa6a91d7c0 100644 --- a/htdocs/product/dynamic_price/class/price_parser.class.php +++ b/htdocs/product/dynamic_price/class/price_parser.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -345,7 +345,7 @@ class PriceParser { //Get the product data $product = new Product($this->db); - $product->fetch($product_id, '', '', 1); + $product->fetch($product_id, '', '', '1'); //Values for product expressions $extra_values = array_merge($extra_values, array( diff --git a/htdocs/product/index.php b/htdocs/product/index.php index fdca1c4133a..ad9f60e0a1c 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -7,7 +7,7 @@ * Copyright (C) 2019 Pierre Ardoin * Copyright (C) 2019-2024 Frédéric France * Copyright (C) 2019 Nicolas ZABOURI - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -119,7 +119,7 @@ print load_fiche_titre($transAreaType, $resultboxes['selectboxlist'], 'product') if (getDolGlobalString('MAIN_SEARCH_FORM_ON_HOME_AREAS')) { // This may be useless due to the global search combo - if (!isset($listofsearchfields) || !is_array($listofsearchfields)) { + if (!isset($listofsearchfields) || !is_array($listofsearchfields)) { // @phan-suppress-current-line PhanPluginUndeclaredVariableIsset // Ensure $listofsearchfields is set and array $listofsearchfields = array(); } @@ -743,7 +743,7 @@ function activitytrim($product_type) $sql .= " AND pf.fk_facture = f.rowid"; $sql .= " AND pf.fk_paiement = p.rowid"; $sql .= " AND fd.product_type = ".((int) $product_type); - $sql .= " AND p.datep >= '".$db->idate(dol_get_first_day($yearofbegindate), 1)."'"; + $sql .= " AND p.datep >= '".$db->idate(dol_get_first_day($yearofbegindate, 1))."'"; $sql .= " GROUP BY annee, mois "; $sql .= " ORDER BY annee, mois "; diff --git a/htdocs/product/inventory/ajax/searchfrombarcode.php b/htdocs/product/inventory/ajax/searchfrombarcode.php index 5f1191aaf38..8f2a81a4936 100644 --- a/htdocs/product/inventory/ajax/searchfrombarcode.php +++ b/htdocs/product/inventory/ajax/searchfrombarcode.php @@ -1,6 +1,6 @@ - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW */ /* * This program is free software; you can redistribute it and/or modify @@ -90,10 +90,10 @@ if ($action == "existbarcode" && !empty($barcode) && $user->hasRight('stock', 'l $sql .= " WHERE p.barcode = '".$db->escape($barcode)."'"; } if (!empty($fk_entrepot)) { - $sql .= " AND ps.fk_entrepot = '".$db->escape($fk_entrepot)."'"; + $sql .= " AND ps.fk_entrepot = '".((int) ($fk_entrepot))."'"; } if (!empty($fk_product)) { - $sql .= " AND ps.fk_product = '".$db->escape($fk_product)."'"; + $sql .= " AND ps.fk_product = '".((int) ($fk_product))."'"; } $result = $db->query($sql); if ($result) { diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 81c52b976da..5f18b5acfa5 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -271,6 +272,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print dol_get_fiche_head($head, 'card', $langs->trans("Inventory"), -1, 'stock'); $formconfirm = ''; + $text = ''; // Confirmation of action xxxx @@ -450,9 +452,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Clone - if ($permissiontoadd) { - //print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=inventory', 'clone', $permissiontoadd); - } + //if ($permissiontoadd) { + //print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=inventory', 'clone', $permissiontoadd); + //} // Delete print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete); diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 4d860191269..5e69da95eed 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -227,7 +228,7 @@ if (empty($reshook)) { $price = $line->pmp_real; } - $idstockmove = $stockmovment->_create($user, $line->fk_product, $line->fk_warehouse, $stock_movement_qty, $movement_type, $price, $langs->trans('LabelOfInventoryMovemement', $object->ref), $inventorycode, $datemovement, '', '', $line->batch); + $idstockmove = $stockmovment->_create($user, $line->fk_product, $line->fk_warehouse, (float) $stock_movement_qty, $movement_type, $price, $langs->trans('LabelOfInventoryMovemement', $object->ref), $inventorycode, $datemovement, '', '', $line->batch); if ($idstockmove < 0) { $error++; setEventMessages($stockmovment->error, $stockmovment->errors, 'errors'); @@ -789,7 +790,7 @@ if ($action == 'updatebyscaning') { console.log("We change #"+product.Id+"_input to match input in scanner box"); if(product.hasOwnProperty("reelqty")){ $.ajax({ url: \''.DOL_URL_ROOT.'/product/inventory/ajax/searchfrombarcode.php\', - data: { "token":"'.newToken().'", "action":"addnewlineproduct", "fk_entrepot":product.Warehouse, "batch":product.Batch, "fk_inventory":'.dol_escape_js($object->id).', "fk_product":product.fk_product, "reelqty":product.reelqty}, + data: { "token":"'.newToken().'", "action":"addnewlineproduct", "fk_entrepot":product.Warehouse, "batch":product.Batch, "fk_inventory":'.dol_escape_js((string) $object->id).', "fk_product":product.fk_product, "reelqty":product.reelqty}, type: \'POST\', async: false, success: function(response) { @@ -1001,7 +1002,7 @@ if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STAT } else { $filtertype = 0; } - print $form->select_produits((GETPOSTISSET('fk_product') ? GETPOSTINT('fk_product') : $object->fk_product), 'fk_product', $filtertype, 0, 0, -1, 2, '', 0, null, 0, '1', 0, 'maxwidth300'); + print $form->select_produits((GETPOSTISSET('fk_product') ? GETPOSTINT('fk_product') : $object->fk_product), 'fk_product', $filtertype, 0, 0, -1, 2, '', 0, array(), 0, '1', 0, 'maxwidth300'); print ''; if (isModEnabled('productbatch')) { print ''; } // Accountancy code sell @@ -1628,6 +1631,7 @@ while ($i < $imaxinloop) { } $product_static->price = $obj->price; + $product_static->price_ttc = $obj->price_ttc; // Allows to use price_ttc in calculated extra fields (ex : price per kilo) $object = $product_static; @@ -1961,7 +1965,7 @@ while ($i < $imaxinloop) { // Default Workstation if (!empty($arrayfields['p.fk_default_workstation']['checked'])) { print ''; @@ -2275,7 +2276,7 @@ while ($i < $imaxinloop) { // Import ID if (!empty($arrayfields['p.import_key']['checked'])) { print ''; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index deff4d29ece..c0f087f9d49 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -108,6 +108,7 @@ if ($object->id > 0) { restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); } +$maxpricesupplier = 0; /* * Actions @@ -235,7 +236,7 @@ if (empty($reshook)) { //$localtaxarray=array('0'=>$localtax1_type,'1'=>$localtax1,'2'=>$localtax2_type,'3'=>$localtax2); $localtaxarray = array(); // We do not store localtaxes into product, we will use instead the "vat code" to retrieve them. $level = $i; - $ret = $object->updatePrice($oldprice, $oldpricebasetype, $user, $tva_tx, $oldminprice, $level, $oldnpr, 0, 0, $localtaxarray, $vatratecode, $price_label); + $ret = $object->updatePrice($oldprice, $oldpricebasetype, $user, (float) $tva_tx, $oldminprice, $level, $oldnpr, 0, 0, $localtaxarray, $vatratecode, $price_label); if ($ret < 0) { $error++; @@ -257,7 +258,7 @@ if (empty($reshook)) { //$localtaxarray=array('0'=>$localtax1_type,'1'=>$localtax1,'2'=>$localtax2_type,'3'=>$localtax2); $localtaxarray = array(); // We do not store localtaxes into product, we will use instead the "vat code" to retrieve them when required. $level = 0; - $ret = $object->updatePrice($oldprice, $oldpricebasetype, $user, $tva_tx, $oldminprice, $level, $oldnpr, 0, 0, $localtaxarray, $vatratecode, $price_label); + $ret = $object->updatePrice($oldprice, $oldpricebasetype, $user, (float) $tva_tx, $oldminprice, $level, $oldnpr, 0, 0, $localtaxarray, $vatratecode, $price_label); if ($ret < 0) { $error++; @@ -275,6 +276,8 @@ if (empty($reshook)) { $action = ''; } + $maxpricesupplier = 0; + if (($action == 'update_price' || $action == 'update_level_price') && !$cancel && $object->getRights()->creer) { $error = 0; $pricestoupdate = array(); @@ -507,7 +510,7 @@ if (empty($reshook)) { } // If price has changed, we update it if (!array_key_exists($key, $object->multiprices) || $object->multiprices[$key] != $newprice || $object->multiprices_min[$key] != $newprice_min || $object->multiprices_base_type[$key] != $val['price_base_type'] || $object->multiprices_tva_tx[$key] != $newvattx) { - $res = $object->updatePrice($newprice, $val['price_base_type'], $user, $val['vat_tx'], $newprice_min, $key, $val['npr'], $psq, 0, $val['localtaxes_array'], $val['default_vat_code'], $val['price_label']); + $res = $object->updatePrice((float) $newprice, $val['price_base_type'], $user, (float) $val['vat_tx'], (float) $newprice_min, $key, $val['npr'], $psq, 0, $val['localtaxes_array'], $val['default_vat_code'], $val['price_label']); if ($res > 0) { $extralabels = $extrafields->fetch_name_optionals_label("product"); if (!getDolGlobalString('PRODUIT_MULTIPRICES') && !getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES') && !empty($extralabels)) { @@ -799,9 +802,9 @@ if (empty($reshook)) { $error++; $action = 'add_customer_price'; } - if (getDolGlobalString('PRODUCT_MINIMUM_RECOMMENDED_PRICE') && $prodcustprice->price_min < $maxpricesupplier) { + if (getDolGlobalString('PRODUCT_MINIMUM_RECOMMENDED_PRICE') && $prodcustprice->price_min < (float) $maxpricesupplier) { $langs->load("errors"); - setEventMessages($langs->trans("MinimumPriceLimit", price($maxpricesupplier, 0, '', 1, -1, -1, 'auto')), null, 'errors'); + setEventMessages($langs->trans("MinimumPriceLimit", price((float) $maxpricesupplier, 0, '', 1, -1, -1, 'auto')), null, 'errors'); $error++; $action = 'add_customer_price'; } @@ -1030,9 +1033,10 @@ print '
'; print '
'; print '
'; diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index 6c93ecfdd39..e99979b0a91 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -122,11 +123,11 @@ foreach ($object->fields as $key => $val) { 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'] : '' ); } } @@ -453,8 +454,8 @@ print ''; print ''; $newcardbutton = ''; -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition')); $newcardbutton .= dolGetButtonTitleSeparator(); $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/inventory/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); @@ -563,7 +564,7 @@ foreach ($object->fields as $key => $val) { } elseif ($key == 'lang') { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $formadmin = new FormAdmin($db); - print $formadmin->select_language($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 ''; } @@ -574,7 +575,7 @@ foreach ($object->fields as $key => $val) { 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, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column @@ -617,7 +618,7 @@ foreach ($object->fields as $key => $val) { // 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, 'totalarray'=>&$totalarray); +$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column @@ -712,13 +713,13 @@ while ($i < $imaxinloop) { if (!empty($arrayfields['t.'.$key]['checked'])) { print '$key)) { - print ' title="'.dol_escape_htmltag($object->$key).'"'; + print ' title="'.dol_escape_htmltag((string) $object->$key).'"'; } print '>'; if ($key == 'status') { print $object->getLibStatut(5); } elseif ($key == 'rowid') { - print $object->showOutputField($val, $key, $object->id, ''); + print $object->showOutputField($val, $key, (string) $object->id, ''); } else { print $object->showOutputField($val, $key, $object->$key, ''); } @@ -743,7 +744,7 @@ while ($i < $imaxinloop) { // 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, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column @@ -786,7 +787,7 @@ if ($num == 0) { $db->free($resql); -$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index aa378d1c85c..1e9c33b7bc9 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -14,7 +14,7 @@ * Copyright (C) 2020-2021 Open-DSI * Copyright (C) 2022 Charlene Benke * Copyright (C) 2020-2023 Alexandre Spangaro - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Benjamin Falière * Copyright (C) 2024 Frédéric France * @@ -313,7 +313,7 @@ if (getDolGlobalString('PRODUIT_MULTIPRICES')) { } else { $labelp = $langs->transnoentitiesnoconv("SellingPrice")." ".$i; } - $arrayfields['p.sellprice'.$i] = array('label' => $labelp, 'checked' => ($i == 1 ? 1 : 0), 'enabled' => getDolGlobalString('PRODUIT_MULTIPRICES'), 'position' => (float) ('40.'.sprintf('%03d', $i))); + $arrayfields['p.sellprice'.$i] = array('label' => $labelp, 'checked' => ($i == 1 ? '1' : '0'), 'enabled' => getDolGlobalString('PRODUIT_MULTIPRICES'), 'position' => (float) ('40.'.sprintf('%03d', $i))); $arraypricelevel[$i] = array($i); } } @@ -323,7 +323,8 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan +// Note: forcing int for position, but in reality it is a float here. +'@phan-var-force array $arrayfields'; // dol_sort_array looses type for Phan // Security check if ($search_type == '0') { @@ -440,6 +441,7 @@ if (empty($reshook)) { */ $product_static = new Product($db); +$workstation_static = null; if (isModEnabled('workstation')) { $workstation_static = new Workstation($db); } @@ -898,6 +900,7 @@ $newcardbutton = ''; $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition')); $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition')); +$perm = false; if ($type === "") { $perm = ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')); } elseif ($type == Product::TYPE_SERVICE) { @@ -913,11 +916,11 @@ if ($type === "") { $newcardbutton .= dolGetButtonTitleSeparator(); if ((isModEnabled('product') && $type === "") || $type == Product::TYPE_PRODUCT) { $label = 'NewProduct'; - $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type=0', '', $perm, $params); + $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type=0', '', (int) $perm, $params); } if ((isModEnabled('service') && $type === "") || $type == Product::TYPE_SERVICE) { $label = 'NewService'; - $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type=1', '', $perm, $params); + $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type=1', '', (int) $perm, $params); } print ''; @@ -1242,7 +1245,7 @@ if (!empty($arrayfields['p.fk_country']['checked'])) { // State if (!empty($arrayfields['p.fk_state']['checked'])) { print ''; - print $formcompany->select_state($search_state, $search_country); + print $formcompany->select_state((int) $search_state, $search_country); print ''; - if (isModEnabled('workstation') && !empty($obj->fk_default_workstation)) { + if (isModEnabled('workstation') && !empty($obj->fk_default_workstation) && $workstation_static !== null) { $workstation_static->id = $obj->fk_default_workstation; $workstation_static->ref = $obj->ref_workstation; $workstation_static->status = $obj->status_workstation; @@ -1990,14 +1994,10 @@ while ($i < $imaxinloop) { } } + $productpricescache = array(); // Multiprices if (getDolGlobalString('PRODUIT_MULTIPRICES')) { - if (! isset($productpricescache)) { - $productpricescache = array(); - } - if (! isset($productpricescache[$obj->rowid])) { - $productpricescache[$obj->rowid] = array(); - } + $productpricescache[$obj->rowid] = array(); if ($product_static->status && $usercancreadprice) { // Make 1 request for all price levels (without filter on price_level) and saved result into an cache array @@ -2027,6 +2027,7 @@ while ($i < $imaxinloop) { dol_print_error($db); } } + '@phan-var-force array> $productpricescache'; foreach ($arraypricelevel as $key => $value) { if (!empty($arrayfields['p.sellprice'.$key]['checked'])) { @@ -2073,7 +2074,7 @@ while ($i < $imaxinloop) { if ($product_static->status_buy && $usercancreadprice) { if (count($productFournList = $product_fourn->list_product_fournisseur_price($obj->rowid)) > 0) { $htmltext = $product_fourn->display_price_product_fournisseur(1, 1, 0, 1, $productFournList); - print $form->textwithpicto(count($productFournList), $htmltext); + print $form->textwithpicto((string) count($productFournList), $htmltext); } } print ''; - print dol_escape_htmltag($product_static->import_key); + print dol_escape_htmltag((string) $product_static->import_key); print '
'; +$soc = null; + // Price per customer segment/level if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) { - $soc = null; // Price and min price are variable (depends on level of company). if (!empty($socid)) { $soc = new Societe($db); @@ -1043,7 +1047,7 @@ if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUS if (isModEnabled("product") && isModEnabled("service")) { $typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service"); print ''; @@ -1127,7 +1131,7 @@ if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUS if (isModEnabled("product") && isModEnabled("service")) { $typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service"); print ''; @@ -1142,7 +1146,7 @@ if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUS if (isModEnabled("product") && isModEnabled("service")) { $typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service"); print ''; @@ -1319,6 +1323,7 @@ if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUS print ''; print ''; print ''; + $ii = 0; foreach ($object->prices_by_qty_list[$i] as $ii => $prices) { if ($action == 'edit_price_by_qty' && $rowid == $prices['rowid'] && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { print ''; @@ -1441,6 +1446,7 @@ if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUS print $object->price_label; print ''; + $ii = 0; // Price by quantity if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) { // TODO Fix the form inside tr instead of td print ''; + print ''; // @phpstan-ignore-line print ''; print ''; print ''; + print '   '.$langs->trans("MinimumRecommendedPrice", price((float) $maxpricesupplier, 0, '', 1, -1, -1, 'auto')).' '.img_warning().''; } print ''; print ''; @@ -1944,7 +1950,7 @@ if (($action == 'edit_price' || $action == 'edit_level_price') && $object->getRi } else { // This option is kept for backward compatibility but has no sense print ''; } @@ -1966,7 +1972,7 @@ if (($action == 'edit_price' || $action == 'edit_level_price') && $object->getRi print ''; } if (getDolGlobalString('PRODUCT_MINIMUM_RECOMMENDED_PRICE')) { - print ''; + print ''; } print ''; @@ -2056,10 +2062,10 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT } // Build filter to display only concerned lines - $filter = array('t.fk_product' => $object->id); + $filter = array('t.fk_product' => (string) $object->id); if (!empty($search_soc)) { - $filter['soc.nom'] = $search_soc; + $filter['soc.nom'] = (string) $search_soc; } if ($action == 'add_customer_price') { @@ -2327,7 +2333,7 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT // List of all log of prices by customers print ''."\n"; - $filter = array('t.fk_product' => $object->id, 't.fk_soc' => GETPOSTINT('socid')); + $filter = array('t.fk_product' => (string) $object->id, 't.fk_soc' => (string) GETPOSTINT('socid')); // Count total nb of records $nbtotalofrecords = ''; @@ -2396,7 +2402,7 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT // Local tax is not saved into table of product. We use value linked to VAT code. $localtaxarray = getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), 0, $staticsoc, $mysoc); // Define part of HT, VAT, TTC - $resultarray = calcul_price_total(1, $pu, 0, $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly, $object->type, $mysoc, $localtaxarray); + $resultarray = calcul_price_total(1, $pu, 0, (float) $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly, $object->type, $mysoc, $localtaxarray); // Calcul du total ht sans remise $total_ht = $resultarray[0]; $total_vat = $resultarray[1]; @@ -2645,7 +2651,7 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT // Local tax is not saved into table of product. We use value linked to VAT code. $localtaxarray = getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), 0, $staticsoc, $mysoc); // Define part of HT, VAT, TTC - $resultarray = calcul_price_total(1, $pu, 0, $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly, $object->type, $mysoc, $localtaxarray); + $resultarray = calcul_price_total(1, $pu, 0, (float) $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly, $object->type, $mysoc, $localtaxarray); // Calcul du total ht sans remise $total_ht = $resultarray[0]; $total_vat = $resultarray[1]; diff --git a/htdocs/product/price_suppliers.php b/htdocs/product/price_suppliers.php index 32720ebf10a..18d7a0ae6a5 100644 --- a/htdocs/product/price_suppliers.php +++ b/htdocs/product/price_suppliers.php @@ -12,6 +12,7 @@ * Copyright (C) 2019 Tim Otte * Copyright (C) 2020 Pierre Ardoin * Copyright (C) 2023 Joachim Kueter + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -141,7 +142,7 @@ if ($cancel) { $action = ''; } -$parameters = array('socid'=>$socid, 'id_prod'=>$id); +$parameters = array('socid' => $socid, 'id_prod' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -197,9 +198,9 @@ if (empty($reshook)) { if ($action == 'save_price' && $usercancreate) { $ref_fourn_price_id = GETPOSTINT('ref_fourn_price_id'); - $id_fourn = GETPOST("id_fourn"); + $id_fourn = GETPOSTINT("id_fourn"); if (empty($id_fourn)) { - $id_fourn = GETPOST("search_id_fourn"); + $id_fourn = GETPOSTINT("search_id_fourn"); } $ref_fourn = GETPOST("ref_fourn"); if (empty($ref_fourn)) { @@ -282,7 +283,7 @@ if (empty($reshook)) { $db->begin(); if (empty($ref_fourn_price_id)) { - $ret = $object->add_fournisseur($user, $id_fourn, $ref_fourn_old, $quantity); // This insert record with no value for price. Values are update later with update_buyprice + $ret = $object->add_fournisseur($user, $id_fourn, $ref_fourn_old, (float) $quantity); // This inserts record with no value for price. Values are updated later with update_buyprice if ($ret == -3) { $error++; @@ -324,9 +325,9 @@ if (empty($reshook)) { $multicurrency_price = GETPOSTFLOAT("multicurrency_price"); $multicurrency_code = GETPOST("multicurrency_code", 'alpha'); - $ret = $object->update_buyprice($quantity, $newprice, $user, GETPOST("price_base_type"), $supplier, GETPOST("oselDispo"), $ref_fourn, $tva_tx, GETPOST("charges"), $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation, array(), '', $multicurrency_price, GETPOST("multicurrency_price_base_type"), $multicurrency_tx, $multicurrency_code, $supplier_description, $barcode, $fk_barcode_type, $extrafield_values); + $ret = $object->update_buyprice((float) $quantity, $newprice, $user, GETPOST("price_base_type"), $supplier, GETPOSTINT("oselDispo"), $ref_fourn, (float) $tva_tx, GETPOST("charges"), (float) $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation, array(), '', $multicurrency_price, GETPOST("multicurrency_price_base_type"), $multicurrency_tx, $multicurrency_code, $supplier_description, $barcode, $fk_barcode_type, $extrafield_values); } else { - $ret = $object->update_buyprice($quantity, $newprice, $user, GETPOST("price_base_type"), $supplier, GETPOST("oselDispo"), $ref_fourn, $tva_tx, GETPOST("charges"), $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation, array(), '', 0, 'HT', 1, '', $supplier_description, $barcode, $fk_barcode_type, $extrafield_values); + $ret = $object->update_buyprice((float) $quantity, $newprice, $user, GETPOST("price_base_type"), $supplier, GETPOSTINT("oselDispo"), $ref_fourn, (float) $tva_tx, GETPOST("charges"), (float) $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation, array(), '', 0, 'HT', 1, '', $supplier_description, $barcode, $fk_barcode_type, $extrafield_values); } if ($ret < 0) { $error++; @@ -421,7 +422,7 @@ if ($id > 0 || $ref) { if (isModEnabled("product") && isModEnabled("service")) { $typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service"); print ''; @@ -432,7 +433,7 @@ if ($id > 0 || $ref) { $textdesc = $langs->trans("CostPriceDescription"); $textdesc .= "
".$langs->trans("CostPriceUsage"); $text = $form->textwithpicto($langs->trans("CostPrice"), $textdesc, 1, 'help', ''); - print $form->editfieldkey($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6'); + print $form->editfieldkey($text, 'cost_price', (string) $object->cost_price, $object, (int) $usercancreate, 'amount:6'); print ''; @@ -445,7 +446,7 @@ if ($id > 0 || $ref) { print ''; print ''; - print ''; print ''; } @@ -901,7 +902,7 @@ if ($id > 0 || $ref) { } if (is_object($hookmanager)) { - $parameters = array('id_fourn'=>!empty($id_fourn) ? $id_fourn : 0, 'prod_id'=>$object->id); + $parameters = array('id_fourn' => !empty($id_fourn) ? $id_fourn : 0, 'prod_id' => $object->id); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); print $hookmanager->resPrint; } @@ -961,22 +962,22 @@ if ($id > 0 || $ref) { // Definition of fields for lists // Some fields are missing because they are not included in the database query $arrayfields = array( - 'pfp.datec'=>array('label'=>$langs->trans("AppliedPricesFrom"), 'checked'=>1, 'position'=>1), - 's.nom'=>array('label'=>$langs->trans("Suppliers"), 'checked'=>1, 'position'=>2), - 'pfp.fk_availability'=>array('label'=>$langs->trans("Availability"), 'enabled' => getDolGlobalInt('FOURN_PRODUCT_AVAILABILITY'), 'checked'=>0, 'position'=>4), - 'pfp.quantity'=>array('label'=>$langs->trans("QtyMin"), 'checked'=>1, 'position'=>5), - 'pfp.unitprice'=>array('label'=>$langs->trans("UnitPriceHT"), 'checked'=>1, 'position'=>9), - 'pfp.multicurrency_unitprice'=>array('label'=>$langs->trans("UnitPriceHTCurrency"), 'enabled' => isModEnabled('multicurrency'), 'checked'=>0, 'position'=>10), - 'pfp.charges'=>array('label'=>$langs->trans("Charges"), 'enabled' => getDolGlobalString('PRODUCT_CHARGES'), 'checked'=>0, 'position'=>11), - 'pfp.delivery_time_days'=>array('label'=>$langs->trans("NbDaysToDelivery"), 'checked'=>-1, 'position'=>13), - 'pfp.supplier_reputation'=>array('label'=>$langs->trans("ReputationForThisProduct"), 'checked'=>-1, 'position'=>14), - 'pfp.fk_barcode_type'=>array('label'=>$langs->trans("BarcodeType"), 'enabled' => isModEnabled('barcode'), 'checked'=>0, 'position'=>15), - 'pfp.barcode'=>array('label'=>$langs->trans("BarcodeValue"), 'enabled' => isModEnabled('barcode'), 'checked'=>0, 'position'=>16), - 'pfp.packaging'=>array('label'=>$langs->trans("PackagingForThisProduct"), 'enabled' => getDolGlobalInt('PRODUCT_USE_SUPPLIER_PACKAGING'), 'checked'=>0, 'position'=>17), - 'pfp.status'=>array('label'=>$langs->trans("Status"), 'enabled' => 1, 'checked'=>0, 'position'=>40), - 'pfp.tms'=>array('label'=>$langs->trans("DateModification"), 'enabled' => isModEnabled('barcode'), 'checked'=>1, 'position'=>50), - 'pfp.price'=>array('label'=>$langs->trans("PriceQtyMinHT"), 'checked'=>1, 'position'=>60), - 'pfp.multicurrency_price'=>array('label'=>$langs->trans("PriceQtyMinHTCurrency"), 'enabled' => isModEnabled('multicurrency'), 'checked'=>1, 'position'=>70), + 'pfp.datec' => array('label' => $langs->trans("AppliedPricesFrom"), 'checked' => '1', 'position' => 1), + 's.nom' => array('label' => $langs->trans("Suppliers"), 'checked' => '1', 'position' => 2), + 'pfp.fk_availability' => array('label' => $langs->trans("Availability"), 'enabled' => (string) getDolGlobalInt('FOURN_PRODUCT_AVAILABILITY'), 'checked' => '0', 'position' => 4), + 'pfp.quantity' => array('label' => $langs->trans("QtyMin"), 'checked' => '1', 'position' => 5), + 'pfp.unitprice' => array('label' => $langs->trans("UnitPriceHT"), 'checked' => '1', 'position' => 9), + 'pfp.multicurrency_unitprice' => array('label' => $langs->trans("UnitPriceHTCurrency"), 'enabled' => (string) (int) isModEnabled('multicurrency'), 'checked' => '0', 'position' => 10), + 'pfp.charges' => array('label' => $langs->trans("Charges"), 'enabled' => getDolGlobalString('PRODUCT_CHARGES'), 'checked' => '0', 'position' => 11), + 'pfp.delivery_time_days' => array('label' => $langs->trans("NbDaysToDelivery"), 'checked' => '-1', 'position' => 13), + 'pfp.supplier_reputation' => array('label' => $langs->trans("ReputationForThisProduct"), 'checked' => '-1', 'position' => 14), + 'pfp.fk_barcode_type' => array('label' => $langs->trans("BarcodeType"), 'enabled' => (string) (int) isModEnabled('barcode'), 'checked' => '0', 'position' => 15), + 'pfp.barcode' => array('label' => $langs->trans("BarcodeValue"), 'enabled' => (string) (int) isModEnabled('barcode'), 'checked' => '0', 'position' => 16), + 'pfp.packaging' => array('label' => $langs->trans("PackagingForThisProduct"), 'enabled' => (string) getDolGlobalInt('PRODUCT_USE_SUPPLIER_PACKAGING'), 'checked' => '0', 'position' => 17), + 'pfp.status' => array('label' => $langs->trans("Status"), 'enabled' => '1', 'checked' => '0', 'position' => 40), + 'pfp.tms' => array('label' => $langs->trans("DateModification"), 'enabled' => (string) (int) isModEnabled('barcode'), 'checked' => '1', 'position' => 50), + 'pfp.price' => array('label' => $langs->trans("PriceQtyMinHT"), 'checked' => '1', 'position' => 60), + 'pfp.multicurrency_price' => array('label' => $langs->trans("PriceQtyMinHTCurrency"), 'enabled' => (string) (int) isModEnabled('multicurrency'), 'checked' => '1', 'position' => 70), ); @@ -990,7 +991,7 @@ if ($id > 0 || $ref) { // Show field if not hidden if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { $extratitle = $langs->trans($value); - $arrayfields['ef.' . $key] = array('label' => $extratitle, 'checked' => 0, + $arrayfields['ef.' . $key] = array('label' => $extratitle, 'checked' => '0', 'position' => (end($arrayfields)['position'] + 1), 'langfile' => $extrafields->attributes["product_fournisseur_price"]['langfile'][$key], 'help' => $extrafields->attributes["product_fournisseur_price"]['help'][$key]); @@ -1130,7 +1131,7 @@ if ($id > 0 || $ref) { } if (is_object($hookmanager)) { - $parameters = array('id_fourn'=>(!empty($id_fourn) ? $id_fourn : ''), 'prod_id'=>$object->id, 'nbfields'=>$nbfields); + $parameters = array('id_fourn' => (!empty($id_fourn) ? $id_fourn : ''), 'prod_id' => $object->id, 'nbfields' => $nbfields); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); } if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { @@ -1237,7 +1238,7 @@ if ($id > 0 || $ref) { // Charges if (!empty($arrayfields['pfp.charges']['checked'])) { // Possible only when getDolGlobalString('PRODUCT_CHARGES') is set print ''; } @@ -1329,7 +1330,7 @@ if ($id > 0 || $ref) { } if (is_object($hookmanager)) { - $parameters = array('id_pfp'=>$productfourn->product_fourn_price_id, 'id_fourn'=>(!empty($id_fourn) ? $id_fourn : ''), 'prod_id'=>$object->id); + $parameters = array('id_pfp' => $productfourn->product_fourn_price_id, 'id_fourn' => (!empty($id_fourn) ? $id_fourn : ''), 'prod_id' => $object->id); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); } diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index 4505e050091..72832801e3f 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -5,7 +5,7 @@ * Copyright (C) 2005 Eric Seigne * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2019 Thibault FOUCART - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -237,13 +237,13 @@ if ($result || !($id > 0)) { print ''; // Project - if (isModEnabled('project')) { + if (isModEnabled('project') && $formproject !== null) { $langs->load('projects'); print ''; } @@ -402,7 +403,7 @@ if ($action == 'create') { // Categories print '"; } print '
'; - print (!getDolGlobalString('PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans('Type'); + print (!getDolGlobalString('PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey("Type", 'fk_product_type', (string) $object->type, $object, 0, $typeformat) : $langs->trans('Type'); print ''; print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat); print '
'; - print (!getDolGlobalString('PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans('Type'); + print (!getDolGlobalString('PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey("Type", 'fk_product_type', (string) $object->type, $object, 0, $typeformat) : $langs->trans('Type'); print ''; print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat); print '
'; - print (!getDolGlobalString('PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans('Type'); + print (!getDolGlobalString('PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey("Type", 'fk_product_type', (string) $object->type, $object, 0, $typeformat) : $langs->trans('Type'); print ''; print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat); print '
'.$langs->trans("Discount").' 
'.$langs->trans("PriceByQuantity"); @@ -1469,7 +1475,7 @@ if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUS print ''; // id in product_price print ''; // id in product_price_by_qty - print '
'; @@ -1730,7 +1736,7 @@ if (($action == 'edit_price' || $action == 'edit_level_price') && $object->getRi // Price $product = new Product($db); - $product->fetch($id, $ref, '', 1); //Ignore the math expression when getting the price + $product->fetch($id, $ref, '', '1'); //Ignore the math expression when getting the price print '
'; $text = $langs->trans('SellingPrice'); print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", getDolGlobalString('MAIN_MAX_DECIMALS_UNIT')), 1, 'help'); @@ -1753,7 +1759,7 @@ if (($action == 'edit_price' || $action == 'edit_level_price') && $object->getRi print ''; } if (getDolGlobalString('PRODUCT_MINIMUM_RECOMMENDED_PRICE')) { - print '   '.$langs->trans("MinimumRecommendedPrice", price($maxpricesupplier, 0, '', 1, -1, -1, 'auto')).' '.img_warning().'
'; - print $form->load_tva("tva_tx[".$i.']', $object->multiprices_tva_tx[$i], $mysoc, '', $object->id, false, $object->type, false, 1); + print $form->load_tva("tva_tx[".$i.']', $object->multiprices_tva_tx[$i], $mysoc, null, $object->id, 0, $object->type, false, 1); print ''.$langs->trans("MinimumRecommendedPrice", price($maxpricesupplier, 0, '', 1, -1, -1, 'auto')).' '.img_warning().''.$langs->trans("MinimumRecommendedPrice", price((float) $maxpricesupplier, 0, '', 1, -1, -1, 'auto')).' '.img_warning().'
'; - print (!getDolGlobalString('PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans('Type'); + print (!getDolGlobalString('PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey("Type", 'fk_product_type', (string) $object->type, $object, 0, $typeformat) : $langs->trans('Type'); print ''; print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat); print '
'; print $form->editfieldval($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6'); print '
'; $textdesc = $langs->trans("AverageUnitPricePMPDesc"); $text = $form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $textdesc, 1, 'help', ''); - print $form->editfieldkey($text, 'pmp', $object->pmp, $object, $usercaneditpmp, 'amount:6'); + print $form->editfieldkey($text, 'pmp', (string) $object->pmp, $object, $usercaneditpmp, 'amount:6'); print ''; print $form->editfieldval($text, 'pmp', ($object->pmp > 0 ? $object->pmp : ''), $object, $usercaneditpmp, 'amount:6'); if ($object->pmp > 0) { @@ -519,7 +520,7 @@ if ($id > 0 || $ref) { $filter = '(fournisseur:=:1) AND (status:=:1)'; print img_picto('', 'company', 'class="pictofixedwidth"').$form->select_company(GETPOST("id_fourn", 'alpha'), 'id_fourn', $filter, $langs->transnoentitiesnoconv('SelectThirdParty'), 0, 0, $events); - $parameters = array('filter'=>$filter, 'html_name'=>'id_fourn', 'selected'=>GETPOST("id_fourn"), 'showempty'=>1, 'prod_id'=>$object->id); + $parameters = array('filter' => $filter, 'html_name' => 'id_fourn', 'selected' => GETPOST("id_fourn"), 'showempty' => 1, 'prod_id' => $object->id); $reshook = $hookmanager->executeHooks('formCreateThirdpartyOptions', $parameters, $object, $action); if (empty($reshook)) { if (empty($form->result)) { @@ -794,7 +795,7 @@ if ($id > 0 || $ref) { if (getDolGlobalString('PRODUCT_CHARGES')) { print '
'.$langs->trans("Charges").''; + print ''; print '
'; - print price($productfourn->fourn_charges); + print price((string) $productfourn->fourn_charges); print '
'.$langs->trans("Year").''; $arrayyears = array(); for ($year = $currentyear - 25; $year < $currentyear; $year++) { - $arrayyears[$year] = $year; + $arrayyears[$year] = (string) $year; } if (!in_array($year, $arrayyears)) { - $arrayyears[$year] = $year; + $arrayyears[$year] = (string) $year; } if (!in_array($currentyear, $arrayyears)) { - $arrayyears[$currentyear] = $currentyear; + $arrayyears[$currentyear] = (string) $currentyear; } arsort($arrayyears); print $form->selectarray('search_year', $arrayyears, $search_year, 1, 0, 0, '', 0, 0, 0, '', 'width75'); @@ -490,30 +490,30 @@ if ($result || !($id > 0)) { continue; } - if ($graphfiles == 'propal' && !$user->hasRight('propal', 'lire')) { + if ($key == 'propal' && !$user->hasRight('propal', 'lire')) { continue; } - if ($graphfiles == 'order' && !$user->hasRight('commande', 'lire')) { + if ($key == 'order' && !$user->hasRight('commande', 'lire')) { continue; } - if ($graphfiles == 'invoices' && !$user->hasRight('facture', 'lire')) { + if ($key == 'invoices' && !$user->hasRight('facture', 'lire')) { continue; } - if ($graphfiles == 'proposals_suppliers' && !$user->hasRight('supplier_proposal', 'lire')) { + if ($key == 'proposals_suppliers' && !$user->hasRight('supplier_proposal', 'lire')) { continue; } - if ($graphfiles == 'invoices_suppliers' && !$user->hasRight('fournisseur', 'facture', 'lire')) { + if ($key == 'invoices_suppliers' && !$user->hasRight('fournisseur', 'facture', 'lire')) { continue; } - if ($graphfiles == 'orders_suppliers' && !$user->hasRight('fournisseur', 'commande', 'lire')) { + if ($key == 'orders_suppliers' && !$user->hasRight('fournisseur', 'commande', 'lire')) { continue; } - if ($graphfiles == 'mrp' && !$user->hasRight('mrp', 'read')) { + if ($key == 'mrp' && !$user->hasRight('mrp', 'read')) { continue; } - if ($i % 2 == 0) { + if (($i % 2) == 0) { print "\n".'
'."\n"; } else { print "\n".'
'."\n"; diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index 20822e9a209..06168cb5237 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Florian Henry * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -172,10 +173,10 @@ if ($id > 0 || !empty($ref)) { $sql .= " AND d.fk_commande = c.rowid"; $sql .= " AND d.fk_product = ".((int) $product->id); if (!empty($search_month)) { - $sql .= " AND MONTH(c.date_commande) IN (".$db->sanitize($search_month).")"; + $sql .= " AND MONTH(c.date_commande) = ".((int) $search_month); } if (!empty($search_year)) { - $sql .= " AND YEAR(c.date_commande) IN (".$db->sanitize($search_year).")"; + $sql .= " AND YEAR(c.date_commande) = ".((int) $search_year); } if (!$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); @@ -243,7 +244,7 @@ if ($id > 0 || !empty($ref)) { print '
'; print $langs->trans('Period').' ('.$langs->trans("OrderDate").') - '; print $langs->trans('Month').': '; - print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print $langs->trans('Year').':'.$formother->selectyear(($search_year ? (string) $search_year : '-1'), 'search_year', 1, 20, 5); print $langs->trans('Status'); $formorder->selectOrderStatus($search_status, 1, 'search_status'); print '
'; diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index 7279c322ef3..1358456ce44 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -5,6 +5,7 @@ * Copyright (C) 2014 Florian Henry * Copyright (C) 2024 Frédéric France * Copyright (C) 2024 Charlene Benke + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -173,10 +174,10 @@ if ($id > 0 || !empty($ref)) { $sql .= " AND d.fk_commande = c.rowid"; $sql .= " AND d.fk_product = ".((int) $product->id); if (!empty($search_month)) { - $sql .= " AND MONTH(c.date_commande) IN (".$db->sanitize($search_month).")"; + $sql .= " AND MONTH(c.date_commande) = ".((int) $search_month); } if (!empty($search_year)) { - $sql .= " AND YEAR(c.date_commande) IN (".$db->sanitize($search_year).")"; + $sql .= " AND YEAR(c.date_commande) = ".((int) $search_year); } if (!$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); @@ -244,7 +245,7 @@ if ($id > 0 || !empty($ref)) { print '
'; print $langs->trans('Period').' ('.$langs->trans("OrderDate").') - '; print $langs->trans('Month').': '; - print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print $langs->trans('Year').':'.$formother->selectyear(($search_year ? (string) $search_year : '-1'), 'search_year', 1, 20, 5); print $langs->trans('Status'); $formorder->selectSupplierOrderStatus($search_status, 1, 'search_status'); print '
'; diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index 593fe5c25aa..7903b1663fd 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -139,10 +140,10 @@ if ($id > 0 || !empty($ref)) { $now = dol_now(); $sql = "SELECT"; - $sql .= " sum(".$db->ifsql("cd.statut=0", 1, 0).') as nb_initial,'; - $sql .= " sum(".$db->ifsql("cd.statut=4 AND cd.date_fin_validite > '".$db->idate($now)."'", 1, 0).") as nb_running,"; - $sql .= " sum(".$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite <= '".$db->idate($now)."')", 1, 0).') as nb_late,'; - $sql .= " sum(".$db->ifsql("cd.statut=5", 1, 0).') as nb_closed,'; + $sql .= " sum(".$db->ifsql("cd.statut=0", '1', '0').') as nb_initial,'; + $sql .= " sum(".$db->ifsql("cd.statut=4 AND cd.date_fin_validite > '".$db->idate($now)."'", '1', '0').") as nb_running,"; + $sql .= " sum(".$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite <= '".$db->idate($now)."')", '1', '0').') as nb_late,'; + $sql .= " sum(".$db->ifsql("cd.statut=5", '1', '0').') as nb_closed,'; $sql .= " c.rowid as rowid, c.ref, c.ref_customer, c.ref_supplier, c.date_contrat, c.statut as statut,"; $sql .= " s.nom as name, s.rowid as socid, s.code_client"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; diff --git a/htdocs/product/stats/expedition.php b/htdocs/product/stats/expedition.php index 595f05526af..83d6c52e444 100644 --- a/htdocs/product/stats/expedition.php +++ b/htdocs/product/stats/expedition.php @@ -5,6 +5,7 @@ * Copyright (C) 2014 Florian Henry * Copyright (C) 2024 Jean-Rémi Taponier * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -164,10 +165,10 @@ if ($id > 0 || !empty($ref)) { $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; $sql .= " AND cd.fk_product = ".((int) $product->id); if (!empty($search_month)) { - $sql .= ' AND MONTH(e.date_creation) IN ('.$db->sanitize($search_month).')'; + $sql .= ' AND MONTH(e.date_creation) ='.((int) $search_month); } if (!empty($search_year)) { - $sql .= ' AND YEAR(e.date_creation) IN ('.$db->sanitize($search_year).')'; + $sql .= ' AND YEAR(e.date_creation) ='.((int) $search_year); } if ($socid) { $sql .= " AND e.fk_soc = ".((int) $socid); @@ -223,7 +224,7 @@ if ($id > 0 || !empty($ref)) { print '
'; print $langs->trans('Period').' ('.$langs->trans("DateCreation").') - '; print $langs->trans('Month').': '; - print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print $langs->trans('Year').':'.$formother->selectyear(($search_year ? (string) $search_year : '-1'), 'search_year', 1, 20, 5); print '
'; print ''; print ''; diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 82be6f9503a..2ea447de01e 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -5,6 +5,7 @@ * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2014 Florian Henry * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -165,10 +166,10 @@ if ($id > 0 || !empty($ref)) { $sql .= " AND d.fk_facture_fourn = f.rowid"; $sql .= " AND d.fk_product = ".((int) $product->id); if (!empty($search_month)) { - $sql .= ' AND MONTH(f.datef) IN ('.$db->sanitize($search_month).')'; + $sql .= ' AND MONTH(f.datef) = '.((int) $search_month); } if (!empty($search_year)) { - $sql .= ' AND YEAR(f.datef) IN ('.$db->sanitize($search_year).')'; + $sql .= ' AND YEAR(f.datef) = '.((int) $search_year); } if (!$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); @@ -227,7 +228,7 @@ if ($id > 0 || !empty($ref)) { print '
'; print $langs->trans('Period').' ('.$langs->trans("DateInvoice").') - '; print $langs->trans('Month').': '; - print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print $langs->trans('Year').':'.$formother->selectyear(($search_year ? (string) $search_year : '-1'), 'search_year', 1, 20, 5); print '
'; print ''; print ''; diff --git a/htdocs/product/stats/facturerec.php b/htdocs/product/stats/facturerec.php index 9b08fd822db..04040fad093 100644 --- a/htdocs/product/stats/facturerec.php +++ b/htdocs/product/stats/facturerec.php @@ -6,6 +6,7 @@ * Copyright (C) 2014 Florian Henry * Copyright (C) 2022 Eric Seigne * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -181,10 +182,10 @@ if ($id > 0 || !empty($ref)) { $sql .= " AND d.fk_facture = f.rowid"; $sql .= " AND d.fk_product = ".((int) $product->id); if (!empty($search_month)) { - $sql .= ' AND MONTH(f.datec) IN ('.$db->sanitize($search_month).')'; + $sql .= ' AND MONTH(f.datec) = '.((int) $search_month); } if (!empty($search_year)) { - $sql .= ' AND YEAR(f.datec) IN ('.$db->sanitize($search_year).')'; + $sql .= ' AND YEAR(f.datec) = '.((int) $search_year); } if (!$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); @@ -243,7 +244,7 @@ if ($id > 0 || !empty($ref)) { print '
'; print $langs->trans('Period').' ('.$langs->trans("DateInvoice").') - '; print $langs->trans('Month').': '; - print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print $langs->trans('Year').':'.$formother->selectyear(($search_year ? (string) $search_year : '-1'), 'search_year', 1, 20, 5); print '
'; print ''; print ''; diff --git a/htdocs/product/stats/mo.php b/htdocs/product/stats/mo.php index 23a987a6243..f94a7a4fcc4 100644 --- a/htdocs/product/stats/mo.php +++ b/htdocs/product/stats/mo.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2023 Gauthier VERDOL * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -44,6 +45,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $langs->loadLangs(array('mrp', 'products', 'companies')); $id = GETPOSTINT('id'); +; $ref = GETPOST('ref', 'alpha'); // Security check @@ -150,10 +152,10 @@ if ($id > 0 || !empty($ref)) { $now = dol_now(); $sql = "SELECT"; - $sql .= " sum(".$db->ifsql("cd.role='toconsume'", "cd.qty", 0).') as nb_toconsume,'; - $sql .= " sum(".$db->ifsql("cd.role='consumed'", "cd.qty", 0).') as nb_consumed,'; - $sql .= " sum(".$db->ifsql("cd.role='toproduce'", "cd.qty", 0).') as nb_toproduce,'; - $sql .= " sum(".$db->ifsql("cd.role='produced'", "cd.qty", 0).') as nb_produced,'; + $sql .= " sum(".$db->ifsql("cd.role='toconsume'", "cd.qty", '0').') as nb_toconsume,'; + $sql .= " sum(".$db->ifsql("cd.role='consumed'", "cd.qty", '0').') as nb_consumed,'; + $sql .= " sum(".$db->ifsql("cd.role='toproduce'", "cd.qty", '0').') as nb_toproduce,'; + $sql .= " sum(".$db->ifsql("cd.role='produced'", "cd.qty", '0').') as nb_produced,'; $sql .= " c.rowid as rowid, c.ref, c.date_valid, c.status"; //$sql .= " s.nom as name, s.rowid as socid, s.code_client"; $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as c"; @@ -162,10 +164,10 @@ if ($id > 0 || !empty($ref)) { $sql .= " AND c.entity IN (".getEntity('mo').")"; $sql .= " AND cd.fk_product = ".((int) $product->id); if (!empty($search_month)) { - $sql .= ' AND MONTH(c.date_valid) IN ('.$db->sanitize($search_month).')'; + $sql .= ' AND MONTH(c.date_valid) = '.((int) $search_month); } if (!empty($search_year)) { - $sql .= ' AND YEAR(c.date_valid) IN ('.$db->sanitize($search_year).')'; + $sql .= ' AND YEAR(c.date_valid) = '.((int) $search_year); } if ($socid > 0) { $sql .= " AND s.rowid = ".((int) $socid); @@ -219,7 +221,7 @@ if ($id > 0 || !empty($ref)) { print '
'; print $langs->trans('Period').' ('.$langs->trans("DateCreation").') - '; print $langs->trans('Month').': '; - print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print $langs->trans('Year').':'.$formother->selectyear(($search_year ? (string) $search_year : '-1'), 'search_year', 1, 20, 5); print '
'; print ''; print ''; diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index 0b3ca3d1c4c..a508c415e8c 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Florian Henry * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -167,10 +168,10 @@ if ($id > 0 || !empty($ref)) { $sql .= " AND d.fk_propal = p.rowid"; $sql .= " AND d.fk_product = ".((int) $product->id); if (!empty($search_month)) { - $sql .= ' AND MONTH(p.datep) IN ('.$db->sanitize($search_month).')'; + $sql .= ' AND MONTH(p.datep) = '.((int) $search_month); } if (!empty($search_year)) { - $sql .= ' AND YEAR(p.datep) IN ('.$db->sanitize($search_year).')'; + $sql .= ' AND YEAR(p.datep) = '.((int) $search_year); } if (!$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); @@ -229,7 +230,7 @@ if ($id > 0 || !empty($ref)) { print '
'; print $langs->trans('Period').' ('.$langs->trans("DatePropal").') - '; print $langs->trans('Month').': '; - print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print $langs->trans('Year').':'.$formother->selectyear(($search_year ? (string) $search_year : '-1'), 'search_year', 1, 20, 5); print '
'; print ''; print ''; diff --git a/htdocs/product/stats/reception.php b/htdocs/product/stats/reception.php index d7440722d81..5c41291924d 100644 --- a/htdocs/product/stats/reception.php +++ b/htdocs/product/stats/reception.php @@ -5,6 +5,7 @@ * Copyright (C) 2014 Florian Henry * Copyright (C) 2024 Jean-Rémi Taponier * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -163,10 +164,10 @@ if ($id > 0 || !empty($ref)) { $sql .= " WHERE r.entity IN (".getEntity('reception').")"; $sql .= " AND cfd.fk_product = ".((int) $product->id); if (!empty($search_month)) { - $sql .= ' AND MONTH(r.date_creation) IN ('.$db->sanitize($search_month).')'; + $sql .= ' AND MONTH(r.date_creation) = '.((int) $search_month); } if (!empty($search_year)) { - $sql .= ' AND YEAR(r.date_creation) IN ('.$db->sanitize($search_year).')'; + $sql .= ' AND YEAR(r.date_creation) = '.((int) $search_year); } if ($socid) { $sql .= " AND r.fk_soc = ".((int) $socid); @@ -222,7 +223,7 @@ if ($id > 0 || !empty($ref)) { print '
'; print $langs->trans('Period').' ('.$langs->trans("DateCreation").') - '; print $langs->trans('Month').': '; - print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print $langs->trans('Year').':'.$formother->selectyear(($search_year ? (string) $search_year : '-1'), 'search_year', 1, 20, 5); print '
'; print ''; print ''; diff --git a/htdocs/product/stats/supplier_proposal.php b/htdocs/product/stats/supplier_proposal.php index df00f9381a6..9bde87ea5b6 100644 --- a/htdocs/product/stats/supplier_proposal.php +++ b/htdocs/product/stats/supplier_proposal.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Florian Henry * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -164,10 +165,10 @@ if ($id > 0 || !empty($ref)) { $sql .= " AND d.fk_supplier_proposal = p.rowid"; $sql .= " AND d.fk_product = ".((int) $product->id); if (!empty($search_month)) { - $sql .= ' AND MONTH(p.datep) IN ('.$db->sanitize($search_month).')'; + $sql .= ' AND MONTH(p.datep) = '.((int) $search_month); } if (!empty($search_year)) { - $sql .= ' AND YEAR(p.datep) IN ('.$db->sanitize($search_year).')'; + $sql .= ' AND YEAR(p.datep) = '.((int) $search_year); } if (!$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); @@ -226,7 +227,7 @@ if ($id > 0 || !empty($ref)) { print '
'; print $langs->trans('Period').' ('.$langs->trans("DatePropal").') - '; print $langs->trans('Month').': '; - print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print $langs->trans('Year').':'.$formother->selectyear(($search_year ? (string) $search_year : '-1'), 'search_year', 1, 20, 5); print '
'; print ''; print ''; diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 1914448023d..41bcc14c066 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -8,7 +8,7 @@ * Copyright (C) 2021-2024 Frédéric France * Copyright (C) 2022-2023 Charlene Benke * Copyright (C) 2023 Christian Foellmann - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -212,14 +212,14 @@ if (empty($reshook)) { if ($object->fetch($id)) { $object->label = GETPOST("libelle"); $object->fk_parent = GETPOST("fk_parent"); - $object->fk_project = GETPOST('projectid'); + $object->fk_project = GETPOSTINT('projectid'); $object->description = GETPOST("desc", 'restricthtml'); $object->statut = GETPOST("statut"); $object->lieu = GETPOST("lieu"); $object->address = GETPOST("address"); $object->zip = GETPOST("zipcode"); $object->town = GETPOST("town"); - $object->country_id = GETPOST("country_id"); + $object->country_id = GETPOSTINT("country_id"); $object->phone = GETPOST("phone"); $object->fax = GETPOST("fax"); @@ -292,6 +292,7 @@ $form = new Form($db); $formproduct = new FormProduct($db); $formcompany = new FormCompany($db); $formfile = new FormFile($db); +$formproject = null; if (isModEnabled('project')) { $formproject = new FormProjets($db); } @@ -330,10 +331,10 @@ if ($action == 'create') { print '
'.$langs->trans('Project').''; - print img_picto('', 'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); + print img_picto('', 'project').$formproject->select_projects(($socid > 0 ? $socid : -1), (string) $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); print ' '; print '
'.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_WAREHOUSE, '', 'parent', 64, 0, 3); - print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); + print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); print "
'; @@ -457,7 +458,7 @@ if ($action == 'create') { $morehtmlref .= $langs->trans("LocationSummary").' : '.$object->lieu; // Project - if (isModEnabled('project')) { + if (isModEnabled('project') && $formproject !== null) { $langs->load("projects"); $morehtmlref .= '
'.img_picto('', 'project').' '.$langs->trans('Project').' '; if ($usercancreate) { @@ -469,11 +470,11 @@ if ($action == 'create') { $morehtmlref .= ''; $morehtmlref .= ''; $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); + $morehtmlref .= $formproject->select_projects(($socid > 0 ? $socid : -1), (string) $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, ($socid > 0 ? $socid : -1), $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, ($socid > 0 ? $socid : -1), (string) $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { @@ -555,6 +556,7 @@ if ($action == 'create') { $sql = "SELECT max(m.datem) as datem"; $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; $sql .= " WHERE m.fk_entrepot = ".((int) $object->id); + $lastmovementdate = 0; $resqlbis = $db->query($sql); if ($resqlbis) { $obj = $db->fetch_object($resqlbis); @@ -818,6 +820,7 @@ if ($action == 'create') { print ''.price(price2num($objp->ppmp * $objp->value, 'MT')).''; $totalvalue += price2num($objp->ppmp * $objp->value, 'MT'); + $pricemin = 0; // Price sell min if (!getDolGlobalString('PRODUIT_MULTIPRICES')) { $pricemin = $objp->price; @@ -914,11 +917,11 @@ if ($action == 'create') { print ''; // Project - if (isModEnabled('project')) { + if (isModEnabled('project') && $formproject !== null) { $projectid = $object->fk_project; $langs->load('projects'); print ''.$langs->trans('Project').''; - print img_picto('', 'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); + print img_picto('', 'project').$formproject->select_projects(($socid > 0 ? $socid : -1), (string) $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); print '
0 ? '&socid='.$socid : "")).'">'; print ''; } @@ -993,7 +996,7 @@ if ($action == 'create') { foreach ($cats as $cat) { $arrayselected[] = $cat->id; } - print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); + print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('categories', $cate_arbo, $arrayselected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); print ""; } @@ -1028,7 +1031,7 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete') { $delallowed = $usercancreate; $modulepart = 'stock'; - print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, '', 0, '', '', '', $object); + print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, '', '', '', '', '', $object); $somethingshown = $formfile->numoffiles; print '
'; diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index ebe21bdc622..88cdb7a8585 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -1059,7 +1059,8 @@ class Entrepot extends CommonObject if (property_exists($this, 'lieu') && (!empty($this->lieu))) { $return .= '
'.$this->lieu.''; } - if (property_exists($this, 'sellvalue') && $this->sellvalue != 0) { + if (property_exists($this, 'sellvalue') && $this->sellvalue != 0) { // @phan-suppress-current-line PhanUndeclaredProperty + // @phan-suppress-next-line PhanUndeclaredProperty $return .= '
'.price($this->sellvalue).''; } if (method_exists($this, 'getLibStatut')) { diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 1c96b0284e3..7659c066370 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -209,17 +209,17 @@ class MouvementStock extends CommonObject * @param string $label Label of stock movement * @param string $inventorycode Inventory code * @param int|string $datem Force date of movement - * @param int|string $eatby eat-by date. Will be used if lot does not exists yet and will be created. - * @param int|string $sellby sell-by date. Will be used if lot does not exists yet and will be created. + * @param int|'' $eatby eat-by date. Will be used if lot does not exists yet and will be created. + * @param int|'' $sellby sell-by date. Will be used if lot does not exists yet and will be created. * @param string $batch batch number - * @param boolean $skip_batch If set to true, stock movement is done without impacting batch record + * @param bool $skip_batch If set to true, stock movement is done without impacting batch record * @param int $id_product_batch Id product_batch (when skip_batch is false and we already know which record of product_batch to use) * @param int<0,1> $disablestockchangeforsubproduct Disable stock change for sub-products of kit (useful only if product is a subproduct) * @param int<0,1> $donotcleanemptylines Do not clean lines in stock table with qty=0 (because we want to have this done by the caller) * @param bool $force_update_batch Allows to add batch stock movement even if $product doesn't use batch anymore * @return int Return integer <0 if KO, 0 if fk_product is null or product id does not exists, >0 if OK */ - public function _create($user, $fk_product, $entrepot_id, $qty, $type, $price = 0, $label = '', $inventorycode = '', $datem = '', $eatby = '', $sellby = '', $batch = '', $skip_batch = false, $id_product_batch = 0, $disablestockchangeforsubproduct = 0, $donotcleanemptylines = 0, $force_update_batch = false) + public function _create($user, $fk_product, $entrepot_id, $qty, $type, $price = 0, $label = '', $inventorycode = '', $datem = '', $eatby = 0, $sellby = 0, $batch = '', $skip_batch = false, $id_product_batch = 0, $disablestockchangeforsubproduct = 0, $donotcleanemptylines = 0, $force_update_batch = false) { // phpcs:enable global $conf, $langs; @@ -363,7 +363,7 @@ class MouvementStock extends CommonObject $obj = $this->db->fetch_object($resql); if ($obj->eatby) { if ($eatby) { - $tmparray = dol_getdate($eatby, true); + $tmparray = dol_getdate((int) $eatby, true); $eatbywithouthour = dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); if ($this->db->jdate($obj->eatby) != $eatby && $this->db->jdate($obj->eatby) != $eatbywithouthour) { // We test date without hours and with hours for backward compatibility // If found and eatby/sellby defined into table and provided and differs, return error @@ -392,7 +392,7 @@ class MouvementStock extends CommonObject } if ($obj->sellby) { if ($sellby) { - $tmparray = dol_getdate($sellby, true); + $tmparray = dol_getdate((int) $sellby, true); $sellbywithouthour = dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); if ($this->db->jdate($obj->sellby) != $sellby && $this->db->jdate($obj->sellby) != $sellbywithouthour) { // We test date without hours and with hours for backward compatibility // If found and eatby/sellby defined into table and provided and differs, return error diff --git a/htdocs/product/stock/info.php b/htdocs/product/stock/info.php index d400873d96b..8487bd92637 100644 --- a/htdocs/product/stock/info.php +++ b/htdocs/product/stock/info.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -87,15 +88,16 @@ if (isModEnabled('project')) { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; } if ($action == 'classify') { + $formproject = new FormProjets($db); $projectid = $object->fk_project; $morehtmlref .= '
'; $morehtmlref .= ''; $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); + $morehtmlref .= $formproject->select_projects(($socid > 0 ? $socid : -1), (string) $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); $morehtmlref .= ''; $morehtmlref .= '
'; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (!empty($object->socid) ? $object->socid : 0), $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (!empty($object->socid) ? $object->socid : 0), (string) $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index ed830e2cc3e..d00b85f8be8 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2015 Juanjo Menent * Copyright (C) 2020 Tobias Sekan - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -121,9 +121,9 @@ foreach ($object->fields as $key => $val) { // Definition of array of fields for columns $arrayfields = array( - 'stockqty' => array('type' => 'float', 'label' => 'PhysicalStock', 'enabled' => 1, 'visible' => -2, 'checked' => 0, 'position' => 170), - 'estimatedvalue' => array('type' => 'float', 'label' => 'EstimatedStockValue', 'enabled' => 1, 'visible' => 1, 'checked' => 1, 'position' => 171), - 'estimatedstockvaluesell' => array('type' => 'float', 'label' => 'EstimatedStockValueSell', 'enabled' => 1, 'checked' => 1, 'visible' => 2, 'position' => 172), + 'stockqty' => array('type' => 'float', 'label' => 'PhysicalStock', 'enabled' => '1', 'visible' => -2, 'checked' => '0', 'position' => 170), + 'estimatedvalue' => array('type' => 'float', 'label' => 'EstimatedStockValue', 'enabled' => '1', 'visible' => 1, 'checked' => '1', 'position' => 171), + 'estimatedstockvaluesell' => array('type' => 'float', 'label' => 'EstimatedStockValueSell', 'enabled' => '1', 'checked' => '1', 'visible' => 2, 'position' => 172), ); foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field @@ -131,8 +131,8 @@ foreach ($object->fields as $key => $val) { $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)), + 'checked' => (($visible < 0) ? '0' : '1'), + 'enabled' => (string) (int) (abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)), 'position' => $val['position'], 'help' => isset($val['help']) ? $val['help'] : '' ); @@ -256,7 +256,7 @@ if ($separatedPMP) { } $sql .= " WHERE t.entity IN (".getEntity('stock').")"; foreach ($search as $key => $val) { - if (array_key_exists($key, $object->fields)||$key == 'status') { + if (array_key_exists($key, $object->fields) || $key == 'status') { $class_key = $key; if ($class_key == 'status') { $class_key = 'statut'; // remove this after refactoring entrepot.class property statut to status @@ -279,10 +279,10 @@ foreach ($search as $key => $val) { $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key); if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) { if (preg_match('/_dtstart$/', $key)) { - $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'"; + $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate((int) $search[$key])."'"; } if (preg_match('/_dtend$/', $key)) { - $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'"; + $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate((int) $search[$key])."'"; } } } @@ -581,7 +581,7 @@ foreach ($object->fields as $key => $val) { } elseif ($key == 'lang') { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $formadmin = new FormAdmin($db); - print $formadmin->select_language($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 ''; } @@ -781,7 +781,7 @@ while ($i < $imaxinloop) { if (!empty($arrayfields['t.'.$key]['checked'])) { print '$key)) { - print ' title="'.dol_escape_htmltag($object->$key).'"'; + print ' title="'.dol_escape_htmltag((string) $object->$key).'"'; } print '>'; if ($key == 'statut') { @@ -792,7 +792,7 @@ while ($i < $imaxinloop) { } elseif ($key == 'fax') { print dol_print_phone($object->fax, '', 0, $object->id, 'AC_FAX'); } else { - print $warehouse->showOutputField($val, $key, $object->$key, ''); + print $warehouse->showOutputField($val, $key, (string) $object->$key, ''); } print ''; if (!$i) { diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index 1eea94722db..0e55f337b9a 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -1,7 +1,7 @@ * Copyright (C) 2014 Regis Houssin - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software: you can redistribute it and/or modify @@ -228,7 +228,7 @@ if ($action == 'createmovements' && $user->hasRight('stock', 'mouvement', 'creer $result1 = $product->correct_stock( $user, $id_sw, - $qty, + (float) $qty, 1, GETPOST("label"), $pricesrc, @@ -244,7 +244,7 @@ if ($action == 'createmovements' && $user->hasRight('stock', 'mouvement', 'creer $result2 = $product->correct_stock( $user, $id_tw, - $qty, + (float) $qty, 0, GETPOST("label"), $pricedest, @@ -275,7 +275,7 @@ if ($action == 'createmovements' && $user->hasRight('stock', 'mouvement', 'creer $result1 = $product->correct_stock_batch( $user, $id_sw, - $qty, + (float) $qty, 1, GETPOST("label"), $pricesrc, @@ -294,7 +294,7 @@ if ($action == 'createmovements' && $user->hasRight('stock', 'mouvement', 'creer $result2 = $product->correct_stock_batch( $user, $id_tw, - $qty, + (float) $qty, 0, GETPOST("label"), $pricedest, @@ -686,11 +686,11 @@ print ''; print ''; // From warehouse print ''; -print img_picto($langs->trans("WarehouseSource"), 'stock', 'class="paddingright"').$formproduct->selectWarehouses($id_sw, 'id_sw', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200'); +print img_picto($langs->trans("WarehouseSource"), 'stock', 'class="paddingright"').$formproduct->selectWarehouses(is_null($id_sw) ? '' : $id_sw, 'id_sw', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200'); print ''; // To warehouse print ''; -print img_picto($langs->trans("WarehouseTarget"), 'stock', 'class="paddingright"').$formproduct->selectWarehouses($id_tw, 'id_tw', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200'); +print img_picto($langs->trans("WarehouseTarget"), 'stock', 'class="paddingright"').$formproduct->selectWarehouses(is_null($id_sw) ? '' : $id_tw, 'id_tw', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200'); print ''; // Product print ''; @@ -699,9 +699,9 @@ if (getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { $filtertype = ''; } if (getDolGlobalInt('PRODUIT_LIMIT_SIZE') <= 0) { - $limit = ''; + $limit = 0; } else { - $limit = getDolGlobalString('PRODUIT_LIMIT_SIZE'); + $limit = getDolGlobalInt('PRODUIT_LIMIT_SIZE'); } print img_picto($langs->trans("Product"), 'product', 'class="paddingright"'); print $form->select_produits((isset($id_product) ? $id_product : 0), 'productid', $filtertype, $limit, 0, -1, 2, '', 1, array(), 0, '1', 0, 'minwidth200imp maxwidth300', 1, '', null, 1); diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index 9c81e707e3d..590420e2028 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -5,7 +5,7 @@ * Copyright (C) 2015 Juanjo Menent * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2019-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -114,23 +114,23 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); $arrayfields = array( - 'm.rowid' => array('label' => $langs->trans("Ref"), 'checked' => 1), - 'm.datem' => array('label' => $langs->trans("Date"), 'checked' => 1), - 'p.ref' => array('label' => $langs->trans("ProductRef"), 'checked' => 1, 'css' => 'maxwidth100'), - 'p.label' => array('label' => $langs->trans("ProductLabel"), 'checked' => 1), - 'm.batch' => array('label' => $langs->trans("BatchNumberShort"), 'checked' => 1, 'enabled' => (isModEnabled('productbatch'))), - 'pl.eatby' => array('label' => $langs->trans("EatByDate"), 'checked' => 0, 'position' => 10, 'enabled' => (isModEnabled('productbatch'))), - 'pl.sellby' => array('label' => $langs->trans("SellByDate"), 'checked' => 0, 'position' => 10, 'enabled' => (isModEnabled('productbatch'))), - 'e.ref' => array('label' => $langs->trans("Warehouse"), 'checked' => 1, 'enabled' => (!($id > 0))), // If we are on specific warehouse, we hide it - 'm.fk_user_author' => array('label' => $langs->trans("Author"), 'checked' => 0), - 'm.inventorycode' => array('label' => $langs->trans("InventoryCodeShort"), 'checked' => 1), - 'm.label' => array('label' => $langs->trans("MovementLabel"), 'checked' => 1), - 'm.type_mouvement' => array('label' => $langs->trans("TypeMovement"), 'checked' => 1), - 'origin' => array('label' => $langs->trans("Origin"), 'checked' => 1), - 'm.value' => array('label' => $langs->trans("Qty"), 'checked' => 1), - 'm.price' => array('label' => $langs->trans("UnitPurchaseValue"), 'checked' => 0), - //'m.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), - //'m.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500) + 'm.rowid' => array('label' => $langs->trans("Ref"), 'checked' => '1'), + 'm.datem' => array('label' => $langs->trans("Date"), 'checked' => '1'), + 'p.ref' => array('label' => $langs->trans("ProductRef"), 'checked' => '1', 'css' => 'maxwidth100'), + 'p.label' => array('label' => $langs->trans("ProductLabel"), 'checked' => '1'), + 'm.batch' => array('label' => $langs->trans("BatchNumberShort"), 'checked' => '1', 'enabled' => (string) (int) (isModEnabled('productbatch'))), + 'pl.eatby' => array('label' => $langs->trans("EatByDate"), 'checked' => '0', 'position' => 10, 'enabled' => (string) (int) (isModEnabled('productbatch'))), + 'pl.sellby' => array('label' => $langs->trans("SellByDate"), 'checked' => '0', 'position' => 10, 'enabled' => (string) (int) (isModEnabled('productbatch'))), + 'e.ref' => array('label' => $langs->trans("Warehouse"), 'checked' => '1', 'enabled' => (string) (int) (!($id > 0))), // If we are on specific warehouse, we hide it + 'm.fk_user_author' => array('label' => $langs->trans("Author"), 'checked' => '0'), + 'm.inventorycode' => array('label' => $langs->trans("InventoryCodeShort"), 'checked' => '1'), + 'm.label' => array('label' => $langs->trans("MovementLabel"), 'checked' => '1'), + 'm.type_mouvement' => array('label' => $langs->trans("TypeMovement"), 'checked' => '1'), + 'origin' => array('label' => $langs->trans("Origin"), 'checked' => '1'), + 'm.value' => array('label' => $langs->trans("Qty"), 'checked' => '1'), + 'm.price' => array('label' => $langs->trans("UnitPurchaseValue"), 'checked' => '0'), + //'m.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked' => '0', 'position'=>500), + //'m.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked' => '0', 'position'=>500) ); $usercanread = (($user->hasRight('stock', 'mouvement', 'lire'))); @@ -218,10 +218,10 @@ if ($action == "correct_stock" && !$cancel && $usercancreate) { $result = $product->correct_stock_batch( $user, $id, - GETPOSTINT("nbpiece"), + GETPOSTFLOAT("nbpiece"), GETPOSTINT("mouvement"), GETPOST("label", 'san_alpha'), - GETPOST('unitprice', 'alpha'), + GETPOSTFLOAT('unitprice'), $eatby, $sellby, $batch, @@ -233,10 +233,10 @@ if ($action == "correct_stock" && !$cancel && $usercancreate) { $result = $product->correct_stock( $user, $id, - GETPOSTINT("nbpiece"), - GETPOST("mouvement", 'alpha'), + GETPOSTFLOAT("nbpiece"), + GETPOSTINT("mouvement"), GETPOST("label", 'san_alpha'), - GETPOST('unitprice', 'alpha'), + GETPOSTFLOAT('unitprice'), GETPOST('inventorycode', 'alpha'), $origin_element, $origin_id @@ -276,7 +276,7 @@ if ($action == "transfert_stock" && !$cancel && $usercancreate) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); $action = 'transfert'; } - if (!GETPOSTINT("nbpiece")) { + if (!GETPOSTFLOAT("nbpiece")) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); $error++; $action = 'transfert'; @@ -314,14 +314,22 @@ if ($action == "transfert_stock" && !$cancel && $usercancreate) { } $pricedest = $pricesrc; + $result1 = -1; + $result2 = -1; + if ($product->hasbatch()) { $pdluo = new Productbatch($db); + $batch = ''; + $eatby = 0; + $sellby = 0; + $srcwarehouseid = 0; + if ($pdluoid > 0) { $result = $pdluo->fetch($pdluoid); if ($result) { $srcwarehouseid = $pdluo->warehouseid; - $batch = $pdluo->batch; + $batch = (string) $pdluo->batch; $eatby = $pdluo->eatby; $sellby = $pdluo->sellby; } else { @@ -330,7 +338,7 @@ if ($action == "transfert_stock" && !$cancel && $usercancreate) { } } else { $srcwarehouseid = $id; - $batch = GETPOST('batch_number', 'alpha'); + $batch = (string) GETPOST('batch_number', 'alpha'); $eatby = $d_eatby; $sellby = $d_sellby; } @@ -340,7 +348,7 @@ if ($action == "transfert_stock" && !$cancel && $usercancreate) { $result1 = $product->correct_stock_batch( $user, $srcwarehouseid, - GETPOSTINT("nbpiece"), + GETPOSTFLOAT("nbpiece"), 1, GETPOST("label", 'san_alpha'), $pricesrc, @@ -353,7 +361,7 @@ if ($action == "transfert_stock" && !$cancel && $usercancreate) { $result2 = $product->correct_stock_batch( $user, GETPOSTINT("id_entrepot_destination"), - GETPOSTINT("nbpiece"), + GETPOSTFLOAT("nbpiece"), 0, GETPOST("label", 'san_alpha'), $pricedest, @@ -368,7 +376,7 @@ if ($action == "transfert_stock" && !$cancel && $usercancreate) { $result1 = $product->correct_stock( $user, $id, - GETPOSTINT("nbpiece"), + GETPOSTFLOAT("nbpiece"), 1, GETPOST("label", 'alpha'), $pricesrc, @@ -378,8 +386,8 @@ if ($action == "transfert_stock" && !$cancel && $usercancreate) { // Add stock $result2 = $product->correct_stock( $user, - GETPOST("id_entrepot_destination"), - GETPOSTINT("nbpiece"), + GETPOSTINT("id_entrepot_destination"), + GETPOSTFLOAT("nbpiece"), 0, GETPOST("label", 'alpha'), $pricedest, @@ -632,6 +640,7 @@ if ($resql) { $sql = "SELECT MAX(m.datem) as datem"; $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; $sql .= " WHERE m.fk_entrepot = ".(int) $object->id; + $lastmovementdate = 0; $resqlbis = $db->query($sql); if ($resqlbis) { $obj = $db->fetch_object($resqlbis); @@ -1218,7 +1227,7 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete' && $id > 0) $genallowed = $user->hasRight('stock', 'lire'); $delallowed = $user->hasRight('stock', 'creer'); - print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $object->default_lang, '', $object); + print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', '', '', $object->default_lang, '', $object); $somethingshown = $formfile->numoffiles; print '
'; diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index e5cabbe26d5..a8df7f3435c 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -5,7 +5,7 @@ * Copyright (C) 2015 Juanjo Menent * Copyright (C) 2018-2022 Ferran Marcet * Copyright (C) 2019-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -73,8 +73,8 @@ $mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hier $id = GETPOSTINT('id'); $ref = GETPOST('ref', 'alpha'); $msid = GETPOSTINT('msid'); -$idproduct = GETPOST('idproduct', 'intcomma'); -$product_id = GETPOST("product_id", 'intcomma'); +$idproduct = GETPOSTINT('idproduct'); +$product_id = GETPOSTINT('product_id'); $show_files = GETPOSTINT('show_files'); $search_all = trim(GETPOST('search_all', 'alphanohtml')); @@ -136,24 +136,24 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); $arrayfields = array( - 'm.rowid' => array('label' => "Ref", 'checked' => 1, 'position' => 1), - 'm.datem' => array('label' => "Date", 'checked' => 1, 'position' => 2), - 'p.ref' => array('label' => "ProductRef", 'checked' => 1, 'css' => 'maxwidth100', 'position' => 3), - 'p.label' => array('label' => "ProductLabel", 'checked' => 0, 'position' => 5), - 'm.batch' => array('label' => "BatchNumberShort", 'checked' => 1, 'position' => 8, 'enabled' => (isModEnabled('productbatch'))), - 'pl.eatby' => array('label' => "EatByDate", 'checked' => 0, 'position' => 9, 'enabled' => (isModEnabled('productbatch'))), - 'pl.sellby' => array('label' => "SellByDate", 'checked' => 0, 'position' => 10, 'enabled' => (isModEnabled('productbatch'))), - 'e.ref' => array('label' => "Warehouse", 'checked' => 1, 'position' => 100, 'enabled' => (!($id > 0))), // If we are on specific warehouse, we hide it - 'm.fk_user_author' => array('label' => "Author", 'checked' => 0, 'position' => 120), - 'm.inventorycode' => array('label' => "InventoryCodeShort", 'checked' => 1, 'position' => 130), - 'm.label' => array('label' => "MovementLabel", 'checked' => 1, 'position' => 140), - 'm.type_mouvement' => array('label' => "TypeMovement", 'checked' => 0, 'position' => 150), - 'origin' => array('label' => "Origin", 'checked' => 1, 'position' => 155), - 'm.fk_projet' => array('label' => 'Project', 'checked' => 0, 'position' => 180), - 'm.value' => array('label' => "Qty", 'checked' => 1, 'position' => 200), - 'm.price' => array('label' => "UnitPurchaseValue", 'checked' => 0, 'position' => 210, 'enabled' => (!getDolGlobalInt('STOCK_MOVEMENT_LIST_HIDE_UNIT_PRICE'))) - //'m.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), - //'m.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500) + 'm.rowid' => array('label' => "Ref", 'checked' => '1', 'position' => 1), + 'm.datem' => array('label' => "Date", 'checked' => '1', 'position' => 2), + 'p.ref' => array('label' => "ProductRef", 'checked' => '1', 'css' => 'maxwidth100', 'position' => 3), + 'p.label' => array('label' => "ProductLabel", 'checked' => '0', 'position' => 5), + 'm.batch' => array('label' => "BatchNumberShort", 'checked' => '1', 'position' => 8, 'enabled' => (string) (int) (isModEnabled('productbatch'))), + 'pl.eatby' => array('label' => "EatByDate", 'checked' => '0', 'position' => 9, 'enabled' => (string) (int) (isModEnabled('productbatch'))), + 'pl.sellby' => array('label' => "SellByDate", 'checked' => '0', 'position' => 10, 'enabled' => (string) (int) (isModEnabled('productbatch'))), + 'e.ref' => array('label' => "Warehouse", 'checked' => '1', 'position' => 100, 'enabled' => (string) (int) (!($id > 0))), // If we are on specific warehouse, we hide it + 'm.fk_user_author' => array('label' => "Author", 'checked' => '0', 'position' => 120), + 'm.inventorycode' => array('label' => "InventoryCodeShort", 'checked' => '1', 'position' => 130), + 'm.label' => array('label' => "MovementLabel", 'checked' => '1', 'position' => 140), + 'm.type_mouvement' => array('label' => "TypeMovement", 'checked' => '0', 'position' => 150), + 'origin' => array('label' => "Origin", 'checked' => '1', 'position' => 155), + 'm.fk_projet' => array('label' => 'Project', 'checked' => '0', 'position' => 180), + 'm.value' => array('label' => "Qty", 'checked' => '1', 'position' => 200), + 'm.price' => array('label' => "UnitPurchaseValue", 'checked' => '0', 'position' => 210, 'enabled' => (string) (int) (!getDolGlobalInt('STOCK_MOVEMENT_LIST_HIDE_UNIT_PRICE'))) + //'m.datec'=>array('label'=>"DateCreation", 'checked' => '0', 'position'=>500), + //'m.tms'=>array('label'=>"DateModificationShort", 'checked' => '0', 'position'=>500) ); include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; @@ -399,10 +399,10 @@ if ($action == "correct_stock" && $permissiontoadd) { $result = $product->correct_stock_batch( $user, $id, - GETPOSTINT("nbpiece"), + GETPOSTFLOAT("nbpiece"), GETPOSTINT("mouvement"), GETPOST("label", 'alphanohtml'), - price2num(GETPOST('unitprice'), 'MT'), + (float) price2num(GETPOST('unitprice'), 'MT'), $eatby, $sellby, $batch, @@ -416,10 +416,10 @@ if ($action == "correct_stock" && $permissiontoadd) { $result = $product->correct_stock( $user, $id, - GETPOSTINT("nbpiece"), + GETPOSTFLOAT("nbpiece"), GETPOSTINT("mouvement"), GETPOST("label", 'alphanohtml'), - price2num(GETPOST('unitprice'), 'MT'), + (float) price2num(GETPOST('unitprice'), 'MT'), GETPOST('inventorycode', 'alphanohtml'), $origin_element, $origin_id, @@ -461,7 +461,7 @@ if ($action == "transfert_stock" && $permissiontoadd && !$cancel) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); $action = 'transfert'; } - if (!GETPOSTINT("nbpiece")) { + if (!GETPOSTFLOAT("nbpiece")) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); $error++; $action = 'transfert'; @@ -530,7 +530,7 @@ if ($action == "transfert_stock" && $permissiontoadd && !$cancel) { $result1 = $product->correct_stock_batch( $user, $srcwarehouseid, - GETPOSTINT("nbpiece"), + GETPOSTFLOAT("nbpiece"), 1, GETPOST("label", 'san_alpha'), $pricesrc, @@ -547,7 +547,7 @@ if ($action == "transfert_stock" && $permissiontoadd && !$cancel) { $result2 = $product->correct_stock_batch( $user, GETPOSTINT("id_entrepot_destination"), - GETPOSTINT("nbpiece"), + GETPOSTFLOAT("nbpiece"), 0, GETPOST("label", 'san_alpha'), $pricedest, @@ -566,7 +566,7 @@ if ($action == "transfert_stock" && $permissiontoadd && !$cancel) { $result1 = $product->correct_stock( $user, $id, - GETPOST("nbpiece"), + GETPOSTFLOAT("nbpiece"), 1, GETPOST("label", 'san_alpha'), $pricesrc, @@ -580,8 +580,8 @@ if ($action == "transfert_stock" && $permissiontoadd && !$cancel) { // Add stock $result2 = $product->correct_stock( $user, - GETPOST("id_entrepot_destination"), - GETPOST("nbpiece"), + GETPOSTINT("id_entrepot_destination"), + GETPOSTFLOAT("nbpiece"), 0, GETPOST("label", 'san_alpha'), $pricedest, @@ -755,7 +755,7 @@ if (!empty($search_batch)) { $sql .= natural_search('m.batch', $search_batch); } if (!empty($product_id) && $product_id != '-1') { - $sql .= natural_search('p.rowid', $product_id); + $sql .= natural_search('p.rowid', (string) $product_id); } if (!empty($search_fk_project) && $search_fk_project != '-1') { $sql .= natural_search('m.fk_projet', $search_fk_project); @@ -865,7 +865,7 @@ if ($warehouse->id > 0) { if (isModEnabled('project') && $formproject !== null) { $langs->load("projects"); $morehtmlref .= '
'.img_picto('', 'project').' '.$langs->trans('Project').' '; - if ($usercancreate && 1 == 2) { + if ($usercancreate && 1 == 2) { // @phan-suppress-current-line PhanPluginBothLiteralsBinaryOp if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; } @@ -874,11 +874,11 @@ if ($warehouse->id > 0) { $morehtmlref .= '
'; $morehtmlref .= ''; $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); + $morehtmlref .= $formproject->select_projects(($socid > 0 ? $socid : -1), (string) $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); $morehtmlref .= ''; $morehtmlref .= '
'; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$warehouse->id, $warehouse->socid, $warehouse->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$warehouse->id, $warehouse->socid, (string) $warehouse->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($warehouse->fk_project)) { @@ -1688,8 +1688,8 @@ if (count($arrayofuniqueproduct) == 1 && !empty($year) && is_numeric($year)) { $productidselected = $key; $productlabelselected = $val; } - $datebefore = dol_get_first_day($year ? $year : dol_print_date(time(), "%Y"), $month ? $month : 1, true); - $dateafter = dol_get_last_day($year ? $year : dol_print_date(time(), "%Y"), $month ? $month : 12, true); + $datebefore = dol_get_first_day($year ? $year : (int) dol_print_date(time(), "%Y"), $month ? $month : 1, true); + $dateafter = dol_get_last_day($year ? $year : (int) dol_print_date(time(), "%Y"), $month ? $month : 12, true); $balancebefore = $object->calculateBalanceForProductBefore($productidselected, $datebefore); $balanceafter = $object->calculateBalanceForProductBefore($productidselected, $dateafter); diff --git a/htdocs/product/stock/stats/mo.php b/htdocs/product/stock/stats/mo.php index 9a87fa83783..b1a3477871b 100644 --- a/htdocs/product/stock/stats/mo.php +++ b/htdocs/product/stock/stats/mo.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2023 Gauthier VERDOL * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -176,9 +177,9 @@ if ($id > 0 || !empty($ref)) { $sql = "SELECT"; // $sql .= " sum(".$db->ifsql("cd.role='toconsume'", "cd.qty", 0).') as nb_toconsume,'; - $sql .= " sum(".$db->ifsql("cd.role='consumed'", "cd.qty", 0).') as nb_consumed,'; + $sql .= " sum(".$db->ifsql("cd.role='consumed'", "cd.qty", '0').') as nb_consumed,'; // $sql .= " sum(".$db->ifsql("cd.role='toproduce'", "cd.qty", 0).') as nb_toproduce,'; - $sql .= " sum(".$db->ifsql("cd.role='produced'", "cd.qty", 0).') as nb_produced,'; + $sql .= " sum(".$db->ifsql("cd.role='produced'", "cd.qty", '0').') as nb_produced,'; $sql .= " c.rowid as rowid, c.ref, c.date_valid, c.status"; //$sql .= " s.nom as name, s.rowid as socid, s.code_client"; $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as c"; diff --git a/htdocs/projet/activity/permonth.php b/htdocs/projet/activity/permonth.php index 804b4afc8f5..502e85e1cba 100644 --- a/htdocs/projet/activity/permonth.php +++ b/htdocs/projet/activity/permonth.php @@ -1,10 +1,11 @@ - * Copyright (C) 2004-2015 Laurent Destailleur - * Copyright (C) 2005-2010 Regis Houssin - * Copyright (C) 2010 François Legastelois +/* Copyright (C) 2005 Rodolphe Quiedeville + * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2010 François Legastelois * Copyright (C) 2024 MDW - * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 Alexandre Spangaro * * 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 @@ -619,29 +620,29 @@ print "\n"; print ''; if (getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT')) { - print ''.$langs->trans("Project").''; + print ''.$langs->trans("Project").''; } if (getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT')) { - print ''.$langs->trans("ThirdParty").''; + print ''.$langs->trans("ThirdParty").''; } -print ''.$langs->trans("Task").''; +print ''.$langs->trans("Task").''; if (!empty($arrayfields['t.planned_workload']['checked'])) { - print ''.$form->textwithpicto($langs->trans("PlannedWorkloadShort"), $langs->trans("PlannedWorkload")).''; + print ''.$form->textwithpicto($langs->trans("PlannedWorkloadShort"), $langs->trans("PlannedWorkload")).''; } if (!empty($arrayfields['t.progress']['checked'])) { - print ''.$langs->trans("ProgressDeclared").''; + print ''.$langs->trans("ProgressDeclared").''; } if (!empty($arrayfields['timeconsumed']['checked'])) { - print ''.$langs->trans("TimeSpentSmall").'
'; + print ''.$langs->trans("TimeSpentSmall").'
'; print ''; print 'Photo'; print ''.$langs->trans("EverybodySmall").''; print ''; - print ''; - print ''.$langs->trans("TimeSpentSmall").($usertoprocess->firstname ? '
'.$usertoprocess->getNomUrl(-2).''.dol_trunc($usertoprocess->firstname, 10).'' : '').''; + print ''; + print ''.$langs->trans("TimeSpentSmall").($usertoprocess->firstname ? '
'.$usertoprocess->getNomUrl(-2).''.dol_trunc($usertoprocess->firstname, 10).'' : '').''; } foreach ($TWeek as $week_number) { - print ''.$langs->trans("WeekShort").' '.$week_number.'
('.$TFirstDays[$week_number].'...'.$TLastDays[$week_number].')
'; + print ''.$langs->trans("WeekShort").' '.$week_number.'
('.$TFirstDays[$week_number].'...'.$TLastDays[$week_number].')
'; } //print ''; diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index ba6f4f83ca5..d76e3a605f4 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1845,9 +1845,9 @@ class Task extends CommonObjectLine $sql .= " MIN(t.element_datehour) as min_date,"; $sql .= " MAX(t.element_datehour) as max_date,"; $sql .= " SUM(t.element_duration) as total_duration,"; - $sql .= " SUM(t.element_duration / 3600 * ".$this->db->ifsql("t.thm IS NULL", 0, "t.thm").") as total_amount,"; + $sql .= " SUM(t.element_duration / 3600 * ".$this->db->ifsql("t.thm IS NULL", '0', "t.thm").") as total_amount,"; $sql .= " COUNT(t.rowid) as nblines,"; - $sql .= " SUM(".$this->db->ifsql("t.thm IS NULL", 1, 0).") as nblinesnull"; + $sql .= " SUM(".$this->db->ifsql("t.thm IS NULL", '1', '0').") as nblinesnull"; $sql .= " FROM ".MAIN_DB_PREFIX."element_time as t"; $sql .= " WHERE t.elementtype='task'"; if ($morewherefilter) { @@ -1899,7 +1899,7 @@ class Task extends CommonObjectLine $sql = "SELECT"; $sql .= " SUM(t.element_duration) as nbseconds,"; - $sql .= " SUM(t.element_duration / 3600 * ".$this->db->ifsql("t.thm IS NULL", 0, "t.thm").") as amount, SUM(".$this->db->ifsql("t.thm IS NULL", 1, 0).") as nblinesnull"; + $sql .= " SUM(t.element_duration / 3600 * ".$this->db->ifsql("t.thm IS NULL", '0', "t.thm").") as amount, SUM(".$this->db->ifsql("t.thm IS NULL", '1', '0').") as nblinesnull"; $sql .= " FROM ".MAIN_DB_PREFIX."element_time as t"; $sql .= " WHERE t.elementtype='task' AND t.fk_element = ".((int) $id); if (is_object($fuser) && $fuser->id > 0) { diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index f827643d2ea..37a0f4a7af6 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -12,7 +12,7 @@ * Copyright (C) 2016 Ferran Marcet * Copyright (C) 2016 Yasser Carreón * Copyright (C) 2018 Quentin Vial-Gouteyron - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -999,7 +999,7 @@ if ($action == 'create') { /** * @var array $suffix2numAsked map HTTP query parameter suffixes (like '1_0') to line indices so that * extrafields from HTTP query can be assigned to the correct dispatch line - */ + */ $suffix2numAsked = array(); $dispatchLines = array(); @@ -1648,7 +1648,7 @@ if ($action == 'create') { if ($volumeUnit < 50) { print showDimensionInBestUnit($calculatedVolume, $volumeUnit, "volume", $langs, getDolGlobalInt('MAIN_VOLUME_DEFAULT_ROUND', -1), getDolGlobalString("MAIN_VOLUME_DEFAULT_UNIT", 'no')); } else { - print $calculatedVolume.' '.measuringUnitString(0, "volume", (string) $volumeUnit); + print $calculatedVolume.' '.measuringUnitString(0, "volume", $volumeUnit); } } if ($totalVolume > 0) {