diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 967d16ab04e..cbe0f4b2732 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -9,8 +9,7 @@ concurrency: cancel-in-progress: true env: - CACHE_KEY_PART: ${{ github.event_name == 'pull_request' && format('{0}-{1}', -github.base_ref, github.head_ref) || github.ref_name }} + CACHE_KEY_PART: ${{ github.event_name == 'pull_request' && format('{0}-{1}', github.base_ref, github.head_ref) || github.ref_name }} GITHUB_JSON: ${{ toJSON(github) }} # Helps in debugging Github Action # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: @@ -57,7 +56,8 @@ jobs: # Run PHPStan - name: Run PHPStan id: phpstan - run: phpstan -vvv analyse --error-format=checkstyle --memory-limit 4G -a build/phpstan/bootstrap_action.php -c phpstan.neon | tee _stan.xml | cs2pr --graceful-warnings + run: | + phpstan -vvv analyse --error-format=checkstyle --memory-limit 7G -a build/phpstan/bootstrap_action.php | tee _stan.xml | cs2pr --graceful-warnings # continue-on-error: true # Save cache diff --git a/.github/workflows/windows-ci.yaml b/.github/workflows/windows-ci.yaml index c0e44dbb74f..f8441c438fc 100644 --- a/.github/workflows/windows-ci.yaml +++ b/.github/workflows/windows-ci.yaml @@ -114,7 +114,7 @@ jobs: curl "http://${{ env.PHPSERVER_DOMAIN_PORT }}" shell: powershell - name: Run PHPUnit tests - continue-on-error: true + # continue-on-error: true shell: cmd # setting up php.ini, starting the php server are currently in this step run: |- @@ -143,7 +143,7 @@ jobs: cat htdocs/conf/conf.php curl "http://${{ env.PHPSERVER_DOMAIN_PORT }}" REM 'DOSKEY' USED to recover error code (no pipefile equivalent in windows?) - ( php "%PHPROOT%\phpunit" -d memory_limit=-1 -c %CD%\test\phpunit\phpunittest.xml "test\phpunit\AllTests.php" & call doskey /exename=err err=%%^^errorlevel%% ) | "${{ env.TEE }}" "${{ env.PHPUNIT_LOG }}" + ( php "%PHPROOT%\phpunit" -d memory_limit=-1 -c %CD%\test\phpunit\phpunittest.xml "test\phpunit\AllTests.php" --exclude-group WindowsWaitingForFix & call doskey /exename=err err=%%^^errorlevel%% ) | "${{ env.TEE }}" "${{ env.PHPUNIT_LOG }}" for /f "tokens=2 delims==" %%A in ('doskey /m:err') do EXIT /B %%A - name: Convert Raw Log to Annotations uses: mdeweerd/logToCheckStyle@v2024.2.9 diff --git a/.gitignore b/.gitignore index efe6c66dfc0..2964b1ead0f 100644 --- a/.gitignore +++ b/.gitignore @@ -66,8 +66,21 @@ doc/install.lock /composer.json /composer.lock -# to execute pre-commit -local.sh +# Local script, executed during pre-commit +/local.sh + +# Local phpstan configuration +/phpstan.neon +/phpstan-baseline.neon + +# Logs +/*.log + +# Vim swap files +*.sw? + +# Generated by PHPUNIT.BAT +/INI_PHPUNIT # ignore cache builds /build/phpstan/phpstan @@ -75,3 +88,4 @@ local.sh phpstan_custom.neon /.php-cs-fixer.cache /.php_cs.cache +/.cache diff --git a/ChangeLog b/ChangeLog index 25688ef0ccb..3207490752d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -30,6 +30,9 @@ The following changes may create regressions for some external modules, but were * The signature for all ->delete() method has been modified to match the modulebuilder template (so first paramis now always $user), except the delete for thirdparty (still accept the id of thirdparty to delete as first parameter). Will probably be modified into another version. * Route for API /thirdparties/gateways has been renamed into /thirdparties/accounts +* The $userdoneid in actioncomm class is deprecated. Please use $userownerid instead. +* The field fk_user_done in actioncomm table is deprecated. Please use fk_user_action instead. +* The AGENDA_ENABLE_DONEBY hidden option is deprecated. ***** ChangeLog for 19.0.1 compared to 19.0.0 ***** diff --git a/SECURITY.md b/SECURITY.md index 0cc37b96ce6..02a015756cf 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -104,3 +104,5 @@ Scope is the web application (backoffice) and the APIs. * SSL/TLS best practices * Invalid or missing SPF (Sender Policy Framework) records (Incomplete or missing SPF/DKIM/DMARC) * Physical or social engineering attempts or issues that require physical access to a victim’s computer/device +* Vulnerabilities of type XSS exploited by using javascript into a website page (with permission to edit website pages) or by using php code into a website page + using the permission to edit php code are not qualified, except if this allow to get higher privileges (being able to set javascript or php code is the expected behaviour). diff --git a/dev/tools/codespell/codespell-ignore.txt b/dev/tools/codespell/codespell-ignore.txt index c71e990a467..0c84807010b 100644 --- a/dev/tools/codespell/codespell-ignore.txt +++ b/dev/tools/codespell/codespell-ignore.txt @@ -57,3 +57,4 @@ dur fonction espace methode +datee diff --git a/dev/tools/github_commits_byversion.sh b/dev/tools/github_commits_byversion.sh index bd3405376cf..eafca6b2e01 100755 --- a/dev/tools/github_commits_byversion.sh +++ b/dev/tools/github_commits_byversion.sh @@ -4,7 +4,7 @@ # # shellcheck disable=1113,2002,2006,2086,2164,2219 -Releases=("3.9" "4.0" "5.0" "6.0" "7.0" "8.0" "9.0" "10.0" "11.0" "12.0" "13.0" "14.0" "15.0" "16.0" "17.0" "18.0" "develop") +Releases=("3.9" "4.0" "5.0" "6.0" "7.0" "8.0" "9.0" "10.0" "11.0" "12.0" "13.0" "14.0" "15.0" "16.0" "17.0" "18.0" "19.0" "develop") let "counter = 0" echo "Copy script into /tmp/github_commits_byversion.sh" @@ -49,4 +49,3 @@ do echo let "counter +=1" done - diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 3ccb13ee599..68fc0c015e7 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -10,13 +10,11 @@ return [ // # Issue statistics: // PhanPluginSuspiciousParamPosition : 45+ occurrences - // PhanPluginDuplicateIfStatements : 30+ occurrences // PhanParamSignatureMismatch : 25+ occurrences // PhanUndeclaredConstant : 15+ occurrences // PhanPluginDuplicateExpressionBinaryOp : 10+ occurrences // PhanTypeArraySuspiciousNull : 10+ occurrences // PhanTypeInvalidUnaryOperandNumeric : 8 occurrences - // PhanPluginDuplicateIfCondition : 6 occurrences // PhanRedefineFunctionInternal : 6 occurrences // PhanPluginUnsafeEval : 5 occurrences // PhanParamSuspiciousOrder : 4 occurrences @@ -32,26 +30,19 @@ return [ // Currently, file_suppressions and directory_suppressions are the only supported suppressions 'file_suppressions' => [ - 'htdocs/adherents/card.php' => ['PhanPluginDuplicateIfStatements'], 'htdocs/adherents/stats/geo.php' => ['PhanTypeArraySuspiciousNull'], 'htdocs/adherents/type.php' => ['PhanPluginDuplicateExpressionBinaryOp'], 'htdocs/admin/receiptprinter.php' => ['PhanRedefineFunctionInternal'], 'htdocs/admin/translation.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/api/class/api_documents.class.php' => ['PhanPluginDuplicateExpressionBinaryOp'], 'htdocs/barcode/printsheet.php' => ['PhanPluginDuplicateExpressionBinaryOp'], - 'htdocs/bom/bom_list.php' => ['PhanPluginDuplicateIfStatements'], 'htdocs/categories/class/api_categories.class.php' => ['PhanAccessMethodProtected'], 'htdocs/categories/viewcat.php' => ['PhanPluginDuplicateExpressionBinaryOp'], 'htdocs/collab/index.php' => ['PhanParamTooMany'], - 'htdocs/comm/action/card.php' => ['PhanPluginDuplicateIfStatements'], 'htdocs/comm/action/index.php' => ['PhanPluginSuspiciousParamPosition', 'PhanTypeArraySuspiciousNull', 'PhanTypeInvalidUnaryOperandNumeric'], - 'htdocs/comm/action/pertype.php' => ['PhanPluginDuplicateIfStatements'], - 'htdocs/comm/action/peruser.php' => ['PhanPluginDuplicateIfStatements'], - 'htdocs/comm/mailing/card.php' => ['PhanPluginDuplicateIfStatements', 'PhanPluginSuspiciousParamPosition'], + 'htdocs/comm/mailing/card.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/comm/mailing/cibles.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/comm/mailing/info.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/comm/propal/list.php' => ['PhanPluginDuplicateIfStatements'], - 'htdocs/commande/list.php' => ['PhanPluginDuplicateIfStatements'], 'htdocs/compta/accounting-files.php' => ['PhanTypeInvalidUnaryOperandNumeric'], 'htdocs/compta/bank/various_payment/card.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/compta/bank/various_payment/document.php' => ['PhanPluginSuspiciousParamPosition'], @@ -59,7 +50,6 @@ return [ 'htdocs/compta/cashcontrol/cashcontrol_card.php' => ['PhanPluginDuplicateExpressionBinaryOp'], 'htdocs/compta/facture/agenda-rec.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/compta/facture/card-rec.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/compta/facture/list.php' => ['PhanPluginDuplicateIfCondition'], 'htdocs/compta/prelevement/class/bonprelevement.class.php' => ['PhanParamTooMany'], 'htdocs/compta/prelevement/create.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/compta/sociales/class/paymentsocialcontribution.class.php' => ['PhanTypeInvalidUnaryOperandNumeric'], @@ -68,38 +58,33 @@ return [ 'htdocs/compta/sociales/note.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/compta/tva/class/paymentvat.class.php' => ['PhanTypeInvalidUnaryOperandNumeric'], 'htdocs/compta/tva/document.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/core/actions_massactions.inc.php' => ['PhanPluginDuplicateIfStatements', 'PhanPluginSuspiciousParamOrder'], + 'htdocs/core/actions_massactions.inc.php' => ['PhanPluginSuspiciousParamOrder'], 'htdocs/core/class/commondocgenerator.class.php' => ['PhanTypeArraySuspiciousNull'], - 'htdocs/core/class/commonobject.class.php' => ['PhanPluginDuplicateIfCondition', 'PhanPluginDuplicateIfStatements', 'PhanPluginSuspiciousParamPosition'], + 'htdocs/core/class/commonobject.class.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/core/class/evalmath.class.php' => ['PhanPluginUnsafeEval'], - 'htdocs/core/class/html.form.class.php' => ['PhanPluginDuplicateIfStatements', 'PhanPluginSuspiciousParamPosition'], + 'htdocs/core/class/html.form.class.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/core/class/html.formmail.class.php' => ['PhanNoopArray'], - 'htdocs/core/class/rssparser.class.php' => ['PhanPluginDuplicateIfStatements', 'PhanUndeclaredFunctionInCallable'], - 'htdocs/core/db/mysqli.class.php' => ['PhanParamSignatureMismatch', 'PhanPluginDuplicateIfStatements'], + 'htdocs/core/class/rssparser.class.php' => ['PhanUndeclaredFunctionInCallable'], + 'htdocs/core/db/mysqli.class.php' => ['PhanParamSignatureMismatch'], 'htdocs/core/db/pgsql.class.php' => ['PhanParamSignatureMismatch'], 'htdocs/core/db/sqlite3.class.php' => ['PhanParamSignatureMismatch'], 'htdocs/core/filemanagerdol/connectors/php/connector.lib.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/core/get_info.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/core/lib/files.lib.php' => ['PhanPluginDuplicateExpressionBinaryOp', 'PhanPluginDuplicateIfCondition'], - 'htdocs/core/lib/ftp.lib.php' => ['PhanPluginDuplicateIfStatements'], - 'htdocs/core/lib/functions.lib.php' => ['PhanParamTooMany', 'PhanPluginAlwaysReturnFunction', 'PhanPluginDuplicateIfCondition', 'PhanPluginUnsafeEval', 'PhanRedefineFunctionInternal'], + 'htdocs/core/lib/files.lib.php' => ['PhanPluginDuplicateExpressionBinaryOp'], + 'htdocs/core/lib/functions.lib.php' => ['PhanParamTooMany', 'PhanPluginAlwaysReturnFunction', 'PhanPluginUnsafeEval', 'PhanRedefineFunctionInternal'], 'htdocs/core/lib/price.lib.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/core/lib/usergroups.lib.php' => ['PhanNoopArrayAccess'], - 'htdocs/core/menus/standard/auguria_menu.php' => ['PhanParamSuspiciousOrder', 'PhanPluginDuplicateIfStatements'], - 'htdocs/core/menus/standard/eldy_menu.php' => ['PhanParamSuspiciousOrder', 'PhanPluginDuplicateIfStatements'], - 'htdocs/core/menus/standard/empty.php' => ['PhanParamSuspiciousOrder', 'PhanPluginDuplicateIfStatements'], + 'htdocs/core/menus/standard/auguria_menu.php' => ['PhanParamSuspiciousOrder'], + 'htdocs/core/menus/standard/eldy_menu.php' => ['PhanParamSuspiciousOrder'], + 'htdocs/core/menus/standard/empty.php' => ['PhanParamSuspiciousOrder'], 'htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php' => ['PhanParamSignatureMismatch'], 'htdocs/core/modules/import/import_xlsx.modules.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/core/modules/member/doc/pdf_standard.class.php' => ['PhanParamSignatureMismatch'], 'htdocs/core/modules/movement/doc/pdf_standard.modules.php' => ['PhanPluginDuplicateExpressionBinaryOp'], 'htdocs/core/modules/mrp/doc/pdf_vinci.modules.php' => ['PhanTypeArraySuspiciousNull'], - 'htdocs/core/modules/societe/mod_codecompta_aquarium.php' => ['PhanPluginDuplicateIfStatements'], - 'htdocs/core/modules/societe/modules_societe.class.php' => ['PhanPluginDuplicateIfCondition'], 'htdocs/core/modules/syslog/mod_syslog_file.php' => ['PhanParamSignatureMismatch', 'PhanParamSuspiciousOrder'], 'htdocs/core/modules/syslog/mod_syslog_syslog.php' => ['PhanParamSignatureMismatch'], 'htdocs/don/class/don.class.php' => ['PhanParamTooMany'], - 'htdocs/ecm/index_auto.php' => ['PhanPluginDuplicateIfStatements'], - 'htdocs/expensereport/card.php' => ['PhanPluginDuplicateIfStatements'], 'htdocs/expensereport/class/paymentexpensereport.class.php' => ['PhanTypeInvalidUnaryOperandNumeric'], 'htdocs/fourn/class/api_supplier_invoices.class.php' => ['PhanPluginSuspiciousParamOrder'], 'htdocs/fourn/facture/card-rec.php' => ['PhanPluginSuspiciousParamPosition'], @@ -114,8 +99,6 @@ return [ 'htdocs/mrp/class/mo.class.php' => ['PhanParamSignatureMismatch'], 'htdocs/product/admin/product_tools.php' => ['PhanNoopStringLiteral'], 'htdocs/product/card.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/product/popuprop.php' => ['PhanPluginDuplicateIfStatements'], - 'htdocs/product/stats/card.php' => ['PhanPluginDuplicateIfStatements'], 'htdocs/projet/tasks/list.php' => ['PhanTypeArraySuspiciousNull'], 'htdocs/public/bookcal/index.php' => ['PhanTypeInvalidUnaryOperandNumeric'], 'htdocs/public/opensurvey/index.php' => ['PhanPluginSuspiciousParamOrder'], @@ -126,7 +109,6 @@ return [ 'htdocs/takepos/invoice.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/user/class/user.class.php' => ['PhanParamSignatureMismatch'], 'htdocs/variants/class/ProductCombination.class.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/webportal/class/html.formwebportal.class.php' => ['PhanPluginSuspiciousParamPosition'], 'internal' => ['PhanUndeclaredConstant'], ], // 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed. diff --git a/dev/tools/phan/config.php b/dev/tools/phan/config.php index ee9cde2603f..0f97494f6f5 100644 --- a/dev/tools/phan/config.php +++ b/dev/tools/phan/config.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France */ define('DOL_PROJECT_ROOT', __DIR__.'/../../..'); define('DOL_DOCUMENT_ROOT', DOL_PROJECT_ROOT.'/htdocs'); @@ -54,7 +55,7 @@ $DEPRECATED_MODULE_MAPPING = array( 'commande' => 'order', 'contrat' => 'contract', 'entrepot' => 'stock', - 'expedition' => 'delivery_note', + 'expedition' => 'shipping', 'facture' => 'invoice', 'ficheinter' => 'intervention', 'product_fournisseur_price' => 'productsupplierprice', @@ -93,7 +94,7 @@ $VALID_MODULE_MAPPING = array( 'datapolicy' => 'DataPolicy', 'dav' => 'Dav', 'debugbar' => 'DebugBar', - 'delivery_note' => 'Expedition', + 'shipping' => 'Expedition', 'deplacement' => 'Deplacement', "documentgeneration" => 'DocumentGeneration', 'don' => 'Don', @@ -228,14 +229,58 @@ return [ 'simplify_ast' => true, 'analyzed_file_extensions' => ['php','inc'], 'globals_type_map' => [ + 'action' => 'string', + 'actioncode' => 'string', + 'badgeStatus0' => 'string', + 'badgeStatus1' => 'string', + 'badgeStatus11' => 'string', + 'badgeStatus3' => 'string', + 'badgeStatus4' => 'string', + 'badgeStatus6' => 'string', + 'badgeStatus8' => 'string', + 'badgeStatus9' => 'string', + 'classname' => 'string', 'conf' => '\Conf', + 'conffile' => 'string', + 'conffiletoshow' => 'string', + 'conffiletoshowshort' => 'string', + 'dateSelector' => 'int<0,1>', 'db' => '\DoliDB', + 'disableedit' => 'int<0,1>', + 'disablemove' => 'int<0,1>', + 'disableremove' => 'int<0,1>', + 'dolibarr_main_authentication' => 'string', + 'dolibarr_main_data_root' => 'string', + 'dolibarr_main_data_root' => 'string', + 'dolibarr_main_db_encrypted_pass' => 'string', + 'dolibarr_main_db_host' => 'string', + 'dolibarr_main_db_pass' => 'string', + 'dolibarr_main_demo' => 'string', + 'dolibarr_main_document_root' => 'string', + 'dolibarr_main_url_root' => 'string', + 'errormsg' => 'string', 'extrafields' => '\ExtraFields', + 'filter' => 'string', + 'filtert' => 'int', + 'forceall' => 'int<0,1>', + 'form' => '\Form', 'hookmanager' => '\HookManager', + 'inputalsopricewithtax' => 'int<0,1>', 'langs' => '\Translate', + 'leftmenu' => 'string', + 'mainmenu' => 'string', + 'menumanager' => 'string', 'mysoc' => '\Societe', 'nblines' => '\int', + 'obj' => '\CommonObject', // Deprecated + 'object_rights' => 'int|stdClass', + 'objectoffield' => '\CommonObject', + 'senderissupplier' => 'int<0,1,2>', 'user' => '\User', + 'website' => '\WebSite', + 'websitepage' => '\WebSitePage', + 'websitepagefile' => 'string', + // 'object' => '\CommonObject', // Deprecated, not enabled because conflicts with $object assignments ], // Supported values: `'5.6'`, `'7.0'`, `'7.1'`, `'7.2'`, `'7.3'`, `'7.4'`, `null`. @@ -284,6 +329,7 @@ return [ .'|htdocs/includes/restler/.*' // @phpstan-ignore-line // Included as stub (did not seem properly analysed by phan without it) .'|htdocs/includes/stripe/.*' // @phpstan-ignore-line + .'|htdocs/conf/conf.php' // @phpstan-ignore-line // .'|htdocs/[^h].*/.*' // For testing @phpstan-ignore-line .')@', // @phpstan-ignore-line @@ -297,7 +343,7 @@ return [ // Alternately, you can pass in the full path to a PHP file // with the plugin's implementation (e.g. 'vendor/phan/phan/.phan/plugins/AlwaysReturnPlugin.php') 'ParamMatchRegexPlugin' => [ - '/^GETPOST$/' => [1, $sanitizeRegex], + '/^GETPOST$/' => [1, $sanitizeRegex, 'GetPostUnknownSanitizeType'], '/^isModEnabled$/' => [0, $moduleNameRegex, 'UnknownModuleName'], // Note: trick to have different key for same regex: '/^isModEnable[d]$/' => [0, $deprecatedModuleNameRegex, "DeprecatedModuleName"], @@ -364,8 +410,7 @@ return [ 'PhanDeprecatedProperty', 'PhanDeprecatedFunction', //'PhanCompatibleNegativeStringOffset', - // Dolibarr has quite a few strange noop assignments like $abc=$abc; - 'PhanPluginDuplicateExpressionAssignment', + // 'PhanPluginDuplicateExpressionAssignment', // Nulls are likely mostly false positives 'PhanPluginConstantVariableNull', 'PhanTypeObjectUnsetDeclaredProperty', @@ -408,7 +453,7 @@ return [ 'PhanTypeInvalidDimOffset', // 'PhanPluginNoCommentOnProtectedProperty', // 'PhanPluginDescriptionlessCommentOnPublicMethod', - 'PhanPluginUnknownClosureParamType', + // 'PhanPluginUnknownClosureParamType', 'PhanPluginUnknownClosureReturnType', // 'PhanPluginNoCommentOnProtectedMethod', // 'PhanTypeArraySuspicious', @@ -420,9 +465,9 @@ return [ // 'PhanPluginNoCommentOnFunction', 'PhanPluginUnknownArrayFunctionParamType', // 'PhanPluginDescriptionlessCommentOnPublicProperty', - 'PhanPluginUnknownFunctionParamType', + // 'PhanPluginUnknownFunctionParamType', // Finds certain errors in PHPdoc typing 'PhanTypeSuspiciousStringExpression', - 'PhanPluginRedundantAssignment', + // 'PhanPluginRedundantAssignment', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeInvalidRightOperandOfNumericOp', @@ -430,14 +475,14 @@ return [ // 'PhanPluginUnknownFunctionReturnType', // 'PhanPluginDescriptionlessCommentOnProtectedProperty', 'PhanPluginRedundantAssignmentInGlobalScope', - 'PhanTypeMismatchDeclaredParamNullable', + // 'PhanTypeMismatchDeclaredParamNullable', 'PhanTypeInvalidRightOperandOfAdd', // 'PhanPluginDescriptionlessCommentOnPrivateProperty', // 'PhanUndeclaredVariableDim', // Array initialisation on undeclared var: $abc['x']='ab' 'PhanTypeInvalidPropertyName', 'PhanPluginDuplicateCatchStatementBody', 'PhanPluginUndeclaredVariableIsset', - 'PhanTypeInvalidUnaryOperandIncOrDec', + // 'PhanTypeInvalidUnaryOperandIncOrDec', // 'PhanPluginDescriptionlessCommentOnClass', 'PhanPluginEmptyStatementIf', 'PhanPluginInlineHTMLTrailing', @@ -448,7 +493,7 @@ return [ 'PhanRedefineClass', 'PhanRedefineFunction', 'PhanTypeInvalidLeftOperandOfBitwiseOp', - 'PhanTypeMismatchDimAssignment', + // 'PhanTypeMismatchDimAssignment', // 'PhanPluginDescriptionlessCommentOnProtectedMethod', 'PhanPluginPrintfIncompatibleArgumentTypeWeak', 'PhanUndeclaredVariableAssignOp', @@ -482,7 +527,7 @@ return [ 'PhanTypeMismatchBitwiseBinaryOperands', 'PhanTypeMismatchDimEmpty', 'PhanTypeSuspiciousEcho', - 'PhanNoopBinaryOperator', + // 'PhanNoopBinaryOperator', // 'PhanTypeInvalidBitwiseBinaryOperator', // 'PhanPluginDescriptionlessCommentOnFunction', 'PhanPluginPHPDocInWrongComment', @@ -490,7 +535,8 @@ return [ // 'PhanTypeInvalidThrowsIsInterface', // 'PhanPluginRedundantAssignmentInLoop', // 'PhanInvalidCommentForDeclarationType', - //'PhanParamSignatureMismatchInternal', + // 'PhanParamSignatureMismatchInternal', + // 'PhanParamSignatureMismatch', // 'PhanPluginEmptyStatementForeachLoop', // 'PhanCompatibleDimAlternativeSyntax', 'PhanInvalidFQSENInClasslike', @@ -503,7 +549,7 @@ return [ // 'PhanSyntaxReturnValueInVoid', // 'PhanTypeInstantiateTraitStaticOrSelf', // 'PhanUndeclaredInvokeInCallable', - 'PhanNoopProperty', + // 'PhanNoopProperty', 'PhanNoopVariable', // 'PhanPluginPrintfUnusedArgument', // 'PhanSyntaxReturnExpectedValue', @@ -523,7 +569,7 @@ return [ // 'PhanTypeMismatchDeclaredReturnNullable', // 'PhanUndeclaredThis', - 'PhanPluginMixedKeyNoKey', + // 'PhanPluginMixedKeyNoKey', 'PhanPluginDuplicateConditionalNullCoalescing', // Suggests to optimize to ?? //'PhanUnreferencedClosure', // False positives seen with closures in arrays, TODO: move closure checks closer to what is done by unused variable plugin //'PhanPluginNoCommentOnProtectedMethod', @@ -540,7 +586,7 @@ return [ 'PhanTypePossiblyInvalidDimOffset', // Also checks optional array keys and requires that they are checked for existence. 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty', - 'PhanPluginPrintfNotPercent', + // 'PhanPluginPrintfNotPercent', // Detects fishy stuff with '%' format and suggests %% 'PhanPossiblyUndeclaredGlobalVariable', // 'PhanPluginPossiblyStaticProtectedMethod', 'PhanTypeMismatchReturn', @@ -554,7 +600,7 @@ return [ 'PhanUndeclaredClassMethod', 'PhanUndeclaredMethod', 'PhanTypeMismatchArgumentProbablyReal', - 'PhanPluginDuplicateExpressionAssignmentOperation', + 'PhanPluginDuplicateExpressionAssignmentOperation', // Suggestions for optimisation 'PhanTypeMismatchPropertyDefault', // 'PhanPluginAlwaysReturnMethod', // 'PhanPluginMissingReturnMethod', @@ -611,5 +657,4 @@ return [ 'sockets' => PHAN_DIR . '/stubs/sockets.phan_php', 'zip' => PHAN_DIR . '/stubs/zip.phan_php', ], - ]; diff --git a/dev/tools/phan/config_extended.php b/dev/tools/phan/config_extended.php index 65dcc8f7389..91b2894cd26 100644 --- a/dev/tools/phan/config_extended.php +++ b/dev/tools/phan/config_extended.php @@ -54,7 +54,7 @@ $DEPRECATED_MODULE_MAPPING = array( 'commande' => 'order', 'contrat' => 'contract', 'entrepot' => 'stock', - 'expedition' => 'delivery_note', + 'expedition' => 'shipping', 'facture' => 'invoice', 'ficheinter' => 'intervention', 'product_fournisseur_price' => 'productsupplierprice', @@ -93,7 +93,7 @@ $VALID_MODULE_MAPPING = array( 'datapolicy' => 'DataPolicy', 'dav' => 'Dav', 'debugbar' => 'DebugBar', - 'delivery_note' => 'Expedition', + 'shipping' => 'Expedition', 'deplacement' => 'Deplacement', "documentgeneration" => 'DocumentGeneration', 'don' => 'Don', @@ -206,6 +206,26 @@ return [ 'mysoc' => '\Societe', 'nblines' => '\int', 'user' => '\User', + 'dolibarr_main_data_root' => 'string', + 'dolibarr_main_authentication' => 'string', + 'dolibarr_main_demo' => 'string', + 'menumanager' => 'string', + 'errormsg' => 'string', + 'form' => '\Form', + 'object_rights' => 'int|stdClass', + 'disableedit' => 'int<0,1>', + 'disablemove' => 'int<0,1>', + 'disableremove' => 'int<0,1>', + // Found in dol_eval + 'website' => '\WebSite', + 'websitepage' => '\WebSitePage', + 'websitepagefile' => 'string', + 'action' => 'string', + 'mainmenu' => 'string', + 'leftmenu' => 'string', + 'objectoffield' => '\CommonObject', + // 'object' => '\CommonObject', // Deprecated, not enabled because conflicts with $object assignments + 'obj' => '\CommonObject', // Deprecated ], // Supported values: `'5.6'`, `'7.0'`, `'7.1'`, `'7.2'`, `'7.3'`, `'7.4'`, `null`. @@ -254,6 +274,7 @@ return [ .'|htdocs/includes/restler/.*' // @phpstan-ignore-line // Included as stub (did not seem properly analysed by phan without it) .'|htdocs/includes/stripe/.*' // @phpstan-ignore-line + .'|htdocs/conf/conf.php' // @phpstan-ignore-line .')@', // @phpstan-ignore-line // A list of plugin files to execute. @@ -266,11 +287,11 @@ return [ // Alternately, you can pass in the full path to a PHP file // with the plugin's implementation (e.g. 'vendor/phan/phan/.phan/plugins/AlwaysReturnPlugin.php') 'ParamMatchRegexPlugin' => [ - '/^GETPOST$/' => [1, $sanitizeRegex], + '/^GETPOST$/' => [1, $sanitizeRegex, 'GetPostUnknownSanitizeType'], '/^isModEnabled$/' => [0, $moduleNameRegex, 'UnknownModuleName'], // Note: trick to have different key for same regex: '/^isModEnable[d]$/' => [0, $deprecatedModuleNameRegex, "DeprecatedModuleName"], - '/^sanitizeVal$/' => [1, $sanitizeRegex], + '/^sanitizeVal$/' => [1, $sanitizeRegex,"UnknownSanitizeType"], ], 'plugins' => [ __DIR__.'/plugins/NoVarDumpPlugin.php', @@ -347,6 +368,7 @@ return [ 'PhanPluginDuplicateConditionalTernaryDuplication', // 2750+ occurrences 'PhanPluginDuplicateConditionalNullCoalescing', // Not essential - 990+ occurrences 'PhanPluginRedundantAssignmentInGlobalScope', // Not essential, a lot of false warning + 'PhanPluginDuplicateCatchStatementBody', // Requires PHP7.1 - 50+ occurrences ], // You can put relative paths to internal stubs in this config option. // Phan will continue using its detailed type annotations, diff --git a/dev/tools/phan/config_fixer.php b/dev/tools/phan/config_fixer.php index 18e50834844..86f1765defb 100644 --- a/dev/tools/phan/config_fixer.php +++ b/dev/tools/phan/config_fixer.php @@ -1,4 +1,7 @@ + * Copyright (C) 2024 Frédéric France + */ // Uncomment require_once to enable corresponding fixer @@ -7,8 +10,6 @@ //require_once __DIR__.'/plugins/UrlEncodeStringifyFixer.php'; require_once __DIR__.'/plugins/SelectDateFixer.php'; -/* Copyright (C) 2024 MDW - */ define('DOL_PROJECT_ROOT', __DIR__.'/../../..'); define('DOL_DOCUMENT_ROOT', DOL_PROJECT_ROOT.'/htdocs'); define('PHAN_DIR', __DIR__); @@ -22,7 +23,7 @@ $DEPRECATED_MODULE_MAPPING = array( 'commande' => 'order', 'contrat' => 'contract', 'entrepot' => 'stock', - 'expedition' => 'delivery_note', + 'expedition' => 'shipping', 'facture' => 'invoice', 'ficheinter' => 'intervention', 'product_fournisseur_price' => 'productsupplierprice', @@ -103,6 +104,7 @@ return [ .'|htdocs/includes/restler/.*' // @phpstan-ignore-line // Included as stub (did not seem properly analysed by phan without it) .'|htdocs/includes/stripe/.*' // @phpstan-ignore-line + .'|htdocs/conf/conf.php' // @phpstan-ignore-line //.'|htdocs/[^c][^o][^r][^e][^/].*' // For testing @phpstan-ignore-line //.'|htdocs/[^h].*' // For testing on restricted set @phpstan-ignore-line .')@', // @phpstan-ignore-line diff --git a/dev/tools/phan/plugins/DeprecatedModuleNameFixer.php b/dev/tools/phan/plugins/DeprecatedModuleNameFixer.php index d8cfcfb141a..cf8a9bc7c62 100644 --- a/dev/tools/phan/plugins/DeprecatedModuleNameFixer.php +++ b/dev/tools/phan/plugins/DeprecatedModuleNameFixer.php @@ -36,7 +36,7 @@ call_user_func(static function (): void { 'commande' => 'order', 'contrat' => 'contract', 'entrepot' => 'stock', - 'expedition' => 'delivery_note', + 'expedition' => 'shipping', 'facture' => 'invoice', 'ficheinter' => 'intervention', 'product_fournisseur_price' => 'productsupplierprice', diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index 8523baecacc..e14477b9158 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -129,7 +129,7 @@ $tabrowid[31] = ""; // List of help for fields $tabhelp = array(); -$tabhelp[31] = array('pcg_version'=>$langs->trans("EnterAnyCode")); +$tabhelp[31] = array('pcg_version' => $langs->trans("EnterAnyCode")); // Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact") @@ -191,10 +191,10 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { // Si verif ok et action add, on ajoute la ligne if ($ok && GETPOST('actionadd', 'alpha')) { + $newid = 0; if ($tabrowid[$id]) { // Get free id for insert - $newid = 0; - $sql = "SELECT MAX(".$db->sanitize($tabrowid[$id]).") newid FROM ".$db->sanitize($tabname[$id]); + $sql = "SELECT MAX(".$db->sanitize($tabrowid[$id]).") as newid FROM ".$db->sanitize($tabname[$id]); $result = $db->query($sql); if ($result) { $obj = $db->fetch_object($result); @@ -241,7 +241,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { $result = $db->query($sql); if ($result) { // Add is ok setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); - $_POST = array('id'=>$id); // Clean $_POST array, we keep only + $_POST = array('id' => $id); // Clean $_POST array, we keep only } else { if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); @@ -353,7 +353,7 @@ print load_fiche_titre($titre, $linkback, 'title_accountancy'); // Confirmation de la suppression de la ligne if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.urlencode($page).'&' : '').'sortfield='.urlencode($sortfield).'&sortorder='.urlencode($sortorder).'&rowid='.urlencode($rowid).'&code='.urlencode($code).'&id='.urlencode($id), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.urlencode((string) ($page)).'&' : '').'sortfield='.urlencode((string) ($sortfield)).'&sortorder='.urlencode((string) ($sortorder)).'&rowid='.urlencode((string) ($rowid)).'&code='.urlencode((string) ($code)).'&id='.urlencode((string) ($id)), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); } //var_dump($elementList); @@ -458,7 +458,7 @@ if ($id) { } $tmpaction = 'create'; - $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $parameters = array('fieldlist' => $fieldlist, 'tabname' => $tabname[$id]); $reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error = $hookmanager->error; $errors = $hookmanager->errors; @@ -486,9 +486,9 @@ if ($id) { $num = $db->num_rows($resql); $i = 0; - $param = '&id='.urlencode($id); + $param = '&id='.urlencode((string) ($id)); if ($search_country_id > 0) { - $param .= '&search_country_id='.urlencode($search_country_id); + $param .= '&search_country_id='.urlencode((string) ($search_country_id)); } $paramwithsearch = $param; if ($sortorder) { @@ -556,7 +556,7 @@ if ($id) { print ''; $tmpaction = 'edit'; - $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $parameters = array('fieldlist' => $fieldlist, 'tabname' => $tabname[$id]); $reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error = $hookmanager->error; $errors = $hookmanager->errors; @@ -571,7 +571,7 @@ if ($id) { print ''; } else { $tmpaction = 'view'; - $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $parameters = array('fieldlist' => $fieldlist, 'tabname' => $tabname[$id]); $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error = $hookmanager->error; @@ -718,7 +718,7 @@ function fieldListAccountModel($fieldlist, $obj = null, $tabname = '', $context print ''; } if ($fieldlist[$field] == 'type_cdr') { - print $form->selectarray($fieldlist[$field], array(0=>$langs->trans('None'), 1=>$langs->trans('AtEndOfMonth'), 2=>$langs->trans('CurrentNext')), (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : '')); + print $form->selectarray($fieldlist[$field], array(0 => $langs->trans('None'), 1 => $langs->trans('AtEndOfMonth'), 2 => $langs->trans('CurrentNext')), (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : '')); } else { print $form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : ''), 1); } diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 032b3ac6e3e..18d793fc43e 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -461,7 +461,7 @@ $fieldlist = explode(',', $tabfield[$id]); $param = '&id='.$id; if ($search_country_id > 0) { - $param .= '&search_country_id='.urlencode($search_country_id); + $param .= '&search_country_id='.urlencode((string) ($search_country_id)); } $paramwithsearch = $param; if ($sortorder) { @@ -474,7 +474,7 @@ if (GETPOST('from', 'alpha')) { $paramwithsearch .= '&from='.urlencode(GETPOST('from', 'alpha')); } if ($listlimit) { - $paramwithsearch .= '&listlimit='.urlencode(GETPOSTINT('listlimit')); + $paramwithsearch .= '&listlimit='.urlencode((string) (GETPOSTINT('listlimit'))); } print '
'; print ''; diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index 1b12d17df07..d710839a391 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -481,7 +481,7 @@ if ($id) { $param = '&id='.((int) $id); if ($search_country_id > 0) { - $param .= '&search_country_id='.urlencode($search_country_id); + $param .= '&search_country_id='.urlencode((string) ($search_country_id)); } $paramwithsearch = $param; if ($sortorder) { diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index fa0db20a05f..403819c7f4d 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -5,6 +5,7 @@ * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Ari Elbaz (elarifr) * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -206,7 +207,7 @@ if ($action == 'update') { $sql_exists .= " WHERE fk_product = " . ((int) $productid) . " AND entity = " . ((int) $conf->entity); $resql_exists = $db->query($sql_exists); if (!$resql_exists) { - $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'
'.$resql_exists.'
'; + $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'
'.json_encode($resql_exists).'
'; $ko++; } else { $nb_exists = $db->num_rows($resql_exists); @@ -422,7 +423,7 @@ if ($resql) { $param .= '&limit='.((int) $limit); } if ($searchCategoryProductOperator == 1) { - $param .= "&search_category_product_operator=".urlencode($searchCategoryProductOperator); + $param .= "&search_category_product_operator=".urlencode((string) ($searchCategoryProductOperator)); } foreach ($searchCategoryProductList as $searchCategoryProduct) { $param .= "&search_category_product_list[]=".urlencode($searchCategoryProduct); diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 66838b8c2e2..e2f1e86008d 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -447,7 +447,7 @@ if ($action == 'create') { print $langs->trans('Docdate'); print ''; if ($action != 'editdate') { - print 'piece_num).'&mode='.urlencode($mode).'">'.img_edit($langs->transnoentitiesnoconv('SetDate'), 1).''; + print 'piece_num)).'&mode='.urlencode((string) ($mode)).'">'.img_edit($langs->transnoentitiesnoconv('SetDate'), 1).''; } print ''; print ''; @@ -474,7 +474,7 @@ if ($action == 'create') { print $langs->trans('Codejournal'); print ''; if ($action != 'editjournal') { - print 'piece_num).'&mode='.urlencode($mode).'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; + print 'piece_num)).'&mode='.urlencode((string) ($mode)).'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; } print ''; print ''; @@ -501,7 +501,7 @@ if ($action == 'create') { print $langs->trans('Piece'); print ''; if ($action != 'editdocref') { - print 'piece_num).'&mode='.urlencode($mode).'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; + print 'piece_num)).'&mode='.urlencode((string) ($mode)).'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; } print ''; print ''; diff --git a/htdocs/accountancy/bookkeeping/export.php b/htdocs/accountancy/bookkeeping/export.php index 6f3c34b279e..16923e5ebbd 100644 --- a/htdocs/accountancy/bookkeeping/export.php +++ b/htdocs/accountancy/bookkeeping/export.php @@ -189,21 +189,21 @@ if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GE $arrayfields = array( - 't.piece_num'=>array('label'=>$langs->trans("TransactionNumShort"), 'checked'=>1), - 't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1), - 't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1), - 't.doc_ref'=>array('label'=>$langs->trans("Piece"), 'checked'=>1), - 't.numero_compte'=>array('label'=>$langs->trans("AccountAccountingShort"), 'checked'=>1), - 't.subledger_account'=>array('label'=>$langs->trans("SubledgerAccount"), 'checked'=>1), - 't.label_operation'=>array('label'=>$langs->trans("Label"), 'checked'=>1), - 't.debit'=>array('label'=>$langs->trans("AccountingDebit"), 'checked'=>1), - 't.credit'=>array('label'=>$langs->trans("AccountingCredit"), 'checked'=>1), - 't.lettering_code'=>array('label'=>$langs->trans("LetteringCode"), 'checked'=>1), - 't.date_creation'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0), - 't.tms'=>array('label'=>$langs->trans("DateModification"), 'checked'=>0), - 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1), - 't.date_validated'=>array('label'=>$langs->trans("DateValidationAndLock"), 'checked'=>1, 'enabled'=>!getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")), - 't.import_key'=>array('label'=>$langs->trans("ImportId"), 'checked'=>0, 'position'=>1100), + 't.piece_num' => array('label' => $langs->trans("TransactionNumShort"), 'checked' => 1), + 't.code_journal' => array('label' => $langs->trans("Codejournal"), 'checked' => 1), + 't.doc_date' => array('label' => $langs->trans("Docdate"), 'checked' => 1), + 't.doc_ref' => array('label' => $langs->trans("Piece"), 'checked' => 1), + 't.numero_compte' => array('label' => $langs->trans("AccountAccountingShort"), 'checked' => 1), + 't.subledger_account' => array('label' => $langs->trans("SubledgerAccount"), 'checked' => 1), + 't.label_operation' => array('label' => $langs->trans("Label"), 'checked' => 1), + 't.debit' => array('label' => $langs->trans("AccountingDebit"), 'checked' => 1), + 't.credit' => array('label' => $langs->trans("AccountingCredit"), 'checked' => 1), + 't.lettering_code' => array('label' => $langs->trans("LetteringCode"), 'checked' => 1), + 't.date_creation' => array('label' => $langs->trans("DateCreation"), 'checked' => 0), + 't.tms' => array('label' => $langs->trans("DateModification"), 'checked' => 0), + 't.date_export' => array('label' => $langs->trans("DateExport"), 'checked' => 1), + 't.date_validated' => array('label' => $langs->trans("DateValidationAndLock"), 'checked' => 1, 'enabled' => !getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")), + 't.import_key' => array('label' => $langs->trans("ImportId"), 'checked' => 0, 'position' => 1100), ); if (!getDolGlobalString('ACCOUNTING_ENABLE_LETTERING')) { @@ -244,7 +244,7 @@ if (!GETPOST('confirmmassaction', 'alpha')) { $massaction = ''; } -$parameters = array('socid'=>$socid); +$parameters = array('socid' => $socid); $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'); @@ -353,7 +353,7 @@ if (empty($reshook)) { } } $filter['t.search_accounting_code_in'] = implode(',', $listofaccountsforgroup2); - $param .= '&search_account_category='.urlencode($search_account_category); + $param .= '&search_account_category='.urlencode((string) ($search_account_category)); } if (!empty($search_accountancy_code)) { $filter['t.numero_compte'] = $search_accountancy_code; @@ -395,7 +395,7 @@ if (empty($reshook)) { } if (!empty($search_mvt_num)) { $filter['t.piece_num'] = $search_mvt_num; - $param .= '&search_mvt_num='.urlencode($search_mvt_num); + $param .= '&search_mvt_num='.urlencode((string) ($search_mvt_num)); } if (!empty($search_date_creation_start)) { $filter['t.date_creation>='] = $search_date_creation_start; @@ -528,25 +528,45 @@ $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { if ($key == 't.doc_date') { - $sqlwhere[] = $key."='".$db->idate($value)."'"; - } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { - $sqlwhere[] = $key."'".$db->idate($value)."'"; - } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') { - $sqlwhere[] = $key."'".$db->escape($value)."'"; + $sqlwhere[] = $db->sanitize($key)." = '".$db->idate($value)."'"; + } elseif ($key == 't.doc_date>=') { + $sqlwhere[] = "t.doc_date >= '".$db->idate($value)."'"; + } elseif ($key == 't.doc_date<=') { + $sqlwhere[] = "t.doc_date <= '".$db->idate($value)."'"; + } elseif ($key == 't.doc_date>') { + $sqlwhere[] = "t.doc_date > '".$db->idate($value)."'"; + } elseif ($key == 't.doc_date<') { + $sqlwhere[] = "t.doc_date < '".$db->idate($value)."'"; + } elseif ($key == 't.numero_compte>=') { + $sqlwhere[] = "t.numero_compte >= '".$db->escape($value)."'"; + } elseif ($key == 't.numero_compte<=') { + $sqlwhere[] = "t.numero_compte <= '".$db->escape($value)."'"; + } elseif ($key == 't.subledger_account>=') { + $sqlwhere[] = "t.subledger_account >= '".$db->escape($value)."'"; + } elseif ($key == 't.subledger_account<=') { + $sqlwhere[] = "t.subledger_account <= '".$db->escape($value)."'"; } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { - $sqlwhere[] = $key.'='.((int) $value); + $sqlwhere[] = $db->sanitize($key).'='.((int) $value); } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { - $sqlwhere[] = $key." LIKE '".$db->escape($value)."%'"; + $sqlwhere[] = $db->sanitize($key)." LIKE '".$db->escape($db->escapeforlike($value))."%'"; } elseif ($key == 't.subledger_account') { $sqlwhere[] = natural_search($key, $value, 0, 1); - } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') { - $sqlwhere[] = $key."'".$db->idate($value)."'"; - } elseif ($key == 't.tms>=' || $key == 't.tms<=') { - $sqlwhere[] = $key."'".$db->idate($value)."'"; - } elseif ($key == 't.date_export>=' || $key == 't.date_export<=') { - $sqlwhere[] = $key."'".$db->idate($value)."'"; - } elseif ($key == 't.date_validated>=' || $key == 't.date_validated<=') { - $sqlwhere[] = $key."'".$db->idate($value)."'"; + } elseif ($key == 't.tms>=') { + $sqlwhere[] = "t.tms >= '".$db->idate($value)."'"; + } elseif ($key == 't.tms<=') { + $sqlwhere[] = "t.tms <= '".$db->idate($value)."'"; + } elseif ($key == 't.date_creation>=') { + $sqlwhere[] = "t.date_creation >= '".$db->idate($value)."'"; + } elseif ($key == 't.date_creation<=') { + $sqlwhere[] = "t.date_creation <= '".$db->idate($value)."'"; + } elseif ($key == 't.date_export>=') { + $sqlwhere[] = "t.date_export >= '".$db->idate($value)."'"; + } elseif ($key == 't.date_export<=') { + $sqlwhere[] = "t.date_export <= '".$db->idate($value)."'"; + } elseif ($key == 't.date_validated>=') { + $sqlwhere[] = "t;date_validate >= '".$db->idate($value)."'"; + } elseif ($key == 't.date_validated<=') { + $sqlwhere[] = "t;date_validate <= '".$db->idate($value)."'"; } elseif ($key == 't.credit' || $key == 't.debit') { $sqlwhere[] = natural_search($key, $value, 1, 1); } elseif ($key == 't.reconciled_option') { @@ -758,7 +778,7 @@ $arrayofselected = is_array($toselect) ? $toselect : array(); // Output page // -------------------------------------------------------------------- -$help_url ='EN:Module_Double_Entry_Accounting#Exports|FR:Module_Comptabilité_en_Partie_Double#Exports'; +$help_url = 'EN:Module_Double_Entry_Accounting#Exports|FR:Module_Comptabilité_en_Partie_Double#Exports'; llxHeader('', $title_page, $help_url); @@ -776,7 +796,7 @@ if ($action == 'export_file') { 'morecss' => 'minwidth200 maxwidth200' ); - $form_question['separator0'] = array('name'=>'separator0', 'type'=>'separator'); + $form_question['separator0'] = array('name' => 'separator0', 'type' => 'separator'); if (getDolGlobalInt("ACCOUNTING_ENABLE_LETTERING")) { // If 1, we check by default. @@ -788,7 +808,7 @@ if ($action == 'export_file') { 'value' => $checked, ); - $form_question['separator1'] = array('name'=>'separator1', 'type'=>'separator'); + $form_question['separator1'] = array('name' => 'separator1', 'type' => 'separator'); } // If 1 or not set, we check by default. @@ -800,7 +820,7 @@ if ($action == 'export_file') { 'value' => (getDolGlobalString('ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE') ? 'false' : 'true'), ); - $form_question['separator2'] = array('name'=>'separator2', 'type'=>'separator'); + $form_question['separator2'] = array('name' => 'separator2', 'type' => 'separator'); if (!getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")) { // If 0 or not set, we NOT check by default. @@ -812,7 +832,7 @@ if ($action == 'export_file') { 'value' => $checked, ); - $form_question['separator3'] = array('name'=>'separator3', 'type'=>'separator'); + $form_question['separator3'] = array('name' => 'separator3', 'type' => 'separator'); } // add documents in an archive for accountancy export (Quadratus) @@ -1016,7 +1036,7 @@ if (!empty($arrayfields['t.lettering_code']['checked'])) { } // Fields from hook -$parameters = array('arrayfields'=>$arrayfields); +$parameters = array('arrayfields' => $arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -1113,7 +1133,7 @@ if (!empty($arrayfields['t.lettering_code']['checked'])) { print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center '); } // Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (!empty($arrayfields['t.date_creation']['checked'])) { @@ -1363,7 +1383,7 @@ while ($i < min($num, $limit)) { } // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -1442,7 +1462,7 @@ if ($num == 0) { print ''.$langs->trans("NoRecordFound").''; } -$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 06921fc9d38..7ac6bc27cea 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -184,21 +184,21 @@ if (!in_array($action, array('delmouv', 'delmouvconfirm')) && !GETPOSTISSET('beg $arrayfields = array( - 't.piece_num'=>array('label'=>$langs->trans("TransactionNumShort"), 'checked'=>1), - 't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1), - 't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1), - 't.doc_ref'=>array('label'=>$langs->trans("Piece"), 'checked'=>1), - 't.numero_compte'=>array('label'=>$langs->trans("AccountAccountingShort"), 'checked'=>1), - 't.subledger_account'=>array('label'=>$langs->trans("SubledgerAccount"), 'checked'=>1), - 't.label_operation'=>array('label'=>$langs->trans("Label"), 'checked'=>1), - 't.debit'=>array('label'=>$langs->trans("AccountingDebit"), 'checked'=>1), - 't.credit'=>array('label'=>$langs->trans("AccountingCredit"), 'checked'=>1), - 't.lettering_code'=>array('label'=>$langs->trans("LetteringCode"), 'checked'=>1), - 't.date_creation'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0), - 't.tms'=>array('label'=>$langs->trans("DateModification"), 'checked'=>0), - 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>0), - 't.date_validated'=>array('label'=>$langs->trans("DateValidationAndLock"), 'checked'=>0, 'enabled'=>!getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")), - 't.import_key'=>array('label'=>$langs->trans("ImportId"), 'checked'=>0, 'position'=>1100), + 't.piece_num' => array('label' => $langs->trans("TransactionNumShort"), 'checked' => 1), + 't.code_journal' => array('label' => $langs->trans("Codejournal"), 'checked' => 1), + 't.doc_date' => array('label' => $langs->trans("Docdate"), 'checked' => 1), + 't.doc_ref' => array('label' => $langs->trans("Piece"), 'checked' => 1), + 't.numero_compte' => array('label' => $langs->trans("AccountAccountingShort"), 'checked' => 1), + 't.subledger_account' => array('label' => $langs->trans("SubledgerAccount"), 'checked' => 1), + 't.label_operation' => array('label' => $langs->trans("Label"), 'checked' => 1), + 't.debit' => array('label' => $langs->trans("AccountingDebit"), 'checked' => 1), + 't.credit' => array('label' => $langs->trans("AccountingCredit"), 'checked' => 1), + 't.lettering_code' => array('label' => $langs->trans("LetteringCode"), 'checked' => 1), + 't.date_creation' => array('label' => $langs->trans("DateCreation"), 'checked' => 0), + 't.tms' => array('label' => $langs->trans("DateModification"), 'checked' => 0), + 't.date_export' => array('label' => $langs->trans("DateExport"), 'checked' => 0), + 't.date_validated' => array('label' => $langs->trans("DateValidationAndLock"), 'checked' => 0, 'enabled' => !getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")), + 't.import_key' => array('label' => $langs->trans("ImportId"), 'checked' => 0, 'position' => 1100), ); if (!getDolGlobalString('ACCOUNTING_ENABLE_LETTERING')) { @@ -232,7 +232,7 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'preunletteringauto $massaction = ''; } -$parameters = array('socid'=>$socid); +$parameters = array('socid' => $socid); $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'); @@ -341,7 +341,7 @@ if (empty($reshook)) { } } $filter['t.search_accounting_code_in'] = implode(',', $listofaccountsforgroup2); - $param .= '&search_account_category='.urlencode($search_account_category); + $param .= '&search_account_category='.urlencode((string) ($search_account_category)); } if (!empty($search_accountancy_code)) { $filter['t.numero_compte'] = $search_accountancy_code; @@ -383,7 +383,7 @@ if (empty($reshook)) { } if (!empty($search_mvt_num)) { $filter['t.piece_num'] = $search_mvt_num; - $param .= '&search_mvt_num='.urlencode($search_mvt_num); + $param .= '&search_mvt_num='.urlencode((string) ($search_mvt_num)); } if (!empty($search_date_creation_start)) { $filter['t.date_creation>='] = $search_date_creation_start; @@ -484,7 +484,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); $error++; break; - } elseif (isset($object->date_validation) || $object->date_validation != '') { + } elseif (isset($object->date_validation) && $object->date_validation != '') { setEventMessages($langs->trans("ValidatedRecordWhereFound"), null, 'errors'); $error++; break; @@ -620,25 +620,45 @@ $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { if ($key == 't.doc_date') { - $sqlwhere[] = $key."='".$db->idate($value)."'"; - } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { - $sqlwhere[] = $key."'".$db->idate($value)."'"; - } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') { - $sqlwhere[] = $key."'".$db->escape($value)."'"; + $sqlwhere[] = $db->sanitize($key)." = '".$db->idate($value)."'"; + } elseif ($key == 't.doc_date>=') { + $sqlwhere[] = "t.doc_date >= '".$db->idate($value)."'"; + } elseif ($key == 't.doc_date<=') { + $sqlwhere[] = "t.doc_date <= '".$db->idate($value)."'"; + } elseif ($key == 't.doc_date>') { + $sqlwhere[] = "t.doc_date > '".$db->idate($value)."'"; + } elseif ($key == 't.doc_date<') { + $sqlwhere[] = "t.doc_date < '".$db->idate($value)."'"; + } elseif ($key == 't.numero_compte>=') { + $sqlwhere[] = "t.numero_compte >= '".$db->escape($value)."'"; + } elseif ($key == 't.numero_compte<=') { + $sqlwhere[] = "t.numero_compte <= '".$db->escape($value)."'"; + } elseif ($key == 't.subledger_account>=') { + $sqlwhere[] = "t.subledger_account >= '".$db->escape($value)."'"; + } elseif ($key == 't.subledger_account<=') { + $sqlwhere[] = "t.subledger_account <= '".$db->escape($value)."'"; } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { - $sqlwhere[] = $key.'='.((int) $value); + $sqlwhere[] = $db->sanitize($key).' = '.((int) $value); } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { - $sqlwhere[] = $key." LIKE '".$db->escape($value)."%'"; + $sqlwhere[] = $db->sanitize($key)." LIKE '".$db->escape($db->escapeforlike($value))."%'"; } elseif ($key == 't.subledger_account') { $sqlwhere[] = natural_search($key, $value, 0, 1); - } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') { - $sqlwhere[] = $key."'".$db->idate($value)."'"; - } elseif ($key == 't.tms>=' || $key == 't.tms<=') { - $sqlwhere[] = $key."'".$db->idate($value)."'"; - } elseif ($key == 't.date_export>=' || $key == 't.date_export<=') { - $sqlwhere[] = $key."'".$db->idate($value)."'"; - } elseif ($key == 't.date_validated>=' || $key == 't.date_validated<=') { - $sqlwhere[] = $key."'".$db->idate($value)."'"; + } elseif ($key == 't.tms>=') { + $sqlwhere[] = "t.tms >= '".$db->idate($value)."'"; + } elseif ($key == 't.tms<=') { + $sqlwhere[] = "t.tms <= '".$db->idate($value)."'"; + } elseif ($key == 't.date_creation>=') { + $sqlwhere[] = "t.date_creation >= '".$db->idate($value)."'"; + } elseif ($key == 't.date_creation<=') { + $sqlwhere[] = "t.date_creation <= '".$db->idate($value)."'"; + } elseif ($key == 't.date_export>=') { + $sqlwhere[] = "t.date_export >= '".$db->idate($value)."'"; + } elseif ($key == 't.date_export<=') { + $sqlwhere[] = "t.date_export <= '".$db->idate($value)."'"; + } elseif ($key == 't.date_validated>=') { + $sqlwhere[] = "t;date_validate >= '".$db->idate($value)."'"; + } elseif ($key == 't.date_validated<=') { + $sqlwhere[] = "t;date_validate <= '".$db->idate($value)."'"; } elseif ($key == 't.credit' || $key == 't.debit') { $sqlwhere[] = natural_search($key, $value, 1, 1); } elseif ($key == 't.reconciled_option') { @@ -916,7 +936,7 @@ if (!empty($arrayfields['t.lettering_code']['checked'])) { } // Fields from hook -$parameters = array('arrayfields'=>$arrayfields); +$parameters = array('arrayfields' => $arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -1013,7 +1033,7 @@ if (!empty($arrayfields['t.lettering_code']['checked'])) { print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center '); } // Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (!empty($arrayfields['t.date_creation']['checked'])) { @@ -1263,7 +1283,7 @@ while ($i < min($num, $limit)) { } // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -1342,7 +1362,7 @@ if ($num == 0) { print ''.$langs->trans("NoRecordFound").''; } -$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 4a39d78e5ef..bb549a3bc6d 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -159,18 +159,18 @@ if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('searc $arrayfields = array( // 't.subledger_account'=>array('label'=>$langs->trans("SubledgerAccount"), 'checked'=>1), - 't.piece_num'=>array('label'=>$langs->trans("TransactionNumShort"), 'checked'=>1), - 't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1), - 't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1), - 't.doc_ref'=>array('label'=>$langs->trans("Piece"), 'checked'=>1), - 't.label_operation'=>array('label'=>$langs->trans("Label"), 'checked'=>1), - 't.lettering_code'=>array('label'=>$langs->trans("Lettering"), 'checked'=>1), - 't.debit'=>array('label'=>$langs->trans("AccountingDebit"), 'checked'=>1), - 't.credit'=>array('label'=>$langs->trans("AccountingCredit"), 'checked'=>1), - 't.balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1), - 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>-1), - 't.date_validated'=>array('label'=>$langs->trans("DateValidation"), 'checked'=>-1, 'enabled'=>!getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")), - 't.import_key'=>array('label'=>$langs->trans("ImportId"), 'checked'=>-1, 'position'=>1100), + 't.piece_num' => array('label' => $langs->trans("TransactionNumShort"), 'checked' => 1), + 't.code_journal' => array('label' => $langs->trans("Codejournal"), 'checked' => 1), + 't.doc_date' => array('label' => $langs->trans("Docdate"), 'checked' => 1), + 't.doc_ref' => array('label' => $langs->trans("Piece"), 'checked' => 1), + 't.label_operation' => array('label' => $langs->trans("Label"), 'checked' => 1), + 't.lettering_code' => array('label' => $langs->trans("Lettering"), 'checked' => 1), + 't.debit' => array('label' => $langs->trans("AccountingDebit"), 'checked' => 1), + 't.credit' => array('label' => $langs->trans("AccountingCredit"), 'checked' => 1), + 't.balance' => array('label' => $langs->trans("Balance"), 'checked' => 1), + 't.date_export' => array('label' => $langs->trans("DateExport"), 'checked' => -1), + 't.date_validated' => array('label' => $langs->trans("DateValidation"), 'checked' => -1, 'enabled' => !getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")), + 't.import_key' => array('label' => $langs->trans("ImportId"), 'checked' => -1, 'position' => 1100), ); if (!getDolGlobalString('ACCOUNTING_ENABLE_LETTERING')) { @@ -217,7 +217,7 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'preunletteringauto $massaction = ''; } -$parameters = array('socid'=>$socid); +$parameters = array('socid' => $socid); $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'); @@ -296,7 +296,7 @@ if (empty($reshook)) { } } $filter['t.search_accounting_code_in'] = implode(',', $listofaccountsforgroup2); - $param .= '&search_account_category='.urlencode($search_account_category); + $param .= '&search_account_category='.urlencode((string) ($search_account_category)); } if (!empty($search_accountancy_code_start)) { if ($type == 'sub') { @@ -320,7 +320,7 @@ if (empty($reshook)) { } if (!empty($search_mvt_num)) { $filter['t.piece_num'] = $search_mvt_num; - $param .= '&search_mvt_num='.urlencode($search_mvt_num); + $param .= '&search_mvt_num='.urlencode((string) ($search_mvt_num)); } if (!empty($search_doc_ref)) { $filter['t.doc_ref'] = $search_doc_ref; @@ -447,7 +447,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); $error++; break; - } elseif (isset($object->date_validation) || $object->date_validation != '') { + } elseif (isset($object->date_validation) && $object->date_validation != '') { setEventMessages($langs->trans("ValidatedRecordWhereFound"), null, 'errors'); $error++; break; @@ -897,7 +897,7 @@ if (!empty($arrayfields['t.import_key']['checked'])) { } // Fields from hook -$parameters = array('arrayfields'=>$arrayfields); +$parameters = array('arrayfields' => $arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -951,7 +951,7 @@ if (!empty($arrayfields['t.import_key']['checked'])) { print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER["PHP_SELF"], "t.import_key", "", $param, '', $sortfield, $sortorder, 'center '); } // Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { @@ -1071,7 +1071,7 @@ while ($i < min($num, $limit)) { // Show the break account print ''; - print ''; + print ''; if ($type == 'sub') { if ($line->subledger_account != "" && $line->subledger_account != '-1') { print empty($line->subledger_label) ? ''.$langs->trans("Unknown").'' : $line->subledger_label; @@ -1227,7 +1227,7 @@ while ($i < min($num, $limit)) { if (strlen(length_accounta($line->subledger_account)) == 0) { print ''.dol_escape_htmltag($line->label_operation).''; } else { - print '('.length_accounta($line->subledger_account).')').'">'.dol_escape_htmltag($line->label_operation).($line->label_operation?'
':'').'('.dol_escape_htmltag(length_accounta($line->subledger_account)).')'; + print '('.length_accounta($line->subledger_account).')').'">'.dol_escape_htmltag($line->label_operation).($line->label_operation ? '
' : '').'('.dol_escape_htmltag(length_accounta($line->subledger_account)).')'; } if (!$i) { $totalarray['nbfield']++; @@ -1302,7 +1302,7 @@ while ($i < min($num, $limit)) { } // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$line); + $parameters = array('arrayfields' => $arrayfields, 'obj' => $line); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -1387,7 +1387,7 @@ if ($num == 0) { print ''.$langs->trans("NoRecordFound").''; } -$parameters = array('arrayfields'=>$arrayfields); +$parameters = array('arrayfields' => $arrayfields); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index a240dca3387..09586c12637 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -14,6 +14,7 @@ * Copyright (C) 2020 Guillaume Alexandre * Copyright (C) 2022 Joachim Kueter * Copyright (C) 2022 Progiseize + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -277,7 +278,7 @@ class AccountancyExport 'ACCOUNTING_EXPORT_FORMAT' => 'csv', ), ), - 'cr'=> array( + 'cr' => array( '1' => $langs->trans("Unix"), '2' => $langs->trans("Windows") ), @@ -302,8 +303,6 @@ class AccountancyExport */ public function getMimeType($formatexportset) { - $mime = 'text/csv'; - switch ($formatexportset) { case self::$EXPORT_TYPE_FEC: $mime = 'text/tab-separated-values'; @@ -346,7 +345,7 @@ class AccountancyExport $exportFile = null; $exportFileName = ''; $exportFilePath = ''; - $exportFileFullName =''; + $exportFileFullName = ''; $downloadFileMimeType = ''; $downloadFileFullName = ''; $downloadFilePath = ''; @@ -1000,7 +999,7 @@ class AccountancyExport $invoice = new FactureFournisseur($this->db); $invoice->fetch($line->fk_doc); $objectDirPath = !empty($conf->fournisseur->facture->multidir_output[$conf->entity]) ? $conf->fournisseur->facture->multidir_output[$conf->entity] : $conf->fournisseur->facture->dir_output; - $objectDirPath.= '/'.rtrim(get_exdir($invoice->id, 2, 0, 0, $invoice, 'invoice_supplier'), '/'); + $objectDirPath .= '/'.rtrim(get_exdir($invoice->id, 2, 0, 0, $invoice, 'invoice_supplier'), '/'); } $arrayofinclusion = array(); // If it is a supplier invoice, we want to use last uploaded file @@ -1466,7 +1465,7 @@ class AccountancyExport $objectDirPath = !empty($conf->expensereport->multidir_output[$conf->entity]) ? $conf->expensereport->multidir_output[$conf->entity] : $conf->expensereport->dir_output; } elseif ($line->doc_type == 'supplier_invoice') { $objectDirPath = !empty($conf->fournisseur->facture->multidir_output[$conf->entity]) ? $conf->fournisseur->facture->multidir_output[$conf->entity] : $conf->fournisseur->facture->dir_output; - $objectDirPath.= '/'.rtrim(get_exdir($invoice->id, 2, 0, 0, $invoice, 'invoice_supplier'), '/'); + $objectDirPath .= '/'.rtrim(get_exdir($invoice->id, 2, 0, 0, $invoice, 'invoice_supplier'), '/'); } $arrayofinclusion = array(); // If it is a supplier invoice, we want to use last uploaded file @@ -1678,7 +1677,7 @@ class AccountancyExport $objectDirPath = !empty($conf->expensereport->multidir_output[$conf->entity]) ? $conf->expensereport->multidir_output[$conf->entity] : $conf->expensereport->dir_output; } elseif ($line->doc_type == 'supplier_invoice') { $objectDirPath = !empty($conf->fournisseur->facture->multidir_output[$conf->entity]) ? $conf->fournisseur->facture->multidir_output[$conf->entity] : $conf->fournisseur->facture->dir_output; - $objectDirPath.= '/'.rtrim(get_exdir($invoice->id, 2, 0, 0, $invoice, 'invoice_supplier'), '/'); + $objectDirPath .= '/'.rtrim(get_exdir($invoice->id, 2, 0, 0, $invoice, 'invoice_supplier'), '/'); } $arrayofinclusion = array(); // If it is a supplier invoice, we want to use last uploaded file @@ -1789,7 +1788,7 @@ class AccountancyExport && $objectLines[$aIndex + 1]->piece_num == $line->piece_num && $aIndex - 1 < $aSize && $objectLines[$aIndex - 1]->piece_num == $line->piece_num - ) { + ) { $sammelBuchung = true; } diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 500fd4a7543..0a8e5a40845 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -5,6 +5,7 @@ * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Ari Elbaz (elarifr) * Copyright (C) 2018 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -501,7 +502,7 @@ class AccountingAccount extends CommonObject $url = DOL_URL_ROOT . '/accountancy/bookkeeping/list.php?search_accountancy_code_start=' . urlencode($this->account_number) . '&search_accountancy_code_end=' . urlencode($this->account_number); $labelurl = $langs->trans("ShowAccountingAccountInJournals"); } elseif ($option == 'accountcard') { - $url = DOL_URL_ROOT . '/accountancy/admin/card.php?id=' . urlencode($this->id); + $url = DOL_URL_ROOT . '/accountancy/admin/card.php?id=' . urlencode((string) ($this->id)); $labelurl = $langs->trans("ShowAccountingAccount"); } @@ -570,7 +571,7 @@ class AccountingAccount extends CommonObject } global $action; $hookmanager->initHooks(array($this->element . 'dao')); - $parameters = array('id'=>$this->id, 'getnomurl' => &$result); + $parameters = array('id' => $this->id, 'getnomurl' => &$result); $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) { $result = $hookmanager->resPrint; @@ -745,7 +746,7 @@ class AccountingAccount extends CommonObject $hookmanager->initHooks(array('accountancyBindingCalculation')); // Execute hook accountancyBindingCalculation - $parameters = array('buyer' => $buyer, 'seller' => $seller, 'product' => $product, 'facture' => $facture, 'factureDet' => $factureDet ,'accountingAccount'=>$accountingAccount, $type); + $parameters = array('buyer' => $buyer, 'seller' => $seller, 'product' => $product, 'facture' => $facture, 'factureDet' => $factureDet ,'accountingAccount' => $accountingAccount, 0 => $type); $reshook = $hookmanager->executeHooks('accountancyBindingCalculation', $parameters); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { @@ -769,11 +770,11 @@ class AccountingAccount extends CommonObject if ($factureDet->product_type == 1) { if ($buyer->country_code == $seller->country_code || empty($buyer->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) $code_l = getDolGlobalString('ACCOUNTING_SERVICE_' . $const_name . '_ACCOUNT'); + // @phan-suppress-next-line PhanPluginRedundantAssignment $suggestedaccountingaccountbydefaultfor = ''; } else { if ($isSellerInEEC && $isBuyerInEEC && $factureDet->tva_tx != 0) { // European intravat sale, but with a VAT $code_l = getDolGlobalString('ACCOUNTING_SERVICE_' . $const_name . '_ACCOUNT'); - $suggestedaccountingaccountbydefaultfor = 'eecwithvat'; } elseif ($isSellerInEEC && $isBuyerInEEC && empty($buyer->tva_intra)) { // European intravat sale, without VAT intra community number $code_l = getDolGlobalString('ACCOUNTING_SERVICE_' . $const_name . '_ACCOUNT'); $suggestedaccountingaccountbydefaultfor = 'eecwithoutvatnumber'; @@ -788,6 +789,7 @@ class AccountingAccount extends CommonObject } elseif ($factureDet->product_type == 0) { if ($buyer->country_code == $seller->country_code || empty($buyer->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) $code_l = getDolGlobalString('ACCOUNTING_PRODUCT_' . $const_name . '_ACCOUNT'); + // @phan-suppress-next-line PhanPluginRedundantAssignment $suggestedaccountingaccountbydefaultfor = ''; } else { if ($isSellerInEEC && $isBuyerInEEC && $factureDet->tva_tx != 0) { // European intravat sale, but with a VAT diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 76b6cdba5a8..90de07f928e 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -161,33 +162,47 @@ class AccountingJournal extends CommonObject /** * Load object in memory from the database * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit limit - * @param int $offset offset limit - * @param array $filter filter array - * @param string $filtermode filter mode (AND or OR) - * @return int Return integer <0 if KO, >0 if OK + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset offset limit + * @param string|array $filter filter array + * @param string $filtermode filter mode (AND or OR) + * @return int Return integer <0 if KO, >0 if OK */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND') { $sql = "SELECT rowid, code, label, nature, active"; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - if ($key == 't.code' || $key == 't.label' || $key == 't.nature') { - $sqlwhere[] = $key." = '".$this->db->escape($value)."'"; - } elseif ($key == 't.rowid' || $key == 't.active') { - $sqlwhere[] = $key.'='.((int) $value); - } - } - } $sql .= ' WHERE 1 = 1'; $sql .= " AND entity IN (".getEntity('accountancy').")"; - if (count($sqlwhere) > 0) { - $sql .= " AND ".implode(" ".$this->db->sanitize($filtermode)." ", $sqlwhere); + + // Manage filter + if (is_array($filter)) { + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.code' || $key == 't.label' || $key == 't.nature') { + $sqlwhere[] = $key." = '".$this->db->escape($value)."'"; + } elseif ($key == 't.rowid' || $key == 't.active') { + $sqlwhere[] = $key.'='.((int) $value); + } + } + } + if (count($sqlwhere) > 0) { + $sql .= " AND ".implode(" ".$this->db->sanitize($filtermode)." ", $sqlwhere); + } + + $filter = ''; + } + + // Manage filter + $errormessage = ''; + $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage); + if ($errormessage) { + $this->errors[] = $errormessage; + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); + return -1; } if (!empty($sortfield)) { @@ -300,7 +315,7 @@ class AccountingJournal extends CommonObject global $action; $hookmanager->initHooks(array('accountingjournaldao')); - $parameters = array('id'=>$this->id, 'getnomurl' => &$result); + $parameters = array('id' => $this->id, 'getnomurl' => &$result); $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) { $result = $hookmanager->resPrint; @@ -406,12 +421,12 @@ class AccountingJournal extends CommonObject case 1: // Various Journal $data = $this->getAssetData($user, $type, $date_start, $date_end, $in_bookkeeping); break; - // case 2: // Sells Journal - // case 3: // Purchases Journal - // case 4: // Bank Journal - // case 5: // Expense reports Journal - // case 8: // Inventory Journal - // case 9: // hasnew Journal + // case 2: // Sells Journal + // case 3: // Purchases Journal + // case 4: // Bank Journal + // case 5: // Expense reports Journal + // case 8: // Inventory Journal + // case 9: // hasnew Journal } } diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 909bfded02a..6d47b7fe700 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -908,22 +908,38 @@ class BookKeeping extends CommonObject $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { - if ($key == 't.doc_date') { - $sqlwhere[] = $key.'=\''.$this->db->idate($value).'\''; - } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { - $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; - } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') { - $sqlwhere[] = $key.'\''.$this->db->escape($value).'\''; + if ($key == 't.doc_date>=') { + $sqlwhere[] = "t.doc_date >= '".$this->db->idate($value)."'"; + } elseif ($key == 't.doc_date<=') { + $sqlwhere[] = "t.doc_date <= '".$this->db->idate($value)."'"; + } elseif ($key == 't.doc_date>') { + $sqlwhere[] = "t.doc_date > '".$this->db->idate($value)."'"; + } elseif ($key == 't.doc_date<') { + $sqlwhere[] = "t.doc_date < '".$this->db->idate($value)."'"; + } elseif ($key == 't.numero_compte>=') { + $sqlwhere[] = "t.numero_compte >= '".$this->db->escape($value)."'"; + } elseif ($key == 't.numero_compte<=') { + $sqlwhere[] = "t.numero_compte <= '".$this->db->escape($value)."'"; + } elseif ($key == 't.subledger_account>=') { + $sqlwhere[] = "t.subledger_account >= '".$this->db->escape($value)."'"; + } elseif ($key == 't.subledger_account<=') { + $sqlwhere[] = "t.subledger_account <= '".$this->db->escape($value)."'"; } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { - $sqlwhere[] = $key.' = '.((int) $value); + $sqlwhere[] = $this->db->sanitize($key).' = '.((int) $value); } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { - $sqlwhere[] = $key.' LIKE \''.$this->db->escape($this->db->escapeforlike($value)).'%\''; - } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') { - $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; - } elseif ($key == 't.date_export>=' || $key == 't.date_export<=') { - $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; - } elseif ($key == 't.date_validated>=' || $key == 't.date_validated<=') { - $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; + $sqlwhere[] = $this->db->sanitize($key).' LIKE \''.$this->db->escape($this->db->escapeforlike($value)).'%\''; + } elseif ($key == 't.date_creation>=') { + $sqlwhere[] = 't.date_creation >= \''.$this->db->idate($value).'\''; + } elseif ($key == 't.date_creation<=') { + $sqlwhere[] = 't.date_creation <= \''.$this->db->idate($value).'\''; + } elseif ($key == 't.date_export>=') { + $sqlwhere[] = 't.date_export >= \''.$this->db->idate($value).'\''; + } elseif ($key == 't.date_export<=') { + $sqlwhere[] = 't.date_export <= \''.$this->db->idate($value).'\''; + } elseif ($key == 't.date_validated>=') { + $sqlwhere[] = 't;date_validate >= \''.$this->db->idate($value).'\''; + } elseif ($key == 't.date_validated<=') { + $sqlwhere[] = 't;date_validate <= \''.$this->db->idate($value).'\''; } elseif ($key == 't.credit' || $key == 't.debit') { $sqlwhere[] = natural_search($key, $value, 1, 1); } elseif ($key == 't.reconciled_option') { @@ -1031,14 +1047,14 @@ class BookKeeping extends CommonObject * * @param string $sortorder Sort Order * @param string $sortfield Sort field - * @param int $limit Offset limit + * @param int $limit Limit * @param int $offset Offset limit - * @param array $filter Filter array + * @param string|array $filter Filter array * @param string $filtermode Filter mode (AND or OR) * @param int $showAlreadyExportMovements Show movements when field 'date_export' is not empty (0:No / 1:Yes (Default)) * @return int Return integer <0 if KO, >0 if OK */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND', $showAlreadyExportMovements = 1) + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND', $showAlreadyExportMovements = 1) { global $conf; @@ -1074,48 +1090,84 @@ class BookKeeping extends CommonObject $sql .= " t.date_export,"; $sql .= " t.date_validated as date_validation"; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - if ($key == 't.doc_date') { - $sqlwhere[] = $key.'=\''.$this->db->idate($value).'\''; - } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { - $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; - } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') { - $sqlwhere[] = $key.'\''.$this->db->escape($value).'\''; - } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { - $sqlwhere[] = $key.'='.((int) $value); - } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { - $sqlwhere[] = $key.' LIKE \''.$this->db->escape($value).'%\''; - } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') { - $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; - } elseif ($key == 't.tms>=' || $key == 't.tms<=') { - $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; - } elseif ($key == 't.date_export>=' || $key == 't.date_export<=') { - $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; - } elseif ($key == 't.date_validated>=' || $key == 't.date_validated<=') { - $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; - } elseif ($key == 't.credit' || $key == 't.debit') { - $sqlwhere[] = natural_search($key, $value, 1, 1); - } elseif ($key == 't.code_journal' && !empty($value)) { - if (is_array($value)) { - $sqlwhere[] = natural_search("t.code_journal", implode(',', $value), 3, 1); - } else { - $sqlwhere[] = natural_search("t.code_journal", $value, 3, 1); - } - } else { - $sqlwhere[] = natural_search($key, $value, 0, 1); - } - } - } + $sql .= ' WHERE t.entity = ' . ((int) $conf->entity); // Do not use getEntity for accounting features if ($showAlreadyExportMovements == 0) { $sql .= " AND t.date_export IS NULL"; } - if (count($sqlwhere) > 0) { - $sql .= ' AND '.implode(" ".$this->db->sanitize($filtermode)." ", $sqlwhere); + + // Manage filter + if (is_array($filter)) { // deprecated, use $filter = USF syntax + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.doc_date') { + $sqlwhere[] = $this->db->sanitize($key).' = \''.$this->db->idate($value).'\''; + } elseif ($key == 't.doc_date>=') { + $sqlwhere[] = "t.doc_date >= '".$this->db->idate($value)."'"; + } elseif ($key == 't.doc_date<=') { + $sqlwhere[] = "t.doc_date <= '".$this->db->idate($value)."'"; + } elseif ($key == 't.doc_date>') { + $sqlwhere[] = "t.doc_date > '".$this->db->idate($value)."'"; + } elseif ($key == 't.doc_date<') { + $sqlwhere[] = "t.doc_date < '".$this->db->idate($value)."'"; + } elseif ($key == 't.numero_compte>=') { + $sqlwhere[] = "t.numero_compte >= '".$this->db->escape($value)."'"; + } elseif ($key == 't.numero_compte<=') { + $sqlwhere[] = "t.numero_compte <= '".$this->db->escape($value)."'"; + } elseif ($key == 't.subledger_account>=') { + $sqlwhere[] = "t.subledger_account >= '".$this->db->escape($value)."'"; + } elseif ($key == 't.subledger_account<=') { + $sqlwhere[] = "t.subledger_account <= '".$this->db->escape($value)."'"; + } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { + $sqlwhere[] = $this->db->sanitize($key).' = '.((int) $value); + } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { + $sqlwhere[] = $this->db->sanitize($key).' LIKE \''.$this->db->escape($value).'%\''; + } elseif ($key == 't.date_creation>=') { + $sqlwhere[] = 't.date_creation >= \''.$this->db->idate($value).'\''; + } elseif ($key == 't.date_creation<=') { + $sqlwhere[] = 't.date_creation <= \''.$this->db->idate($value).'\''; + } elseif ($key == 't.tms>=') { + $sqlwhere[] = 't.tms >= \''.$this->db->idate($value).'\''; + } elseif ($key == 't.tms<=') { + $sqlwhere[] = 't.tms <= \''.$this->db->idate($value).'\''; + } elseif ($key == 't.date_export>=') { + $sqlwhere[] = 't.date_export >= \''.$this->db->idate($value).'\''; + } elseif ($key == 't.date_export<=') { + $sqlwhere[] = 't.date_export <= \''.$this->db->idate($value).'\''; + } elseif ($key == 't.date_validated>=') { + $sqlwhere[] = 't.date_validated >= \''.$this->db->idate($value).'\''; + } elseif ($key == 't.date_validated<=') { + $sqlwhere[] = 't.date_validated <= \''.$this->db->idate($value).'\''; + } elseif ($key == 't.credit' || $key == 't.debit') { + $sqlwhere[] = natural_search($key, $value, 1, 1); + } elseif ($key == 't.code_journal' && !empty($value)) { + if (is_array($value)) { + $sqlwhere[] = natural_search("t.code_journal", implode(',', $value), 3, 1); + } else { + $sqlwhere[] = natural_search("t.code_journal", $value, 3, 1); + } + } else { + $sqlwhere[] = natural_search($key, $value, 0, 1); + } + } + } + if (count($sqlwhere) > 0) { + $sql .= ' AND '.implode(" ".$this->db->sanitize($filtermode)." ", $sqlwhere); + } + + $filter = ''; } + + // Manage filter + $errormessage = ''; + $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage); + if ($errormessage) { + $this->errors[] = $errormessage; + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); + return -1; + } + if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); } @@ -1180,16 +1232,16 @@ class BookKeeping extends CommonObject /** * Load object in memory from the database * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit offset limit - * @param int $offset offset limit - * @param array $filter filter array - * @param string $filtermode filter mode (AND or OR) - * @param int $option option (0: aggregate by general account or 1: aggreegate by subaccount) - * @return int Return integer <0 if KO, >0 if OK + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit Limit + * @param int $offset Offset limit + * @param string|array $filter Filter + * @param string $filtermode Filter mode (AND or OR) + * @param int $option option (0: aggregate by general account or 1: aggreegate by subaccount) + * @return int Return integer <0 if KO, >0 if OK */ - public function fetchAllBalance($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND', $option = 0) + public function fetchAllBalance($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND', $option = 0) { global $conf; @@ -1206,52 +1258,64 @@ class BookKeeping extends CommonObject $sql .= " SUM(t.debit) as debit,"; $sql .= " SUM(t.credit) as credit"; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - - // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - if ($key == 't.doc_date') { - $sqlwhere[] = $this->db->sanitize($key)." = '".$this->db->idate($value)."'"; - } elseif ($key == 't.doc_date>=') { - $sqlwhere[] = "t.doc_date >= '".$this->db->idate($value)."'"; - } elseif ($key == 't.doc_date<=') { - $sqlwhere[] = "t.doc_date <= '".$this->db->idate($value)."'"; - } elseif ($key == 't.doc_date>') { - $sqlwhere[] = "t.doc_date > '".$this->db->idate($value)."'"; - } elseif ($key == 't.doc_date<') { - $sqlwhere[] = "t.doc_date < '".$this->db->idate($value)."'"; - } elseif ($key == 't.numero_compte>=') { - $sqlwhere[] = "t.numero_compte >= '".$this->db->escape($value)."'"; - } elseif ($key == 't.numero_compte<=') { - $sqlwhere[] = "t.numero_compte <= '".$this->db->escape($value)."'"; - } elseif ($key == 't.subledger_account>=') { - $sqlwhere[] = "t.subledger_account >= '".$this->db->escape($value)."'"; - } elseif ($key == 't.subledger_account<=') { - $sqlwhere[] = "t.subledger_account <= '".$this->db->escape($value)."'"; - } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { - $sqlwhere[] = $this->db->sanitize($key)." = ".((int) $value); - } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { - $sqlwhere[] = $this->db->sanitize($key)." LIKE '".$this->db->escape($value)."%'"; - } elseif ($key == 't.subledger_label') { - $sqlwhere[] = $this->db->sanitize($key)." LIKE '".$this->db->escape($value)."%'"; - } elseif ($key == 't.code_journal' && !empty($value)) { - if (is_array($value)) { - $sqlwhere[] = natural_search("t.code_journal", implode(',', $value), 3, 1); - } else { - $sqlwhere[] = natural_search("t.code_journal", $value, 3, 1); - } - } elseif ($key == 't.reconciled_option') { - $sqlwhere[] = 't.lettering_code IS NULL'; - } else { - $sqlwhere[] = $this->db->sanitize($key)." LIKE '%".$this->db->escape($this->db->escapeforlike($value))."%'"; - } - } - } $sql .= ' WHERE entity = ' . ((int) $conf->entity); // Do not use getEntity for accounting features - if (count($sqlwhere) > 0) { - $sql .= " AND ".implode(" ".$this->db->sanitize($filtermode)." ", $sqlwhere); + // Manage filter + if (is_array($filter)) { + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.doc_date') { + $sqlwhere[] = $this->db->sanitize($key)." = '".$this->db->idate($value)."'"; + } elseif ($key == 't.doc_date>=') { + $sqlwhere[] = "t.doc_date >= '".$this->db->idate($value)."'"; + } elseif ($key == 't.doc_date<=') { + $sqlwhere[] = "t.doc_date <= '".$this->db->idate($value)."'"; + } elseif ($key == 't.doc_date>') { + $sqlwhere[] = "t.doc_date > '".$this->db->idate($value)."'"; + } elseif ($key == 't.doc_date<') { + $sqlwhere[] = "t.doc_date < '".$this->db->idate($value)."'"; + } elseif ($key == 't.numero_compte>=') { + $sqlwhere[] = "t.numero_compte >= '".$this->db->escape($value)."'"; + } elseif ($key == 't.numero_compte<=') { + $sqlwhere[] = "t.numero_compte <= '".$this->db->escape($value)."'"; + } elseif ($key == 't.subledger_account>=') { + $sqlwhere[] = "t.subledger_account >= '".$this->db->escape($value)."'"; + } elseif ($key == 't.subledger_account<=') { + $sqlwhere[] = "t.subledger_account <= '".$this->db->escape($value)."'"; + } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { + $sqlwhere[] = $this->db->sanitize($key)." = ".((int) $value); + } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { + $sqlwhere[] = $this->db->sanitize($key)." LIKE '".$this->db->escape($value)."%'"; + } elseif ($key == 't.subledger_label') { + $sqlwhere[] = $this->db->sanitize($key)." LIKE '".$this->db->escape($value)."%'"; + } elseif ($key == 't.code_journal' && !empty($value)) { + if (is_array($value)) { + $sqlwhere[] = natural_search("t.code_journal", implode(',', $value), 3, 1); + } else { + $sqlwhere[] = natural_search("t.code_journal", $value, 3, 1); + } + } elseif ($key == 't.reconciled_option') { + $sqlwhere[] = 't.lettering_code IS NULL'; + } else { + $sqlwhere[] = $this->db->sanitize($key)." LIKE '%".$this->db->escape($this->db->escapeforlike($value))."%'"; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= " AND ".implode(" ".$this->db->sanitize($filtermode)." ", $sqlwhere); + } + + $filter = ''; + } + + // Manage filter + $errormessage = ''; + $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage); + if ($errormessage) { + $this->errors[] = $errormessage; + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); + return -1; } if (!empty($option)) { @@ -2464,7 +2528,7 @@ class BookKeeping extends CommonObject * Get list of fiscal period * * @param string $filter Filter - * @return array|int Return integer <0 if KO, Fiscal periods : [[id, date_start, date_end, label], ...] + * @return array|int Return integer <0 if KO, Fiscal periods : [[id, date_start, date_end, label], ...] */ public function getFiscalPeriods($filter = '') { @@ -2487,11 +2551,11 @@ class BookKeeping extends CommonObject while ($obj = $this->db->fetch_object($resql)) { $list[$obj->rowid] = array( - 'id' => $obj->rowid, + 'id' => (int) $obj->rowid, 'label' => $obj->label, 'date_start' => $this->db->jdate($obj->date_start), 'date_end' => $this->db->jdate($obj->date_end), - 'status' => $obj->statut, + 'status' => (int) $obj->statut, ); } diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 2aaed4ba014..a47a54ae40c 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -351,22 +351,22 @@ if ($result) { $param .= "&search_vat=".urlencode($search_vat); } if ($search_date_startday) { - $param .= '&search_date_startday='.urlencode($search_date_startday); + $param .= '&search_date_startday='.urlencode((string) ($search_date_startday)); } if ($search_date_startmonth) { - $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); + $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth)); } if ($search_date_startyear) { - $param .= '&search_date_startyear='.urlencode($search_date_startyear); + $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear)); } if ($search_date_endday) { - $param .= '&search_date_endday='.urlencode($search_date_endday); + $param .= '&search_date_endday='.urlencode((string) ($search_date_endday)); } if ($search_date_endmonth) { - $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); + $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth)); } if ($search_date_endyear) { - $param .= '&search_date_endyear='.urlencode($search_date_endyear); + $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear)); } if ($search_country) { $param .= "&search_country=".urlencode($search_country); diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index e7487c70e0f..84128d37f94 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -399,25 +399,25 @@ if ($result) { $param .= '&search_societe='.urlencode($search_societe); } if ($search_lineid) { - $param .= '&search_lineid='.urlencode($search_lineid); + $param .= '&search_lineid='.urlencode((string) ($search_lineid)); } if ($search_date_startday) { - $param .= '&search_date_startday='.urlencode($search_date_startday); + $param .= '&search_date_startday='.urlencode((string) ($search_date_startday)); } if ($search_date_startmonth) { - $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); + $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth)); } if ($search_date_startyear) { - $param .= '&search_date_startyear='.urlencode($search_date_startyear); + $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear)); } if ($search_date_endday) { - $param .= '&search_date_endday='.urlencode($search_date_endday); + $param .= '&search_date_endday='.urlencode((string) ($search_date_endday)); } if ($search_date_endmonth) { - $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); + $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth)); } if ($search_date_endyear) { - $param .= '&search_date_endyear='.urlencode($search_date_endyear); + $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear)); } if ($search_invoice) { $param .= '&search_invoice='.urlencode($search_invoice); diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index 11602a58f1f..60f08f4992d 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -279,22 +279,22 @@ if ($result) { $param .= "&search_vat=".urlencode($search_vat); } if ($search_date_startday) { - $param .= '&search_date_startday='.urlencode($search_date_startday); + $param .= '&search_date_startday='.urlencode((string) ($search_date_startday)); } if ($search_date_startmonth) { - $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); + $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth)); } if ($search_date_startyear) { - $param .= '&search_date_startyear='.urlencode($search_date_startyear); + $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear)); } if ($search_date_endday) { - $param .= '&search_date_endday='.urlencode($search_date_endday); + $param .= '&search_date_endday='.urlencode((string) ($search_date_endday)); } if ($search_date_endmonth) { - $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); + $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth)); } if ($search_date_endyear) { - $param .= '&search_date_endyear='.urlencode($search_date_endyear); + $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear)); } print ''."\n"; diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index 73d9dd96cb1..9bb346e153a 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -327,22 +327,22 @@ if ($result) { $param .= '&search_lineid='.urlencode($search_lineid); } if ($search_date_startday) { - $param .= '&search_date_startday='.urlencode($search_date_startday); + $param .= '&search_date_startday='.urlencode((string) ($search_date_startday)); } if ($search_date_startmonth) { - $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); + $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth)); } if ($search_date_startyear) { - $param .= '&search_date_startyear='.urlencode($search_date_startyear); + $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear)); } if ($search_date_endday) { - $param .= '&search_date_endday='.urlencode($search_date_endday); + $param .= '&search_date_endday='.urlencode((string) ($search_date_endday)); } if ($search_date_endmonth) { - $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); + $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth)); } if ($search_date_endyear) { - $param .= '&search_date_endyear='.urlencode($search_date_endyear); + $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear)); } if ($search_expensereport) { $param .= '&search_expensereport='.urlencode($search_expensereport); diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 09c7aca7af7..16d1d3d0202 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -359,22 +359,22 @@ if ($result) { $param .= "&search_vat=".urlencode($search_vat); } if ($search_date_startday) { - $param .= '&search_date_startday='.urlencode($search_date_startday); + $param .= '&search_date_startday='.urlencode((string) ($search_date_startday)); } if ($search_date_startmonth) { - $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); + $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth)); } if ($search_date_startyear) { - $param .= '&search_date_startyear='.urlencode($search_date_startyear); + $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear)); } if ($search_date_endday) { - $param .= '&search_date_endday='.urlencode($search_date_endday); + $param .= '&search_date_endday='.urlencode((string) ($search_date_endday)); } if ($search_date_endmonth) { - $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); + $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth)); } if ($search_date_endyear) { - $param .= '&search_date_endyear='.urlencode($search_date_endyear); + $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear)); } if ($search_country) { $param .= "&search_country=".urlencode($search_country); diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index db16688ff31..b086cdd1914 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -403,25 +403,25 @@ if ($result) { $param .= '&search_societe='.urlencode($search_societe); } if ($search_lineid) { - $param .= '&search_lineid='.urlencode($search_lineid); + $param .= '&search_lineid='.urlencode((string) ($search_lineid)); } if ($search_date_startday) { - $param .= '&search_date_startday='.urlencode($search_date_startday); + $param .= '&search_date_startday='.urlencode((string) ($search_date_startday)); } if ($search_date_startmonth) { - $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); + $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth)); } if ($search_date_startyear) { - $param .= '&search_date_startyear='.urlencode($search_date_startyear); + $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear)); } if ($search_date_endday) { - $param .= '&search_date_endday='.urlencode($search_date_endday); + $param .= '&search_date_endday='.urlencode((string) ($search_date_endday)); } if ($search_date_endmonth) { - $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); + $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth)); } if ($search_date_endyear) { - $param .= '&search_date_endyear='.urlencode($search_date_endyear); + $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear)); } if ($search_invoice) { $param .= '&search_invoice='.urlencode($search_invoice); diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index b9370bf20c8..e8575c36337 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -8,6 +8,7 @@ * Copyright (C) 2015-2018 Alexandre Spangaro * Copyright (C) 2018-2022 Frédéric France * Copyright (C) 2021 Waël Almoman + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -699,11 +700,7 @@ if (empty($reshook)) { } } else { $error++; - if ($object->error) { - setEventMessages($object->error, $object->errors, 'errors'); - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } + setEventMessages($object->error, $object->errors, 'errors'); } if (!$error) { @@ -771,11 +768,7 @@ if (empty($reshook)) { } else { $error++; - if ($object->error) { - setEventMessages($object->error, $object->errors, 'errors'); - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } + setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } } @@ -842,11 +835,7 @@ if (empty($reshook)) { } else { $error++; - if ($object->error) { - setEventMessages($object->error, $object->errors, 'errors'); - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } + setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } } diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 531c089e1f1..1937924df3b 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -15,6 +15,7 @@ * Copyright (C) 2020 Josep Lluís Amador * Copyright (C) 2021 Waël Almoman * Copyright (C) 2021 Philippe Grand + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -315,7 +316,7 @@ class Adherent extends CommonObject /** - * @var array fields + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 10), @@ -323,14 +324,14 @@ class Adherent extends CommonObject 'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 15, 'index' => 1), 'ref_ext' => array('type' => 'varchar(128)', 'label' => 'Ref ext', 'enabled' => 1, 'visible' => 0, 'position' => 20), 'civility' => array('type' => 'varchar(6)', 'label' => 'Civility', 'enabled' => 1, 'visible' => -1, 'position' => 25), - 'lastname' => array('type' => 'varchar(50)', 'label' => 'Lastname', 'enabled' => 1, 'visible' => 1, 'position' => 30, 'showoncombobox'=>1), - 'firstname' => array('type' => 'varchar(50)', 'label' => 'Firstname', 'enabled' => 1, 'visible' => 1, 'position' => 35, 'showoncombobox'=>1), + 'lastname' => array('type' => 'varchar(50)', 'label' => 'Lastname', 'enabled' => 1, 'visible' => 1, 'position' => 30, 'showoncombobox' => 1), + 'firstname' => array('type' => 'varchar(50)', 'label' => 'Firstname', 'enabled' => 1, 'visible' => 1, 'position' => 35, 'showoncombobox' => 1), 'login' => array('type' => 'varchar(50)', 'label' => 'Login', 'enabled' => 1, 'visible' => 1, 'position' => 40), 'pass' => array('type' => 'varchar(50)', 'label' => 'Pass', 'enabled' => 1, 'visible' => -1, 'position' => 45), 'pass_crypted' => array('type' => 'varchar(128)', 'label' => 'Pass crypted', 'enabled' => 1, 'visible' => -1, 'position' => 50), 'morphy' => array('type' => 'varchar(3)', 'label' => 'MemberNature', 'enabled' => 1, 'visible' => 1, 'notnull' => 1, 'position' => 55), 'fk_adherent_type' => array('type' => 'integer', 'label' => 'Fk adherent type', 'enabled' => 1, 'visible' => 1, 'notnull' => 1, 'position' => 60), - 'societe' => array('type' => 'varchar(128)', 'label' => 'Societe', 'enabled' => 1, 'visible' => 1, 'position' => 65, 'showoncombobox'=>2), + 'societe' => array('type' => 'varchar(128)', 'label' => 'Societe', 'enabled' => 1, 'visible' => 1, 'position' => 65, 'showoncombobox' => 2), 'fk_soc' => array('type' => 'integer:Societe:societe/class/societe.class.php', 'label' => 'ThirdParty', 'enabled' => 1, 'visible' => 1, 'position' => 70), 'address' => array('type' => 'text', 'label' => 'Address', 'enabled' => 1, 'visible' => -1, 'position' => 75), 'zip' => array('type' => 'varchar(10)', 'label' => 'Zip', 'enabled' => 1, 'visible' => -1, 'position' => 80), @@ -341,14 +342,14 @@ class Adherent extends CommonObject 'phone_perso' => array('type' => 'varchar(30)', 'label' => 'Phone perso', 'enabled' => 1, 'visible' => -1, 'position' => 120), 'phone_mobile' => array('type' => 'varchar(30)', 'label' => 'Phone mobile', 'enabled' => 1, 'visible' => -1, 'position' => 125), 'email' => array('type' => 'varchar(255)', 'label' => 'Email', 'enabled' => 1, 'visible' => 1, 'position' => 126), - 'url' =>array('type'=>'varchar(255)', 'label'=>'Url', 'enabled'=>1, 'visible'=>-1, 'position'=>127), + 'url' => array('type' => 'varchar(255)', 'label' => 'Url', 'enabled' => 1, 'visible' => -1, 'position' => 127), 'socialnetworks' => array('type' => 'text', 'label' => 'Socialnetworks', 'enabled' => 1, 'visible' => -1, 'position' => 128), 'birth' => array('type' => 'date', 'label' => 'DateOfBirth', 'enabled' => 1, 'visible' => -1, 'position' => 130), 'gender' => array('type' => 'varchar(10)', 'label' => 'Gender', 'enabled' => 1, 'visible' => -1, 'position' => 132), 'photo' => array('type' => 'varchar(255)', 'label' => 'Photo', 'enabled' => 1, 'visible' => -1, 'position' => 135), 'public' => array('type' => 'smallint(6)', 'label' => 'Public', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 145), 'datefin' => array('type' => 'datetime', 'label' => 'DateEnd', 'enabled' => 1, 'visible' => 1, 'position' => 150), - 'default_lang' =>array('type'=>'varchar(6)', 'label'=>'Default lang', 'enabled'=>1, 'visible'=>-1, 'position'=> 153), + 'default_lang' => array('type' => 'varchar(6)', 'label' => 'Default lang', 'enabled' => 1, 'visible' => -1, 'position' => 153), 'note_public' => array('type' => 'text', 'label' => 'NotePublic', 'enabled' => 1, 'visible' => 0, 'position' => 155), 'note_private' => array('type' => 'text', 'label' => 'NotePrivate', 'enabled' => 1, 'visible' => 0, 'position' => 160), 'datevalid' => array('type' => 'datetime', 'label' => 'DateValidation', 'enabled' => 1, 'visible' => -1, 'position' => 165), @@ -490,7 +491,7 @@ class Adherent extends CommonObject */ public function makeSubstitution($text) { - global $conf, $langs; + global $langs; $birthday = dol_print_date($this->birth, 'day'); @@ -2421,7 +2422,7 @@ class Adherent extends CommonObject } global $action; $hookmanager->initHooks(array($this->element . 'dao')); - $parameters = array('id'=>$this->id, 'getnomurl' => &$result); + $parameters = array('id' => $this->id, 'getnomurl' => &$result); $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) { $result = $hookmanager->resPrint; @@ -3276,7 +3277,7 @@ class Adherent extends CommonObject $return .= '
'; $return .= ''; if (property_exists($this, 'photo') || !empty($this->photo)) { - $return.= Form::showphoto('memberphoto', $this, 0, 60, 0, 'photokanban photoref photowithmargin photologintooltip', 'small', 0, 1); + $return .= Form::showphoto('memberphoto', $this, 0, 60, 0, 'photokanban photoref photowithmargin photologintooltip', 'small', 0, 1); } else { $return .= img_picto('', 'user'); } diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 889f1212547..941a685d326 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2017 Regis Houssin * Copyright (C) 2020 Thibault FOUCART * Copyright (C) 2020 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -535,8 +536,6 @@ class Members extends DolibarrApi */ public function getSubscriptions($id) { - $obj_ret = array(); - if (!DolibarrApiAccess::$user->hasRight('adherent', 'cotisation', 'lire')) { throw new RestException(403); } diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 111cb2c04ea..40aa0ab512a 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2006-2015 Laurent Destailleur + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -103,21 +104,21 @@ class Subscription extends CommonObject public $fk_bank; /** - * @var array Array with all fields into database and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>15), - 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>20), - 'fk_adherent' =>array('type'=>'integer', 'label'=>'Member', 'enabled'=>1, 'visible'=>-1, 'position'=>25), - 'dateadh' =>array('type'=>'datetime', 'label'=>'DateSubscription', 'enabled'=>1, 'visible'=>-1, 'position'=>30), - 'datef' =>array('type'=>'datetime', 'label'=>'DateEndSubscription', 'enabled'=>1, 'visible'=>-1, 'position'=>35), - 'subscription' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>-1, 'position'=>40, 'isameasure'=>1), - 'fk_bank' =>array('type'=>'integer', 'label'=>'BankId', 'enabled'=>1, 'visible'=>-1, 'position'=>45), - 'note' =>array('type'=>'html', 'label'=>'Note', 'enabled'=>1, 'visible'=>-1, 'position'=>50), - 'fk_type' =>array('type'=>'integer', 'label'=>'MemberType', 'enabled'=>1, 'visible'=>-1, 'position'=>55), - 'fk_user_creat' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>60), - 'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>65), + 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 10), + 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 15), + 'datec' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'visible' => -1, 'position' => 20), + 'fk_adherent' => array('type' => 'integer', 'label' => 'Member', 'enabled' => 1, 'visible' => -1, 'position' => 25), + 'dateadh' => array('type' => 'datetime', 'label' => 'DateSubscription', 'enabled' => 1, 'visible' => -1, 'position' => 30), + 'datef' => array('type' => 'datetime', 'label' => 'DateEndSubscription', 'enabled' => 1, 'visible' => -1, 'position' => 35), + 'subscription' => array('type' => 'double(24,8)', 'label' => 'Amount', 'enabled' => 1, 'visible' => -1, 'position' => 40, 'isameasure' => 1), + 'fk_bank' => array('type' => 'integer', 'label' => 'BankId', 'enabled' => 1, 'visible' => -1, 'position' => 45), + 'note' => array('type' => 'html', 'label' => 'Note', 'enabled' => 1, 'visible' => -1, 'position' => 50), + 'fk_type' => array('type' => 'integer', 'label' => 'MemberType', 'enabled' => 1, 'visible' => -1, 'position' => 55), + 'fk_user_creat' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserAuthor', 'enabled' => 1, 'visible' => -2, 'position' => 60), + 'fk_user_valid' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserValidation', 'enabled' => 1, 'visible' => -1, 'position' => 65), ); @@ -295,7 +296,7 @@ class Subscription extends CommonObject $result = $member->update_end_date($user); if (!$error && !$notrigger) { - $this->context = array('member'=>$member); + $this->context = array('member' => $member); // Call triggers $result = $this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user); if ($result < 0) { diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php index edfa8adbb2f..f94cc476321 100644 --- a/htdocs/adherents/ldap.php +++ b/htdocs/adherents/ldap.php @@ -120,12 +120,13 @@ print '
'; print ''; // Login -print ''; +print ''; // If there is a link to the unencrypted password, we show the value in database here so we can compare because it is shown nowhere else +// This is for very old situation. Password are now encrypted and $object->pass is empty. if (getDolGlobalString('LDAP_MEMBER_FIELD_PASSWORD')) { print ''; - print ''; + print ''; print "\n"; } diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 7ce26e570c7..e8d85f21c76 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -670,7 +670,7 @@ if ($search_email) { $param .= "&search_email=".urlencode($search_email); } if ($search_categ > 0 || $search_categ == -2) { - $param .= "&search_categ=".urlencode($search_categ); + $param .= "&search_categ=".urlencode((string) ($search_categ)); } if ($search_company) { $param .= "&search_company=".urlencode($search_company); diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index efd6c1b1c47..3a99f379502 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -89,20 +89,20 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen $fieldstosearchall = array( ); $arrayfields = array( - 'd.ref'=>array('label'=>"Ref", 'checked'=>1), - 'd.fk_type'=>array('label'=>"Type", 'checked'=>1), - 'd.lastname'=>array('label'=>"Lastname", 'checked'=>1), - 'd.firstname'=>array('label'=>"Firstname", 'checked'=>1), - 'd.login'=>array('label'=>"Login", 'checked'=>1), - 't.libelle'=>array('label'=>"Label", 'checked'=>1), - 'd.bank'=>array('label'=>"BankAccount", 'checked'=>1, 'enabled'=>(isModEnabled('bank'))), + 'd.ref' => array('label' => "Ref", 'checked' => 1), + 'd.fk_type' => array('label' => "Type", 'checked' => 1), + 'd.lastname' => array('label' => "Lastname", 'checked' => 1), + 'd.firstname' => array('label' => "Firstname", 'checked' => 1), + 'd.login' => array('label' => "Login", 'checked' => 1), + 't.libelle' => array('label' => "Label", 'checked' => 1), + 'd.bank' => array('label' => "BankAccount", 'checked' => 1, 'enabled' => (isModEnabled('bank'))), /*'d.note_public'=>array('label'=>"NotePublic", 'checked'=>0), 'd.note_private'=>array('label'=>"NotePrivate", 'checked'=>0),*/ - 'c.dateadh'=>array('label'=>"DateSubscription", 'checked'=>1, 'position'=>100), - 'c.datef'=>array('label'=>"EndSubscription", 'checked'=>1, 'position'=>101), - 'd.amount'=>array('label'=>"Amount", 'checked'=>1, 'position'=>102), - 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), - 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), + 'c.dateadh' => array('label' => "DateSubscription", 'checked' => 1, 'position' => 100), + 'c.datef' => array('label' => "EndSubscription", 'checked' => 1, 'position' => 101), + 'd.amount' => array('label' => "Amount", 'checked' => 1, 'position' => 102), + 'c.datec' => array('label' => "DateCreation", 'checked' => 0, 'position' => 500), + 'c.tms' => array('label' => "DateModificationShort", 'checked' => 0, 'position' => 500), // 'd.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000) ); @@ -124,7 +124,7 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa $massaction = ''; } -$parameters = array('socid'=>isset($socid) ? $socid : null); +$parameters = array('socid' => isset($socid) ? $socid : null); $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'); @@ -298,7 +298,7 @@ $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; if (!empty($mode)) { - $param .='&mode='.urlencode($mode); + $param .= '&mode='.urlencode($mode); } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); @@ -322,7 +322,7 @@ if ($search_login) { $param .= "&search_login=".urlencode($search_login); } if ($search_account) { - $param .= "&search_account=".urlencode($search_account); + $param .= "&search_account=".urlencode((string) ($search_account)); } if ($search_amount) { $param .= "&search_amount=".urlencode($search_amount); @@ -366,8 +366,8 @@ print ''; print ''; $newcardbutton = ''; -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition')); if ($user->hasRight('adherent', 'cotisation', 'creer')) { $newcardbutton .= dolGetButtonTitleSeparator(); $newcardbutton .= dolGetButtonTitle($langs->trans('NewSubscription'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/list.php?status=-1,1'); @@ -492,7 +492,7 @@ if (!empty($arrayfields['d.amount']['checked'])) { 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; // Date creation @@ -571,7 +571,7 @@ if (!empty($arrayfields['d.amount']['checked'])) { 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; if (!empty($arrayfields['c.datec']['checked'])) { @@ -647,7 +647,7 @@ while ($i < $imaxinloop) { $accountstatic->fetch($obj->fk_account); } // Output Kanban - print $subscription->getKanbanView('', array('selected' => in_array($object->id, $arrayofselected), 'adherent_type' => $adht, 'member' => $adherent, 'bank'=>($obj->fk_account > 0 ? $accountstatic : null))); + print $subscription->getKanbanView('', array('selected' => in_array($object->id, $arrayofselected), 'adherent_type' => $adht, 'member' => $adherent, 'bank' => ($obj->fk_account > 0 ? $accountstatic : null))); if ($i == ($imaxinloop - 1)) { print ''; print ''; @@ -770,7 +770,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, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation @@ -829,7 +829,7 @@ if ($num == 0) { $db->free($resql); -$parameters = array('arrayfields'=>$arrayfields, 'sql' => $sql); +$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; diff --git a/htdocs/adherents/tpl/linkedobjectblock.tpl.php b/htdocs/adherents/tpl/linkedobjectblock.tpl.php index d4efa349202..5582c60e30f 100644 --- a/htdocs/adherents/tpl/linkedobjectblock.tpl.php +++ b/htdocs/adherents/tpl/linkedobjectblock.tpl.php @@ -2,6 +2,7 @@ /* Copyright (C) 2010-2011 Regis Houssin * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2014 Marcos García + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -40,7 +41,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { echo ''; echo ''; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 738ee68c23b..df36f5c95da 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -190,7 +190,7 @@ if ($action == 'update' && $user->hasRight('adherent', 'configurer')) { $object->oldcopy = dol_clone($object, 2); - $object->label= trim($label); + $object->label = trim($label); $object->morphy = trim($morphy); $object->status = (int) $status; $object->subscription = (int) $subscription; @@ -277,8 +277,8 @@ if (!$rowid && $action != 'create' && $action != 'edit') { $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')); if ($user->hasRight('adherent', 'configurer')) { $newcardbutton .= dolGetButtonTitleSeparator(); @@ -379,9 +379,9 @@ if (!$rowid && $action != 'create' && $action != 'edit') { if ($objp->duration) { $duration_value = intval($objp->duration); if ($duration_value > 1) { - $dur = array("i"=>$langs->trans("Minutes"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); + $dur = array("i" => $langs->trans("Minutes"), "h" => $langs->trans("Hours"), "d" => $langs->trans("Days"), "w" => $langs->trans("Weeks"), "m" => $langs->trans("Months"), "y" => $langs->trans("Years")); } else { - $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); + $dur = array("i" => $langs->trans("Minute"), "h" => $langs->trans("Hour"), "d" => $langs->trans("Day"), "w" => $langs->trans("Week"), "m" => $langs->trans("Month"), "y" => $langs->trans("Year")); } $unit = preg_replace("/[^a-zA-Z]+/", "", $objp->duration); print max(1, $duration_value).' '.$dur[$unit]; @@ -441,7 +441,7 @@ if ($action == 'create') { print ''; print ''; // Morphy @@ -548,9 +548,9 @@ if ($rowid > 0) { print ''; @@ -592,7 +592,7 @@ if ($rowid > 0) { $morphy = ''; } - if ($user->hasRight('adherent', 'configurer')&& !empty($object->status)) { + if ($user->hasRight('adherent', 'configurer') && !empty($object->status)) { print ''; } else { print ''; @@ -712,7 +712,7 @@ if ($rowid > 0) { $titre .= " (".$membertype->label.")"; } - $param = "&rowid=".urlencode($object->id); + $param = "&rowid=".urlencode((string) ($object->id)); if (!empty($mode)) { $param .= '&mode='.urlencode($mode); } @@ -918,7 +918,7 @@ if ($rowid > 0) { } if ($i == 0) { - print ''; + print ''; } print "
'.$langs->trans("Login").' / '.$langs->trans("Id").''.$object->login.' 
'.$langs->trans("Login").' / '.$langs->trans("Id").''.dol_escape_htmltag($object->login).' 
'.$langs->trans("LDAPFieldPasswordNotCrypted").''.$object->pass.''.dol_escape_htmltag($object->pass).'
'.dol_print_date($objectlink->dateh, 'day').''; if ($user->hasRight('adherent', 'lire')) { - $total = $total + $objectlink->amount; + $total += $objectlink->amount; echo price($objectlink->amount); } echo '
'.$langs->trans("Label").'
'.$langs->trans("Status").''; - print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100'); + print $form->selectarray('status', array('0' => $langs->trans('ActivityCeased'), '1' => $langs->trans('InActivity')), 1, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100'); print '
'.$langs->trans("Duration").''.$object->duration_value.' '; if ($object->duration_value > 1) { - $dur = array("i"=>$langs->trans("Minutes"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); + $dur = array("i" => $langs->trans("Minutes"), "h" => $langs->trans("Hours"), "d" => $langs->trans("Days"), "w" => $langs->trans("Weeks"), "m" => $langs->trans("Months"), "y" => $langs->trans("Years")); } elseif ($object->duration_value > 0) { - $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); + $dur = array("i" => $langs->trans("Minute"), "h" => $langs->trans("Hour"), "d" => $langs->trans("Day"), "w" => $langs->trans("Week"), "m" => $langs->trans("Month"), "y" => $langs->trans("Year")); } print(!empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) : '')." "; print '
'.$langs->trans("None").'
'.$langs->trans("None").'
\n"; @@ -956,7 +956,7 @@ if ($rowid > 0) { print ''.$langs->trans("Label").''; print ''.$langs->trans("Status").''; - print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->status, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100'); + print $form->selectarray('status', array('0' => $langs->trans('ActivityCeased'), '1' => $langs->trans('InActivity')), $object->status, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100'); print ''; // Morphy diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index 772bc0efa6a..dcc7cdec446 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -5,6 +5,7 @@ * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016 Charlie Benke * Copyright (C) 2017 Open-DSI + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -89,7 +90,7 @@ if ($action == 'set') { dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity); $defaultValues = new DefaultValues($db); - $result = $defaultValues->fetchAll('', '', 0, 0, array('t.page'=>'comm/action/card.php', 't.param'=>'complete', 't.user_id'=>'0', 't.type'=>'createform', 't.entity'=>$conf->entity)); + $result = $defaultValues->fetchAll('', '', 0, 0, array('t.page' => 'comm/action/card.php', 't.param' => 'complete', 't.user_id' => '0', 't.type' => 'createform', 't.entity' => $conf->entity)); if (!is_array($result) && $result < 0) { setEventMessages($defaultValues->error, $defaultValues->errors, 'errors'); } elseif (count($result) > 0) { @@ -123,18 +124,16 @@ if ($action == 'set') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db, $commande); @@ -334,7 +333,7 @@ $htmltext = $langs->trans("ThisValueCanOverwrittenOnUserLevel", $langs->transnoe print ''.$form->textwithpicto($langs->trans("AGENDA_DEFAULT_VIEW"), $htmltext).''."\n"; print ' '."\n"; print ''."\n"; -$tmplist = array(''=>' ', 'show_list'=>$langs->trans("ViewList"), 'show_month'=>$langs->trans("ViewCal"), 'show_week'=>$langs->trans("ViewWeek"), 'show_day'=>$langs->trans("ViewDay"), 'show_peruser'=>$langs->trans("ViewPerUser")); +$tmplist = array('' => ' ', 'show_list' => $langs->trans("ViewList"), 'show_month' => $langs->trans("ViewCal"), 'show_week' => $langs->trans("ViewWeek"), 'show_day' => $langs->trans("ViewDay"), 'show_peruser' => $langs->trans("ViewPerUser")); print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, getDolGlobalString('AGENDA_DEFAULT_VIEW')); print ''."\n"; @@ -369,7 +368,7 @@ print ' '."\n"; print ''."\n"; $defval = 'na'; $defaultValues = new DefaultValues($db); -$result = $defaultValues->fetchAll('', '', 0, 0, array('t.page'=>'comm/action/card.php', 't.param'=>'complete', 't.user_id'=>'0', 't.type'=>'createform', 't.entity'=>$conf->entity)); +$result = $defaultValues->fetchAll('', '', 0, 0, array('t.page' => 'comm/action/card.php', 't.param' => 'complete', 't.user_id' => '0', 't.type' => 'createform', 't.entity' => $conf->entity)); if (!is_array($result) && $result < 0) { setEventMessages($defaultValues->error, $defaultValues->errors, 'errors'); } elseif (count($result) > 0) { diff --git a/htdocs/admin/agenda_reminder.php b/htdocs/admin/agenda_reminder.php index fa4dd0df9a1..cdc6a2b8647 100644 --- a/htdocs/admin/agenda_reminder.php +++ b/htdocs/admin/agenda_reminder.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -86,18 +87,16 @@ if ($action == 'set') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db, $commande); diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index f8ca472744f..865b54f5878 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -3,6 +3,7 @@ * Copyright (C) 2010-2016 Juanjo Menent * Copyright (C) 2013-2018 Philippe Grand * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -131,18 +132,16 @@ if ($action == 'specimen') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/bank/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db); diff --git a/htdocs/admin/bom.php b/htdocs/admin/bom.php index 319e5b71789..ebfa4e6772a 100644 --- a/htdocs/admin/bom.php +++ b/htdocs/admin/bom.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -76,18 +77,16 @@ if ($action == 'updateMask') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/bom/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db); diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 62d11335384..af9db12a62b 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -10,6 +10,7 @@ * Copyright (C) 2011-2016 Philippe Grand * Copyright (C) 2013 Florian Henry * Copyright (C) 2021 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -86,18 +87,16 @@ if ($action == 'updateMask') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db); diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index e30a2b8d0c5..89e09907a6e 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -1,6 +1,7 @@ * Copyright (C) 2011-2018 Philippe Grand + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -82,18 +83,16 @@ if ($action == 'updateMask') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/contract/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db); diff --git a/htdocs/admin/delivery.php b/htdocs/admin/delivery.php index 0e6339c36f8..2c66f284c7d 100644 --- a/htdocs/admin/delivery.php +++ b/htdocs/admin/delivery.php @@ -8,6 +8,7 @@ * Copyright (C) 2011-2013 Juanjo Menent * Copyright (C) 2011-2018 Philippe Grand * Copyright (C) 2015 Claudio Aschieri + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -58,7 +59,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; // Shipment note -if (isModEnabled('delivery_note') && !getDolGlobalString('MAIN_SUBMODULE_EXPEDITION')) { +if (isModEnabled('shipping') && !getDolGlobalString('MAIN_SUBMODULE_EXPEDITION')) { // This option should always be set to on when module is on. dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity); } @@ -131,18 +132,16 @@ if ($action == 'specimen') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/delivery/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db); diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 0ca6a21bfe2..d895854ab2c 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -507,7 +507,7 @@ $tabcond[14] = (isModEnabled("product") && (isModEnabled('ecotax') || getDolGlob $tabcond[15] = true; $tabcond[16] = (isModEnabled("societe") && !getDolGlobalString('SOCIETE_DISABLE_PROSPECTS')); $tabcond[17] = (isModEnabled('deplacement') || isModEnabled('expensereport')); -$tabcond[18] = isModEnabled("delivery_note") || isModEnabled("reception"); +$tabcond[18] = isModEnabled("shipping") || isModEnabled("reception"); $tabcond[19] = isModEnabled("societe"); $tabcond[20] = isModEnabled("supplier_order"); $tabcond[21] = isModEnabled("propal"); @@ -1227,9 +1227,9 @@ if ($id == 7 && GETPOST('from') == 'accountancy') { $titlepicto = 'accountancy'; } -$param = '&id='.urlencode($id); +$param = '&id='.urlencode((string) ($id)); if ($search_country_id || GETPOSTISSET('page') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) { - $param .= '&search_country_id='.urlencode($search_country_id ? $search_country_id : -1); + $param .= '&search_country_id='.urlencode((string) ($search_country_id ? $search_country_id : -1)); } if ($search_code != '') { $param .= '&search_code='.urlencode($search_code); diff --git a/htdocs/admin/dolistore/class/dolistore.class.php b/htdocs/admin/dolistore/class/dolistore.class.php index 2fee52df32b..ac2e3c2ea46 100644 --- a/htdocs/admin/dolistore/class/dolistore.class.php +++ b/htdocs/admin/dolistore/class/dolistore.class.php @@ -68,7 +68,7 @@ class Dolistore $langtmp = explode('_', $langs->defaultlang); $lang = $langtmp[0]; - $lang_array = array('en'=>1, 'fr'=>2, 'es'=>3, 'it'=>4, 'de'=>5); // Into table ps_lang of Prestashop - 1 + $lang_array = array('en' => 1, 'fr' => 2, 'es' => 3, 'it' => 4, 'de' => 5); // Into table ps_lang of Prestashop - 1 if (!in_array($lang, array_keys($lang_array))) { $lang = 'en'; } @@ -270,7 +270,7 @@ class Dolistore // add image or default ? if ($product->id_default_image != '') { - $image_url = DOL_URL_ROOT.'/admin/dolistore/ajax/image.php?id_product='.urlencode(((int) $product->id)).'&id_image='.urlencode(((int) $product->id_default_image)); + $image_url = DOL_URL_ROOT.'/admin/dolistore/ajax/image.php?id_product='.urlencode((string) (((int) $product->id))).'&id_image='.urlencode((string) (((int) $product->id_default_image))); $images = ''; $images .= ''; } else { diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index 7016986b0bd..983a93a9c02 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 MDW * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -47,20 +48,20 @@ $scandir = GETPOST('scan_dir', 'alpha'); $type = 'myobject'; $arrayofparameters = array( - 'EVENTORGANIZATION_TASK_LABEL'=>array('type'=>'textarea','enabled'=>1), - 'EVENTORGANIZATION_CATEG_THIRDPARTY_CONF'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), - 'EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), - 'EVENTORGANIZATION_FILTERATTENDEES_CAT'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), - 'EVENTORGANIZATION_FILTERATTENDEES_TYPE'=>array('type'=>'thirdparty_type:', 'enabled'=>1), - 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_CONF'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1), - 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_BOOTH'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1), - 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1), - 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1), + 'EVENTORGANIZATION_TASK_LABEL' => array('type' => 'textarea','enabled' => 1), + 'EVENTORGANIZATION_CATEG_THIRDPARTY_CONF' => array('type' => 'category:'.Categorie::TYPE_CUSTOMER, 'enabled' => 1), + 'EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH' => array('type' => 'category:'.Categorie::TYPE_CUSTOMER, 'enabled' => 1), + 'EVENTORGANIZATION_FILTERATTENDEES_CAT' => array('type' => 'category:'.Categorie::TYPE_CUSTOMER, 'enabled' => 1), + 'EVENTORGANIZATION_FILTERATTENDEES_TYPE' => array('type' => 'thirdparty_type:', 'enabled' => 1), + 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_CONF' => array('type' => 'emailtemplate:conferenceorbooth', 'enabled' => 1), + 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_BOOTH' => array('type' => 'emailtemplate:conferenceorbooth', 'enabled' => 1), + 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH' => array('type' => 'emailtemplate:conferenceorbooth', 'enabled' => 1), + 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT' => array('type' => 'emailtemplate:conferenceorbooth', 'enabled' => 1), //'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_SPEAKER'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1), //'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1), - 'SERVICE_BOOTH_LOCATION'=>array('type'=>'product', 'enabled'=>1), - 'SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION'=>array('type'=>'product', 'enabled'=>1), - 'EVENTORGANIZATION_SECUREKEY'=>array('type'=>'securekey', 'enabled'=>1), + 'SERVICE_BOOTH_LOCATION' => array('type' => 'product', 'enabled' => 1), + 'SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION' => array('type' => 'product', 'enabled' => 1), + 'EVENTORGANIZATION_SECUREKEY' => array('type' => 'securekey', 'enabled' => 1), ); $error = 0; @@ -80,7 +81,7 @@ if (empty($user->admin)) { */ if ($cancel) { - $action =''; + $action = ''; } include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; @@ -111,18 +112,16 @@ if ($action == 'updateMask') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/eventorganization/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db); @@ -218,7 +217,7 @@ if ($action == 'edit') { print ''.$langs->trans("Parameter").''.$langs->trans("Value").''; foreach ($arrayofparameters as $constname => $val) { - if ($val['enabled']==1) { + if ($val['enabled'] == 1) { $setupnotempty++; print ''; $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : ''); @@ -230,7 +229,7 @@ if ($action == 'edit') { print '\n"; - } elseif ($val['type']== 'html') { + } elseif ($val['type'] == 'html') { require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%'); $doleditor->Create(); @@ -300,7 +299,7 @@ if ($action == 'edit') { print ''.$langs->trans("Parameter").''.$langs->trans("Value").''; foreach ($arrayofparameters as $constname => $val) { - if ($val['enabled']==1) { + if ($val['enabled'] == 1) { $setupnotempty++; print ''; print ''; @@ -311,7 +310,7 @@ if ($action == 'edit') { if ($val['type'] == 'textarea') { print dol_nl2br(getDolGlobalString($constname)); - } elseif ($val['type']== 'html') { + } elseif ($val['type'] == 'html') { print getDolGlobalString($constname); } elseif ($val['type'] == 'yesno') { print ajax_constantonoff($constname); @@ -348,13 +347,13 @@ if ($action == 'edit') { print '
    ' . implode(' ', $toprint) . '
'; } } elseif (preg_match('/thirdparty_type/', $val['type'])) { - if (getDolGlobalString($constname)==2) { + if (getDolGlobalString($constname) == 2) { print $langs->trans("Prospect"); - } elseif (getDolGlobalString($constname)==3) { + } elseif (getDolGlobalString($constname) == 3) { print $langs->trans("ProspectCustomer"); - } elseif (getDolGlobalString($constname)==1) { + } elseif (getDolGlobalString($constname) == 1) { print $langs->trans("Customer"); - } elseif (getDolGlobalString($constname)==0) { + } elseif (getDolGlobalString($constname) == 0) { print $langs->trans("NorProspectNorCustomer"); } } elseif ($val['type'] == 'product') { diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index d054f3bfa5e..082d2a39741 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -7,6 +7,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011-2012 Juanjo Menent * Copyright (C) 2011-2018 Philippe Grand + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -102,18 +103,16 @@ if ($action == 'updateMask') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/expedition/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db); diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index 64cba2b7c6f..d0fa6cfd98b 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -7,6 +7,7 @@ * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2011-2013 Juanjo Menent * Copyright (C) 2011-2022 Philippe Grand + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -83,18 +84,16 @@ if ($action == 'updateMask') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/expensereport/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db); diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php index 5dc257a55d2..d11c3adf4ca 100644 --- a/htdocs/admin/fckeditor.php +++ b/htdocs/admin/fckeditor.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012-2013 Juanjo Menent * Copyright (C) 2019 Christophe Battarel + * Copyright (C) 2024 Frédéric France * * 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 @@ -31,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doleditor.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; // Load translation files required by the page -$langs->loadLangs(array('admin', 'fckeditor')); +$langs->loadLangs(array('admin', 'fckeditor', 'errors')); $action = GETPOST('action', 'aZ09'); // Possible modes are: @@ -221,12 +222,12 @@ if (empty($conf->use_javascript_ajax)) { if ($mode != 'Full_inline') { $uselocalbrowser = true; $readonly = ($mode == 'dolibarr_readonly' ? 1 : 0); - $editor = new DolEditor('formtestfield', isset($conf->global->FCKEDITOR_TEST) ? $conf->global->FCKEDITOR_TEST : 'Test', '', 200, $mode, 'In', true, $uselocalbrowser, 1, 120, 8, $readonly); + $editor = new DolEditor('formtestfield', getDolGlobalString('FCKEDITOR_TEST', 'Test'), '', 200, $mode, 'In', true, $uselocalbrowser, 1, 120, 8, $readonly); $editor->Create(); } else { // CKEditor inline enabled with the contenteditable="true" print '
'; - print $conf->global->FCKEDITOR_TEST; + print getDolGlobalString('FCKEDITOR_TEST'); print '
'; } print $form->buttonsSaveCancel("Save", '', null, 0, 'reposition'); diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index aba9db7f9fd..250d4d9e2cd 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -7,6 +7,7 @@ * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2011-2013 Juanjo Menent * Copyright (C) 2011-2018 Philippe Grand + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -82,18 +83,16 @@ if ($action == 'updateMask') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/fichinter/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db); diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php index 34153e22866..1a8a343ea69 100644 --- a/htdocs/admin/holiday.php +++ b/htdocs/admin/holiday.php @@ -3,6 +3,7 @@ * Copyright (C) 2011-2018 Philippe Grand * Copyright (C) 2018 Charlene Benke * Copyright (C) 2018 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -82,18 +83,16 @@ if ($action == 'updateMask') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/holiday/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db); diff --git a/htdocs/admin/hrm.php b/htdocs/admin/hrm.php index eef0a7a34a8..df883799b2b 100644 --- a/htdocs/admin/hrm.php +++ b/htdocs/admin/hrm.php @@ -4,6 +4,7 @@ * Copyright (C) 2021 Greg Rastklan * Copyright (C) 2021 Jean-Pascal BOUDET * Copyright (C) 2021 Grégory BLEMAND + * Copyright (C) 2024 MDW * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -116,18 +117,16 @@ if ($action == 'update') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/hrm/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db); diff --git a/htdocs/admin/invoice.php b/htdocs/admin/invoice.php index fe290ea6f80..fa0e810f33b 100644 --- a/htdocs/admin/invoice.php +++ b/htdocs/admin/invoice.php @@ -7,6 +7,7 @@ * Copyright (C) 2012-2013 Juanjo Menent * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> * Copyright (C) 2022 Anthony Berton + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -99,18 +100,16 @@ if ($action == 'updateMask') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/facture/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db); @@ -150,8 +149,7 @@ if ($action == 'updateMask') { $ret = addDocumentModel($value, $type, $label, $scandir); } } elseif ($action == 'setmod') { - // TODO Verifier si module numerotation choisi peut etre active - // par appel method canBeActivated + // TODO Check if numbering module chosen can ba activated by calling method canBeActivated() dolibarr_set_const($db, "FACTURE_ADDON", $value, 'chaine', 0, '', $conf->entity); } elseif ($action == 'setribchq') { @@ -619,13 +617,14 @@ if (getDolGlobalString('INVOICE_USE_DEFAULT_DOCUMENT')) { // Hidden conf print ''; print ''; print ''; + print ''; print '
'; print ''; print ''; print ''; print ''; - print ''; + print ''; print "\n"; $listtype = array( @@ -661,6 +660,7 @@ print load_fiche_titre($langs->trans("SuggestedPaymentModesIfNotDefinedInInvoice print ''; print ''; +print ''; print '
'; print '
'.$langs->trans("Type").''.$langs->trans("Name").'
'; @@ -669,17 +669,16 @@ print ''; print ''; -print ''; +print ''; print "\n"; print ''; print ""; print ""; print "
'; print ''; print $langs->trans("PaymentMode").'
".$langs->trans("SuggestPaymentByRIBOnAccount").""; if (isModEnabled('bank')) { - $sql = "SELECT rowid, label"; + $sql = "SELECT rowid, label, clos"; $sql .= " FROM ".MAIN_DB_PREFIX."bank_account"; - $sql .= " WHERE clos = 0"; - $sql .= " AND courant = 1"; + $sql .= " WHERE courant = 1"; $sql .= " AND entity IN (".getEntity('bank_account').")"; $resql = $db->query($sql); if ($resql) { @@ -689,15 +688,19 @@ if (isModEnabled('bank')) { print '"; + print ajax_combobox("rib"); } else { print ''.$langs->trans("NoActiveBankAccountDefined").''; } @@ -737,6 +740,8 @@ if ($resql) { } } print ""; +print ajax_combobox("chq", array(), 0, 0, 'resolve', -2); + print "
"; print '
'; @@ -759,12 +764,13 @@ print "\n"; print ''; print ''; print ''; +print ''; print ''; print $langs->trans("ForceInvoiceDate"); print ''; print $form->selectyesno("forcedate", getDolGlobalInt('FAC_FORCE_DATE_VALIDATION', 0), 1); print ''; -print ''; +print ''; print "\n"; print ''; @@ -779,6 +785,7 @@ $htmltext .= ''; print '
'; print ''; print ''; +print ''; print ''; print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; $variablename = 'INVOICE_FREE_TEXT'; @@ -790,7 +797,7 @@ if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) { print $doleditor->Create(); } print ''; -print ''; +print ''; print "\n"; print '
'; @@ -798,12 +805,13 @@ print ''; print '
'; print ''; print ''; +print ''; print ''; print $form->textwithpicto($langs->trans("WatermarkOnDraftBill"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
'; print ''; print ''; print ''; -print ''; +print ''; print "\n"; print '
'; diff --git a/htdocs/admin/knowledgemanagement.php b/htdocs/admin/knowledgemanagement.php index b8445a0fb9a..1f79f506c89 100644 --- a/htdocs/admin/knowledgemanagement.php +++ b/htdocs/admin/knowledgemanagement.php @@ -1,6 +1,7 @@ * Copyright (C) 2021 SuperAdmin + * Copyright (C) 2024 MDW * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -94,18 +95,16 @@ if ($action == 'updateMask') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/knowledgemanagement/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db); diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index e224b75a986..1856e89f875 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -273,9 +273,9 @@ if ($action == 'edit') { jQuery("#MAIN_MAIL_SMTP_SERVER").show(); jQuery("#MAIN_MAIL_SMTP_PORT").show(); jQuery("#smtp_server_mess").hide(); - jQuery("#smtp_port_mess").hide(); + jQuery("#smtp_port_mess").hide(); jQuery(".smtp_method").show(); - jQuery(".dkim").hide(); + jQuery(".dkim").hide(); jQuery(".smtp_auth_method").show(); } if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\') @@ -302,9 +302,9 @@ if ($action == 'edit') { jQuery("#MAIN_MAIL_SMTP_PORT").show(); jQuery("#smtp_server_mess").hide(); jQuery("#smtp_port_mess").hide(); - jQuery(".smtp_method").show(); + jQuery(".smtp_method").show(); jQuery(".dkim").show(); - jQuery(".smtp_auth_method").show(); + jQuery(".smtp_auth_method").show(); } } function change_smtp_auth_method() { @@ -1109,7 +1109,7 @@ if ($action == 'edit') { $formmail->withtopicreadonly = 0; $formmail->withfile = 2; $formmail->withlayout = 1; - $formmail->withaiprompt = 1; + $formmail->withaiprompt = ($action == 'testhtml' ? 'html' : 'text'); $formmail->withbody = (GETPOSTISSET('message') ? GETPOST('message', 'restricthtml') : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest"))); $formmail->withbodyreadonly = 0; $formmail->withcancel = 1; diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index 0f314ba993a..bcf786ec1b0 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -108,11 +108,11 @@ foreach ($object->fields as $key => $val) { if (!empty($val['visible'])) { $visible = (int) dol_eval($val['visible'], 1); $arrayfields['t.'.$key] = array( - 'label'=>$val['label'], - 'checked'=>(($visible < 0) ? 0 : 1), - 'enabled'=>(abs($visible) != 3 && (int) 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 && (int) dol_eval($val['enabled'], 1)), + 'position' => $val['position'], + 'help' => isset($val['help']) ? $val['help'] : '' ); } } @@ -121,10 +121,10 @@ if (!empty($extrafields->attributes[$object->table_element]['label']) && is_arra foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { $arrayfields["ef.".$key] = array( - 'label'=>$extrafields->attributes[$object->table_element]['label'][$key], - 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), - 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], - 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]) + 'label' => $extrafields->attributes[$object->table_element]['label'][$key], + 'checked' => (($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), + 'position' => $extrafields->attributes[$object->table_element]['pos'][$key], + 'enabled' => (abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]) ); } } @@ -591,7 +591,7 @@ foreach ($object->fields as $key => $val) { // Extra fields 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 @@ -635,7 +635,7 @@ foreach ($object->fields as $key => $val) { 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 @@ -706,7 +706,7 @@ while ($i < $imaxinloop) { $url .= '&limit='.((int) $limit); } if ($page) { - $url .= '&page='.urlencode($page); + $url .= '&page='.urlencode((string) ($page)); } if ($sortfield) { $url .= '&sortfield='.urlencode($sortfield); @@ -783,7 +783,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; @@ -796,7 +796,7 @@ while ($i < $imaxinloop) { $url .= '&limit='.((int) $limit); } if ($page) { - $url .= '&page='.urlencode($page); + $url .= '&page='.urlencode((string) ($page)); } if ($sortfield) { $url .= '&sortfield='.urlencode($sortfield); @@ -845,7 +845,7 @@ if ($num == 0) { $db->free($resql); -$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 830a129b74a..ae1f8bf67d1 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -204,7 +204,7 @@ if (isModEnabled('order') && $user->hasRight('commande', 'lire')) { if (isModEnabled('invoice') && $user->hasRight('facture', 'lire')) { $elementList['facture_send'] = img_picto('', 'bill', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendInvoice')); } -if (isModEnabled("delivery_note")) { +if (isModEnabled("shipping")) { $elementList['shipping_send'] = img_picto('', 'dolly', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendShipment')); } if (isModEnabled("reception")) { diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index dd91a52a04d..e076187e563 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -2,6 +2,7 @@ /* Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2017 Regis Houssin * Copyright (C) 2022 Charlene Benke + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -77,7 +78,7 @@ print ''."\n".''; -$arrayofnatures = array('core'=>$langs->transnoentitiesnoconv("Core"), 'external'=>$langs->transnoentitiesnoconv("External").' - '.$langs->trans("AllPublishers")); +$arrayofnatures = array('core' => $langs->transnoentitiesnoconv("Core"), 'external' => $langs->transnoentitiesnoconv("External").' - '.$langs->trans("AllPublishers")); // Search modules dirs $modulesdir = dolGetModulesDirs(); @@ -116,6 +117,7 @@ foreach ($modulesdir as $dir) { if (class_exists($modName)) { try { $objMod = new $modName($db); + '@phan-var-force DolibarrModules $objMod'; $modNameLoaded[$modName] = $dir; if (!$objMod->numero > 0 && $modName != 'modUser') { @@ -168,6 +170,9 @@ foreach ($modulesdir as $dir) { } else { $familykey = $objMod->family; } + if (empty($familykey) || $familykey === null) { + $familykey = 'other'; + } $moduleposition = ($objMod->module_position ? $objMod->module_position : '50'); if ($moduleposition == '50' && ($objMod->isCoreOrExternalModule() == 'external')) { @@ -235,7 +240,10 @@ foreach ($orders as $tmpkey => $tmpvalue) { } $value = $orders[$key]; $tab = explode('_', $value); -$familyposition = $tab[0]; $familykey = $tab[1]; $module_position = $tab[2]; $numero = $tab[3]; +$familyposition = $tab[0]; +$familykey = $tab[1]; +$module_position = $tab[2]; +$numero = $tab[3]; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 5ce0f2042d7..893523f22da 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -9,6 +9,7 @@ * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2021-2023 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -460,7 +461,7 @@ foreach ($modulesdir as $dir) { $arrayofwarningsext[$modName] = $objMod->warnings_activation_ext; } - $familyposition = (empty($familyinfo[$familykey]['position']) ? 0 : $familyinfo[$familykey]['position']); + $familyposition = (empty($familyinfo[$familykey]['position']) ? '0' : $familyinfo[$familykey]['position']); $listOfOfficialModuleGroups = array('hr', 'technic', 'interface', 'technic', 'portal', 'financial', 'crm', 'base', 'products', 'srm', 'ecm', 'projects', 'other'); if ($external && !in_array($familykey, $listOfOfficialModuleGroups)) { // If module is extern and into a custom group (not into an official predefined one), it must appear at end (custom groups should not be before official groups). @@ -1253,36 +1254,36 @@ if ($mode == 'deploy') { $maxphp = @ini_get('upload_max_filesize'); // In unknown if (preg_match('/k$/i', $maxphp)) { $maxphp = preg_replace('/k$/i', '', $maxphp); - $maxphp = $maxphp * 1; + $maxphp *= 1; } if (preg_match('/m$/i', $maxphp)) { $maxphp = preg_replace('/m$/i', '', $maxphp); - $maxphp = $maxphp * 1024; + $maxphp *= 1024; } if (preg_match('/g$/i', $maxphp)) { $maxphp = preg_replace('/g$/i', '', $maxphp); - $maxphp = $maxphp * 1024 * 1024; + $maxphp *= 1024 * 1024; } if (preg_match('/t$/i', $maxphp)) { $maxphp = preg_replace('/t$/i', '', $maxphp); - $maxphp = $maxphp * 1024 * 1024 * 1024; + $maxphp *= 1024 * 1024 * 1024; } $maxphp2 = @ini_get('post_max_size'); // In unknown if (preg_match('/k$/i', $maxphp2)) { $maxphp2 = preg_replace('/k$/i', '', $maxphp2); - $maxphp2 = $maxphp2 * 1; + $maxphp2 *= 1; } if (preg_match('/m$/i', $maxphp2)) { $maxphp2 = preg_replace('/m$/i', '', $maxphp2); - $maxphp2 = $maxphp2 * 1024; + $maxphp2 *= 1024; } if (preg_match('/g$/i', $maxphp2)) { $maxphp2 = preg_replace('/g$/i', '', $maxphp2); - $maxphp2 = $maxphp2 * 1024 * 1024; + $maxphp2 *= 1024 * 1024; } if (preg_match('/t$/i', $maxphp2)) { $maxphp2 = preg_replace('/t$/i', '', $maxphp2); - $maxphp2 = $maxphp2 * 1024 * 1024 * 1024; + $maxphp2 *= 1024 * 1024 * 1024; } // Now $max and $maxphp and $maxphp2 are in Kb $maxmin = $max; diff --git a/htdocs/admin/mrp.php b/htdocs/admin/mrp.php index 5c2de506880..f616df182c4 100644 --- a/htdocs/admin/mrp.php +++ b/htdocs/admin/mrp.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -77,18 +78,16 @@ if ($action == 'updateMask') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/mrp/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db); diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 6913857a69f..401db58d473 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -7,6 +7,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2011-2013 Juanjo Menent + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -82,18 +83,16 @@ if ($action == 'updateMask') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/propale/doc/pdf_".$modele.".modules.php"); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db); diff --git a/htdocs/admin/reception_setup.php b/htdocs/admin/reception_setup.php index 3b5ee37b77c..b5f8e336b20 100644 --- a/htdocs/admin/reception_setup.php +++ b/htdocs/admin/reception_setup.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -105,18 +106,16 @@ if ($action == 'updateMask') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/reception/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db); diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 4c8c5fc51ae..86f485c11a4 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -5,6 +5,7 @@ * Copyright (C) 2012-2013 Juanjo Menent * Copyright (C) 2013-2018 Philippe Grand * Copyright (C) 2013 Florian Henry + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -109,18 +110,16 @@ if ($action == 'specimen') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/stock/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db); @@ -270,7 +269,7 @@ print ''; print ''; print ''.$langs->trans("DeStockOnShipment").''; print ''; -if (isModEnabled("delivery_note")) { +if (isModEnabled("shipping")) { if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition'); } else { @@ -287,7 +286,7 @@ print ''; print ''; print ''.$langs->trans("DeStockOnShipmentOnClosing").''; print ''; -if (isModEnabled("delivery_note")) { +if (isModEnabled("shipping")) { if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT_CLOSE', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition'); } else { @@ -461,7 +460,7 @@ if (isModEnabled('order')) { print "\n"; } -if (isModEnabled("delivery_note")) { +if (isModEnabled("shipping")) { print ''; print ''.$langs->trans("StockMustBeEnoughForShipment").''; print ''; diff --git a/htdocs/admin/stocktransfer.php b/htdocs/admin/stocktransfer.php index b7e027db2b2..dee8ebc3b14 100644 --- a/htdocs/admin/stocktransfer.php +++ b/htdocs/admin/stocktransfer.php @@ -2,6 +2,7 @@ /* Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2021 Gauthier VERDOL * Copyright (C) 2021 SuperAdmin + * Copyright (C) 2024 MDW * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -91,18 +92,16 @@ if ($action == 'updateMask') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/stocktransfer/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db); diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index 52b1342f88e..38db853af92 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -6,6 +6,7 @@ * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2011-2018 Philippe Grand + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -102,18 +103,16 @@ if ($action == 'specimen') { // For invoices // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/supplier_invoice/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db, $facture); diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index 849a6dff7f3..ecfc2a68b93 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 MDW * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2004 Sebastien Di Cintio @@ -92,18 +93,16 @@ if ($action == 'specimen') { // For orders // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/supplier_order/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db, $commande); diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php index c8ac3fa4423..e420a914155 100644 --- a/htdocs/admin/supplier_payment.php +++ b/htdocs/admin/supplier_payment.php @@ -2,6 +2,7 @@ /* Copyright (C) 2015 Juanjo Menent * Copyright (C) 2016 Laurent Destailleur * Copyright (C) 2020 Maxime DEMAREST + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -103,18 +104,16 @@ if ($action == 'updateMask') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/supplier_payment/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db); diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 09728fbe93e..94197b4bdad 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -8,6 +8,7 @@ * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2011-2013 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -81,18 +82,16 @@ if ($action == 'specimen') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/supplier_proposal/doc/pdf_".$modele.".modules.php"); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db); diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 57b9ea2c7d8..f54720e03df 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -4,6 +4,7 @@ * Copyright (C) 2007-2012 Regis Houssin * Copyright (C) 2015-2019 Frederic France * Copyright (C) 2017 Nicolas ZABOURI + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -83,7 +84,7 @@ $xmlshortfile = dol_sanitizeFileName(GETPOST('xmlshortfile', 'alpha') ? GETPOST( $xmlfile = DOL_DOCUMENT_ROOT.'/install/'.$xmlshortfile; if (!preg_match('/\.zip$/i', $xmlfile) && dol_is_file($xmlfile.'.zip')) { - $xmlfile = $xmlfile.'.zip'; + $xmlfile .= '.zip'; } // Remote file to compare to @@ -183,7 +184,7 @@ if (GETPOST('target') == 'remote') { libxml_disable_entity_loader(true); } - $xml = simplexml_load_string($xmlfile, 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET); + $xml = simplexml_load_string($xmlfile, 'SimpleXMLElement', LIBXML_NOCDATA | LIBXML_NONET); } else { $errormsg = $langs->trans('XmlNotFound').': '.$xmlremote.' - '.$xmlarray['http_code'].(($xmlarray['http_code'] == 400 && $xmlarray['content']) ? ' '.$xmlarray['content'] : '').' '.$xmlarray['curl_error_no'].' '.$xmlarray['curl_error_msg']; setEventMessages($errormsg, null, 'errors'); @@ -259,7 +260,7 @@ if (empty($error) && !empty($xml)) { $tmprelativefilename = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', $valfile['fullname']); if (!in_array($tmprelativefilename, $file_list['insignature'])) { $md5newfile = @md5_file($valfile['fullname']); // Can fails if we don't have permission to open/read file - $file_list['added'][] = array('filename'=>$tmprelativefilename, 'md5'=>$md5newfile); + $file_list['added'][] = array('filename' => $tmprelativefilename, 'md5' => $md5newfile); } } diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index da70b1fbbec..89912dd030e 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2009 Laurent Destailleur * Copyright (C) 2007 Rodolphe Quiedeville * Copyright (C) 2010-2012 Regis Houssin + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -308,21 +309,37 @@ print ''; // sort list if ($sortfield == "name" && $sortorder == "asc") { - usort($moduleList, function (stdClass $a, stdClass $b) { - return strcasecmp($a->name, $b->name); - }); + usort( + $moduleList, + /** @return bool */ + function (stdClass $a, stdClass $b) { + return strcasecmp($a->name, $b->name); + } + ); } elseif ($sortfield == "name" && $sortorder == "desc") { - usort($moduleList, function (stdClass $a, stdClass $b) { - return strcasecmp($b->name, $a->name); - }); + usort( + $moduleList, + /** @return bool */ + static function (stdClass $a, stdClass $b) { + return strcasecmp($b->name, $a->name); + } + ); } elseif ($sortfield == "version" && $sortorder == "asc") { - usort($moduleList, function (stdClass $a, stdClass $b) { - return strcasecmp($a->version, $b->version); - }); + usort( + $moduleList, + /** @return bool */ + static function (stdClass $a, stdClass $b) { + return strcasecmp($a->version, $b->version); + } + ); } elseif ($sortfield == "version" && $sortorder == "desc") { - usort($moduleList, function (stdClass $a, stdClass $b) { - return strcasecmp($b->version, $a->version); - }); + usort( + $moduleList, + /** @return bool */ + static function (stdClass $a, stdClass $b) { + return strcasecmp($b->version, $a->version); + } + ); } elseif ($sortfield == "id" && $sortorder == "asc") { usort($moduleList, "compareIdAsc"); } elseif ($sortfield == "id" && $sortorder == "desc") { diff --git a/htdocs/admin/system/phpinfo.php b/htdocs/admin/system/phpinfo.php index 36c64a826a6..3c410fbe0d4 100644 --- a/htdocs/admin/system/phpinfo.php +++ b/htdocs/admin/system/phpinfo.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2020 Tobias Sekan + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -53,36 +54,36 @@ if (isset($title)) { $maxphp = @ini_get('upload_max_filesize'); // In unknown if (preg_match('/k$/i', $maxphp)) { $maxphp = preg_replace('/k$/i', '', $maxphp); - $maxphp = $maxphp * 1; + $maxphp *= 1; } if (preg_match('/m$/i', $maxphp)) { $maxphp = preg_replace('/m$/i', '', $maxphp); - $maxphp = $maxphp * 1024; + $maxphp *= 1024; } if (preg_match('/g$/i', $maxphp)) { $maxphp = preg_replace('/g$/i', '', $maxphp); - $maxphp = $maxphp * 1024 * 1024; + $maxphp *= 1024 * 1024; } if (preg_match('/t$/i', $maxphp)) { $maxphp = preg_replace('/t$/i', '', $maxphp); - $maxphp = $maxphp * 1024 * 1024 * 1024; + $maxphp *= 1024 * 1024 * 1024; } $maxphp2 = @ini_get('post_max_size'); // In unknown if (preg_match('/k$/i', $maxphp2)) { $maxphp2 = preg_replace('/k$/i', '', $maxphp2); - $maxphp2 = $maxphp2 * 1; + $maxphp2 *= 1; } if (preg_match('/m$/i', $maxphp2)) { $maxphp2 = preg_replace('/m$/i', '', $maxphp2); - $maxphp2 = $maxphp2 * 1024; + $maxphp2 *= 1024; } if (preg_match('/g$/i', $maxphp2)) { $maxphp2 = preg_replace('/g$/i', '', $maxphp2); - $maxphp2 = $maxphp2 * 1024 * 1024; + $maxphp2 *= 1024 * 1024; } if (preg_match('/t$/i', $maxphp2)) { $maxphp2 = preg_replace('/t$/i', '', $maxphp2); - $maxphp2 = $maxphp2 * 1024 * 1024 * 1024; + $maxphp2 *= 1024 * 1024 * 1024; } if ($maxphp > 0 && $maxphp2 > 0 && $maxphp > $maxphp2) { $langs->load("errors"); diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index 9a0138ba6cf..0d98c3161e7 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -341,12 +341,13 @@ if (!getDolGlobalString('SECURITY_DISABLE_TEST_ON_OBFUSCATED_CONF')) { } print '$dolibarr_main_stream_to_disable: '; +// $arrayofstreamtodisable is defined into filefunc.inc.php if (empty($dolibarr_main_stream_to_disable)) { print ''.$langs->trans("Undefined").' = '.implode(', ', $arrayofstreamtodisable).''; } else { print implode(', ', $dolibarr_main_stream_to_disable); } -print ' -> PHP streams allowed = '; +print ' -> Current PHP streams allowed = '; $arrayofstreams = stream_get_wrappers(); if (!empty($arrayofstreams)) { sort($arrayofstreams); diff --git a/htdocs/admin/system/xdebug.php b/htdocs/admin/system/xdebug.php index 719b81859c3..9e0b05a24a3 100644 --- a/htdocs/admin/system/xdebug.php +++ b/htdocs/admin/system/xdebug.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -90,7 +91,12 @@ if (function_exists('socket_create')) { //$client = socket_accept($sock); $client = socket_connect($socket, $address, $port); if ($client) { - print "Connection established: ".$client." - address=".$address." port=".$port."
\n"; + if (is_bool($client)) { + $client_str = 'true'; + } else { + $client_str = (string) $client; + } + print "Connection established: ".$client_str." - address=".$address." port=".$port."
\n"; print "There is a Remote debug server at this address.
\n"; print "
\n"; print "To be sure this debugger accepts input from your PHP server and xdebug, be sure to have\n"; diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index fb65a08dd92..b44581098bc 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -191,7 +191,7 @@ if (in_array($type, array('mysql', 'mysqli'))) { print ''; print '
'; } else { - print 'No method available with database '.$label; + print 'No method available with database '.dol_escape_htmltag($label); } print ''; print ''; diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php index b1b1242ebcc..902239fca39 100644 --- a/htdocs/admin/tools/listevents.php +++ b/htdocs/admin/tools/listevents.php @@ -278,7 +278,7 @@ if ($result) { $param .= '&optioncss='.urlencode($optioncss); } if ($search_rowid) { - $param .= '&search_rowid='.urlencode($search_rowid); + $param .= '&search_rowid='.urlencode((string) ($search_rowid)); } if ($search_code) { $param .= '&search_code='.urlencode($search_code); diff --git a/htdocs/admin/webhook.php b/htdocs/admin/webhook.php index 7755856f8a0..4758220503d 100644 --- a/htdocs/admin/webhook.php +++ b/htdocs/admin/webhook.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 MDW * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -99,18 +100,16 @@ if ($action == 'updateMask') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/webhook/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele."_".strtolower($tmpobjectkey); break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db); diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index 1628db01977..2e28dc8a6f9 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -3,6 +3,7 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2021 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -60,96 +61,96 @@ clearstatcache(); $workflowcodes = array( // Automatic creation - 'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array( - 'family'=>'create', - 'position'=>10, - 'enabled'=>(isModEnabled("propal") && isModEnabled('order')), - 'picto'=>'order' + 'WORKFLOW_PROPAL_AUTOCREATE_ORDER' => array( + 'family' => 'create', + 'position' => 10, + 'enabled' => (isModEnabled("propal") && isModEnabled('order')), + 'picto' => 'order' ), - 'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array( - 'family'=>'create', - 'position'=>20, - 'enabled'=>(isModEnabled('order') && isModEnabled('invoice')), - 'picto'=>'bill' + 'WORKFLOW_ORDER_AUTOCREATE_INVOICE' => array( + 'family' => 'create', + 'position' => 20, + 'enabled' => (isModEnabled('order') && isModEnabled('invoice')), + 'picto' => 'bill' ), 'WORKFLOW_TICKET_CREATE_INTERVENTION' => array( - 'family'=>'create', - 'position'=>25, - 'enabled'=>(isModEnabled('ticket') && isModEnabled('intervention')), - 'picto'=>'ticket' + 'family' => 'create', + 'position' => 25, + 'enabled' => (isModEnabled('ticket') && isModEnabled('intervention')), + 'picto' => 'ticket' ), - 'separator1'=>array('family'=>'separator', 'position'=>25, 'title'=>'', 'enabled'=>((isModEnabled("propal") && isModEnabled('order')) || (isModEnabled('order') && isModEnabled('invoice')) || (isModEnabled('ticket') && isModEnabled('intervention')))), + 'separator1' => array('family' => 'separator', 'position' => 25, 'title' => '', 'enabled' => ((isModEnabled("propal") && isModEnabled('order')) || (isModEnabled('order') && isModEnabled('invoice')) || (isModEnabled('ticket') && isModEnabled('intervention')))), // Automatic classification of proposal - 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array( - 'family'=>'classify_proposal', - 'position'=>30, - 'enabled'=>(isModEnabled("propal") && isModEnabled('order')), - 'picto'=>'propal', - 'warning'=>'' + 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL' => array( + 'family' => 'classify_proposal', + 'position' => 30, + 'enabled' => (isModEnabled("propal") && isModEnabled('order')), + 'picto' => 'propal', + 'warning' => '' ), - 'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL'=>array( - 'family'=>'classify_proposal', - 'position'=>31, - 'enabled'=>(isModEnabled("propal") && isModEnabled('invoice')), - 'picto'=>'propal', - 'warning'=>'' + 'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL' => array( + 'family' => 'classify_proposal', + 'position' => 31, + 'enabled' => (isModEnabled("propal") && isModEnabled('invoice')), + 'picto' => 'propal', + 'warning' => '' ), // Automatic classification of order - 'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING'=>array( // when shipping validated - 'family'=>'classify_order', - 'position'=>40, - 'enabled'=>(isModEnabled("delivery_note") && isModEnabled('order')), - 'picto'=>'order' + 'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING' => array( // when shipping validated + 'family' => 'classify_order', + 'position' => 40, + 'enabled' => (isModEnabled("shipping") && isModEnabled('order')), + 'picto' => 'order' ), - 'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING_CLOSED'=>array( // when shipping closed - 'family'=>'classify_order', - 'position'=>41, - 'enabled'=>(isModEnabled("delivery_note") && isModEnabled('order')), - 'picto'=>'order' + 'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING_CLOSED' => array( // when shipping closed + 'family' => 'classify_order', + 'position' => 41, + 'enabled' => (isModEnabled("shipping") && isModEnabled('order')), + 'picto' => 'order' ), - 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array( - 'family'=>'classify_order', - 'position'=>42, - 'enabled'=>(isModEnabled('invoice') && isModEnabled('order')), - 'picto'=>'order', - 'warning'=>'' + 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER' => array( + 'family' => 'classify_order', + 'position' => 42, + 'enabled' => (isModEnabled('invoice') && isModEnabled('order')), + 'picto' => 'order', + 'warning' => '' ), // For this option, if module invoice is disabled, it does not exists, so "Classify billed" for order must be done manually from order card. // Automatic classification supplier proposal - 'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL'=>array( - 'family'=>'classify_supplier_proposal', - 'position'=>60, - 'enabled'=>(isModEnabled('supplier_proposal') && (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), - 'picto'=>'supplier_proposal', - 'warning'=>'' + 'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL' => array( + 'family' => 'classify_supplier_proposal', + 'position' => 60, + 'enabled' => (isModEnabled('supplier_proposal') && (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), + 'picto' => 'supplier_proposal', + 'warning' => '' ), // Automatic classification supplier order - 'WORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION'=>array( - 'family'=>'classify_supplier_order', - 'position'=>63, - 'enabled'=>(getDolGlobalString('MAIN_FEATURES_LEVEL') && isModEnabled("reception") && isModEnabled('supplier_order')), - 'picto'=>'supplier_order', - 'warning'=>'' + 'WORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION' => array( + 'family' => 'classify_supplier_order', + 'position' => 63, + 'enabled' => (getDolGlobalString('MAIN_FEATURES_LEVEL') && isModEnabled("reception") && isModEnabled('supplier_order')), + 'picto' => 'supplier_order', + 'warning' => '' ), - 'WORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION_CLOSED'=>array( - 'family'=>'classify_supplier_order', - 'position'=>64, - 'enabled'=>(getDolGlobalString('MAIN_FEATURES_LEVEL') && isModEnabled("reception") && isModEnabled('supplier_order')), - 'picto'=>'supplier_order', - 'warning'=>'' + 'WORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION_CLOSED' => array( + 'family' => 'classify_supplier_order', + 'position' => 64, + 'enabled' => (getDolGlobalString('MAIN_FEATURES_LEVEL') && isModEnabled("reception") && isModEnabled('supplier_order')), + 'picto' => 'supplier_order', + 'warning' => '' ), - 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER'=>array( - 'family'=>'classify_supplier_order', - 'position'=>65, - 'enabled'=>(isModEnabled("supplier_order") || isModEnabled("supplier_invoice")), - 'picto'=>'supplier_order', - 'warning'=>'' + 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER' => array( + 'family' => 'classify_supplier_order', + 'position' => 65, + 'enabled' => (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")), + 'picto' => 'supplier_order', + 'warning' => '' ), // Automatic classification shipping @@ -166,7 +167,7 @@ $workflowcodes = array( 'WORKFLOW_SHIPPING_CLASSIFY_BILLED_INVOICE' => array( 'family' => 'classify_shipping', 'position' => 91, - 'enabled' => isModEnabled("delivery_note") && isModEnabled("invoice") && getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT') !== '0', + 'enabled' => isModEnabled("shipping") && isModEnabled("invoice") && getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT') !== '0', 'picto' => 'shipment' ), @@ -188,7 +189,7 @@ $workflowcodes = array( ), - 'separator2'=>array('family'=>'separator', 'position'=>400, 'enabled' => (isModEnabled('ticket') && isModEnabled('contract'))), + 'separator2' => array('family' => 'separator', 'position' => 400, 'enabled' => (isModEnabled('ticket') && isModEnabled('contract'))), // Automatic link ticket -> contract 'WORKFLOW_TICKET_LINK_CONTRACT' => array( @@ -212,9 +213,16 @@ if (!empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['w } // remove not available workflows (based on activated modules and global defined keys) -$workflowcodes = array_filter($workflowcodes, function ($var) { - return $var['enabled']; -}); +$workflowcodes = array_filter( + $workflowcodes, + /** + * @param array{enabled:int<0,1>} $var + * @return int<0,1> + */ + static function ($var) { + return $var['enabled']; + } +); diff --git a/htdocs/admin/workstation.php b/htdocs/admin/workstation.php index 67c2bb9869a..78084737c6e 100644 --- a/htdocs/admin/workstation.php +++ b/htdocs/admin/workstation.php @@ -1,6 +1,7 @@ * Copyright (C) 2020 Gauthier VERDOL + * Copyright (C) 2024 MDW * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -84,18 +85,16 @@ if ($action == 'updateMask') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/workstation/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db); diff --git a/htdocs/ai/admin/custom_prompt.php b/htdocs/ai/admin/custom_prompt.php index c784e9ae3b8..628b3adf568 100644 --- a/htdocs/ai/admin/custom_prompt.php +++ b/htdocs/ai/admin/custom_prompt.php @@ -1,6 +1,7 @@ * Copyright (C) 2022 Alice Adminson + * Copyright (C) 2024 Frédéric France * * 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 @@ -80,8 +81,8 @@ $arrayofaifeatures = array( */ $functioncode = GETPOST('functioncode', 'alpha'); -$pre_prompt = GETPOST('prePrompt', 'alpha'); -$post_prompt = GETPOST('postPrompt', 'alpha'); +$pre_prompt = GETPOST('prePrompt'); +$post_prompt = GETPOST('postPrompt'); // get all configs in const AI $currentConfigurationsJson = getDolGlobalString('AI_CONFIGURATIONS_PROMPT'); @@ -126,6 +127,46 @@ if ($action == 'update' && !GETPOST('cancel')) { $action = 'edit'; } +if ($action == 'updatePrompts') { + $key = GETPOST('key', 'alpha'); + + $currentConfigurations[$key] = [ + 'prePrompt' => $pre_prompt, + 'postPrompt' => $post_prompt, + ]; + + $newConfigurationsJson = json_encode($currentConfigurations, JSON_UNESCAPED_UNICODE); + $result = dolibarr_set_const($db, 'AI_CONFIGURATIONS_PROMPT', $newConfigurationsJson, 'chaine', 0, '', $conf->entity); + if (!$error) { + $action = ''; + if ($result) { + header("Location: ".$_SERVER['PHP_SELF']); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + exit; + } else { + setEventMessages($langs->trans("ErrorUpdating"), null, 'errors'); + } + } +} + +if ($action == 'confirm_deleteproperty' && GETPOST('confirm') == 'yes') { + $key = GETPOST('key', 'alpha'); + + if (isset($currentConfigurations[$key])) { + unset($currentConfigurations[$key]); + + $newConfigurationsJson = json_encode($currentConfigurations, JSON_UNESCAPED_UNICODE); + $res = dolibarr_set_const($db, 'AI_CONFIGURATIONS_PROMPT', $newConfigurationsJson, 'chaine', 0, '', $conf->entity); + if ($res) { + header("Location: ".$_SERVER['PHP_SELF']); + setEventMessages($langs->trans("SetupDeleted"), null, 'mesgs'); + exit; + } else { + setEventMessages($langs->trans("ErrorDeleting"), null, 'errors'); + } + } +} + /* * View @@ -152,11 +193,25 @@ $newbutton = ''; print load_fiche_titre($langs->trans("AIPromptForFeatures"), $newbutton, ''); +if ($action == 'deleteproperty') { + $formconfirm = $form->formconfirm( + $_SERVER["PHP_SELF"].'?key='.urlencode(GETPOST('key', 'alpha')), + $langs->trans('Delete'), + $langs->trans('ConfirmDeleteSetup', GETPOST('key', 'alpha')), + 'confirm_deleteproperty', + '', + 0, + 1 + ); + print $formconfirm; +} + if ($action == 'edit') { $out .= '
'; $out .= ''; $out .= ''; + $out .= ''; $out .= ''; $out .= ''; @@ -201,7 +256,7 @@ if ($action == 'edit') { $out .= 'pre-Prompt'; $out .= ''; $out .= ''; $out .= ''; $out .= ''; @@ -209,14 +264,14 @@ if ($action == 'edit') { $out .= 'Post-prompt'; $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= '
'; - $out .= ''; + $out .= ''; $out .= '
'; - $out .= ''; + $out .= ''; $out .= '
'; $out .= $form->buttonsSaveCancel("Add", ""); - + $out .= '
'; $out .= '


'; print $out; @@ -235,17 +290,25 @@ if ($action == 'edit' || $action == 'create') { $out .= ''; $out .= ''; - $out .= ''.$arrayofaifeatures[$key]['picto'].' '.$langs->trans($arrayofaifeatures[$key]['label']).''; + $out .= ''.$arrayofaifeatures[$key]['picto'].' '.$langs->trans($arrayofaifeatures[$key]['label']); + $out .= ''.img_edit().''; + $out .= ''.img_delete().''; + $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= ''; + + $out .= '
'; + $out .= ''; + $out .= ''; + $out .= ''; $out .= ''; $out .= ''; $out .= 'pre-Prompt'; $out .= ''; $out .= ''; - $out .= ''; + $out .= ''; $out .= ''; $out .= ''; $out .= ''; @@ -253,15 +316,17 @@ if ($action == 'edit' || $action == 'create') { $out .= 'Post-prompt'; $out .= ''; $out .= ''; - $out .= ''; + $out .= ''; + $out .= '
'; + $out .= ''; $out .= ''; + $out .= '
'; } $out .= ''; $out .= ''; } - $out .= ''; $out .= ""; print $out; diff --git a/htdocs/ai/admin/setup.php b/htdocs/ai/admin/setup.php index 73e4765d7a4..9459b501b84 100644 --- a/htdocs/ai/admin/setup.php +++ b/htdocs/ai/admin/setup.php @@ -1,6 +1,7 @@ * Copyright (C) 2022 Alice Adminson + * Copyright (C) 2024 MDW * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -75,7 +76,7 @@ foreach ($arrayofia as $ia) { $item->cssClass = 'minwidth500'; } -$setupnotempty =+ count($formSetup->items); +$setupnotempty = + count($formSetup->items); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); @@ -113,18 +114,16 @@ if ($action == 'updateMask') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/ai/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele."_".strtolower($tmpobjectkey); break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db); @@ -193,45 +192,45 @@ $action = 'edit'; * View */ - $form = new Form($db); +$form = new Form($db); - $help_url = ''; - $title = "AiSetup"; +$help_url = ''; +$title = "AiSetup"; - llxHeader('', $langs->trans($title), $help_url); +llxHeader('', $langs->trans($title), $help_url); - // Subheader - $linkback = ''.$langs->trans("BackToModuleList").''; +// Subheader +$linkback = ''.$langs->trans("BackToModuleList").''; - print load_fiche_titre($langs->trans($title), $linkback, 'title_setup'); +print load_fiche_titre($langs->trans($title), $linkback, 'title_setup'); - // Configuration header - $head = aiAdminPrepareHead(); - print dol_get_fiche_head($head, 'settings', $langs->trans($title), -1, "fa-microchip"); +// Configuration header +$head = aiAdminPrepareHead(); +print dol_get_fiche_head($head, 'settings', $langs->trans($title), -1, "fa-microchip"); - // Setup page goes here - //echo ''.$langs->trans("AiSetupPage").'

'; +// Setup page goes here +//echo ''.$langs->trans("AiSetupPage").'

'; if ($action == 'edit') { - print $formSetup->generateOutput(true); - print '
'; + print $formSetup->generateOutput(true); + print '
'; } elseif (!empty($formSetup->items)) { print $formSetup->generateOutput(); print '
'; print ''.$langs->trans("Modify").''; print '
'; } else { - print '
'.$langs->trans("NothingToSetup"); + print '
'.$langs->trans("NothingToSetup"); } if (empty($setupnotempty)) { - print '
'.$langs->trans("NothingToSetup"); + print '
'.$langs->trans("NothingToSetup"); } - // Page end - print dol_get_fiche_end(); +// Page end +print dol_get_fiche_end(); - llxFooter(); - $db->close(); +llxFooter(); +$db->close(); diff --git a/htdocs/ai/ajax/generate_content.php b/htdocs/ai/ajax/generate_content.php index 9b1adf13b84..11aaa3e787b 100644 --- a/htdocs/ai/ajax/generate_content.php +++ b/htdocs/ai/ajax/generate_content.php @@ -61,13 +61,22 @@ if (is_null($jsonData)) { } $ai = new Ai($db); -$instructions = dol_string_nohtmltag($jsonData['instructions'], 1, 'UTF-8'); $function = 'textgeneration'; +$instructions = dol_string_nohtmltag($jsonData['instructions'], 1, 'UTF-8'); +$format = empty($jsonData['instructions']) ? '' : $jsonData['instructions']; -$generatedContent = $ai->generateContent($instructions, 'auto', $function); +$generatedContent = $ai->generateContent($instructions, 'auto', $function, $format); if (is_array($generatedContent) && $generatedContent['error']) { - print "Error : " . $generatedContent['message']; + // client errors + if ($generatedContent['code'] >= 400) { + print "Error : " . $generatedContent['message']; + print '
'.$langs->trans('Check Config of Module').''; + } elseif ($generatedContent['code'] == 429) { + print "Quota or allowed period exceeded. Retry Later !"; + } else { + print "Error returned by API call: " . $generatedContent['message']; + } } else { print $generatedContent; } diff --git a/htdocs/ai/class/ai.class.php b/htdocs/ai/class/ai.class.php index 399b3adb1ee..68002b62bb8 100644 --- a/htdocs/ai/class/ai.class.php +++ b/htdocs/ai/class/ai.class.php @@ -1,9 +1,5 @@ - * Copyright (C) 2005-2016 Regis Houssin - * Copyright (C) 2012 J. Fernando Lagrange - * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) 2023 Eric Seigne +/* Copyright (C) 2024 Laurent Destailleur * * 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 @@ -20,13 +16,14 @@ * or see https://www.gnu.org/ */ require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; + /** * Class for AI */ class Ai { - /** * @var DoliDB $db Database object */ @@ -57,13 +54,18 @@ class Ai /** * Generate response of instructions * - * @param string $instructions instruction for generate content - * @param string $model model name ('gpt-3.5-turbo') - * @param string $function code of the feature we want to use ('emailing', 'transcription', 'audiotext', 'imagegeneration', 'translation') + * @param string $instructions Instruction to generate content + * @param string $model Model name ('gpt-3.5-turbo', 'gpt-4-turbo', 'dall-e-3', ...) + * @param string $function Code of the feature we want to use ('textgeneration', 'transcription', 'audiotext', 'imagegeneration', 'translation') + * @param string $format Format for output ('', 'html', ...) * @return mixed $response */ - public function generateContent($instructions, $model = 'auto', $function = 'textgeneration') + public function generateContent($instructions, $model = 'auto', $function = 'textgeneration', $format = '') { + if (empty($this->apiKey)) { + return array('error' => true, 'message' => 'API key is no defined'); + } + if (empty($this->apiEndpoint)) { if ($function == 'textgeneration') { $this->apiEndpoint = 'https://api.openai.com/v1/chat/completions'; @@ -97,6 +99,8 @@ class Ai } } + dol_syslog("Call API for apiEndpoint=".$this->apiEndpoint." apiKey=".substr($this->apiKey, 0, 3).'***********, model='.$model); + try { $configurationsJson = getDolGlobalString('AI_CONFIGURATIONS_PROMPT'); $configurations = json_decode($configurationsJson, true); @@ -115,40 +119,37 @@ class Ai } $fullInstructions = $prePrompt.' '.$instructions.' .'.$postPrompt; - // TODO Replace this with a simple call of getDolURLContent(); - $ch = curl_init($this->apiEndpoint); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([ + + $payload = json_encode([ 'messages' => [ ['role' => 'user', 'content' => $fullInstructions] ], 'model' => $model - ])); - curl_setopt($ch, CURLOPT_HTTPHEADER, [ + ]); + + $headers = ([ 'Authorization: Bearer ' . $this->apiKey, 'Content-Type: application/json' ]); + $response = getURLContent($this->apiEndpoint, 'POST', $payload, $headers); - $response = curl_exec($ch); - if (curl_errno($ch)) { - throw new Exception('cURL error: ' . curl_error($ch)); - } - - $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); - if ($statusCode != 200) { - throw new Exception('API request failed with status code ' . $statusCode); + if ($response['http_code'] != 200) { + throw new Exception('API request failed with status code ' . $response['http_code']); } // Decode JSON response - $decodedResponse = json_decode($response, true); + $decodedResponse = json_decode($response['content'], true); // Extraction content $generatedEmailContent = $decodedResponse['choices'][0]['message']['content']; + // If content is not HTML, we convert it into HTML + if (!dol_textishtml($generatedEmailContent)) { + $generatedEmailContent = dol_nl2br($generatedEmailContent); + } + return $generatedEmailContent; } catch (Exception $e) { return array('error' => true, 'message' => $e->getMessage()); - } finally { - curl_close($ch); } } } diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index 82a60bc5116..8e4bdb0db9f 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016 Laurent Destailleur * Copyright (C) 2023 Ferran Marcet + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,11 +20,16 @@ // Create the autoloader for Luracast require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/AutoLoader.php'; -call_user_func(function () { - $loader = Luracast\Restler\AutoLoader::instance(); - spl_autoload_register($loader); - return $loader; -}); +call_user_func( + /** + * @return Luracast\Restler\AutoLoader + */ + static function () { + $loader = Luracast\Restler\AutoLoader::instance(); + spl_autoload_register($loader); + return $loader; + } +); require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/iAuthenticate.php'; require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/iUseAuthentication.php'; diff --git a/htdocs/api/index.php b/htdocs/api/index.php index d55fe8d38d5..4b3385fe5ee 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -3,6 +3,7 @@ * Copyright (C) 2016 Laurent Destailleur * Copyright (C) 2017 Regis Houssin * Copyright (C) 2021 Alexis LAURIER + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -91,11 +92,16 @@ if (!$res) { require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/AutoLoader.php'; -call_user_func(function () { - $loader = Luracast\Restler\AutoLoader::instance(); - spl_autoload_register($loader); - return $loader; -}); +call_user_func( + /** + * @return Luracast\Restler\AutoLoader + */ + static function () { + $loader = Luracast\Restler\AutoLoader::instance(); + spl_autoload_register($loader); + return $loader; + } +); require_once DOL_DOCUMENT_ROOT.'/api/class/api.class.php'; require_once DOL_DOCUMENT_ROOT.'/api/class/api_access.class.php'; diff --git a/htdocs/asset/admin/setup.php b/htdocs/asset/admin/setup.php index 72e6cac37ea..40e37464e90 100644 --- a/htdocs/asset/admin/setup.php +++ b/htdocs/asset/admin/setup.php @@ -1,6 +1,7 @@ * Copyright (C) 2018 Alexandre Spangaro + * Copyright (C) 2024 MDW * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -96,18 +97,16 @@ if ($action == 'updateMask') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/asset/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db); diff --git a/htdocs/asset/agenda.php b/htdocs/asset/agenda.php index f25da35dd6a..56e33e2e317 100644 --- a/htdocs/asset/agenda.php +++ b/htdocs/asset/agenda.php @@ -99,7 +99,7 @@ if (!isModEnabled('asset')) { * Actions */ -$parameters = array('id'=>$id); +$parameters = array('id' => $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'); @@ -167,14 +167,14 @@ if ($object->id > 0) { $objthirdparty = $object; $objcon = new stdClass(); - $out = '&origin=' . urlencode($object->element . '@' . $object->module) . '&originid=' . urlencode($object->id); + $out = '&origin=' . urlencode((string) ($object->element . '@' . $object->module)) . '&originid=' . urlencode((string) ($object->id)); $urlbacktopage = $_SERVER['PHP_SELF'] . '?id=' . $object->id; $out .= '&backtopage=' . urlencode($urlbacktopage); $permok = $user->hasRight('agenda', 'myactions', 'create'); if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.=' * Copyright (C) 2018 Alexandre Spangaro * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -93,7 +94,7 @@ class Asset extends CommonObject */ /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => '1', 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => '1', 'index' => 1, 'css' => 'left', 'comment' => "Id"), diff --git a/htdocs/asset/class/assetdepreciationoptions.class.php b/htdocs/asset/class/assetdepreciationoptions.class.php index e6aa273060c..1be3533eedd 100644 --- a/htdocs/asset/class/assetdepreciationoptions.class.php +++ b/htdocs/asset/class/assetdepreciationoptions.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -64,7 +65,7 @@ class AssetDepreciationOptions extends CommonObject */ /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array(); @@ -77,15 +78,15 @@ class AssetDepreciationOptions extends CommonObject 'label' => 'AssetDepreciationOptionEconomic', 'table' => 'asset_depreciation_options_economic', 'fields' => array( - 'depreciation_type' => array('type'=>'smallint', 'label'=>'AssetDepreciationOptionDepreciationType', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'arrayofkeyval'=>array('0'=>'AssetDepreciationOptionDepreciationTypeLinear', '1'=>'AssetDepreciationOptionDepreciationTypeDegressive', '2'=>'AssetDepreciationOptionDepreciationTypeExceptional'), 'validate'=>'1',), - 'degressive_coefficient' => array('type'=>'double(24,8)', 'label'=>'AssetDepreciationOptionDegressiveRate', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1','enabled_field' => 'economic:depreciation_type:1'), - 'duration' => array('type'=>'integer', 'label'=>'AssetDepreciationOptionDuration', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1',), - 'duration_type' => array('type'=>'smallint', 'label'=>'AssetDepreciationOptionDurationType', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'arrayofkeyval'=>array('0'=>'AssetDepreciationOptionDurationTypeAnnual', '1'=>'AssetDepreciationOptionDurationTypeMonthly'/*, '2'=>'AssetDepreciationOptionDurationTypeDaily'*/), 'validate'=>'1',), - 'rate' => array('type'=>'double(24,8)', 'label'=>'AssetDepreciationOptionRate', 'enabled'=>'1', 'position'=>50, 'visible'=>3, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1', 'computed' => '$object->asset_depreciation_options->getRate("economic")',), - 'accelerated_depreciation_option' => array('type'=>'boolean', 'label'=>'AssetDepreciationOptionAcceleratedDepreciation', 'enabled'=>'1', 'position'=>60, 'column_break' => true, 'notnull'=>0, 'default'=>'0', 'visible'=>1, 'validate'=>'1',), - 'amount_base_depreciation_ht' => array('type'=>'price', 'label'=>'AssetDepreciationOptionAmountBaseDepreciationHT', 'enabled'=>'isset($object)&&get_class($object)=="Asset"', 'only_on_asset'=>1, 'position'=>90, 'notnull'=>0, 'required'=>1, 'visible'=>1, 'default'=>'$object->reversal_amount_ht > 0 ? $object->reversal_amount_ht : $object->acquisition_value_ht', 'isameasure'=>'1', 'validate'=>'1',), - 'amount_base_deductible_ht' => array('type'=>'price', 'label'=>'AssetDepreciationOptionAmountBaseDeductibleHT', 'enabled'=>'isset($object)&&get_class($object)=="Asset"', 'only_on_asset'=>1, 'position'=>100, 'notnull'=>0, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1',), - 'total_amount_last_depreciation_ht' => array('type'=>'price', 'label'=>'AssetDepreciationOptionTotalAmountLastDepreciationHT', 'enabled'=>'isset($object)&&get_class($object)=="Asset"', 'only_on_asset'=>1, 'position'=>110, 'noteditable'=> 1, 'notnull'=>0, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1',), + 'depreciation_type' => array('type' => 'smallint', 'label' => 'AssetDepreciationOptionDepreciationType', 'enabled' => '1', 'position' => 10, 'notnull' => 1, 'visible' => 1, 'default' => '0', 'arrayofkeyval' => array('0' => 'AssetDepreciationOptionDepreciationTypeLinear', '1' => 'AssetDepreciationOptionDepreciationTypeDegressive', '2' => 'AssetDepreciationOptionDepreciationTypeExceptional'), 'validate' => '1',), + 'degressive_coefficient' => array('type' => 'double(24,8)', 'label' => 'AssetDepreciationOptionDegressiveRate', 'enabled' => '1', 'position' => 20, 'notnull' => 1, 'visible' => 1, 'default' => '0', 'isameasure' => '1', 'validate' => '1','enabled_field' => 'economic:depreciation_type:1'), + 'duration' => array('type' => 'integer', 'label' => 'AssetDepreciationOptionDuration', 'enabled' => '1', 'position' => 30, 'notnull' => 1, 'visible' => 1, 'default' => '0', 'isameasure' => '1', 'validate' => '1',), + 'duration_type' => array('type' => 'smallint', 'label' => 'AssetDepreciationOptionDurationType', 'enabled' => '1', 'position' => 40, 'notnull' => 1, 'visible' => 1, 'default' => '0', 'arrayofkeyval' => array('0' => 'AssetDepreciationOptionDurationTypeAnnual', '1' => 'AssetDepreciationOptionDurationTypeMonthly'/*, '2'=>'AssetDepreciationOptionDurationTypeDaily'*/), 'validate' => '1',), + 'rate' => array('type' => 'double(24,8)', 'label' => 'AssetDepreciationOptionRate', 'enabled' => '1', 'position' => 50, 'visible' => 3, 'default' => '0', 'isameasure' => '1', 'validate' => '1', 'computed' => '$object->asset_depreciation_options->getRate("economic")',), + 'accelerated_depreciation_option' => array('type' => 'boolean', 'label' => 'AssetDepreciationOptionAcceleratedDepreciation', 'enabled' => '1', 'position' => 60, 'column_break' => true, 'notnull' => 0, 'default' => '0', 'visible' => 1, 'validate' => '1',), + 'amount_base_depreciation_ht' => array('type' => 'price', 'label' => 'AssetDepreciationOptionAmountBaseDepreciationHT', 'enabled' => 'isset($object)&&get_class($object)=="Asset"', 'only_on_asset' => 1, 'position' => 90, 'notnull' => 0, 'required' => 1, 'visible' => 1, 'default' => '$object->reversal_amount_ht > 0 ? $object->reversal_amount_ht : $object->acquisition_value_ht', 'isameasure' => '1', 'validate' => '1',), + 'amount_base_deductible_ht' => array('type' => 'price', 'label' => 'AssetDepreciationOptionAmountBaseDeductibleHT', 'enabled' => 'isset($object)&&get_class($object)=="Asset"', 'only_on_asset' => 1, 'position' => 100, 'notnull' => 0, 'visible' => 1, 'default' => '0', 'isameasure' => '1', 'validate' => '1',), + 'total_amount_last_depreciation_ht' => array('type' => 'price', 'label' => 'AssetDepreciationOptionTotalAmountLastDepreciationHT', 'enabled' => 'isset($object)&&get_class($object)=="Asset"', 'only_on_asset' => 1, 'position' => 110, 'noteditable' => 1, 'notnull' => 0, 'visible' => 1, 'default' => '0', 'isameasure' => '1', 'validate' => '1',), ), ), 'accelerated_depreciation' => array( @@ -93,14 +94,14 @@ class AssetDepreciationOptions extends CommonObject 'table' => 'asset_depreciation_options_fiscal', 'enabled_field' => 'economic:accelerated_depreciation_option:1', 'fields' => array( - 'depreciation_type' => array('type'=>'smallint', 'label'=>'AssetDepreciationOptionDepreciationType', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'arrayofkeyval'=>array('0'=>'AssetDepreciationOptionDepreciationTypeLinear', '1'=>'AssetDepreciationOptionDepreciationTypeDegressive', '2'=>'AssetDepreciationOptionDepreciationTypeExceptional'), 'validate'=>'1',), - 'degressive_coefficient' => array('type'=>'double(24,8)', 'label'=>'AssetDepreciationOptionDegressiveRate', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1','enabled_field' => 'accelerated_depreciation:depreciation_type:1'), - 'duration' => array('type'=>'integer', 'label'=>'AssetDepreciationOptionDuration', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1',), - 'duration_type' => array('type'=>'smallint', 'label'=>'AssetDepreciationOptionDurationType', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'arrayofkeyval'=>array('0'=>'AssetDepreciationOptionDurationTypeAnnual', '1'=>'AssetDepreciationOptionDurationTypeMonthly'/*, '2'=>'AssetDepreciationOptionDurationTypeDaily'*/), 'validate'=>'1',), - 'rate' => array('type'=>'double(24,8)', 'label'=>'AssetDepreciationOptionRate', 'enabled'=>'1', 'position'=>50, 'visible'=>3, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1', 'computed' => '$object->asset_depreciation_options->getRate("accelerated_depreciation")',), - 'amount_base_depreciation_ht' => array('type'=>'price', 'label'=>'AssetDepreciationOptionAmountBaseDepreciationHT', 'enabled'=>'isset($object)&&get_class($object)=="Asset"', 'only_on_asset'=>1, 'position'=>80, 'column_break' => true, 'notnull'=>0, 'required'=>1, 'visible'=>1, 'default'=>'$object->reversal_amount_ht > 0 ? $object->reversal_amount_ht : $object->acquisition_value_ht', 'isameasure'=>'1', 'validate'=>'1',), - 'amount_base_deductible_ht' => array('type'=>'price', 'label'=>'AssetDepreciationOptionAmountBaseDeductibleHT', 'enabled'=>'isset($object)&&get_class($object)=="Asset"', 'only_on_asset'=>1, 'position'=>90, 'notnull'=>0, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1',), - 'total_amount_last_depreciation_ht' => array('type'=>'price', 'label'=>'AssetDepreciationOptionTotalAmountLastDepreciationHT', 'enabled'=>'isset($object)&&get_class($object)=="Asset"', 'only_on_asset'=>1, 'position'=>100, 'noteditable'=> 1, 'notnull'=>0, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1',), + 'depreciation_type' => array('type' => 'smallint', 'label' => 'AssetDepreciationOptionDepreciationType', 'enabled' => '1', 'position' => 10, 'notnull' => 1, 'visible' => 1, 'default' => '0', 'arrayofkeyval' => array('0' => 'AssetDepreciationOptionDepreciationTypeLinear', '1' => 'AssetDepreciationOptionDepreciationTypeDegressive', '2' => 'AssetDepreciationOptionDepreciationTypeExceptional'), 'validate' => '1',), + 'degressive_coefficient' => array('type' => 'double(24,8)', 'label' => 'AssetDepreciationOptionDegressiveRate', 'enabled' => '1', 'position' => 20, 'notnull' => 1, 'visible' => 1, 'default' => '0', 'isameasure' => '1', 'validate' => '1','enabled_field' => 'accelerated_depreciation:depreciation_type:1'), + 'duration' => array('type' => 'integer', 'label' => 'AssetDepreciationOptionDuration', 'enabled' => '1', 'position' => 30, 'notnull' => 1, 'visible' => 1, 'default' => '0', 'isameasure' => '1', 'validate' => '1',), + 'duration_type' => array('type' => 'smallint', 'label' => 'AssetDepreciationOptionDurationType', 'enabled' => '1', 'position' => 40, 'notnull' => 1, 'visible' => 1, 'default' => '0', 'arrayofkeyval' => array('0' => 'AssetDepreciationOptionDurationTypeAnnual', '1' => 'AssetDepreciationOptionDurationTypeMonthly'/*, '2'=>'AssetDepreciationOptionDurationTypeDaily'*/), 'validate' => '1',), + 'rate' => array('type' => 'double(24,8)', 'label' => 'AssetDepreciationOptionRate', 'enabled' => '1', 'position' => 50, 'visible' => 3, 'default' => '0', 'isameasure' => '1', 'validate' => '1', 'computed' => '$object->asset_depreciation_options->getRate("accelerated_depreciation")',), + 'amount_base_depreciation_ht' => array('type' => 'price', 'label' => 'AssetDepreciationOptionAmountBaseDepreciationHT', 'enabled' => 'isset($object)&&get_class($object)=="Asset"', 'only_on_asset' => 1, 'position' => 80, 'column_break' => true, 'notnull' => 0, 'required' => 1, 'visible' => 1, 'default' => '$object->reversal_amount_ht > 0 ? $object->reversal_amount_ht : $object->acquisition_value_ht', 'isameasure' => '1', 'validate' => '1',), + 'amount_base_deductible_ht' => array('type' => 'price', 'label' => 'AssetDepreciationOptionAmountBaseDeductibleHT', 'enabled' => 'isset($object)&&get_class($object)=="Asset"', 'only_on_asset' => 1, 'position' => 90, 'notnull' => 0, 'visible' => 1, 'default' => '0', 'isameasure' => '1', 'validate' => '1',), + 'total_amount_last_depreciation_ht' => array('type' => 'price', 'label' => 'AssetDepreciationOptionTotalAmountLastDepreciationHT', 'enabled' => 'isset($object)&&get_class($object)=="Asset"', 'only_on_asset' => 1, 'position' => 100, 'noteditable' => 1, 'notnull' => 0, 'visible' => 1, 'default' => '0', 'isameasure' => '1', 'validate' => '1',), ), ), ); @@ -178,7 +179,7 @@ class AssetDepreciationOptions extends CommonObject $this->{$field_key} = $this->deprecation_options[$mode][$field_key] ?? null; } - $this->fields['rowid'] = array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"); + $this->fields['rowid'] = array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => '1', 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => '1', 'index' => 1, 'css' => 'left', 'comment' => "Id"); if (empty($class_type)) { $this->fields['fk_asset'] = array('type' => 'integer:Asset:asset/class/asset.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label' => 'Asset', 'enabled' => '1', 'position' => 0, 'notnull' => 0, 'visible' => 0, 'index' => 1, 'validate' => '1',); } else { diff --git a/htdocs/asset/class/assetmodel.class.php b/htdocs/asset/class/assetmodel.class.php index 811f50252d7..8315231fd76 100644 --- a/htdocs/asset/class/assetmodel.class.php +++ b/htdocs/asset/class/assetmodel.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2021 Open-Dsi * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -99,7 +100,7 @@ class AssetModel extends CommonObject */ /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => '1', 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => '1', 'index' => 1, 'css' => 'left', 'comment' => "Id"), diff --git a/htdocs/asset/model/agenda.php b/htdocs/asset/model/agenda.php index ff190403410..1eb0a2e850a 100644 --- a/htdocs/asset/model/agenda.php +++ b/htdocs/asset/model/agenda.php @@ -173,14 +173,14 @@ if ($object->id > 0) { $objthirdparty = $object; $objcon = new stdClass(); - $out = '&origin=' . urlencode($object->element . '@' . $object->module) . '&originid=' . urlencode($object->id); + $out = '&origin=' . urlencode((string) ($object->element . '@' . $object->module)) . '&originid=' . urlencode((string) ($object->id)); $urlbacktopage = $_SERVER['PHP_SELF'] . '?id=' . $object->id; $out .= '&backtopage=' . urlencode($urlbacktopage); $permok = $user->hasRight('agenda', 'myactions', 'create'); if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.=' * Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2006-2017 Laurent Destailleur + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -253,8 +254,6 @@ if (empty($reshook)) { } } - $i++; - // Build and output PDF if (!$error && $mode == 'label') { if (!count($arrayofrecords)) { diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index 305c34413e5..bb385e34984 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -298,7 +298,7 @@ if (GETPOST('withtab', 'alpha')) { } else { $title = $langs->trans("BrowseBlockedLog"); } -$help_url="EN:Module_Unalterable_Archives_-_Logs|FR:Module_Archives_-_Logs_Inaltérable"; +$help_url = "EN:Module_Unalterable_Archives_-_Logs|FR:Module_Archives_-_Logs_Inaltérable"; llxHeader('', $title, $help_url); @@ -353,16 +353,16 @@ if ($search_startday > 0) { $param .= '&search_startday='.urlencode($search_startday); } if ($search_endyear > 0) { - $param .= '&search_endyear='.urlencode($search_endyear); + $param .= '&search_endyear='.urlencode((string) ($search_endyear)); } if ($search_endmonth > 0) { - $param .= '&search_endmonth='.urlencode($search_endmonth); + $param .= '&search_endmonth='.urlencode((string) ($search_endmonth)); } if ($search_endday > 0) { - $param .= '&search_endday='.urlencode($search_endday); + $param .= '&search_endday='.urlencode((string) ($search_endday)); } if ($search_showonlyerrors > 0) { - $param .= '&search_showonlyerrors='.urlencode($search_showonlyerrors); + $param .= '&search_showonlyerrors='.urlencode((string) ($search_showonlyerrors)); } if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 451720bbd59..64f69ea390d 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2017 ATM Consulting * Copyright (C) 2017-2020 Laurent Destailleur * Copyright (C) 2022 charlene benke + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -351,6 +352,7 @@ class BlockedLog global $langs, $cachedUser; if (empty($cachedUser)) { + // @phan-suppress-next-line PhanPluginRedundantAssignment $cachedUser = array(); } @@ -1014,7 +1016,7 @@ class BlockedLog unset($keyforsignature); return array('checkresult' => $res, 'calculatedsignature' => $signature, 'previoushash' => $previoushash); } else { // Consume much memory ($keyforsignature is a large var) - return array('checkresult' => $res, 'calculatedsignature' => $signature, 'previoushash' => $previoushash, 'keyforsignature'=>$keyforsignature); + return array('checkresult' => $res, 'calculatedsignature' => $signature, 'previoushash' => $previoushash, 'keyforsignature' => $keyforsignature); } } else { unset($keyforsignature); @@ -1227,7 +1229,7 @@ class BlockedLog dol_print_error($this->db); } - dol_syslog("Module Blockedlog alreadyUsed with ignoresystem=".$ignoresystem." is ".$result); + dol_syslog("Module Blockedlog alreadyUsed with ignoresystem=".$ignoresystem." is ".json_encode($result)); return $result; } diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index b7b6be62f2e..a3d335c11da 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -109,11 +110,11 @@ foreach ($object->fields as $key => $val) { if (!empty($val['visible'])) { $visible = (int) dol_eval($val['visible'], 1); $arrayfields['t.'.$key] = array( - 'label'=>$val['label'], - 'checked'=>(($visible < 0) ? 0 : 1), - 'enabled'=>(abs($visible) != 3 && (int) 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 && (int) dol_eval($val['enabled'], 1)), + 'position' => $val['position'], + 'help' => isset($val['help']) ? $val['help'] : '' ); } } @@ -218,11 +219,7 @@ if (empty($reshook)) { } if (!$error) { - if ($nbok > 1) { - setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - } else { - setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - } + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); $db->commit(); } else { $db->rollback(); @@ -266,11 +263,7 @@ if (empty($reshook)) { } if (!$error) { - if ($nbok > 1) { - setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - } else { - setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - } + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); $db->commit(); } else { $db->rollback(); @@ -343,7 +336,7 @@ foreach ($search as $key => $val) { } } else { if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') { - $columnName=preg_replace('/(_dtstart|_dtend)$/', '', $key); + $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->sanitize($columnName)." >= '".$db->idate($search[$key])."'"; @@ -474,8 +467,8 @@ $param .= $hookmanager->resPrint; // List of mass actions available $arrayofmassactions = array( //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), - 'enable'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Enable"), - 'disable'=>img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Disable"), + 'enable' => img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Enable"), + 'disable' => img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Disable"), ); if (!empty($permissiontodelete)) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); @@ -500,8 +493,8 @@ print ''; print ''; $newcardbutton = ''; -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition')); $newcardbutton .= dolGetButtonTitleSeparator(); $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/bom/bom_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->hasRight('bom', 'write')); @@ -607,7 +600,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 @@ -650,7 +643,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 @@ -711,7 +704,7 @@ while ($i < $imaxinloop) { $selected = 1; } } - print $object->getKanbanView('', array('prod'=>$prod, 'selected' => $selected)); + print $object->getKanbanView('', array('prod' => $prod, 'selected' => $selected)); if ($i == ($imaxinloop - 1)) { print ''; print ''; @@ -787,7 +780,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 @@ -830,7 +823,7 @@ if ($num == 0) { $db->free($resql); -$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index a2199a42f97..fda5dd93eeb 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2023 Benjamin Falière * Copyright (C) 2023 Charlene Benke * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -110,7 +111,7 @@ class BOM extends CommonObject // BEGIN MODULEBUILDER PROPERTIES /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -2, 'position' => 1, 'notnull' => 1, 'index' => 1, 'comment' => "Id",), @@ -236,7 +237,7 @@ class BOM extends CommonObject // protected $childtables=array(); /** - * @var array List of child tables. To know object to delete on cascade. + * @var string[] List of child tables. To know object to delete on cascade. */ protected $childtablesoncascade = array('bom_bomline'); @@ -485,18 +486,16 @@ class BOM extends CommonObject /** * Load list of objects in memory from the database. * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit limit - * @param int $offset Offset - * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) - * @param string $filtermode Filter mode (AND or OR) - * @return array|int int <0 if KO, array of pages if OK + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit Limit + * @param int $offset Offset + * @param string $filter Filter USF + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND') { - global $conf; - dol_syslog(__METHOD__, LOG_DEBUG); $records = array(); @@ -510,6 +509,7 @@ class BOM extends CommonObject $sql .= ' WHERE 1 = 1'; } + // Manage filter $errormessage = ''; $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage); if ($errormessage) { diff --git a/htdocs/bookcal/admin/setup.php b/htdocs/bookcal/admin/setup.php index 7117deee8e1..1b445686550 100644 --- a/htdocs/bookcal/admin/setup.php +++ b/htdocs/bookcal/admin/setup.php @@ -1,6 +1,7 @@ * Copyright (C) 2022 Alice Adminson + * Copyright (C) 2024 MDW * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -102,7 +103,7 @@ $item->helpText = $langs->transnoentities('AnHelpMessage');*/ //$item->fieldOutputOverride = false; // set this var to override field output -$setupnotempty =+ count($formSetup->items); +$setupnotempty = + count($formSetup->items); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); @@ -145,18 +146,16 @@ if ($action == 'updateMask') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/bookcal/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_".$modele."_".strtolower($tmpobjectkey); break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db); diff --git a/htdocs/bookcal/availabilities_agenda.php b/htdocs/bookcal/availabilities_agenda.php index ac313e7b699..5c29e0c45cc 100644 --- a/htdocs/bookcal/availabilities_agenda.php +++ b/htdocs/bookcal/availabilities_agenda.php @@ -113,7 +113,7 @@ if (!$permissiontoread) { * Actions */ -$parameters = array('id'=>$id); +$parameters = array('id' => $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'); @@ -218,14 +218,14 @@ if ($object->id > 0) { $objthirdparty = $object; $objcon = new stdClass(); - $out = '&origin='.urlencode($object->element.'@'.$object->module).'&originid='.urlencode($object->id); + $out = '&origin='.urlencode((string) ($object->element.'@'.$object->module)).'&originid='.urlencode((string) ($object->id)); $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id; $out .= '&backtopage='.urlencode($urlbacktopage); $permok = $user->hasRight('agenda', 'myactions', 'create'); if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.='$id); +$parameters = array('id' => $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'); @@ -217,14 +217,14 @@ if ($object->id > 0) { $objthirdparty = $object; $objcon = new stdClass(); - $out = '&origin='.urlencode($object->element.(property_exists($object, 'module') ? '@'.$object->module : '')).'&originid='.urlencode($object->id); + $out = '&origin='.urlencode((string) ($object->element.(property_exists($object, 'module') ? '@'.$object->module : ''))).'&originid='.urlencode((string) ($object->id)); $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id; $out .= '&backtopage='.urlencode($urlbacktopage); $permok = $user->hasRight('agenda', 'myactions', 'create'); if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.=' * Copyright (C) 2022 Alice Adminson * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -111,7 +112,7 @@ class Availabilities extends CommonObject // BEGIN MODULEBUILDER PROPERTIES /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => '1', 'position' => 1, 'notnull' => 1, 'visible' => 2, 'noteditable' => '1', 'index' => 1, 'css' => 'left', 'comment' => "Id"), diff --git a/htdocs/bookcal/class/calendar.class.php b/htdocs/bookcal/class/calendar.class.php index cad6ca0eeb2..f4777bfa003 100644 --- a/htdocs/bookcal/class/calendar.class.php +++ b/htdocs/bookcal/class/calendar.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2023-2024 Frédéric France * Copyright (C) 2023 Alice Adminson + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -111,7 +112,7 @@ class Calendar extends CommonObject // BEGIN MODULEBUILDER PROPERTIES /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => '1', 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => '1', 'index' => 1, 'css' => 'right', 'comment' => "Id"), diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index 3e474c85762..57177cd410c 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -228,6 +228,7 @@ if ($id > 0 && !preg_match('/^add/i', $action)) { print '
'; print ''; + // Title print ''; + // URL print ''; print ''; @@ -1448,13 +1422,6 @@ if ($action == 'create') { print ''; print ''; - // Done by - if (getDolGlobalString('AGENDA_ENABLE_DONEBY')) { - print ''; - } - // Location if (!getDolGlobalString('AGENDA_DISABLE_LOCATION')) { print ''; @@ -1800,7 +1767,7 @@ if ($id > 0) { // Confirmation suppression action if ($action == 'delete') { - print $form->formconfirm("card.php?id=".urlencode($id), $langs->trans("DeleteAction"), $langs->trans("ConfirmDeleteAction"), "confirm_delete", '', '', 1); + print $form->formconfirm("card.php?id=".urlencode((string) ($id)), $langs->trans("DeleteAction"), $langs->trans("ConfirmDeleteAction"), "confirm_delete", '', '', 1); } if ($action == 'edit') { @@ -1949,21 +1916,9 @@ if ($id > 0) { */ print ''; print ''; @@ -2011,13 +1966,6 @@ if ($id > 0) { }*/ print ''; - // Realised by - if (getDolGlobalString('AGENDA_ENABLE_DONEBY')) { - print ''; - } - // Location if (!getDolGlobalString('AGENDA_DISABLE_LOCATION')) { print ''; @@ -2443,17 +2391,6 @@ if ($id > 0) { */ print ' '; - // Done by - if (getDolGlobalString('AGENDA_ENABLE_DONEBY')) { - print ''; - } - // Categories if (isModEnabled('category')) { print ''; + $formmail = new FormMail($db); + $formmail->withfckeditor = 1; + $formmail->withaiprompt = 'html'; + $formmail->withlayout = 1; + + print ''; print '
'; if ($action == 'edit') { print ''; @@ -247,6 +248,7 @@ if ($id > 0 && !preg_match('/^add/i', $action)) { } print '
'; if ($action == 'edit') { print ''; @@ -255,7 +257,7 @@ if ($id > 0 && !preg_match('/^add/i', $action)) { if ($action == 'edit') { print ''; } - print ''; + print ''; if ($action == 'edit') { print 'url).'">'; } else { diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 62bbc69953d..f65789c855c 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -12,6 +12,7 @@ * Copyright (C) 2016 Charlie Benke * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2023 Benjamin Falière + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1009,7 +1010,7 @@ class Categorie extends CommonObject $nbtotalofrecords = $this->db->num_rows($result); if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; - $offset = 0; + $offset = 0; // @phan-suppress-current-line PhanPluginRedundantAssignment } } diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index efcd10ddbb9..a277b9b03c8 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -102,7 +102,7 @@ if ($confirm == 'no') { } } -$parameters = array(); +$parameters = array('type' => $type, 'id' => $id, 'label' => $label); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Remove element from category if ($id > 0 && $removeelem > 0 && $action == 'unlink') { @@ -1355,6 +1355,10 @@ if ($type == Categorie::TYPE_TICKET) { } } +// Note that $action and $object may have been modified by some hooks +$parameters = array('type' => $type, 'id' => $id, 'label' => $label); +$reshook = $hookmanager->executeHooks('addMoreCategoriesList', $parameters, $object, $action); + // End of page llxFooter(); $db->close(); diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 05229a9ab58..1e27f3d54f8 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -426,12 +426,6 @@ if (empty($reshook) && $action == 'add') { } } - if (!$error && getDolGlobalString('AGENDA_ENABLE_DONEBY')) { - if (GETPOST("doneby") > 0) { - $object->userdoneid = GETPOSTINT("doneby"); - } - } - $object->note_private = trim(GETPOST("note", "restricthtml")); if (GETPOSTISSET("contactid")) { @@ -877,12 +871,6 @@ if (empty($reshook) && $action == 'update') { $object->transparency = $transparency; // We set transparency on event (even if we can also store it on each user, standard says this property is for event) // TODO store also transparency on owner user - if (getDolGlobalString('AGENDA_ENABLE_DONEBY')) { - if (GETPOST("doneby")) { - $object->userdoneid = GETPOSTINT("doneby"); - } - } - // Check parameters if (GETPOSTISSET('actioncode') && !GETPOST('actioncode', 'aZ09')) { // actioncode is '0' $error++; @@ -1230,16 +1218,6 @@ if ($action == 'create') { setdatefields(); }); - $("#selectcomplete").change(function() { - console.log("we change the complete status - set the doneby"); - if ($("#selectcomplete").val() == 100) { - if ($("#doneby").val() <= 0) $("#doneby").val(\''.((int) $user->id).'\'); - } - if ($("#selectcomplete").val() == 0) { - $("#doneby").val(-1); - } - }); - $("#actioncode").change(function() { if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired"); else $("#dateend").removeClass("fieldrequired"); @@ -1411,11 +1389,7 @@ if ($action == 'create') { print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 2, 0, 'fulldaystart', '', '', '', 1, '', '', 'tzuserrel'); } print '     -     '; - if (GETPOST("afaire") == 1) { - print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel'); - } else { - print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel'); - } + print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel'); print '
 
'.$langs->trans("ActionDoneBy").''; - print $form->select_dolusers(GETPOSTISSET("doneby") ? GETPOSTINT("doneby") : (!empty($object->userdoneid) && $percent == 100 ? $object->userdoneid : 0), 'doneby', 1); - print '
'.$langs->trans("Location").'
'; $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); - if (GETPOST("afaire") == 1) { - print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); - } elseif (GETPOST("afaire") == 2) { - print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); - } else { - print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); - } + print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); print '     -     '; - if (GETPOST("afaire") == 1) { - print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); - } elseif (GETPOST("afaire") == 2) { - print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); - } else { - print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); - } + print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); print '
 
'.$langs->trans("ActionDoneBy").''; - print $form->select_dolusers($object->userdoneid > 0 ? $object->userdoneid : -1, 'doneby', 1); - print '
'.$langs->trans("Location").'
'.$langs->trans("ActionDoneBy").''; - if ($object->userdoneid > 0) { - $tmpuser = new User($db); - $tmpuser->fetch($object->userdoneid); - print $tmpuser->getNomUrl(1); - } - print '
'.$langs->trans("Categories").''; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index a73b24e9d28..db8eadee618 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -6,6 +6,8 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2024 MDW + * Copyright (C) 2024 William Mead * * 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 @@ -239,11 +241,6 @@ class ActionComm extends CommonObject */ public $userownerid; - /** - * @var int Id of user that has done the event. Used only if AGENDA_ENABLE_DONEBY is set. - */ - public $userdoneid; - /** * @var int[] Array of contact ids */ @@ -492,7 +489,6 @@ class ActionComm extends CommonObject } $userownerid = $this->userownerid; - $userdoneid = $this->userdoneid; // Be sure assigned user is defined as an array of array('id'=>,'mandatory'=>,...). if (empty($this->userassigned) || count($this->userassigned) == 0 || !is_array($this->userassigned)) { @@ -542,7 +538,6 @@ class ActionComm extends CommonObject $sql .= "fk_contact,"; $sql .= "fk_user_author,"; $sql .= "fk_user_action,"; - $sql .= "fk_user_done,"; $sql .= "label,percent,priority,fulldayevent,location,"; $sql .= "transparency,"; $sql .= "fk_element,"; @@ -581,7 +576,6 @@ class ActionComm extends CommonObject $sql .= ((isset($this->contact_id) && $this->contact_id > 0) ? ((int) $this->contact_id) : "null").", "; // deprecated, use ->socpeopleassigned $sql .= (isset($user->id) && $user->id > 0 ? $user->id : "null").", "; $sql .= ($userownerid > 0 ? $userownerid : "null").", "; - $sql .= ($userdoneid > 0 ? $userdoneid : "null").", "; $sql .= "'".$this->db->escape($this->label)."', "; $sql .= "'".$this->db->escape($this->percentage)."', "; $sql .= "'".$this->db->escape($this->priority)."', "; @@ -810,7 +804,7 @@ class ActionComm extends CommonObject $sql .= " a.fk_soc,"; $sql .= " a.fk_project,"; $sql .= " a.fk_user_author, a.fk_user_mod,"; - $sql .= " a.fk_user_action, a.fk_user_done,"; + $sql .= " a.fk_user_action,"; $sql .= " a.fk_contact, a.percent as percentage,"; $sql .= " a.fk_element as elementid, a.elementtype,"; $sql .= " a.priority, a.fulldayevent, a.location, a.transparency,"; @@ -1160,16 +1154,9 @@ class ActionComm extends CommonObject $this->fk_project = 0; } - // Check parameters - if ($this->percentage == 0 && $this->userdoneid > 0) { - $this->error = "ErrorCantSaveADoneUserWithZeroPercentage"; - return -1; - } - $socid = (($this->socid > 0) ? $this->socid : 0); $contactid = (($this->contact_id > 0) ? $this->contact_id : 0); $userownerid = ($this->userownerid ? $this->userownerid : 0); - $userdoneid = ($this->userdoneid ? $this->userdoneid : 0); // If a type_id is set, we must also have the type_code set if ($this->type_id > 0) { @@ -1207,7 +1194,6 @@ class ActionComm extends CommonObject $sql .= ", transparency = '".$this->db->escape($this->transparency)."'"; $sql .= ", fk_user_mod = ".((int) $user->id); $sql .= ", fk_user_action = ".($userownerid > 0 ? ((int) $userownerid) : "null"); - $sql .= ", fk_user_done = ".($userdoneid > 0 ? ((int) $userdoneid) : "null"); if (!empty($this->fk_element)) { $sql .= ", fk_element=".($this->fk_element ? ((int) $this->fk_element) : "null"); } @@ -1430,7 +1416,7 @@ class ActionComm extends CommonObject } $sql .= " AND a.entity IN (".getEntity('agenda').")"; if (!$user->hasRight('agenda', 'allactions', 'read')) { - $sql .= " AND (a.fk_user_author = ".((int) $user->id)." OR a.fk_user_action = ".((int) $user->id)." OR a.fk_user_done = ".((int) $user->id); + $sql .= " AND (a.fk_user_author = ".((int) $user->id)." OR a.fk_user_action = ".((int) $user->id); $sql .= " OR ar.fk_element = ".((int) $user->id); $sql .= ")"; } @@ -1577,7 +1563,7 @@ class ActionComm extends CommonObject $statusType = 'status9'; if ($percent == -1 && !$hidenastatus) { - $statusType = 'status9'; + $statusType = 'status9'; // @phan-suppress-current-line PhanPluginRedundantAssignment } if ($percent == 0) { $statusType = 'status1'; @@ -2002,7 +1988,6 @@ class ActionComm extends CommonObject $buildfile = true; $login = ''; $logina = ''; - $logind = ''; $logint = ''; $eventorganization = ''; @@ -2353,9 +2338,6 @@ class ActionComm extends CommonObject if ($logint) { $more = $langs->transnoentities("ActionsToDoBy").' '.$logint; } - if ($logind) { - $more = $langs->transnoentities("ActionsDoneBy").' '.$logind; - } if ($eventorganization) { $langs->load("eventorganization"); $title = $langs->transnoentities("OrganizedEvent").(empty($eventarray[0]['label']) ? '' : ' '.$eventarray[0]['label']); @@ -2728,7 +2710,7 @@ class ActionComm extends CommonObject return 0; } else { $this->db->commit(); // We commit also on error, to have the error message recorded. - $this->error = 'Nb of emails sent : '.$nbMailSend.', '.(!empty($errorsMsg)) ? implode(', ', $errorsMsg) : $error; + $this->error = 'Nb of emails sent : '.$nbMailSend.', '.(!empty($errorsMsg) ? implode(', ', $errorsMsg) : $error); dol_syslog(__METHOD__." end - ".$this->error, LOG_INFO); diff --git a/htdocs/comm/action/class/actioncommreminder.class.php b/htdocs/comm/action/class/actioncommreminder.class.php index 4880e42300d..cf86e744f70 100644 --- a/htdocs/comm/action/class/actioncommreminder.class.php +++ b/htdocs/comm/action/class/actioncommreminder.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -75,20 +76,20 @@ class ActionCommReminder extends CommonObject // BEGIN MODULEBUILDER PROPERTIES /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( - 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), - 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), - 'dateremind' => array('type'=>'datetime', 'label'=>'DateRemind', 'visible'=>1, 'enabled'=>1, 'position'=>60, 'notnull'=>1, 'index'=>1,), - 'typeremind' => array('type'=>'varchar(32)', 'label'=>'TypeRemind', 'visible'=>-1, 'enabled'=>1, 'position'=>55, 'notnull'=>1, 'comment'=>"email, browser, sms",), - 'fk_user' => array('type'=>'integer', 'label'=>'User', 'visible'=>-1, 'enabled'=>1, 'position'=>65, 'notnull'=>1, 'index'=>1,), - 'offsetvalue' => array('type'=>'integer', 'label'=>'OffsetValue', 'visible'=>1, 'enabled'=>1, 'position'=>56, 'notnull'=>1,), - 'offsetunit' => array('type'=>'varchar(1)', 'label'=>'OffsetUnit', 'visible'=>1, 'enabled'=>1, 'position'=>57, 'notnull'=>1, 'comment'=>"y, m, d, w, h, i",), - 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>58, 'notnull'=>1, 'default'=>0, 'index'=>0, 'arrayofkeyval'=>array('0'=>'ToDo', '1'=>'Done')), - 'lasterror' => array('type'=>'varchar(128)', 'label'=>'LastError', 'visible'=>-1, 'enabled'=>1, 'position'=>59, 'index'=>0), - 'fk_actioncomm' => array('type'=>'integer', 'label'=>'Project', 'visible'=>1, 'enabled'=>1, 'position'=>70, 'notnull'=>1, 'index'=>1,), - 'fk_email_template' => array('type'=>'integer', 'label'=>'EmailTemplate', 'visible'=>1, 'enabled'=>1, 'position'=>80, 'notnull'=>0), + 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'visible' => -1, 'enabled' => 1, 'position' => 1, 'notnull' => 1, 'index' => 1, 'comment' => "Id",), + 'entity' => array('type' => 'integer', 'label' => 'Entity', 'visible' => 0, 'enabled' => 1, 'position' => 20, 'notnull' => 1, 'index' => 1,), + 'dateremind' => array('type' => 'datetime', 'label' => 'DateRemind', 'visible' => 1, 'enabled' => 1, 'position' => 60, 'notnull' => 1, 'index' => 1,), + 'typeremind' => array('type' => 'varchar(32)', 'label' => 'TypeRemind', 'visible' => -1, 'enabled' => 1, 'position' => 55, 'notnull' => 1, 'comment' => "email, browser, sms",), + 'fk_user' => array('type' => 'integer', 'label' => 'User', 'visible' => -1, 'enabled' => 1, 'position' => 65, 'notnull' => 1, 'index' => 1,), + 'offsetvalue' => array('type' => 'integer', 'label' => 'OffsetValue', 'visible' => 1, 'enabled' => 1, 'position' => 56, 'notnull' => 1,), + 'offsetunit' => array('type' => 'varchar(1)', 'label' => 'OffsetUnit', 'visible' => 1, 'enabled' => 1, 'position' => 57, 'notnull' => 1, 'comment' => "y, m, d, w, h, i",), + 'status' => array('type' => 'integer', 'label' => 'Status', 'visible' => 1, 'enabled' => 1, 'position' => 58, 'notnull' => 1, 'default' => 0, 'index' => 0, 'arrayofkeyval' => array('0' => 'ToDo', '1' => 'Done')), + 'lasterror' => array('type' => 'varchar(128)', 'label' => 'LastError', 'visible' => -1, 'enabled' => 1, 'position' => 59, 'index' => 0), + 'fk_actioncomm' => array('type' => 'integer', 'label' => 'Project', 'visible' => 1, 'enabled' => 1, 'position' => 70, 'notnull' => 1, 'index' => 1,), + 'fk_email_template' => array('type' => 'integer', 'label' => 'EmailTemplate', 'visible' => 1, 'enabled' => 1, 'position' => 80, 'notnull' => 0), ); /** diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php index ac9148579b1..d308ce7bd1c 100644 --- a/htdocs/comm/action/class/cactioncomm.class.php +++ b/htdocs/comm/action/class/cactioncomm.class.php @@ -192,9 +192,21 @@ class CActionComm $nump = $this->db->num_rows($resql); if ($nump) { $idforallfornewmodule = 96; - $TSystem = array(); - $TSystemAuto = array(); - $TModule = array(); + $TSystem = array( + 'id' => [], + 'code' => [], + 'all' => [] + ); + $TSystemAuto = array( + 'id' => [], + 'code' => [], + 'all' => [] + ); + $TModule = array( + 'id' => [], + 'code' => [], + 'all' => [] + ); $i = 0; while ($i < $nump) { $obj = $this->db->fetch_object($resql); @@ -228,7 +240,7 @@ class CActionComm if ($obj->module == 'order_supplier' && ((isModEnabled("fournisseur") && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight('fournisseur', 'commande', 'lire')) || (!isModEnabled('supplier_order') && $user->hasRight('supplier_order', 'lire')))) { $qualified = 1; } - if ($obj->module == 'shipping' && isModEnabled("delivery_note") && $user->hasRight('expedition', 'lire')) { + if ($obj->module == 'shipping' && isModEnabled("shipping") && $user->hasRight('expedition', 'lire')) { $qualified = 1; } // For case module = 'myobject@eventorganization' @@ -319,8 +331,8 @@ class CActionComm } if ($onlyautoornot > 0 && preg_match('/^module/', $obj->type) && $obj->module) { - $TModule['code'][$obj->code] .= ' ('.$langs->trans("Module").': '.$obj->module.')'; - $TModule['all'][$obj->code]['label'] .= ' ('.$langs->trans("Module").': '.$obj->module.')'; + array_key_exists($obj->code, $TModule['code']) ? ($TModule['code'][$obj->code] .= ' ('.$langs->trans("Module").': '.$obj->module.')') : ($TModule['code'][$obj->code] = ' ('.$langs->trans("Module").': '.$obj->module.')'); + array_key_exists($obj->code, $TModule['all']) ? ($TModule['all'][$obj->code]['label'] .= ' ('.$langs->trans("Module").': '.$obj->module.')') : ($TModule['all'][$obj->code]['label'] = ' ('.$langs->trans("Module").': '.$obj->module.')'); } } $i++; diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index f0843f3c990..68e6b4d7169 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -393,7 +393,7 @@ if ($actioncode || GETPOSTISSET('search_actioncode')) { } } if ($resourceid > 0) { - $param .= "&search_resourceid=".urlencode($resourceid); + $param .= "&search_resourceid=".urlencode((string) ($resourceid)); } if ($status || GETPOSTISSET('status') || GETPOSTISSET('search_status')) { $param .= "&search_status=".urlencode($status); @@ -405,26 +405,26 @@ if ($filtert) { $param .= "&search_filtert=".urlencode($filtert); } if ($usergroup > 0) { - $param .= "&search_usergroup=".urlencode($usergroup); + $param .= "&search_usergroup=".urlencode((string) ($usergroup)); } if ($socid > 0) { - $param .= "&search_socid=".urlencode($socid); + $param .= "&search_socid=".urlencode((string) ($socid)); } if ($showbirthday) { $param .= "&search_showbirthday=1"; } if ($pid) { - $param .= "&search_projectid=".urlencode($pid); + $param .= "&search_projectid=".urlencode((string) ($pid)); } if ($type) { $param .= "&search_type=".urlencode($type); } -$param .= "&maxprint=".urlencode($maxprint); +$param .= "&maxprint=".urlencode((string) ($maxprint)); if ($mode == 'show_day' || $mode == 'show_week' || $mode == 'show_month') { $param .= '&mode='.urlencode($mode); } if ($search_categ_cus != 0) { - $param .= '&search_categ_cus='.urlencode($search_categ_cus); + $param .= '&search_categ_cus='.urlencode((string) ($search_categ_cus)); } // Show navigation bar diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 03efd125979..eff2e4b3708 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -316,7 +316,7 @@ if ($actioncode != '') { } } if ($resourceid > 0) { - $param .= "&search_resourceid=".urlencode($resourceid); + $param .= "&search_resourceid=".urlencode((string) ($resourceid)); } if ($search_status != '') { $param .= "&search_status=".urlencode($search_status); @@ -328,16 +328,16 @@ if ($filtert) { $param .= "&search_filtert=".urlencode($filtert); } if ($usergroup > 0) { - $param .= "&search_usergroup=".urlencode($usergroup); + $param .= "&search_usergroup=".urlencode((string) ($usergroup)); } if ($socid > 0) { - $param .= "&search_socid=".urlencode($socid); + $param .= "&search_socid=".urlencode((string) ($socid)); } if ($showbirthday) { $param .= "&search_showbirthday=1"; } if ($pid) { - $param .= "&search_projectid=".urlencode($pid); + $param .= "&search_projectid=".urlencode((string) ($pid)); } if ($type) { $param .= "&search_type=".urlencode($type); @@ -391,7 +391,7 @@ if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } if ($search_categ_cus != 0) { - $param .= '&search_categ_cus='.urlencode($search_categ_cus); + $param .= '&search_categ_cus='.urlencode((string) ($search_categ_cus)); } // Add $param from extra fields diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 9bbdd243f12..7bb071f036c 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -286,7 +286,7 @@ if ($actioncode || GETPOSTISSET('search_actioncode')) { } } if ($resourceid > 0) { - $param .= "&search_resourceid=".urlencode($resourceid); + $param .= "&search_resourceid=".urlencode((string) ($resourceid)); } if ($status || GETPOSTISSET('status') || GETPOSTISSET('search_status')) { $param .= "&search_status=".urlencode($status); @@ -298,16 +298,16 @@ if ($filtert) { $param .= "&search_filtert=".urlencode($filtert); } if ($usergroup > 0) { - $param .= "&search_usergroup=".urlencode($usergroup); + $param .= "&search_usergroup=".urlencode((string) ($usergroup)); } if ($socid > 0) { - $param .= "&search_socid=".urlencode($socid); + $param .= "&search_socid=".urlencode((string) ($socid)); } if ($showbirthday) { $param .= "&search_showbirthday=1"; } if ($pid) { - $param .= "&search_projectid=".urlencode($pid); + $param .= "&search_projectid=".urlencode((string) ($pid)); } if ($type) { $param .= "&search_type=".urlencode($type); @@ -322,12 +322,12 @@ if ($end_h != '') { $param .= '&end_h='.urlencode($end_h); } if ($begin_d != '') { - $param .= '&begin_d='.urlencode($begin_d); + $param .= '&begin_d='.urlencode((string) ($begin_d)); } if ($end_d != '') { - $param .= '&end_d='.urlencode($end_d); + $param .= '&end_d='.urlencode((string) ($end_d)); } -$param .= "&maxprint=".urlencode($maxprint); +$param .= "&maxprint=".urlencode((string) ($maxprint)); $paramnoactionodate = $param; @@ -374,7 +374,7 @@ $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); $nav .= ' '; // Must be after the nav definition -$param .= '&year='.urlencode($year).'&month='.urlencode($month).($day ? '&day='.urlencode($day) : ''); +$param .= '&year='.urlencode((string) ($year)).'&month='.urlencode((string) ($month)).($day ? '&day='.urlencode((string) ($day)) : ''); //print 'x'.$param; @@ -695,20 +695,11 @@ if ($resql) { // Defined date_start_in_calendar and date_end_in_calendar property // They are date start and end of action but modified to not be outside calendar view. - if ($event->percentage <= 0) { - $event->date_start_in_calendar = $datep; - if ($datep2 != '' && $datep2 >= $datep) { - $event->date_end_in_calendar = $datep2; - } else { - $event->date_end_in_calendar = $datep; - } + $event->date_start_in_calendar = $datep; + if ($datep2 != '' && $datep2 >= $datep) { + $event->date_end_in_calendar = $datep2; } else { - $event->date_start_in_calendar = $datep; - if ($datep2 != '' && $datep2 >= $datep) { - $event->date_end_in_calendar = $datep2; - } else { - $event->date_end_in_calendar = $datep; - } + $event->date_end_in_calendar = $datep; } // Check values diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 76025723dde..c191a6c35be 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -282,7 +282,7 @@ if ($actioncode || GETPOSTISSET('search_actioncode')) { } } if ($resourceid > 0) { - $param .= "&search_resourceid=".urlencode($resourceid); + $param .= "&search_resourceid=".urlencode((string) ($resourceid)); } if ($status || GETPOSTISSET('status') || GETPOSTISSET('search_status')) { @@ -295,16 +295,16 @@ if ($filtert) { $param .= "&search_filtert=".urlencode($filtert); } if ($usergroup > 0) { - $param .= "&search_usergroup=".urlencode($usergroup); + $param .= "&search_usergroup=".urlencode((string) ($usergroup)); } if ($socid > 0) { - $param .= "&search_socid=".urlencode($socid); + $param .= "&search_socid=".urlencode((string) ($socid)); } if ($showbirthday) { $param .= "&search_showbirthday=1"; } if ($pid) { - $param .= "&search_projectid=".urlencode($pid); + $param .= "&search_projectid=".urlencode((string) ($pid)); } if ($type) { $param .= "&search_type=".urlencode($type); @@ -325,9 +325,9 @@ if ($end_d != '') { $param .= '&end_d='.urlencode($end_d); } if ($search_categ_cus != 0) { - $param .= '&search_categ_cus='.urlencode($search_categ_cus); + $param .= '&search_categ_cus='.urlencode((string) ($search_categ_cus)); } -$param .= "&maxprint=".urlencode($maxprint); +$param .= "&maxprint=".urlencode((string) ($maxprint)); $paramnoactionodate = $param; @@ -377,7 +377,7 @@ $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); $nav .= ' '; // Must be after the nav definition -$param .= '&year='.urlencode($year).'&month='.urlencode($month).($day ? '&day='.urlencode($day) : ''); +$param .= '&year='.urlencode((string) ($year)).'&month='.urlencode((string) ($month)).($day ? '&day='.urlencode((string) ($day)) : ''); //print 'x'.$param; @@ -714,20 +714,11 @@ if ($resql) { // Defined date_start_in_calendar and date_end_in_calendar property // They are date start and end of action but modified to not be outside calendar view. - if ($event->percentage <= 0) { - $event->date_start_in_calendar = $datep; - if ($datep2 != '' && $datep2 >= $datep) { - $event->date_end_in_calendar = $datep2; - } else { - $event->date_end_in_calendar = $datep; - } + $event->date_start_in_calendar = $datep; + if ($datep2 != '' && $datep2 >= $datep) { + $event->date_end_in_calendar = $datep2; } else { - $event->date_start_in_calendar = $datep; - if ($datep2 != '' && $datep2 >= $datep) { - $event->date_end_in_calendar = $datep2; - } else { - $event->date_end_in_calendar = $datep; - } + $event->date_end_in_calendar = $datep; } //print '
'.$i.' - eventid='.$event->id.' '.dol_print_date($event->date_start_in_calendar, 'dayhour').' '.dol_print_date($firstdaytoshow, 'dayhour').' - '.dol_print_date($event->date_end_in_calendar, 'dayhour').' '.dol_print_date($lastdaytoshow, 'dayhour').'
'."\n"; diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 4a20bf2dc9e..796f17e710c 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -52,7 +52,7 @@ if (isModEnabled("propal")) { if (isModEnabled('order')) { require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; } -if (isModEnabled("delivery_note")) { +if (isModEnabled("shipping")) { require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; } if (isModEnabled('contract')) { @@ -74,7 +74,7 @@ if (isModEnabled('contract')) { if (isModEnabled('order')) { $langs->load("orders"); } -if (isModEnabled("delivery_note")) { +if (isModEnabled("shipping")) { $langs->load("sendings"); } if (isModEnabled('invoice')) { @@ -1029,7 +1029,7 @@ if ($object->id > 0) { /* * Latest shipments */ - if (isModEnabled("delivery_note") && $user->hasRight('expedition', 'lire')) { + if (isModEnabled("shipping") && $user->hasRight('expedition', 'lire')) { $sql = 'SELECT e.rowid as id'; $sql .= ', e.ref, e.entity'; $sql .= ', e.date_creation'; diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index b8cb4c1f8d3..559530a6873 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2019 Laurent Destailleur * Copyright (C) 2005-2016 Regis Houssin * Copyright (C) 2021 Waël Almoman + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -70,7 +71,7 @@ $signature = ((!empty($user->signature) && !getDolGlobalString('MAIN_MAIL_DO_NOT $targetobject = null; // Not defined with mass emailing -$parameters = array('mode'=>'emailing'); +$parameters = array('mode' => 'emailing'); $substitutionarray = FormMail::getAvailableSubstitKey('emailing', $targetobject); $object->substitutionarrayfortest = $substitutionarray; @@ -237,7 +238,7 @@ if (empty($reshook)) { $signature = ((!empty($user->signature) && !getDolGlobalString('MAIN_MAIL_DO_NOT_USE_SIGN')) ? $user->signature : ''); - $parameters = array('mode'=>'emailing'); + $parameters = array('mode' => 'emailing'); $substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount'), $targetobject); // Note: On mass emailing, this is null because be don't know object // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) @@ -437,19 +438,14 @@ if (empty($reshook)) { // Loop finished, set global statut of mail if ($nbko > 0) { $statut = 2; // Status 'sent partially' (because at least one error) - if ($nbok > 0) { - setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); - } else { - setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); - } + setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); } else { if ($nbok >= $num) { $statut = 3; // Send to everybody - setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); } else { $statut = 2; // Status 'sent partially' (because not send to everybody) - setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); } + setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); } $sql = "UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".((int) $statut)." WHERE rowid = ".((int) $object->id); @@ -488,7 +484,7 @@ if (empty($reshook)) { $signature = ((!empty($user->signature) && !getDolGlobalString('MAIN_MAIL_DO_NOT_USE_SIGN')) ? $user->signature : ''); - $parameters = array('mode'=>'emailing'); + $parameters = array('mode' => 'emailing'); $substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount'), $targetobject); // Note: On mass emailing, this is null because be don't know object // other are set at begin of page @@ -536,7 +532,7 @@ if (empty($reshook)) { setEventMessages($langs->trans("MailSuccessfulySent", $mailfile->getValidAddress($object->email_from, 2), $mailfile->getValidAddress($object->sendto, 2)), null, 'mesgs'); $action = ''; } else { - setEventMessages($langs->trans("ResultKo").'
'.$mailfile->error.' '.$result, null, 'errors'); + setEventMessages($langs->trans("ResultKo").'
'.$mailfile->error.' '.json_encode($result), null, 'errors'); $action = 'test'; } } @@ -849,6 +845,63 @@ if ($action == 'create') { print $htmlother->selectColor(GETPOST('bgcolor'), 'bgcolor', '', 0); print '
'; + $out = ''; + // Add link to add layout + if ($formmail->withlayout && $formmail->withfckeditor) { + $out .= ''; + $out .= img_picto($langs->trans("FillMessageWithALayout"), 'layout', 'class="paddingrightonly"'); + $out .= $langs->trans("FillMessageWithALayout").'...'; + $out .= '     '; + + $out .= ' + '; + } + + // Add link to add AI content + if ($formmail->withaiprompt && isModEnabled('ai')) { + $out .= ''; + $out .= img_picto($langs->trans("FillMessageWithAIContent"), 'ai', 'class="paddingrightonly"'); + $out .= $langs->trans("FillMessageWithAIContent").'...'; + $out .= ''; + $out .= ''; + } + if ($formmail->withfckeditor) { + $out .= $formmail->getModelEmailTemplate(); + } + if ($formmail->withaiprompt && isModEnabled('ai')) { + $out .= $formmail->getSectionForAIPrompt(); + } + print $out; + print '
'; print '
'; @@ -883,7 +936,7 @@ if ($action == 'create') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id.(!empty($urlfrom) ? '&urlfrom='.urlencode($urlfrom) : ''), $langs->trans("DeleteMailing"), $langs->trans("ConfirmDeleteMailing"), "confirm_delete", '', '', 1); } - if ($action != 'edit' && $action != 'edittxt' &&$action != 'edithtml') { + if ($action != 'edit' && $action != 'edittxt' && $action != 'edithtml') { print dol_get_fiche_head($head, 'card', $langs->trans("Mailing"), -1, 'email'); /* @@ -1098,8 +1151,8 @@ if ($action == 'create') { // Create an array for form $formquestion = array( 'text' => $langs->trans("ConfirmClone"), - array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneContent"), 'value' => 1), - array('type' => 'checkbox', 'name' => 'clone_receivers', 'label' => $langs->trans("CloneReceivers"), 'value' => 0) + 0 => array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneContent"), 'value' => 1), + 1 => array('type' => 'checkbox', 'name' => 'clone_receivers', 'label' => $langs->trans("CloneReceivers"), 'value' => 0) ); // Incomplete payment. On demande si motif = escompte ou autre print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneEMailing', $object->ref), 'confirm_clone', $formquestion, 'yes', 2, 240); @@ -1190,7 +1243,7 @@ if ($action == 'create') { $formmail = new FormMail($db); $formmail->fromname = $object->email_from; $formmail->frommail = $object->email_from; - $formmail->withsubstit =0; + $formmail->withsubstit = 0; $formmail->withfrom = 0; $formmail->withto = $user->email ? $user->email : 1; $formmail->withtocc = 0; @@ -1199,7 +1252,7 @@ if ($action == 'create') { $formmail->withtopicreadonly = 1; $formmail->withfile = 0; $formmail->withlayout = 0; - $formmail->withaiprompt = 0; + $formmail->withaiprompt = ''; $formmail->withbody = 0; $formmail->withbodyreadonly = 1; $formmail->withcancel = 1; diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 4096d3ae161..95ffc1f0c38 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -752,7 +752,7 @@ if ($object->fetch($id) >= 0) { print ''; if ($page) { - $param .= "&page=".urlencode($page); + $param .= "&page=".urlencode((string) ($page)); } print ''; diff --git a/htdocs/comm/propal/agenda.php b/htdocs/comm/propal/agenda.php index a61ed2e0270..1fe3cf6d5dd 100644 --- a/htdocs/comm/propal/agenda.php +++ b/htdocs/comm/propal/agenda.php @@ -96,7 +96,7 @@ restrictedArea($user, 'propal', $object->id, '', '', 'fk_soc', 'rowid', $isdraft * Actions */ -$parameters = array('id'=>$id); +$parameters = array('id' => $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'); @@ -191,14 +191,14 @@ if ($object->id > 0) { $objthirdparty = $object; $objcon = new stdClass(); - $out = '&origin='.urlencode($object->element.(property_exists($object, 'module') ? '@'.$object->module : '')).'&originid='.urlencode($object->id); + $out = '&origin='.urlencode((string) ($object->element.(property_exists($object, 'module') ? '@'.$object->module : ''))).'&originid='.urlencode((string) ($object->id)); $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id; $out .= '&backtopage='.urlencode($urlbacktopage); $permok = $user->hasRight('agenda', 'myactions', 'create'); if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.='id.'&action='.$action.'&origin='.urlencode(GETPOST('origin')).'&originid='.urlencode(GETPOSTINT('originid')); + $backtopage = $_SERVER["PHP_SELF"].'?socid='.$thirdparty->id.'&action='.$action.'&origin='.urlencode((string) (GETPOST('origin'))).'&originid='.urlencode((string) (GETPOSTINT('originid'))); include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; print ''; } @@ -2004,7 +2004,7 @@ if ($action == 'create') { print ''; // Shipping Method - if (isModEnabled("delivery_note")) { + if (isModEnabled("shipping")) { if (getDolGlobalString('SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($soc->shipping_method_id)) { $shipping_method_id = $soc->shipping_method_id; } @@ -2695,7 +2695,7 @@ if ($action == 'create') { print ''; // Shipping Method - if (isModEnabled("delivery_note")) { + if (isModEnabled("shipping")) { print ''; print ''; print ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print ''; + $object->multicurrency_total_localtax1 = price2num($object->total_localtax1 * $object->multicurrency_tx, 'MT'); + + print ''; } print ''; + } - if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) { - print ''; - print ''; - print ''; - if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print ''; - } - print ''; + if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) { + print ''; + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + $object->multicurrency_total_localtax2 = price2num($object->total_localtax2 * $object->multicurrency_tx, 'MT'); + + print ''; } + print ''; } print ''; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 5097273a833..00311e60480 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -19,6 +19,7 @@ * Copyright (C) 2022 OpenDSI * Copyright (C) 2022 Gauthier VERDOL * Copyright (C) 2023 William Mead + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -280,18 +281,6 @@ class Propal extends CommonObject public $labelStatus = array(); public $labelStatusShort = array(); - // Multicurrency - /** - * @var int ID - */ - public $fk_multicurrency; - - public $multicurrency_code; - public $multicurrency_tx; - public $multicurrency_total_ht; - public $multicurrency_total_tva; - public $multicurrency_total_ttc; - /** * 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') @@ -319,7 +308,7 @@ class Propal extends CommonObject // BEGIN MODULEBUILDER PROPERTIES /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 10), @@ -672,7 +661,6 @@ class Propal extends CommonObject // Clean vat code $reg = array(); $vat_src_code = ''; - $reg = array(); if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 2bc33b37f3f..911d866b671 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -17,6 +17,7 @@ * Copyright (C) 2021 Anthony Berton * Copyright (C) 2021 Frédéric France * Copyright (C) 2022 Josep Lluís Amador + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -58,7 +59,7 @@ if (isModEnabled('category')) { // Load translation files required by the page $langs->loadLangs(array('companies', 'propal', 'compta', 'bills', 'orders', 'products', 'deliveries', 'categories')); -if (isModEnabled("delivery_note")) { +if (isModEnabled("shipping")) { $langs->loadLangs(array('sendings')); } @@ -77,7 +78,9 @@ $mode = GETPOST('mode', 'alpha'); // Search Fields $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_user = GETPOSTINT('search_user'); -if ($search_user==-1) $search_user=0; +if ($search_user == -1) { + $search_user = 0; +} $search_sale = GETPOSTINT('search_sale'); $search_ref = GETPOST('sf_ref') ? GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha'); $search_refcustomer = GETPOST('search_refcustomer', 'alpha'); @@ -190,14 +193,14 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // List of fields to search into when doing a "search in all" $fieldstosearchall = array( - 'p.ref'=>'Ref', - 'p.ref_client'=>'RefCustomer', - 'pd.description'=>'Description', - 's.nom'=>"ThirdParty", - 's.name_alias'=>"AliasNameShort", - 's.zip'=>"Zip", - 's.town'=>"Town", - 'p.note_public'=>'NotePublic', + 'p.ref' => 'Ref', + 'p.ref_client' => 'RefCustomer', + 'pd.description' => 'Description', + 's.nom' => "ThirdParty", + 's.name_alias' => "AliasNameShort", + 's.zip' => "Zip", + 's.town' => "Town", + 'p.note_public' => 'NotePublic', ); if (empty($user->socid)) { $fieldstosearchall["p.note_private"] = "NotePrivate"; @@ -206,50 +209,50 @@ if (empty($user->socid)) { $checkedtypetiers = 0; $arrayfields = array( - 'p.ref'=>array('label'=>"Ref", 'checked'=>1), - 'p.ref_client'=>array('label'=>"RefCustomer", 'checked'=>-1), - 'pr.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(isModEnabled('project') ? 1 : 0)), - 'pr.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(isModEnabled('project') ? 1 : 0)), - 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1), - 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>-1), - 's.town'=>array('label'=>"Town", 'checked'=>-1), - 's.zip'=>array('label'=>"Zip", 'checked'=>-1), - 'state.nom'=>array('label'=>"StateShort", 'checked'=>0), - 'country.code_iso'=>array('label'=>"Country", 'checked'=>0), - 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers), - 'p.date'=>array('label'=>"DatePropal", 'checked'=>1), - 'p.fin_validite'=>array('label'=>"DateEnd", 'checked'=>1), - 'p.date_livraison'=>array('label'=>"DeliveryDate", 'checked'=>0), - 'p.date_signature'=>array('label'=>"DateSigning", 'checked'=>0), - 'ava.rowid'=>array('label'=>"AvailabilityPeriod", 'checked'=>0), - 'p.fk_shipping_method'=>array('label'=>"SendingMethod", 'checked'=>0, 'enabled'=>isModEnabled("delivery_note")), - 'p.fk_input_reason'=>array('label'=>"Origin", 'checked'=>0, 'enabled'=>1), - 'p.fk_cond_reglement'=>array('label'=>"PaymentConditionsShort", 'checked'=>0), - 'p.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>0), - 'p.total_ht'=>array('label'=>"AmountHT", 'checked'=>1), - 'p.total_tva'=>array('label'=>"AmountVAT", 'checked'=>0), - 'p.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0), - 'p.total_ht_invoiced'=>array('label'=>"AmountInvoicedHT", 'checked'=>0, 'enabled'=>getDolGlobalString('PROPOSAL_SHOW_INVOICED_AMOUNT')), - 'p.total_invoiced'=>array('label'=>"AmountInvoicedTTC", 'checked'=>0, 'enabled'=>getDolGlobalString('PROPOSAL_SHOW_INVOICED_AMOUNT')), - 'p.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1)), - 'p.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1)), - 'p.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1)), - 'p.multicurrency_total_tva'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1)), - 'p.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1)), - 'p.multicurrency_total_ht_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedHT', 'checked'=>0, 'enabled'=>isModEnabled("multicurrency") && getDolGlobalString('PROPOSAL_SHOW_INVOICED_AMOUNT')), - 'p.multicurrency_total_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedTTC', 'checked'=>0, 'enabled'=>isModEnabled("multicurrency") && getDolGlobalString('PROPOSAL_SHOW_INVOICED_AMOUNT')), - 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10), - 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>-1), + 'p.ref' => array('label' => "Ref", 'checked' => 1), + 'p.ref_client' => array('label' => "RefCustomer", 'checked' => -1), + 'pr.ref' => array('label' => "ProjectRef", 'checked' => 1, 'enabled' => (isModEnabled('project') ? 1 : 0)), + 'pr.title' => array('label' => "ProjectLabel", 'checked' => 0, 'enabled' => (isModEnabled('project') ? 1 : 0)), + 's.nom' => array('label' => "ThirdParty", 'checked' => 1), + 's.name_alias' => array('label' => "AliasNameShort", 'checked' => -1), + 's.town' => array('label' => "Town", 'checked' => -1), + 's.zip' => array('label' => "Zip", 'checked' => -1), + 'state.nom' => array('label' => "StateShort", 'checked' => 0), + 'country.code_iso' => array('label' => "Country", 'checked' => 0), + 'typent.code' => array('label' => "ThirdPartyType", 'checked' => $checkedtypetiers), + 'p.date' => array('label' => "DatePropal", 'checked' => 1), + 'p.fin_validite' => array('label' => "DateEnd", 'checked' => 1), + 'p.date_livraison' => array('label' => "DeliveryDate", 'checked' => 0), + 'p.date_signature' => array('label' => "DateSigning", 'checked' => 0), + 'ava.rowid' => array('label' => "AvailabilityPeriod", 'checked' => 0), + 'p.fk_shipping_method' => array('label' => "SendingMethod", 'checked' => 0, 'enabled' => isModEnabled("shipping")), + 'p.fk_input_reason' => array('label' => "Origin", 'checked' => 0, 'enabled' => 1), + 'p.fk_cond_reglement' => array('label' => "PaymentConditionsShort", 'checked' => 0), + 'p.fk_mode_reglement' => array('label' => "PaymentMode", 'checked' => 0), + 'p.total_ht' => array('label' => "AmountHT", 'checked' => 1), + 'p.total_tva' => array('label' => "AmountVAT", 'checked' => 0), + 'p.total_ttc' => array('label' => "AmountTTC", 'checked' => 0), + 'p.total_ht_invoiced' => array('label' => "AmountInvoicedHT", 'checked' => 0, 'enabled' => getDolGlobalString('PROPOSAL_SHOW_INVOICED_AMOUNT')), + 'p.total_invoiced' => array('label' => "AmountInvoicedTTC", 'checked' => 0, 'enabled' => getDolGlobalString('PROPOSAL_SHOW_INVOICED_AMOUNT')), + 'p.multicurrency_code' => array('label' => 'Currency', 'checked' => 0, 'enabled' => (!isModEnabled("multicurrency") ? 0 : 1)), + 'p.multicurrency_tx' => array('label' => 'CurrencyRate', 'checked' => 0, 'enabled' => (!isModEnabled("multicurrency") ? 0 : 1)), + 'p.multicurrency_total_ht' => array('label' => 'MulticurrencyAmountHT', 'checked' => 0, 'enabled' => (!isModEnabled("multicurrency") ? 0 : 1)), + 'p.multicurrency_total_tva' => array('label' => 'MulticurrencyAmountVAT', 'checked' => 0, 'enabled' => (!isModEnabled("multicurrency") ? 0 : 1)), + 'p.multicurrency_total_ttc' => array('label' => 'MulticurrencyAmountTTC', 'checked' => 0, 'enabled' => (!isModEnabled("multicurrency") ? 0 : 1)), + 'p.multicurrency_total_ht_invoiced' => array('label' => 'MulticurrencyAmountInvoicedHT', 'checked' => 0, 'enabled' => isModEnabled("multicurrency") && getDolGlobalString('PROPOSAL_SHOW_INVOICED_AMOUNT')), + 'p.multicurrency_total_invoiced' => array('label' => 'MulticurrencyAmountInvoicedTTC', 'checked' => 0, 'enabled' => isModEnabled("multicurrency") && getDolGlobalString('PROPOSAL_SHOW_INVOICED_AMOUNT')), + 'u.login' => array('label' => "Author", 'checked' => 1, 'position' => 10), + 'sale_representative' => array('label' => "SaleRepresentativesOfThirdParty", 'checked' => -1), 'total_pa' => array('label' => (getDolGlobalString('MARGIN_TYPE') == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (!isModEnabled('margin') || !$user->hasRight('margins', 'liretous') ? 0 : 1)), 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (!isModEnabled('margin') || !$user->hasRight('margins', 'liretous') ? 0 : 1)), 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (!isModEnabled('margin') || !$user->hasRight('margins', 'liretous') || !getDolGlobalString('DISPLAY_MARGIN_RATES') ? 0 : 1)), 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (!isModEnabled('margin') || !$user->hasRight('margins', 'liretous') || !getDolGlobalString('DISPLAY_MARK_RATES') ? 0 : 1)), - 'p.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), - 'p.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), - 'p.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500), - 'p.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'position'=>510, 'enabled'=>(!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES'))), - 'p.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'position'=>511, 'enabled'=>(!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES'))), - 'p.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), + 'p.datec' => array('label' => "DateCreation", 'checked' => 0, 'position' => 500), + 'p.tms' => array('label' => "DateModificationShort", 'checked' => 0, 'position' => 500), + 'p.date_cloture' => array('label' => "DateClosing", 'checked' => 0, 'position' => 500), + 'p.note_public' => array('label' => 'NotePublic', 'checked' => 0, 'position' => 510, 'enabled' => (!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES'))), + 'p.note_private' => array('label' => 'NotePrivate', 'checked' => 0, 'position' => 511, 'enabled' => (!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES'))), + 'p.fk_statut' => array('label' => "Status", 'checked' => 1, 'position' => 1000), ); // List of fields to search into when doing a "search in all" @@ -310,7 +313,7 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa $massaction = ''; } -$parameters = array('socid'=>$socid, 'arrayfields'=>&$arrayfields); +$parameters = array('socid' => $socid, 'arrayfields' => &$arrayfields); $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'); @@ -518,11 +521,7 @@ if (!$error && $massaction === 'setbilled' && $permissiontoclose) { } if (!$error) { - if ($nbok > 1) { - setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - } else { - setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - } + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); $db->commit(); } else { $db->rollback(); @@ -843,8 +842,8 @@ if (!$resql) { exit; } - $objectstatic = new Propal($db); - $userstatic = new User($db); +$objectstatic = new Propal($db); +$userstatic = new User($db); if ($socid > 0) { $soc = new Societe($db); @@ -857,9 +856,9 @@ if ($socid > 0) { $title = $langs->trans('Proposals'); } - $num = $db->num_rows($resql); +$num = $db->num_rows($resql); - $arrayofselected = is_array($toselect) ? $toselect : array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all) { $obj = $db->fetch_object($resql); @@ -870,10 +869,10 @@ if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $s exit; } - $help_url = 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'; - llxHeader('', $title, $help_url); +$help_url = 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'; +llxHeader('', $title, $help_url); - $param = '&search_status='.urlencode($search_status); +$param = '&search_status='.urlencode($search_status); if (!empty($mode)) { $param .= '&mode='.urlencode($mode); } @@ -887,58 +886,58 @@ if ($search_all) { $param .= '&search_all='.urlencode($search_all); } if ($search_date_startday) { - $param .= '&search_date_startday='.urlencode($search_date_startday); + $param .= '&search_date_startday='.urlencode((string) ($search_date_startday)); } if ($search_date_startmonth) { - $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); + $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth)); } if ($search_date_startyear) { - $param .= '&search_date_startyear='.urlencode($search_date_startyear); + $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear)); } if ($search_date_endday) { - $param .= '&search_date_endday='.urlencode($search_date_endday); + $param .= '&search_date_endday='.urlencode((string) ($search_date_endday)); } if ($search_date_endmonth) { - $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); + $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth)); } if ($search_date_endyear) { - $param .= '&search_date_endyear='.urlencode($search_date_endyear); + $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear)); } if ($search_date_end_startday) { - $param .= '&search_date_end_startday='.urlencode($search_date_end_startday); + $param .= '&search_date_end_startday='.urlencode((string) ($search_date_end_startday)); } if ($search_date_end_startmonth) { - $param .= '&search_date_end_startmonth='.urlencode($search_date_end_startmonth); + $param .= '&search_date_end_startmonth='.urlencode((string) ($search_date_end_startmonth)); } if ($search_date_end_startyear) { - $param .= '&search_date_end_startyear='.urlencode($search_date_end_startyear); + $param .= '&search_date_end_startyear='.urlencode((string) ($search_date_end_startyear)); } if ($search_date_end_endday) { - $param .= '&search_date_end_endday='.urlencode($search_date_end_endday); + $param .= '&search_date_end_endday='.urlencode((string) ($search_date_end_endday)); } if ($search_date_end_endmonth) { - $param .= '&search_date_end_endmonth='.urlencode($search_date_end_endmonth); + $param .= '&search_date_end_endmonth='.urlencode((string) ($search_date_end_endmonth)); } if ($search_date_end_endyear) { - $param .= '&search_date_end_endyear='.urlencode($search_date_end_endyear); + $param .= '&search_date_end_endyear='.urlencode((string) ($search_date_end_endyear)); } if ($search_date_delivery_startday) { - $param .= '&search_date_delivery_startday='.urlencode($search_date_delivery_startday); + $param .= '&search_date_delivery_startday='.urlencode((string) ($search_date_delivery_startday)); } if ($search_date_delivery_startmonth) { - $param .= '&search_date_delivery_startmonth='.urlencode($search_date_delivery_startmonth); + $param .= '&search_date_delivery_startmonth='.urlencode((string) ($search_date_delivery_startmonth)); } if ($search_date_delivery_startyear) { - $param .= '&search_date_delivery_startyear='.urlencode($search_date_delivery_startyear); + $param .= '&search_date_delivery_startyear='.urlencode((string) ($search_date_delivery_startyear)); } if ($search_date_delivery_endday) { - $param .= '&search_date_delivery_endday='.urlencode($search_date_delivery_endday); + $param .= '&search_date_delivery_endday='.urlencode((string) ($search_date_delivery_endday)); } if ($search_date_delivery_endmonth) { - $param .= '&search_date_delivery_endmonth='.urlencode($search_date_delivery_endmonth); + $param .= '&search_date_delivery_endmonth='.urlencode((string) ($search_date_delivery_endmonth)); } if ($search_date_delivery_endyear) { - $param .= '&search_date_delivery_endyear='.urlencode($search_date_delivery_endyear); + $param .= '&search_date_delivery_endyear='.urlencode((string) ($search_date_delivery_endyear)); } if ($search_ref) { $param .= '&search_ref='.urlencode($search_ref); @@ -956,7 +955,7 @@ if ($search_societe_alias) { $param .= '&search_societe_alias='.urlencode($search_societe_alias); } if ($search_user > 0) { - $param .= '&search_user='.urlencode($search_user); + $param .= '&search_user='.urlencode((string) ($search_user)); } if ($search_sale > 0) { $param .= '&search_sale='.urlencode($search_sale); @@ -989,31 +988,31 @@ if ($search_zip) { $param .= '&search_zip='.urlencode($search_zip); } if ($socid > 0) { - $param .= '&socid='.urlencode($socid); + $param .= '&socid='.urlencode((string) ($socid)); } if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } if ($search_categ_cus > 0) { - $param .= '&search_categ_cus='.urlencode($search_categ_cus); + $param .= '&search_categ_cus='.urlencode((string) ($search_categ_cus)); } if ($search_product_category != '') { - $param .= '&search_product_category='.urlencode($search_product_category); + $param .= '&search_product_category='.urlencode((string) ($search_product_category)); } if ($search_fk_cond_reglement > 0) { - $param .= '&search_fk_cond_reglement='.urlencode($search_fk_cond_reglement); + $param .= '&search_fk_cond_reglement='.urlencode((string) ($search_fk_cond_reglement)); } if ($search_fk_shipping_method > 0) { - $param .= '&search_fk_shipping_method='.urlencode($search_fk_shipping_method); + $param .= '&search_fk_shipping_method='.urlencode((string) ($search_fk_shipping_method)); } if ($search_fk_input_reason > 0) { - $param .= '&search_fk_input_reason='.urlencode($search_fk_input_reason); + $param .= '&search_fk_input_reason='.urlencode((string) ($search_fk_input_reason)); } if ($search_fk_mode_reglement > 0) { - $param .= '&search_fk_mode_reglement='.urlencode($search_fk_mode_reglement); + $param .= '&search_fk_mode_reglement='.urlencode((string) ($search_fk_mode_reglement)); } if ($search_type_thirdparty > 0) { - $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); + $param .= '&search_type_thirdparty='.urlencode((string) ($search_type_thirdparty)); } if ($search_town) { $param .= '&search_town='.urlencode($search_town); @@ -1028,1383 +1027,1383 @@ if ($search_town) { $param .= '&search_town='.urlencode($search_town); } if ($search_country) { - $param .= '&search_country='.urlencode($search_country); + $param .= '&search_country='.urlencode((string) ($search_country)); } if ($search_date_signature_startday) { - $param .= '&search_date_signature_startday='.urlencode($search_date_signature_startday); + $param .= '&search_date_signature_startday='.urlencode((string) ($search_date_signature_startday)); } if ($search_date_signature_startmonth) { - $param .= '&search_date_signature_startmonth='.urlencode($search_date_signature_startmonth); + $param .= '&search_date_signature_startmonth='.urlencode((string) ($search_date_signature_startmonth)); } if ($search_date_signature_startyear) { - $param .= '&search_date_signature_startyear='.urlencode($search_date_signature_startyear); + $param .= '&search_date_signature_startyear='.urlencode((string) ($search_date_signature_startyear)); } if ($search_date_signature_endday) { - $param .= '&search_date_signature_endday='.urlencode($search_date_signature_endday); + $param .= '&search_date_signature_endday='.urlencode((string) ($search_date_signature_endday)); } if ($search_date_signature_endmonth) { - $param .= '&search_date_signature_endmonth='.urlencode($search_date_signature_endmonth); + $param .= '&search_date_signature_endmonth='.urlencode((string) ($search_date_signature_endmonth)); } if ($search_date_signature_endyear) { - $param .= '&search_date_signature_endyear='.urlencode($search_date_signature_endyear); + $param .= '&search_date_signature_endyear='.urlencode((string) ($search_date_signature_endyear)); } - // Add $param from extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - // Add $param from hooks - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - $param .= $hookmanager->resPrint; +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; +// Add $param from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$param .= $hookmanager->resPrint; - // List of mass actions available - $arrayofmassactions = array( - 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), - 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), - ); - if ($permissiontosendbymail) { - $arrayofmassactions['presend']=img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"); +// List of mass actions available +$arrayofmassactions = array( + 'generate_doc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), + 'builddoc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), +); +if ($permissiontosendbymail) { + $arrayofmassactions['presend'] = img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"); +} +if ($permissiontovalidate) { + $arrayofmassactions['prevalidate'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"); +} +if ($permissiontoclose) { + $arrayofmassactions['presign'] = img_picto('', 'propal', 'class="pictofixedwidth"').$langs->trans("Sign"); + $arrayofmassactions['nopresign'] = img_picto('', 'propal', 'class="pictofixedwidth"').$langs->trans("NoSign"); + $arrayofmassactions['setbilled'] = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("ClassifyBilled"); +} +if ($permissiontodelete) { + $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); +} + +if (in_array($massaction, array('presend', 'predelete', 'closed'))) { + $arrayofmassactions = array(); +} +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); + +$url = DOL_URL_ROOT.'/comm/propal/card.php?action=create'; +if (!empty($socid)) { + $url .= '&socid='.$socid; +} +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition')); +$newcardbutton .= dolGetButtonTitleSeparator(); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewPropal'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('propal', 'creer')); + +// Fields title search +print '
'; +if ($optioncss != '') { + print ''; +} +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'propal', 0, $newcardbutton, '', $limit, 0, 0, 1); + +$topicmail = "SendPropalRef"; +$modelmail = "propal_send"; +$objecttmp = new Propal($db); +$trackid = 'pro'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + +if ($massaction == 'prevalidate') { + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1); +} + +if ($massaction == 'presign') { + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassSignature"), $langs->trans("ConfirmMassSignatureQuestion"), "sign", null, '', 0, 200, 500, 1); +} + +if ($massaction == 'nopresign') { + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassNoSignature"), $langs->trans("ConfirmMassNoSignatureQuestion"), "nosign", null, '', 0, 200, 500, 1); +} + +if ($search_all) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); } - if ($permissiontovalidate) { - $arrayofmassactions['prevalidate']=img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"); - } - if ($permissiontoclose) { - $arrayofmassactions['presign']=img_picto('', 'propal', 'class="pictofixedwidth"').$langs->trans("Sign"); - $arrayofmassactions['nopresign']=img_picto('', 'propal', 'class="pictofixedwidth"').$langs->trans("NoSign"); - $arrayofmassactions['setbilled'] =img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("ClassifyBilled"); - } - if ($permissiontodelete) { - $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); + print '
'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'
'; +} + +$i = 0; + +$moreforfilter = ''; + +// If the user can view prospects other than his' +if ($user->hasRight('user', 'user', 'lire')) { + $langs->load("commercial"); + $moreforfilter .= '
'; + $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx', 1); + $moreforfilter .= '
'; +} +// If the user can view prospects other than his' +if ($user->hasRight('user', 'user', 'lire')) { + $moreforfilter .= '
'; + $tmptitle = $langs->trans('LinkedToSpecificUsers'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers((empty($search_user) ? -2 : 0), 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx'); + $moreforfilter .= '
'; +} +// If the user can view products +if (isModEnabled('category') && $user->hasRight('categorie', 'read') && ($user->hasRight('product', 'read') || $user->hasRight('service', 'read'))) { + $searchCategoryProductOperator = -1; + include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $tmptitle = $langs->trans('IncludingProductWithTag'); + $formcategory = new FormCategory($db); + $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PRODUCT, array($search_product_category), 'maxwidth300', $searchCategoryProductOperator, 0, 0, $tmptitle); +} +if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '
'; + $tmptitle = $langs->trans('CustomersProspectsCategoriesShort'); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $tmptitle, (empty($conf->dol_optimize_smallscreen) ? 'maxwidth300 widthcentpercentminusx' : 'maxwidth250 widthcentpercentminusx')); + $moreforfilter .= '
'; +} +if (isModEnabled('stock') && getDolGlobalString('WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL')) { + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; + $formproduct = new FormProduct($db); + $moreforfilter .= '
'; + $tmptitle = $langs->trans('Warehouse'); + $moreforfilter .= img_picto($tmptitle, 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses($search_warehouse, 'search_warehouse', '', $tmptitle, 0, 0, $tmptitle); + $moreforfilter .= '
'; +} +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} + +if (!empty($moreforfilter)) { + print '
'; + print $moreforfilter; + print '
'; +} + +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields +$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + +print '
'; +print '
'; print $langs->trans('SendingMethod'); @@ -2903,19 +2903,23 @@ if ($action == 'create') { print '' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($object->total_localtax1, 0, $langs, 1, -1, -1, $conf->currency) . '' . price($object->total_localtax1, 0, $langs, 1, -1, -1, $object->multicurrency_code) . '' . price($object->multicurrency_total_localtax1, 0, $langs, 1, -1, -1, $object->multicurrency_code) . '
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($object->total_localtax2, 0, $langs, 1, -1, -1, $conf->currency) . '' . price($object->total_localtax2, 0, $langs, 1, -1, -1, $object->multicurrency_code) . '
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($object->total_localtax2, 0, $langs, 1, -1, -1, $conf->currency) . '' . price($object->multicurrency_total_localtax2, 0, $langs, 1, -1, -1, $object->multicurrency_code) . '
'."\n"; + +print ''; + +// Action column +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; +} + +if (!empty($arrayfields['p.ref']['checked'])) { + print ''; +} +if (!empty($arrayfields['p.ref_client']['checked'])) { + print ''; +} +if (!empty($arrayfields['pr.ref']['checked'])) { + print ''; +} +if (!empty($arrayfields['pr.title']['checked'])) { + print ''; +} +if (!empty($arrayfields['s.nom']['checked'])) { + print ''; +} +if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; +} +if (!empty($arrayfields['s.town']['checked'])) { + print ''; +} +if (!empty($arrayfields['s.zip']['checked'])) { + print ''; +} +// State +if (!empty($arrayfields['state.nom']['checked'])) { + print ''; +} +// Country +if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; +} +// Company type +if (!empty($arrayfields['typent.code']['checked'])) { + print ''; +} +// Date +if (!empty($arrayfields['p.date']['checked'])) { + print ''; +} +// Date end +if (!empty($arrayfields['p.fin_validite']['checked'])) { + print ''; +} +// Date delivery +if (!empty($arrayfields['p.date_livraison']['checked'])) { + print ''; +} +// Date Signature +if (!empty($arrayfields['p.date_signature']['checked'])) { + print ''; +} +// Availability +if (!empty($arrayfields['ava.rowid']['checked'])) { + print ''; +} +// Shipping Method +if (!empty($arrayfields['p.fk_shipping_method']['checked'])) { + print ''; +} +// Source - Input reason +if (!empty($arrayfields['p.fk_input_reason']['checked'])) { + print ''; +} +// Payment term +if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) { + print ''; +} +// Payment mode +if (!empty($arrayfields['p.fk_mode_reglement']['checked'])) { + print ''; +} +if (!empty($arrayfields['p.total_ht']['checked'])) { + // Amount + print ''; +} +if (!empty($arrayfields['p.total_tva']['checked'])) { + // Amount + print ''; +} +if (!empty($arrayfields['p.total_ttc']['checked'])) { + // Amount + print ''; +} +if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) { + // Amount invoiced + print ''; +} +if (!empty($arrayfields['p.total_invoiced']['checked'])) { + // Amount invoiced + print ''; +} +if (!empty($arrayfields['p.multicurrency_code']['checked'])) { + // Currency + print ''; +} +if (!empty($arrayfields['p.multicurrency_tx']['checked'])) { + // Currency rate + print ''; +} +if (!empty($arrayfields['p.multicurrency_total_ht']['checked'])) { + // Amount + print ''; +} +if (!empty($arrayfields['p.multicurrency_total_tva']['checked'])) { + // Amount + print ''; +} +if (!empty($arrayfields['p.multicurrency_total_ttc']['checked'])) { + // Amount + print ''; +} +if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked'])) { + // Amount invoiced + print ''; +} +if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked'])) { + // Amount invoiced + print ''; +} +if (!empty($arrayfields['u.login']['checked'])) { + // Author + print ''; +} +if (!empty($arrayfields['sale_representative']['checked'])) { + print ''; +} +if (!empty($arrayfields['total_pa']['checked'])) { + print ''; +} +if (!empty($arrayfields['total_margin']['checked'])) { + print ''; +} +if (!empty($arrayfields['total_margin_rate']['checked'])) { + print ''; +} +if (!empty($arrayfields['total_mark_rate']['checked'])) { + print ''; +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + +// Fields from hook +$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; +// Date creation +if (!empty($arrayfields['p.datec']['checked'])) { + print ''; +} +// Date modification +if (!empty($arrayfields['p.tms']['checked'])) { + print ''; +} +// Date cloture +if (!empty($arrayfields['p.date_cloture']['checked'])) { + print ''; +} +if (!empty($arrayfields['p.note_public']['checked'])) { + // Note public + print ''; +} +if (!empty($arrayfields['p.note_private']['checked'])) { + // Note private + print ''; +} +// Status +if (!empty($arrayfields['p.fk_statut']['checked'])) { + print ''; +} +// Action column +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; +} +print "\n"; + +$totalarray = array( + 'nbfield' => 0, + 'val' => array( + 'p.total_ht' => 0, + 'p.total_tva' => 0, + 'p.total_ttc' => 0, + ), +); + +// Fields title +print ''; +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.ref']['checked'])) { + print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.ref_client']['checked'])) { + print_liste_field_titre($arrayfields['p.ref_client']['label'], $_SERVER["PHP_SELF"], 'p.ref_client', '', $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['pr.ref']['checked'])) { + print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], 'pr.ref', '', $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['pr.title']['checked'])) { + print_liste_field_titre($arrayfields['pr.title']['label'], $_SERVER["PHP_SELF"], 'pr.title', '', $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['s.nom']['checked'])) { + print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['s.name_alias']['checked'])) { + print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], 's.name_alias', '', $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['s.town']['checked'])) { + print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['s.zip']['checked'])) { + print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['state.nom']['checked'])) { + print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['country.code_iso']['checked'])) { + print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'class="center"', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['typent.code']['checked'])) { + print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'class="center"', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.date']['checked'])) { + print_liste_field_titre($arrayfields['p.date']['label'], $_SERVER["PHP_SELF"], 'p.datep', '', $param, 'class="center"', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.fin_validite']['checked'])) { + print_liste_field_titre($arrayfields['p.fin_validite']['label'], $_SERVER["PHP_SELF"], 'dfv', '', $param, 'class="center"', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.date_livraison']['checked'])) { + print_liste_field_titre($arrayfields['p.date_livraison']['label'], $_SERVER["PHP_SELF"], 'p.date_livraison', '', $param, 'class="center"', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.date_signature']['checked'])) { + print_liste_field_titre($arrayfields['p.date_signature']['label'], $_SERVER["PHP_SELF"], 'p.date_signature', '', $param, 'class="center"', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['ava.rowid']['checked'])) { + print_liste_field_titre($arrayfields['ava.rowid']['label'], $_SERVER["PHP_SELF"], 'availability', '', $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.fk_shipping_method']['checked'])) { + print_liste_field_titre($arrayfields['p.fk_shipping_method']['label'], $_SERVER["PHP_SELF"], "p.fk_shipping_method", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.fk_input_reason']['checked'])) { + print_liste_field_titre($arrayfields['p.fk_input_reason']['label'], $_SERVER["PHP_SELF"], "p.fk_input_reason", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) { + print_liste_field_titre($arrayfields['p.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "p.fk_cond_reglement", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.fk_mode_reglement']['checked'])) { + print_liste_field_titre($arrayfields['p.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "p.fk_mode_reglement", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.total_ht']['checked'])) { + print_liste_field_titre($arrayfields['p.total_ht']['label'], $_SERVER["PHP_SELF"], 'p.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.total_tva']['checked'])) { + print_liste_field_titre($arrayfields['p.total_tva']['label'], $_SERVER["PHP_SELF"], 'p.total_tva', '', $param, '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.total_ttc']['checked'])) { + print_liste_field_titre($arrayfields['p.total_ttc']['label'], $_SERVER["PHP_SELF"], 'p.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) { + print_liste_field_titre($arrayfields['p.total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.total_invoiced']['checked'])) { + print_liste_field_titre($arrayfields['p.total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.multicurrency_code']['checked'])) { + print_liste_field_titre($arrayfields['p.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_code', '', $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.multicurrency_tx']['checked'])) { + print_liste_field_titre($arrayfields['p.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_tx', '', $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.multicurrency_total_ht']['checked'])) { + print_liste_field_titre($arrayfields['p.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_ht', '', $param, '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.multicurrency_total_tva']['checked'])) { + print_liste_field_titre($arrayfields['p.multicurrency_total_tva']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_tva', '', $param, '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.multicurrency_total_ttc']['checked'])) { + print_liste_field_titre($arrayfields['p.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked'])) { + print_liste_field_titre($arrayfields['p.multicurrency_total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked'])) { + print_liste_field_titre($arrayfields['p.multicurrency_total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['u.login']['checked'])) { + print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['sale_representative']['checked'])) { + print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['total_pa']['checked'])) { + print_liste_field_titre($arrayfields['total_pa']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['total_margin']['checked'])) { + print_liste_field_titre($arrayfields['total_margin']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['total_margin_rate']['checked'])) { + print_liste_field_titre($arrayfields['total_margin_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['total_mark_rate']['checked'])) { + print_liste_field_titre($arrayfields['total_mark_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; +} +// 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, +); + +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + +print $hookmanager->resPrint; +if (!empty($arrayfields['p.datec']['checked'])) { + print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowraponall '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.tms']['checked'])) { + print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowraponall '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.date_cloture']['checked'])) { + print_liste_field_titre($arrayfields['p.date_cloture']['label'], $_SERVER["PHP_SELF"], "p.date_cloture", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.note_public']['checked'])) { + print_liste_field_titre($arrayfields['p.note_public']['label'], $_SERVER["PHP_SELF"], "p.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.note_private']['checked'])) { + print_liste_field_titre($arrayfields['p.note_private']['label'], $_SERVER["PHP_SELF"], "p.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['p.fk_statut']['checked'])) { + print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); + $totalarray['nbfield']++; +} +print ''."\n"; + +// Loop on record +// -------------------------------------------------------------------- +$typenArray = null; +$now = dol_now(); + +$with_margin_info = false; +if (isModEnabled('margin') && ( + !empty($arrayfields['total_pa']['checked']) + || !empty($arrayfields['total_margin']['checked']) + || !empty($arrayfields['total_margin_rate']['checked']) + || !empty($arrayfields['total_mark_rate']['checked']) +) +) { + $with_margin_info = true; +} +$total_ht = 0; +$total_margin = 0; + +$i = 0; +$savnbfield = $totalarray['nbfield']; +$totalarray = array(); +$totalarray['nbfield'] = 0; +$imaxinloop = ($limit ? min($num, $limit) : $num); +while ($i < $imaxinloop) { + $obj = $db->fetch_object($resql); + if (empty($obj)) { + break; // Should not happen } - if (in_array($massaction, array('presend', 'predelete', 'closed'))) { - $arrayofmassactions = array(); - } - $massactionbutton = $form->selectMassAction('', $arrayofmassactions); + $objectstatic->id = $obj->rowid; + $objectstatic->ref = $obj->ref; + $objectstatic->ref_client = $obj->ref_client; + $objectstatic->note_public = $obj->note_public; + $objectstatic->note_private = $obj->note_private; + $objectstatic->statut = $obj->status; + $objectstatic->status = $obj->status; - $url = DOL_URL_ROOT.'/comm/propal/card.php?action=create'; - if (!empty($socid)) { - $url .= '&socid='.$socid; - } - $newcardbutton = ''; - $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); - $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); - $newcardbutton .= dolGetButtonTitleSeparator(); - $newcardbutton .= dolGetButtonTitle($langs->trans('NewPropal'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('propal', 'creer')); + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->name_alias = $obj->alias; + $companystatic->client = $obj->client; + $companystatic->fournisseur = $obj->fournisseur; + $companystatic->code_client = $obj->code_client; + $companystatic->email = $obj->email; + $companystatic->phone = $obj->phone; + $companystatic->address = $obj->address; + $companystatic->zip = $obj->zip; + $companystatic->town = $obj->town; + $companystatic->country_code = $obj->country_code; - // Fields title search - print ''; - if ($optioncss != '') { - print ''; - } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + $projectstatic->id = $obj->project_id; + $projectstatic->ref = $obj->project_ref; + $projectstatic->title = $obj->project_label; - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'propal', 0, $newcardbutton, '', $limit, 0, 0, 1); + $totalInvoicedHT = 0; + $totalInvoicedTTC = 0; + $multicurrency_totalInvoicedHT = 0; + $multicurrency_totalInvoicedTTC = 0; - $topicmail = "SendPropalRef"; - $modelmail = "propal_send"; - $objecttmp = new Propal($db); - $trackid = 'pro'.$object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + $TInvoiceData = $objectstatic->InvoiceArrayList($obj->rowid); - if ($massaction == 'prevalidate') { - print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1); - } + if (!empty($TInvoiceData)) { + foreach ($TInvoiceData as $invoiceData) { + $invoice = new Facture($db); + $invoice->fetch($invoiceData->facid); - if ($massaction == 'presign') { - print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassSignature"), $langs->trans("ConfirmMassSignatureQuestion"), "sign", null, '', 0, 200, 500, 1); - } + if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS') && $invoice->type == Facture::TYPE_DEPOSIT) { + continue; + } - if ($massaction == 'nopresign') { - print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassNoSignature"), $langs->trans("ConfirmMassNoSignatureQuestion"), "nosign", null, '', 0, 200, 500, 1); - } - - if ($search_all) { - foreach ($fieldstosearchall as $key => $val) { - $fieldstosearchall[$key] = $langs->trans($val); + $totalInvoicedHT += $invoice->total_ht; + $totalInvoicedTTC += $invoice->total_ttc; + $multicurrency_totalInvoicedHT += $invoice->multicurrency_total_ht; + $multicurrency_totalInvoicedTTC += $invoice->multicurrency_total_ttc; } - print '
'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'
'; } - $i = 0; + $marginInfo = array(); + if ($with_margin_info === true) { + $objectstatic->fetch_lines(); + $marginInfo = $formmargin->getMarginInfosArray($objectstatic); + $total_ht += $obj->total_ht; + $total_margin += $marginInfo['total_margin']; + } - $moreforfilter = ''; - - // If the user can view prospects other than his' - if ($user->hasRight('user', 'user', 'lire')) { - $langs->load("commercial"); - $moreforfilter .= '
'; - $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); - $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx', 1); - $moreforfilter .= '
'; - } - // If the user can view prospects other than his' - if ($user->hasRight('user', 'user', 'lire')) { - $moreforfilter .= '
'; - $tmptitle = $langs->trans('LinkedToSpecificUsers'); - $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers((empty($search_user)?-2:0), 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx'); - $moreforfilter .= '
'; - } - // If the user can view products - if (isModEnabled('category') && $user->hasRight('categorie', 'read') && ($user->hasRight('product', 'read') || $user->hasRight('service', 'read'))) { - $searchCategoryProductOperator = -1; - include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $tmptitle = $langs->trans('IncludingProductWithTag'); - $formcategory = new FormCategory($db); - $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PRODUCT, array($search_product_category), 'maxwidth300', $searchCategoryProductOperator, 0, 0, $tmptitle); - } - if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) { - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $moreforfilter .= '
'; - $tmptitle = $langs->trans('CustomersProspectsCategoriesShort'); - $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $tmptitle, (empty($conf->dol_optimize_smallscreen) ? 'maxwidth300 widthcentpercentminusx' : 'maxwidth250 widthcentpercentminusx')); - $moreforfilter .= '
'; - } - if (isModEnabled('stock') && getDolGlobalString('WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL')) { - require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; - $formproduct = new FormProduct($db); - $moreforfilter .= '
'; - $tmptitle = $langs->trans('Warehouse'); - $moreforfilter .= img_picto($tmptitle, 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses($search_warehouse, 'search_warehouse', '', $tmptitle, 0, 0, $tmptitle); - $moreforfilter .= '
'; - } - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) { - $moreforfilter .= $hookmanager->resPrint; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + } } else { - $moreforfilter = $hookmanager->resPrint; - } + print ''; - if (!empty($moreforfilter)) { - print '
'; - print $moreforfilter; - print '
'; - } + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } - $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields - $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + if (!empty($arrayfields['p.ref']['checked'])) { + print ''; + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } + if (!empty($arrayfields['p.ref_client']['checked'])) { + // Customer ref + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } - if (!empty($arrayfields['p.ref']['checked'])) { - print ''; - } - if (!empty($arrayfields['p.ref_client']['checked'])) { - print ''; - } - if (!empty($arrayfields['pr.ref']['checked'])) { - print ''; - } - if (!empty($arrayfields['pr.title']['checked'])) { - print ''; - } - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - } - if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; - } - if (!empty($arrayfields['s.town']['checked'])) { - print ''; - } - if (!empty($arrayfields['s.zip']['checked'])) { - print ''; - } - // State - if (!empty($arrayfields['state.nom']['checked'])) { - print ''; - } - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; - } - // Company type - if (!empty($arrayfields['typent.code']['checked'])) { - print ''; - } - // Date - if (!empty($arrayfields['p.date']['checked'])) { - print ''; - } - // Date end - if (!empty($arrayfields['p.fin_validite']['checked'])) { - print ''; - } - // Date delivery - if (!empty($arrayfields['p.date_livraison']['checked'])) { - print ''; - } - // Date Signature - if (!empty($arrayfields['p.date_signature']['checked'])) { - print ''; - } - // Availability - if (!empty($arrayfields['ava.rowid']['checked'])) { - print ''; - } - // Shipping Method - if (!empty($arrayfields['p.fk_shipping_method']['checked'])) { - print ''; - } - // Source - Input reason - if (!empty($arrayfields['p.fk_input_reason']['checked'])) { - print ''; - } - // Payment term - if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) { - print ''; - } - // Payment mode - if (!empty($arrayfields['p.fk_mode_reglement']['checked'])) { - print ''; - } - if (!empty($arrayfields['p.total_ht']['checked'])) { - // Amount - print ''; - } - if (!empty($arrayfields['p.total_tva']['checked'])) { - // Amount - print ''; - } - if (!empty($arrayfields['p.total_ttc']['checked'])) { - // Amount - print ''; - } - if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) { - // Amount invoiced - print ''; - } - if (!empty($arrayfields['p.total_invoiced']['checked'])) { - // Amount invoiced - print ''; - } - if (!empty($arrayfields['p.multicurrency_code']['checked'])) { + if (!empty($arrayfields['pr.ref']['checked'])) { + // Project ref + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + if (!empty($arrayfields['pr.title']['checked'])) { + // Project label + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Thirdparty + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Alias + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Town + if (!empty($arrayfields['s.town']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Zip + if (!empty($arrayfields['s.zip']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // State + if (!empty($arrayfields['state.nom']['checked'])) { + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Type ent + if (!empty($arrayfields['typent.code']['checked'])) { + if (!is_array($typenArray) || empty($typenArray)) { + $typenArray = $formcompany->typent_array(1); + } + + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date proposal + if (!empty($arrayfields['p.date']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date end validity + if (!empty($arrayfields['p.fin_validite']['checked'])) { + if ($obj->dfv) { + print ''; + } else { + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date delivery + if (!empty($arrayfields['p.date_livraison']['checked'])) { + if ($obj->ddelivery) { + print ''; + } else { + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date Signature + if (!empty($arrayfields['p.date_signature']['checked'])) { + if ($obj->dsignature) { + print ''; + } else { + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + } + // Availability + if (!empty($arrayfields['ava.rowid']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Shipping Method + if (!empty($arrayfields['p.fk_shipping_method']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Source - input reason + if (!empty($arrayfields['p.fk_input_reason']['checked'])) { + $labelInputReason = ''; + if ($obj->fk_input_reason > 0) { + $labelInputReason = $form->cache_demand_reason[$obj->fk_input_reason]['label']; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Payment terms + if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Payment mode + if (!empty($arrayfields['p.fk_mode_reglement']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount HT + if (!empty($arrayfields['p.total_ht']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht'; + } + if (empty($totalarray['val']['p.total_ht'])) { + $totalarray['val']['p.total_ht'] = $obj->total_ht; + } else { + $totalarray['val']['p.total_ht'] += $obj->total_ht; + } + } + // Amount VAT + if (!empty($arrayfields['p.total_tva']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'p.total_tva'; + } + if (empty($totalarray['val']['p.total_tva'])) { + $totalarray['val']['p.total_tva'] = $obj->total_tva; + } else { + $totalarray['val']['p.total_tva'] += $obj->total_tva; + } + } + // Amount TTC + if (!empty($arrayfields['p.total_ttc']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ttc'; + } + if (empty($totalarray['val']['p.total_ttc'])) { + $totalarray['val']['p.total_ttc'] = $obj->total_ttc; + } else { + $totalarray['val']['p.total_ttc'] += $obj->total_ttc; + } + } + // Amount invoiced HT + if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht_invoiced'; + } + if (empty($totalarray['val']['p.total_ht_invoiced'])) { + $totalarray['val']['p.total_ht_invoiced'] = $totalInvoicedHT; + } else { + $totalarray['val']['p.total_ht_invoiced'] += $totalInvoicedHT; + } + } + // Amount invoiced TTC + if (!empty($arrayfields['p.total_invoiced']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'p.total_invoiced'; + } + if (empty($totalarray['val']['p.total_invoiced'])) { + $totalarray['val']['p.total_invoiced'] = $totalInvoicedTTC; + } else { + $totalarray['val']['p.total_invoiced'] += $totalInvoicedTTC; + } + } // Currency - print ''; - } - if (!empty($arrayfields['p.multicurrency_tx']['checked'])) { + if (!empty($arrayfields['p.multicurrency_code']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Currency rate - print ''; - } - if (!empty($arrayfields['p.multicurrency_total_ht']['checked'])) { - // Amount - print ''; - } - if (!empty($arrayfields['p.multicurrency_total_tva']['checked'])) { - // Amount - print ''; - } - if (!empty($arrayfields['p.multicurrency_total_ttc']['checked'])) { - // Amount - print ''; - } - if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked'])) { + if (!empty($arrayfields['p.multicurrency_tx']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount HT + if (!empty($arrayfields['p.multicurrency_total_ht']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount VAT + if (!empty($arrayfields['p.multicurrency_total_tva']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount TTC + if (!empty($arrayfields['p.multicurrency_total_ttc']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } // Amount invoiced - print ''; - } - if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked'])) { + if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } // Amount invoiced - print ''; - } - if (!empty($arrayfields['u.login']['checked'])) { + if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + $userstatic->id = $obj->fk_user_author; + $userstatic->login = $obj->login; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + $userstatic->email = $obj->user_email; + $userstatic->statut = $obj->user_statut; + $userstatic->entity = $obj->user_entity; + $userstatic->photo = $obj->photo; + $userstatic->office_phone = $obj->office_phone; + $userstatic->office_fax = $obj->office_fax; + $userstatic->user_mobile = $obj->user_mobile; + $userstatic->job = $obj->job; + $userstatic->gender = $obj->gender; + // Author - print ''; - } - if (!empty($arrayfields['sale_representative']['checked'])) { - print ''; - } - if (!empty($arrayfields['total_pa']['checked'])) { - print ''; - } - if (!empty($arrayfields['total_margin']['checked'])) { - print ''; - } - if (!empty($arrayfields['total_margin_rate']['checked'])) { - print ''; - } - if (!empty($arrayfields['total_mark_rate']['checked'])) { - print ''; - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; - - // Fields from hook - $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; - // Date creation - if (!empty($arrayfields['p.datec']['checked'])) { - print ''; - } - // Date modification - if (!empty($arrayfields['p.tms']['checked'])) { - print ''; - } - // Date cloture - if (!empty($arrayfields['p.date_cloture']['checked'])) { - print ''; - } - if (!empty($arrayfields['p.note_public']['checked'])) { - // Note public - print ''; - } - if (!empty($arrayfields['p.note_private']['checked'])) { - // Note private - print ''; - } - // Status - if (!empty($arrayfields['p.fk_statut']['checked'])) { - print ''; - } - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - print "\n"; - - $totalarray = array( - 'nbfield' => 0, - 'val' => array( - 'p.total_ht' => 0, - 'p.total_tva' => 0, - 'p.total_ttc' => 0, - ), - ); - - // Fields title - print ''; - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.ref']['checked'])) { - print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.ref_client']['checked'])) { - print_liste_field_titre($arrayfields['p.ref_client']['label'], $_SERVER["PHP_SELF"], 'p.ref_client', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['pr.ref']['checked'])) { - print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], 'pr.ref', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['pr.title']['checked'])) { - print_liste_field_titre($arrayfields['pr.title']['label'], $_SERVER["PHP_SELF"], 'pr.title', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['s.nom']['checked'])) { - print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['s.name_alias']['checked'])) { - print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], 's.name_alias', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['s.town']['checked'])) { - print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['s.zip']['checked'])) { - print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['state.nom']['checked'])) { - print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['country.code_iso']['checked'])) { - print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'class="center"', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['typent.code']['checked'])) { - print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'class="center"', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.date']['checked'])) { - print_liste_field_titre($arrayfields['p.date']['label'], $_SERVER["PHP_SELF"], 'p.datep', '', $param, 'class="center"', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.fin_validite']['checked'])) { - print_liste_field_titre($arrayfields['p.fin_validite']['label'], $_SERVER["PHP_SELF"], 'dfv', '', $param, 'class="center"', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.date_livraison']['checked'])) { - print_liste_field_titre($arrayfields['p.date_livraison']['label'], $_SERVER["PHP_SELF"], 'p.date_livraison', '', $param, 'class="center"', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.date_signature']['checked'])) { - print_liste_field_titre($arrayfields['p.date_signature']['label'], $_SERVER["PHP_SELF"], 'p.date_signature', '', $param, 'class="center"', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['ava.rowid']['checked'])) { - print_liste_field_titre($arrayfields['ava.rowid']['label'], $_SERVER["PHP_SELF"], 'availability', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.fk_shipping_method']['checked'])) { - print_liste_field_titre($arrayfields['p.fk_shipping_method']['label'], $_SERVER["PHP_SELF"], "p.fk_shipping_method", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.fk_input_reason']['checked'])) { - print_liste_field_titre($arrayfields['p.fk_input_reason']['label'], $_SERVER["PHP_SELF"], "p.fk_input_reason", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) { - print_liste_field_titre($arrayfields['p.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "p.fk_cond_reglement", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.fk_mode_reglement']['checked'])) { - print_liste_field_titre($arrayfields['p.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "p.fk_mode_reglement", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.total_ht']['checked'])) { - print_liste_field_titre($arrayfields['p.total_ht']['label'], $_SERVER["PHP_SELF"], 'p.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.total_tva']['checked'])) { - print_liste_field_titre($arrayfields['p.total_tva']['label'], $_SERVER["PHP_SELF"], 'p.total_tva', '', $param, '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.total_ttc']['checked'])) { - print_liste_field_titre($arrayfields['p.total_ttc']['label'], $_SERVER["PHP_SELF"], 'p.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) { - print_liste_field_titre($arrayfields['p.total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.total_invoiced']['checked'])) { - print_liste_field_titre($arrayfields['p.total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.multicurrency_code']['checked'])) { - print_liste_field_titre($arrayfields['p.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_code', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.multicurrency_tx']['checked'])) { - print_liste_field_titre($arrayfields['p.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_tx', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.multicurrency_total_ht']['checked'])) { - print_liste_field_titre($arrayfields['p.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_ht', '', $param, '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.multicurrency_total_tva']['checked'])) { - print_liste_field_titre($arrayfields['p.multicurrency_total_tva']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_tva', '', $param, '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.multicurrency_total_ttc']['checked'])) { - print_liste_field_titre($arrayfields['p.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked'])) { - print_liste_field_titre($arrayfields['p.multicurrency_total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked'])) { - print_liste_field_titre($arrayfields['p.multicurrency_total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['u.login']['checked'])) { - print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['sale_representative']['checked'])) { - print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['total_pa']['checked'])) { - print_liste_field_titre($arrayfields['total_pa']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['total_margin']['checked'])) { - print_liste_field_titre($arrayfields['total_margin']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['total_margin_rate']['checked'])) { - print_liste_field_titre($arrayfields['total_margin_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['total_mark_rate']['checked'])) { - print_liste_field_titre($arrayfields['total_mark_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; - } - // 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, - ); - - $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - - print $hookmanager->resPrint; - if (!empty($arrayfields['p.datec']['checked'])) { - print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowraponall '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.tms']['checked'])) { - print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowraponall '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.date_cloture']['checked'])) { - print_liste_field_titre($arrayfields['p.date_cloture']['label'], $_SERVER["PHP_SELF"], "p.date_cloture", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.note_public']['checked'])) { - print_liste_field_titre($arrayfields['p.note_public']['label'], $_SERVER["PHP_SELF"], "p.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.note_private']['checked'])) { - print_liste_field_titre($arrayfields['p.note_private']['label'], $_SERVER["PHP_SELF"], "p.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.fk_statut']['checked'])) { - print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; - } - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); - $totalarray['nbfield']++; - } - print ''."\n"; - - // Loop on record - // -------------------------------------------------------------------- - $typenArray = null; - $now = dol_now(); - - $with_margin_info = false; - if (isModEnabled('margin') && ( - !empty($arrayfields['total_pa']['checked']) - || !empty($arrayfields['total_margin']['checked']) - || !empty($arrayfields['total_margin_rate']['checked']) - || !empty($arrayfields['total_mark_rate']['checked']) - ) - ) { - $with_margin_info = true; - } - $total_ht = 0; - $total_margin = 0; - - $i = 0; - $savnbfield = $totalarray['nbfield']; - $totalarray = array(); - $totalarray['nbfield'] = 0; - $imaxinloop = ($limit ? min($num, $limit) : $num); - while ($i < $imaxinloop) { - $obj = $db->fetch_object($resql); - if (empty($obj)) { - break; // Should not happen - } - - $objectstatic->id = $obj->rowid; - $objectstatic->ref = $obj->ref; - $objectstatic->ref_client = $obj->ref_client; - $objectstatic->note_public = $obj->note_public; - $objectstatic->note_private = $obj->note_private; - $objectstatic->statut = $obj->status; - $objectstatic->status = $obj->status; - - $companystatic->id = $obj->socid; - $companystatic->name = $obj->name; - $companystatic->name_alias = $obj->alias; - $companystatic->client = $obj->client; - $companystatic->fournisseur = $obj->fournisseur; - $companystatic->code_client = $obj->code_client; - $companystatic->email = $obj->email; - $companystatic->phone = $obj->phone; - $companystatic->address = $obj->address; - $companystatic->zip = $obj->zip; - $companystatic->town = $obj->town; - $companystatic->country_code = $obj->country_code; - - $projectstatic->id = $obj->project_id; - $projectstatic->ref = $obj->project_ref; - $projectstatic->title = $obj->project_label; - - $totalInvoicedHT = 0; - $totalInvoicedTTC = 0; - $multicurrency_totalInvoicedHT = 0; - $multicurrency_totalInvoicedTTC = 0; - - $TInvoiceData = $objectstatic->InvoiceArrayList($obj->rowid); - - if (!empty($TInvoiceData)) { - foreach ($TInvoiceData as $invoiceData) { - $invoice = new Facture($db); - $invoice->fetch($invoiceData->facid); - - if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS') && $invoice->type == Facture::TYPE_DEPOSIT) { - continue; - } - - $totalInvoicedHT += $invoice->total_ht; - $totalInvoicedTTC += $invoice->total_ttc; - $multicurrency_totalInvoicedHT += $invoice->multicurrency_total_ht; - $multicurrency_totalInvoicedTTC += $invoice->multicurrency_total_ttc; + if (!empty($arrayfields['u.login']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; } } - $marginInfo = array(); - if ($with_margin_info === true) { - $objectstatic->fetch_lines(); - $marginInfo = $formmargin->getMarginInfosArray($objectstatic); - $total_ht += $obj->total_ht; - $total_margin += $marginInfo['total_margin']; - } - - if ($mode == 'kanban') { - if ($i == 0) { - print ''; - } - } else { - print ''; - - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['p.ref']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['p.ref_client']['checked'])) { - // Customer ref - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['pr.ref']['checked'])) { - // Project ref - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['pr.title']['checked'])) { - // Project label - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Thirdparty - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Alias - if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Town - if (!empty($arrayfields['s.town']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Zip - if (!empty($arrayfields['s.zip']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // State - if (!empty($arrayfields['state.nom']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Type ent - if (!empty($arrayfields['typent.code']['checked'])) { - if (!is_array($typenArray) || empty($typenArray)) { - $typenArray = $formcompany->typent_array(1); - } - - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Date proposal - if (!empty($arrayfields['p.date']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Date end validity - if (!empty($arrayfields['p.fin_validite']['checked'])) { - if ($obj->dfv) { - print ''; - } else { - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date delivery - if (!empty($arrayfields['p.date_livraison']['checked'])) { - if ($obj->ddelivery) { - print ''; - } else { - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date Signature - if (!empty($arrayfields['p.date_signature']['checked'])) { - if ($obj->dsignature) { - print ''; - } else { - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - } - // Availability - if (!empty($arrayfields['ava.rowid']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Shipping Method - if (!empty($arrayfields['p.fk_shipping_method']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Source - input reason - if (!empty($arrayfields['p.fk_input_reason']['checked'])) { - $labelInputReason = ''; - if ($obj->fk_input_reason > 0) { - $labelInputReason = $form->cache_demand_reason[$obj->fk_input_reason]['label']; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Payment terms - if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Payment mode - if (!empty($arrayfields['p.fk_mode_reglement']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount HT - if (!empty($arrayfields['p.total_ht']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht'; - } - if (empty($totalarray['val']['p.total_ht'])) { - $totalarray['val']['p.total_ht'] = $obj->total_ht; - } else { - $totalarray['val']['p.total_ht'] += $obj->total_ht; - } - } - // Amount VAT - if (!empty($arrayfields['p.total_tva']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'p.total_tva'; - } - if (empty($totalarray['val']['p.total_tva'])) { - $totalarray['val']['p.total_tva'] = $obj->total_tva; - } else { - $totalarray['val']['p.total_tva'] += $obj->total_tva; - } - } - // Amount TTC - if (!empty($arrayfields['p.total_ttc']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ttc'; - } - if (empty($totalarray['val']['p.total_ttc'])) { - $totalarray['val']['p.total_ttc'] = $obj->total_ttc; - } else { - $totalarray['val']['p.total_ttc'] += $obj->total_ttc; - } - } - // Amount invoiced HT - if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht_invoiced'; - } - if (empty($totalarray['val']['p.total_ht_invoiced'])) { - $totalarray['val']['p.total_ht_invoiced'] = $totalInvoicedHT; - } else { - $totalarray['val']['p.total_ht_invoiced'] += $totalInvoicedHT; - } - } - // Amount invoiced TTC - if (!empty($arrayfields['p.total_invoiced']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'p.total_invoiced'; - } - if (empty($totalarray['val']['p.total_invoiced'])) { - $totalarray['val']['p.total_invoiced'] = $totalInvoicedTTC; - } else { - $totalarray['val']['p.total_invoiced'] += $totalInvoicedTTC; - } - } - // Currency - if (!empty($arrayfields['p.multicurrency_code']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Currency rate - if (!empty($arrayfields['p.multicurrency_tx']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount HT - if (!empty($arrayfields['p.multicurrency_total_ht']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount VAT - if (!empty($arrayfields['p.multicurrency_total_tva']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount TTC - if (!empty($arrayfields['p.multicurrency_total_ttc']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount invoiced - if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount invoiced - if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - $userstatic->id = $obj->fk_user_author; - $userstatic->login = $obj->login; - $userstatic->lastname = $obj->lastname; - $userstatic->firstname = $obj->firstname; - $userstatic->email = $obj->user_email; - $userstatic->statut = $obj->user_statut; - $userstatic->entity = $obj->user_entity; - $userstatic->photo = $obj->photo; - $userstatic->office_phone = $obj->office_phone; - $userstatic->office_fax = $obj->office_fax; - $userstatic->user_mobile = $obj->user_mobile; - $userstatic->job = $obj->job; - $userstatic->gender = $obj->gender; - - // Author - if (!empty($arrayfields['u.login']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['sale_representative']['checked'])) { - // Sales representatives - print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Total buying or cost price + if (!empty($arrayfields['total_pa']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Total margin + if (!empty($arrayfields['total_margin']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'total_margin'; + } + $totalarray['val']['total_margin'] = $total_margin; + } + // Total margin rate + if (!empty($arrayfields['total_margin_rate']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Total mark rate + if (!empty($arrayfields['total_mark_rate']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate'; + } + if ($i >= $imaxinloop - 1) { + if (!empty($total_ht)) { + $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT'); } else { - print ' '; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; + $totalarray['val']['total_mark_rate'] = ''; } } - - // Total buying or cost price - if (!empty($arrayfields['total_pa']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Total margin - if (!empty($arrayfields['total_margin']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'total_margin'; - } - $totalarray['val']['total_margin'] = $total_margin; - } - // Total margin rate - if (!empty($arrayfields['total_margin_rate']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Total mark rate - if (!empty($arrayfields['total_mark_rate']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate'; - } - if ($i >= $imaxinloop - 1) { - if (!empty($total_ht)) { - $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT'); - } else { - $totalarray['val']['total_mark_rate'] = ''; - } - } - } - - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, '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; - // Date creation - if (!empty($arrayfields['p.datec']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['p.tms']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date cloture - if (!empty($arrayfields['p.date_cloture']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Note public - if (!empty($arrayfields['p.note_public']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Note private - if (!empty($arrayfields['p.note_private']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['p.fk_statut']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - - print ''."\n"; } - $i++; - } - - // Show total line - include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; - - // If no record found - if ($num == 0) { - $colspan = 1; - foreach ($arrayfields as $key => $val) { - if (!empty($val['checked'])) { - $colspan++; + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields' => $arrayfields, '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; + // Date creation + if (!empty($arrayfields['p.datec']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; } } - print ''; - } - - $db->free($resql); - - $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; - - print '
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); + print ''; + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (!getDolGlobalString('SOCIETE_SORT_ON_TYPEENT') ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1); + print ajax_combobox('search_type_thirdparty'); + print ''; + print '
'; + print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + print '
'; + print '
'; + print $form->selectDate($search_date_end_start ? $search_date_end_start : -1, 'search_date_end_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_date_end_end ? $search_date_end_end : -1, 'search_date_end_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + print '
'; + print '
'; + print $form->selectDate($search_date_delivery_start ? $search_date_delivery_start : -1, 'search_date_delivery_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_date_delivery_end ? $search_date_delivery_end : -1, 'search_date_delivery_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print '
'; + print $form->selectDate($search_date_signature_start ? $search_date_signature_start : -1, 'search_date_signature_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_date_signature_end ? $search_date_signature_end : -1, 'search_date_signature_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + $form->selectAvailabilityDelay($search_availability, 'search_availability', '', 1); + print ajax_combobox('search_availability'); + print ''; + $form->selectShippingMethod($search_fk_shipping_method, 'search_fk_shipping_method', '', 1, '', 1); + print ''; + $form->selectInputReason($search_fk_input_reason, 'search_fk_input_reason', '', 1, 'maxwidth125', 1); + print ''; + print $form->getSelectConditionsPaiements($search_fk_cond_reglement, 'search_fk_cond_reglement', 1, 1, 1); + print ''; + print $form->select_types_paiements($search_fk_mode_reglement, 'search_fk_mode_reglement', '', 0, 1, 1, 0, -1, '', 1); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $formpropal->selectProposalStatus($search_status, 1, 0, 1, 'customer', 'search_status', 'search_status width100 onrightofpage'); + print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; + print '
'; + } + // Output Kanban + $userstatic->fetch($obj->fk_user_author); + $arrayofparams = array('selected' => in_array($object->id, $arrayofselected), 'authorlink' => $userstatic->getNomUrl(-2), 'projectlink' => $projectstatic->getNomUrl(2)); + print $objectstatic->getKanbanView('', $arrayofparams); + if ($i == ($imaxinloop - 1)) { + print '
'; + print '
'; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; - print '
'; - print ''."\n"; + print '
'; + // Picto + Ref + print ''; + // Warning + $warnornote = ''; + if ($obj->status == Propal::STATUS_VALIDATED && $db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) { + $warnornote .= img_warning($langs->trans("Late")); + } + if ($warnornote) { + print ''; + } + // Other picto tool + print '
'; + print $objectstatic->getNomUrl(1, '', '', 0, 1, (isset($conf->global->PROPAL_LIST_SHOW_NOTES) ? $conf->global->PROPAL_LIST_SHOW_NOTES : 1)); + print ''; + print $warnornote; + print ''; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->propal->multidir_output[$obj->propal_entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; + print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + print '
'; - print '
'; - $searchpicto = $form->showFilterButtons('left'); - print $searchpicto; - print ''; + print dol_escape_htmltag($obj->ref_client); + print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); - print ''; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (!getDolGlobalString('SOCIETE_SORT_ON_TYPEENT') ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1); - print ajax_combobox('search_type_thirdparty'); - print ''; - print '
'; - print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
'; - print '
'; - print '
'; - print $form->selectDate($search_date_end_start ? $search_date_end_start : -1, 'search_date_end_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate($search_date_end_end ? $search_date_end_end : -1, 'search_date_end_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
'; - print '
'; - print '
'; - print $form->selectDate($search_date_delivery_start ? $search_date_delivery_start : -1, 'search_date_delivery_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate($search_date_delivery_end ? $search_date_delivery_end : -1, 'search_date_delivery_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print '
'; - print $form->selectDate($search_date_signature_start ? $search_date_signature_start : -1, 'search_date_signature_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate($search_date_signature_end ? $search_date_signature_end : -1, 'search_date_signature_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - $form->selectAvailabilityDelay($search_availability, 'search_availability', '', 1); - print ajax_combobox('search_availability'); - print ''; - $form->selectShippingMethod($search_fk_shipping_method, 'search_fk_shipping_method', '', 1, '', 1); - print ''; - $form->selectInputReason($search_fk_input_reason, 'search_fk_input_reason', '', 1, 'maxwidth125', 1); - print ''; - print $form->getSelectConditionsPaiements($search_fk_cond_reglement, 'search_fk_cond_reglement', 1, 1, 1); - print ''; - print $form->select_types_paiements($search_fk_mode_reglement, 'search_fk_mode_reglement', '', 0, 1, 1, 0, -1, '', 1); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + if ($obj->project_id > 0) { + print $projectstatic->getNomUrl(1); + } + print ''; + if ($obj->project_id > 0) { + print dol_escape_htmltag($projectstatic->title); + } + print ''; + print $companystatic->getNomUrl(1, 'customer', 0, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); + print ''; + print $obj->alias; + print ''; + print dol_escape_htmltag($obj->town); + print ''; + print $obj->zip; + print '".$obj->state_name."'; + $tmparray = getCountry($obj->fk_pays, 'all'); + print $tmparray['label']; + print ''; + if (!empty($obj->typent_code)) { + print $typenArray[$obj->typent_code]; + } + print ''; + print dol_print_date($db->jdate($obj->dp), 'day'); + print "'.dol_print_date($db->jdate($obj->dfv), 'day'); + print ' '.dol_print_date($db->jdate($obj->ddelivery), 'day'); + print ' '.dol_print_date($db->jdate($obj->dsignature), 'day'); + print ' '; + $form->form_availability('', $obj->availability, 'none', 1); + print ''; + $form->formSelectShippingMethod('', $obj->fk_shipping_method, 'none', 1); + print ''; + print dol_escape_htmltag($labelInputReason); + print ''; + $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', 1, $obj->deposit_percent); + print ''; + $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1); + print ''.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_ttc)."'.price($totalInvoicedHT)."'.price($totalInvoicedTTC)."'; - print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1); - print ''.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); + print "'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_tva)."'.price($obj->multicurrency_total_ttc)."'; - print ''.price($multicurrency_totalInvoicedHT)."'; - print ''.price($multicurrency_totalInvoicedTTC)."'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $formpropal->selectProposalStatus($search_status, 1, 0, 1, 'customer', 'search_status', 'search_status width100 onrightofpage'); - print ''; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print '
'; + if ($userstatic->id) { + print $userstatic->getNomUrl(-1); + } + print "
'; - print '
'; - } - // Output Kanban - $userstatic->fetch($obj->fk_user_author); - $arrayofparams = array('selected' => in_array($object->id, $arrayofselected), 'authorlink' => $userstatic->getNomUrl(-2), 'projectlink' => $projectstatic->getNomUrl(2)); - print $objectstatic->getKanbanView('', $arrayofparams); - if ($i == ($imaxinloop - 1)) { - print '
'; - print '
'; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; - } - print ''; + if (!empty($arrayfields['sale_representative']['checked'])) { + // Sales representatives + print ''; + if ($obj->socid > 0) { + $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user); + if ($listsalesrepresentatives < 0) { + dol_print_error($db); } - print ''; - - print ''; - // Picto + Ref - print ''; - // Warning - $warnornote = ''; - if ($obj->status == Propal::STATUS_VALIDATED && $db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) { - $warnornote .= img_warning($langs->trans("Late")); - } - if ($warnornote) { - print ''; - } - // Other picto tool - print '
'; - print $objectstatic->getNomUrl(1, '', '', 0, 1, (isset($conf->global->PROPAL_LIST_SHOW_NOTES) ? $conf->global->PROPAL_LIST_SHOW_NOTES : 1)); - print ''; - print $warnornote; - print ''; - $filename = dol_sanitizeFileName($obj->ref); - $filedir = $conf->propal->multidir_output[$obj->propal_entity].'/'.dol_sanitizeFileName($obj->ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; - print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); - print '
'; - - print "
'; - print dol_escape_htmltag($obj->ref_client); - print ''; - if ($obj->project_id > 0) { - print $projectstatic->getNomUrl(1); - } - print ''; - if ($obj->project_id > 0) { - print dol_escape_htmltag($projectstatic->title); - } - print ''; - print $companystatic->getNomUrl(1, 'customer', 0, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); - print ''; - print $obj->alias; - print ''; - print dol_escape_htmltag($obj->town); - print ''; - print $obj->zip; - print '".$obj->state_name."'; - $tmparray = getCountry($obj->fk_pays, 'all'); - print $tmparray['label']; - print ''; - if (!empty($obj->typent_code)) { - print $typenArray[$obj->typent_code]; - } - print ''; - print dol_print_date($db->jdate($obj->dp), 'day'); - print "'.dol_print_date($db->jdate($obj->dfv), 'day'); - print ' '.dol_print_date($db->jdate($obj->ddelivery), 'day'); - print ' '.dol_print_date($db->jdate($obj->dsignature), 'day'); - print ' '; - $form->form_availability('', $obj->availability, 'none', 1); - print ''; - $form->formSelectShippingMethod('', $obj->fk_shipping_method, 'none', 1); - print ''; - print dol_escape_htmltag($labelInputReason); - print ''; - $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', 1, $obj->deposit_percent); - print ''; - $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1); - print ''.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_ttc)."'.price($totalInvoicedHT)."'.price($totalInvoicedTTC)."'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."'; - $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); - print "'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_tva)."'.price($obj->multicurrency_total_ttc)."'.price($multicurrency_totalInvoicedHT)."'.price($multicurrency_totalInvoicedTTC)."'; - if ($userstatic->id) { - print $userstatic->getNomUrl(-1); - } - print "'; - if ($obj->socid > 0) { - $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user); - if ($listsalesrepresentatives < 0) { - dol_print_error($db); - } - $nbofsalesrepresentative = count($listsalesrepresentatives); - if ($nbofsalesrepresentative > 6) { - // We print only number - print $nbofsalesrepresentative; - } elseif ($nbofsalesrepresentative > 0) { - $userstatic = new User($db); - $j = 0; - foreach ($listsalesrepresentatives as $val) { - $userstatic->id = $val['id']; - $userstatic->lastname = $val['lastname']; - $userstatic->firstname = $val['firstname']; - $userstatic->email = $val['email']; - $userstatic->statut = $val['statut']; - $userstatic->entity = $val['entity']; - $userstatic->photo = $val['photo']; - $userstatic->login = $val['login']; - $userstatic->office_phone = $val['office_phone']; - $userstatic->office_fax = $val['office_fax']; - $userstatic->user_mobile = $val['user_mobile']; - $userstatic->job = $val['job']; - $userstatic->gender = $val['gender']; - //print '
': - print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); - $j++; - if ($j < $nbofsalesrepresentative) { - print ' '; - } - //print '
'; + $nbofsalesrepresentative = count($listsalesrepresentatives); + if ($nbofsalesrepresentative > 6) { + // We print only number + print $nbofsalesrepresentative; + } elseif ($nbofsalesrepresentative > 0) { + $userstatic = new User($db); + $j = 0; + foreach ($listsalesrepresentatives as $val) { + $userstatic->id = $val['id']; + $userstatic->lastname = $val['lastname']; + $userstatic->firstname = $val['firstname']; + $userstatic->email = $val['email']; + $userstatic->statut = $val['statut']; + $userstatic->entity = $val['entity']; + $userstatic->photo = $val['photo']; + $userstatic->login = $val['login']; + $userstatic->office_phone = $val['office_phone']; + $userstatic->office_fax = $val['office_fax']; + $userstatic->user_mobile = $val['user_mobile']; + $userstatic->job = $val['job']; + $userstatic->gender = $val['gender']; + //print '
': + print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); + $j++; + if ($j < $nbofsalesrepresentative) { + print ' '; } + //print '
'; } - //else print $langs->trans("NoSalesRepresentativeAffected"); + } + //else print $langs->trans("NoSalesRepresentativeAffected"); + } else { + print ' '; + } + print '
'.price($marginInfo['pa_total']).''.price($marginInfo['total_margin']).''.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], 0, null, null, null, 2).'%').''.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], 0, null, null, null, 2).'%').''.price($marginInfo['pa_total']).''.price($marginInfo['total_margin']).''.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], 0, null, null, null, 2).'%').''.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], 0, null, null, null, 2).'%').''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser'); - print ''; - print dol_string_nohtmltag($obj->note_public); - print ''; - print dol_string_nohtmltag($obj->note_private); - print ''.$objectstatic->getLibStatut(5).''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print '
'; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print '
'.$langs->trans("NoRecordFound").'
'."\n"; - print '
'."\n"; - - print ''."\n"; - - if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { - $hidegeneratedfilelistifempty = 0; + // Date modification + if (!empty($arrayfields['p.tms']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date cloture + if (!empty($arrayfields['p.date_cloture']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Note public + if (!empty($arrayfields['p.note_public']['checked'])) { + print ''; + print dol_string_nohtmltag($obj->note_public); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Note private + if (!empty($arrayfields['p.note_private']['checked'])) { + print ''; + print dol_string_nohtmltag($obj->note_private); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['p.fk_statut']['checked'])) { + print ''.$objectstatic->getLibStatut(5).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; - $formfile = new FormFile($db); - // Show list of available documents - $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource .= str_replace('&', '&', $param); - - $filedir = $diroutputmassaction; - $genallowed = $permissiontoread; - $delallowed = $permissiontoadd; - - print $formfile->showdocuments('massfilesarea_proposals', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); + print ''."\n"; } - // End of page - llxFooter(); - $db->close(); + $i++; +} + +// Show total line +include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + +// If no record found +if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print ''.$langs->trans("NoRecordFound").''; +} + +$db->free($resql); + +$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; + +print ''."\n"; +print ''."\n"; + +print ''."\n"; + +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } + + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + $formfile = new FormFile($db); + + // Show list of available documents + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); + + $filedir = $diroutputmassaction; + $genallowed = $permissiontoread; + $delallowed = $permissiontoadd; + + print $formfile->showdocuments('massfilesarea_proposals', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 994e30fb9f1..1ed17699c6d 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -2,7 +2,8 @@ /* Copyright (C) 2001-2004 Rodolphe Quiedeville * Copyright (C) 2004-2019 Laurent Destailleur * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -45,6 +46,7 @@ $backtopage = GETPOST('backtopage', 'alpha'); // Security check $socid = GETPOSTINT('id') ? GETPOSTINT('id') : GETPOSTINT('socid'); +/** @var User $user */ if ($user->socid > 0) { $socid = $user->socid; } @@ -55,7 +57,7 @@ if ($user->socid > 0) { } $result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0); -$permissiontocreate = ($user->rights->societe->creer || $user->rights->facture->creer); +$permissiontocreate = ($user->hasRight('societe', 'creer') || $user->hasRight('facture', 'creer')); @@ -559,8 +561,8 @@ if ($socid > 0) { $amount2 = ($showconfirminfo['amount_ttc'] - $amount1); $formquestion = array( 'text' => $langs->trans('TypeAmountOfEachNewDiscount'), - array('type' => 'text', 'name' => 'amount_ttc_1', 'label' => $langs->trans("AmountTTC").' 1', 'value' => $amount1, 'size' => '5'), - array('type' => 'text', 'name' => 'amount_ttc_2', 'label' => $langs->trans("AmountTTC").' 2', 'value' => $amount2, 'size' => '5') + 0 => array('type' => 'text', 'name' => 'amount_ttc_1', 'label' => $langs->trans("AmountTTC").' 1', 'value' => $amount1, 'size' => '5'), + 1 => array('type' => 'text', 'name' => 'amount_ttc_2', 'label' => $langs->trans("AmountTTC").' 2', 'value' => $amount2, 'size' => '5') ); $langs->load("dict"); print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.$showconfirminfo['rowid'].($backtopage ? '&backtopage='.urlencode($backtopage) : ''), $langs->trans('SplitDiscount'), $langs->trans('ConfirmSplitDiscount', price($showconfirminfo['amount_ttc']), $langs->transnoentities("Currency".$conf->currency)), 'confirm_split', $formquestion, '', 0); @@ -706,8 +708,8 @@ if ($socid > 0) { $amount2 = ($showconfirminfo['amount_ttc'] - $amount1); $formquestion = array( 'text' => $langs->trans('TypeAmountOfEachNewDiscount'), - array('type' => 'text', 'name' => 'amount_ttc_1', 'label' => $langs->trans("AmountTTC").' 1', 'value' => $amount1, 'size' => '5'), - array('type' => 'text', 'name' => 'amount_ttc_2', 'label' => $langs->trans("AmountTTC").' 2', 'value' => $amount2, 'size' => '5') + 0 => array('type' => 'text', 'name' => 'amount_ttc_1', 'label' => $langs->trans("AmountTTC").' 1', 'value' => $amount1, 'size' => '5'), + 1 => array('type' => 'text', 'name' => 'amount_ttc_2', 'label' => $langs->trans("AmountTTC").' 2', 'value' => $amount2, 'size' => '5') ); $langs->load("dict"); print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.$showconfirminfo['rowid'].($backtopage ? '&backtopage='.urlencode($backtopage) : ''), $langs->trans('SplitDiscount'), $langs->trans('ConfirmSplitDiscount', price($showconfirminfo['amount_ttc']), $langs->transnoentities("Currency".$conf->currency)), 'confirm_split', $formquestion, 0, 0); diff --git a/htdocs/commande/agenda.php b/htdocs/commande/agenda.php index 9ffb69fbb9c..af2a5da5594 100644 --- a/htdocs/commande/agenda.php +++ b/htdocs/commande/agenda.php @@ -96,7 +96,7 @@ restrictedArea($user, 'commande', $object->id, '', '', 'fk_soc', 'rowid', $isdra * Actions */ -$parameters = array('id'=>$id); +$parameters = array('id' => $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'); @@ -191,14 +191,14 @@ if ($object->id > 0) { $objthirdparty = $object; $objcon = new stdClass(); - $out = '&origin='.urlencode($object->element.(property_exists($object, 'module') ? '@'.$object->module : '')).'&originid='.urlencode($object->id); + $out = '&origin='.urlencode((string) ($object->element.(property_exists($object, 'module') ? '@'.$object->module : ''))).'&originid='.urlencode((string) ($object->id)); $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id; $out .= '&backtopage='.urlencode($urlbacktopage); $permok = $user->hasRight('agenda', 'myactions', 'create'); if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.='id.'&action='.$action.'&origin='.urlencode(GETPOST('origin')).'&originid='.urlencode(GETPOSTINT('originid')); + $backtopage = $_SERVER["PHP_SELF"].'?socid='.$thirdparty->id.'&action='.$action.'&origin='.urlencode((string) (GETPOST('origin'))).'&originid='.urlencode((string) (GETPOSTINT('originid'))); include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; print ''; @@ -1953,7 +1953,7 @@ if ($action == 'create' && $usercancreate) { } // Shipping Method - if (isModEnabled('delivery_note')) { + if (isModEnabled('shipping')) { print ''.$langs->trans('SendingMethod').''; print img_picto('', 'object_dolly', 'class="pictofixedwidth"'); $form->selectShippingMethod(((GETPOSTISSET('shipping_method_id') && GETPOSTINT('shipping_method_id') != 0) ? GETPOST('shipping_method_id') : $shipping_method_id), 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); @@ -2593,7 +2593,7 @@ if ($action == 'create' && $usercancreate) { print ''; // Shipping Method - if (isModEnabled('delivery_note')) { + if (isModEnabled('shipping')) { print ''; $editenable = $usercancreate; print $form->editfieldkey("SendingMethod", 'shippingmethod', '', $object, $editenable); @@ -2804,20 +2804,24 @@ if ($action == 'create' && $usercancreate) { print '' . $langs->transcountry("AmountLT1", $mysoc->country_code) . ''; print '' . price($object->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency) . ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($object->total_localtax1, 0, $langs, 0, -1, -1, $object->multicurrency_code) . ''; + $object->multicurrency_total_localtax1 = price2num($object->total_localtax1 * $object->multicurrency_tx, 'MT'); + + print '' . price($object->multicurrency_total_localtax1, 0, $langs, 0, -1, -1, $object->multicurrency_code) . ''; } print ''; + } - // Amount Local Taxes - if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) { - print ''; - print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ''; - print '' . price($object->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency) . ''; - if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($object->total_localtax2, 0, $langs, 0, -1, -1, $object->multicurrency_code) . ''; - } - print ''; + // Amount Local Taxes + if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) { + print ''; + print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ''; + print '' . price($object->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency) . ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + $object->multicurrency_total_localtax2 = price2num($object->total_localtax2 * $object->multicurrency_tx, 'MT'); + + print '' . price($object->multicurrency_total_localtax2, 0, $langs, 0, -1, -1, $object->multicurrency_code) . ''; } + print ''; } print ''; @@ -2995,14 +2999,14 @@ if ($action == 'create' && $usercancreate) { }*/ $numshipping = 0; - if (isModEnabled('delivery_note')) { + if (isModEnabled('shipping')) { $numshipping = $object->countNbOfShipments(); } // Create shipment if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && ($object->getNbOfProductsLines() > 0 || getDolGlobalString('STOCK_SUPPORTS_SERVICES'))) { if ((getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION') && $user->hasRight('expedition', 'creer')) || (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY') && $user->hasRight('expedition', 'delivery', 'creer'))) { - $arrayforbutaction[] = array('lang' => 'sendings', 'enabled' => (isModEnabled("delivery_note") && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && ($object->getNbOfProductsLines() > 0 || getDolGlobalString('STOCK_SUPPORTS_SERVICES')))), 'perm' => $user->hasRight('expedition', 'creer'), 'label' => 'CreateShipment', 'url' => '/expedition/shipment.php?id='.$object->id); + $arrayforbutaction[] = array('lang' => 'sendings', 'enabled' => (isModEnabled("shipping") && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && ($object->getNbOfProductsLines() > 0 || getDolGlobalString('STOCK_SUPPORTS_SERVICES')))), 'perm' => $user->hasRight('expedition', 'creer'), 'label' => 'CreateShipment', 'url' => '/expedition/shipment.php?id='.$object->id); /* if ($user->hasRight('expedition', 'creer')) { print dolGetButtonAction('', $langs->trans('CreateShipment'), 'default', DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id, ''); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index d89d3b39dfb..0929345915b 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -13,6 +13,7 @@ * Copyright (C) 2016-2022 Ferran Marcet * Copyright (C) 2021-2024 Frédéric France * Copyright (C) 2022 Gauthier VERDOL + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -252,20 +253,6 @@ class Commande extends CommonOrder */ public $lines = array(); - // Multicurrency - /** - * @var int Currency ID - */ - public $fk_multicurrency; - - /** - * @var string multicurrency code - */ - public $multicurrency_code; - public $multicurrency_tx; - public $multicurrency_total_ht; - public $multicurrency_total_tva; - public $multicurrency_total_ttc; //! key of module source when order generated from a dedicated module ('cashdesk', 'takepos', ...) public $module_source; @@ -310,7 +297,7 @@ class Commande extends CommonOrder // BEGIN MODULEBUILDER PROPERTIES /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 10), @@ -1316,8 +1303,8 @@ class Commande extends CommonOrder { global $conf, $hookmanager; - dol_include_once('/multicurrency/class/multicurrency.class.php'); - dol_include_once('/core/class/extrafields.class.php'); + require_once DOL_DOCUMENT_ROOT . '/multicurrency/class/multicurrency.class.php'; + require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $error = 0; @@ -3825,7 +3812,7 @@ class Commande extends CommonOrder $result = ''; - if (isModEnabled("delivery_note") && ($option == '1' || $option == '2')) { + if (isModEnabled("shipping") && ($option == '1' || $option == '2')) { $url = DOL_URL_ROOT.'/expedition/shipment.php?id='.$this->id; } else { $url = DOL_URL_ROOT.'/commande/card.php?id='.$this->id; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 54ba84705cb..e01cc02b357 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -12,6 +12,7 @@ * Copyright (C) 2016-2023 Ferran Marcet * Copyright (C) 2018-2023 Charlene Benke * Copyright (C) 2021-2024 Anthony Berton + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -183,7 +184,7 @@ $arrayfields = array( 'typent.code' => array('label' => "ThirdPartyType", 'checked' => $checkedtypetiers, 'position' => 55), 'c.date_commande' => array('label' => "OrderDateShort", 'checked' => 1, 'position' => 60, 'csslist' => 'nowraponall'), 'c.date_delivery' => array('label' => "DateDeliveryPlanned", 'checked' => 1, 'enabled' => !getDolGlobalString('ORDER_DISABLE_DELIVERY_DATE'), 'position' => 65, 'csslist' => 'nowraponall'), - 'c.fk_shipping_method' => array('label' => "SendingMethod", 'checked' => -1, 'position' => 66 , 'enabled' => isModEnabled("delivery_note")), + 'c.fk_shipping_method' => array('label' => "SendingMethod", 'checked' => -1, 'position' => 66 , 'enabled' => isModEnabled("shipping")), 'c.fk_cond_reglement' => array('label' => "PaymentConditionsShort", 'checked' => -1, 'position' => 67), 'c.fk_mode_reglement' => array('label' => "PaymentMode", 'checked' => -1, 'position' => 68), 'c.fk_input_reason' => array('label' => "Channel", 'checked' => -1, 'position' => 69), @@ -206,7 +207,7 @@ $arrayfields = array( 'c.date_cloture' => array('label' => "DateClosing", 'checked' => 0, 'position' => 130), 'c.note_public' => array('label' => 'NotePublic', 'checked' => 0, 'enabled' => (!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES')), 'position' => 135, 'searchall' => 1), 'c.note_private' => array('label' => 'NotePrivate', 'checked' => 0, 'enabled' => (!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES')), 'position' => 140), - 'shippable' => array('label' => "Shippable", 'checked' => 1,'enabled' => (isModEnabled("delivery_note")), 'position' => 990), + 'shippable' => array('label' => "Shippable", 'checked' => 1,'enabled' => (isModEnabled("shipping")), 'position' => 990), 'c.facture' => array('label' => "Billed", 'checked' => 1, 'enabled' => (!getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT')), 'position' => 995), 'c.import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'visible' => -2, 'position' => 999), 'c.fk_statut' => array('label' => "Status", 'checked' => 1, 'position' => 1000) @@ -592,7 +593,7 @@ if (empty($reshook)) { if ($nb_bills_created == 1) { $texttoshow = $langs->trans('BillXCreated', '{s1}'); - $texttoshow = str_replace('{s1}', ''.$lastref.'', $texttoshow); + $texttoshow = str_replace('{s1}', ''.$lastref.'', $texttoshow); setEventMessages($texttoshow, null, 'mesgs'); } else { setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs'); @@ -616,10 +617,10 @@ if (empty($reshook)) { $param .= '&search_all='.urlencode($search_all); } if ($show_files) { - $param .= '&show_files='.urlencode($show_files); + $param .= '&show_files='.urlencode((string) ($show_files)); } if ($socid > 0) { - $param .= '&socid='.urlencode($socid); + $param .= '&socid='.urlencode((string) ($socid)); } if ($search_status != '') { $param .= '&search_status='.urlencode($search_status); @@ -652,10 +653,10 @@ if (empty($reshook)) { $param .= '&search_ref_customer='.urlencode($search_ref_customer); } if ($search_user > 0) { - $param .= '&search_user='.urlencode($search_user); + $param .= '&search_user='.urlencode((string) ($search_user)); } if ($search_sale > 0) { - $param .= '&search_sale='.urlencode($search_sale); + $param .= '&search_sale='.urlencode((string) ($search_sale)); } if ($search_total_ht != '') { $param .= '&search_total_ht='.urlencode($search_total_ht); @@ -783,11 +784,7 @@ if (!$error && $massaction === 'setbilled' && $permissiontoclose) { } if (!$error) { - if ($nbok > 1) { - setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - } else { - setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - } + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); $db->commit(); } else { $db->rollback(); @@ -908,7 +905,7 @@ if ($search_billed != '' && $search_billed >= 0) { } if ($search_status != '') { if ($search_status <= 3 && $search_status >= -1) { // status from -1 to 3 are real status (other are virtual combination) - if ($search_status == 1 && !isModEnabled('delivery_note')) { + if ($search_status == 1 && !isModEnabled('shipping')) { $sql .= ' AND c.fk_statut IN (1,2)'; // If module expedition disabled, we include order with status "sent" into "validated" } else { $sql .= ' AND c.fk_statut = '.((int) $search_status); // draft, validated, in process or canceled @@ -1165,7 +1162,7 @@ if ($search_status == -2) { $title .= ' - '.$langs->trans('StatusOrderToProcessShort'); } if ($search_status == -3) { - $title .= ' - '.$langs->trans('StatusOrderValidated').', '.(!isModEnabled('delivery_note') ? '' : $langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill'); + $title .= ' - '.$langs->trans('StatusOrderValidated').', '.(!isModEnabled('shipping') ? '' : $langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill'); } if ($search_status == -4) { $title .= ' - '.$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort"); @@ -1242,10 +1239,10 @@ if ($search_ref_customer) { $param .= '&search_ref_customer='.urlencode($search_ref_customer); } if ($search_user > 0) { - $param .= '&search_user='.urlencode($search_user); + $param .= '&search_user='.urlencode((string) ($search_user)); } if ($search_sale > 0) { - $param .= '&search_sale='.urlencode($search_sale); + $param .= '&search_sale='.urlencode((string) ($search_sale)); } if ($search_total_ht != '') { $param .= '&search_total_ht='.urlencode($search_total_ht); @@ -1257,7 +1254,7 @@ if ($search_total_ttc != '') { $param .= '&search_total_ttc='.urlencode($search_total_ttc); } if ($search_warehouse != '') { - $param .= '&search_warehouse='.urlencode($search_warehouse); + $param .= '&search_warehouse='.urlencode((string) ($search_warehouse)); } if ($search_login) { $param .= '&search_login='.urlencode($search_login); @@ -1290,19 +1287,19 @@ if ($search_state != '') { $param .= '&search_state='.urlencode($search_state); } if ($search_country != '') { - $param .= '&search_country='.urlencode($search_country); + $param .= '&search_country='.urlencode((string) ($search_country)); } if ($search_type_thirdparty && $search_type_thirdparty != '-1') { - $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); + $param .= '&search_type_thirdparty='.urlencode((string) ($search_type_thirdparty)); } if ($search_product_category != '') { - $param .= '&search_product_category='.urlencode($search_product_category); + $param .= '&search_product_category='.urlencode((string) ($search_product_category)); } if (($search_categ_cus > 0) || ($search_categ_cus == -2)) { - $param .= '&search_categ_cus='.urlencode($search_categ_cus); + $param .= '&search_categ_cus='.urlencode((string) ($search_categ_cus)); } if ($show_files) { - $param .= '&show_files='.urlencode($show_files); + $param .= '&show_files='.urlencode((string) ($show_files)); } if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); @@ -1311,16 +1308,16 @@ if ($search_billed != '') { $param .= '&search_billed='.urlencode($search_billed); } if ($search_fk_cond_reglement > 0) { - $param .= '&search_fk_cond_reglement='.urlencode($search_fk_cond_reglement); + $param .= '&search_fk_cond_reglement='.urlencode((string) ($search_fk_cond_reglement)); } if ($search_fk_shipping_method > 0) { - $param .= '&search_fk_shipping_method='.urlencode($search_fk_shipping_method); + $param .= '&search_fk_shipping_method='.urlencode((string) ($search_fk_shipping_method)); } if ($search_fk_mode_reglement > 0) { - $param .= '&search_fk_mode_reglement='.urlencode($search_fk_mode_reglement); + $param .= '&search_fk_mode_reglement='.urlencode((string) ($search_fk_mode_reglement)); } if ($search_fk_input_reason > 0) { - $param .= '&search_fk_input_reason='.urlencode($search_fk_input_reason); + $param .= '&search_fk_input_reason='.urlencode((string) ($search_fk_input_reason)); } // Add $param from extra fields diff --git a/htdocs/commande/list_det.php b/htdocs/commande/list_det.php index 0451f7d48fe..2adbd25a7d0 100644 --- a/htdocs/commande/list_det.php +++ b/htdocs/commande/list_det.php @@ -195,7 +195,7 @@ $arrayfields = array( 'typent.code' => array('label' => "ThirdPartyType", 'checked' => $checkedtypetiers, 'position' => 55), 'c.date_commande' => array('label' => "OrderDateShort", 'checked' => 1, 'position' => 60), 'c.date_delivery' => array('label' => "DateDeliveryPlanned", 'checked' => 1, 'enabled' => !getDolGlobalString('ORDER_DISABLE_DELIVERY_DATE'), 'position' => 65), - 'c.fk_shipping_method' => array('label' => "SendingMethod", 'checked' => -1, 'position' => 66 , 'enabled' => isModEnabled('delivery_note')), + 'c.fk_shipping_method' => array('label' => "SendingMethod", 'checked' => -1, 'position' => 66 , 'enabled' => isModEnabled('shipping')), 'c.fk_cond_reglement' => array('label' => "PaymentConditionsShort", 'checked' => -1, 'position' => 67), 'c.fk_mode_reglement' => array('label' => "PaymentMode", 'checked' => -1, 'position' => 68), 'c.fk_input_reason' => array('label' => "Channel", 'checked' => -1, 'position' => 69), @@ -219,7 +219,7 @@ $arrayfields = array( 'c.date_cloture' => array('label' => "DateClosing", 'checked' => 0, 'position' => 130), 'c.note_public' => array('label' => 'NotePublic', 'checked' => 0, 'enabled' => (!getDolGlobalString('MAIN_LIST_ALLOW_PUBLIC_NOTES')), 'position' => 135), 'c.note_private' => array('label' => 'NotePrivate', 'checked' => 0, 'enabled' => (!getDolGlobalString('MAIN_LIST_ALLOW_PRIVATE_NOTES')), 'position' => 140), - 'shippable' => array('label' => "Shippable", 'checked' => 1,'enabled' => (isModEnabled('delivery_note')), 'position' => 990), + 'shippable' => array('label' => "Shippable", 'checked' => 1,'enabled' => (isModEnabled('shipping')), 'position' => 990), 'c.facture' => array('label' => "Billed", 'checked' => 1, 'enabled' => (!getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT')), 'position' => 995), 'c.import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'visible' => -2, 'position' => 999), 'c.fk_statut' => array('label' => "Status", 'checked' => 1, 'position' => 1000) @@ -470,7 +470,7 @@ if ($search_billed != '' && $search_billed >= 0) { } if ($search_status != '') { if ($search_status <= 3 && $search_status >= -1) { // status from -1 to 3 are real status (other are virtual combination) - if ($search_status == 1 && !isModEnabled('delivery_note')) { + if ($search_status == 1 && !isModEnabled('shipping')) { $sql .= ' AND c.fk_statut IN (1,2)'; // If module expedition disabled, we include order with status "sent" into "validated" } else { $sql .= ' AND c.fk_statut = '.((int) $search_status); // draft, validated, in process or canceled @@ -685,7 +685,7 @@ if ($resql) { $title .= ' - '.$langs->trans('StatusOrderToProcessShort'); } if ($search_status == -3) { - $title .= ' - '.$langs->trans('StatusOrderValidated').', '.(!isModEnabled('delivery_note') ? '' : $langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill'); + $title .= ' - '.$langs->trans('StatusOrderValidated').', '.(!isModEnabled('shipping') ? '' : $langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill'); } if ($search_status == -4) { $title .= ' - '.$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort"); @@ -716,7 +716,7 @@ if ($resql) { $param .= '&sall='.urlencode($sall); } if ($socid > 0) { - $param .= '&socid='.urlencode($socid); + $param .= '&socid='.urlencode((string) ($socid)); } if ($search_id) { $param .= '&search_id='.urlencode($search_id); @@ -762,7 +762,7 @@ if ($resql) { $param .= '&search_ref_customer='.urlencode($search_ref_customer); } if ($search_user > 0) { - $param .= '&search_user='.urlencode($search_user); + $param .= '&search_user='.urlencode((string) ($search_user)); } if ($search_sale > 0) { $param .= '&search_sale='.urlencode($search_sale); @@ -777,7 +777,7 @@ if ($resql) { $param .= '&search_total_ttc='.urlencode($search_total_ttc); } if ($search_warehouse != '') { - $param .= '&search_warehouse='.urlencode($search_warehouse); + $param .= '&search_warehouse='.urlencode((string) ($search_warehouse)); } if ($search_login) { $param .= '&search_login='.urlencode($search_login); @@ -810,10 +810,10 @@ if ($resql) { $param .= '&search_state='.urlencode($search_state); } if ($search_country != '') { - $param .= '&search_country='.urlencode($search_country); + $param .= '&search_country='.urlencode((string) ($search_country)); } if ($search_type_thirdparty && $search_type_thirdparty != '-1') { - $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); + $param .= '&search_type_thirdparty='.urlencode((string) ($search_type_thirdparty)); } if (!empty($search_product_category_array)) { foreach ($search_product_category_array as $tmpval) { @@ -821,10 +821,10 @@ if ($resql) { } } if (($search_categ_cus > 0) || ($search_categ_cus == -2)) { - $param .= '&search_categ_cus='.urlencode($search_categ_cus); + $param .= '&search_categ_cus='.urlencode((string) ($search_categ_cus)); } if ($show_files) { - $param .= '&show_files='.urlencode($show_files); + $param .= '&show_files='.urlencode((string) ($show_files)); } if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); @@ -833,16 +833,16 @@ if ($resql) { $param .= '&search_billed='.urlencode($search_billed); } if ($search_fk_cond_reglement > 0) { - $param .= '&search_fk_cond_reglement='.urlencode($search_fk_cond_reglement); + $param .= '&search_fk_cond_reglement='.urlencode((string) ($search_fk_cond_reglement)); } if ($search_fk_shipping_method > 0) { - $param .= '&search_fk_shipping_method='.urlencode($search_fk_shipping_method); + $param .= '&search_fk_shipping_method='.urlencode((string) ($search_fk_shipping_method)); } if ($search_fk_mode_reglement > 0) { - $param .= '&search_fk_mode_reglement='.urlencode($search_fk_mode_reglement); + $param .= '&search_fk_mode_reglement='.urlencode((string) ($search_fk_mode_reglement)); } if ($search_fk_input_reason > 0) { - $param .= '&search_fk_input_reason='.urlencode($search_fk_input_reason); + $param .= '&search_fk_input_reason='.urlencode((string) ($search_fk_input_reason)); } if (!empty($productobuy)) { $param .= '&productobuy='.urlencode($productobuy); diff --git a/htdocs/compta/bank/account_statement_document.php b/htdocs/compta/bank/account_statement_document.php index 26613a6bb49..9585ac55973 100644 --- a/htdocs/compta/bank/account_statement_document.php +++ b/htdocs/compta/bank/account_statement_document.php @@ -130,7 +130,7 @@ if (!empty($numref)) { $object->fetch_thirdparty(); $upload_dir = $conf->bank->dir_output."/".$id."/statement/".dol_sanitizeFileName($numref); } -$backtopage = $_SERVER['PHP_SELF']."?account=".urlencode($id)."&num=".urlencode($numref); +$backtopage = $_SERVER['PHP_SELF']."?account=".urlencode((string) ($id))."&num=".urlencode((string) ($numref)); include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 2a3672b0cd9..82184b9ecb7 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -288,16 +288,16 @@ if ((GETPOST('confirm_savestatement', 'alpha') || GETPOST('confirm_reconcile', ' if (!$error) { $param = 'action=reconcile&contextpage=banktransactionlist&id='.((int) $object->id).'&search_account='.((int) $object->id); if ($page) { - $param .= '&page='.urlencode($page); + $param .= '&page='.urlencode((string) ($page)); } if ($offset) { - $param .= '&offset='.urlencode($offset); + $param .= '&offset='.urlencode((string) ($offset)); } if ($limit) { $param .= '&limit='.((int) $limit); } if ($search_conciliated != '' && $search_conciliated != '-1') { - $param .= '&search_conciliated='.urlencode($search_conciliated); + $param .= '&search_conciliated='.urlencode((string) ($search_conciliated)); } if ($search_thirdparty_user) { $param .= '&search_thirdparty='.urlencode($search_thirdparty_user); @@ -449,7 +449,7 @@ if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.((int) $limit); } if ($id > 0) { - $param .= '&id='.urlencode($id); + $param .= '&id='.urlencode((string) ($id)); } if (!empty($ref)) { $param .= '&ref='.urlencode($ref); @@ -473,19 +473,19 @@ if (!empty($search_credit)) { $param .= '&search_credit='.urlencode($search_credit); } if ($search_account > 0) { - $param .= '&search_account='.urlencode($search_account); + $param .= '&search_account='.urlencode((string) ($search_account)); } if (!empty($search_num_releve)) { $param .= '&search_num_releve='.urlencode($search_num_releve); } if ($search_conciliated != '' && $search_conciliated != '-1') { - $param .= '&search_conciliated='.urlencode($search_conciliated); + $param .= '&search_conciliated='.urlencode((string) ($search_conciliated)); } if ($search_fk_bordereau > 0) { - $param .= '$&search_fk_bordereau='.urlencode($search_fk_bordereau); + $param .= '$&search_fk_bordereau='.urlencode((string) ($search_fk_bordereau)); } if ($search_bid > 0) { - $param .= '&search_bid='.urlencode($search_bid); + $param .= '&search_bid='.urlencode((string) ($search_bid)); } if (dol_strlen($search_dt_start) > 0) { $param .= '&search_start_dtmonth='.GETPOSTINT('search_start_dtmonth').'&search_start_dtday='.GETPOSTINT('search_start_dtday').'&search_start_dtyear='.GETPOSTINT('search_start_dtyear'); @@ -503,7 +503,7 @@ if ($search_req_nb) { $param .= '&req_nb='.urlencode($search_req_nb); } if (GETPOSTINT("search_thirdparty")) { - $param .= '&thirdparty='.urlencode(GETPOSTINT("search_thirdparty")); + $param .= '&thirdparty='.urlencode((string) (GETPOSTINT("search_thirdparty"))); } if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); @@ -1022,7 +1022,7 @@ if ($resql) { // We can add page now to param if ($page != '') { - $param .= '&page='.urlencode($page); + $param .= '&page='.urlencode((string) ($page)); } $moreforfilter = ''; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 980139ac752..e871b6dd754 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -10,6 +10,7 @@ * Copyright (C) 2016 Ferran Marcet * Copyright (C) 2019 JC Prieto * Copyright (C) 2022-2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -311,49 +312,49 @@ class Account extends CommonObject // BEGIN MODULEBUILDER PROPERTIES /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), - 'ref' =>array('type'=>'varchar(12)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>25), - 'label' =>array('type'=>'varchar(30)', 'label'=>'Label', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>30), - 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>35, 'index'=>1), - 'bank' =>array('type'=>'varchar(60)', 'label'=>'Bank', 'enabled'=>1, 'visible'=>-1, 'position'=>40), - 'code_banque' =>array('type'=>'varchar(128)', 'label'=>'Code banque', 'enabled'=>1, 'visible'=>-1, 'position'=>45), - 'code_guichet' =>array('type'=>'varchar(6)', 'label'=>'Code guichet', 'enabled'=>1, 'visible'=>-1, 'position'=>50), - 'number' =>array('type'=>'varchar(255)', 'label'=>'Number', 'enabled'=>1, 'visible'=>-1, 'position'=>55), - 'cle_rib' =>array('type'=>'varchar(5)', 'label'=>'Cle rib', 'enabled'=>1, 'visible'=>-1, 'position'=>60), - 'bic' =>array('type'=>'varchar(11)', 'label'=>'Bic', 'enabled'=>1, 'visible'=>-1, 'position'=>65), - 'iban_prefix' =>array('type'=>'varchar(34)', 'label'=>'Iban prefix', 'enabled'=>1, 'visible'=>-1, 'position'=>70), - 'country_iban' =>array('type'=>'varchar(2)', 'label'=>'Country iban', 'enabled'=>1, 'visible'=>-1, 'position'=>75), - 'cle_iban' =>array('type'=>'varchar(2)', 'label'=>'Cle iban', 'enabled'=>1, 'visible'=>-1, 'position'=>80), - 'domiciliation' =>array('type'=>'varchar(255)', 'label'=>'Domiciliation', 'enabled'=>1, 'visible'=>-1, 'position'=>85), - 'state_id' =>array('type'=>'integer', 'label'=>'StateId', 'enabled'=>1, 'visible'=>-1, 'position'=>90), - 'fk_pays' =>array('type'=>'integer', 'label'=>'Country', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>95), - 'proprio' =>array('type'=>'varchar(60)', 'label'=>'Proprio', 'enabled'=>1, 'visible'=>-1, 'position'=>100), - 'owner_address' =>array('type'=>'varchar(255)', 'label'=>'Owner address', 'enabled'=>1, 'visible'=>-1, 'position'=>105), - 'owner_zip' =>array('type'=>'varchar(25)', 'label'=>'Owner zip', 'enabled'=>1, 'visible'=>-1, 'position'=>106), - 'owner_town' =>array('type'=>'varchar(50)', 'label'=>'Owner town', 'enabled'=>1, 'visible'=>-1, 'position'=>107), - 'owner_country_id' =>array('type'=>'integer', 'label'=>'Owner country', 'enabled'=>1, 'visible'=>-1, 'position'=>108), - 'courant' =>array('type'=>'smallint(6)', 'label'=>'Courant', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>110), - 'clos' =>array('type'=>'smallint(6)', 'label'=>'Clos', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>115), - 'rappro' =>array('type'=>'smallint(6)', 'label'=>'Rappro', 'enabled'=>1, 'visible'=>-1, 'position'=>120), - 'url' =>array('type'=>'varchar(128)', 'label'=>'Url', 'enabled'=>1, 'visible'=>-1, 'position'=>125), - 'account_number' =>array('type'=>'varchar(32)', 'label'=>'Account number', 'enabled'=>1, 'visible'=>-1, 'position'=>130), - 'fk_accountancy_journal' =>array('type'=>'integer', 'label'=>'Accountancy journal ID', 'enabled'=>1, 'visible'=>-1, 'position'=>132), - 'accountancy_journal' =>array('type'=>'varchar(20)', 'label'=>'Accountancy journal', 'enabled'=>1, 'visible'=>-1, 'position'=>135), - 'currency_code' =>array('type'=>'varchar(3)', 'label'=>'Currency code', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>140), - 'min_allowed' =>array('type'=>'integer', 'label'=>'Min allowed', 'enabled'=>1, 'visible'=>-1, 'position'=>145), - 'min_desired' =>array('type'=>'integer', 'label'=>'Min desired', 'enabled'=>1, 'visible'=>-1, 'position'=>150), - 'comment' =>array('type'=>'text', 'label'=>'Comment', 'enabled'=>1, 'visible'=>-1, 'position'=>155), - 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>156), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>157), - 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk user author', 'enabled'=>1, 'visible'=>-1, 'position'=>160), - 'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>165), - 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>170), - 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'position'=>175), - 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>180), - 'extraparams' =>array('type'=>'varchar(255)', 'label'=>'Extraparams', 'enabled'=>1, 'visible'=>-1, 'position'=>185), + 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 10), + 'ref' => array('type' => 'varchar(12)', 'label' => 'Ref', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'showoncombobox' => 1, 'position' => 25), + 'label' => array('type' => 'varchar(30)', 'label' => 'Label', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 30), + 'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 35, 'index' => 1), + 'bank' => array('type' => 'varchar(60)', 'label' => 'Bank', 'enabled' => 1, 'visible' => -1, 'position' => 40), + 'code_banque' => array('type' => 'varchar(128)', 'label' => 'Code banque', 'enabled' => 1, 'visible' => -1, 'position' => 45), + 'code_guichet' => array('type' => 'varchar(6)', 'label' => 'Code guichet', 'enabled' => 1, 'visible' => -1, 'position' => 50), + 'number' => array('type' => 'varchar(255)', 'label' => 'Number', 'enabled' => 1, 'visible' => -1, 'position' => 55), + 'cle_rib' => array('type' => 'varchar(5)', 'label' => 'Cle rib', 'enabled' => 1, 'visible' => -1, 'position' => 60), + 'bic' => array('type' => 'varchar(11)', 'label' => 'Bic', 'enabled' => 1, 'visible' => -1, 'position' => 65), + 'iban_prefix' => array('type' => 'varchar(34)', 'label' => 'Iban prefix', 'enabled' => 1, 'visible' => -1, 'position' => 70), + 'country_iban' => array('type' => 'varchar(2)', 'label' => 'Country iban', 'enabled' => 1, 'visible' => -1, 'position' => 75), + 'cle_iban' => array('type' => 'varchar(2)', 'label' => 'Cle iban', 'enabled' => 1, 'visible' => -1, 'position' => 80), + 'domiciliation' => array('type' => 'varchar(255)', 'label' => 'Domiciliation', 'enabled' => 1, 'visible' => -1, 'position' => 85), + 'state_id' => array('type' => 'integer', 'label' => 'StateId', 'enabled' => 1, 'visible' => -1, 'position' => 90), + 'fk_pays' => array('type' => 'integer', 'label' => 'Country', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 95), + 'proprio' => array('type' => 'varchar(60)', 'label' => 'Proprio', 'enabled' => 1, 'visible' => -1, 'position' => 100), + 'owner_address' => array('type' => 'varchar(255)', 'label' => 'Owner address', 'enabled' => 1, 'visible' => -1, 'position' => 105), + 'owner_zip' => array('type' => 'varchar(25)', 'label' => 'Owner zip', 'enabled' => 1, 'visible' => -1, 'position' => 106), + 'owner_town' => array('type' => 'varchar(50)', 'label' => 'Owner town', 'enabled' => 1, 'visible' => -1, 'position' => 107), + 'owner_country_id' => array('type' => 'integer', 'label' => 'Owner country', 'enabled' => 1, 'visible' => -1, 'position' => 108), + 'courant' => array('type' => 'smallint(6)', 'label' => 'Courant', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 110), + 'clos' => array('type' => 'smallint(6)', 'label' => 'Clos', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 115), + 'rappro' => array('type' => 'smallint(6)', 'label' => 'Rappro', 'enabled' => 1, 'visible' => -1, 'position' => 120), + 'url' => array('type' => 'varchar(128)', 'label' => 'Url', 'enabled' => 1, 'visible' => -1, 'position' => 125), + 'account_number' => array('type' => 'varchar(32)', 'label' => 'Account number', 'enabled' => 1, 'visible' => -1, 'position' => 130), + 'fk_accountancy_journal' => array('type' => 'integer', 'label' => 'Accountancy journal ID', 'enabled' => 1, 'visible' => -1, 'position' => 132), + 'accountancy_journal' => array('type' => 'varchar(20)', 'label' => 'Accountancy journal', 'enabled' => 1, 'visible' => -1, 'position' => 135), + 'currency_code' => array('type' => 'varchar(3)', 'label' => 'Currency code', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 140), + 'min_allowed' => array('type' => 'integer', 'label' => 'Min allowed', 'enabled' => 1, 'visible' => -1, 'position' => 145), + 'min_desired' => array('type' => 'integer', 'label' => 'Min desired', 'enabled' => 1, 'visible' => -1, 'position' => 150), + 'comment' => array('type' => 'text', 'label' => 'Comment', 'enabled' => 1, 'visible' => -1, 'position' => 155), + 'datec' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'visible' => -1, 'position' => 156), + 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 157), + 'fk_user_author' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'Fk user author', 'enabled' => 1, 'visible' => -1, 'position' => 160), + 'fk_user_modif' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'enabled' => 1, 'visible' => -2, 'notnull' => -1, 'position' => 165), + 'note_public' => array('type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'visible' => 0, 'position' => 170), + 'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => 1, 'visible' => 0, 'position' => 175), + 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'visible' => -2, 'position' => 180), + 'extraparams' => array('type' => 'varchar(255)', 'label' => 'Extraparams', 'enabled' => 1, 'visible' => -1, 'position' => 185), ); // END MODULEBUILDER PROPERTIES diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 2f5f532e746..bc973b0045b 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -187,6 +187,7 @@ class BankAccounts extends DolibarrApi * @param string $description Description of the internal wire transfer {@from body}{@required true} * @param float $amount Amount to transfer from the source to the destination BankAccount {@from body}{@required true} * @param float $amount_to Amount to transfer to the destination BankAccount (only when accounts does not share the same currency) {@from body}{@required false} + * @param string $cheque_number Cheque numero {@from body}{@required false} * * @url POST /transfer * @@ -199,7 +200,7 @@ class BankAccounts extends DolibarrApi * @throws RestException 422 Unprocessable Entity: Refer to detailed exception message for the cause * @throws RestException 500 Internal Server Error: Error(s) returned by the RDBMS */ - public function transfer($bankaccount_from_id = 0, $bankaccount_to_id = 0, $date = null, $description = "", $amount = 0.0, $amount_to = 0.0) + public function transfer($bankaccount_from_id = 0, $bankaccount_to_id = 0, $date = null, $description = "", $amount = 0.0, $amount_to = 0.0, $cheque_number = "") { if (!DolibarrApiAccess::$user->hasRight('banque', 'configurer')) { throw new RestException(403); @@ -257,21 +258,21 @@ class BankAccounts extends DolibarrApi // Clean data $description = sanitizeVal($description, 'alphanohtml'); - + $cheque_number = sanitizeVal($cheque_number, 'alphanohtml'); /** * Creating bank line records */ if (!$error) { - $bank_line_id_from = $accountfrom->addline($date, $typefrom, $description, -1 * price2num($amount), '', '', $user); + $bank_line_id_from = $accountfrom->addline($date, $typefrom, $description, -1 * price2num($amount), '', '', $user, $cheque_number); } if (!($bank_line_id_from > 0)) { $error++; } if (!$error) { - $bank_line_id_to = $accountto->addline($date, $typeto, $description, price2num($amount_to), '', '', $user); + $bank_line_id_to = $accountto->addline($date, $typeto, $description, price2num($amount_to), '', '', $user, $cheque_number); } if (!($bank_line_id_to > 0)) { $error++; diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 33ac0d8f817..7e54567fc47 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -197,7 +198,7 @@ class PaymentVarious extends CommonObject // BEGIN MODULEBUILDER PROPERTIES /** - * @var array fields definition + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( // TODO: fill this array @@ -744,7 +745,7 @@ class PaymentVarious extends CommonObject global $action; $hookmanager->initHooks(array('variouspayment')); - $parameters = array('id'=>$this->id, 'getnomurl' => &$result); + $parameters = array('id' => $this->id, 'getnomurl' => &$result); $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) { $result = $hookmanager->resPrint; diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index c0cbdb0447e..6ed9e7d37a9 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -352,7 +352,7 @@ if ($result) { // Confirmations if ($action == 'delete_categ') { - print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".urlencode($rowid)."&cat1=".urlencode(GETPOSTINT("fk_categ"))."&orig_account=".urlencode($orig_account), $langs->trans("RemoveFromRubrique"), $langs->trans("RemoveFromRubriqueConfirm"), "confirm_delete_categ", '', 'yes', 1); + print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".urlencode((string) ($rowid))."&cat1=".urlencode((string) (GETPOSTINT("fk_categ")))."&orig_account=".urlencode((string) ($orig_account)), $langs->trans("RemoveFromRubrique"), $langs->trans("RemoveFromRubriqueConfirm"), "confirm_delete_categ", '', 'yes', 1); } print '
'; diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index ef9206a74ed..480c36cd07e 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -60,7 +60,7 @@ $search_number = GETPOST('search_number', 'alpha'); $search_status = GETPOST('search_status') ? GETPOST('search_status', 'alpha') : 'opened'; // 'all' or '' means 'opened' $optioncss = GETPOST('optioncss', 'alpha'); -$search_category_list =""; +$search_category_list = ""; if (isModEnabled('category')) { $search_category_list = GETPOST("search_category_".Categorie::TYPE_ACCOUNT."_list", "array"); } @@ -101,24 +101,24 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // List of fields to search into when doing a "search in all" $fieldstosearchall = array( - 'b.ref'=>'Ref', - 'b.label'=>'Label', + 'b.ref' => 'Ref', + 'b.label' => 'Label', ); $checkedtypetiers = 0; $arrayfields = array( - 'b.ref'=>array('label'=>$langs->trans("BankAccounts"), 'checked'=>1, 'position'=>10), - 'b.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1, 'position'=>12), - 'accountype'=>array('label'=>$langs->trans("Type"), 'checked'=>1, 'position'=>14), - 'b.number'=>array('label'=>$langs->trans("AccountIdShort"), 'checked'=>1, 'position'=>16), - 'b.account_number'=>array('label'=>$langs->trans("AccountAccounting"), 'checked'=>(isModEnabled('accounting')), 'position'=>18), - 'b.fk_accountancy_journal'=>array('label'=>$langs->trans("AccountancyJournal"), 'checked'=>(isModEnabled('accounting')), 'position'=>20), - 'toreconcile'=>array('label'=>$langs->trans("TransactionsToConciliate"), 'checked'=>1, 'position'=>50), - 'b.currency_code'=>array('label'=>$langs->trans("Currency"), 'checked'=>0, 'position'=>22), - 'b.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), - 'b.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), - 'b.clos'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), - 'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1010), + 'b.ref' => array('label' => $langs->trans("BankAccounts"), 'checked' => 1, 'position' => 10), + 'b.label' => array('label' => $langs->trans("Label"), 'checked' => 1, 'position' => 12), + 'accountype' => array('label' => $langs->trans("Type"), 'checked' => 1, 'position' => 14), + 'b.number' => array('label' => $langs->trans("AccountIdShort"), 'checked' => 1, 'position' => 16), + 'b.account_number' => array('label' => $langs->trans("AccountAccounting"), 'checked' => (isModEnabled('accounting')), 'position' => 18), + 'b.fk_accountancy_journal' => array('label' => $langs->trans("AccountancyJournal"), 'checked' => (isModEnabled('accounting')), 'position' => 20), + 'toreconcile' => array('label' => $langs->trans("TransactionsToConciliate"), 'checked' => 1, 'position' => 50), + 'b.currency_code' => array('label' => $langs->trans("Currency"), 'checked' => 0, 'position' => 22), + 'b.datec' => array('label' => $langs->trans("DateCreation"), 'checked' => 0, 'position' => 500), + 'b.tms' => array('label' => $langs->trans("DateModificationShort"), 'checked' => 0, 'position' => 500), + 'b.clos' => array('label' => $langs->trans("Status"), 'checked' => 1, 'position' => 1000), + 'balance' => array('label' => $langs->trans("Balance"), 'checked' => 1, 'position' => 1010), ); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; @@ -150,7 +150,7 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa $massaction = ''; } -$parameters = array('socid'=>$socid); +$parameters = array('socid' => $socid); $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'); @@ -336,7 +336,7 @@ if ($search_status != '') { $param .= '&search_status='.urlencode($search_status); } if ($show_files) { - $param .= '&show_files='.urlencode($show_files); + $param .= '&show_files='.urlencode((string) ($show_files)); } // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -378,8 +378,8 @@ print ''; $newcardbutton = ''; -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition')); $newcardbutton .= dolGetButtonTitleSeparator(); $newcardbutton .= dolGetButtonTitle($langs->trans('NewFinancialAccount'), '', 'fa fa-plus-circle', 'card.php?action=create', '', $user->hasRight('banque', 'configurer')); @@ -486,7 +486,7 @@ if (!empty($arrayfields['b.currency_code']['checked'])) { 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; // Date creation @@ -503,8 +503,8 @@ if (!empty($arrayfields['b.tms']['checked'])) { if (!empty($arrayfields['b.clos']['checked'])) { print ''; $array = array( - 'opened'=>$langs->trans("Opened"), - 'closed'=>$langs->trans("Closed") + 'opened' => $langs->trans("Opened"), + 'closed' => $langs->trans("Closed") ); print $form->selectarray("search_status", $array, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status minwidth75 maxwidth125 onrightofpage', 1); print ''; @@ -568,7 +568,7 @@ if (!empty($arrayfields['toreconcile']['checked'])) { // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (!empty($arrayfields['b.datec']['checked'])) { @@ -601,7 +601,7 @@ $i = 0; $savnbfield = $totalarray['nbfield']; $totalarray = array(); $totalarray['nbfield'] = 0; -$totalarray['val'] = array('balance'=>0); +$totalarray['val'] = array('balance' => 0); $total = array(); $found = 0; $lastcurrencycode = ''; @@ -799,7 +799,7 @@ foreach ($accounts as $key => $type) { } include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objecttmp, $action); // Note that $action and $objecttmpect may have been modified by hook print $hookmanager->resPrint; // Date creation diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 56eb4e93a6c..34c61ad8b31 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -250,7 +250,7 @@ if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.$limit; } if ($id > 0) { - $param .= '&id='.urlencode($id); + $param .= '&id='.urlencode((string) ($id)); } if (empty($numref)) { diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index ae720d63423..90817a5848d 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -3,6 +3,7 @@ * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2023 Laurent Destailleur * Copyright (C) 2023 Joachim Kueter + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -286,9 +287,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) { if (GETPOSTISSET("clone_sens")) { $object->sens = GETPOSTINT("clone_sens"); - } else { - $object->sens = $object->sens; - } + } // else { $object->sens = $object->sens; } if (GETPOSTISSET("clone_amount")) { $object->amount = GETPOSTFLOAT("clone_amount"); diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index 33f9f0154cd..8a2aa9178f7 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -148,27 +148,27 @@ $search_all = GETPOSTISSET("search_all") ? trim(GETPOST("search_all", 'alpha')) // List of fields to search into when doing a "search in all" $fieldstosearchall = array( - 'v.rowid'=>"Ref", - 'v.label'=>"Label", - 'v.datep'=>"DatePayment", - 'v.datev'=>"DateValue", - 'v.amount'=>$langs->trans("Debit").", ".$langs->trans("Credit"), + 'v.rowid' => "Ref", + 'v.label' => "Label", + 'v.datep' => "DatePayment", + 'v.datev' => "DateValue", + 'v.amount' => $langs->trans("Debit").", ".$langs->trans("Credit"), ); // Definition of fields for lists $arrayfields = array( - 'ref' =>array('label'=>"Ref", 'checked'=>1, 'position'=>100), - 'label' =>array('label'=>"Label", 'checked'=>1, 'position'=>110), - 'datep' =>array('label'=>"DatePayment", 'checked'=>1, 'position'=>120), - 'datev' =>array('label'=>"DateValue", 'checked'=>-1, 'position'=>130), - 'type' =>array('label'=>"PaymentMode", 'checked'=>1, 'position'=>140), - 'project' =>array('label'=>"Project", 'checked'=>1, 'position'=>200, "enabled"=>isModEnabled('project')), - 'bank' =>array('label'=>"BankAccount", 'checked'=>1, 'position'=>300, "enabled"=>isModEnabled("bank")), - 'entry' =>array('label'=>"BankTransactionLine", 'checked'=>1, 'position'=>310, "enabled"=>isModEnabled("bank")), - 'account' =>array('label'=>"AccountAccountingShort", 'checked'=>1, 'position'=>400, "enabled"=>isModEnabled('accounting')), - 'subledger' =>array('label'=>"SubledgerAccount", 'checked'=>1, 'position'=>410, "enabled"=>isModEnabled('accounting')), - 'debit' =>array('label'=>"Debit", 'checked'=>1, 'position'=>500), - 'credit' =>array('label'=>"Credit", 'checked'=>1, 'position'=>510), + 'ref' => array('label' => "Ref", 'checked' => 1, 'position' => 100), + 'label' => array('label' => "Label", 'checked' => 1, 'position' => 110), + 'datep' => array('label' => "DatePayment", 'checked' => 1, 'position' => 120), + 'datev' => array('label' => "DateValue", 'checked' => -1, 'position' => 130), + 'type' => array('label' => "PaymentMode", 'checked' => 1, 'position' => 140), + 'project' => array('label' => "Project", 'checked' => 1, 'position' => 200, "enabled" => isModEnabled('project')), + 'bank' => array('label' => "BankAccount", 'checked' => 1, 'position' => 300, "enabled" => isModEnabled("bank")), + 'entry' => array('label' => "BankTransactionLine", 'checked' => 1, 'position' => 310, "enabled" => isModEnabled("bank")), + 'account' => array('label' => "AccountAccountingShort", 'checked' => 1, 'position' => 400, "enabled" => isModEnabled('accounting')), + 'subledger' => array('label' => "SubledgerAccount", 'checked' => 1, 'position' => 410, "enabled" => isModEnabled('accounting')), + 'debit' => array('label' => "Debit", 'checked' => 1, 'position' => 500), + 'credit' => array('label' => "Credit", 'checked' => 1, 'position' => 510), ); $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -401,7 +401,7 @@ if ($search_datev_end) { $param .= '&search_datev_end='.urlencode($search_datev_end); } if ($search_type_id > 0) { - $param .= '&search_type_id='.urlencode($search_type_id); + $param .= '&search_type_id='.urlencode((string) ($search_type_id)); } if ($search_amount_deb) { $param .= '&search_amount_deb='.urlencode($search_amount_deb); @@ -410,7 +410,7 @@ if ($search_amount_cred) { $param .= '&search_amount_cred='.urlencode($search_amount_cred); } if ($search_bank_account > 0) { - $param .= '&search_account='.urlencode($search_bank_account); + $param .= '&search_account='.urlencode((string) ($search_bank_account)); } if ($search_accountancy_account > 0) { $param .= '&search_accountancy_account='.urlencode($search_accountancy_account); @@ -421,7 +421,7 @@ if ($search_accountancy_subledger > 0) { $url = DOL_URL_ROOT.'/compta/bank/various_payment/card.php?action=create'; if (!empty($socid)) { - $url .= '&socid='.urlencode($socid); + $url .= '&socid='.urlencode((string) ($socid)); } // List of mass actions available @@ -443,8 +443,8 @@ print ''; print ''; $newcardbutton = ''; -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition')); $newcardbutton .= dolGetButtonTitleSeparator(); $newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewVariousPayment'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('banque', 'modifier')); @@ -462,7 +462,7 @@ if ($search_all) { $arrayofmassactions = array(); -$moreforfilter= ''; +$moreforfilter = ''; $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) : ''); // This also change content of $arrayfields @@ -662,7 +662,7 @@ if ($arrayfields['credit']['checked']) { // 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 @@ -904,7 +904,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); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index fe4d5a15f77..74cce92938d 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -6,6 +6,7 @@ * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016 Marcos García * Copyright (C) 2018 Andreu Bisquerra + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -68,7 +69,7 @@ if ($contextpage == 'takepos') { $_GET['optioncss'] = 'print'; } -$arrayofpaymentmode = array('cash'=>'Cash', 'cheque'=>'Cheque', 'card'=>'CreditCard'); +$arrayofpaymentmode = array('cash' => 'Cash', 'cheque' => 'Cheque', 'card' => 'CreditCard'); $arrayofposavailable = array(); if (isModEnabled('cashdesk')) { @@ -180,7 +181,7 @@ if ($action == "start") { $db->commit(); $action = "view"; } else { - $db->rollback; + $db->rollback(); $action = "view"; } } diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index 83b0a56e563..bf6a7310720 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -8,6 +8,7 @@ * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2017 Alexandre Spangaro * Copyright (C) 2018 Andreu Bisquerra + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -59,13 +60,13 @@ $sortorder = 'ASC'; $sortfield = 'b.datev,b.dateo,b.rowid'; $arrayfields = array( - 'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), - 'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1), - 'b.num_chq'=>array('label'=>$langs->trans("Number"), 'checked'=>1), - 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>1), - 'cp.code'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>1), - 'b.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1, 'position'=>600), - 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605), + 'b.rowid' => array('label' => $langs->trans("Ref"), 'checked' => 1), + 'b.dateo' => array('label' => $langs->trans("DateOperationShort"), 'checked' => 1), + 'b.num_chq' => array('label' => $langs->trans("Number"), 'checked' => 1), + 'ba.ref' => array('label' => $langs->trans("BankAccount"), 'checked' => 1), + 'cp.code' => array('label' => $langs->trans("PaymentMode"), 'checked' => 1), + 'b.debit' => array('label' => $langs->trans("Debit"), 'checked' => 1, 'position' => 600), + 'b.credit' => array('label' => $langs->trans("Credit"), 'checked' => 1, 'position' => 605), ); $syear = $object->year_close; @@ -209,7 +210,7 @@ if ($resql) { $transactionspertype = array(); $amountpertype = array(); - $totalarray = array(); + $totalarray = array('nbfield' => 0, 'pos' => array()); while ($i < $num) { $objp = $db->fetch_object($resql); diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index bcc66ade965..04c50f82ffe 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -367,7 +367,7 @@ if ($action == 'create') { * Confirm delete trip */ if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".urlencode($id), $langs->trans("DeleteTrip"), $langs->trans("ConfirmDeleteTrip"), "confirm_delete"); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".urlencode((string) ($id)), $langs->trans("DeleteTrip"), $langs->trans("ConfirmDeleteTrip"), "confirm_delete"); } $soc = new Societe($db); diff --git a/htdocs/compta/facture/agenda-rec.php b/htdocs/compta/facture/agenda-rec.php index 6f1ed587758..542dfd8f6c1 100644 --- a/htdocs/compta/facture/agenda-rec.php +++ b/htdocs/compta/facture/agenda-rec.php @@ -96,7 +96,7 @@ restrictedArea($user, 'facture', $object->id, 'facture_rec', '', 'fk_soc', 'rowi * Actions */ -$parameters = array('id'=>$id); +$parameters = array('id' => $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'); @@ -196,14 +196,14 @@ if ($object->id > 0) { $objthirdparty = $object; $objcon = new stdClass(); - $out = '&origin='.urlencode($object->element.(property_exists($object, 'module') ? '@'.$object->module : '')).'&originid='.urlencode($object->id); + $out = '&origin='.urlencode((string) ($object->element.(property_exists($object, 'module') ? '@'.$object->module : ''))).'&originid='.urlencode((string) ($object->id)); $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id; $out .= '&backtopage='.urlencode($urlbacktopage); $permok = $user->hasRight('paymentbagendaybanktransfer', 'myactions', 'create'); if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.='id, '', '', 'fk_soc', 'rowid', $isdraf * Actions */ -$parameters = array('id'=>$id); +$parameters = array('id' => $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'); @@ -191,14 +191,14 @@ if ($object->id > 0) { $objthirdparty = $object; $objcon = new stdClass(); - $out = '&origin='.urlencode($object->element.(property_exists($object, 'module') ? '@'.$object->module : '')).'&originid='.urlencode($object->id); + $out = '&origin='.urlencode((string) ($object->element.(property_exists($object, 'module') ? '@'.$object->module : ''))).'&originid='.urlencode((string) ($object->id)); $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id; $out .= '&backtopage='.urlencode($urlbacktopage); $permok = $user->hasRight('paymentbagendaybanktransfer', 'myactions', 'create'); if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.=' * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2013 Cédric Salvador - * Copyright (C) 2014-2019 Ferran Marcet + * Copyright (C) 2014-2024 Ferran Marcet * Copyright (C) 2015-2016 Marcos García * Copyright (C) 2018-2023 Frédéric France * Copyright (C) 2022 Gauthier VERDOL * Copyright (C) 2023 Nick Fragoulis + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1273,7 +1274,7 @@ if (empty($reshook)) { $line->fk_parent_line = $fk_parent_line; $line->subprice = -$line->subprice; // invert price for object - $line->pa_ht = $line->pa_ht; // we chose to have buy/cost price always positive, so no revert of sign here + // $line->pa_ht = $line->pa_ht; // we chose to have buy/cost price always positive, so no revert of sign here $line->total_ht = -$line->total_ht; $line->total_tva = -$line->total_tva; $line->total_ttc = -$line->total_ttc; @@ -1662,7 +1663,7 @@ if (empty($reshook)) { null, 0, '', - 1 + (!empty($conf->global->MAIN_DEPOSIT_MULTI_TVA) ? 0 : 1) ); } @@ -3832,7 +3833,7 @@ if ($action == 'create') { $thirdparty = $soc; $discount_type = 0; - $backtopage = $_SERVER["PHP_SELF"].'?socid='.$thirdparty->id.'&action='.$action.'&origin='.urlencode(GETPOST('origin')).'&originid='.urlencode(GETPOSTINT('originid')); + $backtopage = $_SERVER["PHP_SELF"].'?socid='.$thirdparty->id.'&action='.$action.'&origin='.urlencode((string) (GETPOST('origin'))).'&originid='.urlencode((string) (GETPOSTINT('originid'))); include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; print ''; @@ -4459,7 +4460,7 @@ if ($action == 'create') { } // Create a form table - $formquestion = array('text' => $langs->trans("ConfirmClassifyPaidPartiallyQuestion"), array('type' => 'radio', 'name' => 'close_code', 'label' => $langs->trans("Reason"), 'values' => $arrayreasons), array('type' => 'text', 'name' => 'close_note', 'label' => $langs->trans("Comment"), 'value' => '', 'morecss' => 'minwidth300')); + $formquestion = array('text' => $langs->trans("ConfirmClassifyPaidPartiallyQuestion"), 0 => array('type' => 'radio', 'name' => 'close_code', 'label' => $langs->trans("Reason"), 'values' => $arrayreasons), 1 => array('type' => 'text', 'name' => 'close_note', 'label' => $langs->trans("Comment"), 'value' => '', 'morecss' => 'minwidth300')); // Incomplete payment. We ask if reason = discount or other $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidPartially', $object->ref), 'confirm_paid_partially', $formquestion, "yes", 1, 380, 600); } @@ -4491,7 +4492,7 @@ if ($action == 'create') { $arrayreasons[$close[2]['code']] = $close[2]['reason']; // Create a form table - $formquestion = array('text' => $langs->trans("ConfirmCancelBillQuestion"), array('type' => 'radio', 'name' => 'close_code', 'label' => $langs->trans("Reason"), 'values' => $arrayreasons), array('type' => 'text', 'name' => 'close_note', 'label' => $langs->trans("Comment"), 'value' => '', 'morecss' => 'minwidth300')); + $formquestion = array('text' => $langs->trans("ConfirmCancelBillQuestion"), 0 => array('type' => 'radio', 'name' => 'close_code', 'label' => $langs->trans("Reason"), 'values' => $arrayreasons), 1 => array('type' => 'text', 'name' => 'close_note', 'label' => $langs->trans("Comment"), 'value' => '', 'morecss' => 'minwidth300')); $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$object->id, $langs->trans('CancelBill'), $langs->trans('ConfirmCancelBill', $object->ref), 'confirm_canceled', $formquestion, "yes", 1, 270); } @@ -5013,21 +5014,24 @@ if ($action == 'create') { print '' . $langs->transcountry("AmountLT1", $mysoc->country_code) . ''; print '' . price($sign * $object->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency) . ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($sign * $object->total_localtax1, 0, $langs, 0, -1, -1, $object->multicurrency_code) . ''; + $object->multicurrency_total_localtax1 = price2num($object->total_localtax1 * $object->multicurrency_tx, 'MT'); + + print '' . price($sign * $object->multicurrency_total_localtax1, 0, $langs, 0, -1, -1, $object->multicurrency_code) . ''; } print ''; - - if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) { - print ''; - print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ''; - print '' . price($sign * $object->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency) . ''; - if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($sign * $object->total_localtax2, 0, $langs, 0, -1, -1, $object->multicurrency_code) . ''; - } - print ''; - } } + if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) { + print ''; + print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ''; + print '' . price($sign * $object->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency) . ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + $object->multicurrency_total_localtax2 = price2num($object->total_localtax2 * $object->multicurrency_tx, 'MT'); + + print '' . price($sign * $object->multicurrency_total_localtax2, 0, $langs, 0, -1, -1, $object->multicurrency_code) . ''; + } + print ''; + } // Add the revenue stamp if ($selleruserevenustamp) { @@ -5954,23 +5958,24 @@ if ($action == 'create') { // Delete $isErasable = $object->is_erasable(); + $htmltooltip = ''; + if ($isErasable == -4) { + $htmltooltip = $langs->trans('DisabledBecausePayments'); + } elseif ($isErasable == -3) { + $htmltooltip = $langs->trans('DisabledBecauseNotLastSituationInvoice'); + } elseif ($isErasable == -2) { + $htmltooltip = $langs->trans('DisabledBecauseNotLastInvoice'); + } elseif ($isErasable == -1) { + $htmltooltip = $langs->trans('DisabledBecauseDispatchedInBookkeeping'); + } elseif ($isErasable <= 0) { // Any other cases + $htmltooltip = $langs->trans('DisabledBecauseNotErasable'); + } elseif ($objectidnext) { + $htmltooltip = $langs->trans('DisabledBecauseReplacedInvoice'); + } if ($usercandelete || ($usercancreate && $isErasable == 1)) { // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions) $enableDelete = false; $deleteHref = '#'; - $htmltooltip = ''; - if ($isErasable == -4) { - $htmltooltip = $langs->trans('DisabledBecausePayments'); - } elseif ($isErasable == -3) { - $htmltooltip = $langs->trans('DisabledBecauseNotLastSituationInvoice'); - } elseif ($isErasable == -2) { - $htmltooltip = $langs->trans('DisabledBecauseNotLastInvoice'); - } elseif ($isErasable == -1) { - $htmltooltip = $langs->trans('DisabledBecauseDispatchedInBookkeeping'); - } elseif ($isErasable <= 0) { // Any other cases - $htmltooltip = $langs->trans('DisabledBecauseNotErasable'); - } elseif ($objectidnext) { - $htmltooltip = $langs->trans('DisabledBecauseReplacedInvoice'); - } else { + if ($isErasable > 0 && ! $objectidnext) { $deleteHref = $_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=delete&token='.newToken(); $enableDelete = true; } diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 50317b0ece3..e48c0d52c5e 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -8,6 +8,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2017-2024 Frédéric France * Copyright (C) 2023 Nick Fragoulis + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -171,7 +172,7 @@ class FactureRec extends CommonInvoice // BEGIN MODULEBUILDER PROPERTIES /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 10), @@ -1589,7 +1590,7 @@ class FactureRec extends CommonInvoice $statusType = 'status6'; $labelStatus = $langs->transnoentitiesnoconv('Disabled'); } else { - $statusType = 'status0'; + $statusType = 'status0'; // @phan-suppress-current-line PhanPluginRedundantAssignment $labelStatus = $langs->transnoentitiesnoconv('Draft'); } } @@ -1608,7 +1609,7 @@ class FactureRec extends CommonInvoice $statusType = 'status6'; $labelStatus = $langs->transnoentitiesnoconv('Disabled'); } else { - $statusType = 'status0'; + $statusType = 'status0'; // @phan-suppress-current-line PhanPluginRedundantAssignment $labelStatus = $langs->transnoentitiesnoconv('Draft'); } } @@ -1627,7 +1628,7 @@ class FactureRec extends CommonInvoice $statusType = 'status6'; $labelStatus = $langs->transnoentitiesnoconv('Disabled'); } else { - $statusType = 'status0'; + $statusType = 'status0'; // @phan-suppress-current-line PhanPluginRedundantAssignment $labelStatus = $langs->transnoentitiesnoconv('Draft'); } } @@ -1649,7 +1650,7 @@ class FactureRec extends CommonInvoice $statusType = 'status6'; $labelStatus = $langs->transnoentitiesnoconv('Disabled'); } else { - $statusType = 'status0'; + $statusType = 'status0'; // @phan-suppress-current-line PhanPluginRedundantAssignment $labelStatus = $langs->transnoentitiesnoconv('Draft'); } } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 352e23c0431..d1d37f33589 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -194,6 +194,7 @@ class Facture extends CommonInvoice public $date_pointoftax; + /** * @var int Situation cycle reference number */ @@ -290,7 +291,7 @@ class Facture extends CommonInvoice // BEGIN MODULEBUILDER PROPERTIES /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 1), @@ -524,8 +525,8 @@ class Facture extends CommonInvoice // Define some dates $originaldatewhen = $_facrec->date_when; - $nextdatewhen = null; - $previousdaynextdatewhen = null; + $nextdatewhen = null; // @phan-suppress-current-line PhanPluginRedundantAssignment + $previousdaynextdatewhen = null; // @phan-suppress-current-line PhanPluginRedundantAssignment if ($originaldatewhen) { $nextdatewhen = dol_time_plus_duree($originaldatewhen, $_facrec->frequency, $_facrec->unit_frequency); $previousdaynextdatewhen = dol_time_plus_duree($nextdatewhen, -1, 'd'); @@ -5915,7 +5916,7 @@ class Facture extends CommonInvoice return 0; } else { - $this->error = 'Nb of emails sent : '.$nbMailSend.', '.(!empty($errorsMsg)) ? implode(', ', $errorsMsg) : $error; + $this->error = 'Nb of emails sent : '.$nbMailSend.', '.(!empty($errorsMsg) ? implode(', ', $errorsMsg) : $error); dol_syslog(__METHOD__." end - ".$this->error, LOG_INFO); diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 4bbea222033..13a119e35b5 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -438,43 +438,43 @@ if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.((int) $limit); } if ($socid > 0) { - $param .= '&socid='.urlencode($socid); + $param .= '&socid='.urlencode((string) ($socid)); } if ($search_date_startday) { - $param .= '&search_date_startday='.urlencode($search_date_startday); + $param .= '&search_date_startday='.urlencode((string) ($search_date_startday)); } if ($search_date_startmonth) { - $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); + $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth)); } if ($search_date_startyear) { - $param .= '&search_date_startyear='.urlencode($search_date_startyear); + $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear)); } if ($search_date_endday) { - $param .= '&search_date_endday='.urlencode($search_date_endday); + $param .= '&search_date_endday='.urlencode((string) ($search_date_endday)); } if ($search_date_endmonth) { - $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); + $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth)); } if ($search_date_endyear) { - $param .= '&search_date_endyear='.urlencode($search_date_endyear); + $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear)); } if ($search_date_when_startday) { - $param .= '&search_date_when_startday='.urlencode($search_date_when_startday); + $param .= '&search_date_when_startday='.urlencode((string) ($search_date_when_startday)); } if ($search_date_when_startmonth) { - $param .= '&search_date_when_startmonth='.urlencode($search_date_when_startmonth); + $param .= '&search_date_when_startmonth='.urlencode((string) ($search_date_when_startmonth)); } if ($search_date_when_startyear) { - $param .= '&search_date_when_startyear='.urlencode($search_date_when_startyear); + $param .= '&search_date_when_startyear='.urlencode((string) ($search_date_when_startyear)); } if ($search_date_when_endday) { - $param .= '&search_date_when_endday='.urlencode($search_date_when_endday); + $param .= '&search_date_when_endday='.urlencode((string) ($search_date_when_endday)); } if ($search_date_when_endmonth) { - $param .= '&search_date_when_endmonth='.urlencode($search_date_when_endmonth); + $param .= '&search_date_when_endmonth='.urlencode((string) ($search_date_when_endmonth)); } if ($search_date_when_endyear) { - $param .= '&search_date_when_endyear='.urlencode($search_date_when_endyear); + $param .= '&search_date_when_endyear='.urlencode((string) ($search_date_when_endyear)); } if ($search_ref) { $param .= '&search_ref='.urlencode($search_ref); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index e897ebd198b..13995e6cc0b 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -16,6 +16,7 @@ * Copyright (C) 2019-2021 Alexandre Spangaro * Copyright (C) 2023 Nick Fragoulis * Copyright (C) 2023 Joachim Kueter + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -273,8 +274,6 @@ foreach ($object->fields as $key => $val) { $newkey = $key; } elseif (array_key_exists('f.'.$key, $arrayfields)) { $newkey = 'f.'.$key; - } elseif (array_key_exists('f.'.$key, $arrayfields)) { - $newkey = 'f.'.$key; } elseif (array_key_exists('s.'.$key, $arrayfields)) { $newkey = 's.'.$key; } @@ -1004,7 +1003,7 @@ if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $s llxHeader('', $title, $help_url); -$param = '&socid='.urlencode($socid); +$param = '&socid='.urlencode((string) ($socid)); if (!empty($mode)) { $param .= '&mode='.urlencode($mode); } @@ -1018,58 +1017,58 @@ if ($search_all) { $param .= '&search_all='.urlencode($search_all); } if ($search_date_startday) { - $param .= '&search_date_startday='.urlencode($search_date_startday); + $param .= '&search_date_startday='.urlencode((string) ($search_date_startday)); } if ($search_date_startmonth) { - $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); + $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth)); } if ($search_date_startyear) { - $param .= '&search_date_startyear='.urlencode($search_date_startyear); + $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear)); } if ($search_date_endday) { - $param .= '&search_date_endday='.urlencode($search_date_endday); + $param .= '&search_date_endday='.urlencode((string) ($search_date_endday)); } if ($search_date_endmonth) { - $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); + $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth)); } if ($search_date_endyear) { - $param .= '&search_date_endyear='.urlencode($search_date_endyear); + $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear)); } if ($search_date_valid_startday) { - $param .= '&search_date_valid_startday='.urlencode($search_date_valid_startday); + $param .= '&search_date_valid_startday='.urlencode((string) ($search_date_valid_startday)); } if ($search_date_valid_startmonth) { - $param .= '&search_date_valid_startmonth='.urlencode($search_date_valid_startmonth); + $param .= '&search_date_valid_startmonth='.urlencode((string) ($search_date_valid_startmonth)); } if ($search_date_valid_startyear) { - $param .= '&search_date_valid_startyear='.urlencode($search_date_valid_startyear); + $param .= '&search_date_valid_startyear='.urlencode((string) ($search_date_valid_startyear)); } if ($search_date_valid_endday) { - $param .= '&search_date_valid_endday='.urlencode($search_date_valid_endday); + $param .= '&search_date_valid_endday='.urlencode((string) ($search_date_valid_endday)); } if ($search_date_valid_endmonth) { - $param .= '&search_date_valid_endmonth='.urlencode($search_date_valid_endmonth); + $param .= '&search_date_valid_endmonth='.urlencode((string) ($search_date_valid_endmonth)); } if ($search_date_valid_endyear) { - $param .= '&search_date_valid_endyear='.urlencode($search_date_valid_endyear); + $param .= '&search_date_valid_endyear='.urlencode((string) ($search_date_valid_endyear)); } if ($search_datelimit_startday) { - $param .= '&search_datelimit_startday='.urlencode($search_datelimit_startday); + $param .= '&search_datelimit_startday='.urlencode((string) ($search_datelimit_startday)); } if ($search_datelimit_startmonth) { - $param .= '&search_datelimit_startmonth='.urlencode($search_datelimit_startmonth); + $param .= '&search_datelimit_startmonth='.urlencode((string) ($search_datelimit_startmonth)); } if ($search_datelimit_startyear) { - $param .= '&search_datelimit_startyear='.urlencode($search_datelimit_startyear); + $param .= '&search_datelimit_startyear='.urlencode((string) ($search_datelimit_startyear)); } if ($search_datelimit_endday) { - $param .= '&search_datelimit_endday='.urlencode($search_datelimit_endday); + $param .= '&search_datelimit_endday='.urlencode((string) ($search_datelimit_endday)); } if ($search_datelimit_endmonth) { - $param .= '&search_datelimit_endmonth='.urlencode($search_datelimit_endmonth); + $param .= '&search_datelimit_endmonth='.urlencode((string) ($search_datelimit_endmonth)); } if ($search_datelimit_endyear) { - $param .= '&search_datelimit_endyear='.urlencode($search_datelimit_endyear); + $param .= '&search_datelimit_endyear='.urlencode((string) ($search_datelimit_endyear)); } if ($search_ref) { $param .= '&search_ref='.urlencode($search_ref); @@ -1117,13 +1116,13 @@ if ($search_sale > 0) { $param .= '&search_sale='.urlencode($search_sale); } if ($search_user > 0) { - $param .= '&search_user='.urlencode($search_user); + $param .= '&search_user='.urlencode((string) ($search_user)); } if ($search_login) { $param .= '&search_login='.urlencode($search_login); } if ($search_product_category > 0) { - $param .= '&search_product_category='.urlencode($search_product_category); + $param .= '&search_product_category='.urlencode((string) ($search_product_category)); } if ($search_montant_ht != '') { $param .= '&search_montant_ht='.urlencode($search_montant_ht); @@ -1159,10 +1158,10 @@ if ($search_status != '') { $param .= '&search_status='.urlencode($search_status); } if ($search_paymentmode > 0) { - $param .= '&search_paymentmode='.urlencode($search_paymentmode); + $param .= '&search_paymentmode='.urlencode((string) ($search_paymentmode)); } if ($search_paymentterms > 0) { - $param .= '&search_paymentterms='.urlencode($search_paymentterms); + $param .= '&search_paymentterms='.urlencode((string) ($search_paymentterms)); } if ($search_module_source) { $param .= '&search_module_source='.urlencode($search_module_source); @@ -1171,7 +1170,7 @@ if ($search_pos_source) { $param .= '&search_pos_source='.urlencode($search_pos_source); } if ($show_files) { - $param .= '&show_files='.urlencode($show_files); + $param .= '&show_files='.urlencode((string) ($show_files)); } if ($search_late) { $param .= "&search_late=".urlencode($search_late); @@ -1180,7 +1179,7 @@ if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } if ($search_categ_cus > 0) { - $param .= '&search_categ_cus='.urlencode($search_categ_cus); + $param .= '&search_categ_cus='.urlencode((string) ($search_categ_cus)); } if (!empty($search_fac_rec_source_title)) { $param .= '&search_fac_rec_source_title='.urlencode($search_fac_rec_source_title); diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index 284dbefcc54..7243c91f3c3 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -221,22 +221,22 @@ if ($resql) { $param .= '&contextpage='.$contextpage; } if ($search_date_startday) { - $param .= '&search_date_startday='.urlencode($search_date_startday); + $param .= '&search_date_startday='.urlencode((string) ($search_date_startday)); } if ($search_date_startmonth) { - $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); + $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth)); } if ($search_date_startyear) { - $param .= '&search_date_startyear='.urlencode($search_date_startyear); + $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear)); } if ($search_date_endday) { - $param .= '&search_date_endday='.urlencode($search_date_endday); + $param .= '&search_date_endday='.urlencode((string) ($search_date_endday)); } if ($search_date_endmonth) { - $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); + $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth)); } if ($search_date_endyear) { - $param .= '&search_date_endyear='.urlencode($search_date_endyear); + $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear)); } if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.$limit; @@ -245,7 +245,7 @@ if ($resql) { $param .= '&search_amount='.urlencode($search_amount); } if ($search_account > 0) { - $param .= '&search_account='.urlencode($search_account); + $param .= '&search_account='.urlencode((string) ($search_account)); } $url = DOL_URL_ROOT.'/compta/paiement/cheque/card.php?action=new'; diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index b59aff4bfc9..12c2ec797d8 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -339,22 +339,22 @@ if ($search_ref) { $param .= '&search_ref='.urlencode($search_ref); } if ($search_date_startday) { - $param .= '&search_date_startday='.urlencode($search_date_startday); + $param .= '&search_date_startday='.urlencode((string) ($search_date_startday)); } if ($search_date_startmonth) { - $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); + $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth)); } if ($search_date_startyear) { - $param .= '&search_date_startyear='.urlencode($search_date_startyear); + $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear)); } if ($search_date_endday) { - $param .= '&search_date_endday='.urlencode($search_date_endday); + $param .= '&search_date_endday='.urlencode((string) ($search_date_endday)); } if ($search_date_endmonth) { - $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); + $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth)); } if ($search_date_endyear) { - $param .= '&search_date_endyear='.urlencode($search_date_endyear); + $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear)); } if ($search_company) { $param .= '&search_company='.urlencode($search_company); @@ -366,7 +366,7 @@ if ($search_paymenttype) { $param .= '&search_paymenttype='.urlencode($search_paymenttype); } if ($search_account) { - $param .= '&search_account='.urlencode($search_account); + $param .= '&search_account='.urlencode((string) ($search_account)); } if ($search_payment_num) { $param .= '&search_payment_num='.urlencode($search_payment_num); diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 691f6d903bf..c9f2401513b 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -506,7 +506,7 @@ if ($id > 0 || $ref) { $num = $db->num_rows($result); $i = 0; - $urladd = "&id=".urlencode($id); + $urladd = "&id=".urlencode((string) ($id)); if ($limit > 0 && $limit != $conf->liste_limit) { $urladd .= '&limit='.((int) $limit); } diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index abda85280a0..0194541b801 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -6,6 +6,7 @@ * Copyright (C) 2014-2016 Ferran Marcet * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2019 JC Prieto + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -144,7 +145,7 @@ class BonPrelevement extends CommonObject // BEGIN MODULEBUILDER PROPERTIES /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => '1', 'position' => 10, 'notnull' => 1, 'visible' => 0,), @@ -315,7 +316,7 @@ class BonPrelevement extends CommonObject if ($resql) { $num = $this->db->num_rows($resql); } else { - $result = -1; + $result = -1; // @phan-suppress-current-line PhanPluginRedundantAssignment } } else { /* @@ -1648,7 +1649,7 @@ class BonPrelevement extends CommonObject dol_syslog("adnotiff: ".$sql); if ($this->db->query($sql)) { - $result = 0; + $result = 0; // @phan-suppress-current-line PhanPluginRedundantAssignment } else { $result = -1; dol_syslog(get_class($this)."::addNotification Error $result"); diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 8102984f3b2..00934b0f0e6 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -185,7 +185,7 @@ if (empty($reshook)) { setEventMessages($texttoshow, null); } - header("Location: ".DOL_URL_ROOT.'/compta/prelevement/card.php?id='.urlencode($bprev->id).'&type='.urlencode($type)); + header("Location: ".DOL_URL_ROOT.'/compta/prelevement/card.php?id='.urlencode((string) ($bprev->id)).'&type='.urlencode((string) ($type))); exit; } } @@ -462,7 +462,7 @@ if ($resql) { $param .= '&limit='.((int) $limit); } if ($socid) { - $param .= '&socid='.urlencode($socid); + $param .= '&socid='.urlencode((string) ($socid)); } if ($option) { $param .= "&option=".urlencode($option); diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index 09015486e30..1fe40efa05e 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -275,9 +275,9 @@ if ($resql) { $i = 0; if ($limit > 0 && $limit != $conf->liste_limit) { - $param.='&limit='.((int) $limit); + $param .= '&limit='.((int) $limit); } - $param = "&id=".urlencode($id); + $param = "&id=".urlencode((string) ($id)); // Lines of title fields print ''; @@ -342,7 +342,7 @@ if ($resql) { print ''; print ''; - print ($salaryBonPl ? $salarytmp->getNomUrl(1) : $invoicetmp->getNomUrl(1)); + print($salaryBonPl ? $salarytmp->getNomUrl(1) : $invoicetmp->getNomUrl(1)); print "\n"; if ($object->type == 'bank-transfer' && !$salaryBonPl) { diff --git a/htdocs/compta/prelevement/line.php b/htdocs/compta/prelevement/line.php index 85e92020011..96d9a2d6b2c 100644 --- a/htdocs/compta/prelevement/line.php +++ b/htdocs/compta/prelevement/line.php @@ -111,7 +111,7 @@ if ($action == 'confirm_rejet' && $permissiontoadd) { $result = $rej->create($user, $id, GETPOSTINT('motif'), $daterej, $lipre->bon_rowid, GETPOSTINT('facturer')); if ($result > 0) { - header("Location: line.php?id=".urlencode($id).'&type='.urlencode($type)); + header("Location: line.php?id=".urlencode((string) ($id)).'&type='.urlencode((string) ($type))); exit; } } @@ -119,7 +119,7 @@ if ($action == 'confirm_rejet' && $permissiontoadd) { $action = "rejet"; } } else { - header("Location: line.php?id=".urlencode($id).'&type='.urlencode($type)); + header("Location: line.php?id=".urlencode((string) ($id)).'&type='.urlencode((string) ($type))); exit; } } @@ -343,7 +343,7 @@ if ($id) { $num = $db->num_rows($result); $i = 0; - $urladd = "&id=".urlencode($id); + $urladd = "&id=".urlencode((string) ($id)); $title = $langs->trans("Bills"); if ($type == 'bank-transfer') { $title = $langs->trans("SupplierInvoices"); diff --git a/htdocs/compta/prelevement/orders_list.php b/htdocs/compta/prelevement/orders_list.php index 23eee162758..b6dd673f37f 100644 --- a/htdocs/compta/prelevement/orders_list.php +++ b/htdocs/compta/prelevement/orders_list.php @@ -235,7 +235,7 @@ llxHeader('', $title, $help_url); $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; -$param .= "&statut=".urlencode($statut); +$param .= "&statut=".urlencode((string) ($statut)); if ($type == 'bank-transfer') { $param .= '&type=bank-transfer'; } diff --git a/htdocs/compta/sociales/class/cchargesociales.class.php b/htdocs/compta/sociales/class/cchargesociales.class.php index 5141708f815..b532bf42095 100644 --- a/htdocs/compta/sociales/class/cchargesociales.class.php +++ b/htdocs/compta/sociales/class/cchargesociales.class.php @@ -389,7 +389,7 @@ class Cchargesociales if ($result < 0) { $error++; $this->errors = $object->errors; - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); } unset($this->context['createfromclone']); diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index e81d5b80e5d..b08bcacfc9a 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2016-2024 Frédéric France * Copyright (C) 2017 Alexandre Spangaro * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -192,7 +193,7 @@ class ChargeSociales extends CommonObject $this->paye = $obj->paye; $this->periode = $this->db->jdate($obj->period); $this->period = $this->db->jdate($obj->period); - $this->import_key = $this->import_key; + $this->import_key = $obj->import_key; $this->db->free($resql); @@ -653,7 +654,7 @@ class ChargeSociales extends CommonObject $result .= $linkend; global $action; $hookmanager->initHooks(array($this->element . 'dao')); - $parameters = array('id'=>$this->id, 'getnomurl' => &$result); + $parameters = array('id' => $this->id, 'getnomurl' => &$result); $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) { $result = $hookmanager->resPrint; diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 0f2b503da99..5f07abd308a 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -328,7 +328,7 @@ if ($search_amount) { $param .= '&search_amount='.urlencode($search_amount); } if ($search_typeid) { - $param .= '&search_typeid='.urlencode($search_typeid); + $param .= '&search_typeid='.urlencode((string) ($search_typeid)); } if ($search_users) { foreach ($search_users as $id_user) { @@ -336,7 +336,7 @@ if ($search_users) { } } if ($search_type) { - $param .= '&search_type='.urlencode($search_type); + $param .= '&search_type='.urlencode((string) ($search_type)); } if ($search_account) { $param .= '&search_account='.$search_account; @@ -345,40 +345,40 @@ if ($search_status != '' && $search_status != '-1') { $param .= '&search_status='.urlencode($search_status); } if ($search_date_startday) { - $param .= '&search_date_startday='.urlencode($search_date_startday); + $param .= '&search_date_startday='.urlencode((string) ($search_date_startday)); } if ($search_date_startmonth) { - $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); + $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth)); } if ($search_date_startyear) { - $param .= '&search_date_startyear='.urlencode($search_date_startyear); + $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear)); } if ($search_date_endday) { - $param .= '&search_date_endday='.urlencode($search_date_endday); + $param .= '&search_date_endday='.urlencode((string) ($search_date_endday)); } if ($search_date_endmonth) { - $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); + $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth)); } if ($search_date_endyear) { - $param .= '&search_date_endyear='.urlencode($search_date_endyear); + $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear)); } if ($search_date_limit_startday) { - $param .= '&search_date_limit_startday='.urlencode($search_date_limit_startday); + $param .= '&search_date_limit_startday='.urlencode((string) ($search_date_limit_startday)); } if ($search_date_limit_startmonth) { - $param .= '&search_date_limit_startmonth='.urlencode($search_date_limit_startmonth); + $param .= '&search_date_limit_startmonth='.urlencode((string) ($search_date_limit_startmonth)); } if ($search_date_limit_startyear) { - $param .= '&search_date_limit_startyear='.urlencode($search_date_limit_startyear); + $param .= '&search_date_limit_startyear='.urlencode((string) ($search_date_limit_startyear)); } if ($search_date_limit_endday) { - $param .= '&search_date_limit_endday='.urlencode($search_date_limit_endday); + $param .= '&search_date_limit_endday='.urlencode((string) ($search_date_limit_endday)); } if ($search_date_limit_endmonth) { - $param .= '&search_date_limit_endmonth='.urlencode($search_date_limit_endmonth); + $param .= '&search_date_limit_endmonth='.urlencode((string) ($search_date_limit_endmonth)); } if ($search_date_limit_endyear) { - $param .= '&search_date_limit_endyear='.urlencode($search_date_limit_endyear); + $param .= '&search_date_limit_endyear='.urlencode((string) ($search_date_limit_endyear)); } $url = DOL_URL_ROOT.'/compta/sociales/card.php?action=create'; diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php index 22bde6bf509..b97882242e3 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -123,10 +123,10 @@ if ($sortorder) { $param .= '&sortorder='.urlencode($sortorder); } if ($year) { - $param .= '&year='.urlencode($year); + $param .= '&year='.urlencode((string) ($year)); } if ($search_sc_type) { - $param .= '&search_sc_type='.urlencode($search_sc_type); + $param .= '&search_sc_type='.urlencode((string) ($search_sc_type)); } if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 0cf70884978..a7b38cc85c7 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -1462,16 +1462,16 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; } - if (isModEnabled('order') || isModEnabled("delivery_note")) { + if (isModEnabled('order') || isModEnabled("shipping")) { print ''; - if (isModEnabled("delivery_note")) { + if (isModEnabled("shipping")) { print $langs->trans("ContactForOrdersOrShipments"); } else { print $langs->trans("ContactForOrders"); } print ''; $none = $langs->trans("NoContactForAnyOrder"); - if (isModEnabled("delivery_note")) { + if (isModEnabled("shipping")) { $none = $langs->trans("NoContactForAnyOrderOrShipments"); } print $object->ref_commande ? $object->ref_commande : $none; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 9b6752305a7..9b204deacf1 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -12,6 +12,7 @@ * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2020 Open-Dsi * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -97,45 +98,45 @@ class Contact extends CommonObject // BEGIN MODULEBUILDER PROPERTIES /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id', 'css'=>'left'), - 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>3, 'notnull'=>1, 'position'=>30, 'index'=>1), - 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'Ref ext', 'enabled'=>1, 'visible'=>3, 'position'=>35), - 'civility' =>array('type'=>'varchar(6)', 'label'=>'Civility', 'enabled'=>1, 'visible'=>3, 'position'=>40), - 'lastname' =>array('type'=>'varchar(50)', 'label'=>'Lastname', 'enabled'=>1, 'visible'=>1, 'position'=>45, 'showoncombobox'=>1, 'searchall'=>1), - 'name_alias' =>array('type'=>'varchar(255)', 'label'=>'Name alias', 'enabled'=>1, 'visible'=>-1, 'position'=>46, 'searchall'=>1), - 'firstname' =>array('type'=>'varchar(50)', 'label'=>'Firstname', 'enabled'=>1, 'visible'=>1, 'position'=>50, 'showoncombobox'=>1, 'searchall'=>1), - 'poste' =>array('type'=>'varchar(80)', 'label'=>'PostOrFunction', 'enabled'=>1, 'visible'=>-1, 'position'=>52), - 'address' =>array('type'=>'varchar(255)', 'label'=>'Address', 'enabled'=>1, 'visible'=>-1, 'position'=>55), - 'zip' =>array('type'=>'varchar(25)', 'label'=>'Zip', 'enabled'=>1, 'visible'=>1, 'position'=>60), - 'town' =>array('type'=>'varchar(50)', 'label'=>'Town', 'enabled'=>1, 'visible'=>-1, 'position'=>65), - 'fk_departement' =>array('type'=>'integer', 'label'=>'Fk departement', 'enabled'=>1, 'visible'=>3, 'position'=>70), - 'fk_pays' =>array('type'=>'integer', 'label'=>'Fk pays', 'enabled'=>1, 'visible'=>3, 'position'=>75), - 'fk_soc' =>array('type'=>'integer', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>1, 'position'=>77, 'searchall'=>1), - 'birthday' =>array('type'=>'date', 'label'=>'Birthday', 'enabled'=>1, 'visible'=>-1, 'position'=>80), - 'phone' =>array('type'=>'varchar(30)', 'label'=>'Phone', 'enabled'=>1, 'visible'=>1, 'position'=>90, 'searchall'=>1), - 'phone_perso' =>array('type'=>'varchar(30)', 'label'=>'PhonePerso', 'enabled'=>1, 'visible'=>-1, 'position'=>95, 'searchall'=>1), - 'phone_mobile' =>array('type'=>'varchar(30)', 'label'=>'PhoneMobile', 'enabled'=>1, 'visible'=>1, 'position'=>100, 'searchall'=>1), - 'fax' =>array('type'=>'varchar(30)', 'label'=>'Fax', 'enabled'=>1, 'visible'=>-1, 'position'=>105, 'searchall'=>1), - 'email' =>array('type'=>'varchar(255)', 'label'=>'Email', 'enabled'=>1, 'visible'=>1, 'position'=>110, 'searchall'=>1), - 'socialnetworks' =>array('type'=>'text', 'label'=>'SocialNetworks', 'enabled'=>1, 'visible'=>3, 'position'=>115), - 'photo' =>array('type'=>'varchar(255)', 'label'=>'Photo', 'enabled'=>1, 'visible'=>3, 'position'=>170), - 'priv' =>array('type'=>'smallint(6)', 'label'=>'ContactVisibility', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>175), - 'fk_stcommcontact' =>array('type'=>'integer', 'label'=>'ProspectStatus', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>220), - 'fk_prospectcontactlevel' =>array('type'=>'varchar(12)', 'label'=>'ProspectLevel', 'enabled'=>1, 'visible'=>-1, 'position'=>255), + 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -2, 'noteditable' => 1, 'notnull' => 1, 'index' => 1, 'position' => 1, 'comment' => 'Id', 'css' => 'left'), + 'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => 3, 'notnull' => 1, 'position' => 30, 'index' => 1), + 'ref_ext' => array('type' => 'varchar(255)', 'label' => 'Ref ext', 'enabled' => 1, 'visible' => 3, 'position' => 35), + 'civility' => array('type' => 'varchar(6)', 'label' => 'Civility', 'enabled' => 1, 'visible' => 3, 'position' => 40), + 'lastname' => array('type' => 'varchar(50)', 'label' => 'Lastname', 'enabled' => 1, 'visible' => 1, 'position' => 45, 'showoncombobox' => 1, 'searchall' => 1), + 'name_alias' => array('type' => 'varchar(255)', 'label' => 'Name alias', 'enabled' => 1, 'visible' => -1, 'position' => 46, 'searchall' => 1), + 'firstname' => array('type' => 'varchar(50)', 'label' => 'Firstname', 'enabled' => 1, 'visible' => 1, 'position' => 50, 'showoncombobox' => 1, 'searchall' => 1), + 'poste' => array('type' => 'varchar(80)', 'label' => 'PostOrFunction', 'enabled' => 1, 'visible' => -1, 'position' => 52), + 'address' => array('type' => 'varchar(255)', 'label' => 'Address', 'enabled' => 1, 'visible' => -1, 'position' => 55), + 'zip' => array('type' => 'varchar(25)', 'label' => 'Zip', 'enabled' => 1, 'visible' => 1, 'position' => 60), + 'town' => array('type' => 'varchar(50)', 'label' => 'Town', 'enabled' => 1, 'visible' => -1, 'position' => 65), + 'fk_departement' => array('type' => 'integer', 'label' => 'Fk departement', 'enabled' => 1, 'visible' => 3, 'position' => 70), + 'fk_pays' => array('type' => 'integer', 'label' => 'Fk pays', 'enabled' => 1, 'visible' => 3, 'position' => 75), + 'fk_soc' => array('type' => 'integer', 'label' => 'ThirdParty', 'enabled' => 1, 'visible' => 1, 'position' => 77, 'searchall' => 1), + 'birthday' => array('type' => 'date', 'label' => 'Birthday', 'enabled' => 1, 'visible' => -1, 'position' => 80), + 'phone' => array('type' => 'varchar(30)', 'label' => 'Phone', 'enabled' => 1, 'visible' => 1, 'position' => 90, 'searchall' => 1), + 'phone_perso' => array('type' => 'varchar(30)', 'label' => 'PhonePerso', 'enabled' => 1, 'visible' => -1, 'position' => 95, 'searchall' => 1), + 'phone_mobile' => array('type' => 'varchar(30)', 'label' => 'PhoneMobile', 'enabled' => 1, 'visible' => 1, 'position' => 100, 'searchall' => 1), + 'fax' => array('type' => 'varchar(30)', 'label' => 'Fax', 'enabled' => 1, 'visible' => -1, 'position' => 105, 'searchall' => 1), + 'email' => array('type' => 'varchar(255)', 'label' => 'Email', 'enabled' => 1, 'visible' => 1, 'position' => 110, 'searchall' => 1), + 'socialnetworks' => array('type' => 'text', 'label' => 'SocialNetworks', 'enabled' => 1, 'visible' => 3, 'position' => 115), + 'photo' => array('type' => 'varchar(255)', 'label' => 'Photo', 'enabled' => 1, 'visible' => 3, 'position' => 170), + 'priv' => array('type' => 'smallint(6)', 'label' => 'ContactVisibility', 'enabled' => 1, 'visible' => 1, 'notnull' => 1, 'position' => 175), + 'fk_stcommcontact' => array('type' => 'integer', 'label' => 'ProspectStatus', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 220), + 'fk_prospectcontactlevel' => array('type' => 'varchar(12)', 'label' => 'ProspectLevel', 'enabled' => 1, 'visible' => -1, 'position' => 255), //no more used. Replace by a scan of email into mailing_unsubscribe. 'no_email' =>array('type'=>'smallint(6)', 'label'=>'No_Email', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>180), - 'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>3, 'position'=>195, 'searchall'=>1), - 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>3, 'position'=>200, 'searchall'=>1), - 'default_lang' =>array('type'=>'varchar(6)', 'label'=>'Default lang', 'enabled'=>1, 'visible'=>3, 'position'=>205), - 'canvas' =>array('type'=>'varchar(32)', 'label'=>'Canvas', 'enabled'=>1, 'visible'=>3, 'position'=>210), - 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>300), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>305), - 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>3, 'position'=>310), - 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>3, 'position'=>315), - 'statut' =>array('type'=>'tinyint(4)', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>500), - 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-1, 'position'=>1000), + 'note_private' => array('type' => 'html', 'label' => 'NotePrivate', 'enabled' => 1, 'visible' => 3, 'position' => 195, 'searchall' => 1), + 'note_public' => array('type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'visible' => 3, 'position' => 200, 'searchall' => 1), + 'default_lang' => array('type' => 'varchar(6)', 'label' => 'Default lang', 'enabled' => 1, 'visible' => 3, 'position' => 205), + 'canvas' => array('type' => 'varchar(32)', 'label' => 'Canvas', 'enabled' => 1, 'visible' => 3, 'position' => 210), + 'datec' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'visible' => -1, 'position' => 300), + 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 305), + 'fk_user_creat' => array('type' => 'integer', 'label' => 'UserAuthor', 'enabled' => 1, 'visible' => 3, 'position' => 310), + 'fk_user_modif' => array('type' => 'integer', 'label' => 'UserModif', 'enabled' => 1, 'visible' => 3, 'position' => 315), + 'statut' => array('type' => 'tinyint(4)', 'label' => 'Status', 'enabled' => 1, 'visible' => 1, 'notnull' => 1, 'position' => 500), + 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'visible' => -1, 'position' => 1000), ); public $civility_id; // In fact we store civility_code @@ -1797,7 +1798,7 @@ class Contact extends CommonObject while ($obj = $this->db->fetch_object($resql)) { $transkey = "TypeContact_".$obj->element."_".$obj->source."_".$obj->code; $libelle_element = $langs->trans('ContactDefault_'.$obj->element); - $this->roles[$obj->contactroleid] = array('id'=>$obj->rowid, 'socid'=>$obj->socid, 'element'=>$obj->element, 'source'=>$obj->source, 'code'=>$obj->code, 'label'=>$libelle_element.' - '.($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->label)); + $this->roles[$obj->contactroleid] = array('id' => $obj->rowid, 'socid' => $obj->socid, 'element' => $obj->element, 'source' => $obj->source, 'code' => $obj->code, 'label' => $libelle_element.' - '.($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->label)); } } } else { @@ -1846,7 +1847,7 @@ class Contact extends CommonObject $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); - $tab[] = array('fk_socpeople'=>$obj->id, 'type_contact'=>$obj->fk_c_type_contact); + $tab[] = array('fk_socpeople' => $obj->id, 'type_contact' => $obj->fk_c_type_contact); $i++; } @@ -2178,7 +2179,7 @@ class Contact extends CommonObject $return .= ''; //var_dump($this->photo);exit; if (property_exists($this, 'photo') && !is_null($this->photo)) { - $return.= Form::showphoto('contact', $this, 0, 60, 0, 'photokanban photoref photowithmargin photologintooltip', 'small', 0, 1); + $return .= Form::showphoto('contact', $this, 0, 60, 0, 'photokanban photoref photowithmargin photologintooltip', 'small', 0, 1); } else { $return .= img_picto('', $this->picto); } diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index 67714ae131e..66067b00e6e 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -368,7 +368,7 @@ $param .= "&month=".urlencode($month); $param .= "&year=".urlencode($year); $param .= "&sprod_fulldescr=".urlencode($sprod_fulldescr); if (!empty($socid)) { - $param .= "&socid=".urlencode($socid); + $param .= "&socid=".urlencode((string) ($socid)); } $param .= "&type_element=".urlencode($type_element); @@ -382,7 +382,7 @@ if ($sql_select) { $num = $db->num_rows($resql); - $param = (!empty($socid) ? "&socid=".urlencode($socid) : "")."&type_element=".urlencode($type_element)."&id=".urlencode($id); + $param = (!empty($socid) ? "&socid=".urlencode((string) ($socid)) : "")."&type_element=".urlencode((string) ($type_element))."&id=".urlencode((string) ($id)); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -396,10 +396,10 @@ if ($sql_select) { $param .= "&sref=".urlencode($sref); } if ($month) { - $param .= "&month=".urlencode($month); + $param .= "&month=".urlencode((string) ($month)); } if ($year) { - $param .= "&year=".urlencode($year); + $param .= "&year=".urlencode((string) ($year)); } if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 6fefaccd5cc..d391b2e8d4b 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -832,25 +832,25 @@ if ($limit > 0 && $limit != $conf->liste_limit) { if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } -$param .= '&begin='.urlencode($begin).'&userid='.urlencode($userid).'&contactname='.urlencode($search_all); +$param .= '&begin='.urlencode((string) ($begin)).'&userid='.urlencode((string) ($userid)).'&contactname='.urlencode((string) ($search_all)); $param .= '&type='.urlencode($type).'&view='.urlencode($view); if (!empty($search_sale) && $search_sale != '-1') { $param .= '&search_sale='.urlencode($search_sale); } if (!empty($search_categ) && $search_categ != '-1') { - $param .= '&search_categ='.urlencode($search_categ); + $param .= '&search_categ='.urlencode((string) ($search_categ)); } if (!empty($search_categ_thirdparty) && $search_categ_thirdparty != '-1') { - $param .= '&search_categ_thirdparty='.urlencode($search_categ_thirdparty); + $param .= '&search_categ_thirdparty='.urlencode((string) ($search_categ_thirdparty)); } if (!empty($search_categ_supplier) && $search_categ_supplier != '-1') { - $param .= '&search_categ_supplier='.urlencode($search_categ_supplier); + $param .= '&search_categ_supplier='.urlencode((string) ($search_categ_supplier)); } if ($search_all != '') { $param .= '&search_all='.urlencode($search_all); } if ($search_id > 0) { - $param .= "&search_id=".urlencode($search_id); + $param .= "&search_id=".urlencode((string) ($search_id)); } if ($search_lastname != '') { $param .= '&search_lastname='.urlencode($search_lastname); @@ -895,16 +895,16 @@ if ($search_email != '') { $param .= '&search_email='.urlencode($search_email); } if ($search_no_email != '') { - $param .= '&search_no_email='.urlencode($search_no_email); + $param .= '&search_no_email='.urlencode((string) ($search_no_email)); } if ($search_status != '') { - $param .= '&search_status='.urlencode($search_status); + $param .= '&search_status='.urlencode((string) ($search_status)); } if ($search_priv == '0' || $search_priv == '1') { $param .= "&search_priv=".urlencode($search_priv); } if ($search_stcomm != '') { - $param .= '&search_stcomm='.urlencode($search_stcomm); + $param .= '&search_stcomm='.urlencode((string) ($search_stcomm)); } if (is_array($search_level) && count($search_level)) { foreach ($search_level as $slevel) { @@ -1688,7 +1688,7 @@ while ($i < $imaxinloop) { $titlealt = $val['label']; } if ($obj->stcomm_id != $val['id']) { - print ''.img_action($titlealt, $val['code'], $val['picto']).''; + print ''.img_action($titlealt, $val['code'], $val['picto']).''; } } print ''; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 98c46cc9f47..4d411b5a2b9 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -12,6 +12,7 @@ * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2023 Charlene Benke * Copyright (C) 2023 Nick Fragoulis + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -763,7 +764,7 @@ if (empty($reshook)) { $fk_unit = GETPOST('unit', 'alpha'); // update price_ht with discount - // TODO Use object->updateline instead objedtline->update + // TODO Use object->updateline instead objectline->update $price_ht = price2num(GETPOST('elprice'), 'MU'); $remise_percent = price2num(GETPOST('elremise_percent'), '', 2); @@ -788,7 +789,7 @@ if (empty($reshook)) { $objectline->user_closing_id = $user->id; //$objectline->fk_fournprice = $fk_fournprice; $objectline->pa_ht = $pa_ht; - $objectline->rang = $objectline->rang; + // $objectline->rang = $objectline->rang; if ($fk_unit > 0) { $objectline->fk_unit = GETPOST('unit'); @@ -1351,8 +1352,8 @@ if ($action == 'create') { } elseif ($action == 'activate') { $formquestion = array( array('type' => 'date', 'name' => 'd_start', 'label' => $langs->trans("DateServiceActivate"), 'value' => dol_now()), - array('type' => 'date', 'name' => 'd_end', 'label' => $langs->trans("DateEndPlanned"), /*'value' => $form->selectDate('', "end", $usehm, $usehm, '', "active", 1, 0),*/ '', ''), - array('type' => 'text', 'name' => 'comment', 'label' => $langs->trans("Comment"), 'value' => '', '', '', 'class' => 'minwidth300', 'moreattr' => 'autofocus') + array('type' => 'date', 'name' => 'd_end', 'label' => $langs->trans("DateEndPlanned"), /*'value' => $form->selectDate('', "end", $usehm, $usehm, '', "active", 1, 0),*/ 0 => '', 1 => ''), + array('type' => 'text', 'name' => 'comment', 'label' => $langs->trans("Comment"), 'value' => '', 0 => '', 1 => '', 'class' => 'minwidth300', 'moreattr' => 'autofocus') ); $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ActivateAllOnContract"), $langs->trans("ConfirmActivateAllOnContract"), "confirm_activate", $formquestion, 'yes', 1, 280); } elseif ($action == 'clone') { @@ -1890,7 +1891,7 @@ if ($action == 'create') { // Cree un tableau formulaire $formquestion = array( 'text' => $langs->trans("ConfirmMoveToAnotherContractQuestion"), - array('type' => 'select', 'name' => 'newcid', 'values' => $arraycontractid)); + 0 => array('type' => 'select', 'name' => 'newcid', 'values' => $arraycontractid)); print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&lineid=".GETPOSTINT('rowid'), $langs->trans("MoveToAnotherContract"), $langs->trans("ConfirmMoveToAnotherContract"), "confirm_move", $formquestion); print '
'; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 8139d7aa755..bc9964d2d33 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -243,31 +243,31 @@ class Contrat extends CommonObject // BEGIN MODULEBUILDER PROPERTIES /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), - 'ref' =>array('type'=>'varchar(50)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'showoncombobox'=>1, 'position'=>15, 'searchall'=>1), - 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'Ref ext', 'enabled'=>1, 'visible'=>0, 'position'=>20), - 'ref_customer' =>array('type'=>'varchar(50)', 'label'=>'RefCustomer', 'enabled'=>1, 'visible'=>-1, 'position'=>25, 'searchall'=>1), - 'ref_supplier' =>array('type'=>'varchar(50)', 'label'=>'RefSupplier', 'enabled'=>1, 'visible'=>-1, 'position'=>26, 'searchall'=>1), - 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>30, 'index'=>1), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35), - 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>40), - 'date_contrat' =>array('type'=>'datetime', 'label'=>'Date contrat', 'enabled'=>1, 'visible'=>-1, 'position'=>45), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'isModEnabled("societe")', 'visible'=>-1, 'notnull'=>1, 'position'=>70), - 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:(fk_statut:=:1)', 'label'=>'Project', 'enabled'=>"isModEnabled('project')", 'visible'=>-1, 'position'=>75), - 'fk_commercial_signature' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'SaleRepresentative Signature', 'enabled'=>1, 'visible'=>-1, 'position'=>80), - 'fk_commercial_suivi' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'SaleRepresentative follower', 'enabled'=>1, 'visible'=>-1, 'position'=>85), - 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>90), - 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>105, 'searchall'=>1), - 'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>110, 'searchall'=>1), - 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'position'=>115), - 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>120), - 'extraparams' =>array('type'=>'varchar(255)', 'label'=>'Extraparams', 'enabled'=>1, 'visible'=>-1, 'position'=>125), - 'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>135), - 'last_main_doc' =>array('type'=>'varchar(255)', 'label'=>'Last main doc', 'enabled'=>1, 'visible'=>-1, 'position'=>140), - 'statut' =>array('type'=>'smallint(6)', 'label'=>'Statut', 'enabled'=>1, 'visible'=>-1, 'position'=>500, 'notnull'=>1, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 2=>'Closed')) + 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 10), + 'ref' => array('type' => 'varchar(50)', 'label' => 'Ref', 'enabled' => 1, 'visible' => -1, 'showoncombobox' => 1, 'position' => 15, 'searchall' => 1), + 'ref_ext' => array('type' => 'varchar(255)', 'label' => 'Ref ext', 'enabled' => 1, 'visible' => 0, 'position' => 20), + 'ref_customer' => array('type' => 'varchar(50)', 'label' => 'RefCustomer', 'enabled' => 1, 'visible' => -1, 'position' => 25, 'searchall' => 1), + 'ref_supplier' => array('type' => 'varchar(50)', 'label' => 'RefSupplier', 'enabled' => 1, 'visible' => -1, 'position' => 26, 'searchall' => 1), + 'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 30, 'index' => 1), + 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 35), + 'datec' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'visible' => -1, 'position' => 40), + 'date_contrat' => array('type' => 'datetime', 'label' => 'Date contrat', 'enabled' => 1, 'visible' => -1, 'position' => 45), + 'fk_soc' => array('type' => 'integer:Societe:societe/class/societe.class.php', 'label' => 'ThirdParty', 'enabled' => 'isModEnabled("societe")', 'visible' => -1, 'notnull' => 1, 'position' => 70), + 'fk_projet' => array('type' => 'integer:Project:projet/class/project.class.php:1:(fk_statut:=:1)', 'label' => 'Project', 'enabled' => "isModEnabled('project')", 'visible' => -1, 'position' => 75), + 'fk_commercial_signature' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'SaleRepresentative Signature', 'enabled' => 1, 'visible' => -1, 'position' => 80), + 'fk_commercial_suivi' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'SaleRepresentative follower', 'enabled' => 1, 'visible' => -1, 'position' => 85), + 'fk_user_author' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserAuthor', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 90), + 'note_public' => array('type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'visible' => 0, 'position' => 105, 'searchall' => 1), + 'note_private' => array('type' => 'html', 'label' => 'NotePrivate', 'enabled' => 1, 'visible' => 0, 'position' => 110, 'searchall' => 1), + 'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => 1, 'visible' => 0, 'position' => 115), + 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'visible' => -2, 'position' => 120), + 'extraparams' => array('type' => 'varchar(255)', 'label' => 'Extraparams', 'enabled' => 1, 'visible' => -1, 'position' => 125), + 'fk_user_modif' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'enabled' => 1, 'visible' => -2, 'notnull' => -1, 'position' => 135), + 'last_main_doc' => array('type' => 'varchar(255)', 'label' => 'Last main doc', 'enabled' => 1, 'visible' => -1, 'position' => 140), + 'statut' => array('type' => 'smallint(6)', 'label' => 'Statut', 'enabled' => 1, 'visible' => -1, 'position' => 500, 'notnull' => 1, 'arrayofkeyval' => array(0 => 'Draft', 1 => 'Validated', 2 => 'Closed')) ); // END MODULEBUILDER PROPERTIES @@ -2154,7 +2154,7 @@ class Contrat extends CommonObject global $action; $hookmanager->initHooks(array('contractdao')); - $parameters = array('id'=>$this->id, 'getnomurl' => &$result); + $parameters = array('id' => $this->id, 'getnomurl' => &$result); $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) { $result = $hookmanager->resPrint; @@ -2744,7 +2744,7 @@ class Contrat extends CommonObject $error = 0; $this->output = ''; - $this->error=''; + $this->error = ''; $contractlineprocessed = array(); $contractignored = array(); @@ -2753,13 +2753,13 @@ class Contrat extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); $sql = 'SELECT c.rowid, c.ref_customer, cd.rowid as lid, cd.date_fin_validite, p.duration'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'contrat as c, '.MAIN_DB_PREFIX.'contratdet as cd'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON p.rowid = cd.fk_product'; - $sql.= ' WHERE cd.fk_contrat = c.rowid'; - $sql.= " AND date_format(cd.date_fin_validite, '%Y-%m-%d') <= date_format('".$this->db->idate($enddatetoscan)."', '%Y-%m-%d')"; - $sql.= " AND cd.statut = 4"; + $sql .= ' FROM '.MAIN_DB_PREFIX.'contrat as c, '.MAIN_DB_PREFIX.'contratdet as cd'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON p.rowid = cd.fk_product'; + $sql .= ' WHERE cd.fk_contrat = c.rowid'; + $sql .= " AND date_format(cd.date_fin_validite, '%Y-%m-%d') <= date_format('".$this->db->idate($enddatetoscan)."', '%Y-%m-%d')"; + $sql .= " AND cd.statut = 4"; if ($thirdparty_id > 0) { - $sql.=" AND c.fk_soc = ".((int) $thirdparty_id); + $sql .= " AND c.fk_soc = ".((int) $thirdparty_id); } //print $sql; @@ -2769,7 +2769,7 @@ class Contrat extends CommonObject include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $i=0; + $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); if ($obj) { @@ -2806,7 +2806,7 @@ class Contrat extends CommonObject usort($object->linkedObjects['facture'], array('Contrat', 'contractCmpDate')); //dol_sort_array($object->linkedObjects['facture'], 'date'); - $someinvoicenotpaid=0; + $someinvoicenotpaid = 0; foreach ($object->linkedObjects['facture'] as $idinvoice => $invoice) { if ($invoice->statut == Facture::STATUS_DRAFT) { continue; @@ -2826,7 +2826,7 @@ class Contrat extends CommonObject if ($expirationdate && $expirationdate < $enddatetoscan) { dol_syslog("Define the newdate of end of services from expirationdate=".$expirationdate); $newdate = $expirationdate; - $protecti=0; //$protecti is to avoid infinite loop + $protecti = 0; //$protecti is to avoid infinite loop while ($newdate < $enddatetoscan && $protecti < 1000) { $newdate = dol_time_plus_duree($newdate, $duration_value, $duration_unit); $protecti++; @@ -2844,10 +2844,10 @@ class Contrat extends CommonObject $comment = 'Renew date of contract '.$object->ref.' line '.$obj->lid.' by doAutoRenewContracts'; $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX."contratdet SET date_fin_validite = '".$this->db->idate($newdate)."'"; - $sqlupdate.= ' WHERE rowid = '.((int) $obj->lid); + $sqlupdate .= ' WHERE rowid = '.((int) $obj->lid); $resqlupdate = $this->db->query($sqlupdate); if ($resqlupdate) { - $contractlineprocessed[$obj->lid]=$object->ref; + $contractlineprocessed[$obj->lid] = $object->ref; $actioncode = 'RENEW_CONTRACT'; $now = dol_now(); @@ -2869,7 +2869,7 @@ class Contrat extends CommonObject $ret = $actioncomm->create($user); // User creating action } else { - $contracterror[$object->id]=$object->ref; + $contracterror[$object->id] = $object->ref; $error++; $errorforlocaltransaction++; @@ -2895,7 +2895,7 @@ class Contrat extends CommonObject $this->error = $this->db->lasterror(); } - $this->output .= count($contractlineprocessed).' contract line(s) with end date before '.dol_print_date($enddatetoscan, 'day').' were renewed'.(count($contractlineprocessed)>0 ? ' : '.implode(',', $contractlineprocessed) : ''); + $this->output .= count($contractlineprocessed).' contract line(s) with end date before '.dol_print_date($enddatetoscan, 'day').' were renewed'.(count($contractlineprocessed) > 0 ? ' : '.implode(',', $contractlineprocessed) : ''); return ($error ? 1 : 0); } @@ -3109,27 +3109,27 @@ class ContratLigne extends CommonObjectLine * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), - 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>30, 'index'=>1), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35), - 'qty' =>array('type'=>'integer', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>35, 'isameasure'=>1), - 'total_ht' =>array('type'=>'integer', 'label'=>'AmountHT', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>36, 'isameasure'=>1), - 'total_tva' =>array('type'=>'integer', 'label'=>'AmountVAT', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>37, 'isameasure'=>1), - 'total_ttc' =>array('type'=>'integer', 'label'=>'AmountTTC', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>38, 'isameasure'=>1), + 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 10), + 'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 30, 'index' => 1), + 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 35), + 'qty' => array('type' => 'integer', 'label' => 'Quantity', 'enabled' => 1, 'visible' => 1, 'notnull' => 1, 'position' => 35, 'isameasure' => 1), + 'total_ht' => array('type' => 'integer', 'label' => 'AmountHT', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 36, 'isameasure' => 1), + 'total_tva' => array('type' => 'integer', 'label' => 'AmountVAT', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 37, 'isameasure' => 1), + 'total_ttc' => array('type' => 'integer', 'label' => 'AmountTTC', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 38, 'isameasure' => 1), //'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>40), //'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>70), - 'fk_contrat' =>array('type'=>'integer:Contrat:contrat/class/contrat.class.php', 'label'=>'Contract', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>70), - 'fk_product' =>array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Product', 'enabled'=>1, 'visible'=>-1, 'position'=>75), + 'fk_contrat' => array('type' => 'integer:Contrat:contrat/class/contrat.class.php', 'label' => 'Contract', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 70), + 'fk_product' => array('type' => 'integer:Product:product/class/product.class.php:1', 'label' => 'Product', 'enabled' => 1, 'visible' => -1, 'position' => 75), //'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk user author', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>90), - 'note_private' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>105), - 'note_public' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>110), + 'note_private' => array('type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'visible' => 0, 'position' => 105), + 'note_public' => array('type' => 'html', 'label' => 'NotePrivate', 'enabled' => 1, 'visible' => 0, 'position' => 110), //'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'position'=>115), //'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>120), //'extraparams' =>array('type'=>'varchar(255)', 'label'=>'Extraparams', 'enabled'=>1, 'visible'=>-1, 'position'=>125), - 'fk_user_ouverture' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserStartingService', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>135), - 'fk_user_cloture' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserClosingService', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>135), - 'statut' =>array('type'=>'smallint(6)', 'label'=>'Statut', 'enabled'=>1, 'visible'=>-1, 'position'=>500, 'arrayofkeyval'=>array(0=>'Draft', 4=>'Open', 5=>'Closed')), - 'rang' =>array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'position'=>500, 'default' =>0) + 'fk_user_ouverture' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserStartingService', 'enabled' => 1, 'visible' => -2, 'notnull' => -1, 'position' => 135), + 'fk_user_cloture' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserClosingService', 'enabled' => 1, 'visible' => -2, 'notnull' => -1, 'position' => 135), + 'statut' => array('type' => 'smallint(6)', 'label' => 'Statut', 'enabled' => 1, 'visible' => -1, 'position' => 500, 'arrayofkeyval' => array(0 => 'Draft', 4 => 'Open', 5 => 'Closed')), + 'rang' => array('type' => 'integer', 'label' => 'Rank', 'enabled' => 1, 'visible' => 0, 'position' => 500, 'default' => 0) ); // END MODULEBUILDER PROPERTIES @@ -3200,7 +3200,7 @@ class ContratLigne extends CommonObjectLine $params = array(); $reg = array(); if (preg_match('/class="(.*)"/', $moreatt, $reg)) { - $params = array('badgeParams'=>array('css' => $reg[1])); + $params = array('badgeParams' => array('css' => $reg[1])); } return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode, '', $params); } @@ -3467,19 +3467,6 @@ class ContratLigne extends CommonObjectLine if (empty($this->remise_percent)) { $this->remise_percent = 0; } - // For backward compatibility - if (empty($this->date_start)) { - $this->date_start = $this->date_start; - } - if (empty($this->date_start_real)) { - $this->date_start_real = $this->date_start_real; - } - if (empty($this->date_end)) { - $this->date_end = $this->date_end; - } - if (empty($this->date_end_real)) { - $this->date_end_real = $this->date_end_real; - } // Calcul du total TTC et de la TVA pour la ligne a partir de // qty, pu, remise_percent et txtva diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 28f6c49a9fb..9f7089afc5f 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -154,9 +155,9 @@ if ($resql) { while ($i < $num) { $obj = $db->fetch_object($resql); if ($obj) { - $nb[$obj->status.true] = $obj->nb; + $nb[$obj->status.((string) true)] = $obj->nb; if ($obj->status != 5) { - $vals[$obj->status.true] = $obj->nb; + $vals[$obj->status.((string) true)] = $obj->nb; $totalinprocess += $obj->nb; } $total += $obj->nb; @@ -175,26 +176,28 @@ include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; print '
'; print ''; print ''."\n"; -$listofstatus = array(0, 4, 4, 5); $bool = false; +$listofstatus = array(0, 4, 4, 5); +$bool = false; foreach ($listofstatus as $status) { - $dataseries[] = array($staticcontratligne->LibStatut($status, 1, ($bool ? 1 : 0)), (isset($nb[$status.$bool]) ? (int) $nb[$status.$bool] : 0)); + $bool_str = (string) $bool; + $dataseries[] = array($staticcontratligne->LibStatut($status, 1, ($bool ? 1 : 0)), (isset($nb[$status.$bool_str]) ? (int) $nb[$status.$bool_str] : 0)); if ($status == ContratLigne::STATUS_INITIAL) { - $colorseries[$status.$bool] = '-'.$badgeStatus0; + $colorseries[$status.$bool_str] = '-'.$badgeStatus0; } if ($status == ContratLigne::STATUS_OPEN && !$bool) { - $colorseries[$status.$bool] = $badgeStatus4; + $colorseries[$status.$bool_str] = $badgeStatus4; } if ($status == ContratLigne::STATUS_OPEN && $bool) { - $colorseries[$status.$bool] = $badgeStatus1; + $colorseries[$status.$bool_str] = $badgeStatus1; } if ($status == ContratLigne::STATUS_CLOSED) { - $colorseries[$status.$bool] = $badgeStatus6; + $colorseries[$status.$bool_str] = $badgeStatus6; } if (empty($conf->use_javascript_ajax)) { print ''; print ''; - print ''; + print ''; print "\n"; } if ($status == 4 && !$bool) { @@ -219,12 +222,14 @@ if (!empty($conf->use_javascript_ajax)) { print ''; } -$listofstatus = array(0, 4, 4, 5); $bool = false; +$listofstatus = array(0, 4, 4, 5); +$bool = false; foreach ($listofstatus as $status) { + $bool_str = (string) $bool; if (empty($conf->use_javascript_ajax)) { print ''; print ''; - print ''; + print ''; if ($status == 4 && !$bool) { $bool = true; } else { diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index a8704ff8da3..a9c49bbeaab 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -626,94 +626,94 @@ if ($search_op2df != '') { $param .= '&search_op2df='.urlencode($search_op2df); } if ($search_date_creation_startmonth) { - $param .= '&search_date_creation_startmonth='.urlencode($search_date_creation_startmonth); + $param .= '&search_date_creation_startmonth='.urlencode((string) ($search_date_creation_startmonth)); } if ($search_date_creation_startyear) { - $param .= '&search_date_creation_startyear='.urlencode($search_date_creation_startyear); + $param .= '&search_date_creation_startyear='.urlencode((string) ($search_date_creation_startyear)); } if ($search_date_creation_startday) { - $param .= '&search_date_creation_startday='.urlencode($search_date_creation_startday); + $param .= '&search_date_creation_startday='.urlencode((string) ($search_date_creation_startday)); } if ($search_date_creation_start) { $param .= '&search_date_creation_start='.urlencode($search_date_creation_start); } if ($search_date_creation_endmonth) { - $param .= '&search_date_creation_endmonth='.urlencode($search_date_creation_endmonth); + $param .= '&search_date_creation_endmonth='.urlencode((string) ($search_date_creation_endmonth)); } if ($search_date_creation_endyear) { - $param .= '&search_date_creation_endyear='.urlencode($search_date_creation_endyear); + $param .= '&search_date_creation_endyear='.urlencode((string) ($search_date_creation_endyear)); } if ($search_date_creation_endday) { - $param .= '&search_date_creation_endday='.urlencode($search_date_creation_endday); + $param .= '&search_date_creation_endday='.urlencode((string) ($search_date_creation_endday)); } if ($search_date_creation_end) { $param .= '&search_date_creation_end='.urlencode($search_date_creation_end); } if ($search_date_modif_startmonth) { - $param .= '&search_date_modif_startmonth='.urlencode($search_date_modif_startmonth); + $param .= '&search_date_modif_startmonth='.urlencode((string) ($search_date_modif_startmonth)); } if ($search_date_modif_startyear) { - $param .= '&search_date_modif_startyear='.urlencode($search_date_modif_startyear); + $param .= '&search_date_modif_startyear='.urlencode((string) ($search_date_modif_startyear)); } if ($search_date_modif_startday) { - $param .= '&search_date_modif_startday='.urlencode($search_date_modif_startday); + $param .= '&search_date_modif_startday='.urlencode((string) ($search_date_modif_startday)); } if ($search_date_modif_start) { $param .= '&search_date_modif_start='.urlencode($search_date_modif_start); } if ($search_date_modif_endmonth) { - $param .= '&search_date_modif_endmonth='.urlencode($search_date_modif_endmonth); + $param .= '&search_date_modif_endmonth='.urlencode((string) ($search_date_modif_endmonth)); } if ($search_date_modif_endyear) { - $param .= '&search_date_modif_endyear='.urlencode($search_date_modif_endyear); + $param .= '&search_date_modif_endyear='.urlencode((string) ($search_date_modif_endyear)); } if ($search_date_modif_endday) { - $param .= '&search_date_modif_endday='.urlencode($search_date_modif_endday); + $param .= '&search_date_modif_endday='.urlencode((string) ($search_date_modif_endday)); } if ($search_date_modif_end) { $param .= '&search_date_modif_end=' . urlencode($search_date_modif_end); } if ($search_date_startday > 0) { - $param .= '&search_date_startday='.urlencode($search_date_startday); + $param .= '&search_date_startday='.urlencode((string) ($search_date_startday)); } if ($search_date_startmonth > 0) { - $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); + $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth)); } if ($search_date_startyear > 0) { - $param .= '&search_date_startyear='.urlencode($search_date_startyear); + $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear)); } if ($search_date_endday > 0) { - $param .= '&search_date_endday='.urlencode($search_date_endday); + $param .= '&search_date_endday='.urlencode((string) ($search_date_endday)); } if ($search_date_endmonth > 0) { - $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); + $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth)); } if ($search_date_endyear > 0) { - $param .= '&search_date_endyear='.urlencode($search_date_endyear); + $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear)); } if ($search_dfyear > 0) { - $param .= '&search_dfyear='.urlencode($search_dfyear); + $param .= '&search_dfyear='.urlencode((string) ($search_dfyear)); } if ($search_dfmonth > 0) { - $param .= '&search_dfmonth='.urlencode($search_dfmonth); + $param .= '&search_dfmonth='.urlencode((string) ($search_dfmonth)); } if ($search_sale > 0) { $param .= '&search_sale='.urlencode($search_sale); } if ($search_user > 0) { - $param .= '&search_user='.urlencode($search_user); + $param .= '&search_user='.urlencode((string) ($search_user)); } if ($search_type_thirdparty > 0) { - $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); + $param .= '&search_type_thirdparty='.urlencode((string) ($search_type_thirdparty)); } if ($search_country != '') { $param .= "&search_country=".urlencode($search_country); } if ($search_product_category > 0) { - $param .= '&search_product_category='.urlencode($search_product_category); + $param .= '&search_product_category='.urlencode((string) ($search_product_category)); } if ($show_files) { - $param .= '&show_files='.urlencode($show_files); + $param .= '&show_files='.urlencode((string) ($show_files)); } if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); diff --git a/htdocs/contrat/messaging.php b/htdocs/contrat/messaging.php index f7e1b285291..8f3e5fac95e 100644 --- a/htdocs/contrat/messaging.php +++ b/htdocs/contrat/messaging.php @@ -37,7 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; // Load translation files required by the page $langs->loadLangs(array('agenda', 'contrat', 'companies')); -$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'contratagenda'; +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'contratagenda'; if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); @@ -45,7 +45,7 @@ if (GETPOST('actioncode', 'array')) { $actioncode = '0'; } } else { - $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); + $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } $search_rowid = GETPOST('search_rowid'); @@ -56,7 +56,7 @@ $confirm = GETPOST('confirm', 'alpha'); $id = GETPOSTINT('id'); $ref = GETPOST('ref', 'alpha'); -$limit = GETPOSTINT('limit') ?GETPOSTINT('limit') : $conf->liste_limit; +$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); @@ -101,7 +101,7 @@ if (!$user->hasRight('contrat', 'lire')) { /* * Actions */ -$parameters = array('id'=>$id); +$parameters = array('id' => $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'); @@ -241,7 +241,7 @@ if (isModEnabled('agenda')) { if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { print '
'; - $param = '&id='.urlencode($id); + $param = '&id='.urlencode((string) ($id)); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -254,9 +254,9 @@ if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $cachekey = 'count_events_thirdparty_'.$object->id; $nbEvent = dol_getcache($cachekey); - $titlelist = $langs->trans("ActionsOnCompany").(is_numeric($nbEvent) ? '('.$nbEvent.')': ''); + $titlelist = $langs->trans("ActionsOnCompany").(is_numeric($nbEvent) ? '('.$nbEvent.')' : ''); if (!empty($conf->dol_optimize_smallscreen)) { - $titlelist = $langs->trans("Actions").(is_numeric($nbEvent) ? '('.$nbEvent.')': ''); + $titlelist = $langs->trans("Actions").(is_numeric($nbEvent) ? '('.$nbEvent.')' : ''); } print_barre_liste($titlelist, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 0); diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 5c37dacedbe..ab0186f9e2f 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -587,7 +587,7 @@ if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) { if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && is_object($object->thirdparty)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 1acea501327..382cb71fca4 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -4,6 +4,7 @@ * Copyright (C) 2018 Juanjo Menent * Copyright (C) 2019 Ferran Marcet * Copyright (C) 2019-2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -373,9 +374,9 @@ if (!$error && $massaction == 'confirm_presend') { if ($filepath_found) { // Create form object $attachedfilesThirdpartyObj[$thirdpartyid][$objectid] = array( - 'paths'=>array($filepath_found), - 'names'=>array($filename_found), - 'mimes'=>array(dol_mimetype($filepath_found)) + 'paths' => array($filepath_found), + 'names' => array($filename_found), + 'mimes' => array(dol_mimetype($filepath_found)) ); } else { $nbignored++; @@ -477,7 +478,7 @@ if (!$error && $massaction == 'confirm_presend') { $substitutionarray['__EMAIL__'] = $thirdparty->email; $substitutionarray['__CHECK_READ__'] = ''; - $parameters = array('mode'=>'formemail'); + $parameters = array('mode' => 'formemail'); if (!empty($listofobjectthirdparties)) { $parameters['listofobjectthirdparties'] = $listofobjectthirdparties; @@ -491,16 +492,16 @@ if (!$error && $massaction == 'confirm_presend') { $subjectreplaced = make_substitutions($subject, $substitutionarray); $messagereplaced = make_substitutions($message, $substitutionarray); - $attachedfiles = array('paths'=>array(), 'names'=>array(), 'mimes'=>array()); + $attachedfiles = array('paths' => array(), 'names' => array(), 'mimes' => array()); if ($oneemailperrecipient) { // if "one email per recipient" is check we must collate $attachedfiles by thirdparty if (is_array($attachedfilesThirdpartyObj[$thirdparty->id]) && count($attachedfilesThirdpartyObj[$thirdparty->id])) { foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles) { // Create form object $attachedfiles = array( - 'paths'=>array_merge($attachedfiles['paths'], $objAttachedFiles['paths']), - 'names'=>array_merge($attachedfiles['names'], $objAttachedFiles['names']), - 'mimes'=>array_merge($attachedfiles['mimes'], $objAttachedFiles['mimes']) + 'paths' => array_merge($attachedfiles['paths'], $objAttachedFiles['paths']), + 'names' => array_merge($attachedfiles['names'], $objAttachedFiles['names']), + 'mimes' => array_merge($attachedfiles['mimes'], $objAttachedFiles['mimes']) ); } } @@ -720,11 +721,7 @@ if (!$error && $massaction == 'cancelorders') { } } if (!$error) { - if ($nbok > 1) { - setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - } else { - setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - } + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); $db->commit(); } else { $db->rollback(); @@ -1043,6 +1040,7 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' $objecttmp = new $objectclass($db); $nbok = 0; + $nbignored = 0; $TMsg = array(); //$toselect could contain duplicate entries, cf https://github.com/Dolibarr/dolibarr/issues/26244 @@ -1203,11 +1201,12 @@ if (!$error && $massaction == 'generate_doc' && $permissiontoread) { } if (!$error && ($action == 'affecttag' && $confirm == 'yes') && $permissiontoadd) { + $nbok = 0; $db->begin(); - $affecttag_type=GETPOST('affecttag_type', 'alpha'); + $affecttag_type = GETPOST('affecttag_type', 'alpha'); if (!empty($affecttag_type)) { - $affecttag_type_array=explode(',', $affecttag_type); + $affecttag_type_array = explode(',', $affecttag_type); } else { setEventMessage('CategTypeNotFound', 'errors'); } @@ -1215,8 +1214,8 @@ if (!$error && ($action == 'affecttag' && $confirm == 'yes') && $permissiontoadd //check if tag type submitted exists into Tag Map categorie class require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $categ = new Categorie($db); - $to_affecttag_type_array=array(); - $categ_type_array=$categ->getMapList(); + $to_affecttag_type_array = array(); + $categ_type_array = $categ->getMapList(); foreach ($categ_type_array as $categdef) { if (in_array($categdef['code'], $affecttag_type_array)) { $to_affecttag_type_array[] = $categdef['code']; @@ -1224,7 +1223,6 @@ if (!$error && ($action == 'affecttag' && $confirm == 'yes') && $permissiontoadd } //For each valid categ type set common categ - $nbok = 0; if (!empty($to_affecttag_type_array)) { foreach ($to_affecttag_type_array as $categ_type) { $contcats = GETPOST('contcats_' . $categ_type, 'array'); @@ -1250,22 +1248,19 @@ if (!$error && ($action == 'affecttag' && $confirm == 'yes') && $permissiontoadd } if (!$error) { - if ($nbok > 1) { - setEventMessages($langs->trans("RecordsModified", $nbok), null); - } else { - setEventMessages($langs->trans("RecordsModified", $nbok), null); - } + setEventMessages($langs->trans("RecordsModified", $nbok), null); $db->commit(); - $toselect=array(); + $toselect = array(); } else { $db->rollback(); } } if (!$error && ($action == 'updateprice' && $confirm == 'yes') && $permissiontoadd) { + $nbok = 0; $db->begin(); if (GETPOSTISSET('pricerate')) { - $pricepercentage=GETPOSTINT('pricerate'); + $pricepercentage = GETPOSTINT('pricerate'); if ($pricepercentage == 0) { setEventMessages($langs->trans("RecordsModified", 0), null); } else { @@ -1300,15 +1295,16 @@ if (!$error && ($action == 'updateprice' && $confirm == 'yes') && $permissiontoa setEventMessages($langs->trans("RecordsModified", $nbok), null); } $db->commit(); - $toselect=array(); + $toselect = array(); } else { $db->rollback(); } } if (!$error && ($action == 'setsupervisor' && $confirm == 'yes') && $permissiontoadd) { + $nbok = 0; $db->begin(); - $supervisortoset=GETPOST('supervisortoset'); + $supervisortoset = GETPOST('supervisortoset'); if (!empty($supervisortoset)) { foreach ($toselect as $toselectid) { $result = $object->fetch($toselectid); @@ -1333,24 +1329,21 @@ if (!$error && ($action == 'setsupervisor' && $confirm == 'yes') && $permissiont } if (!$error) { - if ($nbok > 1) { - setEventMessages($langs->trans("RecordsModified", $nbok), null); - } else { - setEventMessages($langs->trans("RecordsModified", $nbok), null); - } + setEventMessages($langs->trans("RecordsModified", $nbok), null); $db->commit(); - $toselect=array(); + $toselect = array(); } else { $db->rollback(); } } if (!$error && ($action == 'affectuser' && $confirm == 'yes') && $permissiontoadd) { + $nbok = 0; $db->begin(); - $usertoaffect=GETPOST('usertoaffect'); - $projectrole=GETPOST('projectrole'); - $tasksrole=GETPOST('tasksrole'); + $usertoaffect = GETPOST('usertoaffect'); + $projectrole = GETPOST('projectrole'); + $tasksrole = GETPOST('tasksrole'); if (!empty($usertoaffect)) { foreach ($toselect as $toselectid) { $result = $object->fetch($toselectid); @@ -1387,13 +1380,9 @@ if (!$error && ($action == 'affectuser' && $confirm == 'yes') && $permissiontoad } if (!$error) { - if ($nbok > 1) { - setEventMessages($langs->trans("RecordsModified", $nbok), null); - } else { - setEventMessages($langs->trans("RecordsModified", $nbok), null); - } + setEventMessages($langs->trans("RecordsModified", $nbok), null); $db->commit(); - $toselect=array(); + $toselect = array(); } else { $db->rollback(); } @@ -1406,9 +1395,9 @@ if (!$error && ($massaction == 'enable' || ($action == 'enable' && $confirm == ' $nbok = 0; foreach ($toselect as $toselectid) { $result = $objecttmp->fetch($toselectid); - if ($result>0) { + if ($result > 0) { if (in_array($objecttmp->element, array('societe'))) { - $result =$objecttmp->setStatut(1); + $result = $objecttmp->setStatut(1); } if ($result <= 0) { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); @@ -1443,9 +1432,9 @@ if (!$error && ($massaction == 'disable' || ($action == 'disable' && $confirm == $nbok = 0; foreach ($toselect as $toselectid) { $result = $objecttmp->fetch($toselectid); - if ($result>0) { + if ($result > 0) { if (in_array($objecttmp->element, array('societe'))) { - $result =$objecttmp->setStatut(0); + $result = $objecttmp->setStatut(0); } if ($result <= 0) { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); @@ -1488,7 +1477,7 @@ if (!$error && $action == 'confirm_edit_value_extrafields' && $confirm == 'yes' /** @var CommonObject $objecttmp */ $objecttmp = new $objectclass($db); // to avoid ghost data $result = $objecttmp->fetch($toselectid); - if ($result>0) { + if ($result > 0) { // Fill array 'array_options' with data from add form $ret = $e->setOptionalsFromPost(null, $objecttmp, $extrafieldKeyToUpdate); if ($ret > 0) { @@ -1524,7 +1513,7 @@ if (!$error && ($massaction == 'affectcommercial' || ($action == 'affectcommerci foreach ($toselect as $toselectid) { $result = $objecttmp->fetch($toselectid); - if ($result>0) { + if ($result > 0) { if (in_array($objecttmp->element, array('societe'))) { $result = $objecttmp->setSalesRep(GETPOST("commercial", "alpha")); } @@ -1719,7 +1708,7 @@ if (!$error && ($massaction == 'increaseholiday' || ($action == 'increaseholiday setEventMessages($langs->trans("HolidayRecordIncreased"), null, 'mesgs'); } $db->commit(); - $toselect=array(); + $toselect = array(); } else { $db->rollback(); } diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 48ee32f5de2..3fbd13840c2 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -321,7 +321,7 @@ if ($type == 'directory') { $param .= '&website='.urlencode(GETPOST('website', 'alpha')); } if (!preg_match('/pageid=/', $param)) { - $param .= '&pageid='.urlencode(GETPOSTINT('pageid')); + $param .= '&pageid='.urlencode((string) (GETPOSTINT('pageid'))); } //if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid); } diff --git a/htdocs/core/ajax/onlineSign.php b/htdocs/core/ajax/onlineSign.php index 996f7be806d..de58f75c303 100644 --- a/htdocs/core/ajax/onlineSign.php +++ b/htdocs/core/ajax/onlineSign.php @@ -1,4 +1,6 @@ + */ /* * 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 @@ -580,18 +582,15 @@ if ($action == "importSignature") { $classname = 'pdf_' . $last_modelpdf; break; } - if ($filefound) { - break; - } } - if (!$filefound) { + if ($filefound === '') { $response = $langs->trans("Error") . ' Failed to load doc generator with modelpaths=' . $modelpath . ' - modele=' . $last_modelpdf; dol_syslog($response, LOG_ERR); $error++; } - if (!$error) { + if (!$error && $classname !== '') { // If PDF template class was found require_once $file; diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index 00a86ccd9a9..f1d63188307 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -106,7 +106,7 @@ if (isModEnabled('propal') && !getDolGlobalString('MAIN_SEARCHFORM_CUSTOMER_PROP if (isModEnabled('order') && !getDolGlobalString('MAIN_SEARCHFORM_CUSTOMER_ORDER_DISABLED') && $user->hasRight('commande', 'lire')) { $arrayresult['searchintoorder'] = array('position' => 70, 'img' => 'object_order', 'label' => $langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'text' => img_picto('', 'object_order', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'url' => DOL_URL_ROOT.'/commande/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); } -if (isModEnabled('delivery_note') && !getDolGlobalString('MAIN_SEARCHFORM_CUSTOMER_SHIPMENT_DISABLED') && $user->hasRight('expedition', 'lire')) { +if (isModEnabled('shipping') && !getDolGlobalString('MAIN_SEARCHFORM_CUSTOMER_SHIPMENT_DISABLED') && $user->hasRight('expedition', 'lire')) { $arrayresult['searchintoshipment'] = array('position' => 80, 'img' => 'object_shipment', 'label' => $langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'text' => img_picto('', 'object_shipment', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'url' => DOL_URL_ROOT.'/expedition/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); } if (isModEnabled('invoice') && !getDolGlobalString('MAIN_SEARCHFORM_CUSTOMER_INVOICE_DISABLED') && $user->hasRight('facture', 'lire')) { diff --git a/htdocs/core/boxes/box_members_subscriptions_by_year.php b/htdocs/core/boxes/box_members_subscriptions_by_year.php index 09df79556bb..ddb3b12185b 100644 --- a/htdocs/core/boxes/box_members_subscriptions_by_year.php +++ b/htdocs/core/boxes/box_members_subscriptions_by_year.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015-2021 Frederic France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -110,7 +111,7 @@ class box_members_subscriptions_by_year extends ModeleBoxes } - $line = 0; + $line = 0; // @phan-suppress-current-line PhanPluginRedundantAssignment $this->info_box_contents[$line][] = array( 'td' => 'class=""', 'text' => $langs->trans("Year"), diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index 9be28e8bfc0..3ada87e0a10 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Raphaël Doursenaud * Copyright (C) 2015 Frederic France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -194,7 +195,7 @@ class ModeleBoxes // Can't be abstract as it is instantiated to build "empty" bo * Standard method to show a box (usage by boxes not mandatory, a box can still use its own showBox function) * * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines + * @param array> $contents Array with properties of box lines * @param int $nooutput No print, only return string * @return string */ diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index e782e83f662..91e7d127486 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -7,6 +7,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2019-2023 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -197,7 +198,7 @@ class CMailFile } } if (empty($this->sendmode)) { - $this->sendmode = (getDolGlobalString('MAIN_MAIL_SENDMODE') ? $conf->global->MAIN_MAIL_SENDMODE : 'mail'); + $this->sendmode = getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'); } // Add a Feedback-ID. Must be used for stats on spam report only. @@ -274,7 +275,7 @@ class CMailFile // This converts an embed file with src="/viewimage.php?modulepart... into a cid link // TODO Exclude viewimage used for the read tracker ? $findimg = $this->findHtmlImages($dolibarr_main_data_root.'/medias'); - if ($findimg<0) { + if ($findimg < 0) { dol_syslog("CMailFile::CMailfile: Error on findHtmlImages"); $this->error = 'ErrorInAddAttachementsImageBaseOnMedia'; return; @@ -285,7 +286,7 @@ class CMailFile // Search into the body for error = 'ErrorInAddAttachementsImageBaseOnMedia'; return; @@ -388,7 +389,7 @@ class CMailFile $addr_cc = implode(',', $tabcc); //Verify for $addr_bcc - $replacebcc= false; + $replacebcc = false; $tabbcc = explode(',', $addr_bcc); foreach ($tabbcc as $key => $bcc) { if (in_array($bcc, $tabbcc)) { @@ -730,7 +731,7 @@ class CMailFile /** * Send mail that was prepared by constructor. * - * @return boolean True if mail sent, false otherwise + * @return int|bool|string True if mail sent, false otherwise. Negative int if error in hook. String if incorrect send mode. */ public function sendfile() { @@ -755,7 +756,7 @@ class CMailFile $this->error = "Error in hook maildao sendMail ".$reshook; dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); - return $reshook; + return false; } if ($reshook == 1) { // Hook replace standard code return true; @@ -1118,7 +1119,7 @@ class CMailFile $result = $this->smtps->getErrors(); // applicative error code (not SMTP error code) if (empty($this->error) && empty($result)) { dol_syslog("CMailFile::sendfile: mail end success", LOG_DEBUG); - $res = true; + $res = true; // @phan-suppress-current-line PhanPluginRedundantAssignment } else { if (empty($this->error)) { $this->error = $result; @@ -1283,7 +1284,8 @@ class CMailFile // Send mail method not correctly defined // -------------------------------------- - return 'Bad value for sendmode'; + $this->error = 'Bad value for sendmode'; + return false; } // Now we delete image files that were created dynamically to manage data inline files @@ -1300,7 +1302,7 @@ class CMailFile $this->error = "Error in hook maildao sendMailAfter ".$reshook; dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); - return $reshook; + return false; } } else { $this->error = 'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; diff --git a/htdocs/core/class/CSMSFile.class.php b/htdocs/core/class/CSMSFile.class.php index 65c23b44c50..4e34d9a284f 100644 --- a/htdocs/core/class/CSMSFile.class.php +++ b/htdocs/core/class/CSMSFile.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -207,7 +208,7 @@ class CSMSFile // Send sms method not correctly defined // -------------------------------------- $this->error = 'Bad value for MAIN_SMS_SENDMODE constant'; - $res = false; + $res = false; // @phan-suppress-current-line PhanPluginRedundantAssignment } } else { $this->error = 'No sms sent. Feature is disabled by option MAIN_DISABLE_ALL_SMS'; diff --git a/htdocs/core/class/cgenericdic.class.php b/htdocs/core/class/cgenericdic.class.php index 9c617d9c78d..c39f8cbbf23 100644 --- a/htdocs/core/class/cgenericdic.class.php +++ b/htdocs/core/class/cgenericdic.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2016 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -220,16 +221,15 @@ class CGenericDic extends CommonDict /** * Load object in memory from the database * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit offset limit - * @param int $offset offset limit - * @param array $filter filter array - * @param string $filtermode filter mode (AND or OR) - * - * @return int Return integer <0 if KO, >0 if OK + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit Limit + * @param int $offset offset limit + * @param string|array $filter filter USF + * @param string $filtermode filter mode (AND or OR) + * @return int Return integer <0 if KO, >0 if OK */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND') { dol_syslog(__METHOD__, LOG_DEBUG); @@ -243,23 +243,36 @@ class CGenericDic extends CommonDict } $sql = "SELECT"; - $sql .= " t.".$fieldrowid.","; + $sql .= " t.".$this->db->sanitize($fieldrowid).","; $sql .= " t.code,"; - $sql .= " t.".$fieldlabel." as label,"; + $sql .= " t.".$this->db->sanitize($fieldlabel)." as label,"; $sql .= " t.active"; $sql .= " FROM ".$this->db->prefix().$this->table_element." as t"; // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'"; + if (is_array($filter)) { + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + $sqlwhere[] = $this->db->sanitize($key)." LIKE '%".$this->db->escape($value)."%'"; + } } + if (count($sqlwhere) > 0) { + $sql .= " WHERE ".implode(' '.$this->db->escape($filtermode).' ', $sqlwhere); + } + + $filter = ''; } - if (count($sqlwhere) > 0) { - $sql .= " WHERE ".implode(' '.$this->db->escape($filtermode).' ', $sqlwhere); + // Manage filter + $errormessage = ''; + $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage); + if ($errormessage) { + $this->errors[] = $errormessage; + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); + return -1; } + if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); } diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index b80ce304f94..251442a9b72 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -5,8 +5,9 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Marcos García * Copyright (C) 2016-2023 Charlene Benke - * Copyright (C) 2018-2023 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2020 Josep Lluís Amador + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -232,6 +233,9 @@ abstract class CommonDocGenerator ); // Retrieve extrafields if (is_array($user->array_options) && count($user->array_options)) { + if (empty($extrafields->attributes[$user->table_element])) { + $extrafields->fetch_name_optionals_label($user->table_element); + } $array_user = $this->fill_substitutionarray_with_extrafields($user, $array_user, $extrafields, 'myuser', $outputlangs); } return $array_user; @@ -1488,9 +1492,17 @@ abstract class CommonDocGenerator if (!empty($fields)) { // Sort extrafields by rank - uasort($fields, function ($a, $b) { - return ($a->rank > $b->rank) ? 1 : -1; - }); + uasort( + $fields, + /** + * @param stdClass $a + * @param stdClass $b + * @return int<-1,1> + */ + static function ($a, $b) { + return ($a->rank > $b->rank) ? 1 : -1; + } + ); // define some HTML content with style $html .= !empty($params['style']) ? '' : ''; diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 708e198ac98..fcdc114110e 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2023 Nick Fragoulis * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -269,7 +270,7 @@ abstract class CommonInvoice extends CommonObject if ($multicurrency < 0) { $this->sumpayed = $obj->amount; $this->sumpayed_multicurrency = $obj->multicurrency_amount; - return array('alreadypaid'=>(float) $obj->amount, 'alreadypaid_multicurrency'=>(float) $obj->multicurrency_amount); + return array('alreadypaid' => (float) $obj->amount, 'alreadypaid_multicurrency' => (float) $obj->multicurrency_amount); } elseif ($multicurrency) { $this->sumpayed_multicurrency = $obj->multicurrency_amount; return (float) $obj->multicurrency_amount; @@ -477,7 +478,7 @@ abstract class CommonInvoice extends CommonObject $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); - $tmp = array('amount'=>$obj->amount, 'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); + $tmp = array('amount' => $obj->amount, 'type' => $obj->code, 'date' => $obj->datep, 'num' => $obj->num, 'ref' => $obj->ref); if (!empty($field3)) { $tmp['ref_ext'] = $obj->ref_ext; } @@ -511,9 +512,9 @@ abstract class CommonInvoice extends CommonObject while ($i < $num) { $obj = $this->db->fetch_object($resql); if ($multicurrency) { - $retarray[] = array('amount'=>$obj->multicurrency_amount, 'type'=>$obj->type, 'date'=>$obj->date, 'num'=>'0', 'ref'=>$obj->ref); + $retarray[] = array('amount' => $obj->multicurrency_amount, 'type' => $obj->type, 'date' => $obj->date, 'num' => '0', 'ref' => $obj->ref); } else { - $retarray[] = array('amount'=>$obj->amount, 'type'=>$obj->type, 'date'=>$obj->date, 'num'=>'', 'ref'=>$obj->ref); + $retarray[] = array('amount' => $obj->amount, 'type' => $obj->type, 'date' => $obj->date, 'num' => '', 'ref' => $obj->ref); } $i++; } @@ -551,7 +552,6 @@ abstract class CommonInvoice extends CommonObject public function is_erasable() { // phpcs:enable - global $conf; // We check if invoice is a temporary number (PROVxxxx) $tmppart = substr($this->ref, 1, 4); @@ -1313,9 +1313,9 @@ abstract class CommonInvoice extends CommonObject if ($foundalternativestripeaccount) { if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage - $customer = \Stripe\Customer::retrieve(array('id'=>"$foundalternativestripeaccount", 'expand[]'=>'sources')); + $customer = \Stripe\Customer::retrieve(array('id' => "$foundalternativestripeaccount", 'expand[]' => 'sources')); } else { - $customer = \Stripe\Customer::retrieve(array('id'=>"$foundalternativestripeaccount", 'expand[]'=>'sources'), array("stripe_account" => $stripeacc)); + $customer = \Stripe\Customer::retrieve(array('id' => "$foundalternativestripeaccount", 'expand[]' => 'sources'), array("stripe_account" => $stripeacc)); } } else { $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 0); @@ -1501,7 +1501,7 @@ abstract class CommonInvoice extends CommonObject $description = 'Failed to find or use your payment mode (no payment mode for this customer id)'; $stripefailurecode = 'BADPAYMENTMODE'; $stripefailuremessage = 'Failed to find or use your payment mode (no payment mode for this customer id)'; - $postactionmessages = []; + $postactionmessages = []; // @phan-suppress-current-line PhanPluginRedundantAssignment $object = $this; diff --git a/htdocs/core/class/commonnumrefgenerator.class.php b/htdocs/core/class/commonnumrefgenerator.class.php index c4edb202031..60104d09cd7 100644 --- a/htdocs/core/class/commonnumrefgenerator.class.php +++ b/htdocs/core/class/commonnumrefgenerator.class.php @@ -132,7 +132,7 @@ abstract class CommonNumRefGenerator * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param Object $object Object we need next value for + * @param CommonObject $object Object we need next value for * @return boolean false if conflict, true if ok */ public function canBeActivated($object) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a140bf1e4b7..6d3d2c65557 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -140,7 +140,7 @@ abstract class CommonObject /** - * @var array,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array(); @@ -504,6 +504,16 @@ abstract class CommonObject */ public $multicurrency_total_ttc; + /** + * @var float Multicurrency total localta1 + */ + public $multicurrency_total_localtax1; // not in database + + /** + * @var float Multicurrency total localtax2 + */ + public $multicurrency_total_localtax2; // not in database + /** * @var string * @see SetDocModel() @@ -781,9 +791,9 @@ abstract class CommonObject protected $childtables = array(); /** - * @var array List of child tables. To know object to delete on cascade. - * If name is like '@ClassName:FilePathClass:ParentFkFieldName', it will - * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object. + * @var string[] List of child tables. To know object to delete on cascade. + * If name is like '@ClassName:FilePathClass:ParentFkFieldName', it will + * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object. */ protected $childtablesoncascade = array(); @@ -1659,19 +1669,13 @@ abstract class CommonObject $modulename = 'agenda'; } elseif (strpos($obj->element, 'supplier') !== false && $obj->element != 'supplier_proposal') { $modulename = 'fournisseur'; - } elseif (strpos($obj->element, 'supplier') !== false && $obj->element != 'supplier_proposal') { - $modulename = 'fournisseur'; } if (!empty($conf->{$modulename}->enabled)) { $libelle_element = $langs->trans('ContactDefault_'.$obj->element); $tmpelement = $obj->element; $transkey = "TypeContact_".$tmpelement."_".$source."_".$obj->code; $libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->type_label); - if (empty($option)) { - $tab[$obj->rowid] = $libelle_element.' - '.$libelle_type; - } else { - $tab[$obj->rowid] = $libelle_element.' - '.$libelle_type; - } + $tab[$obj->rowid] = $libelle_element.' - '.$libelle_type; } } } @@ -3284,8 +3288,8 @@ abstract class CommonObject if ($this->db->num_rows($resql) > 0) { while ($row = $this->db->fetch_row($resql)) { $rows[] = $row[0]; - if (!empty($includealltree)) { - $rows = array_merge($rows, $this->getChildrenOfLine($row[0]), $includealltree); + if ($includealltree) { + $rows = array_merge($rows, $this->getChildrenOfLine($row[0], $includealltree)); } } } @@ -4228,7 +4232,7 @@ abstract class CommonObject } elseif ($objecttype == 'delivery') { $classpath = 'delivery/class'; $subelement = 'delivery'; - $module = 'delivery_note'; + $module = 'shipping'; } elseif ($objecttype == 'invoice_supplier' || $objecttype == 'order_supplier') { $classpath = 'fourn/class'; $module = 'fournisseur'; @@ -5709,7 +5713,7 @@ abstract class CommonObject } } - if (!$filefound) { + if ($filefound === '' || $classname === '') { $this->error = $langs->trans("Error").' Failed to load doc generator with modelpaths='.$modelspath.' - modele='.$modele; $this->errors[] = $this->error; dol_syslog($this->error, LOG_ERR); @@ -7374,7 +7378,7 @@ abstract class CommonObject } $out = ' '; } elseif ($type == 'select') { // combo list - $out = ''; + $out = ''; // @phan-suppress-current-line PhanPluginRedundantAssignment if (!empty($conf->use_javascript_ajax) && !getDolGlobalString('MAIN_EXTRAFIELDS_DISABLE_SELECT2')) { include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $out .= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); @@ -7396,7 +7400,7 @@ abstract class CommonObject $isDependList = 1; } $tmpselect .= (!empty($parent) ? ' parent="'.$parent.'"' : ''); - $tmpselect .= '>'.$valb.''; + $tmpselect .= '>'.$langs->trans($valb).''; } $out .= ''; } elseif ($type == 'sellist') { - $out = ''; + $out = ''; // @phan-suppress-current-line PhanPluginRedundantAssignment if (!empty($conf->use_javascript_ajax) && !getDolGlobalString('MAIN_EXTRAFIELDS_DISABLE_SELECT2')) { include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $out .= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); @@ -7600,7 +7604,7 @@ abstract class CommonObject $value_arr = explode(',', $value); $out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options']) ? null : $param['options']), $value_arr, '', 0, $morecss, 0, '100%'); } elseif ($type == 'radio') { - $out = ''; + $out = ''; // @phan-suppress-current-line PhanPluginRedundantAssignment foreach ($param['options'] as $keyopt => $valopt) { $out .= ' '; @@ -8010,7 +8014,11 @@ abstract class CommonObject if (!empty($value)) { $checked = ' checked '; } - $value = ''; + if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER') < 2) { + $value = ''; + } else { + $value = yn($value ? 1 : 0); + } } elseif ($type == 'mail' || $type == 'email') { $value = dol_print_email($value, 0, 0, 0, 64, 1, 1); } elseif ($type == 'url') { @@ -8026,7 +8034,7 @@ abstract class CommonObject } elseif ($type == 'select') { $value = isset($param['options'][$value]) ? $param['options'][$value] : ''; if (strpos($value, "|") !== false) { - $value = explode('|', $value)[0]; + $value = $langs->trans(explode('|', $value)[0]); } } elseif ($type == 'sellist') { $param_list = array_keys($param['options']); @@ -8846,13 +8854,7 @@ abstract class CommonObject } $out .= ($display_type == 'card' ? '' : ''); - - if (getDolGlobalString('MAIN_EXTRAFIELDS_USE_TWO_COLUMS') && (($e % 2) == 1)) { - $out .= ($display_type == 'card' ? '' : ''); - } else { - $out .= ($display_type == 'card' ? '' : ''); - } - + $out .= ($display_type == 'card' ? '' : ''); $e++; } } diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index 1a0f1f15ed0..92a84376184 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2012 Cedric Salvador + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -167,8 +168,6 @@ abstract class CommonObjectLine extends CommonObject $langs->load('products'); - $label_type = 'label'; - $label_type = 'label'; if ($type == 'short') { $label_type = 'short_label'; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 647354ef247..a8148548443 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -41,9 +41,14 @@ class Conf extends stdClass */ public $db; - //! To store properties found into database + /** + * @var Object To store global setup found into database + */ public $global; - //! To store browser info (->name, ->os, ->version, ->ua, ->layout, ...) + + /** + * @var Object To store browser info (->name, ->os, ->version, ->ua, ->layout, ...) + */ public $browser; //! To store some setup of generic modules diff --git a/htdocs/core/class/cproductnature.class.php b/htdocs/core/class/cproductnature.class.php index b395bf8983f..749b07b4029 100644 --- a/htdocs/core/class/cproductnature.class.php +++ b/htdocs/core/class/cproductnature.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2020 Florian HENRY + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -153,13 +154,13 @@ class CProductNature extends CommonDict * * @param string $sortorder Sort Order * @param string $sortfield Sort field - * @param int $limit limit + * @param int $limit Limit * @param int $offset Offset - * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) + * @param string $filter Filter USF * @param string $filtermode Filter mode (AND or OR) * @return array|int int <0 if KO, array of pages if OK */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND') { dol_syslog(__METHOD__, LOG_DEBUG); @@ -169,23 +170,38 @@ class CProductNature extends CommonDict $sql .= " t.label,"; $sql .= " t.active"; $sql .= " FROM ".$this->db->prefix().$this->table_element." as t"; + $sql .= " WHERE 1 = 1"; + // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - if ($key == 't.rowid' || $key == 't.active' || $key == 't.code') { - $sqlwhere[] = $key." = ".((int) $value); - } elseif (strpos($key, 'date') !== false) { - $sqlwhere[] = $key." = '".$this->db->idate($value)."'"; - } elseif ($key == 't.label') { - $sqlwhere[] = $key." = '".$this->db->escape($value)."'"; - } else { - $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'"; + if (is_array($filter)) { + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.rowid' || $key == 't.active' || $key == 't.code') { + $sqlwhere[] = $this->db->sanitize($key)." = ".((int) $value); + } elseif (strpos($key, 'date') !== false) { + $sqlwhere[] = $this->db->sanitize($key)." = '".$this->db->idate($value)."'"; + } elseif ($key == 't.label') { + $sqlwhere[] = $this->db->sanitize($key)." = '".$this->db->escape($value)."'"; + } else { + $sqlwhere[] = $this->db->sanitize($key)." LIKE '%".$this->db->escape($value)."%'"; + } } } + if (count($sqlwhere) > 0) { + $sql .= " AND ".implode(' '.$this->db->escape($filtermode).' ', $sqlwhere); + } + + $filter = ''; } - if (count($sqlwhere) > 0) { - $sql .= ' WHERE ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')'; + + // Manage filter + $errormessage = ''; + $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage); + if ($errormessage) { + $this->errors[] = $errormessage; + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); + return -1; } if (!empty($sortfield)) { diff --git a/htdocs/core/class/ctyperesource.class.php b/htdocs/core/class/ctyperesource.class.php index 5d839fb0f26..076b7198353 100644 --- a/htdocs/core/class/ctyperesource.class.php +++ b/htdocs/core/class/ctyperesource.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2016 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -194,16 +195,15 @@ class Ctyperesource extends CommonDict /** * Load object in memory from the database * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit offset limit - * @param int $offset offset limit - * @param array $filter filter array - * @param string $filtermode filter mode (AND or OR) - * - * @return int Return integer <0 if KO, >0 if OK + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit Limit + * @param int $offset Offset limit + * @param string|array $filter filter array + * @param string $filtermode filter mode (AND or OR) + * @return int Return integer <0 if KO, >0 if OK */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND') { dol_syslog(__METHOD__, LOG_DEBUG); @@ -213,18 +213,40 @@ class Ctyperesource extends CommonDict $sql .= " t.label,"; $sql .= " t.active"; $sql .= " FROM ".$this->db->prefix().$this->table_element." as t"; + $sql .= " WHERE 1 = 1"; // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'"; + if (is_array($filter)) { + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.rowid' || $key == 't.active' || $key == 't.code') { + $sqlwhere[] = $this->db->sanitize($key)." = ".((int) $value); + } elseif (strpos($key, 'date') !== false) { + $sqlwhere[] = $this->db->sanitize($key)." = '".$this->db->idate($value)."'"; + } elseif ($key == 't.label') { + $sqlwhere[] = $this->db->sanitize($key)." = '".$this->db->escape($value)."'"; + } else { + $sqlwhere[] = $this->db->sanitize($key)." LIKE '%".$this->db->escape($value)."%'"; + } + } } + if (count($sqlwhere) > 0) { + $sql .= " AND ".implode(' '.$this->db->escape($filtermode).' ', $sqlwhere); + } + + $filter = ''; } - if (count($sqlwhere) > 0) { - $sql .= ' WHERE '.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere); + // Manage filter + $errormessage = ''; + $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage); + if ($errormessage) { + $this->errors[] = $errormessage; + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); + return -1; } + if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); } diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index 7db6859f82b..8d66112174e 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -207,15 +208,15 @@ class CUnits extends CommonDict /** * Load list of objects in memory from the database. * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit limit - * @param int $offset Offset - * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) - * @param string $filtermode Filter mode (AND or OR) - * @return array|int int <0 if KO, array of pages if OK + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit Limit + * @param int $offset Offset + * @param string|array $filter Filter USF + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND') { dol_syslog(__METHOD__, LOG_DEBUG); @@ -229,24 +230,38 @@ class CUnits extends CommonDict $sql .= " t.scale,"; $sql .= " t.active"; $sql .= " FROM ".$this->db->prefix()."c_units as t"; + $sql .= " WHERE 1 = 1"; // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - if ($key == 't.rowid' || $key == 't.active' || $key == 't.scale') { - $sqlwhere[] = $this->db->sanitize($key)." = ".((int) $value); - } elseif (strpos($key, 'date') !== false) { - $sqlwhere[] = $this->db->sanitize($key)." = '".$this->db->idate($value)."'"; - } elseif ($key == 't.unit_type' || $key == 't.code' || $key == 't.short_label') { - $sqlwhere[] = $this->db->sanitize($key)." = '".$this->db->escape($value)."'"; - } else { - $sqlwhere[] = $this->db->sanitize($key)." LIKE '%".$this->db->escape($this->db->escapeforlike($value))."%'"; + if (is_array($filter)) { + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.rowid' || $key == 't.active' || $key == 't.scale') { + $sqlwhere[] = $this->db->sanitize($key)." = ".((int) $value); + } elseif (strpos($key, 'date') !== false) { + $sqlwhere[] = $this->db->sanitize($key)." = '".$this->db->idate($value)."'"; + } elseif ($key == 't.unit_type' || $key == 't.code' || $key == 't.short_label') { + $sqlwhere[] = $this->db->sanitize($key)." = '".$this->db->escape($value)."'"; + } else { + $sqlwhere[] = $this->db->sanitize($key)." LIKE '%".$this->db->escape($this->db->escapeforlike($value))."%'"; + } } } + if (count($sqlwhere) > 0) { + $sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')'; + } + + $filter = ''; } - if (count($sqlwhere) > 0) { - $sql .= ' WHERE ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')'; + + // Manage filter + $errormessage = ''; + $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage); + if ($errormessage) { + $this->errors[] = $errormessage; + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); + return -1; } if (!empty($sortfield)) { diff --git a/htdocs/core/class/defaultvalues.class.php b/htdocs/core/class/defaultvalues.class.php index cdb14b5bd5a..de216b0c47c 100644 --- a/htdocs/core/class/defaultvalues.class.php +++ b/htdocs/core/class/defaultvalues.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2021 Florian HENRY * Copyright (C) 2021-2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -86,7 +87,7 @@ class DefaultValues extends CommonObject // BEGIN MODULEBUILDER PROPERTIES /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 10), diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index d1743b8c733..215d9a9e0e0 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -1,6 +1,7 @@ * Copyright (c) 2004-2015 Laurent Destailleur + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1288,7 +1289,6 @@ class DolGraph $this->stringtoshow .= '], datasets: ['; $i = 0; - $i = 0; while ($i < $nblot) { // Loop on each series $color = 'rgb(' . $this->datacolor[$i][0] . ', ' . $this->datacolor[$i][1] . ', ' . $this->datacolor[$i][2] . ')'; @@ -1310,11 +1310,7 @@ class DolGraph $type = 'bar'; $xaxis = ''; - if (!isset($this->type[$firstlot]) || $this->type[$firstlot] == 'bars') { - $type = 'bar'; - } if (isset($this->type[$firstlot]) && $this->type[$firstlot] == 'horizontalbars') { - $type = 'bar'; $xaxis = "indexAxis: 'y', "; } if (isset($this->type[$firstlot]) && ($this->type[$firstlot] == 'lines' || $this->type[$firstlot] == 'linesnopoint')) { @@ -1348,7 +1344,7 @@ class DolGraph $this->stringtoshow .= 'tooltip: { mode: \'nearest\', callbacks: {'; if (is_array($this->tooltipsTitles)) { - $this->stringtoshow .=' + $this->stringtoshow .= ' title: function(tooltipItem, data) { var tooltipsTitle ='.json_encode($this->tooltipsTitles).' return tooltipsTitle[tooltipItem[0].datasetIndex]; @@ -1360,7 +1356,7 @@ class DolGraph return tooltipslabels[tooltipItem.datasetIndex] }'; } - $this->stringtoshow .='}},'; + $this->stringtoshow .= '}},'; } $this->stringtoshow .= "}, \n"; @@ -1388,7 +1384,7 @@ class DolGraph $this->stringtoshow .= 'tooltips: { mode: \'nearest\', callbacks: {'; if (is_array($this->tooltipsTitles)) { - $this->stringtoshow .=' + $this->stringtoshow .= ' title: function(tooltipItem, data) { var tooltipsTitle ='.json_encode($this->tooltipsTitles).' return tooltipsTitle[tooltipItem[0].datasetIndex]; @@ -1400,7 +1396,7 @@ class DolGraph return tooltipslabels[tooltipItem.datasetIndex] }'; } - $this->stringtoshow .='}},'; + $this->stringtoshow .= '}},'; } $this->stringtoshow .= '};'; $this->stringtoshow .= ' diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php index 00a8d800251..d9f8aa251cc 100644 --- a/htdocs/core/class/emailsenderprofile.class.php +++ b/htdocs/core/class/emailsenderprofile.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -88,19 +89,19 @@ class EmailSenderProfile extends CommonObject // BEGIN MODULEBUILDER PROPERTIES /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( - 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',), - 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>-1, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), - 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>1), - 'email' => array('type'=>'varchar(255)', 'label'=>'Email', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1), - 'private' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'User', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'default'=>'0', 'notnull'=>1), - 'signature' => array('type'=>'html', 'label'=>'Signature', 'visible'=>3, 'enabled'=>1, 'position'=>400, 'notnull'=>-1, 'index'=>1,), - 'position' => array('type'=>'integer', 'label'=>'Position', 'visible'=>1, 'enabled'=>1, 'position'=>405, 'notnull'=>-1, 'index'=>1,), - 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), - 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), - 'active' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'default'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array(0=>'Disabled', 1=>'Enabled')), + 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'visible' => -1, 'enabled' => 1, 'position' => 1, 'notnull' => 1, 'index' => 1, 'comment' => 'Id',), + 'entity' => array('type' => 'integer', 'label' => 'Entity', 'visible' => -1, 'enabled' => 1, 'position' => 20, 'notnull' => 1, 'index' => 1,), + 'label' => array('type' => 'varchar(255)', 'label' => 'Label', 'visible' => 1, 'enabled' => 1, 'position' => 30, 'notnull' => 1), + 'email' => array('type' => 'varchar(255)', 'label' => 'Email', 'visible' => 1, 'enabled' => 1, 'position' => 40, 'notnull' => -1), + 'private' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'User', 'visible' => 1, 'enabled' => 1, 'position' => 50, 'default' => '0', 'notnull' => 1), + 'signature' => array('type' => 'html', 'label' => 'Signature', 'visible' => 3, 'enabled' => 1, 'position' => 400, 'notnull' => -1, 'index' => 1,), + 'position' => array('type' => 'integer', 'label' => 'Position', 'visible' => 1, 'enabled' => 1, 'position' => 405, 'notnull' => -1, 'index' => 1,), + 'date_creation' => array('type' => 'datetime', 'label' => 'DateCreation', 'visible' => -1, 'enabled' => 1, 'position' => 500, 'notnull' => 1,), + 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'visible' => -1, 'enabled' => 1, 'position' => 500, 'notnull' => 1,), + 'active' => array('type' => 'integer', 'label' => 'Status', 'visible' => 1, 'enabled' => 1, 'default' => 1, 'position' => 1000, 'notnull' => 1, 'index' => 1, 'arrayofkeyval' => array(0 => 'Disabled', 1 => 'Enabled')), ); /** diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index deb021bb0bc..59b937fce95 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -11,6 +11,7 @@ * Copyright (C) 2017 Nicolas ZABOURI * Copyright (C) 2018-2022 Frédéric France * Copyright (C) 2022 Antonin MARCHAL + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -44,7 +45,7 @@ class ExtraFields public $db; /** - * @var array,type:array,size:array,default:array,computed:array,unique:array,required:array,param:array,perms:array,list:array,totalizable:array,help:array,printable:array,enabled:array,langfile:array,css:array,csslist:array,hidden:array,mandatoryfieldsofotherentities:array,isameasure?:array}> New array to store extrafields definition + * @var array,type:array,size:array,default:array,computed:array,unique:array,required:array,param:array,perms:array,list:array,totalizable:array,help:array,printable:array,enabled:array,langfile:array,css:array,csslist:array,hidden:array,mandatoryfieldsofotherentities:array}> New array to store extrafields definition */ public $attributes; @@ -1121,7 +1122,6 @@ class ExtraFields } else { $checked = ' value="1" '; } - $out = ''; } else { $out = $form->selectyesno($keyprefix.$key.$keysuffix, $value, 1, false, 1); @@ -1148,7 +1148,7 @@ class ExtraFields } $out = ' '; } elseif ($type == 'select') { - $out = ''; + $out = ''; // @phan-suppress-current-line PhanPluginRedundantAssignment if ($mode) { $options = array(); foreach ($param['options'] as $okey => $val) { @@ -1203,7 +1203,7 @@ class ExtraFields $out .= ''; } } elseif ($type == 'sellist') { - $out = ''; + $out = ''; // @phan-suppress-current-line PhanPluginRedundantAssignment if (!empty($conf->use_javascript_ajax) && !getDolGlobalString('MAIN_EXTRAFIELDS_DISABLE_SELECT2')) { include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $out .= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); @@ -1311,7 +1311,6 @@ class ExtraFields } else { $labeltoshow = $obj->{$InfoFieldList[1]}; } - $labeltoshow = $labeltoshow; if ($value == $obj->rowid) { if (!$notrans) { @@ -1367,7 +1366,7 @@ class ExtraFields } $out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options']) ? null : $param['options']), $value_arr, '', 0, '', 0, '100%'); } elseif ($type == 'radio') { - $out = ''; + $out = ''; // @phan-suppress-current-line PhanPluginRedundantAssignment foreach ($param['options'] as $keyopt => $val) { $out .= ''; + if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER') < 2) { + $value = ''; + } else { + $value = yn($value ? 1 : 0); + } } elseif ($type == 'mail') { $value = dol_print_email($value, 0, 0, 0, 64, 1, 1); } elseif ($type == 'ip') { diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index 290a75738e0..686bc3566d0 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -197,7 +197,7 @@ class FileUpload */ protected function setFileDeleteUrl($file) { - $file->delete_url = $this->options['script_url'].'?file='.urlencode($file->name).'&fk_element='.urlencode($this->fk_element).'&element='.urlencode($this->element); + $file->delete_url = $this->options['script_url'].'?file='.urlencode((string) ($file->name)).'&fk_element='.urlencode((string) ($this->fk_element)).'&element='.urlencode((string) ($this->element)); $file->delete_type = $this->options['delete_type']; if ($file->delete_type !== 'DELETE') { $file->delete_url .= '&_method=DELETE'; diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php index c1592b01db3..4b6f6f60939 100644 --- a/htdocs/core/class/fiscalyear.class.php +++ b/htdocs/core/class/fiscalyear.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2014-2020 Alexandre Spangaro * Copyright (C) 2020 OScss-Shop * Copyright (C) 2023-2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -331,7 +332,7 @@ class Fiscalyear extends CommonObject $params = [ 'id' => $this->id, 'objecttype' => $this->element, - 'option', $option, + 'option' => $option, 'nofetch' => 1, ]; $classfortooltip = 'classfortooltip'; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 4fe3995cd65..cee9e9bfafd 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -23,6 +23,7 @@ * Copyright (C) 2018 Josep Lluis Amador * Copyright (C) 2023 Joachim Kueter * Copyright (C) 2023 Nick Fragoulis + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1342,7 +1343,7 @@ class Form } // mode 1 - $urloption = 'htmlname=' . urlencode(str_replace('.', '_', $htmlname)) . '&outjson=1&filter=' . urlencode($filter) . (empty($excludeids) ? '' : '&excludeids=' . implode(',', $excludeids)) . ($showtype ? '&showtype=' . urlencode($showtype) : '') . ($showcode ? '&showcode=' . urlencode($showcode) : ''); + $urloption = 'htmlname=' . urlencode((string) (str_replace('.', '_', $htmlname))) . '&outjson=1&filter=' . urlencode((string) ($filter)) . (empty($excludeids) ? '' : '&excludeids=' . implode(',', $excludeids)) . ($showtype ? '&showtype=' . urlencode((string) ($showtype)) : '') . ($showcode ? '&showcode=' . urlencode((string) ($showcode)) : ''); $out .= ''; if (empty($hidelabel)) { @@ -2812,7 +2813,7 @@ class Form $sql .= " FROM ".$this->db->prefix()."product as p"; // Add from (left join) from hooks - $parameters = array(); + $parameters = array(); // @phan-suppress-current-line PhanPluginRedundantAssignment $reshook = $hookmanager->executeHooks('selectProductsListFrom', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; @@ -2882,7 +2883,7 @@ class Form $sql .= " AND p.fk_product_type = 0"; } // Add where from hooks - $parameters = array(); + $parameters = array(); // @phan-suppress-current-line PhanPluginRedundantAssignment $reshook = $hookmanager->executeHooks('selectProductsListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; // Add criteria on ref/label @@ -3753,13 +3754,8 @@ class Form $outvallabel .= " - " . $reputations[$objp->supplier_reputation]; } } else { - if (empty($alsoproductwithnosupplierprice)) { // No supplier price defined for couple product/supplier - $optlabel .= " - " . $langs->trans("NoPriceDefinedForThisSupplier") . ''; - $outvallabel .= ' - ' . $langs->transnoentities("NoPriceDefinedForThisSupplier"); - } else { // No supplier price defined for product, even on other suppliers - $optlabel .= " - " . $langs->trans("NoPriceDefinedForThisSupplier") . ''; - $outvallabel .= ' - ' . $langs->transnoentities("NoPriceDefinedForThisSupplier"); - } + $optlabel .= " - " . $langs->trans("NoPriceDefinedForThisSupplier") . ''; + $outvallabel .= ' - ' . $langs->transnoentities("NoPriceDefinedForThisSupplier"); } if (isModEnabled('stock') && $showstockinlist && isset($objp->stock) && ($objp->fk_product_type == Product::TYPE_PRODUCT || getDolGlobalString('STOCK_SUPPORTS_SERVICES'))) { @@ -5374,7 +5370,7 @@ class Form $h = isset($input['hours']) ? $input['hours'] : 1; $m = isset($input['minutes']) ? $input['minutes'] : 1; } - $more .= $this->selectDate($input['value'], $input['name'], $h, $m, 0, '', 1, $addnowlink); + $more .= $this->selectDate(isset($input['value']) ? $input['value'] : -1, $input['name'], $h, $m, 0, '', 1, $addnowlink); $more .= ''."\n"; $formquestion[] = array('name' => $input['name'].'day'); $formquestion[] = array('name' => $input['name'].'month'); @@ -6013,7 +6009,7 @@ class Form print ''; print ''; } else { - dol_include_once('/core/lib/company.lib.php'); + require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; print !empty($selected) ? currency_name($selected, 1) : ' '; } } @@ -7847,7 +7843,6 @@ class Form if (!empty($conf->use_javascript_ajax) && getDolGlobalString('TICKET_USE_SEARCH_TO_SELECT')) { $placeholder = ''; - $urloption = ''; if ($selected && empty($selected_input_value)) { require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; @@ -9185,7 +9180,7 @@ class Form } } elseif ($objecttype == 'shipping' || $objecttype == 'shipment' || $objecttype == 'expedition') { $tplpath = 'expedition'; - if (!isModEnabled('delivery_note')) { + if (!isModEnabled('shipping')) { continue; // Do not show if module disabled } } elseif ($objecttype == 'reception') { @@ -9195,8 +9190,8 @@ class Form } } elseif ($objecttype == 'delivery') { $tplpath = 'delivery'; - if (!isModEnabled('delivery_note')) { - continue; // Do not show if module disabled + if (!getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) { + continue; // Do not show if sub module disabled } } elseif ($objecttype == 'ficheinter') { $tplpath = 'fichinter'; @@ -9302,7 +9297,7 @@ class Form 'label' => 'LinkToProposal', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('propal') . ')'), 'shipping' => array( - 'enabled' => isModEnabled('delivery_note'), + 'enabled' => isModEnabled('shipping'), 'perms' => 1, 'label' => 'LinkToExpedition', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "expedition as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('shipping') . ')'), @@ -9496,7 +9491,7 @@ class Form '; } else { - $linktoelem = ''; + $linktoelem = ''; // @phan-suppress-current-line PhanPluginRedundantAssignment } if (!empty($conf->use_javascript_ajax)) { @@ -9685,8 +9680,8 @@ class Form $stringforfirstkey .= ' CTL +'; } - $previous_ref = $object->ref_previous ? '' : ''; - $next_ref = $object->ref_next ? '' : ''; + $previous_ref = $object->ref_previous ? '' : ''; + $next_ref = $object->ref_next ? '' : ''; } //print "xx".$previous_ref."x".$next_ref; @@ -9700,8 +9695,8 @@ class Form if ($previous_ref || $next_ref || $morehtml) { $ret .= '\n"; } - $parameters = array('socid'=>(isset($GLOBALS['socid']) ? $GLOBALS['socid'] : ''), 'id'=>(isset($GLOBALS['id']) ? $GLOBALS['id'] : ''), 'url'=>$url, 'perm'=>$perm, 'options'=>$options); + $parameters = array('socid' => (isset($GLOBALS['socid']) ? $GLOBALS['socid'] : ''), 'id' => (isset($GLOBALS['id']) ? $GLOBALS['id'] : ''), 'url' => $url, 'perm' => $perm, 'options' => $options); $res = $hookmanager->executeHooks('formattachOptions', $parameters, $object); if (empty($res)) { $out = '
'.$out.'
'; @@ -349,23 +350,23 @@ class FormFile $reshook = 0; if (is_object($hookmanager)) { $parameters = array( - 'modulepart'=>&$modulepart, - 'modulesubdir'=>&$modulesubdir, - 'filedir'=>&$filedir, - 'urlsource'=>&$urlsource, - 'genallowed'=>&$genallowed, - 'delallowed'=>&$delallowed, - 'modelselected'=>&$modelselected, - 'allowgenifempty'=>&$allowgenifempty, - 'forcenomultilang'=>&$forcenomultilang, - 'noform'=>&$noform, - 'param'=>&$param, - 'title'=>&$title, - 'buttonlabel'=>&$buttonlabel, - 'codelang'=>&$codelang, - 'morepicto'=>&$morepicto, - 'hideifempty'=>&$hideifempty, - 'removeaction'=>&$removeaction + 'modulepart' => &$modulepart, + 'modulesubdir' => &$modulesubdir, + 'filedir' => &$filedir, + 'urlsource' => &$urlsource, + 'genallowed' => &$genallowed, + 'delallowed' => &$delallowed, + 'modelselected' => &$modelselected, + 'allowgenifempty' => &$allowgenifempty, + 'forcenomultilang' => &$forcenomultilang, + 'noform' => &$noform, + 'param' => &$param, + 'title' => &$title, + 'buttonlabel' => &$buttonlabel, + 'codelang' => &$codelang, + 'morepicto' => &$morepicto, + 'hideifempty' => &$hideifempty, + 'removeaction' => &$removeaction ); $reshook = $hookmanager->executeHooks('showDocuments', $parameters, $object); // Note that parameters may have been updated by hook // May report error @@ -593,7 +594,7 @@ class FormFile } else { include_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php'; //$modellist = ModeleExports::liste_modeles($this->db); // liste_modeles() does not exists. We are using listOfAvailableExportFormat() method instead that return a different array format. - $modellist = array(); + $modellist = array(); // @phan-suppress-current-line PhanPluginRedundantAssignment } } elseif ($modulepart == 'commande_fournisseur' || $modulepart == 'supplier_order') { if (is_array($genallowed)) { @@ -713,7 +714,7 @@ class FormFile $out .= '
'; $addcolumforpicto = ($delallowed || $printer || $morepicto); $colspan = (4 + ($addcolumforpicto ? 1 : 0)); - $colspanmore = 0; + $colspanmore = 0; // @phan-suppress-current-line PhanPluginRedundantAssignment $out .= ''; // Execute hooks - $parameters = array('colspan'=>($colspan + $colspanmore), 'socid'=>(isset($GLOBALS['socid']) ? $GLOBALS['socid'] : ''), 'id'=>(isset($GLOBALS['id']) ? $GLOBALS['id'] : ''), 'modulepart'=>$modulepart); + $parameters = array('colspan' => ($colspan + $colspanmore), 'socid' => (isset($GLOBALS['socid']) ? $GLOBALS['socid'] : ''), 'id' => (isset($GLOBALS['id']) ? $GLOBALS['id'] : ''), 'modulepart' => $modulepart); if (is_object($hookmanager)) { $reshook = $hookmanager->executeHooks('formBuilddocOptions', $parameters, $GLOBALS['object']); $out .= $hookmanager->resPrint; @@ -967,7 +968,7 @@ class FormFile $addcolumforpicto = ($delallowed || $printer || $morepicto); $colspan = (4 + ($addcolumforpicto ? 1 : 0)); $colspanmore = 0; - $parameters = array('colspan'=>($colspan + $colspanmore), 'socid'=>(isset($GLOBALS['socid']) ? $GLOBALS['socid'] : ''), 'id'=>(isset($GLOBALS['id']) ? $GLOBALS['id'] : ''), 'modulepart'=>$modulepart, 'relativepath'=>$relativepath); + $parameters = array('colspan' => ($colspan + $colspanmore), 'socid' => (isset($GLOBALS['socid']) ? $GLOBALS['socid'] : ''), 'id' => (isset($GLOBALS['id']) ? $GLOBALS['id'] : ''), 'modulepart' => $modulepart, 'relativepath' => $relativepath); $res = $hookmanager->executeHooks('formBuilddocLineOptions', $parameters, $file); if (empty($res)) { $out .= $hookmanager->resPrint; // Complete line @@ -1056,7 +1057,7 @@ class FormFile include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $out = ''; - $this->infofiles = array('nboffiles'=>0, 'extensions'=>array(), 'files'=>array()); + $this->infofiles = array('nboffiles' => 0, 'extensions' => array(), 'files' => array()); $entity = 1; // Without multicompany @@ -1230,7 +1231,7 @@ class FormFile $hookmanager->initHooks(array('formfile')); $parameters = array( 'filearray' => $filearray, - 'modulepart'=> $modulepart, + 'modulepart' => $modulepart, 'param' => $param, 'forcedownload' => $forcedownload, 'relativepath' => $relativepath, // relative filename to module dir @@ -1775,7 +1776,7 @@ class FormFile include_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; $object_instance = new Mo($this->db); } else { - $parameters = array('modulepart'=>$modulepart); + $parameters = array('modulepart' => $modulepart); $reshook = $hookmanager->executeHooks('addSectionECMAuto', $parameters); if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray) > 0) { if (array_key_exists('classpath', $hookmanager->resArray) && !empty($hookmanager->resArray['classpath'])) { @@ -1859,7 +1860,7 @@ class FormFile preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = (isset($reg[1]) ? $reg[1] : ''); } else { - $parameters = array('modulepart'=>$modulepart, 'fileinfo'=>$file); + $parameters = array('modulepart' => $modulepart, 'fileinfo' => $file); $reshook = $hookmanager->executeHooks('addSectionECMAuto', $parameters); if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray) > 0) { if (array_key_exists('ref', $hookmanager->resArray) && !empty($hookmanager->resArray['ref'])) { diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 8c998f0cc50..7557a9d89ce 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -7,6 +7,7 @@ * Copyright (C) 2018-2022 Frédéric France * Copyright (C) 2022 Charlene Benke * Copyright (C) 2023 Anthony Berton + * Copyright (C) 2024 MDW * * * This program is free software; you can redistribute it and/or modify @@ -137,17 +138,17 @@ class FormMail extends Form public $witherrorsto; /** - * @var int 0=No attaches files, 1=Show attached files, 2=Can add new attached files + * @var int|string 0=No attaches files, 1=Show attached files, 2=Can add new attached files, 'text'=Show attached files and the text */ public $withfile; /** - * @var int 1=Add a button "Fill with layout" + * @var int 1=Add a button "Fill with layout" */ public $withlayout; /** - * @var int 1=Add a button "Fill with AI generation" + * @var string 'text' or 'html' to add a button "Fill with AI generation" */ public $withaiprompt; @@ -350,7 +351,7 @@ class FormMail extends Form if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) { $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]); } - return array('paths'=>$listofpaths, 'names'=>$listofnames, 'mimes'=>$listofmimes); + return array('paths' => $listofpaths, 'names' => $listofnames, 'mimes' => $listofmimes); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -407,8 +408,8 @@ class FormMail extends Form $parameters = array( 'addfileaction' => $addfileaction, - 'removefileaction'=> $removefileaction, - 'trackid'=> $this->trackid + 'removefileaction' => $removefileaction, + 'trackid' => $this->trackid ); $reshook = $hookmanager->executeHooks('getFormMail', $parameters, $this); @@ -599,7 +600,7 @@ class FormMail extends Form && !preg_match('/user_aliases/', $this->fromtype) && !preg_match('/global_aliases/', $this->fromtype) && !preg_match('/senderprofile/', $this->fromtype) - ) { + ) { // Use this->fromname and this->frommail or error if not defined $out .= $this->fromname; if ($this->frommail) { @@ -910,7 +911,6 @@ class FormMail extends Form } // Complete substitution array with the url to make online payment - $paymenturl = ''; $validpaymentmethod = array(); if (empty($this->substit['__REF__'])) { $paymenturl = ''; @@ -1051,7 +1051,7 @@ class FormMail extends Form $out .= $this->getModelEmailTemplate(); } if ($this->withaiprompt && isModEnabled('ai')) { - $out .= $this->getSectionForAIPrompt(); + $out .= $this->getSectionForAIPrompt($this->withaiprompt); } $out .= ''; $out .= ''; @@ -1187,7 +1187,7 @@ class FormMail extends Form $tmparray[$key]['label'] = $label; $tmparray[$key]['label'] = str_replace(array('<', '>'), array('(', ')'), $tmparray[$key]['label']); // multiselect array convert html entities into options tags, even if we don't want this, so we encode them a second time - $tmparray[$key]['label'] = dol_htmlentities($tmparray[$key]['label'], ENT_QUOTES|ENT_SUBSTITUTE, 'UTF-8', true); + $tmparray[$key]['label'] = dol_htmlentities($tmparray[$key]['label'], ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8', true); $tmparray[$key]['labelhtml'] = $label; $tmparray[$key]['labelhtml'] = str_replace(array('<', '<', '>', '>'), array('__LTCHAR__', '__LTCHAR__', '__GTCHAR__', '__GTCHAR__'), $tmparray[$key]['labelhtml']); @@ -1240,7 +1240,7 @@ class FormMail extends Form $tmparray[$key]['label'] = $label; $tmparray[$key]['label'] = str_replace(array('<', '>'), array('(', ')'), $tmparray[$key]['label']); // multiselect array convert html entities into options tags, even if we don't want this, so we encode them a second time - $tmparray[$key]['label'] = dol_htmlentities($tmparray[$key]['label'], ENT_QUOTES|ENT_SUBSTITUTE, 'UTF-8', true); + $tmparray[$key]['label'] = dol_htmlentities($tmparray[$key]['label'], ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8', true); $tmparray[$key]['labelhtml'] = $label; $tmparray[$key]['labelhtml'] = str_replace(array('<', '<', '>', '>'), array('__LTCHAR__', '__LTCHAR__', '__GTCHAR__', '__GTCHAR__'), $tmparray[$key]['labelhtml']); @@ -1289,7 +1289,7 @@ class FormMail extends Form $tmparray[$key]['label'] = $label; $tmparray[$key]['label'] = str_replace(array('<', '>'), array('(', ')'), $tmparray[$key]['label']); // multiselect array convert html entities into options tags, even if we don't want this, so we encode them a second time - $tmparray[$key]['label'] = dol_htmlentities($tmparray[$key]['label'], ENT_QUOTES|ENT_SUBSTITUTE, 'UTF-8', true); + $tmparray[$key]['label'] = dol_htmlentities($tmparray[$key]['label'], ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8', true); $tmparray[$key]['labelhtml'] = $label; $tmparray[$key]['labelhtml'] = str_replace(array('<', '<', '>', '>'), array('__LTCHAR__', '__LTCHAR__', '__GTCHAR__', '__GTCHAR__'), $tmparray[$key]['labelhtml']); @@ -1399,7 +1399,7 @@ class FormMail extends Form } /** - * get Html For Topic of message + * Return Html section for the Topic of message * * @param array $arraydefaultmessage Array with message template content * @param string $helpforsubstitution Help string for substitution @@ -1437,11 +1437,12 @@ class FormMail extends Form } /** - * Return Html code for AI instruction of message + * Return Html code for AI instruction of message and autofill result * - * @return string Text for instructions + * @param string $format Format for output ('', 'html', ...) + * @return string HTML code to ask AI instruction and autofill result */ - public function getSectionForAIPrompt() + public function getSectionForAIPrompt($format = '') { global $langs; @@ -1453,9 +1454,9 @@ class FormMail extends Form $out .= '\n"; - $out .= "trans('TotalTTC')."'.substring(0,20);"; - echo "line1=line1.padEnd(20);"; - echo "var line2='".price($invoice->total_ttc, 1, '', 1, -1, -1)."'.substring(0,20);"; - echo "line2=line2.padEnd(20);"; - echo "$.ajax({ + echo "var line1='".$langs->trans('TotalTTC')."'.substring(0,20);"; + echo "line1=line1.padEnd(20);"; + echo "var line2='".price($invoice->total_ttc, 1, '', 1, -1, -1)."'.substring(0,20);"; + echo "line2=line2.padEnd(20);"; + echo "$.ajax({ type: 'GET', data: { text: line1+line2 }, url: '".getDolGlobalString('TAKEPOS_PRINT_SERVER')."/display/index.php', @@ -553,7 +553,7 @@ if (isModEnabled('multicurrency') && $_SESSION["takeposcustomercurrency"] != ""
trans("Received"); ?>: multicurrency_code); + echo price(0, 1, '', 1, -1, -1, $invoice->multicurrency_code); if ($showothercurrency) { print '   (' . price(0 * $multicurrency->rate->rate) . ' ' . $_SESSION["takeposcustomercurrency"] . ')'; } @@ -561,7 +561,7 @@ if (isModEnabled('multicurrency') && $_SESSION["takeposcustomercurrency"] != ""
trans("Change"); ?>: multicurrency_code); + echo price(0, 1, '', 1, -1, -1, $invoice->multicurrency_code); if ($showothercurrency) { print '   (' . price(0 * $multicurrency->rate->rate) . ' ' . $_SESSION["takeposcustomercurrency"] . ')'; } @@ -583,18 +583,18 @@ if (isModEnabled('multicurrency') && $_SESSION["takeposcustomercurrency"] != ""
"reset()", - "span" => "style='font-size: 150%;'", - "text" => "C", - "class" => "poscolorblue" - ), - array( - "function" => "parent.$.colorbox.close();", - "span" => "id='printtext' style='font-weight: bold; font-size: 18pt;'", - "text" => "X", - "class" => "poscolordelete" - ), +array( + "function" => "reset()", + "span" => "style='font-size: 150%;'", + "text" => "C", + "class" => "poscolorblue" +), +array( + "function" => "parent.$.colorbox.close();", + "span" => "id='printtext' style='font-weight: bold; font-size: 18pt;'", + "text" => "X", + "class" => "poscolordelete" +), ); $numpad = getDolGlobalString('TAKEPOS_NUMPAD'); if (isModEnabled('stripe') && isset($keyforstripeterminalbank) && getDolGlobalString('STRIPE_CARD_PRESENT')) { @@ -748,7 +748,7 @@ if (getDolGlobalString('TAKEPOS_DELAYED_PAYMENT')) { executeHooks('completePayment', $parameters, $invoice); print $hookmanager->resPrint; ?> diff --git a/htdocs/ticket/class/cticketcategory.class.php b/htdocs/ticket/class/cticketcategory.class.php index 1bc4f15c5bf..820cc281c89 100644 --- a/htdocs/ticket/class/cticketcategory.class.php +++ b/htdocs/ticket/class/cticketcategory.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2017 Laurent Destailleur * Copyright (C) ---Put here your own copyright and developer email--- * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -97,7 +98,7 @@ class CTicketCategory extends CommonObject // BEGIN MODULEBUILDER PROPERTIES /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 10), diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 4980565b264..778bd6ef730 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -6,6 +6,7 @@ * Copyright (C) 2023 Charlene Benke * Copyright (C) 2023 Benjamin Falière * Copyright (C) 2024 William Mead + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -319,37 +320,37 @@ class Ticket extends CommonObject // BEGIN MODULEBUILDER PROPERTIES public $fields = array( - 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id"), - 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>5, 'notnull'=>1, 'index'=>1), - 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'css'=>'', 'showoncombobox'=>1), - 'track_id' => array('type'=>'varchar(255)', 'label'=>'TicketTrackId', 'visible'=>-2, 'enabled'=>1, 'position'=>11, 'notnull'=>-1, 'searchall'=>1, 'help'=>"Help text"), - 'fk_user_create' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Author', 'visible'=>1, 'enabled'=>1, 'position'=>15, 'notnull'=>1, 'csslist'=>'tdoverflowmax100 maxwidth150onsmartphone'), - 'origin_email' => array('type'=>'mail', 'label'=>'OriginEmail', 'visible'=>-2, 'enabled'=>1, 'position'=>16, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'csslist'=>'tdoverflowmax150'), - 'origin_replyto' => array('type'=>'mail', 'label'=>'EmailReplyto', 'visible'=>-2, 'enabled'=>1, 'position'=>17, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Email to reply to", 'csslist'=>'tdoverflowmax150'), - 'subject' => array('type'=>'varchar(255)', 'label'=>'Subject', 'visible'=>1, 'enabled'=>1, 'position'=>18, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth200 tdoverflowmax200', 'autofocusoncreate'=>1), - 'type_code' => array('type'=>'varchar(32)', 'label'=>'Type', 'visible'=>1, 'enabled'=>1, 'position'=>20, 'notnull'=>-1, 'help'=>"", 'csslist'=>'maxwidth125 tdoverflowmax50'), - 'category_code' => array('type'=>'varchar(32)', 'label'=>'TicketCategory', 'visible'=>-1, 'enabled'=>1, 'position'=>21, 'notnull'=>-1, 'help'=>"", 'css'=>'maxwidth100 tdoverflowmax200'), - 'severity_code' => array('type'=>'varchar(32)', 'label'=>'Severity', 'visible'=>1, 'enabled'=>1, 'position'=>22, 'notnull'=>-1, 'help'=>"", 'css'=>'maxwidth100'), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>'isModEnabled("societe")', 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"OrganizationEventLinkToThirdParty", 'css'=>'tdoverflowmax150 maxwidth150onsmartphone'), - 'notify_tiers_at_create' => array('type'=>'integer', 'label'=>'NotifyThirdparty', 'visible'=>-1, 'enabled'=>0, 'position'=>51, 'notnull'=>1, 'index'=>1), - 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php', 'label'=>'Project', 'visible'=>-1, 'enabled'=>'$conf->project->enabled', 'position'=>52, 'notnull'=>-1, 'index'=>1, 'help'=>"LinkToProject"), - 'fk_contract' => array('type'=>'integer:Contrat:contrat/class/contrat.class.php', 'label'=>'Contract', 'visible'=>-1, 'enabled'=>'$conf->contract->enabled', 'position'=>53, 'notnull'=>-1, 'index'=>1, 'help'=>"LinkToContract"), + 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'visible' => -2, 'enabled' => 1, 'position' => 1, 'notnull' => 1, 'index' => 1, 'comment' => "Id"), + 'entity' => array('type' => 'integer', 'label' => 'Entity', 'visible' => 0, 'enabled' => 1, 'position' => 5, 'notnull' => 1, 'index' => 1), + 'ref' => array('type' => 'varchar(128)', 'label' => 'Ref', 'visible' => 1, 'enabled' => 1, 'position' => 10, 'notnull' => 1, 'index' => 1, 'searchall' => 1, 'comment' => "Reference of object", 'css' => '', 'showoncombobox' => 1), + 'track_id' => array('type' => 'varchar(255)', 'label' => 'TicketTrackId', 'visible' => -2, 'enabled' => 1, 'position' => 11, 'notnull' => -1, 'searchall' => 1, 'help' => "Help text"), + 'fk_user_create' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'Author', 'visible' => 1, 'enabled' => 1, 'position' => 15, 'notnull' => 1, 'csslist' => 'tdoverflowmax100 maxwidth150onsmartphone'), + 'origin_email' => array('type' => 'mail', 'label' => 'OriginEmail', 'visible' => -2, 'enabled' => 1, 'position' => 16, 'notnull' => 1, 'index' => 1, 'searchall' => 1, 'comment' => "Reference of object", 'csslist' => 'tdoverflowmax150'), + 'origin_replyto' => array('type' => 'mail', 'label' => 'EmailReplyto', 'visible' => -2, 'enabled' => 1, 'position' => 17, 'notnull' => 1, 'index' => 1, 'searchall' => 1, 'comment' => "Email to reply to", 'csslist' => 'tdoverflowmax150'), + 'subject' => array('type' => 'varchar(255)', 'label' => 'Subject', 'visible' => 1, 'enabled' => 1, 'position' => 18, 'notnull' => -1, 'searchall' => 1, 'help' => "", 'css' => 'maxwidth200 tdoverflowmax200', 'autofocusoncreate' => 1), + 'type_code' => array('type' => 'varchar(32)', 'label' => 'Type', 'visible' => 1, 'enabled' => 1, 'position' => 20, 'notnull' => -1, 'help' => "", 'csslist' => 'maxwidth125 tdoverflowmax50'), + 'category_code' => array('type' => 'varchar(32)', 'label' => 'TicketCategory', 'visible' => -1, 'enabled' => 1, 'position' => 21, 'notnull' => -1, 'help' => "", 'css' => 'maxwidth100 tdoverflowmax200'), + 'severity_code' => array('type' => 'varchar(32)', 'label' => 'Severity', 'visible' => 1, 'enabled' => 1, 'position' => 22, 'notnull' => -1, 'help' => "", 'css' => 'maxwidth100'), + 'fk_soc' => array('type' => 'integer:Societe:societe/class/societe.class.php', 'label' => 'ThirdParty', 'visible' => 1, 'enabled' => 'isModEnabled("societe")', 'position' => 50, 'notnull' => -1, 'index' => 1, 'searchall' => 1, 'help' => "OrganizationEventLinkToThirdParty", 'css' => 'tdoverflowmax150 maxwidth150onsmartphone'), + 'notify_tiers_at_create' => array('type' => 'integer', 'label' => 'NotifyThirdparty', 'visible' => -1, 'enabled' => 0, 'position' => 51, 'notnull' => 1, 'index' => 1), + 'fk_project' => array('type' => 'integer:Project:projet/class/project.class.php', 'label' => 'Project', 'visible' => -1, 'enabled' => '$conf->project->enabled', 'position' => 52, 'notnull' => -1, 'index' => 1, 'help' => "LinkToProject"), + 'fk_contract' => array('type' => 'integer:Contrat:contrat/class/contrat.class.php', 'label' => 'Contract', 'visible' => -1, 'enabled' => '$conf->contract->enabled', 'position' => 53, 'notnull' => -1, 'index' => 1, 'help' => "LinkToContract"), //'timing' => array('type'=>'varchar(20)', 'label'=>'Timing', 'visible'=>-1, 'enabled'=>1, 'position'=>42, 'notnull'=>-1, 'help'=>""), // what is this ? - 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>1, 'enabled'=>1, 'position'=>500, 'notnull'=>1, 'csslist'=>'nowraponall'), - 'date_read' => array('type'=>'datetime', 'label'=>'TicketReadOn', 'visible'=>-1, 'enabled'=>1, 'position'=>501, 'notnull'=>1, 'csslist'=>'nowraponall'), - 'date_last_msg_sent' => array('type'=>'datetime', 'label'=>'TicketLastMessageDate', 'visible'=>0, 'enabled'=>1, 'position'=>502, 'notnull'=>-1), - 'fk_user_assign' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'AssignedTo', 'visible'=>1, 'enabled'=>1, 'position'=>505, 'notnull'=>1, 'csslist'=>'tdoverflowmax100 maxwidth150onsmartphone'), - 'date_close' => array('type'=>'datetime', 'label'=>'TicketCloseOn', 'visible'=>-1, 'enabled'=>1, 'position'=>510, 'notnull'=>1), - 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-1, 'enabled'=>1, 'position'=>520, 'notnull'=>1), - 'message' => array('type'=>'html', 'label'=>'Message', 'visible'=>-2, 'enabled'=>1, 'position'=>540, 'notnull'=>-1,), - 'email_msgid' => array('type'=>'varchar(255)', 'label'=>'EmailMsgID', 'visible'=>-2, 'enabled'=>1, 'position'=>540, 'notnull'=>-1, 'help'=>'EmailMsgIDDesc', 'csslist'=>'tdoverflowmax100'), - 'email_date' => array('type'=>'datetime', 'label'=>'EmailDate', 'visible'=>-2, 'enabled'=>1, 'position'=>541), - 'progress' => array('type'=>'integer', 'label'=>'Progression', 'visible'=>-1, 'enabled'=>1, 'position'=>540, 'notnull'=>-1, 'css'=>'right', 'help'=>"", 'isameasure'=>2, 'csslist'=>'width50'), - 'resolution' => array('type'=>'integer', 'label'=>'Resolution', 'visible'=>-1, 'enabled'=>'getDolGlobalString("TICKET_ENABLE_RESOLUTION")', 'position'=>550, 'notnull'=>1), - 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'PDFTemplate', 'enabled'=>1, 'visible'=>0, 'position'=>560), - 'extraparams' =>array('type'=>'varchar(255)', 'label'=>'Extraparams', 'enabled'=>1, 'visible'=>-1, 'position'=>570), - 'fk_statut' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>600, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array(0 => 'Unread', 1 => 'Read', 2 => 'Assigned', 3 => 'InProgress', 5 => 'NeedMoreInformation', 7 => 'OnHold', 8 => 'SolvedClosed', 9 => 'Deleted')), - 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>900), + 'datec' => array('type' => 'datetime', 'label' => 'DateCreation', 'visible' => 1, 'enabled' => 1, 'position' => 500, 'notnull' => 1, 'csslist' => 'nowraponall'), + 'date_read' => array('type' => 'datetime', 'label' => 'TicketReadOn', 'visible' => -1, 'enabled' => 1, 'position' => 501, 'notnull' => 1, 'csslist' => 'nowraponall'), + 'date_last_msg_sent' => array('type' => 'datetime', 'label' => 'TicketLastMessageDate', 'visible' => 0, 'enabled' => 1, 'position' => 502, 'notnull' => -1), + 'fk_user_assign' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'AssignedTo', 'visible' => 1, 'enabled' => 1, 'position' => 505, 'notnull' => 1, 'csslist' => 'tdoverflowmax100 maxwidth150onsmartphone'), + 'date_close' => array('type' => 'datetime', 'label' => 'TicketCloseOn', 'visible' => -1, 'enabled' => 1, 'position' => 510, 'notnull' => 1), + 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'visible' => -1, 'enabled' => 1, 'position' => 520, 'notnull' => 1), + 'message' => array('type' => 'html', 'label' => 'Message', 'visible' => -2, 'enabled' => 1, 'position' => 540, 'notnull' => -1,), + 'email_msgid' => array('type' => 'varchar(255)', 'label' => 'EmailMsgID', 'visible' => -2, 'enabled' => 1, 'position' => 540, 'notnull' => -1, 'help' => 'EmailMsgIDDesc', 'csslist' => 'tdoverflowmax100'), + 'email_date' => array('type' => 'datetime', 'label' => 'EmailDate', 'visible' => -2, 'enabled' => 1, 'position' => 541), + 'progress' => array('type' => 'integer', 'label' => 'Progression', 'visible' => -1, 'enabled' => 1, 'position' => 540, 'notnull' => -1, 'css' => 'right', 'help' => "", 'isameasure' => 2, 'csslist' => 'width50'), + 'resolution' => array('type' => 'integer', 'label' => 'Resolution', 'visible' => -1, 'enabled' => 'getDolGlobalString("TICKET_ENABLE_RESOLUTION")', 'position' => 550, 'notnull' => 1), + 'model_pdf' => array('type' => 'varchar(255)', 'label' => 'PDFTemplate', 'enabled' => 1, 'visible' => 0, 'position' => 560), + 'extraparams' => array('type' => 'varchar(255)', 'label' => 'Extraparams', 'enabled' => 1, 'visible' => -1, 'position' => 570), + 'fk_statut' => array('type' => 'integer', 'label' => 'Status', 'visible' => 1, 'enabled' => 1, 'position' => 600, 'notnull' => 1, 'index' => 1, 'arrayofkeyval' => array(0 => 'Unread', 1 => 'Read', 2 => 'Assigned', 3 => 'InProgress', 5 => 'NeedMoreInformation', 7 => 'OnHold', 8 => 'SolvedClosed', 9 => 'Deleted')), + 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'visible' => -2, 'position' => 900), ); // END MODULEBUILDER PROPERTIES @@ -782,16 +783,16 @@ class Ticket extends CommonObject /** * Load all objects in memory from database * - * @param User $user User for action - * @param string $sortorder Sort order - * @param string $sortfield Sort field - * @param int $limit page number - * @param int $offset Offset for query - * @param int $arch archive or not (not used) - * @param array $filter Filter for query - * @return int Return integer <0 if KO, >0 if OK + * @param User $user User for action + * @param string $sortorder Sort order + * @param string $sortfield Sort field + * @param int $limit Limit + * @param int $offset Offset page + * @param int $arch Archive or not (not used) + * @param string|array $filter Filter for query + * @return int Return integer <0 if KO, >0 if OK */ - public function fetchAll($user, $sortorder = 'ASC', $sortfield = 't.datec', $limit = 0, $offset = 0, $arch = 0, $filter = []) + public function fetchAll($user, $sortorder = 'ASC', $sortfield = 't.datec', $limit = 0, $offset = 0, $arch = 0, $filter = '') { global $langs, $extrafields; @@ -825,7 +826,7 @@ class Ticket extends CommonObject $sql .= " t.tms,"; $sql .= " type.label as type_label, category.label as category_label, severity.label as severity_label"; // Add fields for extrafields - if ($extrafields->attributes[$this->table_element]['count']> 0) { + if ($extrafields->attributes[$this->table_element]['count'] > 0) { foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) { $sql .= ($extrafields->attributes[$this->table_element]['type'][$key] != 'separate' ? ",ef.".$key." as options_".$key : ''); } @@ -837,7 +838,7 @@ class Ticket extends CommonObject $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as uc ON uc.rowid = t.fk_user_create"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as ua ON ua.rowid = t.fk_user_assign"; - if ($extrafields->attributes[$this->table_element]['count']> 0) { + if ($extrafields->attributes[$this->table_element]['count'] > 0) { if (is_array($extrafields->attributes[$this->table_element]['label']) && count($extrafields->attributes[$this->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."ticket_extrafields as ef on (t.rowid = ef.fk_object)"; } @@ -845,7 +846,7 @@ class Ticket extends CommonObject $sql .= " WHERE t.entity IN (".getEntity('ticket').")"; // Manage filter - if (!empty($filter)) { + if (is_array($filter)) { foreach ($filter as $key => $value) { if (strpos($key, 'date')) { // To allow $filter['YEAR(s.dated)']=>$year $sql .= " AND ".$this->db->sanitize($key)." = '".$this->db->escape($value)."'"; @@ -863,6 +864,17 @@ class Ticket extends CommonObject $sql .= " AND ".$this->db->sanitize($key)." LIKE '%".$this->db->escape($this->db->escapeforlike($value))."%'"; } } + + $filter = ''; + } + + // Manage filter + $errormessage = ''; + $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage); + if ($errormessage) { + $this->errors[] = $errormessage; + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); + return -1; } // Case of external user @@ -943,7 +955,7 @@ class Ticket extends CommonObject $line->date_close = $this->db->jdate($obj->date_close); // Extra fields - if ($extrafields->attributes[$this->table_element]['count']> 0) { + if ($extrafields->attributes[$this->table_element]['count'] > 0) { if (is_array($extrafields->attributes[$this->table_element]['label']) && count($extrafields->attributes[$this->table_element]['label'])) { foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) { $tmpkey = 'options_'.$key; @@ -1470,7 +1482,7 @@ class Ticket extends CommonObject global $langs, $hookmanager; $labelStatus = (isset($status) && !empty($this->labelStatus[$status])) ? $this->labelStatus[$status] : ''; - $labelStatusShort = (isset($status) && !empty($this->labelStatusShort[$status]))? $this->labelStatusShort[$status] : ''; + $labelStatusShort = (isset($status) && !empty($this->labelStatusShort[$status])) ? $this->labelStatusShort[$status] : ''; switch ($status) { case self::STATUS_NOT_READ: // Not read @@ -2359,7 +2371,7 @@ class Ticket extends CommonObject 'libelle' => $labelType, // deprecated, replaced with labeltype 'labeltype' => $labelType, 'status' => $obj->statuslink, - 'statuscontact'=>$obj->statuscontact, + 'statuscontact' => $obj->statuscontact, 'fk_c_type_contact' => $obj->fk_c_type_contact, 'phone' => $obj->phone, 'phone_mobile' => $obj->phone_mobile); @@ -2503,7 +2515,7 @@ class Ticket extends CommonObject $destfile = $destdir.'/'.$pathinfo['filename'].' - '.dol_print_date($now, 'dayhourlog').'.'.$pathinfo['extension']; } - $moreinfo = array('description'=>'File saved by copyFilesForTicket', 'src_object_type' => $this->element, 'src_object_id' => $this->id); + $moreinfo = array('description' => 'File saved by copyFilesForTicket', 'src_object_type' => $this->element, 'src_object_id' => $this->id); $res = dol_move($filepath[$i], $destfile, 0, 1, 0, 1, $moreinfo); if (!$res) { // Move has failed @@ -2529,7 +2541,7 @@ class Ticket extends CommonObject $listofnames[$i] = basename($destfile); } - return array('listofpaths'=>$listofpaths, 'listofnames'=>$listofnames, 'listofmimes'=>$mimetype); + return array('listofpaths' => $listofpaths, 'listofnames' => $listofnames, 'listofmimes' => $mimetype); } /** @@ -3070,7 +3082,7 @@ class Ticket extends CommonObject if ($mode == 'opened') { $status = 'openall'; //$delay_warning = $conf->ticket->warning_delay; - $delay_warning = 0; + $delay_warning = 0; // @phan-suppress-current-line PhanPluginRedundantAssignment $label = $langs->trans("MenuListNonClosed"); $labelShort = $langs->trans("MenuListNonClosed"); } diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 1233793cd7d..4ccef134ea0 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -668,16 +668,16 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook $param .= $hookmanager->resPrint; if ($socid > 0) { - $param .= '&socid='.urlencode($socid); + $param .= '&socid='.urlencode((string) ($socid)); } if ($search_societe) { $param .= '&search_societe='.urlencode($search_societe); } if ($projectid > 0) { - $param .= '&projectid='.urlencode($projectid); + $param .= '&projectid='.urlencode((string) ($projectid)); } if ($contractid > 0) { - $param .= '&contractid='.urlencode($contractid); + $param .= '&contractid='.urlencode((string) ($contractid)); } if ($search_date_start) { $tmparray = dol_getdate($search_date_start); diff --git a/htdocs/user/agenda.php b/htdocs/user/agenda.php index a9887cc577c..229c299a2e7 100644 --- a/htdocs/user/agenda.php +++ b/htdocs/user/agenda.php @@ -89,7 +89,7 @@ if (($object->id != $user->id) && !$user->hasRight('user', 'user', 'lire')) { accessforbidden(); } -$parameters = array('id'=>$userId); +$parameters = array('id' => $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'); @@ -185,7 +185,7 @@ if (isModEnabled('agenda')) { if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allaactions', 'read'))) { print '
'; - $param = '&id='.urlencode($id); + $param = '&id='.urlencode((string) ($id)); if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.((int) $limit); @@ -195,7 +195,7 @@ if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || // Try to know count of actioncomm from cache require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; $cachekey = 'count_events_user_'.$object->id; - //$nbEvent = dol_getcache($cachekey); // TODO Add nb into badge in menu so we can get it from cache also here + $nbEvent = dol_getcache($cachekey); $titlelist = $langs->trans("ActionsOnCompany").(is_numeric($nbEvent) ? '('.$nbEvent.')' : ''); if (!empty($conf->dol_optimize_smallscreen)) { diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 9c074307e31..2b68a23c5c5 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1582,8 +1582,11 @@ if ($action == 'create' || $action == 'adduserldap') { // Employee print '
'."\n"; // TODO This is also available into the tab RH diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index ac40da2c6df..230344118c6 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2020 Thibault FOUCART + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -446,8 +447,6 @@ class Users extends DolibarrApi throw new RestException(403); } - $obj_ret = array(); - $user = new User($this->db); $result = $user->fetch($id); if (!$result) { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 641189725fd..ba8f8116bdf 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -3096,7 +3096,7 @@ class User extends CommonObject if ($option == 'xxx') { $linkstart = ''; - $linkend = ''; + $linkend = ''; // @phan-suppress-current-line PhanPluginRedundantAssignment } if ($option == 'nolink') { diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 48ec6758351..25a188fa8ee 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -8,6 +8,7 @@ * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2019 Abbes Bahfir * Copyright (C) 2023-2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -111,13 +112,13 @@ class UserGroup extends CommonObject public $oldcopy; // To contains a clone of this when we need to save old properties of object public $fields = array( - 'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>5), - 'nom'=>array('type'=>'varchar(180)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Group name'), - 'note' => array('type'=>'html', 'label'=>'Description', 'enabled'=>1, 'visible'=>1, 'position'=>20, 'notnull'=>-1, 'searchall'=>1), - 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>50, 'notnull'=>1,), - 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>60, 'notnull'=>1,), - 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'ModelPDF', 'enabled'=>1, 'visible'=>0, 'position'=>100), + 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'index' => 1, 'position' => 1, 'comment' => 'Id'), + 'entity' => array('type' => 'integer', 'label' => 'Entity', 'enabled' => 1, 'visible' => 0, 'notnull' => 1, 'default' => 1, 'index' => 1, 'position' => 5), + 'nom' => array('type' => 'varchar(180)', 'label' => 'Name', 'enabled' => 1, 'visible' => 1, 'notnull' => 1, 'showoncombobox' => 1, 'index' => 1, 'position' => 10, 'searchall' => 1, 'comment' => 'Group name'), + 'note' => array('type' => 'html', 'label' => 'Description', 'enabled' => 1, 'visible' => 1, 'position' => 20, 'notnull' => -1, 'searchall' => 1), + 'datec' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'visible' => -2, 'position' => 50, 'notnull' => 1,), + 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'visible' => -2, 'position' => 60, 'notnull' => 1,), + 'model_pdf' => array('type' => 'varchar(255)', 'label' => 'ModelPDF', 'enabled' => 1, 'visible' => 0, 'position' => 100), ); /** @@ -126,12 +127,12 @@ class UserGroup extends CommonObject public $fk_element = 'fk_usergroup'; /** - * @var array List of child tables. To test if we can delete object. + * @var array> List of child tables. To test if we can delete object. */ protected $childtables = array(); /** - * @var array List of child tables. To know object to delete on cascade. + * @var string[] List of child tables. To know object to delete on cascade. */ protected $childtablesoncascade = array('usergroup_rights', 'usergroup_user'); @@ -407,7 +408,7 @@ class UserGroup extends CommonObject if (!$error) { $langs->load("other"); - $this->context = array('audit'=>$langs->trans("PermissionsAdd").($rid ? ' (id='.$rid.')' : '')); + $this->context = array('audit' => $langs->trans("PermissionsAdd").($rid ? ' (id='.$rid.')' : '')); // Call trigger $result = $this->call_trigger('USERGROUP_MODIFY', $user); @@ -536,7 +537,7 @@ class UserGroup extends CommonObject if (!$error) { $langs->load("other"); - $this->context = array('audit'=>$langs->trans("PermissionsDelete").($rid ? ' (id='.$rid.')' : '')); + $this->context = array('audit' => $langs->trans("PermissionsDelete").($rid ? ' (id='.$rid.')' : '')); // Call trigger $result = $this->call_trigger('USERGROUP_MODIFY', $user); @@ -860,7 +861,7 @@ class UserGroup extends CommonObject global $action; $hookmanager->initHooks(array('groupdao')); - $parameters = array('id'=>$this->id, 'getnomurl' => &$result); + $parameters = array('id' => $this->id, 'getnomurl' => &$result); $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) { $result = $hookmanager->resPrint; diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php index ab95f1ad25e..328e14910ae 100644 --- a/htdocs/user/ldap.php +++ b/htdocs/user/ldap.php @@ -1,6 +1,7 @@ - * Copyright (C) 2006-2021 Regis Houssin +/* Copyright (C) 2006-2012 Laurent Destailleur + * Copyright (C) 2006-2021 Regis Houssin + * Copyright (C) 2024 William Mead * * 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 @@ -33,7 +34,7 @@ $langs->loadLangs(array('users', 'admin', 'companies', 'ldap')); $id = GETPOSTINT('id'); $action = GETPOST('action', 'aZ09'); -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'userldap'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?: 'userldap'; // To manage different context of search // Security check $socid = 0; @@ -125,6 +126,7 @@ print ''; if (getDolGlobalString('LDAP_SERVER_TYPE') == "activedirectory") { $ldap = new Ldap(); $result = $ldap->connectBind(); + $userSID = ''; if ($result > 0) { $userSID = $ldap->getObjectSid($object->login); } @@ -204,6 +206,7 @@ if ($result > 0) { $ldap->unbind(); } else { + print ''; setEventMessages($ldap->error, $ldap->errors, 'errors'); } diff --git a/htdocs/user/list.php b/htdocs/user/list.php index c7793975b0f..e55dc5ea1bc 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -606,7 +606,7 @@ if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } if ($search_categ > 0) { - $param .= '&search_categ='.urlencode($search_categ); + $param .= '&search_categ='.urlencode((string) ($search_categ)); } if ($search_warehouse > 0) { $param .= '&search_warehouse='.urlencode($search_warehouse); @@ -650,7 +650,7 @@ print ''; $url = DOL_URL_ROOT.'/user/card.php?action=create'.($contextpage == 'employeelist' ? '&search_employee=1' : '').'&leftmenu='; if (!empty($socid)) { - $url .= '&socid='.urlencode($socid); + $url .= '&socid='.urlencode((string) ($socid)); } $newcardbutton = ''; diff --git a/htdocs/user/messaging.php b/htdocs/user/messaging.php index d9db450b985..319a00e9f5e 100644 --- a/htdocs/user/messaging.php +++ b/htdocs/user/messaging.php @@ -6,6 +6,7 @@ * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2010 Juanjo Menent * Copyright (C) 2015 Marcos García + * Copyright (C) 2024 Frédéric France * * 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 @@ -50,6 +51,8 @@ if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } +$id = GETPOSTINT('userid') ? GETPOSTINT('userid') : GETPOSTINT('id'); +$ref = GETPOST('ref', 'alpha'); $search_rowid = GETPOST('search_rowid'); $search_agenda_label = GETPOST('search_agenda_label'); @@ -74,6 +77,9 @@ if (!$sortorder) { $object = new User($db); if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref, '', 1); + if ($result <= 0) { + accessforbidden('User not found'); + } $object->getrights(); } @@ -81,25 +87,24 @@ if ($id > 0 || !empty($ref)) { $hookmanager->initHooks(array('agendathirdparty', 'globalcard')); // Security check -$userid = GETPOSTINT('userid') ? GETPOSTINT('userid') : GETPOSTINT('id'); if ($user->id) { - $userId = $user->id; + $id = $user->id; } -$result = $object->fetch($userid); -if ($result <= 0) { - accessforbidden('User not found'); +// Security check +$socid = 0; +if ($user->socid > 0) { + $socid = $user->socid; } - -$result = restrictedArea($user, 'user', $userId, '&user'); - +$feature2 = (($socid && $user->hasRight('user', 'self', 'creer')) ? '' : 'user'); +$result = restrictedArea($user, 'user', $id, 'user&user', $feature2); /* * Actions */ -$parameters = array('id'=>$socid); +$parameters = array('id' => $socid); $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'); @@ -153,7 +158,7 @@ $morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->tra dol_banner_tab($object, 'id', $linkback, $user->hasRight('user', 'user', 'lire') || $user->admin, 'rowid', 'ref', $morehtmlref); -$object->info($userid); +$object->info($id); print '
'; @@ -196,7 +201,7 @@ if (isModEnabled('agenda')) { if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allaactions', 'read'))) { print '
'; - $param = '&userid='.urlencode($userid); + $param = '&userid='.urlencode((string) ($id)); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -208,7 +213,7 @@ if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || // Try to know count of actioncomm from cache require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; $cachekey = 'count_events_user_'.$object->id; - //$nbEvent = dol_getcache($cachekey); // TODO Add nb into badge in menu so we can get it from cache also here + $nbEvent = dol_getcache($cachekey); // TODO Add nb into badge in menu so we can get it from cache also here $titlelist = $langs->trans("ActionsOnCompany").(is_numeric($nbEvent) ? '('.$nbEvent.')' : ''); if (!empty($conf->dol_optimize_smallscreen)) { diff --git a/htdocs/user/notify/card.php b/htdocs/user/notify/card.php index 8112a219016..240723c47c8 100644 --- a/htdocs/user/notify/card.php +++ b/htdocs/user/notify/card.php @@ -228,11 +228,11 @@ if ($result > 0) { // Add notification form // print load_fiche_titre($langs->trans("AddNewNotification"), '', ''); - print '
'; + print ''; print ''; print ''; - $param = "&id=".urlencode($id); + $param = "&id=".urlencode((string) ($id)); // Line with titles /* print '
'.$langs->trans("Statistics").' - '.$langs->trans("Services").'
'.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).''.($nb[$status.$bool] ? $nb[$status.$bool] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).''.($nb[$status.$bool_str] ? $nb[$status.$bool_str] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).'
'.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).''.($nb[$status.$bool] ? $nb[$status.$bool] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).''.($nb[$status.$bool_str] ? $nb[$status.$bool_str] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).'
'; @@ -816,7 +817,7 @@ class FormFile $out .= '
'; $out .= ''; $out .= ''; + $out .= '
'.$langs->trans("AIProcessingPleaseWait").'
'; $out .= "
'.$langs->trans("Employee").''; - print 'employee ? ' checked="checked"' : '').'>'; - //print yn($object->employee); + if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER') < 2) { + print 'employee ? ' checked="checked"' : '').'>'; + } else { + print yn($object->employee); + } print '
'.$langs->trans("ErrorFailedToReadLDAP").'
'; diff --git a/htdocs/variants/class/ProductAttribute.class.php b/htdocs/variants/class/ProductAttribute.class.php index f0014a0a7ab..b4c16a23b95 100644 --- a/htdocs/variants/class/ProductAttribute.class.php +++ b/htdocs/variants/class/ProductAttribute.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2016 Marcos García * Copyright (C) 2022 Open-Dsi * Copyright (C) 2023 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -97,14 +98,14 @@ class ProductAttribute extends CommonObject * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor. */ /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( - 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), - 'ref' => array('type'=>'varchar(255)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'css'=>'width200'), - 'ref_ext' => array('type' => 'varchar(255)', 'label' => 'ExternalRef', 'enabled' => 1, 'visible' => 0, 'position' => 20, 'searchall'=>1), - 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'help'=>"", 'showoncombobox'=>'1',), - 'position' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'default'=>0, 'position'=>40, 'notnull'=>1,), + public $fields = array( + 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => '1', 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => '1', 'index' => 1, 'css' => 'left', 'comment' => "Id"), + 'ref' => array('type' => 'varchar(255)', 'label' => 'Ref', 'visible' => 1, 'enabled' => 1, 'position' => 10, 'notnull' => 1, 'index' => 1, 'searchall' => 1, 'comment' => "Reference of object", 'css' => 'width200'), + 'ref_ext' => array('type' => 'varchar(255)', 'label' => 'ExternalRef', 'enabled' => 1, 'visible' => 0, 'position' => 20, 'searchall' => 1), + 'label' => array('type' => 'varchar(255)', 'label' => 'Label', 'enabled' => '1', 'position' => 30, 'notnull' => 1, 'visible' => 1, 'searchall' => 1, 'css' => 'minwidth300', 'help' => "", 'showoncombobox' => '1',), + 'position' => array('type' => 'integer', 'label' => 'Rank', 'enabled' => 1, 'visible' => 0, 'default' => 0, 'position' => 40, 'notnull' => 1,), ); /** diff --git a/htdocs/variants/class/ProductAttributeValue.class.php b/htdocs/variants/class/ProductAttributeValue.class.php index 7636df31290..4b04d46a375 100644 --- a/htdocs/variants/class/ProductAttributeValue.class.php +++ b/htdocs/variants/class/ProductAttributeValue.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2022 Open-Dsi + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -75,14 +76,14 @@ class ProductAttributeValue extends CommonObjectLine * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor. */ /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( - 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), - 'fk_product_attribute' => array('type'=>'integer:ProductAttribute:variants/class/ProductAttribute.class.php', 'label'=>'ProductAttribute', 'enabled'=>1, 'visible'=>0, 'position'=>10, 'notnull'=>1, 'index'=>1,), - 'ref' => array('type'=>'varchar(255)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'css'=>''), - 'value' => array('type'=>'varchar(255)', 'label'=>'Value', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'help'=>"", 'showoncombobox'=>'1',), - 'position' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'default'=>0, 'position'=>200, 'notnull'=>1,), + public $fields = array( + 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => '1', 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => '1', 'index' => 1, 'css' => 'left', 'comment' => "Id"), + 'fk_product_attribute' => array('type' => 'integer:ProductAttribute:variants/class/ProductAttribute.class.php', 'label' => 'ProductAttribute', 'enabled' => 1, 'visible' => 0, 'position' => 10, 'notnull' => 1, 'index' => 1,), + 'ref' => array('type' => 'varchar(255)', 'label' => 'Ref', 'visible' => 1, 'enabled' => 1, 'position' => 20, 'notnull' => 1, 'index' => 1, 'searchall' => 1, 'comment' => "Reference of object", 'css' => ''), + 'value' => array('type' => 'varchar(255)', 'label' => 'Value', 'enabled' => '1', 'position' => 30, 'notnull' => 1, 'visible' => 1, 'searchall' => 1, 'css' => 'minwidth300', 'help' => "", 'showoncombobox' => '1',), + 'position' => array('type' => 'integer', 'label' => 'Rank', 'enabled' => 1, 'visible' => 0, 'default' => 0, 'position' => 200, 'notnull' => 1,), ); public $id; public $fk_product_attribute; diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 25d69eaeac9..ef23ce4857d 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2016 Marcos García * Copyright (C) 2018 Juanjo Menent * Copyright (C) 2022 Open-Dsi + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -292,13 +293,13 @@ class ProductCombination global $conf; $sql = "SELECT pac.rowid, pac.fk_product_parent, pac.fk_product_child, pac.variation_price, pac.variation_price_percentage, pac.variation_ref_ext, pac.variation_weight"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_attribute_combination AS pac"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_attribute_combination AS pac"; if ($sort_by_ref) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product AS p ON p.rowid = pac.fk_product_child"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product AS p ON p.rowid = pac.fk_product_child"; } - $sql.= " WHERE pac.fk_product_parent = ".((int) $fk_product_parent)." AND pac.entity IN (".getEntity('product').")"; + $sql .= " WHERE pac.fk_product_parent = ".((int) $fk_product_parent)." AND pac.entity IN (".getEntity('product').")"; if ($sort_by_ref) { - $sql.= $this->db->order('p.ref', 'ASC'); + $sql .= $this->db->order('p.ref', 'ASC'); } $query = $this->db->query($sql); @@ -614,7 +615,7 @@ class ProductCombination * Retrieves the combination that matches the given features. * * @param int $prodid Id of parent product - * @param array $features Format: [$attr] => $attr_val + * @param array $features Format: [$attr] => $attr_val * @return false|ProductCombination False if not found */ public function fetchByProductCombination2ValuePairs($prodid, array $features) @@ -626,9 +627,15 @@ class ProductCombination $prodcomb2val = new ProductCombination2ValuePair($this->db); $prodcomb = new ProductCombination($this->db); - $features = array_filter($features, function ($v) { - return !empty($v); - }); + $features = array_filter( + $features, + /** + * @param mixed $v Feature information of a product. + */ + static function ($v) { + return !empty($v); + } + ); foreach ($features as $attr => $attr_val) { $actual_comp[$attr] = $attr_val; @@ -729,7 +736,7 @@ class ProductCombination $this->db->begin(); - $price_impact = array(1=>0); // init level price impact + $price_impact = array(1 => 0); // init level price impact $forced_refvar = trim($forced_refvar); diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index e34cf104d40..905e915dfbb 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -117,7 +117,7 @@ if ($action == 'create' && GETPOST('selectvariant', 'alpha')) { // We click on s $action = 'add'; $attribute_id = GETPOSTINT('attribute'); $attribute_value_id = GETPOSTINT('value'); - if ($attribute_id> 0 && $attribute_value_id > 0) { + if ($attribute_id > 0 && $attribute_value_id > 0) { $feature = $attribute_id . '-' . $attribute_value_id; $selectedvariant[$feature] = $feature; $_SESSION['addvariant_'.$object->id] = $selectedvariant; @@ -792,11 +792,11 @@ if (!empty($id) || !empty($ref)) { $prodstatic->fetch($prodcomb->fk_product_child); print $form->formconfirm( - "combinations.php?id=".urlencode($id)."&valueid=".urlencode($valueid), + "combinations.php?id=".urlencode((string) ($id))."&valueid=".urlencode((string) ($valueid)), $langs->trans('Delete'), $langs->trans('ProductCombinationDeleteDialog', $prodstatic->ref), "confirm_deletecombination", - array(array('label'=> $langs->trans('DeleteLinkedProduct'), 'type'=> 'checkbox', 'name' => 'delete_product', 'value' => false)), + array(array('label' => $langs->trans('DeleteLinkedProduct'), 'type' => 'checkbox', 'name' => 'delete_product', 'value' => false)), 0, 1 ); diff --git a/htdocs/webhook/class/target.class.php b/htdocs/webhook/class/target.class.php index 484991e1dc7..011b8b31606 100644 --- a/htdocs/webhook/class/target.class.php +++ b/htdocs/webhook/class/target.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2017 Laurent Destailleur * Copyright (C) ---Put here your own copyright and developer email--- * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -100,7 +101,7 @@ class Target extends CommonObject // BEGIN MODULEBUILDER PROPERTIES /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => '1', 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => '1', 'index' => 1, 'css' => 'left', 'comment' => "Id"), diff --git a/htdocs/webportal/admin/setup.php b/htdocs/webportal/admin/setup.php index 48a3f73e2a4..7680e08cd9a 100644 --- a/htdocs/webportal/admin/setup.php +++ b/htdocs/webportal/admin/setup.php @@ -1,6 +1,7 @@ * Copyright (C) 2023-2024 Lionel Vessiller + * Copyright (C) 2024 MDW * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -146,18 +147,16 @@ if ($action == 'updateMask') { // Search template files $file = ''; $classname = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir . "core/modules/webportal/doc/pdf_" . $modele . "_" . strtolower($tmpobjectkey) . ".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $classname = "pdf_" . $modele . "_" . strtolower($tmpobjectkey); break; } } - if ($filefound) { + if ($classname !== '') { require_once $file; $module = new $classname($db); diff --git a/htdocs/webportal/class/html.formlistwebportal.class.php b/htdocs/webportal/class/html.formlistwebportal.class.php index 524c4e99548..ac7fc81679b 100644 --- a/htdocs/webportal/class/html.formlistwebportal.class.php +++ b/htdocs/webportal/class/html.formlistwebportal.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2023-2024 Lionel Vessiller * Copyright (C) 2023-2024 Patrice Andreani * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -300,7 +301,7 @@ class FormListWebPortal $sql .= " FROM " . $this->db->prefix() . $object->table_element . " as t"; // Add table from hooks - $parameters = array(); + $parameters = array(); // @phan-suppress-current-line PhanPluginRedundantAssignment $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; if ($object->ismultientitymanaged == 1) { @@ -343,7 +344,7 @@ class FormListWebPortal // $sql .= natural_search(array_keys($fieldstosearchall), $search_all); //} // Add where from hooks - $parameters = array(); + $parameters = array(); // @phan-suppress-current-line PhanPluginRedundantAssignment $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; @@ -422,7 +423,7 @@ class FormListWebPortal } } // Add $param from hooks - $parameters = array(); + $parameters = array(); // @phan-suppress-current-line PhanPluginRedundantAssignment $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $param .= $hookmanager->resPrint; diff --git a/htdocs/webportal/class/webportalinvoice.class.php b/htdocs/webportal/class/webportalinvoice.class.php index e120979aaa9..5212a7e433f 100644 --- a/htdocs/webportal/class/webportalinvoice.class.php +++ b/htdocs/webportal/class/webportalinvoice.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2023-2024 Lionel Vessiller + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -96,11 +97,11 @@ class WebPortalInvoice extends Facture // BEGIN MODULEBUILDER PROPERTIES /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => 0, 'notnull' => 1, 'position' => 1,), - 'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => 0, 'notnull' => 1, 'position' => 20, 'index' => 1,), + 'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => '1', 'enabled' => 1, 'visible' => 0, 'notnull' => 1, 'position' => 20, 'index' => 1,), 'ref' => array('type' => 'varchar(30)', 'label' => 'Ref', 'enabled' => 1, 'visible' => 2, 'notnull' => 1, 'showoncombobox' => 1, 'position' => 5,), 'type' => array('type' => 'smallint(6)', 'label' => 'Type', 'enabled' => 1, 'visible' => 0, 'notnull' => 1, 'position' => 15,), 'datef' => array('type' => 'date', 'label' => 'DateInvoice', 'enabled' => 1, 'visible' => 2, 'position' => 20,), diff --git a/htdocs/webportal/class/webportalmember.class.php b/htdocs/webportal/class/webportalmember.class.php index 093703df8c7..d09568cf5f5 100644 --- a/htdocs/webportal/class/webportalmember.class.php +++ b/htdocs/webportal/class/webportalmember.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2023-2024 Lionel Vessiller + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -112,7 +113,7 @@ class WebPortalMember extends Adherent // BEGIN MODULEBUILDER PROPERTIES /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => 0, 'notnull' => 1, 'position' => 10,), diff --git a/htdocs/webportal/class/webportalorder.class.php b/htdocs/webportal/class/webportalorder.class.php index 12b1586e4c3..a1ca6bd5270 100644 --- a/htdocs/webportal/class/webportalorder.class.php +++ b/htdocs/webportal/class/webportalorder.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2023-2024 Lionel Vessiller + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -97,7 +98,7 @@ class WebPortalOrder extends Commande // BEGIN MODULEBUILDER PROPERTIES /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => 0, 'notnull' => 1, 'position' => 10,), diff --git a/htdocs/webportal/class/webportalpartnership.class.php b/htdocs/webportal/class/webportalpartnership.class.php index ffb32ec6dfc..7a0146072dd 100644 --- a/htdocs/webportal/class/webportalpartnership.class.php +++ b/htdocs/webportal/class/webportalpartnership.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2023-2024 Lionel Vessiller + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -96,33 +97,33 @@ class WebPortalPartnership extends Partnership // BEGIN MODULEBUILDER PROPERTIES /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( - 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => '1', 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => '1', 'index' => 1, 'css' => 'left', 'comment' => "Id",), - 'ref' => array('type' => 'varchar(128)', 'label' => 'Ref', 'enabled' => '1', 'position' => 10, 'notnull' => 1, 'visible' => 5, 'noteditable' => '1', 'default' => '(PROV)', 'index' => 1, 'searchall' => 1, 'showoncombobox' => '1', 'comment' => "Reference of object", 'showonheader' => 1,), - 'entity' => array('type' => 'integer', 'label' => 'Entity', 'enabled' => '1', 'position' => 15, 'notnull' => 1, 'visible' => -2, 'default' => '1', 'index' => 1,), + 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => '1', 'index' => 1, 'css' => 'left', 'comment' => "Id",), + 'ref' => array('type' => 'varchar(128)', 'label' => 'Ref', 'enabled' => 1, 'position' => 10, 'notnull' => 1, 'visible' => 5, 'noteditable' => '1', 'default' => '(PROV)', 'index' => 1, 'searchall' => 1, 'showoncombobox' => '1', 'comment' => "Reference of object", 'showonheader' => 1,), + 'entity' => array('type' => 'integer', 'label' => 'Entity', 'enabled' => 1, 'position' => 15, 'notnull' => 1, 'visible' => -2, 'default' => '1', 'index' => 1,), - 'fk_type' => array('type' => 'integer:PartnershipType:partnership/class/partnership_type.class.php:0:(active:=:1)', 'label' => 'Type', 'enabled' => '1', 'position' => 20, 'notnull' => 1, 'visible' => 5, 'csslist' => '',), - 'fk_soc' => array('type' => 'integer:Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))', 'label' => 'ThirdParty', 'picto' => 'company', 'enabled' => '1', 'position' => 50, 'notnull' => -1, 'visible' => 5, 'index' => 1, 'css' => '', 'csslist' => '',), - 'note_public' => array('type' => 'html', 'label' => 'NotePublic', 'enabled' => '1', 'position' => 61, 'notnull' => 0, 'visible' => 0,), - 'note_private' => array('type' => 'html', 'label' => 'NotePrivate', 'enabled' => '1', 'position' => 62, 'notnull' => 0, 'visible' => 0,), - 'date_creation' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => '1', 'position' => 500, 'notnull' => 1, 'visible' => -2,), - 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => '1', 'position' => 501, 'notnull' => 0, 'visible' => -2,), - 'fk_user_creat' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserAuthor', 'enabled' => '1', 'position' => 510, 'notnull' => 1, 'visible' => -2, 'foreignkey' => 'user.rowid',), - 'fk_user_modif' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'enabled' => '1', 'position' => 511, 'notnull' => -1, 'visible' => -2,), - 'last_main_doc' => array('type' => 'varchar(255)', 'label' => 'LastMainDoc', 'enabled' => '1', 'position' => 600, 'notnull' => 0, 'visible' => 0,), - 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => '1', 'position' => 1000, 'notnull' => -1, 'visible' => -2,), - 'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => '1', 'position' => 1010, 'notnull' => -1, 'visible' => 0,), - 'date_partnership_start' => array('type' => 'date', 'label' => 'DatePartnershipStart', 'enabled' => '1', 'position' => 52, 'notnull' => 1, 'visible' => 5,), - 'date_partnership_end' => array('type' => 'date', 'label' => 'DatePartnershipEnd', 'enabled' => '1', 'position' => 53, 'notnull' => 0, 'visible' => 5,), - 'url_to_check' => array('type' => 'varchar(255)', 'label' => 'UrlToCheck', 'enabled' => '1', 'position' => 70, 'notnull' => 0, 'visible' => -5,), - 'count_last_url_check_error' => array('type' => 'integer', 'label' => 'CountLastUrlCheckError', 'enabled' => '1', 'position' => 71, 'notnull' => 0, 'visible' => -2, 'default' => '0',), - 'last_check_backlink' => array('type' => 'datetime', 'label' => 'LastCheckBacklink', 'enabled' => '1', 'position' => 72, 'notnull' => 0, 'visible' => -2,), - 'reason_decline_or_cancel' => array('type' => 'text', 'label' => 'ReasonDeclineOrCancel', 'enabled' => '1', 'position' => 73, 'notnull' => 0, 'visible' => -2,), - 'ip' => array('type' => 'varchar(250)', 'label' => 'Ip', 'enabled' => '1', 'position' => 74, 'notnull' => 0, 'visible' => -2,), + 'fk_type' => array('type' => 'integer:PartnershipType:partnership/class/partnership_type.class.php:0:(active:=:1)', 'label' => 'Type', 'enabled' => 1, 'position' => 20, 'notnull' => 1, 'visible' => 5, 'csslist' => '',), + 'fk_soc' => array('type' => 'integer:Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))', 'label' => 'ThirdParty', 'picto' => 'company', 'enabled' => 1, 'position' => 50, 'notnull' => -1, 'visible' => 5, 'index' => 1, 'css' => '', 'csslist' => '',), + 'note_public' => array('type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'position' => 61, 'notnull' => 0, 'visible' => 0,), + 'note_private' => array('type' => 'html', 'label' => 'NotePrivate', 'enabled' => 1, 'position' => 62, 'notnull' => 0, 'visible' => 0,), + 'date_creation' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'position' => 500, 'notnull' => 1, 'visible' => -2,), + 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'position' => 501, 'notnull' => 0, 'visible' => -2,), + 'fk_user_creat' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserAuthor', 'enabled' => 1, 'position' => 510, 'notnull' => 1, 'visible' => -2, 'foreignkey' => 'user.rowid',), + 'fk_user_modif' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'enabled' => 1, 'position' => 511, 'notnull' => -1, 'visible' => -2,), + 'last_main_doc' => array('type' => 'varchar(255)', 'label' => 'LastMainDoc', 'enabled' => 1, 'position' => 600, 'notnull' => 0, 'visible' => 0,), + 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'position' => 1000, 'notnull' => -1, 'visible' => -2,), + 'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => 1, 'position' => 1010, 'notnull' => -1, 'visible' => 0,), + 'date_partnership_start' => array('type' => 'date', 'label' => 'DatePartnershipStart', 'enabled' => 1, 'position' => 52, 'notnull' => 1, 'visible' => 5,), + 'date_partnership_end' => array('type' => 'date', 'label' => 'DatePartnershipEnd', 'enabled' => 1, 'position' => 53, 'notnull' => 0, 'visible' => 5,), + 'url_to_check' => array('type' => 'varchar(255)', 'label' => 'UrlToCheck', 'enabled' => 1, 'position' => 70, 'notnull' => 0, 'visible' => -5,), + 'count_last_url_check_error' => array('type' => 'integer', 'label' => 'CountLastUrlCheckError', 'enabled' => 1, 'position' => 71, 'notnull' => 0, 'visible' => -2, 'default' => '0',), + 'last_check_backlink' => array('type' => 'datetime', 'label' => 'LastCheckBacklink', 'enabled' => 1, 'position' => 72, 'notnull' => 0, 'visible' => -2,), + 'reason_decline_or_cancel' => array('type' => 'text', 'label' => 'ReasonDeclineOrCancel', 'enabled' => 1, 'position' => 73, 'notnull' => 0, 'visible' => -2,), + 'ip' => array('type' => 'varchar(250)', 'label' => 'Ip', 'enabled' => 1, 'position' => 74, 'notnull' => 0, 'visible' => -2,), - 'status' => array('type' => 'smallint', 'label' => 'Status', 'enabled' => '1', 'position' => 2000, 'notnull' => 1, 'visible' => 5, 'default' => '0', 'index' => 1, 'arrayofkeyval' => self::STATUS_SHORT_LIST, 'showonheader' => 1,), + 'status' => array('type' => 'smallint', 'label' => 'Status', 'enabled' => 1, 'position' => 2000, 'notnull' => 1, 'visible' => 5, 'default' => '0', 'index' => 1, 'arrayofkeyval' => self::STATUS_SHORT_LIST, 'showonheader' => 1,), ); //public $rowid; //public $ref; diff --git a/htdocs/webportal/class/webportalpropal.class.php b/htdocs/webportal/class/webportalpropal.class.php index d53fa5f07ab..2c6a973ec66 100644 --- a/htdocs/webportal/class/webportalpropal.class.php +++ b/htdocs/webportal/class/webportalpropal.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2023-2024 Lionel Vessiller + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -97,7 +98,7 @@ class WebPortalPropal extends Propal // BEGIN MODULEBUILDER PROPERTIES /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => '1', 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => '1', 'index' => 1, 'css' => 'left', 'comment' => "Id",), diff --git a/htdocs/webportal/controllers/propallist.controller.class.php b/htdocs/webportal/controllers/propallist.controller.class.php index 5c6ca9668db..4eb947582c1 100644 --- a/htdocs/webportal/controllers/propallist.controller.class.php +++ b/htdocs/webportal/controllers/propallist.controller.class.php @@ -64,7 +64,7 @@ class PropalListController extends Controller // Load translation files required by the page $langs->loadLangs(array('companies', 'propal', 'compta', 'bills', 'orders', 'products', 'deliveries', 'categories')); - if (isModEnabled('delivery_note')) { + if (isModEnabled('shipping')) { $langs->loadLangs(array('sendings')); } diff --git a/htdocs/webservices/server_category.php b/htdocs/webservices/server_category.php index 6e3e66bc205..a062c5c9361 100644 --- a/htdocs/webservices/server_category.php +++ b/htdocs/webservices/server_category.php @@ -1,6 +1,7 @@ * Copyright (C) 2012 JF FERRY + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -77,11 +78,11 @@ $server->wsdl->addComplexType( 'all', '', array( - 'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'), - 'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'), - 'login' => array('name'=>'login', 'type'=>'xsd:string'), - 'password' => array('name'=>'password', 'type'=>'xsd:string'), - 'entity' => array('name'=>'entity', 'type'=>'xsd:string'), + 'dolibarrkey' => array('name' => 'dolibarrkey', 'type' => 'xsd:string'), + 'sourceapplication' => array('name' => 'sourceapplication', 'type' => 'xsd:string'), + 'login' => array('name' => 'login', 'type' => 'xsd:string'), + 'password' => array('name' => 'password', 'type' => 'xsd:string'), + 'entity' => array('name' => 'entity', 'type' => 'xsd:string'), ) ); @@ -95,16 +96,16 @@ $server->wsdl->addComplexType( 'all', '', array( - 'id' => array('name'=>'id', 'type'=>'xsd:string'), - 'id_mere' => array('name'=>'id_mere', 'type'=>'xsd:string'), - 'label' => array('name'=>'label', 'type'=>'xsd:string'), - 'description' => array('name'=>'description', 'type'=>'xsd:string'), - 'socid' => array('name'=>'socid', 'type'=>'xsd:string'), - 'type' => array('name'=>'type', 'type'=>'xsd:string'), - 'visible' => array('name'=>'visible', 'type'=>'xsd:string'), - 'dir'=> array('name'=>'dir', 'type'=>'xsd:string'), - 'photos' => array('name'=>'photos', 'type'=>'tns:PhotosArray'), - 'filles' => array('name'=>'filles', 'type'=>'tns:FillesArray') + 'id' => array('name' => 'id', 'type' => 'xsd:string'), + 'id_mere' => array('name' => 'id_mere', 'type' => 'xsd:string'), + 'label' => array('name' => 'label', 'type' => 'xsd:string'), + 'description' => array('name' => 'description', 'type' => 'xsd:string'), + 'socid' => array('name' => 'socid', 'type' => 'xsd:string'), + 'type' => array('name' => 'type', 'type' => 'xsd:string'), + 'visible' => array('name' => 'visible', 'type' => 'xsd:string'), + 'dir' => array('name' => 'dir', 'type' => 'xsd:string'), + 'photos' => array('name' => 'photos', 'type' => 'tns:PhotosArray'), + 'filles' => array('name' => 'filles', 'type' => 'tns:FillesArray') ) ); @@ -119,14 +120,14 @@ $server->wsdl->addComplexType( 'SOAP-ENC:Array', array(), array( - array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType'=>'tns:categorie[]') + array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:categorie[]') ), 'tns:categorie' ); - /* - * Image of product - */ +/* + * Image of product +*/ $server->wsdl->addComplexType( 'PhotosArray', 'complexType', @@ -143,9 +144,9 @@ $server->wsdl->addComplexType( ) ); - /* - * An image - */ +/* + * An image +*/ $server->wsdl->addComplexType( 'image', 'complexType', @@ -153,10 +154,10 @@ $server->wsdl->addComplexType( 'all', '', array( - 'photo' => array('name'=>'photo', 'type'=>'xsd:string'), - 'photo_vignette' => array('name'=>'photo_vignette', 'type'=>'xsd:string'), - 'imgWidth' => array('name'=>'imgWidth', 'type'=>'xsd:string'), - 'imgHeight' => array('name'=>'imgHeight', 'type'=>'xsd:string') + 'photo' => array('name' => 'photo', 'type' => 'xsd:string'), + 'photo_vignette' => array('name' => 'photo_vignette', 'type' => 'xsd:string'), + 'imgWidth' => array('name' => 'imgWidth', 'type' => 'xsd:string'), + 'imgHeight' => array('name' => 'imgHeight', 'type' => 'xsd:string') ) ); @@ -170,8 +171,8 @@ $server->wsdl->addComplexType( 'all', '', array( - 'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'), - 'result_label' => array('name'=>'result_label', 'type'=>'xsd:string'), + 'result_code' => array('name' => 'result_code', 'type' => 'xsd:string'), + 'result_label' => array('name' => 'result_label', 'type' => 'xsd:string'), ) ); @@ -187,9 +188,9 @@ $styleuse = 'encoded'; // encoded/literal/literal wrapped $server->register( 'getCategory', // Entry values - array('authentication'=>'tns:authentication', 'id'=>'xsd:string'), + array('authentication' => 'tns:authentication', 'id' => 'xsd:string'), // Exit values - array('result'=>'tns:result', 'categorie'=>'tns:categorie'), + array('result' => 'tns:result', 'categorie' => 'tns:categorie'), $ns, $ns.'#getCategory', $styledoc, @@ -232,7 +233,7 @@ function getCategory($authentication, $id) if (!$error) { $fuser->getrights(); - $nbmax = 10; + $nbmax = 10; // @phan-suppress-current-line PhanPluginRedundantAssignment if ($fuser->hasRight('categorie', 'lire')) { $categorie = new Categorie($db); $result = $categorie->fetch($id); @@ -260,13 +261,13 @@ function getCategory($authentication, $id) $pdir = get_exdir($child_cat->id, 2, 0, 0, $categorie, 'category').$child_cat->id."/photos/"; $dir = $dir.'/'.$pdir; $cat['filles'][] = array( - 'id'=>$child_cat->id, + 'id' => $child_cat->id, 'id_mere' => $categorie->id_mere, - 'label'=>$child_cat->label, - 'description'=>$child_cat->description, - 'socid'=>$child_cat->socid, + 'label' => $child_cat->label, + 'description' => $child_cat->description, + 'socid' => $child_cat->socid, //'visible'=>$child_cat->visible, - 'type'=>$child_cat->type, + 'type' => $child_cat->type, 'dir' => $pdir, 'photos' => $child_cat->liste_photos($dir, $nbmax) ); @@ -275,8 +276,8 @@ function getCategory($authentication, $id) // Create $objectresp = array( - 'result'=>array('result_code'=>'OK', 'result_label'=>''), - 'categorie'=> $cat + 'result' => array('result_code' => 'OK', 'result_label' => ''), + 'categorie' => $cat ); } else { $error++; @@ -291,7 +292,7 @@ function getCategory($authentication, $id) } if ($error) { - $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); + $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel)); } return $objectresp; diff --git a/htdocs/webservices/server_user.php b/htdocs/webservices/server_user.php index 52267436a8d..b0f7f2372fd 100644 --- a/htdocs/webservices/server_user.php +++ b/htdocs/webservices/server_user.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -81,11 +82,11 @@ $server->wsdl->addComplexType( 'all', '', array( - 'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'), - 'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'), - 'login' => array('name'=>'login', 'type'=>'xsd:string'), - 'password' => array('name'=>'password', 'type'=>'xsd:string'), - 'entity' => array('name'=>'entity', 'type'=>'xsd:string'), + 'dolibarrkey' => array('name' => 'dolibarrkey', 'type' => 'xsd:string'), + 'sourceapplication' => array('name' => 'sourceapplication', 'type' => 'xsd:string'), + 'login' => array('name' => 'login', 'type' => 'xsd:string'), + 'password' => array('name' => 'password', 'type' => 'xsd:string'), + 'entity' => array('name' => 'entity', 'type' => 'xsd:string'), ) ); @@ -97,8 +98,8 @@ $server->wsdl->addComplexType( 'all', '', array( - 'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'), - 'result_label' => array('name'=>'result_label', 'type'=>'xsd:string'), + 'result_code' => array('name' => 'result_code', 'type' => 'xsd:string'), + 'result_label' => array('name' => 'result_label', 'type' => 'xsd:string'), ) ); @@ -110,34 +111,34 @@ $server->wsdl->addComplexType( 'all', '', array( - 'element' => array('name'=>'element', 'type'=>'xsd:string'), - 'id' => array('name'=>'id', 'type'=>'xsd:string'), - 'lastname' => array('name'=>'lastname', 'type'=>'xsd:string'), - 'firstname' => array('name'=>'firstname', 'type'=>'xsd:string'), - 'note' => array('name'=>'note', 'type'=>'xsd:string'), - 'email' => array('name'=>'email', 'type'=>'xsd:string'), - 'signature' => array('name'=>'signature', 'type'=>'xsd:string'), - 'office_phone' => array('name'=>'office_phone', 'type'=>'xsd:string'), - 'office_fax' => array('name'=>'office_fax', 'type'=>'xsd:string'), - 'user_mobile' => array('name'=>'user_mobile', 'type'=>'xsd:string'), - 'admin' => array('name'=>'admin', 'type'=>'xsd:string'), - 'login' => array('name'=>'login', 'type'=>'xsd:string'), - 'entity' => array('name'=>'entity', 'type'=>'xsd:string'), - 'pass_indatabase' => array('name'=>'pass_indatabase', 'type'=>'xsd:string'), - 'pass_indatabase_crypted' => array('name'=>'pass_indatabase_crypted', 'type'=>'xsd:string'), - 'datec' => array('name'=>'datec', 'type'=>'xsd:dateTime'), - 'datem' => array('name'=>'datem', 'type'=>'xsd:dateTime'), - 'fk_thirdparty' => array('name'=>'fk_thirdparty', 'type'=>'xsd:string'), - 'fk_contact' => array('name'=>'fk_contact', 'type'=>'xsd:string'), - 'fk_member' => array('name'=>'fk_member', 'type'=>'xsd:string'), - 'datelastlogin' => array('name'=>'datelastlogin', 'type'=>'xsd:dateTime'), - 'datepreviouslogin' => array('name'=>'datepreviouslogin', 'type'=>'xsd:dateTime'), - 'statut' => array('name'=>'statut', 'type'=>'xsd:string'), - 'photo' => array('name'=>'photo', 'type'=>'xsd:string'), - 'lang' => array('name'=>'lang', 'type'=>'xsd:string'), - 'entrepots' => array('name'=>'entrepots', 'type'=>'xsd:string'), + 'element' => array('name' => 'element', 'type' => 'xsd:string'), + 'id' => array('name' => 'id', 'type' => 'xsd:string'), + 'lastname' => array('name' => 'lastname', 'type' => 'xsd:string'), + 'firstname' => array('name' => 'firstname', 'type' => 'xsd:string'), + 'note' => array('name' => 'note', 'type' => 'xsd:string'), + 'email' => array('name' => 'email', 'type' => 'xsd:string'), + 'signature' => array('name' => 'signature', 'type' => 'xsd:string'), + 'office_phone' => array('name' => 'office_phone', 'type' => 'xsd:string'), + 'office_fax' => array('name' => 'office_fax', 'type' => 'xsd:string'), + 'user_mobile' => array('name' => 'user_mobile', 'type' => 'xsd:string'), + 'admin' => array('name' => 'admin', 'type' => 'xsd:string'), + 'login' => array('name' => 'login', 'type' => 'xsd:string'), + 'entity' => array('name' => 'entity', 'type' => 'xsd:string'), + 'pass_indatabase' => array('name' => 'pass_indatabase', 'type' => 'xsd:string'), + 'pass_indatabase_crypted' => array('name' => 'pass_indatabase_crypted', 'type' => 'xsd:string'), + 'datec' => array('name' => 'datec', 'type' => 'xsd:dateTime'), + 'datem' => array('name' => 'datem', 'type' => 'xsd:dateTime'), + 'fk_thirdparty' => array('name' => 'fk_thirdparty', 'type' => 'xsd:string'), + 'fk_contact' => array('name' => 'fk_contact', 'type' => 'xsd:string'), + 'fk_member' => array('name' => 'fk_member', 'type' => 'xsd:string'), + 'datelastlogin' => array('name' => 'datelastlogin', 'type' => 'xsd:dateTime'), + 'datepreviouslogin' => array('name' => 'datepreviouslogin', 'type' => 'xsd:dateTime'), + 'statut' => array('name' => 'statut', 'type' => 'xsd:string'), + 'photo' => array('name' => 'photo', 'type' => 'xsd:string'), + 'lang' => array('name' => 'lang', 'type' => 'xsd:string'), + 'entrepots' => array('name' => 'entrepots', 'type' => 'xsd:string'), //'rights' => array('name'=>'rights','type'=>'xsd:string'), - 'canvas' => array('name'=>'canvas', 'type'=>'xsd:string') + 'canvas' => array('name' => 'canvas', 'type' => 'xsd:string') ) ); @@ -149,10 +150,10 @@ $server->wsdl->addComplexType( 'all', '', array( - 'name' => array('name'=>'name', 'type'=>'xsd:string'), - 'id' => array('name'=>'id', 'type'=>'xsd:string'), - 'datec' => array('name'=>'datec', 'type'=>'xsd:string'), - 'nb' => array('name'=>'nb', 'type'=>'xsd:string') + 'name' => array('name' => 'name', 'type' => 'xsd:string'), + 'id' => array('name' => 'id', 'type' => 'xsd:string'), + 'datec' => array('name' => 'datec', 'type' => 'xsd:string'), + 'nb' => array('name' => 'nb', 'type' => 'xsd:string') ) ); @@ -164,42 +165,42 @@ $server->wsdl->addComplexType( 'SOAP-ENC:Array', array(), array( - array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType'=>'tns:group[]') + array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:group[]') ), 'tns:group' ); $thirdpartywithuser_fields = array( // For thirdparty and contact - 'name' => array('name'=>'name', 'type'=>'xsd:string'), - 'firstname' => array('name'=>'firstname', 'type'=>'xsd:string'), - 'name_thirdparty' => array('name'=>'name_thirdparty', 'type'=>'xsd:string'), - 'ref_ext' => array('name'=>'ref_ext', 'type'=>'xsd:string'), - 'client' => array('name'=>'client', 'type'=>'xsd:string'), - 'fournisseur' => array('name'=>'fournisseur', 'type'=>'xsd:string'), - 'address' => array('name'=>'address', 'type'=>'xsd:string'), - 'zip' => array('name'=>'zip', 'type'=>'xsd:string'), - 'town' => array('name'=>'town', 'type'=>'xsd:string'), - 'country_id' => array('name'=>'country_id', 'type'=>'xsd:string'), - 'country_code' => array('name'=>'country_code', 'type'=>'xsd:string'), - 'phone' => array('name'=>'phone', 'type'=>'xsd:string'), - 'phone_mobile' => array('name'=>'phone_mobile', 'type'=>'xsd:string'), - 'fax' => array('name'=>'fax', 'type'=>'xsd:string'), - 'email' => array('name'=>'email', 'type'=>'xsd:string'), - 'url' => array('name'=>'url', 'type'=>'xsd:string'), - 'profid1' => array('name'=>'profid1', 'type'=>'xsd:string'), - 'profid2' => array('name'=>'profid2', 'type'=>'xsd:string'), - 'profid3' => array('name'=>'profid3', 'type'=>'xsd:string'), - 'profid4' => array('name'=>'profid4', 'type'=>'xsd:string'), - 'profid5' => array('name'=>'profid5', 'type'=>'xsd:string'), - 'profid6' => array('name'=>'profid6', 'type'=>'xsd:string'), - 'capital' => array('name'=>'capital', 'type'=>'xsd:string'), - 'tva_assuj' => array('name'=>'tva_assuj', 'type'=>'xsd:string'), - 'tva_intra' => array('name'=>'tva_intra', 'type'=>'xsd:string'), + 'name' => array('name' => 'name', 'type' => 'xsd:string'), + 'firstname' => array('name' => 'firstname', 'type' => 'xsd:string'), + 'name_thirdparty' => array('name' => 'name_thirdparty', 'type' => 'xsd:string'), + 'ref_ext' => array('name' => 'ref_ext', 'type' => 'xsd:string'), + 'client' => array('name' => 'client', 'type' => 'xsd:string'), + 'fournisseur' => array('name' => 'fournisseur', 'type' => 'xsd:string'), + 'address' => array('name' => 'address', 'type' => 'xsd:string'), + 'zip' => array('name' => 'zip', 'type' => 'xsd:string'), + 'town' => array('name' => 'town', 'type' => 'xsd:string'), + 'country_id' => array('name' => 'country_id', 'type' => 'xsd:string'), + 'country_code' => array('name' => 'country_code', 'type' => 'xsd:string'), + 'phone' => array('name' => 'phone', 'type' => 'xsd:string'), + 'phone_mobile' => array('name' => 'phone_mobile', 'type' => 'xsd:string'), + 'fax' => array('name' => 'fax', 'type' => 'xsd:string'), + 'email' => array('name' => 'email', 'type' => 'xsd:string'), + 'url' => array('name' => 'url', 'type' => 'xsd:string'), + 'profid1' => array('name' => 'profid1', 'type' => 'xsd:string'), + 'profid2' => array('name' => 'profid2', 'type' => 'xsd:string'), + 'profid3' => array('name' => 'profid3', 'type' => 'xsd:string'), + 'profid4' => array('name' => 'profid4', 'type' => 'xsd:string'), + 'profid5' => array('name' => 'profid5', 'type' => 'xsd:string'), + 'profid6' => array('name' => 'profid6', 'type' => 'xsd:string'), + 'capital' => array('name' => 'capital', 'type' => 'xsd:string'), + 'tva_assuj' => array('name' => 'tva_assuj', 'type' => 'xsd:string'), + 'tva_intra' => array('name' => 'tva_intra', 'type' => 'xsd:string'), // For user - 'login' => array('name'=>'login', 'type'=>'xsd:string'), - 'password' => array('name'=>'password', 'type'=>'xsd:string'), - 'group_id' => array('name'=>'group_id', 'type'=>'xsd:string') + 'login' => array('name' => 'login', 'type' => 'xsd:string'), + 'password' => array('name' => 'password', 'type' => 'xsd:string'), + 'group_id' => array('name' => 'group_id', 'type' => 'xsd:string') ); $elementtype = 'socpeople'; @@ -221,7 +222,7 @@ if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafie $type = 'xsd:string'; } - $extrafield_array['contact_options_'.$key] = array('name'=>'contact_options_'.$key, 'type'=>$type); + $extrafield_array['contact_options_'.$key] = array('name' => 'contact_options_'.$key, 'type' => $type); } } @@ -247,9 +248,9 @@ $server->wsdl->addComplexType( 'all', '', array( - 'login' => array('name'=>'login', 'type'=>'xsd:string'), - 'password' => array('name'=>'password', 'type'=>'xsd:string'), - 'entity' => array('name'=>'entity', 'type'=>'xsd:string'), + 'login' => array('name' => 'login', 'type' => 'xsd:string'), + 'password' => array('name' => 'password', 'type' => 'xsd:string'), + 'entity' => array('name' => 'entity', 'type' => 'xsd:string'), ) ); @@ -267,9 +268,9 @@ $styleuse = 'encoded'; // encoded/literal/literal wrapped $server->register( 'getUser', // Entry values - array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'ref'=>'xsd:string', 'ref_ext'=>'xsd:string'), + array('authentication' => 'tns:authentication', 'id' => 'xsd:string', 'ref' => 'xsd:string', 'ref_ext' => 'xsd:string'), // Exit values - array('result'=>'tns:result', 'user'=>'tns:user'), + array('result' => 'tns:result', 'user' => 'tns:user'), $ns, $ns.'#getUser', $styledoc, @@ -280,9 +281,9 @@ $server->register( $server->register( 'getListOfGroups', // Entry values - array('authentication'=>'tns:authentication'), + array('authentication' => 'tns:authentication'), // Exit values - array('result'=>'tns:result', 'groups'=>'tns:GroupsArray'), + array('result' => 'tns:result', 'groups' => 'tns:GroupsArray'), $ns, $ns.'#getListOfGroups', $styledoc, @@ -293,9 +294,9 @@ $server->register( $server->register( 'createUserFromThirdparty', // Entry values - array('authentication'=>'tns:authentication', 'thirdpartywithuser'=>'tns:thirdpartywithuser'), + array('authentication' => 'tns:authentication', 'thirdpartywithuser' => 'tns:thirdpartywithuser'), // Exit values - array('result'=>'tns:result', 'id'=>'xsd:string'), + array('result' => 'tns:result', 'id' => 'xsd:string'), $ns, $ns.'#createUserFromThirdparty', $styledoc, @@ -306,9 +307,9 @@ $server->register( $server->register( 'setUserPassword', // Entry values - array('authentication'=>'tns:authentication', 'shortuser'=>'tns:shortuser'), + array('authentication' => 'tns:authentication', 'shortuser' => 'tns:shortuser'), // Exit values - array('result'=>'tns:result', 'id'=>'xsd:string'), + array('result' => 'tns:result', 'id' => 'xsd:string'), $ns, $ns.'#setUserPassword', $styledoc, @@ -363,8 +364,8 @@ function getUser($authentication, $id, $ref = '', $ref_ext = '') if ($result > 0) { // Create $objectresp = array( - 'result'=>array('result_code'=>'OK', 'result_label'=>''), - 'user'=>array( + 'result' => array('result_code' => 'OK', 'result_label' => ''), + 'user' => array( 'id' => $user->id, 'lastname' => $user->lastname, 'firstname' => $user->firstname, @@ -406,7 +407,7 @@ function getUser($authentication, $id, $ref = '', $ref_ext = '') } if ($error) { - $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); + $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel)); } return $objectresp; @@ -454,7 +455,7 @@ function getListOfGroups($authentication) $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); - $arraygroups[] = array('id'=>$obj->rowid, 'name'=>$obj->name, 'datec'=>$obj->datec, 'nb'=>$obj->nb); + $arraygroups[] = array('id' => $obj->rowid, 'name' => $obj->name, 'datec' => $obj->datec, 'nb' => $obj->nb); $i++; } } else { @@ -466,13 +467,13 @@ function getListOfGroups($authentication) if ($error) { $objectresp = array( - 'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), - 'groups'=>$arraygroups + 'result' => array('result_code' => $errorcode, 'result_label' => $errorlabel), + 'groups' => $arraygroups ); } else { $objectresp = array( - 'result'=>array('result_code' => 'OK', 'result_label' => ''), - 'groups'=>$arraygroups + 'result' => array('result_code' => 'OK', 'result_label' => ''), + 'groups' => $arraygroups ); } @@ -648,8 +649,7 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser) if (!$error) { $db->commit(); - $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>'SUCCESS'), 'id'=>$socid_return); - $error = 0; + $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => 'SUCCESS'), 'id' => $socid_return); } } else { $error++; @@ -672,7 +672,7 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser) if ($error) { $db->rollback(); $objectresp = array( - 'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel) + 'result' => array('result_code' => $errorcode, 'result_label' => $errorlabel) ); } @@ -728,7 +728,7 @@ function setUserPassword($authentication, $shortuser) $errorlabel = 'Error when changing password'; } else { $objectresp = array( - 'result'=>array('result_code' => 'OK', 'result_label' => ''), + 'result' => array('result_code' => 'OK', 'result_label' => ''), ); } } else { @@ -746,7 +746,7 @@ function setUserPassword($authentication, $shortuser) if ($error) { $objectresp = array( - 'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel) + 'result' => array('result_code' => $errorcode, 'result_label' => $errorlabel) ); } diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index a4b80193d02..2dbc2227f9d 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -403,15 +403,15 @@ class Website extends CommonObject /** * Load all object in memory ($this->records) from the database * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit offset limit - * @param int $offset offset limit - * @param array $filter filter array - * @param string $filtermode filter mode (AND or OR) - * @return array|int int <0 if KO, array of pages if OK + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset offset limit + * @param string|array $filter filter array + * @param string $filtermode filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND') { dol_syslog(__METHOD__, LOG_DEBUG); @@ -433,15 +433,29 @@ class Website extends CommonObject $sql .= " t.tms as date_modification"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; $sql .= " WHERE t.entity IN (".getEntity('website').")"; + // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'"; + if (is_array($filter)) { + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'"; + } } + if (count($sqlwhere) > 0) { + $sql .= ' AND '.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere); + } + + $filter = ''; } - if (count($sqlwhere) > 0) { - $sql .= ' AND '.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere); + + // Manage filter + $errormessage = ''; + $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage); + if ($errormessage) { + $this->errors[] = $errormessage; + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); + return -1; } if (!empty($sortfield)) { @@ -1061,15 +1075,16 @@ class Website extends CommonObject $i++; } + $line = '-- File generated by Dolibarr '.DOL_VERSION.' --;'."\n"; + $line .= "\n"; + fwrite($fp, $line); + foreach ($listofpages as $pageid => $objectpageold) { $oldpageid = $objectpageold->id; $allaliases = $objectpageold->pageurl; $allaliases .= ($objectpageold->aliasalt ? ','.$objectpageold->aliasalt : ''); - $line = '-- File generated by Dolibarr '.DOL_VERSION.' -- '.dol_print_date(dol_now('gmt'), 'standard', 'gmt').' UTC --;'."\n"; - $line .= "\n"; - if (!getDolGlobalInt('WEBSITE_EXPORT_KEEP_FILES_OF_PAGES')) { // We don't need to keep the PHP files of pages and aliases (they are regenerated at import) so we remove them. You can ask to keep them in the export // Delete the pageX.tpl.php page dol_delete_file($conf->website->dir_temp.'/'.$website->ref.'/containers/page'.$objectpageold->id.'.tpl.php', 0, 0, 0, null, false, 0); @@ -1084,13 +1099,12 @@ class Website extends CommonObject } // This comment syntax is important, it is parsed by import to get information on page ID and all aliases to regenerate - $line .= '-- Page ID '.$objectpageold->newid.'__+MAX_llx_website_page__ - Aliases '.$allaliases.' --;'; // newid start at 1, 2... + $line = '-- Page ID '.$objectpageold->newid.'__+MAX_llx_website_page__ - Aliases '.$allaliases.' --;'; // newid start at 1, 2... $line .= "\n"; fwrite($fp, $line); // Warning: We must keep llx_ here. It is a generic SQL. $line = 'INSERT INTO llx_website_page(rowid, fk_page, fk_website, pageurl, aliasalt, title, description, lang, image, keywords, status, date_creation, tms, import_key, grabbed_from, type_container, htmlheader, content, author_alias, allowed_in_frames)'; - $line .= " VALUES("; $line .= $objectpageold->newid."__+MAX_llx_website_page__, "; $line .= ($objectpageold->newfk_page ? $this->db->escape($objectpageold->newfk_page)."__+MAX_llx_website_page__" : "null").", "; @@ -1156,7 +1170,7 @@ class Website extends CommonObject fwrite($fp, $line); } - $line .= "\n"; + fwrite($fp, "\n"); } $line = "\n-- For Dolibarr v14+ --;\n"; @@ -1166,6 +1180,7 @@ class Website extends CommonObject fwrite($fp, $line); fclose($fp); + dolChmod($filesql); // Build zip file @@ -1230,7 +1245,8 @@ class Website extends CommonObject $arrayreplacement['__LOGO_MINI_KEY__'] = $this->db->escape($mysoc->logo_mini); $arrayreplacement['__LOGO_KEY__'] = $this->db->escape($mysoc->logo); - // Copy containers + + // Copy containers directory dolCopyDir($conf->website->dir_temp.'/'.$object->ref.'/containers', $conf->website->dir_output.'/'.$object->ref, 0, 1); // Overwrite if exists // Make replacement into css and htmlheader file @@ -1248,8 +1264,17 @@ class Website extends CommonObject $error++; } - dolCopyDir($conf->website->dir_temp.'/'.$object->ref.'/medias/image/websitekey', $conf->website->dir_output.'/'.$object->ref.'/medias/image/'.$object->ref, 0, 1); // Medias can be shared, do not overwrite if exists - dolCopyDir($conf->website->dir_temp.'/'.$object->ref.'/medias/js/websitekey', $conf->website->dir_output.'/'.$object->ref.'/medias/js/'.$object->ref, 0, 1); // Medias can be shared, do not overwrite if exists + $result = dolCopyDir($conf->website->dir_temp.'/'.$object->ref.'/medias/image/websitekey', $conf->website->dir_output.'/'.$object->ref.'/medias/image/'.$object->ref, 0, 1); + if ($result < 0) { + $this->errors[] = 'Failed to copy files into '.$conf->website->dir_output.'/'.$object->ref.'/medias/image/'.$object->ref.'.'; + return -5; + } + + $result = dolCopyDir($conf->website->dir_temp.'/'.$object->ref.'/medias/js/websitekey', $conf->website->dir_output.'/'.$object->ref.'/medias/js/'.$object->ref, 0, 1); + if ($result < 0) { + $this->errors[] = 'Failed to copy files into '.$conf->website->dir_output.'/'.$object->ref.'/medias/js/'.$object->ref.'.'; + return -5; + } $sqlfile = $conf->website->dir_temp."/".$object->ref.'/website_pages.sql'; @@ -1274,7 +1299,7 @@ class Website extends CommonObject $objectpagestatic = new WebsitePage($this->db); - // Make replacement of IDs + // Regenerate the php files for pages $fp = fopen($sqlfile, "r"); if ($fp) { while (!feof($fp)) { @@ -1282,18 +1307,30 @@ class Website extends CommonObject // Warning fgets with second parameter that is null or 0 hang. $buf = fgets($fp, 65000); + $newid = 0; + + // Scan the line if (preg_match('/^-- Page ID (\d+)\s[^\s]+\s(\d+).*Aliases\s(.*)\s--;/i', $buf, $reg)) { + // Example of line: "-- Page ID 179 -> 1__+MAX_llx_website_page__ - Aliases about-us --;" $oldid = $reg[1]; $newid = ($reg[2] + $maxrowid); $aliasesarray = explode(',', $reg[3]); - dol_syslog("Found ID ".$oldid." to replace with ID ".$newid." and shortcut aliases to create: ".$reg[3]); + dol_syslog("In sql source file, we have the page ID ".$oldid." to replace with the new ID ".$newid.", and we must create the shortcut aliases: ".$reg[3]); - dol_move($conf->website->dir_output.'/'.$object->ref.'/page'.$oldid.'.tpl.php', $conf->website->dir_output.'/'.$object->ref.'/page'.$newid.'.tpl.php', 0, 1, 0, 0); + //dol_move($conf->website->dir_output.'/'.$object->ref.'/page'.$oldid.'.tpl.php', $conf->website->dir_output.'/'.$object->ref.'/page'.$newid.'.tpl.php', 0, 1, 0, 0); + } elseif (preg_match('/^-- Page ID (\d+).*Aliases\s(.*)\s--;/i', $buf, $reg)) { + // Example of line: "-- Page ID 1__+MAX_llx_website_page__ - Aliases about-us --;" + $newid = ($reg[1] + $maxrowid); + $aliasesarray = explode(',', $reg[2]); + dol_syslog("In sql source file, we have the page with the new ID ".$newid.", and we must create the shortcut aliases: ".$reg[3]); + } + + if ($newid) { $objectpagestatic->fetch($newid); - // The move is not enough, so we regenerate pageX.tpl.php + // We regenerate the pageX.tpl.php $filetpl = $conf->website->dir_output.'/'.$object->ref.'/page'.$newid.'.tpl.php'; $result = dolSavePageContent($filetpl, $object, $objectpagestatic); if (!$result) { @@ -1332,7 +1369,7 @@ class Website extends CommonObject } } - // Regenerate index page to point to the new index page + // Regenerate the index.php page to point to the new index page $pathofwebsite = $conf->website->dir_output.'/'.$object->ref; dolSaveIndexPage($pathofwebsite, $pathofwebsite.'/index.php', $pathofwebsite.'/page'.$object->fk_default_home.'.tpl.php', $pathofwebsite.'/wrapper.php', $object); @@ -1670,173 +1707,20 @@ class Website extends CommonObject // Export on target sources $resultarray = dol_uncompress($pathtotmpzip, $destdir); + // Remove the file README and LICENSE from the $destdir (already into the containers directory) + dol_delete_file($destdir.'/README.md'); + dol_delete_file($destdir.'/LICENSE'); + + // Remove non required files (will be re-generated during the import) + dol_delete_file($destdir.'/containers/index.php'); + dol_delete_file($destdir.'/containers/master.inc.php'); + if (!empty($resultarray)) { setEventMessages("Error, failed to unzip the export into target dir", null, 'errors'); } else { setEventMessages("Website content written into ".$destdirrel, null, 'mesgs'); } - /* - $sourcedir = $conf->website->dir_output."/".$website->ref; - - // Get array with hash of files (for the last sync) - $fichierEtat = $sourcedir . '/filelist-'.dol_sanitizeFileName($destdir).'.txt'; - $etatPrecedent = $this->checkPreviousState($fichierEtat); - - // Get list of all source files of the website - $arraySourcedir = dol_dir_list($sourcedir); - - // Get list of modified files - $modifications = []; - foreach ($arraySourcedir as $file) { - if (substr($file['name'], -4) === '.old') { - continue; - } - $hashActuel = hash_file('md5', $file['fullname']); - - // Check whether the file is new or has been modified - if (!isset($etatPrecedent[$file['name']]) || $etatPrecedent[$file['name']] !== $hashActuel) { - $modifications[] = $file; - } - - $etatPrecedent[$file['name']] = $hashActuel; // we store he new hash to record it later on disk. - } - - $arraydestdir = dol_dir_list($destdir, "all", 1); - $differences = []; - $names = array_column($arraydestdir, 'name'); - $namesSource = array_column($arraySourcedir, 'name'); - - if (count($modifications) > 1) { - foreach ($modifications as $fichierModifie) { - $nomFichierModifie = $fichierModifie['name']; - if ($nomFichierModifie == basename($fichierEtat)) { - continue; - } - $success = 0; - - //check if it is a new file - if ((!preg_match('/^page\d+\.tpl\.php$/', $nomFichierModifie)) && (!in_array($nomFichierModifie, $names))) { - if (file_exists($fichierModifie['fullname']) && dol_is_dir($destdir.'/containers')) { - $cp = dol_copy($fichierModifie['fullname'], $destdir.'/containers/'.$nomFichierModifie, '0664'); - if ($cp > 0) { - if (file_exists($destdir.'/containers/'.$nomFichierModifie)) { - $tabnumpage = array(); - foreach ($arraydestdir as $fileDest) { - if ($this->extractNumberFromFilename($fileDest['name']) !== -1) { - $tabnumpage[] = $this->extractNumberFromFilename($fileDest['name']); - } - } - $getContentSource = file_get_contents($destdir.'/containers/'.$nomFichierModifie); - $nextpage = max($tabnumpage) + 1; - $chaineModifiee = preg_replace('/page\d+\.tpl\.php/', 'page' . $nextpage . '.tpl.php', $getContentSource); - $write = file_put_contents($destdir.'/containers/'.$nomFichierModifie, $chaineModifiee); - if ($write !== false) { - if (!touch($destdir.'/containers/'."page" . $nextpage . ".tpl.php")) { - setEventMessages("Please check permission to create page" . $nextpage . ".tpl.php in template ".$website->name_template."", null, 'errors'); - } - $filesFound = ''; - foreach ($arraySourcedir as $file) { - if ($file['name'] == $nomFichierModifie) { - $fileContent = file_get_contents($file['fullname']); - $matches = array(); - if (preg_match("/page\d+\.tpl\.php/", $fileContent, $matches)) { - $filesFound = $matches[0]; - break; - } - } - } - foreach ($arraySourcedir as $file) { - if ($file['name'] == $filesFound) { - if (!is_writable($file['fullname'])) { - dolChmod($file['fullname'], '0664'); - } - $diff = $this->showDifferences(file_get_contents($destdir.'/containers/'."page" . $nextpage . ".tpl.php"), file_get_contents($file['fullname']), array($nextpage,$this->extractNumberFromFilename($file['name']))); - if ($diff != -1) { - $replace = $this->replaceLineUsingNum($destdir.'/containers/'."page" . $nextpage . ".tpl.php", $diff); - if ($replace !== false) { - setEventMessages("Copy file page".$nextpage.".tpl.php in template ".$this->name_template." with success", null, 'warnings'); - } - } - } - } - } - } - - $this->saveState($etatPrecedent, $fichierEtat); - setEventMessages("file ".$nomFichierModifie." was created in template ".$website->name_template."", null, 'warnings'); - - header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website->ref); - exit(); - } - } else { - setEventMessages("Error, target dir containers not found", null, 'errors'); - $error = 1; - break; - } - } - - // Find the corresponding file in the destination folder - if (!$error && in_array($nomFichierModifie, $namesSource)) { - foreach ($arraydestdir as $destFile) { - if ($destFile['name'] == $nomFichierModifie) { - $sourceContent = file_get_contents($fichierModifie['fullname']); - $destContent = file_get_contents($destFile['fullname']); - - if ($sourceContent !== $destContent) { - $differences[$nomFichierModifie] = $this->showDifferences($destContent, $sourceContent); - if (count($differences[$nomFichierModifie]) > 0) { - $result = $this->replaceLineUsingNum($destFile['fullname'], $differences[$nomFichierModifie]); - if ($result >= 0) { - setEventMessages("file ".$nomFichierModifie." was modified in template ".$website->name_template."", null, 'warnings'); - } else { - if ($result == -2) { - setEventMessages("No permissions to write into file ".$destdirrel.'/'.$nomFichierModifie." from the current website ".$website->name_template."", null, 'errors'); - - header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website->ref); - exit(); - } - setEventMessages("file ".$nomFichierModifie." was not modified", null, 'errors'); - } - } - } - } - - if (preg_match('/page(\d+)\.tpl\.php/', $nomFichierModifie)) { - $differences[$nomFichierModifie] = $this->compareFichierModifie($sourcedir, $destdir, $fichierModifie); - if (count($differences[$nomFichierModifie]) > 0) { - $result = $this->replaceLineUsingNum($differences[$nomFichierModifie]['file_destination']['fullname'], $differences[$nomFichierModifie]); - if ($result !== false) { - if ($result == -2) { - setEventMessages("No permissions to write into file ".$destdirrel.'/'.$differences[$nomFichierModifie]['file_destination']['name']." from the current website ".$website->name_template."", null, 'errors'); - header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website->ref); - exit(); - } - $success++; - } - } - } - } - } - } - if ($success > 0) { - // Save the state file filelist.txt - $this->saveState($etatPrecedent, $fichierEtat); - setEventMessages("file ".$differences[$nomFichierModifie]['file_destination']['name']." was modified in template ".$website->name_template."", null, 'warnings'); - - header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website->ref); - exit(); - } - } else { - setEventMessages("No file has been modified", null, 'errors'); - } - - // save state file - if (!$error) { - $this->saveState($etatPrecedent, $fichierEtat); - } - */ - header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website->ref); exit(); } @@ -1904,38 +1788,6 @@ class Website extends CommonObject return file_put_contents($pathname, serialize($etat)); } - /** - * create file for save state of all files in folder - * - * @param string $sourcedir path of folder - * @return void - */ - /* - public function initFilesStatus($sourcedir) - { - $fichierEtat = $sourcedir . '/filelist-lastwrite-doctemplates.txt'; - - $etatPrecedent = $this->checkPreviousState($fichierEtat); - - // for first save state when create file - if (empty($etatPrecedent)) { - $arraySourcedir = dol_dir_list($sourcedir, "files"); - $etatFichiers = []; - - foreach ($arraySourcedir as $file) { - // Ignore .old files and the status file itself - if (substr($file['name'], -4) === '.old' || $file['name'] === basename($fichierEtat)) { - continue; - } - - $hashActuel = hash_file('md5', $file['fullname']); - $etatFichiers[$file['name']] = $hashActuel; - } - $this->saveState($etatFichiers, $fichierEtat); - } - } - */ - /** * Compare two files has not same name but same content * @param string $dossierSource filepath of folder source diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index fd684229dd1..f7d8829bd71 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -5,6 +5,7 @@ * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2020 Nicolas ZABOURI * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -57,7 +58,7 @@ class WebsitePage extends CommonObject public $fk_element = 'fk_website_page'; /** - * @var array List of child tables. To know object to delete on cascade. + * @var string[] List of child tables. To know object to delete on cascade. */ protected $childtablesoncascade = array('categorie_website_page'); @@ -162,7 +163,7 @@ class WebsitePage extends CommonObject // BEGIN MODULEBUILDER PROPERTIES /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'index' => 1, 'position' => 1, 'comment' => 'Id'), @@ -515,6 +516,7 @@ class WebsitePage extends CommonObject $sql = 'SELECT COUNT(t.rowid) as nb'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= ' WHERE t.fk_website = '.((int) $websiteid); + // Manage filter (same than into fetchAll) $sqlwhere = array(); if (count($filter) > 0) { diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 31b79d9722e..91adc317602 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1,6 +1,7 @@ * Copyright (C) 2020 Nicolas ZABOURI + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -747,6 +748,8 @@ if ($action == 'addsite' && $usercanedit) { } } +'@phan-var-force int $error'; + // Add page/container if ($action == 'addcontainer' && $usercanedit) { dol_mkdir($pathofwebsite); @@ -761,6 +764,7 @@ if ($action == 'addcontainer' && $usercanedit) { $grabimagesinto = GETPOST('grabimagesinto', 'alpha'); include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; + // The include seems to break typing on variables if (empty($urltograb)) { $error++; @@ -1151,7 +1155,17 @@ if ($action == 'addcontainer' && $usercanedit) { $substitutionarray = array(); $substitutionarray['__WEBSITE_CREATE_BY__'] = $user->getFullName($langs); - // Define id of page the new page is translation of + // Define id of the page the new page is translation of + /* + if ($objectpage->lang == $object->lang) { + // If + $pageidfortranslation = (GETPOSTINT('pageidfortranslation') > 0 ? GETPOSTINT('pageidfortranslation') : 0); + if ($pageidfortranslation > 0) { + // We must update the page $pageidfortranslation to set fk_page = $object->id. + // But what if page $pageidfortranslation is already linked to another ? + } + } else { + */ $pageidfortranslation = (GETPOSTINT('pageidfortranslation') > 0 ? GETPOSTINT('pageidfortranslation') : 0); if ($pageidfortranslation > 0) { // Check if the page we are translation of is already a translation of a source page. if yes, we will use source id instead @@ -1162,6 +1176,7 @@ if ($action == 'addcontainer' && $usercanedit) { } } $objectpage->fk_page = $pageidfortranslation; + //} $sample = GETPOST('sample', 'alpha'); if (empty($sample)) { @@ -2402,6 +2417,22 @@ if ($usercanedit && (($action == 'updatesource' || $action == 'updatecontent' || } } +if ($action == 'deletelang' && $usercanedit) { + $sql = "UPDATE ".MAIN_DB_PREFIX."website_page SET fk_page = NULL"; + $sql .= " WHERE rowid = ".GETPOSTINT('deletelangforid'); + //$sql .= " AND fk_page = ".((int) $objectpage->id); + + $resql = $db->query($sql); + if (!$resql) { + setEventMessages($db->lasterror(), null, 'errors'); + } else { + $objectpage->fk_page = null; + } + + $action = 'editmeta'; +} + + // Export site if ($action == 'exportsite' && $user->hasRight('website', 'export')) { $fileofzip = $object->exportWebSite(); @@ -4356,7 +4387,9 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties if ($i > 0) { $tmpstring .= '
'; } - $tmpstring .= $tmppage->getNomUrl(1).' ('.$tmppage->lang.')'; + $tmpstring .= $tmppage->getNomUrl(1).' '.picto_from_langcode($tmppage->lang).' '.$tmppage->lang; + // Button unlink + $tmpstring .= ' id).'">'.img_picto($langs->trans("Remove"), 'unlink').''; $translatedby++; $i++; } @@ -4372,17 +4405,27 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties dol_print_error($db); } } - if (empty($translatedby) && ($action == 'editmeta' || $action == 'createcontainer' || $objectpage->fk_page > 0)) { + if ((empty($translatedby) || ($objectpage->lang != $object->lang)) && ($action == 'editmeta' || $action == 'createcontainer' || $objectpage->fk_page > 0)) { $sourcepage = new WebsitePage($db); - $result = $sourcepage->fetch($objectpage->fk_page); - if ($result == 0) { - // not found, we can reset value to clean database - } elseif ($result > 0) { + $result = 1; + if ($objectpage->fk_page > 0) { + $result = $sourcepage->fetch($objectpage->fk_page); + if ($result == 0) { + // not found, we can reset value to clean database + // TODO + } + } + if ($result >= 0) { + if ($translatedby) { + print '
'; + } $translationof = $objectpage->fk_page; print ''.$langs->trans('ThisPageIsTranslationOf').' '; - print $formwebsite->selectContainer($website, 'pageidfortranslation', ($translationof ? $translationof : -1), 1, $action, 'minwidth300', array($objectpage->id)); + print $sourcepage->getNomUrl(2).' '.$formwebsite->selectContainer($website, 'pageidfortranslation', ($translationof ? $translationof : -1), 1, $action, 'minwidth300', array($objectpage->id)); if ($translationof > 0 && $sourcepage->lang) { - print $sourcepage->getNomUrl(2).' ('.$sourcepage->lang.')'; + print picto_from_langcode($sourcepage->lang).' '.$sourcepage->lang; + // Button unlink + print ' id).'">'.img_picto($langs->trans("Remove"), 'unlink').''; } } } @@ -5157,6 +5200,12 @@ if ((empty($action) || $action == 'preview' || $action == 'createfromclone' || $ //var_dump($filetpl); $filephp = $filetpl; + + // Get session info and obfuscate session cookie + $savsessionname = session_name(); + $savsessionid = $_COOKIE[$savsessionname]; + $_COOKIE[$savsessionname] = 'obfuscatedcookie'; + ob_start(); try { $res = include $filephp; @@ -5168,6 +5217,9 @@ if ((empty($action) || $action == 'preview' || $action == 'createfromclone' || $ } $newcontent = ob_get_contents(); ob_end_clean(); + + // Restore data + $_COOKIE[$savsessionname] = $savsessionid; } // Change the contenteditable to "true" or "false" when mode Edit Inline is on or off diff --git a/htdocs/workstation/class/workstation.class.php b/htdocs/workstation/class/workstation.class.php index ad650d6c7b0..8a3e195f0fd 100644 --- a/htdocs/workstation/class/workstation.class.php +++ b/htdocs/workstation/class/workstation.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2020 Gauthier VERDOL * Copyright (C) 2023-2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -95,7 +96,7 @@ class Workstation extends CommonObject // BEGIN MODULEBUILDER PROPERTIES /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => '1', 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => '1', 'index' => 1, 'css' => 'left', 'comment' => "Id"), diff --git a/htdocs/workstation/class/workstationresource.class.php b/htdocs/workstation/class/workstationresource.class.php index c50a8417e90..853bba00724 100644 --- a/htdocs/workstation/class/workstationresource.class.php +++ b/htdocs/workstation/class/workstationresource.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2020 Gauthier VERDOL + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -35,7 +36,7 @@ class WorkstationResource extends CommonObject public $element = 'workstationresource'; /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( 'fk_workstation' => array('type' => 'integer'), diff --git a/htdocs/workstation/class/workstationusergroup.class.php b/htdocs/workstation/class/workstationusergroup.class.php index e53bee221ef..54e342ba09a 100644 --- a/htdocs/workstation/class/workstationusergroup.class.php +++ b/htdocs/workstation/class/workstationusergroup.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2020 Gauthier VERDOL + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,7 +35,7 @@ class WorkstationUserGroup extends CommonObject public $element = 'workstationusergroup'; /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( 'fk_workstation' => array('type' => 'integer'), diff --git a/htdocs/workstation/workstation_agenda.php b/htdocs/workstation/workstation_agenda.php index cf25d186ae8..4e6853596bc 100644 --- a/htdocs/workstation/workstation_agenda.php +++ b/htdocs/workstation/workstation_agenda.php @@ -100,7 +100,7 @@ restrictedArea($user, $object->element, $object->id, $object->table_element, 'wo * Actions */ -$parameters = array('id'=>$id); +$parameters = array('id' => $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'); @@ -206,14 +206,14 @@ if ($object->id > 0) { $objthirdparty = $object; $objcon = new stdClass(); - $out = '&origin='.urlencode($object->element.'@'.$object->module).'&originid='.urlencode($object->id); + $out = '&origin='.urlencode((string) ($object->element.'@'.$object->module)).'&originid='.urlencode((string) ($object->id)); $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id; $out .= '&backtopage='.urlencode($urlbacktopage); $permok = $user->hasRight('agenda', 'myactions', 'create'); if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.=' * Copyright (C) 2019-2024 Frédéric France + * Copyright (C) 2024 MDW * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -80,7 +81,7 @@ class Hook extends CommonObject */ /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( 'rowid' => array( diff --git a/phpstan.neon b/phpstan.neon.dist similarity index 86% rename from phpstan.neon rename to phpstan.neon.dist index 8951e8ddaa2..78867274e30 100644 --- a/phpstan.neon +++ b/phpstan.neon.dist @@ -1,11 +1,13 @@ parameters: tmpDir: ./.github/tmp parallel: - jobSize: 8 + # Commented some of the settings, reminding the defaults: + # should adapt better to target machines + # jobSize: 8 # default is 20 processTimeout: 600.0 - maximumNumberOfProcesses: 20 - minimumNumberOfJobsPerProcess: 2 - buffer: 134217728 # 128 MB + # maximumNumberOfProcesses: 20 # default is 32 + # minimumNumberOfJobsPerProcess: 2 # default is 2 + # buffer: 134217728 # 128 MB # Not documented customRulesetUsed: true level: 2 fileExtensions: @@ -13,13 +15,6 @@ parameters: paths: - htdocs - scripts - stubFiles: - # - dev/tools/phan/stubs/GeoIP2.php - # - dev/tools/phan/stubs/geoip_inc.php - - dev/tools/phan/stubs/module_numberwords.php - - dev/tools/phan/stubs/restler.php - - dev/tools/phan/stubs/stripe.php - - dev/tools/phan/stubs/swiss-qr-bill.php excludePaths: analyseAndScan: - htdocs/custom/* diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index 9848ac2185e..633b0b61216 100644 --- a/test/phpunit/AllTests.php +++ b/test/phpunit/AllTests.php @@ -27,8 +27,10 @@ print "PHP Version: ".phpversion()."\n"; print "Memory limit: ". ini_get('memory_limit')."\n"; -// Workaround for false security issue with main.inc.php in tests: -$_SERVER['PHP_SELF'] = "phpunit"; +// Workaround for false security issue with main.inc.php on Windows in tests: +if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { + $_SERVER['PHP_SELF'] = "phpunit"; +} global $conf,$user,$langs,$db; //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver diff --git a/test/phpunit/CommonClassTest.class.php b/test/phpunit/CommonClassTest.class.php index 2be3f58362f..399f972863c 100644 --- a/test/phpunit/CommonClassTest.class.php +++ b/test/phpunit/CommonClassTest.class.php @@ -26,11 +26,18 @@ * \remarks Class that extends all PHPunit tests. To share similare code between each test. */ +// Workaround for false security issue with main.inc.php on Windows in tests: +if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { + $_SERVER['PHP_SELF'] = "phpunit"; +} + global $conf,$user,$langs,$db; //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver //require_once 'PHPUnit/Autoload.php'; require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; + + if (empty($user->id)) { print "Load permissions for admin user nb 1\n"; $user->fetch(1); @@ -240,7 +247,7 @@ abstract class CommonClassTest extends TestCase 'commande' => 'order', 'contrat' => 'contract', 'entrepot' => 'stock', - 'expedition' => 'delivery_note', + 'expedition' => 'shipping', 'facture' => 'invoice', 'fichinter' => 'intervention', 'product_fournisseur_price' => 'productsupplierprice', @@ -289,7 +296,7 @@ abstract class CommonClassTest extends TestCase 'datapolicy' => 'DataPolicy', 'dav' => 'Dav', 'debugbar' => 'DebugBar', - 'delivery_note' => 'Expedition', + 'shipping' => 'Expedition', 'deplacement' => 'Deplacement', "documentgeneration" => 'DocumentGeneration', // TODO: fill in proper name 'don' => 'Don', diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index 91cdcc816bd..32616542c2a 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -247,6 +247,7 @@ class FilesLibTest extends CommonClassTest * testDolCopyMoveDelete * * @return void + * @group WindowsWaitingForFix */ public function testDolCopyMoveDelete() { @@ -490,6 +491,7 @@ class FilesLibTest extends CommonClassTest * testDolDirMove * * @return void + * @group WindowsWaitingForFix */ public function testDolDirMove() { diff --git a/test/phpunit/Functions2LibTest.php b/test/phpunit/Functions2LibTest.php index 1d987d5aac5..081061a08ed 100644 --- a/test/phpunit/Functions2LibTest.php +++ b/test/phpunit/Functions2LibTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2023 Alexandre Janniaux + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -205,4 +206,42 @@ class Functions2LibTest extends CommonClassTest print __METHOD__." for ".$ip." result=".$result."\n"; $this->assertEquals(2, $result, $ip); } + + + /** + * Dataprovider for testGetStringBetween + * + * @return array [ "STARTcontentEND", "START", "END", "content"], + 'start does not match' => [ "ScontentEND", "START", "END", ""], + 'end does not match' => [ "STARTcontentN", "START", "END", ""], + 'no match' => [ "content", "START", "END", ""], + 'end before start' => [ "ENDcontentSTART", "START", "END", ""], + 'end inside start' => [ "BAB", "BA", "AB", ""], + 'multiple matches' => [ "BAcontentABBAdoneAB", "BA", "AB", "content"], + ]; + } + + + /** + * Test get_string_between() + * + * @param string $string String to search in. + * @param string $start String indicating start + * @param string $end String indicating end + * @param string $expected Expected result + * + * @return void + * + * @dataProvider stringBetweenDataProvider + */ + public function testGetStringBetween($string, $start, $end, $expected) + { + $this->assertEquals($expected, get_string_between($string, $start, $end)); + } } diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index 8a154897acb..5ff98738cd2 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -53,7 +53,7 @@ if (! defined("NOSESSION")) { define("NOSESSION", '1'); } -require_once dirname(__FILE__).'/../../htdocs/main.inc.php'; +require_once dirname(__FILE__).'/../../htdocs/main.inc.php'; // We force include of main.inc.php instead of master.inc.php even if we are in CLI mode because it contains a lot of security components we want to test. require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php'; require_once dirname(__FILE__).'/CommonClassTest.class.php'; @@ -988,7 +988,7 @@ class SecurityTest extends CommonClassTest include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; - $result=dol_eval('1==1', 1, 0); + $result = dol_eval('1==1', 1, 0); print "result1 = ".$result."\n"; $this->assertTrue($result);