diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index d7463d62172..280dc3a83cc 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -67,9 +67,12 @@ where
In uppercase if you want to have the log comment appears into the generated ChangeLog file.
The keyword can be ommitted if your commit does not fit in any of the following categories:
+
- Fix/FIX: for a bug fix
- New/NEW: for an unreferenced new feature (Opening a feature request and using close is prefered)
- Close/CLOSE: for closing a referenced feature request
+- Perf/PERF: for performance enhancement
+- Qual/QUAL: for quality code enhancement or re-engeneering
#### Issuenum
If your commit fixes a referenced bug or feature request.
@@ -96,10 +99,10 @@ Try to keep lines under 120 characters.
FIX|Fix #456 Short description (where #456 is number of bug fix, if it exists. In upper case to appear into ChangeLog)
or
-NEW|New Short description (In upper case to appear into ChangeLog, use this if you add a feature not tracked, otherwise use CLOSE #456)
-or
CLOSE|Close #456 Short description (where #456 is number of feature request, if it exists. In upper case to appear into ChangeLog)
or
+NEW|New|QUAL|Qual|PERF|Perf Short description (In upper case to appear into ChangeLog, use this if you add a feature not tracked, otherwise use CLOSE #456)
+or
Short description (when the commit is not introducing feature nor closing a bug)
Long description (Can span accross multiple lines).
@@ -119,7 +122,7 @@ Also, some code changes need a prior approbation:
* if you want to include a new external library (into htdocs/includes directory), please ask before to the core project manager (mention @dolibarr-jedi in your issue) to see if such a library can be accepted.
-* if you add a new tables or fields, you MUST first submit a standalone PR with the data structure changes you plan to add/modify (and only data structure changes). Start development only once this data structure has been accepted.
+* if you add new tables or fields, you MUST first submit a standalone PR with the data structure changes you plan to add/modify (and only data structure changes). Start development only once this data structure has been accepted.
Once a PR has been submitted, you may need to wait for its integration. It is common that the project leader let the PR open for a long delay to allow every developer discuss about the PR (A label is added in such a case).
diff --git a/.github/workflows/code_quality_qodana.yml b/.github/workflows/code_quality_qodana.yml.disabled
similarity index 100%
rename from .github/workflows/code_quality_qodana.yml
rename to .github/workflows/code_quality_qodana.yml.disabled
diff --git a/.github/workflows/exakat.yml b/.github/workflows/exakat.yml
index 85ec1b3820e..0b33ede5f4f 100644
--- a/.github/workflows/exakat.yml
+++ b/.github/workflows/exakat.yml
@@ -2,6 +2,7 @@
name: "Exakat analysis"
on:
+ # execute once a month, the 1st
schedule:
- cron: "0 20 1 * *"
workflow_dispatch:
@@ -15,13 +16,13 @@ jobs:
exakat:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Exakat
uses: docker://exakat/exakat-ga
with:
- ignore_rules: 'Classes/UseInstanceof,Performances/PrePostIncrement,Functions/UndefinedFunctions,Functions/WrongNumberOfArguments,Functions/WrongTypeWithCall,Variables/UndefinedVariable,Classes/DontUnsetProperties,Classes/NonPpp,Classes/StaticMethodsCalledFromObject,Classes/UseClassOperator,Functions/UsesDefaultArguments,Php/NoClassInGlobal,Php/ShouldUseCoalesce,Php/WrongTypeForNativeFunction,Structures/AddZero,Structures/DropElseAfterReturn,Structures/IfWithSameConditions,Structures/MergeIfThen,Structures/ElseIfElseif,Structures/ExitUsage,Structures/RepeatedPrint,Structures/RepeatedRegex,Structures/SameConditions,Structures/SwitchWithoutDefault,Structures/ShouldMakeTernary,Structures/UselessParenthesis,Structures/UseConstant'
+ ignore_rules: 'Classes/UseInstanceof,Performances/PrePostIncrement,Functions/UndefinedFunctions,Functions/WrongNumberOfArguments,Functions/WrongTypeWithCall,Variables/UndefinedVariable,Classes/DontUnsetProperties,Classes/NonPpp,Classes/StaticMethodsCalledFromObject,Classes/UseClassOperator,Functions/UsesDefaultArguments,Php/NoClassInGlobal,Php/ShouldUseCoalesce,Php/WrongTypeForNativeFunction,Structures/AddZero,Structures/DropElseAfterReturn,Structures/IfWithSameConditions,Structures/MergeIfThen,Structures/NestedTernary,Structures/ElseIfElseif,Structures/ExitUsage,Structures/RepeatedPrint,Structures/RepeatedRegex,Structures/SameConditions,Structures/SwitchWithoutDefault,Structures/ShouldMakeTernary,Structures/UselessParenthesis,Structures/UseConstant'
ignore_dirs: '/htdocs/includes/,/htdocs/install/doctemplates/,/build/,/dev/,/doc/,/scripts/,/test/'
file_extensions: php
project_reports: Perfile
\ No newline at end of file
diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml
new file mode 100644
index 00000000000..1bb1184586f
--- /dev/null
+++ b/.github/workflows/phpcs.yml
@@ -0,0 +1,30 @@
+name: "PHPCS"
+
+on:
+ pull_request:
+ paths:
+ - "**.php"
+ - "phpcs.xml"
+ - ".github/workflows/phpcs.yml"
+
+jobs:
+ phpcs:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 50 # important!
+
+ # we may use whatever way to install phpcs, just specify the path on the next step
+ # however, curl seems to be the fastest
+ - name: Install PHP_CodeSniffer
+ run: |
+ curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
+ php phpcs.phar --version
+
+ - uses: thenabeel/action-phpcs@v8
+ with:
+ files: "**.php" # you may customize glob as needed
+ phpcs_path: php phpcs.phar
+ standard: dev/setup/codesniffer/ruleset.xml
+ fail_on_warnings: false
diff --git a/.github/workflows/phpcsfixer.yml b/.github/workflows/phpcsfixer.yml.disabled
similarity index 99%
rename from .github/workflows/phpcsfixer.yml
rename to .github/workflows/phpcsfixer.yml.disabled
index 1bd342f9737..959ba5ad801 100644
--- a/.github/workflows/phpcsfixer.yml
+++ b/.github/workflows/phpcsfixer.yml.disabled
@@ -13,7 +13,7 @@ jobs:
# uses: ./.github/workflows/files_changed.yaml
# with:
# folder_path: .*
-
+
linter_name:
name: Run & fix PHP Code Sniffer
runs-on: ubuntu-latest
@@ -60,3 +60,4 @@ jobs:
#committer_email: eldy@destailleur.fr
message: 'PHP CS fixer github action'
add: '*.php'
+
diff --git a/.gitignore b/.gitignore
index 8c639a26540..cc8b27dae67 100644
--- a/.gitignore
+++ b/.gitignore
@@ -59,11 +59,6 @@ package-lock.json
doc/install.lock
/.asciidoctorconfig.adoc
-# Qodana
-.idea/vcs.xml
-.idea/modules.xml
-.idea/workspace.xml
-.idea/inspectionProfiles/Project_Default.xml
-.idea/jsLinters/jshint.xml
+.idea
/composer.json
/composer.lock
diff --git a/.idea/php.xml b/.idea/php.xml
deleted file mode 100644
index 74fc8003a4b..00000000000
--- a/.idea/php.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/.scrutinizer.yml b/.scrutinizer.yml
deleted file mode 100644
index 058a0ba8b48..00000000000
--- a/.scrutinizer.yml
+++ /dev/null
@@ -1,236 +0,0 @@
-# .scrutinizer.yml
-#build:
-# - php-scrutinizer-run
-build:
- nodes:
- analysis:
- tests:
- override:
- - command: php-scrutinizer-run
- idle_timeout: 8000
- #- php-scrutinizer-run --sub-project-dir=htdocs/admin
-
-imports:
- - php
-
-filter:
- excluded_paths:
- - build/
- - dev/
- - doc/
- - documents/
- - node_modules/
- - test/
- - htdocs/custom/
- - htdocs/includes/
- - htdocs/install/doctemplates/
- #dependency_paths:
- # - htdocs/includes/
- paths:
- - htdocs/*
- - scripts/*
-
-tools:
- # php_analyzer. Doc on https://scrutinizer-ci.com/docs/tools/php/php-analyzer/
- php_analyzer:
- enabled: true
- extensions:
- - php
- #dependency_paths:
- # - htdocs/includes/
- filter:
- excluded_paths:
- - build/
- - dev/
- - doc/
- - documents/
- - htdocs/custom/
- - htdocs/includes/
- - htdocs/install/doctemplates/
- - htdocs/core/class/lessc.class.php
- - node_modules/
- - test/
- paths:
- - htdocs/*
- - scripts/*
- config:
- parameter_reference_check:
- enabled: true
- checkstyle:
- enabled: false
- no_trailing_whitespace: true
- naming:
- enabled: true
- local_variable: ^[a-z][a-zA-Z0-9]*$
- abstract_class_name: ^Abstract|Factory$
- utility_class_name: Utils?$
- constant_name: ^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$
- property_name: ^[a-z][a-zA-Z0-9]*$
- method_name: ^(?:[a-z]|__)[a-zA-Z0-9]*$
- parameter_name: ^[a-z][a-zA-Z0-9]*$
- interface_name: ^[A-Z][a-zA-Z0-9]*Interface$
- type_name: ^[A-Z][a-zA-Z0-9]*$
- exception_name: ^[A-Z][a-zA-Z0-9]*Exception$
- isser_method_name: ^(?:is|has|should|may|supports)
- unreachable_code:
- enabled: true
- check_access_control:
- enabled: true
- typo_checks:
- enabled: true
- check_variables:
- enabled: true
- check_calls:
- enabled: true
- too_many_arguments: true
- missing_argument: true
- argument_type_checks: lenient # Allowed Values: "disabled", "lenient", "strict"
- suspicious_code:
- enabled: true
- overriding_parameter: false
- overriding_closure_use: true
- parameter_closure_use_conflict: true
- parameter_multiple_times: true
- non_existent_class_in_instanceof_check: true
- non_existent_class_in_catch_clause: true
- assignment_of_null_return: true
- non_commented_switch_fallthrough: true
- non_commented_empty_catch_block: true
- overriding_private_members: true
- use_statement_alias_conflict: true
- precedence_in_condition_assignment: true
- dead_assignments:
- enabled: true
- verify_php_doc_comments:
- enabled: false
- parameters: true
- return: true
- suggest_more_specific_types: true
- ask_for_return_if_not_inferrable: true
- ask_for_param_type_annotation: true
- loops_must_use_braces:
- enabled: true
- check_usage_context:
- enabled: true
- simplify_boolean_return:
- enabled: false
- phpunit_checks:
- enabled: false
- reflection_checks:
- enabled: true
-
- # Checks Common Precedence Mistakes
- precedence_checks:
- enabled: true
- assignment_in_condition: true
- comparison_of_bit_result: true
- basic_semantic_checks:
- enabled: true
- # Disabled unused code. In most cases, we want to keep it.
- unused_code:
- enabled: false
- deprecation_checks:
- enabled: true
- useless_function_calls:
- enabled: true
- metrics_lack_of_cohesion_methods:
- enabled: true
- metrics_coupling:
- enabled: true
- stable_code:
- namespace_prefixes: []
- classes: []
- doctrine_parameter_binding:
- enabled: false
- doctrine_entity_manager_injection:
- enabled: false
- symfony_request_injection:
- enabled: false
- doc_comment_fixes:
- enabled: true
- reflection_fixes:
- enabled: false
- use_statement_fixes:
- enabled: true
- remove_unused: true
- # Whether you would like multiple imports in one USE statement to be preserved, e.g. ``use A, B;``.
- preserve_multiple: false
- # Whether you would like to preserve blank lines between use statements.
- preserve_blanklines: false
- order_alphabetically: false
- # To use specific config for a specific path, use path_configs: (see example on page https://scrutinizer-ci.com/docs/configuration/tool_config_structure)
-
- # php_depend
- #php_pdepend:
- # enabled: false
- # configuration_file: null
- # suffixes:
- # - php
- # excluded_dirs: { }
- # filter:
- # excluded_paths:
- # - 'build/*'
- # - 'dev/*'
- # - 'doc/*'
- # - 'test/*'
- # - 'htdocs/includes/*'
- # paths: { }
-
- # change tracking
- #php_changetracking:
- # enabled: false
- # bug_patterns:
- # - '\bfix(?:es|ed)?\b'
- # feature_patterns:
- # - '\badd(?:s|ed)?\b'
- # - '\bimplement(?:s|ed)?\b'
- # filter:
- # excluded_paths:
- # - 'build/*'
- # - 'dev/*'
- # - 'doc/*'
- # - 'documents/*'
- # - 'htdocs/includes/*'
- # - 'node_modules/*'
- # - 'test/*'
- # paths: { }
-
- # Similar code detection
- #php_sim:
- # enabled: false
- # min_mass: 30
- # filter:
- # excluded_paths:
- # - 'build/*'
- # - 'dev/*'
- # - 'doc/*'
- # - 'documents/*'
- # - 'htdocs/includes/*'
- # - 'node_modules/*'
- # - 'test/*'
- # paths: { }
-
- # Coding-Style / Bug Detection
- #js_hint:
- # enabled: false
- # use_native_config: true
- # extensions:
- # - js
- # filter:
- # excluded_paths:
- # - 'build/*'
- # - 'dev/*'
- # - 'doc/*'
- # - 'documents/*'
- # - 'htdocs/includes/*'
- # - 'node_modules/*'
- # - 'test/*'
- # paths: { }
- # config: { }
- # path_configs: { }
-
-
-before_commands: { }
-after_commands: { }
-artifacts: { }
-build_failure_conditions: { }
diff --git a/.stickler.yml b/.stickler.yml
deleted file mode 100644
index 642dec27412..00000000000
--- a/.stickler.yml
+++ /dev/null
@@ -1,14 +0,0 @@
----
-linters:
- phpcs:
- standard: 'dev/setup/codesniffer/ruleset.xml'
- extensions: 'php'
- tab_width: 4
- fixer: true
-
-fixers:
- enable: true
-
-files:
- ignore:
- - 'htdocs/includes/*'
diff --git a/.travis.yml b/.travis.yml
index 54feb351933..19fb70cbc93 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,7 +8,7 @@ dist: focal
language: generic
-scan_logs: false
+#scan_logs: false
git:
depth: 1
@@ -325,22 +325,24 @@ script:
echo
- |
- echo "Checking coding style (only for Pull Requests builds and 1 version to not overload travis and avoid duplicate tests)"
+ echo "Checking coding style (only for 1 version to not overload travis and avoid duplicate tests)"
# Ensure we catch errors
set -e
# Exclusions are defined in the ruleset.xml file
- if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "8.1" ]; then
+ #if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "8.1" ]; then
+ if [ "$TRAVIS_PHP_VERSION" = "8.1" ]; then
phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true .;
fi
set +e
echo
- |
- echo "Checking missing debug"
+ echo "Checking missing debug (only for 1 version to not overload travis and avoid duplicate tests)"
# Ensure we catch errors
set -e
# Exclusions are defined in the ruleset.xml file
- if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "8.1" ]; then
+ #if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "8.1" ]; then
+ if [ "$TRAVIS_PHP_VERSION" = "8.1" ]; then
var-dump-check --extensions php --tracy --exclude htdocs/includes --exclude test/ --exclude htdocs/public/test/ --exclude htdocs/core/lib/functions.lib.php .
fi
set +e
@@ -371,6 +373,7 @@ script:
echo '$'force_install_mainforcehttps=false';' >> $INSTALL_FORCED_FILE
echo '$'force_install_main_data_root=\'$TRAVIS_BUILD_DIR/htdocs\'';' >> $INSTALL_FORCED_FILE
#cat $INSTALL_FORCED_FILE
+ echo
- |
echo "Upgrading Dolibarr"
@@ -436,18 +439,22 @@ script:
php upgrade.php 17.0.0 18.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade17001800.log
php upgrade2.php 17.0.0 18.0.0 > $TRAVIS_BUILD_DIR/upgrade17001800-2.log
php step5.php 17.0.0 18.0.0 > $TRAVIS_BUILD_DIR/upgrade17001800-3.log
- php upgrade.php 18.0.0 19.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade18001900.log
- php upgrade2.php 18.0.0 19.0.0 > $TRAVIS_BUILD_DIR/upgrade18001900-2.log
- php step5.php 18.0.0 19.0.0 > $TRAVIS_BUILD_DIR/upgrade18001900-3.log
+ php upgrade.php 18.0.0 19.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade18001900.log || cat $TRAVIS_BUILD_DIR/upgrade18001900.log
+ php upgrade2.php 18.0.0 19.0.0 > $TRAVIS_BUILD_DIR/upgrade18001900-2.log || cat $TRAVIS_BUILD_DIR/upgrade18001900-2.log
+ php step5.php 18.0.0 19.0.0 > $TRAVIS_BUILD_DIR/upgrade18001900-3.log || cat $TRAVIS_BUILD_DIR/upgrade18001900-3.log
+ set +e
+ echo
- #show table content and log
+ - |
+ echo Show some debug info like table content or log
#echo '\d llx_adherent' | psql 'postgresql://postgres:postgres@127.0.0.1:5432/travis'
- #cat $TRAVIS_BUILD_DIR/upgrade500600.log
+ cat $TRAVIS_BUILD_DIR/upgrade18001900.log
+ echo
- |
echo Result of migration scripts
ls -alrt $TRAVIS_BUILD_DIR/
-
+
echo Show content of last file
cat $TRAVIS_BUILD_DIR/"$(ls -rt $TRAVIS_BUILD_DIR/ | tail -n1)"
@@ -466,6 +473,7 @@ script:
echo
#cat /tmp/dolibarr_install.log
cat $TRAVIS_BUILD_DIR/enablemodule.log
+ echo
- |
echo "Unit testing"
@@ -475,6 +483,7 @@ script:
phpunitresult=$?
echo "Phpunit return code = $phpunitresult"
set +e
+ echo
after_script:
- |
diff --git a/ChangeLog b/ChangeLog
index c5d149c1006..0e57d0be48a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,7 +3,15 @@ English Dolibarr ChangeLog
--------------------------------------------------------------
-***** ChangeLog for 1.0.0 compared to 18.0.0 *****
+***** ChangeLog for 19.0.0 compared to 18.0.0 *****
+
+For users:
+----------
+...
+
+For developers or integrators:
+------------------------------
+...
WARNING:
@@ -11,13 +19,49 @@ WARNING:
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
* The property ->brouillon has been removed from all classes. It was not reliable and was a duplicate of ->status == self::STATUS_DRAFT.
* The method get_substitutionarray_shipment_lines() has been removed. Use the generic get_substitutionarray_lines() instead.
+* Recheck setup of your module workflow to see if you need to enable the new setting to have shipment set to billed automatically
+ when an invoice from a shipment is validated (and if your process is to make invoice on shipment and not on order).
+* It was possible to use a variable $soc or $right inside a php code condition of some extrafields properties, this is no more true (this vars are no more defined globaly).
+***** ChangeLog for 18.0.1 compared to 18.0.0 *****
+FIX: Adding a product in recurring invoice does not use the correct VAT
+FIX: API /product/getAttributes
+FIX: avoid php8 warnings
+FIX: bad balance of TR tag in multicurrency price view
+FIX: Bad calculation of localtax when price_base_type not defined.
+FIX: Bad link into message
+FIX: Bad message on menu to go to setup of accounting custom groups
+FIX: Bank receipt was empty
+FIX: Billing massaction should be possible on Processed Reception.
+FIX: clone when cloning object with ->lines containing not object
+FIX: Condition to show column POSModule and POSTerminal in invoice list
+FIX: CSS
+FIX: date survey : button to add dates would not work. Session would store cells numbers which would stay to 10 for next surveys created.
+FIX: dir output path for ODT models on reception card
+FIX: Duplicate tooltip on ref of an agenda event
+FIX: encrypt sensitive data must not be done for const MAIN_AGENDA_ACTIONAUTO
+FIX: Export when old file export_csv.modules.php is still present
+FIX: fatal error with bad definition of dictionaries
+FIX: fatal error with some parameters
+FIX: hook formBuilddocOptions was broken when used by 2 modules
+FIX: Line for revenuestamp in accountancy transfer must appear only if it exists
+FIX: Navigation between bank receipts
+FIX: payment card: misleading message when delete button disabled
+FIX: reception odt dir output path
+FIX: SQL request parenthesis
+FIX: Suppliers addlines never have VAT if buyprice for this supplier not set
+FIX: TakePOS receipt preview in admin #25648
+FIX: technical error on conciliation of lines
+FIX: the account in chart of account to use for revenue stamp is on dict
+FIX: url to check keyword not saved on partnership from public form
+FIX: when adding new times on a survey, all hours would be erased.
+
***** ChangeLog for 18.0.0 compared to 17.0.0 *****
-For uses:
----------
+For users:
+----------
NEW: PHP 8.2 compatibility (test not yet completed)
NEW: Module Workstations Management upgraded to stable status
@@ -220,6 +264,11 @@ WARNING:
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
* Minimal PHP version is now PHP 7.1 instead of PHP 7.0
+* Sensitive datas like keys in setup pages, that need encyption (for example the API keys of users, the CRON security key, the keys into the Stripe module, or
+external modules setup pages that store sensitive keys or password), are using the $dolibarr_main_instance_unique_id as part of the key for encryption. So,
+if you restore or duplicate the data from another instance dump, you must also update this parameter in ther conf.php file to allow decryption in the new instance, or
+better, you must reenter the sensitive data into the setup pages of the new instance to resave them correctly.
+Note that to find all the parameters that are encrypted into the setup database, you can do a "SELECT * FROM llx_const WHERE value LIKE '%dolcrypt%';"
* The deprecated method "escapeunderscore()" of database handlers has been removed. You must use "escapeforlike()" instead.
* The method "nb_expedition()" has been renamed into "countNbOfShipments()"
* Revert default type of hooks. Default is now 'addreplace' hooks (and exception become 'output' hooks, that become deprecated).
diff --git a/build/debian/patches/use-etc-dolibarr-conf.patch b/build/debian/patches/use-etc-dolibarr-conf.patch
index 07346ad4e63..c5cede64470 100644
--- a/build/debian/patches/use-etc-dolibarr-conf.patch
+++ b/build/debian/patches/use-etc-dolibarr-conf.patch
@@ -33,5 +33,5 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+$conffile = "/etc/dolibarr/conf.php";
+$conffiletoshow = "/etc/dolibarr/conf.php";
-
- // Load conf file if it is already defined
+ $short_options = "c:h";
+ $long_options = array(
diff --git a/build/exe/doliwamp/Makefile b/build/exe/doliwamp/Makefile
index 8e446931c74..3344232b177 100644
--- a/build/exe/doliwamp/Makefile
+++ b/build/exe/doliwamp/Makefile
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------#
-# Makefile
+# Makefile to build UsedPort exe
#-------------------------------------------------------------------#
# 1.0 Laurent Destailleur Creation
#-------------------------------------------------------------------#
diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl
index b7586e3909f..5862f3f2970 100755
--- a/build/makepack-dolibarr.pl
+++ b/build/makepack-dolibarr.pl
@@ -2,7 +2,7 @@
#----------------------------------------------------------------------------
# \file build/makepack-dolibarr.pl
# \brief Dolibarr package builder (tgz, zip, rpm, deb, exe, aps)
-# \author (c)2004-2020 Laurent Destailleur
+# \author (c)2004-2023 Laurent Destailleur
#
# This is list of constant you can set to have generated packages moved into a specific dir:
#DESTIBETARC='/media/HDDATA1_LD/Mes Sites/Web/Dolibarr/dolibarr.org/files/lastbuild'
@@ -369,12 +369,12 @@ if ($nboftargetok) {
}
if (! $BUILD || $BUILD eq '0-rc') # For a major version
{
- print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log `git rev-list --boundary '.$MAJOR.'.'.$MINOR.'..origin/develop | grep ^- | cut -c2- | head -n 1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\|CLOSE\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/CLOSE/NEW/g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
+ print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log `git rev-list --boundary '.$MAJOR.'.'.$MINOR.'..origin/develop | grep ^- | cut -c2- | head -n 1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\|PERF\|SEC\|QUAL\|CLOSE\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/CLOSE/NEW/g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
}
else # For a maintenance release
{
- #print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/CLOSE/NEW/g\'| sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
- print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. | grep -v "Merge branch" | grep -v "Merge pull" | grep "^ " | sed -e "s/^[0-9a-z]* *//" | grep -e \'^FIX\|NEW\|CLOSE\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/CLOSE/NEW/g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
+ #print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\|PERF\|SEC\|QUAL\|CLOSE\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/CLOSE/NEW/g\'| sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
+ print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. | grep -v "Merge branch" | grep -v "Merge pull" | grep "^ " | sed -e "s/^[0-9a-z]* *//" | grep -e \'^FIX\|NEW\|PERF\|SEC\|QUAL\|CLOSE\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/CLOSE/NEW/g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
}
print "\n";
if (! $ret)
@@ -627,11 +627,11 @@ if ($nboftargetok) {
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/sabre/sabre/*/tests`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/stripe/tests`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/stripe/LICENSE`;
- $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/examples`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/freefont-*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/ae_fonts_*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/utils`;
+ $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/examples`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/tools`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/vendor`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/webmozart`;
diff --git a/build/rpm/dolibarr-forrpm.patch b/build/rpm/dolibarr-forrpm.patch
index 5413702efa3..884d1a02e40 100644
--- a/build/rpm/dolibarr-forrpm.patch
+++ b/build/rpm/dolibarr-forrpm.patch
@@ -24,5 +24,5 @@ diff -up htdocs/install/inc.php.patch htdocs/install/inc.php
+$conffile = "/etc/dolibarr/conf.php";
+$conffiletoshow = "/etc/dolibarr/conf.php";
-
- // Load conf file if it is already defined
+ $short_options = "c:h";
+ $long_options = array(
diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt
index dd2ef0023de..89d87a4ab14 100644
--- a/dev/dolibarr_changes.txt
+++ b/dev/dolibarr_changes.txt
@@ -185,6 +185,23 @@ with:
return strval($number);
}
+* Add this at begin of tcpdf_autoconfig.php
+
+ // @CHANGE LDR DOCUMENT_ROOT fix for IIS Webserver
+ if ((!isset($_SERVER['DOCUMENT_ROOT'])) OR (empty($_SERVER['DOCUMENT_ROOT']))) {
+ if (isset($_SERVER['SCRIPT_FILENAME']) && isset($_SERVER['PHP_SELF'])) {
+ $_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr($_SERVER['SCRIPT_FILENAME'], 0, 0-strlen($_SERVER['PHP_SELF'])));
+ } elseif(isset($_SERVER['PATH_TRANSLATED'])) {
+ $_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0-strlen($_SERVER['PHP_SELF'])));
+ } else {
+ // define here your DOCUMENT_ROOT path if the previous fails (e.g. '/var/www')
+ $_SERVER['DOCUMENT_ROOT'] = '/';
+ }
+ }
+ $_SERVER['DOCUMENT_ROOT'] = str_replace('//', '/', $_SERVER['DOCUMENT_ROOT']);
+ if (substr($_SERVER['DOCUMENT_ROOT'], -1) != '/') {
+ $_SERVER['DOCUMENT_ROOT'] .= '/';
+ }
TCPDI:
diff --git a/dev/initdemo/mysqldump_dolibarr_3.5.0.sql b/dev/initdemo/mysqldump_dolibarr_3.5.0.sql
index 64eead005ed..c6d16c22e45 100644
--- a/dev/initdemo/mysqldump_dolibarr_3.5.0.sql
+++ b/dev/initdemo/mysqldump_dolibarr_3.5.0.sql
@@ -4655,75 +4655,6 @@ INSERT INTO `llx_menu` VALUES (19289,'all',1,'cashdesk','top','cashdesk',0,NULL,
/*!40000 ALTER TABLE `llx_menu` ENABLE KEYS */;
UNLOCK TABLES;
---
--- Table structure for table `llx_milestone`
---
-
-DROP TABLE IF EXISTS `llx_milestone`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `llx_milestone` (
- `rowid` int(11) NOT NULL AUTO_INCREMENT,
- `fk_element` int(11) NOT NULL,
- `elementtype` varchar(16) NOT NULL,
- `label` varchar(255) NOT NULL,
- `options` varchar(255) DEFAULT NULL,
- `priority` int(11) DEFAULT '0',
- `tms` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
- `fk_user_modif` int(11) DEFAULT NULL,
- PRIMARY KEY (`rowid`),
- UNIQUE KEY `uk_milestone_fk_element` (`fk_element`,`elementtype`),
- KEY `idx_milestone_fk_user_modif` (`fk_user_modif`),
- CONSTRAINT `fk_milestone_fk_user_modif` FOREIGN KEY (`fk_user_modif`) REFERENCES `llx_user` (`rowid`)
-) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `llx_milestone`
---
-
-LOCK TABLES `llx_milestone` WRITE;
-/*!40000 ALTER TABLE `llx_milestone` DISABLE KEYS */;
-INSERT INTO `llx_milestone` VALUES (2,779,'facture','azerty',NULL,0,'2013-03-09 12:19:30',NULL),(3,780,'facture','fsdf',NULL,0,'2013-03-09 13:01:08',NULL),(4,781,'facture','hhh',NULL,0,'2013-03-09 14:06:37',NULL);
-/*!40000 ALTER TABLE `llx_milestone` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `llx_monitoring_probes`
---
-
-DROP TABLE IF EXISTS `llx_monitoring_probes`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `llx_monitoring_probes` (
- `rowid` int(11) NOT NULL AUTO_INCREMENT,
- `title` varchar(64) NOT NULL,
- `groupname` varchar(64) DEFAULT NULL,
- `url` varchar(250) NOT NULL,
- `useproxy` int(11) DEFAULT '0',
- `checkkey` varchar(250) DEFAULT NULL,
- `maxval` int(11) DEFAULT NULL,
- `frequency` int(11) DEFAULT '60',
- `active` int(11) DEFAULT '1',
- `status` int(11) DEFAULT '0',
- `lastreset` datetime DEFAULT NULL,
- `oldesterrortext` text,
- `oldesterrordate` datetime DEFAULT NULL,
- PRIMARY KEY (`rowid`),
- UNIQUE KEY `uk_monitoring_probes` (`title`)
-) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `llx_monitoring_probes`
---
-
-LOCK TABLES `llx_monitoring_probes` WRITE;
-/*!40000 ALTER TABLE `llx_monitoring_probes` DISABLE KEYS */;
-INSERT INTO `llx_monitoring_probes` VALUES (1,'aaa',NULL,'http://www.chiensderace.com',0,'chiens',1000,10,1,1,'2011-04-20 23:46:41',NULL,NULL),(2,'ChatsDeRace',NULL,'http://www.chatsderace.com',0,'chats',1000,5,1,1,'2011-04-20 23:46:41',NULL,NULL);
-/*!40000 ALTER TABLE `llx_monitoring_probes` ENABLE KEYS */;
-UNLOCK TABLES;
-
--
-- Table structure for table `llx_notify`
--
diff --git a/dev/setup/fail2ban/jail.local b/dev/setup/fail2ban/jail.local
index af74ed16671..4bb38de2cfa 100644
--- a/dev/setup/fail2ban/jail.local
+++ b/dev/setup/fail2ban/jail.local
@@ -2,17 +2,20 @@
# Examle of rule you can add to fail2ban to restrict bruteforce attacks.
#
-[web-dol-passforgotten]
-; rule against call of passwordforgottenpage
+[web-accesslog-limit403]
+
+; rule against call of 403 forbidden access
+; note: you must change the path of log file to the one of the web server for the virtual host of the Dolibarr
enabled = true
port = http,https
-filter = web-dolibarr-rulespassforgotten
-logpath = /mypath/documents/documents/dolibarr.log
+filter = web-accesslog-limit403
+logpath = /var/log/apache2/access.log
+;logpath = /var/log/apache2/other_vhosts_access.log
action = %(action_mw)s
bantime = 4320000 ; 50 days
findtime = 86400 ; 1 day
-maxretry = 10
+maxretry = 100
[web-dol-bruteforce]
@@ -28,10 +31,23 @@ findtime = 14400 ; 4 hours
maxretry = 20
+[web-dol-passforgotten]
+
+; rule against call of passwordforgottenpage
+enabled = true
+port = http,https
+filter = web-dolibarr-rulespassforgotten
+logpath = /mypath/documents/documents/dolibarr.log
+action = %(action_mw)s
+bantime = 4320000 ; 50 days
+findtime = 86400 ; 1 day
+maxretry = 10
+
+
[web-dol-limitpublic]
; rule to add rate limit on some public pages
-; note you must keep enough for public access like agenda export, emailing trackers, stripe ipn access, ...
+; note: you must keep enough for public access like agenda export, emailing trackers, stripe ipn access, ...
enabled = true
port = http,https
filter = web-dolibarr-limitpublic
diff --git a/dev/tools/apstats.php b/dev/tools/apstats.php
new file mode 100755
index 00000000000..0f0895a3ecc
--- /dev/null
+++ b/dev/tools/apstats.php
@@ -0,0 +1,426 @@
+#!/usr/bin/env php
+
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file dev/tools/apstats.php
+ * \brief Script to report Advanced Statistics on a coding project
+ */
+
+
+$sapi_type = php_sapi_name();
+$script_file = basename(__FILE__);
+$path = dirname(__FILE__) . '/';
+
+// Test si mode batch
+$sapi_type = php_sapi_name();
+if (substr($sapi_type, 0, 3) == 'cgi') {
+ echo "Error: You are using PHP for CGI. To execute " . $script_file . " from command line, you must use PHP for CLI mode.\n";
+ exit();
+}
+
+error_reporting(E_ALL & ~ E_DEPRECATED);
+define('PRODUCT', "apstats");
+define('VERSION', "1.0");
+
+
+print '***** '.constant('PRODUCT').' - '.constant('VERSION').' *****'."\n";
+if (empty($argv[1])) {
+ print 'You must run this tool being into the root of the project.'."\n";
+ print 'Usage: '.constant('PRODUCT').'.php pathto/outputfile.html [--dir-scc=pathtoscc] [--dir-phpstan=pathtophpstan]'."\n";
+ print 'Example: '.constant('PRODUCT').'.php documents/apstats/index.html --dir-scc=/snap/bin --dir-phpstan=~/git/phpstan/htdocs/includes/bin';
+ exit(0);
+}
+
+$outputpath = $argv[1];
+$outputdir = dirname($outputpath);
+$outputfile = basename($outputpath);
+
+if (! is_dir($outputdir)) {
+ print 'Error: dir '.$outputdir.' does not exists or is not writable'."\n";
+ exit(1);
+}
+
+$dirscc = '';
+$dirphpstan = '';
+
+$i = 0;
+while ($i < $argc) {
+ $reg = array();
+ if (preg_match('/--dir-scc=(.*)$/', $argv[$i], $reg)) {
+ $dirscc = $reg[1];
+ }
+ if (preg_match('/--dir-phpstan=(.*)$/', $argv[$i], $reg)) {
+ $dirphpstan = $reg[1];
+ }
+ $i++;
+}
+
+
+// Count lines of code of Dolibarr itself
+/*
+$commandcheck = 'cloc . --exclude-dir=includes --exclude-dir=custom --ignore-whitespace --vcs=git';
+$resexec = shell_exec($commandcheck);
+$resexec = (int) (empty($resexec) ? 0 : trim($resexec));
+
+
+// Count lines of code of external dependencies
+$commandcheck = 'cloc htdocs/includes --ignore-whitespace --vcs=git';
+$resexec = shell_exec($commandcheck);
+$resexec = (int) (empty($resexec) ? 0 : trim($resexec));
+*/
+
+// Count lines of code of application
+$commandcheck = ($dirscc ? $dirscc.'/' : '').'scc . --exclude-dir=includes,custom';
+print 'Execute SCC to count lines of code in project: '.$commandcheck."\n";
+$output_arrproj = array();
+$resexecproj = 0;
+exec($commandcheck, $output_arrproj, $resexecproj);
+
+
+// Count lines of code of dependencies
+$commandcheck = ($dirscc ? $dirscc.'/' : '').'scc htdocs/includes';
+print 'Execute SCC to count lines of code in dependencies: '.$commandcheck."\n";
+$output_arrdep = array();
+$resexecdep = 0;
+exec($commandcheck, $output_arrdep, $resexecdep);
+
+
+// Get technical debt
+$commandcheck = ($dirphpstan ? $dirphpstan.'/' : '').'phpstan -v analyze -a build/phpstan/bootstrap.php --memory-limit 5G --error-format=github';
+print 'Execute PHPStan to get the technical debt: '.$commandcheck."\n";
+$output_arrtd = array();
+$resexectd = 0;
+exec($commandcheck, $output_arrtd, $resexectd);
+
+$arrayoflineofcode = array();
+$arraycocomo = array();
+$arrayofmetrics = array(
+ 'proj'=>array('Bytes'=>0, 'Files'=>0, 'Lines'=>0, 'Blanks'=>0, 'Comments'=>0, 'Code'=>0, 'Complexity'=>0),
+ 'dep'=>array('Bytes'=>0, 'Files'=>0, 'Lines'=>0, 'Blanks'=>0, 'Comments'=>0, 'Code'=>0, 'Complexity'=>0)
+);
+
+// Analyse $output_arrproj
+foreach (array('proj', 'dep') as $source) {
+ print 'Analyze SCC result for lines of code for '.$source."\n";
+ if ($source == 'proj') {
+ $output_arr = &$output_arrproj;
+ } elseif ($source == 'dep') {
+ $output_arr = &$output_arrdep;
+ } else {
+ print 'Bad value for $source';
+ die();
+ }
+
+ foreach ($output_arr as $line) {
+ if (preg_match('/^(───|Language|Total)/', $line)) {
+ continue;
+ }
+
+ //print $line." \n";
+
+ if (preg_match('/^Estimated Cost.*\$(.*)/i', $line, $reg)) {
+ $arraycocomo[$source]['currency'] = preg_replace('/[^\d\.]/', '', str_replace(array(',', ' '), array('', ''), $reg[1]));
+ }
+ if (preg_match('/^Estimated Schedule Effort.*\s([\d\s,]+)/i', $line, $reg)) {
+ $arraycocomo[$source]['effort'] = str_replace(array(',', ' '), array('.', ''), $reg[1]);
+ }
+ if (preg_match('/^Estimated People.*\s([\d\s,]+)/i', $line, $reg)) {
+ $arraycocomo[$source]['people'] = str_replace(array(',', ' '), array('.', ''), $reg[1]);
+ }
+ if (preg_match('/^Processed\s(\d+)\s/i', $line, $reg)) {
+ $arrayofmetrics[$source]['Bytes'] = $reg[1];
+ }
+
+ if (preg_match('/^(.*)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)$/', $line, $reg)) {
+ $arrayoflineofcode[$source][$reg[1]]['Files'] = $reg[2];
+ $arrayoflineofcode[$source][$reg[1]]['Lines'] = $reg[3];
+ $arrayoflineofcode[$source][$reg[1]]['Blanks'] = $reg[4];
+ $arrayoflineofcode[$source][$reg[1]]['Comments'] = $reg[5];
+ $arrayoflineofcode[$source][$reg[1]]['Code'] = $reg[6];
+ $arrayoflineofcode[$source][$reg[1]]['Complexity'] = $reg[7];
+ }
+ }
+
+ if (!empty($arrayoflineofcode[$source])) {
+ foreach ($arrayoflineofcode[$source] as $key => $val) {
+ $arrayofmetrics[$source]['Files'] += $val['Files'];
+ $arrayofmetrics[$source]['Lines'] += $val['Lines'];
+ $arrayofmetrics[$source]['Blanks'] += $val['Blanks'];
+ $arrayofmetrics[$source]['Comments'] += $val['Comments'];
+ $arrayofmetrics[$source]['Code'] += $val['Code'];
+ $arrayofmetrics[$source]['Complexity'] += $val['Complexity'];
+ }
+ }
+}
+
+
+/*
+ * View
+ */
+
+$html = ''."\n";
+$html .= ' '."\n";
+$html .= ' '."\n";
+$html .= ' '."\n";
+$html .= ''."\n";
+$html .= '
+'."\n";
+
+$html .= ''."\n";
+
+$html .= ''."\n";
+$html .= 'Advanced Project Statistics '."\n";
+$currentDate = date("Y-m-d H:i:s"); // Format: Year-Month-Day Hour:Minute:Second
+$html .= 'Generated on '.$currentDate.' '."\n";
+$html .= ' '."\n";
+
+$html .= ''."\n";
+$html .= 'Lines of code '."\n";
+
+$html .= ''."\n";
+$html .= '
';
+$html .= '';
+$html .= 'Language';
+$html .= ' Bytes ';
+$html .= 'Files ';
+$html .= 'Lines ';
+$html .= 'Blanks ';
+$html .= 'Comments ';
+$html .= 'Code ';
+//$html .= ''.$val['Complexity'].' ';
+$html .= '';
+foreach (array('proj', 'dep') as $source) {
+ $html .= ' ';
+ if ($source == 'proj') {
+ $html .= 'All files from project only';
+ } elseif ($source == 'dep') {
+ $html .= ' All files from dependencies';
+ }
+ $html .= ' (See detail per file type...) ';
+ $html .= ' '.formatNumber($arrayofmetrics[$source]['Bytes']).' ';
+ $html .= ''.formatNumber($arrayofmetrics[$source]['Files']).' ';
+ $html .= ''.formatNumber($arrayofmetrics[$source]['Lines']).' ';
+ $html .= ''.formatNumber($arrayofmetrics[$source]['Blanks']).' ';
+ $html .= ''.formatNumber($arrayofmetrics[$source]['Comments']).' ';
+ $html .= ''.formatNumber($arrayofmetrics[$source]['Code']).' ';
+ $html .= ' ';
+ $html .= ' ';
+ if (!empty($arrayoflineofcode[$source])) {
+ foreach ($arrayoflineofcode[$source] as $key => $val) {
+ $html .= '';
+ $html .= ''.$key.' ';
+ $html .= ' ';
+ $html .= ''.(empty($val['Files']) ? '' : formatNumber($val['Files'])).' ';
+ $html .= ''.(empty($val['Lines']) ? '' : formatNumber($val['Lines'])).' ';
+ $html .= ''.(empty($val['Blanks']) ? '' : formatNumber($val['Blanks'])).' ';
+ $html .= ''.(empty($val['Comments']) ? '' : formatNumber($val['Comments'])).' ';
+ $html .= ''.(empty($val['Code']) ? '' : formatNumber($val['Code'])).' ';
+ //$html .= ''.(empty($val['Complexity']) ? '' : $val['Complexity']).' ';
+ $html .= 'TODO graph here... ';
+ $html .= ' ';
+ }
+ }
+}
+
+$html .= '';
+$html .= 'Total ';
+$html .= ''.formatNumber($arrayofmetrics['proj']['Bytes'] + $arrayofmetrics['dep']['Bytes']).' ';
+$html .= ''.formatNumber($arrayofmetrics['proj']['Files'] + $arrayofmetrics['dep']['Files']).' ';
+$html .= ''.formatNumber($arrayofmetrics['proj']['Lines'] + $arrayofmetrics['dep']['Lines']).' ';
+$html .= ''.formatNumber($arrayofmetrics['proj']['Blanks'] + $arrayofmetrics['dep']['Blanks']).' ';
+$html .= ''.formatNumber($arrayofmetrics['proj']['Comments'] + $arrayofmetrics['dep']['Comments']).' ';
+$html .= ''.formatNumber($arrayofmetrics['proj']['Code'] + $arrayofmetrics['dep']['Code']).' ';
+//$html .= ''.$arrayofmetrics['Complexity'].' ';
+$html .= ' ';
+$html .= ' ';
+$html .= '
';
+$html .= '
';
+
+$html .= ' '."\n";
+
+$html .= ''."\n";
+$html .= 'Project value '."\n";
+$html .= '';
+$html .= 'COCOMO (Basic organic model) value: ';
+$html .= '$'.formatNumber((empty($arraycocomo['proj']['currency']) ? 0 : $arraycocomo['proj']['currency']) + (empty($arraycocomo['dep']['currency']) ? 0 : $arraycocomo['dep']['currency']), 2).' ';
+$html .= '
';
+$html .= '';
+$html .= 'COCOMO (Basic organic model) effort
';
+$html .= '
'.formatNumber($arraycocomo['proj']['people'] * $arraycocomo['proj']['effort'] + $arraycocomo['dep']['people'] * $arraycocomo['dep']['effort']);
+$html .= ' monthes people ';
+$html .= ''."\n";
+
+$html .= '
'."\n";
+$html .= 'Technical debt ('.count($output_arrtd).') '."\n";
+$html .= ''."\n";
+$html .= '
'."\n";
+$html .= 'File Line Type '."\n";
+foreach ($output_arrtd as $line) {
+ $reg = array();
+ //print $line."\n";
+ preg_match('/^::error file=(.*),line=(\d+),col=(\d+)::(.*)$/', $line, $reg);
+ if (!empty($reg[1])) {
+ $html .= ''.$reg[1].' '.$reg[2].' '.$reg[4].' '."\n";
+ }
+}
+$html .= '
';
+$html .= '
';
+$html .= ' '."\n";
+
+$html .= '
+
+';
+$html .= '';
+$html .= '';
+
+$fh = fopen($outputpath, 'w');
+if ($fh) {
+ fwrite($fh, $html);
+ fclose($fh);
+
+ print 'Generation of output file '.$outputfile.' done.'."\n";
+} else {
+ print 'Failed to open '.$outputfile.' for ouput.'."\n";
+}
+
+
+/**
+ * function to format a number
+ *
+ * @param string|int $number Number to format
+ * @param int $nbdec Number of decimal digits
+ * @return string Formated string
+ */
+function formatNumber($number, $nbdec = 0)
+{
+ return number_format($number, 0, '.', ' ');
+}
diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php
index c5db08e73e7..ed3ee851709 100644
--- a/htdocs/accountancy/admin/account.php
+++ b/htdocs/accountancy/admin/account.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2013-2020 Alexandre Spangaro
+ * Copyright (C) 2013-2023 Alexandre Spangaro
* Copyright (C) 2016-2018 Laurent Destailleur
*
* This program is free software; you can redistribute it and/or modify
@@ -142,10 +142,13 @@ if (empty($reshook)) {
$search_labelshort = "";
$search_accountparent = "";
$search_pcgtype = "";
+ $search_import_key = "";
$search_array_options = array();
}
if ((GETPOST('valid_change_chart', 'alpha') && GETPOST('chartofaccounts', 'int') > 0) // explicit click on button 'Change and load' with js on
|| (GETPOST('chartofaccounts', 'int') > 0 && GETPOST('chartofaccounts', 'int') != getDolGlobalInt('CHARTOFACCOUNTS'))) { // a submit of form is done and chartofaccounts combo has been modified
+ $error = 0;
+
if ($chartofaccounts > 0 && $permissiontoadd) {
// Get language code for this $chartofaccounts
$sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_country as c, '.MAIN_DB_PREFIX.'accounting_system as a';
@@ -218,14 +221,13 @@ if (empty($reshook)) {
/*
* View
*/
-
$form = new Form($db);
$formaccounting = new FormAccounting($db);
llxHeader('', $langs->trans("ListAccounts"));
if ($action == 'delete') {
- $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1);
+ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1);
print $formconfirm;
}
@@ -234,11 +236,24 @@ $pcgver = getDolGlobalInt('CHARTOFACCOUNTS');
$sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.account_number, aa.account_parent, aa.label, aa.labelshort, aa.fk_accounting_category,";
$sql .= " aa.reconcilable, aa.active, aa.import_key,";
$sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2";
+
+// Add fields from hooks
+$parameters = array();
+$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+$sql .= $hookmanager->resPrint;
+$sql = preg_replace('/,\s*$/', '', $sql);
+
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = ".((int) $conf->entity);
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".((int) $conf->entity);
+
+// Add table from hooks
+$parameters = array();
+$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
+$sql .= $hookmanager->resPrint;
+
$sql .= " WHERE asy.rowid = ".((int) $pcgver);
-//print $sql;
+
if (strlen(trim($search_account))) {
$lengthpaddingaccount = 0;
if (getDolGlobalInt('ACCOUNTING_LENGTH_GACCOUNT') || getDolGlobalInt('ACCOUNTING_LENGTH_AACCOUNT')) {
@@ -285,6 +300,15 @@ if (strlen(trim($search_accountparent)) && $search_accountparent != '-1') {
if (strlen(trim($search_pcgtype))) {
$sql .= natural_search("aa.pcg_type", $search_pcgtype);
}
+if (strlen(trim($search_import_key))) {
+ $sql .= natural_search("aa.import_key", $search_import_key);
+}
+
+// Add where from hooks
+$parameters = array();
+$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+$sql .= $hookmanager->resPrint;
+
$sql .= $db->order($sortfield, $sortorder);
//print $sql;
@@ -299,16 +323,6 @@ if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
}
}
-// List of mass actions available
-if ($user->hasRight('accounting', 'chartofaccount')) {
- $arrayofmassactions['predelete'] = ' '.$langs->trans("Delete");
-}
-if (in_array($massaction, array('presend', 'predelete', 'closed'))) {
- $arrayofmassactions = array();
-}
-
-$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
-$arrayofselected = is_array($toselect) ? $toselect : array();
$sql .= $db->plimit($limit + 1, $offset);
dol_syslog('accountancy/admin/account.php:: $sql='.$sql);
@@ -317,6 +331,8 @@ $resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
+ $arrayofselected = is_array($toselect) ? $toselect : array();
+
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
@@ -339,13 +355,18 @@ if ($resql) {
if ($search_pcgtype) {
$param .= '&search_pcgtype='.urlencode($search_pcgtype);
}
- if ($optioncss != '') {
+ if ($search_import_key) {
$param .= '&search_import_key='.urlencode($search_import_key);
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
+ // Add $param from hooks
+ $parameters = array();
+ $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+ $param .= $hookmanager->resPrint;
+
if (!empty($conf->use_javascript_ajax)) {
print '
';
}
+ // List of mass actions available
+ if ($user->hasRight('accounting', 'chartofaccount')) {
+ $arrayofmassactions['predelete'] = ' '.$langs->trans("Delete");
+ }
+ if (in_array($massaction, array('presend', 'predelete', 'closed'))) {
+ $arrayofmassactions = array();
+ }
+
+ $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
+
$newcardbutton = '';
+ $newcardbutton = dolGetButtonTitle($langs->trans('Addanaccount'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/accountancy/admin/card.php?action=create', '', $permissiontoadd);
+
print '';
+ $db->free($resql);
+
+ $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
+ $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+
+ print ''."\n";
+ print ' '."\n";
+
+ print ''."\n";
} else {
dol_print_error($db);
}
diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php
index e77b97fe92d..7b7148f89ce 100644
--- a/htdocs/accountancy/admin/categories_list.php
+++ b/htdocs/accountancy/admin/categories_list.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2004-2023 Laurent Destailleur
* Copyright (C) 2011-2021 Alexandre Spangaro
*
* This program is free software; you can redistribute it and/or modify
@@ -852,6 +852,9 @@ if ($resql) {
print "\n";
$i++;
}
+ } else {
+ $colspan = 11;
+ print ''.$langs->trans("None").' ';
}
} else {
dol_print_error($db);
diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php
index 13a07be6dfc..3a7f743059d 100644
--- a/htdocs/accountancy/admin/defaultaccounts.php
+++ b/htdocs/accountancy/admin/defaultaccounts.php
@@ -78,17 +78,24 @@ if ($mysoc->isInEEC()) {
$list_account[] = 'ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT';
$list_account[] = '---Others---';
-$list_account[] = 'ACCOUNTING_VAT_BUY_ACCOUNT';
$list_account[] = 'ACCOUNTING_VAT_SOLD_ACCOUNT';
+$list_account[] = 'ACCOUNTING_VAT_BUY_ACCOUNT';
+
+/*if ($mysoc->useRevenueStamp()) {
+ $list_account[] = 'ACCOUNTING_REVENUESTAMP_SOLD_ACCOUNT';
+ $list_account[] = 'ACCOUNTING_REVENUESTAMP_BUY_ACCOUNT';
+}*/
+
$list_account[] = 'ACCOUNTING_VAT_PAY_ACCOUNT';
-if (!empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) {
+
+if (getDolGlobalString('ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) {
$list_account[] = 'ACCOUNTING_VAT_BUY_REVERSE_CHARGES_CREDIT';
$list_account[] = 'ACCOUNTING_VAT_BUY_REVERSE_CHARGES_DEBIT';
}
if (isModEnabled('banque')) {
$list_account[] = 'ACCOUNTING_ACCOUNT_TRANSFER_CASH';
}
-if (!empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) {
+if (getDolGlobalString('INVOICE_USE_RETAINED_WARRANTY')) {
$list_account[] = 'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY';
}
if (isModEnabled('don')) {
@@ -110,6 +117,7 @@ if (isModEnabled('societe')) {
/*
* Actions
*/
+
if ($action == 'update') {
$error = 0;
// Process $list_account_main
@@ -257,6 +265,8 @@ foreach ($list_account as $key) {
print img_picto('', 'payment_vat', 'class="pictofixedwidth"');
} elseif (preg_match('/^ACCOUNTING_VAT/', $key)) {
print img_picto('', 'vat', 'class="pictofixedwidth"');
+ /*} elseif (preg_match('/^ACCOUNTING_REVENUESTAMP/', $key)) {
+ print img_picto('', 'vat', 'class="pictofixedwidth"');*/
} elseif (preg_match('/^ACCOUNTING_ACCOUNT_CUSTOMER/', $key)) {
print img_picto('', 'bill', 'class="pictofixedwidth"');
} elseif (preg_match('/^LOAN_ACCOUNTING_ACCOUNT/', $key)) {
diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php
index 30cc0144a1f..70dd216b7c9 100644
--- a/htdocs/accountancy/admin/export.php
+++ b/htdocs/accountancy/admin/export.php
@@ -152,7 +152,7 @@ foreach ($listparam as $key => $param) {
print ' {'."\n";
print ' //console.log("'.$param['label'].'");'."\n";
if (empty($param['ACCOUNTING_EXPORT_FORMAT'])) {
- print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$conf->global->ACCOUNTING_EXPORT_FORMAT.'");'."\n";
+ print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.getDolGlobalString('ACCOUNTING_EXPORT_FORMAT').'");'."\n";
print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").prop("disabled", true);'."\n";
} else {
print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$param['ACCOUNTING_EXPORT_FORMAT'].'");'."\n";
@@ -162,7 +162,7 @@ foreach ($listparam as $key => $param) {
print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("");'."\n";
print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").prop("disabled", true);'."\n";
} else {
- print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("'.$conf->global->ACCOUNTING_EXPORT_SEPARATORCSV.'");'."\n";
+ print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("'.getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV').'");'."\n";
print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").removeAttr("disabled");'."\n";
}
if (empty($param['ACCOUNTING_EXPORT_ENDLINE'])) {
@@ -174,7 +174,7 @@ foreach ($listparam as $key => $param) {
print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("");'."\n";
print ' jQuery("#ACCOUNTING_EXPORT_DATE").prop("disabled", true);'."\n";
} else {
- print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("'.$conf->global->ACCOUNTING_EXPORT_DATE.'");'."\n";
+ print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("'.getDolGlobalString('ACCOUNTING_EXPORT_DATE').'");'."\n";
print ' jQuery("#ACCOUNTING_EXPORT_DATE").removeAttr("disabled");'."\n";
}
print ' }'."\n";
diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php
index 3b6f12566fe..508a4167195 100644
--- a/htdocs/accountancy/admin/index.php
+++ b/htdocs/accountancy/admin/index.php
@@ -45,6 +45,8 @@ if (!$user->hasRight('accounting', 'chartofaccount')) {
$action = GETPOST('action', 'aZ09');
+$nbletter = GETPOST('ACCOUNTING_LETTERING_NBLETTERS', 'int');
+
// Parameters ACCOUNTING_* and others
$list = array(
'ACCOUNTING_LENGTH_GACCOUNT',
@@ -56,7 +58,8 @@ $list = array(
$list_binding = array(
'ACCOUNTING_DATE_START_BINDING',
- 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER'
+ 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER',
+ 'ACCOUNTING_LETTERING_NBLETTERS'
);
$error = 0;
@@ -271,19 +274,19 @@ print load_fiche_titre($title, $linkback, 'accountancy');
// Show message if accountancy hidden options are activated to help to resolve some problems
if (!$user->admin) {
- if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
+ if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) {
print '' . $langs->trans("ConstantIsOn", "FACTURE_DEPOSITS_ARE_JUST_PAYMENTS") . '
';
}
- if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
+ if (getDolGlobalString('FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS')) {
print '' . $langs->trans("ConstantIsOn", "FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS") . '
';
}
- if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
+ if (getDolGlobalString('ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY')) {
print '' . $langs->trans("ConstantIsOn", "ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY") . '
';
}
- if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
+ if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
print '' . $langs->trans("ConstantIsOn", "MAIN_COMPANY_PERENTITY_SHARED") . '
';
}
- if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
+ if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
print '' . $langs->trans("ConstantIsOn", "MAIN_PRODUCT_PERENTITY_SHARED") . '
';
}
}
@@ -303,7 +306,7 @@ print "\n";
/* Set this option as a hidden option but keep it for some needs.
print '';
print ''.$langs->trans("ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL").' ';
-if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) {
+if (getDolGlobalString('ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL')) {
print '';
print img_picto($langs->trans("Activated"), 'switch_on');
print ' ';
@@ -317,7 +320,7 @@ print ' ';
print '';
print ''.$langs->trans("BANK_DISABLE_DIRECT_INPUT").' ';
-if (!empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) {
+if (getDolGlobalString('BANK_DISABLE_DIRECT_INPUT')) {
print '';
print img_picto($langs->trans("Activated"), 'switch_on');
print ' ';
@@ -333,7 +336,7 @@ print ''.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX");
print ' - '.$langs->trans("NotRecommended").' ';
print ' ';
-if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
+if (getDolGlobalString('ACCOUNTANCY_COMBO_FOR_AUX')) {
print '';
print img_picto($langs->trans("Activated"), 'switch_on');
print ' ';
@@ -346,7 +349,7 @@ print ' ';
print '';
print ''.$langs->trans("ACCOUNTING_MANAGE_ZERO").' ';
-if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO)) {
+if (getDolGlobalInt('ACCOUNTING_MANAGE_ZERO')) {
print '';
print img_picto($langs->trans("Activated"), 'switch_on');
print ' ';
@@ -408,7 +411,7 @@ foreach ($list_binding as $key) {
print ' ';
print ''.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_SALES").' ';
-if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)) {
+if (getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_SALES')) {
print '';
print img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', 'warning');
print ' ';
@@ -421,7 +424,7 @@ print ' ';
print '';
print ''.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_PURCHASES").' ';
-if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)) {
+if (getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_PURCHASES')) {
print '';
print img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', 'warning');
print ' ';
@@ -434,7 +437,7 @@ print ' ';
print '';
print ''.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS").' ';
-if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) {
+if (getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS')) {
print '';
print img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', 'warning');
print ' ';
@@ -462,7 +465,7 @@ print " \n";
print '';
print '';
print $form->textwithpicto($langs->trans("ACCOUNTING_ENABLE_LETTERING"), $langs->trans("ACCOUNTING_ENABLE_LETTERING_DESC", $langs->transnoentitiesnoconv("NumMvts")).' '.$langs->trans("EnablingThisFeatureIsNotNecessary")).' ';
-if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) {
+if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) {
print '';
print img_picto($langs->trans("Activated"), 'switch_on');
print ' ';
@@ -473,11 +476,29 @@ if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) {
}
print ' ';
-if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) {
+if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) {
+ // Number of letters for lettering (3 by default (AAA), min 2 (AA))
+ print '';
+ print '';
+ print $form->textwithpicto($langs->trans("ACCOUNTING_LETTERING_NBLETTERS"), $langs->trans("ACCOUNTING_LETTERING_NBLETTERS_DESC")) . ' ';
+ print '';
+
+ if (empty($letter)) {
+ if (getDolGlobalInt('ACCOUNTING_LETTERING_NBLETTERS')) {
+ $nbletter = getDolGlobalInt('ACCOUNTING_LETTERING_NBLETTERS');
+ } else {
+ $nbletter = 3;
+ }
+ }
+
+ print ' ' . "\n";
+ print ' ';
+
+ // Auto Lettering when transfer in accountancy is realized
print '';
print '';
print $form->textwithpicto($langs->trans("ACCOUNTING_ENABLE_AUTOLETTERING"), $langs->trans("ACCOUNTING_ENABLE_AUTOLETTERING_DESC")) . ' ';
- if (!empty($conf->global->ACCOUNTING_ENABLE_AUTOLETTERING)) {
+ if (getDolGlobalInt('ACCOUNTING_ENABLE_AUTOLETTERING')) {
print '';
print img_picto($langs->trans("Activated"), 'switch_on');
print ' ';
@@ -492,7 +513,7 @@ if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) {
print ' ';
print '';
print $form->textwithpicto($langs->trans("ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE"), $langs->trans("ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE_DESC", $langs->transnoentities("MenuDefaultAccounts"))).' ';
-if (!empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) {
+if (getDolGlobalString('ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) {
print '';
print img_picto($langs->trans("Activated"), 'switch_on');
print ' ';
diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php
index a524f29b840..18a85ca923c 100644
--- a/htdocs/accountancy/admin/productaccount.php
+++ b/htdocs/accountancy/admin/productaccount.php
@@ -85,7 +85,7 @@ if (empty($accounting_product_mode)) {
$accounting_product_mode = 'ACCOUNTANCY_SELL';
}
-$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : getDolGlobalInt('ACCOUNTING_LIMIT_LIST_VENTILATION', $conf->liste_limit);
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
@@ -199,7 +199,7 @@ if ($action == 'update') {
$ko++;
} else {
$sql = '';
- if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
+ if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
$sql_exists = "SELECT rowid FROM " . MAIN_DB_PREFIX . "product_perentity";
$sql_exists .= " WHERE fk_product = " . ((int) $productid) . " AND entity = " . ((int) $conf->entity);
$resql_exists = $db->query($sql_exists);
@@ -309,7 +309,7 @@ if (empty($pcgvercode)) {
}
$sql = "SELECT p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy, p.tva_tx,";
-if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
+if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
$sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export,";
$sql .= " ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export,";
} else {
@@ -319,7 +319,7 @@ if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
$sql .= " p.tms, p.fk_product_type as product_type,";
$sql .= " aa.rowid as aaid";
$sql .= " FROM ".MAIN_DB_PREFIX."product as p";
-if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
+if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = ppe." . $accountancy_field_name . " AND aa.fk_pcg_version = '" . $db->escape($pcgvercode) . "'";
} else {
@@ -386,7 +386,7 @@ $sql .= " GROUP BY p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy, p.
$sql .= " p.fk_product_type,";
$sql .= ' p.tms,';
$sql .= ' aa.rowid,';
-if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
+if (!getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
$sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export";
} else {
$sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export, ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export";
@@ -534,7 +534,7 @@ if ($resql) {
}
// Show/hide child products. Hidden by default
- if (isModEnabled('variants') && !empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) {
+ if (isModEnabled('variants') && getDolGlobalInt('PRODUIT_ATTRIBUTES_HIDECHILD')) {
$moreforfilter .= '';
$moreforfilter .= '
';
$moreforfilter .= '
'.$langs->trans('ShowChildProducts').' ';
@@ -570,7 +570,7 @@ if ($resql) {
print '
';
print '
';
- if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) {
+ if (getDolGlobalInt('ACCOUNTANCY_SHOW_PROD_DESC')) {
print '
';
}
// On sell
@@ -604,7 +604,7 @@ if ($resql) {
}
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
- if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) {
+ if (getDolGlobalInt('ACCOUNTANCY_SHOW_PROD_DESC')) {
print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder);
}
print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "p.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ');
@@ -641,30 +641,31 @@ if ($resql) {
// Sales
if ($obj->product_type == 0) {
if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
- $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
+ $compta_prodsell = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_ACCOUNT', $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell;
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
- $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
+ $compta_prodsell = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT', $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell_intra;
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
- $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
+ $compta_prodsell = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT', $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell_export;
} else {
- $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
+ $compta_prodsell = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_ACCOUNT', $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell;
}
} else {
if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
- $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
+ $compta_prodsell = getDolGlobalString('ACCOUNTING_SERVICE_SOLD_ACCOUNT', $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_servsell;
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
- $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
+ $compta_prodsell = getDolGlobalString('ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT', $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_servsell_intra;
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
- $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
+ $compta_prodsell = getDolGlobalString('ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT', $langs->trans("CodeNotDef"));
+
$compta_prodsell_id = $aarowid_servsell_export;
} else {
- $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
+ $compta_prodsell = getDolGlobalString('ACCOUNTING_SERVICE_SOLD_ACCOUNT', $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_servsell;
}
}
@@ -672,30 +673,30 @@ if ($resql) {
// Purchases
if ($obj->product_type == 0) {
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
- $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
+ $compta_prodbuy = getDolGlobalString('ACCOUNTING_PRODUCT_BUY_ACCOUNT', $langs->trans("CodeNotDef"));
$compta_prodbuy_id = $aarowid_prodbuy;
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
- $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
+ $compta_prodbuy = getDolGlobalString('ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT', $langs->trans("CodeNotDef"));
$compta_prodbuy_id = $aarowid_prodbuy_intra;
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
- $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
+ $compta_prodbuy = getDolGlobalString('ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT', $langs->trans("CodeNotDef"));
$compta_prodbuy_id = $aarowid_prodbuy_export;
} else {
- $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
+ $compta_prodbuy = getDolGlobalString('ACCOUNTING_PRODUCT_BUY_ACCOUNT', $langs->trans("CodeNotDef"));
$compta_prodbuy_id = $aarowid_prodbuy;
}
} else {
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
- $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
+ $compta_prodbuy = getDolGlobalString('ACCOUNTING_SERVICE_BUY_ACCOUNT', $langs->trans("CodeNotDef"));
$compta_prodbuy_id = $aarowid_servbuy;
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
- $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
+ $compta_prodbuy = getDolGlobalString('ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT', $langs->trans("CodeNotDef"));
$compta_prodbuy_id = $aarowid_servbuy_intra;
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
- $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
+ $compta_prodbuy = getDolGlobalString('ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT', $langs->trans("CodeNotDef"));
$compta_prodbuy_id = $aarowid_servbuy_export;
} else {
- $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
+ $compta_prodbuy = getDolGlobalString('ACCOUNTING_SERVICE_BUY_ACCOUNT', $langs->trans("CodeNotDef"));
$compta_prodbuy_id = $aarowid_servbuy;
}
}
@@ -722,11 +723,11 @@ if ($resql) {
print '
'.$obj->label.' ';
- if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) {
+ if (getDolGlobalInt('ACCOUNTANCY_SHOW_PROD_DESC')) {
// TODO ADJUST DESCRIPTION SIZE
// print '
' . $obj->description . ' ';
// TODO: we should set a user defined value to adjust user square / wide screen size
- $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
+ $trunclength = getDolGlobalInt('ACCOUNTING_LENGTH_DESCRIPTION', 32);
print '
'.nl2br(dol_trunc($obj->description, $trunclength)).' ';
}
diff --git a/htdocs/accountancy/admin/subaccount.php b/htdocs/accountancy/admin/subaccount.php
index 568ce9f04ab..8c660feb769 100644
--- a/htdocs/accountancy/admin/subaccount.php
+++ b/htdocs/accountancy/admin/subaccount.php
@@ -355,7 +355,7 @@ if ($resql) {
if (!empty($arrayfields['type']['checked'])) {
print '
'.$form->selectarray('search_type', array('1'=>$langs->trans('Customer'), '2'=>$langs->trans('Supplier'), '3'=>$langs->trans('Employee')), $search_type, 1).' ';
}
- if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
+ if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
if (!empty($arrayfields['reconcilable']['checked'])) {
print '
';
}
@@ -383,7 +383,7 @@ if ($resql) {
if (!empty($arrayfields['type']['checked'])) {
print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "type", "", $param, '', $sortfield, $sortorder, 'center ');
}
- if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
+ if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
if (!empty($arrayfields['reconcilable']['checked'])) {
print_liste_field_titre($arrayfields['reconcilable']['label'], $_SERVER["PHP_SELF"], 'reconcilable', '', $param, '', $sortfield, $sortorder, 'center ');
}
@@ -469,7 +469,7 @@ if ($resql) {
}
}
- if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
+ if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
// Activated or not reconciliation on accounting account
if (!empty($arrayfields['reconcilable']['checked'])) {
print '
';
diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php
index 98c8e5b923d..00afaf9795d 100644
--- a/htdocs/accountancy/bookkeeping/card.php
+++ b/htdocs/accountancy/bookkeeping/card.php
@@ -497,7 +497,7 @@ if ($action == 'create') {
// Ref document
print ' ';
- print '';
+ print '';
print $langs->trans('Piece');
print ' ';
if ($action != 'editdocref') {
diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php
index 53650a3cd28..994e7c7d15e 100644
--- a/htdocs/accountancy/bookkeeping/list.php
+++ b/htdocs/accountancy/bookkeeping/list.php
@@ -29,26 +29,30 @@
// Load Dolibarr environment
require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php';
-require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
-require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
+require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
+require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php';
// Load translation files required by the page
$langs->loadLangs(array("accountancy", "compta"));
+// Get Parameters
$socid = GETPOST('socid', 'int');
+// action+display Parameters
$action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$toselect = GETPOST('toselect', 'array');
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'bookkeepinglist';
+
+// Search Parameters
$search_mvt_num = GETPOST('search_mvt_num', 'int');
$search_doc_type = GETPOST("search_doc_type", 'alpha');
$search_doc_ref = GETPOST("search_doc_ref", 'alpha');
diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php
index 80b74c41fdf..0010120d560 100644
--- a/htdocs/accountancy/class/accountancycategory.class.php
+++ b/htdocs/accountancy/class/accountancycategory.class.php
@@ -1,7 +1,7 @@
* Copyright (C) 2016-2017 Alexandre Spangaro
- * Copyright (C) 2018-2019 Frédéric France
+ * Copyright (C) 2018-2023 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -123,11 +123,19 @@ class AccountancyCategory // extends CommonObject
public $lines_display;
/**
- * @var mixed Sample property 1
+ * @var mixed Sum debit credit
*/
public $sdc;
+ /**
+ * @var array Sum debit credit per month
+ */
+ public $sdcpermonth;
+ /**
+ * @var array Sum debit credit per account
+ */
+ public $sdcperaccount;
/**
* Constructor
diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php
index 881142e22ed..318fc26c662 100644
--- a/htdocs/accountancy/class/accountancyexport.class.php
+++ b/htdocs/accountancy/class/accountancyexport.class.php
@@ -816,7 +816,7 @@ class AccountancyExport
/**
* Export format : Quadratus (Format ASCII)
* Format since 2015 compatible QuadraCOMPTA
- * Last review for this format : 2023/01/28 Alexandre Spangaro (aspangaro@open-dsi.fr)
+ * Last review for this format : 2023/09/16 Alexandre Spangaro (aspangaro@open-dsi.fr)
*
* Help : https://docplayer.fr/20769649-Fichier-d-entree-ascii-dans-quadracompta.html
* In QuadraCompta | Use menu : "Outils" > "Suivi des dossiers" > "Import ASCII(Compta)"
@@ -839,10 +839,16 @@ class AccountancyExport
foreach ($objectLines as $line) {
// Clean some data
$line->doc_ref = dol_string_unaccent($line->doc_ref);
+
+ $line->label_operation = str_replace(array("\t", "\n", "\r"), " ", $line->label_operation);
+ $line->label_operation = str_replace(array("- ", "…", "..."), "", $line->label_operation);
$line->label_operation = dol_string_unaccent($line->label_operation);
+
$line->numero_compte = dol_string_unaccent($line->numero_compte);
$line->label_compte = dol_string_unaccent($line->label_compte);
$line->subledger_account = dol_string_unaccent($line->subledger_account);
+
+ $line->subledger_label = str_replace(array("- ", "…", "..."), "", $line->subledger_label);
$line->subledger_label = dol_string_unaccent($line->subledger_label);
$code_compta = $line->numero_compte;
@@ -858,11 +864,11 @@ class AccountancyExport
$tab['lib_compte'] = str_pad(self::trunc($line->subledger_label, 30), 30);
if ($line->doc_type == 'customer_invoice') {
- $tab['lib_alpha'] = strtoupper(str_pad('C'.self::trunc(dol_string_unaccent($line->subledger_label), 6), 6));
+ $tab['lib_alpha'] = strtoupper(str_pad('C'.self::trunc(dol_string_unaccent($line->subledger_label), 6), 7));
$tab['filler'] = str_repeat(' ', 52);
$tab['coll_compte'] = str_pad(self::trunc($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, 8), 8);
} elseif ($line->doc_type == 'supplier_invoice') {
- $tab['lib_alpha'] = strtoupper(str_pad('F'.self::trunc(dol_string_unaccent($line->subledger_label), 6), 6));
+ $tab['lib_alpha'] = strtoupper(str_pad('F'.self::trunc(dol_string_unaccent($line->subledger_label), 6), 7));
$tab['filler'] = str_repeat(' ', 52);
$tab['coll_compte'] = str_pad(self::trunc($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, 8), 8);
} else {
diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php
index 99f908e70e3..ddfa39c6309 100644
--- a/htdocs/accountancy/class/accountancysystem.class.php
+++ b/htdocs/accountancy/class/accountancysystem.class.php
@@ -2,6 +2,7 @@
/* Copyright (C) 2013-2014 Olivier Geffroy
* Copyright (C) 2013-2014 Alexandre Spangaro
* Copyright (C) 2013-2014 Florian Henry
+ * Copyright (C) 2023 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -46,6 +47,13 @@ class AccountancySystem
/**
* @var int ID
*/
+ public $id;
+
+ /**
+ * @var int ID
+ * @deprecated
+ * @see $id
+ */
public $rowid;
/**
@@ -53,6 +61,21 @@ class AccountancySystem
*/
public $fk_pcg_version;
+ /**
+ * @var int pcg version
+ */
+ public $pcg_version;
+
+ /**
+ * @var string ref
+ */
+ public $ref;
+
+ /**
+ * @var int active
+ */
+ public $active;
+
/**
* @var string pcg type
*/
@@ -156,6 +179,7 @@ class AccountancySystem
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."accounting_system");
if ($id > 0) {
+ $this->id = $id;
$this->rowid = $id;
$result = $this->rowid;
} else {
diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php
index 6405a55c689..a0cd11c3ec1 100644
--- a/htdocs/accountancy/class/accountingaccount.class.php
+++ b/htdocs/accountancy/class/accountingaccount.class.php
@@ -508,7 +508,7 @@ class AccountingAccount extends CommonObject
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php
index 455c293686c..b687310193a 100644
--- a/htdocs/accountancy/class/bookkeeping.class.php
+++ b/htdocs/accountancy/class/bookkeeping.class.php
@@ -282,7 +282,7 @@ class BookKeeping extends CommonObject
$this->errors[] = $langs->trans('ErrorFieldAccountNotDefinedForBankLine', $this->fk_docdet, $this->doc_type);
} else {
//$this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->doc_ref, $this->label_compte);
- $mesg = $this->doc_ref.', '.$langs->trans("AccountAccounting").': '.$this->numero_compte;
+ $mesg = $this->doc_ref.', '.$langs->trans("AccountAccounting").': '.($this->numero_compte != -1 ? $this->numero_compte : $langs->trans("Unknown"));
if ($this->subledger_account && $this->subledger_account != $this->numero_compte) {
$mesg .= ', '.$langs->trans("SubledgerAccount").': '.$this->subledger_account;
}
@@ -488,7 +488,7 @@ class BookKeeping extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php
index 67eee9022b5..5cda6cad5b4 100644
--- a/htdocs/accountancy/class/lettering.class.php
+++ b/htdocs/accountancy/class/lettering.class.php
@@ -1,7 +1,7 @@
* Copyright (C) 2013 Olivier Geffroy
- * Copyright (C) 2013-2019 Alexandre Spangaro
+ * Copyright (C) 2013-2023 Alexandre Spangaro
* Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
@@ -97,8 +97,8 @@ class Lettering extends BookKeeping
$object->fetch($socid);
- if ($object->code_compta == '411CUSTCODE') {
- $object->code_compta = '';
+ if ($object->code_compta_client == '411CUSTCODE') {
+ $object->code_compta_client = '';
}
if ($object->code_compta_fournisseur == '401SUPPCODE') {
@@ -106,7 +106,7 @@ class Lettering extends BookKeeping
}
/**
- * Prise en charge des lettering complexe avec prelevment , virement
+ * Support for complex lettering with debit, credit transfer
*/
$sql = "SELECT DISTINCT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.subledger_account, ";
$sql .= " bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant ";
@@ -114,10 +114,10 @@ class Lettering extends BookKeeping
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON(bk.fk_doc = bu.fk_bank AND bu.type IN ('payment', 'payment_supplier') ) ";
$sql .= " WHERE ( ";
- if ($object->code_compta != "") {
- $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta)."' ";
+ if ($object->code_compta_client != "") {
+ $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta_client)."' ";
}
- if ($object->code_compta != "" && $object->code_compta_fournisseur != "") {
+ if ($object->code_compta_client != "" && $object->code_compta_fournisseur != "") {
$sql .= " OR ";
}
if ($object->code_compta_fournisseur != "") {
@@ -149,10 +149,10 @@ class Lettering extends BookKeeping
$sql .= " AND facf.entity = ".$conf->entity;
$sql .= " AND code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=4 AND entity=".$conf->entity.") ";
$sql .= " AND ( ";
- if ($object->code_compta != "") {
- $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta)."' ";
+ if ($object->code_compta_client != "") {
+ $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta_client)."' ";
}
- if ($object->code_compta != "" && $object->code_compta_fournisseur != "") {
+ if ($object->code_compta_client != "" && $object->code_compta_fournisseur != "") {
$sql .= " OR ";
}
if ($object->code_compta_fournisseur != "") {
@@ -178,10 +178,10 @@ class Lettering extends BookKeeping
$sql .= " WHERE bk.code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=3 AND entity=".$conf->entity.") ";
$sql .= " AND facf.entity = ".$conf->entity;
$sql .= " AND ( ";
- if ($object->code_compta != "") {
- $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta)."' ";
+ if ($object->code_compta_client != "") {
+ $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta_client)."' ";
}
- if ($object->code_compta != "" && $object->code_compta_fournisseur != "") {
+ if ($object->code_compta_client != "" && $object->code_compta_fournisseur != "") {
$sql .= " OR ";
}
if ($object->code_compta_fournisseur != "") {
@@ -210,10 +210,10 @@ class Lettering extends BookKeeping
$sql .= " AND bk.code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=4 AND entity=".$conf->entity.") ";
$sql .= " AND fac.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
$sql .= " AND ( ";
- if ($object->code_compta != "") {
- $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta)."' ";
+ if ($object->code_compta_client != "") {
+ $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta_client)."' ";
}
- if ($object->code_compta != "" && $object->code_compta_fournisseur != "") {
+ if ($object->code_compta_client != "" && $object->code_compta_fournisseur != "") {
$sql .= " OR ";
}
if ($object->code_compta_fournisseur != "") {
@@ -238,10 +238,10 @@ class Lettering extends BookKeeping
$sql .= " WHERE code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=2 AND entity=".$conf->entity.") ";
$sql .= " AND fac.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
$sql .= " AND ( ";
- if ($object->code_compta != "") {
- $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta)."' ";
+ if ($object->code_compta_client != "") {
+ $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta_client)."' ";
}
- if ($object->code_compta != "" && $object->code_compta_fournisseur != "") {
+ if ($object->code_compta_client != "" && $object->code_compta_fournisseur != "") {
$sql .= " OR ";
}
if ($object->code_compta_fournisseur != "") {
@@ -288,7 +288,9 @@ class Lettering extends BookKeeping
public function updateLettering($ids = array(), $notrigger = false)
{
$error = 0;
- $lettre = 'AAA';
+
+ // Generate a string with n char A where n is ACCOUNTING_LETTERING_NBLETTERS (So 'AA', 'AAA', ...)
+ $lettre = str_pad("", getDolGlobalInt('ACCOUNTING_LETTERING_NBLETTERS', 3), "A");
$sql = "SELECT DISTINCT ab2.lettering_code";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab";
@@ -327,7 +329,6 @@ class Lettering extends BookKeeping
}
// Update request
-
$now = dol_now();
$affected_rows = 0;
diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php
index 68e8b5c94ef..6b091db2cb8 100644
--- a/htdocs/accountancy/journal/bankjournal.php
+++ b/htdocs/accountancy/journal/bankjournal.php
@@ -861,7 +861,7 @@ if (!$error && $action == 'writebookkeeping') {
if (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT')) {
$error++;
$errorforline++;
- setEventMessages('Try to insert a non balanced transaction in book for '.$ref.'. Canceled. Surely a bug.', null, 'errors');
+ setEventMessages('We tried to insert a non balanced transaction in book for '.$ref.'. Canceled. Surely a bug.', null, 'errors');
}
if (!$errorforline) {
diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php
index 9e46433c5d7..2e8e68526db 100644
--- a/htdocs/accountancy/journal/expensereportsjournal.php
+++ b/htdocs/accountancy/journal/expensereportsjournal.php
@@ -392,7 +392,7 @@ if ($action == 'writebookkeeping') {
if (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT')) {
$error++;
$errorforline++;
- setEventMessages('Try to insert a non balanced transaction in book for '.$val["ref"].'. Canceled. Surely a bug.', null, 'errors');
+ setEventMessages('We tried to insert a non balanced transaction in book for '.$val["ref"].'. Canceled. Surely a bug.', null, 'errors');
}
if (!$errorforline) {
@@ -481,6 +481,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
print "\n";
}
}
+
// VAT
foreach ($tabtva[$key] as $k => $mt) {
if ($mt) {
diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php
index 844bbf392c2..1fd982f3567 100644
--- a/htdocs/accountancy/journal/purchasesjournal.php
+++ b/htdocs/accountancy/journal/purchasesjournal.php
@@ -72,6 +72,8 @@ if (!$user->hasRight('accounting', 'mouvements', 'lire')) {
accessforbidden();
}
+$error = 0;
+
/*
* Actions
@@ -182,6 +184,7 @@ if ($result) {
$tabrctva = array();
$tabrclocaltax1 = array();
$tabrclocaltax2 = array();
+ $vatdata_cache = array();
$num = $db->num_rows($result);
@@ -208,7 +211,13 @@ if ($result) {
}
}
- $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), $mysoc, $mysoc, 0);
+ $tax_id = $obj->tva_tx . ($obj->vat_src_code ? ' (' . $obj->vat_src_code . ')' : '');
+ if (array_key_exists($tax_id, $vatdata_cache)) {
+ $vatdata = $vatdata_cache[$tax_id];
+ } else {
+ $vatdata = getTaxesFromId($tax_id, $mysoc, $mysoc, 0);
+ $vatdata_cache[$tax_id] = $vatdata;
+ }
$compta_tva = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
$compta_localtax1 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
$compta_localtax2 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
@@ -318,8 +327,16 @@ if ($result) {
dol_print_error($db);
}
+// Check for too many invoices first.
+if (count($tabfac) > 10000) { // Global config in htdocs/admin/const.php???
+ $error++;
+ setEventMessages("TooManyInvoicesToProcessPleaseUseAMoreSelectiveFilter", null, 'errors');
+}
+
$errorforinvoice = array();
+/*
+// Old way, 1 query for each invoice
// Loop in invoices to detect lines with not binding lines
foreach ($tabfac as $key => $val) { // Loop on each invoice
$sql = "SELECT COUNT(fd.rowid) as nb";
@@ -336,12 +353,38 @@ foreach ($tabfac as $key => $val) { // Loop on each invoice
dol_print_error($db);
}
}
+*/
+// New way, single query, load all unbound lines
+$sql = "
+SELECT
+ fk_facture_fourn,
+ COUNT(fd.rowid) as nb
+FROM
+ llx_facture_fourn_det as fd
+WHERE
+ fd.product_type <= 2
+ AND fd.fk_code_ventilation <= 0
+ AND fd.total_ttc <> 0
+ AND fk_facture_fourn IN (".$db->sanitize(join(",", array_keys($tabfac))).")
+GROUP BY fk_facture_fourn
+";
+$resql = $db->query($sql);
+
+$num = $db->num_rows($resql);
+$i = 0;
+while ($i < $num) {
+ $obj = $db->fetch_object($resql);
+ if ($obj->nb > 0) {
+ $errorforinvoice[$obj->fk_facture_fourn] = 'somelinesarenotbound';
+ }
+ $i++;
+}
//var_dump($errorforinvoice);exit;
// Bookkeeping Write
-if ($action == 'writebookkeeping') {
+if ($action == 'writebookkeeping' && !$error) {
$now = dol_now();
$error = 0;
@@ -663,7 +706,7 @@ if ($action == 'writebookkeeping') {
$error++;
$errorforline++;
$errorforinvoice[$key] = 'amountsnotbalanced';
- setEventMessages('Try to insert a non balanced transaction in book for '.$invoicestatic->ref.'. Canceled. Surely a bug.', null, 'errors');
+ setEventMessages('We tried to insert a non balanced transaction in book for '.$invoicestatic->ref.'. Canceled. Surely a bug.', null, 'errors');
}
if (!$errorforline) {
@@ -712,7 +755,7 @@ if ($action == 'writebookkeeping') {
$form = new Form($db);
// Export
-if ($action == 'exportcsv') { // ISO and not UTF8 !
+if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
$sep = getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV');
$filename = 'journal';
@@ -1139,7 +1182,7 @@ if (empty($action) || $action == 'view') {
print "";
$accountoshow = length_accountg($k);
if (($accountoshow == "") || $accountoshow == 'NotDefined') {
- print ''.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("Purchase").') ';
+ print ''.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("AccountingJournalType3").') ';
} else {
print $accountoshow;
}
diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php
index 51732a5db04..f87c020ce3b 100644
--- a/htdocs/accountancy/journal/sellsjournal.php
+++ b/htdocs/accountancy/journal/sellsjournal.php
@@ -74,6 +74,8 @@ if (!$user->hasRight('accounting', 'mouvements', 'lire')) {
accessforbidden();
}
+$error = 0;
+
/*
* Actions
@@ -109,7 +111,7 @@ if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
}
-$sql = "SELECT f.rowid, f.ref, f.type, f.situation_cycle_ref, f.datef as df, f.ref_client, f.date_lim_reglement as dlr, f.close_code, f.retained_warranty,";
+$sql = "SELECT f.rowid, f.ref, f.type, f.situation_cycle_ref, f.datef as df, f.ref_client, f.date_lim_reglement as dlr, f.close_code, f.retained_warranty, f.revenuestamp,";
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code, fd.info_bits,";
$sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur,";
if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
@@ -125,6 +127,9 @@ if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
} else {
$sql .= " p.accountancy_code_sell";
}
+$parameters = array();
+$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
+$sql .= $hookmanager->resPrint;
$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product";
if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
@@ -136,6 +141,9 @@ $sql .= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
}
+$parameters = array();
+$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters); // Note that $action and $object may have been modified by hook
+$sql .= $hookmanager->resPrint;
$sql .= " WHERE fd.fk_code_ventilation > 0";
$sql .= " AND f.entity IN (".getEntity('invoice', 0).')'; // We don't share object for accountancy, we use source object sharing
$sql .= " AND f.fk_statut > 0";
@@ -161,8 +169,11 @@ if ($in_bookkeeping == 'notyet') {
$sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
// $sql .= " AND fd.rowid NOT IN (SELECT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; // Useless, we save one line for all products with same account
}
+$parameters = array();
+$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
+$sql .= $hookmanager->resPrint;
$sql .= " ORDER BY f.datef, f.ref";
-//print $sql; exit;
+//print $sql;
dol_syslog('accountancy/journal/sellsjournal.php', LOG_DEBUG);
$result = $db->query($sql);
@@ -172,10 +183,12 @@ if ($result) {
$tabtva = array();
$def_tva = array();
$tabwarranty = array();
+ $tabrevenuestamp = array();
$tabttc = array();
$tablocaltax1 = array();
$tablocaltax2 = array();
$tabcompany = array();
+ $vatdata_cache = array();
$num = $db->num_rows($result);
@@ -199,17 +212,25 @@ if ($result) {
}
}
- $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), $mysoc, $mysoc, 0);
+ //$compta_revenuestamp = getDolGlobalString('ACCOUNTING_REVENUESTAMP_SOLD_ACCOUNT', 'NotDefined');
+
+ $tax_id = $obj->tva_tx . ($obj->vat_src_code ? ' (' . $obj->vat_src_code . ')' : '');
+ if (array_key_exists($tax_id, $vatdata_cache)) {
+ $vatdata = $vatdata_cache[$tax_id];
+ } else {
+ $vatdata = getTaxesFromId($tax_id, $mysoc, $mysoc, 0);
+ $vatdata_cache[$tax_id] = $vatdata;
+ }
$compta_tva = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
$compta_localtax1 = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
$compta_localtax2 = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
- // Define array to display all VAT rates that use this accounting account $compta_tva
+ // Define the array to store the detail of each vat rate and code for lines
if (price2num($obj->tva_tx) || !empty($obj->vat_src_code)) {
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')] = (vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''));
}
- // Create a compensation rate.
+ // Create a compensation rate for situation invoice.
$situation_ratio = 1;
if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
if ($obj->situation_cycle_ref) {
@@ -228,6 +249,8 @@ if ($result) {
}
}
+ $revenuestamp = (double) price2num($obj->revenuestamp, 'MT');
+
// Invoice lines
$tabfac[$obj->rowid]["date"] = $db->jdate($obj->df);
$tabfac[$obj->rowid]["datereg"] = $db->jdate($obj->dlr);
@@ -235,6 +258,7 @@ if ($result) {
$tabfac[$obj->rowid]["type"] = $obj->type;
$tabfac[$obj->rowid]["description"] = $obj->label_compte;
$tabfac[$obj->rowid]["close_code"] = $obj->close_code; // close_code = 'replaced' for replacement invoices (not used in most european countries)
+ $tabfac[$obj->rowid]["revenuestamp"] = $revenuestamp;
//$tabfac[$obj->rowid]["fk_facturedet"] = $obj->fdid;
// Avoid warnings
@@ -259,12 +283,19 @@ if ($result) {
// real data we should have stored and result obtained with a compensation.
// It also seems that credit notes on situation invoices are correctly saved (but it depends on the version used in fact).
// For credit notes, we hope to have situation_ratio = 1 so the compensation has no effect to avoid introducing troubles with credit notes.
- $total_ttc = $obj->total_ttc * $situation_ratio;
+ if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
+ $total_ttc = $obj->total_ttc * $situation_ratio;
+ } else {
+ $total_ttc = $obj->total_ttc;
+ }
+
+ // Move a part of the retained warrenty into the account of warranty
if (getDolGlobalString('INVOICE_USE_RETAINED_WARRANTY') && $obj->retained_warranty > 0) {
- $retained_warranty = (double) price2num($total_ttc * $obj->retained_warranty / 100, 'MT');
+ $retained_warranty = (double) price2num($total_ttc * $obj->retained_warranty / 100, 'MT'); // Calculate the amount of warrenty for this line (using the percent value)
$tabwarranty[$obj->rowid][$compta_soc] += $retained_warranty;
$total_ttc -= $retained_warranty;
}
+
$tabttc[$obj->rowid][$compta_soc] += $total_ttc;
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio;
$tva_npr = (($obj->info_bits & 1 == 1) ? 1 : 0);
@@ -274,6 +305,32 @@ if ($result) {
$tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1 * $situation_ratio;
$tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2 * $situation_ratio;
+ $compta_revenuestamp = 'NotDefined';
+ if (!empty($revenuestamp)) {
+ $sqlrevenuestamp = "SELECT accountancy_code_sell FROM ".MAIN_DB_PREFIX."c_revenuestamp";
+ $sqlrevenuestamp .= " WHERE fk_pays = ".((int) $mysoc->country_id);
+ $sqlrevenuestamp .= " AND taux = ".((double) $revenuestamp);
+ $sqlrevenuestamp .= " AND active = 1";
+ $resqlrevenuestamp = $db->query($sqlrevenuestamp);
+
+ if ($resqlrevenuestamp) {
+ $num_rows_revenuestamp = $db->num_rows($resqlrevenuestamp);
+ if ($num_rows_revenuestamp > 1) {
+ dol_print_error($db, 'Failed 2 or more lines for the revenue stamp of your country. Check the dictionary of revenue stamp.');
+ } else {
+ $objrevenuestamp = $db->fetch_object($resqlrevenuestamp);
+ if ($objrevenuestamp) {
+ $compta_revenuestamp = $objrevenuestamp->accountancy_code_sell;
+ }
+ }
+ }
+ }
+
+ if (empty($tabrevenuestamp[$obj->rowid][$compta_revenuestamp]) && !empty($revenuestamp)) {
+ // The revenue stamp was never seen for this invoice id=$obj->rowid
+ $tabttc[$obj->rowid][$compta_soc] += $obj->revenuestamp;
+ $tabrevenuestamp[$obj->rowid][$compta_revenuestamp] = $obj->revenuestamp;
+ }
$tabcompany[$obj->rowid] = array(
'id' => $obj->socid,
@@ -284,13 +341,23 @@ if ($result) {
$i++;
}
+
+ // After the loop on each line
} else {
dol_print_error($db);
}
+// Check for too many invoices first.
+if (count($tabfac) > 10000) {
+ $error++;
+ setEventMessages("TooManyInvoicesToProcessPleaseUseAMoreSelectiveFilter", null, 'errors');
+}
+
$errorforinvoice = array();
-// Loop in invoices to detect lines with not binding lines
+/*
+// Old way, 1 query for each invoice
+// Loop on all invoices to detect lines without binded code (fk_code_ventilation <= 0)
foreach ($tabfac as $key => $val) { // Loop on each invoice
$sql = "SELECT COUNT(fd.rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd";
@@ -306,11 +373,37 @@ foreach ($tabfac as $key => $val) { // Loop on each invoice
dol_print_error($db);
}
}
+*/
+// New way, single query, load all unbound lines
+
+$sql = "
+SELECT
+ fk_facture,
+ COUNT(fd.rowid) as nb
+FROM
+ ".MAIN_DB_PREFIX."facturedet as fd
+WHERE
+ fd.product_type <= 2
+ AND fd.fk_code_ventilation <= 0
+ AND fd.total_ttc <> 0
+ AND fk_facture IN (".$db->sanitize(join(",", array_keys($tabfac))).")
+GROUP BY fk_facture
+";
+$resql = $db->query($sql);
+
+$num = $db->num_rows($resql);
+$i = 0;
+while ($i < $num) {
+ $obj = $db->fetch_object($resql);
+ if ($obj->nb > 0) {
+ $errorforinvoice[$obj->fk_facture_fourn] = 'somelinesarenotbound';
+ }
+ $i++;
+}
//var_dump($errorforinvoice);exit;
-
// Bookkeeping Write
-if ($action == 'writebookkeeping') {
+if ($action == 'writebookkeeping' && !$error) {
$now = dol_now();
$error = 0;
@@ -335,6 +428,7 @@ if ($action == 'writebookkeeping') {
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->code_compta = $tabcompany[$key]['code_compta'];
+ $companystatic->code_compta_client = $tabcompany[$key]['code_compta'];
$companystatic->code_client = $tabcompany[$key]['code_client'];
$companystatic->client = 3;
@@ -603,12 +697,66 @@ if ($action == 'writebookkeeping') {
}
}
+ // Revenue stamp
+ if (!$errorforline) {
+ foreach ($tabrevenuestamp[$key] as $k => $mt) {
+ if ($mt) {
+ $accountingaccount->fetch(null, $k, true); // TODO Use a cache for label
+ $label_account = $accountingaccount->label;
+
+ $bookkeeping = new BookKeeping($db);
+ $bookkeeping->doc_date = $val["date"];
+ $bookkeeping->date_lim_reglement = $val["datereg"];
+ $bookkeeping->doc_ref = $val["ref"];
+ $bookkeeping->date_creation = $now;
+ $bookkeeping->doc_type = 'customer_invoice';
+ $bookkeeping->fk_doc = $key;
+ $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
+ $bookkeeping->thirdparty_code = $companystatic->code_client;
+
+ $bookkeeping->subledger_account = '';
+ $bookkeeping->subledger_label = '';
+
+ $bookkeeping->numero_compte = $k;
+ $bookkeeping->label_compte = $label_account;
+
+ $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$langs->trans("RevenueStamp");
+ $bookkeeping->montant = $mt;
+ $bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
+ $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
+ $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
+ $bookkeeping->code_journal = $journal;
+ $bookkeeping->journal_label = $langs->transnoentities($journal_label);
+ $bookkeeping->fk_user_author = $user->id;
+ $bookkeeping->entity = $conf->entity;
+
+ $totaldebit += $bookkeeping->debit;
+ $totalcredit += $bookkeeping->credit;
+
+ $result = $bookkeeping->create($user);
+ if ($result < 0) {
+ if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists
+ $error++;
+ $errorforline++;
+ $errorforinvoice[$key] = 'alreadyjournalized';
+ //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
+ } else {
+ $error++;
+ $errorforline++;
+ $errorforinvoice[$key] = 'other';
+ setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
+ }
+ }
+ }
+ }
+ }
+
// Protection against a bug on lines before
if (!$errorforline && (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT'))) {
$error++;
$errorforline++;
$errorforinvoice[$key] = 'amountsnotbalanced';
- setEventMessages('Try to insert a non balanced transaction in book for '.$invoicestatic->ref.'. Canceled. Surely a bug.', null, 'errors');
+ setEventMessages('We Tried to insert a non balanced transaction in book for '.$invoicestatic->ref.'. Canceled. Surely a bug.', null, 'errors');
}
if (!$errorforline) {
@@ -659,7 +807,8 @@ if ($action == 'writebookkeeping') {
$form = new Form($db);
// Export
-if ($action == 'exportcsv') { // ISO and not UTF8 !
+if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
+ // Note that to have the button to get this feature enabled, you must enable ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL
$sep = getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV');
$filename = 'journal';
@@ -787,6 +936,25 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
}
}
}
+
+ // Revenue stamp
+ foreach ($tabrevenuestamp[$key] as $k => $mt) {
+ //if ($mt) {
+ print '"'.$key.'"'.$sep;
+ print '"'.$date.'"'.$sep;
+ print '"'.$val["ref"].'"'.$sep;
+ print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep;
+ print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
+ print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
+ print '""'.$sep;
+ print '"'.$langs->trans("RevenueStamp").'"'.$sep;
+ print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("RevenueStamp").'"'.$sep;
+ print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
+ print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
+ print '"'.$journal.'"';
+ print "\n";
+ //}
+ }
}
}
@@ -883,6 +1051,7 @@ if (empty($action) || $action == 'view') {
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->code_compta = $tabcompany[$key]['code_compta'];
+ $companystatic->code_compta_client = $tabcompany[$key]['code_compta'];
$companystatic->code_client = $tabcompany[$key]['code_client'];
$companystatic->client = 3;
@@ -956,7 +1125,7 @@ if (empty($action) || $action == 'view') {
print " ";
$accountoshow = length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY'));
if (($accountoshow == "") || $accountoshow == 'NotDefined') {
- print ''.$langs->trans("MainAccountForCustomersNotDefined").' ';
+ print ''.$langs->trans("MainAccountForRetainedWarrantyNotDefined").' ';
} else {
print $accountoshow;
}
@@ -1067,7 +1236,7 @@ if (empty($action) || $action == 'view') {
print " ";
$accountoshow = length_accountg($k);
if (($accountoshow == "") || $accountoshow == 'NotDefined') {
- print ''.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("Sale").') ';
+ print ''.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("AccountingJournalType2").') ';
} else {
print $accountoshow;
}
@@ -1085,6 +1254,30 @@ if (empty($action) || $action == 'view') {
}
}
}
+
+ // Warranty
+ foreach ($tabrevenuestamp[$key] as $k => $mt) {
+ print ' ';
+ print "";
+ print "".$date." ";
+ print "".$invoicestatic->getNomUrl(1)." ";
+ // Account
+ print "";
+ $accountoshow = length_accountg($k);
+ if (($accountoshow == "") || $accountoshow == 'NotDefined') {
+ print ''.$langs->trans("MainAccountForRevenueStampSaleNotDefined").' ';
+ } else {
+ print $accountoshow;
+ }
+ print ' ';
+ // Subledger account
+ print "";
+ print ' ';
+ print "".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref.' - '.$langs->trans("RevenueStamp")." ";
+ print ''.($mt < 0 ? price(-$mt) : '')." ";
+ print ''.($mt >= 0 ? price($mt) : '')." ";
+ print " ";
+ }
}
if (!$i) {
diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php
index 0bc4aeed29c..a750fd2bba6 100644
--- a/htdocs/adherents/card.php
+++ b/htdocs/adherents/card.php
@@ -463,10 +463,6 @@ if (empty($reshook)) {
$phone = GETPOST("phone", 'alpha');
$phone_perso = GETPOST("phone_perso", 'alpha');
$phone_mobile = GETPOST("phone_mobile", 'alpha');
- // $skype=GETPOST("member_skype", 'alpha');
- // $twitter=GETPOST("member_twitter", 'alpha');
- // $facebook=GETPOST("member_facebook", 'alpha');
- // $linkedin=GETPOST("member_linkedin", 'alpha');
$email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha'));
$url = trim(GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL));
$login = GETPOST("member_login", 'alphanohtml');
diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php
index 151480533db..9b6dd8b9468 100644
--- a/htdocs/adherents/class/adherent.class.php
+++ b/htdocs/adherents/class/adherent.class.php
@@ -426,7 +426,7 @@ class Adherent extends CommonObject
// Envoi mail confirmation
$from = $conf->email_from;
- if (!empty(getDolGlobalString('ADHERENT_MAIL_FROM'))) {
+ if (getDolGlobalString('ADHERENT_MAIL_FROM')) {
$from = getDolGlobalString('ADHERENT_MAIL_FROM');
}
@@ -1182,7 +1182,7 @@ class Adherent extends CommonObject
if ($result >= 0) {
$result = $luser->setPassword($user, $this->pass, 0, 0, 1);
- if (is_numeric($result) && $result < 0) {
+ if (is_int($result) && $result < 0) {
$this->error = $luser->error;
dol_syslog(get_class($this)."::setPassword ".$this->error, LOG_ERR);
$error++;
@@ -2314,7 +2314,7 @@ class Adherent extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php
index 44b2fb349d6..7d7adaa2d93 100644
--- a/htdocs/adherents/class/adherent_type.class.php
+++ b/htdocs/adherents/class/adherent_type.class.php
@@ -759,7 +759,7 @@ class AdherentType extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php
index 7f130d70b62..fb394afbf3e 100644
--- a/htdocs/adherents/class/subscription.class.php
+++ b/htdocs/adherents/class/subscription.class.php
@@ -429,7 +429,7 @@ class Subscription extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php
index c8857748294..7d201cd2625 100644
--- a/htdocs/adherents/type.php
+++ b/htdocs/adherents/type.php
@@ -252,7 +252,7 @@ $arrayofselected = is_array($toselect) ? $toselect : array();
if (!$rowid && $action != 'create' && $action != 'edit') {
//print dol_get_fiche_head('');
- $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.amount, d.caneditamount, d.vote, d.statut as status, d.morphy";
+ $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.amount, d.caneditamount, d.vote, d.statut as status, d.morphy, d.duration";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
$sql .= " WHERE d.entity IN (".getEntity('member_type').")";
@@ -309,6 +309,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
print ''.$langs->trans("Ref").' ';
print ''.$langs->trans("Label").' ';
print ''.$langs->trans("MembersNature").' ';
+ print ''.$langs->trans("MembershipDuration").' ';
print ''.$langs->trans("SubscriptionRequired").' ';
print ''.$langs->trans("Amount").' ';
print ''.$langs->trans("CanEditAmountShort").' ';
@@ -372,6 +373,18 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
print $langs->trans("MorAndPhy");
}
print '';
+ print '';
+ if ($objp->duration) {
+ $duration_value = intval($objp->duration);
+ if ($duration_value > 1) {
+ $dur = array("i"=>$langs->trans("Minutes"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years"));
+ } else {
+ $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year"));
+ }
+ $unit = preg_replace("/[^a-zA-Z]+/", "", $objp->duration);
+ print max(1, $duration_value).' '.$dur[$unit];
+ }
+ print ' ';
print ''.yn($objp->subscription).' ';
print ''.(is_null($objp->amount) || $objp->amount === '' ? '' : price($objp->amount)).' ';
print ''.yn($objp->caneditamount).' ';
diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php
index ef365881feb..afd0540cca3 100644
--- a/htdocs/admin/bank.php
+++ b/htdocs/admin/bank.php
@@ -243,7 +243,7 @@ while ($i < $nbofbank) {
}
print "\n";
- if ($conf->global->BANK_SHOW_ORDER_OPTION == $i) {
+ if (getDolGlobalInt('BANK_SHOW_ORDER_OPTION') == $i) {
print '';
print img_picto($langs->trans("Activated"), 'on');
print ' ';
@@ -415,7 +415,7 @@ print '';
print $langs->trans('BankColorizeMovementDesc');
print " ";
// Active
-if ($conf->global->BANK_COLORIZE_MOVEMENT) {
+if (getDolGlobalInt('BANK_COLORIZE_MOVEMENT')) {
print ''."\n";
print '';
print img_picto($langs->trans("Enabled"), 'switch_on');
@@ -429,7 +429,7 @@ if ($conf->global->BANK_COLORIZE_MOVEMENT) {
print " \n";
-if (!empty($conf->global->BANK_COLORIZE_MOVEMENT)) {
+if (getDolGlobalInt('BANK_COLORIZE_MOVEMENT')) {
$i = 1;
while ($i <= 2) {
$key = $i;
@@ -471,7 +471,7 @@ print "\n";
print $langs->trans('AutoReportLastAccountStatement');
print ' ';
// Active
-if ($conf->global->BANK_REPORT_LAST_NUM_RELEVE) {
+if (getDolGlobalString('BANK_REPORT_LAST_NUM_RELEVE')) {
print ''."\n";
print '';
print img_picto($langs->trans("Enabled"), 'switch_on');
@@ -482,8 +482,18 @@ if ($conf->global->BANK_REPORT_LAST_NUM_RELEVE) {
print ' '.img_picto($langs->trans("Disabled"), 'switch_off').' ';
print " ";
}
-
print " \n";
+
+// Allow SEPA Mandate OnLine Sign
+if (!getDolGlobalInt('SOCIETE_DISABLE_BANKACCOUNT')) {
+ print '';
+ print ''.$langs->trans("AllowOnLineSign").' '.$langs->trans("BankAccountModelModule").' ';
+ print '';
+ print ajax_constantonoff('SOCIETE_RIB_ALLOW_ONLINESIGN', array(), null, 0, 0, 0, 2, 0, 1);
+ print ' ';
+}
+
+
print '
';
print dol_get_fiche_end();
diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php
index d40b4d7b61f..7223a7d5c57 100644
--- a/htdocs/admin/contract.php
+++ b/htdocs/admin/contract.php
@@ -475,7 +475,7 @@ print '';
print '
';
print '';
print ''.$langs->trans("Parameter").' ';
-print ''.$langs->trans("Value").' ';
+print ''.$langs->trans("Value").' ';
print " \n";
$substitutionarray = pdf_getSubstitutionArray($langs, array('objectamount'), null, 2);
@@ -503,13 +503,13 @@ print ''."\n";
print '';
print $form->textwithpicto($langs->trans("WatermarkOnDraftContractCards"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').' ';
-print ' ';
+print ' ';
print ' ';
print ' '."\n";
print '';
print ''.$langs->trans("HideClosedServiceByDefault").' ';
-print '';
+print ' ';
print $form->selectyesno("activate_hideClosedServiceByDefault", (!empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) ? $conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT : 0), 1);
print ' ';
print ' ';
@@ -517,7 +517,7 @@ print '';
// Allow online signing
print '';
print ''.$langs->trans("AllowOnlineSign").' ';
-print '';
+print ' ';
if (getDolGlobalString('CONTRACT_ALLOW_ONLINESIGN')) {
print '';
print img_picto($langs->trans("Activited"), 'switch_on');
@@ -533,7 +533,7 @@ print ' ';
// Allow external download
print '';
print ''.$langs->trans("AllowExternalDownload").' ';
-print '';
+print ' ';
print ajax_constantonoff('CONTRACT_ALLOW_EXTERNAL_DOWNLOAD', array(), null, 0, 0, 0, 2, 0, 1);
print ' ';
print ' ';
diff --git a/htdocs/admin/dav.php b/htdocs/admin/dav.php
index 66df8bd59f1..e72b87ff7f6 100644
--- a/htdocs/admin/dav.php
+++ b/htdocs/admin/dav.php
@@ -189,7 +189,7 @@ $message .= '';
$message .= ajax_autoselect('webdavpublicurl');
$message .= ' ';
-if (!empty(getDolGlobalString('DAV_ALLOW_PUBLIC_DIR'))) {
+if (getDolGlobalString('DAV_ALLOW_PUBLIC_DIR')) {
$urlEntity = (isModEnabled('multicompany') ? '?entity=' . $conf->entity : '');
$url = '' . $urlwithroot . '/dav/fileserver.php/public/' . $urlEntity . ' ';
diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index 23ff091072c..7dac8f9d440 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -54,6 +54,38 @@ $rowid = GETPOST('rowid', 'alpha');
$entity = GETPOST('entity', 'int');
$code = GETPOST('code', 'alpha');
+$acts = array(); $actl = array();
+$acts[0] = "activate";
+$acts[1] = "disable";
+$actl[0] = img_picto($langs->trans("Disabled"), 'switch_off', 'class="size15x"');
+$actl[1] = img_picto($langs->trans("Activated"), 'switch_on', 'class="size15x"');
+
+// Load variable for pagination
+$listoffset = GETPOST('listoffset');
+$listlimit = GETPOST('listlimit') > 0 ?GETPOST('listlimit') : 1000; // To avoid too long dictionaries
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
+if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
+ // If $page is not defined, or '' or -1 or if we click on clear filters
+ $page = 0;
+}
+$offset = $listlimit * $page;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+
+$search_country_id = GETPOST('search_country_id', 'int');
+$search_code = GETPOST('search_code', 'alpha');
+$search_active = GETPOST('search_active', 'alpha');
+
+// Special case to set a default value for country according to dictionary
+if (!GETPOSTISSET('search_country_id') && $search_country_id == '' && ($id == 2 || $id == 3 || $id == 10)) { // Not a so good idea to force on current country for all dictionaries. Some tables have entries that are for all countries, we must be able to see them, so this is done for dedicated dictionaries only.
+ $search_country_id = $mysoc->country_id;
+}
+
+// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
+$hookmanager->initHooks(array('admin', 'dictionaryadmin'));
+
$allowed = $user->admin;
if ($id == 7 && $user->hasRight('accounting', 'chartofaccount')) {
$allowed = 1; // Tax page allowed to manager of chart account
@@ -68,34 +100,8 @@ if (!$allowed) {
accessforbidden();
}
-$acts = array(); $actl = array();
-$acts[0] = "activate";
-$acts[1] = "disable";
-$actl[0] = img_picto($langs->trans("Disabled"), 'switch_off', 'class="size15x"');
-$actl[1] = img_picto($langs->trans("Activated"), 'switch_on', 'class="size15x"');
+$permissiontoadd = $allowed;
-$listoffset = GETPOST('listoffset');
-$listlimit = GETPOST('listlimit') > 0 ?GETPOST('listlimit') : 1000; // To avoid too long dictionaries
-$active = 1;
-
-$sortfield = GETPOST('sortfield', 'aZ09comma');
-$sortorder = GETPOST('sortorder', 'aZ09comma');
-$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
-if (empty($page) || $page == -1) {
- $page = 0;
-} // If $page is not defined, or '' or -1
-$offset = $listlimit * $page;
-$pageprev = $page - 1;
-$pagenext = $page + 1;
-
-$search_country_id = GETPOST('search_country_id', 'int');
-if (!GETPOSTISSET('search_country_id') && $search_country_id == '' && ($id == 2 || $id == 3 || $id == 10)) { // Not a so good idea to force on current country for all dictionaries. Some tables have entries that are for all countries, we must be able to see them, so this is done for dedicated dictionaries only.
- $search_country_id = $mysoc->country_id;
-}
-$search_code = GETPOST('search_code', 'alpha');
-
-// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
-$hookmanager->initHooks(array('admin', 'dictionaryadmin'));
// This page is a generic page to edit dictionaries
// Put here declaration of dictionaries properties
@@ -201,7 +207,7 @@ $tablib[44] = "DictionaryAssetDisposalType";
$tabsql = array();
$tabsql[1] = "SELECT f.rowid as rowid, f.code, f.libelle, c.code as country_code, c.label as country, f.active FROM ".MAIN_DB_PREFIX."c_forme_juridique as f, ".MAIN_DB_PREFIX."c_country as c WHERE f.fk_pays=c.rowid";
$tabsql[2] = "SELECT d.rowid as rowid, d.code_departement as code, d.nom as libelle, d.fk_region as region_id, r.nom as region, c.code as country_code, c.label as country, d.active FROM ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid and r.active=1 and c.active=1";
-$tabsql[3] = "SELECT r.rowid as rowid, r.code_region as state_code, r.nom as libelle, r.fk_pays as country_id, c.code as country_code, c.label as country, r.active FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE r.fk_pays=c.rowid and c.active=1";
+$tabsql[3] = "SELECT r.rowid as rowid, r.code_region as code, r.nom as libelle, r.fk_pays as country_id, c.code as country_code, c.label as country, r.active FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE r.fk_pays=c.rowid and c.active=1";
$tabsql[4] = "SELECT c.rowid as rowid, c.code, c.label, c.active, c.favorite, c.eec FROM ".MAIN_DB_PREFIX."c_country AS c";
$tabsql[5] = "SELECT c.rowid as rowid, c.code as code, c.label, c.active FROM ".MAIN_DB_PREFIX."c_civility AS c";
$tabsql[6] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.type, a.active, a.module, a.color, a.position FROM ".MAIN_DB_PREFIX."c_actioncomm AS a";
@@ -670,6 +676,7 @@ $localtax_typeList = array(
);
+
/*
* Actions
*/
@@ -702,6 +709,7 @@ if ($reshook < 0) {
if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) {
$search_country_id = '';
$search_code = '';
+ $search_active = '';
}
if (empty($reshook)) {
@@ -746,9 +754,9 @@ if (empty($reshook)) {
&& ($id != 10 || ($value != 'code' && $value != 'note')) // Field code and note is not mandatory for dictionary table 10
)
) {
- $ok = 0;
- $fieldnamekey = $value;
- // We take translate key of field
+ $ok = 0;
+ $fieldnamekey = $value;
+ // We take translate key of field
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) {
$fieldnamekey = 'Label';
}
@@ -823,7 +831,7 @@ if (empty($reshook)) {
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Country")), null, 'errors');
}
}
- if (($id == 3 || $id == 42) && !is_numeric(GETPOST("code"))) {
+ if (($id == 3 || $id == 42) && !is_numeric(GETPOST("code")) && GETPOST('actionadd')) {
$ok = 0;
setEventMessages($langs->transnoentities("ErrorFieldMustBeANumeric", $langs->transnoentities("Code")), null, 'errors');
}
@@ -998,6 +1006,13 @@ if (empty($reshook)) {
setEventMessages($db->error(), null, 'errors');
}
}
+
+ if (!$ok && GETPOST('actionadd')) {
+ $action = 'create';
+ }
+ if (!$ok && GETPOST('actionmodify')) {
+ $action = 'edit';
+ }
}
if ($action == 'confirm_delete' && $confirm == 'yes') { // delete
@@ -1168,7 +1183,6 @@ if (empty($reshook)) {
*/
$form = new Form($db);
-$formadmin = new FormAdmin($db);
$title = $langs->trans("DictionarySetup");
@@ -1189,22 +1203,16 @@ if ($id == 7 && GETPOST('from') == 'accountancy') {
$titlepicto = 'accountancy';
}
-print load_fiche_titre($title, $linkback, $titlepicto);
-
-if (empty($id)) {
- print ''.$langs->trans("DictionaryDesc");
- print " ".$langs->trans("OnlyActiveElementsAreShown")." \n";
- print ' ';
-}
-
-
$param = '&id='.urlencode($id);
-if ($search_country_id > 0) {
- $param .= '&search_country_id='.urlencode($search_country_id);
+if ($search_country_id || GETPOSTISSET('page') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) {
+ $param .= '&search_country_id='.urlencode($search_country_id ? $search_country_id : -1);
}
if ($search_code != '') {
$param .= '&search_code='.urlencode($search_code);
}
+if ($search_active != '') {
+ $param .= '&search_active='.urlencode($search_active);
+}
if ($entity != '') {
$param .= '&entity='.(int) $entity;
}
@@ -1225,37 +1233,55 @@ if ($action == 'delete') {
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'rowid='.urlencode($rowid).'&code='.urlencode($code).$paramwithsearch, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
}
-/*
- * Show a dictionary
- */
+// Show a dictionary
if ($id > 0) {
// Complete search values request with sort criteria
- $sql = $tabsql[$id];
+ $sqlfields = $tabsql[$id];
+ $tablecode = '';
+ $tableprefix = '';
+ $tableprefixarray = array(9 => 'code_iso', 28 => 'h.code', 7 => 'a.code', 32 => 'a.code', 3 => 'r.code_region', 8 => 't.code', 10 => 't.code', 1 => 'f.code', 2 => 'd.code_departement', 14 => 'e.code');
+ if (!empty($tableprefixarray[$id])) {
+ $tablecode = $tableprefixarray[$id];
+ $tableprefix = preg_replace('/\..*$/', '.', $tablecode);
+ }
+
+ $sql = $sqlfields;
if (!preg_match('/ WHERE /', $sql)) {
$sql .= " WHERE 1 = 1";
}
if ($search_country_id > 0) {
$sql .= " AND c.rowid = ".((int) $search_country_id);
}
- if ($search_code != '' && $id == 9) {
- $sql .= natural_search("code_iso", $search_code);
- } elseif ($search_code != '' && $id == 28) {
- $sql .= natural_search("h.code", $search_code);
- } elseif ($search_code != '' && ($id == 7 || $id == 32)) {
- $sql .= natural_search("a.code", $search_code);
- } elseif ($search_code != '' && $id == 3) {
- $sql .= natural_search("r.code_region", $search_code);
- } elseif ($search_code != '' && ($id == 8 || $id == 10)) {
- $sql .= natural_search("t.code", $search_code);
- } elseif ($search_code != '' && $id == 1) {
- $sql .= natural_search("f.code", $search_code);
- } elseif ($search_code != '' && $id == 2) {
- $sql .= natural_search("d.code_departement", $search_code);
- } elseif ($search_code != '' && $id == 14) {
- $sql .= natural_search("e.code", $search_code);
- } elseif ($search_code != '' && $id != 9) {
- $sql .= natural_search("code", $search_code);
+ if ($search_code != '') {
+ $sql .= natural_search($tablecode, $search_code);
+ }
+ if ($search_active == 'yes') {
+ $sql .= " AND ".$tableprefix."active = 1";
+ } elseif ($search_active == 'no') {
+ $sql .= " AND ".$tableprefix."active = 0";
+ }
+ //print $sql;
+
+ // Count total nb of records
+ $nbtotalofrecords = '';
+ if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
+ /* The fast and low memory method to get and count full list converts the sql into a sql count */
+ $sqlforcount = preg_replace('/^.*\sFROM\s/', 'SELECT COUNT(*) as nbtotalofrecords FROM ', $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);
+ }
+
+ if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
+ $page = 0;
+ $offset = 0;
+ }
+ $db->free($resql);
}
if ($sortfield) {
@@ -1272,7 +1298,16 @@ if ($id > 0) {
$sql .= " ORDER BY ";
}
$sql .= $tabsqlsort[$id];
+
$sql .= $db->plimit($listlimit + 1, $offset);
+
+ $resql = $db->query($sql);
+ if (!$resql) {
+ dol_print_error($db);
+ exit;
+ }
+ $num = $db->num_rows($resql);
+
//print $sql;
if (empty($tabfield[$id])) {
@@ -1285,327 +1320,12 @@ if ($id > 0) {
print ' ';
print ' ';
+ // Special warning for VAT dictionary
if ($id == 10 && empty($conf->global->FACTURE_TVAOPTION)) {
print info_admin($langs->trans("VATIsUsedIsOff", $langs->transnoentities("Setup"), $langs->transnoentities("CompanyFoundation")));
print " \n";
}
- // Form to add a new line
- if ($tabname[$id]) {
- $withentity = null;
-
- $fieldlist = explode(',', $tabfield[$id]);
-
- print '';
- print '
';
-
- // Line for title
- print '';
- $tdsoffields = '';
- foreach ($fieldlist as $field => $value) {
- if ($value == 'entity') {
- $withentity = getEntity($tabname[$id]);
- continue;
- }
-
- // Define field friendly name from its technical name
- $valuetoshow = ucfirst($value); // Par defaut
- $valuetoshow = $langs->trans($valuetoshow); // try to translate
- $class = '';
-
- if ($value == 'pos') {
- $valuetoshow = $langs->trans("Position"); $class = 'right';
- }
- if ($value == 'source') {
- $valuetoshow = $langs->trans("Contact");
- }
- if ($value == 'price') {
- $valuetoshow = $langs->trans("PriceUHT");
- }
- if ($value == 'taux') {
- if ($tabname[$id] != "c_revenuestamp") {
- $valuetoshow = $langs->trans("Rate");
- } else {
- $valuetoshow = $langs->trans("Amount");
- }
- $class = 'center';
- }
- if ($value == 'localtax1_type') {
- $valuetoshow = $langs->trans("UseLocalTax")." 2"; $class = "center"; $sortable = 0;
- }
- if ($value == 'localtax1') {
- $valuetoshow = $langs->trans("RateOfTaxN", '2'); $class = "center";
- }
- if ($value == 'localtax2_type') {
- $valuetoshow = $langs->trans("UseLocalTax")." 3"; $class = "center"; $sortable = 0;
- }
- if ($value == 'localtax2') {
- $valuetoshow = $langs->trans("RateOfTaxN", '3'); $class = "center";
- }
- if ($value == 'organization') {
- $valuetoshow = $langs->trans("Organization");
- }
- if ($value == 'lang') {
- $valuetoshow = $langs->trans("Language");
- }
- if ($value == 'type') {
- if ($tabname[$id] == "c_paiement") {
- $valuetoshow = $form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, ''));
- } else {
- $valuetoshow = $langs->trans("Type");
- }
- }
- if ($value == 'code') {
- $valuetoshow = $langs->trans("Code"); $class = 'maxwidth100';
- }
- if ($value == 'libelle' || $value == 'label') {
- $valuetoshow = $form->textwithtooltip($langs->trans("Label"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, ''));
- }
- if ($value == 'libelle_facture') {
- $valuetoshow = $form->textwithtooltip($langs->trans("LabelOnDocuments"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, ''));
- }
- if ($value == 'deposit_percent') {
- $valuetoshow = $langs->trans('DepositPercent');
- $class = 'right';
- }
- if ($value == 'country') {
- if (in_array('region_id', $fieldlist)) {
- print ' '; continue;
- } // For region page, we do not show the country input
- $valuetoshow = $langs->trans("Country");
- }
- if ($value == 'recuperableonly') {
- $valuetoshow = $langs->trans("NPR"); $class = "center";
- }
- if ($value == 'nbjour') {
- $valuetoshow = $langs->trans("NbOfDays");
- $class = 'right';
- }
- if ($value == 'type_cdr') {
- $valuetoshow = $langs->trans("AtEndOfMonth"); $class = "center";
- }
- if ($value == 'decalage') {
- $valuetoshow = $langs->trans("Offset");
- $class = 'right';
- }
- if ($value == 'width' || $value == 'nx') {
- $valuetoshow = $langs->trans("Width");
- }
- if ($value == 'height' || $value == 'ny') {
- $valuetoshow = $langs->trans("Height");
- }
- if ($value == 'unit' || $value == 'metric') {
- $valuetoshow = $langs->trans("MeasuringUnit");
- }
- if ($value == 'region_id' || $value == 'country_id') {
- $valuetoshow = '';
- }
- if ($value == 'accountancy_code') {
- $valuetoshow = $langs->trans("AccountancyCode");
- }
- if ($value == 'accountancy_code_sell') {
- $valuetoshow = $langs->trans("AccountancyCodeSell");
- }
- if ($value == 'accountancy_code_buy') {
- $valuetoshow = $langs->trans("AccountancyCodeBuy");
- }
- if ($value == 'pcg_version' || $value == 'fk_pcg_version') {
- $valuetoshow = $langs->trans("Pcg_version");
- }
- if ($value == 'account_parent') {
- $valuetoshow = $langs->trans("Accountparent");
- }
- if ($value == 'pcg_type') {
- $valuetoshow = $langs->trans("Pcg_type");
- }
- if ($value == 'pcg_subtype') {
- $valuetoshow = $langs->trans("Pcg_subtype");
- }
- if ($value == 'sortorder') {
- $valuetoshow = $langs->trans("SortOrder");
- $class = 'center';
- }
- if ($value == 'short_label') {
- $valuetoshow = $langs->trans("ShortLabel");
- }
- if ($value == 'fk_parent') {
- $valuetoshow = $langs->trans("ParentID"); $class = 'center';
- }
- if ($value == 'range_account') {
- $valuetoshow = $langs->trans("Range");
- }
- if ($value == 'sens') {
- $valuetoshow = $langs->trans("Sens");
- }
- if ($value == 'category_type') {
- $valuetoshow = $langs->trans("Calculated");
- }
- if ($value == 'formula') {
- $valuetoshow = $langs->trans("Formula");
- }
- if ($value == 'paper_size') {
- $valuetoshow = $langs->trans("PaperSize");
- }
- if ($value == 'orientation') {
- $valuetoshow = $langs->trans("Orientation");
- }
- if ($value == 'leftmargin') {
- $valuetoshow = $langs->trans("LeftMargin");
- }
- if ($value == 'topmargin') {
- $valuetoshow = $langs->trans("TopMargin");
- }
- if ($value == 'spacex') {
- $valuetoshow = $langs->trans("SpaceX");
- }
- if ($value == 'spacey') {
- $valuetoshow = $langs->trans("SpaceY");
- }
- if ($value == 'font_size') {
- $valuetoshow = $langs->trans("FontSize");
- }
- if ($value == 'custom_x') {
- $valuetoshow = $langs->trans("CustomX");
- }
- if ($value == 'custom_y') {
- $valuetoshow = $langs->trans("CustomY");
- }
- if ($value == 'percent') {
- $valuetoshow = $langs->trans("Percentage");
- }
- if ($value == 'affect') {
- $valuetoshow = $langs->trans("WithCounter");
- }
- if ($value == 'delay') {
- $valuetoshow = $langs->trans("NoticePeriod");
- }
- if ($value == 'newbymonth') {
- $valuetoshow = $langs->trans("NewByMonth");
- }
- if ($value == 'fk_tva') {
- $valuetoshow = $langs->trans("VAT");
- }
- if ($value == 'range_ik') {
- $valuetoshow = $langs->trans("RangeIk");
- }
- if ($value == 'fk_c_exp_tax_cat') {
- $valuetoshow = $langs->trans("CarCategory");
- }
- if ($value == 'revenuestamp_type') {
- $valuetoshow = $langs->trans('TypeOfRevenueStamp');
- }
- if ($value == 'use_default') {
- $valuetoshow = $langs->trans('Default'); $class = 'center';
- }
- if ($value == 'unit_type') {
- $valuetoshow = $langs->trans('TypeOfUnit');
- }
- if ($value == 'public' && $tablib[$id] == 'TicketDictCategory') {
- $valuetoshow = $langs->trans('TicketGroupIsPublic'); $class = 'center';
- }
- if ($value == 'block_if_negative') {
- $valuetoshow = $langs->trans('BlockHolidayIfNegative');
- }
- if ($value == 'type_duration') {
- $valuetoshow = $langs->trans('Unit');
- }
-
- if ($id == 2) { // Special case for state page
- if ($value == 'region_id') {
- $valuetoshow = ' '; $showfield = 1;
- }
- if ($value == 'region') {
- $valuetoshow = $langs->trans("Country").'/'.$langs->trans("Region"); $showfield = 1;
- }
- }
-
- if ($valuetoshow != '') {
- $tooltiphelp = (isset($tabcomplete[$tabname[$id]]['help'][$value]) ? $tabcomplete[$tabname[$id]]['help'][$value] : '');
-
- $tdsoffields .= '';
- if ($tooltiphelp && preg_match('/^http(s*):/i', $tooltiphelp)) {
- $tdsoffields .= ''.$valuetoshow.' '.img_help(1, $valuetoshow).' ';
- } elseif ($tooltiphelp) {
- $tdsoffields .= $form->textwithpicto($valuetoshow, $tooltiphelp);
- } else {
- $tdsoffields .= $valuetoshow;
- }
- $tdsoffields .= ' ';
- }
- }
-
- if ($id == 4) {
- $tdsoffields .= ' ';
- $tdsoffields .= ' ';
- }
- $tdsoffields .= '';
- $tdsoffields .= ' ';
- if (!is_null($withentity)) {
- $tdsoffields .= ' ';
- }
- $tdsoffields .= ' ';
- $tdsoffields .= ' ';
- $tdsoffields .= ' ';
- $tdsoffields .= ' ';
-
- print $tdsoffields;
-
-
- // Line to enter new values
- print '';
- print '';
-
- $obj = new stdClass();
- // If data was already input, we define them in obj to populate input fields.
- if (GETPOST('actionadd')) {
- foreach ($fieldlist as $key => $val) {
- if (GETPOST($val) != '') {
- $obj->$val = GETPOST($val);
- }
- }
- }
-
- $tmpaction = 'create';
- $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
- $reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
- $error = $hookmanager->error; $errors = $hookmanager->errors;
-
- if ($id == 3) {
- unset($fieldlist[2]); // Remove field ??? if dictionary Regions
- }
-
- if (empty($reshook)) {
- fieldList($fieldlist, $obj, $tabname[$id], 'add');
- }
-
- if ($id == 4) {
- print ' ';
- print ' ';
- }
- print '';
- if ($action != 'edit') {
- print ' ';
- } else {
- print ' ';
- }
- print ' ';
-
- print " ";
-
- print '
';
- print '
';
- }
-
- print '';
-
-
- print ' ';
-
-
- print '';
+
+ print '
';
print '
';
}
diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php
index 28d347bcabe..a6cb4ee62ca 100644
--- a/htdocs/admin/workflow.php
+++ b/htdocs/admin/workflow.php
@@ -153,20 +153,40 @@ $workflowcodes = array(
),
// Automatic classification shipping
+ /* Replaced by next option
'WORKFLOW_SHIPPING_CLASSIFY_CLOSED_INVOICE' => array(
'family' => 'classify_shipping',
'position' => 90,
'enabled' => isModEnabled("expedition") && isModEnabled("facture"),
+ 'picto' => 'shipment',
+ 'deprecated' => 1
+ ),
+ */
+
+ 'WORKFLOW_SHIPPING_CLASSIFY_BILLED_INVOICE' => array(
+ 'family' => 'classify_shipping',
+ 'position' => 91,
+ 'enabled' => isModEnabled("expedition") && isModEnabled("facture") && getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT') !== '0',
'picto' => 'shipment'
),
// Automatic classification reception
- 'WORKFLOW_EXPEDITION_CLASSIFY_CLOSED_INVOICE'=>array(
+ /*
+ 'WORKFLOW_RECEPTION_CLASSIFY_CLOSED_INVOICE'=>array(
'family'=>'classify_reception',
'position'=>95,
'enabled'=>(isModEnabled("reception") && (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))),
'picto'=>'reception'
),
+ */
+
+ 'WORKFLOW_RECEPTION_CLASSIFY_BILLED_INVOICE' => array(
+ 'family' => 'classify_reception',
+ 'position' => 91,
+ 'enabled' => isModEnabled("reception") && isModEnabled("supplier_invoice") && getDolGlobalString('WORKFLOW_BILL_ON_RECEPTION') !== '0',
+ 'picto' => 'shipment'
+ ),
+
'separator2'=>array('family'=>'separator', 'position'=>400, 'enabled' => (isModEnabled('ticket') && isModEnabled('contract'))),
@@ -284,6 +304,9 @@ foreach ($workflowcodes as $key => $params) {
if (!empty($params['warning'])) {
print ' '.img_warning($langs->transnoentitiesnoconv($params['warning']));
}
+ if (!empty($params['deprecated'])) {
+ print ' '.img_warning($langs->transnoentitiesnoconv("Deprecated"));
+ }
print ' ';
diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php
index b3db4e087fb..7f6c95e8d36 100644
--- a/htdocs/asset/class/asset.class.php
+++ b/htdocs/asset/class/asset.class.php
@@ -1313,7 +1313,7 @@ class Asset extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
@@ -1433,7 +1433,7 @@ class Asset extends CommonObject
// phpcs:enable
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
global $langs;
- //$langs->load("asset@asset");
+ //$langs->load("assets");
$this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('AssetInProgress');
$this->labelStatus[self::STATUS_DISPOSED] = $langs->transnoentitiesnoconv('AssetDisposed');
$this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('AssetInProgress');
@@ -1516,7 +1516,7 @@ class Asset extends CommonObject
public function getNextNumRef()
{
global $langs, $conf;
- $langs->load("asset@asset");
+ $langs->load("assets");
if (empty($conf->global->ASSET_ASSET_ADDON)) {
$conf->global->ASSET_ASSET_ADDON = 'mod_asset_standard';
@@ -1581,7 +1581,7 @@ class Asset extends CommonObject
// $result = 0;
// $includedocgeneration = 1;
//
- // $langs->load("asset@asset");
+ // $langs->load("assets");
//
// if (!dol_strlen($modele)) {
// $modele = 'standard_asset';
diff --git a/htdocs/asset/class/assetmodel.class.php b/htdocs/asset/class/assetmodel.class.php
index d31a68284fd..458715f7123 100644
--- a/htdocs/asset/class/assetmodel.class.php
+++ b/htdocs/asset/class/assetmodel.class.php
@@ -580,7 +580,7 @@ class AssetModel extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
@@ -698,7 +698,7 @@ class AssetModel extends CommonObject
// phpcs:enable
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
global $langs;
- //$langs->load("asset@asset");
+ //$langs->load("assets");
$this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
$this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
$this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php
index adbb6afd400..96a09b6507e 100644
--- a/htdocs/asset/list.php
+++ b/htdocs/asset/list.php
@@ -33,6 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php';
// Load translation files required by the page
$langs->loadLangs(array("assets", "other"));
+// Get parameters
$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
@@ -42,8 +43,8 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'assetlist'; // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
-
-$id = GETPOST('id', 'int');
+$mode = GETPOST('mode', 'alpha'); // mode view (kanban or common)
+$id = GETPOST('id', 'int');
// Load variable for pagination
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php
index 4c647c156ad..c82548c743e 100644
--- a/htdocs/bom/bom_card.php
+++ b/htdocs/bom/bom_card.php
@@ -266,7 +266,12 @@ if (empty($reshook)) {
$bomline = new BOMLine($db);
$bomline->fetch($lineid);
- $result = $object->updateLine($lineid, $qty, (int) $qty_frozen, (int) $disable_stock_change, $efficiency, $bomline->position, $bomline->import_key, $fk_unit, $array_options);
+ $fk_default_workstation = $bomline->fk_default_workstation;
+ if (isModEnabled('workstation') && GETPOSTISSET('idworkstations')) {
+ $fk_default_workstation = GETPOSTINT('idworkstations');
+ }
+
+ $result = $object->updateLine($lineid, $qty, (int) $qty_frozen, (int) $disable_stock_change, $efficiency, $bomline->position, $bomline->import_key, $fk_unit, $array_options, $fk_default_workstation);
if ($result <= 0) {
setEventMessages($object->error, $object->errors, 'errors');
diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php
index 02207be5265..bf942c7ad86 100644
--- a/htdocs/bom/class/bom.class.php
+++ b/htdocs/bom/class/bom.class.php
@@ -72,6 +72,10 @@ class BOM extends CommonObject
*/
public $picto = 'bom';
+ /**
+ * @var Product Object product of the BOM
+ */
+ public $product;
const STATUS_DRAFT = 0;
const STATUS_VALIDATED = 1;
@@ -704,9 +708,10 @@ class BOM extends CommonObject
* @param string $import_key Import Key
* @param int $fk_unit Unit of line
* @param array $array_options extrafields array
+ * @param int $fk_default_workstation Default workstation
* @return int <0 if KO, Id of updated BOM-Line if OK
*/
- public function updateLine($rowid, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $import_key = null, $fk_unit = 0, $array_options = 0)
+ public function updateLine($rowid, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $import_key = null, $fk_unit = 0, $array_options = 0, $fk_default_workstation = null)
{
global $mysoc, $conf, $langs, $user;
@@ -785,6 +790,9 @@ class BOM extends CommonObject
$line->array_options[$key] = $array_options[$key];
}
}
+ if ($fk_default_workstation > 0 && $line->fk_default_workstation != $fk_default_workstation) {
+ $line->fk_default_workstation = $fk_default_workstation;
+ }
$result = $line->update($user);
@@ -909,7 +917,7 @@ class BOM extends CommonObject
*/
public function validate($user, $notrigger = 0)
{
- global $conf, $langs;
+ global $conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@@ -1168,7 +1176,7 @@ class BOM extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
@@ -1354,7 +1362,7 @@ class BOM extends CommonObject
{
$this->initAsSpecimenCommon();
$this->ref = 'BOM-123';
- $this->date = $this->date_creation;
+ $this->date_creation = dol_now() - 20000;
}
@@ -1977,7 +1985,7 @@ class BOMLine extends CommonObjectLine
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
diff --git a/htdocs/bom/tpl/objectline_edit.tpl.php b/htdocs/bom/tpl/objectline_edit.tpl.php
index 45d0d281c33..6d7ab47a822 100644
--- a/htdocs/bom/tpl/objectline_edit.tpl.php
+++ b/htdocs/bom/tpl/objectline_edit.tpl.php
@@ -155,6 +155,7 @@ if ($filtertype != 1) {
$coldisplay++;
print '';
+ print $formproduct->selectWorkstations($line->fk_default_workstation, 'idworkstations', 1);
print ' ';
$coldisplay++;
diff --git a/htdocs/bookcal/COPYING b/htdocs/bookcal/COPYING
deleted file mode 100644
index 94a04532226..00000000000
--- a/htdocs/bookcal/COPYING
+++ /dev/null
@@ -1,621 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
diff --git a/htdocs/bookcal/ChangeLog.md b/htdocs/bookcal/ChangeLog.md
deleted file mode 100644
index 992a3d0842c..00000000000
--- a/htdocs/bookcal/ChangeLog.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# CHANGELOG BOOKCAL FOR [DOLIBARR ERP CRM](https://www.dolibarr.org)
-
-## 1.0
-
-Initial version
diff --git a/htdocs/bookcal/admin/booking_extrafields.php b/htdocs/bookcal/admin/booking_extrafields.php
deleted file mode 100644
index de09660f63d..00000000000
--- a/htdocs/bookcal/admin/booking_extrafields.php
+++ /dev/null
@@ -1,113 +0,0 @@
-
- * Copyright (C) 2003 Jean-Louis Bergamo
- * Copyright (C) 2004-2011 Laurent Destailleur
- * Copyright (C) 2012 Regis Houssin
- * Copyright (C) 2014 Florian Henry
- * Copyright (C) 2015 Jean-François Ferry
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-/**
- * \file htdocs/bookcal/admin/booking_extrafields.php
- * \ingroup bookcal
- * \brief Page to setup extra fields of booking
- */
-
-// Load Dolibarr environment
-require '../../main.inc.php';
-
-require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
-require_once '../lib/bookcal.lib.php';
-
-// Load translation files required by the page
-$langs->loadLangs(array('agenda', 'admin'));
-
-$extrafields = new ExtraFields($db);
-$form = new Form($db);
-
-// List of supported format
-$tmptype2label = ExtraFields::$type2label;
-$type2label = array('');
-foreach ($tmptype2label as $key => $val) {
- $type2label[$key] = $langs->transnoentitiesnoconv($val);
-}
-
-$action = GETPOST('action', 'aZ09');
-$attrname = GETPOST('attrname', 'alpha');
-$elementtype = 'bookcal_booking'; //Must be the $table_element of the class that manage extrafield
-
-if (!$user->admin) {
- accessforbidden();
-}
-
-
-/*
- * Actions
- */
-
-require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
-
-
-
-/*
- * View
- */
-
-$textobject = $langs->transnoentitiesnoconv("Booking");
-
-$help_url = '';
-$page_name = "BookCalSetup";
-
-llxHeader('', $langs->trans("BookCalSetup"), $help_url);
-
-
-$linkback = ''.$langs->trans("BackToModuleList").' ';
-print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
-
-
-$head = bookcalAdminPrepareHead();
-
-print dol_get_fiche_head($head, 'booking_extrafields', $langs->trans($page_name), -1, 'fa-calendar-check');
-
-require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
-
-print dol_get_fiche_end();
-
-
-
-/*
- * Creation of an optional field
- */
-if ($action == 'create') {
- print '
';
- print load_fiche_titre($langs->trans('NewAttribute'));
-
- require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
-}
-
-/*
- * Edition of an optional field
- */
-if ($action == 'edit' && !empty($attrname)) {
- print " ";
- print load_fiche_titre($langs->trans("FieldEdition", $attrname));
-
- require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
-}
-
-// End of page
-llxFooter();
-$db->close();
diff --git a/htdocs/bookcal/bookcalindex.php b/htdocs/bookcal/bookcalindex.php
index bed921e91ea..c236815a040 100644
--- a/htdocs/bookcal/bookcalindex.php
+++ b/htdocs/bookcal/bookcalindex.php
@@ -27,7 +27,6 @@
// Load Dolibarr environment
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
-require_once DOL_DOCUMENT_ROOT.'/bookcal/class/booking.class.php';
// Load translation files required by the page
$langs->loadLangs(array("agenda"));
@@ -74,7 +73,7 @@ print '';
// Draft MyObject
if ($user->hasRight('bookcal', 'availabilities', 'read') && isModEnabled('bookcal')) {
$langs->load("orders");
- $myobjectstatic = new Booking($db);
+ /*$myobjectstatic = new Booking($db);
$sql = "SELECT rowid, `ref`, fk_soc, fk_project, description, note_public, note_private, date_creation, tms, fk_user_creat, fk_user_modif, last_main_doc, import_key, model_pdf, status, firstname, lastname, email, `start`, duration";
$sql .= " FROM ". MAIN_DB_PREFIX . 'bookcal_booking';
@@ -129,7 +128,7 @@ if ($user->hasRight('bookcal', 'availabilities', 'read') && isModEnabled('bookca
$db->free($resql);
} else {
dol_print_error($db);
- }
+ }*/
}
//END MODULEBUILDER DRAFT MYOBJECT */
diff --git a/htdocs/bookcal/booking_agenda.php b/htdocs/bookcal/booking_agenda.php
deleted file mode 100644
index 62346d66721..00000000000
--- a/htdocs/bookcal/booking_agenda.php
+++ /dev/null
@@ -1,268 +0,0 @@
-
- * Copyright (C) 2022 Alice Adminson
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-/**
- * \file htdocs/bookcal/booking_agenda.php
- * \ingroup bookcal
- * \brief Tab of events on Booking
- */
-
-// Load Dolibarr environment
-require '../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/bookcal/class/booking.class.php';
-require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_booking.lib.php';
-
-
-// Load translation files required by the page
-$langs->loadLangs(array("agenda", "other"));
-
-// Get parameters
-$id = GETPOST('id', 'int');
-$ref = GETPOST('ref', 'alpha');
-$action = GETPOST('action', 'aZ09');
-$cancel = GETPOST('cancel', 'aZ09');
-$backtopage = GETPOST('backtopage', 'alpha');
-
-if (GETPOST('actioncode', 'array')) {
- $actioncode = GETPOST('actioncode', 'array', 3);
- if (!count($actioncode)) {
- $actioncode = '0';
- }
-} else {
- $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
-}
-
-$search_rowid = GETPOST('search_rowid');
-$search_agenda_label = GETPOST('search_agenda_label');
-
-$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST('sortfield', 'aZ09comma');
-$sortorder = GETPOST('sortorder', 'aZ09comma');
-$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
-if (empty($page) || $page == -1) {
- $page = 0;
-} // If $page is not defined, or '' or -1
-$offset = $limit * $page;
-$pageprev = $page - 1;
-$pagenext = $page + 1;
-if (!$sortfield) {
- $sortfield = 'a.datep,a.id';
-}
-if (!$sortorder) {
- $sortorder = 'DESC,DESC';
-}
-
-// Initialize technical objects
-$object = new Booking($db);
-$extrafields = new ExtraFields($db);
-$diroutputmassaction = $conf->bookcal->dir_output.'/temp/massgeneration/'.$user->id;
-$hookmanager->initHooks(array('bookingagenda', 'globalcard')); // Note that conf->hooks_modules contains array
-// Fetch optionals attributes and labels
-$extrafields->fetch_name_optionals_label($object->table_element);
-
-// Load object
-include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
-if ($id > 0 || !empty($ref)) {
- $upload_dir = $conf->bookcal->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id;
-}
-
-// There is several ways to check permission.
-// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
-$enablepermissioncheck = 0;
-if ($enablepermissioncheck) {
- $permissiontoread = $user->rights->bookcal->booking->read;
- $permissiontoadd = $user->rights->bookcal->booking->write;
-} else {
- $permissiontoread = 1;
- $permissiontoadd = 1;
-}
-
-// Security check (enable the most restrictive one)
-//if ($user->socid > 0) accessforbidden();
-//if ($user->socid > 0) $socid = $user->socid;
-//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
-//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
-if (!isModEnabled('bookcal')) accessforbidden();
-if (!$permissiontoread) accessforbidden();
-
-
-/*
- * Actions
- */
-
-$parameters = array('id'=>$id);
-$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
-if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
-}
-
-if (empty($reshook)) {
- // Cancel
- if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
- header("Location: ".$backtopage);
- exit;
- }
-
- // Purge search criteria
- if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
- $actioncode = '';
- $search_agenda_label = '';
- }
-}
-
-
-
-/*
- * View
- */
-
-$form = new Form($db);
-
-if ($object->id > 0) {
- $title = $langs->trans("Agenda");
- //if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title;
- $help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung';
- llxHeader('', $title, $help_url);
-
- if (!empty($conf->notification->enabled)) {
- $langs->load("mails");
- }
- $head = bookingPrepareHead($object);
-
-
- print dol_get_fiche_head($head, 'agenda', $langs->trans("Booking"), -1, $object->picto);
-
- // Object card
- // ------------------------------------------------------------
- $linkback = ''.$langs->trans("BackToList").' ';
-
- $morehtmlref = '';
- /*
- // Ref customer
- $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
- $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
- // Thirdparty
- $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
- // Project
- if (isModEnabled('project')) {
- $langs->load("projects");
- $morehtmlref.='
'.$langs->trans('Project') . ' ';
- if ($permissiontoadd) {
- if ($action != 'classify') {
- //$morehtmlref.='
' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
- }
- $morehtmlref.=' : ';
- if ($action == 'classify') {
- //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
- $morehtmlref.='
';
- $morehtmlref.=' ';
- $morehtmlref.=' ';
- $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
- $morehtmlref.=' ';
- $morehtmlref.=' ';
- } else {
- $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
- }
- } else {
- if (! empty($object->fk_project)) {
- $proj = new Project($db);
- $proj->fetch($object->fk_project);
- $morehtmlref .= ': '.$proj->getNomUrl();
- } else {
- $morehtmlref .= '';
- }
- }
- }*/
- $morehtmlref .= '
';
-
-
- dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
-
- print '';
- print '
';
-
- $object->info($object->id);
- dol_print_object_info($object, 1);
-
- print '
';
-
- print dol_get_fiche_end();
-
-
-
- // Actions buttons
-
- $objthirdparty = $object;
- $objcon = new stdClass();
-
- $out = '&origin='.urlencode($object->element.'@'.$object->module).'&originid='.urlencode($object->id);
- $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id;
- $out .= '&backtopage='.urlencode($urlbacktopage);
- $permok = $user->hasRight('agenda', 'myactions', 'create');
- if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) {
- //$out.='trans("AddAnAction"),'filenew');
- //$out.=" ";
- }
-
-
- print '';
-
- if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) {
- $param = '&id='.$object->id.(!empty($socid) ? '&socid='.$socid : '');
- if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
- $param .= '&contextpage='.urlencode($contextpage);
- }
- if ($limit > 0 && $limit != $conf->liste_limit) {
- $param .= '&limit='.((int) $limit);
- }
-
-
- //print load_fiche_titre($langs->trans("ActionsOnBooking"), '', '');
-
- // List of all actions
- $filters = array();
- $filters['search_agenda_label'] = $search_agenda_label;
- $filters['search_rowid'] = $search_rowid;
-
- // TODO Replace this with same code than into list.php
- show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module);
- }
-}
-
-// End of page
-llxFooter();
-$db->close();
diff --git a/htdocs/bookcal/booking_card.php b/htdocs/bookcal/booking_card.php
deleted file mode 100644
index f85331cc801..00000000000
--- a/htdocs/bookcal/booking_card.php
+++ /dev/null
@@ -1,569 +0,0 @@
-
- * Copyright (C) 2022 Alice Adminson
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-/**
- * \file htdocs/bookcal/booking_card.php
- * \ingroup bookcal
- * \brief Page to create/edit/view booking
- */
-
-// Load Dolibarr environment
-require '../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
-require_once DOL_DOCUMENT_ROOT.'/bookcal/class/booking.class.php';
-require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_booking.lib.php';
-
-// Load translation files required by the page
-$langs->loadLangs(array("agenda", "other"));
-
-// Get parameters
-$id = GETPOST('id', 'int');
-$ref = GETPOST('ref', 'alpha');
-$lineid = GETPOST('lineid', 'int');
-
-$action = GETPOST('action', 'aZ09');
-$confirm = GETPOST('confirm', 'alpha');
-$cancel = GETPOST('cancel', 'aZ09');
-$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');
-$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
-$dol_openinpopup = GETPOST('dol_openinpopup', 'aZ09');
-
-// Initialize technical objects
-$object = new Booking($db);
-$extrafields = new ExtraFields($db);
-$diroutputmassaction = $conf->bookcal->dir_output.'/temp/massgeneration/'.$user->id;
-$hookmanager->initHooks(array('bookingcard', 'globalcard')); // Note that conf->hooks_modules contains array
-
-// Fetch optionals attributes and labels
-$extrafields->fetch_name_optionals_label($object->table_element);
-
-$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
-
-// Initialize array of search criterias
-$search_all = GETPOST("search_all", 'alpha');
-$search = array();
-foreach ($object->fields as $key => $val) {
- if (GETPOST('search_'.$key, 'alpha')) {
- $search[$key] = GETPOST('search_'.$key, 'alpha');
- }
-}
-
-if (empty($action) && empty($id) && empty($ref)) {
- $action = 'view';
-}
-
-// Load object
-include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
-
-// There is several ways to check permission.
-// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
-$enablepermissioncheck = 0;
-if ($enablepermissioncheck) {
- $permissiontoread = $user->rights->bookcal->booking->read;
- $permissiontoadd = $user->rights->bookcal->booking->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
- $permissiontodelete = $user->rights->bookcal->booking->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
- $permissionnote = $user->rights->bookcal->booking->write; // Used by the include of actions_setnotes.inc.php
- $permissiondellink = $user->rights->bookcal->booking->write; // Used by the include of actions_dellink.inc.php
-} else {
- $permissiontoread = 1;
- $permissiontoadd = 1; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
- $permissiontodelete = 1;
- $permissionnote = 1;
- $permissiondellink = 1;
-}
-
-$upload_dir = $conf->bookcal->multidir_output[isset($object->entity) ? $object->entity : 1].'/booking';
-
-// Security check (enable the most restrictive one)
-//if ($user->socid > 0) accessforbidden();
-//if ($user->socid > 0) $socid = $user->socid;
-//$isdraft = (isset($object->status) && ($object->status == $object::STATUS_DRAFT) ? 1 : 0);
-//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
-if (!isModEnabled('bookcal')) accessforbidden();
-if (!$permissiontoread) accessforbidden();
-
-
-/*
- * Actions
- */
-
-$parameters = array();
-$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
-if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
-}
-
-if (empty($reshook)) {
- $error = 0;
-
- $backurlforlist = dol_buildpath('/bookcal/booking_list.php', 1);
-
- if (empty($backtopage) || ($cancel && empty($id))) {
- if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
- if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
- $backtopage = $backurlforlist;
- } else {
- $backtopage = dol_buildpath('/bookcal/booking_card.php', 1).'?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
- }
- }
- }
-
- $triggermodname = 'BOOKCAL_BOOKING_MODIFY'; // Name of trigger action code to execute when we modify record
-
- // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
- include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
-
- // Actions when linking object each other
- include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
-
- // Actions when printing a doc from card
- include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
-
- // Action to move up and down lines of object
- //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
-
- // Action to build doc
- include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
-
- if ($action == 'set_thirdparty' && $permissiontoadd) {
- $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, $triggermodname);
- }
- if ($action == 'classin' && $permissiontoadd) {
- $object->setProject(GETPOST('projectid', 'int'));
- }
-
- // Actions to send emails
- $triggersendname = 'BOOKCAL_BOOKING_SENTBYMAIL';
- $autocopy = 'MAIN_MAIL_AUTOCOPY_BOOKING_TO';
- $trackid = 'booking'.$object->id;
- include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
-}
-
-
-
-
-/*
- * View
- *
- * Put here all code to build page
- */
-
-$form = new Form($db);
-$formfile = new FormFile($db);
-$formproject = new FormProjets($db);
-
-$title = $langs->trans("Booking");
-$help_url = '';
-llxHeader('', $title, $help_url);
-
-// Example : Adding jquery code
-// print '';
-
-
-// Part to create
-if ($action == 'create') {
- if (empty($permissiontoadd)) {
- accessforbidden($langs->trans('NotEnoughPermissions'), 0, 1);
- exit;
- }
-
- print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Booking")), '', 'object_'.$object->picto);
-
- print '';
- print ' ';
- print ' ';
- if ($backtopage) {
- print ' ';
- }
- if ($backtopageforcancel) {
- print ' ';
- }
-
- print dol_get_fiche_head(array(), '');
-
- // Set some default values
- //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue';
-
- print ''."\n";
-
- // Common attributes
- include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
-
- // Other attributes
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
-
- print '
'."\n";
-
- print dol_get_fiche_end();
-
- print $form->buttonsSaveCancel("Create");
-
- print ' ';
-
- //dol_set_focus('input[name="ref"]');
-}
-
-// Part to edit record
-if (($id || $ref) && $action == 'edit') {
- print load_fiche_titre($langs->trans("Booking"), '', 'object_'.$object->picto);
-
- print '';
- print ' ';
- print ' ';
- print ' ';
- if ($backtopage) {
- print ' ';
- }
- if ($backtopageforcancel) {
- print ' ';
- }
-
- print dol_get_fiche_head();
-
- print ''."\n";
-
- // Common attributes
- include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
-
- // Other attributes
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
-
- print '
';
-
- print dol_get_fiche_end();
-
- print $form->buttonsSaveCancel();
-
- print ' ';
-}
-
-// Part to show record
-if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
- $res = $object->fetch_optionals();
-
- $head = bookingPrepareHead($object);
- print dol_get_fiche_head($head, 'card', $langs->trans("Booking"), -1, $object->picto);
-
- $formconfirm = '';
-
- // Confirmation to delete
- if ($action == 'delete') {
- $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBooking'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
- }
- // Confirmation to delete line
- if ($action == 'deleteline') {
- $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
- }
-
- // Clone confirmation
- if ($action == 'clone') {
- // Create an array for form
- $formquestion = array();
- $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
- }
-
- // Confirmation of action xxxx (You can use it for xxx = 'close', xxx = 'reopen', ...)
- if ($action == 'xxx') {
- $text = $langs->trans('ConfirmActionBooking', $object->ref);
- /*if (! empty($conf->notification->enabled))
- {
- require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php';
- $notify = new Notify($db);
- $text .= ' ';
- $text .= $notify->confirmMessage('BOOKING_CLOSE', $object->socid, $object);
- }*/
-
- $formquestion = array();
- /*
- $forcecombo=0;
- if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
- $formquestion = array(
- // 'text' => $langs->trans("ConfirmClone"),
- // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
- // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
- // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
- );
- */
- $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
- }
-
- // Call Hook formConfirm
- $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
- $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- if (empty($reshook)) {
- $formconfirm .= $hookmanager->resPrint;
- } elseif ($reshook > 0) {
- $formconfirm = $hookmanager->resPrint;
- }
-
- // Print form confirm
- print $formconfirm;
-
-
- // Object card
- // ------------------------------------------------------------
- $linkback = ''.$langs->trans("BackToList").' ';
-
- $morehtmlref = '';
- /*
- // Ref customer
- $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
- $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
- // Thirdparty
- $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
- // Project
- if (isModEnabled('project')) {
- $langs->load("projects");
- $morehtmlref .= '
'.$langs->trans('Project') . ' ';
- if ($permissiontoadd) {
- //if ($action != 'classify') $morehtmlref.='
' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' ';
- $morehtmlref .= ' : ';
- if ($action == 'classify') {
- //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 0, 1, '', 'maxwidth300');
- $morehtmlref .= '
';
- $morehtmlref .= ' ';
- $morehtmlref .= ' ';
- $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
- $morehtmlref .= ' ';
- $morehtmlref .= ' ';
- } else {
- $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
- }
- } else {
- if (! empty($object->fk_project)) {
- $proj = new Project($db);
- $proj->fetch($object->fk_project);
- $morehtmlref .= ': '.$proj->getNomUrl();
- } else {
- $morehtmlref .= '';
- }
- }
- }*/
- $morehtmlref .= '
';
-
-
- dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
-
-
- print '';
- print '
';
- print '
';
- print '
'."\n";
-
- // Common attributes
- //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field
- //unset($object->fields['fk_project']); // Hide field already shown in banner
- //unset($object->fields['fk_soc']); // Hide field already shown in banner
- include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
-
- // Other attributes. Fields from hook formObjectOptions and Extrafields.
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
-
- print '
';
- print '
';
- print '
';
-
- print '
';
-
- print dol_get_fiche_end();
-
-
- /*
- * Lines
- */
-
- if (!empty($object->table_element_line)) {
- // Show object lines
- $result = $object->getLinesArray();
-
- print ' id.(($action != 'editline') ? '' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
-
-
-
-
-
- ';
-
- if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
- include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
- }
-
- print '';
- if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
- print '
';
- }
-
- if (!empty($object->lines)) {
- $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1);
- }
-
- // Form to add new line
- if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') {
- if ($action != 'editline') {
- // Add products/services form
-
- $parameters = array();
- $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- if (empty($reshook))
- $object->formAddObjectLine(1, $mysoc, $soc);
- }
- }
-
- if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
- print '
';
- }
- print '
';
-
- print " \n";
- }
-
-
- // Buttons for actions
-
- if ($action != 'presend' && $action != 'editline') {
- print ''."\n";
- $parameters = array();
- $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- }
-
- if (empty($reshook)) {
- // Send
- if (empty($user->socid)) {
- print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init&token='.newToken().'#formmailbeforetitle');
- }
-
- // Back to draft
- if ($object->status == $object::STATUS_VALIDATED) {
- print dolGetButtonAction($langs->trans('SetToDraft'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes&token='.newToken(), '', $permissiontoadd);
- }
-
- print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd);
-
- // Validate
- if ($object->status == $object::STATUS_DRAFT) {
- if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
- print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes&token='.newToken(), '', $permissiontoadd);
- } else {
- $langs->load("errors");
- print dolGetButtonAction($langs->trans("ErrorAddAtLeastOneLineFirst"), $langs->trans("Validate"), 'default', '#', '', 0);
- }
- }
-
- // Clone
- print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid)?'&socid='.$object->socid:'').'&action=clone&token='.newToken(), '', $permissiontoadd);
-
- /*
- if ($permissiontoadd) {
- if ($object->status == $object::STATUS_ENABLED) {
- print dolGetButtonAction($langs->trans('Disable'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=disable&token='.newToken(), '', $permissiontoadd);
- } else {
- print dolGetButtonAction($langs->trans('Enable'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=enable&token='.newToken(), '', $permissiontoadd);
- }
- }
- if ($permissiontoadd) {
- if ($object->status == $object::STATUS_VALIDATED) {
- print dolGetButtonAction($langs->trans('Cancel'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontoadd);
- } else {
- print dolGetButtonAction($langs->trans('Re-Open'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=reopen&token='.newToken(), '', $permissiontoadd);
- }
- }
- */
-
- // Delete (need delete permission, or if draft, just need create/modify permission)
- print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken(), '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd));
- }
- print '
'."\n";
- }
-
-
- // Select mail models is same action as presend
- if (GETPOST('modelselected')) {
- $action = 'presend';
- }
-
- if ($action != 'presend') {
- print '';
- print '
'; // ancre
-
- $includedocgeneration = 0;
-
- // Documents
- if ($includedocgeneration) {
- $objref = dol_sanitizeFileName($object->ref);
- $relativepath = $objref.'/'.$objref.'.pdf';
- $filedir = $conf->bookcal->dir_output.'/'.$object->element.'/'.$objref;
- $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
- $genallowed = $permissiontoread; // If you can read, you can build the PDF to read content
- $delallowed = $permissiontoadd; // If you can create/edit, you can remove a file on card
- print $formfile->showdocuments('bookcal:Booking', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
- }
-
- // Show links to link elements
- $linktoelem = $form->showLinkToObjectBlock($object, null, array('booking'));
- $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
-
-
- print '
';
-
- $MAXEVENT = 10;
-
- $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', dol_buildpath('/bookcal/booking_agenda.php', 1).'?id='.$object->id);
-
- // List of actions on element
- include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
- $formactions = new FormActions($db);
- $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter);
-
- print '
';
- }
-
- //Select mail models is same action as presend
- if (GETPOST('modelselected')) {
- $action = 'presend';
- }
-
- // Presend form
- $modelmail = 'booking';
- $defaulttopic = 'InformationMessage';
- $diroutput = $conf->bookcal->dir_output;
- $trackid = 'booking'.$object->id;
-
- include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
-}
-
-// End of page
-llxFooter();
-$db->close();
diff --git a/htdocs/bookcal/booking_contact.php b/htdocs/bookcal/booking_contact.php
deleted file mode 100644
index 938e3287c70..00000000000
--- a/htdocs/bookcal/booking_contact.php
+++ /dev/null
@@ -1,197 +0,0 @@
-
- * Copyright (C) 2022 Alice Adminson
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-/**
- * \file htdocs/bookcal/booking_contact.php
- * \ingroup bookcal
- * \brief Tab for contacts linked to Booking
- */
-
-// Load Dolibarr environment
-require '../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
-require_once DOL_DOCUMENT_ROOT.'/bookcal/class/booking.class.php';
-require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_booking.lib.php';
-
-// Load translation files required by the page
-$langs->loadLangs(array("agenda", "companies", "other", "mails"));
-
-$id = (GETPOST('id') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility
-$ref = GETPOST('ref', 'alpha');
-$lineid = GETPOST('lineid', 'int');
-$socid = GETPOST('socid', 'int');
-$action = GETPOST('action', 'aZ09');
-
-// Initialize technical objects
-$object = new Booking($db);
-$extrafields = new ExtraFields($db);
-$diroutputmassaction = $conf->bookcal->dir_output.'/temp/massgeneration/'.$user->id;
-$hookmanager->initHooks(array('bookingcontact', 'globalcard')); // Note that conf->hooks_modules contains array
-// Fetch optionals attributes and labels
-$extrafields->fetch_name_optionals_label($object->table_element);
-
-// Load object
-include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
-
-// There is several ways to check permission.
-// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
-$enablepermissioncheck = 0;
-if ($enablepermissioncheck) {
- $permissiontoread = $user->rights->bookcal->booking->read;
- $permission = $user->rights->bookcal->booking->write;
-} else {
- $permissiontoread = 1;
- $permission = 1;
-}
-
-// Security check (enable the most restrictive one)
-//if ($user->socid > 0) accessforbidden();
-//if ($user->socid > 0) $socid = $user->socid;
-//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
-//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
-if (!isModEnabled('bookcal')) accessforbidden();
-if (!$permissiontoread) accessforbidden();
-
-
-/*
- * Add a new contact
- */
-
-if ($action == 'addcontact' && $permission) {
- $contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
- $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
- $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
-
- if ($result >= 0) {
- header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
- exit;
- } else {
- if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
- $langs->load("errors");
- setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
- } else {
- setEventMessages($object->error, $object->errors, 'errors');
- }
- }
-} elseif ($action == 'swapstatut' && $permission) {
- // Toggle the status of a contact
- $result = $object->swapContactStatus(GETPOST('ligne', 'int'));
-} elseif ($action == 'deletecontact' && $permission) {
- // Deletes a contact
- $result = $object->delete_contact($lineid);
-
- if ($result >= 0) {
- header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
- exit;
- } else {
- dol_print_error($db);
- }
-}
-
-
-/*
- * View
- */
-
-$title = $langs->trans('Booking')." - ".$langs->trans('ContactsAddresses');
-$help_url = '';
-//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
-llxHeader('', $title, $help_url);
-
-$form = new Form($db);
-$formcompany = new FormCompany($db);
-$contactstatic = new Contact($db);
-$userstatic = new User($db);
-
-
-/* *************************************************************************** */
-/* */
-/* View and edit mode */
-/* */
-/* *************************************************************************** */
-
-if ($object->id) {
- /*
- * Show tabs
- */
- $head = bookingPrepareHead($object);
-
- print dol_get_fiche_head($head, 'contact', $langs->trans("Booking"), -1, $object->picto);
-
- $linkback = ''.$langs->trans("BackToList").' ';
-
- $morehtmlref = '';
- /*
- // Ref customer
- $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
- $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
- // Thirdparty
- $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
- // Project
- if (isModEnabled('project'))
- {
- $langs->load("projects");
- $morehtmlref.='
'.$langs->trans('Project') . ' ';
- if ($permissiontoadd)
- {
- if ($action != 'classify')
- //$morehtmlref.='
' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
- $morehtmlref.=' : ';
- if ($action == 'classify') {
- //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
- $morehtmlref.='
';
- $morehtmlref.=' ';
- $morehtmlref.=' ';
- $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
- $morehtmlref.=' ';
- $morehtmlref.=' ';
- } else {
- $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
- }
- } else {
- if (! empty($object->fk_project)) {
- $proj = new Project($db);
- $proj->fetch($object->fk_project);
- $morehtmlref .= ': '.$proj->getNomUrl();
- } else {
- $morehtmlref .= '';
- }
- }
- }*/
- $morehtmlref .= '
';
-
- dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
-
- print dol_get_fiche_end();
-
- print ' ';
-
- // Contacts lines (modules that overwrite templates must declare this into descriptor)
- $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
- foreach ($dirtpls as $reldir) {
- $res = @include dol_buildpath($reldir.'/contacts.tpl.php');
- if ($res) {
- break;
- }
- }
-}
-
-// End of page
-llxFooter();
-$db->close();
diff --git a/htdocs/bookcal/booking_document.php b/htdocs/bookcal/booking_document.php
deleted file mode 100644
index d04258d54d2..00000000000
--- a/htdocs/bookcal/booking_document.php
+++ /dev/null
@@ -1,211 +0,0 @@
-
- * Copyright (C) 2022 Alice Adminson
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-/**
- * \file htdocs/bookcal/booking_document.php
- * \ingroup bookcal
- * \brief Tab for documents linked to Booking
- */
-
-// Load Dolibarr environment
-require '../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
-require_once DOL_DOCUMENT_ROOT.'/bookcal/class/booking.class.php';
-require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_booking.lib.php';
-
-// Load translation files required by the page
-$langs->loadLangs(array("agenda", "companies", "other", "mails"));
-
-
-$action = GETPOST('action', 'aZ09');
-$confirm = GETPOST('confirm');
-$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'));
-$ref = GETPOST('ref', 'alpha');
-
-// Get parameters
-$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST('sortfield', 'aZ09comma');
-$sortorder = GETPOST('sortorder', 'aZ09comma');
-$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
-if (empty($page) || $page == -1) {
- $page = 0;
-} // If $page is not defined, or '' or -1
-$offset = $limit * $page;
-$pageprev = $page - 1;
-$pagenext = $page + 1;
-if (!$sortorder) {
- $sortorder = "ASC";
-}
-if (!$sortfield) {
- $sortfield = "name";
-}
-//if (! $sortfield) $sortfield="position_name";
-
-// Initialize technical objects
-$object = new Booking($db);
-$extrafields = new ExtraFields($db);
-$diroutputmassaction = $conf->bookcal->dir_output.'/temp/massgeneration/'.$user->id;
-$hookmanager->initHooks(array('bookingdocument', 'globalcard')); // Note that conf->hooks_modules contains array
-// Fetch optionals attributes and labels
-$extrafields->fetch_name_optionals_label($object->table_element);
-
-// Load object
-include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
-
-if ($id > 0 || !empty($ref)) {
- $upload_dir = $conf->bookcal->multidir_output[$object->entity ? $object->entity : $conf->entity]."/booking/".get_exdir(0, 0, 0, 1, $object);
-}
-
-// There is several ways to check permission.
-// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
-$enablepermissioncheck = 0;
-if ($enablepermissioncheck) {
- $permissiontoread = $user->rights->bookcal->booking->read;
- $permissiontoadd = $user->rights->bookcal->booking->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php
-} else {
- $permissiontoread = 1;
- $permissiontoadd = 1;
-}
-
-// Security check (enable the most restrictive one)
-//if ($user->socid > 0) accessforbidden();
-//if ($user->socid > 0) $socid = $user->socid;
-//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
-//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
-if (!isModEnabled('bookcal')) accessforbidden();
-if (!$permissiontoread) accessforbidden();
-
-
-/*
- * Actions
- */
-
-include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
-
-
-/*
- * View
- */
-
-$form = new Form($db);
-
-$title = $langs->trans("Booking").' - '.$langs->trans("Files");
-$help_url = '';
-//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
-llxHeader('', $title, $help_url);
-
-if ($object->id) {
- /*
- * Show tabs
- */
- $head = bookingPrepareHead($object);
-
- print dol_get_fiche_head($head, 'document', $langs->trans("Booking"), -1, $object->picto);
-
-
- // Build file list
- $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
- $totalsize = 0;
- foreach ($filearray as $key => $file) {
- $totalsize += $file['size'];
- }
-
- // Object card
- // ------------------------------------------------------------
- $linkback = ''.$langs->trans("BackToList").' ';
-
- $morehtmlref = '';
- /*
- // Ref customer
- $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
- $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
- // Thirdparty
- $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
- // Project
- if (isModEnabled('project'))
- {
- $langs->load("projects");
- $morehtmlref.='
'.$langs->trans('Project') . ' ';
- if ($permissiontoadd)
- {
- if ($action != 'classify')
- //$morehtmlref.='
' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
- $morehtmlref.=' : ';
- if ($action == 'classify') {
- //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
- $morehtmlref.='
';
- $morehtmlref.=' ';
- $morehtmlref.=' ';
- $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
- $morehtmlref.=' ';
- $morehtmlref.=' ';
- } else {
- $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
- }
- } else {
- if (! empty($object->fk_project)) {
- $proj = new Project($db);
- $proj->fetch($object->fk_project);
- $morehtmlref .= ': '.$proj->getNomUrl();
- } else {
- $morehtmlref .= '';
- }
- }
- }*/
- $morehtmlref .= '
';
-
- dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
-
- print '';
-
- print '
';
- print '
';
-
- // Number of files
- print ''.$langs->trans("NbOfAttachedFiles").' '.count($filearray).' ';
-
- // Total size
- print ''.$langs->trans("TotalSizeOfAttachedFiles").' '.$totalsize.' '.$langs->trans("bytes").' ';
-
- print '
';
-
- print '
';
-
- print dol_get_fiche_end();
-
- $modulepart = 'bookcal';
- //$permissiontoadd = $user->rights->bookcal->booking->write;
- $permissiontoadd = 1;
- //$permtoedit = $user->rights->bookcal->booking->write;
- $permtoedit = 1;
- $param = '&id='.$object->id;
-
- //$relativepathwithnofile='booking/' . dol_sanitizeFileName($object->id).'/';
- $relativepathwithnofile = 'booking/'.dol_sanitizeFileName($object->ref).'/';
-
- include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
-} else {
- accessforbidden('', 0, 1);
-}
-
-// End of page
-llxFooter();
-$db->close();
diff --git a/htdocs/bookcal/booking_list.php b/htdocs/bookcal/booking_list.php
deleted file mode 100644
index a141f33a909..00000000000
--- a/htdocs/bookcal/booking_list.php
+++ /dev/null
@@ -1,794 +0,0 @@
-
- * Copyright (C) 2022 Alice Adminson
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-/**
- * \file htdocs/bookcal/booking_list.php
- * \ingroup bookcal
- * \brief List page for booking
- */
-
-// Load Dolibarr environment
-require '../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
-
-// load bookcal libraries
-require_once __DIR__.'/class/booking.class.php';
-
-// for other modules
-//dol_include_once('/othermodule/class/otherobject.class.php');
-
-// Load translation files required by the page
-$langs->loadLangs(array("agenda", "other"));
-
-$id = GETPOST('id', 'int');
-$ref = GETPOST('ref', 'alpha');
-
-$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
-$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
-$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
-$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
-$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
-$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
-$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'); // Go back to a dedicated page
-$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
-$mode = GETPOST('mode', 'aZ');
-
-// Load variable for pagination
-$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST('sortfield', 'aZ09comma');
-$sortorder = GETPOST('sortorder', 'aZ09comma');
-$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
-if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
- // If $page is not defined, or '' or -1 or if we click on clear filters
- $page = 0;
-}
-$offset = $limit * $page;
-$pageprev = $page - 1;
-$pagenext = $page + 1;
-
-// Initialize technical objects
-$object = new Booking($db);
-$extrafields = new ExtraFields($db);
-$diroutputmassaction = $conf->bookcal->dir_output.'/temp/massgeneration/'.$user->id;
-$hookmanager->initHooks(array('bookinglist')); // Note that conf->hooks_modules contains array
-
-// Fetch optionals attributes and labels
-$extrafields->fetch_name_optionals_label($object->table_element);
-//$extrafields->fetch_name_optionals_label($object->table_element_line);
-
-$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
-
-// Default sort order (if not yet defined by previous GETPOST)
-if (!$sortfield) {
- reset($object->fields); // Reset is required to avoid key() to return null.
- $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
-}
-if (!$sortorder) {
- $sortorder = "ASC";
-}
-
-// Initialize array of search criterias
-$search_all = GETPOST('search_all', 'alphanohtml');
-$search = array();
-foreach ($object->fields as $key => $val) {
- if (GETPOST('search_'.$key, 'alpha') !== '') {
- $search[$key] = GETPOST('search_'.$key, 'alpha');
- }
- if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
- $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
- $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
- }
-}
-
-// List of fields to search into when doing a "search in all"
-$fieldstosearchall = array();
-foreach ($object->fields as $key => $val) {
- if (!empty($val['searchall'])) {
- $fieldstosearchall['t.'.$key] = $val['label'];
- }
-}
-
-// Definition of array of fields for columns
-$arrayfields = array();
-foreach ($object->fields as $key => $val) {
- // If $val['visible']==0, then we never show the field
- if (!empty($val['visible'])) {
- $visible = (int) dol_eval($val['visible'], 1);
- $arrayfields['t.'.$key] = array(
- 'label'=>$val['label'],
- 'checked'=>(($visible < 0) ? 0 : 1),
- 'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)),
- 'position'=>$val['position'],
- 'help'=> isset($val['help']) ? $val['help'] : ''
- );
- }
-}
-// Extra fields
-include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
-
-$object->fields = dol_sort_array($object->fields, 'position');
-//$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right');
-$arrayfields = dol_sort_array($arrayfields, 'position');
-
-// There is several ways to check permission.
-// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
-$enablepermissioncheck = 0;
-if ($enablepermissioncheck) {
- $permissiontoread = $user->rights->bookcal->booking->read;
- $permissiontoadd = $user->rights->bookcal->booking->write;
- $permissiontodelete = $user->rights->bookcal->booking->delete;
-} else {
- $permissiontoread = 1;
- $permissiontoadd = 1;
- $permissiontodelete = 1;
-}
-
-// Security check (enable the most restrictive one)
-if ($user->socid > 0) accessforbidden();
-//if ($user->socid > 0) accessforbidden();
-//$socid = 0; if ($user->socid > 0) $socid = $user->socid;
-//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
-//restrictedArea($user, $object->element, 0, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
-if (!isModEnabled('bookcal')) accessforbidden('Module not enabled');
-if (!$permissiontoread) accessforbidden();
-
-
-/*
- * Actions
- */
-
-if (GETPOST('cancel', 'alpha')) {
- $action = 'list';
- $massaction = '';
-}
-if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
- $massaction = '';
-}
-
-$parameters = array();
-$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
-if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
-}
-
-if (empty($reshook)) {
- // Selection of new fields
- include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
-
- // Purge search criteria
- if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
- foreach ($object->fields as $key => $val) {
- $search[$key] = '';
- if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
- $search[$key.'_dtstart'] = '';
- $search[$key.'_dtend'] = '';
- }
- }
- $toselect = array();
- $search_array_options = array();
- }
- if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
- || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
- $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
- }
-
- // Mass actions
- $objectclass = 'Booking';
- $objectlabel = 'Booking';
- $uploaddir = $conf->bookcal->dir_output;
- include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
-}
-
-
-
-/*
- * View
- */
-
-$form = new Form($db);
-
-$now = dol_now();
-
-//$help_url = "EN:Module_Booking|FR:Module_Booking_FR|ES:Módulo_Booking";
-$help_url = '';
-$title = $langs->trans("Bookings");
-$morejs = array();
-$morecss = array();
-
-
-// Build and execute select
-// --------------------------------------------------------------------
-$sql = 'SELECT ';
-$sql .= $object->getFieldList('t');
-// Add fields from extrafields
-if (!empty($extrafields->attributes[$object->table_element]['label'])) {
- foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
- $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
- }
-}
-// Add fields from hooks
-$parameters = array();
-$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
-$sql .= $hookmanager->resPrint;
-$sql = preg_replace('/,\s*$/', '', $sql);
-//$sql .= ", COUNT(rc.rowid) as anotherfield";
-$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
-//$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."anothertable as rc ON rc.parent = t.rowid";
-if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
-}
-// Add table from hooks
-$parameters = array();
-$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
-$sql .= $hookmanager->resPrint;
-if ($object->ismultientitymanaged == 1) {
- $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
-} else {
- $sql .= " WHERE 1 = 1";
-}
-foreach ($search as $key => $val) {
- if (array_key_exists($key, $object->fields)) {
- if ($key == 'status' && $search[$key] == -1) {
- continue;
- }
- $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
- if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
- if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
- $search[$key] = '';
- }
- $mode_search = 2;
- }
- if ($search[$key] != '') {
- $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search));
- }
- } else {
- if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
- $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
- if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
- if (preg_match('/_dtstart$/', $key)) {
- $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'";
- }
- if (preg_match('/_dtend$/', $key)) {
- $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'";
- }
- }
- }
- }
-}
-if ($search_all) {
- $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
-}
-//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
-// Add where from extra fields
-include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
-// Add where from hooks
-$parameters = array();
-$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
-$sql .= $hookmanager->resPrint;
-
-/* If a group by is required
-$sql .= " GROUP BY ";
-foreach($object->fields as $key => $val) {
- $sql .= "t.".$db->escape($key).", ";
-}
-// Add fields from extrafields
-if (!empty($extrafields->attributes[$object->table_element]['label'])) {
- foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
- $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
- }
-}
-// Add where from hooks
-$parameters = array();
-$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
-$sql .= $hookmanager->resPrint;
-$sql = preg_replace('/,\s*$/', '', $sql);
-*/
-
-// Add HAVING from hooks
-/*
-$parameters = array();
-$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook
-$sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint;
-*/
-
-// Count total nb of records
-$nbtotalofrecords = '';
-if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
- /* This old and fast method to get and count full list returns all record so use a high amount of memory.
- $resql = $db->query($sql);
- $nbtotalofrecords = $db->num_rows($resql);
- */
- /* The slow method does not consume memory on mysql (not tested on pgsql) */
- /*$resql = $db->query($sql, 0, 'auto', 1);
- while ($db->fetch_object($resql)) {
- if (empty($nbtotalofrecords)) {
- $nbtotalofrecords = 1; // We can't make +1 because init value is ''
- } else {
- $nbtotalofrecords++;
- }
- }*/
- /* The fast and low memory method to get and count full list converts the sql into a sql count */
- $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
- $resql = $db->query($sqlforcount);
- if ($resql) {
- $objforcount = $db->fetch_object($resql);
- $nbtotalofrecords = $objforcount->nbtotalofrecords;
- } else {
- dol_print_error($db);
- }
-
- if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
- $page = 0;
- $offset = 0;
- }
- $db->free($resql);
-}
-
-// Complete request and execute it with limit
-$sql .= $db->order($sortfield, $sortorder);
-if ($limit) {
- $sql .= $db->plimit($limit + 1, $offset);
-}
-
-$resql = $db->query($sql);
-if (!$resql) {
- dol_print_error($db);
- exit;
-}
-
-$num = $db->num_rows($resql);
-
-
-// Direct jump if only one record found
-if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
- $obj = $db->fetch_object($resql);
- $id = $obj->rowid;
- header("Location: ".dol_buildpath('/bookcal/booking_card.php', 1).'?id='.$id);
- exit;
-}
-
-
-// Output page
-// --------------------------------------------------------------------
-
-llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist');
-
-// Example : Adding jquery code
-// print '';
-
-$arrayofselected = is_array($toselect) ? $toselect : array();
-
-$param = '';
-if (!empty($mode)) {
- $param .= '&mode='.urlencode($mode);
-}
-if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
- $param .= '&contextpage='.urlencode($contextpage);
-}
-if ($limit > 0 && $limit != $conf->liste_limit) {
- $param .= '&limit='.((int) $limit);
-}
-foreach ($search as $key => $val) {
- if (is_array($search[$key]) && count($search[$key])) {
- foreach ($search[$key] as $skey) {
- if ($skey != '') {
- $param .= '&search_'.$key.'[]='.urlencode($skey);
- }
- }
- } elseif ($search[$key] != '') {
- $param .= '&search_'.$key.'='.urlencode($search[$key]);
- }
-}
-if ($optioncss != '') {
- $param .= '&optioncss='.urlencode($optioncss);
-}
-// Add $param from extra fields
-include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
-// Add $param from hooks
-$parameters = array();
-$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
-$param .= $hookmanager->resPrint;
-
-// List of mass actions available
-$arrayofmassactions = array(
- //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
- //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
- //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
- //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
-);
-if (!empty($permissiontodelete)) {
- $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
-}
-if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
- $arrayofmassactions = array();
-}
-$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
-
-print ''."\n";
-if ($optioncss != '') {
- print ' ';
-}
-print ' ';
-print ' ';
-print ' ';
-print ' ';
-print ' ';
-print ' ';
-print ' ';
-print ' ';
-
-
-$newcardbutton = '';
-$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition'));
-$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition'));
-$newcardbutton .= dolGetButtonTitleSeparator();
-$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/bookcal/booking_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
-
-print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
-
-// Add code for pre mass action (confirmation or email presend form)
-$topicmail = "SendBookingRef";
-$modelmail = "booking";
-$objecttmp = new Booking($db);
-$trackid = 'xxxx'.$object->id;
-include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
-
-if ($search_all) {
- $setupstring = '';
- foreach ($fieldstosearchall as $key => $val) {
- $fieldstosearchall[$key] = $langs->trans($val);
- $setupstring .= $key."=".$val.";";
- }
- print ''."\n";
- print ''.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'."\n";
-}
-
-$moreforfilter = '';
-/*$moreforfilter.='';
-$moreforfilter.= $langs->trans('MyFilter') . ': ';
-$moreforfilter.= '
';*/
-
-$parameters = array();
-$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
-if (empty($reshook)) {
- $moreforfilter .= $hookmanager->resPrint;
-} else {
- $moreforfilter = $hookmanager->resPrint;
-}
-
-if (!empty($moreforfilter)) {
- print '';
- print $moreforfilter;
- print '
';
-}
-
-$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
-$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields
-$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
-
-print ''; // You can use div-table-responsive-no-min if you dont need reserved height for your table
-print '
'."\n";
-
-
-// Fields title search
-// --------------------------------------------------------------------
-print '';
-// Action column
-if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
- print '';
- $searchpicto = $form->showFilterButtons('left');
- print $searchpicto;
- print ' ';
-}
-foreach ($object->fields as $key => $val) {
- $searchkey = empty($search[$key]) ? '' : $search[$key];
- $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
- if ($key == 'status') {
- $cssforfield .= ($cssforfield ? ' ' : '').'center';
- } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
- $cssforfield .= ($cssforfield ? ' ' : '').'center';
- } elseif (in_array($val['type'], array('timestamp'))) {
- $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
- } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
- $cssforfield .= ($cssforfield ? ' ' : '').'right';
- }
- if (!empty($arrayfields['t.'.$key]['checked'])) {
- print '';
- if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
- print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
- } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
- print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1);
- } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
- print '';
- print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
- print '
';
- print '';
- print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
- print '
';
- } elseif ($key == 'lang') {
- require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
- $formadmin = new FormAdmin($db);
- print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2);
- } else {
- print ' ';
- }
- print ' ';
- }
-}
-// Extra fields
-include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
-
-// Fields from hook
-$parameters = array('arrayfields'=>$arrayfields);
-$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
-print $hookmanager->resPrint;
-/*if (!empty($arrayfields['anotherfield']['checked'])) {
- print ' ';
-}*/
-// Action column
-if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
- print '';
- $searchpicto = $form->showFilterButtons();
- print $searchpicto;
- print ' ';
-}
-print ' '."\n";
-
-$totalarray = array();
-$totalarray['nbfield'] = 0;
-
-// Fields title label
-// --------------------------------------------------------------------
-print '';
-if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
- print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
-}
-foreach ($object->fields as $key => $val) {
- $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
- if ($key == 'status') {
- $cssforfield .= ($cssforfield ? ' ' : '').'center';
- } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
- $cssforfield .= ($cssforfield ? ' ' : '').'center';
- } elseif (in_array($val['type'], array('timestamp'))) {
- $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
- } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
- $cssforfield .= ($cssforfield ? ' ' : '').'right';
- }
- $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
- if (!empty($arrayfields['t.'.$key]['checked'])) {
- print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
- $totalarray['nbfield']++;
- }
-}
-// Extra fields
-include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
-// Hook fields
-$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
-$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
-print $hookmanager->resPrint;
-/*if (!empty($arrayfields['anotherfield']['checked'])) {
- print ''.$langs->trans("AnotherField").' ';
- $totalarray['nbfield']++;
-}*/
-// Action column
-if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
- print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
-}
-$totalarray['nbfield']++;
-print ' '."\n";
-
-
-// Detect if we need a fetch on each output line
-$needToFetchEachLine = 0;
-if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
- foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
- if (!is_null($val) && preg_match('/\$object/', $val)) {
- $needToFetchEachLine++; // There is at least one compute field that use $object
- }
- }
-}
-
-
-// Loop on record
-// --------------------------------------------------------------------
-$i = 0;
-$savnbfield = $totalarray['nbfield'];
-$totalarray = array();
-$totalarray['nbfield'] = 0;
-$imaxinloop = ($limit ? min($num, $limit) : $num);
-while ($i < $imaxinloop) {
- $obj = $db->fetch_object($resql);
- if (empty($obj)) {
- break; // Should not happen
- }
-
- // Store properties in $object
- $object->setVarsFromFetchObj($obj);
-
- if ($mode == 'kanban') {
- if ($i == 0) {
- print '';
- print '';
- }
- // Output Kanban
- print $object->getKanbanView('', array('selected' => in_array($object->id, $arrayofselected)));
- if ($i == ($imaxinloop - 1)) {
- print '
';
- print ' ';
- }
- } else {
- // Show here line of result
- $j = 0;
- print '';
- // Action column
- if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
- print '';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($object->id, $arrayofselected)) {
- $selected = 1;
- }
- print ' ';
- }
- print ' ';
- }
- foreach ($object->fields as $key => $val) {
- $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
- if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
- $cssforfield .= ($cssforfield ? ' ' : '').'center';
- } elseif ($key == 'status') {
- $cssforfield .= ($cssforfield ? ' ' : '').'center';
- }
-
- if (in_array($val['type'], array('timestamp'))) {
- $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
- } elseif ($key == 'ref') {
- $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
- }
-
- if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
- $cssforfield .= ($cssforfield ? ' ' : '').'right';
- }
- //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
-
- if (!empty($arrayfields['t.'.$key]['checked'])) {
- print '$key)) {
- print ' title="'.dol_escape_htmltag($object->$key).'"';
- }
- print '>';
- if ($key == 'status') {
- print $object->getLibStatut(5);
- } elseif ($key == 'rowid') {
- print $object->showOutputField($val, $key, $object->id, '');
- } else {
- print $object->showOutputField($val, $key, $object->$key, '');
- }
- print ' ';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
- if (!$i) {
- $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
- }
- if (!isset($totalarray['val'])) {
- $totalarray['val'] = array();
- }
- if (!isset($totalarray['val']['t.'.$key])) {
- $totalarray['val']['t.'.$key] = 0;
- }
- $totalarray['val']['t.'.$key] += $object->$key;
- }
- }
- }
- // Extra fields
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
- // Fields from hook
- $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
- $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
- /*if (!empty($arrayfields['anotherfield']['checked'])) {
- print ''.$obj->anotherfield.' ';
- }*/
- // Action column
- if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
- print '';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($object->id, $arrayofselected)) {
- $selected = 1;
- }
- print ' ';
- }
- print ' ';
- }
- if (!$i) {
- $totalarray['nbfield']++;
- }
-
- print ' '."\n";
- }
-
- $i++;
-}
-
-// Show total line
-include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
-
-// If no record found
-if ($num == 0) {
- $colspan = 1;
- foreach ($arrayfields as $key => $val) {
- if (!empty($val['checked'])) {
- $colspan++;
- }
- }
- print ''.$langs->trans("NoRecordFound").' ';
-}
-
-
-$db->free($resql);
-
-$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
-$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
-print $hookmanager->resPrint;
-
-print '
'."\n";
-print '
'."\n";
-
-print ' '."\n";
-
-if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
- $hidegeneratedfilelistifempty = 1;
- if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
- $hidegeneratedfilelistifempty = 0;
- }
-
- require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
- $formfile = new FormFile($db);
-
- // Show list of available documents
- $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
- $urlsource .= str_replace('&', '&', $param);
-
- $filedir = $diroutputmassaction;
- $genallowed = $permissiontoread;
- $delallowed = $permissiontoadd;
-
- print $formfile->showdocuments('massfilesarea_bookcal', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
-}
-
-// End of page
-llxFooter();
-$db->close();
diff --git a/htdocs/bookcal/booking_note.php b/htdocs/bookcal/booking_note.php
deleted file mode 100644
index b72c0fbe6d1..00000000000
--- a/htdocs/bookcal/booking_note.php
+++ /dev/null
@@ -1,171 +0,0 @@
-
- * Copyright (C) 2022 Alice Adminson
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-/**
- * \file htdocs/bookcal/booking_note.php
- * \ingroup bookcal
- * \brief Tab for notes on Booking
- */
-
-// Load Dolibarr environment
-require '../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/bookcal/class/booking.class.php';
-require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_booking.lib.php';
-
-// Load translation files required by the page
-$langs->loadLangs(array("agenda", "companies"));
-
-// Get parameters
-$id = GETPOST('id', 'int');
-$ref = GETPOST('ref', 'alpha');
-$action = GETPOST('action', 'aZ09');
-$cancel = GETPOST('cancel', 'aZ09');
-$backtopage = GETPOST('backtopage', 'alpha');
-
-// Initialize technical objects
-$object = new Booking($db);
-$extrafields = new ExtraFields($db);
-$diroutputmassaction = $conf->bookcal->dir_output.'/temp/massgeneration/'.$user->id;
-$hookmanager->initHooks(array('bookingnote', 'globalcard')); // Note that conf->hooks_modules contains array
-// Fetch optionals attributes and labels
-$extrafields->fetch_name_optionals_label($object->table_element);
-
-// Load object
-include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
-if ($id > 0 || !empty($ref)) {
- $upload_dir = $conf->bookcal->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id;
-}
-
-
-// There is several ways to check permission.
-// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
-$enablepermissioncheck = 0;
-if ($enablepermissioncheck) {
- $permissiontoread = $user->rights->bookcal->booking->read;
- $permissiontoadd = $user->rights->bookcal->booking->write;
- $permissionnote = $user->rights->bookcal->booking->write; // Used by the include of actions_setnotes.inc.php
-} else {
- $permissiontoread = 1;
- $permissiontoadd = 1;
- $permissionnote = 1;
-}
-
-// Security check (enable the most restrictive one)
-//if ($user->socid > 0) accessforbidden();
-//if ($user->socid > 0) $socid = $user->socid;
-//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
-//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
-if (!isModEnabled('bookcal')) accessforbidden();
-if (!$permissiontoread) accessforbidden();
-
-
-/*
- * Actions
- */
-
-$parameters = array();
-$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
-if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
-}
-if (empty($reshook)) {
- include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
-}
-
-
-/*
- * View
- */
-
-$form = new Form($db);
-
-//$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes';
-$help_url = '';
-$title = $langs->trans('Booking').' - '.$langs->trans("Notes");
-llxHeader('', $title, $help_url);
-
-if ($id > 0 || !empty($ref)) {
- $object->fetch_thirdparty();
-
- $head = bookingPrepareHead($object);
-
- print dol_get_fiche_head($head, 'note', $langs->trans("Booking"), -1, $object->picto);
-
- // Object card
- // ------------------------------------------------------------
- $linkback = ''.$langs->trans("BackToList").' ';
-
- $morehtmlref = '';
- /*
- // Ref customer
- $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
- $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
- // Thirdparty
- $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
- // Project
- if (isModEnabled('project'))
- {
- $langs->load("projects");
- $morehtmlref.='
'.$langs->trans('Project') . ' ';
- if ($permissiontoadd)
- {
- if ($action != 'classify')
- //$morehtmlref.='
' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
- $morehtmlref.=' : ';
- if ($action == 'classify') {
- //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
- $morehtmlref.='
';
- $morehtmlref.=' ';
- $morehtmlref.=' ';
- $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
- $morehtmlref.=' ';
- $morehtmlref.=' ';
- } else {
- $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
- }
- } else {
- if (! empty($object->fk_project)) {
- $proj = new Project($db);
- $proj->fetch($object->fk_project);
- $morehtmlref .= ': '.$proj->getNomUrl();
- } else {
- $morehtmlref .= '';
- }
- }
- }*/
- $morehtmlref .= '
';
-
-
- dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
-
-
- print '';
- print '
';
-
-
- $cssclass = "titlefield";
- include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
-
- print '
';
-
- print dol_get_fiche_end();
-}
-
-// End of page
-llxFooter();
-$db->close();
diff --git a/htdocs/bookcal/calendar_agenda.php b/htdocs/bookcal/calendar_agenda.php
index a8513970196..2f524c72382 100644
--- a/htdocs/bookcal/calendar_agenda.php
+++ b/htdocs/bookcal/calendar_agenda.php
@@ -187,7 +187,6 @@ $form = new Form($db);
if ($object->id > 0) {
$title = $langs->trans("Agenda");
- //if (!empty(getDolGlobalString('MAIN_HTML_TITLE')) && preg_match('/thirdpartynameonly/',getDolGlobalString('MAIN_HTML_TITLE')) && $object->name) $title=$object->name." - ".$title;
$help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung';
llxHeader('', $title, $help_url);
diff --git a/htdocs/bookcal/class/availabilities.class.php b/htdocs/bookcal/class/availabilities.class.php
index 8fdbfec04b5..90dd80db888 100644
--- a/htdocs/bookcal/class/availabilities.class.php
+++ b/htdocs/bookcal/class/availabilities.class.php
@@ -102,8 +102,7 @@ class Availabilities extends CommonObject
* @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
*/
public $fields=array(
- 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
- 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'validate'=>'1', 'comment'=>"Reference of object"),
+ 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>2, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>"Help text", 'showoncombobox'=>'2', 'validate'=>'1',),
'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>3, 'validate'=>'1',),
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0, 'cssview'=>'wordbreak', 'validate'=>'1',),
@@ -118,14 +117,12 @@ class Availabilities extends CommonObject
'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '9'=>'Canceled'), 'validate'=>'1',),
'start' => array('type'=>'date', 'label'=>'Start Date', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'searchall'=>1,),
'end' => array('type'=>'date', 'label'=>'End Date', 'enabled'=>'1', 'position'=>45, 'notnull'=>1, 'visible'=>1, 'searchall'=>1,),
- 'type' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>'1', 'position'=>49, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Customer', '1'=>'Supplier', '2'=>'Else'),),
'duration' => array('type'=>'integer', 'label'=>'Duration', 'enabled'=>'1', 'position'=>47, 'notnull'=>1, 'visible'=>1, 'default'=>'30',),
'startHour' => array('type'=>'integer', 'label'=>'Start Hour', 'enabled'=>'1', 'position'=>46, 'notnull'=>1, 'visible'=>-1,),
'endHour' => array('type'=>'integer', 'label'=>'End Hour', 'enabled'=>'1', 'position'=>46.5, 'notnull'=>1, 'visible'=>-1,),
'fk_bookcal_calendar' => array('type'=>'integer:Calendar:bookcal/class/calendar.class.php:1', 'label'=>'CalendarId', 'enabled'=>'1', 'position'=>48, 'notnull'=>1, 'visible'=>1,),
);
public $rowid;
- public $ref;
public $label;
public $description;
public $note_public;
@@ -140,7 +137,6 @@ class Availabilities extends CommonObject
public $status;
public $start;
public $end;
- public $type;
public $duration;
public $startHour;
public $endHour;
@@ -726,7 +722,7 @@ class Availabilities extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($url && $add_save_lastsearch_values) {
diff --git a/htdocs/bookcal/class/booking.class.php b/htdocs/bookcal/class/booking.class.php
deleted file mode 100644
index b3633826271..00000000000
--- a/htdocs/bookcal/class/booking.class.php
+++ /dev/null
@@ -1,1091 +0,0 @@
-
- * Copyright (C) 2022 Alice Adminson
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-/**
- * \file class/booking.class.php
- * \ingroup bookcal
- * \brief This file is a CRUD class file for Booking (Create/Read/Update/Delete)
- */
-
-// Put here all includes required by your class file
-require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
-//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
-//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
-
-/**
- * Class for Booking
- */
-class Booking extends CommonObject
-{
- /**
- * @var string ID of module.
- */
- public $module = 'bookcal';
-
- /**
- * @var string ID to identify managed object.
- */
- public $element = 'booking';
-
- /**
- * @var string Name of table without prefix where object is stored. This is also the key used for extrafields management.
- */
- public $table_element = 'bookcal_booking';
-
- /**
- * @var int Does this object support multicompany module ?
- * 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table
- */
- public $ismultientitymanaged = 0;
-
- /**
- * @var int Does object support extrafields ? 0=No, 1=Yes
- */
- public $isextrafieldmanaged = 1;
-
- /**
- * @var string String with name of icon for booking. Must be a 'fa-xxx' fontawesome code (or 'fa-xxx_fa_color_size') or 'booking@bookcal' if picto is file 'img/object_booking.png'.
- */
- public $picto = 'fa-file';
-
-
- const STATUS_DRAFT = 0;
- const STATUS_VALIDATED = 1;
- const STATUS_CANCELED = 9;
-
-
- /**
- * 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter[:Sortfield]]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
- * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
- * 'label' the translation key.
- * 'picto' is code of a picto to show before value in forms
- * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM' or 'isModEnabled('multicurrency')' ...)
- * 'position' is the sort order of field.
- * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
- * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
- * 'noteditable' says if field is not editable (1 or 0)
- * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created.
- * 'index' if we want an index in database.
- * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
- * 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
- * 'isameasure' must be set to 1 or 2 if field can be used for measure. Field type must be summable like integer or double(24,8). Use 1 in most cases, or 2 if you don't want to see the column total into list (for example for percentage)
- * 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'cssview'=>'wordbreak', 'csslist'=>'tdoverflowmax200'
- * 'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click.
- * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
- * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code.
- * 'arrayofkeyval' to set a list of values if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel"). Note that type can be 'integer' or 'varchar'
- * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1.
- * 'comment' is not used. You can store here any text of your choice. It is not used by application.
- * 'validate' is 1 if need to validate with $this->validateField()
- * 'copytoclipboard' is 1 or 2 to allow to add a picto to copy value into clipboard (1=picto after label, 2=picto after value)
- *
- * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor.
- */
-
- // BEGIN MODULEBUILDER PROPERTIES
- /**
- * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
- */
- public $fields=array(
- 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
- 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>1.2, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'searchall'=>1, 'validate'=>'1', 'comment'=>"Reference of object"),
- 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:((status:=:1) and (entity:IN:__SHARED_ENTITIES__))', 'label'=>'ThirdParty', 'picto'=>'company', 'enabled'=>'isModEnabled("societe")', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'help'=>"LinkToThirparty", 'validate'=>'1',),
- 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'picto'=>'project', 'enabled'=>'$conf->project->enabled', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'validate'=>'1',),
- 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>3, 'validate'=>'1',),
- 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0, 'cssview'=>'wordbreak', 'validate'=>'1',),
- 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0, 'cssview'=>'wordbreak', 'validate'=>'1',),
- 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,),
- 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,),
- 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>-1, 'visible'=>-2,),
- 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'picto'=>'user', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,),
- 'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,),
- 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,),
- 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,),
- 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '9'=>'Canceled'), 'validate'=>'1',),
- 'firstname' => array('type'=>'varchar(128)', 'label'=>'firstname', 'enabled'=>'1', 'position'=>2, 'notnull'=>1, 'visible'=>-1,),
- 'lastname' => array('type'=>'varchar(128)', 'label'=>'lastname', 'enabled'=>'1', 'position'=>3, 'notnull'=>1, 'visible'=>-1,),
- 'email' => array('type'=>'varchar(128)', 'label'=>'email', 'enabled'=>'1', 'position'=>4, 'notnull'=>1, 'visible'=>-1,),
- 'start' => array('type'=>'datetime', 'label'=>'Start Hour', 'enabled'=>'1', 'position'=>5, 'notnull'=>1, 'visible'=>-1,),
- 'duration' => array('type'=>'integer', 'label'=>'Duration', 'enabled'=>'1', 'position'=>6, 'notnull'=>1, 'visible'=>-1,),
- 'fk_bookcal_availability' => array('type'=>'integer:Availabilities:bookcal/class/availabilities.class.php', 'label'=>'AvailabilityId', 'enabled'=>'1', 'position'=>49, 'notnull'=>1, 'visible'=>-1,),
- );
- public $rowid;
- public $ref;
- public $fk_soc;
- public $fk_project;
- public $description;
- public $note_public;
- public $note_private;
- public $date_creation;
- public $tms;
- public $fk_user_creat;
- public $fk_user_modif;
- public $last_main_doc;
- public $import_key;
- public $model_pdf;
- public $status;
- public $firstname;
- public $lastname;
- public $email;
- public $start;
- public $duration;
- public $fk_bookcal_availability;
- // END MODULEBUILDER PROPERTIES
-
-
- // If this object has a subtable with lines
-
- // /**
- // * @var string Name of subtable line
- // */
- // public $table_element_line = 'bookcal_bookingline';
-
- // /**
- // * @var string Field with ID of parent key if this object has a parent
- // */
- // public $fk_element = 'fk_booking';
-
- // /**
- // * @var string Name of subtable class that manage subtable lines
- // */
- // public $class_element_line = 'Bookingline';
-
- // /**
- // * @var array List of child tables. To test if we can delete object.
- // */
- // protected $childtables = array();
-
- // /**
- // * @var array List of child tables. To know object to delete on cascade.
- // * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will
- // * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object
- // */
- // protected $childtablesoncascade = array('bookcal_bookingdet');
-
- // /**
- // * @var BookingLine[] Array of subtable lines
- // */
- // public $lines = array();
-
-
-
- /**
- * Constructor
- *
- * @param DoliDb $db Database handler
- */
- public function __construct(DoliDB $db)
- {
- global $conf, $langs;
-
- $this->db = $db;
-
- if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid']) && !empty($this->fields['ref'])) {
- $this->fields['rowid']['visible'] = 0;
- }
- if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) {
- $this->fields['entity']['enabled'] = 0;
- }
-
- // Example to show how to set values of fields definition dynamically
- /*if ($user->rights->bookcal->booking->read) {
- $this->fields['myfield']['visible'] = 1;
- $this->fields['myfield']['noteditable'] = 0;
- }*/
-
- // Unset fields that are disabled
- foreach ($this->fields as $key => $val) {
- if (isset($val['enabled']) && empty($val['enabled'])) {
- unset($this->fields[$key]);
- }
- }
-
- // Translate some data of arrayofkeyval
- if (is_object($langs)) {
- foreach ($this->fields as $key => $val) {
- if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
- foreach ($val['arrayofkeyval'] as $key2 => $val2) {
- $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
- }
- }
- }
- }
- }
-
- /**
- * Create object into database
- *
- * @param User $user User that creates
- * @param bool $notrigger false=launch triggers after, true=disable triggers
- * @return int <0 if KO, Id of created object if OK
- */
- public function create(User $user, $notrigger = false)
- {
- $resultcreate = $this->createCommon($user, $notrigger);
-
- //$resultvalidate = $this->validate($user, $notrigger);
-
- return $resultcreate;
- }
-
- /**
- * Clone an object into another one
- *
- * @param User $user User that creates
- * @param int $fromid Id of object to clone
- * @return mixed New object created, <0 if KO
- */
- public function createFromClone(User $user, $fromid)
- {
- global $langs, $extrafields;
- $error = 0;
-
- dol_syslog(__METHOD__, LOG_DEBUG);
-
- $object = new self($this->db);
-
- $this->db->begin();
-
- // Load source object
- $result = $object->fetchCommon($fromid);
- if ($result > 0 && !empty($object->table_element_line)) {
- $object->fetchLines();
- }
-
- // get lines so they will be clone
- //foreach($this->lines as $line)
- // $line->fetch_optionals();
-
- // Reset some properties
- unset($object->id);
- unset($object->fk_user_creat);
- unset($object->import_key);
-
- // Clear fields
- if (property_exists($object, 'ref')) {
- $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
- }
- if (property_exists($object, 'label')) {
- $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
- }
- if (property_exists($object, 'status')) {
- $object->status = self::STATUS_DRAFT;
- }
- if (property_exists($object, 'date_creation')) {
- $object->date_creation = dol_now();
- }
- if (property_exists($object, 'date_modification')) {
- $object->date_modification = null;
- }
- // ...
- // Clear extrafields that are unique
- if (is_array($object->array_options) && count($object->array_options) > 0) {
- $extrafields->fetch_name_optionals_label($this->table_element);
- foreach ($object->array_options as $key => $option) {
- $shortkey = preg_replace('/options_/', '', $key);
- if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
- //var_dump($key);
- //var_dump($clonedObj->array_options[$key]); exit;
- unset($object->array_options[$key]);
- }
- }
- }
-
- // Create clone
- $object->context['createfromclone'] = 'createfromclone';
- $result = $object->createCommon($user);
- if ($result < 0) {
- $error++;
- $this->error = $object->error;
- $this->errors = $object->errors;
- }
-
- if (!$error) {
- // copy internal contacts
- if ($this->copy_linked_contact($object, 'internal') < 0) {
- $error++;
- }
- }
-
- if (!$error) {
- // copy external contacts if same company
- if (!empty($object->socid) && property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) {
- if ($this->copy_linked_contact($object, 'external') < 0) {
- $error++;
- }
- }
- }
-
- unset($object->context['createfromclone']);
-
- // End
- if (!$error) {
- $this->db->commit();
- return $object;
- } else {
- $this->db->rollback();
- return -1;
- }
- }
-
- /**
- * Load object in memory from the database
- *
- * @param int $id Id object
- * @param string $ref Ref
- * @return int <0 if KO, 0 if not found, >0 if OK
- */
- public function fetch($id, $ref = null)
- {
- $result = $this->fetchCommon($id, $ref);
- if ($result > 0 && !empty($this->table_element_line)) {
- $this->fetchLines();
- }
- return $result;
- }
-
- /**
- * Load object lines in memory from the database
- *
- * @return int <0 if KO, 0 if not found, >0 if OK
- */
- public function fetchLines()
- {
- $this->lines = array();
-
- $result = $this->fetchLinesCommon();
- return $result;
- }
-
-
- /**
- * Load list of objects in memory from the database.
- *
- * @param string $sortorder Sort Order
- * @param string $sortfield Sort field
- * @param int $limit limit
- * @param int $offset Offset
- * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...)
- * @param string $filtermode Filter mode (AND or OR)
- * @return array|int int <0 if KO, array of pages if OK
- */
- public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
- {
- global $conf;
-
- dol_syslog(__METHOD__, LOG_DEBUG);
-
- $records = array();
-
- $sql = "SELECT ";
- $sql .= $this->getFieldList('t');
- $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
- if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
- $sql .= " WHERE t.entity IN (".getEntity($this->element).")";
- } else {
- $sql .= " WHERE 1 = 1";
- }
- // Manage filter
- $sqlwhere = array();
- if (count($filter) > 0) {
- foreach ($filter as $key => $value) {
- if ($key == 't.rowid') {
- $sqlwhere[] = $key." = ".((int) $value);
- } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
- $sqlwhere[] = $key." = '".$this->db->idate($value)."'";
- } elseif ($key == 'customsql') {
- $sqlwhere[] = $value;
- } elseif (strpos($value, '%') === false) {
- $sqlwhere[] = $key." IN (".$this->db->sanitize($this->db->escape($value)).")";
- } else {
- $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'";
- }
- }
- }
- if (count($sqlwhere) > 0) {
- $sql .= " AND (".implode(" ".$filtermode." ", $sqlwhere).")";
- }
-
- if (!empty($sortfield)) {
- $sql .= $this->db->order($sortfield, $sortorder);
- }
- if (!empty($limit)) {
- $sql .= $this->db->plimit($limit, $offset);
- }
-
- $resql = $this->db->query($sql);
- if ($resql) {
- $num = $this->db->num_rows($resql);
- $i = 0;
- while ($i < ($limit ? min($limit, $num) : $num)) {
- $obj = $this->db->fetch_object($resql);
-
- $record = new self($this->db);
- $record->setVarsFromFetchObj($obj);
-
- $records[$record->id] = $record;
-
- $i++;
- }
- $this->db->free($resql);
-
- return $records;
- } else {
- $this->errors[] = 'Error '.$this->db->lasterror();
- dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
-
- return -1;
- }
- }
-
- /**
- * Update object into database
- *
- * @param User $user User that modifies
- * @param bool $notrigger false=launch triggers after, true=disable triggers
- * @return int <0 if KO, >0 if OK
- */
- public function update(User $user, $notrigger = false)
- {
- return $this->updateCommon($user, $notrigger);
- }
-
- /**
- * Delete object in database
- *
- * @param User $user User that deletes
- * @param bool $notrigger false=launch triggers after, true=disable triggers
- * @return int <0 if KO, >0 if OK
- */
- public function delete(User $user, $notrigger = false)
- {
- return $this->deleteCommon($user, $notrigger);
- //return $this->deleteCommon($user, $notrigger, 1);
- }
-
- /**
- * Delete a line of object in database
- *
- * @param User $user User that delete
- * @param int $idline Id of line to delete
- * @param bool $notrigger false=launch triggers after, true=disable triggers
- * @return int >0 if OK, <0 if KO
- */
- public function deleteLine(User $user, $idline, $notrigger = false)
- {
- if ($this->status < 0) {
- $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
- return -2;
- }
-
- return $this->deleteLineCommon($user, $idline, $notrigger);
- }
-
-
- /**
- * Validate object
- *
- * @param User $user User making status change
- * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
- * @return int <=0 if OK, 0=Nothing done, >0 if KO
- */
- public function validate($user, $notrigger = 0)
- {
- global $conf, $langs;
-
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-
- $error = 0;
-
- // Protection
- if ($this->status == self::STATUS_VALIDATED) {
- dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING);
- return 0;
- }
-
- /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->booking->write))
- || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->booking->booking_advance->validate))))
- {
- $this->error='NotEnoughPermissions';
- dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
- return -1;
- }*/
-
- $now = dol_now();
-
- $this->db->begin();
-
- // Define new ref
- if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
- $num = $this->getNextNumRef();
- } else {
- $num = $this->ref;
- }
- $this->newref = $num;
-
- if (!empty($num)) {
- // Validate
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
- $sql .= " SET ref = '".$this->db->escape($num)."',";
- $sql .= " status = ".self::STATUS_VALIDATED;
- if (!empty($this->fields['date_validation'])) {
- $sql .= ", date_validation = '".$this->db->idate($now)."'";
- }
- if (!empty($this->fields['fk_user_valid'])) {
- $sql .= ", fk_user_valid = ".((int) $user->id);
- }
- $sql .= " WHERE rowid = ".((int) $this->id);
-
- dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if (!$resql) {
- dol_print_error($this->db);
- $this->error = $this->db->lasterror();
- $error++;
- }
-
- if (!$error && !$notrigger) {
- // Call trigger
- $result = $this->call_trigger('BOOKING_VALIDATE', $user);
- if ($result < 0) {
- $error++;
- }
- // End call triggers
- }
- }
-
- if (!$error) {
- $this->oldref = $this->ref;
-
- // Rename directory if dir was a temporary ref
- if (preg_match('/^[\(]?PROV/i', $this->ref)) {
- // Now we rename also files into index
- $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'booking/".$this->db->escape($this->newref)."'";
- $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'booking/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
- $resql = $this->db->query($sql);
- if (!$resql) {
- $error++; $this->error = $this->db->lasterror();
- }
-
- // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
- $oldref = dol_sanitizeFileName($this->ref);
- $newref = dol_sanitizeFileName($num);
- $dirsource = $conf->bookcal->dir_output.'/booking/'.$oldref;
- $dirdest = $conf->bookcal->dir_output.'/booking/'.$newref;
- if (!$error && file_exists($dirsource)) {
- dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
-
- if (@rename($dirsource, $dirdest)) {
- dol_syslog("Rename ok");
- // Rename docs starting with $oldref with $newref
- $listoffiles = dol_dir_list($conf->bookcal->dir_output.'/booking/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
- foreach ($listoffiles as $fileentry) {
- $dirsource = $fileentry['name'];
- $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
- $dirsource = $fileentry['path'].'/'.$dirsource;
- $dirdest = $fileentry['path'].'/'.$dirdest;
- @rename($dirsource, $dirdest);
- }
- }
- }
- }
- }
-
- // Set new ref and current status
- if (!$error) {
- $this->ref = $num;
- $this->status = self::STATUS_VALIDATED;
- }
-
- if (!$error) {
- $this->db->commit();
- return 1;
- } else {
- $this->db->rollback();
- return -1;
- }
- }
-
-
- /**
- * Set draft status
- *
- * @param User $user Object user that modify
- * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
- * @return int <0 if KO, >0 if OK
- */
- public function setDraft($user, $notrigger = 0)
- {
- // Protection
- if ($this->status <= self::STATUS_DRAFT) {
- return 0;
- }
-
- /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->write))
- || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->bookcal_advance->validate))))
- {
- $this->error='Permission denied';
- return -1;
- }*/
-
- return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'BOOKING_UNVALIDATE');
- }
-
- /**
- * Set cancel status
- *
- * @param User $user Object user that modify
- * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
- * @return int <0 if KO, 0=Nothing done, >0 if OK
- */
- public function cancel($user, $notrigger = 0)
- {
- // Protection
- if ($this->status != self::STATUS_VALIDATED) {
- return 0;
- }
-
- /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->write))
- || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->bookcal_advance->validate))))
- {
- $this->error='Permission denied';
- return -1;
- }*/
-
- return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'BOOKING_CANCEL');
- }
-
- /**
- * Set back to validated status
- *
- * @param User $user Object user that modify
- * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
- * @return int <0 if KO, 0=Nothing done, >0 if OK
- */
- public function reopen($user, $notrigger = 0)
- {
- // Protection
- if ($this->status != self::STATUS_CANCELED) {
- return 0;
- }
-
- /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->write))
- || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->bookcal_advance->validate))))
- {
- $this->error='Permission denied';
- return -1;
- }*/
-
- return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'BOOKING_REOPEN');
- }
-
- /**
- * Return a link to the object card (with optionaly the picto)
- *
- * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
- * @param string $option On what the link point to ('nolink', ...)
- * @param int $notooltip 1=Disable tooltip
- * @param string $morecss Add more css on link
- * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
- * @return string String with URL
- */
- public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
- {
- global $conf, $langs, $hookmanager;
-
- if (!empty($conf->dol_no_mouse_hover)) {
- $notooltip = 1; // Force disable tooltips
- }
-
- $result = '';
-
- $label = img_picto('', $this->picto).' '.$langs->trans("Booking").' ';
- if (isset($this->status)) {
- $label .= ' '.$this->getLibStatut(5);
- }
- $label .= ' ';
- $label .= ''.$langs->trans('Ref').': '.$this->ref;
-
- $url = dol_buildpath('/bookcal/booking_card.php', 1).'?id='.$this->id;
-
- if ($option != 'nolink') {
- // Add param to save lastsearch_values or not
- $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
- $add_save_lastsearch_values = 1;
- }
- if ($url && $add_save_lastsearch_values) {
- $url .= '&save_lastsearch_values=1';
- }
- }
-
- $linkclose = '';
- if (empty($notooltip)) {
- if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
- $label = $langs->trans("ShowBooking");
- $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
- }
- $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
- $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
- } else {
- $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
- }
-
- if ($option == 'nolink' || empty($url)) {
- $linkstart = '';
- if ($option == 'nolink' || empty($url)) {
- $linkend = ' ';
- } else {
- $linkend = '';
- }
-
- $result .= $linkstart;
-
- if (empty($this->showphoto_on_popup)) {
- if ($withpicto) {
- $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
- }
- } else {
- if ($withpicto) {
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-
- list($class, $module) = explode('@', $this->picto);
- $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
- $filearray = dol_dir_list($upload_dir, "files");
- $filename = $filearray[0]['name'];
- if (!empty($filename)) {
- $pospoint = strpos($filearray[0]['name'], '.');
-
- $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
- if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) {
- $result .= '';
- } else {
- $result .= '';
- }
-
- $result .= ' ';
- } else {
- $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
- }
- }
- }
-
- if ($withpicto != 2) {
- $result .= $this->ref;
- }
-
- $result .= $linkend;
- //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
-
- global $action, $hookmanager;
- $hookmanager->initHooks(array('bookingdao'));
- $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
- $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
- if ($reshook > 0) {
- $result = $hookmanager->resPrint;
- } else {
- $result .= $hookmanager->resPrint;
- }
-
- return $result;
- }
-
- /**
- * Return the label of the status
- *
- * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
- * @return string Label of status
- */
- public function getLabelStatus($mode = 0)
- {
- return $this->LibStatut($this->status, $mode);
- }
-
- /**
- * Return the label of the status
- *
- * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
- * @return string Label of status
- */
- public function getLibStatut($mode = 0)
- {
- return $this->LibStatut($this->status, $mode);
- }
-
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Return the status
- *
- * @param int $status Id status
- * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
- * @return string Label of status
- */
- public function LibStatut($status, $mode = 0)
- {
- // phpcs:enable
- if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
- global $langs;
- //$langs->load("agenda");
- $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
- $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
- $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
- $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
- $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
- $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
- }
-
- $statusType = 'status'.$status;
- //if ($status == self::STATUS_VALIDATED) $statusType = 'status1';
- if ($status == self::STATUS_CANCELED) {
- $statusType = 'status6';
- }
-
- return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
- }
-
- /**
- * Load the info information in the object
- *
- * @param int $id Id of object
- * @return void
- */
- public function info($id)
- {
- $sql = "SELECT rowid,";
- $sql .= " date_creation as datec, tms as datem,";
- $sql .= " fk_user_creat, fk_user_modif";
- $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
- $sql .= " WHERE t.rowid = ".((int) $id);
-
- $result = $this->db->query($sql);
- if ($result) {
- if ($this->db->num_rows($result)) {
- $obj = $this->db->fetch_object($result);
-
- $this->id = $obj->rowid;
-
- $this->user_creation_id = $obj->fk_user_creat;
- $this->user_modification_id = $obj->fk_user_modif;
- if (!empty($obj->fk_user_valid)) {
- $this->user_validation_id = $obj->fk_user_valid;
- }
- $this->date_creation = $this->db->jdate($obj->datec);
- $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem);
- if (!empty($obj->datev)) {
- $this->date_validation = empty($obj->datev) ? '' : $this->db->jdate($obj->datev);
- }
- }
-
- $this->db->free($result);
- } else {
- dol_print_error($this->db);
- }
- }
-
- /**
- * Initialise object with example values
- * Id must be 0 if object instance is a specimen
- *
- * @return void
- */
- public function initAsSpecimen()
- {
- // Set here init that are not commonf fields
- // $this->property1 = ...
- // $this->property2 = ...
-
- $this->initAsSpecimenCommon();
- }
-
- /**
- * Create an array of lines
- *
- * @return array|int array of lines if OK, <0 if KO
- */
- public function getLinesArray()
- {
- $this->lines = array();
-
- $objectline = new BookingLine($this->db);
- $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_booking = '.((int) $this->id)));
-
- if (is_numeric($result)) {
- $this->error = $objectline->error;
- $this->errors = $objectline->errors;
- return $result;
- } else {
- $this->lines = $result;
- return $this->lines;
- }
- }
-
- /**
- * Returns the reference to the following non used object depending on the active numbering module.
- *
- * @return string Object free reference
- */
- public function getNextNumRef()
- {
- global $langs, $conf;
- $langs->load("agenda");
-
- if (empty($conf->global->BOOKCAL_BOOKING_ADDON)) {
- $conf->global->BOOKCAL_BOOKING_ADDON = 'mod_booking_standard';
- }
-
- if (!empty($conf->global->BOOKCAL_BOOKING_ADDON)) {
- $mybool = false;
-
- $file = $conf->global->BOOKCAL_BOOKING_ADDON.".php";
- $classname = $conf->global->BOOKCAL_BOOKING_ADDON;
-
- // Include file with class
- $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
- foreach ($dirmodels as $reldir) {
- $dir = dol_buildpath($reldir."core/modules/bookcal/");
-
- // Load file with numbering class (if found)
- $mybool |= @include_once $dir.$file;
- }
-
- if ($mybool === false) {
- dol_print_error('', "Failed to include file ".$file);
- return '';
- }
-
- if (class_exists($classname)) {
- $obj = new $classname();
- $numref = $obj->getNextValue($this);
-
- if ($numref != '' && $numref != '-1') {
- return $numref;
- } else {
- $this->error = $obj->error;
- //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
- return "";
- }
- } else {
- print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname;
- return "";
- }
- } else {
- print $langs->trans("ErrorNumberingModuleNotSetup", $this->element);
- return "";
- }
- }
-
- /**
- * Create a document onto disk according to template module.
- *
- * @param string $modele Force template to use ('' to not force)
- * @param Translate $outputlangs objet lang a utiliser pour traduction
- * @param int $hidedetails Hide details of lines
- * @param int $hidedesc Hide description
- * @param int $hideref Hide ref
- * @param null|array $moreparams Array to provide more information
- * @return int 0 if KO, 1 if OK
- */
- public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
- {
- global $conf, $langs;
-
- $result = 0;
- $includedocgeneration = 0;
-
- $langs->load("agenda");
-
- if (!dol_strlen($modele)) {
- $modele = 'standard_booking';
-
- if (!empty($this->model_pdf)) {
- $modele = $this->model_pdf;
- } elseif (!empty($conf->global->BOOKING_ADDON_PDF)) {
- $modele = $conf->global->BOOKING_ADDON_PDF;
- }
- }
-
- $modelpath = "core/modules/bookcal/doc/";
-
- if ($includedocgeneration && !empty($modele)) {
- $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
- }
-
- return $result;
- }
-
- /**
- * Action executed by scheduler
- * CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters'
- * Use public function doScheduledJob($param1, $param2, ...) to get parameters
- *
- * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK)
- */
- public function doScheduledJob()
- {
- global $conf, $langs;
-
- //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
-
- $error = 0;
- $this->output = '';
- $this->error = '';
-
- dol_syslog(__METHOD__, LOG_DEBUG);
-
- $now = dol_now();
-
- $this->db->begin();
-
- // ...
-
- $this->db->commit();
-
- return $error;
- }
-}
-
-
-require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
-
-/**
- * Class BookingLine. You can also remove this and generate a CRUD class for lines objects.
- */
-class BookingLine extends CommonObjectLine
-{
- // To complete with content of an object BookingLine
- // We should have a field rowid, fk_booking and position
-
- /**
- * @var int Does object support extrafields ? 0=No, 1=Yes
- */
- public $isextrafieldmanaged = 0;
-
- /**
- * Constructor
- *
- * @param DoliDb $db Database handler
- */
- public function __construct(DoliDB $db)
- {
- $this->db = $db;
- }
-}
diff --git a/htdocs/bookcal/class/calendar.class.php b/htdocs/bookcal/class/calendar.class.php
index a7a589fb949..38238d00a6b 100644
--- a/htdocs/bookcal/class/calendar.class.php
+++ b/htdocs/bookcal/class/calendar.class.php
@@ -128,6 +128,8 @@ class Calendar extends CommonObject
'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'picto'=>'user', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2, 'csslist'=>'tdoverflowmax150',),
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,),
'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validé', '9'=>'Annulé'), 'validate'=>'1',),
+ 'type' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'arrayofkeyval'=>array('0'=>'Client', '1'=>'Supplier', '3'=>'Autre'),),
+ 'visibility' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Visibility', 'enabled'=>'1', 'position'=>41, 'notnull'=>1, 'visible'=>1,),
);
public $rowid;
public $ref;
@@ -143,6 +145,8 @@ class Calendar extends CommonObject
public $fk_user_modif;
public $import_key;
public $status;
+ public $type;
+ public $visibility;
// END MODULEBUILDER PROPERTIES
@@ -755,7 +759,7 @@ class Calendar extends CommonObject
if ($option !== 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($url && $add_save_lastsearch_values) {
@@ -1016,11 +1020,11 @@ class Calendar extends CommonObject
global $langs, $conf;
$langs->load("bookcal@bookcal");
- if (empty(getDolGlobalString('BOOKCAL_MYOBJECT_ADDON'))) {
+ if (getDolGlobalString('BOOKCAL_MYOBJECT_ADDON')) {
$conf->global->BOOKCAL_MYOBJECT_ADDON = 'mod_calendar_standard';
}
- if (!empty(getDolGlobalString('BOOKCAL_MYOBJECT_ADDON'))) {
+ if (getDolGlobalString('BOOKCAL_MYOBJECT_ADDON')) {
$mybool = false;
$file = getDolGlobalString('BOOKCAL_MYOBJECT_ADDON').".php";
diff --git a/htdocs/bookcal/lib/bookcal_booking.lib.php b/htdocs/bookcal/lib/bookcal_booking.lib.php
deleted file mode 100644
index c0dec7d6d2e..00000000000
--- a/htdocs/bookcal/lib/bookcal_booking.lib.php
+++ /dev/null
@@ -1,110 +0,0 @@
-
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see
.
- */
-
-/**
- * \file lib/bookcal_booking.lib.php
- * \ingroup bookcal
- * \brief Library files with common functions for Booking
- */
-
-/**
- * Prepare array of tabs for Booking
- *
- * @param Booking $object Booking
- * @return array Array of tabs
- */
-function bookingPrepareHead($object)
-{
- global $db, $langs, $conf;
-
- $langs->load("agenda");
-
- $showtabofpagecontact = 1;
- $showtabofpagenote = 1;
- $showtabofpagedocument = 1;
- $showtabofpageagenda = 1;
-
- $h = 0;
- $head = array();
-
- $head[$h][0] = dol_buildpath("/bookcal/booking_card.php", 1).'?id='.$object->id;
- $head[$h][1] = $langs->trans("Card");
- $head[$h][2] = 'card';
- $h++;
-
- if ($showtabofpagecontact) {
- $head[$h][0] = dol_buildpath("/bookcal/booking_contact.php", 1).'?id='.$object->id;
- $head[$h][1] = $langs->trans("Contacts");
- $head[$h][2] = 'contact';
- $h++;
- }
-
- if ($showtabofpagenote) {
- if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
- $nbNote = 0;
- if (!empty($object->note_private)) {
- $nbNote++;
- }
- if (!empty($object->note_public)) {
- $nbNote++;
- }
- $head[$h][0] = dol_buildpath('/bookcal/booking_note.php', 1).'?id='.$object->id;
- $head[$h][1] = $langs->trans('Notes');
- if ($nbNote > 0) {
- $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '
'.$nbNote.' ' : '');
- }
- $head[$h][2] = 'note';
- $h++;
- }
- }
-
- if ($showtabofpagedocument) {
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
- require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
- $upload_dir = $conf->bookcal->dir_output."/booking/".dol_sanitizeFileName($object->ref);
- $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
- $nbLinks = Link::count($db, $object->element, $object->id);
- $head[$h][0] = dol_buildpath("/bookcal/booking_document.php", 1).'?id='.$object->id;
- $head[$h][1] = $langs->trans('Documents');
- if (($nbFiles + $nbLinks) > 0) {
- $head[$h][1] .= '
'.($nbFiles + $nbLinks).' ';
- }
- $head[$h][2] = 'document';
- $h++;
- }
-
- if ($showtabofpageagenda) {
- $head[$h][0] = dol_buildpath("/bookcal/booking_agenda.php", 1).'?id='.$object->id;
- $head[$h][1] = $langs->trans("Events");
- $head[$h][2] = 'agenda';
- $h++;
- }
-
- // Show more tabs from modules
- // Entries must be declared in modules descriptor with line
- //$this->tabs = array(
- // 'entity:+tabname:Title:@bookcal:/bookcal/mypage.php?id=__ID__'
- //); // to add new tab
- //$this->tabs = array(
- // 'entity:-tabname:Title:@bookcal:/bookcal/mypage.php?id=__ID__'
- //); // to remove a tab
- complete_head_from_modules($conf, $langs, $object, $head, $h, 'booking@bookcal');
-
- complete_head_from_modules($conf, $langs, $object, $head, $h, 'booking@bookcal', 'remove');
-
- return $head;
-}
diff --git a/htdocs/bookmarks/class/bookmark.class.php b/htdocs/bookmarks/class/bookmark.class.php
index 389603fb161..c131aa80b25 100644
--- a/htdocs/bookmarks/class/bookmark.class.php
+++ b/htdocs/bookmarks/class/bookmark.class.php
@@ -49,11 +49,6 @@ class Bookmark extends CommonObject
*/
public $picto = 'bookmark';
- /**
- * @var DoliDB Database handler.
- */
- public $db;
-
/**
* Last error code on a local method
* @var int Error number
@@ -313,7 +308,7 @@ class Bookmark extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php
index 3f9524d3f6e..22d4e0f1958 100644
--- a/htdocs/categories/class/categorie.class.php
+++ b/htdocs/categories/class/categorie.class.php
@@ -264,6 +264,20 @@ class Categorie extends CommonObject
*/
public $childs = array();
+ /**
+ * @var array multilangs
+ */
+ public $multilangs;
+
+ /**
+ * @var int imgWidth
+ */
+ public $imgWidth;
+
+ /**
+ * @var int imgHeight
+ */
+ public $imgHeight;
/**
* Constructor
@@ -1886,27 +1900,27 @@ class Categorie extends CommonObject
} else {
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)";
$sql2 .= " VALUES(".((int) $this->id).", '".$this->db->escape($key)."', '".$this->db->escape($this->label)."'";
- $sql2 .= ", '".$this->db->escape($this->multilangs["$key"]["description"])."')";
+ $sql2 .= ", '".$this->db->escape($this->multilangs[$key]["description"])."')";
}
dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG);
if (!$this->db->query($sql2)) {
$this->error = $this->db->lasterror();
return -1;
}
- } elseif (isset($this->multilangs["$key"])) {
+ } elseif (isset($this->multilangs[$key])) {
if ($this->db->num_rows($result)) { // si aucune ligne dans la base
$sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang";
- $sql2 .= " SET label='".$this->db->escape($this->multilangs["$key"]["label"])."',";
- $sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'";
+ $sql2 .= " SET label='".$this->db->escape($this->multilangs[$key]["label"])."',";
+ $sql2 .= " description='".$this->db->escape($this->multilangs[$key]["description"])."'";
$sql2 .= " WHERE fk_category=".((int) $this->id)." AND lang='".$this->db->escape($key)."'";
} else {
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)";
- $sql2 .= " VALUES(".((int) $this->id).", '".$this->db->escape($key)."', '".$this->db->escape($this->multilangs["$key"]["label"])."'";
- $sql2 .= ",'".$this->db->escape($this->multilangs["$key"]["description"])."')";
+ $sql2 .= " VALUES(".((int) $this->id).", '".$this->db->escape($key)."', '".$this->db->escape($this->multilangs[$key]["label"])."'";
+ $sql2 .= ",'".$this->db->escape($this->multilangs[$key]["description"])."')";
}
// on ne sauvegarde pas des champs vides
- if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"] || $this->multilangs["$key"]["note"]) {
+ if ($this->multilangs[$key]["label"] || $this->multilangs[$key]["description"] || $this->multilangs[$key]["note"]) {
dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG);
}
if (!$this->db->query($sql2)) {
@@ -1950,8 +1964,8 @@ class Categorie extends CommonObject
$this->label = $obj->label;
$this->description = $obj->description;
}
- $this->multilangs["$obj->lang"]["label"] = $obj->label;
- $this->multilangs["$obj->lang"]["description"] = $obj->description;
+ $this->multilangs[$obj->lang]["label"] = $obj->label;
+ $this->multilangs[$obj->lang]["description"] = $obj->description;
}
return 1;
} else {
diff --git a/htdocs/categories/info.php b/htdocs/categories/info.php
index f5f63091f9c..382442030e1 100644
--- a/htdocs/categories/info.php
+++ b/htdocs/categories/info.php
@@ -74,7 +74,7 @@ print dol_get_fiche_head($head, 'info', $langs->trans($title), -1, 'category');
$backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.urlencode($type));
$linkback = '
'.$langs->trans("BackToList").' ';
-$object->next_prev_filter = ' type = '.$object->type;
+$object->next_prev_filter = 'type = '.((int) $object->type);
$object->ref = $object->label;
$morehtmlref = '
'.$langs->trans("Root").' >> ';
$ways = $object->print_all_ways(" >> ", '', 1);
diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php
index bd98afb87f7..ab47eb0088d 100644
--- a/htdocs/categories/photos.php
+++ b/htdocs/categories/photos.php
@@ -111,7 +111,7 @@ if ($object->id) {
$backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.urlencode($type));
$linkback = '
'.$langs->trans("BackToList").' ';
- $object->next_prev_filter = ' type = '.$object->type;
+ $object->next_prev_filter = 'type = '.((int) $object->type);
$object->ref = $object->label;
$morehtmlref = '
'.$langs->trans("Root").' >> ';
$ways = $object->print_all_ways(" >> ", '', 1);
diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php
index b63431780e7..9791cdeb5be 100644
--- a/htdocs/categories/traduction.php
+++ b/htdocs/categories/traduction.php
@@ -189,7 +189,7 @@ print dol_get_fiche_head($head, 'translation', $langs->trans($title), -1, 'categ
$backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.urlencode($type));
$linkback = '
'.$langs->trans("BackToList").' ';
-$object->next_prev_filter = ' type = '.$object->type;
+$object->next_prev_filter = 'type = '.((int) $object->type);
$object->ref = $object->label;
$morehtmlref = '
'.$langs->trans("Root").' >> ';
$ways = $object->print_all_ways(" >> ", '', 1);
diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php
index 2791cf1556a..707c23dfe5e 100644
--- a/htdocs/categories/viewcat.php
+++ b/htdocs/categories/viewcat.php
@@ -257,7 +257,7 @@ print dol_get_fiche_head($head, 'card', $langs->trans($title), -1, 'category');
$backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.urlencode($type));
$linkback = '
'.$langs->trans("BackToList").' ';
-$object->next_prev_filter = ' type = '.$object->type;
+$object->next_prev_filter = 'type = '.((int) $object->type);
$object->ref = $object->label;
$morehtmlref = '
'.$langs->trans("Root").' >> ';
$ways = $object->print_all_ways(" >> ", '', 1);
diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php
index a6c00785c31..2b0745c2eb2 100644
--- a/htdocs/comm/action/card.php
+++ b/htdocs/comm/action/card.php
@@ -94,7 +94,7 @@ if (GETPOST('datep')) {
if (GETPOST('datep') == 'now') {
$datep = dol_now();
} elseif (preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])$/', GETPOST("datep"), $reg)) { // Try to not use this. Use insteead '&datep=now'
- $datep = dol_mktime(0, 0, 0, $reg[2], $reg[3], $reg[1], 'tzuser');
+ $datep = dol_mktime(0, 0, 0, $reg[2], $reg[3], $reg[1], 'tzuserrel');
}
}
@@ -546,21 +546,21 @@ if (empty($reshook) && $action == 'add') {
// We set first date of recurrence and offsets
if ($selectedrecurrulefreq == 'WEEKLY' && !empty($selectedrecurrulebyday)) {
$firstdatearray = dol_get_first_day_week(GETPOST("apday", 'int'), GETPOST("apmonth", 'int'), GETPOST("apyear", 'int'));
- $datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), $firstdatearray['month'], $firstdatearray['first_day'], $firstdatearray['year'], $tzforfullday ? $tzforfullday : 'tzuser');
+ $datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), $firstdatearray['month'], $firstdatearray['first_day'], $firstdatearray['year'], $tzforfullday ? $tzforfullday : 'tzuserrel');
$datep = dol_time_plus_duree($datep, $selectedrecurrulebyday + 6, 'd');//We begin the week after
$dayoffset = 7;
$monthoffset = 0;
} elseif ($selectedrecurrulefreq == 'MONTHLY' && !empty($selectedrecurrulebymonthday)) {
$firstday = $selectedrecurrulebymonthday;
$firstmonth = GETPOST("apday") > $selectedrecurrulebymonthday ? GETPOST("apmonth", 'int') + 1 : GETPOST("apmonth", 'int');//We begin the week after
- $datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), $firstmonth, $firstday, GETPOST("apyear", 'int'), $tzforfullday ? $tzforfullday : 'tzuser');
+ $datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), $firstmonth, $firstday, GETPOST("apyear", 'int'), $tzforfullday ? $tzforfullday : 'tzuserrel');
$dayoffset = 0;
$monthoffset = 1;
} else {
$error++;
}
// End date
- $repeateventlimitdate = dol_mktime(23, 59, 59, GETPOSTISSET("limitmonth") ? GETPOST("limitmonth", 'int') : 1, GETPOSTISSET("limitday") ? GETPOST("limitday", 'int') : 1, GETPOSTISSET("limityear") && GETPOST("limityear", 'int') < 2100 ? GETPOST("limityear", 'int') : 2100, $tzforfullday ? $tzforfullday : 'tzuser');
+ $repeateventlimitdate = dol_mktime(23, 59, 59, GETPOSTISSET("limitmonth") ? GETPOST("limitmonth", 'int') : 1, GETPOSTISSET("limitday") ? GETPOST("limitday", 'int') : 1, GETPOSTISSET("limityear") && GETPOST("limityear", 'int') < 2100 ? GETPOST("limityear", 'int') : 2100, $tzforfullday ? $tzforfullday : 'tzuserrel');
// Set date of end of event
$deltatime = num_between_day($object->datep, $datep);
$datef = dol_time_plus_duree($datef, $deltatime, 'd');
@@ -705,11 +705,11 @@ if (empty($reshook) && $action == 'update') {
if ($fulldayevent) {
$tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
// For "full day" events, we must store date in GMT (It must be viewed as same moment everywhere)
- $datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), $tzforfullday ? $tzforfullday : 'tzuser');
- $datef = dol_mktime($fulldayevent ? '23' : GETPOST("p2hour", 'int'), $fulldayevent ? '59' : GETPOST("p2min", 'int'), $fulldayevent ? '59' : GETPOST("apsec", 'int'), GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), $tzforfullday ? $tzforfullday : 'tzuser');
+ $datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), $tzforfullday ? $tzforfullday : 'tzuserrel');
+ $datef = dol_mktime($fulldayevent ? '23' : GETPOST("p2hour", 'int'), $fulldayevent ? '59' : GETPOST("p2min", 'int'), $fulldayevent ? '59' : GETPOST("apsec", 'int'), GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), $tzforfullday ? $tzforfullday : 'tzuserrel');
} else {
- $datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), 'tzuser');
- $datef = dol_mktime($fulldayevent ? '23' : GETPOST("p2hour", 'int'), $fulldayevent ? '59' : GETPOST("p2min", 'int'), $fulldayevent ? '59' : GETPOST("apsec", 'int'), GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), 'tzuser');
+ $datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), 'tzuserrel');
+ $datef = dol_mktime($fulldayevent ? '23' : GETPOST("p2hour", 'int'), $fulldayevent ? '59' : GETPOST("p2min", 'int'), $fulldayevent ? '59' : GETPOST("apsec", 'int'), GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), 'tzuserrel');
}
if ($object->elementtype == 'ticket') { // code should be TICKET_MSG, TICKET_MSG_PRIVATE, TICKET_MSG_SENTBYMAIL, TICKET_MSG_PRIVATE_SENTBYMAIL
@@ -1310,11 +1310,11 @@ if ($action == 'create') {
$datep = ($datep ? $datep : (is_null($object->datep) ? '' : $object->datep));
if (GETPOST('datep', 'int', 1)) {
- $datep = dol_stringtotime(GETPOST('datep', 'int', 1), 'tzuser');
+ $datep = dol_stringtotime(GETPOST('datep', 'int', 1), 'tzuserrel');
}
$datef = ($datef ? $datef : $object->datef);
if (GETPOST('datef', 'int', 1)) {
- $datef = dol_stringtotime(GETPOST('datef', 'int', 1), 'tzuser');
+ $datef = dol_stringtotime(GETPOST('datef', 'int', 1), 'tzuserrel');
}
if (empty($datef) && !empty($datep)) {
if (GETPOST("actioncode", 'aZ09') == 'AC_RDV' || empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT)) {
@@ -1332,9 +1332,9 @@ if ($action == 'create') {
}
print '
- ';
if (GETPOST("afaire") == 1) {
- print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel');
+ print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel');
} else {
- print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel');
+ print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel');
}
print '
';
@@ -1629,8 +1629,8 @@ if ($id > 0) {
if ($listUserAssignedUpdated || $donotclearsession) {
$percentage = in_array(GETPOST('status'), array(-1, 100)) ? GETPOST('status') : (in_array($complete, array(-1, 100)) ? $complete : GETPOST("percentage", 'int')); // If status is -1 or 100, percentage is not defined and we must use status
- $datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), 'tzuser');
- $datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), 'tzuser');
+ $datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), 'tzuserrel');
+ $datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), 'tzuserrel');
$object->type_id = dol_getIdFromCode($db, GETPOST("actioncode", 'aZ09'), 'c_actioncomm');
$object->label = GETPOST("label", "alphanohtml");
diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php
index 92299a54312..167ca6780be 100644
--- a/htdocs/comm/action/class/actioncomm.class.php
+++ b/htdocs/comm/action/class/actioncomm.class.php
@@ -300,6 +300,11 @@ class ActionComm extends CommonObject
*/
public $elementtype;
+ /**
+ * @var int id of availability
+ */
+ public $fk_bookcal_availability;
+
/**
* @var string Ical name
*/
@@ -539,6 +544,7 @@ class ActionComm extends CommonObject
$sql .= "transparency,";
$sql .= "fk_element,";
$sql .= "elementtype,";
+ $sql .= "fk_bookcal_availability,";
$sql .= "entity,";
$sql .= "extraparams,";
// Fields emails
@@ -581,6 +587,7 @@ class ActionComm extends CommonObject
$sql .= "'".$this->db->escape($this->transparency)."', ";
$sql .= (!empty($this->fk_element) ? ((int) $this->fk_element) : "null").", ";
$sql .= (!empty($this->elementtype) ? "'".$this->db->escape($this->elementtype)."'" : "null").", ";
+ $sql .= (!empty($this->fk_bookcal_availability) ? "'".$this->db->escape($this->fk_bookcal_availability)."'" : "null").", ";
$sql .= ((int) $conf->entity).",";
$sql .= (!empty($this->extraparams) ? "'".$this->db->escape($this->extraparams)."'" : "null").", ";
// Fields emails
@@ -647,7 +654,7 @@ class ActionComm extends CommonObject
if (!empty($this->socpeopleassigned)) {
$already_inserted = array();
foreach ($this->socpeopleassigned as $id => $val) {
- // Common value with new behavior is to have $val = iduser and $this->socpeopleassigned is an array of iduser => $val.
+ // Common value with new behavior is to have $this->socpeopleassigned an array of idcontact => dummyvalue
if (!empty($already_inserted[$id])) {
continue;
}
@@ -1314,7 +1321,7 @@ class ActionComm extends CommonObject
* @param string $sortfield Sort on this field
* @param string $sortorder ASC or DESC
* @param string $limit Limit number of answers
- * @return array|string Error string if KO, array with actions if OK
+ * @return ActionComm[]|string Error string if KO, array with actions if OK
*/
public function getActions($socid = 0, $fk_element = 0, $elementtype = '', $filter = '', $sortfield = 'a.datep', $sortorder = 'DESC', $limit = 0)
{
@@ -1729,7 +1736,7 @@ class ActionComm extends CommonObject
}
if (!empty($this->note_private)) {
$tooltip .= ''.$langs->trans('Description').': ';
- $texttoshow = dolGetFirstLineOfText($this->note_private, 10); // Try to limit length of content
+ $texttoshow = dolGetFirstLineOfText($this->note_private, 8); // Try to limit length of content
$tooltip .= ''; // Restrict height of content into the tooltip
$tooltip .= (dol_textishtml($texttoshow) ? str_replace(array("\r", "\n"), "", $texttoshow) : str_replace(array("\r", "\n"), ' ', $texttoshow));
$tooltip .= '
';
@@ -1750,13 +1757,12 @@ class ActionComm extends CommonObject
}
//if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && $this->type_color)
// $linkclose = ' style="background-color:#'.$this->type_color.'"';
-
if (empty($notooltip)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("ShowAction");
$linkclose .= ' alt="'.dol_escape_htmltag($tooltip, 1).'"';
}
- $linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"');
+ $linkclose .= ($tooltip ? ' title="'.dol_escape_htmltag($tooltip, 1).'"' : ' title="tocomplete"');
$linkclose .= $dataparams.' class="'.$classname.' '.$classfortooltip.'"';
} else {
$linkclose .= ' class="'.$classname.'"';
@@ -1774,7 +1780,7 @@ class ActionComm extends CommonObject
if ($option !== 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
@@ -1817,7 +1823,7 @@ class ActionComm extends CommonObject
$result .= $linkstart;
if ($withpicto) {
- $result .= img_object(($notooltip ? '' : $langs->trans("ShowAction").': '.$label), ($overwritepicto ? $overwritepicto : 'action'), (($this->type_color && $overwritepicto) ? 'style="color: #'.$this->type_color.' !important;" ' : '').($notooltip ? 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"' : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
+ $result .= img_object(($notooltip ? '' : $langs->trans("ShowAction").': '.$label), ($overwritepicto ? $overwritepicto : 'action'), (($this->type_color && $overwritepicto) ? 'style="color: #'.$this->type_color.' !important;" ' : '').($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : ' class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1);
}
$result .= dol_escape_htmltag($labelshort);
$result .= $linkend;
@@ -1838,9 +1844,11 @@ class ActionComm extends CommonObject
/**
* Return Picto of type of event
*
+ * @param string $morecss More CSS
+ * @param string $titlealt Title alt
* @return string HTML String
*/
- public function getTypePicto()
+ public function getTypePicto($morecss = 'pictofixedwidth paddingright', $titlealt = '')
{
global $conf;
@@ -1851,34 +1859,35 @@ class ActionComm extends CommonObject
$color = 'style="color: #'.$this->type_color.' !important;"';
}
if ($this->type_picto) {
- $imgpicto = img_picto('', $this->type_picto, 'class="paddingright"');
+ $imgpicto = img_picto($titlealt, $this->type_picto, '', false, 0, 0, '', ($morecss ? ' '.$morecss : ''));
} else {
if ($this->type_code == 'AC_RDV') {
- $imgpicto = img_picto('', 'meeting', $color, false, 0, 0, '', 'paddingright');
+ $imgpicto = img_picto($titlealt, 'meeting', $color, false, 0, 0, '', ($morecss ? ' '.$morecss : ''));
} elseif ($this->type_code == 'AC_TEL') {
- $imgpicto = img_picto('', 'object_phoning', $color, false, 0, 0, '', 'paddingright');
+ $imgpicto = img_picto($titlealt, 'object_phoning', $color, false, 0, 0, '', ($morecss ? ' '.$morecss : ''));
} elseif ($this->type_code == 'AC_FAX') {
- $imgpicto = img_picto('', 'object_phoning_fax', $color, false, 0, 0, '', 'paddingright');
+ $imgpicto = img_picto($titlealt, 'object_phoning_fax', $color, false, 0, 0, '', ($morecss ? ' '.$morecss : ''));
} elseif ($this->type_code == 'AC_EMAIL' || $this->type_code == 'AC_EMAIL_IN' || (!empty($this->code) && preg_match('/_SENTBYMAIL/', $this->code))) {
- $imgpicto = img_picto('', 'object_email', $color, false, 0, 0, '', 'paddingright');
+ $imgpicto = img_picto($titlealt, 'object_email', $color, false, 0, 0, '', ($morecss ? ' '.$morecss : ''));
} elseif ($this->type_code == 'AC_INT') {
- $imgpicto = img_picto('', 'object_intervention', $color, false, 0, 0, '', 'paddingright');
+ $imgpicto = img_picto($titlealt, 'object_intervention', $color, false, 0, 0, '', ($morecss ? ' '.$morecss : ''));
} elseif (!empty($this->code) && preg_match('/^TICKET_MSG/', $this->code)) {
- $imgpicto = img_picto('', 'object_conversation', $color, false, 0, 0, '', 'paddingright');
+ $imgpicto = img_picto($titlealt, 'object_conversation', $color, false, 0, 0, '', ($morecss ? ' '.$morecss : ''));
} elseif ($this->type != 'systemauto') {
- $imgpicto = img_picto('', 'user-cog', $color, false, 0, 0, '', 'paddingright');
+ $imgpicto = img_picto($titlealt, 'user-cog', $color, false, 0, 0, '', ($morecss ? ' '.$morecss : ''));
} else {
- $imgpicto = img_picto('', 'cog', $color, false, 0, 0, '', 'paddingright');
+ $imgpicto = img_picto($titlealt, 'cog', $color, false, 0, 0, '', ($morecss ? ' '.$morecss : ''));
}
}
} else {
// 2 picto: 1 for auto, 1 for manual
if ($this->type != 'systemauto') {
- $imgpicto = img_picto('', 'user-cog', '', false, 0, 0, '', 'paddingright');
+ $imgpicto = img_picto($titlealt, 'user-cog', '', false, 0, 0, '', ($morecss ? ' '.$morecss : ''));
} else {
- $imgpicto = img_picto('', 'cog', '', false, 0, 0, '', 'paddingright');
+ $imgpicto = img_picto($titlealt, 'cog', '', false, 0, 0, '', ($morecss ? ' '.$morecss : ''));
}
}
+
return $imgpicto;
}
diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php
index 7316ee3daaf..3e00699f5fb 100644
--- a/htdocs/comm/action/index.php
+++ b/htdocs/comm/action/index.php
@@ -557,6 +557,34 @@ if ($user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allac
$s = ''; $link = '';
$showextcals = $listofextcals;
+$bookcalcalendars = array();
+
+// Load Bookcal Calendars
+if (isModEnabled("bookcal")) {
+ $sql = "SELECT ba.rowid, bc.label, bc.ref, bc.rowid as id_cal";
+ $sql .= " FROM ".MAIN_DB_PREFIX."bookcal_availabilities as ba";
+ $sql .= " JOIN ".MAIN_DB_PREFIX."bookcal_calendar as bc";
+ $sql .= " ON bc.rowid = ba.fk_bookcal_calendar";
+ $sql .= " WHERE bc.status = 1";
+ $sql .= " AND ba.status = 1";
+ if (!empty($filtert) && $filtert != -1) {
+ $sql .= " AND bc.visibility = ".(int) $filtert ;
+ }
+ $resql = $db->query($sql);
+ if ($resql) {
+ $num = $db->num_rows($resql);
+ $i = 0;
+ while ($i < $num) {
+ $objp = $db->fetch_object($resql);
+ $label = !empty($objp->label) ? $objp->label : $objp->ref;
+ $bookcalcalendars["calendars"][] = array("id" => $objp->id_cal, "label" => $label);
+ $bookcalcalendars["availabilitieslink"][$objp->rowid] = $objp->id_cal;
+ $i++;
+ }
+ } else {
+ dol_print_error($db);
+ }
+}
if (!empty($conf->use_javascript_ajax)) { // If javascript on
$s .= "\n".''."\n";
@@ -564,6 +592,11 @@ if (!empty($conf->use_javascript_ajax)) { // If javascript on
$s .= 'jQuery(document).ready(function () {'."\n";
$s .= 'jQuery(".check_birthday").click(function() { console.log("Toggle birthdays"); jQuery(".family_birthday").toggle(); });'."\n";
$s .= 'jQuery(".check_holiday").click(function() { console.log("Toggle holidays"); jQuery(".family_holiday").toggle(); });'."\n";
+ if (isModEnabled("bookcal")) {
+ foreach ($bookcalcalendars["calendars"] as $key => $value) {
+ $s .= 'jQuery(".check_bookcal_calendar_'.$value['id'].'").click(function() { console.log("Toggle Bookcal Calendar '.$value['id'].'"); jQuery(".family_bookcal_calendar_'.$value['id'].'").toggle(); });'."\n";
+ }
+ }
if ($mode == "show_week" || $mode == "show_month" || empty($mode)) {
// Code to enable drag and drop
$s .= 'jQuery( "div.sortable" ).sortable({connectWith: ".sortable", placeholder: "ui-state-highlight", items: "div.movable", receive: function( event, ui ) {'."\n";
@@ -631,6 +664,14 @@ if (!empty($conf->use_javascript_ajax)) { // If javascript on
// Birthdays
$s .= ' '.$langs->trans("AgendaShowBirthdayEvents").'
';
+ // Bookcal Calendar
+ if (isModEnabled("bookcal")) {
+ foreach ($bookcalcalendars["calendars"] as $key => $value) {
+ $label = $value['label'];
+ $s .= ' '.$langs->trans("AgendaShowBookcalCalendar", $label).'
';
+ }
+ }
+
// Calendars from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action);
@@ -673,7 +714,7 @@ $sql .= ' a.datep2,';
$sql .= ' a.percent,';
$sql .= ' a.fk_user_author,a.fk_user_action,';
$sql .= ' a.transparency, a.priority, a.fulldayevent, a.location,';
-$sql .= ' a.fk_soc, a.fk_contact, a.fk_project,';
+$sql .= ' a.fk_soc, a.fk_contact, a.fk_project, a.fk_bookcal_availability,';
$sql .= ' a.fk_element, a.elementtype,';
$sql .= ' ca.code as type_code, ca.libelle as type_label, ca.color as type_color, ca.type as type_type, ca.picto as type_picto';
$sql .= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a";
@@ -862,6 +903,10 @@ if ($resql) {
$event->socid = $obj->fk_soc;
$event->contact_id = $obj->fk_contact;
+ $event->fk_bookcal_availability = $obj->fk_bookcal_availability;
+ if (!empty($event->fk_bookcal_availability)) {
+ $event->type = "bookcal_calendar";
+ }
// Defined date_start_in_calendar and date_end_in_calendar property
// They are date start and end of action but modified to not be outside calendar view.
@@ -1505,7 +1550,7 @@ if (empty($mode) || $mode == 'show_month') { // View by month
}
//var_dump($todayarray['mday']."==".$tmpday." && ".$todayarray['mon']."==".$month." && ".$todayarray['year']."==".$year.' -> '.$style);
echo ' ';
- show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
+ show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam, 0, 60, 0, $bookcalcalendars);
echo " \n";
} else {
/* Show days after the current month (next month) */
@@ -1578,7 +1623,7 @@ if (empty($mode) || $mode == 'show_month') { // View by month
}
echo ' ';
- show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300);
+ show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0, $bookcalcalendars);
echo " \n";
}
echo " \n";
@@ -1668,13 +1713,13 @@ if (empty($mode) || $mode == 'show_month') { // View by month
echo '';
- show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1);
+ show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1, $bookcalcalendars);
print '';
} else {
print ''; // You can use div-table-responsive-no-min if you dont need reserved height for your table
- show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0);
+ show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0, $bookcalcalendars);
print '
';
}
@@ -1703,9 +1748,10 @@ $db->close();
* @param int $showinfo Add extended information (used by day and week view)
* @param int $minheight Minimum height for each event. 60px by default.
* @param string $nonew 0=Add "new entry button", 1=No "new entry button", -1=Only "new entry button"
+ * @param string $bookcalcalendarsarray Used for Bookcal module array of calendar of bookcal
* @return void
*/
-function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam = '', $showinfo = 0, $minheight = 60, $nonew = 0)
+function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam = '', $showinfo = 0, $minheight = 60, $nonew = 0, $bookcalcalendarsarray = array())
{
global $user, $conf, $langs;
global $action, $mode, $filter, $filtert, $status, $actioncode, $usergroup; // Filters used into search form
@@ -1817,6 +1863,11 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
$colorindex = 2;
$cssclass = 'family_birthday ';
$color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
+ } elseif ($event->type == 'bookcal_calendar') {
+ $numbirthday++;
+ $colorindex = 3;
+ $cssclass = 'family_bookcal_calendar_'.(!empty($bookcalcalendarsarray["availabilitieslink"]) ? $bookcalcalendarsarray["availabilitieslink"][$event->fk_bookcal_availability] : "");
+ $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
} else {
$numother++;
$color = ($event->icalcolor ? $event->icalcolor : -1);
@@ -1904,6 +1955,9 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
if ($event->type == 'holiday' && !GETPOST('check_holiday')) {
$morecss = 'hidden';
}
+ if ($event->type == 'bookcal_calendar' && !GETPOST('check_bookcal_calendar_'.$bookcalcalendarsarray["availabilitieslink"][$event->fk_bookcal_availability])) {
+ $morecss = 'hidden';
+ }
if ($morecss != 'hidden') {
$itoshow++;
}
@@ -1911,8 +1965,11 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
$ireallyshown++;
}
//var_dump($event->type.' - '.$morecss.' - '.$cssclass.' - '.$i.' - '.$ireallyshown.' - '.$itoshow);
-
- print 'type == 'bookcal_calendar') {
+ print '
fk_bookcal_availability].' '.$cssclass.($morecss ? ' '.$morecss : '').'"';
+ } else {
+ print '
* Copyright (C) 2014 Cedric GROSS
* Copyright (C) 2018-2019 Frédéric France
+ * Copyright (C) 2023 Florian HENRY
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -527,19 +528,19 @@ $eventarray = array();
// DEFAULT CALENDAR + AUTOEVENT CALENDAR + CONFERENCEBOOTH CALENDAR
-$sql = 'SELECT';
+$sql = "SELECT";
if ($usergroup > 0) {
$sql .= " DISTINCT";
}
-$sql .= ' a.id, a.label,';
-$sql .= ' a.datep,';
-$sql .= ' a.datep2,';
-$sql .= ' a.percent,';
-$sql .= ' a.fk_user_author,a.fk_user_action,';
-$sql .= ' a.transparency, a.priority, a.fulldayevent, a.location,';
-$sql .= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,';
-$sql .= ' ca.code, ca.libelle as type_label, ca.color, ca.type as type_type, ca.picto as type_picto';
-$sql .= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a";
+$sql .= " a.id, a.label,";
+$sql .= " a.datep,";
+$sql .= " a.datep2,";
+$sql .= " a.percent,";
+$sql .= " a.fk_user_author,a.fk_user_action,";
+$sql .= " a.transparency, a.priority, a.fulldayevent, a.location,";
+$sql .= " a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,";
+$sql .= " ca.code, ca.libelle as type_label, ca.color, ca.type as type_type, ca.picto as type_picto";
+$sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm as ca, ".MAIN_DB_PREFIX."actioncomm as a";
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
}
@@ -549,13 +550,18 @@ if ($resourceid > 0) {
}
// We must filter on assignement table
if ($filtert > 0 || $usergroup > 0) {
- $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
+ $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as ar";
+ $sql .= " ON ar.fk_actioncomm = a.id AND ar.element_type='user'";
+ if ($filtert > 0) {
+ $sql .= " AND ar.fk_element = ".((int) $filtert);
+ }
+ if ($usergroup > 0) {
+ $sql .= " INNER JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element AND ugu.fk_usergroup = ".((int) $usergroup);
+ }
}
-if ($usergroup > 0) {
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
-}
-$sql .= ' WHERE a.fk_action = ca.id';
-$sql .= ' AND a.entity IN ('.getEntity('agenda').')';
+
+$sql .= " WHERE a.fk_action = ca.id";
+$sql .= " AND a.entity IN (".getEntity('agenda').")";
// Condition on actioncode
if (!empty($actioncode)) {
if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
@@ -595,12 +601,9 @@ if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).")";
}
if ($socid > 0) {
- $sql .= ' AND a.fk_soc = '.((int) $socid);
-}
-// We must filter on assignement table
-if ($filtert > 0 || $usergroup > 0) {
- $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
+ $sql .= " AND a.fk_soc = ".((int) $socid);
}
+
if ($mode == 'show_day') {
$sql .= " AND (";
$sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel'))."'";
@@ -611,7 +614,7 @@ if ($mode == 'show_day') {
$sql .= " OR ";
$sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel'))."'";
$sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year, 'tzuserrel'))."')";
- $sql .= ')';
+ $sql .= ")";
} else {
// To limit array
$sql .= " AND (";
@@ -623,7 +626,7 @@ if ($mode == 'show_day') {
$sql .= " OR ";
$sql .= " (a.datep < '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'";
$sql .= " AND a.datep2 > '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')";
- $sql .= ')';
+ $sql .= ")";
}
if ($type) {
$sql .= " AND ca.id = ".((int) $type);
@@ -645,19 +648,8 @@ if ($status == 'done' || $status == '100') {
if ($status == 'todo') {
$sql .= " AND (a.percent >= 0 AND a.percent < 100)";
}
-// We must filter on assignement table
-if ($filtert > 0 || $usergroup > 0) {
- $sql .= " AND (";
- if ($filtert > 0) {
- $sql .= "ar.fk_element = ".$filtert;
- }
- if ($usergroup > 0) {
- $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".((int) $usergroup);
- }
- $sql .= ")";
-}
// Sort on date
-$sql .= ' ORDER BY fk_user_action, datep'; //fk_user_action
+$sql .= $db->order("fk_user_action, datep");
//print $sql;
dol_syslog("comm/action/peruser.php", LOG_DEBUG);
@@ -1050,6 +1042,8 @@ print "\n";
print ''.$this->select_state($selected, $country_codeid, $htmlname, $morecss).' ';
+ }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php
index faa8251ad0a..33694e798e6 100644
--- a/htdocs/core/class/html.formcontract.class.php
+++ b/htdocs/core/class/html.formcontract.class.php
@@ -188,15 +188,13 @@ class FormContract
* @param int $showempty Show empty line
* @param int $showRef Show customer and supplier reference on each contract (when found)
* @param int $noouput 1=Return the output instead of display
- * @return int Nbr of project if OK, <0 if KO
+ * @return string|void html string
*/
public function formSelectContract($page, $socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1, $showRef = 0, $noouput = 0)
{
global $langs;
- $ret = '';
-
- $ret .= '';
+ $ret = ' ';
$ret .= ' ';
$ret .= ' ';
$ret .= $this->select_contract($socid, $selected, $htmlname, $maxlength, $showempty, $showRef, 1);
@@ -208,7 +206,5 @@ class FormContract
}
print $ret;
-
- return $result;
}
}
diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index bb4bb5032d5..1b3f335e8b4 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -585,7 +585,8 @@ class FormFile
$modellist = $genallowed;
} else {
include_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php';
- $modellist = ModeleExports::liste_modeles($this->db);
+ //$modellist = ModeleExports::liste_modeles($this->db); // liste_modeles() does not exists. We are using listOfAvailableExportFormat() method instead that return a different array format.
+ $modellist = array();
}
} elseif ($modulepart == 'commande_fournisseur' || $modulepart == 'supplier_order') {
if (is_array($genallowed)) {
@@ -703,6 +704,9 @@ class FormFile
$out .= '';
diff --git a/htdocs/core/modules/asset/mod_asset_advanced.php b/htdocs/core/modules/asset/mod_asset_advanced.php
index 369cca5db68..ff39d1e2613 100644
--- a/htdocs/core/modules/asset/mod_asset_advanced.php
+++ b/htdocs/core/modules/asset/mod_asset_advanced.php
@@ -81,7 +81,7 @@ class mod_asset_advanced extends ModeleNumRefAsset
$text .= ''.$langs->trans("Mask").': ';
$text .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $text .= ' ';
+ $text .= ' ';
$text .= ' ';
diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php
index 83e66baa3d6..7ebad740724 100644
--- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php
+++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php
@@ -42,6 +42,25 @@ class pdf_sepamandate extends ModeleBankAccountDoc
*/
public $version = 'dolibarr';
+ /**
+ * @var int Height reserved to output the info and total part
+ */
+ public $heightforinfotot;
+
+ /**
+ * @var int Height reserved to output the free text on last page
+ */
+ public $heightforfreetext;
+
+ /**
+ * @var int Height reserved to output the footer (value include bottom margin)
+ */
+ public $heightforfooter;
+
+ /**
+ * @var int x coordinate reserved to output the Signature area
+ */
+ public $xPosSignArea;
/**
* Constructor
*
@@ -80,8 +99,17 @@ class pdf_sepamandate extends ModeleBankAccountDoc
// Define column position
$this->posxref = $this->marge_gauche;
- }
+ $this->update_main_doc_field=1;
+
+ $this->heightforinfotot=50;
+
+ $this->xPosSignArea=120;
+
+ $this->heightforfreetext = (getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT') > 0 ? getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT') : 5);
+
+ $this->heightforfooter = $this->marge_basse + 8;
+ }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
@@ -153,11 +181,9 @@ class pdf_sepamandate extends ModeleBankAccountDoc
$pdf = pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
- $heightforinfotot = 50; // Height reserved to output the info and total part
- $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
- $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+
if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
- $heightforfooter += 6;
+ $this->heightforfooter += 6;
}
$pdf->SetAutoPageBreak(1, 0);
@@ -193,7 +219,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
$tab_top = 50;
$tab_top_newpage = 40;
- $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
+ $tab_height = $this->page_hauteur - $tab_top - $this->heightforfooter - $this->heightforfreetext ;
// Show notes
if (!empty($object->note_public)) {
@@ -381,17 +407,17 @@ class pdf_sepamandate extends ModeleBankAccountDoc
// Show square
if ($pagenb == 1) {
- $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
- $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter, 0, $outputlangs, 0, 0);
+ $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
} else {
- $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
- $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter, 0, $outputlangs, 1, 0);
+ $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
}
//var_dump($tab_top);
- //var_dump($heightforinfotot);
- //var_dump($heightforfreetext);
- //var_dump($heightforfooter);
+ //var_dump($this->heightforinfotot );
+ //var_dump($this->heightforfreetext );
+ //var_dump($this->heightforfooter );
//var_dump($bottomlasttab);
// Affiche zone infos
@@ -525,7 +551,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
$pdf->MultiCell(100, 3, ' ');
$pdf->MultiCell(100, 3, '______________________', 0, 'L', 0);
- $posx = 120;
+ $posx = $this->xPosSignArea;
$largcol = ($this->page_largeur - $this->marge_droite - $posx);
$useborder = 0;
$index = 0;
diff --git a/htdocs/core/modules/barcode/mod_barcode_product_standard.php b/htdocs/core/modules/barcode/mod_barcode_product_standard.php
index b1775a1e95f..99176dd00f2 100644
--- a/htdocs/core/modules/barcode/mod_barcode_product_standard.php
+++ b/htdocs/core/modules/barcode/mod_barcode_product_standard.php
@@ -109,7 +109,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
//$texte.= ''.$langs->trans("Mask").' ('.$langs->trans("BarCodeModel").'): ';
$texte .= ''.$langs->trans("Mask").': ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= ' ';
$texte .= '
';
diff --git a/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php b/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php
index 6eae8da2c1f..c2e73d2d78f 100644
--- a/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php
+++ b/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php
@@ -110,7 +110,7 @@ class mod_barcode_thirdparty_standard extends ModeleNumRefBarCode
//$texte.= ' '.$langs->trans("Mask").' ('.$langs->trans("BarCodeModel").'): ';
$texte .= ''.$langs->trans("Mask").': ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= '';
$texte .= '';
diff --git a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php
index 7ec4266b9d4..219c1fd0873 100644
--- a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php
+++ b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php
@@ -130,17 +130,18 @@ class doc_generic_bom_odt extends ModelePDFBom
}
}
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
+ $texthelp .= '
'.$langs->trans("ExampleOfDirectoriesForModelGen").' ';
// Add list of substitution keys
$texthelp .= '
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
- $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
+ $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
$texte .= '
';
// Scan directories
@@ -172,16 +173,11 @@ class doc_generic_bom_odt extends ModelePDFBom
}
$texte .= '
';
$texte .= '
';
- $texte .= '
';
+ $texte .= '
';
$texte .= '
';
$texte .= '';
- $texte .= '';
- $texte .= '';
- $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
- $texte .= ' ';
- $texte .= ' ';
$texte .= ' ';
$texte .= '';
diff --git a/htdocs/core/modules/bom/mod_bom_advanced.php b/htdocs/core/modules/bom/mod_bom_advanced.php
index a1ffc9ff780..b8933a32504 100644
--- a/htdocs/core/modules/bom/mod_bom_advanced.php
+++ b/htdocs/core/modules/bom/mod_bom_advanced.php
@@ -82,7 +82,7 @@ class mod_bom_advanced extends ModeleNumRefBoms
$texte .= ''.$langs->trans("Mask").': ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= ' ';
diff --git a/htdocs/core/modules/bookcal/mod_booking_advanced.php b/htdocs/core/modules/bookcal/mod_booking_advanced.php
deleted file mode 100644
index d34d08548f8..00000000000
--- a/htdocs/core/modules/bookcal/mod_booking_advanced.php
+++ /dev/null
@@ -1,147 +0,0 @@
-
- * Copyright (C) 2004-2007 Laurent Destailleur
- * Copyright (C) 2005-2009 Regis Houssin
- * Copyright (C) 2008 Raphael Bertrand (Resultic)
- * Copyright (C) 2019 Frédéric France
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- * or see https://www.gnu.org/
- */
-
-/**
- * \file htdocs/core/modules/booking/mod_booking_advanced.php
- * \ingroup bookcal
- * \brief File containing class for advanced numbering model of Booking
- */
-
-dol_include_once('/core/modules/bookcal/modules_booking.php');
-
-
-/**
- * Class to manage the Advanced numbering rule for Booking
- */
-class mod_booking_advanced extends ModeleNumRefBooking
-{
- /**
- * Dolibarr version of the loaded document
- * @var string
- */
- public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
-
- /**
- * @var string Error message
- */
- public $error = '';
-
- /**
- * @var string name
- */
- public $name = 'advanced';
-
-
- /**
- * Returns the description of the numbering model
- *
- * @param Translate $langs Lang object to use for output
- * @return string Descriptive text
- */
- public function info($langs)
- {
- global $langs, $db;
-
- $langs->load("bills");
-
- $form = new Form($db);
-
- $texte = $langs->trans('GenericNumRefModelDesc')." \n";
- $texte .= '';
- $texte .= ' ';
- $texte .= ' ';
- $texte .= ' ';
- $texte .= '';
- $texte .= ' ';
-
- return $texte;
- }
-
- /**
- * Return an example of numbering
- *
- * @return string Example
- */
- public function getExample()
- {
- global $conf, $db, $langs, $mysoc;
-
- $object = new Booking($db);
- $object->initAsSpecimen();
-
- /*$old_code_client = $mysoc->code_client;
- $old_code_type = $mysoc->typent_code;
- $mysoc->code_client = 'CCCCCCCCCC';
- $mysoc->typent_code = 'TTTTTTTTTT';*/
-
- $numExample = $this->getNextValue($object);
-
- /*$mysoc->code_client = $old_code_client;
- $mysoc->typent_code = $old_code_type;*/
-
- if (!$numExample) {
- $numExample = $langs->trans('NotConfigured');
- }
- return $numExample;
- }
-
- /**
- * Return next free value
- *
- * @param Object $object Object we need next value for
- * @return string Value if KO, <0 if KO
- */
- public function getNextValue($object)
- {
- global $db, $conf;
-
- require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
-
- // We get cursor rule
- $mask = getDolGlobalString('BOOKCAL_BOOKING_ADVANCED_MASK');
-
- if (!$mask) {
- $this->error = 'NotConfigured';
- return 0;
- }
-
- $date = $object->date;
-
- $numFinal = get_next_value($db, $mask, 'bookcal_booking', 'ref', '', null, $date);
-
- return $numFinal;
- }
-}
diff --git a/htdocs/core/modules/bookcal/mod_booking_standard.php b/htdocs/core/modules/bookcal/mod_booking_standard.php
deleted file mode 100644
index ba077860ddf..00000000000
--- a/htdocs/core/modules/bookcal/mod_booking_standard.php
+++ /dev/null
@@ -1,162 +0,0 @@
-
- * Copyright (C) 2005-2009 Regis Houssin
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- * or see https://www.gnu.org/
- */
-
-/**
- * \file htdocs/core/modules/bookcal/mod_booking_standard.php
- * \ingroup bookcal
- * \brief File of class to manage booking numbering rules standard
- */
-dol_include_once('/core/modules/bookcal/modules_booking.php');
-
-
-/**
- * Class to manage the Standard numbering rule for booking
- */
-class mod_booking_standard extends ModeleNumRefBooking
-{
- /**
- * Dolibarr version of the loaded document
- * @var string
- */
- public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
-
- public $prefix = 'BK';
-
- /**
- * @var string Error code (or message)
- */
- public $error = '';
-
- /**
- * @var string name
- */
- public $name = 'standard';
-
-
- /**
- * Return description of numbering module
- *
- * @param Translate $langs Lang object to use for output
- * @return string Descriptive text
- */
- public function info($langs)
- {
- global $langs;
- return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
- }
-
-
- /**
- * Return an example of numbering
- *
- * @return string Example
- */
- public function getExample()
- {
- return $this->prefix."0501-0001";
- }
-
-
- /**
- * Checks if the numbers already in the database do not
- * cause conflicts that would prevent this numbering working.
- *
- * @param Object $object Object we need next value for
- * @return boolean false if conflict, true if ok
- */
- public function canBeActivated($object)
- {
- global $conf, $langs, $db;
-
- $coyymm = ''; $max = '';
-
- $posindice = strlen($this->prefix) + 6;
- $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
- $sql .= " FROM ".MAIN_DB_PREFIX."bookcal_booking";
- $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
- if ($object->ismultientitymanaged == 1) {
- $sql .= " AND entity = ".$conf->entity;
- } elseif ($object->ismultientitymanaged == 2) {
- // TODO
- }
-
- $resql = $db->query($sql);
- if ($resql) {
- $row = $db->fetch_row($resql);
- if ($row) {
- $coyymm = substr($row[0], 0, 6); $max = $row[0];
- }
- }
- if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
- $langs->load("errors");
- $this->error = $langs->trans('ErrorNumRefModel', $max);
- return false;
- }
-
- return true;
- }
-
- /**
- * Return next free value
- *
- * @param Object $object Object we need next value for
- * @return string Value if KO, <0 if KO
- */
- public function getNextValue($object)
- {
- global $db, $conf;
-
- // first we get the max value
- $posindice = strlen($this->prefix) + 6;
- $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
- $sql .= " FROM ".MAIN_DB_PREFIX."bookcal_booking";
- $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
- if ($object->ismultientitymanaged == 1) {
- $sql .= " AND entity = ".$conf->entity;
- } elseif ($object->ismultientitymanaged == 2) {
- // TODO
- }
-
- $resql = $db->query($sql);
- if ($resql) {
- $obj = $db->fetch_object($resql);
- if ($obj) {
- $max = intval($obj->max);
- } else {
- $max = 0;
- }
- } else {
- dol_syslog("mod_booking_standard::getNextValue", LOG_DEBUG);
- return -1;
- }
-
- //$date=time();
- $date = $object->date_creation;
- $yymm = strftime("%y%m", $date);
-
- if ($max >= (pow(10, 4) - 1)) {
- $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
- } else {
- $num = sprintf("%04s", $max + 1);
- }
-
- dol_syslog("mod_booking_standard::getNextValue return ".$this->prefix.$yymm."-".$num);
- return $this->prefix.$yymm."-".$num;
- }
-}
diff --git a/htdocs/core/modules/bookcal/modules_booking.php b/htdocs/core/modules/bookcal/modules_booking.php
deleted file mode 100644
index 6025515954e..00000000000
--- a/htdocs/core/modules/bookcal/modules_booking.php
+++ /dev/null
@@ -1,72 +0,0 @@
-
- * Copyright (C) 2004-2011 Laurent Destailleur
- * Copyright (C) 2004 Eric Seigne
- * Copyright (C) 2005-2012 Regis Houssin
- * Copyright (C) 2006 Andre Cianfarani
- * Copyright (C) 2012 Juanjo Menent
- * Copyright (C) 2014 Marcos García
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- * or see https://www.gnu.org/
- */
-
-/**
- * \file htdocs/core/modules/mymodule/modules_myobject.php
- * \ingroup mymodule
- * \brief File that contains parent class for myobjects document models and parent class for myobjects numbering models
- */
-
-require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php';
-require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit
-
-
-/**
- * Parent class for documents models
- */
-abstract class ModelePDFBooking extends CommonDocGenerator
-{
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Return list of active generation modules
- *
- * @param DoliDB $db Database handler
- * @param integer $maxfilenamelength Max length of value to show
- * @return array List of templates
- */
- public static function liste_modeles($db, $maxfilenamelength = 0)
- {
- // phpcs:enable
- global $conf;
-
- $type = 'myobject';
- $list = array();
-
- include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
- $list = getListOfModels($db, $type, $maxfilenamelength);
-
- return $list;
- }
-}
-
-
-
-/**
- * Parent class to manage numbering of MyObject
- */
-abstract class ModeleNumRefBooking extends CommonNumRefGenerator
-{
- // No overload code
-}
diff --git a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php
index 864401b3fb4..f963adccf70 100644
--- a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php
+++ b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php
@@ -34,6 +34,36 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/cheque/modules_chequereceipts.php'
*/
class BordereauChequeBlochet extends ModeleChequeReceipts
{
+ /**
+ * @var int tab_top
+ */
+ public $tab_top;
+
+ /**
+ * @var int tab_height
+ */
+ public $tab_height;
+
+ /**
+ * @var int line_height
+ */
+ public $line_height;
+
+ /**
+ * @var int line per page
+ */
+ public $line_per_page;
+
+ /**
+ * @var Account bank account
+ */
+ public $account;
+
+ /**
+ * @var array lines
+ */
+ public $lines;
+
/**
* Constructor
*
diff --git a/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php b/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php
index 79acb4b56a7..25100994aeb 100644
--- a/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php
+++ b/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php
@@ -76,7 +76,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts
$texte .= ''.$langs->trans("Mask").': ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= ' ';
diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php
index 6a79f31f048..476f649c5fb 100644
--- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php
+++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php
@@ -137,17 +137,18 @@ class doc_generic_order_odt extends ModelePDFCommandes
}
}
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
+ $texthelp .= ''.$langs->trans("ExampleOfDirectoriesForModelGen").' ';
// Add list of substitution keys
$texthelp .= ' '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").' ';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
- $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
+ $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
$texte .= '';
// Scan directories
@@ -179,16 +180,11 @@ class doc_generic_order_odt extends ModelePDFCommandes
}
$texte .= ' ';
$texte .= ' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= '';
$texte .= '';
- $texte .= '';
- $texte .= '';
- $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
- $texte .= ' ';
- $texte .= ' ';
$texte .= '';
$texte .= '';
diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
index 8c2612fa683..eb1f9c29f84 100644
--- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
@@ -162,11 +162,13 @@ class pdf_eratosthene extends ModelePDFCommandes
// phpcs:enable
global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
+ dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
+
if (!is_object($outputlangs)) {
$outputlangs = $langs;
}
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (!empty($conf->global->MAIN_USE_FPDF)) {
+ if (getDolGlobalInt('MAIN_USE_FPDF')) {
$outputlangs->charset_output = 'ISO-8859-1';
}
@@ -180,23 +182,23 @@ class pdf_eratosthene extends ModelePDFCommandes
global $outputlangsbis;
$outputlangsbis = null;
- if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
+ if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) {
$outputlangsbis = new Translate('', $conf);
- $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
+ $outputlangsbis->setDefaultLang(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE'));
$outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
}
- $nblines = count($object->lines);
+ $nblines = (is_array($object->lines) ? count($object->lines) : 0);
$hidetop = 0;
- if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
- $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
+ if (getDolGlobalString('MAIN_PDF_DISABLE_COL_HEAD_TITLE')) {
+ $hidetop = getDolGlobalString('MAIN_PDF_DISABLE_COL_HEAD_TITLE');
}
// Loop on each lines to detect if there is at least one image to show
$realpatharray = array();
$this->atleastonephoto = false;
- if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE)) {
+ if (getDolGlobalInt('MAIN_GENERATE_ORDERS_WITH_PICTURE')) {
$objphoto = new Product($this->db);
for ($i = 0; $i < $nblines; $i++) {
@@ -282,8 +284,8 @@ class pdf_eratosthene extends ModelePDFCommandes
global $action;
$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- // Set nblines with the new command lines content after hook
- $nblines = count($object->lines);
+ // Set nblines with the new lines content after hook
+ $nblines = (is_array($object->lines) ? count($object->lines) : 0);
// Create pdf instance
$pdf = pdf_getInstance($this->format);
@@ -300,12 +302,12 @@ class pdf_eratosthene extends ModelePDFCommandes
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
- if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
+ if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) {
$logodir = $conf->mycompany->dir_output;
if (!empty($conf->mycompany->multidir_output[$object->entity])) {
$logodir = $conf->mycompany->multidir_output[$object->entity];
}
- $pagecount = $pdf->setSourceFile($logodir.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $pagecount = $pdf->setSourceFile($logodir.'/'.getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$tplidx = $pdf->importPage(1);
}
@@ -349,6 +351,8 @@ class pdf_eratosthene extends ModelePDFCommandes
$tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
+ $nexY = $tab_top - 1;
+
// Incoterm
$height_incoterms = 0;
if (isModEnabled('incoterm')) {
@@ -369,7 +373,7 @@ class pdf_eratosthene extends ModelePDFCommandes
}
}
- // Displays notes
+ // Display notes
$notetoshow = empty($object->note_public) ? '' : $object->note_public;
if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) {
// Get first sale rep
@@ -382,7 +386,6 @@ class pdf_eratosthene extends ModelePDFCommandes
}
}
}
-
// Extrafields in note
$extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
if (!empty($extranote)) {
@@ -559,7 +562,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$curY = $tab_top_newpage;
// Allows data in the first page if description is long enough to break in multiples pages
- if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
+ if (getDolGlobalInt('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
$showpricebeforepagebreak = 1;
} else {
$showpricebeforepagebreak = 0;
@@ -595,20 +598,18 @@ class pdf_eratosthene extends ModelePDFCommandes
if (!empty($tplidx)) {
$pdf->useTemplate($tplidx);
}
- //if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) $this->_pagehead($pdf, $object, 0, $outputlangs);
$pdf->setPage($pageposafter + 1);
}
} else {
// We found a page break
// Allows data in the first page if description is long enough to break in multiples pages
- if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
+ if (getDolGlobalInt('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
$showpricebeforepagebreak = 1;
} else {
$showpricebeforepagebreak = 0;
}
}
- } else // No pagebreak
- {
+ } else { // No pagebreak
$pdf->commitTransaction();
}
$posYAfterDescription = $pdf->GetY();
@@ -720,17 +721,6 @@ class pdf_eratosthene extends ModelePDFCommandes
$localtax1_type = $object->lines[$i]->localtax1_type;
$localtax2_type = $object->lines[$i]->localtax2_type;
- // TODO remise_percent is an obsolete field for object parent
- /*if ($object->remise_percent) {
- $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
- }
- if ($object->remise_percent) {
- $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
- }
- if ($object->remise_percent) {
- $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
- }*/
-
$vatrate = (string) $object->lines[$i]->tva_tx;
// Retrieve type from database for backward compatibility with old records
@@ -773,7 +763,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne);
// Add line
- if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
+ if (getDolGlobalInt('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
//$pdf->SetDrawColor(190,190,200);
@@ -786,9 +776,9 @@ class pdf_eratosthene extends ModelePDFCommandes
while ($pagenb < $pageposafter) {
$pdf->setPage($pagenb);
if ($pagenb == $pageposbeforeprintlines) {
- $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
} else {
- $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
+ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
}
$this->_pagefoot($pdf, $object, $outputlangs, 1);
$pagenb++;
@@ -803,9 +793,9 @@ class pdf_eratosthene extends ModelePDFCommandes
}
if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
if ($pagenb == $pageposafter) {
- $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
} else {
- $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
+ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
}
$this->_pagefoot($pdf, $object, $outputlangs, 1);
// New page
@@ -822,9 +812,9 @@ class pdf_eratosthene extends ModelePDFCommandes
// Show square
if ($pagenb == $pageposbeforeprintlines) {
- $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis);
} else {
- $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
+ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis);
}
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
@@ -834,7 +824,7 @@ class pdf_eratosthene extends ModelePDFCommandes
// Display total zone
$posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
- // Affiche zone versements
+ // Display payment area
/*
if ($deja_regle)
{
@@ -842,7 +832,7 @@ class pdf_eratosthene extends ModelePDFCommandes
}
*/
- // Pied de page
+ // Pagefoot
$this->_pagefoot($pdf, $object, $outputlangs);
if (method_exists($pdf, 'AliasNbPages')) {
$pdf->AliasNbPages();
@@ -1368,7 +1358,7 @@ class pdf_eratosthene extends ModelePDFCommandes
if (empty($hidetop)) {
$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
- if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
+ if (getDolGlobalInt('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
$titre .= ' - '.$outputlangsbis->transnoentities("AmountInCurrency", $outputlangsbis->transnoentitiesnoconv("Currency".$currency));
}
@@ -1376,7 +1366,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
- if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
+ if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) {
$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
}
}
@@ -1406,7 +1396,7 @@ class pdf_eratosthene extends ModelePDFCommandes
* @param Translate $outputlangs Object lang for output
* @param Translate $outputlangsbis Object lang for output bis
* @param string $titlekey Translation key to show as title of document
- * @return int Return topshift value
+ * @return float|int Return topshift value
*/
protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null, $titlekey = "PdfOrderTitle")
{
@@ -1464,7 +1454,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$title = $outputlangs->transnoentities($titlekey);
- if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
+ if (getDolGlobalInt('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
$title .= ' - ';
$title .= $outputlangsbis->transnoentities($titlekey);
}
@@ -1500,7 +1490,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65), '', 'R');
}
- if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
+ if (getDolGlobalInt('PDF_SHOW_PROJECT_TITLE')) {
$object->fetch_projet();
if (!empty($object->project->ref)) {
$posy += 3;
@@ -1510,7 +1500,7 @@ class pdf_eratosthene extends ModelePDFCommandes
}
}
- if (!empty($conf->global->PDF_SHOW_PROJECT)) {
+ if (getDolGlobalInt('PDF_SHOW_PROJECT')) {
$object->fetch_projet();
if (!empty($object->project->ref)) {
$outputlangs->load("projects");
@@ -1526,7 +1516,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$title = $outputlangs->transnoentities("OrderDate");
- if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
+ if (getDolGlobalInt('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
$title .= ' - '.$outputlangsbis->transnoentities("DateInvoice");
}
$pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
@@ -1539,7 +1529,7 @@ class pdf_eratosthene extends ModelePDFCommandes
}
// Get contact
- if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
+ if (getDolGlobalInt('DOC_SHOW_FIRST_SALES_REP')) {
$arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
if (count($arrayidcontact) > 0) {
$usertmp = new User($this->db);
@@ -1581,15 +1571,15 @@ class pdf_eratosthene extends ModelePDFCommandes
$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
// Show sender
- $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
+ $posy = getDolGlobalInt('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
$posy += $top_shift;
$posx = $this->marge_gauche;
- if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
+ if (getDolGlobalInt('MAIN_INVERT_SENDER_RECIPIENT')) {
$posx = $this->page_largeur - $this->marge_droite - 80;
}
- $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
- $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
+ $hautcadre = getDolGlobalInt('MAIN_PDF_USE_ISO_LOCATION') ? 38 : 40;
+ $widthrecbox = getDolGlobalInt('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
// Show sender frame
@@ -1626,26 +1616,28 @@ class pdf_eratosthene extends ModelePDFCommandes
}
//Recipient name
- if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
+ if ($usecontact && $object->contact->socid != $object->thirdparty->id && getDolGlobalInt('MAIN_USE_COMPANY_NAME_OF_CONTACT')) {
$thirdparty = $object->contact;
} else {
$thirdparty = $object->thirdparty;
}
- $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
+ if (is_object($thirdparty)) {
+ $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
+ }
$mode = 'target';
$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object);
// Show recipient
- $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
+ $widthrecbox = getDolGlobalInt('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
if ($this->page_largeur < 210) {
$widthrecbox = 84; // To work with US executive format
}
- $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
+ $posy = getDolGlobalInt('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
$posy += $top_shift;
$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
- if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
+ if (getDolGlobalInt('MAIN_INVERT_SENDER_RECIPIENT')) {
$posx = $this->marge_gauche;
}
@@ -1761,7 +1753,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$rank = $rank + 10;
$this->cols['photo'] = array(
'rank' => $rank,
- 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
+ 'width' => (!getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH') ? 20 : getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH')), // in mm
'status' => false,
'title' => array(
'textkey' => 'Photo',
@@ -1773,7 +1765,7 @@ class pdf_eratosthene extends ModelePDFCommandes
'border-left' => false, // remove left line separator
);
- if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE) && !empty($this->atleastonephoto)) {
+ if (getDolGlobalInt('MAIN_GENERATE_ORDERS_WITH_PICTURE') && !empty($this->atleastonephoto)) {
$this->cols['photo']['status'] = true;
}
@@ -1788,7 +1780,7 @@ class pdf_eratosthene extends ModelePDFCommandes
'border-left' => true, // add left line separator
);
- if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
+ if (!getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) {
$this->cols['vat']['status'] = true;
}
@@ -1857,7 +1849,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$this->cols['totalexcltax'] = array(
'rank' => $rank,
'width' => 26, // in mm
- 'status' => empty($conf->global->PDF_PROPAL_HIDE_PRICE_EXCL_TAX) ? true : false,
+ 'status' => empty($conf->global->PDF_ORDER_HIDE_PRICE_EXCL_TAX) ? true : false,
'title' => array(
'textkey' => 'TotalHTShort'
),
@@ -1868,7 +1860,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$this->cols['totalincltax'] = array(
'rank' => $rank,
'width' => 26, // in mm
- 'status' => empty($conf->global->PDF_PROPAL_SHOW_PRICE_INCL_TAX) ? false : true,
+ 'status' => empty($conf->global->PDF_ORDER_SHOW_PRICE_INCL_TAX) ? false : true,
'title' => array(
'textkey' => 'TotalTTCShort'
),
diff --git a/htdocs/core/modules/commande/mod_commande_saphir.php b/htdocs/core/modules/commande/mod_commande_saphir.php
index 641081782cd..65c48a657cc 100644
--- a/htdocs/core/modules/commande/mod_commande_saphir.php
+++ b/htdocs/core/modules/commande/mod_commande_saphir.php
@@ -82,7 +82,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes
$texte .= ''.$langs->trans("Mask").': ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= ' ';
diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php
index f81cbeaf33c..f1d10c1ce6b 100644
--- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php
+++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php
@@ -134,17 +134,18 @@ class doc_generic_contract_odt extends ModelePDFContract
}
}
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
+ $texthelp .= ''.$langs->trans("ExampleOfDirectoriesForModelGen").' ';
// Add list of substitution keys
$texthelp .= ' '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").' ';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
- $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
+ $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
$texte .= '';
// Scan directories
@@ -176,16 +177,11 @@ class doc_generic_contract_odt extends ModelePDFContract
}
$texte .= ' ';
$texte .= ' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= '';
$texte .= '';
- $texte .= '';
- $texte .= '';
- $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
- $texte .= ' ';
- $texte .= ' ';
$texte .= '';
$texte .= '';
diff --git a/htdocs/core/modules/contract/mod_contract_magre.php b/htdocs/core/modules/contract/mod_contract_magre.php
index fd476eb2bc5..4a3f97e7214 100644
--- a/htdocs/core/modules/contract/mod_contract_magre.php
+++ b/htdocs/core/modules/contract/mod_contract_magre.php
@@ -87,7 +87,7 @@ class mod_contract_magre extends ModelNumRefContracts
$texte .= ''.$langs->trans("Mask").': ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= ' ';
$texte .= '';
$texte .= '';
@@ -102,7 +102,7 @@ class mod_contract_magre extends ModelNumRefContracts
*/
public function getExample()
{
- global $conf, $langs, $mysoc;
+ global $langs, $mysoc;
$old_code_client = $mysoc->code_client;
$mysoc->code_client = 'CCCCCCCCCC';
diff --git a/htdocs/core/modules/contract/mod_contract_olive.php b/htdocs/core/modules/contract/mod_contract_olive.php
index 4051ac7c779..2737899a65c 100644
--- a/htdocs/core/modules/contract/mod_contract_olive.php
+++ b/htdocs/core/modules/contract/mod_contract_olive.php
@@ -78,6 +78,16 @@ class mod_contract_olive extends ModelNumRefContracts
return $langs->trans("LeopardNumRefModelDesc");
}
+ /**
+ * Return numbering example
+ *
+ * @return string Example
+ */
+ public function getExample()
+ {
+ return '';
+ }
+
/**
* Return an example of result returned by getNextValue
*
@@ -87,7 +97,6 @@ class mod_contract_olive extends ModelNumRefContracts
*/
public function getNextValue($objsoc, $contract)
{
- global $langs;
return '';
}
@@ -112,9 +121,9 @@ class mod_contract_olive extends ModelNumRefContracts
$result = 0;
$code = strtoupper(trim($code));
- if (empty($code) && $this->code_null && empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED)) {
+ if (empty($code) && $this->code_null && empty($conf->global->MAIN_CONTRACT_CODE_ALWAYS_REQUIRED)) {
$result = 0;
- } elseif (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED))) {
+ } elseif (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_CONTRACT_CODE_ALWAYS_REQUIRED))) {
$result = -2;
}
diff --git a/htdocs/core/modules/delivery/mod_delivery_saphir.php b/htdocs/core/modules/delivery/mod_delivery_saphir.php
index 7faddbd2251..d25df47624d 100644
--- a/htdocs/core/modules/delivery/mod_delivery_saphir.php
+++ b/htdocs/core/modules/delivery/mod_delivery_saphir.php
@@ -86,7 +86,7 @@ class mod_delivery_saphir extends ModeleNumRefDeliveryOrder
$texte .= ''.$langs->trans("Mask").': ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= ' ';
diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php
index d2ed52389d1..80ba1439342 100644
--- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php
+++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php
@@ -137,17 +137,18 @@ class doc_generic_shipment_odt extends ModelePdfExpedition
}
}
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
+ $texthelp .= ''.$langs->trans("ExampleOfDirectoriesForModelGen").' ';
// Add list of substitution keys
$texthelp .= ' '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").' ';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
- $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
+ $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
$texte .= '';
// Scan directories
@@ -178,15 +179,10 @@ class doc_generic_shipment_odt extends ModelePdfExpedition
}
$texte .= ' ';
$texte .= ' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= '';
$texte .= '';
- $texte .= '';
- $texte .= '';
- $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
- $texte .= ' ';
- $texte .= ' ';
$texte .= '';
$texte .= '';
diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
index a9e2bd31160..477c1280a49 100644
--- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
@@ -3,7 +3,7 @@
* Copyright (C) 2005-2012 Laurent Destailleur
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2014-2015 Marcos García
- * Copyright (C) 2018-2020 Frédéric France
+ * Copyright (C) 2018-2023 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -69,6 +69,7 @@ class pdf_rouget extends ModelePdfExpedition
public $version = 'dolibarr';
public $posxweightvol;
+ public $posxqtytoship;
public $posxqtyordered;
diff --git a/htdocs/core/modules/expedition/mod_expedition_ribera.php b/htdocs/core/modules/expedition/mod_expedition_ribera.php
index eed9b96ffef..a90fc7c6653 100644
--- a/htdocs/core/modules/expedition/mod_expedition_ribera.php
+++ b/htdocs/core/modules/expedition/mod_expedition_ribera.php
@@ -82,7 +82,7 @@ class mod_expedition_ribera extends ModelNumRefExpedition
$texte .= ''.$langs->trans("Mask").': ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= ' ';
$texte .= '';
$texte .= '';
diff --git a/htdocs/core/modules/expensereport/mod_expensereport_sand.php b/htdocs/core/modules/expensereport/mod_expensereport_sand.php
index 669b51e22ed..b0aa791e228 100644
--- a/htdocs/core/modules/expensereport/mod_expensereport_sand.php
+++ b/htdocs/core/modules/expensereport/mod_expensereport_sand.php
@@ -86,7 +86,7 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport
$mask = empty($conf->global->EXPENSEREPORT_SAND_MASK) ? '' : $conf->global->EXPENSEREPORT_SAND_MASK;
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= '';
diff --git a/htdocs/core/modules/export/export_csviso.modules.php b/htdocs/core/modules/export/export_csviso.modules.php
index 4e12c32f66c..d9976031686 100644
--- a/htdocs/core/modules/export/export_csviso.modules.php
+++ b/htdocs/core/modules/export/export_csviso.modules.php
@@ -21,7 +21,7 @@
* \brief File of class to build exports with CSV format
*/
-require_once DOL_DOCUMENT_ROOT.'/core/modules/export/exportcsv.modules.php';
+require_once DOL_DOCUMENT_ROOT.'/core/modules/export/exportcsv.class.php';
// avoid timeout for big export
set_time_limit(0);
diff --git a/htdocs/core/modules/export/export_csvutf8.modules.php b/htdocs/core/modules/export/export_csvutf8.modules.php
index a98f3f5f7f8..3fcf1db669c 100644
--- a/htdocs/core/modules/export/export_csvutf8.modules.php
+++ b/htdocs/core/modules/export/export_csvutf8.modules.php
@@ -16,12 +16,12 @@
*/
/**
- * \file htdocs/core/modules/export/export_csv.modules.php
+ * \file htdocs/core/modules/export/exportcsv.class.php
* \ingroup export
* \brief File of class to build exports with CSV format
*/
-require_once DOL_DOCUMENT_ROOT.'/core/modules/export/exportcsv.modules.php';
+require_once DOL_DOCUMENT_ROOT.'/core/modules/export/exportcsv.class.php';
// avoid timeout for big export
set_time_limit(0);
diff --git a/htdocs/core/modules/export/export_tsv.modules.php b/htdocs/core/modules/export/export_tsv.modules.php
index 40ee75a1749..956639f0135 100644
--- a/htdocs/core/modules/export/export_tsv.modules.php
+++ b/htdocs/core/modules/export/export_tsv.modules.php
@@ -230,7 +230,7 @@ class ExportTsv extends ModeleExports
* Output record line into file
*
* @param array $array_selected_sorted Array with list of field to export
- * @param resource $objp A record from a fetch with all fields from select
+ * @param Resource $objp A record from a fetch with all fields from select
* @param Translate $outputlangs Object lang to translate values
* @param array $array_types Array with types of fields
* @return int <0 if KO, >0 if OK
diff --git a/htdocs/core/modules/export/exportcsv.modules.php b/htdocs/core/modules/export/exportcsv.class.php
similarity index 98%
rename from htdocs/core/modules/export/exportcsv.modules.php
rename to htdocs/core/modules/export/exportcsv.class.php
index fd96bf468f3..0e8c0a602ba 100644
--- a/htdocs/core/modules/export/exportcsv.modules.php
+++ b/htdocs/core/modules/export/exportcsv.class.php
@@ -16,7 +16,7 @@
*/
/**
- * \file htdocs/core/modules/export/exportcsv.modules.php
+ * \file htdocs/core/modules/export/exportcsv.class.php
* \ingroup export
* \brief File of class to build exports with CSV format
*/
@@ -213,7 +213,7 @@ class ExportCsv extends ModeleExports
* Output record line into file
*
* @param array $array_selected_sorted Array with list of field to export
- * @param resource $objp A record from a fetch with all fields from select
+ * @param Resource $objp A record from a fetch with all fields from select
* @param Translate $outputlangs Object lang to translate values
* @param array $array_types Array with types of fields
* @return int <0 if KO, >0 if OK
diff --git a/htdocs/core/modules/export/modules_export.php b/htdocs/core/modules/export/modules_export.php
index 0cad4f76509..c55fa7d2a61 100644
--- a/htdocs/core/modules/export/modules_export.php
+++ b/htdocs/core/modules/export/modules_export.php
@@ -37,12 +37,43 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac
public $driverlabel = array();
+ public $driverdesc = array();
+
public $driverversion = array();
public $liblabel = array();
public $libversion = array();
+ /**
+ * @var string picto
+ */
+ public $picto;
+
+ /**
+ * @var string description
+ */
+ public $desc;
+
+ /**
+ * @var string escape
+ */
+ public $escape;
+
+ /**
+ * @var string enclosure
+ */
+ public $enclosure;
+
+ /**
+ * @var int col
+ */
+ public $col;
+
+ /**
+ * @var int disabled
+ */
+ public $disabled;
/**
* Load into memory list of available export format
@@ -62,8 +93,12 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac
$i = 0;
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) {
+ $reg = array();
if (preg_match("/^export_(.*)\.modules\.php$/i", $file, $reg)) {
$moduleid = $reg[1];
+ if ($moduleid == 'csv') {
+ continue; // This may happen if on old file export_csv.modules.php was not correctly deleted
+ }
// Loading Class
$file = $dir."export_".$moduleid.".modules.php";
@@ -72,6 +107,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac
require_once $file;
if (class_exists($classname)) {
$module = new $classname($db);
+ // var_dump($classname);
// Picto
$this->picto[$module->id] = $module->picto;
diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php
index 9799df502f7..679548c3d72 100644
--- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php
+++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php
@@ -136,17 +136,18 @@ class doc_generic_invoice_odt extends ModelePDFFactures
}
}
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
+ $texthelp .= ''.$langs->trans("ExampleOfDirectoriesForModelGen").' ';
// Add list of substitution keys
$texthelp .= ' '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").' ';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
- $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
+ $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
$texte .= '';
// Scan directories
@@ -177,15 +178,10 @@ class doc_generic_invoice_odt extends ModelePDFFactures
}
$texte .= ' ';
$texte .= ' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= '';
$texte .= '';
- $texte .= '';
- $texte .= '';
- $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
- $texte .= ' ';
- $texte .= ' ';
$texte .= '';
$texte .= '';
@@ -333,6 +329,34 @@ class doc_generic_invoice_odt extends ModelePDFFactures
}
}
+ // and determine category of operation
+ $categoryOfOperation = 0;
+ $nbProduct = 0;
+ $nbService = 0;
+ foreach ($object->lines as $line) {
+ // determine category of operation
+ if ($categoryOfOperation < 2) {
+ $lineProductType = $line->product_type;
+ if ($lineProductType == Product::TYPE_PRODUCT) {
+ $nbProduct++;
+ } elseif ($lineProductType == Product::TYPE_SERVICE) {
+ $nbService++;
+ }
+ if ($nbProduct > 0 && $nbService > 0) {
+ // mixed products and services
+ $categoryOfOperation = 2;
+ }
+ }
+ }
+
+ // determine category of operation
+ if ($categoryOfOperation <= 0) {
+ // only services
+ if ($nbProduct == 0 && $nbService > 0) {
+ $categoryOfOperation = 1;
+ }
+ }
+
// Make substitution
$substitutionarray = array(
'__FROM_NAME__' => $this->emetteur->name,
@@ -406,6 +430,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures
// TODO Search all tags {object_...:xxxx} into template then loop on this found tags to analyze them and the the corresponding
// property of object and use the xxxx to know how to format it.
// Before that, we hard code this substitution as if we have found them into the template.
+
$tmparray['object_PREVIOUS_MONTH'] = dol_print_date(dol_time_plus_duree($object->date, -1, 'm'), '%m');
$tmparray['object_MONTH'] = dol_print_date($object->date, '%m');
$tmparray['object_NEXT_MONTH'] = dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%m');
@@ -415,6 +440,8 @@ class doc_generic_invoice_odt extends ModelePDFFactures
$tmparray['object_PREVIOUS_YEAR'] = dol_print_date(dol_time_plus_duree($object->date, -1, 'y'), '%Y');
$tmparray['object_YEAR'] = dol_print_date($object->date, '%Y');
$tmparray['object_NEXT_YEAR'] = dol_print_date(dol_time_plus_duree($object->date, 1, 'y'), '%Y');
+ $tmparray['object_productorservice_operation'] = $outputlangs->transnoentities("MentionCategoryOfOperations" . $categoryOfOperation);
+
// Call the ODTSubstitution hook
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php
index b4041eb7553..fb00fd6246f 100644
--- a/htdocs/core/modules/facture/mod_facture_mercure.php
+++ b/htdocs/core/modules/facture/mod_facture_mercure.php
@@ -80,7 +80,7 @@ class mod_facture_mercure extends ModeleNumRefFactures
$texte .= ''.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").'): ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= ' ';
diff --git a/htdocs/core/modules/fichinter/mod_arctic.php b/htdocs/core/modules/fichinter/mod_arctic.php
index a2d7def3135..8f014e68111 100644
--- a/htdocs/core/modules/fichinter/mod_arctic.php
+++ b/htdocs/core/modules/fichinter/mod_arctic.php
@@ -87,7 +87,7 @@ class mod_arctic extends ModeleNumRefFicheinter
$texte .= ''.$langs->trans("Mask").': ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= ' ';
diff --git a/htdocs/core/modules/holiday/mod_holiday_immaculate.php b/htdocs/core/modules/holiday/mod_holiday_immaculate.php
index 07e60ede935..954f33d8f2a 100644
--- a/htdocs/core/modules/holiday/mod_holiday_immaculate.php
+++ b/htdocs/core/modules/holiday/mod_holiday_immaculate.php
@@ -87,7 +87,7 @@ class mod_holiday_immaculate extends ModelNumRefHolidays
$texte .= ''.$langs->trans("Mask").': ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= ' ';
$texte .= '';
$texte .= '';
diff --git a/htdocs/core/modules/hrm/mod_evaluation_advanced.php b/htdocs/core/modules/hrm/mod_evaluation_advanced.php
index 8bf3b201de6..71fb0024d93 100644
--- a/htdocs/core/modules/hrm/mod_evaluation_advanced.php
+++ b/htdocs/core/modules/hrm/mod_evaluation_advanced.php
@@ -82,7 +82,7 @@ class mod_evaluation_advanced extends ModeleNumRefEvaluation
$texte .= ''.$langs->trans("Mask").': ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= ' ';
diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php
index 29cd8ca5a21..70371759c26 100644
--- a/htdocs/core/modules/import/import_csv.modules.php
+++ b/htdocs/core/modules/import/import_csv.modules.php
@@ -38,18 +38,6 @@ class ImportCsv extends ModeleImports
*/
public $db;
- public $datatoimport;
-
- /**
- * @var string Error code (or message)
- */
- public $error = '';
-
- /**
- * @var string[] Error codes (or messages)
- */
- public $errors = array();
-
/**
* @var string Code of driver
*/
diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php
index c05fabc5968..2cc901bdda1 100644
--- a/htdocs/core/modules/import/import_xlsx.modules.php
+++ b/htdocs/core/modules/import/import_xlsx.modules.php
@@ -42,18 +42,6 @@ class ImportXlsx extends ModeleImports
*/
public $db;
- public $datatoimport;
-
- /**
- * @var string Error code (or message)
- */
- public $error = '';
-
- /**
- * @var string[] Error codes (or messages)
- */
- public $errors = array();
-
/**
* @var string Code of driver
*/
diff --git a/htdocs/core/modules/import/modules_import.php b/htdocs/core/modules/import/modules_import.php
index 5b665c8e2cf..8e24e1e3093 100644
--- a/htdocs/core/modules/import/modules_import.php
+++ b/htdocs/core/modules/import/modules_import.php
@@ -42,6 +42,16 @@ class ModeleImports
*/
public $error = '';
+ /**
+ * @var string[] Error codes (or messages)
+ */
+ public $errors = array();
+
+ /**
+ * @var string[] warnings codes (or messages)
+ */
+ public $warnings = array();
+
/**
* @var string Code of driver
*/
@@ -75,8 +85,35 @@ class ModeleImports
public $libversion = array();
+ /**
+ * @var string charset
+ */
public $charset;
+ /**
+ * @var string picto
+ */
+ public $picto;
+
+ /**
+ * @var string description
+ */
+ public $desc;
+
+ /**
+ * @var string escape
+ */
+ public $escape;
+
+ /**
+ * @var string enclosure
+ */
+ public $enclosure;
+
+ /**
+ * @var Societe thirdparty
+ */
+ public $thirdpartyobject;
/**
* @var array Element mapping from table name
diff --git a/htdocs/core/modules/mailings/advthirdparties.modules.php b/htdocs/core/modules/mailings/advthirdparties.modules.php
index 111943e99e0..7a40e1cdbda 100644
--- a/htdocs/core/modules/mailings/advthirdparties.modules.php
+++ b/htdocs/core/modules/mailings/advthirdparties.modules.php
@@ -37,11 +37,6 @@ class mailing_advthirdparties extends MailingTargets
*/
public $picto = 'company';
- /**
- * @var DoliDB Database handler.
- */
- public $db;
-
public $enabled = 'isModEnabled("societe")';
diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php
index 772c9900573..8452dacce1e 100644
--- a/htdocs/core/modules/mailings/contacts1.modules.php
+++ b/htdocs/core/modules/mailings/contacts1.modules.php
@@ -45,11 +45,6 @@ class mailing_contacts1 extends MailingTargets
*/
public $picto = 'contact';
- /**
- * @var DoliDB Database handler.
- */
- public $db;
-
/**
* Constructor
diff --git a/htdocs/core/modules/mailings/eventorganization.modules.php b/htdocs/core/modules/mailings/eventorganization.modules.php
index 2a8e06693b9..73eea96f8c5 100644
--- a/htdocs/core/modules/mailings/eventorganization.modules.php
+++ b/htdocs/core/modules/mailings/eventorganization.modules.php
@@ -39,11 +39,6 @@ class mailing_eventorganization extends MailingTargets
*/
public $picto = 'conferenceorbooth';
- /**
- * @var DoliDB Database handler.
- */
- public $db;
-
public $enabled = 'isModEnabled("eventorganization")';
diff --git a/htdocs/core/modules/mailings/fraise.modules.php b/htdocs/core/modules/mailings/fraise.modules.php
index 2096aeff135..aa8f0f5859a 100644
--- a/htdocs/core/modules/mailings/fraise.modules.php
+++ b/htdocs/core/modules/mailings/fraise.modules.php
@@ -48,10 +48,6 @@ class mailing_fraise extends MailingTargets
*/
public $picto = 'user';
- /**
- * @var DoliDB Database handler.
- */
- public $db;
/**
* Constructor
diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php
index 28c9e6cc034..632e228ad69 100644
--- a/htdocs/core/modules/mailings/modules_mailings.php
+++ b/htdocs/core/modules/mailings/modules_mailings.php
@@ -32,30 +32,45 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
class MailingTargets // This can't be abstract as it is used for some method
{
/**
- * @var DoliDB Database handler.
+ * @var DoliDb Database handler (result of a new DoliDB)
*/
public $db;
+ /**
+ * @var string Error code (or message)
+ */
+ public $error = '';
+
+ /**
+ * @var array of errors
+ */
+ public $errors;
+
/**
* @var string Condition to be enabled
*/
public $enabled;
/**
- * @var string Error code (or message)
+ * @var string Name of the module
*/
- public $error = '';
+ public $name;
+ /**
+ * @var string Description of the module
+ */
+ public $desc;
+
+ /**
+ * @var string Tooltip to show after description of the module
+ */
public $tooltip = '';
/**
- * @var string The SQL string used to find the recipients
+ * @var string To store the SQL string used to find the recipients
*/
public $sql;
- public $desc;
-
- public $name;
public $evenunsubscribe = 0; // Set this to 1 if you want to flag you also want to include email in target that has opt-out.
diff --git a/htdocs/core/modules/mailings/partnership.modules.php b/htdocs/core/modules/mailings/partnership.modules.php
index 3e947b6ed93..48fabd3b0fe 100644
--- a/htdocs/core/modules/mailings/partnership.modules.php
+++ b/htdocs/core/modules/mailings/partnership.modules.php
@@ -39,11 +39,6 @@ class mailing_partnership extends MailingTargets
*/
public $picto = 'partnership';
- /**
- * @var DoliDB Database handler.
- */
- public $db;
-
public $enabled = 'isModEnabled("partnership")';
@@ -86,6 +81,9 @@ class mailing_partnership extends MailingTargets
if (GETPOST('filter', 'int') > 0) {
$sql .= " AND pt.rowid=".((int) GETPOST('filter', 'int'));
}
+ if (GETPOSTISSET('filter_status_partnership') && GETPOSTINT('filter_status_partnership') >= 0) {
+ $sql .= " AND p.status = ".GETPOSTINT('filter_status_partnership');
+ }
if (empty($this->evenunsubscribe)) {
$sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = s.email and mu.entity = ".((int) $conf->entity).")";
}
@@ -102,6 +100,9 @@ class mailing_partnership extends MailingTargets
if (GETPOST('filter', 'int') > 0) {
$sql .= " AND pt.rowid=".((int) GETPOST('filter', 'int'));
}
+ if (GETPOSTISSET('filter_status_partnership') && GETPOSTINT('filter_status_partnership') >= 0) {
+ $sql .= " AND p.status = ".GETPOSTINT('filter_status_partnership');
+ }
if (empty($this->evenunsubscribe)) {
$sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = s.email and mu.entity = ".((int) $conf->entity).")";
}
@@ -214,13 +215,13 @@ class mailing_partnership extends MailingTargets
*/
public function formFilter()
{
- global $conf, $langs;
+ global $conf, $langs, $form;
$langs->load("companies");
$s = '';
- // Show categories
+ // Show type of partnership
$sql = "SELECT rowid, label, code, active";
$sql .= " FROM ".MAIN_DB_PREFIX."c_partnership_type";
$sql .= " WHERE active = 1";
@@ -255,6 +256,13 @@ class mailing_partnership extends MailingTargets
$s .= ' ';
+ // filter_status_thirdparties
+ include_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php';
+ $tmppartnership = new Partnership($this->db);
+ $dummy = $tmppartnership->getLibStatut(0); // We call this only to have $tmppartnership->labelStatus loaded
+
+ $s .= $form->selectarray('filter_status_partnership', $tmppartnership->labelStatus, GETPOST('filter_status_partnership'), $langs->trans("Status"));
+
return $s;
}
diff --git a/htdocs/core/modules/mailings/pomme.modules.php b/htdocs/core/modules/mailings/pomme.modules.php
index 2d2dd7e1809..cd93813cf68 100644
--- a/htdocs/core/modules/mailings/pomme.modules.php
+++ b/htdocs/core/modules/mailings/pomme.modules.php
@@ -41,11 +41,6 @@ class mailing_pomme extends MailingTargets
*/
public $picto = 'user';
- /**
- * @var DoliDB Database handler.
- */
- public $db;
-
/**
* Constructor
diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php
index e678dab33ed..16194db6862 100644
--- a/htdocs/core/modules/mailings/thirdparties.modules.php
+++ b/htdocs/core/modules/mailings/thirdparties.modules.php
@@ -38,11 +38,6 @@ class mailing_thirdparties extends MailingTargets
*/
public $picto = 'company';
- /**
- * @var DoliDB Database handler.
- */
- public $db;
-
/**
* Constructor
diff --git a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php
index 6c6812759d7..0cf133df273 100644
--- a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php
+++ b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php
@@ -36,11 +36,6 @@ class mailing_thirdparties_services_expired extends MailingTargets
*/
public $picto = 'company';
- /**
- * @var DoliDB Database handler.
- */
- public $db;
-
public $arrayofproducts = array();
diff --git a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php
index 5a06a25f529..9823db229c1 100644
--- a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php
+++ b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php
@@ -133,17 +133,18 @@ class doc_generic_member_odt extends ModelePDFMember
}
}
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
+ $texthelp .= ''.$langs->trans("ExampleOfDirectoriesForModelGen").' ';
// Add list of substitution keys
$texthelp .= ' '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").' ';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
- $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
+ $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
$texte .= '';
// Scan directories
@@ -168,15 +169,10 @@ class doc_generic_member_odt extends ModelePDFMember
}
$texte .= ' ';
$texte .= ' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= '';
$texte .= '';
- $texte .= '';
- $texte .= '';
- $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
- $texte .= ' ';
- $texte .= ' ';
$texte .= '';
$texte .= '';
diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php
index 43a7128b1d0..3d451bd93d6 100644
--- a/htdocs/core/modules/modAgenda.class.php
+++ b/htdocs/core/modules/modAgenda.class.php
@@ -214,7 +214,7 @@ class modAgenda extends DolibarrModules
'url'=>'/comm/action/index.php',
'langs'=>'agenda',
'position'=>86,
- 'perms'=>'$user->rights->agenda->myactions->read || $user->rights->resource->read',
+ 'perms'=>'$user->hasRight("agenda", "myactions", "read") || $user->hasRight("resource", "read")',
'enabled'=>'isModEnabled("agenda") || isModEnabled("resource")',
'target'=>'',
'user'=>2,
@@ -230,7 +230,7 @@ class modAgenda extends DolibarrModules
'url'=>'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda',
'langs'=>'agenda',
'position'=>100,
- 'perms'=>'$user->rights->agenda->myactions->read',
+ 'perms'=>'$user->hasRight("agenda", "myactions", "read")',
'enabled'=>'isModEnabled("agenda")',
'target'=>'',
'user'=>2,
@@ -244,7 +244,7 @@ class modAgenda extends DolibarrModules
'url'=>'/comm/action/card.php?mainmenu=agenda&leftmenu=agenda&action=create',
'langs'=>'commercial',
'position'=>101,
- 'perms'=>'($user->hasRight("agenda", "myactions", "create")||$user->hasRight("agenda", "allactions", "create"))',
+ 'perms'=>'($user->hasRight("agenda", "myactions", "create") || $user->hasRight("agenda", "allactions", "create"))',
'enabled'=>'isModEnabled("agenda")',
'target'=>'',
'user'=>2
@@ -259,7 +259,7 @@ class modAgenda extends DolibarrModules
'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda',
'langs'=>'agenda',
'position'=>140,
- 'perms'=>'$user->rights->agenda->myactions->read',
+ 'perms'=>'$user->hasRight("agenda", "myactions", "read")',
'enabled'=>'isModEnabled("agenda")',
'target'=>'',
'user'=>2
@@ -273,7 +273,7 @@ class modAgenda extends DolibarrModules
'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine',
'langs'=>'agenda',
'position'=>141,
- 'perms'=>'$user->rights->agenda->myactions->read',
+ 'perms'=>'$user->hasRight("agenda", "myactions", "read")',
'enabled'=>'isModEnabled("agenda")',
'target'=>'',
'user'=>2
@@ -287,7 +287,7 @@ class modAgenda extends DolibarrModules
'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=done&filter=mine',
'langs'=>'agenda',
'position'=>142,
- 'perms'=>'$user->rights->agenda->myactions->read',
+ 'perms'=>'$user->hasRight("agenda", "myactions", "read")',
'enabled'=>'isModEnabled("agenda")',
'target'=>'',
'user'=>2
@@ -301,8 +301,8 @@ class modAgenda extends DolibarrModules
'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1',
'langs'=>'agenda',
'position'=>143,
- 'perms'=>'$user->rights->agenda->allactions->read',
- 'enabled'=>'$user->rights->agenda->allactions->read',
+ 'perms'=>'$user->hasRight("agenda", "allactions", "read")',
+ 'enabled'=>'isModEnabled("agenda")',
'target'=>'',
'user'=>2
);
@@ -315,8 +315,8 @@ class modAgenda extends DolibarrModules
'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1',
'langs'=>'agenda',
'position'=>144,
- 'perms'=>'$user->rights->agenda->allactions->read',
- 'enabled'=>'$user->rights->agenda->allactions->read',
+ 'perms'=>'$user->hasRight("agenda", "allactions", "read")',
+ 'enabled'=>'isModEnabled("agenda")',
'target'=>'',
'user'=>2
);
@@ -331,7 +331,7 @@ class modAgenda extends DolibarrModules
'url'=>'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda',
'langs'=>'agenda',
'position'=>110,
- 'perms'=>'$user->rights->agenda->myactions->read',
+ 'perms'=>'$user->hasRight("agenda", "myactions", "read")',
'enabled'=>'isModEnabled("agenda")',
'target'=>'',
'user'=>2
@@ -345,7 +345,7 @@ class modAgenda extends DolibarrModules
'url'=>'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine',
'langs'=>'agenda',
'position'=>111,
- 'perms'=>'$user->rights->agenda->myactions->read',
+ 'perms'=>'$user->hasRight("agenda", "myactions", "read")',
'enabled'=>'isModEnabled("agenda")',
'target'=>'',
'user'=>2
@@ -359,7 +359,7 @@ class modAgenda extends DolibarrModules
'url'=>'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=done&filter=mine',
'langs'=>'agenda',
'position'=>112,
- 'perms'=>'$user->rights->agenda->myactions->read',
+ 'perms'=>'$user->hasRight("agenda", "myactions", "read")',
'enabled'=>'isModEnabled("agenda")',
'target'=>'',
'user'=>2
@@ -373,8 +373,8 @@ class modAgenda extends DolibarrModules
'url'=>'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1',
'langs'=>'agenda',
'position'=>113,
- 'perms'=>'$user->rights->agenda->allactions->read',
- 'enabled'=>'$user->rights->agenda->allactions->read',
+ 'perms'=>'$user->hasRight("agenda", "allactions", "read")',
+ 'enabled'=>'isModEnabled("agenda")',
'target'=>'',
'user'=>2
);
@@ -387,8 +387,8 @@ class modAgenda extends DolibarrModules
'url'=>'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1',
'langs'=>'agenda',
'position'=>114,
- 'perms'=>'$user->rights->agenda->allactions->read',
- 'enabled'=>'$user->rights->agenda->allactions->read',
+ 'perms'=>'$user->hasRight("agenda", "allactions", "read")',
+ 'enabled'=>'isModEnabled("agenda")',
'target'=>'',
'user'=>2
);
@@ -402,7 +402,7 @@ class modAgenda extends DolibarrModules
'url'=>'/comm/action/rapport/index.php?mainmenu=agenda&leftmenu=agenda',
'langs'=>'agenda',
'position'=>160,
- 'perms'=>'$user->rights->agenda->allactions->read',
+ 'perms'=>'$user->hasRight("agenda", "allactions", "read")',
'enabled'=>'isModEnabled("agenda")',
'target'=>'',
'user'=>2
@@ -417,8 +417,8 @@ class modAgenda extends DolibarrModules
'url'=>'/categories/index.php?mainmenu=agenda&leftmenu=agenda&type=10',
'langs' => 'agenda',
'position' => 170,
- 'perms' => '$user->rights->agenda->allactions->read',
- 'enabled' => '$conf->categorie->enabled',
+ 'perms' => '$user->hasRight("agenda", "allactions", "read")',
+ 'enabled' => 'isModEnabled("categorie")',
'target' => '',
'user' => 2
);
diff --git a/htdocs/core/modules/modApi.class.php b/htdocs/core/modules/modApi.class.php
index acceaa822d1..9621904ebe6 100644
--- a/htdocs/core/modules/modApi.class.php
+++ b/htdocs/core/modules/modApi.class.php
@@ -163,7 +163,6 @@ class modApi extends DolibarrModules
'langs'=>'modulebuilder',
'position'=>100,
'perms'=>'1',
- //'enabled'=>'isModEnabled("api") && preg_match(\'/^(devtools)/\',$leftmenu)',
'enabled'=>'isModEnabled("api")',
'target'=>'_apiexplorer',
'user'=>0);
diff --git a/htdocs/core/modules/modBookCal.class.php b/htdocs/core/modules/modBookCal.class.php
index fbbc4180423..07237b63d45 100644
--- a/htdocs/core/modules/modBookCal.class.php
+++ b/htdocs/core/modules/modBookCal.class.php
@@ -297,7 +297,7 @@ class modBookCal extends DolibarrModules
$r = 0;
// Add here entries to declare new menus
/* BEGIN MODULEBUILDER TOPMENU */
- $this->menu[$r++] = array(
+ /*$this->menu[$r++] = array(
'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type'=>'top', // This is a Top menu entry
'titre'=>'ModuleBookCalName',
@@ -311,18 +311,33 @@ class modBookCal extends DolibarrModules
'perms'=>'$user->rights->bookcal->availabilities->read', // Use 'perms'=>'$user->rights->bookcal->availabilities->read' if you want your menu with a permission rules
'target'=>'',
'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
- );
+ );*/
/* END MODULEBUILDER TOPMENU */
/* BEGIN MODULEBUILDER LEFTMENU CALENDAR */
+ $this->menu[$r++] = array(
+ 'fk_menu'=>'fk_mainmenu=agenda',
+ 'type'=>'left',
+ 'titre'=> 'MenuBookcalIndex',
+ 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth em92"'),
+ 'mainmenu'=>'agenda',
+ 'leftmenu'=> 'bookcal',
+ 'url'=> '/bookcal/bookcalindex.php',
+ 'langs'=> 'bookcal',
+ 'position'=> 1100+$r,
+ 'enabled'=> '1',
+ 'perms'=> '$user->rights->bookcal->calendar->read',
+ 'user'=> 0
+ );
+
$this->menu[$r++]=array(
// '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
- 'fk_menu'=>'fk_mainmenu=bookcal',
+ 'fk_menu'=>'fk_mainmenu=agenda,fk_leftmenu=bookcal',
// This is a Left menu entry
'type'=>'left',
- 'titre'=>'List Calendar',
- 'mainmenu'=>'bookcal',
- 'leftmenu'=>'bookcal_calendar',
+ 'titre'=>'Calendar',
+ 'mainmenu'=>'agenda',
+ 'leftmenu'=>'bookcal_calendar_list',
'url'=>'/bookcal/calendar_list.php',
// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'langs'=>'bookcal',
@@ -337,12 +352,12 @@ class modBookCal extends DolibarrModules
);
$this->menu[$r++]=array(
// '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
- 'fk_menu'=>'fk_mainmenu=bookcal,fk_leftmenu=bookcal_calendar',
+ 'fk_menu'=>'fk_mainmenu=agenda,fk_leftmenu=bookcal_calendar_list',
// This is a Left menu entry
'type'=>'left',
- 'titre'=>'New Calendar',
- 'mainmenu'=>'bookcal',
- 'leftmenu'=>'bookcal_calendar',
+ 'titre'=>'NewCalendar',
+ 'mainmenu'=>'agenda',
+ 'leftmenu'=>'bookcal_new',
'url'=>'/bookcal/calendar_card.php?action=create',
// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'langs'=>'bookcal',
@@ -405,11 +420,11 @@ class modBookCal extends DolibarrModules
$this->menu[$r++]=array(
// '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
- 'fk_menu'=>'fk_mainmenu=bookcal',
+ 'fk_menu'=>'fk_mainmenu=agenda,fk_leftmenu=bookcal',
// This is a Left menu entry
'type'=>'left',
- 'titre'=>'List Availabilities',
- 'mainmenu'=>'bookcal',
+ 'titre'=>'Availabilities',
+ 'mainmenu'=>'agenda',
'leftmenu'=>'bookcal_availabilities',
'url'=>'/bookcal/availabilities_list.php',
// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
@@ -425,11 +440,11 @@ class modBookCal extends DolibarrModules
);
$this->menu[$r++]=array(
// '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
- 'fk_menu'=>'fk_mainmenu=bookcal,fk_leftmenu=bookcal_availabilities',
+ 'fk_menu'=>'fk_mainmenu=agenda,fk_leftmenu=bookcal_availabilities',
// This is a Left menu entry
'type'=>'left',
- 'titre'=>'New Availabilities',
- 'mainmenu'=>'bookcal',
+ 'titre'=>'NewAvailabilities',
+ 'mainmenu'=>'agenda',
'leftmenu'=>'bookcal_availabilities',
'url'=>'/bookcal/availabilities_card.php?action=create',
// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
diff --git a/htdocs/core/modules/modDynamicPrices.class.php b/htdocs/core/modules/modDynamicPrices.class.php
index 23a0f892014..bfaf11dbf4c 100644
--- a/htdocs/core/modules/modDynamicPrices.class.php
+++ b/htdocs/core/modules/modDynamicPrices.class.php
@@ -84,4 +84,27 @@ class modDynamicPrices extends DolibarrModules
$this->rights_class = 'dynamicprices';
$r = 0;
}
+
+ /**
+ * Function called when module is enabled.
+ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
+ * It also creates data directories.
+ *
+ * @param string $options Options
+ * @return int 1 if OK, 0 if KO
+ */
+ public function init($options = '')
+ {
+ $result = $this->_load_tables('/install/mysql/', 'dynamicprices');
+ if ($result < 0) {
+ return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
+ }
+
+ // Remove permissions and default values
+ $this->remove($options);
+
+ $sql = array();
+
+ return $this->_init($sql, $options);
+ }
}
diff --git a/htdocs/core/modules/modEmailCollector.class.php b/htdocs/core/modules/modEmailCollector.class.php
index a6e27a546b9..cf9f0dbc5f1 100644
--- a/htdocs/core/modules/modEmailCollector.class.php
+++ b/htdocs/core/modules/modEmailCollector.class.php
@@ -91,8 +91,6 @@ class modEmailCollector extends DolibarrModules
$this->requiredby = array(); // List of module ids to disable if this one is disabled
$this->conflictwith = array(); // List of module class names as string this module is in conflict with
$this->langfiles = array("admin");
- $this->phpmin = array(7, 0); // Minimum version of PHP required by module
- $this->need_dolibarr_version = array(7, 0); // Minimum version of Dolibarr required by module
$this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
$this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
//$this->automatic_activation = array('FR'=>'davWasAutomaticallyActivatedBecauseOfYourCountryChoice');
@@ -159,7 +157,7 @@ class modEmailCollector extends DolibarrModules
// Cronjobs (List of cron jobs entries to add when module is enabled)
// unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
$this->cronjobs = array(
- 0=>array('label'=>'Email collector', 'priority'=>50, 'jobtype'=>'method', 'class'=>'/emailcollector/class/emailcollector.class.php', 'objectname'=>'EmailCollector', 'method'=>'doCollect', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>5, 'unitfrequency'=>60, 'status'=>1, 'test'=>'$conf->emailcollector->enabled')
+ 0=>array('label'=>'Email collector', 'priority'=>50, 'jobtype'=>'method', 'class'=>'/emailcollector/class/emailcollector.class.php', 'objectname'=>'EmailCollector', 'method'=>'doCollect', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>5, 'unitfrequency'=>60, 'status'=>1, 'test'=>'isModEnabled("emailcollector")')
);
diff --git a/htdocs/core/modules/modExpenseReport.class.php b/htdocs/core/modules/modExpenseReport.class.php
index 536aabd086c..a1ab6b43026 100644
--- a/htdocs/core/modules/modExpenseReport.class.php
+++ b/htdocs/core/modules/modExpenseReport.class.php
@@ -245,6 +245,11 @@ class modExpenseReport extends DolibarrModules
{
global $conf;
+ $result = $this->_load_tables('/install/mysql/', 'expensereport');
+ if ($result < 0) {
+ return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
+ }
+
// Remove permissions and default values
$this->remove($options);
diff --git a/htdocs/core/modules/modPartnership.class.php b/htdocs/core/modules/modPartnership.class.php
index b8aafc853fb..48244ae0455 100644
--- a/htdocs/core/modules/modPartnership.class.php
+++ b/htdocs/core/modules/modPartnership.class.php
@@ -253,8 +253,8 @@ class modPartnership extends DolibarrModules
$datestart=dol_mktime(21, 15, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']);
$this->cronjobs = array(
- 0 => array('priority'=>60, 'label'=>'CancelPartnershipForExpiredMembers', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doCancelStatusOfMemberPartnership', 'parameters'=>'', 'comment'=>'Cancel status of partnership when subscription is expired + x days.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>1, 'test'=>'$conf->partnership->enabled', 'datestart'=>$datestart),
- 1 => array('priority'=>61, 'label'=>'PartnershipCheckBacklink', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doWarningOfPartnershipIfDolibarrBacklinkNotfound', 'parameters'=>'', 'comment'=>'Warning of partnership if Dolibarr backlink not found on partner website.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>0, 'test'=>'$conf->partnership->enabled', 'datestart'=>$datestart),
+ 0 => array('priority'=>60, 'label'=>'CancelPartnershipForExpiredMembers', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doCancelStatusOfMemberPartnership', 'parameters'=>'', 'comment'=>'Cancel status of partnership when subscription is expired + x days.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>1, 'test'=>'isModEnabled("partnership")', 'datestart'=>$datestart),
+ 1 => array('priority'=>61, 'label'=>'PartnershipCheckBacklink', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doWarningOfPartnershipIfDolibarrBacklinkNotfound', 'parameters'=>'', 'comment'=>'Add a warning on partnership record if the backlink keyword is not found on the partner website.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>0, 'test'=>'isModEnabled("partnership")', 'datestart'=>$datestart),
);
// Permissions provided by this module
diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php
index 9595226f701..560fd286c2b 100644
--- a/htdocs/core/modules/modProduct.class.php
+++ b/htdocs/core/modules/modProduct.class.php
@@ -68,7 +68,7 @@ class modProduct extends DolibarrModules
// Dependencies
$this->hidden = false; // A condition to hide module
$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
- $this->requiredby = array("modStock", "modBarcode", "modProductBatch", "modVariants"); // List of module ids to disable if this one is disabled
+ $this->requiredby = array("modStock", "modBarcode", "modProductBatch", "modVariants", "modBom"); // List of module ids to disable if this one is disabled
$this->conflictwith = array(); // List of module class names as string this module is in conflict with
$this->phpmin = array(7, 0); // Minimum version of PHP required by module
@@ -356,7 +356,7 @@ class modProduct extends DolibarrModules
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity
$this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile
- $this->export_sql_end[$r] .= ' AND pr.date_price = (SELECT MAX(pr2.date_price) FROM '.MAIN_DB_PREFIX.'product_price as pr2 WHERE pr2.fk_product = pr.fk_product AND pr2.entity IN ('.getEntity('product').'))'; // export only latest prices not full history
+ $this->export_sql_end[$r] .= ' AND pr.date_price = (SELECT MAX(pr2.date_price) FROM '.MAIN_DB_PREFIX.'product_price as pr2 WHERE pr2.fk_product = pr.fk_product AND pr2.price_level = pr.price_level AND pr2.entity IN ('.getEntity('product').'))'; // export only latest prices not full history
$this->export_sql_end[$r] .= ' ORDER BY p.ref, pr.price_level';
}
diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php
index 2461118572a..b7beb1f4d92 100644
--- a/htdocs/core/modules/modPropale.class.php
+++ b/htdocs/core/modules/modPropale.class.php
@@ -104,6 +104,13 @@ class modPropale extends DolibarrModules
$this->const[$r][4] = 0;
$r++;
+ $this->const[$r][0] = "PROPOSAL_ALLOW_ONLINESIGN";
+ $this->const[$r][1] = "chaine";
+ $this->const[$r][2] = "1";
+ $this->const[$r][3] = "";
+ $this->const[$r][4] = 0;
+ $r++;
+
/*$this->const[$r][0] = "PROPALE_DRAFT_WATERMARK";
$this->const[$r][2] = "__(Draft)__";
$this->const[$r][3] = 'Watermark to show on draft proposals';
diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php
index a684f223812..4863dcbdc09 100644
--- a/htdocs/core/modules/modSociete.class.php
+++ b/htdocs/core/modules/modSociete.class.php
@@ -397,7 +397,7 @@ class modSociete extends DolibarrModules
'c.statut'=>"Status",
's.rowid'=>"Numeric", 's.nom'=>"Text", 's.status'=>"Status", 's.code_client'=>"Text", 's.code_fournisseur'=>"Text",
's.code_compta'=>"Text", 's.code_compta_fournisseur'=>"Text",
- 's.client'=>"Text", 's.fournisseur'=>"Text",
+ 's.client'=>"Numeric", 's.fournisseur'=>"Numeric",
's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 's.phone'=>"Text", 's.email'=>"Text",
't.code'=>"List:c_stcomm:libelle:code",
'c.entity'=>'List:entity:label:rowid',
diff --git a/htdocs/core/modules/movement/doc/pdf_standard.modules.php b/htdocs/core/modules/movement/doc/pdf_standard.modules.php
index d8daea8ff51..ac53946bb06 100644
--- a/htdocs/core/modules/movement/doc/pdf_standard.modules.php
+++ b/htdocs/core/modules/movement/doc/pdf_standard.modules.php
@@ -37,32 +37,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
*/
class pdf_standard extends ModelePDFMovement
{
- /**
- * @var DoliDb Database handler
- */
- public $db;
-
- /**
- * @var string model description (short text)
- */
- public $description;
-
/**
* @var int Save the name of generated file as the main doc when generating a doc with this template
*/
public $update_main_doc_field;
- /**
- * @var string document type
- */
- public $type;
-
- /**
- * Dolibarr version of the loaded document
- * @var string
- */
- public $version = 'dolibarr';
-
public $wref;
public $posxidref;
public $posxdatemouv;
@@ -104,7 +83,6 @@ class pdf_standard extends ModelePDFMovement
$this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10);
$this->option_logo = 1; // Display logo
- $this->option_codestockservice = 0; // Display stock-service code
$this->option_multilang = 1; // Available in several languages
$this->option_freetext = 0; // Support add of a personalised text
@@ -707,6 +685,14 @@ class pdf_standard extends ModelePDFMovement
dol_print_error($this->db);
}
+ // Display notes
+ $notetoshow = empty($object->note_public) ? '' : $object->note_public;
+ // Extrafields in note
+ $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
+ if (!empty($extranote)) {
+ $notetoshow = dol_concatdesc($notetoshow, $extranote);
+ }
+
if ($notetoshow) {
$substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
diff --git a/htdocs/core/modules/movement/modules_movement.php b/htdocs/core/modules/movement/modules_movement.php
index 864f1bd4c7c..0525793a715 100644
--- a/htdocs/core/modules/movement/modules_movement.php
+++ b/htdocs/core/modules/movement/modules_movement.php
@@ -30,7 +30,26 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
*/
abstract class ModelePDFMovement extends CommonDocGenerator
{
- public $option_codestockservice;
+ /**
+ * @var DoliDb Database handler
+ */
+ public $db;
+
+ /**
+ * @var string model description (short text)
+ */
+ public $description;
+
+ /**
+ * @var string document type
+ */
+ public $type;
+
+ /**
+ * Dolibarr version of the loaded document
+ * @var string
+ */
+ public $version = 'dolibarr';
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
diff --git a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php
index 1bb999da071..f24f77cb946 100644
--- a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php
+++ b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php
@@ -136,17 +136,18 @@ class doc_generic_mo_odt extends ModelePDFMo
}
}
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
+ $texthelp .= ''.$langs->trans("ExampleOfDirectoriesForModelGen").' ';
// Add list of substitution keys
$texthelp .= ' '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").' ';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
- $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
+ $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
$texte .= '';
// Scan directories
@@ -172,11 +173,6 @@ class doc_generic_mo_odt extends ModelePDFMo
$texte .= '';
- $texte .= '';
- $texte .= '';
- $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
- $texte .= ' ';
- $texte .= ' ';
$texte .= '';
$texte .= '';
diff --git a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php
index f777ed3b6a2..7be587e7c0e 100644
--- a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php
+++ b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php
@@ -5,7 +5,7 @@
* Copyright (C) 2010-2014 Juanjo Menent
* Copyright (C) 2015 Marcos García
* Copyright (C) 2017 Ferran Marcet
- * Copyright (C) 2018-2021 Frédéric France
+ * Copyright (C) 2018-2023 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -969,9 +969,10 @@ class pdf_vinci extends ModelePDFMo
$pdf->SetFont('', '', $default_font_size - 2);
if (empty($hidetop)) {
- //$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
- $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
- $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
+ // $title = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
+ $title = '';
+ $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($title) + 3), $tab_top - 4);
+ $pdf->MultiCell(($pdf->GetStringWidth($title) + 3), 2, $title);
//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
diff --git a/htdocs/core/modules/mrp/mod_mo_advanced.php b/htdocs/core/modules/mrp/mod_mo_advanced.php
index 47cb69f1627..2fc5985cc84 100644
--- a/htdocs/core/modules/mrp/mod_mo_advanced.php
+++ b/htdocs/core/modules/mrp/mod_mo_advanced.php
@@ -83,7 +83,7 @@ class mod_mo_advanced extends ModeleNumRefMos
$texte .= ''.$langs->trans("Mask").': ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= ' ';
diff --git a/htdocs/core/modules/payment/mod_payment_ant.php b/htdocs/core/modules/payment/mod_payment_ant.php
index 0e689453a1e..6fe019dde3b 100644
--- a/htdocs/core/modules/payment/mod_payment_ant.php
+++ b/htdocs/core/modules/payment/mod_payment_ant.php
@@ -85,7 +85,7 @@ class mod_payment_ant extends ModeleNumRefPayments
$texte .= ''.$langs->trans("Mask").': ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= ' ';
diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php
index cb2d773b928..821aa6d8836 100644
--- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php
+++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php
@@ -134,17 +134,18 @@ class doc_generic_product_odt extends ModelePDFProduct
}
}
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
+ $texthelp .= ''.$langs->trans("ExampleOfDirectoriesForModelGen").' ';
// Add list of substitution keys
$texthelp .= ' '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").' ';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
- $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
+ $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
$texte .= '';
// Scan directories
@@ -173,16 +174,11 @@ class doc_generic_product_odt extends ModelePDFProduct
}
$texte .= ' ';
$texte .= ' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= '';
$texte .= '';
- $texte .= '';
- $texte .= '';
- $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
- $texte .= ' ';
- $texte .= ' ';
$texte .= '';
$texte .= '';
diff --git a/htdocs/core/modules/product/mod_codeproduct_elephant.php b/htdocs/core/modules/product/mod_codeproduct_elephant.php
index c883de79c5e..a77ee4de156 100644
--- a/htdocs/core/modules/product/mod_codeproduct_elephant.php
+++ b/htdocs/core/modules/product/mod_codeproduct_elephant.php
@@ -119,7 +119,7 @@ class mod_codeproduct_elephant extends ModeleProductCode
$texte .= ''.$langs->trans("Mask").' ('.$langs->trans("ProductCodeModel").'): ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= ' ';
diff --git a/htdocs/core/modules/product_batch/mod_lot_advanced.php b/htdocs/core/modules/product_batch/mod_lot_advanced.php
index de173a93b8c..18c5cba5b46 100644
--- a/htdocs/core/modules/product_batch/mod_lot_advanced.php
+++ b/htdocs/core/modules/product_batch/mod_lot_advanced.php
@@ -86,7 +86,7 @@ class mod_lot_advanced extends ModeleNumRefBatch
$texte .= ''.$langs->trans("Mask").': ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
// Option to enable custom masks per product
$texte .= '';
diff --git a/htdocs/core/modules/product_batch/mod_sn_advanced.php b/htdocs/core/modules/product_batch/mod_sn_advanced.php
index 8b61a475603..fb6866742ff 100644
--- a/htdocs/core/modules/product_batch/mod_sn_advanced.php
+++ b/htdocs/core/modules/product_batch/mod_sn_advanced.php
@@ -86,7 +86,7 @@ class mod_sn_advanced extends ModeleNumRefBatch
$texte .= ' '.$langs->trans("Mask").': ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
// Option to enable custom masks per product
$texte .= '';
diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php
index 6b0c45d4754..5ad570a3a35 100644
--- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php
+++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php
@@ -430,17 +430,18 @@ class doc_generic_project_odt extends ModelePDFProjects
}
}
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
+ $texthelp .= ''.$langs->trans("ExampleOfDirectoriesForModelGen").' ';
// Add list of substitution keys
$texthelp .= ' '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").' ';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
- $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
+ $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
$texte .= '';
// Scan directories
@@ -466,11 +467,6 @@ class doc_generic_project_odt extends ModelePDFProjects
$texte .= ' ';
- $texte .= '';
- $texte .= '';
- $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
- $texte .= ' ';
- $texte .= ' ';
$texte .= ' ';
$texte .= '';
diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php
index 117ad829408..f4f413758a3 100644
--- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php
+++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php
@@ -63,6 +63,16 @@ class pdf_baleine extends ModelePDFProjects
*/
public $type;
+ /**
+ * @var int posxdatestart
+ */
+ public $posxdatestart;
+
+ /**
+ * @var int posxdateend
+ */
+ public $posxdateend;
+
/**
* Dolibarr version of the loaded document
* @var string
diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php
index 0afff52ee73..a7cf4c50b96 100644
--- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php
+++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php
@@ -88,10 +88,10 @@ class pdf_beluga extends ModelePDFProjects
public $posxref;
public $posxdate;
- public $posxsociete;
+ public $posxsociety;
public $posxamountht;
public $posxamountttc;
- public $posstatut;
+ public $posxstatut;
/**
@@ -156,10 +156,10 @@ class pdf_beluga extends ModelePDFProjects
if ($this->page_largeur < 210) { // To work with US executive format
$this->posxref -= 20;
$this->posxdate -= 20;
- $this->posxsociete -= 20;
+ $this->posxsociety -= 20;
$this->posxamountht -= 20;
$this->posxamountttc -= 20;
- $this->posstatut -= 20;
+ $this->posxstatut -= 20;
}
}
diff --git a/htdocs/core/modules/project/mod_project_universal.php b/htdocs/core/modules/project/mod_project_universal.php
index c75e3dcf385..4f2f5a421ae 100644
--- a/htdocs/core/modules/project/mod_project_universal.php
+++ b/htdocs/core/modules/project/mod_project_universal.php
@@ -91,7 +91,7 @@ class mod_project_universal extends ModeleNumRefProjects
$texte .= ''.$langs->trans("Mask").': ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= ' ';
diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php
index 788780298eb..fd82c477e85 100644
--- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php
+++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php
@@ -395,17 +395,18 @@ class doc_generic_task_odt extends ModelePDFTask
}
}
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
+ $texthelp .= ''.$langs->trans("ExampleOfDirectoriesForModelGen").' ';
// Add list of substitution keys
$texthelp .= ' '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").' ';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
- $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
+ $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
$texte .= '';
// Scan directories
@@ -431,11 +432,6 @@ class doc_generic_task_odt extends ModelePDFTask
$texte .= '';
- $texte .= '';
- $texte .= '';
- $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
- $texte .= ' ';
- $texte .= ' ';
$texte .= '';
$texte .= '';
@@ -532,6 +528,8 @@ class doc_generic_task_odt extends ModelePDFTask
);
complete_substitutions_array($substitutionarray, $langs, $object);
// Call the ODTSubstitution hook
+ $tmparray = array();
+ $action = '';
$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
diff --git a/htdocs/core/modules/project/task/mod_task_universal.php b/htdocs/core/modules/project/task/mod_task_universal.php
index 6d060f6534d..add0de5d9e4 100644
--- a/htdocs/core/modules/project/task/mod_task_universal.php
+++ b/htdocs/core/modules/project/task/mod_task_universal.php
@@ -86,7 +86,7 @@ class mod_task_universal extends ModeleNumRefTask
$texte .= ''.$langs->trans("Mask").': ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= ' ';
diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php
index 47b157c8d57..5a10e24333f 100644
--- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php
+++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php
@@ -144,17 +144,18 @@ class doc_generic_proposal_odt extends ModelePDFPropales
}
}
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
+ $texthelp .= ''.$langs->trans("ExampleOfDirectoriesForModelGen").' ';
// Add list of substitution keys
$texthelp .= ' '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").' ';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
- $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
+ $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
$texte .= '';
// Scan directories
@@ -212,15 +213,10 @@ class doc_generic_proposal_odt extends ModelePDFPropales
}
$texte .= ' ';
$texte .= ' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= '';
$texte .= '';
- $texte .= '';
- $texte .= '';
- $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
- $texte .= ' ';
- $texte .= ' ';
$texte .= '';
$texte .= '';
@@ -413,6 +409,13 @@ class doc_generic_proposal_odt extends ModelePDFPropales
$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
$array_other = $this->get_substitutionarray_other($outputlangs);
+
+ include_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
+ $companybankaccount = new CompanyBankAccount($this->db);
+ $companybankaccount->fetch(0, $object->thirdparty->id);
+ $array_objet['company_default_bank_iban']=$companybankaccount->iban;
+ $array_objet['company_default_bank_bic']=$companybankaccount->bic;
+
// retrieve contact information for use in object as contact_xxx tags
$array_thirdparty_contact = array();
if ($usecontact && is_object($contactobject)) {
diff --git a/htdocs/core/modules/propale/mod_propale_saphir.php b/htdocs/core/modules/propale/mod_propale_saphir.php
index fb5e4866a37..cfa06eb5f01 100644
--- a/htdocs/core/modules/propale/mod_propale_saphir.php
+++ b/htdocs/core/modules/propale/mod_propale_saphir.php
@@ -89,7 +89,7 @@ class mod_propale_saphir extends ModeleNumRefPropales
$mask = empty($conf->global->PROPALE_SAPHIR_MASK) ? '' : $conf->global->PROPALE_SAPHIR_MASK;
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= '';
diff --git a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php
index 259c949a634..12b5e9094e6 100644
--- a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php
+++ b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php
@@ -131,17 +131,18 @@ class doc_generic_reception_odt extends ModelePdfReception
}
}
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
+ $texthelp .= ''.$langs->trans("ExampleOfDirectoriesForModelGen").' ';
// Add list of substitution keys
$texthelp .= ' '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").' ';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
- $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
+ $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
$texte .= '';
// Scan directories
@@ -172,16 +173,11 @@ class doc_generic_reception_odt extends ModelePdfReception
}
$texte .= ' ';
$texte .= ' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= '';
$texte .= '';
- $texte .= '';
- $texte .= '';
- $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
- $texte .= ' ';
- $texte .= ' ';
$texte .= '';
$texte .= '';
@@ -228,7 +224,7 @@ class doc_generic_reception_odt extends ModelePdfReception
$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
- if ($conf->reception->dir_output."/reception") {
+ if ($conf->reception->dir_output) {
// If $object is id instead of object
if (!is_object($object)) {
$id = $object;
@@ -242,7 +238,7 @@ class doc_generic_reception_odt extends ModelePdfReception
$object->fetch_thirdparty();
- $dir = $conf->reception->dir_output."/reception";
+ $dir = !empty($conf->reception->multidir_output[$object->entity]) ? $conf->reception->multidir_output[$object->entity] : $conf->reception->dir_output;
$objectref = dol_sanitizeFileName($object->ref);
if (!preg_match('/specimen/i', $objectref)) {
$dir .= "/".$objectref;
diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php
index 1c1e4c76010..3d6d282bf8e 100644
--- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php
+++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php
@@ -1,5 +1,6 @@
+/* Copyright (C) 2018 Quentin Vial-Gouteyron
+ * Copyright (C) 2023 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -37,6 +38,26 @@ class pdf_squille extends ModelePdfReception
*/
public $version = 'dolibarr';
+ /**
+ * @var int posx weight vol
+ */
+ public $posxweightvol;
+
+ /**
+ * @var int posx qty ordered
+ */
+ public $posxqtyordered;
+
+ /**
+ * @var int posx qty to ship
+ */
+ public $posxqtytoship;
+
+ /**
+ * @var int posx totalht
+ */
+ public $posxtotalht;
+
/**
* Constructor
@@ -617,7 +638,7 @@ class pdf_squille extends ModelePdfReception
* Show total to pay
*
* @param TCPDF $pdf Object PDF
- * @param Facture $object Object invoice
+ * @param Reception $object Object reception
* @param int $deja_regle Montant deja regle
* @param int $posy Position depart
* @param Translate $outputlangs Objet langs
@@ -829,7 +850,7 @@ class pdf_squille extends ModelePdfReception
* Show top header of page.
*
* @param TCPDF $pdf Object PDF
- * @param Object $object Object to show
+ * @param Reception $object Object to show
* @param int $showaddress 0=no, 1=yes
* @param Translate $outputlangs Object lang for output
* @return void
diff --git a/htdocs/core/modules/reception/mod_reception_moonstone.php b/htdocs/core/modules/reception/mod_reception_moonstone.php
index d9c245556d7..b7ab238caec 100644
--- a/htdocs/core/modules/reception/mod_reception_moonstone.php
+++ b/htdocs/core/modules/reception/mod_reception_moonstone.php
@@ -63,7 +63,7 @@ class mod_reception_moonstone extends ModelNumRefReception
$texte .= ''.$langs->trans("Mask").': ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= ' ';
$texte .= '';
$texte .= '';
diff --git a/htdocs/core/modules/security/generate/modGeneratePassNone.class.php b/htdocs/core/modules/security/generate/modGeneratePassNone.class.php
index 3ec764c6ab2..66621512b54 100644
--- a/htdocs/core/modules/security/generate/modGeneratePassNone.class.php
+++ b/htdocs/core/modules/security/generate/modGeneratePassNone.class.php
@@ -51,16 +51,6 @@ class modGeneratePassNone extends ModeleGenPassword
*/
public $length2;
- /**
- * @var DoliDB Database handler.
- */
- public $db;
-
- public $conf;
- public $lang;
- public $user;
-
-
/**
* Constructor
*
diff --git a/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php b/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php
index 491ab9757e8..b708404956b 100644
--- a/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php
+++ b/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php
@@ -65,15 +65,6 @@ class modGeneratePassPerso extends ModeleGenPassword
*/
public $WithoutAmbi = 0;
- /**
- * @var DoliDB Database handler.
- */
- public $db;
-
- public $conf;
- public $lang;
- public $user;
-
public $Maj;
public $Min;
public $Nb;
diff --git a/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php b/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php
index b2d0b260ccb..0bab8e8b32b 100644
--- a/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php
+++ b/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php
@@ -51,16 +51,6 @@ class modGeneratePassStandard extends ModeleGenPassword
*/
public $length2;
- /**
- * @var DoliDB Database handler.
- */
- public $db;
-
- public $conf;
- public $lang;
- public $user;
-
-
/**
* Constructor
*
diff --git a/htdocs/core/modules/security/generate/modules_genpassword.php b/htdocs/core/modules/security/generate/modules_genpassword.php
index bb1e02774c6..4f5aedc7684 100644
--- a/htdocs/core/modules/security/generate/modules_genpassword.php
+++ b/htdocs/core/modules/security/generate/modules_genpassword.php
@@ -43,6 +43,26 @@ abstract class ModeleGenPassword
*/
public $error = '';
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
+ /**
+ * @var Conf dolibarr conf
+ */
+ public $conf;
+
+ /**
+ * @var Translate Translate Object
+ */
+ public $langs;
+
+ /**
+ * @var User user
+ */
+ public $user;
+
/**
* Return if a module can be used or not
*
diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php
index 98f8f9a63b4..abcbb90877e 100644
--- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php
+++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php
@@ -125,18 +125,19 @@ class doc_generic_odt extends ModeleThirdPartyDoc
}
}
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
+ $texthelp .= ''.$langs->trans("ExampleOfDirectoriesForModelGen").' ';
// Add list of substitution keys
$texthelp .= ' '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").' ';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
- $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
+ $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
$texte .= '';
@@ -170,15 +171,10 @@ class doc_generic_odt extends ModeleThirdPartyDoc
}
$texte .= ' ';
$texte .= ' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= '';
$texte .= '';
- $texte .= '';
- $texte .= '';
- $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
- $texte .= ' ';
- $texte .= ' ';
$texte .= '';
$texte .= '';
diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php
index 100799dff95..c094086e46d 100644
--- a/htdocs/core/modules/societe/mod_codeclient_elephant.php
+++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php
@@ -135,7 +135,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
$texte .= ''.$langs->trans("Mask").' ('.$langs->trans("CustomerCodeModel").'): ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= ' ';
diff --git a/htdocs/core/modules/societe/mod_codeclient_leopard.php b/htdocs/core/modules/societe/mod_codeclient_leopard.php
index aff13d41536..133ba8a470e 100644
--- a/htdocs/core/modules/societe/mod_codeclient_leopard.php
+++ b/htdocs/core/modules/societe/mod_codeclient_leopard.php
@@ -88,6 +88,18 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode
return $langs->trans("LeopardNumRefModelDesc");
}
+ /**
+ * Return an example of result returned by getNextValue
+ *
+ * @param Translate $langs Object langs
+ * @param societe $objsoc Object thirdparty
+ * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect)
+ * @return string Return string example
+ */
+ public function getExample($langs, $objsoc = 0, $type = -1)
+ {
+ return '';
+ }
/**
* Return an example of result returned by getNextValue
diff --git a/htdocs/core/modules/societe/mod_codecompta_aquarium.php b/htdocs/core/modules/societe/mod_codecompta_aquarium.php
index 3805feee4ce..f6eb46fa1b5 100644
--- a/htdocs/core/modules/societe/mod_codecompta_aquarium.php
+++ b/htdocs/core/modules/societe/mod_codecompta_aquarium.php
@@ -113,7 +113,7 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode
$texte .= $langs->trans('COMPANY_AQUARIUM_NO_PREFIX').' = '.$conf->global->COMPANY_AQUARIUM_NO_PREFIX." \n";
}
$texte .= '';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= '';
$texte .= '';
diff --git a/htdocs/core/modules/societe/mod_codecompta_digitaria.php b/htdocs/core/modules/societe/mod_codecompta_digitaria.php
index 2ff2313c998..8590f4d95a4 100644
--- a/htdocs/core/modules/societe/mod_codecompta_digitaria.php
+++ b/htdocs/core/modules/societe/mod_codecompta_digitaria.php
@@ -127,7 +127,7 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode
$texte .= $langs->trans('COMPANY_DIGITARIA_UNIQUE_CODE').' = '.yn(1)." \n";
}
$texte .= '';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= '';
$texte .= '';
diff --git a/htdocs/core/modules/societe/modules_societe.class.php b/htdocs/core/modules/societe/modules_societe.class.php
index f5757f00bac..867760432c3 100644
--- a/htdocs/core/modules/societe/modules_societe.class.php
+++ b/htdocs/core/modules/societe/modules_societe.class.php
@@ -202,7 +202,7 @@ abstract class ModeleAccountancyCode extends CommonNumRefGenerator
*/
public function getToolTip($langs, $soc, $type)
{
- global $conf, $db;
+ global $db;
$langs->load("admin");
diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php
index 5b692e38253..fa7c0160eba 100644
--- a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php
+++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php
@@ -133,17 +133,18 @@ class doc_generic_stock_odt extends ModelePDFStock
}
}
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
+ $texthelp .= ''.$langs->trans("ExampleOfDirectoriesForModelGen").' ';
// Add list of substitution keys
$texthelp .= ' '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").' ';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
- $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
+ $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
$texte .= '';
// Scan directories
@@ -175,16 +176,11 @@ class doc_generic_stock_odt extends ModelePDFStock
}
$texte .= ' ';
$texte .= ' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= '';
$texte .= ' ';
- $texte .= '';
- $texte .= '';
- $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
- $texte .= ' ';
- $texte .= ' ';
$texte .= ' ';
$texte .= '';
diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php
index e951abb3622..35cf7c8e560 100644
--- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php
+++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php
@@ -38,32 +38,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
*/
class pdf_standard extends ModelePDFStock
{
- /**
- * @var DoliDb Database handler
- */
- public $db;
-
- /**
- * @var string model name
- */
- public $name;
-
- /**
- * @var string model description (short text)
- */
- public $description;
-
- /**
- * @var string document type
- */
- public $type;
-
- /**
- * Dolibarr version of the loaded document
- * @var string
- */
- public $version = 'dolibarr';
-
public $wref;
public $posxdesc;
public $posxlabel;
@@ -105,7 +79,6 @@ class pdf_standard extends ModelePDFStock
$this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10);
$this->option_logo = 1; // Display logo
- $this->option_codestockservice = 0; // Display product-service code
$this->option_multilang = 1; // Available in several languages
$this->option_freetext = 0; // Support add of a personalised text
diff --git a/htdocs/core/modules/stock/modules_stock.php b/htdocs/core/modules/stock/modules_stock.php
index 5966c27755c..e0acbea66e5 100644
--- a/htdocs/core/modules/stock/modules_stock.php
+++ b/htdocs/core/modules/stock/modules_stock.php
@@ -23,6 +23,32 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
*/
abstract class ModelePDFStock extends CommonDocGenerator
{
+ /**
+ * @var DoliDb Database handler
+ */
+ public $db;
+
+ /**
+ * @var string model name
+ */
+ public $name;
+
+ /**
+ * @var string model description (short text)
+ */
+ public $description;
+
+ /**
+ * @var string document type
+ */
+ public $type;
+
+ /**
+ * @var string Dolibarr version of the loaded document
+ */
+ public $version = 'dolibarr';
+
+
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php
index ff1b43bcd49..2774358e2e3 100644
--- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php
+++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php
@@ -65,6 +65,18 @@ class pdf_eagle extends ModelePDFStockTransfer
*/
public $version = 'dolibarr';
+ /**
+ * @var int posx lot
+ */
+ public $posxlot;
+
+ /**
+ * @var int posx weightvol
+ */
+ public $posxweightvol;
+ public $posxwarehousesource;
+ public $posxwarehousedestination;
+ public $atLeastOneBatch;
/**
* Constructor
@@ -136,13 +148,13 @@ class pdf_eagle extends ModelePDFStockTransfer
/**
* Function to build pdf onto disk
*
- * @param Object $object Object StockTransfer to generate (or id if old method)
- * @param Translate $outputlangs Lang output object
- * @param string $srctemplatepath Full path of source filename for generator using a template file
- * @param int $hidedetails Do not show line details
- * @param int $hidedesc Do not show desc
- * @param int $hideref Do not show ref
- * @return int 1=OK, 0=KO
+ * @param StockTransfer $object Object StockTransfer to generate (or id if old method)
+ * @param Translate $outputlangs Lang output object
+ * @param string $srctemplatepath Full path of source filename for generator using a template file
+ * @param int $hidedetails Do not show line details
+ * @param int $hidedesc Do not show desc
+ * @param int $hideref Do not show ref
+ * @return int 1=OK, 0=KO
*/
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
@@ -420,14 +432,14 @@ class pdf_eagle extends ModelePDFStockTransfer
$object->lines[$i]->fetch_product();
$object->lines[$i]->label = $object->lines[$i]->product->label;
$object->lines[$i]->description = $object->lines[$i]->product->description;
- $object->lines[$i]->weight = $object->lines[$i]->product->weight;
- $object->lines[$i]->weight_units = $object->lines[$i]->product->weight_units;
- $object->lines[$i]->length = $object->lines[$i]->product->length;
- $object->lines[$i]->length_units = $object->lines[$i]->product->length_units;
- $object->lines[$i]->surface = $object->lines[$i]->product->surface;
+ $object->lines[$i]->weight = $object->lines[$i]->product->weight;
+ $object->lines[$i]->weight_units = $object->lines[$i]->product->weight_units;
+ $object->lines[$i]->length = $object->lines[$i]->product->length;
+ $object->lines[$i]->length_units = $object->lines[$i]->product->length_units;
+ $object->lines[$i]->surface = $object->lines[$i]->product->surface;
$object->lines[$i]->surface_units = $object->lines[$i]->product->surface_units;
- $object->lines[$i]->volume = $object->lines[$i]->product->volume;
- $object->lines[$i]->volume_units = $object->lines[$i]->product->volume_units;
+ $object->lines[$i]->volume = $object->lines[$i]->product->volume;
+ $object->lines[$i]->volume_units = $object->lines[$i]->product->volume_units;
$object->lines[$i]->fk_unit = $object->lines[$i]->product->fk_unit;
//var_dump($object->lines[$i]);exit;
}
@@ -632,12 +644,12 @@ class pdf_eagle extends ModelePDFStockTransfer
/**
* Show total to pay
*
- * @param PDF $pdf Object PDF
- * @param Facture $object Object invoice
- * @param int $deja_regle Montant deja regle
- * @param int $posy Position depart
- * @param Translate $outputlangs Objet langs
- * @return int Position pour suite
+ * @param PDF $pdf Object PDF
+ * @param StockTransfer $object Object invoice
+ * @param int $deja_regle Montant deja regle
+ * @param int $posy Position depart
+ * @param Translate $outputlangs Objet langs
+ * @return int Position pour suite
*/
protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
{
@@ -820,10 +832,10 @@ class pdf_eagle extends ModelePDFStockTransfer
}
/**
- * Used to know if at least one line of Stock Transfer object has a batch set
- *
- * @param Object $object Stock Transfer object
- * @return boolean true if at least one line has batch set, false if not
+ * Used to know if at least one line of Stock Transfer object has a batch set
+ *
+ * @param StockTransfer $object Stock Transfer object
+ * @return boolean true if at least one line has batch set, false if not
 */
public function atLeastOneBatch($object)
{
@@ -832,7 +844,9 @@ class pdf_eagle extends ModelePDFStockTransfer
$atLeastOneBatch = false;
- if (empty($conf->productbatch->enabled)) return false;
+ if (!isModEnabled('productbatch')) {
+ return false;
+ }
foreach ($object->lines as $line) {
if (!empty($line->batch)) {
@@ -847,10 +861,10 @@ class pdf_eagle extends ModelePDFStockTransfer
/**
* Show top header of page.
*
- * @param TCPDF $pdf Object PDF
- * @param Object $object Object to show
- * @param int $showaddress 0=no, 1=yes
- * @param Translate $outputlangs Object lang for output
+ * @param TCPDF $pdf Object PDF
+ * @param StockTransfer $object Object to show
+ * @param int $showaddress 0=no, 1=yes
+ * @param Translate $outputlangs Object lang for output
* @return void
*/
protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
@@ -1106,11 +1120,11 @@ class pdf_eagle extends ModelePDFStockTransfer
/**
* Show footer of page. Need this->emetteur object
*
- * @param PDF $pdf PDF
- * @param Object $object Object to show
- * @param Translate $outputlangs Object lang for output
- * @param int $hidefreetext 1=Hide free text
- * @return int Return height of bottom margin including footer text
+ * @param PDF $pdf PDF
+ * @param StockTransfer $object Object to show
+ * @param Translate $outputlangs Object lang for output
+ * @param int $hidefreetext 1=Hide free text
+ * @return int Return height of bottom margin including footer text
*/
protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
{
diff --git a/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php b/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php
index 3bd049792e4..8eac5b14f4b 100644
--- a/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php
+++ b/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php
@@ -83,7 +83,7 @@ class mod_stocktransfer_advanced extends ModeleNumRefStockTransfer
$texte .= ''.$langs->trans("Mask").': ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= ' ';
diff --git a/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php b/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php
index 6031907b305..56175353538 100644
--- a/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php
+++ b/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php
@@ -146,17 +146,18 @@ class doc_generic_supplier_invoice_odt extends ModelePDFSuppliersInvoices
}
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
+ $texthelp .= ''.$langs->trans("ExampleOfDirectoriesForModelGen").' ';
// Add list of substitution keys
$texthelp .= ' '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").' ';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
- $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
+ $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
$texte .= '';
// Scan directories
@@ -182,15 +183,10 @@ class doc_generic_supplier_invoice_odt extends ModelePDFSuppliersInvoices
// Add input to upload a new template file.
$texte .= ''.$langs->trans("UploadNewTemplate").' ';
$texte .= ' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= '
';
$texte .= '';
- $texte .= '';
- $texte .= '';
- $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
- $texte .= ' ';
- $texte .= ' ';
$texte .= '';
$texte .= '';
diff --git a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php
index dcb4deff292..3172a54711c 100644
--- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php
+++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php
@@ -607,12 +607,12 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
/**
* Show total to pay
*
- * @param TCPDF $pdf Object PDF
- * @param Object $object Object invoice
- * @param int $deja_regle Amount already paid (in the currency of invoice)
- * @param int $posy Position depart
- * @param Translate $outputlangs Objet langs
- * @return int Position pour suite
+ * @param TCPDF $pdf Object PDF
+ * @param FactureFournisseur $object Object invoice
+ * @param int $deja_regle Amount already paid (in the currency of invoice)
+ * @param int $posy Position depart
+ * @param Translate $outputlangs Objet langs
+ * @return int Position of cursor after output
*/
protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
{
diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php
index cc3a2967471..f14a5df4605 100644
--- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php
+++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php
@@ -96,7 +96,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices
$texte .= ':';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= '';
diff --git a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php
index 285be7c2799..1d5f194e9ab 100644
--- a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php
+++ b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php
@@ -142,17 +142,18 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders
}
}
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
+ $texthelp .= ''.$langs->trans("ExampleOfDirectoriesForModelGen").' ';
// Add list of substitution keys
$texthelp .= ' '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").' ';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
- $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
+ $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
$texte .= '';
// Scan directories
@@ -178,15 +179,10 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders
// Add input to upload a new template file.
$texte .= ''.$langs->trans("UploadNewTemplate").' ';
$texte .= ' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= '
';
$texte .= '';
- $texte .= '';
- $texte .= '';
- $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
- $texte .= ' ';
- $texte .= ' ';
$texte .= '';
$texte .= '';
diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php
index fa215824f55..cbddbf76c9b 100644
--- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php
+++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php
@@ -1598,7 +1598,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders
$this->cols['totalexcltax'] = array(
'rank' => $rank,
'width' => 26, // in mm
- 'status' => true,
+ 'status' => false,
'title' => array(
'textkey' => 'TotalHT'
),
diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php
index c6985645288..9132d35c8a2 100644
--- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php
+++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php
@@ -88,7 +88,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders
$texte .= ''.$langs->trans("Mask").': ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= ' ';
diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php
index fc7d142d5ae..35d74ec432a 100644
--- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php
+++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php
@@ -86,7 +86,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
*/
public function __construct($db)
{
- global $conf, $langs, $mysoc;
+ global $langs, $mysoc;
// Load translation files required by the page
$langs->loadLangs(array("main", "bills"));
@@ -227,7 +227,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
global $action;
$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- $nblines = count($object->lines);
+ $nblines = (empty($object->lines) ? 0 : count($object->lines));
$pdf = pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
diff --git a/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php b/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php
index fb980a4e038..7da2543ab00 100644
--- a/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php
+++ b/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php
@@ -85,7 +85,7 @@ class mod_supplier_payment_brodator extends ModeleNumRefSupplierPayments
$texte .= ''.$langs->trans("Mask").': ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= ' ';
diff --git a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php
index 53bacc7aad2..32b6b64694a 100644
--- a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php
+++ b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php
@@ -143,17 +143,18 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal
}
}
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
+ $texthelp .= ''.$langs->trans("ExampleOfDirectoriesForModelGen").' ';
// Add list of substitution keys
$texthelp .= ' '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").' ';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
- $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
+ $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
$texte .= '';
// Scan directories
@@ -203,11 +204,6 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal
$texte .= '';
- $texte .= '';
- $texte .= '';
- $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
- $texte .= ' ';
- $texte .= ' ';
$texte .= '';
$texte .= '';
diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php
new file mode 100644
index 00000000000..d876d5a6b12
--- /dev/null
+++ b/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php
@@ -0,0 +1,1617 @@
+
+ * Copyright (C) 2005-2011 Regis Houssin
+ * Copyright (C) 2007 Franky Van Liedekerke
+ * Copyright (C) 2010-2014 Juanjo Menent
+ * Copyright (C) 2015 Marcos García
+ * Copyright (C) 2017 Ferran Marcet
+ * Copyright (C) 2018-2022 Frédéric France
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ * or see https://www.gnu.org/
+ */
+
+/**
+ * \file htdocs/core/modules/supplir_proposal/doc/pdf_zenith.modules.php
+ * \ingroup fournisseur
+ * \brief File of class to generate suppliers proposals from zenith model
+ */
+
+require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_proposal/modules_supplier_proposal.php';
+require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
+require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
+
+
+/**
+ * Class to generate the supplier proposals with the zenith model
+ */
+class pdf_zenith extends ModelePDFSupplierProposal
+{
+ /**
+ * @var DoliDb Database handler
+ */
+ public $db;
+
+ /**
+ * @var string model name
+ */
+ public $name;
+
+ /**
+ * @var string model description (short text)
+ */
+ public $description;
+
+ /**
+ * @var int Save the name of generated file as the main doc when generating a doc with this template
+ */
+ public $update_main_doc_field;
+
+ /**
+ * @var string document type
+ */
+ public $type;
+
+ /**
+ * Dolibarr version of the loaded document
+ * @var string
+ */
+ public $version = 'dolibarr';
+
+
+ /**
+ * Constructor
+ *
+ * @param DoliDB $db Database handler
+ */
+ public function __construct($db)
+ {
+ global $conf, $langs, $mysoc;
+
+ // Load translation files required by the page
+ $langs->loadLangs(array("main", "bills"));
+
+ $this->db = $db;
+ $this->name = "zenith";
+ $this->description = $langs->trans('DocModelZenithDescription');
+ $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
+
+ // Page size for A4 format
+ $this->type = 'pdf';
+ $formatarray = pdf_getFormat();
+ $this->page_largeur = $formatarray['width'];
+ $this->page_hauteur = $formatarray['height'];
+ $this->format = array($this->page_largeur, $this->page_hauteur);
+ $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10);
+ $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10);
+ $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10);
+ $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10);
+
+ $this->option_logo = 1; // Display logo
+ $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
+ $this->option_modereg = 1; // Display payment mode
+ $this->option_condreg = 1; // Display payment terms
+ $this->option_multilang = 1; //Available in several languages
+ $this->option_escompte = 0; // Displays if there has been a discount
+ $this->option_credit_note = 0; // Support credit notes
+ $this->option_freetext = 1; // Support add of a personalised text
+ $this->option_draft_watermark = 1; // Support add of a watermark on drafts
+
+ // Get source company
+ $this->emetteur = $mysoc;
+ if (empty($this->emetteur->country_code)) {
+ $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
+ }
+
+ // Define position of columns
+ $this->posxdesc = $this->marge_gauche + 1; // For module retrocompatibility support durring PDF transition: TODO remove this at the end
+
+ $this->tabTitleHeight = 5; // default height
+
+ $this->tva = array();
+ $this->tva_array = array();
+ $this->localtax1 = array();
+ $this->localtax2 = array();
+ $this->atleastoneratenotnull = 0;
+ $this->atleastonediscount = 0;
+ }
+
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Function to build pdf onto disk
+ *
+ * @param SupplierProposal $object Id of object to generate
+ * @param Translate $outputlangs Lang output object
+ * @param string $srctemplatepath Full path of source filename for generator using a template file
+ * @param int $hidedetails Do not show line details
+ * @param int $hidedesc Do not show desc
+ * @param int $hideref Do not show ref
+ * @return int 1=OK, 0=KO
+ */
+ public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
+ {
+ // phpcs:enable
+ global $user, $langs, $conf, $hookmanager, $mysoc, $nblines;
+
+ if (!is_object($outputlangs)) {
+ $outputlangs = $langs;
+ }
+ // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
+ if (!empty($conf->global->MAIN_USE_FPDF)) {
+ $outputlangs->charset_output = 'ISO-8859-1';
+ }
+
+ // Load translation files required by the page
+ $outputlangs->loadLangs(array("main", "supplier_proposal", "companies", "bills", "dict", "products"));
+
+ global $outputlangsbis;
+ $outputlangsbis = null;
+ if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
+ $outputlangsbis = new Translate('', $conf);
+ $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
+ $outputlangsbis->loadLangs(array("main", "supplier_proposal", "companies", "bills", "dict", "products"));
+ }
+
+ $nblines = count($object->lines);
+
+ $hidetop = 0;
+ if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
+ $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
+ }
+
+ // Loop on each lines to detect if there is at least one image to show
+ $realpatharray = array();
+ if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_PROPOSAL_WITH_PICTURE)) {
+ for ($i = 0; $i < $nblines; $i++) {
+ if (empty($object->lines[$i]->fk_product)) {
+ continue;
+ }
+
+ $objphoto = new Product($this->db);
+ $objphoto->fetch($object->lines[$i]->fk_product);
+
+ if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) {
+ $pdir = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
+ $dir = $conf->product->dir_output.'/'.$pdir;
+ } else {
+ $pdir = get_exdir($objphoto->id, 0, 0, 0, $objphoto, 'product');
+ $dir = $conf->product->dir_output.'/'.$pdir;
+ }
+
+ $realpath = '';
+ foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
+ if (!getDolGlobalInt('CAT_HIGH_QUALITY_IMAGES')) { // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
+ if ($obj['photo_vignette']) {
+ $filename = $obj['photo_vignette'];
+ } else {
+ $filename = $obj['photo'];
+ }
+ } else {
+ $filename = $obj['photo'];
+ }
+ $realpath = $dir.$filename;
+ break;
+ }
+
+ if ($realpath) {
+ $realpatharray[$i] = $realpath;
+ }
+ }
+ }
+ if (count($realpatharray) == 0) {
+ $this->posxpicture = $this->posxtva;
+ }
+
+ if ($conf->supplier_proposal->dir_output) {
+ $object->fetch_thirdparty();
+
+ $deja_regle = 0;
+ $amount_credit_notes_included = 0;
+ $amount_deposits_included = 0;
+ //$amount_credit_notes_included = $object->getSumCreditNotesUsed();
+ //$amount_deposits_included = $object->getSumDepositsUsed();
+
+ // Definition of $dir and $file
+ if ($object->specimen) {
+ $dir = $conf->supplier_proposal->dir_output;
+ $file = $dir."/SPECIMEN.pdf";
+ } else {
+ $objectref = dol_sanitizeFileName($object->ref);
+ $objectrefsupplier = dol_sanitizeFileName($object->ref_supplier);
+ $dir = $conf->supplier_proposal->dir_output.'/'.$objectref;
+ $file = $dir."/".$objectref.".pdf";
+ if (!empty($conf->global->SUPPLIER_REF_IN_NAME)) {
+ $file = $dir."/".$objectref.($objectrefsupplier ? "_".$objectrefsupplier : "").".pdf";
+ }
+ }
+
+ if (!file_exists($dir)) {
+ if (dol_mkdir($dir) < 0) {
+ $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
+ return 0;
+ }
+ }
+
+ if (file_exists($dir)) {
+ // Add pdfgeneration hook
+ if (!is_object($hookmanager)) {
+ include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
+ $hookmanager = new HookManager($this->db);
+ }
+ $hookmanager->initHooks(array('pdfgeneration'));
+ $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
+ global $action;
+ $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+
+ $nblines = count($object->lines);
+
+ $pdf = pdf_getInstance($this->format);
+ $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+ $heightforinfotot = 50; // Height reserved to output the info and total part
+ $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+ $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+ if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
+ $heightforfooter += 6;
+ }
+ $pdf->SetAutoPageBreak(1, 0);
+
+ if (class_exists('TCPDF')) {
+ $pdf->setPrintHeader(false);
+ $pdf->setPrintFooter(false);
+ }
+ $pdf->SetFont(pdf_getPDFFont($outputlangs));
+ // Set path to the background PDF File
+ if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
+ $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $tplidx = $pdf->importPage(1);
+ }
+
+ $pdf->Open();
+ $pagenb = 0;
+ $pdf->SetDrawColor(128, 128, 128);
+
+ $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
+ $pdf->SetSubject($outputlangs->transnoentities("SupplierProposal"));
+ $pdf->SetCreator("Dolibarr ".DOL_VERSION);
+ $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
+ $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("SupplierProposal")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
+ if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
+ $pdf->SetCompression(false);
+ }
+
+ $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
+
+ // Does we have at least one line with discount $this->atleastonediscount
+ foreach ($object->lines as $line) {
+ if ($line->remise_percent) {
+ $this->atleastonediscount = true;
+ break;
+ }
+ }
+
+ // New page
+ $pdf->AddPage();
+ if (!empty($tplidx)) {
+ $pdf->useTemplate($tplidx);
+ }
+ $pagenb++;
+ $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->MultiCell(0, 3, ''); // Set interline to 3
+ $pdf->SetTextColor(0, 0, 0);
+
+ $tab_top = 90 + $top_shift;
+ $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
+
+ $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
+
+ // Incoterm
+ if (isModEnabled('incoterm')) {
+ $desc_incoterms = $object->getIncotermsForPDF();
+ if ($desc_incoterms) {
+ $tab_top -= 2;
+
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
+ $nexY = $pdf->GetY();
+ $height_incoterms = $nexY - $tab_top;
+
+ // Rect takes a length in 3rd parameter
+ $pdf->SetDrawColor(192, 192, 192);
+ $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
+
+ $tab_top = $nexY + 6;
+ }
+ }
+
+ // Affiche notes
+ $notetoshow = empty($object->note_public) ? '' : $object->note_public;
+
+ // Extrafields in note
+ $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
+ if (!empty($extranote)) {
+ $notetoshow = dol_concatdesc($notetoshow, $extranote);
+ }
+
+ $pagenb = $pdf->getPage();
+ if ($notetoshow) {
+ $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
+ $pageposbeforenote = $pagenb;
+
+ $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
+ complete_substitutions_array($substitutionarray, $outputlangs, $object);
+ $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
+ $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
+
+ $tab_top -= 2;
+
+ $pdf->startTransaction();
+
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
+ // Description
+ $pageposafternote = $pdf->getPage();
+ $posyafter = $pdf->GetY();
+
+ if ($pageposafternote > $pageposbeforenote) {
+ $pdf->rollbackTransaction(true);
+
+ // prepar pages to receive notes
+ while ($pagenb < $pageposafternote) {
+ $pdf->AddPage();
+ $pagenb++;
+ if (!empty($tplidx)) {
+ $pdf->useTemplate($tplidx);
+ }
+ if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
+ $this->_pagehead($pdf, $object, 0, $outputlangs);
+ }
+ // $this->_pagefoot($pdf,$object,$outputlangs,1);
+ $pdf->setTopMargin($tab_top_newpage);
+ // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
+ }
+
+ // back to start
+ $pdf->setPage($pageposbeforenote);
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
+ $pageposafternote = $pdf->getPage();
+
+ $posyafter = $pdf->GetY();
+
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // There is no space left for total+free text
+ $pdf->AddPage('', '', true);
+ $pagenb++;
+ $pageposafternote++;
+ $pdf->setPage($pageposafternote);
+ $pdf->setTopMargin($tab_top_newpage);
+ // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
+ //$posyafter = $tab_top_newpage;
+ }
+
+
+ // apply note frame to previus pages
+ $i = $pageposbeforenote;
+ while ($i < $pageposafternote) {
+ $pdf->setPage($i);
+
+
+ $pdf->SetDrawColor(128, 128, 128);
+ // Draw note frame
+ if ($i > $pageposbeforenote) {
+ $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
+ $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
+ } else {
+ $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
+ $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
+ }
+
+ // Add footer
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+ $this->_pagefoot($pdf, $object, $outputlangs, 1);
+
+ $i++;
+ }
+
+ // apply note frame to last page
+ $pdf->setPage($pageposafternote);
+ if (!empty($tplidx)) {
+ $pdf->useTemplate($tplidx);
+ }
+ if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
+ $this->_pagehead($pdf, $object, 0, $outputlangs);
+ }
+ $height_note = $posyafter - $tab_top_newpage;
+ $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
+ } else {
+ // No pagebreak
+ $pdf->commitTransaction();
+ $posyafter = $pdf->GetY();
+ $height_note = $posyafter - $tab_top;
+ $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
+
+
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
+ // not enough space, need to add page
+ $pdf->AddPage('', '', true);
+ $pagenb++;
+ $pageposafternote++;
+ $pdf->setPage($pageposafternote);
+ if (!empty($tplidx)) {
+ $pdf->useTemplate($tplidx);
+ }
+ if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
+ $this->_pagehead($pdf, $object, 0, $outputlangs);
+ }
+
+ $posyafter = $tab_top_newpage;
+ }
+ }
+
+ $tab_height = $tab_height - $height_note;
+ $tab_top = $posyafter + 6;
+ } else {
+ $height_note = 0;
+ }
+
+ // Use new auto collum system
+ $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
+
+ $nexY = $tab_top + $this->tabTitleHeight;
+
+ // Loop on each lines
+ $pageposbeforeprintlines = $pdf->getPage();
+ $pagenb = $pageposbeforeprintlines;
+ for ($i = 0; $i < $nblines; $i++) {
+ $curY = $nexY;
+ $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
+ $pdf->SetTextColor(0, 0, 0);
+
+ // Define size of image if we need it
+ $imglinesize = array();
+ if (!empty($realpatharray[$i])) {
+ $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
+ }
+
+ $pdf->setTopMargin($tab_top_newpage);
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
+ $pageposbefore = $pdf->getPage();
+
+ $showpricebeforepagebreak = 1;
+ $posYAfterImage = 0;
+ $posYAfterDescription = 0;
+
+ // We start with Photo of product line
+ if ($this->getColumnStatus('photo')) {
+ // We start with Photo of product line
+ if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page
+ $pdf->AddPage('', '', true);
+ if (!empty($tplidx)) {
+ $pdf->useTemplate($tplidx);
+ }
+ $pdf->setPage($pageposbefore + 1);
+
+ $curY = $tab_top_newpage;
+
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
+ $showpricebeforepagebreak = 1;
+ } else {
+ $showpricebeforepagebreak = 0;
+ }
+ }
+
+ if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
+ $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
+ // $pdf->Image does not increase value return by getY, so we save it manually
+ $posYAfterImage = $curY + $imglinesize['height'];
+ }
+ }
+ // Description of product line
+ $curX = $this->posxdesc - 1;
+ $showpricebeforepagebreak = 1;
+
+ if ($this->getColumnStatus('desc')) {
+ $pdf->startTransaction();
+ $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc, 1);
+
+ $pageposafter = $pdf->getPage();
+ if ($pageposafter > $pageposbefore) { // There is a pagebreak
+ $pdf->rollbackTransaction(true);
+
+ $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc, 1);
+
+ $pageposafter = $pdf->getPage();
+ $posyafter = $pdf->GetY();
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
+ if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
+ $pdf->AddPage('', '', true);
+ if (!empty($tplidx)) {
+ $pdf->useTemplate($tplidx);
+ }
+ //if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) $this->_pagehead($pdf, $object, 0, $outputlangs);
+ $pdf->setPage($pageposafter + 1);
+ }
+ } else {
+ // We found a page break
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
+ $showpricebeforepagebreak = 1;
+ } else {
+ $showpricebeforepagebreak = 0;
+ }
+ }
+ } else // No pagebreak
+ {
+ $pdf->commitTransaction();
+ }
+ $posYAfterDescription = $pdf->GetY();
+ }
+
+ $nexY = $pdf->GetY();
+ $pageposafter = $pdf->getPage();
+ $pdf->setPage($pageposbefore);
+ $pdf->setTopMargin($this->marge_haute);
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+
+ // We suppose that a too long description is moved completely on next page
+ if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
+ $pdf->setPage($pageposafter);
+ $curY = $tab_top_newpage;
+ }
+
+ $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
+
+ // VAT Rate
+ if ($this->getColumnStatus('vat')) {
+ $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
+ $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
+ $nexY = max($pdf->GetY(), $nexY);
+ }
+
+ // Unit price before discount
+ if ($this->getColumnStatus('subprice')) {
+ $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
+ $this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
+ $nexY = max($pdf->GetY(), $nexY);
+ }
+
+ // Quantity
+ // Enough for 6 chars
+ if ($this->getColumnStatus('qty')) {
+ $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
+ $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
+ $nexY = max($pdf->GetY(), $nexY);
+ }
+
+
+ // Unit
+ if ($this->getColumnStatus('unit')) {
+ $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
+ $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
+ $nexY = max($pdf->GetY(), $nexY);
+ }
+
+ // Discount on line
+ if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent) {
+ $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
+ $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
+ $nexY = max($pdf->GetY(), $nexY);
+ }
+
+ // Total HT line
+ if ($this->getColumnStatus('totalexcltax')) {
+ $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
+ $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
+ $nexY = max($pdf->GetY(), $nexY);
+ }
+
+ // Extrafields
+ if (!empty($object->lines[$i]->array_options)) {
+ foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
+ if ($this->getColumnStatus($extrafieldColKey)) {
+ $extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
+ $this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue);
+ $nexY = max($pdf->GetY(), $nexY);
+ }
+ }
+ }
+
+ $parameters = array(
+ 'object' => $object,
+ 'i' => $i,
+ 'pdf' =>& $pdf,
+ 'curY' =>& $curY,
+ 'nexY' =>& $nexY,
+ 'outputlangs' => $outputlangs,
+ 'hidedetails' => $hidedetails
+ );
+ $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
+
+
+ // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
+ if (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) {
+ $tvaligne = $object->lines[$i]->multicurrency_total_tva;
+ } else {
+ $tvaligne = $object->lines[$i]->total_tva;
+ }
+
+ $localtax1ligne = $object->lines[$i]->total_localtax1;
+ $localtax2ligne = $object->lines[$i]->total_localtax2;
+ $localtax1_rate = $object->lines[$i]->localtax1_tx;
+ $localtax2_rate = $object->lines[$i]->localtax2_tx;
+ $localtax1_type = $object->lines[$i]->localtax1_type;
+ $localtax2_type = $object->lines[$i]->localtax2_type;
+
+ // TODO remise_percent is an obsolete field for object parent
+ /*if (!empty($object->remise_percent)) {
+ $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
+ }
+ if (!empty($object->remise_percent)) {
+ $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
+ }
+ if (!empty($object->remise_percent)) {
+ $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
+ }*/
+
+ $vatrate = (string) $object->lines[$i]->tva_tx;
+
+ // Retrieve type from database for backward compatibility with old records
+ if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
+ && (!empty($localtax1_rate) || !empty($localtax2_rate))) { // and there is local tax
+ $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $mysoc, $object->thirdparty);
+ $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] : '';
+ $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] : '';
+ }
+
+ // retrieve global local tax
+ if ($localtax1_type && $localtax1ligne != 0) {
+ if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
+ $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
+ } else {
+ $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
+ }
+ }
+ if ($localtax2_type && $localtax2ligne != 0) {
+ if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
+ $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
+ } else {
+ $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
+ }
+ }
+
+ if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
+ $vatrate .= '*';
+ }
+
+ // Fill $this->tva and $this->tva_array
+ if (!isset($this->tva[$vatrate])) {
+ $this->tva[$vatrate] = 0;
+ }
+ $this->tva[$vatrate] += $tvaligne;
+ $vatcode = $object->lines[$i]->vat_src_code;
+ if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'])) {
+ $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] = 0;
+ }
+ $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne);
+
+ if ($posYAfterImage > $posYAfterDescription) {
+ $nexY = $posYAfterImage;
+ }
+
+ // Add line
+ if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
+ $pdf->setPage($pageposafter);
+ $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
+ //$pdf->SetDrawColor(190,190,200);
+ $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
+ $pdf->SetLineStyle(array('dash'=>0));
+ }
+
+ // Detect if some page were added automatically and output _tableau for past pages
+ while ($pagenb < $pageposafter) {
+ $pdf->setPage($pagenb);
+ if ($pagenb == $pageposbeforeprintlines) {
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
+ } else {
+ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
+ }
+ $this->_pagefoot($pdf, $object, $outputlangs, 1);
+ $pagenb++;
+ $pdf->setPage($pagenb);
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+ if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
+ $this->_pagehead($pdf, $object, 0, $outputlangs);
+ }
+ if (!empty($tplidx)) {
+ $pdf->useTemplate($tplidx);
+ }
+ }
+ if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
+ if ($pagenb == $pageposafter) {
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
+ } else {
+ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
+ }
+ $this->_pagefoot($pdf, $object, $outputlangs, 1);
+ // New page
+ $pdf->AddPage();
+ if (!empty($tplidx)) {
+ $pdf->useTemplate($tplidx);
+ }
+ $pagenb++;
+ if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
+ $this->_pagehead($pdf, $object, 0, $outputlangs);
+ }
+ }
+ }
+
+ // Show square
+ if ($pagenb == $pageposbeforeprintlines) {
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
+ $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ } else {
+ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
+ $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ }
+
+ // Affiche zone infos
+ $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
+
+ // Affiche zone totaux
+ $posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
+
+ // Affiche zone versements
+ if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) {
+ $posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs);
+ }
+
+ // Pied de page
+ $this->_pagefoot($pdf, $object, $outputlangs);
+ if (method_exists($pdf, 'AliasNbPages')) {
+ $pdf->AliasNbPages();
+ }
+
+ $pdf->Close();
+
+ $pdf->Output($file, 'F');
+
+ // Add pdfgeneration hook
+ $hookmanager->initHooks(array('pdfgeneration'));
+ $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
+ global $action;
+ $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
+ if ($reshook < 0) {
+ $this->error = $hookmanager->error;
+ $this->errors = $hookmanager->errors;
+ }
+
+ dolChmod($file);
+
+ $this->result = array('fullpath'=>$file);
+
+ return 1; // No error
+ } else {
+ $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
+ return 0;
+ }
+ } else {
+ $this->error = $langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR");
+ return 0;
+ }
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Show payments table
+ *
+ * @param TCPDF $pdf Object PDF
+ * @param SupplierProposal $object Object supplier propsal
+ * @param int $posy Position y in PDF
+ * @param Translate $outputlangs Object langs for output
+ * @return int <0 if KO, >0 if OK
+ */
+ protected function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
+ {
+ // phpcs:enable
+ return 1;
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Show miscellaneous information (payment mode, payment term, ...)
+ *
+ * @param TCPDF $pdf Object PDF
+ * @param SupplierProposal $object Object to show
+ * @param int $posy Y
+ * @param Translate $outputlangs Langs object
+ * @return integer
+ */
+ protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
+ {
+ // phpcs:enable
+ global $conf, $mysoc;
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
+
+ $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
+
+ // If France, show VAT mention if not applicable
+ if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) {
+ $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
+
+ $posy = $pdf->GetY() + 4;
+ }
+
+ $posxval = 52;
+
+ // Show payments conditions
+ if (!empty($object->cond_reglement_code) || $object->cond_reglement) {
+ $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $titre = $outputlangs->transnoentities("PaymentConditions").':';
+ $pdf->MultiCell(80, 4, $titre, 0, 'L');
+
+ $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
+ $pdf->SetXY($posxval, $posy);
+ $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label);
+ $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
+ $pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L');
+
+ $posy = $pdf->GetY() + 3;
+ }
+
+ // Show payment mode
+ if (!empty($object->mode_reglement_code)) {
+ $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $titre = $outputlangs->transnoentities("PaymentMode").':';
+ $pdf->MultiCell(80, 5, $titre, 0, 'L');
+
+ $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
+ $pdf->SetXY($posxval, $posy);
+ $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
+ $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
+
+ $posy = $pdf->GetY() + 2;
+ }
+
+
+ return $posy;
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Show total to pay
+ *
+ * @param TCPDF $pdf Object PDF
+ * @param Facture $object Object invoice
+ * @param int $deja_regle Montant deja regle
+ * @param int $posy Position depart
+ * @param Translate $outputlangs Objet langs
+ * @return int Position pour suite
+ */
+ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
+ {
+ // phpcs:enable
+ global $conf, $mysoc;
+
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
+
+ $tab2_top = $posy;
+ $tab2_hl = 4;
+ $pdf->SetFont('', '', $default_font_size - 1);
+
+ // Tableau total
+ $col1x = 120;
+ $col2x = 170;
+ if ($this->page_largeur < 210) { // To work with US executive format
+ $col2x -= 20;
+ }
+ $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
+
+ $useborder = 0;
+ $index = 0;
+
+ // Total HT
+ $pdf->SetFillColor(255, 255, 255);
+ $pdf->SetXY($col1x, $tab2_top);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
+
+ $total_ht = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
+ $pdf->SetXY($col2x, $tab2_top);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, 'R', 1);
+
+ // Show VAT by rates and total
+ $pdf->SetFillColor(248, 248, 248);
+
+ $this->atleastoneratenotnull = 0;
+ foreach ($this->tva as $tvakey => $tvaval) {
+ if ($tvakey > 0) { // On affiche pas taux 0
+ $this->atleastoneratenotnull++;
+
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+ $tvacompl = '';
+
+ if (preg_match('/\*/', $tvakey)) {
+ $tvakey = str_replace('*', '', $tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+
+ $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
+ $totalvat .= vatrate($tvakey, 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
+ }
+ }
+ if (!$this->atleastoneratenotnull) { // If no vat at all
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1);
+
+ // Total LocalTax1
+ if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION == 'localtax1on' && $object->total_localtax1 > 0) {
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code), 0, 'L', 1);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1);
+ }
+
+ // Total LocalTax2
+ if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION == 'localtax2on' && $object->total_localtax2 > 0) {
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code), 0, 'L', 1);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1);
+ }
+ } else {
+ //if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
+ //{
+ //Local tax 1
+ foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
+ if (in_array((string) $localtax_type, array('2', '4', '6'))) {
+ continue;
+ }
+
+ foreach ($localtax_rate as $tvakey => $tvaval) {
+ if ($tvakey != 0) { // On affiche pas taux 0
+ //$this->atleastoneratenotnull++;
+
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+ $tvacompl = '';
+ if (preg_match('/\*/', $tvakey)) {
+ $tvakey = str_replace('*', '', $tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+ }
+ }
+ }
+
+ //if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
+ //{
+ //Local tax 2
+ foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
+ if (in_array((string) $localtax_type, array('2', '4', '6'))) {
+ continue;
+ }
+
+ foreach ($localtax_rate as $tvakey => $tvaval) {
+ if ($tvakey != 0) { // On affiche pas taux 0
+ //$this->atleastoneratenotnull++;
+
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+ $tvacompl = '';
+ if (preg_match('/\*/', $tvakey)) {
+ $tvakey = str_replace('*', '', $tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
+ }
+ }
+ }
+ }
+
+ // Total TTC
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->SetFillColor(224, 224, 224);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
+
+ $total_ttc = (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1);
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->SetTextColor(0, 0, 0);
+
+ $creditnoteamount = 0;
+ $depositsamount = 0;
+ //$creditnoteamount=$object->getSumCreditNotesUsed();
+ //$depositsamount=$object->getSumDepositsUsed();
+ //print "x".$creditnoteamount."-".$depositsamount;exit;
+ $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
+ if (!empty($object->paye)) {
+ $resteapayer = 0;
+ }
+
+ if ($deja_regle > 0) {
+ // Already paid + Deposits
+ $index++;
+
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0);
+
+ $index++;
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->SetFillColor(224, 224, 224);
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1);
+
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->SetTextColor(0, 0, 0);
+ }
+
+ $index++;
+ return ($tab2_top + ($tab2_hl * $index));
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
+ /**
+ * Show table for lines
+ *
+ * @param TCPDF $pdf Object PDF
+ * @param string $tab_top Top position of table
+ * @param string $tab_height Height of table (rectangle)
+ * @param int $nexY Y (not used)
+ * @param Translate $outputlangs Langs object
+ * @param int $hidetop Hide top bar of array
+ * @param int $hidebottom Hide bottom bar of array
+ * @param string $currency Currency code
+ * @return void
+ */
+ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
+ {
+ global $conf;
+
+ // Force to disable hidetop and hidebottom
+ $hidebottom = 0;
+ if ($hidetop) {
+ $hidetop = -1;
+ }
+
+ $currency = !empty($currency) ? $currency : $conf->currency;
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
+
+ // Amount in (at tab_top - 1)
+ $pdf->SetTextColor(0, 0, 0);
+ $pdf->SetFont('', '', $default_font_size - 2);
+
+ if (empty($hidetop)) {
+ $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
+ $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
+ $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
+
+ //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
+ if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
+ $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
+ }
+ }
+
+ $pdf->SetDrawColor(128, 128, 128);
+ $pdf->SetFont('', '', $default_font_size - 1);
+
+ // Output Rect
+ $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
+
+ $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
+
+ if (empty($hidetop)) {
+ $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
+ }
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
+ /**
+ * Show top header of page.
+ *
+ * @param TCPDF $pdf Object PDF
+ * @param CommandeFournisseur $object Object to show
+ * @param int $showaddress 0=no, 1=yes
+ * @param Translate $outputlangs Object lang for output
+ * @return float|int
+ */
+ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
+ {
+ global $langs, $conf, $mysoc;
+
+ $ltrdirection = 'L';
+ if ($outputlangs->trans("DIRECTION") == 'rtl') $ltrdirection = 'R';
+
+ // Load translation files required by the page
+ $outputlangs->loadLangs(array("main", "supplier_proposal", "companies", "bills", "sendings"));
+
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
+
+ // Do not add the BACKGROUND as this is for suppliers
+ //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
+
+ //Affiche le filigrane brouillon - Print Draft Watermark
+ /*if($object->statut==0 && getDolGlobalString('COMMANDE_DRAFT_WATERMARK'))
+ {
+ pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',getDolGlobalString('COMMANDE_DRAFT_WATERMARK'));
+ }*/
+ //Print content
+
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->SetFont('', 'B', $default_font_size + 3);
+
+ $posx = $this->page_largeur - $this->marge_droite - 100;
+ $posy = $this->marge_haute;
+
+ $pdf->SetXY($this->marge_gauche, $posy);
+
+ // Logo
+ if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) {
+ if ($this->emetteur->logo) {
+ $logodir = $conf->mycompany->dir_output;
+ if (!empty($conf->mycompany->multidir_output[$object->entity])) {
+ $logodir = $conf->mycompany->multidir_output[$object->entity];
+ }
+ if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
+ $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
+ } else {
+ $logo = $logodir.'/logos/'.$this->emetteur->logo;
+ }
+ if (is_readable($logo)) {
+ $height = pdf_getHeightForLogo($logo);
+ $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+ } else {
+ $pdf->SetTextColor(200, 0, 0);
+ $pdf->SetFont('', 'B', $default_font_size - 2);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
+ }
+ } else {
+ $text = $this->emetteur->name;
+ $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
+ }
+ }
+
+ $pdf->SetFont('', 'B', $default_font_size + 3);
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $title = $outputlangs->transnoentities("SupplierProposal")." ".$outputlangs->convToOutputCharset($object->ref);
+ $pdf->MultiCell(100, 3, $title, '', 'R');
+ $posy += 1;
+
+ if ($object->ref_supplier) {
+ $posy += 4;
+ $pdf->SetFont('', 'B', $default_font_size);
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier")." : ".$outputlangs->convToOutputCharset($object->ref_supplier), '', 'R');
+ $posy += 1;
+ }
+
+ $pdf->SetFont('', '', $default_font_size - 1);
+
+ if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
+ $object->fetch_projet();
+ if (!empty($object->project->ref)) {
+ $posy += 3;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R');
+ }
+ }
+
+ if (!empty($conf->global->PDF_SHOW_PROJECT)) {
+ $object->fetch_projet();
+ if (!empty($object->project->ref)) {
+ $outputlangs->load("projects");
+ $posy += 4;
+ $pdf->SetXY($posx, $posy);
+ $langs->load("projects");
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R');
+ }
+ }
+
+ if (!empty($object->date)) {
+ $posy += 5;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
+ } else {
+ $posy += 5;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(255, 0, 0);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Draft"), '', 'R');
+ }
+
+ $pdf->SetTextColor(0, 0, 60);
+ $usehourmin = 'day';
+ if (!empty($conf->global->SUPPLIER_PROPOSAL_USE_HOUR_FOR_DELIVERY_DATE)) {
+ $usehourmin = 'dayhour';
+ }
+ if (!empty($object->delivery_date)) {
+ $posy += 4;
+ $pdf->SetXY($posx - 90, $posy);
+ $pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->delivery_date, $usehourmin, false, $outputlangs, true), '', 'R');
+ }
+
+ if ($object->thirdparty->code_fournisseur) {
+ $posy += 4;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
+ }
+
+ // Get contact
+ if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
+ $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
+ if (count($arrayidcontact) > 0) {
+ $usertmp = new User($this->db);
+ $usertmp->fetch($arrayidcontact[0]);
+ $posy += 4;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R');
+ }
+ }
+
+ $posy += 1;
+ $pdf->SetTextColor(0, 0, 60);
+
+ $top_shift = 0;
+ // Show list of linked objects
+ $current_y = $pdf->getY();
+ $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
+ if ($current_y < $pdf->getY()) {
+ $top_shift = $pdf->getY() - $current_y;
+ }
+
+ if ($showaddress) {
+ // Sender properties
+ $carac_emetteur = '';
+ // Add internal contact of object if defined
+ $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
+ if (count($arrayidcontact) > 0) {
+ $object->fetch_user($arrayidcontact[0]);
+ $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
+ $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
+ $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : '';
+ $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : '';
+ $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : '';
+ $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : '';
+ $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : '';
+ $carac_emetteur .= "\n";
+ }
+
+ $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
+
+ // Show sender
+ $posy = 42 + $top_shift;
+ $posx = $this->marge_gauche;
+ if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
+ $posx = $this->page_largeur - $this->marge_droite - 80;
+ }
+ $hautcadre = 40;
+
+ // Show sender frame
+ $pdf->SetTextColor(0, 0, 0);
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posx, $posy - 5);
+ $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection);
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetFillColor(230, 230, 230);
+ $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
+ $pdf->SetTextColor(0, 0, 60);
+
+ // Show sender name
+ $pdf->SetXY($posx + 2, $posy + 3);
+ $pdf->SetFont('', 'B', $default_font_size);
+ $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
+ $posy = $pdf->getY();
+
+ // Show sender information
+ $pdf->SetXY($posx + 2, $posy);
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
+
+
+
+ // If CUSTOMER contact defined on proposal, we use it. Note: Even if this is a supplier object, the code for external contat that follow order is 'CUSTOMER'
+ $usecontact = false;
+ $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
+ if (count($arrayidcontact) > 0) {
+ $usecontact = true;
+ $result = $object->fetch_contact($arrayidcontact[0]);
+ }
+
+ // Recipient name
+ if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
+ $thirdparty = $object->contact;
+ } else {
+ $thirdparty = $object->thirdparty;
+ }
+
+ $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
+
+ $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
+
+ // Show recipient
+ $widthrecbox = 100;
+ if ($this->page_largeur < 210) {
+ $widthrecbox = 84; // To work with US executive format
+ }
+ $posy = 42 + $top_shift;
+ $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
+ if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
+ $posx = $this->marge_gauche;
+ }
+
+ // Show recipient frame
+ $pdf->SetTextColor(0, 0, 0);
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posx + 2, $posy - 5);
+ $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection);
+ $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
+
+ // Show recipient name
+ $pdf->SetXY($posx + 2, $posy + 3);
+ $pdf->SetFont('', 'B', $default_font_size);
+ $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
+
+ $posy = $pdf->getY();
+
+ // Show recipient information
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->SetXY($posx + 2, $posy);
+ $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
+ }
+
+ return $top_shift;
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
+ /**
+ * Show footer of page. Need this->emetteur object
+ *
+ * @param TCPDF $pdf PDF
+ * @param CommandeFournisseur $object Object to show
+ * @param Translate $outputlangs Object lang for output
+ * @param int $hidefreetext 1=Hide free text
+ * @return int Return height of bottom margin including footer text
+ */
+ protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
+ {
+ $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
+ return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
+ }
+
+
+
+ /**
+ * Define Array Column Field
+ *
+ * @param Object $object common object
+ * @param Translate $outputlangs langs
+ * @param int $hidedetails Do not show line details
+ * @param int $hidedesc Do not show desc
+ * @param int $hideref Do not show ref
+ * @return void
+ */
+ public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
+ {
+ global $conf, $hookmanager;
+
+ // Default field style for content
+ $this->defaultContentsFieldsStyle = array(
+ 'align' => 'R', // R,C,L
+ 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ );
+
+ // Default field style for content
+ $this->defaultTitlesFieldsStyle = array(
+ 'align' => 'C', // R,C,L
+ 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ );
+
+ $rank = 0; // do not use negative rank
+ $this->cols['desc'] = array(
+ 'rank' => $rank,
+ 'width' => false, // only for desc
+ 'status' => true,
+ 'title' => array(
+ 'textkey' => 'Designation', // use lang key is usefull in somme case with module
+ 'align' => 'L',
+ // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
+ // 'label' => ' ', // the final label
+ 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ ),
+ 'content' => array(
+ 'align' => 'L',
+ 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ ),
+ );
+
+ $rank = $rank + 10;
+ $this->cols['photo'] = array(
+ 'rank' => $rank,
+ 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
+ 'status' => false,
+ 'title' => array(
+ 'textkey' => 'Photo',
+ 'label' => ' '
+ ),
+ 'content' => array(
+ 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ ),
+ 'border-left' => false, // remove left line separator
+ );
+
+ if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_PROPOSAL_WITH_PICTURE)) {
+ $this->cols['photo']['status'] = true;
+ }
+
+
+ $rank = $rank + 10;
+ $this->cols['vat'] = array(
+ 'rank' => $rank,
+ 'status' => false,
+ 'width' => 16, // in mm
+ 'title' => array(
+ 'textkey' => 'VAT'
+ ),
+ 'border-left' => true, // add left line separator
+ );
+
+ if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
+ $this->cols['vat']['status'] = true;
+ }
+
+ $rank = $rank + 10;
+ $this->cols['subprice'] = array(
+ 'rank' => $rank,
+ 'width' => 19, // in mm
+ 'status' => false,
+ 'title' => array(
+ 'textkey' => 'PriceUHT'
+ ),
+ 'border-left' => true, // add left line separator
+ );
+
+ if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SUPPLIER_PROPOSAL_WITHOUT_UNIT_PRICE)) {
+ $this->cols['subprice']['status'] = true;
+ }
+
+ $rank = $rank + 10;
+ $this->cols['qty'] = array(
+ 'rank' => $rank,
+ 'width' => 16, // in mm
+ 'status' => true,
+ 'title' => array(
+ 'textkey' => 'Qty'
+ ),
+ 'border-left' => true, // add left line separator
+ );
+
+ $rank = $rank + 10;
+ $this->cols['unit'] = array(
+ 'rank' => $rank,
+ 'width' => 11, // in mm
+ 'status' => false,
+ 'title' => array(
+ 'textkey' => 'Unit'
+ ),
+ 'border-left' => true, // add left line separator
+ );
+ if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
+ $this->cols['unit']['status'] = true;
+ }
+
+ $rank = $rank + 10;
+ $this->cols['discount'] = array(
+ 'rank' => $rank,
+ 'width' => 13, // in mm
+ 'status' => false,
+ 'title' => array(
+ 'textkey' => 'ReductionShort'
+ ),
+ 'border-left' => true, // add left line separator
+ );
+ if ($this->atleastonediscount) {
+ $this->cols['discount']['status'] = true;
+ }
+
+ $rank = $rank + 1000; // add a big offset to be sure is the last col because default extrafield rank is 100
+ $this->cols['totalexcltax'] = array(
+ 'rank' => $rank,
+ 'width' => 26, // in mm
+ 'status' => false,
+ 'title' => array(
+ 'textkey' => 'TotalHT'
+ ),
+ 'border-left' => true, // add left line separator
+ );
+
+ if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SUPPLIER_PROPOSAL_WITHOUT_TOTAL_COLUMN)) {
+ $this->cols['totalexcltax']['status'] = true;
+ }
+
+ // Add extrafields cols
+ if (!empty($object->lines)) {
+ $line = reset($object->lines);
+ $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
+ }
+
+ $parameters = array(
+ 'object' => $object,
+ 'outputlangs' => $outputlangs,
+ 'hidedetails' => $hidedetails,
+ 'hidedesc' => $hidedesc,
+ 'hideref' => $hideref
+ );
+
+ $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
+ if ($reshook < 0) {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+ } elseif (empty($reshook)) {
+ $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
+ } else {
+ $this->cols = $hookmanager->resArray;
+ }
+ }
+}
diff --git a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php
index 75817d8e773..4601d24c03a 100644
--- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php
+++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php
@@ -90,7 +90,7 @@ class mod_supplier_proposal_saphir extends ModeleNumRefSupplierProposal
$texte .= ''.$langs->trans("Mask").': ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= ' ';
diff --git a/htdocs/core/modules/takepos/mod_takepos_ref_universal.php b/htdocs/core/modules/takepos/mod_takepos_ref_universal.php
index b624332e0a6..35c7242368f 100644
--- a/htdocs/core/modules/takepos/mod_takepos_ref_universal.php
+++ b/htdocs/core/modules/takepos/mod_takepos_ref_universal.php
@@ -83,7 +83,7 @@ class mod_takepos_ref_universal extends ModeleNumRefTakepos
$texte .= ''.$langs->trans("Mask").': ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= ' ';
diff --git a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php
index 2ddd40a255d..709085d544b 100644
--- a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php
+++ b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php
@@ -130,17 +130,18 @@ class doc_generic_ticket_odt extends ModelePDFTicket
}
}
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
+ $texthelp .= ''.$langs->trans("ExampleOfDirectoriesForModelGen").' ';
// Add list of substitution keys
$texthelp .= ' '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").' ';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
- $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
+ $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
$texte .= '';
// Scan directories
@@ -158,23 +159,18 @@ class doc_generic_ticket_odt extends ModelePDFTicket
}
// Add input to upload a new template file.
$texte .= ''.$langs->trans("UploadNewTemplate");
- $texte .= ' ';
$maxfilesizearray = getMaxFileSizeArray();
$maxmin = $maxfilesizearray['maxmin'];
if ($maxmin > 0) {
$texte .= ' '; // MAX_FILE_SIZE must precede the field type=file
}
+ $texte .= ' ';
$texte .= ' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= '
';
$texte .= '';
- $texte .= '';
- $texte .= '';
- $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
- $texte .= ' ';
- $texte .= ' ';
$texte .= '';
$texte .= '';
diff --git a/htdocs/core/modules/ticket/mod_ticket_universal.php b/htdocs/core/modules/ticket/mod_ticket_universal.php
index 643ee368bc5..15398b43f30 100644
--- a/htdocs/core/modules/ticket/mod_ticket_universal.php
+++ b/htdocs/core/modules/ticket/mod_ticket_universal.php
@@ -84,7 +84,7 @@ class mod_ticket_universal extends ModeleNumRefTicket
$texte .= ''.$langs->trans("Mask").': ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= ' ';
diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php
index fb28cd18b4b..cb1e28666e6 100644
--- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php
+++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php
@@ -141,17 +141,18 @@ class doc_generic_user_odt extends ModelePDFUser
}
}
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
+ $texthelp .= ''.$langs->trans("ExampleOfDirectoriesForModelGen").' ';
// Add list of substitution keys
$texthelp .= ' '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").' ';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
- $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
+ $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
$texte .= '';
// Scan directories
@@ -199,16 +200,11 @@ class doc_generic_user_odt extends ModelePDFUser
}
$texte .= ' ';
$texte .= ' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= '';
$texte .= '';
- $texte .= '';
- $texte .= '';
- $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
- $texte .= ' ';
- $texte .= ' ';
$texte .= '';
$texte .= '';
diff --git a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php
index 535b744f626..7c1b4484fd0 100644
--- a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php
+++ b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php
@@ -109,7 +109,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup
$odtPath = trim(getDolGlobalString('USERGROUP_ADDON_PDF_ODT_PATH'));
$texte = $this->description.". \n";
- $texte .= '';
+ $texte .= ' ';
$texte .= ' ';
$texte .= ' ';
$texte .= ' ';
@@ -143,17 +143,18 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup
}
}
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
+ $texthelp .= ''.$langs->trans("ExampleOfDirectoriesForModelGen").' ';
// Add list of substitution keys
$texthelp .= ' '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").' ';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
- $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
+ $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
$texte .= '';
// Scan directories
@@ -183,15 +184,29 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup
$texte .= "";
$texte .= '';
}
+ $texte .= '';
}
+ // Add input to upload a new template file.
+ $texte .= ''.$langs->trans("UploadNewTemplate");
+ $maxfilesizearray = getMaxFileSizeArray();
+ $maxmin = $maxfilesizearray['maxmin'];
+ if ($maxmin > 0) {
+ $texte .= ' '; // MAX_FILE_SIZE must precede the field type=file
+ }
+ $texte .= ' ';
+ $texte .= ' ';
+ $texte .= ' ';
+ $texte .= '
';
$texte .= '';
- $texte .= '';
- $texte .= '';
- $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
- $texte .= ' ';
- $texte .= ' ';
$texte .= '';
$texte .= '';
diff --git a/htdocs/core/modules/workstation/mod_workstation_advanced.php b/htdocs/core/modules/workstation/mod_workstation_advanced.php
index 7dc6ddc3978..6695d26e64c 100644
--- a/htdocs/core/modules/workstation/mod_workstation_advanced.php
+++ b/htdocs/core/modules/workstation/mod_workstation_advanced.php
@@ -83,7 +83,7 @@ class mod_workstation_advanced extends ModeleNumRefWorkstation
$texte .= ''.$langs->trans("Mask").': ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= ' ';
diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php
index 68899012433..d4e46dc7789 100644
--- a/htdocs/core/photos_resize.php
+++ b/htdocs/core/photos_resize.php
@@ -554,7 +554,7 @@ if (!empty($conf->use_javascript_ajax)) {
print ''."\n";
print '';
- print ''.$langs->trans("Recenter").' ';
+ print ''.$langs->trans("Crop").' ';
print $langs->trans("DefineNewAreaToPick").'... ';
print '';
@@ -589,7 +589,7 @@ if (!empty($conf->use_javascript_ajax)) {
-
+
'."\n";
diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php
index 5404f831a65..7930551e376 100644
--- a/htdocs/core/tpl/admin_extrafields_add.tpl.php
+++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php
@@ -157,7 +157,22 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php
Contact:con
trans("AttributeCode"); ?> (trans("AlphaNumOnlyLowerCharsAndNoSpace"); ?>)
trans("Type"); ?>
-selectarray('type', $type2label, GETPOST('type', 'alpha'), 0, 0, 0, '', 0, 0, 0, '', '', 1); ?>
+';
+foreach ($type2label as $key => $val) {
+ $selected = '';
+ if ($key == GETPOST('type', 'alpha')) {
+ $selected = ' selected="selected"';
+ }
+
+ // Set $valhtml with the picto for the type
+ $valhtml = ($key ? getPictoForType($key) : '').$val;
+
+ print ''.($val ? $val : ' ').' ';
+}
+print '';
+print ajax_combobox('type');
+?>
diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php
index cb5775ca347..d94d58a1659 100644
--- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php
+++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php
@@ -216,23 +216,26 @@ if ($size <= 255 && in_array($type, array('text', 'html'))) {
}*/
if (in_array($type, array_keys($typewecanchangeinto))) {
- $newarray = array();
print '
';
foreach ($type2label as $key => $val) {
$selected = '';
- if ($key == (GETPOST('type', 'alpha') ?GETPOST('type', 'alpha') : $type)) {
+ if ($key == (GETPOST('type', 'alpha') ? GETPOST('type', 'alpha') : $type)) {
$selected = ' selected="selected"';
}
+
+ // Set $valhtml with the picto for the type
+ $valhtml = ($key ? getPictoForType($key) : '').$val;
+
if (in_array($key, $typewecanchangeinto[$type])) {
- print ''.$val.' ';
+ print ''.$val.' ';
} else {
- print ''.$val.' ';
+ print ''.$val.' ';
}
}
print ' ';
print ajax_combobox('type');
} else {
- print $type2label[$type];
+ print getPictoForType($type).$type2label[$type];
print '
';
}
?>
diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php
index 7eb871f5b2b..f8dade2db27 100644
--- a/htdocs/core/tpl/admin_extrafields_view.tpl.php
+++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php
@@ -59,6 +59,9 @@ print '
';
print '
';
print '';
+if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
+ print ' ';
+}
print ''.$langs->trans("Position");
print '';
print img_picto('A-Z', '1downarrow.png');
@@ -82,7 +85,10 @@ print ' '.$form->textwithpicto($langs->trans("CssOnList"), $la
if (isModEnabled('multicompany')) {
print ' '.$langs->trans("Entity").' ';
}
-print ' ';
+// Action column
+if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
+ print ' ';
+}
print " \n";
if (isset($extrafields->attributes[$elementtype]['type']) && is_array($extrafields->attributes[$elementtype]['type']) && count($extrafields->attributes[$elementtype]['type'])) {
@@ -98,6 +104,16 @@ if (isset($extrafields->attributes[$elementtype]['type']) && is_array($extrafiel
}
print '';
+ // Actions
+ if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
+ print '';
+ print ''.img_edit().' ';
+ print ' '.img_delete().' ';
+ if ($extrafields->attributes[$elementtype]['type'][$key] == 'password' && !empty($extrafields->attributes[$elementtype]['param'][$key]['options']) && array_key_exists('dolcrypt', $extrafields->attributes[$elementtype]['param'][$key]['options'])) {
+ print ' '.img_picto('', 'refresh').' ';
+ }
+ print ' '."\n";
+ }
// Position
print "".dol_escape_htmltag($extrafields->attributes[$elementtype]['pos'][$key])." \n";
// Label
@@ -109,6 +125,7 @@ if (isset($extrafields->attributes[$elementtype]['type']) && is_array($extrafiel
// Type
$typetoshow = $type2label[$extrafields->attributes[$elementtype]['type'][$key]];
print '';
+ print getPictoForType($extrafields->attributes[$elementtype]['type'][$key]);
print dol_escape_htmltag($typetoshow);
print " \n";
// Size
@@ -155,10 +172,15 @@ if (isset($extrafields->attributes[$elementtype]['type']) && is_array($extrafiel
print '';
}
// Actions
- print '';
- print ''.img_edit().' ';
- print ' '.img_delete().' ';
- print ' '."\n";
+ if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
+ print '';
+ print ''.img_edit().' ';
+ print ' '.img_delete().' ';
+ if ($extrafields->attributes[$elementtype]['type'][$key] == 'password' && !empty($extrafields->attributes[$elementtype]['param'][$key]['options']) && array_key_exists('dolcrypt', $extrafields->attributes[$elementtype]['param'][$key]['options'])) {
+ print ' '.img_picto('', 'refresh').' ';
+ }
+ print ' '."\n";
+ }
print " ";
}
} else {
diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php
index 0c812cc7609..59c7529c520 100644
--- a/htdocs/core/tpl/card_presend.tpl.php
+++ b/htdocs/core/tpl/card_presend.tpl.php
@@ -24,7 +24,7 @@
*
* $trackid must be defined
* $modelmail
- * $defaulttopic
+ * $defaulttopic and $defaulttopiclang
* $diroutput
* $arrayoffamiliestoexclude=array('system', 'mycompany', 'object', 'objectamount', 'date', 'user', ...);
*/
@@ -77,6 +77,9 @@ if ($action == 'presend') {
$outputlangs->setDefaultLang($newlang);
// Load traductions files required by page
$outputlangs->loadLangs(array('commercial', 'bills', 'orders', 'contracts', 'members', 'propal', 'products', 'supplier_proposal', 'interventions', 'receptions', 'sendings'));
+ if (!empty($defaulttopiclang)) {
+ $outputlangs->loadLangs(array($defaulttopiclang));
+ }
}
$topicmail = '';
@@ -205,6 +208,7 @@ if ($action == 'presend') {
$fuser->fetch($object->fk_user);
$liste['thirdparty'] = $fuser->getFullName($outputlangs)." <".$fuser->email.">";
} else {
+ // For exemple if element is project
if (!empty($object->socid) && $object->socid > 0 && !is_object($object->thirdparty) && method_exists($object, 'fetch_thirdparty')) {
$object->fetch_thirdparty();
}
@@ -269,7 +273,7 @@ if ($action == 'presend') {
if (is_object($object) && is_object($object->thirdparty)) {
$checkRead= ' ';
$substitutionarray['__CHECK_READ__'] = $checkRead;
}
diff --git a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php
index 267ca6803c9..0f0add8e9ae 100644
--- a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php
+++ b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php
@@ -34,11 +34,8 @@ if (!empty($extrafieldsobjectkey) && !empty($extrafields->attributes[$extrafield
}
// If field is a computed field, we make computation to get value
if ($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]) {
- //global $obj, $object;
- //var_dump($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]);
- //var_dump($obj);
- //var_dump($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]);
- $value = dol_eval($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key], 1, 1, '0');
+ $objectoffield = $object; //For compatibily with the computed formula
+ $value = dol_eval($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key], 1, 1, '2');
if (is_numeric(price2num($value)) && $extrafields->attributes[$extrafieldsobjectkey]['totalizable'][$key]) {
$obj->$tmpkey = price2num($value);
}
diff --git a/htdocs/core/tpl/extrafields_list_search_param.tpl.php b/htdocs/core/tpl/extrafields_list_search_param.tpl.php
index 7e58e106882..2ab5749b4e0 100644
--- a/htdocs/core/tpl/extrafields_list_search_param.tpl.php
+++ b/htdocs/core/tpl/extrafields_list_search_param.tpl.php
@@ -31,8 +31,14 @@ if (!empty($search_array_options) && is_array($search_array_options)) { // $extr
$param .= '&'.$search_options_pattern.$tmpkey.'_endmin='.dol_print_date($val['end'], '%M');
$val = '';
}
- if ($val != '') {
- $param .= '&'.$search_options_pattern.$tmpkey.'='.urlencode($val);
+ if ($val !== '') {
+ if (is_array($val)) {
+ foreach ($val as $val2) {
+ $param .= '&'.$search_options_pattern.$tmpkey.'[]='.urlencode($val2);
+ }
+ } else {
+ $param .= '&'.$search_options_pattern.$tmpkey.'='.urlencode($val);
+ }
}
}
}
diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php
index 54557539b26..c5c561c5ec5 100644
--- a/htdocs/core/tpl/massactions_pre.tpl.php
+++ b/htdocs/core/tpl/massactions_pre.tpl.php
@@ -31,7 +31,6 @@
// $sendto
// $withmaindocfilemail
-
if ($massaction == 'predeletedraft') {
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDraftDeletion"), $langs->trans("ConfirmMassDeletionQuestion", count($toselect)), "delete", null, '', 0, 200, 500, 1);
}
@@ -94,7 +93,7 @@ if ($massaction == 'preaffecttag' && isModEnabled('category')) {
}
}
-if ($massaction == 'preupdateprice' && isModEnabled('category')) {
+if ($massaction == 'preupdateprice') {
$formquestion = array();
$valuefield = '';
diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php
index aaf568fc724..382dcb93b7e 100644
--- a/htdocs/core/tpl/objectline_create.tpl.php
+++ b/htdocs/core/tpl/objectline_create.tpl.php
@@ -927,7 +927,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
}
options += ''+this.label+' ';
});
- options += 'trans("InputPrice").'...'; ?> ';
+ options += 'trans("InputPrice").'...'); ?> ';
console.log("finally selected defaultkey="+defaultkey+" defaultprice for buying price="+defaultprice);
@@ -1103,7 +1103,6 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
$('#tva_tx option').removeAttr('selected');
console.log("stringforvatrateselection="+stringforvatrateselection+" -> value of option label for this key="+$('#tva_tx option[value="'+stringforvatrateselection+'"]').val());
$('#tva_tx option[value="'+stringforvatrateselection+'"]').prop('selected', true);
-
global->FCKEDITOR_ENABLE_DETAILS)) {
diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php
index 249da00676f..03449f96f2a 100644
--- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php
+++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php
@@ -189,6 +189,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers
}
}
+ // Set shipment to "Closed" if WORKFLOW_SHIPPING_CLASSIFY_CLOSED_INVOICE is set (deprecated, WORKFLOW_SHIPPING_CLASSIFY_BILLED_INVOICE instead))
if (isModEnabled("expedition") && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_SHIPPING_CLASSIFY_CLOSED_INVOICE)) {
$object->fetchObjectLinked('', 'shipping', $object->id, $object->element);
if (!empty($object->linkedObjects)) {
@@ -210,6 +211,27 @@ class InterfaceWorkflowManager extends DolibarrTriggers
}
}
+ if (isModEnabled("expedition") && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_SHIPPING_CLASSIFY_BILLED_INVOICE)) {
+ $object->fetchObjectLinked('', 'shipping', $object->id, $object->element);
+ if (!empty($object->linkedObjects)) {
+ $totalonlinkedelements = 0;
+ foreach ($object->linkedObjects['shipping'] as $element) {
+ if ($element->statut == Expedition::STATUS_VALIDATED || $element->statut == Expedition::STATUS_CLOSED) {
+ $totalonlinkedelements += $element->total_ht;
+ }
+ }
+ dol_syslog("Amount of linked shipment = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht), LOG_DEBUG);
+ if ($totalonlinkedelements == $object->total_ht) {
+ foreach ($object->linkedObjects['shipping'] as $element) {
+ $ret = $element->setBilled();
+ if ($ret < 0) {
+ return $ret;
+ }
+ }
+ }
+ }
+ }
+
return $ret;
}
@@ -246,7 +268,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers
if (!empty($object->linkedObjects)) {
$totalonlinkedelements = 0;
foreach ($object->linkedObjects['supplier_proposal'] as $element) {
- if ($element->statut == SupplierProposal::STATUS_SIGNED || $element->statut == SupplierProposal::STATUS_BILLED) {
+ if ($element->statut == SupplierProposal::STATUS_SIGNED || $element->statut == SupplierProposal::STATUS_CLOSE) {
$totalonlinkedelements += $element->total_ht;
}
}
@@ -262,13 +284,37 @@ class InterfaceWorkflowManager extends DolibarrTriggers
}
}
- // Then set reception to "Billed" if WORKFLOW_EXPEDITION_CLASSIFY_CLOSED_INVOICE is set
- if (isModEnabled("reception") && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_EXPEDITION_CLASSIFY_CLOSED_INVOICE)) {
+ // Set reception to "Closed" if WORKFLOW_RECEPTION_CLASSIFY_CLOSED_INVOICE is set (deprecated, WORKFLOW_RECEPTION_CLASSIFY_BILLED_INVOICE instead))
+ /*
+ if (isModEnabled("reception") && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_RECEPTION_CLASSIFY_CLOSED_INVOICE)) {
$object->fetchObjectLinked('', 'reception', $object->id, $object->element);
if (!empty($object->linkedObjects)) {
$totalonlinkedelements = 0;
foreach ($object->linkedObjects['reception'] as $element) {
- if ($element->statut == Reception::STATUS_VALIDATED) {
+ if ($element->statut == Reception::STATUS_VALIDATED || $element->statut == Reception::STATUS_CLOSED) {
+ $totalonlinkedelements += $element->total_ht;
+ }
+ }
+ dol_syslog("Amount of linked reception = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht), LOG_DEBUG);
+ if ($totalonlinkedelements == $object->total_ht) {
+ foreach ($object->linkedObjects['reception'] as $element) {
+ $ret = $element->setClosed();
+ if ($ret < 0) {
+ return $ret;
+ }
+ }
+ }
+ }
+ }
+ */
+
+ // Then set reception to "Billed" if WORKFLOW_RECEPTION_CLASSIFY_BILLED_INVOICE is set
+ if (isModEnabled("reception") && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_RECEPTION_CLASSIFY_BILLED_INVOICE)) {
+ $object->fetchObjectLinked('', 'reception', $object->id, $object->element);
+ if (!empty($object->linkedObjects)) {
+ $totalonlinkedelements = 0;
+ foreach ($object->linkedObjects['reception'] as $element) {
+ if ($element->statut == Reception::STATUS_VALIDATED || $element->statut == Reception::STATUS_CLOSED) {
$totalonlinkedelements += $element->total_ht;
}
}
@@ -343,8 +389,9 @@ class InterfaceWorkflowManager extends DolibarrTriggers
if (is_array($order->linkedObjects) && count($order->linkedObjects) > 0) {
foreach ($order->linkedObjects as $type => $shipping_array) {
if ($type == 'shipping' && is_array($shipping_array) && count($shipping_array) > 0) {
+ /** @var Expedition[] $shipping_array */
foreach ($shipping_array as $shipping) {
- if ($shipping->statut <= 0) {
+ if ($shipping->status <= 0) {
continue;
}
if (is_array($shipping->lines) && count($shipping->lines) > 0) {
diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
index 0b6b4a06732..38f2ae5fbcb 100644
--- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
+++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
@@ -106,9 +106,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "companies"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("NewCompanyToDolibarr", $object->name);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("NewCompanyToDolibarr", $object->name);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("NewCompanyToDolibarr", $object->name);
}
- $object->actionmsg = $langs->transnoentities("NewCompanyToDolibarr", $object->name);
$object->sendtoid = 0;
$object->socid = $object->id;
@@ -117,9 +123,16 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "companies"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("COMPANY_MODIFYInDolibarr", $object->name);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("COMPANY_MODIFYInDolibarr", $object->name);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
}
- $object->actionmsg = $langs->transnoentities("COMPANY_MODIFYInDolibarr", $object->name);
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("COMPANY_MODIFYInDolibarr", $object->name);
+ }
+
// For merge event, we add a mention
if (!empty($object->context['mergefromname'])) {
$object->actionmsg = dol_concatdesc($object->actionmsg, $langs->trans("DataFromWasMerged", $object->context['mergefromname']));
@@ -132,7 +145,11 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "orders"));
if (empty($object->actionmsg2)) {
- dol_syslog('Trigger called with property actionmsg2 on object not defined', LOG_ERR);
+ if (empty($object->context['actionmsg2'])) {
+ dol_syslog('Trigger called with property actionmsg2 and context[actionmsg2] on object not defined', LOG_ERR);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
}
// Parameters $object->sendtoid defined by caller
@@ -142,9 +159,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "companies"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("CONTACT_CREATEInDolibarr", $object->getFullName($langs));
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("CONTACT_CREATEInDolibarr", $object->getFullName($langs));
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("CONTACT_CREATEInDolibarr", $object->getFullName($langs));
}
- $object->actionmsg = $langs->transnoentities("CONTACT_CREATEInDolibarr", $object->getFullName($langs));
$object->sendtoid = array($object->id => $object->id);
$object->socid = $object->socid;
@@ -153,9 +176,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "companies"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("CONTACT_MODIFYInDolibarr", $object->name);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("CONTACT_MODIFYInDolibarr", $object->name);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("CONTACT_MODIFYInDolibarr", $object->name);
}
- $object->actionmsg = $langs->transnoentities("CONTACT_MODIFYInDolibarr", $object->name);
$object->sendtoid = array($object->id => $object->id);
$object->socid = $object->socid;
@@ -164,9 +193,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "contracts"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("ContractValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("ContractValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("ContractValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
}
- $object->actionmsg = $langs->transnoentities("ContractValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
$object->sendtoid = 0;
} elseif ($action == 'CONTRACT_SENTBYMAIL') {
@@ -174,7 +209,11 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "contracts"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("ContractSentByEMail", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("ContractSentByEMail", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
}
if (empty($object->actionmsg)) {
$object->actionmsg = $langs->transnoentities("ContractSentByEMail", $object->ref);
@@ -187,17 +226,31 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "propal"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
}
- $object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
$object->sendtoid = 0;
} elseif ($action == 'PROPAL_MODIFY') {
// Load translation files required by the page
$langs->loadLangs(array("agenda", "other", "propal"));
- if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalBackToDraftInDolibarr", ($object->newref ? $object->newref : $object->ref));
- $object->actionmsg = $langs->transnoentities("PropalBackToDraftInDolibarr", ($object->newref ? $object->newref : $object->ref));
+ if (empty($object->actionmsg2)) {
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("PropalBackToDraftInDolibarr", ($object->newref ? $object->newref : $object->ref));
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("PropalBackToDraftInDolibarr", ($object->newref ? $object->newref : $object->ref));
+ }
$object->sendtoid = 0;
} elseif ($action == 'PROPAL_SENTBYMAIL') {
@@ -205,7 +258,11 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "propal"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("ProposalSentByEMail", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("ProposalSentByEMail", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
}
if (empty($object->actionmsg)) {
$object->actionmsg = $langs->transnoentities("ProposalSentByEMail", $object->ref);
@@ -218,9 +275,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "propal"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref);
}
- $object->actionmsg = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref);
$object->sendtoid = 0;
} elseif ($action == 'PROPAL_CLASSIFY_BILLED') {
@@ -228,9 +291,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "propal"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref);
}
- $object->actionmsg = $langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref);
$object->sendtoid = 0;
} elseif ($action == 'PROPAL_CLOSE_REFUSED') {
@@ -238,9 +307,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "propal"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref);
}
- $object->actionmsg = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref);
$object->sendtoid = 0;
} elseif ($action == 'ORDER_VALIDATE') {
@@ -248,9 +323,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "orders"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
}
- $object->actionmsg = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
$object->sendtoid = 0;
} elseif ($action == 'ORDER_CLOSE') {
@@ -258,9 +339,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "orders"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("OrderDeliveredInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("OrderDeliveredInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("OrderDeliveredInDolibarr", $object->ref);
}
- $object->actionmsg = $langs->transnoentities("OrderDeliveredInDolibarr", $object->ref);
$object->sendtoid = 0;
} elseif ($action == 'ORDER_CLASSIFY_BILLED') {
@@ -268,9 +355,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "orders"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("OrderBilledInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("OrderBilledInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("OrderBilledInDolibarr", $object->ref);
}
- $object->actionmsg = $langs->transnoentities("OrderBilledInDolibarr", $object->ref);
$object->sendtoid = 0;
} elseif ($action == 'ORDER_CANCEL') {
@@ -278,9 +371,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "orders"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref);
}
- $object->actionmsg = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref);
$object->sendtoid = 0;
} elseif ($action == 'ORDER_SENTBYMAIL') {
@@ -288,7 +387,11 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "orders"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("OrderSentByEMail", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("OrderSentByEMail", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
}
if (empty($object->actionmsg)) {
$object->actionmsg = $langs->transnoentities("OrderSentByEMail", $object->ref);
@@ -301,9 +404,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "bills"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
}
- $object->actionmsg = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
$object->sendtoid = 0;
} elseif ($action == 'BILL_UNVALIDATE') {
@@ -311,9 +420,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "bills"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref);
}
- $object->actionmsg = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref);
$object->sendtoid = 0;
} elseif ($action == 'BILL_SENTBYMAIL') {
@@ -321,7 +436,11 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "bills"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("InvoiceSentByEMail", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("InvoiceSentByEMail", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
}
if (empty($object->actionmsg)) {
$object->actionmsg = $langs->transnoentities("InvoiceSentByEMail", $object->ref);
@@ -334,8 +453,16 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "bills"));
// Values for this action can't be defined by caller.
- $object->actionmsg2 = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref);
- $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref);
+ if (empty($object->actionmsg2)) {
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref);
+ }
$object->sendtoid = 0;
} elseif ($action == 'BILL_CANCEL') {
@@ -343,9 +470,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "bills"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref);
}
- $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref);
$object->sendtoid = 0;
} elseif ($action == 'FICHINTER_CREATE') {
@@ -353,9 +486,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "interventions"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("InterventionCreatedInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("InterventionCreatedInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("InterventionCreatedInDolibarr", $object->ref);
}
- $object->actionmsg = $langs->transnoentities("InterventionCreatedInDolibarr", $object->ref);
$object->sendtoid = 0;
$object->fk_element = 0;
@@ -365,9 +504,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "interventions"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("InterventionValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("InterventionValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("InterventionValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
}
- $object->actionmsg = $langs->transnoentities("InterventionValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
$object->sendtoid = 0;
$object->fk_element = 0;
@@ -377,9 +522,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "interventions"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("InterventionModifiedInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("InterventionModifiedInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("InterventionModifiedInDolibarr", $object->ref);
}
- $object->actionmsg = $langs->transnoentities("InterventionModifiedInDolibarr", $object->ref);
$object->sendtoid = 0;
$object->fk_element = 0;
@@ -389,7 +540,11 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "interventions"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("InterventionSentByEMail", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("InterventionSentByEMail", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
}
if (empty($object->actionmsg)) {
$object->actionmsg = $langs->transnoentities("InterventionSentByEMail", $object->ref);
@@ -402,9 +557,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "interventions"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref);
}
- $object->actionmsg = $langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref);
$object->sendtoid = 0;
} elseif ($action == 'FICHINTER_CLASSIFY_UNBILLED') {
@@ -412,9 +573,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "interventions"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref);
}
- $object->actionmsg = $langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref);
$object->sendtoid = 0;
} elseif ($action == 'FICHINTER_DELETE') {
@@ -422,9 +589,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "interventions"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("InterventionDeletedInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("InterventionDeletedInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("InterventionDeletedInDolibarr", $object->ref);
}
- $object->actionmsg = $langs->transnoentities("InterventionDeletedInDolibarr", $object->ref);
$object->sendtoid = 0;
$object->fk_element = 0;
@@ -434,7 +607,11 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "sendings"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("ShippingValidated", ($object->newref ? $object->newref : $object->ref));
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("ShippingValidated", ($object->newref ? $object->newref : $object->ref));
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
}
if (empty($object->actionmsg)) {
$object->actionmsg = $langs->transnoentities("ShippingValidated", ($object->newref ? $object->newref : $object->ref));
@@ -447,7 +624,11 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "sendings"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("ShippingSentByEMail", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("ShippingSentByEMail", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
}
if (empty($object->actionmsg)) {
$object->actionmsg = $langs->transnoentities("ShippingSentByEMail", $object->ref);
@@ -461,7 +642,11 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->load("receptions");
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("ReceptionValidated", ($object->newref ? $object->newref : $object->ref));
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("ReceptionValidated", ($object->newref ? $object->newref : $object->ref));
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
}
if (empty($object->actionmsg)) {
$object->actionmsg = $langs->transnoentities("ReceptionValidated", ($object->newref ? $object->newref : $object->ref));
@@ -475,7 +660,11 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->load("receptions");
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("ReceptionSentByEMail", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("ReceptionSentByEMail", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
}
if (empty($object->actionmsg)) {
$object->actionmsg = $langs->transnoentities("ReceptionSentByEMail", $object->ref);
@@ -488,9 +677,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "propal"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
}
- $object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
$object->sendtoid = 0;
} elseif ($action == 'PROPOSAL_SUPPLIER_SENTBYMAIL') {
@@ -498,7 +693,11 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "propal"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("ProposalSentByEMail", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("ProposalSentByEMail", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
}
if (empty($object->actionmsg)) {
$object->actionmsg = $langs->transnoentities("ProposalSentByEMail", $object->ref);
@@ -511,9 +710,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "propal"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref);
}
- $object->actionmsg = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref);
$object->sendtoid = 0;
} elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_REFUSED') {
@@ -521,9 +726,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "propal"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref);
}
- $object->actionmsg = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref);
$object->sendtoid = 0;
} elseif ($action == 'ORDER_SUPPLIER_CREATE') {
@@ -531,9 +742,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "orders"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("OrderCreatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("OrderCreatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("OrderCreatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
}
- $object->actionmsg = $langs->transnoentities("OrderCreatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
$object->sendtoid = 0;
} elseif ($action == 'ORDER_SUPPLIER_VALIDATE') {
@@ -541,9 +758,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "orders"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
}
- $object->actionmsg = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
$object->sendtoid = 0;
} elseif ($action == 'ORDER_SUPPLIER_APPROVE') {
@@ -551,9 +774,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "orders"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("OrderApprovedInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("OrderApprovedInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("OrderApprovedInDolibarr", $object->ref);
}
- $object->actionmsg = $langs->transnoentities("OrderApprovedInDolibarr", $object->ref);
$object->sendtoid = 0;
} elseif ($action == 'ORDER_SUPPLIER_REFUSE') {
@@ -561,9 +790,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "orders", "main"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("OrderRefusedInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("OrderRefusedInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("OrderRefusedInDolibarr", $object->ref);
}
- $object->actionmsg = $langs->transnoentities("OrderRefusedInDolibarr", $object->ref);
if (!empty($object->refuse_note)) {
$object->actionmsg .= ' ';
@@ -576,9 +811,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "orders", "main"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref);
}
- $object->actionmsg = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref);
if (!empty($object->cancel_note)) {
$object->actionmsg .= ' ';
@@ -591,9 +832,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "orders"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref ? $object->newref : $object->ref));
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref ? $object->newref : $object->ref));
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref ? $object->newref : $object->ref));
}
- $object->actionmsg = $langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref ? $object->newref : $object->ref));
if (!empty($object->context['comments'])) {
$object->actionmsg .= ' ';
@@ -605,12 +852,16 @@ class InterfaceActionsAuto extends DolibarrTriggers
// Load translation files required by the page
$langs->loadLangs(array("agenda", "other", "orders"));
- if (empty($object->context['actionmsg2'])) {
- $object->actionmsg2 = $langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref ? $object->newref : $object->ref));
- } else {
- $object->actionmsg2 = $object->context['actionmsg2'];
+ if (empty($object->actionmsg2)) {
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref ? $object->newref : $object->ref));
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref ? $object->newref : $object->ref));
}
- $object->actionmsg = $langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref ? $object->newref : $object->ref));
$object->sendtoid = 0;
} elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') {
@@ -618,7 +869,11 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "bills", "orders"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("SupplierOrderSentByEMail", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("SupplierOrderSentByEMail", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
}
if (empty($object->actionmsg)) {
$object->actionmsg = $langs->transnoentities("SupplierOrderSentByEMail", $object->ref);
@@ -631,7 +886,11 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "bills", "orders"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("SupplierOrderClassifiedBilled", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("SupplierOrderClassifiedBilled", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
}
if (empty($object->actionmsg)) {
$object->actionmsg = $langs->transnoentities("SupplierOrderClassifiedBilled", $object->ref);
@@ -643,9 +902,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "bills"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
}
- $object->actionmsg = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
$object->sendtoid = 0;
} elseif ($action == 'BILL_SUPPLIER_UNVALIDATE') {
@@ -653,9 +918,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "bills"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref);
}
- $object->actionmsg = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref);
$object->sendtoid = 0;
} elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL') {
@@ -663,7 +934,11 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "bills", "orders"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
}
if (empty($object->actionmsg)) {
$object->actionmsg = $langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref);
@@ -676,9 +951,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "bills"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref);
}
- $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref);
$object->sendtoid = 0;
} elseif ($action == 'BILL_SUPPLIER_CANCELED') {
@@ -686,9 +967,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "bills"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref);
}
- $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref);
$object->sendtoid = 0;
} elseif ($action == 'MEMBER_VALIDATE') {
@@ -697,11 +984,17 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "members"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("MemberValidatedInDolibarr", $object->getFullName($langs));
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("MemberValidatedInDolibarr", $object->getFullName($langs));
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("MemberValidatedInDolibarr", $object->getFullName($langs));
+ $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
+ $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type;
}
- $object->actionmsg = $langs->transnoentities("MemberValidatedInDolibarr", $object->getFullName($langs));
- $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
- $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type;
$object->sendtoid = 0;
} elseif ($action == 'MEMBER_MODIFY') {
@@ -709,11 +1002,17 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "members"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("MemberModifiedInDolibarr", $object->getFullName($langs));
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("MemberModifiedInDolibarr", $object->getFullName($langs));
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("MemberModifiedInDolibarr", $object->getFullName($langs));
+ $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
+ $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type;
}
- $object->actionmsg = $langs->transnoentities("MemberModifiedInDolibarr", $object->getFullName($langs));
- $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
- $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type;
$object->sendtoid = 0;
} elseif ($action == 'MEMBER_SUBSCRIPTION_CREATE') {
@@ -729,13 +1028,19 @@ class InterfaceActionsAuto extends DolibarrTriggers
}
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs));
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs));
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs));
+ $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$member->getFullName($langs);
+ $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->fk_type;
+ $object->actionmsg .= "\n".$langs->transnoentities("Amount").': '.$object->amount;
+ $object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day');
}
- $object->actionmsg = $langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs));
- $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$member->getFullName($langs);
- $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->fk_type;
- $object->actionmsg .= "\n".$langs->transnoentities("Amount").': '.$object->amount;
- $object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day');
$object->sendtoid = 0;
if (isset($object->fk_soc) && $object->fk_soc > 0) {
@@ -753,13 +1058,19 @@ class InterfaceActionsAuto extends DolibarrTriggers
}
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs));
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs));
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs));
+ $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$member->getFullName($langs);
+ $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->fk_type;
+ $object->actionmsg .= "\n".$langs->transnoentities("Amount").': '.$object->amount;
+ $object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day');
}
- $object->actionmsg = $langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs));
- $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$member->getFullName($langs);
- $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->fk_type;
- $object->actionmsg .= "\n".$langs->transnoentities("Amount").': '.$object->amount;
- $object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day');
$object->sendtoid = 0;
if ($object->fk_soc > 0) {
@@ -777,13 +1088,19 @@ class InterfaceActionsAuto extends DolibarrTriggers
$member->fetch($object->fk_adherent);
}
- $object->actionmsg = $langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $member->getFullName($langs));
- $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$member->getFullName($langs);
- $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->fk_type;
- $object->actionmsg .= "\n".$langs->transnoentities("Amount").': '.$object->amount;
- $object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day');
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $member->getFullName($langs));
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $member->getFullName($langs));
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $member->getFullName($langs));
+ $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$member->getFullName($langs);
+ $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->fk_type;
+ $object->actionmsg .= "\n".$langs->transnoentities("Amount").': '.$object->amount;
+ $object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day');
}
$object->sendtoid = 0;
@@ -795,11 +1112,17 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "members"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("MemberResiliatedInDolibarr", $object->getFullName($langs));
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("MemberResiliatedInDolibarr", $object->getFullName($langs));
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("MemberResiliatedInDolibarr", $object->getFullName($langs));
+ $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
+ $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type;
}
- $object->actionmsg = $langs->transnoentities("MemberResiliatedInDolibarr", $object->getFullName($langs));
- $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
- $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type;
$object->sendtoid = 0;
} elseif ($action == 'MEMBER_DELETE') {
@@ -807,11 +1130,17 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "members"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("MemberDeletedInDolibarr", $object->getFullName($langs));
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("MemberDeletedInDolibarr", $object->getFullName($langs));
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("MemberDeletedInDolibarr", $object->getFullName($langs));
+ $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
+ $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type;
}
- $object->actionmsg = $langs->transnoentities("MemberDeletedInDolibarr", $object->getFullName($langs));
- $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
- $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type;
$object->sendtoid = 0;
} elseif ($action == 'MEMBER_EXCLUDE') {
@@ -819,11 +1148,17 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "members"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("MemberExcludedInDolibarr", $object->getFullName($langs));
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("MemberExcludedInDolibarr", $object->getFullName($langs));
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("MemberExcludedInDolibarr", $object->getFullName($langs));
+ $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
+ $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type;
}
- $object->actionmsg = $langs->transnoentities("MemberExcludedInDolibarr", $object->getFullName($langs));
- $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
- $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type;
$object->sendtoid = 0;
} elseif ($action == 'PROJECT_CREATE') {
@@ -832,10 +1167,16 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "projects"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("ProjectCreatedInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("ProjectCreatedInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("ProjectCreatedInDolibarr", $object->ref);
+ $object->actionmsg .= "\n".$langs->transnoentities("Project").': '.$object->ref;
}
- $object->actionmsg = $langs->transnoentities("ProjectCreatedInDolibarr", $object->ref);
- $object->actionmsg .= "\n".$langs->transnoentities("Project").': '.$object->ref;
$object->sendtoid = 0;
} elseif ($action == 'PROJECT_VALIDATE') {
@@ -843,10 +1184,16 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "projects"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("ProjectValidatedInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("ProjectValidatedInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("ProjectValidatedInDolibarr", $object->ref);
+ $object->actionmsg .= "\n".$langs->transnoentities("Project").': '.$object->ref;
}
- $object->actionmsg = $langs->transnoentities("ProjectValidatedInDolibarr", $object->ref);
- $object->actionmsg .= "\n".$langs->transnoentities("Project").': '.$object->ref;
$object->sendtoid = 0;
} elseif ($action == 'PROJECT_MODIFY') {
@@ -854,9 +1201,16 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "projects"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("ProjectModifiedInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("ProjectModifiedInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
}
- $object->actionmsg = $langs->transnoentities("ProjectModifiedInDolibarr", $object->ref);
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("ProjectModifiedInDolibarr", $object->ref);
+ }
+
//$object->actionmsg .= "\n".$langs->transnoentities("Task").': ???';
if (!empty($object->usage_opportunity) && is_object($object->oldcopy) && $object->opp_status != $object->oldcopy->opp_status) {
$object->actionmsg .= "\n".$langs->transnoentitiesnoconv("OpportunityStatus").': '.$object->oldcopy->opp_status.' -> '.$object->opp_status;
@@ -868,7 +1222,11 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "projects"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("ProjectSentByEMail", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("ProjectSentByEMail", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
}
if (empty($object->actionmsg)) {
$object->actionmsg = $langs->transnoentities("ProjectSentByEMail", $object->ref);
@@ -881,9 +1239,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "projects"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("ProjectClosedInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("ProjectClosedInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("ProjectClosedInDolibarr", $object->ref);
}
- $object->actionmsg = $langs->transnoentities("ProjectClosedInDolibarr", $object->ref);
$object->sendtoid = 0;
} elseif ($action == 'TASK_CREATE') {
@@ -892,10 +1256,16 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "projects"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("TaskCreatedInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("TaskCreatedInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("TaskCreatedInDolibarr", $object->ref);
+ $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref;
}
- $object->actionmsg = $langs->transnoentities("TaskCreatedInDolibarr", $object->ref);
- $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref;
$object->sendtoid = 0;
} elseif ($action == 'TASK_MODIFY') {
@@ -903,10 +1273,16 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "projects"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("TaskModifiedInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("TaskModifiedInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("TaskModifieddInDolibarr", $object->ref);
+ $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref;
}
- $object->actionmsg = $langs->transnoentities("TaskModifieddInDolibarr", $object->ref);
- $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref;
$object->sendtoid = 0;
} elseif ($action == 'TASK_DELETE') {
@@ -914,10 +1290,16 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "projects"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("TaskDeletedInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("TaskDeletedInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
+ }
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("TaskDeletedInDolibarr", $object->ref);
+ $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref;
}
- $object->actionmsg = $langs->transnoentities("TaskDeletedInDolibarr", $object->ref);
- $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref;
$object->sendtoid = 0;
} elseif ($action == 'TICKET_ASSIGNED') {
@@ -925,9 +1307,16 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->loadLangs(array("agenda", "other", "projects"));
if (empty($object->actionmsg2)) {
- $object->actionmsg2 = $langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref);
+ if (empty($object->context['actionmsg2'])) {
+ $object->actionmsg2 = $langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref);
+ } else {
+ $object->actionmsg2 = $object->context['actionmsg2'];
+ }
}
- $object->actionmsg = $langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref);
+ if (empty($object->actionmsg)) {
+ $object->actionmsg = $langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref);
+ }
+
if ($object->oldcopy->fk_user_assign > 0) {
$tmpuser = new User($this->db);
$tmpuser->fetch($object->oldcopy->fk_user_assign);
@@ -942,6 +1331,7 @@ class InterfaceActionsAuto extends DolibarrTriggers
} else {
$object->actionmsg .= "\n".$langs->transnoentities("NewUser").': '.$langs->trans("None");
}
+
$object->sendtoid = 0;
} else {
// TODO Merge all previous cases into this generic one
@@ -949,10 +1339,10 @@ class InterfaceActionsAuto extends DolibarrTriggers
// Can also be a value defined by an external module like SENTBYSMS, COMPANY_SENTBYSMS, MEMBER_SENTBYSMS, ...
// Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function).
// Note that these key can be set in agenda setup, only if defined into llx_c_action_trigger
- if (!empty($object->context['actionmsg']) && empty($object->actionmsg)) {
+ if (!empty($object->context['actionmsg']) && empty($object->actionmsg)) { // For description
$object->actionmsg = $object->context['actionmsg'];
}
- if (!empty($object->context['actionmsg2']) && empty($object->actionmsg2)) {
+ if (!empty($object->context['actionmsg2']) && empty($object->actionmsg2)) { // For label
$object->actionmsg2 = $object->context['actionmsg2'];
}
@@ -1029,14 +1419,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
}
}
- /* Seems no more required: We have the data in dedicated field now.
- if (!empty($user->login)) {
- $object->actionmsg = dol_concatdesc($langs->transnoentities("Author").': '.$user->login, $object->actionmsg);
- } elseif (isset($object->origin_email)) {
- $object->actionmsg = dol_concatdesc($langs->transnoentities("Author").': '.$object->origin_email, $object->actionmsg);
- }
- */
-
dol_syslog("Trigger '".$this->name."' for action '".$action."' launched by ".__FILE__.". id=".$object->id);
// Add entry in event table
@@ -1048,28 +1430,27 @@ class InterfaceActionsAuto extends DolibarrTriggers
$object->actionmsg = dol_concatdesc($object->actionmsg, "\n".$langs->transnoentities("AttachedFiles").': '.$attachs);
}
}
- require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
- require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
- $contactforaction = new Contact($this->db);
- $societeforaction = new Societe($this->db);
- // Set contactforaction if there is only 1 contact.
+ $societeforactionid = 0;
+ $contactforactionid = 0;
+
+ // Set $contactforactionid
if (is_array($object->sendtoid)) {
if (count($object->sendtoid) == 1) {
- $contactforaction->fetch(reset($object->sendtoid));
+ $contactforactionid = reset($object->sendtoid);
}
} else {
if ($object->sendtoid > 0) {
- $contactforaction->fetch($object->sendtoid);
+ $contactforactionid = $object->sendtoid;
}
}
- // Set societeforaction.
+ // Set $societeforactionid
if (isset($object->socid) && $object->socid > 0) {
- $societeforaction->fetch($object->socid);
+ $societeforactionid = $object->socid;
} elseif (isset($object->fk_soc) && $object->fk_soc > 0) {
- $societeforaction->fetch($object->fk_soc);
+ $societeforactionid = $object->fk_soc;
} elseif (isset($object->thirdparty) && isset($object->thirdparty->id) && $object->thirdparty->id > 0) {
- $societeforaction = $object->thirdparty;
+ $societeforactionid = $object->thirdparty->id;
}
$projectid = isset($object->fk_project) ? $object->fk_project : 0;
@@ -1098,8 +1479,8 @@ class InterfaceActionsAuto extends DolibarrTriggers
$actioncomm->datef = $now;
$actioncomm->durationp = 0;
$actioncomm->percentage = -1; // Not applicable
- $actioncomm->socid = $societeforaction->id;
- $actioncomm->contact_id = $contactforaction->id; // deprecated, use ->socpeopleassigned instead
+ $actioncomm->socid = $societeforactionid;
+ $actioncomm->contact_id = $contactforactionid; // deprecated, now managed by setting $actioncomm->socpeopleassigned later
$actioncomm->authorid = $user->id; // User saving action
$actioncomm->userownerid = $user->id; // Owner of action
// Fields defined when action is an email (content should be into object->actionmsg to be added into event note, subject should be into object->actionms2 to be added into event label)
@@ -1149,6 +1530,9 @@ class InterfaceActionsAuto extends DolibarrTriggers
}
}
+ // Reset value set by caller
+ unset($object->context['actionmsg']);
+ unset($object->context['actionmsg2']);
unset($object->actionmsg);
unset($object->actionmsg2);
unset($object->actiontypecode); // When several action are called on same object, we must be sure to not reuse value of first action.
diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php
index 13581de7e3c..bcc70dd15d2 100644
--- a/htdocs/cron/class/cronjob.class.php
+++ b/htdocs/cron/class/cronjob.class.php
@@ -1057,7 +1057,7 @@ class Cronjob extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php
index 9ad81450806..e188526ef58 100644
--- a/htdocs/delivery/class/delivery.class.php
+++ b/htdocs/delivery/class/delivery.class.php
@@ -786,7 +786,7 @@ class Delivery extends CommonObject
//{
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php
index c730c7d0b08..0d9a9e043fd 100644
--- a/htdocs/don/class/don.class.php
+++ b/htdocs/don/class/don.class.php
@@ -443,7 +443,6 @@ class Don extends CommonObject
}
} else {
$this->error = $this->db->lasterror();
- $this->errno = $this->db->lasterrno();
$error++;
}
@@ -931,7 +930,7 @@ class Don extends CommonObject
$url = DOL_URL_ROOT.'/don/card.php?id='.$this->id;
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php
index 0f6d52638cb..1d02008dd6d 100644
--- a/htdocs/emailcollector/class/emailcollector.class.php
+++ b/htdocs/emailcollector/class/emailcollector.class.php
@@ -580,7 +580,7 @@ class EmailCollector extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
@@ -1105,8 +1105,8 @@ class EmailCollector extends CommonObject
$searchfilterisanswer = 0;
$searchfilterisnotanswer = 0;
$searchfilterreplyto = 0;
- $searchfilterexcludebody = '';
- $searchfilterexcludesubject = '';
+ $searchfilterexcludebodyarray = array();
+ $searchfilterexcludesubjectarray = array();
$operationslog = '';
$now = dol_now();
@@ -1131,6 +1131,8 @@ class EmailCollector extends CommonObject
if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
if ($this->acces_type == 1) {
// Mode OAUth2 with PHP-IMAP
+ $supportedoauth2array = array();
+
require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // define $supportedoauth2array
$keyforsupportedoauth2array = $this->oauth_service;
if (preg_match('/^.*-/', $keyforsupportedoauth2array)) {
@@ -1298,7 +1300,7 @@ class EmailCollector extends CommonObject
if ($rule['type'] == 'subject') {
if (strpos($rule['rulevalue'], '!') === 0) {
//array_push($criteria, array("NOT SUBJECT" => $rule['rulevalue']));
- $searchfilterexcludesubject = preg_replace('/^!/', '', $rule['rulevalue']);
+ $searchfilterexcludesubjectarray[] = preg_replace('/^!/', '', $rule['rulevalue']);
} else {
array_push($criteria, array("SUBJECT" => $rule['rulevalue']));
}
@@ -1306,7 +1308,7 @@ class EmailCollector extends CommonObject
if ($rule['type'] == 'body') {
if (strpos($rule['rulevalue'], '!') === 0) {
//array_push($criteria, array("NOT BODY" => $rule['rulevalue']));
- $searchfilterexcludebody = preg_replace('/^!/', '', $rule['rulevalue']);
+ $searchfilterexcludebodyarray[] = preg_replace('/^!/', '', $rule['rulevalue']);
} else {
array_push($criteria, array("BODY" => $rule['rulevalue']));
}
@@ -1429,7 +1431,7 @@ class EmailCollector extends CommonObject
if ($rule['type'] == 'subject') {
if (strpos($rule['rulevalue'], '!') === 0) {
//$search .= ($search ? ' ' : '').'NOT BODY "'.str_replace('"', '', $rule['rulevalue']).'"';
- $searchfilterexcludesubject = preg_replace('/^!/', '', $rule['rulevalue']);
+ $searchfilterexcludesubjectarray[] = preg_replace('/^!/', '', $rule['rulevalue']);
} else {
$search .= ($search ? ' ' : '').'SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"';
}
@@ -1437,7 +1439,7 @@ class EmailCollector extends CommonObject
if ($rule['type'] == 'body') {
if (strpos($rule['rulevalue'], '!') === 0) {
//$search .= ($search ? ' ' : '').'NOT BODY "'.str_replace('"', '', $rule['rulevalue']).'"';
- $searchfilterexcludebody = preg_replace('/^!/', '', $rule['rulevalue']);
+ $searchfilterexcludebodyarray[] = preg_replace('/^!/', '', $rule['rulevalue']);
} else {
// Warning: Google doesn't implement IMAP properly, and only matches whole words,
$search .= ($search ? ' ' : '').'BODY "'.str_replace('"', '', $rule['rulevalue']).'"';
@@ -1630,7 +1632,14 @@ class EmailCollector extends CommonObject
$emailto = $this->decodeSMTPSubject($overview[0]->to);
- $operationslog .= ' ** Process email #'.dol_escape_htmltag($iforemailloop)." - ".dol_escape_htmltag((string) $imapemail)." - References: ".dol_escape_htmltag($headers['References']??'')." - Subject: ".dol_escape_htmltag($headers['Subject']);
+ $operationslog .= ' ** Process email #'.dol_escape_htmltag($iforemailloop);
+ if (getDolGlobalInt('MAIN_IMAP_USE_PHPIMAP')) {
+ /** @var Webklex\PHPIMAP\Message $imapemail */
+ // $operationslog .= " - ".dol_escape_htmltag((string) $imapemail);
+ } else {
+ $operationslog .= " - ".dol_escape_htmltag((string) $imapemail);
+ }
+ $operationslog .= " - References: ".dol_escape_htmltag($headers['References']??'')." - Subject: ".dol_escape_htmltag($headers['Subject']);
dol_syslog("** Process email ".$iforemailloop." References: ".($headers['References']??'')." Subject: ".$headers['Subject']);
@@ -1735,10 +1744,10 @@ class EmailCollector extends CommonObject
$overview[0]->subject = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $overview[0]->subject);
}
// GET IMAP email structure/content
-
global $htmlmsg, $plainmsg, $charset, $attachments;
- if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
+ if (getDolGlobalInt('MAIN_IMAP_USE_PHPIMAP')) {
+ /** @var Webklex\PHPIMAP\Message $imapemail */
if ($imapemail->hasHTMLBody()) {
$htmlmsg = $imapemail->getHTMLBody();
}
@@ -1769,12 +1778,14 @@ class EmailCollector extends CommonObject
continue; // Exclude email
}
- if ($searchfilterexcludebody) {
- if (preg_match('/'.preg_quote($searchfilterexcludebody, '/').'/ms', $messagetext)) {
- $nbemailprocessed++;
- $operationslog .= ' Discarded - Email body contains string '.$searchfilterexcludebody;
- dol_syslog(" Discarded - Email body contains string ".$searchfilterexcludebody);
- continue; // Exclude email
+ if (!empty($searchfilterexcludebodyarray)) {
+ foreach ($searchfilterexcludebodyarray as $searchfilterexcludebody) {
+ if (preg_match('/'.preg_quote($searchfilterexcludebody, '/').'/ms', $messagetext)) {
+ $nbemailprocessed++;
+ $operationslog .= ' Discarded - Email body contains string '.$searchfilterexcludebody;
+ dol_syslog(" Discarded - Email body contains string ".$searchfilterexcludebody);
+ continue 2; // Exclude email
+ }
}
}
@@ -1861,12 +1872,14 @@ class EmailCollector extends CommonObject
//var_dump($msgid);exit;
}
- if ($searchfilterexcludesubject) {
- if (preg_match('/'.preg_quote($searchfilterexcludesubject, '/').'/ms', $subject)) {
- $nbemailprocessed++;
- $operationslog .= ' Discarded - Email subject contains string '.$searchfilterexcludesubject;
- dol_syslog(" Discarded - Email subject contains string ".$searchfilterexcludesubject);
- continue; // Exclude email
+ if (!empty($searchfilterexcludesubjectarray)) {
+ foreach ($searchfilterexcludesubjectarray as $searchfilterexcludesubject) {
+ if (preg_match('/'.preg_quote($searchfilterexcludesubject, '/').'/ms', $subject)) {
+ $nbemailprocessed++;
+ $operationslog .= ' Discarded - Email subject contains string '.$searchfilterexcludesubject;
+ dol_syslog(" Discarded - Email subject contains string ".$searchfilterexcludesubject);
+ continue 2; // Exclude email
+ }
}
}
@@ -2041,7 +2054,7 @@ class EmailCollector extends CommonObject
}
if (get_class($objectemail) != 'Societe') {
- $thirdpartyid = $objectemail->fk_soc;
+ $thirdpartyid = $objectemail->fk_soc ?? $objectemail->socid;
} else {
$thirdpartyid = $objectemail->id;
}
@@ -2270,12 +2283,16 @@ class EmailCollector extends CommonObject
}
} else {
// Regex not found
- $idtouseforthirdparty = null;
- $nametouseforthirdparty = null;
- $emailtouseforthirdparty = null;
- $namealiastouseforthirdparty = null;
+ if (in_array($propertytooverwrite, array('id', 'email', 'name', 'name_alias'))) {
+ $idtouseforthirdparty = null;
+ $nametouseforthirdparty = null;
+ $emailtouseforthirdparty = null;
+ $namealiastouseforthirdparty = null;
- $operationslog .= ' propertytooverwrite='.$propertytooverwrite.' Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Not found';
+ $operationslog .= ' propertytooverwrite='.$propertytooverwrite.' Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Not found. Property searched is critical so we cancel the search.';
+ } else {
+ $operationslog .= ' propertytooverwrite='.$propertytooverwrite.' Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Not found';
+ }
}
//var_dump($object->$tmpproperty);exit;
} else {
@@ -2317,7 +2334,7 @@ class EmailCollector extends CommonObject
if (!$errorforactions && ($idtouseforthirdparty || $emailtouseforthirdparty || $nametouseforthirdparty || $namealiastouseforthirdparty)) {
// We make another search on thirdparty
- $operationslog .= ' We have this data to search thirdparty: '.$idtouseforthirdparty.' '.$emailtouseforthirdparty.' '.$nametouseforthirdparty.' '.$namealiastouseforthirdparty;
+ $operationslog .= ' We have this data to search thirdparty: id='.$idtouseforthirdparty.', email='.$emailtouseforthirdparty.', name='.$nametouseforthirdparty.', name_alias='.$namealiastouseforthirdparty;
$tmpobject = new stdClass();
$tmpobject->element == 'generic';
@@ -2598,15 +2615,25 @@ class EmailCollector extends CommonObject
}
}
} elseif ($operation['type'] == 'recordjoinpiece') {
- $pj = getAttachments($imapemail, $connection);
- foreach ($pj as $key => $val) {
- $data[$val['filename']] = getFileData($imapemail, $val['pos'], $val['type'], $connection);
+ $data = [];
+ if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
+ foreach ($attachments as $attachment) {
+ if ($attachment->getName() === 'undefined') {
+ continue;
+ }
+ $data[$attachment->getName()] = $attachment->getContent();
+ }
+ } else {
+ $pj = getAttachments($imapemail, $connection);
+ foreach ($pj as $key => $val) {
+ $data[$val['filename']] = getFileData($imapemail, $val['pos'], $val['type'], $connection);
+ }
}
- if (count($pj) > 0) {
+ if (count($data) > 0) {
$sql = "SELECT rowid as id FROM ".MAIN_DB_PREFIX."user WHERE email LIKE '%".$this->db->escape($from)."%'";
$resql = $this->db->query($sql);
if ($this->db->num_rows($resql) == 0) {
- $this->errors[] = 'User Not allowed to add documents';
+ $this->errors[] = "User Not allowed to add documents ({$from})";
}
$arrayobject = array(
'propale' => array('table' => 'propal',
@@ -2749,9 +2776,8 @@ class EmailCollector extends CommonObject
}
}
foreach ($dirs as $target) {
+ $prefix = $this->actions[$this->id]['actionparam'];
foreach ($data as $filename => $content) {
- $prefix = $this->actions[$this->id]['actionparam'];
-
$resr = saveAttachment($target, $prefix . '_' . $filename, $content);
if ($resr == -1) {
$this->errors[] = 'Doc not saved';
@@ -2877,7 +2903,11 @@ class EmailCollector extends CommonObject
}
if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
foreach ($attachments as $attachment) {
- $attachment->save($destdir.'/');
+ // $attachment->save($destdir.'/');
+ $typeattachment = (string) $attachment->getDisposition();
+ $filename = $attachment->getFilename();
+ $content = $attachment->getContent();
+ $this->saveAttachment($destdir, $filename, $content);
}
} else {
$this->getmsg($connection, $imapemail, $destdir);
@@ -3007,7 +3037,11 @@ class EmailCollector extends CommonObject
}
if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
foreach ($attachments as $attachment) {
- $attachment->save($destdir.'/');
+ // $attachment->save($destdir.'/');
+ $typeattachment = (string) $attachment->getDisposition();
+ $filename = $attachment->getFilename();
+ $content = $attachment->getContent();
+ $this->saveAttachment($destdir, $filename, $content);
}
} else {
$this->getmsg($connection, $imapemail, $destdir);
@@ -3223,6 +3257,7 @@ class EmailCollector extends CommonObject
} else {
$langs->load("admin");
$output = $langs->trans('NoNewEmailToProcess');
+ $output .= ' (defaultlang='.$langs->defaultlang.')';
}
// Disconnect
@@ -3537,4 +3572,33 @@ class EmailCollector extends CommonObject
return $text;
}
+
+ /**
+ * saveAttachment
+ *
+ * @param string $destdir destination
+ * @param string $filename filename
+ * @param string $content content
+ * @return void
+ */
+ private function saveAttachment($destdir, $filename, $content)
+ {
+ require_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php';
+
+ $tmparraysize = getDefaultImageSizes();
+ $maxwidthsmall = $tmparraysize['maxwidthsmall'];
+ $maxheightsmall = $tmparraysize['maxheightsmall'];
+ $maxwidthmini = $tmparraysize['maxwidthmini'];
+ $maxheightmini = $tmparraysize['maxheightmini'];
+ $quality = $tmparraysize['quality'];
+
+ file_put_contents($destdir.'/'.$filename, $content);
+ if (image_format_supported($filename) == 1) {
+ // Create thumbs
+ vignette($destdir.'/'.$filename, $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs");
+ // Create mini thumbs for image (Ratio is near 16/9)
+ vignette($destdir.'/'.$filename, $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs");
+ }
+ addFileIntoDatabaseIndex($destdir, $filename);
+ }
}
diff --git a/htdocs/emailcollector/class/emailcollectoraction.class.php b/htdocs/emailcollector/class/emailcollectoraction.class.php
index ec985238b82..07aea7feda8 100644
--- a/htdocs/emailcollector/class/emailcollectoraction.class.php
+++ b/htdocs/emailcollector/class/emailcollectoraction.class.php
@@ -295,7 +295,7 @@ class EmailCollectorAction extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
diff --git a/htdocs/emailcollector/class/emailcollectorfilter.class.php b/htdocs/emailcollector/class/emailcollectorfilter.class.php
index 807b16c951b..0bdb0294a27 100644
--- a/htdocs/emailcollector/class/emailcollectorfilter.class.php
+++ b/htdocs/emailcollector/class/emailcollectorfilter.class.php
@@ -309,7 +309,7 @@ class EmailCollectorFilter extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php
index a7b173acc6c..ffd3b7d1604 100644
--- a/htdocs/eventorganization/class/conferenceorbooth.class.php
+++ b/htdocs/eventorganization/class/conferenceorbooth.class.php
@@ -536,7 +536,7 @@ class ConferenceOrBooth extends ActionComm
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php
index 11cbd811da8..f45066d3d11 100644
--- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php
+++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php
@@ -780,7 +780,7 @@ class ConferenceOrBoothAttendee extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
diff --git a/htdocs/eventorganization/conferenceorbooth_card.php b/htdocs/eventorganization/conferenceorbooth_card.php
index f78d4a9ba2f..9c1bf7c2361 100644
--- a/htdocs/eventorganization/conferenceorbooth_card.php
+++ b/htdocs/eventorganization/conferenceorbooth_card.php
@@ -216,7 +216,7 @@ if (!empty($withproject)) {
// Define a complementary filter for search of next/prev ref.
if (empty($user->rights->project->all->lire)) {
$objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
- $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
+ $projectstatic->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
}
dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
diff --git a/htdocs/eventorganization/conferenceorbooth_contact.php b/htdocs/eventorganization/conferenceorbooth_contact.php
index 7810114aec1..6ec1927e5a8 100644
--- a/htdocs/eventorganization/conferenceorbooth_contact.php
+++ b/htdocs/eventorganization/conferenceorbooth_contact.php
@@ -194,7 +194,7 @@ if (!empty($withproject)) {
// Define a complementary filter for search of next/prev ref.
if (empty($user->rights->project->all->lire)) {
$objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
- $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
+ $projectstatic->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
}
dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
diff --git a/htdocs/eventorganization/conferenceorbooth_document.php b/htdocs/eventorganization/conferenceorbooth_document.php
index 0326449b0be..802e6be12d3 100644
--- a/htdocs/eventorganization/conferenceorbooth_document.php
+++ b/htdocs/eventorganization/conferenceorbooth_document.php
@@ -167,7 +167,7 @@ if (!empty($withproject)) {
// Define a complementary filter for search of next/prev ref.
if (empty($user->rights->project->all->lire)) {
$objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
- $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
+ $projectstatic->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
}
dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php
index 2d88979c907..8fa96f1e9c4 100644
--- a/htdocs/eventorganization/conferenceorbooth_list.php
+++ b/htdocs/eventorganization/conferenceorbooth_list.php
@@ -329,7 +329,7 @@ if ($projectid > 0) {
// Define a complementary filter for search of next/prev ref.
if (empty($user->rights->project->all->lire)) {
$objectsListId = $project->getProjectsAuthorizedForUser($user, 0, 0);
- $project->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
+ $project->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
}
dol_banner_tab($project, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
diff --git a/htdocs/eventorganization/conferenceorboothattendee_card.php b/htdocs/eventorganization/conferenceorboothattendee_card.php
index cb31eb4ac62..5084b3bf798 100644
--- a/htdocs/eventorganization/conferenceorboothattendee_card.php
+++ b/htdocs/eventorganization/conferenceorboothattendee_card.php
@@ -242,7 +242,7 @@ if (!empty($withproject)) {
// Define a complementary filter for search of next/prev ref.
if (empty($user->rights->projet->all->lire)) {
$objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
- $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
+ $projectstatic->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
}
dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
diff --git a/htdocs/eventorganization/conferenceorboothattendee_list.php b/htdocs/eventorganization/conferenceorboothattendee_list.php
index 00fbe27663f..7404550cdba 100644
--- a/htdocs/eventorganization/conferenceorboothattendee_list.php
+++ b/htdocs/eventorganization/conferenceorboothattendee_list.php
@@ -429,7 +429,7 @@ if ($projectstatic->id > 0 || $confOrBooth > 0) {
// Define a complementary filter for search of next/prev ref.
if (empty($user->rights->projet->all->lire)) {
$objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
- $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
+ $projectstatic->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
}
dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php
index 7f948153e10..cbaa6bbca12 100644
--- a/htdocs/expedition/card.php
+++ b/htdocs/expedition/card.php
@@ -334,6 +334,7 @@ if (empty($reshook)) {
$stockLine[$i][$j]['ix_l'] = GETPOST($idl, 'int');
$totalqty += price2num(GETPOST($qty, 'alpha'), 'MS');
+ $subtotalqty += price2num(GETPOST($qty, 'alpha'), 'MS');
$j++;
$stockLocation = "ent1".$i."_".$j;
@@ -343,9 +344,17 @@ if (empty($reshook)) {
//shipment line for product with no batch management and no multiple stock location
if (GETPOST($qty, 'int') > 0) {
$totalqty += price2num(GETPOST($qty, 'alpha'), 'MS');
+ $subtotalqty = price2num(GETPOST($qty, 'alpha'), 'MS');
}
}
+ // check qty shipped not greater than ordered
+ if (getDolGlobalInt("MAIN_DONT_SHIP_MORE_THAN_ORDERED") && $subtotalqty > $objectsrc->lines[$i]->qty) {
+ setEventMessages($langs->trans("ErrorTooMuchShipped", $i+1), null, 'errors');
+ $error++;
+ continue;
+ }
+
// Extrafields
$array_options[$i] = $extrafields->getOptionalsFromPost($object->table_element_line, $i);
// Unset extrafield
@@ -862,7 +871,7 @@ if (empty($reshook)) {
* View
*/
-$title = $langs->trans("Shipment");
+$title = $object->ref.' - '.$langs->trans("Shipment");
if ($action == 'create2') {
$title = $langs->trans("CreateShipment");
}
@@ -1370,7 +1379,7 @@ if ($action == 'create') {
//var_dump($dbatch);
$batchStock = + $dbatch->qty; // To get a numeric
$deliverableQty = min($quantityToBeDelivered, $batchStock);
- print '
';
+ print ' ';
print '';
print ' ';
print ' ';
@@ -1442,7 +1451,7 @@ if ($action == 'create') {
$deliverableQty = min($quantityToBeDelivered, $stock);
$deliverableQty = max(0, $deliverableQty);
// Quantity to send
- print ' ';
+ print ' ';
print '';
if ($line->product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
if (isset($alreadyQtySetted[$line->fk_product][intval($warehouse_id)])) {
@@ -1582,7 +1591,7 @@ if ($action == 'create') {
}
$alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = $deliverableQty + $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
- print ' ';
+ print ' ';
print ' ';
print ' ';
@@ -1755,9 +1764,9 @@ if ($action == 'create') {
$text = $langs->trans("ConfirmValidateSending", $numref);
if (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT')) {
- $text .= ' '.$langs->trans("StockMovementWillBeRecorded").'.';
+ $text .= ' '.img_picto('', 'movement', 'class="pictofixedwidth"').$langs->trans("StockMovementWillBeRecorded").'.';
} elseif (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT_CLOSE')) {
- $text .= ' '.$langs->trans("StockMovementNotYetRecorded").'.';
+ $text .= ' '.img_picto('', 'movement', 'class="pictofixedwidth"').$langs->trans("StockMovementNotYetRecorded").'.';
}
if (isModEnabled('notification')) {
@@ -2411,7 +2420,7 @@ if ($action == 'create') {
// Warehouse source
if (isModEnabled('stock')) {
- print '';
+ print ' ';
if ($lines[$i]->entrepot_id > 0) {
$entrepot = new Entrepot($db);
$entrepot->fetch($lines[$i]->entrepot_id);
@@ -2532,6 +2541,10 @@ if ($action == 'create') {
// TODO Show also lines ordered but not delivered
+ if (empty($num_prod)) {
+ print ' '.$langs->trans("NoLineGoOnTabToAddSome", $langs->transnoentitiesnoconv("ShipmentDistribution")).' ';
+ }
+
print "
\n";
print '';
print '
';
@@ -2564,7 +2577,6 @@ if ($action == 'create') {
}
// 0=draft, 1=validated/delivered, 2=closed/delivered
- // If WORKFLOW_BILL_ON_SHIPMENT: 0=draft, 1=validated, 2=billed (no status delivered)
if ($object->statut == Expedition::STATUS_VALIDATED && !getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT')) {
if ($user->hasRight('expedition', 'creer')) {
print dolGetButtonAction('', $langs->trans('SetToDraft'), 'default', $_SERVER["PHP_SELF"].'?action=setdraft&token='.newToken().'&id='.$object->id, '');
@@ -2572,11 +2584,7 @@ if ($action == 'create') {
}
if ($object->statut == Expedition::STATUS_CLOSED) {
if ($user->hasRight('expedition', 'creer')) {
- if (isModEnabled('facture') && !empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ?
- print dolGetButtonAction('', $langs->trans('ClassifyUnbilled'), 'default', $_SERVER["PHP_SELF"].'?action=reopen&token='.newToken().'&id='.$object->id, '');
- } else {
- print dolGetButtonAction('', $langs->trans('ReOpen'), 'default', $_SERVER["PHP_SELF"].'?action=reopen&token='.newToken().'&id='.$object->id, '');
- }
+ print dolGetButtonAction('', $langs->trans('ReOpen'), 'default', $_SERVER["PHP_SELF"].'?action=reopen&token='.newToken().'&id='.$object->id, '');
}
}
@@ -2594,9 +2602,9 @@ if ($action == 'create') {
// Create bill
if (isModEnabled('facture') && ($object->statut == Expedition::STATUS_VALIDATED || $object->statut == Expedition::STATUS_CLOSED)) {
if ($user->hasRight('facture', 'creer')) {
- // TODO show button only if (!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))
- // If we do that, we must also make this option official.
- print dolGetButtonAction('', $langs->trans('CreateBill'), 'default', DOL_URL_ROOT.'/compta/facture/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, '');
+ if (getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT') !== '0') {
+ print dolGetButtonAction('', $langs->trans('CreateBill'), 'default', DOL_URL_ROOT.'/compta/facture/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, '');
+ }
}
}
@@ -2605,28 +2613,26 @@ if ($action == 'create') {
if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY') && ($object->statut == Expedition::STATUS_VALIDATED || $object->statut == Expedition::STATUS_CLOSED) && $user->rights->expedition->delivery->creer && empty($object->linkedObjectsIds['delivery'])) {
print dolGetButtonAction('', $langs->trans('CreateDeliveryOrder'), 'default', $_SERVER["PHP_SELF"].'?action=create_delivery&token='.newToken().'&id='.$object->id, '');
}
- // Close
+
+ // Set Billed and Closed
if ($object->statut == Expedition::STATUS_VALIDATED) {
- if ($user->rights->expedition->creer && $object->statut > 0 && !$object->billed) {
- $label = "Close"; $paramaction = 'classifyclosed'; // = Transferred/Received
- // Label here should be "Close" or "ClassifyBilled" if we decided to make bill on shipments instead of orders
- if (isModEnabled('facture') && !empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ?
- $label = "ClassifyBilled";
- $paramaction = 'classifybilled';
+ if ($user->hasRight('expedition', 'creer') && $object->statut > 0) {
+ if (!$object->billed && getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT') !== '0') {
+ print dolGetButtonAction('', $langs->trans('ClassifyBilled'), 'default', $_SERVER["PHP_SELF"].'?action=classifybilled&token='.newToken().'&id='.$object->id, '');
}
- print dolGetButtonAction('', $langs->trans($label), 'default', $_SERVER["PHP_SELF"].'?action='. $paramaction .'&token='.newToken().'&id='.$object->id, '');
+ print dolGetButtonAction('', $langs->trans("Close"), 'default', $_SERVER["PHP_SELF"].'?action='. $paramaction .'&token='.newToken().'&id='.$object->id, '');
}
}
// Cancel
if ($object->statut == Expedition::STATUS_VALIDATED) {
- if ($user->rights->expedition->supprimer) {
+ if ($user->hasRight('expedition', 'creer')) {
print dolGetButtonAction('', $langs->trans('Cancel'), 'danger', $_SERVER["PHP_SELF"].'?action=cancel&token='.newToken().'&id='.$object->id.'&mode=init#formmailbeforetitle', '');
}
}
// Delete
- if ($user->rights->expedition->supprimer) {
+ if ($user->hasRight('expedition', 'supprimer')) {
print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id, '');
}
}
diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php
index 0392bc8c4eb..412f192ac54 100644
--- a/htdocs/expedition/class/expedition.class.php
+++ b/htdocs/expedition/class/expedition.class.php
@@ -79,6 +79,11 @@ class Expedition extends CommonObject
*/
public $ismultientitymanaged = 1;
+ /**
+ * @var int Does object support extrafields ? 0=No, 1=Yes
+ */
+ public $isextrafieldmanaged = 1;
+
/**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
*/
@@ -674,7 +679,7 @@ class Expedition extends CommonObject
return 1;
} else {
dol_syslog(get_class($this).'::Fetch no expedition found', LOG_ERR);
- $this->error = 'Delivery with id '.$id.' not found';
+ $this->error = 'Shipment with id '.$id.' not found';
return 0;
}
} else {
@@ -692,14 +697,14 @@ class Expedition extends CommonObject
*/
public function valid($user, $notrigger = 0)
{
- global $conf, $langs;
+ global $conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_syslog(get_class($this)."::valid");
// Protection
- if ($this->statut) {
+ if ($this->status) {
dol_syslog(get_class($this)."::valid not in draft status", LOG_WARNING);
return 0;
}
@@ -720,7 +725,7 @@ class Expedition extends CommonObject
$soc->fetch($this->socid);
// Class of company linked to order
- $result = $soc->set_as_client();
+ $result = $soc->setAsCustomer();
// Define new ref
if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
@@ -749,7 +754,7 @@ class Expedition extends CommonObject
// If stock increment is done on sending (recommanded choice)
if (!$error && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) {
- $result = $this->manageStockMvtOnEvt($user);
+ $result = $this->manageStockMvtOnEvt($user, "ShipmentValidatedInDolibarr");
if ($result < 0) {
return -2;
}
@@ -1083,14 +1088,11 @@ class Expedition extends CommonObject
$this->model_pdf = trim($this->model_pdf);
}
-
-
// Check parameters
// Put here code to add control on parameters values
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET";
-
$sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").",";
$sql .= " ref_ext=".(isset($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null").",";
$sql .= " ref_customer=".(isset($this->ref_customer) ? "'".$this->db->escape($this->ref_customer)."'" : "null").",";
@@ -1116,7 +1118,6 @@ class Expedition extends CommonObject
$sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").",";
$sql .= " model_pdf=".(isset($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null").",";
$sql .= " entity=".$conf->entity;
-
$sql .= " WHERE rowid=".((int) $this->id);
$this->db->begin();
@@ -1588,11 +1589,12 @@ class Expedition extends CommonObject
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
+
if ($originline > 0 && $originline == $obj->fk_origin_line) {
$line->entrepot_id = 0; // entrepod_id in details_entrepot
$line->qty_shipped += $obj->qty_shipped;
} else {
- $line = new ExpeditionLigne($this->db);
+ $line = new ExpeditionLigne($this->db); // new group to start
$line->entrepot_id = $obj->fk_entrepot; // this is a property of a shipment line
$line->qty_shipped = $obj->qty_shipped; // this is a property of a shipment line
}
@@ -1826,7 +1828,7 @@ class Expedition extends CommonObject
if ($option !== 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
@@ -1850,7 +1852,7 @@ class Expedition extends CommonObject
$result .= $linkstart;
if ($withpicto) {
- $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
+ $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1);
}
if ($withpicto != 2) {
$result .= $this->ref;
@@ -2103,13 +2105,13 @@ class Expedition extends CommonObject
}
/**
- * Classify the shipping as closed.
+ * Classify the shipping as closed (this record also the stock movement)
*
* @return int <0 if KO, >0 if OK
*/
public function setClosed()
{
- global $conf, $langs, $user;
+ global $conf, $user;
$error = 0;
@@ -2187,12 +2189,14 @@ class Expedition extends CommonObject
/**
* Manage Stock MVt onb Close or valid Shipment
- * @param User $user Object user that modify
- * @return int <0 if ko, >0 if ok
+ *
+ * @param User $user Object user that modify
+ * @param string $labelmovement Label of movement
+ * @return int <0 if KO, >0 if OK
* @throws Exception
*
*/
- private function manageStockMvtOnEvt($user)
+ private function manageStockMvtOnEvt($user, $labelmovement = 'ShipmentClassifyClosedInDolibarr')
{
global $langs;
@@ -2239,7 +2243,7 @@ class Expedition extends CommonObject
// line without batch detail
// We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record
- $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr", $obj->ref));
+ $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans($labelmovement, $obj->ref));
if ($result < 0) {
$this->error = $mouvS->error;
$this->errors = $mouvS->errors;
@@ -2250,7 +2254,7 @@ class Expedition extends CommonObject
// line with batch detail
// We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record
- $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr", $obj->ref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock);
+ $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans($labelmovement, $obj->ref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock);
if ($result < 0) {
$this->error = $mouvS->error;
$this->errors = $mouvS->errors;
@@ -2275,7 +2279,7 @@ class Expedition extends CommonObject
}
/**
- * Classify the shipping as invoiced (used when WORKFLOW_BILL_ON_SHIPMENT is on)
+ * Classify the shipping as invoiced (used for exemple by trigger when WORKFLOW_SHIPPING_CLASSIFY_BILLED_INVOICE is on)
*
* @return int <0 if ko, >0 if ok
*/
@@ -2286,17 +2290,17 @@ class Expedition extends CommonObject
$this->db->begin();
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2, billed=1'; // TODO Update only billed
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET billed = 1';
$sql .= " WHERE rowid = ".((int) $this->id).' AND fk_statut > 0';
$resql = $this->db->query($sql);
if ($resql) {
- $this->statut = self::STATUS_CLOSED;
$this->billed = 1;
// Call trigger
$result = $this->call_trigger('SHIPPING_BILLED', $user);
if ($result < 0) {
+ $this->billed = 0;
$error++;
}
} else {
@@ -2308,8 +2312,6 @@ class Expedition extends CommonObject
$this->db->commit();
return 1;
} else {
- $this->statut = self::STATUS_VALIDATED;
- $this->billed = 0;
$this->db->rollback();
return -1;
}
@@ -2826,8 +2828,6 @@ class ExpeditionLigne extends CommonObjectLine
*/
public function delete($user = null, $notrigger = 0)
{
- global $conf;
-
$error = 0;
$this->db->begin();
@@ -2891,8 +2891,6 @@ class ExpeditionLigne extends CommonObjectLine
*/
public function update($user = null, $notrigger = 0)
{
- global $conf;
-
$error = 0;
dol_syslog(get_class($this)."::update id=$this->id, entrepot_id=$this->entrepot_id, product_id=$this->fk_product, qty=$this->qty");
diff --git a/htdocs/expedition/class/expeditionlinebatch.class.php b/htdocs/expedition/class/expeditionlinebatch.class.php
index b010564768f..fbf6564616f 100644
--- a/htdocs/expedition/class/expeditionlinebatch.class.php
+++ b/htdocs/expedition/class/expeditionlinebatch.class.php
@@ -44,7 +44,8 @@ class ExpeditionLineBatch extends CommonObject
public $qty;
public $dluo_qty; // deprecated, use qty
public $entrepot_id;
- public $fk_origin_stock; // rowid in llx_product_batch table
+ public $fk_origin_stock; // rowid in llx_product_batch table (not usefull)
+ public $fk_warehouse; // warehouse ID
public $fk_expeditiondet;
@@ -62,7 +63,7 @@ class ExpeditionLineBatch extends CommonObject
* Fill object based on a product-warehouse-batch's record
*
* @param int $id_stockdluo Rowid in product_batch table
- * @return int -1 if KO, 1 if OK
+ * @return int -1 if KO, 1 if OK
*/
public function fetchFromStock($id_stockdluo)
{
@@ -71,7 +72,6 @@ class ExpeditionLineBatch extends CommonObject
$sql .= " pl.sellby,";
$sql .= " pl.eatby,";
$sql .= " ps.fk_entrepot";
-
$sql .= " FROM ".MAIN_DB_PREFIX."product_batch as pb";
$sql .= " JOIN ".MAIN_DB_PREFIX."product_stock as ps on pb.fk_product_stock=ps.rowid";
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."product_lot as pl on pl.batch = pb.batch AND pl.fk_product = ps.fk_product";
@@ -123,13 +123,15 @@ class ExpeditionLineBatch extends CommonObject
$sql .= ", batch";
$sql .= ", qty";
$sql .= ", fk_origin_stock";
+ $sql .= ", fk_warehouse";
$sql .= ") VALUES (";
- $sql .= $id_line_expdet.",";
- $sql .= " ".(!isset($this->sellby) || dol_strlen($this->sellby) == 0 ? 'NULL' : ("'".$this->db->idate($this->sellby))."'").",";
- $sql .= " ".(!isset($this->eatby) || dol_strlen($this->eatby) == 0 ? 'NULL' : ("'".$this->db->idate($this->eatby))."'").",";
- $sql .= " ".(!isset($this->batch) ? 'NULL' : ("'".$this->db->escape($this->batch)."'")).",";
- $sql .= " ".(!isset($this->qty) ? ((!isset($this->dluo_qty)) ? 'NULL' : $this->dluo_qty) : $this->qty).","; // dluo_qty deprecated, use qty
- $sql .= " ".(!isset($this->fk_origin_stock) ? 'NULL' : $this->fk_origin_stock);
+ $sql .= $id_line_expdet;
+ $sql .= ", ".(!isset($this->sellby) || dol_strlen($this->sellby) == 0 ? 'NULL' : ("'".$this->db->idate($this->sellby))."'");
+ $sql .= ", ".(!isset($this->eatby) || dol_strlen($this->eatby) == 0 ? 'NULL' : ("'".$this->db->idate($this->eatby))."'");
+ $sql .= ", ".(!isset($this->batch) ? 'NULL' : ("'".$this->db->escape($this->batch)."'"));
+ $sql .= ", ".(!isset($this->qty) ? ((!isset($this->dluo_qty)) ? 'NULL' : $this->dluo_qty) : $this->qty); // dluo_qty deprecated, use qty
+ $sql .= ", ".(!isset($this->fk_origin_stock) ? 'NULL' : $this->fk_origin_stock);
+ $sql .= ", ".(!isset($this->fk_warehouse) ? 'NULL' : $this->fk_warehouse);
$sql .= ")";
dol_syslog(__METHOD__, LOG_DEBUG);
@@ -199,7 +201,8 @@ class ExpeditionLineBatch extends CommonObject
$sql .= " eb.eatby as oldeatby,"; // deprecated
$sql .= " eb.batch,";
$sql .= " eb.qty,";
- $sql .= " eb.fk_origin_stock";
+ $sql .= " eb.fk_origin_stock,";
+ $sql .= " eb.fk_warehouse";
if ($fk_product > 0) {
$sql .= ", pl.sellby";
$sql .= ", pl.eatby";
@@ -226,6 +229,7 @@ class ExpeditionLineBatch extends CommonObject
$tmp->id = $obj->rowid;
$tmp->fk_origin_stock = $obj->fk_origin_stock;
$tmp->fk_expeditiondet = $obj->fk_expeditiondet;
+ $tmp->fk_warehouse = $obj->fk_warehouse;
$tmp->dluo_qty = $obj->qty; // dluo_qty deprecated, use qty
$tmp->qty = $obj->qty;
diff --git a/htdocs/expedition/dispatch.php b/htdocs/expedition/dispatch.php
index 5707b3474ef..cf7c5023bea 100644
--- a/htdocs/expedition/dispatch.php
+++ b/htdocs/expedition/dispatch.php
@@ -25,9 +25,9 @@
*/
/**
- * \file htdocs/expedition/dispatch.php
+ * \file htdocs/expedition/dispatch.php
* \ingroup expedition
- * \brief Page to dispatch shipments
+ * \brief Page to dispatch shipments
*/
// Load Dolibarr environment
@@ -40,15 +40,12 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.dispatch.class
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php';
-
-
-
if (isModEnabled('project')) {
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
}
// Load translation files required by the page
-$langs->loadLangs(array("sendings", "companies", "bills", 'deliveries', 'orders', 'stocks', 'other', 'propal'));
+$langs->loadLangs(array("sendings", "companies", "bills", 'deliveries', 'orders', 'stocks', 'other', 'propal', 'receptions'));
if (isModEnabled('productbatch')) {
$langs->load('productbatch');
@@ -63,6 +60,9 @@ $fk_default_warehouse = GETPOST('fk_default_warehouse', 'int');
$cancel = GETPOST('cancel', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
+$error = 0;
+$errors = array();
+
if ($user->socid) {
$socid = $user->socid;
}
@@ -78,9 +78,10 @@ if (GETPOSTISSET("projectid")) {
$object = new Expedition($db);
$objectorder = new Commande($db);
+
if ($id > 0 || !empty($ref)) {
$result = $object->fetch($id, $ref);
- if ($result < 0) {
+ if ($result <= 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
$result = $object->fetch_thirdparty();
@@ -99,12 +100,13 @@ if ($id > 0 || !empty($ref)) {
$result = restrictedArea($user, 'expedition', $object, '');
if (!isModEnabled('stock')) {
- accessforbidden();
+ accessforbidden('Module stock disabled');
}
$usercancreate = $user->hasRight('expedition', 'creer');
$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php
+
/*
* Actions
*/
@@ -150,46 +152,53 @@ if ($action == 'updatelines' && $usercancreate) {
$lot = '';
$dDLUO = '';
$dDLC = '';
- if ($modebatch == "batch") { //TODO: Make impossible to input non existing batchcode
+ if ($modebatch == "batch") { //TODO: Make impossible to input non existing batch code
$lot = GETPOST('lot_number_'.$reg[1].'_'.$reg[2]);
$dDLUO = dol_mktime(12, 0, 0, GETPOST('dluo_'.$reg[1].'_'.$reg[2].'month', 'int'), GETPOST('dluo_'.$reg[1].'_'.$reg[2].'day', 'int'), GETPOST('dluo_'.$reg[1].'_'.$reg[2].'year', 'int'));
$dDLC = dol_mktime(12, 0, 0, GETPOST('dlc_'.$reg[1].'_'.$reg[2].'month', 'int'), GETPOST('dlc_'.$reg[1].'_'.$reg[2].'day', 'int'), GETPOST('dlc_'.$reg[1].'_'.$reg[2].'year', 'int'));
}
+ $newqty = price2num(GETPOST($qty, 'alpha'), 'MS');
+
// We ask to move a qty
- if (($modebatch == "batch" && GETPOST($qty) > 0) || ($modebatch == "barcode" && GETPOST($qty) != 0)) {
- if (!(GETPOST($ent, 'int') > 0)) {
- dol_syslog('No dispatch for line '.$key.' as no warehouse was chosen.');
- $text = $langs->transnoentities('Warehouse').', '.$langs->transnoentities('Line').' '.($numline);
- setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors');
- $error++;
- }
- if ($modebatch == "batch") {
- $sql = "SELECT pb.rowid ";
- $sql .= " FROM ".MAIN_DB_PREFIX."product_batch as pb";
- $sql .= " JOIN ".MAIN_DB_PREFIX."product_stock as ps";
- $sql .= " ON ps.rowid = pb.fk_product_stock";
- $sql .= " WHERE pb.batch ='".$db->escape($lot)."'";
- $sql .= " AND ps.fk_product =".((int) GETPOST($prod, 'int')) ;
- $sql .= " AND ps.fk_entrepot =".((int) GETPOST($ent, 'int')) ;
- $resql = $db->query($sql);
- if ($resql) {
- $num = $db->num_rows($resql);
- if ($num > 1) {
- dol_syslog('No dispatch for line '.$key.' as too many combination warehouse, product, batch code was found ('.$num.').');
- setEventMessages($langs->trans('ErrorTooManyCombinationBatchcode', $numline, $num), null, 'errors');
- $error++;
- } elseif ($num < 1) {
- dol_syslog('No dispatch for line '.$key.' as no combination warehouse, product, batch code was found.');
- setEventMessages($langs->trans('ErrorNoCombinationBatchcode', $numline), null, 'errors');
- $error++;
+ if (($modebatch == "batch" && $newqty >= 0) || ($modebatch == "barcode" && $newqty != 0)) {
+ if ($newqty > 0) { // If we want a qty, we make test on input data
+ if (!(GETPOST($ent, 'int') > 0)) {
+ dol_syslog('No dispatch for line '.$key.' as no warehouse was chosen.');
+ $text = $langs->transnoentities('Warehouse').', '.$langs->transnoentities('Line').' '.($numline);
+ setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors');
+ $error++;
+ }
+ if (!$error && $modebatch == "batch") {
+ $sql = "SELECT pb.rowid ";
+ $sql .= " FROM ".MAIN_DB_PREFIX."product_batch as pb";
+ $sql .= " JOIN ".MAIN_DB_PREFIX."product_stock as ps";
+ $sql .= " ON ps.rowid = pb.fk_product_stock";
+ $sql .= " WHERE pb.batch = '".$db->escape($lot)."'";
+ $sql .= " AND ps.fk_product = ".((int) GETPOST($prod, 'int')) ;
+ $sql .= " AND ps.fk_entrepot = ".((int) GETPOST($ent, 'int')) ;
+
+ $resql = $db->query($sql);
+ if ($resql) {
+ $num = $db->num_rows($resql);
+ if ($num > 1) {
+ dol_syslog('No dispatch for line '.$key.' as too many combination warehouse, product, batch code was found ('.$num.').');
+ setEventMessages($langs->trans('ErrorTooManyCombinationBatchcode', $numline, $num), null, 'errors');
+ $error++;
+ } elseif ($num < 1) {
+ dol_syslog('No dispatch for line '.$key.' as no combination warehouse, product, batch code was found.');
+ setEventMessages($langs->trans('ErrorNoCombinationBatchcode', $numline), null, 'errors');
+ $error++;
+ }
+ $db->free($resql);
}
- $db->free($resql);
}
}
+ //var_dump($key.' '.$newqty.' '.$idline.' '.$error);
if (!$error) {
$qtystart = 0;
+
if ($idline > 0) {
$result = $expeditiondispatch->fetch($idline);
if ($result < 0) {
@@ -197,22 +206,38 @@ if ($action == 'updatelines' && $usercancreate) {
$error++;
} else {
$qtystart = $expeditiondispatch->qty;
- $expeditiondispatch->qty = GETPOST($qty);
+ $expeditiondispatch->qty = $newqty;
$expeditiondispatch->entrepot_id = GETPOST($ent, 'int');
- $result = $expeditiondispatch->update($user);
+ if ($newqty > 0) {
+ $result = $expeditiondispatch->update($user);
+ } else {
+ $result = $expeditiondispatch->delete($user);
+ }
if ($result < 0) {
setEventMessages($expeditiondispatch->error, $expeditiondispatch->errors, 'errors');
$error++;
}
if (!$error && $modebatch == "batch") {
- $sql = "UPDATE ".MAIN_DB_PREFIX.$expeditionlinebatch->table_element." SET";
- $sql .= " eatby = ".($eatby ? "'".$db->idate($eatby)."'" : "null");
- $sql .= " , sellby = ".($sellby ? "'".$db->idate($sellby)."'" : "null");
- $sql .= " , qty = ".((float) price2num(GETPOST($qty, 'int'), 'MS'));
- $sql .= " WHERE fk_expeditiondet = ".((int) $idline);
- $sql .= " AND batch = ".((int) $idline);
+ if ($newqty > 0) {
+ $suffixkeyfordate = preg_replace('/^product_batch/', '', $key);
+ $sellby = dol_mktime(0, 0, 0, GETPOST('dlc'.$suffixkeyfordate.'month'), GETPOST('dlc'.$suffixkeyfordate.'day'), GETPOST('dlc'.$suffixkeyfordate.'year'), '');
+ $eatby = dol_mktime(0, 0, 0, GETPOST('dluo'.$suffixkeyfordate.'month'), GETPOST('dluo'.$suffixkeyfordate.'day'), GETPOST('dluo'.$suffixkeyfordate.'year'));
+
+ $sql = "UPDATE ".MAIN_DB_PREFIX.$expeditionlinebatch->table_element." SET";
+ $sql .= " eatby = ".($eatby ? "'".$db->idate($eatby)."'" : "null");
+ $sql .= " , sellby = ".($sellby ? "'".$db->idate($sellby)."'" : "null");
+ $sql .= " , qty = ".((float) $newqty);
+ // TODO Add a column fk_warehouse
+ $sql .= " WHERE fk_expeditiondet = ".((int) $idline);
+ $sql .= " AND batch = '".$db->escape($lot)."'";
+ } else {
+ $sql = " DELETE FROM ".MAIN_DB_PREFIX.$expeditionlinebatch->table_element;
+ $sql .= " WHERE fk_expeditiondet = ".((int) $idline);
+ $sql .= " AND batch = '".$db->escape($lot)."'";
+ }
+
$resql = $db->query($sql);
if (!$db->query($sql)) {
dol_print_error($db);
@@ -224,34 +249,40 @@ if ($action == 'updatelines' && $usercancreate) {
$expeditiondispatch->fk_expedition = $object->id;
$expeditiondispatch->entrepot_id = GETPOST($ent, 'int');
$expeditiondispatch->fk_origin_line = GETPOST($fk_commandedet, 'int');
- $expeditiondispatch->qty = GETPOST($qty, 'int');
- $idline = $expeditiondispatch->insert($user);
- if ($idline < 0) {
- setEventMessages($expeditiondispatch->error, $expeditiondispatch->errors, 'errors');
- $error++;
- }
+ $expeditiondispatch->qty = $newqty;
- if ($modebatch == "batch" && !$error) {
- $expeditionlinebatch->sellby = $dDLUO;
- $expeditionlinebatch->eatby = $dDLC;
- $expeditionlinebatch->batch = $lot;
- $expeditionlinebatch->qty = GETPOST($qty, 'int');
- $expeditionlinebatch->fk_origin_stock = 0;
- $result = $expeditionlinebatch->create($idline);
- if ($result < 0) {
- setEventMessages($expeditionlinebatch->error, $expeditionlinebatch->errors, 'errors');
+ if ($newqty > 0) {
+ $idline = $expeditiondispatch->insert($user);
+ if ($idline < 0) {
+ setEventMessages($expeditiondispatch->error, $expeditiondispatch->errors, 'errors');
$error++;
}
+
+ if ($modebatch == "batch" && !$error) {
+ $expeditionlinebatch->sellby = $dDLUO;
+ $expeditionlinebatch->eatby = $dDLC;
+ $expeditionlinebatch->batch = $lot;
+ $expeditionlinebatch->qty = $newqty;
+ $expeditionlinebatch->fk_origin_stock = 0;
+ $expeditionlinebatch->fk_warehouse = GETPOST($ent, 'int');
+
+ $result = $expeditionlinebatch->create($idline);
+ if ($result < 0) {
+ setEventMessages($expeditionlinebatch->error, $expeditionlinebatch->errors, 'errors');
+ $error++;
+ }
+ }
}
}
- // If module stock is enabled and the stock increase is done on purchase order dispatching
- if (!$error && GETPOST($ent, 'int') > 0 && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) {
+ // If module stock is enabled and the stock decrease is done on edtion of this page
+ /*
+ if (!$error && GETPOST($ent, 'int') > 0 && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_DISPATCH_ORDER)) {
$mouv = new MouvementStock($db);
$product = GETPOST($prod, 'int');
$entrepot = GETPOST($ent, 'int');
- $qtymouv = GETPOST($qty) - $qtystart;
- $price = GETPOST($pu);
+ $qtymouv = price2num(GETPOST($qty, 'alpha'), 'MS') - $qtystart;
+ $price = price2num(GETPOST($pu), 'MU');
$comment = GETPOST('comment');
$inventorycode = dol_print_date(dol_now(), 'dayhourlog');
$now = dol_now();
@@ -281,6 +312,7 @@ if ($action == 'updatelines' && $usercancreate) {
}
}
}
+ */
}
}
}
@@ -291,6 +323,9 @@ if ($action == 'updatelines' && $usercancreate) {
} else {
$db->commit();
setEventMessages($langs->trans("ReceptionUpdated"), null);
+
+ header("Location: ".DOL_URL_ROOT.'/expedition/dispatch.php?id='.$object->id);
+ exit;
}
} elseif ($action == 'setdate_livraison' && $usercancreate) {
$datedelivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int'));
@@ -319,8 +354,9 @@ $morejs = array('/expedition/js/lib_dispatch.js.php');
llxHeader('', $title, $help_url, '', 0, 0, $morejs);
-if ($id > 0 || !empty($ref)) {
- $lines = $object->lines;
+if ($object->id > 0 || !empty($object->ref)) {
+ $lines = $object->lines; // This is an array of detail of line, on line per source order line found intolines[]->fk_origin_line, then each line may have sub data
+ //var_dump($lines[0]->fk_origin_line); exit;
$num_prod = count($lines);
@@ -467,7 +503,7 @@ if ($id > 0 || !empty($ref)) {
print '
';
$disabled = 0; // This is used to disable or not the bulk selection of target warehouse. No reason to have it disabled so forced to 0.
- if ($object->statut == Reception::STATUS_DRAFT) {
+ if ($object->statut == Expedition::STATUS_DRAFT) {
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$formproduct = new FormProduct($db);
$formproduct->loadWarehouses();
@@ -484,7 +520,7 @@ if ($id > 0 || !empty($ref)) {
print '
';
print '
';
- // Get list of lines from the shipments $products_dispatched with qty dispatched for each product id
+ // Get list of lines of the shipment $products_dispatched, with qty dispatched for each product id
$products_dispatched = array();
$sql = "SELECT ed.fk_origin_line as rowid, sum(ed.qty) as qty";
$sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed";
@@ -505,6 +541,7 @@ if ($id > 0 || !empty($ref)) {
}
$db->free($resql);
}
+
//$sql = "SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref AS sref, SUM(l.qty) as qty,";
$sql = "SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, '' AS sref, l.qty as qty,";
$sql .= " p.ref, p.label, p.tobatch, p.fk_default_warehouse";
@@ -567,8 +604,12 @@ if ($id > 0 || !empty($ref)) {
print ' ';
}
print ''.$langs->trans("QtyOrdered").' ';
- print ''.$langs->trans("QtyDispatchedShort").' ';
- print ' '.$langs->trans("QtyToDispatchShort");
+ if ($object->status == Expedition::STATUS_DRAFT) {
+ print ' '.$langs->trans("QtyToDispatchShort"); // Qty to dispatch (sum for all lines of batch detail if there is)
+ } else {
+ print ' '.$langs->trans("QtyDispatchedShort").' ';
+ }
+ print ''.$langs->trans("QtyToDispatchShort");
print ' ';
if (!empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
@@ -612,6 +653,7 @@ if ($id > 0 || !empty($ref)) {
$conf->cache['product'] = array();
+ // Loop on each line of origin order
while ($i < $num) {
$objp = $db->fetch_object($resql);
@@ -703,10 +745,6 @@ if ($id > 0 || !empty($ref)) {
print ''; // Dispatch column
print ' '; // Warehouse column
- /*$sql = "SELECT cfd.rowid, cfd.qty, cfd.fk_entrepot, cfd.batch, cfd.eatby, cfd.sellby, cfd.fk_product";
- $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd";
- $sql .= " WHERE cfd.fk_commandefourndet = ".(int) $objp->rowid;*/
-
$sql = "SELECT ed.rowid, ed.qty, ed.fk_entrepot, eb.batch, eb.eatby, eb.sellby, cd.fk_product FROM ".MAIN_DB_PREFIX."expeditiondet as ed";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet_batch as eb on ed.rowid = eb.fk_expeditiondet";
$sql .= " JOIN ".MAIN_DB_PREFIX."commandedet as cd on ed.fk_origin_line = cd.rowid";
@@ -760,8 +798,8 @@ if ($id > 0 || !empty($ref)) {
print '';
print '';
- print ' ';
- //print ' ';
+ print ' ';
+ //print ' ';
print ' ';
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
print '';
@@ -814,9 +852,11 @@ if ($id > 0 || !empty($ref)) {
print ' ';
}
// Qty to dispatch
- print '';
- print ''.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').' ';
- print ' ';
+ print ' ';
+ print ''.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').' ';
+ $suggestedvalue = (GETPOSTISSET('qty'.$suffix) ? GETPOST('qty'.$suffix, 'int') : $objd->qty);
+ //var_dump($suggestedvalue);exit;
+ print ' ';
print ' ';
print '';
if (isModEnabled('productbatch') && $objp->tobatch > 0) {
@@ -959,8 +999,14 @@ if ($id > 0 || !empty($ref)) {
}
// Qty to dispatch
print ' ';
- print ''.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').' ';
- print ' ';
+ print ''.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').' ';
+ $amounttosuggest = (GETPOSTISSET('qty'.$suffix) ? GETPOST('qty'.$suffix, 'int') : (empty($conf->global->SUPPLIER_ORDER_DISPATCH_FORCE_QTY_INPUT_TO_ZERO) ? $remaintodispatch : 0));
+ if (count($products_dispatched)) {
+ // There is already existing lines into llx_expeditiondet, this means a plan for the shipment has already been started.
+ // In such a case, we do not suggest new values, we suggest the value known.
+ $amounttosuggest = (GETPOSTISSET('qty'.$suffix) ? GETPOST('qty'.$suffix, 'int') : (isset($products_dispatched[$objp->rowid]) ? $products_dispatched[$objp->rowid] : ''));
+ }
+ print ' ';
print ' ';
print '';
if (isModEnabled('productbatch') && $objp->tobatch > 0) {
@@ -1017,14 +1063,14 @@ if ($id > 0 || !empty($ref)) {
print '';
if ($nbproduct) {
- $checkboxlabel = $langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv('StatusOrderReceivedAll'));
+ //$checkboxlabel = $langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv('StatusOrderReceivedAll'));
print '';
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
// modified by hook
if (empty($reshook)) {
- if (empty($conf->reception->enabled)) {
+ /*if (empty($conf->reception->enabled)) {
print $langs->trans("Comment").' : ';
print '
trans("DispatchSupplierOrder", $object->ref);
@@ -1037,6 +1083,8 @@ if ($id > 0 || !empty($ref)) {
$dispatchBt = empty($conf->reception->enabled) ? $langs->trans("Receive") : $langs->trans("CreateReception");
print '
';
+ */
+
print '
0 || !empty($ref)) {
print '';
+
/*print '
';
print '
';
print '
';
@@ -4652,7 +4815,6 @@ if ($module == 'initmodule') {
print '
';
print '
';
*/
- print '';
} elseif ($tabdic == 'deletedictionary') {
// Delete dic tab
print '
';
@@ -4666,8 +4828,6 @@ if ($module == 'initmodule') {
print ' ';
print ' ';
print ' ';
- } else {
- print $langs->trans("FeatureNotYetAvailable");
}
print dol_get_fiche_end();
@@ -5030,14 +5190,14 @@ if ($module == 'initmodule') {
var groupedRights = ' . $groupedRights_json . ';
var objectsSelect = $("select[id=\'objects\']");
var permsSelect = $("select[id=\'perms\']");
-
+
objectsSelect.change(function() {
var selectedObject = $(this).val();
-
+
permsSelect.empty();
-
+
var rights = groupedRights[selectedObject];
-
+
if (rights) {
for (var i = 0; i < rights.length; i++) {
var right = rights[i];
@@ -5048,7 +5208,7 @@ if ($module == 'initmodule') {
var option = $("
").attr("value", "read").text("read");
permsSelect.append(option);
}
-
+
if (selectedObject !== "" && selectedObject !== null && rights) {
permsSelect.show();
} else {
@@ -5059,7 +5219,7 @@ if ($module == 'initmodule') {
}
});
});
- ';
+ ';
// display permissions for each object
} else {
diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php
index d4023d4840d..b27f77d2ef9 100644
--- a/htdocs/modulebuilder/template/admin/setup.php
+++ b/htdocs/modulebuilder/template/admin/setup.php
@@ -257,7 +257,7 @@ if ($action == 'updateMask') {
if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) {
// The constant that was read before the new set
// We therefore requires a variable to have a coherent view
- $conf->global->$constforval = $value;
+ $conf->global->{$constforval} = $value;
}
// We disable/enable the document template (into llx_document_model table)
diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php
index 06efac605d5..034cd1614ae 100644
--- a/htdocs/modulebuilder/template/class/myobject.class.php
+++ b/htdocs/modulebuilder/template/class/myobject.class.php
@@ -85,7 +85,7 @@ class MyObject extends CommonObject
* Note: Filter must be a Dolibarr Universal Filter syntax string. Example: "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.status:!=:0) or (t.nature:is:NULL)"
* 'label' the translation key.
* 'picto' is code of a picto to show before value in forms
- * 'enabled' is a condition when the field must be managed (Example: 1 or 'getDolGlobalInt('MY_SETUP_PARAM') or 'isModEnabled("multicurrency")' ...)
+ * 'enabled' is a condition when the field must be managed (Example: 1 or 'getDolGlobalInt("MY_SETUP_PARAM")' or 'isModEnabled("multicurrency")' ...)
* 'position' is the sort order of field.
* 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
* 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
@@ -470,7 +470,7 @@ class MyObject extends CommonObject
} elseif (strpos($value, '%') === false) {
$sqlwhere[] = $key." IN (".$this->db->sanitize($this->db->escape($value)).")";
} else {
- $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'";
+ $sqlwhere[] = $key." LIKE '%".$this->db->escapeforlike($this->db->escape($value))."%'";
}
}
}
@@ -575,7 +575,7 @@ class MyObject extends CommonObject
return 0;
}
- /*if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->mymodule->myobject->write))
+ /* if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','write'))
|| (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->mymodule->myobject->myobject_advance->validate))))
{
$this->error='NotEnoughPermissions';
@@ -693,8 +693,8 @@ class MyObject extends CommonObject
return 0;
}
- /*if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->mymodule->write))
- || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->mymodule->mymodule_advance->validate))))
+ /* if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','write'))
+ || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','mymodule_advance','validate'))))
{
$this->error='Permission denied';
return -1;
@@ -717,8 +717,8 @@ class MyObject extends CommonObject
return 0;
}
- /*if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->mymodule->write))
- || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->mymodule->mymodule_advance->validate))))
+ /* if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','write'))
+ || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','mymodule_advance','validate'))))
{
$this->error='Permission denied';
return -1;
@@ -741,13 +741,14 @@ class MyObject extends CommonObject
return 0;
}
- /*if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->mymodule->write))
- || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->mymodule->mymodule_advance->validate))))
+ /*if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','write'))
+ || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','mymodule_advance','validate'))))
{
$this->error='Permission denied';
return -1;
}*/
+
return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'MYOBJECT_REOPEN');
}
@@ -815,7 +816,7 @@ class MyObject extends CommonObject
if ($option !== 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($url && $add_save_lastsearch_values) {
@@ -865,7 +866,7 @@ class MyObject extends CommonObject
$pospoint = strpos($filearray[0]['name'], '.');
$pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
- if (!getDolGlobalInt(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) {
+ if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) {
$result .= '
';
} else {
$result .= '
';
@@ -924,6 +925,9 @@ class MyObject extends CommonObject
if (property_exists($this, 'label')) {
$return .= '
'.$this->label.'
';
}
+ if (property_exists($this, 'thirdparty') && is_object($this->thirdparty)) {
+ $return .= '
'.$this->thirdparty->getNomUrl(1).'
';
+ }
if (property_exists($this, 'amount')) {
$return .= '
';
$return .= '
'.price($this->amount, 0, $langs, 1, -1, -1, $conf->currency).' ';
@@ -1076,11 +1080,11 @@ class MyObject extends CommonObject
global $langs, $conf;
$langs->load("mymodule@mymodule");
- if (empty(getDolGlobalString('MYMODULE_MYOBJECT_ADDON'))) {
+ if (!getDolGlobalString('MYMODULE_MYOBJECT_ADDON')) {
$conf->global->MYMODULE_MYOBJECT_ADDON = 'mod_myobject_standard';
}
- if (!empty(getDolGlobalString('MYMODULE_MYOBJECT_ADDON'))) {
+ if (getDolGlobalString('MYMODULE_MYOBJECT_ADDON')) {
$mybool = false;
$file = getDolGlobalString('MYMODULE_MYOBJECT_ADDON').".php";
diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php
index 4828d1fb85d..c19b0715713 100644
--- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php
+++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php
@@ -415,8 +415,8 @@ class modMyModule extends DolibarrModules
$this->import_convertvalue_array[$r] = array(
't.ref' => array(
'rule'=>'getrefifauto',
- 'class'=>(empty(getDolGlobalString('MYMODULE_MYOBJECT_ADDON')) ? 'mod_myobject_standard' : getDolGlobalString('MYMODULE_MYOBJECT_ADDON')),
- 'path'=>"/core/modules/commande/".(empty(getDolGlobalString('MYMODULE_MYOBJECT_ADDON')) ? 'mod_myobject_standard' : getDolGlobalString('MYMODULE_MYOBJECT_ADDON')).'.php'
+ 'class'=>(!getDolGlobalString('MYMODULE_MYOBJECT_ADDON') ? 'mod_myobject_standard' : getDolGlobalString('MYMODULE_MYOBJECT_ADDON')),
+ 'path'=>"/core/modules/commande/".(!getDolGlobalString('MYMODULE_MYOBJECT_ADDON') ? 'mod_myobject_standard' : getDolGlobalString('MYMODULE_MYOBJECT_ADDON')).'.php'
'classobject'=>'MyObject',
'pathobject'=>'/mymodule/class/myobject.class.php',
),
diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php
index 0063ba76b73..5014b764832 100644
--- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php
+++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php
@@ -148,22 +148,23 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
}
}
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
+ $texthelp .= '
'.$langs->trans("ExampleOfDirectoriesForModelGen").' ';
// Add list of substitution keys
$texthelp .= '
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
- $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
+ $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
$texte .= '
';
// Scan directories
$nbofiles = count($listoffiles);
- if (!empty(getDolGlobalString('MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH'))) {
+ if (getDolGlobalString('MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH')) {
$texte .= $langs->trans("NumberOfModelFilesFound").':
';
//$texte.=$nbofiles?'':'';
$texte .= count($listoffiles);
@@ -191,16 +192,11 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
}
$texte .= ' ';
$texte .= ' ';
- $texte .= ' ';
+ $texte .= ' ';
$texte .= ' ';
$texte .= ' ';
- $texte .= '';
- $texte .= '';
- $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
- $texte .= ' ';
- $texte .= ' ';
$texte .= '';
$texte .= '
';
@@ -283,8 +279,8 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
// Get extension (ods or odt)
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
- if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) {
- $format = getDolGlobalInt('MAIN_DOC_USE_TIMING');
+ if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
+ $format = getDolGlobalString('MAIN_DOC_USE_TIMING');
if ($format == '1') {
$format = '%Y%m%d%H%M%S';
}
diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php
index 5dca1a952b1..d4836dc773e 100644
--- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php
+++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php
@@ -48,6 +48,11 @@ class pdf_standard_myobject extends ModelePDFMyObject
*/
public $db;
+ /**
+ * @var int The environment ID when using a multicompany module
+ */
+ public $entity;
+
/**
* @var string model name
*/
@@ -86,12 +91,6 @@ class pdf_standard_myobject extends ModelePDFMyObject
*/
public $emetteur;
- /**
- * @var bool Situation invoice type
- */
- public $situationinvoice;
-
-
/**
* @var array of document table columns
*/
@@ -141,11 +140,11 @@ class pdf_standard_myobject extends ModelePDFMyObject
// Use new system for position of columns, view $this->defineColumnField()
$this->tva = array();
+ $this->tva_array = array();
$this->localtax1 = array();
$this->localtax2 = array();
$this->atleastoneratenotnull = 0;
$this->atleastonediscount = 0;
- $this->situationinvoice = false;
}
@@ -153,7 +152,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
/**
* Function to build pdf onto disk
*
- * @param Object $object Object to generate
+ * @param MyObject $object Object to generate
* @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details
@@ -179,8 +178,14 @@ class pdf_standard_myobject extends ModelePDFMyObject
// Load translation files required by the page
$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies"));
- if (!empty(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) && $outputlangs->defaultlang != getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) {
- global $outputlangsbis;
+ // Show Draft Watermark
+ if (getDolGlobalString('MYOBJECT_DRAFT_WATERMARK') && $object->statut == $object::STATUS_DRAFT) {
+ $this->watermark = getDolGlobalString('MYOBJECT_DRAFT_WATERMARK');
+ }
+
+ global $outputlangsbis;
+ $outputlangsbis = null;
+ if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) {
$outputlangsbis = new Translate('', $conf);
$outputlangsbis->setDefaultLang(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE'));
$outputlangsbis->loadLangs(array("main", "bills", "products", "dict", "companies"));
@@ -197,14 +202,15 @@ class pdf_standard_myobject extends ModelePDFMyObject
$realpatharray = array();
$this->atleastonephoto = false;
/*
- if (getDolGlobalInt('MAIN_GENERATE_MYOBJECT_WITH_PICTURE')))
- {
+ if (getDolGlobalInt('MAIN_GENERATE_MYOBJECT_WITH_PICTURE'))) {
$objphoto = new Product($this->db);
- for ($i = 0; $i < $nblines; $i++)
- {
- if (empty($object->lines[$i]->fk_product)) continue;
+ for ($i = 0; $i < $nblines; $i++) {
+ if (empty($object->lines[$i]->fk_product)) {
+ continue;
+ }
+ $objphoto->fetch($object->lines[$i]->fk_product);
//var_dump($objphoto->ref);exit;
if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) {
$pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/";
@@ -215,18 +221,17 @@ class pdf_standard_myobject extends ModelePDFMyObject
}
$arephoto = false;
- foreach ($pdir as $midir)
- {
- if (!$arephoto)
- {
- $dir = $conf->product->dir_output.'/'.$midir;
+ foreach ($pdir as $midir) {
+ if (!$arephoto) {
+ if ($conf->entity != $objphoto->entity) {
+ $dir = $conf->product->multidir_output[$objphoto->entity].'/'.$midir; //Check repertories of current entities
+ } else {
+ $dir = $conf->product->dir_output.'/'.$midir; //Check repertory of the current product
+ }
- foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
- {
- if (!getDolGlobalInt('CAT_HIGH_QUALITY_IMAGES')) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
- {
- if ($obj['photo_vignette'])
- {
+ foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
+ if (!getDolGlobalInt('CAT_HIGH_QUALITY_IMAGES')) { // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
+ if ($obj['photo_vignette']) {
$filename = $obj['photo_vignette'];
} else {
$filename = $obj['photo'];
@@ -242,23 +247,25 @@ class pdf_standard_myobject extends ModelePDFMyObject
}
}
- if ($realpath && $arephoto) $realpatharray[$i] = $realpath;
+ if ($realpath && $arephoto) {
+ $realpatharray[$i] = $realpath;
+ }
}
}
*/
//if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
- if ($conf->mymodule->dir_output.'/myobject') {
+ if (getMultidirOutput($object)) {
$object->fetch_thirdparty();
// Definition of $dir and $file
if ($object->specimen) {
- $dir = $conf->mymodule->dir_output.'/myobject';
+ $dir = getMultidirOutput($object);
$file = $dir."/SPECIMEN.pdf";
} else {
$objectref = dol_sanitizeFileName($object->ref);
- $dir = $conf->mymodule->dir_output.'/myobject/'.$objectref;
+ $dir = getMultidirOutput($object)."/".$objectref;
$file = $dir."/".$objectref.".pdf";
}
if (!file_exists($dir)) {
@@ -270,12 +277,16 @@ class pdf_standard_myobject extends ModelePDFMyObject
if (file_exists($dir)) {
// Add pdfgeneration hook
+ if (!is_object($hookmanager)) {
+ include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
+ $hookmanager = new HookManager($this->db);
+ }
$hookmanager->initHooks(array('pdfgeneration'));
$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
global $action;
$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- // Set nblines with the new facture lines content after hook
+ // Set nblines with the new lines content after hook
$nblines = (is_array($object->lines) ? count($object->lines) : 0);
// Create pdf instance
@@ -284,7 +295,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
$pdf->SetAutoPageBreak(1, 0);
$heightforinfotot = 50; // Height reserved to output the info and total part and payment part
- $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+ $heightforfreetext = getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT', 5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + (getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22); // Height reserved to output the footer (value include bottom margin)
if (class_exists('TCPDF')) {
@@ -295,7 +306,11 @@ class pdf_standard_myobject extends ModelePDFMyObject
// Set path to the background PDF File
if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) {
- $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
+ $logodir = $conf->mycompany->dir_output;
+ if (!empty($conf->mycompany->multidir_output[$object->entity])) {
+ $logodir = $conf->mycompany->multidir_output[$object->entity];
+ }
+ $pagecount = $pdf->setSourceFile($logodir.'/'.getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$tplidx = $pdf->importPage(1);
}
@@ -316,7 +331,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
$cert = empty($user->conf->CERTIFICATE_CRT) ? '' : $user->conf->CERTIFICATE_CRT;
// If user has no certificate, we try to take the company one
if (!$cert) {
- $cert = getDolGlobalString('CERTIFICATE_CRT') ? '' : getDolGlobalString('CERTIFICATE_CRT');
+ $cert = getDolGlobalString('CERTIFICATE_CRT');
}
// If a certificate is found
if ($cert) {
@@ -331,6 +346,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
+
// New page
$pdf->AddPage();
if (!empty($tplidx)) {
@@ -345,7 +361,9 @@ class pdf_standard_myobject extends ModelePDFMyObject
$tab_top = 90 + $top_shift;
$tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
- $tab_height = 130 - $top_shift;
+
+ $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
+
$tab_height_newpage = 150;
if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
$tab_height_newpage -= $top_shift;
@@ -454,8 +472,8 @@ class pdf_standard_myobject extends ModelePDFMyObject
}
$height_note = $posyafter - $tab_top_newpage;
$pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
- } else // No pagebreak
- {
+ } else {
+ // No pagebreak
$pdf->commitTransaction();
$posyafter = $pdf->GetY();
$height_note = $posyafter - $tab_top;
@@ -515,6 +533,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
$showpricebeforepagebreak = 1;
$posYAfterImage = 0;
+ $posYAfterDescription = 0;
if ($this->getColumnStatus('photo')) {
// We start with Photo of product line
@@ -536,7 +555,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
}
if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
- $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
+ $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
// $pdf->Image does not increase value return by getY, so we save it manually
$posYAfterImage = $curY + $imglinesize['height'];
}
@@ -551,6 +570,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
if ($pageposafter > $pageposbefore) { // There is a pagebreak
$pdf->rollbackTransaction(true);
+ $pageposafter = $pageposbefore;
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
$this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
@@ -575,13 +595,15 @@ class pdf_standard_myobject extends ModelePDFMyObject
$showpricebeforepagebreak = 0;
}
}
- } else // No pagebreak
- {
+ } else { // No pagebreak
$pdf->commitTransaction();
}
+ $posYAfterDescription = $pdf->GetY();
}
- $nexY = $pdf->GetY();
+ $nexY = max($pdf->GetY(), $posYAfterImage);
+
+
$pageposafter = $pdf->getPage();
$pdf->setPage($pageposbefore);
$pdf->setTopMargin($this->marge_haute);
@@ -589,10 +611,11 @@ class pdf_standard_myobject extends ModelePDFMyObject
// We suppose that a too long description or photo were moved completely on next page
if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
- $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
+ $pdf->setPage($pageposafter);
+ $curY = $tab_top_newpage;
}
- $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
+ $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
// Quantity
// Enough for 6 chars
@@ -650,16 +673,6 @@ class pdf_standard_myobject extends ModelePDFMyObject
$localtax1_type = $object->lines[$i]->localtax1_type;
$localtax2_type = $object->lines[$i]->localtax2_type;
- if ($object->remise_percent) {
- $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
- }
- if ($object->remise_percent) {
- $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
- }
- if ($object->remise_percent) {
- $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
- }
-
$vatrate = (string) $object->lines[$i]->tva_tx;
// Retrieve type from database for backward compatibility with old records
@@ -689,10 +702,17 @@ class pdf_standard_myobject extends ModelePDFMyObject
if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
$vatrate .= '*';
}
+
+ // Fill $this->tva and $this->tva_array
if (!isset($this->tva[$vatrate])) {
$this->tva[$vatrate] = 0;
}
$this->tva[$vatrate] += $tvaligne;
+ $vatcode = $object->lines[$i]->vat_src_code;
+ if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'])) {
+ $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] = 0;
+ }
+ $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne);
$nexY = max($nexY, $posYAfterImage);
@@ -747,11 +767,10 @@ class pdf_standard_myobject extends ModelePDFMyObject
// Show square
if ($pagenb == $pageposbeforeprintlines) {
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis);
- $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
} else {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis);
- $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
+ $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
// Display infos area
//$posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
@@ -761,7 +780,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
// Display payment area
/*
- if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && !getDolGlobalInt('INVOICE_NO_PAYMENT_DETAILS')))
+ if ($deja_regle)
{
$posy = $this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
}
@@ -882,7 +901,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
* Show top header of page.
*
* @param TCPDF $pdf Object PDF
- * @param Object $object Object to show
+ * @param MyObject $object Object to show
* @param int $showaddress 0=no, 1=yes
* @param Translate $outputlangs Object lang for output
* @param Translate $outputlangsbis Object lang for output bis
@@ -890,8 +909,12 @@ class pdf_standard_myobject extends ModelePDFMyObject
*/
protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null)
{
+ // phpcs:enable
global $conf, $langs;
+ $ltrdirection = 'L';
+ if ($outputlangs->trans("DIRECTION") == 'rtl') $ltrdirection = 'R';
+
// Load traductions files required by page
$outputlangs->loadLangs(array("main", "bills", "propal", "companies"));
@@ -900,7 +923,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
// Show Draft Watermark
- if ($object->statut == $object::STATUS_DRAFT && getDolGlobalString('MYMODULE_DRAFT_WATERMARK')) {
+ if (getDolGlobalString('MYMODULE_DRAFT_WATERMARK') && $object->statut == $object::STATUS_DRAFT) {
pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', dol_escape_htmltag(getDolGlobalString('MYMODULE_DRAFT_WATERMARK')));
}
@@ -918,8 +941,8 @@ class pdf_standard_myobject extends ModelePDFMyObject
if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) {
if ($this->emetteur->logo) {
$logodir = $conf->mycompany->dir_output;
- if (!empty($conf->mycompany->multidir_output[$object->entity])) {
- $logodir = $conf->mycompany->multidir_output[$object->entity];
+ if (!empty(getMultidirOutput($object, 'mycompany'))) {
+ $logodir = getMultidirOutput($object, 'mycompany');
}
if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
$logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
@@ -945,7 +968,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$title = $outputlangs->transnoentities("PdfTitle");
- if (getDolGlobalInt('MAIN_ODT_AS_PDF') && is_object($outputlangsbis)) {
+ if (getDolGlobalInt('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
$title .= ' - ';
$title .= $outputlangsbis->transnoentities("PdfTitle");
}
@@ -970,7 +993,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
$posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65), '', 'R');
}
if (getDolGlobalInt('PDF_SHOW_PROJECT_TITLE')) {
@@ -979,7 +1002,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
$posy += 3;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R');
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R');
}
}
@@ -1002,9 +1025,9 @@ class pdf_standard_myobject extends ModelePDFMyObject
if (getDolGlobalInt('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
$title .= ' - '.$outputlangsbis->transnoentities("Date");
}
- $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs), '', 'R');
+ $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
- if ($object->thirdparty->code_client) {
+ if (empty($conf->global->MAIN_PDF_HIDE_CUSTOMER_CODE) && !empty($object->thirdparty->code_client)) {
$posy += 3;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
@@ -1051,27 +1074,31 @@ class pdf_standard_myobject extends ModelePDFMyObject
// Show sender frame
- $pdf->SetTextColor(0, 0, 0);
- $pdf->SetFont('', '', $default_font_size - 2);
- $pdf->SetXY($posx, $posy - 5);
- $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
- $pdf->SetXY($posx, $posy);
- $pdf->SetFillColor(230, 230, 230);
- $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
- $pdf->SetTextColor(0, 0, 60);
+ if (empty($conf->global->MAIN_PDF_NO_SENDER_FRAME)) {
+ $pdf->SetTextColor(0, 0, 0);
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posx, $posy - 5);
+ $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillFrom").":", 0, $ltrdirection);
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetFillColor(230, 230, 230);
+ $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
+ $pdf->SetTextColor(0, 0, 60);
+ }
// Show sender name
- $pdf->SetXY($posx + 2, $posy + 3);
- $pdf->SetFont('', 'B', $default_font_size);
- $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
- $posy = $pdf->getY();
+ if (empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) {
+ $pdf->SetXY($posx + 2, $posy + 3);
+ $pdf->SetFont('', 'B', $default_font_size);
+ $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
+ $posy = $pdf->getY();
+ }
// Show sender information
$pdf->SetXY($posx + 2, $posy);
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L');
+ $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
- // If BILLING contact defined on invoice, we use it
+ // If BILLING contact defined, we use it
$usecontact = false;
$arrayidcontact = $object->getIdContact('external', 'BILLING');
if (count($arrayidcontact) > 0) {
@@ -1080,7 +1107,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
}
// Recipient name
- if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
+ if ($usecontact && $object->contact->socid != $object->thirdparty->id && getDolGlobalInt('MAIN_USE_COMPANY_NAME_OF_CONTACT')) {
$thirdparty = $object->contact;
} else {
$thirdparty = $object->thirdparty;
@@ -1090,7 +1117,8 @@ class pdf_standard_myobject extends ModelePDFMyObject
$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
}
- $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
+ $mode = 'target';
+ $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object);
// Show recipient
$widthrecbox = getDolGlobalInt('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
@@ -1105,23 +1133,25 @@ class pdf_standard_myobject extends ModelePDFMyObject
}
// Show recipient frame
- $pdf->SetTextColor(0, 0, 0);
- $pdf->SetFont('', '', $default_font_size - 2);
- $pdf->SetXY($posx + 2, $posy - 5);
- $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
- $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
+ if (empty($conf->global->MAIN_PDF_NO_RECIPENT_FRAME)) {
+ $pdf->SetTextColor(0, 0, 0);
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posx + 2, $posy - 5);
+ $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("To").":", 0, $ltrdirection);
+ $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
+ }
// Show recipient name
$pdf->SetXY($posx + 2, $posy + 3);
$pdf->SetFont('', 'B', $default_font_size);
- $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L');
+ $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
$posy = $pdf->getY();
// Show recipient information
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->SetXY($posx + 2, $posy);
- $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
+ $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
}
$pdf->SetTextColor(0, 0, 0);
@@ -1239,7 +1269,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
'border-left' => true, // add left line separator
);
- if (getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') && !getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN')) {
+ if (!getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') && !getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN')) {
$this->cols['vat']['status'] = true;
}
@@ -1265,21 +1295,6 @@ class pdf_standard_myobject extends ModelePDFMyObject
'border-left' => true, // add left line separator
);
- $rank = $rank + 10;
- $this->cols['progress'] = array(
- 'rank' => $rank,
- 'width' => 19, // in mm
- 'status' => false,
- 'title' => array(
- 'textkey' => 'Progress'
- ),
- 'border-left' => true, // add left line separator
- );
-
- if ($this->situationinvoice) {
- $this->cols['progress']['status'] = true;
- }
-
$rank = $rank + 10;
$this->cols['unit'] = array(
'rank' => $rank,
@@ -1290,7 +1305,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
),
'border-left' => true, // add left line separator
);
- if (!empty($conf->global->PRODUCT_USE_UNITS)) {
+ if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
$this->cols['unit']['status'] = true;
}
@@ -1314,7 +1329,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
'width' => 26, // in mm
'status' => true,
'title' => array(
- 'textkey' => 'TotalHT'
+ 'textkey' => 'TotalHTShort'
),
'border-left' => true, // add left line separator
);
diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php
index a31a63f0b14..967192deaab 100644
--- a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php
+++ b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php
@@ -54,22 +54,23 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
/**
* Returns the description of the numbering model
*
- * @return string Descriptive text
+ * @param Translate $langs Translate Object
+ * @return string Text with description
*/
- public function info()
+ public function info($langs)
{
- global $conf, $langs, $db;
+ global $db;
$langs->load("bills");
$form = new Form($db);
- $texte = $langs->trans('GenericNumRefModelDesc')."
\n";
- $texte .= '
';
- $texte .= ' ';
- $texte .= ' ';
- $texte .= ' ';
- $texte .= '';
+ $text = $langs->trans('GenericNumRefModelDesc')." \n";
+ $text .= '';
+ $text .= ' ';
+ $text .= ' ';
+ $text .= ' ';
+ $text .= '';
$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("MyObject"), $langs->transnoentities("MyObject"));
$tooltip .= $langs->trans("GenericMaskCodes2");
@@ -78,15 +79,15 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
$tooltip .= $langs->trans("GenericMaskCodes5");
// Parametrage du prefix
- $texte .= ''.$langs->trans("Mask").': ';
- $texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
- $texte .= ' ';
+ $text .= ''.$langs->trans("Mask").': ';
+ $text .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
+ $text .= ' ';
+ $text .= ' ';
- $texte .= '
';
- $texte .= ' ';
+ $text .= '
';
+ $text .= ' ';
- return $texte;
+ return $text;
}
/**
diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php
index f21ffe880d0..22877a3fd0e 100644
--- a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php
+++ b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php
@@ -52,11 +52,11 @@ class mod_myobject_standard extends ModeleNumRefMyObject
/**
* Return description of numbering module
*
- * @return string Text with description
+ * @param Translate $langs Translate Object
+ * @return string Text with description
*/
- public function info()
+ public function info($langs)
{
- global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
diff --git a/htdocs/modulebuilder/template/myobject_agenda.php b/htdocs/modulebuilder/template/myobject_agenda.php
index 57409ab097c..00c5b9d1bc7 100644
--- a/htdocs/modulebuilder/template/myobject_agenda.php
+++ b/htdocs/modulebuilder/template/myobject_agenda.php
@@ -189,6 +189,7 @@ if ($object->id > 0) {
$title = $langs->trans("MyObject")." - ".$langs->trans('Agenda');
//$title = $object->ref." - ".$langs->trans("Agenda");
$help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung';
+
llxHeader('', $title, $help_url);
if (isModEnabled('notification')) {
diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php
index f3d39a829a5..48a23edf4d2 100644
--- a/htdocs/modulebuilder/template/myobject_card.php
+++ b/htdocs/modulebuilder/template/myobject_card.php
@@ -17,30 +17,33 @@
*/
/**
- * \file htdocs/modulebuilder/template/myobject_card.php
- * \ingroup mymodule
- * \brief Page to create/edit/view myobject
+ * \file htdocs/modulebuilder/template/myobject_card.php
+ * \ingroup mymodule
+ * \brief Page to create/edit/view myobject
*/
-//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
-//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
-//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
-//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
-//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
-//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
-//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
-//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
-//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
-//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
-//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
-//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too.
-//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
-//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value
-//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
-//if (! defined("MAIN_SECURITY_FORCECSP")) define('MAIN_SECURITY_FORCECSP', 'none'); // Disable all Content Security Policies
-//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
-//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
-//if (! defined('NOSESSION')) define('NOSESSION', '1'); // Disable session
+
+// General defined Options
+//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
+//if (! defined('MAIN_AUTHENTICATION_MODE')) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
+//if (! defined('MAIN_LANG_DEFAULT')) define('MAIN_LANG_DEFAULT', 'auto'); // Force LANG (language) to a particular value
+//if (! defined('MAIN_SECURITY_FORCECSP')) define('MAIN_SECURITY_FORCECSP', 'none'); // Disable all Content Security Policies
+//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
+//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
+//if (! defined('NOLOGIN')) define('NOLOGIN', '1'); // Do not use login - if this page is public (can be called outside logged session). This includes the NOIPCHECK too.
+//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
+//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
+//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // Do not load html.form.class.php
+//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // Do not load and show top and left menu
+//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
+//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
+//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
+//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
+//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
+//if (! defined('NOSESSION')) define('NOSESSION', '1'); // On CLI mode, no need to use web sessions
+//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
+//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
+
// Load Dolibarr environment
$res = 0;
@@ -405,10 +408,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
/*
// Ref customer
$morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1);
- $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ? ':'.$conf->global->THIRDPARTY_REF_INPUT_SIZE : ''), '', null, null, '', 1);
+ $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string'.(getDolGlobalInt('THIRDPARTY_REF_INPUT_SIZE') ? ':'.getDolGlobalInt('THIRDPARTY_REF_INPUT_SIZE') : ''), '', null, null, '', 1);
// Thirdparty
$morehtmlref .= '
'.$object->thirdparty->getNomUrl(1, 'customer');
- if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
+ if (!getDolGlobalInt('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) {
$morehtmlref .= ' (
'.$langs->trans("OtherOrders").' )';
}
// Project
diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php
index d7eafaa78a3..8b97342da44 100644
--- a/htdocs/modulebuilder/template/myobject_document.php
+++ b/htdocs/modulebuilder/template/myobject_document.php
@@ -22,24 +22,26 @@
* \brief Tab for documents linked to MyObject
*/
-//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
-//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
-//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
-//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
-//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
-//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
-//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
-//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
-//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
-//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
-//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
-//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too.
-//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
-//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value
-//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
-//if (! defined("MAIN_SECURITY_FORCECSP")) define('MAIN_SECURITY_FORCECSP', 'none'); // Disable all Content Security Policies
-//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
-//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
+// General defined Options
+//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
+//if (! defined('MAIN_AUTHENTICATION_MODE')) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
+//if (! defined('MAIN_LANG_DEFAULT')) define('MAIN_LANG_DEFAULT', 'auto'); // Force LANG (language) to a particular value
+//if (! defined('MAIN_SECURITY_FORCECSP')) define('MAIN_SECURITY_FORCECSP', 'none'); // Disable all Content Security Policies
+//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
+//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
+//if (! defined('NOLOGIN')) define('NOLOGIN', '1'); // Do not use login - if this page is public (can be called outside logged session). This includes the NOIPCHECK too.
+//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
+//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
+//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // Do not load html.form.class.php
+//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // Do not load and show top and left menu
+//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
+//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
+//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
+//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
+//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
+//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
+//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
+
// Load Dolibarr environment
$res = 0;
@@ -82,13 +84,12 @@ dol_include_once('/mymodule/lib/mymodule_myobject.lib.php');
// Load translation files required by the page
$langs->loadLangs(array("mymodule@mymodule", "companies", "other", "mails"));
-
-$action = GETPOST('action', 'aZ09');
+// Get parameters
+$action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm');
-$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'));
+$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'));
$ref = GETPOST('ref', 'alpha');
-// Get parameters
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
@@ -112,6 +113,7 @@ $object = new MyObject($db);
$extrafields = new ExtraFields($db);
$diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array($object->element.'document', 'globalcard')); // Note that conf->hooks_modules contains array
+
// Fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
@@ -122,15 +124,16 @@ if ($id > 0 || !empty($ref)) {
$upload_dir = $conf->mymodule->multidir_output[$object->entity ? $object->entity : $conf->entity]."/myobject/".get_exdir(0, 0, 0, 1, $object);
}
-// There is several ways to check permission.
+// Permissions
+// (There are several ways to check permission.)
// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
$enablepermissioncheck = 0;
if ($enablepermissioncheck) {
$permissiontoread = $user->rights->mymodule->myobject->read;
- $permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php
+ $permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php
} else {
$permissiontoread = 1;
- $permissiontoadd = 1;
+ $permissiontoadd = 1;
}
// Security check (enable the most restrictive one)
@@ -163,10 +166,12 @@ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
$form = new Form($db);
+// Header
+// ------
$title = $langs->trans("MyObject")." - ".$langs->trans("Files");
//$title = $object->ref." - ".$langs->trans("Files");
$help_url = '';
-//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
+//Example $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $title, $help_url);
// Show tabs
diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php
index efbd9e4dd05..db7cdd34d67 100644
--- a/htdocs/modulebuilder/template/myobject_list.php
+++ b/htdocs/modulebuilder/template/myobject_list.php
@@ -22,25 +22,28 @@
* \brief List page for myobject
*/
-//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
-//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
-//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
-//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
-//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
-//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
-//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
-//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
-//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
-//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
-//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
-//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too.
-//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
-//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value
-//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
-//if (! defined("MAIN_SECURITY_FORCECSP")) define('MAIN_SECURITY_FORCECSP', 'none'); // Disable all Content Security Policies
-//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
-//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
-//if (! defined('NOSESSION')) define('NOSESSION', '1'); // On CLI mode, no need to use web sessions
+
+// General defined Options
+//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
+//if (! defined('MAIN_AUTHENTICATION_MODE')) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
+//if (! defined('MAIN_LANG_DEFAULT')) define('MAIN_LANG_DEFAULT', 'auto'); // Force LANG (language) to a particular value
+//if (! defined('MAIN_SECURITY_FORCECSP')) define('MAIN_SECURITY_FORCECSP', 'none'); // Disable all Content Security Policies
+//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
+//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
+//if (! defined('NOLOGIN')) define('NOLOGIN', '1'); // Do not use login - if this page is public (can be called outside logged session). This includes the NOIPCHECK too.
+//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
+//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
+//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // Do not load html.form.class.php
+//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // Do not load and show top and left menu
+//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
+//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
+//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
+//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
+//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
+//if (! defined('NOSESSION')) define('NOSESSION', '1'); // On CLI mode, no need to use web sessions
+//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
+//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
+
// Load Dolibarr environment
$res = 0;
@@ -87,6 +90,7 @@ require_once __DIR__.'/class/myobject.class.php';
// Load translation files required by the page
$langs->loadLangs(array("mymodule@mymodule", "other"));
+// Get parameters
$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)
$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
@@ -136,7 +140,7 @@ if (!$sortorder) {
}
// Initialize array of search criterias
-$search_all = GETPOST('search_all', 'alphanohtml');
+$search_all = trim(GETPOST('search_all', 'alphanohtml'));
$search = array();
foreach ($object->fields as $key => $val) {
if (GETPOST('search_'.$key, 'alpha') !== '') {
@@ -411,7 +415,7 @@ $num = $db->num_rows($resql);
// Direct jump if only one record found
-if ($num == 1 && !getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
+if ($num == 1 && getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
$obj = $db->fetch_object($resql);
$id = $obj->rowid;
header("Location: ".dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.((int) $id));
@@ -696,6 +700,20 @@ while ($i < $imaxinloop) {
// Store properties in $object
$object->setVarsFromFetchObj($obj);
+ /*
+ $object->thirdparty = null;
+ if ($obj->fk_soc > 0) {
+ if (!empty($conf->cache['thirdparty'][$obj->fk_soc])) {
+ $companyobj = $conf->cache['thirdparty'][$obj->fk_soc];
+ } else {
+ $companyobj = new Societe($db);
+ $companyobj->fetch($obj->fk_soc);
+ $conf->cache['thirdparty'][$obj->fk_soc] = $companyobj;
+ }
+
+ $object->thirdparty = $companyobj;
+ }*/
+
if ($mode == 'kanban') {
if ($i == 0) {
print '
';
@@ -709,6 +727,7 @@ while ($i < $imaxinloop) {
$selected = 1;
}
}
+ //print $object->getKanbanView('', array('thirdparty'=>$object->thirdparty, 'selected' => $selected));
print $object->getKanbanView('', array('selected' => $selected));
if ($i == ($imaxinloop - 1)) {
print '';
@@ -755,7 +774,7 @@ while ($i < $imaxinloop) {
if (!empty($arrayfields['t.'.$key]['checked'])) {
print ' $key)) {
+ if (preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) {
print ' title="'.dol_escape_htmltag($object->$key).'"';
}
print '>';
diff --git a/htdocs/modulebuilder/template/myobject_note.php b/htdocs/modulebuilder/template/myobject_note.php
index 9cf46053574..03c1b4c5027 100644
--- a/htdocs/modulebuilder/template/myobject_note.php
+++ b/htdocs/modulebuilder/template/myobject_note.php
@@ -22,24 +22,27 @@
* \brief Tab for notes on MyObject
*/
-//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
-//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
-//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
-//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
-//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
-//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
-//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
-//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
-//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
-//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
-//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
-//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too.
-//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
-//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value
-//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
-//if (! defined("MAIN_SECURITY_FORCECSP")) define('MAIN_SECURITY_FORCECSP', 'none'); // Disable all Content Security Policies
-//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
-//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
+
+// General defined Options
+//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
+//if (! defined('MAIN_AUTHENTICATION_MODE')) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
+//if (! defined('MAIN_LANG_DEFAULT')) define('MAIN_LANG_DEFAULT', 'auto'); // Force LANG (language) to a particular value
+//if (! defined('MAIN_SECURITY_FORCECSP')) define('MAIN_SECURITY_FORCECSP', 'none'); // Disable all Content Security Policies
+//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
+//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
+//if (! defined('NOLOGIN')) define('NOLOGIN', '1'); // Do not use login - if this page is public (can be called outside logged session). This includes the NOIPCHECK too.
+//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
+//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
+//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // Do not load html.form.class.php
+//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // Do not load and show top and left menu
+//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
+//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
+//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
+//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
+//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
+//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
+//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
+
// Load Dolibarr environment
$res = 0;
diff --git a/htdocs/mrp/class/api_mos.class.php b/htdocs/mrp/class/api_mos.class.php
index b3e3ff44ff5..9723d5b2070 100644
--- a/htdocs/mrp/class/api_mos.class.php
+++ b/htdocs/mrp/class/api_mos.class.php
@@ -631,9 +631,9 @@ class Mos extends DolibarrApi
dol_syslog("consumptioncomplete = ".$consumptioncomplete." productioncomplete = ".$productioncomplete);
//var_dump("consumptioncomplete = ".$consumptioncomplete." productioncomplete = ".$productioncomplete);
if ($consumptioncomplete && $productioncomplete) {
- $result = $this->mo->setStatut(self::STATUS_PRODUCED, 0, '', 'MRP_MO_PRODUCED');
+ $result = $this->mo->setStatut(Mo::STATUS_PRODUCED, 0, '', 'MRP_MO_PRODUCED');
} else {
- $result = $this->mo->setStatut(self::STATUS_INPROGRESS, 0, '', 'MRP_MO_PRODUCED');
+ $result = $this->mo->setStatut(Mo::STATUS_INPROGRESS, 0, '', 'MRP_MO_PRODUCED');
}
if ($result <= 0) {
throw new RestException(500, $this->mo->error);
diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php
index 4379808d8d2..ae404fbf9ff 100644
--- a/htdocs/mrp/class/mo.class.php
+++ b/htdocs/mrp/class/mo.class.php
@@ -184,7 +184,6 @@ class Mo extends CommonObject
*/
public $date_end_planned;
-
/**
* @var int ID bom
*/
@@ -200,6 +199,13 @@ class Mo extends CommonObject
*/
public $fk_project;
+ /**
+ * @var double New quantity. When we update the quantity to produce, we set this to save old value before calling the ->update that call the updateProduction that need this
+ * to recalculate all the quantities in lines to consume and produce.
+ */
+ public $oldQty;
+
+
// If this object has a subtable with lines
/**
@@ -247,6 +253,7 @@ class Mo extends CommonObject
*/
public $tpl = array();
+
/**
* Constructor
*
@@ -634,8 +641,6 @@ class Mo extends CommonObject
*/
public function update(User $user, $notrigger = false)
{
- global $langs;
-
$error = 0;
$this->db->begin();
@@ -771,7 +776,7 @@ class Mo extends CommonObject
}
/**
- * Update quantities in lines to consume and to produce.
+ * Update quantities in lines to consume and/or lines to produce.
*
* @param User $user User that modifies
* @param bool $notrigger false=launch triggers after, true=disable triggers
@@ -799,7 +804,7 @@ class Mo extends CommonObject
if ($moLine->role == 'toconsume' || $moLine->role == 'toproduce') {
if (empty($moLine->qty_frozen)) {
$qty = $newQty * $moLine->qty / $oldQty;
- $moLine->qty = price2num($qty * (!empty($line->efficiency) ? $line->efficiency : 1 ), 'MS'); // Calculate with Qty to produce and more presition
+ $moLine->qty = price2num($qty * (!empty($line->efficiency) ? $line->efficiency : 1 ), 'MS'); // Calculate with Qty to produce and efficiency
$res = $moLine->update($user);
if (!$res) $error++;
}
@@ -1245,7 +1250,7 @@ class Mo extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php
index 18213acdb89..3e89216ebd1 100644
--- a/htdocs/opensurvey/class/opensurveysondage.class.php
+++ b/htdocs/opensurvey/class/opensurveysondage.class.php
@@ -50,61 +50,95 @@ class Opensurveysondage extends CommonObject
*/
public $picto = 'poll';
- /**
- * @var string ID survey
- */
- public $id_sondage;
/**
- * @var string description
+ * @var string Description
*/
public $description;
/**
- * @var string email admin
+ * @var string Date last modification (same as tms)
*/
- public $mail_admin;
-
- /**
- * @var string admin name
- */
- public $nom_admin;
-
- /**
- * Id of user author of the poll
- * @var int
- */
- public $fk_user_creat;
-
- /**
- * @var string Title
- */
- public $title;
-
- public $date_fin = '';
-
public $date_m;
- /**
- * @var int status
- */
- public $status = 1;
/**
- * @var string format of survey
+ * 'type' field format:
+ * 'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',
+ * 'select' (list of values are in 'options'),
+ * 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter[:Sortfield]]]]',
+ * 'chkbxlst:...',
+ * 'varchar(x)',
+ * 'text', 'text:none', 'html',
+ * 'double(24,8)', 'real', 'price',
+ * 'date', 'datetime', 'timestamp', 'duration',
+ * 'boolean', 'checkbox', 'radio', 'array',
+ * 'mail', 'phone', 'url', 'password', 'ip'
+ * Note: Filter must be a Dolibarr Universal Filter syntax string. Example: "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.status:!=:0) or (t.nature:is:NULL)"
+ * 'label' the translation key.
+ * 'picto' is code of a picto to show before value in forms
+ * 'enabled' is a condition when the field must be managed (Example: 1 or 'getDolGlobalInt("MY_SETUP_PARAM")' or 'isModEnabled("multicurrency")' ...)
+ * 'position' is the sort order of field.
+ * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
+ * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
+ * 'noteditable' says if field is not editable (1 or 0)
+ * 'alwayseditable' says if field can be modified also when status is not draft ('1' or '0')
+ * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created.
+ * 'index' if we want an index in database.
+ * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
+ * 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
+ * 'isameasure' must be set to 1 or 2 if field can be used for measure. Field type must be summable like integer or double(24,8). Use 1 in most cases, or 2 if you don't want to see the column total into list (for example for percentage)
+ * 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'cssview'=>'wordbreak', 'csslist'=>'tdoverflowmax200'
+ * 'help' and 'helplist' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click.
+ * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
+ * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code.
+ * 'arrayofkeyval' to set a list of values if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel"). Note that type can be 'integer' or 'varchar'
+ * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1.
+ * 'comment' is not used. You can store here any text of your choice. It is not used by application.
+ * 'validate' is 1 if need to validate with $this->validateField()
+ * 'copytoclipboard' is 1 or 2 to allow to add a picto to copy value into clipboard (1=picto after label, 2=picto after value)
+ *
+ * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor.
*/
+
+ // BEGIN MODULEBUILDER PROPERTIES
+ /**
+ * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
+ */
+ public $fields=array(
+ 'id_sondage' => array('type'=>'varchar(16)', 'label'=>'Idsondage', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>-1,),
+ 'commentaires' => array('type'=>'mediumtext', 'label'=>'Commentaires', 'enabled'=>'1', 'position'=>15, 'notnull'=>0, 'visible'=>-1,),
+ 'mail_admin' => array('type'=>'varchar(128)', 'label'=>'Mailadmin', 'enabled'=>'1', 'position'=>20, 'notnull'=>0, 'visible'=>-1,),
+ 'nom_admin' => array('type'=>'varchar(64)', 'label'=>'Nomadmin', 'enabled'=>'1', 'position'=>25, 'notnull'=>0, 'visible'=>-1,),
+ 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>-2, 'css'=>'maxwidth500 widthcentpercentminusxx', 'csslist'=>'tdoverflowmax150',),
+ 'titre' => array('type'=>'mediumtext', 'label'=>'Titre', 'enabled'=>'1', 'position'=>35, 'notnull'=>1, 'visible'=>-1,),
+ 'date_fin' => array('type'=>'datetime', 'label'=>'Datefin', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>-1,),
+ 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>500, 'notnull'=>0, 'visible'=>-1,),
+ 'format' => array('type'=>'varchar(2)', 'label'=>'Format', 'enabled'=>'1', 'position'=>50, 'notnull'=>1, 'visible'=>-1,),
+ 'mailsonde' => array('type'=>'integer', 'label'=>'Mailsonde', 'enabled'=>'1', 'position'=>55, 'notnull'=>1, 'visible'=>-1,),
+ 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>60, 'notnull'=>1, 'visible'=>-1,),
+ 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>'1', 'position'=>65, 'notnull'=>1, 'visible'=>-2, 'default'=>'1', 'index'=>1,),
+ 'allow_comments' => array('type'=>'integer', 'label'=>'Allowcomments', 'enabled'=>'1', 'position'=>70, 'notnull'=>1, 'visible'=>-1,),
+ 'allow_spy' => array('type'=>'integer', 'label'=>'Allowspy', 'enabled'=>'1', 'position'=>75, 'notnull'=>1, 'visible'=>-1,),
+ 'sujet' => array('type'=>'mediumtext', 'label'=>'Sujet', 'enabled'=>'1', 'position'=>80, 'notnull'=>0, 'visible'=>-1,),
+ 'id_sondage_admin' => array('type'=>'char(24)', 'label'=>'Idsondageadmin', 'enabled'=>'1', 'position'=>85, 'notnull'=>0, 'visible'=>-1,),
+ );
+ public $id_sondage;
+ /**
+ * @var string Description
+ * @deprecated Use $description instead
+ */
+ public $commentaires;
+ public $mail_admin;
+ public $nom_admin;
+ public $fk_user_creat;
+ public $titre;
+ public $date_fin = '';
+ public $status;
public $format;
-
- /**
- * @var int mailsonde
- */
public $mailsonde;
-
- /**
- * @var string subject
- */
- public $sujet;
-
+ public $tms;
+ public $entity;
/**
* @var int Allow comments on this poll
*/
@@ -114,11 +148,9 @@ class Opensurveysondage extends CommonObject
* @var int Allow users see others vote
*/
public $allow_spy;
-
- /**
- * @var array fields
- */
- public $fields = array();
+ public $sujet;
+ public $id_sondage_admin;
+ // END MODULEBUILDER PROPERTIES
/**
@@ -457,9 +489,7 @@ class Opensurveysondage extends CommonObject
*/
public function getNomUrl($withpicto = 0, $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
{
- global $db, $conf, $langs;
- global $dolibarr_main_authentication, $dolibarr_main_demo;
- global $menumanager;
+ global $conf, $langs;
if (!empty($conf->dol_no_mouse_hover)) {
$notooltip = 1; // Force disable tooltips
@@ -484,7 +514,7 @@ class Opensurveysondage extends CommonObject
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
@@ -509,7 +539,7 @@ class Opensurveysondage extends CommonObject
$result .= $linkstart;
if ($withpicto) {
- $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
+ $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
}
if ($withpicto != 2) {
$result .= $this->ref;
@@ -739,4 +769,82 @@ class Opensurveysondage extends CommonObject
return $result;
}
+
+ /**
+ * Load list of objects in memory from the database.
+ *
+ * @param string $sortorder Sort Order
+ * @param string $sortfield Sort field
+ * @param int $limit limit
+ * @param int $offset Offset
+ * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...)
+ * @param string $filtermode Filter mode (AND or OR)
+ * @return array|int int <0 if KO, array of pages if OK
+ */
+ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
+ {
+ dol_syslog(__METHOD__, LOG_DEBUG);
+
+ $records = array();
+
+ $sql = 'SELECT ';
+ $sql .= $this->getFieldList();
+ $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
+ if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
+ $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')';
+ } else {
+ $sql .= ' WHERE 1 = 1';
+ }
+ // Manage filter
+ $sqlwhere = array();
+ if (count($filter) > 0) {
+ foreach ($filter as $key => $value) {
+ if ($key == 't.rowid') {
+ $sqlwhere[] = $key." = ".((int) $value);
+ } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
+ $sqlwhere[] = $key." = '".$this->db->idate($value)."'";
+ } elseif ($key == 'customsql') {
+ $sqlwhere[] = $value;
+ } elseif (strpos($value, '%') === false) {
+ $sqlwhere[] = $key." IN (".$this->db->sanitize($this->db->escape($value)).")";
+ } else {
+ $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'";
+ }
+ }
+ }
+ if (count($sqlwhere) > 0) {
+ $sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
+ }
+
+ if (!empty($sortfield)) {
+ $sql .= $this->db->order($sortfield, $sortorder);
+ }
+ if (!empty($limit)) {
+ $sql .= $this->db->plimit($limit, $offset);
+ }
+
+ $resql = $this->db->query($sql);
+ if ($resql) {
+ $num = $this->db->num_rows($resql);
+ $i = 0;
+ while ($i < ($limit ? min($limit, $num) : $num)) {
+ $obj = $this->db->fetch_object($resql);
+
+ $record = new self($this->db);
+ $record->setVarsFromFetchObj($obj);
+
+ $records[$record->id_sondage] = $record;
+
+ $i++;
+ }
+ $this->db->free($resql);
+
+ return $records;
+ } else {
+ $this->errors[] = 'Error '.$this->db->lasterror();
+ dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
+
+ return -1;
+ }
+ }
}
diff --git a/htdocs/opensurvey/css/style.css b/htdocs/opensurvey/css/style.css
index e7f0d279a14..308d92b51f5 100644
--- a/htdocs/opensurvey/css/style.css
+++ b/htdocs/opensurvey/css/style.css
@@ -363,7 +363,7 @@ div.cadre td.ok {
}
/*Case de tableau NON dans affichage de sondage*/
div.cadre td.non {
- background-color: #FF7777;
+ background-color: #FFBBBB;
min-width: 60px;
}
/*Case de tableau VIDE dans affichage de sondage*/
@@ -378,6 +378,9 @@ div.cadre td.nom {
text-align:center;
padding: 8px;
}
+div.cadre td.sujet, div.cadre td.annee, div.cadre td.mois, div.cadre td.jour {
+ padding: 8px !important;
+}
div.cadre td.casevide {
background-color: white;
text-align:center;
diff --git a/htdocs/opensurvey/lib/opensurvey.lib.php b/htdocs/opensurvey/lib/opensurvey.lib.php
index c9c75b01d26..6076ff2d8c5 100644
--- a/htdocs/opensurvey/lib/opensurvey.lib.php
+++ b/htdocs/opensurvey/lib/opensurvey.lib.php
@@ -126,7 +126,7 @@ function llxHeaderSurvey($title, $head = "", $disablejs = 0, $disablehead = 0, $
print '';
}
- print '';
+ print '
';
}
/**
diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php
index d9191278edd..764ca877c58 100644
--- a/htdocs/opensurvey/results.php
+++ b/htdocs/opensurvey/results.php
@@ -331,7 +331,7 @@ for ($i = 0; $i < $nbcolonnes; $i++) {
if ((GETPOST("effacecolonne".$i) || GETPOST("effacecolonne".$i."_x") || GETPOST("effacecolonne".$i.".x"))
&& $nbcolonnes > 1) { // effacecolonnei for chrome, effacecolonnei_x for firefox
// Security check
- if (!$user->rights->opensurvey->write) {
+ if (!$user->hasRight('opensurvey', 'write')) {
accessforbidden();
}
@@ -673,7 +673,7 @@ print '
';
print '
'."\n";
// Start to show survey result
-print '
'."\n";
+print ''."\n";
//reformatage des données des sujets du sondage
$toutsujet = explode(",", $object->sujet);
@@ -684,9 +684,9 @@ print ' '."\n";
print ' '."\n";
// loop to show the delete link
-if ($user->rights->opensurvey->write) {
+if ($user->hasRight('opensurvey', 'write')) {
for ($i = 0; isset($toutsujet[$i]); $i++) {
- print ' '."\n";
+ print ' '."\n";
}
}
diff --git a/htdocs/opensurvey/wizard/choix_date.php b/htdocs/opensurvey/wizard/choix_date.php
index d8f89b18e16..62e262ca6f9 100644
--- a/htdocs/opensurvey/wizard/choix_date.php
+++ b/htdocs/opensurvey/wizard/choix_date.php
@@ -179,6 +179,7 @@ if (GETPOST('confirmation')) {
// Add survey into database
if (!$erreur && $erreurNb == 0) {
$_SESSION["toutchoix"] = substr("$choixdate", 1);
+ unset($_SESSION["nbrecaseshoraires"]);
ajouter_sondage();
}
@@ -215,10 +216,22 @@ llxHeader('', $langs->trans("OpenSurvey"), "", '', 0, 0, $arrayofjs, $arrayofcss
//nombre de cases par défaut
if (!isset($_SESSION["nbrecaseshoraires"])) {
$_SESSION["nbrecaseshoraires"] = 5;
-} elseif (GETPOST('ajoutcases') && $_SESSION["nbrecaseshoraires"] == 5) {
+} elseif ((GETPOST('ajoutcases') || GETPOST("ajoutcases_y")) && $_SESSION["nbrecaseshoraires"] == 5) {
$_SESSION["nbrecaseshoraires"] = 10;
+ //On sauvegarde les heures deja entrées
+ if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) {
+ $nbofchoice = count($_SESSION["totalchoixjour"]);
+ for ($i = 0; $i < $nbofchoice; $i++) {
+ //affichage des 5 cases horaires
+ for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
+ $horairesi = GETPOST("horaires".$i);
+ $_SESSION["horaires$i"][$j] = $horairesi[$j];
+ }
+ }
+ }
}
+
//valeurs de la date du jour actuel
$jourAJ = date("j");
$moisAJ = date("n");
@@ -347,11 +360,13 @@ print ''."\n";
print ''."\n";
print '
'."\n";
print '
'."\n";
print '
'."\n";
@@ -407,7 +422,7 @@ if (issetAndNoEmpty('choixjourajout')) {
$k = $i + 1;
if (issetAndNoEmpty('horaires'.$i) === true && issetAndNoEmpty($i, $_POST['horaires'.$i]) === true) {
for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
- $horairesi = GETPOST("horaires".$i);
+ $horairesi = GETPOST("horaires".$i, 'array');
$_SESSION["horaires$i"][$j] = $horairesi[$j];
}
}
@@ -452,7 +467,7 @@ if (issetAndNoEmpty('reporterhoraires')) {
}
}
-//report des horaires dans toutes les cases
+//effacer les horaires dans toutes les cases
if (issetAndNoEmpty('resethoraires')) {
$nbofchoice = count($_SESSION["totalchoixjour"]);
for ($i = 0; $i < $nbofchoice; $i++) {
@@ -480,7 +495,7 @@ for ($i = 0; $i < $nbrejourmois + $premierjourmois; $i++) {
for ($j = 0; $j < $nbofchoice; $j++) {
// show red buttons
if (date("j", $_SESSION["totalchoixjour"][$j]) == $numerojour && date("n", $_SESSION["totalchoixjour"][$j]) == $_SESSION["mois"] && date("Y", $_SESSION["totalchoixjour"][$j]) == $_SESSION["annee"]) {
- print '
'."\n";
+ print '
'."\n";
$dejafait = $numerojour;
}
}
@@ -490,10 +505,10 @@ for ($i = 0; $i < $nbrejourmois + $premierjourmois; $i++) {
if (isset($dejafait) === false || $dejafait != $numerojour) {
// green button
if (($numerojour >= $jourAJ && $_SESSION["mois"] == $moisAJ && $_SESSION["annee"] == $anneeAJ) || ($_SESSION["mois"] > $moisAJ && $_SESSION["annee"] == $anneeAJ) || $_SESSION["annee"] > $anneeAJ) {
- print '
'."\n";
+ print '
'."\n";
} else {
// grey button
- print '
'.$numerojour.' '."\n";
+ print '
'.$numerojour.' '."\n";
}
}
}
@@ -530,12 +545,13 @@ if (issetAndNoEmpty('totalchoixjour', $_SESSION) || $erreur) {
print ''."\n";
- //affichage de la liste des jours choisis
+ // Show list of selected days
+
$nbofchoice = count($_SESSION["totalchoixjour"]);
for ($i = 0; $i < $nbofchoice; $i++) {
print '
'."\n";
- print ''.dol_print_date($_SESSION["totalchoixjour"][$i], 'daytext').' ('.dol_print_date($_SESSION["totalchoixjour"][$i], '%A').') ';
+ print ''.dol_print_date($_SESSION["totalchoixjour"][$i], 'daytext').' ('.dol_print_date($_SESSION["totalchoixjour"][$i], '%A').') ';
//affichage des cases d'horaires
for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
@@ -555,7 +571,9 @@ if (issetAndNoEmpty('totalchoixjour', $_SESSION) || $erreur) {
// show buttons to cancel, delete days or create survey
print ''."\n";
diff --git a/htdocs/opensurvey/wizard/index.php b/htdocs/opensurvey/wizard/index.php
index 4542ecfa3bd..ef7a35dd303 100644
--- a/htdocs/opensurvey/wizard/index.php
+++ b/htdocs/opensurvey/wizard/index.php
@@ -2,7 +2,7 @@
/* Copyright (C) 2013 Laurent Destailleur
* Copyright (C) 2014 Marcos García
* Copyright (C) 2016 Regis Houssin
- * Copyright (C) 2019 Frédéric France
+ * Copyright (C) 2019 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -55,13 +55,18 @@ print '';
print '
';
print '
';
print '
';
-print '
'.dol_escape_htmltag($langs->trans("CreateSurveyDate")).'';
+print '
';
+print ' ';
+print ''.dol_escape_htmltag($langs->trans("CreateSurveyDate")).'
';
print '
';
print '
';
print '
';
-print '
'.dol_escape_htmltag($langs->trans("CreateSurveyStandard")).'';
+print '
';
+print ' ';
+print ''.dol_escape_htmltag($langs->trans("CreateSurveyStandard")).'
';
print '
';
print '
';
+print '
';
print '
';
print '';
diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php
index bb71d053dfe..bb2c22ab09d 100644
--- a/htdocs/partnership/class/partnership.class.php
+++ b/htdocs/partnership/class/partnership.class.php
@@ -106,7 +106,7 @@ class Partnership extends CommonObject
public $fields=array(
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"),
- 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>'1', 'position'=>15, 'notnull'=>1, 'visible'=>-2, 'default'=>'1', 'index'=>1,),
+ 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>'isModEnabled("multicompany")', 'position'=>15, 'notnull'=>1, 'visible'=>-2, 'default'=>'1', 'index'=>1,),
'fk_type' => array('type'=>'integer:PartnershipType:partnership/class/partnership_type.class.php:0:(active:=:1)', 'label'=>'Type', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'csslist'=>'tdoverflowmax100'),
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))', 'label'=>'ThirdParty', 'picto'=>'company', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'css'=>'maxwidth500', 'csslist'=>'tdoverflowmax125',),
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,),
@@ -120,12 +120,12 @@ class Partnership extends CommonObject
'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,),
'date_partnership_start' => array('type'=>'date', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,),
'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>0, 'visible'=>1,),
- 'url_to_check' => array('type'=>'varchar(255)', 'label'=>'UrlToCheck', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>-1,),
- 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',),
- 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>-2,),
+ 'url_to_check' => array('type'=>'url', 'label'=>'UrlToCheck', 'enabled'=>'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position'=>70, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflowmax150'),
+ 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position'=>71, 'notnull'=>0, 'visible'=>-4, 'default'=>'0',),
+ 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position'=>72, 'notnull'=>0, 'visible'=>-4, 'csslist'=>'nowraponall'),
'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>73, 'notnull'=>0, 'visible'=>-2,),
- 'ip' => array('type'=>'varchar(250)', 'label'=>'Ip', 'enabled'=>'1', 'position'=>74, 'notnull'=>0, 'visible'=>-2,),
- 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>2, 'default'=>'0', 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Accepted', '2'=>'Refused', '8'=>'Suspended', '9'=>'Terminated'),),
+ 'ip' => array('type'=>'ip', 'label'=>'IPOfApplicant', 'enabled'=>'1', 'position'=>74, 'notnull'=>0, 'visible'=>-2,),
+ 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>2, 'default'=>'0', 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '2'=>'Approved', '3'=>'Refused', '9'=>'Terminated'),),
);
public $rowid;
public $ref;
@@ -153,41 +153,6 @@ class Partnership extends CommonObject
// END MODULEBUILDER PROPERTIES
- // If this object has a subtable with lines
-
- // /**
- // * @var string Name of subtable line
- // */
- // public $table_element_line = 'partnershipline';
-
- // /**
- // * @var string Field with ID of parent key if this object has a parent
- // */
- // public $fk_element = 'fk_partnership';
-
- // /**
- // * @var string Name of subtable class that manage subtable lines
- // */
- // public $class_element_line = 'Partnershipline';
-
- // /**
- // * @var array List of child tables. To test if we can delete object.
- // */
- // protected $childtables = array();
-
- // /**
- // * @var array List of child tables. To know object to delete on cascade.
- // * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will
- // * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object
- // */
- // protected $childtablesoncascade = array('partnershipdet');
-
- // /**
- // * @var PartnershipLine[] Array of subtable lines
- // */
- // public $lines = array();
-
-
/**
* Constructor
*
@@ -208,15 +173,6 @@ class Partnership extends CommonObject
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid']) && !empty($this->fields['ref'])) {
$this->fields['rowid']['visible'] = 0;
}
- // if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
- // $this->fields['entity']['enabled'] = 0;
- // }
-
- // Example to show how to set values of fields definition dynamically
- /*if ($user->rights->partnership->read) {
- $this->fields['myfield']['visible'] = 1;
- $this->fields['myfield']['noteditable'] = 0;
- }*/
// Unset fields that are disabled
foreach ($this->fields as $key => $val) {
@@ -367,8 +323,6 @@ class Partnership extends CommonObject
*/
public function fetch($id, $ref = null, $fk_member = null, $fk_soc = null)
{
- global $conf;
-
// Check parameters
if (empty($id) && empty($ref) && empty($fk_member) && empty($fk_soc)) {
return -1;
@@ -479,8 +433,6 @@ class Partnership extends CommonObject
*/
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
{
- global $conf;
-
dol_syslog(__METHOD__, LOG_DEBUG);
$records = array();
@@ -607,7 +559,7 @@ class Partnership extends CommonObject
*/
public function validate($user, $notrigger = 0)
{
- global $conf, $langs;
+ global $conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@@ -731,7 +683,7 @@ class Partnership extends CommonObject
*/
public function approve($user, $notrigger = 0)
{
- global $conf, $langs;
+ global $conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@@ -1009,7 +961,7 @@ class Partnership extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
@@ -1309,8 +1261,6 @@ class Partnership extends CommonObject
*/
public function doScheduledJob()
{
- global $conf, $langs;
-
//$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
$error = 0;
@@ -1319,7 +1269,7 @@ class Partnership extends CommonObject
dol_syslog(__METHOD__, LOG_DEBUG);
- $now = dol_now();
+ //$now = dol_now();
$this->db->begin();
@@ -1352,6 +1302,9 @@ class Partnership extends CommonObject
if (property_exists($this, 'label')) {
$return .= ' '.$this->label.'
';
}
+ if (property_exists($this, 'thirdparty') && is_object($this->thirdparty)) {
+ $return .= ''.$this->thirdparty->getNomUrl(1).'
';
+ }
if (method_exists($this, 'getLibStatut')) {
$return .= ''.$this->getLibStatut(3).'
';
}
diff --git a/htdocs/partnership/class/partnership_type.class.php b/htdocs/partnership/class/partnership_type.class.php
index 48b3d7c6984..b6d0f3dec70 100644
--- a/htdocs/partnership/class/partnership_type.class.php
+++ b/htdocs/partnership/class/partnership_type.class.php
@@ -285,7 +285,7 @@ class PartnershipType extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($url && $add_save_lastsearch_values) {
@@ -368,6 +368,17 @@ class PartnershipType extends CommonObject
return $result;
}
+ /**
+ * Return the label of the status
+ *
+ * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
+ * @return string Label of status
+ */
+ public function getLibStatut($mode = 0)
+ {
+ return '';
+ }
+
/**
* Load the info information in the object
*
diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php
index 86722ed1da2..96ee748bae3 100644
--- a/htdocs/partnership/class/partnershiputils.class.php
+++ b/htdocs/partnership/class/partnershiputils.class.php
@@ -147,7 +147,7 @@ class PartnershipUtils
$partnershipsprocessed[$object->id] = $object->ref;
// Send an email to inform member
- $labeltemplate = '(SendingEmailOnPartnershipCanceled)';
+ $labeltemplate = '('.getDolGlobalString('PARTNERSHIP_SENDMAIL_IF_AUTO_CANCEL', 'SendingEmailOnPartnershipCanceled').')';
dol_syslog("Now we will send an email to member id=".$object->fk_member." with label ".$labeltemplate);
@@ -175,16 +175,59 @@ class PartnershipUtils
$msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs);
$from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
+ // We are in the case of autocancellation subscription because of missing backlink
+ $fk_partner = $object->fk_member;
+
$adherent = new Adherent($this->db);
$adherent->fetch($object->fk_member);
- $to = $adherent->email;
+ $sendto = $adherent->email;
+
+ $trackid = 'par'.$object->id;
+ $sendcontext = 'standard';
+
+ $cmail = new CMailFile($subject, $sendto, $from, $msg, array(), array(), array(), '', '', 0, 1, '', '', $trackid, '', $sendcontext);
- $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1);
$result = $cmail->sendfile();
- if (!$result || $cmail->error) {
+
+ if (!$result || !empty($cmail->error) || !empty($cmail->errors)) {
$erroremail .= ($erroremail ? ', ' : '').$cmail->error;
$this->errors[] = $cmail->error;
if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors;
+ } else {
+ // Initialisation of datas of object to call trigger
+ if (is_object($object)) {
+ $actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically
+ $attachedfiles = array();
+
+ $object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
+ $object->actionmsg = $arraydefaultmessage->topic."\n".$arraydefaultmessage->content; // Long text
+ $object->actionmsg2 = $langs->transnoentities("PartnershipSentByEMail", $object->ref);; // Short text ($langs->transnoentities('MailSentBy')...);
+ if (!empty($conf->global->MAIN_MAIL_REPLACE_EVENT_TITLE_BY_EMAIL_SUBJECT)) {
+ $object->actionmsg2 = $subject; // Short text
+ }
+
+ $object->trackid = $trackid;
+ $object->fk_element = $object->id;
+ $object->elementtype = $object->element;
+ if (is_array($attachedfiles) && count($attachedfiles) > 0) {
+ $object->attachedfiles = $attachedfiles;
+ }
+
+ $object->email_from = $from;
+ $object->email_subject = $subject;
+ $object->email_to = $sendto;
+ $object->email_subject = $subject;
+
+ $triggersendname = 'PARTNERSHIP_SENTBYMAIL';
+ // Call of triggers (you should have set $triggersendname to execute trigger)
+ if (!empty($triggersendname)) {
+ $result = $object->call_trigger($triggersendname, $user);
+ if ($result < 0) {
+ $error++;
+ }
+ }
+ // End call of triggers
+ }
}
}
}
@@ -215,16 +258,19 @@ class PartnershipUtils
*
* CAN BE A CRON TASK
*
- * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK)
+ * @param int $maxpercall Max per call
+ * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK)
*/
- public function doWarningOfPartnershipIfDolibarrBacklinkNotfound()
+ public function doWarningOfPartnershipIfDolibarrBacklinkNotfound($maxpercall = 0)
{
global $conf, $langs, $user;
$managedfor = getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR');
$partnership = new Partnership($this->db);
- $MAXPERCALL = (empty($conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL) ? 10 : $conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL); // Limit to 10 per call
+ if (empty($maxpercall)) {
+ $maxpercall = getDolGlobalInt('PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL', 10);
+ }
$langs->loadLangs(array("partnership", "member"));
@@ -233,39 +279,36 @@ class PartnershipUtils
$this->output = '';
$this->error = '';
$partnershipsprocessed = array();
+ $emailnotfound = '';
+ $websitenotfound = '';
- $gracedelay = $conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL;
+ /*$gracedelay = getDolGlobalInt('PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL');
if ($gracedelay < 1) {
$this->error = 'BadValueForDelayBeforeCancelCheckSetup';
return -1;
- }
+ }*/
$fk_partner = ($managedfor == 'member') ? 'fk_member' : 'fk_soc';
dol_syslog(get_class($this)."::doWarningOfPartnershipIfDolibarrBacklinkNotfound Warning of partnership");
$now = dol_now();
- $datetotest = dol_time_plus_duree($now, -1 * abs($gracedelay), 'd');
+ //$datetotest = dol_time_plus_duree($now, -1 * abs($gracedelay), 'd');
$this->db->begin();
$sql = "SELECT p.rowid, p.status, p.".$fk_partner;
- $sql .= ", p.last_check_backlink";
-
+ $sql .= ", p.url_to_check, p.last_check_backlink";
$sql .= ', partner.url, partner.email';
-
$sql .= " FROM ".MAIN_DB_PREFIX."partnership as p";
-
if ($managedfor == 'member') {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as partner on (partner.rowid = p.fk_member)";
} else {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as partner on (partner.rowid = p.fk_soc)";
}
-
- $sql .= " WHERE 1 = 1";
- $sql .= " AND p.".$fk_partner." > 0";
- $sql .= " AND p.status = ".((int) $partnership::STATUS_APPROVED); // Only accepted not yet canceled
- $sql .= " AND (p.last_check_backlink IS NULL OR p.last_check_backlink <= '".$this->db->idate($now - 7 * 24 * 3600)."')"; // Every week, check that website contains a link to dolibarr.
+ $sql .= " WHERE p.".$fk_partner." > 0";
+ $sql .= " AND p.status = ".((int) $partnership::STATUS_APPROVED); // Only accepted and not yet canceled
+ $sql .= " AND (p.last_check_backlink IS NULL OR p.last_check_backlink <= '".$this->db->idate($now - 24 * 3600)."')"; // Never more than 1 check every day to check that website contains a referal link.
$sql .= $this->db->order('p.rowid', 'ASC');
// Limit is managed into loop later
@@ -274,16 +317,17 @@ class PartnershipUtils
$numofexpiredmembers = $this->db->num_rows($resql);
$somethingdoneonpartnership = 0;
$ifetchpartner = 0;
- $websitenotfound = '';
while ($ifetchpartner < $numofexpiredmembers) {
$ifetchpartner++;
$obj = $this->db->fetch_object($resql);
if ($obj) {
- if (!empty($partnershipsprocessed[$obj->rowid])) continue;
+ if (!empty($partnershipsprocessed[$obj->rowid])) {
+ continue;
+ }
- if ($somethingdoneonpartnership >= $MAXPERCALL) {
- dol_syslog("We reach the limit of ".$MAXPERCALL." partnership processed, so we quit loop for this batch doWarningOfPartnershipIfDolibarrBacklinkNotfound to avoid to reach email quota.", LOG_WARNING);
+ if ($somethingdoneonpartnership >= $maxpercall) {
+ dol_syslog("We reach the limit of ".$maxpercall." partnership processed, so we quit loop for this batch doWarningOfPartnershipIfDolibarrBacklinkNotfound to avoid to reach email quota.", LOG_WARNING);
break;
}
@@ -298,7 +342,7 @@ class PartnershipUtils
$fk_partner = $object->fk_soc;
}
- $website = $obj->url;
+ $website = (empty($obj->url_to_check) ? $obj->url : $obj->url_to_check);
if (empty($website)) {
$websitenotfound .= ($websitenotfound ? ', ' : '').'Website not found for id="'.$fk_partner.'"'."\n";
@@ -309,51 +353,101 @@ class PartnershipUtils
if (!$backlinkfound) {
$tmpcount = $object->count_last_url_check_error + 1;
- if ($tmpcount > 2 && $tmpcount <= 4) { // Send Warning Email
- if (!empty($obj->email)) {
- $emailnotfound .= ($emailnotfound ? ', ' : '').'Email not found for id="'.$fk_partner.'"'."\n";
- } else {
- $labeltemplate = '(SendingEmailOnPartnershipWillSoonBeCanceled)';
+ $nbminbacklinkerrorforcancel = getDolGlobalString('PARTNERSHIP_MIN_BACKLINK_ERROR_FOR_CANCEL', 3);
+ $nbmaxbacklinkerrorforcancel = getDolGlobalString('PARTNERSHIP_MAX_BACKLINK_ERROR_FOR_CANCEL', $nbminbacklinkerrorforcancel + 2);
- dol_syslog("Now we will send an email to partner id=".$fk_partner." with label ".$labeltemplate);
+ // If $nbminbacklinkerrorforemail = 0, no autoemail
+ if ($nbminbacklinkerrorforcancel > 0) {
+ if ($tmpcount > $nbminbacklinkerrorforcancel && $tmpcount <= $nbmaxbacklinkerrorforcancel) { // Send Warning Email
+ if (!empty($obj->email)) {
+ $emailnotfound .= ($emailnotfound ? ', ' : '').'Email not found for id="'.$fk_partner.'"'."\n";
+ } else {
+ // Example: 'SendingEmailOnPartnershipWillSoonBeCanceled'
+ $labeltemplate = '('.getDolGlobalString('PARTNERSHIP_SENDMAIL_IF_NO_LINK', 'SendingEmailOnPartnershipWillSoonBeCanceled').')';
- // Send deployment email
- include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
- include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
- $formmail = new FormMail($this->db);
+ dol_syslog("Now we will send an email to partner id=".$fk_partner." with label ".$labeltemplate);
- // Define output language
- $outputlangs = $langs;
- $newlang = '';
- if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
- if (!empty($newlang)) {
- $outputlangs = new Translate("", $conf);
- $outputlangs->setDefaultLang($newlang);
- $outputlangs->loadLangs(array('main', 'member', 'partnership'));
- }
-
- $arraydefaultmessage = $formmail->getEMailTemplate($this->db, 'partnership_send', $user, $outputlangs, 0, 1, $labeltemplate);
-
- $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
- complete_substitutions_array($substitutionarray, $outputlangs, $object);
-
- $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs);
- $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs);
- $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
-
- $to = $obj->email;
-
- $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1);
- $result = $cmail->sendfile();
- if (!$result || $cmail->error) {
- $erroremail .= ($erroremail ? ', ' : '').$cmail->error;
- $this->errors[] = $cmail->error;
- if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors;
+ // Send deployment email
+ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
+ $formmail = new FormMail($this->db);
+
+ // Define output language
+ $outputlangs = $langs;
+ $newlang = '';
+ if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
+ if (!empty($newlang)) {
+ $outputlangs = new Translate("", $conf);
+ $outputlangs->setDefaultLang($newlang);
+ $outputlangs->loadLangs(array('main', 'member', 'partnership'));
+ }
+
+ $arraydefaultmessage = $formmail->getEMailTemplate($this->db, 'partnership_send', $user, $outputlangs, 0, 1, $labeltemplate);
+
+ $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
+ complete_substitutions_array($substitutionarray, $outputlangs, $object);
+
+ $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs);
+ $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs);
+ $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
+
+ $sendto = $obj->email;
+
+ $trackid = 'par'.$object->id;
+ $sendcontext = 'standard';
+
+ $cmail = new CMailFile($subject, $sendto, $from, $msg, array(), array(), array(), '', '', 0, 1, '', '', $trackid, '', $sendcontext);
+
+ $result = $cmail->sendfile();
+
+ if (!$result || !empty($cmail->error) || !empty($cmail->errors)) {
+ $erroremail .= ($erroremail ? ', ' : '').$cmail->error;
+ $this->errors[] = $cmail->error;
+ if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors;
+ } else {
+ // Initialisation of datas of object to call trigger
+ if (is_object($object)) {
+ $actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically
+ $attachedfiles = array();
+
+ if ($managedfor != 'member') {
+ $object->socid = $fk_partner; // To link to a company
+ }
+ $object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
+ $object->actionmsg = $arraydefaultmessage->topic."\n".$arraydefaultmessage->content; // Long text
+ $object->actionmsg2 = $langs->transnoentities("PartnershipSentByEMail", $object->ref);; // Short text ($langs->transnoentities('MailSentBy')...);
+ if (!empty($conf->global->MAIN_MAIL_REPLACE_EVENT_TITLE_BY_EMAIL_SUBJECT)) {
+ $object->actionmsg2 = $subject; // Short text
+ }
+
+ $object->trackid = $trackid;
+ $object->fk_element = $object->id;
+ $object->elementtype = $object->element;
+ if (is_array($attachedfiles) && count($attachedfiles) > 0) {
+ $object->attachedfiles = $attachedfiles;
+ }
+
+ $object->email_from = $from;
+ $object->email_subject = $subject;
+ $object->email_to = $sendto;
+ $object->email_subject = $subject;
+
+ $triggersendname = 'PARTNERSHIP_SENTBYMAIL';
+ // Call of triggers (you should have set $triggersendname to execute trigger)
+ if (!empty($triggersendname)) {
+ $result = $object->call_trigger($triggersendname, $user);
+ if ($result < 0) {
+ $error++;
+ }
+ }
+ // End call of triggers
+ }
+ }
}
+ } elseif ($tmpcount > $nbmaxbacklinkerrorforcancel) { // Cancel Partnership
+ $object->status = $object::STATUS_CANCELED;
+ $object->reason_decline_or_cancel = $langs->trans('BacklinkNotFoundOnPartnerWebsite');
}
- } elseif ($tmpcount > 4) { // Cancel Partnership
- $object->status = $object::STATUS_CANCELED;
- $object->reason_decline_or_cancel = $langs->trans('BacklinkNotFoundOnPartnerWebsite');
}
$object->count_last_url_check_error = $tmpcount;
@@ -364,7 +458,7 @@ class PartnershipUtils
$partnershipsprocessed[$object->id] = $object->ref;
- $object->last_check_backlink = $this->db->idate($now);
+ $object->last_check_backlink = $now;
$object->update($user);
}
@@ -376,18 +470,16 @@ class PartnershipUtils
if (!$error) {
$this->db->commit();
- $this->output = $numofexpiredmembers.' partnership checked'."\n";
- if ($erroremail) $this->output .= '. Got errors when sending some email : '.$erroremail."\n";
- if ($emailnotfound) $this->output .= '. Email not found for some partner : '.$emailnotfound."\n";
- if ($websitenotfound) $this->output .= '. Website not found for some partner : '.$websitenotfound."\n";
+ $this->output = "";
} else {
$this->db->rollback();
$this->output = "Rollback after error\n";
- $this->output .= $numofexpiredmembers.' partnership checked'."\n";
- if ($erroremail) $this->output .= '. Got errors when sending some email : '.$erroremail."\n";
- if ($emailnotfound) $this->output .= '. Email not found for some partner : '.$emailnotfound."\n";
- if ($websitenotfound) $this->output .= '. Website not found for some partner : '.$websitenotfound."\n";
}
+ $this->output .= $numofexpiredmembers.' partnership checked'."\n";
+ if ($erroremail) $this->output .= '. Got errors when sending some email : '.$erroremail."\n";
+ if ($emailnotfound) $this->output .= '. Email not found for some partner : '.$emailnotfound."\n";
+ if ($websitenotfound) $this->output .= '. Website not found for some partner : '.$websitenotfound."\n";
+ $this->output .= "\nSQL used to find partnerships to scan: ".$sql;
return ($error ? 1 : 0);
}
@@ -400,7 +492,7 @@ class PartnershipUtils
*/
private function checkDolibarrBacklink($website = null)
{
- global $conf, $langs, $user;
+ global $conf;
$found = 0;
$error = 0;
diff --git a/htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php b/htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php
index 821a9e67303..c3b3a888b54 100644
--- a/htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php
+++ b/htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php
@@ -3,7 +3,7 @@
* Copyright (C) 2004-2007 Laurent Destailleur
* Copyright (C) 2005-2009 Regis Houssin
* Copyright (C) 2008 Raphael Bertrand (Resultic)
- * Copyright (C) 2019 Frédéric France
+ * Copyright (C) 2019-2023 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,7 +26,7 @@
* \brief File containing class for advanced numbering model of Partnership
*/
-dol_include_once('/partnership/core/modules/partnership/modules_partnership.php');
+require_once DOL_DOCUMENT_ROOT.'/partnership/core/modules/partnership/modules_partnership.php';
/**
@@ -54,22 +54,23 @@ class mod_partnership_advanced extends ModeleNumRefPartnership
/**
* Returns the description of the numbering model
*
+ * @param Translate $langs Lang object to use for output
* @return string Descriptive text
*/
- public function info()
+ public function info($langs)
{
- global $conf, $langs, $db;
+ global $db;
$langs->load("bills");
$form = new Form($db);
- $texte = $langs->trans('GenericNumRefModelDesc')." \n";
- $texte .= '';
- $texte .= ' ';
- $texte .= ' ';
- $texte .= ' ';
- $texte .= '';
+ $text = $langs->trans('GenericNumRefModelDesc')." \n";
+ $text .= '';
+ $text .= ' ';
+ $text .= ' ';
+ $text .= ' ';
+ $text .= '';
$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Partnership"), $langs->transnoentities("Partnership"));
$tooltip .= $langs->trans("GenericMaskCodes2");
@@ -78,17 +79,17 @@ class mod_partnership_advanced extends ModeleNumRefPartnership
$tooltip .= $langs->trans("GenericMaskCodes5");
// Parametrage du prefix
- $texte .= ''.$langs->trans("Mask").': ';
- $texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
+ $text .= ''.$langs->trans("Mask").': ';
+ $text .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
- $texte .= ' ';
+ $text .= ' ';
- $texte .= ' ';
+ $text .= '';
- $texte .= '
';
- $texte .= ' ';
+ $text .= '
';
+ $text .= ' ';
- return $texte;
+ return $text;
}
/**
diff --git a/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php b/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php
index 5de4b07f215..c7409aba85e 100644
--- a/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php
+++ b/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php
@@ -22,7 +22,7 @@
* \ingroup partnership
* \brief File of class to manage Partnership numbering rules standard
*/
-dol_include_once('/partnership/core/modules/partnership/modules_partnership.php');
+require_once DOL_DOCUMENT_ROOT.'/partnership/core/modules/partnership/modules_partnership.php';
/**
@@ -52,11 +52,11 @@ class mod_partnership_standard extends ModeleNumRefPartnership
/**
* Return description of numbering module
*
- * @return string Text with description
+ * @param Translate $langs Lang object to use for output
+ * @return string Text with description
*/
- public function info()
+ public function info($langs)
{
- global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
diff --git a/htdocs/partnership/core/modules/partnership/modules_partnership.php b/htdocs/partnership/core/modules/partnership/modules_partnership.php
index 4d1f6c0b107..dafab0cc8ed 100644
--- a/htdocs/partnership/core/modules/partnership/modules_partnership.php
+++ b/htdocs/partnership/core/modules/partnership/modules_partnership.php
@@ -29,6 +29,7 @@
*/
require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit
@@ -66,93 +67,7 @@ abstract class ModelePDFPartnership extends CommonDocGenerator
/**
* Parent class to manage numbering of Partnership
*/
-abstract class ModeleNumRefPartnership
+abstract class ModeleNumRefPartnership extends CommonNumRefGenerator
{
- /**
- * @var string Error code (or message)
- */
- public $error = '';
-
- /**
- * Return if a module can be used or not
- *
- * @return boolean true if module can be used
- */
- public function isEnabled()
- {
- return true;
- }
-
- /**
- * Returns the default description of the numbering template
- *
- * @return string Descriptive text
- */
- public function info()
- {
- global $langs;
- $langs->load("partnership");
- return $langs->trans("NoDescription");
- }
-
- /**
- * Returns an example of numbering
- *
- * @return string Example
- */
- public function getExample()
- {
- global $langs;
- $langs->load("partnership");
- return $langs->trans("NoExample");
- }
-
- /**
- * Checks if the numbers already in the database do not
- * cause conflicts that would prevent this numbering working.
- *
- * @param Object $object Object we need next value for
- * @return boolean false if conflict, true if ok
- */
- public function canBeActivated($object)
- {
- return true;
- }
-
- /**
- * Returns next assigned value
- *
- * @param Object $object Object we need next value for
- * @return string Valeur
- */
- public function getNextValue($object)
- {
- global $langs;
- return $langs->trans("NotAvailable");
- }
-
- /**
- * Returns version of numbering module
- *
- * @return string Valeur
- */
- public function getVersion()
- {
- global $langs;
- $langs->load("admin");
-
- if ($this->version == 'development') {
- return $langs->trans("VersionDevelopment");
- }
- if ($this->version == 'experimental') {
- return $langs->trans("VersionExperimental");
- }
- if ($this->version == 'dolibarr') {
- return DOL_VERSION;
- }
- if ($this->version) {
- return $this->version;
- }
- return $langs->trans("NotAvailable");
- }
+ // No overload code
}
diff --git a/htdocs/partnership/partnership_card.php b/htdocs/partnership/partnership_card.php
index bf51b1fe5df..d1fb24eb493 100644
--- a/htdocs/partnership/partnership_card.php
+++ b/htdocs/partnership/partnership_card.php
@@ -444,12 +444,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}
*/
$morehtmlref .= '';
- if (!isset($npfilter)) {
- $npfilter = "";
- }
- if ($managedfor == 'member') $npfilter .= " AND te.fk_member > 0 "; else $npfilter .= " AND te.fk_soc > 0 ";
- $object->next_prev_filter = $npfilter;
+ if ($managedfor == 'member') {
+ $object->next_prev_filter = "te.fk_member > 0";
+ } else {
+ $object->next_prev_filter = "te.fk_soc > 0";
+ }
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php
index 98d78e0a2b2..a6653c17a17 100644
--- a/htdocs/partnership/partnership_list.php
+++ b/htdocs/partnership/partnership_list.php
@@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php';
@@ -286,6 +287,7 @@ if (empty($reshook)) {
*/
$form = new Form($db);
+$companystatic = new Societe($db);
$now = dol_now();
@@ -863,13 +865,26 @@ while ($i < $imaxinloop) {
// Store properties in $object
$object->setVarsFromFetchObj($obj);
+ $object->thirdparty = null;
+ if ($obj->fk_soc > 0) {
+ if (!empty($conf->cache['thirdparty'][$obj->fk_soc])) {
+ $companyobj = $conf->cache['thirdparty'][$obj->fk_soc];
+ } else {
+ $companyobj = new Societe($db);
+ $companyobj->fetch($obj->fk_soc);
+ $conf->cache['thirdparty'][$obj->fk_soc] = $companyobj;
+ }
+
+ $object->thirdparty = $companyobj;
+ }
+
if ($mode == 'kanban') {
if ($i == 0) {
print '';
print '';
}
// Output Kanban
- print $object->getKanbanView('', array('selected' => in_array($object->id, $arrayofselected)));
+ print $object->getKanbanView('', array('thirdparty'=>$object->thirdparty, 'selected' => in_array($object->id, $arrayofselected)));
if ($i == ($imaxinloop - 1)) {
print '
';
print ' ';
@@ -914,7 +929,7 @@ while ($i < $imaxinloop) {
if (!empty($arrayfields['t.'.$key]['checked'])) {
print '$key)) {
+ if (preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) {
print ' title="'.dol_escape_htmltag($object->$key).'"';
}
print '>';
diff --git a/htdocs/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php
index 79003956f12..db949620440 100644
--- a/htdocs/paypal/lib/paypal.lib.php
+++ b/htdocs/paypal/lib/paypal.lib.php
@@ -145,7 +145,7 @@ function print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType,
$ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]);
if ($ErrorCode == 10729) {
- $mesg .= "PayPal can't accept payments for this thirdparty. An address is defined but is not complete (missing State). Ask system administrator to fix address or to setup Paypal module to accept payments even on not complete addresses (remove option PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS). \n";
+ $mesg = "PayPal can't accept payments for this thirdparty. An address is defined but is not complete (missing State). Ask system administrator to fix address or to setup Paypal module to accept payments even on not complete addresses (remove option PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS). \n";
} else {
$mesg = $langs->trans('SetExpressCheckoutAPICallFailed')." \n";
$mesg .= $langs->trans('DetailedErrorMessage').": ".$ErrorLongMsg." \n";
diff --git a/htdocs/product/admin/product_tools.php b/htdocs/product/admin/product_tools.php
index 1bf36688f93..02e0f52e0fc 100644
--- a/htdocs/product/admin/product_tools.php
+++ b/htdocs/product/admin/product_tools.php
@@ -161,7 +161,7 @@ if ($action == 'convert') {
}
$newvat = str_replace('*', '', $newvatrate);
$localtaxes_type = getLocalTaxesFromRate($newvat, 0, $mysoc, $mysoc);
- $newnpr = $objectstatic->recuperableonly;
+ $newnpr = $objectstatic->tva_npr;
$newdefaultvatcode = $vat_src_code_new;
$newlevel = 0;
if (!empty($price_base_type) && !$updatelevel1) {
@@ -226,7 +226,7 @@ if ($action == 'convert') {
//if ($newminprice > $newprice) $newminprice=$newprice;
$newvat = str_replace('*', '', $newvatrate);
$localtaxes_type = getLocalTaxesFromRate($newvat, 0, $mysoc, $mysoc);
- //$newnpr=$objectstatic2->recuperableonly;
+ //$newnpr=$objectstatic2->tva_npr;
$newnpr = 0;
$newdefaultvatcode = $vat_src_code_new;
diff --git a/htdocs/product/agenda.php b/htdocs/product/agenda.php
index e77aacc195d..ed5d456b3a5 100644
--- a/htdocs/product/agenda.php
+++ b/htdocs/product/agenda.php
@@ -161,7 +161,7 @@ if ($id > 0 || $ref) {
print dol_get_fiche_head($head, 'agenda', $titre, -1, $picto);
$linkback = ''.$langs->trans("BackToList").' ';
- $object->next_prev_filter = " fk_product_type = ".$object->type;
+ $object->next_prev_filter = "fk_product_type = ".((int) $object->type);
$shownav = 1;
if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php
index 3f60355301f..65ba3593630 100644
--- a/htdocs/product/ajax/products.php
+++ b/htdocs/product/ajax/products.php
@@ -195,7 +195,7 @@ if ($action == 'fetch' && !empty($id)) {
if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') && !empty($socid)) {
require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php';
- $prodcustprice = new Productcustomerprice($db);
+ $prodcustprice = new ProductCustomerPrice($db);
$filter = array('t.fk_product' => $object->id, 't.fk_soc' => $socid);
diff --git a/htdocs/product/canvas/product/actions_card_product.class.php b/htdocs/product/canvas/product/actions_card_product.class.php
index 324cdc1324c..00e171b389d 100644
--- a/htdocs/product/canvas/product/actions_card_product.class.php
+++ b/htdocs/product/canvas/product/actions_card_product.class.php
@@ -28,10 +28,22 @@ include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
*/
class ActionsCardProduct
{
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
+ public $dirmodule;
public $targetmodule;
public $canvas;
public $card;
+ public $name;
+ public $definition;
+ public $fieldListName;
+ public $next_prev_filter;
+
+ //! Object container
public $object;
//! Template container
@@ -40,6 +52,16 @@ class ActionsCardProduct
// List of fiels for action=list
public $field_list = array();
+ /**
+ * @var string Error code (or message)
+ */
+ public $error = '';
+
+ /**
+ * @var string[] Error codes (or messages)
+ */
+ public $errors = array();
+
/**
* Constructor
@@ -59,7 +81,7 @@ class ActionsCardProduct
$this->card = $card;
$this->name = "product";
- $this->definition = "Product canvas (défaut)";
+ $this->definition = "Product canvas (default)";
$this->fieldListName = "product_default";
$this->next_prev_filter = "canvas='product'";
}
diff --git a/htdocs/product/canvas/product/tpl/card_view.tpl.php b/htdocs/product/canvas/product/tpl/card_view.tpl.php
index 7e44b0daf2f..a5a8fedc969 100644
--- a/htdocs/product/canvas/product/tpl/card_view.tpl.php
+++ b/htdocs/product/canvas/product/tpl/card_view.tpl.php
@@ -33,7 +33,7 @@ $titre = $langs->trans("CardProduct".$object->type);
print dol_get_fiche_head($head, 'card', $titre, -1, 'product');
$linkback = ''.$langs->trans("BackToList").' ';
-$object->next_prev_filter = " fk_product_type = ".$object->type;
+$object->next_prev_filter = "fk_product_type = ".((int) $object->type);
$shownav = 1;
if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
diff --git a/htdocs/product/canvas/service/actions_card_service.class.php b/htdocs/product/canvas/service/actions_card_service.class.php
index 41ae5c3041e..ae378bd39e2 100644
--- a/htdocs/product/canvas/service/actions_card_service.class.php
+++ b/htdocs/product/canvas/service/actions_card_service.class.php
@@ -28,10 +28,24 @@ include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
*/
class ActionsCardService
{
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
+ public $dirmodule;
public $targetmodule;
public $canvas;
public $card;
+ public $name;
+ public $definition;
+ public $fieldListName;
+ public $next_prev_filter;
+
+ //! Object container
+ public $object;
+
//! Template container
public $tpl = array();
@@ -45,18 +59,30 @@ class ActionsCardService
public $price;
public $price_min;
+ /**
+ * @var string Error code (or message)
+ */
+ public $error = '';
+
+ /**
+ * @var string[] Error codes (or messages)
+ */
+ public $errors = array();
+
/**
* Constructor
*
- * @param DoliDB $db Handler acces base de donnees
- * @param string $targetmodule Name of directory of module where canvas is stored
+ * @param DoliDB $db Database handler
+ * @param string $dirmodule Name of directory of module
+ * @param string $targetmodule Name of directory where canvas is stored
* @param string $canvas Name of canvas
* @param string $card Name of tab (sub-canvas)
*/
- public function __construct($db, $targetmodule, $canvas, $card)
+ public function __construct($db, $dirmodule, $targetmodule, $canvas, $card)
{
$this->db = $db;
+ $this->dirmodule = $dirmodule;
$this->targetmodule = $targetmodule;
$this->canvas = $canvas;
$this->card = $card;
diff --git a/htdocs/product/canvas/service/tpl/card_view.tpl.php b/htdocs/product/canvas/service/tpl/card_view.tpl.php
index 3236e7e7074..1bea6ffe23c 100644
--- a/htdocs/product/canvas/service/tpl/card_view.tpl.php
+++ b/htdocs/product/canvas/service/tpl/card_view.tpl.php
@@ -33,7 +33,7 @@ $titre = $langs->trans("CardProduct".$object->type);
print dol_get_fiche_head($head, 'card', $titre, -1, 'service');
$linkback = ''.$langs->trans("BackToList").' ';
-$object->next_prev_filter = " fk_product_type = ".$object->type;
+$object->next_prev_filter = " fk_product_type = ".((int) $object->type);
$shownav = 1;
if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
diff --git a/htdocs/product/card.php b/htdocs/product/card.php
index e25729427b1..093814c3e08 100644
--- a/htdocs/product/card.php
+++ b/htdocs/product/card.php
@@ -152,17 +152,18 @@ if ($id > 0 || !empty($ref)) {
if ($result < 0) {
dol_print_error($db, $object->error, $object->errors);
}
+ $entity = (!empty($object->entity) ? $object->entity : $conf->entity);
if (isModEnabled("product")) {
- $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref);
+ $upload_dir = $conf->product->multidir_output[$entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref);
} elseif (isModEnabled("service")) {
- $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref);
+ $upload_dir = $conf->service->multidir_output[$entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref);
}
if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) { // For backward compatiblity, we scan also old dirs
if (isModEnabled("product")) {
- $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos";
+ $upload_dirold = $conf->product->multidir_output[$entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos";
} else {
- $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos";
+ $upload_dirold = $conf->service->multidir_output[$entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos";
}
}
}
@@ -506,10 +507,11 @@ if (empty($reshook)) {
if (!$error) {
$units = GETPOST('units', 'int');
- $object->ref = $ref;
- $object->label = GETPOST('label', $label_security_check);
- $object->price_base_type = GETPOST('price_base_type', 'aZ09');
- $object->mandatory_period = !empty(GETPOST("mandatoryperiod", 'alpha')) ? 1 : 0;
+ $object->entity = $conf->entity;
+ $object->ref = $ref;
+ $object->label = GETPOST('label', $label_security_check);
+ $object->price_base_type = GETPOST('price_base_type', 'aZ09');
+ $object->mandatory_period = !empty(GETPOST("mandatoryperiod", 'alpha')) ? 1 : 0;
if ($object->price_base_type == 'TTC') {
$object->price_ttc = GETPOST('price');
} else {
@@ -908,7 +910,9 @@ if (empty($reshook)) {
} else {
if ($object->id > 0) {
$error = 0;
- $clone = dol_clone($object, 2);
+ // We clone object to avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object.
+ // We use native clone to keep this->db valid and allow to use later all the methods of object.
+ $clone = dol_clone($object, 1);
$clone->id = null;
$clone->ref = GETPOST('clone_ref', 'alphanohtml');
@@ -1067,7 +1071,7 @@ if (empty($reshook)) {
} elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php';
- $prodcustprice = new Productcustomerprice($db);
+ $prodcustprice = new ProductCustomerPrice($db);
$filter = array('t.fk_product' => $object->id, 't.fk_soc' => $soc->id);
@@ -2059,7 +2063,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
// Default warehouse
print ' '.$langs->trans("DefaultWarehouse").' ';
print img_picto($langs->trans("DefaultWarehouse"), 'stock', 'class="pictofixedwidth"');
- print $formproduct->selectWarehouses((GETPOSTISSET('fk_default_warehouse') ? GETPOST('fk_default_warehouse') : $object->fk_default_warehouse), 'fk_default_warehouse', 'warehouseopen', 1);
+ print $formproduct->selectWarehouses((GETPOSTISSET('fk_default_warehouse') ? GETPOST('fk_default_warehouse') : $object->fk_default_warehouse), 'fk_default_warehouse', 'warehouseopen', 1, 0, 0, '', 0, 0, array(), 'maxwidth500 widthcentpercentminusxx');
print ' ';
print ' ';
print ' ';
@@ -2349,7 +2353,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print dol_get_fiche_head($head, 'card', $titre, -1, $picto);
$linkback = ''.$langs->trans("BackToList").' ';
- $object->next_prev_filter = " fk_product_type = ".$object->type;
+ $object->next_prev_filter = "fk_product_type = ".((int) $object->type);
$shownav = 1;
if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php
index d114d115e0e..1594cd3bd05 100644
--- a/htdocs/product/class/api_products.class.php
+++ b/htdocs/product/class/api_products.class.php
@@ -674,7 +674,7 @@ class Products extends DolibarrApi
if ($result > 0) {
require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php';
- $prodcustprice = new Productcustomerprice($this->db);
+ $prodcustprice = new ProductCustomerPrice($this->db);
$filter = array();
$filter['t.fk_product'] = $id;
if ($thirdparty_id) {
@@ -1047,21 +1047,21 @@ class Products extends DolibarrApi
$sql .= $this->db->plimit($limit, $offset);
}
- $result = $this->db->query($sql);
+ $resql = $this->db->query($sql);
- if (!$result) {
- throw new RestException(503, 'Error when retrieve product attribute list : '.$this->db->lasterror());
+ if (!$resql) {
+ throw new RestException(503, 'Error when retrieving product attribute list : '.$this->db->lasterror());
}
$return = array();
- while ($result = $this->db->fetch_object($query)) {
+ while ($obj = $this->db->fetch_object($resql)) {
$tmp = new ProductAttribute($this->db);
- $tmp->id = $result->rowid;
- $tmp->ref = $result->ref;
- $tmp->ref_ext = $result->ref_ext;
- $tmp->label = $result->label;
- $tmp->position = $result->position;
- $tmp->entity = $result->entity;
+ $tmp->id = $obj->rowid;
+ $tmp->ref = $obj->ref;
+ $tmp->ref_ext = $obj->ref_ext;
+ $tmp->label = $obj->label;
+ $tmp->position = $obj->position;
+ $tmp->entity = $obj->entity;
$return[] = $this->_cleanObjectDatas($tmp);
}
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 69983d41c45..61e5cc26cb6 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -173,6 +173,7 @@ class Product extends CommonObject
public $multiprices = array();
public $multiprices_ttc = array();
public $multiprices_base_type = array();
+ public $multiprices_default_vat_code = array();
public $multiprices_min = array();
public $multiprices_min_ttc = array();
public $multiprices_tva_tx = array();
@@ -184,6 +185,11 @@ class Product extends CommonObject
public $prices_by_qty_id = array();
public $prices_by_qty_list = array();
+ /**
+ * @var int price level set after updateprice for trigger
+ */
+ public $level;
+
//! Array for multilangs
public $multilangs = array();
@@ -194,13 +200,9 @@ class Product extends CommonObject
public $tva_tx;
/**
- * int French VAT NPR (0 or 1)
+ * int French VAT NPR is used (0 or 1)
*/
public $tva_npr = 0;
- /**
- * @deprecated
- */
- public $recuperableonly;
//! Default discount percent
public $remise_percent;
@@ -224,12 +226,12 @@ class Product extends CommonObject
public $packaging;
- public $lifetime;
+ public $lifetime; // In seconds
public $qc_frequency;
/**
- * Stock real
+ * Stock real (denormalized data)
*
* @var int
*/
@@ -379,23 +381,17 @@ class Product extends CommonObject
public $accountancy_code_buy_export;
/**
- * Main Barcode value
- *
- * @var string
+ * @var string Main Barcode value
*/
public $barcode;
/**
- * Main Barcode type ID
- *
- * @var int
+ * @var int Main Barcode type ID
*/
public $barcode_type;
/**
- * Main Barcode type code
- *
- * @var string
+ * @var string Main Barcode type code
*/
public $barcode_type_code;
@@ -439,8 +435,6 @@ class Product extends CommonObject
//! Contains detail of stock of product into each warehouse
public $stock_warehouse = array();
- public $oldcopy;
-
/**
* @var int Default warehouse Id
*/
@@ -508,11 +502,11 @@ class Product extends CommonObject
*/
public $is_object_used;
+ public $is_sousproduit_qty;
+ public $is_sousproduit_incdec;
+
+ public $mandatory_period;
- /**
- *
- */
- public $mandatory_period;
/**
* 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
@@ -809,7 +803,7 @@ class Product extends CommonObject
$sql .= ", mandatory_period";
$sql .= ") VALUES (";
$sql .= "'".$this->db->idate($now)."'";
- $sql .= ", ".((int) $conf->entity);
+ $sql .= ", ".(!empty($this->entity) ? (int) $this->entity : (int) $conf->entity);
$sql .= ", '".$this->db->escape($this->ref)."'";
$sql .= ", ".(!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null");
$sql .= ", ".price2num($price_min_ht);
@@ -1898,7 +1892,7 @@ class Product extends CommonObject
*/
public function getSellPrice($thirdparty_seller, $thirdparty_buyer, $pqp = 0)
{
- global $conf, $db, $hookmanager, $action;
+ global $conf, $hookmanager, $action;
// Call hook if any
if (is_object($hookmanager)) {
@@ -1943,7 +1937,7 @@ class Product extends CommonObject
// If price per customer
require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php';
- $prodcustprice = new Productcustomerprice($this->db);
+ $prodcustprice = new ProductCustomerPrice($this->db);
$filter = array('t.fk_product' => $this->id, 't.fk_soc' => $thirdparty_buyer->id);
@@ -2255,7 +2249,7 @@ class Product extends CommonObject
if (!empty($newdefaultvatcode)) {
global $mysoc;
// Get record from code
- $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
+ $sql = "SELECT t.rowid, t.code, t.recuperableonly as tva_npr, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
$sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$this->db->escape($mysoc->country_code)."'";
$sql .= " AND t.taux = ".((float) $newdefaultvatcode)." AND t.active = 1";
@@ -2264,7 +2258,7 @@ class Product extends CommonObject
if ($resql) {
$obj = $this->db->fetch_object($resql);
if ($obj) {
- $npr = $obj->recuperableonly;
+ $npr = $obj->tva_npr;
$localtax1 = $obj->localtax1;
$localtax2 = $obj->localtax2;
$localtaxtype1 = $obj->localtax1_type;
@@ -2291,18 +2285,18 @@ class Product extends CommonObject
// Ne pas mettre de quote sur les numeriques decimaux.
// Ceci provoque des stockages avec arrondis en base au lieu des valeurs exactes.
$sql = "UPDATE ".$this->db->prefix()."product SET";
- $sql .= " price_base_type='".$this->db->escape($newpricebase)."',";
- $sql .= " price=".$price.",";
- $sql .= " price_ttc=".$price_ttc.",";
- $sql .= " price_min=".$price_min.",";
- $sql .= " price_min_ttc=".$price_min_ttc.",";
- $sql .= " localtax1_tx=".($localtax1 >= 0 ? $localtax1 : 'NULL').",";
- $sql .= " localtax2_tx=".($localtax2 >= 0 ? $localtax2 : 'NULL').",";
- $sql .= " localtax1_type=".($localtaxtype1 != '' ? "'".$this->db->escape($localtaxtype1)."'" : "'0'").",";
- $sql .= " localtax2_type=".($localtaxtype2 != '' ? "'".$this->db->escape($localtaxtype2)."'" : "'0'").",";
- $sql .= " default_vat_code=".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").",";
- $sql .= " tva_tx='".price2num($newvat)."',";
- $sql .= " recuperableonly='".$this->db->escape($newnpr)."'";
+ $sql .= " price_base_type = '".$this->db->escape($newpricebase)."',";
+ $sql .= " price = ".(float) $price.",";
+ $sql .= " price_ttc = ".(float) $price_ttc.",";
+ $sql .= " price_min = ".(float) $price_min.",";
+ $sql .= " price_min_ttc = ".(float) $price_min_ttc.",";
+ $sql .= " localtax1_tx = ".($localtax1 >= 0 ? (float) $localtax1 : 'NULL').",";
+ $sql .= " localtax2_tx = ".($localtax2 >= 0 ? (float) $localtax2 : 'NULL').",";
+ $sql .= " localtax1_type = ".($localtaxtype1 != '' ? "'".$this->db->escape($localtaxtype1)."'" : "'0'").",";
+ $sql .= " localtax2_type = ".($localtaxtype2 != '' ? "'".$this->db->escape($localtaxtype2)."'" : "'0'").",";
+ $sql .= " default_vat_code = ".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").",";
+ $sql .= " tva_tx = ".(float) price2num($newvat).",";
+ $sql .= " recuperableonly = '".$this->db->escape($newnpr)."'";
$sql .= " WHERE rowid = ".((int) $id);
dol_syslog(get_class($this)."::update_price", LOG_DEBUG);
@@ -2527,7 +2521,6 @@ class Product extends CommonObject
$this->tva_tx = $obj->tva_tx;
//! French VAT NPR
$this->tva_npr = $obj->tva_npr;
- $this->recuperableonly = $obj->tva_npr; // For backward compatibility
//! Local taxes
$this->localtax1_tx = $obj->localtax1_tx;
$this->localtax2_tx = $obj->localtax2_tx;
@@ -2817,7 +2810,7 @@ class Product extends CommonObject
$sql .= " FROM ".$this->db->prefix()."mrp_mo as c";
$sql .= " INNER JOIN ".$this->db->prefix()."mrp_production as mp ON mp.fk_mo=c.rowid";
if (empty($user->rights->societe->client->voir) && !$socid) {
- $sql .= "INNER JOIN ".$this->db->prefix()."societe_commerciaux as sc ON sc.fk_soc=c.fk_soc AND sc.fk_user = ".((int) $user->id);
+ $sql .= " INNER JOIN ".$this->db->prefix()."societe_commerciaux as sc ON sc.fk_soc=c.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= " WHERE ";
$sql .= " c.entity IN (".getEntity('mo').")";
@@ -3569,7 +3562,7 @@ class Product extends CommonObject
public function load_stats_facture($socid = 0)
{
// phpcs:enable
- global $db, $conf, $user, $hookmanager, $action;
+ global $conf, $user, $hookmanager, $action;
$sql = "SELECT COUNT(DISTINCT f.fk_soc) as nb_customers, COUNT(DISTINCT f.rowid) as nb,";
$sql .= " COUNT(fd.rowid) as nb_rows, SUM(".$this->db->ifsql('f.type != 2', 'fd.qty', 'fd.qty * -1').") as qty";
@@ -3644,7 +3637,7 @@ class Product extends CommonObject
public function load_stats_facturerec($socid = 0)
{
// phpcs:enable
- global $db, $conf, $user, $hookmanager;
+ global $conf, $user, $hookmanager, $action;
$sql = "SELECT COUNT(DISTINCT f.fk_soc) as nb_customers, COUNT(DISTINCT f.rowid) as nb,";
$sql .= " COUNT(fd.rowid) as nb_rows, SUM(fd.qty) as qty";
@@ -4648,12 +4641,10 @@ class Product extends CommonObject
$sql .= ", multicurrency_tx";
$sql .= ", multicurrency_price";
$sql .= ", multicurrency_price_ttc";
- $sql .= " FROM ".$this->db->prefix()."product_price";
+ $sql .= " FROM ".$this->db->prefix()."product_price ps";
$sql .= " WHERE fk_product = ".((int) $fromId);
+ $sql .= " AND date_price IN (SELECT MAX(pd.date_price) FROM ".$this->db->prefix()."product_price pd WHERE pd.fk_product = ".((int) $fromId)." AND pd.price_level = ps.price_level)";
$sql .= " ORDER BY date_price DESC";
- if ($conf->global->PRODUIT_MULTIPRICES_LIMIT > 0) {
- $sql .= " LIMIT ".$conf->global->PRODUIT_MULTIPRICES_LIMIT;
- }
dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
@@ -5058,7 +5049,7 @@ class Product extends CommonObject
{
global $conf, $langs;
- $langs->load('products', 'other');
+ $langs->loadLangs(array('products', 'other'));
$datas = array();
$nofetch = !empty($params['nofetch']);
@@ -5228,7 +5219,7 @@ class Product extends CommonObject
if ($option !== 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
@@ -6260,7 +6251,7 @@ class Product extends CommonObject
*/
public function generateMultiprices(User $user, $baseprice, $price_type, $price_vat, $npr, $psq)
{
- global $conf, $db;
+ global $conf;
$sql = "SELECT rowid, level, fk_level, var_percent, var_min_percent FROM ".$this->db->prefix()."product_pricerules";
$query = $this->db->query($sql);
@@ -6276,7 +6267,7 @@ class Product extends CommonObject
1 => $baseprice
);
- for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
+ for ($i = 1; $i <= getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT'); $i++) {
$price = $baseprice;
$price_min = $baseprice;
diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php
index 4e40ce28dea..efd93dc7c89 100644
--- a/htdocs/product/class/productcustomerprice.class.php
+++ b/htdocs/product/class/productcustomerprice.class.php
@@ -26,7 +26,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
/**
* File of class to manage predefined price products or services by customer
*/
-class Productcustomerprice extends CommonObject
+class ProductCustomerPrice extends CommonObject
{
/**
* @var string ID to identify managed object
@@ -383,8 +383,6 @@ class Productcustomerprice extends CommonObject
*/
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = array())
{
- global $langs;
-
if (empty($sortfield)) {
$sortfield = "t.rowid";
}
@@ -850,7 +848,7 @@ class Productcustomerprice extends CommonObject
while (($obj = $this->db->fetch_object($resql)) && (empty($error))) {
// find if there is an existing line for the product and the subsidiaries
- $prodsocprice = new Productcustomerprice($this->db);
+ $prodsocprice = new ProductCustomerPrice($this->db);
$filter = array(
't.fk_product' => $this->fk_product, 't.fk_soc' => $obj->rowid
@@ -865,7 +863,7 @@ class Productcustomerprice extends CommonObject
if (count($prodsocprice->lines) > 0) {
// If force update => Update
if (!empty($forceupdateaffiliate)) {
- $prodsocpriceupd = new Productcustomerprice($this->db);
+ $prodsocpriceupd = new ProductCustomerPrice($this->db);
$prodsocpriceupd->fetch($prodsocprice->lines [0]->id);
$prodsocpriceupd->price = $this->price;
@@ -882,7 +880,7 @@ class Productcustomerprice extends CommonObject
}
} else {
// If line do not exits then create it
- $prodsocpricenew = new Productcustomerprice($this->db);
+ $prodsocpricenew = new ProductCustomerPrice($this->db);
$prodsocpricenew->fk_soc = $obj->rowid;
$prodsocpricenew->ref_customer = $obj->ref_customer;
$prodsocpricenew->fk_product = $this->fk_product;
@@ -971,7 +969,7 @@ class Productcustomerprice extends CommonObject
{
$error = 0;
- $object = new Productcustomerprice($this->db);
+ $object = new ProductCustomerPrice($this->db);
$this->db->begin();
diff --git a/htdocs/product/class/productfournisseurprice.class.php b/htdocs/product/class/productfournisseurprice.class.php
index 428c44722d6..8900f769ef5 100644
--- a/htdocs/product/class/productfournisseurprice.class.php
+++ b/htdocs/product/class/productfournisseurprice.class.php
@@ -589,8 +589,12 @@ class ProductFournisseurPrice extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
- if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ $add_save_lastsearch_values = 1;
+ }
+ if ($add_save_lastsearch_values) {
+ $url .= '&save_lastsearch_values=1';
+ }
}
$linkclose = '';
diff --git a/htdocs/product/document.php b/htdocs/product/document.php
index 9b6876150d2..f7753432043 100644
--- a/htdocs/product/document.php
+++ b/htdocs/product/document.php
@@ -240,7 +240,7 @@ if ($object->id) {
$linkback = ''.$langs->trans("BackToList").' ';
- $object->next_prev_filter = " fk_product_type = ".$object->type;
+ $object->next_prev_filter = "fk_product_type = ".((int) $object->type);
$shownav = 1;
if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php
index 9996ad26bfe..b36c134d20b 100644
--- a/htdocs/product/fournisseurs.php
+++ b/htdocs/product/fournisseurs.php
@@ -102,8 +102,10 @@ if (!$sortorder) {
$hookmanager->initHooks(array('pricesuppliercard', 'globalcard'));
$object = new ProductFournisseur($db);
+$prod = new Product($db);
if ($id > 0 || $ref) {
$object->fetch($id, $ref);
+ $prod->fetch($id, $ref);
}
$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'lire')));
@@ -389,14 +391,14 @@ if ($id > 0 || $ref) {
print dol_get_fiche_head($head, 'suppliers', $titre, -1, $picto);
$linkback = ''.$langs->trans("BackToList").' ';
- $object->next_prev_filter = " fk_product_type = ".$object->type;
+ $object->next_prev_filter = "fk_product_type = ".((int) $object->type);
$shownav = 1;
if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
$shownav = 0;
}
- dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
+ dol_banner_tab($prod, 'ref', $linkback, $shownav, 'ref');
print '';
diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php
index 7db7f5af6a4..5f42266d617 100644
--- a/htdocs/product/inventory/card.php
+++ b/htdocs/product/inventory/card.php
@@ -40,6 +40,7 @@ $confirm = GETPOST('confirm', 'alpha');
$cancel = GETPOST('cancel', 'aZ09');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'inventorycard'; // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha');
+$include_sub_warehouse = !empty(GETPOST('include_sub_warehouse')) ? GETPOST('include_sub_warehouse') : 0;
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
$result = restrictedArea($user, 'stock', $id);
@@ -289,6 +290,18 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
}
+
+ if ($action == 'validate') {
+ $form = new Form($db);
+ $formquestion = '';
+ if (getDolGlobalInt('INVENTORY_INCLUDE_SUB_WAREHOUSE') && !empty($object->fk_warehouse)) {
+ $formquestion = array(
+ array('type' => 'checkbox', 'name' => 'include_sub_warehouse', 'label' => $langs->trans("IncludeSubWarehouse"), 'value' => 1, 'size' => '10'),
+ );
+ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateInventory'), $langs->trans('IncludeSubWarehouseExplanation'), 'confirm_validate', $formquestion, '', 1);
+ }
+ }
+
// Call Hook formConfirm
$parameters = array('formConfirm' => $formconfirm);
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
@@ -412,7 +425,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Validate
if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_CANCELED) {
if ($permissiontoadd) {
- print '
'.$langs->trans("Validate").' ('.$langs->trans("ToStart").') ';
+ if (getDolGlobalInt('INVENTORY_INCLUDE_SUB_WAREHOUSE') && !empty($object->fk_warehouse)) {
+ print '
'.$langs->trans("Validate").' ('.$langs->trans("Start").') ';
+ } else {
+ print '
'.$langs->trans("Validate").' ('.$langs->trans("Start").') ';
+ }
}
}
diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php
index 97ae607e70b..509c4b93131 100644
--- a/htdocs/product/inventory/class/inventory.class.php
+++ b/htdocs/product/inventory/class/inventory.class.php
@@ -256,11 +256,12 @@ class Inventory extends CommonObject
/**
* Validate inventory (start it)
*
- * @param User $user User that creates
- * @param bool $notrigger false=launch triggers after, true=disable triggers
- * @return int <0 if KO, Id of created object if OK
+ * @param User $user User that creates
+ * @param bool $notrigger false=launch triggers after, true=disable triggers
+ * @param int $include_sub_warehouse Include sub warehouses
+ * @return int <0 if KO, Id of created object if OK
*/
- public function validate(User $user, $notrigger = false)
+ public function validate(User $user, $notrigger = false, $include_sub_warehouse = 0)
{
global $conf;
$this->db->begin();
@@ -292,7 +293,13 @@ class Inventory extends CommonObject
$sql .= " AND ps.fk_product = ".((int) $this->fk_product);
}
if ($this->fk_warehouse > 0) {
- $sql .= " AND ps.fk_entrepot = ".((int) $this->fk_warehouse);
+ $sql .= " AND (ps.fk_entrepot = ".((int) $this->fk_warehouse);
+ if (!empty($include_sub_warehouse) && getDolGlobalInt('INVENTORY_INCLUDE_SUB_WAREHOUSE')) {
+ $TChildWarehouses = array();
+ $this->getChildWarehouse($this->fk_warehouse, $TChildWarehouses);
+ $sql .= " OR ps.fk_entrepot IN (".$this->db->sanitize(join(',', $TChildWarehouses)).")";
+ }
+ $sql .= ')';
}
if (!empty($this->categories_product)) {
$sql .= " AND EXISTS (";
@@ -745,6 +752,30 @@ class Inventory extends CommonObject
$this->initAsSpecimenCommon();
$this->title = '';
}
+
+ /**
+ * Return the child warehouse of the current one
+ *
+ * @param int $id Id of warehouse
+ * @param array $TChildWarehouse Array of child warehouses
+ * @return int <0 if KO, >0 if OK
+ */
+ public function getChildWarehouse($id, &$TChildWarehouse)
+ {
+ $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'entrepot';
+ $sql.= ' WHERE fk_parent='.(int) $id;
+ $sql.= ' ORDER BY rowid';
+ $resql = $this->db->query($sql);
+ if ($resql && $this->db->num_rows($resql)>0) {
+ while ($obj = $this->db->fetch_object($resql)) {
+ $TChildWarehouse[] = $obj->rowid;
+ $this->getChildWarehouse($obj->rowid, $TChildWarehouse);
+ }
+ return 1;
+ } else {
+ return -1;
+ }
+ }
}
/**
diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php
index 8f595abcc53..dee02f04954 100644
--- a/htdocs/product/inventory/inventory.php
+++ b/htdocs/product/inventory/inventory.php
@@ -468,6 +468,17 @@ if ($action == 'confirm_cancel') {
$action = 'view';
}
+if ($action == 'validate') {
+ $form = new Form($db);
+ $formquestion = '';
+ if (getDolGlobalInt('INVENTORY_INCLUDE_SUB_WAREHOUSE') && !empty($object->fk_warehouse)) {
+ $formquestion = array(
+ array('type' => 'checkbox', 'name' => 'include_sub_warehouse', 'label' => $langs->trans("IncludeSubWarehouse"), 'value' => 1, 'size' => '10'),
+ );
+ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateInventory'), $langs->trans('IncludeSubWarehouseExplanation'), 'confirm_validate', $formquestion, '', 1);
+ }
+}
+
// Call Hook formConfirm
$parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
@@ -573,7 +584,11 @@ if ($action != 'record') {
if (empty($reshook)) {
if ($object->status == Inventory::STATUS_DRAFT) {
if ($permissiontoadd) {
- print '
id.'&action=confirm_validate&confirm=yes&token='.newToken().'">'.$langs->trans("Validate").' ('.$langs->trans("Start").') '."\n";
+ if (getDolGlobalInt('INVENTORY_INCLUDE_SUB_WAREHOUSE') && !empty($object->fk_warehouse)) {
+ print '
'.$langs->trans("Validate").' ('.$langs->trans("Start").') ';
+ } else {
+ print '
'.$langs->trans("Validate").' ('.$langs->trans("Start").') ';
+ }
} else {
print '
'.$langs->trans('Validate').' ('.$langs->trans("Start").') '."\n";
}
diff --git a/htdocs/product/list.php b/htdocs/product/list.php
index a573333ec29..0f99d58720e 100644
--- a/htdocs/product/list.php
+++ b/htdocs/product/list.php
@@ -10,8 +10,10 @@
* Copyright (C) 2013 Florian Henry
* Copyright (C) 2013 Adolfo segura
* Copyright (C) 2015 Jean-François Ferry
- * Copyright (C) 2016 Ferran Marcet
- * Copyright (C) 2020-2023 Alexandre Spangaro
+ * Copyright (C) 2016 Ferran Marcet
+ * Copyright (C) 2020-2021 Open-DSI
+ * Copyright (C) 2022 Charlene Benke
+ * Copyright (C) 2020-2023 Alexandre Spangaro
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -44,7 +46,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
-require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php';
+
+if (isModEnabled('workstation')) {
+ require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php';
+}
if (isModEnabled('categorie')) {
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php';
@@ -103,12 +108,9 @@ $optioncss = GETPOST('optioncss', 'alpha');
$type = GETPOST("type", "int");
$mode = GETPOST('mode', 'alpha');
-
-//Show/hide child products
-if (isModEnabled('variants') && !empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) {
+// Show/hide child product variants
+if (isModEnabled('variants')) {
$show_childproducts = GETPOST('search_show_childproducts');
-} else {
- $show_childproducts = '';
}
$diroutputmassaction = $conf->product->dir_output.'/temp/massgeneration/'.$user->id;
@@ -187,7 +189,7 @@ $fieldstosearchall = array(
'p.label'=>"ProductLabel",
'p.description'=>"Description",
"p.note"=>"Note",
-
+ 'pfp.ref_fourn'=>'RefSupplier'
);
// multilang
if (getDolGlobalInt('MAIN_MULTILANGS')) {
@@ -197,6 +199,7 @@ if (getDolGlobalInt('MAIN_MULTILANGS')) {
}
if (isModEnabled('barcode')) {
$fieldstosearchall['p.barcode'] = 'Gencod';
+ $fieldstosearchall['pfp.barcode'] = 'GencodBuyPrice';
}
// Personalized search criterias. Example: $conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS = 'p.ref=ProductRef;p.label=ProductLabel;p.description=Description;p.note=Note;'
if (!empty($conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS)) {
@@ -224,6 +227,7 @@ $arrayfields = array(
'p.fk_product_type'=>array('label'=>"Type", 'checked'=>0, 'enabled'=>(isModEnabled("product") && isModEnabled("service")), 'position'=>11),
'p.barcode'=>array('label'=>"Gencod", 'checked'=>1, 'enabled'=>(isModEnabled('barcode')), 'position'=>12),
'p.duration'=>array('label'=>"Duration", 'checked'=>($contextpage != 'productlist'), 'enabled'=>(isModEnabled("service") && (string) $type == '1'), 'position'=>13),
+ 'pac.fk_product_parent' => array('label'=>"ParentProductOfVariant", 'checked'=>-1, 'enabled'=>(isModEnabled('variants')), 'position'=>14),
'p.finished'=>array('label'=>"Nature", 'checked'=>0, 'enabled'=>(isModEnabled("product") && $type != '1'), 'position'=>19),
'p.weight'=>array('label'=>'Weight', 'checked'=>0, 'enabled'=>(isModEnabled("product") && $type != '1'), 'position'=>20),
'p.weight_units'=>array('label'=>'WeightUnits', 'checked'=>0, 'enabled'=>(isModEnabled("product") && $type != '1'), 'position'=>21),
@@ -410,7 +414,9 @@ if (empty($reshook)) {
*/
$product_static = new Product($db);
-$static_ws = new Workstation($db);
+if (isModEnabled('workstation')) {
+ $workstation_static = new Workstation($db);
+}
$product_fourn = new ProductFournisseur($db);
$title = $langs->trans("ProductsAndServices");
@@ -438,12 +444,13 @@ if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
}
$sql .= ' p.datec as date_creation, p.tms as date_update, p.pmp, p.stock, p.cost_price,';
$sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units, fk_country, fk_state,';
-if (!empty($conf->global->PRODUCT_USE_UNITS)) {
+if (getDolGlobalString('PRODUCT_USE_UNITS')) {
$sql .= ' p.fk_unit, cu.label as cu_label,';
}
$sql .= ' MIN(pfp.unitprice) as bestpurchaseprice';
-if (isModEnabled('variants') && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) {
+if (isModEnabled('variants')) {
$sql .= ', pac.rowid as prod_comb_id';
+ $sql .= ', pac.fk_product_parent';
}
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
@@ -461,7 +468,7 @@ $sqlfields = $sql; // $sql fields to remove for count total
$sql .= ' FROM '.MAIN_DB_PREFIX.'product as p';
if (isModEnabled('workstation')) {
- $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "workstation_workstation ws ON (p.fk_default_workstation = ws.rowid)";
+ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "workstation_workstation as ws ON (p.fk_default_workstation = ws.rowid)";
}
if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
@@ -475,18 +482,22 @@ $sql .= $linktopfp;
if (getDolGlobalInt('MAIN_MULTILANGS')) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang = '".$db->escape($langs->getDefaultLang())."'";
}
-
-if (isModEnabled('variants') && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) {
+if (isModEnabled('variants')) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination pac ON pac.fk_product_child = p.rowid";
}
-if (!empty($conf->global->PRODUCT_USE_UNITS)) {
+if (getDolGlobalString('PRODUCT_USE_UNITS')) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_units cu ON cu.rowid = p.fk_unit";
}
$sql .= ' WHERE p.entity IN ('.getEntity('product').')';
if ($sall) {
+ // Clean $fieldstosearchall
+ $newfieldstosearchall = $fieldstosearchall;
+ unset($newfieldstosearchall['pfp.ref_fourn']);
+ unset($newfieldstosearchall['pfp.barcode']);
+
$sql .= ' AND (';
- $sql .= natural_search(array_keys($fieldstosearchall), $sall, 0, 1);
+ $sql .= natural_search(array_keys($newfieldstosearchall), $sall, 0, 1);
// Search also into a supplier reference 'pfp.ref_fourn'="RefSupplier"
$sql .= ' OR EXISTS (SELECT rowid FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp WHERE pfp.fk_product = p.rowid';
$sql .= ' AND ('.natural_search('pfp.ref_fourn', $sall, 0, 1);
@@ -505,7 +516,7 @@ if (dol_strlen($search_type) && $search_type != '-1') {
}
}
-if (isModEnabled('variants') && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) {
+if (isModEnabled('variants') && !$show_childproducts) {
$sql .= " AND pac.rowid IS NULL";
}
@@ -615,15 +626,15 @@ if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
$sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export, ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export,";
}
$sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units, p.fk_country, p.fk_state';
-if (!empty($conf->global->PRODUCT_USE_UNITS)) {
+if (getDolGlobalString('PRODUCT_USE_UNITS')) {
$sql .= ', p.fk_unit, cu.label';
}
if (isModEnabled('workstation')) {
- $sql .= ', p.fk_default_workstation, ws.status, ws.ref ';
+ $sql .= ', p.fk_default_workstation, ws.status, ws.ref';
}
-
-if (isModEnabled('variants') && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) {
+if (isModEnabled('variants')) {
$sql .= ', pac.rowid';
+ $sql .= ', pac.fk_product_parent';
}
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
@@ -643,6 +654,7 @@ if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
$sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
$sqlforcount = preg_replace('/'.preg_quote($linktopfp, '/').'/', '', $sqlforcount);
$sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
+
$resql = $db->query($sqlforcount);
if ($resql) {
$objforcount = $db->fetch_object($resql);
@@ -907,8 +919,8 @@ if (isModEnabled('categorie') && $user->hasRight('categorie', 'read')) {
$moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PRODUCT, $searchCategoryProductList, 'minwidth300', $searchCategoryProductOperator ? $searchCategoryProductOperator : 0);
}
-//Show/hide child products. Hidden by default
-if (isModEnabled('variants') && !empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) {
+// Show/hide child variant products
+if (isModEnabled('variants')) {
$moreforfilter .= '';
$moreforfilter .= '
';
$moreforfilter .= '
'.$langs->trans('ShowChildProducts').' ';
@@ -992,7 +1004,11 @@ if (!empty($arrayfields['p.duration']['checked'])) {
print '
';
print ' ';
}
-
+// Parent
+if (!empty($arrayfields['pac.fk_product_parent']['checked'])) {
+ print '
';
+ print ' ';
+}
// Finished
if (!empty($arrayfields['p.finished']['checked'])) {
print '
';
@@ -1262,6 +1278,9 @@ if (!empty($arrayfields['p.duration']['checked'])) {
print_liste_field_titre($arrayfields['p.duration']['label'], $_SERVER["PHP_SELF"], "p.duration", "", $param, '', $sortfield, $sortorder, 'center ');
$totalarray['nbfield']++;
}
+if (!empty($arrayfields['pac.fk_product_parent']['checked'])) {
+ print_liste_field_titre($arrayfields['pac.fk_product_parent']['label'], $_SERVER["PHP_SELF"], "pac.fk_product_parent", "", $param, '', $sortfield, $sortorder, '', empty($arrayfields['pac.fk_product_parent']['help']) ? '' : $arrayfields['pac.fk_product_parent']['help']);
+}
if (!empty($arrayfields['p.finished']['checked'])) {
print_liste_field_titre($arrayfields['p.finished']['label'], $_SERVER["PHP_SELF"], "p.finished", "", $param, '', $sortfield, $sortorder, 'center ');
$totalarray['nbfield']++;
@@ -1672,6 +1691,23 @@ while ($i < $imaxinloop) {
}
}
+ if (!empty($arrayfields['pac.fk_product_parent']['checked'])) {
+ print ' ';
+ if ($obj->fk_product_parent > 0) {
+ if (!empty($conf->cache['product'][$obj->fk_product_parent])) {
+ $product_parent_static = $conf->cache['product'][$obj->fk_product_parent];
+ } else {
+ $product_parent_static= new Product($db);
+ $product_parent_static->fetch($obj->fk_product_parent);
+ $conf->cache['product'][$obj->fk_product_parent] = $product_parent_static;
+ }
+ print $product_parent_static->getNomUrl(1);
+ }
+ print ' ';
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ }
// Finished
if (!empty($arrayfields['p.finished']['checked'])) {
print '
';
@@ -1817,12 +1853,12 @@ while ($i < $imaxinloop) {
// Default Workstation
if (!empty($arrayfields['p.fk_default_workstation']['checked'])) {
print ' ';
- if (!empty($obj->fk_default_workstation)) {
- $static_ws->id = $obj->fk_default_workstation;
- $static_ws->ref = $obj->ref_workstation;
- $static_ws->status = $obj->status_workstation;
+ if (isModEnabled('workstation') && !empty($obj->fk_default_workstation)) {
+ $workstation_static->id = $obj->fk_default_workstation;
+ $workstation_static->ref = $obj->ref_workstation;
+ $workstation_static->status = $obj->status_workstation;
- print $static_ws->getNomUrl(1);
+ print $workstation_static->getNomUrl(1);
}
print ' ';
if (!$i) {
diff --git a/htdocs/product/note.php b/htdocs/product/note.php
index 54c214224d5..f8dab5e6bf3 100644
--- a/htdocs/product/note.php
+++ b/htdocs/product/note.php
@@ -123,7 +123,7 @@ if ($id > 0 || !empty($ref)) {
print dol_get_fiche_head($head, 'note', $titre, -1, $picto);
$linkback = '
'.$langs->trans("BackToList").' ';
- $object->next_prev_filter = " fk_product_type = ".$object->type;
+ $object->next_prev_filter = "fk_product_type = ".((int) $object->type);
$shownav = 1;
if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
diff --git a/htdocs/product/price.php b/htdocs/product/price.php
index d7384dd6643..713c68c6974 100644
--- a/htdocs/product/price.php
+++ b/htdocs/product/price.php
@@ -45,7 +45,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php';
- $prodcustprice = new Productcustomerprice($db);
+ $prodcustprice = new ProductCustomerPrice($db);
}
// Load translation files required by the page
@@ -873,7 +873,7 @@ $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product');
print dol_get_fiche_head($head, 'price', $titre, -1, $picto);
$linkback = '
'.$langs->trans("BackToList").' ';
-$object->next_prev_filter = " fk_product_type = ".$object->type;
+$object->next_prev_filter = "fk_product_type = ".((int) $object->type);
$shownav = 1;
if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
@@ -1906,7 +1906,7 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul
// Add area to show/add/edit a price for a dedicated customer
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
- $prodcustprice = new Productcustomerprice($db);
+ $prodcustprice = new ProductCustomerPrice($db);
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php
index f43b76f843e..0d81fd7b399 100644
--- a/htdocs/product/stock/class/entrepot.class.php
+++ b/htdocs/product/stock/class/entrepot.class.php
@@ -4,7 +4,7 @@
* Copyright (C) 2005-2008 Regis Houssin
* Copyright (C) 2011 Juanjo Menent
* Copyright (C) 2016 Francis Appels
- * Copyright (C) 2019-2020 Frédéric France
+ * Copyright (C) 2019-2023 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -139,6 +139,7 @@ class Entrepot extends CommonObject
//'fk_user_author' =>array('type'=>'integer', 'label'=>'Fk user author', 'enabled'=>1, 'visible'=>-2, 'position'=>82),
'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>300),
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>301),
+ 'warehouse_usage' => array('type'=>'integer', 'label' => 'WarehouseUsage', 'enabled'=>'getDolGlobalInt("MAIN_FEATURES_LEVEL")', 'visible'=>1, 'position'=>400, 'arrayofkeyval'=>array(1=>'InternalWarehouse', 2=>'ExternalWarehouse')),
//'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000),
//'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'ModelPDF', 'enabled'=>1, 'visible'=>0, 'position'=>1010),
'statut' =>array('type'=>'tinyint(4)', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'position'=>500, 'css'=>'minwidth50'),
@@ -791,7 +792,7 @@ class Entrepot extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
@@ -815,7 +816,7 @@ class Entrepot extends CommonObject
$result .= $linkstart;
if ($withpicto) {
- $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
+ $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1);
}
if ($withpicto != 2) {
$result .= (($showfullpath || !empty($conf->global->STOCK_ALWAYS_SHOW_FULL_ARBO)) ? $this->get_full_arbo() : $this->label);
diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php
index 72b97a44873..2291effe8c4 100644
--- a/htdocs/product/stock/class/mouvementstock.class.php
+++ b/htdocs/product/stock/class/mouvementstock.class.php
@@ -1183,6 +1183,8 @@ class MouvementStock extends CommonObject
} elseif ($mode == 5) {
return $langs->trans('StatusNotApplicable').' '.img_picto($langs->trans('StatusNotApplicable'), 'statut9');
}
+
+ return 'Bad value for mode';
}
/**
diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php
index 815d0af1a50..b659e6e9447 100644
--- a/htdocs/product/stock/class/productlot.class.php
+++ b/htdocs/product/stock/class/productlot.class.php
@@ -106,11 +106,12 @@ class Productlot extends CommonObject
'batch' => array('type'=>'varchar(30)', 'label'=>'Batch', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'comment'=>'Batch', 'searchall'=>1, 'picto'=>'lot'),
'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20),
'sellby' => array('type'=>'date', 'label'=>'SellByDate', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_SELLBY)?1:0', 'visible'=>5, 'position'=>60),
- 'eol_date' => array('type'=>'date', 'label'=>'EndOfLife', 'enabled'=>'empty($conf->global->PRODUCT_ENABLE_TRACEABILITY)?0:1', 'visible'=>5, 'position'=>70),
- 'manufacturing_date' => array('type'=>'date', 'label'=>'ManufacturingDate', 'enabled'=>1, 'visible'=>1, 'position'=>80),
- 'scrapping_date' => array('type'=>'date', 'label'=>'DestructionDate', 'enabled'=>'getDolGlobalInt("PRODUCT_ENABLE_TRACEABILITY", 0)', 'visible'=>5, 'position'=>90),
- //'commissionning_date' => array('type'=>'date', 'label'=>'FirstUseDate', 'enabled'=>'getDolGlobalInt("PRODUCT_ENABLE_TRACEABILITY", 0)', 'visible'=>5, 'position'=>100),
- //'qc_frequency' => array('type'=>'varchar(6)', 'label'=>'QCFrequency', 'enabled'=>'empty($conf->global->PRODUCT_ENABLE_QUALITYCONTROL)?1:0', 'visible'=>5, 'position'=>110),
+ 'eol_date' => array('type'=>'date', 'label'=>'EndOfLife', 'enabled'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_QUALITY_CONTROL")?1:0', 'visible'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_QUALITY_CONTROL")?5:0', 'position'=>70),
+ 'manufacturing_date' => array('type'=>'date', 'label'=>'ManufacturingDate', 'enabled'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_TRACEABILITY")?1:0', 'visible'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_TRACEABILITY")?5:0', 'position'=>80),
+ 'scrapping_date' => array('type'=>'date', 'label'=>'DestructionDate', 'enabled'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_TRACEABILITY")?1:0', 'visible'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_TRACEABILITY")?5:0', 'position'=>90),
+ //'commissionning_date' => array('type'=>'date', 'label'=>'FirstUseDate', 'enabled'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_TRACEABILITY", 0)', 'visible'=>5, 'position'=>100),
+ 'qc_frequency' => array('type'=>'integer', 'label'=>'QCFrequency', 'enabled'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_QUALITY_CONTROL")?1:0', 'visible'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_QUALITY_CONTROL")?5:0', 'position'=>110),
+ 'lifetime' => array('type'=>'integer', 'label'=>'Lifetime', 'enabled'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_QUALITY_CONTROL")?1:0', 'visible'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_QUALITY_CONTROL")?5:0', 'position'=>110),
'eatby' => array('type'=>'date', 'label'=>'EatByDate', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_EATBY)?1:0', 'visible'=>5, 'position'=>62),
'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => 1, 'visible' => 0, 'position' => 215),
'last_main_doc' => array('type' => 'varchar(255)', 'label' => 'LastMainDoc', 'enabled' => 1, 'visible' => -2, 'position' => 310),
@@ -141,7 +142,8 @@ class Productlot extends CommonObject
public $manufacturing_date = '';
public $scrapping_date = '';
//public $commissionning_date = '';
- //public $qc_frequency = '';
+ public $qc_frequency = '';
+ public $lifetime = '';
public $datec = '';
public $tms = '';
@@ -227,7 +229,8 @@ class Productlot extends CommonObject
$sql .= 'manufacturing_date,';
$sql .= 'scrapping_date,';
//$sql .= 'commissionning_date,';
- //$sql .= 'qc_frequency,';
+ $sql .= 'qc_frequency,';
+ $sql .= 'lifetime,';
$sql .= 'datec,';
$sql .= 'fk_user_creat,';
$sql .= 'fk_user_modif,';
@@ -242,7 +245,8 @@ class Productlot extends CommonObject
$sql .= ' '.(!isset($this->manufacturing_date) || dol_strlen($this->manufacturing_date) == 0 ? 'NULL' : "'".$this->db->idate($this->manufacturing_date)."'").',';
$sql .= ' '.(!isset($this->scrapping_date) || dol_strlen($this->scrapping_date) == 0 ? 'NULL' : "'".$this->db->idate($this->scrapping_date)."'").',';
//$sql .= ' '.(!isset($this->commissionning_date) || dol_strlen($this->commissionning_date) == 0 ? 'NULL' : "'".$this->db->idate($this->commissionning_date)."'").',';
- //$sql .= ' '.(!isset($this->qc_frequency) ? 'NULL' : $this->qc_frequency).',';
+ $sql .= ' '.(empty($this->qc_frequency) ? 'NULL' : $this->qc_frequency).',';
+ $sql .= ' '.(empty($this->lifetime) ? 'NULL' : $this->lifetime).',';
$sql .= ' '."'".$this->db->idate(dol_now())."'".',';
$sql .= ' '.(!isset($this->fk_user_creat) ? 'NULL' : $this->fk_user_creat).',';
$sql .= ' '.(!isset($this->fk_user_modif) ? 'NULL' : $this->fk_user_modif).',';
@@ -316,7 +320,8 @@ class Productlot extends CommonObject
$sql .= " t.manufacturing_date,";
$sql .= " t.scrapping_date,";
//$sql .= " t.commissionning_date,";
- //$sql .= " t.qc_frequency,";
+ $sql .= " t.qc_frequency,";
+ $sql .= " t.lifetime,";
$sql .= " t.model_pdf,";
$sql .= " t.last_main_doc,";
$sql .= " t.datec,";
@@ -352,7 +357,8 @@ class Productlot extends CommonObject
$this->manufacturing_date = $this->db->jdate($obj->manufacturing_date);
$this->scrapping_date = $this->db->jdate($obj->scrapping_date);
//$this->commissionning_date = $this->db->jdate($obj->commissionning_date);
- //$this->qc_frequency = $obj->qc_frequency;
+ $this->qc_frequency = $obj->qc_frequency;
+ $this->lifetime = $obj->lifetime;
$this->model_pdf = $obj->model_pdf;
$this->last_main_doc = $obj->last_main_doc;
@@ -434,7 +440,8 @@ class Productlot extends CommonObject
$sql .= ' manufacturing_date = '.(!isset($this->manufacturing_date) || dol_strlen($this->manufacturing_date) != 0 ? "'".$this->db->idate($this->manufacturing_date)."'" : 'null').',';
$sql .= ' scrapping_date = '.(!isset($this->scrapping_date) || dol_strlen($this->scrapping_date) != 0 ? "'".$this->db->idate($this->scrapping_date)."'" : 'null').',';
//$sql .= ' commissionning_date = '.(!isset($this->first_use_date) || dol_strlen($this->first_use_date) != 0 ? "'".$this->db->idate($this->first_use_date)."'" : 'null').',';
- //$sql .= ' qc_frequency = '.(!isset($this->qc_frequency) || dol_strlen($this->qc_frequency) != 0 ? "'".$this->db->escape($this->qc_frequency)."'" : 'null').',';
+ $sql .= ' qc_frequency = '.(!empty($this->qc_frequency) ? (int) $this->qc_frequency : 'null').',';
+ $sql .= ' lifetime = '.(!empty($this->lifetime) ? (int) $this->lifetime : 'null').',';
$sql .= ' datec = '.(!isset($this->datec) || dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').',';
$sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'").',';
$sql .= ' fk_user_creat = '.(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").',';
@@ -980,9 +987,7 @@ class Productlot extends CommonObject
*/
public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '', $save_lastsearch_value = -1)
{
- global $langs, $conf, $hookmanager, $db;
- global $dolibarr_main_authentication, $dolibarr_main_demo;
- global $menumanager;
+ global $langs, $conf, $hookmanager;
$result = '';
$params = [
@@ -1005,7 +1010,7 @@ class Productlot extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
@@ -1039,7 +1044,7 @@ class Productlot extends CommonObject
$result .= $linkstart;
if ($withpicto) {
- $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
+ $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1);
}
if ($withpicto != 2) {
$result .= $this->batch;
diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php
index d52b15ca307..0696b3a1857 100644
--- a/htdocs/product/stock/product.php
+++ b/htdocs/product/stock/product.php
@@ -936,7 +936,7 @@ if (empty($reshook)) {
if ($user->rights->stock->mouvement->creer) {
if (!$variants || !empty($conf->global->VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT)) {
- print 'id.'&action=transfert">'.$langs->trans("TransferStock").' ';
+ print 'id.'&action=transfert">'.$langs->trans("TransferStock").' ';
} else {
print ''.$langs->trans("TransferStock").' ';
}
@@ -1069,7 +1069,7 @@ if (!$variants) {
// Sell price
$minsellprice = null; $maxsellprice = null;
- print '';
+ print ' ';
if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
foreach ($object->multiprices as $priceforlevel) {
if (is_numeric($priceforlevel)) {
@@ -1179,7 +1179,7 @@ if (!$variants) {
}
print ' '.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : '').' ';
print ' ';
- print '';
+ print ' ';
if ($entrepotstatic->status != $entrepotstatic::STATUS_CLOSED) {
print 'id.'&id_entrepot='.$entrepotstatic->id.'&action=transfert&pdluoid='.$pdluo->id.'">';
print img_picto($langs->trans("TransferStock"), 'add', 'class="hideonsmartphone paddingright" style="color: #a69944"');
@@ -1191,7 +1191,7 @@ if (!$variants) {
//print img_edit().' ';
}
print ' ';
- print '';
+ print ' ';
if ($entrepotstatic->status != $entrepotstatic::STATUS_CLOSED) {
print 'id.'&id_entrepot='.$entrepotstatic->id.'&action=correction&pdluoid='.$pdluo->id.'">';
print img_picto($langs->trans("CorrectStock"), 'add', 'class="hideonsmartphone paddingright" style="color: #a69944"');
diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php
index 5fa6afe983c..42adc0a471a 100644
--- a/htdocs/product/stock/productlot_card.php
+++ b/htdocs/product/stock/productlot_card.php
@@ -34,6 +34,8 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php';
+global $conf, $db, $langs, $user;
+
// Load translation files required by the page
$langs->loadLangs(array('stocks', 'other', 'productbatch'));
@@ -69,9 +71,9 @@ if (empty($action) && empty($id) && empty($ref)) {
$action = 'view';
}
-$batch = GETPOST('batch', 'alpha');
-$productid = GETPOST('productid', 'int');
-$ref = GETPOST('ref', 'alpha'); // ref is productid_batch
+$batch = GETPOST('batch', 'alpha');
+$productid = GETPOST('productid', 'int');
+$ref = GETPOST('ref', 'alpha'); // ref is productid_batch
$search_entity = GETPOST('search_entity', 'int');
$search_fk_product = GETPOST('search_fk_product', 'int');
@@ -106,13 +108,13 @@ if ($id || $ref) {
$hookmanager->initHooks(array('productlotcard', 'globalcard'));
-$permissionnote = $user->rights->stock->creer; // Used by the include of actions_setnotes.inc.php
-$permissiondellink = $user->rights->stock->creer; // Used by the include of actions_dellink.inc.php
-$permissiontoadd = $user->rights->stock->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
+$permissionnote = $user->hasRight('stock', 'creer'); // Used by the include of actions_setnotes.inc.php
+$permissiondellink = $user->hasRight('stock', 'creer'); // Used by the include of actions_dellink.inc.php
+$permissiontoadd = $user->hasRight('stock', 'creer'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
-$usercanread = $user->rights->produit->lire;
-$usercancreate = $user->rights->produit->creer;
-$usercandelete = $user->rights->produit->supprimer;
+$usercanread = $user->hasRight('produit', 'lire');
+$usercancreate = $user->hasRight('produit', 'creer');
+$usercandelete = $user->hasRight('produit', 'supprimer');
$upload_dir = $conf->productbatch->multidir_output[$conf->entity];
@@ -121,7 +123,7 @@ $permissiontoadd = $usercancreate;
$permissiontodelete = $usercandelete;
// Security check
-if (empty($conf->productbatch->enabled)) {
+if (!isModEnabled('productbatch')) {
accessforbidden('Module not enabled');
}
$socid = 0;
@@ -130,7 +132,9 @@ if ($user->socid > 0) { // Protection if external user
accessforbidden();
}
//$result = restrictedArea($user, 'productbatch');
-if (!$permissiontoread) accessforbidden();
+if (!$permissiontoread) {
+ accessforbidden();
+}
/*
@@ -148,7 +152,7 @@ if (empty($reshook)) {
$backurlforlist = dol_buildpath('/product/stock/productlot_list.php', 1);
- if ($action == 'seteatby' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) {
+ if ($action == 'seteatby' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) {
$newvalue = dol_mktime(12, 0, 0, GETPOST('eatbymonth', 'int'), GETPOST('eatbyday', 'int'), GETPOST('eatbyyear', 'int'));
$result = $object->setValueFrom('eatby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY');
if ($result < 0) {
@@ -159,7 +163,7 @@ if (empty($reshook)) {
}
}
- if ($action == 'setsellby' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) {
+ if ($action == 'setsellby' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) {
$newvalue = dol_mktime(12, 0, 0, GETPOST('sellbymonth', 'int'), GETPOST('sellbyday', 'int'), GETPOST('sellbyyear', 'int'));
$result = $object->setValueFrom('sellby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY');
if ($result < 0) {
@@ -170,7 +174,7 @@ if (empty($reshook)) {
}
}
- if ($action == 'seteol_date' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) {
+ if ($action == 'seteol_date' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) {
$newvalue = dol_mktime(12, 0, 0, GETPOST('eol_datemonth', 'int'), GETPOST('eol_dateday', 'int'), GETPOST('eol_dateyear', 'int'));
$result = $object->setValueFrom('eol_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY');
if ($result < 0) {
@@ -181,7 +185,7 @@ if (empty($reshook)) {
}
}
- if ($action == 'setmanufacturing_date' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) {
+ if ($action == 'setmanufacturing_date' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) {
$newvalue = dol_mktime(12, 0, 0, GETPOST('manufacturing_datemonth', 'int'), GETPOST('manufacturing_dateday', 'int'), GETPOST('manufacturing_dateyear', 'int'));
$result = $object->setValueFrom('manufacturing_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY');
if ($result < 0) {
@@ -192,7 +196,7 @@ if (empty($reshook)) {
}
}
- if ($action == 'setscrapping_date' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) {
+ if ($action == 'setscrapping_date' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) {
$newvalue = dol_mktime(12, 0, 0, GETPOST('scrapping_datemonth', 'int'), GETPOST('scrapping_dateday', 'int'), GETPOST('scrapping_dateyear', 'int'));
$result = $object->setValueFrom('scrapping_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY');
if ($result < 0) {
@@ -203,7 +207,7 @@ if (empty($reshook)) {
}
}
- /* if ($action == 'setcommissionning_date' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) {
+ /* if ($action == 'setcommissionning_date' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) {
$newvalue = dol_mktime(12, 0, 0, GETPOST('commissionning_datemonth', 'int'), GETPOST('commissionning_dateday', 'int'), GETPOST('commissionning_dateyear', 'int'));
$result = $object->setValueFrom('commissionning_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY');
if ($result < 0) {
@@ -214,7 +218,7 @@ if (empty($reshook)) {
}
} */
- if ($action == 'setqc_frequency' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) {
+ if ($action == 'setqc_frequency' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) {
$result = $object->setValueFrom('qc_frequency', GETPOST('qc_frequency'), '', null, 'int', '', $user, 'PRODUCT_MODIFY');
if ($result < 0) { // Prévoir un test de format de durée
setEventMessages($object->error, null, 'errors');
@@ -229,20 +233,17 @@ if (empty($reshook)) {
// Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
/*
- if ($action == 'update_extras')
- {
+ if ($action == 'update_extras') {
$object->oldcopy = dol_clone($object);
// Fill array 'array_options' with data from update form
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml'));
if ($ret < 0) $error++;
- if (!$error)
- {
+ if (!$error) {
// Actions on extra fields
$result = $object->insertExtraFields('PRODUCT_LOT_MODIFY');
- if ($result < 0)
- {
+ if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
@@ -254,10 +255,8 @@ if (empty($reshook)) {
}
// Action to add record
- if ($action == 'add')
- {
- if (GETPOST('cancel', 'alpha'))
- {
+ if ($action == 'add') {
+ if (GETPOST('cancel', 'alpha')) {
$urltogo = $backtopage ? $backtopage : dol_buildpath('/stock/list.php', 1);
header("Location: ".$urltogo);
exit;
@@ -272,17 +271,14 @@ if (empty($reshook)) {
$object->fk_user_modif = GETPOST('fk_user_modif', 'int');
$object->import_key = GETPOST('import_key', 'int');
- if (empty($object->ref))
- {
+ if (empty($object->ref)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors');
}
- if (!$error)
- {
+ if (!$error) {
$result = $object->create($user);
- if ($result > 0)
- {
+ if ($result > 0) {
// Creation OK
$urltogo = $backtopage ? $backtopage : dol_buildpath('/stock/list.php', 1);
header("Location: ".$urltogo);
@@ -303,8 +299,7 @@ if (empty($reshook)) {
if ($action == 'update' && GETPOST('cancel', 'alpha')) $action = 'view';
// Action to update record
- if ($action == 'update' && !GETPOST('cancel', 'alpha'))
- {
+ if ($action == 'update' && !GETPOST('cancel', 'alpha')) {
$error = 0;
$object->entity = GETPOST('entity', 'int');
@@ -314,17 +309,14 @@ if (empty($reshook)) {
$object->fk_user_modif = GETPOST('fk_user_modif', 'int');
$object->import_key = GETPOST('import_key', 'int');
- if (empty($object->ref))
- {
+ if (empty($object->ref)) {
$error++;
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors');
}
- if (!$error)
- {
+ if (!$error) {
$result = $object->update($user);
- if ($result > 0)
- {
+ if ($result > 0) {
$action = 'view';
} else {
// Creation KO
@@ -338,11 +330,9 @@ if (empty($reshook)) {
}
// Action to delete
- if ($action == 'confirm_delete')
- {
+ if ($action == 'confirm_delete') {
$result = $object->delete($user);
- if ($result > 0)
- {
+ if ($result > 0) {
// Delete OK
setEventMessages("RecordDeleted", null, 'mesgs');
header("Location: ".dol_buildpath('/stock/list.php', 1));
@@ -468,9 +458,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Sell by
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
print '';
- print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker');
+ print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->hasRight('stock', 'creer'), 'datepicker');
print ' ';
- print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker', '', null, null, '', 1, '', 'id', 'auto', array(), $action);
+ print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->hasRight('stock', 'creer'), 'datepicker', '', null, null, '', 1, '', 'id', 'auto', array(), $action);
print ' ';
print ' ';
}
@@ -478,32 +468,35 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Eat by
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print '';
- print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker');
+ print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->hasRight('stock', 'creer'), 'datepicker');
print ' ';
- print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker', '', null, null, '', 1, '', 'id', 'auto', array(), $action);
+ print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->hasRight('stock', 'creer'), 'datepicker', '', null, null, '', 1, '', 'id', 'auto', array(), $action);
print ' ';
print ' ';
}
- if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) {
- print ''.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).' ';
- print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').' ';
+ if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABILITY)) {
+ print ''.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->hasRight('stock', 'creer')).' ';
+ print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').' ';
print ' ';
- // print ''.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).' ';
- // print ''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').' ';
+ // print ''.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->hasRight('stock', 'creer')).' ';
+ // print ''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').' ';
// print ' ';
- print ''.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).' ';
- print ''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer, 'datepicker').' ';
+ print ''.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->hasRight('stock', 'creer')).' ';
+ print ''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').' ';
print ' ';
}
// Quality control
if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) {
- print ''.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).' ';
- print ''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').' ';
+ print ''.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->hasRight('stock', 'creer')).' ';
+ print ''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').' ';
print ' ';
- print ''.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).' ';
- print ''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'numeric').' ';
+ print ''.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->hasRight('stock', 'creer')).' ';
+ print ''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->hasRight('stock', 'creer'), 'string').' ';
+ print ' ';
+ print ''.$form->editfieldkey($langs->trans('Lifetime'), 'lifetime', $object->lifetime, $object, $user->hasRight('stock', 'creer')).' ';
+ print ''.$form->editfieldval($langs->trans('Lifetime'), 'lifetime', $object->lifetime, $object, $user->hasRight('stock', 'creer'), 'string').' ';
print ' ';
}
@@ -536,8 +529,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}
if (empty($reshook)) {
- /*TODO if ($user->rights->stock->lire)
- {
+ /*TODO
+ if ($user->hasRight('stock', 'lire')) {
print ''."\n";
}
*/
diff --git a/htdocs/product/stock/productlot_document.php b/htdocs/product/stock/productlot_document.php
index 38c5b0503d8..0f4cb68df98 100644
--- a/htdocs/product/stock/productlot_document.php
+++ b/htdocs/product/stock/productlot_document.php
@@ -26,7 +26,7 @@
/**
* \file htdocs/product/stock/productlot_document.php
* \ingroup product
- * \brief Page of attached documents for porudct lots
+ * \brief Page of attached documents for product lots
*/
// Load Dolibarr environment
@@ -38,11 +38,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php';
+global $conf, $db, $langs, $user;
+
// Load translation files required by the page
$langs->loadLangs(array('other', 'products'));
-$id = GETPOST('id', 'int');
-$ref = GETPOST('ref', 'alpha');
+$id = GETPOST('id', 'int');
+$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha');
@@ -97,9 +99,9 @@ if ($id || $ref) {
}
}
-$usercanread = $user->rights->produit->lire;
-$usercancreate = $user->rights->produit->creer;
-$usercandelete = $user->rights->produit->supprimer;
+$usercanread = $user->hasRight('produit', 'lire');
+$usercancreate = $user->hasRight('produit', 'creer');
+$usercandelete = $user->hasRight('produit', 'supprimer');
if (empty($upload_dir)) {
$upload_dir = $conf->productbatch->multidir_output[$conf->entity];
@@ -111,7 +113,7 @@ $permtoedit = $user->rights->produit->creer;
//$permissiontodelete = $usercandelete;
// Security check
-if (empty($conf->productbatch->enabled)) {
+if (!isModEnabled('productbatch')) {
accessforbidden('Module not enabled');
}
$socid = 0;
diff --git a/htdocs/product/stock/stats/commande_fournisseur.php b/htdocs/product/stock/stats/commande_fournisseur.php
index 432b8965db8..e75a8578bb8 100644
--- a/htdocs/product/stock/stats/commande_fournisseur.php
+++ b/htdocs/product/stock/stats/commande_fournisseur.php
@@ -173,7 +173,7 @@ if ($id > 0 || !empty($ref)) {
// print ' ';
// }
//
- // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) {
+ // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABILITY)) {
// print '
'.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).' ';
// print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').' ';
// print '';
diff --git a/htdocs/product/stock/stats/expedition.php b/htdocs/product/stock/stats/expedition.php
index 01739862433..612b265a0b9 100644
--- a/htdocs/product/stock/stats/expedition.php
+++ b/htdocs/product/stock/stats/expedition.php
@@ -173,7 +173,7 @@ if ($id > 0 || !empty($ref)) {
// print '';
// }
//
- // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) {
+ // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABILITY)) {
// print '
'.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).' ';
// print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').' ';
// print '';
diff --git a/htdocs/product/stock/stats/reception.php b/htdocs/product/stock/stats/reception.php
index f4bd6f10d87..b6a019ff012 100644
--- a/htdocs/product/stock/stats/reception.php
+++ b/htdocs/product/stock/stats/reception.php
@@ -173,7 +173,7 @@ if ($id > 0 || !empty($ref)) {
// print '';
// }
//
- // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) {
+ // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABILITY)) {
// print '
'.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).' ';
// print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').' ';
// print '';
diff --git a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php
index da0ce6e3a4f..6d29d5e34e6 100644
--- a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php
+++ b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php
@@ -87,6 +87,7 @@ class StockTransfer extends CommonObject
public $date_prevue_arrivee;
public $date_reelle_depart;
public $date_reelle_arrivee;
+ public $origin_type;
const STATUS_DRAFT = 0;
@@ -725,8 +726,12 @@ class StockTransfer extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
- if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ $add_save_lastsearch_values = 1;
+ }
+ if ($add_save_lastsearch_values) {
+ $url .= '&save_lastsearch_values=1';
+ }
}
$linkclose = '';
diff --git a/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php b/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php
index 0a07568f09b..d97f782498f 100644
--- a/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php
+++ b/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php
@@ -293,8 +293,6 @@ class StockTransferLine extends CommonObjectLine
*/
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
{
- global $conf;
-
dol_syslog(__METHOD__, LOG_DEBUG);
$records = array();
@@ -723,8 +721,12 @@ class StockTransferLine extends CommonObjectLine
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
- if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ $add_save_lastsearch_values = 1;
+ }
+ if ($add_save_lastsearch_values) {
+ $url .= '&save_lastsearch_values=1';
+ }
}
$linkclose = '';
@@ -866,28 +868,6 @@ class StockTransferLine extends CommonObjectLine
$this->initAsSpecimenCommon();
}
- /**
- * Create an array of lines
- *
- * @return array|int array of lines if OK, <0 if KO
- */
- public function getLinesArray()
- {
- $this->lines = array();
-
- $objectline = new StockTransferLineLine($this->db);
- $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_stocktransferline = '.((int) $this->id)));
-
- if (is_numeric($result)) {
- $this->error = $objectline->error;
- $this->errors = $objectline->errors;
- return $result;
- } else {
- $this->lines = $result;
- return $this->lines;
- }
- }
-
/**
* Returns the reference to the following non used object depending on the active numbering module.
*
@@ -966,8 +946,8 @@ class StockTransferLine extends CommonObjectLine
if (!dol_strlen($modele)) {
$modele = 'standard_stocktransferline';
- if ($this->modelpdf) {
- $modele = $this->modelpdf;
+ if (!empty($this->model_pdf)) {
+ $modele = $this->model_pdf;
} elseif (!empty($conf->global->STOCKTRANSFERLINE_ADDON_PDF)) {
$modele = $conf->global->STOCKTRANSFERLINE_ADDON_PDF;
}
@@ -991,8 +971,6 @@ class StockTransferLine extends CommonObjectLine
*/
public function doScheduledJob()
{
- global $conf, $langs;
-
//$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
$error = 0;
@@ -1012,27 +990,3 @@ class StockTransferLine extends CommonObjectLine
return $error;
}
}
-
-/**
- * Class StockTransferLineLine. You can also remove this and generate a CRUD class for lines objects.
- */
-class StockTransferLineLine
-{
- // To complete with content of an object StockTransferLineLine
- // We should have a field rowid, fk_stocktransferline and position
-
- /**
- * @var int Does object support extrafields ? 0=No, 1=Yes
- */
- public $isextrafieldmanaged = 0;
-
- /**
- * Constructor
- *
- * @param DoliDb $db Database handler
- */
- public function __construct(DoliDB $db)
- {
- $this->db = $db;
- }
-}
diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php
index daf1dd0ac7b..d5108333f6d 100644
--- a/htdocs/projet/activity/perweek.php
+++ b/htdocs/projet/activity/perweek.php
@@ -760,7 +760,11 @@ if (count($tasksarray) > 0) {
$projectstatic->loadTimeSpent($firstdaytoshow, 0, $usertoprocess->id); // Load time spent from table element_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
for ($idw = 0; $idw < 7; $idw++) {
$tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
- $totalforeachday[$tmpday] += $projectstatic->weekWorkLoad[$tmpday];
+ if (empty($totalforeachday[$tmpday])) {
+ $totalforeachday[$tmpday] = empty($projectstatic->weekWorkLoad[$tmpday]) ? 0 : $projectstatic->weekWorkLoad[$tmpday];
+ } else {
+ $totalforeachday[$tmpday] += empty($projectstatic->weekWorkLoad[$tmpday]) ? 0 : $projectstatic->weekWorkLoad[$tmpday];
+ }
}
}
diff --git a/htdocs/projet/agenda.php b/htdocs/projet/agenda.php
index 5e8f0dfafbf..4b8b2640afe 100644
--- a/htdocs/projet/agenda.php
+++ b/htdocs/projet/agenda.php
@@ -127,7 +127,13 @@ print dol_get_fiche_head($head, 'agenda', $langs->trans("Project"), -1, ($object
// Project card
-$linkback = '
'.$langs->trans("BackToList").' ';
+if (!empty($_SESSION['pageforbacktolist']) && !empty($_SESSION['pageforbacktolist']['project'])) {
+ $tmpurl = $_SESSION['pageforbacktolist']['project'];
+ $tmpurl = preg_replace('/__SOCID__/', $object->socid, $tmpurl);
+ $linkback = '
'.$langs->trans("BackToList").' ';
+} else {
+ $linkback = '
'.$langs->trans("BackToList").' ';
+}
$morehtmlref = '
';
// Title
@@ -141,7 +147,7 @@ $morehtmlref .= '
';
// Define a complementary filter for search of next/prev ref.
if (empty($user->rights->projet->all->lire)) {
$objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
- $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
+ $object->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
}
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
diff --git a/htdocs/projet/ajax/projects.php b/htdocs/projet/ajax/projects.php
index 03d118dc9b9..fbb02a60a48 100644
--- a/htdocs/projet/ajax/projects.php
+++ b/htdocs/projet/ajax/projects.php
@@ -53,7 +53,6 @@ $discard_closed = GETPOST('discardclosed', 'int');
// Security check
restrictedArea($user, 'projet', 0, 'projet&project');
-
/*
* View
*/
@@ -62,29 +61,32 @@ dol_syslog("Call ajax projet/ajax/projects.php");
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
-top_httphead('application/json');
-
-if (empty($htmlname) && !GETPOST('mode', 'aZ09')) {
- return;
-}
-
// Mode to get list of projects
if (empty($mode) || $mode != 'gettasks') {
+ top_httphead('application/json');
+
// When used from jQuery, the search term is added as GET param "term".
$searchkey = (GETPOSTISSET($htmlname) ? GETPOST($htmlname, 'aZ09') : '');
$formproject = new FormProjets($db);
- $arrayresult = $formproject->select_projects_list($socid, '', $htmlname, 0, 0, 1, $discard_closed, 0, 0, 1, $searchkey);
-}
+ $arrayresult = $formproject->select_projects_list($socid, '', '', 0, 0, 1, $discard_closed, 0, 0, 1, $searchkey);
+
+ $db->close();
+
+ print json_encode($arrayresult);
-// Mode to get list of tasks
-if ($mode == 'gettasks') {
- $formproject = new FormProjets($db);
- $formproject->selectTasks((!empty($socid) ? $socid : -1), 0, 'taskid', 24, 1, '1', 1, 0, 0, 'maxwidth500', GETPOST('projectid', 'int'), '');
return;
}
+// Mode to get list of tasks
+// THIS MODE RETURNS HTML NOT JSON - THE CALL SHOULD BE UPDATE IN THE FUTURE
+if ($mode == 'gettasks') {
+ top_httphead();
-$db->close();
+ $formproject = new FormProjets($db);
+ $formproject->selectTasks((!empty($socid) ? $socid : -1), 0, 'taskid', 24, 1, '1', 1, 0, 0, 'maxwidth500', GETPOST('projectid', 'int'), '');
-print json_encode($arrayresult);
+ $db->close();
+
+ return;
+}
diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php
index 22237675fb3..801129da8e6 100644
--- a/htdocs/projet/card.php
+++ b/htdocs/projet/card.php
@@ -463,7 +463,16 @@ if (empty($reshook)) {
$result = $object->delete($user);
if ($result > 0) {
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
- header("Location: list.php?restore_lastsearch_values=1");
+
+ if (!empty($_SESSION['pageforbacktolist']) && !empty($_SESSION['pageforbacktolist']['project'])) {
+ $tmpurl = $_SESSION['pageforbacktolist']['project'];
+ $tmpurl = preg_replace('/__SOCID__/', $object->socid, $tmpurl);
+ $urlback = $tmpurl.(preg_match('/\?/', $tmpurl) ? '&' : '?'). 'restore_lastsearch_values=1';
+ } else {
+ $urlback = DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1';
+ }
+
+ header("Location: ".$urlback);
exit;
} else {
dol_syslog($object->error, LOG_DEBUG);
@@ -1221,7 +1230,13 @@ if ($action == 'create' && $user->rights->projet->creer) {
// Project card
- $linkback = '
'.$langs->trans("BackToList").' ';
+ if (!empty($_SESSION['pageforbacktolist']) && !empty($_SESSION['pageforbacktolist']['project'])) {
+ $tmpurl = $_SESSION['pageforbacktolist']['project'];
+ $tmpurl = preg_replace('/__SOCID__/', $object->socid, $tmpurl);
+ $linkback = '
'.$langs->trans("BackToList").' ';
+ } else {
+ $linkback = '
'.$langs->trans("BackToList").' ';
+ }
$morehtmlref = '
';
// Title
@@ -1236,7 +1251,7 @@ if ($action == 'create' && $user->rights->projet->creer) {
// Define a complementary filter for search of next/prev ref.
if (empty($user->rights->projet->all->lire)) {
$objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
- $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
+ $object->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
}
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
@@ -1563,7 +1578,7 @@ if ($action == 'create' && $user->rights->projet->creer) {
50 => array('lang'=>'suppliers', 'enabled'=>isModEnabled("supplier_order"), 'perm'=>$user->hasRight('fournisseur', 'commande', 'creer'), 'label' => 'AddSupplierOrder', 'url'=>'/fourn/commande/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid),
60 => array('lang'=>'suppliers', 'enabled'=>isModEnabled("supplier_invoice"), 'perm'=>$user->hasRight('fournisseur', 'facture', 'creer'), 'label' => 'AddSupplierInvoice', 'url'=>'/fourn/facture/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid),
70 => array('lang'=>'interventions', 'enabled'=>isModEnabled("ficheinter"), 'perm'=>$user->hasRight('fichinter', 'creer'), 'label' => 'AddIntervention', 'url'=>'/fichinter/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid),
- 80 => array('lang'=>'contrats', 'enabled'=>isModEnabled("contrat"), 'perm'=>$user->hasRight('contrat', 'creer'), 'label' => 'AddContract', 'url'=>'/contrat/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid),
+ 80 => array('lang'=>'contracts', 'enabled'=>isModEnabled("contrat"), 'perm'=>$user->hasRight('contrat', 'creer'), 'label' => 'AddContract', 'url'=>'/contrat/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid),
90 => array('lang'=>'trips', 'enabled'=>isModEnabled("expensereport"), 'perm'=>$user->hasRight('expensereport', 'creer'), 'label' => 'AddTrip', 'url'=>'/expensereport/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid),
100 => array('lang'=>'donations', 'enabled'=>isModEnabled("don"), 'perm'=>$user->hasRight('don', 'creer'), 'label' => 'AddDonation', 'url'=>'/don/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid),
);
@@ -1631,6 +1646,7 @@ if ($action == 'create' && $user->rights->projet->creer) {
// Presend form
$modelmail = 'project';
$defaulttopic = 'SendProjectRef';
+ $defaulttopiclang = 'projects';
$diroutput = $conf->project->multidir_output[$object->entity];
$autocopy = 'MAIN_MAIL_AUTOCOPY_PROJECT_TO'; // used to know the automatic BCC to add
$trackid = 'proj'.$object->id;
diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php
index c26264aaccf..91e22f4e054 100644
--- a/htdocs/projet/class/api_projects.class.php
+++ b/htdocs/projet/class/api_projects.class.php
@@ -42,6 +42,12 @@ class Projects extends DolibarrApi
*/
public $project;
+ /**
+ * @var Task $task {@type Task}
+ */
+ public $task;
+
+
/**
* Constructor
*/
@@ -100,8 +106,6 @@ class Projects extends DolibarrApi
*/
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $category = 0, $sqlfilters = '')
{
- global $db, $conf;
-
if (!DolibarrApiAccess::$user->rights->projet->lire) {
throw new RestException(401);
}
diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php
index 4466138e006..8d8b7b4147a 100644
--- a/htdocs/projet/class/project.class.php
+++ b/htdocs/projet/class/project.class.php
@@ -495,7 +495,6 @@ class Project extends CommonObject
}
} else {
$this->error = $this->db->lasterror();
- $this->errno = $this->db->lasterrno();
$error++;
}
@@ -1313,9 +1312,10 @@ class Project extends CommonObject
* @param int $notooltip 1=Disable tooltip
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
* @param string $morecss More css on a link
+ * @param string $save_pageforbacktolist Back to this page 'context:url'
* @return string String with URL
*/
- public function getNomUrl($withpicto = 0, $option = '', $addlabel = 0, $moreinpopup = '', $sep = ' - ', $notooltip = 0, $save_lastsearch_value = -1, $morecss = '')
+ public function getNomUrl($withpicto = 0, $option = '', $addlabel = 0, $moreinpopup = '', $sep = ' - ', $notooltip = 0, $save_lastsearch_value = -1, $morecss = '', $save_pageforbacktolist = '')
{
global $conf, $langs, $user, $hookmanager;
@@ -1358,12 +1358,16 @@ class Project extends CommonObject
}
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
$url .= '&save_lastsearch_values=1';
}
+ $add_save_backpagefor = ($save_pageforbacktolist ? 1 : 0);
+ if ($add_save_backpagefor) {
+ $url .= "&save_pageforbacktolist=".urlencode($save_pageforbacktolist);
+ }
}
$linkclose = '';
diff --git a/htdocs/projet/class/projectstats.class.php b/htdocs/projet/class/projectstats.class.php
index 014753f7131..d14e2ec6213 100644
--- a/htdocs/projet/class/projectstats.class.php
+++ b/htdocs/projet/class/projectstats.class.php
@@ -27,8 +27,6 @@ class ProjectStats extends Stats
private $project;
public $userid;
public $socid;
- public $year;
- public $yearmonth;
public $status;
public $opp_status;
diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php
index 51b4d3e68e1..45c7c12f487 100644
--- a/htdocs/projet/class/task.class.php
+++ b/htdocs/projet/class/task.class.php
@@ -800,7 +800,7 @@ class Task extends CommonObjectLine
$url = DOL_URL_ROOT.'/projet/tasks/'.$mode.'.php?id='.$this->id.($option == 'withproject' ? '&withproject=1' : '');
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
diff --git a/htdocs/projet/class/taskstats.class.php b/htdocs/projet/class/taskstats.class.php
index b97a2c8ebb5..5c0192fa937 100644
--- a/htdocs/projet/class/taskstats.class.php
+++ b/htdocs/projet/class/taskstats.class.php
@@ -27,8 +27,11 @@ class TaskStats extends Stats
private $project;
public $userid;
public $socid;
- public $year;
- public $month;
+
+ /**
+ * @var int priority
+ */
+ public $priority;
/**
* Constructor of the class
@@ -55,7 +58,7 @@ class TaskStats extends Stats
$sql = "SELECT";
$sql .= " COUNT(t.rowid), t.priority";
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task as t INNER JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = t.fk_projet";
- if (empty($user->rights->societe->client->voir) && !$user->soc_id) {
+ if (empty($user->rights->societe->client->voir) && !$user->socid) {
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc=p.fk_soc AND sc.fk_user=".((int) $user->id);
}
$sql .= $this->buildWhere();
@@ -109,7 +112,7 @@ class TaskStats extends Stats
$sql = "SELECT date_format(t.datec,'%Y') as year, COUNT(t.rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task as t INNER JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = t.fk_projet";
- if (empty($user->rights->societe->client->voir) && !$user->soc_id) {
+ if (empty($user->rights->societe->client->voir) && !$user->socid) {
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc=p.fk_soc AND sc.fk_user=".((int) $user->id);
}
$sql .= $this->buildWhere();
@@ -171,7 +174,7 @@ class TaskStats extends Stats
$sql = "SELECT date_format(t.datec,'%m') as dm, COUNT(t.rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task as t INNER JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = t.fk_projet";
- if (empty($user->rights->societe->client->voir) && !$user->soc_id) {
+ if (empty($user->rights->societe->client->voir) && !$user->socid) {
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc=p.fk_soc AND sc.fk_user=".((int) $user->id);
}
$sql .= $this->buildWhere();
diff --git a/htdocs/projet/comment.php b/htdocs/projet/comment.php
index b418eb54441..a27bb8db561 100644
--- a/htdocs/projet/comment.php
+++ b/htdocs/projet/comment.php
@@ -98,7 +98,13 @@ $param = ($mode == 'mine' ? '&mode=mine' : '');
// Project card
-$linkback = '
'.$langs->trans("BackToList").' ';
+if (!empty($_SESSION['pageforbacktolist']) && !empty($_SESSION['pageforbacktolist']['project'])) {
+ $tmpurl = $_SESSION['pageforbacktolist']['project'];
+ $tmpurl = preg_replace('/__SOCID__/', $object->socid, $tmpurl);
+ $linkback = '
'.$langs->trans("BackToList").' ';
+} else {
+ $linkback = '
'.$langs->trans("BackToList").' ';
+}
$morehtmlref = '
';
// Title
@@ -112,7 +118,7 @@ $morehtmlref .= '
';
// Define a complementary filter for search of next/prev ref.
if (empty($user->rights->projet->all->lire)) {
$objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
- $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
+ $object->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
}
dol_banner_tab($object, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php
index b0fece54827..b21dbf46a0d 100644
--- a/htdocs/projet/contact.php
+++ b/htdocs/projet/contact.php
@@ -294,7 +294,13 @@ if ($id > 0 || !empty($ref)) {
// Project card
- $linkback = '
'.$langs->trans("BackToList").' ';
+ if (!empty($_SESSION['pageforbacktolist']) && !empty($_SESSION['pageforbacktolist']['project'])) {
+ $tmpurl = $_SESSION['pageforbacktolist']['project'];
+ $tmpurl = preg_replace('/__SOCID__/', $object->socid, $tmpurl);
+ $linkback = '
'.$langs->trans("BackToList").' ';
+ } else {
+ $linkback = '
'.$langs->trans("BackToList").' ';
+ }
$morehtmlref = '
';
// Title
@@ -309,7 +315,7 @@ if ($id > 0 || !empty($ref)) {
// Define a complementary filter for search of next/prev ref.
if (empty($user->rights->projet->all->lire)) {
$objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
- $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
+ $object->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
}
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php
index 19ecebb2214..9b5f2e2c31c 100644
--- a/htdocs/projet/document.php
+++ b/htdocs/projet/document.php
@@ -131,7 +131,13 @@ if ($object->id > 0) {
// Project card
- $linkback = '
'.$langs->trans("BackToList").' ';
+ if (!empty($_SESSION['pageforbacktolist']) && !empty($_SESSION['pageforbacktolist']['project'])) {
+ $tmpurl = $_SESSION['pageforbacktolist']['project'];
+ $tmpurl = preg_replace('/__SOCID__/', $object->socid, $tmpurl);
+ $linkback = '
'.$langs->trans("BackToList").' ';
+ } else {
+ $linkback = '
'.$langs->trans("BackToList").' ';
+ }
$morehtmlref = '
';
// Title
@@ -145,7 +151,7 @@ if ($object->id > 0) {
// Define a complementary filter for search of next/prev ref.
if (empty($user->rights->projet->all->lire)) {
$objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
- $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
+ $object->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
}
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php
index bca52b73045..cf740aadcfa 100644
--- a/htdocs/projet/element.php
+++ b/htdocs/projet/element.php
@@ -212,7 +212,13 @@ print dol_get_fiche_head($head, 'element', $langs->trans("Project"), -1, ($objec
// Project card
-$linkback = '
'.$langs->trans("BackToList").' ';
+if (!empty($_SESSION['pageforbacktolist']) && !empty($_SESSION['pageforbacktolist']['project'])) {
+ $tmpurl = $_SESSION['pageforbacktolist']['project'];
+ $tmpurl = preg_replace('/__SOCID__/', $object->socid, $tmpurl);
+ $linkback = '
'.$langs->trans("BackToList").' ';
+} else {
+ $linkback = '
'.$langs->trans("BackToList").' ';
+}
$morehtmlref = '
';
// Title
@@ -226,7 +232,7 @@ $morehtmlref .= '
';
// Define a complementary filter for search of next/prev ref.
if (empty($user->rights->projet->all->lire)) {
$objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
- $object->next_prev_filter = " te.rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
+ $object->next_prev_filter = "te.rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
}
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php
index 47f7cb0a9ef..145152d0089 100644
--- a/htdocs/projet/ganttview.php
+++ b/htdocs/projet/ganttview.php
@@ -110,7 +110,13 @@ if (($id > 0 && is_numeric($id)) || !empty($ref)) {
// Project card
- $linkback = '
'.$langs->trans("BackToList").' ';
+ if (!empty($_SESSION['pageforbacktolist']) && !empty($_SESSION['pageforbacktolist']['project'])) {
+ $tmpurl = $_SESSION['pageforbacktolist']['project'];
+ $tmpurl = preg_replace('/__SOCID__/', $object->socid, $tmpurl);
+ $linkback = '
'.$langs->trans("BackToList").' ';
+ } else {
+ $linkback = '
'.$langs->trans("BackToList").' ';
+ }
$morehtmlref = '
';
// Title
@@ -124,7 +130,7 @@ if (($id > 0 && is_numeric($id)) || !empty($ref)) {
// Define a complementary filter for search of next/prev ref.
if (empty($user->rights->projet->all->lire)) {
$objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
- $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
+ $object->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
}
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php
index aa40ba4bc5a..c781fb49e17 100644
--- a/htdocs/projet/index.php
+++ b/htdocs/projet/index.php
@@ -53,7 +53,7 @@ if ($search_project_user == $user->id) {
// Security check
$socid = 0;
//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement.
-if (!$user->rights->projet->lire) {
+if (!$user->hasRight('projet', 'lire')) {
accessforbidden();
}
diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php
index 643c020cc50..3d4904c272c 100644
--- a/htdocs/projet/list.php
+++ b/htdocs/projet/list.php
@@ -375,6 +375,8 @@ if (empty($reshook)) {
* View
*/
+unset($_SESSION['pageforbacktolist']['project']);
+
$form = new Form($db);
$formcompany = new FormCompany($db);
@@ -992,12 +994,12 @@ $includeonly = '';
if (empty($user->rights->user->user->lire)) {
$includeonly = array($user->id);
}
-$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', $tmptitle, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx');
+$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', $tmptitle, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth300 widthcentpercentminusx');
$moreforfilter .= '
';
$moreforfilter .= '
';
$tmptitle = $langs->trans('ProjectsWithThisContact');
-$moreforfilter .= img_picto($tmptitle, 'contact', 'class="pictofixedwidth"').$form->selectcontacts(0, $search_project_contact ? $search_project_contact : '', 'search_project_contact', $tmptitle, '', '', 0, 'maxwidth250 widthcentpercentminusx');
+$moreforfilter .= img_picto($tmptitle, 'contact', 'class="pictofixedwidth"').$form->selectcontacts(0, $search_project_contact ? $search_project_contact : '', 'search_project_contact', $tmptitle, '', '', 0, 'maxwidth300 widthcentpercentminusx');
$moreforfilter .= '
';
// If the user can view thirdparties other than his'
@@ -1005,14 +1007,14 @@ if ($user->rights->user->user->lire) {
$langs->load("commercial");
$moreforfilter .= '
';
$tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
- $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx');
+ $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth300 widthcentpercentminusx');
$moreforfilter .= '
';
}
// Filter on categories
if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) {
$formcategory = new FormCategory($db);
- $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PROJECT, $search_category_array, 'minwidth300imp widthcentpercentminusx');
+ $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PROJECT, $search_category_array, 'minwidth300imp minwidth300 widthcentpercentminusx');
}
// Filter on customer categories
if (!empty($conf->global->MAIN_SEARCH_CATEGORY_CUSTOMER_ON_PROJECT_LIST) && isModEnabled("categorie") && $user->hasRight('categorie', 'lire')) {
@@ -1021,7 +1023,7 @@ if (!empty($conf->global->MAIN_SEARCH_CATEGORY_CUSTOMER_ON_PROJECT_LIST) && isMo
$moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"');
$categoriesArr = $form->select_all_categories(Categorie::TYPE_CUSTOMER, '', '', 64, 0, 1);
$categoriesArr[-2] = '- '.$langs->trans('NotCategorized').' -';
- $moreforfilter .= Form::multiselectarray('search_category_customer_list', $categoriesArr, $searchCategoryCustomerList, 0, 0, 'minwidth300', 0, 0, '', 'category', $tmptitle);
+ $moreforfilter .= Form::multiselectarray('search_category_customer_list', $categoriesArr, $searchCategoryCustomerList, 0, 0, 'minwidth300im minwidth300 widthcentpercentminusx', 0, 0, '', 'category', $tmptitle);
$moreforfilter .= '
';
$moreforfilter .= $form->textwithpicto('', $langs->trans('UseOrOperatorForCategories') . ' : ' . $tmptitle, 1, 'help', '', 0, 2, 'tooltip_cat_cus'); // Tooltip on click
$moreforfilter .= '
';
@@ -1465,19 +1467,20 @@ while ($i < $imaxinloop) {
$c = new Contact($db);
}
$c->fetch($contactproject['id']);
- if (!empty($c->photo)) {
- if (get_class($c) == 'User') {
- $stringassignedusers .= $c->getNomUrl(-2, '', 0, 0, 24, 1, '', 'valignmiddle'.($ifisrt ? '' : ' notfirst'));
- } else {
- $stringassignedusers .= $c->getNomUrl(-2, '', 0, '', -1, 0, 'valignmiddle'.($ifisrt ? '' : ' notfirst'));
- }
+ //var_dump($c->photo);
+ //if (!empty($c->photo)) {
+ if (get_class($c) == 'User') {
+ $stringassignedusers .= $c->getNomUrl(-2, '', 0, 0, 24, 1, '', 'valignmiddle'.($ifisrt ? '' : ' notfirst'));
} else {
+ $stringassignedusers .= $c->getNomUrl(-2, '', 0, '', -1, 0, 'valignmiddle'.($ifisrt ? '' : ' notfirst'));
+ }
+ /*} else {
if (get_class($c) == 'User') {
$stringassignedusers .= $c->getNomUrl(2, '', 0, 0, 24, 1, '', 'valignmiddle'.($ifisrt ? '' : ' notfirst'));
} else {
$stringassignedusers .= $c->getNomUrl(2, '', 0, '', -1, 0, 'valignmiddle'.($ifisrt ? '' : ' notfirst'));
}
- }
+ }*/
$ifisrt = 0;
}
}
diff --git a/htdocs/projet/messaging.php b/htdocs/projet/messaging.php
index e0290d984a4..9787e7ca587 100644
--- a/htdocs/projet/messaging.php
+++ b/htdocs/projet/messaging.php
@@ -126,7 +126,13 @@ print dol_get_fiche_head($head, 'agenda', $langs->trans("Project"), -1, ($object
// Project card
-$linkback = '
'.$langs->trans("BackToList").' ';
+if (!empty($_SESSION['pageforbacktolist']) && !empty($_SESSION['pageforbacktolist']['project'])) {
+ $tmpurl = $_SESSION['pageforbacktolist']['project'];
+ $tmpurl = preg_replace('/__SOCID__/', $object->socid, $tmpurl);
+ $linkback = '
'.$langs->trans("BackToList").' ';
+} else {
+ $linkback = '
'.$langs->trans("BackToList").' ';
+}
$morehtmlref = '
';
// Title
@@ -140,7 +146,7 @@ $morehtmlref .= '
';
// Define a complementary filter for search of next/prev ref.
if (empty($user->rights->projet->all->lire)) {
$objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
- $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
+ $object->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
}
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
diff --git a/htdocs/projet/note.php b/htdocs/projet/note.php
index 20392059916..55f3e6d864a 100644
--- a/htdocs/projet/note.php
+++ b/htdocs/projet/note.php
@@ -96,7 +96,13 @@ if ($id > 0 || !empty($ref)) {
// Project card
- $linkback = '
'.$langs->trans("BackToList").' ';
+ if (!empty($_SESSION['pageforbacktolist']) && !empty($_SESSION['pageforbacktolist']['project'])) {
+ $tmpurl = $_SESSION['pageforbacktolist']['project'];
+ $tmpurl = preg_replace('/__SOCID__/', $object->socid, $tmpurl);
+ $linkback = '
'.$langs->trans("BackToList").' ';
+ } else {
+ $linkback = '
'.$langs->trans("BackToList").' ';
+ }
$morehtmlref = '
';
// Title
@@ -110,7 +116,7 @@ if ($id > 0 || !empty($ref)) {
// Define a complementary filter for search of next/prev ref.
if (empty($user->rights->projet->all->lire)) {
$objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
- $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
+ $object->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
}
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php
index 196bc2d4582..db780ddfa44 100644
--- a/htdocs/projet/tasks.php
+++ b/htdocs/projet/tasks.php
@@ -566,7 +566,13 @@ if ($id > 0 || !empty($ref)) {
// Project card
- $linkback = '
'.$langs->trans("BackToList").' ';
+ if (!empty($_SESSION['pageforbacktolist']) && !empty($_SESSION['pageforbacktolist']['project'])) {
+ $tmpurl = $_SESSION['pageforbacktolist']['project'];
+ $tmpurl = preg_replace('/__SOCID__/', $object->socid, $tmpurl);
+ $linkback = '
'.$langs->trans("BackToList").' ';
+ } else {
+ $linkback = '
'.$langs->trans("BackToList").' ';
+ }
$morehtmlref = '
';
// Title
@@ -580,7 +586,7 @@ if ($id > 0 || !empty($ref)) {
// Define a complementary filter for search of next/prev ref.
if (empty($user->rights->projet->all->lire)) {
$objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
- $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
+ $object->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
}
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
@@ -723,6 +729,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
print dol_get_fiche_head('');
+ print '
';
print '
';
$defaultref = '';
@@ -749,7 +756,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
// Label
print ''.$langs->trans("Label").' ';
- print ' ';
+ print ' ';
print ' ';
// Project
@@ -768,12 +775,12 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
print ''.$langs->trans("AffectedTo").' ';
print img_picto('', 'user', 'class="pictofixedwidth"');
if (is_array($contactsofproject) && count($contactsofproject)) {
- print $form->select_dolusers($user->id, 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, '', 'maxwidth300');
+ print $form->select_dolusers($user->id, 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, '', 'maxwidth500 widthcentpercentminusx');
} else {
if ((isset($projectid) && $projectid > 0) || $object->id > 0) {
print ''.$langs->trans("NoUserAssignedToTheProject").' ';
} else {
- print $form->select_dolusers($user->id, 'userid', 0, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
+ print $form->select_dolusers($user->id, 'userid', 0, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth500 widthcentpercentminusx');
}
}
print ' ';
@@ -813,7 +820,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
$nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT;
}
- $doleditor = new DolEditor('description', $object->description, '', 80, 'dolibarr_details', '', false, true, $cked_enabled, $nbrows);
+ $doleditor = new DolEditor('description', $object->description, '', 80, 'dolibarr_details', '', false, true, $cked_enabled, $nbrows, '90%');
print $doleditor->Create();
print '';
@@ -833,6 +840,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
}
print '
';
+ print '
';
print dol_get_fiche_end();
diff --git a/htdocs/projet/tasks/comment.php b/htdocs/projet/tasks/comment.php
index 5199c026b93..33ac8ea5767 100644
--- a/htdocs/projet/tasks/comment.php
+++ b/htdocs/projet/tasks/comment.php
@@ -139,7 +139,7 @@ if ($id > 0 || !empty($ref)) {
// Define a complementary filter for search of next/prev ref.
if (empty($user->rights->projet->all->lire)) {
$objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
- $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
+ $projectstatic->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
}
dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
@@ -292,9 +292,9 @@ if ($id > 0 || !empty($ref)) {
if (!GETPOST('withproject') || empty($projectstatic->id)) {
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
- $object->next_prev_filter = " fk_projet IN (".$db->sanitize($projectsListId).")";
+ $object->next_prev_filter = "fk_projet IN (".$db->sanitize($projectsListId).")";
} else {
- $object->next_prev_filter = " fk_projet = ".((int) $projectstatic->id);
+ $object->next_prev_filter = "fk_projet = ".((int) $projectstatic->id);
}
$morehtmlref = '';
diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php
index 16d60a15033..8bde7e16c5a 100644
--- a/htdocs/projet/tasks/contact.php
+++ b/htdocs/projet/tasks/contact.php
@@ -203,7 +203,7 @@ if ($id > 0 || !empty($ref)) {
// Define a complementary filter for search of next/prev ref.
if (empty($user->rights->projet->all->lire)) {
$objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
- $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
+ $projectstatic->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
}
dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
@@ -326,9 +326,9 @@ if ($id > 0 || !empty($ref)) {
if (!GETPOST('withproject') || empty($projectstatic->id)) {
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
- $object->next_prev_filter = " fk_projet IN (".$db->sanitize($projectsListId).")";
+ $object->next_prev_filter = "fk_projet IN (".$db->sanitize($projectsListId).")";
} else {
- $object->next_prev_filter = " fk_projet = ".$projectstatic->id;
+ $object->next_prev_filter = "fk_projet = ".((int) $projectstatic->id);
}
$morehtmlref = '';
diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php
index ba9249411aa..2f761e1b304 100644
--- a/htdocs/projet/tasks/document.php
+++ b/htdocs/projet/tasks/document.php
@@ -160,7 +160,7 @@ if ($object->id > 0) {
// Define a complementary filter for search of next/prev ref.
if (empty($user->rights->projet->all->lire)) {
$objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
- $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
+ $projectstatic->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
}
dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
@@ -284,9 +284,9 @@ if ($object->id > 0) {
if (!GETPOST('withproject') || empty($projectstatic->id)) {
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
- $object->next_prev_filter = " fk_projet IN (".$db->sanitize($projectsListId).")";
+ $object->next_prev_filter = "fk_projet IN (".$db->sanitize($projectsListId).")";
} else {
- $object->next_prev_filter = " fk_projet = ".$projectstatic->id;
+ $object->next_prev_filter = "fk_projet = ".((int) $projectstatic->id);
}
$morehtmlref = '';
diff --git a/htdocs/projet/tasks/note.php b/htdocs/projet/tasks/note.php
index 2e3166fb46d..fd3222907d4 100644
--- a/htdocs/projet/tasks/note.php
+++ b/htdocs/projet/tasks/note.php
@@ -150,7 +150,7 @@ if ($object->id > 0) {
// Define a complementary filter for search of next/prev ref.
if (empty($user->rights->projet->all->lire)) {
$objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
- $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
+ $projectstatic->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
}
dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
@@ -270,7 +270,7 @@ if ($object->id > 0) {
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
$object->next_prev_filter = " fk_projet IN (".$db->sanitize($projectsListId).")";
} else {
- $object->next_prev_filter = " fk_projet = ".$projectstatic->id;
+ $object->next_prev_filter = " fk_projet = ".((int) $projectstatic->id);
}
$morehtmlref = '';
diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php
index fd76494cb9f..b8ff5a6f9bc 100644
--- a/htdocs/projet/tasks/task.php
+++ b/htdocs/projet/tasks/task.php
@@ -275,7 +275,7 @@ if ($id > 0 || !empty($ref)) {
// Define a complementary filter for search of next/prev ref.
if (empty($user->rights->projet->all->lire)) {
$objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
- $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
+ $projectstatic->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
}
dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
@@ -537,9 +537,9 @@ if ($id > 0 || !empty($ref)) {
if (!GETPOST('withproject') || empty($projectstatic->id)) {
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
- $object->next_prev_filter = " fk_projet IN (".$db->sanitize($projectsListId).")";
+ $object->next_prev_filter = "fk_projet IN (".$db->sanitize($projectsListId).")";
} else {
- $object->next_prev_filter = " fk_projet = ".((int) $projectstatic->id);
+ $object->next_prev_filter = "fk_projet = ".((int) $projectstatic->id);
}
$morehtmlref = '';
diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php
index 52f68b11b08..10fc2f1508c 100644
--- a/htdocs/projet/tasks/time.php
+++ b/htdocs/projet/tasks/time.php
@@ -23,46 +23,46 @@
*/
/**
- * \file htdocs/projet/tasks/time.php
- * \ingroup project
- * \brief Page to add new time spent on a task
+ * \file htdocs/projet/tasks/time.php
+ * \ingroup project
+ * \brief Page to add new time spent on a task
*/
// Load Dolibarr environment
require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
-require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
-require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formintervention.class.php';
+require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
+require_once DOL_DOCUMENT_ROOT . '/projet/class/task.class.php';
+require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/lib/project.lib.php';
+require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/html.formintervention.class.php';
// Load translation files required by the page
-$langsLoad=array('projects', 'bills', 'orders', 'companies');
+$langsLoad = array('projects', 'bills', 'orders', 'companies');
if (isModEnabled('eventorganization')) {
- $langsLoad[]='eventorganization';
+ $langsLoad[] = 'eventorganization';
}
$langs->loadLangs($langsLoad);
-$action = GETPOST('action', 'alpha');
+$action = GETPOST('action', 'alpha');
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
-$confirm = GETPOST('confirm', 'alpha');
-$cancel = GETPOST('cancel', 'alpha');
+$confirm = GETPOST('confirm', 'alpha');
+$cancel = GETPOST('cancel', 'alpha');
$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
-$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'timespentlist'; // To manage different context of search
+$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'timespentlist'; // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
-$optioncss = GETPOST('optioncss', 'alpha');
-$mode = GETPOST('mode', 'alpha');
+$optioncss = GETPOST('optioncss', 'alpha');
+$mode = GETPOST('mode', 'alpha');
-$id = GETPOST('id', 'int');
-$projectid = GETPOST('projectid', 'int');
-$ref = GETPOST('ref', 'alpha');
+$id = GETPOST('id', 'int');
+$projectid = GETPOST('projectid', 'int');
+$ref = GETPOST('ref', 'alpha');
$withproject = GETPOST('withproject', 'int');
$project_ref = GETPOST('project_ref', 'alpha');
-$tab = GETPOST('tab', 'aZ09');
+$tab = GETPOST('tab', 'aZ09');
$search_day = GETPOST('search_day', 'int');
$search_month = GETPOST('search_month', 'int');
@@ -92,13 +92,13 @@ $search_timespent_startmin = GETPOSTINT("search_timespent_duration_startmin");
$search_timespent_endhour = GETPOSTINT("search_timespent_duration_endhour");
$search_timespent_endmin = GETPOSTINT("search_timespent_duration_endmin");
-$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
+$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
-} // If $page is not defined, or '' or -1
+} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
@@ -158,13 +158,13 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa
$massaction = '';
}
-$parameters = array('socid'=>$socid, 'projectid'=>$projectid);
+$parameters = array('socid' => $socid, 'projectid' => $projectid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
-include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
+include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php';
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
@@ -242,7 +242,7 @@ if ($action == 'addtimespent' && $user->rights->projet->time) {
}
$object->timespent_duration = GETPOSTINT("timespent_durationhour") * 60 * 60; // We store duration in seconds
$object->timespent_duration += (GETPOSTINT('timespent_durationmin') ? GETPOSTINT('timespent_durationmin') : 0) * 60; // We store duration in seconds
- if (GETPOST("timehour") != '' && GETPOST("timehour") >= 0) { // If hour was entered
+ if (GETPOST("timehour") != '' && GETPOST("timehour") >= 0) { // If hour was entered
$object->timespent_date = dol_mktime(GETPOST("timehour", 'int'), GETPOST("timemin", 'int'), 0, GETPOST("timemonth", 'int'), GETPOST("timeday", 'int'), GETPOST("timeyear", 'int'));
$object->timespent_withhour = 1;
} else {
@@ -279,7 +279,7 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us
}
if (!$error) {
- if (GETPOST('taskid', 'int') != $id) { // GETPOST('taskid') is id of new task
+ if (GETPOST('taskid', 'int') != $id) { // GETPOST('taskid') is id of new task
$id_temp = GETPOST('taskid', 'int'); // should not overwrite $id
@@ -296,7 +296,7 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us
$object->timespent_old_duration = GETPOST("old_duration", "int");
$object->timespent_duration = GETPOSTINT("new_durationhour") * 60 * 60; // We store duration in seconds
$object->timespent_duration += (GETPOSTINT("new_durationmin") ? GETPOSTINT('new_durationmin') : 0) * 60; // We store duration in seconds
- if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) { // If hour was entered
+ if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) { // If hour was entered
$object->timespent_date = dol_mktime(GETPOST("timelinehour"), GETPOST("timelinemin"), 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear"));
$object->timespent_withhour = 1;
} else {
@@ -325,7 +325,7 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us
$object->timespent_old_duration = GETPOST("old_duration", "int");
$object->timespent_duration = GETPOSTINT("new_durationhour") * 60 * 60; // We store duration in seconds
$object->timespent_duration += (GETPOSTINT("new_durationmin") ? GETPOSTINT('new_durationmin') : 0) * 60; // We store duration in seconds
- if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) { // If hour was entered
+ if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) { // If hour was entered
$object->timespent_date = dol_mktime(GETPOST("timelinehour", 'int'), GETPOST("timelinemin", 'int'), 0, GETPOST("timelinemonth", 'int'), GETPOST("timelineday", 'int'), GETPOST("timelineyear", 'int'));
$object->timespent_withhour = 1;
} else {
@@ -354,10 +354,10 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us
}
if ($action == 'confirm_deleteline' && $confirm == "yes" && ($user->hasRight('projet', 'time') || $user->hasRight('projet', 'all', 'creer'))) {
- $object->fetchTimeSpent(GETPOST('lineid', 'int')); // load properties like $object->timespent_xxx
+ $object->fetchTimeSpent(GETPOST('lineid', 'int')); // load properties like $object->timespent_xxx
if (in_array($object->timespent_fk_user, $childids) || $user->hasRight('projet', 'all', 'creer')) {
- $result = $object->delTimeSpent($user); // delete line with $object->timespent_id
+ $result = $object->delTimeSpent($user); // delete line with $object->timespent_id
if ($result < 0) {
$langs->load("errors");
@@ -377,7 +377,7 @@ if (!empty($project_ref) && !empty($withproject)) {
if (count($tasksarray) > 0) {
$id = $tasksarray[0]->id;
} else {
- header("Location: ".DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.($withproject ? '&withproject=1' : '').(empty($mode) ? '' : '&mode='.$mode));
+ header("Location: " . DOL_URL_ROOT . '/projet/tasks.php?id=' . $projectstatic->id . ($withproject ? '&withproject=1' : '') . (empty($mode) ? '' : '&mode=' . $mode));
exit;
}
}
@@ -414,9 +414,9 @@ if ($action == 'confirm_generateinvoice') {
if (!($projectstatic->thirdparty->id > 0)) {
setEventMessages($langs->trans("ThirdPartyRequiredToGenerateInvoice"), null, 'errors');
} else {
- include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
- include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
- include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
+ include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
+ include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
+ include_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
$tmpinvoice = new Facture($db);
$tmptimespent = new Task($db);
@@ -432,13 +432,13 @@ if ($action == 'confirm_generateinvoice') {
$product_data_cache = array();
if ($idprod > 0) {
$tmpproduct->fetch($idprod);
- if ($result<0) {
+ if ($result < 0) {
$error++;
setEventMessages($tmpproduct->error, $tmpproduct->errors, 'errors');
}
- $prodDurationHoursBase=$tmpproduct->getProductDurationHours();
- if ($prodDurationHoursBase<0) {
+ $prodDurationHoursBase = $tmpproduct->getProductDurationHours();
+ if ($prodDurationHoursBase < 0) {
$error++;
$langs->load("errors");
setEventMessages(null, $tmpproduct->errors, 'errors');
@@ -477,11 +477,11 @@ if ($action == 'confirm_generateinvoice') {
}
if (!$error) {
- if ($generateinvoicemode == 'onelineperuser') { // 1 line per user (and per product)
+ if ($generateinvoicemode == 'onelineperuser') { // 1 line per user (and per product)
$arrayoftasks = array();
foreach ($toselect as $key => $value) {
// Get userid, timepent
- $object->fetchTimeSpent($value); // $value is ID of 1 line in timespent table
+ $object->fetchTimeSpent($value); // $value is ID of 1 line in timespent table
$arrayoftasks[$object->timespent_fk_user][(int) $object->timespent_fk_product]['timespent'] += $object->timespent_duration;
$arrayoftasks[$object->timespent_fk_user][(int) $object->timespent_fk_product]['totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm);
}
@@ -513,7 +513,7 @@ if ($action == 'confirm_generateinvoice') {
// Add lines
$prodDurationHours = $prodDurationHoursBase;
- $idprodline=$idprod;
+ $idprodline = $idprod;
$pu_htline = $pu_ht;
$txtvaline = $txtva;
$localtax1line = $localtax1;
@@ -541,7 +541,7 @@ if ($action == 'confirm_generateinvoice') {
$localtax1line = $dataforprice['localtax1'];
$localtax2line = $dataforprice['localtax2'];
- $product_data_cache[$fk_product] = array('duration'=>$prodDurationHours,'dataforprice'=>$dataforprice);
+ $product_data_cache[$fk_product] = array('duration' => $prodDurationHours, 'dataforprice' => $dataforprice);
} else {
$prodDurationHours = $product_data_cache[$fk_product]['duration'];
$pu_htline = empty($product_data_cache[$fk_product]['dataforprice']['pu_ht']) ? 0 : $product_data_cache[$fk_product]['dataforprice']['pu_ht'];
@@ -549,12 +549,12 @@ if ($action == 'confirm_generateinvoice') {
$localtax1line = $product_data_cache[$fk_product]['dataforprice']['localtax1'];
$localtax2line = $product_data_cache[$fk_product]['dataforprice']['localtax2'];
}
- $idprodline=$fk_product;
+ $idprodline = $fk_product;
}
// Add lines
- $lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username).' : '.$qtyhourtext, $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0));
- if ($lineid<0) {
+ $lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username) . ' : ' . $qtyhourtext, $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0));
+ if ($lineid < 0) {
$error++;
setEventMessages(null, $tmpinvoice->errors, 'errors');
}
@@ -570,10 +570,10 @@ if ($action == 'confirm_generateinvoice') {
}
}
}
- } elseif ($generateinvoicemode == 'onelineperperiod') { // One line for each time spent line
+ } elseif ($generateinvoicemode == 'onelineperperiod') { // One line for each time spent line
$arrayoftasks = array();
- $withdetail=GETPOST('detail_time_duration', 'alpha');
+ $withdetail = GETPOST('detail_time_duration', 'alpha');
foreach ($toselect as $key => $value) {
// Get userid, timepent
$object->fetchTimeSpent($value);
@@ -586,20 +586,16 @@ if ($action == 'confirm_generateinvoice') {
$arrayoftasks[$object->timespent_id]['timespent'] = $object->timespent_duration;
$arrayoftasks[$object->timespent_id]['totalvaluetodivideby3600'] = $object->timespent_duration * $object->timespent_thm;
- $arrayoftasks[$object->timespent_id]['note'] = $ftask->ref.' - '.$ftask->label.' - '.$username.($object->timespent_note ? ' - '.$object->timespent_note : ''); // TODO Add user name in note
- if (!empty($withdetail)) {
- if (isModEnabled('fckeditor') && !empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) {
- $arrayoftasks[$object->timespent_id]['note'] .= "
";
- } else {
- $arrayoftasks[$object->timespent_id]['note'] .= "\n";
- }
+ $arrayoftasks[$object->timespent_id]['note'] = $ftask->ref . ' - ' . $ftask->label . ' - ' . $username;
+ $arrayoftasks[$object->timespent_id]['note'] = dol_concatdesc($arrayoftasks[$object->timespent_id]['note'], $object->timespent_note);
+ if (!empty($withdetail)) {
if (!empty($object->timespent_withhour)) {
- $arrayoftasks[$object->timespent_id]['note'] .= $langs->trans("Date") . ': ' . dol_print_date($object->timespent_datehour);
+ $arrayoftasks[$object->timespent_id]['note'] = dol_concatdesc($arrayoftasks[$object->timespent_id]['note'], $langs->trans("Date") . ': ' . dol_print_date($object->timespent_datehour));
} else {
- $arrayoftasks[$object->timespent_id]['note'] .= $langs->trans("Date") . ': ' . dol_print_date($object->timespent_date);
+ $arrayoftasks[$object->timespent_id]['note'] = dol_concatdesc($arrayoftasks[$object->timespent_id]['note'], $langs->trans("Date") . ': ' . dol_print_date($object->timespent_date));
}
- $arrayoftasks[$object->timespent_id]['note'] .= ' - '.$langs->trans("Duration").': '.convertSecondToTime($object->timespent_duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
+ $arrayoftasks[$object->timespent_id]['note'] = dol_concatdesc($arrayoftasks[$object->timespent_id]['note'], $langs->trans("Duration") . ': ' . convertSecondToTime($object->timespent_duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY));
}
$arrayoftasks[$object->timespent_id]['user'] = $object->timespent_fk_user;
$arrayoftasks[$object->timespent_id]['fk_product'] = $object->timespent_fk_product;
@@ -619,13 +615,13 @@ if ($action == 'confirm_generateinvoice') {
// Add lines
$prodDurationHours = $prodDurationHoursBase;
- $idprodline=$idprod;
+ $idprodline = $idprod;
$pu_htline = $pu_ht;
$txtvaline = $txtva;
$localtax1line = $localtax1;
$localtax2line = $localtax2;
- if (!empty($value['fk_product']) && $value['fk_product']!==$idprod) {
+ if (!empty($value['fk_product']) && $value['fk_product'] !== $idprod) {
if (!array_key_exists($value['fk_product'], $product_data_cache)) {
$result = $tmpproduct->fetch($value['fk_product']);
if ($result < 0) {
@@ -646,7 +642,7 @@ if ($action == 'confirm_generateinvoice') {
$localtax1line = $dataforprice['localtax1'];
$localtax2line = $dataforprice['localtax2'];
- $product_data_cache[$value['fk_product']] = array('duration'=>$prodDurationHours,'dataforprice'=>$dataforprice);
+ $product_data_cache[$value['fk_product']] = array('duration' => $prodDurationHours, 'dataforprice' => $dataforprice);
} else {
$prodDurationHours = $product_data_cache[$value['fk_product']]['duration'];
$pu_htline = empty($product_data_cache[$value['fk_product']]['dataforprice']['pu_ht']) ? 0 : $product_data_cache[$value['fk_product']]['dataforprice']['pu_ht'];
@@ -654,10 +650,10 @@ if ($action == 'confirm_generateinvoice') {
$localtax1line = $product_data_cache[$value['fk_product']]['dataforprice']['localtax1'];
$localtax2line = $product_data_cache[$value['fk_product']]['dataforprice']['localtax2'];
}
- $idprodline=$value['fk_product'];
+ $idprodline = $value['fk_product'];
}
$lineid = $tmpinvoice->addline($value['note'], $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0));
- if ($lineid<0) {
+ if ($lineid < 0) {
$error++;
setEventMessages(null, $tmpinvoice->errors, 'errors');
}
@@ -673,11 +669,11 @@ if ($action == 'confirm_generateinvoice') {
break;
}
}
- } elseif ($generateinvoicemode == 'onelinepertask') { // One line for each different task
+ } elseif ($generateinvoicemode == 'onelinepertask') { // One line for each different task
$arrayoftasks = array();
foreach ($toselect as $key => $value) {
// Get userid, timepent
- $object->fetchTimeSpent($value); // Call method to get list of timespent for a timespent line id (We use the utiliy method found into Task object)
+ $object->fetchTimeSpent($value); // Call method to get list of timespent for a timespent line id (We use the utiliy method found into Task object)
// $object->id is now the task id
$arrayoftasks[$object->id][(int) $object->timespent_fk_product]['timespent'] += $object->timespent_duration;
$arrayoftasks[$object->id][(int) $object->timespent_fk_product]['totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm);
@@ -687,19 +683,19 @@ if ($action == 'confirm_generateinvoice') {
$ftask = new Task($db);
$ftask->fetch($task_id);
- foreach ($data as $fk_product=>$timespent_data) {
+ foreach ($data as $fk_product => $timespent_data) {
$qtyhour = $timespent_data['timespent'] / 3600;
$qtyhourtext = convertSecondToTime($timespent_data['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
// Add lines
$prodDurationHours = $prodDurationHoursBase;
- $idprodline=$idprod;
+ $idprodline = $idprod;
$pu_htline = $pu_ht;
$txtvaline = $txtva;
$localtax1line = $localtax1;
$localtax2line = $localtax2;
- if (!empty($fk_product) && $fk_product!==$idprod) {
+ if (!empty($fk_product) && $fk_product !== $idprod) {
if (!array_key_exists($fk_product, $product_data_cache)) {
$result = $tmpproduct->fetch($fk_product);
if ($result < 0) {
@@ -720,7 +716,7 @@ if ($action == 'confirm_generateinvoice') {
$localtax1line = $dataforprice['localtax1'];
$localtax2line = $dataforprice['localtax2'];
- $product_data_cache[$fk_product] = array('duration'=>$prodDurationHours,'dataforprice'=>$dataforprice);
+ $product_data_cache[$fk_product] = array('duration' => $prodDurationHours, 'dataforprice' => $dataforprice);
} else {
$prodDurationHours = $product_data_cache[$fk_product]['duration'];
$pu_htline = empty($product_data_cache[$fk_product]['dataforprice']['pu_ht']) ? 0 : $product_data_cache[$fk_product]['dataforprice']['pu_ht'];
@@ -728,7 +724,7 @@ if ($action == 'confirm_generateinvoice') {
$localtax1line = $product_data_cache[$fk_product]['dataforprice']['localtax1'];
$localtax2line = $product_data_cache[$fk_product]['dataforprice']['localtax2'];
}
- $idprodline=$fk_product;
+ $idprodline = $fk_product;
}
@@ -800,12 +796,12 @@ if ($action == 'confirm_generateinter') {
if (!($projectstatic->thirdparty->id > 0)) {
setEventMessages($langs->trans("ThirdPartyRequiredToGenerateIntervention"), null, 'errors');
} else {
- include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
- include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
- include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
+ include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
+ include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
+ include_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
- require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
+ require_once DOL_DOCUMENT_ROOT . '/fichinter/class/fichinter.class.php';
$tmpinter = new Fichinter($db);
$tmptimespent = new Task($db);
$fuser = new User($db);
@@ -817,7 +813,7 @@ if ($action == 'confirm_generateinter') {
$tmpinter->socid = $projectstatic->thirdparty->id;
$tmpinter->date = dol_mktime(GETPOST('rehour', 'int'), GETPOST('remin', 'int'), GETPOST('resec', 'int'), GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
$tmpinter->fk_project = $projectstatic->id;
- $tmpinter->description = $projectstatic->title . ( !empty($projectstatic->description) ? '-' . $projectstatic->label : '' );
+ $tmpinter->description = $projectstatic->title . (!empty($projectstatic->description) ? '-' . $projectstatic->label : '');
if ($interToUse) {
$tmpinter->fetch($interToUse);
@@ -850,7 +846,7 @@ if ($action == 'confirm_generateinter') {
$qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
// Add lines
- $lineid = $tmpinter->addline($user, $tmpinter->id, $ftask->label . ( !empty($value['note']) ? ' - ' . $value['note'] : '' ), $value['date'], $value['timespent']);
+ $lineid = $tmpinter->addline($user, $tmpinter->id, $ftask->label . (!empty($value['note']) ? ' - ' . $value['note'] : ''), $value['date'], $value['timespent']);
}
}
@@ -883,7 +879,7 @@ $arrayofselected = is_array($toselect) ? $toselect : array();
$title = $object->ref . ' - ' . $langs->trans("TimeSpent");
if (!empty($withproject)) {
- $title .= ' | ' . $langs->trans("Project") . (!empty($projectstatic->ref) ? ': '.$projectstatic->ref : '') ;
+ $title .= ' | ' . $langs->trans("Project") . (!empty($projectstatic->ref) ? ': ' . $projectstatic->ref : '');
}
$help_url = '';
@@ -932,13 +928,13 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$param = ((!empty($mode) && $mode == 'mine') ? '&mode=mine' : '');
if ($search_user) {
- $param .= '&search_user='.((int) $search_user);
+ $param .= '&search_user=' . ((int) $search_user);
}
if ($search_month) {
- $param .= '&search_month='.((int) $search_month);
+ $param .= '&search_month=' . ((int) $search_month);
}
if ($search_year) {
- $param .= '&search_year='.((int) $search_year);
+ $param .= '&search_year=' . ((int) $search_year);
}
// Project card
@@ -950,14 +946,14 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$morehtmlref .= $projectstatic->title;
// Thirdparty
if (!empty($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
- $morehtmlref .= '
'.$projectstatic->thirdparty->getNomUrl(1, 'project');
+ $morehtmlref .= '
' . $projectstatic->thirdparty->getNomUrl(1, 'project');
}
$morehtmlref .= '
';
// Define a complementary filter for search of next/prev ref.
if (empty($user->rights->projet->all->lire)) {
$objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
- $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
+ $projectstatic->next_prev_filter = "rowid IN (" . $db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0') . ")";
}
dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
@@ -975,25 +971,25 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print '';
print '
';
if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
- print ' usage_opportunity ? ' checked="checked"' : '')).'"> ';
+ print ' usage_opportunity ? ' checked="checked"' : '')) . '"> ';
$htmltext = $langs->trans("ProjectFollowOpportunity");
print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
print ' ';
}
if (empty($conf->global->PROJECT_HIDE_TASKS)) {
- print ' usage_task ? ' checked="checked"' : '')).'"> ';
+ print ' usage_task ? ' checked="checked"' : '')) . '"> ';
$htmltext = $langs->trans("ProjectFollowTasks");
print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
print ' ';
}
if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
- print ' usage_bill_time ? ' checked="checked"' : '')).'"> ';
+ print ' usage_bill_time ? ' checked="checked"' : '')) . '"> ';
$htmltext = $langs->trans("ProjectBillTimeDescription");
print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
print ' ';
}
if (isModEnabled('eventorganization')) {
- print ' usage_organize_event ? ' checked="checked"' : '')).'"> ';
+ print ' usage_organize_event ? ' checked="checked"' : '')) . '"> ';
$htmltext = $langs->trans("EventOrganizationDescriptionLong");
print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext);
}
@@ -1001,7 +997,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
}
// Visibility
- print ' '.$langs->trans("Visibility").' ';
+ print ' ' . $langs->trans("Visibility") . ' ';
if ($projectstatic->public) {
print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
print $langs->trans('SharedProject');
@@ -1012,14 +1008,14 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print ' ';
// Budget
- print '
'.$langs->trans("Budget").' ';
+ print ' ' . $langs->trans("Budget") . ' ';
if (!is_null($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount, '')) {
- print ''.price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency).' ';
+ print '' . price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency) . ' ';
}
print ' ';
// Date start - end project
- print '
'.$langs->trans("Dates").' ';
+ print ' ' . $langs->trans("Dates") . ' ';
$start = dol_print_date($projectstatic->date_start, 'day');
print ($start ? $start : '?');
$end = dol_print_date($projectstatic->date_end, 'day');
@@ -1052,7 +1048,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
// Categories
if (isModEnabled('categorie')) {
- print ' '.$langs->trans("Categories").' ';
+ print ' ' . $langs->trans("Categories") . ' ';
print $form->showCategories($projectstatic->id, 'project', 1);
print " ";
}
@@ -1081,12 +1077,12 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if (!empty($projectidforalltimes)) {
// We are on tab 'Time Spent' of project
- $backtourl = $_SERVER['PHP_SELF'].'?projectid='.$projectstatic->id.($withproject ? '&withproject=1' : '');
- $linktocreatetimeUrl = $_SERVER['PHP_SELF'].'?'.($withproject ? 'withproject=1' : '').'&projectid='.$projectstatic->id.'&action=createtime&token='.newToken().$param.'&backtopage='.urlencode($backtourl);
+ $backtourl = $_SERVER['PHP_SELF'] . '?projectid=' . $projectstatic->id . ($withproject ? '&withproject=1' : '');
+ $linktocreatetimeUrl = $_SERVER['PHP_SELF'] . '?' . ($withproject ? 'withproject=1' : '') . '&projectid=' . $projectstatic->id . '&action=createtime&token=' . newToken() . $param . '&backtopage=' . urlencode($backtourl);
} else {
// We are on tab 'Time Spent' of task
- $backtourl = $_SERVER['PHP_SELF'].'?id='.$object->id.($withproject ? '&withproject=1' : '');
- $linktocreatetimeUrl = $_SERVER['PHP_SELF'].'?'.($withproject ? 'withproject=1' : '').($object->id > 0 ? '&id='.$object->id : '&projectid='.$projectstatic->id).'&action=createtime&token='.newToken().$param.'&backtopage='.urlencode($backtourl);
+ $backtourl = $_SERVER['PHP_SELF'] . '?id=' . $object->id . ($withproject ? '&withproject=1' : '');
+ $linktocreatetimeUrl = $_SERVER['PHP_SELF'] . '?' . ($withproject ? 'withproject=1' : '') . ($object->id > 0 ? '&id=' . $object->id : '&projectid=' . $projectstatic->id) . '&action=createtime&token=' . newToken() . $param . '&backtopage=' . urlencode($backtourl);
}
} else {
$linktocreatetimeBtnStatus = -2;
@@ -1097,7 +1093,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$linktocreatetimeHelpText = $langs->trans("NotEnoughPermissions");
}
- $paramsbutton = array('morecss'=>'reposition');
+ $paramsbutton = array('morecss' => 'reposition');
$linktocreatetime = dolGetButtonTitle($langs->trans('AddTimeSpent'), $linktocreatetimeHelpText, 'fa fa-plus-circle', $linktocreatetimeUrl, '', $linktocreatetimeBtnStatus, $paramsbutton);
}
@@ -1108,11 +1104,11 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
// If we are on a given project.
if ($projectstatic->usage_bill_time) {
$arrayofmassactions = array(
- 'generateinvoice'=>$langs->trans("GenerateBill"),
+ 'generateinvoice' => $langs->trans("GenerateBill"),
//'builddoc'=>$langs->trans("PDFMerge"),
);
}
- if ( isModEnabled('ficheinter') && $user->hasRight('ficheinter', 'creer')) {
+ if (isModEnabled('ficheinter') && $user->hasRight('ficheinter', 'creer')) {
$langs->load("interventions");
$arrayofmassactions['generateinter'] = $langs->trans("GenerateInter");
}
@@ -1131,19 +1127,19 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print dol_get_fiche_head($head, 'task_time', $langs->trans("Task"), -1, 'projecttask', 0, '', 'reposition');
if ($action == 'deleteline') {
- $urlafterconfirm = $_SERVER["PHP_SELF"]."?".($object->id > 0 ? "id=".$object->id : 'projectid='.$projectstatic->id).'&lineid='.GETPOST("lineid", 'int').($withproject ? '&withproject=1' : '');
+ $urlafterconfirm = $_SERVER["PHP_SELF"] . "?" . ($object->id > 0 ? "id=" . $object->id : 'projectid=' . $projectstatic->id) . '&lineid=' . GETPOST("lineid", 'int') . ($withproject ? '&withproject=1' : '');
print $form->formconfirm($urlafterconfirm, $langs->trans("DeleteATimeSpent"), $langs->trans("ConfirmDeleteATimeSpent"), "confirm_deleteline", '', '', 1);
}
$param = ($withproject ? '&withproject=1' : '');
- $param .= ($param ? '&' : '').'id='.$object->id; // ID of task
- $linkback = $withproject ? '
'.$langs->trans("BackToList").' ' : '';
+ $param .= ($param ? '&' : '') . 'id=' . $object->id; // ID of task
+ $linkback = $withproject ? '
' . $langs->trans("BackToList") . ' ' : '';
if (!GETPOST('withproject') || empty($projectstatic->id)) {
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
- $object->next_prev_filter = " fk_projet IN (".$db->sanitize($projectsListId).")";
+ $object->next_prev_filter = "fk_projet IN (" . $db->sanitize($projectsListId) . ")";
} else {
- $object->next_prev_filter = " fk_projet = ".((int) $projectstatic->id);
+ $object->next_prev_filter = "fk_projet = " . ((int) $projectstatic->id);
}
$morehtmlref = '';
@@ -1151,12 +1147,12 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
// Project
if (empty($withproject)) {
$morehtmlref .= '
';
- $morehtmlref .= $langs->trans("Project").': ';
+ $morehtmlref .= $langs->trans("Project") . ': ';
$morehtmlref .= $projectstatic->getNomUrl(1);
$morehtmlref .= '
';
// Third party
- $morehtmlref .= $langs->trans("ThirdParty").': ';
+ $morehtmlref .= $langs->trans("ThirdParty") . ': ';
if (!empty($projectstatic->thirdparty) && is_object($projectstatic->thirdparty)) {
$morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
}
@@ -1172,7 +1168,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print '
';
// Task parent
- print ''.$langs->trans("ChildOfTask").' ';
+ print ' ' . $langs->trans("ChildOfTask") . ' ';
if ($object->fk_task_parent > 0) {
$tasktmp = new Task($db);
$tasktmp->fetch($object->fk_task_parent);
@@ -1181,7 +1177,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print ' ';
// Date start - Date end task
- print ''.$langs->trans("DateStart").' - '.$langs->trans("Deadline").' ';
+ print ' ' . $langs->trans("DateStart") . ' - ' . $langs->trans("Deadline") . ' ';
$start = dol_print_date($object->date_start, 'dayhour');
print ($start ? $start : '?');
$end = dol_print_date($object->date_end, 'dayhour');
@@ -1193,7 +1189,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print ' ';
// Planned workload
- print ''.$langs->trans("PlannedWorkload").' ';
+ print ' ' . $langs->trans("PlannedWorkload") . ' ';
if ($object->planned_workload) {
print convertSecondToTime($object->planned_workload, 'allhourmin');
}
@@ -1208,21 +1204,21 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print '';
// Progress declared
- print ''.$langs->trans("ProgressDeclared").' ';
- print $object->progress != '' ? $object->progress.' %' : '';
+ print ' ' . $langs->trans("ProgressDeclared") . ' ';
+ print $object->progress != '' ? $object->progress . ' %' : '';
print ' ';
// Progress calculated
- print ''.$langs->trans("ProgressCalculated").' ';
+ print ' ' . $langs->trans("ProgressCalculated") . ' ';
if ($object->planned_workload) {
$tmparray = $object->getSummaryOfTimeSpent();
if ($tmparray['total_duration'] > 0) {
- print round($tmparray['total_duration'] / $object->planned_workload * 100, 2).' %';
+ print round($tmparray['total_duration'] / $object->planned_workload * 100, 2) . ' %';
} else {
print '0 %';
}
} else {
- print ''.$langs->trans("WorkloadNotDefined").' ';
+ print '' . $langs->trans("WorkloadNotDefined") . ' ';
}
print ' ';
@@ -1236,6 +1232,11 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print '
';
print dol_get_fiche_end();
+ } else {
+ if ($action == 'deleteline') {
+ $urlafterconfirm = $_SERVER["PHP_SELF"] . "?" . ($object->id > 0 ? "id=" . $object->id : 'projectid=' . $projectstatic->id) . '&lineid=' . GETPOST("lineid", 'int') . ($withproject ? '&withproject=1' : '');
+ print $form->formconfirm($urlafterconfirm, $langs->trans("DeleteATimeSpent"), $langs->trans("ConfirmDeleteATimeSpent"), "confirm_deleteline", '', '', 1);
+ }
}
@@ -1247,7 +1248,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if ($action == 'deleteline' && !empty($projectidforalltimes)) {
// We must use projectidprojectid if on list of timespent of project and id=taskid if on list of timespent of a task
- $urlafterconfirm = $_SERVER["PHP_SELF"]."?".($projectstatic->id > 0 ? 'projectid='.$projectstatic->id : ($object->id > 0 ? "id=".$object->id : '')).'&lineid='.GETPOST('lineid', 'int').($withproject ? '&withproject=1' : '')."&contextpage=".urlencode($contextpage);
+ $urlafterconfirm = $_SERVER["PHP_SELF"] . "?" . ($projectstatic->id > 0 ? 'projectid=' . $projectstatic->id : ($object->id > 0 ? "id=" . $object->id : '')) . '&lineid=' . GETPOST('lineid', 'int') . ($withproject ? '&withproject=1' : '') . "&contextpage=" . urlencode($contextpage);
$formconfirm = $form->formconfirm($urlafterconfirm, $langs->trans("DeleteATimeSpent"), $langs->trans("ConfirmDeleteATimeSpent"), "confirm_deleteline", '', '', 1);
}
@@ -1276,91 +1277,91 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$arrayfields['t.element_ref'] = array('label'=>$langs->trans("RefTask"), 'checked'=>1);
$arrayfields['t.element_label'] = array('label'=>$langs->trans("LabelTask"), 'checked'=>1);
}
- $arrayfields['author'] = array('label'=>$langs->trans("By"), 'checked'=>1);
- $arrayfields['t.note'] = array('label'=>$langs->trans("Note"), 'checked'=>1);
+ $arrayfields['author'] = array('label' => $langs->trans("By"), 'checked' => 1);
+ $arrayfields['t.note'] = array('label' => $langs->trans("Note"), 'checked' => 1);
if (isModEnabled('service') && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
$arrayfields['t.fk_product'] = array('label' => $langs->trans("Product"), 'checked' => 1);
}
$arrayfields['t.element_duration'] = array('label'=>$langs->trans("Duration"), 'checked'=>1);
- $arrayfields['value'] = array('label'=>$langs->trans("Value"), 'checked'=>1, 'enabled'=>(empty($conf->salaries->enabled) ? 0 : 1));
- $arrayfields['valuebilled'] = array('label'=>$langs->trans("Billed"), 'checked'=>1, 'enabled'=>(((!empty($conf->global->PROJECT_HIDE_TASKS) || empty($conf->global->PROJECT_BILL_TIME_SPENT)) ? 0 : 1) && $projectstatic->usage_bill_time));
+ $arrayfields['value'] = array('label'=>$langs->trans("Value"), 'checked'=>1, 'enabled'=>isModEnabled("salaries"));
+ $arrayfields['valuebilled'] = array('label'=>$langs->trans("Billed"), 'checked'=>1, 'enabled'=>(((getDolGlobalInt('PROJECT_HIDE_TASKS') || !getDolGlobalInt('PROJECT_BILL_TIME_SPENT')) ? 0 : 1) && $projectstatic->usage_bill_time));
// Extra fields
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
+ include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php';
$arrayfields = dol_sort_array($arrayfields, 'position');
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
- $param .= '&contextpage='.urlencode($contextpage);
+ $param .= '&contextpage=' . urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.((int) $limit);
}
if ($search_month > 0) {
- $param .= '&search_month='.urlencode($search_month);
+ $param .= '&search_month=' . urlencode($search_month);
}
if ($search_year > 0) {
- $param .= '&search_year='.urlencode($search_year);
+ $param .= '&search_year=' . urlencode($search_year);
}
if (!empty($search_user)) { // We keep param if -1 because default value is forced to user id if not set
$param .= '&search_user='.urlencode($search_user);
}
if ($search_task_ref != '') {
- $param .= '&search_task_ref='.urlencode($search_task_ref);
+ $param .= '&search_task_ref=' . urlencode($search_task_ref);
}
if ($search_company != '') {
- $param .= '&$search_company='.urlencode($search_company);
+ $param .= '&$search_company=' . urlencode($search_company);
}
if ($search_company_alias != '') {
- $param .= '&$search_company_alias='.urlencode($search_company_alias);
+ $param .= '&$search_company_alias=' . urlencode($search_company_alias);
}
if ($search_project_ref != '') {
- $param .= '&$search_project_ref='.urlencode($search_project_ref);
+ $param .= '&$search_project_ref=' . urlencode($search_project_ref);
}
if ($search_project_label != '') {
- $param .= '&$search_project_label='.urlencode($search_project_label);
+ $param .= '&$search_project_label=' . urlencode($search_project_label);
}
if ($search_task_label != '') {
- $param .= '&search_task_label='.urlencode($search_task_label);
+ $param .= '&search_task_label=' . urlencode($search_task_label);
}
if ($search_note != '') {
- $param .= '&search_note='.urlencode($search_note);
+ $param .= '&search_note=' . urlencode($search_note);
}
if ($search_duration != '') {
- $param .= '&search_field2='.urlencode($search_duration);
+ $param .= '&search_field2=' . urlencode($search_duration);
}
if ($optioncss != '') {
- $param .= '&optioncss='.urlencode($optioncss);
+ $param .= '&optioncss=' . urlencode($optioncss);
}
if ($search_date_startday) {
- $param .= '&search_date_startday='.urlencode($search_date_startday);
+ $param .= '&search_date_startday=' . urlencode($search_date_startday);
}
if ($search_date_startmonth) {
- $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
+ $param .= '&search_date_startmonth=' . urlencode($search_date_startmonth);
}
if ($search_date_startyear) {
- $param .= '&search_date_startyear='.urlencode($search_date_startyear);
+ $param .= '&search_date_startyear=' . urlencode($search_date_startyear);
}
if ($search_date_endday) {
- $param .= '&search_date_endday='.urlencode($search_date_endday);
+ $param .= '&search_date_endday=' . urlencode($search_date_endday);
}
if ($search_date_endmonth) {
- $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
+ $param .= '&search_date_endmonth=' . urlencode($search_date_endmonth);
}
if ($search_date_endyear) {
- $param .= '&search_date_endyear='.urlencode($search_date_endyear);
+ $param .= '&search_date_endyear=' . urlencode($search_date_endyear);
}
if ($search_timespent_starthour) {
- $param .= '&search_timespent_duration_starthour='.urlencode($search_timespent_starthour);
+ $param .= '&search_timespent_duration_starthour=' . urlencode($search_timespent_starthour);
}
if ($search_timespent_startmin) {
- $param .= '&search_timespent_duration_startmin='.urlencode($search_timespent_startmin);
+ $param .= '&search_timespent_duration_startmin=' . urlencode($search_timespent_startmin);
}
if ($search_timespent_endhour) {
- $param .= '&search_timespent_duration_endhour='.urlencode($search_timespent_endhour);
+ $param .= '&search_timespent_duration_endhour=' . urlencode($search_timespent_endhour);
}
if ($search_timespent_endmin) {
- $param .= '&search_timespent_duration_endmin='.urlencode($search_timespent_endmin);
+ $param .= '&search_timespent_duration_endmin=' . urlencode($search_timespent_endmin);
}
/*
@@ -1368,24 +1369,24 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
*/
if ($id) {
- $param .= '&id='.urlencode($id);
+ $param .= '&id=' . urlencode($id);
}
if ($projectid) {
- $param .= '&projectid='.urlencode($projectid);
+ $param .= '&projectid=' . urlencode($projectid);
}
if ($withproject) {
- $param .= '&withproject='.urlencode($withproject);
+ $param .= '&withproject=' . urlencode($withproject);
}
// Add $param from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
$param .= $hookmanager->resPrint;
- print '';
+ print ' ';
if ($optioncss != '') {
- print ' ';
+ print ' ';
}
- print ' ';
+ print ' ';
print ' ';
if ($action == 'editline') {
print ' ';
@@ -1400,18 +1401,18 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
} else {
print ' ';
}
- print ' ';
- print ' ';
+ print ' ';
+ print ' ';
- print ' ';
- print ' ';
- print ' ';
- print ' ';
+ print ' ';
+ print ' ';
+ print ' ';
+ print ' ';
print ' ';
// Form to convert time spent into invoice
if ($massaction == 'generateinvoice') {
- if ($projectstatic->thirdparty->id > 0) {
+ if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
print '';
print '';
print '';
@@ -1428,12 +1429,12 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print ' ';
print '';
$tmparray = array(
- 'onelineperuser'=>'OneLinePerUser',
- 'onelinepertask'=>'OneLinePerTask',
- 'onelineperperiod'=>'OneLinePerTimeSpentLine',
+ 'onelineperuser' => 'OneLinePerUser',
+ 'onelinepertask' => 'OneLinePerTask',
+ 'onelineperperiod' => 'OneLinePerTimeSpentLine',
);
print $form->selectarray('generateinvoicemode', $tmparray, 'onelineperuser', 0, 0, 0, '', 1);
- print "\n".''."\n";
- print ' '.$langs->trans('AddDetailDateAndDuration').' ';
+ print '' . "\n";
+ print ' ' . $langs->trans('AddDetailDateAndDuration') . ' ';
print ' ';
print ' ';
@@ -1475,25 +1476,25 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print '';
print '';
/*print '';
- print '';
- print $langs->trans('ValidateInvoices');
- print ' ';
- print '';
- print $form->selectyesno('validate_invoices', 0, 1);
- print ' ';
- print ' ';*/
+ print '';
+ print $langs->trans('ValidateInvoices');
+ print ' ';
+ print '';
+ print $form->selectyesno('validate_invoices', 0, 1);
+ print ' ';
+ print '';*/
print '
';
print ' ';
print '';
- print ' ';
- print ' ';
+ print ' ';
+ print ' ';
print '
';
print ' ';
} else {
- print ''.$langs->trans("ThirdPartyRequiredToGenerateInvoice").'
';
+ print '' . $langs->trans("ThirdPartyRequiredToGenerateInvoice") . '
';
print '';
- print ' ';
+ print ' ';
print '
';
$massaction = '';
}
@@ -1501,12 +1502,12 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
// Form to convert time spent into invoice
print ' ';
- if ($projectstatic->thirdparty->id > 0) {
+ if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
print ' ';
print '';
print '';
print '';
- print img_picto('', 'intervention', 'class="pictofixedwidth"').$langs->trans('InterToUse');
+ print img_picto('', 'intervention', 'class="pictofixedwidth"') . $langs->trans('InterToUse');
print ' ';
print '';
$forminter = new FormIntervention($db);
@@ -1516,14 +1517,14 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print '
';
print '';
- print ' ';
- print ' ';
+ print ' ';
+ print ' ';
print '
';
print ' ';
} else {
- print ''.$langs->trans("ThirdPartyRequiredToGenerateIntervention").'
';
+ print '' . $langs->trans("ThirdPartyRequiredToGenerateIntervention") . '
';
print '';
- print ' ';
+ print ' ';
print '
';
$massaction = '';
}
@@ -1584,13 +1585,13 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$sql .= " AND t.fk_element =".((int) $object->id);
} elseif (!empty($projectidforalltimes)) {
// Limit on one project
- $sql .= " AND pt.fk_projet IN (".$db->sanitize($projectidforalltimes).")";
+ $sql .= " AND pt.fk_projet IN (" . $db->sanitize($projectidforalltimes) . ")";
} elseif (!empty($allprojectforuser)) {
// Limit on on user
if (empty($search_user)) {
$search_user = $user->id;
}
- if ($search_user > 0) $sql .= " AND t.fk_user = ".((int) $search_user);
+ if ($search_user > 0) $sql .= " AND t.fk_user = " . ((int) $search_user);
}
if ($search_note) {
@@ -1696,13 +1697,13 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if ($num >= 0) {
if (!empty($projectidforalltimes)) {
- print ''."\n";
+ print '' . "\n";
$title = $langs->trans("ListTaskTimeUserProject");
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'clock', 0, $linktocreatetime, '', $limit, 0, 0, 1);
} else {
- print ''."\n";
+ print '' . "\n";
$title = $langs->trans("ListTaskTimeForTask");
@@ -1723,31 +1724,31 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
/*
* Form to add a new line of time spent
*/
- if ($action == 'createtime' && $user->rights->projet->time) {
- print ''."\n";
+ if ($action == 'createtime' && $user->hasRight('projet', 'time')) {
+ print '' . "\n";
if (!empty($id)) {
- print ' ';
+ print ' ';
}
print ''; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '
';
print '';
- print ''.$langs->trans("Date").' ';
+ print '' . $langs->trans("Date") . ' ';
if (!empty($allprojectforuser)) {
- print ''.$langs->trans("Project").' ';
+ print '' . $langs->trans("Project") . ' ';
}
if (empty($id)) {
- print ''.$langs->trans("Task").' ';
+ print '' . $langs->trans("Task") . ' ';
}
- print ''.$langs->trans("By").' ';
- print ''.$langs->trans("Note").' ';
- print ''.$langs->trans("NewTimeSpent").' ';
- print ''.$langs->trans("ProgressDeclared").' ';
+ print '' . $langs->trans("By") . ' ';
+ print '' . $langs->trans("Note") . ' ';
+ print '' . $langs->trans("NewTimeSpent") . ' ';
+ print '' . $langs->trans("ProgressDeclared") . ' ';
if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
print ' ';
- if (isModEnabled("service") && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
+ if (isModEnabled("service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
print ''.$langs->trans("Product").' ';
}
}
@@ -1794,17 +1795,17 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if ($projectstatic->public) {
$contactsofproject = array();
}
- print $form->select_dolusers((GETPOST('userid', 'int') ? GETPOST('userid', 'int') : $userid), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToProject"), 'maxwidth200');
+ print $form->select_dolusers((GETPOST('userid', 'int') ? GETPOST('userid', 'int') : $userid), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToProject"), 'minwidth150imp maxwidth200');
} else {
if ($nboftasks) {
- print img_error($langs->trans('FirstAddRessourceToAllocateTime')).' '.$langs->trans('FirstAddRessourceToAllocateTime');
+ print img_error($langs->trans('FirstAddRessourceToAllocateTime')) . ' ' . $langs->trans('FirstAddRessourceToAllocateTime');
}
}
print '';
// Note
print '';
- print ''.(GETPOST('timespent_note') ? GETPOST('timespent_note') : '').' ';
+ print '' . (GETPOST('timespent_note') ? GETPOST('timespent_note') : '') . ' ';
print ' ';
// Duration - Time spent
@@ -1818,7 +1819,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
// Progress declared
print '';
- print $formother->select_percent(GETPOST('progress') ?GETPOST('progress') : $object->progress, 'progress', 0, 5, 0, 100, 1);
+ print $formother->select_percent(GETPOST('progress') ? GETPOST('progress') : $object->progress, 'progress', 0, 5, 0, 100, 1);
print ' ';
// Invoiced
@@ -1826,7 +1827,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print '';
print ' ';
- if (isModEnabled("service") && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
+ if (isModEnabled("service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
print '';
print img_picto('', 'product');
print $form->select_produits('', 'fk_product', '1', 0, $projectstatic->thirdparty->price_level, 1, 2, '', 1, array(), $projectstatic->thirdparty->id, 'None', 0, 'maxwidth150', 0, '', null, 1);
@@ -1872,7 +1873,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$selectedfields .= (is_array($arrayofmassactions) && count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
print '';
- print '
'."\n";
+ print '' . "\n";
// Fields title search
// --------------------------------------------------------------------
@@ -1897,20 +1898,20 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
}
// Thirdparty
if (!empty($arrayfields['p.fk_soc']['checked'])) {
- print ' ';
+ print ' ';
}
// Thirdparty alias
if (!empty($arrayfields['s.name_alias']['checked'])) {
- print ' ';
+ print ' ';
}
if (!empty($allprojectforuser)) {
if (!empty($arrayfields['p.project_ref']['checked'])) {
- print ' ';
+ print ' ';
}
if (!empty($arrayfields['p.project_label']['checked'])) {
- print ' ';
+ print ' ';
}
}
// Task
@@ -1928,7 +1929,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
}
// Note
if (!empty($arrayfields['t.note']['checked'])) {
- print ' ';
+ print ' ';
}
// Duration
if (!empty($arrayfields['t.element_duration']['checked'])) {
@@ -1939,7 +1940,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if ($search_timespent_starthour || $search_timespent_startmin) {
$durationtouse_start = ($search_timespent_starthour * 3600 + $search_timespent_startmin * 60);
}
- print ''.$langs->trans('from').' ';
+ print '
' . $langs->trans('from') . ' ';
print $form->select_duration('search_timespent_duration_start', $durationtouse_start, 0, 'text', 0, 1);
print '
';
@@ -1947,7 +1948,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if ($search_timespent_endhour || $search_timespent_endmin) {
$durationtouse_end = ($search_timespent_endhour * 3600 + $search_timespent_endmin * 60);
}
- print '
'.$langs->trans('at').' ';
+ print '
' . $langs->trans('at') . ' ';
print $form->select_duration('search_timespent_duration_end', $durationtouse_end, 0, 'text', 0, 1);
print '
';
@@ -1963,15 +1964,15 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
}
// Value billed
if (!empty($arrayfields['valuebilled']['checked'])) {
- print '
'.$form->selectyesno('search_valuebilled', $search_valuebilled, 1, false, 1).' ';
+ print '
' . $form->selectyesno('search_valuebilled', $search_valuebilled, 1, false, 1) . ' ';
}
/*
- // Extra fields
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
- */
+ // Extra fields
+ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
+ */
// Fields from hook
- $parameters = array('arrayfields'=>$arrayfields);
+ $parameters = array('arrayfields' => $arrayfields);
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Action column
@@ -1981,7 +1982,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print $searchpicto;
print '';
}
- print ''."\n";
+ print '' . "\n";
$totalarray = array();
$totalarray['nbfield'] = 0;
@@ -2051,11 +2052,11 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$totalarray['nbfield']++;
}
/*
- // Extra fields
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
- */
+ // Extra fields
+ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
+ */
// Hook fields
- $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
+ $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
@@ -2091,34 +2092,34 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '
';
if (($action == 'editline' || $action == 'splitline') && GETPOST('lineid', 'int') == $task_time->rowid) {
- print ' ';
+ print ' ';
print ' ';
- print ' ';
+ print ' ';
print ' ';
} elseif ($user->hasRight('projet', 'time') || $user->hasRight('projet', 'all', 'creer')) { // Read project and enter time consumed on assigned tasks
if (in_array($task_time->fk_user, $childids) || $user->hasRight('projet', 'all', 'creer')) {
if (getDolGlobalString('MAIN_FEATURES_LEVEL') >= 2) {
print ' ';
- print 'rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">';
+ print ' rowid . $param . ((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '') . '">';
print img_split('', 'class="pictofixedwidth"');
print ' ';
}
- print 'fk_element.'&action=editline&token='.newToken().'&lineid='.$task_time->rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">';
+ print ' fk_element : '').'&action=editline&token='.newToken().'&lineid='.$task_time->rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">';
print img_edit('default', 0, 'class="pictofixedwidth paddingleft"');
print ' ';
- print 'fk_element.'&action=deleteline&token='.newToken().'&lineid='.$task_time->rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">';
+ print ' fk_element : '').'&action=deleteline&token='.newToken().'&lineid='.$task_time->rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">';
print img_delete('default', 'class="pictodelete paddingleft"');
print ' ';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($task_time->rowid, $arrayofselected)) {
$selected = 1;
}
print ' ';
- print ' ';
+ print ' ';
}
}
}
@@ -2197,7 +2198,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
}
print $tmpproject->getNomUrl(1);
print ' ';
- if (! $i) {
+ if (!$i) {
$totalarray['nbfield']++;
}
}
@@ -2212,7 +2213,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
}
print $tmpproject->title;
print '';
- if (! $i) {
+ if (!$i) {
$totalarray['nbfield']++;
}
}
@@ -2236,7 +2237,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
}
}
} elseif ($action !== 'createtime') {
- print '
';
+ print '
';
}
// Task label
@@ -2266,7 +2267,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print img_object('', 'user', 'class="hideonsmartphone"');
print $form->select_dolusers($task_time->fk_user, 'userid_line', 0, '', 0, '', $contactsoftask, '0', 0, 0, '', 0, '', 'maxwidth200');
} else {
- print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime');
+ print img_error($langs->trans('FirstAddRessourceToAllocateTime')) . $langs->trans('FirstAddRessourceToAllocateTime');
}
} else {
$userstatic->id = $task_time->fk_user;
@@ -2284,18 +2285,20 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
// Note
if (!empty($arrayfields['t.note']['checked'])) {
- print '
';
if ($action == 'editline' && GETPOST('lineid', 'int') == $task_time->rowid) {
- print ''.dol_escape_htmltag($task_time->note, 0, 1).' ';
+ print ' ';
+ print '' . dol_escape_htmltag($task_time->note, 0, 1) . ' ';
+ print ' ';
} else {
- print dol_nl2br($task_time->note);
+ print '
';
+ print dolGetFirstLineOfText($task_time->note);
+ print ' ';
}
- print '';
if (!$i) {
$totalarray['nbfield']++;
}
} elseif ($action == 'editline' && GETPOST('lineid', 'int') == $task_time->rowid) {
- print '
';
+ print '
';
}
// Time spent
@@ -2355,7 +2358,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$value = price2num($task_time->thm * $task_time->element_duration / 3600, 'MT', 1);
print '
';
- print 'thm).'">';
+ print 'thm) . '">';
print price($value, 1, $langs, 1, -1, -1, $conf->currency);
print ' ';
print ' ';
@@ -2406,7 +2409,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print $langs->trans("No");
}
} else {
- print '
'.$langs->trans("NA").' ';
+ print '
' . $langs->trans("NA") . ' ';
}
}
print '';
@@ -2416,12 +2419,12 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
}
/*
- // Extra fields
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
- */
+ // Extra fields
+ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
+ */
// Fields from hook
- $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$task_time, 'i'=>$i, 'totalarray'=>&$totalarray);
+ $parameters = array('arrayfields' => $arrayfields, 'obj' => $task_time, 'i' => $i, 'totalarray' => &$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
@@ -2431,32 +2434,32 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if (($action == 'editline' || $action == 'splitline') && GETPOST('lineid', 'int') == $task_time->rowid) {
print '
';
print '
';
- print ' ';
+ print '
';
print '
';
} elseif ($user->hasRight('projet', 'time') || $user->hasRight('projet', 'all', 'creer')) { // Read project and enter time consumed on assigned tasks
if (in_array($task_time->fk_user, $childids) || $user->hasRight('projet', 'all', 'creer')) {
if (getDolGlobalString('MAIN_FEATURES_LEVEL') >= 2) {
print ' ';
- print '
rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">';
+ print ' rowid . $param . ((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '') . '">';
print img_split('', 'class="pictofixedwidth"');
print ' ';
}
- print '
fk_element.'&action=editline&token='.newToken().'&lineid='.$task_time->rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">';
+ print ' fk_element : '').'&action=editline&token='.newToken().'&lineid='.$task_time->rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">';
print img_edit('default', 0, 'class="pictofixedwidth paddingleft"');
print ' ';
- print '
fk_element.'&action=deleteline&token='.newToken().'&lineid='.$task_time->rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">';
+ print ' fk_element : '').'&action=deleteline&token='.newToken().'&lineid='.$task_time->rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">';
print img_delete('default', 'class="pictodelete paddingleft"');
print ' ';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($task_time->rowid, $arrayofselected)) {
$selected = 1;
}
print ' ';
- print '
';
+ print '
';
}
}
}
@@ -2504,7 +2507,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
// Project ref
if (!empty($allprojectforuser)) {
- if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task
+ if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task
print '
';
print ' ';
}
@@ -2546,7 +2549,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print img_object('', 'user', 'class="hideonsmartphone"');
print $form->select_dolusers($task_time->fk_user, 'userid_line', 0, '', 0, '', $contactsoftask);
} else {
- print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime');
+ print img_error($langs->trans('FirstAddRessourceToAllocateTime')) . $langs->trans('FirstAddRessourceToAllocateTime');
}
} else {
$userstatic->id = $task_time->fk_user;
@@ -2563,13 +2566,13 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if (!empty($arrayfields['t.note']['checked'])) {
print '
';
if ($action == 'splitline' && GETPOST('lineid', 'int') == $task_time->rowid) {
- print ''.dol_escape_htmltag($task_time->note, 0, 1).' ';
+ print '' . dol_escape_htmltag($task_time->note, 0, 1) . ' ';
} else {
print dol_nl2br($task_time->note);
}
print ' ';
} elseif ($action == 'splitline' && GETPOST('lineid', 'int') == $task_time->rowid) {
- print '
';
+ print '
';
}
// Time spent
@@ -2616,7 +2619,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
*/
// Fields from hook
- $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$task_time, 'mode' => 'split1');
+ $parameters = array('arrayfields' => $arrayfields, 'obj' => $task_time, 'mode' => 'split1');
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
@@ -2660,7 +2663,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
// Project ref
if (!empty($allprojectforuser)) {
- if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task
+ if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task
print '
';
print ' ';
}
@@ -2702,7 +2705,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print img_object('', 'user', 'class="hideonsmartphone"');
print $form->select_dolusers($task_time->fk_user, 'userid_line_2', 0, '', 0, '', $contactsoftask);
} else {
- print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime');
+ print img_error($langs->trans('FirstAddRessourceToAllocateTime')) . $langs->trans('FirstAddRessourceToAllocateTime');
}
} else {
$userstatic->id = $task_time->fk_user;
@@ -2719,13 +2722,13 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if (!empty($arrayfields['t.note']['checked'])) {
print '
';
if ($action == 'splitline' && GETPOST('lineid', 'int') == $task_time->rowid) {
- print ''.dol_escape_htmltag($task_time->note, 0, 1).' ';
+ print '' . dol_escape_htmltag($task_time->note, 0, 1) . ' ';
} else {
print dol_nl2br($task_time->note);
}
print ' ';
} elseif ($action == 'splitline' && GETPOST('lineid', 'int') == $task_time->rowid) {
- print '
';
+ print '
';
}
// Time spent
@@ -2774,7 +2777,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
*/
// Fields from hook
- $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$task_time, 'mode' => 'split2');
+ $parameters = array('arrayfields' => $arrayfields, 'obj' => $task_time, 'mode' => 'split2');
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
@@ -2797,14 +2800,14 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$i++;
if ($i == 1) {
if ($num < $limit && empty($offset)) {
- print '
'.$langs->trans("Total").' ';
+ print '
' . $langs->trans("Total") . ' ';
} else {
print '
'.$form->textwithpicto($langs->trans("Total"), $langs->trans("Totalforthispage")).' ';
}
} elseif ($totalarray['totaldurationfield'] == $i) {
- print '
'.convertSecondToTime($totalarray['totalduration'], 'allhourmin').' ';
+ print '
' . convertSecondToTime($totalarray['totalduration'], 'allhourmin') . ' ';
} elseif ($totalarray['totalvaluefield'] == $i) {
- print '
'.price($totalarray['totalvalue']).' ';
+ print '
' . price($totalarray['totalvalue']) . ' ';
//} elseif ($totalarray['totalvaluebilledfield'] == $i) { print '
'.price($totalarray['totalvaluebilled']).' ';
} else {
print '
';
@@ -2820,12 +2823,12 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$totalnboffields++;
}
}
- print '
';
- print ''.$langs->trans("None").' ';
+ print ' ';
+ print '' . $langs->trans("None") . ' ';
print ' ';
}
- $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
+ $parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
diff --git a/htdocs/public/bookcal/booking.php b/htdocs/public/bookcal/booking.php
index d478046d143..fa9c3597667 100644
--- a/htdocs/public/bookcal/booking.php
+++ b/htdocs/public/bookcal/booking.php
@@ -19,7 +19,7 @@
*/
/**
- * \file htdocs/public/onlinesign/newonlinesign.php
+ * \file htdocs/public/bookcal/booking.php
* \ingroup core
* \brief File to offer a way to make an online signature for a particular Dolibarr entity
* Example of URL: https://localhost/public/bookcal/booking.php?ref=PR...
@@ -44,7 +44,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/bookcal/class/calendar.class.php';
require_once DOL_DOCUMENT_ROOT.'/bookcal/class/availabilities.class.php';
-require_once DOL_DOCUMENT_ROOT.'/bookcal/class/booking.class.php';
+require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
+require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
$langs->loadLangs(array("main", "other", "dict", "agenda", "errors", "companies"));
@@ -170,13 +171,21 @@ function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $
if ($action == 'add') {
$error = 0;
- $urlback = '';
+ $idcontact = 0;
+ $calendar = new Calendar($db);
+ $contact = new Contact($db);
+ $actioncomm = new ActionComm($db);
+
+ $res = $calendar->fetch($fk_calendar);
+ if ($res < 0) {
+ $error++;
+ $errmsg .= $calendar->error." ".join(',', $calendar->errors);
+ }
+
if (!is_object($user)) {
$user = new User($db);
}
- $booking = new Booking($db);
-
$db->begin();
if (!GETPOST("lastname")) {
$error++;
@@ -192,21 +201,71 @@ if ($action == 'add') {
}
if (!$error) {
- $booking->ref = $booking->getNextNumRef();
- $booking->lastname = GETPOST("lastname");
- $booking->firstname = GETPOST("firstname");
- $booking->email = GETPOST("email");
- $booking->description = GETPOST("description");
- $booking->duration = GETPOST("duration");
- $booking->start = GETPOST("datetimebooking", 'int');
- $booking->fk_bookcal_availability = GETPOST("id", 'int');
+ $sql = "SELECT s.rowid";
+ $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as s";
+ $sql .= " WHERE s.lastname = '".GETPOST("lastname")."'";
+ $sql .= " AND s.firstname = '".GETPOST("firstname")."'";
+ $sql .= " AND s.email = '".GETPOST("email")."'";
+ $resql = $db->query($sql);
- $result = $booking->create($user);
- if ($result <= 0) {
+ if ($resql) {
+ $num = $db->num_rows($resql);
+ if ($num > 0) {
+ $obj = $db->fetch_object($resql);
+ $idcontact = $obj->rowid;
+ $contact->fetch($idcontact);
+ } else {
+ $contact->lastname = GETPOST("lastname");
+ $contact->firstname = GETPOST("firstname");
+ $contact->email = GETPOST("email");
+ $result = $contact->create($user);
+ if ($result < 0) {
+ $error++;
+ $errmsg .= $contact->error." ".join(',', $contact->errors);
+ }
+ }
+ } else {
$error++;
- $errmsg = ($booking->error ? $booking->error.'
' : '').join('
', $booking->errors);
+ $errmsg .= $db->lasterror();
}
}
+
+ if (!$error) {
+ $dateend = dol_time_plus_duree(GETPOST("datetimebooking", 'int'), GETPOST("duration"), 'i');
+
+ $actioncomm->label = "test";
+ $actioncomm->type = 'AC_RDV';
+ $actioncomm->type_id = 5;
+ $actioncomm->datep = GETPOST("datetimebooking", 'int');
+ $actioncomm->datef = $dateend;
+ $actioncomm->note_private = GETPOST("description");
+ $actioncomm->percentage = -1;
+ $actioncomm->fk_bookcal_availability = GETPOST("id", 'int');
+ $actioncomm->userownerid = $calendar->visibility;
+ $actioncomm->contact_id = $contact->id;
+ $actioncomm->socpeopleassigned = $contact->id;
+ $result = $actioncomm->create($user);
+ if ($result < 0) {
+ $error++;
+ $errmsg .= $actioncomm->error." ".join(',', $actioncomm->errors);
+ }
+
+ if (!$error) {
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources";
+ $sql .= "(fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency";
+ $sql .= ") VALUES (";
+ $sql .= (int) $actioncomm->id;
+ $sql .= ", 'socpeople'";
+ $sql .= ", ". (int) $contact->id;
+ $sql .= ", 0, 0, 0)";
+ $resql = $db->query($sql);
+ if (!$resql) {
+ $error++;
+ $errmsg .= $db->lasterror();
+ }
+ }
+ }
+
if (!$error) {
$db->commit();
$action = 'afteradd';
@@ -365,7 +424,7 @@ if ($action == 'afteradd') {
$style .= ' cal_other_month_right';
}
echo '
';
- show_day_events($max_day_in_prev_month + $tmpday, $prev_month, $prev_year);
+ show_bookcal_day_events($max_day_in_prev_month + $tmpday, $prev_month, $prev_year);
echo " \n";
} elseif ($tmpday <= $max_day_in_month) {
/* Show days of the current month */
@@ -390,7 +449,7 @@ if ($action == 'afteradd') {
$isdatechosen = true;
}
echo '
';
- show_day_events($tmpday, $month, $year, $today);
+ show_bookcal_day_events($tmpday, $month, $year, $today);
echo " \n";
} else {
/* Show days after the current month (next month) */
@@ -399,7 +458,7 @@ if ($action == 'afteradd') {
$style .= ' cal_other_month_right';
}
echo '
';
- show_day_events($tmpday - $max_day_in_month, $next_month, $next_year);
+ show_bookcal_day_events($tmpday - $max_day_in_month, $next_month, $next_year);
echo " \n";
}
$tmpday++;
@@ -501,7 +560,7 @@ llxFooter('', 'public');
* @param int $today Today's day
* @return void
*/
-function show_day_events($day, $month, $year, $today = 0)
+function show_bookcal_day_events($day, $month, $year, $today = 0)
{
global $conf;
if ($conf->use_javascript_ajax) { // Enable the "Show more button..."
@@ -510,7 +569,7 @@ function show_day_events($day, $month, $year, $today = 0)
$dateint = sprintf("%04d", $year).'_'.sprintf("%02d", $month).'_'.sprintf("%02d", $day);
$eventdatetime = dol_mktime(-1, -1, -1, $month, $day, $year);
- //print 'show_day_events day='.$day.' month='.$month.' year='.$year.' dateint='.$dateint;
+ //print 'show_bookcal_day_events day='.$day.' month='.$month.' year='.$year.' dateint='.$dateint;
print "\n";
diff --git a/htdocs/public/bookcal/index.php b/htdocs/public/bookcal/index.php
index 530f37fc91e..39d6b1f84da 100644
--- a/htdocs/public/bookcal/index.php
+++ b/htdocs/public/bookcal/index.php
@@ -19,7 +19,7 @@
*/
/**
- * \file htdocs/public/onlinesign/newonlinesign.php
+ * \file htdocs/public/bookcal/index.php
* \ingroup core
* \brief File to offer a way to make an online signature for a particular Dolibarr entity
* Example of URL: https://localhost/public/bookcal/booking.php?ref=PR...
@@ -44,6 +44,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/bookcal/class/calendar.class.php';
require_once DOL_DOCUMENT_ROOT.'/bookcal/class/availabilities.class.php';
+require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
$langs->loadLangs(array("main", "other", "dict", "agenda", "errors", "bookcal"));
@@ -179,7 +180,7 @@ print '
';
print '
'.(!empty($object->label) ? $object->label : $object->ref).' ';
-$sql = "SELECT b.rowid, b.ref, b.label, b.start, b.end, b.duration, b.startHour, b.endHour";
+$sql = "SELECT b.rowid, b.label, b.start, b.end, b.duration, b.startHour, b.endHour";
$sql .= " FROM ".MAIN_DB_PREFIX."bookcal_availabilities as b";
$sql .= " WHERE b.status = ".(int) $availabilities::STATUS_VALIDATED;
$sql .= " AND b.fk_bookcal_calendar = ".(int) $id;
@@ -192,7 +193,7 @@ if ($resql) {
while ($i < $num) {
$i++;
$obj = $db->fetch_object($resql);
- print '
'.(!empty($obj->label) ? $obj->label : $obj->ref).' ';
+ print ''.(!empty($obj->label) ? $obj->label : $obj->id).' ';
}
}
print '';
diff --git a/htdocs/public/company/new.php b/htdocs/public/company/new.php
new file mode 100644
index 00000000000..8c34fe03784
--- /dev/null
+++ b/htdocs/public/company/new.php
@@ -0,0 +1,473 @@
+
+ * Copyright (C) 2001-2002 Jean-Louis Bergamo
+ * Copyright (C) 2006-2013 Laurent Destailleur
+ * Copyright (C) 2012 Regis Houssin
+ * Copyright (C) 2012 J. Fernando Lagrange
+ * Copyright (C) 2018-2019 Frédéric France
+ * Copyright (C) 2018 Alexandre Spangaro
+ * Copyright (C) 2021 Waël Almoman
+ * Copyright (C) 2022 Udo Tamm
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/public/company/new.php
+ * \ingroup prospect
+ * \brief Example of form to add a new prospect
+ *
+ */
+
+if (!defined('NOLOGIN')) {
+ define("NOLOGIN", 1); // This means this output page does not require to be logged.
+}
+if (!defined('NOCSRFCHECK')) {
+ define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
+}
+if (!defined('NOBROWSERNOTIF')) {
+ define('NOBROWSERNOTIF', '1');
+}
+
+
+// For MultiCompany module.
+// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
+$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
+if (is_numeric($entity)) {
+ define("DOLENTITY", $entity);
+}
+
+
+// Load Dolibarr environment
+require '../../main.inc.php';
+require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
+require_once DOL_DOCUMENT_ROOT . '/core/lib/payments.lib.php';
+require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
+require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent_type.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/cunits.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/html.formadmin.class.php';
+// Init vars
+$backtopage = GETPOST('backtopage', 'alpha');
+$action = GETPOST('action', 'aZ09');
+
+$errmsg = '';
+$num = 0;
+$error = 0;
+
+// Load translation files
+$langs->loadLangs(array("main", "members", "companies", "install", "other", "errors"));
+
+// Security check
+if (!isModEnabled('societe')) {
+ httponly_accessforbidden('Module Thirdparty not enabled');
+}
+
+if (!getDolGlobalString('SOCIETE_ENABLE_PUBLIC')) {
+ httponly_accessforbidden("Online form for contact for public visitors has not been enabled");
+}
+
+
+//permissions
+
+$permissiontoadd = $user->hasRight('societe', 'creer');
+
+// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
+$hookmanager->initHooks(array('publicnewmembercard', 'globalcard'));
+
+$extrafields = new ExtraFields($db);
+
+
+$objectsoc = new Societe($db);
+$user->loadDefaultValues();
+
+
+/**
+ * Show header for new prospect
+ *
+ * @param string $title Title
+ * @param string $head Head array
+ * @param int $disablejs More content into html header
+ * @param int $disablehead More content into html header
+ * @param array $arrayofjs Array of complementary js files
+ * @param array $arrayofcss Array of complementary css files
+ * @return void
+ */
+function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '')
+{
+ global $conf, $langs, $mysoc;
+
+ top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
+
+ print '';
+
+ // Define urllogo
+ $urllogo = DOL_URL_ROOT . '/theme/common/login_logo.png';
+
+ if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small)) {
+ $urllogo = DOL_URL_ROOT . '/viewimage.php?cache=1&modulepart=mycompany&file=' . urlencode('logos/thumbs/' . $mysoc->logo_small);
+ } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) {
+ $urllogo = DOL_URL_ROOT . '/viewimage.php?cache=1&modulepart=mycompany&file=' . urlencode('logos/' . $mysoc->logo);
+ } elseif (is_readable(DOL_DOCUMENT_ROOT . '/theme/dolibarr_logo.svg')) {
+ $urllogo = DOL_URL_ROOT . '/theme/dolibarr_logo.svg';
+ }
+
+ print '';
+
+ print '';
+}
+
+/**
+ * Show footer for new societe
+ *
+ * @return void
+ */
+function llxFooterVierge()
+{
+ global $conf, $langs;
+
+ $ext = '';
+
+ print '
';
+
+ printCommonFooter('public');
+
+ if (!empty($conf->use_javascript_ajax)) {
+ print "\n" . '' . "\n";
+ print '' . "\n";
+ }
+
+ print "\n";
+ print "\n";
+}
+
+
+
+/*
+ * Actions
+ */
+
+$parameters = array();
+// Note that $action and $object may have been modified by some hooks
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
+if ($reshook < 0) {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+}
+
+// Action called when page is submitted
+if (empty($reshook) && $action == 'add') {
+ $error = 0;
+ $urlback = '';
+
+ $db->begin();
+
+ if (!GETPOST('name')) {
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Company")), null, 'errors');
+ $error++;
+ }
+
+ // Check Captcha code if is enabled
+ if (!empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) {
+ $sessionkey = 'dol_antispam_value';
+ $ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) == strtolower($_POST['code'])));
+ if (!$ok) {
+ $error++;
+ $errmsg .= $langs->trans("ErrorBadValueForCode") . " \n";
+ $action = '';
+ }
+ }
+
+ if (!$error) {
+ $societe = new Societe($db);
+
+ $societe->name = GETPOST('name', 'alphanohtml');
+
+ $societe->client = GETPOST('client', 'int') ? GETPOST('client', 'int') : $societe->client;
+
+ $societe->address = GETPOST('address', 'alphanohtml');
+
+ $societe->country_id = GETPOST('country_id', 'int');
+
+ $societe->phone = GETPOST('phone', 'alpha');
+
+ $societe->fax = GETPOST('fax', 'alpha');
+
+ $societe->email = trim(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL));
+
+ $societe->client = 2 ; // our client is a prospect
+
+ $societe->code_client = -1;
+
+ $societe->name_alias = GETPOST('name_alias', 'alphanohtml');
+
+ $societe->note_private = GETPOST('note_private');
+ if (!$error) {
+ $result = $societe->create($user);
+ if ($result > 0) {
+ require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
+ $objectsoc = $societe;
+
+ if (!empty($backtopage)) {
+ $urlback = $backtopage;
+ } elseif (!empty($conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION)) {
+ $urlback = $conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION;
+ // TODO Make replacement of __AMOUNT__, etc...
+ } else {
+ $urlback = $_SERVER["PHP_SELF"] . "?action=added&token=" . newToken();
+ }
+ } else {
+ $error++;
+ $errmsg .= join(' ', $societe->errors);
+ }
+ }
+ }
+
+ if (!$error) {
+ $db->commit();
+
+ Header("Location: " . $urlback);
+ exit;
+ } else {
+ $db->rollback();
+ $action = "create";
+ }
+}
+
+// Action called after a submitted was send and prospect created successfully
+// If MEMBER_URL_REDIRECT_SUBSCRIPTION is set to an url, we never go here because a redirect was done to this url. Same if we ask to redirect to the payment page.
+// backtopage parameter with an url was set on prospect submit page, we never go here because a redirect was done to this url.
+
+if (empty($reshook) && $action == 'added') {
+ llxHeaderVierge("newSocieteAdded");
+
+ // If we have not been redirected
+ print ' ';
+ print '';
+ print $langs->trans("newSocieteAdded");
+ print '
';
+
+ llxFooterVierge();
+ exit;
+}
+
+
+
+/*
+ * View
+ */
+
+$form = new Form($db);
+$formcompany = new FormCompany($db);
+$adht = new AdherentType($db);
+$formadmin = new FormAdmin($db);
+$extrafields->fetch_name_optionals_label($objectsoc->table_element); // fetch optionals attributes and labels
+
+
+llxHeaderVierge($langs->trans("ContactUs"));
+
+print ' ';
+print load_fiche_titre(img_picto('', 'member_nocolor', 'class="pictofixedwidth"') . ' ' . $langs->trans("ContactUs"), '', '', 0, 0, 'center');
+
+
+print '';
+print '
';
+
+print '
';
+if (!empty($conf->global->COMPANY_NEWFORM_TEXT)) {
+ print $langs->trans($conf->global->COMPANY_NEWFORM_TEXT) . " \n";
+} else {
+ print $langs->trans("ContactUsDesc", getDolGlobalString("MAIN_INFO_SOCIETE_MAIL")) . " \n";
+}
+print '
';
+
+dol_htmloutput_errors($errmsg);
+dol_htmloutput_events();
+
+// Print form
+print '
' . "\n";
+print ' ';
+print ' ';
+print ' ';
+print ' ';
+
+$messagemandatory = '' . $langs->trans("FieldsWithAreMandatory", '*') . ' ';
+//print ''.$langs->trans("FieldsWithAreMandatory", '*').' ';
+//print $langs->trans("FieldsWithIsForPublic",'**').' ';
+
+print dol_get_fiche_head('');
+
+print '';
+
+
+print '' . "\n";
+//Third party name
+/*
+if ($objectsoc->particulier || $private) {
+ print ''.$langs->trans('ThirdPartyName').' / '.$langs->trans('LastName', 'name').' ';
+} else {
+ print ''.$form->editfieldkey('ThirdPartyName', 'name', '', $objectsoc, 0).' ';
+}
+*/
+print ''; // text appreas left
+print ' ';
+print '' . $form->editfieldkey('Company', 'name', '', $objectsoc, 0) . ' * ';
+print ' '; // inline input
+print ' ';
+//
+
+// Name and lastname
+print ' ' . $langs->trans("Firstname") . ' * ' . "\n";
+
+print '' . $langs->trans("Lastname") . ' * ' . "\n";
+
+// Address
+print '';
+print $form->editfieldkey('Address', 'address', '', $objectsoc, 0);
+print ' ';
+print '';
+print '';
+print dol_escape_htmltag($objectsoc->address, 0, 1);
+print ' ';
+print $form->widgetForTranslation("address", $objectsoc, $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent');
+print ' ';
+
+// Country
+print '' . $form->editfieldkey('Country', 'selectcountry_id', '', $objectsoc, 0) . ' ';
+print img_picto('', 'country', 'class="pictofixedwidth"');
+print $form->select_country((GETPOSTISSET('country_id') ? GETPOST('country_id') : $objectsoc->country_id), 'country_id', '', 0, 'minwidth300 maxwidth500 widthcentpercentminusx');
+if ($user->admin) {
+ print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
+}
+print ' ';
+
+// Phone / Fax
+print '' . $form->editfieldkey('Phone', 'phone', '', $objectsoc, 0) . ' ';
+print '' . img_picto('', 'object_phoning', 'class="pictofixedwidth"') . ' ';
+print ' ';
+
+print '';
+print '' . $form->editfieldkey('Fax', 'fax', '', $objectsoc, 0) . ' ';
+print '' . img_picto('', 'object_phoning_fax', 'class="pictofixedwidth"') . ' ';
+print ' ';
+
+// Email / Web
+print '' . $form->editfieldkey('EMail', 'email', '', $objectsoc, 0, 'string', '', empty($conf->global->SOCIETE_EMAIL_MANDATORY) ? '' : $conf->global->SOCIETE_EMAIL_MANDATORY) . ' ';
+print '' . img_picto('', 'object_email', 'class="pictofixedwidth"') . ' ';
+if (isModEnabled('mailing') && !empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) {
+ if ($conf->browser->layout == 'phone') {
+ print '';
+ }
+ print '' . $form->editfieldkey($langs->trans('No_Email') . ' (' . $langs->trans('Contact') . ')', 'contact_no_email', '', $objectsoc, 0) . ' ';
+ print 'browser->layout == 'phone') || !isModEnabled('mailing') ? ' colspan="3"' : '') . '>' . $form->selectyesno('contact_no_email', (GETPOSTISSET("contact_no_email") ? GETPOST("contact_no_email", 'alpha') : (empty($objectsoc->no_email) ? 0 : 1)), 1, false, 1) . ' ';
+}
+print ' ';
+
+print '' . $form->editfieldkey('Web', 'url', '', $objectsoc, 0) . ' ';
+print '' . img_picto('', 'globe', 'class="pictofixedwidth"') . ' ';
+
+
+// Comments
+print '';
+print '' . $langs->trans("Comments") . ' ';
+print '' . dol_escape_htmltag(GETPOST('note_private', 'restricthtml'), 0, 1) . ' ';
+print ' ' . "\n";
+// TODO Move this into generic feature.
+
+
+
+// Display Captcha code if is enabled
+if (!empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) {
+ require_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php';
+ print '' . $langs->trans("SecurityCode") . ' ';
+ print '';
+ print ' ';
+ print ' ';
+ print '';
+ print ' ';
+ print '' . img_picto($langs->trans("Refresh"), 'refresh', 'id="captcha_refresh_img"') . ' ';
+ print ' ';
+ print ' ';
+}
+
+print "
\n";
+
+print dol_get_fiche_end();
+
+// Save / Submit
+print '';
+print ' ';
+if (!empty($backtopage)) {
+ print ' ';
+}
+print '
';
+
+
+print " \n";
+print "
";
+print '
';
+
+
+
+llxFooterVierge();
+
+$db->close();
diff --git a/htdocs/public/demo/index.php b/htdocs/public/demo/index.php
index c71f1d86dc7..ae0d2e53be5 100644
--- a/htdocs/public/demo/index.php
+++ b/htdocs/public/demo/index.php
@@ -110,7 +110,7 @@ if (empty($reshook)) {
// Visible
$alwayscheckedmodules = array('barcode', 'bookmark', 'categorie', 'externalrss', 'fckeditor', 'geoipmaxmind', 'gravatar', 'memcached', 'syslog', 'user', 'webservices'); // Technical module we always want
- $alwaysuncheckedmodules = array('dav', 'dynamicprices', 'incoterm', 'loan', 'multicurrency', 'paybox', 'paypal', 'stripe', 'google', 'printing', 'scanner', 'skype', 'website'); // Module we dont want by default
+ $alwaysuncheckedmodules = array('dav', 'dynamicprices', 'incoterm', 'loan', 'multicurrency', 'paybox', 'paypal', 'stripe', 'google', 'printing', 'scanner', 'socialnetworks', 'website'); // Module we dont want by default
// Not visible
$alwayshiddencheckedmodules = array('accounting', 'api', 'barcode', 'blockedlog', 'bookmark', 'clicktodial', 'comptabilite', 'cron', 'document', 'domain', 'externalrss', 'externalsite', 'fckeditor', 'geoipmaxmind', 'gravatar', 'label', 'ldap',
'mailmanspip', 'notification', 'oauth', 'syslog', 'user', 'webservices', 'workflow',
diff --git a/htdocs/public/emailing/index.html b/htdocs/public/emailing/index.html
deleted file mode 100644
index e69de29bb2d..00000000000
diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php
index 2f2a3254a26..aba005205d9 100644
--- a/htdocs/public/members/new.php
+++ b/htdocs/public/members/new.php
@@ -85,7 +85,7 @@ if (!isModEnabled('adherent')) {
httponly_accessforbidden('Module Membership not enabled');
}
-if (empty($conf->global->MEMBER_ENABLE_PUBLIC)) {
+if (!getDolGlobalString('MEMBER_ENABLE_PUBLIC')) {
httponly_accessforbidden("Auto subscription form for public visitors has not been enabled");
}
diff --git a/htdocs/public/notice.php b/htdocs/public/notice.php
index 57f47424501..c107fba3d3b 100644
--- a/htdocs/public/notice.php
+++ b/htdocs/public/notice.php
@@ -59,3 +59,5 @@ if (!GETPOST('transkey', 'alphanohtml') && !GETPOST('transphrase', 'alphanohtml'
print dol_escape_htmltag($langs->trans(GETPOST('transkey', 'alphanohtml')));
}
}
+
+$db->close();
diff --git a/htdocs/public/onlinesign/index.html b/htdocs/public/onlinesign/index.html
deleted file mode 100644
index 8b137891791..00000000000
--- a/htdocs/public/onlinesign/index.html
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php
index 0bf197e7a5e..99c82669071 100644
--- a/htdocs/public/onlinesign/newonlinesign.php
+++ b/htdocs/public/onlinesign/newonlinesign.php
@@ -136,6 +136,8 @@ if ($source == 'proposal') {
$securekeyseed = getDolGlobalString('CONTRACT_ONLINE_SIGNATURE_SECURITY_TOKEN');
} elseif ($source == 'fichinter') {
$securekeyseed = getDolGlobalString('FICHINTER_ONLINE_SIGNATURE_SECURITY_TOKEN');
+} elseif ($source == 'societe_rib') {
+ $securekeyseed = getDolGlobalString('SOCIETE_RIB_ONLINE_SIGNATURE_SECURITY_TOKEN');
}
if (!dol_verifyHash($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? $entity : ''), $SECUREKEY, '0')) {
httponly_accessforbidden('Bad value for securitykey. Value provided '.dol_escape_htmltag($SECUREKEY).' does not match expected value for ref='.dol_escape_htmltag($ref), 403, 1);
@@ -153,6 +155,10 @@ if ($source == 'proposal') {
require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
$object = new Fichinter($db);
$result= $object->fetch(0, $ref);
+} elseif ($source == 'societe_rib') {
+ require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
+ $object = new CompanyBankAccount($db);
+ $result= $object->fetch($ref);
} else {
httponly_accessforbidden($langs->trans('ErrorBadParameters')." - Bad value for source", 400, 1);
}
@@ -243,6 +249,8 @@ print ' '."\n";
print ' ';
print ' ';
+print ' ';
+print ' ';
print "\n";
print ''."\n";
@@ -308,6 +316,9 @@ if (empty($text)) {
} elseif ($source == 'fichinter') {
$text .= ''.$langs->trans("WelcomeOnOnlineSignaturePageFichinter", $mysoc->name).' '."\n";
$text .= ''.$langs->trans("ThisScreenAllowsYouToSignDocFromFichinter", $creditor).' '."\n";
+ } else {
+ $text .= ''.$langs->trans("WelcomeOnOnlineSignaturePage".dol_ucfirst($source), $mysoc->name).' '."\n";
+ $text .= ''.$langs->trans("ThisScreenAllowsYouToSignDocFrom".dol_ucfirst($source), $creditor).' '."\n";
}
}
print $text;
@@ -321,6 +332,8 @@ if ($source == 'proposal') {
print ''.$langs->trans("ThisIsInformationOnDocumentToSignContract").' : '."\n";
} elseif ($source == 'fichinter') {
print ''.$langs->trans("ThisIsInformationOnDocumentToSignFichinter").' : '."\n";
+} else {
+ print ''.$langs->trans("ThisIsInformationOnDocumentToSign".dol_ucfirst($source)).' : '."\n";
}
$found = false;
$error = 0;
@@ -465,7 +478,8 @@ if ($source == 'proposal') {
print ' ';
print ' ';
print ''."\n";
-} elseif ($source == 'fichinter') { // Signature on fichinter
+} elseif ($source == 'fichinter') {
+ // Signature on fichinter
$found = true;
$langs->load("fichinter");
@@ -513,6 +527,109 @@ if ($source == 'proposal') {
print ' ';
print ' ';
print ''."\n";
+} elseif ($source == 'societe_rib') {
+ $found = true;
+ $langs->loadLangs(array("companies", "commercial", "withdrawals"));
+
+ $result = $object->fetch_thirdparty();
+
+ // Proposer
+ print '' . $langs->trans("Proposer");
+ print ' ';
+ print img_picto('', 'company', 'class="pictofixedwidth"');
+ print '' . $creditor . ' ';
+ print ' ';
+ print ' ' . "\n";
+
+ // Target
+ print '' . $langs->trans("ThirdParty");
+ print ' ';
+ print img_picto('', 'company', 'class="pictofixedwidth"');
+ print '' . $object->thirdparty->name . ' ';
+ print ' ' . "\n";
+
+ // Object
+ $text = '' . $langs->trans("Signature" . dol_ucfirst($source) . "Ref", $object->ref) . ' ';
+ print '' . $langs->trans("Designation");
+ print ' ' . $text;
+
+ $last_main_doc_file = $object->last_main_doc;
+ $diroutput = $conf->societe->multidir_output[$object->thirdparty->entity].'/'
+ .dol_sanitizeFileName($object->thirdparty->id).'/';
+ if ((empty($last_main_doc_file) ||
+ !dol_is_file($diroutput
+ .$langs->transnoentitiesnoconv("SepaMandateShort").' '.$object->id."-".dol_sanitizeFileName($object->rum).".pdf"))
+ && $message != "signed") {
+ // It seems document has never been generated, or was generated and then deleted.
+ // So we try to regenerate it with its default template.
+ //$defaulttemplate = 'sepamandate';
+ $defaulttemplate = getDolGlobalString("BANKADDON_PDF");
+
+ $object->setDocModel($user, $defaulttemplate);
+ $moreparams = array(
+ 'use_companybankid'=>$object->id,
+ 'force_dir_output'=>$diroutput
+ );
+ $result = $object->thirdparty->generateDocument($defaulttemplate, $langs, 0, 0, 0, $moreparams);
+ $object->last_main_doc=$object->thirdparty->last_main_doc;
+ }
+ $directdownloadlink = $object->getLastMainDocLink('company');
+ if ($directdownloadlink) {
+ print '';
+ print img_mime($object->last_main_doc, '');
+ if ($message == "signed") {
+ print $langs->trans("DownloadSignedDocument").' ';
+ } else {
+ print $langs->trans("DownloadDocument").'';
+ }
+ }
+} else {
+ $found = true;
+ $langs->load('companies');
+
+ if (!empty($object->socid) || !empty($object->fk_soc)) {
+ $result = $object->fetch_thirdparty();
+ }
+
+ // Proposer
+ print ' '.$langs->trans("Proposer");
+ print ' ';
+ print img_picto('', 'company', 'class="pictofixedwidth"');
+ print ''.$creditor.' ';
+ print ' ';
+ print ' '."\n";
+
+ // Target
+ print ''.$langs->trans("ThirdParty");
+ print ' ';
+ print img_picto('', 'company', 'class="pictofixedwidth"');
+ print ''.$object->thirdparty->name.' ';
+ print ' '."\n";
+
+ // Object
+ $text = ''.$langs->trans("Signature".dol_ucfirst($source)."Ref", $object->ref).' ';
+ print ''.$langs->trans("Designation");
+ print ' '.$text;
+
+ $last_main_doc_file = $object->last_main_doc;
+
+ if (empty($last_main_doc_file) || !dol_is_file(DOL_DATA_ROOT.'/'.$object->last_main_doc)) {
+ // It seems document has never been generated, or was generated and then deleted.
+ // So we try to regenerate it with its default template.
+ $defaulttemplate = ''; // We force the use an empty string instead of $object->model_pdf to be sure to use a "main" default template and not the last one used.
+ $object->generateDocument($defaulttemplate, $langs);
+ }
+
+ $directdownloadlink = $object->getLastMainDocLink($source);
+ if ($directdownloadlink) {
+ print '';
+ print img_mime($object->last_main_doc, '');
+ if ($message == "signed") {
+ print $langs->trans("DownloadSignedDocument").' ';
+ } else {
+ print $langs->trans("DownloadDocument").'';
+ }
+ }
}
// Call Hook addFormSign
@@ -641,6 +758,12 @@ if ($action == "dosign" && empty($cancel)) {
} else {
print ' ';
}
+ } else {
+ if ($message == 'signed') {
+ print ''.$langs->trans(dol_ucfirst($source)."Signed").' ';
+ } else {
+ print ' ';
+ }
}
}
print ' '."\n";
diff --git a/htdocs/public/opensurvey/index.php b/htdocs/public/opensurvey/index.php
new file mode 100644
index 00000000000..be051b7fe5c
--- /dev/null
+++ b/htdocs/public/opensurvey/index.php
@@ -0,0 +1,255 @@
+
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/public/opensurvey/index.php
+ * \ingroup opensurvey
+ * \brief Public file to show onpen surveys
+ */
+
+if (!defined('NOLOGIN')) {
+ define("NOLOGIN", 1); // This means this output page does not require to be logged.
+}
+if (!defined('NOCSRFCHECK')) {
+ define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
+}
+if (!defined('NOIPCHECK')) {
+ define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
+}
+if (!defined('NOBROWSERNOTIF')) {
+ define('NOBROWSERNOTIF', '1');
+}
+
+// Load Dolibarr environment
+require '../../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/opensurvey/class/opensurveysondage.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
+
+// Load translation files required by the page
+$langs->loadLangs(array("companies", "other", "opensurveys"));
+
+// Get parameters
+$action = GETPOST('action', 'aZ09');
+$cancel = GETPOST('cancel', 'alpha');
+$SECUREKEY = GETPOST("securekey");
+$entity = GETPOST('entity', 'int') ? GETPOST('entity', 'int') : $conf->entity;
+$backtopage = '';
+$suffix = "";
+
+// Load variable for pagination
+$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
+if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
+ $page = 0;
+} // If $page is not defined, or '' or -1 or if we click on clear filters
+$offset = $limit * $page;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+
+if (GETPOST('btn_view')) {
+ unset($_SESSION['email_customer']);
+}
+if (isset($_SESSION['email_customer'])) {
+ $email = $_SESSION['email_customer'];
+}
+
+$object = new Opensurveysondage($db);
+
+// Define $urlwithroot
+//$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
+//$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
+$urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost.
+
+// Security check
+if (empty($conf->recruitment->enabled)) {
+ httponly_accessforbidden('Module Recruitment not enabled');
+}
+
+
+/*
+ * Actions
+ */
+
+// None
+
+
+/*
+ * View
+ */
+
+$head = '';
+if (getDolGlobalString('MAIN_OPENSURVEY_CSS_URL')) {
+ $head = ' '."\n";
+}
+
+$conf->dol_hide_topmenu = 1;
+$conf->dol_hide_leftmenu = 1;
+
+if (!getDolGlobalString('OPENSURVEY_ENABLE_PUBLIC_INTERFACE')) {
+ $langs->load("errors");
+ print ''.$langs->trans('ErrorPublicInterfaceNotEnabled').'
';
+ $db->close();
+ exit();
+}
+
+$arrayofjs = array();
+$arrayofcss = array();
+
+$replacemainarea = (empty($conf->dol_hide_leftmenu) ? '' : '').'
';
+llxHeader($head, $langs->trans("Surveys"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea, 1, 1);
+
+
+print '
'."\n";
+print '
'."\n";
+print '
'."\n";
+print ' '."\n";
+print ' '."\n";
+print ' '."\n";
+print ' '."\n";
+print ' '."\n";
+print ' ';
+print "\n";
+print ''."\n";
+
+// Show logo (search order: logo defined by ONLINE_SIGN_LOGO_suffix, then ONLINE_SIGN_LOGO_, then small company logo, large company logo, theme logo, common logo)
+// Define logo and logosmall
+$logosmall = $mysoc->logo_small;
+$logo = $mysoc->logo;
+$paramlogo = 'ONLINE_OPENSURVEY_LOGO_'.$suffix;
+if (!empty($conf->global->$paramlogo)) {
+ $logosmall = $conf->global->$paramlogo;
+} elseif (!empty($conf->global->ONLINE_OPENSURVEY_LOGO)) {
+ $logosmall = $conf->global->ONLINE_OPENSURVEY_LOGO_;
+}
+//print ''."\n";
+// Define urllogo
+$urllogo = '';
+$urllogofull = '';
+if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) {
+ $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall);
+ $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall);
+} elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) {
+ $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo);
+ $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo);
+}
+// Output html code for logo
+if ($urllogo) {
+ print '';
+ print '
';
+ print '
';
+ print '
';
+ if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
+ print '
';
+ }
+ print '
';
+}
+
+if (!empty($conf->global->OPENSURVEY_IMAGE_PUBLIC_INTERFACE)) {
+ print '';
+ print '
';
+ print '
';
+}
+
+
+$results = $object->fetchAll($sortfield, $sortorder, 0, 0, array('status' => 1));
+$now = dol_now();
+
+if (is_array($results)) {
+ if (empty($results)) {
+ print ' ';
+ print $langs->trans("NoSurvey");
+ } else {
+ print ' ';
+ print ''.$langs->trans("ListOfOpenSurveys").' ';
+ print ' ';
+ print ' ';
+
+ foreach ($results as $survey) {
+ $object = $survey;
+
+ print ''."\n";
+
+ // Output payment summary form
+ print '';
+
+ print '';
+
+ $error = 0;
+ $found = true;
+
+ // Label
+ print $langs->trans("Label").' : ';
+ print '
'.dol_escape_htmltag($object->titre).' ';
+
+ // Date
+ print $langs->trans("DateExpected").' : ';
+ print '
';
+ if ($object->date_fin > $now) {
+ print dol_print_date($object->date_fin, 'day');
+ } else {
+ print $langs->trans("ASAP");
+ }
+ print ' ';
+
+ // Description
+ //print $langs->trans("Desription").' : ';
+ print '
';
+ print '
';
+ print dol_htmlwithnojs(dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->commentaires), 1, 1, 1));
+ //print dol_escape_htmltag($object->commentaires);
+ print '
';
+ print '
';
+
+ print '
'."\n";
+ print "\n";
+
+
+ if ($action != 'dosubmit') {
+ if ($found && !$error) {
+ // We are in a management option and no error
+ } else {
+ dol_print_error_email('ERRORSUBMITAPPLICATION');
+ }
+ } else {
+ // Print
+ }
+
+ print ' '."\n";
+
+ print '
'."\n";
+
+ print ' '."\n";
+ }
+ }
+} else {
+ dol_print_error($db, $object->error, $object->errors);
+}
+
+print ' '."\n";
+print '
'."\n";
+print '
';
+
+
+htmlPrintOnlineFooter($mysoc, $langs);
+
+llxFooter('', 'public');
+
+$db->close();
diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php
index ec1f4829051..c6171867557 100644
--- a/htdocs/public/opensurvey/studs.php
+++ b/htdocs/public/opensurvey/studs.php
@@ -330,7 +330,7 @@ foreach ($toutsujet as $value) {
$toutsujet = str_replace("°", "'", $toutsujet);
-
+print '
';
print '
'.$langs->trans("YouAreInivitedToVote").'
';
print '
'.$langs->trans("OpenSurveyHowTo").' ';
if (empty($object->allow_spy)) {
@@ -338,6 +338,7 @@ if (empty($object->allow_spy)) {
} else {
print $form->textwithpicto('
'.$langs->trans("YourVoteIsPublic").' ', $langs->trans("CanSeeOthersVote")).'
';
}
+print '
';
print '
';
if (empty($object->description)) {
@@ -346,7 +347,7 @@ if (empty($object->description)) {
// show title of survey
$titre = str_replace("\\", "", $object->title);
-print '
'.dol_htmlentities($titre).' ';
+print '
'.img_picto('', 'poll', 'class="size15x paddingright"').' '.dol_htmlentities($titre).'
';
if (!empty($object->description)) {
print '
'."\n";
@@ -372,6 +373,7 @@ print '
'."\n";
print '
'."\n";
// Start to show survey result
+print '
';
print '
'."\n";
// Show choice titles
@@ -498,7 +500,7 @@ while ($compteur < $num) {
print ''."\n";
// Name
- print ''.dol_htmlentities($obj->name).' '."\n";
+ print ''.img_picto($obj->name, 'user', 'class="pictofixedwidth"').dol_htmlentities($obj->name).' '."\n";
// si la ligne n'est pas a changer, on affiche les données
if (!$testligneamodifier) {
@@ -686,7 +688,7 @@ if ($ligneamodifier < 0 && (!isset($_SESSION['nom']))) {
}
print ''."\n";
- // affichage des cases de formulaire checkbox pour un nouveau choix
+ // show cell form checkbox for a new choice
for ($i = 0; $i < $nbcolonnes; $i++) {
print '';
if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) {
@@ -773,6 +775,8 @@ if ($object->allow_spy) {
print '
'."\n";
print '
'."\n";
+print '
'."\n";
+
if ($object->allow_spy) {
$toutsujet = explode(",", $object->sujet);
$toutsujet = str_replace("°", "'", $toutsujet);
@@ -825,7 +829,7 @@ print '
';
$comments = $object->getComments();
if ($comments) {
- print '
'.$langs->trans("CommentsOfVoters").': '."\n";
+ print '
'.img_picto('', 'note', 'class="pictofixedwidth"').'
'.$langs->trans("CommentsOfVoters").': '."\n";
foreach ($comments as $obj) {
// ligne d'un usager pré-authentifié
@@ -836,7 +840,7 @@ if ($comments) {
print '
id_comment.'&sondage='.$numsondage.'"> '.img_picto('', 'delete.png', '', false, 0, 0, '', 'nomarginleft').' ';
}
//else print img_picto('', 'ellipsis-h', '', false, 0, 0, '', 'nomarginleft').' ';
- print dol_htmlentities($obj->usercomment).':
";
+ print img_picto('', 'user', 'class="pictofixedwidth"').dol_htmlentities($obj->usercomment).':
";
}
}
diff --git a/htdocs/public/partnership/new.php b/htdocs/public/partnership/new.php
index 174b35dc9b8..2bd0247a965 100644
--- a/htdocs/public/partnership/new.php
+++ b/htdocs/public/partnership/new.php
@@ -229,6 +229,7 @@ if (empty($reshook) && $action == 'add') {
$partnership->date_partnership_start = dol_now();
$partnership->fk_user_creat = 0;
$partnership->fk_type = GETPOST('partnershiptype', 'int');
+ $partnership->url = GETPOST('url');
//$partnership->typeid = $conf->global->PARTNERSHIP_NEWFORM_FORCETYPE ? $conf->global->PARTNERSHIP_NEWFORM_FORCETYPE : GETPOST('typeid', 'int');
$partnership->ip = getUserRemoteIP();
@@ -253,16 +254,16 @@ if (empty($reshook) && $action == 'add') {
}
}
}
- // test if societe already exist
+ // test if thirdparty already exists
$company = new Societe($db);
$result = $company->fetch(0, GETPOST('societe'));
- if ($result == 0) { // si il ya pas d'entree sur le nom on teste l'email
+ if ($result == 0) { // if entry with name not found, we search using the email
$result1 = $company->fetch(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, GETPOST('email'));
if ($result1 > 0) {
$error++;
$errmsg = $langs->trans("EmailAlreadyExistsPleaseRewriteYourCompanyName");
} else {
- //create thirdparty
+ // create thirdparty
$company = new Societe($db);
$company->name = GETPOST('societe');
diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php
index f9cbcc76567..0a304bb7aed 100644
--- a/htdocs/public/payment/newpayment.php
+++ b/htdocs/public/payment/newpayment.php
@@ -94,7 +94,7 @@ if (!GETPOST("currency", 'alpha')) {
$currency = GETPOST("currency", 'aZ09');
}
$source = GETPOST("s", 'aZ09') ?GETPOST("s", 'aZ09') : GETPOST("source", 'aZ09');
-//$download = GETPOST('d', 'int') ?GETPOST('d', 'int') : GETPOST('download', 'int');
+$getpostlang = GETPOST('lang', 'aZ09');
if (!$action) {
if (!GETPOST("amount", 'alpha') && !$source) {
@@ -241,6 +241,10 @@ if (!empty($entity)) {
$urlok .= 'e='.urlencode($entity).'&';
$urlko .= 'e='.urlencode($entity).'&';
}
+if (!empty($getpostlang)) {
+ $urlok .= 'lang='.urlencode($getpostlang).'&';
+ $urlko .= 'lang='.urlencode($getpostlang).'&';
+}
$urlok = preg_replace('/&$/', '', $urlok); // Remove last &
$urlko = preg_replace('/&$/', '', $urlko); // Remove last &
@@ -834,7 +838,7 @@ $form = new Form($db);
$head = '';
if (!empty($conf->global->ONLINE_PAYMENT_CSS_URL)) {
- $head = '
'."\n";
+ $head = '
'."\n";
}
$conf->dol_hide_topmenu = 1;
@@ -878,6 +882,7 @@ print '
'."\n";
print '
';
print '
';
+print '
';
print "\n";
@@ -2233,6 +2238,7 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme
print '
';
print '
';
print '
';
+ print '
';
if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || !empty($conf->global->STRIPE_USE_NEW_CHECKOUT)) { // Use a SCA ready method
require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php
index 9435c94b193..6b59c71d473 100644
--- a/htdocs/public/payment/paymentok.php
+++ b/htdocs/public/payment/paymentok.php
@@ -387,6 +387,10 @@ $tmptag = dolExplodeIntoArray($fulltag, '.', '=');
dol_syslog("ispaymentok=".$ispaymentok." tmptag=".var_export($tmptag, true), LOG_DEBUG, 0, '_payment');
+// Set $appli for emails title
+$appli = $mysoc->name;
+
+
// Make complementary actions
$ispostactionok = 0;
$postactionmessages = array();
@@ -1322,7 +1326,7 @@ if ($ispaymentok) {
$subject = $arraydefaultmessage->topic;
$msg = $arraydefaultmessage->content;
} else {
- $subject = '['.$appli.'] '.$object->ref.' - '.$outputlangs->trans("NewRegistration").']';
+ $subject = '['.$appli.'] '.$object->ref.' - '.$outputlangs->trans("NewRegistration");
$msg = $outputlangs->trans("OrganizationEventPaymentOfRegistrationWasReceived");
}
@@ -1716,10 +1720,6 @@ if ($ispaymentok) {
}
-// Set $appli for emails title
-$appli = $mysoc->name;
-
-
if ($ispaymentok) {
// Get on url call
$onlinetoken = empty($PAYPALTOKEN) ? $_SESSION['onlinetoken'] : $PAYPALTOKEN;
@@ -1764,7 +1764,7 @@ if ($ispaymentok) {
dol_syslog("Send email to admins if we have to (sendemail = ".$sendemail.")", LOG_DEBUG, 0, '_payment');
- // Send an email to admins
+ // Send an email to the admins
if ($sendemail) {
$companylangs = new Translate('', $conf);
$companylangs->setDefaultLang($mysoc->default_lang);
diff --git a/htdocs/public/recruitment/index.php b/htdocs/public/recruitment/index.php
index 7fa61c93cf7..19debdf1bcd 100644
--- a/htdocs/public/recruitment/index.php
+++ b/htdocs/public/recruitment/index.php
@@ -104,7 +104,7 @@ if (!empty($conf->global->MAIN_RECRUITMENT_CSS_URL)) {
$conf->dol_hide_topmenu = 1;
$conf->dol_hide_leftmenu = 1;
-if (!$conf->global->RECRUITMENT_ENABLE_PUBLIC_INTERFACE) {
+if (!getDolGlobalString('RECRUITMENT_ENABLE_PUBLIC_INTERFACE')) {
$langs->load("errors");
print '
'.$langs->trans('ErrorPublicInterfaceNotEnabled').'
';
$db->close();
@@ -211,7 +211,7 @@ if (is_array($results)) {
// Output payment summary form
print '
';
- print '';
+ print '
';
print '
'.$langs->trans("ThisIsInformationOnJobPosition").' :
'."\n";
$error = 0;
diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php
index f9e0799897a..0e47828b580 100644
--- a/htdocs/public/stripe/ipn.php
+++ b/htdocs/public/stripe/ipn.php
@@ -1,6 +1,7 @@
- * Copyright (C) 2018 Frédéric France
+/* Copyright (C) 2018-2020 Thibault FOUCART
+ * Copyright (C) 2018 Fédéric France
+ * Copyright (C) 2023 Laurent Destailleur
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -111,7 +112,7 @@ $event = null;
if (getDolGlobalString('STRIPE_DEBUG')) {
$fh = fopen(DOL_DATA_ROOT.'/dolibarr_stripeipn_payload.log', 'w+');
if ($fh) {
- fwrite($fh, dol_print_date(dol_now('gmt'), 'standard').' IPN Called. HTTP_STRIPE_SIGNATURE='.$sig_header."\n");
+ fwrite($fh, dol_print_date(dol_now('gmt'), 'standard').' IPN Called. service='.$service.' HTTP_STRIPE_SIGNATURE='.$sig_header."\n");
fwrite($fh, $payload);
fclose($fh);
dolChmod(DOL_DATA_ROOT.'/dolibarr_stripeipn_payload.log');
@@ -126,7 +127,7 @@ try {
// Invalid payload
httponly_accessforbidden('Invalid payload', 400);
} catch (\Stripe\Exception\SignatureVerificationException $e) {
- httponly_accessforbidden('Invalid signature', 400);
+ httponly_accessforbidden('Invalid signature. May be a hook for an event created by another Stripe env ? Check setup of your keys whsec_...', 400);
} catch (Exception $e) {
httponly_accessforbidden('Error '.$e->getMessage(), 400);
}
@@ -326,30 +327,53 @@ if ($event->type == 'payout.created') {
$paymentmethodstripeid = $object->payment_method;
$customer_id = $object->customer;
$invoice_id = "";
- $paymentTypeId = "";
+ $paymentTypeId = ""; // payment type according to Stripe
+ $paymentTypeIdInDolibarr = ""; // payment type according to Dolibarr
$payment_amount = 0;
+ $payment_amountInDolibarr = 0;
- dol_syslog("Try to find the payment in database for the payment_intent id = ".$TRANSACTIONID);
+ dol_syslog("Try to find a payment in database for the payment_intent id = ".$TRANSACTIONID);
- $sql = "SELECT pi.rowid, pi.fk_facture, pi.fk_prelevement_bons, pi.amount, pi.type";
+ $sql = "SELECT pi.rowid, pi.fk_facture, pi.fk_prelevement_bons, pi.amount, pi.type, pi.traite";
$sql .= " FROM llx_prelevement_demande as pi";
$sql .= " WHERE pi.ext_payment_id = '".$db->escape($TRANSACTIONID)."'";
- $sql .= " AND pi.traite = '1'";
+ //$sql .= " AND pi.type = 'ban' AND pi.traite = '1'";
$sql .= " AND pi.ext_payment_site = '".$db->escape($service)."'";
$result = $db->query($sql);
if ($result) {
$obj = $db->fetch_object($result);
if ($obj) {
- $pdid = $obj->rowid;
- $invoice_id = $obj->fk_facture;
- $directdebitorcreditransfer_id = $obj->fk_prelevement_bons;
- $payment_amount = $obj->amount;
- $paymentTypeId = $obj->type;
+ if ($obj->type == 'ban') {
+ if ($obj->traite == 1) {
+ // This is a direct-debit with an order (llx_bon_prelevement) ALREADY generated, so
+ // it means we received here the confirmation that payment request is finished.
+ $pdid = $obj->rowid;
+ $invoice_id = $obj->fk_facture;
+ $directdebitorcreditransfer_id = $obj->fk_prelevement_bons;
+ $payment_amountInDolibarr = $obj->amount;
+ $paymentTypeIdInDolibarr = $obj->type;
- dol_syslog("Found a request in database to pay with direct debit pdid = ".$pdid." directdebitorcreditransfer_id=".$directdebitorcreditransfer_id);
+ dol_syslog("Found a request in database to pay with direct debit generated (pdid = ".$pdid." directdebitorcreditransfer_id=".$directdebitorcreditransfer_id.")");
+ } else {
+ dol_syslog("Found a request in database not yet generated (pdid = ".$pdid." directdebitorcreditransfer_id=".$directdebitorcreditransfer_id."). Was the order deleted after being sent ?", LOG_WARNING);
+ }
+ }
+ if ($obj->type == 'card' || empty($obj->type)) {
+ if ($obj->traite == 0) {
+ // This is a card payment not already flagged as sent to Stripe.
+ $pdid = $obj->rowid;
+ $invoice_id = $obj->fk_facture;
+ $payment_amountInDolibarr = $obj->amount;
+ $paymentTypeIdInDolibarr = empty($obj->type) ? 'card' : $obj->type;
+
+ dol_syslog("Found a request in database to pay with card (pdid = ".$pdid."). We should fix status traite to 1");
+ } else {
+ dol_syslog("Found a request in database to pay with card (pdid = ".$pdid.") already set to traite=1. Nothing to fix.");
+ }
+ }
} else {
- dol_syslog("Not found");
+ dol_syslog("Payment intent not found into database, so ignored.");
print "Payment intent not found into database, so ignored.";
http_response_code(200);
return 1;
@@ -360,186 +384,247 @@ if ($event->type == 'payout.created') {
return -1;
}
- // Here a $invoice_id has been found.
+ if ($paymentTypeIdInDolibarr) {
+ // Here, we need to do something. A $invoice_id has been found.
- $stripeacc = $stripearrayofkeysbyenv[$servicestatus]['secret_key'];
+ $stripeacc = $stripearrayofkeysbyenv[$servicestatus]['secret_key'];
- dol_syslog("Get the Stripe payment object for the payment method id = ".json_encode($paymentmethodstripeid));
+ dol_syslog("Get the Stripe payment object for the payment method id = ".json_encode($paymentmethodstripeid));
- $s = new \Stripe\StripeClient($stripeacc);
+ $s = new \Stripe\StripeClient($stripeacc);
- $paymentmethodstripe = $s->paymentMethods->retrieve($paymentmethodstripeid);
- $paymentTypeId = $paymentmethodstripe->type;
- if ($paymentTypeId == "ban" || $paymentTypeId == "sepa_debit") {
- $paymentTypeId = "PRE";
- } elseif ($paymentTypeId == "card") {
- $paymentTypeId = "CB";
- }
-
- if ($paymentTypeId == "PRE") {
- $paiement = new Paiement($db);
- $paiement->datepaye = $now;
- $paiement->date = $now;
- if ($currencyCodeType == $conf->currency) {
- $paiement->amounts = [$invoice_id => $payment_amount]; // Array with all payments dispatching with invoice id
- } else {
- $paiement->multicurrency_amounts = [$invoice_id => $payment_amount]; // Array with all payments dispatching
-
- $postactionmessages[] = 'Payment was done in a different currency than currency expected of company';
- $ispostactionok = -1;
- // Not yet supported, so error
- $error++;
- }
- $paiement->paiementid = $paymentTypeId;
- $paiement->num_payment = '';
- $paiement->note_public = '';
- $paiement->note_private = 'StripeSepa payment ' . dol_print_date($now, 'standard') . ' using ' . $servicestatus . ($ipaddress ? ' from ip ' . $ipaddress : '') . ' - Transaction ID = ' . $TRANSACTIONID;
- $paiement->ext_payment_id = $TRANSACTIONID.':'.$customer_id.'@'.$stripearrayofkeysbyenv[$servicestatus]['publishable_key']; // May be we should store py_... instead of pi_... but we started with pi_... so we continue.
- $paiement->ext_payment_site = $service;
-
- $ispaymentdone = 0;
- $sql = "SELECT p.rowid FROM llx_paiement as p";
- $sql .= " WHERE p.ext_payment_id = '".$db->escape($paiement->ext_payment_id)."'";
- $sql .= " AND p.ext_payment_site = '".$db->escape($paiement->ext_payment_site)."'";
- $result = $db->query($sql);
- if ($result) {
- if ($db->num_rows($result)) {
- $ispaymentdone = 1;
- dol_syslog('* Payment for ext_payment_id '.$paiement->ext_payment_id.' already done. We do not recreate the payment');
- }
+ $paymentmethodstripe = $s->paymentMethods->retrieve($paymentmethodstripeid);
+ $paymentTypeId = $paymentmethodstripe->type;
+ if ($paymentTypeId == "ban" || $paymentTypeId == "sepa_debit") {
+ $paymentTypeId = "PRE";
+ } elseif ($paymentTypeId == "card") {
+ $paymentTypeId = "CB";
}
- $db->begin();
+ $payment_amount = $payment_amountInDolibarr;
+ // TODO Check payment_amount in Stripe (received) is same than the one in Dolibarr
- if (!$error && !$ispaymentdone) {
- dol_syslog('* Record payment for invoice id ' . $invoice_id . '. It includes closing of invoice and regenerating document');
+ if ($paymentTypeId == "CB" && ($paymentTypeIdInDolibarr == 'card' || empty($paymentTypeIdInDolibarr))) {
+ // Case payment type in Stripe and into prelevement_demande are both CARD.
+ // For this case, payment should already have been recorded so we just update flag of payment request if not yet 1
- // This include closing invoices to 'paid' (and trigger including unsuspending) and regenerating document
- $paiement_id = $paiement->create($user, 1);
- if ($paiement_id < 0) {
- $postactionmessages[] = $paiement->error . ($paiement->error ? ' ' : '') . join(" \n", $paiement->errors);
- $ispostactionok = -1;
- $error++;
+ // TODO Set traite to 1
+ dol_syslog("TODO update flag traite to 1");
+ } elseif ($paymentTypeId == "PRE" && $paymentTypeIdInDolibarr == 'ban') {
+ // Case payment type in Stripe and into prelevement_demande are both BAN.
+ // For this case, payment on invoice (not yet recorded) must be done and direct debit order must be closed.
- dol_syslog("Failed to create the payment for invoice id " . $invoice_id);
+ $paiement = new Paiement($db);
+ $paiement->datepaye = $now;
+ $paiement->date = $now;
+ if ($currencyCodeType == $conf->currency) {
+ $paiement->amounts = [$invoice_id => $payment_amount]; // Array with all payments dispatching with invoice id
} else {
- $postactionmessages[] = 'Payment created';
+ $paiement->multicurrency_amounts = [$invoice_id => $payment_amount]; // Array with all payments dispatching
- dol_syslog("The payment has been created for invoice id " . $invoice_id);
+ $postactionmessages[] = 'Payment was done in a different currency than currency expected of company';
+ $ispostactionok = -1;
+ // Not yet supported, so error
+ $error++;
}
- }
+ $paiement->paiementid = $paymentTypeId;
+ $paiement->num_payment = '';
+ $paiement->note_public = '';
+ $paiement->note_private = 'StripeSepa payment ' . dol_print_date($now, 'standard') . ' using ' . $servicestatus . ($ipaddress ? ' from ip ' . $ipaddress : '') . ' - Transaction ID = ' . $TRANSACTIONID;
+ $paiement->ext_payment_id = $TRANSACTIONID.':'.$customer_id.'@'.$stripearrayofkeysbyenv[$servicestatus]['publishable_key']; // May be we should store py_... instead of pi_... but we started with pi_... so we continue.
+ $paiement->ext_payment_site = $service;
- if (!$error && isModEnabled('banque')) {
- // Search again the payment to see if it is already linked to a bank payment record (We should always find the payement now we have created before).
$ispaymentdone = 0;
- $sql = "SELECT p.rowid, p.fk_bank FROM llx_paiement as p";
+ $sql = "SELECT p.rowid FROM llx_paiement as p";
$sql .= " WHERE p.ext_payment_id = '".$db->escape($paiement->ext_payment_id)."'";
$sql .= " AND p.ext_payment_site = '".$db->escape($paiement->ext_payment_site)."'";
- $sql .= " AND p.fk_bank <> 0";
$result = $db->query($sql);
if ($result) {
if ($db->num_rows($result)) {
$ispaymentdone = 1;
- $obj = $db->fetch_object($result);
- dol_syslog('* Payment already linked to bank record '.$obj->fk_bank.' . We do not recreate the link');
+ dol_syslog('* Payment for ext_payment_id '.$paiement->ext_payment_id.' already done. We do not recreate the payment');
}
}
- if (!$ispaymentdone) {
- dol_syslog('* Add payment to bank');
- // The bank used is the one defined into Stripe setup
- $paymentmethod = 'stripe';
- $bankaccountid = getDolGlobalInt("STRIPE_BANK_ACCOUNT_FOR_PAYMENTS");
+ $db->begin();
- if ($bankaccountid > 0) {
- $label = '(CustomerInvoicePayment)';
- $result = $paiement->addPaymentToBank($user, 'payment', $label, $bankaccountid, $customer_id, '');
- if ($result < 0) {
- $postactionmessages[] = $paiement->error . ($paiement->error ? ' ' : '') . join(" \n", $paiement->errors);
+ if (!$error && !$ispaymentdone) {
+ dol_syslog('* Record payment for invoice id ' . $invoice_id . '. It includes closing of invoice and regenerating document');
+
+ // This include closing invoices to 'paid' (and trigger including unsuspending) and regenerating document
+ $paiement_id = $paiement->create($user, 1);
+ if ($paiement_id < 0) {
+ $postactionmessages[] = $paiement->error . ($paiement->error ? ' ' : '') . join(" \n", $paiement->errors);
+ $ispostactionok = -1;
+ $error++;
+
+ dol_syslog("Failed to create the payment for invoice id " . $invoice_id);
+ } else {
+ $postactionmessages[] = 'Payment created';
+
+ dol_syslog("The payment has been created for invoice id " . $invoice_id);
+ }
+ }
+
+ if (!$error && isModEnabled('banque')) {
+ // Search again the payment to see if it is already linked to a bank payment record (We should always find the payement now we have created before).
+ $ispaymentdone = 0;
+ $sql = "SELECT p.rowid, p.fk_bank FROM llx_paiement as p";
+ $sql .= " WHERE p.ext_payment_id = '".$db->escape($paiement->ext_payment_id)."'";
+ $sql .= " AND p.ext_payment_site = '".$db->escape($paiement->ext_payment_site)."'";
+ $sql .= " AND p.fk_bank <> 0";
+ $result = $db->query($sql);
+ if ($result) {
+ if ($db->num_rows($result)) {
+ $ispaymentdone = 1;
+ $obj = $db->fetch_object($result);
+ dol_syslog('* Payment already linked to bank record '.$obj->fk_bank.' . We do not recreate the link');
+ }
+ }
+ if (!$ispaymentdone) {
+ dol_syslog('* Add payment to bank');
+
+ // The bank used is the one defined into Stripe setup
+ $paymentmethod = 'stripe';
+ $bankaccountid = getDolGlobalInt("STRIPE_BANK_ACCOUNT_FOR_PAYMENTS");
+
+ if ($bankaccountid > 0) {
+ $label = '(CustomerInvoicePayment)';
+ $result = $paiement->addPaymentToBank($user, 'payment', $label, $bankaccountid, $customer_id, '');
+ if ($result < 0) {
+ $postactionmessages[] = $paiement->error . ($paiement->error ? ' ' : '') . join(" \n", $paiement->errors);
+ $ispostactionok = -1;
+ $error++;
+ } else {
+ $postactionmessages[] = 'Bank transaction of payment created (by ipn.php file)';
+ }
+ } else {
+ $postactionmessages[] = 'Setup of bank account to use in module ' . $paymentmethod . ' was not set. No way to record the payment.';
$ispostactionok = -1;
$error++;
+ }
+ }
+ }
+
+ if (!$error && isModEnabled('prelevement')) {
+ $bon = new BonPrelevement($db);
+ $idbon = 0;
+ $sql = "SELECT dp.fk_prelevement_bons as idbon";
+ $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as dp";
+ $sql .= " JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb"; // Here we join to prevent modification of a prelevement bon already credited
+ $sql .= " ON pb.rowid = dp.fk_prelevement_bons";
+ $sql .= " WHERE dp.fk_facture = ".((int) $invoice_id);
+ $sql .= " AND dp.sourcetype = 'facture'";
+ $sql .= " AND dp.ext_payment_id = '".$db->escape($TRANSACTIONID)."'";
+ $sql .= " AND dp.traite = 1";
+ $sql .= " AND statut = ".((int) $bon::STATUS_TRANSFERED); // To be sure that it's not already credited
+ $result = $db->query($sql);
+ if ($result) {
+ if ($db->num_rows($result)) {
+ $obj = $db->fetch_object($result);
+ $idbon = $obj->idbon;
+ dol_syslog('* Set prelevement to credite');
} else {
- $postactionmessages[] = 'Bank transaction of payment created (by makeStripeSepaRequest)';
+ dol_syslog('* Prelevement not found or already credited');
}
} else {
- $postactionmessages[] = 'Setup of bank account to use in module ' . $paymentmethod . ' was not set. No way to record the payment.';
+ $postactionmessages[] = $db->lasterror();
$ispostactionok = -1;
$error++;
}
- }
- }
- if (!$error && isModEnabled('prelevement')) {
- $bon = new BonPrelevement($db);
- $idbon = 0;
- $sql = "SELECT dp.fk_prelevement_bons as idbon";
- $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as dp";
- $sql .= " JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb"; // Here we join to prevent modification of a prelevement bon already credited
- $sql .= " ON pb.rowid = dp.fk_prelevement_bons";
- $sql .= " WHERE dp.fk_facture = ".((int) $invoice_id);
- $sql .= " AND dp.sourcetype = 'facture'";
- $sql .= " AND dp.ext_payment_id = '".$db->escape($TRANSACTIONID)."'";
- $sql .= " AND dp.traite = 1";
- $sql .= " AND statut = ".((int) $bon::STATUS_TRANSFERED); // To be sure that it's not already credited
- $result = $db->query($sql);
- if ($result) {
- if ($db->num_rows($result)) {
- $obj = $db->fetch_object($result);
- $idbon = $obj->idbon;
- dol_syslog('* Set prelevement to credite');
- } else {
- dol_syslog('* Prelevement not found or already credited');
+ if (!$error && !empty($idbon)) {
+ $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_bons";
+ $sql .= " SET fk_user_credit = ".((int) $user->id);
+ $sql .= ", statut = ".((int) $bon::STATUS_CREDITED);
+ $sql .= ", date_credit = '".$db->idate($now)."'";
+ $sql .= ", credite = 1";
+ $sql .= " WHERE rowid = ".((int) $idbon);
+ $sql .= " AND statut = ".((int) $bon::STATUS_TRANSFERED);
+
+ $result = $db->query($sql);
+ if (!$result) {
+ $postactionmessages[] = $db->lasterror();
+ $ispostactionok = -1;
+ $error++;
+ }
}
+
+ if (!$error && !empty($idbon)) {
+ $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_lignes";
+ $sql .= " SET statut = 2";
+ $sql .= " WHERE fk_prelevement_bons = ".((int) $idbon);
+ $result = $db->query($sql);
+ if (!$result) {
+ $postactionmessages[] = $db->lasterror();
+ $ispostactionok = -1;
+ $error++;
+ }
+ }
+ }
+
+ if (!$error) {
+ $db->commit();
+ http_response_code(200);
+ return 1;
} else {
- $postactionmessages[] = $db->lasterror();
- $ispostactionok = -1;
- $error++;
+ $db->rollback();
+ http_response_code(500);
+ return -1;
}
-
- if (!$error && !empty($idbon)) {
- $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_bons";
- $sql .= " SET fk_user_credit = ".((int) $user->id);
- $sql .= ", statut = ".((int) $bon::STATUS_CREDITED);
- $sql .= ", date_credit = '".$db->idate($now)."'";
- $sql .= ", credite = 1";
- $sql .= " WHERE rowid = ".((int) $idbon);
- $sql .= " AND statut = ".((int) $bon::STATUS_TRANSFERED);
-
- $result = $db->query($sql);
- if (!$result) {
- $postactionmessages[] = $db->lasterror();
- $ispostactionok = -1;
- $error++;
- }
- }
-
- if (!$error && !empty($idbon)) {
- $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_lignes";
- $sql .= " SET statut = 2";
- $sql .= " WHERE fk_prelevement_bons = ".((int) $idbon);
- $result = $db->query($sql);
- if (!$result) {
- $postactionmessages[] = $db->lasterror();
- $ispostactionok = -1;
- $error++;
- }
- }
- }
-
- if (!$error) {
- $db->commit();
- http_response_code(200);
- return 1;
} else {
- $db->rollback();
- http_response_code(500);
- return -1;
+ dol_syslog("The payment mode of this payment is ".$paymentTypeId." in Stripe and ".$paymentTypeIdInDolibarr." in Dolibarr. This case is not managed by the IPN");
}
} else {
- dol_syslog("The payment mode of this payment is ".$paymentTypeId.". This payment mode is not managed by the IPN");
+ dol_syslog("Nothing to do in database");
}
} elseif ($event->type == 'payment_intent.payment_failed') {
dol_syslog("A try to make a payment has failed");
+
+ $db->begin();
+
+ $object = $event->data->object;
+ $ipaddress = $object->metadata->ipaddress;
+ $now = dol_now();
+ $currencyCodeType = strtoupper($object->currency);
+ $paymentmethodstripeid = $object->payment_method;
+ $customer_id = $object->customer;
+
+ $chargesdata = $object->charges->data;
+ $objpayid = $chargesdata->id;
+ $objpaydesc = $chargesdata->description;
+ $objinvoiceid = 0;
+ if ($chargesdata->metadata->dol_type == 'facture') {
+ $objinvoiceid = $chargesdata->metadata->dol_id;
+ }
+ $objerrcode = $chargesdata->outcome->reason;
+ $objerrmessage = $chargesdata->outcome->seller_message;
+
+ $objpaymentmodetype = $chargesdata->payment_method_details->type;
+
+ // If this is a differed payment for SEPA, add a line into agenda events
+ if ($objpaymentmodetype == 'sepa_debit') {
+ require_once DOL_DOCUMENT_ROOT.'/comm/class/actioncomm.class.php';
+ $actioncomm = new ActionComm($db);
+
+ if ($objinvoiceid > 0) {
+ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
+ $invoice = new Facture($db);
+ $invoice->fetch($objinvoiceid);
+
+ $actioncomm->socid = $invoice->fk_soc;
+ $actioncomm->fk_project = $invoice->fk_project;
+ $actioncomm->elementid = $invoice->id;
+ $actioncomm->elementtype = $invoice->type;
+ }
+
+ $actioncomm->actionmsg = 'Error returned on payment id '.$objpayid.' after request '.$objpaydesc.' Error code is: '.$objerrcode.' Error message is: '.$objerrmessage;
+ $actioncomm->actionmsg2 = 'Payment error returned';
+
+ $actioncomm->create($user);
+ }
+
+ $db->commit();
} elseif ($event->type == 'checkout.session.completed') { // Called when making payment with new Checkout method ($conf->global->STRIPE_USE_NEW_CHECKOUT is on).
// TODO: create fees
} elseif ($event->type == 'payment_method.attached') {
diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php
index 954e2428cfe..ccf0b992e29 100644
--- a/htdocs/public/ticket/list.php
+++ b/htdocs/public/ticket/list.php
@@ -266,7 +266,7 @@ if ($action == "view_ticketlist") {
if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
if ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate') {
- $enabled = abs(dol_eval($extrafields->attributes[$object->table_element]['list'][$key], 1, 1, 0));
+ $enabled = abs(dol_eval($extrafields->attributes[$object->table_element]['list'][$key], 1, 1, '2'));
$enabled = (($enabled == 0 || $enabled == 3) ? 0 : $enabled);
$arrayfields["ef.".$key] = array('label' => $extrafields->attributes[$object->table_element]['label'][$key], 'checked' => ($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1, 'position' => $extrafields->attributes[$object->table_element]['pos'][$key], 'enabled' => $enabled && $extrafields->attributes[$object->table_element]['perms'][$key]);
}
diff --git a/htdocs/public/website/javascript.js.php b/htdocs/public/website/javascript.js.php
new file mode 100644
index 00000000000..51cecf8c699
--- /dev/null
+++ b/htdocs/public/website/javascript.js.php
@@ -0,0 +1,171 @@
+
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/public/website/javascript.js.php
+ * \ingroup website
+ * \brief Page to output style page. Called with
+ */
+
+if (!defined('NOTOKENRENEWAL')) {
+ define('NOTOKENRENEWAL', 1); // Disables token renewal
+}
+if (!defined('NOLOGIN')) {
+ define("NOLOGIN", 1);
+}
+if (!defined('NOCSRFCHECK')) {
+ define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
+}
+if (!defined('NOREQUIREMENU')) {
+ define('NOREQUIREMENU', '1');
+}
+if (!defined('NOREQUIREHTML')) {
+ define('NOREQUIREHTML', '1');
+}
+if (!defined('NOREQUIREAJAX')) {
+ define('NOREQUIREAJAX', '1');
+}
+if (!defined('NOIPCHECK')) {
+ define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
+}
+if (!defined('NOBROWSERNOTIF')) {
+ define('NOBROWSERNOTIF', '1');
+}
+
+/**
+ * Header empty
+ *
+ * @return void
+ */
+function llxHeader()
+{
+}
+/**
+ * Footer empty
+ *
+ * @return void
+ */
+function llxFooter()
+{
+}
+
+require '../../master.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+
+
+$error = 0;
+$website = GETPOST('website', 'alpha');
+$websiteid = GETPOST('websiteid', 'int');
+$pageid = GETPOST('page', 'alpha') ?GETPOST('page', 'alpha') : GETPOST('pageid', 'alpha');
+
+$accessallowed = 1;
+$type = '';
+
+
+/*
+ * View
+ */
+
+$appli = constant('DOL_APPLICATION_TITLE');
+if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
+ $appli = $conf->global->MAIN_APPLICATION_TITLE;
+}
+
+//print 'Directory with '.$appli.' websites. ';
+
+if (empty($pageid)) {
+ require_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
+
+ $object = new Website($db);
+ if ($websiteid) {
+ $object->fetch($websiteid);
+ $website = $object->ref;
+ } else {
+ $object->fetch(0, $website);
+ }
+
+ $objectpage = new WebsitePage($db);
+ /* Not required for CSS file
+ $array=$objectpage->fetchAll($object->id);
+
+ if (is_array($array) && count($array) > 0)
+ {
+ $firstrep=reset($array);
+ $pageid=$firstrep->id;
+ }
+ */
+}
+/* Not required for CSS file
+if (empty($pageid))
+{
+ $langs->load("website");
+ print $langs->trans("PreviewOfSiteNotYetAvailable");
+ exit;
+}
+*/
+
+// Security: Delete string ../ into $original_file
+global $dolibarr_main_data_root;
+
+$original_file = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$website.'/javascript.js.php';
+
+// Find the subdirectory name as the reference
+$refname = basename(dirname($original_file)."/");
+
+// Security:
+// Limite acces si droits non corrects
+if (!$accessallowed) {
+ accessforbidden();
+}
+
+// Security:
+// On interdit les remontees de repertoire ainsi que les pipe dans
+// les noms de fichiers.
+if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file)) {
+ dol_syslog("Refused to deliver file ".$original_file);
+ $file = basename($original_file); // Do no show plain path of original_file in shown error message
+ dol_print_error(0, $langs->trans("ErrorFileNameInvalid", $file));
+ exit;
+}
+
+clearstatcache();
+
+$filename = basename($original_file);
+
+// Output file on browser
+dol_syslog("javascript.js.css.php include $original_file $filename content-type=$type");
+$original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset
+
+// This test if file exists should be useless. We keep it to find bug more easily
+if (!file_exists($original_file_osencoded)) {
+ $langs->load("website");
+ print $langs->trans("RequestedPageHasNoContentYet", $pageid);
+ //dol_print_error(0,$langs->trans("ErrorFileDoesNotExists",$original_file));
+ exit;
+}
+
+
+// Output page content
+define('USEDOLIBARRSERVER', 1);
+print '/* Page content '.$original_file.' : JS content that was saved into tpl dir */'."\n";
+require_once $original_file_osencoded;
+
+
+if (is_object($db)) {
+ $db->close();
+}
diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php
index 5c58c71f8e1..d4bdb30121b 100644
--- a/htdocs/reception/card.php
+++ b/htdocs/reception/card.php
@@ -143,13 +143,14 @@ if ($user->socid) {
$socid = $user->socid;
}
+// TODO Test on reception module on only
if (isModEnabled("reception") || $origin == 'reception' || empty($origin)) {
- $result = restrictedArea($user, 'reception', $id);
+ $result = restrictedArea($user, 'reception', $object->id);
} else {
// We do not use the reception module, so we test permission on the supplier orders
if ($origin == 'supplierorder' || $origin == 'order_supplier') {
$result = restrictedArea($user, 'fournisseur', $origin_id, 'commande_fournisseur', 'commande');
- } elseif (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) {
+ } elseif (!$user->hasRight($origin, 'lire') && !$user->hasRight($origin, 'read')) {
accessforbidden();
}
}
@@ -1037,14 +1038,16 @@ if ($action == 'create') {
print '';
diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php
index 4df7f795a0c..95180890233 100644
--- a/htdocs/reception/list.php
+++ b/htdocs/reception/list.php
@@ -129,7 +129,7 @@ $arrayfields = array(
'e.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
'e.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
'e.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
- 'e.billed'=>array('label'=>$langs->trans("Billed"), 'checked'=>1, 'position'=>1000, 'enabled'=>(!empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)))
+ 'e.billed'=>array('label'=>$langs->trans("Billed"), 'checked'=>1, 'position'=>1000, 'enabled'=>'getDolGlobalConst("WORKFLOW_BILL_ON_RECEPTION") !== "0"')
);
// Extra fields
@@ -554,6 +554,7 @@ if (empty($reshook)) {
}
$id = $objecttmp->id; // For builddoc action
+ $lastref = $objecttmp->ref; // generated ref
$object =$objecttmp;
// Fac builddoc
diff --git a/htdocs/reception/note.php b/htdocs/reception/note.php
index b227a3e4a43..bbcd91e32a2 100644
--- a/htdocs/reception/note.php
+++ b/htdocs/reception/note.php
@@ -83,22 +83,18 @@ if (isModEnabled("reception")) {
}
$permissionnote = $user->rights->reception->creer; // Used by the include of actions_setnotes.inc.php
+// TODO Test on reception module on only
if ($origin == 'reception') {
$result = restrictedArea($user, $origin, $object->id);
} else {
- if ($origin == 'reception') {
- $result = restrictedArea($user, $origin, $object->id);
- } else {
- if ($origin == 'supplierorder' || $origin == 'order_supplier') {
- $result = restrictedArea($user, 'fournisseur', $object, 'commande_fournisseur', 'commande');
- } elseif (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) {
- accessforbidden();
- }
+ if ($origin == 'supplierorder' || $origin == 'order_supplier') {
+ $result = restrictedArea($user, 'fournisseur', $object, 'commande_fournisseur', 'commande');
+ } elseif (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) {
+ accessforbidden();
}
}
-
/*
* Actions
*/
diff --git a/htdocs/recruitment/class/recruitmentcandidature.class.php b/htdocs/recruitment/class/recruitmentcandidature.class.php
index 858e58f3b3a..891a7fd3075 100644
--- a/htdocs/recruitment/class/recruitmentcandidature.class.php
+++ b/htdocs/recruitment/class/recruitmentcandidature.class.php
@@ -366,8 +366,6 @@ class RecruitmentCandidature extends CommonObject
*/
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
{
- global $conf;
-
dol_syslog(__METHOD__, LOG_DEBUG);
$records = array();
@@ -732,7 +730,7 @@ class RecruitmentCandidature extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
diff --git a/htdocs/recruitment/class/recruitmentjobposition.class.php b/htdocs/recruitment/class/recruitmentjobposition.class.php
index a934834665f..450c6f45896 100644
--- a/htdocs/recruitment/class/recruitmentjobposition.class.php
+++ b/htdocs/recruitment/class/recruitmentjobposition.class.php
@@ -807,7 +807,7 @@ class RecruitmentJobPosition extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
diff --git a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php
index 16eb4b2cb5e..9fa3f689b8b 100644
--- a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php
+++ b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php
@@ -91,6 +91,20 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
*/
public $situationinvoice;
+ /**
+ * @var int tabTitleHeight
+ */
+ public $tabTitleHeight;
+
+ /**
+ * @var array defaultContentsFieldsStyle
+ */
+ public $defaultContentsFieldsStyle = array();
+
+ /**
+ * @var array defaultTitlesFieldsStyle
+ */
+ public $defaultTitlesFieldsStyle = array();
/**
* @var array of document table columns
@@ -150,11 +164,11 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
// Use new system for position of columns, view $this->defineColumnField()
- $this->tva = array();
- $this->localtax1 = array();
- $this->localtax2 = array();
- $this->atleastoneratenotnull = 0;
- $this->atleastonediscount = 0;
+ // $this->tva = array();
+ // $this->localtax1 = array();
+ // $this->localtax2 = array();
+ // $this->atleastoneratenotnull = 0;
+ // $this->atleastonediscount = 0;
$this->situationinvoice = false;
}
@@ -206,7 +220,7 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
// Loop on each lines to detect if there is at least one image to show
$realpatharray = array();
- $this->atleastonephoto = false;
+ // $this->atleastonephoto = false;
/*
if (!empty($conf->global->MAIN_GENERATE_MYOBJECT_WITH_PICTURE))
{
diff --git a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php
index 415ac3357eb..7f7056a9db4 100644
--- a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php
+++ b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php
@@ -54,11 +54,12 @@ class mod_recruitmentcandidature_advanced extends ModeleNumRefRecruitmentCandida
/**
* Returns the description of the numbering model
*
+ * @param Translate $langs Language
* @return string Descriptive text
*/
- public function info()
+ public function info($langs)
{
- global $conf, $langs, $db;
+ global $conf, $db;
$langs->load("bills");
diff --git a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_standard.php b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_standard.php
index 4221915eb29..68e4e9dfc51 100644
--- a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_standard.php
+++ b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_standard.php
@@ -52,11 +52,11 @@ class mod_recruitmentcandidature_standard extends ModeleNumRefRecruitmentCandida
/**
* Return description of numbering module
*
+ * @param Translate $langs Language
* @return string Text with description
*/
- public function info()
+ public function info($langs)
{
- global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
diff --git a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php
index be565486c3a..7d0eea8b7cb 100644
--- a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php
+++ b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php
@@ -54,11 +54,12 @@ class mod_recruitmentjobposition_advanced extends ModeleNumRefRecruitmentJobPosi
/**
* Returns the description of the numbering model
*
+ * @param Translate $langs Language
* @return string Descriptive text
*/
- public function info()
+ public function info($langs)
{
- global $conf, $langs, $db;
+ global $conf, $db;
$langs->load("bills");
diff --git a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_standard.php b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_standard.php
index 260ee510c5b..99f49d69f62 100644
--- a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_standard.php
+++ b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_standard.php
@@ -52,11 +52,11 @@ class mod_recruitmentjobposition_standard extends ModeleNumRefRecruitmentJobPosi
/**
* Return description of numbering module
*
+ * @param Translate $langs Language
* @return string Text with description
*/
- public function info()
+ public function info($langs)
{
- global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
diff --git a/htdocs/recruitment/core/modules/recruitment/modules_recruitmentcandidature.php b/htdocs/recruitment/core/modules/recruitment/modules_recruitmentcandidature.php
index 3bd754881a2..6dbb2e50d25 100644
--- a/htdocs/recruitment/core/modules/recruitment/modules_recruitmentcandidature.php
+++ b/htdocs/recruitment/core/modules/recruitment/modules_recruitmentcandidature.php
@@ -65,7 +65,7 @@ abstract class ModelePDFRecruitmentCandidature extends CommonDocGenerator
/**
* Parent class to manage numbering of RecruitmentCandidature
*/
-abstract class ModeleNumRefRecruitmentCandidature
+abstract class ModeleNumRefRecruitmentCandidature extends CommonNumRefGenerator
{
// No overloaded code
}
diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php
index 8045b2857cb..e60f6a7a352 100644
--- a/htdocs/resource/class/dolresource.class.php
+++ b/htdocs/resource/class/dolresource.class.php
@@ -71,12 +71,19 @@ class Dolresource extends CommonObject
public $element_type;
public $busy;
public $mandatory;
+ public $fulldayevent;
+
/**
* @var int ID
*/
public $fk_user_create;
public $tms = '';
+ /**
+ * Used by fetch_element_resource() to return an object
+ */
+ public $objelement;
+
/**
* @var array Cache of type of resources. TODO Use $conf->cache['type_of_resources'] instead
*/
@@ -361,7 +368,7 @@ class Dolresource extends CommonObject
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
- * Load data of link in memory from database
+ * Load data of resource links in memory from database
*
* @param int $id Id of link element_resources
* @return int <0 if KO, >0 if OK
@@ -369,7 +376,6 @@ class Dolresource extends CommonObject
public function fetch_element_resource($id)
{
// phpcs:enable
- global $langs;
$sql = "SELECT";
$sql .= " t.rowid,";
$sql .= " t.resource_id,";
@@ -398,9 +404,9 @@ class Dolresource extends CommonObject
$this->mandatory = $obj->mandatory;
$this->fk_user_create = $obj->fk_user_create;
- if ($obj->resource_id && $obj->resource_type) {
+ /*if ($obj->resource_id && $obj->resource_type) {
$this->objresource = fetchObjectByElement($obj->resource_id, $obj->resource_type);
- }
+ }*/
if ($obj->element_id && $obj->element_type) {
$this->objelement = fetchObjectByElement($obj->element_id, $obj->element_type);
}
@@ -494,18 +500,16 @@ class Dolresource extends CommonObject
/**
* Load resource objects into $this->lines
*
- * @param string $sortorder sort order
- * @param string $sortfield sort field
- * @param int $limit limit page
- * @param int $offset page
- * @param array $filter filter output
- * @return int <0 if KO, >0 if OK
+ * @param string $sortorder sort order
+ * @param string $sortfield sort field
+ * @param int $limit limit page
+ * @param int $offset page
+ * @param array $filter filter output
+ * @return int <0 if KO, Number of lines loaded if OK
*/
public function fetchAll($sortorder, $sortfield, $limit, $offset, $filter = '')
{
// phpcs:enable
- global $conf;
-
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db);
@@ -541,14 +545,10 @@ class Dolresource extends CommonObject
}
}
$sql .= $this->db->order($sortfield, $sortorder);
- $this->num_all = 0;
- if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
- $result = $this->db->query($sql);
- $this->num_all = $this->db->num_rows($result);
- }
if ($limit) {
$sql .= $this->db->plimit($limit, $offset);
}
+
dol_syslog(get_class($this)."::fetchAll", LOG_DEBUG);
$this->lines = array();
@@ -773,7 +773,7 @@ class Dolresource extends CommonObject
*/
public function getTooltipContentArray($params)
{
- global $conf, $langs;
+ global $langs;
$langs->load('resource');
@@ -782,8 +782,8 @@ class Dolresource extends CommonObject
$datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Resource").' ';
$datas['ref'] = ''.$langs->trans('Ref').': '.$this->ref;
/*if (isset($this->status)) {
- $datas['status'] = '' . $langs->trans("Status").": ".$this->getLibStatut(5);
- }*/
+ $datas['status'] = '' . $langs->trans("Status").": ".$this->getLibStatut(5);
+ }*/
if (isset($this->type_label)) {
$datas['label'] = ''.$langs->trans("ResourceType").": ".$this->type_label;
}
@@ -826,7 +826,7 @@ class Dolresource extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
@@ -850,11 +850,11 @@ class Dolresource extends CommonObject
$linkstart .= $linkclose.'>';
$linkend = '';
/*$linkstart = '';
- $linkend = ' ';*/
+ $linkend = '';*/
$result .= $linkstart;
if ($withpicto) {
- $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
+ $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
}
if ($withpicto != 2) {
$result .= $this->ref;
@@ -896,8 +896,6 @@ class Dolresource extends CommonObject
public static function LibStatut($status, $mode = 0)
{
// phpcs:enable
- global $langs;
-
return '';
}
@@ -910,8 +908,6 @@ class Dolresource extends CommonObject
public function load_state_board()
{
// phpcs:enable
- global $conf;
-
$this->nb = array();
$sql = "SELECT count(r.rowid) as nb";
diff --git a/htdocs/salaries/class/paymentsalary.class.php b/htdocs/salaries/class/paymentsalary.class.php
index 79adb9bff9b..fb9be8f3432 100644
--- a/htdocs/salaries/class/paymentsalary.class.php
+++ b/htdocs/salaries/class/paymentsalary.class.php
@@ -87,6 +87,11 @@ class PaymentSalary extends CommonObject
*/
public $fk_bank;
+ /**
+ * @var int ID of bank_line
+ */
+ public $bank_line;
+
/**
* @var int ID
*/
@@ -764,7 +769,7 @@ class PaymentSalary extends CommonObject
if ($option !== 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($url && $add_save_lastsearch_values) {
diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php
index 5a114def6f1..078620a09d2 100644
--- a/htdocs/salaries/class/salary.class.php
+++ b/htdocs/salaries/class/salary.class.php
@@ -526,7 +526,7 @@ class Salary extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
@@ -552,7 +552,7 @@ class Salary extends CommonObject
$result .= $linkstart;
if ($withpicto) {
- $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright pictofixedwidth"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.' pictofixedwidth"'), 0, 0, $notooltip ? 0 : 1);
+ $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1);
}
if ($withpicto != 2) {
$result .= $this->ref;
diff --git a/htdocs/salaries/document.php b/htdocs/salaries/document.php
index c90069ef8bf..f5be79b373d 100644
--- a/htdocs/salaries/document.php
+++ b/htdocs/salaries/document.php
@@ -92,6 +92,7 @@ if ($id > 0 || !empty($ref)) {
if (!empty($user->rights->salaries->read) && $object->fk_user > 0 && in_array($object->fk_user, $childids)) {
$canread = 1;
}
+
if (!$canread) {
accessforbidden();
}
diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php
index 76cc8a60831..16102685e3e 100644
--- a/htdocs/societe/admin/societe.php
+++ b/htdocs/societe/admin/societe.php
@@ -676,6 +676,12 @@ $profid['IDPROF6'][0] = $langs->trans("ProfId6");
$profid['IDPROF6'][1] = $langs->transcountry('ProfId6', $mysoc->country_code);
$profid['EMAIL'][0] = $langs->trans("EMail");
$profid['EMAIL'][1] = $langs->trans('Email');
+if (isModEnabled('accounting')) {
+ $profid['ACCOUNTANCY_CODE_CUSTOMER'][0] = $langs->trans("CustomerAccountancyCodeShort");
+ $profid['ACCOUNTANCY_CODE_CUSTOMER'][1] = $langs->trans('CustomerAccountancyCodeShort');
+ $profid['ACCOUNTANCY_CODE_SUPPLIER'][0] = $langs->trans("SupplierAccountancyCodeShort");
+ $profid['ACCOUNTANCY_CODE_SUPPLIER'][1] = $langs->trans('SupplierAccountancyCodeShort');
+}
$nbofloop = count($profid);
foreach ($profid as $key => $val) {
@@ -728,23 +734,6 @@ foreach ($profid as $key => $val) {
$i++;
}
-if (isModEnabled('accounting')) {
- print '';
- print ''.$langs->trans('CustomerAccountancyCodeShort')." \n";
- print ' ';
-
- if (!empty($conf->global->SOCIETE_ACCOUNTANCY_CODE_CUSTOMER_INVOICE_MANDATORY)) {
- print '';
- print img_picto($langs->trans("Activated"), 'switch_on');
- print ' ';
- } else {
- print '';
- print img_picto($langs->trans("Disabled"), 'switch_off');
- print ' ';
- }
- print " \n";
-}
-
// VAT ID
print '';
print ''.$langs->trans('VATIntra')." \n";
diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php
index e2887ebf284..7c790c11bf3 100644
--- a/htdocs/societe/agenda.php
+++ b/htdocs/societe/agenda.php
@@ -168,7 +168,7 @@ if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) {
$out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : '').'&backtopage='.urlencode($_SERVER['PHP_SELF'].($objthirdparty->id > 0 ? '?socid='.$objthirdparty->id : ''));
}
$out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '');
- $out .= '&datep='.dol_print_date(dol_now(), 'dayhourlog');
+ $out .= '&datep='.dol_print_date(dol_now(), 'dayhourlog', 'tzuserrel');
}
$morehtmlright = '';
diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php
index 638a045f1e4..d6b9b3f62b5 100644
--- a/htdocs/societe/canvas/actions_card_common.class.php
+++ b/htdocs/societe/canvas/actions_card_common.class.php
@@ -39,6 +39,7 @@ abstract class ActionsCardCommon
//! Template container
public $tpl = array();
+
//! Object container
public $object;
@@ -47,7 +48,6 @@ abstract class ActionsCardCommon
*/
public $error = '';
-
/**
* @var string[] Error codes (or messages)
*/
@@ -249,7 +249,7 @@ abstract class ActionsCardCommon
// Language
if (getDolGlobalInt('MAIN_MULTILANGS')) {
- $this->tpl['select_lang'] = $formadmin->select_language(($this->object->default_lang ? $this->object->default_lang : $conf->global->MAIN_LANG_DEFAULT), 'default_lang', 0, 0, 1);
+ $this->tpl['select_lang'] = $formadmin->select_language((empty($this->object->default_lang) ? getDolGlobalString('MAIN_LANG_DEFAULT') : $this->object->default_lang), 'default_lang', 0, 0, 1);
}
// VAT
@@ -313,7 +313,7 @@ abstract class ActionsCardCommon
//$s=picto_from_langcode($this->default_lang);
//print ($s?$s.' ':'');
$langs->load("languages");
- $this->tpl['default_lang'] = ($this->default_lang ? $langs->trans('Language_'.$this->object->default_lang) : '');
+ $this->tpl['default_lang'] = (empty($this->object->default_lang) ? '' : $langs->trans('Language_'.$this->object->default_lang));
}
$this->tpl['image_edit'] = img_edit();
diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php
index e10571512c6..42d7e37a8aa 100644
--- a/htdocs/societe/class/api_thirdparties.class.php
+++ b/htdocs/societe/class/api_thirdparties.class.php
@@ -375,7 +375,7 @@ class Thirdparties extends DolibarrApi
$object->client = $object->client | $soc_origin->client;
$object->fournisseur = $object->fournisseur | $soc_origin->fournisseur;
$listofproperties = array(
- 'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'url', 'barcode',
+ 'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'url', 'barcode',
'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6',
'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'remise_supplier_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis',
'stcomm_id', 'outstanding_limit', 'price_level', 'parent', 'default_lang', 'ref', 'ref_ext', 'import_key', 'fk_incoterms', 'fk_multicurrency',
diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php
index b4893704243..732a39a17e4 100644
--- a/htdocs/societe/class/companybankaccount.class.php
+++ b/htdocs/societe/class/companybankaccount.class.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2010-2013 Laurent Destailleur
+ * Copyright (C) 2010-2023 Laurent Destailleur
* Copyright (C) 2012 Regis Houssin
* Copyright (C) 2013 Peter Fontaine
* Copyright (C) 2016 Marcos García
@@ -33,33 +33,115 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
*/
class CompanyBankAccount extends Account
{
- public $socid;
-
/**
- * @var string ID to identify managed object
+ * @var string ID to identify managed object.
*/
public $element = 'societe_rib';
/**
- * @var string Name of table without prefix where object is stored
+ * @var string Name of table without prefix where object is stored. This is also the key used for extrafields management.
*/
public $table_element = 'societe_rib';
- /** @var bool $default_rib 1 = this object is the third party's default bank information */
- public $default_rib;
-
/**
- * Value 'FRST' or 'RCUR' (For SEPA mandate)
+ * 'type' field format:
+ * 'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',
+ * 'select' (list of values are in 'options'),
+ * 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter[:Sortfield]]]]',
+ * 'chkbxlst:...',
+ * 'varchar(x)',
+ * 'text', 'text:none', 'html',
+ * 'double(24,8)', 'real', 'price',
+ * 'date', 'datetime', 'timestamp', 'duration',
+ * 'boolean', 'checkbox', 'radio', 'array',
+ * 'mail', 'phone', 'url', 'password', 'ip'
+ * Note: Filter must be a Dolibarr Universal Filter syntax string. Example: "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.status:!=:0) or (t.nature:is:NULL)"
+ * 'label' the translation key.
+ * 'picto' is code of a picto to show before value in forms
+ * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM' or 'isModEnabled("multicurrency")' ...)
+ * 'position' is the sort order of field.
+ * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
+ * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
+ * 'noteditable' says if field is not editable (1 or 0)
+ * 'alwayseditable' says if field can be modified also when status is not draft ('1' or '0')
+ * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created.
+ * 'index' if we want an index in database.
+ * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
+ * 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
+ * 'isameasure' must be set to 1 or 2 if field can be used for measure. Field type must be summable like integer or double(24,8). Use 1 in most cases, or 2 if you don't want to see the column total into list (for example for percentage)
+ * 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'cssview'=>'wordbreak', 'csslist'=>'tdoverflowmax200'
+ * 'help' and 'helplist' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click.
+ * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
+ * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code.
+ * 'arrayofkeyval' to set a list of values if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel"). Note that type can be 'integer' or 'varchar'
+ * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1.
+ * 'comment' is not used. You can store here any text of your choice. It is not used by application.
+ * 'validate' is 1 if need to validate with $this->validateField()
+ * 'copytoclipboard' is 1 or 2 to allow to add a picto to copy value into clipboard (1=picto after label, 2=picto after value)
*
- * @var string
+ * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor.
*/
- public $frstrecur;
- public $rum;
- public $date_rum;
-
- public $stripe_card_ref; // ID of BAN into an external payment system
- public $stripe_account; // Account of the external payment system
+ // BEGIN MODULEBUILDER PROPERTIES
+ /**
+ * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
+ */
+ public $fields=array(
+ 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>-1,),
+ 'type' => array('type'=>'varchar(32)', 'label'=>'Type', 'enabled'=>'1', 'position'=>15, 'notnull'=>1, 'visible'=>-1,),
+ 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'picto'=>'company', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>-1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'csslist'=>'tdoverflowmax150',),
+ 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>25, 'notnull'=>0, 'visible'=>-1,),
+ 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>-1,),
+ 'label' => array('type'=>'varchar(200)', 'label'=>'Label', 'enabled'=>'1', 'position'=>35, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1', 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'csslist'=>'tdoverflowmax150',),
+ 'bank' => array('type'=>'varchar(255)', 'label'=>'Bank', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'code_banque' => array('type'=>'varchar(128)', 'label'=>'Codebanque', 'enabled'=>'1', 'position'=>45, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'code_guichet' => array('type'=>'varchar(6)', 'label'=>'Codeguichet', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'number' => array('type'=>'varchar(255)', 'label'=>'Number', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'cle_rib' => array('type'=>'varchar(5)', 'label'=>'Clerib', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'bic' => array('type'=>'varchar(20)', 'label'=>'Bic', 'enabled'=>'1', 'position'=>65, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'iban_prefix' => array('type'=>'varchar(34)', 'label'=>'Ibanprefix', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'domiciliation' => array('type'=>'varchar(255)', 'label'=>'Domiciliation', 'enabled'=>'1', 'position'=>75, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'proprio' => array('type'=>'varchar(60)', 'label'=>'Proprio', 'enabled'=>'1', 'position'=>80, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'owner_address' => array('type'=>'varchar(255)', 'label'=>'Owneraddress', 'enabled'=>'1', 'position'=>85, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'default_rib' => array('type'=>'smallint(6)', 'label'=>'Defaultrib', 'enabled'=>'1', 'position'=>90, 'notnull'=>1, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'state_id' => array('type'=>'integer', 'label'=>'Stateid', 'enabled'=>'1', 'position'=>95, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'fk_country' => array('type'=>'integer', 'label'=>'Fkcountry', 'enabled'=>'1', 'position'=>100, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1', 'css'=>'maxwidth500 widthcentpercentminusxx',),
+ 'currency_code' => array('type'=>'varchar(3)', 'label'=>'Currencycode', 'enabled'=>'1', 'position'=>105, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'rum' => array('type'=>'varchar(32)', 'label'=>'Rum', 'enabled'=>'1', 'position'=>110, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'date_rum' => array('type'=>'date', 'label'=>'Daterum', 'enabled'=>'1', 'position'=>115, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'frstrecur' => array('type'=>'varchar(16)', 'label'=>'Frstrecur', 'enabled'=>'1', 'position'=>120, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>900, 'notnull'=>0, 'visible'=>-2, 'alwayseditable'=>'1',),
+ 'last_four' => array('type'=>'varchar(4)', 'label'=>'Lastfour', 'enabled'=>'1', 'position'=>130, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'card_type' => array('type'=>'varchar(255)', 'label'=>'Cardtype', 'enabled'=>'1', 'position'=>135, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'cvn' => array('type'=>'varchar(255)', 'label'=>'Cvn', 'enabled'=>'1', 'position'=>140, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'exp_date_month' => array('type'=>'integer', 'label'=>'Expdatemonth', 'enabled'=>'1', 'position'=>145, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'exp_date_year' => array('type'=>'integer', 'label'=>'Expdateyear', 'enabled'=>'1', 'position'=>150, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'country_code' => array('type'=>'varchar(10)', 'label'=>'Countrycode', 'enabled'=>'1', 'position'=>155, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'approved' => array('type'=>'integer', 'label'=>'Approved', 'enabled'=>'1', 'position'=>160, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'email' => array('type'=>'varchar(255)', 'label'=>'Email', 'enabled'=>'1', 'position'=>165, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'ending_date' => array('type'=>'date', 'label'=>'Endingdate', 'enabled'=>'1', 'position'=>170, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'max_total_amount_of_all_payments' => array('type'=>'double(24,8)', 'label'=>'Maxtotalamountofallpayments', 'enabled'=>'1', 'position'=>175, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'preapproval_key' => array('type'=>'varchar(255)', 'label'=>'Preapprovalkey', 'enabled'=>'1', 'position'=>180, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'starting_date' => array('type'=>'date', 'label'=>'Startingdate', 'enabled'=>'1', 'position'=>185, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'total_amount_of_all_payments' => array('type'=>'double(24,8)', 'label'=>'Totalamountofallpayments', 'enabled'=>'1', 'position'=>190, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'stripe_card_ref' => array('type'=>'varchar(128)', 'label'=>'Stripecardref', 'enabled'=>'1', 'position'=>195, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'comment' => array('type'=>'varchar(255)', 'label'=>'Comment', 'enabled'=>'1', 'position'=>205, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'ipaddress' => array('type'=>'varchar(68)', 'label'=>'Ipaddress', 'enabled'=>'1', 'position'=>210, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'stripe_account' => array('type'=>'varchar(128)', 'label'=>'Stripeaccount', 'enabled'=>'1', 'position'=>215, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'last_main_doc' =>array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>1, 'visible'=>0, 'position'=>230),
+ );
+ public $id;
+ public $type;
+ /**
+ * @var int Thirdparty ID
+ * @deprecated Use socid
+ */
+ public $fk_soc;
+ /**
+ * @var int Thirdparty ID
+ */
+ public $socid;
/**
* Date creation record (datec)
@@ -67,6 +149,68 @@ class CompanyBankAccount extends Account
* @var integer
*/
public $datec;
+ public $label;
+ public $bank;
+ public $code_banque;
+ public $code_guichet;
+ public $number;
+ public $cle_rib;
+ public $bic;
+ public $iban_prefix;
+ public $domiciliation;
+ public $proprio;
+ public $owner_address;
+
+ /**
+ * @var bool $default_rib 1 = this object is the third party's default bank information
+ */
+ public $default_rib;
+ public $state_id;
+ public $fk_country;
+ public $currency_code;
+ public $rum;
+ public $date_rum;
+
+ /**
+ * Value 'FRST' or 'RCUR' (For SEPA mandate)
+ *
+ * @var string
+ */
+ public $frstrecur;
+ public $import_key;
+ public $last_four;
+ public $card_type;
+ public $cvn;
+ public $exp_date_month;
+ public $exp_date_year;
+ public $country_code;
+ public $approved;
+ public $email;
+ public $ending_date;
+ public $max_total_amount_of_all_payments;
+ public $preapproval_key;
+ public $starting_date;
+ public $total_amount_of_all_payments;
+
+
+ public $ext_payment_site; // Name of the external payment system ('StripeLive', 'StripeTest', 'StancerLive', 'StancerTest', ...)
+ public $comment;
+ public $ipaddress;
+
+
+ /**
+ * Account of the external payment system
+ *
+ * @var string
+ */
+ public $stripe_account;
+
+ /**
+ * ID of BAN into an external payment system
+ *
+ * @var string
+ */
+ public $stripe_card_ref;
/**
* Date modification record (tms)
@@ -75,6 +219,12 @@ class CompanyBankAccount extends Account
*/
public $datem;
+ /**
+ * @var string
+ * @see SetDocModel()
+ */
+ public $model_pdf;
+
/**
* @var string TRIGGER_PREFIX Dolibarr 16.0 and above use the prefix to prevent the creation of inconsistently
* named triggers
@@ -82,7 +232,6 @@ class CompanyBankAccount extends Account
*/
const TRIGGER_PREFIX = 'COMPANY_RIB';
-
/**
* Constructor
*
@@ -96,6 +245,7 @@ class CompanyBankAccount extends Account
$this->solde = 0;
$this->balance = 0;
$this->default_rib = 0;
+ $this->type = "ban";
}
@@ -119,6 +269,10 @@ class CompanyBankAccount extends Account
return -1;
}
+ if (empty($this->datec)) {
+ $this->datec=$now;
+ }
+
// Correct ->default_rib to not set the new account as default, if there is already 1. We want to be sure to have always 1 default for type = 'ban'.
// If we really want the new bank account to be the default, we must set it by calling setDefault() after creation.
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".((int) $this->socid)." AND default_rib = 1 AND type = 'ban'";
@@ -136,8 +290,10 @@ class CompanyBankAccount extends Account
$this->db->begin();
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, type, datec)";
- $sql .= " VALUES (".((int) $this->socid).", 'ban', '".$this->db->idate($now)."')";
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, type, datec, model_pdf)";
+ $sql .= " VALUES (".((int) $this->socid).", '".$this->type."', '".$this->db->idate($this->datec)."',";
+ $sql .= " '".$this->db->escape(getDolGlobalString("BANKADDON_PDF"))."'";
+ $sql .= ")";
$resql = $this->db->query($sql);
if ($resql) {
if ($this->db->affected_rows($resql)) {
@@ -191,6 +347,10 @@ class CompanyBankAccount extends Account
$this->owner_address = dol_trunc($this->owner_address, 254, 'right', 'UTF-8', 1);
}
+ if (isset($this->model_pdf)) {
+ $this->model_pdf = trim($this->model_pdf);
+ }
+
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET";
@@ -217,6 +377,7 @@ class CompanyBankAccount extends Account
}
$sql .= ",stripe_card_ref = '".$this->db->escape($this->stripe_card_ref)."'";
$sql .= ",stripe_account = '".$this->db->escape($this->stripe_account)."'";
+ $sql .= ",model_pdf=".(isset($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null");
$sql .= " WHERE rowid = ".((int) $this->id);
$result = $this->db->query($sql);
@@ -263,9 +424,12 @@ class CompanyBankAccount extends Account
return -1;
}
- $sql = "SELECT rowid, type, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
+ $sql = "SELECT rowid, type, fk_soc as socid, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
$sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur, date_rum,";
- $sql .= " stripe_card_ref, stripe_account";
+ $sql .= " stripe_card_ref, stripe_account, ext_payment_site";
+ $sql .= " ,last_main_doc";
+ $sql .= " ,model_pdf";
+
$sql .= " FROM ".MAIN_DB_PREFIX."societe_rib";
if ($id) {
$sql .= " WHERE rowid = ".((int) $id);
@@ -284,11 +448,11 @@ class CompanyBankAccount extends Account
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
- $this->ref = $obj->fk_soc.'-'.$obj->label; // Generate an artificial ref
+ $this->ref = $obj->socid.'-'.$obj->label; // Generate an artificial ref
$this->id = $obj->rowid;
$this->type = $obj->type;
- $this->socid = $obj->fk_soc;
+ $this->socid = $obj->socid;
$this->bank = $obj->bank;
$this->code_banque = $obj->code_banque;
$this->code_guichet = $obj->code_guichet;
@@ -306,8 +470,11 @@ class CompanyBankAccount extends Account
$this->rum = $obj->rum;
$this->frstrecur = $obj->frstrecur;
$this->date_rum = $this->db->jdate($obj->date_rum);
- $this->stripe_card_ref = $obj->stripe_card_ref;
- $this->stripe_account = $obj->stripe_account;
+ $this->stripe_card_ref = $obj->stripe_card_ref; // External system payment mode ID
+ $this->stripe_account = $obj->stripe_account; // External system customer ID
+ $this->ext_payment_site= $obj->ext_payment_site; // External system name ('StripeLive', 'StripeTest', 'StancerLive', 'StancerTest', ...)
+ $this->last_main_doc = $obj->last_main_doc;
+ $this->model_pdf = $obj->model_pdf;
}
$this->db->free($resql);
@@ -391,7 +558,7 @@ class CompanyBankAccount extends Account
*/
public function setAsDefault($rib = 0, $resetolddefaultfor = 'ban')
{
- $sql1 = "SELECT rowid as id, fk_soc FROM ".MAIN_DB_PREFIX."societe_rib";
+ $sql1 = "SELECT rowid as id, fk_soc as socid FROM ".MAIN_DB_PREFIX."societe_rib";
$sql1 .= " WHERE rowid = ".($rib ? $rib : $this->id);
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
@@ -405,7 +572,7 @@ class CompanyBankAccount extends Account
$this->db->begin();
$sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0";
- $sql2 .= " WHERE fk_soc = ".((int) $obj->fk_soc);
+ $sql2 .= " WHERE fk_soc = ".((int) $obj->socid);
if ($resetolddefaultfor) {
$sql2 .= " AND type = '".$this->db->escape($resetolddefaultfor)."'";
}
diff --git a/htdocs/societe/class/companypaymentmode.class.php b/htdocs/societe/class/companypaymentmode.class.php
index 6af7f359ec1..6fc7f6d4e2e 100644
--- a/htdocs/societe/class/companypaymentmode.class.php
+++ b/htdocs/societe/class/companypaymentmode.class.php
@@ -114,8 +114,9 @@ class CompanyPaymentMode extends CommonObject
'max_total_amount_of_all_payments' =>array('type'=>'double(24,8)', 'label'=>'Max total amount of all payments', 'enabled'=>1, 'visible'=>-2, 'position'=>155),
'preapproval_key' =>array('type'=>'varchar(255)', 'label'=>'Preapproval key', 'enabled'=>1, 'visible'=>-2, 'position'=>160),
'total_amount_of_all_payments' =>array('type'=>'double(24,8)', 'label'=>'Total amount of all payments', 'enabled'=>1, 'visible'=>-2, 'position'=>165),
- 'stripe_card_ref' =>array('type'=>'varchar(128)', 'label'=>'Stripe card ref', 'enabled'=>1, 'visible'=>-2, 'position'=>170),
- 'stripe_account' =>array('type'=>'varchar(128)', 'label'=>'Stripe account', 'enabled'=>1, 'visible'=>-2, 'position'=>171),
+ 'stripe_card_ref' =>array('type'=>'varchar(128)', 'label'=>'ExternalSystemID', 'enabled'=>1, 'visible'=>-2, 'position'=>170, 'help'=>'IDOfPaymentInAnExternalSystem'),
+ 'stripe_account' =>array('type'=>'varchar(128)', 'label'=>'ExternalSystemCustomerAccount', 'enabled'=>1, 'visible'=>-2, 'position'=>171, 'help'=>'IDOfCustomerInAnExternalSystem'),
+ 'ext_payment_site' =>array('type'=>'varchar(128)', 'label'=>'ExternalSystem', 'enabled'=>1, 'visible'=>-2, 'position'=>172, 'help'=>'NameOfExternalSystem'),
'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>175),
'starting_date' =>array('type'=>'date', 'label'=>'Starting date', 'enabled'=>1, 'visible'=>-2, 'position'=>180),
'ending_date' =>array('type'=>'date', 'label'=>'Ending date', 'enabled'=>1, 'visible'=>-2, 'position'=>185),
@@ -178,8 +179,9 @@ class CompanyPaymentMode extends CommonObject
public $max_total_amount_of_all_payments;
public $preapproval_key;
public $total_amount_of_all_payments;
- public $stripe_card_ref;
- public $stripe_account;
+ public $stripe_card_ref; // External system payment mode ID
+ public $stripe_account; // External system customer ID
+ public $ext_payment_site; // External system 'StripeLive', 'StripeTest', 'StancerLive', 'StancerTest', ...
/**
* @var int Status
@@ -388,7 +390,7 @@ class CompanyPaymentMode extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index 97d528e4b1c..d1b87656588 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -1193,9 +1193,11 @@ class Societe extends CommonObject
}
// Check for duplicate or mandatory fields defined into setup
- $array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL', 'TVA_INTRA');
+ $array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL', 'TVA_INTRA', 'ACCOUNTANCY_CODE_CUSTOMER', 'ACCOUNTANCY_CODE_SUPPLIER');
foreach ($array_to_check as $key) {
$keymin = strtolower($key);
+ if ($key == 'ACCOUNTANCY_CODE_CUSTOMER') $keymin = 'code_compta';
+ elseif ($key == 'ACCOUNTANCY_CODE_SUPPLIER') $keymin = 'code_compta_fournisseur';
$i = (int) preg_replace('/[^0-9]/', '', $key);
$vallabel = $this->$keymin;
@@ -1246,6 +1248,38 @@ class Societe extends CommonObject
$error++; $this->errors[] = $langs->trans('VATIntra')." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel).' ('.$langs->trans("ForbiddenBySetupRules").')';
}
}
+ } elseif ($key == 'ACCOUNTANCY_CODE_CUSTOMER' && !empty($this->client)) {
+ // Check for unicity
+ if ($vallabel && !empty($conf->global->SOCIETE_ACCOUNTANCY_CODE_CUSTOMER_UNIQUE)) {
+ if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0))) {
+ $langs->loadLangs(array("errors", 'compta'));
+ $error++;
+ $this->errors[] = $langs->trans('CustomerAccountancyCodeShort') . " " . $langs->trans("ErrorProdIdAlreadyExist", $vallabel) . ' (' . $langs->trans("ForbiddenBySetupRules") . ')';
+ }
+ }
+
+ // Check for mandatory
+ if (!empty($conf->global->SOCIETE_ACCOUNTANCY_CODE_CUSTOMER_MANDATORY) && (!isset($vallabel) || trim($vallabel) === '')) {
+ $langs->loadLangs(array("errors", 'compta'));
+ $error++;
+ $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv('CustomerAccountancyCodeShort')) . ' (' . $langs->trans("ForbiddenBySetupRules") . ')';
+ }
+ } elseif ($key == 'ACCOUNTANCY_CODE_SUPPLIER' && !empty($this->fournisseur)) {
+ // Check for unicity
+ if ($vallabel && !empty($conf->global->SOCIETE_ACCOUNTANCY_CODE_SUPPLIER_UNIQUE)) {
+ if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0))) {
+ $langs->loadLangs(array("errors", 'compta'));
+ $error++;
+ $this->errors[] = $langs->trans('SupplierAccountancyCodeShort') . " " . $langs->trans("ErrorProdIdAlreadyExist", $vallabel) . ' (' . $langs->trans("ForbiddenBySetupRules") . ')';
+ }
+ }
+
+ // Check for mandatory
+ if (!empty($conf->global->SOCIETE_ACCOUNTANCY_CODE_SUPPLIER_MANDATORY) && (!isset($vallabel) || trim($vallabel) === '')) {
+ $langs->loadLangs(array("errors", 'compta'));
+ $error++;
+ $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv('SupplierAccountancyCodeShort')) . ' (' . $langs->trans("ForbiddenBySetupRules") . ')';
+ }
}
}
}
@@ -2171,16 +2205,31 @@ class Societe extends CommonObject
* Define third party as a customer
*
* @return int <0 if KO, >0 if OK
+ * @deprecated
+ * @see setAsCustomer()
*/
public function set_as_client()
{
+ global $conf;
// phpcs:enable
+ dol_syslog(get_class($this)."::set_as_client is deprecated use setAsCustomer instead", LOG_NOTICE);
+ return $this->setAsCustomer();
+ }
+
+ /**
+ * Define third party as a customer
+ *
+ * @return int <0 if KO, >0 if OK
+ * @since dolibarr v19
+ */
+ public function setAsCustomer()
+ {
if ($this->id) {
$newclient = 1;
- if (($this->client == 2 || $this->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
+ if (($this->client == 2 || $this->client == 3) && !getDolGlobalInt('SOCIETE_DISABLE_PROSPECTSCUSTOMERS')) {
$newclient = 3; //If prospect, we keep prospect tag
}
- $sql = "UPDATE ".MAIN_DB_PREFIX."societe";
+ $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET client = ".((int) $newclient);
$sql .= " WHERE rowid = ".((int) $this->id);
@@ -2858,7 +2907,7 @@ class Societe extends CommonObject
$linkstart .= (!empty($this->canvas) ? '&canvas='.$this->canvas : '');
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
@@ -2997,7 +3046,7 @@ class Societe extends CommonObject
/**
* Return list of contacts emails existing for third party
*
- * @param int $addthirdparty 1=Add also a record for thirdparty email
+ * @param int $addthirdparty 1=Add also a record for thirdparty email, 2=Same than 1 but add text ThirdParty in grey
* @return array Array of contacts emails
*/
public function thirdparty_and_contact_email_array($addthirdparty = 0)
@@ -3010,7 +3059,7 @@ class Societe extends CommonObject
if (empty($this->name)) {
$this->name = $this->nom;
}
- $contact_emails['thirdparty'] = $langs->transnoentitiesnoconv("ThirdParty").': '.dol_trunc($this->name, 16)." <".$this->email.">";
+ $contact_emails['thirdparty'] = ($addthirdparty == 2 ? '' : '').$langs->transnoentitiesnoconv("ThirdParty").($addthirdparty == 2 ? ' ' : '').': '.dol_trunc($this->name, 16)." <".$this->email.">";
}
//var_dump($contact_emails)
return $contact_emails;
@@ -3517,18 +3566,18 @@ class Societe extends CommonObject
global $conf;
if (!empty($conf->global->SOCIETE_CODECOMPTA_ADDON)) {
+ $module=$conf->global->SOCIETE_CODECOMPTA_ADDON;
$res = false;
$dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
foreach ($dirsociete as $dirroot) {
- $res = dol_include_once($dirroot.$conf->global->SOCIETE_CODECOMPTA_ADDON.'.php');
+ $res = dol_include_once($dirroot.$module.'.php');
if ($res) {
break;
}
}
if ($res) {
- $classname = $conf->global->SOCIETE_CODECOMPTA_ADDON;
- $mod = new $classname;
+ $mod = new $module();
// Set code count in $mod->code
$result = $mod->get_code($this->db, $this, $type);
@@ -3947,6 +3996,20 @@ class Societe extends CommonObject
}
}
+ //Verify ID Prof 1 if country is BE (xxxx.xxx.xxx) (https://economie.fgov.be/fr/themes/entreprises/banque-carrefour-des/actualites/structure-du-numero)
+ //Returns: 1 if ok, -1 if bad, 0 if unexpected bad
+ if ($idprof == 1 && $soc->country_code == 'BE') {
+ $string = trim($this->idprof1);
+ $string = preg_replace('/(\s)/', '', $string);
+
+ //Check
+ if (preg_match('/(^[0-9]{4}\.[0-9]{3}\.[0-9]{3}$)/', $string)) {
+ return 1;
+ } else {
+ return -1;
+ }
+ }
+
return $ok;
}
@@ -4514,10 +4577,10 @@ class Societe extends CommonObject
$this->country_code = 'FR';
$this->email = 'specimen@specimen.com';
$this->socialnetworks = array(
- 'skype' => 'tom.hanson',
- 'twitter' => 'tomhanson',
- 'facebook' => 'tomhanson',
- 'linkedin' => 'tomhanson',
+ 'skype' => 'skypepseudo',
+ 'twitter' => 'twitterpseudo',
+ 'facebook' => 'facebookpseudo',
+ 'linkedin' => 'linkedinpseudo',
);
$this->url = 'http://www.specimen.com';
@@ -4971,6 +5034,7 @@ class Societe extends CommonObject
dol_print_error($this->db, $companybankaccount->error, $companybankaccount->errors);
}
$result = $companybankaccount->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
+ $this->last_main_doc=$companybankaccount->last_main_doc;
} else {
// Positionne le modele sur le nom du modele a utiliser
if (!dol_strlen($modele)) {
diff --git a/htdocs/societe/class/societeaccount.class.php b/htdocs/societe/class/societeaccount.class.php
index 4d4fdc012d8..ee95f2bd1a2 100644
--- a/htdocs/societe/class/societeaccount.class.php
+++ b/htdocs/societe/class/societeaccount.class.php
@@ -84,8 +84,8 @@ class SocieteAccount extends CommonObject
'pass_crypted' => array('type'=>'varchar(128)', 'label'=>'Password', 'visible'=>1, 'enabled'=>1, 'position'=>31, 'notnull'=>1),
'pass_temp' => array('type'=>'varchar(128)', 'label'=>'Temp', 'visible'=>0, 'enabled'=>0, 'position'=>32, 'notnull'=>-1,),
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1, 'index'=>1),
- 'fk_website' => array('type'=>'integer:Website:website/class/website.class.php', 'label'=>'WebSite', 'visible'=>1, 'enabled'=>1, 'position'=>42, 'notnull'=>-1, 'index'=>1),
- 'site' => array('type'=>'varchar(128)', 'label'=>'ExternalSite', 'visible'=>0, 'enabled'=>1, 'position'=>43, 'help'=>'Name of the website or service if this is account on an external website or service'),
+ 'site' => array('type'=>'varchar(128)', 'label'=>'WebsiteTypeLabel', 'visible'=>0, 'enabled'=>0, 'position'=>41, 'notnull'=>1, 'default' => '', 'help'=>'Name of the website or service if this is account on an external website or service'),
+ 'fk_website' => array('type'=>'integer:Website:website/class/website.class.php', 'label'=>'WebSite', 'visible'=>0, 'enabled'=>0, 'position'=>42, 'notnull'=>-1, 'index'=>1),
'site_account' => array('type'=>'varchar(128)', 'label'=>'ExternalSiteAccount', 'visible'=>0, 'enabled'=>1, 'position'=>44, 'help'=>'A key to identify the account on external web site if this is an account on an external website'),
'key_account' => array('type'=>'varchar(128)', 'label'=>'KeyAccount', 'visible'=>0, 'enabled'=>1, 'position'=>48, 'notnull'=>0, 'index'=>1, 'searchall'=>1, 'comment'=>'The id of third party in the external web site (for site_account if site_account defined)',),
'date_last_login' => array('type'=>'datetime', 'label'=>'LastConnexion', 'visible'=>2, 'enabled'=>1, 'position'=>50, 'notnull'=>0,),
@@ -168,13 +168,29 @@ class SocieteAccount extends CommonObject
*/
public function __construct(DoliDB $db)
{
- global $conf;
+ global $conf, $langs;
$this->db = $db;
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
$this->fields['rowid']['visible'] = 0;
}
+
+ // add site type list and set visible
+ $site_type_list = array();
+ if (isModEnabled('website')) {
+ $this->fields['fk_website']['visible'] = 1;
+ $this->fields['fk_website']['enabled'] = 1;
+ $this->fields['site']['visible'] = 1;
+ $this->fields['site']['enabled'] = 1;
+ $site_type_list['dolibarr_website'] = $langs->trans('WebsiteTypeDolibarrWebsite');
+ }
+ if (isModEnabled('webportal')) {
+ $this->fields['site']['visible'] = 1;
+ $this->fields['site']['enabled'] = 1;
+ $site_type_list['dolibarr_portal'] = $langs->trans('WebsiteTypeDolibarrPortal');
+ }
+ $this->fields['site']['arrayofkeyval'] = $site_type_list;
}
/**
@@ -417,7 +433,7 @@ class SocieteAccount extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php
index 240baf7075c..e0c3f8c8db7 100644
--- a/htdocs/societe/list.php
+++ b/htdocs/societe/list.php
@@ -1004,7 +1004,7 @@ if ($contextpage != 'poslist') {
} elseif ($user->hasRight('societe', 'creer')) {
$url = DOL_URL_ROOT.'/societe/card.php?action=create&type=t&contextpage=poslist&optioncss=print&backtopage='.urlencode($_SERVER["PHP_SELF"].'?type=t&contextpage=poslist&nomassaction=1&optioncss=print&place='.$place);
$label = 'MenuNewCustomer';
- $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url);
+ $newcardbutton = dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url);
}
print ''."\n";
diff --git a/htdocs/societe/messaging.php b/htdocs/societe/messaging.php
index de8c7396c3a..4fdc1c54a69 100644
--- a/htdocs/societe/messaging.php
+++ b/htdocs/societe/messaging.php
@@ -158,7 +158,7 @@ if ($socid > 0) {
$out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : '').'&backtopage='.urlencode($_SERVER['PHP_SELF'].($objthirdparty->id > 0 ? '?socid='.$objthirdparty->id : ''));
}
$out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '');
- $out .= '&datep='.dol_print_date(dol_now(), 'dayhourlog');
+ $out .= '&datep='.dol_print_date(dol_now(), 'dayhourlog', 'tzuserrel');
}
$morehtmlright = '';
diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php
index 746b5d2bd5c..c122d61c7d5 100644
--- a/htdocs/societe/paymentmodes.php
+++ b/htdocs/societe/paymentmodes.php
@@ -48,11 +48,13 @@ $langs->loadLangs(array("companies", "commercial", "banks", "bills", 'paypal', '
// Get parameters
+$action = GETPOST("action", 'alpha', 3);
+$cancel = GETPOST('cancel', 'alpha');
+$backtopage = GETPOST('backtopage');
+
$id = GETPOST("id", "int");
$source = GETPOST("source", "alpha"); // source can be a source or a paymentmode
$ribid = GETPOST("ribid", "int");
-$action = GETPOST("action", 'alpha', 3);
-$cancel = GETPOST('cancel', 'alpha');
// Security check
$socid = GETPOST("socid", "int");
@@ -478,7 +480,7 @@ if (empty($reshook)) {
if ($action == 'confirm_deletebank' && GETPOST('confirm', 'alpha') == 'yes') {
// Delete the bank account
$companybankaccount = new CompanyBankAccount($db);
- if ($companybankaccount->fetch($ribid ? $ribid : $id)) {
+ if ($companybankaccount->fetch($ribid ? $ribid : $id) > 0) {
// TODO This is currently done at bottom of page instead of asking confirm
/*if ($companypaymentmode->stripe_card_ref && preg_match('/pm_/', $companypaymentmode->stripe_card_ref))
{
@@ -525,23 +527,37 @@ if (empty($reshook)) {
// Action for stripe
if (isModEnabled('stripe') && class_exists('Stripe')) {
- if ($action == 'synccustomertostripe') {
+ if ($action == 'synccustomertostripe' || $action == 'synccustomertostripetest') {
if ($object->client == 0) {
$error++;
setEventMessages('ThisThirdpartyIsNotACustomer', null, 'errors');
} else {
+ if ($action == 'synccustomertostripe') {
+ $tmpservicestatus = 1;
+ $tmpservice = 'StripeLive';
+ } else {
+ $tmpservicestatus = 0;
+ $tmpservice = 'StripeTest';
+ }
+
+ $stripe = new Stripe($db);
+ $tmpstripeacc = $stripe->getStripeAccount($tmpservice); // Get Stripe OAuth connect account (no remote access to Stripe here)
+
// Creation of Stripe customer + update of societe_account
- $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus, 1);
- if (!$cu) {
+ $tmpcu = $stripe->customerStripe($object, $tmpstripeacc, $tmpservicestatus, 1);
+
+ if (empty($tmpcu)) {
$error++;
setEventMessages($stripe->error, $stripe->errors, 'errors');
} else {
- $stripecu = $cu->id;
+ if ($tmpservicestatus == $servicestatus) {
+ $stripecu = $tmpcu->id;
+ }
}
}
}
if ($action == 'synccardtostripe') {
- // Create the credit card on Stripe
+ // Create the credit card on current Stripe env
$companypaymentmode = new CompanyPaymentMode($db);
$companypaymentmode->fetch($id);
@@ -569,7 +585,7 @@ if (empty($reshook)) {
}
}
if ($action == 'syncsepatostripe') {
- // Create the bank account on Stripe side
+ // Create the bank account on current Stripe env
$companypaymentmode = new CompanyPaymentMode($db); // Get record in llx_societe_rib
$companypaymentmode->fetch($id);
@@ -599,18 +615,34 @@ if (empty($reshook)) {
}
}
- if ($action == 'setkey_account') {
+ // Set the customer Stripe account (for Live or Test env)
+ if ($action == 'setkey_account' || $action == 'setkey_accounttest') {
$error = 0;
- $newcu = GETPOST('key_account', 'alpha');
+ $tmpservice = 'StripeTest';
+ $tmpservicestatus = 0;
+ if ($action == 'setkey_account') {
+ $tmpservice = 'StripeLive';
+ $tmpservicestatus = 1;
+ }
+
+ // Force to use the correct API key
+ global $stripearrayofkeysbyenv;
+ $tmpsite_account = $stripearrayofkeysbyenv[$tmpservicestatus]['publishable_key'];
+
+ if ($action == 'setkey_account') {
+ $newcu = GETPOST('key_account', 'alpha');
+ } else {
+ $newcu = GETPOST('key_accounttest', 'alpha');
+ }
$db->begin();
if (empty($newcu)) {
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($site_account)."') AND fk_soc = ".$object->id." AND status = ".((int) $servicestatus)." AND entity = ".$conf->entity;
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($tmpsite_account)."') AND fk_soc = ".$object->id." AND status = ".((int) $tmpservicestatus)." AND entity = ".$conf->entity;
} else {
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX."societe_account";
- $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($site_account)."') AND fk_soc = ".((int) $object->id)." AND status = ".((int) $servicestatus)." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified !
+ $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($tmpsite_account)."') AND fk_soc = ".((int) $object->id)." AND status = ".((int) $tmpservicestatus)." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified !
}
$resql = $db->query($sql);
@@ -624,15 +656,15 @@ if (empty($reshook)) {
$societeaccount->site = 'stripe';
$societeaccount->status = $servicestatus;
$societeaccount->key_account = $newcu;
- $societeaccount->site_account = $site_account;
+ $societeaccount->site_account = $tmpsite_account;
$result = $societeaccount->create($user);
if ($result < 0) {
$error++;
}
} else {
$sql = 'UPDATE '.MAIN_DB_PREFIX."societe_account";
- $sql .= " SET key_account = '".$db->escape(GETPOST('key_account', 'alpha'))."', site_account = '".$db->escape($site_account)."'";
- $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($site_account)."') AND fk_soc = ".((int) $object->id)." AND status = ".((int) $servicestatus)." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified !
+ $sql .= " SET key_account = '".$db->escape($newcu)."', site_account = '".$db->escape($tmpsite_account)."'";
+ $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($tmpsite_account)."') AND fk_soc = ".((int) $object->id)." AND status = ".((int) $tmpservicestatus)." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified !
$resql = $db->query($sql);
}
}
@@ -641,34 +673,52 @@ if (empty($reshook)) {
//var_dump($num); exit;
if (!$error) {
- $stripecu = $newcu;
+ if ($tmpservicestatus == $servicestatus) {
+ $stripecu = $newcu;
+ }
$db->commit();
} else {
$db->rollback();
}
}
- if ($action == 'setkey_account_supplier') {
+ // Set the supplier Stripe account (for Live or Test env)
+ if ($action == 'setkey_account_supplier' || $action == 'setkey_account_suppliertest') {
$error = 0;
- $newsup = GETPOST('key_account_supplier', 'alpha');
+ $tmpservice = 'StripeTest';
+ $tmpservicestatus = 0;
+ if ($action == 'setkey_account_supplier') {
+ $tmpservice = 'StripeLive';
+ $tmpservicestatus = 1;
+ }
+
+ // Force to use the correct API key
+ global $stripearrayofkeysbyenv;
+ $tmpsite_account = $stripearrayofkeysbyenv[$tmpservicestatus]['publishable_key'];
+
+ if ($action == 'setkey_account_supplier') {
+ $newsup = GETPOST('key_account_supplier', 'alpha');
+ } else {
+ $newsup = GETPOST('key_account_suppliertest', 'alpha');
+ }
$db->begin();
if (empty($newsup)) {
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE fk_soc = ".$object->id." AND service = '".$db->escape($service)."' AND entity = ".$conf->entity;
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE fk_soc = ".$object->id." AND service = '".$db->escape($tmpservice)."' AND entity = ".$conf->entity;
// TODO Add site and site_account on oauth_token table
//$sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE site = 'stripe' AND (site_account IS NULL or site_account = '".$db->escape($site_account)."') AND fk_soc = ".((int) $object->id)." AND service = '".$db->escape($service)."' AND entity = ".$conf->entity;
} else {
try {
- $stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha')));
+ $stripesup = \Stripe\Account::retrieve($newsup);
$tokenstring['stripe_user_id'] = $stripesup->id;
$tokenstring['type'] = $stripesup->type;
$sql = "UPDATE ".MAIN_DB_PREFIX."oauth_token";
$sql .= " SET tokenstring = '".$db->escape(json_encode($tokenstring))."'";
- $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '".$db->escape($site_account)."') AND fk_soc = ".((int) $object->id)." AND service = '".$db->escape($service)."' AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified !
+ $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '".$db->escape($tmpsite_account)."') AND fk_soc = ".((int) $object->id)." AND service = '".$db->escape($tmpservice)."' AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified !
// TODO Add site and site_account on oauth_token table
- $sql .= " WHERE fk_soc = ".$object->id." AND service = '".$db->escape($service)."' AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified !
+ $sql .= " WHERE fk_soc = ".$object->id." AND service = '".$db->escape($tmpservice)."' AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified !
} catch (Exception $e) {
$error++;
setEventMessages($e->getMessage(), null, 'errors');
@@ -679,11 +729,11 @@ if (empty($reshook)) {
$num = $db->num_rows($resql);
if (empty($num) && !empty($newsup)) {
try {
- $stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha')));
+ $stripesup = \Stripe\Account::retrieve($newsup);
$tokenstring['stripe_user_id'] = $stripesup->id;
$tokenstring['type'] = $stripesup->type;
$sql = "INSERT INTO ".MAIN_DB_PREFIX."oauth_token (service, fk_soc, entity, tokenstring)";
- $sql .= " VALUES ('".$db->escape($service)."', ".((int) $object->id).", ".((int) $conf->entity).", '".$db->escape(json_encode($tokenstring))."')";
+ $sql .= " VALUES ('".$db->escape($tmpservice)."', ".((int) $object->id).", ".((int) $conf->entity).", '".$db->escape(json_encode($tokenstring))."')";
// TODO Add site and site_account on oauth_token table
} catch (Exception $e) {
$error++;
@@ -693,7 +743,9 @@ if (empty($reshook)) {
}
if (!$error) {
- $stripesupplieracc = $newsup;
+ if ($tmpservicestatus == $servicestatus) {
+ $stripesupplieracc = $newsup;
+ }
$db->commit();
} else {
$db->rollback();
@@ -786,6 +838,10 @@ if (empty($reshook)) {
}
$url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
+ if (GETPOST('page_y', 'int')) {
+ $url .= '&page_y='.GETPOST('page_y', 'int');
+ }
+
header('Location: '.$url);
exit;
} catch (Exception $e) {
@@ -921,24 +977,59 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
}
if (isModEnabled('stripe')) {
+ // Force to use the correct API key
+ global $stripearrayofkeysbyenv;
+
+ $tmpservice = 0;
+ $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice]['publishable_key'];
+ $tmpstripeacc = $stripe->getStripeAccount($tmpservice); // Get Stripe OAuth connect account (no remote access to Stripe here)
+ $tmpstripecu = $stripe->getStripeCustomerAccount($object->id, $tmpservice, $tmpsite_account); // Get remote Stripe customer 'cus_...' (no remote access to Stripe here)
+
// Stripe customer key 'cu_....' stored into llx_societe_account
print '';
- print $form->editfieldkey("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid');
+ print $form->editfieldkey($langs->trans("StripeCustomerId").' (Test)', 'key_accounttest', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid');
print ' ';
- print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', null, null, '', 2, '', 'socid');
- if (isModEnabled('stripe') && $stripecu && $action != 'editkey_account') {
+ print $form->editfieldval($langs->trans("StripeCustomerId").' (Test)', 'key_accounttest', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', null, null, '', 2, '', 'socid');
+ if ($tmpstripecu && $action != 'editkey_accounttest') {
$connect = '';
if (!empty($stripeacc)) {
$connect = $stripeacc.'/';
}
- $url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$stripecu;
- if ($servicestatus) {
- $url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$stripecu;
- }
- print ' '.img_picto($langs->trans('ShowInStripe').' - Publishable key = '.$site_account, 'globe').' ';
+ $url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$tmpstripecu;
+ print ' '.img_picto($langs->trans('ShowInStripe').' - Publishable key = '.$tmpsite_account, 'globe').' ';
}
print ' ';
- if (empty($stripecu)) {
+ if (empty($tmpstripecu)) {
+ print '';
+ print ' ';
+ print ' ';
+ print ' ';
+ print img_picto($langs->trans("CreateCustomerOnStripe"), 'stripe');
+ print ' ';
+ print ' ';
+ }
+ print ' ';
+
+ $tmpservice = 1;
+ $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice]['publishable_key'];
+ $tmpstripeacc = $stripe->getStripeAccount($tmpservice); // Get Stripe OAuth connect account (no remote access to Stripe here)
+ $tmpstripecu = $stripe->getStripeCustomerAccount($object->id, $tmpservice, $tmpsite_account); // Get remote Stripe customer 'cus_...' (no remote access to Stripe here)
+
+ // Stripe customer key 'cu_....' stored into llx_societe_account
+ print '';
+ print $form->editfieldkey($langs->trans("StripeCustomerId").' (Live)', 'key_account', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid');
+ print ' ';
+ print $form->editfieldval($langs->trans("StripeCustomerId").' (Live)', 'key_account', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', null, null, '', 2, '', 'socid');
+ if ($tmpstripecu && $action != 'editkey_account') {
+ $connect = '';
+ if (!empty($stripeacc)) {
+ $connect = $stripeacc.'/';
+ }
+ $url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$tmpstripecu;
+ print ' '.img_picto($langs->trans('ShowInStripe').' - Publishable key = '.$tmpsite_account, 'globe').' ';
+ }
+ print ' ';
+ if (empty($tmpstripecu)) {
print '';
print ' ';
print ' ';
@@ -1136,18 +1227,22 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
print '';
print dol_escape_htmltag($companypaymentmodetemp->label);
print ' ';
- // External card ID
- print '';
- if (!empty($companypaymentmodetemp->stripe_card_ref)) {
- $connect = '';
- if (!empty($stripeacc)) {
- $connect = $stripeacc.'/';
+ // External system card ID
+ print ' ';
+ if (!empty($companypaymentmodetemp->stripe_card_ref) && !empty($companypaymentmodetemp->ext_payment_site)) {
+ if (isModEnabled('stripe') && in_array($companypaymentmodetemp->ext_payment_site, array('StripeTest', 'StripeLive'))) {
+ $connect = '';
+ if (!empty($stripeacc)) {
+ $connect = $stripeacc.'/';
+ }
+ if ($companypaymentmodetemp->ext_payment_site == 'StripeLive') {
+ $url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$companypaymentmodetemp->stripe_card_ref;
+ } else {
+ $url = 'https://dashboard.stripe.com/'.$connect.'test/search?query='.$companypaymentmodetemp->stripe_card_ref;
+ }
+ print "".img_picto($langs->trans('ShowInStripe').' - '.$companypaymentmodetemp->stripe_account, 'globe')." ";
}
- $url = 'https://dashboard.stripe.com/'.$connect.'test/search?query='.$companypaymentmodetemp->stripe_card_ref;
- if ($servicestatus) {
- $url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$companypaymentmodetemp->stripe_card_ref;
- }
- print ''.img_picto($langs->trans('ShowInStripe').' - Customer and Publishable key = '.$companypaymentmodetemp->stripe_account, 'globe').' ';
+ // TODO Add hook here for other payment services
}
print dol_escape_htmltag($companypaymentmodetemp->stripe_card_ref);
print ' ';
@@ -1451,6 +1546,9 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
print_liste_field_titre("WithdrawMode");
}
print_liste_field_titre("Default", '', '', '', '', '', '', '', 'center ');
+ if (!getDolGlobalInt('SOCIETE_DISABLE_BANKACCOUNT') && getDolGlobalInt("SOCIETE_RIB_ALLOW_ONLINESIGN")) {
+ print_liste_field_titre('', '', '', '', '', '', '', '', 'center ');
+ }
print_liste_field_titre('', '', '', '', '', '', '', '', 'center ');
// Fields from hook
$parameters = array('arrayfields'=>array(), 'linetype'=>'stripebantitle');
@@ -1468,22 +1566,24 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
print '';
// Label
print ''.dol_escape_htmltag($rib->label).' ';
- // Stripe ID
- print '';
- if ($rib->stripe_card_ref) {
- $connect = '';
- if (!empty($stripeacc)) {
- $connect = $stripeacc.'/';
+ // External system ID
+ print ' ';
+ if (!empty($rib->stripe_card_ref) && !empty($rib->ext_payment_site)) {
+ if (isModEnabled('stripe') && in_array($rib->ext_payment_site, array('StripeTest', 'StripeLive'))) {
+ $connect = '';
+ if (!empty($stripeacc)) {
+ $connect = $stripeacc.'/';
+ }
+ if ($rib->ext_payment_site == 'StripeLive') {
+ $url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$rib->stripe_card_ref;
+ } else {
+ $url = 'https://dashboard.stripe.com/'.$connect.'test/search?query='.$rib->stripe_card_ref;
+ }
+ print "".img_picto($langs->trans('ShowInStripe'), 'globe')." ";
}
- //$url='https://dashboard.stripe.com/'.$connect.'test/sources/'.$src->id;
- $url = 'https://dashboard.stripe.com/'.$connect.'test/search?query='.$rib->stripe_card_ref;
- if ($servicestatus) {
- //$url='https://dashboard.stripe.com/'.$connect.'sources/'.$src->id;
- $url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$rib->stripe_card_ref;
- }
- print "".img_picto($langs->trans('ShowInStripe'), 'globe')." ";
+ // TODO Add hook here for other payment services
}
- print $rib->stripe_card_ref;
+ print dol_escape_htmltag($rib->stripe_card_ref);
print ' ';
// Bank name
print ''.dol_escape_htmltag($rib->bank).' ';
@@ -1542,7 +1642,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
print ''.dol_print_date($rib->date_rum, 'day').' ';
- // FRSTRECUR
+ // FRST or RCUR
print ''.$rib->frstrecur.' ';
}
@@ -1626,6 +1726,17 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
+ if (!getDolGlobalInt('SOCIETE_DISABLE_BANKACCOUNT') && getDolGlobalInt("SOCIETE_RIB_ALLOW_ONLINESIGN")) {
+ // Show online signature link
+ print '';
+ $useonlinesignature = 1;
+ if ($useonlinesignature) {
+ require_once DOL_DOCUMENT_ROOT . '/core/lib/signature.lib.php';
+ print showOnlineSignatureUrl($companybankaccount->element, $rib->id);
+ }
+ print ' ';
+ }
+
// Edit/Delete
print '';
if ($permissiontoaddupdatepaymentinformation) {
@@ -1640,7 +1751,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
print img_picto($langs->trans("Modify"), 'edit');
print '';
- print 'id.'&id='.$rib->id.'&action=deletebank&token='.newToken().'">';
+ print ' id.'&id='.$rib->id.'&action=deletebank&token='.newToken().'">';
print img_picto($langs->trans("Delete"), 'delete');
print ' ';
}
@@ -1744,7 +1855,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
// Action column
print ' ';
if ($permissiontoaddupdatepaymentinformation) {
- print '';
+ print ' ';
print img_picto($langs->trans("Delete"), 'delete');
print ' ';
}
diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php
index 8f2990361e2..78b8375ec2b 100644
--- a/htdocs/societe/price.php
+++ b/htdocs/societe/price.php
@@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php';
- $prodcustprice = new Productcustomerprice($db);
+ $prodcustprice = new ProductCustomerPrice($db);
}
@@ -257,7 +257,7 @@ print dol_get_fiche_end();
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
- $prodcustprice = new Productcustomerprice($db);
+ $prodcustprice = new ProductCustomerPrice($db);
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
diff --git a/htdocs/societe/project.php b/htdocs/societe/project.php
index 5a8ba6a46b2..522fa407a36 100644
--- a/htdocs/societe/project.php
+++ b/htdocs/societe/project.php
@@ -33,10 +33,21 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
+
+$form = new Form($db);
// Load translation files required by the page
$langs->loadLangs(array('companies', 'projects'));
+$action = GETPOST('action', 'aZ09');
+$massaction = GETPOST('massaction', 'alpha');
+$confirm = GETPOST('confirm', 'alpha');
+
+$toselect = GETPOST('toselect', 'array');
+
+
// Security check
$socid = GETPOST('socid', 'int');
if ($user->socid) {
@@ -47,35 +58,64 @@ $result = restrictedArea($user, 'societe', $socid, '&societe');
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('projectthirdparty'));
+$object = new Societe($db);
+$permissiontodelete = $user->hasRight('societe', 'supprimer');
+
+
/*
* Actions
*/
-$parameters = array('id'=>$socid);
+
+if (GETPOST('cancel', 'alpha')) {
+ $massaction = '';
+}
+if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
+ $massaction = '';
+ $massactionbutton = '';
+}
+
+
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
+$parameters = array('id'=>$socid);
+
+// List of mass actions available
+if (!empty($permissiontodelete)) {
+ $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
+}
+if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) {
+ $arrayofmassactions = array();
+}
+
+if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preenable', 'preclose'))) {
+ $arrayofmassactions = array();
+}
+
+// Mass actions
+$objectclass = 'Project';
+$objectlabel = 'Project';
+$uploaddir = $conf->societe->dir_output;
+include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
+
+$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
/*
* View
*/
-$contactstatic = new Contact($db);
-
-$form = new Form($db);
-
+unset($_SESSION['pageforbacktolist']['project']);
if ($socid) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
$langs->load("companies");
-
- $object = new Societe($db);
$result = $object->fetch($socid);
$title = $langs->trans("Projects");
@@ -100,6 +140,7 @@ if ($socid) {
print '
';
print '';
+
// Type Prospect/Customer/Supplier
print ''.$langs->trans('NatureOfThirdParty').' ';
print $object->getTypeUrl(1);
@@ -137,15 +178,23 @@ if ($socid) {
print dol_get_fiche_end();
+ print ' ';
$params = '';
$backtopage = $_SERVER['PHP_SELF'].'?socid='.$object->id;
$newcardbutton = dolGetButtonTitle($langs->trans("NewProject"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?action=create&socid='.$object->id.'&backtopageforcancel='.urlencode($backtopage), '', 1, $params);
- print ' ';
+ if (empty($conf->dol_optimize_smallscreen)) {
+ print 'id.'">';
+ print ' ';
+ print ''.$massactionbutton.'
';
+ }
// Projects list
+ include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
+ $arrayofselected = is_array($toselect) ? $toselect : array();
$result = show_projects($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id, 1, $newcardbutton);
+ print ' ';
}
// End of page
diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php
index 2c38ad02770..a29cf93e403 100644
--- a/htdocs/societe/website.php
+++ b/htdocs/societe/website.php
@@ -249,7 +249,7 @@ print '';
print dol_get_fiche_end();
$newcardbutton = '';
-if (isModEnabled('website')) {
+if (isModEnabled('website') || isModEnabled('webportal')) {
if ($user->hasRight('societe', 'lire')) {
$newcardbutton .= dolGetButtonTitle($langs->trans("AddWebsiteAccount"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/website/websiteaccount_card.php?action=create&fk_soc='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id));
} else {
@@ -263,6 +263,13 @@ print ' ';
// Build and execute select
// --------------------------------------------------------------------
+$site_filter_list = array();
+if (isModEnabled('website')) {
+ $site_filter_list[] = 'dolibarr_website';
+}
+if (isModEnabled('webportal')) {
+ $site_filter_list[] = 'dolibarr_portal';
+}
$sql = 'SELECT ';
foreach ($objectwebsiteaccount->fields as $key => $val) {
$sql .= "t.".$key.", ";
@@ -283,11 +290,14 @@ if (isset($extrafields->attributes[$object->table_element]['label']) && is_array
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
}
if ($objectwebsiteaccount->ismultientitymanaged == 1) {
- $sql .= " WHERE t.entity IN (".getEntity('societeaccount').")";
+ $sql .= " WHERE t.entity IN (".getEntity('thirdpartyaccount').")";
} else {
$sql .= " WHERE 1 = 1";
}
$sql .= " AND fk_soc = ".((int) $object->id);
+if (!empty($site_filter_list)) {
+ $sql .= " AND t.site IN (".$db->sanitize("'".implode("','", $site_filter_list)."'", 1).")";
+}
foreach ($search as $key => $val) {
$mode_search = (($objectwebsiteaccount->isInt($objectwebsiteaccount->fields[$key]) || $objectwebsiteaccount->isFloat($objectwebsiteaccount->fields[$key])) ? 1 : 0);
if ($search[$key] != '') {
diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php
index 6785869feb5..98c5757699a 100644
--- a/htdocs/stripe/admin/stripe.php
+++ b/htdocs/stripe/admin/stripe.php
@@ -227,7 +227,7 @@ if (empty($conf->stripeconnect->enabled)) {
print ' ';
print ''.$langs->trans("STRIPE_TEST_WEBHOOK_KEY").' ';
- if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
+ if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
print ' ';
print ' ';
}
@@ -241,28 +241,36 @@ if (empty($conf->stripeconnect->enabled)) {
$out .= ajax_autoselect("onlinetestwebhookurl", 0);
print ' '.$out;
print ' ';
- if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
+ if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
if (!empty($conf->global->STRIPE_TEST_WEBHOOK_KEY) && !empty($conf->global->STRIPE_TEST_SECRET_KEY) && !empty($conf->global->STRIPE_TEST_WEBHOOK_ID)) {
- \Stripe\Stripe::setApiKey($conf->global->STRIPE_TEST_SECRET_KEY);
- $endpoint = \Stripe\WebhookEndpoint::retrieve($conf->global->STRIPE_TEST_WEBHOOK_ID);
- $endpoint->enabled_events = $stripearrayofwebhookevents;
- if (GETPOST('webhook', 'alpha') == $conf->global->STRIPE_TEST_WEBHOOK_ID) {
- if (!GETPOST('status', 'alpha')) {
- $endpoint->disabled = true;
- } else {
- $endpoint->disabled = false;
+ if (utf8_check($conf->global->STRIPE_TEST_SECRET_KEY)) {
+ try {
+ \Stripe\Stripe::setApiKey($conf->global->STRIPE_TEST_SECRET_KEY);
+ $endpoint = \Stripe\WebhookEndpoint::retrieve($conf->global->STRIPE_TEST_WEBHOOK_ID);
+ $endpoint->enabled_events = $stripearrayofwebhookevents;
+ if (GETPOST('webhook', 'alpha') == $conf->global->STRIPE_TEST_WEBHOOK_ID) {
+ if (!GETPOST('status', 'alpha')) {
+ $endpoint->disabled = true;
+ } else {
+ $endpoint->disabled = false;
+ }
+ }
+ $endpoint->url = $url;
+ $endpoint->save();
+
+ if ($endpoint->status == 'enabled') {
+ print '';
+ print img_picto($langs->trans("Activated"), 'switch_on');
+ } else {
+ print ' ';
+ print img_picto($langs->trans("Disabled"), 'switch_off');
+ }
+ } catch (Exception $e) {
+ print $e->getMessage();
}
- }
- $endpoint->url = $url;
- $endpoint->save();
- if ($endpoint->status == 'enabled') {
- print ' ';
- print img_picto($langs->trans("Activated"), 'switch_on');
} else {
- print ' ';
- print img_picto($langs->trans("Disabled"), 'switch_off');
+ print 'Bad value for the secret key. Reenter and save it again to fix this.';
}
- //print $endpoint;
} else {
print img_picto($langs->trans("Inactive"), 'statut5');
}
@@ -292,7 +300,7 @@ if (empty($conf->stripeconnect->enabled)) {
print '';
print ''.$langs->trans("STRIPE_LIVE_WEBHOOK_KEY").' ';
- if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
+ if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
print ' ';
print ' ';
}
@@ -305,39 +313,40 @@ if (empty($conf->stripeconnect->enabled)) {
$out .= ajax_autoselect("onlinelivewebhookurl", 0);
print ' '.$out;
print ' ';
- if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
+ if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
if (!empty($conf->global->STRIPE_LIVE_WEBHOOK_KEY) && !empty($conf->global->STRIPE_LIVE_SECRET_KEY) && !empty($conf->global->STRIPE_LIVE_WEBHOOK_ID)) {
- \Stripe\Stripe::setApiKey($conf->global->STRIPE_LIVE_SECRET_KEY);
- $endpoint = \Stripe\WebhookEndpoint::retrieve($conf->global->STRIPE_LIVE_WEBHOOK_ID);
- $endpoint->enabled_events = $stripearrayofwebhookevents;
- if (GETPOST('webhook', 'alpha') == $conf->global->STRIPE_LIVE_WEBHOOK_ID) {
- if (empty(GETPOST('status', 'alpha'))) {
- $endpoint->disabled = true;
- } else {
- $endpoint->disabled = false;
+ if (utf8_check($conf->global->STRIPE_TEST_SECRET_KEY)) {
+ try {
+ \Stripe\Stripe::setApiKey($conf->global->STRIPE_LIVE_SECRET_KEY);
+ $endpoint = \Stripe\WebhookEndpoint::retrieve($conf->global->STRIPE_LIVE_WEBHOOK_ID);
+ $endpoint->enabled_events = $stripearrayofwebhookevents;
+ if (GETPOST('webhook', 'alpha') == $conf->global->STRIPE_LIVE_WEBHOOK_ID) {
+ if (empty(GETPOST('status', 'alpha'))) {
+ $endpoint->disabled = true;
+ } else {
+ $endpoint->disabled = false;
+ }
+ }
+ $endpoint->url = $url;
+ $endpoint->save();
+ if ($endpoint->status == 'enabled') {
+ print '';
+ print img_picto($langs->trans("Activated"), 'switch_on');
+ } else {
+ print ' ';
+ print img_picto($langs->trans("Disabled"), 'switch_off');
+ }
+ } catch (Exception $e) {
+ print $e->getMessage();
}
}
- $endpoint->url = $url;
- $endpoint->save();
- if ($endpoint->status == 'enabled') {
- print ' ';
- print img_picto($langs->trans("Activated"), 'switch_on');
- } else {
- print ' ';
- print img_picto($langs->trans("Disabled"), 'switch_off');
- }
- //print $endpoint;
} else {
print img_picto($langs->trans("Inactive"), 'statut5');
}
}
print ' ';
-} else {
- print ''.$langs->trans("StripeConnect").' ';
- print ''.$langs->trans("StripeConnect_Mode").' ';
}
-
print '
';
print '';
@@ -377,7 +386,7 @@ if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { // What is this for ?
}
// Card Present for Stripe Terminal
-if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
+if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { // TODO Not used by current code
print ' ';
print $langs->trans("STRIPE_CARD_PRESENT").' ';
if ($conf->use_javascript_ajax) {
@@ -390,7 +399,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
}
// Locations for Stripe Terminal
-if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
+if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { // TODO Not used by current code
print ' ';
print $langs->trans("TERMINAL_LOCATION").' ';
$service = 'StripeTest';
@@ -453,7 +462,7 @@ print ' ';
// Activate Klarna
-if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
+if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { // TODO Not used by current code
print '';
print $langs->trans("STRIPE_KLARNA").' ';
if ($conf->use_javascript_ajax) {
@@ -467,7 +476,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
}
// Activate Bancontact
-if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
+if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { // TODO Not used by current code
print ' ';
print $langs->trans("STRIPE_BANCONTACT").' ';
if ($conf->use_javascript_ajax) {
@@ -481,7 +490,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
}
// Activate iDEAL
-if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
+if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { // TODO Not used by current code
print ' ';
print $langs->trans("STRIPE_IDEAL").' ';
if ($conf->use_javascript_ajax) {
@@ -495,7 +504,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
}
// Activate Giropay
-if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
+if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { // TODO Not used by current code
print ' ';
print $langs->trans("STRIPE_GIROPAY").' ';
if ($conf->use_javascript_ajax) {
@@ -509,7 +518,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
}
// Activate Sofort
-if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
+if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { // TODO Not used by current code
print ' ';
print $langs->trans("STRIPE_SOFORT").' ';
if ($conf->use_javascript_ajax) {
diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php
index 34ad99b18b9..614af91a5ae 100644
--- a/htdocs/stripe/class/stripe.class.php
+++ b/htdocs/stripe/class/stripe.class.php
@@ -881,10 +881,10 @@ class Stripe extends CommonObject
if ($status) {
$url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$cu->id;
}
- $urtoswitchonstripe = ' '.img_picto($langs->trans('ShowInStripe'), 'globe').' ';
+ $urtoswitchonstripe = ''.img_picto($langs->trans('ShowInStripe'), 'globe').' ';
//dol_syslog("Error: This case is not supported", LOG_ERR);
- $this->error = $langs->trans('CreationOfPaymentModeMustBeDoneFromStripeInterface', $urtoswitchonstripe);
+ $this->error = str_replace('{s1}', $urtoswitchonstripe, $langs->trans('CreationOfPaymentModeMustBeDoneFromStripeInterface', '{s1}'));
}
} else {
if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) {
@@ -902,10 +902,10 @@ class Stripe extends CommonObject
if ($status) {
$url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$cu->id;
}
- $urtoswitchonstripe = ' '.img_picto($langs->trans('ShowInStripe'), 'globe').' ';
+ $urtoswitchonstripe = ''.img_picto($langs->trans('ShowInStripe'), 'globe').' ';
//dol_syslog("Error: This case is not supported", LOG_ERR);
- $this->error = $langs->trans('CreationOfPaymentModeMustBeDoneFromStripeInterface', $urtoswitchonstripe);
+ $this->error = str_replace('{s1}', $urtoswitchonstripe, $langs->trans('CreationOfPaymentModeMustBeDoneFromStripeInterface', '{s1}'));
}
}
@@ -936,7 +936,7 @@ class Stripe extends CommonObject
/**
- * Get the Stripe SEPA of a company payment mode
+ * Get the Stripe SEPA of a company payment mode (create it if it doesn't exists and $createifnotlinkedtostripe is set)
*
* @param \Stripe\Customer $cu Object stripe customer.
* @param CompanyPaymentMode $object Object companypaymentmode to check, or create on stripe (create on stripe also update the societe_rib table for current entity)
@@ -947,7 +947,7 @@ class Stripe extends CommonObject
*/
public function sepaStripe($cu, CompanyPaymentMode $object, $stripeacc = '', $status = 0, $createifnotlinkedtostripe = 0)
{
- global $conf, $user, $langs;
+ global $conf;
$sepa = null;
$sql = "SELECT sa.stripe_card_ref, sa.proprio, sa.iban_prefix as iban, sa.rum"; // stripe_card_ref is 'src_...' for Stripe SEPA
@@ -1028,7 +1028,7 @@ class Stripe extends CommonObject
//$a = \Stripe\Stripe::getApiKey();
//var_dump($a);var_dump($stripeacc);exit;
try {
- dol_syslog("Try to create sepa_debit 0");
+ dol_syslog("Try to create sepa_debit");
$service = 'StripeTest';
$servicestatus = 0;
@@ -1053,13 +1053,17 @@ class Stripe extends CommonObject
// link customer and src
//$cs = $this->getSetupIntent($description, $soc, $cu, '', $status);
$dataforintent = array(['description'=> $description, 'payment_method_types' => ['sepa_debit'], 'customer' => $cu->id, 'payment_method' => $sepa->id], 'metadata'=>$metadata);
+
$cs = $s->setupIntents->create($dataforintent);
//$cs = $s->setupIntents->update($cs->id, ['payment_method' => $sepa->id]);
$cs = $s->setupIntents->confirm($cs->id, ['mandate_data' => ['customer_acceptance' => ['type' => 'offline']]]);
+ // note: $cs->mandate contians ID of mandate on Stripe side
+
if (!$cs) {
$this->error = 'Link SEPA <-> Customer failed';
} else {
dol_syslog("Update the payment mode of the customer");
+
// print json_encode($sepa);
// Save the Stripe payment mode ID into the Dolibarr database
@@ -1068,6 +1072,17 @@ class Stripe extends CommonObject
$sql .= " card_type = 'sepa_debit',";
$sql .= " stripe_account= '" . $this->db->escape($cu->id . "@" . $stripeacc) . "',";
$sql .= " ext_payment_site = '".$this->db->escape($service)."'";
+ if (!empty($cs->mandate)) {
+ $mandateservice = new \Stripe\Mandate($stripeacc);
+ $mandate = $mandateservice->retrieve($cs->mandate);
+ if (is_object($mandate) && is_object($mandate->payment_method_details) && is_object($mandate->payment_method_details->sepa_debit)) {
+ $refmandate = $mandate->payment_method_details->sepa_debit->reference;
+ //$urlmandate = $mandate->payment_method_details->sepa_debit->url;
+ $sql .= ", rum = '".$this->db->escape($refmandate)."'";
+ }
+ $sql .= ", comment = '".$this->db->escape($cs->mandate)."'";
+ $sql .= ", date_rum = '".$this->db->idate(dol_now())."'";
+ }
$sql .= " WHERE rowid = ".((int) $object->id);
$sql .= " AND type = 'ban'";
$resql = $this->db->query($sql);
@@ -1078,8 +1093,8 @@ class Stripe extends CommonObject
}
} catch (Exception $e) {
$sepa = null;
- $this->error = $e->getMessage();
- dol_syslog($this->error, LOG_WARNING);
+ $this->error = 'Stripe error: '.$e->getMessage().'. Check the BAN information.';
+ dol_syslog($this->error, LOG_WARNING); // Error from Stripe, so a warning on Dolibarr
}
}
}
diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php
index 8e49cc36260..a03d52ecbd0 100644
--- a/htdocs/supplier_proposal/card.php
+++ b/htdocs/supplier_proposal/card.php
@@ -1848,8 +1848,8 @@ if ($action == 'create') {
}
print ' ';
- print '';
if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) {
+ print ' ';
print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ' ';
print '' . price($object->total_localtax2, '', $langs, 0, -1, -1, $conf->currency) . ' ';
if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php
index dba68f99190..72a4f663cc7 100644
--- a/htdocs/supplier_proposal/class/supplier_proposal.class.php
+++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php
@@ -2549,7 +2549,7 @@ class SupplierProposal extends CommonObject
if ($option !== 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
@@ -2573,7 +2573,7 @@ class SupplierProposal extends CommonObject
$result .= $linkstart;
if ($withpicto) {
- $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
+ $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
}
if ($withpicto != 2) {
$result .= $this->ref;
diff --git a/htdocs/takepos/admin/appearance.php b/htdocs/takepos/admin/appearance.php
index 54ed2f642a2..d351b90ae8c 100644
--- a/htdocs/takepos/admin/appearance.php
+++ b/htdocs/takepos/admin/appearance.php
@@ -46,6 +46,9 @@ if (GETPOST('action', 'alpha') == 'set') {
$res = dolibarr_set_const($db, "TAKEPOS_COLOR_THEME", GETPOST('TAKEPOS_COLOR_THEME', 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_LINES_TO_SHOW", GETPOST('TAKEPOS_LINES_TO_SHOW', 'alpha'), 'chaine', 0, '', $conf->entity);
+ if (GETPOSTISSET('TAKEPOS_SHOW_PRODUCT_REFERENCE')) {
+ $res = dolibarr_set_const($db, "TAKEPOS_SHOW_PRODUCT_REFERENCE", GETPOST('TAKEPOS_SHOW_PRODUCT_REFERENCE', 'alpha'), 'chaine', 0, '', $conf->entity);
+ }
dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha'));
@@ -91,72 +94,76 @@ print " \n";
// Color theme
print '';
print $langs->trans("ColorTheme");
-print ' ';
+print ' ';
$array = array(0=>"Eldy", 1=>$langs->trans("Colorful"));
print $form->selectarray('TAKEPOS_COLOR_THEME', $array, (empty($conf->global->TAKEPOS_COLOR_THEME) ? '0' : $conf->global->TAKEPOS_COLOR_THEME), 0);
print " \n";
-// Hide category images to speed up
+// Don't display category section
print '';
-print $langs->trans('HideCategoryImages');
-print ' ';
-print ajax_constantonoff("TAKEPOS_HIDE_CATEGORY_IMAGES", array(), $conf->entity, 0, 0, 1, 0);
+print $langs->trans('HideCategories');
+print ' ';
+print ajax_constantonoff("TAKEPOS_HIDE_CATEGORIES", array(), $conf->entity, 0, 0, 1, 0);
print " \n";
+// Hide category images to speed up
+if (!getDolGlobalString('TAKEPOS_HIDE_CATEGORIES')) {
+ print '';
+ print $langs->trans('HideCategoryImages');
+ print ' ';
+ print ajax_constantonoff("TAKEPOS_HIDE_CATEGORY_IMAGES", array(), $conf->entity, 0, 0, 1, 0);
+ print " \n";
+}
+
// Hide category images to speed up
print '';
print $langs->trans('HideProductImages');
-print ' ';
+print ' ';
print ajax_constantonoff("TAKEPOS_HIDE_PRODUCT_IMAGES", array(), $conf->entity, 0, 0, 1, 0);
print " \n";
+// View reference or label of products
+print '';
+print $langs->trans('ShowProductReference');
+print ' ';
+$array = array("0"=>$langs->trans("Label"), 1=>$langs->trans("Ref").'+'.$langs->trans("Label"), 2=>$langs->trans("Ref"));
+print $form->selectarray('TAKEPOS_SHOW_PRODUCT_REFERENCE', $array, getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE', 2), 0);
+//print ajax_constantonoff("TAKEPOS_SHOW_PRODUCT_REFERENCE", array(), $conf->entity, 0, 0, 1, 0);
+print " \n";
+
// Lines to show
print '';
print $langs->trans("NumberOfLinesToShow");
-print ' ';
+print ' ';
$array = array(1=>"1", 2=>"2", 3=>"3", 4=>"4", 5=>"5", 6=>"6");
print $form->selectarray('TAKEPOS_LINES_TO_SHOW', $array, getDolGlobalInt('TAKEPOS_LINES_TO_SHOW', 2), 0);
print " \n";
-// D'ont display category
-print '';
-print $langs->trans('HideCategories');
-print ' ';
-print ajax_constantonoff("TAKEPOS_HIDE_CATEGORIES", array(), $conf->entity, 0, 0, 1, 0);
-print " \n";
-
// Hide stock on line
print '';
print $langs->trans('HideStockOnLine');
-print ' ';
+print ' ';
print ajax_constantonoff("TAKEPOS_HIDE_STOCK_ON_LINE", array(), $conf->entity, 0, 0, 1, 0);
print " \n";
// Only the products in stock
print '';
print $langs->trans('ShowOnlyProductInStock');
-print ' ';
+print ' ';
print ajax_constantonoff("TAKEPOS_PRODUCT_IN_STOCK", array(), $conf->entity, 0, 0, 1, 0);
print " \n";
// View description of the categories
print '';
print $langs->trans('ShowCategoryDescription');
-print ' ';
+print ' ';
print ajax_constantonoff("TAKEPOS_SHOW_CATEGORY_DESCRIPTION", array(), $conf->entity, 0, 0, 1, 0);
print " \n";
-// View reference of products
-print '';
-print $langs->trans('ShowProductReference');
-print ' ';
-print ajax_constantonoff("TAKEPOS_SHOW_PRODUCT_REFERENCE", array(), $conf->entity, 0, 0, 1, 0);
-print " \n";
-
// Use price excl. taxes (HT) and not price incl. taxes (TTC)
print '';
print $langs->trans('UsePriceHT');
-print ' ';
+print ' ';
print ajax_constantonoff("TAKEPOS_CHANGE_PRICE_HT", array(), $conf->entity, 0, 0, 1, 0);
print " \n";
diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php
index 56796b121d4..249cdc04ed9 100644
--- a/htdocs/takepos/ajax/ajax.php
+++ b/htdocs/takepos/ajax/ajax.php
@@ -41,6 +41,7 @@ if (!defined('NOBROWSERNOTIF')) {
require '../../main.inc.php'; // Load $user and permissions
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php";
+require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
$category = GETPOST('category', 'alphanohtml'); // Can be id of category or 'supplements'
$action = GETPOST('action', 'aZ09');
@@ -56,11 +57,16 @@ if (empty($user->rights->takepos->run)) {
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks
$hookmanager->initHooks(array('takeposproductsearch')); // new context for product search hooks
+$pricelevel = 1; // default price level if PRODUIT_MULTIPRICES. TODO Get price level from thirdparty.
+
+
/*
* View
*/
+$thirdparty = new Societe($db);
+
if ($action == 'getProducts') {
$tosell = GETPOSTISSET('tosell') ? GETPOST('tosell', 'int') : '';
$limit = GETPOSTISSET('limit') ? GETPOST('limit', 'int') : 0;
@@ -68,6 +74,14 @@ if ($action == 'getProducts') {
top_httphead('application/json');
+ // Search
+ if (GETPOSTINT('thirdpartyid') > 0) {
+ $result = $thirdparty->fetch(GETPOSTINT('thirdpartyid'));
+ if ($result > 0) {
+ $pricelevel = $thirdparty->price_level;
+ }
+ }
+
$object = new Categorie($db);
if ($category == "supplements") {
$category = getDolGlobalInt('TAKEPOS_SUPPLEMENTS_CATEGORY');
@@ -98,8 +112,8 @@ if ($action == 'getProducts') {
unset($prod->fields);
unset($prod->db);
- $prod->price_formated = price(price2num($prod->price, 'MT'), 1, $langs, 1, -1, -1, $conf->currency);
- $prod->price_ttc_formated = price(price2num($prod->price_ttc, 'MT'), 1, $langs, 1, -1, -1, $conf->currency);
+ $prod->price_formated = price(price2num(empty($prod->multiprices[$pricelevel]) ? $prod->price : $prod->multiprices[$pricelevel], 'MT'), 1, $langs, 1, -1, -1, $conf->currency);
+ $prod->price_ttc_formated = price(price2num(empty($prod->multiprices_ttc[$pricelevel]) ? $prod->price_ttc : $prod->multiprices_ttc[$pricelevel], 'MT'), 1, $langs, 1, -1, -1, $conf->currency);
$res[] = $prod;
}
@@ -111,10 +125,7 @@ if ($action == 'getProducts') {
} elseif ($action == 'search' && $term != '') {
top_httphead('application/json');
- // Change thirdparty with barcode
- require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
-
- $thirdparty = new Societe($db);
+ // Search barcode into thirdparties. If found, it means we want to change thirdparties.
$result = $thirdparty->fetch('', '', '', $term);
if ($result && $thirdparty->id > 0) {
@@ -129,6 +140,14 @@ if ($action == 'getProducts') {
exit;
}
+ // Search
+ if (GETPOSTINT('thirdpartyid') > 0) {
+ $result = $thirdparty->fetch(GETPOSTINT('thirdpartyid'));
+ if ($result > 0) {
+ $pricelevel = $thirdparty->price_level;
+ }
+ }
+
// Define $filteroncategids, the filter on category ID if there is a Root category defined.
$filteroncategids = '';
if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) { // A root category is defined, we must filter on products inside this category tree
@@ -196,10 +215,11 @@ if ($action == 'getProducts') {
$qty = floatval($qty_str);
}
+ $objProd = new Product($db);
+ $objProd->fetch($obj->rowid);
+
$ig = '../public/theme/common/nophoto.png';
if (empty($conf->global->TAKEPOS_HIDE_PRODUCT_IMAGES)) {
- $objProd = new Product($db);
- $objProd->fetch($obj->rowid);
$image = $objProd->show_photos('product', $conf->product->multidir_output[$objProd->entity], 'small', 1);
$match = array();
@@ -222,8 +242,8 @@ if ($action == 'getProducts') {
'tosell' => $obj->tosell,
'tobuy' => $obj->tobuy,
'barcode' => $obj->barcode,
- 'price' => $obj->price,
- 'price_ttc' => $obj->price_ttc,
+ 'price' => empty($objProd->multiprices[$pricelevel]) ? $obj->price : $objProd->multiprices[$pricelevel],
+ 'price_ttc' => empty($objProd->multiprices_ttc[$pricelevel]) ? $obj->price_ttc : $objProd->multiprices_ttc[$pricelevel],
'object' => 'product',
'img' => $ig,
'qty' => $qty,
@@ -244,7 +264,10 @@ if ($action == 'getProducts') {
if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1) {
$sql .= ', ps.reel';
}
-
+ /* this will be possible when field archive will be supported into llx_product_price
+ if (getDolGlobalString('PRODUIT_MULTIPRICES')) {
+ $sql .= ', pp.price_level, pp.price as multiprice_ht, pp.price_ttc as multiprice_ttc';
+ }*/
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters);
@@ -253,6 +276,11 @@ if ($action == 'getProducts') {
}
$sql .= ' FROM '.MAIN_DB_PREFIX.'product as p';
+ /* this will be possible when field archive will be supported into llx_product_price
+ if (getDolGlobalString('PRODUIT_MULTIPRICES')) {
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_price as pp ON pp.fk_product = p.rowid AND pp.entity = ".((int) $conf->entity)." AND pp.price_level = ".((int) $pricelevel);
+ $sql .= " AND archive = 0";
+ }*/
if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1) {
$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'product_stock as ps';
$sql .= ' ON (p.rowid = ps.fk_product';
@@ -267,7 +295,7 @@ if ($action == 'getProducts') {
$sql .= $hookmanager->resPrint;
}
- $sql .= ' WHERE entity IN ('.getEntity('product').')';
+ $sql .= ' WHERE p.entity IN ('.getEntity('product').')';
if ($filteroncategids) {
$sql .= ' AND EXISTS (SELECT cp.fk_product FROM '.MAIN_DB_PREFIX.'categorie_product as cp WHERE cp.fk_product = p.rowid AND cp.fk_categorie IN ('.$db->sanitize($filteroncategids).'))';
}
@@ -316,13 +344,13 @@ if ($action == 'getProducts') {
'tosell' => $obj->tosell,
'tobuy' => $obj->tobuy,
'barcode' => $obj->barcode,
- 'price' => $obj->price,
- 'price_ttc' => $obj->price_ttc,
+ 'price' => empty($objProd->multiprices[$pricelevel]) ? $obj->price : $objProd->multiprices[$pricelevel],
+ 'price_ttc' => empty($objProd->multiprices_ttc[$pricelevel]) ? $obj->price_ttc : $objProd->multiprices_ttc[$pricelevel],
'object' => 'product',
'img' => $ig,
'qty' => 1,
- 'price_formated' => price(price2num($obj->price, 'MT'), 1, $langs, 1, -1, -1, $conf->currency),
- 'price_ttc_formated' => price(price2num($obj->price_ttc, 'MT'), 1, $langs, 1, -1, -1, $conf->currency)
+ 'price_formated' => price(price2num(empty($objProd->multiprices[$pricelevel]) ? $obj->price : $objProd->multiprices[$pricelevel], 'MT'), 1, $langs, 1, -1, -1, $conf->currency),
+ 'price_ttc_formated' => price(price2num(empty($objProd->multiprices_ttc[$pricelevel]) ? $obj->price_ttc : $objProd->multiprices_ttc[$pricelevel], 'MT'), 1, $langs, 1, -1, -1, $conf->currency)
);
// Add entries to row from hooks
$parameters=array();
diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php
index ff6371fe735..0bea76c5144 100644
--- a/htdocs/takepos/index.php
+++ b/htdocs/takepos/index.php
@@ -331,7 +331,7 @@ function LoadProducts(position, issubcat) {
limit = maxproduct-1;
}
// Only show products for sale (tosell=1)
- $.getJSON('/takepos/ajax/ajax.php?action=getProducts&token=&category='+currentcat+'&tosell=1&limit='+limit+'&offset=0', function(data) {
+ $.getJSON('/takepos/ajax/ajax.php?action=getProducts&token=&thirdpartyid=' + jQuery('#thirdpartyid').val() + '&category='+currentcat+'&tosell=1&limit='+limit+'&offset=0', function(data) {
console.log("Call ajax.php (in LoadProducts) to get Products of category "+currentcat+" then loop on result to fill image thumbs");
console.log(data);
while (ishow < maxproduct) {
@@ -361,6 +361,8 @@ function LoadProducts(position, issubcat) {
echo '$("#prodivdesc"+ishow).show();';
if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) {
echo '$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold() + \' - \' + data[parseInt(idata)][\'label\']);';
+ } elseif (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) {
+ echo '$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold());';
} else {
echo '$("#prodesc"+ishow).html(data[parseInt(idata)][\'label\']);';
}
@@ -449,9 +451,10 @@ function MoreProducts(moreorless) {
$("#prodiv"+ishow).data("rowid","");
} else {
$("#prodivdesc"+ishow).show();
-
+
$("#prodesc"+ishow).html(data[parseInt(idata)]['ref'].bold() + ' - ' + data[parseInt(idata)]['label']);
+
+ $("#prodesc"+ishow).html(data[parseInt(idata)]['ref'].bold());
$("#prodesc"+ishow).html(data[parseInt(idata)]['label']);
@@ -567,7 +570,7 @@ function Refresh() {
function New() {
// If we go here,it means $conf->global->TAKEPOS_BAR_RESTAURANT is not defined
- invoiceid = $("#invoiceid").val();
+ invoiceid = $("#invoiceid").val(); // This is a hidden field added by invoice.php
console.log("New with place = , js place="+place+", invoiceid="+invoiceid);
@@ -641,7 +644,7 @@ function Search2(keyCodeForEnter, moreorless) {
pageproducts = 0;
jQuery(".wrapper2 .catwatermark").hide();
var nbsearchresults = 0;
- $.getJSON('/takepos/ajax/ajax.php?action=search&token=&term=' + search_term + '&search_start=' + search_start + '&search_limit=' + search_limit, function (data) {
+ $.getJSON('/takepos/ajax/ajax.php?action=search&token=&term=' + search_term + '&thirdpartyid=' + jQuery('#thirdpartyid').val() + '&search_start=' + search_start + '&search_limit=' + search_limit, function (data) {
for (i = 0; i < ; i++) {
if (typeof (data[i]) == "undefined") {
$("#prowatermark" + i).html("");
@@ -659,9 +662,10 @@ function Search2(keyCodeForEnter, moreorless) {
$titlestring .= " + ' - ".dol_escape_js($langs->trans("Barcode").': ')."' + data[i]['barcode']";
?>
var titlestring = ;
-
- $("#prodesc" + i).html(data[i]['ref'].bold() + ' - ' + data[i]['label']);
+
+ $("#prodesc" + i).html(data[i]['ref'].bold() + ' - ' + data[i]['label']);
+
+ $("#prodesc" + i).html(data[i]['ref'].bold());
$("#prodesc" + i).html(data[i]['label']);
@@ -1451,10 +1455,12 @@ if (!empty($conf->global->TAKEPOS_WEIGHING_SCALE)) {
//echo ' ';
print ' ';
} else {
- if (getDolGlobalString('TAKEPOS_HIDE_PRODUCT_IMAGES')) {
- echo ' ';
- } else {
+ if (!getDolGlobalString('TAKEPOS_HIDE_PRODUCT_PRICES')) {
print '
';
+ }
+ if (getDolGlobalString('TAKEPOS_HIDE_PRODUCT_IMAGES')) {
+ print ' ';
+ } else {
print ' ';
}
}
diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php
index ade8e1d3242..4c37a2367b8 100644
--- a/htdocs/takepos/invoice.php
+++ b/htdocs/takepos/invoice.php
@@ -494,7 +494,7 @@ if (empty($reshook)) {
$price = $datapriceofproduct['pu_ht'];
$price_ttc = $datapriceofproduct['pu_ttc'];
//$price_min = $datapriceofproduct['price_min'];
- $price_base_type = $datapriceofproduct['price_base_type'];
+ $price_base_type = empty($datapriceofproduct['price_base_type']) ? 'HT' : $datapriceofproduct['price_base_type'];
$tva_tx = $datapriceofproduct['tva_tx'];
$tva_npr = $datapriceofproduct['tva_npr'];
@@ -1319,7 +1319,9 @@ print '';
print '';
// In phone version only show when it is invoice page
if (empty($mobilepage) || $mobilepage == "invoice") {
+ print '';
print ' ';
+ print ' ';
}
if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
$sql = "SELECT floor, label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place);
@@ -1560,6 +1562,8 @@ if ($placeid > 0) {
}
if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) {
$htmlforlines .= $form->textwithpicto($line->product_label ? '' . $line->product_ref . ' - ' . $line->product_label : dolGetFirstLineOfText($line->desc, 1), $tooltiptext);
+ } elseif (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) {
+ $htmlforlines .= $form->textwithpicto($line->product_ref ? ''.$line->product_ref.'' : dolGetFirstLineOfText($line->desc, 1), $tooltiptext);
} else {
$htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext);
}
diff --git a/htdocs/takepos/receipt.php b/htdocs/takepos/receipt.php
index 7a4885f043f..3d3f6a85d56 100644
--- a/htdocs/takepos/receipt.php
+++ b/htdocs/takepos/receipt.php
@@ -111,12 +111,12 @@ if (!empty($hookmanager->resPrint)) {
global->TAKEPOS_HEADER) || getDolGlobalString($constFreeText)) {
+$constFreeText = 'TAKEPOS_HEADER'.(empty($_SESSION['takeposterminal']) ? '0' : $_SESSION['takeposterminal']);
+if (getDolGlobalString('TAKEPOS_HEADER') || getDolGlobalString($constFreeText)) {
$newfreetext = '';
$substitutionarray = getCommonSubstitutionArray($langs);
- if (!empty($conf->global->TAKEPOS_HEADER)) {
- $newfreetext .= make_substitutions($conf->global->TAKEPOS_HEADER, $substitutionarray);
+ if (getDolGlobalString('TAKEPOS_HEADER')) {
+ $newfreetext .= make_substitutions(getDolGlobalString('TAKEPOS_HEADER'), $substitutionarray);
}
if (getDolGlobalString($constFreeText)) {
$newfreetext .= make_substitutions(getDolGlobalString($constFreeText), $substitutionarray);
@@ -279,7 +279,7 @@ if (price2num($object->total_localtax1, 'MU') || $mysoc->useLocalTax(1)) { ?>
} ?>
currency != $_SESSION["takeposcustomercurrency"]) {
+if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency"]) && $_SESSION["takeposcustomercurrency"] != "" && $conf->currency != $_SESSION["takeposcustomercurrency"]) {
//Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
$multicurrency = new MultiCurrency($db);
@@ -318,6 +318,7 @@ if (getDolGlobalString('TAKEPOS_PRINT_PAYMENT_METHOD')) {
$i = 0;
while ($i < $num) {
$row = $db->fetch_object($resql);
+
echo '';
echo '';
echo $langs->transnoentitiesnoconv("PaymentTypeShort".$row->code);
@@ -352,14 +353,14 @@ if (getDolGlobalString('TAKEPOS_PRINT_PAYMENT_METHOD')) {
global->TAKEPOS_FOOTER) || getDolGlobalString($constFreeText)) {
+$constFreeText = 'TAKEPOS_FOOTER'.(empty($_SESSION['takeposterminal']) ? '0' : $_SESSION['takeposterminal']);
+if (getDolGlobalString('TAKEPOS_FOOTER') || getDolGlobalString($constFreeText)) {
$newfreetext = '';
$substitutionarray = getCommonSubstitutionArray($langs);
if (getDolGlobalString($constFreeText)) {
$newfreetext .= make_substitutions(getDolGlobalString($constFreeText), $substitutionarray);
}
- if (!empty($conf->global->TAKEPOS_FOOTER)) {
+ if (getDolGlobalString('TAKEPOS_FOOTER')) {
$newfreetext .= make_substitutions(getDolGlobalString('TAKEPOS_FOOTER'), $substitutionarray);
}
print $newfreetext;
diff --git a/htdocs/theme/eldy/dropdown.inc.php b/htdocs/theme/eldy/dropdown.inc.php
index 87681ac023c..ac0b25e8f82 100644
--- a/htdocs/theme/eldy/dropdown.inc.php
+++ b/htdocs/theme/eldy/dropdown.inc.php
@@ -549,10 +549,18 @@ dropdown-holder {
background: none;
color: #000 !important;
}
+.dropdown-content a.butAction {
+ display: flex;
+}
.dropdown-content .butAction:hover {
box-shadow: none;
text-decoration: underline;
}
+.dropdown-content .butActionRefused {
+ margin-left: 0;
+ margin-right: 0;
+ border: none;
+}
.dropdown-holder.open .dropdown-content {
display: block;
diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php
index a7b1dc20082..850b145fd08 100644
--- a/htdocs/theme/eldy/global.inc.php
+++ b/htdocs/theme/eldy/global.inc.php
@@ -191,7 +191,7 @@ th.wrapcolumntitle dl dt a span.fas.fa-list {
.liste_titre input[name=search_day_date_when], .liste_titre input[name=search_month_date_when], .liste_titre input[name=search_year_date_when],
.liste_titre input[name=search_dtstartday], .liste_titre input[name=search_dtendday], .liste_titre input[name=search_dtstartmonth], .liste_titre input[name=search_dtendmonth],
*/
-.liste_titre input[name=search_month] {
+.liste_titre input[name=search_month], .liste_titre input[name=search_month_start], .liste_titre input[name=search_month_end] {
margin-right: 4px;
}
@@ -425,9 +425,12 @@ a.butStatus {
margin: 0 0.45em !important;
}
-span.userimg.notfirst {
+span.userimg.notfirst, div.userimg.notfirst {
margin-left: -5px;
}
+div.userimg.notfirst {
+ display: block-inline;
+}
/* Used by timesheets */
span.timesheetalreadyrecorded input {
@@ -3147,6 +3150,13 @@ img.userphoto { /* size for user photo in lists */
background-size: contain;
vertical-align: middle;
}
+span.userimg div.userphoto {
+ background-color: #eee;
+ border-radius: 0.72em;
+ width: 1.4em;
+ height: 1.4em;
+ padding-top: 1px;
+}
img.userphotosmall { /* size for user photo in lists */
border-radius: 0.6em;
width: 1.2em;
@@ -4968,7 +4978,7 @@ table.table-fiche-title {
}
-div.backgreypublicpayment { background-color: #f0f0f0; padding: 20px; border-bottom: 1px solid #ddd; }
+div.backgreypublicpayment { background-color: #f0f0f0; padding: 20px; border-bottom: 1px solid #ddd; text-align: center; }
.backgreypublicpayment a { color: #222 !important; }
.poweredbypublicpayment {
float: right;
@@ -5062,7 +5072,7 @@ div#card-errors {
/* ============================================================================== */
-/* Formulaire confirmation (When Ajax JQuery is used) and Dialog popups */
+/* Form confirmation (When Ajax JQuery is used) and Dialog popups */
/* ============================================================================== */
.ui-dialog-titlebar {
@@ -5072,7 +5082,10 @@ div#card-errors {
.ui-dialog.ui-corner-all.ui-widget.ui-widget-content.ui-front.ui-draggable {
z-index: 1005 !important; /* Default 101 with ui-jquery, top menu have a z-index of 1000 */
}
-
+.ui-dialog.ui-widget.ui-widget-content {
+ border: 1px solid #e0e0e0;
+ border-radius: 6px;
+}
/* ============================================================================== */
/* For content of image preview */
@@ -7685,6 +7698,35 @@ table.jPicker {
border: 1px solid #bbb !important;
}
+/* ============================================================================== */
+/* CSS style used for survey */
+/* ============================================================================== */
+
+.opensurveydescription * {
+ width: 100%;
+}
+.imgopensurveywizard
+{
+ padding: 0 4px 0 4px;
+}
+.survey_borders {
+ margin-left: 100px;
+ margin-right: 100px;
+ text-align: start;
+}
+.survey_intro {
+ background-color: #f0f0f0;
+ padding: 15px;
+ border-radius: 8px;
+}
+.survey_borders .resultats .nom {
+ text-align:
+}
+.survey_borders .resultats .sujet, .survey_borders .resultats .jour {
+ min-width: 100px;
+}
+
+
/* ============================================================================== */
/* CSS style used for small screen */
/* ============================================================================== */
@@ -7693,10 +7735,6 @@ table.jPicker {
background-size: 22px auto;
top: 2px;
}
-.imgopensurveywizard
-{
- padding: 0 4px 0 4px;
-}
@media only screen and (max-width: 767px)
{
.imgopensurveywizard, .imgautosize { width:95%; height: auto; }
@@ -7742,6 +7780,12 @@ table.jPicker {
.poweredbyimg {
width: 48px;
}
+
+ .survey_borders {
+ margin-left: 10px;
+ margin-right: 10px;
+ text-align: start;
+ }
}
@media only screen and (max-width: 1024px)
@@ -7796,7 +7840,7 @@ table.jPicker {
max-width: 370px;
}
}
-/* rule to reduce top menu - 2nd reduction: Reduce width of top menu icons again */
+/* rule to reduce top menu - 2nd reduction: Reduce width of top menu icons again ( menu entries) */
@media only screen and (max-width: global->THEME_ELDY_WITDHOFFSET_FOR_REDUC2) ? round($nbtopmenuentries * 69, 0) + 130 : $conf->global->THEME_ELDY_WITDHOFFSET_FOR_REDUC2; ?>px) /* reduction 2 */
{
li.tmenucompanylogo {
@@ -7806,16 +7850,16 @@ table.jPicker {
height: 23px;
}
div.tmenucenter {
- max-width: px; /* size of viewport */
- text-overflow: clip;
+ max-width: px; /* size of viewport */
+ text-overflow: clip;
}
span.mainmenuaspan {
margin-left: 1px;
}
.mainmenuaspan {
- font-size: 0.9em;
- padding-left: 0;
- padding-right: 0;
+ font-size: 0.9em;
+ padding-left: 0;
+ padding-right: 0;
}
.topmenuimage {
background-size: 20px auto;
diff --git a/htdocs/theme/eldy/manifest.json.php b/htdocs/theme/eldy/manifest.json.php
index 1355722a875..1fe54edfd63 100644
--- a/htdocs/theme/eldy/manifest.json.php
+++ b/htdocs/theme/eldy/manifest.json.php
@@ -77,8 +77,8 @@ if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
$manifest->short_name = $manifest->name;
-$manifest->theme_color = !empty($conf->global->MAIN_MANIFEST_APPLI_THEME_COLOR) ? $conf->global->MAIN_MANIFEST_APPLI_THEME_COLOR : '#F05F40';
-$manifest->background_color = !empty($conf->global->MAIN_MANIFEST_APPLI_BG_COLOR) ? $conf->global->MAIN_MANIFEST_APPLI_BG_COLOR : "#ffffff";
+$manifest->theme_color = empty($conf->global->MAIN_MANIFEST_APPLI_THEME_COLOR) ? getDolGlobalString('THEME_ELDY_TOPMENU_BACK1', '#F05F40') : $conf->global->MAIN_MANIFEST_APPLI_THEME_COLOR;
+$manifest->background_color = empty($conf->global->MAIN_MANIFEST_APPLI_BG_COLOR) ? "#ffffff" : $conf->global->MAIN_MANIFEST_APPLI_BG_COLOR;
$manifest->display = "standalone";
$manifest->splash_pages = null;
$manifest->icons = array();
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php
index ee8c02d1131..05c16635b53 100644
--- a/htdocs/theme/eldy/style.css.php
+++ b/htdocs/theme/eldy/style.css.php
@@ -265,12 +265,11 @@ $colortext = join(',', colorStringToArray($colortext));
$colortextlink = join(',', colorStringToArray($colortextlink));
$nbtopmenuentries = $menumanager->showmenu('topnb');
-
+$nbtopmenuentriesreal = $nbtopmenuentries;
if ($conf->browser->layout == 'phone') {
$nbtopmenuentries = max($nbtopmenuentries, 10);
}
-
$minwidthtmenu = 66; /* minimum width for one top menu entry */
$heightmenu = 50; /* height of top menu, part with image */
$heightmenu2 = 49; /* height of top menu, part with login */
diff --git a/htdocs/theme/eldy/timeline.inc.php b/htdocs/theme/eldy/timeline.inc.php
index a4fa4ee29b3..e8790738898 100644
--- a/htdocs/theme/eldy/timeline.inc.php
+++ b/htdocs/theme/eldy/timeline.inc.php
@@ -145,6 +145,7 @@ a.timeline-btn:hover
padding: 10px;
}
.timeline > li > .fa,
+.timeline > li > .fas,
.timeline > li > .glyphicon,
.timeline > li > .ion {
width: 30px;
@@ -212,6 +213,11 @@ a.timeline-btn:hover
margin-right: 5px;
}
+.messaging-author {
+ width: 100px;
+}
+
+
/* Force values for small screen 767 */
@media only screen and (max-width: 767px)
{
diff --git a/htdocs/theme/md/dropdown.inc.php b/htdocs/theme/md/dropdown.inc.php
index 56d7e20b4f4..45551b36842 100644
--- a/htdocs/theme/md/dropdown.inc.php
+++ b/htdocs/theme/md/dropdown.inc.php
@@ -553,10 +553,18 @@ dropdown-holder {
background: none;
color: #000 !important;
}
+.dropdown-content a.butAction {
+ display: flex;
+}
.dropdown-content .butAction:hover {
box-shadow: none;
text-decoration: underline;
}
+.dropdown-content .butActionRefused {
+ margin-left: 0;
+ margin-right: 0;
+ border: none;
+}
.dropdown-holder.open .dropdown-content {
display: block;
diff --git a/htdocs/theme/md/manifest.json.php b/htdocs/theme/md/manifest.json.php
index 6a7dd646ecf..887fb2f9564 100644
--- a/htdocs/theme/md/manifest.json.php
+++ b/htdocs/theme/md/manifest.json.php
@@ -75,9 +75,8 @@ if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
}
$manifest->short_name = $manifest->name;
-
-$manifest->theme_color = !empty($conf->global->MAIN_MANIFEST_APPLI_THEME_COLOR) ? $conf->global->MAIN_MANIFEST_APPLI_THEME_COLOR : '#F05F40';
-$manifest->background_color = !empty($conf->global->MAIN_MANIFEST_APPLI_BG_COLOR) ? $conf->global->MAIN_MANIFEST_APPLI_BG_COLOR : "#ffffff";
+$manifest->theme_color = empty($conf->global->MAIN_MANIFEST_APPLI_THEME_COLOR) ? getDolGlobalString('THEME_ELDY_TOPMENU_BACK1', '#F05F40') : $conf->global->MAIN_MANIFEST_APPLI_THEME_COLOR;
+$manifest->background_color = empty($conf->global->MAIN_MANIFEST_APPLI_BG_COLOR) ? "#ffffff" : $conf->global->MAIN_MANIFEST_APPLI_BG_COLOR;
$manifest->display = "standalone";
$manifest->splash_pages = null;
$manifest->icons = array();
diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php
index 71d1d49f3ee..315f3caafbf 100644
--- a/htdocs/theme/md/style.css.php
+++ b/htdocs/theme/md/style.css.php
@@ -271,6 +271,7 @@ $colortext = join(',', colorStringToArray($colortext));
$colortextlink = join(',', colorStringToArray($colortextlink));
$nbtopmenuentries = $menumanager->showmenu('topnb');
+$nbtopmenuentriesreal = $nbtopmenuentries;
if ($conf->browser->layout == 'phone') {
$nbtopmenuentries = max($nbtopmenuentries, 10);
}
@@ -494,7 +495,7 @@ th.wrapcolumntitle dl dt a span.fas.fa-list {
vertical-align: bottom;
}
-.liste_titre input[name=month_date_when], .liste_titre input[name=monthvalid], .liste_titre input[name=search_ordermonth], .liste_titre input[name=search_deliverymonth],
+/*.liste_titre input[name=month_date_when], .liste_titre input[name=monthvalid], .liste_titre input[name=search_ordermonth], .liste_titre input[name=search_deliverymonth],
.liste_titre input[name=search_smonth], .liste_titre input[name=search_month], .liste_titre input[name=search_emonth], .liste_titre input[name=smonth], .liste_titre input[name=month],
.liste_titre input[name=month_lim], .liste_titre input[name=month_start], .liste_titre input[name=month_end], .liste_titre input[name=month_create],
.liste_titre input[name=search_month_lim], .liste_titre input[name=search_month_start], .liste_titre input[name=search_month_end], .liste_titre input[name=search_month_create],
@@ -506,10 +507,15 @@ th.wrapcolumntitle dl dt a span.fas.fa-list {
.liste_titre input[name=search_day_create], .liste_titre input[name=search_day_start], .liste_titre input[name=search_day_end],
.liste_titre input[name=search_day_date_when], .liste_titre input[name=search_month_date_when], .liste_titre input[name=search_year_date_when],
.liste_titre input[name=search_dtstartday], .liste_titre input[name=search_dtendday], .liste_titre input[name=search_dtstartmonth], .liste_titre input[name=search_dtendmonth],
+*/
+.liste_titre input[name=search_month], .liste_titre input[name=search_month_start], .liste_titre input[name=search_month_end] {
+ margin-right: 4px;
+}
select#date_startday, select#date_startmonth, select#date_endday, select#date_endmonth, select#reday, select#remonth
{
margin-right: 4px;
}
+
input, input.flat, textarea, textarea.flat, form.flat select, select, select.flat, .dataTables_length label select {
color: var(--colortext);
border: none;
@@ -682,9 +688,12 @@ a.butStatus {
margin: 0 0.45em !important;
}
-span.userimg.notfirst {
+span.userimg.notfirst, div.userimg.notfirst {
margin-left: -5px;
}
+div.userimg.notfirst {
+ display: block-inline;
+}
/* Used by timesheets */
span.timesheetalreadyrecorded input {
@@ -5012,7 +5021,7 @@ table.table-fiche-title .col-title div.titre, .col-right .btnTitle-icon {
line-height: 40px;
}
-div.backgreypublicpayment { background-color: #f0f0f0; padding: 20px; border-bottom: 1px solid #ddd; }
+div.backgreypublicpayment { background-color: #f0f0f0; padding: 20px; border-bottom: 1px solid #ddd; text-align: center; }
.backgreypublicpayment a { color: #222 !important; }
.poweredbypublicpayment {
float: right;
@@ -5101,7 +5110,7 @@ div#card-errors {
/* ============================================================================== */
-/* Formulaire confirmation (When Ajax JQuery is used) and Dialog popups */
+/* Form confirmation (When Ajax JQuery is used) and Dialog popups */
/* ============================================================================== */
.ui-dialog-titlebar {
@@ -5113,6 +5122,11 @@ div#card-errors {
z-index: 1005 !important; /* Default 101 with ui-jquery, top menu have a z-index of 1000 */
}
+.ui-dialog.ui-widget.ui-widget-content {
+ border: 1px solid #e0e0e0;
+ border-radius: 6px;
+}
+
div#dialogforpopup {
background-color: #f8f8f8 !important;
}
@@ -7612,13 +7626,38 @@ table.jPicker {
}
/* ============================================================================== */
-/* CSS style used for small screen */
+/* CSS style used for survey */
/* ============================================================================== */
+.opensurveydescription * {
+ width: 100%;
+}
.imgopensurveywizard
{
padding: 0 4px 0 4px;
}
+.survey_borders {
+ margin-left: 100px;
+ margin-right: 100px;
+ text-align: start;
+}
+.survey_intro {
+ background-color: #f0f0f0;
+ padding: 15px;
+ border-radius: 8px;
+}
+.survey_borders .resultats .nom {
+ text-align:
+}
+.survey_borders .resultats .sujet {
+ min-width: 100px;
+}
+
+
+/* ============================================================================== */
+/* CSS style used for small screen */
+/* ============================================================================== */
+
@media only screen and (max-width: 767px)
{
.imgopensurveywizard, .imgautosize { width:95%; height: auto; }
@@ -7660,6 +7699,12 @@ table.jPicker {
.poweredbyimg {
width: 48px;
}
+
+ .survey_borders {
+ margin-left: 10px;
+ margin-right: 10px;
+ text-align: start;
+ }
}
@media only screen and (max-width: 1024px)
@@ -7714,7 +7759,7 @@ table.jPicker {
}
div.tmenucenter {
- max-width: 24px; /* size of viewport */
+ max-width: px; /* size of viewport */
text-overflow: clip;
}
.mainmenuaspan {
diff --git a/htdocs/ticket/agenda.php b/htdocs/ticket/agenda.php
index c6e4cff0b38..39d25c3a215 100644
--- a/htdocs/ticket/agenda.php
+++ b/htdocs/ticket/agenda.php
@@ -166,9 +166,9 @@ if ($socid > 0) {
}
if (!$user->socid && !empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY)) {
- $object->next_prev_filter = "te.fk_user_assign = '".$user->id."'";
+ $object->next_prev_filter = "te.fk_user_assign = ".((int) $user->id);
} elseif ($user->socid > 0) {
- $object->next_prev_filter = "te.fk_soc = '".$user->socid."'";
+ $object->next_prev_filter = "te.fk_soc = ".((int) $user->socid);
}
$head = ticket_prepare_head($object);
diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php
index cc6043e5718..f6f26a13c7f 100755
--- a/htdocs/ticket/card.php
+++ b/htdocs/ticket/card.php
@@ -217,7 +217,8 @@ if (empty($reshook)) {
$db->begin();
$getRef = GETPOST("ref", 'alphanohtml');
- if ($object->fetch('', $getRef) > 0) {
+ $test = new Ticket($db);
+ if ($test->fetch('', $getRef) > 0) {
$object->ref = $object->getDefaultRef();
$object->track_id = null;
setEventMessage($langs->trans('TicketRefAlreadyUsed', $getRef, $object->ref));
@@ -225,7 +226,7 @@ if (empty($reshook)) {
$object->ref = $getRef;
}
- $object->fk_soc = GETPOST("socid", 'int') > 0 ? GETPOST("socid", 'int') : 0;
+ $object->fk_soc = $object->socid = GETPOST("socid", 'int') > 0 ? GETPOST("socid", 'int') : 0;
$object->subject = GETPOST("subject", 'alphanohtml');
$object->message = GETPOST("message", 'restricthtml');
@@ -235,7 +236,7 @@ if (empty($reshook)) {
$object->category_label = $langs->trans($langs->getLabelFromKey($db, $object->category_code, 'c_ticket_category', 'code', 'label'));
$object->severity_code = GETPOST("severity_code", 'alpha');
$object->severity_label = $langs->trans($langs->getLabelFromKey($db, $object->severity_code, 'c_ticket_severity', 'code', 'label'));
- $object->email_from = $user->email;
+ $object->email_from = $object->origin_email = $user->email;
$notifyTiers = GETPOST("notify_tiers_at_create", 'alpha');
$object->notify_tiers_at_create = empty($notifyTiers) ? 0 : 1;
$fk_user_assign = GETPOST("fk_user_assign", 'int');
@@ -448,8 +449,6 @@ if (empty($reshook)) {
if (!$error) {
// Log action in ticket logs table
$object->fetch_user($usertoassign);
- //$log_action = $langs->trans('TicketLogAssignedTo', $object->user->getFullName($langs));
-
setEventMessages($langs->trans('TicketAssigned'), null, 'mesgs');
header("Location: card.php?track_id=".$object->track_id);
@@ -499,9 +498,6 @@ if (empty($reshook)) {
if ($_SESSION['email_customer'] == $object->origin_email || $_SESSION['email_customer'] == $object->thirdparty->email) {
$object->close($user);
- // Log action in ticket logs table
- //$log_action = $langs->trans('TicketLogClosedBy', $_SESSION['email_customer']);
-
setEventMessages(''.$langs->trans('TicketMarkedAsClosed').'
', null, 'mesgs');
$url = 'card.php?track_id='.GETPOST('track_id', 'alpha');
@@ -588,9 +584,6 @@ if (empty($reshook)) {
if ($object->status == Ticket::STATUS_CLOSED || $object->status == Ticket::STATUS_CANCELED) {
$res = $object->setStatut(Ticket::STATUS_ASSIGNED);
if ($res) {
- // Log action in ticket logs table
- //$log_action = $langs->trans('TicketLogReopen');
-
$url = 'card.php?track_id='.$object->track_id;
header("Location: ".$url);
exit();
@@ -619,15 +612,13 @@ if (empty($reshook)) {
} elseif ($action == "set_message" && $user->rights->ticket->manage) {
if (!GETPOST('cancel')) {
$object->fetch('', '', GETPOST('track_id', 'alpha'));
- $oldvalue_message = $object->message;
+ //$oldvalue_message = $object->message;
$fieldtomodify = GETPOST('message_initial', 'restricthtml');
$object->message = $fieldtomodify;
$ret = $object->update($user);
if ($ret > 0) {
- //$log_action = $langs->trans('TicketInitialMessageModified')." \n";
- // include the Diff class
- include_once DOL_DOCUMENT_ROOT.'/core/class/utils_diff.class.php';
+ //include_once DOL_DOCUMENT_ROOT.'/core/class/utils_diff.class.php';
// output the result of comparing two files as plain text
//$log_action .= Diff::toString(Diff::compare(strip_tags($oldvalue_message), strip_tags($object->message)));
@@ -643,12 +634,9 @@ if (empty($reshook)) {
// Reopen ticket
if ($object->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) {
$new_status = GETPOST('new_status', 'int');
- $old_status = $object->status;
+ //$old_status = $object->status;
$res = $object->setStatut($new_status);
if ($res) {
- // Log action in ticket logs table
- $log_action = $langs->trans('TicketLogStatusChanged', $langs->transnoentities($object->statuts_short[$old_status]), $langs->transnoentities($object->statuts_short[$new_status]));
-
$url = 'card.php?track_id='.$object->track_id;
header("Location: ".$url);
exit();
@@ -693,8 +681,6 @@ if (empty($reshook)) {
$ret = $object->update($user);
if ($ret > 0) {
- //$log_action = $langs->trans('TicketLogPropertyChanged', $oldvalue_label, $newvalue_label);
-
setEventMessages($langs->trans('TicketUpdated'), null, 'mesgs');
} else {
$error++;
@@ -890,7 +876,7 @@ if ($action == 'create' || $action == 'presend') {
// Define a complementary filter for search of next/prev ref.
if (empty($user->rights->projet->all->lire)) {
$objectsListId = $projectstat->getProjectsAuthorizedForUser($user, $mine, 0);
- $projectstat->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
+ $projectstat->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
}
print $form->showrefnav($projectstat, 'ref', $linkback, 1, 'ref', 'ref', '');
print ' ';
@@ -940,9 +926,9 @@ if ($action == 'create' || $action == 'presend') {
}
if (!$user->socid && !empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY)) {
- $object->next_prev_filter = "te.fk_user_assign = '".$user->id."'";
+ $object->next_prev_filter = "te.fk_user_assign = ".((int) $user->id);
} elseif ($user->socid > 0) {
- $object->next_prev_filter = "te.fk_soc = '".$user->socid."'";
+ $object->next_prev_filter = "te.fk_soc = ".((int) $user->socid);
}
$head = ticket_prepare_head($object);
@@ -1018,7 +1004,7 @@ if ($action == 'create' || $action == 'presend') {
if ($permissiontoedit) {
$morehtmlref .= img_picto($langs->trans("Contract"), 'contract', 'class="pictofixedwidth"');
if ($action == 'edit_contrat') {
- $formcontract = new Formcontract($db);
+ $formcontract = new FormContract($db);
$morehtmlref .= $formcontract->formSelectContract($_SERVER["PHP_SELF"].'?id='.$object->id, $object->socid, $object->fk_contract, 'contratid', 0, 1, 1, 1);
} else {
$morehtmlref .= 'id.'">';
@@ -1259,7 +1245,7 @@ if ($action == 'create' || $action == 'presend') {
print ' ';
} else {
// Button to edit Properties
- if (isset($object->status) && $object->status < $object::STATUS_NEED_MORE_INFO && $user->rights->ticket->write) {
+ if (isset($object->status) && ($object->status < $object::STATUS_NEED_MORE_INFO || !empty($conf->global->TICKET_ALLOW_CLASSIFICATION_MODIFICATION_EVEN_IF_CLOSED)) && $user->rights->ticket->write) {
print ' '.img_edit($langs->trans('Modify')).' ';
}
}
diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php
index e65c3e58050..59b4af40b34 100644
--- a/htdocs/ticket/class/actions_ticket.class.php
+++ b/htdocs/ticket/class/actions_ticket.class.php
@@ -301,7 +301,7 @@ class ActionsTicket extends CommonHookActions
//print '';
print ' ';
print '';
- print img_picto('', 'object_action', 'class="paddingright"').dol_print_date($arraymsgs['datec'], 'dayhour');
+ print img_picto('', 'object_action', 'class="paddingright"').dol_print_date($arraymsgs['datep'], 'dayhour');
print ' ';
if ($show_user) {
print '';
diff --git a/htdocs/ticket/class/cticketcategory.class.php b/htdocs/ticket/class/cticketcategory.class.php
index 5fe39fe4660..38a4214f2b6 100644
--- a/htdocs/ticket/class/cticketcategory.class.php
+++ b/htdocs/ticket/class/cticketcategory.class.php
@@ -518,7 +518,7 @@ class CTicketCategory extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php
index 86b9333e9a5..08334b5efea 100644
--- a/htdocs/ticket/class/ticket.class.php
+++ b/htdocs/ticket/class/ticket.class.php
@@ -1401,7 +1401,7 @@ class Ticket extends CommonObject
*/
public function getLibStatut($mode = 0)
{
- return $this->libStatut($this->fk_statut, $mode, 0, $this->progress);
+ return $this->LibStatut($this->fk_statut, $mode, 0, $this->progress);
}
@@ -1522,9 +1522,7 @@ class Ticket extends CommonObject
*/
public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
{
- global $db, $conf, $langs;
- global $dolibarr_main_authentication, $dolibarr_main_demo;
- global $menumanager;
+ global $conf, $langs;
if (!empty($conf->dol_no_mouse_hover)) {
$notooltip = 1; // Force disable tooltips
@@ -1553,7 +1551,7 @@ class Ticket extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
@@ -1579,7 +1577,7 @@ class Ticket extends CommonObject
$result .= $linkstart;
if ($withpicto) {
- $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
+ $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
}
if ($withpicto != 2) {
$result .= $this->ref;
@@ -1649,7 +1647,7 @@ class Ticket extends CommonObject
}
/**
- * Mark a message as read
+ * Set an assigned user to a ticket.
*
* @param User $user Object user
* @param int $id_assign_user ID of user assigned
@@ -1658,8 +1656,6 @@ class Ticket extends CommonObject
*/
public function assignUser($user, $id_assign_user, $notrigger = 0)
{
- global $conf, $langs;
-
$error = 0;
$this->oldcopy = dol_clone($this);
@@ -1801,11 +1797,11 @@ class Ticket extends CommonObject
// Cache already loaded
- $sql = "SELECT id as rowid, fk_user_author, email_from, datec, label, note as message, code";
+ $sql = "SELECT id as rowid, fk_user_author, email_from, datec, datep, label, note as message, code";
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm";
$sql .= " WHERE fk_element = ".(int) $this->id;
$sql .= " AND elementtype = 'ticket'";
- $sql .= " ORDER BY datec DESC";
+ $sql .= " ORDER BY datep DESC";
dol_syslog(get_class($this)."::load_cache_actions_ticket", LOG_DEBUG);
$resql = $this->db->query($sql);
@@ -1820,6 +1816,7 @@ class Ticket extends CommonObject
$this->cache_msgs_ticket[$i]['fk_contact_author'] = $obj->email_from;
}
$this->cache_msgs_ticket[$i]['datec'] = $this->db->jdate($obj->datec);
+ $this->cache_msgs_ticket[$i]['datep'] = $this->db->jdate($obj->datep);
$this->cache_msgs_ticket[$i]['subject'] = $obj->label;
$this->cache_msgs_ticket[$i]['message'] = $obj->message;
$this->cache_msgs_ticket[$i]['private'] = (preg_match('/^TICKET_MSG_PRIVATE/', $obj->code) ? 1 : 0);
diff --git a/htdocs/ticket/contact.php b/htdocs/ticket/contact.php
index 8af633dc140..ba678ae2dca 100644
--- a/htdocs/ticket/contact.php
+++ b/htdocs/ticket/contact.php
@@ -195,9 +195,9 @@ if ($id > 0 || !empty($track_id) || !empty($ref)) {
}
if (!$user->socid && !empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY)) {
- $object->next_prev_filter = "te.fk_user_assign = '".$user->id."'";
+ $object->next_prev_filter = "te.fk_user_assign ='".((int) $user->id);
} elseif ($user->socid > 0) {
- $object->next_prev_filter = "te.fk_soc = '".$user->socid."'";
+ $object->next_prev_filter = "te.fk_soc = ".((int) $user->socid);
}
$head = ticket_prepare_head($object);
diff --git a/htdocs/ticket/document.php b/htdocs/ticket/document.php
index bb078104b05..23e0b00882c 100644
--- a/htdocs/ticket/document.php
+++ b/htdocs/ticket/document.php
@@ -133,9 +133,9 @@ if ($object->id) {
}
if (!$user->socid && !empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY)) {
- $object->next_prev_filter = "te.fk_user_assign = '".$user->id."'";
+ $object->next_prev_filter = "te.fk_user_assign = ".((int) $user->id);
} elseif ($user->socid > 0) {
- $object->next_prev_filter = "te.fk_soc = '".$user->socid."'";
+ $object->next_prev_filter = "te.fk_soc = ".((int) $user->socid);
}
$head = ticket_prepare_head($object);
diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php
index 27e7ca09d3f..b661717aaa0 100644
--- a/htdocs/ticket/list.php
+++ b/htdocs/ticket/list.php
@@ -604,7 +604,7 @@ if ($projectid > 0 || $project_ref) {
// Define a complementary filter for search of next/prev ref.
if (empty($user->rights->projet->all->lire)) {
$objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
- $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
+ $object->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
}
dol_banner_tab($object, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
diff --git a/htdocs/ticket/messaging.php b/htdocs/ticket/messaging.php
index a80b7727e08..e0926da74f0 100644
--- a/htdocs/ticket/messaging.php
+++ b/htdocs/ticket/messaging.php
@@ -162,9 +162,9 @@ if ($socid > 0) {
}
if (!$user->socid && !empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY)) {
- $object->next_prev_filter = "te.fk_user_assign = '".$user->id."'";
+ $object->next_prev_filter = "te.fk_user_assign = ".((int) $user->id);
} elseif ($user->socid > 0) {
- $object->next_prev_filter = "te.fk_soc = '".$user->socid."'";
+ $object->next_prev_filter = "te.fk_soc = ".((int) $user->socid);
}
$head = ticket_prepare_head($object);
diff --git a/htdocs/user/card.php b/htdocs/user/card.php
index 543e6806674..354c5350a63 100644
--- a/htdocs/user/card.php
+++ b/htdocs/user/card.php
@@ -74,7 +74,7 @@ $group = GETPOST("group", "int", 3);
$cancel = GETPOST('cancel', 'alpha');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'useracard'; // To manage different context of search
-if (empty($id)) {
+if (empty($id) && $action != 'create') {
$id = $user->id;
}
@@ -134,7 +134,8 @@ if ($id > 0) {
// $user is the current logged user, $id is the user we want to edit
$canedituser = (($user->id == $id) && $user->hasRight("user", "self", "write")) || (($user->id != $id) && $user->hasRight("user", "user", "write"));
$caneditfield = ((($user->id == $id) && $user->hasRight("user", "self", "write")) || (($user->id != $id) && $user->hasRight("user", "user", "write")));
- $caneditpassword = ((($user->id == $id) && $user->hasRight("user", "self", "password")) || (($user->id != $id) && $user->hasRight("user", "user", "password")));
+ $caneditpasswordandsee = ((($user->id == $id) && $user->hasRight("user", "self", "password")) || (($user->id != $id) && $user->hasRight("user", "user", "password") && $user->admin));
+ $caneditpasswordandsend = ((($user->id == $id) && $user->hasRight("user", "self", "password")) || (($user->id != $id) && $user->hasRight("user", "user", "password")));
}
@@ -350,7 +351,7 @@ if (empty($reshook)) {
if (GETPOST('password', 'none')) {
$resPass = $object->setPassword($user, GETPOST('password', 'none'));
}
- if ($resPass < 0) {
+ if (is_int($resPass) && $resPass < 0) {
$langs->load("errors");
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
@@ -439,10 +440,10 @@ if (empty($reshook)) {
$object->national_registration_number = GETPOST("national_registration_number", 'alphanohtml');
}
$object->gender = GETPOST("gender", 'aZ09');
- if ($caneditpassword) {
+ if ($caneditpasswordandsee) {
$object->pass = GETPOST("password", 'none'); // We can keep 'none' for password fields
}
- if ($caneditpassword || $user->hasRight("api", "apikey", "generate")) {
+ if ($caneditpasswordandsee || $user->hasRight("api", "apikey", "generate")) {
$object->api_key = (GETPOST("api_key", 'alphanohtml')) ? GETPOST("api_key", 'alphanohtml') : $object->api_key;
}
if (!empty($user->admin) && $user->id != $id) {
@@ -654,7 +655,7 @@ if (empty($reshook)) {
}
}
} else {
- if ($caneditpassword) { // Case we can edit only password
+ if ($caneditpasswordandsee) { // Case we can edit only password
dol_syslog("Not allowed to change fields, only password");
$object->fetch($id);
@@ -663,7 +664,7 @@ if (empty($reshook)) {
$object->oldcopy = clone $object;
$ret = $object->setPassword($user, GETPOST("password", "none"));
- if ($ret < 0) {
+ if (is_int($ret) && $ret < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
@@ -672,13 +673,13 @@ if (empty($reshook)) {
}
// Change password with a new generated one
- if ((($action == 'confirm_password' && $confirm == 'yes')
- || ($action == 'confirm_passwordsend' && $confirm == 'yes')) && $caneditpassword
+ if ((($action == 'confirm_password' && $confirm == 'yes' && $caneditpasswordandsee)
+ || ($action == 'confirm_passwordsend' && $confirm == 'yes' && $caneditpasswordandsend))
) {
$object->fetch($id);
$newpassword = $object->setPassword($user, ''); // This will generate a new password
- if ($newpassword < 0) {
+ if (is_int($newpassword) && $newpassword < 0) {
// Echec
setEventMessages($langs->trans("ErrorFailedToSetNewPassword"), null, 'errors');
} else {
@@ -695,27 +696,32 @@ if (empty($reshook)) {
}
}
- // Action initialisation donnees depuis record LDAP
+ // Action to initialize data from a LDAP record
if ($action == 'adduserldap' && $canadduser) {
$selecteduser = GETPOST('users');
$required_fields = array(
- $conf->global->LDAP_KEY_USERS,
- $conf->global->LDAP_FIELD_NAME,
- $conf->global->LDAP_FIELD_FIRSTNAME,
- $conf->global->LDAP_FIELD_LOGIN,
- $conf->global->LDAP_FIELD_LOGIN_SAMBA,
- $conf->global->LDAP_FIELD_PASSWORD,
- $conf->global->LDAP_FIELD_PASSWORD_CRYPTED,
- $conf->global->LDAP_FIELD_PHONE,
- $conf->global->LDAP_FIELD_FAX,
- $conf->global->LDAP_FIELD_MOBILE,
- $conf->global->LDAP_FIELD_SKYPE,
- $conf->global->LDAP_FIELD_MAIL,
- $conf->global->LDAP_FIELD_TITLE,
- $conf->global->LDAP_FIELD_DESCRIPTION,
- $conf->global->LDAP_FIELD_SID
+ getDolGlobalString('LDAP_KEY_USERS'),
+ getDolGlobalString('LDAP_FIELD_NAME'),
+ getDolGlobalString('LDAP_FIELD_FIRSTNAME'),
+ getDolGlobalString('LDAP_FIELD_LOGIN'),
+ getDolGlobalString('LDAP_FIELD_LOGIN_SAMBA'),
+ getDolGlobalString('LDAP_FIELD_PASSWORD'),
+ getDolGlobalString('LDAP_FIELD_PASSWORD_CRYPTED'),
+ getDolGlobalString('LDAP_FIELD_PHONE'),
+ getDolGlobalString('LDAP_FIELD_FAX'),
+ getDolGlobalString('LDAP_FIELD_MOBILE'),
+ getDolGlobalString('LDAP_FIELD_MAIL'),
+ getDolGlobalString('LDAP_FIELD_TITLE'),
+ getDolGlobalString('LDAP_FIELD_DESCRIPTION'),
+ getDolGlobalString('LDAP_FIELD_SID')
);
+ if (isModEnabled('socialnetworks')) {
+ $arrayofsocialnetworks = array('skype', 'twitter', 'facebook', 'linkedin');
+ foreach ($arrayofsocialnetworks as $socialnetwork) {
+ $required_fields[] = getDolGlobalString('LDAP_FIELD_'.strtoupper($socialnetwork));
+ }
+ }
$ldap = new Ldap();
$result = $ldap->connect_bind();
@@ -737,12 +743,15 @@ if (empty($reshook)) {
$ldap_phone = $attribute[$conf->global->LDAP_FIELD_PHONE];
$ldap_fax = $attribute[$conf->global->LDAP_FIELD_FAX];
$ldap_mobile = $attribute[$conf->global->LDAP_FIELD_MOBILE];
- $ldap_social['skype'] = $attribute[$conf->global->LDAP_FIELD_SKYPE];
- $ldap_social['twitter'] = $attribute[$conf->global->LDAP_FIELD_TWITTER];
- $ldap_social['facebook'] = $attribute[$conf->global->LDAP_FIELD_FACEBOOK];
- $ldap_social['linkedin'] = $attribute[$conf->global->LDAP_FIELD_LINKEDIN];
$ldap_mail = $attribute[$conf->global->LDAP_FIELD_MAIL];
$ldap_sid = $attribute[$conf->global->LDAP_FIELD_SID];
+
+ if (isModEnabled('socialnetworks')) {
+ $arrayofsocialnetworks = array('skype', 'twitter', 'facebook', 'linkedin');
+ foreach ($arrayofsocialnetworks as $socialnetwork) {
+ $ldap_social[$socialnetwork] = $attribute[getDolGlobalString('LDAP_FIELD_'.strtoupper($socialnetwork))];
+ }
+ }
}
}
} else {
@@ -953,7 +962,7 @@ if ($action == 'create' || $action == 'adduserldap') {
// Administrator
if (!empty($user->admin)) {
- print ' '.$langs->trans("Administrator").' ';
+ print ''.$form->textwithpicto($langs->trans("Administrator"), $langs->trans("AdministratorDesc"), 1, 'star').' ';
print '';
print $form->selectyesno('admin', GETPOST('admin'), 1, false, 0, 1);
@@ -1133,7 +1142,7 @@ if ($action == 'create' || $action == 'adduserldap') {
// Country
print ' '.$form->editfieldkey('Country', 'selectcountry_id', '', $object, 0).' ';
print img_picto('', 'country', 'class="pictofixedwidth"');
- print $form->select_country((GETPOST('country_id') != '' ?GETPOST('country_id') : $object->country_id));
+ print $form->select_country((GETPOST('country_id') != '' ?GETPOST('country_id') : $object->country_id), 'country_id');
if ($user->admin) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
@@ -1143,7 +1152,7 @@ if ($action == 'create' || $action == 'adduserldap') {
if (empty($conf->global->USER_DISABLE_STATE)) {
print ' '.$form->editfieldkey('State', 'state_id', '', $object, 0).' ';
print img_picto('', 'state', 'class="pictofixedwidth"');
- print $formcompany->select_state($object->state_id, $object->country_code, 'state_id');
+ print $formcompany->select_state_ajax('country_id', $object->state_id, $object->country_id, 'state_id');
print ' ';
}
@@ -1488,7 +1497,7 @@ if ($action == 'create' || $action == 'adduserldap') {
}
/*
- * Fiche en mode visu
+ * View mode
*/
if ($action != 'edit') {
print dol_get_fiche_head($head, 'user', $title, -1, 'user');
@@ -1965,7 +1974,7 @@ if ($action == 'create' || $action == 'adduserldap') {
} else {
print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit&token='.newToken(), '', true, $params);
}
- } elseif ($caneditpassword && !$object->ldap_sid &&
+ } elseif ($caneditpasswordandsee && !$object->ldap_sid &&
(!isModEnabled('multicompany') || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
$params = array(
'attr' => array(
@@ -1976,26 +1985,26 @@ if ($action == 'create' || $action == 'adduserldap') {
print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit', '', true, $params);
}
- // Si on a un gestionnaire de generation de mot de passe actif
+ // If we have a password generator engine enabled
$params = array(
'attr' => array(
'title' => '',
'class' => 'classfortooltip'
)
);
- if ($conf->global->USER_PASSWORD_GENERATED != 'none') {
- if ($object->statut == 0) {
+ if (getDolGlobalString('USER_PASSWORD_GENERATED') != 'none') {
+ if ($object->status == $object::STATUS_DISABLED) {
$params['attr']['title'] = $langs->trans('UserDisabled');
print dolGetButtonAction($langs->trans('ReinitPassword'), '', 'default', $_SERVER['PHP_SELF'].'#', '', false, $params);
- } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid &&
+ } elseif (($user->id != $id && $caneditpasswordandsee) && $object->login && !$object->ldap_sid &&
((!isModEnabled('multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
print dolGetButtonAction($langs->trans('ReinitPassword'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=password&token='.newToken(), '', true, $params);
}
- if ($object->statut == 0) {
+ if ($object->status == $object::STATUS_DISABLED) {
$params['attr']['title'] = $langs->trans('UserDisabled');
print dolGetButtonAction($langs->trans('SendNewPassword'), '', 'default', $_SERVER['PHP_SELF'].'#', '', false, $params);
- } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid &&
+ } elseif (($user->id != $id && $caneditpasswordandsend) && $object->login && !$object->ldap_sid &&
((!isModEnabled('multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
if ($object->email) {
print dolGetButtonAction($langs->trans('SendNewPassword'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=passwordsend&token='.newToken(), '', true, $params);
@@ -2140,9 +2149,9 @@ if ($action == 'create' || $action == 'adduserldap') {
}
/*
- * Card in edit mode
+ * Edit mode
*/
- if ($action == 'edit' && ($canedituser || $caneditpassword)) {
+ if ($action == 'edit' && ($canedituser || $caneditpasswordandsee)) {
print ' ';
print ' ';
print ' ';
@@ -2207,7 +2216,7 @@ if ($action == 'create' || $action == 'adduserldap') {
print ' ';
// Administrator
- print ''.$langs->trans("Administrator").' ';
+ print ''.$form->textwithpicto($langs->trans("Administrator"), $langs->trans("AdministratorDesc")).' ';
if ($object->socid > 0) {
$langs->load("admin");
print '';
@@ -2444,7 +2453,7 @@ if ($action == 'create' || $action == 'adduserldap') {
$valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$form->textwithpicto($text, $langs->trans("DolibarrInHttpAuthenticationSoPasswordUseless", $dolibarr_main_authentication), 1, 'warning');
}
if (preg_match('/dolibarr/', $dolibarr_main_authentication) || preg_match('/forceuser/', $dolibarr_main_authentication)) {
- if ($caneditpassword) {
+ if ($caneditpasswordandsee) {
$valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').' ';
if (!empty($conf->use_javascript_ajax)) {
$valuetoshow .= img_picto((getDolGlobalString('USER_PASSWORD_GENERATED') === 'none' ? $langs->trans('NoPasswordGenerationRuleConfigured') : $langs->trans('Generate')), 'refresh', 'id="generate_password" class="paddingleft'.(getDolGlobalString('USER_PASSWORD_GENERATED') === 'none' ? ' opacitymedium' : ' linkobject').'"');
@@ -2454,7 +2463,7 @@ if ($action == 'create' || $action == 'adduserldap') {
}
}
// Other form for user password
- $parameters = array('valuetoshow' => $valuetoshow, 'caneditpassword' => $caneditpassword);
+ $parameters = array('valuetoshow' => $valuetoshow, 'caneditpasswordandsee' => $caneditpasswordandsee, 'caneditpasswordandsend' => $caneditpasswordandsend);
$reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook > 0) {
$valuetoshow = $hookmanager->resPrint; // to replace
@@ -2469,7 +2478,7 @@ if ($action == 'create' || $action == 'adduserldap') {
if (isModEnabled('api')) {
print ' '.$langs->trans("ApiKey").' ';
print '';
- if ($caneditpassword || $user->hasRight("api", "apikey", "generate")) {
+ if ($caneditpasswordandsee || $user->hasRight("api", "apikey", "generate")) {
print ' ';
if (!empty($conf->use_javascript_ajax)) {
print img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject paddingleft"');
diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php
index acfb1ecd88c..26408e3b55a 100644
--- a/htdocs/user/class/user.class.php
+++ b/htdocs/user/class/user.class.php
@@ -1663,7 +1663,7 @@ class User extends CommonObject
$this->civility_code = $contact->civility_code;
$this->lastname = $contact->lastname;
$this->firstname = $contact->firstname;
- $this->gender = $contact->gender;
+ //$this->gender = $contact->gender; // contact ha sno gender
$this->email = $contact->email;
$this->socialnetworks = $contact->socialnetworks;
$this->office_phone = $contact->phone_pro;
@@ -1772,7 +1772,7 @@ class User extends CommonObject
if ($result > 0) {
if (!empty($this->pass)) { // If a clear password was received (this situation should not happen anymore now), we use it to save it into database
$newpass = $this->setPassword($user, $this->pass);
- if (is_numeric($newpass) && $newpass < 0) {
+ if (is_int($newpass) && $newpass < 0) {
$result = -2;
}
} elseif (!empty($this->pass_crypted)) { // If a crypted password is already known, we save it directly into database because the previous create did not save it.
@@ -2047,7 +2047,7 @@ class User extends CommonObject
if ($this->pass != $this->pass_indatabase && !dol_verifyHash($this->pass, $this->pass_indatabase_crypted)) {
// If a new value for password is set and different than the one crypted into database
$result = $this->setPassword($user, $this->pass, 0, $notrigger, $nosyncmemberpass, 0, 1);
- if (is_numeric($result) && $result < 0) {
+ if (is_int($result) && $result < 0) {
return -5;
}
}
@@ -2339,7 +2339,7 @@ class User extends CommonObject
if ($result >= 0) {
$result = $adh->setPassword($user, $this->pass, (empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1), 1); // Cryptage non gere dans module adherent
- if (is_numeric($result) && $result < 0) {
+ if (is_int($result) && $result < 0) {
$this->error = $adh->error;
dol_syslog(get_class($this)."::setPassword ".$this->error, LOG_ERR);
$error++;
@@ -2911,7 +2911,7 @@ class User extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
@@ -2945,7 +2945,7 @@ class User extends CommonObject
}
// Only picto
if ($withpictoimg > 0) {
- $picto = ''.img_object('', 'user', $paddafterimage.' class="paddingright")', 0, 0, $notooltip ? 0 : 1).' ';
+ $picto = ''.img_object('', 'user', $paddafterimage.' class="")', 0, 0, $notooltip ? 0 : 1).'
';
} else {
// Picto must be a photo
$picto = ''.Form::showphoto('userphoto', $this, 0, 0, 0, 'userphoto'.($withpictoimg == -3 ? 'small' : ''), 'mini', 0, 1).' ';
@@ -3125,9 +3125,9 @@ class User extends CommonObject
$return .= '';
$return .= '
'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(0, '', 0, 0, 24, 0, '', 'valignmiddle') : $this->ref);
if (isModEnabled('multicompany') && $this->admin && !$this->entity) {
- $return .= img_picto($langs->trans("SuperAdministrator"), 'redstar', 'class="valignmiddle paddingright paddingleft"');
+ $return .= img_picto($langs->trans("SuperAdministratorDesc"), 'redstar', 'class="valignmiddle paddingright paddingleft"');
} elseif ($this->admin) {
- $return .= img_picto($langs->trans("Administrator"), 'star', 'class="valignmiddle paddingright paddingleft"');
+ $return .= img_picto($langs->trans("AdministratorDesc"), 'star', 'class="valignmiddle paddingright paddingleft"');
}
$return .= ' ';
$return .= '
';
diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php
index 81a44bd3aec..5bfdcf9e4e6 100644
--- a/htdocs/user/class/usergroup.class.php
+++ b/htdocs/user/class/usergroup.class.php
@@ -803,8 +803,6 @@ class UserGroup extends CommonObject
public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
{
global $langs, $conf, $db, $hookmanager;
- global $dolibarr_main_authentication, $dolibarr_main_demo;
- global $menumanager;
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpicto) {
$withpicto = 0;
@@ -835,7 +833,7 @@ class UserGroup extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
@@ -860,7 +858,7 @@ class UserGroup extends CommonObject
$result = $linkstart;
if ($withpicto) {
- $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.'class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
+ $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1);
}
if ($withpicto != 2) {
$result .= $this->name;
diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php
index 7f6a3c0eec2..c1e4cab934e 100644
--- a/htdocs/user/group/card.php
+++ b/htdocs/user/group/card.php
@@ -457,9 +457,9 @@ if ($action == 'create') {
print '
';
print $useringroup->getNomUrl(-1, '', 0, 0, 24, 0, 'login');
if (isModEnabled('multicompany') && $useringroup->admin && empty($useringroup->entity)) {
- print img_picto($langs->trans("SuperAdministrator"), 'redstar');
+ print img_picto($langs->trans("SuperAdministratorDesc"), 'redstar');
} elseif ($useringroup->admin) {
- print img_picto($langs->trans("Administrator"), 'star');
+ print img_picto($langs->trans("AdministratorDesc"), 'star');
}
print ' ';
print '
'.$useringroup->lastname.' ';
diff --git a/htdocs/user/group/list.php b/htdocs/user/group/list.php
index f14eace736a..d0998329fa0 100644
--- a/htdocs/user/group/list.php
+++ b/htdocs/user/group/list.php
@@ -94,7 +94,7 @@ if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
}
// Users/Groups management only in master entity if transverse mode
-if (isModEnabled('multicompany') && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) {
+if (isModEnabled('multicompany') && $conf->entity > 1 && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) {
accessforbidden();
}
@@ -440,7 +440,7 @@ while ($i < $imaxinloop) {
}
}
- print '
';
+ print ' ';
print $object->getNomUrl(1);
if (isModEnabled('multicompany') && !$obj->entity) {
print img_picto($langs->trans("GlobalGroup"), 'redstar');
@@ -457,12 +457,12 @@ while ($i < $imaxinloop) {
$totalarray['nbfield']++;
}
}
- print ' '.$obj->nb.' ';
+ print '
'.dol_escape_htmltag($obj->nb).' ';
if (!$i) {
$totalarray['nbfield']++;
}
print '
';
- print ''.$obj->nbpermissions.' ';
+ print ''.dol_escape_htmltag($obj->nbpermissions).' ';
print ' ';
if (!$i) {
$totalarray['nbfield']++;
@@ -513,12 +513,7 @@ if ($num == 0) {
$colspan++;
}
}*/
- $colspan = 1;
- foreach ($arrayfields as $key => $val) {
- if (!empty($val['checked'])) {
- $colspan++;
- }
- }
+ $colspan = $savnbfield;
print '
'.$langs->trans("NoRecordFound").' ';
}
diff --git a/htdocs/user/hierarchy.php b/htdocs/user/hierarchy.php
index 5857c6257ac..9dc7bffff3f 100644
--- a/htdocs/user/hierarchy.php
+++ b/htdocs/user/hierarchy.php
@@ -151,9 +151,9 @@ if (!is_array($user_arbo) && $user_arbo < 0) {
$li = $userstatic->getNomUrl(-1, '', 0, 1);
if (isModEnabled('multicompany') && $userstatic->admin && !$userstatic->entity) {
- $li .= img_picto($langs->trans("SuperAdministrator"), 'redstar', 'class="valignmiddle paddingright paddingleft"');
+ $li .= img_picto($langs->trans("SuperAdministratorDesc"), 'redstar', 'class="valignmiddle paddingright paddingleft"');
} elseif ($userstatic->admin) {
- $li .= img_picto($langs->trans("Administrator"), 'star', 'class="valignmiddle paddingright paddingleft"');
+ $li .= img_picto($langs->trans("AdministratorDesc"), 'star', 'class="valignmiddle paddingright paddingleft"');
}
$li .= '
('.$val['login'].($entitystring ? ' - '.$entitystring : '').') ';
diff --git a/htdocs/user/home.php b/htdocs/user/home.php
index c93a22f5cfb..a27eb56776e 100644
--- a/htdocs/user/home.php
+++ b/htdocs/user/home.php
@@ -168,9 +168,9 @@ if ($resql) {
$lastcreatedbox .= '
';
$lastcreatedbox .= $fuserstatic->getNomUrl(-1);
if (isModEnabled('multicompany') && $obj->admin && !$obj->entity) {
- $lastcreatedbox .= img_picto($langs->trans("SuperAdministrator"), 'redstar');
+ $lastcreatedbox .= img_picto($langs->trans("SuperAdministratorDesc"), 'redstar');
} elseif ($obj->admin) {
- $lastcreatedbox .= img_picto($langs->trans("Administrator"), 'star');
+ $lastcreatedbox .= img_picto($langs->trans("AdministratorDesc"), 'star');
}
$lastcreatedbox .= " ";
$lastcreatedbox .= '
'.dol_escape_htmltag($obj->login).' ';
diff --git a/htdocs/user/list.php b/htdocs/user/list.php
index f9d39c1ab42..7377ed83330 100644
--- a/htdocs/user/list.php
+++ b/htdocs/user/list.php
@@ -994,8 +994,8 @@ while ($i < $imaxinloop) {
$object->lastname = $obj->lastname;
$object->employee = $obj->employee;
$object->photo = $obj->photo;
- $object->datestartvalidity = $obj->datestartvalidity;
- $object->dateendvalidity = $obj->dateendvalidity;
+ $object->datestartvalidity = $db->jdate($obj->datestartvalidity);
+ $object->dateendvalidity = $db->jdate($obj->dateendvalidity);
$li = $object->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1);
@@ -1046,9 +1046,9 @@ while ($i < $imaxinloop) {
print '
';
print $li;
if (isModEnabled('multicompany') && $obj->admin && !$obj->entity) {
- print img_picto($langs->trans("SuperAdministrator"), 'redstar', 'class="valignmiddle paddingright paddingleft"');
+ print img_picto($langs->trans("SuperAdministratorDesc"), 'redstar', 'class="valignmiddle paddingright paddingleft"');
} elseif ($obj->admin) {
- print img_picto($langs->trans("Administrator"), 'star', 'class="valignmiddle paddingright paddingleft"');
+ print img_picto($langs->trans("AdministratorDesc"), 'star', 'class="valignmiddle paddingright paddingleft"');
}
print ' ';
if (!$i) {
@@ -1117,9 +1117,9 @@ while ($i < $imaxinloop) {
$user2->statut = $obj->status2;
$user2->status = $obj->status2;
if (isModEnabled('multicompany') && $obj->admin2 && !$obj->entity2) {
- print img_picto($langs->trans("SuperAdministrator"), 'redstar', 'class="valignmiddle paddingright"');
+ print img_picto($langs->trans("SuperAdministratorDesc"), 'redstar', 'class="valignmiddle paddingright"');
} elseif ($obj->admin2) {
- print img_picto($langs->trans("Administrator"), 'star', 'class="valignmiddle paddingright"');
+ print img_picto($langs->trans("AdministratorDesc"), 'star', 'class="valignmiddle paddingright"');
}
print $user2->getNomUrl(-1, '', 0, 0, 24, 0, '', '', 1);
}
diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php
index 8f8ad206a44..19e98d06dfc 100644
--- a/htdocs/user/param_ihm.php
+++ b/htdocs/user/param_ihm.php
@@ -464,7 +464,7 @@ if ($action == 'edit') {
print '
conf->MAIN_LANDING_PAGE) ? " checked" : "");
print empty($dolibarr_main_demo) ? '' : ' disabled="disabled"'; // Disabled for demo
print '> '.$langs->trans("UsePersonalValue").'';
- print '
';
+ print ' ';
if (!empty($object->conf->MAIN_LANDING_PAGE)) {
$urltoshow = '';
if (!empty($tmparray[$object->conf->MAIN_LANDING_PAGE])) {
@@ -476,10 +476,17 @@ if ($action == 'edit') {
} else {
$urltoshow = $object->conf->MAIN_LANDING_PAGE;
}
- print ' ';
- print img_picto($urltoshow, $tmparray[$object->conf->MAIN_LANDING_PAGE]['picto'], 'class="pictofixedwidth"');
+ print ' ';
+ $s = '';
+ if (!empty($tmparray[$object->conf->MAIN_LANDING_PAGE]['picto'])) {
+ $s = img_picto($urltoshow, $tmparray[$object->conf->MAIN_LANDING_PAGE]['picto'], 'class="pictofixedwidth"');
+ }
+ if (empty($s)) {
+ print img_picto($urltoshow, 'globe', 'class="pictofixedwidth"');
+ } else {
+ print $s;
+ }
print $urltoshow;
- print img_picto($urltoshow, 'globe', 'class="paddingleft"');
print ' ';
}
print ' ';
diff --git a/htdocs/user/passwordforgotten.php b/htdocs/user/passwordforgotten.php
index ad66bc5987a..2a711208e8b 100644
--- a/htdocs/user/passwordforgotten.php
+++ b/htdocs/user/passwordforgotten.php
@@ -151,7 +151,7 @@ if (empty($reshook)) {
$message .= $messagewarning;
} else {
$newpassword = $edituser->setPassword($user, '', 1);
- if (is_numeric($newpassword) && $newpassword < 0) {
+ if (is_int($newpassword) && $newpassword < 0) {
// Technical failure
$message = ''.$langs->trans("ErrorFailedToChangePassword").'
';
} else {
diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php
index 2b5261ed16f..c0eece3111b 100644
--- a/htdocs/user/perms.php
+++ b/htdocs/user/perms.php
@@ -193,7 +193,7 @@ foreach ($modulesdir as $dir) {
$db->commit();
-// Read permissions of user
+// Read permissions of edited user
$permsuser = array();
$sql = "SELECT DISTINCT ur.fk_id";
@@ -222,23 +222,8 @@ $permsgroupbyentity = array();
$sql = "SELECT DISTINCT gr.fk_id, gu.entity"; // fk_id are permission id and entity is entity of the group
$sql .= " FROM ".MAIN_DB_PREFIX."usergroup_rights as gr,";
$sql .= " ".MAIN_DB_PREFIX."usergroup_user as gu"; // all groups of a user
-$sql .= " WHERE 1 = 1";
-// A very strange business rules. Must be same than into user->getrights() user/perms.php and user/group/perms.php
-if (!empty($conf->global->MULTICOMPANY_BACKWARD_COMPATIBILITY)) {
- if (isModEnabled('multicompany') && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
- $sql .= " AND gu.entity IN (0,".$conf->entity.")";
- } else {
- //$sql .= " AND r.entity = ".((int) $conf->entity);
- }
-} else {
- $sql .= " AND gr.entity = ".((int) $conf->entity); // Only groups created in current entity
- // The entity on the table usergroup_user should be useless and should never be used because it is alreay into gr and r.
- // but when using MULTICOMPANY_TRANSVERSE_MODE, we may insert record that make rubbish result due to duplicate record of
- // other entities, so we are forced to add a filter here
- $sql .= " AND gu.entity IN (0,".$conf->entity.")";
- //$sql .= " AND r.entity = ".((int) $conf->entity); // Only permission of modules enabled in current entity
-}
-// End of strange business rule
+$sql .= " WHERE gr.entity = ".((int) $entity);
+$sql .= " AND gu.entity =".((int) $entity);
$sql .= " AND gr.fk_usergroup = gu.fk_usergroup";
$sql .= " AND gu.fk_user = ".((int) $object->id);
@@ -606,7 +591,7 @@ if ($result) {
// Permission and tick (2 columns)
if (!empty($object->admin) && !empty($objMod->rights_admin_allowed)) { // Permission granted because admin
if ($caneditperms) {
- print ''.img_picto($langs->trans("Administrator"), 'star').' ';
+ print ''.img_picto($langs->trans("AdministratorDesc"), 'star').' ';
} else {
print ' ';
}
@@ -690,6 +675,22 @@ if ($result) {
print ' ('.$langs->trans("AdvancedModeOnly").') ';
}
}
+ // Special warning case for the permission "Allow to modify other users password"
+ if ($obj->module == 'user' && $obj->perms == 'user' && $obj->subperms == 'password') {
+ if ((!empty($object->admin) && !empty($objMod->rights_admin_allowed)) ||
+ in_array($obj->id, $permsuser) /* if edited user owns this permissions */ ||
+ (isset($permsgroupbyentitypluszero) && is_array($permsgroupbyentitypluszero) && in_array($obj->id, $permsgroupbyentitypluszero))) {
+ print ' '.img_warning($langs->trans("AllowPasswordResetBySendingANewPassByEmail"));
+ }
+ }
+ // Special warning case for the permission "Create/modify other users, groups and permissions"
+ if ($obj->module == 'user' && $obj->perms == 'user' && ($obj->subperms == 'creer' || $obj->subperms == 'create')) {
+ if ((!empty($object->admin) && !empty($objMod->rights_admin_allowed)) ||
+ in_array($obj->id, $permsuser) /* if edited user owns this permissions */ ||
+ (isset($permsgroupbyentitypluszero) && is_array($permsgroupbyentitypluszero) && in_array($obj->id, $permsgroupbyentitypluszero))) {
+ print ' '.img_warning($langs->trans("AllowAnyPrivileges"));
+ }
+ }
print '';
// Permission id
diff --git a/htdocs/user/virtualcard.php b/htdocs/user/virtualcard.php
index f7ce93e71e0..0df9d037de0 100644
--- a/htdocs/user/virtualcard.php
+++ b/htdocs/user/virtualcard.php
@@ -186,8 +186,9 @@ if (getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) {
print '';
+ }
+}
+
// Part to create
if ($action == 'create') {
print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("WebsiteAccount")));
@@ -147,6 +218,8 @@ if ($action == 'create') {
print $form->buttonsSaveCancel("Create");
print ' ';
+
+ print $out_js;
}
// Part to edit record
@@ -175,6 +248,8 @@ if (($id || $ref) && $action == 'edit') {
print $form->buttonsSaveCancel();
print '';
+
+ print $out_js;
}
// Part to show record
@@ -196,7 +271,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}
// Call Hook formConfirm
- $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
+ $parameters = array('formConfirm' => $formconfirm);
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) {
$formconfirm .= $hookmanager->resPrint;
@@ -214,9 +289,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if ($socid) {
$linkback = ''.$langs->trans("BackToListForThirdParty").' ';
}
- if ($fk_website) {
- $linkback = ''.$langs->trans("BackToList").' ';
- }
+ //if ($fk_website) {
+ // $linkback = ''.$langs->trans("BackToList").' ';
+ //}
$morehtmlref = '';
/*
@@ -305,7 +380,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '
'."\n";
}
- if ($user->hasRight('website', 'write')) {
+ if ($permissiontoadd) {
print '
'."\n";
}
diff --git a/htdocs/workstation/class/workstation.class.php b/htdocs/workstation/class/workstation.class.php
index 097ef6cf2ff..1367f9af5ee 100644
--- a/htdocs/workstation/class/workstation.class.php
+++ b/htdocs/workstation/class/workstation.class.php
@@ -622,7 +622,7 @@ class Workstation extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
diff --git a/htdocs/workstation/workstation_agenda.php b/htdocs/workstation/workstation_agenda.php
index 1e181ac46bd..cf5fb59a258 100644
--- a/htdocs/workstation/workstation_agenda.php
+++ b/htdocs/workstation/workstation_agenda.php
@@ -31,6 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php';
require_once DOL_DOCUMENT_ROOT.'/workstation/lib/workstation_workstation.lib.php';
+global $conf, $db, $hookmanager, $langs, $user;
+
// Load translation files required by the page
$langs->loadLangs(array('mrp', 'other'));
@@ -87,7 +89,7 @@ if ($id > 0 || !empty($ref)) {
}
// Permissions
-$permissiontoadd = $user->rights->workstation->workstation->write; // Used by the include of actions_addupdatedelete.inc.php
+$permissiontoadd = $user->hasRight('workstation', 'workstation', 'write'); // Used by the include of actions_addupdatedelete.inc.php
// Security check
$isdraft = 0;
diff --git a/htdocs/workstation/workstation_card.php b/htdocs/workstation/workstation_card.php
index dfeccf54a87..0a1eb0a4c78 100644
--- a/htdocs/workstation/workstation_card.php
+++ b/htdocs/workstation/workstation_card.php
@@ -32,6 +32,8 @@ require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php';
require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstationusergroup.class.php';
require_once DOL_DOCUMENT_ROOT.'/workstation/lib/workstation_workstation.lib.php';
+global $conf, $db, $hookmanager, $langs, $user;
+
// Load translation files required by the page
$langs->loadLangs(array('mrp', 'other'));
@@ -78,11 +80,11 @@ if (empty($action) && empty($id) && empty($ref)) {
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
// Permissions
-$permissiontoread = $user->rights->workstation->workstation->read;
-$permissiontoadd = $user->rights->workstation->workstation->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
-$permissiontodelete = $user->rights->workstation->workstation->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
-$permissionnote = $user->rights->workstation->workstation->write; // Used by the include of actions_setnotes.inc.php
-$permissiondellink = $user->rights->workstation->workstation->write; // Used by the include of actions_dellink.inc.php
+$permissiontoread = $user->hasRight('workstation', 'workstation', 'read');
+$permissiontoadd = $user->hasRight('workstation', 'workstation', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
+$permissiontodelete = $user->hasRight('workstation', 'workstation', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DISABLED);
+$permissionnote = $user->hasRight('workstation', 'workstation', 'write'); // Used by the include of actions_setnotes.inc.php
+$permissiondellink = $user->hasRight('workstation', 'workstation', 'write'); // Used by the include of actions_dellink.inc.php
$upload_dir = $conf->workstation->multidir_output[isset($object->entity) ? $object->entity : 1];
@@ -161,7 +163,7 @@ llxHeader('', $title, $help_url);
// jquery code
?>
-