diff --git a/.github/workflows/cache-clean-pr.yml b/.github/workflows/cache-clean-pr.yml index 51a4282a0e98f..bad5d6837df31 100644 --- a/.github/workflows/cache-clean-pr.yml +++ b/.github/workflows/cache-clean-pr.yml @@ -19,17 +19,17 @@ jobs: - name: Cleanup run: | gh extension install actions/gh-actions-cache - REPO=${{ github.repository }} - BRANCH=refs/pull/${{ github.event.pull_request.number }}/merge + REPO="${{ github.repository }}" + BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge" echo "Fetching list of cache key" - cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 ) + cacheKeysForPR=$(gh actions-cache list -R "$REPO" -B "$BRANCH" | cut -f 1 ) - ## Setting this to not fail the workflow while deleting cache keys. + ## Setting this to not fail the workflow while deleting cache keys. set +e echo "Deleting caches..." for cacheKey in $cacheKeysForPR do - gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm + gh actions-cache delete "$cacheKey" -R "$REPO" -B "$BRANCH" --confirm done echo "Done" env: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c7655592983e5..7e2854a9522f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,6 +36,6 @@ jobs: # Note (not tested, from https://github.com/orgs/community/discussions/38361) -# To cancel jobs if one failes, the following action may help +# To cancel jobs if one fails, the following action may help # - if: "failure()" # uses: "andymckay/cancel-action@0.3" diff --git a/.github/workflows/exakat.yml b/.github/workflows/exakat.yml index 3b1b2f656e00d..420ca085cad95 100644 --- a/.github/workflows/exakat.yml +++ b/.github/workflows/exakat.yml @@ -4,10 +4,8 @@ name: "Exakat analysis" on: # execute once a month, the 1st schedule: - - cron: "0 20 1 * *" + - cron: "0 20 1 * *" workflow_dispatch: - branches: - - develop permissions: contents: read @@ -19,6 +17,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 1 + ref: develop - name: Exakat uses: docker://exakat/exakat-ga with: diff --git a/.github/workflows/phan.yml b/.github/workflows/phan.yml index 56a33ef76c7e8..c1c1d6100481a 100644 --- a/.github/workflows/phan.yml +++ b/.github/workflows/phan.yml @@ -17,8 +17,7 @@ concurrency: cancel-in-progress: true env: gh_event: ${{ inputs.gh_event || github.event_name }} - PHAN_CONFIG: > - ${{ 'dev/tools/phan/config.php' }} + PHAN_CONFIG: dev/tools/phan/config.php PHAN_BASELINE: dev/tools/phan/baseline.txt PHAN_MIN_PHP: 7.0 PHAN_QUICK: ${{ github.event.schedule && '' || '--quick' }} @@ -43,7 +42,8 @@ jobs: tools: cs2pr,phan - name: Run Phan analysis run: | - phan $PHAN_QUICK -k $PHAN_CONFIG -B $PHAN_BASELINE --analyze-twice --minimum-target-php-version $PHAN_MIN_PHP --output-mode=checkstyle -o _phan.xml + # shellcheck disable=2086 + phan $PHAN_QUICK -k "$PHAN_CONFIG" -B "$PHAN_BASELINE" --analyze-twice --minimum-target-php-version "$PHAN_MIN_PHP" --output-mode=checkstyle -o _phan.xml - name: Add results to PR if: ${{ always() }} run: | diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index df4141f31a3ae..f2056f63a14d6 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -67,7 +67,7 @@ jobs: run: | set -o pipefail pre-commit gc - pre-commit run --show-diff-on-failure --color=always --all-files | tee ${RAW_LOG} + pre-commit run --show-diff-on-failure --color=always --all-files | tee "${RAW_LOG}" # The next uses git, which is slow for a bit repo. # - name: Get all changed php files (if PR) @@ -105,7 +105,8 @@ jobs: ALL_CHANGED_FILES: ${{ steps.changed-php.outputs.all_changed_files }} run: | set -o pipefail - pre-commit run php-cs --files ${ALL_CHANGED_FILES} | tee -a ${RAW_LOG} + # shellcheck disable=2086 + pre-commit run php-cs --files ${ALL_CHANGED_FILES} | tee -a "${RAW_LOG}" - name: Run some pre-commit hooks on all files on push to "main" branches if: | @@ -117,8 +118,8 @@ jobs: run: | set -o pipefail ln -sf ~/.cache .cache # Absolute path in .pre-commit-config.yaml - pre-commit run --hook-stage manual -a php-cs-with-cache | tee -a ${RAW_LOG} - pre-commit run --hook-stage manual -a sqlfluff-lint | tee -a ${RAW_LOG} + pre-commit run --hook-stage manual -a php-cs-with-cache | tee -a "${RAW_LOG}" + pre-commit run --hook-stage manual -a sqlfluff-lint | tee -a "${RAW_LOG}" ls -l ~/.cache/pre-commit/ - name: Convert Raw Log to Annotations diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml index 9dbdf1b5ee4e8..976a5415a4261 100644 --- a/.github/workflows/windows-ci.yml +++ b/.github/workflows/windows-ci.yml @@ -36,11 +36,6 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - - name: Setup MariaDB - uses: ankane/setup-mariadb@v1 - with: - # mariadb-version: ${{ matrix.mariadb-version }} - database: travis # Specify your database name - name: Setup PHP uses: shivammathur/setup-php@v2 with: @@ -66,10 +61,11 @@ jobs: KEY_ROOT: ${{ matrix.os }}-${{ env.ckey }}-${{ matrix.php_version }} with: # See https://github.com/actions/cache/issues/1275#issuecomment-1925217178 - enableCrossOsArchive: true + enableCrossOsArchive: true path: | ./db_init.sql ./db_init.sql.md5 + ./.cache/mariadb key: ${{ env.KEY_ROOT }}-${{ env.HASH }}-${{ env.CACHE_KEY_PART }}-${{ github.run_id }} restore-keys: | ${{ env.KEY_ROOT }}-${{ env.HASH }}-${{ env.CACHE_KEY_PART }}- @@ -78,6 +74,12 @@ jobs: ${{ env.KEY_ROOT }}-${{ env.HASH }}- ${{ env.KEY_ROOT }}- + - name: Setup MariaDB + uses: frederic34/setup-mariadb@v1 + with: + # mariadb-version: ${{ matrix.mariadb-version }} + database: travis # Specify your database name + - name: Create local php.ini with open_basedir restrictions shell: cmd # Objective: separate step, and before database initialisation to verify open_basedir restrictions @@ -114,6 +116,7 @@ jobs: # Note this is bash (MSYS) on Windows shell: bash run: | + # shellcheck disable=SC2129 ECHO "#[group]Directory contents to verify cache files, ..." ls -l ECHO "#[endgroup]" @@ -128,10 +131,12 @@ jobs: ls -l ECHO "#[endgroup]" # Export some tool paths to reuse the from CMD shell. - echo "TAIL=$(cygpath -w "$(which tail)")" >> "$GITHUB_ENV" - echo "GREP=$(cygpath -w "$(which grep)")" >> "$GITHUB_ENV" - echo "TEE=$(cygpath -w "$(which tee)")" >> "$GITHUB_ENV" - echo "BASEDIR=$(realpath .)" >> "$GITHUB_ENV" + { + echo "TAIL=$(cygpath -w "$(which tail)")" + echo "GREP=$(cygpath -w "$(which grep)")" + echo "TEE=$(cygpath -w "$(which tee)")" + echo "BASEDIR=$(realpath .)" + } >> "$GITHUB_ENV" - name: Run PHPUnit tests # continue-on-error: true @@ -184,8 +189,9 @@ jobs: if: ${{ ! cancelled() }} with: # See https://github.com/actions/cache/issues/1275#issuecomment-1925217178 - enableCrossOsArchive: true + enableCrossOsArchive: true key: ${{ steps.cache.outputs.cache-primary-key }} path: | ./db_init.sql ./db_init.sql.md5 + ./.cache/mariadb diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d23fe1be28a96..c2b29ef90af9d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ --- -exclude: (?x)^( htdocs/includes/ckeditor/.*|(\.[^/]*/.*))$ +exclude: (?x)^( htdocs/includes/ckeditor/.*|(\.(?!github/workflows)[^/]*/.*))$ repos: # Several miscellaneous checks and fix (on yaml files, end of files fix) - repo: https://github.com/pre-commit/pre-commit-hooks @@ -64,6 +64,12 @@ repos: hooks: - id: gitleaks + # Check github actions + - repo: https://github.com/rhysd/actionlint + rev: v1.7.3 + hooks: + - id: actionlint + # Beautify shell scripts - repo: https://github.com/lovesegfault/beautysh.git rev: v6.2.1 @@ -210,7 +216,7 @@ repos: - -x - dev/tools/codespell/codespell-lines-ignore.txt exclude_types: [image] - exclude: (?x)^(.phan/stubs/.*)$ + exclude: (?x)^(.phan/stubs/.*|phpstan\.neon.*)$ additional_dependencies: [tomli] - alias: codespell-lang-en_US # Only for translations with specialised exceptions diff --git a/ChangeLog b/ChangeLog index a8241b7557af1..a5a0368f78340 100644 --- a/ChangeLog +++ b/ChangeLog @@ -25,6 +25,7 @@ The following changes may create regressions for some external modules, but were * The experimental and deprecated module WebserviceClient is completely removed (SOAP technology is deprecated). May be replaced with the stable module Webhook. * The dynamic properties ->no_button_delete, ->no_button_edit, ->no_button_copy for $object Product that could be set by an external module must no more be set (not allowed by PHP 8.2). A module can already return an array with key 'no_button_delete', 'no_button_edit', 'no_button_copy' for same purpose. +* The old function dol_bc($var, $moreclass = '') has been removed. If you called it, just stop to call it. ***** ChangeLog for 20.0.0 compared to 19.0 ***** @@ -164,7 +165,7 @@ NEW: Module Website: Can link/unlink translation between web pages NEW: Move dir of cache for widgets NEW: multiselect with checkbox in categories/tags search for thirdparty list (#28335) NEW: new consts to redirect from massaction createbills (#29436) -NEW: new global string to preselect yes for one bill per thirparty in orderlist massaction (#29359) +NEW: new global string to preselect yes for one bill per third party in orderlist massaction (#29359) NEW: notification action triggers for cancelling orders and invoices NEW: now button when editing an event NEW: online signature of shipments (#29559) @@ -3302,7 +3303,7 @@ FIX: fix checkbox displayed according to module project setup parameters - work FIX: inconsistency in margin recording with option "Force to sale price" FIX: invoice PDF generation after payment FIX: mask selector fournisseur if module not activate -FIX: merge thirparty also work for bank URL entry +FIX: merge third party also works for bank URL entry FIX: Missing extrafields into export of agenda record FIX: missing parameter in select for POP FIX: missing return edit if update error diff --git a/dev/tools/codespell/codespell-dict.txt b/dev/tools/codespell/codespell-dict.txt index 2334fd033276f..f26d7250488ec 100644 --- a/dev/tools/codespell/codespell-dict.txt +++ b/dev/tools/codespell/codespell-dict.txt @@ -8,6 +8,7 @@ aplhanothtml->alphanohtml aploha->alpha aplohanothtml->alphanohtml aplphanothtml->alphanohtml +centpecent->centpercent choosed->chosen cumuled->cumulative dokument->document @@ -18,12 +19,32 @@ dollibarr->dolibarr extrafeild->extrafield thoose->those # fiche->card -nempty->an empty, empty, not empty, +maringbottomonly->marginbottomonly +maxwidthonsmartpone->maxwidthonsmartphone +maxwidthonspartphone->maxwidthonsmartphone +minwith100->minwidth100 +minwith200->minwidth200 mot de passe->password +multicurreny->multicurrency +nempty->an empty, empty, not empty, +nocellnopadding->nocellnopadd +nodrap->nodrag, nodrop, not de passe->password nothtml->nohtml +notoptoleftroright->notoptoleftnoright +nowraponalls->nowraponall +oddevene->oddeven +oddseven->oddeven +opacitymediuem->opacitymedium +pictofiwedwidth->pictofixedwidth +pictofixedwith->pictofixedwidth shippin->shipping tableau de bord->state board tagret->target -thridparty->thirdparty +tdoverflowmax100aaa->tdoverflowmax100 +tdoverlowmax200->tdoverflowmax200 +thirparty->thirdparty, third party, +thridparty->thirdparty, third party, +with100->width100 +with75->width75 wysiwig->wysiwyg diff --git a/dev/tools/codespell/codespell-ignore.txt b/dev/tools/codespell/codespell-ignore.txt index e0450f0c643b0..85595e74857a6 100644 --- a/dev/tools/codespell/codespell-ignore.txt +++ b/dev/tools/codespell/codespell-ignore.txt @@ -86,6 +86,10 @@ espace methode datee +# Translation keys +addin +amountin + # other blacklists confirmactionxxx diff --git a/dev/tools/codespell/codespell-lines-ignore.txt b/dev/tools/codespell/codespell-lines-ignore.txt index b355752270221..4a92b80dc80f0 100644 --- a/dev/tools/codespell/codespell-lines-ignore.txt +++ b/dev/tools/codespell/codespell-lines-ignore.txt @@ -2,17 +2,14 @@ if (empty($objMod->dictionaries) && !empty($objMod->{"dictionnaries"})) { print 'id.'&token='.newToken().'">'; $object->date_ech = $object->periode; - $object->periode = $object->date_ech; $reponsesadd = str_split($obj->reponses); $sql .= " SET reponses = '".$db->escape($reponsesadd)."'"; $sql .= " SET reponses = '0".$db->escape($obj->reponses)."'"; $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0); - // $object->periode = dol_get_last_day(year of $object->date_ech - 1m, month or $object->date_ech -1m) //$pice = ''; //$typea = ($objp->typea == 'birth') ? $picb : $pice; print ''; $dateemail = dol_stringtotime((string) $overview[0]->udate, 'gmt'); - $object->periode = $newdateperiod; $pice = ''; $typea = ($data[$j]->typea == 'birth') ? $picb : $pice; GETPOSTINT("mouvement"), @@ -25,8 +22,6 @@ $date_liv = dol_mktime(GETPOST('rehour'), GETPOST('remin'), GETPOST('resec'), GETPOST("remonth"), GETPOST("reday"), GETPOST("reyear")); $newfiletmp = preg_replace('/\.od(s|t)/i', '', $newfile); $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile); - $object->period = dol_time_plus_duree($object->periode, 1, 'm'); - $object->periode = dol_time_plus_duree($object->periode, 1, 'm'); $this->category->childs[] = $this->_cleanObjectDatas($cat); $this->periode = $this->db->jdate($obj->period); $tmp = array('id_users' => $obj->id_users, 'nom' => $obj->name, 'reponses' => $obj->reponses); @@ -58,12 +53,9 @@ if (empty($reyear) || empty($remonth) || empty($reday)) { jQuery("#mouvement").change(function() { preg_match('/:([!<>=\s]+|in|notin|like|notlike):/', $tmpcrit, $reg); - print $form->selectDate($object->periode, 'period', 0, 0, 0, 'charge', 1); print ''.$langs->trans("TransferStock").''; print ''.$langs->trans("ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv("Referers")).''; print ''.dol_print_date($db->jdate($obj->periode), 'day').''; - print ''.$langs->trans("AddIn").''; - print dol_print_date($object->periode, "day"); "sme", $action = 'transfert'; $cle_rib = strtolower(checkES($rib, $CCC)); @@ -97,9 +89,7 @@ if ($user->hasRight('stock', 'mouvement', 'creer')) { if (GETPOSTISSET("reday") && GETPOSTISSET("remonth") && GETPOSTISSET("reyear")) { if (empty($reyear) || empty($remonth) || empty($reday)) { - print ''; - print ''.$langs->trans("AddIn").''; - * @param float|string $selectedrate Force preselected vat rate. Can be '8.5' or '8.5 (NOO)' for example. Use '' for no forcing. + * @param float|string $selectedrate Force preselected vat rate. Can be '8.5' or '8.5 (NOO)' for example. Use '' for no forcing. $date = $obj->periode; $datepaid = dol_mktime(12, 0, 0, GETPOST("remonth"), GETPOST("reday"), GETPOST("reyear")); $datepaid = dol_mktime(12, 0, 0, GETPOSTINT("remonth"), GETPOSTINT("reday"), GETPOSTINT("reyear")); @@ -132,14 +122,12 @@ // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire TaskItem(pID, pName, pStart, pEnd, pColor, pLink, pMile, pRes, pComp, pGroup, pParent, pOpen, pDepend, pCaption, pNotes, pGantt)

if ($action == "transfert") { - if ($object->id > 0 && $action == 'addin') { if (GETPOST('reday')) { if (GETPOSTINT("reyear") && GETPOSTINT("remonth") && GETPOSTINT("reday")) { print ''; print ' '; } diff --git a/htdocs/accountancy/admin/closure.php b/htdocs/accountancy/admin/closure.php index a11c83cea464e..982222bf20d5a 100644 --- a/htdocs/accountancy/admin/closure.php +++ b/htdocs/accountancy/admin/closure.php @@ -148,16 +148,20 @@ // Accounting groups used for the balance sheet account print ''; -print ''.$langs->trans("ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT").''; +print ''; +print $form->textwithpicto($langs->trans("ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT"), $langs->trans("ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNTHelp")); +print ''; print ''; -print ''; +print ''; print ''; // Accounting groups used for the income statement print ''; -print ''.$langs->trans("ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT").''; +print ''; +print $form->textwithpicto($langs->trans("ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT"), $langs->trans("ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENTHelp")); +print ''; print ''; -print ''; +print ''; print ''; print "\n"; diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index 5d856d5027c91..ca68c0f5aed04 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -314,7 +314,7 @@ print '' . img_picto('', 'bill', 'class="pictofixedwidth"') . $langs->trans("UseAuxiliaryAccountOnCustomerDeposit") . ''; if (getDolGlobalInt('ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT')) { print ''; - print img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', 'warning'); + print img_picto($langs->trans("Activated"), 'switch_on', '', 0, 0, 0, '', 'warning'); print ''; } else { print ''; @@ -341,7 +341,7 @@ print '' . img_picto('', 'supplier_invoice', 'class="pictofixedwidth"') . $langs->trans("UseAuxiliaryAccountOnSupplierDeposit") . ''; if (getDolGlobalInt('ACCOUNTING_ACCOUNT_SUPPLIER_USE_AUXILIARY_ON_DEPOSIT')) { print ''; - print img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', 'warning'); + print img_picto($langs->trans("Activated"), 'switch_on', '', 0, 0, 0, '', 'warning'); print ''; } else { print ''; diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index b4f48bb27458c..aac530b137488 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -94,7 +94,7 @@ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } -if ($action == 'confirm_delete' && $confirm == "yes") { +if ($action == 'confirm_delete' && $confirm == "yes" && $permissiontoadd) { $result = $object->delete($user); if ($result >= 0) { header("Location: fiscalyear.php"); @@ -102,7 +102,7 @@ } else { setEventMessages($object->error, $object->errors, 'errors'); } -} elseif ($action == 'add') { +} elseif ($action == 'add' && $permissiontoadd) { if (!GETPOST('cancel', 'alpha')) { $error = 0; @@ -144,7 +144,7 @@ header("Location: ./fiscalyear.php"); exit(); } -} elseif ($action == 'update') { +} elseif ($action == 'update' && $permissiontoadd) { // Update record if (!GETPOST('cancel', 'alpha')) { $result = $object->fetch($id); @@ -166,8 +166,19 @@ header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit(); } -} +} elseif ($action == 'reopen' && $permissiontoadd && getDolGlobalString('ACCOUNTING_CAN_REOPEN_CLOSED_PERIOD')) { + $result = $object->fetch($id); + + $object->status = GETPOSTINT('status'); + $result = $object->update($user); + if ($result > 0) { + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit(); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } +} /* @@ -364,6 +375,10 @@ if ($user->hasRight('accounting', 'fiscalyear', 'write')) { print '
'; + if (getDolGlobalString('ACCOUNTING_CAN_REOPEN_CLOSED_PERIOD') && $object->status == $object::STATUS_CLOSED) { + print dolGetButtonAction($langs->trans("ReOpen"), '', 'reopen', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen&token='.newToken(), 'reopen', $permissiontoadd); + } + print ''.$langs->trans('Modify').''; //print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete); diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 4025db92cab39..517a43158545c 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -1,13 +1,14 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2024 Alexandre Spangaro + * Copyright (C) 2013-2024 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2014 Marcos García * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2021 Ferran Marcet + * 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 @@ -56,6 +57,7 @@ $list_binding = array( 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER', 'ACCOUNTING_DATE_START_BINDING', + 'ACCOUNTING_LABEL_OPERATION_ON_TRANSFER' ); $error = 0; @@ -402,6 +404,13 @@ } elseif ($key == 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER') { $array = array(0=>$langs->trans("PreviousMonth"), 1=>$langs->trans("CurrentMonth"), 2=>$langs->trans("Fiscalyear")); print $form->selectarray($key, $array, getDolGlobalInt('ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER', 0), 0, 0, 0, '', 0, 0, 0, '', 'onrightofpage width200'); + } elseif ($key == 'ACCOUNTING_LABEL_OPERATION_ON_TRANSFER') { + $array = array( + 0=>$langs->trans("ThirdPartyName") . ' - ' . $langs->trans("NumPiece") . ' - ' . $langs->trans("LabelAccount"), + 1=>$langs->trans("ThirdPartyName") . ' - ' . $langs->trans("NumPiece"), + 2=>$langs->trans("ThirdPartyName") + ); + print $form->selectarray($key, $array, getDolGlobalInt('ACCOUNTING_LABEL_OPERATION_ON_TRANSFER', 0), 0, 0, 0, '', 0, 0, 0, '', 'onrightofpage width200'); } else { print ''; } @@ -414,7 +423,7 @@ print ''.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_SALES").''; if (getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_SALES')) { print ''; - print img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', 'warning'); + print img_picto($langs->trans("Activated"), 'switch_on', '', 0, 0, 0, '', 'warning'); print ''; } else { print ''; @@ -427,7 +436,7 @@ print ''.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_PURCHASES").''; if (getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_PURCHASES')) { print ''; - print img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', 'warning'); + print img_picto($langs->trans("Activated"), 'switch_on', '', 0, 0, 0, '', 'warning'); print ''; } else { print ''; @@ -440,7 +449,7 @@ print ''.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS").''; if (getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS')) { print ''; - print img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', 'warning'); + print img_picto($langs->trans("Activated"), 'switch_on', '', 0, 0, 0, '', 'warning'); print ''; } else { print ''; diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index f5bfce73aff4f..0f7c57339f54c 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -438,7 +438,7 @@ print ''; // Line to enter new values - print ''; + print ''; $obj = new stdClass(); // If data was already input, we define them in obj to populate input fields. diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index ace31d2caa2f2..a0d23a13beb58 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -567,7 +567,7 @@ } $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { $moreforfilter .= $hookmanager->resPrint; } else { diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 43ed4e3a09d24..eacc1a1632e71 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -128,6 +128,7 @@ accessforbidden(); } + /* * Action */ @@ -169,10 +170,6 @@ $filter['t.doc_date<='] = $search_date_end; $param .= '&date_endmonth=' . GETPOSTINT('date_endmonth') . '&date_endday=' . GETPOSTINT('date_endday') . '&date_endyear=' . GETPOSTINT('date_endyear'); } - if (!empty($search_doc_date)) { - $filter['t.doc_date'] = $search_doc_date; - $param .= '&doc_datemonth=' . GETPOSTINT('doc_datemonth') . '&doc_dateday=' . GETPOSTINT('doc_dateday') . '&doc_dateyear=' . GETPOSTINT('doc_dateyear'); - } if (!empty($search_accountancy_code_start)) { if ($type == 'sub') { $filter['t.subledger_account>='] = $search_accountancy_code_start; @@ -207,7 +204,7 @@ } } -if ($action == 'export_csv') { +if ($action == 'export_csv' && $user->hasRight('accounting', 'mouvements', 'lire')) { $sep = getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV'); $filename = 'balance'; @@ -393,7 +390,7 @@ print '
'; print $moreforfilter; $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; } diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 9ac8eda9eca0e..1cc28021ef852 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -523,15 +523,15 @@ print dol_get_fiche_head($head, 'transaction', '', -1); - $object->ref = $object->piece_num; + $object->ref = (string) $object->piece_num; $object->label = $object->doc_ref; - $morehtmlref .= '
'; + $morehtmlref = '
'; $morehtmlref .= '
'; $morehtmlref .= $object->label; $morehtmlref .= '
'; - print dol_banner_tab($object, 'ref', $backlink, 1, 'piece_num', 'piece_num', $morehtmlref); + dol_banner_tab($object, 'ref', $backlink, 1, 'piece_num', 'piece_num', $morehtmlref); print '
'; @@ -958,7 +958,7 @@ if ($mode == '_tmp' && $action == '' && $permissiontoadd) { print '
'; print '
'; - if (empty($total_debit) && empty($total_debit)) { + if (empty($total_debit) && empty($total_credit)) { print ''; } elseif ($total_debit == $total_credit) { print ''.$langs->trans("ValidTransaction").''; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index bf97689732ff4..33e35a6a7c4d1 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -846,7 +846,7 @@ $moreforfilter .= '
'; $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { $moreforfilter .= $hookmanager->resPrint; } else { diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 798c355ecd793..f5092e7a9a865 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -775,7 +775,7 @@ public function getCatsCpts($catid = 0) * * @param int $categorytype -1=All, 0=Only non computed groups, 1=Only computed groups * @param int $active 1= active, 0=not active - * @return array|int Array of groups or -1 if error + * @return array|int Array of groups or -1 if error * @see getCatsCpts(), getCptsCat() */ public function getCats($categorytype = -1, $active = 1) diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 0e2442a9b6204..3a0b59a6740c4 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -74,7 +74,7 @@ class AccountingJournal extends CommonObject public $active; /** - * @var array Accounting account cached + * @var array Accounting account cached */ public static $accounting_account_cached = array(); @@ -583,7 +583,7 @@ public function getAssetData(User $user, $type = 'view', $date_start = null, $da $lines = array(); $lines[0][$accountancy_code_value_asset_sold] = -((float) $element_static->acquisition_value_ht - $last_cumulative_amount_ht); - $lines[0][$accountancy_code_depreciation_asset] = -$last_cumulative_amount_ht; + $lines[0][$accountancy_code_depreciation_asset] = - (float) $last_cumulative_amount_ht; $lines[0][$accountancy_code_asset] = $element_static->acquisition_value_ht; $disposal_amount_vat = $disposal_subject_to_vat ? (float) price2num($disposal_amount * $disposal_vat / 100, 'MT') : 0; @@ -928,7 +928,7 @@ public function exportCsv(&$journal_data = array(), $search_date_end = 0, $sep = * Get accounting account info * * @param string $account Accounting account number - * @return array{found:bool,label:string,code_formatted1:string,label_formatted_1:string,label_formatted_2:string} Accounting account info + * @return array{found:bool,label:string,code_formatted_1:string,label_formatted_1:string,label_formatted_2:string} Accounting account info */ public function getAccountingAccountInfos($account) { diff --git a/htdocs/accountancy/class/api_accountancy.class.php b/htdocs/accountancy/class/api_accountancy.class.php index 61faec2bc51e5..0b201108f5bc5 100644 --- a/htdocs/accountancy/class/api_accountancy.class.php +++ b/htdocs/accountancy/class/api_accountancy.class.php @@ -1,8 +1,8 @@ - * Copyright (C) 2019 Cedric Ancelin - * Copyright (C) 2023 Lionel Vessiller - * Copyright (C) 2024 MDW +/* Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2019 Cedric Ancelin + * Copyright (C) 2023 Lionel Vessiller + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index dbe2101cd3e54..2671adb04dff6 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -463,15 +463,13 @@ public function create(User $user, $notrigger = 0) dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); } - // Uncomment this and change MYOBJECT to your own tag if you - // want this action to call a trigger. - //if (! $error && ! $notrigger) { - - // // Call triggers - // $result=$this->call_trigger('MYOBJECT_CREATE',$user); - // if ($result < 0) $error++; - // // End call triggers - //} + // Call triggers + if (! $error && ! $notrigger) { + $result = $this->call_trigger('BOOKKEEPING_CREATE', $user); + if ($result < 0) { + $error++; + } + } // Commit or rollback if ($error) { @@ -716,6 +714,13 @@ public function createStd(User $user, $notrigger = 0, $mode = '') if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element.$mode); + // Call triggers + if (! $notrigger) { + $result = $this->call_trigger('BOOKKEEPING_CREATE', $user); + if ($result < 0) { + $error++; + } + } } // Commit or rollback @@ -1477,15 +1482,13 @@ public function update(User $user, $notrigger = 0, $mode = '') dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); } - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - //if (! $error && ! $notrigger) { - - // // Call triggers - // $result=$this->call_trigger('MYOBJECT_MODIFY',$user); - // if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} - // // End call triggers - //} + // Call triggers + if (! $error && ! $notrigger) { + $result = $this->call_trigger('BOOKKEEPING_MODIFY', $user); + if ($result < 0) { + $error++; + } + } // Commit or rollback if ($error) { @@ -1572,15 +1575,13 @@ public function delete(User $user, $notrigger = 0, $mode = '') $this->db->begin(); - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - //if (! $error && ! $notrigger) { - - // // Call triggers - // $result=$this->call_trigger('MYOBJECT_DELETE',$user); - // if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} - // // End call triggers - //} + // Call triggers + if (! $error && ! $notrigger) { + $result = $this->call_trigger('BOOKKEEPING_DELETE', $user); + if ($result < 0) { + $error++; + } + } if (!$error) { $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.$mode; @@ -2344,7 +2345,7 @@ public function getCanModifyBookkeepingSQL($alias = '', $force = false) global $conf; $alias = trim($alias); - $alias = !empty($alias) && strpos($alias, '.') < 0 ? $alias . "." : $alias; + $alias = !empty($alias) && strpos($alias, '.') === false ? $alias . "." : $alias; if (!isset(self::$can_modify_bookkeeping_sql_cached[$alias]) || $force) { $result = $this->loadFiscalPeriods($force, 'active'); @@ -2430,6 +2431,47 @@ public function canModifyBookkeeping($id, $mode = '') } } + /** + * Generate label operation when operation is transferred into accounting + * + * @param string $thirdpartyname Thirdparty name + * @param string $reference Reference of the element + * @param string $labelaccount Label of the accounting account + * @return string Label of the operation + */ + public function accountingLabelForOperation($thirdpartyname, $reference, $labelaccount) + { + global $conf; + + $accountingLabelOperation = ''; + + if (!getDolGlobalString('ACCOUNTING_LABEL_OPERATION_ON_TRANSFER') || getDolGlobalString('ACCOUNTING_LABEL_OPERATION_ON_TRANSFER') == 0) { + $truncThirdpartyName = 16; + // Avoid trunc with dot in accountancy for the compatibility with another accounting software + $accountingLabelOperation = dol_trunc($thirdpartyname, $truncThirdpartyName, 'right', 'UTF-8', 1); + if (!empty($reference)) { + $accountingLabelOperation .= ' - '. $reference; + } + if (!empty($labelaccount)) { + $accountingLabelOperation .= ' - '. $labelaccount; + } + } elseif (getDolGlobalString('ACCOUNTING_LABEL_OPERATION_ON_TRANSFER') == 1) { + $truncThirdpartyName = 32; + // Avoid trunc with dot in accountancy for the compatibility with another accounting software + $accountingLabelOperation = dol_trunc($thirdpartyname, $truncThirdpartyName, 'right', 'UTF-8', 1); + if (!empty($reference)) { + $accountingLabelOperation .= ' - '. $reference; + } + } elseif (getDolGlobalString('ACCOUNTING_LABEL_OPERATION_ON_TRANSFER') == 2) { + $truncThirdpartyName = 64; + // Avoid trunc with dot in accountancy for the compatibility with another accounting software + $accountingLabelOperation = dol_trunc($thirdpartyname, $truncThirdpartyName, 'right', 'UTF-8', 1); + } + dol_syslog('label'.$accountingLabelOperation, LOG_ERR); + + return $accountingLabelOperation; + } + /** * Is the bookkeeping date valid (on an open period or not on a closed period) ? * @@ -2536,7 +2578,7 @@ public function loadFiscalPeriods($force = false, $mode = 'active') } /** - * Get list of fiscal period + * Get list of fiscal period ordered by start date. * * @param string $filter Filter * @return array|int Return integer <0 if KO, Fiscal periods : [[id, date_start, date_end, label], ...] diff --git a/htdocs/accountancy/closure/index.php b/htdocs/accountancy/closure/index.php index 1846aafbb7550..16031d1962bf2 100644 --- a/htdocs/accountancy/closure/index.php +++ b/htdocs/accountancy/closure/index.php @@ -61,33 +61,57 @@ setEventMessages($object->error, $object->errors, 'errors'); } +// Define the arrays of fiscal periods $active_fiscal_periods = array(); +$first_active_fiscal_period = null; $last_fiscal_period = null; $current_fiscal_period = null; $next_fiscal_period = null; $next_active_fiscal_period = null; if (is_array($fiscal_periods)) { - foreach ($fiscal_periods as $fiscal_period) { - if (empty($fiscal_period['status'])) { + foreach ($fiscal_periods as $fiscal_period) { // List of fiscal periods sorted by date start + if (empty($first_active_fiscal_period) && empty($fiscal_period['status'])) { + $first_active_fiscal_period = $fiscal_period; + } + if (empty($fiscal_period['status'])) { // if not closed $active_fiscal_periods[] = $fiscal_period; } - if (isset($current_fiscal_period)) { + if (isset($current_fiscal_period)) { // If we already reach then current fiscal period, then this one is the next one just after if (!isset($next_fiscal_period)) { $next_fiscal_period = $fiscal_period; } if (!isset($next_active_fiscal_period) && empty($fiscal_period['status'])) { $next_active_fiscal_period = $fiscal_period; } - } else { + } else { // If we did not found the current fiscal period if ($fiscal_period_id == $fiscal_period['id'] || (empty($fiscal_period_id) && $fiscal_period['date_start'] <= $now && $now <= $fiscal_period['date_end'])) { $current_fiscal_period = $fiscal_period; } else { - $last_fiscal_period = $fiscal_period; + $last_fiscal_period = $fiscal_period; // $last_fiscal_period is in fact $previous_fiscal_period } } } } +// If a current fiscal period open with an end and start date was not found, we autoselect the first one that is open and has a start and end date defined +if (empty($current_fiscal_period) && !empty($first_active_fiscal_period)) { + $current_fiscal_period = $first_active_fiscal_period; + $last_fiscal_period = null; + $foundcurrent = false; + foreach ($fiscal_periods as $fiscal_period) { // List of fiscal periods sorted by date start + if ($foundcurrent) { + $next_fiscal_period = $fiscal_period; + break; + } + if ($fiscal_period['id'] == $current_fiscal_period['id']) { + $foundcurrent = true; + } + if (!$foundcurrent) { + $last_fiscal_period = $fiscal_period; + } + } +} + $accounting_groups_used_for_balance_sheet_account = array_filter(array_map('trim', explode(',', getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT'))), 'strlen'); $accounting_groups_used_for_income_statement = array_filter(array_map('trim', explode(',', getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT'))), 'strlen'); @@ -103,8 +127,8 @@ } if (empty($reshook)) { - if (isset($current_fiscal_period) && $user->hasRight('accounting', 'fiscalyear', 'write')) { - if ($action == 'confirm_step_1' && $confirm == "yes") { + if (isset($current_fiscal_period)) { + if ($action == 'confirm_step_1' && $confirm == "yes" && $user->hasRight('accounting', 'fiscalyear', 'write')) { $date_start = dol_mktime(0, 0, 0, GETPOSTINT('date_startmonth'), GETPOSTINT('date_startday'), GETPOSTINT('date_startyear')); $date_end = dol_mktime(23, 59, 59, GETPOSTINT('date_endmonth'), GETPOSTINT('date_endday'), GETPOSTINT('date_endyear')); @@ -119,21 +143,34 @@ setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } - } elseif ($action == 'confirm_step_2' && $confirm == "yes") { + } elseif ($action == 'confirm_step_2' && $confirm == "yes" && $user->hasRight('accounting', 'fiscalyear', 'write')) { $new_fiscal_period_id = GETPOSTINT('new_fiscal_period_id'); $separate_auxiliary_account = GETPOST('separate_auxiliary_account', 'aZ09'); $generate_bookkeeping_records = GETPOST('generate_bookkeeping_records', 'aZ09'); - $result = $object->closeFiscalPeriod($current_fiscal_period['id'], $new_fiscal_period_id, $separate_auxiliary_account, $generate_bookkeeping_records); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } else { - setEventMessages($langs->trans("AccountancyClosureCloseSuccessfully"), null, 'mesgs'); + $error = 0; + if ($generate_bookkeeping_records) { + if (!getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT')) { + $error++; + setEventMessages($langs->trans("ErrorAccountingClosureSetupNotComplete"), null, 'errors'); + } elseif (!getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT')) { + $error++; + setEventMessages($langs->trans("ErrorAccountingClosureSetupNotComplete"), null, 'errors'); + } + } - header("Location: " . $_SERVER['PHP_SELF'] . (isset($current_fiscal_period) ? '?fiscal_period_id=' . $current_fiscal_period['id'] : '')); - exit; + if (!$error) { + $result = $object->closeFiscalPeriod($current_fiscal_period['id'], $new_fiscal_period_id, $separate_auxiliary_account, $generate_bookkeeping_records); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } else { + setEventMessages($langs->trans("AccountancyClosureCloseSuccessfully"), null, 'mesgs'); + + header("Location: " . $_SERVER['PHP_SELF'] . (isset($current_fiscal_period) ? '?fiscal_period_id=' . $current_fiscal_period['id'] : '')); + exit; + } } - } elseif ($action == 'confirm_step_3' && $confirm == "yes") { + } elseif ($action == 'confirm_step_3' && $confirm == "yes" && $user->hasRight('accounting', 'fiscalyear', 'write')) { $inventory_journal_id = GETPOSTINT('inventory_journal_id'); $new_fiscal_period_id = GETPOSTINT('new_fiscal_period_id'); $date_start = dol_mktime(0, 0, 0, GETPOSTINT('date_startmonth'), GETPOSTINT('date_startday'), GETPOSTINT('date_startyear')); @@ -302,9 +339,7 @@ if (empty($current_fiscal_period)) { print $langs->trans('ErrorNoFiscalPeriodActiveFound', $langs->transnoentitiesnoconv("Accounting"), $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("FiscalPeriod")); -} - -if (isset($current_fiscal_period)) { +} else { // Step 1 $head = array(); $head[0][0] = DOL_URL_ROOT . '/accountancy/closure/index.php?fiscal_period_id=' . $current_fiscal_period['id']; @@ -370,7 +405,7 @@ if (empty($count_by_month['total']) && empty($current_fiscal_period['status'])) { $button = '' . $langs->trans("AccountancyClosureClose") . ''; } else { - $button = '' . $langs->trans("AccountancyClosureClose") . ''; + $button = '' . $langs->trans("AccountancyClosureClose") . ''; } print_barre_liste('', '', '', '', '', '', '', -1, '', '', 0, $button, '', 0, 1, 0); diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 8ec10ca961ebc..7d3c02eab2543 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -1,18 +1,18 @@ - * Copyright (C) 2007-2010 Jean Heimburger - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2012 Regis Houssin - * Copyright (C) 2013 Christophe Battarel - * Copyright (C) 2013-2022 Open-DSI - * Copyright (C) 2013-2024 Alexandre Spangaro - * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2014 Olivier Geffroy - * Copyright (C) 2017-2024 Frédéric France - * Copyright (C) 2018 Ferran Marcet - * Copyright (C) 2018-2024 Eric Seigne - * Copyright (C) 2021 Gauthier VERDOL - * Copyright (C) 2024 MDW +/* Copyright (C) 2007-2010 Laurent Destailleur + * Copyright (C) 2007-2010 Jean Heimburger + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2013 Christophe Battarel + * Copyright (C) 2013-2022 Open-DSI + * Copyright (C) 2013-2024 Alexandre Spangaro + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2013-2014 Olivier Geffroy + * Copyright (C) 2017-2024 Frédéric France + * Copyright (C) 2018 Ferran Marcet + * Copyright (C) 2018-2024 Eric Seigne + * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 681ffd5d0ac82..4407435bf8053 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -1,13 +1,13 @@ - * Copyright (C) 2007-2010 Jean Heimburger - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2012 Regis Houssin - * Copyright (C) 2013-2024 Alexandre Spangaro - * Copyright (C) 2013-2016 Olivier Geffroy - * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2018 Frédéric France - * Copyright (C) 2018 Eric Seigne +/* Copyright (C) 2007-2010 Laurent Destailleur + * Copyright (C) 2007-2010 Jean Heimburger + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2013-2024 Alexandre Spangaro + * Copyright (C) 2013-2016 Olivier Geffroy + * Copyright (C) 2013-2016 Florian Henry + * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018 Eric Seigne * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify @@ -261,6 +261,9 @@ $now = dol_now(); $error = 0; + $userstatic = new User($db); + $bookkeepingstatic = new BookKeeping($db); + $accountingaccountexpense = new AccountingAccount($db); $accountingaccountexpense->fetch(0, getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT'), true); @@ -272,6 +275,10 @@ $db->begin(); + $userstatic->id = $tabuser[$key]['id']; + $userstatic->name = $tabuser[$key]['name']; + $userstatic->accountancy_code = $tabuser[$key]['user_accountancy_code']; + // Error if some lines are not binded/ready to be journalized if (!empty($errorforinvoice[$key]) && $errorforinvoice[$key] == 'somelinesarenotbound') { $error++; @@ -297,7 +304,7 @@ $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT'); $bookkeeping->label_compte = $accountingaccountexpense->label; - $bookkeeping->label_operation = $tabuser[$key]['name']; + $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($userstatic->name, '', $langs->trans("SubledgerAccount")); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; $bookkeeping->debit = ($mt <= 0) ? -$mt : 0; @@ -348,7 +355,7 @@ $bookkeeping->numero_compte = $k; $bookkeeping->label_compte = $accountingaccount->label; - $bookkeeping->label_operation = $accountingaccount->label; + $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($userstatic->name, '', $accountingaccount->label); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->debit = ($mt > 0) ? $mt : 0; @@ -419,7 +426,11 @@ $bookkeeping->numero_compte = $k; $bookkeeping->label_compte = $account_label; - $bookkeeping->label_operation = $langs->trans("VAT").' '.implode(', ', $def_tva[$key][$k]).' %'; + $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ? '' : $arrayofvat[$key][$k]) : implode(', ', $def_tva[$key][$k])); + $labelvataccount = $langs->trans("Taxes").' '.$tmpvatrate.' %'; + $labelvataccount .= ($numtax ? ' - Localtax '.$numtax : ''); + $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($userstatic->name, '', $labelvataccount); + $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->debit = ($mt > 0) ? $mt : 0; @@ -516,6 +527,9 @@ $type_export = 'journal'; include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; + $userstatic = new User($db); + $bookkeepingstatic = new BookKeeping($db); + // CSV header line print '"'.$langs->transnoentitiesnoconv("Date").'"'.$sep; print '"'.$langs->transnoentitiesnoconv("Piece").'"'.$sep; @@ -539,7 +553,7 @@ print '"'.$date.'"'.$sep; print '"'.$val["ref"].'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; - print '"'.dol_trunc($accountingaccount->label, 32).'"'.$sep; + print '"'.csvClean($bookkeepingstatic->accountingLabelForOperation($userstatic->name, '', $accountingaccount->label)).'"'.$sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'; print "\n"; @@ -552,7 +566,7 @@ print '"'.$date.'"'.$sep; print '"'.$val["ref"].'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; - print '"'.dol_trunc($langs->trans("VAT")).'"'.$sep; + print '"'.csvClean($bookkeepingstatic->accountingLabelForOperation($userstatic->name, '', $langs->trans("VAT").implode($def_tva[$key][$k]).' %')).'"'.$sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'; print "\n"; @@ -564,7 +578,7 @@ print '"'.$date.'"'.$sep; print '"'.$val["ref"].'"'.$sep; print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; - print '"'.dol_trunc($userstatic->name).'"'.$sep; + print '"'.csvClean($bookkeepingstatic->accountingLabelForOperation($userstatic->name, '', $langs->trans("Thirdparty"))).'"'.$sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; print '"'.($mt >= 0 ? price($mt) : '').'"'; } @@ -673,6 +687,7 @@ function writebookkeeping() { $expensereportstatic = new ExpenseReport($db); $expensereportlinestatic = new ExpenseReportLine($db); + $bookkeepingstatic = new BookKeeping($db); foreach ($taber as $key => $val) { $expensereportstatic->id = $key; @@ -733,7 +748,7 @@ function writebookkeeping() { print ''; $userstatic->id = $tabuser[$key]['id']; $userstatic->name = $tabuser[$key]['name']; - print "".$userstatic->getNomUrl(0, 'user', 16).' - '.$accountingaccount->label.""; + print "" . $bookkeepingstatic->accountingLabelForOperation($userstatic->getNomUrl(0, 'user'), '', $accountingaccount->label) . ""; print ''.($mt >= 0 ? price($mt) : '').""; print ''.($mt < 0 ? price(-$mt) : '').""; print ""; @@ -769,7 +784,7 @@ function writebookkeeping() { print $accountoshow; } print ''; - print "".$userstatic->getNomUrl(0, 'user', 16).' - '.$langs->trans("SubledgerAccount").""; + print "" . $bookkeepingstatic->accountingLabelForOperation($userstatic->getNomUrl(0, 'user'), '', $langs->trans("SubledgerAccount")) . ""; print ''.($mt < 0 ? price(-$mt) : '').""; print ''.($mt >= 0 ? price($mt) : '').""; print ""; @@ -806,8 +821,10 @@ function writebookkeeping() { // Subledger account print ""; print ''; - print "".$userstatic->getNomUrl(0, 'user', 16).' - '.$langs->trans("VAT").' '.implode(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : ''); - print ""; + $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ? '' : $arrayofvat[$key][$k]) : implode(', ', $def_tva[$key][$k])); + $labelvatrate = $langs->trans("Taxes").' '.$tmpvatrate.' %'; + $labelvatrate .= ($numtax ? ' - Localtax '.$numtax : ''); + print "" . $bookkeepingstatic->accountingLabelForOperation($userstatic->getNomUrl(0, 'user'), '', $labelvatrate) . ""; print ''.($mt >= 0 ? price($mt) : '').""; print ''.($mt < 0 ? price(-$mt) : '').""; print ""; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 31e08f0bdaf9f..0652a6bfc5223 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -1,14 +1,14 @@ - * Copyright (C) 2007-2010 Jean Heimburger - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2012 Regis Houssin - * Copyright (C) 2013-2024 Alexandre Spangaro - * Copyright (C) 2013-2016 Olivier Geffroy - * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2018-2024 Frédéric France - * Copyright (C) 2018 Eric Seigne - * Copyright (C) 2024 MDW +/* Copyright (C) 2007-2010 Laurent Destailleur + * Copyright (C) 2007-2010 Jean Heimburger + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2013-2024 Alexandre Spangaro + * Copyright (C) 2013-2016 Olivier Geffroy + * Copyright (C) 2013-2016 Florian Henry + * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2018 Eric Seigne + * 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 @@ -413,6 +413,7 @@ $companystatic = new Societe($db); $invoicestatic = new FactureFournisseur($db); $accountingaccountsupplier = new AccountingAccount($db); + $bookkeepingstatic = new BookKeeping($db); $accountingaccountsupplier->fetch(0, getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'), true); @@ -481,7 +482,7 @@ $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'); $bookkeeping->label_compte = $accountingaccountsupplier->label; - $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("SubledgerAccount"); + $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref_supplier, $langs->trans("SubledgerAccount")); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; $bookkeeping->debit = ($mt <= 0) ? -$mt : 0; @@ -559,7 +560,7 @@ $bookkeeping->numero_compte = $k; $bookkeeping->label_compte = $label_account; - $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref_supplier.' - '.$label_account; + $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref_supplier, $label_account); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->debit = ($mt > 0) ? $mt : 0; @@ -647,7 +648,11 @@ $bookkeeping->numero_compte = $k; $bookkeeping->label_compte = $label_account; - $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("VAT").' '.implode(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : ''); + $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ? '' : $arrayofvat[$key][$k]) : implode(', ', $def_tva[$key][$k])); + $labelvataccount = $langs->trans("Taxes").' '.$tmpvatrate.' %'; + $labelvataccount .= ($numtax ? ' - Localtax '.$numtax : ''); + $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref_supplier, $labelvataccount); + $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->debit = ($mt > 0) ? $mt : 0; @@ -699,7 +704,7 @@ $bookkeeping->numero_compte = $k; - $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("VAT").' NPR'; + $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref_supplier, $langs->trans("VAT").' NPR'); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->debit = ($mt > 0) ? $mt : 0; @@ -793,6 +798,7 @@ $companystatic = new Fournisseur($db); $invoicestatic = new FactureFournisseur($db); + $bookkeepingstatic = new BookKeeping($db); foreach ($tabfac as $key => $val) { $companystatic->id = $tabcompany[$key]['id']; @@ -831,12 +837,12 @@ print '"'.$key.'"'.$sep; print '"'.$date.'"'.$sep; print '"'.$val["refsologest"].'"'.$sep; - print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 32), 'ISO-8859-1').'"'.$sep; + print '"'.csvClean(dol_trunc($companystatic->name, 32)).'"'.$sep; print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER')).'"'.$sep; print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; print '"'.$langs->trans("Thirdparty").'"'.$sep; - print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 16), 'ISO-8859-1').' - '.$val["refsuppliersologest"].' - '.$langs->trans("Thirdparty").'"'.$sep; + print '"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $val["refsuppliersologest"], $langs->trans("Thirdparty"))).'"'.$sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; print '"'.$journal.'"'; @@ -852,12 +858,12 @@ print '"'.$key.'"'.$sep; print '"'.$date.'"'.$sep; print '"'.$val["refsologest"].'"'.$sep; - print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 32), 'ISO-8859-1').'"'.$sep; + print '"'.csvClean(dol_trunc($companystatic->name, 32)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '""'.$sep; - print '"'.mb_convert_encoding(dol_trunc($accountingaccount->label, 32), 'ISO-8859-1').'"'.$sep; - print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 16), 'ISO-8859-1').' - '.$val["refsuppliersologest"].' - '.dol_trunc($accountingaccount->label, 32).'"'.$sep; + print '"'.csvClean(dol_trunc($accountingaccount->label, 32)).'"'.$sep; + print '"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $val["refsuppliersologest"], $accountingaccount->label)).'"'.$sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; print '"'.$journal.'"'; @@ -904,12 +910,12 @@ print '"'.$key.'"'.$sep; print '"'.$date.'"'.$sep; print '"'.$val["refsologest"].'"'.$sep; - print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 32), 'ISO-8859-1').'"'.$sep; + print '"'.csvClean(dol_trunc($companystatic->name, 32)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '""'.$sep; print '"'.$langs->trans("VAT").' - '.implode(', ', $def_tva[$key][$k]).' %"'.$sep; - print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 16), 'ISO-8859-1').' - '.$val["refsuppliersologest"].' - '.$langs->trans("VAT").implode(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '').'"'.$sep; + print '"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $val["refsuppliersologest"], $langs->trans("VAT").implode($def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : ''))).'"'.$sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; print '"'.$journal.'"'; @@ -924,12 +930,12 @@ print '"'.$key.'"'.$sep; print '"'.$date.'"'.$sep; print '"'.$val["refsologest"].'"'.$sep; - print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 32), 'ISO-8859-1').'"'.$sep; + print '"'.csvClean(dol_trunc($companystatic->name, 32)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '"'.$langs->trans("Thirdparty").'"'.$sep; - print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 16), 'ISO-8859-1').' - '.$val["refsuppliersologest"].' - '.$langs->trans("VAT").' NPR"'.$sep; + print '"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $val["refsuppliersologest"], $langs->trans("VAT").' NPR')).'"'.$sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; print '"'.$journal.'"'; @@ -1046,6 +1052,7 @@ function writebookkeeping() { $invoicestatic = new FactureFournisseur($db); $companystatic = new Fournisseur($db); + $bookkeepingstatic = new BookKeeping($db); foreach ($tabfac as $key => $val) { $companystatic->id = $tabcompany[$key]['id']; @@ -1140,7 +1147,7 @@ function writebookkeeping() { print $accountoshow; } print ''; - print "".$companystatic->getNomUrl(0, 'supplier', 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("SubledgerAccount").""; + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $langs->trans("SubledgerAccount")) . ""; print ''.($mt < 0 ? price(-$mt) : '').""; print ''.($mt >= 0 ? price($mt) : '').""; print ""; @@ -1183,7 +1190,7 @@ function writebookkeeping() { print ''; $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; - print "".$companystatic->getNomUrl(0, 'supplier', 16).' - '.$invoicestatic->ref_supplier.' - '.$accountingaccount->label.""; + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $accountingaccount->label) . ""; print ''.($mt >= 0 ? price($mt) : '').""; print ''.($mt < 0 ? price(-$mt) : '').""; print ""; @@ -1244,7 +1251,10 @@ function writebookkeeping() { print ""; print ''; print ""; - print $companystatic->getNomUrl(0, 'supplier', 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("VAT").' '.implode(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : ''); + $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ? '' : $arrayofvat[$key][$k]) : implode(', ', $def_tva[$key][$k])); + $labelvatrate = $langs->trans("Taxes").' '.$tmpvatrate.' %'; + $labelvatrate .= ($numtax ? ' - Localtax '.$numtax : ''); + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $labelvatrate) . ""; print ""; print ''.($mt >= 0 ? price($mt) : '').""; print ''.($mt < 0 ? price(-$mt) : '').""; @@ -1275,7 +1285,7 @@ function writebookkeeping() { // Subledger account print ""; print ''; - print "".$companystatic->getNomUrl(0, 'supplier', 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("VAT")." NPR (counterpart)"; + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $langs->trans("VAT")." NPR (counterpart)") . ""; print ''.($mt < 0 ? price(-$mt) : '').""; print ''.($mt >= 0 ? price($mt) : '').""; print ""; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 0929cc70717cc..6f175879c40ea 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -1,15 +1,15 @@ - * Copyright (C) 2007-2010 Jean Heimburger - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2012 Regis Houssin - * Copyright (C) 2013 Christophe Battarel - * Copyright (C) 2013-2024 Alexandre Spangaro - * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2013-2016 Olivier Geffroy - * Copyright (C) 2014 Raphaël Doursenaud - * Copyright (C) 2018-2021 Frédéric France - * Copyright (C) 2024 MDW +/* Copyright (C) 2007-2010 Laurent Destailleur + * Copyright (C) 2007-2010 Jean Heimburger + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2013 Christophe Battarel + * Copyright (C) 2013-2024 Alexandre Spangaro + * Copyright (C) 2013-2016 Florian Henry + * Copyright (C) 2013-2016 Olivier Geffroy + * Copyright (C) 2014 Raphaël Doursenaud + * Copyright (C) 2018-2021 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -236,7 +236,14 @@ if (array_key_exists($tax_id, $vatdata_cache)) { $vatdata = $vatdata_cache[$tax_id]; } else { - $vatdata = getTaxesFromId($tax_id, $mysoc, $mysoc, 0); + if (getDolGlobalString('SERVICE_ARE_ECOMMERCE_200238EC')) { + $buyer = new Societe($db); + $buyer->fetch($obj->socid); + } else { + $buyer = null; // We don't need the buyer in this case + } + $seller = $mysoc; + $vatdata = getTaxesFromId($tax_id, $buyer, $seller, 0); $vatdata_cache[$tax_id] = $vatdata; } $compta_tva = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); @@ -450,6 +457,7 @@ $companystatic = new Societe($db); $invoicestatic = new Facture($db); + $bookkeepingstatic = new BookKeeping($db); $accountingaccountcustomer = new AccountingAccount($db); $accountingaccountcustomer->fetch(0, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'), true); @@ -522,7 +530,7 @@ $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY'); $bookkeeping->label_compte = $accountingaccountcustomerwarranty->label; - $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("RetainedWarranty"); + $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans("RetainedWarranty")); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt >= 0) ? $mt : 0; @@ -572,7 +580,7 @@ $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'); $bookkeeping->label_compte = $accountingaccountcustomer->label; - $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$langs->trans("SubledgerAccount"); + $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans("SubledgerAccount")); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt >= 0) ? $mt : 0; @@ -650,7 +658,7 @@ $bookkeeping->numero_compte = $k; $bookkeeping->label_compte = $label_account; - $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$label_account; + $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $label_account); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt < 0) ? -$mt : 0; @@ -715,10 +723,10 @@ $bookkeeping->label_compte = $label_account; - $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref; $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ? '' : $arrayofvat[$key][$k]) : implode(', ', $def_tva[$key][$k])); - $bookkeeping->label_operation .= ' - '.$langs->trans("Taxes").' '.$tmpvatrate.' %'; - $bookkeeping->label_operation .= ($numtax ? ' - Localtax '.$numtax : ''); + $labelvataccount = $langs->trans("Taxes").' '.$tmpvatrate.' %'; + $labelvataccount .= ($numtax ? ' - Localtax '.$numtax : ''); + $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $labelvataccount); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; @@ -775,7 +783,7 @@ $bookkeeping->numero_compte = $k; $bookkeeping->label_compte = $label_account; - $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("RevenueStamp"); + $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans("RevenueStamp")); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt < 0) ? -$mt : 0; @@ -873,6 +881,7 @@ $companystatic = new Client($db); $invoicestatic = new Facture($db); + $bookkeepingstatic = new BookKeeping($db); foreach ($tabfac as $key => $val) { $companystatic->id = $tabcompany[$key]['id']; @@ -911,12 +920,12 @@ print '"'.$key.'"'.$sep; print '"'.$date.'"'.$sep; print '"'.$val["ref"].'"'.$sep; - print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 32), 'ISO-8859-1').'"'.$sep; + print '"'.csvClean(dol_trunc($companystatic->name, 32)).'"'.$sep; print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY')).'"'.$sep; print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; print '"'.$langs->trans("Thirdparty").'"'.$sep; - print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 16), 'ISO-8859-1').' - '.$invoicestatic->ref.' - '.$langs->trans("RetainedWarranty").'"'.$sep; + print '"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans("RetainedWarranty"))).'"'.$sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; print '"'.$journal.'"'; @@ -931,12 +940,12 @@ print '"'.$key.'"'.$sep; print '"'.$date.'"'.$sep; print '"'.$val["ref"].'"'.$sep; - print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 32), 'ISO-8859-1').'"'.$sep; + print '"'.csvClean(dol_trunc($companystatic->name, 32)).'"'.$sep; print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER')).'"'.$sep; print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; print '"'.$langs->trans("Thirdparty").'"'.$sep; - print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 16), 'ISO-8859-1').' - '.$invoicestatic->ref.' - '.$langs->trans("Thirdparty").'"'.$sep; + print '"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans("Thirdparty"))).'"'.$sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; print '"'.$journal.'"'; @@ -952,12 +961,12 @@ print '"'.$key.'"'.$sep; print '"'.$date.'"'.$sep; print '"'.$val["ref"].'"'.$sep; - print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 32), 'ISO-8859-1').'"'.$sep; + print '"'.csvClean(dol_trunc($companystatic->name, 32)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '""'.$sep; - print '"'.mb_convert_encoding(dol_trunc($accountingaccount->label, 32), 'ISO-8859-1').'"'.$sep; - print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 16), 'ISO-8859-1').' - '.dol_trunc($accountingaccount->label, 32).'"'.$sep; + print '"'.csvClean(dol_trunc($accountingaccount->label, 32)).'"'.$sep; + print '"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $accountingaccount->label)).'"'.$sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; print '"'.$journal.'"'; @@ -981,12 +990,12 @@ print '"'.$key.'"'.$sep; print '"'.$date.'"'.$sep; print '"'.$val["ref"].'"'.$sep; - print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 32), 'ISO-8859-1').'"'.$sep; + print '"'.csvClean(dol_trunc($companystatic->name, 32)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '""'.$sep; print '"'.$langs->trans("VAT").' - '.implode(', ', $def_tva[$key][$k]).' %"'.$sep; - print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 16), 'ISO-8859-1').' - '.$invoicestatic->ref.' - '.$langs->trans("VAT").implode(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '').'"'.$sep; + print '"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans("VAT").implode($def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : ''))).'"'.$sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; print '"'.$journal.'"'; @@ -1002,12 +1011,12 @@ print '"'.$key.'"'.$sep; print '"'.$date.'"'.$sep; print '"'.$val["ref"].'"'.$sep; - print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 32), 'ISO-8859-1').'"'.$sep; + print '"'.csvClean(dol_trunc($companystatic->name, 32)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '""'.$sep; print '"'.$langs->trans("RevenueStamp").'"'.$sep; - print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 16), 'ISO-8859-1').' - '.$invoicestatic->ref.' - '.$langs->trans("RevenueStamp").'"'.$sep; + print '"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans("RevenueStamp"))).'"'.$sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; print '"'.$journal.'"'; @@ -1125,6 +1134,7 @@ function writebookkeeping() { $companystatic = new Client($db); $invoicestatic = new Facture($db); + $bookkeepingstatic = new BookKeeping($db); foreach ($tabfac as $key => $val) { $companystatic->id = $tabcompany[$key]['id']; @@ -1219,7 +1229,7 @@ function writebookkeeping() { print $accountoshow; } print ''; - print "" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("RetainedWarranty") . ""; + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0), $invoicestatic->ref, $langs->trans("RetainedWarranty")) . ""; print '' . ($mt >= 0 ? price($mt) : '') . ""; print '' . ($mt < 0 ? price(-$mt) : '') . ""; print ""; @@ -1250,7 +1260,7 @@ function writebookkeeping() { print $accountoshow; } print ''; - print "".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref.' - '.$langs->trans("SubledgerAccount").""; + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $langs->trans("SubledgerAccount")) . ""; print ''.($mt >= 0 ? price($mt) : '').""; print ''.($mt < 0 ? price(-$mt) : '').""; print ""; @@ -1293,7 +1303,7 @@ function writebookkeeping() { print ''; $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; - print "".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref.' - '.$accountingaccount->label.""; + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $accountingaccount->label) . ""; print ''.($mt < 0 ? price(-$mt) : '').""; print ''.($mt >= 0 ? price($mt) : '').""; print ""; @@ -1331,13 +1341,12 @@ function writebookkeeping() { // Subledger account print ""; print ''; - print "".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref; // $def_tva is array[invoiceid][accountancy_code_sell_of_vat_rate_found][vatrate]=vatrate //var_dump($arrayofvat[$key]); //var_dump($key); //var_dump($k); $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ? '' : $arrayofvat[$key][$k]) : implode(', ', $def_tva[$key][$k])); - print ' - '.$langs->trans("Taxes").' '.$tmpvatrate.' %'; - print($numtax ? ' - Localtax '.$numtax : ''); - print ""; + $labelvatrate = $langs->trans("Taxes").' '.$tmpvatrate.' %'; + $labelvatrate .= ($numtax ? ' - Localtax '.$numtax : ''); + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $labelvatrate) . ""; print ''.($mt < 0 ? price(-$mt) : '').""; print ''.($mt >= 0 ? price($mt) : '').""; print ""; @@ -1366,7 +1375,7 @@ function writebookkeeping() { // Subledger account print ""; print ''; - print "" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("RevenueStamp") . ""; + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $langs->trans("RevenueStamp")) . ""; print '' . ($mt < 0 ? price(-$mt) : '') . ""; print '' . ($mt >= 0 ? price($mt) : '') . ""; print ""; diff --git a/htdocs/accountancy/journal/variousjournal.php b/htdocs/accountancy/journal/variousjournal.php index 60050fa52b42d..3ae29327ff016 100644 --- a/htdocs/accountancy/journal/variousjournal.php +++ b/htdocs/accountancy/journal/variousjournal.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2021-2024 Alexandre Spangaro * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index dfe7441a3d2a3..cf20feec80427 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -76,8 +76,8 @@ $res = dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MEMBER_MIN_AMOUNT", $minamount, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MEMBER_COUNTERS_ARE_PUBLIC", $publiccounters, 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "MEMBER_SKIP_TABLE", !$showtable, 'chaine', 0, '', $conf->entity); // Logic is reversed for retrocompatibility: "skip -> show" - $res = dolibarr_set_const($db, "MEMBER_HIDE_VOTE_ALLOWED", !$showvoteallowed, 'chaine', 0, '', $conf->entity); // Logic is reversed for retrocompatibility: "hide -> show" + $res = dolibarr_set_const($db, "MEMBER_SKIP_TABLE", $showtable ? 0 : 1, 'chaine', 0, '', $conf->entity); // Logic is reversed for retrocompatibility: "skip -> show" + $res = dolibarr_set_const($db, "MEMBER_HIDE_VOTE_ALLOWED", $showvoteallowed ? 0 : 1, 'chaine', 0, '', $conf->entity); // Logic is reversed for retrocompatibility: "hide -> show" $res = dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity); if ($forcetype < 0) { $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCETYPE", $conf->entity); diff --git a/htdocs/adherents/agenda.php b/htdocs/adherents/agenda.php index bd40ed7166e7a..cc81b058d87e7 100644 --- a/htdocs/adherents/agenda.php +++ b/htdocs/adherents/agenda.php @@ -192,7 +192,16 @@ $param .= '&limit='.$limit; } - print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $newcardbutton, '', 0, 1, 0); + require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; + $cachekey = 'count_events_member_'.$object->id; + $nbEvent = dol_getcache($cachekey); + + $titlelist = $langs->trans("ActionsOnMember").(is_numeric($nbEvent) ? '('.$nbEvent.')' : ''); + if (!empty($conf->dol_optimize_smallscreen)) { + $titlelist = $langs->trans("Actions").(is_numeric($nbEvent) ? '('.$nbEvent.')' : ''); + } + + print_barre_liste($titlelist, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $newcardbutton, '', 0, 1, 0); // List of all actions $filters = array(); diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php index fe33407cf21f3..93201fcf2fc5c 100644 --- a/htdocs/adherents/cartes/carte.php +++ b/htdocs/adherents/cartes/carte.php @@ -3,6 +3,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2006-2013 Laurent Destailleur * Copyright (C) 2024 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 @@ -311,7 +312,7 @@ } asort($arrayoflabels); print $form->selectarray('model', $arrayoflabels, (GETPOST('model') ? GETPOST('model') : getDolGlobalString('ADHERENT_CARD_TYPE')), 1, 0, 0, '', 0, 0, 0, '', '', 1); -print '
'.$langs->trans("Login").': '; +print '
'.$langs->trans("Login").': '; print '
'; print ''; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index be94b51069b28..8e5ed262fe419 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -176,7 +176,7 @@ class Adherent extends CommonObject public $morphy; /** - * @var int Info can be public + * @var int<0,1> Info can be public */ public $public; @@ -3288,12 +3288,9 @@ public function getKanbanView($option = '', $arraydata = null) if ($selected >= 0) { $return .= ''; } - if (property_exists($this, 'type')) { - $return .= '
'.$this->type.''; - } - if (method_exists($this, 'getmorphylib')) { - $return .= '
'.$this->getmorphylib('', 2).''; - } + $return .= '
'.$this->getmorphylib('', 2).''; + $return .= ''.$this->type.''; + if (method_exists($this, 'getLibStatut')) { $return .= '
'; $return .= $this->LibStatut($this->status, $this->need_subscription, $this->datefin, 5); diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 920f5f8838e58..2947f20b15895 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -107,7 +107,9 @@ class AdherentType extends CommonObject /** @var string Public note */ public $note_public; - /** @var integer Can vote */ + /** + * @var int<0,1> Can vote + */ public $vote; /** @var string Email sent during validation of member */ @@ -141,6 +143,28 @@ class AdherentType extends CommonObject public $multilangs = array(); + // BEGIN MODULEBUILDER PROPERTIES + /** + * @inheritdoc + * Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields = array( + "rowid" => array("type" => "integer", "label" => "TechnicalID", "enabled" => "1", 'position' => 10, 'notnull' => 1, "visible" => "-1",), + "tms" => array("type" => "timestamp", "label" => "DateModification", "enabled" => "1", 'position' => 20, 'notnull' => 1, "visible" => "-1",), + "statut" => array("type" => "smallint(6)", "label" => "Statut", "enabled" => "1", 'position' => 500, 'notnull' => 1, "visible" => "-1",), + "libelle" => array("type" => "varchar(50)", "label" => "Label", "enabled" => "1", 'position' => 30, 'notnull' => 1, "visible" => "-1",), + "subscription" => array("type" => "varchar(3)", "label" => "Subscription", "enabled" => "1", 'position' => 35, 'notnull' => 1, "visible" => "-1",), + "amount" => array("type" => "double(24,8)", "label" => "Amount", "enabled" => "1", 'position' => 40, 'notnull' => 0, "visible" => "-1",), + "caneditamount" => array("type" => "integer", "label" => "Caneditamount", "enabled" => "1", 'position' => 45, 'notnull' => 0, "visible" => "-1",), + "vote" => array("type" => "varchar(3)", "label" => "Vote", "enabled" => "1", 'position' => 50, 'notnull' => 1, "visible" => "-1",), + "note" => array("type" => "longtext", "label" => "Note", "enabled" => "1", 'position' => 55, 'notnull' => 0, "visible" => "-1",), + "mail_valid" => array("type" => "longtext", "label" => "Mailvalid", "enabled" => "1", 'position' => 60, 'notnull' => 0, "visible" => "-1",), + "morphy" => array("type" => "varchar(3)", "label" => "Morphy", "enabled" => "1", 'position' => 65, 'notnull' => 0, "visible" => "-1",), + "duration" => array("type" => "varchar(6)", "label" => "Duration", "enabled" => "1", 'position' => 70, 'notnull' => 0, "visible" => "-1",), + ); + // END MODULEBUILDER PROPERTIES + + /** * Constructor * diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 6f09b14c9334e..e67d3e3e0b216 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -120,6 +120,55 @@ public function getByThirdparty($thirdparty) return $this->_cleanObjectDatas($member); } + /** + * Get properties of a member object by linked thirdparty account + * + * @param string $site Site key + * @param string $key_account Key of account + * + * @return array|mixed + * @throws RestException 401 Unauthorized: User does not have permission to read thirdparties + * @throws RestException 404 Not Found: Specified thirdparty ID does not belongs to an existing thirdparty + * + * @url GET thirdparty/accounts/{site}/{key_account} + */ + public function getByThirdpartyAccounts($site, $key_account) + { + if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) { + throw new RestException(403); + } + + $sql = "SELECT rowid, fk_soc, key_account, site, date_creation, tms FROM ".MAIN_DB_PREFIX."societe_account"; + $sql .= " WHERE site = '".$this->db->escape($site)."' AND key_account = '".$this->db->escape($key_account)."'"; + $sql .= " AND entity IN (".getEntity('adherent').")"; + + $result = $this->db->query($sql); + + if ($result && $this->db->num_rows($result) == 1) { + $obj = $this->db->fetch_object($result); + $thirdparty = new Societe($this->db); + $result = $thirdparty->fetch($obj->fk_soc); + + if ($result <= 0) { + throw new RestException(404, 'thirdparty not found'); + } + + $member = new Adherent($this->db); + $result = $member->fetch(0, '', $thirdparty->id); + if (!$result) { + throw new RestException(404, 'member not found'); + } + } else { + throw new RestException(404, 'This account have many thirdparties attached or does not exist.'); + } + + if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) { + throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + return $this->_cleanObjectDatas($member); + } + /** * Get properties of a member object by linked thirdparty email * diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 611363ec3a11f..753a178c7fc7f 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -54,6 +54,7 @@ $backtopage = GETPOST('backtopage', 'alpha'); $optioncss = GETPOST('optioncss', 'aZ'); $mode = GETPOST('mode', 'alpha'); +$groupby = GETPOST('groupby', 'aZ09'); // Example: $groupby = 'p.fk_opp_status' or $groupby = 'p.fk_statut' // Search fields $search = GETPOST("search", 'alpha'); @@ -107,14 +108,15 @@ $search_status = ''; } -// Pagination parameters +// Load variable for pagination $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); -$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); -if (empty($page) || $page == -1) { +$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; -} // If $page is not defined, or '' or -1 +} $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -131,7 +133,7 @@ $hookmanager->initHooks(array('memberlist')); $extrafields = new ExtraFields($db); -// fetch optionals attributes and labels +// Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); @@ -184,20 +186,10 @@ 'd.import_key' => array('label' => "ImportId"), ); -// Extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; - -$object->fields = dol_sort_array($object->fields, 'position'); -//$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right'); - // Complete array of fields for columns $tableprefix = 'd'; foreach ($object->fields as $key => $val) { - if (!array_key_exists($tableprefix.'.'.$key, $arrayfields)) { // Discard record not into $arrayfields - continue; - } // If $val['visible']==0, then we never show the field - if (!empty($val['visible'])) { $visible = (int) dol_eval((string) $val['visible'], 1); $arrayfields[$tableprefix.'.'.$key] = array( @@ -209,6 +201,13 @@ ); } } + +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; + +$object->fields = dol_sort_array($object->fields, 'position'); +//$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right'); + $arrayfields = dol_sort_array($arrayfields, 'position'); '@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan @@ -410,11 +409,7 @@ // Build and execute select // -------------------------------------------------------------------- -if (!empty($search_categ) && $search_categ > 0) { - $sql = "SELECT DISTINCT"; -} else { - $sql = "SELECT"; -} +$sql = "SELECT"; $sql .= " d.rowid, d.ref, d.login, d.lastname, d.firstname, d.gender, d.societe as company, d.fk_soc,"; $sql .= " d.civility, d.datefin, d.address, d.zip, d.town, d.state_id, d.country,"; $sql .= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.birth, d.public, d.photo,"; @@ -428,7 +423,7 @@ // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ""); } } @@ -441,7 +436,7 @@ $sqlfields = $sql; // $sql fields to remove for count total // SQL Alias adherent -$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; // maybe better to use ad (adh) instead of d +$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; if (!empty($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (d.rowid = ef.fk_object)"; } @@ -623,7 +618,7 @@ // Direct jump if only one record found -if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) { +if ($num == 1 && getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) { $obj = $db->fetch_object($resql); $id = $obj->rowid; header("Location: ".DOL_URL_ROOT.'/adherents/card.php?id='.$id); @@ -658,6 +653,9 @@ if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } +if ($groupby != '') { + $param .= '&groupby='.urlencode($groupby); +} if ($search_all != "") { $param .= "&search_all=".urlencode($search_all); } @@ -777,13 +775,12 @@ $newcardbutton = ''; $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition')); $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition')); -if ($user->hasRight('adherent', 'creer')) { - $newcardbutton .= dolGetButtonTitleSeparator(); - $newcardbutton .= dolGetButtonTitle($langs->trans('NewMember'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create'); -} +$newcardbutton .= dolGetButtonTitleSeparator(); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewMember'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create', '', $user->hasRight('adherent', 'creer')); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); +// Add code for pre mass action (confirmation or email presend form) $topicmail = "Information"; $modelmail = "member"; $objecttmp = new Adherent($db); @@ -853,9 +850,6 @@ if (!empty($moreforfilter)) { print '
'; print $moreforfilter; - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; print '
'; } @@ -1091,6 +1085,7 @@ $totalarray['nbfield']++; } if (!empty($arrayfields['d.rowid']['checked'])) { + // @phan-suppress-next-line PhanTypeInvalidDimOffset print_liste_field_titre($arrayfields['d.rowid']['label'], $_SERVER["PHP_SELF"], 'd.rowid', '', $param, '', $sortfield, $sortorder, 'center '); $totalarray['nbfield']++; } diff --git a/htdocs/adherents/messaging.php b/htdocs/adherents/messaging.php index 2ea8397391919..e5aaa491bb204 100644 --- a/htdocs/adherents/messaging.php +++ b/htdocs/adherents/messaging.php @@ -193,7 +193,7 @@ // Try to know count of actioncomm from cache require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; - $cachekey = 'count_events_user_'.$object->id; + $cachekey = 'count_events_member_'.$object->id; $nbEvent = dol_getcache($cachekey); // TODO Add nb into badge in menu so we can get it from cache also here $titlelist = $langs->trans("ActionsOnMember").(is_numeric($nbEvent) ? '('.$nbEvent.')' : ''); diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 3d69be5edf31a..04dc1afccb60a 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -411,9 +411,6 @@ if (!empty($moreforfilter)) { print '
'; print $moreforfilter; - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; print '
'; } diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 478402f301854..1f2916e0957b3 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -100,6 +100,25 @@ // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); + +// Definition of array of fields for columns +$tableprefix = 't'; +$arrayfields = array(); +foreach ($object->fields as $key => $val) { + // If $val['visible']==0, then we never show the field + if (!empty($val['visible'])) { + $visible = (int) dol_eval((string) $val['visible'], 1); + $arrayfields[$tableprefix.'.'.$key] = array( + 'label' => $val['label'], + 'checked' => (($visible < 0) ? 0 : 1), + 'enabled' => (abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)), + 'position' => $val['position'], + 'help' => isset($val['help']) ? $val['help'] : '' + ); + } +} + + // Security check $result = restrictedArea($user, 'adherent', $rowid, 'adherent_type'); @@ -420,16 +439,18 @@ $i++; } + // Show total line + include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + // If no record found if ($num == 0) { - /*$colspan = 1; + $colspan = 1; foreach ($arrayfields as $key => $val) { - if (!empty($val['checked'])) { + //if (!empty($val['checked'])) { $colspan++; - } - }*/ - $colspan = 9; - print ''.$langs->trans("NoRecordFound").''; + //} + } + print ''.$langs->trans("NoRecordFound").''; } print ""; diff --git a/htdocs/admin/accountant.php b/htdocs/admin/accountant.php index 61e3d483237bd..f514625989b96 100644 --- a/htdocs/admin/accountant.php +++ b/htdocs/admin/accountant.php @@ -106,6 +106,7 @@ print "\n".''; + +// Methods oauth +print ''.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").''; +print ''; +print ''; +print ''; +if (!isModEnabled('oauth')) { + print '   '.$langs->trans("EnableModuleX", "OAuth").''; +} else { + print '   '.$langs->trans("SetupModuleX", " OAuth").''; +} +print ''; +print ''; + +print ''; +print ''.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE").''; +print ''; + +$oauthservicesStringKeys = []; +foreach ($oauthservices as $key => $value) { + $key = (string) $key; + $oauthservicesStringKeys[$key] = $value; +} + +/** @phan-var-force array $oauthservices */ +if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) { + print $form->selectarray('OAUTH_SERVICE_SOCIAL_NETWORK', $oauthservicesStringKeys, (string) $conf->global->OAUTH_SERVICE_SOCIAL_NETWORK); +} else { + $selectedKey = (string) getDolGlobalString('OAUTH_SERVICE_SOCIAL_NETWORK'); + $text = isset($oauthservicesStringKeys[$selectedKey]) ? $oauthservicesStringKeys[$selectedKey]['label'] : ''; + if (empty($text)) { + $text = $langs->trans("Undefined"); + } + $htmltext = $langs->trans("ContactSuperAdminForChange"); + print $form->textwithpicto($text, $htmltext, 1, 'superadmin'); + print ''; +} +print ''; +print ''; -print ''; +print ''; print $form->textwithpicto($langs->trans("Others"), $langs->trans("AddMoreParams")); print ''; print 'Token : ****
Cookie : ****'; @@ -294,14 +373,38 @@ print $form->buttonsSaveCancel("Add", ''); print ''; print ''; print ''; @@ -381,7 +484,7 @@ print ''."\n"; print ''; - print ""; + print ""; print ''; print ''; - // show input border - /* - print ''; - print ''; - */ - // First day for weeks print ''; print ''; // DefaultWorkingDays print ''; print ''; // DefaultWorkingHours print ''; print ''; // Firstname/Name print ''; print ''; @@ -523,7 +515,7 @@ print ''; print ''; @@ -561,17 +553,10 @@ print '' . "\n"; - - /* no more need for this option. It is now a widget already controlled by end user - print ''; - print ''; - */ + print ''."\n"; print '
".$langs->trans("SocialNetworks")." ".($i+1)."".$langs->trans("SocialNetworks")." ".($i + 1)."'; print ''.img_edit().''; print ''.img_delete().''; @@ -479,8 +582,8 @@ /** * Check if the given fediverse feed if inside the list of boxes/widgets * - * @param int $id The id of the socialnetwork - * @param array $boxlist A list with boxes/widgets (array of stdClass objects). + * @param int $id The id of the socialnetwork + * @param ModeleBoxes[] $boxlist A list with boxes/widgets * @return bool True if the socialnetwork is inside the box/widget list, otherwise false */ function _isInBoxListFediverse(int $id, array $boxlist) diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index cb4baa5517035..38b0d37fb6ce6 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -338,9 +338,9 @@ 0, 0, array( - '/includes/ace/src/ace.js', - '/includes/ace/src/ext-statusbar.js', - '/includes/ace/src/ext-language_tools.js', + '/includes/ace/src/ace.js', + '/includes/ace/src/ext-statusbar.js', + '/includes/ace/src/ext-language_tools.js', ), array(), '', @@ -456,36 +456,28 @@ print '
'.$langs->trans("showInputBorder").''; - print $form->selectyesno('main_showInputBorder',isset($conf->global->THEME_ELDY_SHOW_BORDER_INPUT)?$conf->global->THEME_ELDY_SHOW_BORDER_INPUT:0,1); - print '
' . $langs->trans("WeekStartOnDay") . ''; - print $formother->select_dayofweek((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : '1'), 'MAIN_START_WEEK', 0); + print $formother->select_dayofweek(getDolGlobalString('MAIN_START_WEEK', '1'), 'MAIN_START_WEEK', 0); print '
' . $langs->trans("DefaultWorkingDays") . ''; - print ''; + print ''; print '
' . $langs->trans("DefaultWorkingHours") . ''; - print ''; + print ''; print '
' . $langs->trans("FirstnameNamePosition") . ''; $array = array(0 => $langs->trans("Firstname") . ' ' . $langs->trans("Lastname"), 1 => $langs->trans("Lastname") . ' ' . $langs->trans("Firstname")); - print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION', $array, (isset($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? $conf->global->MAIN_FIRSTNAME_NAME_POSITION : 0)); + print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION', $array, getDolGlobalInt('MAIN_FIRSTNAME_NAME_POSITION', 0)); print '
'; print $form->textwithpicto($langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")), $langs->trans("ShowBugTrackLinkDesc")); print ''; - print ''; + print ''; print '
'; - $doleditor = new DolEditor('main_motd', (isset($conf->global->MAIN_MOTD) ? $conf->global->MAIN_MOTD : ''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%'); + $doleditor = new DolEditor('main_motd', getDolGlobalString('MAIN_MOTD'), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%'); $doleditor->Create(); - print '
' . $langs->trans('BoxstatsDisableGlobal') . ''; - print ajax_constantonoff("MAIN_DISABLE_GLOBAL_BOXSTATS", array(), $conf->entity, 0, 0, 1, 0); - print '
'; print '
'; diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index dfe885496cfd8..f3c2872b1810a 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -1092,12 +1092,12 @@ function change_smtp_auth_method() { if (($dnstype == 'SPF' && stripos($info['txt'], 'v=spf') !== false) || ($dnstype == 'DMARC' && stripos($info['txt'], 'v=dmarc') !== false)) { $foundforemail++; - $text .= ($text ? '
' : '').$langs->trans("ActualMailDNSRecordFound", $dnstype, implode(', ', $listofemails), $info['txt']); + $text .= ($text ? '
' : '').'- '.$langs->trans("ActualMailDNSRecordFound", ''.$dnstype.'', ''.implode(', ', $listofemails).'', ''.$info['txt'].''); } } } if (!$foundforemail) { - $text .= ($text ? '
' : '').$langs->trans("ActualMailDNSRecordFound", $dnstype, implode(', ', $listofemails), ''.$langs->transnoentitiesnoconv("None").''); + $text .= ($text ? '
' : '').'- '.$langs->trans("ActualMailDNSRecordFound", ''.$dnstype.'', ''.implode(', ', $listofemails).'', ''.$langs->transnoentitiesnoconv("None").''); } } } diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index 053c87ad69c86..5532b8e4e5030 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -531,9 +531,6 @@ if (!empty($moreforfilter)) { print '
'; print $moreforfilter; - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; print '
'; } diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index 11822eb47a27c..c2d6d2a7d7957 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -350,8 +350,6 @@ $text .= '
'.$langs->trans("IdModule").': '.$objMod->numero; - $text .= '
'.$langs->trans("Version").': '.$version; - $textexternal = ''; if ($objMod->isCoreOrExternalModule() == 'external') { $tmpdirofmoduletoshow = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', (string) $dirofmodule); @@ -381,8 +379,10 @@ } elseif (!empty($objMod->enabled_bydefault)) { $text .= '   ('.$langs->trans("EnabledByDefaultAtInstall").')'; } - $text .= '
'; } + + $text .= '
'.$langs->trans("Version").': '.$version; + $text .= '
'; $moduledesclong = $objMod->getDescLong(); diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 7e5e28adec1b0..9c93d7972868e 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -165,7 +165,7 @@ if ($action == 'install' && $allowonlineinstall) { $error = 0; - + $modulenameval = ''; // $original_file should match format module_modulename-x.y[.z].zip $original_file = basename($_FILES["fileinstall"]["name"]); $original_file = preg_replace('/\s*\(\d+\)\.zip$/i', '.zip', $original_file); @@ -282,8 +282,20 @@ } if (!$error) { - $message = $langs->trans("SetupIsReadyForUse", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->transnoentitiesnoconv("Home").' - '.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Modules")); + $searchParams = array( + 'search_keyword' => $modulenameval, + 'search_status' => '-1', + 'search_nature' => '-1', + 'search_version' => '-1' + ); + $queryString = http_build_query($searchParams); + $redirectUrl = DOL_URL_ROOT . '/admin/modules.php?' . $queryString; + + $message = $langs->trans("SetupIsReadyForUse", $redirectUrl, $langs->transnoentitiesnoconv("Home").' - '.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Modules")); + setEventMessages($message, null, 'warnings'); + header('Location: ' . $redirectUrl); + exit; } } elseif ($action == 'install' && !$allowonlineinstall) { httponly_accessforbidden("You try to bypass the protection to disallow deployment of an external module. Hack attempt ?"); @@ -690,7 +702,7 @@ if (!empty($moreforfilter)) { print $moreforfilter; $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; } @@ -905,7 +917,7 @@ if (method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) { $codeenabledisable .= $langs->trans("Used"); } else { - $codeenabledisable .= img_picto($langs->trans("Required"), 'switch_on', '', false, 0, 0, '', 'opacitymedium valignmiddle'); + $codeenabledisable .= img_picto($langs->trans("Required"), 'switch_on', '', 0, 0, 0, '', 'opacitymedium valignmiddle'); //print $langs->trans("Required"); } if (isModEnabled('multicompany') && $user->entity) { @@ -964,20 +976,20 @@ } else { if (preg_match('/^([^@]+)@([^@]+)$/i', $urlpage, $regs)) { $urltouse = dol_buildpath('/'.$regs[2].'/admin/'.$regs[1], 1); - $codetoconfig .= ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15').''; + $codetoconfig .= ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', 0, 0, 0, '', 'fa-15').''; } else { $urltouse = $urlpage; - $codetoconfig .= ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15').''; + $codetoconfig .= ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', 0, 0, 0, '', 'fa-15').''; } } } } elseif (preg_match('/^([^@]+)@([^@]+)$/i', (string) $objMod->config_page_url, $regs)) { - $codetoconfig .= ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15').''; + $codetoconfig .= ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', 0, 0, 0, '', 'fa-15').''; } else { - $codetoconfig .= ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15').''; + $codetoconfig .= ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', 0, 0, 0, '', 'fa-15').''; } } else { - $codetoconfig .= img_picto($langs->trans("NothingToSetup"), "setup", 'class="opacitytransp" style="padding-right: 6px"', false, 0, 0, '', 'fa-15'); + $codetoconfig .= img_picto($langs->trans("NothingToSetup"), "setup", 'class="opacitytransp" style="padding-right: 6px"', 0, 0, 0, '', 'fa-15'); } } else { // Module not yet activated // Set $codeenabledisable @@ -1101,7 +1113,7 @@ if ($action == 'checklastversion') { if ($foundoneexternalmodulewithupdate) { - setEventMessages($langs->trans("ModuleUpdateAvailable"), null, 'warnings'); + setEventMessages($langs->trans("ModuleUpdateAvailable"), null, 'warnings', '', 0, 1); } else { setEventMessages($langs->trans("NoExternalModuleWithUpdate"), null, 'mesgs'); } diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php index 7c8de60082e89..7f78caa2b3e64 100644 --- a/htdocs/admin/oauth.php +++ b/htdocs/admin/oauth.php @@ -178,9 +178,9 @@ $callbacktodel .= '/core/modules/oauth/google_oauthcallback.php?action=delete&keyforprovider='.$provider.'&token='.newToken().'&backtourl='.urlencode($backtourl); } elseif ($label == 'OAUTH_GITHUB') { $callbacktodel .= '/core/modules/oauth/github_oauthcallback.php?action=delete&keyforprovider='.$provider.'&token='.newToken().'&backtourl='.urlencode($backtourl); - } elseif ($label == 'OAUTH_STRIPE_LIVE') { + } elseif ($label == 'OAUTH_STRIPELIVE') { $callbacktodel .= '/core/modules/oauth/stripelive_oauthcallback.php?action=delete&keyforprovider='.$provider.'&token='.newToken().'&backtourl='.urlencode($backtourl); - } elseif ($label == 'OAUTH_STRIPE_TEST') { + } elseif ($label == 'OAUTH_STRIPETEST') { $callbacktodel .= '/core/modules/oauth/stripetest_oauthcallback.php?action=delete&keyforprovider='.$provider.'&token='.newToken().'&backtourl='.urlencode($backtourl); } elseif ($label == 'OAUTH_MICROSOFT') { $callbacktodel .= '/core/modules/oauth/microsoft_oauthcallback.php?action=delete&keyforprovider='.$provider.'&token='.newToken().'&backtourl='.urlencode($backtourl); @@ -249,9 +249,11 @@ print ''.$langs->trans("ListOfSupportedOauthProviders").'

'; +$list = getAllOauth2Array(); + + print ''; print ''; +// Frame corner radius +print ''; +print $form->textwithpicto($langs->trans("PDFBoxFrameRoundedCorners"), $langs->trans("MAIN_PDF_FRAME_CORNER_RADIUS")); +print ''; +$arrval = array('0', '1', '2', '3'); +print $form->selectarray("MAIN_PDF_FRAME_CORNER_RADIUS", $arrval, getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0)); +print ''; + // Show project if (isModEnabled('project')) { print ''.$langs->trans("PDF_SHOW_PROJECT").''; @@ -525,8 +537,7 @@ print ''; } -// - +// Hide customer code print ''.$langs->trans("MAIN_PDF_HIDE_CUSTOMER_CODE"); print ''; if ($conf->use_javascript_ajax) { @@ -537,7 +548,7 @@ } print ''; -// Ref +// Hide Ref print ''.$langs->trans("HideRefOnPDF").''; if ($conf->use_javascript_ajax) { @@ -638,7 +649,11 @@ print ''; print ''.$langs->trans("PDF_USE_A").''; -print $form->selectarray('PDF_USE_A', $arraylistofpdfformat, getDolGlobalString('PDF_USE_A', '0')); + +//$pdfa = false; // PDF default version +$pdfa = getDolGlobalInt('PDF_USE_A', 0); // PDF/A-1 ou PDF/A-3 + +print $form->selectarray('PDF_USE_A', $arraylistofpdfformat, $pdfa); print ''; print ''; diff --git a/htdocs/admin/pdf_other.php b/htdocs/admin/pdf_other.php index 8862a524b6114..5f58e063ead29 100644 --- a/htdocs/admin/pdf_other.php +++ b/htdocs/admin/pdf_other.php @@ -7,6 +7,7 @@ * Copyright (C) 2021-2022 Anthony Berton * Copyright (C) 2022 Alexandre Spangaro * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 Nick Fragoulis * * 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 @@ -63,6 +64,10 @@ if (GETPOSTISSET('MAIN_GENERATE_PROPOSALS_WITH_PICTURE')) { dolibarr_set_const($db, "MAIN_GENERATE_PROPOSALS_WITH_PICTURE", GETPOST("MAIN_GENERATE_PROPOSALS_WITH_PICTURE"), 'chaine', 0, '', $conf->entity); } + if (GETPOSTISSET('SALES_ORDER_SHOW_SHIPPING_ADDRESS')) { + dolibarr_set_const($db, "SALES_ORDER_SHOW_SHIPPING_ADDRESS", GETPOSTINT("SALES_ORDER_SHOW_SHIPPING_ADDRESS"), 'chaine', 0, '', $conf->entity); + dolibarr_del_const($db, "SALES_ORDER_SHOW_SHIPPING_ADDRESS", $conf->entity); + } if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_SUPPLIER_PROPOSAL_WITHOUT_UNIT_PRICE')) { dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_SUPPLIER_PROPOSAL_WITHOUT_UNIT_PRICE", GETPOST("MAIN_GENERATE_DOCUMENTS_SUPPLIER_PROPOSAL_WITHOUT_UNIT_PRICE"), 'chaine', 0, '', $conf->entity); } @@ -183,6 +188,30 @@ } +if (isModEnabled('order')) { + $langs->load("orders"); + print load_fiche_titre($langs->trans('CustomersOrders'), '', 'order'); + + print '
'; + print ''; + print ''; + + print ''; + + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + print $form->textwithpicto($langs->trans("SALES_ORDER_SHOW_SHIPPING_ADDRESS"), $langs->trans("SALES_ORDER_SHOW_SHIPPING_ADDRESSMore")); + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('SALES_ORDER_SHOW_SHIPPING_ADDRESS'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("SALES_ORDER_SHOW_SHIPPING_ADDRESS", $arrval, $conf->global->SALES_ORDER_SHOW_SHIPPING_ADDRESS); + } + print '
'; + print '
'; +} + + if (isModEnabled('supplier_proposal')) { $langs->load("supplier_proposal"); print load_fiche_titre($langs->trans("SupplierProposal"), '', 'supplier_proposal'); diff --git a/htdocs/admin/proxy.php b/htdocs/admin/proxy.php index 90e4040027091..0fafb4e060b5c 100644 --- a/htdocs/admin/proxy.php +++ b/htdocs/admin/proxy.php @@ -127,7 +127,7 @@ function initfields() print ''; print ''.$langs->trans("Parameters").''; -print ''.$langs->trans("Value").''; +print ''; print "\n"; diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 182374fd3ae31..6ea47093c4ed4 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -192,7 +192,7 @@ print ''; print ''; -// Charge tableau des modules generation +// Load array with all password generation modules $dir = "../core/modules/security/generate"; clearstatcache(); $handle = opendir($dir); @@ -200,6 +200,7 @@ $arrayhandler = array(); if (is_resource($handle)) { while (($file = readdir($handle)) !== false) { + $reg = array(); if (preg_match('/(modGeneratePass[a-z]+)\.class\.php$/i', $file, $reg)) { // Charging the numbering class $classname = $reg[1]; diff --git a/htdocs/admin/security_captcha.php b/htdocs/admin/security_captcha.php new file mode 100644 index 0000000000000..84b3faf29f248 --- /dev/null +++ b/htdocs/admin/security_captcha.php @@ -0,0 +1,213 @@ + + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2013 Juanjo Menent + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/admin/security_captcha.php + * \ingroup core + * \brief Security captcha options setup + */ + +// Load Dolibarr environment +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array("users", "admin", "other")); + +if (!$user->admin) { + accessforbidden(); +} + +$action = GETPOST('action', 'aZ09'); + + + +/* + * Actions + */ + +if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { + $code = $reg[1]; + $value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1); + if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } +} elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { + $code = $reg[1]; + if (dolibarr_del_const($db, $code, $conf->entity) > 0) { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } +} elseif ($action == 'updateform') { + $res1 = 1; + $res2 = 1; + $res3 = 1; + $res4 = 1; + $res5 = 1; + if (GETPOSTISSET('MAIN_APPLICATION_TITLE')) { + $res1 = dolibarr_set_const($db, "MAIN_APPLICATION_TITLE", GETPOST("MAIN_APPLICATION_TITLE", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('MAIN_SESSION_TIMEOUT')) { + $res2 = dolibarr_set_const($db, "MAIN_SESSION_TIMEOUT", GETPOST("MAIN_SESSION_TIMEOUT", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT')) { + $res3 = dolibarr_set_const($db, "MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", GETPOST("MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", 'alphanohtml'), 'int', 0, '', $conf->entity); + } + if (GETPOSTISSET('MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS')) { + $res4 = dolibarr_set_const($db, "MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", GETPOST("MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 'alphanohtml'), 'int', 0, '', $conf->entity); + } + if (GETPOSTISSET('MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS')) { + $res5 = dolibarr_set_const($db, "MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS", GETPOST("MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS", 'alphanohtml'), 'int', 0, '', $conf->entity); + } + if ($res1 && $res2 && $res3 && $res4 && $res5) { + setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); + } +} + + + +/* + * View + */ + +$form = new Form($db); + +$wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad'; +llxHeader('', $langs->trans("Miscellaneous"), $wikihelp, '', 0, 0, '', '', '', 'mod-admin page-security_other'); + +print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup'); + +print ''.$langs->trans("CaptchaDesc")."
\n"; +print "
\n"; + + +// Load array with all captcha generation modules +$dir = "../core/modules/security/captcha"; +clearstatcache(); +$handle = opendir($dir); +$i = 1; +$arrayhandler = array(); +if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + $reg = array(); + if (preg_match('/(modCaptcha[a-z]+)\.class\.php$/i', $file, $reg)) { + // Charging the numbering class + $classname = $reg[1]; + require_once $dir.'/'.$file; + + $obj = new $classname($db, $conf, $langs, $user); + '@phan-var-force ModeleCaptcha $obj'; + $arrayhandler[$obj->id] = $obj; + $i++; + } + } + closedir($handle); +} +asort($arrayhandler); + + + +print '
'; +print ''; +print ''; + +$head = security_prepare_head(); + +print dol_get_fiche_head($head, 'captcha', '', -1); + +print '
'; + + +print $langs->trans("UseCaptchaCode"); +if (function_exists("imagecreatefrompng")) { + if (!empty($conf->use_javascript_ajax)) { + print ajax_constantonoff('MAIN_SECURITY_ENABLECAPTCHA', array(), null, 0, 0, 1); + } else { + if (!getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA')) { + print ''.img_picto($langs->trans("Disabled"), 'off').''; + } else { + print ''.img_picto($langs->trans("Enabled"), 'on').''; + } + } +} else { + $desc = $form->textwithpicto('', $langs->transnoentities("EnableGDLibraryDesc"), 1, 'warning'); + print $desc; +} + + +if (getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA')) { + print '
'; + print '
'; + print '
'; + + // List of all available captcha + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $arrayofcaptcha = array( + 'standard' => array('label' => 'Standard', 'picto' => 'ee') + ); + //$arrayofcaptcha['google'] = array('label' => 'Google'); + + $selectedcaptcha = 'standard'; + + // Loop on each available captcha + foreach ($arrayhandler as $key => $module) { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + + print '
'.$langs->trans("Captcha").''.$langs->trans("Example").''.$langs->trans("Status").'
'; + print img_picto('', $module->picto, 'class="width25 size15x marginrightonly"').' '; + print ucfirst($key); + print ''; + print $module->getDescription().'
'; + print '
'; + print $module->getExample().'
'; + print '
'; + if ($key == $selectedcaptcha) { + print 'On'; + } + print '
'; + + //print $form->buttonsSaveCancel("Modify", ''); +} + +print dol_get_fiche_end(); + +print '
'; + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/admin/security_file.php b/htdocs/admin/security_file.php index d3fd5c0917a3b..9ae88c2f8ee6f 100644 --- a/htdocs/admin/security_file.php +++ b/htdocs/admin/security_file.php @@ -143,7 +143,7 @@ print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; diff --git a/htdocs/admin/security_other.php b/htdocs/admin/security_other.php index d1f9b2049b101..72d2b4f98c43b 100644 --- a/htdocs/admin/security_other.php +++ b/htdocs/admin/security_other.php @@ -122,26 +122,6 @@ print ''; print ''; -// Enable Captcha code -print ''; -print ''; -print ''; - // Enable advanced perms print ''; print ''; @@ -167,7 +147,7 @@ print '
'.$langs->trans("Parameters").''.$langs->trans("Value").'
'.$langs->trans("Status").'
'.$langs->trans("UseCaptchaCode").''; -if (function_exists("imagecreatefrompng")) { - if (!empty($conf->use_javascript_ajax)) { - print ajax_constantonoff('MAIN_SECURITY_ENABLECAPTCHA'); - } else { - if (!getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA')) { - print ''.img_picto($langs->trans("Disabled"), 'off').''; - } else { - print ''.img_picto($langs->trans("Enabled"), 'on').''; - } - } -} else { - $desc = $form->textwithpicto('', $langs->transnoentities("EnableGDLibraryDesc"), 1, 'warning'); - print $desc; -} -print '
'.$langs->trans("UseAdvancedPerms").'
'; print ''; print ''; -print ''; +print ''; print "\n"; diff --git a/htdocs/admin/system/about.php b/htdocs/admin/system/about.php index a09ae2a044fff..a9f36965ca13a 100644 --- a/htdocs/admin/system/about.php +++ b/htdocs/admin/system/about.php @@ -58,27 +58,30 @@ print load_fiche_titre($langs->trans("ExternalResources"), '', 'title_setup'); -print '
'.img_picto_common('', 'dolibarr_box.png', 'height="120"').'
'; - - print '
'; +print '
'; +print '
'.img_picto_common('', 'dolibarr_box.png', 'height="100"').'
'; print $langs->trans("DolibarrLicense").' : '; print ''; +print'
'; //print "
\n"; +print '
'; print $langs->trans("Developpers").':'; print ''; +print '
'; //print "
\n"; +print '
'; print $langs->trans("OtherInformations").':'; print ''; +print '
'; +print '
'; print $langs->trans("Demo").':'; print ''; +print '
'; +print '
'; print $langs->trans("ModulesMarketPlaces").':'; print ''; - +print '
'; print '
'; - +print '
'; print $langs->trans("HelpCenter").':'; print ''; +print '
'; - +print '
'; print $langs->trans("Foundation").':'; print ''; +print '
'; +print '
'; print $langs->trans("SocialNetworks").':'; print ''; +print '
'; - +print '
'; print $langs->trans("OtherResources").':'; print '
    '; @@ -191,6 +201,7 @@ print ''; print '
'; +print '
'; print '
'; print '
'; diff --git a/htdocs/admin/system/database-tables.php b/htdocs/admin/system/database-tables.php index ac03d3d10ca0d..62bf71af96c8b 100644 --- a/htdocs/admin/system/database-tables.php +++ b/htdocs/admin/system/database-tables.php @@ -53,12 +53,40 @@ $db->query($sql); } if ($action == 'convertutf8') { - $sql = "ALTER TABLE ".$db->sanitize($table)." CHARACTER SET utf8 COLLATE utf8_unicode_ci"; - $db->query($sql); + $collation = 'utf8_unicode_ci'; + $defaultcollation = $db->getDefaultCollationDatabase(); + if (preg_match('/general/', $defaultcollation)) { + $collation = 'utf8_general_ci'; + } + $sql = "ALTER TABLE ".$db->sanitize($table)." CHARACTER SET utf8 COLLATE ".$db->sanitize($collation); // Set the default value on table + $resql1 = $db->query($sql); + if (!$resql1) { + setEventMessages($db->lasterror(), null, 'warnings'); + } else { + $sql = "ALTER TABLE ".$db->sanitize($table)." CONVERT TO CHARACTER SET utf8 COLLATE ".$db->sanitize($collation); // Switch fields (may fails due to foreign key) + $resql2 = $db->query($sql); + if (!$resql2) { + setEventMessages($db->lasterror(), null, 'warnings'); + } + } } if ($action == 'convertutf8mb4') { - $sql = "ALTER TABLE ".$db->sanitize($table)." CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"; - $db->query($sql); + $collation = 'utf8mb4_unicode_ci'; + $defaultcollation = $db->getDefaultCollationDatabase(); + if (preg_match('/general/', $defaultcollation)) { + $collation = 'utf8mb4_general_ci'; + } + $sql = "ALTER TABLE ".$db->sanitize($table)." CHARACTER SET utf8mb4 COLLATE ".$db->sanitize($collation); // Set the default value on table + $resql1 = $db->query($sql); + if (!$resql1) { + setEventMessages($db->lasterror(), null, 'warnings'); + } else { + $sql = "ALTER TABLE ".$db->sanitize($table)." CONVERT TO CHARACTER SET utf8mb4 COLLATE ".$db->sanitize($collation); // Switch fields (may fails due to foreign key) + $resql2 = $db->query($sql); + if (!$resql2) { + setEventMessages($db->lasterror(), null, 'warnings'); + } + } } if ($action == 'convertdynamic') { $sql = "ALTER TABLE ".$db->sanitize($table)." ROW_FORMAT=DYNAMIC;"; diff --git a/htdocs/admin/system/database.php b/htdocs/admin/system/database.php index b70d57c9d668c..094e43fc553e2 100644 --- a/htdocs/admin/system/database.php +++ b/htdocs/admin/system/database.php @@ -1,9 +1,10 @@ - * Copyright (C) 2004-2014 Laurent Destailleur - * Copyright (C) 2004 Sebastien Di Cintio - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2024 MDW +/* Copyright (C) 2003-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2024 MDW + * 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 @@ -29,11 +30,34 @@ $langs->load("admin"); +$action = GETPOST('action', 'aZ09'); + if (!$user->admin) { accessforbidden(); } +/* + * Actions + */ + +if ($action == 'convertutf8unicode') { // Test on permission already done. + $sql = "ALTER DATABASE ".$db->sanitize($db->database_name)." CHARACTER SET utf8 COLLATE utf8_unicode_ci"; + $db->query($sql); +} +if ($action == 'convertutf8mb4unicode') { // Test on permission already done. + $sql = "ALTER DATABASE CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"; + $db->query($sql); +} +if ($action == 'convertutf8general') { // Test on permission already done. + $sql = "ALTER DATABASE ".$db->sanitize($db->database_name)." CHARACTER SET utf8 COLLATE utf8_general_ci"; + $db->query($sql); +} +if ($action == 'convertutf8mb4general') { // Test on permission already done. + $sql = "ALTER DATABASE ".$db->sanitize($db->database_name)." CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci"; + $db->query($sql); +} + /* * View @@ -59,14 +83,36 @@ print ''."\n"; print ''."\n"; -print ''."\n"; print '
'.$langs->trans("Parameters").''.$langs->trans("Value").'
'.$langs->trans("Password").''.preg_replace('/./i', '*', $dolibarr_main_db_pass).'
'.$langs->trans("DBStoringCharset").''.$db->getDefaultCharacterSetDatabase(); if ($db->type == 'mysqli') { - print ' '.$form->textwithpicto('', $langs->transnoentitiesnoconv("HelpMariaDBToGetPossibleValues", "SHOW CHARSET")); + $tooltipexample = "
SHOW VARIABLES LIKE 'character_set_database' (cached)
You can avoid cache effect with:
SELECT DEFAULT_CHARACTER_SET_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = '".$db->escape($conf->db->name)."'"; + print ' '.$form->textwithpicto('', $langs->transnoentitiesnoconv("HelpMariaDBToGetValue", $tooltipexample.'
'.$langs->transnoentitiesnoconv("HelpMariaDBToGetPossibleValues", "
SHOW CHARSET"))); // We can use $db->getDefaultCharacterSetDatabase(), $db->getListOfCharacterSet(), } print '
'.$langs->trans("DBSortingCharset").''.$db->getDefaultCollationDatabase(); +print '
'.$langs->trans("DBSortingCharset").''; +$defaultcollation = $db->getDefaultCollationDatabase(); +print dolPrintHTML($defaultcollation); +global $dolibarr_main_db_collation; if ($db->type == 'mysqli') { - print ' '.$form->textwithpicto('', $langs->transnoentitiesnoconv("HelpMariaDBToGetPossibleValues", "SHOW COLLATION")); + if ($defaultcollation != $conf->db->dolibarr_main_db_collation) { + print img_warning('The database default value of collation '.$defaultcollation.' differs from conf setup '.$conf->db->dolibarr_main_db_collation); + } + $tooltipexample = "
SHOW VARIABLES LIKE 'collation_database' (cached)
You can avoid cache effect with:
SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = '".$db->escape($conf->db->name)."'"; + print ' '.$form->textwithpicto('', $langs->transnoentitiesnoconv("HelpMariaDBToGetValue", $tooltipexample.'
'.$langs->transnoentitiesnoconv("HelpMariaDBToGetPossibleValues", "
SHOW COLLATION"))); // We can use $db->getDefaultCollationDatabase(), $db->getListOfCollation(); + + print '       '.$langs->trans("ConvertInto"); + if (!in_array($defaultcollation, array("utf8_unicode_ci"))) { + print '   utf8 unicode'; + } + if (!in_array($defaultcollation, array("utf8_general_ci"))) { + print '   utf8 general'; + } + if (!in_array($defaultcollation, array("utf8mb4_unicode_ci"))) { + print '   utf8mb4 unicode'; + } + if (!in_array($defaultcollation, array("utf8mb4_general_ci"))) { + print '   utf8mb4 general'; + } } print '
'; diff --git a/htdocs/admin/system/dbtable.php b/htdocs/admin/system/dbtable.php index 203d41b805d42..0ada8cec8018d 100644 --- a/htdocs/admin/system/dbtable.php +++ b/htdocs/admin/system/dbtable.php @@ -4,7 +4,8 @@ * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2024 MDW + * Copyright (C) 2024 MDW + * 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 @@ -22,7 +23,7 @@ /** * \file htdocs/admin/system/dbtable.php - * \brief Page d'info des contraintes d'une table + * \brief Page with information about a database table */ // Load Dolibarr environment @@ -56,8 +57,17 @@ $sql = "ALTER TABLE ".$db->sanitize($table)." MODIFY ".$db->sanitize($row[0])." ".$row[1]." CHARACTER SET utf8"; // We must not sanitize the $row[1] $db->query($sql); - $sql = "ALTER TABLE ".$db->sanitize($table)." MODIFY ".$db->sanitize($row[0])." ".$row[1]." COLLATE utf8_unicode_ci"; // We must not sanitize the $row[1] - $db->query($sql); + $collation = 'utf8_unicode_ci'; + $defaultcollation = $db->getDefaultCollationDatabase(); + if (preg_match('/general/', $defaultcollation)) { + $collation = 'utf8_general_ci'; + } + + $sql = "ALTER TABLE ".$db->sanitize($table)." MODIFY ".$db->sanitize($row[0])." ".$row[1]." COLLATE ".$db->sanitize($collation); // We must not sanitize the $row[1] + $resql2 = $db->query($sql); + if (!$resql2) { + setEventMessages($db->lasterror(), null, 'warnings'); + } break; } @@ -77,8 +87,17 @@ $sql = "ALTER TABLE ".$db->sanitize($table)." MODIFY ".$db->sanitize($row[0])." ".$row[1]." CHARACTER SET utf8mb4"; // We must not sanitize the $row[1] $db->query($sql); - $sql = "ALTER TABLE ".$db->sanitize($table)." MODIFY ".$db->sanitize($row[0])." ".$row[1]." COLLATE utf8mb4_unicode_ci"; // We must not sanitize the $row[1] - $db->query($sql); + $collation = 'utf8mb4_unicode_ci'; + $defaultcollation = $db->getDefaultCollationDatabase(); + if (preg_match('/general/', $defaultcollation)) { + $collation = 'utf8mb4_general_ci'; + } + + $sql = "ALTER TABLE ".$db->sanitize($table)." MODIFY ".$db->sanitize($row[0])." ".$row[1]." COLLATE ".$db->sanitize($collation); // We must not sanitize the $row[1] + $resql2 = $db->query($sql); + if (!$resql2) { + setEventMessages($db->lasterror(), null, 'warnings'); + } break; } @@ -137,6 +156,7 @@ } } + print '
'; print ''; print ''; print ''; @@ -215,13 +235,14 @@ print ""; - print ''; - print ''; + print ''; + print ''; print ''; $i++; } } print '
'.$langs->trans("Fields").'".(isset($link[$row[0]][0]) ? $link[$row[0]][0] : '')."."; print(isset($link[$row[0]][1]) ? $link[$row[0]][1] : '')."
'; + print '
'; } } diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 866d57cec819c..a216e256d554b 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -2,7 +2,8 @@ /* Copyright (C) 2005-2020 Laurent Destailleur * Copyright (C) 2007 Rodolphe Quiedeville * Copyright (C) 2007-2012 Regis Houssin - * Copyright (C) 2024 MDW + * Copyright (C) 2024 MDW + * 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 @@ -243,10 +244,10 @@ $dec = $langs->transnoentitiesnoconv("SeparatorDecimal"); print ''.$langs->trans("CurrentValueSeparatorDecimal").''.$dec.''."\n"; // Show results of functions to see if everything works -print '  => price2num(1233.56+1)'.price2num(1233.56 + 1, '2').''."\n"; -print '  => price2num('."'1".$thousand."234".$dec."56')".price2num("1".$thousand."234".$dec."56", '2')."\n"; +print '  => price2num(1233.56+1)'.price2num(1233.56 + 1, 2).''."\n"; +print '  => price2num('."'1".$thousand."234".$dec."56')".price2num("1".$thousand."234".$dec."56", 2)."\n"; if (($thousand != ',' && $thousand != '.') || ($thousand != ' ')) { - print '  => price2num('."'1 234.56')".price2num("1 234.56", '2').""; + print '  => price2num('."'1 234.56')".price2num("1 234.56", 2).""; print "\n"; } print '  => price(1234.56)'.price(1234.56).''."\n"; @@ -276,7 +277,7 @@ $val = ($a >= 0 ? '+' : '').$a; $val .= ' ('.($a == 'unknown' ? 'unknown' : ($a >= 0 ? '+' : '').($a * 3600)).')'; $val .= '       '.getServerTimeZoneString(); -$val .= '       '.$langs->trans("DaylingSavingTime").': '.((is_null($b) || is_null($c)) ? 'unknown' : ($a == $c ? yn($daylight) : yn(0).($daylight ? '     ('.$langs->trans('YesInSummer').')' : ''))); +$val .= '       '.$langs->trans("DaylingSavingTime").': '.((is_null($b) || is_null($c)) ? 'unknown' : ($a == $c ? yn((int) $daylight) : yn(0).($daylight ? '     ('.$langs->trans('YesInSummer').')' : ''))); print $form->textwithtooltip($val, $txt, 2, 1, img_info('')); print ''."\n"; // value defined in http://fr3.php.net/manual/en/timezones.europe.php print '  => '.$langs->trans("CurrentHour").''.dol_print_date(dol_now('gmt'), 'dayhour', 'tzserver').''."\n"; diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index 3aaadbfe2f09f..7b91532672007 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -107,7 +107,7 @@ if ($modName) { //print 'xx'.$dir.$file.'
'; if (in_array($file, $modules_files)) { - // File duplicate + // File duplicate @phan-suppress-next-line PhanTypeInvalidDimOffset print "Warning duplicate file found : ".$file." (Found ".$dir.$file.", already found ".$modules_fullpath[$file].")
"; } else { // File to load diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 5f043b13b7a4d..162151102e255 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -250,7 +250,7 @@ print '
'; -if (isset($optioncss) && $optioncss != '') { +if ($optioncss != '') { print ''; } print ''; @@ -469,7 +469,7 @@ $nbempty++; } - if ($action == 'search' && ($nbempty > 999)) { // 999 to disable this + if ($action == 'search' && ($nbempty > 999)) { // 999 to disable this @phpstan-ignore-line setEventMessages($langs->trans("WarningAtLeastKeyOrTranslationRequired"), null, 'warnings'); } else { // Now search into translation array diff --git a/htdocs/admin/webhook.php b/htdocs/admin/webhook.php index 2c0c043abe461..91d08a9c7239a 100644 --- a/htdocs/admin/webhook.php +++ b/htdocs/admin/webhook.php @@ -165,7 +165,7 @@ if ($action == 'edit') { - if ($useFormSetup && (float) DOL_VERSION >= 15) { + if ($useFormSetup && (float) DOL_VERSION >= 15) { // @phpstan-ignore-line print $formSetup->generateOutput(true); } else { print ''; @@ -257,7 +257,7 @@ print '
'; } else { - if ($useFormSetup && (float) DOL_VERSION >= 15) { + if ($useFormSetup && (float) DOL_VERSION >= 15) { // @phpstan-ignore-line if (!empty($formSetup->items)) { print $formSetup->generateOutput(); } diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 48df30067a174..7c7c624603bbd 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -662,6 +662,9 @@ public function get($id) { * @param string $fileencoding File encoding (''=no encoding, 'base64'=Base 64) * @param int $overwriteifexists Overwrite file if exists (1 by default) * @param int $createdirifnotexists Create subdirectories if the doesn't exists (1 by default) + * @param int $position Position + * @param string $cover Cover info + * @param array $array_options array of options * @return string * * @url POST /upload @@ -669,16 +672,12 @@ public function get($id) { * @throws RestException 400 Bad Request * @throws RestException 403 Access denied * @throws RestException 404 Object not found - * @throws RestException 500 Error on file operationw + * @throws RestException 500 Error on file operation */ - public function post($filename, $modulepart, $ref = '', $subdir = '', $filecontent = '', $fileencoding = '', $overwriteifexists = 0, $createdirifnotexists = 1) + public function post($filename, $modulepart, $ref = '', $subdir = '', $filecontent = '', $fileencoding = '', $overwriteifexists = 0, $createdirifnotexists = 1, $position = 0, $cover = '', $array_options = []) { global $conf; - //var_dump($modulepart); - //var_dump($filename); - //var_dump($filecontent);exit; - $modulepartorig = $modulepart; if (empty($modulepart)) { @@ -939,11 +938,20 @@ public function post($filename, $modulepart, $ref = '', $subdir = '', $fileconte $moreinfo['src_object_type'] = $object->table_element; $moreinfo['src_object_id'] = $object->id; } + if (!empty($array_options)) { + $moreinfo = array_merge($moreinfo, ["array_options" => $array_options]); + } + if (!empty($position)) { + $moreinfo = array_merge($moreinfo, ["position" => $position]); + } + if (!empty($cover)) { + $moreinfo = array_merge($moreinfo, ["cover" => $cover]); + } // Move the temporary file at its final emplacement $result = dol_move($destfiletmp, $dest_file, '0', $overwriteifexists, 1, 1, $moreinfo); if (!$result) { - throw new RestException(500, "Failed to move file into '".$destfile."'"); + throw new RestException(500, "Failed to move file into '".$dest_file."'"); } return dol_basename($destfile); diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index d3ca1e430b9f2..d30ba75b5a4e2 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1,12 +1,12 @@ - * Copyright (C) 2016 Laurent Destailleur - * Copyright (C) 2017 Regis Houssin - * Copyright (C) 2017 Neil Orley - * Copyright (C) 2018-2021 Frédéric France - * Copyright (C) 2018-2022 Thibault FOUCART - * Copyright (C) 2024 Jon Bendtsen - * Copyright (C) 2024 MDW +/* Copyright (C) 2016 Xebax Christy + * Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2017 Regis Houssin + * Copyright (C) 2017 Neil Orley + * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2018-2022 Thibault FOUCART + * Copyright (C) 2024 Jon Bendtsen + * Copyright (C) 2024 MDW * * * This program is free software; you can redistribute it and/or modify @@ -419,7 +419,7 @@ public function getRegionByID($id) */ public function getRegionByCode($code) { - return $this->_fetchCregion('', $code); + return $this->_fetchCregion(0, $code); } /** @@ -528,7 +528,7 @@ public function getStateByID($id) */ public function getStateByCode($code) { - return $this->_fetchCstate('', $code); + return $this->_fetchCstate(0, $code); } /** @@ -637,7 +637,7 @@ public function getCountryByID($id, $lang = '') */ public function getCountryByCode($code, $lang = '') { - return $this->_fetchCcountry('', $code, '', $lang); + return $this->_fetchCcountry(0, $code, '', $lang); } /** @@ -654,7 +654,7 @@ public function getCountryByCode($code, $lang = '') */ public function getCountryByISO($iso, $lang = '') { - return $this->_fetchCcountry('', '', $iso, $lang); + return $this->_fetchCcountry(0, '', $iso, $lang); } /** diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index cbc7e0a7c880f..e02474b495eff 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -146,15 +146,15 @@ class Asset extends CommonObject */ public $recovered_vat; /** - * @var string + * @var int|'' */ public $reversal_date; /** - * @var string + * @var int|'' */ public $date_acquisition; /** - * @var string + * @var int|'' */ public $date_start; /** @@ -245,7 +245,7 @@ class Asset extends CommonObject */ public $asset_accountancy_codes; /** - * @var array> List of depreciation lines for each mode (sort by depreciation date). + * @var array> List of depreciation lines for each mode (sort by depreciation date). */ public $depreciation_lines = array(); @@ -450,6 +450,7 @@ public function fetch($id, $ref = null) $this->fields['reversal_amount_ht']['noteditable'] = '1'; } } + return $result; } diff --git a/htdocs/asset/class/assetmodel.class.php b/htdocs/asset/class/assetmodel.class.php index 38bb118665a0b..5e9e32e7fa523 100644 --- a/htdocs/asset/class/assetmodel.class.php +++ b/htdocs/asset/class/assetmodel.class.php @@ -278,9 +278,11 @@ public function createFromClone(User $user, $fromid) // Clear fields if (property_exists($object, 'ref')) { + // @phan-suppress-next-line PhanTypeInvalidDimOffset $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default']; } if (property_exists($object, 'label')) { + // @phan-suppress-next-line PhanTypeInvalidDimOffset $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; } if (property_exists($object, 'status')) { diff --git a/htdocs/asset/depreciation.php b/htdocs/asset/depreciation.php index 13da0968e6153..da797816db8b0 100644 --- a/htdocs/asset/depreciation.php +++ b/htdocs/asset/depreciation.php @@ -190,7 +190,7 @@ print price($line['cumulative_depreciation_ht']); print ''; print ''; - print price(price2num((float) $depreciation_info['base_depreciation_ht'] - $line['cumulative_depreciation_ht'], 'MT')); + print price(price2num((float) $depreciation_info['base_depreciation_ht'] - (float) $line['cumulative_depreciation_ht'], 'MT')); print ''; print "\n"; } diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php index 00cff62c431ce..63f85a14a7a2f 100644 --- a/htdocs/asset/list.php +++ b/htdocs/asset/list.php @@ -439,7 +439,7 @@ $moreforfilter.= '
';*/ $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { $moreforfilter .= $hookmanager->resPrint; } else { diff --git a/htdocs/asset/model/list.php b/htdocs/asset/model/list.php index f4681c88bd277..29dad0d92ba1b 100644 --- a/htdocs/asset/model/list.php +++ b/htdocs/asset/model/list.php @@ -443,7 +443,7 @@ $moreforfilter.= '
';*/ $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { $moreforfilter .= $hookmanager->resPrint; } else { diff --git a/htdocs/asset/tpl/depreciation_options_edit.tpl.php b/htdocs/asset/tpl/depreciation_options_edit.tpl.php index b704725acadc3..6809a5a543710 100644 --- a/htdocs/asset/tpl/depreciation_options_edit.tpl.php +++ b/htdocs/asset/tpl/depreciation_options_edit.tpl.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 @@ -121,7 +122,7 @@ print ''; print ''; if (!empty($field_info['picto'])) { - print img_picto('', $field_info['picto'], '', false, 0, 0, '', 'pictofixedwidth'); + print img_picto('', $field_info['picto'], '', 0, 0, 0, '', 'pictofixedwidth'); } if (in_array($field_info['type'], array('int', 'integer'))) { $value = GETPOSTISSET($html_name) ? GETPOSTINT($html_name) : $assetdepreciationoptions->$field_key; diff --git a/htdocs/asset/tpl/linkedobjectblock.tpl.php b/htdocs/asset/tpl/linkedobjectblock.tpl.php index 04bfd2ad3dfcd..cb83c1d0f9412 100644 --- a/htdocs/asset/tpl/linkedobjectblock.tpl.php +++ b/htdocs/asset/tpl/linkedobjectblock.tpl.php @@ -52,7 +52,7 @@ echo ''; echo ''.$langs->trans("Asset"); if (!empty($showImportButton) && getDolGlobalString('MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES')) { - print ' '; echo ''.$objectlink->getNomUrl(1).''; diff --git a/htdocs/barcode/codeinit.php b/htdocs/barcode/codeinit.php index 7334ec261187b..e45ddb08da2ea 100644 --- a/htdocs/barcode/codeinit.php +++ b/htdocs/barcode/codeinit.php @@ -140,7 +140,7 @@ $thirdpartystatic->id = $obj->rowid; $nextvalue = $modBarCodeThirdparty->getNextValue($thirdpartystatic, ''); - $result = $thirdpartystatic->setValueFrom('barcode', $nextvalue, '', '', 'text', '', $user, 'THIRDPARTY_MODIFY'); + $result = $thirdpartystatic->setValueFrom('barcode', $nextvalue, '', null, 'text', '', $user, 'THIRDPARTY_MODIFY'); $nbtry++; if ($result > 0) { @@ -249,7 +249,7 @@ $nextvalue = $modBarCodeProduct->getNextValue($productstatic, ''); //print 'Set value '.$nextvalue.' to product '.$productstatic->id." ".$productstatic->ref." ".$productstatic->type."
\n"; - $result = $productstatic->setValueFrom('barcode', $nextvalue, '', '', 'text', '', $user, 'PRODUCT_MODIFY'); + $result = $productstatic->setValueFrom('barcode', $nextvalue, '', null, 'text', '', $user, 'PRODUCT_MODIFY'); $nbtry++; if ($result > 0) { diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index dc5ce2b572947..1c9b9282bd7ec 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -201,7 +201,7 @@ public function loadTrackedEvents() /* // Salary - if (!empty($conf->salary->enabled)) { + if (isModEnabled('salary')) { $this->trackedevents['PAYMENT_SALARY_CREATE']='BlockedLogSalaryPaymentCreate'; $this->trackedevents['PAYMENT_SALARY_MODIFY']='BlockedLogSalaryPaymentCreate'; $this->trackedevents['PAYMENT_SALARY_DELETE']='BlockedLogSalaryPaymentCreate'; @@ -1220,7 +1220,7 @@ public function getSignature() require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $fingerprint = dol_hash(print_r($mysoc, true).getRandomPassword(1), '5'); + $fingerprint = dol_hash(print_r($mysoc, true).getRandomPassword(true), '5'); dolibarr_set_const($db, 'BLOCKEDLOG_ENTITY_FINGERPRINT', $fingerprint, 'chaine', 0, 'Numeric Unique Fingerprint', $conf->entity); diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index ddbb7ac010e5b..d945541aa4909 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -534,9 +534,6 @@ if (!empty($moreforfilter)) { print '
'; print $moreforfilter; - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; print '
'; } diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index b88a007822c6a..bf70f5469ff24 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -341,6 +341,7 @@ public function createFromClone(User $user, $fromid) // Clear fields $default_ref = $this->fields['ref']['default'] ?? null; $object->ref = empty($default_ref) ? $langs->trans("copy_of_").$object->ref : $default_ref; + // @phan-suppress-next-line PhanTypeInvalidDimOffset $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; $object->status = self::STATUS_DRAFT; // ... diff --git a/htdocs/bom/tpl/linkedobjectblock.tpl.php b/htdocs/bom/tpl/linkedobjectblock.tpl.php index aa429b2d65c8b..aee1a6bebdbf6 100644 --- a/htdocs/bom/tpl/linkedobjectblock.tpl.php +++ b/htdocs/bom/tpl/linkedobjectblock.tpl.php @@ -53,7 +53,7 @@ echo ''; echo ''.$langs->trans("Bom"); if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { - print '
'; echo ''.$objectlink->getNomUrl(1).''; diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index b2bf4b25bcaee..72e764322b4d7 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -112,6 +112,7 @@ print ' '; print ''; } + print ''; $coldisplay = 0; diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index f44b36eb9d872..32aa4f6751669 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -192,6 +192,16 @@ print ''; $coldisplay++; if ($res > 0) { + $unit = new CUnits($object->db); + $fk_defaultUnit = $unit->getUnitFromCode('h', 'short_label', 'time'); + $nbPlannedHour = $unit->unitConverter($line->qty, $line->fk_unit, $fk_defaultUnit); + $line->total_cost = 0; + if ($workstation->thm_machine_estimated) { + $line->total_cost += $nbPlannedHour * $workstation->thm_machine_estimated; + } + if ($workstation->thm_operator_estimated) { + $line->total_cost += $nbPlannedHour * $workstation->thm_operator_estimated; + } echo $workstation->getNomUrl(1); } print ''; @@ -199,6 +209,7 @@ // Cost $total_cost = 0; + $tmpbom->calculateCosts(); print ''; $coldisplay++; diff --git a/htdocs/bookcal/admin/calendar_extrafields.php b/htdocs/bookcal/admin/calendar_extrafields.php index 582997fe3d0c6..edd46e34e238f 100644 --- a/htdocs/bookcal/admin/calendar_extrafields.php +++ b/htdocs/bookcal/admin/calendar_extrafields.php @@ -6,6 +6,7 @@ * Copyright (C) 2014 Florian Henry * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -85,7 +86,7 @@ // Buttons -if ((float) DOL_VERSION < 17) { // On v17+, the "New Attribute" button is included into tpl. +if ((float) DOL_VERSION < 17) { // On v17+, the "New Attribute" button is included into tpl. @phpstan-ignore-line if ($action != 'create' && $action != 'edit') { print '
'; print ''.$langs->trans("NewAttribute").''; diff --git a/htdocs/bookcal/availabilities_agenda.php b/htdocs/bookcal/availabilities_agenda.php index 4de8cdae28402..30a5cb249c3a3 100644 --- a/htdocs/bookcal/availabilities_agenda.php +++ b/htdocs/bookcal/availabilities_agenda.php @@ -146,7 +146,7 @@ $help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung'; llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-bookcal page-card_availabilities_agenda'); - if (!empty($conf->notification->enabled)) { + if (isModEnabled('notification')) { $langs->load("mails"); } $head = availabilitiesPrepareHead($object); diff --git a/htdocs/bookcal/availabilities_card.php b/htdocs/bookcal/availabilities_card.php index 4cd7fc5dd2fad..512fd618c4482 100644 --- a/htdocs/bookcal/availabilities_card.php +++ b/htdocs/bookcal/availabilities_card.php @@ -2,6 +2,7 @@ /* Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2022 Alice Adminson * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -180,8 +181,8 @@ } - // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen - include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; + // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; // Actions when linking object each other include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; @@ -196,7 +197,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; if ($action == 'set_thirdparty' && $permissiontoadd) { - $object->setValueFrom('fk_soc', GETPOSTINT('fk_soc'), '', '', 'date', '', $user, $triggermodname); + $object->setValueFrom('fk_soc', GETPOSTINT('fk_soc'), '', null, 'date', '', $user, $triggermodname); } if ($action == 'classin' && $permissiontoadd) { $object->setProject(GETPOSTINT('projectid')); diff --git a/htdocs/bookcal/availabilities_list.php b/htdocs/bookcal/availabilities_list.php index a496dc0554c8e..8eeb09661b13a 100644 --- a/htdocs/bookcal/availabilities_list.php +++ b/htdocs/bookcal/availabilities_list.php @@ -511,9 +511,6 @@ if (!empty($moreforfilter)) { print '
'; print $moreforfilter; - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; print '
'; } diff --git a/htdocs/bookcal/bookcalindex.php b/htdocs/bookcal/bookcalindex.php index cbb6ae1f74a85..a368c928ce6c8 100644 --- a/htdocs/bookcal/bookcalindex.php +++ b/htdocs/bookcal/bookcalindex.php @@ -63,9 +63,9 @@ $form = new Form($db); $formfile = new FormFile($db); -llxHeader("", $langs->trans("BookCalArea"), '', '', 0, 0, '', '', '', 'mod-bookcal page-index'); +llxHeader("", $langs->trans("BookcalBookingTitle"), '', '', 0, 0, '', '', '', 'mod-bookcal page-index'); -print load_fiche_titre($langs->trans("BookCalArea"), '', 'fa-calendar-check'); +print load_fiche_titre($langs->trans("BookcalBookingTitle"), '', 'fa-calendar-check'); print '
'; diff --git a/htdocs/bookcal/calendar_agenda.php b/htdocs/bookcal/calendar_agenda.php index e72b5e691a3d2..74d31b5c80d1a 100644 --- a/htdocs/bookcal/calendar_agenda.php +++ b/htdocs/bookcal/calendar_agenda.php @@ -265,6 +265,7 @@ //$cachekey = 'count_events_myobject_'.$object->id; //$nbEvent = dol_getcache($cachekey); $titlelist = $langs->trans("Actions").(is_numeric($nbEvent) ? '('.$nbEvent.')': ''); + print_barre_liste($titlelist, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 0); // List of all actions diff --git a/htdocs/bookcal/calendar_card.php b/htdocs/bookcal/calendar_card.php index 070b0c01ff183..30e3bf7b8e458 100644 --- a/htdocs/bookcal/calendar_card.php +++ b/htdocs/bookcal/calendar_card.php @@ -2,6 +2,7 @@ /* Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2023 Alice Adminson * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -158,7 +159,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; if ($action == 'set_thirdparty' && $permissiontoadd) { - $object->setValueFrom('fk_soc', GETPOSTINT('fk_soc'), '', '', 'date', '', $user, $triggermodname); + $object->setValueFrom('fk_soc', GETPOSTINT('fk_soc'), '', null, 'date', '', $user, $triggermodname); } if ($action == 'classin' && $permissiontoadd) { $object->setProject(GETPOSTINT('projectid')); diff --git a/htdocs/bookcal/calendar_list.php b/htdocs/bookcal/calendar_list.php index 983b5bc8b7357..ed60c9741b699 100644 --- a/htdocs/bookcal/calendar_list.php +++ b/htdocs/bookcal/calendar_list.php @@ -492,9 +492,6 @@ if (!empty($moreforfilter)) { print '
'; print $moreforfilter; - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; print '
'; } diff --git a/htdocs/bookcal/class/availabilities.class.php b/htdocs/bookcal/class/availabilities.class.php index a04ed3acd76b4..c7e69ff01653b 100644 --- a/htdocs/bookcal/class/availabilities.class.php +++ b/htdocs/bookcal/class/availabilities.class.php @@ -331,6 +331,7 @@ public function createFromClone(User $user, $fromid) $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default']; } if (property_exists($object, 'label')) { + // @phan-suppress-next-line PhanTypeInvalidDimOffset $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; } if (property_exists($object, 'status')) { diff --git a/htdocs/bookcal/class/calendar.class.php b/htdocs/bookcal/class/calendar.class.php index 47955005423ea..93f79d45326e7 100644 --- a/htdocs/bookcal/class/calendar.class.php +++ b/htdocs/bookcal/class/calendar.class.php @@ -283,9 +283,11 @@ public function createFromClone(User $user, $fromid) // Clear fields if (property_exists($object, 'ref')) { + // @phan-suppress-next-line PhanTypeInvalidDimOffset $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default']; } if (property_exists($object, 'label')) { + // @phan-suppress-next-line PhanTypeInvalidDimOffset $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; } if (property_exists($object, 'status')) { diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index edd6988d38b91..0034df3990472 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.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 @@ -93,13 +94,13 @@ function printDropdownBookmarksList() //$urltoadd=DOL_URL_ROOT.'/bookmarks/card.php?action=create&urlsource='.urlencode($url).'&url='.urlencode($url); $urltoadd = DOL_URL_ROOT.'/bookmarks/card.php?action=create&url='.urlencode($url); $newbtn .= ''; - $newbtn .= img_picto('', 'add', '', false, 0, 0, '', 'paddingright').dol_escape_htmltag($langs->trans('AddThisPageToBookmarks')).''; + $newbtn .= img_picto('', 'add', '', 0, 0, 0, '', 'pictofixedwidth paddingright').dol_escape_htmltag($langs->trans('AddThisPageToBookmarks')).''; } } // Url to list/edit bookmark $listbtn = ''; - $listbtn .= img_picto('', 'edit', 'class="paddingright opacitymedium"').$langs->trans('EditBookmarks').''; + $listbtn .= img_picto('', 'edit', 'class="pictofixedwidth paddingright opacitymedium"').$langs->trans('EditBookmarks').''; $bookmarkList = ''; $bookmarkNb = 0; @@ -124,7 +125,6 @@ function printDropdownBookmarksList() $searchForm .= ''; } else { $searchForm .= ''; print ''; print ' '; - print ''; + print ''; print "\n"; $i = 0; diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index ca4f0c8d863e1..298a936b90ab0 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -1500,7 +1500,7 @@ foreach ($listofpaths as $key => $val) { $out .= '
'; $out .= img_mime($listofpaths[$key]['name']).' '.$listofpaths[$key]['name']; - $out .= ' '; + $out .= ' '; $out .= '
'; } } else { diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 28bdb0b02d8e1..5b37f801dcbcb 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -1,6 +1,7 @@ + * Copyright (C) 2013 Florian Henry + * 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 @@ -17,7 +18,7 @@ */ /** - * \file comm/mailing/class/advtargetemailing.class.php + * \file htdocs/comm/mailing/class/advtargetemailing.class.php * \ingroup mailing * \brief This file is an example CRUD class file (Create/Read/Update/Delete) */ @@ -92,7 +93,15 @@ class AdvanceTargetingMailing extends CommonObject * @var array type status comm prospect */ public $type_statuscommprospect = array(); + + /** + * @var int[] + */ public $thirdparty_lines; + + /** + * @var int[] + */ public $contact_lines; diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index 80b11d9b45071..eea6d8ac8f246 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -372,9 +372,6 @@ if (!empty($moreforfilter)) { print '
'; print $moreforfilter; - $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 '
'; } diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index d6a78f296c735..ad445ce6fe0d5 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -547,7 +547,7 @@ $element = $subelement = 'contrat'; } if ($element == 'inter') { - $element = $subelement = 'ficheinter'; + $element = $subelement = 'fichinter'; } if ($element == 'shipping') { $element = $subelement = 'expedition'; @@ -568,6 +568,7 @@ $classname = ucfirst($subelement); $srcobject = new $classname($db); + '@phan-var-force Commande|Propal|Contrat|Fichinter|Expedition $srcobject'; // Can be other class, but CommonObject is too generic dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); $result = $srcobject->fetch($object->origin_id); @@ -930,7 +931,10 @@ // Go back to draft if ($action == 'modif' && $usercancreate) { - $object->setDraft($user); + $result = $object->setDraft($user); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { // Define output language @@ -1012,7 +1016,7 @@ $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->subprice = (float) $subprice; $line->multicurrency_subprice = $multicurrency_subprice; } } elseif ($action == 'addline' && !GETPOST('submitforalllines', 'alpha') && !GETPOST('submitforallmargins', 'alpha') && $usercancreate) { // Add line @@ -1137,8 +1141,51 @@ $price_min_ttc = $prod->price_min_ttc; $price_base_type = $prod->price_base_type; - // If price per segment - if (getDolGlobalString('PRODUIT_MULTIPRICES') && $object->thirdparty->price_level) { + if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) { + // If price per customer + require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; + $prodcustprice = new ProductCustomerPrice($db); + $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $object->thirdparty->id); + + // If a price per customer exist + $pricebycustomerexist = false; + $result = $prodcustprice->fetchAll('', '', 0, 0, $filter); + if ($result) { + // If there is some prices specific to the customer + if (count($prodcustprice->lines) > 0) { + $pricebycustomerexist = true; + $pu_ht = price($prodcustprice->lines[0]->price); + $pu_ttc = price($prodcustprice->lines[0]->price_ttc); + $price_min = price($prodcustprice->lines[0]->price_min); + $price_min_ttc = price($prodcustprice->lines[0]->price_min_ttc); + $price_base_type = $prodcustprice->lines[0]->price_base_type; + /*$tva_tx = ($prodcustprice->lines[0]->default_vat_code ? $prodcustprice->lines[0]->tva_tx.' ('.$prodcustprice->lines[0]->default_vat_code.' )' : $prodcustprice->lines[0]->tva_tx); + if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) { + $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + } + $tva_npr = $prodcustprice->lines[0]->recuperableonly; + if (empty($tva_tx)) { + $tva_npr = 0; + }*/ + } + } + + if (!$pricebycustomerexist && $object->thirdparty->price_level) { // If price per segment + $pu_ht = $prod->multiprices[$object->thirdparty->price_level]; + $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level]; + $price_min = $prod->multiprices_min[$object->thirdparty->price_level]; + $price_min_ttc = $prod->multiprices_min_ttc[$object->thirdparty->price_level]; + $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; + if (getDolGlobalString('PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL')) { // using this option is a bug. kept for backward compatibility + if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) { + $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level]; + } + if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) { + $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level]; + } + } + } + } elseif (getDolGlobalString('PRODUIT_MULTIPRICES') && $object->thirdparty->price_level) { // If price per segment $pu_ht = $prod->multiprices[$object->thirdparty->price_level]; $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level]; $price_min = $prod->multiprices_min[$object->thirdparty->price_level]; @@ -1549,11 +1596,11 @@ $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); $price_min = $product->price_min; - if (getDolGlobalString('PRODUIT_MULTIPRICES') && !empty($object->thirdparty->price_level)) { + if ((getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) && !empty($object->thirdparty->price_level)) { $price_min = $product->multiprices_min[$object->thirdparty->price_level]; } $price_min_ttc = $product->price_min_ttc; - if (getDolGlobalString('PRODUIT_MULTIPRICES') && !empty($object->thirdparty->price_level)) { + if ((getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) && !empty($object->thirdparty->price_level)) { $price_min_ttc = $product->multiprices_min_ttc[$object->thirdparty->price_level]; } @@ -1839,6 +1886,7 @@ $classname = ucfirst($subelement); $objectsrc = new $classname($db); + '@phan-var-force Commande|Propal|Contrat|Expedition $objectsrc'; // Can be other class, but CommonObject is too generic $objectsrc->fetch($originid); if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) { $objectsrc->fetch_lines(); @@ -1956,7 +2004,7 @@ } else { print ''; $filter = '((s.client:IN:1,2,3) AND (s.status:=:1))'; - print img_picto('', 'company', 'class="pictofixedwidth"').$form->select_company('', 'socid', $filter, 'SelectThirdParty', 1, 0, null, 0, 'minwidth300 maxwidth500 widthcentpercentminusxx'); + print img_picto('', 'company', 'class="pictofixedwidth"').$form->select_company('', 'socid', $filter, 'SelectThirdParty', 1, 0, array(), 0, 'minwidth300 maxwidth500 widthcentpercentminusxx'); // reload page to retrieve customer information if (!getDolGlobalString('RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED')) { print ''; - $stringtoshow .= '
'; // hideobject is to start hidden + $stringtoshow .= '
'; // hideobject is to start hidden $stringtoshow .= ''; $stringtoshow .= ''; $stringtoshow .= ''; - $stringtoshow .= ''; + $stringtoshow .= ''; $stringtoshow .= ' '.$langs->trans("Days"); - $stringtoshow .= ''; + $stringtoshow .= ''; $stringtoshow .= ''; $stringtoshow .= '
'; @@ -201,13 +201,15 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string - * @return string + * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) { diff --git a/htdocs/core/boxes/box_graph_nb_tickets_type.php b/htdocs/core/boxes/box_graph_nb_tickets_type.php index 334e747a8a4ae..1a17fbf1de883 100644 --- a/htdocs/core/boxes/box_graph_nb_tickets_type.php +++ b/htdocs/core/boxes/box_graph_nb_tickets_type.php @@ -183,13 +183,15 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string - * @return string + * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) { diff --git a/htdocs/core/boxes/box_graph_new_vs_close_ticket.php b/htdocs/core/boxes/box_graph_new_vs_close_ticket.php index 271bf534cdbc1..ca61d098f6af1 100644 --- a/htdocs/core/boxes/box_graph_new_vs_close_ticket.php +++ b/htdocs/core/boxes/box_graph_new_vs_close_ticket.php @@ -164,13 +164,15 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string - * @return string + * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) { diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index faae74f904150..461cda11cb650 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -99,19 +99,19 @@ public function loadBox($max = 5) if ($user->hasRight('commande', 'lire')) { $langs->load("orders"); - $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; - $param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; - $param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; + $param_year = 'DOLUSER_box_'.$this->boxcode.'_year'; + $param_shownb = 'DOLUSER_box_'.$this->boxcode.'_shownb'; + $param_showtot = 'DOLUSER_box_'.$this->boxcode.'_showtot'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php'; $autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); - if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray)) { + if (in_array('DOLUSER_box_'.$this->boxcode, $autosetarray)) { $endyear = GETPOSTINT($param_year); $shownb = GETPOST($param_shownb, 'alpha'); $showtot = GETPOST($param_showtot, 'alpha'); } else { - $tmparray = (!empty($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode]) ? json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true) : array()); + $tmparray = (!empty($_COOKIE['DOLUSER_box_'.$this->boxcode]) ? json_decode($_COOKIE['DOLUSER_box_'.$this->boxcode], true) : array()); $endyear = (!empty($tmparray['year']) ? $tmparray['year'] : ''); $shownb = (!empty($tmparray['shownb']) ? $tmparray['shownb'] : ''); $showtot = (!empty($tmparray['showtot']) ? $tmparray['showtot'] : ''); @@ -233,13 +233,13 @@ public function loadBox($max = 5) $stringtoshow .= ''; $stringtoshow .= ''; $stringtoshow .= ''; - $stringtoshow .= ''; - $stringtoshow .= ' '.$langs->trans("NumberOfOrdersByMonth"); + $stringtoshow .= ''; + $stringtoshow .= ''; $stringtoshow .= '   '; - $stringtoshow .= ' '.$langs->trans("AmountOfOrdersByMonthHT"); + $stringtoshow .= ''; $stringtoshow .= '
'; $stringtoshow .= $langs->trans("Year").' '; - $stringtoshow .= ''; + $stringtoshow .= ''; $stringtoshow .= ''; $stringtoshow .= '
'; if ($shownb && $showtot) { @@ -281,13 +281,15 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string - * @return string + * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) { diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index 6b75fdf3368da..1964f4317adcd 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -98,19 +98,19 @@ public function loadBox($max = 5) if ($user->hasRight('fournisseur', 'commande', 'lire')) { $langs->load("orders"); - $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; - $param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; - $param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; + $param_year = 'DOLUSER_box_'.$this->boxcode.'_year'; + $param_shownb = 'DOLUSER_box_'.$this->boxcode.'_shownb'; + $param_showtot = 'DOLUSER_box_'.$this->boxcode.'_showtot'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php'; $autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); - if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray)) { + if (in_array('DOLUSER_box_'.$this->boxcode, $autosetarray)) { $endyear = GETPOSTINT($param_year); $shownb = GETPOST($param_shownb, 'alpha'); $showtot = GETPOST($param_showtot, 'alpha'); } else { - $tmparray = (!empty($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode]) ? json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true) : array()); + $tmparray = (!empty($_COOKIE['DOLUSER_box_'.$this->boxcode]) ? json_decode($_COOKIE['DOLUSER_box_'.$this->boxcode], true) : array()); $endyear = (!empty($tmparray['year']) ? $tmparray['year'] : ''); $shownb = (!empty($tmparray['shownb']) ? $tmparray['shownb'] : ''); $showtot = (!empty($tmparray['showtot']) ? $tmparray['showtot'] : ''); @@ -232,13 +232,13 @@ public function loadBox($max = 5) $stringtoshow .= ''; $stringtoshow .= ''; $stringtoshow .= ''; - $stringtoshow .= ''; - $stringtoshow .= ' '.$langs->trans("NumberOfOrdersByMonth"); + $stringtoshow .= ''; + $stringtoshow .= ''; $stringtoshow .= '   '; - $stringtoshow .= ' '.$langs->trans("AmountOfOrdersByMonthHT"); + $stringtoshow .= ''; $stringtoshow .= '
'; $stringtoshow .= $langs->trans("Year").' '; - $stringtoshow .= ''; + $stringtoshow .= ''; $stringtoshow .= ''; $stringtoshow .= '
'; if ($shownb && $showtot) { @@ -280,11 +280,13 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string * @return string */ diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index eeb4e2a4a29f8..f232fa8ef811d 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -1,6 +1,6 @@ - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify @@ -75,18 +75,18 @@ public function loadBox($max = 5) include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; - $param_showinvoicenb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showinvoicenb'; - $param_showpropalnb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showpropalnb'; - $param_showordernb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showordernb'; + $param_year = 'DOLUSER_box_'.$this->boxcode.'_year'; + $param_showinvoicenb = 'DOLUSER_box_'.$this->boxcode.'_showinvoicenb'; + $param_showpropalnb = 'DOLUSER_box_'.$this->boxcode.'_showpropalnb'; + $param_showordernb = 'DOLUSER_box_'.$this->boxcode.'_showordernb'; $autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); - if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray)) { + if (in_array('DOLUSER_box_'.$this->boxcode, $autosetarray)) { $year = GETPOSTINT($param_year); $showinvoicenb = GETPOST($param_showinvoicenb, 'alpha'); $showpropalnb = GETPOST($param_showpropalnb, 'alpha'); $showordernb = GETPOST($param_showordernb, 'alpha'); } else { - $tmparray = (!empty($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode]) ? json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true) : array()); + $tmparray = (!empty($_COOKIE['DOLUSER_box_'.$this->boxcode]) ? json_decode($_COOKIE['DOLUSER_box_'.$this->boxcode], true) : array()); $year = (!empty($tmparray['year']) ? $tmparray['year'] : ''); $showinvoicenb = (!empty($tmparray['showinvoicenb']) ? $tmparray['showinvoicenb'] : ''); $showpropalnb = (!empty($tmparray['showpropalnb']) ? $tmparray['showpropalnb'] : ''); @@ -354,7 +354,7 @@ public function loadBox($max = 5) $stringtoshow .= ''; $stringtoshow .= ''; $stringtoshow .= ''; - $stringtoshow .= ''; + $stringtoshow .= ''; if (isModEnabled("propal") || $user->hasRight('propal', 'lire')) { $stringtoshow .= ' '.$langs->trans("ForProposals"); $stringtoshow .= ' '; @@ -368,7 +368,7 @@ public function loadBox($max = 5) } $stringtoshow .= '
'; $stringtoshow .= $langs->trans("Year").' '; - $stringtoshow .= ''; + $stringtoshow .= ''; $stringtoshow .= ''; $stringtoshow .= '
'; @@ -420,11 +420,13 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string * @return string */ diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index 52520e3cf14bc..bb9f0d14dbb32 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -99,19 +99,19 @@ public function loadBox($max = 5) } if ($user->hasRight('propal', 'lire')) { - $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; - $param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; - $param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; + $param_year = 'DOLUSER_box_'.$this->boxcode.'_year'; + $param_shownb = 'DOLUSER_box_'.$this->boxcode.'_shownb'; + $param_showtot = 'DOLUSER_box_'.$this->boxcode.'_showtot'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php'; $autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); - if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray)) { + if (in_array('DOLUSER_box_'.$this->boxcode, $autosetarray)) { $endyear = GETPOSTINT($param_year); $shownb = GETPOST($param_shownb, 'alpha'); $showtot = GETPOST($param_showtot, 'alpha'); } else { - $tmparray = (!empty($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode]) ? json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true) : array()); + $tmparray = (!empty($_COOKIE['DOLUSER_box_'.$this->boxcode]) ? json_decode($_COOKIE['DOLUSER_box_'.$this->boxcode], true) : array()); $endyear = (!empty($tmparray['year']) ? $tmparray['year'] : ''); $shownb = (!empty($tmparray['shownb']) ? $tmparray['shownb'] : ''); $showtot = (!empty($tmparray['showtot']) ? $tmparray['showtot'] : ''); @@ -229,13 +229,13 @@ public function loadBox($max = 5) $stringtoshow .= ''; $stringtoshow .= ''; $stringtoshow .= ''; - $stringtoshow .= ''; - $stringtoshow .= ' '.$langs->trans("NumberOfProposalsByMonth"); + $stringtoshow .= ''; + $stringtoshow .= ''; $stringtoshow .= '   '; - $stringtoshow .= ' '.$langs->trans("AmountOfProposalsByMonthHT"); + $stringtoshow .= ''; $stringtoshow .= '
'; $stringtoshow .= $langs->trans("Year").' '; - $stringtoshow .= ''; + $stringtoshow .= ''; $stringtoshow .= ''; $stringtoshow .= '
'; if ($shownb && $showtot) { @@ -277,11 +277,13 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string * @return string */ diff --git a/htdocs/core/boxes/box_graph_ticket_by_severity.php b/htdocs/core/boxes/box_graph_ticket_by_severity.php index e12fe6a6d6ef7..6dd7f3b6bff43 100644 --- a/htdocs/core/boxes/box_graph_ticket_by_severity.php +++ b/htdocs/core/boxes/box_graph_ticket_by_severity.php @@ -199,13 +199,15 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string - * @return string + * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) { diff --git a/htdocs/core/boxes/box_last_knowledgerecord.php b/htdocs/core/boxes/box_last_knowledgerecord.php index 88a12929e0efc..9f4d98999acda 100644 --- a/htdocs/core/boxes/box_last_knowledgerecord.php +++ b/htdocs/core/boxes/box_last_knowledgerecord.php @@ -183,13 +183,15 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string - * @return string + * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) { diff --git a/htdocs/core/boxes/box_last_modified_knowledgerecord.php b/htdocs/core/boxes/box_last_modified_knowledgerecord.php index ca121fc409c28..c41d141d5e8d8 100644 --- a/htdocs/core/boxes/box_last_modified_knowledgerecord.php +++ b/htdocs/core/boxes/box_last_modified_knowledgerecord.php @@ -183,13 +183,15 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string - * @return string + * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) { diff --git a/htdocs/core/boxes/box_last_modified_ticket.php b/htdocs/core/boxes/box_last_modified_ticket.php index abdc6653331f9..f5c5c6b49d333 100644 --- a/htdocs/core/boxes/box_last_modified_ticket.php +++ b/htdocs/core/boxes/box_last_modified_ticket.php @@ -190,13 +190,15 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string - * @return string + * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) { diff --git a/htdocs/core/boxes/box_last_ticket.php b/htdocs/core/boxes/box_last_ticket.php index 833af7f3cc129..8910aed5aa4cb 100644 --- a/htdocs/core/boxes/box_last_ticket.php +++ b/htdocs/core/boxes/box_last_ticket.php @@ -184,13 +184,15 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string - * @return string + * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) { diff --git a/htdocs/core/boxes/box_lastlogin.php b/htdocs/core/boxes/box_lastlogin.php index 6561ebfe6955e..6ec1d99c03216 100644 --- a/htdocs/core/boxes/box_lastlogin.php +++ b/htdocs/core/boxes/box_lastlogin.php @@ -95,13 +95,15 @@ public function loadBox($max = 5) } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string - * @return string + * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) { diff --git a/htdocs/core/boxes/box_members_by_tags.php b/htdocs/core/boxes/box_members_by_tags.php index 3209b71050544..07a9e9962ad8c 100644 --- a/htdocs/core/boxes/box_members_by_tags.php +++ b/htdocs/core/boxes/box_members_by_tags.php @@ -254,11 +254,13 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string * @return string */ diff --git a/htdocs/core/boxes/box_members_by_type.php b/htdocs/core/boxes/box_members_by_type.php index 812ad837abbb8..ebe15471a4b67 100644 --- a/htdocs/core/boxes/box_members_by_type.php +++ b/htdocs/core/boxes/box_members_by_type.php @@ -254,11 +254,13 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string * @return string */ diff --git a/htdocs/core/boxes/box_members_last_modified.php b/htdocs/core/boxes/box_members_last_modified.php index 3f3d74f6c1081..c4a3fc27e7d9a 100644 --- a/htdocs/core/boxes/box_members_last_modified.php +++ b/htdocs/core/boxes/box_members_last_modified.php @@ -180,11 +180,13 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string * @return string */ diff --git a/htdocs/core/boxes/box_members_last_subscriptions.php b/htdocs/core/boxes/box_members_last_subscriptions.php index c1d637ebada56..03c77b0500e78 100644 --- a/htdocs/core/boxes/box_members_last_subscriptions.php +++ b/htdocs/core/boxes/box_members_last_subscriptions.php @@ -179,11 +179,13 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string * @return string */ diff --git a/htdocs/core/boxes/box_members_subscriptions_by_year.php b/htdocs/core/boxes/box_members_subscriptions_by_year.php index 7b262f595ebc7..755e58a011854 100644 --- a/htdocs/core/boxes/box_members_subscriptions_by_year.php +++ b/htdocs/core/boxes/box_members_subscriptions_by_year.php @@ -219,11 +219,13 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string * @return string */ diff --git a/htdocs/core/boxes/box_mos.php b/htdocs/core/boxes/box_mos.php index 985f7c48e3d80..214c38ced17e6 100644 --- a/htdocs/core/boxes/box_mos.php +++ b/htdocs/core/boxes/box_mos.php @@ -169,11 +169,13 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string * @return string */ diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index 82299daf345a1..52a27b151cb55 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -233,13 +233,15 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string - * @return string + * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) { diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index 650040367e22f..da714ede7ab25 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -225,11 +225,13 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string * @return string */ diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index c2713dff76bee..e713b65499724 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -204,11 +204,13 @@ public function loadBox($max = 5) ); } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string * @return string */ diff --git a/htdocs/core/boxes/box_project_opportunities.php b/htdocs/core/boxes/box_project_opportunities.php index 53a30d2ae013b..43e35640e7ed2 100644 --- a/htdocs/core/boxes/box_project_opportunities.php +++ b/htdocs/core/boxes/box_project_opportunities.php @@ -189,11 +189,13 @@ public function loadBox($max = 5) ); } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string * @return string */ diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index 02fe9be891211..59daa109ef1b8 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -194,11 +194,13 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string * @return string */ diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php index 88c93c8670053..0052c28a3319f 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -176,11 +176,13 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string * @return string */ diff --git a/htdocs/core/boxes/box_scheduled_jobs.php b/htdocs/core/boxes/box_scheduled_jobs.php index 4e66eca08fc24..1b621155ee240 100644 --- a/htdocs/core/boxes/box_scheduled_jobs.php +++ b/htdocs/core/boxes/box_scheduled_jobs.php @@ -194,11 +194,13 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string * @return string */ diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index 25df9d0275a4d..ccdf6b9fce1b2 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -223,11 +223,13 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string * @return string */ diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index 46dec068b358c..f5c7ee6211a8f 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -179,13 +179,15 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string - * @return string + * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) { diff --git a/htdocs/core/boxes/box_shipments.php b/htdocs/core/boxes/box_shipments.php index 34d0e10a51866..9dbf5448c07cf 100644 --- a/htdocs/core/boxes/box_shipments.php +++ b/htdocs/core/boxes/box_shipments.php @@ -186,11 +186,13 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string * @return string */ diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index 3dbd7d852a6c6..168d5f6fc9b25 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -183,13 +183,15 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string - * @return string + * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) { diff --git a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php index a882814a5ca24..2b89a8ed4364d 100644 --- a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php +++ b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php @@ -182,13 +182,15 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string - * @return string + * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) { diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index d81278383d3d3..8fcfe21fb96b0 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -75,7 +75,7 @@ public function loadBox($max = 5) $projectstatic = new Project($this->db); $taskstatic = new Task($this->db); $form = new Form($this->db); - $cookie_name = 'DOLUSERCOOKIE_boxfilter_task'; + $cookie_name = 'DOLUSER_boxfilter_task'; $boxcontent = ''; $socid = $user->socid; @@ -200,11 +200,13 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string * @return string */ diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php index fc1df5741d00a..0bd6472805ae2 100644 --- a/htdocs/core/boxes/box_validated_projects.php +++ b/htdocs/core/boxes/box_validated_projects.php @@ -186,11 +186,13 @@ public function loadBox($max = 5) } } + + /** - * Method to show box + * Method to show box. Called when the box needs to be displayed. * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string * @return string */ diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index 6877e50419a35..d7d237d69616a 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -52,12 +52,12 @@ class ModeleBoxes // Can't be abstract as it is instantiated to build "empty" bo public $param; /** - * @var array box info heads. Example: array('text' => $langs->trans("BoxScheduledJobs", $max), 'nbcol' => 4); + * @var array,sublink?:string,subtext?:string,picto?:string,target?:string,td?:string}>|array{text:string,nbcol?:int,limit?:int,graph?:int<0,1>,sublink?:string,subtext?:string,picto?:string,target?:string,td?:string} box info heads. Example: array('text' => $langs->trans("BoxScheduledJobs", $max), 'nbcol' => 4); */ public $info_box_head = array(); /** - * @var array box info content + * @var array,maxlength?:int}>>|array,maxlength?:int}> box info content */ public $info_box_contents = array(); @@ -172,6 +172,22 @@ public function __construct($db, $param = '') $this->db = $db; } + + + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + // Must be implemented in derived classes + $msg = get_class($this)."::".__FUNCTION__." not implemented"; + dol_syslog($msg, LOG_ERR); + } + + /** * Return last error message * @@ -224,8 +240,8 @@ public function fetch($rowid) /** * Standard method to show a box (usage by boxes not mandatory, a box can still use its own showBox function) * - * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param ?array> $contents Array with properties of box lines + * @param ?array,target?:string}> $head Array with properties of box title + * @param ?array}> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string * @return string */ @@ -284,7 +300,7 @@ public function showBox($head = null, $contents = null, $nooutput = 0) //$out.= '"; } } @@ -596,7 +674,7 @@ function groupticketchange() { $events = array(); $events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); print img_picto('', 'company', 'class="paddingright"'); - print $form->select_company($this->withfromsocid, 'socid', '', 1, 1, '', $events, 0, 'minwidth200'); + print $form->select_company($this->withfromsocid, 'socid', '', 1, 1, 0, $events, 0, 'minwidth200'); print ''; if (!empty($conf->use_javascript_ajax) && getDolGlobalString('COMPANY_USE_SEARCH_TO_SELECT')) { $htmlname = 'socid'; @@ -726,6 +804,8 @@ function(response) { print dol_get_fiche_end(); } + print '
'; + if ($mode == 'create') { print $form->buttonsSaveCancel(((isset($this->withreadid) && $this->withreadid > 0) ? "SendResponse" : "CreateTicket"), ($this->withcancel ? "Cancel" : "")); } else { @@ -753,7 +833,7 @@ function(response) { /** * Return html list of tickets type * - * @param string|array $selected Id of preselected field or array of Ids + * @param string|int[] $selected Id of preselected field or array of Ids * @param string $htmlname Nom de la zone select * @param string $filtertype To filter on field type in llx_c_ticket_type (array('code'=>xx,'label'=>zz)) * @param int $format 0=id+libelle, 1=code+code, 2=code+libelle, 3=id+code @@ -1541,7 +1621,7 @@ public function showMessageForm($width = '40%') // Zone to select its email template if (count($modelmail_array) > 0) { print ''; // Type $out .= ''; + // Label $out .= ''; $out .= ''; $out .= ''; @@ -2193,7 +2202,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { $out .= getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'maxwidthsearch '); } - if ($donetodo) { + if ($donetodo && $filterobj !== null) { $tmp = ''; if (get_class($filterobj) == 'Societe') { $tmp .= ''; @@ -2517,9 +2526,14 @@ function show_subsidiaries($conf, $langs, $db, $object) */ function addEventTypeSQL(&$sql, $actioncode, $sqlANDOR = "AND") { - global $conf, $db; + global $db; + // Condition on actioncode + if ((string) $actioncode == '-1') { + return $sql; + } + if (!getDolGlobalString('AGENDA_USE_EVENT_TYPE')) { if ($actioncode == 'AC_NON_AUTO') { $sql .= " $sqlANDOR c.type <> 'systemauto'"; diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index a8bdff59b9797..541cd56bd413a 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -31,23 +31,23 @@ /** * Return an array with timezone values * - * @return array Array with timezone values + * @return array,string> Array with timezone values */ function get_tz_array() { $tzarray = array( - -11 => "Pacific/Midway", - -10 => "Pacific/Fakaofo", + -11 => "Pacific/Pago_Pago", + -10 => "Pacific/Honolulu", -9 => "America/Anchorage", -8 => "America/Los_Angeles", -7 => "America/Dawson_Creek", -6 => "America/Chicago", -5 => "America/Bogota", - -4 => "America/Anguilla", + -4 => "America/Asuncion", -3 => "America/Araguaina", -2 => "America/Noronha", -1 => "Atlantic/Azores", - 0 => "Africa/Abidjan", + 0 => "Europe/London", 1 => "Europe/Paris", 2 => "Europe/Helsinki", 3 => "Europe/Moscow", @@ -60,7 +60,8 @@ function get_tz_array() 10 => "Australia/Sydney", 11 => "Pacific/Noumea", 12 => "Pacific/Auckland", - 13 => "Pacific/Enderbury" + 13 => "Pacific/Fakaofo", + 14 => "Pacific/Kiritimati" ); return $tzarray; } @@ -478,7 +479,7 @@ function dol_stringtotime($string, $gm = 1) * @param int $day Day * @param int $month Month * @param int $year Year - * @return array Previous year,month,day + * @return array{year:int,month:int,day:int} Previous year,month,day */ function dol_get_prev_day($day, $month, $year) { @@ -494,7 +495,7 @@ function dol_get_prev_day($day, $month, $year) * @param int $day Day * @param int $month Month * @param int $year Year - * @return array Next year,month,day + * @return array{year:int,month:int,day:int} Next year,month,day */ function dol_get_next_day($day, $month, $year) { @@ -509,7 +510,7 @@ function dol_get_next_day($day, $month, $year) * * @param int $month Month * @param int $year Year - * @return array Previous year,month + * @return array{year:int,month:int} Previous year,month */ function dol_get_prev_month($month, $year) { @@ -528,7 +529,7 @@ function dol_get_prev_month($month, $year) * * @param int $month Month * @param int $year Year - * @return array Next year,month + * @return array{year:int,month:int} Next year,month */ function dol_get_next_month($month, $year) { @@ -549,7 +550,7 @@ function dol_get_next_month($month, $year) * @param int $week Week * @param int $month Month * @param int $year Year - * @return array Previous year,month,day + * @return array{year:int,month:int,day:int} Previous year,month,day */ function dol_get_prev_week($day, $week, $month, $year) { @@ -568,7 +569,7 @@ function dol_get_prev_week($day, $week, $month, $year) * @param int $week Week * @param int $month Month * @param int $year Year - * @return array Next year,month,day + * @return array{year:int,month:int,day:int} Next year,month,day */ function dol_get_next_week($day, $week, $month, $year) { @@ -663,9 +664,9 @@ function dol_get_first_hour($date, $gm = 'tzserver') * @param int $day Day * @param int $month Month * @param int $year Year - * @param bool|int|string $gm False or 0 or 'tzserver' = Return date to compare with server TZ, - * True or 1 or 'gmt' to compare with GMT date. - * @return array year,month,week,first_day,first_month,first_year,prev_day,prev_month,prev_year + * @param bool|int|'tzserver' $gm False or 0 or 'tzserver' = Return date to compare with server TZ, + * True or 1 or 'gmt' to compare with GMT date. + * @return array{year:int,month:int,week:string,first_day:int,first_month:int,first_year:int,prev_year:int,prev_month:int,prev_day:int} */ function dol_get_first_day_week($day, $month, $year, $gm = false) { diff --git a/htdocs/core/lib/fichinter.lib.php b/htdocs/core/lib/fichinter.lib.php index 99e354a332ee0..64b91da020677 100644 --- a/htdocs/core/lib/fichinter.lib.php +++ b/htdocs/core/lib/fichinter.lib.php @@ -31,7 +31,7 @@ /** * Prepare array with list of tabs * - * @param Object $object Object related to tabs + * @param CommonObject $object Object related to tabs * @return array Array of tabs to show */ function fichinter_prepare_head($object) @@ -165,7 +165,7 @@ function fichinter_prepare_head($object) /** * Return array head with list of tabs to view object information. * - * @return array head array with tabs + * @return array head array with tabs */ function fichinter_admin_prepare_head() { diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 7a4084b34e5ea..313e2975ac3fa 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -930,6 +930,7 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayrep // Recursive function to copy all subdirectories and contents: if (is_dir($ossrcfile)) { $dir_handle = opendir($ossrcfile); + $tmpresult = 0; // Initialised before loop to keep old behavior, may be needed inside loop while ($file = readdir($dir_handle)) { if ($file != "." && $file != ".." && !is_link($ossrcfile."/".$file)) { if (is_dir($ossrcfile."/".$file)) { @@ -998,19 +999,19 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayrep * - Database indexes for files are updated. * - Test on virus is done only if param testvirus is provided and an antivirus was set. * - * @param string $srcfile Source file (can't be a directory. use native php @rename() to move a directory) - * @param string $destfile Destination file (can't be a directory. use native php @rename() to move a directory) - * @param string $newmask Mask in octal string for new file ('0' by default means $conf->global->MAIN_UMASK) - * @param int $overwriteifexists Overwrite file if exists (1 by default) - * @param int $testvirus Do an antivirus test. Move is canceled if a virus is found. - * @param int $indexdatabase Index new file into database. - * @param array $moreinfo Array with more information to set in index table + * @param string $srcfile Source file (can't be a directory. use native php @rename() to move a directory) + * @param string $destfile Destination file (can't be a directory. use native php @rename() to move a directory) + * @param string $newmask Mask in octal string for new file ('0' by default means $conf->global->MAIN_UMASK) + * @param int<0,1> $overwriteifexists Overwrite file if exists (1 by default) + * @param int<0,1> $testvirus Do an antivirus test. Move is canceled if a virus is found. + * @param int<0,1> $indexdatabase Index new file into database. + * @param array $moreinfo Array with more information to set in index table * @return boolean True if OK, false if KO * @see dol_move_uploaded_file() */ function dol_move($srcfile, $destfile, $newmask = '0', $overwriteifexists = 1, $testvirus = 0, $indexdatabase = 1, $moreinfo = array()) { - global $user, $db, $conf; + global $user, $db; $result = false; dol_syslog("files.lib.php::dol_move srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwritifexists=".$overwriteifexists); @@ -1136,6 +1137,12 @@ function dol_move($srcfile, $destfile, $newmask = '0', $overwriteifexists = 1, $ if (!empty($moreinfo) && !empty($moreinfo['src_object_id'])) { $ecmfile->src_object_id = $moreinfo['src_object_id']; } + if (!empty($moreinfo) && !empty($moreinfo['position'])) { + $ecmfile->position = $moreinfo['position']; + } + if (!empty($moreinfo) && !empty($moreinfo['cover'])) { + $ecmfile->cover = $moreinfo['cover']; + } $resultecm = $ecmfile->create($user); if ($resultecm < 0) { @@ -1518,7 +1525,8 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, $ok = true; $globencoded = str_replace('[', '\[', $file_osencoded); $globencoded = str_replace(']', '\]', $globencoded); - $listofdir = glob($globencoded); + $listofdir = glob($globencoded); // This scan dir for files. If file does not exists, return empty. + if (!empty($listofdir) && is_array($listofdir)) { foreach ($listofdir as $filename) { if ($nophperrors) { @@ -1795,9 +1803,12 @@ function dol_meta_create($object) dol_mkdir($dir); } + $meta = ''; if (is_dir($dir)) { if (is_countable($object->lines) && count($object->lines) > 0) { $nblines = count($object->lines); + } else { + $nblines = 0; } $client = $object->thirdparty->name." ".$object->thirdparty->address." ".$object->thirdparty->zip." ".$object->thirdparty->town; $meta = "REFERENCE=\"".$object->ref."\" @@ -1867,15 +1878,15 @@ function dol_init_file_process($pathtoscan = '', $trackid = '') * All information used are in db, conf, langs, user and _FILES. * Note: This function can be used only into a HTML page context. * - * @param string $upload_dir Directory where to store uploaded file (note: used to forge $destpath = $upload_dir + filename) - * @param int $allowoverwrite 1=Allow overwrite existing file - * @param int $updatesessionordb 1=Do no edit _SESSION variable but update database index. 0=Update _SESSION and not database index. -1=Do not update SESSION neither db. - * @param string $varfiles _FILES var name - * @param string $savingdocmask Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__' - * @param string $link Link to add (to add a link instead of a file) - * @param string $trackid Track id (used to prefix name of session vars to avoid conflict) - * @param int $generatethumbs 1=Generate also thumbs for uploaded image files - * @param Object $object Object used to set 'src_object_*' fields + * @param string $upload_dir Directory where to store uploaded file (note: used to forge $destpath = $upload_dir + filename) + * @param int<0,1> $allowoverwrite 1=Allow overwrite existing file + * @param int<-1,1> $updatesessionordb 1=Do no edit _SESSION variable but update database index. 0=Update _SESSION and not database index. -1=Do not update SESSION neither db. + * @param string $varfiles _FILES var name + * @param string $savingdocmask Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__' + * @param ?string $link Link to add (to add a link instead of a file) + * @param string $trackid Track id (used to prefix name of session vars to avoid conflict) + * @param int<0,1> $generatethumbs 1=Generate also thumbs for uploaded image files + * @param ?Object $object Object used to set 'src_object_*' fields * @return int Return integer <=0 if KO, >0 if OK * @see dol_remove_file_process() */ @@ -2351,6 +2362,7 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz", &$errorstring dol_syslog("dol_compress_file mode=".$mode." inputfile=".$inputfile." outputfile=".$outputfile); $data = implode("", file(dol_osencode($inputfile))); + $compressdata = null; if ($mode == 'gz' && function_exists('gzencode')) { $foundhandler = 1; $compressdata = gzencode($data, 9); @@ -2385,6 +2397,7 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz", &$errorstring new RecursiveDirectoryIterator($rootPath, FilesystemIterator::UNIX_PATHS), RecursiveIteratorIterator::LEAVES_ONLY ); + '@phan-var-force SplFileInfo[] $files'; foreach ($files as $name => $file) { // Skip directories (they would be added automatically) @@ -2437,7 +2450,7 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz", &$errorstring } } - if ($foundhandler) { + if ($foundhandler && is_string($compressdata)) { $fp = fopen($outputfile, "w"); fwrite($fp, $compressdata); fclose($fp); @@ -2466,7 +2479,7 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz", &$errorstring * * @param string $inputfile File to uncompress * @param string $outputdir Target dir name - * @return array array('error'=>'Error code') or array() if no error + * @return array{error?:string} array('error'=>'Error code') or array() if no error * @see dol_compress_file(), dol_compress_dir() */ function dol_uncompress($inputfile, $outputdir) @@ -2601,7 +2614,7 @@ function dol_uncompress($inputfile, $outputdir) * @param string $mode 'zip' * @param string $excludefiles A regex pattern to exclude files. For example: '/\.log$|\/temp\//' * @param string $rootdirinzip Add a root dir level in zip file - * @param string $newmask Mask for new file (0 by default means $conf->global->MAIN_UMASK). Example: '0666' + * @param string $newmask Mask for new file ('0' by default means getDolGlobalString('MAIN_UMASK')). Example: '0666' * @return int Return integer <0 if KO, >0 if OK * @see dol_uncompress(), dol_compress_file() */ @@ -2657,6 +2670,7 @@ function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles = new RecursiveDirectoryIterator($inputdir, FilesystemIterator::UNIX_PATHS), RecursiveIteratorIterator::LEAVES_ONLY ); + '@phan-var-force SplFileInfo[] $files'; //var_dump($inputdir); foreach ($files as $name => $file) { @@ -2909,19 +2923,19 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed = 1; } $original_file = $conf->contract->multidir_output[$entity].'/'.$original_file; - } elseif (($modulepart == 'apercusupplier_proposal' || $modulepart == 'apercusupplier_proposal') && !empty($conf->supplier_proposal->dir_output)) { + } elseif (($modulepart == 'apercusupplier_proposal') && !empty($conf->supplier_proposal->dir_output)) { // Wrapping pour les apercu supplier proposal if ($fuser->hasRight('supplier_proposal', $lire)) { $accessallowed = 1; } $original_file = $conf->supplier_proposal->dir_output.'/'.$original_file; - } elseif (($modulepart == 'apercusupplier_order' || $modulepart == 'apercusupplier_order') && !empty($conf->fournisseur->commande->dir_output)) { + } elseif (($modulepart == 'apercusupplier_order') && !empty($conf->fournisseur->commande->dir_output)) { // Wrapping pour les apercu supplier order if ($fuser->hasRight('fournisseur', 'commande', $lire)) { $accessallowed = 1; } $original_file = $conf->fournisseur->commande->dir_output.'/'.$original_file; - } elseif (($modulepart == 'apercusupplier_invoice' || $modulepart == 'apercusupplier_invoice') && !empty($conf->fournisseur->facture->dir_output)) { + } elseif (($modulepart == 'apercusupplier_invoice') && !empty($conf->fournisseur->facture->dir_output)) { // Wrapping pour les apercu supplier invoice if ($fuser->hasRight('fournisseur', $lire)) { $accessallowed = 1; @@ -3246,7 +3260,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $original_file = $conf->fournisseur->payment->dir_output.'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."paiementfournisseur WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; } elseif ($modulepart == 'payment') { - // Wrapping pour les rapport de paiements + // Wrapping pour les rapport de paiements if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } @@ -3584,12 +3598,12 @@ function dirbasename($pathfile) * Function to get list of updated or modified files. * $file_list is used as global variable * - * @param array $file_list Array for response + * @param array{insignature:string[],missing?:array,updated:array} $file_list Array for response * @param SimpleXMLElement $dir SimpleXMLElement of files to test - * @param string $path Path of files relative to $pathref. We start with ''. Used by recursive calls. - * @param string $pathref Path ref (DOL_DOCUMENT_ROOT) - * @param array $checksumconcat Array of checksum - * @return array Array of filenames + * @param string $path Path of files relative to $pathref. We start with ''. Used by recursive calls. + * @param string $pathref Path ref (DOL_DOCUMENT_ROOT) + * @param string[] $checksumconcat Array of checksum + * @return array{insignature:string[],missing?:array,updated:array} $file_list Array of filenames */ function getFilesUpdated(&$file_list, SimpleXMLElement $dir, $path = '', $pathref = '', &$checksumconcat = array()) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a8377a1870d5e..a63b8a86c1c2f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -281,7 +281,7 @@ function getDolUserInt($key, $default = 0, $tmpuser = null) $tmpuser = $user; } - return (int) (isset($tmpuser->conf->$key) ? $tmpuser->conf->$key: $default); + return (int) (isset($tmpuser->conf->$key) ? $tmpuser->conf->$key : $default); } @@ -1102,7 +1102,7 @@ function GETPOSTINT($paramname, $method = 0) * Return the value of a $_GET or $_POST supervariable, converted into float. * * @param string $paramname Name of the $_GET or $_POST parameter - * @param string|int $rounding Type of rounding ('', 'MU', 'MT, 'MS', 'CU', 'CT', integer) {@see price2num()} + * @param ''|'MU'|'MT'|'MS'|'CU'|'CT'|int $rounding Type of rounding ('', 'MU', 'MT, 'MS', 'CU', 'CT', integer) {@see price2num()} * @return float Value converted into float * @since Dolibarr V20 */ @@ -1384,7 +1384,10 @@ function dol_include_once($relpath, $classname = '') * Return path of url or filesystem. Can check into alternate dir or alternate dir + main dir depending on value of $returnemptyifnotfound. * * @param string $path Relative path to file (if mode=0) or relative url (if mode=1). Ie: mydir/myfile, ../myfile - * @param int $type 0=Used for a Filesystem path, 1=Used for an URL path (output relative), 2=Used for an URL path (output full path using same host that current url), 3=Used for an URL path (output full path using host defined into $dolibarr_main_url_root of conf file) + * @param int $type 0=Used for a Filesystem path, + * 1=Used for an URL path (output relative), + * 2=Used for an URL path (output full path using same host that current url), + * 3=Used for an URL path (output full path using host defined into $dolibarr_main_url_root of conf file) * @param int $returnemptyifnotfound 0:If $type==0 and if file was not found into alternate dir, return default path into main dir (no test on it) * 1:If $type==0 and if file was not found into alternate dir, return empty string * 2:If $type==0 and if file was not found into alternate dir, test into main dir, return default path if found, empty string if not found @@ -1455,11 +1458,9 @@ function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0) if (@file_exists($dirroot.'/'.$regs[1])) { // avoid [php:warn] if ($type == 1) { $res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : DOL_URL_ROOT).$conf->file->dol_url_root[$key].'/'.$path; - } - if ($type == 2) { + } elseif ($type == 2) { $res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : DOL_MAIN_URL_ROOT).$conf->file->dol_url_root[$key].'/'.$path; - } - if ($type == 3) { + } elseif ($type == 3) { /*global $dolibarr_main_url_root;*/ // Define $urlwithroot @@ -2234,7 +2235,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = } if (!empty($message)) { - // Test log level @phan-ignore-next-line PhanPluginDuplicateArrayKey + // Test log level @phan-suppress-next-line PhanPluginDuplicateArrayKey $logLevels = array(LOG_EMERG => 'EMERG', LOG_ALERT => 'ALERT', LOG_CRIT => 'CRITICAL', LOG_ERR => 'ERR', LOG_WARNING => 'WARN', LOG_NOTICE => 'NOTICE',LOG_INFO => 'INFO', LOG_DEBUG => 'DEBUG'); if (!array_key_exists($level, $logLevels)) { throw new Exception('Incorrect log level'); @@ -2596,7 +2597,7 @@ function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab // Show tabs // if =0 we don't use the feature if (empty($limittoshow)) { - $limittoshow = (!getDolGlobalString('MAIN_MAXTABS_IN_CARD') ? 99 : $conf->global->MAIN_MAXTABS_IN_CARD); + $limittoshow = getDolGlobalInt('MAIN_MAXTABS_IN_CARD', 99); } if (!empty($conf->dol_optimize_smallscreen)) { $limittoshow = 2; @@ -2641,7 +2642,7 @@ function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab $out .= ''; } - if ($displaytab == 0) { + if ($displaytab == 0 && $picto) { $out .= img_picto($title, $picto, '', $pictoisfullpath, 0, 0, '', 'imgTabTitle paddingright marginrightonlyshort'); } @@ -3162,23 +3163,6 @@ function fieldLabel($langkey, $fieldkey, $fieldrequired = 0) return $ret; } -/** - * Return string to add class property on html element with pair/impair. - * - * @param boolean $var false or true - * @param string $moreclass More class to add - * @return string String to add class onto HTML element - */ -function dol_bc($var, $moreclass = '') -{ - global $bc; - $ret = ' '.$bc[$var]; - if ($moreclass) { - $ret = preg_replace('/class=\"/', 'class="'.$moreclass.' ', $ret); - } - return $ret; -} - /** * Return a formatted address (part address/zip/town/state) according to country rules. * See https://en.wikipedia.org/wiki/Address @@ -4536,7 +4520,7 @@ function dolGetCountryCodeFromIp($ip) $countrycode = ''; - if (!empty($conf->geoipmaxmind->enabled)) { + if (isModEnabled('geoipmaxmind')) { $datafile = getDolGlobalString('GEOIPMAXMIND_COUNTRY_DATAFILE'); //$ip='24.24.24.24'; //$datafile='/usr/share/GeoIP/GeoIP.dat'; Note that this must be downloaded datafile (not same than datafile provided with ubuntu packages) @@ -4562,7 +4546,7 @@ function dol_user_country() //$ret=$user->xxx; $ret = ''; - if (!empty($conf->geoipmaxmind->enabled)) { + if (isModEnabled('geoipmaxmind')) { $ip = getUserRemoteIP(); $datafile = getDolGlobalString('GEOIPMAXMIND_COUNTRY_DATAFILE'); //$ip='24.24.24.24'; @@ -4841,8 +4825,8 @@ function dol_trunc($string, $size = 40, $trunc = 'right', $stringencoding = 'UTF } elseif ($trunc == 'middle') { $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string; if (dol_strlen($newstring, $stringencoding) > 2 && dol_strlen($newstring, $stringencoding) > ($size + 1)) { - $size1 = round($size / 2); - $size2 = round($size / 2); + $size1 = (int) round($size / 2); + $size2 = (int) round($size / 2); return dol_substr($newstring, 0, $size1, $stringencoding).'…'.dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding); } else { return $string; @@ -4895,6 +4879,7 @@ function getPictoForType($key, $morecss = '') 'ip' => 'country', 'select' => 'list', 'sellist' => 'list', + 'stars' => 'fontawesome_star_fas', 'radio' => 'check-circle', 'checkbox' => 'list', 'chkbxlst' => 'list', @@ -5026,7 +5011,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = 0, $srco if (empty($srconly) && in_array($pictowithouttext, array( '1downarrow', '1uparrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected', 'accountancy', 'accounting_account', 'account', 'accountline', 'action', 'add', 'address', 'ai', 'angle-double-down', 'angle-double-up', 'asset', - 'bank_account', 'barcode', 'bank', 'bell', 'bill', 'billa', 'billr', 'billd', 'birthday-cake', 'bom', 'bookcal', 'bookmark', 'briefcase-medical', 'bug', 'building', + 'back', 'bank_account', 'barcode', 'bank', 'bell', 'bill', 'billa', 'billr', 'billd', 'birthday-cake', 'bom', 'bookcal', 'bookmark', 'briefcase-medical', 'bug', 'building', 'card', 'calendarlist', 'calendar', 'calendarmonth', 'calendarweek', 'calendarday', 'calendarperuser', 'calendarpertype', 'cash-register', 'category', 'chart', 'check', 'clock', 'clone', 'close_title', 'code', 'cog', 'collab', 'company', 'contact', 'country', 'contract', 'conversation', 'cron', 'cross', 'cubes', 'check-circle', 'check-square', 'circle', 'stop-circle', 'currency', 'multicurrency', @@ -5045,7 +5030,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = 0, $srco 'off', 'on', 'order', 'paiment', 'paragraph', 'play', 'pdf', 'phone', 'phoning', 'phoning_mobile', 'phoning_fax', 'playdisabled', 'previous', 'poll', 'pos', 'printer', 'product', 'propal', 'proposal', 'puce', 'stock', 'resize', 'service', 'stats', - 'security', 'setup', 'share-alt', 'sign-out', 'split', 'stripe', 'stripe-s', 'switch_off', 'switch_on', 'switch_on_warning', 'switch_on_red', 'tools', 'unlink', 'uparrow', 'user', 'user-tie', 'vcard', 'wrench', + 'security', 'setup', 'share-alt', 'sign-out', 'split', 'stripe', 'stripe-s', 'switch_off', 'switch_on', 'switch_on_grey', 'switch_on_warning', 'switch_on_red', 'tools', 'unlink', 'uparrow', 'user', 'user-tie', 'vcard', 'wrench', 'github', 'google', 'jabber', 'microsoft', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp', 'generic', 'home', 'hrm', 'members', 'products', 'invoicing', 'partnership', 'payment', 'payment_vat', 'pencil-ruler', 'pictoconfirm', 'preview', 'project', 'projectpub', 'projecttask', 'question', 'refresh', 'region', @@ -5055,7 +5040,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = 0, $srco 'recent', 'reception', 'recruitmentcandidature', 'recruitmentjobposition', 'replacement', 'resource', 'recurring','rss', 'shapes', 'skill', 'square', 'sort-numeric-down', 'status', 'stop-circle', 'supplier', 'supplier_proposal', 'supplier_order', 'supplier_invoice', 'terminal', 'tick', 'timespent', 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda', 'trip', - 'uncheck', 'url', 'user-cog', 'user-injured', 'user-md', 'vat', 'website', 'workstation', 'webhook', 'world', 'private', + 'uncheck', 'undo', 'url', 'user-cog', 'user-injured', 'user-md', 'vat', 'website', 'workstation', 'webhook', 'world', 'private', 'conferenceorbooth', 'eventorganization', 'stamp', 'signature', 'webportal' @@ -5074,7 +5059,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = 0, $srco $arrayconvpictotofa = array( 'account' => 'university', 'accounting_account' => 'clipboard-list', 'accountline' => 'receipt', 'accountancy' => 'search-dollar', 'action' => 'calendar-alt', 'add' => 'plus-circle', 'address' => 'address-book', 'ai' => 'magic', 'asset' => 'money-check-alt', 'autofill' => 'fill', - 'bank_account' => 'university', + 'back' => 'arrow-left', 'bank_account' => 'university', 'bill' => 'file-invoice-dollar', 'billa' => 'file-excel', 'billr' => 'file-invoice-dollar', 'billd' => 'file-medical', 'bookcal' => 'calendar-check', 'supplier_invoice' => 'file-invoice-dollar', 'supplier_invoicea' => 'file-excel', 'supplier_invoicer' => 'file-invoice-dollar', 'supplier_invoiced' => 'file-medical', @@ -5094,7 +5079,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = 0, $srco 'member' => 'user-alt', 'meeting' => 'chalkboard-teacher', 'mrp' => 'cubes', 'next' => 'arrow-alt-circle-right', 'trip' => 'wallet', 'expensereport' => 'wallet', 'group' => 'users', 'movement' => 'people-carry', 'sign-out' => 'sign-out-alt', - 'switch_off' => 'toggle-off', 'switch_on' => 'toggle-on', 'switch_on_warning' => 'toggle-on', 'switch_on_red' => 'toggle-on', 'check' => 'check', 'bookmark' => 'star', + 'switch_off' => 'toggle-off', 'switch_on' => 'toggle-on', 'switch_on_grey' => 'toggle-on', 'switch_on_warning' => 'toggle-on', 'switch_on_red' => 'toggle-on', 'check' => 'check', 'bookmark' => 'star', 'bank' => 'university', 'close_title' => 'times', 'delete' => 'trash', 'filter' => 'filter', 'list-alt' => 'list-alt', 'calendarlist' => 'bars', 'calendar' => 'calendar-alt', 'calendarmonth' => 'calendar-alt', 'calendarweek' => 'calendar-week', 'calendarday' => 'calendar-day', 'calendarperuser' => 'table', 'intervention' => 'ambulance', 'invoice' => 'file-invoice-dollar', 'order' => 'file-invoice', @@ -5165,7 +5150,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = 0, $srco // Define $marginleftonlyshort $arrayconvpictotomarginleftonly = array( 'bank', 'check', 'delete', 'generic', 'grip', 'grip_title', 'jabber', - 'grip_title', 'grip', 'listlight', 'note', 'on', 'off', 'playdisabled', 'printer', 'resize', 'sign-out', 'stats', 'switch_on', 'switch_on_red', 'switch_off', + 'grip_title', 'grip', 'listlight', 'note', 'on', 'off', 'playdisabled', 'printer', 'resize', 'sign-out', 'stats', 'switch_on', 'switch_on_grey', 'switch_on_red', 'switch_off', 'uparrow', '1uparrow', '1downarrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected' ); if (!array_key_exists($pictowithouttext, $arrayconvpictotomarginleftonly)) { @@ -6332,7 +6317,7 @@ function load_fiche_titre($title, $morehtmlright = '', $picto = 'generic', $pict } $return .= "\n"; - $return .= '
'; $out .= '
'; } - if (!empty($head['text'])) { + if (!empty($head['text']) && !is_array($head['text'])) { $s = dol_trunc($head['text'], isset($head['limit']) ? $head['limit'] : $MAXLENGTHBOX); $out .= $s; } @@ -298,7 +314,7 @@ public function showBox($head = null, $contents = null, $nooutput = 0) if (!empty($head['sublink'])) { $sublink .= ''; } - if (!empty($head['subpicto'])) { + if (!empty($head['subpicto']) && !is_array($head['subtext']) && !is_array($head['subpicto'])) { $sublink .= img_picto($head['subtext'], $head['subpicto'], 'class="opacitymedium marginleftonly '.(empty($head['subclass']) ? '' : $head['subclass']).'" id="idsubimg'.$this->boxcode.'"'); } if (!empty($head['sublink'])) { diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 2cfe7727c58a3..fbba4e094c63c 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -1113,14 +1113,18 @@ public function sendfile() $keyforsupportedoauth2array = 'OAUTH_'.$keyforsupportedoauth2array.'_NAME'; if (!empty($supportedoauth2array)) { - $OAUTH_SERVICENAME = (empty($supportedoauth2array[$keyforsupportedoauth2array]['name']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['name'].($keyforprovider ? '-'.$keyforprovider : '')); + $nameofservice = ucfirst(strtolower(empty($supportedoauth2array[$keyforsupportedoauth2array]['callbackfile']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['callbackfile'])); + $nameofservice .= ($keyforprovider ? '-'.$keyforprovider : ''); + $OAUTH_SERVICENAME = $nameofservice; } else { $OAUTH_SERVICENAME = 'Unknown'; } + $keyforparamtenant = 'OAUTH_'.strtoupper(empty($supportedoauth2array[$keyforsupportedoauth2array]['callbackfile']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['callbackfile']).($keyforprovider ? '-'.$keyforprovider : '').'_TENANT'; + require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php'; - $storage = new DoliStorage($db, $conf, $keyforprovider); + $storage = new DoliStorage($db, $conf, $keyforprovider, getDolGlobalString($keyforparamtenant)); try { $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME); @@ -1255,10 +1259,10 @@ public function sendfile() $this->transport = new Swift_SmtpTransport($server, getDolGlobalInt($keyforsmtpport), $secure); if (getDolGlobalString($keyforsmtpid)) { - $this->transport->setUsername($conf->global->$keyforsmtpid); + $this->transport->setUsername(getDolGlobalString($keyforsmtpid)); } if (getDolGlobalString($keyforsmtppw) && getDolGlobalString($keyforsmtpauthtype) != "XOAUTH2") { - $this->transport->setPassword($conf->global->$keyforsmtppw); + $this->transport->setPassword(getDolGlobalString($keyforsmtppw)); } if (getDolGlobalString($keyforsmtpauthtype) === "XOAUTH2") { require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; @@ -1274,16 +1278,19 @@ public function sendfile() $keyforsupportedoauth2array = preg_replace('/-.*$/', '', $keyforsupportedoauth2array); $keyforsupportedoauth2array = 'OAUTH_'.$keyforsupportedoauth2array.'_NAME'; - $OAUTH_SERVICENAME = 'Unknown'; - if (array_key_exists($keyforsupportedoauth2array, $supportedoauth2array) - && array_key_exists('name', $supportedoauth2array[$keyforsupportedoauth2array]) - && !empty($supportedoauth2array[$keyforsupportedoauth2array]['name'])) { - $OAUTH_SERVICENAME = $supportedoauth2array[$keyforsupportedoauth2array]['name'].(!empty($keyforprovider) ? '-'.$keyforprovider : ''); + if (!empty($supportedoauth2array)) { + $nameofservice = ucfirst(strtolower(empty($supportedoauth2array[$keyforsupportedoauth2array]['callbackfile']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['callbackfile'])); + $nameofservice .= ($keyforprovider ? '-'.$keyforprovider : ''); + $OAUTH_SERVICENAME = $nameofservice; + } else { + $OAUTH_SERVICENAME = 'Unknown'; } + $keyforparamtenant = 'OAUTH_'.strtoupper(empty($supportedoauth2array[$keyforsupportedoauth2array]['callbackfile']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['callbackfile']).($keyforprovider ? '-'.$keyforprovider : '').'_TENANT'; + require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php'; - $storage = new DoliStorage($db, $conf, $keyforprovider); + $storage = new DoliStorage($db, $conf, $keyforprovider, getDolGlobalString($keyforparamtenant)); try { $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME); @@ -1377,7 +1384,7 @@ public function sendfile() $this->error = 'Transport failed for the following addresses: "' . implode('", "', $failedRecipients) . '".'; $this->errors[] = $this->error; } - dol_syslog("CMailFile::sendfile: mail end error=". join(' ', $this->errors), LOG_ERR); + dol_syslog("CMailFile::sendfile: mail end error=". implode(' ', $this->errors), LOG_ERR); $res = false; if (getDolGlobalString('MAIN_MAIL_DEBUG')) { diff --git a/htdocs/core/class/CSMSFile.class.php b/htdocs/core/class/CSMSFile.class.php index 7fe6fb1451314..cf03bf06c78a0 100644 --- a/htdocs/core/class/CSMSFile.class.php +++ b/htdocs/core/class/CSMSFile.class.php @@ -65,21 +65,48 @@ class CSMSFile * @var string address to */ public $addr_to; + /** + * @var int + */ public $deferred; + /** + * @var int + */ public $priority; + /** + * @var int + */ public $class; + /** + * @var string + */ public $message; /** * @var bool */ public $nostop; + /** + * @var int + */ public $socid; + /** + * @var int + */ public $contact_id; + /** + * @var int + */ public $member_id; + /** + * @var int + */ public $fk_project; + /** + * @var int + */ public $deliveryreceipt; @@ -169,6 +196,7 @@ public function sendfile() if (class_exists($classname)) { $sms = new $classname($this->db); + '@phan-var-force OvhSms $sms'; // Using original for analysis $sms->expe = $this->addr_from; $sms->dest = $this->addr_to; diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 372e721acda81..9c49e9071b795 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2011 Laurent Destailleur + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -43,14 +44,35 @@ class Canvas */ public $errors = array(); + /** + * @var string + */ public $actiontype; + /** + * @var string Module directory + */ public $dirmodule; // Module directory + /** + * @var string + */ public $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) + /** + * @var string + */ public $canvas; // Name of canvas (ex: company, individual, product, service, ...) + /** + * @var string + */ public $card; // Tab (sub-canvas) - public $template_dir; // Initialized by getCanvas with templates directory + /** + * @var string Initialized by getCanvas with templates directory + */ + public $template_dir; + /** + * @var ActionsContactCardCommon|ActionsAdherentCardCommon|ActionsCardProduct|ActionsCardService|ActionsCardCommon + */ public $control; // Initialized by getCanvas with controller instance diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 6165890eccd40..e0d01f4005140 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -9,6 +9,7 @@ * Copyright (C) 2020 Josep Lluís Amador * Copyright (C) 2024 MDW * Copyright (C) 2024 Mélina Joum + * Copyright (C) 2024 Nick Fragoulis * * 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 @@ -92,13 +93,45 @@ abstract class CommonDocGenerator */ public $type; + /** + * @var float page height + */ public $page_hauteur; + + /** + * @var float page wicth + */ public $page_largeur; + + /** + * @var float left margin + */ public $marge_gauche; + + /** + * @var float right margin + */ public $marge_droite; + + /** + * @var float top margin + */ public $marge_haute; + + /** + * @var float bottom margin + */ public $marge_basse; + /** + * @var int corner radius + */ + public $corner_radius; + + /** + * @var int<0,1> option logo + */ + public $option_logo; public $option_tva; public $option_multilang; @@ -362,6 +395,10 @@ public function get_substitutionarray_thirdparty($object, $outputlangs, $array_k // phpcs:enable global $extrafields; + if (!is_object($object)) { + return array(); + } + if (empty($object->country) && !empty($object->country_code)) { $object->country = $outputlangs->transnoentitiesnoconv("Country".$object->country_code); } @@ -884,7 +921,7 @@ public function get_substitutionarray_shipment($object, $outputlangs, $array_key $array_key.'_tracking_number' => $object->tracking_number, $array_key.'_tracking_url' => $object->tracking_url, $array_key.'_shipping_method' => $object->listmeths[0]['libelle'], - $array_key.'_weight' => $object->trueWeight.' '.measuringUnitString(0, 'weight', $object->weight_units), + $array_key.'_weight' => $object->trueWeight.' '.measuringUnitString(0, 'weight', (string) $object->weight_units), $array_key.'_width' => $object->trueWidth.' '.measuringUnitString(0, 'size', $object->width_units), $array_key.'_height' => $object->trueHeight.' '.measuringUnitString(0, 'size', $object->height_units), $array_key.'_depth' => $object->trueDepth.' '.measuringUnitString(0, 'size', $object->depth_units), @@ -1079,6 +1116,33 @@ public function printRect($pdf, $x, $y, $l, $h, $hidetop = 0, $hidebottom = 0) $pdf->line($x, $y + $h, $x, $y); } + /** + * Print a rounded rectangle on the PDF + * + * @param TCPDF $pdf Object PDF + * @param float $x Abscissa of first point + * @param float $y Ordinate of first point + * @param float $w Width of the rectangle + * @param float $h Height of the rectangle + * @param float $r Corner radius (can be an array for different radii per corner) + * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title + * @param int $hidebottom Hide bottom + * @param string $style Draw style (e.g. 'D' for draw, 'F' for fill, 'DF' for both) + * @return void + */ + public function printRoundedRect($pdf, $x, $y, $w, $h, $r, $hidetop = 0, $hidebottom = 0, $style = 'D') + { + // Top line + if (empty($hidetop) || $hidetop == -1) { + $pdf->RoundedRect($x, $y, $w, $h, $r, '1111', $style); + } else { + // Draw rounded rectangle with hidden top side + $pdf->RoundedRect($x, $y, $w, $h, $r, '0111', $style); + } + if (!empty($hidebottom)) { + $pdf->RoundedRect($x, $y, $w, $h, $r, '1101', $style); + } + } /** * uasort callback function to Sort columns fields diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 4e9e084a81bb1..f8b2b8eae5399 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -231,7 +231,7 @@ public function getRemainToPay($multicurrency = 0) $alreadypaid += $this->getSumCreditNotesUsed($multicurrency); $remaintopay = price2num($this->total_ttc - $alreadypaid, 'MT'); - if ($this->statut == self::STATUS_CLOSED && $this->close_code == 'discount_vat') { // If invoice closed with discount for anticipated payment + if ($this->status == self::STATUS_CLOSED && $this->close_code == 'discount_vat') { // If invoice closed with discount for anticipated payment $remaintopay = 0.0; } return $remaintopay; @@ -239,7 +239,7 @@ public function getRemainToPay($multicurrency = 0) /** * Return amount of payments already done. This must include ONLY the record into the payment table. - * Payments dones using discounts, credit notes, etc are not included. + * Payments done using discounts, credit notes, etc are not included. * * @param int $multicurrency Return multicurrency_amount instead of amount. -1=Return both. * @return float|int|array Amount of payment already done, <0 and set ->error if KO @@ -439,15 +439,15 @@ public function getIdReplacingInvoice($option = '') * * @see $error Empty string '' if no error. * - * @param string $filtertype 1 to filter on type of payment == 'PRE' - * @param int $multicurrency Return multicurrency_amount instead of amount + * @param string $filtertype 1 to filter on type of payment == 'PRE' for the payment lines + * @param int $multicurrency Return multicurrency_amount instead of amount + * @param int $mode 0=payments + discount, 1=payments only * @return array Array with list of payments */ - public function getListOfPayments($filtertype = '', $multicurrency = 0) + public function getListOfPayments($filtertype = '', $multicurrency = 0, $mode = 0) { $retarray = array(); - // By default no error, list can be empty. - $this->error = ''; + $this->error = ''; // By default no error, list can be empty. $table = 'paiement_facture'; $table2 = 'paiement'; @@ -465,36 +465,50 @@ public function getListOfPayments($filtertype = '', $multicurrency = 0) $sharedentity = 'facture_fourn'; } - $sql = "SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code".$field3 . $field4; - $sql .= " FROM ".$this->db->prefix().$table." as pf, ".$this->db->prefix().$table2." as p, ".$this->db->prefix()."c_paiement as t"; - $sql .= " WHERE pf.".$field." = ".((int) $this->id); - $sql .= " AND pf.".$field2." = p.rowid"; - $sql .= ' AND p.fk_paiement = t.id'; - $sql .= ' AND p.entity IN ('.getEntity($sharedentity).')'; - if ($filtertype) { - $sql .= " AND t.code='PRE'"; - } + // List of payments + if (empty($mode) || $mode == 1) { + $sql = "SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code".$field3 . $field4; + $sql .= " FROM ".$this->db->prefix().$table." as pf, ".$this->db->prefix().$table2." as p, ".$this->db->prefix()."c_paiement as t"; + $sql .= " WHERE pf.".$field." = ".((int) $this->id); + $sql .= " AND pf.".$field2." = p.rowid"; + $sql .= ' AND p.fk_paiement = t.id'; + $sql .= ' AND p.entity IN ('.getEntity($sharedentity).')'; + if ($filtertype) { + $sql .= " AND t.code='PRE'"; + } - dol_syslog(get_class($this)."::getListOfPayments", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < $num) { - $obj = $this->db->fetch_object($resql); - $tmp = array('amount' => $obj->amount, 'type' => $obj->code, 'date' => $obj->datep, 'num' => $obj->num, 'ref' => $obj->ref); - if (!empty($field3)) { - $tmp['ref_ext'] = $obj->ref_ext; - } - if (!empty($field4)) { - $tmp['fk_bank_line'] = $obj->fk_bank; + dol_syslog(get_class($this)."::getListOfPayments filtertype=".$filtertype." multicurrency=".$multicurrency." mode=".$mode, LOG_DEBUG); + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) { + $obj = $this->db->fetch_object($resql); + if ($multicurrency) { + $tmp = array('amount' => $obj->multicurrency_amount, 'type' => $obj->code, 'typeline' => 'payment', 'date' => $obj->datep, 'num' => $obj->num, 'ref' => $obj->ref); + } else { + $tmp = array('amount' => $obj->amount, 'type' => $obj->code, 'typeline' => 'payment', 'date' => $obj->datep, 'num' => $obj->num, 'ref' => $obj->ref); + } + if (!empty($field3)) { + $tmp['ref_ext'] = $obj->ref_ext; + } + if (!empty($field4)) { + $tmp['fk_bank_line'] = $obj->fk_bank; + } + $retarray[] = $tmp; + $i++; } - $retarray[] = $tmp; - $i++; + $this->db->free($resql); + } else { + $this->error = $this->db->lasterror(); + dol_print_error($this->db); + return array(); } - $this->db->free($resql); + } - //look for credit notes and discounts and deposits + // Look for credit notes and discounts and deposits + if (empty($mode) || $mode == 2) { $sql = ''; if ($this->element == 'facture' || $this->element == 'invoice') { $sql = "SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type"; @@ -516,9 +530,9 @@ public function getListOfPayments($filtertype = '', $multicurrency = 0) while ($i < $num) { $obj = $this->db->fetch_object($resql); if ($multicurrency) { - $retarray[] = array('amount' => $obj->multicurrency_amount, 'type' => $obj->type, 'date' => $obj->date, 'num' => '0', 'ref' => $obj->ref); + $retarray[] = array('amount' => $obj->multicurrency_amount, 'type' => $obj->type, 'typeline' => 'discount', 'date' => $obj->date, 'num' => '0', 'ref' => $obj->ref); } else { - $retarray[] = array('amount' => $obj->amount, 'type' => $obj->type, 'date' => $obj->date, 'num' => '', 'ref' => $obj->ref); + $retarray[] = array('amount' => $obj->amount, 'type' => $obj->type, 'typeline' => 'discount', 'date' => $obj->date, 'num' => '', 'ref' => $obj->ref); } $i++; } @@ -528,14 +542,14 @@ public function getListOfPayments($filtertype = '', $multicurrency = 0) return array(); } $this->db->free($resql); + } else { + $this->error = $this->db->lasterror(); + dol_print_error($this->db); + return array(); } - - return $retarray; - } else { - $this->error = $this->db->lasterror(); - dol_print_error($this->db); - return array(); } + + return $retarray; } @@ -560,7 +574,7 @@ public function is_erasable() // We check if invoice is a temporary number (PROVxxxx) $tmppart = substr($this->ref, 1, 4); - if ($this->statut == self::STATUS_DRAFT && $tmppart === 'PROV') { // If draft invoice and ref not yet defined + if ($this->status == self::STATUS_DRAFT && $tmppart === 'PROV') { // If draft invoice and ref not yet defined return 1; } @@ -609,7 +623,8 @@ public function is_erasable() } /** - * Return if an invoice was dispatched into bookkeeping + * Return if an invoice was transferred into accountnancy. + * This is true if at least on line was transferred into table accounting_bookkeeping * * @return int Return integer <0 if KO, 0=no, 1=yes */ @@ -622,7 +637,9 @@ public function getVentilExportCompta() $type = 'supplier_invoice'; } - $sql = " SELECT COUNT(ab.rowid) as nb FROM ".$this->db->prefix()."accounting_bookkeeping as ab WHERE ab.doc_type='".$this->db->escape($type)."' AND ab.fk_doc = ".((int) $this->id); + $sql = " SELECT COUNT(ab.rowid) as nb FROM ".$this->db->prefix()."accounting_bookkeeping as ab"; + $sql .= " WHERE ab.doc_type='".$this->db->escape($type)."' AND ab.fk_doc = ".((int) $this->id); + $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); @@ -779,7 +796,7 @@ public function getArrayOfInvoiceSubtypes($mode = 0) */ public function getLibStatut($mode = 0, $alreadypaid = -1) { - return $this->LibStatut($this->paye, $this->statut, $mode, $alreadypaid, $this->type); + return $this->LibStatut($this->paye, $this->status, $mode, $alreadypaid, $this->type); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 8c7d624c50c26..4b8b075d0cd98 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -769,14 +769,14 @@ abstract class CommonObject public $sendtoid; /** - * @var float Amount already paid from getSommePaiement() (used to show correct status) - * @deprecated Use $totalpaid instead + * @var float Amount already paid from getSommePaiement() + getSumCreditNotesUsed() + getSumDepositsUsed() (used to show correct status) * @see $totalpaid */ - private $alreadypaid; + public $alreadypaid; /** - * @var float Amount already paid from getSommePaiement() (used to show correct status) + * @var float Amount already paid from getSommePaiement() + * @see $alreadpaid */ public $totalpaid; @@ -1749,7 +1749,7 @@ public function listeTypeContacts($source = 'internal', $option = 0, $activeonly } elseif (strpos($obj->element, 'supplier') !== false && $obj->element != 'supplier_proposal') { $modulename = 'fournisseur'; } - if (!empty($conf->{$modulename}->enabled)) { + if (isModEnabled($modulename)) { $libelle_element = $langs->trans('ContactDefault_'.$obj->element); $tmpelement = $obj->element; $transkey = "TypeContact_".$tmpelement."_".$source."_".$obj->code; @@ -1893,7 +1893,7 @@ public function fetch_thirdparty($force_thirdparty_id = 0) $this->thirdparty = $thirdparty; // Use first price level if level not defined for third party - if (getDolGlobalString('PRODUIT_MULTIPRICES') && empty($this->thirdparty->price_level)) { + if ((getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) && empty($this->thirdparty->price_level)) { $this->thirdparty->price_level = 1; } @@ -2750,6 +2750,8 @@ public function setMulticurrencyRate($rate, $mode = 1) case 'propal': /** @var Propal $this */ /** @var PropaleLigne $line */ + '@phan-var-force Propal $this'; + '@phan-var-force PropaleLigne $line'; $this->updateline( $line->id, $line->subprice, @@ -2778,6 +2780,8 @@ public function setMulticurrencyRate($rate, $mode = 1) case 'commande': /** @var Commande $this */ /** @var OrderLine $line */ + '@phan-var-force Commande $this'; + '@phan-var-force OrderLine $line'; $this->updateline( $line->id, ($line->description ? $line->description : $line->desc), @@ -2806,6 +2810,8 @@ public function setMulticurrencyRate($rate, $mode = 1) case 'facture': /** @var Facture $this */ /** @var FactureLigne $line */ + '@phan-var-force Facture $this'; + '@phan-var-force FactureLigne $line'; $this->updateline( $line->id, ($line->description ? $line->description : $line->desc), @@ -2835,6 +2841,8 @@ public function setMulticurrencyRate($rate, $mode = 1) case 'supplier_proposal': /** @var SupplierProposal $this */ /** @var SupplierProposalLine $line */ + '@phan-var-force SupplierProposal $this'; + '@phan-var-force SupplierProposalLine $line'; $this->updateline( $line->id, $line->subprice, @@ -2861,6 +2869,8 @@ public function setMulticurrencyRate($rate, $mode = 1) case 'order_supplier': /** @var CommandeFournisseur $this */ /** @var CommandeFournisseurLigne $line */ + '@phan-var-force CommandeFournisseur $this'; + '@phan-var-force CommandeFournisseurLigne $line'; $this->updateline( $line->id, ($line->description ? $line->description : $line->desc), @@ -2885,6 +2895,8 @@ public function setMulticurrencyRate($rate, $mode = 1) case 'invoice_supplier': /** @var FactureFournisseur $this */ /** @var SupplierInvoiceLine $line */ + '@phan-var-force FactureFournisseur $this'; + '@phan-var-force SupplierInvoiceLIne $line'; $this->updateline( $line->id, ($line->description ? $line->description : $line->desc), @@ -3664,6 +3676,7 @@ public function update_ref_ext($ref_ext) $sql = "UPDATE ".$this->db->prefix().$this->table_element; $sql .= " SET ref_ext = '".$this->db->escape($ref_ext)."'"; + // @phan-suppress-next-line PhanUndeclaredProperty $sql .= " WHERE ".(isset($this->table_rowid) ? $this->table_rowid : 'rowid')." = ".((int) $this->id); dol_syslog(get_class($this)."::update_ref_ext", LOG_DEBUG); @@ -4024,12 +4037,15 @@ public function update_price($exclspec = 0, $roundingadjust = 'auto', $nodatabas } // Add revenue stamp to total + // @phan-suppress-next-line PhanUndeclaredProperty $this->total_ttc += isset($this->revenuestamp) ? $this->revenuestamp : 0; + // @phan-suppress-next-line PhanUndeclaredProperty $this->multicurrency_total_ttc += isset($this->revenuestamp) ? ($this->revenuestamp * $multicurrency_tx) : 0; // Situations totals - if (!empty($this->situation_cycle_ref) && !empty($this->situation_counter) && $this->situation_counter > 1 && method_exists($this, 'get_prev_sits')) { - include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + if (!empty($this->situation_cycle_ref) && !empty($this->situation_counter) && $this->situation_counter > 1 && method_exists($this, 'get_prev_sits')) { // @phan-suppress-current-line PhanUndeclaredProperty + '@phan-var-force Facture $this'; + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; // Note: possibly useless as $this is normally already Facture, so the class file should be loaded if ($this->type != Facture::TYPE_CREDIT_NOTE) { // @phpstan-ignore-line if (getDolGlobalInt('INVOICE_USE_SITUATION') != 2) { $prev_sits = $this->get_prev_sits(); @@ -4353,6 +4369,7 @@ public function fetchObjectLinked($sourceid = null, $sourcetype = '', $targetid if (class_exists($className)) { foreach ($objectids as $i => $objectid) { // $i is rowid into llx_element_element $object = new $className($this->db); + '@phan-var-force CommonObject $object'; $ret = $object->fetch($objectid); if ($ret >= 0) { $this->linkedObjects[$objecttype][$i] = $object; @@ -4459,13 +4476,13 @@ public function updateObjectLinked($sourceid = null, $sourcetype = '', $targetid /** * Delete all links between an object $this * - * @param int $sourceid Object source id + * @param ?int $sourceid Object source id * @param string $sourcetype Object source type - * @param int $targetid Object target id + * @param ?int $targetid Object target id * @param string $targettype Object target type * @param int $rowid Row id of line to delete. If defined, other parameters are not used. - * @param User $f_user User that create - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @param ?User $f_user User that create + * @param int<0,1> $notrigger 1=Does not execute triggers, 0= execute triggers * @return int >0 if OK, <0 if KO * @see add_object_linked(), updateObjectLinked(), fetchObjectLinked() */ @@ -4631,7 +4648,7 @@ public static function deleteAllItemsLinkedByObjectID($fk_object_where, $field_w * Set status of an object. * * @param int $status Status to set - * @param int $elementId Id of element to force (use this->id by default if null) + * @param ?int $elementId Id of element to force (use this->id by default if null) * @param string $elementType Type of element to force (use this->table_element by default) * @param string $trigkey Trigger key to use for trigger. Use '' means automatic but it is not recommended and is deprecated. * @param string $fieldstatus Name of status field in this->table_element @@ -5269,7 +5286,7 @@ public function printObjectLines($action, $seller, $buyer, $selected = 0, $dateS * @param Societe $seller Object of seller third party * @param Societe $buyer Object of buyer third party * @param int $selected ID line selected - * @param Extrafields $extrafields Object of extrafields + * @param ?Extrafields $extrafields Object of extrafields * @param string $defaulttpldir Directory where to find the template (deprecated) * @return void */ @@ -5458,6 +5475,7 @@ public function printOriginLine($line, $var, $restrictlist = '', $defaulttpldir //var_dump($line); if (!empty($line->date_start)) { + // @phan-suppress-next-line PhanUndeclaredProperty $date_start = $line->date_start; } else { $date_start = $line->date_debut_prevue; @@ -5466,6 +5484,7 @@ public function printOriginLine($line, $var, $restrictlist = '', $defaulttpldir } } if (!empty($line->date_end)) { + // @phan-suppress-next-line PhanUndeclaredProperty $date_end = $line->date_end; } else { $date_end = $line->date_fin_prevue; @@ -5519,6 +5538,7 @@ public function printOriginLine($line, $var, $restrictlist = '', $defaulttpldir } if (!empty($line->desc)) { + '@phan-var-force OrderLine|FactureLigne|ContratLigne|FactureFournisseurLigneRec|SupplierInvoiceLine|SupplierProposalLine $line'; if ($line->desc == '(CREDIT_NOTE)') { // TODO Not sure this is used for source object $discount = new DiscountAbsolute($this->db); $discount->fetch($line->fk_remise_except); @@ -5854,6 +5874,8 @@ protected function commonGenerateDocument($modelspath, $modele, $outputlangs, $h if ($obj instanceof ModelePDFMember) { $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, 'tmp_cards'); } else { + // TODO: Try to set type above again + '@phan-var-force ModeleBarCode|ModeleDon|ModeleExports|ModeleImports|ModelePDFAsset|ModelePDFContract|ModelePDFDeliveryOrder|ModelePDFEvaluation|ModelePDFFactures|ModelePDFFicheinter|ModelePDFMo|ModelePDFMovement|ModelePDFProduct|ModelePDFProjects|ModelePDFPropales|ModelePDFRecruitmentJobPosition|ModelePDFStock|ModelePDFStockTransfer|ModelePDFSupplierProposal|ModelePDFSuppliersInvoices|ModelePDFSuppliersOrders|ModelePDFSuppliersPayments|ModelePDFTask|ModelePDFTicket|ModelePDFUser|ModelePDFUserGroup|ModelePdfExpedition|ModelePdfReception|ModeleThirdPartyDoc $obj'; $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams); } // After call of write_file $obj->result['fullpath'] is set with generated file. It will be used to update the ECM database index. @@ -6357,8 +6379,8 @@ public function fetch_optionals($rowid = null, $optionsArray = null) if (empty($rowid)) { $rowid = $this->id; } - if (empty($rowid) && isset($this->rowid)) { - $rowid = $this->rowid; // deprecated + if (empty($rowid) && isset($this->rowid)) { // @phan-suppress-current-line PhanUndeclaredProperty + $rowid = $this->rowid; // deprecated @phan-suppress-current-line PhanUndeclaredProperty } // To avoid SQL errors. Probably not the better solution though @@ -6704,6 +6726,7 @@ public function insertExtraFields($trigger = '', $userused = null) $new_array_options[$key] = ''; } elseif ($value) { $object = new $InfoFieldList[0]($this->db); + '@phan-var-force CommonObject $object'; if (is_numeric($value)) { $res = $object->fetch($value); // Common case } else { @@ -6884,12 +6907,12 @@ public function insertExtraLanguages($trigger = '', $userused = null) if (is_array($value) || (!is_numeric($value) && $value != '')) { $this->errors[] = $langs->trans("ExtraLanguageHasWrongValue", $attributeLabel); return -1; - } elseif ($value == '') { + } elseif ($value == '') { // @phan-suppress-current-line PhanTypeComparisonFromArray $new_array_languages[$key] = null; } break; case 'double': - $value = price2num($value); + $value = price2num((string) $value); if (!is_numeric($value) && $value != '') { dol_syslog($langs->trans("ExtraLanguageHasWrongValue")." on ".$attributeLabel."(".$value."is not '".$attributeType."')", LOG_DEBUG); $this->errors[] = $langs->trans("ExtraLanguageHasWrongValue", $attributeLabel); @@ -7399,6 +7422,10 @@ public function showInputField($val, $key, $value, $moreparam = '', $keysuffix = } elseif (preg_match('/varchar/', $val['type'])) { $param['options'] = array(); $type = 'varchar'; + } elseif (preg_match('/stars\((\d+)\)/', $val['type'], $reg)) { + $param['options'] = array(); + $type = 'stars'; + $size = $reg[1]; } else { $param['options'] = array(); $type = $this->fields[$key]['type']; @@ -7590,6 +7617,44 @@ function handlemultiinputdisabling(htmlname){ $value = price($value); } $out = ' '.$langs->getCurrencySymbol($conf->currency); + } elseif ($type == 'stars') { + $out = ''; + $out .= '
'; + $i = 1; + while ($i <= $size) { + $out .= ''.img_picto('', 'fontawesome_star_fas').''; + $i++; + } + $out .= '
'; + $out .= ''; } elseif (preg_match('/^double(\([0-9],[0-9]\)){0,1}/', (string) $type)) { if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. $value = price($value); @@ -8060,7 +8125,7 @@ function handlemultiinputdisabling(htmlname){ $isDependList = 1; } - $data[$obj->rowid] = $labeltoshow; + $data[(int) $obj->rowid] = $labeltoshow; } $i++; @@ -8073,7 +8138,7 @@ function handlemultiinputdisabling(htmlname){ } } else { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]], '', 'parent', 64, $InfoFieldList[6], 1, 1); + $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[(int) $InfoFieldList[5]], '', 'parent', 64, $InfoFieldList[6], 1, 1); $out = $form->multiselectarray($keyprefix . $key . $keysuffix, $data, $value_arr, 0, 0, $morecss, 0, '100%'); } } @@ -8255,6 +8320,10 @@ public function showOutputField($val, $key, $value, $moreparam = '', $keysuffix } elseif (preg_match('/^chkbxlst:(.*)/i', $val['type'], $reg)) { $param['options'] = array($reg[1] => 'N'); $type = 'chkbxlst'; + } elseif (preg_match('/stars\((\d+)\)/', $val['type'], $reg)) { + $param['options'] = array(); + $type = 'stars'; + $size = $reg[1]; } $langfile = empty($val['langfile']) ? '' : $val['langfile']; @@ -8342,6 +8411,62 @@ public function showOutputField($val, $key, $value, $moreparam = '', $keysuffix $value = dol_print_phone($value, '', 0, 0, '', ' ', 'phone'); } elseif ($type == 'ip') { $value = dol_print_ip($value, 0); + } elseif ($type == 'stars') { + $value = ''; + $value .= '
'; + $i = 1; + while ($i <= $size) { + $value .= ''.img_picto('', 'fontawesome_star_fas').''; + $i++; + } + $value .= '
'; + $value .= ''; } elseif ($type == 'price') { if (!is_null($value) && $value !== '') { $value = price($value, 0, $langs, 0, 0, -1, $conf->currency); @@ -8590,13 +8715,16 @@ public function showOutputField($val, $key, $value, $moreparam = '', $keysuffix if ($classname && class_exists($classname)) { $object = new $classname($this->db); + '@phan-var-force CommonObject $object'; if ($object->element === 'product') { // Special case for product because default valut of fetch are wrong + '@phan-var-force Product $object'; $result = $object->fetch($value, '', '', '', 0, 1, 1); } else { $result = $object->fetch($value); } if ($result > 0) { if ($object->element === 'product') { + '@phan-var-force Product $object'; $get_name_url_param_arr = array($getnomurlparam, $getnomurlparam2, 0, -1, 0, '', 0); if (isset($val['get_name_url_params'])) { $get_name_url_params = explode(':', $val['get_name_url_params']); @@ -9035,7 +9163,7 @@ public function showOptionals($extrafields, $mode = 'view', $params = null, $key $value = $getposttemp; } } elseif (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('int'))) { - $value = (!empty($this->array_options["options_".$key]) || $this->array_options["options_".$key] === '0') ? $this->array_options["options_".$key] : ''; + $value = (!empty($this->array_options["options_".$key]) || (isset($this->array_options["options_".$key]) && $this->array_options["options_".$key] === '0')) ? $this->array_options["options_".$key] : ''; } else { $value = (!empty($this->array_options["options_".$key]) ? $this->array_options["options_".$key] : ''); // No GET, no POST, no default value, so we take value of object. } @@ -9350,6 +9478,20 @@ public function getRights() */ public static function commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors = 0) { + global $hookmanager; + + $parameters = array( + 'origin_id' => $origin_id, + 'dest_id' => $dest_id, + 'tables' => $tables, + ); + $reshook = $hookmanager->executeHooks('commonReplaceThirdparty', $parameters); + if ($reshook) { + return true; // replacement code + } elseif ($reshook < 0) { + return $ignoreerrors === 1; // failure + } // reshook = 0 => execute normal code + foreach ($tables as $table) { $sql = 'UPDATE '.$dbs->prefix().$table.' SET fk_soc = '.((int) $dest_id).' WHERE fk_soc = '.((int) $origin_id); @@ -10266,7 +10408,7 @@ public function createCommon(User $user, $notrigger = 0) * Load object in memory from the database. This does not load line. This is done by parent fetch() that call fetchCommon * * @param int $id Id object - * @param string $ref Ref + * @param ?string $ref Ref * @param string $morewhere More SQL filters (' AND ...') * @param int<0,1> $noextrafields 0=Default to load extrafields, 1=No extrafields * @return int<-4,1> Return integer <0 if KO, 0 if not found, >0 if OK @@ -10331,7 +10473,7 @@ public function fetchCommon($id, $ref = null, $morewhere = '', $noextrafields = /** * Load object in memory from the database * - * @param string $morewhere More SQL filters (' AND ...') + * @param string $morewhere More SQL filters (' AND ...'). No user coming from user input are allowed here. Only hard coded values. * @param int<0,1> $noextrafields 0=Default to load extrafields, 1=No extrafields * @return int<-1,1> Return integer <0 if KO, 0 if not found, >0 if OK */ @@ -10360,6 +10502,7 @@ public function fetchLinesCommon($morewhere = '', $noextrafields = 0) if ($resql) { $num_rows = $this->db->num_rows($resql); $i = 0; + $this->lines = array(); while ($i < $num_rows) { $obj = $this->db->fetch_object($resql); if ($obj) { diff --git a/htdocs/core/class/commonorder.class.php b/htdocs/core/class/commonorder.class.php index d0210edc9c141..0f82d2a5fe480 100644 --- a/htdocs/core/class/commonorder.class.php +++ b/htdocs/core/class/commonorder.class.php @@ -162,7 +162,7 @@ abstract class CommonOrderLine extends CommonObjectLine /** * Product use lot - * @var string + * @var int */ public $product_tobatch; diff --git a/htdocs/core/class/commonpeople.class.php b/htdocs/core/class/commonpeople.class.php index c9d7dba4cb964..016a5a185a671 100644 --- a/htdocs/core/class/commonpeople.class.php +++ b/htdocs/core/class/commonpeople.class.php @@ -315,6 +315,19 @@ public function getBannerAddress($htmlkey, $object) */ public function setUpperOrLowerCase() { + if (getDolGlobalString('MAIN_TE_PRIVATE_FIRST_AND_LASTNAME_TO_UPPER')) { + $this->lastname = dol_ucwords(dol_strtolower($this->lastname)); + $this->firstname = dol_ucwords(dol_strtolower($this->firstname)); + if (empty($this->typent_code) || $this->typent_code != "TE_PRIVATE") { + $this->name = dol_ucwords(dol_strtolower($this->name)); + } + if (!empty($this->firstname)) { + $this->lastname = dol_strtoupper($this->lastname); + } + if (property_exists($this, 'name_alias')) { + $this->name_alias = isset($this->name_alias) ? dol_ucwords(dol_strtolower($this->name_alias)) : ''; + } + } if (getDolGlobalString('MAIN_FIRST_TO_UPPER')) { $this->lastname = dol_ucwords(dol_strtolower($this->lastname)); $this->firstname = dol_ucwords(dol_strtolower($this->firstname)); diff --git a/htdocs/core/class/commonstickergenerator.class.php b/htdocs/core/class/commonstickergenerator.class.php index 76ca7efff3bf7..ab048d5ab6a5c 100644 --- a/htdocs/core/class/commonstickergenerator.class.php +++ b/htdocs/core/class/commonstickergenerator.class.php @@ -5,6 +5,7 @@ * Copyright (C) 2002-2003 Jean-Louis Bergamo * Copyright (C) 2006-2013 Laurent Destailleur * Copyright (C) 2015 Francis Appels + * 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 @@ -296,7 +297,7 @@ protected function _Get_Height_Chars($pt) * protected Set format * * @param TCPDF $pdf PDF reference - * @param array{metric:string,name:string,code:string,marginLeft:float,marginTip:float,SpaceX:float,SpaceY:float,NX:int,NY:int,width:float,height:float,font-size:float} $format Format + * @param array{metric:string,name:string,code:string,marginLeft:float,marginTop:float,SpaceX:float,SpaceY:float,NX:int,NY:int,width:float,height:float,font-size:float} $format Format * @return void */ protected function _Set_Format(&$pdf, $format) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index e69628e64e095..d44aba190296e 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -956,6 +956,7 @@ public function setValues($db) $this->global->MAIN_MODULES_FOR_EXTERNAL .= ",".$key; } } + //$this->global->MAIN_MODULES_FOR_EXTERNAL .= ",ecm"; // Enable select2 if (empty($this->global->MAIN_USE_JQUERY_MULTISELECT) || $this->global->MAIN_USE_JQUERY_MULTISELECT == '1') { @@ -1041,7 +1042,7 @@ public function setValues($db) $this->holiday->approve->warning_delay = (isset($this->global->MAIN_DELAY_HOLIDAYS) ? (int) $this->global->MAIN_DELAY_HOLIDAYS : 0) * 86400; } - if (!empty($this->global->PRODUIT_MULTIPRICES) && empty($this->global->PRODUIT_MULTIPRICES_LIMIT)) { + if ((!empty($this->global->PRODUIT_MULTIPRICES) || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) && empty($this->global->PRODUIT_MULTIPRICES_LIMIT)) { $this->global->PRODUIT_MULTIPRICES_LIMIT = 5; } @@ -1070,6 +1071,10 @@ public function setValues($db) $this->global->MAIN_JS_GRAPH = 'chart'; // Use chart.js library } + if (!isset($this->global->THEME_ELDY_USEBORDERONTABLE)) { + $this->global->THEME_ELDY_USEBORDERONTABLE = 1; + } + if (empty($this->global->MAIN_MODULE_DOLISTORE_API_SRV)) { $this->global->MAIN_MODULE_DOLISTORE_API_SRV = 'https://www.dolistore.com'; } diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 2593cfbb8cb36..47874f4516d23 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -166,7 +166,12 @@ public function Create($noprint = 0, $morejs = '', $disallowAnyContent = true, $ //$out.= ''; @@ -204,6 +209,7 @@ public function Create($noprint = 0, $morejs = '', $disallowAnyContent = true, $ $htmlencode_force = preg_match('/_encoded$/', $this->toolbarname) ? 'true' : 'false'; $out .= ''."\n"; + //$out .= ''; $out .= ' - '; + '; + } + + if ($nooutput) { + return array('linktoelem' => $linktoelem, 'htmltoenteralink' => $htmltoenteralink); + } else { + print $htmltoenteralink; } return $linktoelem; @@ -9788,16 +9810,16 @@ public function showLinkToObjectBlock($object, $restrictlinksto = array(), $excl /** * Return an html string with a select combo box to choose yes or no * - * @param string $htmlname Name of html select field - * @param string $value Pre-selected value - * @param int $option 0 return yes/no, 1 return 1/0 - * @param bool $disabled true or false - * @param int $useempty 1=Add empty line - * @param int $addjscombo 1=Add js beautifier on combo box - * @param string $morecss More CSS - * @param string $labelyes Label for Yes - * @param string $labelno Label for No - * @return string See option + * @param string $htmlname Name of html select field + * @param string|int $value Pre-selected value + * @param int $option 0 return yes/no, 1 return 1/0 + * @param bool $disabled true or false + * @param int $useempty 1=Add empty line + * @param int $addjscombo 1=Add js beautifier on combo box + * @param string $morecss More CSS + * @param string $labelyes Label for Yes + * @param string $labelno Label for No + * @return string See option */ public function selectyesno($htmlname, $value = '', $option = 0, $disabled = false, $useempty = 0, $addjscombo = 0, $morecss = 'width75', $labelyes = 'Yes', $labelno = 'No') { diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 2c75db69e1136..96f4a3b778000 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -365,9 +365,10 @@ public function showactions($object, $typeelement, $socid = 0, $forceshowtitle = * @param int $multiselect 1=Allow multiselect of action type * @param int $nooutput 1=No output * @param string $morecss More css to add to SELECT component. + * @param int<0,1>|string $showempty 0 or 1 or 'Placeholder string' * @return string */ - public function select_type_actions($selected = '', $htmlname = 'actioncode', $excludetype = '', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0, $morecss = 'minwidth300') + public function select_type_actions($selected = '', $htmlname = 'actioncode', $excludetype = '', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0, $morecss = 'minwidth300', $showempty = 0) { // phpcs:enable global $langs, $user, $form; @@ -382,10 +383,12 @@ public function select_type_actions($selected = '', $htmlname = 'actioncode', $e // Suggest a list with manual events or all auto events $arraylist = $caction->liste_array(1, 'code', $excludetype, $onlyautoornot, '', 0); // If we use param 'all' instead of 'code', there is no group by include in answer but the key 'type' of answer array contains the key for the group by. + /* Removed. The empty line must now be managed with param showempty if (empty($multiselect)) { // Add empty line at start only if no multiselect array_unshift($arraylist, ' '); } + */ //asort($arraylist); if ($selected == 'manual') { @@ -415,9 +418,9 @@ public function select_type_actions($selected = '', $htmlname = 'actioncode', $e if (!is_array($selected) && !empty($selected)) { $selected = explode(',', $selected); } - $out .= $form->multiselectarray($htmlname, $newarraylist, $selected, 0, 0, 'centpercent', 0, 0); + $out .= $form->multiselectarray($htmlname, $newarraylist, $selected, 0, 0, 'centpercent', 0, 0, '', '', (is_numeric($showempty) ? '' : $showempty)); } else { - $out .= $form->selectarray($htmlname, $newarraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', $morecss, 1); + $out .= $form->selectarray($htmlname, $newarraylist, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1); } if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0) { diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index b71662f1f8849..30d7a793f7638 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -45,9 +45,9 @@ class FormCompany extends Form /** * Return list of labels (translated) of third parties type * - * @param int $mode 0=Return id+label, 1=Return code+label - * @param string $filter Add a SQL filter to select. Data must not come from user input. - * @return array Array of types + * @param int<0,1> $mode 0=Return id+label, 1=Return code+label + * @param string $filter Add a SQL filter to select. Data must not come from user input. + * @return array Array of types */ public function typent_array($mode = 0, $filter = '') { @@ -96,9 +96,9 @@ public function typent_array($mode = 0, $filter = '') /** * Return the list of entries for staff (no translation, it is number ranges) * - * @param int $mode 0=return id+label, 1=return code+Label - * @param string $filter Add a SQL filter to select. Data must not come from user input. - * @return array Array of types d'effectifs + * @param int<0,1> $mode 0=return id+label, 1=return code+Label + * @param string $filter Add a SQL filter to select. Data must not come from user input. + * @return array Array of types d'effectifs */ public function effectif_array($mode = 0, $filter = '') { @@ -126,13 +126,14 @@ public function effectif_array($mode = 0, $filter = '') $key = $objp->code; } - $effs[$key] = $objp->label != '-' ? $objp->label : ''; + $effs[$key] = $objp->label != '-' ? (string) $objp->label : ''; $i++; } $this->db->free($resql); } //return natural sorted list natsort($effs); + '@phan-var-force array $effs'; return $effs; } @@ -642,7 +643,7 @@ public function select_juridicalstatus($selected = 0, $country_codeid = 0, $filt * @param string $var_id Name of id field * @param int $selected Pre-selected third party * @param string $htmlname Name of HTML form - * @param array $limitto Disable answers that are not id in this array list + * @param int[] $limitto Disable answers that are not id in this array list * @param int $forceid This is to force another object id than object->id * @param string $moreparam String with more param to add into url when noajax search is used. * @param string $morecss More CSS on select component @@ -768,6 +769,7 @@ function(response) { $num = $this->db->num_rows($resql); $i = 0; + $firstCompany = 0; // For static analysis if ($num) { while ($i < $num) { $obj = $this->db->fetch_object($resql); @@ -808,15 +810,15 @@ function(response) { /** * Return a select list with types of contacts * - * @param object $object Object to use to find type of contact + * @param Object $object Object to use to find type of contact * @param string $selected Default selected value * @param string $htmlname HTML select name * @param string $source Source ('internal' or 'external') * @param string $sortorder Sort criteria ('position', 'code', ...) * @param int $showempty 1=Add en empty line * @param string $morecss Add more css to select component - * @param int $output 0=return HTML, 1= direct print - * @param int $forcehidetooltip Force hide tooltip for admin + * @param int<0,1> $output 0=return HTML, 1= direct print + * @param int<0,1> $forcehidetooltip Force hide tooltip for admin * @return string|void Depending on $output param, return the HTML select list (recommended method) or nothing */ public function selectTypeContact($object, $selected, $htmlname = 'type', $source = 'internal', $sortorder = 'position', $showempty = 0, $morecss = '', $output = 1, $forcehidetooltip = 0) @@ -825,6 +827,7 @@ public function selectTypeContact($object, $selected, $htmlname = 'type', $sourc $out = ''; if (is_object($object) && method_exists($object, 'liste_type_contact')) { + '@phan-var-force CommonObject $object'; // CommonObject has the method. $lesTypes = $object->liste_type_contact($source, $sortorder, 0, 1); // List of types into c_type_contact for element=$object->element $out .= '
'; + print ''; // Show file name with link to download //print "XX".$file['name']; //$file['name'] must be utf8 @@ -2247,7 +2256,7 @@ public function showPreview($file, $modulepart, $relativepath, $ruleforpicto = 0 $out .= ''; } else { if ($ruleforpicto < 0) { - $out .= img_picto('', 'generic', '', false, 0, 0, '', 'paddingright pictofixedwidth'); + $out .= img_picto('', 'generic', '', 0, 0, 0, '', 'paddingright pictofixedwidth'); } } } diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index d51d1177e6815..8b5c9a10bb8f2 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -180,7 +180,7 @@ class FormMail extends Form public $substit = array(); public $substit_lines = array(); /** - * @var array{}|array{models:string,langmodels?:string,fileinit?:string[],returnurl:string} + * @var array{}|array{models:string,langsmodels?:string,fileinit?:string[],returnurl:string} */ public $param = array(); @@ -1946,8 +1946,8 @@ public function setSubstitFromObject($object, $outputlangs) '__PRODUCT_DESCRIPTION__' => isset($line->product_desc) ? $line->product_desc : '', '__LABEL__' => isset($line->label) ? $line->label : '', '__DESCRIPTION__' => isset($line->desc) ? $line->desc : '', - '__DATE_START_YMD__' => dol_print_date($line->date_start, 'day', 0, $outputlangs), - '__DATE_END_YMD__' => dol_print_date($line->date_end, 'day', 0, $outputlangs), + '__DATE_START_YMD__' => dol_print_date($line->date_start, 'day', false, $outputlangs), + '__DATE_END_YMD__' => dol_print_date($line->date_end, 'day', false, $outputlangs), '__QUANTITY__' => $line->qty, '__SUBPRICE__' => price($line->subprice), '__AMOUNT__' => price($line->total_ttc), diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php index e2e326695959d..fdc36ef21c302 100644 --- a/htdocs/core/class/html.formmargin.class.php +++ b/htdocs/core/class/html.formmargin.class.php @@ -211,7 +211,7 @@ public function getMarginInfosArray($object, $force_price = false) */ public function displayMarginInfos($object, $force_price = false) { - global $langs, $conf, $user, $hookmanager; + global $langs, $user, $hookmanager; global $action; if (!empty($user->socid)) { @@ -224,50 +224,53 @@ public function displayMarginInfos($object, $force_price = false) $marginInfo = $this->getMarginInfosArray($object, $force_price); + print '' . "\n"; + $parameters = array('marginInfo' => &$marginInfo); $reshook = $hookmanager->executeHooks('displayMarginInfos', $parameters, $object, $action); if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } elseif (empty($reshook)) { - if (getDolGlobalString('MARGIN_ADD_SHOWHIDE_BUTTON')) { - print $langs->trans('ShowMarginInfos') . ' '; - $hidemargininfos = preg_replace('/[^a-zA-Z0-9_\-]/', '', $_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW']) ?? ''; // Clean cookie - print '' . img_picto($langs->trans("Disabled"), 'switch_off') . ''; - print '' . img_picto($langs->trans("Enabled"), 'switch_on') . ''; + $hidemargininfos = preg_replace('/[^a-zA-Z0-9_\-]/', '', $_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW']) ?? ''; // Clean cookie - print ''; + $buttonToShowHideMargin = ''; + $buttonToShowHideMargin .= img_picto($langs->trans("ShowMarginInfos"), 'switch_off', '', 0, 0, 0, '', 'size15x'); + $buttonToShowHideMargin .= ''; + $buttonToShowHideMargin .= ''; + $buttonToShowHideMargin .= img_picto($langs->trans("Hide"), 'switch_on_grey', '', 0, 0, 0, '', 'size15x opacitymedium'); + $buttonToShowHideMargin .= ''; + + $buttonToShowHideMargin .= ''; - print '' . "\n"; print '
'; print ''; print ''; - print ''; - print ''; + print ''; + print ''; if (getDolGlobalString('MARGIN_TYPE') == "1") { - print ''; + print ''; } else { - print ''; + print ''; } - print ''; + print ''; if (getDolGlobalString('DISPLAY_MARGIN_RATES')) { - print ''; + print ''; } if (getDolGlobalString('DISPLAY_MARK_RATES')) { - print ''; + print ''; } print ''; if (isModEnabled("product")) { //if ($marginInfo['margin_on_products'] != 0 && $marginInfo['margin_on_services'] != 0) { - print ''; + print ''; print ''; print ''; print ''; @@ -282,7 +285,7 @@ public function displayMarginInfos($object, $force_price = false) } if (isModEnabled("service")) { - print ''; + print ''; print ''; print ''; print ''; @@ -297,7 +300,7 @@ public function displayMarginInfos($object, $force_price = false) } if (isModEnabled("product") && isModEnabled("service")) { - print ''; + print ''; print ''; print ''; print ''; @@ -310,7 +313,7 @@ public function displayMarginInfos($object, $force_price = false) } print ''; } - print $hookmanager->resPrint; + print $hookmanager->resPrint; print '
' . $langs->trans('Margins') . '' . $langs->trans('SellingPrice') . '' . $langs->trans('Margins') . ' ' . $buttonToShowHideMargin . '' . $langs->trans('SellingPrice') . '' . $langs->trans('BuyingPrice') . '' . $langs->trans('BuyingPrice') . '' . $langs->trans('CostPrice') . '' . $langs->trans('CostPrice') . '' . $langs->trans('Margin') . '' . $langs->trans('Margin') . '' . $langs->trans('MarginRate') . '' . $langs->trans('MarginRate') . '' . $langs->trans('MarkRate') . '' . $langs->trans('MarkRate') . '
' . $langs->trans('MarginOnProducts') . '' . price($marginInfo['pv_products']) . '' . price($marginInfo['pa_products']) . '
' . $langs->trans('MarginOnServices') . '' . price($marginInfo['pv_services']) . '' . price($marginInfo['pa_services']) . '
' . $langs->trans('TotalMargin') . '' . price($marginInfo['pv_total']) . '' . price($marginInfo['pa_total']) . '
'; print '
'; } elseif ($reshook > 0) { diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index f4c8a736b9993..09a9daa59940a 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -40,6 +40,9 @@ */ class FormOther { + /** + * @var DoliDB + */ private $db; /** @@ -694,7 +697,7 @@ public function selectProjectTasks($selectedtask = 0, $projectid = 0, $htmlname * * @param int $inc Cursor counter * @param int $parent Id of parent task we want to see - * @param array $lines Array of task lines + * @param Task[] $lines Array of task lines * @param int $level Level * @param int $selectedtask Id selected task * @param int $selectedproject Id selected project @@ -831,9 +834,9 @@ public static function showColor($color, $textifnotdefined = '') * @param string $prefix Name of HTML field * @param string $form_name Deprecated. Not used. * @param int $showcolorbox 1=Show color code and color box, 0=Show only color code - * @param array $arrayofcolors Array of colors. Example: array('29527A','5229A3','A32929','7A367A','B1365F','0D7813') + * @param string[] $arrayofcolors Array of colors. Example: array('29527A','5229A3','A32929','7A367A','B1365F','0D7813') * @return void - * @deprecated Use instead selectColor + * @deprecated Use selectColor() * @see selectColor() */ public function select_color($set_color = '', $prefix = 'f_color', $form_name = '', $showcolorbox = 1, $arrayofcolors = []) @@ -1216,16 +1219,23 @@ public function selectyear($selected = '', $htmlname = 'yearid', $useempty = 0, * * @param User $user Object User * @param string $areacode Code of area for pages - 0 = Home page ... See getListOfPagesForBoxes() - * @return array array('selectboxlist'=>, 'boxactivated'=>, 'boxlista'=>, 'boxlistb'=>) + * @return array{selectboxlist:string,boxactivated:ModeleBoxes[],boxlista:string,boxlistb:string} */ public static function getBoxesArea($user, $areacode) { global $conf, $langs, $db; include_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; + // From include + ' + @phan-var-force ModeleBoxes[] $boxactivated + @phan-var-force int[] $boxidactivatedforuser + '; $confuserzone = 'MAIN_BOXES_'.$areacode; + + // $boxactivated will be array of boxes enabled into global setup // $boxidactivatedforuser will be array of boxes chose by user @@ -1541,12 +1551,12 @@ public function selectAutoManual($htmlname, $value = '', $option = 0, $disabled /** * Return HTML select list to select a group by field * - * @param mixed $object Object analyzed - * @param array $search_groupby Array of preselected fields - * @param array $arrayofgroupby Array of groupby to fill - * @param string $morecss More CSS - * @param string $showempty '1' or 'text' - * @return string HTML string component + * @param mixed $object Object analyzed + * @param string[] $search_groupby Array of preselected fields + * @param array $arrayofgroupby Array of groupby to fill + * @param string $morecss More CSS + * @param string $showempty '1' or 'text' + * @return string HTML string component */ public function selectGroupByField($object, $search_groupby, &$arrayofgroupby, $morecss = 'minwidth200 maxwidth250', $showempty = '1') { @@ -1565,8 +1575,8 @@ public function selectGroupByField($object, $search_groupby, &$arrayofgroupby, $ * Return HTML select list to select a group by field * * @param mixed $object Object analyzed - * @param array $search_xaxis Array of preselected fields - * @param array $arrayofxaxis Array of groupby to fill + * @param string[] $search_xaxis Array of preselected fields + * @param array $arrayofxaxis Array of groupby to fill * @param string $showempty '1' or 'text' * @param string $morecss More css * @return string HTML string component diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 05909cfa6102b..6c088bce60f6a 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -1,7 +1,7 @@ - * Copyright (C) 2015 Marcos García - * Copyright (C) 2018 Charlene Benke +/* Copyright (c) 2013 Florian Henry + * Copyright (C) 2015 Marcos García + * Copyright (C) 2018 Charlene Benke * Copyright (C) 2024 Frédéric France * Copyright (C) 2024 MDW * Copyright (C) 2024 Benjamin Falière @@ -402,7 +402,7 @@ public function selectTasks($socid = -1, $selected = 0, $htmlname = 'taskid', $m if (!empty($show_empty)) { $out .= '
'; - print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0, '', '', $langs->transnoentitiesnoconv("Categories")); + print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0, '', '', $langs->transnoentitiesnoconv("Categories")); print "
'; // maring bottom must be same than into print_barre_list + $return .= '
'; // margin bottom must be same than into print_barre_list $return .= ''; if ($picto) { $return .= ''; @@ -6406,8 +6391,8 @@ function print_barre_liste($title, $page, $file, $options = '', $sortfield = '', //print 'totalnboflines='.$totalnboflines.'-savlimit='.$savlimit.'-limit='.$limit.'-num='.$num.'-nextpage='.$nextpage.'-hideselectlimit='.$hideselectlimit.'-hidenavigation='.$hidenavigation; print "\n"; - print "\n"; - print '
'.img_picto('', $picto, 'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath).'
'; // maring bottom must be same than into load_fiche_tire + print "\n"; + print '
'; // margin bottom must be same than into load_fiche_tire // Left @@ -6417,9 +6402,9 @@ function print_barre_liste($title, $page, $file, $options = '', $sortfield = '', print ''; @@ -6685,8 +6670,8 @@ function vatrate($rate, $addpercent = false, $info_bits = 0, $usestarfornpr = 0, * @param int<0,1> $form Type of formatting: 1=HTML, 0=no formatting (no by default) * @param Translate|string|null $outlangs Object langs for output. '' use default lang. 'none' use international separators. * @param int $trunc 1=Truncate if there is more decimals than MAIN_MAX_DECIMALS_SHOWN (default), 0=Does not truncate. Deprecated because amount are rounded (to unit or total amount accuracy) before being inserted into database or after a computation, so this parameter should be useless. - * @param int $rounding MINIMUM number of decimal to show: 0=no change, -1=we use min(getDolGlobalString('MAIN_MAX_DECIMALS_UNIT'), getDolGlobalString('MAIN_MAX_DECIMALS_TOT')) - * @param int|string $forcerounding MAXIMUM number of decimal to forcerounding decimal: -1=no change, -2=keep non zero part, 'MU' or 'MT' or a numeric to round to MU or MT or to a given number of decimal + * @param int<-1,max> $rounding MINIMUM number of decimal to show: 0=no change, -1=we use min(getDolGlobalString('MAIN_MAX_DECIMALS_UNIT'), getDolGlobalString('MAIN_MAX_DECIMALS_TOT')) + * @param ''|'MU'|'MT'|'MS'|'CU'|'CT'|int<-2,max> $forcerounding MAXIMUM number of decimal to forcerounding decimal: -1=no change, -2=keep non zero part, 'MU' or 'MT' or a numeric to round to MU or MT or to a given number of decimal * @param string $currency_code To add currency symbol (''=add nothing, 'auto'=Use default currency, 'XXX'=add currency symbols for XXX currency) * @return string String with formatted amount * @@ -6747,10 +6732,11 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $ if (dol_strlen($decpart) > $nbdecimal) { $nbdecimal = dol_strlen($decpart); } - // Si on depasse max - $max_nbdecimal = (int) str_replace('...', '', getDolGlobalString('MAIN_MAX_DECIMALS_SHOWN')); - if ($trunc && $nbdecimal > $max_nbdecimal) { - $nbdecimal = $max_nbdecimal; + + // If nbdecimal is higher than max to show + $nbdecimalmaxshown = (int) str_replace('...', '', getDolGlobalString('MAIN_MAX_DECIMALS_SHOWN')); + if ($trunc && $nbdecimal > $nbdecimalmaxshown) { + $nbdecimal = $nbdecimalmaxshown; if (preg_match('/\.\.\./i', getDolGlobalString('MAIN_MAX_DECIMALS_SHOWN'))) { // If output is truncated, we show ... $end = '...'; @@ -6801,14 +6787,14 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $ * should be roundtext2num(). * * @param string|float $amount Amount to convert/clean or round - * @param string|int $rounding ''=No rounding - * 'MU'=Round to Max unit price (MAIN_MAX_DECIMALS_UNIT) - * 'MT'=Round to Max for totals with Tax (MAIN_MAX_DECIMALS_TOT) - * 'MS'=Round to Max for stock quantity (MAIN_MAX_DECIMALS_STOCK) - * 'CU'=Round to Max unit price of foreign currency accuracy - * 'CT'=Round to Max for totals with Tax of foreign currency accuracy - * Numeric = Nb of digits for rounding (For example 2 for a percentage) - * @param int $option Put 1 if you know that content is already universal format number (so no correction on decimal will be done) + * @param ''|'MU'|'MT'|'MS'|'CU'|'CT'|int<0,max> $rounding ''=No rounding + * 'MU'=Round to Max unit price (MAIN_MAX_DECIMALS_UNIT) + * 'MT'=Round to Max for totals with Tax (MAIN_MAX_DECIMALS_TOT) + * 'MS'=Round to Max for stock quantity (MAIN_MAX_DECIMALS_STOCK) + * 'CU'=Round to Max unit price of foreign currency accuracy + * 'CT'=Round to Max for totals with Tax of foreign currency accuracy + * Numeric = Nb of digits for rounding (For example 2 for a percentage) + * @param int<0,2> $option Put 1 if you know that content is already universal format number (so no correction on decimal will be done) * Put 2 if you know that number is a user input (so we know we have to fix decimal separator). * @return string Amount with universal numeric format (Example: '99.99999'), or error message. * If conversion fails to return a numeric, it returns: @@ -6946,7 +6932,7 @@ function price2num($amount, $rounding = '', $option = 0) * @param int $unit Unit scale of dimension (Example: 0=kg, -3=g, -6=mg, 98=ounce, 99=pound, ...) * @param string $type 'weight', 'volume', ... * @param Translate $outputlangs Translate language object - * @param int $round -1 = non rounding, x = number of decimal + * @param int<-1,max> $round -1 = non rounding, x = number of decimal * @param string $forceunitoutput 'no' or numeric (-3, -6, ...) compared to $unit (In most case, this value is value defined into $conf->global->MAIN_WEIGHT_DEFAULT_UNIT) * @param int $use_short_label 1=Use short label ('g' instead of 'gram'). Short labels are not translated. * @return string String to show dimensions @@ -7215,7 +7201,12 @@ function getTaxesFromId($vatrate, $buyer = null, $seller = null, $firstparamisid $sql .= ", ".MAIN_DB_PREFIX."c_country as c"; /*if ($mysoc->country_code == 'ES') $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($buyer->country_code)."'"; // vat in spain use the buyer country ?? else $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($seller->country_code)."'";*/ - $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($seller->country_code)."'"; + $sql .= " WHERE t.fk_pays = c.rowid"; + if (getDolGlobalString('SERVICE_ARE_ECOMMERCE_200238EC')) { + $sql .= " AND c.code = '".$db->escape($buyer->country_code)."'"; + } else { + $sql .= " AND c.code = '".$db->escape($seller->country_code)."'"; + } $sql .= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1"; $sql .= " AND t.entity IN (".getEntity('c_tva').")"; if ($vatratecode) { @@ -7609,7 +7600,7 @@ function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, * @param Societe $thirdparty_buyer Thirdparty buyer * @param int $idprod Id product * @param int $idprodfournprice Id supplier price for product - * @return float 0 or 1 + * @return int<0,1> 0 or 1 * @see get_default_tva(), get_default_localtax() */ function get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod = 0, $idprodfournprice = 0) @@ -7693,10 +7684,10 @@ function get_default_localtax($thirdparty_seller, $thirdparty_buyer, $local, $id /** * Return yes or no in current language * - * @param string|int $yesno Value to test (1, 'yes', 'true' or 0, 'no', 'false') - * @param integer $case 1=Yes/No, 0=yes/no, 2=Disabled checkbox, 3=Disabled checkbox + Yes/No - * @param int $color 0=texte only, 1=Text is formatted with a color font style ('ok' or 'error'), 2=Text is formatted with 'ok' color. - * @return string HTML string + * @param int<0, 1>|'yes'|'true'|'no'|'false' $yesno Value to test (1, 'yes', 'true' or 0, 'no', 'false') + * @param integer $case 1=Yes/No, 0=yes/no, 2=Disabled checkbox, 3=Disabled checkbox + Yes/No + * @param int $color 0=texte only, 1=Text is formatted with a color font style ('ok' or 'error'), 2=Text is formatted with 'ok' color. + * @return string HTML string */ function yn($yesno, $case = 1, $color = 0) { @@ -8984,10 +8975,10 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__REF_SUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); $substitutionarray['__NOTE_PUBLIC__'] = (isset($object->note_public) ? $object->note_public : null); $substitutionarray['__NOTE_PRIVATE__'] = (isset($object->note_private) ? $object->note_private : null); - $substitutionarray['__DATE_CREATION__'] = (isset($object->date_creation) ? dol_print_date($object->date_creation, 'day', 0, $outputlangs) : ''); - $substitutionarray['__DATE_MODIFICATION__'] = (isset($object->date_modification) ? dol_print_date($object->date_modification, 'day', 0, $outputlangs) : ''); - $substitutionarray['__DATE_VALIDATION__'] = (isset($object->date_validation) ? dol_print_date($object->date_validation, 'day', 0, $outputlangs) : ''); - $substitutionarray['__DATE_DELIVERY__'] = (isset($object->date_delivery) ? dol_print_date($object->date_delivery, 'day', 0, $outputlangs) : ''); + $substitutionarray['__DATE_CREATION__'] = (isset($object->date_creation) ? dol_print_date($object->date_creation, 'day', false, $outputlangs) : ''); + $substitutionarray['__DATE_MODIFICATION__'] = (isset($object->date_modification) ? dol_print_date($object->date_modification, 'day', false, $outputlangs) : ''); + $substitutionarray['__DATE_VALIDATION__'] = (isset($object->date_validation) ? dol_print_date($object->date_validation, 'day', false, $outputlangs) : ''); + $substitutionarray['__DATE_DELIVERY__'] = (isset($object->date_delivery) ? dol_print_date($object->date_delivery, 'day', false, $outputlangs) : ''); $substitutionarray['__DATE_DELIVERY_DAY__'] = (isset($object->date_delivery) ? dol_print_date($object->date_delivery, "%d") : ''); $substitutionarray['__DATE_DELIVERY_DAY_TEXT__'] = (isset($object->date_delivery) ? dol_print_date($object->date_delivery, "%A") : ''); $substitutionarray['__DATE_DELIVERY_MON__'] = (isset($object->date_delivery) ? dol_print_date($object->date_delivery, "%m") : ''); @@ -9000,7 +8991,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, // For backward compatibility (deprecated) $substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null)); $substitutionarray['__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); - $substitutionarray['__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, 'day', 0, $outputlangs) : ''); + $substitutionarray['__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, 'day', false, $outputlangs) : ''); $substitutionarray['__SUPPLIER_ORDER_DELAY_DELIVERY__'] = (isset($object->availability_code) ? ($outputlangs->transnoentities("AvailabilityType".$object->availability_code) != 'AvailabilityType'.$object->availability_code ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability : '')) : ''); $substitutionarray['__EXPIRATION_DATE__'] = (isset($object->fin_validite) ? dol_print_date($object->fin_validite, 'daytext') : ''); @@ -9358,10 +9349,10 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, '@phan-var-force Facture|FactureRec $object'; include_once DOL_DOCUMENT_ROOT.'/core/lib/functionsnumtoword.lib.php'; - $substitutionarray['__DATE_YMD__'] = is_object($object) ? (isset($object->date) ? dol_print_date($object->date, 'day', 0, $outputlangs) : null) : ''; - $substitutionarray['__DATE_DUE_YMD__'] = is_object($object) ? (isset($object->date_lim_reglement) ? dol_print_date($object->date_lim_reglement, 'day', 0, $outputlangs) : null) : ''; - $substitutionarray['__DATE_YMD_TEXT__'] = is_object($object) ? (isset($object->date) ? dol_print_date($object->date, 'daytext', 0, $outputlangs) : null) : ''; - $substitutionarray['__DATE_DUE_YMD_TEXT__'] = is_object($object) ? (isset($object->date_lim_reglement) ? dol_print_date($object->date_lim_reglement, 'daytext', 0, $outputlangs) : null) : ''; + $substitutionarray['__DATE_YMD__'] = is_object($object) ? (isset($object->date) ? dol_print_date($object->date, 'day', false, $outputlangs) : null) : ''; + $substitutionarray['__DATE_DUE_YMD__'] = is_object($object) ? (isset($object->date_lim_reglement) ? dol_print_date($object->date_lim_reglement, 'day', false, $outputlangs) : null) : ''; + $substitutionarray['__DATE_YMD_TEXT__'] = is_object($object) ? (isset($object->date) ? dol_print_date($object->date, 'daytext', false, $outputlangs) : null) : ''; + $substitutionarray['__DATE_DUE_YMD_TEXT__'] = is_object($object) ? (isset($object->date_lim_reglement) ? dol_print_date($object->date_lim_reglement, 'daytext', false, $outputlangs) : null) : ''; $already_payed_all = 0; if (is_object($object) && ($object instanceof Facture)) { @@ -9827,10 +9818,11 @@ function dolGetFirstLastname($firstname, $lastname, $nameorder = -1) * @param string|string[] $mesgs Message string or array * @param string $style Which style to use ('mesgs' by default, 'warnings', 'errors') * @param int $noduplicate 1 means we do not add the message if already present in session stack + * @param int $attop Add the message in the top of the stack (at bottom by default) * @return void * @see dol_htmloutput_events() */ -function setEventMessage($mesgs, $style = 'mesgs', $noduplicate = 0) +function setEventMessage($mesgs, $style = 'mesgs', $noduplicate = 0, $attop = 0) { //dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING); This is not deprecated, it is used by setEventMessages function if (!is_array($mesgs)) { @@ -9840,7 +9832,11 @@ function setEventMessage($mesgs, $style = 'mesgs', $noduplicate = 0) if (!empty($noduplicate) && isset($_SESSION['dol_events'][$style]) && in_array($mesgs, $_SESSION['dol_events'][$style])) { return; } - $_SESSION['dol_events'][$style][] = $mesgs; + if ($attop) { + array_unshift($_SESSION['dol_events'][$style], $mesgs); + } else { + $_SESSION['dol_events'][$style][] = $mesgs; + } } } else { // If mesgs is an array @@ -9850,7 +9846,11 @@ function setEventMessage($mesgs, $style = 'mesgs', $noduplicate = 0) if (!empty($noduplicate) && isset($_SESSION['dol_events'][$style]) && in_array($mesg, $_SESSION['dol_events'][$style])) { return; } - $_SESSION['dol_events'][$style][] = $mesg; + if ($attop) { + array_unshift($_SESSION['dol_events'][$style], $mesgs); + } else { + $_SESSION['dol_events'][$style][] = $mesg; + } } } } @@ -9865,10 +9865,11 @@ function setEventMessage($mesgs, $style = 'mesgs', $noduplicate = 0) * @param string $style Which style to use ('mesgs' by default, 'warnings', 'errors') * @param string $messagekey A key to be used to allow the feature "Never show this message during this session again" * @param int $noduplicate 1 means we do not add the message if already present in session stack + * @param int $attop Add the message in the top of the stack (at bottom by default) * @return void * @see dol_htmloutput_events() */ -function setEventMessages($mesg, $mesgs, $style = 'mesgs', $messagekey = '', $noduplicate = 0) +function setEventMessages($mesg, $mesgs, $style = 'mesgs', $messagekey = '', $noduplicate = 0, $attop = 0) { if (empty($mesg) && empty($mesgs)) { dol_syslog("Try to add a message in stack, but value to add is empty message", LOG_WARNING); @@ -9878,17 +9879,17 @@ function setEventMessages($mesg, $mesgs, $style = 'mesgs', $messagekey = '', $no // TODO $mesg .= ''; } - if (empty($messagekey) || empty($_COOKIE["DOLHIDEMESSAGE".$messagekey])) { + if (empty($messagekey) || empty($_COOKIE["DOLUSER_HIDEMESSAGE".$messagekey])) { if (!in_array((string) $style, array('mesgs', 'warnings', 'errors'))) { dol_print_error(null, 'Bad parameter style='.$style.' for setEventMessages'); } if (empty($mesgs)) { - setEventMessage($mesg, $style, $noduplicate); + setEventMessage($mesg, $style, $noduplicate, $attop); } else { if (!empty($mesg) && !in_array($mesg, $mesgs)) { - setEventMessage($mesg, $style, $noduplicate); // Add message string if not already into array + setEventMessage($mesg, $style, $noduplicate, $attop); // Add message string if not already into array } - setEventMessage($mesgs, $style, $noduplicate); + setEventMessage($mesgs, $style, $noduplicate, $attop); } } } @@ -12384,7 +12385,7 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st $dolGetBadgeParams['attr']['title'] = empty($params['tooltip']) ? $statusLabel : ($params['tooltip'] != 'no' ? $params['tooltip'] : ''); } else { // If a title was forced from $params['badgeParams']['attr']['title'], we set the class to get it as a tooltip. $dolGetBadgeParams['attr']['class'] .= ' classfortooltip'; - // And if we use tooltip, we can output title in HTML + // And if we use tooltip, we can output title in HTML @phan-suppress-next-line PhanTypeInvalidDimOffset $dolGetBadgeParams['attr']['title'] = dol_htmlentitiesbr($dolGetBadgeParams['attr']['title'], 1); } @@ -12408,17 +12409,17 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st * @param string $text Optional : short label on button. Can be escaped HTML content or full simple text. * @param string $actionType 'default', 'danger', 'email', 'clone', 'cancel', 'delete', ... * - * @param string|array $url Url for link or array of subbutton description + * @param string|array}> $url Url for link or array of subbutton description * - * Example when an array is used: $arrayforbutaction = array( - * 10 => array('lang'=>'propal', 'enabled'=>isModEnabled("propal"), 'perm'=>$user->hasRight('propal', 'creer'), 'label' => 'AddProp', 'url'=>'/comm/propal/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid), - * 20 => array('lang'=>'orders', 'enabled'=>isModEnabled("order"), 'perm'=>$user->hasRight('commande', 'creer'), 'label' => 'CreateOrder', 'url'=>'/commande/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid), - * 30 => array('lang'=>'bills', 'enabled'=>isModEnabled("invoice"), 'perm'=>$user->hasRight('facture', 'creer'), 'label' => 'CreateBill', 'url'=>'/compta/facture/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid), - * ); + * Example when an array is used: + * $arrayforbutaction = array( + * 10 => array('attr' => array('class'=>''), 'lang'=>'propal', 'enabled'=>isModEnabled("propal"), 'perm'=>$user->hasRight('propal', 'creer'), 'label' => 'AddProp', 'url'=>'/comm/propal/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid), + * 20 => array('attr' => array('class'=>''), 'lang'=>'mymodule', 'enabled'=>isModEnabled("mymodule"), 'perm'=>$user->hasRight('mymodule', 'write'), 'label' => 'MyModuleAction', 'urlroot'=>dol_build_patch('/mymodule/mypage.php?action=create')), + * ); ); * @param string $id Attribute id of action button. Example 'action-delete'. This can be used for full ajax confirm if this code is reused into the ->formconfirm() method. * @param int|boolean $userRight User action right * // phpcs:disable - * @param array $params = [ // Various params for future : recommended rather than adding more function arguments + * @param array{confirm?:array{url?:string,title?:string,content?:string,action-btn-label?:string,cancel-btn-label?:string,modal?:bool},attr?:array,areDropdownButtons?:bool,backtopage?:string,lang?:string,enabled?:bool,perm?:int<0,1>,label?:string,url?:string,isDropdown?:int<0,1>,isDropDown?:int<0,1>} $params = [ // Various params for future : recommended rather than adding more function arguments * 'attr' => [ // to add or override button attributes * 'xxxxx' => '', // your xxxxx attribute you want * 'class' => 'reposition', // to add more css class to the button class attribute @@ -12431,7 +12432,7 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st * 'cancel-btn-label' => '', // Override label of cancel button, if empty default label use "CloseDialog" lang key * 'content' => '', // Override text of content, if empty default content use "ConfirmBtnCommonContent" lang key * 'modal' => true, // true|false to display dialog as a modal (with dark background) - * 'isDropDrown' => false, // true|false to display dialog as a dropdown (with dark background) + * 'isDropDown' => false, // true|false to display dialog as a dropdown list (css dropdown-item with dark background) * ], * ] * // phpcs:enable @@ -12452,7 +12453,7 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url = $out = ''; - if (isset($params["areDropdownButtons"]) && $params["areDropdownButtons"] === false) { + if (array_key_exists('areDropdownButtons', $params) && $params["areDropdownButtons"] === false) { // @phan-suppress-current-line PhanTypeInvalidDimOffset foreach ($url as $button) { if (!empty($button['lang'])) { $langs->load($button['lang']); @@ -12461,11 +12462,11 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url = $text = $button['text'] ?? ''; $actionType = $button['actionType'] ?? ''; $tmpUrl = DOL_URL_ROOT.$button['url'].(empty($params['backtopage']) ? '' : '&backtopage='.urlencode($params['backtopage'])); - $id = $button['$id'] ?? ''; + $id = $button['id'] ?? ''; $userRight = $button['perm'] ?? 1; - $params = $button['$params'] ?? []; + $button['params'] = $button['params'] ?? []; // @phan-suppress-current-line PhanPluginDuplicateExpressionAssignmentOperation - $out .= dolGetButtonAction($label, $text, $actionType, $tmpUrl, $id, $userRight, $params); + $out .= dolGetButtonAction($label, $text, $actionType, $tmpUrl, $id, $userRight, $button['params']); } return $out; } @@ -12478,8 +12479,20 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url = if (!empty($subbutton['lang'])) { $langs->load($subbutton['lang']); } - $tmpurl = DOL_URL_ROOT.$subbutton['url'].(empty($params['backtopage']) ? '' : '&backtopage='.urlencode($params['backtopage'])); - $out .= dolGetButtonAction('', $langs->trans($subbutton['label']), 'default', $tmpurl, '', $subbutton['perm'], array('isDropDown' => true)); + + if (!empty($subbutton['urlroot'])) { + $tmpurl = $subbutton['urlroot'].(empty($params['backtopage']) ? '' : '&backtopage='.urlencode($params['backtopage'])); + } else { + $tmpurl = DOL_URL_ROOT.$subbutton['url'].(empty($params['backtopage']) ? '' : '&backtopage='.urlencode($params['backtopage'])); + } + + $subbuttonparam = array(); + if (!empty($subbutton['attr'])) { + $subbuttonparam['attr'] = $subbutton['attr']; + } + $subbuttonparam['isDropDown'] = (empty($params['isDropDown']) ? $subbutton['isDropDown'] : $params['isDropDown']); + + $out .= dolGetButtonAction('', $langs->trans($subbutton['label']), 'default', $tmpurl, $subbutton['id'] ?? '', $subbutton['perm'], $subbuttonparam); } $out .= ""; $out .= ""; @@ -12488,8 +12501,14 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url = if (!empty($subbutton['lang'])) { $langs->load($subbutton['lang']); } - $tmpurl = DOL_URL_ROOT.$subbutton['url'].(empty($params['backtopage']) ? '' : '&backtopage='.urlencode($params['backtopage'])); - $out .= dolGetButtonAction('', $langs->trans($subbutton['label']), 'default', $tmpurl, '', $subbutton['perm']); + + if (!empty($subbutton['urlroot'])) { + $tmpurl = $subbutton['urlroot'].(empty($params['backtopage']) ? '' : '&backtopage='.urlencode($params['backtopage'])); + } else { + $tmpurl = DOL_URL_ROOT.$subbutton['url'].(empty($params['backtopage']) ? '' : '&backtopage='.urlencode($params['backtopage'])); + } + + $out .= dolGetButtonAction('', $langs->trans($subbutton['label']), 'default', $tmpurl, '', $subbutton['perm'], $params); } } @@ -12498,7 +12517,7 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url = // Here, $url is a simple link - if (!empty($params['isDropdown'])) { + if (!empty($params['isDropdown']) || !empty($params['isDropDown'])) { // Use the dropdown-item style (not for action button) $class = "dropdown-item"; } else { $class = 'butAction'; @@ -12635,7 +12654,7 @@ function dolGetButtonTitleSeparator($moreClass = "") /** * get field error icon * - * @param string $fieldValidationErrorMsg message to add in tooltip + * @param string $fieldValidationErrorMsg Message to add in tooltip * @return string html output */ function getFieldErrorIcon($fieldValidationErrorMsg) @@ -13126,7 +13145,7 @@ function getElementProperties($elementType) * @param string $element_ref Element ref (Use this or element_id but not both. If id and ref are empty, object with no fetch is returned) * @param int<0,2> $useCache If you want to store object in cache or get it from cache 0 => no use cache , 1 use cache, 2 force reload cache * @param int $maxCacheByType Number of object in cache for this element type - * @return int<-1,0>|object object || 0 || <0 if error + * @return int<-1,0>|CommonObject object || 0 || <0 if error * @see getElementProperties() */ function fetchObjectByElement($element_id, $element_type, $element_ref = '', $useCache = 0, $maxCacheByType = 10) @@ -13481,7 +13500,7 @@ function jsonOrUnserialize($stringtodecode) /** * forgeSQLFromUniversalSearchCriteria * - * @param string $filter String with universal search string. Must be '(aaa:bbb:ccc) OR (ddd:eeee:fff) ...' with + * @param ?string $filter String with universal search string. Must be '(aaa:bbb:ccc) OR (ddd:eeee:fff) ...' with * aaa is a field name (with alias or not) and * bbb is one of this operator '=', '<', '>', '<=', '>=', '!=', 'in', 'notin', 'like', 'notlike', 'is', 'isnot'. * ccc must not contains ( or ) @@ -13498,7 +13517,7 @@ function forgeSQLFromUniversalSearchCriteria($filter, &$errorstr = '', $noand = { global $db, $user; - if ($filter === '') { + if (is_null($filter) || !is_string($filter) || $filter === '') { return ''; } if (!preg_match('/^\(.*\)$/', $filter)) { // If $filter does not start and end with () @@ -13941,15 +13960,7 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = null, $sql .= ", sp.lastname, sp.firstname"; } elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') { $sql .= ", m.lastname, m.firstname"; - } elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') { - $sql .= ", o.ref"; - } elseif (is_object($filterobj) && get_class($filterobj) == 'Product') { - $sql .= ", o.ref"; - } elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') { - $sql .= ", o.ref"; - } elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') { - $sql .= ", o.ref"; - } elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') { + } elseif (is_object($filterobj) && in_array(get_class($filterobj), array('Commande', 'CommandeFournisseur', 'Product', 'Ticket', 'BOM', 'Contrat', 'Facture', 'FactureFournisseur'))) { $sql .= ", o.ref"; } $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; @@ -14000,6 +14011,11 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = null, if ($filterobj->id) { $sql .= " AND a.fk_element = ".((int) $filterobj->id); } + } elseif (is_object($filterobj) && get_class($filterobj) == 'Commande') { + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'order'"; + if ($filterobj->id) { + $sql .= " AND a.fk_element = ".((int) $filterobj->id); + } } elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') { $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'"; if ($filterobj->id) { @@ -14031,9 +14047,14 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = null, $sql .= " AND a.fk_contact = ".((int) $filterobj->id); } } elseif (is_object($filterobj) && get_class($filterobj) == 'Facture') { - $sql .= "AND a.fk_element = o.rowid"; + $sql .= " AND a.fk_element = o.rowid"; if ($filterobj->id) { - $sql .= " AND a.fk_element = ".((int) $filterobj->id); + $sql .= " AND a.fk_element = ".((int) $filterobj->id)." AND a.elementtype = 'invoice'"; + } + } elseif (is_object($filterobj) && get_class($filterobj) == 'FactureFournisseur') { + $sql .= " AND a.fk_element = o.rowid"; + if ($filterobj->id) { + $sql .= " AND a.fk_element = ".((int) $filterobj->id)." AND a.elementtype = 'invoice_supplier'"; } } } else { @@ -14041,7 +14062,7 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = null, } // Condition on actioncode - if (!empty($actioncode)) { + if (!empty($actioncode) && $actioncode != '-1') { if (!getDolGlobalString('AGENDA_USE_EVENT_TYPE')) { if ($actioncode == 'AC_NON_AUTO') { $sql .= " AND c.type != 'systemauto'"; @@ -14256,17 +14277,19 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = null, $out .= ''; } - $out .= getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', '', $param, '', $sortfield, $sortorder, '')."\n"; + // Date + $out .= getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', '', $param, '', $sortfield, $sortorder, 'nowraponall nopaddingleftimp ')."\n"; - $out .= ''; + $out .= ''; if ($donetodo) { $out .= ''; } + // Type of event $out .= ''; + // Label $out .= ''; @@ -14281,7 +14304,6 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = null, $out .= ''; - $out .= '
'; print '
'; - print $title; // $title may contains HTML + print ''.dolPrintLabel($title).''; // $title may contains HTML if (!empty($title) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '') { - print '('.$totalnboflines.')'; + print '('.$totalnboflines.')'; } print '
'.$langs->trans("Search").' : '.$langs->trans("Search").' : '; - $out .= ''; - //$out .= img_picto($langs->trans("Type"), 'type'); - $out .= $formactions->select_type_actions($actioncode, "actioncode", '', !getDolGlobalString('AGENDA_USE_EVENT_TYPE') ? 1 : -1, 0, 0, 1, 'minwidth200imp'); + $out .= ''; + $out .= $formactions->select_type_actions($actioncode, "actioncode", '', getDolGlobalString('AGENDA_USE_EVENT_TYPE') ? -1 : 1, 0, 0, 1, 'selecttype minwidth100', $langs->trans("Type")); $out .= ''; $out .= ''; $out .= '
'; $out .= ''; @@ -14641,7 +14663,7 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = null, /** * Helper function that combines values of a dolibarr DatePicker (such as Form::selectDate) for year, month, day (and - * optionally hour, minute, second) fields to return a a portion of URL reproducing the values from the current HTTP + * optionally hour, minute, second) fields to return a portion of URL reproducing the values from the current HTTP * request. * * @param string $prefix Prefix used to build the date selector (for instance using Form::selectDate) @@ -14676,14 +14698,13 @@ function buildParamDate($prefix, $timestamp = null, $hourTime = '', $gm = 'auto' * whether to include the header and footer, and if only the message should be shown without additional details. * The function also supports executing additional hooks for customized handling of error pages. * - * @param string $message Custom error message to display. If empty, a default "Record Not Found" message is shown. - * @param int<0,1> $printheader Determines if the page header should be printed (1 = yes, 0 = no). - * @param int<0,1> $printfooter Determines if the page footer should be printed (1 = yes, 0 = no). - * @param int<0,1> $showonlymessage If set to 1, only the error message is displayed without any additional information or hooks. - * @param mixed $params Optional parameters to pass to hooks for further processing or customization. + * @param string $message Custom error message to display. If empty, a default "Record Not Found" message is shown. + * @param int<0,1> $printheader Determines if the page header should be printed (1 = yes, 0 = no). + * @param int<0,1> $printfooter Determines if the page footer should be printed (1 = yes, 0 = no). + * @param int<0,1> $showonlymessage If set to 1, only the error message is displayed without any additional information or hooks. + * @param mixed $params Optional parameters to pass to hooks for further processing or customization. * @global Conf $conf Dolibarr configuration object (global) * @global DoliDB $db Database connection object (global) - * @global User $user Current user object (global) * @global Translate $langs Language translation object, initialized within the function if not already. * @global HookManager $hookmanager Hook manager object, initialized within the function if not already for executing hooks. * @global string $action Current action, can be modified by hooks. diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 07fae627c56b9..115baba4bee01 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -117,10 +117,10 @@ function dolGetModulesDirs($subdir = '') /** * Try to guess default paper format according to language into $langs * - * @param Translate|null $outputlangs Output lang to use to autodetect output format if setup not done + * @param ?Translate $outputlangs Output lang to use to autodetect output format if setup not done * @return string Default paper format code */ -function dol_getDefaultFormat(Translate $outputlangs = null) +function dol_getDefaultFormat($outputlangs = null) { global $langs; @@ -143,8 +143,8 @@ function dol_getDefaultFormat(Translate $outputlangs = null) * Show information on an object * TODO Move this into html.formother * - * @param object $object Object to show - * @param int $usetable Output into a table + * @param object|CommonObject $object Object to show + * @param int $usetable Output into a table * @return void */ function dol_print_object_info($object, $usetable = 0) @@ -361,8 +361,10 @@ function dol_print_object_info($object, $usetable = 0) } else { print ': '; } + // user_approve is not defined in Dolibarr code @phan-suppress-next-line PhanUndeclaredProperty if (!empty($object->user_approve) && is_object($object->user_approve)) { - if ($object->user_approve->id) { + if ($object->user_approve->id) { // @phan-suppress-current-line PhanUndeclaredProperty + // @phan-suppress-next-line PhanUndeclaredProperty,PhanPluginUnknownObjectMethodCall print $object->user_approve->getNomUrl(-1, '', 0, 0, 0); } else { print $langs->trans("Unknown"); @@ -385,6 +387,7 @@ function dol_print_object_info($object, $usetable = 0) // Date approve if (!empty($object->date_approve) || !empty($object->date_approval)) { + '@phan-var-force ExpenseReport|CommandeFournisseur $object'; if ($usetable) { print ''; } @@ -407,6 +410,7 @@ function dol_print_object_info($object, $usetable = 0) // User approve if (!empty($object->user_approve_id2)) { + '@phan-var-force CommandeFournisseur $object'; if ($usetable) { print ''; } @@ -454,6 +458,7 @@ function dol_print_object_info($object, $usetable = 0) // User signature if (!empty($object->user_signature) || !empty($object->user_signature_id)) { + '@phan-var-force Propal $object'; if ($usetable) { print ''; } @@ -559,6 +564,7 @@ function dol_print_object_info($object, $usetable = 0) // User conciliate if (!empty($object->user_rappro) || !empty($object->user_rappro_id)) { + '@phan-var-force Account $object'; if ($usetable) { print ''; } @@ -569,8 +575,10 @@ function dol_print_object_info($object, $usetable = 0) print ': '; } if (is_object($object->user_rappro)) { - if ($object->user_rappro->id) { - print $object->user_rappro->getNomUrl(-1, '', 0, 0, 0); + $user_rappro = $object->user_rappro; + '@phan-var-force User $user_rappro'; + if ($user_rappro->id) { + print $user_rappro->getNomUrl(-1, '', 0, 0, 0); } else { print $langs->trans("Unknown"); } @@ -590,8 +598,9 @@ function dol_print_object_info($object, $usetable = 0) } } - // Date conciliate + // Date conciliate Note: date_rappro is not found on Dolibarr classes if (!empty($object->date_rappro)) { + // Datte if ($usetable) { print ''; } @@ -601,9 +610,9 @@ function dol_print_object_info($object, $usetable = 0) } else { print ': '; } - print dol_print_date($object->date_rappro, 'dayhour', 'tzserver'); + print dol_print_date($object->date_rappro, 'dayhour', 'tzserver'); // @phan-suppress-current-line PhanUndeclaredProperty if ($deltadateforuser) { - print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_rappro, "dayhour", 'tzuserrel').'  '.$langs->trans("ClientHour").''; + print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_rappro, "dayhour", 'tzuserrel').'  '.$langs->trans("ClientHour").''; // @phan-suppress-current-line PhanUndeclaredProperty } if ($usetable) { print ''; @@ -614,6 +623,7 @@ function dol_print_object_info($object, $usetable = 0) // Date send if (!empty($object->date_envoi)) { + '@phan-var-force Mailing $object'; if ($usetable) { print ''; } @@ -893,12 +903,12 @@ function array2table($data, $tableMarkup = 1, $tableoptions = '', $troptions = ' * @param string $table Table containing field with counter * @param string $field Field containing already used values of counter * @param string $where To add a filter on selection (for example to filter on invoice types) - * @param Societe|'' $objsoc The company that own the object we need a counter for - * @param string $date Date to use for the {y},{m},{d} tags. + * @param null|Societe|'' $objsoc The company that own the object we need a counter for + * @param int|'' $date Date to use for the {y},{m},{d} tags. is timestamp or '' to use dol_now() * @param string $mode 'next' for next value or 'last' for last value * @param bool $bentityon Activate the entity filter. Default is true (for modules not compatible with multicompany) - * @param User $objuser Object user we need data from. - * @param int $forceentity Entity id to force + * @param ?User $objuser Object user we need data from. + * @param ?string $forceentity Entity id to force, can be '0' or '1' or '1,2' etc * @return string New value (numeric) or error message */ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $date = '', $mode = 'next', $bentityon = true, $objuser = null, $forceentity = null) @@ -906,7 +916,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ global $user; if (!is_object($objsoc)) { - $valueforccc = $objsoc; + $valueforccc = (string) $objsoc; } elseif ($table == "commande_fournisseur" || $table == "facture_fourn" || $table == "paiementfourn") { $valueforccc = dol_string_unaccent($objsoc->code_fournisseur); } else { @@ -930,8 +940,12 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ //$mask='FA{yy}{mm}-{0000@99}'; //$date=dol_mktime(12, 0, 0, 1, 1, 1900); //$date=dol_stringtotime('20130101'); - $hasglobalcounter = false; + $maskrefclient_maskcounter = ''; + $maskrefclient_clientcode = ''; + $maskrefclient_maskclientcode = ''; + $maskrefclient_maskoffset = ''; + $reg = array(); // Extract value for mask counter, mask raz and mask offset if (preg_match('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i', $mask, $reg)) { @@ -1156,6 +1170,8 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $yearcomp1 = sprintf("%04d", idate("Y", $date) + $yearoffset + 1); } elseif ($yearlen == 2) { $yearcomp1 = sprintf("%02d", idate("y", $date) + $yearoffset + 1); + } else { + $yearcomp1 = ''; } $sqlwhere .= "("; @@ -1408,7 +1424,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ if (dol_strlen($maskrefclient_maskcounter) > 0) { $maskrefclient_maskafter .= str_pad((string) $maskrefclient_counter, dol_strlen($maskrefclient_maskcounter), "0", STR_PAD_LEFT); } - $numFinal = str_replace($maskrefclient_maskbefore, $maskrefclient_maskafter, $numFinal); + $numFinal = str_replace($maskrefclient_maskbefore, (string) $maskrefclient_maskafter, $numFinal); } // Now we replace the type @@ -1470,6 +1486,8 @@ function check_value($mask, $value) $result = 0; $hasglobalcounter = false; + $maskrefclient_maskcounter = ''; + // Extract value for mask counter, mask raz and mask offset $reg = array(); if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $mask, $reg)) { @@ -1639,6 +1657,10 @@ function numero_semaine($time) $annee = (int) $reg[1]; $mois = (int) $reg[2]; $jour = (int) $reg[3]; + } else { + $annee = 0; + $mois = 0; + $jour = 0; } /* @@ -1738,7 +1760,7 @@ function weight_convert($weight, &$from_unit, $to_unit) * @param DoliDB $db Handler database * @param Conf $conf Object conf * @param User $user Object user - * @param array $tab Array (key=>value) with all parameters to save/update + * @param array $tab Array (key=>value) with all parameters to save/update * @return int Return integer <0 if KO, >0 if OK * * @see dolibarr_get_const(), dolibarr_set_const(), dolibarr_del_const() @@ -1941,7 +1963,7 @@ function getListOfModels($db, $type, $maxfilenamelength = 0) } if (is_dir($tmpdir)) { // all type of template is allowed - $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '', null, 'name', SORT_ASC, 0); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '', array(), 'name', SORT_ASC, 0); if (count($tmpfiles)) { $listoffiles = array_merge($listoffiles, $tmpfiles); } @@ -2044,7 +2066,7 @@ function dol_buildlogin($lastname, $firstname) /** * Return array to use for SoapClient constructor * - * @return array + * @return array{connection_timeout:int,response_timeout:int,proxy_use:int<0,1>,proxy_host:false|string,proxy_port:false|string,proxy_login:false|string,proxy_password:false|string,trace:int<0,1>} */ function getSoapParams() { @@ -2284,7 +2306,7 @@ function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent) $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree." SET ".$fieldfkparent." = 0 WHERE ".$fieldfkparent." = rowid"; // So we update only records linked to themself $resql = $db->query($sql); if ($resql) { - $nb = $db->affected_rows($sql); + $nb = $db->affected_rows($resql); if ($nb > 0) { print '
Some record that were parent of themself were cleaned.'; } @@ -2323,7 +2345,7 @@ function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent) $sql .= " WHERE rowid IN (".$db->sanitize(implode(',', $listofidtoclean)).")"; // So we update only records detected wrong $resql = $db->query($sql); if ($resql) { - $nb = $db->affected_rows($sql); + $nb = $db->affected_rows($resql); if ($nb > 0) { // Removed orphelins records print '
Some records were detected to have parent that is a child, we set them as root record for id: '; @@ -2340,7 +2362,7 @@ function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent) $sql .= " WHERE ".$db->sanitize($fieldfkparent)." NOT IN (".$db->sanitize(implode(',', $listofid), 1).")"; // So we update only records linked to a non existing parent $resql = $db->query($sql); if ($resql) { - $nb = $db->affected_rows($sql); + $nb = $db->affected_rows($resql); if ($nb > 0) { // Removed orphelins records print '
Some orphelins were found and modified to be parent so records are visible again for id: '; @@ -2362,7 +2384,7 @@ function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent) * Convert an array with RGB value into hex RGB value. * This is the opposite function of colorStringToArray * - * @param array $arraycolor Array + * @param array{0:int,1:int,2:int} $arraycolor Array * @param string $colorifnotfound Color code to return if entry not defined or not a RGB format * @return string RGB hex value (without # before). For example: 'FF00FF', '01FF02' * @see colorStringToArray(), colorHexToRgb() @@ -2383,9 +2405,9 @@ function colorArrayToHex($arraycolor, $colorifnotfound = '888888') * This is the opposite function of colorArrayToHex. * If entry is already an array, return it. * - * @param string $stringcolor String with hex (FFFFFF) or comma RGB ('255,255,255') - * @param array $colorifnotfound Color code array to return if entry not defined - * @return array RGB hex value (without # before). For example: FF00FF + * @param string $stringcolor String with hex (FFFFFF) or comma RGB ('255,255,255') + * @param array{0:int,1:int,2:int}|array{} $colorifnotfound Color code array to return if entry not defined + * @return array{0:int,1:int,2:int} RGB hex value (without # before). For example: FF00FF * @see colorArrayToHex(), colorHexToRgb() */ function colorStringToArray($stringcolor, $colorifnotfound = array(88, 88, 88)) @@ -2396,7 +2418,8 @@ function colorStringToArray($stringcolor, $colorifnotfound = array(88, 88, 88)) $reg = array(); $tmp = preg_match('/^#?([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])$/', $stringcolor, $reg); if (!$tmp) { - $tmp = explode(',', $stringcolor); + $tmp = array_map('intval', explode(',', $stringcolor)); + '@phan-var-force int[] $tmp'; if (count($tmp) < 3) { return $colorifnotfound; } @@ -2624,8 +2647,8 @@ function colorHexToHsl($hex, $alpha = false, $returnArray = false) * Applies the Cartesian product algorithm to an array * Source: http://stackoverflow.com/a/15973172 * - * @param array $input Array of products - * @return array Array of combinations + * @param array $input Array of products + * @return array> Array of combinations */ function cartesianArray(array $input) { @@ -3020,9 +3043,9 @@ function getArrayOfEmojiBis() /** * Remove EMoji from email content * - * @param string $text String to sanitize - * @param int $allowedemoji Mode to allow emoji - * @return string Sanitized string + * @param string $text String to sanitize + * @param int<0,2> $allowedemoji Mode to allow emoji + * @return string Sanitized string */ function removeEmoji($text, $allowedemoji = 1) { @@ -3052,3 +3075,62 @@ function removeEmoji($text, $allowedemoji = 1) return $text; } + + +/** + * Clean a cell to respect rules of CSV file cells + * + * @param string $newvalue String to clean (must be UTF-8 encoded) + * @param string $charset Expected output character set ('UTF-8', 'ISO-8859-1', ...). Default '' will use the value into EXPORT_CSV_FORCE_CHARSET. + * @param string $separator CSV char separator (often ',' or ';'). Default '' will use the value into EXPORT_CSV_SEPARATOR_TO_USE. + * @return string Value cleaned + */ +function csvClean($newvalue, $charset = '', $separator = '') +{ + global $langs; + + $addquote = 0; + + if (empty($charset)) { + $charset = getDolGlobalString('EXPORT_CSV_FORCE_CHARSET'); + } + if (empty($separator)) { + $separator = getDolGlobalString('EXPORT_CSV_SEPARATOR_TO_USE'); + } + + + $newvalue = $langs->convToOutputCharset($newvalue, 'UTF-8', $charset); // newvalue is now encoded into $charset + + + // Rule Dolibarr: No HTML + //print $charset.' '.$newvalue."\n"; + //$newvalue=dol_string_nohtmltag($newvalue,0,$charset); + $newvalue = dol_htmlcleanlastbr($newvalue); + //print $charset.' '.$newvalue."\n"; + + // Rule 1 CSV: No CR, LF in cells (except if USE_STRICT_CSV_RULES is 1, we can keep record as it is but we must add quotes) + $oldvalue = $newvalue; + $newvalue = str_replace("\r", '', $newvalue); + $newvalue = str_replace("\n", '\n', $newvalue); + if (getDolGlobalString('USE_STRICT_CSV_RULES') && $oldvalue != $newvalue) { + // If we must use enclusure on text with CR/LF) + if (getDolGlobalInt('USE_STRICT_CSV_RULES') == 1) { + // If we use strict CSV rules (original value must remain but we add quote) + $newvalue = $oldvalue; + } + $addquote = 1; + } + + // Rule 2 CSV: If value contains ", we must escape with ", and add " + if (preg_match('/"/', $newvalue)) { + $addquote = 1; + $newvalue = str_replace('"', '""', $newvalue); + } + + // Rule 3 CSV: If value contains separator, we must add " + if (preg_match('/'.$separator.'/', $newvalue)) { + $addquote = 1; + } + + return ($addquote ? '"' : '').$newvalue.($addquote ? '"' : ''); +} diff --git a/htdocs/core/lib/functions_ch.lib.php b/htdocs/core/lib/functions_ch.lib.php index 50b373e17d71f..a702f05c1eff9 100644 --- a/htdocs/core/lib/functions_ch.lib.php +++ b/htdocs/core/lib/functions_ch.lib.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 @@ -160,7 +161,7 @@ function dol_ch_controle_bvrb($bvrb) // Check (verify/validate) $report = 0; while (dol_strlen($bv) > 1) { - $match = substr($bv, 0, 1); + $match = (int) substr($bv, 0, 1); $report = $tableau[$report][$match]; $bv = substr($bv, 1); } diff --git a/htdocs/core/lib/functions_fi.lib.php b/htdocs/core/lib/functions_fi.lib.php index 75d28b51975b3..e09f49bd58917 100644 --- a/htdocs/core/lib/functions_fi.lib.php +++ b/htdocs/core/lib/functions_fi.lib.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Mikko Virtanen * * 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 @@ -37,16 +38,16 @@ function dolFICalculatePaymentReference($invoice_number, $statut, $use_rf) { if ($statut >= 1) { $invoice_number = preg_replace('/[^0-9]/', '', $invoice_number); // Keep only numbers - $invoice_number = ltrim($invoice_number, '0'); //Remove any leading zero or zeros - $invoice_number = strrev($invoice_number); // Reverse the reference number - $coefficients = array(7, 3, 1, 7, 3); // Define the coefficient numbers + $invoice_number = ltrim($invoice_number, '0'); // Remove leading zeros + $coefficients = array(7, 3, 1); // Define the coefficient numbers (rotating 7, 3, 1) $sum = 0; $stlen_invoice_number = (int) strlen($invoice_number); - for ($i = 0; $i < $stlen_invoice_number; $i++) { // Calculate the sum using coefficients - $sum += (int) $invoice_number[$i] * $coefficients[$i % 5]; + // Calculate the weighted sum from right to left + for ($i = 0; $i < $stlen_invoice_number; $i++) { + $sum += (int) $invoice_number[$stlen_invoice_number - $i - 1] * $coefficients[$i % 3]; } $check_digit = (10 - ($sum % 10)) % 10; // Calculate the check digit - $bank_reference_fi = strrev($invoice_number) . $check_digit; // Concatenate the Reversed reference number and the check digit + $bank_reference_fi = $invoice_number . $check_digit; // Concatenate the reference number and the check digit if ($use_rf) { // SEPA RF creditor reference $reference_with_suffix = $bank_reference_fi . "271500"; // Append "271500" to the end of the payment reference number $remainder = (int) bcmod($reference_with_suffix, '97'); // Calculate the remainder when dividing by 97 diff --git a/htdocs/core/lib/functionscli.lib.php b/htdocs/core/lib/functionscli.lib.php new file mode 100644 index 0000000000000..f6a603f17ceb3 --- /dev/null +++ b/htdocs/core/lib/functionscli.lib.php @@ -0,0 +1,50 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/lib/functionscli.lib.php + * \brief A set of functions for CLI scripts of Dolibarr + * This file contains only functions used by script run on command line. + */ + + +// Define ANSI color constant to use colors and bold in CLI script +define('DOL_COLOR_RESET', "\033[0m"); // Restore color +define('DOL_COLOR_BOLD', "\033[1m"); // Bold +define('DOL_COLOR_RED', "\033[31m"); +define('DOL_COLOR_GREEN', "\033[32m"); +define('DOL_COLOR_YELLOW', "\033[33m"); +define('DOL_COLOR_BLUE', "\033[34m"); +define('DOL_COLOR_MAGENTA', "\033[35m"); +define('DOL_COLOR_CYAN', "\033[36m"); +define('DOL_COLOR_WHITE', "\033[37m"); + + +/** + * Output text in color or bold + * + * @param string $text Text to show + * @param string $color Color code + * @param boolean $bold Bold or not + * @return string Text enhanced with colors + */ +function coloredText($text, $color, $bold = false) +{ + $boldCode = $bold ? DOL_COLOR_BOLD : ''; + return $boldCode . $color . $text . DOL_COLOR_RESET; +} diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 0a725b04cc42b..c92922c542680 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -187,7 +187,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, { require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - global $conf, $langs; + global $langs; dol_syslog("dol_imageResizeOrCrop file=".$file." mode=".$mode." newWidth=".$newWidth." newHeight=".$newHeight." src_x=".$src_x." src_y=".$src_y); @@ -423,8 +423,8 @@ function dolRotateImage($file_path) * Add exif orientation correction for image * * @param string $fileSource Full path to source image to rotate - * @param string|bool $fileDest string : Full path to image to rotate | false return gd img | null the raw image stream will be outputted directly - * @param int $quality output image quality + * @param string|bool|null $fileDest string : Full path to image to rotate | false return gd img | null the raw image stream will be outputted directly + * @param int<-1,100> $quality output image quality * @return bool : true on success or false on failure or gd img if $fileDest is false. */ function correctExifImageOrientation($fileSource, $fileDest, $quality = 95) diff --git a/htdocs/core/lib/ldap.lib.php b/htdocs/core/lib/ldap.lib.php index a3ea72226a19a..9b5c039372e30 100644 --- a/htdocs/core/lib/ldap.lib.php +++ b/htdocs/core/lib/ldap.lib.php @@ -1,7 +1,8 @@ - * Copyright (C) 2006-2021 Regis Houssin - * Copyright (C) 2024 MDW +/* Copyright (C) 2006 Laurent Destailleur + * Copyright (C) 2006-2021 Regis Houssin + * Copyright (C) 2024 MDW + * 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 @@ -125,15 +126,13 @@ function show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass) * @param array<'count'|int|string,int|string|array> $result Array to show. This array is already encoded into charset_output * @param int $level Level * @param int $count Count - * @param string $var Var + * @param bool $var Var deprecated (replaced by css oddeven) * @param int<0,1> $hide Hide * @param int $subcount Subcount * @return int */ function show_ldap_content($result, $level, $count, $var, $hide = 0, $subcount = 0) { - global $bc, $conf; - $count--; if ($count == 0) { return -1; // To stop loop diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 0ebfb8b8d9494..205f3254d4bcb 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -65,11 +65,18 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Label")), null, 'errors'); return -2; } - if (!preg_match('/^(integer|price|sellist|varchar|double|text|html|duration)/', $addfieldentry['type']) + if (!preg_match('/^(integer|price|sellist|varchar|double|text|html|duration|stars)/', $addfieldentry['type']) && !preg_match('/^(boolean|smallint|real|date|datetime|timestamp|phone|mail|url|ip|password)$/', $addfieldentry['type'])) { setEventMessages($langs->trans('BadValueForType', $addfieldentry['type']), null, 'errors'); return -2; } + // Check for type stars(NumberOfStars), NumberOfStars must be an integer between 1 and 10 + if (preg_match('/^stars\((.+)\)$/', $addfieldentry['type'], $matches)) { + if (!ctype_digit($matches[1]) || $matches[1] < 1 || $matches[1] > 10) { + setEventMessages($langs->trans('BadValueForType', $addfieldentry['type']), null, 'errors'); + return -2; + } + } } $pathoffiletoeditsrc = $readdir.'/class/'.strtolower($objectname).'.class.php'; @@ -343,6 +350,8 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = ' $type = 'integer'; } elseif ($type == 'mail') { $type = 'varchar(128)'; + } elseif (strpos($type, 'stars(') === 0) { + $type = 'integer'; } elseif ($type == 'phone') { $type = 'varchar(20)'; } elseif ($type == 'ip') { diff --git a/htdocs/core/lib/oauth.lib.php b/htdocs/core/lib/oauth.lib.php index 2366b4c0d34a8..ecd69c3d0458a 100644 --- a/htdocs/core/lib/oauth.lib.php +++ b/htdocs/core/lib/oauth.lib.php @@ -33,238 +33,238 @@ function getAllOauth2Array() { $list = array( - array( - 'OAUTH_AMAZON_NAME', - 'OAUTH_AMAZON_ID', - 'OAUTH_AMAZON_SECRET', - ), - array( - 'OAUTH_BITBUCKET_NAME', - 'OAUTH_BITBUCKET_ID', - 'OAUTH_BITBUCKET_SECRET', - ), - array( - 'OAUTH_BITLY_NAME', - 'OAUTH_BITLY_ID', - 'OAUTH_BITLY_SECRET', - ), - array( - 'OAUTH_BITRIX24_NAME', - 'OAUTH_BITRIX24_ID', - 'OAUTH_BITRIX24_SECRET', - ), - array( - 'OAUTH_BOX_NAME', - 'OAUTH_BOX_ID', - 'OAUTH_BOX_SECRET', - ), - array( - 'OAUTH_BUFFER_NAME', - 'OAUTH_BUFFER_ID', - 'OAUTH_BUFFER_SECRET', - ), - array( - 'OAUTH_DAILYMOTION_NAME', - 'OAUTH_DAILYMOTION_ID', - 'OAUTH_DAILYMOTION_SECRET', - ), - array( - 'OAUTH_DEVIANTART_NAME', - 'OAUTH_DEVIANTART_ID', - 'OAUTH_DEVIANTART_SECRET', - ), - array( - 'OAUTH_DROPBOX_NAME', - 'OAUTH_DROPBOX_ID', - 'OAUTH_DROPBOX_SECRET', - ), - array( - 'OAUTH_ETSY_NAME', - 'OAUTH_ETSY_ID', - 'OAUTH_ETSY_SECRET', - ), - array( - 'OAUTH_EVEONLINE_NAME', - 'OAUTH_EVEONLINE_ID', - 'OAUTH_EVEONLINE_SECRET', - ), - array( - 'OAUTH_FACEBOOK_NAME', - 'OAUTH_FACEBOOK_ID', - 'OAUTH_FACEBOOK_SECRET', - ), - array( - 'OAUTH_FITBIT_NAME', - 'OAUTH_FITBIT_ID', - 'OAUTH_FITBIT_SECRET', - ), - array( - 'OAUTH_FIVEHUNDREDPX_NAME', - 'OAUTH_FIVEHUNDREDPX_ID', - 'OAUTH_FIVEHUNDREDPX_SECRET', - ), - array( - 'OAUTH_FLICKR_NAME', - 'OAUTH_FLICKR_ID', - 'OAUTH_FLICKR_SECRET', - ), - array( - 'OAUTH_FOURSQUARE_NAME', - 'OAUTH_FOURSQUARE_ID', - 'OAUTH_FOURSQUARE_SECRET', - ), - array( - 'OAUTH_GITHUB_NAME', - 'OAUTH_GITHUB_ID', - 'OAUTH_GITHUB_SECRET', - 'OAUTH_GITHUB_DESC', - ), - array( - 'OAUTH_GOOGLE_NAME', - 'OAUTH_GOOGLE_ID', - 'OAUTH_GOOGLE_SECRET', - 'OAUTH_GOOGLE_DESC', - ), - array( - 'OAUTH_HUBIC_NAME', - 'OAUTH_HUBIC_ID', - 'OAUTH_HUBIC_SECRET', - ), - array( - 'OAUTH_INSTAGRAM_NAME', - 'OAUTH_INSTAGRAM_ID', - 'OAUTH_INSTAGRAM_SECRET', - ), - array( - 'OAUTH_LINKEDIN_NAME', - 'OAUTH_LINKEDIN_ID', - 'OAUTH_LINKEDIN_SECRET', - ), - array( - 'OAUTH_MAILCHIMP_NAME', - 'OAUTH_MAILCHIMP_ID', - 'OAUTH_MAILCHIMP_SECRET', - ), - array( - 'OAUTH_MICROSOFT_NAME', - 'OAUTH_MICROSOFT_ID', - 'OAUTH_MICROSOFT_SECRET', - ), - array( - 'OAUTH_MICROSOFT2_NAME', - 'OAUTH_MICROSOFT2_ID', - 'OAUTH_MICROSOFT2_SECRET', - ), - array( - 'OAUTH_NEST_NAME', - 'OAUTH_NEST_ID', - 'OAUTH_NEST_SECRET', - ), - array( - 'OAUTH_NETATMO_NAME', - 'OAUTH_NETATMO_ID', - 'OAUTH_NETATMO_SECRET', - ), - array( - 'OAUTH_PARROTFLOWERPOWER_NAME', - 'OAUTH_PARROTFLOWERPOWER_ID', - 'OAUTH_PARROTFLOWERPOWER_SECRET', - ), - array( - 'OAUTH_PAYPAL_NAME', - 'OAUTH_PAYPAL_ID', - 'OAUTH_PAYPAL_SECRET', - ), - array( - 'OAUTH_POCKET_NAME', - 'OAUTH_POCKET_ID', - 'OAUTH_POCKET_SECRET', - ), - array( - 'OAUTH_QUICKBOOKS_NAME', - 'OAUTH_QUICKBOOKS_ID', - 'OAUTH_QUICKBOOKS_SECRET', - ), - array( - 'OAUTH_REDDIT_NAME', - 'OAUTH_REDDIT_ID', - 'OAUTH_REDDIT_SECRET', - ), - array( - 'OAUTH_REDMINE_NAME', - 'OAUTH_REDMINE_ID', - 'OAUTH_REDMINE_SECRET', - ), - array( - 'OAUTH_RUNKEEPER_NAME', - 'OAUTH_RUNKEEPER_ID', - 'OAUTH_RUNKEEPER_SECRET', - ), - array( - 'OAUTH_SCOOPIT_NAME', - 'OAUTH_SCOOPIT_ID', - 'OAUTH_SCOOPIT_SECRET', - ), - array( - 'OAUTH_SOUNDCLOUD_NAME', - 'OAUTH_SOUNDCLOUD_ID', - 'OAUTH_SOUNDCLOUD_SECRET', - ), - array( - 'OAUTH_SPOTIFY_NAME', - 'OAUTH_SPOTIFY_ID', - 'OAUTH_SPOTIFY_SECRET', - ), - array( - 'OAUTH_STRAVA_NAME', - 'OAUTH_STRAVA_ID', - 'OAUTH_STRAVA_SECRET', - ), - array( - 'OAUTH_STRIPE_TEST_NAME', - 'OAUTH_STRIPE_TEST_ID', - 'STRIPE_TEST_SECRET_KEY', - ), - array( - 'OAUTH_STRIPE_LIVE_NAME', - 'OAUTH_STRIPE_LIVE_ID', - 'STRIPE_LIVE_SECRET_KEY', - ), - array( - 'OAUTH_TUMBLR_NAME', - 'OAUTH_TUMBLR_ID', - 'OAUTH_TUMBLR_SECRET', - ), - array( - 'OAUTH_TWITTER_NAME', - 'OAUTH_TWITTER_ID', - 'OAUTH_TWITTER_SECRET', - ), - array( - 'OAUTH_USTREAM_NAME', - 'OAUTH_USTREAM_ID', - 'OAUTH_USTREAM_SECRET', - ), - array( - 'OAUTH_VIMEO_NAME', - 'OAUTH_VIMEO_ID', - 'OAUTH_VIMEO_SECRET', - ), - array( - 'OAUTH_YAHOO_NAME', - 'OAUTH_YAHOO_ID', - 'OAUTH_YAHOO_SECRET', - ), - array( - 'OAUTH_YAMMER_NAME', - 'OAUTH_YAMMER_ID', - 'OAUTH_YAMMER_SECRET', - ), - array( - 'OAUTH_GENERIC_NAME', - 'OAUTH_GENERIC_ID', - 'OAUTH_GENERIC_SECRET', - ) + array( + 'OAUTH_AMAZON_NAME', + 'OAUTH_AMAZON_ID', + 'OAUTH_AMAZON_SECRET', + ), + array( + 'OAUTH_BITBUCKET_NAME', + 'OAUTH_BITBUCKET_ID', + 'OAUTH_BITBUCKET_SECRET', + ), + array( + 'OAUTH_BITLY_NAME', + 'OAUTH_BITLY_ID', + 'OAUTH_BITLY_SECRET', + ), + array( + 'OAUTH_BITRIX24_NAME', + 'OAUTH_BITRIX24_ID', + 'OAUTH_BITRIX24_SECRET', + ), + array( + 'OAUTH_BOX_NAME', + 'OAUTH_BOX_ID', + 'OAUTH_BOX_SECRET', + ), + array( + 'OAUTH_BUFFER_NAME', + 'OAUTH_BUFFER_ID', + 'OAUTH_BUFFER_SECRET', + ), + array( + 'OAUTH_DAILYMOTION_NAME', + 'OAUTH_DAILYMOTION_ID', + 'OAUTH_DAILYMOTION_SECRET', + ), + array( + 'OAUTH_DEVIANTART_NAME', + 'OAUTH_DEVIANTART_ID', + 'OAUTH_DEVIANTART_SECRET', + ), + array( + 'OAUTH_DROPBOX_NAME', + 'OAUTH_DROPBOX_ID', + 'OAUTH_DROPBOX_SECRET', + ), + array( + 'OAUTH_ETSY_NAME', + 'OAUTH_ETSY_ID', + 'OAUTH_ETSY_SECRET', + ), + array( + 'OAUTH_EVEONLINE_NAME', + 'OAUTH_EVEONLINE_ID', + 'OAUTH_EVEONLINE_SECRET', + ), + array( + 'OAUTH_FACEBOOK_NAME', + 'OAUTH_FACEBOOK_ID', + 'OAUTH_FACEBOOK_SECRET', + ), + array( + 'OAUTH_FITBIT_NAME', + 'OAUTH_FITBIT_ID', + 'OAUTH_FITBIT_SECRET', + ), + array( + 'OAUTH_FIVEHUNDREDPX_NAME', + 'OAUTH_FIVEHUNDREDPX_ID', + 'OAUTH_FIVEHUNDREDPX_SECRET', + ), + array( + 'OAUTH_FLICKR_NAME', + 'OAUTH_FLICKR_ID', + 'OAUTH_FLICKR_SECRET', + ), + array( + 'OAUTH_FOURSQUARE_NAME', + 'OAUTH_FOURSQUARE_ID', + 'OAUTH_FOURSQUARE_SECRET', + ), + array( + 'OAUTH_GITHUB_NAME', + 'OAUTH_GITHUB_ID', + 'OAUTH_GITHUB_SECRET', + 'OAUTH_GITHUB_DESC', + ), + array( + 'OAUTH_GOOGLE_NAME', + 'OAUTH_GOOGLE_ID', + 'OAUTH_GOOGLE_SECRET', + 'OAUTH_GOOGLE_DESC', + ), + array( + 'OAUTH_HUBIC_NAME', + 'OAUTH_HUBIC_ID', + 'OAUTH_HUBIC_SECRET', + ), + array( + 'OAUTH_INSTAGRAM_NAME', + 'OAUTH_INSTAGRAM_ID', + 'OAUTH_INSTAGRAM_SECRET', + ), + array( + 'OAUTH_LINKEDIN_NAME', + 'OAUTH_LINKEDIN_ID', + 'OAUTH_LINKEDIN_SECRET', + ), + array( + 'OAUTH_MAILCHIMP_NAME', + 'OAUTH_MAILCHIMP_ID', + 'OAUTH_MAILCHIMP_SECRET', + ), + array( + 'OAUTH_MICROSOFT_NAME', + 'OAUTH_MICROSOFT_ID', + 'OAUTH_MICROSOFT_SECRET', + ), + array( + 'OAUTH_MICROSOFT2_NAME', + 'OAUTH_MICROSOFT2_ID', + 'OAUTH_MICROSOFT2_SECRET', + ), + array( + 'OAUTH_NEST_NAME', + 'OAUTH_NEST_ID', + 'OAUTH_NEST_SECRET', + ), + array( + 'OAUTH_NETATMO_NAME', + 'OAUTH_NETATMO_ID', + 'OAUTH_NETATMO_SECRET', + ), + array( + 'OAUTH_PARROTFLOWERPOWER_NAME', + 'OAUTH_PARROTFLOWERPOWER_ID', + 'OAUTH_PARROTFLOWERPOWER_SECRET', + ), + array( + 'OAUTH_PAYPAL_NAME', + 'OAUTH_PAYPAL_ID', + 'OAUTH_PAYPAL_SECRET', + ), + array( + 'OAUTH_POCKET_NAME', + 'OAUTH_POCKET_ID', + 'OAUTH_POCKET_SECRET', + ), + array( + 'OAUTH_QUICKBOOKS_NAME', + 'OAUTH_QUICKBOOKS_ID', + 'OAUTH_QUICKBOOKS_SECRET', + ), + array( + 'OAUTH_REDDIT_NAME', + 'OAUTH_REDDIT_ID', + 'OAUTH_REDDIT_SECRET', + ), + array( + 'OAUTH_REDMINE_NAME', + 'OAUTH_REDMINE_ID', + 'OAUTH_REDMINE_SECRET', + ), + array( + 'OAUTH_RUNKEEPER_NAME', + 'OAUTH_RUNKEEPER_ID', + 'OAUTH_RUNKEEPER_SECRET', + ), + array( + 'OAUTH_SCOOPIT_NAME', + 'OAUTH_SCOOPIT_ID', + 'OAUTH_SCOOPIT_SECRET', + ), + array( + 'OAUTH_SOUNDCLOUD_NAME', + 'OAUTH_SOUNDCLOUD_ID', + 'OAUTH_SOUNDCLOUD_SECRET', + ), + array( + 'OAUTH_SPOTIFY_NAME', + 'OAUTH_SPOTIFY_ID', + 'OAUTH_SPOTIFY_SECRET', + ), + array( + 'OAUTH_STRAVA_NAME', + 'OAUTH_STRAVA_ID', + 'OAUTH_STRAVA_SECRET', + ), + array( + 'OAUTH_STRIPETEST_NAME', + 'OAUTH_STRIPETEST_ID', + 'OAUTH_STRIPETEST_SECRET_KEY', + ), + array( + 'OAUTH_STRIPELIVE_NAME', + 'OAUTH_STRIPELIVE_ID', + 'OAUTH_STRIPELIVE_SECRET_KEY', + ), + array( + 'OAUTH_TUMBLR_NAME', + 'OAUTH_TUMBLR_ID', + 'OAUTH_TUMBLR_SECRET', + ), + array( + 'OAUTH_TWITTER_NAME', + 'OAUTH_TWITTER_ID', + 'OAUTH_TWITTER_SECRET', + ), + array( + 'OAUTH_USTREAM_NAME', + 'OAUTH_USTREAM_ID', + 'OAUTH_USTREAM_SECRET', + ), + array( + 'OAUTH_VIMEO_NAME', + 'OAUTH_VIMEO_ID', + 'OAUTH_VIMEO_SECRET', + ), + array( + 'OAUTH_YAHOO_NAME', + 'OAUTH_YAHOO_ID', + 'OAUTH_YAHOO_SECRET', + ), + array( + 'OAUTH_YAMMER_NAME', + 'OAUTH_YAMMER_ID', + 'OAUTH_YAMMER_SECRET', + ), + array( + 'OAUTH_GENERIC_NAME', + 'OAUTH_GENERIC_ID', + 'OAUTH_GENERIC_SECRET', + ) ); return $list; @@ -291,7 +291,7 @@ function getSupportedOauth2Array() ), ); if (isModEnabled('stripe')) { - $supportedoauth2array['OAUTH_STRIPE_TEST_NAME'] = array( + $supportedoauth2array['OAUTH_STRIPETEST_NAME'] = array( 'callbackfile' => 'stripetest', 'picto' => 'stripe', 'urlforapp' => '', @@ -300,7 +300,7 @@ function getSupportedOauth2Array() 'availablescopes' => 'read_write', 'returnurl' => '/core/modules/oauth/stripetest_oauthcallback.php' ); - $supportedoauth2array['OAUTH_STRIPE_LIVE_NAME'] = array( + $supportedoauth2array['OAUTH_STRIPELIVE_NAME'] = array( 'callbackfile' => 'stripelive', 'picto' => 'stripe', 'urlforapp' => '', @@ -338,8 +338,9 @@ function getSupportedOauth2Array() 'urlforcredentials' => 'https://portal.azure.com/', // User.Read is a microsoftgraph scope, if it's not working, do not select it 'availablescopes' => 'openid,offline_access,profile,email,User.Read,https://outlook.office.com/.default', - 'returnurl' => '/core/modules/oauth/microsoft_oauthcallback.php' + 'returnurl' => '/core/modules/oauth/microsoft2_oauthcallback.php' ); + // Add a generic Oauth token handler. Tested with Mastodon. $supportedoauth2array['OAUTH_GENERIC_NAME'] = array( 'callbackfile' => 'generic', diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index ae6a8e40d997b..40ac55b3ba7e8 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -83,7 +83,7 @@ function pdf_admin_prepare_head() * @param 'setup'|'auto' $mode 'setup' = Use setup, 'auto' = Force autodetection whatever is setup * @return array{width:float|int,height:float|int,unit:string} Array('width'=>w,'height'=>h,'unit'=>u); */ -function pdf_getFormat(Translate $outputlangs = null, $mode = 'setup') +function pdf_getFormat($outputlangs = null, $mode = 'setup') { global $conf, $db, $langs; @@ -180,10 +180,8 @@ function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P') //$format=array($arrayformat['width'],$arrayformat['height']); //$metric=$arrayformat['unit']; - $pdfa = false; // PDF-1.3 - if (getDolGlobalString('PDF_USE_A')) { - $pdfa = getDolGlobalString('PDF_USE_A'); // PDF/A-1 ou PDF/A-3 - } + //$pdfa = false; // PDF default version + $pdfa = getDolGlobalInt('PDF_USE_A', 0); // PDF/A-1 ou PDF/A-3 if (!getDolGlobalString('MAIN_DISABLE_TCPDI') && class_exists('TCPDI')) { $pdf = new TCPDI($pagetype, $metric, $format, true, 'UTF-8', false, $pdfa); @@ -209,13 +207,13 @@ function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P') $pdfrights = (getDolGlobalString('PDF_SECURITY_ENCRYPTION_RIGHTS') ? json_decode($conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS, true) : array('modify', 'copy')); // Json format in llx_const // Password for the end user - $pdfuserpass = (getDolGlobalString('PDF_SECURITY_ENCRYPTION_USERPASS') ? $conf->global->PDF_SECURITY_ENCRYPTION_USERPASS : ''); + $pdfuserpass = getDolGlobalString('PDF_SECURITY_ENCRYPTION_USERPASS'); // Password of the owner, created randomly if not defined - $pdfownerpass = (getDolGlobalString('PDF_SECURITY_ENCRYPTION_OWNERPASS') ? $conf->global->PDF_SECURITY_ENCRYPTION_OWNERPASS : null); + $pdfownerpass = (getDolGlobalString('PDF_SECURITY_ENCRYPTION_OWNERPASS') ? getDolGlobalString('PDF_SECURITY_ENCRYPTION_OWNERPASS') : null); // For encryption strength: 0 = RC4 40 bit; 1 = RC4 128 bit; 2 = AES 128 bit; 3 = AES 256 bit - $encstrength = (getDolGlobalString('PDF_SECURITY_ENCRYPTION_STRENGTH') ? $conf->global->PDF_SECURITY_ENCRYPTION_STRENGTH : 0); + $encstrength = getDolGlobalInt('PDF_SECURITY_ENCRYPTION_STRENGTH', 0); // Array of recipients containing public-key certificates ('c') and permissions ('p'). // For example: array(array('c' => 'file://../examples/data/cert/tcpdf.crt', 'p' => array('print'))) @@ -1010,7 +1008,7 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, * @param TCPDF $pdf The PDF factory * @param Translate $outputlangs Object lang for output * @param string $paramfreetext Constant name of free text - * @param Societe $fromcompany Object company + * @param ?Societe $fromcompany Object company * @param int $marge_basse Margin bottom we use for the autobreak * @param int $marge_gauche Margin left (no more used) * @param int $page_hauteur Page height @@ -1036,8 +1034,10 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ if (empty($hidefreetext) && getDolGlobalString($paramfreetext)) { $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); // More substitution keys - $substitutionarray['__FROM_NAME__'] = $fromcompany->name; - $substitutionarray['__FROM_EMAIL__'] = $fromcompany->email; + if (is_object($fromcompany)) { + $substitutionarray['__FROM_NAME__'] = $fromcompany->name; + $substitutionarray['__FROM_EMAIL__'] = $fromcompany->email; + } complete_substitutions_array($substitutionarray, $outputlangs, $object); $newfreetext = make_substitutions(getDolGlobalString($paramfreetext), $substitutionarray, $outputlangs); @@ -1056,7 +1056,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $line3 = ""; $line4 = ""; - if ($showdetails == 1 || $showdetails == 3) { + if (is_object($fromcompany) && in_array($showdetails, array(1, 3))) { // Company name if ($fromcompany->name) { $line1 .= ($line1 ? " - " : "").$outputlangs->transnoentities("RegisteredOffice").": ".$fromcompany->name; @@ -1508,7 +1508,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $prodser = new Product($db); - if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES')) { + if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) { include_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; } } @@ -1687,7 +1687,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, } else { $ref_prodserv = $prodser->ref; // Show local ref only - if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES')) { + if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) { $productCustomerPriceStatic = new ProductCustomerPrice($db); $filter = array('fk_product' => $idprod, 'fk_soc' => $object->socid); diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 463427a131eba..a809f43841955 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -454,7 +454,7 @@ function show_stats_for_company($product, $socid) print ''; print $product->stats_propale['nb']; print ''; - print $product->stats_propale['qty']; + print price($product->stats_propale['qty'], 1, $langs, 0, 0); print ''; print ''; } @@ -473,7 +473,7 @@ function show_stats_for_company($product, $socid) print ''; print $product->stats_proposal_supplier['nb']; print ''; - print $product->stats_proposal_supplier['qty']; + print price($product->stats_proposal_supplier['qty'], 1, $langs, 0, 0); print ''; print ''; } @@ -492,7 +492,7 @@ function show_stats_for_company($product, $socid) print ''; print $product->stats_commande['nb']; print ''; - print $product->stats_commande['qty']; + print price($product->stats_commande['qty'], 1, $langs, 0, 0); print ''; print ''; } @@ -511,7 +511,7 @@ function show_stats_for_company($product, $socid) print ''; print $product->stats_commande_fournisseur['nb']; print ''; - print $product->stats_commande_fournisseur['qty']; + print price($product->stats_commande_fournisseur['qty'], 1, $langs, 0, 0); print ''; print ''; } @@ -530,7 +530,7 @@ function show_stats_for_company($product, $socid) print ''; print $product->stats_facture['nb']; print ''; - print $product->stats_facture['qty']; + print price($product->stats_facture['qty'], 1, $langs, 0, 0); print ''; print ''; } @@ -568,7 +568,7 @@ function show_stats_for_company($product, $socid) print ''; print $product->stats_facture_fournisseur['nb']; print ''; - print $product->stats_facture_fournisseur['qty']; + print price($product->stats_facture_fournisseur['qty'], 1, $langs, 0, 0); print ''; print ''; } @@ -628,7 +628,7 @@ function show_stats_for_company($product, $socid) print ''; print $product->stats_contrat['nb']; print ''; - print $product->stats_contrat['qty']; + print price($product->stats_contrat['qty'], 1, $langs, 0, 0); print ''; print ''; } diff --git a/htdocs/core/lib/profid.lib.php b/htdocs/core/lib/profid.lib.php index f4b54afb18b73..666e81121b08e 100644 --- a/htdocs/core/lib/profid.lib.php +++ b/htdocs/core/lib/profid.lib.php @@ -189,6 +189,7 @@ function isValidTinForES($str) for ($i = 0; $i < 9; $i++) { $num[$i] = substr($str, $i, 1); } + '@phan-var-force array,string> $num'; //Check NIF if (preg_match('/(^[0-9]{8}[A-Z]{1}$)/', $str)) { diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 0818eb3359cc6..6abf66876d863 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -585,10 +585,10 @@ function project_admin_prepare_head() * @param int $parent Id of parent task to show (0 to show all) * @param Task[] $lines Array of lines * @param int $level Level (start to 0, then increased/decrease by recursive call), or -1 to show all level in order of $lines without the recursive groupment feature. - * @param string $var Color + * @param string $var Not used * @param int $showproject Show project columns * @param int $taskrole Array of roles of user for each tasks - * @param string $projectsListId List of id of project allowed to user (string separated with comma) + * @param string $projectsListId List of id of projects allowed to user (string separated with comma) * @param int $addordertick Add a tick to move task * @param int $projectidfortotallink 0 or Id of project to use on total line (link to see all time consumed for project) * @param string $dummy Not used. @@ -610,7 +610,10 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t $lastprojectid = 0; - $projectsArrayId = explode(',', $projectsListId); + $projectsArrayId = array(); + if ($projectsListId) { + $projectsArrayId = explode(',', $projectsListId); + } $numlines = count($lines); @@ -672,7 +675,6 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if ($showline) { // Break on a new project if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) { - $var = !$var; $lastprojectid = $lines[$i]->fk_project; } @@ -985,7 +987,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if ($level >= 0) { // Call sublevels $level++; if ($lines[$i]->id) { - projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick, $projectidfortotallink, '', $showbilltime, $arrayfields); + projectLinesa($inc, $lines[$i]->id, $lines, $level, '', $showproject, $taskrole, $projectsListId, $addordertick, $projectidfortotallink, '', $showbilltime, $arrayfields); } $level--; } @@ -2549,7 +2551,7 @@ function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole) * @param DoliDB $db Database handler * @param Form $form Object form * @param int $socid Id thirdparty - * @param int $projectsListId Id of project I have permission on + * @param int|string $projectsListId Id or ids of project I have permission on (separated with comma) * @param int<0,1> $mytasks Limited to task I am contact to * @param int<-1,1> $status -1=No filter on statut, 0 or 1 = Filter on status * @param array $listofoppstatus List of opportunity status @@ -2607,7 +2609,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; } $sql .= " WHERE p.entity IN (".getEntity('project').")"; - $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; + $sql .= " AND p.rowid IN (".$db->sanitize((string) $projectsListId).")"; if ($socid) { $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).")"; } diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index e0b5e000c330a..153d8e7029259 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -27,7 +27,7 @@ /** * Prepare array with list of tabs * - * @param object $object Object related to tabs + * @param Propal $object Object related to tabs * @return array Array of tabs to show */ function propal_prepare_head($object) @@ -154,7 +154,7 @@ function propal_prepare_head($object) /** * Return array head with list of tabs to view object information. * - * @return array head array with tabs + * @return array head array with tabs */ function propal_admin_prepare_head() { diff --git a/htdocs/core/lib/public.lib.php b/htdocs/core/lib/public.lib.php index ecc75de10dacc..47a3f0e42094b 100644 --- a/htdocs/core/lib/public.lib.php +++ b/htdocs/core/lib/public.lib.php @@ -30,11 +30,11 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php'; /** - * Check if the object exceeded the number of posts for a specific ip - * @param object $object Object to check - * @param int $nb_post_max Number max of posts + * Check if the object exceeded the number of posts for a specific ip in the same week * - * @return int return <0 if error, >0 if OK + * @param object $object Object to check + * @param int $nb_post_max Number max of posts + * @return int Return <0 if error, >0 if OK */ function checkNbPostsForASpeceificIp($object, $nb_post_max) { @@ -42,7 +42,7 @@ function checkNbPostsForASpeceificIp($object, $nb_post_max) $nb_post_ip = 0; $now = dol_now(); - $minmonthpost = dol_time_plus_duree($now, -1, "m"); + $minmonthpost = dol_time_plus_duree($now, -1, "w"); if (empty($object->ip)) { $object->ip = getUserRemoteIP(); @@ -52,7 +52,11 @@ function checkNbPostsForASpeceificIp($object, $nb_post_max) $sql = "SELECT COUNT(".(!empty($object->table_rowid) ? $object->table_rowid : 'rowid').") as nb_posts"; $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element; $sql .= " WHERE ip = '".$db->escape($object->ip)."'"; - $sql .= " AND datec > '".$db->idate($minmonthpost)."'"; + if (array_key_exists('date_creation', $object->fields)) { + $sql .= " AND date_creation > '".$db->idate($minmonthpost)."'"; + } else { + $sql .= " AND datec > '".$db->idate($minmonthpost)."'"; + } $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); diff --git a/htdocs/core/lib/reception.lib.php b/htdocs/core/lib/reception.lib.php index d39e8dc69bd7b..a38793d135548 100644 --- a/htdocs/core/lib/reception.lib.php +++ b/htdocs/core/lib/reception.lib.php @@ -114,7 +114,7 @@ function reception_prepare_head(Reception $object) /** * Return array head with list of tabs to view object information. * - * @return array head array with tabs + * @return array head array with tabs */ function reception_admin_prepare_head() { diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index fbc0baf93cd08..66fc5f15bcfd6 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -48,12 +48,12 @@ function dol_getwebuser($mode) /** * Return a login if login/pass was successful * - * @param string $usertotest Login value to test - * @param string $passwordtotest Password value to test - * @param string $entitytotest Instance of data we must check - * @param array $authmode Array list of selected authentication mode array('http', 'dolibarr', 'xxx'...) - * @param string $context Context checkLoginPassEntity was created for ('api', 'dav', 'ws', '') - * @return string Login or '' or '--bad-login-validity--' + * @param string $usertotest Login value to test + * @param string $passwordtotest Password value to test + * @param string $entitytotest Instance of data we must check + * @param string[] $authmode Array list of selected authentication mode array('http', 'dolibarr', 'xxx'...) + * @param 'api'|'dav'|'ws'|'' $context Context checkLoginPassEntity was created for ('api', 'dav', 'ws', '') + * @return string Login or '' or '--bad-login-validity--' */ function checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $authmode, $context = '') { @@ -175,6 +175,7 @@ function dol_loginfunction($langs, $conf, $mysoc) */ // Select templates dir + $template_dir = ''; if (!empty($conf->modules_parts['tpl'])) { // Using this feature slow down application $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl/')); foreach ($dirtpls as $reldir) { @@ -210,7 +211,7 @@ function dol_loginfunction($langs, $conf, $mysoc) session_set_cookie_params($sessioncookieparams); } - setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", '', !empty($dolibarr_main_force_https), true); + setcookie($sessiontimeout, getDolGlobalString('MAIN_SESSION_TIMEOUT'), 0, "/", '', !empty($dolibarr_main_force_https), true); } } @@ -394,6 +395,7 @@ function encodedecode_dbpassconf($level = 0) $lineofpass = 0; $reg = array(); + $mode = ''; if (preg_match('/^[^#]*dolibarr_main_db_encrypted_pass[\s]*=[\s]*(.*)/i', $buffer, $reg)) { // Old way to save encrypted value $val = trim($reg[1]); // This also remove CR/LF $val = preg_replace('/^["\']/', '', $val); @@ -479,8 +481,8 @@ function encodedecode_dbpassconf($level = 0) /** * Return a generated password using default module * - * @param boolean $generic true=Create generic password (32 chars/numbers), false=Use the configured password generation module - * @param array $replaceambiguouschars Discard ambiguous characters. For example array('I'). + * @param bool $generic true=Create generic password (32 chars/numbers), false=Use the configured password generation module + * @param ?array $replaceambiguouschars Discard ambiguous characters. For example array('I'). * @param int $length Length of random string (Used only if $generic is true) * @return string New value for password * @see dol_hash(), dolJSToSetRandomPassword() @@ -542,6 +544,7 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len //print DOL_DOCUMENT_ROOT."/core/modules/security/generate/".$nomclass; require_once DOL_DOCUMENT_ROOT."/core/modules/security/generate/".$nomfichier; $genhandler = new $nomclass($db, $conf, $langs, $user); + '@phan-var-force ModeleGenPassword $genhandler'; $generated_password = $genhandler->getNewGeneratedPassword(); unset($genhandler); } diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index 19fe34df9455a..bfd96475cc816 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -30,7 +30,7 @@ /** * Prepare array with list of tabs * - * @param Object $object Object related to tabs + * @param Expedition $object Object related to tabs * @return array Array of tabs to show */ function shipping_prepare_head($object) @@ -285,7 +285,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') print ''.$langs->trans("Warehouse").''; } /*TODO Add link to expeditiondet_batch - if (!empty($conf->productbatch->enabled)) + if (isModEnabled('productbatch')) { print ''; print ''; @@ -320,6 +320,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') // Define output language if (getDolGlobalInt('MAIN_MULTILANGS') && getDolGlobalString('PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE')) { $object = new $origin($db); + '@phan-var-force CommonObject $object'; $object->fetch($origin_id); $object->fetch_thirdparty(); @@ -356,7 +357,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') $text = $product_static->getNomUrl(1); $text .= ' - '.$label; $description = (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE') ? '' : dol_htmlentitiesbr($objp->description)); - print $form->textwithtooltip($text, $description, 3, '', '', $i); + print $form->textwithtooltip($text, $description, 3, 0, '', $i); // Show range print_date_range($objp->date_start, $objp->date_end); @@ -377,7 +378,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') if (!empty($objp->label)) { $text .= ' '.$objp->label.''; - print $form->textwithtooltip($text, $objp->description, 3, '', '', $i); + print $form->textwithtooltip($text, $objp->description, 3, 0, '', $i); } else { print $text.' '.nl2br($objp->description); } @@ -410,7 +411,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') // Batch number management /*TODO Add link to expeditiondet_batch - if (!empty($conf->productbatch->enabled)) + if (isModEnabled('productbatch')) { //var_dump($objp->edrowid); $lines[$i]->detail_batch @@ -452,6 +453,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') } if (!empty($receiving)) { + '@phan-var-force Delivery $receiving'; // $expedition->fk_elementdet = id of det line of order // $receiving->fk_origin_line = id of det line of order // $receiving->origin may be 'shipping' diff --git a/htdocs/core/lib/signature.lib.php b/htdocs/core/lib/signature.lib.php index ee2ac8d39c533..76b464a508fb7 100644 --- a/htdocs/core/lib/signature.lib.php +++ b/htdocs/core/lib/signature.lib.php @@ -96,6 +96,10 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1, $o if ($type == 'proposal') { $securekeyseed = getDolGlobalString('PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN'); + if (strpos($securekeyseed, "\0") !== false) { + // String contains a null character that can't be encoded. Return an error to avoid fatal error later. + return 'Invalid parameter PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN. Contains a null character.'; + } $out = $urltouse.'/public/onlinesign/newonlinesign.php?source=proposal&ref='.($mode ? '' : ''); if ($mode == 1) { @@ -136,6 +140,11 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1, $o }*/ } elseif ($type == 'contract') { $securekeyseed = getDolGlobalString('CONTRACT_ONLINE_SIGNATURE_SECURITY_TOKEN'); + if (strpos($securekeyseed, "\0") !== false) { + // String contains a null character that can't be encoded. Return an error to avoid fatal error later. + return 'Invalid parameter CONTRACT_ONLINE_SIGNATURE_SECURITY_TOKEN. Contains a null character.'; + } + $out = $urltouse.'/public/onlinesign/newonlinesign.php?source=contract&ref='.($mode ? '' : ''); if ($mode == 1) { $out .= 'contract_ref'; @@ -151,6 +160,11 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1, $o } } elseif ($type == 'fichinter') { $securekeyseed = getDolGlobalString('FICHINTER_ONLINE_SIGNATURE_SECURITY_TOKEN'); + if (strpos($securekeyseed, "\0") !== false) { + // String contains a null character that can't be encoded. Return an error to avoid fatal error later. + return 'Invalid parameter FICHINTER_ONLINE_SIGNATURE_SECURITY_TOKEN. Contains a null character.'; + } + $out = $urltouse.'/public/onlinesign/newonlinesign.php?source=fichinter&ref='.($mode ? '' : ''); if ($mode == 1) { $out .= 'fichinter_ref'; @@ -166,6 +180,11 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1, $o } } else { // For example $type = 'societe_rib' $securekeyseed = getDolGlobalString(dol_strtoupper($type).'_ONLINE_SIGNATURE_SECURITY_TOKEN'); + if (strpos($securekeyseed, "\0") !== false) { + // String contains a null character that can't be encoded. Return an error to avoid fatal error later. + return 'Invalid parameter '.dol_strtoupper($type).'_ONLINE_SIGNATURE_SECURITY_TOKEN. Contains a null character.'; + } + $out = $urltouse.'/public/onlinesign/newonlinesign.php?source='.$type.'&ref='.($mode ? '' : ''); if ($mode == 1) { $out .= $type.'_ref'; diff --git a/htdocs/core/lib/supplier_proposal.lib.php b/htdocs/core/lib/supplier_proposal.lib.php index 6540b0140f79f..3ba952cce74cf 100644 --- a/htdocs/core/lib/supplier_proposal.lib.php +++ b/htdocs/core/lib/supplier_proposal.lib.php @@ -20,15 +20,15 @@ */ /** - * \file htdocs/core/lib/propal.lib.php - * \brief Ensemble de functions de base pour le module propal - * \ingroup propal + * \file htdocs/core/lib/supplier_proposal.lib.php + * \brief Ensemble de functions de base pour le module supplier_proposal + * \ingroup supplier_proposal */ /** * Prepare array with list of tabs * - * @param object $object Object related to tabs + * @param SupplierProposal $object Object related to tabs * @return array Array of tabs to show */ function supplier_proposal_prepare_head($object) @@ -108,7 +108,7 @@ function supplier_proposal_prepare_head($object) /** * Return array head with list of tabs to view object information. * - * @return array head array with tabs + * @return array head array with tabs */ function supplier_proposal_admin_prepare_head() { diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 668ccef36d63e..3ba2088e4b222 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -109,6 +109,7 @@ function ticket_prepare_head($object) include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $upload_dir = $conf->ticket->dir_output."/".$object->ref; $nbFiles = count(dol_dir_list($upload_dir, 'files')); + /* disabled. Too many bugs. All file of a ticket must be stored into ticket. File must be linked to an event by column agenda_id into llx_ecmfiles. $sql = 'SELECT id FROM '.MAIN_DB_PREFIX.'actioncomm'; $sql .= " WHERE fk_element = ".(int) $object->id." AND elementtype = 'ticket'"; $resql = $db->query($sql); @@ -119,6 +120,7 @@ function ticket_prepare_head($object) $nbFiles += count(dol_dir_list($upload_msg_dir, "files")); } } + */ $head[$h][0] = DOL_URL_ROOT.'/ticket/document.php?id='.$object->id; $head[$h][1] = $langs->trans("Documents"); if ($nbFiles > 0) { diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 475d60da1c861..6e31b8726f7fe 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -671,7 +671,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''.$langs->trans("TopMenuBackgroundColor").''; print ''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray((getDolGlobalString('THEME_ELDY_TOPMENU_BACK1') ? $conf->global->THEME_ELDY_TOPMENU_BACK1 : ''), array()), ''), 'THEME_ELDY_TOPMENU_BACK1', '', 1, '', '', 'colorbackhmenu1', $default).' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray((getDolGlobalString('THEME_ELDY_TOPMENU_BACK1') ? $conf->global->THEME_ELDY_TOPMENU_BACK1 : ''), array()), ''), 'THEME_ELDY_TOPMENU_BACK1', '', 1, array(), '', 'colorbackhmenu1', $default).' '; } else { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1, array()), ''); if ($color) { @@ -715,7 +715,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''.$langs->trans("LeftMenuBackgroundColor").''; print ''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray((getDolGlobalString('THEME_ELDY_VERMENU_BACK1') ? $conf->global->THEME_ELDY_VERMENU_BACK1 : ''), array()), ''), 'THEME_ELDY_VERMENU_BACK1', '', 1, '', '', 'colorbackvmenu1', $default).' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray((getDolGlobalString('THEME_ELDY_VERMENU_BACK1') ? $conf->global->THEME_ELDY_VERMENU_BACK1 : ''), array()), ''), 'THEME_ELDY_VERMENU_BACK1', '', 1, array(), '', 'colorbackvmenu1', $default).' '; } else { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_VERMENU_BACK1, array()), ''); if ($color) { @@ -756,7 +756,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''; //var_dump($conf->global->THEME_ELDY_BACKBODY); if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray((getDolGlobalString('THEME_ELDY_BACKBODY') ? $conf->global->THEME_ELDY_BACKBODY : ''), array()), ''), 'THEME_ELDY_BACKBODY', '', 1, '', '', 'colorbackbody', $default).' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray((getDolGlobalString('THEME_ELDY_BACKBODY') ? $conf->global->THEME_ELDY_BACKBODY : ''), array()), ''), 'THEME_ELDY_BACKBODY', '', 1, array(), '', 'colorbackbody', $default).' '; } else { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BACKBODY, array()), ''); if ($color) { @@ -780,7 +780,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''.$langs->trans("TextTitleColor").''; print ''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray((getDolGlobalString('THEME_ELDY_TEXTTITLENOTAB') ? $conf->global->THEME_ELDY_TEXTTITLENOTAB : ''), array()), ''), 'THEME_ELDY_TEXTTITLENOTAB', '', 1, '', '', 'colortexttitlenotab', $default).' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray((getDolGlobalString('THEME_ELDY_TEXTTITLENOTAB') ? $conf->global->THEME_ELDY_TEXTTITLENOTAB : ''), array()), ''), 'THEME_ELDY_TEXTTITLENOTAB', '', 1, array(), '', 'colortexttitlenotab', $default).' '; } else { print $formother->showColor($conf->global->THEME_ELDY_TEXTTITLENOTAB, $langs->trans("Default")); } @@ -800,7 +800,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''.$langs->trans("BackgroundTableTitleColor").''; print ''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray((getDolGlobalString('THEME_ELDY_BACKTITLE1') ? $conf->global->THEME_ELDY_BACKTITLE1 : ''), array()), ''), 'THEME_ELDY_BACKTITLE1', '', 1, '', '', 'colorbacktitle1', $default).' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray((getDolGlobalString('THEME_ELDY_BACKTITLE1') ? $conf->global->THEME_ELDY_BACKTITLE1 : ''), array()), ''), 'THEME_ELDY_BACKTITLE1', '', 1, array(), '', 'colorbacktitle1', $default).' '; } else { print $formother->showColor($conf->global->THEME_ELDY_BACKTITLE1, $langs->trans("Default")); } @@ -820,7 +820,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''.$langs->trans("BackgroundTableTitleTextColor").''; print ''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray((getDolGlobalString('THEME_ELDY_TEXTTITLE') ? $conf->global->THEME_ELDY_TEXTTITLE : ''), array()), ''), 'THEME_ELDY_TEXTTITLE', '', 1, '', '', 'colortexttitle', $default).' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray((getDolGlobalString('THEME_ELDY_TEXTTITLE') ? $conf->global->THEME_ELDY_TEXTTITLE : ''), array()), ''), 'THEME_ELDY_TEXTTITLE', '', 1, array(), '', 'colortexttitle', $default).' '; } else { print $formother->showColor($conf->global->THEME_ELDY_TEXTTITLE, $langs->trans("Default")); } @@ -840,7 +840,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''.$langs->trans("BackgroundTableTitleTextlinkColor").''; print ''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray((getDolGlobalString('THEME_ELDY_TEXTTITLELINK') ? $conf->global->THEME_ELDY_TEXTTITLELINK : ''), array()), ''), 'THEME_ELDY_TEXTTITLELINK', '', 1, '', '', 'colortexttitlelink', $default).' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray((getDolGlobalString('THEME_ELDY_TEXTTITLELINK') ? $conf->global->THEME_ELDY_TEXTTITLELINK : ''), array()), ''), 'THEME_ELDY_TEXTTITLELINK', '', 1, array(), '', 'colortexttitlelink', $default).' '; } else { print $formother->showColor($conf->global->THEME_ELDY_TEXTTITLELINK, $langs->trans("Default")); } @@ -861,7 +861,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''.$langs->trans("BackgroundTableLineOddColor").''; print ''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray((getDolGlobalString('THEME_ELDY_LINEIMPAIR1') ? $conf->global->THEME_ELDY_LINEIMPAIR1 : ''), array()), ''), 'THEME_ELDY_LINEIMPAIR1', '', 1, '', '', 'colorbacklineimpair2', $default).' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray((getDolGlobalString('THEME_ELDY_LINEIMPAIR1') ? $conf->global->THEME_ELDY_LINEIMPAIR1 : ''), array()), ''), 'THEME_ELDY_LINEIMPAIR1', '', 1, array(), '', 'colorbacklineimpair2', $default).' '; } else { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEIMPAIR1, array()), ''); if ($color) { @@ -885,7 +885,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''.$langs->trans("BackgroundTableLineEvenColor").''; print ''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray((getDolGlobalString('THEME_ELDY_LINEPAIR1') ? $conf->global->THEME_ELDY_LINEPAIR1 : ''), array()), ''), 'THEME_ELDY_LINEPAIR1', '', 1, '', '', 'colorbacklinepair2', $default).' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray((getDolGlobalString('THEME_ELDY_LINEPAIR1') ? $conf->global->THEME_ELDY_LINEPAIR1 : ''), array()), ''), 'THEME_ELDY_LINEPAIR1', '', 1, array(), '', 'colorbacklinepair2', $default).' '; } else { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEPAIR1, array()), ''); if ($color) { @@ -929,7 +929,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''.$langs->trans("LinkColor").''; print ''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray((getDolGlobalString('THEME_ELDY_TEXTLINK') ? $conf->global->THEME_ELDY_TEXTLINK : ''), array()), ''), 'THEME_ELDY_TEXTLINK', '', 1, '', '', 'colortextlink', $default).' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray((getDolGlobalString('THEME_ELDY_TEXTLINK') ? $conf->global->THEME_ELDY_TEXTLINK : ''), array()), ''), 'THEME_ELDY_TEXTLINK', '', 1, array(), '', 'colortextlink', $default).' '; } else { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTLINK, array()), ''); if ($color) { @@ -972,7 +972,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { $color = colorArrayToHex(colorStringToArray((getDolGlobalString('THEME_ELDY_USE_HOVER') ? $conf->global->THEME_ELDY_USE_HOVER : ''), array()), ''); } - print $formother->selectColor($color, 'THEME_ELDY_USE_HOVER', '', 1, '', '', 'colorbacklinepairhover', $default).' '; + print $formother->selectColor($color, 'THEME_ELDY_USE_HOVER', '', 1, array(), '', 'colorbacklinepairhover', $default).' '; } else { if (getDolGlobalString('THEME_ELDY_USE_HOVER') == '1') { $color = colorArrayToHex(colorStringToArray($colorbacklinepairhover)); @@ -1020,7 +1020,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { $color = colorArrayToHex(colorStringToArray((getDolGlobalString('THEME_ELDY_USE_CHECKED') ? $conf->global->THEME_ELDY_USE_CHECKED : ''), array()), ''); } - print $formother->selectColor($color, 'THEME_ELDY_USE_CHECKED', '', 1, '', '', 'colorbacklinepairchecked', $default).' '; + print $formother->selectColor($color, 'THEME_ELDY_USE_CHECKED', '', 1, array(), '', 'colorbacklinepairchecked', $default).' '; } else { if (getDolGlobalString('THEME_ELDY_USE_CHECKED') == '1') { $color = 'e6edf0'; @@ -1072,7 +1072,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''.$langs->trans("BtnActionColor").''; print ''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray((getDolGlobalString('THEME_ELDY_BTNACTION') ? $conf->global->THEME_ELDY_BTNACTION : ''), array()), ''), 'THEME_ELDY_BTNACTION', '', 1, '', '', 'butactionbg', $default).' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray((getDolGlobalString('THEME_ELDY_BTNACTION') ? $conf->global->THEME_ELDY_BTNACTION : ''), array()), ''), 'THEME_ELDY_BTNACTION', '', 1, array(), '', 'butactionbg', $default).' '; } else { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BTNACTION, array()), ''); if ($color) { @@ -1118,7 +1118,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''.$langs->trans("TextBtnActionColor").''; print ''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray((getDolGlobalString('THEME_ELDY_TEXTBTNACTION') ? $conf->global->THEME_ELDY_TEXTBTNACTION : ''), array()), ''), 'THEME_ELDY_TEXTBTNACTION', '', 1, '', '', 'textbutaction', $default).' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray((getDolGlobalString('THEME_ELDY_TEXTBTNACTION') ? $conf->global->THEME_ELDY_TEXTBTNACTION : ''), array()), ''), 'THEME_ELDY_TEXTBTNACTION', '', 1, array(), '', 'textbutaction', $default).' '; } else { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTBTNACTION, array()), ''); if ($color) { diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index c090d999114dd..c4bebcedbb62b 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -1033,7 +1033,7 @@ function getNbOfImagePublicURLOfObject($object) * @param int $no Numero of image (if there is several images. 1st one by default) * @param string $extName Extension to differentiate thumb file name ('', '_small', '_mini') * @return string HTML img content or '' if no image found - * @see getNbOfImagePublicURLOfObject(), getPublicFilesOfObject() + * @see getNbOfImagePublicURLOfObject(), getPublicFilesOfObject(), getImageFromHtmlContent() */ function getImagePublicURLOfObject($object, $no = 1, $extName = '') { @@ -1334,6 +1334,7 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so * @param string $htmlContent HTML content * @param int $imageNumber The position of image. 1 by default = first image found * @return string URL of image or '' if not foud + * @see getImagePublicURLOfObject() */ function getImageFromHtmlContent($htmlContent, $imageNumber = 1) { diff --git a/htdocs/core/lib/xcal.lib.php b/htdocs/core/lib/xcal.lib.php index 9986ccca60a3f..4ac67cb32628b 100644 --- a/htdocs/core/lib/xcal.lib.php +++ b/htdocs/core/lib/xcal.lib.php @@ -397,6 +397,18 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt $tmpevent['desc'] = $event->description; if (!empty($event->image)) { $tmpevent['image'] = $GLOBALS['website']->virtualhost.'/medias/'.$event->image; + } else { + include_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php'; + $tmpimage = getImageFromHtmlContent($event->content); + if ($tmpimage) { + if (strpos($tmpimage, '/') === 0) { // If $tmpimage is an absolute path + $tmpevent['image'] = $GLOBALS['website']->virtualhost.$tmpimage; + } elseif (stripos($tmpimage, 'http') === 0) { // If $tmpimage is a full URI + $tmpevent['image'] = $tmpimage; + } else { + $tmpevent['image'] = $GLOBALS['website']->virtualhost.'/medias/'.$tmpimage; + } // TODO If $tmpimage is "data:..." + } } $tmpevent['content'] = $event->content; diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index e5f2244f88a0d..afa04f17b488a 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -83,9 +83,9 @@ function print_auguria_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout $showmode = dol_auguria_showmenu($type_user, $newTabMenu[$i], $listofmodulesforexternal); if ($showmode == 1) { $newTabMenu[$i]['url'] = make_substitutions($newTabMenu[$i]['url'], $substitarray); - // url = url from host, shorturl = relative path into dolibarr sources $url = $shorturl = $newTabMenu[$i]['url']; + if (!preg_match("/^(http:\/\/|https:\/\/)/i", $newTabMenu[$i]['url'])) { // Do not change url content for external links $tmp = explode('?', $newTabMenu[$i]['url'], 2); $url = $shorturl = $tmp[0]; @@ -109,6 +109,9 @@ function print_auguria_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout } } + // Phan issue #4881 requires that we reforce the type + '@phan-var-force array,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,prefix:string}> $newTabMenu'; + // TODO Find a generic solution if (preg_match('/search_project_user=__search_project_user__/', $shorturl)) { $search_project_user = GETPOSTINT('search_project_user'); @@ -119,6 +122,9 @@ function print_auguria_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout } } + // Phan issue #4881 requires that we reforce the type + '@phan-var-force array,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,prefix:string}> $newTabMenu'; + // Define the class (top menu selected or not) if (!empty($_SESSION['idmenu']) && $newTabMenu[$i]['rowid'] == $_SESSION['idmenu']) { $classname = 'class="tmenusel"'; @@ -690,7 +696,7 @@ function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$t * Function to test if an entry is enabled or not * * @param int $type_user 0=We need backoffice menu, 1=We need frontoffice menu - * @param array{rowid:string,fk_menu:string,langs:string,enabled:int<0,2>,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level:int,prefix:string} $menuentry Array for menu entry + * @param array{rowid:string,fk_menu:string,langs:string,enabled:int<0,2>,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level:int,prefix:string,module:string} $menuentry Array for menu entry * @param string[] $listofmodulesforexternal Array with list of modules allowed to external users * @return int<0,2> 0=Hide, 1=Show, 2=Show gray */ diff --git a/htdocs/core/menus/standard/auguria_menu.php b/htdocs/core/menus/standard/auguria_menu.php index 5416dfad1f0f0..a6190316c9f46 100644 --- a/htdocs/core/menus/standard/auguria_menu.php +++ b/htdocs/core/menus/standard/auguria_menu.php @@ -281,6 +281,7 @@ public function showmenu($mode, $moredata = null) if ($val2['level'] > 0) { $levelcursor = $val2['level'] - 1; while ($levelcursor >= 0) { + // @phan-suppress-next-line PhanTypeInvalidDimOffset if ($lastlevel2[$levelcursor] != 'enabled') { $showmenu = false; } diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index c3fdfdba886d1..da693f6abbe2a 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -498,6 +498,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $idsel = (empty($newTabMenu[$i]['mainmenu']) ? 'none' : $newTabMenu[$i]['mainmenu']); $newTabMenu[$i]['url'] = make_substitutions($newTabMenu[$i]['url'], $substitarray); + '@phan-var-force array,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,prefix:string}> $newTabMenu'; // url = url from host, shorturl = relative path into dolibarr sources $url = $shorturl = $newTabMenu[$i]['url']; diff --git a/htdocs/core/menus/standard/empty.php b/htdocs/core/menus/standard/empty.php index f00a785d93c12..915e6a3251ef4 100644 --- a/htdocs/core/menus/standard/empty.php +++ b/htdocs/core/menus/standard/empty.php @@ -288,6 +288,7 @@ public function showmenu($mode, $moredata = null) if ($val2['level'] > 0) { $levelcursor = $val2['level'] - 1; while ($levelcursor >= 0) { + // @phan-suppress-next-line PhanTypeInvalidDimOffset if ($lastlevel2[$levelcursor] != 'enabled') { $showmenu = false; } diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 5a3e77f10d704..a2612a039760d 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -109,12 +109,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it public $dirs = array(); /** - * @var array Module boxes + * @var array Module boxes */ public $boxes = array(); /** - * @var array Module constants + * @var array,5?:string,6?:int<0,1>}> Module constants + * (0:name,1:type,2:val,3:note,4:visible,5:entity,6:deleteonunactive) */ public $const = array(); @@ -812,7 +813,7 @@ public function getDescLong() if ($pathoffile) { // Mostly for external modules $content = file_get_contents($pathoffile, false, null, 0, 1024 * 1024); // Max size loaded 1Mb - if ((float) DOL_VERSION >= 6.0) { + if ((float) DOL_VERSION >= 6.0) { // @phpstan-ignore-line @include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php'; $content = dolMd2Html( @@ -844,7 +845,7 @@ public function getDescLong() } } - return $content; + return '
'.$content.'
'; } /** @@ -913,7 +914,7 @@ public function getChangeLog() if ($filefound) { // Mostly for external modules $content = file_get_contents($pathoffile); - if ((float) DOL_VERSION >= 6.0) { + if ((float) DOL_VERSION >= 6.0) { // @phpstan-ignore-line @include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php'; $content = dolMd2Html($content, 'parsedown', array('doc/' => dol_buildpath(strtolower($this->name).'/doc/', 1))); @@ -1290,7 +1291,7 @@ protected function _load_tables($reldir, $onlywithsuffix = '') } } if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'llx_') { - $result = run_sql($dir.$file, !getDolGlobalString('MAIN_DISPLAY_SQL_INSTALL_LOG') ? 1 : 0, '', 1); + $result = run_sql($dir.$file, !getDolGlobalString('MAIN_DISPLAY_SQL_INSTALL_LOG') ? 1 : 0, 0, 1); if ($result <= 0) { $error++; } @@ -1315,7 +1316,7 @@ protected function _load_tables($reldir, $onlywithsuffix = '') } } if (preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'llx_') { - $result = run_sql($dir.$file, !getDolGlobalString('MAIN_DISPLAY_SQL_INSTALL_LOG') ? 1 : 0, '', 1); + $result = run_sql($dir.$file, !getDolGlobalString('MAIN_DISPLAY_SQL_INSTALL_LOG') ? 1 : 0, 0, 1); if ($result <= 0) { $error++; } @@ -1340,7 +1341,7 @@ protected function _load_tables($reldir, $onlywithsuffix = '') } } if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 9) == 'functions') { - $result = run_sql($dir.$file, !getDolGlobalString('MAIN_DISPLAY_SQL_INSTALL_LOG') ? 1 : 0, '', 1); + $result = run_sql($dir.$file, !getDolGlobalString('MAIN_DISPLAY_SQL_INSTALL_LOG') ? 1 : 0, 0, 1); if ($result <= 0) { $error++; } @@ -1365,7 +1366,7 @@ protected function _load_tables($reldir, $onlywithsuffix = '') } } if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'data') { - $result = run_sql($dir.$file, !getDolGlobalString('MAIN_DISPLAY_SQL_INSTALL_LOG') ? 1 : 0, '', 1); + $result = run_sql($dir.$file, !getDolGlobalString('MAIN_DISPLAY_SQL_INSTALL_LOG') ? 1 : 0, 0, 1); if ($result <= 0) { $error++; } @@ -1390,7 +1391,7 @@ protected function _load_tables($reldir, $onlywithsuffix = '') } } if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 6) == 'update') { - $result = run_sql($dir.$file, !getDolGlobalString('MAIN_DISPLAY_SQL_INSTALL_LOG') ? 1 : 0, '', 1); + $result = run_sql($dir.$file, !getDolGlobalString('MAIN_DISPLAY_SQL_INSTALL_LOG') ? 1 : 0, 0, 1); if ($result <= 0) { $error++; } diff --git a/htdocs/core/modules/action/doc/pdf_standard_actions.class.php b/htdocs/core/modules/action/doc/pdf_standard_actions.class.php index 8bc4377426319..bf3d192070b44 100644 --- a/htdocs/core/modules/action/doc/pdf_standard_actions.class.php +++ b/htdocs/core/modules/action/doc/pdf_standard_actions.class.php @@ -1,9 +1,10 @@ - * Copyright (C) 2004-2012 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2024 MDW - * Copyright (C) 2024 Frédéric France +/* Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 Nick Fragoulis * * 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 @@ -23,7 +24,7 @@ /** * \file htdocs/core/modules/action/doc/pdf_standard_actions.class.php * \ingroup commercial - * \brief File to build PDF with events + * \brief File to build PDF with events (reports), it's not a standard module to generate a pdf for only one actioncomm */ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; @@ -42,8 +43,14 @@ class pdf_standard_actions */ public $db; + /** + * @var string error message + */ public $error; + /** + * @var string[] array of errors messages + */ public $errors; /** @@ -51,34 +58,78 @@ class pdf_standard_actions */ public $description; + /** + * @var int edition date + */ public $date_edition; + /** + * @var int year + */ public $year; + /** + * @var int month + */ public $month; + /** + * @var string title + */ public $title; + /** + * @var string subject + */ public $subject; + /** + * @var int left margin + */ public $marge_gauche; + /** + * @var int right margin + */ public $marge_droite; + /** + * @var int top margin + */ public $marge_haute; + /** + * @var int bottom margin + */ public $marge_basse; + /** + * @var array format + */ public $format; + /** + * @var string type of doc + */ public $type; + /** + * @var int page height + */ public $page_hauteur; + /** + * @var int page wicth + */ public $page_largeur; /** - * @var array + * @var int corner radius + */ + public $corner_radius; + + /** + * @var array{fullpath:string} */ public $result; @@ -101,7 +152,7 @@ public function __construct($db, $month, $year) $this->date_edition = time(); $this->month = $month; $this->year = $year; - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); // Page size for A4 format $this->type = 'pdf'; $formatarray = pdf_getFormat(); @@ -379,7 +430,7 @@ private function _pagehead(&$pdf, $outputlangs, $pagenb) $y = $pdf->GetY() + 2; - $pdf->Rect($this->marge_gauche, $y, ($this->page_largeur - $this->marge_gauche - $this->marge_droite), ($this->page_hauteur - $this->marge_haute - $this->marge_basse)); + $pdf->RoundedRect($this->marge_gauche, $y, ($this->page_largeur - $this->marge_gauche - $this->marge_droite), ($this->page_hauteur - $this->marge_haute - $this->marge_basse), $this->corner_radius, '1234', 'D'); $y = $pdf->GetY() + 1; return $y; diff --git a/htdocs/core/modules/action/modules_action.php b/htdocs/core/modules/action/modules_action.php index 1069baa571483..4cfb5103f006b 100644 --- a/htdocs/core/modules/action/modules_action.php +++ b/htdocs/core/modules/action/modules_action.php @@ -4,6 +4,7 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2016 Charlie Benke + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,9 +38,9 @@ abstract class ModeleAction extends CommonDocGenerator /** * Return list of active generation modules * - * @param DoliDB $db Database handler - * @param integer $maxfilenamelength Max length of value to show - * @return array List of templates + * @param DoliDB $db Database handler + * @param int<0,max> $maxfilenamelength Max length of value to show + * @return string[]|int<-1,0> List of templates */ public static function liste_modeles($db, $maxfilenamelength = 0) { diff --git a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php index e67f123d7c1cf..e98ee2642a957 100644 --- a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php +++ b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php @@ -9,7 +9,8 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2017 Ferran Marcet * Copyright (C) 2018-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Nick Fragoulis * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -113,7 +114,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); // Get source company $this->emetteur = $mysoc; if (empty($this->emetteur->country_code)) { @@ -368,10 +369,10 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Draw note frame if ($i > $pageposbeforenote) { $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter); - $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius, '1234', 'D'); } else { $height_note = $this->page_hauteur - ($tab_top + $heightforfooter); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1, $this->corner_radius, '1234', 'D'); } // Add footer @@ -390,12 +391,12 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $this->_pagehead($pdf, $object, 0, $outputlangs); } $height_note = $posyafter - $tab_top_newpage; - $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius, '1234', 'D'); } else { // No pagebreak $pdf->commitTransaction(); $posyafter = $pdf->GetY(); $height_note = $posyafter - $tab_top; - $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1, $this->corner_radius, '1234', 'D'); if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { @@ -708,9 +709,9 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede /** * Return list of active generation modules * - * @param DoliDB $db Database handler - * @param integer $maxfilenamelength Max length of value to show - * @return array List of templates + * @param DoliDB $db Database handler + * @param int<0,max> $maxfilenamelength Max length of value to show + * @return string[]|int<-1,0> List of templates */ public static function liste_modeles($db, $maxfilenamelength = 0) { @@ -761,7 +762,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } @@ -769,7 +770,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); @@ -959,7 +960,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); $pdf->SetTextColor(0, 0, 60); // Show sender name @@ -1011,7 +1012,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L'); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); // Show recipient name $pdf->SetXY($posx + 2, $posy + 3); diff --git a/htdocs/core/modules/bank/doc/pdf_ban.modules.php b/htdocs/core/modules/bank/doc/pdf_ban.modules.php index 23fbc7c175e67..3606b28ca31c5 100644 --- a/htdocs/core/modules/bank/doc/pdf_ban.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_ban.modules.php @@ -1,7 +1,8 @@ +/* Copyright (C) 2016 Laurent Destailleur * Copyright (C) 2024 MDW * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 Nick Fragoulis * * 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 @@ -78,7 +79,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo FAC_PDF_LOGO $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION @@ -206,7 +207,7 @@ public function write_file($object, $outputlangs) // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 3, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 3, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius, '1234', 'D'); $tab_height -= $height_note; $tab_top = $nexY + 6; diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index 27201aebf05b8..9f1852ccacca3 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -1,8 +1,9 @@ - * Copyright (C) 2020 Josep Lluís Amador - * Copyright (C) 2024 MDW - * Copyright (C) 2024 Frédéric France +/* Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2020 Josep Lluís Amador + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 Nick Fragoulis * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -89,7 +90,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo FAC_PDF_LOGO $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION @@ -238,7 +239,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 3, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 3, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius, '1234', 'D'); $tab_height -= $height_note; $tab_top = $nexY + 6; @@ -385,7 +386,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $pdf->SetXY($this->marge_gauche, $posY); $txt = $outputlangs->transnoentitiesnoconv("SEPAFrstOrRecur").' * : '; $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); - $pdf->Rect(80, $posY, 5, 5); + $pdf->RoundedRect(80, $posY, 5, 5, $this->corner_radius, '1234', 'D'); $pdf->SetXY(80, $posY); if ($object->frstrecur == 'RCUR') { $pdf->MultiCell(5, 3, 'X', 0, 'L'); @@ -394,7 +395,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $txt = $langs->transnoentitiesnoconv("ModeRECUR").' '.$langs->transnoentitiesnoconv("or"); $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); $posY += 6; - $pdf->Rect(80, $posY, 5, 5); + $pdf->RoundedRect(80, $posY, 5, 5, $this->corner_radius, '1234', 'D'); $pdf->SetXY(80, $posY); if ($object->frstrecur == 'FRST') { $pdf->MultiCell(5, 3, 'X', 0, 'L'); diff --git a/htdocs/core/modules/barcode/modules_barcode.class.php b/htdocs/core/modules/barcode/modules_barcode.class.php index 9e3fe8894e2d1..16232e783eb99 100644 --- a/htdocs/core/modules/barcode/modules_barcode.class.php +++ b/htdocs/core/modules/barcode/modules_barcode.class.php @@ -145,7 +145,7 @@ public function getToolTip($langs, $soc, $type) if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) { $s .= ''; } - $s .= yn(!$this->code_null, 1, 2); + $s .= yn($this->code_null ? 0 : 1, 1, 2); if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) { $s .= ' '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')'; } @@ -156,7 +156,7 @@ public function getToolTip($langs, $soc, $type) if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) { $s .= ''; } - $s .= yn(!$this->code_null, 1, 2); + $s .= yn($this->code_null ? 0 : 1, 1, 2); if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) { $s .= ' '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')'; } @@ -167,7 +167,7 @@ public function getToolTip($langs, $soc, $type) if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) { $s .= ''; } - $s .= yn(!$this->code_null, 1, 2); + $s .= yn($this->code_null ? 0 : 1, 1, 2); if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) { $s .= ' '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')'; } diff --git a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php index 9fb45623b372b..8e6660856a74f 100644 --- a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php @@ -2,8 +2,9 @@ /* Copyright (C) 2006 Rodolphe Quiedeville * Copyright (C) 2009-2015 Laurent Destailleur * Copyright (C) 2016 Juanjo Menent - * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Nick Fragoulis * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -86,6 +87,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); // Retrieves transmitter $this->emetteur = $mysoc; @@ -286,7 +288,7 @@ public function Header(&$pdf, $page, $pages, $outputlangs) $pdf->SetXY(114, 15); $pdf->MultiCell(40, 2, $outputlangs->transnoentities("Signature"), 0, 'L'); - $pdf->Rect(9, 14, 192, 35); + $pdf->RoundedRect(9, 14, 192, 35, $this->corner_radius, '1234', 'D'); $pdf->line(9, 19, 112, 19); $pdf->line(9, 25, 112, 25); //$pdf->line(9, 31, 201, 31); @@ -297,7 +299,7 @@ public function Header(&$pdf, $page, $pages, $outputlangs) // Number of cheques $posy = 51; - $pdf->Rect(9, $posy, 192, 6); + $pdf->RoundedRect(9, $posy, 192, 6, $this->corner_radius, '1234', 'D'); $pdf->line(55, $posy, 55, $posy + 6); $pdf->line(140, $posy, 140, $posy + 6); $pdf->line(170, $posy, 170, $posy + 6); @@ -336,7 +338,7 @@ public function Header(&$pdf, $page, $pages, $outputlangs) $pdf->MultiCell(20, 2, $outputlangs->transnoentities("Amount"), 0, 'R'); $pdf->line(9, $this->tab_top + 8, 201, $this->tab_top + 8); - $pdf->Rect(9, $this->tab_top, 192, $this->tab_height + 10); + $pdf->RoundedRect(9, $this->tab_top, 192, $this->tab_height + 10, $this->corner_radius, '1234', 'D'); } diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 8c711aea9763c..f00d76ee07e1d 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -8,7 +8,8 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2017-2018 Ferran Marcet * Copyright (C) 2018-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Nick Fragoulis * * 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 @@ -107,7 +108,7 @@ public function __construct(DoliDB $db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION $this->option_modereg = 1; // Display payment mode @@ -314,13 +315,14 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $pdf->useTemplate($tplidx); } $pagenb++; - $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, (is_object($outputlangsbis) ? $outputlangsbis : null)); + $pagehead = $this->_pagehead($pdf, $object, 1, $outputlangs, (is_object($outputlangsbis) ? $outputlangsbis : null)); + $top_shift = $pagehead['top_shift']; + $shipp_shift = $pagehead['shipp_shift']; $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); - - $tab_top = 90 + $top_shift; + $tab_top = 90 + $top_shift + $shipp_shift; $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10); // Incoterm @@ -337,7 +339,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius, '1234', 'D'); $tab_top = $nexY + 6; } @@ -377,7 +379,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1, $this->corner_radius, '1234', 'D'); $tab_top = $nexY + 6; } @@ -1200,7 +1202,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } @@ -1208,7 +1210,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter if (empty($hidetop)) { $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line takes a position y in 2nd parameter and 4th parameter @@ -1273,7 +1275,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ * @param Translate $outputlangs Object lang for output * @param Translate $outputlangsbis Object lang for output bis * @param string $titlekey Translation key to show as title of document - * @return float|int Return topshift value + * @return array top shift of linked object lines */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null, $titlekey = "PdfOrderTitle") { @@ -1408,6 +1410,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output $posy += 2; $top_shift = 0; + $shipp_shift = 0; // Show list of linked objects $current_y = $pdf->getY(); $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size); @@ -1450,7 +1453,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius, '1234', 'F'); $pdf->SetTextColor(0, 0, 60); } @@ -1506,7 +1509,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); } // Show recipient name @@ -1522,11 +1525,54 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output $pdf->SetXY($posx + 2, $posy); // @phan-suppress-next-line PhanPluginSuspiciousParamOrder $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection); + + // Show shipping address + if (getDolGlobalInt('SALES_ORDER_SHOW_SHIPPING_ADDRESS')) { + $idaddressshipping = $object->getIdContact('external', 'SHIPPING'); + + if (!empty($idaddressshipping)) { + $contactshipping = $object->fetch_Contact($idaddressshipping[0]); + $companystatic = new Societe($this->db); + $companystatic->fetch($object->contact->fk_soc); + $carac_client_name_shipping = pdfBuildThirdpartyName($object->contact, $outputlangs); + $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $companystatic, $object->contact, ($usecontact ? 1 : 0), 'target', $object); + } else { + $carac_client_name_shipping = pdfBuildThirdpartyName($object->thirdparty, $outputlangs); + $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object); + } + if (!empty($carac_client_shipping)) { + $posy += $hautcadre; + + $hautcadre -= 10; // Height for the shipping address does not need to be as high as main box + + // Show shipping frame + $pdf->SetXY($posx + 2, $posy - 5); + $pdf->SetFont('', '', $default_font_size - 2); + $pdf->MultiCell($widthrecbox, '', $outputlangs->transnoentities('ShippingTo'), 0, 'L', 0); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); + + // Show shipping name + $pdf->SetXY($posx + 2, $posy + 1); + $pdf->SetFont('', 'B', $default_font_size); + $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping, '', 'L'); + + $posy = $pdf->getY(); + + // Show shipping information + $pdf->SetXY($posx + 2, $posy); + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping, '', 'L'); + + $shipp_shift += $hautcadre + 10; + } + } } $pdf->SetTextColor(0, 0, 0); - return $top_shift; + $pagehead = array('top_shift' => $top_shift, 'shipp_shift' => $shipp_shift); + + return $pagehead; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index a881793cf0398..ac999c10042f0 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -8,7 +8,8 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2017 Ferran Marcet * Copyright (C) 2018-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Nick Fragoulis * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -112,7 +113,7 @@ public function __construct(DoliDB $db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION $this->option_modereg = 1; // Display payment mode @@ -347,13 +348,15 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $pdf->useTemplate($tplidx); } $pagenb++; - $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, (is_object($outputlangsbis) ? $outputlangsbis : null)); + $pagehead = $this->_pagehead($pdf, $object, 1, $outputlangs, (is_object($outputlangsbis) ? $outputlangsbis : null)); + $top_shift = $pagehead['top_shift']; + $shipp_shift = $pagehead['shipp_shift']; $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); - $tab_top = 90 + $top_shift; + $tab_top = 90 + $top_shift + $shipp_shift; $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10); $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; @@ -374,7 +377,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius, '1234', 'D'); $tab_top = $nexY + 6; } @@ -469,10 +472,10 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Draw note frame if ($i > $pageposbeforenote) { $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter); - $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius, '1234', 'D'); } else { $height_note = $this->page_hauteur - ($tab_top + $heightforfooter); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1, $this->corner_radius, '1234', 'D'); } // Add footer @@ -491,13 +494,13 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $this->_pagehead($pdf, $object, 0, $outputlangs); } $height_note = $posyafter - $tab_top_newpage; - $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius, '1234', 'D'); } else { // No pagebreak $pdf->commitTransaction(); $posyafter = $pdf->GetY(); $height_note = $posyafter - $tab_top; - $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1, $this->corner_radius, '1234', 'D'); if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { @@ -1355,7 +1358,7 @@ protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlan $pdf->SetTextColor(0, 0, 0); } - $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index); + $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index, 'posy' => $posy); $reshook = $hookmanager->executeHooks('afterPDFTotalTable', $parameters, $this); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { @@ -1410,7 +1413,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } @@ -1418,7 +1421,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); @@ -1439,7 +1442,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ * @param Translate $outputlangs Object lang for output * @param Translate $outputlangsbis Object lang for output bis * @param string $titlekey Translation key to show as title of document - * @return float|int Return topshift value + * @return array top shift of linked object lines */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null, $titlekey = "PdfOrderTitle") { @@ -1589,6 +1592,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output $posy += 2; $top_shift = 0; + $shipp_shift = 0; // Show list of linked objects $current_y = $pdf->getY(); $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size); @@ -1635,7 +1639,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'F'); $pdf->SetTextColor(0, 0, 60); } @@ -1692,7 +1696,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); } // Show recipient name @@ -1708,11 +1712,54 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output $pdf->SetXY($posx + 2, $posy); // @phan-suppress-next-line PhanPluginSuspiciousParamOrder $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection); + + // Show shipping address + if (getDolGlobalInt('SALES_ORDER_SHOW_SHIPPING_ADDRESS')) { + $idaddressshipping = $object->getIdContact('external', 'SHIPPING'); + + if (!empty($idaddressshipping)) { + $contactshipping = $object->fetch_Contact($idaddressshipping[0]); + $companystatic = new Societe($this->db); + $companystatic->fetch($object->contact->fk_soc); + $carac_client_name_shipping = pdfBuildThirdpartyName($object->contact, $outputlangs); + $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $companystatic, $object->contact, ($usecontact ? 1 : 0), 'target', $object); + } else { + $carac_client_name_shipping = pdfBuildThirdpartyName($object->thirdparty, $outputlangs); + $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object); + } + if (!empty($carac_client_shipping)) { + $posy += $hautcadre; + + $hautcadre -= 10; // Height for the shipping address does not need to be as high as main box + + // Show shipping frame + $pdf->SetXY($posx + 2, $posy - 5); + $pdf->SetFont('', '', $default_font_size - 2); + $pdf->MultiCell($widthrecbox, '', $outputlangs->transnoentities('ShippingTo'), 0, 'L', 0); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); + + // Show shipping name + $pdf->SetXY($posx + 2, $posy + 1); + $pdf->SetFont('', 'B', $default_font_size); + $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping, '', 'L'); + + $posy = $pdf->getY(); + + // Show shipping information + $pdf->SetXY($posx + 2, $posy); + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping, '', 'L'); + + $shipp_shift += $hautcadre + 10; + } + } } $pdf->SetTextColor(0, 0, 0); - return $top_shift; + $pagehead = array('top_shift' => $top_shift, 'shipp_shift' => $shipp_shift); + + return $pagehead; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php index 24b189fb09533..e4199a5bf8efd 100644 --- a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php @@ -67,7 +67,7 @@ public function __construct($db) * @param Translate $outputlangs Object lang for output * @param Translate $outputlangsbis Object lang for output bis * @param string $titlekey Translation key to show as title of document - * @return float|int Return topshift value + * @return array top shift of linked object lines */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null, $titlekey = "InvoiceProForma") { diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index 194f8846b4862..ca43aa31e9276 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -8,6 +8,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2024 MDW + * Copyright (C) 2024 Nick Fragoulis * * 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 @@ -108,7 +109,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo $this->option_tva = 0; // Manage the vat option FACTURE_TVAOPTION $this->option_modereg = 0; // Display payment mode @@ -271,7 +272,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius, '1234', 'D'); $tab_top = $nexY + 6; } @@ -543,11 +544,12 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ */ // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height + 3); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height + 3, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter } /** * Show footer signature of page + * * @param TCPDF $pdf Object PDF * @param int $tab_top tab height position * @param int $tab_height tab height @@ -560,17 +562,21 @@ protected function tabSignature(&$pdf, $tab_top, $tab_height, $outputlangs) $posmiddle = $this->marge_gauche + round(($this->page_largeur - $this->marge_gauche - $this->marge_droite) / 2); $posy = $tab_top + $tab_height + 3 + 3; - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->MultiCell($posmiddle - $this->marge_gauche - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->emetteur->name), 0, 'L', 0); + if (!getDolGlobalString('CONTRACT_HIDE_MYCOMPANY_SIGNATURE_SECTION_PDF')) { + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->MultiCell($posmiddle - $this->marge_gauche - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->emetteur->name), 0, 'L', 0); - $pdf->SetXY($this->marge_gauche, $posy + 5); - $pdf->MultiCell($posmiddle - $this->marge_gauche - 5, 20, '', 1); + $pdf->SetXY($this->marge_gauche, $posy + 5); + $pdf->RoundedRect($this->marge_gauche, $posy + 5, $posmiddle - $this->marge_gauche - 5, 20, $this->corner_radius, '1234', 'D'); + } - $pdf->SetXY($posmiddle + 5, $posy); - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posmiddle - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->recipient->name), 0, 'L', 0); + if (!getDolGlobalString('CONTRACT_HIDE_THIRPARTY_SIGNATURE_SECTION_PDF')) { + $pdf->SetXY($posmiddle + 5, $posy); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posmiddle - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->recipient->name), 0, 'L', 0); - $pdf->SetXY($posmiddle + 5, $posy + 5); - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posmiddle - 5, 20, '', 1); + $pdf->SetXY($posmiddle + 5, $posy + 5); + $pdf->RoundedRect($posmiddle + 5, $posy + 5, $this->page_largeur - $this->marge_droite - $posmiddle - 5, 20, $this->corner_radius, '1234', 'D'); + } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore @@ -710,7 +716,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output $pdf->SetXY($posx, $posy - 5); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius, '1234', 'F'); $pdf->SetTextColor(0, 0, 60); } @@ -768,7 +774,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); $pdf->SetTextColor(0, 0, 0); } diff --git a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php index 3df593da5d77f..e61453a8fc2fa 100644 --- a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php @@ -6,9 +6,10 @@ * Copyright (C) 2011-2021 Philippe Grand * Copyright (C) 2015 Marcos García * Copyright (C) 2020 John BOTELLA - * Copyright (C) 2024 MDW - * Copyright (C) 2024 Frédéric France - + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 Nick Fragoulis + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -100,7 +101,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo FAC_PDF_LOGO $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION @@ -309,7 +310,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius, '1234', 'D'); $tab_top = $nexY + 6; $height_incoterms += 4; @@ -335,7 +336,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius, '1234', 'D'); $tab_height -= $height_note; $tab_top = $nexY + 6; @@ -615,11 +616,11 @@ protected function _tableau_info(&$pdf, $object, $posy, $outputlangs) $pdf->SetXY($this->marge_gauche, $posy); $larg_sign = ($this->page_largeur - $this->marge_gauche - $this->marge_droite) / 3; - $pdf->Rect($this->marge_gauche, $posy + 1, $larg_sign, 25); + $pdf->RoundedRect($this->marge_gauche, $posy + 1, $larg_sign, 25, $this->corner_radius, '1234', 'D'); $pdf->SetXY($this->marge_gauche + 2, $posy + 2); $pdf->MultiCell($larg_sign, 2, $outputlangs->trans("For").' '.$outputlangs->convToOutputCharset($mysoc->name).":", '', 'L'); - $pdf->Rect(2 * $larg_sign + $this->marge_gauche, $posy + 1, $larg_sign, 25); + $pdf->RoundedRect(2 * $larg_sign + $this->marge_gauche, $posy + 1, $larg_sign, 25, $this->corner_radius, '1234', 'D'); $pdf->SetXY(2 * $larg_sign + $this->marge_gauche + 2, $posy + 2); $pdf->MultiCell($larg_sign, 2, $outputlangs->trans("ForCustomer").':', '', 'L'); } @@ -657,7 +658,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ if (empty($hidetop)) { //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } @@ -665,7 +666,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); @@ -773,7 +774,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillFrom"), 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius, '1234', 'F'); $pdf->SetTextColor(0, 0, 60); // Show sender name @@ -833,7 +834,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); //$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L'); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); // Show recipient name $pdf->SetXY($posx + 2, $posy + 3); diff --git a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php index ef5ecdabcc9ec..5f9173e7581be 100644 --- a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php @@ -5,9 +5,10 @@ * Copyright (C) 2008 Chiptronik * Copyright (C) 2011-2021 Philippe Grand * Copyright (C) 2015 Marcos García - * Copyright (C) 2024 MDW - * Copyright (C) 2024 Frédéric France - + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 Nick Fragoulis + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -103,7 +104,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo FAC_PDF_LOGO $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION @@ -294,7 +295,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius, '1234', 'D'); $tab_top = $nexY + 6; $height_incoterms += 4; @@ -312,7 +313,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius, '1234', 'D'); $tab_height -= $height_note; $tab_top = $nexY + 6; @@ -608,11 +609,11 @@ protected function _tableau_info(&$pdf, $object, $posy, $outputlangs) $pdf->SetXY($this->marge_gauche, $posy); $larg_sign = ($this->page_largeur - $this->marge_gauche - $this->marge_droite) / 3; - $pdf->Rect($this->marge_gauche, $posy + 1, $larg_sign, 25); + $pdf->RoundedRect($this->marge_gauche, $posy + 1, $larg_sign, 25, $this->corner_radius, '1234', 'D'); $pdf->SetXY($this->marge_gauche + 2, $posy + 2); $pdf->MultiCell($larg_sign, 2, $outputlangs->trans("For").' '.$outputlangs->convToOutputCharset($mysoc->name).":", '', 'L'); - $pdf->Rect(2 * $larg_sign + $this->marge_gauche, $posy + 1, $larg_sign, 25); + $pdf->RoundedRect(2 * $larg_sign + $this->marge_gauche, $posy + 1, $larg_sign, 25, $this->corner_radius, '1234', 'D'); $pdf->SetXY(2 * $larg_sign + $this->marge_gauche + 2, $posy + 2); $pdf->MultiCell($larg_sign, 2, $outputlangs->trans("ForCustomer").':', '', 'L'); } @@ -647,7 +648,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetFont('', '', $default_font_size - 2); // Output Rec - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter if (empty($hidetop)) { $pdf->line($this->marge_gauche, $tab_top + 10, $this->page_largeur - $this->marge_droite, $tab_top + 10); @@ -781,7 +782,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillFrom"), 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius, '1234', 'D'); $pdf->SetTextColor(0, 0, 60); // Show sender name @@ -841,7 +842,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); //$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L'); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); // Show recipient name $pdf->SetXY($posx + 2, $posy + 3); diff --git a/htdocs/core/modules/dons/modules_don.php b/htdocs/core/modules/dons/modules_don.php index a6c9d4f3e656b..6aa58b432d05f 100644 --- a/htdocs/core/modules/dons/modules_don.php +++ b/htdocs/core/modules/dons/modules_don.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005 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 @@ -39,9 +40,9 @@ abstract class ModeleDon extends CommonDocGenerator /** * Return list of active generation modules * - * @param DoliDB $db Database handler - * @param integer $maxfilenamelength Max length of value to show - * @return array List of templates + * @param DoliDB $db Database handler + * @param int<0,max> $maxfilenamelength Max length of value to show + * @return string[]|int<-1,0> List of templates */ public static function liste_modeles($db, $maxfilenamelength = 0) { diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 4a14a1778bccd..40415f5f2b960 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -1,11 +1,12 @@ - * Copyright (C) 2005-2012 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2014-2015 Marcos García - * Copyright (C) 2018-2024 Frédéric France - * Copyright (C) 2023 Charlene Benke - * Copyright (C) 2024 MDW +/* Copyright (C) 2005 Rodolphe Quiedeville + * Copyright (C) 2005-2012 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2014-2015 Marcos García + * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2023 Charlene Benke + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Nick Fragoulis * * 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 @@ -69,8 +70,17 @@ class pdf_espadon extends ModelePdfExpedition */ public $version = 'dolibarr'; + /** + * @var int|float + */ public $posxweightvol; + /** + * @var int|float + */ public $posxqtytoship; + /** + * @var int|float + */ public $posxqtyordered; @@ -97,7 +107,7 @@ public function __construct(DoliDB $db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo $this->option_draft_watermark = 1; // Support add of a watermark on drafts $this->watermark = ''; @@ -311,7 +321,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius, '1234', 'D'); $tab_top = $nexY + 6; $height_incoterms += 4; @@ -439,7 +449,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter) + $height_trackingnumber + 1; $tab_top_newpage = $tab_topbeforetrackingnumber; } - $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2); + $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); } else { if (empty($height_trackingnumber)) { $height_note = $this->page_hauteur - ($tab_top + $heightforfooter); @@ -447,7 +457,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $height_note = $this->page_hauteur - ($tab_top + $heightforfooter) + $height_trackingnumber + 1; $tab_top = $tab_topbeforetrackingnumber; } - $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); } // Add footer @@ -466,7 +476,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $this->_pagehead($pdf, $object, 0, $outputlangs); } $height_note = $posyafter - $tab_top_newpage; - $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius, '1234', 'D'); } else { // No pagebreak $pdf->commitTransaction(); $posyafter = $pdf->GetY(); @@ -476,7 +486,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $height_note = $posyafter - $tab_top + $height_trackingnumber + 1; $tab_top = $tab_topbeforetrackingnumber; } - $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { @@ -865,7 +875,7 @@ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1); } if (!empty($object->trueWeight)) { - $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); + $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, (int) $object->weight_units, "weight", $outputlangs); } if (!empty($object->trueVolume)) { if ($object->volume_units < 50) { @@ -943,7 +953,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ if (empty($hidetop)) { if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', array(), explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, $this->corner_radius, '1001', 'F', array(), explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } @@ -951,7 +961,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); @@ -967,7 +977,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ * * @param TCPDF $pdf Object PDF * @param Expedition $object Object to show - * @param int $showaddress 0=no, 1=yes + * @param int<0,1> $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output * @return float|int Return topshift value */ @@ -1066,6 +1076,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $classname = ucfirst($origin); $linkedobject = new $classname($this->db); + '@phan-var-force Commande|Facture $linkedobject'; $result = $linkedobject->fetch($origin_id); if ($result >= 0) { //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects @@ -1134,7 +1145,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Sender"), 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'F'); $pdf->SetTextColor(0, 0, 60); $pdf->SetFillColor(255, 255, 255); } @@ -1189,7 +1200,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient"), 0, 'L'); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); } // Show recipient name diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index bfc9ee0a2cb40..fccb96c7e60c5 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -4,8 +4,9 @@ * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2013 Florian Henry * Copyright (C) 2015 Marcos García - * Copyright (C) 2024 MDW - * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 Nick Fragoulis * * 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 @@ -98,7 +99,7 @@ public function __construct(DoliDB $db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo // Get source company @@ -256,7 +257,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius, '1234', 'D'); $tab_height -= $height_note; $tab_top = $nexY + 6; @@ -440,7 +441,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetXY(170, $tab_top); $pdf->MultiCell(30, 5, $outputlangs->transnoentities("QtyToShip"), 0, 'C', 1); } - $pdf->Rect(10, $tab_top, 190, $tab_height); + $pdf->RoundedRect(10, $tab_top, 190, $tab_height, $this->corner_radius, '1234', 'D'); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore @@ -631,7 +632,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $blExpX = $Xoff - 20; $blW = 52; $Ydef = $Yoff; - $pdf->Rect($blExpX, $Yoff, $blW, 26); + $pdf->RoundedRect($blExpX, $Yoff, $blW, 26, $this->corner_radius, '1234', 'D'); $object->fetch_thirdparty(); @@ -674,7 +675,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->SetFont('', 'B', $default_font_size - 3); $pdf->SetXY($blDestX, $Yoff - 4); $pdf->MultiCell($blW, 3, $outputlangs->transnoentities("Recipient"), 0, 'L'); - $pdf->Rect($blDestX, $Yoff - 1, $blW, 26); + $pdf->RoundedRect($blDestX, $Yoff - 1, $blW, 26, $this->corner_radius, '1234', 'D'); // Show recipient name $pdf->SetFont('', 'B', $default_font_size - 3); diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 703e74ea93b05..5cf08c6ad018b 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -3,8 +3,9 @@ * Copyright (C) 2005-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014-2015 Marcos García - * Copyright (C) 2018-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Nick Fragoulis * * 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 @@ -69,8 +70,17 @@ class pdf_rouget extends ModelePdfExpedition */ public $version = 'dolibarr'; + /** + * @var float|int + */ public $posxweightvol; + /** + * @var float|int + */ public $posxqtytoship; + /** + * @var float|int + */ public $posxqtyordered; @@ -97,7 +107,7 @@ public function __construct(DoliDB $db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo $this->option_draft_watermark = 1; // Support add of a watermark on drafts $this->watermark = ''; @@ -342,7 +352,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius, '1234', 'D'); $tab_top = $nexY + 6; $height_incoterms += 4; @@ -390,7 +400,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Notes if (!empty($object->note_public)) { $pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page - $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1); } $nexY = $pdf->GetY(); @@ -398,7 +408,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 3, $this->corner_radius, '1234', 'D'); $tab_height -= $height_note; $tab_top = $nexY + 6; @@ -757,7 +767,7 @@ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1); } if (!empty($object->trueWeight)) { - $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); + $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, (int) $object->weight_units, "weight", $outputlangs); } if (!empty($object->trueVolume)) { $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); @@ -815,7 +825,7 @@ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs * * @param TCPDF $pdf Object PDF * @param float|int $tab_top Top position of table - * @param float|int $tab_height Height of table (rectangle) + * @param float|int $tab_height Height of table (angle) * @param int $nexY Y * @param Translate $outputlangs Langs object * @param int $hidetop Hide top bar of array @@ -840,7 +850,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetFont('', '', $default_font_size - 2); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter $pdf->SetDrawColor(128, 128, 128); $pdf->SetFont('', '', $default_font_size - 1); @@ -999,6 +1009,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $classname = ucfirst($origin); $linkedobject = new $classname($this->db); + '@phan-var-force Commande|Facture $linkedobject'; $result = $linkedobject->fetch($origin_id); if ($result >= 0) { //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects @@ -1067,7 +1078,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Sender"), 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'F'); $pdf->SetTextColor(0, 0, 60); $pdf->SetFillColor(255, 255, 255); } @@ -1122,7 +1133,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient"), 0, 'L'); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); } // Show recipient name diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard_expensereport.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard_expensereport.modules.php index 2e69df6d35533..88e18d4d23f62 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard_expensereport.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard_expensereport.modules.php @@ -7,7 +7,8 @@ * Copyright (C) 2019 Markus Welters * Copyright (C) 2019 Rafael Ingenleuf * Copyright (C) 2020 Marc Guenneugues - * Copyright (C) 2024 MDW + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Nick Fragoulis * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -119,7 +120,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION $this->option_modereg = 1; // Display payment mode @@ -315,7 +316,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1, $this->corner_radius, '1234', 'D'); $tab_height -= $height_note; $tab_top = $nexY + 6; @@ -759,7 +760,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->MultiCell(80, 5, $outputlangs->transnoentities("TripSociete"), '', 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(224, 224, 224); - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius, '1234', 'F'); $pdf->SetTextColor(0, 0, 60); // Show sender information @@ -791,7 +792,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->SetFont('', 'B', 8); $pdf->SetXY($posx, $posy - 5); $pdf->MultiCell(80, 5, $outputlangs->transnoentities("TripNDF")." :", 0, 'L'); - $pdf->rect($posx, $posy, $this->page_largeur - $this->marge_gauche - $posx, $hautcadre); + $pdf->RoundedRect($posx, $posy, $this->page_largeur - $this->marge_gauche - $posx, $hautcadre, $this->corner_radius, '1234', 'D'); // Information for expense report (dates and users workflow) if ($object->fk_user_author > 0) { @@ -901,8 +902,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetDrawColor(128, 128, 128); // Rect takes a length in 3rd parameter - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height); - // line prend une position y en 3eme param + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, '1234', 'D'); if (empty($hidetop)) { $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); } diff --git a/htdocs/core/modules/expensereport/mod_expensereport_sand.php b/htdocs/core/modules/expensereport/mod_expensereport_sand.php index 15180f5ff2663..0c5962c871e1f 100644 --- a/htdocs/core/modules/expensereport/mod_expensereport_sand.php +++ b/htdocs/core/modules/expensereport/mod_expensereport_sand.php @@ -152,7 +152,7 @@ public function getNextValue($object) $fuser->fetch($object->fk_user_author); } - $numFinal = get_next_value($db, $mask, 'expensereport', 'ref', '', null, (string) $date, 'next', true, $fuser); + $numFinal = get_next_value($db, $mask, 'expensereport', 'ref', '', null, $date, 'next', true, $fuser); return $numFinal; } diff --git a/htdocs/core/modules/export/exportcsv.class.php b/htdocs/core/modules/export/exportcsv.class.php index 4be654b38ebab..1e263a6728402 100644 --- a/htdocs/core/modules/export/exportcsv.class.php +++ b/htdocs/core/modules/export/exportcsv.class.php @@ -208,8 +208,11 @@ public function write_title($array_export_fields_label, $array_selected_sorted, continue; } - $newvalue = $outputlangs->transnoentities($array_export_fields_label[$code]); // newvalue is now $outputlangs->charset_output encoded - $newvalue = $this->csvClean($newvalue, $outputlangs->charset_output); + $newvalue = $array_export_fields_label[$code]; + + // Clean data and add encloser if required (depending on value of USE_STRICT_CSV_RULES) + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $newvalue = csvClean($newvalue, $outputlangs->charset_output, $this->separator); fwrite($this->handle, $newvalue.$this->separator); $typefield = isset($array_types[$code]) ? $array_types[$code] : ''; @@ -258,7 +261,7 @@ public function write_record($array_selected_sorted, $objp, $outputlangs, $array continue; } - $newvalue = $outputlangs->convToOutputCharset($objp->$alias); // objp->$alias must be utf8 encoded as any var in memory // newvalue is now $outputlangs->charset_output encoded + $newvalue = $objp->$alias; $typefield = isset($array_types[$code]) ? $array_types[$code] : ''; // Translation newvalue @@ -267,7 +270,8 @@ public function write_record($array_selected_sorted, $objp, $outputlangs, $array } // Clean data and add encloser if required (depending on value of USE_STRICT_CSV_RULES) - $newvalue = $this->csvClean($newvalue, $outputlangs->charset_output); + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $newvalue = csvClean($newvalue, $outputlangs->charset_output, $this->separator); if (preg_match('/^Select:/i', $typefield) && $typefield = substr($typefield, 7)) { $array = jsonOrUnserialize($typefield); @@ -316,51 +320,4 @@ public function close_file() fclose($this->handle); return 0; } - - - /** - * Clean a cell to respect rules of CSV file cells - * Note: It uses $this->separator - * Note: We keep this function public to be able to test - * - * @param string $newvalue String to clean - * @param string $charset Input AND Output character set - * @return string Value cleaned - */ - public function csvClean($newvalue, $charset) - { - $addquote = 0; - - // Rule Dolibarr: No HTML - //print $charset.' '.$newvalue."\n"; - //$newvalue=dol_string_nohtmltag($newvalue,0,$charset); - $newvalue = dol_htmlcleanlastbr($newvalue); - //print $charset.' '.$newvalue."\n"; - - // Rule 1 CSV: No CR, LF in cells (except if USE_STRICT_CSV_RULES is 1, we can keep record as it is but we must add quotes) - $oldvalue = $newvalue; - $newvalue = str_replace("\r", '', $newvalue); - $newvalue = str_replace("\n", '\n', $newvalue); - if (getDolGlobalString('USE_STRICT_CSV_RULES') && $oldvalue != $newvalue) { - // If we must use enclusure on text with CR/LF) - if (getDolGlobalInt('USE_STRICT_CSV_RULES') == 1) { - // If we use strict CSV rules (original value must remain but we add quote) - $newvalue = $oldvalue; - } - $addquote = 1; - } - - // Rule 2 CSV: If value contains ", we must escape with ", and add " - if (preg_match('/"/', $newvalue)) { - $addquote = 1; - $newvalue = str_replace('"', '""', $newvalue); - } - - // Rule 3 CSV: If value contains separator, we must add " - if (preg_match('/'.$this->separator.'/', $newvalue)) { - $addquote = 1; - } - - return ($addquote ? '"' : '').$newvalue.($addquote ? '"' : ''); - } } diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 9afb01fc36145..4a48aba4c93bc 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -318,7 +318,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } // Fetch info for linked propal - $object->fetchObjectLinked('', '', '', ''); + $object->fetchObjectLinked(0, '', null, ''); //print_r($object->linkedObjects['propal']); exit; $propal_object = null; diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index f40b2279de6ec..143d5e9eddba4 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -12,6 +12,7 @@ * Copyright (C) 2022 Anthony Berton * Copyright (C) 2022 Charlene Benke * Copyright (C) 2024 MDW + * Copyright (C) 2024 Nick Fragoulis * * 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 @@ -120,7 +121,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION $this->option_modereg = 1; // Display payment mode @@ -516,7 +517,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius, '1234', 'D'); $tab_top = $nexY + 6; } @@ -556,7 +557,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1, $this->corner_radius, '1234', 'D'); $tab_top = $nexY + 6; } @@ -866,7 +867,8 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis); // Display Payments area - if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && !getDolGlobalString('INVOICE_NO_PAYMENT_DETAILS')) { + $listofpayments = $object->getListOfPayments('', 0, 1); + if ((count($listofpayments) || $amount_credit_notes_included || $amount_deposits_included) && !getDolGlobalString('INVOICE_NO_PAYMENT_DETAILS')) { $posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs, $heightforfooter); } @@ -928,7 +930,6 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede protected function _tableau_versements(&$pdf, $object, $posy, $outputlangs, $heightforfooter = 0) { // phpcs:enable - global $conf; $sign = 1; if ($object->type == 2 && getDolGlobalString('INVOICE_POSITIVE_CREDIT_NOTE')) { @@ -1014,7 +1015,7 @@ protected function _tableau_versements(&$pdf, $object, $posy, $outputlangs, $hei } // Loop on each payment - // TODO Call getListOfPaymentsgetListOfPayments instead of hard coded sql + // TODO Call getListOfPayments instead of hard coded sql $sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; $sql .= " cp.code"; $sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; @@ -1736,7 +1737,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } @@ -1744,7 +1745,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter if (empty($hidetop)) { $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line takes a position y in 2nd parameter and 4th parameter @@ -2086,7 +2087,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'F'); $pdf->SetTextColor(0, 0, 60); } @@ -2142,7 +2143,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); } // Show recipient name @@ -2176,11 +2177,13 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output if (!empty($carac_client_shipping)) { $posy += $hautcadre; + $hautcadre -= 10; // Height for the shipping address does not need to be as high as main box + // Show shipping frame $pdf->SetXY($posx + 2, $posy - 5); $pdf->SetFont('', '', $default_font_size - 2); $pdf->MultiCell($widthrecbox, '', $outputlangs->transnoentities('ShippingTo'), 0, 'L', 0); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); // Show shipping name $pdf->SetXY($posx + 2, $posy + 3); @@ -2193,7 +2196,8 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output $pdf->SetXY($posx + 2, $posy); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping, '', 'L'); - $top_shift += $hautcadre; + + $top_shift += $hautcadre + 10; } } } diff --git a/htdocs/core/modules/facture/doc/pdf_octopus.modules.php b/htdocs/core/modules/facture/doc/pdf_octopus.modules.php index d5b62a2779195..5513d1bbaf907 100644 --- a/htdocs/core/modules/facture/doc/pdf_octopus.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_octopus.modules.php @@ -12,7 +12,8 @@ * Copyright (C) 2022 Anthony Berton * Copyright (C) 2022-2024 Alexandre Spangaro * Copyright (C) 2022-2024 Eric Seigne - * Copyright (C) 2024 MDW + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Nick Fragoulis * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -90,7 +91,7 @@ class pdf_octopus extends ModelePDFFactures public $heightforfreetext; /** - * @var int height for footer + * @var float height for footer */ public $heightforfooter; @@ -207,7 +208,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->posx_cumul_anterieur = 94; $this->posx_new_cumul = 130; $this->posx_current = 166; @@ -603,7 +604,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); + $pdf->RoundedRect($this->marge_gauche, $this->tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius, '1234', 'D'); $this->tab_top = $nexY + 6; $height_incoterms += 4; @@ -699,10 +700,10 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Draw note frame if ($i > $pageposbeforenote) { $height_note = $this->page_hauteur - ($this->tab_top_newpage + $this->heightforfooter); - $pdf->Rect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); } else { $height_note = $this->page_hauteur - ($this->tab_top + $this->heightforfooter); - $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); } // Add footer @@ -721,13 +722,13 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis); } $height_note = $posyafter - $this->tab_top_newpage; - $pdf->Rect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); } else { // No pagebreak $pdf->commitTransaction(); $posyafter = $pdf->GetY(); $height_note = $posyafter - $this->tab_top; - $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) { @@ -1115,7 +1116,8 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis); // Display payment area - if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && !getDolGlobalString('INVOICE_NO_PAYMENT_DETAILS')) { + $listofpayments = $object->getListOfPayments('', 0, 1); + if ((count($listofpayments) || $amount_credit_notes_included || $amount_deposits_included) && !getDolGlobalString('INVOICE_NO_PAYMENT_DETAILS')) { $posy = $this->drawPaymentsTable($pdf, $object, $posy, $outputlangs); } @@ -1261,7 +1263,7 @@ public function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs) } // Loop on each payment - // TODO Call getListOfPaymentsgetListOfPayments instead of hard coded sql + // TODO Call getListOfPayments instead of hard coded sql $sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; $sql .= " cp.code"; $sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; @@ -1908,7 +1910,7 @@ protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlan $pdf->SetTextColor(0, 0, 0); } - $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index); + $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index, 'posy' => $posy); $reshook = $hookmanager->executeHooks('afterPDFTotalTable', $parameters, $this); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { @@ -1978,7 +1980,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ // MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } $tab_top += 4; } @@ -1987,7 +1989,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param + $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect prend une longueur en 3eme param et 4eme param // situation invoice $pdf->SetFont('', '', $default_font_size - 2); @@ -2303,7 +2305,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'F'); $pdf->SetTextColor(0, 0, 60); } @@ -2358,7 +2360,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); } // Show recipient name @@ -2396,7 +2398,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output $pdf->SetXY($posx + 2, $posy - 5); $pdf->SetFont('', '', $default_font_size - 2); $pdf->MultiCell($widthrecbox, '', $outputlangs->transnoentities('ShippingTo'), 0, 'L', 0); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); // Show shipping name $pdf->SetXY($posx + 2, $posy + 3); @@ -2773,8 +2775,10 @@ public function _tableFirstPage(&$pdf, $tab_top, $tab_height, $nexY, $outputlang //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->Rect($this->posx_cumul_anterieur - 1, $tab_top, $width, 5, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); - $pdf->Rect($this->marge_gauche, $tab_top + 92.5, $this->page_largeur - $this->marge_gauche - $this->marge_droite, 5, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + //$pdf->Rect($this->posx_cumul_anterieur - 1, $tab_top, $width, 5, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->posx_cumul_anterieur - 1, $tab_top, $width, 5, $this->corner_radius, '1001', 'F', explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + //$pdf->Rect($this->marge_gauche, $tab_top + 92.5, $this->page_largeur - $this->marge_gauche - $this->marge_droite, 5, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top + 92.5, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } @@ -2783,7 +2787,7 @@ public function _tableFirstPage(&$pdf, $tab_top, $tab_height, $nexY, $outputlang // Output Rect // KEEPTHIS => Affiche les bords extérieurs - $this->printRectBtp($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param + $this->printRoundedRectBtp($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect prend une longueur en 3eme param et 4eme param $pdf->line($this->posx_cumul_anterieur - 1, $tab_top, $this->posx_cumul_anterieur - 1, $tab_top + $tab_height); if (empty($hidetop)) { @@ -3211,6 +3215,7 @@ public function getInfosLineLastSituation(&$object, &$current_line) * @param int $hidebottom Hide bottom * @return void */ + /* public function printRectBtp(&$pdf, $x, $y, $l, $h, $hidetop = 0, $hidebottom = 0) { if (empty($hidetop) || $hidetop == -1) { @@ -3221,8 +3226,35 @@ public function printRectBtp(&$pdf, $x, $y, $l, $h, $hidetop = 0, $hidebottom = $pdf->line($x + $l, $y + $h, $x, $y + $h); } $pdf->line($x, $y + $h, $x, $y); - } + }*/ + /** + * Print a rounded rectangle on the PDF + * + * @param TCPDF $pdf Object PDF + * @param float $x Abscissa of first point + * @param float $y Ordinate of first point + * @param float $w Width of the rectangle + * @param float $h Height of the rectangle + * @param float $r Corner radius (can be an array for different radii per corner) + * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title + * @param int $hidebottom Hide bottom + * @param string $style Draw style (e.g. 'D' for draw, 'F' for fill, 'DF' for both) + * @return void + */ + public function printRoundedRectBtp($pdf, $x, $y, $w, $h, $r, $hidetop = 0, $hidebottom = 0, $style = 'D') + { + // Top line + if (empty($hidetop) || $hidetop == -1) { + $pdf->RoundedRect($x, $y, $w, $h, $r, '1111', $style); + } else { + // Draw rounded rectangle with hidden top side + $pdf->RoundedRect($x, $y, $w, $h, $r, '0111', $style); + } + if (!empty($hidebottom)) { + $pdf->RoundedRect($x, $y, $w, $h, $r, '1101', $style); + } + } /** * Get data about invoice @@ -3400,7 +3432,8 @@ public function resumeLastPage(&$pdf, $object, $deja_regle, $posy, $outputlangs, // Output Rect $pdf->SetDrawColor(128, 128, 128); - $this->printRect($pdf, $posx, $posy, $this->page_largeur - $this->marge_gauche - $this->marge_droite, 6); // Rect prend une longueur en 3eme param et 4eme param + //$this->printRect($pdf, $posx, $posy, $this->page_largeur - $this->marge_gauche - $this->marge_droite, 6); // Rect prend une longueur en 3eme param et 4eme param + $this->printRoundedRect($pdf, $posx, $posy, $this->page_largeur - $this->marge_gauche - $this->marge_droite, 6, $this->corner_radius, 0, 0, 'D'); // Rect takes a length in 3rd parameter and 4th parameter $posy += 4; } elseif (count($orders)) { @@ -3680,7 +3713,8 @@ public function resumeLastPage(&$pdf, $object, $deja_regle, $posy, $outputlangs, // Output Rect $pdf->SetDrawColor(128, 128, 128); - $this->printRect($pdf, $this->marge_gauche, $posy, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height * $index + $y); + //$this->printRect($pdf, $this->marge_gauche, $posy, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height * $index + $y); + $this->printRoundedRect($pdf, $this->marge_gauche, $posy, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height * $index + $y, $this->corner_radius, 0, 0, 'D'); $posy += $height * $index + $y; $pageposafter = $pdf->getPage(); @@ -3740,6 +3774,7 @@ public function resumeLastPage(&$pdf, $object, $deja_regle, $posy, $outputlangs, $pdf->MultiCell($width2, 3, $amount, 0, 'R', 0, 1, $posx + $width, $posy + 1); $pdf->SetDrawColor(128, 128, 128); - $this->printRect($pdf, $this->marge_gauche, $posy, $this->page_largeur - $this->marge_gauche - $this->marge_droite, 7); + //$this->printRect($pdf, $this->marge_gauche, $posy, $this->page_largeur - $this->marge_gauche - $this->marge_droite, 7); + $this->printRoundedRect($pdf, $this->marge_gauche, $posy, $this->page_largeur - $this->marge_gauche - $this->marge_droite, 7, $this->corner_radius, 0, 0, 'D'); } } diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 167b2d661cd51..5db21abcc503e 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -12,6 +12,7 @@ * Copyright (C) 2022 Anthony Berton * Copyright (C) 2022 Alexandre Spangaro * Copyright (C) 2024 MDW + * Copyright (C) 2024 Nick Fragoulis * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -88,7 +89,7 @@ class pdf_sponge extends ModelePDFFactures public $heightforfreetext; /** - * @var int heightforfooter + * @var float heightforfooter */ public $heightforfooter; @@ -146,7 +147,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION $this->option_modereg = 1; // Display payment mode @@ -531,7 +532,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); + $pdf->RoundedRect($this->marge_gauche, $this->tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius, '1234', 'D'); $this->tab_top = $nexY + 6; $height_incoterms += 4; @@ -627,10 +628,10 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Draw note frame if ($i > $pageposbeforenote) { $height_note = $this->page_hauteur - ($this->tab_top_newpage + $this->heightforfooter); - $pdf->Rect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius, '1234', 'D'); } else { $height_note = $this->page_hauteur - ($this->tab_top + $this->heightforfooter); - $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1, $this->corner_radius, '1234', 'D'); } // Add footer @@ -649,13 +650,13 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis); } $height_note = $posyafter - $this->tab_top_newpage; - $pdf->Rect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius, '1234', 'D'); } else { // No pagebreak $pdf->commitTransaction(); $posyafter = $pdf->GetY(); $height_note = $posyafter - $this->tab_top; - $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1, $this->corner_radius, '1234', 'D'); if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) { @@ -1028,7 +1029,8 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis); // Display payment area - if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && !getDolGlobalString('INVOICE_NO_PAYMENT_DETAILS')) { + $listofpayments = $object->getListOfPayments('', 0, 1); + if ((count($listofpayments) || $amount_credit_notes_included || $amount_deposits_included) && !getDolGlobalString('INVOICE_NO_PAYMENT_DETAILS')) { $posy = $this->drawPaymentsTable($pdf, $object, $posy, $outputlangs); } @@ -1997,7 +1999,7 @@ protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlan $pdf->SetTextColor(0, 0, 0); } - $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index); + $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index, 'posy' => $posy); $reshook = $hookmanager->executeHooks('afterPDFTotalTable', $parameters, $this); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { @@ -2073,7 +2075,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } @@ -2081,7 +2083,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); @@ -2366,7 +2368,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'F'); $pdf->SetTextColor(0, 0, 60); } @@ -2421,7 +2423,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); } // Show recipient name @@ -2455,11 +2457,13 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output if (!empty($carac_client_shipping)) { $posy += $hautcadre; + $hautcadre -= 10; // Height for the shipping address does not need to be as high as main box + // Show shipping frame $pdf->SetXY($posx + 2, $posy - 5); $pdf->SetFont('', '', $default_font_size - 2); $pdf->MultiCell($widthrecbox, '', $outputlangs->transnoentities('ShippingTo'), 0, 'L', 0); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); // Show shipping name $pdf->SetXY($posx + 2, $posy + 3); @@ -2472,7 +2476,8 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output $pdf->SetXY($posx + 2, $posy); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping, '', 'L'); - $shipp_shift += $hautcadre; + + $shipp_shift += $hautcadre + 10; } } } diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php index 3c5334bfa0350..40dc103464243 100644 --- a/htdocs/core/modules/facture/mod_facture_mercure.php +++ b/htdocs/core/modules/facture/mod_facture_mercure.php @@ -7,6 +7,7 @@ * Copyright (C) 2022 Anthony Berton * Copyright (C) 2024 Frédéric France * Copyright (C) 2024 MDW + * Copyright (C) 2024 Nick Fragoulis * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -102,9 +103,11 @@ public function info($langs) } // Prefix setting of deposit - $texte .= ''.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):'; - $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1, '', 0, 3, 'tooltipdownpaymentmercure').''; - $texte .= ''; + if (!getDolGlobalString('INVOICE_DISABLE_DEPOSIT')) { + $texte .= ''.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):'; + $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1, '', 0, 3, 'tooltipdownpaymentmercure').''; + $texte .= ''; + } $texte .= ''; $texte .= ''; @@ -155,7 +158,7 @@ public function getNextValue($objsoc, $invoice, $mode = 'next') $mask = getDolGlobalString('FACTURE_MERCURE_MASK_REPLACEMENT', getDolGlobalString('FACTURE_MERCURE_MASK_INVOICE')); } elseif (is_object($invoice) && $invoice->type == 2) { $mask = getDolGlobalString('FACTURE_MERCURE_MASK_CREDIT'); - } elseif (is_object($invoice) && $invoice->type == 3) { + } elseif (is_object($invoice) && $invoice->type == 3 && !getDolGlobalString('INVOICE_DISABLE_DEPOSIT')) { $mask = getDolGlobalString('FACTURE_MERCURE_MASK_DEPOSIT'); } else { $mask = getDolGlobalString('FACTURE_MERCURE_MASK_INVOICE'); diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 6912fccb4ad4c..6bcde30e3ec24 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -8,6 +8,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2024 MDW * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 Nick Fragoulis * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -97,7 +98,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo $this->option_tva = 0; // Manage the vat option FACTURE_TVAOPTION $this->option_modereg = 0; // Display payment mode @@ -253,7 +254,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius, '1234', 'D'); $tab_height -= $height_note; $tab_top = $nexY + 6; @@ -454,7 +455,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede * @param ?Fichinter $object FichInter Object * @return void */ - protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, Fichinter $object = null) + protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $object = null) { global $conf; @@ -487,7 +488,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ */ // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height + 1, 0, 0); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height + 1, $this->corner_radius, 0, 0, 'D'); // Rect takes a length in 3rd parameter and 4th parameter if (empty($hidebottom)) { $employee_name = ''; @@ -630,7 +631,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->SetXY($posx, $posy - 5); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius, '1234', 'F'); } // Show sender name @@ -683,7 +684,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); $pdf->SetTextColor(0, 0, 0); } diff --git a/htdocs/core/modules/hrm/doc/pdf_standard_evaluation.modules.php b/htdocs/core/modules/hrm/doc/pdf_standard_evaluation.modules.php index f0f27172fb3a0..9560d1d7e0f47 100644 --- a/htdocs/core/modules/hrm/doc/pdf_standard_evaluation.modules.php +++ b/htdocs/core/modules/hrm/doc/pdf_standard_evaluation.modules.php @@ -7,7 +7,8 @@ * Copyright (C) 2019 Markus Welters * Copyright (C) 2019 Rafael Ingenleuf * Copyright (C) 2020 Marc Guenneugues - * Copyright (C) 2024 MDW + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Nick Fragoulis * * 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 @@ -106,7 +107,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo $this->option_draft_watermark = 1; // Support add of a watermark on drafts @@ -261,7 +262,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1 - 4, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1 + 6); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1 - 4, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1 + 6, $this->corner_radius, '1234', 'D'); $tab_height -= $height_note; $tab_top = $nexY + 6; @@ -616,7 +617,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->MultiCell(190, 5, $outputlangs->transnoentities("Information"), '', 'L');*/ $pdf->SetXY($posx, $posy); $pdf->SetFillColor(224, 224, 224); - $pdf->MultiCell(190, $hautcadre, "", 0, 'R', 1); + $pdf->RoundedRect($posx, $posy, 190, $hautcadre, $this->corner_radius, '1234', 'F'); $pdf->SetTextColor(0, 0, 60); // Show sender information @@ -658,7 +659,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetDrawColor(128, 128, 128); // Rect takes a length in 3rd parameter - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, '1234', 'D'); // line prend une position y en 3eme param if (empty($hidetop)) { $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); diff --git a/htdocs/core/modules/import/modules_import.php b/htdocs/core/modules/import/modules_import.php index a5c2218efec5c..864338b5bca9e 100644 --- a/htdocs/core/modules/import/modules_import.php +++ b/htdocs/core/modules/import/modules_import.php @@ -98,32 +98,32 @@ class ModeleImports // Array of all drivers /** - * @var string[] + * @var array */ public $driverlabel = array(); /** - * @var string[] + * @var array */ public $driverdesc = array(); /** - * @var string[] + * @var array */ public $driverversion = array(); /** - * @var string[] + * @var array */ public $drivererror = array(); /** - * @var string[] + * @var array */ public $liblabel = array(); /** - * @var string[] + * @var array */ public $libversion = array(); @@ -133,7 +133,7 @@ class ModeleImports public $charset; /** - * @var string picto + * @var array|string picto */ public $picto; @@ -158,7 +158,7 @@ class ModeleImports public $thirdpartyobject; /** - * @var array Element mapping from table name + * @var array Element mapping from table name */ public static $mapTableToElement = MODULE_MAPPING; @@ -256,8 +256,8 @@ public function getLibVersion() * Load into memory list of available import format * * @param DoliDB $db Database handler - * @param integer $maxfilenamelength Max length of value to show - * @return array List of templates + * @param int $maxfilenamelength Max length of value to show + * @return array List of templates */ public function listOfAvailableImportFormat($db, $maxfilenamelength = 0) { @@ -279,17 +279,18 @@ public function listOfAvailableImportFormat($db, $maxfilenamelength = 0) require_once $file; $module = new $classname($db, ''); + '@phan-var-force ModeleImports $module'; // Picto $this->picto[$module->id] = $module->picto; // Driver properties - $this->driverlabel[$module->id] = $module->getDriverLabel(''); - $this->driverdesc[$module->id] = $module->getDriverDesc(''); - $this->driverversion[$module->id] = $module->getDriverVersion(''); + $this->driverlabel[$module->id] = $module->getDriverLabel(); + $this->driverdesc[$module->id] = $module->getDriverDesc(); + $this->driverversion[$module->id] = $module->getDriverVersion(); $this->drivererror[$module->id] = $module->error ? $module->error : ''; // If use an external lib - $this->liblabel[$module->id] = ($module->error ? ''.$module->error.'' : $module->getLibLabel('')); - $this->libversion[$module->id] = $module->getLibVersion(''); + $this->liblabel[$module->id] = ($module->error ? ''.$module->error.'' : $module->getLibLabel()); + $this->libversion[$module->id] = $module->getLibVersion(); } } } diff --git a/htdocs/core/modules/mailings/advthirdparties.modules.php b/htdocs/core/modules/mailings/advthirdparties.modules.php index ab337600a1a5c..9546c9953d476 100644 --- a/htdocs/core/modules/mailings/advthirdparties.modules.php +++ b/htdocs/core/modules/mailings/advthirdparties.modules.php @@ -57,9 +57,9 @@ public function __construct($db) * This is the main function that returns the array of emails * * @param int $mailing_id Id of mailing. No need to use it. - * @param array $socid Array of id soc to add + * @param int[] $socid Array of id soc to add * @param int $type_of_target Defined in advtargetemailing.class.php - * @param array $contactid Array of contact id to add + * @param int[] $contactid Array of contact id to add * @return int Return integer <0 if error, number of emails added if ok */ public function add_to_target_spec($mailing_id, $socid, $type_of_target, $contactid) @@ -290,7 +290,7 @@ public function formFilter() * Can include an URL link on each record provided by selector shown on target page. * * @param int $id ID - * @param string $type type + * @param string $type type * @return string Url link */ public function url($id, $type) diff --git a/htdocs/core/modules/member/modules_cards.php b/htdocs/core/modules/member/modules_cards.php index f7300eba1b281..8179aaed99c9b 100644 --- a/htdocs/core/modules/member/modules_cards.php +++ b/htdocs/core/modules/member/modules_cards.php @@ -43,11 +43,11 @@ class ModelePDFCards // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return list of active generation modules + * Return list of active generation modules * - * @param DoliDB $db Database handler - * @param integer $maxfilenamelength Max length of value to show - * @return array List of templates + * @param DoliDB $db Database handler + * @param int<0,max> $maxfilenamelength Max length of value to show + * @return string[]|int<-1,0> List of templates */ public static function liste_modeles($db, $maxfilenamelength = 0) { diff --git a/htdocs/core/modules/member/modules_member.class.php b/htdocs/core/modules/member/modules_member.class.php index eeb188056e64d..640c31ee2d3a0 100644 --- a/htdocs/core/modules/member/modules_member.class.php +++ b/htdocs/core/modules/member/modules_member.class.php @@ -108,7 +108,7 @@ public function getToolTip($langs, $soc) $s .= ''.$langs->trans("ThisIsModuleRules").':
'; $s .= $langs->trans("Required").': '.$strikestart; - $s .= yn(!$this->code_null, 1, 2).$strikeend; + $s .= yn($this->code_null ? 0 : 1, 1, 2).$strikeend; $s .= '
'; $s .= $langs->trans("CanBeModifiedIfOk").': '; $s .= yn($this->code_modifiable, 1, 2); diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index cb91305a48368..47c766d525b1b 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -87,7 +87,10 @@ public function __construct($db) // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) // ); $this->const = array(); - //$this->const[] = array('AGENDA_DEFAULT_FILTER_TYPE', 'chaine', 'AC_NON_AUTO', 'Default filter for type of event on agenda', 0, 'current'); + $r = 0; + + // $this->const[$r] = ["ACTION_EVENT_ADDON_PDF", "chaine", "standard", 'Name of PDF model of actioncomm', 0]; + // $this->const[] = array('AGENDA_DEFAULT_FILTER_TYPE', 'chaine', 'AC_NON_AUTO', 'Default filter for type of event on agenda', 0, 'current'); $sqlreadactions = "SELECT code, label, description FROM ".MAIN_DB_PREFIX."c_action_trigger ORDER by rang"; $resql = $this->db->query($sqlreadactions); if ($resql) { @@ -605,8 +608,8 @@ public function init($options = '') $this->remove($options); $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type='member' AND entity = ".((int) $conf->entity), - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','member',".((int) $conf->entity).")" + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type='action' AND entity = ".((int) $conf->entity), + // "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','action',".((int) $conf->entity).")" ); return $this->_init($sql, $options); diff --git a/htdocs/core/modules/modKnowledgeManagement.class.php b/htdocs/core/modules/modKnowledgeManagement.class.php index 5d43bee307706..d7352647f2455 100644 --- a/htdocs/core/modules/modKnowledgeManagement.class.php +++ b/htdocs/core/modules/modKnowledgeManagement.class.php @@ -251,6 +251,11 @@ public function __construct($db) $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->knowledgemanagement->level1->level2) $r++; $this->rights[$r][0] = $this->numero + $r + 1; // Permission id (must not be already used) + $this->rights[$r][1] = 'Validate articles'; // Permission label + $this->rights[$r][4] = 'knowledgerecord_advance'; // In php code, permission will be checked by test if ($user->rights->knowledgemanagement->level1->level2) + $this->rights[$r][5] = 'validate'; // In php code, permission will be checked by test if ($user->rights->knowledgemanagement->level1->level2) + $r++; + $this->rights[$r][0] = $this->numero + $r + 1; // Permission id (must not be already used) $this->rights[$r][1] = 'Delete articles'; // Permission label $this->rights[$r][4] = 'knowledgerecord'; // In php code, permission will be checked by test if ($user->rights->knowledgemanagement->level1->level2) $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->knowledgemanagement->level1->level2) diff --git a/htdocs/core/modules/modMrp.class.php b/htdocs/core/modules/modMrp.class.php index 862d069a79409..acf4dbd737aad 100644 --- a/htdocs/core/modules/modMrp.class.php +++ b/htdocs/core/modules/modMrp.class.php @@ -266,12 +266,12 @@ public function __construct($db) 'm.date_valid'=>'DateValidation', 'm.note_private'=>'NotePrivate', 'm.note_public'=>'Note', - 'm.fk_soc'=>'Tiers', - 'e.rowid'=>'WarehouseId', - 'e.ref'=>'WarehouseRef', + 'm.fk_soc'=>'ThirdParty:ID', 'm.qty'=>'Qty', 'm.date_creation'=>'DateCreation', - 'm.tms'=>'DateModification' + 'm.tms'=>'DateModification', + 'm.fk_warehouse'=>'WarehouseForProduction:ID', + 'e.ref'=>'WarehouseForProduction:Ref' ); $keyforselect = 'mrp_mo'; $keyforelement = 'mrp_mo'; @@ -294,20 +294,120 @@ public function __construct($db) 'm.note_private'=>'Text', 'm.note_public'=>'Text', 'm.fk_soc'=>'Numeric', - 'e.fk_warehouse'=>'Numeric', - 'e.ref'=>'Text', 'm.qty'=>'Numeric', 'm.date_creation'=>'Date', - 'm.tms'=>'Date' - + 'm.tms'=>'Date', + 'm.fk_warehouse'=>'Numeric', + 'e.ref'=>'Text', ); - $this->export_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->export_entities_array[$r] = array('m.fk_warehouse' => 'warehouse', 'e.ref' => 'warehouse'); // We define here only fields that use another icon that the one defined into import_icon $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'mrp_mo as m'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'mrp_mo_extrafields as extra ON m.rowid = extra.fk_object'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as e ON e.rowid = m.fk_warehouse'; $this->export_sql_end[$r] .= ' WHERE m.entity IN ('.getEntity('mrp_mo').')'; // For product and service profile + // Export of MO + liste of consumption / production + $r++; + $this->export_code[$r]=$this->rights_class.'_'.$r; + $this->export_label[$r]='ConsumptionAndProductionInMos'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_icon[$r]='mrp'; + $this->export_fields_array[$r] = array( + 'm.rowid'=>"Id", + 'm.ref'=>"Ref", + 'm.label'=>"Label", + 'm.fk_project'=>'ProjectId', + 'm.fk_bom'=>"Bom:ID", + 'm.date_start_planned'=>"DateStartPlanned", + 'm.date_end_planned'=>"DateEndPlanned", + 'm.fk_product'=>"Product", + 'm.status'=>'Status', + 'm.model_pdf'=>'Model', + 'm.fk_user_valid'=>'ValidatedById', + 'm.fk_user_modif'=>'ModifiedById', + 'm.fk_user_creat'=>'CreatedById', + 'm.date_valid'=>'DateValidation', + 'm.note_private'=>'NotePrivate', + 'm.note_public'=>'Note', + 'm.fk_soc'=>'Tiers', + 'm.qty'=>'Qty', + 'm.date_creation'=>'DateCreation', + 'm.tms'=>'DateModification', + //'e.rowid'=>'WarehouseId', + //'e.ref'=>'WarehouseRef', + ); + $keyforselect = 'mrp_mo'; + $keyforelement = 'mrp_mo'; + $keyforaliasextra = 'extra'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + // Add fields for lines + $this->export_fields_array[$r]['mp.role'] = 'TypeOfMovement'; + $this->export_fields_array[$r]['mp.date_creation'] = 'DateCreation'; + $this->export_fields_array[$r]['mp.qty'] = 'Qty'; + $this->export_fields_array[$r]['mp.batch'] = 'Batch'; + $this->export_fields_array[$r]['mp.fk_product'] = 'ProductId'; + $this->export_fields_array[$r]['p.ref'] = 'ProductRef'; + $this->export_fields_array[$r]['mp.fk_warehouse'] = 'WarehouseId'; + $this->export_fields_array[$r]['e.ref'] = 'WarehouseRef'; + $this->export_fields_array[$r]['mp.fk_stock_movement'] = 'StockMovement:ID'; + + $keyforselect = 'mrp_production'; + $keyforelement = 'mrp_production'; + $keyforaliasextra = 'extramp'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + + $this->export_TypeFields_array[$r] = array( + 'm.ref'=>"Text", + 'm.label'=>"Text", + 'm.fk_project'=>'Numeric', + 'm.fk_bom'=>"Numeric", + 'm.date_end_planned'=>"Date", + 'm.date_start_planned'=>"Date", + 'm.fk_product'=>"Numeric", + 'm.status'=>'Numeric', + 'm.model_pdf'=>'Text', + 'm.fk_user_valid'=>'Numeric', + 'm.fk_user_modif'=>'Numeric', + 'm.fk_user_creat'=>'Numeric', + 'm.date_valid'=>'Date', + 'm.note_private'=>'Text', + 'm.note_public'=>'Text', + 'm.fk_soc'=>'Numeric', + 'm.qty'=>'Numeric', + 'm.date_creation'=>'Date', + 'm.tms'=>'Date', + 'e.fk_warehouse'=>'Numeric', + 'e.ref'=>'Text', + 'mp.qty' => 'Numeric', + 'mp.batch' => 'Text', + 'mp.fk_product' => 'Numeric', + 'p.ref' => 'Text', + 'mp.role' => 'Text', + 'mp.date_creation' => 'Date', + 'mp.fk_warehouse' => 'Numeric', + 'mp.fk_stock_movement' => 'Numeric' + ); + $this->export_entities_array[$r] = array( + 'mp.qty' => 'mrp_line', + 'mp.batch' => 'mrp_line', + 'mp.role' => 'mrp_line', + 'mp.date_creation' => 'mrp_line', + 'mp.fk_product' => 'product', + 'p.ref' => 'product', + 'mp.fk_warehouse' => 'warehouse', + 'e.ref' => 'warehouse', + 'mp.fk_stock_movement' => 'stock' + ); // We define here only fields that use another icon that the one defined into import_icon + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'mrp_mo as m'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'mrp_mo_extrafields as extra ON m.rowid = extra.fk_object'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'mrp_production as mp ON m.rowid = mp.fk_mo'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'mrp_production_extrafields as extramp ON mp.rowid = extramp.fk_object'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as e ON e.rowid = mp.fk_warehouse'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON p.rowid = mp.fk_product'; + $this->export_sql_end[$r] .= ' WHERE m.entity IN ('.getEntity('mrp_mo').')'; // For product and service profile + + // Imports profiles provided by this module $r = 0; $langs->load("mrp"); diff --git a/htdocs/core/modules/modProductBatch.class.php b/htdocs/core/modules/modProductBatch.class.php index 5a7e283ccf573..b0c6a41ea8bba 100644 --- a/htdocs/core/modules/modProductBatch.class.php +++ b/htdocs/core/modules/modProductBatch.class.php @@ -136,7 +136,7 @@ public function init($options = '') $sql = array(); - if (!empty($conf->cashdesk->enabled)) { + if (isModEnabled('cashdesk')) { if (!getDolGlobalString('CASHDESK_NO_DECREASE_STOCK')) { include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK", 1, 'chaine', 0, '', $conf->entity); diff --git a/htdocs/core/modules/movement/doc/pdf_standard_movementstock.modules.php b/htdocs/core/modules/movement/doc/pdf_standard_movementstock.modules.php index 21045e9ec2106..41925a7935a74 100644 --- a/htdocs/core/modules/movement/doc/pdf_standard_movementstock.modules.php +++ b/htdocs/core/modules/movement/doc/pdf_standard_movementstock.modules.php @@ -2,6 +2,7 @@ /* Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2024 MDW * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 Nick Fragoulis * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -83,7 +84,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo $this->option_multilang = 1; // Available in several languages $this->option_freetext = 0; // Support add of a personalised text @@ -166,8 +167,8 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'movementlist'; $idproduct = GETPOSTINT('idproduct'); - $year = GETPOST("year"); - $month = GETPOST("month"); + $year = GETPOSTINT("year"); + $month = GETPOSTINT("month"); $search_ref = GETPOST('search_ref', 'alpha'); $search_movement = GETPOST("search_movement"); $search_product_ref = trim(GETPOST("search_product_ref")); @@ -709,7 +710,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius, '1234', 'D'); $tab_height -= $height_note; $tab_top = $nexY + 6; @@ -781,7 +782,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede * * @param TCPDF $pdf Object PDF * @param float|int $tab_top Top position of table - * @param float|int $tab_height Height of table (rectangle) + * @param float|int $tab_height Height of table (angle) * @param int $nexY Y (not used) * @param Translate $outputlangs Langs object * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title @@ -813,7 +814,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', array(), explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius, '1001', 'F', array(), explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } diff --git a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php index e36d0ca04331a..a08a7bb8de33d 100644 --- a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php +++ b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php @@ -8,6 +8,7 @@ * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2024 MDW * Copyright (C) 2024 Josep Lluís Amador + * Copyright (C) 2024 Nick Fragoulis * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -103,7 +104,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo $this->option_multilang = 1; //Available in several languages $this->option_escompte = 0; // Displays if there has been a discount @@ -342,10 +343,10 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Draw note frame if ($i > $pageposbeforenote) { $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter); - $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); } else { $height_note = $this->page_hauteur - ($tab_top + $heightforfooter); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); } // Add footer @@ -364,13 +365,13 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $this->_pagehead($pdf, $object, 0, $outputlangs); } $height_note = $posyafter - $tab_top_newpage; - $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); } else { // No pagebreak $pdf->commitTransaction(); $posyafter = $pdf->GetY(); $height_note = $posyafter - $tab_top; - $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { @@ -938,7 +939,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } @@ -946,7 +947,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter foreach ($this->cols as $colKey => $colDef) { if (!$this->getColumnStatus($colKey)) { @@ -1200,7 +1201,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius, '1234', 'F'); $pdf->SetTextColor(0, 0, 60); // Show sender name diff --git a/htdocs/core/modules/oauth/generic_oauthcallback.php b/htdocs/core/modules/oauth/generic_oauthcallback.php index c5993d99cd979..4ebdcc2518f63 100644 --- a/htdocs/core/modules/oauth/generic_oauthcallback.php +++ b/htdocs/core/modules/oauth/generic_oauthcallback.php @@ -244,7 +244,7 @@ exit(); } else { // We are coming from the return of an OAuth2 provider page. - dol_syslog("We are coming from the oauth provider page keyforprovider=".$keyforprovider." code=".dol_trunc(GETPOST('code'), 5)); + dol_syslog(basename(__FILE__)." We are coming from the oauth provider page keyforprovider=".$keyforprovider." code=".dol_trunc(GETPOST('code'), 5)); // We must validate that the $state is the same than the one into $_SESSION['oauthstateanticsrf'], return error if not. if (isset($_SESSION['oauthstateanticsrf']) && $state != $_SESSION['oauthstateanticsrf']) { diff --git a/htdocs/core/modules/oauth/github_oauthcallback.php b/htdocs/core/modules/oauth/github_oauthcallback.php index fe77dcb3dd07f..ae0464db61ead 100644 --- a/htdocs/core/modules/oauth/github_oauthcallback.php +++ b/htdocs/core/modules/oauth/github_oauthcallback.php @@ -121,7 +121,7 @@ // We should have //$_GET=array('code' => string 'aaaaaaaaaaaaaa' (length=20), 'state' => string 'user,public_repo' (length=16)) - dol_syslog("We are coming from the oauth provider page code=".dol_trunc(GETPOST('code'), 5)); + dol_syslog(basename(__FILE__)." We are coming from the oauth provider page code=".dol_trunc(GETPOST('code'), 5)); // This was a callback request from service, get the token try { diff --git a/htdocs/core/modules/oauth/google_oauthcallback.php b/htdocs/core/modules/oauth/google_oauthcallback.php index 381ed5e363503..a39eac8ab6c07 100644 --- a/htdocs/core/modules/oauth/google_oauthcallback.php +++ b/htdocs/core/modules/oauth/google_oauthcallback.php @@ -222,7 +222,7 @@ exit(); } else { // We are coming from the return of an OAuth2 provider page. - dol_syslog("We are coming from the oauth provider page keyforprovider=".$keyforprovider." code=".dol_trunc(GETPOST('code'), 5)); + dol_syslog(basename(__FILE__)." We are coming from the oauth provider page keyforprovider=".$keyforprovider." code=".dol_trunc(GETPOST('code'), 5)); // We must validate that the $state is the same than the one into $_SESSION['oauthstateanticsrf'], return error if not. if (isset($_SESSION['oauthstateanticsrf']) && $state != $_SESSION['oauthstateanticsrf']) { diff --git a/htdocs/core/modules/oauth/microsoft2_oauthcallback.php b/htdocs/core/modules/oauth/microsoft2_oauthcallback.php index 10146a1be4432..8e98017181356 100644 --- a/htdocs/core/modules/oauth/microsoft2_oauthcallback.php +++ b/htdocs/core/modules/oauth/microsoft2_oauthcallback.php @@ -18,7 +18,7 @@ */ /** - * \file htdocs/core/modules/oauth/microsoft_oauthcallback.php + * \file htdocs/core/modules/oauth/microsoft2_oauthcallback.php * \ingroup oauth * \brief Page to get oauth callback */ @@ -50,7 +50,8 @@ $uriFactory = new \OAuth\Common\Http\Uri\UriFactory(); //$currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER); //$currentUri->setQuery(''); -$currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/microsoft_oauthcallback.php'); + +$currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/microsoft2_oauthcallback.php'); /** @@ -65,19 +66,21 @@ //$httpClient->setCurlParameters($params); $serviceFactory->setHttpClient($httpClient); -// Dolibarr storage -$storage = new DoliStorage($db, $conf, $keyforprovider); - // Setup the credentials for the requests $keyforparamid = 'OAUTH_'.$genericstring.($keyforprovider ? '-'.$keyforprovider : '').'_ID'; $keyforparamsecret = 'OAUTH_'.$genericstring.($keyforprovider ? '-'.$keyforprovider : '').'_SECRET'; $keyforparamtenant = 'OAUTH_'.$genericstring.($keyforprovider ? '-'.$keyforprovider : '').'_TENANT'; + +// Dolibarr storage +$storage = new DoliStorage($db, $conf, $keyforprovider, getDolGlobalString($keyforparamtenant)); + $credentials = new Credentials( getDolGlobalString($keyforparamid), getDolGlobalString($keyforparamsecret), $currentUri->getAbsoluteUri() ); + $state = GETPOST('state'); $requestedpermissionsarray = array(); @@ -95,7 +98,8 @@ // $requestedpermissionsarray contains list of scopes. // Conversion into URL is done by Reflection on constant with name SCOPE_scope_in_uppercase try { - $apiService = $serviceFactory->createService(ucfirst(strtolower($genericstring)), $credentials, $storage, $requestedpermissionsarray); + $nameofservice = ucfirst(strtolower($genericstring)); + $apiService = $serviceFactory->createService($nameofservice, $credentials, $storage, $requestedpermissionsarray); '@phan-var-force OAuth\OAuth2\Service\AbstractService|OAuth\OAuth1\Service\AbstractService $apiService'; // createService is only ServiceInterface } catch (Exception $e) { print $e->getMessage(); @@ -124,6 +128,9 @@ if (!getDolGlobalString($keyforparamsecret)) { accessforbidden('Setup of service is not complete. Secret key is missing'); } +if (!getDolGlobalString($keyforparamtenant)) { + accessforbidden('Setup of service is not complete. Tenant/Annuary ID key is missing'); +} /* @@ -151,7 +158,7 @@ // We should have //$_GET=array('code' => string 'aaaaaaaaaaaaaa' (length=20), 'state' => string 'user,public_repo' (length=16)) - dol_syslog("We are coming from the oauth provider page code=".dol_trunc(GETPOST('code'), 5)." error=".GETPOST('error')); + dol_syslog(basename(__FILE__)." We are coming from the oauth provider page code=".dol_trunc(GETPOST('code'), 5)." error=".GETPOST('error')); // This was a callback request from service, get the token try { diff --git a/htdocs/core/modules/oauth/microsoft_oauthcallback.php b/htdocs/core/modules/oauth/microsoft_oauthcallback.php index 6d32b4047c902..435f3206b356a 100644 --- a/htdocs/core/modules/oauth/microsoft_oauthcallback.php +++ b/htdocs/core/modules/oauth/microsoft_oauthcallback.php @@ -43,7 +43,6 @@ } $genericstring = 'MICROSOFT'; - /** * Create a new instance of the URI class with the current URI, stripping the query string */ @@ -65,13 +64,14 @@ //$httpClient->setCurlParameters($params); $serviceFactory->setHttpClient($httpClient); -// Dolibarr storage -$storage = new DoliStorage($db, $conf, $keyforprovider); - // Setup the credentials for the requests $keyforparamid = 'OAUTH_'.$genericstring.($keyforprovider ? '-'.$keyforprovider : '').'_ID'; $keyforparamsecret = 'OAUTH_'.$genericstring.($keyforprovider ? '-'.$keyforprovider : '').'_SECRET'; $keyforparamtenant = 'OAUTH_'.$genericstring.($keyforprovider ? '-'.$keyforprovider : '').'_TENANT'; + +// Dolibarr storage +$storage = new DoliStorage($db, $conf, $keyforprovider, getDolGlobalString($keyforparamtenant)); + $credentials = new Credentials( getDolGlobalString($keyforparamid), getDolGlobalString($keyforparamsecret), @@ -95,7 +95,8 @@ // $requestedpermissionsarray contains list of scopes. // Conversion into URL is done by Reflection on constant with name SCOPE_scope_in_uppercase try { - $apiService = $serviceFactory->createService(ucfirst(strtolower($genericstring)), $credentials, $storage, $requestedpermissionsarray); + $nameofservice = ucfirst(strtolower($genericstring)); + $apiService = $serviceFactory->createService($nameofservice, $credentials, $storage, $requestedpermissionsarray); '@phan-var-force OAuth\OAuth2\Service\AbstractService|OAuth\OAuth1\Service\AbstractService $apiService'; // createService is only ServiceInterface } catch (Exception $e) { print $e->getMessage(); @@ -124,6 +125,9 @@ if (!getDolGlobalString($keyforparamsecret)) { accessforbidden('Setup of service is not complete. Secret key is missing'); } +if (!getDolGlobalString($keyforparamtenant)) { + accessforbidden('Setup of service is not complete. Tenant/Annuary ID key is missing'); +} /* @@ -151,7 +155,7 @@ // We should have //$_GET=array('code' => string 'aaaaaaaaaaaaaa' (length=20), 'state' => string 'user,public_repo' (length=16)) - dol_syslog("We are coming from the oauth provider page code=".dol_trunc(GETPOST('code'), 5)." error=".GETPOST('error')); + dol_syslog(basename(__FILE__)." We are coming from the oauth provider page code=".dol_trunc(GETPOST('code'), 5)." error=".GETPOST('error')); // This was a callback request from service, get the token try { @@ -168,7 +172,7 @@ // Microsoft is a service that does not need state to be stored as second parameter of requestAccessToken //print $token->getAccessToken().'

'; - //print $token->getExtraParams()['id_token'].'
'; + //print $token->getExtraParams()['id_token'].'

'; //print $token->getRefreshToken().'
';exit; setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs'); // Stored into object managed by class DoliStorage so into table oauth_token diff --git a/htdocs/core/modules/oauth/stripelive_oauthcallback.php b/htdocs/core/modules/oauth/stripelive_oauthcallback.php index 3c3070a6abc77..bd592e42a73b8 100644 --- a/htdocs/core/modules/oauth/stripelive_oauthcallback.php +++ b/htdocs/core/modules/oauth/stripelive_oauthcallback.php @@ -68,8 +68,8 @@ $storage = new DoliStorage($db, $conf, $keyforprovider); // Setup the credentials for the requests -$keyforparamid = 'OAUTH_STRIPE_LIVE'.($keyforprovider ? '-'.$keyforprovider : '').'_ID'; -$keyforparamsecret = 'OAUTH_STRIPE_LIVE'.($keyforprovider ? '-'.$keyforprovider : '').'_SECRET'; +$keyforparamid = 'OAUTH_STRIPELIVE'.($keyforprovider ? '-'.$keyforprovider : '').'_ID'; +$keyforparamsecret = 'OAUTH_STRIPELIVE'.($keyforprovider ? '-'.$keyforprovider : '').'_SECRET'; $credentials = new Credentials( getDolGlobalString($keyforparamid), getDolGlobalString($keyforparamsecret), @@ -131,7 +131,7 @@ // We should have //$_GET=array('code' => string 'aaaaaaaaaaaaaa' (length=20), 'state' => string 'user,public_repo' (length=16)) - dol_syslog("We are coming from the oauth provider page code=".dol_trunc(GETPOST('code'), 5)); + dol_syslog(basename(__FILE__)." We are coming from the oauth provider page code=".dol_trunc(GETPOST('code'), 5)); // This was a callback request from service, get the token if ($apiService === null) { @@ -168,6 +168,7 @@ if ($apiService === null) { dol_syslog("No API Service", LOG_ERR); } else { + '@phan-var-force OAuth\OAuth2\Service\AbstractService|OAuth\OAuth1\Service\AbstractService $apiService'; $url = $apiService->getAuthorizationUri(array('state' => GETPOST('state'))); } } else { diff --git a/htdocs/core/modules/oauth/stripetest_oauthcallback.php b/htdocs/core/modules/oauth/stripetest_oauthcallback.php index 78b8007d986a9..32338d822eb17 100644 --- a/htdocs/core/modules/oauth/stripetest_oauthcallback.php +++ b/htdocs/core/modules/oauth/stripetest_oauthcallback.php @@ -1,6 +1,7 @@ * 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 @@ -50,9 +51,12 @@ //$currentUri->setQuery(''); $currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/stripetest_oauthcallback.php'); +$state = null; +$apiService = null; + /** - * Load the credential for the service + * Load the credentials for the service */ /** @var \OAuth\ServiceFactory $serviceFactory An OAuth service factory. */ @@ -67,8 +71,8 @@ $storage = new DoliStorage($db, $conf, $keyforprovider); // Setup the credentials for the requests -$keyforparamid = 'OAUTH_STRIPE_TEST'.($keyforprovider ? '-'.$keyforprovider : '').'_ID'; -$keyforparamsecret = 'OAUTH_STRIPE_TEST'.($keyforprovider ? '-'.$keyforprovider : '').'_SECRET'; +$keyforparamid = 'OAUTH_STRIPETEST'.($keyforprovider ? '-'.$keyforprovider : '').'_ID'; +$keyforparamsecret = 'OAUTH_STRIPETEST'.($keyforprovider ? '-'.$keyforprovider : '').'_SECRET'; $credentials = new Credentials( getDolGlobalString($keyforparamid), getDolGlobalString($keyforparamsecret), @@ -124,10 +128,11 @@ // We should have //$_GET=array('code' => string 'aaaaaaaaaaaaaa' (length=20), 'state' => string 'user,public_repo' (length=16)) - dol_syslog("We are coming from the oauth provider page code=".dol_trunc(GETPOST('code'), 5)); + dol_syslog(basename(__FILE__)." We are coming from the oauth provider page code=".dol_trunc(GETPOST('code'), 5)); // This was a callback request from service, get the token try { + '@phan-var-force OAuth\OAuth2\Service\AbstractService|OAuth\OAuth1\Service\AbstractService $apiService'; //var_dump($state); //var_dump($apiService); // OAuth\OAuth2\Service\Stripe @@ -157,7 +162,12 @@ // This may create record into oauth_state before the header redirect. // Creation of record with state in this tables depend on the Provider used (see its constructor). if (GETPOST('state')) { - $url = $apiService->getAuthorizationUri(array('state'=>GETPOST('state'))); + if (is_object($apiService)) { // @phpstan-ignore-line + '@phan-var-force OAuth\OAuth2\Service\AbstractService|OAuth\OAuth1\Service\AbstractService $apiService'; + $url = $apiService->getAuthorizationUri(array('state' => GETPOST('state'))); + } else { + $url = null; + } } else { //$url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated //https://connect.stripe.com/oauth/authorize?response_type=code&client_id=ca_AX27ut70tJ1j6eyFCV3ObEXhNOo2jY6V&scope=read_write diff --git a/htdocs/core/modules/printsheet/modules_labels.php b/htdocs/core/modules/printsheet/modules_labels.php index 47c35ceb59769..f9def22474bb1 100644 --- a/htdocs/core/modules/printsheet/modules_labels.php +++ b/htdocs/core/modules/printsheet/modules_labels.php @@ -47,7 +47,7 @@ class ModelePDFLabels * * @param DoliDB $db Database handler * @param integer $maxfilenamelength Max length of value to show - * @return array List of templates + * @return string[]|int<-1,0> List of templates */ public function liste_modeles($db, $maxfilenamelength = 0) { @@ -68,7 +68,7 @@ public function liste_modeles($db, $maxfilenamelength = 0) * Create a document onto disk according to template module. * * @param DoliDB $db Database handler - * @param array $arrayofrecords Array of records + * @param array{} $arrayofrecords Array of records * @param string $modele Force le modele a utiliser ('' to not force) * @param Translate $outputlangs Object lang a utiliser pour traduction * @param string $outputdir Output directory @@ -143,6 +143,7 @@ function doc_label_pdf_create($db, $arrayofrecords, $modele, $outputlangs, $outp require_once $file; $obj = new $classname($db); + '@phan-var-force CommonStickerGenerator $obj'; // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php index 9f72337a0aab3..db632a4b14bdc 100644 --- a/htdocs/core/modules/product/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php @@ -1,8 +1,9 @@ * Copyright (C) 2023 Anthony Berton - * Copyright (C) 2024 MDW - * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 Nick Fragoulis * * 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 @@ -92,7 +93,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo $this->option_multilang = 1; // Available in several languages $this->option_freetext = 0; // Support add of a personalised text @@ -337,7 +338,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius, '1234', 'D'); $tab_height -= $height_note; $tab_top = $nexY + 6; @@ -636,7 +637,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', array(), explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius, '1001', 'F', array(), explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } @@ -644,7 +645,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter if (empty($hidetop)) { $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line takes a position y in 2nd parameter and 4th parameter diff --git a/htdocs/core/modules/product/modules_product.class.php b/htdocs/core/modules/product/modules_product.class.php index 554d83f3affd0..dc81b248f52e3 100644 --- a/htdocs/core/modules/product/modules_product.class.php +++ b/htdocs/core/modules/product/modules_product.class.php @@ -154,15 +154,15 @@ public function getToolTip($langs, $product, $type) $s .= ''.$langs->trans("ThisIsModuleRules").':
'; if ($type == 0) { $s .= $langs->trans("RequiredIfProduct").': '.$strikestart; - $s .= yn(!$this->code_null, 1, 2).$strikeend; + $s .= yn($this->code_null ? 0 : 1, 1, 2).$strikeend; $s .= '
'; } elseif ($type == 1) { $s .= $langs->trans("RequiredIfService").': '.$strikestart; - $s .= yn(!$this->code_null, 1, 2).$strikeend; + $s .= yn($this->code_null ? 0 : 1, 1, 2).$strikeend; $s .= '
'; } elseif ($type == -1) { $s .= $langs->trans("Required").': '.$strikestart; - $s .= yn(!$this->code_null, 1, 2).$strikeend; + $s .= yn($this->code_null ? 0 : 1, 1, 2).$strikeend; $s .= '
'; } $s .= $langs->trans("CanBeModifiedIfOk").': '; diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php index 7ded9a0413264..aaa54b1aacf13 100644 --- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php @@ -1,8 +1,9 @@ - * Copyright (C) 2018 Laurent Destailleur - * Copyright (C) 2024 MDW - * Copyright (C) 2024 Frédéric France +/* Copyright (C) 2010-2012 Regis Houssin + * Copyright (C) 2018 Laurent Destailleur + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 Nick Fragoulis * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -109,7 +110,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo FAC_PDF_LOGO $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION @@ -273,7 +274,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '') // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 2, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 2, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius, '1234', 'D'); $tab_height -= $height_note; $tab_top = $nexY + 6; @@ -509,7 +510,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '') * * @param TCPDF $pdf Object PDF * @param float|int $tab_top Top position of table - * @param float|int $tab_height Height of table (rectangle) + * @param float|int $tab_height Height of table (angle) * @param int $nexY Y * @param Translate $outputlangs Langs object * @param int $hidetop Hide top bar of array @@ -527,7 +528,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetDrawColor(128, 128, 128); // Draw rect of all tab (title + lines). Rect takes a length in 3rd parameter - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, '1234', 'D'); // Line takes a position y in 3rd parameter $pdf->line($this->marge_gauche, $tab_top + $heightoftitleline, $this->page_largeur - $this->marge_droite, $tab_top + $heightoftitleline); diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 4f0d81dd64bc1..d4eb38ff6fbee 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -4,6 +4,7 @@ * Copyright (C) 2018 Laurent Destailleur * Copyright (C) 2024 MDW * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 Nick Fragoulis * * 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 @@ -129,7 +130,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo FAC_PDF_LOGO $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION @@ -306,7 +307,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '') // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 2, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 2, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius, '1234', 'D'); $tab_height -= $height_note; $tab_top = $nexY + 6; @@ -757,7 +758,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetDrawColor(128, 128, 128); // Draw rect of all tab (title + lines). Rect takes a length in 3rd parameter - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, '1234', 'D'); // line prend une position y en 3eme param $pdf->line($this->marge_gauche, $tab_top + $heightoftitleline, $this->page_largeur - $this->marge_droite, $tab_top + $heightoftitleline); diff --git a/htdocs/core/modules/project/doc/pdf_timespent.modules.php b/htdocs/core/modules/project/doc/pdf_timespent.modules.php index 420c33cc81b33..1e6644c686ea9 100644 --- a/htdocs/core/modules/project/doc/pdf_timespent.modules.php +++ b/htdocs/core/modules/project/doc/pdf_timespent.modules.php @@ -1,8 +1,9 @@ - * Copyright (C) 2024 MDW - * Copyright (C) 2024 Frédéric France - +/* Copyright (C) 2010-2012 Regis Houssin + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 Nick Fragoulis + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -103,7 +104,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo FAC_PDF_LOGO $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION @@ -268,7 +269,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '') // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 2, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 2, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius, '1234', 'D'); $tab_height -= $height_note; $tab_top = $nexY + 6; @@ -525,7 +526,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetDrawColor(128, 128, 128); // Draw rect of all tab (title + lines). Rect takes a length in 3rd parameter - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, '1234', 'D'); // Line takes a position y in 3rd parameter $pdf->line($this->marge_gauche, $tab_top + $heightoftitleline, $this->page_largeur - $this->marge_droite, $tab_top + $heightoftitleline); diff --git a/htdocs/core/modules/project/mod_project_simple.php b/htdocs/core/modules/project/mod_project_simple.php index 1d4df75aaf296..5319b83156ee1 100644 --- a/htdocs/core/modules/project/mod_project_simple.php +++ b/htdocs/core/modules/project/mod_project_simple.php @@ -123,7 +123,7 @@ public function canBeActivated($object) /** * Return next value * - * @param Societe $objsoc Object third party + * @param ?Societe $objsoc Object third party * @param Project $project Object project * @return string|int<-1,0> Value if OK, 0 if KO */ diff --git a/htdocs/core/modules/project/mod_project_universal.php b/htdocs/core/modules/project/mod_project_universal.php index 93215ba2bf0f9..2be62efa5f399 100644 --- a/htdocs/core/modules/project/mod_project_universal.php +++ b/htdocs/core/modules/project/mod_project_universal.php @@ -133,7 +133,7 @@ public function getExample() /** * Return next value * - * @param Societe $objsoc Object third party + * @param ?Societe $objsoc Object third party * @param Project $project Object project * @return string|int<-1,0> Value if OK, 0 if KO */ diff --git a/htdocs/core/modules/project/modules_project.php b/htdocs/core/modules/project/modules_project.php index 92bd6d61c7731..48885f0e4c7e7 100644 --- a/htdocs/core/modules/project/modules_project.php +++ b/htdocs/core/modules/project/modules_project.php @@ -87,7 +87,7 @@ abstract class ModeleNumRefProjects extends CommonNumRefGenerator /** * Return next value * - * @param Societe $objsoc Object third party + * @param ?Societe $objsoc Object third party * @param Project $project Object project * @return string|int<-1,0> Value if OK, 0 if KO */ diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 80fe1b07e7a93..9f0e59f019f51 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -1,15 +1,16 @@ - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2008 Raphael Bertrand - * Copyright (C) 2010-2015 Juanjo Menent - * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2012 Cedric Salvador - * Copyright (C) 2015 Marcos García - * Copyright (C) 2017-2018 Ferran Marcet +/* Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2008 Raphael Bertrand + * Copyright (C) 2010-2015 Juanjo Menent + * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2012 Cedric Salvador + * Copyright (C) 2015 Marcos García + * Copyright (C) 2017-2018 Ferran Marcet * Copyright (C) 2018-2024 Frédéric France - * Copyright (C) 2019 Pierre Ardoin - * Copyright (C) 2024 MDW + * Copyright (C) 2019 Pierre Ardoin + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Nick Fragoulis * * 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 @@ -108,7 +109,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION $this->option_modereg = 1; // Display payment mode @@ -396,7 +397,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius, '1234', 'D'); $tab_top = $nexY + 6; $height_incoterms += 4; @@ -452,7 +453,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius, '1234', 'D'); $tab_top = $nexY + 6; } @@ -1385,7 +1386,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } @@ -1393,7 +1394,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter if (empty($hidetop)) { $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line takes a position y in 2nd parameter and 4th parameter @@ -1658,7 +1659,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius, '1234', 'F'); $pdf->SetTextColor(0, 0, 60); } @@ -1713,7 +1714,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); } // Show recipient name diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index b7831b5269628..4fea94802b73d 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -7,8 +7,9 @@ * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2015 Marcos García * Copyright (C) 2017 Ferran Marcet - * Copyright (C) 2018-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Nick Fragoulis * * 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 @@ -106,7 +107,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION $this->option_modereg = 1; // Display payment mode @@ -369,7 +370,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius, '1234', 'D'); $tab_top = $nexY + 6; $height_incoterms += 4; @@ -483,10 +484,10 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Draw note frame if ($i > $pageposbeforenote) { $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter); - $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); } else { $height_note = $this->page_hauteur - ($tab_top + $heightforfooter); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); } // Add footer @@ -505,13 +506,13 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $this->_pagehead($pdf, $object, 0, $outputlangs); } $height_note = $posyafter - $tab_top_newpage; - $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); } else { // No pagebreak $pdf->commitTransaction(); $posyafter = $pdf->GetY(); $height_note = $posyafter - $tab_top; - $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { @@ -1432,7 +1433,7 @@ protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlan $pdf->SetTextColor(0, 0, 0); } - $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index); + $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index, 'posy' => $posy); $reshook = $hookmanager->executeHooks('afterPDFTotalTable', $parameters, $this); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { @@ -1487,7 +1488,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } @@ -1495,7 +1496,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter if (getDolGlobalString('MAIN_PDF_TITLE_TEXT_COLOR')) { $arrayColorTextTitle = explode(',', getDolGlobalString('MAIN_PDF_TITLE_TEXT_COLOR')); @@ -1725,7 +1726,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'F'); $pdf->SetTextColor(0, 0, 60); } @@ -1781,7 +1782,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); } // Show recipient name diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 1004d3d83c98d..55dcc8cd0beec 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -1,7 +1,8 @@ +/* Copyright (C) 2018 Quentin Vial-Gouteyron * Copyright (C) 2023-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Nick Fragoulis * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -82,7 +83,7 @@ public function __construct(DoliDB $db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo $this->option_draft_watermark = 1; // Support add of a watermark on drafts $this->watermark = ''; @@ -311,7 +312,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius, '1234', 'D'); $tab_top = $nexY + 6; $height_incoterms += 4; @@ -364,7 +365,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius, '1234', 'D'); $tab_height -= $height_note; $tab_top = $nexY + 6; @@ -823,7 +824,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetFont('', '', $default_font_size - 2); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter $pdf->SetDrawColor(128, 128, 128); $pdf->SetFont('', '', $default_font_size - 1); @@ -1054,7 +1055,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Sender"), 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'F'); $pdf->SetTextColor(0, 0, 60); $pdf->SetFillColor(255, 255, 255); @@ -1106,7 +1107,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient"), 0, 'L'); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); diff --git a/htdocs/core/modules/reception/mod_reception_beryl.php b/htdocs/core/modules/reception/mod_reception_beryl.php index 1b0f9510e1f75..ef60d5747e38d 100644 --- a/htdocs/core/modules/reception/mod_reception_beryl.php +++ b/htdocs/core/modules/reception/mod_reception_beryl.php @@ -31,8 +31,14 @@ class mod_reception_beryl extends ModelNumRefReception { public $version = 'dolibarr'; + /** + * @var string + */ public $prefix = 'RCP'; public $error = ''; + /** + * @var string + */ public $nom = 'Beryl'; diff --git a/htdocs/core/modules/reception/mod_reception_moonstone.php b/htdocs/core/modules/reception/mod_reception_moonstone.php index de514911410a9..3810da99bb171 100644 --- a/htdocs/core/modules/reception/mod_reception_moonstone.php +++ b/htdocs/core/modules/reception/mod_reception_moonstone.php @@ -33,6 +33,9 @@ class mod_reception_moonstone extends ModelNumRefReception { public $version = 'dolibarr'; public $error = ''; + /** + * @var string + */ public $nom = 'Moonstone'; /** diff --git a/htdocs/core/modules/security/captcha/README b/htdocs/core/modules/security/captcha/README new file mode 100644 index 0000000000000..99aac4ea4c671 --- /dev/null +++ b/htdocs/core/modules/security/captcha/README @@ -0,0 +1,35 @@ +README (english) +------------------------------------ +Adding your own captcha module +------------------------------------ + + +If you want to add your own captcha module. This is steps to follow to add your own password generator: + + +***** STEP 1 ***** + +Copy file +htdocs/core/modules/security/captcha/modCaptchaGoogle.class.php +into +htdocs/core/modules/mailings/captcha/modCaptchaMycaptcha.class.php + +You can choose value of your choice instead of "Mycaptcha" in name of new file. + + +***** STEP 2 ***** + +Edit this file modCaptchaMycaptcha.class.php and change following text: + +"class modCaptchaGoogle" into "class modCaptchaMycaptcha" + +Then add code inside the "getDescription" function. +Then add code inside the "getExample" function. +Then add code inside the "getCodeForLoginForm" function. +Then add code inside the "validateCodeAfterLoginSubmit" function. + + +***** STEP 3 ***** + +Once this file has been edited, you can go to the Dolibarr security setup, +choose tab "captcha", you will see a new captcha in the "Captcha generators" area. diff --git a/htdocs/core/modules/security/captcha/modCaptchaStandard.class.php b/htdocs/core/modules/security/captcha/modCaptchaStandard.class.php new file mode 100644 index 0000000000000..5e448df4ff6ac --- /dev/null +++ b/htdocs/core/modules/security/captcha/modCaptchaStandard.class.php @@ -0,0 +1,91 @@ + + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/security/captcha/modCaptchaStandard.class.php + * \ingroup core + * \brief File to manage captcha generation according to dolibarr native code + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/security/captcha/modules_captcha.php'; + + +/** + * Class to generate a password according to a dolibarr standard rule (12 random chars) + */ +class modCaptchaStandard extends ModeleCaptcha +{ + /** + * @var string ID + */ + public $id; + + public $picto = 'fa-shield-alt'; + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param Conf $conf Handler de conf + * @param Translate $langs Handler de langue + * @param User $user Handler du user connected + */ + public function __construct($db, $conf, $langs, $user) + { + $this->id = "standard"; + + $this->db = $db; + $this->conf = $conf; + $this->langs = $langs; + $this->user = $user; + } + + /** + * Return description of module + * + * @return string Description of module + */ + public function getDescription() + { + global $langs; + return $langs->trans("DolibarrStandardCaptcha"); + } + + /** + * Return an example of password generated by this module + * + * @return string Example of password + */ + public function getExample() + { + return ''; + } + + + /** + * Validate a captcha + * This function is called after a log to validate a captcha, before validating a password. + * + * @return int 0 if KO, >0 if OK + */ + public function validateCodeAfterLoginSubmit() + { + return 1; + } +} diff --git a/htdocs/core/modules/security/captcha/modules_captcha.php b/htdocs/core/modules/security/captcha/modules_captcha.php new file mode 100644 index 0000000000000..912badfe31b1f --- /dev/null +++ b/htdocs/core/modules/security/captcha/modules_captcha.php @@ -0,0 +1,120 @@ + + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/security/captcha/modules_captcha.php + * \ingroup core + * \brief File with parent class for captcha generating classes + */ +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; + + +/** + * Parent class for password rules/management modules + */ +abstract class ModeleCaptcha +{ + /** + * @var string + */ + public $id; + + /** + * @var string + */ + public $version; + + /** + * @var string + */ + public $picto = 'generic'; + + /** + * @var string Error code (or message) + */ + public $error = ''; + + /** + * @var DoliDB Database handler. + */ + public $db; + + /** + * @var Conf dolibarr conf + */ + public $conf; + + /** + * @var Translate Translate Object + */ + public $langs; + + /** + * @var User user + */ + public $user; + + + /** + * Return if a module can be used or not + * + * @return boolean true if module can be used + */ + public function isEnabled() + { + return true; + } + + + /** + * Return description of module + * + * @return string Description of module + */ + public function getDescription() + { + global $langs; + return $langs->trans("NoDescription"); + } + + /** + * Return an example of password generated by this module + * + * @return string Example of captcha + */ + public function getExample() + { + global $langs; + $langs->load("bills"); + return $langs->trans("NoExample"); + } + + + /** + * Validate a captcha + * This function is called after a log to validate a captcha, before validating a password. + * + * @return int 0 if KO, >0 if OK + */ + public function validateCodeAfterLoginSubmit() + { + return 1; + } +} diff --git a/htdocs/core/modules/security/generate/README b/htdocs/core/modules/security/generate/README index 23dc7dcdd9168..b71e652e1f690 100644 --- a/htdocs/core/modules/security/generate/README +++ b/htdocs/core/modules/security/generate/README @@ -10,9 +10,9 @@ If you want to add your own password generator module. This is steps to follow t ***** STEP 1 ***** Copy file -htdocs/core/modules/security/modGeneratePassNone.class.php +htdocs/core/modules/security/generate/modGeneratePassNone.class.php into -htdocs/core/modules/mailings/modGeneratePassMygenerator.class.php +htdocs/core/modules/security/generate/modGeneratePassMygenerator.class.php You can choose value of your choice instead of "Mygenerator" in name of new file. @@ -23,10 +23,10 @@ Edit this file modGeneratePassMygenerator.class.php and change following text: "class modGeneratePassNone" into "class modGeneratePassMygenerator" -Then add code inside the "getDecription" function. -Then add code inside the "getExample" function. -Then add code inside the "getNewGeneratedPassword" function. -Then add code inside the "validatePassword" function. +Then add code inside the "getDecription" function. +Then add code inside the "getExample" function. +Then add code inside the "getNewGeneratedPassword" function. +Then add code inside the "validatePassword" function. ***** STEP 3 ***** diff --git a/htdocs/core/modules/societe/modules_societe.class.php b/htdocs/core/modules/societe/modules_societe.class.php index c4e65c4fded91..82551e436ae37 100644 --- a/htdocs/core/modules/societe/modules_societe.class.php +++ b/htdocs/core/modules/societe/modules_societe.class.php @@ -174,15 +174,15 @@ public function getToolTip($langs, $soc, $type) $s .= ''.$langs->trans("ThisIsModuleRules").':
'; if ($type == 0) { $s .= $langs->trans("RequiredIfCustomer").': '.$strikestart; - $s .= yn(!$this->code_null, 1, 2).$strikeend; + $s .= yn($this->code_null ? 0 : 1, 1, 2).$strikeend; $s .= '
'; } elseif ($type == 1) { $s .= $langs->trans("RequiredIfSupplier").': '.$strikestart; - $s .= yn(!$this->code_null, 1, 2).$strikeend; + $s .= yn($this->code_null ? 0 : 1, 1, 2).$strikeend; $s .= '
'; } elseif ($type == -1) { $s .= $langs->trans("Required").': '.$strikestart; - $s .= yn(!$this->code_null, 1, 2).$strikeend; + $s .= yn($this->code_null ? 0 : 1, 1, 2).$strikeend; $s .= '
'; } $s .= $langs->trans("CanBeModifiedIfOk").': '; diff --git a/htdocs/core/modules/stock/doc/pdf_standard_stock.modules.php b/htdocs/core/modules/stock/doc/pdf_standard_stock.modules.php index 9224e7d503cb4..1afd23e99ec18 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard_stock.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard_stock.modules.php @@ -1,9 +1,10 @@ - * Copyright (C) 2022 Ferran Marcet - * Copyright (C) 2022 Nicolas Silobre - * Copyright (C) 2024 MDW - * Copyright (C) 2024 Frédéric France + * Copyright (C) 2022 Ferran Marcet + * Copyright (C) 2022 Nicolas Silobre + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 Nick Fragoulis * * 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 @@ -79,7 +80,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo $this->option_multilang = 1; // Available in several languages $this->option_freetext = 0; // Support add of a personalised text @@ -506,7 +507,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius, '1234', 'D'); $tab_height -= $height_note; $tab_top = $nexY + 6; @@ -610,7 +611,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', array(), explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius, '1001', 'F', array(), explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } @@ -619,7 +620,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetFont('', 'B', $default_font_size - 3); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter $pdf->SetLineStyle(array('dash' => '0', 'color' => array(200, 200, 200))); $pdf->SetDrawColor(200, 200, 200); diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php index 9cdea4485c8d8..1b4440e35b996 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php @@ -3,9 +3,10 @@ * Copyright (C) 2005-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014-2015 Marcos García - * Copyright (C) 2018-2024 Frédéric France - * Copyright (C) 2021 Gauthier VERDOL - * Copyright (C) 2024 MDW + * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Nick Fragoulis * * 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 @@ public function __construct(DoliDB $db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo // Get source company @@ -368,7 +369,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius, '1234', 'D'); $tab_top = $nexY + 6; $height_incoterms += 4; @@ -424,7 +425,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius, '1234', 'D'); $tab_height -= $height_note; $tab_top = $nexY + 6; @@ -905,7 +906,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetFont('', '', $default_font_size - 2); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter $pdf->SetDrawColor(128, 128, 128); $pdf->SetFont('', '', $default_font_size - 1); @@ -1185,7 +1186,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Sender").":", 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'F'); $pdf->SetTextColor(0, 0, 60); $pdf->SetFillColor(255, 255, 255); @@ -1240,7 +1241,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L'); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); // Show recipient name $pdf->SetXY($posx + 2, $posy + 3); diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php index 2d96b52c554f8..06ef936d358f3 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php @@ -9,7 +9,8 @@ * Copyright (C) 2017 Ferran Marcet * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2021 Gauthier VERDOL - * Copyright (C) 2024 MDW + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Nick Fragoulis * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -103,7 +104,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION $this->option_modereg = 1; // Display payment mode @@ -345,7 +346,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius, '1234', 'D'); $tab_top = $nexY + 6; $height_incoterms += 4; @@ -442,10 +443,10 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Draw note frame if ($i > $pageposbeforenote) { $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter); - $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); } else { $height_note = $this->page_hauteur - ($tab_top + $heightforfooter); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); } // Add footer @@ -464,12 +465,12 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $this->_pagehead($pdf, $object, 0, $outputlangs); } $height_note = $posyafter - $tab_top_newpage; - $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); } else { // No pagebreak $pdf->commitTransaction(); $posyafter = $pdf->GetY(); $height_note = $posyafter - $tab_top; - $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { @@ -1148,7 +1149,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } @@ -1156,7 +1157,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); @@ -1391,7 +1392,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlek $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Sender").":", 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'F'); $pdf->SetTextColor(0, 0, 60); $pdf->SetFillColor(255, 255, 255); @@ -1446,7 +1447,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlek $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L'); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); // Show recipient name $pdf->SetXY($posx + 2, $posy + 3); diff --git a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php index 20ac7bb948b3c..e1b59c7888ac0 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -3,7 +3,8 @@ * Copyright (C) 2010-2014 Laurent Destailleur * Copyright (C) 2015 Marcos García * Copyright (C) 2018-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Nick Fragoulis * * 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 @@ -98,7 +99,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION $this->option_modereg = 1; // Display payment mode @@ -315,7 +316,7 @@ public function write_file($object, $outputlangs = null, $srctemplatepath = '', // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius, '1234', 'D'); $tab_top = $nexY + 6; } @@ -347,7 +348,7 @@ public function write_file($object, $outputlangs = null, $srctemplatepath = '', // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius, '1234', 'D'); $tab_top = $nexY + 6; } @@ -724,7 +725,7 @@ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price((string) $tvaval, 0, $outputlangs), 0, 'R', 1); } } //} @@ -749,7 +750,7 @@ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price((string) $tvaval, 0, $outputlangs), 0, 'R', 1); } } //} @@ -817,7 +818,7 @@ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs $pdf->SetTextColor(0, 0, 0); } - $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index); + $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index, 'posy' => $posy); $reshook = $hookmanager->executeHooks('afterPDFTotalTable', $parameters, $this); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { @@ -867,7 +868,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } @@ -875,7 +876,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter if (empty($hidetop)) { $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line takes a position y in 2nd parameter and 4th parameter @@ -1196,7 +1197,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillFrom"), 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius, '1234', 'F'); $pdf->SetTextColor(0, 0, 60); // Show sender name @@ -1247,7 +1248,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo"), 0, 'L'); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); // Show recipient name $pdf->SetXY($posx + 2, $posy + 3); diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 4c366ebb21263..95e2d4300f298 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -5,9 +5,10 @@ * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2015 Marcos García * Copyright (C) 2017 Ferran Marcet - * Copyright (C) 2018-2024 Frédéric France - * Copyright (C) 2023 William Mead - * Copyright (C) 2024 MDW + * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2023 William Mead + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Nick Fragoulis * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -102,7 +103,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION $this->option_modereg = 1; // Display payment mode @@ -336,7 +337,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius, '1234', 'D'); $tab_top = $nexY + 6; } @@ -421,10 +422,10 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Draw note frame if ($i > $pageposbeforenote) { $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter); - $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); } else { $height_note = $this->page_hauteur - ($tab_top + $heightforfooter); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); } // Add footer @@ -443,13 +444,13 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $this->_pagehead($pdf, $object, 0, $outputlangs); } $height_note = $posyafter - $tab_top_newpage; - $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); } else { // No pagebreak $pdf->commitTransaction(); $posyafter = $pdf->GetY(); $height_note = $posyafter - $tab_top; - $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { @@ -1106,7 +1107,7 @@ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs $pdf->SetTextColor(0, 0, 0); } - $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index); + $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index, 'posy' => $posy); $reshook = $hookmanager->executeHooks('afterPDFTotalTable', $parameters, $this); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { @@ -1156,7 +1157,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } @@ -1164,7 +1165,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); @@ -1380,7 +1381,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius, '1234', 'F'); $pdf->SetTextColor(0, 0, 60); // Show sender name @@ -1431,7 +1432,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); // Show recipient name $pdf->SetXY($posx + 2, $posy + 3); diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index af0b16d5ea68c..1082d2382bf08 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -5,8 +5,9 @@ * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2015 Marcos García * Copyright (C) 2017 Ferran Marcet - * Copyright (C) 2018-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Nick Fragoulis * * 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 @@ -101,7 +102,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION $this->option_modereg = 1; // Display payment mode @@ -355,7 +356,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius, '1234', 'D'); $tab_top = $nexY + 6; } @@ -372,7 +373,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius, '1234', 'D'); $tab_top = $nexY + 6; } @@ -1024,7 +1025,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } @@ -1032,7 +1033,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter if (empty($hidetop)) { $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line takes a position y in 2nd parameter and 4th parameter @@ -1291,7 +1292,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius, '1234', 'F'); $pdf->SetTextColor(0, 0, 60); // Show sender name @@ -1341,7 +1342,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); // Show recipient name $pdf->SetXY($posx + 2, $posy + 3); diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard_supplierpayment.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard_supplierpayment.modules.php index 426c4336fc4a3..14c3954741d69 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard_supplierpayment.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard_supplierpayment.modules.php @@ -5,6 +5,7 @@ * Copyright (C) 2022 Ferran Marcet * Copyright (C) 2024 Frédéric France * Copyright (C) 2024 MDW + * Copyright (C) 2024 Nick Fragoulis * * 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 @@ -108,7 +109,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo $this->option_multilang = 1; // Available in several languages @@ -729,7 +730,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->MultiCell(80, 5, $outputlangs->transnoentities("PayedBy"), 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius, '1234', 'F'); $pdf->SetTextColor(0, 0, 60); // Show sender name @@ -768,7 +769,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("PayedTo"), 0, 'L'); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); // Show recipient name $pdf->SetXY($posx + 2, $posy + 3); diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 665441838f67b..3d215cc3a6f55 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -5,8 +5,9 @@ * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2012 Christophe Battarel * Copyright (C) 2017 Ferran Marcet - * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Nick Fragoulis * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -99,7 +100,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION $this->option_modereg = 1; // Display payment mode @@ -366,7 +367,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius, '1234', 'D'); $tab_top = $nexY + 6; } @@ -1143,7 +1144,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } @@ -1151,7 +1152,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter if (empty($hidetop)) { $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line takes a position y in 2nd parameter and 4th parameter @@ -1339,7 +1340,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillFrom"), 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius, '1234', 'F'); $pdf->SetTextColor(0, 0, 60); // Show sender name @@ -1397,7 +1398,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo"), 0, 'L'); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); // Show recipient name $pdf->SetXY($posx + 2, $posy + 3); diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php index 82e731a5b4093..72044b24b058a 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php @@ -5,8 +5,9 @@ * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2015 Marcos García * Copyright (C) 2017 Ferran Marcet - * Copyright (C) 2018-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Nick Fragoulis * * 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 @@ -101,7 +102,7 @@ public function __construct($db) $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - + $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION $this->option_modereg = 1; // Display payment mode @@ -335,7 +336,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius, '1234', 'D'); $tab_top = $nexY + 6; } @@ -420,10 +421,10 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Draw note frame if ($i > $pageposbeforenote) { $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter); - $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); } else { $height_note = $this->page_hauteur - ($tab_top + $heightforfooter); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); } // Add footer @@ -442,13 +443,13 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $this->_pagehead($pdf, $object, 0, $outputlangs); } $height_note = $posyafter - $tab_top_newpage; - $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); } else { // No pagebreak $pdf->commitTransaction(); $posyafter = $pdf->GetY(); $height_note = $posyafter - $tab_top; - $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); + $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D'); if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { @@ -1145,7 +1146,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } @@ -1153,7 +1154,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom, 'D'); // Rect takes a length in 3rd parameter and 4th parameter $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); @@ -1360,7 +1361,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius, '1234', 'F'); $pdf->SetTextColor(0, 0, 60); // Show sender name @@ -1415,7 +1416,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); // Show recipient name $pdf->SetXY($posx + 2, $posy + 3); diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php index 4e114a9bf27c7..abd7fda7e2019 100644 --- a/htdocs/core/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -346,7 +346,7 @@ } } -if ($action == 'confirm_resize' && GETPOSTISSET("file") && GETPOSTISSET("sizex") && GETPOSTISSET("sizey")) { +if ($action == 'confirm_resize' && GETPOSTISSET("file") && GETPOSTISSET("sizex") && GETPOSTISSET("sizey")) { // Test on permission already done if (empty($dir)) { dol_print_error(null, 'Bug: Value for $dir could not be defined.'); exit; diff --git a/htdocs/core/search_page.php b/htdocs/core/search_page.php index 375ad2c171fa5..90aa23c6879c5 100644 --- a/htdocs/core/search_page.php +++ b/htdocs/core/search_page.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France * * This file is a modified version of datepicker.php from phpBSM to fix some * bugs, to add new features and to dramatically increase speed. @@ -174,7 +175,7 @@ $ret .= ''; $ret .= ''; $ret .= '
'; - $ret .= img_picto('', 'url', '', false, 0, 0, '', 'paddingright width20'); + $ret .= img_picto('', 'url', '', 0, 0, 0, '', 'paddingright width20'); $ret .= 'trans("OrPasteAnURL")).'"'; diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 89f1146a3ffba..403db12d2d77e 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -4,6 +4,7 @@ * Copyright (C) 2023 Maxime Nicolas * Copyright (C) 2023 Benjamin GREMBI * 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 @@ -30,6 +31,14 @@ * $arrayoffamiliestoexclude=array('system', 'mycompany', 'object', 'objectamount', 'date', 'user', ...); * $file */ +' +@phan-var-force int<0,1> $diroutput +@phan-var-force string $defaulttopic +@phan-var-force string $defaulttopiclang +@phan-var-force string[] $arrayoffamiliestoexclude +@phan-var-force string $file +@phan-var-force CommonObject $object +'; // Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { @@ -45,9 +54,6 @@ $titreform = 'SendMail'; $object->fetch_projet(); - if (!isset($file)) { - $file = null; - } $ref = dol_sanitizeFileName($object->ref); if (!in_array($object->element, array('user', 'member'))) { //$fileparams['fullname'] can be filled from the card @@ -197,22 +203,28 @@ // Define $liste, a list of recipients with email inside <>. $liste = array(); if ($object->element == 'expensereport') { + '@phan-var-force ExpenseReport $object'; $fuser = new User($db); $fuser->fetch($object->fk_user_author); $liste['thirdparty'] = $fuser->getFullName($outputlangs)." <".$fuser->email.">"; } elseif ($object->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { + '@phan-var-force Partnership $object'; $fadherent = new Adherent($db); $fadherent->fetch($object->fk_member); $liste['member'] = $fadherent->getFullName($outputlangs)." <".$fadherent->email.">"; } elseif ($object->element == 'societe') { + '@phan-var-force Societe $object'; foreach ($object->thirdparty_and_contact_email_array(1) as $key => $value) { $liste[$key] = $value; } } elseif ($object->element == 'contact') { + '@phan-var-force Contact $object'; $liste['contact'] = $object->getFullName($outputlangs)." <".$object->email.">"; } elseif ($object->element == 'user' || $object->element == 'member') { + '@phan-var-force User|Adherent $object'; $liste['thirdparty'] = $object->getFullName($outputlangs)." <".$object->email.">"; } elseif ($object->element == 'salary') { + '@phan-var-force Salary $object'; $fuser = new User($db); $fuser->fetch($object->fk_user); $liste['thirdparty'] = $fuser->getFullName($outputlangs)." <".$fuser->email.">"; @@ -257,6 +269,7 @@ } $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, $arrayoffamiliestoexclude, $object); + $emailsendersignature = null; // Overwrite __SENDEREMAIL_SIGNATURE__ with value select into form if ($formmail->fromtype) { $reg = array(); @@ -281,6 +294,7 @@ $substitutionarray['__CHECK_READ__'] = ""; if (is_object($object) && is_object($object->thirdparty)) { $checkRead = 'fetch($origin_id); $tmpobject = $objectsrc; diff --git a/htdocs/core/tpl/commonfields_add.tpl.php b/htdocs/core/tpl/commonfields_add.tpl.php index 1a50479ae323b..2ea20d8ed04e1 100644 --- a/htdocs/core/tpl/commonfields_add.tpl.php +++ b/htdocs/core/tpl/commonfields_add.tpl.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 MDW + * 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 @@ print ''; print ''; if (!empty($val['picto'])) { - print img_picto('', $val['picto'], '', false, 0, 0, '', 'pictofixedwidth'); + print img_picto('', $val['picto'], '', 0, 0, 0, '', 'pictofixedwidth'); } if (in_array($val['type'], array('int', 'integer'))) { $value = GETPOSTINT($key); @@ -108,7 +109,7 @@ } else { if ($key == 'lang') { print img_picto('', 'language', 'class="pictofixedwidth"'); - print $formadmin->select_language($value, $key, 0, null, 1, 0, 0, 'minwidth300', 2); + print $formadmin->select_language($value, $key, 0, array(), 1, 0, 0, 'minwidth300', 2); } else { print $object->showInputField($val, $key, $value, '', '', '', 0); } diff --git a/htdocs/core/tpl/commonfields_edit.tpl.php b/htdocs/core/tpl/commonfields_edit.tpl.php index 39a029f148071..1d7b32c004a10 100644 --- a/htdocs/core/tpl/commonfields_edit.tpl.php +++ b/htdocs/core/tpl/commonfields_edit.tpl.php @@ -1,5 +1,7 @@ + * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -65,7 +67,7 @@ print ''; if (!empty($val['picto'])) { - print img_picto('', $val['picto'], '', false, 0, 0, '', 'pictofixedwidth'); + print img_picto('', $val['picto'], '', 0, 0, 0, '', 'pictofixedwidth'); } if (in_array($val['type'], array('int', 'integer'))) { @@ -93,6 +95,7 @@ } elseif ($val['type'] == 'price') { $value = GETPOSTISSET($key) ? price2num(GETPOST($key)) : price2num($object->$key); } elseif ($key == 'lang') { + // @phan-suppress-next-line PhanUndeclaredProperty $value = GETPOSTISSET($key) ? GETPOST($key, 'aZ09') : $object->lang; } else { $value = GETPOSTISSET($key) ? GETPOST($key, 'alpha') : $object->$key; @@ -103,7 +106,7 @@ } else { if ($key == 'lang') { print img_picto('', 'language', 'class="pictofixedwidth"'); - print $formadmin->select_language($value, $key, 0, null, 1, 0, 0, 'minwidth300', 2); + print $formadmin->select_language($value, $key, 0, array(), 1, 0, 0, 'minwidth300', 2); } else { print $object->showInputField($val, $key, $value, '', '', '', 0); } diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index df68da385bf78..b7be093a4a75a 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -3,6 +3,7 @@ * Copyright (C) 2013-2015 Laurent Destailleur * Copyright (C) 2015-2016 Charlie BENKE * Copyright (C) 2021 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,6 +31,12 @@ exit(1); } + +' +@phan-var-force ?CommonObject $object +@phan-var-force ?CommonObject $objectsrc +@phan-var-force ?string $permission +'; if (empty($preselectedtypeofcontact)) { $preselectedtypeofcontact = 0; } @@ -40,7 +47,7 @@ $module = $object->element; // Special cases -if (isset($permissiontoadd) && ! isset($permission)) { +if (isset($permissiontoadd) && !isset($permission)) { $permission = $permissiontoadd; } // TODO Remove this section. We already got $permissiontoadd. @@ -114,7 +121,7 @@
- select_dolusers($user->id, 'userid', 1, (!empty($userAlreadySelected) ? $userAlreadySelected : null), 0, null, null, 0, 56, 0, '', 0, '', 'minwidth100imp widthcentpercentminusxx maxwidth400 userselectcontact'); + select_dolusers($user->id, 'userid', 1, (!empty($userAlreadySelected) ? $userAlreadySelected : null), 0, '', '', 0, 56, 0, '', 0, '', 'minwidth100imp widthcentpercentminusxx maxwidth400 userselectcontact'); if (empty($hideaddcontactforgroups) && $module == 'project') { print ' '.$langs->trans("or").' '; echo img_object('', 'group', 'class="pictofixedwidth"').$form->select_dolgroups(0, 'groupid', 1, '', 0, '', array(), '0', false, 'minwidth100imp widthcentpercentminusxx maxwidth400 groupselectcontact'); @@ -164,7 +171,7 @@
socid) ? 0 : $object->socid); - $selectedCompany = $formcompany->selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany', '', 0, '', 'minwidth300imp maxwidth400 widthcentpercentminusx'); // This also print the select component?> + $selectedCompany = $formcompany->selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany', array(), 0, '', 'minwidth300imp maxwidth400 widthcentpercentminusx'); // This also print the select component?>
element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) { + '@phan-var-force Commande|Facture $objectsrc'; $tmpobject = $objectsrc; } $formcompany->selectTypeContact($tmpobject, $preselectedtypeofcontact, 'typecontact', 'external', 'position', 0, 'minwidth150imp widthcentpercentminusx maxwidth200'); ?> @@ -212,6 +220,7 @@ $list = array(); foreach (array('internal', 'external') as $source) { if (($object->element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) { + '@phan-var-force Commande|Facture $objectsrc'; $contactlist = $objectsrc->liste_contact(-1, $source); } else { $contactlist = $object->liste_contact(-1, $source); @@ -289,13 +298,13 @@ $list = dol_sort_array($list, $sortfield, $sortorder, 1, 0, 1); $arrayfields = array( - 'rowid' => array('label'=>$langs->trans("Id"), 'checked'=>1), - 'nature' => array('label'=>$langs->trans("NatureOfContact"), 'checked'=>1), - 'thirdparty' => array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), - 'contact' => array('label'=>$langs->trans("Users").' | '.$langs->trans("Contacts"), 'checked'=>1), - 'type' => array('label'=>$langs->trans("ContactType"), 'checked'=>1), - 'status' => array('label'=>$langs->trans("Status"), 'checked'=>1), - 'link' => array('label'=>$langs->trans("Link"), 'checked'=>1), + 'rowid' => array('label' => $langs->trans("Id"), 'checked' => 1), + 'nature' => array('label' => $langs->trans("NatureOfContact"), 'checked' => 1), + 'thirdparty' => array('label' => $langs->trans("ThirdParty"), 'checked' => 1), + 'contact' => array('label' => $langs->trans("Users").' | '.$langs->trans("Contacts"), 'checked' => 1), + 'type' => array('label' => $langs->trans("ContactType"), 'checked' => 1), + 'status' => array('label' => $langs->trans("Status"), 'checked' => 1), + 'link' => array('label' => $langs->trans("Link"), 'checked' => 1), ); $param = 'id='.$object->id.'&mainmenu=home'; diff --git a/htdocs/core/tpl/document_actions_post_headers.tpl.php b/htdocs/core/tpl/document_actions_post_headers.tpl.php index 0f478bb75498c..ecfac1f560cba 100644 --- a/htdocs/core/tpl/document_actions_post_headers.tpl.php +++ b/htdocs/core/tpl/document_actions_post_headers.tpl.php @@ -60,8 +60,11 @@ if (in_array($modulepart, array('product', 'produit', 'societe', 'user', 'ticket', 'holiday', 'expensereport'))) { $disablemove = 0; } - - +$parameters = array(); +$reshook = $hookmanager->executeHooks('isLinkedDocumentObjectNotMovable', $parameters, $object); +if ($reshook) { + $disablemove = $hookmanager->resArray['disablemove']; +} /* * Confirm form to delete a file diff --git a/htdocs/core/tpl/extrafields_add.tpl.php b/htdocs/core/tpl/extrafields_add.tpl.php index dc28a6f2f4892..e25ff129d0e9d 100644 --- a/htdocs/core/tpl/extrafields_add.tpl.php +++ b/htdocs/core/tpl/extrafields_add.tpl.php @@ -20,9 +20,7 @@ * $action * $conf * $langs - * * $parameters - * $cols */ // Protection to avoid direct call of template @@ -31,6 +29,14 @@ exit(1); } +' +@phan-var-force CommonObject $object +@phan-var-force string $action +@phan-var-force Conf $conf +@phan-var-force Translate $langs +@phan-var-force array $parameters +'; + ?> $parameters -'; $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/core/tpl/extrafields_edit.tpl.php b/htdocs/core/tpl/extrafields_edit.tpl.php index 17ceda033d3c3..a449b0444c343 100644 --- a/htdocs/core/tpl/extrafields_edit.tpl.php +++ b/htdocs/core/tpl/extrafields_edit.tpl.php @@ -20,9 +20,7 @@ * $action * $conf * $langs - * * $parameters - * $cols */ // Protection to avoid direct call of template @@ -31,6 +29,14 @@ exit(1); } +' +@phan-var-force CommonObject $object +@phan-var-force string $action +@phan-var-force Conf $conf +@phan-var-force Translate $langs +@phan-var-force array $parameters +'; + ?> idate($crit)."'"; } elseif (is_array($crit)) { - if ($crit['start'] !== '' && $crit['end'] !== '') { + if (!is_null($crit['start']) && $crit['start'] !== '' && !is_null($crit['end']) && $crit['end'] !== '') { $sql .= " AND (".$extrafieldsobjectprefix.$tmpkey." BETWEEN '". $db->idate($crit['start']). "' AND '".$db->idate($crit['end']) . "')"; - } elseif ($crit['start'] !== '') { + } elseif (!is_null($crit['start']) && $crit['start'] !== '') { $sql .= " AND (".$extrafieldsobjectprefix.$tmpkey." >= '". $db->idate($crit['start'])."')"; - } elseif ($crit['end'] !== '') { + } elseif (!is_null($crit['end']) && $crit['end'] !== '') { $sql .= " AND (".$extrafieldsobjectprefix.$tmpkey." <= '". $db->idate($crit['end'])."')"; } } diff --git a/htdocs/core/tpl/filemanager.tpl.php b/htdocs/core/tpl/filemanager.tpl.php index ea3d626c64be3..2bbea639c7bac 100644 --- a/htdocs/core/tpl/filemanager.tpl.php +++ b/htdocs/core/tpl/filemanager.tpl.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 MDW + * 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 @@ -81,27 +82,27 @@ if ($permtoadd) { $websitekeyandpageid = (!empty($websitekey) ? '&website='.urlencode($websitekey) : '').(!empty($pageid) ? '&pageid='.urlencode((string) $pageid) : ''); print ''; - print img_picto('', 'folder-plus', '', false, 0, 0, '', 'size15x marginrightonly'); + print img_picto('', 'folder-plus', '', 0, 0, 0, '', 'size15x marginrightonly'); print ''; } else { print ''; - print img_picto('', 'folder-plus', 'disabled', false, 0, 0, '', 'size15x marginrightonly'); + print img_picto('', 'folder-plus', 'disabled', 0, 0, 0, '', 'size15x marginrightonly'); print ''; } if ($module == 'ecm') { $tmpurl = ((!empty($conf->use_javascript_ajax) && !getDolGlobalString('MAIN_ECM_DISABLE_JS')) ? '#' : ($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module ? '&module='.$module : '').($section ? '&section='.$section : ''))); print ''; - print img_picto('', 'refresh', 'id="refreshbutton"', false, 0, 0, '', 'size15x marginrightonly'); + print img_picto('', 'refresh', 'id="refreshbutton"', 0, 0, 0, '', 'size15x marginrightonly'); print ''; } if ($permtoadd && GETPOSTISSET('website')) { // If on file manager to manage medias of a web site print 'ref).'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.dol_escape_htmltag($langs->trans("GenerateImgWebp")).'">'; - print img_picto('', 'images', '', false, 0, 0, '', 'size15x flip marginrightonly'); + print img_picto('', 'images', '', 0, 0, 0, '', 'size15x flip marginrightonly'); print ''; } elseif ($permtoadd && $module == 'ecm') { // If on file manager medias in ecm if (getDolGlobalInt('ECM_SHOW_GENERATE_WEBP_BUTTON')) { print ''; - print img_picto('', 'images', '', false, 0, 0, '', 'size15x flip marginrightonly'); + print img_picto('', 'images', '', 0, 0, 0, '', 'size15x flip marginrightonly'); print ''; } } @@ -273,6 +274,7 @@ $action = 'file_manager'; } +// List of directories if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg_match('/refresh/i', $action) || $action == 'delete') { $langs->load("ecm"); diff --git a/htdocs/core/tpl/object_currency_amount.tpl.php b/htdocs/core/tpl/object_currency_amount.tpl.php new file mode 100644 index 0000000000000..21da43235b202 --- /dev/null +++ b/htdocs/core/tpl/object_currency_amount.tpl.php @@ -0,0 +1,105 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Needs the following variables defined: + * $object Proposal, order, invoice (including supplier versions) + * $usercancreate Permission to edit object + * $action + * $form + * $conf + * $langs + */ + +// Protection to avoid direct call of template +if (empty($conf) || !is_object($conf)) { + print "Error, template page can't be called as URL"; + exit(1); +} + +' +@phan-var-force CommonObject $object +@phan-var-force int $usercancreate +@phan-var-force string $action +@phan-var-force Form $form +@phan-var-force Conf $conf +@phan-var-force Translate $langs +'; + + +print ''."\n"; + +// Multicurrency +if (isModEnabled('multicurrency')) { + $colspan = 1; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + $colspan = 2; + } + if ($object instanceof FactureFournisseurRec || $object instanceof FactureRec) { + $currencyIsEditable = ($object->suspended == $object::STATUS_SUSPENDED); + $colspan = 1; + } else { + // @phan-suppress-next-line PhanUndeclaredConstantOfClass + $currencyIsEditable = ($object->status == $object::STATUS_DRAFT); + } + + // Multicurrency code + print ''; + print ''; + print ''; + if ($usercancreate && $action != 'editmulticurrencycode' && $currencyIsEditable) { + print ''; + } + print '
'; + print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); + print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'
'; + print ''; + $htmlname = (($usercancreate && $action == 'editmulticurrencycode' && $currencyIsEditable) ? 'multicurrency_code' : 'none'); + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, $htmlname); + print ''; + + // Multicurrency rate + if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) { + print ''; + print ''; + print ''; + if ($usercancreate && $action != 'editmulticurrencyrate' && $currencyIsEditable && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { + print ''; + } + print '
'; + print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); + print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'
'; + print ''; + if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { + if ($action == 'actualizemulticurrencyrate') { + list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); + } + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, ($usercancreate ? 'multicurrency_tx' : 'none'), $object->multicurrency_code); + } else { + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); + if ($object->status == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { + print ''; + } + } + print ''; + } +} + +print ''; diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 42f7f17a77e87..2161f41709a2e 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -5,10 +5,10 @@ * Copyright (C) 2012 Cédric Salvador * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2013 Florian Henry - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2022 OpenDSI - * Copyright (C) 2024 MDW - * Copyright (C) 2024 Alexandre Spangaro + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -304,7 +304,7 @@ $coldisplay++; if (getDolGlobalInt('INVOICE_USE_SITUATION') == 2) { $tmp_fieldv = (GETPOSTISSET('progress') ? GETPOST('progress') : $line->situation_percent); - $old_fieldv = $line->get_allprev_progress($line->fk_facture); + $old_fieldv = $line->getAllPrevProgress($line->fk_facture); $fieldv = $tmp_fieldv + $old_fieldv; print '%'; diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index febbfa30ebe7e..e3fef9eebbcf3 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -7,9 +7,9 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2017 Juanjo Menent * Copyright (C) 2022 OpenDSI - * Copyright (C) 2024 MDW - * Copyright (C) 2024 Alexandre Spangaro - * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Alexandre Spangaro + * 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 @@ -388,7 +388,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; $coldisplay++; if (getDolGlobalInt('INVOICE_USE_SITUATION') == 2) { - $previous_progress = $line->get_allprev_progress($object->id); + $previous_progress = $line->getAllPrevProgress($object->id); $current_progress = $previous_progress + floatval($line->situation_percent); print ''.$current_progress.'%'; $coldisplay++; diff --git a/htdocs/core/tpl/resource_view.tpl.php b/htdocs/core/tpl/resource_view.tpl.php index 3f66edd22d7eb..42ed0f8139de4 100644 --- a/htdocs/core/tpl/resource_view.tpl.php +++ b/htdocs/core/tpl/resource_view.tpl.php @@ -1,11 +1,20 @@ + */ // Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit(1); } +' +@phan-var-force string $element +@phan-var-force int $element_id +@phan-var-force string $resource_type +@phan-var-force array,mandatory:int<0,1>}> $linked_resources +'; + $form = new Form($db); diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index 169fa9d11d18f..88850010c05a5 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -71,7 +71,7 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf $ret = 0; // Proposals to order - if ($action == 'PROPAL_CLOSE_SIGNED') { + if ($action == 'PROPAL_CLOSE_SIGNED' && $object instanceof Propal) { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); if (isModEnabled('order') && getDolGlobalString('WORKFLOW_PROPAL_AUTOCREATE_ORDER')) { $object->fetchObjectLinked(); @@ -135,7 +135,7 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf if ($action == 'ORDER_CLASSIFY_BILLED') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); if (isModEnabled("propal") && !empty($conf->workflow->enabled) && getDolGlobalString('WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL')) { - $object->fetchObjectLinked('', 'propal', $object->id, $object->element); + $object->fetchObjectLinked(0, 'propal', $object->id, $object->element); if (!empty($object->linkedObjects['propal'])) { $totalonlinkedelements = 0; foreach ($object->linkedObjects['propal'] as $element) { @@ -160,7 +160,7 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf // First classify billed the order to allow the proposal classify process if (isModEnabled('order') && !empty($conf->workflow->enabled) && getDolGlobalString('WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER')) { - $object->fetchObjectLinked('', 'commande', $object->id, $object->element); + $object->fetchObjectLinked(0, 'commande', $object->id, $object->element); if (!empty($object->linkedObjects['commande'])) { $totalonlinkedelements = 0; foreach ($object->linkedObjects['commande'] as $element) { @@ -179,7 +179,7 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf // Second classify billed the proposal. if (isModEnabled("propal") && !empty($conf->workflow->enabled) && getDolGlobalString('WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL')) { - $object->fetchObjectLinked('', 'propal', $object->id, $object->element); + $object->fetchObjectLinked(0, 'propal', $object->id, $object->element); if (!empty($object->linkedObjects['propal'])) { $totalonlinkedelements = 0; foreach ($object->linkedObjects['propal'] as $element) { @@ -198,7 +198,7 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf // Set shipment to "Closed" if WORKFLOW_SHIPPING_CLASSIFY_CLOSED_INVOICE is set (deprecated, has been replaced with WORKFLOW_SHIPPING_CLASSIFY_BILLED_INVOICE instead)) if (isModEnabled("shipping") && !empty($conf->workflow->enabled) && getDolGlobalString('WORKFLOW_SHIPPING_CLASSIFY_CLOSED_INVOICE')) { - $object->fetchObjectLinked('', 'shipping', $object->id, $object->element); + $object->fetchObjectLinked(0, 'shipping', $object->id, $object->element); if (!empty($object->linkedObjects['shipping'])) { $totalonlinkedelements = 0; foreach ($object->linkedObjects['shipping'] as $element) { @@ -219,7 +219,7 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf } if (isModEnabled("shipping") && !empty($conf->workflow->enabled) && getDolGlobalString('WORKFLOW_SHIPPING_CLASSIFY_BILLED_INVOICE')) { - $object->fetchObjectLinked('', 'shipping', $object->id, $object->element); + $object->fetchObjectLinked(0, 'shipping', $object->id, $object->element); if (!empty($object->linkedObjects['shipping'])) { $totalonlinkedelements = 0; foreach ($object->linkedObjects['shipping'] as $element) { @@ -241,7 +241,7 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf // First classify billed the order to allow the proposal classify process if (isModEnabled('order') && isModEnabled('workflow') && getDolGlobalString('WORKFLOW_SUM_INVOICES_AMOUNT_CLASSIFY_BILLED_ORDER')) { - $object->fetchObjectLinked('', 'commande', $object->id, $object->element); + $object->fetchObjectLinked(0, 'commande', $object->id, $object->element); if (!empty($object->linkedObjects['commande']) && count($object->linkedObjects['commande']) == 1) { // If the invoice has only 1 source order $orderLinked = reset($object->linkedObjects['commande']); $orderLinked->fetchObjectLinked($orderLinked->id, '', $orderLinked->element); @@ -279,7 +279,7 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf // Firstly, we set to purchase order to "Billed" if WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER is set. // After we will set proposals if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && getDolGlobalString('WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER')) { - $object->fetchObjectLinked('', 'order_supplier', $object->id, $object->element); + $object->fetchObjectLinked(0, 'order_supplier', $object->id, $object->element); if (!empty($object->linkedObjects['order_supplier'])) { $totalonlinkedelements = 0; foreach ($object->linkedObjects['order_supplier'] as $element) { @@ -301,7 +301,7 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf // Secondly, we set to linked Proposal to "Billed" if WORKFLOW_INVOICE_CLASSIFY_BILLED_SUPPLIER_PROPOSAL is set. if (isModEnabled('supplier_proposal') && getDolGlobalString('WORKFLOW_INVOICE_CLASSIFY_BILLED_SUPPLIER_PROPOSAL')) { - $object->fetchObjectLinked('', 'supplier_proposal', $object->id, $object->element); + $object->fetchObjectLinked(0, 'supplier_proposal', $object->id, $object->element); if (!empty($object->linkedObjects['supplier_proposal'])) { $totalonlinkedelements = 0; foreach ($object->linkedObjects['supplier_proposal'] as $element) { @@ -347,7 +347,7 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf // Then set reception to "Billed" if WORKFLOW_RECEPTION_CLASSIFY_BILLED_INVOICE is set if (isModEnabled("reception") && !empty($conf->workflow->enabled) && getDolGlobalString('WORKFLOW_RECEPTION_CLASSIFY_BILLED_INVOICE')) { - $object->fetchObjectLinked('', 'reception', $object->id, $object->element); + $object->fetchObjectLinked(0, 'reception', $object->id, $object->element); if (!empty($object->linkedObjects['reception'])) { $totalonlinkedelements = 0; foreach ($object->linkedObjects['reception'] as $element) { @@ -375,7 +375,7 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); if (isModEnabled('order') && getDolGlobalString('WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER')) { - $object->fetchObjectLinked('', 'commande', $object->id, $object->element); + $object->fetchObjectLinked(0, 'commande', $object->id, $object->element); if (!empty($object->linkedObjects['commande'])) { $totalonlinkedelements = 0; foreach ($object->linkedObjects['commande'] as $element) { @@ -541,7 +541,7 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf $diff_array = array_diff_assoc($qtyordred, $qtyshipped); if (count($diff_array) == 0) { //No diff => mean everything is received - $ret = $order->setStatut(CommandeFournisseur::STATUS_RECEIVED_COMPLETELY, null, null, 'SUPPLIER_ORDER_CLOSE'); + $ret = $order->setStatut(CommandeFournisseur::STATUS_RECEIVED_COMPLETELY, null, '', 'SUPPLIER_ORDER_CLOSE'); if ($ret < 0) { $this->setErrorsFromObject($order); return $ret; diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 4a2a8f9880ffa..f0d32aba00357 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -924,6 +924,23 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf $object->actionmsg = $langs->transnoentities("SupplierOrderClassifiedBilled", $object->ref); } + $object->sendtoid = array(); + } elseif ($action == 'BILL_SUPPLIER_CREATE') { + '@phan-var-force FactureFournisseur $object'; + // Load translation files required by the page + $langs->loadLangs(array("agenda", "other", "orders")); + + if (empty($object->actionmsg2)) { + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("InvoiceCreatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("InvoiceCreatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + } + $object->sendtoid = array(); } elseif ($action == 'BILL_SUPPLIER_VALIDATE') { // Load translation files required by the page @@ -1572,9 +1589,12 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf if ($ret > 0 && getDolGlobalString('MAIN_COPY_FILE_IN_EVENT_AUTO')) { if (property_exists($object, 'attachedfiles') && is_array($object->attachedfiles) && array_key_exists('paths', $object->attachedfiles) && count($object->attachedfiles['paths']) > 0) { + // Get directory of object + $tmpelems = getElementProperties($object->element.($object->module ? '@'.$object->module : '')); + $destdir = $tmpelems['dir_output'].'/'.$ret; + foreach ($object->attachedfiles['paths'] as $key => $filespath) { $srcfile = $filespath; - $destdir = $conf->agenda->dir_output.'/'.$ret; $destfile = $destdir.'/'.$object->attachedfiles['names'][$key]; if (dol_mkdir($destdir) >= 0) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php index b5295c891f776..faa556da23576 100644 --- a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php +++ b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php @@ -191,7 +191,7 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf } // Send email to customer - if (!getDolGlobalString('TICKET_DISABLE_CUSTOMER_MAILS') && empty($object->context['disableticketemail']) && $object->notify_tiers_at_create) { + if (!getDolGlobalInt('TICKET_DISABLE_CUSTOMER_MAILS') && empty($object->context['disableticketemail']) && $object->notify_tiers_at_create) { $sendto = ''; // if contact selected send to email's contact else send to email's thirdparty diff --git a/htdocs/core/triggers/interface_95_modWebhook_WebhookTriggers.class.php b/htdocs/core/triggers/interface_95_modWebhook_WebhookTriggers.class.php index 65b5dffb0b27b..1ae1e322ea044 100644 --- a/htdocs/core/triggers/interface_95_modWebhook_WebhookTriggers.class.php +++ b/htdocs/core/triggers/interface_95_modWebhook_WebhookTriggers.class.php @@ -101,7 +101,13 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf //'Accept: application/json' ); - $response = getURLContent($tmpobject->url, 'POST', $jsonstr, 1, $headers, array('http', 'https'), 2, -1); + $method = 'POSTALREADYFORMATED'; + if (getDolGlobalString('WEBHOOK_POST_SEND_DATA_AS_PARAM_STRING')) { // For compatibility with v20- versions + $method = 'POST'; + } + + // warning; the test page use its own call + $response = getURLContent($tmpobject->url, $method, $jsonstr, 1, $headers, array('http', 'https'), 2, -1); if (empty($response['curl_error_no']) && $response['http_code'] >= 200 && $response['http_code'] < 300) { $nbPosts++; diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index fc1217833eae3..3960be82f19f8 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -664,11 +664,11 @@ public function fetchAll(string $sortorder = 'DESC', string $sortfield = 't.rowi /** * Update object into database * - * @param User|null $user User that modifies - * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @param ?User $user User that modifies + * @param int<0,1> $notrigger 0=launch triggers after, 1=disable triggers * @return int if KO: <0 || if OK: >0 */ - public function update(User $user = null, int $notrigger = 0) + public function update($user = null, int $notrigger = 0) { global $conf, $langs; diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 00d05a7d8a38f..302b5bc03c9a7 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -568,7 +568,7 @@ print ''; // Label - print ''; + print ''; if (!empty($object->label)) { $object->ref = $langs->trans($object->label); print '
'; @@ -725,9 +725,9 @@ } if ($user->hasRight('cron', 'delete')) { print ''.img_picto($langs->trans('CronDelete'), 'delete', '', false, 0, 0, '', 'marginleftonly').'   '; + print '" title="'.dol_escape_htmltag($langs->trans('CronDelete')).'">'.img_picto($langs->trans('CronDelete'), 'delete', '', 0, 0, 0, '', 'marginleftonly').'   '; } else { - print ''.img_picto($langs->trans('NotEnoughPermissions'), 'delete', '', false, 0, 0, '', 'marginleftonly').'   '; + print ''.img_picto($langs->trans('NotEnoughPermissions'), 'delete', '', 0, 0, 0, '', 'marginleftonly').'   '; } if ($user->hasRight('cron', 'execute')) { if (!empty($obj->status)) { @@ -735,12 +735,12 @@ print(!getDolGlobalString('CRON_KEY') ? '' : '&securitykey=' . getDolGlobalString('CRON_KEY')); print($sortfield ? '&sortfield='.$sortfield : ''); print($sortorder ? '&sortorder='.$sortorder : ''); - print $param."\" title=\"".dol_escape_htmltag($langs->trans('CronExecute'))."\">".img_picto($langs->trans('CronExecute'), "play", '', false, 0, 0, '', 'marginleftonly').''; + print $param."\" title=\"".dol_escape_htmltag($langs->trans('CronExecute'))."\">".img_picto($langs->trans('CronExecute'), "play", '', 0, 0, 0, '', 'marginleftonly').''; } else { - print ''.img_picto($langs->trans('JobDisabled'), "playdisabled", '', false, 0, 0, '', 'marginleftonly').''; + print ''.img_picto($langs->trans('JobDisabled'), "playdisabled", '', 0, 0, 0, '', 'marginleftonly').''; } } else { - print ''.img_picto($langs->trans('NotEnoughPermissions'), "playdisabled", '', false, 0, 0, '', 'marginleftonly').''; + print ''.img_picto($langs->trans('NotEnoughPermissions'), "playdisabled", '', 0, 0, 0, '', 'marginleftonly').''; } print ''; diff --git a/htdocs/datapolicy/class/datapolicy.class.php b/htdocs/datapolicy/class/datapolicy.class.php index bebebda84c113..8421b84c92438 100644 --- a/htdocs/datapolicy/class/datapolicy.class.php +++ b/htdocs/datapolicy/class/datapolicy.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,6 +38,9 @@ class DataPolicy */ public $db; + /** + * @var string + */ public $error; @@ -165,7 +169,7 @@ public function getAllAdherentsNotInformed() /** * sendMailDataPolicyContact * - * @param mixed $contact Contact + * @param Contact $contact Contact * @return void */ public static function sendMailDataPolicyContact($contact) diff --git a/htdocs/delivery/card.php b/htdocs/delivery/card.php index 0d7bda4986d87..93c64a8526710 100644 --- a/htdocs/delivery/card.php +++ b/htdocs/delivery/card.php @@ -60,12 +60,12 @@ $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); +$id = GETPOSTINT('id'); // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('deliverycard', 'globalcard')); - $object = new Delivery($db); $extrafields = new ExtraFields($db); @@ -81,7 +81,6 @@ $error = 0; // Security check -$id = GETPOSTINT('id'); if ($user->socid) { $socid = $user->socid; } diff --git a/htdocs/delivery/tpl/linkedobjectblock.tpl.php b/htdocs/delivery/tpl/linkedobjectblock.tpl.php index 320243ce103f6..fa6257b7e8254 100644 --- a/htdocs/delivery/tpl/linkedobjectblock.tpl.php +++ b/htdocs/delivery/tpl/linkedobjectblock.tpl.php @@ -53,7 +53,7 @@ echo ''; echo ''.$langs->trans("Delivery"); if (!empty($showImportButton) && getDolGlobalString('MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES')) { - print ' '; echo ''.$objectlink->getNomUrl(1).''; diff --git a/htdocs/don/admin/donation.php b/htdocs/don/admin/donation.php index 9f7faf9b6caea..176ea270768f2 100644 --- a/htdocs/don/admin/donation.php +++ b/htdocs/don/admin/donation.php @@ -68,6 +68,7 @@ $classname = (string) $modele; $obj = new $classname($db); + '@phan-var-force ModeleDon $obj'; if ($obj->write_file($don, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=donation&file=SPECIMEN.html"); @@ -231,6 +232,7 @@ require_once $dir.'/'.$file; $module = new $classname($db); + '@phan-var-force ModeleDon $module'; // Show modules according to features level if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) { @@ -341,7 +343,7 @@ print ''; print ''; if (isModEnabled('accounting')) { - print $formaccounting->select_account($conf->global->DONATION_ACCOUNTINGACCOUNT, 'DONATION_ACCOUNTINGACCOUNT', 1, '', 1, 1); + print $formaccounting->select_account($conf->global->DONATION_ACCOUNTINGACCOUNT, 'DONATION_ACCOUNTINGACCOUNT', 1, array(), 1, 1); } else { print ''; } diff --git a/htdocs/don/paiement/list.php b/htdocs/don/paiement/list.php index 81668de176dae..d3d08775372b6 100644 --- a/htdocs/don/paiement/list.php +++ b/htdocs/don/paiement/list.php @@ -443,6 +443,7 @@ $totalarray['nbfield']++; } if (!empty($arrayfields['pd.rowid']['checked'])) { + // False positive @phan-suppress-next-line PhanTypeInvalidDimOffset print_liste_field_titre($arrayfields['pd.rowid']['label'], $_SERVER["PHP_SELF"], "pd.rowid", '', $param, '', $sortfield, $sortorder); $totalarray['nbfield']++; } diff --git a/htdocs/don/payment/card.php b/htdocs/don/payment/card.php index 23202ea9034d9..e7986ba5f05cb 100644 --- a/htdocs/don/payment/card.php +++ b/htdocs/don/payment/card.php @@ -54,13 +54,17 @@ } } +$permissiontoread = $user->hasRight('don', 'lire'); +$permissiontoadd = $user->hasRight('don', 'creer'); +$permissiontodelete = $user->hasRight('don', 'supprimer'); + /* * Actions */ // Delete payment -if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('don', 'supprimer')) { +if ($action == 'confirm_delete' && $confirm == 'yes' && $permissiontodelete) { $db->begin(); $result = $object->delete($user); @@ -79,6 +83,7 @@ /* * View */ + $title = $langs->trans("Payment"); llxHeader('', $title, '', '', 0, 0, '', '', '', 'mod-donation page-payment_card'); diff --git a/htdocs/don/payment/payment.php b/htdocs/don/payment/payment.php index e914988f78087..7d10d716e6e38 100644 --- a/htdocs/don/payment/payment.php +++ b/htdocs/don/payment/payment.php @@ -44,12 +44,16 @@ $object = new Don($db); +$permissiontoread = $user->hasRight('don', 'lire'); +$permissiontoadd = $user->hasRight('don', 'creer'); +$permissiontodelete = $user->hasRight('don', 'supprimer'); + /* * Actions */ -if ($action == 'add_payment') { +if ($action == 'add_payment' && $permissiontoadd) { $error = 0; if ($cancel) { diff --git a/htdocs/ecm/index_auto.php b/htdocs/ecm/index_auto.php index 003cbf6effb58..98f10bdaab205 100644 --- a/htdocs/ecm/index_auto.php +++ b/htdocs/ecm/index_auto.php @@ -432,7 +432,7 @@ // Toolbar $url = ((!empty($conf->use_javascript_ajax) && !getDolGlobalString('MAIN_ECM_DISABLE_JS')) ? '#' : ($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module ? '&module='.$module : '').($section ? '&section='.$section : ''))); print ''; -print img_picto('', 'refresh', 'id="refreshbutton"', false, 0, 0, '', 'size15x marginrightonly'); +print img_picto('', 'refresh', 'id="refreshbutton"', 0, 0, 0, '', 'size15x marginrightonly'); print ''; print '
'; @@ -462,6 +462,7 @@ print ''; $showonrightsize = ''; + // Auto section if (count($sectionauto)) { $htmltooltip = $langs->trans("ECMAreaDesc2"); @@ -473,6 +474,8 @@ print ''; print '
    '; + $arrayofmodulesforexternalusers = explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')); + $nbofentries = 0; $oldvallevel = 0; foreach ($sectionauto as $key => $val) { @@ -480,9 +483,19 @@ continue; // If condition to show the ECM auto directory is ok } + // External users are not allowed to see manual directories so we quit. + if ($user->socid > 0) { + // Check if dir is allowed to external users + //var_dump($conf->global->MAIN_MODULES_FOR_EXTERNAL); + if (! in_array($val['module'], $arrayofmodulesforexternalusers)) { + // Discard this entry + continue; + } + } + print '