Merge branch 'fix_v20_pdf_space_lost_with_images_eratosthene2' of github.com:thersane-john/dolibarr into fix_v20_pdf_space_lost_with_images_sponge

This commit is contained in:
John BOTELLA 2024-10-24 11:52:09 +02:00
commit fbb8252588
3276 changed files with 86397 additions and 54178 deletions

View file

@ -1,28 +1,41 @@
How to contribute to Dolibarr
=============================
Bug reports and feature requests
--------------------------------
Submit a Bug report or a Feature request
---------------------------------------
<a name="not-a-support-forum"></a>*Note*: **GitHub Issues is not a support forum.** If you have questions about Dolibarr / need help using the software, please use [the forums](https://www.dolibarr.org/forum.php). Forums exist in different languages.
<a name="not-a-support-forum"></a>*Note*: **GitHub Issues is not a support forum.**
If you have questions about Dolibarr or need help on using the software, please use [the forums](https://www.dolibarr.org/forum.php). Forums exist in different languages.
Issues are managed on [GitHub](https://github.com/Dolibarr/dolibarr/issues).
Default **language here is English**. So please prepare your contributions in English.
Issues to inform about a bug or a development trouble and requests for a new feature, are managed on [GitHub](https://github.com/Dolibarr/dolibarr/issues).
Default **language here is English**. So please prepare your contributions in English (we recommend using an online translation service if you don't speak English).
1. Please [use the search engine](https://help.github.com/articles/searching-issues) to check if nobody's already reported your problem.
1. Please [use the search engine](https://help.github.com/articles/searching-issues) to check if anyone else has already reported your issue.
2. [Create an issue](https://help.github.com/articles/creating-an-issue). Choose an appropriate title. Prepend appropriately with Bug or Feature Request.
3. Tell us the version you are using! (look at /htdocs/admin/system/dolibarr.php? and check if you are using the latest version)
4. Write a report with as much detail as possible (Use [screenshots](https://help.github.com/articles/issue-attachments) or even screencasts and provide logging and debugging information whenever possible).
5. Delete unnecessary submissions.
6. **Check your Message at Preview before sending.**
6. **Check your Message at Preview before submitting.**
<a name="code"></a>Submit code
<a name="code"></a>
Submit code
---------------------
This process describes how a Developer can submit code to the project so it can be analyzed and validated by the PR Maintainer (we call this a Pull Request).
Definition:
- Developer: is the human knowing the development language of the application that wants to change some part of the code by modifying the sources of the project.
- PR Maintainer: is the human knowing the development language and code who checks that the code submitted for approbation is correct to validate it, in other words, the PR Maintainer is the approbator of commits.
- Release Maintainer: is the human that validates that a freeze/beta version is ok to be released officially as a stable version.
### Basic workflow
As the Developer:
1. [Fork](https://help.github.com/articles/fork-a-repo) the [GitHub repository](https://github.com/Dolibarr/dolibarr).
2. Clone your fork.
3. Choose a branch(See the [Branches](#branches) section below).
@ -30,27 +43,47 @@ Default **language here is English**. So please prepare your contributions in En
5. Commit and push your changes.
6. [Make a pull request](https://help.github.com/articles/creating-a-pull-request).
As the PR Maintainer:
7. The PR Maintainer will check and decide if he approves or not the commits. During this step, the PR Maintainer can modify your own code to make it valid for approbation or ask you to make the change yourself. For this the PR Maintainer may add commits to a PR. Depending on the tools used (can be done from github directly or from an IDE), such commits may be done directly after validating your PR (for example to complete it).
As the Release Maintainer:
8. A tag will be added to take a snapshot of the code with all the changes approved by PR Maintainers, when ready to do a release.
Note: Project leader(Master Yoda and BDFL) retains all above roles and can directly commit to the project without a PR. Of course anyone can check commit history and comment!
<span id="branches" name="branches"></span>
### Branches
Unless you're fixing a bug, all pull requests should be made against the *develop* branch.
If you're fixing a bug, it is preferred that you cook your fix and pull request it against an oldest version affected.
If you're fixing a bug, it is preferred that you make a pull request against the oldest version affected.
We recommend to push it into N - 2 for N the latest version available, if not possible into version N - 1, and finally into develop.
This is just a recommendation, currently, if you push a bug fix on a very old version, it is still merged and propagated into
higher versions.
We recommend to push it into N - 2 where N is the latest version available, if not possible into version N - 1, and finally into develop.
The rule N - 2 is just a tip if you don't know which version to choose to get the best compromise between ease of correction and number of potential beneficiaries of the correction.
If you push a bug fix on a very old version it is still going to be merged and propagated into newer versions(choose wisely because old versions depend on old deprecated/unsupported versions of PHP and external libraries).
The rule N - 2 is just a tip if you don't know which version to choose to get the best the best compromise between ease of correction
and number of potential beneficiaries of the correction.
### General rules
Please don't edit the ChangeLog file. This file is generated from all commit messages during release process by the project manager.
- As the Developer, please don't edit the ChangeLog file. This file is generated from all commit messages during the release process by the Project releaser.
- As the Developer: Do not submit changes into files xx_XX/afile.lang. They are language files and are updated/synced automatically from Transifex. If you need to add a new language file, just add it for the en_US language.
- As the Release Maintainer: The Release Maintainer will decide to make a new release as soon as the planning of the release is reached and the code in the branch to release reach the status of "No more known serious bugs".
### <a name="commits"></a>Commits
<a name="commits"></a>
### Commits
Use clear commit messages with the following structure:
```plaintext
@ -106,9 +139,9 @@ FIX|Fix #456 Short description (where #456 is number of bug fix, if it exists. I
or
CLOSE|Close #456 Short description (where #456 is number of feature request, if it exists. In upper case to appear into ChangeLog)
or
NEW|New|QUAL|Qual|PERF|Perf Short description (In upper case to appear into ChangeLog, use this if you add a feature not tracked, otherwise use CLOSE #456)
NEW|New|QUAL|Qual|PERF|Perf Short description (In upper case to appear into ChangeLog, use this if you add a feature not tracked, otherwise use CLOSE #xxx)
or
Short description (when the commit is not introducing feature nor closing a bug)
Short description (when the commit is not introducing a feature nor closing a bug)
Long description (Can span across multiple lines).
</pre>
@ -125,11 +158,11 @@ a process to follow to optimize the chance to have PRs merged efficiently...
* When submitting a pull request, use same rule as [Commits](#commits) for the message. If your pull request only contains 1 commit, GitHub will be smart enough to fill it for you. Otherwise, please be a bit verbose about what you're providing.
* A screenshot will be always required for any PR of change/addition of a GUI behaviour.
* A screenshot will be always required for any PR of change/addition of a GUI behavior.
Also, some code changes need a prior approbation:
* if you want to include a new external library (into htdocs/includes directory), please ask before to the core project manager (mention @dolibarr-jedi in your issue) to see if such a library can be accepted.
* if you want to include a new external library (into htdocs/includes directory), please contact the core project manager first (mention @dolibarr-jedi in your issue) to see if such a library can be accepted.
* if you add new tables or fields, you MUST first submit a standalone PR with the data structure changes you plan to add/modify (and only data structure changes). Start development only once this data structure has been accepted.
@ -137,12 +170,12 @@ Once a PR has been submitted, you may need to wait for its integration. It is co
If the label of PR start with "Draft" or "WIP" (Work In Progress), it will not be analyzed for merging until you change the label of the PR (but it can be analyzed for discussion).
If your PR has errors reported by the Continuous Integration Platform, it means your PR is not valid and nothing will be done with it. It will be kept open to allow developers to fix this, or it may be closed several month later. Don't expect anything on your PR if you have such errors, you MUST first fix the Continuous Integration error to have it taken into consideration.
If your PR has errors reported by the Continuous Integration Platform, it means your PR is not valid and nothing will be done with it. It will be kept open to allow developers to fix this, or it may be closed several months later. Don't expect anything on your PR if you have such errors, you MUST first fix the Continuous Integration error to have it taken into consideration.
If the PR is valid, and is kept open for a long time, a tag will also be added on the PR to describe the status of your PR and why the PR is kept open. By putting your mouse on the tag, you will get a full explanation of the tag/status that explain why your PR has not been integrated yet.
In most cases, it gives you information of things you have to do to have the PR taken into consideration (for example a change is requested, a conflict is expected to be solved, some questions were asked). If you have a yellow, red flag of purple flag, don't expect to have your PR validated. You must first provide the answer the tag ask you. The majority of open PR are waiting an action of the author of the PR.
If the PR is valid, and is kept open for a long time, a tag will also be added on the PR to describe the status of your PR and why the PR is kept open. By putting your mouse on the tag, you will get a full explanation of the tag/status that explains why your PR has not been integrated yet.
In most cases, it gives you information of things you have to do to have the PR taken into consideration (for example a change is requested, a conflict is expected to be solved, some questions were asked). If you have a yellow, red flag of purple flag, don't expect to have your PR validated. You must first provide the answer the tag asks you. The majority of open PRs are waiting an action of the author of the PR.
Statistics on Dolibarr project shows that 95% of submitted PR are reviewed and tagged. Average answer delay is also one of the best among Open source projects (just few days before having the Answer Tag set). This is one of the most important ratio of answered PR in Open Source world for a major project. Don't expect the core team to reach the 100%.
Statistics on Dolibarr project shows that 95% of submitted PRs are reviewed and tagged. Average answer delay is also one of the best among Open source projects (just few days before having the Answer Tag set). This is one of the most important ratio of answered PRs in Open Source world for a major project. Don't expect the core team to reach 100%.
A so high ratio is very rare on a so popular project and with the increasing popularity of Dolibarr, this ratio will probably decrease in future to a more common level.
@ -157,9 +190,9 @@ All other translations are managed online at [Transifex](https://www.transifex.c
Translations done on transifex are available in the next major release.
Note: Sometimes, the source text (English) is modified. In such a case, the translation is reset. Transifex assume that if the original source
Note: Sometimes, the source text (English) is modified. In such a case, the translation is reset. Transifex assumes that if the original source
has changed, the translation is surely no more correct so must be done again. But old translation is not lost and you can use the tab "History"
to retrieve all old translation of a source text, and restore the translation in one click with no need to retranslate it if there is no need to.
to retrieve all old translations of a source text and restore the translation in one click with no need to retranslate it if there is no need to.
### Resources

View file

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

View file

@ -10,16 +10,17 @@ jobs:
phan:
uses: ./.github/workflows/phan.yml
secrets: inherit
needs: [pre-commit]
with:
gh_event: ${{ github.event_name }}
phpstan:
uses: ./.github/workflows/phpstan.yml
secrets: inherit
needs: [pre-commit, phan]
needs: [pre-commit]
with:
gh_event: ${{ github.event_name }}
windows-ci:
needs: [pre-commit, phan]
needs: [pre-commit, phpstan, phan]
secrets: inherit
uses: ./.github/workflows/windows-ci.yml
with:
@ -35,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"

View file

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

View file

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

View file

@ -32,7 +32,7 @@ jobs:
# This is faster for a big repo.
- name: Get all changed php files (if PR)
id: changed-php
uses: tj-actions/changed-files@v44
uses: tj-actions/changed-files@v45
if: env.gh_event == 'pull_request'
with:
files: |
@ -67,12 +67,12 @@ 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)
# id: changed-php
# uses: tj-actions/changed-files@v44
# uses: tj-actions/changed-files@v45
# if: env.gh_event == 'pull_request'
# with:
# files: |
@ -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

View file

@ -61,7 +61,7 @@ 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
@ -116,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]"
@ -130,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
@ -186,7 +189,7 @@ 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

1
.gitignore vendored
View file

@ -41,6 +41,7 @@ htdocs/includes/php-parallel-lint/
htdocs/includes/sebastian/
htdocs/includes/squizlabs/
htdocs/includes/webmozart/
htdocs/install/install.forced.php
htdocs/.well-known/apple-developer-merchantid-domain-association
/factory/
/output/

View file

@ -5,7 +5,7 @@ Laurent Destailleur <eldy@destailleur.fr> Laurent Destailleur <eldy@users.source
Laurent Destailleur <eldy@destailleur.fr> eldy <eldy@destailleur.fr>
Laurent Destailleur <eldy@destailleur.fr> Laurent Destailleur <ldestailleur@teclib.com>
Laurent Destailleur <eldy@destailleur.fr> eldy10 <eldy10@master8.(none)>
Laurent Destailleur <eldy@destailleur.fr> Laurent Destailleur <ephpcsdy@destailleur.fr>
Laurent Destailleur <eldy@destailleur.fr> Laurent Destailleur <eldy@destailleur.fr>
Regis Houssin <regis.houssin@inodbox.com> Regis Houssin <regis@dolibarr.fr>
Regis Houssin <regis.houssin@inodbox.com> Régis Houssin <regishoussin@device5.home>
Juanjo Menent <jmenent@2byte.es> simnandez <jmenent@2byte.es>
@ -94,4 +94,4 @@ Anthony Berton <anthony.berton@bb2a.fr> Berton Anthony <anthony.berton@bb2a.fr>
Anthony Berton <anthony.berton@bb2a.fr> BB2A-Anthony <anthony.berton@bb2a.fr>
Anthony Berton <anthony.berton@bb2a.fr> Anthony Berton <bertonanthony@gmail.com>
Anthony Berton <anthony.berton@bb2a.fr> Berton Anthony <bertonanthony@gmail.com>
Anthony Berton <anthony.berton@bb2a.fr> BB2A-Anthony <bertonanthony@gmail.com>
Anthony Berton <anthony.berton@bb2a.fr> BB2A-Anthony <bertonanthony@gmail.com>

View file

@ -1,9 +1,9 @@
---
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
rev: v4.5.0
rev: v4.6.0
hooks:
# This hook tests the name of the branch and return an error if the name is
# 'develop' or an official version 'x.y'
@ -58,12 +58,18 @@ repos:
# Check that there are no files that have are the same when uppercased (conflict on windows)
- id: check-case-conflict
# Beautify shell scripts
# Gitleaks is a SAST tool for detecting and preventing hardcoded secrets like passwords, api keys, and tokens in git repos
- repo: https://github.com/gitleaks/gitleaks.git
rev: v8.16.1
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
@ -183,7 +189,7 @@ repos:
# Check format of yaml files
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.33.0
rev: v1.35.1
hooks:
- id: yamllint
args:
@ -193,7 +199,7 @@ repos:
# Execute codespell to fix typo errors (setup of codespell into dev/tools/codespell/)
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.3.0
hooks:
- id: codespell
# Due to a current limitation of configuration files,
@ -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
@ -236,30 +242,31 @@ repos:
# Check some shell scripts
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.9.0.6
rev: v0.10.0.1
hooks:
- id: shellcheck
args: [-W, "100"]
# Check sql file syntax
- repo: https://github.com/sqlfluff/sqlfluff
rev: 3.0.4
rev: 3.1.0
hooks:
- id: sqlfluff-lint
stages: [pre-commit, manual] # manual needed for ci
exclude: (?x)^
(htdocs/includes/.*
|htdocs/install/doctemplates/websites/.*_template
(dev/initdemo/mysqldump_.*\.sql
|htdocs/core/menus/init_menu_auguria\.sql
|htdocs/install/doctemplates/websites/website_template-.*\.sql
|(htdocs/install/mysql/data/(llx_20_c_departements\.sql
|llx_accounting_account_.*\.sql)
|(htdocs/install/mysql/migration/3\.[256]\.0-.*\.sql)
)
|htdocs/includes/.*
|htdocs/install/doctemplates/websites/.*_template
|htdocs/install/doctemplates/websites/website_template.*\.sql
|htdocs/install/mysql/data/llx_20_c_departements\.sql
|htdocs/install/mysql/data/llx_accounting_account_.*\.sql
|htdocs/install/mysql/migration/3\..*\.sql
|htdocs/install/mysql/migration/(1[0-5]|[456789])\.0\.0-.*\.sql
|htdocs/install/mysql/migration/3\.([0134789])\.0-.*\.sql
|htdocs/install/mysql/migration/repair\.sql
|htdocs/install/mysql/tables/llx_bookcal_availabilities-bookcal\.sql
|htdocs/install/mysql/tables/llx_categorie(_(account|actioncomm|contact|fournisseur|knowledgemanagement-knowledgemanagement|member|product|project|societe|ticket-ticket|user|warehouse|website_page-website)?\.key\.sql)
|htdocs/install/mysql/tables/llx_categorie.*\.key\.sql
|htdocs/install/mysql/tables/llx_rights_def\.key\.sql
|htdocs/install/pgsql/functions/functions(-(don|loan|mailing|opensurvey|partnership|recruitment|website))?\.sql
|htdocs/install/pgsql/functions/functions.*\.sql
|htdocs/modulebuilder/template/sql/.*\.sql
)$

View file

@ -492,6 +492,9 @@ script:
php upgrade.php 19.0.0 20.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade19002000.log || cat $TRAVIS_BUILD_DIR/upgrade19002000.log
php upgrade2.php 19.0.0 20.0.0 > $TRAVIS_BUILD_DIR/upgrade19002000-2.log || cat $TRAVIS_BUILD_DIR/upgrade19002000-2.log
php step5.php 19.0.0 20.0.0 > $TRAVIS_BUILD_DIR/upgrade19002000-3.log || cat $TRAVIS_BUILD_DIR/upgrade19002000-3.log
php upgrade.php 20.0.0 21.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade20002100.log || cat $TRAVIS_BUILD_DIR/upgrade20002100.log
php upgrade2.php 20.0.0 21.0.0 > $TRAVIS_BUILD_DIR/upgrade20002100-2.log || cat $TRAVIS_BUILD_DIR/upgrade20002100-2.log
php step5.php 20.0.0 21.0.0 > $TRAVIS_BUILD_DIR/upgrade20002100-3.log || cat $TRAVIS_BUILD_DIR/upgrade20002100-3.log
set +e
echo

View file

@ -47,7 +47,7 @@ Sabre 4.6.0 BSD Yes
Swift Mailer 5.4.2-DEV MIT License Yes Comprehensive mailing tools for PHP
Symfony/var-dumper ??? MIT License Yes Library to make var dump (used by DebugBar)
Stripe 10.7.0 MIT Licence Yes Library for Stripe module
TCPDF 6.3.2 LGPL-3+ Yes PDF generation
TCPDF 6.7.5 LGPL-3+ Yes PDF generation
TCPDI 1.0.0 LGPL-3+ / Apache 2.0 Yes FPDI replacement
bacon, dasprid, swiss-qr-bill, kmukku, symfony/validator

View file

@ -2,6 +2,31 @@
English Dolibarr ChangeLog
--------------------------------------------------------------
***** ChangeLog for 21.0.0 compared to 20.0 *****
For users:
----------
NEW Add option THEME_STICKY_TOPMENU = 'scrollleftmenu_after_mainpage' (or 'disabled')
NEW value for FICHINTER_DISABLE_DETAILS. If FICHINTER_DISABLE_DETAILS is set to '2' details are disabled only on intervention list.
For developers:
---------------
QUAL line classes for various business object classes have been moved to individual files.
WARNING:
--------
The following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
* Prepare your module for deprecation of triggers code XXX_INSERT to support also XXX_CREATE.
* More class properties (with old name in french) are now deprecated in favor of the property name in english.
* The json emulator dol_json_encode/decode() is removed. The native json PHP module must be enabled/available (this is the case by default with most PHP installation).
* 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.
* The trigger code CATEGORY_LINK and CATEGORY_UNLINK has been replaced with code CATEGORY_MODIFY. You can read ->context['linkto'] or ->context['unlinkoff' to detect we want to make a link or unlink.
***** ChangeLog for 20.0.1 compared to 20.0.0 *****
FIX: #30960 show and search extrafields (#31026)
@ -52,7 +77,6 @@ FIX: when qty is not an integer, apply price() (#31138)
FIX: Wrong price for BOM with workstation (#31142)
FIX: determine multi-currency price on object line create tpl (#28021)
***** ChangeLog for 20.0.0 compared to 19.0 *****
For users:
@ -190,7 +214,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)
@ -306,7 +330,6 @@ QUAL: professional identifiers - remove TODO by adding profid.lib.php
QUAL: Properties ->date_update and ->date_modification were merged
QUAL: removed duplicate language file
QUAL: Remove the external js library jstimezonedetect
QUAL: Remove use of customurl filter. Must use the USF syntax.
QUAL: Rename all input fields "tel" into "phone"
QUAL: Rename column fk_origin_line on shipment lines into fk_elementdet to match a generic use. (#28989)
QUAL: replace $conf->global with getDolGlobalString()
@ -327,6 +350,7 @@ The following changes may create regressions for some external modules, but were
See https://wiki.dolibarr.org/index.php?title=Universal_Search_Filter_Syntax
* The parameter $filter of methods fetchAll() does not accept array of SQL commands but must be a string of an Universal Search Filter syntax.
See https://wiki.dolibarr.org/index.php?title=Universal_Search_Filter_Syntax
* The use of 'customurl' into $filter has been removed. Must use the USF syntax.
* Some API HTTP return code were moved from 401 to 403 to better follow REST specification.
* More class properties (with old name in french) are now deprecated in favor of the property name in english.
* dolibarrtriggers class VERSION_XXX constants have been deprecated. Please use array dictionary VERSIONS['XXX'].
@ -345,7 +369,7 @@ The following changes may create regressions for some external modules, but were
* Removed trigger BILLREC_CREATEBILL. This trigger was not a CRUD event. If you used it, you can already use the trigger BILL_CREATE and
test that ($object->fac_rec > 0) to know if creation trigger is from a recurring invoice or not. Also this old trigger was never enabled
into table llx_c_action_trigger.
* Renamings in expedition line table and class, fk_origin_line is now fk_elementdet in table and class.
* Renaming into expedition line table and class: fk_origin_line is now fk_elementdet in table and class.
* The signature of method fetch() of class CompanyBankAccount has been modified to match the signature of method Account->fetch()
@ -1747,7 +1771,7 @@ NEW: Add link to create an element from the category page
NEW: add margin infos to takepos invoice lines
NEW: Add max size send for "backup and link to mail" option
NEW: Add method httponly_accessforbidden()
NEW: Add more advices into the Setup security page
NEW: Add more advice into the Setup security page
NEW: Add new global variable for keeping the previous signature information on proposal (case of reopening a proposal)
NEW: Add objectLink on shipment
NEW: Add option --force on CLI cron_run_jobs.php
@ -3165,8 +3189,8 @@ NEW: add option in Workflow module to set a shipment as closed
for Admins
NEW: Add a security center page with all information and advices related to the security of your instance
NEW: Add a performance center page with all information and advices related to the performance of your instance
NEW: Add a security center page with all information and advice related to the security of your instance
NEW: Add a performance center page with all information and advice related to the performance of your instance
Modules
NEW: Module Recruitment is now stable
@ -3328,7 +3352,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
@ -7184,7 +7208,7 @@ NEW: Add index and constraints keys on supplier proposal detail table
NEW: Add phpunit to check the engine is defined into sql create files.
NEW: Add project and Hook to Loan
NEW: Add REST API to push a file.
NEW: Allow extrafields list select to be dependands on other standard list and not only other extrafields list
NEW: Allow extrafields list select to be dependent on other standard list and not only other extrafields list
NEW: Architecture to manage search criteria persistence (using save_lastsearch_values=1 on exit links and restore_lastsearch_values=1 in entry links)
NEW: data files are now also parsed by phpunit for sql syntax
NEW: Hook to allow inserting custom product head #6001
@ -8208,7 +8232,7 @@ NEW: The clicktodial module is now able to provide link "tel:" on phone numbers.
NEW: The conditional IF into ODT templates works also on not defined var so we can show data only if defined. Close #3819
NEW: The free text in PDF footers can now be a HTML content. So the WYSIWYG editor is on by default to edit it into module setup.
NEW: The thirdparties tabs, the contacts tabs and the members tabs are now presented using a new "top banner", saving space and using a same way to show address, status and navigation arrows.
NEW: Thumbs for statistics on main page are fully clicable (not only link inside the thumb)
NEW: Thumbs for statistics on main page are fully clickable (not only link inside the thumb)
NEW: Translate extrafield's labels.
NEW: Use new select2 component for juridical status, country and state selection.
NEW: When creating order, proposal or invoice from thirdparty card, the project is asked during creation. A link to create project if it does not exists is also available.
@ -8807,7 +8831,7 @@ NEW: [ task #851 ] Add a new field: Commercial name
NEW: [ task #977 ] New option to manage product unit Migrated code from GPCSolutions/dolibarr:3.2-units branch and adapted for 3.8 with some improvements
NEW: The line where mouse is over can be highlight with option THEME_ELDY_USE_HOVER (on by default)
NEW: The notification module accept keyword __SUPERVISOR__ to send notification to supervisor of user.
NEW: Thumbs for statistics on main page are fully clicable (not only link inside the thumb)
NEW: Thumbs for statistics on main page are fully clickable (not only link inside the thumb)
NEW: Title of page project contains project ref and label
NEW: update skeleton and class builder
NEW: Use new select2 component for juridical status, country and state selection.
@ -9958,7 +9982,7 @@ For users:
prices, radio).
- New: [ task #798 ] Add range limit date on product/services as it is done on order
and invoice.
- New: [ task #814 ] Add extrafield feature for projects ands tasks.
- New: [ task #814 ] Add extrafield feature for projects and tasks.
- New: [ task #770 ] Add ODT document generation for Projects module.
- New: [ task #741 ] Add intervention box.
- New: [ task #826 ] Optional increase stock when deleting an invoice already validated.

View file

@ -10,13 +10,15 @@ Il est simple d'utilisation et modulaire, vous permettant de n'activez que les f
![ScreenShot](https://www.dolibarr.org/medias/dolibarr_screenshot1_1920x1080.jpg)
## LICENCE
Dolibarr est distribué sous les termes de la licence GNU General Public License v3+ ou supérieure.
## INSTALLER DOLIBARR
### Configuration simple
### Installation simple
Si vous avez peu de compétences techniques et que vous souhaitez installer Dolibarr ERP/CRM en quelques clics, vous pouvez utiliser l'une des versions pré-packagées avec les prérequis:
@ -26,7 +28,7 @@ Si vous avez peu de compétences techniques et que vous souhaitez installer Doli
Les packages peuvent être téléchargés à partir de [site web officiel](https://www.dolibarr.org/).
### Configuration avancée
### Installation recommandée/avancée
Vous pouvez aussi utiliser un serveur Web et une base de données prise en charge (MariaDB, MySQL ou PostgreSQL) pour installer la version standard.
@ -54,6 +56,7 @@ Vous pouvez aussi utiliser un serveur Web et une base de données prise en charg
- Suivez les instructions de l'installateur
## METTRE A JOUR DOLIBARR
Pour mettre à jour Dolibarr depuis une vieille version vers celle ci:
@ -70,10 +73,12 @@ Pour mettre à jour Dolibarr depuis une vieille version vers celle ci:
Note: *Le processus de migration peut être lancé manuellement et plusieurs fois, sans risque, en appelant la page /install/*
## CE QUI EST NOUVEAU
Voir le fichier [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog).
## CE QUE DOLIBARR PEUT FAIRE
### Modules principaux (tous optionnels)
@ -143,6 +148,7 @@ Voir le fichier [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/Ch
Dolibarr peut aussi être étendu à volonté avec l'ajout de modules/applications externes développées par des développeurs tiers, disponible sur [DoliStore](https://www.dolistore.com).
## CE QUE DOLIBARR NE PEUT PAS (ENCORE) FAIRE
Voici un liste de fonctionnalités pas encore gérées par Dolibarr:
@ -152,22 +158,26 @@ Voici un liste de fonctionnalités pas encore gérées par Dolibarr:
- Dolibarr n'embarque pas de Webmail intégré nativement.
- Dolibarr ne fait pas le café (pas encore).
## DOCUMENTATION
La documentation utilisateur, développeur et traducteur est disponible sous forme de ressources de la communauté via le site [Wiki](https://wiki.dolibarr.org).
## CONTRIBUER
Ce projet existe grâce à ses nombreux contributeurs [[Contribuer](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md)].
[![Dolibarr](https://opencollective.com/dolibarr/contributors.svg?width=890&button=false)](https://github.com/Dolibarr/dolibarr/graphs/contributors)
## CREDITS
Dolibarr est le résultat du travail de nombreux contributeurs depuis des années et utilise des librairies d'autres contributeurs.
Voir le fichier [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT)
## ACTUALITES ET RESEAUX SOCIAUX
Suivez le projet Dolibarr sur les réseaux francophones

View file

@ -5,7 +5,7 @@
[![GitHub release](https://img.shields.io/github/v/release/Dolibarr/dolibarr)](https://github.com/Dolibarr/dolibarr)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/5521/badge)](https://bestpractices.coreinfrastructure.org/projects/5521)
Dolibarr ERP & CRM is a modern software package that helps manage your organization's activities (contacts, suppliers, invoices, orders, stocks, agenda…).
Dolibarr ERP & CRM is a modern software package that helps manage your organization's activities (contacts, quotes, invoices, orders, stocks, agenda, human resources, ecm, manufacturing…).
It's an Open-Source Software suite (written in PHP with JavaScript enhancements) designed for small, medium or large companies, foundations and freelancers.
@ -17,6 +17,7 @@ Dolibarr has a large community ready to help you, free forums and [preferred par
![ScreenShot](https://www.dolibarr.org/medias/dolibarr_screenshot1_1920x1080.jpg)
## LICENSE
Dolibarr is released 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 (GPL-3+).
@ -25,9 +26,12 @@ See the [COPYING](https://github.com/Dolibarr/dolibarr/blob/develop/COPYING) fil
Other licenses apply for some included dependencies. See [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT) for a full list.
## INSTALLING
### Simple setup
There is a lot of different solutions to install Dolibarr.
### Using packages
If you have low technical skills and you're looking to install Dolibarr ERP/CRM with just a few clicks, you can use one of the packaged versions:
@ -37,12 +41,9 @@ If you have low technical skills and you're looking to install Dolibarr ERP/CRM
Releases can be downloaded from [official website](https://www.dolibarr.org/).
### Recommended setup
### Using the generic step by step setup (recommended)
You can use any web server supporting PHP (Apache, Nginx, ...) and a supported database (MariaDB, MySQL or PostgreSQL) to install the standard version.
#### Generic install steps
You can use any web server supporting PHP (Apache, Nginx, ...) and a supported database (MariaDB, MySQL or PostgreSQL) to install the standard version:
- Verify that your installed PHP version is supported [see PHP support](https://wiki.dolibarr.org/index.php/Releases).
@ -68,12 +69,17 @@ You can use any web server supporting PHP (Apache, Nginx, ...) and a supported d
`http://yourdolibarrvirtualhost/install/`
- Follow the installer instructions
- Follow the installer instructions;;;
### SaaS/Cloud Setup
### Using Docker images
Dolibarr is also available as a [Docker image](https://hub.docker.com/r/dolibarr/dolibarr). Installation instructions are available [here](https://github.com/Dolibarr/dolibarr-docker).
### Using ready to use SaaS/Cloud offers
If you lack the time to install it yourself, consider exploring commercial 'ready-to-use' Cloud offerings (refer to https://saas.dolibarr.org). Keep in mind that this third option comes with associated costs.
## UPGRADING
Dolibarr supports upgrading, usually without the need for any (commercial) support (depending on if you use any commercial extensions). It supports upgrading all the way from any version after 2.8 without breakage. This is unique in the ERP ecosystem and a benefit our users highly appreciate!
@ -86,10 +92,12 @@ Follow these step-by-step instructions to seamlessly upgrade Dolibarr to the lat
- At your next access, Dolibarr will redirect you to the "install/" page to follow the upgrade process.
 If an `install.lock` file exists to lock any other upgrade process, the application will ask you to remove the file manually (you should find the `install.lock` file in the directory used to store generated and uploaded documents, in most cases, it is the directory called "*documents*").
## WHAT'S NEW
See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) file.
## FEATURES
### Main application/modules (all optional)
@ -211,6 +219,7 @@ See exact requirements on the [Wiki](https://wiki.dolibarr.org/index.php/Prerequ
Dolibarr can be extended with a lot of other external applications or modules from third-party developers available at the [DoliStore](https://www.dolistore.com).
## WHAT DOLIBARR CAN'T DO YET
These are features that Dolibarr does **not** yet fully support:
@ -220,10 +229,12 @@ These are features that Dolibarr does **not** yet fully support:
- Native embedded Webmail, but you can send email to contacts in Dolibarr with e.g. offers, invoices, etc.
- Dolibarr can't do coffee (yet)
## DOCUMENTATION
Administrator, user, developer and translator's documentation are available along with other community resources in the [Wiki](https://wiki.dolibarr.org).
## CONTRIBUTING
This project exists thanks to all the people who contribute.
@ -233,12 +244,14 @@ A View on Contributors:
[![Dolibarr](https://opencollective.com/dolibarr/contributors.svg?width=890&button=false)](https://github.com/Dolibarr/dolibarr/graphs/contributors)
## CREDITS
Dolibarr is the work of many contributors over the years and uses some fine PHP libraries.
See [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT) file.
## NEWS AND SOCIAL NETWORKS
Follow Dolibarr project on:
@ -250,6 +263,7 @@ Follow Dolibarr project on:
- [YouTube](https://www.youtube.com/user/DolibarrERPCRM)
- [GitHub](https://github.com/Dolibarr/dolibarr)
### Sponsors
## Sponsors
Support this project by becoming a sponsor. Your logo will show up here. 🙏 [[Become a sponsor/backer](https://opencollective.com/dolibarr#backer)]

View file

@ -1,6 +1,6 @@
# Security Policy
This file contains some policies about the security reports on Dolibarr ERP CRM project, one of the most popular Open Source ERP and CRM in the world.
This file contains some policies about the security reports on Dolibarr ERP CRM project, a popular Open Source ERP and CRM used by millions of users.
## Supported Versions for security reports

View file

@ -2,7 +2,7 @@
The docker-compose.yml file is a sample of a config file to use to build and run Dolibarr in the current workspace with Docker.
This docker image is intended for development usage.
For production usage you should consider other contributor reference like https://hub.docker.com/r/tuxgasy/dolibarr
For production usage you should consider other contributor reference like https://hub.docker.com/r/dolibarr/dolibarr
Before build/run, define the variable HOST_USER_ID as following:

View file

@ -1,6 +1,17 @@
# How to use it ?
This directory is experimental. Scope of its used is not clear and not documented.
If you are looking for a process to run Dolibarr as an official Docker image, you can find it on https://hub.docker.com/r/dolibarr/dolibarr
# For experimental dev - TO REMOVE.
But if you want to execute the version of Dolibarr that is into this current directory as a docker process, you can do it with this commands.
export HOST_USER_ID=$(id -u)
export HOST_GROUP_ID=$(id -g)
export MYSQL_ROOT_PWD=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 13; echo)
docker-compose up -d
Warning: There is no persistency of data. If you need so, you should use instead the official Docker image that you can find on https://hub.docker.com/r/dolibarr/dolibarr

View file

@ -1,25 +1,15 @@
# This docker-compose.yml file is used to build and test quickly
# a specific version of Dolibarr
#
# Before build, define the variable DOLI_VERSION as following:
# $ export DOLI_VERSION=4.0.4
# And then, you can run :
# $ docker-compose up
#
# More information about Docker-compose : https://docs.docker.com/compose/
version: "3"
services:
mariadb:
container_name: dolibarr-mariadb-dev
mariadb-prod:
container_name: dolibarr-mariadb-prod
image: mariadb:latest
environment:
MYSQL_ROOT_PASSWORD: $MYSQL_ROOT_PWD
MYSQL_DATABASE: "dolibarr-prod"
web:
container_name: dolibarr-web-dev
container_name: dolibarr-web-prod
build: .
volumes:
@ -27,12 +17,12 @@ services:
- ../../documents:/var/www/html/documents
depends_on:
- mariadb
- mariadb-prod
environment:
WWW_USER_ID: 1000
WWW_GROUP_ID: 1000
HOST_USER_ID: $HOST_USER_ID
HOST_GROUP_ID: $HOST_GROUP_ID
DOLI_ROOT_PASSWORD: $MYSQL_ROOT_PWD
DOLI_DATABASE: "dolibarr-prod"
DOLI_DB_SERVER: "mariadb"
DOLI_DB_SERVER: "mariadb-prod"
ports:
- "8080:80"

View file

@ -3,7 +3,7 @@
# See README.md to know how to create a Dolibarr env with docker
usermod -u "${HOST_USER_ID}" www-data
groupmod -g "${HOST_USER_ID}" www-data
groupmod -g "${HOST_GROUP_ID}" www-data
chgrp -hR www-data /var/www/html
chmod g+rwx /var/www/html/conf

View file

@ -1,6 +1,7 @@
#!/usr/bin/env php
<?php
/* Copyright (C) 2015-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -199,7 +200,7 @@ fputs($fp, ' </dir>'."\n");
fputs($fp, '</dolibarr_htdocs_dir>'."\n");
asort($checksumconcat); // Sort list of checksum
//var_dump($checksumconcat);
fputs($fp, '<dolibarr_htdocs_dir_checksum>'."\n");
fputs($fp, md5(join(',', $checksumconcat))."\n");
fputs($fp, '</dolibarr_htdocs_dir_checksum>'."\n");

View file

@ -113,24 +113,9 @@ PHP TCPDF:
to
* @public
* Replace in tcpdf.php:
if (isset($this->imagekeys)) {
foreach($this->imagekeys as $file) {
unlink($file);
}
}
with
if (isset($this->imagekeys)) {
foreach($this->imagekeys as $file) {
// DOL CHANGE If we keep this, source image files are physically destroyed
// unlink($file);
}
}
* Replace in tcpdf.php:
$preserve = array(
'file_id',
'internal_encoding',
'state',
'bufferlen',
'buffer',
@ -138,7 +123,6 @@ with
with
$preserve = array(
'file_id',
'internal_encoding',
'state',
'bufferlen',
'buffer',
@ -147,16 +131,16 @@ with
'imagekeys',
* Replace in tcpdf.php:
if (!@TCPDF_STATIC::file_exists($file)) {
if (!@this->fileExists($file)) {
return false;
}
with
if (!@TCPDF_STATIC::file_exists($file)) {
if (!@this->fileExists($file)) {
// DOL CHANGE If we keep this, the image is not visible on pages after the first one.
//var_dump($file.' '.(!@TCPDF_STATIC::file_exists($file)));
//var_dump($file.' '.(!@this->fileExists($file)));
//return false;
$tfile = str_replace(' ', '%20', $file);
if (@TCPDF_STATIC::file_exists($tfile)) {
if (@this->fileExists($tfile)) {
$file = $tfile;
}
}
@ -191,7 +175,7 @@ with
}
elseif (strpos($filename, '://') === false)
* To avoid to have QRcode changed because generated with a random mask, replace:
* In tecnickcom/tcpdf/include/barcodes/qrcode.php To avoid to have QRcode changed because generated with a random mask, replace:
define('QR_FIND_FROM_RANDOM', 2);
with
define('QR_FIND_FROM_RANDOM', false);
@ -215,19 +199,6 @@ In htdocs/includes/tecnickcom/tcpdf/tcpdf.php
- protected $default_monospaced_font = 'courier';
+ protected $default_monospaced_font = 'freemono';
* In tecnickcom/tcpdf/include/tcpdf_static, in function intToRoman, right at the beginning
of the function, replace:
$roman = '';
with:
$roman = '';
if ($number >= 4000) {
// do not represent numbers above 4000 in Roman numerals
return strval($number);
}
* Add this at begin of tcpdf_autoconfig.php
// @CHANGE LDR DOCUMENT_ROOT fix for IIS Webserver
@ -384,7 +355,9 @@ PHP PARSEDOWN
PHP OAUTH
---------
Add into Class Google of file OAuth2/Service/Google:
Restore old OAuth2/Service/Google.php file and OAuth2/Service/Microsoft.php and OAuth2/Service/Microsoft2.php
Or add into Class Google of file OAuth2/Service/Google:
// LDR CHANGE Add approval_prompt to force the prompt if value is set to 'force' so it force return of a "refresh token" in addition to "standard token"
public $approvalPrompt='auto';
@ -398,6 +371,17 @@ Add into Class Google of file OAuth2/Service/Google:
}
Modify function
public function getAuthorizationEndpoint()
{
// LDR CHANGE Add approval_prompt to force the prompt if value is set to 'force' so it force return of a "refresh token" in addition to "standard token"
//return new Uri('https://accounts.google.com/o/oauth2/auth?access_type='.$this->accessType);
$url = 'https://accounts.google.com/o/oauth2/auth?'.($this->approvalPrompt?'approval_prompt='.$this->approvalPrompt.'&':'').'access_type='.$this->accessType;
return new Uri($url);
}
JS JSGANTT:
-----------

View file

@ -2,6 +2,7 @@
<?php
/* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* This 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
@ -225,7 +226,6 @@ if (!empty($argv[4])) {
$user=new User($db);
}
//var_dump($user->db->database_name);
$ret=$user->fetch('', 'admin');
if (! $ret > 0) {
print 'An admin user with login "admin" must exists to use this script.'."\n";

View file

@ -1,16 +1,16 @@
JOURNALCODE JOURNALLIB ECRITURENUM ECRITUREDATE COMPTENUM COMPTELIB COMPAUXNUM COMPAUXLIB PIECEREF PIECEDATE ECRITURELIB DEBIT CREDIT ECRITURELET DATELET VALIDDATE MONTANTDEVISE IDEVISE
Banque Banque 17293 20170109 401PPRO PUBLI-PROV L08 20170109 PPRO domiciliation 1TR 187,20 0,00 20170109
Banque Banque 17293 20170109 5121CRA CR AGRICOLE L08 20170109 PPRO domiciliation 1TR 0,00 187,20 20170109
Banque Banque 17295 20170109 401ORPA ORANGE PARIS Report 20170109 ORPA adsl par 12 96,00 0,00 20170109
Banque Banque 17295 20170109 5121CRA CR AGRICOLE Report 20170109 ORPA adsl par 12 0,00 96,00 20170109
Banque Banque 17302 20170105 401ORVI ORANGE VEBRON INTERNET Report 20170105 ORVI adsl veb 12 26,00 0,00 20170109
Banque Banque 17302 20170105 5121CRA CR AGRICOLE Report 20170105 ORVI adsl veb 12 0,00 26,00 20170109
Fournisseurs Fournisseurs 17305 20170119 401ZDAV SANDRA DAVILA A01 20170119 ZDAV courtage s/ ventes 0,00 508,00 20170119
Fournisseurs Fournisseurs 17305 20170119 622200 Courtages s/ ventes A01 20170119 ZDAV courtage s/ ventes 508,00 0,00 20170119
Banque Banque 17306 20170119 5121CRA CR AGRICOLE A01 20170119 ZDAV courtage s/ ventes 0,00 508,00 20170119
Banque Banque 17306 20170119 401ZDAV SANDRA DAVILA A01 20170119 ZDAV courtage s/ ventes 508,00 0,00 20170119
Banque Banque 17307 20170119 401ZDAV SANDRA DAVILA A01 20170119 ZDAV courtage s/ ventes 508,00 0,00 20170131
Banque Banque 17307 20170119 5121CRA CR AGRICOLE A01 20170119 ZDAV courtage s/ ventes 0,00 508,00 20170131
Banque Banque 17293 20170109 401PPRO PUBLI-PROV L08 20170109 PPRO domiciliation 1TR 187,20 0,00 20170109
Banque Banque 17293 20170109 5121CRA CR AGRICOLE L08 20170109 PPRO domiciliation 1TR 0,00 187,20 20170109
Banque Banque 17295 20170109 401ORPA ORANGE PARIS Report 20170109 ORPA adsl par 12 96,00 0,00 20170109
Banque Banque 17295 20170109 5121CRA CR AGRICOLE Report 20170109 ORPA adsl par 12 0,00 96,00 20170109
Banque Banque 17302 20170105 401ORVI ORANGE VEBRON INTERNET Report 20170105 ORVI adsl veb 12 26,00 0,00 20170109
Banque Banque 17302 20170105 5121CRA CR AGRICOLE Report 20170105 ORVI adsl veb 12 0,00 26,00 20170109
Fournisseurs Fournisseurs 17305 20170119 401ZDAV SANDRA DAVILA A01 20170119 ZDAV courtage s/ ventes 0,00 508,00 20170119
Fournisseurs Fournisseurs 17305 20170119 622200 Courtages s/ ventes A01 20170119 ZDAV courtage s/ ventes 508,00 0,00 20170119
Banque Banque 17306 20170119 5121CRA CR AGRICOLE A01 20170119 ZDAV courtage s/ ventes 0,00 508,00 20170119
Banque Banque 17306 20170119 401ZDAV SANDRA DAVILA A01 20170119 ZDAV courtage s/ ventes 508,00 0,00 20170119
Banque Banque 17307 20170119 401ZDAV SANDRA DAVILA A01 20170119 ZDAV courtage s/ ventes 508,00 0,00 20170131
Banque Banque 17307 20170119 5121CRA CR AGRICOLE A01 20170119 ZDAV courtage s/ ventes 0,00 508,00 20170131

View file

@ -0,0 +1,2 @@
OFX is an old Financial format:
See https://stackoverflow.com/questions/15735330/how-to-parse-a-ofx-version-1-0-2-file-in-php

View file

@ -11,6 +11,7 @@ List of QR Code format we found on some invoices
------------------------------------------
https://en.wikipedia.org/wiki/EPC_QR_code#Generators
Experimental support can be enabled in Dolibarr by setting INVOICE_ADD_EPC_QR_CODE = 1
* For ZATCA QR Code format (Saudi Arabia). Used when INVOICE_ADD_ZATCA_QR_CODE is set
@ -19,11 +20,14 @@ https://www.pwc.com/m1/en/services/tax/me-tax-legal-news/2021/saudi-arabia-guide
https://www.tecklenborgh.com/post/ksa-zatca-publishes-guide-on-how-to-develop-a-fatoora-compliant-qr-code
Method to encode/decode ZATCA string is available in test/phpunit/BarcodeTest.php
Method to encode/decode ZATCA string is available in test/phpunit/BarcodeTest.php
* FOR QR-Bill in switzerland - Facture-QR
-----------------------------------------
Syntax of QR Code - See file ig-qr-bill-v2.2-fr.pdf (more doc on https://www.swiss-qr-invoice.org/downloads/)
Syntax of complementary field named "structured information of invoice S1": https://www.swiss-qr-invoice.org/downloads/qr-bill-s1-syntax-fr.pdf
* FOR QR-Bill in switzerland - Facture-QR or QR-Facture
-------------------------------------------------------
- Syntax of QR Code - See file ig-qr-bill-v2.2-fr.pdf (more doc on https://www.swiss-qr-invoice.org/downloads/)
- Syntax of complementary field named "structured information of invoice S1": https://www.swiss-qr-invoice.org/downloads/qr-bill-s1-syntax-fr.pdf
To test/validate: https://www.swiss-qr-invoice.org/validator/
Experimental support to show the QR code can be enabled in dolibarr by setting INVOICE_ADD_SWISS_QR_CODE = 1.
If setting value to "bottom", the complete top banner can be added at bottom of invoice PDF. Note: an external PHP library may be requested at first PDF generation.

File diff suppressed because it is too large Load diff

View file

@ -2,11 +2,11 @@ https://en.wikipedia.org/wiki/Single_Euro_Payments_Area
https://www.ecb.europa.eu/paym/integration/retail/sepa/html/index.en.html
https://www.europeanpaymentscouncil.eu/about-sepa
Spec for credit transfer:
Spec for credit transfer:
https://docs.oracle.com/cd/E39124_01/doc.91/e60210/fields_sepa_pay_file_appx.htm#EOAEL00515
To validate a SEPA file:
xmllint --schema pain.001.001.03.xsd T200801.xml --noout
To test a SEPA file:
https://www.mesfluxdepaiement.fr/testez-vos-fichiers-sepa
To test a SEPA file:
https://www.mesfluxdepaiement.fr/testez-vos-fichiers-sepa

View file

@ -1 +0,0 @@
See specification at http://www.ofx.net

View file

@ -10,8 +10,11 @@ PHP_OPT="-d error_reporting=32767"
DB=${DB:=mariadb}
DB_ROOT=${DB_ROOT:=root}
DB_PASS=${DB_PASS:=}
DB_PASSROOT=${DB_PASSROOT:=}
DB_USER=${DB_USER:=travis}
DB_PASS=${DB_PASS:=password}
DB_CACHE_FILE="${TRAVIS_BUILD_DIR}/db_init.sql"
DB_PREFIX="llx21_"
TRAVIS_DOC_ROOT_PHP="${TRAVIS_DOC_ROOT_PHP:=$TRAVIS_BUILD_DIR/htdocs}"
TRAVIS_DATA_ROOT_PHP="${TRAVIS_DATA_ROOT_PHP:=$TRAVIS_BUILD_DIR/documents}"
@ -25,20 +28,24 @@ if [[ "$(uname -a)" =~ "MINGW"* ]] || [[ "$(uname -a)" =~ "CYGWIN"* ]] ; then
else
SUDO="sudo"
fi
CONF_FILE=${CONF_FILE:=${TRAVIS_BUILD_DIR}/htdocs/conf/conf.php}
function save_db_cache() (
set -x
rm "${DB_CACHE_FILE}".md5 2>/dev/null
echo "Saving DB to cache file '${DB_CACHE_FILE}'"
${SUDO} "${MYSQLDUMP}" -u "$DB_ROOT" -h 127.0.0.1 $PASS_OPT travis \
eval ${SUDO} "${MYSQLDUMP}" ${USERPASS_OPT} -h 127.0.0.1 travis \
--hex-blob --lock-tables=false --skip-add-locks \
| sed -e 's/DEFINER=[^ ]* / /' > ${DB_CACHE_FILE}
echo "${sum}" > "${DB_CACHE_FILE}".md5
set +x
)
if [ "${DB_USER}" = travis ] && [ -r "${CONF_FILE}" ] ; then
# Cleanup configuration file in ci
mv "${CONF_FILE}" "${CONF_FILE}.$(date +"%Y%m%d%H%M%S").bak"
fi
if [ -r "${CONF_FILE}" ] ; then
echo "'${CONF_FILE} exists, not overwriting!"
@ -56,8 +63,8 @@ else
if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ]; then
echo '$'dolibarr_main_db_type=\'mysqli\'';'
echo '$'dolibarr_main_db_port=3306';'
echo '$'dolibarr_main_db_user=\'travis\'';'
echo '$'dolibarr_main_db_pass=\'password\'';'
echo '$'"dolibarr_main_db_user='${DB_USER}'"';'
echo '$'"dolibarr_main_db_pass='${DB_PASS}'"';'
fi
if [ "$DB" = 'postgresql' ]; then
echo '$'dolibarr_main_db_type=\'pgsql\'';'
@ -65,12 +72,20 @@ else
echo '$'dolibarr_main_db_user=\'postgres\'';'
echo '$'dolibarr_main_db_pass=\'postgres\'';'
fi
if [ "${DB_PREFIX}" != '' ]; then
echo '$'"dolibarr_main_db_prefix='${DB_PREFIX}'"';'
fi
echo '$'dolibarr_main_authentication=\'dolibarr\'';'
echo '$'force_install_createuser=true';'
echo '$'"dolibarr_main_db_collation='utf8_unicode_ci'"';'
} > "$CONF_FILE"
cat $CONF_FILE
echo
fi
# From here on, the DB_PREFIX can not be empty, set default value if empty
DB_PREFIX="${DB_PREFIX:=llx_}"
load_cache=0
echo "Setting up database '$DB'"
if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ] || [ "$DB" = 'postgresql' ]; then
@ -81,59 +96,63 @@ if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ] || [ "$DB" = 'postgresql' ]; the
${SUDO} mysqld_safe --skip-grant-tables --socket=/tmp/aaa &
sleep 3
${SUDO} ps fauxww
if [ "${DB_PASS}" = "" ] ; then
PASS_OPT="-password="
PASS_OPT=""
if [ "${DB_PASSROOT}" = "" ] ; then
ROOTPASS_OPT="-u ${DB_ROOT}"
else
PASS_OPT="'-password=${DB_PASS}'"
ROOTPASS_OPT="-u ${DB_ROOT} --password='${DB_PASSROOT}'"
fi
USERPASS_OPT="-u ${DB_USER} --password=\"${DB_PASS}\""
echo "MySQL set root password"
if [ 1 = 1 ] ; then
CMDS=( \
""
"FLUSH PRIVILEGES; DROP DATABASE travis; CREATE DATABASE IF NOT EXISTS travis CHARACTER SET = 'utf8';"
"CREATE USER 'root'@'localhost' IDENTIFIED BY '$DB_PASS';"
"CREATE USER 'root'@'127.0.0.1' IDENTIFIED BY '$DB_PASS';"
"CREATE USER 'travis'@'localhost' IDENTIFIED BY 'password';"
"CREATE USER 'travis'@'127.0.0.1' IDENTIFIED BY 'password';"
"GRANT ALL PRIVILEGES ON travis.* TO root@localhost;"
"GRANT ALL PRIVILEGES ON travis.* TO root@127.0.0.1;"
"GRANT ALL PRIVILEGES ON travis.* TO travis@127.0.0.1;"
"GRANT ALL PRIVILEGES ON travis.* TO travis@localhost;"
"CREATE USER '${DB_ROOT}'@'localhost' IDENTIFIED BY '${DB_PASSROOT}';"
"CREATE USER '${DB_ROOT}'@'127.0.0.1' IDENTIFIED BY '${DB_PASSROOT}';"
"CREATE USER '${DB_USER}'@'localhost' IDENTIFIED BY '${DB_PASS}';"
"CREATE USER '${DB_USER}'@'127.0.0.1' IDENTIFIED BY '${DB_PASS}';"
"GRANT ALL PRIVILEGES ON travis.* TO ${DB_ROOT}@localhost;"
"GRANT ALL PRIVILEGES ON travis.* TO ${DB_ROOT}@127.0.0.1;"
"GRANT ALL PRIVILEGES ON travis.* TO ${DB_USER}@127.0.0.1;"
"GRANT ALL PRIVILEGES ON travis.* TO ${DB_USER}@localhost;"
"FLUSH PRIVILEGES;"
)
# Local, not changing root
for CMD in "${CMDS[@]}" ; do
${SUDO} "${MYSQL}" -u "$DB_ROOT" ${PASS_OPT} -h 127.0.0.1 -e "$CMD"
${SUDO} "${MYSQL}" ${ROOTPASS_OPT} -h 127.0.0.1 -e "$CMD"
done
else
DB_ROOT='root'
DB_PASS='password'
${SUDO} "${MYSQL}" -u "$DB_ROOT" -h 127.0.0.1 -e "FLUSH PRIVILEGES; CREATE DATABASE IF NOT EXISTS travis CHARACTER SET = 'utf8'; ALTER USER 'root'@'localhost' IDENTIFIED BY '$DB_PASS'; CREATE USER 'root'@'127.0.0.1' IDENTIFIED BY '$DB_PASS'; CREATE USER 'travis'@'127.0.0.1' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON travis.* TO root@127.0.0.1; GRANT ALL PRIVILEGES ON travis.* TO travis@127.0.0.1; FLUSH PRIVILEGES;"
DB_PASSROOT='password'
ROOTPASS_OPT="-u ${DB_ROOT} '--password=${DB_PASSROOT}'"
${SUDO} "${MYSQL}" -u "${ROOTPASS_OPT}" -h 127.0.0.1 -e "FLUSH PRIVILEGES; CREATE DATABASE IF NOT EXISTS travis CHARACTER SET = 'utf8'; ALTER USER '${DB_ROOT}'@'localhost' IDENTIFIED BY '${DB_PASSROOT}'; CREATE USER '${DB_ROOT}'@'127.0.0.1' IDENTIFIED BY '${DB_PASSROOT}'; CREATE USER '${DB_USER}'@'127.0.0.1' IDENTIFIED BY '${DB_PASS}'; GRANT ALL PRIVILEGES ON travis.* TO '${DB_ROOT}@127.0.0.1; GRANT ALL PRIVILEGES ON travis.* TO '${DB_USER}'@127.0.0.1; FLUSH PRIVILEGES;"
fi
echo "MySQL grant"
${SUDO} "${MYSQL}" -u "$DB_ROOT" -h 127.0.0.1 $PASS_OPT -e 'FLUSH PRIVILEGES; GRANT ALL PRIVILEGES ON travis.* TO travis@127.0.0.1; FLUSH PRIVILEGES;'
${SUDO} "${MYSQL}" -u "$DB_ROOT" -h 127.0.0.1 $PASS_OPT -e 'FLUSH PRIVILEGES; GRANT ALL PRIVILEGES ON travis.* TO travis@localhost; FLUSH PRIVILEGES;'
${SUDO} "${MYSQL}" ${ROOTPASS_OPT} -h 127.0.0.1 -e "FLUSH PRIVILEGES; GRANT ALL PRIVILEGES ON travis.* TO ${DB_USER}@127.0.0.1; FLUSH PRIVILEGES;"
${SUDO} "${MYSQL}" ${ROOTPASS_OPT} -h 127.0.0.1 -e "FLUSH PRIVILEGES; GRANT ALL PRIVILEGES ON travis.* TO ${DB_USER}@localhost; FLUSH PRIVILEGES;"
echo "MySQL list current users"
${SUDO} "${MYSQL}" -u "$DB_ROOT" -h 127.0.0.1 $PASS_OPT -e 'use mysql; select * from user;'
${SUDO} "${MYSQL}" ${ROOTPASS_OPT} -h 127.0.0.1 -e 'use mysql; select * from user;'
echo "List pid file"
${SUDO} "${MYSQL}" -u "$DB_ROOT" -h 127.0.0.1 $PASS_OPT -e "show variables like '%pid%';"
${SUDO} "${MYSQL}" ${ROOTPASS_OPT} -h 127.0.0.1 -e "show variables like '%pid%';"
#sudo kill `cat /var/lib/mysqld/mysqld.pid`
#sudo systemctl start mariadb
echo "MySQL grant"
${SUDO} "${MYSQL}" -u "$DB_ROOT" -h 127.0.0.1 $PASS_OPT -e 'GRANT ALL PRIVILEGES ON travis.* TO travis@127.0.0.1;'
${SUDO} "${MYSQL}" ${ROOTPASS_OPT} -h 127.0.0.1 -e "GRANT ALL PRIVILEGES ON travis.* TO ${DB_USER}@127.0.0.1;"
echo "MySQL flush"
${SUDO} "${MYSQL}" -u "$DB_ROOT" -h 127.0.0.1 $PASS_OPT -e 'FLUSH PRIVILEGES;'
${SUDO} "${MYSQL}" ${ROOTPASS_OPT} -h 127.0.0.1 -e 'FLUSH PRIVILEGES;'
# shellcheck disable=2046
# Compute md5 based on install file contents, and on db prefix
# filefunc.inc.php holds the version, so include it"
# shellcheck disable=2046
sum=$(md5sum $(find "${TRAVIS_BUILD_DIR}/htdocs/install" -type f ; echo "${TRAVIS_BUILD_DIR}/filefunc.inc.php" ) | md5sum)
# shellcheck disable=2046
cnt=$(md5sum $(find "${TRAVIS_BUILD_DIR}/htdocs/install" -type f) | wc)
echo "NEWSUM $sum COUNT:$cnt"
echo "MD5SUM $sum COUNT:$cnt"
load_cache=0
if [ -r "$DB_CACHE_FILE".md5 ] && [ -r "$DB_CACHE_FILE" ] && [ -x "$(which "${MYSQLDUMP}")" ] ; then
cache_sum="$(<"$DB_CACHE_FILE".md5)"
@ -142,10 +161,10 @@ if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ] || [ "$DB" = 'postgresql' ]; the
if [ "$load_cache" = "1" ] ; then
echo "MySQL load cached sql"
${SUDO} "${MYSQL}" --force -u "$DB_ROOT" -h 127.0.0.1 $PASS_OPT -D travis < ${DB_CACHE_FILE} | tee $TRAVIS_BUILD_DIR/db_from_cacheinit.log
eval ${SUDO} "${MYSQL}" --force ${USERPASS_OPT} -h 127.0.0.1 -D travis < ${DB_CACHE_FILE} | tee $TRAVIS_BUILD_DIR/db_from_cacheinit.log
else
echo "MySQL load initial sql"
${SUDO} "${MYSQL}" --force -u "$DB_ROOT" -h 127.0.0.1 $PASS_OPT -D travis < ${TRAVIS_BUILD_DIR}/dev/initdemo/mysqldump_dolibarr_3.5.0.sql | tee $TRAVIS_BUILD_DIR/initial_350.log
sed 's/\([ `]\)llx_/\1'"${DB_PREFIX}/g" < "${TRAVIS_BUILD_DIR}/dev/initdemo/mysqldump_dolibarr_3.5.0.sql" | eval ${SUDO} "${MYSQL}" --force ${USERPASS_OPT} -h 127.0.0.1 -D travis | tee $TRAVIS_BUILD_DIR/initial_350.log
fi
elif [ "$DB" = 'postgresql' ]; then
echo Install pgsql if run is for pgsql
@ -188,9 +207,13 @@ set +e
fi
echo '$'force_install_dbserver=\'127.0.0.1\'';'
echo '$'force_install_database=\'travis\'';'
echo '$'force_install_databaselogin=\'travis\'';'
echo '$'force_install_databasepass=\'\'';'
echo '$'force_install_prefix=\'llx_\'';'
echo '$'"force_install_databaselogin='${DB_USER}'"';'
echo '$'"force_install_databasepass='${DB_PASS}'"';'
if [ "${DB_PREFIX}" != '' ] ; then
echo '$'"force_install_prefix='${DB_PREFIX}'"';'
fi
#echo '$'"force_install_dolibarrlogin='admin'"';'
#echo '$'force_install_createuser=true';'
} > "$INSTALL_FORCED_FILE"
if [ "$load_cache" != "1" ] ; then
@ -239,8 +262,16 @@ if [ "$load_cache" != "1" ] ; then
pVer="$v"
done
${SUDO} "${MYSQL}" --force -u "$DB_ROOT" -h 127.0.0.1 $PASS_OPT -D travis < "${TRAVIS_BUILD_DIR}/htdocs/install/mysql/migration/repair.sql"
sed "s/ llx_/ ${DB_PREFIX}/g" <"${TRAVIS_BUILD_DIR}/htdocs/install/mysql/migration/repair.sql" | eval ${SUDO} "${MYSQL}" --force ${USERPASS_OPT} -h 127.0.0.1 -D travis
# Apply repair options:
# Excluded options: force_utf8_on_tables force_utf8mb4_on_tables rebuild_sequences ; do
PHP_REPAIR_OPT=""
for opt in force_disable_of_modules_not_found restore_thirdparties_logos restore_user_pictures rebuild_product_thumbs clean_linked_elements clean_menus clean_orphelin_dir clean_product_stock_batch clean_perm_table repair_link_d set_empty_time_spent_amount force_collation_from_conf_on_tables ; do
PHP_REPAIR_OPT="$PHP_REPAIR_OPT\$_POST['$opt'] = '1';"
done
LOGNAME="${TRAVIS_BUILD_DIR}/repair${pVer//./}${v//./}"
"${PHP}" $PHP_OPT -r "$PHP_REPAIR_OPT; include 'repair.php';" > ${LOGNAME}.log
{
"${PHP}" $PHP_OPT upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_ProductBatch,MAIN_MODULE_SupplierProposal,MAIN_MODULE_STRIPE,MAIN_MODULE_ExpenseReport

View file

@ -25,7 +25,10 @@ the project: `pre-commit-config.yaml`.
1. Install pre-commit tool.\
If you do not have python installed, install [python](https://www.python.org) first.\
`sudo apt install python3`
If you do not have [`pip`](https://pypi.org/project/pip), install that as well.\\
`sudo apt install pip`
Then you can install pre-commit tool:
`python3 -m pip install pre-commit`
@ -91,4 +94,4 @@ CI also runs pre-commit to help maintain code quality.
Note:
Code for precommits are saved into:
.cache/pre-commit/repoyXXXXX/py_env-python3/lib/pythonX.Y/site-packages/pre_commit_hooks/no_commit_to_branch.py
.cache/pre-commit/repo*/py_env-python3/lib/python*/site-packages/pre_commit_hooks/no_commit_to_branch.py

View file

@ -98,7 +98,7 @@ while ($i < $argc) {
}
// PHPSTAN setup
$PHPSTANLEVEL = 4;
$PHPSTANLEVEL = 6;
// PHAN setup. Configuration is required, otherwise phan is disabled.
$PHAN_CONFIG = "{$path}phan/config_extended.php";
@ -745,7 +745,7 @@ $html .= '<div class="boxallwidth">'."\n";
$html .= <<<END
<center><br>Thumbs of most active contributors<br>
<br>
<a href="https://github.com/Dolibarr/dolibarr/graphs/contributors"><img src="https://camo.githubusercontent.com/a641a400eef38e00a93b572dcfc30d13ceaaeefbca951d09ed9189142d20cf62/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f646f6c69626172722f636f6e7472696275746f72732e7376673f77696474683d38393026627574746f6e3d66616c7365" alt="Dolibarr" data-canonical-src="https://opencollective.com/dolibarr/contributors.svg?width=890&amp;button=false" style="max-width: 100%;"></a>
<a href="https://github.com/Dolibarr/dolibarr/graphs/contributors"><img src="https://opencollective.com/dolibarr/contributors.svg?width=890&button=false" alt="Dolibarr" data-canonical-src="https://opencollective.com/dolibarr/contributors.svg?width=890&amp;button=false" style="max-width: 100%;"></a>
</center>
<br>
END;

View file

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

View file

@ -15,6 +15,8 @@ noe
udo
tim
ConfirmActionXxx
# Inside email
ba
blacklist
@ -71,7 +73,6 @@ unvalidate
# Some french strings
somme
caracteres
cas
sur
Datas
@ -84,3 +85,11 @@ fonction
espace
methode
datee
# Translation keys
addin
amountin
# other
blacklists
confirmactionxxx

View file

@ -1,197 +1,96 @@
|| !empty($dates) && empty($datee) && $loanSchedule->datep >= $dates && $loanSchedule->datep <= dol_now()
|| empty($dates) && !empty($datee) && $loanSchedule->datep <= $datee
$objMod->dictionaries = $objMod->{"dictionnaries"}; // For backward compatibility
if (($loanSchedule->datep >= $dates && $loanSchedule->datep <= $datee) // dates filter is defined
$datee = $langs->trans("Unknown");
$datee = dol_print_date($objectligne->date_end, 'day', false, $outputlangs, true);
$txt .= $outputlangs->transnoentities("DateStartPlannedShort")." : <strong>".$datei."</strong> - ".$outputlangs->transnoentities("DateEndPlanned")." : <strong>".$datee.'</strong>';
if (empty($objMod->dictionaries) && !empty($objMod->{"dictionnaries"})) {
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;id_entrepot='.$entrepotstatic->id.'&amp;action=transfert&amp;pdluoid='.$pdluo->id.'">';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&id_entrepot='.$entrepotstatic->id.'&action=transfert&pdluoid='.$pdluo->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 = '<i class="fas fa-briefcase inline-block"></i>';
//$typea = ($objp->typea == 'birth') ? $picb : $pice;
print '<td class="center"><a href="'.DOL_URL_ROOT.'/product/stock/product.php?dwid='.$object->id.'&id='.$objp->rowid.'&action=transfert&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$id).'">';
$date = $overview[0]->udate;
$dateb = $this->db->jdate($data[$j]->datea);
print '<td class="center"><a href="'.DOL_URL_ROOT.'/product/stock/product.php?dwid='.$object->id.'&id='.$objp->rowid.'&action=transfert&token='.newToken().'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$id).'">';
$dateemail = dol_stringtotime((string) $overview[0]->udate, 'gmt');
$link->datea = $this->db->jdate($obj->datea);
$object->periode = $newdateperiod;
$out .= dol_print_date($file->datea, 'dayhour');
$pice = '<i class="fas fa-briefcase inline-block"></i>';
$taskstatic->date_end = $this->db->jdate($objp->datee);
$tmp = $element->getSumOfAmount($idofelementuser ? $elementuser : '', $dates, $datee);
$tmpprojtime = $element->getSumOfAmount($idofelementuser ? $elementuser : '', $dates, $datee); // $element is a task. $elementuser may be empty
$typea = ($data[$j]->typea == 'birth') ? $picb : $pice;
//var_dump("$key, $tablename, $datefieldname, $dates, $datee");
GETPOSTINT("mouvement"),
dol_syslog("msgid=".$overview[0]->message_id." date=".dol_print_date($overview[0]->udate, 'dayrfc', 'gmt')." from=".$overview[0]->from." to=".$overview[0]->to." subject=".$overview[0]->subject);
if ((empty($dates) && empty($datee)) || (intval($dates) <= $element->datestart && intval($datee) >= $element->dateend)) {
jQuery("#mouvement option").removeAttr("selected").change();
jQuery("#mouvement option[value=0]").attr("selected","selected").trigger("change");
jQuery("#mouvement option[value=1]").attr("selected","selected").trigger("change");
jQuery("#mouvement").trigger("change");
print '<td colspan="'.(6 + count($TWeek)).'">';
$TFirstDay = getFirstDayOfEachWeek($TWeek, date('Y', $firstdaytoshow));
$TFirstDay[reset($TWeek)] = 1;
$action = 'transfert';
$addform .= '<input type="hidden" name="dateerfc" value="'.dol_print_date($datee, 'dayhourrfc').'">';
$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');
$project_static->date_end = $this->db->jdate($obj->datee);
$projectstatic->date_end = $db->jdate($objp->datee);
$ret = projectLinesPerMonth($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $TWeek);
$taskstatic->datee = $lines[$i]->date_end; // deprecated
$this->category->childs[] = $this->_cleanObjectDatas($cat);
$this->date_approbation = $this->db->jdate($obj->datea);
$this->date_approval = $this->db->jdate($obj->datea);
$this->date_approve = $this->db->jdate($obj->datea);
$this->datea = $this->db->jdate($obj->datea);
$this->datee = $this->db->jdate($obj->datee);
$this->periode = $this->db->jdate($obj->period);
$tmp = array('id_users' => $obj->id_users, 'nom' => $obj->name, 'reponses' => $obj->reponses);
$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0, true); // Disable hook for the moment
$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0, 1); // Disable hook for the moment
//si les reponses ne concerne pas la colonne effacée, on concatenate
GETPOST("mouvement", 'alpha'),
GETPOSTINT("mouvement"),
foreach ($TWeek as $weekIndex => $weekNb) {
if (count($arrayfields) > 0 && !empty($arrayfields['t.datee']['checked'])) {
if (jQuery("#mouvement").val() == \'0\') jQuery("#unitprice").removeAttr("disabled");
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=transfert">'.$langs->trans("TransferStock").'</a>';
print '<td class="center">'.dol_print_date($link->datea, "dayhour", "tzuser").'</td>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=transfert&token='.newToken().'">'.$langs->trans("TransferStock").'</a>';
$action = 'transfert';
$date_com = dol_mktime(GETPOSTINT('rehour'), GETPOSTINT('remin'), GETPOSTINT('resec'), GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'));
$date_next_execution = (GETPOST('remonth') ? dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')) : -1);
$date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear);
$datee = dol_get_last_day(GETPOSTINT('yeartoexport'), GETPOSTINT('monthtoexport') ? GETPOSTINT('monthtoexport') : 12);
$datesubscription = dol_mktime(12, 0, 0, GETPOSTINT("remonth"), GETPOSTINT("reday"), GETPOSTINT("reyear"));
$ensemblereponses = $obj->reponses;
$field = preg_replace('/(:[!<>=\s]+:|:in:|:notin:|:like:|:notlike:).*$/', '', $tmpcrit); // the name of the field
$newcrit = preg_replace('/(:[!<>=\s]+:|:in:|:notin:|:like:|:notlike:)/', '', $tmpcrit);
$object->datee = $datee;
$object->periode = $dateperiod;
$return .= '<br><span class="opacitymedium">'.$langs->trans("Payement").'</span> : <span class="info-box-label">'.$this->type_payment.'</span>';
$sortfield = "datea";
$sql = "SELECT p.rowid as id, p.entity, p.title, p.ref, p.public, p.dateo as do, p.datee as de, p.fk_statut as status, p.fk_opp_status, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount";
$sql .= " '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.date_ech as date, t.periode as date_due, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, ".PAY_DEBIT." as sens";
$sql .= " , datee = ".(!empty($obj->datee) ? "'".$this->db->escape($obj->datee)."'" : "null");
$sql .= " AND (".$datefieldname." <= '".$this->db->idate($datee)."' OR ".$datefieldname." IS NULL)";
$sql .= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day($project_year_filter, 1, false)).")";
$sql .= " AND date_creation BETWEEN '".$db->idate($dates)."' AND '".$db->idate($datee)."'";
$sql .= " AND er.datee >= '".$this->db->idate($date)."'";
$sql .= " ORDER BY pt.datee ASC, pt.dateo ASC";
$sql .= " t.datec, t.dateo, t.datee, t.tms,";
$sql .= " t.dateo, t.datee, t.planned_workload, t.rang,";
$sql .= ", datee = ".($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : 'null');
$sql .= "SELECT u.rowid, u.firstname, u.lastname, u.dateemployment as datea, date_format(u.dateemployment, '%d') as daya, 'employment' as typea, u.email, u.statut as status";
$sql = "SELECT pt.rowid, pt.ref, pt.fk_projet, pt.fk_task_parent, pt.datec, pt.dateo, pt.datee, pt.datev, pt.label, pt.description, pt.duration_effective, pt.planned_workload, pt.progress";
$sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth as datea, date_format(u.birth, '%d') as daya, 'birth' as typea, u.email, u.statut as status";
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'opensurvey_user_studs (nom, id_sondage, reponses, date_creation)';
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'opensurvey_user_studs (nom, id_sondage, reponses, ip, date_creation)';
$sql = 'SELECT s.reponses';
$sql2 .= " SET reponses = '".$db->escape($newcar)."'";
$taskstatic->datee = $db->jdate($obj->date_end);
$this->category->childs = array();
$this->datea = dol_now();
$tmpcrit = preg_replace('/^.*(:[!<>=\s]+:|:in:|:notin:|:like:|:notlike:)/', '\1', $tmpcrit); // the condition after the name of the field
'datee' => $date_end,
// mise a jour des reponses utilisateurs dans la base
if (!empty($arrayfields['t.datee']['checked'])) {
if ($user->hasRight('stock', 'mouvement', 'lire')) {
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 '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&action=transfert">'.$langs->trans("TransferStock").'</a>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&action=transfert&token='.newToken().'">'.$langs->trans("TransferStock").'</a>';
print '<span class="opacitymedium">'.$langs->trans("ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv("Referers")).'</span>';
print '<td class="center nowraponall">'.dol_print_date($db->jdate($obj->periode), 'day').'</td>';
print '<tr><td>'.$langs->trans("AddIn").'</td><td>';
print dol_print_date($object->periode, "day");
$TWeek[$week_number] = $week_number;
"sme",
$action = 'transfert';
$cle_rib = strtolower(checkES($rib, $CCC));
$date_com = dol_mktime(GETPOST('rehour'), GETPOST('remin'), GETPOST('resec'), GETPOST("remonth"), GETPOST("reday"), GETPOST("reyear"));
$date_next_execution = isset($date_next_execution) ? $date_next_execution : (GETPOST('remonth') ? dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')) : -1);
$date_next_execution = isset($date_next_execution) ? $date_next_execution : (GETPOSTINT('remonth') ? dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear')) : -1);
$datefrom = dol_mktime(0, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'));
$datesubscription = dol_mktime(0, 0, 0, GETPOSTINT("remonth"), GETPOSTINT("reday"), GETPOSTINT("reyear"));
$datetouse = ($this->date_end > 0) ? $this->date_end : ((isset($this->datee) && $this->datee > 0) ? $this->datee : 0);
$elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, !empty($project_field) ? $project_field : 'fk_projet');
$ensemblereponses = $obj->reponses;
$head[$h][1] = $langs->trans("Referers");
$head[$tab][1] = $langs->trans("Referers");
$out .= "<b>".$langs->trans("Referer").":</b> ".(isset($_SERVER["HTTP_REFERER"]) ? dol_htmlentities($_SERVER["HTTP_REFERER"], ENT_COMPAT) : '')."<br>\n";
$reday = GETPOSTINT('reday');
$sql = "SELECT p.rowid as id, p.entity, p.title, p.ref, p.public, p.dateo as do, p.datee as de, p.fk_statut as status, p.fk_opp_status, p.opp_amount, p.opp_percent, p.tms as date_modification, p.budget_amount";
$sql = 'SELECT p.rowid as id, p.entity, p.title, p.ref, p.public, p.dateo as do, p.datee as de, p.fk_statut as status, p.fk_opp_status, p.opp_amount, p.opp_percent, p.tms as date_modification, p.budget_amount';
$sql .= " (cs.periode IS NOT NULL AND cs.periode between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')";
$sql .= " OR (cs.periode IS NULL AND cs.date_ech between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')";
$sql .= " VALUES (".$conf->entity.", '".$this->db->idate($this->datea)."'";
$sql .= " datee=".($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : 'null').",";
$sql .= " f.date_approval as datea,";
$sql .= " f.date_approve as datea,";
$sql .= " f.datec, f.dateo, f.datee, f.datet, f.fk_user_author,";
$sql .= " t.datee as date_end,";
$sql .= " t.dateo as date_start, t.datee as date_end";
$sql .= " t.dateo as date_start, t.datee as date_end, t.planned_workload, t.rang,";
$sql .= " tms, dateo as date_start, datee as date_end, date_close, fk_soc, fk_user_creat, fk_user_modif, fk_user_close, fk_statut as status, fk_opp_status, opp_percent,";
$sql .= ", '".$this->db->idate($this->periode)."'";
$sql .= ", cs.libelle as label, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode as period, cs.import_key";
$sql .= ", datea = '".$this->db->idate(dol_now())."'";
$sql .= ", datee";
$sql .= ", periode='".$this->db->idate($this->periode)."'";
$sql = "INSERT INTO ".$this->db->prefix()."links (entity, datea, url, label, objecttype, objectid)";
$sql .= ", periode = '".$this->db->idate($this->period ? $this->period : $this->periode)."'";
$sql = "INSERT INTO ".MAIN_DB_PREFIX."chargesociales (fk_type, fk_account, fk_mode_reglement, libelle, date_ech, periode, amount, fk_projet, entity, fk_user_author, fk_user, date_creation)";
$sql = "SELECT SUM(duree) as total_duration, min(date) as dateo, max(date) as datee ";
$sql = "SELECT id_users, nom as name, id_sondage, reponses";
$sql = "SELECT id_users, nom as name, reponses";
$sql = "SELECT p.rowid, p.fk_statut as status, p.fk_opp_status, p.datee as datee";
$sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM ".$this->db->prefix()."links";
$sql = 'SELECT c.rowid, date_creation as datec, tms as datem, date_valid as date_validation, date_approve as datea, date_approve2 as datea2,';
$test = "<IMG SRC=\"jav&#x0D;ascript:alert('XSS');\">"; // Same
$test = '/javas:cript/google.com';
$this->periode = $this->date_creation + 3600 * 24 * 30;
$title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Referers');
$title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Referers');
$title = $langs->transnoentities("Balance")." - ".$langs->transnoentities("AllTime");
'datee' => $datee
'datee' =>array('type'=>'date', 'label'=>'DateEnd', 'enabled'=>1, 'visible'=>1, 'position'=>35),
'datee' =>array('type'=>'date', 'label'=>'Datee', 'enabled'=>1, 'visible'=>-1, 'position'=>90),
,'datee'=>array('type'=>'date')
// ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire
echo dol_print_date($rule->datee, 'day');
foreach ($TWeek as $weekNb) {
if (!empty($arrayfields['cs.periode']['checked'])) {
if (!empty($arrayfields['p.datee']['checked'])) {
if ($datee > 0) {
if ($newamount == 0 || empty($this->date_ech) || (empty($this->period) && empty($this->periode))) {
if ($user->hasRight('stock', 'mouvement', 'creer')) {
if (GETPOSTISSET("reday") && GETPOSTISSET("remonth") && GETPOSTISSET("reyear")) {
if (count($arrayfields) > 0 && !empty($arrayfields['t.datee']['checked'])) {
if (empty($datee)) {
if (empty($reyear) || empty($remonth) || empty($reday)) {
if (empty($this->datea)) {
if (in_array('01', $TWeek) && in_array('52', $TWeek) && $weekNb == '01') {
print $form->selectDate(strtotime(date('Y-m-d', $object->datee)), 'end', '', '', 0, '', 1, 0);
print $form->selectDate(strtotime(date('Y-m-d', $object->datee)), 'end', 0, 0, 0, '', 1, 0);
print $object->datee ? dol_print_date($object->datee, 'daytext') : '&nbsp;';
print '<input type="hidden" name="action" value="addin">';
print '<tr><td>'.$langs->trans("AddIn").'</td><td>';
print '<tr><td>'.$langs->trans("Datee").'</td>';
print_liste_field_titre($arrayfields['t.datee']['label'], $_SERVER["PHP_SELF"], "t.datee", '', $param, '', $sortfield, $sortorder, 'center ');
* @param string $datee End date (ex 23:59:59)
* @param float|string $selectedrate Force preselected vat rate. Can be '8.5' or '8.5 (NOO)' for example. Use '' for no forcing.
$TWeek = array();
* @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;
$datee = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear'));
$datee = dol_stringtotime($dateerfc);
$datepaid = dol_mktime(12, 0, 0, GETPOST("remonth"), GETPOST("reday"), GETPOST("reyear"));
$datepaid = dol_mktime(12, 0, 0, GETPOSTINT("remonth"), GETPOSTINT("reday"), GETPOSTINT("reyear"));
$datepaye = dol_mktime(12, 0, 0, GETPOSTINT("remonth"), GETPOSTINT("reday"), GETPOSTINT("reyear"));
@ -201,60 +100,34 @@
$head[$h][1] = $langs->trans('Referers');
$inj += preg_match('/on(dblclick|drop|durationchange|emptied|end|ended|error|focus|focusin|focusout|formdata|gotpointercapture|hashchange|input|invalid)[a-z]*\s*=/i', $tmpval);
$inj += preg_match('/on(dblclick|drop|durationchange|emptied|end|ended|error|focus|focusin|focusout|formdata|gotpointercapture|hashchange|input|invalid)[a-z]*\s*=/i', $val);
$morewherefilterarray[] = " t.datee <= '".$db->idate($search_date_end_end)."'";
$morewherefilterarray[] = " t.datee >= '".$db->idate($search_date_end_start)."'";
$opensurveysondage->mail_admin = $_SESSION['adresse'];
$pdf->SetXY($savx, $savy);
$projectstatic->datee = $db->jdate($obj->projectdatee);
$reday = GETPOST('reday');
$savy = $pdf->getY();
$somethingshown = $formactions->showactions($object, 'mouvement', 0, 1, '', $MAXEVENT, '', $morehtmlcenter); // Show all action for product
$sql .= " (cs.periode IS NOT NULL AND cs.periode between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')";
$sql .= " AND cs.periode <= '".$db->idate($search_date_limit_end)."'";
$sql .= " AND cs.periode >= '".$db->idate($search_date_limit_start)."'";
$sql .= " AND p.datee <= '".$db->idate($search_date_end_end)."'";
$sql .= " AND p.datee >= '".$db->idate($search_date_end_start)."'";
$sql .= " AND t.datee <= '".$db->idate($search_datelimit_end)."'";
$sql .= " AND t.datee >= '".$db->idate($search_datelimit_start)."'";
$sql .= " GROUP BY p.ref, p.title, p.rowid, p.fk_statut, p.fk_opp_status, p.public, p.dateo, p.datee, t.label, t.rowid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee";
$sql .= " GROUP BY p.rowid, p.ref, p.title, p.fk_statut, p.datee, p.fk_opp_status, p.public, p.fk_user_creat,";
$sql .= " OR (cs.periode IS NULL AND cs.date_ech between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')";
$sql .= " ORDER BY t.dateo DESC, t.rowid DESC, t.datee DESC";
$sql .= " SET reponses = '".$db->escape($nouveauchoix)."'";
$sql .= " cs.rowid, cs.libelle, cs.fk_type as type, cs.periode as period, cs.date_ech, cs.amount as total,";
$sql .= " t.datec, t.dateo, t.datee, t.tms,";
$sql .= " t.label, t.rowid as taskid, t.planned_workload, t.duration_effective, t.progress, t.dateo as date_start, t.datee as date_end, SUM(tasktime.element_duration) as timespent";
$sql = "SELECT p.ref, p.title, p.rowid as projectid, p.fk_statut as status, p.fk_opp_status as opp_status, p.public, p.dateo as projdate_start, p.datee as projdate_end,";
$sql.= " ".MAIN_DB_PREFIX."notify_def as nd,";
$sql.= " AND nd.fk_action = ad.rowid";
$sql.= " WHERE u.rowid = nd.fk_user";
$sql.= " nd.rowid, ad.code, ad.label";
$sql2 .= " p.dateo, p.datee,";
$sql2 .= " s.logo, s.email, s.entity, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_percent, p.opp_amount, p.dateo, p.datee";
$title = $langs->trans('Batch')." ".$shortlabel." - ".$langs->trans('Referers');
$totalforvisibletasks = projectLinesPerMonth($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $isavailable, 0, $TWeek);
$value = preg_replace('/([a-z\.]+)\s*([!<>=]+|in|notin|like|notlike)\s*/', '\1:\2:', $value); // Clean string 'x < 10' into 'x:<:10' so we can then explode on space to get all AND tests to do
'cs.periode' => array('label' => "PeriodEndDate", 'checked' => 1, 'position' => 50),
't.datee'=>array('label'=>"Deadline", 'checked'=>1, 'position'=>101),
't.datee'=>array('label'=>"Deadline", 'checked'=>1, 'position'=>5),
// Ligne de la periode d'analyse du rapport
// ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire
//$datee=$now
//$dates=dol_time_plus_duree($datee, -1, 'y');
<strong>TaskItem(<em>pID, pName, pStart, pEnd, pColor, pLink, pMile, pRes, pComp, pGroup, pParent, pOpen, pDepend, pCaption, pNotes, pGantt</em>)</strong></p>
foreach ($TWeek as $weekNb) {
foreach ($TWeek as $week_number) {
if (!empty($arrayfields['t.datee']['checked'])) {
if ($action == "transfert") {
if ($object->id > 0 && $action == 'addin') {
if (GETPOST('reday')) {
if (GETPOSTINT("reyear") && GETPOSTINT("remonth") && GETPOSTINT("reday")) {
print $form->selectDate($datee, 'datee', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
print '<option value="1"'.(GETPOST('mouvement') ? ' selected="selected"' : '').'>'.$langs->trans("Delete").'</option>';
print '<select name="mouvement" id="mouvement" class="minwidth100 valignmiddle">';
print '<td class="left" width="25%">'.$langs->trans("Referers").'</td>';
print '<td class="right">'.$langs->trans("NbOfMembers").' <span class="opacitymedium">('.$langs->trans("AllTime").')</span></td>';
print '<tr><td>'.$langs->trans("AddIn").'</td><td>';
print '<tr><td>'.$langs->trans("Period")."</td><td>".dol_print_date($charge->periode, 'day')."</td></tr>\n";
print ajax_combobox("mouvement");
print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.lastname,cs.periode", "", $param, 'class="left"', $sortfield, $sortorder);
@ -266,58 +139,20 @@
print_liste_field_titre($arrayfields['cs.libelle']['label'], $_SERVER["PHP_SELF"], "cs.libelle,cs.periode", '', $param, '', $sortfield, $sortorder);
print_liste_field_titre($arrayfields['cs.paye']['label'], $_SERVER["PHP_SELF"], "cs.paye,cs.periode", '', $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre($arrayfields['cs.periode']['label'], $_SERVER["PHP_SELF"], "cs.periode", '', $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre($arrayfields['p.datee']['label'], $_SERVER["PHP_SELF"], "p.datee", "", $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre($arrayfields['t.datee']['label'], $_SERVER["PHP_SELF"], "t.datee", "", $param, '', $sortfield, $sortorder, 'center ');
public $childs = array();
public $datea;
public $datee;
public $periode;
public function getSumOfAmount($fuser = '', $dates = '', $datee = '')
return $TWeek;
unset($_SESSION["adresse"]);
- creat,unitl,alltime,datas,referers
- informations,medias,uptodate,reenable,crypted,developpers
- ned
* @param array $TWeek array of week numbers
* @param string[] $TWeek array of week numbers
* @param string[] $TWeek array of week numbers (week 1 must be '01')
* @param array $TWeek Array of week numbers
* Copyright (C) 2019 Tim Otte <otte@meuser.it>
* Copyright (C) 2019 Tim Otte <otte@meuser.it>
* Copyright (C) 2019 Tim Otte <otte@meuser.it>
* Copyright (C) 2020 Thibault FOUCART <suport@ptibogxiv.net>
* Copyright (C) 2020-2021 Udo Tamm <dev@dolibit.de>
* Copyright (C) 2021 Noé Cendrier <noe.cendrier@altairis.fr>
* Copyright (C) 2021 Noé Cendrier <noe.cendrier@altairis.fr>
* Copyright (C) 2021 Noé Cendrier <noe.cendrier@altairis.fr>
* Copyright (C) 2021 Noé Cendrier <noe.cendrier@altairis.fr>
* Copyright (C) 2022 Udo Tamm <dev@dolibit.de>
* Copyright (C) 2022 Udo Tamm <dev@dolibit.de>
* Copyright (C) 2022-2023 Udo Tamm <dev@dolibit.de>
* Copyright (C) 2023 Udo Tamm <dev@dolibit.de>
* Copyright (C) 2024 Noé Cendrier <noe.cendrier@altairis.fr>
* add german links 2020 Udo Tamm <dev@dolibit.de>
$TFirstDays = getFirstDayOfEachWeek($TWeek, $year);
$TFirstDays[reset($TWeek)] = '01'; //first day of month
$TLastDays = getLastDayOfEachWeek($TWeek, $year);
$TLastDays[end($TWeek)] = date("t", strtotime($year.'-'.$month.'-'.$day)); //last day of month
$TWeek = getWeekNumbersOfMonth($month, $year);
$datee = dol_mktime(23, 59, 59, GETPOST('dateemonth'), GETPOST('dateeday'), GETPOST('dateeyear'));
$moresql = dolSqlDateFilter('t.datee', $search_dtendday, $search_dtendmonth, $search_dtendyear, 1);
$parameters = array('id' => $id, 'taskid' => $taskid, 'projectid' => $projectid, 'TWeek' => $TWeek, 'TFirstDays' => $TFirstDays, 'TLastDays' => $TLastDays);
* Copyright (C) 2019 Cedric Ancelin <icedo.anc@gmail.com>
$permissiontoadd = $user->hasRight('stock', 'mouvement', 'creer');
$permissiontodelete = $user->hasRight('stock', 'mouvement', 'creer'); // There is no deletion permission for stock movement as we should never delete
$permissiontoread = $user->hasRight('stock', 'mouvement', 'lire');
$sql .= " GROUP BY cs.rowid, cs.fk_type, cs.fk_user, cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode, cs.fk_account, c.libelle, c.accountancy_code, ba.label, ba.ref, ba.number, ba.account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.clos, pay.code";
$sql .= " cs.amount, cs.date_ech, cs.libelle as label, cs.paye, cs.periode, cs.fk_account,";
$sql .= " cs.rowid, cs.libelle as label_sc, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total, cs.paye,";
$sql .= " p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.opp_percent, (p.opp_amount*p.opp_percent/100) as opp_weighted_amount, p.tms as date_modification, p.budget_amount,";
$sql .= " t.datec as date_creation, t.dateo as date_start, t.datee as date_end, t.tms as date_modification,";
$sql .= dolSqlDateFilter('p.datee', $search_eday, $search_emonth, $search_eyear);
$sql = "SELECT ".$distinct." p.rowid as projectid, p.ref as projectref, p.title as projecttitle, p.fk_statut as projectstatus, p.datee as projectdatee, p.fk_opp_status, p.public, p.fk_user_creat as projectusercreate, p.usage_bill_time,";
$sql = "SELECT id_users, nom as name, id_sondage, reponses";
$sql = "SELECT p.rowid, p.ref, p.title, p.dateo as date_start, p.datee as date_end, p.fk_statut as status, p.tms as datem";
$sql = "SELECT s.rowid, s.nom as name, s.client, s.town, s.datec, s.datea";
$sql = 'SELECT nom as name, reponses';
$title = $langs->trans("Referers", $object->name);
$usercancreate = $user->hasRight('stock', 'mouvement', 'creer');
@ -326,33 +161,19 @@ $usercandelete = $user->hasRight('stock', 'mouvement', 'creer');
$usercandelete = (($user->hasRight('stock', 'mouvement', 'supprimer')));
$usercanread = $user->hasRight('stock', 'mouvement', 'lire');
$usercanread = (($user->hasRight('stock', 'mouvement', 'lire')));
* The hook contaxt commcard has been renamed thirdpartycomm
* The hook contaxt thirdpartycard has been renamed thirdpartycontact
$usercanupdatestock = $user->hasRight('stock', 'mouvement', 'creer');
* The private array ->status_short, ->statuts and ->status_long are now array ->labelStatusShort and ->labelStatus everywhere.
- Fix: [ bug #485 ] Configurated amount for public auto-subscription form is not taken into account
- New: Add proposals into referer page of thirdparty.
AmountIn
NEW: ModuleBuilder: Checkin comments begin and end before each actions
Vous pouvez voir la progression du ticket en cliquant sur le lien
for /F "tokens=2 delims=," %%i in ('tasklist /FI "IMAGENAME eq php.exe" /FO CSV /NH') do (
foreach ($TWeek as $week_number) {
function checkES($IentOfi, $InumCta)
function getFirstDayOfEachWeek($TWeek, $year)
function getLastDayOfEachWeek($TWeek, $year)
function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $TWeek = array())
if (!$user->hasRight('stock', 'mouvement', 'lire')) {
if (!empty($arrayfields['cs.periode']['checked'])) {
if (!empty($arrayfields['p.datee']['checked'])) {
if (!empty($arrayfields['t.datee']['checked'])) {
if ($action == "transfert") {
if (empty($datee) && !empty($dateerfc)) { // deprecated
print $langs->trans("Developpers").':';
print '<input type="hidden" id="numberOfFirstLine" name="numberOfFirstLine" value="'.(reset($TWeek)).'"/>'."\n";
print '<td class="right">'.$langs->trans("NbOfMembers").' <span class="opacitymedium">('.$langs->trans("AllTime").')</span></td>';
print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "cs.periode", "", $param, '', $sortfield, $sortorder, 'center ');
select#date_startday, select#date_startmonth, select#date_endday, select#date_endmonth, select#reday, select#remonth
select#date_startday, select#date_startmonth, select#date_endday, select#date_endmonth, select#reday, select#remonth,
print '<td class="center"><a href="'.DOL_URL_ROOT.'/product/stock/product.php?dwid='.$object->id.'&id='.$objp->rowid.'&action=transfert&token='.newToken().'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$id).'">';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&action=transfert&token='.newToken().'">'.$langs->trans("TransferStock").'</a>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&action=transfert&token='.newToken().'">'.$langs->trans("TransferStock").'</a>';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&id_entrepot='.$entrepotstatic->id.'&action=transfert&pdluoid='.$pdluo->id.'&token='.newToken().'">';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=transfert&token='.newToken().'">'.$langs->trans("TransferStock").'</a>';

View file

@ -157,7 +157,7 @@ foreach my $file (keys %filelist) {
print OUT "\\c ". $1;
next;
}
if ($create_sql ne "") { # we are inside create table statement so lets process datatypes
if ($create_sql ne "") { # we are inside create table statement so let's process datatypes
if (/\);/i) { # end of create table sequence
$create_sql =~ s/,$//g; # strip last , inside create table

View file

@ -3,6 +3,7 @@
/*
* Copyright (C) 2005-2011 James Grant <james@lightbox.org> Lightbox Technologies Inc.
* Copyright (C) 2020 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -419,7 +420,7 @@ function pg2mysql(&$input, &$arrayofprimaryalreadyintabledef, $header = true)
// in after, we need to watch out for escape format strings, ie (E'escaped \r in a string'), and ('bla',E'escaped \r in a string'), but could also be (number, E'string'); so we can't search for the previous '
// ugh i guess its possible these strings could exist IN the data as well, but the only way to solve that is to process these lines one character
// at a time, and that's just stupid, so lets just hope this doesn't appear anywhere in the actual data
// at a time, and that's just stupid, so let's just hope this doesn't appear anywhere in the actual data
$after = str_replace(" (E'", " ('", $after);
$after = str_replace(", E'", ", '", $after);
@ -439,7 +440,7 @@ function pg2mysql(&$input, &$arrayofprimaryalreadyintabledef, $header = true)
// in after, we need to watch out for escape format strings, ie (E'escaped \r in a string'), and ('bla',E'escaped \r in a string')
// ugh i guess its possible these strings could exist IN the data as well, but the only way to solve that is to process these lines one character
// at a time, and that's just stupid, so lets just hope this doesn't appear anywhere in the actual data
// at a time, and that's just stupid, so let's just hope this doesn't appear anywhere in the actual data
$after = str_replace(" (E'", " ('", $after);
$after = str_replace(", E'", ", '", $after);
@ -457,7 +458,7 @@ function pg2mysql(&$input, &$arrayofprimaryalreadyintabledef, $header = true)
// in after, we need to watch out for escape format strings, ie (E'escaped \r in a string'), and ('bla',E'escaped \r in a string')
// ugh i guess its possible these strings could exist IN the data as well, but the only way to solve that is to process these lines one character
// at a time, and that's just stupid, so lets just hope this doesn't appear anywhere in the actual data
// at a time, and that's just stupid, so let's just hope this doesn't appear anywhere in the actual data
// after the first line, we only need to check for it in the middle, not at the beginning of an insert (because the beginning will be on the first line)
// $after=str_replace(" (E'","' ('",$after);
@ -497,7 +498,7 @@ function pg2mysql(&$input, &$arrayofprimaryalreadyintabledef, $header = true)
$reg2 = array();
if (preg_match('/ALTER TABLE ([^\s]+)/', $pkey, $reg2)) {
if (empty($arrayofprimaryalreadyintabledef[$reg2[1]])) {
// looks like we have a single line PRIMARY KEY definition, lets go ahead and add it
// looks like we have a single line PRIMARY KEY definition, let's go ahead and add it
$output .= str_replace("\n", "", $pkey);
// the postgres and mysql syntax for this is (at least, in the example im looking at)
// identical, so we can just add it as is.

View file

@ -42,6 +42,32 @@ const PREFIXES = [
'php' => ['/* ', ' * ', ' */', '<?php'],
];
/**
* Expand tabs in string to spaces.
*
* @param $str String in which to expand the tabs to spaces
* @param $tabWidth Width to use for a tabstop
*
* @return string Expanded string value.
*/
function expandTabs($str, $tabWidth)
{
$expanded = '';
$col = 0;
$len = mb_strlen($str);
for ($i = 0; $i < $len; $i++) {
if ($str[$i] == "\t") {
$expanded .= str_repeat(' ', $tabWidth - ($col % $tabWidth));
$col += $tabWidth - ($col % $tabWidth);
} else {
$expanded .= $str[$i];
$col++;
}
}
return $expanded;
}
/**
* Update or add copyright notice in a file
*
@ -70,18 +96,45 @@ function updateCopyrightNotice($filename, $fileType, $name, $email)
$n = 50;
$lines = implode('', array_slice(file($filename), 0, $n));
// Define the regex pattern for matching copyright notices
$pattern = "~(?:{$r_prefix0}|{$r_prefix1})Copyright \(C\)\s+(?:(?:\d{4}-)?(?<year>\d{4}))\s+{$r_name}\s*\<{$r_email}>~";
// Based on the tendency to limit the length of the spacing between the name
// and email to the smallest one, determine the biggest offset from the start
// of a name to the start of the email, and use that for the current name/email
// offset if it is sufficient.
// Pattern to match any copyright already present
$allpattern = "~(?:{$r_prefix0}|{$r_prefix1})Copyright \(C\)\s+(?:(?:\d{4}-)?(?:\d{4}))\s+(\S.*)<\S+>~";
// Set minimum offset based of width of new name
$nameStartToMailStartOffset = 4 * (int) ((mb_strlen($r_name) + 4) / 4);
if (preg_match_all($allpattern, $lines, $allmatches)) {
foreach ($allmatches[1] as $nameAndSpaces) {
//print $nameAndSpaces."\n";
$nameAndSpaces = expandTabs($nameAndSpaces, 4);
$currentOffset = mb_strlen($nameAndSpaces);
$currentOffset = 4 * (int) ((3 + $currentOffset) / 4);
//print "Other offset $nameAndSpaces: $currentOffset\n";
if ($currentOffset > $nameStartToMailStartOffset) {
$nameStartToMailStartOffset = $currentOffset;
}
}
}
// Pattern to match the line matching the current developer
$pattern = "~(?:{$r_prefix0}|{$r_prefix1})Copyright \(C\)\s+(?:(?:(?<start>\d{4})-)?(?<last>\d{4}))\s+{$r_name}\s*\<{$r_email}>~";
// Check if the lines match the pattern
$matches = array();
if (preg_match($pattern, $lines, $matches)) {
$existingYear = $matches['year'];
$existingYear = $matches['last'];
if (array_key_exists('start', $matches)) {
$startYear = $matches['start'];
} else {
$startYear = $existingYear;
}
// Check if the existing year is different from the current year
if ($existingYear !== date('Y')) {
// Update the year range to include or be up to the current year
$updatedNotice = preg_replace('/(\d{4})(-\d{4})?\s+/', $existingYear . '-' . date('Y') . "\t", $matches[0]);
// Extend the year range to the current year
$updatedNotice = preg_replace('/(?:\d{4}-)?\d{4}\s+/', $startYear . '-' . date('Y') . "\t", $matches[0]);
// Replace the old notice with the updated one in the file
file_put_contents($filename, preg_replace($pattern, $updatedNotice, file_get_contents($filename)));
@ -90,7 +143,8 @@ function updateCopyrightNotice($filename, $fileType, $name, $email)
// If the existing year is the same, no need to update
} else {
// Adjust tabs for proper alignment
$emailTabs = str_repeat("\t", (int) (max(0, (31 - mb_strlen($name)) / 4)));
// print "Offset:".$nameStartToMailStartOffset."\n";
$emailTabs = str_repeat("\t", (int) (max(0, ($nameStartToMailStartOffset + 4 - mb_strlen($name)) / 4)));
// No match found, add a new line to the header
$newNotice = "Copyright (C) " . date('Y') . "\t\t" . $name . $emailTabs . "<" . $email . ">";
@ -114,6 +168,7 @@ function updateCopyrightNotice($filename, $fileType, $name, $email)
// Write the updated content back to the file
file_put_contents($filename, $fileContent);
// print $fileContent;
return true; // Change detected
}

File diff suppressed because it is too large Load diff

View file

@ -11,6 +11,7 @@ $sanitizeRegex
array(
// Documented:
'none',
'password',
'array',
'int',
'intcomma',
@ -22,24 +23,16 @@ $sanitizeRegex
'aZ09',
'aZ09arobase',
'aZ09comma',
'email',
'san_alpha',
'restricthtml',
'nohtml',
'custom',
// Not documented:
'email',
'restricthtmlallowclass',
'restricthtmlallowunvalid',
'restricthtmlnolink',
//'ascii',
//'categ_id',
//'chaine',
//'html',
//'boolean',
//'double',
//'float',
//'string',
'restricthtmlallowlinkscript'
)
).')*$/';
@ -137,7 +130,7 @@ $VALID_MODULE_MAPPING = array(
'mymodule' => null, // modMyModule - Name used in module builder (avoid false positives)
'notification' => 'Notification',
'numberwords' => null, // Not provided by default, no module tests
'oauth' => 'Oauth',
'oauth' => 'OAuth',
'openstreetmap' => null, // External module?
'opensurvey' => 'OpenSurvey',
'order' => 'Commande',
@ -265,17 +258,18 @@ return [
'filtert' => 'int',
'forceall' => 'int<0,1>',
'form' => '\Form',
'formcompany' => '\FormCompany',
'hookmanager' => '\HookManager',
'inputalsopricewithtax' => 'int<0,1>',
'langs' => '\Translate',
'leftmenu' => 'string',
'linkedObjectBlock' => '\CommonObject[]', // See htdocs/core/class/html.form.class.php
'mainmenu' => 'string',
'menumanager' => '\MenuManager',
'mysoc' => '\Societe',
'mysoc' => '?\Societe',
'nblines' => '\int',
'obj' => '\CommonObject', // Deprecated
'object_rights' => 'int|stdClass',
'objectoffield' => '\CommonObject',
'objsoc' => '\Societe',
'senderissupplier' => 'int<0,2>',
'user' => '\User',
'website' => 'string', // See discussion https://github.com/Dolibarr/dolibarr/pull/28891#issuecomment-2002268334 // Disable because Phan infers Website type
@ -325,13 +319,15 @@ return [
//'exclude_file_regex' => '@^vendor/.*/(tests?|Tests?)/@',
'exclude_file_regex' => '@^(' // @phpstan-ignore-line
.'dummy' // @phpstan-ignore-line
// mymodule seen in cti, but not in git.
.'|htdocs/custom/.*' // Ignore all custom modules @phpstan-ignore-line
.'|htdocs/.*/canvas/.*/tpl/.*.tpl.php' // @phpstan-ignore-line
.'|htdocs/modulebuilder/template/.*' // @phpstan-ignore-line
//.'|htdocs/modulebuilder/template/.*' // @phpstan-ignore-line
// Included as stub (better analysis)
.'|htdocs/includes/nusoap/.*' // @phpstan-ignore-line
// Included as stub (old version + incompatible typing hints)
.'|htdocs/includes/restler/.*' // @phpstan-ignore-line
// Included as stub (did not seem properly analysed by phan without it)
// Included as stub (did not seem properly analyzed by phan without it)
.'|htdocs/includes/stripe/.*' // @phpstan-ignore-line
.'|htdocs/conf/conf.php' // @phpstan-ignore-line
// .'|htdocs/[^h].*/.*' // For testing @phpstan-ignore-line
@ -354,9 +350,9 @@ return [
'/^sanitizeVal$/' => [1, $sanitizeRegex,"UnknownSanitizeType"],
'/^checkVal$/' => [1, $sanitizeRegex,"UnknownCheckValSanitizeType"],
'/^\\\\ExtraFields::addExtraField$/' => [2, $extraFieldTypeRegex,"UnknownExtrafieldTypeBack"],
'/^dol_now$/' => [0, '{^(?:auto|gmt|tz(?:server|ref|user(?:rel)?))$}',"InvalidDolNowArgument"], // '', 0, 1 match bool and int values
'/^dol_now$/' => [0, '{^(?:auto|gmt|tz(?:server|ref|user(?:rel)?))$}',"InvalidDolNowArgument"],
'/^dol_mktime$/' => [6, '{^(?:|0|1|auto|gmt|tz(?:server|ref|user(?:rel)?|,[+a-zA-Z-/]+))$}',"InvalidDolMktimeArgument"], // '', 0, 1 match bool and int values
'/^dol_print_date$/' => [2, '{^(?:|0|1|auto|gmt|tz(?:server|user(?:rel)?))$}',"InvalidDolMktimeArgument"],
'/^dol_print_date$/' => [2, '{^(?:|0|1|auto|gmt|tz(?:server|user(?:rel)?))$}',"InvalidDolMktimeArgument"], // '', 0, 1 match bool and int values
'/^GETPOSTFLOAT$/' => [1, '{^(?:|M[UTS]|C[UT]|\d+)$}',"InvalidGetPostFloatRounding"],
'/^price2num$/' => [1, '{^(?:|M[UTS]|C[UT]|\d+)$}',"InvalidPrice2NumRounding"],
],
@ -392,7 +388,7 @@ return [
'UnknownElementTypePlugin',
'WhitespacePlugin',
//'RemoveDebugStatementPlugin', // Reports echo, print, ...
//'SimplifyExpressionPlugin',
'SimplifyExpressionPlugin',
//'StrictComparisonPlugin', // Expects ===
'SuspiciousParamOrderPlugin',
'UnsafeCodePlugin',
@ -421,13 +417,14 @@ return [
'PhanCompatibleNegativeStringOffset', // return false positive
'PhanPluginConstantVariableBool', // a lot of false positive, in most cases, we want to keep the code as it is
'PhanPluginUnknownArrayPropertyType', // this option costs more time to be supported than it solves time
// 'PhanPluginUnknownArrayPropertyType', // this option costs more time to be supported than it solves time
'PhanTypeArraySuspiciousNullable', // this option costs more time to be supported than it solves time
'PhanTypeInvalidDimOffset', // this option costs more time to be supported than it solves time
// 'PhanTypeInvalidDimOffset', // Helps identify missing array indexes in types or reference to unset indexes
'PhanTypeObjectUnsetDeclaredProperty',
'PhanTypePossiblyInvalidDimOffset', // a lot of false positive, in most cases, we want to keep the code as it is
'PhanTypePossiblyInvalidDimOffset', // a lot of false positive, in most cases, we want to keep the code as it is
// 'PhanPluginUnknownArrayFunctionReturnType', // a lot of false positive, in most cases, we want to keep the code as it is
'PhanPluginWhitespaceTab', // Dolibarr used tabs
'PhanPluginWhitespaceTab', // Dolibarr uses tabs
'PhanPluginCanUsePHP71Void', // Dolibarr is maintaining 7.0 compatibility
'PhanPluginShortArray', // Dolibarr uses array()
'PhanPluginShortArrayList', // Dolibarr uses array()
@ -439,7 +436,7 @@ return [
'PhanPluginNonBoolBranch', // Not essential - 31240+ occurrences
'PhanPluginNumericalComparison', // Not essential - 19870+ occurrences
'PhanTypeMismatchArgument', // Not essential - 12300+ occurrences
'PhanTypeMismatchArgument', // Also reported by phpstan < lvl6 - 12300+ occurrences
'PhanPluginNonBoolInLogicalArith', // Not essential - 11040+ occurrences
'PhanPluginConstantVariableScalar', // Not essential - 5180+ occurrences
'PhanPluginDuplicateAdjacentStatement',
@ -449,10 +446,11 @@ return [
'PhanPluginRedundantAssignment', // Not essential, useless
'PhanPluginDuplicateCatchStatementBody', // Requires PHP7.1 - 50+ occurrences
'PhanPluginUnknownArrayMethodParamType', // Too many troubles to manage. Is enabled into config_extended only.
'PhanPluginUnknownArrayMethodReturnType', // Too many troubles to manage. Is enabled into config_extended only.
'PhanUndeclaredGlobalVariable', // Too many false positives on .tpl.php files. Is enabled into config_extended only.
'PhanPluginUnknownObjectMethodCall', // False positive for some class. Is enabled into config_extended only.
// 'PhanPluginUnknownArrayMethodParamType', // Too many troubles to manage. Is enabled in config_extended only.
// 'PhanPluginUnknownArrayMethodReturnType', // Too many troubles to manage. Is enabled in config_extended only.
// 'PhanUndeclaredGlobalVariable', // Helps identify variables that are not set/defined - add '@phan-var-force TYPE $varname' in tpl or includes to help type the variable
// 'PhanPluginUnknownObjectMethodCall', // False positive for some class. Is enabled in config_extended only.
'PhanTypeSuspiciousNonTraversableForeach', // Reports on `foreach ($object as $key => $value)` which works without php notices, so we ignore it because this is intentional in the code.
],
// You can put relative paths to internal stubs in this config option.
// Phan will continue using its detailed type annotations,

View file

@ -68,9 +68,10 @@ $config['suppress_issue_types'] = [
'PhanPluginConstantVariableBool', // a lot of false positive, in most cases, we want to keep the code as it is
'PhanPluginUnknownArrayPropertyType', // this option costs more time to be supported than it solves time
'PhanTypeArraySuspiciousNullable', // this option costs more time to be supported than it solves time
'PhanTypeInvalidDimOffset', // this option costs more time to be supported than it solves time
// 'PhanTypeInvalidDimOffset', // Helps identify missing array indexes in types or reference to unset indexes
'PhanTypeObjectUnsetDeclaredProperty',
'PhanTypePossiblyInvalidDimOffset', // a lot of false positive, in most cases, we want to keep the code as it is
'PhanPluginUnknownArrayFunctionReturnType', // a lot of false positive, in most cases, we want to keep the code as it is
'PhanPluginWhitespaceTab', // Dolibarr used tabs
'PhanPluginCanUsePHP71Void', // Dolibarr is maintaining 7.0 compatibility
@ -93,6 +94,10 @@ $config['suppress_issue_types'] = [
'PhanPluginRedundantAssignmentInGlobalScope', // Not essential, a lot of false warning
'PhanPluginRedundantAssignment', // Not essential, useless
'PhanPluginDuplicateCatchStatementBody', // Requires PHP7.1 - 50+ occurrences
'PhanPluginUnknownArrayMethodParamType', // this option costs more time to be supported than it solves time
'PhanPluginUnknownArrayMethodReturnType', // this option costs more time to be supported than it solves time
'PhanTypeSuspiciousNonTraversableForeach', // Reports on `foreach ($object as $key => $value)` which works without php notices, so we ignore it because this is intentional in the code.
];
return $config;

View file

@ -135,8 +135,16 @@ class ParamMatchVisitor extends PluginAwarePostAnalysisVisitor
{
$class_name = $node->children['class']->children['name'] ?? null;
if (!\is_string($class_name)) {
throw new NodeException($expr, 'does not have class');
// May happen for $this->className::$name(...$arguments); (variable class name)
$location = $this->context->getFile().":".$node->lineno;
print "$location: Node does not have fixed string class_name - node type ".(is_object($class_name) ? get_class_name($class_name) : gettype($class_name)).PHP_EOL;
return;
// throw new NodeException($node, 'does not have class');
}
// } else {
// $location = $this->context->getFile().":".$node->lineno;
// print "$location: Static call - node type ".get_class($node).PHP_EOL;
//}
try {
$class_name = (string) FullyQualifiedClassName::fromFullyQualifiedString($class_name);
} catch (FQSENException $_) {

View file

@ -0,0 +1,115 @@
<?php
/* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*/
namespace {
/**
* Use an OVH account to send SMS with Dolibarr
*/
class OvhSms extends \CommonObject
{
public $db;
//!< To store db handler
public $error;
//!< To return error code (or message)
public $errors = array();
//!< To return several error codes (or messages)
public $element = 'ovhsms';
//!< Id that identify managed object
public $id;
public $account;
public $socid;
public $contact_id;
public $member_id;
public $fk_project;
public $nostop;
public $expe;
public $dest;
public $message;
public $validity;
public $class;
public $deferred;
public $priority;
public $soap;
// Old API
public $conn;
// New API
public $endpoint;
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
public function __construct($db)
{
}
/**
* Logout
*
* @return void
*/
public function logout()
{
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps,PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Send SMS
*
* @return int <=0 if error, >0 if OK
*/
public function SmsSend()
{
}
/**
* Show HTML select box to select account
*
* @return void
*/
public function printListAccount()
{
}
/**
* Return list of SMSAccounts
*
* @return array
*/
public function getSmsListAccount()
{
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps,PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Return Credit
*
* @return array
*/
public function CreditLeft()
{
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps,PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Return History
*
* @return array
*/
public function SmsHistory()
{
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps,PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Return list of possible SMS senders
*
* @return array|int <0 if KO, array with list of available senders if OK
*/
public function SmsSenderList()
{
}
/**
* Call soapDebug method to output traces
*
* @return void
*/
public function soapDebug()
{
}
}
}

View file

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
/* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*/
// phpcs:disable PEAR.Commenting,Generic.NamingConventions,PEAR.NamingConventions,Squiz.Scope.MethodScope.Missing
@ -3162,7 +3163,7 @@ namespace Luracast\Restler {
505 => 'HTTP Version Not Supported',
);
/**
* @param string $httpStatusCode http status code
* @param int $httpStatusCode http status code
* @param string|null $errorMessage error message
* @param array $details any extra detail about the exception
* @param Exception $previous previous exception if any

View file

@ -48,6 +48,7 @@ return static function (RectorConfig $rectorConfig): void {
__DIR__ . '/../../../scripts/',
__DIR__ . '/../../../test/phpunit/',
]);
$rectorConfig->skip([
'**/includes/**',
'**/custom/**',
@ -55,6 +56,7 @@ return static function (RectorConfig $rectorConfig): void {
'**/rector/**', // Disable this line to test the "test.php" file.
__DIR__ . '/../../../htdocs/custom/',
__DIR__ . '/../../../htdocs/install/doctemplates/*'
//'test.php',
]);
$rectorConfig->parallel(240);
@ -70,9 +72,9 @@ return static function (RectorConfig $rectorConfig): void {
//$rectorConfig->rule(ReplaceEachAssignmentWithKeyCurrentRector::class);
$rectorConfig->rule(Rector\CodeQuality\Rector\FuncCall\FloatvalToTypeCastRector::class);
$rectorConfig->rule(Rector\CodeQuality\Rector\FuncCall\BoolvalToTypeCastRector::class);
$rectorConfig->rule(Rector\CodeQuality\Rector\NotEqual\CommonNotEqualRector::class);
//Not yet ready: $rectorconfig->rule(Rector\CodeQuality\Rector\If_\CompleteMissingIfElseBracketRector::class);
$rectorConfig->rule(Rector\CodeQuality\Rector\For_\ForRepeatedCountToOwnVariableRector::class);
@ -82,11 +84,16 @@ return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rule(Dolibarr\Rector\Renaming\UserRightsToFunction::class);
//$rectorConfig->rule(Dolibarr\Rector\Renaming\UsePositiveExit::class);
// This fix <> into != but it breaks other rules, so added at end.
$rectorConfig->rule(Rector\CodeQuality\Rector\NotEqual\CommonNotEqualRector::class);
// Add all predefined rules to migrate to up to php 71.
// Warning this break tab spacing of arrays on several lines
/*$rectorConfig->sets([
LevelSetList::UP_TO_PHP_70
]);*/
LevelSetList::UP_TO_PHP_70
]);*/
// Add predefined rules for a given version only
//$rectorConfig->import(SetList::PHP_70);
//$rectorConfig->import(SetList::PHP_71);

View file

@ -64,8 +64,8 @@ class GlobalToFunction extends AbstractRector
[new CodeSample(
'$conf->global->CONSTANT',
'getDolGlobalInt(\'CONSTANT\')'
)]
);
)]
);
}
/**
@ -133,7 +133,7 @@ class GlobalToFunction extends AbstractRector
$node->dim = new FuncCall(
new Name('getDolGlobalString'),
[new Arg($constName)]
);
);
}
return $node;
}
@ -208,7 +208,7 @@ class GlobalToFunction extends AbstractRector
$leftConcat = new FuncCall(
new Name('getDolGlobalString'),
[new Arg($constName)]
);
);
$rightConcat = $node->right;
}
if ($this->isGlobalVar($node->right)) {
@ -219,7 +219,7 @@ class GlobalToFunction extends AbstractRector
$rightConcat = new FuncCall(
new Name('getDolGlobalString'),
[new Arg($constName)]
);
);
$leftConcat = $node->left;
}
if (!isset($leftConcat, $rightConcat)) {
@ -238,6 +238,7 @@ class GlobalToFunction extends AbstractRector
$node = $nodes->getFirstExpr();
}
// Now process all comparison like:
// $conf->global->... Operator Value
@ -264,11 +265,14 @@ class GlobalToFunction extends AbstractRector
$typeofcomparison = 'NotIdentical';
//var_dump($node->left);
}
if (empty($typeofcomparison)) {
return;
}
if (!$this->isGlobalVar($node->left)) {
$isconfglobal = $this->isGlobalVar($node->left);
if (!$isconfglobal) {
// The left side is not conf->global->xxx, so we leave
return;
}
@ -282,7 +286,8 @@ class GlobalToFunction extends AbstractRector
$funcName = 'getDolGlobalString';
break;
default:
return;
$funcName = 'getDolGlobalString';
break;
}
$constName = $this->getConstName($node->left);
@ -295,9 +300,9 @@ class GlobalToFunction extends AbstractRector
new FuncCall(
new Name($funcName),
[new Arg($constName)]
),
),
$node->right
);
);
}
if ($typeofcomparison == 'NotEqual') {
return new NotEqual(
@ -313,36 +318,36 @@ class GlobalToFunction extends AbstractRector
new FuncCall(
new Name($funcName),
[new Arg($constName)]
),
),
$node->right
);
);
}
if ($typeofcomparison == 'GreaterOrEqual') {
return new GreaterOrEqual(
new FuncCall(
new Name($funcName),
[new Arg($constName)]
),
),
$node->right
);
);
}
if ($typeofcomparison == 'Smaller') {
return new Smaller(
new FuncCall(
new Name($funcName),
[new Arg($constName)]
),
),
$node->right
);
);
}
if ($typeofcomparison == 'SmallerOrEqual') {
return new SmallerOrEqual(
new FuncCall(
new Name($funcName),
[new Arg($constName)]
),
),
$node->right
);
);
}
if ($typeofcomparison == 'NotIdentical') {
return new NotIdentical(
@ -382,7 +387,7 @@ class GlobalToFunction extends AbstractRector
}
return \true;
}
);
);
}
/**

View file

@ -143,7 +143,7 @@ BAN
BI
BOMs
Back
Bad value for email, email lwas not verified by Google
Bad value for email, email was not verified by Google
Bad value for returned userinfo[aud]
Bad value for returned userinfo[exp]. Token expired.
Bad value for returned userinfo[iss]
@ -164,7 +164,6 @@ BlockLogNeedElement
BlockedLogAuthorityNeededToStoreYouFingerprintsInNonAlterableRemote
BlockedLogAuthorityUrl
BlockedLogSetup
BookCalArea
BookCalSystem
Bookings
BoxTitleLast
@ -302,8 +301,6 @@ ECMAreaDesc2
ECMDocsByProducts
ECMSectionAutoDesc
ECMSectionManualDesc
EMail
EMails
EcmFiles
EditAdherent
EditAdherentAddress
@ -525,7 +522,6 @@ MemberAllowchangeOfType
MemberTypeCard
MembersListOfTiers
MenuAddedSuccesfuly
Message
MigrationBankTransfertsToUpdate
MigrationContractsEmptyCreationDatesUpdateSuccess
Millisecond
@ -696,7 +692,6 @@ Production
ProfId
Profile
Programs
Progression
ProjectNbProject
ProjectNbTask
Property %s not found in the class. The class was probably not generated by modulebuilder.
@ -808,7 +803,6 @@ ShowRecruitmentCandidature
ShowRecruitmentJobPosition
ShowSearchFields
ShowSkill
ShowSkillRank
ShowSkilldet
ShowStockTransfer
ShowStockTransferLine
@ -821,8 +815,6 @@ SignatureOK
Siren
Situation
SizeUnit
SkillCreated
SkillRank
SmsTestSubstitutionReplacedByGenericValues
SomeShipmentExists
SourceType

View file

@ -103,7 +103,7 @@ if (getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
$accounting = new AccountingAccount($db);
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array
$hookmanager->initHooks(array('accountancyadminaccount'));
@ -230,7 +230,7 @@ $formaccounting = new FormAccounting($db);
$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
llxHeader('', $langs->trans("ListAccounts"), $help_url);
llxHeader('', $langs->trans("ListAccounts"), $help_url, '', 0, 0, '', '', '', 'mod-accountancy page-admin_account');
if ($action == 'delete') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1);

View file

@ -88,7 +88,7 @@ if (!$user->hasRight('accounting', 'chartofaccount')) {
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
$hookmanager->initHooks(array('admin'));
// This page is a generic page to edit dictionaries
@ -340,7 +340,7 @@ $formadmin = new FormAdmin($db);
$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
llxHeader('', $langs->trans("Pcg_version"), $help_url);
llxHeader('', $langs->trans("Pcg_version"), $help_url, '', 0, 0, '', '', '', 'mod-accountancy page-admin_accountmodel');
$titre = $langs->trans($tablib[$id]);
$linkback = '';
@ -492,7 +492,7 @@ if ($resql) {
// There is several pages
if ($num > $listlimit) {
print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">';
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit ? 1 : 0), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
print '</td></tr>';
}
@ -657,7 +657,7 @@ $db->close();
* Show fields in insert/edit mode
*
* @param string[] $fieldlist Array of fields
* @param stdClass $obj If we show a particular record, obj is filled with record fields
* @param ?stdClass $obj If we show a particular record, obj is filled with record fields
* @param string $tabname Name of SQL table
* @param string $context 'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we don't want it to be rendered
* @return void

View file

@ -206,7 +206,7 @@ $title = $langs->trans('AccountAccounting')." - ".$langs->trans('Card');
$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
llxHeader('', $title, $help_url);
llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-accountancy page-admin_card');
// Create mode

View file

@ -3,6 +3,7 @@
* Copyright (C) 2017-2024 Alexandre Spangaro <aspangaro@easya.solutions>
* Copyright (C) 2022 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -117,7 +118,7 @@ $formaccounting = new FormAccounting($db);
$title= $langs->trans('AccountingCategory');
$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
llxHeader('', $title, $help_url);
llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-accountancy page-admin_categories');
$linkback = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/categories_list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$titlepicto = 'setup';
@ -164,7 +165,7 @@ if (!empty($cat_id)) {
}
if (is_array($accountingcategory->lines_cptbk) && count($accountingcategory->lines_cptbk) > 0) {
print img_picto($langs->trans("AccountingAccount"), 'accounting_account', 'class="pictofixedwith"');
print img_picto($langs->trans("AccountingAccount"), 'accounting_account', 'class="pictofixedwidth"');
print $form->multiselectarray('cpt_bk', $arraykeyvalue, GETPOST('cpt_bk', 'array'), 0, 0, '', 0, "80%", '', '', $langs->transnoentitiesnoconv("AddAccountFromBookKeepingWithNoCategories"));
print '<input type="submit" class="button button-add small" id="" class="action-delete" value="'.$langs->trans("Add").'"> ';
}

View file

@ -72,7 +72,7 @@ $pagenext = $page + 1;
$search_country_id = GETPOST('search_country_id', 'int');
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
$hookmanager->initHooks(array('admin'));
// This page is a generic page to edit dictionaries
@ -408,7 +408,7 @@ $formadmin = new FormAdmin($db);
$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
llxHeader('', $langs->trans('DictionaryAccountancyCategory'), $help_url);
llxHeader('', $langs->trans('DictionaryAccountancyCategory'), $help_url, '', 0, 0, '', '', '', 'mod-accountancy page-admin_categories_list');
$titre = $langs->trans($tablib[$id]);
$linkback = '';
@ -617,7 +617,7 @@ if ($resql) {
// There is several pages
if ($num > $listlimit) {
print '<tr class="none"><td class="right" colspan="'.(2 + count($fieldlist)).'">';
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit ? 1 : 0), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
print '</td></tr>';
}
@ -947,7 +947,7 @@ $db->close();
* Show fields in insert/edit mode
*
* @param string[] $fieldlist Array of fields
* @param stdClass $obj If we show a particular record, obj is filled with record fields
* @param ?stdClass $obj If we show a particular record, obj is filled with record fields
* @param string $tabname Name of SQL table
* @param string $context 'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we don't want it to be rendered
* @return void

View file

@ -106,7 +106,7 @@ $title = $langs->trans('Closure');
$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
llxHeader('', $title, $help_url);
llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-accountancy page-admin_closure');
$linkback = '';
print load_fiche_titre($langs->trans('MenuClosureAccounts'), $linkback, 'title_accountancy');
@ -148,16 +148,20 @@ print '</td></tr>';
// Accounting groups used for the balance sheet account
print '<tr class="oddeven">';
print '<td class="fieldrequired">'.$langs->trans("ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT").'</td>';
print '<td class="fieldrequired">';
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 '</td>';
print '<td>';
print '<input type="text" size="100" id="ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT" name="ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT" value="' . dol_escape_htmltag(getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT')). '">';
print '<input type="text" class="quatrevingtpercent" id="ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT" name="ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT" value="' . dol_escape_htmltag(getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT')). '">';
print '</td></tr>';
// Accounting groups used for the income statement
print '<tr class="oddeven">';
print '<td class="fieldrequired">'.$langs->trans("ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT").'</td>';
print '<td class="fieldrequired">';
print $form->textwithpicto($langs->trans("ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT"), $langs->trans("ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENTHelp"));
print '</td>';
print '<td>';
print '<input type="text" size="100" id="ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT" name="ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT" value="' . dol_escape_htmltag(getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT')). '">';
print '<input type="text" class="quatrevingtpercent" id="ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT" name="ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT" value="' . dol_escape_htmltag(getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT')). '">';
print '</td></tr>';
print "</table>\n";

View file

@ -205,7 +205,7 @@ $formaccounting = new FormAccounting($db);
$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
llxHeader('', $langs->trans('MenuDefaultAccounts'), $help_url);
llxHeader('', $langs->trans('MenuDefaultAccounts'), $help_url, '', 0, 0, '', '', '', 'mod-accountancy page-admin_defaultaccounts');
$linkback = '';
print load_fiche_titre($langs->trans('MenuDefaultAccounts'), $linkback, 'title_accountancy');
@ -314,7 +314,7 @@ if (isModEnabled('societe') && getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_D
print '<td>' . img_picto('', 'bill', 'class="pictofixedwidth"') . $langs->trans("UseAuxiliaryAccountOnCustomerDeposit") . '</td>';
if (getDolGlobalInt('ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT')) {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT&value=0">';
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 '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT&value=1">';
@ -341,7 +341,7 @@ if (isModEnabled('societe') && getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER_D
print '<td>' . img_picto('', 'supplier_invoice', 'class="pictofixedwidth"') . $langs->trans("UseAuxiliaryAccountOnSupplierDeposit") . '</td>';
if (getDolGlobalInt('ACCOUNTING_ACCOUNT_SUPPLIER_USE_AUXILIARY_ON_DEPOSIT')) {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setACCOUNTING_ACCOUNT_SUPPLIER_USE_AUXILIARY_ON_DEPOSIT&value=0">';
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 '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setACCOUNTING_ACCOUNT_SUPPLIER_USE_AUXILIARY_ON_DEPOSIT&value=1">';

View file

@ -5,7 +5,7 @@
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2017-2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2017-2018 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -136,7 +136,7 @@ $form = new Form($db);
$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
$title = $langs->trans('ExportOptions');
llxHeader('', $title, $help_url);
llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-accountancy page-admin_export');
$linkback = '';
// $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';

View file

@ -58,7 +58,7 @@ static $tmpstatut2label = array(
'1' => 'CloseFiscalYear'
);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
$object = new Fiscalyear($db);
$hookmanager->initHooks(array('fiscalyearlist'));
@ -89,7 +89,7 @@ $title = $langs->trans('AccountingPeriods');
$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
llxHeader('', $title, $help_url);
llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-accountancy page-admin_fiscalyear');
$sql = "SELECT f.rowid, f.label, f.date_start, f.date_end, f.statut as status, f.entity";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear as f";

View file

@ -51,12 +51,12 @@ if (!empty($backtopagejsfields)) {
$error = 0;
// Initialize technical objects
// Initialize a technical objects
$object = new Fiscalyear($db);
$extrafields = new ExtraFields($db);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'.
// List of status
static $tmpstatus2label = array(

View file

@ -47,7 +47,7 @@ $title = $langs->trans("Fiscalyear")." - ".$langs->trans("Info");
$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
llxHeader('', $title, $help_url);
llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-accountancy page-admin_fiscalyear_info');
if ($id) {
$object = new Fiscalyear($db);

View file

@ -1,13 +1,14 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2024 Alexandre Spangaro <aspangaro@easya.solutions>
* Copyright (C) 2013-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2017 Laurent Destailleur <eldy@destailleur.fr>
* Copyright (C) 2021 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This 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 = array(
$list_binding = array(
'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER',
'ACCOUNTING_DATE_START_BINDING',
'ACCOUNTING_LABEL_OPERATION_ON_TRANSFER'
);
$error = 0;
@ -259,7 +261,7 @@ $form = new Form($db);
$title = $langs->trans('ConfigAccountingExpert');
$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
llxHeader('', $title, $help_url);
llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-accountancy page-admin_index');
$linkback = '';
@ -402,6 +404,13 @@ foreach ($list_binding as $key) {
} 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 '<input type="text" class="maxwidth100" id="'.$key.'" name="'.$key.'" value="'.getDolGlobalString($key).'">';
}
@ -414,7 +423,7 @@ print '<tr class="oddeven">';
print '<td>'.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_SALES").'</td>';
if (getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_SALES')) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonsales&value=0">';
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 '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonsales&value=1">';
@ -427,7 +436,7 @@ print '<tr class="oddeven">';
print '<td>'.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_PURCHASES").'</td>';
if (getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_PURCHASES')) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonpurchases&value=0">';
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 '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonpurchases&value=1">';
@ -440,7 +449,7 @@ print '<tr class="oddeven">';
print '<td>'.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS").'</td>';
if (getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS')) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonexpensereports&value=0">';
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 '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonexpensereports&value=1">';

View file

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2017-2024 Alexandre Spangaro <aspangaro@easya.solutions>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -82,7 +83,7 @@ $error = 0;
$search_country_id = GETPOST('search_country_id', 'int');
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
$hookmanager->initHooks(array('admin'));
// This page is a generic page to edit dictionaries
@ -350,7 +351,7 @@ $formadmin = new FormAdmin($db);
$title = $langs->trans('AccountingJournals');
$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
llxHeader('', $title, $help_url);
llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-accountancy page-admin_journals_list');
$titre = $langs->trans("DictionarySetup");
$linkback = '';
@ -437,7 +438,7 @@ if ($id) {
print '</tr>';
// Line to enter new values
print '<tr class="oddeven nodrag nodrap nohover">';
print '<tr class="oddeven nodrag nodrop nohover">';
$obj = new stdClass();
// If data was already input, we define them in obj to populate input fields.
@ -494,7 +495,7 @@ if ($id) {
// There is several pages
if ($num > $listlimit) {
print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">';
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit ? 1 : 0), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
print '</td></tr>';
}
@ -685,8 +686,8 @@ $db->close();
/**
* Show fields in insert/edit mode
*
* @param string[] $fieldlist Array of fields
* @param Object $obj If we show a particular record, obj is filled with record fields
* @param string[] $fieldlist Array of fields
* @param ?Object $obj If we show a particular record, obj is filled with record fields
* @param string $tabname Name of SQL table
* @param string $context 'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we don't want it to be rendered
* @return void

View file

@ -274,6 +274,7 @@ if ($action == 'update' && $permissiontobind) {
*/
$form = new FormAccounting($db);
'@phan-var-force string[] $toselect'; // For some reason typing is lost at this point
// Default AccountingAccount RowId Product / Service
// at this time ACCOUNTING_SERVICE_SOLD_ACCOUNT & ACCOUNTING_PRODUCT_SOLD_ACCOUNT are account number not accountingacount rowid
@ -517,7 +518,7 @@ if ($resql) {
$massactionbutton = '';
$nbselected = is_array($toselect) ? count($toselect) : 0;
$nbselected = count($toselect);
if ($massaction == 'set_default_account') {
if ($nbselected <= 0) {
$langs->load("errors");
@ -726,10 +727,8 @@ if ($resql) {
}
$selected = 0;
if (!empty($toselect)) {
if (in_array($product_static->id, $toselect)) {
$selected = 1;
}
if (in_array($product_static->id, $toselect)) {
$selected = 1;
}
print '<tr class="oddeven">';

View file

@ -129,7 +129,7 @@ $form = new Form($db);
$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
$title = $langs->trans('ChartOfIndividualAccountsOfSubsidiaryLedger');
llxHeader('', $title, $help_url);
llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-accountancy page-admin_subaccount');
// Customer

View file

@ -83,7 +83,7 @@ if ($sortfield == "") {
$sortfield = "t.numero_compte";
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
$object = new BookKeeping($db);
$hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array
@ -103,7 +103,7 @@ if (empty($search_date_start) && !GETPOSTISSET('formfilteraction')) {
$search_date_end = strtotime($fiscalYear->date_end);
} else {
$month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
$year_start = dol_print_date(dol_now(), '%Y');
$year_start = (int) dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) {
$year_start--; // If current month is lower that starting fiscal month, we start last year
}
@ -128,6 +128,7 @@ if (!$user->hasRight('accounting', 'mouvements', 'lire')) {
accessforbidden();
}
/*
* Action
*/
@ -169,10 +170,6 @@ if (empty($reshook)) {
$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 (empty($reshook)) {
}
}
if ($action == 'export_csv') {
if ($action == 'export_csv' && $user->hasRight('accounting', 'mouvements', 'lire')) {
$sep = getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV');
$filename = 'balance';

View file

@ -186,6 +186,12 @@ if (empty($reshook)) {
}
if (!$error) {
if (GETPOSTINT('doc_datemonth') && GETPOSTINT('doc_dateday') && GETPOSTINT('doc_dateyear')) {
$datedoc = dol_mktime(0, 0, 0, GETPOSTINT('doc_datemonth'), GETPOSTINT('doc_dateday'), GETPOSTINT('doc_dateyear'));
} else {
$datedoc = (int) GETPOSTINT('doc_date'); // TODO Use instead the mode day-month-year
}
$object = new BookKeeping($db);
$object->numero_compte = $accountingaccount_number;
@ -195,7 +201,7 @@ if (empty($reshook)) {
$object->label_operation = $label_operation;
$object->debit = $debit;
$object->credit = $credit;
$object->doc_date = (string) GETPOST('doc_date', 'alpha');
$object->doc_date = $datedoc;
$object->doc_type = (string) GETPOST('doc_type', 'alpha');
$object->piece_num = $piece_num;
$object->doc_ref = (string) GETPOST('doc_ref', 'alpha');
@ -265,10 +271,12 @@ if (empty($reshook)) {
}
if (!$error) {
$date_start = dol_mktime(0, 0, 0, GETPOSTINT('doc_datemonth'), GETPOSTINT('doc_dateday'), GETPOSTINT('doc_dateyear'));
$object->label_compte = '';
$object->debit = 0;
$object->credit = 0;
$object->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOSTINT('doc_datemonth'), GETPOSTINT('doc_dateday'), GETPOSTINT('doc_dateyear'));
$object->doc_date = $date_start;
$object->doc_type = GETPOST('doc_type', 'alpha');
$object->piece_num = GETPOSTINT('next_num_mvt');
$object->doc_ref = GETPOST('doc_ref', 'alpha');
@ -591,7 +599,7 @@ if ($action == 'create') {
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setdate">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
print $form->selectDate($object->doc_date ? $object->doc_date : - 1, 'doc_date', 0, 0, 0, "setdate");
print $form->selectDate($object->doc_date ? $object->doc_date : -1, 'doc_date', 0, 0, 0, "setdate");
print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">';
print '</form>';
} else {
@ -622,7 +630,7 @@ if ($action == 'create') {
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setjournal">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
print $formaccounting->select_journal($object->code_journal, 'code_journal', 0, 0, array(), 1, 1);
print $formaccounting->select_journal($object->code_journal, 'code_journal', 0, 0, 0, 1, 1);
print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">';
print '</form>';
} else {
@ -657,6 +665,16 @@ if ($action == 'create') {
print '</td>';
print '</tr>';
// Due date (if invoice)
//if (in_array($object->doc_type, array('customer_invoice', 'supplier_invoice'))) {
print '<tr>';
print '<td class="titlefield">' . $form->textwithpicto($langs->trans('DateDue'), $langs->trans("IfTransactionHasDueDate")) . '</td>';
print '<td>';
print $object->date_lim_reglement ? dol_print_date($object->date_lim_reglement, 'day') : '&nbsp;';
print '</td>';
print '</tr>';
//}
// Don't show in tmp mode, inevitably empty
if ($mode != "_tmp") {
// Date document export
@ -878,7 +896,7 @@ if ($action == 'create') {
} else {
print '<tr class="oddeven" data-lineid="'.((int) $line->id).'">';
print '<!-- td columns in display mode -->';
$resultfetch = $accountingaccount->fetch(null, $line->numero_compte, true);
$resultfetch = $accountingaccount->fetch(0, $line->numero_compte, true);
print '<td>';
if ($resultfetch > 0) {
print $accountingaccount->getNomUrl(0, 1, 1, '', 0);

View file

@ -4,7 +4,7 @@
* Copyright (C) 2013-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2022 Lionel Vessiller <lvessiller@open-dsi.fr>
* Copyright (C) 2016-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2022 Progiseize <a.bisotti@progiseize.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
@ -153,7 +153,7 @@ if ($sortfield == "") {
$sortfield = "t.piece_num,t.rowid";
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
$object = new BookKeeping($db);
$hookmanager->initHooks(array('bookkeepingexport'));
@ -172,7 +172,7 @@ if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GE
$search_date_end = strtotime($fiscalYear->date_end);
} else {
$month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
$year_start = dol_print_date(dol_now(), '%Y');
$year_start = (int) dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) {
$year_start--; // If current month is lower that starting fiscal month, we start last year
}
@ -912,7 +912,7 @@ print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield,
// Not display message when all the list of docs are included
if (!getDolGlobalString('ACCOUNTING_REEXPORT')) {
print info_admin($langs->trans("WarningDataDisappearsWhenDataIsExported"), 0, 0, 0, 'hideonsmartphone info');
print info_admin($langs->trans("WarningDataDisappearsWhenDataIsExported"), 0, 0, '0', 'hideonsmartphone info');
}
//$topicmail = "Information";
@ -1243,7 +1243,7 @@ while ($i < min($num, $limit)) {
// Journal code
if (!empty($arrayfields['t.code_journal']['checked'])) {
$accountingjournal = new AccountingJournal($db);
$result = $accountingjournal->fetch('', $line->code_journal);
$result = $accountingjournal->fetch(0, $line->code_journal);
$journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal);
print '<td class="center tdoverflowmax150">'.$journaltoshow.'</td>';
if (!$i) {

View file

@ -4,7 +4,7 @@
* Copyright (C) 2013-2024 Alexandre Spangaro <alexandre@inoveasya.solutions>
* Copyright (C) 2022 Lionel Vessiller <lvessiller@open-dsi.fr>
* Copyright (C) 2016-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018-2021 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2022 Progiseize <a.bisotti@progiseiea-conseil.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
@ -98,6 +98,16 @@ $search_date_validation_endmonth = GETPOSTINT('search_date_validation_endmonth'
$search_date_validation_endday = GETPOSTINT('search_date_validation_endday');
$search_date_validation_start = dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear);
$search_date_validation_end = dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear);
// Due date start
$search_date_due_start_day = GETPOSTINT('search_date_due_start_day');
$search_date_due_start_month = GETPOSTINT('search_date_due_start_month');
$search_date_due_start_year = GETPOSTINT('search_date_due_start_year');
$search_date_due_start = dol_mktime(0, 0, 0, $search_date_due_start_month, $search_date_due_start_day, $search_date_due_start_year);
// Due date end
$search_date_due_end_day = GETPOSTINT('search_date_due_end_day');
$search_date_due_end_month = GETPOSTINT('search_date_due_end_month');
$search_date_due_end_year = GETPOSTINT('search_date_due_end_year');
$search_date_due_end = dol_mktime(23, 59, 59, $search_date_due_end_month, $search_date_due_end_day, $search_date_due_end_year);
$search_import_key = GETPOST("search_import_key", 'alpha');
$search_account_category = GETPOSTINT('search_account_category');
@ -148,7 +158,7 @@ if ($sortfield == "") {
$sortfield = "t.piece_num,t.rowid";
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
$object = new BookKeeping($db);
$hookmanager->initHooks(array('bookkeepinglist'));
@ -167,7 +177,7 @@ if (!in_array($action, array('delmouv', 'delmouvconfirm')) && !GETPOSTISSET('beg
$search_date_end = strtotime($fiscalYear->date_end);
} else {
$month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
$year_start = dol_print_date(dol_now(), '%Y');
$year_start = (int) dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) {
$year_start--; // If current month is lower that starting fiscal month, we start last year
}
@ -199,6 +209,7 @@ $arrayfields = array(
't.tms' => array('label' => $langs->trans("DateModification"), 'checked' => 0),
't.date_export' => array('label' => $langs->trans("DateExport"), 'checked' => 0),
't.date_validated' => array('label' => $langs->trans("DateValidationAndLock"), 'checked' => 0, 'enabled' => !getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")),
't.date_lim_reglement' => array('label' => $langs->trans("DateDue"), 'checked' => 0),
't.import_key' => array('label' => $langs->trans("ImportId"), 'checked' => 0, 'position' => 1100),
);
@ -299,6 +310,16 @@ if (empty($reshook)) {
$search_date_validation_endday = '';
$search_date_validation_start = '';
$search_date_validation_end = '';
// Due date start
$search_date_due_start_day = '';
$search_date_due_start_month = '';
$search_date_due_start_year = '';
$search_date_due_start = '';
// Due date end
$search_date_due_end_day = '';
$search_date_due_end_month = '';
$search_date_due_end_year = '';
$search_date_due_end = '';
$search_debit = '';
$search_credit = '';
$search_lettering_code = '';
@ -428,6 +449,16 @@ if (empty($reshook)) {
$tmp = dol_getdate($search_date_validation_end);
$param .= '&search_date_validation_endmonth='.((int) $tmp['mon']).'&search_date_validation_endday='.((int) $tmp['mday']).'&search_date_validation_endyear='.((int) $tmp['year']);
}
// Due date start
if (!empty($search_date_due_start)) {
$filter['t.date_lim_reglement>='] = $search_date_due_start;
$param .= '&search_date_due_start_day='.$search_date_due_start_day.'&search_date_due_start_month='.$search_date_due_start_month.'&search_date_due_start_year='.$search_date_due_start_year;
}
// Due date end
if (!empty($search_date_due_end)) {
$filter['t.date_lim_reglement<='] = $search_date_due_end;
$param .= '&search_date_due_end_day='.$search_date_due_end_day.'&search_date_due_end_month='.$search_date_due_end_month.'&search_date_due_end_year='.$search_date_due_end_year;
}
if (!empty($search_debit)) {
$filter['t.debit'] = $search_debit;
$param .= '&search_debit='.urlencode($search_debit);
@ -572,7 +603,7 @@ if (empty($reshook)) {
} elseif ($action == 'unletteringmanual' && $confirm == "yes" && $permissiontoadd) {
$lettering = new Lettering($db);
$nb_lettering = $lettering->deleteLettering($toselect);
if ($result < 0) {
if ($nb_lettering < 0) {
setEventMessages('', $lettering->errors, 'errors');
} else {
setEventMessages($langs->trans('AccountancyOneUnletteringModifiedSuccessfully'), array(), 'mesgs');
@ -614,6 +645,7 @@ $sql .= " t.date_creation,";
$sql .= " t.tms as date_modification,";
$sql .= " t.date_export,";
$sql .= " t.date_validated as date_validation,";
$sql .= " t.date_lim_reglement,";
$sql .= " t.import_key";
$sqlfields = $sql; // $sql fields to remove for count total
@ -663,6 +695,10 @@ if (count($filter) > 0) {
$sqlwhere[] = "t.date_validated >= '".$db->idate($value)."'";
} elseif ($key == 't.date_validated<=') {
$sqlwhere[] = "t.date_validated <= '".$db->idate($value)."'";
} elseif ($key == 't.date_lim_reglement>=') {
$sqlwhere[] = "t.date_lim_reglement >= '".$db->idate($value)."'";
} elseif ($key == 't.date_lim_reglement<=') {
$sqlwhere[] = "t.date_lim_reglement <= '".$db->idate($value)."'";
} elseif ($key == 't.credit' || $key == 't.debit') {
$sqlwhere[] = natural_search($key, $value, 1, 1);
} elseif ($key == 't.reconciled_option') {
@ -988,6 +1024,17 @@ if (!empty($arrayfields['t.date_validated']['checked'])) {
print '</div>';
print '</td>';
}
// Due date start and end
if (!empty($arrayfields['t.date_lim_reglement']['checked'])) {
print '<td class="liste_titre center">';
print '<div class="nowrapfordate">';
print $form->selectDate($search_date_due_start, 'search_date_due_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
print '</div>';
print '<div class="nowrapfordate">';
print $form->selectDate($search_date_due_end, 'search_date_due_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
print '</div>';
print '</td>';
}
if (!empty($arrayfields['t.import_key']['checked'])) {
print '<td class="liste_titre center">';
print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
@ -1052,6 +1099,10 @@ if (!empty($arrayfields['t.date_export']['checked'])) {
if (!empty($arrayfields['t.date_validated']['checked'])) {
print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated,t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
}
// Due date
if (!empty($arrayfields['t.date_lim_reglement']['checked'])) {
print_liste_field_titre($arrayfields['t.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], 't.date_lim_reglement', '', $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['t.import_key']['checked'])) {
print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER["PHP_SELF"], "t.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
}
@ -1105,6 +1156,8 @@ while ($i < min($num, $limit)) {
$line->date_modification = $db->jdate($obj->date_modification);
$line->date_export = $db->jdate($obj->date_export);
$line->date_validation = $db->jdate($obj->date_validation);
// Due date
$line->date_lim_reglement = $db->jdate($obj->date_lim_reglement);
print '<tr class="oddeven">';
// Action column
@ -1161,9 +1214,11 @@ while ($i < min($num, $limit)) {
}
// Document ref
$modulepart = '';
$modulepart = ''; // may be used by include*.tpl.php
if (!empty($arrayfields['t.doc_ref']['checked'])) {
if ($line->doc_type == 'customer_invoice') {
$objectstatic = null;
if ($line->doc_type === 'customer_invoice') {
$langs->loadLangs(array('bills'));
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
@ -1175,7 +1230,7 @@ while ($i < min($num, $limit)) {
$filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
} elseif ($line->doc_type == 'supplier_invoice') {
} elseif ($line->doc_type === 'supplier_invoice') {
$langs->loadLangs(array('bills'));
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
@ -1196,7 +1251,7 @@ while ($i < min($num, $limit)) {
} else {
$documentlink = $line->doc_ref;
}
} elseif ($line->doc_type == 'expense_report') {
} elseif ($line->doc_type === 'expense_report') {
$langs->loadLangs(array('trips'));
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
@ -1208,7 +1263,7 @@ while ($i < min($num, $limit)) {
$filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
} elseif ($line->doc_type == 'bank') {
} elseif ($line->doc_type === 'bank') {
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$objectstatic = new AccountLine($db);
$objectstatic->fetch($line->fk_doc);
@ -1219,11 +1274,11 @@ while ($i < min($num, $limit)) {
$labeltoshow = '';
$labeltoshowalt = '';
$classforlabel = '';
if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') {
if (($line->doc_type === 'customer_invoice' || $line->doc_type === 'supplier_invoice' || $line->doc_type === 'expense_report') && is_object($objectstatic)) {
$labeltoshow .= $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
$labeltoshow .= $documentlink;
$labeltoshowalt .= $objectstatic->ref;
} elseif ($line->doc_type == 'bank') {
} elseif ($line->doc_type === 'bank' && is_object($objectstatic)) {
$labeltoshow .= $objectstatic->getNomUrl(1);
$labeltoshowalt .= $objectstatic->ref;
$bank_ref = strstr($line->doc_ref, '-');
@ -1336,6 +1391,14 @@ while ($i < min($num, $limit)) {
}
}
// Due date
if (!empty($arrayfields['t.date_lim_reglement']['checked'])) {
print '<td class="center">'.dol_print_date($line->date_lim_reglement, 'day').'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
if (!empty($arrayfields['t.import_key']['checked'])) {
print '<td class="tdoverflowmax125" title="'.dol_escape_htmltag($obj->import_key).'">'.dol_escape_htmltag($obj->import_key)."</td>\n";
if (!$i) {

View file

@ -78,6 +78,16 @@ $search_date_validation_endmonth = GETPOSTINT('search_date_validation_endmonth')
$search_date_validation_endday = GETPOSTINT('search_date_validation_endday');
$search_date_validation_start = dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear);
$search_date_validation_end = dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear);
// Due date start
$search_date_due_start_day = GETPOSTINT('search_date_due_start_day');
$search_date_due_start_month = GETPOSTINT('search_date_due_start_month');
$search_date_due_start_year = GETPOSTINT('search_date_due_start_year');
$search_date_due_start = dol_mktime(0, 0, 0, $search_date_due_start_month, $search_date_due_start_day, $search_date_due_start_year);
// Due date end
$search_date_due_end_day = GETPOSTINT('search_date_due_end_day');
$search_date_due_end_month = GETPOSTINT('search_date_due_end_month');
$search_date_due_end_year = GETPOSTINT('search_date_due_end_year');
$search_date_due_end = dol_mktime(23, 59, 59, $search_date_due_end_month, $search_date_due_end_day, $search_date_due_end_year);
$search_import_key = GETPOST("search_import_key", 'alpha');
$search_account_category = GETPOSTINT('search_account_category');
@ -123,7 +133,7 @@ if ($sortfield == "") {
$sortfield = "t.doc_date,t.rowid";
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
$object = new BookKeeping($db);
$formfile = new FormFile($db);
$hookmanager->initHooks(array($context_default));
@ -143,7 +153,7 @@ if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('searc
$search_date_end = strtotime($fiscalYear->date_end);
} else {
$month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
$year_start = dol_print_date(dol_now(), '%Y');
$year_start = (int) dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) {
$year_start--; // If current month is lower that starting fiscal month, we start last year
}
@ -171,6 +181,7 @@ $arrayfields = array(
't.balance' => array('label' => $langs->trans("Balance"), 'checked' => 1),
't.date_export' => array('label' => $langs->trans("DateExport"), 'checked' => -1),
't.date_validated' => array('label' => $langs->trans("DateValidation"), 'checked' => -1, 'enabled' => !getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")),
't.date_lim_reglement' => array('label' => $langs->trans("DateDue"), 'checked' => 0),
't.import_key' => array('label' => $langs->trans("ImportId"), 'checked' => -1, 'position' => 1100),
);
@ -202,6 +213,8 @@ if (!$user->hasRight('accounting', 'mouvements', 'lire')) {
}
$error = 0;
$result = -1; // For static analysis
$documentlink = ''; // For static analysis
$permissiontoadd = $user->hasRight('accounting', 'mouvements', 'creer');
@ -210,7 +223,9 @@ $permissiontoadd = $user->hasRight('accounting', 'mouvements', 'creer');
* Action
*/
$filter = array();
$param = '';
$url_param = '';
if (GETPOST('cancel', 'alpha')) {
$action = 'list';
@ -264,6 +279,16 @@ if (empty($reshook)) {
$search_date_validation_endyear = '';
$search_date_validation_endmonth = '';
$search_date_validation_endday = '';
// Due date start
$search_date_due_start_day = '';
$search_date_due_start_month = '';
$search_date_due_start_year = '';
$search_date_due_start = '';
// Due date end
$search_date_due_end_day = '';
$search_date_due_end_month = '';
$search_date_due_end_year = '';
$search_date_due_end = '';
$search_lettering_code = '';
$search_debit = '';
$search_credit = '';
@ -272,9 +297,6 @@ if (empty($reshook)) {
$toselect = array();
}
// Must be after the remove filter action, before the export.
$filter = array();
if (!empty($search_date_start)) {
$filter['t.doc_date>='] = $search_date_start;
$param .= '&search_date_startmonth='.$search_date_startmonth.'&search_date_startday='.$search_date_startday.'&search_date_startyear='.$search_date_startyear;
@ -375,6 +397,16 @@ if (empty($reshook)) {
$filter['t.date_validated<='] = $search_date_validation_end;
$param .= '&search_date_validation_endmonth='.$search_date_validation_endmonth.'&search_date_validation_endday='.$search_date_validation_endday.'&search_date_validation_endyear='.$search_date_validation_endyear;
}
// Due date start
if (!empty($search_date_due_start)) {
$filter['t.date_lim_reglement>='] = $search_date_due_start;
$param .= '&search_date_due_start_day='.$search_date_due_start_day.'&search_date_due_start_month='.$search_date_due_start_month.'&search_date_due_start_year='.$search_date_due_start_year;
}
// Due date end
if (!empty($search_date_due_end)) {
$filter['t.date_lim_reglement<='] = $search_date_due_end;
$param .= '&search_date_due_end_day='.$search_date_due_end_day.'&search_date_due_end_month='.$search_date_due_end_month.'&search_date_due_end_year='.$search_date_due_end_year;
}
if (!empty($search_import_key)) {
$filter['t.import_key'] = $search_import_key;
$param .= '&search_import_key='.urlencode($search_import_key);
@ -506,7 +538,17 @@ if (empty($reshook)) {
if ($result < 0) {
setEventMessages('', $lettering->errors, 'errors');
} else {
setEventMessages($langs->trans('AccountancyOneLetteringModifiedSuccessfully'), array(), 'mesgs');
setEventMessages($langs->trans($result == 0 ? 'AccountancyNoLetteringModified' : 'AccountancyOneLetteringModifiedSuccessfully'), array(), 'mesgs');
header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
exit();
}
} elseif ($type == 'sub' && $massaction == 'letteringpartial') {
$lettering = new Lettering($db);
$result = $lettering->updateLettering($toselect, false, true);
if ($result < 0) {
setEventMessages('', $lettering->errors, 'errors');
} else {
setEventMessages($langs->trans($result == 0 ? 'AccountancyNoLetteringModified' : 'AccountancyOneLetteringModifiedSuccessfully'), array(), 'mesgs');
header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
exit();
}
@ -537,7 +579,7 @@ if (empty($reshook)) {
if ($result < 0) {
setEventMessages('', $lettering->errors, 'errors');
} else {
setEventMessages($langs->trans('AccountancyOneUnletteringModifiedSuccessfully'), array(), 'mesgs');
setEventMessages($langs->trans($result == 0 ? 'AccountancyNoUnletteringModified' : 'AccountancyOneUnletteringModifiedSuccessfully'), array(), 'mesgs');
header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
exit();
}
@ -581,12 +623,15 @@ if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
}
}
$num = 0;
if (!$error) {
if ($type == 'sub') {
$result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 1);
} else {
$result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 0);
}
//$num = count($object->lines);
$num = $result; // $result is total nb of lines, or limit + 1, but $object->lines is always limited to $limit
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
@ -595,8 +640,6 @@ if (!$error) {
$arrayofselected = is_array($toselect) ? $toselect : array();
$num = count($object->lines);
///if ($action == 'delbookkeepingyear') {
// $form_question = array();
@ -648,6 +691,9 @@ if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->hasRight('accountin
$arrayofmassactions['letteringauto'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('LetteringAuto');
$arrayofmassactions['preunletteringauto'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('UnletteringAuto');
$arrayofmassactions['letteringmanual'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('LetteringManual');
if ($type == 'sub') {
$arrayofmassactions['letteringpartial'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('LetteringPartial');
}
$arrayofmassactions['preunletteringmanual'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('UnletteringManual');
}
if ($user->hasRight('accounting', 'mouvements', 'supprimer')) {
@ -698,7 +744,7 @@ if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.((int) $limit);
}
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
if ($massaction == 'preunletteringauto') {
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassUnletteringAuto"), $langs->trans("ConfirmMassUnletteringQuestion", count($toselect)), "unletteringauto", null, '', 0, 200, 500, 1);
@ -893,6 +939,17 @@ if (!empty($arrayfields['t.date_validated']['checked'])) {
print '</div>';
print '</td>';
}
// Due date start and end
if (!empty($arrayfields['t.date_lim_reglement']['checked'])) {
print '<td class="liste_titre center">';
print '<div class="nowrapfordate">';
print $form->selectDate($search_date_due_start, 'search_date_due_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
print '</div>';
print '<div class="nowrapfordate">';
print $form->selectDate($search_date_due_end, 'search_date_due_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
print '</div>';
print '</td>';
}
if (!empty($arrayfields['t.import_key']['checked'])) {
print '<td class="liste_titre center">';
print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
@ -950,6 +1007,10 @@ if (!empty($arrayfields['t.date_export']['checked'])) {
if (!empty($arrayfields['t.date_validated']['checked'])) {
print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated", "", $param, '', $sortfield, $sortorder, 'center ');
}
// Due date
if (!empty($arrayfields['t.date_lim_reglement']['checked'])) {
print_liste_field_titre($arrayfields['t.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], 't.date_lim_reglement', '', $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['t.import_key']['checked'])) {
print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER["PHP_SELF"], "t.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
}
@ -964,6 +1025,10 @@ print "</tr>\n";
$displayed_account_number = null; // Start with undefined to be able to distinguish with empty
$objectstatic = null; // Init for static analysis
$objectlink = ''; // Init for static analysis
$result = -1; // Init for static analysis
// Loop on record
// --------------------------------------------------------------------
$i = 0;
@ -975,7 +1040,12 @@ $sous_total_credit = 0;
$totalarray['val'] = array();
$totalarray['val']['totaldebit'] = 0;
$totalarray['val']['totalcredit'] = 0;
$totalarray['val']['totalbalance']=0;
$totalarray['val']['totalbalance'] = 0;
// Init for static analysis
$colspan = 0; // colspan before field 'label of operation'
$colspanend = 0; // colspan after debit/credit
$accountg = '-';
while ($i < min($num, $limit)) {
$line = $object->lines[$i];
@ -1020,6 +1090,10 @@ while ($i < min($num, $limit)) {
if (!empty($arrayfields['t.date_validated']['checked'])) {
$colspanend++;
}
// Due date
if (!empty($arrayfields['t.date_lim_reglement']['checked'])) {
$colspanend++;
}
if (!empty($arrayfields['t.lettering_code']['checked'])) {
$colspanend++;
}
@ -1222,7 +1296,7 @@ while ($i < min($num, $limit)) {
// Label operation
if (!empty($arrayfields['t.label_operation']['checked'])) {
// Affiche un lien vers la facture client/fournisseur
// Show a link to the customer/supplier invoice
$doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref);
if (strlen(length_accounta($line->subledger_account)) == 0) {
print '<td class="small tdoverflowmax350 classfortooltip" title="'.dol_escape_htmltag($line->label_operation).'">'.dol_escape_htmltag($line->label_operation).'</td>';
@ -1294,6 +1368,14 @@ while ($i < min($num, $limit)) {
}
}
// Due date
if (!empty($arrayfields['t.date_lim_reglement']['checked'])) {
print '<td class="center">'.dol_print_date($line->date_lim_reglement, 'day').'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
if (!empty($arrayfields['t.import_key']['checked'])) {
print '<td class="tdoverflowmax125" title="'.dol_escape_htmltag($line->import_key).'">'.dol_escape_htmltag($line->import_key)."</td>\n";
if (!$i) {

View file

@ -1,7 +1,8 @@
<?php
/* Copyright (C) 2016 Jamal Elbaz <jamelbaz@gmail.pro>
* Copyright (C) 2016-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018-2023 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -113,12 +114,12 @@ class AccountancyCategory // extends CommonObject
public $active;
/**
* @var array Lines cptbk
* @var Object[] Lines cptbk
*/
public $lines_cptbk;
/**
* @var array Lines display
* @var Object[] Lines display
*/
public $lines_display;
@ -133,7 +134,7 @@ class AccountancyCategory // extends CommonObject
public $sdcpermonth;
/**
* @var array Sum debit credit per account
* @var array<string,float> Sum debit credit per account
*/
public $sdcperaccount;
@ -193,7 +194,7 @@ class AccountancyCategory // extends CommonObject
// Put here code to add control on parameters values
// Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."c_accounting_category(";
$sql = "INSERT INTO ".$this->db->prefix().$this->table_element." (";
if ($this->rowid > 0) {
$sql .= "rowid, ";
}
@ -268,7 +269,7 @@ class AccountancyCategory // extends CommonObject
$sql .= " t.position,";
$sql .= " t.fk_country,";
$sql .= " t.active";
$sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as t";
$sql .= " FROM ".$this->db->prefix().$this->table_element." as t";
if ($id) {
$sql .= " WHERE t.rowid = ".((int) $id);
} else {
@ -353,7 +354,7 @@ class AccountancyCategory // extends CommonObject
// Put here code to add control on parameters values
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."c_accounting_category SET";
$sql = "UPDATE ".$this->db->prefix().$this->table_element." SET";
$sql .= " code=".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").",";
$sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").",";
$sql .= " range_account=".(isset($this->range_account) ? "'".$this->db->escape($this->range_account)."'" : "null").",";
@ -401,7 +402,7 @@ class AccountancyCategory // extends CommonObject
global $conf, $langs;
$error = 0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."c_accounting_category";
$sql = "DELETE FROM ".$this->db->prefix().$this->table_element;
$sql .= " WHERE rowid=".((int) $this->id);
$this->db->begin();
@ -438,7 +439,7 @@ class AccountancyCategory // extends CommonObject
{
global $conf;
$sql = "SELECT t.rowid, t.account_number, t.label";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t";
$sql .= " FROM ".$this->db->prefix().$this->table_element." as t";
$sql .= " WHERE t.fk_accounting_category = ".((int) $id);
$sql .= " AND t.entity = ".$conf->entity;
@ -474,8 +475,8 @@ class AccountancyCategory // extends CommonObject
global $conf;
$sql = "SELECT aa.account_number as numero_compte, aa.label as label_compte";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " FROM ".$this->db->prefix()."accounting_account as aa";
$sql .= " INNER JOIN ".$this->db->prefix()."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " WHERE (aa.fk_accounting_category <> ".((int) $id)." OR aa.fk_accounting_category IS NULL)";
$sql .= " AND asy.rowid = ".((int) getDolGlobalInt('CHARTOFACCOUNTS'));
$sql .= " AND aa.active = 1";
@ -508,8 +509,8 @@ class AccountancyCategory // extends CommonObject
/**
* Function to add an accounting account in an accounting category
*
* @param int $id_cat Id category
* @param array $cpts list of accounts array
* @param int $id_cat Id category
* @param array<string,?string> $cpts list of accounts array
*
* @return int Return integer <0 if KO, >0 if OK
*/
@ -521,8 +522,8 @@ class AccountancyCategory // extends CommonObject
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
$sql = "SELECT aa.rowid, aa.account_number";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " FROM ".$this->db->prefix()."accounting_account as aa";
$sql .= " INNER JOIN ".$this->db->prefix()."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND asy.rowid = ".((int) getDolGlobalInt('CHARTOFACCOUNTS'));
$sql .= " AND aa.active = 1";
$sql .= " AND aa.entity = ".$conf->entity;
@ -549,7 +550,7 @@ class AccountancyCategory // extends CommonObject
if (array_key_exists($account_number_formated, $cpts)) {
$accountincptsadded[$account_number_formated] = 1;
// We found an account number that is in list $cpts of account to add
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account";
$sql = "UPDATE ".$this->db->prefix()."accounting_account";
$sql .= " SET fk_accounting_category=".((int) $id_cat);
$sql .= " WHERE rowid=".((int) $obj->rowid);
dol_syslog(__METHOD__, LOG_DEBUG);
@ -588,7 +589,7 @@ class AccountancyCategory // extends CommonObject
{
$error = 0;
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account as aa";
$sql = "UPDATE ".$this->db->prefix()."accounting_account as aa";
$sql .= " SET fk_accounting_category= 0";
$sql .= " WHERE aa.rowid = ".((int) $cpt_id);
$this->db->begin();
@ -619,11 +620,11 @@ class AccountancyCategory // extends CommonObject
/**
* Function to show result of an accounting account from the ledger with a direction and a period
*
* @param int|array $cpt Accounting account or array of accounting account
* @param int|array<?string> $cpt Accounting account or array of accounting account
* @param string $date_start Date start
* @param string $date_end Date end
* @param int $sens Sens of the account: 0: credit - debit (use this by default), 1: debit - credit
* @param string $thirdparty_code Thirdparty code
* @param int<0,1> $sens Sens of the account: 0: credit - debit (use this by default), 1: debit - credit
* @param string $thirdparty_code Third party code
* @param int $month Specific month - Can be empty
* @param int $year Specific year - Can be empty
* @return integer Return integer <0 if KO, >= 0 if OK
@ -635,8 +636,9 @@ class AccountancyCategory // extends CommonObject
$this->sdc = 0;
$this->sdcpermonth = array();
$listofaccount = '';
if (is_array($cpt)) {
$listofaccount = '';
foreach ($cpt as $cptcursor) {
if (! is_null($cptcursor)) {
if ($listofaccount) {
@ -655,7 +657,7 @@ class AccountancyCategory // extends CommonObject
if (is_array($cpt)) {
$sql .= ", t.numero_compte as accountancy_account";
}
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t";
$sql .= " FROM ".$this->db->prefix()."accounting_bookkeeping as t";
//if (in_array($this->db->type, array('mysql', 'mysqli'))) $sql.=' USE INDEX idx_accounting_bookkeeping_doc_date';
$sql .= " WHERE t.entity = ".((int) $conf->entity);
if (is_array($cpt)) {
@ -710,7 +712,7 @@ class AccountancyCategory // extends CommonObject
* Function to get an array of all active custom groups (llx_c_accunting_categories) with their accounts from the chart of account (ll_accounting_acount)
*
* @param int $catid Custom group ID
* @return array|integer Result in table (array), -1 if KO
* @return array<string,array<int,array{id:int,code:string,label:string,position:string,category_type:string,formula:string,sens:string,account_number:string,account_label:string}>>|int<-1,-1> Result in table (array), -1 if KO
* @see getCats(), getCptsCat()
*/
public function getCatsCpts($catid = 0)
@ -725,9 +727,9 @@ class AccountancyCategory // extends CommonObject
$sql = "SELECT t.rowid, t.account_number, t.label as account_label,";
$sql .= " cat.code, cat.position, cat.label as name_cat, cat.sens, cat.category_type, cat.formula";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t, ".MAIN_DB_PREFIX."c_accounting_category as cat";
$sql .= " FROM ".$this->db->prefix()."accounting_account as t, ".$this->db->prefix()."c_accounting_category as cat";
$sql .= " WHERE t.fk_accounting_category IN (SELECT c.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c";
$sql .= " FROM ".$this->db->prefix().$this->table_element." as c";
$sql .= " WHERE c.active = 1";
$sql .= " AND c.entity = ".$conf->entity;
$sql .= " AND (c.fk_country = ".((int) $mysoc->country_id)." OR c.fk_country = 0)";
@ -773,7 +775,7 @@ class AccountancyCategory // extends CommonObject
*
* @param int $categorytype -1=All, 0=Only non computed groups, 1=Only computed groups
* @param int $active 1= active, 0=not active
* @return array<array{code:string,label:string,formula:string,position:string,category_type:string,sens:string,bc:string}>|int Array of groups or -1 if error
* @return array<array{rowid:string,code:string,label:string,formula:string,position:string,category_type:string,sens:string,bc:string}>|int Array of groups or -1 if error
* @see getCatsCpts(), getCptsCat()
*/
public function getCats($categorytype = -1, $active = 1)
@ -786,7 +788,7 @@ class AccountancyCategory // extends CommonObject
}
$sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position, c.category_type, c.sens";
$sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c";
$sql .= " FROM ".$this->db->prefix().$this->table_element." as c";
$sql .= " WHERE c.active = " . (int) $active;
$sql .= " AND c.entity = ".$conf->entity;
if ($categorytype >= 0) {
@ -837,7 +839,7 @@ class AccountancyCategory // extends CommonObject
* @param string $predefinedgroupwhere Sql criteria filter to select accounting accounts. This value must be sanitized and not come from an input of a user.
* Example: "pcg_type = 'EXPENSE' AND fk_pcg_version = 'xx'"
* Example: "fk_accounting_category = 99"
* @return array|int Array of accounting accounts or -1 if error
* @return array<array{id:int,account_number:string,account_label:string}>|int<-1,-1> Array of accounting accounts or -1 if error
* @see getCats(), getCatsCpts()
*/
public function getCptsCat($cat_id, $predefinedgroupwhere = '')
@ -851,14 +853,14 @@ class AccountancyCategory // extends CommonObject
}
$pcgverid = getDolGlobalInt('CHARTOFACCOUNTS');
$pcgvercode = dol_getIdFromCode($this->db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version');
$pcgvercode = dol_getIdFromCode($this->db, (string) $pcgverid, 'accounting_system', 'rowid', 'pcg_version');
if (empty($pcgvercode)) {
$pcgvercode = $pcgverid;
}
if (!empty($cat_id)) {
$sql = "SELECT t.rowid, t.account_number, t.label as account_label";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t";
$sql .= " FROM ".$this->db->prefix()."accounting_account as t";
$sql .= " WHERE t.fk_accounting_category = ".((int) $cat_id);
$sql .= " AND t.entity = ".$conf->entity;
$sql .= " AND t.active = 1";
@ -866,7 +868,7 @@ class AccountancyCategory // extends CommonObject
$sql .= " ORDER BY t.account_number";
} else {
$sql = "SELECT t.rowid, t.account_number, t.label as account_label";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t";
$sql .= " FROM ".$this->db->prefix()."accounting_account as t";
$sql .= " WHERE ".$predefinedgroupwhere;
$sql .= " AND t.entity = ".$conf->entity;
$sql .= ' AND t.active = 1';

View file

@ -9,7 +9,7 @@
* Copyright (C) 2022 Lionel Vessiller <lvessiller@open-dsi.fr>
* Copyright (C) 2013-2017 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2017 Elarifr. Ari Elbaz <github@accedinfo.com>
* Copyright (C) 2017-2019 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2017-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2017 André Schild <a.schild@aarboard.ch>
* Copyright (C) 2020 Guillaume Alexandre <guillaume@tag-info.fr>
* Copyright (C) 2022 Joachim Kueter <jkueter@gmx.de>
@ -49,26 +49,46 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
class AccountancyExport
{
// Types of export.
/** @var int */
public static $EXPORT_TYPE_CONFIGURABLE = 1; // CSV
/** @var int */
public static $EXPORT_TYPE_AGIRIS = 10;
/** @var int */
public static $EXPORT_TYPE_EBP = 15;
/** @var int */
public static $EXPORT_TYPE_CEGID = 20;
/** @var int */
public static $EXPORT_TYPE_COGILOG = 25;
/** @var int */
public static $EXPORT_TYPE_COALA = 30;
/** @var int */
public static $EXPORT_TYPE_BOB50 = 35;
/** @var int */
public static $EXPORT_TYPE_CIEL = 40;
/** @var int */
public static $EXPORT_TYPE_SAGE50_SWISS = 45;
/** @var int */
public static $EXPORT_TYPE_CHARLEMAGNE = 50;
/** @var int */
public static $EXPORT_TYPE_QUADRATUS = 60;
/** @var int */
public static $EXPORT_TYPE_WINFIC = 70;
/** @var int */
public static $EXPORT_TYPE_OPENCONCERTO = 100;
/** @var int */
public static $EXPORT_TYPE_LDCOMPTA = 110;
/** @var int */
public static $EXPORT_TYPE_LDCOMPTA10 = 120;
/** @var int */
public static $EXPORT_TYPE_GESTIMUMV3 = 130;
/** @var int */
public static $EXPORT_TYPE_GESTIMUMV5 = 135;
/** @var int */
public static $EXPORT_TYPE_ISUITEEXPERT = 200;
// Generic FEC after that
/** @var int */
public static $EXPORT_TYPE_FEC = 1000;
/** @var int */
public static $EXPORT_TYPE_FEC2 = 1010;
/**
@ -92,7 +112,7 @@ class AccountancyExport
public $end_line = '';
/**
* @var array Generated file
* @var array{downloadFilePath:string,downloadFileMimeType:string,downloadFileFullName:string}|array{} Generated file
*/
public $generatedfiledata = array();
@ -116,8 +136,8 @@ class AccountancyExport
/**
* Array with all export type available (key + label)
*
* @param int $mode Mode of list: 0=flat list, 1=rich list
* @return array of type
* @param int<0,1> $mode Mode of list: 0=flat list, 1=rich list
* @return array<int|string,string>|array<int|string,array{id:int|string,label:string,position:int,disabled?:string}> array of type
*/
public function getType($mode = 0)
{
@ -214,9 +234,9 @@ class AccountancyExport
}
/**
* Array with all export type available (key + label) and parameters for config
* Array with all export types available (key + label) and parameters for config
*
* @return array of type
* @return array{param:array<int|string,array<string,string>>,cr:array<int|string,string>,format:array<string,string>} of type
*/
public function getTypeConfig()
{
@ -338,21 +358,21 @@ class AccountancyExport
/**
* Function who chose which export to use with the default config, and make the export into a file
*
* @param array $TData Array with data
* @param int $formatexportset Id of export format
* @param int $withAttachment [=0] Not add files
* or 1 to have attached in an archive (ex : Quadratus) - Force output mode to write in a file (output mode = 1)
* @param int $downloadMode [=0] Direct download. Deprecated. Always use value 1.
* or 1 to download after writing files - Forced by default when use withAttachment = 1
* or -1 not to download files
* @param int $outputMode [=0] Print on screen. Deprecated. Always use value 1.
* or 1 to write in file and uses the temp directory - Forced by default when use withAttachment = 1
* or 2 to write in file a default export directory (accounting/export/)
* @param int $noouput 0=old mode. Deprecated. Always use value 1.
* or 1=Do not output the file on stdout with this method. This must always be done by the main page, never by a method.
* @param BookKeepingLine[] $TData Array with data
* @param int $formatexportset Id of export format
* @param int<0,1> $withAttachment [=0] Not add files
* or 1 to have attached in an archive (ex : Quadratus) - Force output mode to write in a file (output mode = 1)
* @param int<1,1> $downloadMode [=0] Direct download. Deprecated. Always use value 1.
* or 1 to download after writing files - Forced by default when use withAttachment = 1
* or -1 not to download files
* @param int<1,1> $outputMode [=0] Print on screen. Deprecated. Always use value 1.
* or 1 to write in file and uses the temp directory - Forced by default when use withAttachment = 1
* or 2 to write in file a default export directory (accounting/export/)
* @param int<1,1> $noouput 0=old mode. Deprecated. Always use value 1.
* or 1=Do not output the file on stdout with this method. This must always be done by the main page, never by a method.
* @return int Return integer <0 if KO, >0 OK. The property ->generatedfile is also filled.
*/
public function export(&$TData, $formatexportset, $withAttachment = 0, $downloadMode = 0, $outputMode = 0, $noouput = 0)
public function export(&$TData, $formatexportset, $withAttachment = 0, $downloadMode = 1, $outputMode = 1, $noouput = 1)
{
global $db, $conf, $langs; // The tpl file use $db
global $search_date_end; // Used into /accountancy/tpl/export_journal.tpl.php
@ -414,7 +434,7 @@ class AccountancyExport
// directory already created when module is enabled
$outputDir .= '/export';
$outputDir .= '/'.dol_sanitizePathName($formatexportset);
$outputDir .= '/'.dol_sanitizePathName((string) $formatexportset);
}
if (!dol_is_dir($outputDir)) {
@ -614,8 +634,8 @@ class AccountancyExport
/**
* Export format : CEGID
*
* @param array $objectLines data
* @param resource $exportFile [=null] File resource to export or print if null
* @param BookKeepingLine[] $objectLines data
* @param ?resource $exportFile [=null] File resource to export or print if null
* @return void
*/
public function exportCegid($objectLines, $exportFile = null)
@ -650,8 +670,8 @@ class AccountancyExport
* Export format : COGILOG
* Last review for this format : 2022-07-12 Alexandre Spangaro (aspangaro@open-dsi.fr)
*
* @param array $objectLines data
* @param resource $exportFile [=null] File resource to export or print if null
* @param BookKeepingLine[] $objectLines data
* @param ?resource $exportFile [=null] File resource to export or print if null
* @return void
*/
public function exportCogilog($objectLines, $exportFile = null)
@ -714,8 +734,8 @@ class AccountancyExport
/**
* Export format : COALA
*
* @param array $objectLines data
* @param resource $exportFile [=null] File resource to export or print if null
* @param BookKeepingLine[] $objectLines data
* @param ?resource $exportFile [=null] File resource to export or print if null
* @return void
*/
public function exportCoala($objectLines, $exportFile = null)
@ -751,8 +771,8 @@ class AccountancyExport
/**
* Export format : BOB50
*
* @param array $objectLines data
* @param resource $exportFile [=null] File resource to export or print if null
* @param BookKeepingLine[] $objectLines data
* @param ?resource $exportFile [=null] File resource to export or print if null
* @return void
*/
public function exportBob50($objectLines, $exportFile = null)
@ -806,8 +826,8 @@ class AccountancyExport
* If you want to force filename to "XIMPORT.TXT" for automatically import file present in a directory :
* use constant ACCOUNTING_EXPORT_XIMPORT_FORCE_FILENAME
*
* @param array $objectLines data
* @param resource $exportFile [=null] File resource to export or print if null
* @param BookKeepingLine[] $objectLines data
* @param ?resource $exportFile [=null] File resource to export or print if null
* @return void
*/
public function exportCiel($objectLines, $exportFile = null)
@ -827,7 +847,7 @@ class AccountancyExport
$tab = array();
$tab[] = str_pad($line->piece_num, 5);
$tab[] = str_pad((string) $line->piece_num, 5);
$tab[] = str_pad(self::trunc($line->code_journal, 2), 2);
$tab[] = str_pad($date_document, 8, ' ', STR_PAD_LEFT);
$tab[] = str_pad($date_echeance, 8, ' ', STR_PAD_LEFT);
@ -859,11 +879,11 @@ class AccountancyExport
* Help to import in Quadra: https://wiki.dolibarr.org/index.php?title=Module_Comptabilit%C3%A9_en_Partie_Double#Import_vers_CEGID_Quadra
* In QuadraCompta | Use menu : "Outils" > "Suivi des dossiers" > "Import ASCII(Compta)"
*
* @param array $objectLines data
* @param resource $exportFile [=null] File resource to export or print if null
* @param array $archiveFileList [=array()] Archive file list : array of ['path', 'name']
* @param int $withAttachment [=0] Not add files or 1 to have attached in an archive
* @return array Archive file list : array of ['path', 'name']
* @param BookKeepingLine[] $objectLines data
* @param ?resource $exportFile [=null] File resource to export or print if null
* @param array<string,array{name:string,path:string}> $archiveFileList [=array()] Archive file list : array of ['path', 'name']
* @param int<0,1> $withAttachment [=0] Not add files or 1 to have attached in an archive
* @return array<string,array{name:string,path:string}> Archive file list : array of ['path', 'name']
*/
public function exportQuadratus($objectLines, $exportFile = null, $archiveFileList = array(), $withAttachment = 0)
{
@ -978,13 +998,13 @@ class AccountancyExport
// $tab['lettrage'] = str_repeat(' ', 5);
$tab['lettrage'] = str_repeat(' ', 2);
$tab['codestat'] = str_repeat(' ', 3);
$tab['num_piece'] = str_pad(self::trunc($line->piece_num, 5), 5);
$tab['num_piece'] = str_pad(self::trunc((string) $line->piece_num, 5), 5);
// Keep correct quadra named field instead of anon filler
// $tab['filler2'] = str_repeat(' ', 20);
$tab['affaire'] = str_repeat(' ', 10);
$tab['quantity1'] = str_repeat(' ', 10);
$tab['num_piece2'] = str_pad(self::trunc($line->piece_num, 8), 8);
$tab['num_piece2'] = str_pad(self::trunc((string) $line->piece_num, 8), 8);
$tab['devis'] = str_pad($conf->currency, 3);
$tab['code_journal2'] = str_pad(self::trunc($line->code_journal, 3), 3);
$tab['filler3'] = str_repeat(' ', 3);
@ -1006,7 +1026,7 @@ class AccountancyExport
// get document file
$attachmentFileName = '';
if ($withAttachment == 1) {
$attachmentFileKey = trim($line->piece_num);
$attachmentFileKey = trim((string) $line->piece_num);
if (!isset($archiveFileList[$attachmentFileKey])) {
$objectDirPath = '';
@ -1025,9 +1045,9 @@ class AccountancyExport
$arrayofinclusion = array();
// If it is a supplier invoice, we want to use last uploaded file
$arrayofinclusion[] = '^'.preg_quote($objectFileName, '/').(($line->doc_type == 'supplier_invoice') ? '.+' : '').'\.pdf$';
$fileFoundList = dol_dir_list($objectDirPath.'/'.$objectFileName, 'files', 0, implode('|', $arrayofinclusion), '(\.meta|_preview.*\.png)$', 'date', SORT_DESC, 0, true);
$fileFoundList = dol_dir_list($objectDirPath.'/'.$objectFileName, 'files', 0, implode('|', $arrayofinclusion), '(\.meta|_preview.*\.png)$', 'date', SORT_DESC, 0, 1);
if (!empty($fileFoundList)) {
$attachmentFileNameTrunc = str_pad(self::trunc($line->piece_num, 8), 8, '0', STR_PAD_LEFT);
$attachmentFileNameTrunc = str_pad(self::trunc((string) $line->piece_num, 8), 8, '0', STR_PAD_LEFT);
foreach ($fileFoundList as $fileFound) {
if (strstr($fileFound['name'], $objectFileName)) {
// skip native invoice pdfs (canelle)
@ -1080,8 +1100,8 @@ class AccountancyExport
*
* Help : https://wiki.gestan.fr/lib/exe/fetch.php?media=wiki:v15:compta:accountancy-format_winfic-ewinfic-winsiscompta.pdf
*
* @param array $objectLines data
* @param resource $exportFile [=null] File resource to export or print if null
* @param BookKeepingLine[] $objectLines data
* @param ?resource $exportFile [=null] File resource to export or print if null
* @return void
*/
public function exportWinfic($objectLines, $exportFile = null)
@ -1110,7 +1130,7 @@ class AccountancyExport
$tab['folio'] = ' 1';
$tab['num_ecriture'] = str_pad(dol_trunc($index, 6, 'right', 'UTF-8', 1), 6, ' ', STR_PAD_LEFT);
$tab['num_ecriture'] = str_pad(dol_trunc((string) $index, 6, 'right', 'UTF-8', 1), 6, ' ', STR_PAD_LEFT);
$tab['jour_ecriture'] = dol_print_date($line->doc_date, '%d%m%y');
@ -1130,7 +1150,7 @@ class AccountancyExport
$tab['lettrage'] = str_repeat(dol_trunc($line->lettering_code, 2, 'left', 'UTF-8', 1), 2);
$tab['code_piece'] = str_pad(dol_trunc($line->piece_num, 5, 'left', 'UTF-8', 1), 5, ' ', STR_PAD_LEFT);
$tab['code_piece'] = str_pad(dol_trunc((string) $line->piece_num, 5, 'left', 'UTF-8', 1), 5, ' ', STR_PAD_LEFT);
$tab['code_stat'] = str_repeat(' ', 4);
@ -1162,8 +1182,8 @@ class AccountancyExport
/**
* Export format : EBP
*
* @param array $objectLines data
* @param resource $exportFile [=null] File resource to export or print if null
* @param BookKeepingLine[] $objectLines data
* @param ?resource $exportFile [=null] File resource to export or print if null
* @return void
*/
public function exportEbp($objectLines, $exportFile = null)
@ -1186,7 +1206,7 @@ class AccountancyExport
}
//$tab[] = substr(length_accountg($line->numero_compte), 0, 2) . $separator;
$tab[] = '"'.dol_trunc($line->label_operation, 40, 'right', 'UTF-8', 1).'"';
$tab[] = '"'.dol_trunc($line->piece_num, 15, 'right', 'UTF-8', 1).'"';
$tab[] = '"'.dol_trunc((string) $line->piece_num, 15, 'right', 'UTF-8', 1).'"';
$tab[] = price2num(abs($line->debit - $line->credit));
$tab[] = $line->sens;
$tab[] = $date_document;
@ -1205,8 +1225,8 @@ class AccountancyExport
/**
* Export format : Agiris Isacompta
*
* @param array $objectLines data
* @param resource $exportFile [=null] File resource to export or print if null
* @param BookKeepingLine[] $objectLines data
* @param ?resource $exportFile [=null] File resource to export or print if null
* @return void
*/
public function exportAgiris($objectLines, $exportFile = null)
@ -1252,8 +1272,8 @@ class AccountancyExport
/**
* Export format : OpenConcerto
*
* @param array $objectLines data
* @param resource $exportFile [=null] File resource to export or print if null
* @param BookKeepingLine[] $objectLines data
* @param ?resource $exportFile [=null] File resource to export or print if null
* @return void
*/
public function exportOpenConcerto($objectLines, $exportFile = null)
@ -1290,8 +1310,8 @@ class AccountancyExport
/**
* Export format : Configurable CSV
*
* @param array $objectLines data
* @param resource $exportFile [=null] File resource to export or print if null
* @param BookKeepingLine[] $objectLines data
* @param ?resource $exportFile [=null] File resource to export or print if null
* @return void
*/
public function exportConfigurable($objectLines, $exportFile = null)
@ -1331,11 +1351,11 @@ class AccountancyExport
*
* Help to import in your software: https://wiki.dolibarr.org/index.php?title=Module_Comptabilit%C3%A9_en_Partie_Double#Exports_avec_fichiers_sources
*
* @param array $objectLines data
* @param resource $exportFile [=null] File resource to export or print if null
* @param array $archiveFileList [=array()] Archive file list : array of ['path', 'name']
* @param int $withAttachment [=0] Not add files or 1 to have attached in an archive
* @return array Archive file list : array of ['path', 'name']
* @param BookKeepingLine[] $objectLines data
* @param ?resource $exportFile [=null] File resource to export or print if null
* @param array<string,array{name:string,path:string}> $archiveFileList [=array()] Archive file list : array of ['path', 'name']
* @param int<0,1> $withAttachment [=0] Not add files or 1 to have attached in an archive
* @return array<string,array{name:string,path:string}> Archive file list : array of ['path', 'name']
*/
public function exportFEC($objectLines, $exportFile = null, $archiveFileList = array(), $withAttachment = 0)
{
@ -1475,7 +1495,7 @@ class AccountancyExport
// get document file
$attachmentFileName = '';
if ($withAttachment == 1) {
$attachmentFileKey = trim($line->piece_num);
$attachmentFileKey = trim((string) $line->piece_num);
if (!isset($archiveFileList[$attachmentFileKey])) {
$objectDirPath = '';
@ -1485,13 +1505,14 @@ class AccountancyExport
} elseif ($line->doc_type == 'expense_report') {
$objectDirPath = !empty($conf->expensereport->multidir_output[$conf->entity]) ? $conf->expensereport->multidir_output[$conf->entity] : $conf->expensereport->dir_output;
} elseif ($line->doc_type == 'supplier_invoice') {
'@phan-var-force FactureFournisseur $invoice';
$objectDirPath = !empty($conf->fournisseur->facture->multidir_output[$conf->entity]) ? $conf->fournisseur->facture->multidir_output[$conf->entity] : $conf->fournisseur->facture->dir_output;
$objectDirPath .= '/'.rtrim(get_exdir($invoice->id, 2, 0, 0, $invoice, 'invoice_supplier'), '/');
}
$arrayofinclusion = array();
// If it is a supplier invoice, we want to use last uploaded file
$arrayofinclusion[] = '^'.preg_quote($objectFileName, '/').(($line->doc_type == 'supplier_invoice') ? '.+' : '').'\.pdf$';
$fileFoundList = dol_dir_list($objectDirPath.'/'.$objectFileName, 'files', 0, implode('|', $arrayofinclusion), '(\.meta|_preview.*\.png)$', 'date', SORT_DESC, 0, true);
$fileFoundList = dol_dir_list($objectDirPath.'/'.$objectFileName, 'files', 0, implode('|', $arrayofinclusion), '(\.meta|_preview.*\.png)$', 'date', SORT_DESC, 0, 1);
if (!empty($fileFoundList)) {
$attachmentFileNameTrunc = $line->doc_ref;
foreach ($fileFoundList as $fileFound) {
@ -1544,11 +1565,11 @@ class AccountancyExport
*
* Help to import in your software: https://wiki.dolibarr.org/index.php?title=Module_Comptabilit%C3%A9_en_Partie_Double#Exports_avec_fichiers_sources
*
* @param array $objectLines data
* @param resource $exportFile [=null] File resource to export or print if null
* @param array $archiveFileList [=array()] Archive file list : array of ['path', 'name']
* @param int $withAttachment [=0] Not add files or 1 to have attached in an archive
* @return array Archive file list : array of ['path', 'name']
* @param BookKeepingLine[] $objectLines data
* @param ?resource $exportFile [=null] File resource to export or print if null
* @param array<string,array{name:string,path:string}> $archiveFileList [=array()] Archive file list : array of ['path', 'name']
* @param int<0,1> $withAttachment [=0] Not add files or 1 to have attached in an archive
* @return array<string,array{name:string,path:string}> Archive file list : array of ['path', 'name']
*/
public function exportFEC2($objectLines, $exportFile = null, $archiveFileList = array(), $withAttachment = 0)
{
@ -1687,7 +1708,7 @@ class AccountancyExport
// get document file
$attachmentFileName = '';
if ($withAttachment == 1) {
$attachmentFileKey = trim($line->piece_num);
$attachmentFileKey = trim((string) $line->piece_num);
if (!isset($archiveFileList[$attachmentFileKey])) {
$objectDirPath = '';
@ -1697,13 +1718,14 @@ class AccountancyExport
} elseif ($line->doc_type == 'expense_report') {
$objectDirPath = !empty($conf->expensereport->multidir_output[$conf->entity]) ? $conf->expensereport->multidir_output[$conf->entity] : $conf->expensereport->dir_output;
} elseif ($line->doc_type == 'supplier_invoice') {
'@phan-var-force FactureFournisseur $invoice';
$objectDirPath = !empty($conf->fournisseur->facture->multidir_output[$conf->entity]) ? $conf->fournisseur->facture->multidir_output[$conf->entity] : $conf->fournisseur->facture->dir_output;
$objectDirPath .= '/'.rtrim(get_exdir($invoice->id, 2, 0, 0, $invoice, 'invoice_supplier'), '/');
}
$arrayofinclusion = array();
// If it is a supplier invoice, we want to use last uploaded file
$arrayofinclusion[] = '^'.preg_quote($objectFileName, '/').(($line->doc_type == 'supplier_invoice') ? '.+' : '').'\.pdf$';
$fileFoundList = dol_dir_list($objectDirPath.'/'.$objectFileName, 'files', 0, implode('|', $arrayofinclusion), '(\.meta|_preview.*\.png)$', 'date', SORT_DESC, 0, true);
$fileFoundList = dol_dir_list($objectDirPath.'/'.$objectFileName, 'files', 0, implode('|', $arrayofinclusion), '(\.meta|_preview.*\.png)$', 'date', SORT_DESC, 0, 1);
if (!empty($fileFoundList)) {
$attachmentFileNameTrunc = $line->doc_ref;
foreach ($fileFoundList as $fileFound) {
@ -1755,8 +1777,8 @@ class AccountancyExport
* https://onlinehelp.sageschweiz.ch/default.aspx?tabid=19984
* http://media.topal.ch/Public/Schnittstellen/TAF/Specification/Sage50-TAF-format.pdf
*
* @param array $objectLines data
* @param resource $exportFile [=null] File resource to export or print if null
* @param BookKeepingLine[] $objectLines data
* @param ?resource $exportFile [=null] File resource to export or print if null
* @return void
*/
public function exportSAGE50SWISS($objectLines, $exportFile = null)
@ -1909,8 +1931,8 @@ class AccountancyExport
* Export format : LD Compta version 9
* http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW9.pdf
*
* @param array $objectLines data
* @param resource $exportFile [=null] File resource to export or print if null
* @param BookKeepingLine[] $objectLines data
* @param ?resource $exportFile [=null] File resource to export or print if null
* @return void
*/
public function exportLDCompta($objectLines, $exportFile = null)
@ -2049,8 +2071,8 @@ class AccountancyExport
*
* Help : http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW10.pdf
*
* @param array $objectLines data
* @param resource $exportFile [=null] File resource to export or print if null
* @param BookKeepingLine[] $objectLines data
* @param ?resource $exportFile [=null] File resource to export or print if null
* @return void
*/
public function exportLDCompta10($objectLines, $exportFile = null)
@ -2329,8 +2351,8 @@ class AccountancyExport
/**
* Export format : Charlemagne
*
* @param array $objectLines data
* @param resource $exportFile [=null] File resource to export or print if null
* @param BookKeepingLine[] $objectLines data
* @param ?resource $exportFile [=null] File resource to export or print if null
* @return void
*/
public function exportCharlemagne($objectLines, $exportFile = null)
@ -2407,8 +2429,8 @@ class AccountancyExport
/**
* Export format : Gestimum V3
*
* @param array $objectLines data
* @param resource $exportFile [=null] File resource to export or print if null
* @param BookKeepingLine[] $objectLines data
* @param ?resource $exportFile [=null] File resource to export or print if null
* @return void
*/
public function exportGestimumV3($objectLines, $exportFile = null)
@ -2490,7 +2512,7 @@ class AccountancyExport
//Libellé manual
$tab[] = dol_trunc(str_replace('"', '', $invoice_ref . (!empty($company_name) ? ' - ' : '') . $company_name), 40, 'right', 'UTF-8', 1);
//Numéro de pièce
$tab[] = dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1);
$tab[] = dol_trunc(str_replace('"', '', (string) $line->piece_num), 10, 'right', 'UTF-8', 1);
//Devise
$tab[] = 'EUR';
//Amount
@ -2515,8 +2537,8 @@ class AccountancyExport
/**
* Export format : Gestimum V5
*
* @param array $objectLines data
* @param resource $exportFile [=null] File resource to export or print if null
* @param BookKeepingLine[] $objectLines data
* @param ?resource $exportFile [=null] File resource to export or print if null
* @return void
*/
public function exportGestimumV5($objectLines, $exportFile = null)
@ -2543,7 +2565,7 @@ class AccountancyExport
$tab[] = "";
$tab[] = '"'.dol_trunc(str_replace('"', '', $line->label_operation), 40, 'right', 'UTF-8', 1).'"';
$tab[] = '"' . dol_trunc(str_replace('"', '', $line->doc_ref), 40, 'right', 'UTF-8', 1) . '"';
$tab[] = '"' . dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . '"';
$tab[] = '"' . dol_trunc(str_replace('"', '', (string) $line->piece_num), 10, 'right', 'UTF-8', 1) . '"';
$tab[] = price2num(abs($line->debit - $line->credit));
$tab[] = $line->sens;
$tab[] = $date_document;
@ -2566,8 +2588,8 @@ class AccountancyExport
*
* by OpenSolus [https://opensolus.fr]
*
* @param array $objectLines data
* @param resource $exportFile [=null] File resource to export or print if null
* @param BookKeepingLine[] $objectLines data
* @param ?resource $exportFile [=null] File resource to export or print if null
* @return void
*/
public function exportiSuiteExpert($objectLines, $exportFile = null)

View file

@ -11,6 +11,7 @@
* Copyright (C) 2017-2019 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2017 André Schild <a.schild@aarboard.ch>
* Copyright (C) 2020 Guillaume Alexandre <guillaume@tag-info.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -62,8 +63,8 @@ class AccountancyImport
/**
* Clean amount
*
* @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param array $listfields Fields list to add
* @param array<array{val:null|int|float|string,type:int<-1,1>}> $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param array<string,string> $listfields Fields list to add
* @param int $record_key Record key
* @return float Value
*/
@ -76,8 +77,8 @@ class AccountancyImport
/**
* Clean value with trim
*
* @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param array $listfields Fields list to add
* @param array<array{val:null|int|float|string,type:int<-1,1>}> $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param array<string,string> $listfields Fields list to add
* @param int $record_key Record key
* @return mixed Value
*/
@ -89,8 +90,8 @@ class AccountancyImport
/**
* Compute amount
*
* @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param array $listfields Fields list to add
* @param array<array{val:null|int|float|string,type:int<-1,1>}> $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param array<string,string> $listfields Fields list to add
* @param int $record_key Record key
* @return string Value
*/
@ -118,8 +119,8 @@ class AccountancyImport
/**
* Compute direction
*
* @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param array $listfields Fields list to add
* @param array<array{val:null|int|float|string,type:int<-1,1>}> $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param array<string,string> $listfields Fields list to add
* @param int $record_key Record key
* @return string Value
*/
@ -144,8 +145,8 @@ class AccountancyImport
/**
* Compute piece number
*
* @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param array $listfields Fields list to add
* @param array<array{val:null|int|float|string,type:int<-1,1>}> $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param array<string,string> $listfields Fields list to add
* @param int $record_key Record key
* @return string Value
*/
@ -179,7 +180,7 @@ class AccountancyImport
}
// at least one record value has changed, so we search for the next piece number from database or increment it
if ($atLeastOneLastRecordChanged === true) {
if ($atLeastOneLastRecordChanged) {
$lastPieceNum = 0;
if (empty($conf->cache['accounting']['nextPieceNum'])) {
// get last piece number from database

View file

@ -3,6 +3,7 @@
* Copyright (C) 2013-2014 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2023 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2024 Alexandre Janniaux <alexandre.janniaux@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -27,7 +28,7 @@
/**
* Class to manage accountancy systems
*/
class AccountancySystem
class AccountancySystem extends CommonObject
{
/**
* @var DoliDB Database handler.
@ -57,17 +58,13 @@ class AccountancySystem
public $rowid;
/**
* @var int ID
*/
public $fk_pcg_version;
/**
* @var int pcg version
* @var string Accountancy system code
*/
public $pcg_version;
/**
* @var string ref
* @var string Ref of accountancy system. Duplicate property with ->pcg_version.
* @see $pcg_version
*/
public $ref;
@ -76,31 +73,11 @@ class AccountancySystem
*/
public $active;
/**
* @var string pcg type
*/
public $pcg_type;
/**
* @var string Accountancy System numero
*/
public $numero;
/**
* @var string Accountancy System label
*/
public $label;
/**
* @var string account number
*/
public $account_number;
/**
* @var string account parent
*/
public $account_parent;
/**
* Constructor
*
@ -170,8 +147,13 @@ class AccountancySystem
$now = dol_now();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_system";
$sql .= " (date_creation, fk_user_author, numero, label)";
$sql .= " VALUES ('".$this->db->idate($now)."',".((int) $user->id).",'".$this->db->escape($this->numero)."','".$this->db->escape($this->label)."')";
$sql .= " (date_creation, fk_user_author, label, pcg_version, active)";
$sql .= " VALUES ('"
. $this->db->idate($now) ."',"
. ((int) $user->id) .",'"
. $this->db->escape($this->label) ."','"
. $this->db->escape($this->pcg_version) ."',"
. ((int) $this->active) .")";
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
@ -184,12 +166,12 @@ class AccountancySystem
$result = $this->rowid;
} else {
$result = - 2;
$this->error = "AccountancySystem::Create Error $result";
$this->error = "AccountancySystem::Create Error $result: " . $this->db->lasterror();
dol_syslog($this->error, LOG_ERR);
}
} else {
$result = - 1;
$this->error = "AccountancySystem::Create Error $result";
$this->error = "AccountancySystem::Create Error $result: " . $this->db->lasterror();
dol_syslog($this->error, LOG_ERR);
}

View file

@ -145,7 +145,7 @@ class AccountingAccount extends CommonObject
public $reconcilable;
/**
* @var array cache array
* @var array<string,int> cache array
*/
private $accountingaccount_codetotid_cache = array();
@ -164,7 +164,7 @@ class AccountingAccount extends CommonObject
$this->db = $db;
$this->ismultientitymanaged = 1;
$this->next_prev_filter = "fk_pcg_version IN (SELECT pcg_version FROM ".MAIN_DB_PREFIX."accounting_system WHERE rowid = ".((int) getDolGlobalInt('CHARTOFACCOUNTS')).")"; // Used to add a filter in Form::showrefnav method
$this->next_prev_filter = "fk_pcg_version IN (SELECT pcg_version FROM ".$this->db->prefix()."accounting_system WHERE rowid = ".((int) getDolGlobalInt('CHARTOFACCOUNTS')).")"; // Used to add a filter in Form::showrefnav method
}
/**
@ -183,8 +183,8 @@ class AccountingAccount extends CommonObject
if ($rowid || $account_number) {
$sql = "SELECT a.rowid as rowid, a.datec, a.tms, a.fk_pcg_version, a.pcg_type, a.account_number, a.account_parent, a.label, a.labelshort, a.fk_accounting_category, a.fk_user_author, a.fk_user_modif, a.active, a.reconcilable";
$sql .= ", ca.label as category_label";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as a";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_accounting_category as ca ON a.fk_accounting_category = ca.rowid";
$sql .= " FROM ".$this->db->prefix().$this->table_element." as a";
$sql .= " LEFT JOIN ".$this->db->prefix()."c_accounting_category as ca ON a.fk_accounting_category = ca.rowid";
$sql .= " WHERE";
if ($rowid) {
$sql .= " a.rowid = ".(int) $rowid;
@ -193,7 +193,7 @@ class AccountingAccount extends CommonObject
$sql .= " AND a.entity = ".$conf->entity;
}
if (!empty($limittocurrentchart)) {
$sql .= ' AND a.fk_pcg_version IN (SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid = '.((int) getDolGlobalInt('CHARTOFACCOUNTS')).')';
$sql .= ' AND a.fk_pcg_version IN (SELECT pcg_version FROM '.$this->db->prefix().'accounting_system WHERE rowid = '.((int) getDolGlobalInt('CHARTOFACCOUNTS')).')';
}
if (!empty($limittoachartaccount)) {
$sql .= " AND a.fk_pcg_version = '".$this->db->escape($limittoachartaccount)."'";
@ -276,7 +276,7 @@ class AccountingAccount extends CommonObject
// Put here code to add control on parameters values
// Insert request
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_account(";
$sql = "INSERT INTO " . $this->db->prefix() . $this->table_element . " (";
$sql .= "datec";
$sql .= ", entity";
$sql .= ", fk_pcg_version";
@ -314,7 +314,7 @@ class AccountingAccount extends CommonObject
}
if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_account");
$this->id = $this->db->last_insert_id($this->db->prefix() . $this->table_element);
// Uncomment this and change MYOBJECT to your own tag if you
// want this action to call a trigger.
@ -356,7 +356,7 @@ class AccountingAccount extends CommonObject
$this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account ";
$sql = "UPDATE " . $this->db->prefix() . $this->table_element;
$sql .= " SET fk_pcg_version = " . ($this->fk_pcg_version ? "'" . $this->db->escape($this->fk_pcg_version) . "'" : "null");
$sql .= " , pcg_type = " . ($this->pcg_type ? "'" . $this->db->escape($this->pcg_type) . "'" : "null");
$sql .= " , account_number = '" . $this->db->escape($this->account_number) . "'";
@ -397,10 +397,10 @@ class AccountingAccount extends CommonObject
global $langs;
// TODO Looks a stupid check
$sql = "(SELECT fk_code_ventilation FROM ".MAIN_DB_PREFIX."facturedet";
$sql = "(SELECT fk_code_ventilation FROM ".$this->db->prefix()."facturedet";
$sql .= " WHERE fk_code_ventilation=".((int) $this->id).")";
$sql .= "UNION";
$sql .= " (SELECT fk_code_ventilation FROM ".MAIN_DB_PREFIX."facture_fourn_det";
$sql .= " (SELECT fk_code_ventilation FROM ".$this->db->prefix()."facture_fourn_det";
$sql .= " WHERE fk_code_ventilation=".((int) $this->id).")";
dol_syslog(get_class($this)."::checkUsage", LOG_DEBUG);
@ -437,7 +437,7 @@ class AccountingAccount extends CommonObject
$this->db->begin();
if (!$error) {
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_account";
$sql = "DELETE FROM " . $this->db->prefix() . $this->table_element;
$sql .= " WHERE rowid=" . ((int) $this->id);
dol_syslog(get_class($this) . "::delete sql=" . $sql);
@ -466,7 +466,7 @@ class AccountingAccount extends CommonObject
}
/**
* Return clicable name (with picto eventually)
* Return clickable name (with picto eventually)
*
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @param int $withlabel 0=No label, 1=Include label of account
@ -586,7 +586,7 @@ class AccountingAccount extends CommonObject
public function info($id)
{
$sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms as date_modification';
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as a';
$sql .= ' FROM ' . $this->db->prefix() . $this->table_element . ' as a';
$sql .= ' WHERE a.rowid = ' . ((int) $id);
dol_syslog(get_class($this) . '::info sql=' . $sql);
@ -628,8 +628,8 @@ class AccountingAccount extends CommonObject
if ($result > 0) {
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account ";
$sql .= "SET ".$this->db->sanitize($fieldtouse)." = 0";
$sql = "UPDATE ".$this->db->prefix().$this->table_element;
$sql .= " SET ".$this->db->sanitize($fieldtouse)." = 0";
$sql .= " WHERE rowid = ".((int) $id);
dol_syslog(get_class($this)."::accountDeactivate ".$fieldtouse, LOG_DEBUG);
@ -666,7 +666,7 @@ class AccountingAccount extends CommonObject
$fieldtouse = 'reconcilable';
}
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account";
$sql = "UPDATE ".$this->db->prefix().$this->table_element;
$sql .= " SET ".$this->db->sanitize($fieldtouse)." = 1";
$sql .= " WHERE rowid = ".((int) $id);
@ -729,9 +729,9 @@ class AccountingAccount extends CommonObject
* @param Product $product Product object sell or buy
* @param Facture|FactureFournisseur $facture Facture
* @param FactureLigne|SupplierInvoiceLine $factureDet Facture Det
* @param array $accountingAccount Array of Accounting account
* @param array<string,int> $accountingAccount Array of Accounting account
* @param string $type Customer / Supplier
* @return array|int Array of accounting accounts suggested or < 0 if technical error.
* @return array{suggestedaccountingaccountbydefaultfor:string,suggestedaccountingaccountfor:string,suggestedid:?int,code_l:string,code_p:string,code_t:string}|int<-1,-1> Array of accounting accounts suggested or < 0 if technical error.
* 'suggestedaccountingaccountbydefaultfor'=>Will be used for the label to show on tooltip for account by default on any product
* 'suggestedaccountingaccountfor'=>Is the account suggested for this product
*/
@ -745,6 +745,7 @@ class AccountingAccount extends CommonObject
$parameters = array('buyer' => $buyer, 'seller' => $seller, 'product' => $product, 'facture' => $facture, 'factureDet' => $factureDet ,'accountingAccount' => $accountingAccount, 0 => $type);
$reshook = $hookmanager->executeHooks('accountancyBindingCalculation', $parameters); // Note that $action and $object may have been modified by some hooks
$result = -1; // Init for static analysis
if (empty($reshook)) {
$const_name = '';
if ($type == 'customer') {

View file

@ -74,12 +74,12 @@ class AccountingJournal extends CommonObject
public $active;
/**
* @var array Accounting account cached
* @var array<string,array{found:bool,label:string,code_formatted_1:string,label_formatted_1:string,label_formatted_2:string}> Accounting account cached
*/
public static $accounting_account_cached = array();
/**
* @var array Nature mapping
* @var array<int,string> Nature mapping
*/
public static $nature_maps = array(
1 => 'variousoperations',
@ -107,7 +107,7 @@ class AccountingJournal extends CommonObject
* Load an object from database
*
* @param int $rowid Id of record to load
* @param string|null $journal_code Journal code
* @param ?string $journal_code Journal code
* @return int Return integer <0 if KO, Id of record if OK and found
*/
public function fetch($rowid = 0, $journal_code = null)
@ -239,8 +239,8 @@ class AccountingJournal extends CommonObject
/**
* Return the label of the status
*
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
* @return string Label of status
* @param int<0,6> $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
* @return string Label of status
*/
public function getLibType($mode = 0)
{
@ -251,8 +251,8 @@ class AccountingJournal extends CommonObject
/**
* Return type of an accounting journal
*
* @param int $nature Id type
* @param int $mode 0=label long, 1=label short
* @param int $nature Id type
* @param int<0,1> $mode 0=label long, 1=label short
* @return string Label of type
*/
public function LibType($nature, $mode = 0)
@ -304,7 +304,7 @@ class AccountingJournal extends CommonObject
* @param int $date_start Filter 'start date'
* @param int $date_end Filter 'end date'
* @param string $in_bookkeeping Filter 'in bookkeeping' ('already', 'notyet')
* @return array|int Return integer <0 if KO, >0 if OK
* @return int<-1,-1>|array<int,array{ref:string,error:?string,blocks:array<array<array{date:string,piece:string,account_accounting:string,subledger_account:string,label_operation:string,debit:string,credit:string}|array{doc_date:string,date_lim_reglement:string,doc_ref:string,date_creation:string,doc_type:string,fk_doc:string,fk_docdet:string,thirdparty_code:string,subledger_account:string,subledger_label:string,numero_compte:string,label_compte:string,label_operation:string,montant:string,sens:string,debit:string,credit:string,code_journal:string,journal_label:string,piece_num:string,import_key:string,fk_user_author:string,entity:string}>>}> Return integer <0 if KO, array
*/
public function getData(User $user, $type = 'view', $date_start = null, $date_end = null, $in_bookkeeping = 'notyet')
{
@ -348,11 +348,11 @@ class AccountingJournal extends CommonObject
* Get asset data for various journal
*
* @param User $user User who get infos
* @param string $type Type data returned ('view', 'bookkeeping', 'csv')
* @param int $date_start Filter 'start date'
* @param int $date_end Filter 'end date'
* @param string $in_bookkeeping Filter 'in bookkeeping' ('already', 'notyet')
* @return array|int Return integer <0 if KO, >0 if OK
* @param 'view'|'bookkeeping'|'csv' $type Type data returned ('view', 'bookkeeping', 'csv')
* @param ?int $date_start Filter 'start date'
* @param ?int $date_end Filter 'end date'
* @param 'already'|'notyet' $in_bookkeeping Filter 'in bookkeeping' ('already', 'notyet')
* @return int<-1,-1>|array<int,array{ref:string,error:?string,blocks:array<array<array{date:string,piece:string,account_accounting:string,subledger_account:string,label_operation:string,debit:string,credit:string}|array{doc_date:''|int,date_lim_reglement:string,doc_ref:string,date_creation:int,doc_type:string,fk_doc:int|string,fk_docdet:int|string,thirdparty_code:string,subledger_account:string,subledger_label:string,numero_compte:string,label_compte:string,label_operation:string,montant:string,sens:string,debit:int|float|string,credit:int|float|string,code_journal:string,journal_label:string,piece_num:string,import_key:string,fk_user_author:string,entity:string}>>}> Return integer <0 if KO, array
*/
public function getAssetData(User $user, $type = 'view', $date_start = null, $date_end = null, $in_bookkeeping = 'notyet')
{
@ -462,7 +462,7 @@ class AccountingJournal extends CommonObject
$element = array(
'ref' => dol_trunc($element_static->ref, 16, 'right', 'UTF-8', 1),
'error' => $pre_data_info['error'],
'error' => array_key_exists('error', $pre_data_info) ? $pre_data_info['error'] : '',
'blocks' => array(),
);
@ -582,8 +582,8 @@ class AccountingJournal extends CommonObject
}
$lines = array();
$lines[0][$accountancy_code_value_asset_sold] = -($element_static->acquisition_value_ht - $last_cumulative_amount_ht);
$lines[0][$accountancy_code_depreciation_asset] = -$last_cumulative_amount_ht;
$lines[0][$accountancy_code_value_asset_sold] = -((float) $element_static->acquisition_value_ht - $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;
@ -670,43 +670,43 @@ class AccountingJournal extends CommonObject
* Write bookkeeping
*
* @param User $user User who write in the bookkeeping
* @param array $journal_data Journal data to write in the bookkeeping
* $journal_data = array(
* id_element => array(
* 'ref' => 'ref',
* 'error' => '',
* 'blocks' => array(
* pos_block => array(
* num_line => array(
* 'doc_date' => '',
* 'date_lim_reglement' => '',
* 'doc_ref' => '',
* 'date_creation' => '',
* 'doc_type' => '',
* 'fk_doc' => '',
* 'fk_docdet' => '',
* 'thirdparty_code' => '',
* 'subledger_account' => '',
* 'subledger_label' => '',
* 'numero_compte' => '',
* 'label_compte' => '',
* 'label_operation' => '',
* 'montant' => '',
* 'sens' => '',
* 'debit' => '',
* 'credit' => '',
* 'code_journal' => '',
* 'journal_label' => '',
* 'piece_num' => '',
* 'import_key' => '',
* 'fk_user_author' => '',
* 'entity' => '',
* ),
* ),
* ),
* ),
* );
* @param int $max_nb_errors Nb error authorized before stop the process
* @param array<int,array{ref?:string,error?:string,blocks:array<array<array{doc_date:int|string,date_lim_reglement:int|string,doc_ref:string,date_creation:int,doc_type:string,fk_doc:int|string,fk_docdet:int|string,thirdparty_code:string,subledger_account:string,subledger_label:string,numero_compte:string,label_compte:string,label_operation:string,montant:float|string,sens:string,debit:int|float|string,credit:int|float|string,code_journal:string,journal_label:string,piece_num:int|string,import_key:string,fk_user_author:string,entity:string}>>}> $journal_data Journal data to write in the bookkeeping
* $journal_data = array(
* . id_element => array(
* . 'ref' => 'ref',
* . 'error' => '',
* . 'blocks' => array(
* . pos_block => array(
* . num_line => array(
* . 'doc_date' => '',
* . 'date_lim_reglement' => '',
* . 'doc_ref' => '',
* . 'date_creation' => '',
* . 'doc_type' => '',
* . 'fk_doc' => '',
* . 'fk_docdet' => '',
* . 'thirdparty_code' => '',
* . 'subledger_account' => '',
* . 'subledger_label' => '',
* . 'numero_compte' => '',
* . 'label_compte' => '',
* . 'label_operation' => '',
* . 'montant' => '',
* . 'sens' => '',
* . 'debit' => '',
* . 'credit' => '',
* . 'code_journal' => '',
* . 'journal_label' => '',
* . 'piece_num' => '',
* . 'import_key' => '',
* . 'fk_user_author' => '',
* . 'entity' => '',
* . ),
* . ),
* . ),
* . ),
* );
* @param int $max_nb_errors Nb errors authorized before stopping the process
* @return int Return integer <0 if KO, >0 if OK
*/
public function writeIntoBookkeeping(User $user, &$journal_data = array(), $max_nb_errors = 10)
@ -725,7 +725,9 @@ class AccountingJournal extends CommonObject
return -1;
} elseif (empty($reshook)) {
// Clean parameters
$journal_data = is_array($journal_data) ? $journal_data : array();
if (!is_array($journal_data)) {
$journal_data = array();
}
foreach ($journal_data as $element_id => $element) {
$error_for_line = 0;
@ -744,8 +746,8 @@ class AccountingJournal extends CommonObject
foreach ($element['blocks'] as $lines) {
foreach ($lines as $line) {
$bookkeeping = new BookKeeping($this->db);
$bookkeeping->doc_date = $line['doc_date'];
$bookkeeping->date_lim_reglement = $line['date_lim_reglement'];
$bookkeeping->doc_date = (int) $line['doc_date'];
$bookkeeping->date_lim_reglement = (int) $line['date_lim_reglement'];
$bookkeeping->doc_ref = $line['doc_ref'];
$bookkeeping->date_creation = $line['date_creation']; // not used
$bookkeeping->doc_type = $line['doc_type'];
@ -757,13 +759,13 @@ class AccountingJournal extends CommonObject
$bookkeeping->numero_compte = $line['numero_compte'];
$bookkeeping->label_compte = $line['label_compte'];
$bookkeeping->label_operation = $line['label_operation'];
$bookkeeping->montant = $line['montant'];
$bookkeeping->montant = $line['montant']; // Deprecated: sens/debit/credit (and deprecated amount...)
$bookkeeping->sens = $line['sens'];
$bookkeeping->debit = $line['debit'];
$bookkeeping->credit = $line['credit'];
$bookkeeping->debit = (float) $line['debit'];
$bookkeeping->credit = (float) $line['credit'];
$bookkeeping->code_journal = $line['code_journal'];
$bookkeeping->journal_label = $line['journal_label'];
$bookkeeping->piece_num = $line['piece_num'];
$bookkeeping->piece_num = (int) $line['piece_num'];
$bookkeeping->import_key = $line['import_key'];
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->entity = $conf->entity;
@ -810,7 +812,7 @@ class AccountingJournal extends CommonObject
$error++;
$error_for_line++;
$journal_data[$element_id]['error'] = 'amountsnotbalanced';
$this->errors[] = 'Try to insert a non balanced transaction in book for ' . $element['blocks'] . '. Canceled. Surely a bug.';
$this->errors[] = 'Try to insert a non balanced transaction in book for ' . json_encode($element['blocks']) . '. Canceled. Surely a bug.';
}
if (!$error_for_line) {
@ -833,19 +835,19 @@ class AccountingJournal extends CommonObject
* Export journal CSV
* ISO and not UTF8 !
*
* @param array $journal_data Journal data to write in the bookkeeping
* $journal_data = array(
* id_element => array(
* 'continue' => false,
* 'blocks' => array(
* pos_block => array(
* num_line => array(
* data to write in the CSV line
* ),
* ),
* ),
* ),
* );
* @param array<int,array{blocks:array<array<array<string>>>}> $journal_data Journal data to write in the bookkeeping
* $journal_data = array(
* id_element => array(
* 'continue' => false,
* 'blocks' => array(
* pos_block => array(
* num_line => array(
* data to write in the CSV line
* ),
* ),
* ),
* ),
* );
* @param int $search_date_end Search date end
* @param string $sep CSV separator
* @return int|string Return integer <0 if KO, >0 if OK
@ -923,10 +925,10 @@ class AccountingJournal extends CommonObject
}
/**
* Get accounting account infos
* Get accounting account info
*
* @param string $account Accounting account number
* @return array Accounting account infos
* @param string $account Accounting account number
* @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)
{
@ -934,7 +936,7 @@ class AccountingJournal extends CommonObject
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
$accountingaccount = new AccountingAccount($this->db);
$result = $accountingaccount->fetch(null, $account, true);
$result = $accountingaccount->fetch(0, $account, true);
if ($result > 0) {
self::$accounting_account_cached[$account] = array(
'found' => true,

View file

@ -1,7 +1,8 @@
<?php
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2019 Cedric Ancelin <icedo.anc@gmail.com>
* Copyright (C) 2023 Lionel Vessiller <lvessiller@open-dsi.fr>
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2019 Cedric Ancelin <icedo.anc@gmail.com>
* Copyright (C) 2023 Lionel Vessiller <lvessiller@open-dsi.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -30,7 +31,7 @@ class Accountancy extends DolibarrApi
{
/**
*
* @var array $FIELDS Mandatory fields, checked when create and update object
* @var string[] $FIELDS Mandatory fields, checked when create and update object
*/
public static $FIELDS = array();
@ -40,7 +41,7 @@ class Accountancy extends DolibarrApi
public $bookkeeping;
/**
* @var AccountancyExport $accountancy_export {@type AccountancyExport}
* @var AccountancyExport $accountancyexport {@type AccountancyExport}
*/
public $accountancyexport;
@ -137,7 +138,7 @@ class Accountancy extends DolibarrApi
// set filter for each period available
$filter = array();
$doc_date_start = null;
$doc_date_end= null;
$doc_date_end = null;
$now = dol_now();
$now_arr = dol_getdate($now);
$now_month = $now_arr['mon'];
@ -173,9 +174,9 @@ class Accountancy extends DolibarrApi
$prev_month_date_list = array();
$prev_month_date_list[] = dol_get_prev_month($now_month, $now_year); // get previous month for index = 0
for ($i = 1; $i < $nb_prev_month; $i++) {
$prev_month_date_list[] = dol_get_prev_month($prev_month_date_list[$i-1]['month'], $prev_month_date_list[$i-1]['year']); // get i+1 previous month for index=i
$prev_month_date_list[] = dol_get_prev_month($prev_month_date_list[$i - 1]['month'], $prev_month_date_list[$i - 1]['year']); // get i+1 previous month for index=i
}
$doc_date_start = dol_mktime(0, 0, 0, $prev_month_date_list[$nb_prev_month-1]['month'], 1, $prev_month_date_list[$nb_prev_month-1]['year']); // first day of n previous month for index=n-1
$doc_date_start = dol_mktime(0, 0, 0, $prev_month_date_list[$nb_prev_month - 1]['month'], 1, $prev_month_date_list[$nb_prev_month - 1]['year']); // first day of n previous month for index=n-1
$doc_date_end = dol_get_last_day($prev_month_date_list[0]['year'], $prev_month_date_list[0]['month']); // last day of previous month for index = 0
} elseif ($period == 'currentyear' || $period == 'lastyear') {
$period_year = $now_year;

View file

@ -38,17 +38,17 @@ require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
class BookKeeping extends CommonObject
{
/**
* @var string Id to identify managed objects
* @var string Id to identify managed objects
*/
public $element = 'accountingbookkeeping';
/**
* @var string Name of table without prefix where object is stored
* @var string Name of table without prefix where object is stored
*/
public $table_element = 'accounting_bookkeeping';
/**
* @var int Entity
* @var int Entity
*/
public $entity;
@ -58,52 +58,52 @@ class BookKeeping extends CommonObject
public $lines = array();
/**
* @var int ID
* @var int ID
*/
public $id;
/**
* @var int Date of source document, in db date NOT NULL
* @var int Date of source document, in db date NOT NULL
*/
public $doc_date;
/**
* @var int Deadline for payment
* @var int Deadline for payment
*/
public $date_lim_reglement;
/**
* @var string doc_type
* @var string Doc type
*/
public $doc_type;
/**
* @var string doc_ref
* @var string Doc ref
*/
public $doc_ref;
/**
* @var int ID
* @var int ID
*/
public $fk_doc;
/**
* @var int ID
* @var int ID
*/
public $fk_docdet;
/**
* @var string thirdparty code
* @var string Thirdparty code
*/
public $thirdparty_code;
/**
* @var string subledger account
* @var string|null Subledger account
*/
public $subledger_account;
/**
* @var string subledger label
* @var string|null Subledger label
*/
public $subledger_label;
@ -185,12 +185,7 @@ class BookKeeping extends CommonObject
public $linesexport = array();
/**
* @var integer|string date of movement validated & lock
*/
public $date_validation;
/**
* @var integer|string date of movement who are noticed like exported
* @var int|string date of movement who are noticed like exported
*/
public $date_export;
@ -334,7 +329,7 @@ class BookKeeping extends CommonObject
// WARNING: This is not reliable, label may have been modified. This is just a small protection.
// The page that make transfer make the test on couple (doc_type - fk_doc) only.
$sql = "SELECT count(*) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " FROM ".$this->db->prefix().$this->table_element;
$sql .= " WHERE doc_type = '".$this->db->escape($this->doc_type)."'";
$sql .= " AND fk_doc = ".((int) $this->fk_doc);
if (getDolGlobalString('ACCOUNTANCY_ENABLE_FKDOCDET')) {
@ -352,7 +347,7 @@ class BookKeeping extends CommonObject
if ($row->nb == 0) { // Not already into bookkeeping
// Check to know if piece_num already exists for data we try to insert to reuse the same value
$sqlnum = "SELECT piece_num";
$sqlnum .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
$sqlnum .= " FROM ".$this->db->prefix().$this->table_element;
$sqlnum .= " WHERE doc_type = '".$this->db->escape($this->doc_type)."'"; // For example doc_type = 'bank'
$sqlnum .= " AND fk_doc = ".((int) $this->fk_doc);
if (getDolGlobalString('ACCOUNTANCY_ENABLE_FKDOCDET')) {
@ -372,7 +367,7 @@ class BookKeeping extends CommonObject
dol_syslog(get_class($this)."::create this->piece_num=".$this->piece_num, LOG_DEBUG);
if (empty($this->piece_num)) {
$sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum";
$sqlnum .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
$sqlnum .= " FROM ".$this->db->prefix().$this->table_element;
$sqlnum .= " WHERE entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
$resqlnum = $this->db->query($sqlnum);
@ -388,7 +383,7 @@ class BookKeeping extends CommonObject
$now = dol_now();
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." (";
$sql = "INSERT INTO ".$this->db->prefix().$this->table_element." (";
$sql .= "doc_date";
$sql .= ", date_lim_reglement";
$sql .= ", doc_type";
@ -413,7 +408,7 @@ class BookKeeping extends CommonObject
$sql .= ', entity';
$sql .= ") VALUES (";
$sql .= "'".$this->db->idate($this->doc_date)."'";
$sql .= ", ".(!isset($this->date_lim_reglement) || dol_strlen($this->date_lim_reglement) == 0 ? 'NULL' : "'".$this->db->idate($this->date_lim_reglement)."'");
$sql .= ", ".(isDolTms($this->date_lim_reglement) ? "'".$this->db->idate($this->date_lim_reglement)."'" : 'NULL');
$sql .= ", '".$this->db->escape($this->doc_type)."'";
$sql .= ", '".$this->db->escape($this->doc_ref)."'";
$sql .= ", ".((int) $this->fk_doc);
@ -438,7 +433,7 @@ class BookKeeping extends CommonObject
$resql = $this->db->query($sql);
if ($resql) {
$id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
$id = $this->db->last_insert_id($this->db->prefix().$this->table_element);
if ($id > 0) {
$this->id = $id;
@ -468,15 +463,13 @@ class BookKeeping extends CommonObject
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) {
@ -662,7 +655,7 @@ class BookKeeping extends CommonObject
$this->journal_label = $langs->trans($this->journal_label);
// Insert request
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.$mode.' (';
$sql = 'INSERT INTO '.$this->db->prefix().$this->table_element.$mode.' (';
$sql .= 'doc_date,';
$sql .= 'date_lim_reglement,';
$sql .= 'doc_type,';
@ -686,8 +679,8 @@ class BookKeeping extends CommonObject
$sql .= 'piece_num,';
$sql .= 'entity';
$sql .= ') VALUES (';
$sql .= ' '.(!isset($this->doc_date) || dol_strlen($this->doc_date) == 0 ? 'NULL' : "'".$this->db->idate($this->doc_date)."'").',';
$sql .= ' '.(!isset($this->date_lim_reglement) || dol_strlen($this->date_lim_reglement) == 0 ? 'NULL' : "'".$this->db->idate($this->date_lim_reglement)."'").',';
$sql .= ' '.(isDolTms($this->doc_date) ? "'".$this->db->idate($this->doc_date)."'" : 'NULL').',';
$sql .= ' '.(isDolTms($this->date_lim_reglement) ? "'".$this->db->idate($this->date_lim_reglement)."'" : 'NULL').',';
$sql .= ' '.(!isset($this->doc_type) ? 'NULL' : "'".$this->db->escape($this->doc_type)."'").',';
$sql .= ' '.(!isset($this->doc_ref) ? 'NULL' : "'".$this->db->escape($this->doc_ref)."'").',';
$sql .= ' '.(empty($this->fk_doc) ? '0' : (int) $this->fk_doc).',';
@ -720,7 +713,14 @@ class BookKeeping extends CommonObject
}
if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element.$mode);
$this->id = $this->db->last_insert_id($this->db->prefix().$this->table_element.$mode);
// Call triggers
if (! $notrigger) {
$result = $this->call_trigger('BOOKKEEPING_CREATE', $user);
if ($result < 0) {
$error++;
}
}
}
// Commit or rollback
@ -778,7 +778,7 @@ class BookKeeping extends CommonObject
$sql .= " t.date_export,";
}
$sql .= " t.date_validated as date_validation";
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.$mode.' as t';
$sql .= ' FROM '.$this->db->prefix().$this->table_element.$mode.' as t';
$sql .= ' WHERE 1 = 1';
$sql .= " AND entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
if (null !== $ref) {
@ -844,7 +844,7 @@ class BookKeeping extends CommonObject
* @param string $sortfield Sort field
* @param int $limit limit
* @param int $offset offset limit
* @param array $filter filter array
* @param array<string,string> $filter filter array
* @param string $filtermode filter mode (AND or OR)
* @param int $option option (0: general account or 1: subaccount)
* @param int $countonly Do not fill the $object->lines, return only the count.
@ -891,6 +891,7 @@ class BookKeeping extends CommonObject
$sql .= " t.date_creation,";
$sql .= " t.date_export,";
$sql .= " t.date_validated as date_validation,";
$sql .= " t.date_lim_reglement,";
$sql .= " t.import_key";
}
// Manage filter
@ -929,6 +930,10 @@ class BookKeeping extends CommonObject
$sqlwhere[] = 't.date_validated >= \''.$this->db->idate($value).'\'';
} elseif ($key == 't.date_validated<=') {
$sqlwhere[] = 't.date_validated <= \''.$this->db->idate($value).'\'';
} elseif ($key == 't.date_lim_reglement>=') {
$sqlwhere[] = 't.date_lim_reglement>=\''.$this->db->idate($value).'\'';
} elseif ($key == 't.date_lim_reglement<=') {
$sqlwhere[] = 't.date_lim_reglement<=\''.$this->db->idate($value).'\'';
} elseif ($key == 't.credit' || $key == 't.debit') {
$sqlwhere[] = natural_search($key, $value, 1, 1);
} elseif ($key == 't.reconciled_option') {
@ -946,7 +951,7 @@ class BookKeeping extends CommonObject
}
}
}
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' FROM '.$this->db->prefix().$this->table_element.' as t';
$sql .= ' WHERE entity = ' . ((int) $conf->entity); // Do not use getEntity for accounting features
if (count($sqlwhere) > 0) {
$sql .= " AND ".implode(" ".$this->db->sanitize($filtermode)." ", $sqlwhere);
@ -1013,6 +1018,8 @@ class BookKeeping extends CommonObject
$line->date_creation = $this->db->jdate($obj->date_creation);
$line->date_export = $this->db->jdate($obj->date_export);
$line->date_validation = $this->db->jdate($obj->date_validation);
// Due date
$line->date_lim_reglement = $this->db->jdate($obj->date_lim_reglement);
$line->import_key = $obj->import_key;
$this->lines[] = $line;
@ -1038,7 +1045,7 @@ class BookKeeping extends CommonObject
* @param string $sortfield Sort field
* @param int $limit Limit
* @param int $offset Offset limit
* @param string|array $filter Filter array
* @param string|array<string,string> $filter Filter array
* @param string $filtermode Filter mode (AND or OR)
* @param int $showAlreadyExportMovements Show movements when field 'date_export' is not empty (0:No / 1:Yes (Default))
* @return int Return integer <0 if KO, >0 if OK
@ -1078,7 +1085,7 @@ class BookKeeping extends CommonObject
$sql .= " t.tms as date_modification,";
$sql .= " t.date_export,";
$sql .= " t.date_validated as date_validation";
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' FROM '.$this->db->prefix().$this->table_element.' as t';
$sql .= ' WHERE t.entity = ' . ((int) $conf->entity); // Do not use getEntity for accounting features
if ($showAlreadyExportMovements == 0) {
@ -1226,7 +1233,7 @@ class BookKeeping extends CommonObject
* @param string $sortfield Sort field
* @param int $limit Limit
* @param int $offset Offset limit
* @param string|array $filter Filter
* @param string|array<string,string> $filter Filter
* @param string $filtermode Filter mode (AND or OR)
* @param int $option option (0: aggregate by general account or 1: aggreegate by subaccount)
* @return int Return integer <0 if KO, >0 if OK
@ -1247,7 +1254,7 @@ class BookKeeping extends CommonObject
}
$sql .= " SUM(t.debit) as debit,";
$sql .= " SUM(t.credit) as credit";
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' FROM '.$this->db->prefix().$this->table_element.' as t';
$sql .= ' WHERE entity = ' . ((int) $conf->entity); // Do not use getEntity for accounting features
// Manage filter
@ -1443,8 +1450,8 @@ class BookKeeping extends CommonObject
// Put here code to add a control on parameters values
// Update request
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.$mode.' SET';
$sql .= ' doc_date = '.(!isset($this->doc_date) || dol_strlen($this->doc_date) != 0 ? "'".$this->db->idate($this->doc_date)."'" : 'null').',';
$sql = 'UPDATE '.$this->db->prefix().$this->table_element.$mode.' SET';
$sql .= ' doc_date = '.(isDolTms($this->doc_date) ? "'".$this->db->idate($this->doc_date)."'" : 'null').',';
$sql .= ' doc_type = '.(isset($this->doc_type) ? "'".$this->db->escape($this->doc_type)."'" : "null").',';
$sql .= ' doc_ref = '.(isset($this->doc_ref) ? "'".$this->db->escape($this->doc_ref)."'" : "null").',';
$sql .= ' fk_doc = '.(isset($this->fk_doc) ? $this->fk_doc : "null").',';
@ -1475,15 +1482,13 @@ class BookKeeping extends CommonObject
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) {
@ -1517,7 +1522,7 @@ class BookKeeping extends CommonObject
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element.$mode;
$sql = "UPDATE ".$this->db->prefix().$this->table_element.$mode;
$sql .= " SET ".$this->db->sanitize($field)." = ".(is_numeric($value) ? ((float) $value) : "'".$this->db->escape($value)."'");
$sql .= " WHERE piece_num = ".((int) $piece_num);
$sql .= $sql_filter;
@ -1570,18 +1575,16 @@ class BookKeeping extends CommonObject
$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;
$sql = 'DELETE FROM '.$this->db->prefix().$this->table_element.$mode;
$sql .= ' WHERE rowid='.((int) $this->id);
$resql = $this->db->query($sql);
@ -1622,7 +1625,7 @@ class BookKeeping extends CommonObject
// first check if line not yet in bookkeeping
$sql = "DELETE";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode;
$sql .= " FROM ".$this->db->prefix().$this->table_element.$mode;
$sql .= " WHERE import_key = '".$this->db->escape($importkey)."'";
$sql .= $sql_filter;
@ -1670,7 +1673,7 @@ class BookKeeping extends CommonObject
// Delete record in bookkeeping
$sql = "DELETE";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode;
$sql .= " FROM ".$this->db->prefix().$this->table_element.$mode;
$sql .= " WHERE 1 = 1";
$sql .= dolSqlDateFilter('doc_date', 0, $delmonth, $delyear);
if (!empty($journal)) {
@ -1721,7 +1724,7 @@ class BookKeeping extends CommonObject
// first check if line not yet in bookkeeping
$sql = "DELETE";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode;
$sql .= " FROM ".$this->db->prefix().$this->table_element.$mode;
$sql .= " WHERE piece_num = ".(int) $piecenum;
$sql .= " AND date_validated IS NULL"; // For security, exclusion of validated entries at the time of deletion
$sql .= " AND entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
@ -1845,12 +1848,12 @@ class BookKeeping extends CommonObject
global $conf;
$sql = "SELECT piece_num, doc_date, code_journal, journal_label, doc_ref, doc_type,";
$sql .= " date_creation, tms as date_modification, date_validated as date_validation, import_key";
$sql .= " date_creation, tms as date_modification, date_validated as date_validation, date_lim_reglement, import_key";
// In llx_accounting_bookkeeping_tmp, field date_export doesn't exist
if ($mode != "_tmp") {
$sql .= ", date_export";
}
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode;
$sql .= " FROM ".$this->db->prefix().$this->table_element.$mode;
$sql .= " WHERE piece_num = ".((int) $piecenum);
$sql .= " AND entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
@ -1871,6 +1874,7 @@ class BookKeeping extends CommonObject
$this->date_export = $this->db->jdate($obj->date_export);
}
$this->date_validation = $this->db->jdate($obj->date_validation);
$this->date_lim_reglement = $this->db->jdate($obj->date_lim_reglement);
$this->import_key = $obj->import_key;
} else {
$this->error = "Error ".$this->db->lasterror();
@ -1891,7 +1895,7 @@ class BookKeeping extends CommonObject
{
global $conf;
$sql = "SELECT MAX(piece_num)+1 as max FROM ".MAIN_DB_PREFIX.$this->table_element.$mode;
$sql = "SELECT MAX(piece_num)+1 as max FROM ".$this->db->prefix().$this->table_element.$mode;
$sql .= " WHERE entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
dol_syslog(get_class($this)."::getNextNumMvt", LOG_DEBUG);
@ -1934,7 +1938,7 @@ class BookKeeping extends CommonObject
if ($mode != "_tmp") {
$sql .= ", date_export";
}
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode;
$sql .= " FROM ".$this->db->prefix().$this->table_element.$mode;
$sql .= " WHERE piece_num = ".((int) $piecenum);
$sql .= " AND entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
@ -2000,7 +2004,7 @@ class BookKeeping extends CommonObject
$sql .= " numero_compte, label_compte, label_operation, debit, credit,";
$sql .= " montant as amount, sens, fk_user_author, import_key, code_journal, piece_num,";
$sql .= " date_validated as date_validation";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " FROM ".$this->db->prefix().$this->table_element;
$sql .= " WHERE entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
dol_syslog(get_class($this)."::export_bookkeeping", LOG_DEBUG);
@ -2079,7 +2083,7 @@ class BookKeeping extends CommonObject
if (!$error) {
// Delete if there is an empty line
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity)." AND numero_compte IS NULL AND debit = 0 AND credit = 0";
$sql = 'DELETE FROM '.$this->db->prefix().$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity)." AND numero_compte IS NULL AND debit = 0 AND credit = 0";
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
@ -2089,7 +2093,7 @@ class BookKeeping extends CommonObject
}
if (!$error) {
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.' (doc_date, doc_type,';
$sql = 'INSERT INTO '.$this->db->prefix().$this->table_element.' (doc_date, doc_type,';
$sql .= ' doc_ref, fk_doc, fk_docdet, entity, thirdparty_code, subledger_account, subledger_label,';
$sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num, date_creation)';
@ -2097,7 +2101,7 @@ class BookKeeping extends CommonObject
$sql .= ' doc_ref, fk_doc, fk_docdet, entity, thirdparty_code, subledger_account, subledger_label,';
$sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, '.((int) $next_piecenum).", '".$this->db->idate($now)."'";
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND numero_compte IS NOT NULL AND entity = ' .((int) $conf->entity);
$sql .= ' FROM '.$this->db->prefix().$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND numero_compte IS NOT NULL AND entity = ' .((int) $conf->entity);
$sql .= $sql_filter;
$resql = $this->db->query($sql);
if (!$resql) {
@ -2108,7 +2112,7 @@ class BookKeeping extends CommonObject
}
if (!$error) {
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
$sql = 'DELETE FROM '.$this->db->prefix().$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
@ -2118,7 +2122,7 @@ class BookKeeping extends CommonObject
}
} elseif ($direction == 1) {
if (!$error) {
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
$sql = 'DELETE FROM '.$this->db->prefix().$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
@ -2128,7 +2132,7 @@ class BookKeeping extends CommonObject
}
if (!$error) {
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.'_tmp (doc_date, doc_type,';
$sql = 'INSERT INTO '.$this->db->prefix().$this->table_element.'_tmp (doc_date, doc_type,';
$sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,';
$sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num)';
@ -2136,7 +2140,7 @@ class BookKeeping extends CommonObject
$sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,';
$sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num';
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
$sql .= ' FROM '.$this->db->prefix().$this->table_element.' WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
$sql .= $sql_filter;
$resql = $this->db->query($sql);
if (!$resql) {
@ -2147,7 +2151,7 @@ class BookKeeping extends CommonObject
}
if (!$error) {
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
$sql = 'DELETE FROM '.$this->db->prefix().$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
$sql .= $sql_filter;
$resql = $this->db->query($sql);
if (!$resql) {
@ -2166,10 +2170,10 @@ class BookKeeping extends CommonObject
}
/*
$sql = "DELETE FROM ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = ab.numero_compte";
$sql .= " FROM " . $this->db->prefix() . "accounting_bookkeeping as ab";
$sql .= " LEFT JOIN " . $this->db->prefix() . "accounting_account as aa ON aa.account_number = ab.numero_compte";
$sql .= " AND aa.active = 1";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " INNER JOIN " . $this->db->prefix() . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND asy.rowid = " . ((int) $pcgver);
$sql .= " AND ab.entity IN (" . getEntity('accountancy') . ")";
$sql .= " ORDER BY account_number ASC";
@ -2182,11 +2186,11 @@ class BookKeeping extends CommonObject
*
* @param string $selectid Preselected chart of accounts
* @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field
* @param array $event Event options
* @param int<0,1> $showempty Add an empty field
* @param array<array{method:string,url:string,htmlname:string,params:array<string,string>}> $event Event options
* @param int $select_in Value is a aa.rowid (0 default) or aa.account_number (1)
* @param int $select_out Set value returned by select 0=rowid (default), 1=account_number
* @param string $aabase Set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by this number
* @param string $aabase Set accounting_account base class to display empty=all or from 1 to 8 will display only account starting from this number
* @return string|int String with HTML select or -1 if KO
*/
public function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '')
@ -2199,10 +2203,10 @@ class BookKeeping extends CommonObject
$pcgver = getDolGlobalInt('CHARTOFACCOUNTS');
$sql = "SELECT DISTINCT ab.numero_compte as account_number, aa.label as label, aa.rowid as rowid, aa.fk_pcg_version";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.account_number = ab.numero_compte";
$sql .= " FROM ".$this->db->prefix().$this->table_element." as ab";
$sql .= " LEFT JOIN ".$this->db->prefix()."accounting_account as aa ON aa.account_number = ab.numero_compte";
$sql .= " AND aa.active = 1";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " INNER JOIN ".$this->db->prefix()."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND asy.rowid = ".((int) $pcgver);
$sql .= " AND ab.entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
$sql .= " ORDER BY account_number ASC";
@ -2253,7 +2257,7 @@ class BookKeeping extends CommonObject
* FIXME: This function takes the parent of parent to get the root account !
*
* @param string $account Accounting account
* @return array|int Array with root account information (max 2 upper level), <0 if KO
* @return array{id:int,account_number:string,label:string}|int<-1,-1> Array with root account information (max 2 upper level), <0 if KO
*/
public function getRootAccount($account = null)
{
@ -2262,11 +2266,11 @@ class BookKeeping extends CommonObject
$sql = "SELECT root.rowid, root.account_number, root.label as label,";
$sql .= " parent.rowid as parent_rowid, parent.account_number as parent_account_number, parent.label as parent_label";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " FROM ".$this->db->prefix()."accounting_account as aa";
$sql .= " INNER JOIN ".$this->db->prefix()."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND asy.rowid = ".((int) $pcgver);
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as parent ON aa.account_parent = parent.rowid AND parent.active = 1";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as root ON parent.account_parent = root.rowid AND root.active = 1";
$sql .= " LEFT JOIN ".$this->db->prefix()."accounting_account as parent ON aa.account_parent = parent.rowid AND parent.active = 1";
$sql .= " LEFT JOIN ".$this->db->prefix()."accounting_account as root ON parent.account_parent = root.rowid AND root.active = 1";
$sql .= " WHERE aa.account_number = '".$this->db->escape($account)."'";
$sql .= " AND aa.entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
@ -2302,12 +2306,12 @@ class BookKeeping extends CommonObject
$pcgver = getDolGlobalInt('CHARTOFACCOUNTS');
$sql = "SELECT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version, cat.label as category";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa ";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " FROM ".$this->db->prefix()."accounting_account as aa ";
$sql .= " INNER JOIN ".$this->db->prefix()."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND aa.account_number = '".$this->db->escape($account)."'";
$sql .= " AND asy.rowid = ".((int) $pcgver);
$sql .= " AND aa.active = 1";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid";
$sql .= " LEFT JOIN ".$this->db->prefix()."c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid";
$sql .= " WHERE aa.entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
dol_syslog(get_class($this)."::select_account", LOG_DEBUG);
@ -2341,7 +2345,7 @@ class BookKeeping extends CommonObject
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');
@ -2427,6 +2431,47 @@ class BookKeeping extends CommonObject
}
}
/**
* 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) ?
*
@ -2575,7 +2620,7 @@ class BookKeeping extends CommonObject
*
* @param int $date_start Date start
* @param int $date_end Date end
* @return array|int Return integer <0 if KO, Fiscal periods : [[id, date_start, date_end, label], ...]
* @return array{total:int,list:array<array{year:int,count:array<int<1,12>,int>,total:int}>}|int<-1,-1> Return integer <0 if KO, Fiscal periods : [[id, date_start, date_end, label], ...]
*/
public function getCountByMonthForFiscalPeriod($date_start, $date_end)
{
@ -2587,7 +2632,7 @@ class BookKeeping extends CommonObject
$sql .= ", SUM(".$this->db->ifsql("MONTH(b.doc_date) = ".((int) $i), "1", "0") . ") AS month".((int) $i);
}
$sql .= ", COUNT(b.rowid) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as b";
$sql .= " FROM " . $this->db->prefix() . $this->table_element . " as b";
$sql .= " WHERE b.doc_date >= '" . $this->db->idate($date_start) . "'";
$sql .= " AND b.doc_date <= '" . $this->db->idate($date_end) . "'";
$sql .= " AND b.entity IN (" . getEntity('bookkeeping', 0) . ")"; // We don't share object for accountancy
@ -2648,7 +2693,7 @@ class BookKeeping extends CommonObject
$now = dol_now();
// Specify as export : update field date_validated on selected month/year
$sql = " UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping";
$sql = " UPDATE " . $this->db->prefix() . $this->table_element;
$sql .= " SET date_validated = '" . $this->db->idate($now) . "'";
$sql .= " WHERE entity = " . ((int) $conf->entity);
$sql .= " AND DATE(doc_date) >= '" . $this->db->idate($date_start) . "'";
@ -2692,11 +2737,11 @@ class BookKeeping extends CommonObject
$sql .= " t.numero_compte,";
$sql .= " aa.pcg_type,";
$sql .= " (SUM(t.credit) - SUM(t.debit)) as accounting_result";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'accounting_account as aa ON aa.account_number = t.numero_compte';
$sql .= ' FROM ' . $this->db->prefix() . $this->table_element . ' as t';
$sql .= ' LEFT JOIN ' . $this->db->prefix() . 'accounting_account as aa ON aa.account_number = t.numero_compte';
$sql .= ' WHERE t.entity = ' . ((int) $conf->entity); // Do not use getEntity for accounting features
$sql .= " AND aa.entity = " . ((int) $conf->entity);
$sql .= ' AND aa.fk_pcg_version IN (SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid = ' . ((int) getDolGlobalInt('CHARTOFACCOUNTS')) . ')';
$sql .= ' AND aa.fk_pcg_version IN (SELECT pcg_version FROM ' . $this->db->prefix() . 'accounting_system WHERE rowid = ' . ((int) getDolGlobalInt('CHARTOFACCOUNTS')) . ')';
$sql .= ' AND aa.pcg_type IN (' . $this->db->sanitize(implode(',', $pcg_type_filter), 1) . ')';
$sql .= " AND DATE(t.doc_date) >= '" . $this->db->idate($date_start) . "'";
$sql .= " AND DATE(t.doc_date) <= '" . $this->db->idate($date_end) . "'";
@ -2800,9 +2845,11 @@ class BookKeeping extends CommonObject
$this->errors[] = $langs->trans('ErrorRecordNotFound') . ' - ' . $langs->trans('Codejournal') . ' (' . $langs->trans('AccountingJournalType9') . ')';
$error++;
}
} else {
$journal = null;
}
if (!$error) {
if (!$error && is_object($journal)) {
$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');
@ -2821,11 +2868,11 @@ class BookKeeping extends CommonObject
}
$sql .= " aa.pcg_type,";
$sql .= " (SUM(t.credit) - SUM(t.debit)) as opening_balance";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'accounting_account as aa ON aa.account_number = t.numero_compte';
$sql .= ' FROM ' . $this->db->prefix() . $this->table_element . ' as t';
$sql .= ' LEFT JOIN ' . $this->db->prefix() . 'accounting_account as aa ON aa.account_number = t.numero_compte';
$sql .= ' WHERE t.entity = ' . ((int) $conf->entity); // Do not use getEntity for accounting features
$sql .= " AND aa.entity = ". ((int) $conf->entity);
$sql .= ' AND aa.fk_pcg_version IN (SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid = '.((int) getDolGlobalInt('CHARTOFACCOUNTS')).')';
$sql .= ' AND aa.fk_pcg_version IN (SELECT pcg_version FROM '.$this->db->prefix().'accounting_system WHERE rowid = '.((int) getDolGlobalInt('CHARTOFACCOUNTS')).')';
$sql .= ' AND aa.pcg_type IN (' . $this->db->sanitize(implode(',', $pcg_type_filter), 1) . ')';
$sql .= " AND DATE(t.doc_date) >= '" . $this->db->idate($fiscal_period->date_start) . "'";
$sql .= " AND DATE(t.doc_date) <= '" . $this->db->idate($fiscal_period->date_end) . "'";
@ -2896,7 +2943,7 @@ class BookKeeping extends CommonObject
if (!$error && $income_statement_amount != 0) {
$mt = $income_statement_amount;
$accountingaccount = new AccountingAccount($this->db);
$accountingaccount->fetch(null, getDolGlobalString($income_statement_amount < 0 ? 'ACCOUNTING_RESULT_LOSS' : 'ACCOUNTING_RESULT_PROFIT'), true);
$accountingaccount->fetch(0, getDolGlobalString($income_statement_amount < 0 ? 'ACCOUNTING_RESULT_LOSS' : 'ACCOUNTING_RESULT_PROFIT'), true);
$bookkeeping = new BookKeeping($this->db);
$bookkeeping->doc_date = $new_fiscal_period->date_start;
@ -3027,7 +3074,7 @@ class BookKeeping extends CommonObject
$this->db->begin();
$sql = 'SELECT t.rowid';
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
$sql .= ' FROM ' . $this->db->prefix() . $this->table_element . ' as t';
$sql .= ' WHERE t.entity = ' . ((int) $conf->entity); // Do not use getEntity for accounting features
$sql .= " AND code_journal = '" . $this->db->escape($inventory_journal->code) . "'";
$sql .= " AND DATE(t.doc_date) >= '" . $this->db->idate($date_start) . "'";
@ -3106,8 +3153,18 @@ class BookKeepingLine extends CommonObjectLine
*/
public $id;
/**
* @var ?int Date of source document
*/
public $doc_date = null;
/**
* @var string Doc type
*/
public $doc_type;
/**
* @var string Doc ref
*/
public $doc_ref;
/**
@ -3120,13 +3177,44 @@ class BookKeepingLine extends CommonObjectLine
*/
public $fk_docdet;
/**
* @var string Thirdparty code
*/
public $thirdparty_code;
/**
* @var string|null Subledger account
*/
public $subledger_account;
/**
* @var string|null Subledger label
*/
public $subledger_label;
/**
* @var string doc_type
*/
public $numero_compte;
/**
* @var string label compte
*/
public $label_compte;
/**
* @var string label operation
*/
public $label_operation;
/**
* @var float FEC:Debit
*/
public $debit;
/**
* @var float FEC:Credit
*/
public $credit;
/**
@ -3154,7 +3242,15 @@ class BookKeepingLine extends CommonObjectLine
* @var string Sens
*/
public $sens;
/**
* @var ?string
*/
public $lettering_code;
/**
* @var string
*/
public $date_lettering;
/**
@ -3162,8 +3258,20 @@ class BookKeepingLine extends CommonObjectLine
*/
public $fk_user_author;
/**
* @var string key for import
*/
public $import_key;
/**
* @var string
*/
public $code_journal;
/**
* @var string
*/
public $journal_label;
/**
* @var int accounting transaction id
@ -3171,27 +3279,12 @@ class BookKeepingLine extends CommonObjectLine
public $piece_num;
/**
* @var integer|string date_creation
*/
public $date_creation;
/**
* @var integer|string $date_modification;
*/
public $date_modification;
/**
* @var integer|string $date_export;
* @var int|string $date_export;
*/
public $date_export;
/**
* @var integer|string $date_validation;
*/
public $date_validation;
/**
* @var integer|string $date_lim_reglement;
* @var int|string $date_lim_reglement;
*/
public $date_lim_reglement;
}

View file

@ -1,8 +1,9 @@
<?php
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2023 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2013-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -33,6 +34,9 @@ include_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php";
*/
class Lettering extends BookKeeping
{
/**
* @var array<string,array{payment_table:string,payment_table_fk_bank:string,doc_payment_table:string,doc_payment_table_fk_payment:string,doc_payment_table_fk_doc:string,linked_info:array<array{table:string,fk_doc:string,fk_link:string,prefix:string,fk_line_link?:string,table_link_line?:string,fk_table_link_line?:string,fk_table_link_line_parent?:string,is_fk_link_is_also_fk_doc?:bool}>}>
*/
public static $doc_type_infos = array(
'customer_invoice' => array(
'payment_table' => 'paiement',
@ -289,90 +293,151 @@ class Lettering extends BookKeeping
/**
*
* @param array $ids ids array
* @param int[] $ids ids array
* @param int $notrigger no trigger
* @param bool $partial Partial lettering
* @return int
*/
public function updateLettering($ids = array(), $notrigger = 0)
public function updateLettering($ids = array(), $notrigger = 0, $partial = false)
{
$error = 0;
// Generate a string with n char A where n is ACCOUNTING_LETTERING_NBLETTERS (So 'AA', 'AAA', ...) @phan-suppress-next-line PhanParamSuspiciousOrder
$lettre = str_pad("", getDolGlobalInt('ACCOUNTING_LETTERING_NBLETTERS', 3), "A");
$sql = "SELECT DISTINCT ab2.lettering_code";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab2 ON ab2.subledger_account = ab.subledger_account";
$sql .= " WHERE ab.rowid IN (" . $this->db->sanitize(implode(',', $ids)) . ")";
$sql .= " AND ab2.lettering_code != ''";
$sql .= " ORDER BY ab2.lettering_code DESC";
$sql .= " LIMIT 1 ";
$resqla = $this->db->query($sql);
if ($resqla) {
$obj = $this->db->fetch_object($resqla);
$lettre = (empty($obj->lettering_code) ? $lettre : $obj->lettering_code);
if (!empty($obj->lettering_code)) {
$lettre++;
}
$this->db->free($resqla);
} else {
$this->errors[] = 'Error'.$this->db->lasterror();
$error++;
}
$sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE ";
$sql .= " rowid IN (".$this->db->sanitize(implode(',', $ids)).") AND lettering_code IS NULL AND subledger_account != ''";
$resqlb = $this->db->query($sql);
if ($resqlb) {
$obj = $this->db->fetch_object($resqlb);
if (!(round(abs($obj->deb), 2) === round(abs($obj->cred), 2))) {
$this->errors[] = 'Total not exacts '.round(abs($obj->deb), 2).' vs '.round(abs($obj->cred), 2);
$error++;
}
$this->db->free($resqlb);
} else {
$this->errors[] = 'Erreur sql'.$this->db->lasterror();
$error++;
}
// Update request
$now = dol_now();
$error = 0;
$affected_rows = 0;
if (!$error) {
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping SET";
$sql .= " lettering_code='".$this->db->escape($lettre)."'";
$sql .= ", date_lettering = '".$this->db->idate($now)."'"; // todo correct date it's false
$sql .= " WHERE rowid IN (".$this->db->sanitize(implode(',', $ids)).") AND lettering_code IS NULL AND subledger_account != ''";
// Generate a string with n char 'A' (for manual/auto reconcile) or 'a' (for partial reconcile) where n is ACCOUNTING_LETTERING_NBLETTERS (So 'AA'/'aa', 'AAA'/'aaa', ...) @phan-suppress-next-line PhanParamSuspiciousOrder
$letter = str_pad("", getDolGlobalInt('ACCOUNTING_LETTERING_NBLETTERS', 3), $partial ? 'a' : 'A');
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$this->db->begin();
// Check partial / normal lettering case
$sql = "SELECT ab.lettering_code, GROUP_CONCAT(DISTINCT ab.rowid SEPARATOR ',') AS bookkeeping_ids";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab";
$sql .= " WHERE ab.rowid IN (" . $this->db->sanitize(implode(',', $ids)) . ")";
$sql .= " GROUP BY ab.lettering_code";
$sql .= " ORDER BY ab.lettering_code DESC";
dol_syslog(__METHOD__ . " - Check partial / normal lettering case", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
while ($obj = $this->db->fetch_object($resql)) {
if (empty($obj->lettering_code)) {
continue;
}
// Remove normal lettering code if set partial lettering
if ($partial && preg_match('/^[A-Z]+$/', $obj->lettering_code)) {
if (!empty($obj->bookkeeping_ids)) {
$ids = array_diff($ids, explode(',', $obj->bookkeeping_ids));
}
} elseif (!$partial && preg_match('/^[a-z]+$/', $obj->lettering_code)) {
// Delete partial lettering code if set normal lettering
$sql2 = "UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping SET";
$sql2 .= " lettering_code = NULL";
$sql2 .= ", date_lettering = NULL";
$sql2 .= " WHERE entity IN (" . getEntity('accountancy') . ")";
$sql2 .= " AND lettering_code = '" . $this->db->escape($obj->lettering_code) . "'";
dol_syslog(__METHOD__ . " - Remove partial lettering", LOG_DEBUG);
$resql2 = $this->db->query($sql2);
if (!$resql2) {
$this->errors[] = 'Error' . $this->db->lasterror();
$error++;
break;
}
}
}
$this->db->free($resql);
} else {
$this->errors[] = 'Error' . $this->db->lasterror();
$error++;
}
if (!$error && !empty($ids)) {
// Get next code
$sql = "SELECT DISTINCT ab2.lettering_code";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab2 ON ab2.subledger_account = ab.subledger_account";
$sql .= " WHERE ab.rowid IN (" . $this->db->sanitize(implode(',', $ids)) . ")";
$sql .= " AND ab2.lettering_code != ''";
$sql .= " ORDER BY ab2.lettering_code DESC";
dol_syslog(__METHOD__ . " - Get next code", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
$this->errors[] = "Error ".$this->db->lasterror();
if ($resql) {
while ($obj = $this->db->fetch_object($resql)) {
if (!empty($obj->lettering_code) &&
(($partial && preg_match('/^[a-z]+$/', $obj->lettering_code)) ||
(!$partial && preg_match('/^[A-Z]+$/', $obj->lettering_code)))
) {
$letter = $obj->lettering_code;
$letter++;
break;
}
}
$this->db->free($resql);
} else {
$affected_rows = $this->db->affected_rows($resql);
$this->errors[] = 'Error' . $this->db->lasterror();
$error++;
}
// Test amount integrity
if (!$error && !$partial) {
$sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE ";
$sql .= " rowid IN (" . $this->db->sanitize(implode(',', $ids)) . ") AND lettering_code IS NULL AND subledger_account != ''";
dol_syslog(__METHOD__ . " - Test amount integrity", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
if ($obj = $this->db->fetch_object($resql)) {
if (!(round(abs($obj->deb), 2) === round(abs($obj->cred), 2))) {
$this->errors[] = 'Total not exacts ' . round(abs($obj->deb), 2) . ' vs ' . round(abs($obj->cred), 2);
$error++;
}
}
$this->db->free($resql);
} else {
$this->errors[] = 'Erreur sql' . $this->db->lasterror();
$error++;
}
}
// Update lettering code
if (!$error) {
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping SET";
$sql .= " lettering_code='" . $this->db->escape($letter) . "'";
$sql .= ", date_lettering = '" . $this->db->idate($now) . "'"; // todo correct date it's false
$sql .= " WHERE rowid IN (" . $this->db->sanitize(implode(',', $ids)) . ") AND lettering_code IS NULL AND subledger_account != ''";
dol_syslog(__METHOD__ . " - Update lettering code", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
$this->errors[] = "Error " . $this->db->lasterror();
} else {
$affected_rows = $this->db->affected_rows($resql);
}
}
}
// Commit or rollback
if ($error) {
$this->db->rollback();
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
dol_syslog(get_class($this) . "::update " . $errmsg, LOG_ERR);
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
}
return -1 * $error;
} else {
$this->db->commit();
return $affected_rows;
}
}
/**
*
* @param array $ids ids array
* @param int[] $ids ids array
* @param int $notrigger no trigger
* @return int
* @return int Nb of affectd rows or <0 if error
*/
public function deleteLettering($ids, $notrigger = 0)
{
@ -406,7 +471,7 @@ class Lettering extends BookKeeping
/**
* Lettering bookkeeping lines all types
*
* @param array $bookkeeping_ids Lettering specific list of bookkeeping id
* @param int[] $bookkeeping_ids Lettering specific list of bookkeeping id
* @param bool $unlettering Do unlettering
* @return int Return integer <0 if error (nb lettered = result -1), 0 if noting to lettering, >0 if OK (nb lettered)
*/
@ -438,7 +503,7 @@ class Lettering extends BookKeeping
/**
* Lettering bookkeeping lines
*
* @param array $bookkeeping_ids Lettering specific list of bookkeeping id
* @param int[] $bookkeeping_ids Lettering specific list of bookkeeping id
* @param bool $unlettering Do unlettering
* @return int Return integer <0 if error (nb lettered = result -1), 0 if noting to lettering, >0 if OK (nb lettered)
*/
@ -524,9 +589,9 @@ class Lettering extends BookKeeping
/**
* Lettering bookkeeping lines
*
* @param array $bookkeeping_ids Lettering specific list of bookkeeping id
* @param int[] $bookkeeping_ids Lettering specific list of bookkeeping id
* @param bool $only_has_subledger_account Get only lines who have subledger account
* @return array|int Return integer <0 if error otherwise all linked lines by block
* @return int<-1,-1>|array<array<int,array{id:int,piece_num:int,debit:int|float,credit:int|float,lettering_code:string}>> Return integer <0 if error otherwise all linked lines by block
*/
public function getLinkedLines($bookkeeping_ids, $only_has_subledger_account = true)
{
@ -662,8 +727,8 @@ class Lettering extends BookKeeping
/**
* Get all fk_doc by doc_type from list of bank ids
*
* @param array $bank_ids List of bank ids
* @return array|int Return integer <0 if error otherwise all fk_doc by doc_type
* @param int[] $bank_ids List of bank ids
* @return array<string,array<int,int>>|int Return integer <0 if error otherwise all fk_doc by doc_type
*/
public function getDocTypeAndFkDocFromBankLines($bank_ids)
{
@ -704,9 +769,9 @@ class Lettering extends BookKeeping
/**
* Get all bank ids from list of document ids of a type
*
* @param array $document_ids List of document id
* @param array<string,int[]> $document_ids List of document id
* @param string $doc_type Type of document ('customer_invoice' or 'supplier_invoice', ...)
* @return array|int Return integer <0 if error otherwise all all bank ids from list of document ids of a type
* @return array<int,int>|int<-1,-1> Return integer <0 if error otherwise all all bank ids from list of document ids of a type
*/
public function getBankLinesFromFkDocAndDocType($document_ids, $doc_type)
{
@ -737,6 +802,7 @@ class Lettering extends BookKeeping
$sql = "SELECT DISTINCT p." . $this->db->sanitize($doc_type_info['payment_table_fk_bank']) . " AS fk_doc";
$sql .= " FROM " . MAIN_DB_PREFIX . $this->db->sanitize($doc_type_info['payment_table']) . " AS p";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $this->db->sanitize($doc_type_info['doc_payment_table']) . " AS dp ON dp." . $this->db->sanitize($doc_type_info['doc_payment_table_fk_payment']) . " = p.rowid";
// Implode used on array of int @phan-suppress-next-line PhanTypeMismatchArgumentInternal
$sql .= " WHERE dp." . $this->db->sanitize($doc_type_info['doc_payment_table_fk_doc']) . " IN (" . $this->db->sanitize(implode(',', $document_ids)) . ")";
$sql .= " AND p." . $this->db->sanitize($doc_type_info['payment_table_fk_bank']) . " > 0";
@ -758,9 +824,9 @@ class Lettering extends BookKeeping
/**
* Get all linked document ids by group and type
*
* @param array $document_ids List of document id
* @param int[] $document_ids List of document id
* @param string $doc_type Type of document ('customer_invoice' or 'supplier_invoice', ...)
* @return array|int Return integer <0 if error otherwise all linked document ids by group and type [ [ 'doc_type' => [ doc_id, ... ], ... ], ... ]
* @return array<int,array<int,int>>|int<-1,-1> Return integer <0 if error otherwise all linked document ids by group and type [ [ 'doc_type' => [ doc_id, ... ], ... ], ... ]
*/
public function getLinkedDocumentByGroup($document_ids, $doc_type)
{
@ -846,11 +912,11 @@ class Lettering extends BookKeeping
/**
* Get element ids grouped by link or element in common
*
* @param array $link_by_element List of payment ids by link key
* @param array $element_by_link List of element ids by link key
* @param string $link_key Link key (used for recursive function)
* @param array $current_group Current group (used for recursive function)
* @return array List of element ids grouped by link or element in common
* @param array<array<string,int>> $link_by_element List of payment ids by link key
* @param array<string,array<int,int>> $element_by_link List of element ids by link key
* @param string $link_key Link key (used for recursive function)
* @param array<int,int> $current_group Current group (used for recursive function)
* @return array<int,array<int,int>> List of element ids grouped by link or element in common
*/
public function getGroupElements(&$link_by_element, &$element_by_link, $link_key = '', &$current_group = array())
{
@ -860,8 +926,9 @@ class Lettering extends BookKeeping
return $grouped_elements;
}
if (empty($link_key)) {
// Save list when is the begin of recursive function
// Save list when is the first step of the recursive recursive function
$save_link_by_element = $link_by_element;
$save_element_by_link = $element_by_link;
}
@ -900,8 +967,8 @@ class Lettering extends BookKeeping
if (empty($link_key)) {
// Restore list when is the begin of recursive function
$link_by_element = $save_link_by_element;
$element_by_link = $save_element_by_link;
$link_by_element = $save_link_by_element; // @phan-suppress-current-line PhanPossiblyUndeclaredVariable
$element_by_link = $save_element_by_link; // @phan-suppress-current-line PhanPossiblyUndeclaredVariable
}
return $grouped_elements;

View file

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2019-2023 Open-DSI <support@open-dsi.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -49,7 +50,7 @@ if (!$user->hasRight('accounting', 'fiscalyear', 'write')) {
accessforbidden();
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
$hookmanager->initHooks(array('accountancyclosure'));
$object = new BookKeeping($db);
@ -126,8 +127,8 @@ if ($reshook < 0) {
}
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'));
@ -142,7 +143,7 @@ if (empty($reshook)) {
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');
@ -169,7 +170,7 @@ if (empty($reshook)) {
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'));
@ -200,7 +201,7 @@ $title = $langs->trans('Closure');
$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#Cl.C3.B4ture_annuelle';
llxHeader('', $title, $help_url);
llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-accountancy page-closure-index');
$formconfirm = '';
@ -292,7 +293,7 @@ if (isset($current_fiscal_period)) {
'name' => 'date_start',
'type' => 'date',
'label' => $langs->trans('DateStart'),
'value' => dol_time_plus_duree($current_fiscal_period['date_end'], -1, 'm')
'value' => dol_time_plus_duree((int) $current_fiscal_period['date_end'], -1, 'm')
);
$form_question['date_end'] = array(
'name' => 'date_end',

View file

@ -4,6 +4,7 @@
* Copyright (C) 2013-2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This 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,7 +64,7 @@ $year_current = $year_start;
// Validate History
$action = GETPOST('action', 'aZ09');
$chartaccountcode = dol_getIdFromCode($db, getDolGlobalInt('CHARTOFACCOUNTS'), 'accounting_system', 'rowid', 'pcg_version');
$chartaccountcode = dol_getIdFromCode($db, getDolGlobalString('CHARTOFACCOUNTS'), 'accounting_system', 'rowid', 'pcg_version');
// Security check
if (!isModEnabled('accounting')) {

View file

@ -6,6 +6,8 @@
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -101,13 +103,13 @@ if (!$sortorder) {
}
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
$hookmanager->initHooks(array('accountancycustomerlist'));
$formaccounting = new FormAccounting($db);
$accountingAccount = new AccountingAccount($db);
$chartaccountcode = dol_getIdFromCode($db, getDolGlobalInt('CHARTOFACCOUNTS'), 'accounting_system', 'rowid', 'pcg_version');
$chartaccountcode = dol_getIdFromCode($db, getDolGlobalString('CHARTOFACCOUNTS'), 'accounting_system', 'rowid', 'pcg_version');
// Security check
if (!isModEnabled('accounting')) {
@ -549,6 +551,8 @@ if ($result) {
$accountingaccount_codetotid_cache = array();
$suggestedaccountingaccountfor = ''; // Initialise (for static analysis)
$suggestedaccountingaccountbydefaultfor = '';
while ($i < min($num_lines, $limit)) {
$objp = $db->fetch_object($result);

View file

@ -3,6 +3,7 @@
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -58,7 +59,7 @@ $year_current = $year_start;
// Validate History
$action = GETPOST('action', 'aZ09');
$chartaccountcode = dol_getIdFromCode($db, getDolGlobalInt('CHARTOFACCOUNTS'), 'accounting_system', 'rowid', 'pcg_version');
$chartaccountcode = dol_getIdFromCode($db, getDolGlobalString('CHARTOFACCOUNTS'), 'accounting_system', 'rowid', 'pcg_version');
// Security check
if (!isModEnabled('accounting')) {

View file

@ -423,7 +423,7 @@ if ($result) {
// Fees description -- Can be null
print '<td>';
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments, 1));
$trunclength = getDolGlobalString('ACCOUNTING_LENGTH_DESCRIPTION', 32);
$trunclength = getDolGlobalInt('ACCOUNTING_LENGTH_DESCRIPTION', 32);
print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->comments);
print '</td>';

View file

@ -95,13 +95,13 @@ if (!$sortorder) {
}
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
$hookmanager->initHooks(array('accountancyexpensereportlist'));
$formaccounting = new FormAccounting($db);
$accounting = new AccountingAccount($db);
$chartaccountcode = dol_getIdFromCode($db, getDolGlobalInt('CHARTOFACCOUNTS'), 'accounting_system', 'rowid', 'pcg_version');
$chartaccountcode = dol_getIdFromCode($db, getDolGlobalString('CHARTOFACCOUNTS'), 'accounting_system', 'rowid', 'pcg_version');
// Security check
if (!isModEnabled('accounting')) {

View file

@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
// Load translation files required by the page
$langs->loadLangs(array("compta", "bills", "other", "accountancy", "loans", "banks", "admin", "dict"));
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks
// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array of hooks
$hookmanager->initHooks(array('accountancyindex'));
// Security check

View file

@ -1,18 +1,18 @@
<?php
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013-2022 Open-DSI <support@open-dsi.fr>
* Copyright (C) 2013-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2017-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018-2024 Eric Seigne <eric.seigne@cap-rel.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013-2022 Open-DSI <support@open-dsi.fr>
* Copyright (C) 2013-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2017-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018-2024 Eric Seigne <eric.seigne@cap-rel.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -113,6 +113,9 @@ $error = 0;
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
$pastmonth = null; // Initialise for static analysis (could be really unseg)
$pastmonthyear = null;
if (empty($date_startmonth)) {
// Period by default on transfer
$dates = getDefaultDatesForTransfer();
@ -137,10 +140,14 @@ $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.amount_main_c
$sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_journal,";
$sql .= " soc.rowid as socid, soc.nom as name, soc.email as email, bu1.type as typeop_company,";
if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
$sql .= " spe.accountancy_code_customer as code_compta,";
$sql .= " spe.accountancy_code_customer_general,";
$sql .= " spe.accountancy_code_customer as code_compta_client,";
$sql .= " spe.accountancy_code_supplier_general,";
$sql .= " spe.accountancy_code_supplier as code_compta_fournisseur,";
} else {
$sql .= " soc.code_compta,";
$sql .= " soc.accountancy_code_customer_general,";
$sql .= " soc.code_compta as code_compta_client,";
$sql .= " soc.accountancy_code_supplier_general,";
$sql .= " soc.code_compta_fournisseur,";
}
$sql .= " u.accountancy_code, u.rowid as userid, u.lastname as lastname, u.firstname as firstname, u.email as useremail, u.statut as userstatus,";
@ -199,6 +206,7 @@ $tmppayment = new Paiement($db);
$tmpinvoice = new Facture($db);
$accountingaccount = new AccountingAccount($db);
$account_transfer = 'NotDefined'; // For static analysis, NotDefined is a reserved word
// Get code of finance journal
$accountingjournalstatic = new AccountingJournal($db);
@ -215,12 +223,15 @@ $tabtype = array();
$tabmoreinfo = array();
'
@phan-var-force array<array{id:mixed,name:mixed,code_compta:string,email:string}> $tabcompany
@phan-var-force array<array{id:mixed,name:mixed,code_compta_client:string,email:string}> $tabcompany
@phan-var-force array<array{id:int,name:string,lastname:string,firstname:string,email:string,accountancy_code:string,status:int> $tabuser
@phan-var-force array<int,array{date:string,type_payment:string,ref:string,fk_bank:int,ban_account_ref:string,fk_bank_account:int,lib:string,type:string}> $tabpay
@phan-var-force array<array{lib:string,date?:int|string,type_payment?:string,ref?:string,fk_bank?:int,ban_account_ref?:string,fk_bank_account?:int,type?:string,bank_account_ref?:string,paymentid?:int,paymentsupplierid?:int,soclib?:string,paymentscid?:int,paymentdonationid?:int,paymentsubscriptionid?:int,paymentvatid?:int,paymentsalid?:int,paymentexpensereport?:int,paymentvariousid?:int,account_various?:string,paymentloanid?:int}> $tabtp
';
$account_customer = 'NotDefined';
$account_supplier = 'NotDefined';
//print $sql;
dol_syslog("accountancy/journal/bankjournal.php", LOG_DEBUG);
$result = $db->query($sql);
@ -275,17 +286,21 @@ if ($result) {
// Set accountancy code for thirdparty (example: '411CU...' or '411' if no subledger account defined on customer)
$compta_soc = 'NotDefined';
$accountancy_code_general = 'NotDefined';
if ($lineisapurchase > 0) {
$accountancy_code_general = (!empty($obj->accountancy_code_supplier_general)) ? $obj->accountancy_code_supplier_general : $account_supplier;
$compta_soc = (($obj->code_compta_fournisseur != "") ? $obj->code_compta_fournisseur : $account_supplier);
}
if ($lineisasale > 0) {
$compta_soc = (!empty($obj->code_compta) ? $obj->code_compta : $account_customer);
$accountancy_code_general = (!empty($obj->accountancy_code_customer_general)) ? $obj->accountancy_code_customer_general : $account_customer;
$compta_soc = (!empty($obj->code_compta_client) ? $obj->code_compta_client : $account_customer);
}
$tabcompany[$obj->rowid] = array(
'id' => $obj->socid,
'name' => $obj->name,
'code_compta' => $compta_soc,
'accountancy_code_general' => $accountancy_code_general,
'email' => $obj->email
);
@ -413,9 +428,10 @@ if ($result) {
$userstatic->lastname = $tabuser[$obj->rowid]['lastname'];
$userstatic->status = $tabuser[$obj->rowid]['status'];
$userstatic->accountancy_code = $tabuser[$obj->rowid]['accountancy_code'];
// For a payment of social contribution, we have a link sc + user.
// but we already fill the $tabpay[$obj->rowid]["soclib"] in the line 'sc'.
// If we fill it here to, we must concat
// If we fill it here to, we must concat.
if ($userstatic->id > 0) {
if ($is_sc) {
$tabpay[$obj->rowid]["soclib"] .= ' '.$userstatic->getNomUrl(1, 'accountancy', 0);
@ -448,6 +464,8 @@ if ($result) {
$chargestatic->label = $links[$key]['label'];
}
$chargestatic->ref = $chargestatic->label;
//$chargestatic->fetch($chargestatic->id);
$tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30);
$tabpay[$obj->rowid]["paymentscid"] = $chargestatic->id;
@ -616,31 +634,24 @@ if ($result) {
dol_print_error($db);
}
//var_dump($tabpay);
//var_dump($tabcompany);
//var_dump($tabbq);
//var_dump($tabtp);
//var_dump($tabtype);
// Write bookkeeping
if (!$error && $action == 'writebookkeeping' && $user->hasRight('accounting', 'bind', 'write')) {
$now = dol_now();
$accountingaccountcustomer = new AccountingAccount($db);
$accountingaccountcustomer->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'), true);
$accountingaccountcustomer->fetch(0, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'), true);
$accountingaccountsupplier = new AccountingAccount($db);
$accountingaccountsupplier->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'), true);
$accountingaccountsupplier->fetch(0, getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'), true);
$accountingaccountpayment = new AccountingAccount($db);
$accountingaccountpayment->fetch(null, getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'), true);
$accountingaccountpayment->fetch(0, getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'), true);
$accountingaccountexpensereport = new AccountingAccount($db);
$accountingaccountexpensereport->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_EXPENSEREPORT, true);
$accountingaccountexpensereport->fetch(0, $conf->global->ACCOUNTING_ACCOUNT_EXPENSEREPORT, true);
$accountingaccountsuspense = new AccountingAccount($db);
$accountingaccountsuspense->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'), true);
$accountingaccountsuspense->fetch(0, getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'), true);
$error = 0;
foreach ($tabpay as $key => $val) { // $key is rowid into llx_bank
@ -656,9 +667,6 @@ if (!$error && $action == 'writebookkeeping' && $user->hasRight('accounting', 'b
$db->begin();
// Introduce a protection. Total of tabtp must be total of tabbq
//var_dump($tabpay);
//var_dump($tabtp);
//var_dump($tabbq);exit;
// Bank
if (!$errorforline && is_array($tabbq[$key])) {
@ -788,43 +796,43 @@ if (!$error && $action == 'writebookkeeping' && $user->hasRight('accounting', 'b
} elseif (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$accountingaccount->fetch(null, $k, true); // TODO Use a cache
$accountingaccount->fetch(0, $k, true); // TODO Use a cache
$bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = $accountingaccount->label;
} elseif ($tabtype[$key] == 'payment_vat') {
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$accountingaccount->fetch(null, $k, true); // TODO Use a cache
$accountingaccount->fetch(0, $k, true); // TODO Use a cache
$bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = $accountingaccount->label;
} elseif ($tabtype[$key] == 'payment_donation') {
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$accountingaccount->fetch(null, $k, true); // TODO Use a cache
$accountingaccount->fetch(0, $k, true); // TODO Use a cache
$bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = $accountingaccount->label;
} elseif ($tabtype[$key] == 'member') {
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$accountingaccount->fetch(null, $k, true); // TODO Use a cache
$accountingaccount->fetch(0, $k, true); // TODO Use a cache
$bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = $accountingaccount->label;
} elseif ($tabtype[$key] == 'payment_loan') {
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$accountingaccount->fetch(null, $k, true); // TODO Use a cache
$accountingaccount->fetch(0, $k, true); // TODO Use a cache
$bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = $accountingaccount->label;
} elseif ($tabtype[$key] == 'payment_various') {
$bookkeeping->subledger_account = $k;
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
$accountingaccount->fetch(null, $tabpay[$key]["account_various"], true); // TODO Use a cache
$accountingaccount->fetch(0, $tabpay[$key]["account_various"], true); // TODO Use a cache
$bookkeeping->numero_compte = $tabpay[$key]["account_various"];
$bookkeeping->label_compte = $accountingaccount->label;
} elseif ($tabtype[$key] == 'banktransfert') {
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$accountingaccount->fetch(null, $k, true); // TODO Use a cache
$accountingaccount->fetch(0, $k, true); // TODO Use a cache
$bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = $accountingaccount->label;
} else {
@ -1030,9 +1038,11 @@ if ($action == 'exportcsv' && $user->hasRight('accounting', 'bind', 'write')) {
print '"'.$val["type_payment"].'"'.$sep;
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
if ($tabtype[$key] == 'payment_supplier') {
print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER').'"'.$sep;
$account_ledger = (!empty($obj->accountancy_code_supplier_general)) ? $obj->accountancy_code_supplier_general : $account_supplier;
print '"'.$account_ledger.'"'.$sep;
} elseif ($tabtype[$key] == 'payment') {
print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER').'"'.$sep;
$account_ledger = (!empty($obj->accountancy_code_customer_general)) ? $obj->accountancy_code_customer_general : $account_customer;
print '"'.$account_ledger.'"'.$sep;
} elseif ($tabtype[$key] == 'payment_expensereport') {
print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT').'"'.$sep;
} elseif ($tabtype[$key] == 'payment_salary') {
@ -1094,7 +1104,7 @@ if (empty($action) || $action == 'view') {
$variousstatic = new PaymentVarious($db);
$title = $langs->trans("GenerationOfAccountingEntries").' - '.$accountingjournalstatic->getNomUrl(0, 2, 1, '', 1);
$help_url ='EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#G&eacute;n&eacute;ration_des_&eacute;critures_en_comptabilit&eacute;';
$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#G&eacute;n&eacute;ration_des_&eacute;critures_en_comptabilit&eacute;';
llxHeader('', dol_string_nohtmltag($title), $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-generation page-bankjournal');
$nom = $title;
@ -1381,9 +1391,6 @@ if (empty($action) || $action == 'view') {
$accounttoshowsubledger = length_accounta($k);
if ($accounttoshow != $accounttoshowsubledger) {
if (empty($accounttoshowsubledger) || $accounttoshowsubledger == 'NotDefined') {
//var_dump($tabpay[$key]);
//var_dump($tabtype[$key]);
//var_dump($tabbq[$key]);
//print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
if (!empty($tabcompany[$key]['code_compta'])) {
if (in_array($tabtype[$key], array('payment_various', 'payment_salary'))) {
@ -1472,7 +1479,7 @@ $db->close();
/**
* Return source for doc_ref of a bank transaction
*
* @param array $val Array of val
* @param array<string,null|int|float|string> $val Array of val
* @param string $typerecord Type of record ('payment', 'payment_supplier', 'payment_expensereport', 'payment_vat', ...)
* @return string A string label to describe a record into llx_bank_url
*/

View file

@ -1,13 +1,14 @@
<?php
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2018 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2018 Eric Seigne <eric.seigne@cap-rel.fr>
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2018 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2018 Eric Seigne <eric.seigne@cap-rel.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -60,6 +61,13 @@ $now = dol_now();
$hookmanager->initHooks(array('expensereportsjournal'));
$parameters = array();
$taber = array(); // Initialise for static analysis
$tabht = array();
$tabtva = array();
$tabttc = array();
$tablocaltax1 = array();
$tablocaltax2 = array();
// Security check
if (!isModEnabled('accounting')) {
accessforbidden();
@ -81,7 +89,7 @@ $errorforinvoice = array();
$accountingaccount = new AccountingAccount($db);
// Get information of journal
// Get information of a journal
$accountingjournalstatic = new AccountingJournal($db);
$accountingjournalstatic->fetch($id_journal);
$journal = $accountingjournalstatic->code;
@ -90,6 +98,9 @@ $journal_label = $accountingjournalstatic->label;
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
$pastmonth = null; // Initialise (could be unset)
$pastmonthyear = null; // Initialise (could be unset)
if (empty($date_startmonth)) {
// Period by default on transfer
$dates = getDefaultDatesForTransfer();
@ -178,7 +189,7 @@ if ($result) {
$compta_localtax1 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $account_vat);
$compta_localtax2 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $account_vat);
// Define array to display all VAT rates that use this accounting account $compta_tva
// Define an array to display all VAT rates that use this accounting account $compta_tva
if (price2num($obj->tva_tx) || !empty($obj->vat_src_code)) {
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')] = (vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''));
}
@ -250,8 +261,11 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
$now = dol_now();
$error = 0;
$userstatic = new User($db);
$bookkeepingstatic = new BookKeeping($db);
$accountingaccountexpense = new AccountingAccount($db);
$accountingaccountexpense->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT'), true);
$accountingaccountexpense->fetch(0, getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT'), true);
foreach ($taber as $key => $val) { // Loop on each expense report
$errorforline = 0;
@ -261,6 +275,10 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
$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++;
@ -286,7 +304,7 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
$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;
@ -322,7 +340,7 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
foreach ($tabht[$key] as $k => $mt) {
if ($mt) {
// get compte id and label
if ($accountingaccount->fetch(null, $k, true)) {
if ($accountingaccount->fetch(0, $k, true)) {
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
@ -337,7 +355,7 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
$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;
@ -408,7 +426,11 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
$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;
@ -505,6 +527,9 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
$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;
@ -523,12 +548,12 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
// Fees
foreach ($tabht[$key] as $k => $mt) {
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k, true);
$accountingaccount->fetch(0, $k, true);
if ($mt) {
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";
@ -541,7 +566,7 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
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";
@ -553,7 +578,7 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
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) : '').'"';
}
@ -563,7 +588,7 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
if (empty($action) || $action == 'view') {
$title = $langs->trans("GenerationOfAccountingEntries").' - '.$accountingjournalstatic->getNomUrl(0, 2, 1, '', 1);
$help_url ='EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#G&eacute;n&eacute;ration_des_&eacute;critures_en_comptabilit&eacute;';
$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#G&eacute;n&eacute;ration_des_&eacute;critures_en_comptabilit&eacute;';
llxHeader('', dol_string_nohtmltag($title), $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-generation page-expensereportsjournal');
$nom = $title;
@ -573,7 +598,7 @@ if (empty($action) || $action == 'view') {
$builddate = dol_now();
$description = $langs->trans("DescJournalOnlyBindedVisible").'<br>';
$listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
$listofchoices = array('notyet' => $langs->trans("NotYetInGeneralLedger"), 'already' => $langs->trans("AlreadyInGeneralLedger"));
$period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0);
$period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
@ -662,6 +687,7 @@ if (empty($action) || $action == 'view') {
$expensereportstatic = new ExpenseReport($db);
$expensereportlinestatic = new ExpenseReportLine($db);
$bookkeepingstatic = new BookKeeping($db);
foreach ($taber as $key => $val) {
$expensereportstatic->id = $key;
@ -722,7 +748,7 @@ if (empty($action) || $action == 'view') {
print '</td>';
$userstatic->id = $tabuser[$key]['id'];
$userstatic->name = $tabuser[$key]['name'];
print "<td>".$userstatic->getNomUrl(0, 'user', 16).' - '.$accountingaccount->label."</td>";
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($userstatic->getNomUrl(0, 'user'), '', $accountingaccount->label) . "</td>";
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
print "</tr>";
@ -758,7 +784,7 @@ if (empty($action) || $action == 'view') {
print $accountoshow;
}
print '</td>';
print "<td>".$userstatic->getNomUrl(0, 'user', 16).' - '.$langs->trans("SubledgerAccount")."</td>";
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($userstatic->getNomUrl(0, 'user'), '', $langs->trans("SubledgerAccount")) . "</td>";
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print "</tr>";
@ -795,8 +821,10 @@ if (empty($action) || $action == 'view') {
// Subledger account
print "<td>";
print '</td>';
print "<td>".$userstatic->getNomUrl(0, 'user', 16).' - '.$langs->trans("VAT").' '.implode(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '');
print "</td>";
$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 "<td>" . $bookkeepingstatic->accountingLabelForOperation($userstatic->getNomUrl(0, 'user'), '', $labelvatrate) . "</td>";
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
print "</tr>";

View file

@ -1,14 +1,14 @@
<?php
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2018 Eric Seigne <eric.seigne@cap-rel.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2018 Eric Seigne <eric.seigne@cap-rel.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -75,6 +75,19 @@ if (!$user->hasRight('accounting', 'bind', 'write')) {
$error = 0;
$tabfac = array();
$tabht = array();
$tabtva = array();
$tabttc = array();
$tablocaltax1 = array();
$tablocaltax2 = array();
$tabrctva = array();
$tabrclocaltax1 = array();
$tabrclocaltax2 = array();
$tabpay = array();
$cptcli = 'NotDefined';
$cptfour = 'NotDefined';
/*
* Actions
@ -84,7 +97,7 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $user, $action);
$accountingaccount = new AccountingAccount($db);
// Get information of journal
// Get information of a journal
$accountingjournalstatic = new AccountingJournal($db);
$accountingjournalstatic->fetch($id_journal);
$journal = $accountingjournalstatic->code;
@ -93,6 +106,9 @@ $journal_label = $accountingjournalstatic->label;
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
$pastmonth = null; // Initialise, could be unset
$pastmonthyear = null; // Initialise, could be unset
if (empty($date_startmonth)) {
// Period by default on transfer
$dates = getDefaultDatesForTransfer();
@ -119,10 +135,14 @@ $sql .= " p.default_vat_code AS product_buy_default_vat_code, p.tva_tx as produc
$sql .= " co.code as country_code, co.label as country_label,";
$sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.fk_pays,";
if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
$sql .= " spe.accountancy_code_customer_general,";
$sql .= " spe.accountancy_code_customer as code_compta,";
$sql .= " spe.accountancy_code_supplier_general,";
$sql .= " spe.accountancy_code_supplier as code_compta_fournisseur,";
} else {
$sql .= " s.accountancy_code_customer_general,";
$sql .= " s.code_compta as code_compta,";
$sql .= " s.accountancy_code_supplier_general,";
$sql .= " s.code_compta_fournisseur,";
}
if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
@ -207,6 +227,7 @@ if ($result) {
$obj = $db->fetch_object($result);
// Controls
$accountancy_code_supplier_general = (!empty($obj->accountancy_code_supplier_general)) ? $obj->accountancy_code_supplier_general : $cptfour;
$compta_soc = ($obj->code_compta_fournisseur != "") ? $obj->code_compta_fournisseur : $cptfour;
$compta_prod = $obj->compte;
@ -230,7 +251,7 @@ if ($result) {
$compta_localtax2 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
$compta_counterpart_tva_npr = getDolGlobalString('ACCOUNTING_COUNTERPART_VAT_NPR', 'NotDefined');
// Define array to display all VAT rates that use this accounting account $compta_tva
// Define an array to display all VAT rates that use this accounting account $compta_tva
if (price2num($obj->tva_tx) || !empty($obj->vat_src_code)) {
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')] = (vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''));
}
@ -325,6 +346,7 @@ if ($result) {
'id' => $obj->socid,
'name' => $obj->name,
'code_fournisseur' => $obj->code_fournisseur,
'accountancy_code_supplier_general' => $accountancy_code_supplier_general,
'code_compta_fournisseur' => $compta_soc
);
@ -399,8 +421,9 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
$companystatic = new Societe($db);
$invoicestatic = new FactureFournisseur($db);
$accountingaccountsupplier = new AccountingAccount($db);
$bookkeepingstatic = new BookKeeping($db);
$accountingaccountsupplier->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'), true);
$accountingaccountsupplier->fetch(0, getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'), true);
foreach ($tabfac as $key => $val) { // Loop on each invoice
$errorforline = 0;
@ -408,10 +431,11 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
$totalcredit = 0;
$totaldebit = 0;
$db->begin(); // We accept transaction into loop so if we hang, we can continue transfer from last error
$db->begin(); // We accept transaction into loop, so if we hang, we can continue transfer from the last error
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->accountancy_code_supplier_general = $tabcompany[$key]['accountancy_code_supplier_general'];
$companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur'];
$companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur'];
$companystatic->fournisseur = 1;
@ -425,7 +449,7 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
$date = dol_print_date($val["date"], 'day');
// Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
// Is it a replaced invoice? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
$replacedinvoice = 0;
if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) {
$replacedinvoice = 1;
@ -464,10 +488,10 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta_fournisseur'];
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
$bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER');
$bookkeeping->numero_compte = $tabcompany[$key]['accountancy_code_supplier_general'];
$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;
@ -531,7 +555,7 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
if (getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER_USE_AUXILIARY_ON_DEPOSIT')) {
if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER_DEPOSIT')) {
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta_fournisseur'];
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
} else {
$bookkeeping->subledger_account = '';
@ -545,7 +569,7 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
$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;
@ -614,7 +638,7 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
foreach ($arrayofvat[$key] as $k => $mt) {
if ($mt) {
$accountingaccount->fetch(null, $k, true); // TODO Use a cache for label
$accountingaccount->fetch(0, $k, true); // TODO Use a cache for label
$label_account = $accountingaccount->label;
$bookkeeping = new BookKeeping($db);
@ -633,7 +657,11 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
$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;
@ -685,7 +713,7 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
$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;
@ -779,10 +807,12 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
$companystatic = new Fournisseur($db);
$invoicestatic = new FactureFournisseur($db);
$bookkeepingstatic = new BookKeeping($db);
foreach ($tabfac as $key => $val) {
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->accountancy_code_supplier_general = !empty($tabcompany[$key]['accountancy_code_supplier_general']) ? $tabcompany[$key]['accountancy_code_supplier_general'] : $cptfour;
$companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur'];
$companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur'];
$companystatic->fournisseur = 1;
@ -796,7 +826,7 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
$date = dol_print_date($val["date"], 'day');
// Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
// Is it a replaced invoice? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
$replacedinvoice = 0;
if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) {
$replacedinvoice = 1;
@ -817,12 +847,12 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
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_accountg($companystatic->accountancy_code_supplier_general).'"'.$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.'"';
@ -833,17 +863,17 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
// Product / Service
foreach ($tabht[$key] as $k => $mt) {
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k, true);
$accountingaccount->fetch(0, $k, true);
//if ($mt) {
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.'"';
@ -890,12 +920,12 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
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.'"';
@ -910,12 +940,12 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
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.'"';
@ -929,7 +959,7 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
if (empty($action) || $action == 'view') {
$title = $langs->trans("GenerationOfAccountingEntries").' - '.$accountingjournalstatic->getNomUrl(0, 2, 1, '', 1);
$help_url ='EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#G&eacute;n&eacute;ration_des_&eacute;critures_en_comptabilit&eacute;';
$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#G&eacute;n&eacute;ration_des_&eacute;critures_en_comptabilit&eacute;';
llxHeader('', dol_string_nohtmltag($title), $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-generation page-purchasesjournal');
$nom = $title;
@ -1032,10 +1062,12 @@ if (empty($action) || $action == 'view') {
$invoicestatic = new FactureFournisseur($db);
$companystatic = new Fournisseur($db);
$bookkeepingstatic = new BookKeeping($db);
foreach ($tabfac as $key => $val) {
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->accountancy_code_supplier_general = !empty($tabcompany[$key]['accountancy_code_supplier_general']) ? $tabcompany[$key]['accountancy_code_supplier_general'] : $cptfour;
$companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur'];
$companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur'];
$companystatic->fournisseur = 1;
@ -1049,7 +1081,7 @@ if (empty($action) || $action == 'view') {
$date = dol_print_date($val["date"], 'day');
// Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
// Is it a replaced invoice? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
$replacedinvoice = 0;
if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) {
$replacedinvoice = 1;
@ -1110,7 +1142,7 @@ if (empty($action) || $action == 'view') {
print "<td>".$invoicestatic->getNomUrl(1)."</td>";
// Account
print "<td>";
$accountoshow = length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'));
$accountoshow = length_accountg(!empty($tabcompany[$key]['accountancy_code_supplier_general']) ? $tabcompany[$key]['accountancy_code_supplier_general'] : $cptfour);
if (($accountoshow == "") || $accountoshow == 'NotDefined') {
print '<span class="error">'.$langs->trans("MainAccountForSuppliersNotDefined").'</span>';
} else {
@ -1126,7 +1158,7 @@ if (empty($action) || $action == 'view') {
print $accountoshow;
}
print '</td>';
print "<td>".$companystatic->getNomUrl(0, 'supplier', 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("SubledgerAccount")."</td>";
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $langs->trans("SubledgerAccount")) . "</td>";
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print "</tr>";
@ -1161,7 +1193,7 @@ if (empty($action) || $action == 'view') {
print "<td>";
if (getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER_USE_AUXILIARY_ON_DEPOSIT')) {
if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER_DEPOSIT')) {
print length_accounta($tabcompany[$key]['code_compta']);
print length_accounta($tabcompany[$key]['code_compta_fournisseur']);
}
} elseif (($accountoshow == "") || $accountoshow == 'NotDefined') {
print '<span class="error">' . $langs->trans("ThirdpartyAccountNotDefined") . '</span>';
@ -1169,7 +1201,7 @@ if (empty($action) || $action == 'view') {
print '</td>';
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
print "<td>".$companystatic->getNomUrl(0, 'supplier', 16).' - '.$invoicestatic->ref_supplier.' - '.$accountingaccount->label."</td>";
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $accountingaccount->label) . "</td>";
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
print "</tr>";
@ -1230,7 +1262,10 @@ if (empty($action) || $action == 'view') {
print "<td>";
print '</td>';
print "<td>";
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 "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $labelvatrate) . "</td>";
print "</td>";
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
@ -1261,7 +1296,7 @@ if (empty($action) || $action == 'view') {
// Subledger account
print "<td>";
print '</td>';
print "<td>".$companystatic->getNomUrl(0, 'supplier', 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("VAT")." NPR (counterpart)</td>";
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $langs->trans("VAT")." NPR (counterpart)") . "</td>";
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print "</tr>";

View file

@ -1,15 +1,15 @@
<?php
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -77,6 +77,15 @@ if (!$user->hasRight('accounting', 'bind', 'write')) {
$error = 0;
$tabfac = array();
$tabht = array();
$tabtva = array();
$tabwarranty = array();
$tabttc = array();
$tablocaltax1 = array();
$tablocaltax2 = array();
$cptcli = 'NotDefined';
/*
* Actions
@ -86,7 +95,7 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $user, $action);
$accountingaccount = new AccountingAccount($db);
// Get information of journal
// Get information of a journal
$accountingjournalstatic = new AccountingJournal($db);
$accountingjournalstatic->fetch($id_journal);
$journal = $accountingjournalstatic->code;
@ -95,6 +104,9 @@ $journal_label = $accountingjournalstatic->label;
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
$pastmonth = null; // Initialise, could be unset
$pastmonthyear = null; // Initialise, could be unset
if (empty($date_startmonth)) {
// Period by default on transfer
$dates = getDefaultDatesForTransfer();
@ -122,10 +134,14 @@ $sql = "SELECT f.rowid, f.ref, f.type, f.situation_cycle_ref, f.datef as df, f.r
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code, fd.info_bits,";
$sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur,";
if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
$sql .= " spe.accountancy_code_customer as code_compta,";
$sql .= " spe.accountancy_code_customer_general,";
$sql .= " spe.accountancy_code_customer as code_compta_client,";
$sql .= " spe.accountancy_code_supplier_general,";
$sql .= " spe.accountancy_code_supplier as code_compta_fournisseur,";
} else {
$sql .= " s.code_compta as code_compta,";
$sql .= " s.accountancy_code_customer_general,";
$sql .= " s.code_compta as code_compta_client,";
$sql .= " s.accountancy_code_supplier_general,";
$sql .= " s.code_compta_fournisseur,";
}
$sql .= " p.rowid as pid, p.ref as pref, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,";
@ -208,7 +224,8 @@ if ($result) {
$obj = $db->fetch_object($result);
// Controls
$compta_soc = (!empty($obj->code_compta)) ? $obj->code_compta : $cptcli;
$accountancy_code_customer_general = (!empty($obj->accountancy_code_customer_general)) ? $obj->accountancy_code_customer_general : $cptcli;
$compta_soc = (!empty($obj->code_compta_client)) ? $obj->code_compta_client : $cptcli;
$compta_prod = $obj->compte;
if (empty($compta_prod)) {
@ -225,7 +242,14 @@ if ($result) {
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);
@ -349,9 +373,27 @@ if ($result) {
'id' => $obj->socid,
'name' => $obj->name,
'code_client' => $obj->code_client,
'accountancy_code_customer_general' => $accountancy_code_customer_general,
'code_compta' => $compta_soc
);
// After the line is processed
$parameters = array(
'obj' => $obj,
'tabfac' => &$tabfac,
'tabht' => &$tabht,
'tabtva' => &$tabtva,
'def_tva' => &$def_tva,
'tabwarranty' => &$tabwarranty,
'tabrevenuestamp' => &$tabrevenuestamp,
'tabttc' => &$tabttc,
'tablocaltax1' => &$tablocaltax1,
'tablocaltax2' => &$tablocaltax2,
'tabcompany' => &$tabcompany,
'vatdata_cache' => &$vatdata_cache,
);
$reshook = $hookmanager->executeHooks('processingJournalData', $parameters); // Note that $action and $object may have been modified by hook
$i++;
// Check for too many lines.
@ -363,6 +405,20 @@ if ($result) {
}
// After the loop on each line
$parameters = array(
'tabfac' => &$tabfac,
'tabht' => &$tabht,
'tabtva' => &$tabtva,
'def_tva' => &$def_tva,
'tabwarranty' => &$tabwarranty,
'tabrevenuestamp' => &$tabrevenuestamp,
'tabttc' => &$tabttc,
'tablocaltax1' => &$tablocaltax1,
'tablocaltax2' => &$tablocaltax2,
'tabcompany' => &$tabcompany,
'vatdata_cache' => &$vatdata_cache,
);
$reshook = $hookmanager->executeHooks('processedJournalData', $parameters); // Note that $action and $object may have been modified by hook
} else {
dol_print_error($db);
}
@ -425,12 +481,13 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
$companystatic = new Societe($db);
$invoicestatic = new Facture($db);
$bookkeepingstatic = new BookKeeping($db);
$accountingaccountcustomer = new AccountingAccount($db);
$accountingaccountcustomer->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'), true);
$accountingaccountcustomer->fetch(0, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'), true);
$accountingaccountcustomerwarranty = new AccountingAccount($db);
$accountingaccountcustomerwarranty->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY'), true);
$accountingaccountcustomerwarranty->fetch(0, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY'), true);
foreach ($tabfac as $key => $val) { // Loop on each invoice
$errorforline = 0;
@ -438,10 +495,11 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
$totalcredit = 0;
$totaldebit = 0;
$db->begin(); // We accept transaction into loop so if we hang, we can continue transfer from last error
$db->begin(); // We accept transaction into loop, so if we hang, we can continue transfer from the last error
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->accountancy_code_customer_general = $tabcompany[$key]['accountancy_code_customer_general'];
$companystatic->code_compta = $tabcompany[$key]['code_compta'];
$companystatic->code_compta_client = $tabcompany[$key]['code_compta'];
$companystatic->code_client = $tabcompany[$key]['code_client'];
@ -454,7 +512,7 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
$date = dol_print_date($val["date"], 'day');
// Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
// Is it a replaced invoice? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
$replacedinvoice = 0;
if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
$replacedinvoice = 1;
@ -464,7 +522,7 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
}
}
// If not already into bookkeeping, we won't add it. If yes, do nothing (should not happen because creating replacement not possible if invoice is accounted)
// If not already into bookkeeping, we won't add it. If yes, do nothing (should not happen because creating a replacement is not possible if invoice is accounted)
if ($replacedinvoice == 1) {
$db->rollback();
continue;
@ -488,7 +546,7 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
$bookkeeping->date_creation = $now;
$bookkeeping->doc_type = 'customer_invoice';
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are the source of this record to add
$bookkeeping->thirdparty_code = $companystatic->code_client;
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
@ -497,7 +555,7 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
$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;
@ -544,10 +602,10 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
$bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER');
$bookkeeping->numero_compte = !empty($tabcompany[$key]['accountancy_code_customer_general']) ? $tabcompany[$key]['accountancy_code_customer_general'] : $cptcli;
$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;
@ -625,7 +683,7 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
$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;
@ -670,7 +728,7 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
foreach ($arrayofvat[$key] as $k => $mt) {
if ($mt) {
$accountingaccount->fetch(null, $k, true); // TODO Use a cache for label
$accountingaccount->fetch(0, $k, true); // TODO Use a cache for label
$label_account = $accountingaccount->label;
$bookkeeping = new BookKeeping($db);
@ -690,10 +748,10 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
$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';
@ -731,7 +789,7 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
if (isset($tabrevenuestamp[$key]) && is_array($tabrevenuestamp[$key])) {
foreach ($tabrevenuestamp[$key] as $k => $mt) {
if ($mt) {
$accountingaccount->fetch(null, $k, true); // TODO Use a cache for label
$accountingaccount->fetch(0, $k, true); // TODO Use a cache for label
$label_account = $accountingaccount->label;
$bookkeeping = new BookKeeping($db);
@ -750,7 +808,7 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
$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;
@ -848,10 +906,12 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
$companystatic = new Client($db);
$invoicestatic = new Facture($db);
$bookkeepingstatic = new BookKeeping($db);
foreach ($tabfac as $key => $val) {
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->accountancy_code_customer_general = !empty($tabcompany[$key]['accountancy_code_customer_general']) ? $tabcompany[$key]['accountancy_code_customer_general'] : $cptcli;
$companystatic->code_compta = $tabcompany[$key]['code_compta']; // deprecated
$companystatic->code_compta_client = $tabcompany[$key]['code_compta'];
$companystatic->code_client = $tabcompany[$key]['code_client'];
@ -864,7 +924,7 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
$date = dol_print_date($val["date"], 'day');
// Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
// Is it a replaced invoice? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
$replacedinvoice = 0;
if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
$replacedinvoice = 1;
@ -886,12 +946,12 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
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.'"';
@ -906,12 +966,12 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
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_accountg($companystatic->accountancy_code_customer_general).'"'.$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.'"';
@ -922,17 +982,17 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
// Product / Service
foreach ($tabht[$key] as $k => $mt) {
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k, true);
$accountingaccount->fetch(0, $k, true);
//if ($mt) {
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.'"';
@ -956,12 +1016,12 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
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.'"';
@ -977,12 +1037,12 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
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.'"';
@ -997,7 +1057,7 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
if (empty($action) || $action == 'view') {
$title = $langs->trans("GenerationOfAccountingEntries").' - '.$accountingjournalstatic->getNomUrl(0, 2, 1, '', 1);
$help_url ='EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#G&eacute;n&eacute;ration_des_&eacute;critures_en_comptabilit&eacute;';
$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#G&eacute;n&eacute;ration_des_&eacute;critures_en_comptabilit&eacute;';
llxHeader('', dol_string_nohtmltag($title), $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-generation page-sellsjournal');
$nom = $title;
@ -1100,10 +1160,12 @@ if (empty($action) || $action == 'view') {
$companystatic = new Client($db);
$invoicestatic = new Facture($db);
$bookkeepingstatic = new BookKeeping($db);
foreach ($tabfac as $key => $val) {
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->accountancy_code_customer_general = !empty($tabcompany[$key]['accountancy_code_customer_general']) ? $tabcompany[$key]['accountancy_code_customer_general'] : $cptcli;
$companystatic->code_compta = $tabcompany[$key]['code_compta'];
$companystatic->code_compta_client = $tabcompany[$key]['code_compta'];
$companystatic->code_client = $tabcompany[$key]['code_client'];
@ -1116,7 +1178,7 @@ if (empty($action) || $action == 'view') {
$date = dol_print_date($val["date"], 'day');
// Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
// Is it a replaced invoice? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
$replacedinvoice = 0;
if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
$replacedinvoice = 1;
@ -1194,7 +1256,7 @@ if (empty($action) || $action == 'view') {
print $accountoshow;
}
print '</td>';
print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("RetainedWarranty") . "</td>";
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0), $invoicestatic->ref, $langs->trans("RetainedWarranty")) . "</td>";
print '<td class="right nowraponall amount">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print '<td class="right nowraponall amount">' . ($mt < 0 ? price(-$mt) : '') . "</td>";
print "</tr>";
@ -1209,7 +1271,7 @@ if (empty($action) || $action == 'view') {
print "<td>".$invoicestatic->getNomUrl(1)."</td>";
// Account
print "<td>";
$accountoshow = length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'));
$accountoshow = length_accountg($companystatic->accountancy_code_customer_general);
if (($accountoshow == "") || $accountoshow == 'NotDefined') {
print '<span class="error">'.$langs->trans("MainAccountForCustomersNotDefined").'</span>';
} else {
@ -1225,7 +1287,7 @@ if (empty($action) || $action == 'view') {
print $accountoshow;
}
print '</td>';
print "<td>".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref.' - '.$langs->trans("SubledgerAccount")."</td>";
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $langs->trans("SubledgerAccount")) . "</td>";
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
print "</tr>";
@ -1268,7 +1330,7 @@ if (empty($action) || $action == 'view') {
print '</td>';
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
print "<td>".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref.' - '.$accountingaccount->label."</td>";
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $accountingaccount->label) . "</td>";
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print "</tr>";
@ -1306,13 +1368,12 @@ if (empty($action) || $action == 'view') {
// Subledger account
print "<td>";
print '</td>';
print "<td>".$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 "</td>";
$labelvatrate = $langs->trans("Taxes").' '.$tmpvatrate.' %';
$labelvatrate .= ($numtax ? ' - Localtax '.$numtax : '');
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $labelvatrate) . "</td>";
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print "</tr>";
@ -1341,7 +1402,7 @@ if (empty($action) || $action == 'view') {
// Subledger account
print "<td>";
print '</td>';
print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("RevenueStamp") . "</td>";
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $langs->trans("RevenueStamp")) . "</td>";
print '<td class="right nowraponall amount">' . ($mt < 0 ? price(-$mt) : '') . "</td>";
print '<td class="right nowraponall amount">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print "</tr>";

View file

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2021-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
/* Copyright (C) 2021-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -44,7 +45,7 @@ if ($in_bookkeeping == '') {
$in_bookkeeping = 'notyet';
}
// Get information of journal
// Get information of a journal
$object = new AccountingJournal($db);
$result = $object->fetch($id_journal);
if ($result > 0) {
@ -61,6 +62,9 @@ $parameters = array();
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
$pastmonth = null; // Initialise, could be unset
$pastmonthyear = null; // Initialise, could be unset
if (empty($date_startmonth)) {
// Period by default on transfer
$dates = getDefaultDatesForTransfer();
@ -196,7 +200,7 @@ if ($object->nature == 2) {
}
$title = $langs->trans("GenerationOfAccountingEntries") . ' - ' . $object->getNomUrl(0, 2, 1, '', 1);
$help_url ='EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#G&eacute;n&eacute;ration_des_&eacute;critures_en_comptabilit&eacute;';
$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#G&eacute;n&eacute;ration_des_&eacute;critures_en_comptabilit&eacute;';
llxHeader('', dol_string_nohtmltag($title), $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-generation page-variousjournal');
$nom = $title;

View file

@ -3,6 +3,7 @@
* Copyright (C) 2013-2021 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2022 Alexandre Spangaro <aspangaro@easya.solutions>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -62,7 +63,7 @@ $year_current = $year_start;
// Validate History
$action = GETPOST('action', 'aZ09');
$chartaccountcode = dol_getIdFromCode($db, getDolGlobalInt('CHARTOFACCOUNTS'), 'accounting_system', 'rowid', 'pcg_version');
$chartaccountcode = dol_getIdFromCode($db, getDolGlobalString('CHARTOFACCOUNTS'), 'accounting_system', 'rowid', 'pcg_version');
// Security check
if (!isModEnabled('accounting')) {

View file

@ -6,6 +6,8 @@
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>s
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -98,13 +100,13 @@ if (!$sortorder) {
}
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
$hookmanager->initHooks(array('accountancysupplierlist'));
$formaccounting = new FormAccounting($db);
$accountingAccount = new AccountingAccount($db);
$chartaccountcode = dol_getIdFromCode($db, getDolGlobalInt('CHARTOFACCOUNTS'), 'accounting_system', 'rowid', 'pcg_version');
$chartaccountcode = dol_getIdFromCode($db, getDolGlobalString('CHARTOFACCOUNTS'), 'accounting_system', 'rowid', 'pcg_version');
// Security check
if (!isModEnabled('accounting')) {
@ -560,6 +562,8 @@ if ($result) {
$accountingaccount_codetotid_cache = array();
$suggestedaccountingaccountfor = '';
$suggestedaccountingaccountbydefaultfor = '';
while ($i < min($num_lines, $limit)) {
$objp = $db->fetch_object($result);

Some files were not shown because too many files have changed in this diff Show more