Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur (aka Eldy) 2025-02-10 19:48:46 +01:00
commit 3a212e4ddb
69 changed files with 817 additions and 822 deletions

View file

@ -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\<string, array\{rank\: int, width\: float\|int, status\: bool, title\: array\{textkey\: string, label\: string, align\: string, padding\: array\{float, float, float, float\}\}, content\: array\{align\: string, padding\: array\{float, float, float, float\}\}\}\>\) does not accept non\-empty\-array\<string, array\{rank\: 0, status\: true, width\: 35, title\: array\{textkey\: ''Ref'', align\: ''L'', padding\: array\{0\.5, 1, 0\.5, 1\.5\}\}, border\-left\: true, content\: array\{align\: ''L'', padding\: array\{1, 0\.5, 1, 1\.5\}\}\}\|array\{rank\: int, width\: float\|int, status\: bool, title\: array\{textkey\: string, label\: string, align\: string, padding\: array\{float, float, float, float\}\}, content\: array\{align\: string, padding\: array\{float, float, float, float\}\}\}\>\.$#'
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\<mixed\>\|string given\.$#'
identifier: argument.type
count: 2
path: ../../../htdocs/fourn/commande/dispatch.php
-
message: '#^Parameter \#5 \$day of function dol_mktime expects int, array\<mixed\>\|string given\.$#'
identifier: argument.type
count: 2
path: ../../../htdocs/fourn/commande/dispatch.php
-
message: '#^Parameter \#6 \$year of function dol_mktime expects int, array\<mixed\>\|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\<mixed\>\|string given\.$#'
identifier: argument.type
count: 1
path: ../../../htdocs/opensurvey/card.php
-
message: '#^Parameter \#5 \$day of function dol_mktime expects int, array\<mixed\>\|string given\.$#'
identifier: argument.type
count: 1
path: ../../../htdocs/opensurvey/card.php
-
message: '#^Parameter \#6 \$year of function dol_mktime expects int, array\<mixed\>\|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<CommonObject\|stdClass> 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\<array\<string, int\|string\>\> of property Opensurveysondage\:\:\$lines is not covariant with PHPDoc type array\<CommonObject\|stdClass\> 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\<mixed\>\|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\<mixed\>\|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\<mixed\>\|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\<mixed\>\|string given\.$#'
identifier: argument.type
count: 2
path: ../../../htdocs/projet/element.php
-
message: '#^Parameter \#5 \$day of function dol_mktime expects int, array\<mixed\>\|string given\.$#'
identifier: argument.type
count: 2
path: ../../../htdocs/projet/element.php
-
message: '#^Parameter \#6 \$year of function dol_mktime expects int, array\<mixed\>\|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\<mixed\>\|string given\.$#'
identifier: argument.type
count: 4
path: ../../../htdocs/reception/dispatch.php
-
message: '#^Parameter \#5 \$day of function dol_mktime expects int, array\<mixed\>\|string given\.$#'
identifier: argument.type
count: 4
path: ../../../htdocs/reception/dispatch.php
-
message: '#^Parameter \#6 \$year of function dol_mktime expects int, array\<mixed\>\|string given\.$#'
identifier: argument.type
count: 4
path: ../../../htdocs/reception/dispatch.php
-
message: '#^Variable \$modebatch might not be defined\.$#'
identifier: variable.undefined

View file

@ -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'],

View file

@ -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';

View file

@ -0,0 +1,177 @@
<?php
/* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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
);
});

View file

@ -5,6 +5,7 @@
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 '<td class="right nowraponall amount" title="'.price($row[2*$i - 2]).' - '.$row[2*$i - 1].' lines">';
print price($row[2*$i - 2]);
print '<td class="right nowraponall amount" title="'.price($row[2 * $i - 2]).' - '.$row[2 * $i - 1].' lines">';
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 '<a href="'.$_SERVER['PHP_SELF'].'?action=validatehistory&year='.$y.'&validatemonth='.((int) $cursormonth).'&validateyear='.((int) $cursoryear).'&token='.newToken().'">';
print img_picto($langs->trans("ValidateHistory").' ('.$langs->trans('Month'.str_pad((string) $cursormonth, 2, '0', STR_PAD_LEFT)).' '.$cursoryear.')', 'link', 'class="marginleft2"');
print '</a>';
@ -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(

View file

@ -2,7 +2,7 @@
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Jose MARTINEZ <jose.martinez@pichinov.com>
*
* 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;

View file

@ -6,7 +6,7 @@
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2017 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -153,7 +153,7 @@ print '</td>';
if ($filtertype != 1) { // Product
if (getDolGlobalInt('PRODUCT_USE_UNITS')) { // For product, unit is shown only if option PRODUCT_USE_UNITS is on
print '<td class="linecoluseunit nowrap">';
$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);

View file

@ -4,7 +4,7 @@
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
@ -328,11 +328,11 @@ print '</div><div class="fichetwothirdright">';
// 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,";

View file

@ -9,7 +9,7 @@
* Copyright (C) 2016-2018 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2019 Nicolas Zabouri <info@inovea-conseil.com>
* Copyright (C) 2021-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 Benjamin Falière <benjamin.faliere@altairis.fr>
*
@ -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) {

View file

@ -7,7 +7,7 @@
* Copyright (C) 2016-2023 Charlene Benke <charlene@patas-monkey.com>
* Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2020 Josep Lluís Amador <joseplluis@lliuretic.cat>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Mélina Joum <melina.joum@altairis.fr>
* 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;

View file

@ -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) . "')";
}
}

View file

@ -81,6 +81,7 @@ class Form
public $cache_types_paiements = array();
public $cache_conditions_paiements = array();
public $cache_transport_mode = array();
/** @var array<int,array{code:string,label:string,position:int}> */
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<int,array{transparency:bool|int<0,1>}> $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<string,string|string[]> $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 = '')

View file

@ -5,7 +5,7 @@
* Copyright (C) 2017 Rui Strecht <rui.strecht@aliartalentos.com>
* Copyright (C) 2020 Open-Dsi <support@open-dsi.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 <option>
* @param string $morecss Add more css
* @return string String with HTML select
* @param int $selected Code state preselected (must be state id)
* @param int|string $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 <option>
* @param string $morecss Add more css
* @return string String with HTML select
* @see select_country()
*/
public function select_state($selected = 0, $country_codeid = 0, $htmlname = 'state_id', $morecss = 'maxwidth200onsmartphone minwidth300')

View file

@ -396,8 +396,8 @@ class FormFile
* @param string $modulesubdir Sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into subdir of module.
* @param string $filedir Directory to scan
* @param string $urlsource Url of origin page (for return)
* @param int $genallowed Generation is allowed (1/0 or array of formats)
* @param int $delallowed Remove is allowed (1/0)
* @param int<0,1> $genallowed Generation is allowed (1/0 or array of formats)
* @param int<0,1> $delallowed Remove is allowed (1/0)
* @param string $modelselected Model to preselect by default
* @param integer $allowgenifempty Show warning if no model activated
* @param integer $forcenomultilang Do not show language option (even if MAIN_MULTILANGS defined)
@ -427,24 +427,24 @@ class FormFile
* @param string $modulesubdir Existing (so sanitized) sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into a subdir of module.
* @param string $filedir Directory to scan (must not end with a /). Example: '/mydolibarrdocuments/facture/FAYYMM-1234'
* @param string $urlsource Url of origin page (for return)
* @param int|string[] $genallowed Generation is allowed (1/0 or array list of templates)
* @param int $delallowed Remove is allowed (1/0)
* @param int<0,1>|string[] $genallowed Generation is allowed (1/0 or array list of templates)
* @param int<0,1> $delallowed Remove is allowed (1/0)
* @param string $modelselected Model to preselect by default
* @param integer $allowgenifempty Allow generation even if list of template ($genallowed) is empty (show however a warning)
* @param integer $forcenomultilang Do not show language option (even if MAIN_MULTILANGS defined)
* @param int<0,1> $allowgenifempty Allow generation even if list of template ($genallowed) is empty (show however a warning)
* @param int<0,1> $forcenomultilang Do not show language option (even if MAIN_MULTILANGS defined)
* @param int $iconPDF Deprecated, see getDocumentsLink
* @param int $notused Not used
* @param integer $noform Do not output html form tags
* @param int<0,1> $noform Do not output html form tags
* @param string $param More param on http links
* @param string $title Title to show on top of form. Example: '' (Default to "Documents") or 'none'
* @param string $buttonlabel Label on submit button
* @param string $codelang Default language code to use on lang combo box if multilang is enabled
* @param string $morepicto Add more HTML content into cell with picto
* @param Object|null $object Object when method is called from an object card.
* @param int $hideifempty Hide section of generated files if there is no file
* @param int<0,1> $hideifempty Hide section of generated files if there is no file
* @param string $removeaction (optional) The action to remove a file
* @param string $tooltipontemplatecombo Text to show on a tooltip after the combo list of templates
* @return string|int Output string with HTML array of documents (might be empty string)
* @return string|int<-1,-1> Output string with HTML array of documents (might be empty string)
*/
public function showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected = '', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $notused = 0, $noform = 0, $param = '', $title = '', $buttonlabel = '', $codelang = '', $morepicto = '', $object = null, $hideifempty = 0, $removeaction = 'remove_file', $tooltipontemplatecombo = '')
{
@ -947,6 +947,8 @@ class FormFile
}
}
'@phan-var-force array<array{name:string,path:string,level1name:string,relativename:string,fullname:string,date:string,size:int,perm:int,type:string,position_name:string,cover:string,keywords:string,acl:string,rowid:int,label:string,share:string}> $file_list';
require_once DOL_DOCUMENT_ROOT . '/ecm/class/ecmfiles.class.php';
$i = 0;
@ -1145,13 +1147,13 @@ class FormFile
* You may want to call this into a div like this:
* print '<div class="inline-block valignmiddle">'.$formfile->getDocumentsLink($element_doc, $filename, $filedir).'</div>';
*
* @param string $modulepart 'propal', 'facture', 'facture_fourn', ...
* @param string $modulesubdir Sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into subdir of module.
* @param string $filedir Full path to directory to scan
* @param string $filter Filter filenames on this regex string (Example: '\.pdf$')
* @param string $morecss Add more css to the download picto
* @param int $allfiles 0=Only generated docs, 1=All files
* @return string Output string with HTML link of documents (might be empty string). This also fill the array ->infofiles
* @param string $modulepart 'propal', 'facture', 'facture_fourn', ...
* @param string $modulesubdir Sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into subdir of module.
* @param string $filedir Full path to directory to scan
* @param string $filter Filter filenames on this regex string (Example: '\.pdf$')
* @param string $morecss Add more css to the download picto
* @param int<0,1> $allfiles 0=Only generated docs, 1=All files
* @return string Output string with HTML link of documents (might be empty string). This also fill the array ->infofiles
*/
public function getDocumentsLink($modulepart, $modulesubdir, $filedir, $filter = '', $morecss = 'valignmiddle', $allfiles = 0)
{
@ -1373,6 +1375,7 @@ class FormFile
if ($permtoeditline < 0) { // Old behaviour for backward compatibility. New feature should call method with value 0 or 1
$permtoeditline = 0;
if (in_array($modulepart, array('product', 'produit', 'service'))) {
'@phan-var-force Product $object';
if ($user->hasRight('produit', 'creer') && $object->type == Product::TYPE_PRODUCT) {
$permtoeditline = 1;
}
@ -2352,9 +2355,9 @@ class FormFile
* Show detail icon with link for preview
*
* @param array{name:string,path:string,level1name:string,relativename:string,fullname:string,date:string,size:int,perm:int,type:string} $file Array with data of file. Example: array('name'=>...)
* @param string $modulepart propal, facture, facture_fourn, ...
* @param string $relativepath Relative path of docs
* @param integer $ruleforpicto Rule for picto: 0=Use the generic preview picto, 1=Use the picto of mime type of file). Use a negative value to show a generic picto even if preview not available.
* @param string $modulepart propal, facture, facture_fourn, ...
* @param string $relativepath Relative path of docs
* @param int<min,1> $ruleforpicto Rule for picto: 0=Use the generic preview picto, 1=Use the picto of mime type of file). Use a negative value to show a generic picto even if preview not available.
* @param string $param More param on http links
* @return string $out Output string with HTML
*/

View file

@ -4,7 +4,7 @@
* Copyright (C) 2011-2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018-2024 Charlene Benke <charlene@patas-monkey.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -373,8 +373,8 @@ function convertDurationtoHour($duration_value, $duration_unit)
* @param int|string $month_date Month date (Can be 0 or '' for filter on a year)
* @param int|string $year_date Year date
* @param int $excludefirstand Exclude first and
* @param mixed $gm False or 0 or 'tzserver' = Input date fields are date info in the server TZ. True or 1 or 'gmt' = Input are date info in GMT TZ.
* Note: In database, dates are always for the server TZ.
* @param bool|int<0,1>|'gmt'|'tzserver'|'tzref'|'tzuser'|'tzuserrel' $gm False or 0 or 'tzserver' = Input date fields are date info in the server TZ. True or 1 or 'gmt' = Input are date info in GMT TZ.
* Note: In database, dates are always for the server TZ.
* @return string $sqldate String with SQL filter
* @see forgeSQLFromUniversalSearchCriteria()
* @see natural_search()
@ -420,8 +420,8 @@ function dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $exclu
* YYYY-MM-DDTHH:MM:SSZ (RFC3339)
* DD/MM/YY or DD/MM/YYYY (deprecated)
* DD/MM/YY HH:MM:SS or DD/MM/YYYY HH:MM:SS (deprecated)
* @param int|string $gm 'gmt' or 1 =Input date is GM date,
* 'tzserver' or 0 =Input date is date using PHP server timezone
* @param int<0,1>|'gmt'|'tzserver'|'tzref'|'tzuser'|'tzuserrel'|'dayrfc' $gm 'gmt' or 1 =Input date is GM date,
* 'tzserver' or 0 =Input date is date using PHP server timezone
* @return int Date as a timestamp
* 19700101020000 -> 7200 with gm=1
* 19700101000000 -> 0 with gm=1
@ -589,12 +589,12 @@ function dol_get_next_week($day, $week, $month, $year)
/**
* Return GMT time for first day of a month or year
*
* @param int $year Year
* @param int $month Month
* @param bool|int|string $gm False or 0 or 'tzserver' = Return date to compare with server TZ,
* True or 1 or 'gmt' to compare with GMT date.
* Example: dol_get_first_day(1970,1,false) will return -3600 with TZ+1, a dol_print_date on it will return 1970-01-01 00:00:00
* Example: dol_get_first_day(1970,1,true) will return 0 whatever is TZ, a dol_print_date on it will return 1970-01-01 00:00:00
* @param int $year Year
* @param int $month Month
* @param bool|int<0,1>|'gmt'|'tzserver'|'tzref'|'tzuser'|'tzuserrel' $gm False or 0 or 'tzserver' = Return date to compare with server TZ,
* True or 1 or 'gmt' to compare with GMT date.
* Example: dol_get_first_day(1970,1,false) will return -3600 with TZ+1, a dol_print_date on it will return 1970-01-01 00:00:00
* Example: dol_get_first_day(1970,1,true) will return 0 whatever is TZ, a dol_print_date on it will return 1970-01-01 00:00:00
* @return int|string Date as a timestamp, '' if error
*/
function dol_get_first_day($year, $month = 1, $gm = false)
@ -612,8 +612,8 @@ function dol_get_first_day($year, $month = 1, $gm = false)
*
* @param int $year Year
* @param int $month Month
* @param bool|int|string $gm False or 0 or 'tzserver' = Return date to compare with server TZ,
* True or 1 or 'gmt' to compare with GMT date.
* @param bool|int<0,1>|'gmt'|'tzserver'|'tzref'|'tzuser'|'tzuserrel' $gm False or 0 or 'tzserver' = Return date to compare with server TZ,
* True or 1 or 'gmt' to compare with GMT date.
* @return int|string Date as a timestamp, '' if error
*/
function dol_get_last_day($year, $month = 12, $gm = false)
@ -665,11 +665,11 @@ function dol_get_first_hour($date, $gm = 'tzserver')
/** Return first day of week for a date. First day of week may be monday if option MAIN_START_WEEK is 1.
*
* @param int $day Day
* @param int $month Month
* @param int $year Year
* @param bool|int|'tzserver' $gm False or 0 or 'tzserver' = Return date to compare with server TZ,
* True or 1 or 'gmt' to compare with GMT date.
* @param int $day Day
* @param int $month Month
* @param int $year Year
* @param bool|int<0,1>|'gmt'|'tzserver'|'tzref'|'tzuser'|'tzuserrel' $gm False or 0 or 'tzserver' = Return date to compare with server TZ,
* True or 1 or 'gmt' to compare with GMT date.
* @return array{year:int,month:int,week:string,first_day:int,first_month:int,first_year:int,prev_year:int,prev_month:int,prev_day:int}
*/
function dol_get_first_day_week($day, $month, $year, $gm = false)

View file

@ -7104,7 +7104,7 @@ function price2num($amount, $rounding = '', $option = 0)
* @param Translate $outputlangs Translate language object
* @param int<-1,max> $round -1 = non rounding, x = number of decimal
* @param string $forceunitoutput 'no' or numeric (-3, -6, ...) compared to $unit (In most case, this value is value defined into $conf->global->MAIN_WEIGHT_DEFAULT_UNIT)
* @param int $use_short_label 1=Use short label ('g' instead of 'gram'). Short labels are not translated.
* @param int<0,1> $use_short_label 1=Use short label ('g' instead of 'gram'). Short labels are not translated.
* @return string String to show dimensions
*/
function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round = -1, $forceunitoutput = 'no', $use_short_label = 0)
@ -7139,7 +7139,7 @@ function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round
$ret = price($dimension, 0, $outputlangs, 0, 0, $round);
// @phan-suppress-next-line PhanPluginSuspiciousParamPosition
$ret .= ' '.measuringUnitString(0, $type, (string) $unit, $use_short_label, $outputlangs);
$ret .= ' '.measuringUnitString(0, $type, $unit, $use_short_label, $outputlangs);
return $ret;
}

View file

@ -5,7 +5,7 @@
* Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2017 Charlie Benke <charlie@patas-monkey.com>
* Copyright (C) 2017 ATM-CONSULTING <contact@atm-consulting.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -441,12 +441,12 @@ function getNumberInvoicesPieChart($mode)
$amount_mode = (getDolGlobalInt('FACTURE_VALIDATED_IN_AMOUNT') == 1);
$sql = "SELECT";
$sql .= " sum(".$db->ifsql("f.date_lim_reglement < '".date_format($datenowsub30, 'Y-m-d')."'", $amount_mode ? "f.total_ht" : 1, 0).") as late30";
$sql .= ", sum(".$db->ifsql("f.date_lim_reglement < '".date_format($datenowsub15, 'Y-m-d')."' AND f.date_lim_reglement >= '".date_format($datenowsub30, 'Y-m-d')."'", $amount_mode ? "f.total_ht" : 1, 0).") as late15";
$sql .= ", sum(".$db->ifsql("f.date_lim_reglement < '".date_format($now, 'Y-m-d')."' AND f.date_lim_reglement >= '".date_format($datenowsub15, 'Y-m-d')."'", $amount_mode ? "f.total_ht" : 1, 0).") as latenow";
$sql .= ", sum(".$db->ifsql("f.date_lim_reglement >= '".date_format($now, 'Y-m-d')."' AND f.date_lim_reglement < '".date_format($datenowadd15, 'Y-m-d')."'", $amount_mode ? "f.total_ht" : 1, 0).") as notlatenow";
$sql .= ", sum(".$db->ifsql("f.date_lim_reglement >= '".date_format($datenowadd15, 'Y-m-d')."' AND f.date_lim_reglement < '".date_format($datenowadd30, 'Y-m-d')."'", $amount_mode ? "f.total_ht" : 1, 0).") as notlate15";
$sql .= ", sum(".$db->ifsql("f.date_lim_reglement >= '".date_format($datenowadd30, 'Y-m-d')."'", $amount_mode ? "f.total_ht" : 1, 0).") as notlate30";
$sql .= " sum(".$db->ifsql("f.date_lim_reglement < '".date_format($datenowsub30, 'Y-m-d')."'", $amount_mode ? "f.total_ht" : 1, '0').") as late30";
$sql .= ", sum(".$db->ifsql("f.date_lim_reglement < '".date_format($datenowsub15, 'Y-m-d')."' AND f.date_lim_reglement >= '".date_format($datenowsub30, 'Y-m-d')."'", $amount_mode ? "f.total_ht" : 1, '0').") as late15";
$sql .= ", sum(".$db->ifsql("f.date_lim_reglement < '".date_format($now, 'Y-m-d')."' AND f.date_lim_reglement >= '".date_format($datenowsub15, 'Y-m-d')."'", $amount_mode ? "f.total_ht" : 1, '0').") as latenow";
$sql .= ", sum(".$db->ifsql("f.date_lim_reglement >= '".date_format($now, 'Y-m-d')."' AND f.date_lim_reglement < '".date_format($datenowadd15, 'Y-m-d')."'", $amount_mode ? "f.total_ht" : 1, '0').") as notlatenow";
$sql .= ", sum(".$db->ifsql("f.date_lim_reglement >= '".date_format($datenowadd15, 'Y-m-d')."' AND f.date_lim_reglement < '".date_format($datenowadd30, 'Y-m-d')."'", $amount_mode ? "f.total_ht" : 1, '0').") as notlate15";
$sql .= ", sum(".$db->ifsql("f.date_lim_reglement >= '".date_format($datenowadd30, 'Y-m-d')."'", $amount_mode ? "f.total_ht" : 1, '0').") as notlate30";
if ($mode == 'customers') {
$element = 'invoice';
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
@ -569,7 +569,9 @@ function getCustomerInvoiceDraftTable($maxCount = 500, $socid = 0)
$result = '';
if (isModEnabled('invoice') && $user->hasRight('facture', 'lire')) {
if ($user->socid > 0) $socid = $user->socid;
if ($user->socid > 0) {
$socid = $user->socid;
}
$maxofloop = (!getDolGlobalString('MAIN_MAXLIST_OVERLOAD') ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
$tmpinvoice = new Facture($db);
@ -721,7 +723,9 @@ function getDraftSupplierTable($maxCount = 500, $socid = 0)
$result = '';
if ((isModEnabled('fournisseur') || isModEnabled('supplier_invoice')) && $user->hasRight('facture', 'lire')) {
if ($user->socid > 0) $socid = $user->socid;
if ($user->socid > 0) {
$socid = $user->socid;
}
$maxofloop = (!getDolGlobalString('MAIN_MAXLIST_OVERLOAD') ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
$facturesupplierstatic = new FactureFournisseur($db);
@ -854,7 +858,9 @@ function getDraftSupplierTable($maxCount = 500, $socid = 0)
function getCustomerInvoiceLatestEditTable($maxCount = 5, $socid = 0)
{
global $conf, $db, $langs, $user;
if ($user->socid > 0) $socid = $user->socid;
if ($user->socid > 0) {
$socid = $user->socid;
}
$sql = "SELECT f.rowid, f.entity, f.ref, f.fk_statut as status, f.paye, f.type, f.total_ht, f.total_tva, f.total_ttc, f.datec,";
$sql .= " s.nom as socname, s.rowid as socid, s.canvas, s.client";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
@ -963,7 +969,9 @@ function getCustomerInvoiceLatestEditTable($maxCount = 5, $socid = 0)
function getPurchaseInvoiceLatestEditTable($maxCount = 5, $socid = 0)
{
global $conf, $db, $langs, $user;
if ($user->socid > 0) $socid = $user->socid;
if ($user->socid > 0) {
$socid = $user->socid;
}
$sql = "SELECT f.rowid, f.entity, f.ref, f.fk_statut as status, f.paye, f.total_ht, f.total_tva, f.total_ttc, f.type, f.ref_supplier, f.datec,";
$sql .= " s.nom as socname, s.rowid as socid, s.canvas, s.client";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
@ -1081,7 +1089,9 @@ function getCustomerInvoiceUnpaidOpenTable($maxCount = 500, $socid = 0)
$result = '';
if (isModEnabled('invoice') && $user->hasRight('facture', 'lire')) {
if ($user->socid > 0) $socid = $user->socid;
if ($user->socid > 0) {
$socid = $user->socid;
}
$tmpinvoice = new Facture($db);
$sql = "SELECT f.rowid, f.ref, f.fk_statut as status, f.datef, f.type, f.total_ht, f.total_tva, f.total_ttc, f.paye, f.tms";
@ -1271,7 +1281,9 @@ function getPurchaseInvoiceUnpaidOpenTable($maxCount = 500, $socid = 0)
$result = '';
if (isModEnabled("supplier_invoice") && ($user->hasRight('fournisseur', 'facture', 'lire') || $user->hasRight('supplier_invoice', 'read'))) {
if ($user->socid > 0) $socid = $user->socid;
if ($user->socid > 0) {
$socid = $user->socid;
}
$facstatic = new FactureFournisseur($db);
$sql = "SELECT ff.rowid, ff.ref, ff.fk_statut as status, ff.type, ff.libelle as label, ff.total_ht, ff.total_tva, ff.total_ttc, ff.paye";

View file

@ -6,7 +6,7 @@
* Copyright (C) 2015-2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2023 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2024 Jean-Rémi TAPONIER <jean-remi@netlogic.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Mélina Joum <melina.joum@altairis.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
@ -879,15 +879,15 @@ function show_stats_for_batch($batch, $socid)
* Return translation label of a unit key.
* Function kept for backward compatibility.
*
* @param string $unitscale Scale of unit: '0', '-3', '6', ...
* @param ?int $unitscale Scale of unit: '0', '-3', '6', ...
* @param string $measuring_style Style of unit: weight, volume,...
* @param int $unitid ID of unit (rowid in llx_c_units table)
* @param int $use_short_label 1=Use short label ('g' instead of 'gram'). Short labels are not translated.
* @param Translate $outputlangs Language object
* @param int<0,1> $use_short_label 1=Use short label ('g' instead of 'gram'). Short labels are not translated.
* @param ?Translate $outputlangs Language object
* @return string Unit string
* @see measuringUnitString() formproduct->selectMeasuringUnits()
*/
function measuring_units_string($unitscale = '', $measuring_style = '', $unitid = 0, $use_short_label = 0, $outputlangs = null)
function measuring_units_string($unitscale = null, $measuring_style = '', $unitid = 0, $use_short_label = 0, $outputlangs = null)
{
return measuringUnitString($unitid, $measuring_style, $unitscale, $use_short_label, $outputlangs);
}
@ -897,13 +897,13 @@ function measuring_units_string($unitscale = '', $measuring_style = '', $unitid
*
* @param int $unitid ID of unit (rowid in llx_c_units table)
* @param string $measuring_style Style of unit: 'weight', 'volume', ..., '' = 'net_measure' for option PRODUCT_ADD_NET_MEASURE
* @param string $unitscale Scale of unit: '0', '-3', '6', ...
* @param int $use_short_label 1=Use very short label ('g' instead of 'gram'), not translated. 2=Use translated short label.
* @param Translate $outputlangs Language object
* @param ?int $unitscale Scale of unit: '0', '-3', '6', ...
* @param int<0,2> $use_short_label 1=Use very short label ('g' instead of 'gram'), not translated. 2=Use translated short label.
* @param ?Translate $outputlangs Language object
* @return string|-1 Unit string if OK, -1 if KO
* @see formproduct->selectMeasuringUnits()
*/
function measuringUnitString($unitid, $measuring_style = '', $unitscale = '', $use_short_label = 0, $outputlangs = null)
function measuringUnitString($unitid, $measuring_style = '', $unitscale = null, $use_short_label = 0, $outputlangs = null)
{
global $langs, $db;
global $measuring_unit_cache;

View file

@ -705,7 +705,7 @@ class pdf_espadon extends ModelePdfExpedition
}
if ($this->getColumnStatus('unit_order')) {
$this->printStdColumnContent($pdf, $curY, 'unit_order', measuringUnitString($object->lines[$i]->fk_unit));
$this->printStdColumnContent($pdf, $curY, 'unit_order', measuringUnitString((int) $object->lines[$i]->fk_unit));
$nexY = max($pdf->GetY(), $nexY);
}

View file

@ -4,7 +4,7 @@
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -81,7 +81,7 @@ abstract class ModeleProductCode extends CommonNumRefGenerator
/**
* Return next value available
*
* @param Product|string $objproduct Object product
* @param Product|'' $objproduct Object product
* @param int $type Type
* @return string Value
*/
@ -124,8 +124,8 @@ abstract class ModeleProductCode extends CommonNumRefGenerator
* Return description of module parameters
*
* @param Translate $langs Output language
* @param Product $product Product object
* @param int $type -1=Nothing, 0=Customer, 1=Supplier
* @param Product|'' $product Product object
* @param int<-1,1> $type -1=Nothing, 0=Customer, 1=Supplier
* @return string HTML translated description
*/
public function getToolTip($langs, $product, $type)
@ -205,7 +205,7 @@ abstract class ModeleProductCode extends CommonNumRefGenerator
* Return an example of result returned by getNextValue
*
* @param ?Translate $langs Object langs
* @param Product|string $objproduct Object product
* @param Product|'' $objproduct Object product
* @param int<-1,2> $type Type of third party (1:customer, 2:supplier, -1:autodetect)
* @return string Return string example
*/

View file

@ -2113,7 +2113,7 @@ if ($action == 'create') {
print '</form>';
} else {
print $object->trueWeight;
print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", (string) $object->weight_units) : '';
print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", $object->weight_units) : '';
}
// Calculated
@ -2175,7 +2175,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) {
@ -2409,6 +2409,7 @@ if ($action == 'create') {
print '<tbody>';
// Loop on each product to send/sent
$conf->cache['product'] = array();
for ($i = 0; $i < $num_prod; $i++) {
$parameters = array('i' => $i, 'line' => $lines[$i], 'line_id' => $line_id, 'num' => $num_prod, 'alreadysent' => $alreadysent, 'editColspan' => !empty($editColspan) ? $editColspan : 0, 'outputlangs' => $outputlangs);
$reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action);
@ -2429,8 +2430,14 @@ if ($action == 'create') {
if ($lines[$i]->fk_product > 0) {
// Define output language
if (getDolGlobalInt('MAIN_MULTILANGS') && getDolGlobalString('PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE')) {
$prod = new Product($db);
$prod->fetch($lines[$i]->fk_product);
$product_id = $lines[$i]->fk_product;
if (!isset($conf->cache['product'][$product_id])) {
$prod = new Product($db);
$prod->fetch($product_id);
$conf->cache['product'][$product_id] = $prod;
} else {
$prod = $conf->cache['product'][$product_id];
}
$label = (!empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $lines[$i]->product_label;
} else {
$label = (!empty($lines[$i]->label) ? $lines[$i]->label : $lines[$i]->product_label);

View file

@ -149,7 +149,7 @@ class Expedition extends CommonObject
*/
public $trueWidth;
/**
* @var string
* @var int
*/
public $width_units;
/**
@ -157,7 +157,7 @@ class Expedition extends CommonObject
*/
public $trueHeight;
/**
* @var string
* @var int
*/
public $height_units;
/**
@ -165,7 +165,7 @@ class Expedition extends CommonObject
*/
public $trueDepth;
/**
* @var string
* @var int
*/
public $depth_units;
/**

View file

@ -13,7 +13,7 @@
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2020 Lenin Rivas <lenin@leninrivas.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -228,7 +228,7 @@ class ExpeditionLigne extends CommonObjectLine
public $width;
/**
* @var string|int
* @var int
*/
public $width_units;
@ -238,7 +238,7 @@ class ExpeditionLigne extends CommonObjectLine
public $height;
/**
* @var string|int
* @var int
*/
public $height_units;

View file

@ -1619,7 +1619,7 @@ while ($i < $imaxinloop) {
print $form->textwithpicto('', $langs->trans('EstimatedWeight'), 1);
} else {
print $object->trueWeight;
print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", (string) $object->weight_units) : '';
print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", $object->weight_units) : '';
}
print '</td>';
if (!$i) {

View file

@ -1039,7 +1039,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}
$qtyhourforline = 0;
if ($line->fk_unit) {
$unitforline = measuringUnitString($line->fk_unit, '', '', 1);
$unitforline = measuringUnitString($line->fk_unit, '', null, 1);
$qtyhourforline = convertDurationtoHour($line->qty, $unitforline);
}
@ -1096,7 +1096,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<td class="right nowraponall">';
$useunit = (($tmpproduct->type == Product::TYPE_PRODUCT && getDolGlobalInt('PRODUCT_USE_UNITS')) || (($tmpproduct->type == Product::TYPE_SERVICE) && ($line->fk_unit)));
if ($useunit) {
print measuringUnitString($line->fk_unit, '', '', 2);
print measuringUnitString($line->fk_unit, '', null, 2);
}
print '</td>';
@ -1186,7 +1186,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<td class="right nowraponall">';
$useunit = (($tmpproduct->type == Product::TYPE_PRODUCT && getDolGlobalInt('PRODUCT_USE_UNITS')) || (($tmpproduct->type == Product::TYPE_SERVICE) && ($line->fk_unit)));
if ($useunit) {
print measuringUnitString($line->fk_unit, '', '', 2);
print measuringUnitString($line->fk_unit, '', null, 2);
}
print '</td>';
@ -1671,7 +1671,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<td class="right">'.$line->qty.'</td>';
// Unit
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
print '<td class="right">'.measuringUnitString($line->fk_unit, '', '', 1).'</td>';
print '<td class="right">'.measuringUnitString($line->fk_unit, '', null, 1).'</td>';
}
// Cost price
if ($permissiontoupdatecost) {

View file

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2017 Charlie Benke <charlie@patas-monkey.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -85,7 +85,7 @@ print '</td>';
// Qty
print '<td class="right">'.$this->tpl['qty'].(($this->tpl['efficiency'] > 0 && $this->tpl['efficiency'] < 1) ? ' / '.$form->textwithpicto($this->tpl['efficiency'], $langs->trans("ValueOfMeansLoss")).' = '.$qtytoconsumeforline : '').'</td>';
// Unit
print '<td class="right">'.measuringUnitString($this->tpl['fk_unit'], '', '', 1).'</td>';
print '<td class="right">'.measuringUnitString($this->tpl['fk_unit'], '', null, 1).'</td>';
// Stock
print '<td class="center">';
if ($tmpproduct->isStockManaged()) {
@ -170,7 +170,7 @@ if ($resql) {
}
// Unit
print '<td class="linecolunit nowrap right" id="sub_bom_unit_'.$sub_bom_line->id.'">'.measuringUnitString($sub_bom_line->fk_unit, '', '', 1).'</td>';
print '<td class="linecolunit nowrap right" id="sub_bom_unit_'.$sub_bom_line->id.'">'.measuringUnitString($sub_bom_line->fk_unit, '', null, 1).'</td>';
// Stock réel
if ($sub_bom_product->stock_reel > 0) {

View file

@ -1,7 +1,7 @@
<?php
/**
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -93,12 +93,12 @@ if ($action == 'update') {
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_pricerules (level, fk_level, var_percent, var_min_percent) VALUES (";
$sql .= ((int) $i).", ".$db->escape($i_fk_level).", ".$i_var_percent.", ".$i_var_min_percent.")";
$sql .= ((int) $i).", ".((int) $i_fk_level).", ".$i_var_percent.", ".$i_var_min_percent.")";
if (!$db->query($sql)) {
//If we could not create, then we try updating
$sql = "UPDATE ".MAIN_DB_PREFIX."product_pricerules";
$sql .= " SET fk_level = ".$db->escape($i_fk_level).", var_percent = ".$i_var_percent.", var_min_percent = ".$i_var_min_percent." WHERE level = ".((int) $i);
$sql .= " SET fk_level = ".((int) $i_fk_level).", var_percent = ".$i_var_percent.", var_min_percent = ".$i_var_min_percent." WHERE level = ".((int) $i);
if (!$db->query($sql)) {
setEventMessages($langs->trans('ErrorSavingChanges'), null, 'errors');

View file

@ -363,8 +363,8 @@ foreach ($dirproduct as $dirroot) {
print "</td>\n";
} else {
$disabled = false;
if (!(isModEnabled('multicompany') && ((is_object($mc) && !empty($mc->sharings['referent'])) && ($mc->sharings['referent'] == $conf->entity)))) {
}
// if (!(isModEnabled('multicompany') && ((is_object($mc) && !empty($mc->sharings['referent'])) && ($mc->sharings['referent'] == $conf->entity)))) {
// }
print '<td class="center">';
if (!$disabled) {
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setcodeproduct&token='.newToken().'&value='.urlencode($file).'">';

View file

@ -2,6 +2,7 @@
/* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -150,7 +151,7 @@ if ($action == 'convert') {
$newlevel = $level;
//print "$objectstatic->id $newprice, $price_base_type, $newvat, $newminprice, $newlevel, $newnpr<br>\n";
$retm = $objectstatic->updatePrice($newprice, $price_base_type, $user, $newvatrateclean, $newminprice, $newlevel, $newnpr, 0, 0, $localtaxes_type, $newdefaultvatcode);
$retm = $objectstatic->updatePrice((float) $newprice, $price_base_type, $user, (float) $newvatrateclean, $newminprice, $newlevel, $newnpr, 0, 0, $localtaxes_type, $newdefaultvatcode);
if ($retm < 0) {
$error++;
break;
@ -180,7 +181,7 @@ if ($action == 'convert') {
$newlevel = 0;
if (!empty($price_base_type) && !$updatelevel1) {
//print "$objectstatic->id $newprice, $price_base_type, $newvat, $newminprice, $newlevel, $newnpr<br>\n";
$ret = $objectstatic->updatePrice($newprice, $price_base_type, $user, $newvatrateclean, $newminprice, $newlevel, $newnpr, 0, 0, $localtaxes_type, $newdefaultvatcode);
$ret = $objectstatic->updatePrice((float) $newprice, $price_base_type, $user, (float) $newvatrateclean, $newminprice, $newlevel, $newnpr, 0, 0, $localtaxes_type, $newdefaultvatcode);
}
if ($ret < 0 || $retm < 0) {
@ -236,8 +237,8 @@ if ($action == 'convert') {
//}
//else
//{
$newprice = price2num($obj->price, 'MU'); // Second param must be MU (we want a unit price so 'MU'. If unit price was on 4 decimal, we must keep 4 decimals)
//$newminprice=$objectstatic2->fourn_price_min;
$newprice = price2num($obj->price, 'MU'); // Second param must be MU (we want a unit price so 'MU'. If unit price was on 4 decimal, we must keep 4 decimals)
//$newminprice=$objectstatic2->fourn_price_min;
//}
//if ($newminprice > $newprice) $newminprice=$newprice;
$newvat = str_replace('*', '', $newvatrate);
@ -254,7 +255,7 @@ if ($action == 'convert') {
if (!empty($price_base_type) && !$updatelevel1) {
//print "$objectstatic2->id $newprice, $price_base_type, $newvat, $newminprice, $newlevel, $newnpr<br>\n";
$fourn->id = $obj->fk_soc;
$ret = $objectstatic2->update_buyprice($obj->qty, $newprice, $user, $price_base_type, $fourn, $obj->fk_availability, $obj->ref_fourn, $newvat, '', $newpercent, 0, $newnpr, $newdeliverydelay, $newsupplierreputation, $localtaxes_type, $newdefaultvatcode);
$ret = $objectstatic2->update_buyprice($obj->qty, (float) $newprice, $user, $price_base_type, $fourn, $obj->fk_availability, $obj->ref_fourn, (float) $newvat, '', $newpercent, 0, $newnpr, $newdeliverydelay, $newsupplierreputation, $localtaxes_type, $newdefaultvatcode);
}
if ($ret < 0 || $retm < 0) {

View file

@ -4,6 +4,7 @@
* Copyright (C) 2007-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2020 Josep Lluís Amador <joseplluis@lliuretic.cat>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@ -68,7 +69,7 @@ $finished = GETPOSTINT('finished');
$alsoproductwithnosupplierprice = GETPOSTINT('alsoproductwithnosupplierprice');
$warehouseStatus = GETPOST('warehousestatus', 'alpha');
$hidepriceinlabel = GETPOSTINT('hidepriceinlabel');
$warehouseId = GETPOST('warehouseid', 'int');
$warehouseId = GETPOSTINT('warehouseid');
// Security check
restrictedArea($user, 'produit|service|commande|propal|facture', 0, 'product&product');
@ -214,7 +215,7 @@ if ($action == 'fetch' && !empty($id)) {
$prodcustprice = new ProductCustomerPrice($db);
$filter = array('t.fk_product' => $object->id, 't.fk_soc' => $socid);
$filter = array('t.fk_product' => (string) $object->id, 't.fk_soc' => (string) $socid);
$result = $prodcustprice->fetchAll('', '', 0, 0, $filter);
if ($result) {
@ -252,7 +253,7 @@ if ($action == 'fetch' && !empty($id)) {
$tmpvatwithcode = get_default_tva($mysoc, $thirdparty_buyer, $id, 0);
if (!is_numeric($tmpvatwithcode) || $tmpvatwithcode != -1) {
$reg =array();
$reg = array();
if (preg_match('/(.+)\s\((.+)\)/', $tmpvatwithcode, $reg)) {
$outtva_tx = price2num($reg[1]);
$outtva_tx_formated = price($outtva_tx);
@ -286,7 +287,7 @@ if ($action == 'fetch' && !empty($id)) {
'qty' => $outqty,
'discount' => $outdiscount,
'mandatory_period' => $mandatory_period,
'array_options'=>$object->array_options
'array_options' => $object->array_options
);
}
@ -325,7 +326,7 @@ if ($action == 'fetch' && !empty($id)) {
$arrayresult = [];
if (empty($mode) || $mode == 1) { // mode=1: customer
$arrayresult = $form->select_produits_list("", $htmlname, $type, getDolGlobalInt('PRODUIT_LIMIT_SIZE', 1000), $price_level, $searchkey, $status, $finished, $outjson, $socid, '1', 0, '', $hidepriceinlabel, $warehouseStatus, $status_purchase, $warehouseId);
$arrayresult = $form->select_produits_list(0, $htmlname, $type, getDolGlobalInt('PRODUIT_LIMIT_SIZE', 1000), $price_level, $searchkey, $status, $finished, $outjson, $socid, '1', 0, '', $hidepriceinlabel, $warehouseStatus, $status_purchase, $warehouseId);
} elseif ($mode == 2) { // mode=2: supplier
$arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson, getDolGlobalInt('PRODUIT_LIMIT_SIZE', 1000), $alsoproductwithnosupplierprice);
}

View file

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2010-2018 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@ -245,23 +245,23 @@ class ActionsCardProduct
// Finished
$statutarray = array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial"));
$this->tpl['finished'] = $form->selectarray('finished', $statutarray, $this->object->finished);
$this->tpl['finished'] = $form->selectarray('finished', $statutarray, (int) $this->object->finished);
// Weight
$this->tpl['weight'] = $this->object->weight;
$this->tpl['weight_units'] = $formproduct->selectMeasuringUnits("weight_units", "weight", $this->object->weight_units, 0, 2);
$this->tpl['weight_units'] = $formproduct->selectMeasuringUnits("weight_units", "weight", (string) $this->object->weight_units, 0, 2);
// Length
$this->tpl['length'] = $this->object->length;
$this->tpl['length_units'] = $formproduct->selectMeasuringUnits("length_units", "size", $this->object->length_units, 0, 2);
$this->tpl['length_units'] = $formproduct->selectMeasuringUnits("length_units", "size", (string) $this->object->length_units, 0, 2);
// Surface
$this->tpl['surface'] = $this->object->surface;
$this->tpl['surface_units'] = $formproduct->selectMeasuringUnits("surface_units", "surface", $this->object->surface_units, 0, 2);
$this->tpl['surface_units'] = $formproduct->selectMeasuringUnits("surface_units", "surface", (string) $this->object->surface_units, 0, 2);
// Volume
$this->tpl['volume'] = $this->object->volume;
$this->tpl['volume_units'] = $formproduct->selectMeasuringUnits("volume_units", "volume", $this->object->volume_units, 0, 2);
$this->tpl['volume_units'] = $formproduct->selectMeasuringUnits("volume_units", "volume", (string) $this->object->volume_units, 0, 2);
}
if ($action == 'view') {

View file

@ -161,7 +161,7 @@ $extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($object->table_element);
if ($id > 0 || !empty($ref)) {
$result = $object->fetch($id, $ref);
$result = $object->fetch($id, (string) $ref);
if ($result < 0) {
dol_print_error($db, $object->error, $object->errors);
}
@ -634,7 +634,7 @@ if (empty($reshook)) {
$object->desiredstock = GETPOST('desiredstock') ? GETPOST('desiredstock') : 0;
$object->canvas = GETPOST('canvas');
$object->net_measure = GETPOST('net_measure');
$object->net_measure_units = GETPOST('net_measure_units'); // This is not the fk_unit but the power of unit
$object->net_measure_units = GETPOST('net_measure_units') === '' ? null : GETPOSTINT('net_measure_units'); // This is not the fk_unit but the power of unit
$object->weight = GETPOST('weight');
$object->weight_units = GETPOST('weight_units'); // This is not the fk_unit but the power of unit
$object->length = GETPOST('size');
@ -812,7 +812,7 @@ if (empty($reshook)) {
$object->canvas = GETPOST('canvas');
$object->net_measure = GETPOST('net_measure');
$object->net_measure_units = GETPOST('net_measure_units'); // This is not the fk_unit but the power of unit
$object->net_measure_units = GETPOST('net_measure_units') === '' ? null : GETPOSTINT('net_measure_units'); // This is not the fk_unit but the power of unit
$object->weight = GETPOST('weight');
$object->weight_units = GETPOST('weight_units'); // This is not the fk_unit but the power of unit
$object->length = GETPOST('size');
@ -1090,27 +1090,27 @@ if (empty($reshook)) {
$commande = null;
// Get object and test permission
if (GETPOST('propalid') > 0) {
if (GETPOSTINT('propalid') > 0) {
$propal = new Propal($db);
$result = $propal->fetch(GETPOST('propalid'));
$result = $propal->fetch(GETPOSTINT('propalid'));
if ($result <= 0) {
dol_print_error($db, $propal->error);
exit;
}
$thirdpartyid = $propal->socid;
$permissiontoaddline = $user->hasRight('propal', 'creer');
} elseif (GETPOST('commandeid') > 0) {
} elseif (GETPOSTINT('commandeid') > 0) {
$commande = new Commande($db);
$result = $commande->fetch(GETPOST('commandeid'));
$result = $commande->fetch(GETPOSTINT('commandeid'));
if ($result <= 0) {
dol_print_error($db, $commande->error);
exit;
}
$thirdpartyid = $commande->socid;
$permissiontoaddline = $user->hasRight('commande', 'creer');
} elseif (GETPOST('factureid') > 0) {
} elseif (GETPOSTINT('factureid') > 0) {
$facture = new Facture($db);
$result = $facture->fetch(GETPOST('factureid'));
$result = $facture->fetch(GETPOSTINT('factureid'));
if ($result <= 0) {
dol_print_error($db, $facture->error);
exit;
@ -1151,7 +1151,7 @@ if (empty($reshook)) {
$prodcustprice = new ProductCustomerPrice($db);
$filter = array('t.fk_product' => $object->id, 't.fk_soc' => $soc->id);
$filter = array('t.fk_product' => (string) $object->id, 't.fk_soc' => (string) $soc->id);
$result = $prodcustprice->fetchAll('', '', 0, 0, $filter);
if ($result) {
@ -1165,7 +1165,7 @@ if (empty($reshook)) {
}
$tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $object->tva_tx));
// On reevalue prix selon taux tva car taux tva transaction peut etre different
// de ceux du produit par default (par example si pays different entre vendeur et acheteur).
@ -1177,10 +1177,10 @@ if (empty($reshook)) {
}
}
if (GETPOST('propalid') > 0 && $permissiontoaddline && is_object($propal)) {
if (GETPOSTINT('propalid') > 0 && $permissiontoaddline && is_object($propal)) {
// Define cost price for margin calculation
$buyprice = 0;
if (($result = $propal->defineBuyPrice($pu_ht, price2num(GETPOST('remise_percent'), '', 2), $object->id)) < 0) {
if (($result = $propal->defineBuyPrice($pu_ht, (float) price2num(GETPOST('remise_percent'), '', 2), $object->id)) < 0) {
dol_syslog($langs->trans('FailedToGetCostPrice'));
setEventMessages($langs->trans('FailedToGetCostPrice'), null, 'errors');
} else {
@ -1190,12 +1190,12 @@ if (empty($reshook)) {
$result = $propal->addline(
$desc,
$pu_ht,
price2num(GETPOST('qty'), 'MS'),
(float) price2num(GETPOST('qty'), 'MS'),
$tva_tx,
$localtax1_tx, // localtax1
$localtax2_tx, // localtax2
$object->id,
price2num(GETPOST('remise_percent'), '', 2),
(float) price2num(GETPOST('remise_percent'), '', 2),
$price_base_type,
$pu_ttc,
0,
@ -1220,7 +1220,7 @@ if (empty($reshook)) {
} elseif (GETPOST('commandeid') > 0 && $permissiontoaddline && is_object($commande)) {
// Define cost price for margin calculation
$buyprice = 0;
if (($result = $commande->defineBuyPrice($pu_ht, price2num(GETPOST('remise_percent'), '', 2), $object->id)) < 0) {
if (($result = $commande->defineBuyPrice($pu_ht, (float) price2num(GETPOST('remise_percent'), '', 2), $object->id)) < 0) {
dol_syslog($langs->trans('FailedToGetCostPrice'));
setEventMessages($langs->trans('FailedToGetCostPrice'), null, 'errors');
} else {
@ -1229,13 +1229,13 @@ if (empty($reshook)) {
$result = $commande->addline(
$desc,
$pu_ht,
price2num(GETPOST('qty'), 'MS'),
(float) $pu_ht,
(float) price2num(GETPOST('qty'), 'MS'),
$tva_tx,
$localtax1_tx, // localtax1
$localtax2_tx, // localtax2
$object->id,
price2num(GETPOST('remise_percent'), '', 2),
(float) price2num(GETPOST('remise_percent'), '', 2),
0,
0,
$price_base_type,
@ -1262,7 +1262,7 @@ if (empty($reshook)) {
} elseif (GETPOST('factureid') > 0 && $permissiontoaddline && is_object($facture)) {
// Define cost price for margin calculation
$buyprice = 0;
if (($result = $facture->defineBuyPrice($pu_ht, price2num(GETPOST('remise_percent'), '', 2), $object->id)) < 0) {
if (($result = $facture->defineBuyPrice($pu_ht, (float) price2num(GETPOST('remise_percent'), '', 2), $object->id)) < 0) {
dol_syslog($langs->trans('FailedToGetCostPrice'));
setEventMessages($langs->trans('FailedToGetCostPrice'), null, 'errors');
} else {
@ -1271,13 +1271,13 @@ if (empty($reshook)) {
$result = $facture->addline(
$desc,
$pu_ht,
price2num(GETPOST('qty'), 'MS'),
(float) $pu_ht,
(float) price2num(GETPOST('qty'), 'MS'),
$tva_tx,
$localtax1_tx,
$localtax2_tx,
$object->id,
price2num(GETPOST('remise_percent'), '', 2),
(float) price2num(GETPOST('remise_percent'), '', 2),
'',
'',
0,
@ -1666,7 +1666,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
if (!getDolGlobalString('PRODUCT_DISABLE_NATURE')) {
// Nature
print '<tr><td>'.$form->textwithpicto($langs->trans("NatureOfProductShort"), $langs->trans("NatureOfProductDesc")).'</td><td>';
print $formproduct->selectProductNature('finished', $object->finished);
print $formproduct->selectProductNature('finished', (string) $object->finished);
print '</td></tr>';
}
}
@ -1845,7 +1845,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
} else {
$accountancy_code_sell = (GETPOSTISSET('accountancy_code_sell') ? GETPOST('accountancy_code_sell', 'alpha') : getDolGlobalString("ACCOUNTING_SERVICE_SOLD_ACCOUNT"));
}
print $formaccounting->select_account($accountancy_code_sell, 'accountancy_code_sell', 1, array(), 1, 1, 'minwidth150 maxwidth300', 1);
print $formaccounting->select_account($accountancy_code_sell, 'accountancy_code_sell', 1, array(), 1, 1, 'minwidth150 maxwidth300', '1');
print '</td></tr>';
// Accountancy_code_sell_intra
@ -1857,7 +1857,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
} else {
$accountancy_code_sell_intra = (GETPOSTISSET('accountancy_code_sell_intra') ? GETPOST('accountancy_code_sell_intra', 'alpha') : getDolGlobalString("ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT"));
}
print $formaccounting->select_account($accountancy_code_sell_intra, 'accountancy_code_sell_intra', 1, array(), 1, 1, 'minwidth150 maxwidth300', 1);
print $formaccounting->select_account($accountancy_code_sell_intra, 'accountancy_code_sell_intra', 1, array(), 1, 1, 'minwidth150 maxwidth300', '1');
print '</td></tr>';
}
@ -1869,7 +1869,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
} else {
$accountancy_code_sell_export = (GETPOST('accountancy_code_sell_export') ? GETPOST('accountancy_code_sell_export', 'alpha') : getDolGlobalString("ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT"));
}
print $formaccounting->select_account($accountancy_code_sell_export, 'accountancy_code_sell_export', 1, array(), 1, 1, 'minwidth150 maxwidth300', 1);
print $formaccounting->select_account($accountancy_code_sell_export, 'accountancy_code_sell_export', 1, array(), 1, 1, 'minwidth150 maxwidth300', '1');
print '</td></tr>';
// Accountancy_code_buy
@ -1880,7 +1880,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
} else {
$accountancy_code_buy = (GETPOST('accountancy_code_buy', 'alpha') ? (GETPOST('accountancy_code_buy', 'alpha')) : getDolGlobalString("ACCOUNTING_SERVICE_BUY_ACCOUNT"));
}
print $formaccounting->select_account($accountancy_code_buy, 'accountancy_code_buy', 1, array(), 1, 1, 'minwidth150 maxwidth300', 1);
print $formaccounting->select_account($accountancy_code_buy, 'accountancy_code_buy', 1, array(), 1, 1, 'minwidth150 maxwidth300', '1');
print '</td></tr>';
// Accountancy_code_buy_intra
@ -1892,7 +1892,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
} else {
$accountancy_code_buy_intra = (GETPOSTISSET('accountancy_code_buy_intra') ? GETPOST('accountancy_code_buy_intra', 'alpha') : getDolGlobalString("ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT"));
}
print $formaccounting->select_account($accountancy_code_buy_intra, 'accountancy_code_buy_intra', 1, array(), 1, 1, 'minwidth150 maxwidth300', 1);
print $formaccounting->select_account($accountancy_code_buy_intra, 'accountancy_code_buy_intra', 1, array(), 1, 1, 'minwidth150 maxwidth300', '1');
print '</td></tr>';
}
@ -1904,7 +1904,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
} else {
$accountancy_code_buy_export = (GETPOST('accountancy_code_buy_export') ? GETPOST('accountancy_code_buy_export', 'alpha') : getDolGlobalString("ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT"));
}
print $formaccounting->select_account($accountancy_code_buy_export, 'accountancy_code_buy_export', 1, array(), 1, 1, 'minwidth150 maxwidth300', 1);
print $formaccounting->select_account($accountancy_code_buy_export, 'accountancy_code_buy_export', 1, array(), 1, 1, 'minwidth150 maxwidth300', '1');
print '</td></tr>';
} else {// For external software
if (!empty($accountancy_code_sell)) {
@ -2360,7 +2360,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
print '<tr><td>'.$langs->trans("CountryOrigin").'</td>';
print '<td>';
print img_picto('', 'globe-americas', 'class="paddingrightonly"');
print $form->select_country(GETPOSTISSET('country_id') ? GETPOSTINT('country_id') : $object->country_id, 'country_id', '', 0, 'minwidth100 maxwidthonsmartphone');
print $form->select_country((string) (GETPOSTISSET('country_id') ? GETPOSTINT('country_id') : $object->country_id), 'country_id', '', 0, 'minwidth100 maxwidthonsmartphone');
if ($user->admin) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
@ -2559,7 +2559,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
if (isModEnabled("product") && isModEnabled("service")) {
$typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service");
print '<tr><td class="titlefield">';
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 '</td><td>';
print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, $usercancreate, $typeformat);
print '</td></tr>';
@ -2605,7 +2605,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
if ($action == 'editbarcode') {
$tmpcode = GETPOSTISSET('barcode') ? GETPOST('barcode') : $object->barcode;
if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) {
$tmpcode = $modBarCodeProduct->getNextValue($object, $fk_barcode_type);
$tmpcode = $modBarCodeProduct->getNextValue($object, (string) $fk_barcode_type);
}
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">';
@ -2900,7 +2900,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
// Net Measure
print '<tr><td class="titlefieldmiddle">'.$langs->trans("NetMeasure").'</td><td>';
if ($object->net_measure != '') {
print $object->net_measure." ".measuringUnitString($object->net_measure_units);
print $object->net_measure." ".measuringUnitString((int) $object->net_measure_units);
} else {
print '&nbsp;';
}
@ -3212,7 +3212,7 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete') {
$genallowed = $usercanread;
$delallowed = $usercancreate;
print $formfile->showdocuments($modulepart, $object->ref, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $langs->getDefaultLang(), '', $object);
print $formfile->showdocuments($modulepart, $object->ref, $filedir, $urlsource, (int) $genallowed, (int) $delallowed, '', 0, 0, 0, 28, 0, '', '', '', $langs->getDefaultLang(), '', $object);
$somethingshown = $formfile->numoffiles;
print '</div><div class="fichehalfright">';

View file

@ -2,7 +2,7 @@
/* Copyright (C) 2008-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015-2017 Francis Appels <francis.appels@yahoo.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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<array{method:string,url:string,htmlname:string,params:array<string,string>}> $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) {

View file

@ -246,7 +246,7 @@ class Product extends CommonObject
public $level;
/**
* @var ?array<string,array{label:string,description:string,note?:string}> Array for multilangs
* @var ?array<string,array{label:string,description:string,note?:string,other?:string}> 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<int,array{id:int,id_parent:int,ref:string,nb:int,nb_total:int,stock:float,stock_alert:float,label:string,fullpath:string,type:int,desiredstick:float,level:int,incdec:int<0,1>,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) {

View file

@ -2,7 +2,7 @@
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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);

View file

@ -8,7 +8,7 @@
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2023 Benjamin Falière <benjamin.faliere@altairis.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 '<tr><td class="titlefield">';
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 '</td><td>';
print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, $usercancreate, $typeformat);
print '</td></tr>';

View file

@ -9,7 +9,7 @@
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 '<table class="noborder">';
$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 ';

View file

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2015 Ion Agorria <ion@agorria.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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(

View file

@ -7,7 +7,7 @@
* Copyright (C) 2019 Pierre Ardoin <mapiolca@me.com>
* Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 ";

View file

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*/
/*
* 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) {

View file

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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);

View file

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2019 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 '</td>';
if (isModEnabled('productbatch')) {
print '<td>';

View file

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 '<input type="hidden" name="page_y" value="">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
$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 '<input type="text" class="flat maxwidth'.($val['type'] == 'integer' ? '50' : '75').'" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
}
@ -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 '<td'.($cssforfield ? ' class="'.$cssforfield.(preg_match('/tdoverflow/', $cssforfield) ? ' classfortooltip' : '').'"' : '');
if (preg_match('/tdoverflow/', $cssforfield) && !is_numeric($object->$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;

View file

@ -14,7 +14,7 @@
* Copyright (C) 2020-2021 Open-DSI <support@open-dsi.fr>
* Copyright (C) 2022 Charlene Benke <charlene@patas-monkey.com>
* Copyright (C) 2020-2023 Alexandre Spangaro <aspangaro@easya.solutions>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Benjamin Falière <benjamin.faliere@altairis.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
@ -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<string,array{label:string,checked?:int<0,1>,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<string,array{label:string,checked?:string,position?:int,enabled?:string,help?:string}> $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 '<form id="searchFormList" action="'.$_SERVER["PHP_SELF"].'" method="POST" name="formulaire">';
@ -1242,7 +1245,7 @@ if (!empty($arrayfields['p.fk_country']['checked'])) {
// State
if (!empty($arrayfields['p.fk_state']['checked'])) {
print '<td class="liste_titre center">';
print $formcompany->select_state($search_state, $search_country);
print $formcompany->select_state((int) $search_state, $search_country);
print '</td>';
}
// 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 '<td align="left">';
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<int,array<int,array{price:string,price_ttc:string,price_base_type:string}>> $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 '</td>';
@ -2275,7 +2276,7 @@ while ($i < $imaxinloop) {
// Import ID
if (!empty($arrayfields['p.import_key']['checked'])) {
print '<td class="center nowrap">';
print dol_escape_htmltag($product_static->import_key);
print dol_escape_htmltag((string) $product_static->import_key);
print '</td>';
if (!$i) {
$totalarray['nbfield']++;

View file

@ -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 '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield centpercent">';
$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 '<tr><td class="">';
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 '</td><td>';
print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat);
print '</td></tr>';
@ -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 '<tr><td class="">';
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 '</td><td>';
print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat);
print '</td></tr>';
@ -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 '<tr><td class="">';
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 '</td><td>';
print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat);
print '</td></tr>';
@ -1319,6 +1323,7 @@ if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUS
print '<td class="right">'.$langs->trans("Discount").'</td>';
print '<td>&nbsp;</td>';
print '</tr>';
$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 '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">';
@ -1441,6 +1446,7 @@ if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUS
print $object->price_label;
print '</td></tr>';
$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 '<tr><td>'.$langs->trans("PriceByQuantity");
@ -1469,7 +1475,7 @@ if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUS
print '<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[0].'">'; // id in product_price
print '<input type="hidden" value="0" name="rowid">'; // id in product_price_by_qty
print '<tr class="'.($ii % 2 == 0 ? 'pair' : 'impair').'">';
print '<tr class="'.(($ii % 2) == 0 ? 'pair' : 'impair').'">'; // @phpstan-ignore-line
print '<td><input size="5" type="text" value="1" name="quantity"></td>';
print '<td class="right"><input class="width50 right" type="text" value="0" name="price"></td>';
print '<td>';
@ -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 '<tr id="price_numeric"><td>';
$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 '<input name="price_min" size="10" value="'.price($object->price_min).'">';
}
if (getDolGlobalString('PRODUCT_MINIMUM_RECOMMENDED_PRICE')) {
print ' &nbsp; '.$langs->trans("MinimumRecommendedPrice", price($maxpricesupplier, 0, '', 1, -1, -1, 'auto')).' '.img_warning().'</td>';
print ' &nbsp; '.$langs->trans("MinimumRecommendedPrice", price((float) $maxpricesupplier, 0, '', 1, -1, -1, 'auto')).' '.img_warning().'</td>';
}
print '</td>';
print '</tr>';
@ -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 '<td style="text-align: center">';
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 '</td>';
}
@ -1966,7 +1972,7 @@ if (($action == 'edit_price' || $action == 'edit_level_price') && $object->getRi
print '<input name="price_min['.$i.']" size="10" value="'.price($object->multiprices_min [$i]).'">';
}
if (getDolGlobalString('PRODUCT_MINIMUM_RECOMMENDED_PRICE')) {
print '<td class="left">'.$langs->trans("MinimumRecommendedPrice", price($maxpricesupplier, 0, '', 1, -1, -1, 'auto')).' '.img_warning().'</td>';
print '<td class="left">'.$langs->trans("MinimumRecommendedPrice", price((float) $maxpricesupplier, 0, '', 1, -1, -1, 'auto')).' '.img_warning().'</td>';
}
print '</td>';
@ -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 '<!-- list of all log of prices per customer -->'."\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];

View file

@ -12,6 +12,7 @@
* Copyright (C) 2019 Tim Otte <otte@meuser.it>
* Copyright (C) 2020 Pierre Ardoin <mapiolca@me.com>
* Copyright (C) 2023 Joachim Kueter <git-jk@bloxera.com>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 '<tr><td class="">';
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 '</td><td>';
print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat);
print '</td></tr>';
@ -432,7 +433,7 @@ if ($id > 0 || $ref) {
$textdesc = $langs->trans("CostPriceDescription");
$textdesc .= "<br>".$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 '</td><td>';
print $form->editfieldval($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6');
print '</td></tr>';
@ -445,7 +446,7 @@ if ($id > 0 || $ref) {
print '<tr><td class="titlefieldcreate">';
$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 '</td><td>';
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 '<tr>';
print '<td>'.$langs->trans("Charges").'</td>';
print '<td><input class="flat" name="charges" size="8" value="'.(GETPOST('charges') ? price(GETPOST('charges')) : (isset($object->fourn_charges) ? price($object->fourn_charges) : '')).'">';
print '<td><input class="flat" name="charges" size="8" value="'.(GETPOST('charges') ? price(GETPOST('charges')) : (isset($object->fourn_charges) ? price((string) $object->fourn_charges) : '')).'">';
print '</td>';
print '</tr>';
}
@ -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 '<td class="right">';
print price($productfourn->fourn_charges);
print price((string) $productfourn->fourn_charges);
print '</td>';
}
@ -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);
}

View file

@ -5,7 +5,7 @@
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2019 Thibault FOUCART <support@ptibogxiv.net>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -237,13 +237,13 @@ if ($result || !($id > 0)) {
print '<tr class="nooddeven"><td class="titlefield">'.$langs->trans("Year").'</td><td>';
$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".'<div class="fichecenter"><div class="fichehalfleft">'."\n";
} else {
print "\n".'<div class="fichehalfright">'."\n";

View file

@ -4,6 +4,7 @@
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 '<div class="divsearchfield">';
print $langs->trans('Period').' ('.$langs->trans("OrderDate").') - ';
print $langs->trans('Month').':<input class="flat" type="text" size="4" name="search_month" value="'.($search_month > 0 ? $search_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 '<div style="vertical-align: middle; display: inline-block">';

View file

@ -5,6 +5,7 @@
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 Charlene Benke <charlene@patas-monkey.com>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 '<div class="divsearchfield">';
print $langs->trans('Period').' ('.$langs->trans("OrderDate").') - ';
print $langs->trans('Month').':<input class="flat" type="text" size="4" name="search_month" value="'.($search_month > 0 ? $search_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 '<div style="vertical-align: middle; display: inline-block">';

View file

@ -3,6 +3,7 @@
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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";

View file

@ -5,6 +5,7 @@
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2024 Jean-Rémi Taponier <jean-remi@netlogic.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 '<div class="divsearchfield">';
print $langs->trans('Period').' ('.$langs->trans("DateCreation").') - ';
print $langs->trans('Month').':<input class="flat" type="text" size="4" name="search_month" value="'.($search_month > 0 ? $search_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 '<div style="vertical-align: middle; display: inline-block">';
print '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"), 'search.png', '', 0, 1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"), 'searchclear.png', '', 0, 1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';

View file

@ -5,6 +5,7 @@
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 '<div class="divsearchfield">';
print $langs->trans('Period').' ('.$langs->trans("DateInvoice").') - ';
print $langs->trans('Month').':<input class="flat" type="text" size="4" name="search_month" value="'.($search_month > 0 ? $search_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 '<div style="vertical-align: middle; display: inline-block">';
print '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"), 'search.png', '', 0, 1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"), 'searchclear.png', '', 0, 1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';

View file

@ -6,6 +6,7 @@
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2022 Eric Seigne <eric.seigne@cap-rel.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 '<div class="divsearchfield">';
print $langs->trans('Period').' ('.$langs->trans("DateInvoice").') - ';
print $langs->trans('Month').':<input class="flat" type="text" size="4" name="search_month" value="'.($search_month > 0 ? $search_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 '<div style="vertical-align: middle; display: inline-block">';
print '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"), 'search.png', '', 0, 1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"), 'searchclear.png', '', 0, 1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';

View file

@ -4,6 +4,7 @@
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2023 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 '<div class="divsearchfield">';
print $langs->trans('Period').' ('.$langs->trans("DateCreation").') - ';
print $langs->trans('Month').':<input class="flat" type="text" size="4" name="search_month" value="'.($search_month > 0 ? $search_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 '<div style="vertical-align: middle; display: inline-block">';
print '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"), 'search.png', '', 0, 1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"), 'searchclear.png', '', 0, 1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';

View file

@ -4,6 +4,7 @@
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 '<div class="divsearchfield">';
print $langs->trans('Period').' ('.$langs->trans("DatePropal").') - ';
print $langs->trans('Month').':<input class="flat" type="text" size="4" name="search_month" value="'.($search_month > 0 ? $search_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 '<div style="vertical-align: middle; display: inline-block">';
print '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"), 'search.png', '', 0, 1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"), 'searchclear.png', '', 0, 1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';

View file

@ -5,6 +5,7 @@
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2024 Jean-Rémi Taponier <jean-remi@netlogic.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 '<div class="divsearchfield">';
print $langs->trans('Period').' ('.$langs->trans("DateCreation").') - ';
print $langs->trans('Month').':<input class="flat" type="text" size="4" name="search_month" value="'.($search_month > 0 ? $search_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 '<div style="vertical-align: middle; display: inline-block">';
print '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"), 'search.png', '', 0, 1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"), 'searchclear.png', '', 0, 1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';

View file

@ -4,6 +4,7 @@
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 '<div class="divsearchfield">';
print $langs->trans('Period').' ('.$langs->trans("DatePropal").') - ';
print $langs->trans('Month').':<input class="flat" type="text" size="4" name="search_month" value="'.($search_month > 0 ? $search_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 '<div style="vertical-align: middle; display: inline-block">';
print '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"), 'search.png', '', 0, 1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"), 'searchclear.png', '', 0, 1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';

View file

@ -8,7 +8,7 @@
* Copyright (C) 2021-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2022-2023 Charlene Benke <charlene@patas-monkey.com>
* Copyright (C) 2023 Christian Foellmann <christian@foellmann.de>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 '</td></tr>';
// Project
if (isModEnabled('project')) {
if (isModEnabled('project') && $formproject !== null) {
$langs->load('projects');
print '<tr><td>'.$langs->trans('Project').'</td><td colspan="2">';
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 ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$socid.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$socid).'"><span class="fa fa-plus-circle valignmiddle" title="'.$langs->trans("AddProject").'"></span></a>';
print '</td></tr>';
}
@ -402,7 +403,7 @@ if ($action == 'create') {
// Categories
print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">';
$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 "</td></tr>";
}
print '</table>';
@ -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 .= '<br>'.img_picto('', 'project').' '.$langs->trans('Project').' ';
if ($usercancreate) {
@ -469,11 +470,11 @@ if ($action == 'create') {
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
$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 .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>';
} 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 '<td class="right amount nowraponall">'.price(price2num($objp->ppmp * $objp->value, 'MT')).'</td>';
$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 '</td></tr>';
// Project
if (isModEnabled('project')) {
if (isModEnabled('project') && $formproject !== null) {
$projectid = $object->fk_project;
$langs->load('projects');
print '<tr><td>'.$langs->trans('Project').'</td><td colspan="2">';
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 ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.($socid > 0 ? $socid : "").'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create'.($socid > 0 ? '&socid='.$socid : "")).'"><span class="fa fa-plus-circle valignmiddle" title="'.$langs->trans("AddProject").'"></span></a>';
print '</td></tr>';
}
@ -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 "</td></tr>";
}
@ -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 '</div><div class="fichehalfright">';

View file

@ -1059,7 +1059,8 @@ class Entrepot extends CommonObject
if (property_exists($this, 'lieu') && (!empty($this->lieu))) {
$return .= '<br><span class="info-box-label opacitymedium">'.$this->lieu.'</span>';
}
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 .= '<br><span class="info-box-label amount">'.price($this->sellvalue).'</span>';
}
if (method_exists($this, 'getLibStatut')) {

View file

@ -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

View file

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
}
if ($action == 'classify') {
$formproject = new FormProjets($db);
$projectid = $object->fk_project;
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
$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 .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>';
} 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)) {

View file

@ -4,7 +4,7 @@
* Copyright (C) 2005-2014 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* 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 '<input type="text" class="flat maxwidth'.($val['type'] == 'integer' ? '50' : '75').'" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
}
@ -781,7 +781,7 @@ while ($i < $imaxinloop) {
if (!empty($arrayfields['t.'.$key]['checked'])) {
print '<td'.($cssforfield ? ' class="'.$cssforfield.(preg_match('/tdoverflow/', $cssforfield) ? ' classfortooltip' : '').'"' : '');
if (preg_match('/tdoverflow/', $cssforfield) && !is_numeric($object->$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 '</td>';
if (!$i) {

View file

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2013-2022 Laurent Destaileur <ely@users.sourceforge.net>
* Copyright (C) 2014 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* 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 '</tr>';
print '<tr class="oddeven">';
// From warehouse
print '<td class="nowraponall">';
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 '</td>';
// To warehouse
print '<td class="nowraponall">';
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 '</td>';
// Product
print '<td class="nowraponall">';
@ -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);

View file

@ -5,7 +5,7 @@
* Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 '</div><div class="fichehalfright">';

View file

@ -5,7 +5,7 @@
* Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2018-2022 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 .= '<br>'.img_picto('', 'project').' '.$langs->trans('Project').' ';
if ($usercancreate && 1 == 2) {
if ($usercancreate && 1 == 2) { // @phan-suppress-current-line PhanPluginBothLiteralsBinaryOp
if ($action != 'classify') {
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$warehouse->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
}
@ -874,11 +874,11 @@ if ($warehouse->id > 0) {
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$warehouse->id.'">';
$morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
$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 .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>';
} 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);

View file

@ -4,6 +4,7 @@
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2023 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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";

View file

@ -1,10 +1,11 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010 François Legastelois <flegastelois@teclib.com>
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010 François Legastelois <flegastelois@teclib.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
*
* 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 "</tr>\n";
print '<tr class="liste_titre">';
if (getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT')) {
print '<td>'.$langs->trans("Project").'</td>';
print '<th>'.$langs->trans("Project").'</th>';
}
if (getDolGlobalString('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT')) {
print '<td>'.$langs->trans("ThirdParty").'</td>';
print '<th>'.$langs->trans("ThirdParty").'</th>';
}
print '<td>'.$langs->trans("Task").'</td>';
print '<th>'.$langs->trans("Task").'</th>';
if (!empty($arrayfields['t.planned_workload']['checked'])) {
print '<td align="right" class="leftborder plannedworkload maxwidth75">'.$form->textwithpicto($langs->trans("PlannedWorkloadShort"), $langs->trans("PlannedWorkload")).'</td>';
print '<th class="leftborder plannedworkload maxwidth75 maxwidth100 right">'.$form->textwithpicto($langs->trans("PlannedWorkloadShort"), $langs->trans("PlannedWorkload")).'</th>';
}
if (!empty($arrayfields['t.progress']['checked'])) {
print '<td class="right maxwidth75">'.$langs->trans("ProgressDeclared").'</td>';
print '<th class="right maxwidth75">'.$langs->trans("ProgressDeclared").'</th>';
}
if (!empty($arrayfields['timeconsumed']['checked'])) {
print '<td class="right maxwidth100">'.$langs->trans("TimeSpentSmall").'<br>';
print '<th class="right maxwidth100">'.$langs->trans("TimeSpentSmall").'<br>';
print '<span class="nowraponall">';
print '<span class="opacitymedium nopadding userimg"><img alt="Photo" class="photouserphoto userphoto" src="'.DOL_URL_ROOT.'/theme/common/everybody.png"></span>';
print '<span class="opacitymedium paddingleft">'.$langs->trans("EverybodySmall").'</span>';
print '</span>';
print '</td>';
print '<td class="right maxwidth75">'.$langs->trans("TimeSpentSmall").($usertoprocess->firstname ? '<br><span class="nowraponall">'.$usertoprocess->getNomUrl(-2).'<span class="opacitymedium paddingleft">'.dol_trunc($usertoprocess->firstname, 10).'</span></span>' : '').'</td>';
print '</th>';
print '<th class="right maxwidth75">'.$langs->trans("TimeSpentSmall").($usertoprocess->firstname ? '<br><span class="nowraponall">'.$usertoprocess->getNomUrl(-2).'<span class="opacitymedium paddingleft">'.dol_trunc($usertoprocess->firstname, 10).'</span></span>' : '').'</th>';
}
foreach ($TWeek as $week_number) {
print '<td width="6%" class="center bold hide"><a href="'.DOL_URL_ROOT.'/projet/activity/perweek.php?year='.$year.'&month='.$month.'&day='.$TFirstDays[$week_number].'">'.$langs->trans("WeekShort").' '.$week_number.'<br>('.$TFirstDays[$week_number].'...'.$TLastDays[$week_number].')</a></td>';
print '<th width="6%" class="center bold hide"><a href="'.DOL_URL_ROOT.'/projet/activity/perweek.php?year='.$year.'&month='.$month.'&day='.$TFirstDays[$week_number].'">'.$langs->trans("WeekShort").' '.$week_number.'<br>('.$TFirstDays[$week_number].'...'.$TLastDays[$week_number].')</a></th>';
}
//print '<td></td>';

View file

@ -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) {

View file

@ -12,7 +12,7 @@
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2016 Yasser Carreón <yacasia@gmail.com>
* Copyright (C) 2018 Quentin Vial-Gouteyron <quentin.vial-gouteyron@atm-consulting.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -999,7 +999,7 @@ if ($action == 'create') {
/**
* @var array<string,int> $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) {