diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 00000000000..fbe406e6c46 --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,16 @@ +# Workflow run order + +To reduce run minutes, the following order is put in place: + +On PR & Merge, always run: + +- pre-commit; +- phan. + +When both succeed, start: + +- phpstan; +- Windows-ci; +- travis. + +See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-a-workflow-based-on-the-conclusion-of-another-workflow diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000000..39edbc3496b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,40 @@ +name: "CI" + +on: [push, pull_request] +jobs: + pre-commit: + uses: ./.github/workflows/pre-commit.yml + secrets: inherit + with: + gh_event: ${{ github.event_name }} + phan: + uses: ./.github/workflows/phan.yml + secrets: inherit + with: + gh_event: ${{ github.event_name }} + phpstan: + uses: ./.github/workflows/phpstan.yml + secrets: inherit + needs: [pre-commit, phan] + with: + gh_event: ${{ github.event_name }} + windows-ci: + needs: [pre-commit, phan] + secrets: inherit + uses: ./.github/workflows/windows-ci.yml + with: + gh_event: ${{ github.event_name }} + gh-travis: # Runs travis script on github runner (not on travis) + if: false + # needs: [pre-commit, phan] + # needs: [windows-ci] + secrets: inherit + uses: ./.github/workflows/gh-travis.yml + with: + gh_event: ${{ github.event_name }} + + +# Note (not tested, from https://github.com/orgs/community/discussions/38361) +# To cancel jobs if one failes, the following action may help +# - if: "failure()" +# uses: "andymckay/cancel-action@0.3" diff --git a/.github/workflows/gh-travis.yml b/.github/workflows/gh-travis.yml new file mode 100644 index 00000000000..30c10765f07 --- /dev/null +++ b/.github/workflows/gh-travis.yml @@ -0,0 +1,49 @@ +--- +# This runs a travis script inside a github runner +name: Travis +# Controls when the workflow will run +on: + # push: + # pull_request: + workflow_call: + inputs: + gh_event: + required: true + type: string + workflow_dispatch: + +concurrency: + group: travis-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref + }} + cancel-in-progress: true +env: + gh_event: ${{ inputs.gh_event || github.event_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: + # This workflow contains a single job + gh-travis: + # The type of runner that the job will run on + runs-on: ubuntu-latest + strategy: + fail-fast: false + # matrix: + # php-version: + # # PHPStan requires PHP >= 7.2. + # #- "7.2" + # - "8.2" + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + - name: Checkout travis file + uses: actions/checkout@v4 + - name: Run .travis.yml build script + uses: ktomk/run-travis-yml@v1 + with: + # run-job: travis # name of a job in travis file + allow-failure: false + # file: .travis.yml + # steps: | # Default: setup, before_install, install, before_script, script, after_script, before_deploy + # install + # script + # env: + # TRAVIS_PHP_VERSION: ${{ matrix.php-version }} diff --git a/.github/workflows/phan.yml b/.github/workflows/phan.yml index 67bec077a13..f233c24907c 100644 --- a/.github/workflows/phan.yml +++ b/.github/workflows/phan.yml @@ -1,16 +1,22 @@ --- on: - pull_request: - push: - schedule: - # execute once a day, the 1st - - cron: 10 9 * * * + # pull_request: + # push: + # schedule: + # # execute once a day, the 1st + # - cron: 10 9 * * * + workflow_call: + inputs: + gh_event: + required: true + type: string workflow_dispatch: + concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + group: phan-${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true env: - # Do pull analysis on schedule or manual dispatch + gh_event: ${{ inputs.gh_event || github.event_name }} PHAN_CONFIG: > ${{ ( github.event.schedule || github.event_name == 'workflow_dispatch' ) @@ -21,6 +27,7 @@ env: PHAN_MIN_PHP: 7.0 PHAN_QUICK: ${{ github.event.schedule && '' || '--quick' }} GITHUB_JSON: ${{ toJSON(github) }} # Helps in debugging Github Action + name: phan jobs: phan: diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index cbe0f4b2732..c638ee83e50 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -1,16 +1,25 @@ +--- # This is a basic workflow to check code with PHPSTAN tool - -name: "PHPStan" - +name: PHPStan # Controls when the workflow will run -on: [push, pull_request] -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true +on: + # push: + # pull_request: + workflow_call: + inputs: + gh_event: + required: true + type: string + workflow_dispatch: +concurrency: + group: stan-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref + }} + 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 }} - GITHUB_JSON: ${{ toJSON(github) }} # Helps in debugging Github Action + gh_event: ${{ inputs.gh_event || github.event_name }} + CACHE_KEY_PART: ${{ ( inputs.gh_event == 'pull_request' || 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: # This workflow contains a single job @@ -23,7 +32,7 @@ jobs: php-version: # PHPStan requires PHP >= 7.2. #- "7.2" - - "8.2" + - '8.2' # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it @@ -34,9 +43,10 @@ jobs: id: setup-php uses: shivammathur/setup-php@v2 with: - php-version: "${{ matrix.php-version }}" + php-version: ${{ matrix.php-version }} tools: phpstan, cs2pr - extensions: calendar, json, imagick, gd, zip, mbstring, intl, opcache, imap, mysql, pgsql, sqlite3, ldap, xml, mcrypt + extensions: calendar, json, imagick, gd, zip, mbstring, intl, opcache, imap, + mysql, pgsql, sqlite3, ldap, xml, mcrypt # Restore old cache - name: Restore phpstan cache @@ -44,7 +54,8 @@ jobs: uses: actions/cache/restore@v4 with: path: ./.github/tmp - key: phpstan-cache-${{ matrix.php-version }}-${{ env.CACHE_KEY_PART }}-${{ github.run_id }} + key: phpstan-cache-${{ matrix.php-version }}-${{ env.CACHE_KEY_PART }}-${{ + github.run_id }} restore-keys: | phpstan-cache-${{ matrix.php-version }}-${{ env.CACHE_KEY_PART }}- phpstan-cache-${{ matrix.php-version }}-${{ github.head_ref }}- @@ -61,12 +72,13 @@ jobs: # continue-on-error: true # Save cache - - name: "Save phpstan cache" + - name: Save phpstan cache uses: actions/cache/save@v4 if: ${{ success() || ( ! cancelled() && steps.cache.outputs.cache-hit != 'true' ) }} with: path: ./.github/tmp - key: phpstan-cache-${{ matrix.php-version }}-${{ env.CACHE_KEY_PART }}-${{ github.run_id }} + key: phpstan-cache-${{ matrix.php-version }}-${{ env.CACHE_KEY_PART }}-${{ + github.run_id }} - name: Provide phpstan log as artifact uses: actions/upload-artifact@v4 if: ${{ always() }} diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 671a266c767..f113a8a7a36 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -1,8 +1,17 @@ --- name: pre-commit on: - pull_request: - push: + # pull_request: + # push: + workflow_call: + inputs: + gh_event: + required: true + type: string + workflow_dispatch: + +env: + gh_event: ${{ inputs.gh_event || github.event_name }} jobs: pre-commit: runs-on: ubuntu-latest @@ -20,7 +29,7 @@ jobs: - name: Get all changed php files (if PR) id: changed-php uses: tj-actions/changed-files@v43 - if: github.event_name == 'pull_request' + if: env.gh_event == 'pull_request' with: files: | **.php @@ -58,7 +67,7 @@ jobs: # - name: Get all changed php files (if PR) # id: changed-php # uses: tj-actions/changed-files@v43 - # if: github.event_name == 'pull_request' + # if: env.gh_event == 'pull_request' # with: # files: | # **.php @@ -72,7 +81,7 @@ jobs: steps.changed-php.outputs.any_changed == 'true' || ( - github.event_name == 'push' + env.gh_event == 'push' && ( github.event.ref == 'refs/heads/develop' || endsWith(github.event.ref, '.0') @@ -94,7 +103,7 @@ jobs: - name: Run some pre-commit hooks on all files on push to "main" branches if: | - github.event_name == 'push' + env.gh_event == 'push' && ( github.event.ref == 'refs/heads/develop' || endsWith(github.event.ref, '.0') diff --git a/.github/workflows/windows-ci.yaml b/.github/workflows/windows-ci.yml similarity index 94% rename from .github/workflows/windows-ci.yaml rename to .github/workflows/windows-ci.yml index cb467055156..f85ad2535be 100644 --- a/.github/workflows/windows-ci.yaml +++ b/.github/workflows/windows-ci.yml @@ -2,19 +2,26 @@ name: Win CI # yamllint disable-line rule:truthy on: - push: - pull_request: + # push: + # pull_request: + workflow_call: + inputs: + gh_event: + required: true + type: string workflow_dispatch: + concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref + group: win-ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true env: + gh_event: ${{ inputs.gh_event || github.event_name }} PHPUNIT_LOG: phpunit_tests.log DOLIBARR_LOG: documents/dolibarr.log PHPSERVER_LOG: phpserver.log PHPSERVER_DOMAIN_PORT: 127.0.0.1:8000 # could be 127.0.0.1:8000 if config modified - CACHE_KEY_PART: ${{ github.event_name == 'pull_request' && format('{0}-{1}', github.base_ref, github.head_ref) || github.ref_name }} + CACHE_KEY_PART: ${{ ( inputs.gh_event == 'pull_request' || github.event_name == 'pull_request' ) && format('{0}-{1}', github.base_ref, github.head_ref) || github.ref_name }} PHP_INI_SCAN_DIR: C:\myphpini CKEY: win-ci-2 GITHUB_JSON: ${{ toJSON(github) }} # Helps in debugging Github Action diff --git a/COPYRIGHT b/COPYRIGHT index e6525d5ccb2..a94d93ede38 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -68,7 +68,7 @@ jQuery jqueryFileTree 1.0.1 GPL and MIT License Yes jQuery jquerytreeview 1.4.1 MIT License Yes JS library for filetree jQuery TableDnD 0.6 GPL and MIT License Yes JS library plugin TableDnD (to reorder table rows) jQuery Timepicker 1.1.0 GPL and MIT License Yes JS library Timepicker addon for Datepicker -jsGanttImproved 2.7.3 BSD License Yes JS library (to build Gantt reports) +jsGanttImproved 2.8.10 BSD License Yes JS library (to build Gantt reports) SwaggerUI 2.2.10 GPL-2+ Yes JS library to offer the REST API explorer Image libraries: diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index 58723960150..3f62333d5e8 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -31,7 +31,7 @@ Replace: d.items&& With d&&d.items&& - + ESCPOS: ------- @@ -55,8 +55,8 @@ NUSOAP: * Line 1257 of file nusoap.php. Add: libxml_disable_entity_loader(true); // Avoid load of external entities (security problem). Required only for libxml < 2. - - + + * Line 4346 of file nusoap.php $rev = array(); @@ -128,13 +128,13 @@ with if (!@TCPDF_STATIC::file_exists($file)) { // DOL CHANGE If we keep this, the image is not visible on pages after the first one. //var_dump($file.' '.(!@TCPDF_STATIC::file_exists($file))); - //return false; + //return false; $tfile = str_replace(' ', '%20', $file); if (@TCPDF_STATIC::file_exists($tfile)) { $file = $tfile; } } - + * Replace in tcpdf.php: if (($imgsrc[0] === '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) { with @@ -174,7 +174,7 @@ with imagesetpixel($imgalpha, $xpx, $ypx, $alpha); into imagesetpixel($imgalpha, $xpx, $ypx, (int) $alpha); - + * Removed useless directories ("examples", "tools") * Optionally, removed all fonts except @@ -243,7 +243,7 @@ with: with foreach ($value[1] as $k => $v) { -* Fix by replacing +* Fix by replacing if ($res[0] == PDF_TYPE_OBJECT) with if (isset($res[0]) && $res[0] == PDF_TYPE_OBJECT) @@ -253,23 +253,16 @@ with JSGANTT: -------- * Replace in function JSGantt.taskLink - var OpenWindow=window.open(pRef, "newwin", "height="+vHeight+",width="+vWidth); + window.open(pRef, 'newwin', 'height=' + vHeight + ',width=' + vWidth); with - // LDR To open in same window + // @CHANGE DOLI To open in same window //var OpenWindow=window.open(pRef, "newwin", "height="+vHeight+",width="+vWidth); window.location.href=pRef -* Replace - vTmpDiv=this.newNode(vTmpCell, 'div', null, null, vTaskList[i].getResource()); -with - var vTmpNode=this.newNode(vTmpCell, 'div', null, ''); - vTmpNode=this.newNode(vTmpNode, 'a', null, '', vLangs[vLang]['moreinfo']); - vTmpNode.setAttribute('href',vTaskList[i].getLink()); - * Replace '% Comp.' to have a smaller text column header - 'comp':'% Comp.' + 'comp': '%...' with - 'comp':'%' + 'comp': '%' @@ -307,19 +300,19 @@ RESTLER: // @CHANGE LDR if (!is_string($haystack)) return false; -* Replace +* Replace $loaders = array_unique(static::$rogueLoaders); - - with - + + with + $loaders = array_unique(static::$rogueLoaders, SORT_REGULAR); - + * Replace CommentParser.php line 423 elseif (count($value) && is_numeric($value[0])) - + with - + elseif (count($value) && isset($value[0]) && is_numeric($value[0])) * Add CommentParser.php line 406 & 407 to remove a warning on api request in php 8.1 @@ -417,5 +410,3 @@ Edit CSS to restore line removed between 4.0.5 and 4.0.6. It generates this bug: .select2-hidden-accessible { margin: -10000px !important; /* line to restore */ } - - diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index f39b1262064..52c70f4f641 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -47,7 +47,7 @@ return [ 'htdocs/core/lib/functions.lib.php' => ['PhanParamTooMany', 'PhanRedefineFunctionInternal'], 'htdocs/core/lib/price.lib.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/core/modules/movement/doc/pdf_standard.modules.php' => ['PhanPluginDuplicateExpressionBinaryOp'], - 'htdocs/core/modules/mrp/doc/pdf_vinci.modules.php' => ['PhanTypeArraySuspiciousNull'], + 'htdocs/core/modules/mrp/doc/pdf_vinci.modules.php' => ['PhanTypeArraySuspiciousNull', 'PhanTypeInvalidRightOperandOfAdd'], 'htdocs/core/modules/syslog/mod_syslog_file.php' => ['PhanParamSignatureMismatch'], 'htdocs/core/modules/syslog/mod_syslog_syslog.php' => ['PhanParamSignatureMismatch'], 'htdocs/don/class/don.class.php' => ['PhanParamTooMany'], diff --git a/dev/tools/phan/config.php b/dev/tools/phan/config.php index 01043b3adc3..5de8de73754 100644 --- a/dev/tools/phan/config.php +++ b/dev/tools/phan/config.php @@ -463,7 +463,7 @@ return [ // 'PhanTypeMismatchPropertyProbablyReal', // 'PhanPluginNoCommentOnPrivateMethod', 'PhanPluginUnknownArrayFunctionReturnType', - 'PhanTypeInvalidLeftOperandOfAdd', + // 'PhanTypeInvalidLeftOperandOfAdd', // 'PhanPluginNoCommentOnPrivateProperty', // 'PhanPluginNoCommentOnFunction', 'PhanPluginUnknownArrayFunctionParamType', @@ -473,14 +473,14 @@ return [ // 'PhanPluginRedundantAssignment', 'PhanTypeExpectedObjectPropAccess', - 'PhanTypeInvalidRightOperandOfNumericOp', + // 'PhanTypeInvalidRightOperandOfNumericOp', // 'PhanPluginInlineHTML', // 'PhanPluginInlineHTMLTrailing', // 'PhanPluginUnknownFunctionReturnType', // 'PhanPluginDescriptionlessCommentOnProtectedProperty', 'PhanPluginRedundantAssignmentInGlobalScope', // 'PhanTypeMismatchDeclaredParamNullable', - 'PhanTypeInvalidRightOperandOfAdd', + // 'PhanTypeInvalidRightOperandOfAdd', // 'PhanPluginDescriptionlessCommentOnPrivateProperty', // 'PhanUndeclaredVariableDim', // Array initialisation on undeclared var: $abc['x']='ab' 'PhanTypeInvalidPropertyName', @@ -600,7 +600,7 @@ return [ // 'PhanPluginUnreachableCode', // 'PhanTypeMismatchArgumentInternal', // 'PhanPluginAlwaysReturnMethod', - 'PhanUndeclaredClassMethod', + // 'PhanUndeclaredClassMethod', 'PhanUndeclaredMethod', 'PhanTypeMismatchArgumentProbablyReal', 'PhanPluginDuplicateExpressionAssignmentOperation', // Suggestions for optimisation @@ -608,7 +608,7 @@ return [ // 'PhanPluginAlwaysReturnMethod', // 'PhanPluginMissingReturnMethod', // 'PhanUndeclaredTypeReturnType', - 'PhanUndeclaredClassProperty', + // 'PhanUndeclaredClassProperty', 'PhanTypeArraySuspiciousNullable', // 'PhanPluginInconsistentReturnMethod', 'PhanTypeExpectedObjectPropAccessButGotNull', @@ -643,11 +643,13 @@ return [ 'ftp' => PHAN_DIR . '/stubs/ftp.phan_php', 'gd' => PHAN_DIR . '/stubs/gd.phan_php', 'geoip' => PHAN_DIR . '/stubs/geoip.phan_php', + 'imagick' => PHAN_DIR . '/stubs/imagick.phan_php', 'imap' => PHAN_DIR . '/stubs/imap.phan_php', 'intl' => PHAN_DIR . '/stubs/intl.phan_php', 'ldap' => PHAN_DIR . '/stubs/ldap.phan_php', 'mcrypt' => PHAN_DIR . '/stubs/mcrypt.phan_php', 'memcache' => PHAN_DIR . '/stubs/memcache.phan_php', + 'memcached' => PHAN_DIR . '/stubs/memcached.phan_php', 'mysqli' => PHAN_DIR . '/stubs/mysqli.phan_php', 'pdo_cubrid' => PHAN_DIR . '/stubs/pdo_cubrid.phan_php', 'pdo_mysql' => PHAN_DIR . '/stubs/pdo_mysql.phan_php', @@ -658,6 +660,7 @@ return [ 'simplexml' => PHAN_DIR . '/stubs/SimpleXML.phan_php', 'soap' => PHAN_DIR . '/stubs/soap.phan_php', 'sockets' => PHAN_DIR . '/stubs/sockets.phan_php', + 'tidy' => PHAN_DIR . '/stubs/tidy.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 b5f0123526c..6fdb39c0621 100644 --- a/dev/tools/phan/config_extended.php +++ b/dev/tools/phan/config_extended.php @@ -397,10 +397,12 @@ return [ 'gd' => PHAN_DIR . '/stubs/gd.phan_php', 'geoip' => PHAN_DIR . '/stubs/geoip.phan_php', 'imap' => PHAN_DIR . '/stubs/imap.phan_php', + 'imagick' => PHAN_DIR . '/stubs/imagick.phan_php', 'intl' => PHAN_DIR . '/stubs/intl.phan_php', 'ldap' => PHAN_DIR . '/stubs/ldap.phan_php', 'mcrypt' => PHAN_DIR . '/stubs/mcrypt.phan_php', 'memcache' => PHAN_DIR . '/stubs/memcache.phan_php', + 'memcached' => PHAN_DIR . '/stubs/memcached.phan_php', 'mysqli' => PHAN_DIR . '/stubs/mysqli.phan_php', 'pdo_cubrid' => PHAN_DIR . '/stubs/pdo_cubrid.phan_php', 'pdo_mysql' => PHAN_DIR . '/stubs/pdo_mysql.phan_php', @@ -411,6 +413,7 @@ return [ 'simplexml' => PHAN_DIR . '/stubs/SimpleXML.phan_php', 'soap' => PHAN_DIR . '/stubs/soap.phan_php', 'sockets' => PHAN_DIR . '/stubs/sockets.phan_php', + 'tidy' => PHAN_DIR . '/stubs/tidy.phan_php', 'zip' => PHAN_DIR . '/stubs/zip.phan_php', ], diff --git a/dev/tools/phan/config_fixer.php b/dev/tools/phan/config_fixer.php index b12c94d6468..5df01eb7ae6 100644 --- a/dev/tools/phan/config_fixer.php +++ b/dev/tools/phan/config_fixer.php @@ -228,10 +228,12 @@ return [ 'gd' => PHAN_DIR . '/stubs/gd.phan_php', 'geoip' => PHAN_DIR . '/stubs/geoip.phan_php', 'imap' => PHAN_DIR . '/stubs/imap.phan_php', + 'imagick' => PHAN_DIR . '/stubs/imagick.phan_php', 'intl' => PHAN_DIR . '/stubs/intl.phan_php', 'ldap' => PHAN_DIR . '/stubs/ldap.phan_php', 'mcrypt' => PHAN_DIR . '/stubs/mcrypt.phan_php', 'memcache' => PHAN_DIR . '/stubs/memcache.phan_php', + 'memcached' => PHAN_DIR . '/stubs/memcached.phan_php', 'mysqli' => PHAN_DIR . '/stubs/mysqli.phan_php', 'pdo_cubrid' => PHAN_DIR . '/stubs/pdo_cubrid.phan_php', 'pdo_mysql' => PHAN_DIR . '/stubs/pdo_mysql.phan_php', @@ -241,6 +243,7 @@ return [ 'session' => PHAN_DIR . '/stubs/session.phan_php', 'simplexml' => PHAN_DIR . '/stubs/SimpleXML.phan_php', 'soap' => PHAN_DIR . '/stubs/soap.phan_php', + 'tidy' => PHAN_DIR . '/stubs/tidy.phan_php', 'sockets' => PHAN_DIR . '/stubs/sockets.phan_php', 'zip' => PHAN_DIR . '/stubs/zip.phan_php', ], diff --git a/dev/tools/phan/stubs/imagick.phan_php b/dev/tools/phan/stubs/imagick.phan_php new file mode 100644 index 00000000000..e9bb9db450a --- /dev/null +++ b/dev/tools/phan/stubs/imagick.phan_php @@ -0,0 +1,1216 @@ + + */ +class ActionsMulticompany +{ + /** + * @param DoliDB $db + */ + public function __construct($db) + { + } + /** @ver string */ + public $id; + /** @ver string */ + public $label; + /** @var array{stock:string[],referent:string} */ + public $sharings; + /** @ver DoliDB */ + public $db; +} diff --git a/dev/tools/phan/stubs/tidy.phan_php b/dev/tools/phan/stubs/tidy.phan_php new file mode 100644 index 00000000000..5ac1bc69f4e --- /dev/null +++ b/dev/tools/phan/stubs/tidy.phan_php @@ -0,0 +1,244 @@ +trans(\$key.'SomeString')." echo "## You can add such dynamic keys to $(basename "$DYNAMIC_KEYS_SRC_FILE")" echo "## so that they are ignored for this report." - echo "## :warning: Unused Translations may be commented in the code" + echo "## :warning: Unused Translations may also be commented in the code" echo "## You can add such 'disabled' keys to $(basename "$EXCLUDE_KEYS_SRC_FILE")" echo "## so that they are ignored for this report." echo diff --git a/htdocs/accountancy/admin/subaccount.php b/htdocs/accountancy/admin/subaccount.php index 188915b0ec0..5e30c3d0a50 100644 --- a/htdocs/accountancy/admin/subaccount.php +++ b/htdocs/accountancy/admin/subaccount.php @@ -44,7 +44,7 @@ $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'ac $search_subaccount = GETPOST('search_subaccount', 'alpha'); $search_label = GETPOST('search_label', 'alpha'); -$search_type = GETPOSTINT('search_type'); +$search_type = GETPOST('search_type', 'intcomma'); // Security check if ($user->socid > 0) { @@ -128,6 +128,7 @@ $form = new Form($db); // Page Header $help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration'; $title = $langs->trans('ChartOfIndividualAccountsOfSubsidiaryLedger'); + llxHeader('', $title, $help_url); @@ -300,14 +301,17 @@ if ($resql) { if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.((int) $limit); } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } if ($search_subaccount) { $param .= '&search_subaccount='.urlencode($search_subaccount); } if ($search_label) { $param .= '&search_label='.urlencode($search_label); } - if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); + if ($search_type) { + $param .= '&search_type='.urlencode($search_type); } // List of mass actions available @@ -373,7 +377,7 @@ if ($resql) { print ''; // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center maxwidthsearch '); } if (!empty($arrayfields['subaccount']['checked'])) { print_liste_field_titre($arrayfields['subaccount']['label'], $_SERVER["PHP_SELF"], "subaccount", "", $param, '', $sortfield, $sortorder); @@ -391,7 +395,7 @@ if ($resql) { } // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center maxwidthsearch '); } print "\n"; diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index b27805ca1a7..8dc85fb642c 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -475,9 +475,9 @@ if ($action != 'export_csv') { $resql = $db->query($sql); $opening_balances = array(); if ($resql) { - $nrows = $resql->num_rows; + $nrows = $db->num_rows($resql); for ($i = 0; $i < $nrows; $i++) { - $arr = $resql->fetch_array(); + $arr = $db->fetch_array($resql); $opening_balances["'" . $arr['numero_compte'] . "'"] = $arr['opening_balance']; } } diff --git a/htdocs/accountancy/bookkeeping/export.php b/htdocs/accountancy/bookkeeping/export.php index cb9e8ea09d4..72aee30478d 100644 --- a/htdocs/accountancy/bookkeeping/export.php +++ b/htdocs/accountancy/bookkeeping/export.php @@ -726,7 +726,7 @@ if ($action == 'export_fileconfirm' && $user->hasRight('accounting', 'mouvements setEventMessages('', $accountancyexport->errors, 'errors'); header('Location: '.$_SERVER['PHP_SELF']); } - exit(); // download or show errors + exit(0); // download or show errors } @@ -845,7 +845,7 @@ if ($action == 'export_file') { ); } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans("ExportFilteredList").'...', $langs->trans('ConfirmExportFile'), 'export_fileconfirm', $form_question, '', 1, 420, 600); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans("ExportFilteredList").'...', $langs->trans('ConfirmExportFile'), 'export_fileconfirm', $form_question, '', 1, 390, 700); } // Print form confirm @@ -924,12 +924,15 @@ if ($massactionbutton && $contextpage != 'poslist') { } $moreforfilter = ''; -$moreforfilter .= '
'; -$moreforfilter .= $langs->trans('AccountingCategory').': '; -$moreforfilter .= '
'; -$moreforfilter .= $formaccounting->select_accounting_category($search_account_category, 'search_account_category', 1, 0, 0, 0); -$moreforfilter .= '
'; -$moreforfilter .= '
'; + +if (!empty($search_account_category)) { + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('AccountingCategory').': '; + $moreforfilter .= '
'; + $moreforfilter .= $formaccounting->select_accounting_category($search_account_category, 'search_account_category', 1, 0, 0, 0); + $moreforfilter .= '
'; + $moreforfilter .= '
'; +} $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -939,9 +942,11 @@ if (empty($reshook)) { $moreforfilter = $hookmanager->resPrint; } -print '
'; -print $moreforfilter; -print '
'; +if ($moreforfilter) { + print '
'; + print $moreforfilter; + print '
'; +} print '
'; print ''; @@ -999,10 +1004,10 @@ if (!empty($arrayfields['t.subledger_account']['checked'])) { if (getDolGlobalString('ACCOUNTANCY_COMBO_FOR_AUX')) { print '
'; //print $langs->trans('From').' '; - print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', $langs->trans('From'), 'maxwidth250', 'subledgeraccount'); + print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', $langs->trans('From'), 'maxwidth150', 'subledgeraccount'); print '
'; print '
'; - print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', $langs->trans('to'), 'maxwidth250', 'subledgeraccount'); + print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', $langs->trans('to'), 'maxwidth150', 'subledgeraccount'); print '
'; } else { print ''; @@ -1257,6 +1262,7 @@ while ($i < min($num, $limit)) { // Document ref if (!empty($arrayfields['t.doc_ref']['checked'])) { + $documentlink = ''; if ($line->doc_type == 'customer_invoice') { $langs->loadLangs(array('bills')); @@ -1265,10 +1271,12 @@ while ($i < min($num, $limit)) { $objectstatic->fetch($line->fk_doc); //$modulepart = 'facture'; - $filename = dol_sanitizeFileName($line->doc_ref); - $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; - $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + if ($objectstatic->id > 0) { + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + } } elseif ($line->doc_type == 'supplier_invoice') { $langs->loadLangs(array('bills')); @@ -1277,10 +1285,12 @@ while ($i < min($num, $limit)) { $objectstatic->fetch($line->fk_doc); //$modulepart = 'invoice_supplier'; - $filename = dol_sanitizeFileName($line->doc_ref); - $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); - $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); - $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir); + if ($objectstatic->id > 0) { + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); + $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir); + } } elseif ($line->doc_type == 'expense_report') { $langs->loadLangs(array('trips')); @@ -1289,10 +1299,12 @@ while ($i < min($num, $limit)) { $objectstatic->fetch($line->fk_doc); //$modulepart = 'expensereport'; - $filename = dol_sanitizeFileName($line->doc_ref); - $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; - $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + if ($objectstatic->id > 0) { + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + } } elseif ($line->doc_type == 'bank') { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $objectstatic = new AccountLine($db); @@ -1304,9 +1316,13 @@ while ($i < min($num, $limit)) { $labeltoshow = ''; $labeltoshowalt = ''; if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') { - $labeltoshow .= $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); - $labeltoshow .= $documentlink; - $labeltoshowalt .= $objectstatic->ref; + if ($objectstatic->id > 0) { + $labeltoshow .= $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); + $labeltoshow .= $documentlink; + $labeltoshowalt .= $objectstatic->ref; + } else { + $labeltoshow = ''.$langs->trans("Deleted").''; + } } elseif ($line->doc_type == 'bank') { $labeltoshow .= $objectstatic->getNomUrl(1); $labeltoshowalt .= $objectstatic->ref; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index a47a54ae40c..9b9daf3d07b 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -45,7 +45,7 @@ $account_parent = GETPOST('account_parent'); $changeaccount = GETPOST('changeaccount'); // Search Getpost $search_societe = GETPOST('search_societe', 'alpha'); -$search_lineid = GETPOSTINT('search_lineid'); +$search_lineid = GETPOST('search_lineid', 'alpha'); $search_ref = GETPOST('search_ref', 'alpha'); $search_invoice = GETPOST('search_invoice', 'alpha'); $search_label = GETPOST('search_label', 'alpha'); @@ -392,7 +392,7 @@ if ($result) { print '
'.$langs->trans("ChangeAccount").' '; print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle'); - print '
'; + print ''; $moreforfilter = ''; @@ -400,7 +400,7 @@ if ($result) { print '
'."\n"; print ''; - print ''; + print ''; print ''; print '
'; print '
'; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 84128d37f94..eedb807e396 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -55,7 +55,7 @@ $mesCasesCochees = GETPOST('toselect', 'array'); // Search Getpost $search_societe = GETPOST('search_societe', 'alpha'); -$search_lineid = GETPOSTINT('search_lineid'); +$search_lineid = GETPOST('search_lineid', 'alpha'); // Can be '> 100' $search_ref = GETPOST('search_ref', 'alpha'); $search_invoice = GETPOST('search_invoice', 'alpha'); $search_label = GETPOST('search_label', 'alpha'); diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index 60f08f4992d..cb0317d5c01 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -39,9 +39,10 @@ $langs->loadLangs(array("compta", "bills", "other", "accountancy", "trips", "pro $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$account_parent = GETPOSTINT('account_parent'); +$account_parent = GETPOST('account_parent'); $changeaccount = GETPOST('changeaccount'); // Search Getpost +$search_lineid = GETPOST('search_lineid', 'alpha'); // Can be '> 100' $search_login = GETPOST('search_login', 'alpha'); $search_expensereport = GETPOST('search_expensereport', 'alpha'); $search_label = GETPOST('search_label', 'alpha'); @@ -101,6 +102,7 @@ $formaccounting = new FormAccounting($db); // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers + $search_lineid = ''; $search_login = ''; $search_expensereport = ''; $search_label = ''; @@ -203,6 +205,9 @@ $sql .= " WHERE erd.fk_code_ventilation > 0"; $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")"; // Add search filter like +if (strlen($search_lineid)) { + $sql .= natural_search("fd.rowid", $search_lineid, 1); +} if (strlen(trim($search_login))) { $sql .= natural_search("u.login", $search_login); } @@ -314,7 +319,7 @@ if ($result) { print '
'.$langs->trans("ChangeAccount").' '; print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle'); - print '
'; + print '
'; $moreforfilter = ''; @@ -322,8 +327,8 @@ if ($result) { print ''."\n"; print ''; + print ''; print ''; - print ''; print ''; if (getDolGlobalString('ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE')) { print ''; @@ -348,8 +353,8 @@ if ($result) { print "\n"; print ''; - print_liste_field_titre("Employees", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Employees", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder); if (getDolGlobalString('ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE')) { print_liste_field_titre("DateValidation", $_SERVER["PHP_SELF"], "er.date_valid", "", $param, '', $sortfield, $sortorder, 'center '); @@ -393,14 +398,14 @@ if ($result) { print ''; + // Line id + print ''; + // Login print ''; - // Line id - print ''; - // Ref Expense report print ''; diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index 9bb346e153a..0ce64a66fa0 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -25,8 +25,8 @@ * \ingroup Accountancy (Double entries) * \brief Ventilation page from expense reports */ -require '../../main.inc.php'; +require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; @@ -135,6 +135,7 @@ if ($reshook < 0) { if (empty($reshook)) { // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers + $search_lineid = ''; $search_login = ''; $search_expensereport = ''; $search_label = ''; @@ -249,6 +250,9 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = er.fk_user_author"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON f.accountancy_code = aa.account_number AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; $sql .= " WHERE er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.") AND erd.fk_code_ventilation <= 0"; // Add search filter like +if (strlen($search_lineid)) { + $sql .= natural_search("er.rowid", $search_lineid, 1); +} if (strlen(trim($search_login))) { $sql .= natural_search("u.login", $search_login); } @@ -320,12 +324,12 @@ if ($result) { if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.((int) $limit); } - if ($search_login) { - $param .= '&search_login='.urlencode($search_login); - } if ($search_lineid) { $param .= '&search_lineid='.urlencode($search_lineid); } + if ($search_login) { + $param .= '&search_login='.urlencode($search_login); + } if ($search_date_startday) { $param .= '&search_date_startday='.urlencode((string) ($search_date_startday)); } @@ -392,8 +396,8 @@ if ($result) { // We add search filter print ''; - print ''; - print ''; + print ''; + print ''; print ''; if (getDolGlobalString('ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE')) { print ''; @@ -419,8 +423,8 @@ if ($result) { print ''; print ''; - print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder); if (getDolGlobalString('ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE')) { print_liste_field_titre("DateValidation", $_SERVER["PHP_SELF"], "er.date_valid", "", $param, '', $sortfield, $sortorder, 'center '); @@ -465,14 +469,14 @@ if ($result) { print ''; + // Line id + print ''; + // Login print ''; - // Line id - print ''; - // Ref Expense report print ''; diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 10adfea0bc8..49fccc7d147 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -77,11 +77,21 @@ $help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacut llxHeader('', $langs->trans("AccountancyArea"), $help_url); +$resultboxes = FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) +$boxlist = '
'; +$boxlist .= '
'; +$boxlist .= $resultboxes['boxlista']; +$boxlist .= '
'; +$boxlist .= '
'; +$boxlist .= $resultboxes['boxlistb']; +$boxlist .= '
'; +$boxlist .= "\n"; +$boxlist .= '
'; + + if (isModEnabled('accounting')) { $step = 0; - - $helpisexpanded = empty($resultboxes['boxactivated']) || (empty($resultboxes['boxlista']) && empty($resultboxes['boxlistb'])); // If there is no widget, the tooltip help is expanded by default. $showtutorial = ''; @@ -102,7 +112,7 @@ if (isModEnabled('accounting')) { '; } - print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'accountancy', 0, '', '', $showtutorial); + print load_fiche_titre($langs->trans("AccountancyArea"), empty($resultboxes['selectboxlist']) ? '' : $resultboxes['selectboxlist'], 'accountancy', 0, '', '', $showtutorial); if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) { print info_admin($langs->trans("SorryThisModuleIsNotCompatibleWithTheExperimentalFeatureOfSituationInvoices")); @@ -276,16 +286,6 @@ if (isModEnabled('accounting')) { /* * Show boxes */ -$resultboxes = FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) -$boxlist = '
'; -$boxlist .= '
'; -$boxlist .= $resultboxes['boxlista']; -$boxlist .= '
'; -$boxlist .= '
'; -$boxlist .= $resultboxes['boxlistb']; -$boxlist .= '
'; -$boxlist .= "\n"; -$boxlist .= '
'; print $boxlist; // End of page diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 16d1d3d0202..6dd160ed9b9 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -46,7 +46,7 @@ $account_parent = GETPOST('account_parent'); $changeaccount = GETPOST('changeaccount'); // Search Getpost $search_societe = GETPOST('search_societe', 'alpha'); -$search_lineid = GETPOSTINT('search_lineid'); +$search_lineid = GETPOST('search_lineid', 'alpha'); // Can be '> 100' $search_ref = GETPOST('search_ref', 'alpha'); $search_invoice = GETPOST('search_invoice', 'alpha'); //$search_ref_supplier = GETPOST('search_ref_supplier', 'alpha'); @@ -400,7 +400,7 @@ if ($result) { print '
'.$langs->trans("ChangeAccount").' '; print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle'); - print '
'; + print ''; $moreforfilter = ''; @@ -409,7 +409,7 @@ if ($result) { // We add search filter print ''; - print ''; + print ''; print ''; //print ''; print ''; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index b086cdd1914..b7411f66fd5 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -55,8 +55,8 @@ $default_account = GETPOSTINT('default_account'); $mesCasesCochees = GETPOST('toselect', 'array'); // Search Getpost +$search_lineid = GETPOST('search_lineid', 'alpha'); // Can be '> 100' $search_societe = GETPOST('search_societe', 'alpha'); -$search_lineid = GETPOSTINT('search_lineid'); $search_ref = GETPOST('search_ref', 'alpha'); $search_ref_supplier = GETPOST('search_ref_supplier', 'alpha'); $search_invoice = GETPOST('search_invoice', 'alpha'); @@ -291,12 +291,12 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON " . $alias_so $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " AND l.product_type <= 2"; // Add search filter like -if ($search_societe) { - $sql .= natural_search('s.nom', $search_societe); -} -if ($search_lineid) { +if (strlen($search_lineid)) { $sql .= natural_search("l.rowid", $search_lineid, 1); } +if (strlen($search_societe)) { + $sql .= natural_search('s.nom', $search_societe); +} if (strlen(trim($search_invoice))) { $sql .= natural_search(array("f.ref", "f.ref_supplier"), $search_invoice); } @@ -399,12 +399,12 @@ if ($result) { if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.((int) $limit); } - if ($search_societe) { - $param .= '&search_societe='.urlencode($search_societe); - } if ($search_lineid) { $param .= '&search_lineid='.urlencode((string) ($search_lineid)); } + if ($search_societe) { + $param .= '&search_societe='.urlencode($search_societe); + } if ($search_date_startday) { $param .= '&search_date_startday='.urlencode((string) ($search_date_startday)); } diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index baa8560b9c6..214060ad2d2 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -6,6 +6,7 @@ * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2021-2023 Frédéric France * Copyright (C) 2021-2023 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 @@ -90,13 +91,13 @@ print load_fiche_titre($langs->trans("MembersArea"), $resultboxes['selectboxlist $boxgraph = ''; if ($conf->use_javascript_ajax) { - $year = date('Y'); + $year = idate('Y'); $numberyears = getDolGlobalInt("MAIN_NB_OF_YEAR_IN_MEMBERSHIP_WIDGET_GRAPH"); - $boxgraph .='
'; - $boxgraph .='
'.$objp->rowid.''; print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1); print ''.$objp->rowid.''.$expensereportstatic->getNomUrl(1).'
'.$objp->rowid.''; print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1); print ''.$objp->rowid.''.$expensereport_static->getNomUrl(1).'
'; - $boxgraph .=''; - $boxgraph .='
'.$langs->trans("Statistics").($numberyears ? ' ('.($year-$numberyears).' - '.$year.')' : '').'
'; + $boxgraph .= '
'; + $boxgraph .= ''; + $boxgraph .= ''; + $boxgraph .= ''; $boxgraph .= ''; print ''; if (!$foundphy) { - $data[] = array('label'=>'phy', 'nb'=>'0', 'nbactive'=>'0', 'lastdate'=>'', 'lastsubscriptiondate'=>''); + $data[] = array('label' => 'phy', 'nb' => '0', 'nbactive' => '0', 'lastdate' => '', 'lastsubscriptiondate' => ''); } if (!$foundmor) { - $data[] = array('label'=>'mor', 'nb'=>'0', 'nbactive'=>'0', 'lastdate'=>'', 'lastsubscriptiondate'=>''); + $data[] = array('label' => 'mor', 'nb' => '0', 'nbactive' => '0', 'lastdate' => '', 'lastsubscriptiondate' => ''); } foreach ($data as $val) { diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php index 443249a525b..b9d09f6f683 100644 --- a/htdocs/adherents/stats/geo.php +++ b/htdocs/adherents/stats/geo.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 @@ -42,7 +43,7 @@ if ($user->socid > 0) { } $result = restrictedArea($user, 'adherent', '', '', 'cotisation'); -$year = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); +$year = (int) dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS')))); $endyear = $year; @@ -162,40 +163,40 @@ if ($mode) { while ($i < $num) { $obj = $db->fetch_object($resql); if ($mode == 'memberbycountry') { - $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? img_picto('', DOL_URL_ROOT.'/theme/common/flags/'.strtolower($obj->code).'.png', '', 1).' '.$langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), - 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), - 'code'=>$obj->code, - 'nb'=>$obj->nb, - 'lastdate'=>$db->jdate($obj->lastdate), - 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) + $data[] = array('label' => (($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? img_picto('', DOL_URL_ROOT.'/theme/common/flags/'.strtolower($obj->code).'.png', '', 1).' '.$langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), + 'label_en' => (($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), + 'code' => $obj->code, + 'nb' => $obj->nb, + 'lastdate' => $db->jdate($obj->lastdate), + 'lastsubscriptiondate' => $db->jdate($obj->lastsubscriptiondate) ); } if ($mode == 'memberbyregion') { //+ $data[] = array( - 'label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? img_picto('', DOL_URL_ROOT.'/theme/common/flags/'.strtolower($obj->code).'.png', '', 1).' '.$langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), - 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), - 'label2'=>($obj->label2 ? $obj->label2 : ''.$langs->trans("Unknown").''), - 'nb'=>$obj->nb, - 'lastdate'=>$db->jdate($obj->lastdate), - 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) + 'label' => (($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? img_picto('', DOL_URL_ROOT.'/theme/common/flags/'.strtolower($obj->code).'.png', '', 1).' '.$langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), + 'label_en' => (($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), + 'label2' => ($obj->label2 ? $obj->label2 : ''.$langs->trans("Unknown").''), + 'nb' => $obj->nb, + 'lastdate' => $db->jdate($obj->lastdate), + 'lastsubscriptiondate' => $db->jdate($obj->lastsubscriptiondate) ); } if ($mode == 'memberbystate') { - $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? img_picto('', DOL_URL_ROOT.'/theme/common/flags/'.strtolower($obj->code).'.png', '', 1).' '.$langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), - 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), - 'label2'=>($obj->label2 ? $obj->label2 : ''.$langs->trans("Unknown").''), - 'nb'=>$obj->nb, - 'lastdate'=>$db->jdate($obj->lastdate), - 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) + $data[] = array('label' => (($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? img_picto('', DOL_URL_ROOT.'/theme/common/flags/'.strtolower($obj->code).'.png', '', 1).' '.$langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), + 'label_en' => (($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), + 'label2' => ($obj->label2 ? $obj->label2 : ''.$langs->trans("Unknown").''), + 'nb' => $obj->nb, + 'lastdate' => $db->jdate($obj->lastdate), + 'lastsubscriptiondate' => $db->jdate($obj->lastsubscriptiondate) ); } if ($mode == 'memberbytown') { - $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? img_picto('', DOL_URL_ROOT.'/theme/common/flags/'.strtolower($obj->code).'.png', '', 1).' '.$langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), - 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), - 'label2'=>($obj->label2 ? $obj->label2 : ''.$langs->trans("Unknown").''), - 'nb'=>$obj->nb, - 'lastdate'=>$db->jdate($obj->lastdate), - 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) + $data[] = array('label' => (($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? img_picto('', DOL_URL_ROOT.'/theme/common/flags/'.strtolower($obj->code).'.png', '', 1).' '.$langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), + 'label_en' => (($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), + 'label2' => ($obj->label2 ? $obj->label2 : ''.$langs->trans("Unknown").''), + 'nb' => $obj->nb, + 'lastdate' => $db->jdate($obj->lastdate), + 'lastsubscriptiondate' => $db->jdate($obj->lastsubscriptiondate) ); } diff --git a/htdocs/adherents/stats/index.php b/htdocs/adherents/stats/index.php index 0672b5f90c0..17488f72508 100644 --- a/htdocs/adherents/stats/index.php +++ b/htdocs/adherents/stats/index.php @@ -2,6 +2,7 @@ /* Copyright (C) 2003 Rodolphe Quiedeville * Copyright (C) 2004-2011 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 @@ -49,7 +50,7 @@ if ($user->socid > 0) { } $result = restrictedArea($user, 'adherent', '', '', 'cotisation'); -$year = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); +$year = (int) dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $startyear = $year - (!getDolGlobalInt('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalInt('MAIN_STATS_GRAPHS_SHOW_N_YEARS')))); $endyear = $year; if (getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER')) { diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index 99d56c35658..b8d523666aa 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2022 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * 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 @@ -177,7 +178,7 @@ if ($action == 'switch') { $newsecond = $objfrom->box_order; if ($newfirst == $newsecond) { $newsecondchar = preg_replace('/[0-9]+/', '', $newsecond); - $newsecondnum = preg_replace('/[a-zA-Z]+/', '', $newsecond); + $newsecondnum = (int) preg_replace('/[a-zA-Z]+/', '', $newsecond); $newsecond = sprintf("%s%02d", $newsecondchar ? $newsecondchar : 'A', $newsecondnum + 1); } diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index f07961486c6..1a5a68fc085 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -652,7 +652,7 @@ print ''; if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-') { print ''; @@ -604,7 +605,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { if ($modetax != 1) { print ''; diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 14984794eab..1d549dc2d02 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -83,7 +83,7 @@ $formquestion = array(); $usercanissuepayment = $user->hasRight('facture', 'paiement'); $fieldid = 'rowid'; -$isdraft = (($object->statut == Facture::STATUS_DRAFT) ? 1 : 0); +$isdraft = (($object->status == Facture::STATUS_DRAFT) ? 1 : 0); $result = restrictedArea($user, 'facture', $object->id, '', '', 'fk_soc', $fieldid, $isdraft); @@ -115,8 +115,8 @@ if (empty($reshook)) { if (substr($key, 0, 7) == 'amount_' && GETPOST($key) != '') { $cursorfacid = substr($key, 7); $amounts[$cursorfacid] = price2num(GETPOST($key)); - $totalpayment = $totalpayment + $amounts[$cursorfacid]; if (!empty($amounts[$cursorfacid])) { + $totalpayment += (float) $amounts[$cursorfacid]; $atleastonepaymentnotnull++; } $result = $tmpinvoice->fetch($cursorfacid); @@ -463,7 +463,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie //Add js for AutoFill print ' $(document).ready(function () {'; - print ' $(".AutoFillAmout").on(\'click touchstart\', function(){ + print ' $(".AutoFillAmount").on(\'click touchstart\', function(){ $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change"); });'; print ' });'."\n"; @@ -730,7 +730,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // Multicurrency remain to pay print ''; @@ -743,7 +743,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { if ($action != 'add_paiement') { if (!empty($conf->use_javascript_ajax)) { - print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $multicurrency_remaintopay)."'"); + print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmount' data-rowname='".$namef."' data-value='".($sign * (float) $multicurrency_remaintopay)."'"); } print ''; print ''; @@ -770,7 +770,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // Remain to take or to pay back print ''; - print ''; + print ''; print ''; // Autofilled print ''; print "\n"; diff --git a/htdocs/compta/prelevement/class/rejetprelevement.class.php b/htdocs/compta/prelevement/class/rejetprelevement.class.php index c66dda3df0a..453920c5faa 100644 --- a/htdocs/compta/prelevement/class/rejetprelevement.class.php +++ b/htdocs/compta/prelevement/class/rejetprelevement.class.php @@ -178,9 +178,6 @@ class RejetPrelevement // Make a negative payment // Amount must be an array (id of invoice -> amount) $pai->amounts = array(); - - //var_dump($this->type);exit; - $pai->amounts[$facs[$i][0]] = price2num($amountrejected * -1); // The payment must be negative because it is a refund $pai->datepaye = $date_rejet; diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index bff81de3bda..ffd6498dbd7 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -98,7 +98,7 @@ $form = new Form($db); $userstatic = new User($db); $title = $langs->trans("ThirdParty").' - '.$langs->trans("Summary"); -if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { +if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->name) { $title = $object->name.' - '.$langs->trans("Summary"); } $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 863eb956f33..b1ff1585bc6 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -227,6 +227,7 @@ if (empty($reshook)) { $paiement->paiementtype = GETPOST("type_payment", 'alphanohtml'); $paiement->num_payment = GETPOST("num_payment", 'alphanohtml'); $paiement->note = GETPOST("note", 'restricthtml'); + $paiement->note_private = GETPOST("note", 'restricthtml'); if (!$error) { $paymentid = $paiement->create($user, (int) GETPOST('closepaidtva')); diff --git a/htdocs/compta/tva/class/paymentvat.class.php b/htdocs/compta/tva/class/paymentvat.class.php index 1776fe56a77..886d4968a15 100644 --- a/htdocs/compta/tva/class/paymentvat.class.php +++ b/htdocs/compta/tva/class/paymentvat.class.php @@ -170,8 +170,6 @@ class PaymentVAT extends CommonObject */ public function create($user, $closepaidvat = 0) { - global $conf, $langs; - $error = 0; $now = dol_now(); diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index e2e45bac9dd..060072bdb95 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -5,6 +5,7 @@ * Copyright (C) 2006 Yannick Warnier * Copyright (C) 2014 Ferran Marcet * 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 @@ -122,7 +123,7 @@ $calcmode .= ' ('.$langs->trans("TaxModuleSetupToMod // Set period $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); $prevyear = $date_start_year; -$q=0; +$q = 0; $prevquarter = $q; if ($prevquarter > 1) { $prevquarter--; @@ -254,32 +255,32 @@ if (!is_array($x_coll) || !is_array($x_paye)) { $company_static->code_compta_fournisseur = $x_coll[$my_coll_thirdpartyid]['company_supplier_accounting_code'][$id]; $x_both[$my_coll_thirdpartyid]['coll']['detail'][] = array( - 'id' =>$x_coll[$my_coll_thirdpartyid]['facid'][$id], - 'descr' =>$x_coll[$my_coll_thirdpartyid]['descr'][$id], + 'id' => $x_coll[$my_coll_thirdpartyid]['facid'][$id], + 'descr' => $x_coll[$my_coll_thirdpartyid]['descr'][$id], - 'pid' =>$x_coll[$my_coll_thirdpartyid]['pid'][$id], - 'pref' =>isset($x_coll[$my_coll_thirdpartyid]['pref'][$id]) ? $x_coll[$my_coll_thirdpartyid]['pref'][$id] : '', - 'ptype' =>$x_coll[$my_coll_thirdpartyid]['ptype'][$id], - 'pstatus' =>isset($x_paye[$my_coll_thirdpartyid]['pstatus'][$id]) ? $x_paye[$my_coll_thirdpartyid]['pstatus'][$id] : '', - 'pstatusbuy'=>isset($x_paye[$my_coll_thirdpartyid]['pstatusbuy'][$id]) ? $x_paye[$my_coll_thirdpartyid]['pstatusbuy'][$id] : '', + 'pid' => $x_coll[$my_coll_thirdpartyid]['pid'][$id], + 'pref' => isset($x_coll[$my_coll_thirdpartyid]['pref'][$id]) ? $x_coll[$my_coll_thirdpartyid]['pref'][$id] : '', + 'ptype' => $x_coll[$my_coll_thirdpartyid]['ptype'][$id], + 'pstatus' => isset($x_paye[$my_coll_thirdpartyid]['pstatus'][$id]) ? $x_paye[$my_coll_thirdpartyid]['pstatus'][$id] : '', + 'pstatusbuy' => isset($x_paye[$my_coll_thirdpartyid]['pstatusbuy'][$id]) ? $x_paye[$my_coll_thirdpartyid]['pstatusbuy'][$id] : '', - 'payment_id'=>$x_coll[$my_coll_thirdpartyid]['payment_id'][$id], - 'payment_ref'=>isset($x_coll[$my_coll_thirdpartyid]['payment_ref'][$id]) ? $x_coll[$my_coll_thirdpartyid]['payment_ref'][$id] : '', - 'payment_amount'=>$x_coll[$my_coll_thirdpartyid]['payment_amount'][$id], - 'ftotal_ttc'=>$x_coll[$my_coll_thirdpartyid]['ftotal_ttc'][$id], - 'dtotal_ttc'=>$x_coll[$my_coll_thirdpartyid]['dtotal_ttc'][$id], - 'dtype' =>$x_coll[$my_coll_thirdpartyid]['dtype'][$id], - 'drate' =>$x_coll[$my_coll_thirdpartyid]['drate'][$id], - 'datef' =>$x_coll[$my_coll_thirdpartyid]['datef'][$id], - 'datep' =>$x_coll[$my_coll_thirdpartyid]['datep'][$id], + 'payment_id' => $x_coll[$my_coll_thirdpartyid]['payment_id'][$id], + 'payment_ref' => isset($x_coll[$my_coll_thirdpartyid]['payment_ref'][$id]) ? $x_coll[$my_coll_thirdpartyid]['payment_ref'][$id] : '', + 'payment_amount' => $x_coll[$my_coll_thirdpartyid]['payment_amount'][$id], + 'ftotal_ttc' => $x_coll[$my_coll_thirdpartyid]['ftotal_ttc'][$id], + 'dtotal_ttc' => $x_coll[$my_coll_thirdpartyid]['dtotal_ttc'][$id], + 'dtype' => $x_coll[$my_coll_thirdpartyid]['dtype'][$id], + 'drate' => $x_coll[$my_coll_thirdpartyid]['drate'][$id], + 'datef' => $x_coll[$my_coll_thirdpartyid]['datef'][$id], + 'datep' => $x_coll[$my_coll_thirdpartyid]['datep'][$id], - 'company_link'=>$company_static->getNomUrl(1, '', 20), + 'company_link' => $company_static->getNomUrl(1, '', 20), - 'ddate_start'=>$x_coll[$my_coll_thirdpartyid]['ddate_start'][$id], - 'ddate_end' =>$x_coll[$my_coll_thirdpartyid]['ddate_end'][$id], - 'totalht' =>$x_coll[$my_coll_thirdpartyid]['totalht_list'][$id], - 'vat' =>$x_coll[$my_coll_thirdpartyid]['vat_list'][$id], - 'link' =>$invoice_customer->getNomUrl(1, '', 12) + 'ddate_start' => $x_coll[$my_coll_thirdpartyid]['ddate_start'][$id], + 'ddate_end' => $x_coll[$my_coll_thirdpartyid]['ddate_end'][$id], + 'totalht' => $x_coll[$my_coll_thirdpartyid]['totalht_list'][$id], + 'vat' => $x_coll[$my_coll_thirdpartyid]['vat_list'][$id], + 'link' => $invoice_customer->getNomUrl(1, '', 12) ); } } @@ -302,27 +303,27 @@ if (!is_array($x_coll) || !is_array($x_paye)) { $expensereport->type = $x_paye[$my_paye_thirdpartyid]['type'][$id]; $x_both[$my_paye_thirdpartyid]['paye']['detail'][] = array( - 'id' =>$x_paye[$my_paye_thirdpartyid]['facid'][$id], - 'descr' =>$x_paye[$my_paye_thirdpartyid]['descr'][$id], + 'id' => $x_paye[$my_paye_thirdpartyid]['facid'][$id], + 'descr' => $x_paye[$my_paye_thirdpartyid]['descr'][$id], - 'pid' =>$x_paye[$my_paye_thirdpartyid]['pid'][$id], - 'pref' =>$x_paye[$my_paye_thirdpartyid]['pref'][$id], - 'ptype' =>$x_paye[$my_paye_thirdpartyid]['ptype'][$id], - 'pstatus' =>$x_paye[$my_paye_thirdpartyid]['pstatus'][$id], - 'pstatusbuy' =>$x_paye[$my_paye_thirdpartyid]['pstatusbuy'][$id], + 'pid' => $x_paye[$my_paye_thirdpartyid]['pid'][$id], + 'pref' => $x_paye[$my_paye_thirdpartyid]['pref'][$id], + 'ptype' => $x_paye[$my_paye_thirdpartyid]['ptype'][$id], + 'pstatus' => $x_paye[$my_paye_thirdpartyid]['pstatus'][$id], + 'pstatusbuy' => $x_paye[$my_paye_thirdpartyid]['pstatusbuy'][$id], - 'payment_id' =>$x_paye[$my_paye_thirdpartyid]['payment_id'][$id], - 'payment_ref' =>$x_paye[$my_paye_thirdpartyid]['payment_ref'][$id], - 'payment_amount' =>$x_paye[$my_paye_thirdpartyid]['payment_amount'][$id], - 'ftotal_ttc' =>price2num($x_paye[$my_paye_thirdpartyid]['ftotal_ttc'][$id]), - 'dtotal_ttc' =>price2num($x_paye[$my_paye_thirdpartyid]['dtotal_ttc'][$id]), - 'dtype' =>$x_paye[$my_paye_thirdpartyid]['dtype'][$id], - 'drate' =>$x_paye[$my_coll_thirdpartyid]['drate'][$id], - 'ddate_start' =>$x_paye[$my_paye_thirdpartyid]['ddate_start'][$id], - 'ddate_end' =>$x_paye[$my_paye_thirdpartyid]['ddate_end'][$id], - 'totalht' =>price2num($x_paye[$my_paye_thirdpartyid]['totalht_list'][$id]), - 'vat' =>$x_paye[$my_paye_thirdpartyid]['vat_list'][$id], - 'link' =>$expensereport->getNomUrl(1) + 'payment_id' => $x_paye[$my_paye_thirdpartyid]['payment_id'][$id], + 'payment_ref' => $x_paye[$my_paye_thirdpartyid]['payment_ref'][$id], + 'payment_amount' => $x_paye[$my_paye_thirdpartyid]['payment_amount'][$id], + 'ftotal_ttc' => price2num($x_paye[$my_paye_thirdpartyid]['ftotal_ttc'][$id]), + 'dtotal_ttc' => price2num($x_paye[$my_paye_thirdpartyid]['dtotal_ttc'][$id]), + 'dtype' => $x_paye[$my_paye_thirdpartyid]['dtype'][$id], + 'drate' => $x_paye[$my_coll_thirdpartyid]['drate'][$id], + 'ddate_start' => $x_paye[$my_paye_thirdpartyid]['ddate_start'][$id], + 'ddate_end' => $x_paye[$my_paye_thirdpartyid]['ddate_end'][$id], + 'totalht' => price2num($x_paye[$my_paye_thirdpartyid]['totalht_list'][$id]), + 'vat' => $x_paye[$my_paye_thirdpartyid]['vat_list'][$id], + 'link' => $expensereport->getNomUrl(1) ); } else { $invoice_supplier->id = $x_paye[$my_paye_thirdpartyid]['facid'][$id]; @@ -344,32 +345,32 @@ if (!is_array($x_coll) || !is_array($x_paye)) { $company_static->code_compta_fournisseur = $x_paye[$my_paye_thirdpartyid]['company_supplier_accounting_code'][$id]; $x_both[$my_paye_thirdpartyid]['paye']['detail'][] = array( - 'id' =>$x_paye[$my_paye_thirdpartyid]['facid'][$id], - 'descr' =>$x_paye[$my_paye_thirdpartyid]['descr'][$id], + 'id' => $x_paye[$my_paye_thirdpartyid]['facid'][$id], + 'descr' => $x_paye[$my_paye_thirdpartyid]['descr'][$id], - 'pid' =>$x_paye[$my_paye_thirdpartyid]['pid'][$id], - 'pref' =>$x_paye[$my_paye_thirdpartyid]['pref'][$id], - 'ptype' =>$x_paye[$my_paye_thirdpartyid]['ptype'][$id], - 'pstatus' =>$x_paye[$my_paye_thirdpartyid]['pstatus'][$id], - 'pstatusbuy'=>$x_paye[$my_paye_thirdpartyid]['pstatusbuy'][$id], + 'pid' => $x_paye[$my_paye_thirdpartyid]['pid'][$id], + 'pref' => $x_paye[$my_paye_thirdpartyid]['pref'][$id], + 'ptype' => $x_paye[$my_paye_thirdpartyid]['ptype'][$id], + 'pstatus' => $x_paye[$my_paye_thirdpartyid]['pstatus'][$id], + 'pstatusbuy' => $x_paye[$my_paye_thirdpartyid]['pstatusbuy'][$id], - 'payment_id'=>$x_paye[$my_paye_thirdpartyid]['payment_id'][$id], - 'payment_ref'=>$x_paye[$my_paye_thirdpartyid]['payment_ref'][$id], - 'payment_amount'=>$x_paye[$my_paye_thirdpartyid]['payment_amount'][$id], - 'ftotal_ttc'=>price2num($x_paye[$my_paye_thirdpartyid]['ftotal_ttc'][$id]), - 'dtotal_ttc'=>price2num($x_paye[$my_paye_thirdpartyid]['dtotal_ttc'][$id]), - 'dtype' =>$x_paye[$my_paye_thirdpartyid]['dtype'][$id], - 'drate' =>$x_paye[$my_coll_thirdpartyid]['drate'][$id], - 'datef' =>$x_paye[$my_paye_thirdpartyid]['datef'][$id], - 'datep' =>$x_paye[$my_paye_thirdpartyid]['datep'][$id], + 'payment_id' => $x_paye[$my_paye_thirdpartyid]['payment_id'][$id], + 'payment_ref' => $x_paye[$my_paye_thirdpartyid]['payment_ref'][$id], + 'payment_amount' => $x_paye[$my_paye_thirdpartyid]['payment_amount'][$id], + 'ftotal_ttc' => price2num($x_paye[$my_paye_thirdpartyid]['ftotal_ttc'][$id]), + 'dtotal_ttc' => price2num($x_paye[$my_paye_thirdpartyid]['dtotal_ttc'][$id]), + 'dtype' => $x_paye[$my_paye_thirdpartyid]['dtype'][$id], + 'drate' => $x_paye[$my_coll_thirdpartyid]['drate'][$id], + 'datef' => $x_paye[$my_paye_thirdpartyid]['datef'][$id], + 'datep' => $x_paye[$my_paye_thirdpartyid]['datep'][$id], - 'company_link'=>$company_static->getNomUrl(1, '', 20), + 'company_link' => $company_static->getNomUrl(1, '', 20), - 'ddate_start'=>$x_paye[$my_paye_thirdpartyid]['ddate_start'][$id], - 'ddate_end' =>$x_paye[$my_paye_thirdpartyid]['ddate_end'][$id], - 'totalht' =>price2num($x_paye[$my_paye_thirdpartyid]['totalht_list'][$id]), - 'vat' =>$x_paye[$my_paye_thirdpartyid]['vat_list'][$id], - 'link' =>$invoice_supplier->getNomUrl(1, '', 12) + 'ddate_start' => $x_paye[$my_paye_thirdpartyid]['ddate_start'][$id], + 'ddate_end' => $x_paye[$my_paye_thirdpartyid]['ddate_end'][$id], + 'totalht' => price2num($x_paye[$my_paye_thirdpartyid]['totalht_list'][$id]), + 'vat' => $x_paye[$my_paye_thirdpartyid]['vat_list'][$id], + 'link' => $invoice_supplier->getNomUrl(1, '', 12) ); } } @@ -699,7 +700,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print price($fields['totalht']); if (price2num($fields['ftotal_ttc'])) { //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; - $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); + $ratiolineinvoice = ((float) $fields['dtotal_ttc'] / (float) $fields['ftotal_ttc']); //print ' ('.round($ratiolineinvoice*100,2).'%)'; } print ''; @@ -720,7 +721,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print $langs->trans("NA"); } else { if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + $ratiopaymentinvoice = ($fields['payment_amount'] / (float) $fields['ftotal_ttc']); } print ''.price(price2num($fields['payment_amount'], 'MT')).''; if (isset($fields['payment_amount'])) { @@ -732,7 +733,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { // VAT paid print ''; diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index db73cc25e56..994123bc0db 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -7,6 +7,7 @@ * Copyright (C) 2018 Frédéric France * Copyright (C) 2021 Gauthier VERDOL * Copyright (C) 2021 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 @@ -464,12 +465,12 @@ if ($refresh === true) { //print $langs->trans("NA"); } else { if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + $ratiopaymentinvoice = ($fields['payment_amount'] / (float) $fields['ftotal_ttc']); } } } //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + $temp_ht = (float) $fields['totalht'] * $ratiopaymentinvoice; $temp_vat = $fields['vat'] * $ratiopaymentinvoice; $subtot_paye_total_ht += $temp_ht; $subtot_paye_vat += $temp_vat; diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index 0873ab75072..441c6bee6cd 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -7,6 +7,7 @@ * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2019 Eric Seigne * Copyright (C) 2021-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 @@ -131,7 +132,7 @@ $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', $period .= ' - '; $period .= $form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); $prevyear = $date_start_year; -$q=0; +$q = 0; $prevquarter = $q; if ($prevquarter > 1) { $prevquarter--; @@ -684,13 +685,13 @@ if (!is_array($x_coll) || !is_array($x_paye)) { || ($type == 1 && getDolGlobalString('TAX_MODE_BUY_SERVICE') == 'invoice')) { } else { if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + $ratiopaymentinvoice = ($fields['payment_amount'] / (float) $fields['ftotal_ttc']); } } } // VAT paid - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + $temp_ht = (float) $fields['totalht'] * $ratiopaymentinvoice; // VAT $temp_vat = $fields['vat'] * $ratiopaymentinvoice; @@ -787,7 +788,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print price($fields['totalht']); if (price2num($fields['ftotal_ttc'])) { //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; - $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); + $ratiolineinvoice = ((float) $fields['dtotal_ttc'] / (float) $fields['ftotal_ttc']); //print ' ('.round($ratiolineinvoice*100,2).'%)'; } print ''; @@ -808,7 +809,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print $langs->trans("NA"); } else { if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + $ratiopaymentinvoice = ($fields['payment_amount'] / (float) $fields['ftotal_ttc']); } print price(price2num($fields['payment_amount'], 'MT')); if (isset($fields['payment_amount'])) { @@ -820,7 +821,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { // VAT paid print ''; diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index af06f40761f..2c1a0d2ab99 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -145,7 +145,7 @@ if (empty($reshook)) { $form = new Form($db); $title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); -if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) { +if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/contactnameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->lastname) { $title = $object->lastname; } $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas|DE:Modul_Partner'; diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 28e39259101..16087378bf2 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -570,7 +570,7 @@ if ($socid > 0) { } $title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); -if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) { +if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/contactnameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->lastname) { $title = $object->lastname; } $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; diff --git a/htdocs/contact/document.php b/htdocs/contact/document.php index 1a98fb921fa..c4b216d2679 100644 --- a/htdocs/contact/document.php +++ b/htdocs/contact/document.php @@ -111,7 +111,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; $form = new Form($db); $title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); -if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) { +if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/contactnameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->lastname) { $title = $object->lastname; } $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index 357b6401023..90028857f99 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -120,7 +120,7 @@ if ($action == 'update' && !GETPOST("cancel") && $user->hasRight('societe', 'con $now = dol_now(); $title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); -if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) { +if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/contactnameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->lastname) { $title = $object->lastname; } $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; diff --git a/htdocs/contact/project.php b/htdocs/contact/project.php index 389bb693d1d..7fe377f1a96 100644 --- a/htdocs/contact/project.php +++ b/htdocs/contact/project.php @@ -63,7 +63,7 @@ if ($id) { } $socid = !empty($object->thirdparty->id) ? $object->thirdparty->id : null; $title = $langs->trans("Projects"); - if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { + if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->name) { $title = $object->name." - ".$title; } llxHeader('', $title); diff --git a/htdocs/contrat/agenda.php b/htdocs/contrat/agenda.php index 848f1a088d7..63eae100841 100644 --- a/htdocs/contrat/agenda.php +++ b/htdocs/contrat/agenda.php @@ -146,7 +146,7 @@ if ($object->id > 0) { $object->fetch_thirdparty(); $title = $langs->trans("Agenda"); - if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/contractrefonly/', $conf->global->MAIN_HTML_TITLE) && $object->ref) { + if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/contractrefonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->ref) { $title = $object->ref." - ".$title; } $help_url = 'EN:Module_Contracts|FR:Module_Contrat'; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 5877525b7fe..97ce15937e2 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -551,11 +551,11 @@ if (empty($reshook)) { // Set unit price to use if (!empty($price_ht) || $price_ht === '0') { $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); + $pu_ttc = price2num((float) $pu_ht * (1 + ((float) $tmpvat / 100)), 'MU'); $price_base_type = 'HT'; } elseif (!empty($price_ttc) || $price_ttc === '0') { $pu_ttc = price2num($price_ttc, 'MU'); - $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); + $pu_ht = price2num((float) $pu_ttc / (1 + ((float) $tmpvat / 100)), 'MU'); $price_base_type = 'TTC'; } @@ -591,11 +591,11 @@ if (empty($reshook)) { // Set unit price to use if (!empty($price_ht) || $price_ht === '0') { $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num($pu_ht * (1 + ((float) $tmpvat / 100)), 'MU'); + $pu_ttc = price2num((float) $pu_ht * (1 + ((float) $tmpvat / 100)), 'MU'); $price_base_type = 'HT'; } elseif (!empty($price_ttc) || $price_ttc === '0') { $pu_ttc = price2num($price_ttc, 'MU'); - $pu_ht = price2num($pu_ttc / (1 + ((float) $tmpvat / 100)), 'MU'); + $pu_ht = price2num((float) $pu_ttc / (1 + ((float) $tmpvat / 100)), 'MU'); $price_base_type = 'TTC'; } } @@ -617,7 +617,7 @@ if (empty($reshook)) { } if (((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('produit', 'ignore_price_min_advance')) - || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) && ($price_min && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) { + || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) && ($price_min && ((float) price2num($pu_ht) * (1 - (float) price2num($remise_percent) / 100) < (float) price2num($price_min)))) { $object->error = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); $result = -1; } else { @@ -769,7 +769,7 @@ if (empty($reshook)) { $price_ht = price2num(GETPOST('elprice'), 'MU'); $remise_percent = price2num(GETPOST('elremise_percent'), '', 2); if ($remise_percent > 0) { - $remise = round(($price_ht * $remise_percent / 100), 2); + $remise = round(((float) $price_ht * (float) $remise_percent / 100), 2); } $objectline->fk_product = GETPOSTINT('idprod'); diff --git a/htdocs/contrat/messaging.php b/htdocs/contrat/messaging.php index 8f3e5fac95e..be189fb2b5d 100644 --- a/htdocs/contrat/messaging.php +++ b/htdocs/contrat/messaging.php @@ -145,7 +145,7 @@ require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; $object->fetch_thirdparty(); $title = $langs->trans("Agenda"); -if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/contractrefonly/', $conf->global->MAIN_HTML_TITLE) && $object->ref) { +if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/contractrefonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->ref) { $title = $object->ref." - ".$title; } $help_url = 'EN:Module_Contracts|FR:Module_Contrat'; diff --git a/htdocs/core/ajax/ajaxtooltip.php b/htdocs/core/ajax/ajaxtooltip.php index 782123ca317..8bc7305d744 100644 --- a/htdocs/core/ajax/ajaxtooltip.php +++ b/htdocs/core/ajax/ajaxtooltip.php @@ -85,7 +85,7 @@ if (is_object($object)) { if ($object->id > 0 || !empty($object->ref)) { /** @var CommonObject $object */ $html = $object->getTooltipContent($params); - } elseif ($res == 0) { + } elseif ($id > 0) { $html = $langs->trans('Deleted'); } unset($object); diff --git a/htdocs/core/ajax/flowjs-server.php b/htdocs/core/ajax/flowjs-server.php index 73617cbc008..dfe8b4ad2ce 100644 --- a/htdocs/core/ajax/flowjs-server.php +++ b/htdocs/core/ajax/flowjs-server.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 @@ -162,10 +163,10 @@ function createFileFromChunks($temp_dir, $upload_dir, $fileName, $chunkSize, $to // check that all the parts are present // the size of the last part is between chunkSize and 2*$chunkSize - if ($total_files * $chunkSize >= ($totalSize - $chunkSize + 1)) { + if ($total_files * (float) $chunkSize >= ((float) $totalSize - (float) $chunkSize + 1)) { // create the final destination file if (($fp = fopen($upload_dir.'/'.$fileName, 'w')) !== false) { - for ($i=1; $i<=$total_files; $i++) { + for ($i = 1; $i <= $total_files; $i++) { fwrite($fp, file_get_contents($temp_dir.'/'.$fileName.'.part'.$i)); dol_syslog('writing chunk '.$i); } diff --git a/htdocs/core/boxes/box_accountancy_last_manual_entries.php b/htdocs/core/boxes/box_accountancy_last_manual_entries.php index f10fd4ee61c..14169dfe17c 100644 --- a/htdocs/core/boxes/box_accountancy_last_manual_entries.php +++ b/htdocs/core/boxes/box_accountancy_last_manual_entries.php @@ -33,7 +33,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; class box_accountancy_last_manual_entries extends ModeleBoxes { public $boxcode = "accountancy_last_manual_entries"; - public $boximg = "accounting"; + public $boximg = "accountancy"; public $boxlabel = "BoxLastManualEntries"; public $depends = array("accounting"); diff --git a/htdocs/core/boxes/box_accountancy_suspense_account.php b/htdocs/core/boxes/box_accountancy_suspense_account.php index 49ad1322d15..a52f0a1a3b8 100644 --- a/htdocs/core/boxes/box_accountancy_suspense_account.php +++ b/htdocs/core/boxes/box_accountancy_suspense_account.php @@ -33,7 +33,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; class box_accountancy_suspense_account extends ModeleBoxes { public $boxcode = "accountancy_suspense_account"; - public $boximg = "accounting"; + public $boximg = "accountancy"; public $boxlabel = "BoxSuspenseAccount"; public $depends = array("accounting"); diff --git a/htdocs/core/boxes/box_birthdays.php b/htdocs/core/boxes/box_birthdays.php index 3abab74e28a..050611acc00 100644 --- a/htdocs/core/boxes/box_birthdays.php +++ b/htdocs/core/boxes/box_birthdays.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * 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 @@ -121,7 +122,7 @@ class box_birthdays extends ModeleBoxes $userstatic->statut = $data[$j]->status; $dateb = $this->db->jdate($data[$j]->datea); - $age = date('Y', dol_now()) - date('Y', $dateb); + $age = idate('Y', dol_now()) - idate('Y', $dateb); $picb = ''; $pice = ''; diff --git a/htdocs/core/boxes/box_birthdays_members.php b/htdocs/core/boxes/box_birthdays_members.php index 8ac73aa4bd0..062eeb31506 100644 --- a/htdocs/core/boxes/box_birthdays_members.php +++ b/htdocs/core/boxes/box_birthdays_members.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2015-2023 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 @@ -115,7 +116,7 @@ class box_birthdays_members extends ModeleBoxes $memberstatic->datefin = $this->db->jdate($data[$j]->datefin); $dateb = $this->db->jdate($data[$j]->birth); - $age = date('Y', dol_now()) - date('Y', $dateb); + $age = idate('Y', dol_now()) - idate('Y', $dateb); $typea = ''; diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 74b31a3daaf..f38604467e4 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -1,5 +1,6 @@ + * 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 @@ -68,7 +69,7 @@ class box_graph_invoices_permonth extends ModeleBoxes //include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; //$facturestatic=new Facture($this->db); - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + $startmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); if (!getDolGlobalString('GRAPH_USE_FISCAL_YEAR')) { $startmonth = 1; } diff --git a/htdocs/core/boxes/box_graph_invoices_peryear.php b/htdocs/core/boxes/box_graph_invoices_peryear.php index f6decd57660..be20f7ff3c0 100644 --- a/htdocs/core/boxes/box_graph_invoices_peryear.php +++ b/htdocs/core/boxes/box_graph_invoices_peryear.php @@ -1,5 +1,6 @@ + * 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 @@ -65,7 +66,7 @@ class box_graph_invoices_peryear extends ModeleBoxes //include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; //$facturestatic=new Facture($this->db); - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + $startmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); if (!getDolGlobalString('GRAPH_USE_FISCAL_YEAR')) { $startmonth = 1; } diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index 818398324c8..30cc4616d59 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -1,5 +1,6 @@ + * 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 @@ -66,7 +67,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + $startmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); if (!getDolGlobalString('GRAPH_USE_FISCAL_YEAR')) { $startmonth = 1; } diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index ce11fe9e93d..182b2f5fb72 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -1,5 +1,6 @@ + * 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 @@ -67,7 +68,7 @@ class box_graph_orders_permonth extends ModeleBoxes //include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; //$commandestatic=new Commande($this->db); - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + $startmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); if (!getDolGlobalString('GRAPH_USE_FISCAL_YEAR')) { $startmonth = 1; } diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index 9b7e40ab20f..6924bb9d9e8 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -1,5 +1,6 @@ + * 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 @@ -66,7 +67,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + $startmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); if (!getDolGlobalString('GRAPH_USE_FISCAL_YEAR')) { $startmonth = 1; } diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index 0192ecf2b12..5699d71e678 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -1,5 +1,6 @@ + * 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 @@ -67,7 +68,7 @@ class box_graph_propales_permonth extends ModeleBoxes //include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; //$propalstatic=new Propal($this->db); - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + $startmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); if (!getDolGlobalString('GRAPH_USE_FISCAL_YEAR')) { $startmonth = 1; } diff --git a/htdocs/core/boxes/box_members_by_tags.php b/htdocs/core/boxes/box_members_by_tags.php index 99c71e59063..20ef8187840 100644 --- a/htdocs/core/boxes/box_members_by_tags.php +++ b/htdocs/core/boxes/box_members_by_tags.php @@ -1,9 +1,9 @@ - * Copyright (C) 2004-2017 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2015-2023 Frédéric France - * Copyright (C) 2021-2023 Waël Almoman +/* Copyright (C) 2003-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2015-2024 Frédéric France + * Copyright (C) 2021-2023 Waël Almoman * * 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 @@ -140,12 +140,11 @@ class box_members_by_tags extends ModeleBoxes $line++; $AdherentTag = array(); foreach ($sumMembers as $key => $data) { - $adhtag = new Categorie($this->db); - $adhtag->id = $key; - if ($key == 'total') { break; } + $adhtag = new Categorie($this->db); + $adhtag->id = (int) $key; $adhtag->label = $data['label']; $AdherentTag[$key] = $adhtag; diff --git a/htdocs/core/boxes/box_members_by_type.php b/htdocs/core/boxes/box_members_by_type.php index 05f886e2858..63479a55212 100644 --- a/htdocs/core/boxes/box_members_by_type.php +++ b/htdocs/core/boxes/box_members_by_type.php @@ -1,9 +1,9 @@ - * Copyright (C) 2004-2017 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2015-2023 Frederic France - * Copyright (C) 2021-2023 Waël Almoman +/* Copyright (C) 2003-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2015-2024 Frédéric France + * Copyright (C) 2021-2023 Waël Almoman * * 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 @@ -140,12 +140,11 @@ class box_members_by_type extends ModeleBoxes $line++; $AdherentType = array(); foreach ($sumMembers as $key => $data) { - $adhtype = new AdherentType($this->db); - $adhtype->id = $key; - if ($key == 'total') { break; } + $adhtype = new AdherentType($this->db); + $adhtype->id = (int) $key; $adhtype->label = $data['label']; $AdherentType[$key] = $adhtype; diff --git a/htdocs/core/boxes/box_members_last_modified.php b/htdocs/core/boxes/box_members_last_modified.php index 2ef36c822dd..a33b2b7577c 100644 --- a/htdocs/core/boxes/box_members_last_modified.php +++ b/htdocs/core/boxes/box_members_last_modified.php @@ -2,7 +2,7 @@ /* Copyright (C) 2003-2007 Rodolphe Quiedeville * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2015-2020 Frederic France + * Copyright (C) 2015-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 @@ -110,7 +110,7 @@ class box_members_last_modified extends ModeleBoxes $memberstatic->email = $objp->email; $memberstatic->morphy = $objp->morphy; $memberstatic->company = $objp->company; - $memberstatic->statut = $objp->status; + $memberstatic->status = $objp->status; $memberstatic->date_creation = $datec; $memberstatic->date_modification = $datem; $memberstatic->need_subscription = $objp->subscription; diff --git a/htdocs/core/boxes/box_members_last_subscriptions.php b/htdocs/core/boxes/box_members_last_subscriptions.php index 92d0413c5e7..8dbb96df25f 100644 --- a/htdocs/core/boxes/box_members_last_subscriptions.php +++ b/htdocs/core/boxes/box_members_last_subscriptions.php @@ -1,8 +1,8 @@ - * Copyright (C) 2004-2017 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2015-2020 Frederic France +/* Copyright (C) 2003-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2015-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 @@ -110,7 +110,7 @@ class box_members_last_subscriptions extends ModeleBoxes $staticmember->email = $obj->email; $staticmember->photo = $obj->photo; $staticmember->morphy = $obj->morphy; - $staticmember->statut = $obj->status; + $staticmember->status = $obj->status; $staticmember->need_subscription = $obj->need_subscription; $staticmember->datefin = $this->db->jdate($obj->date_end_subscription); if (!empty($obj->fk_soc)) { diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index 170dd59e4b1..89f09bf5389 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -1,6 +1,6 @@ - * Copyright (C) 2015-2021 Frederic France + * Copyright (C) 2015-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 @@ -174,7 +174,7 @@ class box_task extends ModeleBoxes $taskstatic->ref = $objp->ref; $taskstatic->label = $objp->label; $taskstatic->progress = $objp->progress; - $taskstatic->fk_statut = $objp->fk_statut; + $taskstatic->status = $objp->fk_statut; $taskstatic->date_end = $this->db->jdate($objp->datee); $taskstatic->planned_workload = $objp->planned_workload; $taskstatic->duration_effective = $objp->duration_effective; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index ab8c695c143..6d1a31a1677 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -147,18 +147,18 @@ abstract class CommonDocGenerator public $emetteur; /** - * @var array Minimum version of PHP required by module. + * @var array{0:int,1:int} Minimum version of PHP required by module. * e.g.: PHP ≥ 7.1 = array(7, 1) */ public $phpmin = array(7, 1); /** - * @var array Array of columns + * @var array Array of columns */ public $cols; /** - * @var array Array with result of doc generation. content is array('fullpath'=>$file) + * @var array{fullpath:string} Array with result of doc generation. content is array('fullpath'=>$file) */ public $result; @@ -856,7 +856,7 @@ abstract class CommonDocGenerator include_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; $object->list_delivery_methods($object->shipping_method_id); - $calculatedVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth); + $calculatedVolume = ((float) $object->trueWidth * (float) $object->trueHeight * (float) $object->trueDepth); $array_shipment = array( $array_key.'_id' => $object->id, diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 41a9a69114d..1cfcea32108 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3861,7 +3861,7 @@ abstract class CommonObject if ($forcedroundingmode == '1') { // Check if we need adjustment onto line for vat. TODO This works on the company currency but not on foreign currency $tmpvat = price2num($total_ht_by_vats[$obj->vatrate] * $obj->vatrate / 100, 'MT', 1); - $diff = price2num($total_tva_by_vats[$obj->vatrate] - $tmpvat, 'MT', 1); + $diff = price2num($total_tva_by_vats[$obj->vatrate] - (float) $tmpvat, 'MT', 1); //print 'Line '.$i.' rowid='.$obj->rowid.' vat_rate='.$obj->vatrate.' total_ht='.$obj->total_ht.' total_tva='.$obj->total_tva.' total_ttc='.$obj->total_ttc.' total_ht_by_vats='.$total_ht_by_vats[$obj->vatrate].' total_tva_by_vats='.$total_tva_by_vats[$obj->vatrate].' (new calculation = '.$tmpvat.') total_ttc_by_vats='.$total_ttc_by_vats[$obj->vatrate].($diff?" => DIFF":"")."
\n"; if ($diff) { if (abs((float) $diff) > (10 * pow(10, -1 * getDolGlobalInt('MAIN_MAX_DECIMALS_TOT', 0)))) { @@ -3872,7 +3872,7 @@ abstract class CommonObject $error++; break; } - $sqlfix = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldtva." = ".price2num($obj->total_tva - $diff).", total_ttc = ".price2num($obj->total_ttc - $diff)." WHERE rowid = ".((int) $obj->rowid); + $sqlfix = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldtva." = ".price2num($obj->total_tva - (float) $diff).", total_ttc = ".price2num($obj->total_ttc - (float) $diff)." WHERE rowid = ".((int) $obj->rowid); dol_syslog('We found a difference of '.$diff.' for line rowid = '.$obj->rowid.". We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix); $resqlfix = $this->db->query($sqlfix); @@ -3881,10 +3881,10 @@ abstract class CommonObject dol_print_error($this->db, 'Failed to update line'); } - $this->total_tva = (float) price2num($this->total_tva - $diff, '', 1); - $this->total_ttc = (float) price2num($this->total_ttc - $diff, '', 1); - $total_tva_by_vats[$obj->vatrate] = (float) price2num($total_tva_by_vats[$obj->vatrate] - $diff, '', 1); - $total_ttc_by_vats[$obj->vatrate] = (float) price2num($total_ttc_by_vats[$obj->vatrate] - $diff, '', 1); + $this->total_tva = (float) price2num($this->total_tva - (float) $diff, '', 1); + $this->total_ttc = (float) price2num($this->total_ttc - (float) $diff, '', 1); + $total_tva_by_vats[$obj->vatrate] = (float) price2num($total_tva_by_vats[$obj->vatrate] - (float) $diff, '', 1); + $total_ttc_by_vats[$obj->vatrate] = (float) price2num($total_ttc_by_vats[$obj->vatrate] - (float) $diff, '', 1); } } diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index a8148548443..ca1817e27a3 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -754,7 +754,7 @@ class Conf extends stdClass // MAIN_HTML_TITLE if (!isset($this->global->MAIN_HTML_TITLE)) { - $this->global->MAIN_HTML_TITLE = 'noapp,thirdpartynameonly,contactnameonly,projectnameonly'; + $this->global->MAIN_HTML_TITLE = 'thirdpartynameonly,contactnameonly,projectnameonly'; } // conf->liste_limit = constante de taille maximale des listes diff --git a/htdocs/core/class/defaultvalues.class.php b/htdocs/core/class/defaultvalues.class.php index 0b54bd8fb79..c2bf1199322 100644 --- a/htdocs/core/class/defaultvalues.class.php +++ b/htdocs/core/class/defaultvalues.class.php @@ -64,7 +64,7 @@ class DefaultValues extends CommonObject * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" * 'label' the translation key. * 'picto' is code of a picto to show before value in forms - * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM) + * 'enabled' is a condition when the field must be managed (Example: 1 or 'getDolGlobalString("MY_SETUP_PARAM")' * 'position' is the sort order of field. * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0c62d6e7e2a..8baf4c7c86a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6920,8 +6920,8 @@ class Form } elseif ($usecalendar == 'jquery' || $usecalendar == 'html') { if (!$disabled && $usecalendar != 'html') { // Output javascript for datepicker - $minYear = getDolGlobalInt('MIN_YEAR_SELECT_DATE', (date('Y') - 100)); - $maxYear = getDolGlobalInt('MAX_YEAR_SELECT_DATE', (date('Y') + 100)); + $minYear = getDolGlobalInt('MIN_YEAR_SELECT_DATE', (idate('Y') - 100)); + $maxYear = getDolGlobalInt('MAX_YEAR_SELECT_DATE', (idate('Y') + 100)); $retstring .= '
'.$langs->trans("Statistics").($numberyears ? ' ('.($year - $numberyears).' - '.$year.')' : '').'
'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php'; $stats = new AdherentStats($db, 0, $userid); @@ -133,7 +134,7 @@ if ($conf->use_javascript_ajax) { $dolgraph->SetType(array('pie')); $dolgraph->setHeight('200'); $dolgraph->draw('idgraphstatus'); - $boxgraph .=$dolgraph->show($total ? 0 : 1); + $boxgraph .= $dolgraph->show($total ? 0 : 1); $boxgraph .= '
'.$langs->trans("Total").''; diff --git a/htdocs/adherents/stats/byproperties.php b/htdocs/adherents/stats/byproperties.php index 43875336810..f7d530f0f62 100644 --- a/htdocs/adherents/stats/byproperties.php +++ b/htdocs/adherents/stats/byproperties.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 @@ -40,7 +41,7 @@ if ($user->socid > 0) { } $result = restrictedArea($user, 'adherent', '', '', 'cotisation'); -$year = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); +$year = (int) dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS')))); $endyear = $year; @@ -90,7 +91,7 @@ if ($resql) { $foundmor++; } - $data[$obj->code] = array('label'=>$obj->code, 'nb'=>$obj->nb, 'nbsubscriptions'=>$obj->nbsubscriptions, 'lastdate'=>$db->jdate($obj->lastdate), 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)); + $data[$obj->code] = array('label' => $obj->code, 'nb' => $obj->nb, 'nbsubscriptions' => $obj->nbsubscriptions, 'lastdate' => $db->jdate($obj->lastdate), 'lastsubscriptiondate' => $db->jdate($obj->lastsubscriptiondate)); $i++; } @@ -162,10 +163,10 @@ print ''.$langs->trans("LatestSubscriptionDate").'
'; if (!empty($mysoc->country_code)) { - print ''; + print ''; } else { print $countrynotdefined; } @@ -663,7 +663,7 @@ if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-') { if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-') { print '
'; if (!empty($mysoc->country_code)) { - print ''; + print ''; } else { print $countrynotdefined; } @@ -674,7 +674,7 @@ if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-') { if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-') { print '
'; if (!empty($mysoc->country_code)) { - print ''; + print ''; } else { print $countrynotdefined; } @@ -685,7 +685,7 @@ if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-') { if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-') { print '
'; if (!empty($mysoc->country_code)) { - print ''; + print ''; } else { print $countrynotdefined; } @@ -696,7 +696,7 @@ if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-') { if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-') { print '
'; if (!empty($mysoc->country_code)) { - print ''; + print ''; } else { print $countrynotdefined; } @@ -707,7 +707,7 @@ if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-') { if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-') { print '
'; if (!empty($mysoc->country_code)) { - print ''; + print ''; } else { print $countrynotdefined; } @@ -716,9 +716,9 @@ if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-') { // ProfId7 if ($langs->transcountry("ProfId7", $mysoc->country_code) != '-') { - print '
'; + print '
'; if (!empty($mysoc->country_code)) { - print ''; + print ''; } else { print $countrynotdefined; } @@ -727,9 +727,9 @@ if ($langs->transcountry("ProfId7", $mysoc->country_code) != '-') { // ProfId8 if ($langs->transcountry("ProfId8", $mysoc->country_code) != '-') { - print '
'; + print '
'; if (!empty($mysoc->country_code)) { - print ''; + print ''; } else { print $countrynotdefined; } @@ -738,9 +738,9 @@ if ($langs->transcountry("ProfId8", $mysoc->country_code) != '-') { // ProfId9 if ($langs->transcountry("ProfId9", $mysoc->country_code) != '-') { - print '
'; + print '
'; if (!empty($mysoc->country_code)) { - print ''; + print ''; } else { print $countrynotdefined; } @@ -749,9 +749,9 @@ if ($langs->transcountry("ProfId9", $mysoc->country_code) != '-') { // ProfId10 if ($langs->transcountry("ProfId10", $mysoc->country_code) != '-') { - print '
'; + print '
'; if (!empty($mysoc->country_code)) { - print ''; + print ''; } else { print $countrynotdefined; } diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index da9b0271b15..b75e50e7a01 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -984,7 +984,7 @@ if (empty($reshook)) { } $i = 0; foreach ($listfieldmodify as $field) { - $keycode = $listfieldvalue[$i]; + $keycode = empty($listfieldvalue[$i]) ? '' : $listfieldvalue[$i]; if (empty($keycode)) { $keycode = $field; } @@ -1001,7 +1001,7 @@ if (empty($reshook)) { $sql .= ","; } $sql .= $field."="; - if ($listfieldvalue[$i] == 'sortorder') { // For column name 'sortorder', we use the field name 'position' + if ($keycode == 'sortorder') { // For column name 'sortorder', we use the field name 'position' $sql .= GETPOSTINT('position'); } elseif (GETPOST($keycode) == '' && !($keycode == 'code' && $id == 10)) { $sql .= "null"; // For vat, we want/accept code = '' diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php index a4911e94e52..c3a08c3612f 100644 --- a/htdocs/admin/limits.php +++ b/htdocs/admin/limits.php @@ -3,6 +3,7 @@ * Copyright (C) 2009-2018 Regis Houssin * Copyright (C) 2010 Juanjo Menent * Copyright (C) 2023 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 @@ -80,7 +81,7 @@ if ($action == 'update' && !$cancel) { } if ($valmainroundingruletot) { - if ($valmainroundingruletot * pow(10, $valmainmaxdecimalstot) < 1) { + if ((float) $valmainroundingruletot * pow(10, $valmainmaxdecimalstot) < 1) { $langs->load("errors"); $error++; setEventMessages($langs->trans("ErrorMAIN_ROUNDING_RULE_TOTCanMAIN_MAX_DECIMALS_TOT"), null, 'errors'); @@ -239,7 +240,7 @@ if (empty($mysoc->country_code)) { $s = 2 / 3; $qty = 1; $vat = 0; - $tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc); + $tmparray = calcul_price_total(1, $qty * (float) price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc); print ''.$langs->trans("UnitPriceOfProduct").": ".price2num($s, 'MU'); print ' x '.$langs->trans("Quantity").": ".$qty; print ' - '.$langs->trans("VAT").": ".$vat.'%'; @@ -248,7 +249,7 @@ if (empty($mysoc->country_code)) { $s = 10 / 3; $qty = 1; $vat = 0; - $tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc); + $tmparray = calcul_price_total(1, $qty * (float) price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc); print ''.$langs->trans("UnitPriceOfProduct").": ".price2num($s, 'MU'); print ' x '.$langs->trans("Quantity").": ".$qty; print ' - '.$langs->trans("VAT").": ".$vat.'%'; @@ -257,7 +258,7 @@ if (empty($mysoc->country_code)) { $s = 10 / 3; $qty = 2; $vat = 0; - $tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc); + $tmparray = calcul_price_total(1, $qty * (float) price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc); print ''.$langs->trans("UnitPriceOfProduct").": ".price2num($s, 'MU'); print ' x '.$langs->trans("Quantity").": ".$qty; print ' - '.$langs->trans("VAT").": ".$vat.'%'; @@ -277,7 +278,7 @@ if (empty($mysoc->country_code)) { if ($num) { for ($i = 0; $i < $num; $i++) { $obj = $db->fetch_object($resql); - $vat_rates[] = array('vat_rate'=>$obj->vat_rate, 'code'=>$obj->vat_code, 'localtax_rate1'=>$obj->localtax_rate1, 'locltax_rate2'=>$obj->localtax_rate2); + $vat_rates[] = array('vat_rate' => $obj->vat_rate, 'code' => $obj->vat_code, 'localtax_rate1' => $obj->localtax_rate1, 'locltax_rate2' => $obj->localtax_rate2); } } } else { diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index ab111f7c67f..dd8278f19bf 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -144,14 +144,14 @@ if ($action == 'activate_MAIN_SECURITY_DISABLEFORGETPASSLINK') { if ($action == 'updatepattern') { $pattern = GETPOST("pattern", "alpha"); - $explodePattern = explode(';', $pattern); + $explodePattern = explode(';', $pattern); // List of ints separated with ';' containing counts $patternInError = false; - if ($explodePattern[0] < 1 || $explodePattern[4] < 0) { + if ((int) $explodePattern[0] < 1 || (int) $explodePattern[4] < 0) { $patternInError = true; } - if ($explodePattern[0] < $explodePattern[1] + $explodePattern[2] + $explodePattern[3]) { + if ((int) $explodePattern[0] < (int) $explodePattern[1] + (int) $explodePattern[2] + (int) $explodePattern[3]) { $patternInError = true; } diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 71dc5df45f6..5475e20d0d1 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2007 Rodolphe Quiedeville * Copyright (C) 2013 Juanjo Menent + * 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 @@ -112,11 +113,16 @@ if ($action == 'set') { dolibarr_del_const($db, 'SYSLOG_HANDLERS', -1); // To be sure there is not a setup into another entity dolibarr_set_const($db, 'SYSLOG_HANDLERS', json_encode($activeModules), 'chaine', 0, '', 0); - + $error = 0; + $errors = []; // Check configuration foreach ($activeModules as $modulename) { $module = new $modulename(); - $error = $module->checkConfiguration(); + $res = $module->checkConfiguration(); + if (!$res) { + $error++; + $errors = array_merge($errors, $module->errors); + } } @@ -125,7 +131,7 @@ if ($action == 'set') { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { $db->rollback(); - setEventMessages($error, $errors, 'errors'); + setEventMessages('', $errors, 'errors'); } } diff --git a/htdocs/asset/agenda.php b/htdocs/asset/agenda.php index 56e33e2e317..1669e7b688f 100644 --- a/htdocs/asset/agenda.php +++ b/htdocs/asset/agenda.php @@ -129,7 +129,6 @@ $form = new Form($db); if ($object->id > 0) { $title = $langs->trans("Agenda"); - //if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; $help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung'; llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-asset page-card_agenda'); diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index ed7a57e3af5..4c016282171 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -70,7 +70,7 @@ class Asset extends CommonObject * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" * 'label' the translation key. * 'picto' is code of a picto to show before value in forms - * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM) + * 'enabled' is a condition when the field must be managed (Example: 1 or 'getDolGlobalString("MY_SETUP_PARAM")' * 'position' is the sort order of field. * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing) @@ -1001,8 +1001,8 @@ class Asset extends CommonObject // futures depreciation lines //----------------------------------------------------- - $nb_days_in_year = getDolGlobalString('ASSET_DEPRECIATION_DURATION_PER_YEAR') ? $conf->global->ASSET_DEPRECIATION_DURATION_PER_YEAR : 365; - $nb_days_in_month = getDolGlobalString('ASSET_DEPRECIATION_DURATION_PER_MONTH') ? $conf->global->ASSET_DEPRECIATION_DURATION_PER_MONTH : 30; + $nb_days_in_year = getDolGlobalInt('ASSET_DEPRECIATION_DURATION_PER_YEAR', 365); + $nb_days_in_month = getDolGlobalInt('ASSET_DEPRECIATION_DURATION_PER_MONTH', 30); $period_amount = (float) price2num($depreciation_period_amount / $fields['duration'], 'MT'); $first_period_found = false; // TODO fix declaration of $begin_period @@ -1576,43 +1576,4 @@ class Asset extends CommonObject return ""; } } - - /** - * Create a document onto disk according to template module. - * - * @param string $modele Force template to use ('' to not force) - * @param Translate $outputlangs object lang a utiliser pour traduction - * @param int $hidedetails Hide details of lines - * @param int $hidedesc Hide description - * @param int $hideref Hide ref - * @param null|array $moreparams Array to provide more information - * @return int 0 if KO, 1 if OK - */ - // public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) - // { - // global $conf, $langs; - // - // $result = 0; - // $includedocgeneration = 1; - // - // $langs->load("assets"); - // - // if (!dol_strlen($modele)) { - // $modele = 'standard_asset'; - // - // if (!empty($this->model_pdf)) { - // $modele = $this->model_pdf; - // } elseif (!empty($conf->global->ASSET_ADDON_PDF)) { - // $modele = $conf->global->ASSET_ADDON_PDF; - // } - // } - // - // $modelpath = "core/modules/asset/doc/"; - // - // if ($includedocgeneration && !empty($modele)) { - // $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); - // } - // - // return $result; - // } } diff --git a/htdocs/asset/class/assetdepreciationoptions.class.php b/htdocs/asset/class/assetdepreciationoptions.class.php index dac2d1ad194..e11ecfb9321 100644 --- a/htdocs/asset/class/assetdepreciationoptions.class.php +++ b/htdocs/asset/class/assetdepreciationoptions.class.php @@ -39,7 +39,7 @@ class AssetDepreciationOptions extends CommonObject * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" * 'label' the translation key. * 'picto' is code of a picto to show before value in forms - * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM) + * 'enabled' is a condition when the field must be managed (Example: 1 or 'getDolGlobalString("MY_SETUP_PARAM")' * 'position' is the sort order of field. * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing) diff --git a/htdocs/asset/class/assetmodel.class.php b/htdocs/asset/class/assetmodel.class.php index 51243277071..2ec02762b94 100644 --- a/htdocs/asset/class/assetmodel.class.php +++ b/htdocs/asset/class/assetmodel.class.php @@ -76,7 +76,7 @@ class AssetModel extends CommonObject * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" * 'label' the translation key. * 'picto' is code of a picto to show before value in forms - * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM) + * 'enabled' is a condition when the field must be managed (Example: 1 or 'getDolGlobalString("MY_SETUP_PARAM")' * 'position' is the sort order of field. * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing) @@ -796,7 +796,7 @@ class AssetModel extends CommonObject */ public function doScheduledJob() { - global $conf, $langs; + //global $conf, $langs; //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log'; diff --git a/htdocs/asset/model/agenda.php b/htdocs/asset/model/agenda.php index 1eb0a2e850a..247d52408bf 100644 --- a/htdocs/asset/model/agenda.php +++ b/htdocs/asset/model/agenda.php @@ -135,7 +135,6 @@ $form = new Form($db); if ($object->id > 0) { $title = $langs->trans("Agenda"); - //if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; $help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung'; llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-asset page-model-card_agenda'); diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index bb385e34984..2604e35f362 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'bills', 'blockedlog', 'other')); @@ -154,7 +155,10 @@ if ($action === 'downloadblockchain') { $previoushash = ''; $firstid = ''; - if (!$error) { + if (! (GETPOSTINT('yeartoexport') > 0)) { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Year")), null, "errors"); + $error++; + } else { // Get ID of first line $sql = "SELECT rowid,date_creation,tms,user_fullname,action,amounts,element,fk_object,date_object,ref_object,signature,fk_user,object_data"; $sql .= " FROM ".MAIN_DB_PREFIX."blockedlog"; @@ -292,6 +296,7 @@ if ($action === 'downloadblockchain') { */ $form = new Form($db); +$formother = new FormOther($db); if (GETPOST('withtab', 'alpha')) { $title = $langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog'); @@ -374,24 +379,14 @@ if (GETPOST('withtab', 'alpha')) { // Add $param from extra fields //include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; -print '
'; +print ''; print ''; print '
'; print $langs->trans("RestrictYearToExport").': '; -$smonth = GETPOSTINT('monthtoexport'); // Month -$retstring = ''; -$retstring .= '"; -print $retstring; -print ''; +print $formother->select_month(GETPOSTINT('monthtoexport'), 'monthtoexport', 1, 0, 'minwidth50 maxwidth75imp valignmiddle', true); +print ''; print ''; print ''; if (getDolGlobalString('BLOCKEDLOG_USE_REMOTE_AUTHORITY')) { @@ -416,7 +411,7 @@ print ''; print ''; print '
'; // You can use div-table-responsive-no-min if you don't need reserved height for your table -print ''; +print '
'; // Line of filters print ''; @@ -465,9 +460,9 @@ print ''; print ''; // Status -print ''; // Status note diff --git a/htdocs/bom/bom_agenda.php b/htdocs/bom/bom_agenda.php index f6229b309a1..e8029fd4592 100644 --- a/htdocs/bom/bom_agenda.php +++ b/htdocs/bom/bom_agenda.php @@ -131,7 +131,6 @@ $form = new Form($db); if ($object->id > 0) { $title = $langs->trans("Agenda"); - //if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; $help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Agenda'; llxHeader('', $title, $help_url); diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 6de866029f7..d6d320b36a1 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -88,7 +88,7 @@ class BOM extends CommonObject * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" * 'label' the translation key. * 'picto' is code of a picto to show before value in forms - * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM) + * 'enabled' is a condition when the field must be managed (Example: 1 or 'getDolGlobalString("MY_SETUP_PARAM")' * 'position' is the sort order of field. * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 38da2d0077c..cf6ca335125 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -6,6 +6,7 @@ * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2013 Florian Henry * Copyright (C) 2017 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 @@ -34,7 +35,14 @@ * $type, $text, $description, $line */ -/** var ObjectLine $line */ +/** + * @var CommonObjectLine $line + * @var int $num + */ +'@phan-var-force CommonObjectLine $line + @phan-var-force int $num + @phan-var-force CommonObject $this + @phan-var-force CommonObject $object'; require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php'; @@ -44,8 +52,6 @@ if (empty($object) || !is_object($object)) { exit(1); } -'@phan-var-force CommonObject $this - @phan-var-force CommonObject $object'; global $filtertype; if (empty($filtertype)) { @@ -249,7 +255,7 @@ print ''; // Select of all the sub-BOM lines // From this point to the end of the file, we only take care of sub-BOM lines $sql = 'SELECT rowid, fk_bom_child, fk_product, qty FROM '.MAIN_DB_PREFIX.'bom_bomline AS bl'; -$sql.= ' WHERE fk_bom ='. (int) $tmpbom->id; +$sql .= ' WHERE fk_bom ='. (int) $tmpbom->id; $resql = $object->db->query($sql); if ($resql) { @@ -323,7 +329,7 @@ if ($resql) { if (!empty($sub_bom->id)) { $sub_bom->calculateCosts(); print ''; - $total_cost+= $sub_bom->total_cost * $sub_bom_line->qty * $line->qty; + $total_cost += $sub_bom->total_cost * $sub_bom_line->qty * $line->qty; } elseif ($sub_bom_product->type == Product::TYPE_SERVICE && isModEnabled('workstation') && !empty($sub_bom_product->fk_default_workstation)) { //Convert qty to hour $unit = measuringUnitString($sub_bom_line->fk_unit, '', '', 1); @@ -339,24 +345,24 @@ if ($resql) { } elseif ($sub_bom_product->cost_price > 0) { print ''; - $total_cost+= $sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty; + $total_cost += $sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty; } elseif ($sub_bom_product->pmp > 0) { // PMP if cost price isn't defined print ''; - $total_cost.= $sub_bom_product->pmp * $sub_bom_line->qty * $line->qty; + $total_cost .= $sub_bom_product->pmp * $sub_bom_line->qty * $line->qty; } else { // Minimum purchase price if cost price and PMP aren't defined $sql_supplier_price = 'SELECT MIN(price) AS min_price, quantity AS qty FROM '.MAIN_DB_PREFIX.'product_fournisseur_price'; - $sql_supplier_price.= ' WHERE fk_product = '. (int) $sub_bom_product->id; + $sql_supplier_price .= ' WHERE fk_product = '. (int) $sub_bom_product->id; $resql_supplier_price = $object->db->query($sql_supplier_price); if ($resql_supplier_price) { $obj = $object->db->fetch_object($resql_supplier_price); if (!empty($obj->qty) && !empty($sub_bom_line->qty) && !empty($line->qty)) { - $line_cost = $obj->min_price/$obj->qty * $sub_bom_line->qty * $line->qty; + $line_cost = $obj->min_price / $obj->qty * $sub_bom_line->qty * $line->qty; } else { $line_cost = $obj->min_price; } print ''; - $total_cost+= $line_cost; + $total_cost += $line_cost; } } diff --git a/htdocs/bookcal/availabilities_agenda.php b/htdocs/bookcal/availabilities_agenda.php index 5c29e0c45cc..88c0935c86d 100644 --- a/htdocs/bookcal/availabilities_agenda.php +++ b/htdocs/bookcal/availabilities_agenda.php @@ -143,7 +143,6 @@ $form = new Form($db); if ($object->id > 0) { $title = $langs->trans("Agenda"); - //if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; $help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung'; llxHeader('', $title, $help_url); diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 9b688ac3d3e..cf1ba00ba66 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -495,10 +495,10 @@ if (empty($reshook) && $action == 'add') { $selectedrecurrulefreq = $reg1[1]; } if ($object->recurrule && preg_match('/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i', $object->recurrule, $reg2)) { - $selectedrecurrulebymonthday = $reg2[1]; + $selectedrecurrulebymonthday = (int) $reg2[1]; } if ($object->recurrule && preg_match('/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg3)) { - $selectedrecurrulebyday = $reg3[1]; + $selectedrecurrulebyday = (int) $reg3[1]; } // Is event recurrent ? @@ -1300,10 +1300,10 @@ if ($action == 'create') { $selectedrecurrulefreq = $reg[1]; } if ($object->recurrule && preg_match('/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i', $object->recurrule, $reg)) { - $selectedrecurrulebymonthday = $reg[1]; + $selectedrecurrulebymonthday = (int) $reg[1]; } if ($object->recurrule && preg_match('/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg)) { - $selectedrecurrulebyday = $reg[1]; + $selectedrecurrulebyday = (int) $reg[1]; } print $form->selectarray('recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0, '', 0, 0, 0, '', 'marginrightonly'); @@ -1916,9 +1916,9 @@ if ($id > 0) { */ print ''; print ''; diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 3abd25ae840..106be0c0b25 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -729,7 +729,7 @@ $url = DOL_URL_ROOT.'/comm/action/card.php?action=create'; $url .= '&apyear='.$tmpforcreatebutton['year'].'&apmonth='.$tmpforcreatebutton['mon'].'&apday='.$tmpforcreatebutton['mday'].'&aphour='.$tmpforcreatebutton['hours'].'&apmin='.$tmpforcreatebutton['minutes']; $url .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')); -$newcardbutton = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, '', $user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allactions', 'create')); +$newcardbutton = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')); $param .= '&mode='.urlencode($mode); diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 796f17e710c..a952b9565d7 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -313,7 +313,7 @@ $form = new Form($db); $formcompany = new FormCompany($db); $title = $langs->trans("ThirdParty")." - ".$langs->trans('Customer'); -if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { +if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->name) { $title = $object->name." - ".$langs->trans('Customer'); } @@ -321,7 +321,6 @@ $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas|DE:Modul_Gesch llxHeader('', $title, $help_url); - if ($object->id > 0) { $head = societe_prepare_head($object); diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index e97f3d6df66..28bdb0b02d8 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -584,6 +584,9 @@ class AdvanceTargetingMailing extends CommonObject if (!empty($arrayquery['cust_saleman']) && count($arrayquery['cust_saleman']) > 0) { $sqlwhere[] = " (saleman.fk_user IN (".$this->db->sanitize(implode(',', $arrayquery['cust_saleman']))."))"; } + if (!empty($arrayquery['cust_state']) && count($arrayquery['cust_state']) > 0) { + $sqlwhere[] = " (t.fk_departement IN (".$this->db->sanitize(implode(',', $arrayquery['cust_state']))."))"; + } if (!empty($arrayquery['cust_country']) && count($arrayquery['cust_country']) > 0) { $sqlwhere[] = " (t.fk_pays IN (".$this->db->sanitize(implode(',', $arrayquery['cust_country']))."))"; } @@ -825,6 +828,12 @@ class AdvanceTargetingMailing extends CommonObject if (!empty($arrayquery['cust_saleman']) && count($arrayquery['cust_saleman']) > 0) { $sqlwhere[] = " (saleman.fk_user IN (".$this->db->sanitize(implode(',', $arrayquery['cust_saleman']))."))"; } + //if (!empty($arrayquery['cust_state'])) { + // $sqlwhere[] = $this->transformToSQL('tsd.nom', $arrayquery['cust_state']); + //} + if (!empty($arrayquery['cust_state']) && count($arrayquery['cust_state']) > 0) { + $sqlwhere[] = " (t.fk_departement IN (".$this->db->sanitize(implode(',', $arrayquery['cust_state']))."))"; + } if (!empty($arrayquery['cust_country']) && count($arrayquery['cust_country']) > 0) { $sqlwhere[] = " (ts.fk_pays IN (".$this->db->sanitize(implode(',', $arrayquery['cust_country']))."))"; } diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index 70f7c9ba975..16ba79dba54 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -87,6 +87,67 @@ class FormAdvTargetEmailing extends Form return $this->advMultiselectarray($htmlname, $options_array, $selected_array); } + /** + * Return combo list of activated countries, into language of user + * + * @param string $htmlname of html select object + * @param array $selected_array or Code or Label of preselected country + * @return string HTML string with select + */ + public function multiselectState($htmlname = 'state_id', $selected_array = array()) + { + global $conf, $langs; + + $langs->load("dict"); + $maxlength = 0; + + $out = ''; + $stateArray = array(); + $label = array(); + + $options_array = array(); + + $sql = "SELECT d.rowid as rowid, d.code_departement as code, d.nom as department, r.nom as region"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_departements d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions r on d.fk_region=r.code_region"; + $sql .= " WHERE d.active = 1 AND d.code_departement<>'' AND r.code_region<>''"; + //$sql .= " ORDER BY r.nom ASC, d.nom ASC"; + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + if ($num) { + $foundselected = false; + + while ($i < $num) { + $obj = $this->db->fetch_object($resql); + $stateArray [$i] ['rowid'] = $obj->rowid; + $stateArray [$i] ['code'] = $obj->code; + $stateArray [$i] ['label'] = $obj->region.'/'.$obj->department; + $label[$i] = $stateArray[$i]['label']; + $i++; + } + + $array1_sort_order = SORT_ASC; + array_multisort($label, $array1_sort_order, $stateArray); + + foreach ($stateArray as $row) { + $label = dol_trunc($row['label'], $maxlength, 'middle'); + if ($row['code']) { + $label .= ' ('.$row['code'].')'; + } + + $options_array[$row['rowid']] = $label; + } + } + } else { + dol_print_error($this->db); + } + + return $this->advMultiselectarray($htmlname, $options_array, $selected_array); + } + /** * Return combo list of activated countries, into language of user * diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index 42673dea754..652f771cb4e 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -1,6 +1,7 @@ * Copyright (C) 2005-2010 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 @@ -45,7 +46,7 @@ $mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hier $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOSTINT("page"); +$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // If $page is not defined, or '' or -1 or if we click on clear filters $page = 0; @@ -80,7 +81,7 @@ if (!$sortfield) { // List of fields to search into when doing a "search in all" $fieldstosearchall = array( - 'm.titre'=>'Ref', + 'm.titre' => 'Ref', ); $permissiontoread = $user->hasRight('mailing', 'lire'); @@ -370,7 +371,7 @@ if (empty($reshook)) { if (!empty($moreforfilter)) { print '
'; print $moreforfilter; - $parameters = array('type'=>$type); + $parameters = array('type' => $type); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; @@ -415,7 +416,7 @@ print '
'; // 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 @@ -466,7 +467,7 @@ if (!$filteremail) { // 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; print_liste_field_titre("Status", $_SERVER["PHP_SELF"], ($filteremail ? "mc.statut" : "m.statut"), $param, "", '', $sortfield, $sortorder, 'center '); @@ -603,7 +604,7 @@ if (empty($num)) { $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/comm/propal/agenda.php b/htdocs/comm/propal/agenda.php index 1fe3cf6d5dd..657f2e639f9 100644 --- a/htdocs/comm/propal/agenda.php +++ b/htdocs/comm/propal/agenda.php @@ -126,7 +126,6 @@ $form = new Form($db); if ($object->id > 0) { $title = $langs->trans("Agenda"); - //if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; $help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung'; llxHeader('', $title, $help_url); diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 444a2c97a66..8044e284b73 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -974,20 +974,20 @@ if (empty($reshook)) { setEventMessages($prod->ref.' - '.$prod->label.' ('.$price_subprice.' < '.$price_price_min.' '.strtolower($langs->trans("MinPrice")).')'."\n", null, 'warnings'); } // Manage $line->subprice and $line->multicurrency_subprice - $multicurrency_subprice = $subprice * $line->multicurrency_subprice / $line->subprice; + $multicurrency_subprice = (float) $subprice * $line->multicurrency_subprice / $line->subprice; // Update DB $result = $object->updateline($line->id, $subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_rate, $line->localtax2_rate, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $multicurrency_subprice); // Update $object with new margin info $line->price = $subprice; $line->marge_tx = $margin_rate; - $line->marque_tx = $margin_rate * $line->pa_ht / $subprice; - $line->total_ht = $line->qty * $subprice; - $line->total_tva = $line->tva_tx * $line->qty * $subprice; - $line->total_ttc = (1 + $line->tva_tx) * $line->qty * $subprice; + $line->marque_tx = $margin_rate * $line->pa_ht / (float) $subprice; + $line->total_ht = $line->qty * (float) $subprice; + $line->total_tva = $line->tva_tx * $line->qty * (float) $subprice; + $line->total_ttc = (1 + $line->tva_tx) * $line->qty * (float) $subprice; // Manage $line->subprice and $line->multicurrency_subprice - $line->multicurrency_total_ht = $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice; - $line->multicurrency_total_tva = $line->tva_tx * $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice; - $line->multicurrency_total_ttc = (1 + $line->tva_tx) * $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice; + $line->multicurrency_total_ht = $line->qty * (float) $subprice * $line->multicurrency_subprice / $line->subprice; + $line->multicurrency_total_tva = $line->tva_tx * $line->qty * (float) $subprice * $line->multicurrency_subprice / $line->subprice; + $line->multicurrency_total_ttc = (1 + $line->tva_tx) * $line->qty * (float) $subprice * $line->multicurrency_subprice / $line->subprice; // Used previous $line->subprice and $line->multicurrency_subprice above, now they can be set to their new values $line->subprice = $subprice; $line->multicurrency_subprice = $multicurrency_subprice; @@ -1206,20 +1206,20 @@ if (empty($reshook)) { // Set unit price to use if (!empty($price_ht) || (string) $price_ht === '0') { $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num($pu_ht * (1 + ((float) $tmpvat / 100)), 'MU'); + $pu_ttc = price2num((float) $pu_ht * (1 + ((float) $tmpvat / 100)), 'MU'); } elseif (!empty($price_ht_devise) || (string) $price_ht_devise === '0') { $pu_ht_devise = price2num($price_ht_devise, 'MU'); $pu_ht = ''; $pu_ttc = ''; } elseif (!empty($price_ttc) || (string) $price_ttc === '0') { $pu_ttc = price2num($price_ttc, 'MU'); - $pu_ht = price2num($pu_ttc / (1 + ((float) $tmpvat / 100)), 'MU'); + $pu_ht = price2num((float) $pu_ttc / (1 + ((float) $tmpvat / 100)), 'MU'); } elseif ($tmpvat != $tmpprodvat) { // Is this still used ? if ($price_base_type != 'HT') { - $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); + $pu_ht = price2num((float) $pu_ttc / (1 + ($tmpvat / 100)), 'MU'); } else { - $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); + $pu_ttc = price2num((float) $pu_ht * (1 + ($tmpvat / 100)), 'MU'); } } @@ -1344,10 +1344,10 @@ if (empty($reshook)) { // Check if we have a foreign currency // If so, we update the pu_equiv as the equivalent price in base currency if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { - $pu_equivalent = $pu_ht_devise * $currency_tx; + $pu_equivalent = (float) $pu_ht_devise * (float) $currency_tx; } if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { - $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; + $pu_equivalent_ttc = (float) $pu_ttc_devise * (float) $currency_tx; } // TODO $pu_equivalent or $pu_equivalent_ttc must be calculated from the one not null taking into account all taxes @@ -1366,11 +1366,11 @@ if (empty($reshook)) { // Check price is not lower than minimum if ($usermustrespectpricemin) { - if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min)) && $price_base_type == 'HT') { + if ($pu_equivalent && $price_min && (((float) price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min)) && $price_base_type == 'HT') { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; - } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc)) && $price_base_type == 'TTC') { + } elseif ($pu_equivalent_ttc && $price_min_ttc && (((float) price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc)) && $price_base_type == 'TTC') { $mesg = $langs->trans("CantBeLessThanMinPriceInclTax", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; @@ -1482,10 +1482,10 @@ if (empty($reshook)) { // Check if we have a foreign currency // If so, we update the pu_equiv as the equivalent price in base currency if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { - $pu_equivalent = $pu_ht_devise * $currency_tx; + $pu_equivalent = (float) $pu_ht_devise * (float) $currency_tx; } if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { - $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; + $pu_equivalent_ttc = (float) $pu_ttc_devise * (float) $currency_tx; } // TODO $pu_equivalent or $pu_equivalent_ttc must be calculated from the one not null taking into account all taxes @@ -1539,12 +1539,12 @@ if (empty($reshook)) { // Check price is not lower than minimum if ($usermustrespectpricemin) { - if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - (float) $remise_percent / 100)) < price2num($price_min)) && $price_base_type == 'HT') { + if ($pu_equivalent && $price_min && (((float) price2num($pu_equivalent) * (1 - (float) $remise_percent / 100)) < (float) price2num($price_min)) && $price_base_type == 'HT') { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; $action = 'editline'; - } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - (float) $remise_percent / 100)) < price2num($price_min_ttc)) && $price_base_type == 'TTC') { + } elseif ($pu_equivalent_ttc && $price_min_ttc && (((float) price2num($pu_equivalent_ttc) * (1 - (float) $remise_percent / 100)) < (float) price2num($price_min_ttc)) && $price_base_type == 'TTC') { $mesg = $langs->trans("CantBeLessThanMinPriceInclTax", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 04b4a6e99b2..f7e4da009f9 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -694,9 +694,9 @@ class Propal extends CommonObject // Anciens indicateurs: $price, $remise (a ne plus utiliser) $price = $pu; $remise = 0; - if ($remise_percent > 0) { - $remise = round(($pu * $remise_percent / 100), 2); - $price = $pu - $remise; + if ((float) $remise_percent > 0) { + $remise = round(((float) $pu * (float) $remise_percent / 100), 2); + $price = (float) $pu - $remise; } // Insert line @@ -901,9 +901,9 @@ class Propal extends CommonObject // Anciens indicateurs: $price, $remise (a ne plus utiliser) $price = $pu; $remise = 0; - if ($remise_percent > 0) { - $remise = round(($pu * $remise_percent / 100), 2); - $price = $pu - $remise; + if ((float) $remise_percent > 0) { + $remise = round(((float) $pu * (float) $remise_percent / 100), 2); + $price = (float) $pu - $remise; } //Fetch current line from the database and then clone the object and set it in $oldline property diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 1ed17699c6d..f98eb74fcee 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -84,7 +84,7 @@ if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes' && $permi $error++; setEventMessages($langs->trans("ErrorFailedToLoadDiscount"), null, 'errors'); } - if (!$error && price2num($amount_ttc_1 + $amount_ttc_2) != $discount->amount_ttc) { + if (!$error && price2num((float) $amount_ttc_1 + (float) $amount_ttc_2) != $discount->amount_ttc) { $error++; setEventMessages($langs->trans("TotalOfTwoDiscountMustEqualsOriginal"), null, 'errors'); } @@ -134,7 +134,7 @@ if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes' && $permi $newdiscount1->amount_tva = price2num($newdiscount1->amount_ttc - $newdiscount1->amount_ht); $newdiscount2->amount_tva = price2num($newdiscount2->amount_ttc - $newdiscount2->amount_ht); - $newdiscount1->multicurrency_amount_ttc = $amount_ttc_1 * ($discount->multicurrency_amount_ttc / $discount->amount_ttc); + $newdiscount1->multicurrency_amount_ttc = (float) $amount_ttc_1 * ($discount->multicurrency_amount_ttc / $discount->amount_ttc); $newdiscount2->multicurrency_amount_ttc = price2num($discount->multicurrency_amount_ttc - $newdiscount1->multicurrency_amount_ttc); $newdiscount1->multicurrency_amount_ht = price2num($newdiscount1->multicurrency_amount_ttc / (1 + $newdiscount1->tva_tx / 100), 'MT'); $newdiscount2->multicurrency_amount_ht = price2num($newdiscount2->multicurrency_amount_ttc / (1 + $newdiscount2->tva_tx / 100), 'MT'); @@ -558,7 +558,7 @@ if ($socid > 0) { if (count($showconfirminfo)) { $amount1 = price2num($showconfirminfo['amount_ttc'] / 2, 'MT'); - $amount2 = ($showconfirminfo['amount_ttc'] - $amount1); + $amount2 = ($showconfirminfo['amount_ttc'] - (float) $amount1); $formquestion = array( 'text' => $langs->trans('TypeAmountOfEachNewDiscount'), 0 => array('type' => 'text', 'name' => 'amount_ttc_1', 'label' => $langs->trans("AmountTTC").' 1', 'value' => $amount1, 'size' => '5'), @@ -705,7 +705,7 @@ if ($socid > 0) { if (count($showconfirminfo)) { $amount1 = price2num($showconfirminfo['amount_ttc'] / 2, 'MT'); - $amount2 = ($showconfirminfo['amount_ttc'] - $amount1); + $amount2 = ($showconfirminfo['amount_ttc'] - (float) $amount1); $formquestion = array( 'text' => $langs->trans('TypeAmountOfEachNewDiscount'), 0 => array('type' => 'text', 'name' => 'amount_ttc_1', 'label' => $langs->trans("AmountTTC").' 1', 'value' => $amount1, 'size' => '5'), diff --git a/htdocs/commande/agenda.php b/htdocs/commande/agenda.php index af2a5da5594..be9a4fcf168 100644 --- a/htdocs/commande/agenda.php +++ b/htdocs/commande/agenda.php @@ -126,7 +126,6 @@ $form = new Form($db); if ($object->id > 0) { $title = $langs->trans("Agenda"); - //if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; $help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung'; llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-order page-card_agenda'); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index eb3b5fd0fa5..46309e4168e 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -899,10 +899,10 @@ if (empty($reshook)) { // Set unit price to use if (!empty($price_ht) || $price_ht === '0') { $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); + $pu_ttc = price2num((float) $pu_ht * (1 + ($tmpvat / 100)), 'MU'); } elseif (!empty($price_ttc) || $price_ttc === '0') { $pu_ttc = price2num($price_ttc, 'MU'); - $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); + $pu_ht = price2num((float) $pu_ttc / (1 + ($tmpvat / 100)), 'MU'); } elseif ($tmpvat != $tmpprodvat) { // Is this still used ? if ($price_base_type != 'HT') { @@ -1031,10 +1031,10 @@ if (empty($reshook)) { // Check if we have a foreign currency // If so, we update the pu_equiv as the equivalent price in base currency if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { - $pu_equivalent = $pu_ht_devise * $currency_tx; + $pu_equivalent = (float) $pu_ht_devise * (float) $currency_tx; } if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { - $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; + $pu_equivalent_ttc = (float) $pu_ttc_devise * (float) $currency_tx; } // TODO $pu_equivalent or $pu_equivalent_ttc must be calculated from the one defined @@ -1052,11 +1052,11 @@ if (empty($reshook)) { // Check price is not lower than minimum if ($usermustrespectpricemin) { - if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min)) && $price_base_type == 'HT') { + if ($pu_equivalent && $price_min && (((float) price2num($pu_equivalent) * (1 - $remise_percent / 100)) < (float) price2num($price_min)) && $price_base_type == 'HT') { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; - } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc)) && $price_base_type == 'TTC') { + } elseif ($pu_equivalent_ttc && $price_min_ttc && (((float) price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < (float) price2num($price_min_ttc)) && $price_base_type == 'TTC') { $mesg = $langs->trans("CantBeLessThanMinPriceInclTax", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; @@ -1161,10 +1161,10 @@ if (empty($reshook)) { // Check if we have a foreign currency // If so, we update the pu_equiv as the equivalent price in base currency if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { - $pu_equivalent = $pu_ht_devise * $currency_tx; + $pu_equivalent = (float) $pu_ht_devise * (float) $currency_tx; } if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { - $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; + $pu_equivalent_ttc = (float) $pu_ttc_devise * (float) $currency_tx; } // TODO $pu_equivalent or $pu_equivalent_ttc must be calculated from the one not null taking into account all taxes @@ -1221,12 +1221,12 @@ if (empty($reshook)) { // Check price is not lower than minimum if ($usermustrespectpricemin) { - if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min)) && $price_base_type == 'HT') { + if ($pu_equivalent && $price_min && (((float) price2num($pu_equivalent) * (1 - $remise_percent / 100)) < (float) price2num($price_min)) && $price_base_type == 'HT') { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; $action = 'editline'; - } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc)) && $price_base_type == 'TTC') { + } elseif ($pu_equivalent_ttc && $price_min_ttc && (((float) price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < (float) price2num($price_min_ttc)) && $price_base_type == 'TTC') { $mesg = $langs->trans("CantBeLessThanMinPriceInclTax", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 291ead61cd3..d2ee2bb3079 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1634,8 +1634,8 @@ class Commande extends CommonOrder $price = $pu; $remise = 0; if ($remise_percent > 0) { - $remise = round(($pu * $remise_percent / 100), 2); - $price = $pu - $remise; + $remise = round(((float) $pu * $remise_percent / 100), 2); + $price = (float) $pu - $remise; } // Insert line @@ -3187,8 +3187,8 @@ class Commande extends CommonOrder } $remise = 0; if ($remise_percent > 0) { - $remise = round(($pu * $remise_percent / 100), 2); - $price = ($pu - $remise); + $remise = round(((float) $pu * $remise_percent / 100), 2); + $price = ((float) $pu - $remise); } //Fetch current line from the database and then clone the object and set it in $oldline property diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 22703534d89..1c1bab1c252 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -94,12 +94,12 @@ $search_zip = GETPOST('search_zip', 'alpha'); $search_state = GETPOST('search_state', 'alpha'); $search_country = GETPOSTINT('search_country'); $search_type_thirdparty = GETPOSTINT('search_type_thirdparty'); -$search_user = GETPOSTINT('search_user'); -$search_sale = GETPOSTINT('search_sale'); +$search_user = GETPOST('search_user', 'intcomma'); +$search_sale = GETPOST('search_sale', 'intcomma'); $search_total_ht = GETPOST('search_total_ht', 'alpha'); $search_total_vat = GETPOST('search_total_vat', 'alpha'); $search_total_ttc = GETPOST('search_total_ttc', 'alpha'); -$search_warehouse = GETPOSTINT('search_warehouse'); +$search_warehouse = GETPOST('search_warehouse', 'intcomma'); $search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha'); $search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha'); diff --git a/htdocs/commande/list_det.php b/htdocs/commande/list_det.php index d9435aea40f..1ae80e341ec 100644 --- a/htdocs/commande/list_det.php +++ b/htdocs/commande/list_det.php @@ -106,12 +106,12 @@ $search_country = GETPOSTINT("search_country"); $search_type_thirdparty = GETPOSTINT("search_type_thirdparty"); $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $socid = GETPOSTINT('socid'); -$search_user = GETPOSTINT('search_user'); -$search_sale = GETPOSTINT('search_sale'); +$search_user = GETPOST('search_user', 'intcomma'); +$search_sale = GETPOST('search_sale', 'intcomma'); $search_total_ht = GETPOST('search_total_ht', 'alpha'); $search_total_vat = GETPOST('search_total_vat', 'alpha'); $search_total_ttc = GETPOST('search_total_ttc', 'alpha'); -$search_warehouse = GETPOSTINT('search_warehouse'); +$search_warehouse = GETPOST('search_warehouse', 'intcomma'); $search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha'); $search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha'); $search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha'); diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 05351d41713..36b12bf6b36 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -72,7 +72,7 @@ $date_stopMonth = GETPOSTINT('date_stopmonth'); $date_stopYear = GETPOSTINT('date_stopyear'); $date_stop = dol_mktime(23, 59, 59, $date_stopMonth, $date_stopDay, $date_stopYear, 'tzuserrel'); $action = GETPOST('action', 'aZ09'); -$projectid = (GETPOSTINT('projectid') ? GETPOSTINT('projectid') : 0); +$projectid = GETPOSTINT('projectid'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('comptafileslist', 'globallist')); @@ -667,7 +667,7 @@ foreach ($listofchoices as $choice => $val) { $disabled = ' disabled'; } $checked = (((!GETPOSTISSET('search') && $action != 'searchfiles') || GETPOST($choice)) ? ' checked="checked"' : ''); - print '
'; +print ''; $array = array("1" => "OnlyNonValid"); -print $form->selectarray('search_showonlyerrors', $array, $search_showonlyerrors, 1, 0, 0, '', 1, 0, 0, 'ASC', 'search_status maxwidth200 onrightofpage', 1); +print $form->selectarray('search_showonlyerrors', $array, $search_showonlyerrors, 1, 0, 0, '', 1, 0, 0, 'ASC', 'search_status width100 onrightofpage', 1); print '
'.price(price2num($sub_bom->total_cost * $sub_bom_line->qty * $line->qty, 'MT')).''; print ''.price(price2num($sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty, 'MT')).''; print ''.price(price2num($sub_bom_product->pmp * $sub_bom_line->qty * $line->qty, 'MT')).''.price2num($line_cost, 'MT').''; $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); - print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "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, 2, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); print '     -     '; - 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, 2, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); print '
 
 
'; // Graphs if ($mode == 'standard') { - $prevyear = $year; - $nextyear = $year; - $prevmonth = $month - 1; - $nextmonth = $month + 1; + $prevyear = (int) $year; + $nextyear = (int) $year; + $prevmonth = (int) $month - 1; + $nextmonth = (int) $month + 1; if ($prevmonth < 1) { $prevmonth = 12; $prevyear--; @@ -817,6 +824,10 @@ if ($mode == 'standard') { $nextmonth = 1; $nextyear++; } + $nextmonth = sprintf('%02d', $nextmonth); + $prevmonth = sprintf('%02d', $prevmonth); + $nextyear = sprintf('%04d', $nextyear); + $prevyear = sprintf('%04d', $prevyear); // For month $link = "".img_previous('', 'class="valignbottom"')." ".$langs->trans("Month")." ".img_next('', 'class="valignbottom"').""; @@ -832,8 +843,10 @@ if ($mode == 'standard') { print '
'; // For year - $prevyear = $year - 1; - $nextyear = $year + 1; + $prevyear = (int) $year - 1; + $nextyear = (int) $year + 1; + $nextyear = sprintf('%04d', $nextyear); + $prevyear = sprintf('%04d', $prevyear); $link = "".img_previous('', 'class="valignbottom"')." ".$langs->trans("Year")." ".img_next('', 'class="valignbottom"').""; print '
'.$link.'
'; diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 34c61ad8b31..d780eff0d41 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -528,11 +528,12 @@ if (empty($numref)) { print '
'; print ''; $reg = array(); - preg_match('/\((.+)\)/i', $objp->label, $reg); // Si texte entoure de parentheses on tente recherche de traduction - if ($reg[1] && $langs->trans($reg[1]) != $reg[1]) { + + preg_match('/\((.+)\)/i', $objp->label, $reg); // If text rounded by parenthesis, we try to search translation + if (!empty($reg[1]) && $langs->trans($reg[1]) != $reg[1]) { print $langs->trans($reg[1]); } else { - print $objp->label; + print dol_escape_htmltag($objp->label); } print ''; diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index 1ecfab6693c..f0aef136fd4 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -8,6 +8,7 @@ * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2023 Maxime Nicolas * Copyright (C) 2023 Benjamin GREMBI + * 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 @@ -164,7 +165,7 @@ if ($action == 'add' && $user->hasRight('banque', 'transfer')) { } if (!$error) { - $bank_line_id_from = $tmpaccountfrom->addline($dateo[$n], $typefrom, $label[$n], price2num(-1 * $amount[$n]), '', '', $user); + $bank_line_id_from = $tmpaccountfrom->addline($dateo[$n], $typefrom, $label[$n], price2num(-1 * (float) $amount[$n]), '', '', $user); } if (!($bank_line_id_from > 0)) { $error++; diff --git a/htdocs/compta/cashcontrol/class/cashcontrol.class.php b/htdocs/compta/cashcontrol/class/cashcontrol.class.php index 15959866819..bcb5426aa4c 100644 --- a/htdocs/compta/cashcontrol/class/cashcontrol.class.php +++ b/htdocs/compta/cashcontrol/class/cashcontrol.class.php @@ -60,7 +60,7 @@ class CashControl extends CommonObject * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" * 'label' the translation key. * 'picto' is code of a picto to show before value in forms - * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM) + * 'enabled' is a condition when the field must be managed (Example: 1 or 'getDolGlobalString("MY_SETUP_PARAM")' * 'position' is the sort order of field. * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing) diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index bf6a7310720..c59c5be8b34 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -356,7 +356,7 @@ if ($resql) { print ""; //$cash = $amountpertype['LIQ'] + $object->opening; - $cash = price2num($cash + $object->opening, 'MT'); + $cash = price2num($cash + (float) $object->opening, 'MT'); print '
'; print '

'; @@ -387,7 +387,7 @@ if ($resql) { print '
'; } - print $langs->trans("Total").' ('.$totalqty.' '.$langs->trans("Articles").') :
'.price($cash + $cheque + $bank + $other).'
'; + print $langs->trans("Total").' ('.$totalqty.' '.$langs->trans("Articles").') :
'.price((float) $cash + (float) $cheque + (float) $bank + (float) $other).'
'; print '
'.$langs->trans("TotalVAT").' :
'.price($totalvat).'
'; diff --git a/htdocs/compta/facture/agenda.php b/htdocs/compta/facture/agenda.php index 2880e158273..382d9eaafa4 100644 --- a/htdocs/compta/facture/agenda.php +++ b/htdocs/compta/facture/agenda.php @@ -126,7 +126,6 @@ $form = new Form($db); if ($object->id > 0) { $title = $langs->trans("Agenda"); - //if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; $help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung'; llxHeader('', $title, $help_url); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 69c113e86d7..4293ae1abe0 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1599,7 +1599,7 @@ if (empty($reshook)) { if ($qualified) { $totalamount += $lines[$i]->total_ht; // Fixme : is it not for the customer ? Shouldn't we take total_ttc ? $tva_tx = $lines[$i]->tva_tx; - $amountdeposit[$tva_tx] += ($lines[$i]->total_ht * $valuedeposit) / 100; + $amountdeposit[$tva_tx] += ($lines[$i]->total_ht * (float) $valuedeposit) / 100; } } @@ -1691,7 +1691,7 @@ if (empty($reshook)) { if (is_array($lines)) { foreach ($lines as $line) { // We keep ->subprice and ->pa_ht, but we change the qty - $line->qty = price2num($line->qty * $valuestandardinvoice / 100, 'MS'); + $line->qty = price2num($line->qty * (float) $valuestandardinvoice / 100, 'MS'); } } } @@ -1700,7 +1700,7 @@ if (empty($reshook)) { if (is_array($lines)) { foreach ($lines as $line) { // We keep ->subprice and ->pa_ht, but we change the qty - $line->qty = price2num($line->qty * $valuedeposit / 100, 'MS'); + $line->qty = price2num($line->qty * (float) $valuedeposit / 100, 'MS'); } } } @@ -2253,14 +2253,14 @@ if (empty($reshook)) { // TODO We should not have this if (!empty($price_ht) || $price_ht === '0') { $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); + $pu_ttc = price2num((float) $pu_ht * (1 + ($tmpvat / 100)), 'MU'); } elseif (!empty($price_ht_devise) || $price_ht_devise === '0') { $pu_ht_devise = price2num($price_ht_devise, 'MU'); $pu_ht = ''; $pu_ttc = ''; } elseif (!empty($price_ttc) || $price_ttc === '0') { $pu_ttc = price2num($price_ttc, 'MU'); - $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); + $pu_ht = price2num((float) $pu_ttc / (1 + ($tmpvat / 100)), 'MU'); } elseif ($tmpvat != $tmpprodvat) { // Is this still used ? if ($price_base_type != 'HT') { @@ -2399,7 +2399,7 @@ if (empty($reshook)) { $pu_equivalent = $pu_ht_devise * $currency_tx; } if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { - $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; + $pu_equivalent_ttc = (float) $pu_ttc_devise * $currency_tx; } // TODO $pu_equivalent or $pu_equivalent_ttc must be calculated from the one not null taking into account all taxes @@ -2437,11 +2437,11 @@ if (empty($reshook)) { // Check price is not lower than minimum (check is done only for standard or replacement invoices) if ($usermustrespectpricemin && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT)) { - if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min)) && $price_base_type == 'HT') { + if ($pu_equivalent && $price_min && (((float) price2num($pu_equivalent) * (1 - $remise_percent / 100)) < (float) price2num($price_min)) && $price_base_type == 'HT') { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; - } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc)) && $price_base_type == 'TTC') { + } elseif ($pu_equivalent_ttc && $price_min_ttc && (((float) price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < (float) price2num($price_min_ttc)) && $price_base_type == 'TTC') { $mesg = $langs->trans("CantBeLessThanMinPriceInclTax", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; @@ -2572,10 +2572,10 @@ if (empty($reshook)) { // Check if we have a foreign currency // If so, we update the pu_equiv as the equivalent price in base currency if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { - $pu_equivalent = $pu_ht_devise * $currency_tx; + $pu_equivalent = (float) $pu_ht_devise * (float) $currency_tx; } if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { - $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; + $pu_equivalent_ttc = (float) $pu_ttc_devise * (float) $currency_tx; } // TODO $pu_equivalent or $pu_equivalent_ttc must be calculated from the one not null taking into account all taxes @@ -2659,7 +2659,7 @@ if (empty($reshook)) { setEventMessages($mesg, null, 'errors'); $error++; $action = 'editline'; - } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - (float) $remise_percent / 100)) < price2num($price_min_ttc)) && $price_base_type == 'TTC') { + } elseif ($pu_equivalent_ttc && $price_min_ttc && (((float) price2num($pu_equivalent_ttc) * (1 - (float) $remise_percent / 100)) < (float) price2num($price_min_ttc)) && $price_base_type == 'TTC') { $mesg = $langs->trans("CantBeLessThanMinPriceInclTax", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; @@ -4195,7 +4195,7 @@ if ($action == 'create') { // TODO We should not need this. Also data comes from a not reliable value of $object->multicurrency_total_ttc that may be wrong if it was // calculated by summing lines that were in a currency for some of them and into another for others (lines from discount/down payment into another currency for example) if ($resteapayer == 0 && $multicurrency_resteapayer != 0 && $object->multicurrency_code != $conf->currency) { - $resteapayer = price2num($multicurrency_resteapayer / $object->multicurrency_tx, 'MT'); + $resteapayer = price2num((float) $multicurrency_resteapayer / $object->multicurrency_tx, 'MT'); } } diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index ef52e74f6c8..8ca14c775a7 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2020 Thibault FOUCART * Copyright (C) 2023 Joachim Kueter * 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 @@ -1480,10 +1481,10 @@ class Invoices extends DolibarrApi // Clean parameters amount if payment is for a credit note if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) { $resteapayer = price2num($resteapayer, 'MT'); - $amounts[$id] = (float) price2num(-1 * $resteapayer, 'MT'); + $amounts[$id] = (float) price2num(-1 * (float) $resteapayer, 'MT'); // Multicurrency $newvalue = price2num($this->invoice->multicurrency_total_ttc, 'MT'); - $multicurrency_amounts[$id] = (float) price2num(-1 * $newvalue, 'MT'); + $multicurrency_amounts[$id] = (float) price2num(-1 * (float) $newvalue, 'MT'); } else { $resteapayer = price2num($resteapayer, 'MT'); $amounts[$id] = (float) $resteapayer; @@ -1626,7 +1627,7 @@ class Invoices extends DolibarrApi } if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) { - $amount = price2num(-1 * $amount, 'MT'); + $amount = price2num(-1 * (float) $amount, 'MT'); } if ($is_multicurrency) { diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 63cee7e8709..c326bb1218b 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -115,8 +115,8 @@ $search_state = GETPOST("search_state"); $search_country = GETPOST("search_country", 'alpha'); $search_customer_code = GETPOST("search_customer_code", 'alphanohtml'); $search_type_thirdparty = GETPOSTINT("search_type_thirdparty"); -$search_user = GETPOSTINT('search_user'); -$search_sale = GETPOSTINT('search_sale'); +$search_user = GETPOST('search_user', 'intcomma'); +$search_sale = GETPOST('search_sale', 'intcomma'); $search_date_startday = GETPOSTINT('search_date_startday'); $search_date_startmonth = GETPOSTINT('search_date_startmonth'); $search_date_startyear = GETPOSTINT('search_date_startyear'); diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index 0e6ffde780c..1c277b80f3f 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -3,6 +3,7 @@ * Copyright (C) 2014 Ferran Marcet * Copyright (C) 2018 Laurent Destailleur * 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 @@ -333,26 +334,26 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $ //$invoice_customer->type=$x_coll[$my_coll_rate]['type'][$id]; //$company_static->fetch($x_coll[$my_coll_rate]['company_id'][$id]); $x_both[$my_coll_rate]['coll']['detail'][] = array( - 'id' =>$x_coll[$my_coll_rate]['facid'][$id], - 'descr' =>$x_coll[$my_coll_rate]['descr'][$id], - 'pid' =>$x_coll[$my_coll_rate]['pid'][$id], - 'pref' =>$x_coll[$my_coll_rate]['pref'][$id], - 'ptype' =>$x_coll[$my_coll_rate]['ptype'][$id], - 'payment_id'=>$x_coll[$my_coll_rate]['payment_id'][$id], - 'payment_amount'=>$x_coll[$my_coll_rate]['payment_amount'][$id], - 'ftotal_ttc'=>$x_coll[$my_coll_rate]['ftotal_ttc'][$id], - 'dtotal_ttc'=>$x_coll[$my_coll_rate]['dtotal_ttc'][$id], - 'dtype' =>$x_coll[$my_coll_rate]['dtype'][$id], - 'datef' =>$x_coll[$my_coll_rate]['datef'][$id], - 'datep' =>$x_coll[$my_coll_rate]['datep'][$id], + 'id' => $x_coll[$my_coll_rate]['facid'][$id], + 'descr' => $x_coll[$my_coll_rate]['descr'][$id], + 'pid' => $x_coll[$my_coll_rate]['pid'][$id], + 'pref' => $x_coll[$my_coll_rate]['pref'][$id], + 'ptype' => $x_coll[$my_coll_rate]['ptype'][$id], + 'payment_id' => $x_coll[$my_coll_rate]['payment_id'][$id], + 'payment_amount' => $x_coll[$my_coll_rate]['payment_amount'][$id], + 'ftotal_ttc' => $x_coll[$my_coll_rate]['ftotal_ttc'][$id], + 'dtotal_ttc' => $x_coll[$my_coll_rate]['dtotal_ttc'][$id], + 'dtype' => $x_coll[$my_coll_rate]['dtype'][$id], + 'datef' => $x_coll[$my_coll_rate]['datef'][$id], + 'datep' => $x_coll[$my_coll_rate]['datep'][$id], //'company_link'=>$company_static->getNomUrl(1,'',20), - 'ddate_start'=>$x_coll[$my_coll_rate]['ddate_start'][$id], - 'ddate_end' =>$x_coll[$my_coll_rate]['ddate_end'][$id], + 'ddate_start' => $x_coll[$my_coll_rate]['ddate_start'][$id], + 'ddate_end' => $x_coll[$my_coll_rate]['ddate_end'][$id], - 'totalht' =>$x_coll[$my_coll_rate]['totalht_list'][$id], - 'vat' =>$x_coll[$my_coll_rate]['vat_list'][$id], - 'localtax1' =>$x_coll[$my_coll_rate]['localtax1_list'][$id], - 'localtax2' =>$x_coll[$my_coll_rate]['localtax2_list'][$id], + 'totalht' => $x_coll[$my_coll_rate]['totalht_list'][$id], + 'vat' => $x_coll[$my_coll_rate]['vat_list'][$id], + 'localtax1' => $x_coll[$my_coll_rate]['localtax1_list'][$id], + 'localtax2' => $x_coll[$my_coll_rate]['localtax2_list'][$id], //'link' =>$invoice_customer->getNomUrl(1,'',12) ); } @@ -381,23 +382,23 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $ //$expensereport->type=$x_paye[$my_paye_rate]['type'][$id]; $x_both[$my_paye_rate]['paye']['detail'][] = array( - 'id' =>$x_paye[$my_paye_rate]['facid'][$id], - 'descr' =>$x_paye[$my_paye_rate]['descr'][$id], - 'pid' =>$x_paye[$my_paye_rate]['pid'][$id], - 'pref' =>$x_paye[$my_paye_rate]['pref'][$id], - 'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id], - 'payment_id' =>$x_paye[$my_paye_rate]['payment_id'][$id], - 'payment_amount' =>$x_paye[$my_paye_rate]['payment_amount'][$id], - 'ftotal_ttc' =>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), - 'dtotal_ttc' =>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), - 'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id], - 'ddate_start' =>$x_paye[$my_paye_rate]['ddate_start'][$id], - 'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id], + 'id' => $x_paye[$my_paye_rate]['facid'][$id], + 'descr' => $x_paye[$my_paye_rate]['descr'][$id], + 'pid' => $x_paye[$my_paye_rate]['pid'][$id], + 'pref' => $x_paye[$my_paye_rate]['pref'][$id], + 'ptype' => $x_paye[$my_paye_rate]['ptype'][$id], + 'payment_id' => $x_paye[$my_paye_rate]['payment_id'][$id], + 'payment_amount' => $x_paye[$my_paye_rate]['payment_amount'][$id], + 'ftotal_ttc' => price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), + 'dtotal_ttc' => price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), + 'dtype' => $x_paye[$my_paye_rate]['dtype'][$id], + 'ddate_start' => $x_paye[$my_paye_rate]['ddate_start'][$id], + 'ddate_end' => $x_paye[$my_paye_rate]['ddate_end'][$id], - 'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), - 'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id], - 'localtax1' =>$x_paye[$my_paye_rate]['localtax1_list'][$id], - 'localtax2' =>$x_paye[$my_paye_rate]['localtax2_list'][$id], + 'totalht' => price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), + 'vat' => $x_paye[$my_paye_rate]['vat_list'][$id], + 'localtax1' => $x_paye[$my_paye_rate]['localtax1_list'][$id], + 'localtax2' => $x_paye[$my_paye_rate]['localtax2_list'][$id], //'link' =>$expensereport->getNomUrl(1) ); } else { @@ -406,26 +407,26 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $ //$invoice_supplier->type=$x_paye[$my_paye_rate]['type'][$id]; //$company_static->fetch($x_paye[$my_paye_rate]['company_id'][$id]); $x_both[$my_paye_rate]['paye']['detail'][] = array( - 'id' =>$x_paye[$my_paye_rate]['facid'][$id], - 'descr' =>$x_paye[$my_paye_rate]['descr'][$id], - 'pid' =>$x_paye[$my_paye_rate]['pid'][$id], - 'pref' =>$x_paye[$my_paye_rate]['pref'][$id], - 'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id], - 'payment_id'=>$x_paye[$my_paye_rate]['payment_id'][$id], - 'payment_amount'=>$x_paye[$my_paye_rate]['payment_amount'][$id], - 'ftotal_ttc'=>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), - 'dtotal_ttc'=>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), - 'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id], - 'datef' =>$x_paye[$my_paye_rate]['datef'][$id], - 'datep' =>$x_paye[$my_paye_rate]['datep'][$id], + 'id' => $x_paye[$my_paye_rate]['facid'][$id], + 'descr' => $x_paye[$my_paye_rate]['descr'][$id], + 'pid' => $x_paye[$my_paye_rate]['pid'][$id], + 'pref' => $x_paye[$my_paye_rate]['pref'][$id], + 'ptype' => $x_paye[$my_paye_rate]['ptype'][$id], + 'payment_id' => $x_paye[$my_paye_rate]['payment_id'][$id], + 'payment_amount' => $x_paye[$my_paye_rate]['payment_amount'][$id], + 'ftotal_ttc' => price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), + 'dtotal_ttc' => price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), + 'dtype' => $x_paye[$my_paye_rate]['dtype'][$id], + 'datef' => $x_paye[$my_paye_rate]['datef'][$id], + 'datep' => $x_paye[$my_paye_rate]['datep'][$id], //'company_link'=>$company_static->getNomUrl(1,'',20), - 'ddate_start'=>$x_paye[$my_paye_rate]['ddate_start'][$id], - 'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id], + 'ddate_start' => $x_paye[$my_paye_rate]['ddate_start'][$id], + 'ddate_end' => $x_paye[$my_paye_rate]['ddate_end'][$id], - 'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), - 'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id], - 'localtax1' =>$x_paye[$my_paye_rate]['localtax1_list'][$id], - 'localtax2' =>$x_paye[$my_paye_rate]['localtax2_list'][$id], + 'totalht' => price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), + 'vat' => $x_paye[$my_paye_rate]['vat_list'][$id], + 'localtax1' => $x_paye[$my_paye_rate]['localtax1_list'][$id], + 'localtax2' => $x_paye[$my_paye_rate]['localtax2_list'][$id], //'link' =>$invoice_supplier->getNomUrl(1,'',12) ); } @@ -514,12 +515,12 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $ //print $langs->trans("NA"); } else { if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + $ratiopaymentinvoice = ($fields['payment_amount'] / (float) $fields['ftotal_ttc']); } } } //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + $temp_ht = (float) $fields['totalht'] * $ratiopaymentinvoice; $temp_vat = $fields['localtax'.$localTaxType] * $ratiopaymentinvoice; $subtot_paye_total_ht += $temp_ht; $subtot_paye_vat += $temp_vat; diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php index 63df3750d22..6644378a926 100644 --- a/htdocs/compta/localtax/quadri_detail.php +++ b/htdocs/compta/localtax/quadri_detail.php @@ -5,6 +5,7 @@ * Copyright (C) 2006-2007 Yannick Warnier * Copyright (C) 2014-2016 Juanjo Menent * 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 @@ -169,7 +170,7 @@ $calcmode .= ' ('.$langs->trans("TaxModuleSetupToMod // Set period $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); $prevyear = $year_start; -$q=0; +$q = 0; $prevquarter = $q; if ($prevquarter > 1) { $prevquarter--; @@ -277,26 +278,26 @@ if (!is_array($x_coll) || !is_array($x_paye)) { $invoice_customer->type = $x_coll[$my_coll_rate]['type'][$id]; $company_static->fetch($x_coll[$my_coll_rate]['company_id'][$id]); $x_both[$my_coll_rate]['coll']['detail'][] = array( - 'id' =>$x_coll[$my_coll_rate]['facid'][$id], - 'descr' =>$x_coll[$my_coll_rate]['descr'][$id], - 'pid' =>$x_coll[$my_coll_rate]['pid'][$id], - 'pref' =>$x_coll[$my_coll_rate]['pref'][$id], - 'ptype' =>$x_coll[$my_coll_rate]['ptype'][$id], - 'payment_id'=>$x_coll[$my_coll_rate]['payment_id'][$id], - 'payment_amount'=>$x_coll[$my_coll_rate]['payment_amount'][$id], - 'ftotal_ttc'=>$x_coll[$my_coll_rate]['ftotal_ttc'][$id], - 'dtotal_ttc'=>$x_coll[$my_coll_rate]['dtotal_ttc'][$id], - 'dtype' =>$x_coll[$my_coll_rate]['dtype'][$id], - 'datef' =>$x_coll[$my_coll_rate]['datef'][$id], - 'datep' =>$x_coll[$my_coll_rate]['datep'][$id], - 'company_link'=>$company_static->getNomUrl(1, '', 20), - 'ddate_start'=>$x_coll[$my_coll_rate]['ddate_start'][$id], - 'ddate_end' =>$x_coll[$my_coll_rate]['ddate_end'][$id], - 'totalht' =>$x_coll[$my_coll_rate]['totalht_list'][$id], - 'localtax1'=> $x_coll[$my_coll_rate]['localtax1_list'][$id], - 'localtax2'=> $x_coll[$my_coll_rate]['localtax2_list'][$id], - 'vat' =>$x_coll[$my_coll_rate]['vat_list'][$id], - 'link' =>$invoice_customer->getNomUrl(1, '', 12) + 'id' => $x_coll[$my_coll_rate]['facid'][$id], + 'descr' => $x_coll[$my_coll_rate]['descr'][$id], + 'pid' => $x_coll[$my_coll_rate]['pid'][$id], + 'pref' => $x_coll[$my_coll_rate]['pref'][$id], + 'ptype' => $x_coll[$my_coll_rate]['ptype'][$id], + 'payment_id' => $x_coll[$my_coll_rate]['payment_id'][$id], + 'payment_amount' => $x_coll[$my_coll_rate]['payment_amount'][$id], + 'ftotal_ttc' => $x_coll[$my_coll_rate]['ftotal_ttc'][$id], + 'dtotal_ttc' => $x_coll[$my_coll_rate]['dtotal_ttc'][$id], + 'dtype' => $x_coll[$my_coll_rate]['dtype'][$id], + 'datef' => $x_coll[$my_coll_rate]['datef'][$id], + 'datep' => $x_coll[$my_coll_rate]['datep'][$id], + 'company_link' => $company_static->getNomUrl(1, '', 20), + 'ddate_start' => $x_coll[$my_coll_rate]['ddate_start'][$id], + 'ddate_end' => $x_coll[$my_coll_rate]['ddate_end'][$id], + 'totalht' => $x_coll[$my_coll_rate]['totalht_list'][$id], + 'localtax1' => $x_coll[$my_coll_rate]['localtax1_list'][$id], + 'localtax2' => $x_coll[$my_coll_rate]['localtax2_list'][$id], + 'vat' => $x_coll[$my_coll_rate]['vat_list'][$id], + 'link' => $invoice_customer->getNomUrl(1, '', 12) ); } } @@ -316,26 +317,26 @@ if (!is_array($x_coll) || !is_array($x_paye)) { $invoice_supplier->ref = $x_paye[$my_paye_rate]['facnum'][$id]; $invoice_supplier->type = $x_paye[$my_paye_rate]['type'][$id]; $x_both[$my_paye_rate]['paye']['detail'][] = array( - 'id' =>$x_paye[$my_paye_rate]['facid'][$id], - 'descr' =>$x_paye[$my_paye_rate]['descr'][$id], - 'pid' =>$x_paye[$my_paye_rate]['pid'][$id], - 'pref' =>$x_paye[$my_paye_rate]['pref'][$id], - 'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id], - 'payment_id'=>$x_paye[$my_paye_rate]['payment_id'][$id], - 'payment_amount'=>$x_paye[$my_paye_rate]['payment_amount'][$id], - 'ftotal_ttc'=>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), - 'dtotal_ttc'=>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), - 'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id], - 'datef' =>$x_paye[$my_paye_rate]['datef'][$id], - 'datep' =>$x_paye[$my_paye_rate]['datep'][$id], - 'company_link'=>$company_static->getNomUrl(1, '', 20), - 'ddate_start'=>$x_paye[$my_paye_rate]['ddate_start'][$id], - 'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id], - 'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), - 'localtax1'=> $x_paye[$my_paye_rate]['localtax1_list'][$id], - 'localtax2'=> $x_paye[$my_paye_rate]['localtax2_list'][$id], - 'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id], - 'link' =>$invoice_supplier->getNomUrl(1, '', 12) + 'id' => $x_paye[$my_paye_rate]['facid'][$id], + 'descr' => $x_paye[$my_paye_rate]['descr'][$id], + 'pid' => $x_paye[$my_paye_rate]['pid'][$id], + 'pref' => $x_paye[$my_paye_rate]['pref'][$id], + 'ptype' => $x_paye[$my_paye_rate]['ptype'][$id], + 'payment_id' => $x_paye[$my_paye_rate]['payment_id'][$id], + 'payment_amount' => $x_paye[$my_paye_rate]['payment_amount'][$id], + 'ftotal_ttc' => price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), + 'dtotal_ttc' => price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), + 'dtype' => $x_paye[$my_paye_rate]['dtype'][$id], + 'datef' => $x_paye[$my_paye_rate]['datef'][$id], + 'datep' => $x_paye[$my_paye_rate]['datep'][$id], + 'company_link' => $company_static->getNomUrl(1, '', 20), + 'ddate_start' => $x_paye[$my_paye_rate]['ddate_start'][$id], + 'ddate_end' => $x_paye[$my_paye_rate]['ddate_end'][$id], + 'totalht' => price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), + 'localtax1' => $x_paye[$my_paye_rate]['localtax1_list'][$id], + 'localtax2' => $x_paye[$my_paye_rate]['localtax2_list'][$id], + 'vat' => $x_paye[$my_paye_rate]['vat_list'][$id], + 'link' => $invoice_supplier->getNomUrl(1, '', 12) ); } } @@ -593,7 +594,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print price($fields['totalht']); if (price2num($fields['ftotal_ttc'])) { //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; - $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); + $ratiolineinvoice = ((float) $fields['dtotal_ttc'] / (float) $fields['ftotal_ttc']); //print ' ('.round($ratiolineinvoice*100,2).'%)'; } print '

'; if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + $ratiopaymentinvoice = ($fields['payment_amount'] / (float) $fields['ftotal_ttc']); } if ($fields['payment_amount'] && $fields['ftotal_ttc']) { $paymentfourn_static->id = $fields['payment_id']; @@ -623,7 +624,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { // VAT paid print ''; - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + $temp_ht = (float) $fields['totalht'] * $ratiopaymentinvoice; print price(price2num($temp_ht, 'MT'), 1); print ''; if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { - print price($sign * $multicurrency_remaintopay); + print price($sign * (float) $multicurrency_remaintopay); } print ''; - print price($sign * $remaintopay); + print price($sign * (float) $remaintopay); if (isModEnabled('prelevement')) { $numdirectdebitopen = 0; $totaldirectdebit = 0; @@ -805,7 +805,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if ($action != 'add_paiement') { if (!empty($conf->use_javascript_ajax)) { - print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $remaintopay)."'"); + print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmount' data-rowname='".$namef."' data-value='".($sign * (float) $remaintopay)."'"); } print ''; print ''; @@ -856,7 +856,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print '+'.price($totalrecudeposits); } print ''.price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')).''.price($sign * (float) price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')).' 
'; - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + $temp_ht = (float) $fields['totalht'] * $ratiopaymentinvoice; print price(price2num($temp_ht, 'MT'), 1); print ''; - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + $temp_ht = (float) $fields['totalht'] * $ratiopaymentinvoice; print price(price2num($temp_ht, 'MT'), 1); print '