Merge branch 'develop' into addInputInEmailing

This commit is contained in:
lamrani abdelwadoud 2024-01-24 17:38:59 +01:00 committed by GitHub
commit fbf46a4d4b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
416 changed files with 16414 additions and 2198 deletions

View file

@ -25,8 +25,6 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Get PHP and addons
- name: Setup PHP
@ -36,15 +34,11 @@ jobs:
php-version: "${{ matrix.php-version }}"
tools: phpstan, cs2pr
extensions: calendar, json, imagick, gd, zip, mbstring, intl, opcache, imap, mysql, pgsql, sqlite3, ldap, xml, mcrypt
# ???
- uses: actions/setup-node@v4
with:
node-version: 14.x
registry-url: 'https://registry.npmjs.org'
# Restore old cache
- name: Restore phpstan cache
uses: actions/cache/restore@v3
id: cache
uses: actions/cache/restore@v4
with:
path: ./.github/tmp
key: "phpstan-cache-${{ matrix.php-version }}-${{ github.run_id }}"
@ -55,13 +49,14 @@ jobs:
# Run PHPStan
- name: Run PHPStan
id: phpstan
run: phpstan -vvv analyse --error-format=checkstyle --memory-limit 4G -a build/phpstan/bootstrap_action.php -c phpstan.neon | cs2pr --graceful-warnings
# continue-on-error: true
# Save cache
- name: "Save phpstan cache"
uses: actions/cache/save@v3
if: always()
uses: actions/cache/save@v4
if: ${{ success() || ( ! cancelled() && steps.cache.outputs.cache-hit != 'true' ) }}
with:
path: ./.github/tmp
key: "phpstan-cache-${{ matrix.php-version }}-${{ github.run_id }}"

View file

@ -16,7 +16,8 @@ jobs:
if: false
# Checkout git sources to analyze
- uses: actions/checkout@v4
# ???
# Action setup-python needs a requirements.txt or pyproject.toml
# This ensures one of them exists.
- name: Create requirements.txt if no requirements.txt or pyproject.toml
run: |-
[ -r requirements.txt ] || [ -r pyproject.toml ] || touch requirements.txt
@ -27,11 +28,12 @@ jobs:
python-version: '3.11'
- run: python -m pip install pre-commit regex
# Restore previous cache of precommit
- uses: actions/cache/restore@v3
- uses: actions/cache/restore@v4
with:
path: ~/.cache/pre-commit/
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
# Run all the precommit tools (defined into pre-commit-config.yaml). We can force exclusion of some of them here.
# Run all the precommit tools (defined into pre-commit-config.yaml).
# We can force exclusion of some of them here.
- name: Run pre-commit hooks
env:
# SKIP is used by pre-commit to not execute certain hooks
@ -54,8 +56,8 @@ jobs:
notices-as-warnings: true # optional
prepend-filename: true # optional
# Save the precommit cache
- uses: actions/cache/save@v3
if: ${{ always() }}
- uses: actions/cache/save@v4
if: ${{ ! cancelled() }}
with:
path: ~/.cache/pre-commit/
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml')
@ -63,7 +65,7 @@ jobs:
# Upload result log files of precommit into the Artifact shared store
- name: Provide log as artifact
uses: actions/upload-artifact@v4
if: ${{ always() }}
if: ${{ ! cancelled() }}
with:
name: precommit-logs
path: |

View file

@ -15,7 +15,6 @@ repos:
- id: trailing-whitespace
exclude_types: [markdown]
- id: end-of-file-fixer
types: [yaml]
- id: check-merge-conflict
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
@ -35,6 +34,15 @@ repos:
args: [--tab]
# Run local script
#
# For instance to update the license in edited files, you could add to local.sh:
#
# ```shell
# #!/bin/bash
# MYDIR=$(dirname "$0")
# CHANGED_INTERNALS=$(git diff --name-only | grep -v includes)
# "$MYDIR/dev/tools/updatelicense.php" $CHANGED_INTERNALS
# ```
- repo: local
hooks:
- id: local-precommit-script
@ -77,7 +85,7 @@ repos:
- css
- yaml
# Check format of yam files
# Check format of yaml files
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.32.0
hooks:
@ -107,6 +115,7 @@ repos:
- dev/tools/codespell/codespell-lines-ignore.txt
- --uri-ignore-words-list
- ned
exclude_types: [image]
exclude: (?x)^(.phan/stubs/.*)$
additional_dependencies: [tomli]
- alias: codespell-lang-en_US

View file

@ -3,6 +3,26 @@ English Dolibarr ChangeLog
--------------------------------------------------------------
***** ChangeLog for 19.0.0 compared to 18.0.0 *****
For users:
----------
NEW: Compatibility with PHP 8.3
...
For developers or integrators:
------------------------------
...
WARNING:
--------
The following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
* More class properties (with old name in french) are now deprecated in favor of the property name in english.
* Some API HTTP return code were moved from 401 to 403 to better follow REST specification.
***** ChangeLog for 19.0.0 compared to 18.0.0 *****
For users:
@ -19,9 +39,9 @@ NEW: #22626 date filter thirdparties contracts projects (#22707)
NEW: #24085 Add the Project filter
NEW: #25312 Support extrafields in selectForForms
NEW: #26312 Manage intermediate BIC - SQL Part (#26325)
NEW: Accountancy - Add quick navigation with keyboard shortcut on ledger (#26221)
NEW: Accountancy - FEC/FEC2 format export with attachments (#26192)
NEW: Accountancy - Option to choose length of lettering code
NEW: Accountancy: Add quick navigation with keyboard shortcut on ledger (#26221)
NEW: Accountancy: FEC/FEC2 format export with attachments (#26192)
NEW: Accountancy: Option to choose length of lettering code
NEW: Add a button to create a product or a service from an order or an invoice (#26173)
NEW: Add a button to re-encrypt data of a dolcrypt extrafield password
NEW: Add a CLI tool to regenerate all documents
@ -35,7 +55,7 @@ NEW: add constant to check if qty shipped not greater than qty ordered
NEW: Add context for the movement stock (role toconsume/toproduce) on mrp
NEW: Add contract link on ticket
NEW: Add culum Technical ID in list of details lines of an order (#26164)
NEW: ADD: custom compute for exports
NEW: Add custom compute for exports
NEW: Add custom Text on footer total (#26334)
NEW: Add different picto for each type of extrafields (date, string, ...)
NEW: Add edit line on MO (#26122)
@ -87,12 +107,12 @@ NEW: can edit bomline workstation
NEW: Can edit both the Test and Live stripe customer account on payment
NEW: Can include product variants in list of products
NEW: Can manage ODT documents for groups of users.
NEW: Can modify the picto into modulebuilder
NEW: Can modify the picto into ModuleBuilder
NEW: Can restore product in stock when deleting the supplier invoice
NEW: Can see the favicon file into setup of properties of a website
NEW: Can switch product batch management to no management. (#21691)
NEW: Can upload/delete ODT template for project and tasks
NEW: chart of accounts ES PCG08-PYME-CAT in catalan language
NEW: Chart of accounts ES PCG08-PYME-CAT in catalan language
NEW: clone skill object (#26526)
NEW: close notification for interventions
NEW: column in table prelevement_lignes for fk_user (#26196)
@ -112,7 +132,7 @@ NEW: extrafields password accepts 'dolcrypt' algorithm (reversible algo)
NEW: Factorize a lot of code for numbering modules
NEW: filter on from/to period rather than month/year (#26378)
NEW: FontAwesome - Add possibility to select another version
NEW: Form for add object's property on moduleBuilder
NEW: Form for add object's property on ModuleBuilder
NEW: Can generate SEPA files for salaries (#26541)
NEW: massactions to delete projects
NEW: Generic doc template for donations (#26338)
@ -120,15 +140,15 @@ NEW: Get list evaluation with skills details in user fiche (#26510)
NEW: hidden conf to disable use of dns_get_record (which can become unresponsive) (#26339)
NEW: improved resource data structure
NEW: Include sub warehouse in inventory
NEW: inventory without virtual products (kits)
NEW: Inventory without virtual products (kits)
NEW: Invoice subtypes for customers and vendors (#26233)
NEW: Invoice time from task, make task note better display in invoice line
NEW: lazy load to substitute project variables (#26451)
NEW: LDAP Active Directory UserAccountControl (#25507)
NEW: LDAP: Active Directory UserAccountControl (#25507)
NEW: Library including math and financial functions (#25035)
NEW: Loan - Can upload a file with drag and drop
NEW: Loan: can upload a file with drag and drop
NEW: Manage rate indirect. (#26449)
NEW: memorize model name for pdf hooks
NEW: memorize model name for PDF hooks
NEW: Menu editor is responsive
NEW: Merge the "Create ..." buttons on contract into one.
NEW: More accurate tooltip on what admin permissions are
@ -139,38 +159,38 @@ NEW: no need to create invoice supplier object on supplier card for standalone c
NEW: Option to show label, ref+label or only ref of product in TakePOS
NEW: payment full amount detail tooltip
NEW: possibility to deselect line when create a recurring invoice + missing to use fk_parent_line
NEW: Project - List - use select2 multiselect for status
NEW: Projects: List - use select2 multiselect for status
NEW: Propagate invoice extrafields into template invoice (#26529)
NEW: remove include_subwarehouse form llx_inventory database table
NEW: resource improvements - data structure (#26285)
NEW: Retrieve vat details from the Greek Ministry of Finance GSIS SOAP web service and autocomplete third party fields
NEW: Retrieve VAT details from the Greek Ministry of Finance GSIS SOAP web service and autocomplete third party fields
NEW: Right for stats orders (#24607)
NEW: rights and check access to create portal accounts
NEW: Row in list higher height (#26177)
NEW: Save date of RUM creation when creating a Stripe SEPA mandate
NEW: shipment can include service (for information and invoicing) (#26407)
NEW: Shipment: can include service (for information and invoicing) (#26407)
NEW: Show id of module on the tooltip module help page
NEW: show VAT free amount on payment input close #26208 (#26209)
NEW: start and end date for due date filter on invoice list
NEW: Sub total in list (#26165)
NEW: Support html content for combo list of email recipient
NEW: Website: Support of js into the Dolibarr server preview
NEW: TakePOS - add constant to check qty asked is available (#24820)
NEW: TakePOS - add constant to choose contact instead of customer (#24807)
NEW: TakePOS - amount label with or without tax in free product (#24829)
NEW: TakePOS compatibility with lots and serials
NEW: TakePOS compatibility with lots and serials (#26426)
NEW: TakePOS: add constant to check qty asked is available (#24820)
NEW: TakePOS: add constant to choose contact instead of customer (#24807)
NEW: TakePOS: amount label with or without tax in free product (#24829)
NEW: TakePOS: compatibility with lots and serials (#26426)
NEW: Tooltips are using ajax by default
NEW: Top menu support picto of modules that are font awesome picto.
NEW: updating by adding massactions for delete projects in societe tab
NEW: updating by adding tooltip for api section in Modulebuilder
NEW: updating by adjust request Sql for Salary invoice (#26279)
NEW: updating by adjust request SQL for Salary invoice (#26279)
NEW: updating for display Help title when try to delete Don (issue #25314)
NEW: Upgrade in module builder in menu section
NEW: use account address in sepa mandate (#23642)
NEW: VAT rate - Add entity
NEW: webportal site account
NEW: When an user unset the batch management of products, transformation of each batch stock movement in global stock movement
FIX: #25828 wrong odt style naming
SEC: #25512 applicative anti bruteforce - security on too many login attempts (#25520)
@ -185,10 +205,12 @@ For developers or integrators:
QUAL Reduce very seriously the technical debt (using PHPStan, Psalm and Rector)
NEW Tool in dev/tools/rector to autofix code using style coding practice rules
PERFORMANCE
PERF: Removed a useless fetch_thirdparty
PERF: Perf avoid 2 useless fetch into the triggers of agenda.
PERF: performance & code quality enhancements template sections
QUALITY
QUAL: Remove hardcoded code for OVH sms. Generic method is ok now.
QUAL: Code fix using rector
QUAL: Force subclass MINVERSION (#26314)
@ -202,25 +224,26 @@ QUAL: Use dol_clone with parameter 2 for ->oldcopy
QUAL: use switch case instead of if elseif statements for actions
QUAL: Better respect of REST API RFC.
Hooks:
NEW: [Add hook in user bank page]
NEW: #19501 Add two hooks in dolreceiptprinter.php (#26439)
NEW: Accountancy - Add hooks on PrintFieldList for expensereportsjournal, purchasesjournal, sellsjournal
NEW: add a $notrigger param to Product::updatePrice() method (#26404)
NEW: Add a rule to fix empty($conf->global->...) into !getDolGlobal...
NEW: Add column extraparams on societe_rib
NEW: Add hook on selectLotDataList() function (#25368)
NEW: add hook on selectLotDataList() function (#25368)
NEW: add Hooks and prepare extrafields management for product invoices consumptions (#26280)
NEW: Add hooks on import, step 5 - 6 (#24915)
NEW: add hooks on import, step 5 - 6 (#24915)
NEW: add hook tabContentCreateSupplierOrder (#26418)
NEW: add hook tabContentViewSupplierInvoice (#26431)
NEW: add new hook AfterImportInsert
NEW: add new hook OrderCard (#26380)
NEW: add new hook tabContentCreateOrder (#26408)
NEW: Add phpunit for REST API of contacts
NEW: Add triggers COMPANY_RIB_XXX already present in companybankaccount.class.php
NEW: Add triggers on import success
NEW: Add trigger when deleting a bank account line
NEW: subproduct triggers in product class (#25142)
Triggers:
NEW: Trigger: add trigger COMPANY_RIB_XXX already present in companybankaccount.class.php
NEW: Trigger: add trigger on import success
NEW: Trigger: add trigger when deleting a bank account line
NEW: Trigger: subproduct triggers in product class (#25142)
ModuleBuilder:
NEW: ModuleBuilder: add section changeLog to Doc in MB
NEW: ModuleBuilder: Add api url to documentation in ModuleBuilder
NEW: ModuleBuilder: Checkin comments begin and end before each actions
@ -229,7 +252,13 @@ NEW: ModuleBuilder: remove dictionary in ModuleBuilder
NEW: ModuleBuilder: add page for create dictionary
NEW: ModuleBuilder: add badge for each tabs
NEW: ModuleBuilder: for edit name of dictionary and delete it in MB
NEW: add barcode function to check if EAN13 is valid (
NEW: add a $notrigger param to Product::updatePrice() method (#26404)
NEW: add a rule to fix empty($conf->global->...) into !getDolGlobal...
NEW: add column extraparams on societe_rib
NEW: add phpunit for REST API of contacts
NEW: add barcode function to check if EAN13 is valid
WARNING:
--------
@ -7073,7 +7102,7 @@ FIX: incoterms do not output into crabe invoice PDF
FIX: in PgSQL no quote "word style" is permitted around column name
FIX: Introduce hidden option MAIL_PREFIX_FOR_EMAIL_ID to solve pb of tracking email.
FIX: margin tab on customer card must filter on current entity invoices
FIX: missing column into SQL on thridparty list
FIX: missing column into SQL on thirdparty list
FIX: only show projects of related third if external user
FIX: PgSQL Module Resource list crash #5637
FIX: php Strict
@ -7127,7 +7156,7 @@ FIX: incoterms do not output into crabe invoice PDF
FIX: in PgSQL no quote "word style" is permitted around column name
FIX: Introduce hidden option MAIL_PREFIX_FOR_EMAIL_ID to solve pb of tracking email.
FIX: margin tab on customer card must filter on current entity invoices
FIX: missing column into SQL on thridparty list
FIX: missing column into SQL on thirdparty list
FIX: only show projects of related third if external user
FIX: PgSQL Module Resource list crash #5637
FIX: php Strict
@ -7763,7 +7792,7 @@ FIX: avoid SQL error when no sortfield send to method
FIX: bad link into project box
FIX: Bad title line in project view when using jmobile
FIX: Bad translation key for project "Overview"
FIX: Can create Proposal on close thridparty #3526
FIX: Can create Proposal on close thirdparty #3526
FIX: Can't change state on a contact
FIX: Can't change the admin with default setup
FIX: Can't delete thirdparty if there is some discounts
@ -8099,7 +8128,7 @@ FIX: [ bug #3383 ] Company name is overlapped with company direction in PDF mode
FIX: [ bug #3426 ] Unable to create an invoice from a contract with extrafields
FIX: [ bug #3431 ] Invoice bank account is not respected
FIX: [ bug #3432 ] Spaces should be removed from IBAN when formatting it
FIX: Can create Proposal on close thridparty #3526
FIX: Can create Proposal on close thirdparty #3526
FIX: change order date on clone (as everywhere else)
FIX: Close #2835 Customer prices of a product shows incorrect history order
FIX: Close #2837 Product list table column header does not match column body

View file

@ -304,22 +304,15 @@ if (isset($_GET['img']))
// Definition de la langue et des textes
// Definition of language and texts
if (isset ($_GET['lang']))
{
$langue = $_GET['lang'];
}
elseif (preg_match("/^fr/", $_SERVER['HTTP_ACCEPT_LANGUAGE']))
{
if (isset ($_GET['lang'])) {
$langue = preg_replace('/[^a-z_]/i', '', $_GET['lang']);
} elseif (preg_match("/^fr/", $_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$langue = 'fr';
}
elseif (preg_match("/^es/", $_SERVER['HTTP_ACCEPT_LANGUAGE']))
{
} elseif (preg_match("/^es/", $_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$langue = 'es';
}
else
{
} else {
$langue = 'en';
}
@ -327,29 +320,25 @@ else
// Read PHP extensions
$loaded_extensions = get_loaded_extensions();
$phpExtContents='';
foreach ($loaded_extensions as $extension)
foreach ($loaded_extensions as $extension) {
$phpExtContents .= "<li>${extension}</li>";
}
// Read alias directory
$listoffile=array();
$aliasarray=array();
$aliasContents='';
if (is_dir($aliasDir))
{
if (is_dir($aliasDir)) {
$handle=opendir($aliasDir);
if (is_resource($handle))
{
while ($file = readdir($handle))
{
if (is_resource($handle)) {
while ($file = readdir($handle)) {
$listoffiles[]=$file;
}
}
sort($listoffiles);
foreach($listoffiles as $file)
{
foreach($listoffiles as $file) {
if (is_file($aliasDir.$file) && preg_match('/\.conf/',$file))
{
$msg = '';
@ -374,8 +363,7 @@ if (!isset($aliasContents))
// Read projects in www dir
$listoffiles=array();
$handle=opendir(".");
if (is_resource($handle))
{
if (is_resource($handle)) {
while ($file = readdir($handle))
{
$listoffiles[]=$file;
@ -383,8 +371,7 @@ if (is_resource($handle))
closedir($handle);
}
foreach($listoffiles as $file)
{
foreach($listoffiles as $file) {
if (is_dir($file) && !in_array($file,$projectsListIgnore) && !in_array($file,$aliasarray))
{
$projectContents .= '<tr><td><ul class="projects">';
@ -397,9 +384,9 @@ foreach($listoffiles as $file)
}
}
if (!isset($projectContents))
if (!isset($projectContents)) {
$projectContents = '<tr><td colspan="3">'.$langues[$langue]['txtNoProjet'].'</td></tr>';
}
$nameServer=getenv("COMPUTERNAME");

View file

@ -43,6 +43,8 @@ $error = 0;
require_once $path."../../../htdocs/master.inc.php";
// After this $db, $mysoc, $langs and $conf->entity are defined. Opened handler to database will be closed at end of file.
global $db, $conf, $langs;
//$langs->setDefaultLang('en_US'); // To change default language of $langs
$langs->load("main"); // To load language file for default language
@set_time_limit(0);
@ -50,7 +52,7 @@ $langs->load("main"); // To load language file for default language
// Load user and its permissions
$result = $user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user.
if (!$result > 0) {
dol_print_error('', $user->error);
dol_print_error(null, $user->error);
exit;
}
$user->getrights();

View file

@ -50,7 +50,7 @@ $langs->load("main"); // To load language file for default language
// Load user and its permissions
$result = $user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user.
if (!$result > 0) {
dol_print_error('', $user->error);
dol_print_error(null, $user->error);
exit;
}
$user->getrights();

View file

@ -50,7 +50,7 @@ $langs->load("main"); // To load language file for default language
// Load user and its permissions
$result = $user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user.
if (!$result > 0) {
dol_print_error('', $user->error);
dol_print_error(null, $user->error);
exit;
}
$user->getrights();

View file

@ -50,7 +50,7 @@ $langs->load("main"); // To load language file for default language
// Load user and its permissions
$result = $user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user.
if (!$result > 0) {
dol_print_error('', $user->error);
dol_print_error(null, $user->error);
exit;
}
$user->getrights();

View file

@ -50,7 +50,7 @@ $langs->load("main"); // To load language file for default language
// Load user and its permissions
$result = $user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user.
if (!$result > 0) {
dol_print_error('', $user->error);
dol_print_error(null, $user->error);
exit;
}
$user->getrights();

View file

@ -98,7 +98,7 @@ print 'SFTP connect string : '.$sftpconnectstring."\n";
// SFTP connect
if (!function_exists("ssh2_connect")) {
dol_print_error('', 'ssh2_connect function does not exists');
dol_print_error(null, 'ssh2_connect function does not exists');
exit(1);
}

10
dev/setup/README.md Normal file
View file

@ -0,0 +1,10 @@
# Setting up for Dolibarr development
Check out the
[online documentation](https://wiki.dolibarr.org/index.php?title=Environment_and_development_tools)
for recommendations (to be updated).
If anything, install `pre-commit` - it will help run the tools to format and
make some basic verifications on your submission before committing and pushing
to github for a PR. See [a quick start guide](./pre-commit/README.md) in this
Dolibarr repository.

View file

@ -1,7 +1,7 @@
README (English)
--------------------------------
This directory contains ruleset files to use to develop Dolibarr EPR & CRM.
This directory contains ruleset files to use to develop Dolibarr ERP & CRM.
To install/upgrade phpcs:
> sudo pear upgrade PHP_CodeSniffer
@ -17,5 +17,4 @@ To fix with phpcbf:
Note with Eclipse: You must setup the PTI plugin of Eclipse into PHPCodeSniffer menu with:
* tab value to 4
* path of code sniffer standard to dev/codesniffer
* path of code sniffer standard to dev/codesniffer

View file

@ -0,0 +1,85 @@
## 'pre-commit' ("replaces" precommit)
### Introduction
[`pre-commit`](https://pre-commit.org) is a framework for managing and
maintaining multi-language pre-commit hooks.
"pre-commit hooks" integrate with `git` and are run when you perform a
`git commit` for instance.
Historically there was `precommit` for Dolibarr which you can find in this
directory. That script runs `phplint`, `phpcs` and `phpcbf` upon commit.
`pre-commit` is not specific to Dolibarr and is deployed on many projects -
mostly Python projects, but it is applicable to most (or *all*) code and
documentation development.
You can find documentation at https://pre-commit.com/ .
Now you can use `pre-commit` which uses the configuration found at the root of
the project: `pre-commit-config.yaml`.
### How to
1. Install `pre-commit`.\
If you do not have python installed, install
[python](https://www.python.org) first.\
If you do not have
[`pip`](https://pypi.org/project/pip), install that as well.\\
Then you can install pre-commit: `python -m pip install pre-commit`.
1. In you local git clone of the project, run `pre-commit install`. That will
add the hooks.
### Tips
After installing `pre-commit` onto your local git clone, pre-commit will run
on every commit.
When it finds some issue, the git commit will be aborted, so you can fix it,
or verify it.
The tools run by `pre-commit` may modify your code: format PHP code
(`phpcbf`), fix line endings, end of files, etc.
They may also alert about potential issues: syntax errors, spelling errors,
code quality, an execute bit that was (not) set in the git repository, etc.
One way to use it is this:
```bash
cd PROJECT_DIR
pre-commit install # Only needed once
# Repeat until success.
git commit -a -m "My message"
# `pre-commit` is run and reports
# Check the results, make fixes, and re-commit (=repeat above line).
```
In some cases you may want to commit despite the changes.\
You can just add
`--no-verify` to your git command:
```bash
git commit -a -m "My message" --no-verify
```
If you want to skip certain checks for whatever reason, you can set the SKIP
environment variable:
```bash
SKIP=no-commit-to-branch git commit -a -m "My message"
or
export SKIP=no-commit-to-branch # In your .bashrc or session.
```
There is much more you can do with pre-commit, check out its
[documentation](https://pre-commit.com).
Now your commit is less likely to fail in the Continuous Intagration (CI) run
on github.\
CI also runs pre-commit to help maintain code quality.

View file

@ -1,4 +1,6 @@
#!/bin/bash
# Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
#
# Script to add codespell exceptions to the ignores lines file.
#
@ -18,7 +20,7 @@
#
# :warning:
#
# This script only works properly if codespell is install for your CLI.
# This script only works properly if codespell is installed for your CLI.
# As the configuration is in pyproject.toml, you also need tomli.
#
# ```shell
@ -50,11 +52,17 @@ fi
[ -r "${codespell_ignore_file}" ] || { echo "${codespell_ignore_file} not found" ; exit 1 ; }
# Then:
# - Run codespell;
# - Identify files that have fixes;
# - Limit to files under git control;
# - Run codespell on selected files;
# - For each line, create a grep command to find the lines;
# - Execute that command by evaluation
codespell . | sed -n -E 's@^([^:]+):[[:digit:]]+:[[:space:]](\S+)[[:space:]].*@grep -P '\''\\b\2\\b'\'' "\1" >> '"${codespell_ignore_file}"'@p' | \
while read -r line ; do eval "$line" ; done
codespell . \
| sed -n -E 's@^([^:]+):.*@\1@p' \
| xargs -r git ls-files -- \
| xargs -r codespell -- \
| sed -n -E 's@^([^:]+):[[:digit:]]+:[[:space:]](\S+)[[:space:]].*@grep -P '\''\\b\2\\b'\'' -- "\1" >> '"${codespell_ignore_file}"'@p' \
| while read -r line ; do eval "$line" ; done
# Finally, sort and remove duplicates to make merges easier.
sort -u -o "${codespell_ignore_file}"{,}

View file

@ -1,8 +1,21 @@
# Please add in alphabetical order->(`sort -u` like).
EPR->ERP
alpah->alpha
alphanothtml->alphanohtml
alpahnothtml->alphanohtml
aplha->alpha
aplhanothtml->alphanohtml
aploha->alpha
aplohanothtml->alphanohtml
aplphanothtml->alphanohtml
choosed->chosen
dolibar->dolibarr
dollibar->dolibarr
dollibarr->dolibarr
not de passe->password
# fiche->card
mot de passe->password
choosed->chosen
not de passe->password
nothtml->nohtml
tableau de bord->state board
#DoliDB->DoliDB
tagret->target
thridparty->thirdparty

View file

@ -1,4 +1,5 @@
$objMod->dictionaries = $objMod->{"dictionnaries"}; // For backward compatibility
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.'">';
$reponsesadd = str_split($obj->reponses);
$sql .= " SET reponses = '".$db->escape($reponsesadd)."'";

154
dev/tools/updatelicense.php Executable file
View file

@ -0,0 +1,154 @@
#!/usr/bin/env php
<?php
/* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* Script to update year periods and user/email in headers.
*/
/**
* Retrieve Git user information
*
* @return array{name:string,email:string}
*/
function getGitUserInfo()
{
$name = trim(shell_exec('git config user.name'));
$email = trim(shell_exec('git config user.email'));
return ['name' => $name, 'email' => $email];
}
const PREFIXES = [
'sh' => ['# ', '# ', '', '#!'],
'php' => ['/* ', ' * ', ' */', '<?php'],
];
/**
* Update or add copyright notice in a file
*
* @param $filename string Path to the file to modify
* @param $fileType string Filetype identification for the file
* @param $name string Name of developer to add in header
* @param $email string Email for the developer
*
* @return bool True if license was updated
*/
function updateCopyrightNotice($filename, $fileType, $name, $email)
{
// Determine the appropriate prefix based on file type
if (!array_key_exists($fileType, PREFIXES)) {
return false;
}
// Get configuration for the filetype
list($prefix0, $prefix1, $prefix2, $prefix3) = PREFIXES[$fileType];
$r_prefix0 = preg_quote($prefix0);
$r_prefix1 = preg_quote($prefix1);
$r_prefix3 = preg_quote($prefix3);
$r_name = preg_quote($name);
$r_email = preg_quote($email);
// Read the first n lines of the file
$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}>~";
// Check if the lines match the pattern
if (preg_match($pattern, $lines, $matches)) {
$existingYear = $matches['year'];
// 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]);
// Replace the old notice with the updated one in the file
file_put_contents($filename, preg_replace($pattern, $updatedNotice, file_get_contents($filename)));
return true; // Change detected
}
// 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)));
// No match found, add a new line to the header
$newNotice = "Copyright (C) " . date('Y') . "\t\t" . $name . $emailTabs . "<" . $email . ">";
// Read the file content
$fileContent = file_get_contents($filename);
// Check if there are existing copyright notices
$pos = max(strrpos($fileContent, "{$prefix0}Copyright"), strrpos($fileContent, "{$prefix1}Copyright"));
if ($pos !== false) {
// Add the new notice behind the last preceding copyright notices
$pos = strpos($fileContent, "\n", $pos) + 1;
$fileContent = substr_replace($fileContent, $prefix1 . $newNotice . "\n", $pos, 0);
} elseif (strpos($fileContent, $prefix3) !== false) {
// Add the new notice after the shebang or '<?php' line
$fileContent = preg_replace("~{$r_prefix3}.*\n~", "$0$prefix0$newNotice\n$prefix2\n", $fileContent, 1);
} else {
return false; // No change detected
}
// Write the updated content back to the file
file_put_contents($filename, $fileContent);
return true; // Change detected
}
return false; // No change detected
}
// Main program
// Check if filenames are provided as parameters
if ($argc < 2) {
echo "Usage: php " . __FILE__ . " <filename1> [<filename2> ...]" . PHP_EOL;
exit(1);
}
// Process each filename provided
$changesDetected = false;
for ($i = 1; $i < $argc; $i++) {
$filename = $argv[$i];
// Determine file type based on extension
$fileType = pathinfo($filename, PATHINFO_EXTENSION);
// Retrieve Git user information
$gitUserInfo = getGitUserInfo();
$name = $gitUserInfo['name'];
$email = $gitUserInfo['email'];
// Update or add copyright notice based on file type
$changeDetected = updateCopyrightNotice($filename, $fileType, $name, $email);
$changesDetected |= $changeDetected;
if ($changeDetected) {
echo "Copyright notice updated in '$filename'" . PHP_EOL;
}
}
if (!$changesDetected) {
echo "No changes needed in any file" . PHP_EOL;
}

View file

@ -190,9 +190,9 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) {
// Si verif ok et action add, on ajoute la ligne
if ($ok && GETPOST('actionadd', 'alpha')) {
if ($tabrowid[$id]) {
// Recupere id libre pour insertion
// Get free id for insert
$newid = 0;
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
$sql = "SELECT MAX(".$tabrowid[$id].") newid from ".$tabname[$id];
$result = $db->query($sql);
if ($result) {
$obj = $db->fetch_object($result);

View file

@ -200,9 +200,9 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) {
// Si verif ok et action add, on ajoute la ligne
if ($ok && GETPOST('actionadd', 'alpha')) {
if ($tabrowid[$id]) {
// Recupere id libre pour insertion
// Get free id for insert
$newid = 0;
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
$sql = "SELECT MAX(".$tabrowid[$id].") newid from ".$tabname[$id];
$result = $db->query($sql);
if ($result) {
$obj = $db->fetch_object($result);

View file

@ -184,9 +184,9 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) {
// Si verif ok et action add, on ajoute la ligne
if ($ok && GETPOST('actionadd', 'alpha')) {
if ($tabrowid[$id]) {
// Recupere id libre pour insertion
// Get free id for insert
$newid = 0;
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
$sql = "SELECT MAX(".$tabrowid[$id].") newid from ".$tabname[$id];
$result = $db->query($sql);
if ($result) {
$obj = $db->fetch_object($result);

View file

@ -676,6 +676,35 @@ if ($action != 'export_csv') {
}
print '</tr>';
// Accounting result
if (getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT')) {
print '<tr class="liste_total">';
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print "<td></td>\n";
}
print '<td class="right">' . $langs->trans("AccountingResult") . ':</td>';
if (getDolGlobalString('ACCOUNTANCY_SHOW_OPENING_BALANCE')) {
print '<td></td>';
}
$accountingResult = $object->accountingResult($search_date_start, $search_date_end);
if ($accountingResult < 0) {
$accountingResultDebit = price(price2num(abs($accountingResult), 'MT'));
$accountingResultClassCSS = ' error';
} else {
$accountingResultCredit = price(price2num($accountingResult, 'MT'));
$accountingResultClassCSS = ' green';
}
print '<td class="right nowraponall amount' . $accountingResultClassCSS . '">' . $accountingResultDebit . '</td>';
print '<td class="right nowraponall amount' . $accountingResultClassCSS . '">' . $accountingResultCredit . '</td>';
print '<td></td>';
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print "<td></td>\n";
}
print '</tr>';
}
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;

View file

@ -43,9 +43,9 @@ $cancel = GETPOST('cancel', 'aZ09');
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
$id = GETPOST('id', 'int'); // id of record
$id = GETPOSTINT('id'); // id of record
$mode = GETPOST('mode', 'aZ09'); // '' or '_tmp'
$piece_num = GETPOST("piece_num", 'int'); // id of transaction (several lines share the same transaction id)
$piece_num = GETPOSTINT("piece_num"); // id of transaction (several lines share the same transaction id)
$accountingaccount = new AccountingAccount($db);
$accountingjournal = new AccountingJournal($db);
@ -65,8 +65,8 @@ if ($subledger_account == -1) {
$subledger_label = GETPOST('subledger_label', 'alphanohtml');
$label_operation = GETPOST('label_operation', 'alphanohtml');
$debit = price2num(GETPOST('debit', 'alpha'));
$credit = price2num(GETPOST('credit', 'alpha'));
$debit = (float) price2num(GETPOST('debit', 'alpha'));
$credit = (float) price2num(GETPOST('credit', 'alpha'));
$save = GETPOST('save', 'alpha');
if (!empty($save)) {
@ -252,7 +252,7 @@ if ($action == "confirm_update") {
$object->credit = 0;
$object->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int'));
$object->doc_type = GETPOST('doc_type', 'alpha');
$object->piece_num = GETPOST('next_num_mvt', 'alpha');
$object->piece_num = GETPOSTINT('next_num_mvt');
$object->doc_ref = GETPOST('doc_ref', 'alpha');
$object->code_journal = $journal_code;
$object->journal_label = $journal_label;
@ -350,7 +350,7 @@ if ($action == 'create') {
$next_num_mvt = $object->getNextNumMvt('_tmp');
if (empty($next_num_mvt)) {
dol_print_error('', 'Failed to get next piece number');
dol_print_error(null, 'Failed to get next piece number');
}
print '<form action="'.$_SERVER["PHP_SELF"].'" name="create_mvt" method="POST">';

View file

@ -505,6 +505,7 @@ $sql .= " t.label_operation,";
$sql .= " t.debit,";
$sql .= " t.credit,";
$sql .= " t.lettering_code,";
$sql .= " t.date_lettering,";
$sql .= " t.montant as amount,";
$sql .= " t.sens,";
$sql .= " t.fk_user_author,";
@ -513,6 +514,7 @@ $sql .= " t.code_journal,";
$sql .= " t.journal_label,";
$sql .= " t.piece_num,";
$sql .= " t.date_creation,";
$sql .= " t.date_lim_reglement,";
$sql .= " t.tms as date_modification,";
$sql .= " t.date_export,";
$sql .= " t.date_validated as date_validation,";
@ -575,19 +577,47 @@ if (count($sqlwhere) > 0) {
// Export into a file with format defined into setup (FEC, CSV, ...)
// Must be after definition of $sql
if ($action == 'export_fileconfirm' && $user->hasRight('accounting', 'mouvements', 'export')) {
// TODO Replace the fetchAll to get all ->line followed by call to ->export(). fetchAll() currently consumes too much memory on large export.
// Replace this with the query($sql) and loop on each line to export them.
$result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter, 'AND', (!getDolGlobalString('ACCOUNTING_REEXPORT') ? 0 : 1));
// Export files then exit
$accountancyexport = new AccountancyExport($db);
$error = 0;
$nbtotalofrecords = 0;
// Open transaction to read lines to export, export them and update field date_export or date_validated
$db->begin();
/* The fast and low memory method to get and count full list converts the sql into a sql count */
$sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
$sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
$resql = $db->query($sqlforcount);
if ($resql) {
$objforcount = $db->fetch_object($resql);
$nbtotalofrecords = $objforcount->nbtotalofrecords;
} else {
dol_print_error($db);
}
$db->free($resql);
//$sqlforexport = $sql;
//$sqlforexport .= $db->order($sortfield, $sortorder);
// TODO Call the fetchAll for a $limit and $offset
// Replace the fetchAll to get all ->line followed by call to ->export(). fetchAll() currently consumes too much memory on large export.
// Replace this with the query($sqlforexport) on a limited block and loop on each line to export them.
$limit = 0;
$offset = 0;
$result = $object->fetchAll($sortorder, $sortfield, $limit, $offset, $filter, 'AND', (!getDolGlobalString('ACCOUNTING_REEXPORT') ? 0 : 1));
if ($result < 0) {
$error++;
setEventMessages($object->error, $object->errors, 'errors');
} else {
// Export files then exit
$accountancyexport = new AccountancyExport($db);
$formatexport = GETPOST('formatexport', 'int');
$notexportlettering = GETPOST('notexportlettering', 'alpha');
if (!empty($notexportlettering)) {
if (is_array($object->lines)) {
foreach ($object->lines as $k => $movement) {
@ -602,9 +632,9 @@ if ($action == 'export_fileconfirm' && $user->hasRight('accounting', 'mouvements
$withAttachment = !empty(trim(GETPOST('notifiedexportfull', 'alphanohtml'))) ? 1 : 0;
// Output data on screen or download
$result = $accountancyexport->export($object->lines, $formatexport, $withAttachment);
//$result = $accountancyexport->export($object->lines, $formatexport, $withAttachment);
$result = $accountancyexport->export($object->lines, $formatexport, $withAttachment, 1, 1, 1);
$error = 0;
if ($result < 0) {
$error++;
} else {
@ -612,11 +642,9 @@ if ($action == 'export_fileconfirm' && $user->hasRight('accounting', 'mouvements
if (is_array($object->lines)) {
dol_syslog("/accountancy/bookkeeping/list.php Function export_file Specify movements as exported", LOG_DEBUG);
// Specify as export : update field date_export or date_validated
$db->begin();
// TODO Merge update for each line into one global using rowid IN (list of movement ids)
foreach ($object->lines as $movement) {
// Update the line to set date_export and/or date_validated (if not already set !)
$now = dol_now();
$setfields = '';
@ -640,23 +668,45 @@ if ($action == 'export_fileconfirm' && $user->hasRight('accounting', 'mouvements
}
}
if (!$error) {
$db->commit();
} else {
$error++;
if ($error) {
$accountancyexport->errors[] = $langs->trans('NotAllExportedMovementsCouldBeRecordedAsExportedOrValidated');
$db->rollback();
}
}
}
}
if ($error) {
setEventMessages('', $accountancyexport->errors, 'errors');
header('Location: '.$_SERVER['PHP_SELF']);
}
exit(); // download or show errors
}
if (!$error) {
$db->commit();
$downloadFilePath = $accountancyexport->generatedfiledata['downloadFilePath'];
$downloadFileMimeType = $accountancyexport->generatedfiledata['downloadFileMimeType'];
$downloadFileFullName = $accountancyexport->generatedfiledata['downloadFileFullName'];
// No error, we can output the file
top_httphead($downloadFileMimeType);
header('Content-Description: File Transfer');
// Add MIME Content-Disposition from RFC 2183 (inline=automatically displayed, attachment=need user action to open)
$attachment = 1;
if ($attachment) {
header('Content-Disposition: attachment; filename="'.$downloadFileFullName.'"');
} else {
header('Content-Disposition: inline; filename="'.$downloadFileFullName.'"');
}
// Ajout directives pour resoudre bug IE
header('Cache-Control: Public, must-revalidate');
header('Pragma: public');
header('Content-Length: ' . dol_filesize($downloadFilePath));
readfileLowMemory($downloadFilePath);
} else {
$db->rollback();
setEventMessages('', $accountancyexport->errors, 'errors');
header('Location: '.$_SERVER['PHP_SELF']);
}
exit(); // download or show errors
}

View file

@ -781,7 +781,7 @@ class AccountancyCategory // extends CommonObject
global $conf, $mysoc;
if (empty($mysoc->country_id)) {
dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined');
dol_print_error(null, 'Call to select_accounting_account with mysoc country not yet defined');
exit();
}
@ -846,7 +846,7 @@ class AccountancyCategory // extends CommonObject
$sql = '';
if (empty($mysoc->country_id) && empty($mysoc->country_code)) {
dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined');
dol_print_error(null, 'Call to select_accounting_account with mysoc country not yet defined');
exit();
}

View file

@ -81,17 +81,21 @@ class AccountancyExport
public $errors = array();
/**
*
* @var string Separator
* @var string Separator
*/
public $separator = '';
/**
*
* @var string End of line
* @var string End of line
*/
public $end_line = '';
/**
* @var array Generated file
*/
public $generatedfiledata = array();
/**
* Constructor
*
@ -195,7 +199,7 @@ class AccountancyExport
*/
public function getTypeConfig()
{
global $conf, $langs;
global $langs;
$exporttypes = array(
'param' => array(
@ -319,24 +323,25 @@ class AccountancyExport
* @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
* @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
* or 1 to write in file and uses a temp directory - Forced by default when use withAttachment = 1
* @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/)
* @return int Return integer <0 if KO, >0 OK
* @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.
* @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)
public function export(&$TData, $formatexportset, $withAttachment = 0, $downloadMode = 0, $outputMode = 0, $noouput = 0)
{
global $conf, $langs;
global $search_date_end; // Used into /accountancy/tpl/export_journal.tpl.php
global $db, $conf, $langs; // The tpl file use $db
global $search_date_end; // Used into /accountancy/tpl/export_journal.tpl.php
// Define name of file to save
$filename = 'general_ledger-'.$this->getFormatCode($formatexportset);
$type_export = 'general_ledger';
global $db; // The tpl file use $db
$completefilename = '';
$exportFile = null;
$exportFileName = '';
@ -369,17 +374,19 @@ class AccountancyExport
// begin to print header for direct download
top_httphead($mimetype, 1);
}
include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
if ($outputMode == 1 || $outputMode == 2) {
if ($outputMode == 1) {
// uses temp directory by default to write files
// uses the temp directory by default to write files
if (!empty($conf->accounting->multidir_temp[$conf->entity])) {
$outputDir = $conf->accounting->multidir_temp[$conf->entity];
} else {
$outputDir = $conf->accounting->dir_temp;
}
} else {
// uses default export directory "accounting/export"
// uses the default export directory "accounting/export"
if (!empty($conf->accounting->multidir_output[$conf->entity])) {
$outputDir = $conf->accounting->multidir_output[$conf->entity];
} else {
@ -503,7 +510,8 @@ class AccountancyExport
break;
}
// create and download export file or archive
// Create and download export file or archive
if ($outputMode == 1 || $outputMode == 2) {
$error = 0;
@ -558,14 +566,19 @@ class AccountancyExport
}
// download export file or archive
if (!empty($downloadFileMimeType) && !empty($downloadFileFullName) && !empty($downloadFilePath)) {
if (!empty($downloadFileMimeType) && !empty($downloadFileFullName) && !empty($downloadFilePath) && empty($noouput)) {
// deprecated. We must not use this anymore, but have $noouput = 1 because HTTP header must be sent
// into main page not into a method.
header('Content-Type: ' . $downloadFileMimeType);
header('Content-Disposition: attachment; filename=' . $downloadFileFullName);
header('Cache-Control: Public, must-revalidate');
header('Pragma: public');
header('Content-Length: ' . dol_filesize($downloadFilePath));
readfileLowMemory($downloadFilePath);
}
$this->generatedfiledata = array('downloadFilePath' => $downloadFilePath, 'downloadFileMimeType' => $downloadFileMimeType, 'downloadFileFullName' => $downloadFileFullName);
}
}
@ -1343,6 +1356,7 @@ class AccountancyExport
foreach ($objectLines as $line) {
if ($line->debit == 0 && $line->credit == 0) {
//var_dump($line->id);
//unset($array[$line]);
} else {
$date_creation = dol_print_date($line->date_creation, '%Y%m%d');
@ -1492,6 +1506,7 @@ class AccountancyExport
$tab[] = $attachmentFileName;
$output = implode($separator, $tab).$end_line;
if ($exportFile) {
fwrite($exportFile, $output);
} else {

View file

@ -219,6 +219,7 @@ class Accountancy extends DolibarrApi
$filter['t.doc_date<='] = $doc_date_end;
}
// @FIXME Critical bugged. Never use fetchAll without limit !
$result = $bookkeeping->fetchAll($sortorder, $sortfield, 0, 0, $filter, 'AND', $alreadyexport);
if ($result < 0) {

View file

@ -62,7 +62,7 @@ class BookKeeping extends CommonObject
public $id;
/**
* @var string Date of source document, in db date NOT NULL
* @var int Date of source document, in db date NOT NULL
*/
public $doc_date;
@ -285,7 +285,7 @@ class BookKeeping extends CommonObject
$this->journal_label = trim($this->journal_label);
}
if (isset($this->piece_num)) {
$this->piece_num = trim($this->piece_num);
$this->piece_num = (int) $this->piece_num;
}
if (empty($this->debit)) {
$this->debit = 0.0;
@ -614,18 +614,6 @@ class BookKeeping extends CommonObject
if (isset($this->label_operation)) {
$this->label_operation = trim($this->label_operation);
}
if (isset($this->debit)) {
$this->debit = trim($this->debit);
}
if (isset($this->credit)) {
$this->credit = trim($this->credit);
}
if (isset($this->montant)) {
$this->montant = trim($this->montant);
}
if (isset($this->amount)) {
$this->amount = trim($this->amount);
}
if (isset($this->sens)) {
$this->sens = trim($this->sens);
}
@ -639,7 +627,7 @@ class BookKeeping extends CommonObject
$this->journal_label = trim($this->journal_label);
}
if (isset($this->piece_num)) {
$this->piece_num = trim($this->piece_num);
$this->piece_num = (int) $this->piece_num;
}
if (empty($this->debit)) {
$this->debit = 0;
@ -663,9 +651,9 @@ class BookKeeping extends CommonObject
return -1;
}
$this->debit = price2num($this->debit, 'MT');
$this->credit = price2num($this->credit, 'MT');
$this->montant = price2num($this->montant, 'MT');
$this->debit = (float) price2num($this->debit, 'MT');
$this->credit = (float) price2num($this->credit, 'MT');
$this->montant = (float) price2num($this->montant, 'MT');
$now = dol_now();
@ -1348,15 +1336,6 @@ class BookKeeping extends CommonObject
if (isset($this->label_operation)) {
$this->label_operation = trim($this->label_operation);
}
if (isset($this->debit)) {
$this->debit = trim($this->debit);
}
if (isset($this->credit)) {
$this->credit = trim($this->credit);
}
if (isset($this->amount)) {
$this->amount = trim($this->amount);
}
if (isset($this->sens)) {
$this->sens = trim($this->sens);
}
@ -1370,7 +1349,7 @@ class BookKeeping extends CommonObject
$this->journal_label = trim($this->journal_label);
}
if (isset($this->piece_num)) {
$this->piece_num = trim($this->piece_num);
$this->piece_num = (int) $this->piece_num;
}
$result = $this->canModifyBookkeeping($this->id);
@ -1385,8 +1364,9 @@ class BookKeeping extends CommonObject
return -1;
}
$this->debit = price2num($this->debit, 'MT');
$this->credit = price2num($this->credit, 'MT');
$this->debit = (float) price2num($this->debit, 'MT');
$this->credit = (float) price2num($this->credit, 'MT');
$this->montant = (float) price2num($this->montant, 'MT');
// Check parameters
// Put here code to add a control on parameters values
@ -1785,7 +1765,7 @@ class BookKeeping extends CommonObject
{
global $conf;
$sql = "SELECT piece_num, doc_date,code_journal, journal_label, doc_ref, doc_type,";
$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";
// In llx_accounting_bookkeeping_tmp, field date_export doesn't exist
if ($mode != "_tmp") {
@ -1825,7 +1805,7 @@ class BookKeeping extends CommonObject
* Return next number movement
*
* @param string $mode Mode
* @return string Next numero to use
* @return int Return integer <0 if KO, >0 if OK (Next numero to use)
*/
public function getNextNumMvt($mode = '')
{
@ -1850,7 +1830,7 @@ class BookKeeping extends CommonObject
} else {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::getNextNumMvt ".$this->error, LOG_ERR);
return -1;
return "-1";
}
}
@ -2126,7 +2106,7 @@ class BookKeeping extends CommonObject
* @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
* @return string String with HTML select
* @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 = '')
{
@ -2152,7 +2132,7 @@ class BookKeeping extends CommonObject
if (!$resql) {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::select_account ".$this->error, LOG_ERR);
return -1;
return "-1";
}
$out = ajax_combobox($htmlname, $event);
@ -2232,7 +2212,7 @@ class BookKeeping extends CommonObject
* Description of accounting account
*
* @param string $account Accounting account
* @return string Account desc
* @return string|int Account desc or -1 if KO
*/
public function get_compte_desc($account = null)
{
@ -2264,7 +2244,7 @@ class BookKeeping extends CommonObject
} else {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(__METHOD__." ".$this->error, LOG_ERR);
return -1;
return "-1";
}
}
@ -2594,6 +2574,56 @@ class BookKeeping extends CommonObject
return 1;
}
/**
* Define accounting result
*
* @param int $date_start Date start
* @param int $date_end Date end
* @return string Accounting result
*/
public function accountingResult($date_start, $date_end)
{
global $conf;
$this->db->begin();
$income_statement_amount = 0;
if (getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT')) {
$accounting_groups_used_for_income_statement = array_filter(array_map('trim', explode(',', getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT'))), 'strlen');
foreach ($accounting_groups_used_for_income_statement as $item) {
$pcg_type_filter[] = "'" . $this->db->escape($item) . "'";
}
$sql = 'SELECT';
$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 .= ' 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.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) . "'";
$sql .= ' GROUP BY t.numero_compte, aa.pcg_type';
$resql = $this->db->query($sql);
if (!$resql) {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
} else {
while ($obj = $this->db->fetch_object($resql)) {
$income_statement_amount += $obj->accounting_result;
}
}
}
return $income_statement_amount;
}
/**
* Close fiscal period
*
@ -2731,7 +2761,7 @@ class BookKeeping extends CommonObject
$bookkeeping = new BookKeeping($this->db);
$bookkeeping->doc_date = $new_fiscal_period->date_start;
$bookkeeping->date_lim_reglement = '';
$bookkeeping->date_lim_reglement = (string) '';
$bookkeeping->doc_ref = $new_fiscal_period->label;
$bookkeeping->date_creation = $now;
$bookkeeping->doc_type = 'closure';
@ -2778,7 +2808,7 @@ class BookKeeping extends CommonObject
$bookkeeping = new BookKeeping($this->db);
$bookkeeping->doc_date = $new_fiscal_period->date_start;
$bookkeeping->date_lim_reglement = '';
$bookkeeping->date_lim_reglement = (string) '';
$bookkeeping->doc_ref = $new_fiscal_period->label;
$bookkeeping->date_creation = $now;
$bookkeeping->doc_type = 'closure';
@ -2984,7 +3014,7 @@ class BookKeepingLine extends CommonObjectLine
*/
public $id;
public $doc_date = '';
public $doc_date = null;
public $doc_type;
public $doc_ref;
@ -3024,7 +3054,7 @@ class BookKeepingLine extends CommonObjectLine
public $multicurrency_amount;
/**
* @var float Multicurrency code
* @var string Multicurrency code
*/
public $multicurrency_code;

View file

@ -50,7 +50,7 @@ $result = $object->fetch($id_journal);
if ($result > 0) {
$id_journal = $object->id;
} elseif ($result < 0) {
dol_print_error('', $object->error, $object->errors);
dol_print_error(null, $object->error, $object->errors);
} elseif ($result == 0) {
accessforbidden('ErrorRecordNotFound');
}

View file

@ -307,8 +307,8 @@ if (empty($reshook)) {
$object->address = trim(GETPOST("address", 'alphanohtml'));
$object->zip = trim(GETPOST("zipcode", 'alphanohtml'));
$object->town = trim(GETPOST("town", 'alphanohtml'));
$object->state_id = GETPOST("state_id", 'int');
$object->country_id = GETPOST("country_id", 'int');
$object->state_id = GETPOSTINT("state_id");
$object->country_id = GETPOSTINT("country_id");
$object->phone = trim(GETPOST("phone", 'alpha'));
$object->phone_perso = trim(GETPOST("phone_perso", 'alpha'));
@ -334,9 +334,9 @@ if (empty($reshook)) {
}
// Get status and public property
$object->statut = GETPOST("statut", 'alpha');
$object->status = GETPOST("statut", 'alpha');
$object->public = GETPOST("public", 'alpha');
$object->statut = GETPOSTINT("statut");
$object->status = GETPOSTINT("statut");
$object->public = GETPOSTINT("public");
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
@ -913,7 +913,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
$object = new Adherent($db);
$result = $object->fetch($id);
if ($result <= 0) {
dol_print_error('', $object->error);
dol_print_error(null, $object->error);
}
}
$objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates

View file

@ -245,7 +245,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
}
if ($result <= 0) {
dol_print_error('', $result);
dol_print_error(null, $result);
}
} else {
dol_print_error($db);

View file

@ -7,7 +7,7 @@
* Copyright (C) 2009-2017 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2014-2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015-2023 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2015-2024 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2018-2019 Thibault FOUCART <support@ptibogxiv.net>
@ -1121,7 +1121,7 @@ class Adherent extends CommonObject
* @param int $isencrypted 0 ou 1 if the password needs to be encrypted in the DB (default: 0)
* @param int $notrigger 1=Does not raise the triggers
* @param int $nosyncuser Do not synchronize linked user
* @return string If OK return clear password, 0 if no change, < 0 if error
* @return string|int Clear password if change ok, 0 if no change, <0 if error
*/
public function setPassword($user, $password = '', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0)
{
@ -2461,15 +2461,13 @@ class Adherent extends CommonObject
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Load indicators this->nb in state board
*
* @return int Return integer <0 if KO, >0 if OK
*/
public function load_state_board()
public function loadStateBoard()
{
// phpcs:enable
global $conf;
$this->nb = array();

View file

@ -79,7 +79,7 @@ $catid = GETPOST("catid", 'int');
$socid = GETPOST('socid', 'int');
$search_filter = GETPOST("search_filter", 'alpha');
$search_status = GETPOST("search_status", 'intcomma'); // statut
$search_status = GETPOST("search_status", 'intcomma'); // status
$search_datec_start = dol_mktime(0, 0, 0, GETPOST('search_datec_start_month', 'int'), GETPOST('search_datec_start_day', 'int'), GETPOST('search_datec_start_year', 'int'));
$search_datec_end = dol_mktime(23, 59, 59, GETPOST('search_datec_end_month', 'int'), GETPOST('search_datec_end_day', 'int'), GETPOST('search_datec_end_year', 'int'));
$search_datem_start = dol_mktime(0, 0, 0, GETPOST('search_datem_start_month', 'int'), GETPOST('search_datem_start_day', 'int'), GETPOST('search_datem_start_year', 'int'));
@ -374,7 +374,7 @@ if ((!empty($search_categ) && $search_categ > 0) || !empty($catid)) {
$sql .= " d.rowid, d.ref, d.login, d.lastname, d.firstname, d.gender, d.societe as company, d.fk_soc,";
$sql .= " d.civility, d.datefin, d.address, d.zip, d.town, d.state_id, d.country,";
$sql .= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.birth, d.public, d.photo,";
$sql .= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,";
$sql .= " d.fk_adherent_type as type_id, d.morphy, d.statut as status, d.datec as date_creation, d.tms as date_update,";
$sql .= " d.note_private, d.note_public, d.import_key,";
$sql .= " s.nom,";
$sql .= " ".$db->ifsql("d.societe IS NULL", "s.nom", "d.societe")." as companyname,";
@ -967,9 +967,16 @@ if (!empty($arrayfields['d.tms']['checked'])) {
print '</td>';
}
// Import Key
if (!empty($arrayfields['d.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).'">';
print '</td>';
}
// Status
if (!empty($arrayfields['d.statut']['checked'])) {
print '<td class="liste_titre right parentonrightofpage">';
print '<td class="liste_titre center parentonrightofpage">';
$liststatus = array(
Adherent::STATUS_DRAFT => $langs->trans("Draft"),
Adherent::STATUS_VALIDATED => $langs->trans("Validated"),
@ -980,13 +987,6 @@ if (!empty($arrayfields['d.statut']['checked'])) {
print '</td>';
}
// Import Key
if (!empty($arrayfields['d.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).'">';
print '</td>';
}
// Action column
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="liste_titre center maxwidthsearch">';
@ -1008,7 +1008,7 @@ if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
$totalarray['nbfield']++;
}
if (getDolGlobalString('MAIN_SHOW_TECHNICAL_ID')) {
print_liste_field_titre("ID", $_SERVER["PHP_SELF"], '', '', $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("ID", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
$totalarray['nbfield']++;
}
if (!empty($arrayfields['d.ref']['checked'])) {
@ -1096,27 +1096,27 @@ $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // No
print $hookmanager->resPrint;
if (!empty($arrayfields['d.datec']['checked'])) {
print_liste_field_titre($arrayfields['d.datec']['label'], $_SERVER["PHP_SELF"], "d.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
print_liste_field_titre($arrayfields['d.datec']['label'], $_SERVER["PHP_SELF"], "d.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
$totalarray['nbfield']++;
}
if (!empty($arrayfields['d.birth']['checked'])) {
print_liste_field_titre($arrayfields['d.birth']['label'], $_SERVER["PHP_SELF"], "d.birth", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
print_liste_field_titre($arrayfields['d.birth']['label'], $_SERVER["PHP_SELF"], "d.birth", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
$totalarray['nbfield']++;
}
if (!empty($arrayfields['d.tms']['checked'])) {
print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['d.statut']['checked'])) {
print_liste_field_titre($arrayfields['d.statut']['label'], $_SERVER["PHP_SELF"], "d.statut,t.subscription,d.datefin", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
$totalarray['nbfield']++;
}
if (!empty($arrayfields['d.import_key']['checked'])) {
print_liste_field_titre($arrayfields['d.import_key']['label'], $_SERVER["PHP_SELF"], "d.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
$totalarray['nbfield']++;
}
if (!empty($arrayfields['d.statut']['checked'])) {
print_liste_field_titre($arrayfields['d.statut']['label'], $_SERVER["PHP_SELF"], "d.statut,t.subscription,d.datefin", "", $param, '', $sortfield, $sortorder, 'center ');
$totalarray['nbfield']++;
}
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch center ');
$totalarray['nbfield']++;
}
print "</tr>\n";
@ -1143,7 +1143,8 @@ while ($i < $imaxinloop) {
$memberstatic->lastname = $obj->lastname;
$memberstatic->firstname = $obj->firstname;
$memberstatic->gender = $obj->gender;
$memberstatic->statut = $obj->statut;
$memberstatic->statut = $obj->status;
$memberstatic->status = $obj->status;
$memberstatic->datefin = $datefin;
$memberstatic->socid = $obj->fk_soc;
$memberstatic->photo = $obj->photo;
@ -1374,7 +1375,7 @@ while ($i < $imaxinloop) {
// End of subscription date
$datefin = $db->jdate($obj->datefin);
if (!empty($arrayfields['d.datefin']['checked'])) {
print '<td class="nowrap center">';
print '<td class="nowraponall center">';
if ($datefin) {
print dol_print_date($datefin, 'day');
if ($memberstatic->hasDelay()) {
@ -1384,7 +1385,7 @@ while ($i < $imaxinloop) {
} else {
if (!empty($obj->subscription)) {
print '<span class="opacitymedium">'.$langs->trans("SubscriptionNotReceived").'</span>';
if ($obj->statut > 0) {
if ($obj->status > 0) {
print " ".img_warning();
}
} else {
@ -1429,15 +1430,7 @@ while ($i < $imaxinloop) {
$totalarray['nbfield']++;
}
}
// Status
if (!empty($arrayfields['d.statut']['checked'])) {
print '<td class="nowrap right">';
print $memberstatic->LibStatut($obj->statut, $obj->subscription, $datefin, 5);
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
// Import key
if (!empty($arrayfields['d.import_key']['checked'])) {
print '<td class="tdoverflowmax100 center" title="'.dol_escape_htmltag($obj->import_key).'">';
print dol_escape_htmltag($obj->import_key);
@ -1446,6 +1439,15 @@ while ($i < $imaxinloop) {
$totalarray['nbfield']++;
}
}
// Status
if (!empty($arrayfields['d.statut']['checked'])) {
print '<td class="nowrap center">';
print $memberstatic->LibStatut($obj->status, $obj->subscription, $datefin, 5);
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
// Action column
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="center">';

View file

@ -197,7 +197,7 @@ if ($id > 0) {
print dol_get_fiche_end();
} else {
dol_print_error('', 'Parameter rowid not defined');
dol_print_error(null, 'Parameter rowid not defined');
}

View file

@ -163,7 +163,7 @@ if (empty($reshook) && $action == 'setuserid' && ($user->hasRight('user', 'self'
if (GETPOST("userid", 'int') != $object->user_id) { // If link differs from currently in database
$result = $object->setUserId(GETPOST("userid", 'int'));
if ($result < 0) {
dol_print_error('', $object->error);
dol_print_error(null, $object->error);
}
$action = '';
}
@ -192,7 +192,7 @@ if (empty($reshook) && $action == 'setsocid') {
if (!$error) {
$result = $object->setThirdPartyId(GETPOST('socid', 'int'));
if ($result < 0) {
dol_print_error('', $object->error);
dol_print_error(null, $object->error);
}
$action = '';
}

View file

@ -33,7 +33,7 @@ if (isModEnabled("banque")) {
}
// Load translation files required by the page
$langs->loadLangs(array("companies", "members", "bills", "users"));
$langs->loadLangs(array("companies", "members", "bills", "users", "banks"));
$adh = new Adherent($db);
$adht = new AdherentType($db);
@ -42,12 +42,12 @@ $errmsg = '';
$action = GETPOST("action", 'alpha');
$rowid = GETPOST("rowid", "int") ? GETPOST("rowid", "int") : GETPOST("id", "int");
$typeid = GETPOST("typeid", "int");
$typeid = GETPOSTINT("typeid");
$cancel = GETPOST('cancel', 'alpha');
$confirm = GETPOST('confirm');
$note = GETPOST('note', 'alpha');
$typeid = (int) GETPOST('typeid', 'int');
$amount = price2num(GETPOST('amount', 'alpha'), 'MT');
$typeid = GETPOSTINT('typeid');
$amount = (float) price2num(GETPOST('amount', 'alpha'), 'MT');
if (!$user->hasRight('adherent', 'cotisation', 'lire')) {
accessforbidden();
@ -86,7 +86,10 @@ if ($user->hasRight('adherent', 'cotisation', 'creer') && $action == 'update' &&
$errmsg = '';
if ($object->fk_bank) {
$newdatestart = dol_mktime(GETPOST('datesubhour', 'int'), GETPOST('datesubmin', 'int'), 0, GETPOST('datesubmonth', 'int'), GETPOST('datesubday', 'int'), GETPOST('datesubyear', 'int'));
$newdateend = dol_mktime(GETPOST('datesubendhour', 'int'), GETPOST('datesubendmin', 'int'), 0, GETPOST('datesubendmonth', 'int'), GETPOST('datesubendday', 'int'), GETPOST('datesubendyear', 'int'));
if ($object->fk_bank > 0) {
$accountline = new AccountLine($db);
$result = $accountline->fetch($object->fk_bank);
@ -94,9 +97,10 @@ if ($user->hasRight('adherent', 'cotisation', 'creer') && $action == 'update' &&
if ($accountline->rappro) {
$errmsg = $langs->trans("SubscriptionLinkedToConciliatedTransaction");
} else {
$accountline->datev = dol_mktime(GETPOST('datesubhour', 'int'), GETPOST('datesubmin', 'int'), 0, GETPOST('datesubmonth', 'int'), GETPOST('datesubday', 'int'), GETPOST('datesubyear', 'int'));
$accountline->dateo = dol_mktime(GETPOST('datesubhour', 'int'), GETPOST('datesubmin', 'int'), 0, GETPOST('datesubmonth', 'int'), GETPOST('datesubday', 'int'), GETPOST('datesubyear', 'int'));
$accountline->datev = $newdatestart;
$accountline->dateo = $newdatestart;
$accountline->amount = $amount;
$result = $accountline->update($user);
if ($result < 0) {
$errmsg = $accountline->error;
@ -106,8 +110,8 @@ if ($user->hasRight('adherent', 'cotisation', 'creer') && $action == 'update' &&
if (!$errmsg) {
// Modify values
$object->dateh = dol_mktime(GETPOST('datesubhour', 'int'), GETPOST('datesubmin', 'int'), 0, GETPOST('datesubmonth', 'int'), GETPOST('datesubday', 'int'), GETPOST('datesubyear', 'int'));
$object->datef = dol_mktime(GETPOST('datesubendhour', 'int'), GETPOST('datesubendmin', 'int'), 0, GETPOST('datesubendmonth', 'int'), GETPOST('datesubendday', 'int'), GETPOST('datesubendyear', 'int'));
$object->dateh = $newdatestart;
$object->datef = $newdateend;
$object->fk_type = $typeid;
$object->note_public = $note;
$object->note_private = $note;
@ -335,7 +339,7 @@ if ($rowid && $action != 'edit') {
// Bank line
if (isModEnabled("banque") && (getDolGlobalString('ADHERENT_BANK_USE') || $object->fk_bank)) {
print '<tr><td>'.$langs->trans("BankTransactionLine").'</td><td class="valeur">';
if ($object->fk_bank) {
if ($object->fk_bank > 0) {
$bankline = new AccountLine($db);
$result = $bankline->fetch($object->fk_bank);
print $bankline->getNomUrl(1, 0, 'showall');
@ -358,8 +362,8 @@ if ($rowid && $action != 'edit') {
print '<div class="tabsAction">';
if ($user->hasRight('adherent', 'cotisation', 'creer')) {
if (!empty($bankline->rappro) || empty($bankline)) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"]."?rowid=".$object->id.'&action=edit&token='.newToken().'">'.$langs->trans("Modify")."</a></div>";
if (empty($bankline->rappro) || empty($bankline)) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"]."?rowid=".((int) $object->id).'&action=edit&token='.newToken().'">'.$langs->trans("Modify")."</a></div>";
} else {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.$langs->trans("BankLineConciliated").'" href="#">'.$langs->trans("Modify")."</a></div>";
}

View file

@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$langs->loadLangs(array("members", "companies"));
$langs->loadLangs(array("members", "companies", "banks"));
$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ...
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
@ -172,7 +172,7 @@ $accountstatic = new Account($db);
$now = dol_now();
// List of subscriptions
$sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, d.photo, d.statut,";
$sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, d.photo, d.statut as status,";
$sql .= " d.gender, d.email, d.morphy,";
$sql .= " c.rowid as crowid, c.fk_type, c.subscription,";
$sql .= " c.dateadh, c.datef, c.datec as date_creation, c.tms as date_update,";
@ -611,7 +611,8 @@ while ($i < $imaxinloop) {
$adherent->firstname = $obj->firstname;
$adherent->ref = $obj->rowid;
$adherent->id = $obj->rowid;
$adherent->statut = $obj->statut;
$adherent->statut = $obj->status;
$adherent->status = $obj->status;
$adherent->login = $obj->login;
$adherent->photo = $obj->photo;
$adherent->gender = $obj->gender;
@ -672,14 +673,14 @@ while ($i < $imaxinloop) {
}
// Ref
if (!empty($arrayfields['d.ref']['checked'])) {
print '<td>'.$subscription->getNomUrl(1).'</td>';
print '<td class="nowraponall">'.$subscription->getNomUrl(1).'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
// Type
if (!empty($arrayfields['d.fk_type']['checked'])) {
print '<td class="nowraponall">';
print '<td class="tdoverflowmax100">';
if ($typeid > 0) {
print $adht->getNomUrl(1);
}
@ -739,14 +740,14 @@ while ($i < $imaxinloop) {
// Date start
if (!empty($arrayfields['c.dateadh']['checked'])) {
print '<td class="center">'.dol_print_date($db->jdate($obj->dateadh), 'day')."</td>\n";
print '<td class="center nowraponall">'.dol_print_date($db->jdate($obj->dateadh), 'day')."</td>\n";
if (!$i) {
$totalarray['nbfield']++;
}
}
// Date end
if (!empty($arrayfields['c.datef']['checked'])) {
print '<td class="center">'.dol_print_date($db->jdate($obj->datef), 'day')."</td>\n";
print '<td class="center nowraponall">'.dol_print_date($db->jdate($obj->datef), 'day')."</td>\n";
if (!$i) {
$totalarray['nbfield']++;
}

View file

@ -8,6 +8,7 @@
* Copyright (C) 2019-2022 Thibault Foucart <support@ptibogxiv.net>
* Copyright (C) 2020 Josep Lluís Amador <joseplluis@lliuretic.cat>
* Copyright (C) 2021 Waël Almoman <info@almoman.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
@ -47,7 +48,7 @@ $cancel = GETPOST('cancel', 'alpha');
$toselect = GETPOST('toselect', 'array');
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha');
$mode = GETPOST('mode', 'alopha');
$mode = GETPOST('mode', 'alpha');
$sall = GETPOST("sall", "alpha");
$filter = GETPOST("filter", 'alpha');

View file

@ -40,7 +40,7 @@ if (!$user->admin) {
accessforbidden();
}
$id = GETPOST('rowid', 'int');
$id = GETPOSTINT('rowid');
$action = GETPOST('action', 'aZ09');
$optioncss = GETPOST('optionscss', 'alphanohtml');

View file

@ -21,7 +21,7 @@
/**
* \file htdocs/admin/expensereport_ik.php
* \ingroup expensereport
* \brief Page to display expense tax ik
* \brief Page to display expense tax ik. Used when MAIN_USE_EXPENSE_IK is set.
*/
// Load Dolibarr environment
@ -38,11 +38,11 @@ $error = 0;
$action = GETPOST('action', 'aZ09');
$id = GETPOST('id', 'int');
$ikoffset = GETPOST('ikoffset', 'int');
$coef = GETPOST('coef', 'int');
$fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat');
$fk_range = GETPOST('fk_range', 'int');
$id = GETPOSTINT('id');
$ikoffset = (float) price2num(GETPOST('ikoffset', 'alpha'));
$coef = (float) price2num(GETPOST('coef', 'alpha'));
$fk_c_exp_tax_cat = GETPOSTINT('fk_c_exp_tax_cat');
$fk_range = GETPOSTINT('fk_range');
$expIk = new ExpenseReportIk($db);
@ -59,7 +59,7 @@ if ($action == 'updateik') {
if ($id > 0) {
$result = $expIk->fetch($id);
if ($result < 0) {
dol_print_error('', $expIk->error, $expIk->errors);
dol_print_error(null, $expIk->error, $expIk->errors);
}
}
@ -85,7 +85,7 @@ if ($action == 'updateik') {
if ($id > 0) {
$result = $expIk->fetch($id);
if ($result < 0) {
dol_print_error('', $expIk->error, $expIk->errors);
dol_print_error(null, $expIk->error, $expIk->errors);
}
$expIk->delete($user);
@ -167,6 +167,7 @@ foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab) {
echo $range->ik->ikoffset;
}
echo '</td>';
// Coef
echo '<td class="nowraponall">';
if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) {

View file

@ -65,17 +65,17 @@ if (empty($reshook)) {
$apply_to = GETPOST('apply_to');
$fk_user = GETPOST('fk_user', 'int');
$fk_usergroup = GETPOST('fk_usergroup', 'int');
$restrictive = GETPOST('restrictive', 'int');
$fk_c_type_fees = GETPOST('fk_c_type_fees', 'int');
$restrictive = GETPOSTINT('restrictive');
$fk_c_type_fees = GETPOSTINT('fk_c_type_fees');
$code_expense_rules_type = GETPOST('code_expense_rules_type');
$dates = dol_mktime(12, 0, 0, GETPOST('startmonth'), GETPOST('startday'), GETPOST('startyear'));
$datee = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear'));
$amount = price2num(GETPOST('amount'), 'MT', 2);
$amount = (float) price2num(GETPOST('amount'), 'MT', 2);
if (!empty($id)) {
$result = $object->fetch($id);
if ($result < 0) {
dol_print_error('', $object->error, $object->errors);
dol_print_error(null, $object->error, $object->errors);
}
}
@ -166,7 +166,7 @@ if (empty($reshook)) {
$tab_apply = array(
'A' => $langs->trans('All'),
'G' => $langs->trans('Group'),
'G' => $langs->trans('UserGroup'),
'U' => $langs->trans('User')
);
$tab_rules_type = array(
@ -176,22 +176,24 @@ if (empty($reshook)) {
'EX_EXP' => $langs->trans('OnExpense')
);
}
/*
* View
*/
llxHeader('', $langs->trans("ExpenseReportsSetup"));
$form = new Form($db);
/*
* View
*/
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
print load_fiche_titre($langs->trans("ExpenseReportsSetup"), $linkback, 'title_setup');
llxHeader('', $langs->trans("ExpenseReportsSetup"));
$head = expensereport_admin_prepare_head();
print dol_get_fiche_head($head, 'expenserules', $langs->trans("ExpenseReportsRules"), -1, 'trip');
$form = new Form($db);
echo '<span class="opacitymedium">' . $langs->trans('ExpenseReportRulesDesc') . '</span>';
print '<br><br>';
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
print load_fiche_titre($langs->trans("ExpenseReportsSetup"), $linkback, 'title_setup');
$head = expensereport_admin_prepare_head();
print dol_get_fiche_head($head, 'expenserules', $langs->trans("ExpenseReportsRules"), -1, 'trip');
echo '<span class="opacitymedium">' . $langs->trans('ExpenseReportRulesDesc') . '</span>';
print '<br><br>';
if ($action != 'edit') {
echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">';
@ -232,26 +234,29 @@ if ($action != 'edit') {
}
echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">';
echo '<input type="hidden" name="token" value="' . newToken() . '" />';
echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">';
echo '<input type="hidden" name="token" value="' . newToken() . '" />';
if ($action == 'edit') {
echo '<input type="hidden" name="id" value="' . $object->id . '" />';
echo '<input type="hidden" name="action" value="save" />';
}
echo '<table class="noborder centpercent">';
print dol_get_fiche_end();
echo '<tr class="liste_titre expensereportrules">';
echo '<th class="linecolapplyto">' . $langs->trans('ExpenseReportApplyTo') . '</th>';
echo '<th class="linecoltype">' . $langs->trans('Type') . '</th>';
echo '<th class="linecollimiton">' . $langs->trans('ExpenseReportLimitOn') . '</th>';
echo '<th class="linecoldatestart">' . $langs->trans('ExpenseReportDateStart') . '</th>';
echo '<th class="linecoldateend">' . $langs->trans('ExpenseReportDateEnd') . '</th>';
echo '<th class="linecollimitamount">' . $langs->trans('ExpenseReportLimitAmount') . '</th>';
echo '<th class="linecolrestrictive">' . $langs->trans('ExpenseReportRestrictive') . '</th>';
echo '<th>&nbsp;</th>';
echo '</tr>';
echo '<table class="noborder centpercent">';
echo '<tr class="liste_titre expensereportrules">';
echo '<th class="linecolapplyto">' . $langs->trans('ExpenseReportApplyTo') . '</th>';
echo '<th class="linecoltype">' . $langs->trans('Type') . '</th>';
echo '<th class="linecollimiton">' . $langs->trans('ExpenseReportLimitOn') . '</th>';
echo '<th class="linecoldatestart">' . $langs->trans('ExpenseReportDateStart') . '</th>';
echo '<th class="linecoldateend">' . $langs->trans('ExpenseReportDateEnd') . '</th>';
echo '<th class="linecollimitamount">' . $langs->trans('ExpenseReportLimitAmount') . '</th>';
echo '<th class="linecolrestrictive">' . $langs->trans('ExpenseReportRestrictive') . '</th>';
echo '<th>&nbsp;</th>';
echo '</tr>';
foreach ($rules as $rule) {
echo '<tr class="oddeven linetrdata" id="'.$rule->id.'">';
@ -273,7 +278,6 @@ foreach ($rules as $rule) {
}
echo '</td>';
echo '<td class="linecoltype">';
if ($action == 'edit' && $object->id == $rule->id) {
echo $form->selectExpense($object->fk_c_type_fees, 'fk_c_type_fees', 0, 1, 1);
@ -351,11 +355,14 @@ foreach ($rules as $rule) {
echo '</tr>';
}
if (count($rules) == 0) {
print '<tr class="none"><td colspan="8"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
}
echo '</table>';
echo '</form>';
echo '</table>';
echo '</form>';
echo '<script type="text/javascript"> $(function() {
echo '<script type="text/javascript"> $(function() {
$("#apply_to").change(function() {
var value = $(this).val();
if (value == "A") {

View file

@ -73,7 +73,7 @@ if ($action == 'updateMask') {
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
}
} elseif ($action == 'specimen') { // For fiche inter
} elseif ($action == 'specimen') { // For Intervention card
$modele = GETPOST('module', 'alpha');
$inter = new Fichinter($db);

View file

@ -355,7 +355,7 @@ if (count($listinsetup) > 0) {
if ($supported) {
$redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$keyforsupportedoauth2array]['callbackfile'].'_oauthcallback.php';
print '<tr class="oddeven value">';
print '<td>'.$langs->trans("UseTheFollowingUrlAsRedirectURI").'</td>';
print '<td>'.$form->textwithpicto($langs->trans("RedirectURL"), $langs->trans("UseTheFollowingUrlAsRedirectURI")).'</td>';
print '<td><input style="width: 80%" type="text" name="uri'.$keyforsupportedoauth2array.'" id="uri'.$keyforsupportedoauth2array.$keyforprovider.'" value="'.$redirect_uri.'" disabled>';
print ajax_autoselect('uri'.$keyforsupportedoauth2array.$keyforprovider);
print '</td>';

View file

@ -93,12 +93,12 @@ if (empty($conf->use_javascript_ajax)) {
} else {
print '<td width="60" class="right">';
$arrval = array(
'0'=>$langs->trans("No"),
'1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')',
'2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')',
'3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')',
$langs->trans("No"),
$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')',
$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')',
$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')',
);
print $form->selectarray("activate_RESOURCE_USE_SEARCH_TO_SELECT", $arrval, $conf->global->RESOURCE_USE_SEARCH_TO_SELECT);
print $form->selectarray("activate_RESOURCE_USE_SEARCH_TO_SELECT", $arrval, getDolGlobalInt('RESOURCE_USE_SEARCH_TO_SELECT'));
print '</td>';
print '<td class="right">';
print '<input type="submit" class="button small" name="RESOURCE_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">';

View file

@ -2,6 +2,7 @@
/* Copyright (C) 2004-2022 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2007 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013-2015 Juanjo Menent <jmenent@2byte.es>
* 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
@ -484,11 +485,11 @@ print '</form>';
print '<br>';
if (GETPOST('info', 'int') > 0) {
if (GETPOSTINT('info') > 0) {
if (function_exists('password_hash')) {
print $langs->trans("Note: The function password_hash exists on your PHP")."<br>\n";
} else {
print $langs->trans("Note: The function password_hash does not exists on your PHP")."<br>\n";
print $langs->trans("Note: The function password_hash does not exist on your PHP")."<br>\n";
}
print 'MAIN_SECURITY_HASH_ALGO = '.getDolGlobalString('MAIN_SECURITY_HASH_ALGO')."<br>\n";
print 'MAIN_SECURITY_SALT = '.getDolGlobalString('MAIN_SECURITY_SALT')."<br>\n";

View file

@ -247,6 +247,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
print load_fiche_titre($langs->trans("NumberingModules", $myTmpObjectKey), '', '');
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td>';
@ -343,7 +344,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
}
}
}
print "</table><br>\n";
print "</table></div><br>\n";
}
if ($myTmpObjectArray['includedocgeneration']) {
@ -374,6 +375,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
dol_print_error($db);
}
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
print '<table class="noborder centpercent">'."\n";
print '<tr class="liste_titre">'."\n";
print '<td>'.$langs->trans("Name").'</td>';
@ -486,7 +488,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
}
}
print '</table>';
print '</table></div>';
}
}

View file

@ -473,8 +473,6 @@ foreach ($dirmodels as $reldir) {
}
print '</td>';
print "</tr>\n";
// Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
@ -494,6 +492,8 @@ foreach ($dirmodels as $reldir) {
print '<td class="center">';
print $formcategory->textwithpicto('', $htmltooltip, 1, 0);
print '</td>';
print "</tr>\n";
}
}
}

View file

@ -161,9 +161,9 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) {
// Si verif ok et action add, on ajoute la ligne
if ($ok && GETPOST('actionadd', 'alpha')) {
if ($tabrowid[$id]) {
// Recupere id libre pour insertion
// Get free id for insert
$newid = 0;
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
$sql = "SELECT MAX(".$tabrowid[$id].") newid from ".$tabname[$id];
$result = $db->query($sql);
if ($result) {
$obj = $db->fetch_object($result);

View file

@ -44,7 +44,7 @@ class Ai
* Constructor
*
* @param string $apiEndpoint Endpoint of api
* @param boolean $apiKey key of api
* @param string $apiKey key of api
*/
public function __construct($apiEndpoint, $apiKey)
{

View file

@ -50,11 +50,11 @@ $rawData = file_get_contents('php://input');
$jsonData = json_decode($rawData, true);
if (is_null($jsonData)) {
dol_print_error('data with format JSON valide.');
dol_print_error(null, 'data with format JSON valide.');
}
$token = GETPOST('token');
if ($token !== currentToken()) { // Remplacez 'newToken' par le nom de votre variable de session contenant le token
dol_print_error('CSRF token validation failed.');
dol_print_error(null, 'CSRF token validation failed.');
exit;
}
$chatGPT = new Ai('API_ENDPOINT', 'API_KEY');
@ -66,5 +66,5 @@ $generatedContent = $chatGPT->generateContent($instructions);
if ($generatedContent) {
print $generatedContent;
} else {
dol_print_error('error!!');
dol_print_error(null, 'error!!');
}

View file

@ -446,7 +446,7 @@ if (method_exists($apiMethodInfo->className, $terminateCall)) {
fastcgi_finish_request();
}
// Call a termination method. Warning: This method can do I/O, sync but must not make ouput.
// Call a termination method. Warning: This method can do I/O, sync but must not make output.
call_user_func(array(Luracast\Restler\Scope::get($apiMethodInfo->className), $terminateCall), $responsedata);
}

View file

@ -1561,7 +1561,7 @@ class Asset extends CommonObject
}
if ($mybool === false) {
dol_print_error('', "Failed to include file ".$file);
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View file

@ -217,7 +217,7 @@ class BOM extends CommonObject
// If this object has a subtable with lines
/**
* @var int Name of subtable line
* @var string Name of subtable line
*/
public $table_element_line = 'bom_bomline';
@ -247,12 +247,12 @@ class BOM extends CommonObject
public $lines = array();
/**
* @var int Calculated cost for the BOM
* @var float Calculated cost for the BOM
*/
public $total_cost = 0;
/**
* @var int Calculated cost for 1 unit of the product in BOM
* @var float Calculated cost for 1 unit of the product in BOM
*/
public $unit_cost = 0;
@ -597,7 +597,7 @@ class BOM extends CommonObject
* @param int $position Position of BOM-Line in BOM-Lines
* @param int $fk_bom_child Id of BOM Child
* @param string $import_key Import Key
* @param string $fk_unit Unit
* @param int $fk_unit Unit
* @param array $array_options extrafields array
* @param int $fk_default_workstation Default workstation
* @return int Return integer <0 if KO, Id of created object if OK
@ -636,9 +636,9 @@ class BOM extends CommonObject
$position = -1;
}
$qty = price2num($qty);
$efficiency = price2num($efficiency);
$position = price2num($position);
$qty = (float) price2num($qty);
$efficiency = (float) price2num($efficiency);
$position = (float) price2num($position);
$this->db->begin();
@ -741,9 +741,9 @@ class BOM extends CommonObject
$position = -1;
}
$qty = price2num($qty);
$efficiency = price2num($efficiency);
$position = price2num($position);
$qty = (float) price2num($qty);
$efficiency = (float) price2num($efficiency);
$position = (float) price2num($position);
$this->db->begin();
@ -890,7 +890,7 @@ class BOM extends CommonObject
}
if ($mybool === false) {
dol_print_error('', "Failed to include file ".$file);
dol_print_error(null, "Failed to include file ".$file);
return '';
}
@ -1475,7 +1475,7 @@ class BOM extends CommonObject
$this->error = $tmpproduct->error;
return -1;
}
$line->unit_cost = price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp);
$line->unit_cost = price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : (float) $tmpproduct->pmp);
if (empty($line->unit_cost)) {
if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0) {
if ($productFournisseur->fourn_remise_percent != "0") {
@ -1486,7 +1486,7 @@ class BOM extends CommonObject
}
}
$line->total_cost = price2num($line->qty * $line->unit_cost, 'MT');
$line->total_cost = (float) price2num($line->qty * $line->unit_cost, 'MT');
$this->total_cost += $line->total_cost;
} else {
@ -1495,7 +1495,7 @@ class BOM extends CommonObject
if ($res > 0) {
$bom_child->calculateCosts();
$line->childBom[] = $bom_child;
$this->total_cost += price2num($bom_child->total_cost * $line->qty, 'MT');
$this->total_cost += (float) price2num($bom_child->total_cost * $line->qty, 'MT');
$this->total_cost += $line->total_cost;
} else {
$this->error = $bom_child->error;
@ -1512,7 +1512,7 @@ class BOM extends CommonObject
$res = $workstation->fetch($line->fk_default_workstation);
if ($res > 0) {
$line->total_cost = price2num($qtyhourforline * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated), 'MT');
$line->total_cost = (float) price2num($qtyhourforline * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated), 'MT');
} else {
$this->error = $workstation->error;
return -3;
@ -1526,9 +1526,9 @@ class BOM extends CommonObject
}
if ($qtyhourservice) {
$line->total_cost = price2num($qtyhourforline / $qtyhourservice * $tmpproduct->cost_price, 'MT');
$line->total_cost = (float) price2num($qtyhourforline / $qtyhourservice * $tmpproduct->cost_price, 'MT');
} else {
$line->total_cost = price2num($line->qty * $tmpproduct->cost_price, 'MT');
$line->total_cost = (float) price2num($line->qty * $tmpproduct->cost_price, 'MT');
}
}
@ -1536,12 +1536,12 @@ class BOM extends CommonObject
}
}
$this->total_cost = price2num($this->total_cost, 'MT');
$this->total_cost = (float) price2num($this->total_cost, 'MT');
if ($this->qty > 0) {
$this->unit_cost = price2num($this->total_cost / $this->qty, 'MU');
$this->unit_cost = (float) price2num($this->total_cost / $this->qty, 'MU');
} elseif ($this->qty < 0) {
$this->unit_cost = price2num($this->total_cost * $this->qty, 'MU');
$this->unit_cost = (float) price2num($this->total_cost * $this->qty, 'MU');
}
}

View file

@ -1019,7 +1019,7 @@ class Availabilities extends CommonObject
}
if ($mybool === false) {
dol_print_error('', "Failed to include file ".$file);
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View file

@ -1007,7 +1007,7 @@ class Calendar extends CommonObject
}
if ($mybool === false) {
dol_print_error('', "Failed to include file ".$file);
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View file

@ -40,8 +40,8 @@ $title = (string) GETPOST("title", "alpha");
$url = (string) GETPOST("url", "alpha");
$urlsource = GETPOST("urlsource", "alpha");
$target = GETPOST("target", "int");
$userid = GETPOST("userid", "int");
$position = GETPOST("position", "int");
$userid = GETPOSTINT("userid");
$position = GETPOSTINT("position");
$backtopage = GETPOST('backtopage', 'alpha');

View file

@ -53,6 +53,7 @@ $backtopage = GETPOST('backtopage', 'alpha');
$label = (string) GETPOST('label', 'alphanohtml');
$description = (string) GETPOST('description', 'restricthtml');
$color = preg_replace('/[^0-9a-f#]/i', '', (string) GETPOST('color', 'alphanohtml'));
$position = (int) GETPOST('position', 'int');
$visible = (int) GETPOST('visible', 'int');
$parent = (int) GETPOST('parent', 'int');
@ -95,7 +96,7 @@ $error = 0;
/*
* Actions
*/
$parameters = array('socid' => $socid, 'origin' => $origin, 'catorigin' => $catorigin, 'type' => $type, 'urlfrom' => $urlfrom, 'backtopage' => $backtopage, 'label' => $label, 'description' => $description, 'color' => $color, 'visible' => $visible, 'parent' => $parent);
$parameters = array('socid' => $socid, 'origin' => $origin, 'catorigin' => $catorigin, 'type' => $type, 'urlfrom' => $urlfrom, 'backtopage' => $backtopage, 'label' => $label, 'description' => $description, 'color' => $color, 'position' => $position, 'visible' => $visible, 'parent' => $parent);
// Note that $action and $object may be modified by some hooks
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
if ($reshook < 0) {
@ -138,6 +139,7 @@ if (empty($reshook)) {
}
$object->label = $label;
$object->color = $color;
$object->position = $position;
$object->description = dol_htmlcleanlastbr($description);
$object->socid = ($socid > 0 ? $socid : 0);
$object->visible = $visible;
@ -259,6 +261,11 @@ if ($user->hasRight('categorie', 'creer')) {
print $formother->selectColor($color, 'color');
print '</td></tr>';
// Position
print '<tr>';
print '<td class="titlefieldcreate">'.$langs->trans("Position").'</td><td><input id="position" class="minwidth100" name="position" value="'.$position.'">';
print'</td></tr>';
// Parent category
print '<tr><td>'.$langs->trans("AddIn").'</td><td>';
print img_picto($langs->trans("ParentCategory"), 'category', 'class="pictofixedwidth"');

View file

@ -50,7 +50,7 @@ $visible = (int) GETPOST('visible', 'int');
$parent = (int) GETPOST('parent', 'int');
if ($id == "") {
dol_print_error('', 'Missing parameter id');
dol_print_error(null, 'Missing parameter id');
exit();
}

View file

@ -43,7 +43,7 @@ $action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm');
if ($id == '' && $label == '') {
dol_print_error('', 'Missing parameter id');
dol_print_error(null, 'Missing parameter id');
exit();
}

View file

@ -42,7 +42,7 @@ $action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha');
if ($id == '' && $label == '') {
dol_print_error('', 'Missing parameter id');
dol_print_error(null, 'Missing parameter id');
exit();
}

View file

@ -66,7 +66,7 @@ $pageprev = $page - 1;
$pagenext = $page + 1;
if ($id == "" && $label == "") {
dol_print_error('', 'Missing parameter id');
dol_print_error(null, 'Missing parameter id');
exit();
}
@ -153,7 +153,7 @@ if ($id > 0 && $removeelem > 0 && $action == 'unlink') {
$result = $object->del_type($tmpobject, $elementtype);
if ($result < 0) {
dol_print_error('', $object->error);
dol_print_error(null, $object->error);
}
}

View file

@ -72,7 +72,7 @@ $addreminder = GETPOST('addreminder', 'alpha');
$offsetvalue = GETPOSTINT('offsetvalue');
$offsetunit = GETPOST('offsetunittype_duration', 'aZ09');
$remindertype = GETPOST('selectremindertype', 'aZ09');
$modelmail = GETPOST('actioncommsendmodel_mail', 'int');
$modelmail = GETPOSTINT('actioncommsendmodel_mail');
$complete = GETPOST('complete', 'alpha'); // 'na' must be allowed
$private = GETPOST('private', 'alphanohtml');
if ($complete == 'na' || $complete == -2) {
@ -127,7 +127,7 @@ if ($id > 0 && $action != 'add') {
$ret1 = $object->fetch_userassigned();
}
if ($ret < 0 || $ret1 < 0) {
dol_print_error('', $object->error);
dol_print_error(null, $object->error);
}
}
@ -368,7 +368,7 @@ if (empty($reshook) && $action == 'add') {
$hasPermissionOnLinkedObject = 1;
}
if ($hasPermissionOnLinkedObject) {
$object->fk_element = GETPOST("fk_element", 'int');
$object->fk_element = GETPOSTINT("fk_element");
$object->elementtype = GETPOST("elementtype", 'alpha');
}
}
@ -387,7 +387,7 @@ if (empty($reshook) && $action == 'add') {
}
$object->fk_project = GETPOSTISSET("projectid") ? GETPOST("projectid", 'int') : 0;
$taskid = GETPOST('taskid', 'int');
$taskid = GETPOSTINT('taskid');
if (!empty($taskid)) {
$taskProject = new Task($db);
if ($taskProject->fetch($taskid) > 0) {
@ -426,7 +426,7 @@ if (empty($reshook) && $action == 'add') {
if (!$error && getDolGlobalString('AGENDA_ENABLE_DONEBY')) {
if (GETPOST("doneby") > 0) {
$object->userdoneid = GETPOST("doneby", "int");
$object->userdoneid = GETPOSTINT("doneby");
}
}
@ -437,7 +437,7 @@ if (empty($reshook) && $action == 'add') {
}
if (GETPOST('socid', 'int') > 0) {
$object->socid = GETPOST('socid', 'int');
$object->socid = GETPOSTINT('socid');
$object->fetch_thirdparty();
$object->societe = $object->thirdparty; // For backward compatibility
@ -1545,8 +1545,14 @@ if ($action == 'create') {
if ($origin=='contact') {
$preselectedids[GETPOST('originid', 'int')] = GETPOST('originid', 'int');
}
// select "all" or "none" contact by default
if (getDolGlobalInt('MAIN_ACTIONCOM_CAN_ADD_ANY_CONTACT')) {
$select_contact_default = 0; // select "all" contacts by default : avoid to use it if there is a lot of contacts
} else {
$select_contact_default = -1; // select "none" by default
}
print img_picto('', 'contact', 'class="paddingrightonly"');
print $form->selectcontacts(!getDolGlobalString('MAIN_ACTIONCOM_CAN_ADD_ANY_CONTACT') ? GETPOST('socid', 'int') : 0, $preselectedids, 'socpeopleassigned[]', 1, '', '', 0, 'minwidth300 widthcentpercentminusxx maxwidth500', false, 0, array(), false, 'multiple', 'contactid');
print $form->selectcontacts(GETPOSTISSET('socid') ? GETPOSTINT('socid') : $select_contact_default, $preselectedids, 'socpeopleassigned[]', 1, '', '', 0, 'minwidth300 widthcentpercentminusxx maxwidth500', false, 0, array(), false, 'multiple', 'contactid');
print '</td></tr>';
}

View file

@ -218,7 +218,7 @@ if (empty($reshook)) {
// assujetissement a la TVA
if ($action == 'setassujtva' && $user->hasRight('societe', 'creer')) {
$object->fetch($id);
$object->tva_assuj = GETPOST('assujtva_value');
$object->tva_assuj = GETPOSTINT('assujtva_value');
$result = $object->update($object->id);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');

View file

@ -61,7 +61,7 @@ if (!$sortfield) {
$sortfield = "email";
}
$id = GETPOST('id', 'int');
$id = GETPOSTINT('id');
$rowid = GETPOST('rowid', 'int');
$action = GETPOST('action', 'aZ09');
$search_nom = GETPOST("search_nom");

View file

@ -163,7 +163,7 @@ if (empty($reshook)) {
$action = '';
} else {
if ($object->statut == 0) {
dol_print_error('', 'ErrorMailIsNotValidated');
dol_print_error(null, 'ErrorMailIsNotValidated');
exit;
}

View file

@ -645,6 +645,7 @@ if ($object->fetch($id) >= 0) {
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<input type="hidden" name="page_y" value="">';
$morehtmlcenter = '';
if ($allowaddtarget) {
@ -712,7 +713,7 @@ if ($object->fetch($id) >= 0) {
print '&nbsp;';
print '</td>';
//Statut
// Status
print '<td class="liste_titre center parentonrightofpage">';
print $formmailing->selectDestinariesStatus($search_dest_status, 'search_dest_status', 1, 'width100 onrightofpage');
print '</td>';

View file

@ -437,19 +437,19 @@ if (empty($reshook)) {
$object->datep = $datep;
$object->date = $datep;
$object->delivery_date = $date_delivery;
$object->availability_id = GETPOST('availability_id');
$object->demand_reason_id = GETPOST('demand_reason_id');
$object->fk_delivery_address = GETPOST('fk_address', 'int');
$object->shipping_method_id = GETPOST('shipping_method_id', 'int');
$object->warehouse_id = GETPOST('warehouse_id', 'int');
$object->availability_id = GETPOSTINT('availability_id');
$object->demand_reason_id = GETPOSTINT('demand_reason_id');
$object->fk_delivery_address = GETPOSTINT('fk_address');
$object->shipping_method_id = GETPOSTINT('shipping_method_id');
$object->warehouse_id = GETPOSTINT('warehouse_id');
$object->duree_validite = $duration;
$object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->cond_reglement_id = GETPOSTINT('cond_reglement_id');
$object->deposit_percent = GETPOST('cond_reglement_id_deposit_percent', 'alpha');
$object->mode_reglement_id = GETPOST('mode_reglement_id', 'int');
$object->fk_account = GETPOST('fk_account', 'int');
$object->socid = GETPOST('socid', 'int');
$object->contact_id = GETPOST('contactid', 'int');
$object->fk_project = GETPOST('projectid', 'int');
$object->mode_reglement_id = GETPOSTINT('mode_reglement_id');
$object->fk_account = GETPOSTINT('fk_account');
$object->socid = GETPOSTINT('socid');
$object->contact_id = GETPOSTINT('contactid');
$object->fk_project = GETPOSTINT('projectid');
$object->model_pdf = GETPOST('model', 'alphanohtml');
$object->author = $user->id; // deprecated
$object->user_author_id = $user->id;
@ -457,7 +457,7 @@ if (empty($reshook)) {
$object->note_public = GETPOST('note_public', 'restricthtml');
$object->statut = Propal::STATUS_DRAFT;
$object->status = Propal::STATUS_DRAFT;
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->fk_incoterms = GETPOSTINT('incoterm_id');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
} else {
setEventMessages($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), null, 'errors');
@ -468,27 +468,27 @@ if (empty($reshook)) {
$object->datep = $datep;
$object->date = $datep;
$object->delivery_date = $date_delivery;
$object->availability_id = GETPOST('availability_id', 'int');
$object->demand_reason_id = GETPOST('demand_reason_id', 'int');
$object->fk_delivery_address = GETPOST('fk_address', 'int');
$object->shipping_method_id = GETPOST('shipping_method_id', 'int');
$object->warehouse_id = GETPOST('warehouse_id', 'int');
$object->availability_id = GETPOSTINT('availability_id');
$object->demand_reason_id = GETPOSTINT('demand_reason_id');
$object->fk_delivery_address = GETPOSTINT('fk_address');
$object->shipping_method_id = GETPOSTINT('shipping_method_id');
$object->warehouse_id = GETPOSTINT('warehouse_id');
$object->duree_validite = price2num(GETPOST('duree_validite', 'alpha'));
$object->cond_reglement_id = GETPOST('cond_reglement_id', 'int');
$object->cond_reglement_id = GETPOSTINT('cond_reglement_id');
$object->deposit_percent = GETPOST('cond_reglement_id_deposit_percent', 'alpha');
$object->mode_reglement_id = GETPOST('mode_reglement_id', 'int');
$object->fk_account = GETPOST('fk_account', 'int');
$object->contact_id = GETPOST('contactid', 'int');
$object->fk_project = GETPOST('projectid', 'int');
$object->mode_reglement_id = GETPOSTINT('mode_reglement_id');
$object->fk_account = GETPOSTINT('fk_account');
$object->contact_id = GETPOSTINT('contactid');
$object->fk_project = GETPOSTINT('projectid');
$object->model_pdf = GETPOST('model');
$object->author = $user->id; // deprecated
$object->note_private = GETPOST('note_private', 'restricthtml');
$object->note_public = GETPOST('note_public', 'restricthtml');
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->fk_incoterms = GETPOSTINT('incoterm_id');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->origin = GETPOST('origin');
$object->origin_id = GETPOST('originid');
$object->origin_id = GETPOSTINT('originid');
// Multicurrency
if (isModEnabled("multicurrency")) {
@ -1616,7 +1616,7 @@ if (empty($reshook)) {
}
}
} elseif ($action == 'updateline' && $usercancreate && GETPOST('cancel', 'alpha')) {
header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition
header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // To re-display card in edit mode
exit();
} elseif ($action == 'classin' && $usercancreate) {
// Set project
@ -1654,14 +1654,15 @@ if (empty($reshook)) {
$result = $object->setWarehouse(GETPOST('warehouse_id', 'int'));
} elseif ($action == 'update_extras') {
$object->oldcopy = dol_clone($object, 2);
$attribute_name = GETPOST('attribute', 'restricthtml');
// Fill array 'array_options' with data from update form
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml'));
$ret = $extrafields->setOptionalsFromPost(null, $object, $attribute_name);
if ($ret < 0) {
$error++;
}
if (!$error) {
$result = $object->insertExtraFields('PROPAL_MODIFY');
$result = $object->updateExtraField($attribute_name, 'PROPAL_MODIFY');
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
$error++;

View file

@ -3685,15 +3685,13 @@ class Propal extends CommonObject
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Load the indicators this->nb for the state board
*
* @return int Return integer <0 if ko, >0 if ok
*/
public function load_state_board()
public function loadStateBoard()
{
// phpcs:enable
global $user;
$this->nb = array();
@ -3763,7 +3761,7 @@ class Propal extends CommonObject
}
if (!$mybool) {
dol_print_error('', "Failed to include file ".$file);
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View file

@ -39,7 +39,7 @@ if ($user->socid > 0) {
}
$backtopage = GETPOST('backtopage', 'alpha');
$cancel = GETPOST('cancel', 'aplha');
$cancel = GETPOST('cancel', 'alpha');
$action = GETPOST('action', 'aZ09');
// Security check
@ -99,7 +99,7 @@ llxHeader();
/*********************************************************************************
*
* Mode fiche
* Card mode
*
*********************************************************************************/
if ($socid > 0) {

View file

@ -290,24 +290,24 @@ if (empty($reshook)) {
$object->note_private = GETPOST('note_private', 'restricthtml');
$object->note_public = GETPOST('note_public', 'restricthtml');
$object->source = GETPOST('source_id', 'int');
$object->fk_project = GETPOST('projectid', 'int');
$object->fk_project = GETPOSTINT('projectid');
$object->ref_client = GETPOST('ref_client', 'alpha');
$object->model_pdf = GETPOST('model');
$object->cond_reglement_id = GETPOST('cond_reglement_id', 'int');
$object->deposit_percent = GETPOST('cond_reglement_id_deposit_percent', 'alpha');
$object->mode_reglement_id = GETPOST('mode_reglement_id', 'int');
$object->fk_account = GETPOST('fk_account', 'int');
$object->availability_id = GETPOST('availability_id');
$object->demand_reason_id = GETPOST('demand_reason_id', 'int');
$object->cond_reglement_id = GETPOSTINT('cond_reglement_id');
$object->deposit_percent = (float) GETPOST('cond_reglement_id_deposit_percent', 'int');
$object->mode_reglement_id = GETPOSTINT('mode_reglement_id');
$object->fk_account = GETPOSTINT('fk_account');
$object->availability_id = GETPOSTINT('availability_id');
$object->demand_reason_id = GETPOSTINT('demand_reason_id');
$object->delivery_date = $date_delivery;
$object->shipping_method_id = GETPOST('shipping_method_id', 'int');
$object->warehouse_id = GETPOST('warehouse_id', 'int');
$object->fk_delivery_address = GETPOST('fk_address', 'int');
$object->contact_id = GETPOST('contactid', 'int');
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->shipping_method_id = GETPOSTINT('shipping_method_id');
$object->warehouse_id = GETPOSTINT('warehouse_id');
$object->fk_delivery_address = GETPOSTINT('fk_address');
$object->contact_id = GETPOSTINT('contactid');
$object->fk_incoterms = GETPOSTINT('incoterm_id');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
$object->multicurrency_tx = (float) price2num(GETPOST('originmulticurrency_tx'));
// Fill array 'array_options' with data from add form
if (!$error) {
$ret = $extrafields->setOptionalsFromPost(null, $object);
@ -1304,7 +1304,7 @@ if (empty($reshook)) {
}
}
} elseif ($action == 'updateline' && $usercancreate && GETPOST('cancel', 'alpha')) {
header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition
header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // To re-display card in edit mode
exit();
} elseif ($action == 'confirm_validate' && $confirm == 'yes' && $usercanvalidate) {
$idwarehouse = GETPOST('idwarehouse', 'int');

View file

@ -131,7 +131,7 @@ class Commande extends CommonOrder
public $billed;
/**
* @var string Limit date payment
* @var int Deadline for payment
*/
public $date_lim_reglement;
/**
@ -436,7 +436,7 @@ class Commande extends CommonOrder
}
if ($mybool === false) {
dol_print_error('', "Failed to include file ".$file);
dol_print_error(null, "Failed to include file ".$file);
return '';
}
@ -1553,12 +1553,12 @@ class Commande extends CommonOrder
$ref_ext = '';
}
$remise_percent = price2num($remise_percent);
$qty = price2num($qty);
$remise_percent = (float) price2num($remise_percent);
$qty = (float) price2num($qty);
$pu_ht = price2num($pu_ht);
$pu_ht_devise = price2num($pu_ht_devise);
$pu_ttc = price2num($pu_ttc);
$pa_ht = price2num($pa_ht);
$pa_ht = (float) price2num($pa_ht);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5,1' or '5.1' or '5.1(XXX)', we must clean only if '5,1'
}
@ -3149,16 +3149,16 @@ class Commande extends CommonOrder
return -1;
}
$remise_percent = price2num($remise_percent);
$qty = price2num($qty);
$remise_percent = (float) price2num($remise_percent);
$qty = (float) price2num($qty);
$pu = price2num($pu);
$pa_ht = price2num($pa_ht);
$pa_ht = (float) price2num($pa_ht);
$pu_ht_devise = price2num($pu_ht_devise);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);
$txlocaltax1 = (float) price2num($txlocaltax1);
$txlocaltax2 = (float) price2num($txlocaltax2);
$this->db->begin();
@ -4062,15 +4062,13 @@ class Commande extends CommonOrder
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Load the indicators this->nb for the state board
*
* @return int Return integer <0 if KO, >0 if OK
*/
public function load_state_board()
public function loadStateBoard()
{
// phpcs:enable
global $user;
$this->nb = array();

View file

@ -117,7 +117,7 @@ $userstatic = new User($db);
/* *************************************************************************** */
/* */
/* Mode vue et edition */
/* Card view and edit mode */
/* */
/* *************************************************************************** */

View file

@ -1301,7 +1301,7 @@ if ($resql) {
// If we are in a situation where we need/can show balance, we calculate the start of balance
if (!$balancecalculated && (!empty($arrayfields['balancebefore']['checked']) || !empty($arrayfields['balance']['checked'])) && ($mode_balance_ok || $search_conciliated === '0')) {
if (!$search_account) {
dol_print_error('', 'account is not defined but $mode_balance_ok is true');
dol_print_error(null, 'account is not defined but $mode_balance_ok is true');
exit;
}

View file

@ -558,6 +558,8 @@ class Account extends CommonObject
*/
public function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur = '', $banque = '', $accountancycode = '', $datev = null, $num_releve = '', $amount_main_currency = null)
{
global $langs;
// Deprecation warning
if (is_numeric($oper)) {
dol_syslog(__METHOD__.": using numeric operations is deprecated", LOG_WARNING);
@ -590,11 +592,11 @@ class Account extends CommonObject
// Check parameters
if (!$oper) {
$this->error = "Operation code not defined";
$this->error = $langs->trans("OperNotDefined");
return -1;
}
if (!$this->id) {
$this->error = "this->id not defined";
$this->error = $langs->trans("ThisIdNotDefined");
return -2;
}
if ($this->courant == Account::TYPE_CASH && $oper != 'LIQ') {
@ -1346,16 +1348,14 @@ class Account extends CommonObject
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Load the indicators this->nb for the state board
*
* @param int $filteraccountid To get info for a particular account id
* @return int Return integer <0 if KO, >0 if OK
*/
public function load_state_board($filteraccountid = 0)
public function loadStateBoard($filteraccountid = 0)
{
// phpcs:enable
global $user;
if ($user->socid) {
@ -2092,7 +2092,7 @@ class AccountLine extends CommonObjectLine
$this->fk_user_rappro = $obj->fk_user_rappro;
$this->fk_type = $obj->fk_type; // Type of transaction
$this->rappro = $obj->rappro;
$this->rappro = (int) $obj->rappro;
$this->num_releve = $obj->num_releve;
$this->num_chq = $obj->num_chq;

View file

@ -55,9 +55,9 @@ if (isModEnabled('salaries')) {
$id = GETPOST('rowid', 'int');
$rowid = GETPOST("rowid", 'int');
$accountoldid = GETPOST('account', 'int'); // GETPOST('account') is old account id
$accountid = GETPOST('accountid', 'int'); // GETPOST('accountid') is new account id
$rowid = GETPOSTINT('rowid');
$accountoldid = GETPOSTINT('account'); // GETPOST('account') is old account id
$accountid = GETPOSTINT('accountid'); // GETPOST('accountid') is new account id
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha');

View file

@ -235,7 +235,7 @@ if ($action == 'confirm_delete' && !empty($permissiontodelete)) {
$object->fetch($id);
if (!($object->id > 0)) {
dol_print_error('', 'Error, object must be fetched before being deleted');
dol_print_error(null, 'Error, object must be fetched before being deleted');
exit;
}
@ -351,7 +351,7 @@ if ($action == "create" || $action == "start" || $action == 'close') {
} elseif ($key == 'card') {
$sql .= " AND cp.code = 'CB'";
} else {
dol_print_error('Value for key = '.$key.' not supported');
dol_print_error(null, 'Value for key = '.$key.' not supported');
exit;
}
if ($syear && !$smonth) {

View file

@ -114,7 +114,7 @@ $sql.= " AND f.entity IN (".getEntity('facture').")";
if ($syear && ! $smonth) $sql.= " AND dateo BETWEEN '".$db->idate(dol_get_first_day($syear, 1))."' AND '".$db->idate(dol_get_last_day($syear, 12))."'";
elseif ($syear && $smonth && ! $sday) $sql.= " AND dateo BETWEEN '".$db->idate(dol_get_first_day($syear, $smonth))."' AND '".$db->idate(dol_get_last_day($syear, $smonth))."'";
elseif ($syear && $smonth && $sday) $sql.= " AND dateo BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $smonth, $sday, $syear))."'";
else dol_print_error('', 'Year not defined');
else dol_print_error(null, 'Year not defined');
// Define filter on bank account
$sql.=" AND (b.fk_account = ".((int) $conf->global->CASHDESK_ID_BANKACCOUNT_CASH);
$sql.=" OR b.fk_account = ".((int) $conf->global->CASHDESK_ID_BANKACCOUNT_CB);
@ -133,7 +133,7 @@ elseif ($key == 'cheque') $sql.=" AND cp.code = 'CHQ'";
elseif ($key == 'card') $sql.=" AND cp.code = 'CB'";
else
{
dol_print_error('Value for key = '.$key.' not supported');
dol_print_error(null, 'Value for key = '.$key.' not supported');
exit;
}*/
if ($syear && !$smonth) {
@ -143,7 +143,7 @@ if ($syear && !$smonth) {
} elseif ($syear && $smonth && $sday) {
$sql .= " AND datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $smonth, $sday, $syear))."'";
} else {
dol_print_error('', 'Year not defined');
dol_print_error(null, 'Year not defined');
}
$resql = $db->query($sql);

View file

@ -57,8 +57,8 @@ $toselect = GETPOST('toselect', 'array');
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'invoicetemplatelist'; // To manage different context of search
// Security check
$id = (GETPOST('facid', 'int') ? GETPOST('facid', 'int') : GETPOST('id', 'int'));
$lineid = GETPOST('lineid', 'int');
$id = (GETPOSTINT('facid') ? GETPOSTINT('facid') : GETPOSTINT('id'));
$lineid = GETPOSTINT('lineid');
$ref = GETPOST('ref', 'alpha');
if ($user->socid) {
$socid = $user->socid;
@ -67,13 +67,13 @@ $objecttype = 'facture_rec';
if ($action == "create" || $action == "add") {
$objecttype = '';
}
$projectid = GETPOST('projectid', 'int');
$projectid = GETPOSTINT('projectid');
$year_date_when = GETPOST('year_date_when');
$month_date_when = GETPOST('month_date_when');
$selectedLines = GETPOST('toselect', 'array');
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
@ -181,16 +181,16 @@ if (empty($reshook)) {
$error++;
}
$frequency = GETPOST('frequency', 'int');
$reyear = GETPOST('reyear', 'int');
$remonth = GETPOST('remonth', 'int');
$reday = GETPOST('reday', 'int');
$rehour = GETPOST('rehour', 'int');
$remin = GETPOST('remin', 'int');
$nb_gen_max = GETPOST('nb_gen_max', 'int');
$frequency = GETPOSTINT('frequency');
$reyear = GETPOSTINT('reyear');
$remonth = GETPOSTINT('remonth');
$reday = GETPOSTINT('reday');
$rehour = GETPOSTINT('rehour');
$remin = GETPOSTINT('remin');
$nb_gen_max = GETPOSTINT('nb_gen_max');
//if (empty($nb_gen_max)) $nb_gen_max =0;
if (GETPOST('frequency', 'int')) {
if (GETPOSTINT('frequency')) {
if (empty($reyear) || empty($remonth) || empty($reday)) {
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("Date")), null, 'errors');
$action = "create";
@ -204,21 +204,21 @@ if (empty($reshook)) {
}
if (!$error) {
$object->subtype = GETPOST('subtype');
$object->subtype = GETPOSTINT('subtype');
$object->title = GETPOST('title', 'alphanohtml');
$object->note_private = GETPOST('note_private', 'restricthtml');
$object->note_public = GETPOST('note_public', 'restricthtml');
$object->model_pdf = GETPOST('modelpdf', 'alphanohtml');
$object->usenewprice = GETPOST('usenewprice', 'alphanohtml');
$object->mode_reglement_id = GETPOST('mode_reglement_id', 'int');
$object->cond_reglement_id = GETPOST('cond_reglement_id', 'int');
$object->mode_reglement_id = GETPOSTINT('mode_reglement_id');
$object->cond_reglement_id = GETPOSTINT('cond_reglement_id');
$object->frequency = $frequency;
$object->unit_frequency = GETPOST('unit_frequency', 'alpha');
$object->nb_gen_max = $nb_gen_max;
$object->auto_validate = GETPOST('auto_validate', 'int');
$object->generate_pdf = GETPOST('generate_pdf', 'int');
$object->auto_validate = GETPOSTINT('auto_validate');
$object->generate_pdf = GETPOSTINT('generate_pdf');
$object->fk_project = $projectid;
$date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear);
@ -230,9 +230,9 @@ if (empty($reshook)) {
}
// Get first contract linked to invoice used to generate template (facid is id of source invoice)
if (GETPOST('facid', 'int') > 0) {
if (GETPOSTINT('facid') > 0) {
$srcObject = new Facture($db);
$srcObject->fetch(GETPOST('facid', 'int'));
$srcObject->fetch(GETPOSTINT('facid'));
$srcObject->fetchObjectLinked();
@ -248,7 +248,7 @@ if (empty($reshook)) {
$db->begin();
$oldinvoice = new Facture($db);
$oldinvoice->fetch(GETPOST('facid', 'int'));
$oldinvoice->fetch(GETPOSTINT('facid'));
$onlylines = GETPOST('toselect', 'array');
@ -292,15 +292,15 @@ if (empty($reshook)) {
if ($action == 'setconditions' && $user->hasRight('facture', 'creer')) {
// Set condition
$object->context['actionmsg'] = $langs->trans("FieldXModified", $langs->transnoentitiesnoconv("PaymentTerm"));
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
$result = $object->setPaymentTerms(GETPOSTINT('cond_reglement_id'));
} elseif ($action == 'setmode' && $user->hasRight('facture', 'creer')) {
// Set mode
$object->context['actionmsg'] = $langs->trans("FieldXModified", $langs->transnoentitiesnoconv("PaymentMode"));
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
$result = $object->setPaymentMethods(GETPOSTINT('mode_reglement_id'));
} elseif ($action == 'classin' && $user->hasRight('facture', 'creer')) {
// Set project
$object->context['actionmsg'] = $langs->trans("FieldXModified", $langs->transnoentitiesnoconv("Project"));
$object->setProject(GETPOST('projectid', 'int'));
$object->setProject(GETPOSTINT('projectid'));
} elseif ($action == 'setref' && $user->hasRight('facture', 'creer')) {
// Set bank account
$object->context['actionmsg'] = $langs->trans("FieldXModifiedFromYToZ", $langs->transnoentitiesnoconv("Title"), $object->title, $ref);
@ -1204,7 +1204,7 @@ if ($action == 'create') {
print "</form>\n";
} else {
dol_print_error('', "Error, no invoice ".$object->id);
dol_print_error(null, "Error, no invoice ".$object->id);
}
} else {
/*

View file

@ -528,7 +528,7 @@ if (empty($reshook)) {
}
} elseif ($action == 'setrevenuestamp' && $usercancreate) {
$object->fetch($id);
$object->revenuestamp = GETPOST('revenuestamp');
$object->revenuestamp = (float) price2num(GETPOST('revenuestamp'));
$result = $object->update($user);
$object->update_price(1);
if ($result < 0) {
@ -1003,7 +1003,7 @@ if (empty($reshook)) {
} elseif ($action == 'add' && $usercancreate) {
// Insert new invoice in database
if ($socid > 0) {
$object->socid = GETPOST('socid', 'int');
$object->socid = GETPOSTINT('socid');
}
if (GETPOST('type', 'int') === '') {
@ -1104,7 +1104,7 @@ if (empty($reshook)) {
if (!empty($originentity)) {
$object->entity = $originentity;
}
$object->socid = GETPOST('socid', 'int');
$object->socid = GETPOSTINT('socid');
$object->subtype = GETPOST('subtype');
$object->ref = GETPOST('ref');
$object->date = $dateinvoice;
@ -1326,7 +1326,7 @@ if (empty($reshook)) {
}
if (!$error) {
$object->socid = GETPOST('socid', 'int');
$object->socid = GETPOSTINT('socid');
$object->type = GETPOST('type');
$object->subtype = GETPOST('subtype');
$object->ref = GETPOST('ref');
@ -1413,7 +1413,7 @@ if (empty($reshook)) {
}
if (!$error) {
$object->socid = GETPOST('socid', 'int');
$object->socid = GETPOSTINT('socid');
$object->type = GETPOST('type');
$object->subtype = GETPOST('subtype');
$object->ref = GETPOST('ref');
@ -5926,7 +5926,7 @@ if ($action == 'create') {
print dolGetButtonAction($htmltooltip, $langs->trans('Delete'), 'delete', $deleteHref, '', $enableDelete, $params);
} else {
$params['attr']['title'] = '';
print dolGetButtonAction($langs->trans('Delete'), $langs->trans('Delete'), 'delete', '#', '', false);
print dolGetButtonAction($htmltooltip, $langs->trans('Delete'), 'delete', '#', '', false);
}
}
print '</div>';

View file

@ -132,6 +132,9 @@ class FactureRec extends CommonInvoice
public $usenewprice = 0;
/**
* @var int Deadline for payment
*/
public $date_lim_reglement;
public $cond_reglement_code; // Code in llx_c_paiement
public $mode_reglement_code; // Code in llx_c_paiement

View file

@ -129,7 +129,7 @@ class Facture extends CommonInvoice
public $user_valid;
/**
* @var int ID
* @var int|null ID
*/
public $fk_user_valid;
@ -2452,7 +2452,7 @@ class Facture extends CommonInvoice
$this->type = self::TYPE_STANDARD;
}
if (isset($this->subtype)) {
$this->subtype = trim($this->subtype);
$this->subtype = (int) trim($this->subtype);
}
if (isset($this->ref)) {
$this->ref = trim($this->ref);
@ -3856,7 +3856,7 @@ class Facture extends CommonInvoice
$ref_ext = '';
}
$remise_percent = price2num($remise_percent);
$remise_percent = (float) price2num($remise_percent);
$qty = price2num($qty);
$pu_ht = price2num($pu_ht);
$pu_ht_devise = price2num($pu_ht_devise);
@ -4117,7 +4117,7 @@ class Facture extends CommonInvoice
$ref_ext = '';
}
$remise_percent = price2num($remise_percent);
$remise_percent = (float) price2num($remise_percent);
$qty = price2num($qty);
$pu = price2num($pu);
$pu_ht_devise = price2num($pu_ht_devise);
@ -4125,8 +4125,8 @@ class Facture extends CommonInvoice
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);
$txlocaltax1 = (float) price2num($txlocaltax1);
$txlocaltax2 = (float) price2num($txlocaltax2);
// Check parameters
if ($type < 0) {
@ -4633,7 +4633,7 @@ class Facture extends CommonInvoice
}
if (!$mybool) {
dol_print_error('', 'Failed to include file '.$file);
dol_print_error(null, 'Failed to include file '.$file);
return '';
}
@ -5152,15 +5152,13 @@ class Facture extends CommonInvoice
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
* @return int Return integer <0 if KO, >0 if OK
*/
public function load_state_board()
public function loadStateBoard()
{
// phpcs:enable
global $conf, $user;
$this->nb = array();

View file

@ -94,7 +94,7 @@ $search_date_when_end = dol_mktime(23, 59, 59, $search_date_when_endmonth, $sear
$search_recurring = GETPOST('search_recurring', 'int');
$search_frequency = GETPOST('search_frequency', 'alpha');
$search_unit_frequency = GETPOST('search_unit_frequency', 'alpha');
$search_nb_gen_done = GETPOST('search_nb_gen_done', 'aplha');
$search_nb_gen_done = GETPOST('search_nb_gen_done', 'alpha');
$search_status = GETPOST('search_status', 'int');
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;

View file

@ -71,7 +71,7 @@ if ($action == 'add' && !$cancel) {
$datev = dol_mktime(12, 0, 0, GETPOST("datevmonth"), GETPOST("datevday"), GETPOST("datevyear"));
$datep = dol_mktime(12, 0, 0, GETPOST("datepmonth"), GETPOST("datepday"), GETPOST("datepyear"));
$object->accountid = GETPOST("accountid", 'int');
$object->accountid = GETPOSTINT("accountid");
$object->paymenttype = GETPOST("paiementtype");
$object->datev = $datev;
$object->datep = $datep;

View file

@ -443,7 +443,7 @@ class RemiseCheque extends CommonObject
}
if (!$mybool) {
dol_print_error('', "Failed to include file ".$file);
dol_print_error(null, "Failed to include file ".$file);
return '';
}
@ -524,16 +524,14 @@ class RemiseCheque extends CommonObject
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Load indicators this->nb for the state board
*
* @param string $type Type of payment mode deposit ('CHQ', 'TRA', ...)
* @return int Return integer <0 if ko, >0 if ok
*/
public function load_state_board($type = 'CHQ')
public function loadStateBoard($type = 'CHQ')
{
// phpcs:enable
global $user;
if ($user->socid) {

View file

@ -277,7 +277,7 @@ class Paiement extends CommonObject
// Add controls of input validity
if ($value_converted === false) {
// We failed to find the conversion for one invoice
$this->error = 'FailedToFoundTheConversionRateForInvoice';
$this->error = $langs->trans('FailedToFoundTheConversionRateForInvoice');
return -1;
}
if (empty($currencyofpayment)) {
@ -326,7 +326,7 @@ class Paiement extends CommonObject
// Check parameters
if (empty($totalamount) && empty($atleastonepaymentnotnull)) { // We accept negative amounts for withdraw reject but not empty arrays
$this->errors[] = 'TotalAmountEmpty';
$this->error = 'TotalAmountEmpty';
$this->error = $langs->trans('TotalAmountEmpty');
return -1;
}
@ -1156,7 +1156,7 @@ class Paiement extends CommonObject
}
if (!$mybool) {
dol_print_error('', "Failed to include file ".$file);
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View file

@ -405,7 +405,7 @@ if ($action == 'create') {
print '<tr><td>';
print $langs->trans('Employee');
print '</td>';
print '<td>'.img_picto('', 'user', 'class="pictofixedwidth"').$form->select_dolusers($fk_user, 'userid', 1).'</td></tr>';
print '<td>'.img_picto('', 'user', 'class="pictofixedwidth"').$form->select_dolusers('', 'userid', 1).'</td></tr>';
// Project
if (isModEnabled('project')) {
@ -884,7 +884,7 @@ if ($id > 0) {
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
} else {
/* Social contribution not found */
dol_print_error('', $object->error);
dol_print_error(null, $object->error);
}
}

View file

@ -165,7 +165,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
$object = new Contact($db);
$result = $object->fetch($id);
if ($result <= 0) {
dol_print_error('', $object->error);
dol_print_error(null, $object->error);
}
}
$objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
@ -210,7 +210,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
$objsoc = new Societe($db);
/*
* Fiche en mode visualisation
* Card in view mode
*/
dol_htmloutput_errors($error, $errors);

View file

@ -206,7 +206,7 @@ if (empty($reshook)) {
}
$object->entity = (GETPOSTISSET('entity') ? GETPOST('entity', 'int') : $conf->entity);
$object->socid = GETPOST("socid", 'int');
$object->socid = GETPOSTINT("socid");
$object->lastname = (string) GETPOST("lastname", 'alpha');
$object->firstname = (string) GETPOST("firstname", 'alpha');
$object->civility_code = (string) GETPOST("civility_code", 'alpha');
@ -225,12 +225,12 @@ if (empty($reshook)) {
}
}
$object->email = (string) GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL);
$object->no_email = GETPOST("no_email", "int");
$object->no_email = GETPOSTINT("no_email");
$object->phone_pro = (string) GETPOST("phone_pro", 'alpha');
$object->phone_perso = (string) GETPOST("phone_perso", 'alpha');
$object->phone_mobile = (string) GETPOST("phone_mobile", 'alpha');
$object->fax = (string) GETPOST("fax", 'alpha');
$object->priv = GETPOST("priv", 'int');
$object->priv = GETPOSTINT("priv");
$object->note_public = (string) GETPOST("note_public", 'restricthtml');
$object->note_private = (string) GETPOST("note_private", 'restricthtml');
$object->roles = GETPOST("roles", 'array');
@ -239,7 +239,7 @@ if (empty($reshook)) {
// Note: Correct date should be completed with location to have exact GM time of birth.
$object->birthday = dol_mktime(0, 0, 0, GETPOST("birthdaymonth", 'int'), GETPOST("birthdayday", 'int'), GETPOST("birthdayyear", 'int'));
$object->birthday_alert = GETPOST("birthday_alert", 'alpha');
$object->birthday_alert = GETPOSTINT("birthday_alert");
//Default language
$object->default_lang = GETPOST('default_lang');
@ -586,7 +586,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
$object = new Contact($db);
$result = $object->fetch($id);
if ($result <= 0) {
dol_print_error('', $object->error);
dol_print_error(null, $object->error);
}
}
$objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
@ -624,7 +624,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
if ($user->hasRight('societe', 'contact', 'creer')) {
if ($action == 'create') {
/*
* Fiche en mode creation
* Card in create mode
*/
$object->canvas = $canvas;
@ -929,7 +929,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print "</form>";
} elseif ($action == 'edit' && !empty($id)) {
/*
* Fiche en mode edition
* Card in edit mode
*/
// We set country_id, and country_code label of the chosen country

View file

@ -339,8 +339,14 @@ class Contact extends CommonObject
public $roles;
public $cacheprospectstatus = array();
/**
* @var string Prospect level. ie: 'PL_LOW', 'PL...'
*/
public $fk_prospectlevel;
public $stcomm_id;
public $statut_commercial;
/**
@ -397,15 +403,13 @@ class Contact extends CommonObject
}*/
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Load indicators into this->nb for board
*
* @return int Return integer <0 if KO, >0 if OK
*/
public function load_state_board()
public function loadStateBoard()
{
// phpcs:enable
global $user, $hookmanager;
$this->nb = array();
@ -1818,6 +1822,7 @@ class Contact extends CommonObject
$sql .= " WHERE sc.fk_soc =".((int) $this->socid);
$sql .= " AND sc.fk_c_type_contact=tc.rowid";
$sql .= " AND tc.element = '".$this->db->escape($element)."'";
$sql .= " AND sp.entity IN (".getEntity('contact').")";
$sql .= " AND tc.active = 1";
dol_syslog(__METHOD__, LOG_DEBUG);
@ -1953,7 +1958,7 @@ class Contact extends CommonObject
/**
* Return label of prospect level
*
* @param int $fk_prospectlevel Prospect level
* @param string $fk_prospectlevel Prospect level
* @return string label of level
*/
public function libProspLevel($fk_prospectlevel)
@ -1962,7 +1967,7 @@ class Contact extends CommonObject
$lib = $langs->trans("ProspectLevel".$fk_prospectlevel);
// If lib not found in language file, we get label from cache/database
if ($lib == $langs->trans("ProspectLevel".$fk_prospectlevel)) {
if ($lib == "ProspectLevel".$fk_prospectlevel) {
$lib = $langs->getLabelFromKey($this->db, $fk_prospectlevel, 'c_prospectlevel', 'code', 'label');
}
return $lib;

View file

@ -97,6 +97,7 @@ if (isModEnabled('socialnetworks')) {
}
}
$search_priv = GETPOST("search_priv", 'alpha');
$search_sale = GETPOSTINT('search_sale');
$search_categ = GETPOST("search_categ", 'int');
$search_categ_thirdparty = GETPOST("search_categ_thirdparty", 'int');
$search_categ_supplier = GETPOST("search_categ_supplier", 'int');
@ -383,6 +384,7 @@ if (empty($reshook)) {
$search_stcomm = '';
$search_level = '';
$search_status = -1;
$search_sale = '';
$search_categ = '';
$search_categ_thirdparty = '';
$search_categ_supplier = '';
@ -416,6 +418,10 @@ if (empty($reshook)) {
if ($search_priv < 0) {
$search_priv = '';
}
// the user has not right to see other third-party than their own
if (!$user->hasRight('societe', 'client', 'voir')) {
$search_sale = $user->id;
}
/*
@ -495,18 +501,12 @@ if (isset($extrafields->attributes[$object->table_element]['label']) && is_array
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = p.fk_pays";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_stcommcontact as st ON st.id = p.fk_stcommcontact";
if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
}
// Add fields from hooks - ListFrom
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= ' WHERE p.entity IN ('.getEntity('contact').')';
if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND (sc.fk_user = ".((int) $user->id)." OR p.fk_soc IS NULL)";
}
if (!empty($userid)) { // propre au commercial
$sql .= " AND p.fk_user_creat=".((int) $userid);
}
@ -529,6 +529,14 @@ if ($search_priv != '0' && $search_priv != '1') {
}
}
// Search on sale representative
if (!empty($search_sale) && $search_sale != '-1') {
if ($search_sale == -2) {
$sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".$db->prefix()."societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc)";
} elseif ($search_sale > 0) {
$sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".$db->prefix()."societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
}
}
// Search Contact Categories
$searchCategoryContactList = $search_categ ? array($search_categ) : array();
@ -823,6 +831,9 @@ if ($optioncss != '') {
}
$param .= '&begin='.urlencode($begin).'&userid='.urlencode($userid).'&contactname='.urlencode($search_all);
$param .= '&type='.urlencode($type).'&view='.urlencode($view);
if (!empty($search_sale) && $search_sale != '-1') {
$param .= '&search_sale='.urlencode($search_sale);
}
if (!empty($search_categ) && $search_categ != '-1') {
$param .= '&search_categ='.urlencode($search_categ);
}
@ -981,6 +992,16 @@ if ($search_firstlast_only) {
}
$moreforfilter = '';
// If the user can view third-party other than their own
if ($user->hasRight('societe', 'client', 'voir')) {
$langs->load('commercial');
$moreforfilter .= '<div class="divsearchfield">';
$tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx', 1);
$moreforfilter .= '</div>';
}
if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) {
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$moreforfilter .= '<div class="divsearchfield">';

View file

@ -55,7 +55,7 @@ if ($action == 'update' && !GETPOST("cancel") && $user->hasRight('societe', 'con
// Note: Correct date should be completed with location to have exact GM time of birth.
$object->birthday = dol_mktime(0, 0, 0, GETPOST("birthdaymonth"), GETPOST("birthdayday"), GETPOST("birthdayyear"));
$object->birthday_alert = GETPOST("birthday_alert");
$object->birthday_alert = GETPOSTINT("birthday_alert");
if (GETPOST('deletephoto')) {
$object->photo = '';
@ -135,7 +135,7 @@ $head = contact_prepare_head($object);
if ($action == 'edit') {
/*
* Fiche en mode edition
* Card in edit mode
*/
print '<form name="perso" method="POST" enctype="multipart/form-data" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';

View file

@ -94,7 +94,7 @@ if ($id > 0 || !empty($ref) && $action != 'add') {
$ret = $object->fetch_thirdparty();
}
if ($ret < 0) {
dol_print_error('', $object->error);
dol_print_error(null, $object->error);
}
}

View file

@ -11,6 +11,8 @@
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2018-2023 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2015-2018 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2024 William Mead <william.mead@manchenumerique.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
@ -313,7 +315,7 @@ class Contrat extends CommonObject
}
if (!$mybool) {
dol_print_error('', "Failed to include file ".$file);
dol_print_error(null, "Failed to include file ".$file);
return '';
}
@ -965,9 +967,9 @@ class Contrat extends CommonObject
// Now set the global properties on contract not stored into database.
$this->nbofservices = count($this->lines);
$this->total_ttc = price2num($total_ttc);
$this->total_tva = price2num($total_vat);
$this->total_ht = price2num($total_ht);
$this->total_ttc = (float) price2num($total_ttc);
$this->total_tva = (float) price2num($total_vat);
$this->total_ht = (float) price2num($total_ht);
return $this->lines;
}
@ -1156,7 +1158,8 @@ class Contrat extends CommonObject
return -2;
}
} else {
$this->error = $langs->trans("UnknownError: ".$this->db->error()." -", LOG_DEBUG);
$this->error = $langs->trans("UnknownError").": ".$this->db->error();
dol_syslog(get_class($this)."::create - 10 - ".$this->error, LOG_ERR);
$this->db->rollback();
return -1;
@ -1586,8 +1589,9 @@ class Contrat extends CommonObject
// if buy price not defined, define buyprice as configured in margin admin
if ($pa_ht == 0) {
if (($result = $this->defineBuyPrice($pu_ht, $remise_percent, $fk_product)) < 0) {
return $result;
$result = $this->defineBuyPrice($pu_ht, $remise_percent, $fk_product);
if ($result < 0) {
return -1;
} else {
$pa_ht = $result;
}
@ -1621,7 +1625,7 @@ class Contrat extends CommonObject
$sql .= " ".price2num($remise_percent).",";
$sql .= " ".price2num($pu_ht).",";
$sql .= " ".price2num($total_ht).",".price2num($total_tva).",".price2num($total_localtax1).",".price2num($total_localtax2).",".price2num($total_ttc).",";
$sql .= " '".$this->db->escape($info_bits)."',";
$sql .= " ".((int) $info_bits).",";
$sql .= " ".price2num($price).",".price2num($remise).",";
if (isset($fk_fournprice)) {
$sql .= ' '.((int) $fk_fournprice).',';
@ -1783,8 +1787,9 @@ class Contrat extends CommonObject
// if buy price not defined, define buyprice as configured in margin admin
if ($pa_ht == 0) {
if (($result = $this->defineBuyPrice($pu, $remise_percent)) < 0) {
return $result;
$result = $this->defineBuyPrice($pu, $remise_percent);
if ($result < 0) {
return -1;
} else {
$pa_ht = $result;
}
@ -2374,15 +2379,13 @@ class Contrat extends CommonObject
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Load the indicators this->nb for state board
*
* @return int Return integer <0 si ko, >0 si ok
*/
public function load_state_board()
public function loadStateBoard()
{
// phpcs:enable
global $conf, $user;
$this->nb = array();
@ -3060,29 +3063,35 @@ class ContratLigne extends CommonObjectLine
public $total_ttc;
/**
* @var int ID
* @var int ID
*/
public $fk_fournprice;
public $pa_ht;
/**
* @var int Info bits
*/
public $info_bits;
/**
* @var int ID
* @var int ID of user that insert the service
*/
public $fk_user_author;
/**
* @var int ID
* @var int ID of user opening the service
*/
public $fk_user_ouverture;
/**
* @var int ID
* @var int ID of user closing the service
*/
public $fk_user_cloture;
/**
* @var string Comment
*/
public $commentaire;
@ -3432,12 +3441,7 @@ class ContratLigne extends CommonObjectLine
$this->fk_remise_except = (int) $this->fk_remise_except;
$this->subprice = price2num($this->subprice);
$this->price_ht = price2num($this->price_ht);
$this->total_ht = trim($this->total_ht);
$this->total_tva = trim($this->total_tva);
$this->total_localtax1 = trim($this->total_localtax1);
$this->total_localtax2 = trim($this->total_localtax2);
$this->total_ttc = trim($this->total_ttc);
$this->info_bits = trim($this->info_bits);
$this->info_bits = (int) $this->info_bits;
$this->fk_user_author = (int) $this->fk_user_author;
$this->fk_user_ouverture = (int) $this->fk_user_ouverture;
$this->fk_user_cloture = (int) $this->fk_user_cloture;
@ -3498,8 +3502,9 @@ class ContratLigne extends CommonObjectLine
// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0) {
if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) {
return $result;
$result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product);
if ($result < 0) {
return -1;
} else {
$this->pa_ht = $result;
}

View file

@ -132,7 +132,7 @@ $userstatic = new User($db);
/* *************************************************************************** */
/* */
/* Mode vue et edition */
/* Card view and edit mode */
/* */
/* *************************************************************************** */

View file

@ -43,7 +43,7 @@ $ref=GETPOST('ref', 'alpha');
$action=GETPOST('action', 'alpha');
if ($id == '' && $ref == '') {
dol_print_error('', 'Bad parameter');
dol_print_error(null, 'Bad parameter');
exit;
}

View file

@ -384,7 +384,7 @@ if ($action == "update_extras" && GETPOST('id', 'int') > 0 && !empty($permission
// Action to delete
if ($action == 'confirm_delete' && !empty($permissiontodelete)) {
if (!($object->id > 0)) {
dol_print_error('', 'Error, object must be fetched before being deleted');
dol_print_error(null, 'Error, object must be fetched before being deleted');
exit;
}

View file

@ -43,7 +43,7 @@ if ($action == 'builddoc' && ($permissiontoadd || !empty($usercangeneretedoc)))
$ret = $object->fetch_thirdparty();
/*if (empty($object->id) || ! $object->id > 0)
{
dol_print_error('Object must have been loaded by a fetch');
dol_print_error(null, 'Object must have been loaded by a fetch');
exit;
}*/

View file

@ -3,7 +3,7 @@
* Copyright (C) 2018-2021 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2018 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2019 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2019-2021 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019-2024 Frédéric France <frederic.france@netlogic.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
@ -1034,12 +1034,9 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) {
} else {
$db->rollback();
}
//var_dump($listofobjectthirdparties);exit;
}
}
//var_dump($_POST);var_dump($massaction);exit;
// Delete record from mass action (massaction = 'delete' for direct delete, action/confirm='delete'/'yes' with a confirmation step before)
if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == 'yes')) && $permissiontodelete) {
$db->begin();
@ -1085,9 +1082,14 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == '
}
}
if (in_array($objecttmp->element, array('societe', 'member'))) {
if ($objecttmp->element == 'societe') {
/** @var Societe $objecttmp */
$result = $objecttmp->delete($objecttmp->id, $user, 1);
} elseif (in_array($objecttmp->element, array('action'))) {
} elseif ($objecttmp->element == 'member') {
/** @var Adherent $objecttmp */
$result = $objecttmp->delete($objecttmp->id, $user, 0);
} elseif ($objecttmp->element == 'action') {
/** @var ActionComm $objecttmp */
$result = $objecttmp->delete(); // TODO Add User $user as first param
} else {
$result = $objecttmp->delete($user);

View file

@ -155,7 +155,7 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO
}
}
} else {
dol_print_error('', "Use actions_sendmails.in.php for an element/object '".$object->element."' that is not supported");
dol_print_error(null, "Use actions_sendmails.in.php for an element/object '".$object->element."' that is not supported");
}
if (is_object($hookmanager)) {

View file

@ -30,7 +30,7 @@
// Set public note
if ($action == 'setnote_public' && !empty($permissionnote) && !GETPOST('cancel', 'alpha')) {
if (empty($action) || !is_object($object) || empty($id)) {
dol_print_error('', 'Include of actions_setnotes.inc.php was done but required variable was not set before');
dol_print_error(null, 'Include of actions_setnotes.inc.php was done but required variable was not set before');
}
if (empty($object->id)) {
$object->fetch($id); // Fetch may not be already done
@ -76,7 +76,7 @@ if ($action == 'setnote_public' && !empty($permissionnote) && !GETPOST('cancel',
if (empty($user->socid)) {
// Private notes (always hidden to external users)
if (empty($action) || !is_object($object) || empty($id)) {
dol_print_error('', 'Include of actions_setnotes.inc.php was done but required variable was not set before');
dol_print_error(null, 'Include of actions_setnotes.inc.php was done but required variable was not set before');
}
if (empty($object->id)) {
$object->fetch($id); // Fetch may not be already done

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