diff --git a/.github/workflows/code_quality.yml b/.github/workflows/code_quality.yml new file mode 100644 index 00000000000..65f350e1b53 --- /dev/null +++ b/.github/workflows/code_quality.yml @@ -0,0 +1,25 @@ +name: Qodana +on: + schedule: + - cron: "0 20 * * *" + workflow_dispatch: + branches: + - develop +# push: +# branches: +# - develop + +jobs: + qodana: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + #php-version: '7.1' + - name: 'Qodana Scan' + uses: JetBrains/qodana-action@v2022.3.0 + #with: + # php-version: '7.1' + env: + QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/doxygen-gh-pages.yml.disabled b/.github/workflows/doxygen-gh-pages.yml.disabled new file mode 100644 index 00000000000..33dd47aa6e6 --- /dev/null +++ b/.github/workflows/doxygen-gh-pages.yml.disabled @@ -0,0 +1,38 @@ +# See syntax file on https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions +name: Doxygen +on: + schedule: + - cron: "0 15 * * *" + workflow_dispatch: + branches: + - develop +permissions: + contents: write + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Build + uses: DenverCoder1/doxygen-github-pages-action@v1.2.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: gh-pages + folder: build/html + config_file: build/doxygen/dolibarr-doxygen.doxyfile + +# - name: Deploy +# uses: JamesIves/github-pages-deploy-action@v4 +# with: +# branch: gh-pages +# folder: build/html # The folder the action should deploy. +# target-folder: docs/html2 + +#jobs: +# doxygen: +# runs-on: ubuntu-latest +# steps: +# - name: 'Doxygen' +# uses: mattnotmitt/doxygen-action@1.9.5 +# with: +# doxyfile-path: build/doxygen diff --git a/.github/workflows/exakat.yml b/.github/workflows/exakat.yml.disabled similarity index 93% rename from .github/workflows/exakat.yml rename to .github/workflows/exakat.yml.disabled index 528626e0308..1e9121a0e00 100644 --- a/.github/workflows/exakat.yml +++ b/.github/workflows/exakat.yml.disabled @@ -4,6 +4,9 @@ name: "Exakat analysis" on: schedule: - cron: "0 20 * * *" + workflow_dispatch: + branches: + - develop permissions: contents: read @@ -13,6 +16,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + with: + fetch-depth: 1 - name: Exakat uses: docker://exakat/exakat-ga with: diff --git a/.github/workflows/stale-issues-safe.yml b/.github/workflows/stale-issues-safe.yml index 4ac9fa8f5b9..af04675d48d 100644 --- a/.github/workflows/stale-issues-safe.yml +++ b/.github/workflows/stale-issues-safe.yml @@ -6,7 +6,8 @@ on: - cron: "0 21 * * *" issue_comment: types: [created] - + workflow_dispatch: + permissions: {} # none jobs: diff --git a/.gitignore b/.gitignore index e935ec1bd59..55a4c417ce7 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ default.properties *.orig Thumbs.db /dolibarr_genesis.mp4 +.phpunit.result.cache # Log files dolibarr_install.log upgrade.log diff --git a/.scrutinizer.yml b/.scrutinizer.yml index c1cb2e853f1..058a0ba8b48 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -8,21 +8,24 @@ build: override: - command: php-scrutinizer-run idle_timeout: 8000 + #- php-scrutinizer-run --sub-project-dir=htdocs/admin imports: - - javascript - php filter: excluded_paths: - - build/* - - dev/* - - doc/* - - documents/* - - node_modules/* - - test/* - dependency_paths: - - htdocs/includes/* + - build/ + - dev/ + - doc/ + - documents/ + - node_modules/ + - test/ + - htdocs/custom/ + - htdocs/includes/ + - htdocs/install/doctemplates/ + #dependency_paths: + # - htdocs/includes/ paths: - htdocs/* - scripts/* @@ -33,21 +36,23 @@ tools: enabled: true extensions: - php - dependency_paths: - - htdocs/includes/ + #dependency_paths: + # - htdocs/includes/ filter: excluded_paths: - - build/* - - dev/* - - doc/* - - documents/* - - htdocs/includes/* + - build/ + - dev/ + - doc/ + - documents/ + - htdocs/custom/ + - htdocs/includes/ + - htdocs/install/doctemplates/ - htdocs/core/class/lessc.class.php - - node_modules/* - - test/* + - node_modules/ + - test/ paths: - - htdocs/ - - scripts/ + - htdocs/* + - scripts/* config: parameter_reference_check: enabled: true @@ -156,73 +161,73 @@ tools: # 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: { } + #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: { } + #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: { } + #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: { } + #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: { } diff --git a/.travis.yml b/.travis.yml index 6422e33a7e9..5380ef54d3d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -95,19 +95,20 @@ notifications: install: - | - echo "Updating Composer" - rm $TRAVIS_BUILD_DIR/composer.json - rm $TRAVIS_BUILD_DIR/composer.lock + echo "Updating Composer config" composer -V - composer self-update - composer -n init - composer -n config vendor-dir htdocs/includes + #rm $TRAVIS_BUILD_DIR/composer.json + #rm $TRAVIS_BUILD_DIR/composer.lock + #composer -n init + #composer -n config vendor-dir htdocs/includes composer -n config -g vendor-dir htdocs/includes echo - | - echo "Installing Composer dependencies - PHP Unit, Parallel Lint, PHP CodeSniffer, PHP Vardump check - for $TRAVIS_PHP_VERSION" + echo "Update Composer version and Install tools - PHP Unit, Parallel Lint, PHP CodeSniffer, PHP Vardump check - for $TRAVIS_PHP_VERSION" + echo "(version 2.5 is bugged and generate phpunit error Exception: Serialization of 'Closure' is not allowed)" if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ]; then + composer self-update 2.2.18 composer -n require phpunit/phpunit ^6 \ php-parallel-lint/php-parallel-lint ^1 \ php-parallel-lint/php-console-highlighter ^0 \ @@ -115,6 +116,7 @@ install: squizlabs/php_codesniffer ^3 fi if [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ]; then + composer self-update 2.2.18 composer -n require phpunit/phpunit ^7 \ php-parallel-lint/php-parallel-lint ^1.2 \ php-parallel-lint/php-console-highlighter ^0 \ @@ -123,12 +125,15 @@ install: fi # phpunit 9 is required for php 8 if [ "$TRAVIS_PHP_VERSION" = '8.0' ] || [ "$TRAVIS_PHP_VERSION" = '8.1' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then + composer self-update 2.4.4 composer -n require --ignore-platform-reqs phpunit/phpunit ^8 \ php-parallel-lint/php-parallel-lint ^1.2 \ php-parallel-lint/php-console-highlighter ^0 \ php-parallel-lint/php-var-dump-check ~0.4 \ squizlabs/php_codesniffer ^3 fi + # Remove non expected files + rm -fr /home/travis/build/Dolibarr/dolibarr/htdocs/includes/phpunit/php-code-coverage/src/Report/Html/Renderer/Template/js echo - | @@ -450,6 +455,9 @@ script: php upgrade.php 16.0.0 17.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade16001700.log php upgrade2.php 16.0.0 17.0.0 > $TRAVIS_BUILD_DIR/upgrade16001700-2.log php step5.php 16.0.0 17.0.0 > $TRAVIS_BUILD_DIR/upgrade16001700-3.log + 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 ls -alrt $TRAVIS_BUILD_DIR/ - | diff --git a/ChangeLog b/ChangeLog index 1697b668934..9ec9fb4525a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,16 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 18.0.0 compared to 17.0.0 ***** + +WARNING: + +Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: +* The deprecated method escapeunderscore() of database handlers has been removed. You must use escapeforlike instead. +* The method nb_expedition() has been renamed into countNbOfShipments() + + + ***** ChangeLog for 17.0.0 compared to 16.0.0 ***** For users: @@ -11,7 +21,7 @@ For users: NEW: Minimal PHP version is now PHP 7.0 instead of PHP 5.6 NEW: #21780 Add pid field to Cronjob class and store PID on job execution NEW: #19680 Add option PRODUCT_ALLOW_EXTERNAL_DOWNLOAD to automatically have uploaded files shared publicly by a link -NEW: #20650 can move the checkbox column on left (experimental option) +NEW: #20650 can move the checkbox column on left (experimental option MAIN_CHECKBOX_LEFT_COLUMN) NEW: #21000 Added columns 'alias_name' on project, supplier invoice, supplier order, supplier proposals and task list NEW: #21395 Added option for dark theme mode in display - color and theme NEW: #21397 added option to auto define barcode numbers for third-parties in barcode module setup @@ -36,7 +46,6 @@ NEW: Accountancy - Add a way to clean some words when you generate thirdparty ac NEW: Accountancy - Added an option during export to export or not the lettering FPC21 NEW: Accountancy - Manage supplier deposit with specific account NEW: Accountancy - Model Digitaria - Add a way to clean some words when you generate thirdparty accounting account FPC22 -NEW: Add a button "Test collect" in email collector NEW: Add a constant to disallow modification of the product reference. NEW: Add a method doAutoRenewContracts that can be used as a cron task. NEW: Add " as enclosure by default for CSV export. Keep removing CR/LF. @@ -50,9 +59,6 @@ NEW: Add extrafield type "IP" to store IP addresses NEW: Add fail2ban rules examples to limit access to /public pages NEW: Add filter "Product subject to lot/Serial" in stock per lot/serial NEW: Add hidden option MAIN_EMAIL_SUPPORT_ACK to restore Email ack checkbox (feature abandonned by mailers) -NEW: Add IMAP port setting on email collector module -NEW: Adding JAPAN Chart-of-Account and regions/departments -NEW: Adding NIF verification for Algeria NEW: Add link to create an element from the category page NEW: add margin infos to takepos invoice lines NEW: Add max size send for "backup and link to mail" option @@ -92,16 +98,22 @@ NEW: Change filter type on tickets list into a multiselect combo NEW: conf TIMESPENT_ALWAYS_UPDATE_THM, when it's on we always check current thm of user to update it in task time line NEW: constant PROPAL_NEW_AS_SIGNED NEW: show date delivery planned on orders linked to company and product -NEW: Default template of contract is not mandatory NEW: Default values in extrafields are not more limited to 255 char. NEW: display currency in takepos menu NEW: Enable online signature for interventions NEW: Encrypt all sensitive constants in llx_const NEW: extrafield price with currency NEW: filter on reception dates (from / to) in cheque paiement card +NEW: Contracts: Default template of contract is not mandatory +NEW: Contracts: Manage Position (Rank) on Contract Lines +NEW: EMail-Collector: add IMAP port setting +NEW: EMail-Collector: add a button "Test collect" NEW: Members: default_lang for members NEW: Members: Table of membership types NEW: Members: add free membership amounts at the membership type level +NEW: Projects: add author on list +NEW: Proposals: show delivery mode on PDF for proposals +NEW: Reception: add a from/to on search on date field NEW: TakePOS: Header Scroll in TakePOS NEW: TakePOS: add price to product box in TakePOS NEW: TakePOS: add setup parameters, can setup terminal name @@ -124,7 +136,6 @@ NEW: The link "add to bookmark" is always on top in the bookmark popup NEW: MAIN_SEARCH_CATEGORY_PRODUCT_ON_LISTS const to show category customer filter NEW: Make module WebservicesClient deprecated. Use module WebHook instead. NEW: manage no email with thirdparties (better for GDPR) -NEW: Manage Position (Rank) on Contract Lines NEW: Manage VAT on all lines on purchases cycle NEW: manage virtual stock at a future date NEW: On a bank reconciled line, we can modify the bank receipt @@ -139,9 +150,7 @@ NEW: possibility to select scopes with checkbox for Oauth tokens NEW: private and public note on user, thirdparty and contact list NEW: product categories filter on inventory list NEW: Product supplier price: autofill default supplier VAT -NEW: Project - Add author on list NEW: Public counters feature -NEW: Reception - Add a from/to on search on date field NEW: Start a simple support of recurrent events on agenda NEW: Resize parent company column in order list NEW: Saved token of OAUTH module are now encrypted into llx_oauth_token @@ -156,7 +165,7 @@ NEW: show product label on inventory NEW: show sell-by and eat-by dates only if not empty NEW: show SellBy/EatBy dates for each batch product in shipment card NEW: skip accept/refuse process for proposals (option PROPAL_SKIP_ACCEPT_REFUSE) -NEW: SMTP using oauth2 authentication +NEW: experimental SMTP using PhpImap allowing OAuth2 authentication (need to add option MAIN_IMAP_USE_PHPIMAP) NEW: can substitue project title in mail template NEW: Supplier order list - Add column private and public note NEW: Support IP type in extrafields @@ -164,19 +173,23 @@ NEW: The purge of files can purge only if older than a number of seconds NEW: Update ActionComm type_code on email message ticket NEW: VAT - Admin - Add information on deadline day for submission of VAT declaration NEW: expand/collapse permissions on user permission page -NEW: Show delivery mode on PDF for proposals NEW: Add the target to select attendees of event for emailings + Localisation: +NEW: adding JAPAN Chart-of-Account and regions/departments +NEW: adding NIF verification for Algeria + Modules NEW: Experimental module Asset + For developers or integrators: ------------------------------ NEW: ModuleBuilder can generate code of class from an existing SQL table -NEW: #22370 Modulebuilder supports 'alwayseditable' (like extrafields) NEW: #20912 Add trigger to record the event of sending an email from a project NEW: #21750 Added "Get lines and Post lines from BOM" at the REST Service +NEW: #22370 Modulebuilder supports 'alwayseditable' (like extrafields) NEW: Removed completely the need for the library adodbtime NEW: hook on agenda pages NEW: hook to complete payment in TakePOS @@ -209,6 +222,39 @@ Following changes may create regressions for some external modules, but were nec * Rename the substitution for project label instead of project title in substitution variables +***** ChangeLog for 16.0.4 compared to 16.0.2 ***** + +FIX: Amount of localtax1 and 2 not correctly save on purchase order (the rate was saved instead) +FIX: #20415 +FIX: #21280 +FIX: #23008 +FIX: #22271 +FIX: #22837 +FIX: #23019 Impossible to add task times to an existing draft invoice +FIX: #23072 +FIX: #23087 +FIX: #23115 +FIX: #23116 +FIX: #23281 +FIX: bad selection of barcode numbering module +FIX: Can't see all time spent by all user +FIX: CI +FIX: CommonObject - showOptionals - Display blank td when MAIN_VIEW_LINE_NUMBER is enabled and action is confirm_valid +FIX: Documents API inconsistency +FIX: #23075 +FIX: #23117 +FIX: get multicurrency infos of propal when create order from propal with "WORKFLOW_PROPAL_AUTOCREATE_ORDER" conf +FIX: Give predictable order to inventory lines +FIX: include class multicurrency +FIX: methods declaration (backport fix 67b9a7dc07d708231d12b5e58800334d4a01ef98) +FIX: multicurrency_tx and not currency_tx +FIX: PGSQL Integer type does not have a free length +FIX: Product list in setup.php in new Module +FIX: propal and order stats broken on Tag+User(retricted customer list) +FIX: saving of numbering module for jobs +FIX: Stickler +FIX: travis + ***** ChangeLog for 16.0.3 compared to 16.0.2 ***** FIX: $sign is useless diff --git a/build/doxygen/dolibarr-doxygen-build.pl b/build/doxygen/dolibarr-doxygen-build.pl index 75a5cceddbe..5a4849a3a5b 100755 --- a/build/doxygen/dolibarr-doxygen-build.pl +++ b/build/doxygen/dolibarr-doxygen-build.pl @@ -17,9 +17,9 @@ use Cwd; my $dir = getcwd; print "Current dir is: $dir\n"; -print "Running dir for doxygen must be: $DIR\n"; +#print "Running dir for doxygen must be: $DIR\n"; -if (! -s $CONFFILE) +if (! -s "build/doxygen/$CONFFILE") { print "Error: current directory for building Dolibarr doxygen documentation is not correct.\n"; print "\n"; @@ -30,7 +30,7 @@ if (! -s $CONFFILE) exit 1; } -$SOURCE="../.."; +$SOURCE="."; # Get version $MAJOR, $MINOR and $BUILD $result = open( IN, "< " . $SOURCE . "/htdocs/filefunc.inc.php" ); @@ -47,8 +47,8 @@ $version=$MAJOR.".".$MINOR.".".$BUILD; print "Running doxygen for version ".$version.", please wait...\n"; -print "cat $CONFFILE | sed -e 's/x\.y\.z/".$version."/' | doxygen $OPTIONS - 2>&1\n"; -$result=`cat $CONFFILE | sed -e 's/x\.y\.z/$version/' | doxygen $OPTIONS - 2>&1`; +print "cat build/doxygen/$CONFFILE | sed -e 's/x\.y\.z/".$version."/' | doxygen $OPTIONS - 2>&1\n"; +$result=`cat build/doxygen/$CONFFILE | sed -e 's/x\.y\.z/$version/' | doxygen $OPTIONS - 2>&1`; print $result; diff --git a/build/doxygen/dolibarr-doxygen.doxyfile b/build/doxygen/dolibarr-doxygen.doxyfile index 31400661ecc..6f668ebad7e 100644 --- a/build/doxygen/dolibarr-doxygen.doxyfile +++ b/build/doxygen/dolibarr-doxygen.doxyfile @@ -1,14 +1,17 @@ -# Doxyfile 1.7.3 +# Doxyfile 1.8.16 # This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project +# doxygen (www.doxygen.org) for a project. # -# All text after a hash (#) is considered a comment and will be ignored +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. # The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). #--------------------------------------------------------------------------- # Project related configuration options @@ -38,7 +41,7 @@ PROJECT_NUMBER = x.y.z # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. -OUTPUT_DIRECTORY = ../../build +OUTPUT_DIRECTORY = build # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output @@ -114,7 +117,7 @@ FULL_PATH_NAMES = YES # If left blank the directory from which doxygen is run is used as the # path to strip. -STRIP_FROM_PATH = "../.." +STRIP_FROM_PATH = "/home/dolibarr/doxygen.dolibarr.org/" # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells @@ -287,7 +290,7 @@ TYPEDEF_HIDES_STRUCT = NO # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols -SYMBOL_CACHE_SIZE = 0 +#SYMBOL_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options @@ -448,7 +451,7 @@ GENERATE_TODOLIST = NO # disable (NO) the test list. This list is created by putting \test # commands in the documentation. -GENERATE_TESTLIST = YES +GENERATE_TESTLIST = NO # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug @@ -487,7 +490,7 @@ SHOW_USED_FILES = YES # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. -SHOW_DIRECTORIES = YES +#SHOW_DIRECTORIES = YES # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the @@ -571,7 +574,7 @@ WARN_FORMAT = "$file:$line: $text" # and error messages should be written. If left blank the output is written # to stderr. -WARN_LOGFILE = doxygen_warnings.log +WARN_LOGFILE = build/html/doxygen_warnings.log #--------------------------------------------------------------------------- # configuration options related to the input files @@ -582,7 +585,7 @@ WARN_LOGFILE = doxygen_warnings.log # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = ../../htdocs ../../scripts +INPUT = htdocs scripts # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is @@ -611,7 +614,7 @@ RECURSIVE = YES # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. -EXCLUDE = ../../build ../../dev ../../doc ../../document ../../documents ../../htdocs/conf/conf.php ../../htdocs/custom ../../htdocs/document ../../htdocs/documents ../../htdocs/includes +EXCLUDE = build dev doc document documents htdocs/conf/conf.php htdocs/custom htdocs/document htdocs/documents htdocs/includes htdocs/install/doctemplates # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded @@ -625,7 +628,7 @@ EXCLUDE_SYMLINKS = YES # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* -EXCLUDE_PATTERNS = */CVS/* *google* *pibarcode* +EXCLUDE_PATTERNS = */CVS/* # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the @@ -639,27 +642,27 @@ EXCLUDE_SYMBOLS = # directories that contain example code fragments that are included (see # the \include command). -EXAMPLE_PATH = ../../htdocs/modulebuilder/template +#EXAMPLE_PATH = htdocs/modulebuilder/template # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. -EXAMPLE_PATTERNS = *.php +#EXAMPLE_PATTERNS = *.php # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. -EXAMPLE_RECURSIVE = NO +#EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). -IMAGE_PATH = ../../doc/images +IMAGE_PATH = doc/images # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program @@ -762,7 +765,7 @@ ALPHABETICAL_INDEX = YES # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) -COLS_IN_ALPHA_INDEX = 5 +#COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. @@ -775,14 +778,16 @@ IGNORE_PREFIX = # configuration options related to the HTML output #--------------------------------------------------------------------------- -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. GENERATE_HTML = YES -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_OUTPUT = html @@ -797,14 +802,14 @@ HTML_FILE_EXTENSION = .html # standard header. # Does not work with 1.7.3 -#HTML_HEADER = doxygen_header.html +#HTML_HEADER = build/doxygen/doxygen_header.html # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. # Does not work with 1.7.3 -HTML_FOOTER = doxygen_footer.html +HTML_FOOTER = build/doxygen/doxygen_footer.html # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to @@ -850,7 +855,18 @@ HTML_TIMESTAMP = YES # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. -HTML_ALIGN_MEMBERS = YES +#HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML +# documentation will contain a main index with vertical navigation menus that +# are dynamically created via Javascript. If disabled, the navigation index will +# consists of multiple levels of tabs that are statically embedded in every HTML +# page. Disable this option to support browsers that do not have Javascript, +# like the Qt help browser. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_MENUS = NO # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the @@ -858,7 +874,7 @@ HTML_ALIGN_MEMBERS = YES # JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). -HTML_DYNAMIC_SECTIONS = YES +HTML_DYNAMIC_SECTIONS = NO # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 @@ -1003,7 +1019,7 @@ QHG_LOCATION = # the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before # the help appears. -GENERATE_ECLIPSEHELP = YES +GENERATE_ECLIPSEHELP = NO # A unique identifier for the eclipse help plugin. When installing the plugin # the directory name containing the HTML and XML files should also have @@ -1035,7 +1051,7 @@ GENERATE_TREEVIEW = NO # By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, # and Class Hierarchy pages using a tree view instead of an ordered list. -USE_INLINE_TREES = NO +#USE_INLINE_TREES = NO # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree @@ -1072,7 +1088,7 @@ FORMULA_TRANSPARENT = YES # typically be disabled. For large projects the javascript based search engine # can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. -SEARCHENGINE = NO +SEARCHENGINE = YES # When the SERVER_BASED_SEARCH tag is enabled the search engine will be # implemented using a PHP enabled web server instead of at the web client @@ -1082,7 +1098,7 @@ SEARCHENGINE = NO # full text search. The disadvances is that it is more difficult to setup # and does not have live searching capabilities. -SERVER_BASED_SEARCH = NO +SERVER_BASED_SEARCH = YES #--------------------------------------------------------------------------- # configuration options related to the LaTeX output @@ -1260,13 +1276,13 @@ XML_OUTPUT = xml # which can be used by a validating XML parser to check the # syntax of the XML files. -XML_SCHEMA = +#XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. -XML_DTD = +#XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting @@ -1431,7 +1447,7 @@ EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). -PERL_PATH = /usr/bin/perl +#PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool @@ -1453,7 +1469,7 @@ CLASS_DIAGRAMS = NO # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. -MSCGEN_PATH = +#MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented @@ -1485,7 +1501,7 @@ DOT_NUM_THREADS = 0 # DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory # containing the font. -DOT_FONTNAME = FreeSans.ttf +#DOT_FONTNAME = FreeSans.ttf # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. # The default size is 10pt. @@ -1634,3 +1650,7 @@ GENERATE_LEGEND = YES # the various graphs. DOT_CLEANUP = YES + + +FULL_SIDEBAR = NO +HTML_EXTRA_STYLESHEET = build/doxygen/doxygen-awesome.css diff --git a/build/doxygen/doxygen-awesome.css b/build/doxygen/doxygen-awesome.css new file mode 100644 index 00000000000..0b1c8c20892 --- /dev/null +++ b/build/doxygen/doxygen-awesome.css @@ -0,0 +1,2413 @@ +/** + +Doxygen Awesome +https://github.com/jothepro/doxygen-awesome-css + +MIT License + +Copyright (c) 2021 - 2022 jothepro + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +*/ + +html { + /* primary theme color. This will affect the entire websites color scheme: links, arrows, labels, ... */ + --primary-color: #1779c4; + --primary-dark-color: #335c80; + --primary-light-color: #70b1e9; + + /* page base colors */ + --page-background-color: #ffffff; + --page-foreground-color: #2f4153; + --page-secondary-foreground-color: #6f7e8e; + + /* color for all separators on the website: hr, borders, ... */ + --separator-color: #dedede; + + /* border radius for all rounded components. Will affect many components, like dropdowns, memitems, codeblocks, ... */ + --border-radius-large: 8px; + --border-radius-small: 4px; + --border-radius-medium: 6px; + + /* default spacings. Most components reference these values for spacing, to provide uniform spacing on the page. */ + --spacing-small: 5px; + --spacing-medium: 10px; + --spacing-large: 16px; + + /* default box shadow used for raising an element above the normal content. Used in dropdowns, search result, ... */ + --box-shadow: 0 2px 8px 0 rgba(0,0,0,.075); + + --odd-color: rgba(0,0,0,.028); + + /* font-families. will affect all text on the website + * font-family: the normal font for text, headlines, menus + * font-family-monospace: used for preformatted text in memtitle, code, fragments + */ + --font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif; + --font-family-monospace: ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace; + + /* font sizes */ + --page-font-size: 15.6px; + --navigation-font-size: 14.4px; + --toc-font-size: 13.4px; + --code-font-size: 14px; /* affects code, fragment */ + --title-font-size: 22px; + + /* content text properties. These only affect the page content, not the navigation or any other ui elements */ + --content-line-height: 27px; + /* The content is centered and constraint in it's width. To make the content fill the whole page, set the variable to auto.*/ + --content-maxwidth: 1050px; + --table-line-height: 24px; + --toc-sticky-top: var(--spacing-medium); + --toc-width: 200px; + --toc-max-height: calc(100vh - 2 * var(--spacing-medium) - 85px); + + /* colors for various content boxes: @warning, @note, @deprecated @bug */ + --warning-color: #f8d1cc; + --warning-color-dark: #b61825; + --warning-color-darker: #75070f; + --note-color: #faf3d8; + --note-color-dark: #f3a600; + --note-color-darker: #5f4204; + --todo-color: #e4f3ff; + --todo-color-dark: #1879C4; + --todo-color-darker: #274a5c; + --deprecated-color: #ecf0f3; + --deprecated-color-dark: #5b6269; + --deprecated-color-darker: #43454a; + --bug-color: #e4dafd; + --bug-color-dark: #5b2bdd; + --bug-color-darker: #2a0d72; + --invariant-color: #d8f1e3; + --invariant-color-dark: #44b86f; + --invariant-color-darker: #265532; + + /* blockquote colors */ + --blockquote-background: #f8f9fa; + --blockquote-foreground: #636568; + + /* table colors */ + --tablehead-background: #f1f1f1; + --tablehead-foreground: var(--page-foreground-color); + + /* menu-display: block | none + * Visibility of the top navigation on screens >= 768px. On smaller screen the menu is always visible. + * `GENERATE_TREEVIEW` MUST be enabled! + */ + --menu-display: block; + + --menu-focus-foreground: var(--page-background-color); + --menu-focus-background: var(--primary-color); + --menu-selected-background: rgba(0,0,0,.05); + + + --header-background: var(--page-background-color); + --header-foreground: var(--page-foreground-color); + + /* searchbar colors */ + --searchbar-background: var(--side-nav-background); + --searchbar-foreground: var(--page-foreground-color); + + /* searchbar size + * (`searchbar-width` is only applied on screens >= 768px. + * on smaller screens the searchbar will always fill the entire screen width) */ + --searchbar-height: 33px; + --searchbar-width: 210px; + --searchbar-border-radius: var(--searchbar-height); + + /* code block colors */ + --code-background: #f5f5f5; + --code-foreground: var(--page-foreground-color); + + /* fragment colors */ + --fragment-background: #F8F9FA; + --fragment-foreground: #37474F; + --fragment-keyword: #bb6bb2; + --fragment-keywordtype: #8258b3; + --fragment-keywordflow: #d67c3b; + --fragment-token: #438a59; + --fragment-comment: #969696; + --fragment-link: #5383d6; + --fragment-preprocessor: #46aaa5; + --fragment-linenumber-color: #797979; + --fragment-linenumber-background: #f4f4f5; + --fragment-linenumber-border: #e3e5e7; + --fragment-lineheight: 20px; + + /* sidebar navigation (treeview) colors */ + --side-nav-background: #fbfbfb; + --side-nav-foreground: var(--page-foreground-color); + --side-nav-arrow-opacity: 0; + --side-nav-arrow-hover-opacity: 0.9; + + --toc-background: var(--side-nav-background); + --toc-foreground: var(--side-nav-foreground); + + /* height of an item in any tree / collapsable table */ + --tree-item-height: 30px; + + --memname-font-size: var(--code-font-size); + --memtitle-font-size: 18px; + + --webkit-scrollbar-size: 7px; + --webkit-scrollbar-padding: 4px; + --webkit-scrollbar-color: var(--separator-color); +} + +@media screen and (max-width: 767px) { + html { + --page-font-size: 16px; + --navigation-font-size: 16px; + --toc-font-size: 15px; + --code-font-size: 15px; /* affects code, fragment */ + --title-font-size: 22px; + } +} + +@media (prefers-color-scheme: dark) { + html:not(.light-mode) { + color-scheme: dark; + + --primary-color: #1982d2; + --primary-dark-color: #86a9c4; + --primary-light-color: #4779ac; + + --box-shadow: 0 2px 8px 0 rgba(0,0,0,.35); + + --odd-color: rgba(100,100,100,.06); + + --menu-selected-background: rgba(0,0,0,.4); + + --page-background-color: #1C1D1F; + --page-foreground-color: #d2dbde; + --page-secondary-foreground-color: #859399; + --separator-color: #38393b; + --side-nav-background: #252628; + + --code-background: #2a2c2f; + + --tablehead-background: #2a2c2f; + + --blockquote-background: #222325; + --blockquote-foreground: #7e8c92; + + --warning-color: #2e1917; + --warning-color-dark: #ad2617; + --warning-color-darker: #f5b1aa; + --note-color: #3b2e04; + --note-color-dark: #f1b602; + --note-color-darker: #ceb670; + --todo-color: #163750; + --todo-color-dark: #1982D2; + --todo-color-darker: #dcf0fa; + --deprecated-color: #2e323b; + --deprecated-color-dark: #738396; + --deprecated-color-darker: #abb0bd; + --bug-color: #2a2536; + --bug-color-dark: #7661b3; + --bug-color-darker: #ae9ed6; + --invariant-color: #303a35; + --invariant-color-dark: #76ce96; + --invariant-color-darker: #cceed5; + + --fragment-background: #282c34; + --fragment-foreground: #dbe4eb; + --fragment-keyword: #cc99cd; + --fragment-keywordtype: #ab99cd; + --fragment-keywordflow: #e08000; + --fragment-token: #7ec699; + --fragment-comment: #999999; + --fragment-link: #98c0e3; + --fragment-preprocessor: #65cabe; + --fragment-linenumber-color: #cccccc; + --fragment-linenumber-background: #35393c; + --fragment-linenumber-border: #1f1f1f; + } +} + +/* dark mode variables are defined twice, to support both the dark-mode without and with doxygen-awesome-darkmode-toggle.js */ +html.dark-mode { + color-scheme: dark; + + --primary-color: #1982d2; + --primary-dark-color: #86a9c4; + --primary-light-color: #4779ac; + + --box-shadow: 0 2px 8px 0 rgba(0,0,0,.30); + + --odd-color: rgba(100,100,100,.06); + + --menu-selected-background: rgba(0,0,0,.4); + + --page-background-color: #1C1D1F; + --page-foreground-color: #d2dbde; + --page-secondary-foreground-color: #859399; + --separator-color: #38393b; + --side-nav-background: #252628; + + --code-background: #2a2c2f; + + --tablehead-background: #2a2c2f; + + --blockquote-background: #222325; + --blockquote-foreground: #7e8c92; + + --warning-color: #2e1917; + --warning-color-dark: #ad2617; + --warning-color-darker: #f5b1aa; + --note-color: #3b2e04; + --note-color-dark: #f1b602; + --note-color-darker: #ceb670; + --todo-color: #163750; + --todo-color-dark: #1982D2; + --todo-color-darker: #dcf0fa; + --deprecated-color: #2e323b; + --deprecated-color-dark: #738396; + --deprecated-color-darker: #abb0bd; + --bug-color: #2a2536; + --bug-color-dark: #7661b3; + --bug-color-darker: #ae9ed6; + --invariant-color: #303a35; + --invariant-color-dark: #76ce96; + --invariant-color-darker: #cceed5; + + --fragment-background: #282c34; + --fragment-foreground: #dbe4eb; + --fragment-keyword: #cc99cd; + --fragment-keywordtype: #ab99cd; + --fragment-keywordflow: #e08000; + --fragment-token: #7ec699; + --fragment-comment: #999999; + --fragment-link: #98c0e3; + --fragment-preprocessor: #65cabe; + --fragment-linenumber-color: #cccccc; + --fragment-linenumber-background: #35393c; + --fragment-linenumber-border: #1f1f1f; +} + +body { + color: var(--page-foreground-color); + background-color: var(--page-background-color); + font-size: var(--page-font-size); +} + +body, table, div, p, dl, #nav-tree .label, .title, +.sm-dox a, .sm-dox a:hover, .sm-dox a:focus, #projectname, +.SelectItem, #MSearchField, .navpath li.navelem a, +.navpath li.navelem a:hover, p.reference, p.definition { + font-family: var(--font-family); +} + +h1, h2, h3, h4, h5 { + margin-top: .9em; + font-weight: 600; + line-height: initial; +} + +p, div, table, dl, p.reference, p.definition { + font-size: var(--page-font-size); +} + +p.reference, p.definition { + color: var(--page-secondary-foreground-color); +} + +a:link, a:visited, a:hover, a:focus, a:active { + color: var(--primary-color) !important; + font-weight: 500; +} + +a.anchor { + scroll-margin-top: var(--spacing-large); + display: block; +} + +/* + Title and top navigation + */ + +#top { + background: var(--header-background); + border-bottom: 1px solid var(--separator-color); +} + +@media screen and (min-width: 768px) { + #top { + display: flex; + flex-wrap: wrap; + justify-content: space-between; + align-items: center; + } +} + +#main-nav { + flex-grow: 5; + padding: var(--spacing-small) var(--spacing-medium); +} + +#titlearea { + width: auto; + padding: var(--spacing-medium) var(--spacing-large); + background: none; + color: var(--header-foreground); + border-bottom: none; +} + +@media screen and (max-width: 767px) { + #titlearea { + padding-bottom: var(--spacing-small); + } +} + +#titlearea table tbody tr { + height: auto !important; +} + +#projectname { + font-size: var(--title-font-size); + font-weight: 600; +} + +#projectnumber { + font-family: inherit; + font-size: 60%; +} + +#projectbrief { + font-family: inherit; + font-size: 80%; +} + +#projectlogo { + vertical-align: middle; +} + +#projectlogo img { + max-height: calc(var(--title-font-size) * 2); + margin-right: var(--spacing-small); +} + +.sm-dox, .tabs, .tabs2, .tabs3 { + background: none; + padding: 0; +} + +.tabs, .tabs2, .tabs3 { + border-bottom: 1px solid var(--separator-color); + margin-bottom: -1px; +} + +.main-menu-btn-icon, .main-menu-btn-icon:before, .main-menu-btn-icon:after { + background: var(--page-secondary-foreground-color); +} + +@media screen and (max-width: 767px) { + .sm-dox a span.sub-arrow { + background: var(--code-background); + } + + #main-menu a.has-submenu span.sub-arrow { + color: var(--page-secondary-foreground-color); + border-radius: var(--border-radius-medium); + } + + #main-menu a.has-submenu:hover span.sub-arrow { + color: var(--page-foreground-color); + } +} + +@media screen and (min-width: 768px) { + .sm-dox li, .tablist li { + display: var(--menu-display); + } + + .sm-dox a span.sub-arrow { + border-color: var(--header-foreground) transparent transparent transparent; + } + + .sm-dox a:hover span.sub-arrow { + border-color: var(--menu-focus-foreground) transparent transparent transparent; + } + + .sm-dox ul a span.sub-arrow { + border-color: transparent transparent transparent var(--page-foreground-color); + } + + .sm-dox ul a:hover span.sub-arrow { + border-color: transparent transparent transparent var(--menu-focus-foreground); + } +} + +.sm-dox ul { + background: var(--page-background-color); + box-shadow: var(--box-shadow); + border: 1px solid var(--separator-color); + border-radius: var(--border-radius-medium) !important; + padding: var(--spacing-small); + animation: ease-out 150ms slideInMenu; +} + +@keyframes slideInMenu { + from { + opacity: 0; + transform: translate(0px, -2px); + } + + to { + opacity: 1; + transform: translate(0px, 0px); + } +} + +.sm-dox ul a { + color: var(--page-foreground-color) !important; + background: var(--page-background-color); + font-size: var(--navigation-font-size); +} + +.sm-dox>li>ul:after { + border-bottom-color: var(--page-background-color) !important; +} + +.sm-dox>li>ul:before { + border-bottom-color: var(--separator-color) !important; +} + +.sm-dox ul a:hover, .sm-dox ul a:active, .sm-dox ul a:focus { + font-size: var(--navigation-font-size) !important; + color: var(--menu-focus-foreground) !important; + text-shadow: none; + background-color: var(--menu-focus-background); + border-radius: var(--border-radius-small) !important; +} + +.sm-dox a, .sm-dox a:focus, .tablist li, .tablist li a, .tablist li.current a { + text-shadow: none; + background: transparent; + background-image: none !important; + color: var(--header-foreground) !important; + font-weight: normal; + font-size: var(--navigation-font-size); + border-radius: var(--border-radius-small) !important; +} + +.sm-dox a:focus { + outline: auto; +} + +.sm-dox a:hover, .sm-dox a:active, .tablist li a:hover { + text-shadow: none; + font-weight: normal; + background: var(--menu-focus-background); + color: var(--menu-focus-foreground) !important; + border-radius: var(--border-radius-small) !important; + font-size: var(--navigation-font-size); +} + +.tablist li.current { + border-radius: var(--border-radius-small); + background: var(--menu-selected-background); +} + +.tablist li { + margin: var(--spacing-small) 0 var(--spacing-small) var(--spacing-small); +} + +.tablist a { + padding: 0 var(--spacing-large); +} + + +/* + Search box + */ + +#MSearchBox { + height: var(--searchbar-height); + background: var(--searchbar-background); + border-radius: var(--searchbar-border-radius); + border: 1px solid var(--separator-color); + overflow: hidden; + width: var(--searchbar-width); + position: relative; + box-shadow: none; + display: block; + margin-top: 0; +} + +/* until Doxygen 1.9.4 */ +.left img#MSearchSelect { + left: 0; + user-select: none; + padding-left: 8px; +} + +/* Doxygen 1.9.5 */ +.left span#MSearchSelect { + left: 0; + user-select: none; + margin-left: 8px; + padding: 0; +} + +.left #MSearchSelect[src$=".png"] { + padding-left: 0 +} + +.SelectionMark { + user-select: none; +} + +.tabs .left #MSearchSelect { + padding-left: 0; +} + +.tabs #MSearchBox { + position: absolute; + right: var(--spacing-medium); +} + +@media screen and (max-width: 767px) { + .tabs #MSearchBox { + position: relative; + right: 0; + margin-left: var(--spacing-medium); + margin-top: 0; + } +} + +#MSearchSelectWindow, #MSearchResultsWindow { + z-index: 9999; +} + +#MSearchBox.MSearchBoxActive { + border-color: var(--primary-color); + box-shadow: inset 0 0 0 1px var(--primary-color); +} + +#main-menu > li:last-child { + margin-right: 0; +} + +@media screen and (max-width: 767px) { + #main-menu > li:last-child { + height: 50px; + } +} + +#MSearchField { + font-size: var(--navigation-font-size); + height: calc(var(--searchbar-height) - 2px); + background: transparent; + width: calc(var(--searchbar-width) - 64px); +} + +.MSearchBoxActive #MSearchField { + color: var(--searchbar-foreground); +} + +#MSearchSelect { + top: calc(calc(var(--searchbar-height) / 2) - 11px); +} + +#MSearchBox span.left, #MSearchBox span.right { + background: none; + background-image: none; +} + +#MSearchBox span.right { + padding-top: calc(calc(var(--searchbar-height) / 2) - 12px); + position: absolute; + right: var(--spacing-small); +} + +.tabs #MSearchBox span.right { + top: calc(calc(var(--searchbar-height) / 2) - 12px); +} + +@keyframes slideInSearchResults { + from { + opacity: 0; + transform: translate(0, 15px); + } + + to { + opacity: 1; + transform: translate(0, 20px); + } +} + +#MSearchResultsWindow { + left: auto !important; + right: var(--spacing-medium); + border-radius: var(--border-radius-large); + border: 1px solid var(--separator-color); + transform: translate(0, 20px); + box-shadow: var(--box-shadow); + animation: ease-out 280ms slideInSearchResults; + background: var(--page-background-color); +} + +iframe#MSearchResults { + margin: 4px; +} + +iframe { + color-scheme: normal; +} + +@media (prefers-color-scheme: dark) { + html:not(.light-mode) iframe#MSearchResults { + filter: invert() hue-rotate(180deg); + } +} + +html.dark-mode iframe#MSearchResults { + filter: invert() hue-rotate(180deg); +} + +#MSearchResults .SRPage { + background-color: transparent; +} + +#MSearchResults .SRPage .SREntry { + font-size: 10pt; + padding: var(--spacing-small) var(--spacing-medium); +} + +#MSearchSelectWindow { + border: 1px solid var(--separator-color); + border-radius: var(--border-radius-medium); + box-shadow: var(--box-shadow); + background: var(--page-background-color); + padding-top: var(--spacing-small); + padding-bottom: var(--spacing-small); +} + +#MSearchSelectWindow a.SelectItem { + font-size: var(--navigation-font-size); + line-height: var(--content-line-height); + margin: 0 var(--spacing-small); + border-radius: var(--border-radius-small); + color: var(--page-foreground-color) !important; + font-weight: normal; +} + +#MSearchSelectWindow a.SelectItem:hover { + background: var(--menu-focus-background); + color: var(--menu-focus-foreground) !important; +} + +@media screen and (max-width: 767px) { + #MSearchBox { + margin-top: var(--spacing-medium); + margin-bottom: var(--spacing-medium); + width: calc(100vw - 30px); + } + + #main-menu > li:last-child { + float: none !important; + } + + #MSearchField { + width: calc(100vw - 110px); + } + + @keyframes slideInSearchResultsMobile { + from { + opacity: 0; + transform: translate(0, 15px); + } + + to { + opacity: 1; + transform: translate(0, 20px); + } + } + + #MSearchResultsWindow { + left: var(--spacing-medium) !important; + right: var(--spacing-medium); + overflow: auto; + transform: translate(0, 20px); + animation: ease-out 280ms slideInSearchResultsMobile; + width: auto !important; + } + + /* + * Overwrites for fixing the searchbox on mobile in doxygen 1.9.2 + */ + label.main-menu-btn ~ #searchBoxPos1 { + top: 3px !important; + right: 6px !important; + left: 45px; + display: flex; + } + + label.main-menu-btn ~ #searchBoxPos1 > #MSearchBox { + margin-top: 0; + margin-bottom: 0; + flex-grow: 2; + float: left; + } +} + +/* + Tree view + */ + +#side-nav { + padding: 0 !important; + background: var(--side-nav-background); +} + +@media screen and (max-width: 767px) { + #side-nav { + display: none; + } + + #doc-content { + margin-left: 0 !important; + } +} + +#nav-tree { + background: transparent; +} + +#nav-tree .label { + font-size: var(--navigation-font-size); +} + +#nav-tree .item { + height: var(--tree-item-height); + line-height: var(--tree-item-height); +} + +#nav-sync { + bottom: 12px; + right: 12px; + top: auto !important; + user-select: none; +} + +#nav-tree .selected { + text-shadow: none; + background-image: none; + background-color: transparent; + position: relative; +} + +#nav-tree .selected::after { + content: ""; + position: absolute; + top: 1px; + bottom: 1px; + left: 0; + width: 4px; + border-radius: 0 var(--border-radius-small) var(--border-radius-small) 0; + background: var(--primary-color); +} + + +#nav-tree a { + color: var(--side-nav-foreground) !important; + font-weight: normal; +} + +#nav-tree a:focus { + outline-style: auto; +} + +#nav-tree .arrow { + opacity: var(--side-nav-arrow-opacity); +} + +.arrow { + color: inherit; + cursor: pointer; + font-size: 45%; + vertical-align: middle; + margin-right: 2px; + font-family: serif; + height: auto; + text-align: right; +} + +#nav-tree div.item:hover .arrow, #nav-tree a:focus .arrow { + opacity: var(--side-nav-arrow-hover-opacity); +} + +#nav-tree .selected a { + color: var(--primary-color) !important; + font-weight: bolder; + font-weight: 600; +} + +.ui-resizable-e { + background: var(--separator-color); + width: 1px; +} + +/* + Contents + */ + +div.header { + border-bottom: 1px solid var(--separator-color); + background-color: var(--page-background-color); + background-image: none; +} + +@media screen and (min-width: 1000px) { + #doc-content > div > div.contents, + .PageDoc > div.contents { + display: flex; + flex-direction: row-reverse; + flex-wrap: nowrap; + align-items: flex-start; + } + + div.contents .textblock { + min-width: 200px; + flex-grow: 1; + } +} + +div.contents, div.header .title, div.header .summary { + max-width: var(--content-maxwidth); +} + +div.contents, div.header .title { + line-height: initial; + margin: calc(var(--spacing-medium) + .2em) auto var(--spacing-medium) auto; +} + +div.header .summary { + margin: var(--spacing-medium) auto 0 auto; +} + +div.headertitle { + padding: 0; +} + +div.header .title { + font-weight: 600; + font-size: 225%; + padding: var(--spacing-medium) var(--spacing-large); + word-break: break-word; +} + +div.header .summary { + width: auto; + display: block; + float: none; + padding: 0 var(--spacing-large); +} + +td.memSeparator { + border-color: var(--separator-color); +} + +span.mlabel { + background: var(--primary-color); + border: none; + padding: 4px 9px; + border-radius: 12px; + margin-right: var(--spacing-medium); +} + +span.mlabel:last-of-type { + margin-right: 2px; +} + +div.contents { + padding: 0 var(--spacing-large); +} + +div.contents p, div.contents li { + line-height: var(--content-line-height); +} + +div.contents div.dyncontent { + margin: var(--spacing-medium) 0; +} + +@media (prefers-color-scheme: dark) { + html:not(.light-mode) div.contents div.dyncontent img, + html:not(.light-mode) div.contents center img, + html:not(.light-mode) div.contents > table img, + html:not(.light-mode) div.contents div.dyncontent iframe, + html:not(.light-mode) div.contents center iframe, + html:not(.light-mode) div.contents table iframe { + filter: hue-rotate(180deg) invert(); + } +} + +html.dark-mode div.contents div.dyncontent img, +html.dark-mode div.contents center img, +html.dark-mode div.contents > table img, +html.dark-mode div.contents div.dyncontent iframe, +html.dark-mode div.contents center iframe, +html.dark-mode div.contents table iframe { + filter: hue-rotate(180deg) invert(); +} + +h2.groupheader { + border-bottom: 0px; + color: var(--page-foreground-color); + box-shadow: + 100px 0 var(--page-background-color), + -100px 0 var(--page-background-color), + 100px 0.75px var(--separator-color), + -100px 0.75px var(--separator-color), + 500px 0 var(--page-background-color), + -500px 0 var(--page-background-color), + 500px 0.75px var(--separator-color), + -500px 0.75px var(--separator-color), + 900px 0 var(--page-background-color), + -900px 0 var(--page-background-color), + 900px 0.75px var(--separator-color), + -900px 0.75px var(--separator-color), + 1400px 0 var(--page-background-color), + -1400px 0 var(--page-background-color), + 1400px 0.75px var(--separator-color), + -1400px 0.75px var(--separator-color), + 1900px 0 var(--page-background-color), + -1900px 0 var(--page-background-color), + 1900px 0.75px var(--separator-color), + -1900px 0.75px var(--separator-color); +} + +blockquote { + margin: 0 var(--spacing-medium) 0 var(--spacing-medium); + padding: var(--spacing-small) var(--spacing-large); + background: var(--blockquote-background); + color: var(--blockquote-foreground); + border-left: 0; + overflow: visible; + border-radius: var(--border-radius-medium); + overflow: visible; + position: relative; +} + +blockquote::before, blockquote::after { + font-weight: bold; + font-family: serif; + font-size: 360%; + opacity: .15; + position: absolute; +} + +blockquote::before { + content: "“"; + left: -10px; + top: 4px; +} + +blockquote::after { + content: "”"; + right: -8px; + bottom: -25px; +} + +blockquote p { + margin: var(--spacing-small) 0 var(--spacing-medium) 0; +} +.paramname { + font-weight: 600; + color: var(--primary-dark-color); +} + +.paramname > code { + border: 0; +} + +table.params .paramname { + font-weight: 600; + font-family: var(--font-family-monospace); + font-size: var(--code-font-size); + padding-right: var(--spacing-small); + line-height: var(--table-line-height); +} + +h1.glow, h2.glow, h3.glow, h4.glow, h5.glow, h6.glow { + text-shadow: 0 0 15px var(--primary-light-color); +} + +.alphachar a { + color: var(--page-foreground-color); +} + +/* + Table of Contents + */ + +div.contents .toc { + max-height: var(--toc-max-height); + min-width: var(--toc-width); + border: 0; + border-left: 1px solid var(--separator-color); + border-radius: 0; + background-color: transparent; + box-shadow: none; + position: sticky; + top: var(--toc-sticky-top); + padding: 0 var(--spacing-large); + margin: var(--spacing-small) 0 var(--spacing-large) var(--spacing-large); +} + +div.toc h3 { + color: var(--toc-foreground); + font-size: var(--navigation-font-size); + margin: var(--spacing-large) 0 var(--spacing-medium) 0; +} + +div.toc li { + padding: 0; + background: none; + line-height: var(--toc-font-size); + margin: var(--toc-font-size) 0 0 0; +} + +div.toc li::before { + display: none; +} + +div.toc ul { + margin-top: 0 +} + +div.toc li a { + font-size: var(--toc-font-size); + color: var(--page-foreground-color) !important; + text-decoration: none; +} + +div.toc li a:hover, div.toc li a.active { + color: var(--primary-color) !important; +} + +div.toc li a.aboveActive { + color: var(--page-secondary-foreground-color) !important; +} + + +@media screen and (max-width: 999px) { + div.contents .toc { + max-height: 45vh; + float: none; + width: auto; + margin: 0 0 var(--spacing-medium) 0; + position: relative; + top: 0; + position: relative; + border: 1px solid var(--separator-color); + border-radius: var(--border-radius-medium); + background-color: var(--toc-background); + box-shadow: var(--box-shadow); + } + + div.contents .toc.interactive { + max-height: calc(var(--navigation-font-size) + 2 * var(--spacing-large)); + overflow: hidden; + } + + div.contents .toc > h3 { + -webkit-tap-highlight-color: transparent; + cursor: pointer; + position: sticky; + top: 0; + background-color: var(--toc-background); + margin: 0; + padding: var(--spacing-large) 0; + display: block; + } + + div.contents .toc.interactive > h3::before { + content: ""; + width: 0; + height: 0; + border-left: 4px solid transparent; + border-right: 4px solid transparent; + border-top: 5px solid var(--primary-color); + display: inline-block; + margin-right: var(--spacing-small); + margin-bottom: calc(var(--navigation-font-size) / 4); + transform: rotate(-90deg); + transition: transform 0.25s ease-out; + } + + div.contents .toc.interactive.open > h3::before { + transform: rotate(0deg); + } + + div.contents .toc.interactive.open { + max-height: 45vh; + overflow: auto; + transition: max-height 0.2s ease-in-out; + } + + div.contents .toc a, div.contents .toc a.active { + color: var(--primary-color) !important; + } + + div.contents .toc a:hover { + text-decoration: underline; + } +} + +/* + Code & Fragments + */ + +code, div.fragment, pre.fragment { + border-radius: var(--border-radius-small); + border: 1px solid var(--separator-color); + overflow: hidden; +} + +code { + display: inline; + background: var(--code-background); + color: var(--code-foreground); + padding: 2px 6px; +} + +div.fragment, pre.fragment { + margin: var(--spacing-medium) 0; + padding: calc(var(--spacing-large) - (var(--spacing-large) / 6)) var(--spacing-large); + background: var(--fragment-background); + color: var(--fragment-foreground); + overflow-x: auto; +} + +@media screen and (max-width: 767px) { + div.fragment, pre.fragment { + border-top-right-radius: 0; + border-bottom-right-radius: 0; + border-right: 0; + } + + .contents > div.fragment, + .textblock > div.fragment, + .textblock > pre.fragment, + .contents > .doxygen-awesome-fragment-wrapper > div.fragment, + .textblock > .doxygen-awesome-fragment-wrapper > div.fragment, + .textblock > .doxygen-awesome-fragment-wrapper > pre.fragment { + margin: var(--spacing-medium) calc(0px - var(--spacing-large)); + border-radius: 0; + border-left: 0; + } + + .textblock li > .fragment, + .textblock li > .doxygen-awesome-fragment-wrapper > .fragment { + margin: var(--spacing-medium) calc(0px - var(--spacing-large)); + } + + .memdoc li > .fragment, + .memdoc li > .doxygen-awesome-fragment-wrapper > .fragment { + margin: var(--spacing-medium) calc(0px - var(--spacing-medium)); + } + + .textblock ul, .memdoc ul { + overflow: initial; + } + + .memdoc > div.fragment, + .memdoc > pre.fragment, + dl dd > div.fragment, + dl dd pre.fragment, + .memdoc > .doxygen-awesome-fragment-wrapper > div.fragment, + .memdoc > .doxygen-awesome-fragment-wrapper > pre.fragment, + dl dd > .doxygen-awesome-fragment-wrapper > div.fragment, + dl dd .doxygen-awesome-fragment-wrapper > pre.fragment { + margin: var(--spacing-medium) calc(0px - var(--spacing-medium)); + border-radius: 0; + border-left: 0; + } +} + +code, code a, pre.fragment, div.fragment, div.fragment .line, div.fragment span, div.fragment .line a, div.fragment .line span { + font-family: var(--font-family-monospace); + font-size: var(--code-font-size) !important; +} + +div.line:after { + margin-right: var(--spacing-medium); +} + +div.fragment .line, pre.fragment { + white-space: pre; + word-wrap: initial; + line-height: var(--fragment-lineheight); +} + +div.fragment span.keyword { + color: var(--fragment-keyword); +} + +div.fragment span.keywordtype { + color: var(--fragment-keywordtype); +} + +div.fragment span.keywordflow { + color: var(--fragment-keywordflow); +} + +div.fragment span.stringliteral { + color: var(--fragment-token) +} + +div.fragment span.comment { + color: var(--fragment-comment); +} + +div.fragment a.code { + color: var(--fragment-link) !important; +} + +div.fragment span.preprocessor { + color: var(--fragment-preprocessor); +} + +div.fragment span.lineno { + display: inline-block; + width: 27px; + border-right: none; + background: var(--fragment-linenumber-background); + color: var(--fragment-linenumber-color); +} + +div.fragment span.lineno a { + background: none; + color: var(--fragment-link) !important; +} + +div.fragment .line:first-child .lineno { + box-shadow: -999999px 0px 0 999999px var(--fragment-linenumber-background), -999998px 0px 0 999999px var(--fragment-linenumber-border); +} + +div.line { + border-radius: var(--border-radius-small); +} + +div.line.glow { + background-color: var(--primary-light-color); + box-shadow: none; +} + +/* + dl warning, attention, note, deprecated, bug, ... + */ + +dl.bug dt a, dl.deprecated dt a, dl.todo dt a { + font-weight: bold !important; +} + +dl.warning, dl.attention, dl.note, dl.deprecated, dl.bug, dl.invariant, dl.pre, dl.todo, dl.remark { + padding: var(--spacing-medium); + margin: var(--spacing-medium) 0; + color: var(--page-background-color); + overflow: hidden; + margin-left: 0; + border-radius: var(--border-radius-small); +} + +dl.section dd { + margin-bottom: 2px; +} + +dl.warning, dl.attention { + background: var(--warning-color); + border-left: 8px solid var(--warning-color-dark); + color: var(--warning-color-darker); +} + +dl.warning dt, dl.attention dt { + color: var(--warning-color-dark); +} + +dl.note, dl.remark { + background: var(--note-color); + border-left: 8px solid var(--note-color-dark); + color: var(--note-color-darker); +} + +dl.note dt, dl.remark dt { + color: var(--note-color-dark); +} + +dl.todo { + background: var(--todo-color); + border-left: 8px solid var(--todo-color-dark); + color: var(--todo-color-darker); +} + +dl.todo dt { + color: var(--todo-color-dark); +} + +dl.bug dt a { + color: var(--todo-color-dark) !important; +} + +dl.bug { + background: var(--bug-color); + border-left: 8px solid var(--bug-color-dark); + color: var(--bug-color-darker); +} + +dl.bug dt a { + color: var(--bug-color-dark) !important; +} + +dl.deprecated { + background: var(--deprecated-color); + border-left: 8px solid var(--deprecated-color-dark); + color: var(--deprecated-color-darker); +} + +dl.deprecated dt a { + color: var(--deprecated-color-dark) !important; +} + +dl.section dd, dl.bug dd, dl.deprecated dd, dl.todo dd { + margin-inline-start: 0px; +} + +dl.invariant, dl.pre { + background: var(--invariant-color); + border-left: 8px solid var(--invariant-color-dark); + color: var(--invariant-color-darker); +} + +dl.invariant dt, dl.pre dt { + color: var(--invariant-color-dark); +} + +/* + memitem + */ + +div.memdoc, div.memproto, h2.memtitle { + box-shadow: none; + background-image: none; + border: none; +} + +div.memdoc { + padding: 0 var(--spacing-medium); + background: var(--page-background-color); +} + +h2.memtitle, div.memitem { + border: 1px solid var(--separator-color); + box-shadow: var(--box-shadow); +} + +h2.memtitle { + box-shadow: 0px var(--spacing-medium) 0 -1px var(--fragment-background), var(--box-shadow); +} + +div.memitem { + transition: none; +} + +div.memproto, h2.memtitle { + background: var(--fragment-background); +} + +h2.memtitle { + font-weight: 500; + font-size: var(--memtitle-font-size); + font-family: var(--font-family-monospace); + border-bottom: none; + border-top-left-radius: var(--border-radius-medium); + border-top-right-radius: var(--border-radius-medium); + word-break: break-all; + position: relative; +} + +h2.memtitle:after { + content: ""; + display: block; + background: var(--fragment-background); + height: var(--spacing-medium); + bottom: calc(0px - var(--spacing-medium)); + left: 0; + right: -14px; + position: absolute; + border-top-right-radius: var(--border-radius-medium); +} + +h2.memtitle > span.permalink { + font-size: inherit; +} + +h2.memtitle > span.permalink > a { + text-decoration: none; + padding-left: 3px; + margin-right: -4px; + user-select: none; + display: inline-block; + margin-top: -6px; +} + +h2.memtitle > span.permalink > a:hover { + color: var(--primary-dark-color) !important; +} + +a:target + h2.memtitle, a:target + h2.memtitle + div.memitem { + border-color: var(--primary-light-color); +} + +div.memitem { + border-top-right-radius: var(--border-radius-medium); + border-bottom-right-radius: var(--border-radius-medium); + border-bottom-left-radius: var(--border-radius-medium); + overflow: hidden; + display: block !important; +} + +div.memdoc { + border-radius: 0; +} + +div.memproto { + border-radius: 0 var(--border-radius-small) 0 0; + overflow: auto; + border-bottom: 1px solid var(--separator-color); + padding: var(--spacing-medium); + margin-bottom: -1px; +} + +div.memtitle { + border-top-right-radius: var(--border-radius-medium); + border-top-left-radius: var(--border-radius-medium); +} + +div.memproto table.memname { + font-family: var(--font-family-monospace); + color: var(--page-foreground-color); + font-size: var(--memname-font-size); + text-shadow: none; +} + +div.memproto div.memtemplate { + font-family: var(--font-family-monospace); + color: var(--primary-dark-color); + font-size: var(--memname-font-size); + margin-left: 2px; + text-shadow: none; +} + +table.mlabels, table.mlabels > tbody { + display: block; +} + +td.mlabels-left { + width: auto; +} + +td.mlabels-right { + margin-top: 3px; + position: sticky; + left: 0; +} + +table.mlabels > tbody > tr:first-child { + display: flex; + justify-content: space-between; + flex-wrap: wrap; +} + +.memname, .memitem span.mlabels { + margin: 0 +} + +/* + reflist + */ + +dl.reflist { + box-shadow: var(--box-shadow); + border-radius: var(--border-radius-medium); + border: 1px solid var(--separator-color); + overflow: hidden; + padding: 0; +} + + +dl.reflist dt, dl.reflist dd { + box-shadow: none; + text-shadow: none; + background-image: none; + border: none; + padding: 12px; +} + + +dl.reflist dt { + font-weight: 500; + border-radius: 0; + background: var(--code-background); + border-bottom: 1px solid var(--separator-color); + color: var(--page-foreground-color) +} + + +dl.reflist dd { + background: none; +} + +/* + Table + */ + +.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname), +.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody { + display: inline-block; + max-width: 100%; +} + +.contents > table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname):not(.classindex) { + margin-left: calc(0px - var(--spacing-large)); + margin-right: calc(0px - var(--spacing-large)); + max-width: calc(100% + 2 * var(--spacing-large)); +} + +table.fieldtable, +table.markdownTable tbody, +table.doxtable tbody { + border: none; + margin: var(--spacing-medium) 0; + box-shadow: 0 0 0 1px var(--separator-color); + border-radius: var(--border-radius-small); +} + +table.doxtable caption { + display: block; +} + +table.fieldtable { + border-collapse: collapse; + width: 100%; +} + +th.markdownTableHeadLeft, +th.markdownTableHeadRight, +th.markdownTableHeadCenter, +th.markdownTableHeadNone, +table.doxtable th { + background: var(--tablehead-background); + color: var(--tablehead-foreground); + font-weight: 600; + font-size: var(--page-font-size); +} + +th.markdownTableHeadLeft:first-child, +th.markdownTableHeadRight:first-child, +th.markdownTableHeadCenter:first-child, +th.markdownTableHeadNone:first-child, +table.doxtable tr th:first-child { + border-top-left-radius: var(--border-radius-small); +} + +th.markdownTableHeadLeft:last-child, +th.markdownTableHeadRight:last-child, +th.markdownTableHeadCenter:last-child, +th.markdownTableHeadNone:last-child, +table.doxtable tr th:last-child { + border-top-right-radius: var(--border-radius-small); +} + +table.markdownTable td, +table.markdownTable th, +table.fieldtable td, +table.fieldtable th, +table.doxtable td, +table.doxtable th { + border: 1px solid var(--separator-color); + padding: var(--spacing-small) var(--spacing-medium); +} + +table.markdownTable td:last-child, +table.markdownTable th:last-child, +table.fieldtable td:last-child, +table.fieldtable th:last-child, +table.doxtable td:last-child, +table.doxtable th:last-child { + border-right: none; +} + +table.markdownTable td:first-child, +table.markdownTable th:first-child, +table.fieldtable td:first-child, +table.fieldtable th:first-child, +table.doxtable td:first-child, +table.doxtable th:first-child { + border-left: none; +} + +table.markdownTable tr:first-child td, +table.markdownTable tr:first-child th, +table.fieldtable tr:first-child td, +table.fieldtable tr:first-child th, +table.doxtable tr:first-child td, +table.doxtable tr:first-child th { + border-top: none; +} + +table.markdownTable tr:last-child td, +table.markdownTable tr:last-child th, +table.fieldtable tr:last-child td, +table.fieldtable tr:last-child th, +table.doxtable tr:last-child td, +table.doxtable tr:last-child th { + border-bottom: none; +} + +table.markdownTable tr, table.doxtable tr { + border-bottom: 1px solid var(--separator-color); +} + +table.markdownTable tr:last-child, table.doxtable tr:last-child { + border-bottom: none; +} + +table.fieldtable th { + font-size: var(--page-font-size); + font-weight: 600; + background-image: none; + background-color: var(--tablehead-background); + color: var(--tablehead-foreground); +} + +table.fieldtable td.fieldtype, .fieldtable td.fieldname, .fieldtable td.fielddoc, .fieldtable th { + border-bottom: 1px solid var(--separator-color); + border-right: 1px solid var(--separator-color); +} + +table.fieldtable tr:last-child td:first-child { + border-bottom-left-radius: var(--border-radius-small); +} + +table.fieldtable tr:last-child td:last-child { + border-bottom-right-radius: var(--border-radius-small); +} + +.memberdecls td.glow, .fieldtable tr.glow { + background-color: var(--primary-light-color); + box-shadow: none; +} + +table.memberdecls { + display: block; + -webkit-tap-highlight-color: transparent; +} + +table.memberdecls tr[class^='memitem'] { + font-family: var(--font-family-monospace); + font-size: var(--code-font-size); +} + +table.memberdecls tr[class^='memitem'] .memTemplParams { + font-family: var(--font-family-monospace); + font-size: var(--code-font-size); + color: var(--primary-dark-color); + white-space: normal; +} + +table.memberdecls .memItemLeft, +table.memberdecls .memItemRight, +table.memberdecls .memTemplItemLeft, +table.memberdecls .memTemplItemRight, +table.memberdecls .memTemplParams { + transition: none; + padding-top: var(--spacing-small); + padding-bottom: var(--spacing-small); + border-top: 1px solid var(--separator-color); + border-bottom: 1px solid var(--separator-color); + background-color: var(--fragment-background); +} + +table.memberdecls .memTemplItemLeft, +table.memberdecls .memTemplItemRight { + padding-top: 2px; +} + +table.memberdecls .memTemplParams { + border-bottom: 0; + border-left: 1px solid var(--separator-color); + border-right: 1px solid var(--separator-color); + border-radius: var(--border-radius-small) var(--border-radius-small) 0 0; + padding-bottom: var(--spacing-small); +} + +table.memberdecls .memTemplItemLeft { + border-radius: 0 0 0 var(--border-radius-small); + border-left: 1px solid var(--separator-color); + border-top: 0; +} + +table.memberdecls .memTemplItemRight { + border-radius: 0 0 var(--border-radius-small) 0; + border-right: 1px solid var(--separator-color); + padding-left: 0; + border-top: 0; +} + +table.memberdecls .memItemLeft { + border-radius: var(--border-radius-small) 0 0 var(--border-radius-small); + border-left: 1px solid var(--separator-color); + padding-left: var(--spacing-medium); + padding-right: 0; +} + +table.memberdecls .memItemRight { + border-radius: 0 var(--border-radius-small) var(--border-radius-small) 0; + border-right: 1px solid var(--separator-color); + padding-right: var(--spacing-medium); + padding-left: 0; + +} + +table.memberdecls .mdescLeft, table.memberdecls .mdescRight { + background: none; + color: var(--page-foreground-color); + padding: var(--spacing-small) 0; +} + +table.memberdecls .memItemLeft, +table.memberdecls .memTemplItemLeft { + padding-right: var(--spacing-medium); +} + +table.memberdecls .memSeparator { + background: var(--page-background-color); + height: var(--spacing-large); + border: 0; + transition: none; +} + +table.memberdecls .groupheader { + margin-bottom: var(--spacing-large); +} + +table.memberdecls .inherit_header td { + padding: 0 0 var(--spacing-medium) 0; + text-indent: -12px; + color: var(--page-secondary-foreground-color); +} + +table.memberdecls img[src="closed.png"], +table.memberdecls img[src="open.png"], +div.dynheader img[src="open.png"], +div.dynheader img[src="closed.png"] { + width: 0; + height: 0; + border-left: 4px solid transparent; + border-right: 4px solid transparent; + border-top: 5px solid var(--primary-color); + margin-top: 8px; + display: block; + float: left; + margin-left: -10px; + transition: transform 0.25s ease-out; +} + +table.memberdecls img { + margin-right: 10px; +} + +table.memberdecls img[src="closed.png"], +div.dynheader img[src="closed.png"] { + transform: rotate(-90deg); + +} + +.compoundTemplParams { + font-family: var(--font-family-monospace); + color: var(--primary-dark-color); + font-size: var(--code-font-size); +} + +@media screen and (max-width: 767px) { + + table.memberdecls .memItemLeft, + table.memberdecls .memItemRight, + table.memberdecls .mdescLeft, + table.memberdecls .mdescRight, + table.memberdecls .memTemplItemLeft, + table.memberdecls .memTemplItemRight, + table.memberdecls .memTemplParams { + display: block; + text-align: left; + padding-left: var(--spacing-large); + margin: 0 calc(0px - var(--spacing-large)) 0 calc(0px - var(--spacing-large)); + border-right: none; + border-left: none; + border-radius: 0; + white-space: normal; + } + + table.memberdecls .memItemLeft, + table.memberdecls .mdescLeft, + table.memberdecls .memTemplItemLeft { + border-bottom: 0; + padding-bottom: 0; + } + + table.memberdecls .memTemplItemLeft { + padding-top: 0; + } + + table.memberdecls .mdescLeft { + margin-bottom: calc(0px - var(--page-font-size)); + } + + table.memberdecls .memItemRight, + table.memberdecls .mdescRight, + table.memberdecls .memTemplItemRight { + border-top: 0; + padding-top: 0; + padding-right: var(--spacing-large); + overflow-x: auto; + } + + table.memberdecls tr[class^='memitem']:not(.inherit) { + display: block; + width: calc(100vw - 2 * var(--spacing-large)); + } + + table.memberdecls .mdescRight { + color: var(--page-foreground-color); + } + + table.memberdecls tr.inherit { + visibility: hidden; + } + + table.memberdecls tr[style="display: table-row;"] { + display: block !important; + visibility: visible; + width: calc(100vw - 2 * var(--spacing-large)); + animation: fade .5s; + } + + @keyframes fade { + 0% { + opacity: 0; + max-height: 0; + } + + 100% { + opacity: 1; + max-height: 200px; + } + } +} + + +/* + Horizontal Rule + */ + +hr { + margin-top: var(--spacing-large); + margin-bottom: var(--spacing-large); + height: 1px; + background-color: var(--separator-color); + border: 0; +} + +.contents hr { + box-shadow: 100px 0 0 var(--separator-color), + -100px 0 0 var(--separator-color), + 500px 0 0 var(--separator-color), + -500px 0 0 var(--separator-color), + 1500px 0 0 var(--separator-color), + -1500px 0 0 var(--separator-color), + 2000px 0 0 var(--separator-color), + -2000px 0 0 var(--separator-color); +} + +.contents img, .contents .center, .contents center, .contents div.image object { + max-width: 100%; + overflow: auto; +} + +@media screen and (max-width: 767px) { + .contents .dyncontent > .center, .contents > center { + margin-left: calc(0px - var(--spacing-large)); + margin-right: calc(0px - var(--spacing-large)); + max-width: calc(100% + 2 * var(--spacing-large)); + } +} + +/* + Directories + */ +div.directory { + border-top: 1px solid var(--separator-color); + border-bottom: 1px solid var(--separator-color); + width: auto; +} + +table.directory { + font-family: var(--font-family); + font-size: var(--page-font-size); + font-weight: normal; + width: 100%; +} + +table.directory td.entry, table.directory td.desc { + padding: calc(var(--spacing-small) / 2) var(--spacing-small); + line-height: var(--table-line-height); +} + +table.directory tr.even td:last-child { + border-radius: 0 var(--border-radius-small) var(--border-radius-small) 0; +} + +table.directory tr.even td:first-child { + border-radius: var(--border-radius-small) 0 0 var(--border-radius-small); +} + +table.directory tr.even:last-child td:last-child { + border-radius: 0 var(--border-radius-small) 0 0; +} + +table.directory tr.even:last-child td:first-child { + border-radius: var(--border-radius-small) 0 0 0; +} + +table.directory td.desc { + min-width: 250px; +} + +table.directory tr.even { + background-color: var(--odd-color); +} + +table.directory tr.odd { + background-color: transparent; +} + +.icona { + width: auto; + height: auto; + margin: 0 var(--spacing-small); +} + +.icon { + background: var(--primary-color); + border-radius: var(--border-radius-small); + font-size: var(--page-font-size); + padding: calc(var(--page-font-size) / 5); + line-height: var(--page-font-size); + transform: scale(0.8); + height: auto; + width: var(--page-font-size); + user-select: none; +} + +.iconfopen, .icondoc, .iconfclosed { + background-position: center; + margin-bottom: 0; + height: var(--table-line-height); +} + +.icondoc { + filter: saturate(0.2); +} + +@media screen and (max-width: 767px) { + div.directory { + margin-left: calc(0px - var(--spacing-large)); + margin-right: calc(0px - var(--spacing-large)); + } +} + +@media (prefers-color-scheme: dark) { + html:not(.light-mode) .iconfopen, html:not(.light-mode) .iconfclosed { + filter: hue-rotate(180deg) invert(); + } +} + +html.dark-mode .iconfopen, html.dark-mode .iconfclosed { + filter: hue-rotate(180deg) invert(); +} + +/* + Class list + */ + +.classindex dl.odd { + background: var(--odd-color); + border-radius: var(--border-radius-small); +} + +.classindex dl.even { + background-color: transparent; +} + +/* + Class Index Doxygen 1.8 +*/ + +table.classindex { + margin-left: 0; + margin-right: 0; + width: 100%; +} + +table.classindex table div.ah { + background-image: none; + background-color: initial; + border-color: var(--separator-color); + color: var(--page-foreground-color); + box-shadow: var(--box-shadow); + border-radius: var(--border-radius-large); + padding: var(--spacing-small); +} + +div.qindex { + background-color: var(--odd-color); + border-radius: var(--border-radius-small); + border: 1px solid var(--separator-color); + padding: var(--spacing-small) 0; +} + +/* + Footer and nav-path + */ + +#nav-path { + width: 100%; +} + +#nav-path ul { + background-image: none; + background: var(--page-background-color); + border: none; + border-top: 1px solid var(--separator-color); + border-bottom: 1px solid var(--separator-color); + border-bottom: 0; + box-shadow: 0 0.75px 0 var(--separator-color); + font-size: var(--navigation-font-size); +} + +img.footer { + width: 60px; +} + +.navpath li.footer { + color: var(--page-secondary-foreground-color); +} + +address.footer { + color: var(--page-secondary-foreground-color); + margin-bottom: var(--spacing-large); +} + +#nav-path li.navelem { + background-image: none; + display: flex; + align-items: center; +} + +.navpath li.navelem a { + text-shadow: none; + display: inline-block; + color: var(--primary-color) !important; +} + +.navpath li.navelem b { + color: var(--primary-dark-color); + font-weight: 500; +} + +li.navelem { + padding: 0; + margin-left: -8px; +} + +li.navelem:first-child { + margin-left: var(--spacing-large); +} + +li.navelem:first-child:before { + display: none; +} + +#nav-path li.navelem:after { + content: ''; + border: 5px solid var(--page-background-color); + border-bottom-color: transparent; + border-right-color: transparent; + border-top-color: transparent; + transform: translateY(-1px) scaleY(4.2); + z-index: 10; + margin-left: 6px; +} + +#nav-path li.navelem:before { + content: ''; + border: 5px solid var(--separator-color); + border-bottom-color: transparent; + border-right-color: transparent; + border-top-color: transparent; + transform: translateY(-1px) scaleY(3.2); + margin-right: var(--spacing-small); +} + +.navpath li.navelem a:hover { + color: var(--primary-color); +} + +/* + Scrollbars for Webkit +*/ + +#nav-tree::-webkit-scrollbar, +div.fragment::-webkit-scrollbar, +pre.fragment::-webkit-scrollbar, +div.memproto::-webkit-scrollbar, +.contents center::-webkit-scrollbar, +.contents .center::-webkit-scrollbar, +.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody::-webkit-scrollbar, +div.contents .toc::-webkit-scrollbar { + background: transparent; + width: calc(var(--webkit-scrollbar-size) + var(--webkit-scrollbar-padding) + var(--webkit-scrollbar-padding)); + height: calc(var(--webkit-scrollbar-size) + var(--webkit-scrollbar-padding) + var(--webkit-scrollbar-padding)); +} + +#nav-tree::-webkit-scrollbar-thumb, +div.fragment::-webkit-scrollbar-thumb, +pre.fragment::-webkit-scrollbar-thumb, +div.memproto::-webkit-scrollbar-thumb, +.contents center::-webkit-scrollbar-thumb, +.contents .center::-webkit-scrollbar-thumb, +.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody::-webkit-scrollbar-thumb, +div.contents .toc::-webkit-scrollbar-thumb { + background-color: transparent; + border: var(--webkit-scrollbar-padding) solid transparent; + border-radius: calc(var(--webkit-scrollbar-padding) + var(--webkit-scrollbar-padding)); + background-clip: padding-box; +} + +#nav-tree:hover::-webkit-scrollbar-thumb, +div.fragment:hover::-webkit-scrollbar-thumb, +pre.fragment:hover::-webkit-scrollbar-thumb, +div.memproto:hover::-webkit-scrollbar-thumb, +.contents center:hover::-webkit-scrollbar-thumb, +.contents .center:hover::-webkit-scrollbar-thumb, +.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody:hover::-webkit-scrollbar-thumb, +div.contents .toc:hover::-webkit-scrollbar-thumb { + background-color: var(--webkit-scrollbar-color); +} + +#nav-tree::-webkit-scrollbar-track, +div.fragment::-webkit-scrollbar-track, +pre.fragment::-webkit-scrollbar-track, +div.memproto::-webkit-scrollbar-track, +.contents center::-webkit-scrollbar-track, +.contents .center::-webkit-scrollbar-track, +.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody::-webkit-scrollbar-track, +div.contents .toc::-webkit-scrollbar-track { + background: transparent; +} + +#nav-tree::-webkit-scrollbar-corner { + background-color: var(--side-nav-background); +} + +#nav-tree, +div.fragment, +pre.fragment, +div.memproto, +.contents center, +.contents .center, +.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody, +div.contents .toc { + overflow-x: auto; + overflow-x: overlay; +} + +#nav-tree { + overflow-x: auto; + overflow-y: auto; + overflow-y: overlay; +} + +/* + Scrollbars for Firefox +*/ + +#nav-tree, +div.fragment, +pre.fragment, +div.memproto, +.contents center, +.contents .center, +.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody, +div.contents .toc { + scrollbar-width: thin; +} + +/* + Optional Dark mode toggle button +*/ + +doxygen-awesome-dark-mode-toggle { + display: inline-block; + margin: 0 0 0 var(--spacing-small); + padding: 0; + width: var(--searchbar-height); + height: var(--searchbar-height); + background: none; + border: none; + border-radius: var(--searchbar-height); + vertical-align: middle; + text-align: center; + line-height: var(--searchbar-height); + font-size: 22px; + display: flex; + align-items: center; + justify-content: center; + user-select: none; + cursor: pointer; +} + +doxygen-awesome-dark-mode-toggle > svg { + transition: transform .1s ease-in-out; +} + +doxygen-awesome-dark-mode-toggle:active > svg { + transform: scale(.5); +} + +doxygen-awesome-dark-mode-toggle:hover { + background-color: rgba(0,0,0,.03); +} + +html.dark-mode doxygen-awesome-dark-mode-toggle:hover { + background-color: rgba(0,0,0,.18); +} + +/* + Optional fragment copy button +*/ +.doxygen-awesome-fragment-wrapper { + position: relative; +} + +doxygen-awesome-fragment-copy-button { + opacity: 0; + background: var(--fragment-background); + width: 28px; + height: 28px; + position: absolute; + right: calc(var(--spacing-large) - (var(--spacing-large) / 2.5)); + top: calc(var(--spacing-large) - (var(--spacing-large) / 2.5)); + border: 1px solid var(--fragment-foreground); + cursor: pointer; + border-radius: var(--border-radius-small); + display: flex; + justify-content: center; + align-items: center; +} + +.doxygen-awesome-fragment-wrapper:hover doxygen-awesome-fragment-copy-button, doxygen-awesome-fragment-copy-button.success { + opacity: .28; +} + +doxygen-awesome-fragment-copy-button:hover, doxygen-awesome-fragment-copy-button.success { + opacity: 1 !important; +} + +doxygen-awesome-fragment-copy-button:active:not([class~=success]) svg { + transform: scale(.91); +} + +doxygen-awesome-fragment-copy-button svg { + fill: var(--fragment-foreground); + width: 18px; + height: 18px; +} + +doxygen-awesome-fragment-copy-button.success svg { + fill: rgb(14, 168, 14); +} + +doxygen-awesome-fragment-copy-button.success { + border-color: rgb(14, 168, 14); +} + +@media screen and (max-width: 767px) { + .textblock > .doxygen-awesome-fragment-wrapper > doxygen-awesome-fragment-copy-button, + .textblock li > .doxygen-awesome-fragment-wrapper > doxygen-awesome-fragment-copy-button, + .memdoc li > .doxygen-awesome-fragment-wrapper > doxygen-awesome-fragment-copy-button, + .memdoc > .doxygen-awesome-fragment-wrapper > doxygen-awesome-fragment-copy-button, + dl dd > .doxygen-awesome-fragment-wrapper > doxygen-awesome-fragment-copy-button { + right: 0; + } +} + +/* + Optional paragraph link button +*/ + +a.anchorlink { + font-size: 90%; + margin-left: var(--spacing-small); + color: var(--page-foreground-color) !important; + text-decoration: none; + opacity: .15; + display: none; + transition: opacity .1s ease-in-out, color .1s ease-in-out; +} + +a.anchorlink svg { + fill: var(--page-foreground-color); +} + +h3 a.anchorlink svg, h4 a.anchorlink svg { + margin-bottom: -3px; + margin-top: -4px; +} + +a.anchorlink:hover { + opacity: .45; +} + +h2:hover a.anchorlink, h1:hover a.anchorlink, h3:hover a.anchorlink, h4:hover a.anchorlink { + display: inline-block; +} + + +#MSearchBox .left { + background: none !important; +} +#MSearchBox .right { + background: none !important; +} diff --git a/dev/setup/apache/virtualhost b/dev/setup/apache/virtualhost index 7508bbca171..e8c5f2a8f4b 100644 --- a/dev/setup/apache/virtualhost +++ b/dev/setup/apache/virtualhost @@ -1,14 +1,15 @@ #php_admin_value sendmail_path "/usr/sbin/sendmail -t -i" #php_admin_value mail.force_extra_parameters "-f postmaster@mydomain.com" - php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f postmaster@mydomain.com" + #php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f postmaster@mydomain.com" + php_admin_value open_basedir /tmp/:/home/.../htdocs:/home/.../dolibarr_documents: # Add this to use a custom apparmor profile when using apache php handler - - AADefaultHatName sellyoursaas-instances - + + AADefaultHatName sellyoursaas-instances + ServerName myvirtualalias @@ -35,8 +36,8 @@ #AuthUserFile /etc/apache2/.htpasswd #require valid-user - - # Leaving /public and /api, /dav, .well_known but also wrappers for document and viewimage accessible to everyone + + # Leaving /public and /api, /dav, .well_known but also wrappers for document, viewimage and public json/img accessible to everyone AuthType None Require all granted diff --git a/dev/setup/fail2ban/filter.d/web-accesslog-limit403.conf b/dev/setup/fail2ban/filter.d/web-accesslog-limit403.conf new file mode 100644 index 00000000000..1356df80115 --- /dev/null +++ b/dev/setup/fail2ban/filter.d/web-accesslog-limit403.conf @@ -0,0 +1,19 @@ +# Fail2Ban configuration file +# +# Regexp to detect forbidden access on pages (public or not) so we can add mitigation on IP making too much +# access to your a Dolibarr instance. + + +[Definition] + +# To test, you can inject this example into log +# echo `myvirtualhost.com:443 1.2.3.4 - - [15/Dec/2022:09:57:47 +0000] "GET /public/abc" 403 123 "-" "Mozilla" >> /var/log/apache2/access.log +# +# then +# fail2ban-client status web-accesslog-limit403 +# +# To test rule file on a existing log file +# fail2ban-regex /var/log/apache2/access.log /etc/fail2ban/filter.d/web-accesslog-limit403.conf + +failregex = - - .*HTTP/[0-9]+(.[0-9]+)?" 403 +ignoreregex = diff --git a/dev/setup/qodana/README.md b/dev/setup/qodana/README.md new file mode 100644 index 00000000000..37b465cabc9 --- /dev/null +++ b/dev/setup/qodana/README.md @@ -0,0 +1,14 @@ +QODANA TUTO +----------- +This README explains how to use qodana to generate static analytics reports on the code + +Install docker + + +Install qodana + + +To run inspection on CLI + cd ~/git/dirtoscan + sudo qodana scan --show-report + diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 2a23ee5eb85..91b7673ab81 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -47,6 +47,7 @@ $search_label = GETPOST('search_label', 'alpha'); $search_labelshort = GETPOST('search_labelshort', 'alpha'); $search_accountparent = GETPOST('search_accountparent', 'alpha'); $search_pcgtype = GETPOST('search_pcgtype', 'alpha'); +$search_import_key = GETPOST('search_import_key', 'alpha'); $toselect = GETPOST('toselect', 'array'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $confirm = GETPOST('confirm', 'alpha'); @@ -83,16 +84,19 @@ if (!$sortorder) { } $arrayfields = array( - 'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1), - 'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), - 'aa.labelshort'=>array('label'=>$langs->trans("LabelToShow"), 'checked'=>1), - 'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>1), - 'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'), - 'aa.reconcilable'=>array('label'=>$langs->trans("Reconcilable"), 'checked'=>1), - 'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1) + 'aa.account_number'=>array('label'=>"AccountNumber", 'checked'=>1), + 'aa.label'=>array('label'=>"Label", 'checked'=>1), + 'aa.labelshort'=>array('label'=>"LabelToShow", 'checked'=>1), + 'aa.account_parent'=>array('label'=>"Accountparent", 'checked'=>1), + 'aa.pcg_type'=>array('label'=>"Pcgtype", 'checked'=>1, 'help'=>'PcgtypeDesc'), + 'categories'=>array('label'=>"AccountingCategories", 'checked'=>-1, 'help'=>'AccountingCategoriesDesc'), + 'aa.reconcilable'=>array('label'=>"Reconcilable", 'checked'=>1), + 'aa.active'=>array('label'=>"Activated", 'checked'=>1), + 'aa.import_key'=>array('label'=>"ImportId", 'checked'=>-1) ); if ($conf->global->MAIN_FEATURES_LEVEL < 2) { + unset($arrayfields['categories']); unset($arrayfields['aa.reconcilable']); } @@ -226,15 +230,12 @@ if ($action == 'delete') { $pcgver = $conf->global->CHARTOFACCOUNTS; -$sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.account_number, aa.account_parent , aa.label, aa.labelshort, aa.reconcilable, aa.active, "; +$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"; $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 = ".$conf->entity; -if ($db->type == 'pgsql') { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity; -} else { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity; -} +$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); $sql .= " WHERE asy.rowid = ".((int) $pcgver); //print $sql; if (strlen(trim($search_account))) { @@ -337,6 +338,9 @@ if ($resql) { if ($search_pcgtype) { $param .= '&search_pcgtype='.urlencode($search_pcgtype); } + if ($optioncss != '') { + $param .= '&search_import_key='.urlencode($search_import_key); + } if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } @@ -399,7 +403,7 @@ if ($resql) { } print ""; print ajax_combobox("chartofaccounts"); - print ''; + print ''; print '
'; @@ -436,11 +440,20 @@ if ($resql) { } if (!empty($arrayfields['aa.account_parent']['checked'])) { print ''; - print $formaccounting->select_account($search_accountparent, 'search_accountparent', 2); + print $formaccounting->select_account($search_accountparent, 'search_accountparent', 2, array(), 0, 0, 'maxwidth150'); print ''; } + // Predefined group if (!empty($arrayfields['aa.pcg_type']['checked'])) { - print ''; + print ''; + } + // Custom groups + if (!empty($arrayfields['categories']['checked'])) { + print ''; + } + // Import key + if (!empty($arrayfields['aa.import_key']['checked'])) { + print ''; } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['aa.reconcilable']['checked'])) { @@ -471,6 +484,12 @@ if ($resql) { if (!empty($arrayfields['aa.pcg_type']['checked'])) { print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type,aa.account_number', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help'], 1); } + if (!empty($arrayfields['categories']['checked'])) { + print_liste_field_titre($arrayfields['categories']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, '', $arrayfields['categories']['help'], 1); + } + if (!empty($arrayfields['aa.import_key']['checked'])) { + print_liste_field_titre($arrayfields['aa.import_key']['label'], $_SERVER["PHP_SELF"], 'aa.import_key', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.import_key']['help'], 1); + } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['aa.reconcilable']['checked'])) { print_liste_field_titre($arrayfields['aa.reconcilable']['label'], $_SERVER["PHP_SELF"], 'aa.reconcilable', '', $param, '', $sortfield, $sortorder); @@ -505,7 +524,7 @@ if ($resql) { // Account label if (!empty($arrayfields['aa.label']['checked'])) { print ""; - print $obj->label; + print dol_escape_htmltag($obj->label); print "\n"; if (!$i) { $totalarray['nbfield']++; @@ -515,7 +534,7 @@ if ($resql) { // Account label to show (label short) if (!empty($arrayfields['aa.labelshort']['checked'])) { print ""; - print $obj->labelshort; + print dol_escape_htmltag($obj->labelshort); print "\n"; if (!$i) { $totalarray['nbfield']++; @@ -549,10 +568,30 @@ if ($resql) { } } - // Chart of accounts type + // Predefined group (deprecated) if (!empty($arrayfields['aa.pcg_type']['checked'])) { print ""; - print $obj->pcg_type; + print dol_escape_htmltag($obj->pcg_type); + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Custom accounts + if (!empty($arrayfields['categories']['checked'])) { + print ""; + // TODO Get all custom groups labels the account is in + print dol_escape_htmltag($obj->fk_accounting_category); + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Import id + if (!empty($arrayfields['aa.import_key']['checked'])) { + print ""; + print dol_escape_htmltag($obj->import_key); print "\n"; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index 02921a78cb2..c5b8fd20045 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -640,7 +640,8 @@ if ($id) { foreach ($fieldlist as $field => $value) { $showfield = 1; $class = "left"; - $valuetoshow = $obj->{$fieldlist[$field]}; + $tmpvar = $fieldlist[$field]; + $valuetoshow = $obj->$tmpvar; if ($value == 'type_template') { $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow; } diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 9eabd378e11..43d1852c720 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -282,7 +282,7 @@ if ($action == 'create') { print $form->textwithpicto($langs->trans("AccountingCategory"), $langs->transnoentitiesnoconv("AccountingAccountGroupsDesc")); print ''; print ''; - $formaccounting->select_accounting_category($object->account_category, 'account_category', 1, 0, 1); + print $formaccounting->select_accounting_category($object->account_category, 'account_category', 1, 0, 1); print ''; print ''; @@ -329,7 +329,8 @@ if ($action == 'create') { // Account parent print ''.$langs->trans("Accountparent").''; print ''; - print $formaccounting->select_account($object->account_parent, 'account_parent', 1); + // Note: We accept disabled account as parent account so we can build a hierarchy and use only childs + print $formaccounting->select_account($object->account_parent, 'account_parent', 1, array(), 0, 0, 'minwidth100 maxwidth300 maxwidthonsmartphone', 1, ''); print ''; // Chart of accounts type @@ -358,7 +359,7 @@ if ($action == 'create') { print $form->textwithpicto($langs->trans("AccountingCategory"), $langs->transnoentitiesnoconv("AccountingAccountGroupsDesc")); print ''; print ''; - $formaccounting->select_accounting_category($object->account_category, 'account_category', 1); + print $formaccounting->select_accounting_category($object->account_category, 'account_category', 1); print ''; print ''; diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php index 7b86902e009..7b660419daf 100644 --- a/htdocs/accountancy/admin/categories.php +++ b/htdocs/accountancy/admin/categories.php @@ -1,6 +1,7 @@ * Copyright (C) 2017-2022 Alexandre Spangaro + * Copyright (C) 2022 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 @@ -31,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; $error = 0; // Load translation files required by the page -$langs->loadLangs(array("bills", "accountancy")); +$langs->loadLangs(array("bills", "accountancy", "compta")); $id = GETPOST('id', 'int'); $cancel = GETPOST('cancel', 'alpha'); @@ -44,6 +45,26 @@ if ($cat_id == 0) { $cat_id = null; } +// 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; + +if (empty($sortfield)) { + $sortfield = 'account_number'; +} +if (empty($sortorder)) { + $sortorder = 'ASC'; +} + // Security check if (!$user->hasRight('accounting', 'chartofaccount')) { accessforbidden(); @@ -110,18 +131,22 @@ print ''; // Select the category print ''; print ''; +print '
'.$langs->trans("AccountingCategory").''; -$formaccounting->select_accounting_category($cat_id, 'account_category', 1, 0, 0, 1); -print ''; +print $formaccounting->select_accounting_category($cat_id, 'account_category', 1, 0, 0, 0); +print ''; print '
'; + +print dol_get_fiche_end(); + + // Select the accounts if (!empty($cat_id)) { $return = $accountingcategory->getAccountsWithNoCategory($cat_id); if ($return < 0) { setEventMessages(null, $accountingcategory->errors, 'errors'); } - print ''.$langs->trans("AddAccountFromBookKeepingWithNoCategories").''; - print ''; + print '
'; $arraykeyvalue = array(); foreach ($accountingcategory->lines_cptbk as $key => $val) { @@ -130,33 +155,25 @@ if (!empty($cat_id)) { } if (is_array($accountingcategory->lines_cptbk) && count($accountingcategory->lines_cptbk) > 0) { - print $form->multiselectarray('cpt_bk', $arraykeyvalue, GETPOST('cpt_bk', 'array'), null, null, null, null, "90%"); - print '
'; - /*print '
'; - print ajax_combobox('cpt_bk'); - */ - print ' '; + print img_picto($langs->trans("AccountingAccount"), 'accounting_account', 'class="pictofixedwith"'); + print $form->multiselectarray('cpt_bk', $arraykeyvalue, GETPOST('cpt_bk', 'array'), null, null, '', 0, "80%", '', '', $langs->transnoentitiesnoconv("AddAccountFromBookKeepingWithNoCategories")); + print ' '; } - print ''; } -print ''; - -print dol_get_fiche_end(); - print ''; -if ($action == 'display' || $action == 'delete') { - print "\n"; +if ((empty($action) || $action == 'display' || $action == 'delete') && $cat_id > 0) { + $param = 'account_category='.((int) $cat_id); + + print '
'; + print '
'."\n"; print ''; - print '"; - print '"; - print "\n"; + print getTitleFieldOfList('AccountAccounting', 0, $_SERVER['PHP_SELF'], 'account_number', '', $param, '', $sortfield, $sortorder, '')."\n"; + print getTitleFieldOfList('Label', 0, $_SERVER['PHP_SELF'], 'label', '', $param, '', $sortfield, $sortorder, '')."\n"; + print getTitleFieldOfList('', 0, $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, '')."\n"; + print ''."\n"; if (!empty($cat_id)) { $return = $accountingcategory->display($cat_id); // This load ->lines_display @@ -165,6 +182,8 @@ if ($action == 'display' || $action == 'delete') { } if (is_array($accountingcategory->lines_display) && count($accountingcategory->lines_display) > 0) { + $accountingcategory->lines_display = dol_sort_array($accountingcategory->lines_display, $sortfield, $sortorder, -1, 0, 1); + foreach ($accountingcategory->lines_display as $cpt) { print ''; print ''; @@ -177,6 +196,8 @@ if ($action == 'display' || $action == 'delete') { print ""; print "\n"; } + } else { + print ''; } } diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 3a6664b8b44..0fd7b9012eb 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -190,7 +190,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors'); } } - if (!is_numeric(GETPOST('position', 'alpha'))) { + if (GETPOST('position') && !is_numeric(GETPOST('position', 'alpha'))) { $langs->loadLangs(array("errors")); $ok = 0; setEventMessages($langs->transnoentities('ErrorFieldMustBeANumeric', $langs->transnoentities("Position")), null, 'errors'); @@ -444,15 +444,37 @@ if ($search_country_id > 0) { if ($sortfield == 'country') { $sortfield = 'country_code'; } +if (empty($sortfield)) { + $sortfield = 'position'; +} + $sql .= $db->order($sortfield, $sortorder); $sql .= $db->plimit($listlimit + 1, $offset); //print $sql; $fieldlist = explode(',', $tabfield[$id]); +$param = '&id='.$id; +if ($search_country_id > 0) { + $param .= '&search_country_id='.urlencode($search_country_id); +} +$paramwithsearch = $param; +if ($sortorder) { + $paramwithsearch .= '&sortorder='.urlencode($sortorder); +} +if ($sortfield) { + $paramwithsearch .= '&sortfield='.urlencode($sortfield); +} +if (GETPOST('from', 'alpha')) { + $paramwithsearch .= '&from='.urlencode(GETPOST('from', 'alpha')); +} + print ''; print ''; print ''; +print ''; +print ''; + print '
'; print '
'.$langs->trans("AccountAccounting")."'.$langs->trans("Label")."
'.length_accountg($cpt->account_number).'
'.$langs->trans("NoRecordFound").'
'; @@ -571,20 +593,6 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; - $param = '&id='.$id; - if ($search_country_id > 0) { - $param .= '&search_country_id='.urlencode($search_country_id); - } - $paramwithsearch = $param; - if ($sortorder) { - $paramwithsearch .= '&sortorder='.$sortorder; - } - if ($sortfield) { - $paramwithsearch .= '&sortfield='.$sortfield; - } - if (GETPOST('from', 'alpha')) { - $paramwithsearch .= '&from='.GETPOST('from', 'alpha'); - } // There is several pages if ($num > $listlimit) { print ''; $filterfound++; } else { @@ -725,11 +733,11 @@ if ($resql) { print ''; print ''; print ''; print ''; } else { @@ -743,7 +751,8 @@ if ($resql) { foreach ($fieldlist as $field => $value) { $showfield = 1; $class = "left"; - $valuetoshow = $obj->{$fieldlist[$field]}; + $tmpvar = $fieldlist[$field]; + $valuetoshow = $obj->$tmpvar; if ($value == 'category_type') { $valuetoshow = yn($valuetoshow); } elseif ($valuetoshow == 'all') { @@ -822,7 +831,7 @@ if ($resql) { } // Link to setup the group - print ''; } elseif ($fieldlist[$field] == 'country_id') { diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index 9a3b63adcc3..2bd1037db39 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -84,6 +84,9 @@ $list_account[] = 'ACCOUNTING_VAT_PAY_ACCOUNT'; if (isModEnabled('banque')) { $list_account[] = 'ACCOUNTING_ACCOUNT_TRANSFER_CASH'; } +if (!empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) { + $list_account[] = 'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY'; +} if (isModEnabled('don')) { $list_account[] = 'DONATION_ACCOUNTINGACCOUNT'; } diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 385c105451e..3a7be3e073e 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -261,6 +261,20 @@ if ($action == 'setenablelettering') { } } +if ($action == 'setenableautolettering') { + $setenableautolettering = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "ACCOUNTING_ENABLE_AUTOLETTERING", $setenableautolettering, 'yesno', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } +} + /* * View @@ -430,7 +444,7 @@ foreach ($list_binding as $key) { print $form->selectDate((!empty($conf->global->$key) ? $db->idate($conf->global->$key) : -1), $key, 0, 0, 1); } elseif ($key == 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER') { $array = array(0=>$langs->trans("PreviousMonth"), 1=>$langs->trans("CurrentMonth"), 2=>$langs->trans("Fiscalyear")); - print $form->selectarray($key, $array, (isset($conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER) ? $conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER : 0)); + print $form->selectarray($key, $array, (isset($conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER) ? $conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER : 0), 0, 0, 0, '', 0, 0, 0, '', 'onrightofpage'); } else { print ''; } @@ -479,6 +493,7 @@ if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) { print ''; print '
'; @@ -605,7 +613,7 @@ if ($resql) { if ($showfield) { if ($value == 'country') { print ''; - print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone'); + print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth150 maxwidthonsmartphone'); print ''; + print '
'; print ''; print ''; - print ''; - print '
'; - print ''; + print ''; + print ''; print '
'; + print ''; if (empty($obj->formula)) { print ''; print $langs->trans("ListOfAccounts"); @@ -887,10 +896,10 @@ function fieldListAccountingCategories($fieldlist, $obj = '', $tabname = '', $co if ($context == 'add') { $fieldname = 'country_id'; $preselectcountrycode = GETPOSTISSET('country_id') ? GETPOST('country_id', 'int') : $mysoc->country_code; - print $form->select_country($preselectcountrycode, $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone'); + print $form->select_country($preselectcountrycode, $fieldname, '', 28, 'maxwidth150 maxwidthonsmartphone'); } else { $preselectcountrycode = (empty($obj->country_code) ? (empty($obj->country) ? $mysoc->country_code : $obj->country) : $obj->country_code); - print $form->select_country($preselectcountrycode, $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone'); + print $form->select_country($preselectcountrycode, $fieldname, '', 28, 'maxwidth150 maxwidthonsmartphone'); } print '
'; +print '
'; // Lettering params print ''; @@ -499,6 +514,21 @@ if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { } print ''; +if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { + print ''; + print ''; + if (!empty($conf->global->ACCOUNTING_ENABLE_AUTOLETTERING)) { + print ''; + } else { + print ''; + } + print ''; +} + print '
' . $langs->trans("ACCOUNTING_ENABLE_AUTOLETTERING") . ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print '
'; print '
'; diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index e1a07fef5fc..ba2d867ebd6 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -587,7 +587,8 @@ if ($id) { foreach ($fieldlist as $field => $value) { $showfield = 1; $class = "left"; - $valuetoshow = $obj->{$fieldlist[$field]}; + $tmpvar = $fieldlist[$field]; + $valuetoshow = $obj->$tmpvar; if ($valuetoshow == 'all') { $valuetoshow = $langs->trans('All'); } elseif ($fieldlist[$field] == 'nature' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') { diff --git a/htdocs/accountancy/admin/subaccount.php b/htdocs/accountancy/admin/subaccount.php index c9f78596bcd..4f2274269d8 100644 --- a/htdocs/accountancy/admin/subaccount.php +++ b/htdocs/accountancy/admin/subaccount.php @@ -408,7 +408,7 @@ if ($resql) { $s .= ''.$langs->trans("Supplier").''; } elseif ($obj->type == 3) { // User - $s .= ''.$langs->trans("Employee").''; + $s .= ''.$langs->trans("Employee").''; } print $s; print ''; diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 4620bf37e4e..42ac08383ea 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -4,6 +4,7 @@ * Copyright (C) 2013-2022 Alexandre Spangaro * Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2018-2020 Frédéric France + * Copyright (C) 2022 Waël Almoman * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -44,7 +45,7 @@ $cancel = GETPOST('cancel', 'aZ09'); $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $id = GETPOST('id', 'int'); // id of record -$mode = GETPOST('mode', 'aZ09'); // '' or '_tmp' +$mode = $mode = $action == 'create' ? "_tmp" : GETPOST('mode', 'aZ09'); // '' or '_tmp' $piece_num = GETPOST("piece_num", 'int'); // id of transaction (several lines share the same transaction id) $accountingaccount = new AccountingAccount($db); @@ -54,10 +55,15 @@ $accountingaccount_number = GETPOST('accountingaccount_number', 'alphanohtml'); $accountingaccount->fetch(null, $accountingaccount_number, true); $accountingaccount_label = $accountingaccount->label; -$journal_code = GETPOST('code_journal', 'alpha'); +$journal_code = GETPOST('code_journal', 'alpha') ? GETPOST('code_journal', 'alpha') : "NULL"; $accountingjournal->fetch(null, $journal_code); $journal_label = $accountingjournal->label; +$next_num_mvt = (int) GETPOST('next_num_mvt', 'alpha'); +$doc_ref = (string) GETPOST('doc_ref', 'alpha'); +$doc_date = (string) GETPOST('doc_date', 'alpha'); +$doc_date = $doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); + $subledger_account = GETPOST('subledger_account', 'alphanohtml'); if ($subledger_account == -1) { $subledger_account = null; @@ -72,6 +78,10 @@ $save = GETPOST('save', 'alpha'); if (!empty($save)) { $action = 'add'; } +$valid = GETPOST('validate', 'alpha'); +if (!empty($valid)) { + $action = 'valid'; +} $update = GETPOST('update', 'alpha'); if (!empty($update)) { $action = 'confirm_update'; @@ -156,64 +166,79 @@ if ($action == "confirm_update") { } } } -} elseif ($action == "add") { +} elseif ($action == 'add' || $action == 'valid') { $error = 0; - if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) { - $error++; - setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); - $action = ''; - } - if (empty($accountingaccount_number) || $accountingaccount_number == '-1') { - $error++; - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors'); - $action = ''; + if (array_sum($debit) != array_sum($credit)) { + $action = 'add'; } - if (!$error) { - $object = new BookKeeping($db); + foreach ($accountingaccount_number as $key => $value) { + $accountingaccount->fetch(null, $accountingaccount_number[$key], true); + $accountingaccount_label[$key] = $accountingaccount->label[$key]; - $object->numero_compte = $accountingaccount_number; - $object->subledger_account = $subledger_account; - $object->subledger_label = $subledger_label; - $object->label_compte = $accountingaccount_label; - $object->label_operation = $label_operation; - $object->debit = $debit; - $object->credit = $credit; - $object->doc_date = (string) GETPOST('doc_date', 'alpha'); - $object->doc_type = (string) GETPOST('doc_type', 'alpha'); - $object->piece_num = $piece_num; - $object->doc_ref = (string) GETPOST('doc_ref', 'alpha'); - $object->code_journal = $journal_code; - $object->journal_label = $journal_label; - $object->fk_doc = GETPOSTINT('fk_doc'); - $object->fk_docdet = GETPOSTINT('fk_docdet'); - - if (floatval($debit) != 0.0) { - $object->montant = $debit; // deprecated - $object->amount = $debit; - $object->sens = 'D'; + // if one added row is empty remove it before continue + if ($key < 1 && (empty($accountingaccount_number[$key]) || $accountingaccount_number[$key] == '-1') || (floatval($debit[$key]) == 0.0) && (floatval($credit[$key]) == 0.0)) { + continue; } - if (floatval($credit) != 0.0) { - $object->montant = $credit; // deprecated - $object->amount = $credit; - $object->sens = 'C'; - } - - $result = $object->createStd($user, false, $mode); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } else { - if ($mode != '_tmp') { - setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); - } - - $debit = 0; - $credit = 0; - + if ((floatval($debit[$key]) != 0.0) && (floatval($credit[$key]) != 0.0)) { + $error++; + setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); $action = ''; } + + if (empty($accountingaccount_number[$key]) || $accountingaccount_number[$key] == '-1') { + $error++; + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors'); + $action = ''; + } + + if (!$error) { + $object = new BookKeeping($db); + $object->numero_compte = $accountingaccount_number[$key]; + $object->subledger_account = $subledger_account[$key]; + $object->subledger_label = $subledger_label[$key]; + $object->label_compte = $accountingaccount_label[$key]; + $object->label_operation = $label_operation[$key]; + $object->debit = price2num($debit[$key]); + $object->credit = price2num($credit[$key]); + $object->doc_date = $doc_date; + $object->doc_type = (string) GETPOST('doc_type', 'alpha'); + $object->piece_num = $piece_num; + $object->doc_ref = $doc_ref; + $object->code_journal = $journal_code; + $object->journal_label = $journal_label; + $object->fk_doc = GETPOSTINT('fk_doc'); + $object->fk_docdet = GETPOSTINT('fk_docdet'); + + if (floatval($debit[$key]) != 0.0) { + $object->montant = $object->debit; // deprecated + $object->amount = $object->debit; + $object->sens = 'D'; + } + + if (floatval($credit[$key]) != 0.0) { + $object->montant = $object->credit; // deprecated + $object->amount = $object->credit; + $object->sens = 'C'; + } + + $result = $object->createStd($user, false, $mode); + if ($result < 0) { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + if (empty($error)) { + if ($mode != '_tmp') { + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); + } + $debit = 0; + $credit = 0; + + $action = $action == 'add' ? '' : $action ; // stay in valid mode when not adding line } } elseif ($action == "confirm_delete") { $object = new BookKeeping($db); @@ -230,17 +255,28 @@ if ($action == "confirm_update") { } } $action = ''; -} elseif ($action == "confirm_create") { +} elseif ($action == 'create') { $error = 0; $object = new BookKeeping($db); + $next_num_mvt = !empty($next_num_mvt) ? $next_num_mvt : $object->getNextNumMvt('_tmp'); + $doc_ref = !empty($doc_ref) ? $doc_ref : $next_num_mvt; + + if (empty($doc_date)) { + $tmp_date = dol_getdate(dol_now()); + $_POST['doc_dateday'] = $tmp_date['mday']; + $_POST['doc_datemonth'] = $tmp_date['mon']; + $_POST['doc_dateyear'] = $tmp_date['year']; + unset($tmp_date); + } + if (!$journal_code || $journal_code == '-1') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Journal")), null, 'errors'); $action = 'create'; $error++; } - if (!GETPOST('doc_ref', 'alpha')) { + if (empty($doc_ref)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Piece")), null, 'errors'); $action = 'create'; $error++; @@ -252,8 +288,8 @@ if ($action == "confirm_update") { $object->credit = 0; $object->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); $object->doc_type = GETPOST('doc_type', 'alpha'); - $object->piece_num = GETPOST('next_num_mvt', 'alpha'); - $object->doc_ref = GETPOST('doc_ref', 'alpha'); + $object->piece_num = $next_num_mvt; + $object->doc_ref = $doc_ref; $object->code_journal = $journal_code; $object->journal_label = $journal_label; $object->fk_doc = 0; @@ -302,7 +338,7 @@ if ($action == 'setjournal') { } if ($action == 'setdocref') { - $refdoc = GETPOST('doc_ref', 'alpha'); + $refdoc = $doc_ref; $result = $object->updateByMvt($piece_num, 'doc_ref', $refdoc, $mode); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -333,7 +369,7 @@ if ($action == 'valid') { $html = new Form($db); $formaccounting = new FormAccounting($db); -$title = $langs->trans("CreateMvts"); +$title = $langs->trans($mode =="_tmp" ? "CreateMvts": "UpdateMvts"); llxHeader('', $title); @@ -343,28 +379,37 @@ if ($action == 'delete') { print $formconfirm; } -if ($action == 'create') { - print load_fiche_titre($title); - $object = new BookKeeping($db); - $next_num_mvt = $object->getNextNumMvt('_tmp'); +$object = new BookKeeping($db); +$result = $object->fetchPerMvt($piece_num, $mode); +if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); +} - if (empty($next_num_mvt)) { - dol_print_error('', 'Failed to get next piece number'); +if (!empty($object->piece_num)) { + $backlink = ''.$langs->trans('BackToList').''; + + print load_fiche_titre($langs->trans($mode =="_tmp" ? "CreateMvts": "UpdateMvts"), $backlink); + + print ''; if ($optioncss != '') { + print ''; } + $head = array(); + $h = 0; + $head[$h][0] = $_SERVER['PHP_SELF'].'?piece_num='.$object->piece_num.($mode ? '&mode='.$mode : ''); + $head[$h][1] = $langs->trans("Transaction"); + $head[$h][2] = 'transaction'; + $h++; - print ''; - if ($optioncss != '') { - print ''; - } - print ''; - print ''."\n"; - print ''."\n"; - print ''."\n"; + print dol_get_fiche_head($head, 'transaction', '', -1); - print dol_get_fiche_head(); + //dol_banner_tab($object, '', $backlink); - print ''; + print '
'; + print '
'; + + print '
'; + print '
'; /*print ''; print ''; @@ -374,7 +419,7 @@ if ($action == 'create') { print ''; print ''; print ''; print ''; @@ -385,294 +430,218 @@ if ($action == 'create') { print ''; print ''; - print ''; + print ''; print ''; /* print ''; print ''; - print ''; + print ''; print ''; */ print '
' . $langs->trans("NumPiece") . '
'.$langs->trans("Docdate").''; - print $html->selectDate('', 'doc_date', '', '', '', "create_mvt", 1, 1); + print $html->selectDate($doc_date, 'doc_date', '', '', '', "create_mvt", 1, 1); print '
'.$langs->trans("Piece").'
' . $langs->trans("Doctype") . '
'; - print dol_get_fiche_end(); + print ''; - print $form->buttonsSaveCancel("Create"); + print '
'; - print ''; -} else { - $object = new BookKeeping($db); - $result = $object->fetchPerMvt($piece_num, $mode); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); + print '
'; + print ''; + + // Doc type + if (!empty($object->doc_type)) { + print ''; + print ''; + print ''; + print ''; } - if (!empty($object->piece_num)) { - $backlink = ''.$langs->trans('BackToList').''; + // Date document creation + print ''; + print ''; + print ''; + print ''; - print load_fiche_titre($langs->trans("UpdateMvts"), $backlink); - - $head = array(); - $h = 0; - $head[$h][0] = $_SERVER['PHP_SELF'].'?piece_num='.$object->piece_num.($mode ? '&mode='.$mode : ''); - $head[$h][1] = $langs->trans("Transaction"); - $head[$h][2] = 'transaction'; - $h++; - - print dol_get_fiche_head($head, 'transaction', '', -1); - - //dol_banner_tab($object, '', $backlink); - - print '
'; - print '
'; - - print '
'; - print '
'.$langs->trans("Doctype").''.$object->doc_type.'
'.$langs->trans("DateCreation").''; + print $object->date_creation ? dol_print_date($object->date_creation, 'day') : ' '; + print '
'; - - // Account movement + // Don't show in tmp mode, inevitably empty + if ($mode != "_tmp") { + // Date document export print ''; - print ''; - print ''; - print ''; - - // Date - print ''; - print ''; - - // Journal - print ''; - print ''; - - // Ref document - print ''; - print ''; - - print '
'.$langs->trans("NumMvts").''.($mode == '_tmp' ? ''.$langs->trans("Draft").'' : $object->piece_num).'
'; - print ''; - if ($action != 'editdate') { - print ''; - } - print '
'; - print $langs->trans('Docdate'); - print 'piece_num).'&mode='.urlencode($mode).'">'.img_edit($langs->transnoentitiesnoconv('SetDate'), 1).'
'; - print '
'; - if ($action == 'editdate') { - print '
'; - if ($optioncss != '') { - print ''; - } - print ''; - print ''; - print ''; - print $form->selectDate($object->doc_date ? $object->doc_date : - 1, 'doc_date', '', '', '', "setdate"); - print ''; - print '
'; - } else { - print $object->doc_date ? dol_print_date($object->doc_date, 'day') : ' '; - } - print '
'; - print ''; - if ($action != 'editjournal') { - print ''; - } - print '
'; - print $langs->trans('Codejournal'); - print 'piece_num).'&mode='.urlencode($mode).'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'
'; - print '
'; - if ($action == 'editjournal') { - print '
'; - if ($optioncss != '') { - print ''; - } - print ''; - print ''; - print ''; - print $formaccounting->select_journal($object->code_journal, 'code_journal', 0, 0, array(), 1, 1); - print ''; - print '
'; - } else { - print $object->code_journal; - } - print '
'; - print ''; - if ($action != 'editdocref') { - print ''; - } - print '
'; - print $langs->trans('Piece'); - print 'piece_num).'&mode='.urlencode($mode).'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'
'; - print '
'; - if ($action == 'editdocref') { - print '
'; - if ($optioncss != '') { - print ''; - } - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - } else { - print $object->doc_ref; - } - print '
'; - - print '
'; - - print '
'; - - print '
'; - print ''; - - // Doc type - if (!empty($object->doc_type)) { - print ''; - print ''; - print ''; - print ''; - } - - // Date document creation - print ''; - print ''; + print ''; print ''; print ''; - // Don't show in tmp mode, inevitably empty - if ($mode != "_tmp") { - // Date document export - print ''; - print ''; - print ''; - print ''; - - // Date document validation - print ''; - print ''; - print ''; - print ''; - } - - // Validate - /* + // Date document validation print ''; - print ''; + print ''; print ''; + print $object->date_validation ? dol_print_date($object->date_validation, 'dayhour') : ' '; + print ''; print ''; - */ + } + // Validate + /* + print ''; + print ''; + print ''; + print ''; + */ // check data - /* - print ''; - print ''; - if ($object->doc_type == 'customer_invoice') - { - $sqlmid = 'SELECT rowid as ref'; - $sqlmid .= " FROM ".MAIN_DB_PREFIX."facture as fac"; - $sqlmid .= " WHERE fac.rowid=" . ((int) $object->fk_doc); - dol_syslog("accountancy/bookkeeping/card.php::sqlmid=" . $sqlmid, LOG_DEBUG); - $resultmid = $db->query($sqlmid); - if ($resultmid) { - $objmid = $db->fetch_object($resultmid); - $invoicestatic = new Facture($db); - $invoicestatic->fetch($objmid->ref); - $ref=$langs->trans("Invoice").' '.$invoicestatic->getNomUrl(1); - } - else dol_print_error($db); - } - print ''; - print ''; - */ - print "
'.$langs->trans("Doctype").''.$object->doc_type.'
'.$langs->trans("DateCreation").''.$langs->trans("DateExport").''; - print $object->date_creation ? dol_print_date($object->date_creation, 'day') : ' '; + print $object->date_export ? dol_print_date($object->date_export, 'dayhour') : ' '; print '
' . $langs->trans("DateExport") . ''; - print $object->date_export ? dol_print_date($object->date_export, 'dayhour') : ' '; - print '
' . $langs->trans("DateValidation") . ''; - print $object->date_validation ? dol_print_date($object->date_validation, 'dayhour') : ' '; - print '
' . $langs->trans("Status") . ''.$langs->trans("DateValidation").''; - if (empty($object->validated)) { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - } else { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - } - print '
' . $langs->trans("Status") . ''; + if (empty($object->validated)) { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + } else { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; + } + print '
' . $langs->trans("Control") . '' . $ref .'
\n"; - - print '
'; - - print dol_get_fiche_end(); - - print '
'; - - print '
'; - - $result = $object->fetchAllPerMvt($piece_num, $mode); // This load $object->linesmvt - - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); + /* + print ''; + print '' . $langs->trans("Control") . ''; + if ($object->doc_type == 'customer_invoice') { + $sqlmid = 'SELECT rowid as ref'; + $sqlmid .= " FROM ".MAIN_DB_PREFIX."facture as fac"; + $sqlmid .= " WHERE fac.rowid=" . ((int) $object->fk_doc); + dol_syslog("accountancy/bookkeeping/card.php::sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $invoicestatic = new Facture($db); + $invoicestatic->fetch($objmid->ref); + $ref=$langs->trans("Invoice").' '.$invoicestatic->getNomUrl(1); } else { - // List of movements - print load_fiche_titre($langs->trans("ListeMvts"), '', ''); + dol_print_error($db); + } + } + print '' . $ref .''; + print ''; + */ + print "\n"; - print '
'; - if ($optioncss != '') { - print ''; + print dol_get_fiche_end(); + + print '
'; + + print '
'; + + $result = $object->fetchAllPerMvt($piece_num, $mode); // This load $object->linesmvt + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } else { + // List of movements + print load_fiche_titre($langs->trans("ListeMvts"), '', ''); + + if ($optioncss != '') { + print ''; + } + + print ''; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + + if (count($object->linesmvt) > 0) { + print '
'; + print ''; + + $total_debit = 0; + $total_credit = 0; + + // Don't show in tmp mode, inevitably empty + if ($mode != "_tmp") { + // Date document export + print ''; + print ''; + print ''; + print ''; + + // Date document validation + print ''; + print ''; + print ''; + print ''; } - print ''; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - if (count($object->linesmvt) > 0) { - print '
'; - print '
' . $langs->trans("DateExport") . ''; + print $object->date_export ? dol_print_date($object->date_export, 'dayhour') : ' '; + print '
' . $langs->trans("DateValidation") . ''; + print $object->date_validation ? dol_print_date($object->date_validation, 'dayhour') : ' '; + print '
'; + print ''; - $total_debit = 0; - $total_credit = 0; + print_liste_field_titre("AccountAccountingShort"); + print_liste_field_titre("SubledgerAccount"); + print_liste_field_titre("LabelOperation"); + print_liste_field_titre("AccountingDebit", "", "", "", "", 'class="right"'); + print_liste_field_titre("AccountingCredit", "", "", "", "", 'class="right"'); + if (empty($object->date_validation)) { + print_liste_field_titre("Action", "", "", "", "", 'width="60"', "", "", 'center '); + } else { + print_liste_field_titre(""); + } - print ''; + print "\n"; - print_liste_field_titre("AccountAccountingShort"); - print_liste_field_titre("SubledgerAccount"); - print_liste_field_titre("LabelOperation"); - print_liste_field_titre("AccountingDebit", "", "", "", "", 'class="right"'); - print_liste_field_titre("AccountingCredit", "", "", "", "", 'class="right"'); - if (empty($object->date_validation)) { - print_liste_field_titre("Action", "", "", "", "", 'width="60"', "", "", 'center '); - } else { - print_liste_field_titre(""); - } + // In _tmp mode the first line is empty so we remove it + if ($mode == "_tmp") { + array_shift($object->linesmvt); + } - print "\n"; + // Add an empty line at the end to be able to add transaction + $line = new BookKeepingLine(); + $object->linesmvt[] = $line; - // Add an empty line if there is not yet - if (!empty($object->linesmvt[0])) { - $tmpline = $object->linesmvt[0]; - if (!empty($tmpline->numero_compte)) { - $line = new BookKeepingLine(); - $object->linesmvt[] = $line; + // Add a second line empty line if there is not yet + if (empty($object->linesmvt[1])) { + $line = new BookKeepingLine(); + $object->linesmvt[] = $line; + } + + $count_line = count($object->linesmvt); + $num_line = 0; + foreach ($object->linesmvt as $key => $line) { + $num_line++; + print ''; + $total_debit += $line->debit; + $total_credit += $line->credit; + + if ($action == 'update' && $line->id == $id) { + print ''; + print ''; + print ''; - $total_debit += $line->debit; - $total_credit += $line->credit; - - if ($action == 'update' && $line->id == $id) { - print ''; + // Add also input for subledger label + print '
subledger_label).'" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccountLabel")).'" />'; + print ''; + print ''; + print ''; + print ''; + print ''; + } elseif (empty($line->numero_compte) || (empty($line->debit) && empty($line->credit))) { + if ($action == "" || $action == 'add') { + print ''; print ''; print ''; - print ''; - print ''; - print ''; - print ''; - } elseif (empty($line->numero_compte) || (empty($line->debit) && empty($line->credit))) { - if ($action == "" || $action == 'add') { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - } else { - print ''; - $resultfetch = $accountingaccount->fetch(null, $line->numero_compte, true); - print ''; + print ''; + print ''; + // Add button should not appear twice + if ($num_line === $count_line) { + print ''; } else { - print $line->numero_compte.' ('.$langs->trans("AccountRemovedFromCurrentChartOfAccount").')'; + print ''; } - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; } - print "\n"; - } - - $total_debit = price2num($total_debit, 'MT'); - $total_credit = price2num($total_credit, 'MT'); - - if ($total_debit != $total_credit) { - setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_debit, $total_credit)), 'warnings'); - } - - print '
'; + print $formaccounting->select_account((GETPOSTISSET("accountingaccount_number") ? GETPOST("accountingaccount_number", "alpha") : $line->numero_compte), 'accountingaccount_number', 1, array(), 1, 1, ''); + print ''; + // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because: + // It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases. + // Also, it is not possible to use a value that is not in the list. + // Also, the label is not automatically filled when a value is selected. + if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { + print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1, 'maxwidth250', '', 'subledger_label'); + } else { + print 'subledger_account).'" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccount")).'" />'; } - } - - foreach ($object->linesmvt as $line) { - print '
label_operation).'" />debit)).'" />credit)).'" />'; + print ''."\n"; + print ''; + print ''; - print $formaccounting->select_account((GETPOSTISSET("accountingaccount_number") ? GETPOST("accountingaccount_number", "alpha") : $line->numero_compte), 'accountingaccount_number', 1, array(), 1, 1, 'minwidth200 maxwidth500'); + print $formaccounting->select_account((is_array($accountingaccount_number) ? $accountingaccount_number[$key] : $accountingaccount_number ), 'accountingaccount_number['.$key.']', 1, array(), 1, 1, ''); print ''; // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because: @@ -680,124 +649,102 @@ if ($action == 'create') { // Also, it is not possible to use a value that is not in the list. // Also, the label is not automatically filled when a value is selected. if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { - print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1, 'maxwidth250', '', 'subledger_label'); + print $formaccounting->select_auxaccount((is_array($subledger_account) ? $subledger_account[$key] : $subledger_account ), 'subledger_account['.$key.']', 1, 'maxwidth250', '', 'subledger_label'); } else { - print 'subledger_account).'" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccount")).'">'; + print ''; } - // Add also input for subledger label - print '
subledger_label).'" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccountLabel")).'">'; + print '
'; print '
label_operation).'">debit)).'">credit)).'">'; - print ''."\n"; - print ''; - print ''; - print $formaccounting->select_account('', 'accountingaccount_number', 1, array(), 1, 1, 'minwidth200 maxwidth500'); - print ''; - // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because: - // It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases. - // Also, it is not possible to use a value that is not in the list. - // Also, the label is not automatically filled when a value is selected. - if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { - print $formaccounting->select_auxaccount('', 'subledger_account', 1, 'maxwidth250', '', 'subledger_label'); - } else { - print ''; - } - print '
'; - print '
'; - if ($resultfetch > 0) { - print $accountingaccount->getNomUrl(0, 1, 1, '', 0); + print ''.length_accounta($line->subledger_account); - if ($line->subledger_label) { - print ' - '.$line->subledger_label.''; - } - print ''.$line->label_operation.''.($line->debit != 0 ? price($line->debit) : '').''.($line->credit != 0 ? price($line->credit) : '').''; - if (empty($line->date_export) && empty($line->date_validation)) { - print 'id . '&piece_num=' . urlencode($line->piece_num) . '&mode=' . urlencode($mode) . '&token=' . urlencode(newToken()) . '">'; - print img_edit('', 0, 'class="marginrightonly"'); - print '  '; - } else { - print ''; - print img_edit($langs->trans("ForbiddenTransactionAlreadyExported"), 0, 'class="marginrightonly"'); - print '  '; - } - - if (empty($line->date_validation)) { - $actiontodelete = 'delete'; - if ($mode == '_tmp' || $action != 'delmouv') { - $actiontodelete = 'confirm_delete'; - } - - print ''; - print img_delete(); - print ''; - } else { - print ''; - print img_delete($langs->trans("ForbiddenTransactionAlreadyValidated")); - print ''; - } - - print '
'; - print '
'; - - if ($mode == '_tmp' && $action == '') { - print '
'; - print '
'; - if ($total_debit == $total_credit) { - print ''.$langs->trans("ValidTransaction").''; + } else { + print ''; + $resultfetch = $accountingaccount->fetch(null, $line->numero_compte, true); + print ''; + if ($resultfetch > 0) { + print $accountingaccount->getNomUrl(0, 1, 1, '', 0); } else { - print ''; + print $line->numero_compte.' ('.$langs->trans("AccountRemovedFromCurrentChartOfAccount").')'; + } + print ''; + print ''.length_accounta($line->subledger_account); + if ($line->subledger_label) { + print ' - '.$line->subledger_label.''; + } + print ''; + print ''.$line->label_operation.''; + print ''.($line->debit != 0 ? price($line->debit) : '').''; + print ''.($line->credit != 0 ? price($line->credit) : '').''; + + print ''; + if (empty($line->date_export) && empty($line->date_validation)) { + print 'id . '&piece_num=' . urlencode($line->piece_num) . '&mode=' . urlencode($mode) . '&token=' . urlencode(newToken()) . '">'; + print img_edit('', 0, 'class="marginrightonly"'); + print '  '; + } else { + print ''; + print img_edit($langs->trans("ForbiddenTransactionAlreadyExported"), 0, 'class="marginrightonly"'); + print '  '; } - print '   '; - print ''.$langs->trans("Cancel").''; + if (empty($line->date_validation)) { + $actiontodelete = 'delete'; + if ($mode == '_tmp' || $action != 'delmouv') { + $actiontodelete = 'confirm_delete'; + } - print "
"; + print ''; + print img_delete(); + print ''; + } else { + print ''; + print img_delete($langs->trans("ForbiddenTransactionAlreadyValidated")); + print ''; + } + + print ''; } + print "\n"; } - print '
'; + $total_debit = price2num($total_debit, 'MT'); + $total_credit = price2num($total_credit, 'MT'); + + if ($total_debit != $total_credit) { + setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_debit, $total_credit)), 'warnings'); + } + + print ''; + print ''; + + if ($mode == '_tmp' && $action == '') { + print '
'; + print '
'; + if ($total_debit == $total_credit) { + print ''; + } else { + print ''; + } + + print '   '; + print ''.$langs->trans("Cancel").''; + + print "
"; + } } - } else { - print load_fiche_titre($langs->trans("NoRecords")); + + print ''; } +} else { + print load_fiche_titre($langs->trans("NoRecords")); } print dol_get_fiche_end(); diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 2b2df70d647..ecd5668beb5 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -2,8 +2,10 @@ /* Copyright (C) 2013-2016 Olivier Geffroy * Copyright (C) 2013-2016 Florian Henry * Copyright (C) 2013-2022 Alexandre Spangaro + * Copyright (C) 2022 Lionel Vessiller * Copyright (C) 2016-2017 Laurent Destailleur * Copyright (C) 2018-2021 Frédéric France + * Copyright (C) 2022 Progiseize * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -102,7 +104,9 @@ if (GETPOST("button_export_file_x") || GETPOST("button_export_file.x") || GETPOS $action = 'export_file'; } -$search_accountancy_code = GETPOST("search_accountancy_code"); +$search_account_category = GETPOST('search_account_category', 'int'); + +$search_accountancy_code = GETPOST("search_accountancy_code", 'alpha'); $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); if ($search_accountancy_code_start == - 1) { $search_accountancy_code_start = ''; @@ -253,6 +257,7 @@ if (empty($reshook)) { $search_doc_type = ''; $search_doc_ref = ''; $search_doc_date = ''; + $search_account_category = ''; $search_accountancy_code = ''; $search_accountancy_code_start = ''; $search_accountancy_code_end = ''; @@ -335,6 +340,20 @@ if (empty($reshook)) { $filter['t.doc_ref'] = $search_doc_ref; $param .= '&search_doc_ref='.urlencode($search_doc_ref); } + if ($search_account_category != '-1' && !empty($search_account_category)) { + require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php'; + $accountingcategory = new AccountancyCategory($db); + + $listofaccountsforgroup = $accountingcategory->getCptsCat(0, 'fk_accounting_category = '.((int) $search_account_category)); + $listofaccountsforgroup2 = array(); + if (is_array($listofaccountsforgroup)) { + foreach ($listofaccountsforgroup as $tmpval) { + $listofaccountsforgroup2[] = "'".$db->escape($tmpval['id'])."'"; + } + } + $filter['t.search_accounting_code_in'] = join(',', $listofaccountsforgroup2); + $param .= '&search_account_category='.urlencode($search_account_category); + } if (!empty($search_accountancy_code)) { $filter['t.numero_compte'] = $search_accountancy_code; $param .= '&search_accountancy_code='.urlencode($search_accountancy_code); @@ -642,6 +661,9 @@ $sql .= " t.tms as date_modification,"; $sql .= " t.date_export,"; $sql .= " t.date_validated as date_validation,"; $sql .= " t.import_key"; + +$sqlfields = $sql; // $sql fields to remove for count total + $sql .= ' FROM '.MAIN_DB_PREFIX.$object->table_element.' as t'; // Manage filter $sqlwhere = array(); @@ -672,7 +694,13 @@ if (count($filter) > 0) { } elseif ($key == 't.reconciled_option') { $sqlwhere[] = 't.lettering_code IS NULL'; } elseif ($key == 't.code_journal' && !empty($value)) { - $sqlwhere[] = natural_search("t.code_journal", join(',', $value), 3, 1); + if (is_array($value)) { + $sqlwhere[] = natural_search("t.code_journal", join(',', $value), 3, 1); + } else { + $sqlwhere[] = natural_search("t.code_journal", $value, 3, 1); + } + } elseif ($key == 't.search_accounting_code_in' && !empty($value)) { + $sqlwhere[] = 't.numero_compte IN ('.$db->sanitize($value, 1).')'; } else { $sqlwhere[] = natural_search($key, $value, 0, 1); } @@ -685,9 +713,6 @@ if (empty($conf->global->ACCOUNTING_REEXPORT)) { if (count($sqlwhere) > 0) { $sql .= ' AND '.implode(' AND ', $sqlwhere); } -if (!empty($sortfield)) { - $sql .= $db->order($sortfield, $sortorder); -} //print $sql; @@ -715,58 +740,62 @@ if ($action == 'export_fileconfirm' && $user->hasRight('accounting', 'mouvements } } - $mimetype = $accountancyexport->getMimeType($formatexportset); - - top_httphead($mimetype, 1); - - // Output data on screen - $accountancyexport->export($object->lines, $formatexportset); - $notifiedexportdate = GETPOST('notifiedexportdate', 'alpha'); $notifiedvalidationdate = GETPOST('notifiedvalidationdate', 'alpha'); + $withAttachment = !empty(trim(GETPOST('notifiedexportfull', 'alphanohtml'))) ? 1 : 0; - if (!empty($accountancyexport->errors)) { - dol_print_error('', '', $accountancyexport->errors); - } elseif (!empty($notifiedexportdate) || !empty($notifiedvalidationdate)) { - // Specify as export : update field date_export or date_validated - $error = 0; - $db->begin(); + // Output data on screen or download + $result = $accountancyexport->export($object->lines, $formatexportset, $withAttachment); - if (is_array($object->lines)) { - foreach ($object->lines as $movement) { - $now = dol_now(); + $error = 0; + if ($result < 0) { + $error++; + } else { + if (!empty($notifiedexportdate) || !empty($notifiedvalidationdate)) { + if (is_array($object->lines)) { + // Specify as export : update field date_export or date_validated + $db->begin(); - $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; - $sql .= " SET"; - if (!empty($notifiedexportdate) && !empty($notifiedvalidationdate)) { - $sql .= " date_export = '".$db->idate($now)."'"; - $sql .= ", date_validated = '".$db->idate($now)."'"; - } elseif (!empty($notifiedexportdate)) { - $sql .= " date_export = '".$db->idate($now)."'"; - } elseif (!empty($notifiedvalidationdate)) { - $sql .= " date_validated = '".$db->idate($now)."'"; + foreach ($object->lines as $movement) { + $now = dol_now(); + + $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; + $sql .= " SET"; + if (!empty($notifiedexportdate) && !empty($notifiedvalidationdate)) { + $sql .= " date_export = '".$db->idate($now)."'"; + $sql .= ", date_validated = '".$db->idate($now)."'"; + } elseif (!empty($notifiedexportdate)) { + $sql .= " date_export = '".$db->idate($now)."'"; + } elseif (!empty($notifiedvalidationdate)) { + $sql .= " date_validated = '".$db->idate($now)."'"; + } + $sql .= " WHERE rowid = ".((int) $movement->id); + + dol_syslog("/accountancy/bookkeeping/list.php Function export_file Specify movements as exported", LOG_DEBUG); + + $result = $db->query($sql); + if (!$result) { + $error++; + break; + } } - $sql .= " WHERE rowid = ".((int) $movement->id); - dol_syslog("/accountancy/bookkeeping/list.php Function export_file Specify movements as exported", LOG_DEBUG); - - $result = $db->query($sql); - if (!$result) { + if (!$error) { + $db->commit(); + } else { $error++; - break; + $accountancyexport->errors[] = $langs->trans('NotAllExportedMovementsCouldBeRecordedAsExportedOrValidated'); + $db->rollback(); } } } - - if (!$error) { - $db->commit(); - } else { - $error++; - $db->rollback(); - dol_print_error('', $langs->trans("NotAllExportedMovementsCouldBeRecordedAsExportedOrValidated")); - } } - exit; + + if ($error) { + setEventMessages('', $accountancyexport->errors, 'errors'); + header('Location: '.$_SERVER['PHP_SELF']); + } + exit(); // download or show errors } } @@ -783,28 +812,38 @@ $title_page = $langs->trans("Operations").' - '.$langs->trans("Journals"); // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $resql = $db->query($sql); - $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 + /* The fast and low memory method to get and count full list converts the sql into a sql count */ + $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); + $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); + $resql = $db->query($sqlforcount); + if ($resql) { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + } else { + dol_print_error($db); + } + + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } + $db->free($resql); } -// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { - $num = $nbtotalofrecords; -} else { + +// 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); } +$resql = $db->query($sql); +if (!$resql) { + dol_print_error($db); + exit; +} + +$num = $db->num_rows($resql); + $arrayofselected = is_array($toselect) ? $toselect : array(); // Output page @@ -854,7 +893,17 @@ if ($action == 'export_file') { $form_question['separator3'] = array('name'=>'separator3', 'type'=>'separator'); } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', $langs->trans('ConfirmExportFile'), 'export_fileconfirm', $form_question, '', 1, 350, 600); + // add documents in an archive for accountancy export (Quadratus) + if (getDolGlobalString('ACCOUNTING_EXPORT_MODELCSV') == AccountancyExport::$EXPORT_TYPE_QUADRATUS) { + $form_question['notifiedexportfull'] = array( + 'name' => 'notifiedexportfull', + 'type' => 'checkbox', + 'label' => $langs->trans('NotifiedExportFull'), + 'value' => 'false', + ); + } + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', $langs->trans('ConfirmExportFile'), 'export_fileconfirm', $form_question, '', 1, 400, 600); } //if ($action == 'delbookkeepingyear') { @@ -997,15 +1046,25 @@ if ($massactionbutton && $contextpage != 'poslist') { } $moreforfilter = ''; +$moreforfilter .= '
'; +$moreforfilter .= $langs->trans('AccountingCategory').': '; +$moreforfilter .= '
'; +$moreforfilter .= $formaccounting->select_accounting_category($search_account_category, 'search_account_category', 1, 0, 0, 0); +$moreforfilter .= '
'; +$moreforfilter .= '
'; $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { $moreforfilter .= $hookmanager->resPrint; } else { $moreforfilter = $hookmanager->resPrint; } +print '
'; +print $moreforfilter; +print '
'; + print '
'; print ''; @@ -1511,6 +1570,16 @@ while ($i < min($num, $limit)) { // 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 ''; +} $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 4a6e37ceb29..78aea811a5d 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -79,7 +79,8 @@ $search_date_validation_start = dol_mktime(0, 0, 0, $search_date_validation_star $search_date_validation_end = dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear); $search_import_key = GETPOST("search_import_key", 'alpha'); -$search_accountancy_code = GETPOST("search_accountancy_code"); +$search_account_category = GETPOST('search_account_category', 'int'); + $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); if ($search_accountancy_code_start == - 1) { $search_accountancy_code_start = ''; @@ -198,6 +199,8 @@ if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } +$error = 0; + /* * Action @@ -224,7 +227,7 @@ if (empty($reshook)) { 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 $search_doc_date = ''; - $search_accountancy_code = ''; + $search_account_category = ''; $search_accountancy_code_start = ''; $search_accountancy_code_end = ''; $search_label_account = ''; @@ -280,6 +283,20 @@ if (empty($reshook)) { $filter['t.doc_date'] = $search_doc_date; $param .= '&doc_datemonth='.GETPOST('doc_datemonth', 'int').'&doc_dateday='.GETPOST('doc_dateday', 'int').'&doc_dateyear='.GETPOST('doc_dateyear', 'int'); } + if ($search_account_category != '-1' && !empty($search_account_category)) { + require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php'; + $accountingcategory = new AccountancyCategory($db); + + $listofaccountsforgroup = $accountingcategory->getCptsCat(0, 'fk_accounting_category = '.((int) $search_account_category)); + $listofaccountsforgroup2 = array(); + if (is_array($listofaccountsforgroup)) { + foreach ($listofaccountsforgroup as $tmpval) { + $listofaccountsforgroup2[] = "'".$db->escape($tmpval['id'])."'"; + } + } + $filter['t.search_accounting_code_in'] = join(',', $listofaccountsforgroup2); + $param .= '&search_account_category='.urlencode($search_account_category); + } if (!empty($search_accountancy_code_start)) { if ($type == 'sub') { $filter['t.subledger_account>='] = $search_accountancy_code_start; @@ -358,7 +375,6 @@ if (empty($reshook)) { $filter['t.import_key'] = $search_import_key; $param .= '&search_import_key='.urlencode($search_import_key); } - // param with type of list $url_param = substr($param, 1); // remove first "&" if (!empty($type)) { @@ -544,25 +560,29 @@ llxHeader('', $title_page); // List $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + // TODO Perf Replace this by a count if ($type == 'sub') { - $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter, 'AND', 1); + $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter, 'AND', 1, 1); } else { - $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter); + $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter, 'AND', 0, 1); } if ($nbtotalofrecords < 0) { setEventMessages($object->error, $object->errors, 'errors'); + $error++; } } -if ($type == 'sub') { - $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 1); -} else { - $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter); -} +if (!$error) { + if ($type == 'sub') { + $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 1); + } else { + $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 0); + } -if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } $arrayofselected = is_array($toselect) ? $toselect : array(); @@ -711,7 +731,7 @@ if ($type == 'sub') { $moreforfilter = ''; -// Accountancy account +// Search on accountancy custom groups or account $moreforfilter .= '
'; $moreforfilter .= $langs->trans('AccountAccounting').': '; $moreforfilter .= '
'; @@ -729,6 +749,13 @@ if ($type == 'sub') { $moreforfilter .= '
'; $moreforfilter .= '
'; +$moreforfilter .= '
'; +$moreforfilter .= $langs->trans('AccountingCategory').': '; +$moreforfilter .= '
'; +$moreforfilter .= $formaccounting->select_accounting_category($search_account_category, 'search_account_category', 1, 0, 0, 0); +$moreforfilter .= '
'; +$moreforfilter .= '
'; + $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) { @@ -935,8 +962,8 @@ while ($i < min($num, $limit)) { } else { print ''; } - print ''; - print ''; + print ''; + print ''; print ''; print ''; // Show balance of last shown account @@ -945,13 +972,13 @@ while ($i < min($num, $limit)) { print ''; if ($balance > 0) { print ''; print ''; } else { print ''; print ''; } print ''; @@ -1206,8 +1233,8 @@ while ($i < min($num, $limit)) { if ($num > 0 && $colspan > 0) { print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; // Show balance of last shown account @@ -1216,22 +1243,42 @@ if ($num > 0 && $colspan > 0) { print ''; if ($balance > 0) { print ''; print ''; } else { print ''; print ''; } print ''; print ''; } + +// Clean total values to round them +if (!empty($totalarray['val']['totaldebit'])) { + $totalarray['val']['totaldebit'] = price2num($totalarray['val']['totaldebit'], 'MT'); +} +if (!empty($totalarray['val']['totalcredit'])) { + $totalarray['val']['totalcredit'] = price2num($totalarray['val']['totalcredit'], 'MT'); +} + + // 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 ''; +} $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 68662ccb610..d68f4e79f5e 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -353,7 +353,7 @@ class AccountancyCategory // extends CommonObject $sql .= " formula=".(isset($this->formula) ? "'".$this->db->escape($this->formula)."'" : "null").","; $sql .= " position=".(isset($this->position) ? $this->position : "null").","; $sql .= " fk_country=".(isset($this->fk_country) ? $this->fk_country : "null").","; - $sql .= " active=".(isset($this->active) ? $this->active : "null").""; + $sql .= " active=".(isset($this->active) ? $this->active : "null"); $sql .= " WHERE rowid=".((int) $this->id); $this->db->begin(); @@ -446,7 +446,7 @@ class AccountancyCategory // extends CommonObject } else { $this->error = "Error ".$this->db->lasterror(); $this->errors[] = $this->error; - dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR); + dol_syslog(__METHOD__." ".implode(',', $this->errors), LOG_ERR); return -1; } @@ -488,7 +488,7 @@ class AccountancyCategory // extends CommonObject } else { $this->error = "Error ".$this->db->lasterror(); $this->errors[] = $this->error; - dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR); + dol_syslog(__METHOD__." ".implode(',', $this->errors), LOG_ERR); return -1; } @@ -605,60 +605,6 @@ class AccountancyCategory // extends CommonObject } } - /** - * Function to know all custom groupd from an accounting account - * - * @return array|integer Result in table (array), -1 if KO - */ - public function getCatsCpts() - { - global $mysoc, $conf; - - if (empty($mysoc->country_id)) { - dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined'); - exit(); - } - - $sql = "SELECT t.rowid, t.account_number, t.label as account_label, cat.code, cat.position, cat.label as name_cat, cat.sens "; - $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t, ".MAIN_DB_PREFIX."c_accounting_category as cat"; - $sql .= " WHERE t.fk_accounting_category IN ( SELECT c.rowid "; - $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c"; - $sql .= " WHERE c.active = 1"; - $sql .= " AND c.entity = ".$conf->entity; - $sql .= " AND (c.fk_country = ".((int) $mysoc->country_id)." OR c.fk_country = 0)"; - $sql .= " AND cat.rowid = t.fk_accounting_category"; - $sql .= " AND t.entity = ".$conf->entity; - $sql .= " ORDER BY cat.position ASC"; - - $resql = $this->db->query($sql); - if ($resql) { - $i = 0; - $obj = ''; - $num = $this->db->num_rows($resql); - $data = array(); - if ($num) { - while ($obj = $this->db->fetch_object($resql)) { - $name_cat = $obj->name_cat; - $data[$name_cat][$i] = array( - 'id' => $obj->rowid, - 'code' => $obj->code, - 'position' => $obj->position, - 'account_number' => $obj->account_number, - 'account_label' => $obj->account_label, - 'sens' => $obj->sens - ); - $i++; - } - } - return $data; - } else { - $this->error = "Error ".$this->db->lasterror(); - dol_syslog(__METHOD__." ".$this->error, LOG_ERR); - - return -1; - } - } - /** * Function to show result of an accounting account from the ledger with a direction and a period * @@ -678,6 +624,22 @@ class AccountancyCategory // extends CommonObject $this->sdc = 0; $this->sdcpermonth = array(); + if (is_array($cpt)) { + $listofaccount = ''; + foreach ($cpt as $cptcursor) { + if (! is_null($cptcursor)) { + if ($listofaccount) { + $listofaccount .= ","; + } + $listofaccount .= "'".$cptcursor."'"; + } + } + if (empty($listofaccount)) { + // List of account is empty, so we do no try sql request, we can say result is empty. + return 0; + } + } + $sql = "SELECT SUM(t.debit) as debit, SUM(t.credit) as credit"; if (is_array($cpt)) { $sql .= ", t.numero_compte as accountancy_account"; @@ -686,13 +648,6 @@ class AccountancyCategory // extends CommonObject //if (in_array($this->db->type, array('mysql', 'mysqli'))) $sql.=' USE INDEX idx_accounting_bookkeeping_doc_date'; $sql .= " WHERE t.entity = ".$conf->entity; if (is_array($cpt)) { - $listofaccount = ''; - foreach ($cpt as $cptcursor) { - if ($listofaccount) { - $listofaccount .= ","; - } - $listofaccount .= "'".$cptcursor."'"; - } $sql .= " AND t.numero_compte IN (".$this->db->sanitize($listofaccount, 1).")"; } else { $sql .= " AND t.numero_compte = '".$this->db->escape($cpt)."'"; @@ -709,22 +664,28 @@ class AccountancyCategory // extends CommonObject if (is_array($cpt)) { $sql .= " GROUP BY t.numero_compte"; } - //print $sql; $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); if ($num) { - $obj = $this->db->fetch_object($resql); - if ($sens == 1) { - $this->sdc = $obj->debit - $obj->credit; - } else { - $this->sdc = $obj->credit - $obj->debit; - } - if (is_array($cpt)) { - $this->sdcperaccount[$obj->accountancy_account] = $this->sdc; + $i = 0; + while ($i < $num) { + $obj = $this->db->fetch_object($resql); + if ($obj) { + if ($sens == 1) { + $this->sdc = $obj->debit - $obj->credit; + } else { + $this->sdc = $obj->credit - $obj->debit; + } + if (is_array($cpt)) { + $this->sdcperaccount[$obj->accountancy_account] = $this->sdc; + } + } + $i++; } } + return $num; } else { $this->error = "Error ".$this->db->lasterror(); @@ -734,12 +695,75 @@ class AccountancyCategory // extends CommonObject } } + /** + * Function to get an array of all active custom groups (llx_c_accunting_categories) with their accounts from the chart of account (ll_accounting_acount) + * + * @param int $catid Custom group ID + * @return array|integer Result in table (array), -1 if KO + * @see getCats(), getCptsCat() + */ + public function getCatsCpts($catid = 0) + { + global $mysoc, $conf; + + if (empty($mysoc->country_id)) { + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(__METHOD__." ".$this->error, LOG_ERR); + return -1; + } + + $sql = "SELECT t.rowid, t.account_number, t.label as account_label,"; + $sql .= " cat.code, cat.position, cat.label as name_cat, cat.sens, cat.category_type, cat.formula"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t, ".MAIN_DB_PREFIX."c_accounting_category as cat"; + $sql .= " WHERE t.fk_accounting_category IN (SELECT c.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c"; + $sql .= " WHERE c.active = 1"; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " AND (c.fk_country = ".((int) $mysoc->country_id)." OR c.fk_country = 0)"; + $sql .= " AND cat.rowid = t.fk_accounting_category"; + $sql .= " AND t.entity = ".$conf->entity; + if ($catid > 0) { + $sql .= " AND cat.rowid = ".((int) $catid); + } + $sql .= " ORDER BY cat.position ASC"; + + $resql = $this->db->query($sql); + if ($resql) { + $obj = ''; + $num = $this->db->num_rows($resql); + $data = array(); + if ($num) { + while ($obj = $this->db->fetch_object($resql)) { + $name_cat = $obj->name_cat; + $data[$name_cat][$obj->rowid] = array( + 'id' => $obj->rowid, + 'code' => $obj->code, + 'label' => $obj->label, + 'position' => $obj->position, + 'category_type' => $obj->category_type, + 'formula' => $obj->formula, + 'sens' => $obj->sens, + 'account_number' => $obj->account_number, + 'account_label' => $obj->account_label + ); + } + } + return $data; + } else { + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(__METHOD__." ".$this->error, LOG_ERR); + return -1; + } + } + /** * Return list of custom groups. + * For list + detail of accounting account, see getCatsCpt() * * @param int $categorytype -1=All, 0=Only non computed groups, 1=Only computed groups * @param int $active 1= active, 0=not active * @return array|int Array of groups or -1 if error + * @see getCatsCpts(), getCptsCat() */ public function getCats($categorytype = -1, $active = 1) { @@ -774,9 +798,10 @@ class AccountancyCategory // extends CommonObject 'rowid' => $obj->rowid, 'code' => $obj->code, 'label' => $obj->label, - 'formula' => $obj->formula, 'position' => $obj->position, 'category_type' => $obj->category_type, + 'formula' => $obj->formula, + 'sens' => $obj->sens, 'bc' => $obj->sens ); $i++; @@ -794,12 +819,15 @@ class AccountancyCategory // extends CommonObject /** - * Get all accounting account of a custom group (or a list of custom groups). + * Get all accounting account of a given custom group (or a list of custom groups). * You must choose between first parameter (personalized group) or the second (free criteria filter) * * @param int $cat_id Id if personalized accounting group/category - * @param string $predefinedgroupwhere Sql criteria filter to select accounting accounts. This value must not come from an input of a user. + * @param string $predefinedgroupwhere Sql criteria filter to select accounting accounts. This value must be sanitized and not come from an input of a user. + * Example: "pcg_type = 'EXPENSE' AND fk_pcg_version = 'xx'" + * Example: "fk_accounting_category = 99" * @return array|int Array of accounting accounts or -1 if error + * @see getCats(), getCatsCpts() */ public function getCptsCat($cat_id, $predefinedgroupwhere = '') { diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 3c45315ffa9..4c6e2d09838 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -5,13 +5,15 @@ * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2016 Pierre-Henry Favre - * Copyright (C) 2016-2021 Alexandre Spangaro + * Copyright (C) 2016-2022 Alexandre Spangaro + * Copyright (C) 2022 Lionel Vessiller * Copyright (C) 2013-2017 Olivier Geffroy * Copyright (C) 2017 Elarifr. Ari Elbaz * Copyright (C) 2017-2019 Frédéric France * Copyright (C) 2017 André Schild * Copyright (C) 2020 Guillaume Alexandre * Copyright (C) 2022 Joachim Kueter + * Copyright (C) 2022 Progiseize * * 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 @@ -36,6 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; /** @@ -313,9 +316,10 @@ class AccountancyExport * * @param array $TData Array with data * @param int $formatexportset Id of export format - * @return void + * @param int $withAttachment [=0] Not add files or 1 to have attached in an archive (ex : Quadratus) + * @return int <0 if KO, >0 OK */ - public function export(&$TData, $formatexportset) + public function export(&$TData, $formatexportset, $withAttachment = 0) { global $conf, $langs; global $search_date_end; // Used into /accountancy/tpl/export_journal.tpl.php @@ -325,8 +329,44 @@ class AccountancyExport $type_export = 'general_ledger'; global $db; // The tpl file use $db + $completefilename = ''; + $exportFile = null; + $exportFileName = ''; + $exportFilePath = ''; + $archiveFileList = array(); + if ($withAttachment == 1) { + // PHP ZIP extension must be enabled + if (!extension_loaded('zip')) { + $langs->load('install'); + $this->errors[] = $langs->trans('ErrorPHPDoesNotSupport', 'ZIP'); + return -1; + } + } else { + $mimetype = $this->getMimeType($formatexportset); + top_httphead($mimetype, 1); + } include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; + if ($withAttachment == 1 && !empty($completefilename)) { + // create export file + $tmpDir = !empty($conf->accounting->multidir_temp[$conf->entity]) ? $conf->accounting->multidir_temp[$conf->entity] : $conf->accounting->dir_temp; + $exportFileFullName = $completefilename; + $exportFileBaseName = basename($exportFileFullName); + $exportFileName = pathinfo($exportFileBaseName, PATHINFO_FILENAME); + $exportFilePath = $tmpDir.'/'.$exportFileFullName; + $exportFile = fopen($exportFilePath, 'w'); + if (!$exportFile) { + $this->errors[] = $langs->trans('ErrorFileNotFound', $exportFilePath); + return -1; + } + $archiveFileList[0] = array( + 'path' => $exportFilePath, + 'name' => $exportFileFullName, + ); + // archive name and path + $archiveFullName = $exportFileName.'.zip'; + $archivePath = $tmpDir.'/'.$archiveFullName; + } switch ($formatexportset) { case self::$EXPORT_TYPE_CONFIGURABLE: @@ -345,7 +385,7 @@ class AccountancyExport $this->exportCiel($TData); break; case self::$EXPORT_TYPE_QUADRATUS: - $this->exportQuadratus($TData); + $archiveFileList = $this->exportQuadratus($TData, $exportFile, $archiveFileList, $withAttachment); break; case self::$EXPORT_TYPE_WINFIC: $this->exportWinfic($TData); @@ -399,6 +439,69 @@ class AccountancyExport } break; } + + // create and download export file or archive + if ($withAttachment == 1) { + $error = 0; + + // close export file + if ($exportFile) { + fclose($exportFile); + } + + if (!empty($archiveFullName) && !empty($archivePath) && !empty($archiveFileList)) { + // archive files + $downloadFileMimeType = 'application/zip'; + $downloadFileFullName = $archiveFullName; + $downloadFilePath = $archivePath; + + // create archive + $archive = new ZipArchive(); + $res = $archive->open($archivePath, ZipArchive::OVERWRITE | ZipArchive::CREATE); + if ($res !== true) { + $error++; + $this->errors[] = $langs->trans('ErrorFileNotFound', $archivePath); + } + if (!$error) { + // add files + foreach ($archiveFileList as $archiveFileArr) { + $res = $archive->addFile($archiveFileArr['path'], $archiveFileArr['name']); + if (!$res) { + $error++; + $this->errors[] = $langs->trans('ErrorArchiveAddFile', $archiveFileArr['name']); + break; + } + } + } + if (!$error) { + // close archive + $archive->close(); + } + } elseif (!empty($exportFileFullName) && !empty($exportFilePath)) { + // only one file to download + $downloadFileMimeType = 'text/csv'; + $downloadFileFullName = $exportFileFullName; + $downloadFilePath = $exportFilePath; + } + + if (!$error) { + // download export file + if (!empty($downloadFileMimeType) && !empty($downloadFileFullName) && !empty($downloadFilePath)) { + header('Content-Type: '.$downloadFileMimeType); + header('Content-Disposition: attachment; filename='.$downloadFileFullName); + header('Cache-Control: Public, must-revalidate'); + header('Pragma: public'); + header('Content-Length: '.dol_filesize($downloadFilePath)); + readfileLowMemory($downloadFilePath); + } + } + + if ($error) { + return -1; + } + } + + return 1; } @@ -444,14 +547,14 @@ class AccountancyExport print $date.$separator; print $line->piece_num.$separator; print length_accountg($line->numero_compte).$separator; - print ''.$separator; + print $separator; print $line->label_operation.$separator; print $date.$separator; if ($line->sens == 'D') { print price($line->debit).$separator; - print ''.$separator; + print $separator; } elseif ($line->sens == 'C') { - print ''.$separator; + print $separator; print price($line->credit).$separator; } print $line->doc_ref.$separator; @@ -584,10 +687,13 @@ class AccountancyExport * Help : https://docplayer.fr/20769649-Fichier-d-entree-ascii-dans-quadracompta.html * In QuadraCompta | Use menu : "Outils" > "Suivi des dossiers" > "Import ASCII(Compta)" * - * @param array $TData data - * @return void + * @param array $TData Data + * @param resource $exportFile [=null] File resource to export or print if null + * @param array $archiveFileList [=array()] Archive file list : array of ['path', 'name'] + * @param bool $withAttachment [=0] Not add files or 1 to have attached in an archive + * @return array Archive file list : array of ['path', 'name'] */ - public function exportQuadratus(&$TData) + public function exportQuadratus(&$TData, $exportFile = null, $archiveFileList = array(), $withAttachment = 0) { global $conf, $db; @@ -637,7 +743,11 @@ class AccountancyExport $Tab['end_line'] = $end_line; - print implode($Tab); + if ($exportFile) { + fwrite($exportFile, implode($Tab)); + } else { + print implode($Tab); + } } $Tab = array(); @@ -708,12 +818,63 @@ class AccountancyExport // We need to keep the 10 lastest number of invoice doc_ref not the beginning part that is the unusefull almost same part // $Tab['num_piece3'] = str_pad(self::trunc($data->piece_num, 10), 10); $Tab['num_piece3'] = substr(self::trunc($data->doc_ref, 20), -10); - $Tab['filler4'] = str_repeat(' ', 73); + $Tab['reserved'] = str_repeat(' ', 10); // position 159 + $Tab['currency_amount'] = str_repeat(' ', 13); // position 169 + // get document file + $attachmentFileName = ''; + if ($withAttachment == 1) { + $attachmentFileKey = trim($data->piece_num); + if (!isset($archiveFileList[$attachmentFileKey])) { + $objectDirPath = ''; + $objectFileName = dol_sanitizeFileName($data->doc_ref); + if ($data->doc_type == 'customer_invoice') { + $objectDirPath = !empty($conf->facture->multidir_output[$conf->entity]) ? $conf->facture->multidir_output[$conf->entity] : $conf->facture->dir_output; + } elseif ($data->doc_type == 'expense_report') { + $objectDirPath = !empty($conf->expensereport->multidir_output[$conf->entity]) ? $conf->expensereport->multidir_output[$conf->entity] : $conf->factureexpensereport->dir_output; + } elseif ($data->doc_type == 'supplier_invoice') { + $objectDirPath = !empty($conf->fournisseur->facture->multidir_output[$conf->entity]) ? $conf->fournisseur->facture->multidir_output[$conf->entity] : $conf->fournisseur->facture->dir_output; + } + $arrayofinclusion = array(); + $arrayofinclusion[] = '^'.preg_quote($objectFileName, '/').'\.pdf$'; + $fileFoundList = dol_dir_list($objectDirPath.'/'.$objectFileName, 'files', 0, implode('|', $arrayofinclusion), '(\.meta|_preview.*\.png)$', 'date', SORT_DESC, 0, true); + if (!empty($fileFoundList)) { + $attachmentFileNameTrunc = str_pad(self::trunc($data->piece_num, 8), 8, '0', STR_PAD_LEFT); + foreach ($fileFoundList as $fileFound) { + if (strstr($fileFound['name'], $objectFileName)) { + $fileFoundPath = $objectDirPath.'/'.$objectFileName.'/'.$fileFound['name']; + if (file_exists($fileFoundPath)) { + $archiveFileList[$attachmentFileKey] = array( + 'path' => $fileFoundPath, + 'name' => $attachmentFileNameTrunc.'.pdf', + ); + break; + } + } + } + } + } + + if (isset($archiveFileList[$attachmentFileKey])) { + $attachmentFileName = $archiveFileList[$attachmentFileKey]['name']; + } + } + if (dol_strlen($attachmentFileName) == 12) { + $Tab['attachment'] = $attachmentFileName; // position 182 + } else { + $Tab['attachment'] = str_repeat(' ', 12); // position 182 + } + $Tab['filler4'] = str_repeat(' ', 38); $Tab['end_line'] = $end_line; - print implode($Tab); + if ($exportFile) { + fwrite($exportFile, implode($Tab)); + } else { + print implode($Tab); + } } + + return $archiveFileList; } /** diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 4accf66e154..f56932d4985 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -454,27 +454,12 @@ class AccountingJournal extends CommonObject } $sql = ""; - - // FIXME sql error with Mysql 5.7 - /*if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') { - $sql .= "WITH in_accounting_bookkeeping(fk_docdet) AS ("; - $sql .= " SELECT DISTINCT fk_docdet"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; - $sql .= " WHERE doc_type = 'asset'"; - $sql .= ") "; - }*/ - $sql .= "SELECT ad.fk_asset AS rowid, a.ref AS asset_ref, a.label AS asset_label, a.acquisition_value_ht AS asset_acquisition_value_ht"; $sql .= ", a.disposal_date AS asset_disposal_date, a.disposal_amount_ht AS asset_disposal_amount_ht, a.disposal_subject_to_vat AS asset_disposal_subject_to_vat"; $sql .= ", ad.rowid AS depreciation_id, ad.depreciation_mode, ad.ref AS depreciation_ref, ad.depreciation_date, ad.depreciation_ht, ad.accountancy_code_debit, ad.accountancy_code_credit"; $sql .= " FROM " . MAIN_DB_PREFIX . "asset_depreciation as ad"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "asset as a ON a.rowid = ad.fk_asset"; - // FIXME sql error with Mysql 5.7 - /*if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') { - $sql .= " LEFT JOIN in_accounting_bookkeeping as iab ON iab.fk_docdet = ad.rowid"; - }*/ $sql .= " WHERE a.entity IN (" . getEntity('asset', 0) . ')'; // We don't share object for accountancy, we use source object sharing - // Compatibility with Mysql 5.7 if ($in_bookkeeping == 'already') { $sql .= " AND EXISTS (SELECT iab.fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS iab WHERE iab.fk_docdet = ad.rowid AND doc_type = 'asset')"; } elseif ($in_bookkeeping == 'notyet') { @@ -488,11 +473,6 @@ class AccountingJournal extends CommonObject if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { $sql .= " AND ad.depreciation_date >= '" . $this->db->idate($conf->global->ACCOUNTING_DATE_START_BINDING) . "'"; } - // Already in bookkeeping or not - // FIXME sql error with Mysql 5.7 - /*if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') { - $sql .= " AND iab.fk_docdet IS" . ($in_bookkeeping == 'already' ? " NOT" : "") . " NULL"; - }*/ $sql .= " ORDER BY ad.depreciation_date"; dol_syslog(__METHOD__, LOG_DEBUG); @@ -755,7 +735,7 @@ class AccountingJournal extends CommonObject } } - $journal_data[$pre_data_id] = $element; + $journal_data[(int) $pre_data_id] = $element; } unset($pre_data); diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 803e2feb619..f880ac6481c 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -817,56 +817,61 @@ class BookKeeping extends CommonObject /** - * Load object in memory from the database + * Load object in memory from the database in ->lines. Or just make a simple count if $countonly=1. * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit offset limit - * @param int $offset offset limit - * @param array $filter filter array - * @param string $filtermode filter mode (AND or OR) - * @param int $option option (0: general account or 1: subaccount) - * - * @return int <0 if KO, >=0 if OK + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit offset limit + * @param int $offset offset limit + * @param array $filter filter array + * @param string $filtermode filter mode (AND or OR) + * @param int $option option (0: general account or 1: subaccount) + * @param int $countonly Do not fill the $object->lines, return only the count. + * @return int <0 if KO, Number of lines if OK */ - public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND', $option = 0) + public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND', $option = 0, $countonly = 0) { global $conf; dol_syslog(__METHOD__, LOG_DEBUG); $this->lines = array(); + $num = 0; $sql = 'SELECT'; - $sql .= ' t.rowid,'; - $sql .= " t.doc_date,"; - $sql .= " t.doc_type,"; - $sql .= " t.doc_ref,"; - $sql .= " t.fk_doc,"; - $sql .= " t.fk_docdet,"; - $sql .= " t.thirdparty_code,"; - $sql .= " t.subledger_account,"; - $sql .= " t.subledger_label,"; - $sql .= " t.numero_compte,"; - $sql .= " t.label_compte,"; - $sql .= " t.label_operation,"; - $sql .= " t.debit,"; - $sql .= " t.credit,"; - $sql .= " t.montant as amount,"; - $sql .= " t.sens,"; - $sql .= " t.multicurrency_amount,"; - $sql .= " t.multicurrency_code,"; - $sql .= " t.lettering_code,"; - $sql .= " t.date_lettering,"; - $sql .= " t.fk_user_author,"; - $sql .= " t.import_key,"; - $sql .= " t.code_journal,"; - $sql .= " t.journal_label,"; - $sql .= " t.piece_num,"; - $sql .= " t.date_creation,"; - $sql .= " t.date_export,"; - $sql .= " t.date_validated as date_validation,"; - $sql .= " t.import_key"; + if ($countonly) { + $sql .= ' COUNT(t.rowid) as nb'; + } else { + $sql .= ' t.rowid,'; + $sql .= " t.doc_date,"; + $sql .= " t.doc_type,"; + $sql .= " t.doc_ref,"; + $sql .= " t.fk_doc,"; + $sql .= " t.fk_docdet,"; + $sql .= " t.thirdparty_code,"; + $sql .= " t.subledger_account,"; + $sql .= " t.subledger_label,"; + $sql .= " t.numero_compte,"; + $sql .= " t.label_compte,"; + $sql .= " t.label_operation,"; + $sql .= " t.debit,"; + $sql .= " t.credit,"; + $sql .= " t.montant as amount,"; + $sql .= " t.sens,"; + $sql .= " t.multicurrency_amount,"; + $sql .= " t.multicurrency_code,"; + $sql .= " t.lettering_code,"; + $sql .= " t.date_lettering,"; + $sql .= " t.fk_user_author,"; + $sql .= " t.import_key,"; + $sql .= " t.code_journal,"; + $sql .= " t.journal_label,"; + $sql .= " t.piece_num,"; + $sql .= " t.date_creation,"; + $sql .= " t.date_export,"; + $sql .= " t.date_validated as date_validation,"; + $sql .= " t.import_key"; + } // Manage filter $sqlwhere = array(); if (count($filter) > 0) { @@ -880,7 +885,7 @@ class BookKeeping extends CommonObject } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { $sqlwhere[] = $key.'='.$value; } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { - $sqlwhere[] = $key.' LIKE \''.$this->db->escape($value).'%\''; + $sqlwhere[] = $key.' LIKE \''.$this->db->escapeforlike($this->db->escape($value)).'%\''; } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') { $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; } elseif ($key == 't.date_export>=' || $key == 't.date_export<=') { @@ -897,18 +902,19 @@ class BookKeeping extends CommonObject } else { $sqlwhere[] = natural_search("t.code_journal", $value, 3, 1); } + } elseif ($key == 't.search_accounting_code_in' && !empty($value)) { + $sqlwhere[] = 't.numero_compte IN ('.$this->db->sanitize($value, 1).')'; } else { $sqlwhere[] = natural_search($key, $value, 0, 1); } } } $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql .= ' WHERE 1 = 1'; - $sql .= " AND entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features + $sql .= ' WHERE entity = ' . ((int) $conf->entity); // Do not use getEntity for accounting features if (count($sqlwhere) > 0) { $sql .= " AND ".implode(" ".$filtermode." ", $sqlwhere); } - // Affichage par compte comptable + // Filter by ledger account or subledger account if (!empty($option)) { $sql .= " AND t.subledger_account IS NOT NULL"; $sql .= " AND t.subledger_account <> ''"; @@ -919,54 +925,63 @@ class BookKeeping extends CommonObject $sortorder = 'ASC'.($sortorder ? ','.$sortorder : ''); } - $sql .= $this->db->order($sortfield, $sortorder); - if (!empty($limit)) { - $sql .= $this->db->plimit($limit + 1, $offset); + if (!$countonly) { + $sql .= $this->db->order($sortfield, $sortorder); + if (!empty($limit)) { + $sql .= $this->db->plimit($limit + 1, $offset); + } } $resql = $this->db->query($sql); if ($resql) { - $num = $this->db->num_rows($resql); + if ($countonly) { + $obj = $this->db->fetch_object($resql); + if ($obj) { + $num = $obj->nb; + } + } else { + $num = $this->db->num_rows($resql); - $i = 0; - while (($obj = $this->db->fetch_object($resql)) && (empty($limit) || $i < min($limit, $num))) { - $line = new BookKeepingLine(); + $i = 0; + while (($obj = $this->db->fetch_object($resql)) && (empty($limit) || $i < min($limit, $num))) { + $line = new BookKeepingLine(); - $line->id = $obj->rowid; + $line->id = $obj->rowid; - $line->doc_date = $this->db->jdate($obj->doc_date); - $line->doc_type = $obj->doc_type; - $line->doc_ref = $obj->doc_ref; - $line->fk_doc = $obj->fk_doc; - $line->fk_docdet = $obj->fk_docdet; - $line->thirdparty_code = $obj->thirdparty_code; - $line->subledger_account = $obj->subledger_account; - $line->subledger_label = $obj->subledger_label; - $line->numero_compte = $obj->numero_compte; - $line->label_compte = $obj->label_compte; - $line->label_operation = $obj->label_operation; - $line->debit = $obj->debit; - $line->credit = $obj->credit; - $line->montant = $obj->amount; // deprecated - $line->amount = $obj->amount; - $line->sens = $obj->sens; - $line->multicurrency_amount = $obj->multicurrency_amount; - $line->multicurrency_code = $obj->multicurrency_code; - $line->lettering_code = $obj->lettering_code; - $line->date_lettering = $obj->date_lettering; - $line->fk_user_author = $obj->fk_user_author; - $line->import_key = $obj->import_key; - $line->code_journal = $obj->code_journal; - $line->journal_label = $obj->journal_label; - $line->piece_num = $obj->piece_num; - $line->date_creation = $this->db->jdate($obj->date_creation); - $line->date_export = $this->db->jdate($obj->date_export); - $line->date_validation = $this->db->jdate($obj->date_validation); - $line->import_key = $obj->import_key; + $line->doc_date = $this->db->jdate($obj->doc_date); + $line->doc_type = $obj->doc_type; + $line->doc_ref = $obj->doc_ref; + $line->fk_doc = $obj->fk_doc; + $line->fk_docdet = $obj->fk_docdet; + $line->thirdparty_code = $obj->thirdparty_code; + $line->subledger_account = $obj->subledger_account; + $line->subledger_label = $obj->subledger_label; + $line->numero_compte = $obj->numero_compte; + $line->label_compte = $obj->label_compte; + $line->label_operation = $obj->label_operation; + $line->debit = $obj->debit; + $line->credit = $obj->credit; + $line->montant = $obj->amount; // deprecated + $line->amount = $obj->amount; + $line->sens = $obj->sens; + $line->multicurrency_amount = $obj->multicurrency_amount; + $line->multicurrency_code = $obj->multicurrency_code; + $line->lettering_code = $obj->lettering_code; + $line->date_lettering = $obj->date_lettering; + $line->fk_user_author = $obj->fk_user_author; + $line->import_key = $obj->import_key; + $line->code_journal = $obj->code_journal; + $line->journal_label = $obj->journal_label; + $line->piece_num = $obj->piece_num; + $line->date_creation = $this->db->jdate($obj->date_creation); + $line->date_export = $this->db->jdate($obj->date_export); + $line->date_validation = $this->db->jdate($obj->date_validation); + $line->import_key = $obj->import_key; - $this->lines[] = $line; + $this->lines[] = $line; - $i++; + $i++; + } } $this->db->free($resql); diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index e4f7d556c16..b8df8890a01 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -529,6 +529,10 @@ if ($result) { print ''; $i++; } + if ($num_lines == 0) { + print ''; + } + print '
'.$langs->trans("NoRecordFound").'
' . $langs->trans("TotalForAccount") . ' ' . length_accountg($displayed_account_number) . ':'.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_debit, 'MT')).''.price(price2num($sous_total_credit, 'MT')).'
'.$langs->trans("Balance").':'; - print price($sous_total_debit - $sous_total_credit); + print price(price2num($sous_total_debit - $sous_total_credit, 'MT')); print ''; - print price($sous_total_credit - $sous_total_debit); + print price(price2num($sous_total_credit - $sous_total_debit, 'MT')); print '
'.$langs->trans("TotalForAccount").' '.$accountg.':'.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_debit, 'MT')).''.price(price2num($sous_total_credit, 'MT')).'
'.$langs->trans("Balance").':'; - print price($sous_total_debit - $sous_total_credit); + print price(price2num($sous_total_debit - $sous_total_credit, 'MT')); print ''; - print price($sous_total_credit - $sous_total_debit); + print price(price2num($sous_total_credit - $sous_total_debit, 'MT')); print '
'.$langs->trans("NoRecordFound").'
'.$langs->trans("NoRecordFound").'
'; print "
"; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 57a9dd99e5e..021c1ec7821 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -749,6 +749,10 @@ if ($result) { print ''; $i++; } + if ($num_lines == 0) { + print ''.$langs->trans("NoRecordFound").''; + } + print ''; print ""; diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index aef45ae3ce1..1d0653fc5ac 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -427,6 +427,13 @@ if ($result) { print ""; $i++; } + if ($num_lines == 0) { + $colspan=10; + if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { + $colspan++; + } + print ''.$langs->trans("NoRecordFound").''; + } print ""; print ""; diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index b90a8a2c573..9cfbd940875 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -513,6 +513,9 @@ if ($result) { print ""; $i++; } + if ($num_lines == 0) { + print ''.$langs->trans("NoRecordFound").''; + } print ''; print ""; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index e63101594cb..699002395ab 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -793,7 +793,7 @@ if (!$error && $action == 'writebookkeeping') { setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } } else { - if ($lettering && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) { + if ($lettering && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && getDolGlobalInt('ACCOUNTING_ENABLE_AUTOLETTERING')) { require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; $lettering_static = new Lettering($db); $nb_lettering = $lettering_static->bookkeepingLetteringAll(array($bookkeeping->id)); @@ -1227,22 +1227,22 @@ if (empty($action) || $action == 'view') { $account_ledger = $k; // Try to force general ledger account depending on type if ($tabtype[$key] == 'payment') { - $account_ledger = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; + $account_ledger = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'); } if ($tabtype[$key] == 'payment_supplier') { - $account_ledger = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; + $account_ledger = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'); } if ($tabtype[$key] == 'payment_expensereport') { - $account_ledger = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; + $account_ledger = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); } if ($tabtype[$key] == 'payment_salary') { - $account_ledger = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; + $account_ledger = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); } if ($tabtype[$key] == 'payment_vat') { - $account_ledger = $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT; + $account_ledger = getDolGlobalString('ACCOUNTING_VAT_PAY_ACCOUNT'); } if ($tabtype[$key] == 'member') { - $account_ledger = $conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT; + $account_ledger = getDolGlobalString('ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT'); } if ($tabtype[$key] == 'payment_various') { $account_ledger = $tabpay[$key]["account_various"]; @@ -1281,7 +1281,7 @@ if (empty($action) || $action == 'view') { } } print ''; - print $accounttoshow; + print $accounttoshow; // This is a HTML string print ""; // Subledger account @@ -1310,7 +1310,7 @@ if (empty($action) || $action == 'view') { } } print ''; - print $accounttoshowsubledger; + print $accounttoshowsubledger; // This is a html string print ""; print "".$reflabel.""; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index a5b82e7b2d0..746383fef0b 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -376,7 +376,7 @@ if ($action == 'writebookkeeping') { setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } } else { - if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) { + if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && getDolGlobalInt('ACCOUNTING_ENABLE_AUTOLETTERING')) { require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; $lettering_static = new Lettering($db); $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id)); diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 0519762baef..666024833d0 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -4,7 +4,7 @@ * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2012 Regis Houssin * Copyright (C) 2013 Christophe Battarel - * Copyright (C) 2013-2021 Alexandre Spangaro + * Copyright (C) 2013-2022 Alexandre Spangaro * Copyright (C) 2013-2016 Florian Henry * Copyright (C) 2013-2016 Olivier Geffroy * Copyright (C) 2014 Raphaël Doursenaud @@ -106,7 +106,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.datef as df, f.ref_client, f.date_lim_reglement as dlr, f.close_code,"; +$sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.ref_client, f.date_lim_reglement as dlr, f.close_code, f.retained_warranty,"; $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,"; $sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur,"; if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { @@ -168,6 +168,7 @@ if ($result) { $tabht = array(); $tabtva = array(); $def_tva = array(); + $tabwarranty = array(); $tabttc = array(); $tablocaltax1 = array(); $tablocaltax2 = array(); @@ -248,7 +249,13 @@ if ($result) { $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; } - $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc * $situation_ratio; + $total_ttc = $obj->total_ttc * $situation_ratio; + if (!empty($conf->global->INVOICE_USE_RETAINED_WARRANTY) && $obj->retained_warranty > 0) { + $retained_warranty = (double) price2num($total_ttc * $obj->retained_warranty / 100, 'MT'); + $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; if (empty($line->tva_npr)) { $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio; // We ignore line if VAT is a NPR @@ -300,6 +307,10 @@ if ($action == 'writebookkeeping') { $accountingaccountcustomer->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, true); + $accountingaccountcustomerwarranty = new AccountingAccount($db); + + $accountingaccountcustomerwarranty->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY, true); + foreach ($tabfac as $key => $val) { // Loop on each invoice $errorforline = 0; @@ -344,6 +355,55 @@ if ($action == 'writebookkeeping') { setEventMessages($langs->trans('ErrorInvoiceContainsLinesNotYetBounded', $val['ref']), null, 'errors'); } + // Warranty + if (!$errorforline) { + foreach ($tabwarranty[$key] as $k => $mt) { + $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 = $tabcompany[$key]['code_compta']; + $bookkeeping->subledger_label = $tabcompany[$key]['name']; + + $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY; + $bookkeeping->label_compte = $accountingaccountcustomerwarranty->label; + + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$langs->trans("Retainedwarranty"); + $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'); + } + } + } + } + // Thirdparty if (!$errorforline) { foreach ($tabttc[$key] as $k => $mt) { @@ -390,7 +450,7 @@ if ($action == 'writebookkeeping') { setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } } else { - if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) { + if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && getDolGlobalInt('ACCOUNTING_ENABLE_AUTOLETTERING')) { require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; $lettering_static = new Lettering($db); $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id)); @@ -624,6 +684,25 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! continue; } + // Warranty + foreach ($tabwarranty[$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_accounta(html_entity_decode($k)).'"'.$sep; + print '"'.length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY).'"'.$sep; + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; + print '"'.$langs->trans("Thirdparty").'"'.$sep; + print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("Retainedwarranty").'"'.$sep; + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; + print '"'.$journal.'"'; + print "\n"; + //} + } + // Third party foreach ($tabttc[$key] as $k => $mt) { //if ($mt) { @@ -849,6 +928,36 @@ if (empty($action) || $action == 'view') { print ""; } + // Warranty + foreach ($tabwarranty[$key] as $k => $mt) { + print ''; + print ""; + print "".$date.""; + print "".$invoicestatic->getNomUrl(1).""; + // Account + print ""; + $accountoshow = length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY); + if (($accountoshow == "") || $accountoshow == 'NotDefined') { + print ''.$langs->trans("MainAccountForCustomersNotDefined").''; + } else { + print $accountoshow; + } + print ''; + // Subledger account + print ""; + $accountoshow = length_accounta($k); + if (($accountoshow == "") || $accountoshow == 'NotDefined') { + print ''.$langs->trans("ThirdpartyAccountNotDefined").''; + } else { + print $accountoshow; + } + print ''; + print "".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref.' - '.$langs->trans("Retainedwarranty").""; + print ''.($mt >= 0 ? price($mt) : '').""; + print ''.($mt < 0 ? price(-$mt) : '').""; + print ""; + } + // Third party foreach ($tabttc[$key] as $k => $mt) { print ''; diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 25368f30c61..ea9841d2fbb 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -558,6 +558,10 @@ if ($result) { print ''; $i++; } + if ($num_lines == 0) { + print ''.$langs->trans("NoRecordFound").''; + } + print ''; print ""; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index b78227a67f6..3b8e93cb54b 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -777,6 +777,9 @@ if ($result) { print ''; $i++; } + if ($num_lines == 0) { + print ''.$langs->trans("NoRecordFound").''; + } print ''; print ""; diff --git a/htdocs/accountancy/tpl/export_journal.tpl.php b/htdocs/accountancy/tpl/export_journal.tpl.php index 22537a60a39..8e3c914a6f5 100644 --- a/htdocs/accountancy/tpl/export_journal.tpl.php +++ b/htdocs/accountancy/tpl/export_journal.tpl.php @@ -1,6 +1,8 @@ + * Copyright (C) 2022 Lionel Vessiller * Copyright (C) 2016 Charlie Benke + * Copyright (C) 2022 Progiseize * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,7 +35,9 @@ $siren = getDolGlobalString('MAIN_INFO_SIREN'); $date_export = "_".dol_print_date(dol_now(), '%Y%m%d%H%M%S'); $endaccountingperiod = dol_print_date(dol_now(), '%Y%m%d'); -header('Content-Type: text/csv'); +if (empty($withAttachment)) { + header('Content-Type: text/csv'); +} include_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php'; $accountancyexport = new AccountancyExport($db); @@ -66,4 +70,6 @@ if (($accountancyexport->getFormatCode($formatexportset) == 'fec' || $accountanc $completefilename = ($code ? $code."_" : "").($prefix ? $prefix."_" : "").$filename.($nodateexport ? "" : $date_export).".".$format; } -header('Content-Disposition: attachment;filename='.$completefilename); +if (empty($withAttachment)) { + header('Content-Disposition: attachment;filename=' . $completefilename); +} diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php index d20bd784ced..f9e15e88fca 100644 --- a/htdocs/adherents/admin/member.php +++ b/htdocs/adherents/admin/member.php @@ -152,10 +152,13 @@ if ($action == 'set_default') { setEventMessages('RecordModifiedSuccessfully', null, 'mesgs'); $db->commit(); } -} - -// Action to update or add a constant -if ($action == 'update' || $action == 'add') { +} elseif ($action == 'setcodemember') { + $result = dolibarr_set_const($db, "MEMBER_CODEMEMBER_ADDON", $value, 'chaine', 0, '', $conf->entity); + if ($result <= 0) { + dol_print_error($db); + } +} elseif ($action == 'update' || $action == 'add') { + // Action to update or add a constant $constname = GETPOST('constname', 'alpha'); $constvalue = (GETPOST('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname) : GETPOST('constvalue')); @@ -223,6 +226,97 @@ $head = member_admin_prepare_head(); print dol_get_fiche_head($head, 'general', $langs->trans("Members"), -1, 'user'); +$dirModMember = array_merge(array('/core/modules/member/'), $conf->modules_parts['member']); +foreach ($conf->modules_parts['models'] as $mo) { + //Add more models + $dirModMember[] = $mo.'core/modules/member/'; +} + +// Module to manage customer/supplier code + +print load_fiche_titre($langs->trans("MemberCodeChecker"), '', ''); + +print '
'; +print ''."\n"; +print ''."\n"; +print ' '; +print ' '; +print ' '; +print ' '; +print ' '; +print "\n"; + +$arrayofmodules = array(); + +foreach ($dirModMember as $dirroot) { + $dir = dol_buildpath($dirroot, 0); + + $handle = @opendir($dir); + if (is_resource($handle)) { + // Loop on each module find in opened directory + while (($file = readdir($handle)) !== false) { + // module filename has to start with mod_member_ + if (substr($file, 0, 11) == 'mod_member_' && substr($file, -3) == 'php') { + $file = substr($file, 0, dol_strlen($file) - 4); + try { + dol_include_once($dirroot.$file.'.php'); + } catch (Exception $e) { + dol_syslog($e->getMessage(), LOG_ERR); + continue; + } + $modCodeMember = new $file; + // Show modules according to features level + if ($modCodeMember->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + continue; + } + if ($modCodeMember->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + continue; + } + + $arrayofmodules[$file] = $modCodeMember; + } + } + closedir($handle); + } +} + +$arrayofmodules = dol_sort_array($arrayofmodules, 'position'); + +foreach ($arrayofmodules as $file => $modCodeMember) { + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + + if (getDolGlobalString('MEMBER_CODEMEMBER_ADDON') == "$file") { + print '\n"; + } else { + $disabled = (isModEnabled('multicompany') && (is_object($mc) && !empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? true : false); + print ''; + } + + print ''; + + print ''; +} +print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
'.$modCodeMember->name.''.$modCodeMember->info($langs).''.$modCodeMember->getExample($langs).''."\n"; + print img_picto($langs->trans("Activated"), 'switch_on'); + print "'; + if (!$disabled) { + print ''; + } + print img_picto($langs->trans("Disabled"), 'switch_off'); + if (!$disabled) { + print ''; + } + print ''; + $s = $modCodeMember->getToolTip($langs, null, -1); + print $form->textwithpicto('', $s, 1); + print '
'; +print '
'; + +print "
"; + print '
'; print ''; print ''; diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index 08e9f617750..14379166247 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -178,7 +178,7 @@ if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) { //print $langs->trans('FollowingLinksArePublic').'
'; print img_picto('', 'globe').' '.$langs->trans('BlankSubscriptionForm').'
'; if (isModEnabled('multicompany')) { - $entity_qr = '?entity='.$conf->entity; + $entity_qr = '?entity='.((int) $conf->entity); } else { $entity_qr = ''; } diff --git a/htdocs/adherents/agenda.php b/htdocs/adherents/agenda.php index e13211fb239..918eaa5d27e 100644 --- a/htdocs/adherents/agenda.php +++ b/htdocs/adherents/agenda.php @@ -64,7 +64,7 @@ if (GETPOST('actioncode', 'array')) { $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)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } $search_agenda_label = GETPOST('search_agenda_label'); diff --git a/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php b/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php index c79143ab345..b6f0489108a 100644 --- a/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php +++ b/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php @@ -112,34 +112,9 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon $this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1); } else { // Confirm delete contact - if ($action == 'delete' && $user->rights->adherent->supprimer) { + if ($action == 'delete' && $user->hasRight('adherent', 'supprimer')) { $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteAdherent"), $langs->trans("ConfirmDeleteAdherent"), "confirm_delete", '', 0, 1); } } - - if ($action == 'list') { - $this->LoadListDatas($limit, $offset, $sortfield, $sortorder); - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Fetch datas list and save into ->list_datas - * - * @param int $limit Limit number of responses - * @param int $offset Offset for first response - * @param string $sortfield Sort field - * @param string $sortorder Sort order ('ASC' or 'DESC') - * @return void - */ - public function LoadListDatas($limit, $offset, $sortfield, $sortorder) - { - // phpcs:enable - global $conf, $langs; - - //$this->getFieldList(); - - $this->list_datas = array(); } } diff --git a/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php b/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php index 14da758457f..1ad9e4ff3d4 100644 --- a/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php +++ b/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php @@ -128,12 +128,12 @@ if (empty($user->socid)) { echo ''.$langs->trans('Modify').''; } - if (!$this->control->tpl['user_id'] && $user->rights->user->user->creer) { + if (!$this->control->tpl['user_id'] && $user->hasRight('user', 'user', 'creer')) { echo ''.$langs->trans("CreateDolibarrLogin").''; } - if ($user->rights->adherent->supprimer) { - print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$this->control->tpl['id'].'&action=delete&token='.newToken().'&canvas='.$canvas, 'delete', $user->rights->adherent->supprimer); + if ($user->hasRight('adherent', 'supprimer')) { + print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$this->control->tpl['id'].'&action=delete&token='.newToken().'&canvas='.$canvas, 'delete', $user->hasRight('adherent', 'supprimer')); } echo '
'; diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 56e7868ec5a..f72682ce22a 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -6,7 +6,7 @@ * Copyright (C) 2012 Marcos García * Copyright (C) 2012-2020 Philippe Grand * Copyright (C) 2015-2018 Alexandre Spangaro - * Copyright (C) 2018-2021 Frédéric France + * Copyright (C) 2018-2022 Frédéric France * Copyright (C) 2021 Waël Almoman * * This program is free software; you can redistribute it and/or modify @@ -305,23 +305,23 @@ if (empty($reshook)) { $object->phone = trim(GETPOST("phone", 'alpha')); $object->phone_perso = trim(GETPOST("phone_perso", 'alpha')); $object->phone_mobile = trim(GETPOST("phone_mobile", 'alpha')); - $object->email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha')); - $object->url = trim(GETPOST('member_url', 'custom', 0, FILTER_SANITIZE_URL)); + $object->email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha')); + $object->url = trim(GETPOST('member_url', 'custom', 0, FILTER_SANITIZE_URL)); $object->socialnetworks = array(); foreach ($socialnetworks as $key => $value) { if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { $object->socialnetworks[$key] = trim(GETPOST($key, 'alphanohtml')); } } - //$object->skype = trim(GETPOST("skype", 'alpha')); - //$object->twitter = trim(GETPOST("twitter", 'alpha')); - //$object->facebook = trim(GETPOST("facebook", 'alpha')); - //$object->linkedin = trim(GETPOST("linkedin", 'alpha')); - $object->birth = $birthdate; + //$object->skype = trim(GETPOST("skype", 'alpha')); + //$object->twitter = trim(GETPOST("twitter", 'alpha')); + //$object->facebook = trim(GETPOST("facebook", 'alpha')); + //$object->linkedin = trim(GETPOST("linkedin", 'alpha')); + $object->birth = $birthdate; $object->default_lang = GETPOST('default_lang', 'alpha'); - $object->typeid = GETPOST("typeid", 'int'); - //$object->note = trim(GETPOST("comment","alpha")); - $object->morphy = GETPOST("morphy", 'alpha'); + $object->typeid = GETPOST("typeid", 'int'); + //$object->note = trim(GETPOST("comment","alpha")); + $object->morphy = GETPOST("morphy", 'alpha'); if (GETPOST('deletephoto', 'alpha')) { $object->photo = ''; @@ -330,8 +330,8 @@ if (empty($reshook)) { } // Get status and public property - $object->statut = GETPOST("statut", 'alpha'); - $object->public = GETPOST("public", 'alpha'); + $object->statut = GETPOST("statut", 'alpha'); + $object->public = GETPOST("public", 'alpha'); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); @@ -342,7 +342,7 @@ if (empty($reshook)) { // Check if we need to also synchronize user information $nosyncuser = 0; if ($object->user_id) { // If linked to a user - if ($user->id != $object->user_id && empty($user->rights->user->user->creer)) { + if ($user->id != $object->user_id && !$user->hasRight('user', 'user', 'creer')) { $nosyncuser = 1; // Disable synchronizing } } @@ -350,7 +350,7 @@ if (empty($reshook)) { // Check if we need to also synchronize password information $nosyncuserpass = 0; if ($object->user_id) { // If linked to a user - if ($user->id != $object->user_id && empty($user->rights->user->user->password)) { + if ($user->id != $object->user_id && !$user->hasRight('user', 'user', 'password')) { $nosyncuserpass = 1; // Disable synchronizing } } @@ -454,7 +454,7 @@ if (empty($reshook)) { // $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)); + $url = trim(GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL)); $login = GETPOST("member_login", 'alphanohtml'); $pass = GETPOST("password", 'none'); // For password, we use 'none' $photo = GETPOST("photo", 'alphanohtml'); @@ -565,7 +565,7 @@ if (empty($reshook)) { } if (!empty($object->url) && !isValidUrl($object->url)) { $langs->load("errors"); - setEventMessages('', $langs->trans("ErrorBadUrl", $object->url), 'errors'); + setEventMessages($langs->trans("ErrorBadUrl", $object->url), null, 'errors'); } $public = 0; if (isset($public)) { @@ -659,7 +659,7 @@ if (empty($reshook)) { $outputlangs->loadLangs(array("main", "members", "companies", "install", "other")); // Get email content from template $arraydefaultmessage = null; - $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION; + $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION'); if (!empty($labeltouse)) { $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); @@ -731,7 +731,7 @@ if (empty($reshook)) { $outputlangs->loadLangs(array("main", "members", "companies", "install", "other")); // Get email content from template $arraydefaultmessage = null; - $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_CANCELATION; + $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_CANCELATION'); if (!empty($labeltouse)) { $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); @@ -802,7 +802,7 @@ if (empty($reshook)) { $outputlangs->loadLangs(array("main", "members", "companies", "install", "other")); // Get email content from template $arraydefaultmessage = null; - $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_EXCLUSION; + $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_EXCLUSION'); if (!empty($labeltouse)) { $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); @@ -1046,7 +1046,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Website print ''.$form->editfieldkey('Web', 'member_url', GETPOST('member_url', 'alpha'), $object, 0).''; - print ''.img_picto('', 'globe').' '; + print ''.img_picto('', 'globe').' '; // Address print ''.$langs->trans("Address").''; @@ -1524,7 +1524,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { $subject = $arraydefaultmessage->topic; - $msg = $arraydefaultmessage->content; + $msg = $arraydefaultmessage->content; } $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); @@ -1533,10 +1533,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs); $tmp = $langs->trans("SendingAnEMailToMember"); - $tmp .= '
'.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.', '; + $tmp .= '
'.$langs->trans("MailFrom").': '.getDolGlobalString('ADHERENT_MAIL_FROM').', '; $tmp .= '
'.$langs->trans("MailRecipient").': '.$object->email.''; $helpcontent = ''; - $helpcontent .= ''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.'
'."\n"; + $helpcontent .= ''.$langs->trans("MailFrom").': '.getDolGlobalString('ADHERENT_MAIL_FROM').'
'."\n"; $helpcontent .= ''.$langs->trans("MailRecipient").': '.$object->email.'
'."\n"; $helpcontent .= ''.$langs->trans("Subject").':
'."\n"; $helpcontent .= $subjecttosend."\n"; @@ -1596,10 +1596,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnResiliate()), $substitutionarray, $outputlangs); $tmp = $langs->trans("SendingAnEMailToMember"); - $tmp .= '
('.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.', '; + $tmp .= '
('.$langs->trans("MailFrom").': '.getDolGlobalString('ADHERENT_MAIL_FROM').', '; $tmp .= $langs->trans("MailRecipient").': '.$object->email.')'; $helpcontent = ''; - $helpcontent .= ''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.'
'."\n"; + $helpcontent .= ''.$langs->trans("MailFrom").': '.getDolGlobalString('ADHERENT_MAIL_FROM').'
'."\n"; $helpcontent .= ''.$langs->trans("MailRecipient").': '.$object->email.'
'."\n"; $helpcontent .= ''.$langs->trans("Subject").':
'."\n"; $helpcontent .= $subjecttosend."\n"; @@ -1639,7 +1639,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $outputlangs->loadLangs(array("main", "members")); // Get email content from template $arraydefaultmessage = null; - $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_EXCLUSION; + $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_EXCLUSION'); if (!empty($labeltouse)) { $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); @@ -1656,10 +1656,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnExclude()), $substitutionarray, $outputlangs); $tmp = $langs->trans("SendingAnEMailToMember"); - $tmp .= '
('.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.', '; + $tmp .= '
('.$langs->trans("MailFrom").': '.getDolGlobalString('ADHERENT_MAIL_FROM').', '; $tmp .= $langs->trans("MailRecipient").': '.$object->email.')'; $helpcontent = ''; - $helpcontent .= ''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.'
'."\n"; + $helpcontent .= ''.$langs->trans("MailFrom").': '.getDolGlobalString('ADHERENT_MAIL_FROM').'
'."\n"; $helpcontent .= ''.$langs->trans("MailRecipient").': '.$object->email.'
'."\n"; $helpcontent .= ''.$langs->trans("Subject").':
'."\n"; $helpcontent .= $subjecttosend."\n"; diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php index e9eb00d23f7..5eb3403b825 100644 --- a/htdocs/adherents/cartes/carte.php +++ b/htdocs/adherents/cartes/carte.php @@ -307,7 +307,7 @@ foreach (array_keys($_Avery_Labels) as $codecards) { } asort($arrayoflabels); print $form->selectarray('model', $arrayoflabels, (GETPOST('model') ?GETPOST('model') : (empty($conf->global->ADHERENT_CARD_TYPE) ? '' : $conf->global->ADHERENT_CARD_TYPE)), 1, 0, 0, '', 0, 0, 0, '', '', 1); -print '
'.$langs->trans("Login").': '; +print '
'.$langs->trans("Login").': '; print '
'; print ''; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 4c68b3e91ec..6da25c8ef01 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -92,6 +92,7 @@ class Adherent extends CommonObject /** * @var string company name * @deprecated + * @see $company */ public $societe; @@ -102,8 +103,14 @@ class Adherent extends CommonObject /** * @var int Thirdparty ID + * @deprecated + * @see $socid */ public $fk_soc; + + /** + * @var int socid + */ public $socid; /** @@ -154,24 +161,28 @@ class Adherent extends CommonObject /** * @var string skype account * @deprecated + * @see $socialnetworks */ public $skype; /** * @var string twitter account * @deprecated + * @see $socialnetworks */ public $twitter; /** * @var string facebook account * @deprecated + * @see $socialnetworks */ public $facebook; /** * @var string linkedin account * @deprecated + * @see $socialnetworks */ public $linkedin; @@ -259,10 +270,19 @@ class Adherent extends CommonObject */ public $type; + /** + * @var int need_subscription + */ public $need_subscription; + /** + * @var int user_id + */ public $user_id; + /** + * @var string user_login + */ public $user_login; public $datefin; @@ -425,8 +445,8 @@ class Adherent extends CommonObject // Envoi mail confirmation $from = $conf->email_from; - if (!empty($conf->global->ADHERENT_MAIL_FROM)) { - $from = $conf->global->ADHERENT_MAIL_FROM; + if (!empty(getDolGlobalString('ADHERENT_MAIL_FROM'))) { + $from = getDolGlobalString('ADHERENT_MAIL_FROM'); } $trackid = 'mem'.$this->id; @@ -576,7 +596,7 @@ class Adherent extends CommonObject */ public function create($user, $notrigger = 0) { - global $conf, $langs; + global $conf, $langs, $mysoc; $error = 0; @@ -624,7 +644,22 @@ class Adherent extends CommonObject $id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent"); if ($id > 0) { $this->id = $id; - $this->ref = (string) $id; + if (getDolGlobalString('MEMBER_CODEMEMBER_ADDON') == '') { + // keep old numbering + $this->ref = (string) $id; + } else { + // auto code + $modfile = dol_buildpath('core/modules/member/'.getDolGlobalString('MEMBER_CODEMEMBER_ADDON').'.php', 0); + try { + require_once $modfile; + $modname = getDolGlobalString('MEMBER_CODEMEMBER_ADDON'); + $modCodeMember = new $modname; + $this->ref = $modCodeMember->getNextValue($mysoc, $this); + } catch (Exception $e) { + dol_syslog($e->getMessage(), LOG_ERR); + $error++; + } + } // Update minor fields $result = $this->update($user, 1, 1, 0, 0, 'add'); // nosync is 1 to avoid update data of user @@ -1505,7 +1540,7 @@ class Adherent extends CommonObject require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; - $sql = "SELECT c.rowid, c.fk_adherent, c.fk_type, c.subscription, c.note, c.fk_bank,"; + $sql = "SELECT c.rowid, c.fk_adherent, c.fk_type, c.subscription, c.note as note_public, c.fk_bank,"; $sql .= " c.tms as datem,"; $sql .= " c.datec as datec,"; $sql .= " c.dateadh as dateh,"; @@ -1537,7 +1572,8 @@ class Adherent extends CommonObject $subscription->fk_adherent = $obj->fk_adherent; $subscription->fk_type = $obj->fk_type; $subscription->amount = $obj->subscription; - $subscription->note = $obj->note; + $subscription->note = $obj->note_public; + $subscription->note_public = $obj->note_public; $subscription->fk_bank = $obj->fk_bank; $subscription->datem = $this->db->jdate($obj->datem); $subscription->datec = $this->db->jdate($obj->datec); @@ -2871,8 +2907,8 @@ class Adherent extends CommonObject * Adds it to non existing supplied categories. * Existing categories are left untouch. * - * @param int[]|int $categories Category or categories IDs - * @return void + * @param int[]|int $categories Category or categories IDs + * @return int <0 if KO, >0 if OK */ public function setCategories($categories) { @@ -3015,7 +3051,7 @@ class Adherent extends CommonObject $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); - $from = $conf->global->ADHERENT_MAIL_FROM; + $from = getDolGlobalString('ADHERENT_MAIL_FROM'); $to = $adherent->email; $trackid = 'mem'.$adherent->id; diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 6ab65697745..0a4663f8149 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -472,7 +472,7 @@ class AdherentType extends CommonObject } /** - * Function that retrieves the status of the member + * Function that retrieves the properties of a membership type * * @param int $rowid Id of member type to load * @return int <0 if KO, >0 if OK @@ -927,4 +927,46 @@ class AdherentType extends CommonObject return ''; } + + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $langs,$user; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + if ($user->rights->adherent->configurer) { + $return .= 'ref.'">'.img_edit().''; + } else { + $return .= ' '; + } + if (property_exists($this, 'vote')) { + $return .= '
'.$langs->trans("VoteAllowed").' : '.yn($this->vote).''; + } + if (property_exists($this, 'amount')) { + if (is_null($this->amount) || $this->amount === '') { + $return .= '
'; + } else { + $return .= '
'.$langs->trans("Amount").''; + $return .= ' : '.price($this->amount).''; + } + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 9aa2fe2e8ad..72db71d07bd 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -55,7 +55,7 @@ class AdherentStats extends Stats */ public function __construct($db, $socid = 0, $userid = 0) { - global $user, $conf; + global $conf; $this->db = $db; $this->socid = $socid; @@ -87,8 +87,6 @@ class AdherentStats extends Stats */ public function getNbByMonth($year, $format = 0) { - global $user; - $sql = "SELECT date_format(p.dateadh,'%m') as dm, count(*)"; $sql .= " FROM ".$this->from; //if (empty($user->rights->societe->client->voir) && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -107,8 +105,6 @@ class AdherentStats extends Stats */ public function getNbByYear() { - global $user; - $sql = "SELECT date_format(p.dateadh,'%Y') as dm, count(*)"; $sql .= " FROM ".$this->from; //if (empty($user->rights->societe->client->voir) && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -128,8 +124,6 @@ class AdherentStats extends Stats */ public function getAmountByMonth($year, $format = 0) { - global $user; - $sql = "SELECT date_format(p.dateadh,'%m') as dm, sum(p.".$this->field.")"; $sql .= " FROM ".$this->from; //if (empty($user->rights->societe->client->voir) && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -149,8 +143,6 @@ class AdherentStats extends Stats */ public function getAverageByMonth($year) { - global $user; - $sql = "SELECT date_format(p.dateadh,'%m') as dm, avg(p.".$this->field.")"; $sql .= " FROM ".$this->from; //if (empty($user->rights->societe->client->voir) && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -170,8 +162,6 @@ class AdherentStats extends Stats */ public function getAllByYear() { - global $user; - $sql = "SELECT date_format(p.dateadh,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; $sql .= " FROM ".$this->from; //if (empty($user->rights->societe->client->voir) && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 51ef1153a57..1e1f8db1bbf 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -62,7 +62,7 @@ class Members extends DolibarrApi */ public function get($id) { - if (!DolibarrApiAccess::$user->rights->adherent->lire) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) { throw new RestException(401); } @@ -99,7 +99,7 @@ class Members extends DolibarrApi */ public function getByThirdparty($thirdparty) { - if (!DolibarrApiAccess::$user->rights->adherent->lire) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) { throw new RestException(401); } @@ -132,7 +132,7 @@ class Members extends DolibarrApi */ public function getByThirdpartyEmail($email) { - if (!DolibarrApiAccess::$user->rights->adherent->lire) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) { throw new RestException(401); } @@ -171,7 +171,7 @@ class Members extends DolibarrApi */ public function getByThirdpartyBarcode($barcode) { - if (!DolibarrApiAccess::$user->rights->adherent->lire) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) { throw new RestException(401); } @@ -217,7 +217,7 @@ class Members extends DolibarrApi $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->adherent->lire) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) { throw new RestException(401); } @@ -370,7 +370,7 @@ class Members extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->adherent->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'supprimer')) { throw new RestException(401); } $member = new Adherent($this->db); @@ -464,7 +464,7 @@ class Members extends DolibarrApi { $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'cotisation', 'lire')) { throw new RestException(401); } @@ -495,7 +495,7 @@ class Members extends DolibarrApi */ public function createSubscription($id, $start_date, $end_date, $amount, $label = '') { - if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'cotisation', 'creer')) { throw new RestException(401); } diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index 95c514bfedf..e7c039d1038 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -55,7 +55,7 @@ class MembersTypes extends DolibarrApi */ public function get($id) { - if (!DolibarrApiAccess::$user->rights->adherent->lire) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) { throw new RestException(401); } @@ -92,7 +92,7 @@ class MembersTypes extends DolibarrApi $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->adherent->lire) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) { throw new RestException(401); } @@ -151,7 +151,7 @@ class MembersTypes extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->adherent->configurer) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'configurer')) { throw new RestException(401); } // Check mandatory fields @@ -176,7 +176,7 @@ class MembersTypes extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->adherent->configurer) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'configurer')) { throw new RestException(401); } @@ -216,7 +216,7 @@ class MembersTypes extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->adherent->configurer) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'configurer')) { throw new RestException(401); } $membertype = new AdherentType($this->db); diff --git a/htdocs/adherents/class/api_subscriptions.class.php b/htdocs/adherents/class/api_subscriptions.class.php index 67484a723fd..dd01ca94027 100644 --- a/htdocs/adherents/class/api_subscriptions.class.php +++ b/htdocs/adherents/class/api_subscriptions.class.php @@ -58,7 +58,7 @@ class Subscriptions extends DolibarrApi */ public function get($id) { - if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'cotisation', 'lire')) { throw new RestException(401); } @@ -91,7 +91,7 @@ class Subscriptions extends DolibarrApi $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'cotisation', 'lire')) { throw new RestException(401); } @@ -148,7 +148,7 @@ class Subscriptions extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'cotisation', 'creer')) { throw new RestException(401); } // Check mandatory fields @@ -206,7 +206,7 @@ class Subscriptions extends DolibarrApi public function delete($id) { // The right to delete a subscription comes with the right to create one. - if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'cotisation', 'creer')) { throw new RestException(401); } $subscription = new Subscription($this->db); diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index b3cfe027197..12e19fd9c3a 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -505,4 +505,36 @@ class Subscription extends CommonObject dol_print_error($this->db); } } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + + $return .= '
'; + $return .= ''.(property_exists($this, 'fk_adherent')? $this->fk_adherent: $this->ref ).''; + if (property_exists($this, 'dateh') || property_exists($this, 'datef')) { + $return .= '
'.dol_print_date($this->dateh, 'day').' - '.dol_print_date($this->datef, 'day').''; + } + + if (property_exists($this, 'fk_bank')) { + $return .= '
'.$this->fk_bank.''; + } + if (property_exists($this, 'amount')) { + $return .= '
'.price($this->amount).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php index 4517bee15c6..d3aa8cc2211 100644 --- a/htdocs/adherents/document.php +++ b/htdocs/adherents/document.php @@ -80,7 +80,7 @@ if ($id > 0 || !empty($ref)) { // Define variables to know what current user can do on properties of user linked to edited member if ($object->user_id) { // $User is the user who edits, $object->user_id is the id of the related user in the edited member - $caneditfielduser = ((($user->id == $object->user_id) && $$user->hasRight('user', 'self', 'creer')) + $caneditfielduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'creer')) || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'creer'))); $caneditpassworduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'password')) || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'password'))); diff --git a/htdocs/adherents/htpasswd.php b/htdocs/adherents/htpasswd.php index a97a0a74d28..a36f8092add 100644 --- a/htdocs/adherents/htpasswd.php +++ b/htdocs/adherents/htpasswd.php @@ -37,7 +37,7 @@ $sortorder = GETPOST('sortorder', 'aZ09'); if (!isModEnabled('adherent')) { accessforbidden(); } -if (empty($user->rights->adherent->export)) { +if (!$user->hasRight('adherent', 'export')) { accessforbidden(); } diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php index 7f09bccb3d3..83b7e5f3764 100644 --- a/htdocs/adherents/ldap.php +++ b/htdocs/adherents/ldap.php @@ -51,14 +51,14 @@ if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); // Define variables to know what current user can do on users - $canadduser = (!empty($user->admin) || !empty($user->rights->user->user->creer)); + $canadduser = (!empty($user->admin) || $user->hasRight('user', 'user', 'creer')); // Define variables to know what current user can do on properties of user linked to edited member if ($object->user_id) { // $User is the user who edits, $object->user_id is the id of the related user in the edited member $caneditfielduser = ((($user->id == $object->user_id) && !empty($user->rights->user->self->creer)) - || (($user->id != $object->user_id) && !empty($user->rights->user->user->creer))); + || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'creer'))); $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password) - || (($user->id != $object->user_id) && !empty($user->rights->user->user->password))); + || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'password'))); } } diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index c2b81860210..50bbbca42d7 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -126,7 +126,6 @@ $fieldstosearchall = array( 'd.login'=>'Login', 'd.lastname'=>'Lastname', 'd.firstname'=>'Firstname', - 'd.login'=>'Login', 'd.societe'=>"Company", 'd.email'=>'EMail', 'd.address'=>'Address', @@ -262,7 +261,7 @@ if (empty($reshook)) { } // Create external user - if ($massaction == 'createexternaluser' && $user->hasRight('adherent', 'creer') && $user->rights->user->user->creer) { + if ($massaction == 'createexternaluser' && $user->hasRight('adherent', 'creer') && $user->hasRight('user', 'user', 'creer')) { $tmpmember = new Adherent($db); $error = 0; $nbcreated = 0; @@ -836,14 +835,14 @@ if (!empty($arrayfields['d.tms']['checked'])) { } // Status if (!empty($arrayfields['d.statut']['checked'])) { - print ''; + print ''; $liststatus = array( Adherent::STATUS_DRAFT => $langs->trans("Draft"), Adherent::STATUS_VALIDATED => $langs->trans("Validated"), Adherent::STATUS_RESILIATED => $langs->trans("MemberStatusResiliatedShort"), Adherent::STATUS_EXCLUDED =>$langs->trans("MemberStatusExcludedShort") ); - print $form->selectarray('search_status', $liststatus, $search_status, -3, 0, 0, '', 0, 0, 0, '', 'onrightofpage'); + print $form->selectarray('search_status', $liststatus, $search_status, -3, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage'); print ''; } if (!empty($arrayfields['d.import_key']['checked'])) { diff --git a/htdocs/adherents/partnership.php b/htdocs/adherents/partnership.php index 805a3137226..3664187b34e 100644 --- a/htdocs/adherents/partnership.php +++ b/htdocs/adherents/partnership.php @@ -76,13 +76,13 @@ foreach ($object->fields as $key => $val) { // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. -$permissiontoread = $user->rights->partnership->read; -$permissiontoadd = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = $user->rights->partnership->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); -$permissionnote = $user->rights->partnership->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->partnership->write; // Used by the include of actions_dellink.inc.php -$usercanclose = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1]; +$permissiontoread = $user->hasRight('partnership', 'read'); +$permissiontoadd = $user->hasRight('partnership', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->hasRight('partnership', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); +$permissionnote = $user->hasRight('partnership', 'write'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('partnership', 'write'); // Used by the include of actions_dellink.inc.php +$usercanclose = $user->hasRight('partnership', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1]; if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') != 'member') { diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 93b57a630e1..8c423d53029 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -151,9 +151,9 @@ if (empty($reshook) && $action == 'confirm_create_thirdparty' && $confirm == 'ye } } -if (empty($reshook) && $action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) { +if (empty($reshook) && $action == 'setuserid' && ($user->rights->user->self->creer || $user->hasRight('user', 'user', 'creer'))) { $error = 0; - if (empty($user->rights->user->user->creer)) { // If can edit only itself user, we can link to itself only + if (!$user->hasRight('user', 'user', 'creer')) { // If can edit only itself user, we can link to itself only if (GETPOST("userid", 'int') != $user->id && GETPOST("userid", 'int') != $object->user_id) { $error++; setEventMessages($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), null, 'errors'); @@ -201,7 +201,7 @@ if (empty($reshook) && $action == 'setsocid') { } } -if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !$cancel) { +if ($user->hasRight('adherent', 'cotisation', 'creer') && $action == 'subscription' && !$cancel) { $error = 0; $langs->load("banks"); @@ -674,7 +674,7 @@ if ($rowid > 0) { */ // Button to create a new subscription if member no draft (-1) neither resiliated (0) neither excluded (-2) - if ($user->rights->adherent->cotisation->creer) { + if ($user->hasRight('adherent', 'cotisation', 'creer')) { if ($action != 'addsubscription' && $action != 'create_thirdparty') { print '
'; @@ -814,7 +814,7 @@ if ($rowid > 0) { /* * Add new subscription form */ - if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->rights->adherent->cotisation->creer) { + if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->hasRight('adherent', 'cotisation', 'creer')) { print '
'; print load_fiche_titre($langs->trans("NewCotisation")); @@ -1142,7 +1142,7 @@ if ($rowid > 0) { $tmp = 'global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? ' checked' : '')).'>'; $helpcontent = ''; - $helpcontent .= ''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.'
'."\n"; + $helpcontent .= ''.$langs->trans("MailFrom").': '.getDolGlobalString('ADHERENT_MAIL_FROM').'
'."\n"; $helpcontent .= ''.$langs->trans("MailRecipient").': '.$object->email.'
'."\n"; $helpcontent .= ''.$langs->trans("MailTopic").':
'."\n"; if ($subjecttosend) { diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index 83f1a01441c..ea47ffc9362 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -49,13 +49,13 @@ $note = GETPOST('note', 'alpha'); $typeid = (int) GETPOST('typeid', 'int'); $amount = price2num(GETPOST('amount', 'alpha'), 'MT'); -if (empty($user->rights->adherent->cotisation->lire)) { +if (!$user->hasRight('adherent', 'cotisation', 'lire')) { accessforbidden(); } -$permissionnote = $user->rights->adherent->cotisation->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->adherent->cotisation->creer; // Used by the include of actions_dellink.inc.php -$permissiontoedit = $user->rights->adherent->cotisation->creer; // Used by the include of actions_lineupdonw.inc.php +$permissionnote = $user->hasRight('adherent', 'cotisation', 'creer'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('adherent', 'cotisation', 'creer'); // Used by the include of actions_dellink.inc.php +$permissiontoedit = $user->hasRight('adherent', 'cotisation', 'creer'); // Used by the include of actions_lineupdonw.inc.php $hookmanager->initHooks(array('subscriptioncard', 'globalcard')); @@ -78,7 +78,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, n //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once -if ($user->rights->adherent->cotisation->creer && $action == 'update' && !$cancel) { +if ($user->hasRight('adherent', 'cotisation', 'creer') && $action == 'update' && !$cancel) { // Load current object $result = $object->fetch($rowid); if ($result > 0) { @@ -109,8 +109,9 @@ if ($user->rights->adherent->cotisation->creer && $action == 'update' && !$cance $object->dateh = dol_mktime(GETPOST('datesubhour', 'int'), GETPOST('datesubmin', 'int'), 0, GETPOST('datesubmonth', 'int'), GETPOST('datesubday', 'int'), GETPOST('datesubyear', 'int')); $object->datef = dol_mktime(GETPOST('datesubendhour', 'int'), GETPOST('datesubendmin', 'int'), 0, GETPOST('datesubendmonth', 'int'), GETPOST('datesubendday', 'int'), GETPOST('datesubendyear', 'int')); $object->fk_type = $typeid; - $object->note = $note; + $object->note_public = $note; $object->note_private = $note; + $object->amount = $amount; $result = $object->update($user); @@ -140,7 +141,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'update' && !$cance } } -if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->adherent->cotisation->creer) { +if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('adherent', 'cotisation', 'creer')) { $result = $object->fetch($rowid); $result = $object->delete($user); if ($result > 0) { @@ -166,7 +167,7 @@ llxHeader('', $langs->trans("SubscriptionCard"), $help_url); dol_htmloutput_errors($errmsg); -if ($user->rights->adherent->cotisation->creer && $action == 'edit') { +if ($user->hasRight('adherent', 'cotisation', 'creer') && $action == 'edit') { /******************************************** * * Subscription card in edit mode @@ -350,7 +351,7 @@ if ($rowid && $action != 'edit') { */ print '
'; - if ($user->rights->adherent->cotisation->creer) { + if ($user->hasRight('adherent', 'cotisation', 'creer')) { if (!empty($bankline->rappro)) { print '"; } else { @@ -359,7 +360,7 @@ if ($rowid && $action != 'edit') { } // Delete - if ($user->rights->adherent->cotisation->creer) { + if ($user->hasRight('adherent', 'cotisation', 'creer')) { print '\n"; } diff --git a/htdocs/adherents/subscription/info.php b/htdocs/adherents/subscription/info.php index 5faf1d31760..14afbafca50 100644 --- a/htdocs/adherents/subscription/info.php +++ b/htdocs/adherents/subscription/info.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; // Load translation files required by the page $langs->loadLangs(array("companies", "members", "bills", "users")); -if (empty($user->rights->adherent->lire)) { +if (!$user->hasRight('adherent', 'lire')) { accessforbidden(); } diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 1523bd4ee90..3c17fc64852 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -37,6 +37,8 @@ $massaction = GETPOST('massaction', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'subscriptionlist'; // To manage different context of search +$mode = GETPOST('mode', 'alpha'); + $statut = (GETPOSTISSET("statut") ?GETPOST("statut", "alpha") : 1); $search_ref = GETPOST('search_ref', 'alpha'); @@ -242,17 +244,20 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ exit; } -$help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; -llxHeader('', $langs->trans("ListOfSubscriptions"), $help_url); - -$i = 0; - -$title = $langs->trans("ListOfSubscriptions"); +$title = $langs->trans("Subscriptions"); if (!empty($date_select)) { $title .= ' ('.$langs->trans("Year").' '.$date_select.')'; } +$help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; +llxHeader('', $title, $help_url); + +$i = 0; + $param = ''; +if (!empty($mode)) { + $param .='&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -291,14 +296,17 @@ $arrayofmassactions = array( //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), ); -//if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); +//if ($user->hasRight('adherent', 'supprimer')) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); if (in_array($massaction, array('presend', 'predelete'))) { $arrayofmassactions = array(); } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $newcardbutton = ''; -if ($user->rights->adherent->cotisation->creer) { +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); + +if ($user->hasRight('adherent', 'cotisation', 'creer')) { $newcardbutton .= dolGetButtonTitle($langs->trans('NewSubscription'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/list.php?status=-1,1'); } @@ -313,6 +321,8 @@ print ''; print ''; print ''; print ''; +print ''; + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $subscription->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -507,143 +517,166 @@ while ($i < min($num, $limit)) { $adherent->need_subscription = $adht->subscription; - print ''; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + print '
'; + } - // Ref - if (!empty($arrayfields['d.ref']['checked'])) { - print ''.$subscription->getNomUrl(1).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Type - if (!empty($arrayfields['d.fk_type']['checked'])) { - print ''; - if ($typeid > 0) { - print $adht->getNomUrl(1); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Lastname - if (!empty($arrayfields['d.lastname']['checked'])) { - print ''.$adherent->getNomUrl(-1, 0, 'card', 'lastname').''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Firstname - if (!empty($arrayfields['d.firstname']['checked'])) { - print ''.$adherent->firstname.''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Login - if (!empty($arrayfields['d.login']['checked'])) { - print ''.$adherent->login.''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Label - if (!empty($arrayfields['t.libelle']['checked'])) { - print ''; - print $obj->note; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Banque - if (!empty($arrayfields['d.bank']['checked'])) { - print ''; + //fetch informations needs on this mode + $subscription->fk_adherent = $adherent->getNomUrl(1); + $subscription->fk_type = $adht->getNomUrl(1); + $subscription->amount = $obj->subscription; if ($obj->fk_account > 0) { $accountstatic->id = $obj->fk_account; $accountstatic->fetch($obj->fk_account); - //$accountstatic->label=$obj->label; - print $accountstatic->getNomUrl(1); + $subscription->fk_bank = $accountstatic->getNomUrl(1); } - print "\n"; - if (!$i) { - $totalarray['nbfield']++; + // Output Kanban + print $subscription->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print '
'; + print ''; } - } + } else { + print ''; - // Date start - if (!empty($arrayfields['c.dateadh']['checked'])) { - print ''.dol_print_date($db->jdate($obj->dateadh), 'day')."\n"; - if (!$i) { - $totalarray['nbfield']++; + // Ref + if (!empty($arrayfields['d.ref']['checked'])) { + print ''.$subscription->getNomUrl(1).''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Date end - if (!empty($arrayfields['c.datef']['checked'])) { - print ''.dol_print_date($db->jdate($obj->datef), 'day')."\n"; - if (!$i) { - $totalarray['nbfield']++; + // Type + if (!empty($arrayfields['d.fk_type']['checked'])) { + print ''; + if ($typeid > 0) { + print $adht->getNomUrl(1); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Price - if (!empty($arrayfields['d.amount']['checked'])) { - print ''.price($obj->subscription).''; - if (!$i) { - $totalarray['nbfield']++; + + // Lastname + if (!empty($arrayfields['d.lastname']['checked'])) { + print ''.$adherent->getNomUrl(-1, 0, 'card', 'lastname').''; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'd.amount'; + // Firstname + if (!empty($arrayfields['d.firstname']['checked'])) { + print ''.$adherent->firstname.''; + if (!$i) { + $totalarray['nbfield']++; + } } - if (empty($totalarray['val']['d.amount'])) { - $totalarray['val']['d.amount'] = $obj->subscription; - } else { - $totalarray['val']['d.amount'] += $obj->subscription; + + // Login + if (!empty($arrayfields['d.login']['checked'])) { + print ''.$adherent->login.''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Label + if (!empty($arrayfields['t.libelle']['checked'])) { + print ''; + print $obj->note; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Banque + if (!empty($arrayfields['d.bank']['checked'])) { + print ''; + if ($obj->fk_account > 0) { + $accountstatic->id = $obj->fk_account; + $accountstatic->fetch($obj->fk_account); + //$accountstatic->label=$obj->label; + print $accountstatic->getNomUrl(1); + } + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date start + if (!empty($arrayfields['c.dateadh']['checked'])) { + print ''.dol_print_date($db->jdate($obj->dateadh), 'day')."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date end + if (!empty($arrayfields['c.datef']['checked'])) { + print ''.dol_print_date($db->jdate($obj->datef), 'day')."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Price + if (!empty($arrayfields['d.amount']['checked'])) { + print ''.price($obj->subscription).''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'd.amount'; + } + if (empty($totalarray['val']['d.amount'])) { + $totalarray['val']['d.amount'] = $obj->subscription; + } else { + $totalarray['val']['d.amount'] += $obj->subscription; + } + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['c.datec']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['c.tms']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Action 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($obj->crowid, $arrayofselected)) { + $selected = 1; + } + print ''; } - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['c.datec']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; if (!$i) { $totalarray['nbfield']++; } - } - // Date modification - if (!empty($arrayfields['c.tms']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Action 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($obj->crowid, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - print "\n"; + print "\n"; + } $i++; } diff --git a/htdocs/adherents/tpl/linkedobjectblock.tpl.php b/htdocs/adherents/tpl/linkedobjectblock.tpl.php index 5928b706a8e..d4efa349202 100644 --- a/htdocs/adherents/tpl/linkedobjectblock.tpl.php +++ b/htdocs/adherents/tpl/linkedobjectblock.tpl.php @@ -39,7 +39,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { echo ''; echo ''.dol_print_date($objectlink->dateh, 'day').''; echo ''; - if ($user->rights->adherent->lire) { + if ($user->hasRight('adherent', 'lire')) { $total = $total + $objectlink->amount; echo price($objectlink->amount); } diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 962624db428..f516efdd819 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -44,6 +44,7 @@ $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); +$mode = GETPOST('mode', 'alopha'); $sall = GETPOST("sall", "alpha"); $filter = GETPOST("filter", 'alpha'); @@ -171,7 +172,7 @@ if ($action == 'add' && $user->hasRight('adherent', 'configurer')) { } } -if ($action == 'update' && $user->rights->adherent->configurer) { +if ($action == 'update' && $user->hasRight('adherent', 'configurer')) { $object->fetch($rowid); $object->oldcopy = dol_clone($object); @@ -207,7 +208,7 @@ if ($action == 'update' && $user->rights->adherent->configurer) { exit; } -if ($action == 'confirm_delete' && !empty($user->rights->adherent->configurer)) { +if ($action == 'confirm_delete' && $user->hasRight('adherent', 'configurer')) { $object->fetch($rowid); $res = $object->delete(); @@ -249,6 +250,9 @@ if (!$rowid && $action != 'create' && $action != 'edit') { $i = 0; $param = ''; + if (!empty($mode)) { + $param .= '&mode'.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.$contextpage; } @@ -257,7 +261,11 @@ if (!$rowid && $action != 'create' && $action != 'edit') { } $newcardbutton = ''; - if ($user->rights->adherent->configurer) { + + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); + + if ($user->hasRight('adherent', 'configurer')) { $newcardbutton .= dolGetButtonTitle($langs->trans('NewMemberType'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/type.php?action=create'); } @@ -270,6 +278,8 @@ if (!$rowid && $action != 'create' && $action != 'edit') { print ''; print ''; print ''; + print ''; + print_barre_liste($langs->trans("MembersTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'members', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -292,7 +302,13 @@ if (!$rowid && $action != 'create' && $action != 'edit') { $membertype = new AdherentType($db); - while ($i < $num) { + $i = 0; + /*$savnbfield = $totalarray['nbfield']; + $totalarray = array(); + $totalarray['nbfield'] = 0;*/ + + $imaxinloop = ($limit ? min($num, $limit) : $num); + while ($i < $imaxinloop) { $objp = $db->fetch_object($result); $membertype->id = $objp->rowid; @@ -303,32 +319,46 @@ if (!$rowid && $action != 'create' && $action != 'edit') { $membertype->amount = $objp->amount; $membertype->caneditamount = $objp->caneditamount; - print ''; - print ''; - print $membertype->getNomUrl(1); - //'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.' - print ''; - print ''.dol_escape_htmltag($objp->label).''; - print ''; - if ($objp->morphy == 'phy') { - print $langs->trans("Physical"); - } elseif ($objp->morphy == 'mor') { - print $langs->trans("Moral"); + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + print '
'; + } + //output kanban + $membertype->label = $objp->label; + print $membertype->getKanbanView(''); + if ($i == ($imaxinloop - 1)) { + print '
'; + print ''; + } } else { - print $langs->trans("MorAndPhy"); + print ''; + print ''; + print $membertype->getNomUrl(1); + //'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.' + print ''; + print ''.dol_escape_htmltag($objp->label).''; + print ''; + if ($objp->morphy == 'phy') { + print $langs->trans("Physical"); + } elseif ($objp->morphy == 'mor') { + print $langs->trans("Moral"); + } else { + print $langs->trans("MorAndPhy"); + } + print ''; + print ''.yn($objp->subscription).''; + print ''.(is_null($objp->amount) || $objp->amount === '' ? '' : price($objp->amount)).''; + print ''.yn($objp->caneditamount).''; + print ''.yn($objp->vote).''; + print ''.$membertype->getLibStatut(5).''; + if ($user->rights->adherent->configurer) { + print 'rowid.'">'.img_edit().''; + } else { + print ' '; + } + print ""; } - print ''; - print ''.yn($objp->subscription).''; - print ''.(is_null($objp->amount) || $objp->amount === '' ? '' : price($objp->amount)).''; - print ''.yn($objp->caneditamount).''; - print ''.yn($objp->vote).''; - print ''.$membertype->getLibStatut(5).''; - if ($user->rights->adherent->configurer) { - print 'rowid.'">'.img_edit().''; - } else { - print ' '; - } - print ""; $i++; } diff --git a/htdocs/adherents/type_translation.php b/htdocs/adherents/type_translation.php index 9539250cb44..85b346b4225 100644 --- a/htdocs/adherents/type_translation.php +++ b/htdocs/adherents/type_translation.php @@ -71,7 +71,7 @@ if ($action == 'delete' && GETPOST('langtodelete', 'alpha')) { } // Add translation -if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && $user->rights->adherent->configurer) { +if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && $user->hasRight('adherent', 'configurer')) { $object = new AdherentType($db); $object->fetch($id); $current_lang = $langs->getDefaultLang(); @@ -99,7 +99,7 @@ if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && $user->rights->ad } // Edit translation -if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && $user->rights->adherent->configurer) { +if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && $user->hasRight('adherent', 'configurer')) { $object = new AdherentType($db); $object->fetch($id); $current_lang = $langs->getDefaultLang(); @@ -125,7 +125,7 @@ if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && $user->rights->a } // Delete translation -if ($action == 'vdelete' && $cancel != $langs->trans("Cancel") && $user->rights->adherent->configurer) { +if ($action == 'vdelete' && $cancel != $langs->trans("Cancel") && $user->hasRight('adherent', 'configurer')) { $object = new AdherentType($db); $object->fetch($id); $langtodelete = GETPOST('langdel', 'alpha'); diff --git a/htdocs/adherents/vcard.php b/htdocs/adherents/vcard.php index 1b5a0e5d0fe..618f2d50ffa 100644 --- a/htdocs/adherents/vcard.php +++ b/htdocs/adherents/vcard.php @@ -42,14 +42,14 @@ if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); // Define variables to know what current user can do on users - $canadduser = ($user->admin || $user->rights->user->user->creer); + $canadduser = ($user->admin || $user->hasRight('user', 'user', 'creer')); // Define variables to know what current user can do on properties of user linked to edited member if ($object->user_id) { // $User is the user who edits, $object->user_id is the id of the related user in the edited member - $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer) - || (($user->id != $object->user_id) && $user->rights->user->user->creer)); - $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password) - || (($user->id != $object->user_id) && $user->rights->user->user->password)); + $caneditfielduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'creer')) + || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'creer'))); + $caneditpassworduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'password')) + || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'password'))); } } @@ -122,18 +122,23 @@ if ($company->id) { } elseif (empty(trim($object->email))) { // when adherent e-mail is empty, use only company e-mail $v->setEmail($company->email); - } elseif (strtolower(end(explode("@", $object->email))) == strtolower(end(explode("@", $company->email)))) { - // when e-mail domain of adherent and company are the same, use adherent e-mail at first (and company e-mail at second) - $v->setEmail($object->email); - - // support by Microsoft Outlook (2019 and possible earlier) - $v->setEmail($company->email, 'INTERNET'); } else { - // when e-mail of adherent and company complete different use company e-mail at first (and adherent e-mail at second) - $v->setEmail($company->email); + $tmpobject = explode("@", trim($object->email)); + $tmpcompany = explode("@", trim($company->email)); - // support by Microsoft Outlook (2019 and possible earlier) - $v->setEmail($object->email, 'INTERNET'); + if (strtolower(end($tmpobject)) == strtolower(end($tmpcompany))) { + // when e-mail domain of adherent and company are the same, use adherent e-mail at first (and company e-mail at second) + $v->setEmail($object->email); + + // support by Microsoft Outlook (2019 and possible earlier) + $v->setEmail($company->email, 'INTERNET'); + } else { + // when e-mail of adherent and company complete different use company e-mail at first (and adherent e-mail at second) + $v->setEmail($company->email); + + // support by Microsoft Outlook (2019 and possible earlier) + $v->setEmail($object->email, 'INTERNET'); + } } // Si adherent lie a un tiers non de type "particulier" diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index 7b057a0693c..5003593905e 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -368,7 +368,7 @@ if (!is_array($result) && $result < 0) { } elseif (count($result) > 0) { $defval = reset($result)->value; } -$formactions->form_select_status_action('agenda', $defval, 1, "AGENDA_EVENT_DEFAULT_STATUS", 0, 1, 'maxwidth200'); +$formactions->form_select_status_action('agenda', $defval, 1, "AGENDA_EVENT_DEFAULT_STATUS", 0, 1, 'maxwidth200 onrightofpage'); print ''."\n"; // AGENDA_DEFAULT_FILTER_TYPE diff --git a/htdocs/admin/bom.php b/htdocs/admin/bom.php index a35aef780d2..57b4b5aad06 100644 --- a/htdocs/admin/bom.php +++ b/htdocs/admin/bom.php @@ -51,10 +51,10 @@ $type = 'bom'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstbom = GETPOST('maskconstBom', 'alpha'); + $maskconstbom = GETPOST('maskconstBom', 'aZ09'); $maskbom = GETPOST('maskBom', 'alpha'); - if ($maskconstbom) { + if ($maskconstbom && preg_match('/_MASK$/', $maskconstbom)) { $res = dolibarr_set_const($db, $maskconstbom, $maskbom, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index cf93155b814..77994debadb 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -54,9 +54,9 @@ if (empty($conf->global->CHEQUERECEIPTS_ADDON)) { */ if ($action == 'updateMask') { - $maskconstchequereceipts = GETPOST('maskconstchequereceipts', 'alpha'); + $maskconstchequereceipts = GETPOST('maskconstchequereceipts', 'aZ09'); $maskchequereceipts = GETPOST('maskchequereceipts', 'alpha'); - if ($maskconstchequereceipts) { + if ($maskconstchequereceipts && preg_match('/_MASK$/', $maskconstchequereceipts)) { $res = dolibarr_set_const($db, $maskconstchequereceipts, $maskchequereceipts, 'chaine', 0, '', $conf->entity); } @@ -211,7 +211,7 @@ foreach ($dirmodels as $reldir) { print ''; print $form->textwithpicto('', $htmltooltip, 1, 0); - if ($conf->global->CHEQUERECEIPTS_ADDON.'.php' == $file) { // If module is the one used, we show existing errors + if (getDolGlobalString('CHEQUERECEIPTS_ADDON').'.php' == $file) { // If module is the one used, we show existing errors if (!empty($module->error)) { dol_htmloutput_mesg($module->error, '', 'error', 1); } diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 34a5e281fac..79c42f6e2db 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -61,10 +61,10 @@ $type = 'order'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstorder = GETPOST('maskconstorder', 'alpha'); + $maskconstorder = GETPOST('maskconstorder', 'aZ09'); $maskorder = GETPOST('maskorder', 'alpha'); - if ($maskconstorder) { + if ($maskconstorder && preg_match('/_MASK$/', $maskconstorder)) { $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index 48247bf0b8e..c5a4d1a3463 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -58,9 +58,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; $error=0; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconstcontract', 'alpha'); + $maskconst = GETPOST('maskconstcontract', 'aZ09'); $maskvalue = GETPOST('maskcontract', 'alpha'); - if ($maskconst) { + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index 59c826413aa..55259ecfff3 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -325,7 +325,7 @@ if (empty($conf->global->MAIN_DISABLE_METEO) || $conf->global->MAIN_DISABLE_METE if (!empty($conf->global->MAIN_METEO_LEVEL0)) { $level0 = $conf->global->MAIN_METEO_LEVEL0; } - $level1 = $offset + 1 * $cursor; + $level1 = $offset + $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL1)) { $level1 = $conf->global->MAIN_METEO_LEVEL1; } @@ -459,7 +459,7 @@ if ($action == 'edit') { print ''; } else { print '

'; } diff --git a/htdocs/admin/delivery.php b/htdocs/admin/delivery.php index a1fef4091ce..9094762f68d 100644 --- a/htdocs/admin/delivery.php +++ b/htdocs/admin/delivery.php @@ -90,9 +90,9 @@ if ($action == 'activate_delivery') { } if ($action == 'updateMask') { - $maskconstdelivery = GETPOST('maskconstdelivery', 'alpha'); + $maskconstdelivery = GETPOST('maskconstdelivery', 'aZ09'); $maskdelivery = GETPOST('maskdelivery', 'alpha'); - if ($maskconstdelivery) { + if ($maskconstdelivery && preg_match('/_MASK$/', $maskconstdelivery)) { $res = dolibarr_set_const($db, $maskconstdelivery, $maskdelivery, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index d928931c9ab..abf62b51fa7 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1944,7 +1944,7 @@ if ($id > 0) { //var_dump($fieldlist); $class = ''; $showfield = 1; - $valuetoshow = empty($obj->{$value}) ? '' : $obj->{$value}; + $valuetoshow = empty($obj->$value) ? '' : $obj->$value; $titletoshow = ''; if ($value == 'entity') { @@ -1985,76 +1985,76 @@ if ($id > 0) { } elseif ($value == 'libelle_facture') { $langs->load("bills"); $key = $langs->trans("PaymentCondition".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "PaymentCondition".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "PaymentCondition".strtoupper($obj->code) ? $key : $obj->$value); $valuetoshow = nl2br($valuetoshow); } elseif ($value == 'label' && $tabname[$id] == 'c_country') { $key = $langs->trans("Country".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'label' && $tabname[$id] == 'c_availability') { $langs->load("propal"); $key = $langs->trans("AvailabilityType".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "AvailabilityType".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "AvailabilityType".strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'libelle' && $tabname[$id] == 'c_actioncomm') { $key = $langs->trans("Action".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "Action".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "Action".strtoupper($obj->code) ? $key : $obj->$value); } elseif (!empty($obj->code_iso) && $value == 'label' && $tabname[$id] == 'c_currencies') { $key = $langs->trans("Currency".strtoupper($obj->code_iso)); - $valuetoshow = ($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso) ? $key : $obj->$value); } elseif ($value == 'libelle' && $tabname[$id] == 'c_typent') { $key = $langs->trans(strtoupper($obj->code)); - $valuetoshow = ($key != strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($key != strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'libelle' && $tabname[$id] == 'c_prospectlevel') { $key = $langs->trans(strtoupper($obj->code)); - $valuetoshow = ($key != strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($key != strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'label' && $tabname[$id] == 'c_civility') { $key = $langs->trans("Civility".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "Civility".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "Civility".strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'libelle' && $tabname[$id] == 'c_type_contact') { $langs->load('agenda'); $key = $langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'libelle' && $tabname[$id] == 'c_payment_term') { $langs->load("bills"); $key = $langs->trans("PaymentConditionShort".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'libelle' && $tabname[$id] == 'c_paiement') { $langs->load("bills"); $key = $langs->trans("PaymentType".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "PaymentType".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "PaymentType".strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'type' && $tabname[$id] == 'c_paiement') { $payment_type_list = array(0=>$langs->trans('PaymentTypeCustomer'), 1=>$langs->trans('PaymentTypeSupplier'), 2=>$langs->trans('PaymentTypeBoth')); $valuetoshow = $payment_type_list[$valuetoshow]; } elseif ($value == 'label' && $tabname[$id] == 'c_input_reason') { $key = $langs->trans("DemandReasonType".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "DemandReasonType".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "DemandReasonType".strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'libelle' && $tabname[$id] == 'c_input_method') { $langs->load("orders"); $key = $langs->trans($obj->code); - $valuetoshow = ($obj->code && $key != $obj->code) ? $key : $obj->{$value}; + $valuetoshow = ($obj->code && $key != $obj->code) ? $key : $obj->$value; } elseif ($value == 'libelle' && $tabname[$id] == 'c_shipment_mode') { $langs->load("sendings"); $key = $langs->trans("SendingMethod".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "SendingMethod".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "SendingMethod".strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'libelle' && $tabname[$id] == 'c_paper_format') { $key = $langs->trans('PaperFormat'.strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != 'PaperFormat'.strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != 'PaperFormat'.strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'label' && $tabname[$id] == 'c_type_fees') { $langs->load('trips'); $key = $langs->trans(strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'region_id' || $value == 'country_id') { $showfield = 0; } elseif ($value == 'unicode') { $valuetoshow = $langs->getCurrencySymbol($obj->code, 1); } elseif ($value == 'label' && $tabname[GETPOST("id", 'int')] == 'c_units') { $langs->load("products"); - $valuetoshow = $langs->trans($obj->{$value}); + $valuetoshow = $langs->trans($obj->$value); } elseif ($value == 'short_label' && $tabname[GETPOST("id", 'int')] == 'c_units') { $langs->load("products"); - $valuetoshow = $langs->trans($obj->{$value}); + $valuetoshow = $langs->trans($obj->$value); } elseif (($value == 'unit') && ($tabname[$id] == 'c_paper_format')) { $key = $langs->trans('SizeUnit'.strtolower($obj->unit)); - $valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->$value); } elseif ($value == 'localtax1' || $value == 'localtax2') { $class = "center"; } elseif ($value == 'localtax1_type') { @@ -2357,7 +2357,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') foreach ($fieldlist as $field => $value) { if ($value == 'entity') { - $withentity = $obj->{$value}; + $withentity = $obj->$value; continue; } diff --git a/htdocs/admin/ecm.php b/htdocs/admin/ecm.php index 3e0c2378742..4b5ccbb133e 100644 --- a/htdocs/admin/ecm.php +++ b/htdocs/admin/ecm.php @@ -31,6 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page $langs->load("admin"); +$action = GETPOST('action', 'aZ09'); + if (!$user->admin) { accessforbidden(); } @@ -41,6 +43,7 @@ if (!$user->admin) { */ // set +$reg = array(); if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { $code = $reg[1]; if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) { @@ -67,6 +70,8 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { * View */ +$form = new Form($db); + $help_url = ''; llxHeader('', $langs->trans("ECMSetup"), $help_url); @@ -81,26 +86,21 @@ print dol_get_fiche_head($head, 'ecm', '', -1, ''); print ''; print ''; print ''; -print ''; -print ''."\n"; +print ''."\n"; print ''; -$form = new Form($db); - // Mail required for members print ''; print ''; -print ''; - -print ''; diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index cc9b8d7bca8..0d10602b1c4 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -83,15 +83,13 @@ if ($cancel) { $action =''; } -if ((float) DOL_VERSION >= 6) { - include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -} +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstorder = GETPOST('maskconstorder', 'alpha'); + $maskconstorder = GETPOST('maskconstorder', 'aZ09'); $maskorder = GETPOST('maskorder', 'alpha'); - if ($maskconstorder) { + if ($maskconstorder && preg_match('/_MASK$/', $maskconstorder)) { $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 485ce901e5c..1db6a9cc9d6 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -62,9 +62,9 @@ if (empty($conf->global->EXPEDITION_ADDON_NUMBER)) { include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconstexpedition', 'alpha'); + $maskconst = GETPOST('maskconstexpedition', 'aZ09'); $maskvalue = GETPOST('maskexpedition', 'alpha'); - if (!empty($maskconst)) { + if (!empty($maskconst) && preg_match('/_MASK$/', $maskconst)) { $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index 8c20b493105..25bef9fde22 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -58,9 +58,9 @@ $type = 'expensereport'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconst', 'alpha'); + $maskconst = GETPOST('maskconst', 'aZ09'); $maskvalue = GETPOST('maskvalue', 'alpha'); - if ($maskconst) { + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 10746c794be..a364b17cc4b 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -58,24 +58,24 @@ $type = 'invoice'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstinvoice = GETPOST('maskconstinvoice', 'alpha'); - $maskconstreplacement = GETPOST('maskconstreplacement', 'alpha'); - $maskconstcredit = GETPOST('maskconstcredit', 'alpha'); - $maskconstdeposit = GETPOST('maskconstdeposit', 'alpha'); + $maskconstinvoice = GETPOST('maskconstinvoice', 'aZ09'); + $maskconstreplacement = GETPOST('maskconstreplacement', 'aZ09'); + $maskconstcredit = GETPOST('maskconstcredit', 'aZ09'); + $maskconstdeposit = GETPOST('maskconstdeposit', 'aZ09'); $maskinvoice = GETPOST('maskinvoice', 'alpha'); $maskreplacement = GETPOST('maskreplacement', 'alpha'); $maskcredit = GETPOST('maskcredit', 'alpha'); $maskdeposit = GETPOST('maskdeposit', 'alpha'); - if ($maskconstinvoice) { + if ($maskconstinvoice && preg_match('/_MASK_/', $maskconstinvoice)) { $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity); } - if ($maskconstreplacement) { + if ($maskconstreplacement && preg_match('/_MASK_/', $maskconstreplacement)) { $res = dolibarr_set_const($db, $maskconstreplacement, $maskreplacement, 'chaine', 0, '', $conf->entity); } - if ($maskconstcredit) { + if ($maskconstcredit && preg_match('/_MASK_/', $maskconstcredit)) { $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity); } - if ($maskconstdeposit) { + if ($maskconstdeposit && preg_match('/_MASK_/', $maskconstdeposit)) { $res = dolibarr_set_const($db, $maskconstdeposit, $maskdeposit, 'chaine', 0, '', $conf->entity); } @@ -743,7 +743,7 @@ print load_fiche_titre($langs->trans("OtherOptions"), '', ''); print '
'; print '
'.$langs->trans("Description").' '.$langs->trans("Value").''.$langs->trans("Value").'
'.$langs->trans("ECMAutoTree").' '; +print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('ECM_AUTO_TREE_ENABLED'); + print ajax_constantonoff('ECM_AUTO_TREE_HIDEN', null, null, 1); } else { - if (empty($conf->global->ECM_AUTO_TREE_ENABLED)) { - print ''.img_picto($langs->trans("Disabled"), 'off').''; - } elseif (!empty($conf->global->USER_MAIL_REQUIRED)) { - print ''.img_picto($langs->trans("Enabled"), 'on').''; + if (empty($conf->global->ECM_AUTO_TREE_HIDEN)) { + print ''.img_picto($langs->trans("Enabled"), 'on').''; + } else { + print ''.img_picto($langs->trans("Disabled"), 'off').''; } } print '
'; print ''; -print ''; +print ''; print ''; print ''; print "\n"; diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index cf637d37329..2e331b3cc80 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -58,9 +58,9 @@ $type = 'ficheinter'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconst', 'alpha'); + $maskconst = GETPOST('maskconst', 'aZ09'); $maskvalue = GETPOST('maskvalue', 'alpha'); - if ($maskconst) { + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php index 9a60c6b9b84..b85e257c69e 100644 --- a/htdocs/admin/holiday.php +++ b/htdocs/admin/holiday.php @@ -58,9 +58,9 @@ if (empty($conf->global->HOLIDAY_ADDON)) { include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconstholiday', 'alpha'); + $maskconst = GETPOST('maskconstholiday', 'aZ09'); $maskvalue = GETPOST('maskholiday', 'alpha'); - if ($maskconst) { + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/hrm.php b/htdocs/admin/hrm.php index 838e9bf9a0b..14d6e8b175f 100644 --- a/htdocs/admin/hrm.php +++ b/htdocs/admin/hrm.php @@ -53,7 +53,7 @@ $label = GETPOST('label', 'alpha'); $modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php $scandir = GETPOST('scan_dir', 'alpha'); -$type = 'myobject'; +$type = 'evaluation'; $arrayofparameters = array( 'HRM_MAXRANK'=>array('type'=>'integer','enabled'=>1), @@ -70,9 +70,7 @@ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); * Actions */ -if ((float) DOL_VERSION >= 6) { - include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -} +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'update') { $max_rank = GETPOST('HRM_MAXRANK', 'int'); @@ -91,11 +89,11 @@ if ($action == 'update') { } } } elseif ($action == 'updateMask') { - $maskconstorder = GETPOST('maskconstorder', 'alpha'); - $maskorder = GETPOST('maskorder', 'alpha'); + $maskconst = GETPOST('maskconstEvaluation', 'aZ09'); + $maskvalue = GETPOST('maskEvaluation', 'alpha'); - if ($maskconstorder) { - $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity); + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { + $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; } @@ -210,10 +208,10 @@ print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "hrm" $moduledir = 'hrm'; $myTmpObjects = array(); -$myTmpObjects['evaluation'] = array('includerefgeneration'=>1, 'includedocgeneration'=>0); +$myTmpObjects['evaluation'] = array('label'=>'Evaluation', 'includerefgeneration'=>1, 'includedocgeneration'=>0); foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { - if ($myTmpObjectKey == 'MyObject') { + if ($myTmpObjectKey != $type) { continue; } if ($myTmpObjectArray['includerefgeneration']) { @@ -222,7 +220,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { */ $setupnotempty++; - print load_fiche_titre($langs->trans("NumberingModules", $myTmpObjectKey), '', ''); + print load_fiche_titre($langs->trans("NumberingModules").' ('.$myTmpObjectArray['label'].')', '', ''); print '
'.$langs->trans("Parameter").''.$langs->trans("Parameters").''.$langs->trans("Value").' 
'; print ''; @@ -493,16 +491,16 @@ if ($action == 'edit') { if ($val['type'] == 'textarea') { print '\n"; } elseif ($val['type'] == 'integer') { - print '' . "\n"; + print '' . "\n"; } elseif ($val['type'] == 'html') { require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%'); + $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%'); $doleditor->Create(); } elseif ($val['type'] == 'yesno') { - print $form->selectyesno($constname, $conf->global->{$constname}, 1); + print $form->selectyesno($constname, getDolGlobalString($constname), 1); } elseif (preg_match('/emailtemplate:/', $val['type'])) { include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($db); @@ -577,9 +575,9 @@ if ($action == 'edit') { print ''; } diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index e462b7854ac..1cb418cb6c9 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -69,6 +69,7 @@ $search_type_template = GETPOST('search_type_template', 'alpha'); $search_lang = GETPOST('search_lang', 'alpha'); $search_fk_user = GETPOST('search_fk_user', 'intcomma'); $search_topic = GETPOST('search_topic', 'alpha'); +$search_module = GETPOST('search_module', 'alpha'); $acts = array(); $actl = array(); @@ -108,7 +109,7 @@ $tabname[25] = MAIN_DB_PREFIX."c_email_templates"; // Nom des champs en resultat de select pour affichage du dictionnaire $tabfield = array(); -$tabfield[25] = "label,lang,type_template,fk_user,private,position,topic,joinfiles,content"; +$tabfield[25] = "label,lang,type_template,fk_user,private,position,module,topic,joinfiles,content"; if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { $tabfield[25] .= ',content_lines'; } @@ -290,6 +291,7 @@ if (empty($reshook)) { $search_lang = ''; $search_fk_user = ''; $search_topic = ''; + $search_module = ''; $toselect = array(); $search_array_options = array(); } @@ -598,6 +600,9 @@ if ($search_lang) { if ($search_fk_user != '' && $search_fk_user != '-1') { $sql .= natural_search('fk_user', $search_fk_user, 2); } +if ($search_module) { + $sql .= natural_search('module', $search_module); +} if ($search_topic) { $sql .= natural_search('topic', $search_topic); } @@ -703,6 +708,9 @@ if ($action == 'create') { $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut $valuetoshow = $langs->trans($valuetoshow); // try to translate $align = "left"; + if ($fieldlist[$field] == 'module') { + $valuetoshow = ''; + } if ($fieldlist[$field] == 'fk_user') { $valuetoshow = $langs->trans("Owner"); } @@ -802,9 +810,9 @@ if ($action == 'create') { $fieldsforcontent = array('topic', 'joinfiles', 'content', 'content_lines'); } foreach ($fieldsforcontent as $tmpfieldlist) { - print ''; foreach ($fieldlist as $field => $value) { - if ($value == 'label') { + if ($value == 'module') { + print ''; + } elseif ($value == 'label') { print ''; } elseif ($value == 'lang') { print ''; } elseif ($value == 'fk_user') { print ''; } elseif ($value == 'topic') { print ''; @@ -958,6 +971,9 @@ foreach ($fieldlist as $field => $value) { */ $valuetoshow = ucfirst($fieldlist[$field]); // By defaut $valuetoshow = $langs->trans($valuetoshow); // try to translate + if ($fieldlist[$field] == 'module') { + $align = 'tdoverflowmax100'; + } if ($fieldlist[$field] == 'fk_user') { $valuetoshow = $langs->trans("Owner"); } @@ -1000,11 +1016,15 @@ foreach ($fieldlist as $field => $value) { $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, '', $forcenowrap); // Tooltip on hover } } - print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "align=".$align, $sortfield, $sortorder); + $sortfieldtouse = ($sortable ? $fieldlist[$field] : ''); + if ($sortfieldtouse == 'type_template') { + $sortfieldtouse.= ',label'; + } + print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], $sortfieldtouse, ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, $align.' '); } } -print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, 'align="center"', $sortfield, $sortorder); +print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center '); print getTitleFieldOfList(''); print ''; @@ -1052,7 +1072,7 @@ if ($num) { if ($showfield) { // Show line for topic, joinfiles and content print ''; - print ''; + } elseif ($value == 'fk_user') { print ''; } elseif ($context == 'add' && in_array($value, array('topic', 'joinfiles', 'content', 'content_lines'))) { diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index e18e65e47a0..9a0c34aea2b 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -372,13 +372,13 @@ if ($mode == 'feature') { if (count($objMod->depends)) { $text .= join(',', $objMod->depends); } else { - $text .= $langs->trans("None"); + $text .= ''.$langs->trans("None").''; } $text .= '
'.$langs->trans("RequiredBy").': '; if (count($objMod->requiredby)) { $text .= join(',', $objMod->requiredby); } else { - $text .= $langs->trans("None"); + $text .= ''.$langs->trans("None").''; } $text .= '

'; @@ -395,7 +395,7 @@ if ($mode == 'feature') { $i++; } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -408,7 +408,7 @@ if ($mode == 'feature') { $i++; } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -418,7 +418,7 @@ if ($mode == 'feature') { if (dol_is_file($filedata)) { $text .= $langs->trans("Yes").' ('.$moduledir.'/sql/data.sql)'; } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -437,7 +437,7 @@ if ($mode == 'feature') { } } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -446,7 +446,7 @@ if ($mode == 'feature') { if (isset($objMod->module_parts) && isset($objMod->module_parts['models']) && $objMod->module_parts['models']) { $text .= $langs->trans("Yes"); } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -455,7 +455,7 @@ if ($mode == 'feature') { if (isset($objMod->module_parts) && isset($objMod->module_parts['substitutions']) && $objMod->module_parts['substitutions']) { $text .= $langs->trans("Yes"); } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -468,7 +468,7 @@ if ($mode == 'feature') { $i++; } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -502,7 +502,7 @@ if ($mode == 'feature') { $i++; } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -531,7 +531,7 @@ if ($mode == 'feature') { $i++; } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -544,7 +544,7 @@ if ($mode == 'feature') { $i++; } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -553,7 +553,7 @@ if ($mode == 'feature') { if (isset($objMod->menu) && !empty($objMod->menu)) { // objMod can be an array or just an int 1 $text .= $langs->trans("Yes"); } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -566,7 +566,7 @@ if ($mode == 'feature') { $i++; } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -579,13 +579,13 @@ if ($mode == 'feature') { $i++; } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; $text .= '
'.$langs->trans("AddOtherPagesOrServices").': '; - $text .= $langs->trans("DetectionNotPossible"); + $text .= ''.$langs->trans("DetectionNotPossible").''; } @@ -594,7 +594,7 @@ if ($mode == 'changelog') { if ($changelog) { $text .= '
'.$changelog.'
'; } else { - $text .= '
'.$langs->trans("NotAvailable").'
'; + $text .= '
'.$langs->trans("NotAvailable").'
'; } } diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index bd6a238c0f0..e93b5a58e96 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -65,9 +65,9 @@ $search_version = GETPOST('search_version', 'alpha'); // For dolistore search $options = array(); $options['per_page'] = 20; -$options['categorie'] = ((GETPOST('categorie', 'int') ?GETPOST('categorie', 'int') : 0) + 0); -$options['start'] = ((GETPOST('start', 'int') ?GETPOST('start', 'int') : 0) + 0); -$options['end'] = ((GETPOST('end', 'int') ?GETPOST('end', 'int') : 0) + 0); +$options['categorie'] = ((int) (GETPOST('categorie', 'int') ? GETPOST('categorie', 'int') : 0)); +$options['start'] = ((int) (GETPOST('start', 'int') ?GETPOST('start', 'int') : 0)); +$options['end'] = ((int) (GETPOST('end', 'int') ?GETPOST('end', 'int') : 0)); $options['search'] = GETPOST('search_keyword', 'alpha'); $dolistore = new Dolistore(false); @@ -641,11 +641,11 @@ if ($mode == 'common' || $mode == 'commonkanban') { // We discard showing according to filters if ($search_keyword) { $qualified = 0; - if (preg_match('/'.preg_quote($search_keyword).'/i', $modulename) - || preg_match('/'.preg_quote($search_keyword).'/i', $moduletechnicalname) - || preg_match('/'.preg_quote($search_keyword).'/i', $moduledesc) - || preg_match('/'.preg_quote($search_keyword).'/i', $moduledesclong) - || preg_match('/'.preg_quote($search_keyword).'/i', $moduleauthor) + if (preg_match('/'.preg_quote($search_keyword, '/').'/i', $modulename) + || preg_match('/'.preg_quote($search_keyword, '/').'/i', $moduletechnicalname) + || ($moduledesc && preg_match('/'.preg_quote($search_keyword, '/').'/i', $moduledesc)) + || ($moduledesclong && preg_match('/'.preg_quote($search_keyword, '/').'/i', $moduledesclong)) + || ($moduleauthor && preg_match('/'.preg_quote($search_keyword, '/').'/i', $moduleauthor)) ) { $qualified = 1; } @@ -844,10 +844,10 @@ if ($mode == 'common' || $mode == 'commonkanban') { } } } - } elseif (preg_match('/^([^@]+)@([^@]+)$/i', $objMod->config_page_url, $regs)) { + } elseif (preg_match('/^([^@]+)@([^@]+)$/i', (string) $objMod->config_page_url, $regs)) { $codetoconfig .= ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15').''; } else { - $codetoconfig .= ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15').''; + $codetoconfig .= ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15').''; } } else { $codetoconfig .= img_picto($langs->trans("NothingToSetup"), "setup", 'class="opacitytransp" style="padding-right: 6px"', false, 0, 0, '', 'fa-15'); @@ -1075,7 +1075,7 @@ if ($mode == 'marketplace') {
'; if ($val['type'] == 'textarea') { - print dol_nl2br($conf->global->{$constname}); + print dol_nl2br(getDolGlobalString($constname)); } elseif ($val['type']== 'html') { - print $conf->global->{$constname}; + print getDolGlobalString($constname); } elseif ($val['type'] == 'yesno') { print ajax_constantonoff($constname); } elseif (preg_match('/emailtemplate:/', $val['type'])) { @@ -588,14 +586,14 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); - $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname}); + $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname)); if ($template<0) { setEventMessages(null, $formmail->errors, 'errors'); } print $langs->trans($template->label); } elseif (preg_match('/category:/', $val['type'])) { $c = new Categorie($db); - $result = $c->fetch($conf->global->{$constname}); + $result = $c->fetch(getDolGlobalString($constname)); if ($result < 0) { setEventMessages(null, $c->errors, 'errors'); } diff --git a/htdocs/admin/knowledgemanagement.php b/htdocs/admin/knowledgemanagement.php index b1710a53839..3fc8ebb3724 100644 --- a/htdocs/admin/knowledgemanagement.php +++ b/htdocs/admin/knowledgemanagement.php @@ -69,11 +69,11 @@ if (!$user->admin) { include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstorder = GETPOST('maskconstorder', 'alpha'); + $maskconst = GETPOST('maskconst', 'aZ09'); $maskorder = GETPOST('maskorder', 'alpha'); - if ($maskconstorder) { - $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity); + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { + $res = dolibarr_set_const($db, $maskconst, $maskorder, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; } @@ -209,14 +209,14 @@ if ($action == 'edit') { if ($val['type'] == 'textarea') { print '\n"; } elseif ($val['type'] == 'html') { require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%'); + $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%'); $doleditor->Create(); } elseif ($val['type'] == 'yesno') { - print $form->selectyesno($constname, $conf->global->{$constname}, 1); + print $form->selectyesno($constname, getDolGlobalString($constname), 1); } elseif (preg_match('/emailtemplate:/', $val['type'])) { include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($db); @@ -275,9 +275,9 @@ if ($action == 'edit') { print ''; if ($val['type'] == 'textarea') { - print dol_nl2br($conf->global->{$constname}); + print dol_nl2br(getDolGlobalString($constname)); } elseif ($val['type']== 'html') { - print $conf->global->{$constname}; + print getDolGlobalString($constname); } elseif ($val['type'] == 'yesno') { print ajax_constantonoff($constname); } elseif (preg_match('/emailtemplate:/', $val['type'])) { @@ -286,7 +286,7 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); - $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname}); + $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname)); if ($template<0) { setEventMessages(null, $formmail->errors, 'errors'); } @@ -304,17 +304,17 @@ if ($action == 'edit') { } print '
    ' . implode(' ', $toprint) . '
'; } elseif (preg_match('/thirdparty_type/', $val['type'])) { - if ($conf->global->{$constname}==2) { + if (getDolGlobalString($constname)==2) { print $langs->trans("Prospect"); - } elseif ($conf->global->{$constname}==3) { + } elseif (getDolGlobalString($constname)==3) { print $langs->trans("ProspectCustomer"); - } elseif ($conf->global->{$constname}==1) { + } elseif (getDolGlobalInt($constname)==1) { print $langs->trans("Customer"); - } elseif ($conf->global->{$constname}==0) { + } elseif (getDolGlobalInt($constname)==0) { print $langs->trans("NorProspectNorCustomer"); } } else { - print $conf->global->{$constname}; + print getDolGlobalString($constname); } print '
'; + print '
'; - // Label + // Topic of email if ($tmpfieldlist == 'topic') { print ''.$form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' '; } @@ -882,6 +890,9 @@ if ($search_type_template != '-1') { if ($search_fk_user > 0) { $param .= '&search_fk_user='.urlencode($search_fk_user); } +if ($search_module) { + $param .= '&search_module='.urlencode($search_module); +} if ($search_topic) { $param .= '&search_topic='.urlencode($search_topic); } @@ -909,7 +920,9 @@ if ($num > $listlimit) { print '
'; @@ -917,7 +930,7 @@ foreach ($fieldlist as $field => $value) { print ''; - print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'maxwidth125', 1); + print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'maxwidth100', 1); print '
'; + print ''; if ($tmpfieldlist == 'topic') { print ''.$form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' '; print ''; @@ -1068,7 +1088,6 @@ if ($num) { if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { $okforextended = false; } - $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 500, 'dolibarr_mailings', 'In', 0, $acceptlocallinktomedia, $okforextended, ROWS_6, '90%'); print $doleditor->Create(1); } @@ -1130,7 +1149,8 @@ if ($num) { $align = ""; $class = "tddict"; $title = ''; - $valuetoshow = $obj->{$fieldlist[$field]}; + $tmpvar = $fieldlist[$field]; + $valuetoshow = $obj->$tmpvar; if ($value == 'label' || $value == 'topic') { if ($langs->trans($valuetoshow) != $valuetoshow) { $valuetoshow = $langs->trans($valuetoshow); @@ -1268,29 +1288,31 @@ $db->close(); */ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') { - global $conf, $langs, $user, $db; + global $langs, $user, $db; global $form; global $elementList; $formadmin = new FormAdmin($db); foreach ($fieldlist as $field => $value) { - if ($value == 'fk_user') { + if ($value == 'module') { + print ''; if ($user->admin) { - print $form->select_dolusers(empty($obj->{$value}) ? '' : $obj->{$value}, 'fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'minwidth150 maxwidth200'); + print $form->select_dolusers(empty($obj->$value) ? '' : $obj->$value, 'fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'minwidth75 maxwidth100'); } else { if ($context == 'add') { // I am not admin and we show the add form print $user->getNomUrl(1); // Me $forcedvalue = $user->id; } else { - if ($obj && !empty($obj->{$value}) && $obj->{$value} > 0) { + if ($obj && !empty($obj->$value) && $obj->$value > 0) { $fuser = new User($db); - $fuser->fetch($obj->{$value}); + $fuser->fetch($obj->$value); print $fuser->getNomUrl(1); $forcedvalue = $fuser->id; } else { - $forcedvalue = $obj->{$value}; + $forcedvalue = $obj->$value; } } $keyname = $value; @@ -1304,7 +1326,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') if ($context == 'edit') { $selectedlang = $obj->lang; } - print $formadmin->select_language($selectedlang, 'langcode', 0, null, 1, 0, 0, 'maxwidth150'); + print $formadmin->select_language($selectedlang, 'langcode', 0, null, 1, 0, 0, 'maxwidth100'); } else { if (!empty($obj->lang)) { print $obj->lang.' - '.$langs->trans('Language_'.$obj->lang); @@ -1324,7 +1346,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') print ''; print $obj->type_template; } else { - print $form->selectarray('type_template', $elementList, (!empty($obj->type_template) ? $obj->type_template:''), 1, 0, 0, '', 0, 0, 0, '', 'minwidth150', 1, '', 0, 1); + print $form->selectarray('type_template', $elementList, (!empty($obj->type_template) ? $obj->type_template:''), 1, 0, 0, '', 0, 0, 0, '', 'minwidth75 maxwidth125', 1, '', 0, 1); } print '
- get_products(!empty($categorie) ? $categorie: ''); ?> + get_products(); ?>
@@ -1216,10 +1216,10 @@ if ($mode == 'deploy') { print ''."\n"; diff --git a/htdocs/admin/mrp.php b/htdocs/admin/mrp.php index 36a82e965f4..21fff1c45e6 100644 --- a/htdocs/admin/mrp.php +++ b/htdocs/admin/mrp.php @@ -52,10 +52,10 @@ $type = 'mrp'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstmrp = GETPOST('maskconstMo', 'alpha'); + $maskconstmrp = GETPOST('maskconstMo', 'aZ09'); $maskmrp = GETPOST('maskMo', 'alpha'); - if ($maskconstmrp) { + if ($maskconstmrp && preg_match('/_MASK$/', $maskconstmrp)) { $res = dolibarr_set_const($db, $maskconstmrp, $maskmrp, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index 1cf838c08cb..5945ebfb5d5 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -134,7 +134,8 @@ if ($action == 'add_currency') { dolibarr_set_const($db, 'MULTICURRENCY_APP_SOURCE', GETPOST('MULTICURRENCY_APP_SOURCE', 'alpha')); //dolibarr_set_const($db, 'MULTICURRENCY_ALTERNATE_SOURCE', GETPOST('MULTICURRENCY_ALTERNATE_SOURCE', 'alpha')); } else { - $result = MultiCurrency::syncRates($conf->global->MULTICURRENCY_APP_ID); + $multiurrency = new MultiCurrency($db); + $result = $multiurrency->syncRates(getDolGlobalString('MULTICURRENCY_APP_ID')); if ($result > 0) { setEventMessages($langs->trans("CurrencyRateSyncSucceed"), null, "mesgs"); } diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php index 64968b1a516..217dfd63cc9 100644 --- a/htdocs/admin/oauth.php +++ b/htdocs/admin/oauth.php @@ -285,7 +285,7 @@ if (count($listinsetup) > 0) { // Delete print ''; $label = preg_replace('/_NAME$/', '', $keyforsupportedoauth2array); - print ''; + print ''; print img_picto('', 'delete'); print ''; @@ -298,7 +298,8 @@ if (count($listinsetup) > 0) { $redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$keyforsupportedoauth2array]['callbackfile'].'_oauthcallback.php'; print ''; print ''.$langs->trans("UseTheFollowingUrlAsRedirectURI").''; - print ''; + print ''; + print ajax_autoselect('uri'.$keyforsupportedoauth2array.$keyforprovider); print ''; print ''; print ''; @@ -306,7 +307,7 @@ if (count($listinsetup) > 0) { if ($keyforsupportedoauth2array == 'OAUTH_OTHER_NAME') { print ''; print ''.$langs->trans("URLOfServiceForAuthorization").''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php index f798995d525..9a0532880cd 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -213,7 +213,13 @@ if ($mode == 'setup' && $user->admin) { $urltocheckperms = ''; } - $urltorenew .= '&keyforprovider='.urlencode($keyforprovider); + if ($urltorenew) { + $urltorenew .= '&keyforprovider='.urlencode($keyforprovider); + } + if ($urltodelete) { + $urltodelete .= '&keyforprovider='.urlencode($keyforprovider); + } + // Show value of token $tokenobj = null; diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index 59da712b266..7b0d0acbf06 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -51,9 +51,9 @@ if (empty($conf->global->PAYMENT_ADDON)) { */ if ($action == 'updateMask') { - $maskconstpayment = GETPOST('maskconstpayment', 'alpha'); + $maskconstpayment = GETPOST('maskconstpayment', 'aZ09'); $maskpayment = GETPOST('maskpayment', 'alpha'); - if ($maskconstpayment) { + if ($maskconstpayment && preg_match('/_MASK$/', $maskconstpayment)) { $res = dolibarr_set_const($db, $maskconstpayment, $maskpayment, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index d8cc8d554a2..f5f87877ab7 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; // Load translation files required by the page -$langs->loadLangs(array('admin', 'languages', 'other', 'companies', 'products', 'members', 'stocks', 'Trips')); +$langs->loadLangs(array('admin', 'companies', 'languages', 'members', 'other', 'products', 'stocks', 'trips')); if (!$user->admin) { accessforbidden(); @@ -276,7 +276,7 @@ print load_fiche_titre($langs->trans("DictionaryPaperFormat"), '', ''); print '
'; print ''; -print ''; +print ''; $selected = (isset($conf->global->MAIN_PDF_FORMAT) ? $conf->global->MAIN_PDF_FORMAT : ''); if (empty($selected)) { diff --git a/htdocs/admin/pdf_other.php b/htdocs/admin/pdf_other.php index e5c76a36269..933486b0577 100644 --- a/htdocs/admin/pdf_other.php +++ b/htdocs/admin/pdf_other.php @@ -5,6 +5,7 @@ * Copyright (C) 2012-2107 Juanjo Menent * Copyright (C) 2019 Ferran Marcet * Copyright (C) 2021-2022 Anthony Berton + * Copyright (C) 2022 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 @@ -35,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; // Load translation files required by the page -$langs->loadLangs(array('admin', 'languages', 'other', 'companies', 'products', 'members', 'stocks', 'Trips')); +$langs->loadLangs(array('admin', 'bills', 'companies', 'languages', 'members', 'other', 'products', 'propal', 'receptions', 'stocks', 'trips')); if (!$user->admin) { accessforbidden(); @@ -69,6 +70,9 @@ if ($action == 'update') { dolibarr_set_const($db, "INVOICE_ADD_SWISS_QR_CODE", GETPOST("INVOICE_ADD_SWISS_QR_CODE", 'int'), 'chaine', 0, '', $conf->entity); dolibarr_del_const($db, "INVOICE_ADD_ZATCA_QR_CODE", $conf->entity); } + if (GETPOSTISSET('INVOICE_CATEGORY_OF_OPERATION')) { + dolibarr_set_const($db, "INVOICE_CATEGORY_OF_OPERATION", GETPOST("INVOICE_CATEGORY_OF_OPERATION", 'int'), 'chaine', 0, '', $conf->entity); + } if (GETPOSTISSET('INVOICE_SHOW_SHIPPING_ADDRESS')) { dolibarr_set_const($db, "INVOICE_SHOW_SHIPPING_ADDRESS", GETPOST("INVOICE_SHOW_SHIPPING_ADDRESS", 'int'), 'chaine', 0, '', $conf->entity); dolibarr_del_const($db, "INVOICE_SHOW_SHIPPING_ADDRESS", $conf->entity); @@ -135,7 +139,7 @@ if (isModEnabled('facture')) { print '
'; print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("Parameters").''.$langs->trans("Value").'
'; - print ''; + print ''; print ''; + // Mention category of operations + // French Decret n°2099-1299 2022-10-07 print ''; + + print 'global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print 'global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $coldisplay++; print ''; +// Vendor price ref if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier' || $object->element == 'invoice_supplier_rec') { // We must have same test in printObjectLines print ''; } + +$tooltiponprice = ''; +$tooltiponpriceend = ''; +if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $tooltiponprice = $langs->transcountry("TotalHT", $mysoc->country_code).'='.price($line->total_ht); + $tooltiponprice .= '
'.$langs->transcountry("TotalVAT", ($senderissupplier ? $object->thirdparty->country_code : $mysoc->country_code)).'='.price($line->total_tva); + if (is_object($object->thirdparty)) { + if ($senderissupplier) { + $seller = $object->thirdparty; + $buyer = $mysoc; + } else { + $seller = $mysoc; + $buyer = $object->thirdparty; + } + + if ($mysoc->useLocalTax(1)) { + if (($seller->country_code == $buyer->country_code) || $line->total_localtax1 || $seller->useLocalTax(1)) { + $tooltiponprice .= '
'.$langs->transcountry("TotalLT1", $seller->country_code).'='.price($line->total_localtax1); + } else { + $tooltiponprice .= '
'.$langs->transcountry("TotalLT1", $seller->country_code).'='.$langs->trans($senderissupplier ? "NotUsedForThisVendor" : "NotUsedForThisCustomer").''; + } + } + if ($mysoc->useLocalTax(2)) { + if (($seller->country_code == $buyer->thirdparty->country_code) || $line->total_localtax2 || $seller->useLocalTax(2)) { + $tooltiponprice .= '
'.$langs->transcountry("TotalLT2", $seller->country_code).'='.price($line->total_localtax2); + } else { + $tooltiponprice .= '
'.$langs->transcountry("TotalLT2", $seller->country_code).'='.$langs->trans($senderissupplier ? "NotUsedForThisVendor" : "NotUsedForThisCustomer").''; + } + } + } + $tooltiponprice .= '
'.$langs->transcountry("TotalTTC", $mysoc->country_code).'='.price($line->total_ttc); + + $tooltiponprice = ''; + $tooltiponpriceend = ''; +} + // VAT Rate print ' @@ -344,53 +382,24 @@ if ($usemargins && isModEnabled('margin') && empty($user->socid)) { special_code == 3) { ?> '; $coldisplay++; - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $tooltiponprice = $langs->transcountry("TotalHT", $mysoc->country_code).'='.price($line->total_ht); - $tooltiponprice .= '
'.$langs->transcountry("TotalVAT", ($senderissupplier ? $object->thirdparty->country_code : $mysoc->country_code)).'='.price($line->total_tva); - if (is_object($object->thirdparty)) { - if ($senderissupplier) { - $seller = $object->thirdparty; - $buyer = $mysoc; - } else { - $seller = $mysoc; - $buyer = $object->thirdparty; - } - - if ($mysoc->useLocalTax(1)) { - if (($seller->country_code == $buyer->country_code) || $line->total_localtax1 || $seller->useLocalTax(1)) { - $tooltiponprice .= '
'.$langs->transcountry("TotalLT1", $seller->country_code).'='.price($line->total_localtax1); - } else { - $tooltiponprice .= '
'.$langs->transcountry("TotalLT1", $seller->country_code).'='.$langs->trans($senderissupplier ? "NotUsedForThisSupplier" : "NotUsedForThisCustomer").''; - } - } - if ($mysoc->useLocalTax(2)) { - if (($seller->country_code == $buyer->thirdparty->country_code) || $line->total_localtax2 || $seller->useLocalTax(2)) { - $tooltiponprice .= '
'.$langs->transcountry("TotalLT2", $seller->country_code).'='.price($line->total_localtax2); - } else { - $tooltiponprice .= '
'.$langs->transcountry("TotalLT2", $seller->country_code).'='.$langs->trans($senderissupplier ? "NotUsedForThisSupplier" : "NotUsedForThisCustomer").''; - } - } - } - $tooltiponprice .= '
'.$langs->transcountry("TotalTTC", $mysoc->country_code).'='.price($line->total_ttc); - - print ''; - } + print $tooltiponprice; print price($sign * $line->total_ht); - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - print ''; - } + print $tooltiponpriceend; print ''; if (isModEnabled("multicurrency") && $this->multicurrency_code != $conf->currency) { print ''; $coldisplay++; } } + +// Price inc tax if ($outputalsopricetotalwithtax) { print ''; $coldisplay++; @@ -405,6 +414,7 @@ if ($this->statut == 0 && !empty($object_rights->creer) && $action != 'selectlin } } + // Asset info if (isModEnabled('asset') && $object->element == 'invoice_supplier') { print ''; } + // Edit picto print ''; + // Delete picto print ''; + // Move up-down picto if ($num > 1 && $conf->browser->layout != 'phone' && ($this->situation_counter == 1 || !$this->situation_cycle_ref) && empty($disablemove)) { print ''; print ''; print ''; } print ''; - print ''; print ''; // Status - print ''; + print ''; // Amount paid print ''; print "\n"; diff --git a/htdocs/don/stats/index.php b/htdocs/don/stats/index.php index e9c2b82ae22..866cd25eef1 100644 --- a/htdocs/don/stats/index.php +++ b/htdocs/don/stats/index.php @@ -58,7 +58,7 @@ $form = new Form($db); llxHeader(); -print load_fiche_titre($langs->trans("StatisticsOfSendings"), $mesg); +print load_fiche_titre($langs->trans("StatisticsOfDonations"), $mesg); dol_mkdir($dir); @@ -72,9 +72,9 @@ $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear); if (empty($user->rights->societe->client->voir) || $user->socid) { - $filenamenb = $dir.'/shipmentsnbinyear-'.$user->id.'-'.$year.'.png'; + $filenamenb = $dir.'/donationnbinyear-'.$user->id.'-'.$year.'.png'; } else { - $filenamenb = $dir.'/shipmentsnbinyear-'.$year.'.png'; + $filenamenb = $dir.'/donationnbinyear-'.$year.'.png'; } $px1 = new DolGraph(); @@ -91,11 +91,11 @@ if (!$mesg) { $px1->SetMinValue(min(0, $px1->GetFloorMinValue())); $px1->SetWidth($WIDTH); $px1->SetHeight($HEIGHT); - $px1->SetYLabel($langs->trans("NbOfSendings")); + $px1->SetYLabel($langs->trans("NbOfDonations")); $px1->SetShading(3); $px1->SetHorizTickIncrement(1); $px1->mode = 'depth'; - $px1->SetTitle($langs->trans("NumberOfShipmentsByMonth")); + $px1->SetTitle($langs->trans("NumberOfDonationsByMonth")); $px1->draw($filenamenb, $fileurlnb); } @@ -245,7 +245,7 @@ print '
'; print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("Parameters").''.$langs->trans("Value").'
'; print $form->textwithpicto($langs->trans("INVOICE_ADD_ZATCA_QR_CODE"), $langs->trans("INVOICE_ADD_ZATCA_QR_CODEMore")); @@ -159,11 +163,21 @@ if (isModEnabled('facture')) { } print '
'; - print $form->textwithpicto($langs->trans("INVOICE_SHOW_SHIPPING_ADDRESS"), $langs->trans("INVOICE_SHOW_SHIPPING_ADDRESSMore")); + print $form->textwithpicto($langs->trans("InvoiceOptionCategoryOfOperations"), $langs->trans('InvoiceOptionCategoryOfOperationsHelp'), 1); print ''; + $arrval = array('0'=>$langs->trans("No"), + '1'=>$langs->trans("InvoiceOptionCategoryOfOperationsYes1"), + '2'=>$langs->trans("InvoiceOptionCategoryOfOperationsYes2") + ); + print $form->selectarray("INVOICE_CATEGORY_OF_OPERATION", $arrval, $conf->global->INVOICE_CATEGORY_OF_OPERATION, 0, 0, 0, '', 0, 0, 0, '', 'minwidth75imp'); + print '
'.$langs->trans("MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING").''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('INVOICE_SHOW_SHIPPING_ADDRESS'); + print ajax_constantonoff('MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("INVOICE_SHOW_SHIPPING_ADDRESS", $arrval, $conf->global->INVOICE_SHOW_SHIPPING_ADDRESS); @@ -181,7 +195,7 @@ if (isModEnabled('reception')) { print '
'; print ''; - print ''; + print ''; print ''; print ''; print '\n\n"; $found++; -//if (!empty($conf->expedition->enabled)) +//if (isModEnabled('expedition')) //{ print ''; @@ -247,7 +255,7 @@ print ''; print ''; print ''; print ''; print ''."\n"; // value defined in http://fr3.php.net/manual/en/timezones.europe.php print ''."\n"; diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 7d8233cdc0a..36904cba63d 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -100,11 +100,11 @@ if (empty($xmlremote)) { } if ($xmlremote && !preg_match('/^https?:\/\//', $xmlremote)) { $langs->load("errors"); - setEventMessages($langs->trans("ErrorURLMustStartWithHttp", $xmlremote), '', 'errors'); + setEventMessages($langs->trans("ErrorURLMustStartWithHttp", $xmlremote), null, 'errors'); $error++; } elseif ($xmlremote && !preg_match('/\.xml$/', $xmlremote)) { $langs->load("errors"); - setEventMessages($langs->trans("ErrorURLMustEndWith", $xmlremote, '.xml'), '', 'errors'); + setEventMessages($langs->trans("ErrorURLMustEndWith", $xmlremote, '.xml'), null, 'errors'); $error++; } diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php index 6d7ef8f1863..cc9ab7658db 100644 --- a/htdocs/admin/system/perf.php +++ b/htdocs/admin/system/perf.php @@ -50,8 +50,13 @@ llxHeader(); print load_fiche_titre($langs->trans("PerfDolibarr"), '', 'title_setup'); -print ''.$langs->trans("YouMayFindPerfAdviceHere", 'https://wiki.dolibarr.org/index.php/FAQ_Increase_Performance').' ('.$langs->trans("Reload").')
'; - +print ''.$langs->trans("YouMayFindPerfAdviceHere", 'https://wiki.dolibarr.org/index.php/FAQ_Increase_Performance').''; +print '     '; +print ''; +print img_picto($langs->trans("Reload"), 'refresh').' '; +print $langs->trans("Reload"); +print ''; +print '
'; print '
'; print '
'; @@ -198,7 +203,7 @@ jQuery(document).ready(function() { compphpstring=getphpurl.getResponseHeader(\'Content-Encoding\'); /* alert(\'php:\'+getphpurl.getAllResponseHeaders()); */ /*alert(\'php:\'+compphpstring);*/ - if (compphpstring == null || (compphpstring.indexOf("gzip") == -1 && compphpstring.indexOf("deflate") == -1)) + if (compphpstring == null || (compphpstring.indexOf("gzip") == -1 && compphpstring.indexOf("deflate") == -1 && compphpstring.indexOf("br") == -1)) { jQuery("#httpcompphpok").hide(); jQuery("#httpcompphpko").show(); @@ -238,7 +243,7 @@ jQuery(document).ready(function() { compcssstring=getcssurl.getResponseHeader(\'Content-Encoding\'); /* alert(\'php:\'+getcssurl.getAllResponseHeaders()); */ /*alert(\'php:\'+compcssstring);*/ - if (compcssstring == null || (compcssstring.indexOf("gzip") == -1 && compcssstring.indexOf("deflate") == -1)) + if (compcssstring == null || (compcssstring.indexOf("gzip") == -1 && compcssstring.indexOf("deflate") == -1 && compcssstring.indexOf("br") == -1)) { jQuery("#httpcompcssok").hide(); jQuery("#httpcompcssko").show(); @@ -278,7 +283,7 @@ jQuery(document).ready(function() { compcssphpstring=getcssphpurl.getResponseHeader(\'Content-Encoding\'); /* alert(\'php:\'+getcssphpurl.getAllResponseHeaders()); */ /*alert(\'php:\'+compcssphpstring);*/ - if (compcssphpstring == null || (compcssphpstring.indexOf("gzip") == -1 && compcssphpstring.indexOf("deflate") == -1)) + if (compcssphpstring == null || (compcssphpstring.indexOf("gzip") == -1 && compcssphpstring.indexOf("deflate") == -1 && compcssphpstring.indexOf("br") == -1)) { jQuery("#httpcompcssphpok").hide(); jQuery("#httpcompcssphpko").show(); @@ -318,7 +323,7 @@ jQuery(document).ready(function() { compimgstring=getimgurl.getResponseHeader(\'Content-Encoding\'); /* alert(\'php:\'+getimgurl.getAllResponseHeaders()); */ /*alert(\'php:\'+compimgstring);*/ - if (compimgstring == null || (compimgstring.indexOf("gzip") == -1 && compimgstring.indexOf("deflate") == -1)) + if (compimgstring == null || (compimgstring.indexOf("gzip") == -1 && compimgstring.indexOf("deflate") == -1 && compimgstring.indexOf("br") == -1)) { jQuery("#httpcompimgok").hide(); jQuery("#httpcompimgko").show(); @@ -358,7 +363,7 @@ jQuery(document).ready(function() { compjsstring=getjsurl.getResponseHeader(\'Content-Encoding\'); /* alert(\'js:\'+getjsurl.getAllResponseHeaders()); */ /*alert(\'js:\'+compjsstring);*/ - if (compjsstring == null || (compjsstring.indexOf("gzip") == -1 && compjsstring.indexOf("deflate") == -1)) + if (compjsstring == null || (compjsstring.indexOf("gzip") == -1 && compjsstring.indexOf("deflate") == -1 && compjsstring.indexOf("br") == -1)) { jQuery("#httpcompjsok").hide(); jQuery("#httpcompjsko").show(); @@ -398,7 +403,7 @@ jQuery(document).ready(function() { compjsphpstring=getjsphpurl.getResponseHeader(\'Content-Encoding\'); /* alert(\'php:\'+getjsphpurl.getAllResponseHeaders()); */ /*alert(\'php:\'+compjsphpstring);*/ - if (compjsphpstring == null || (compjsphpstring.indexOf("gzip") == -1 && compjsphpstring.indexOf("deflate") == -1)) + if (compjsphpstring == null || (compjsphpstring.indexOf("gzip") == -1 && compjsphpstring.indexOf("deflate") == -1 && compjsphpstring.indexOf("br") == -1)) { jQuery("#httpcompjsphpok").hide(); jQuery("#httpcompjsphpko").show(); diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index f8f47baebf9..a8a6f345781 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -41,7 +41,7 @@ if (GETPOST('action', 'aZ09') == 'donothing') { exit; } -$execmethod = empty($conf->global->MAIN_EXEC_USE_POPEN) ? 1 : $conf->global->MAIN_EXEC_USE_POPEN; +$execmethod = getDolGlobalInt('MAIN_EXEC_USE_POPEN', 1); /* @@ -52,7 +52,13 @@ llxHeader(); print load_fiche_titre($langs->trans("Security"), '', 'title_setup'); -print ''.$langs->trans("YouMayFindSecurityAdviceHere", 'hhttps://wiki.dolibarr.org/index.php/Security_information').' ('.$langs->trans("Reload").')
'; +print ''.$langs->trans("YouMayFindSecurityAdviceHere", 'hhttps://wiki.dolibarr.org/index.php/Security_information').''; +print '     '; +print ''; +print img_picto($langs->trans("Reload"), 'refresh').' '; +print $langs->trans("Reload"); +print ''; +print '
'; print '
'; print load_fiche_titre($langs->trans("PHPSetup"), '', 'folder'); @@ -487,7 +493,7 @@ if (empty($conf->api->enabled) && empty($conf->webservices->enabled)) { print '
'; } if (!empty($conf->api->enabled)) { - print 'API_ENDPOINT_RULES = '.(empty($conf->global->API_ENDPOINT_RULES) ? ''.$langs->trans("Undefined").'   ('.$langs->trans("Example").': login:0,users:0,setup:1,status:1,tickets:1,...)' : $conf->global->API_ENDPOINT_RULES)."
\n"; + print 'API_ENDPOINT_RULES = '.getDolGlobalString('API_ENDPOINT_RULES', ''.$langs->trans("Undefined").'   ('.$langs->trans("Example").': login:0,users:0,setup:1,status:1,tickets:1,...)')."
\n"; print '
'; } } @@ -501,19 +507,19 @@ print '
'; print load_fiche_titre($langs->trans("OtherSetup"), '', 'folder'); -print 'MAIN_ALLOW_SVG_FILES_AS_IMAGES = '.(empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES) ? '0' : $conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES).'   ('.$langs->trans("Recommended").': 0)
'; +print 'MAIN_ALLOW_SVG_FILES_AS_IMAGES = '.getDolGlobalString('MAIN_ALLOW_SVG_FILES_AS_IMAGES', '0').'   ('.$langs->trans("Recommended").': 0)
'; print '
'; -print 'MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE = '.(empty($conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE).'   ('.$langs->trans("Recommended").': 1)
'; +print 'MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE = '.getDolGlobalString('MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE', ''.$langs->trans("Undefined").'').'   ('.$langs->trans("Recommended").': 1)
'; print '
'; //print ''.$langs->trans("PasswordEncryption").': '; -print 'MAIN_SECURITY_HASH_ALGO = '.(empty($conf->global->MAIN_SECURITY_HASH_ALGO) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_HASH_ALGO)."   "; +print 'MAIN_SECURITY_HASH_ALGO = '.getDolGlobalString('MAIN_SECURITY_HASH_ALGO', ''.$langs->trans("Undefined").'')."   "; if (empty($conf->global->MAIN_SECURITY_HASH_ALGO)) { print '     If unset: \'md5\''; } if ($conf->global->MAIN_SECURITY_HASH_ALGO != 'password_hash') { - print '
MAIN_SECURITY_SALT = '.(empty($conf->global->MAIN_SECURITY_SALT) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_SALT).'
'; + print '
MAIN_SECURITY_SALT = '.getDolGlobalString('MAIN_SECURITY_SALT', ''.$langs->trans("Undefined").'').'
'; } else { print '('.$langs->trans("Recommended").': password_hash)'; print '
'; @@ -528,10 +534,10 @@ if ($conf->global->MAIN_SECURITY_HASH_ALGO != 'password_hash') { } print '
'; -print 'MAIN_SECURITY_ANTI_SSRF_SERVER_IP = '.(empty($conf->global->MAIN_SECURITY_ANTI_SSRF_SERVER_IP) ? ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': List of static IPs of server separated with coma - '.$langs->trans("Note").': common loopback ip like 127.*.*.*, [::1] are already added)' : $conf->global->MAIN_SECURITY_ANTI_SSRF_SERVER_IP)."
"; +print 'MAIN_SECURITY_ANTI_SSRF_SERVER_IP = '.getDolGlobalString('MAIN_SECURITY_ANTI_SSRF_SERVER_IP', ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': List of static IPs of server separated with coma - '.$langs->trans("Note").': common loopback ip like 127.*.*.*, [::1] are already added)')."
"; print '
'; -print 'MAIN_SECURITY_CSRF_WITH_TOKEN = '.(empty($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN).'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 2)'."
"; +print 'MAIN_SECURITY_CSRF_WITH_TOKEN = '.getDolGlobalString('MAIN_SECURITY_CSRF_WITH_TOKEN', ''.$langs->trans("Undefined").'').'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 2)'."
"; print '
'; print '
'; @@ -559,31 +565,32 @@ if ($execmethod == 2) { print '
'; print '
'; -print 'MAIN_RESTRICTHTML_ONLY_VALID_HTML = '.(empty($conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML) ? ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': 1)' : $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML)."
"; +print 'MAIN_RESTRICTHTML_ONLY_VALID_HTML = '.getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML', ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': 1)')."
"; print '
'; -print 'MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = '.(empty($conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES) ? ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': 1)' : $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES)."
"; +print 'MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = '.getDolGlobalString('MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES', ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': 1)')."
"; print '
'; -print 'MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL = '.(empty($conf->global->MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL) ? ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0)' : $conf->global->MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL)."
"; +print 'MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL = '.getDolGlobalString('MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL', ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0)')."
"; print '
'; -print 'MAIN_SECURITY_FORCECSP = '.(empty($conf->global->MAIN_SECURITY_FORCECSP) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_FORCECSP).'   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self'; img-src *;\")
"; +print 'MAIN_SECURITY_FORCECSP = '.getDolGlobalString('MAIN_SECURITY_FORCECSP', ''.$langs->trans("Undefined").'').'   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self'; img-src *;\")
"; print '
'; -print 'MAIN_SECURITY_FORCERP = '.(empty($conf->global->MAIN_SECURITY_FORCERP) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_FORCERP).'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"same-origin\" so browser doesn't send any referrer when going into another web site domain)
"; +print 'MAIN_SECURITY_FORCERP = '.getDolGlobalString('MAIN_SECURITY_FORCERP', ''.$langs->trans("Undefined").'').'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"same-origin\" so browser doesn't send any referrer when going into another web site domain)
"; print '
'; -print 'WEBSITE_MAIN_SECURITY_FORCECSP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCECSP) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCECSP).'   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self'; style-src https://cdnjs.cloudflare.com https://fonts.googleapis.com; script-src https://cdn.transifex.com https://www.googletagmanager.com; object-src https://youtube.com; frame-src https://youtube.com; img-src *;\")
"; +print 'WEBSITE_MAIN_SECURITY_FORCECSP = '.getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCECSP', ''.$langs->trans("Undefined").''); +print '   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self'; style-src https://cdnjs.cloudflare.com https://fonts.googleapis.com; script-src https://cdn.transifex.com https://www.googletagmanager.com; object-src https://youtube.com; frame-src https://youtube.com; img-src *;\")
"; print '
'; -print 'WEBSITE_MAIN_SECURITY_FORCERP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCERP) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCERP).'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"strict-origin-when-cross-origin\")
"; +print 'WEBSITE_MAIN_SECURITY_FORCERP = '.getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCERP', ''.$langs->trans("Undefined").'').'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"strict-origin-when-cross-origin\")
"; print '
'; -print 'WEBSITE_MAIN_SECURITY_FORCESTS = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCESTS) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCESTS).'   ('.$langs->trans("Example").": \"max-age=31536000; includeSubDomains\")
"; +print 'WEBSITE_MAIN_SECURITY_FORCESTS = '.getDolGlobalString('>WEBSITE_MAIN_SECURITY_FORCESTS', ''.$langs->trans("Undefined").'').'   ('.$langs->trans("Example").": \"max-age=31536000; includeSubDomains\")
"; print '
'; -print 'WEBSITE_MAIN_SECURITY_FORCEPP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCEPP) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCEPP).'   ('.$langs->trans("Example").": \"camera: 'none'; microphone: 'none';\")
"; +print 'WEBSITE_MAIN_SECURITY_FORCEPP = '.getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCEPP', ''.$langs->trans("Undefined").'').'   ('.$langs->trans("Example").": \"camera: 'none'; microphone: 'none';\")
"; print '
'; print '
'; @@ -598,16 +605,13 @@ print ''; print '
'; $urlexamplebase = 'https://github.com/Dolibarr/dolibarr/blob/develop/dev/setup/fail2ban/filter.d/'; print '- Login process (see fail2ban example on GitHub)
'; -print '- '.DOL_URL_ROOT.'/passwordforgotten.php (see fail2ban example on GitHub)
'; +print '- '.DOL_URL_ROOT.'/passwordforgotten.php (see fail2ban example on GitHub)
'; print '- '.DOL_URL_ROOT.'/public/* (see fail2ban example on GitHub)
'; print '
'; $urlexamplebase = 'https://github.com/Dolibarr/dolibarr/blob/develop/dev/setup/apache/'; print '- You can also protect the application using a HTTP Basic authentication layer (see apache2 virtualhost example on GitHub)
'; - - - // End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index 9cebbc3b36d..6a6201642ee 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -47,7 +47,7 @@ $scandir = GETPOST('scandir', 'alpha'); $type = 'ticket'; $error = 0; - +$reg = array(); /* * Actions @@ -56,10 +56,10 @@ $error = 0; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstticket = GETPOST('maskconstticket', 'alpha'); + $maskconstticket = GETPOST('maskconstticket', 'aZ09'); $maskticket = GETPOST('maskticket', 'alpha'); - if ($maskconstticket) { + if ($maskconstticket && preg_match('/_MASK$/', $maskconstticket)) { $res = dolibarr_set_const($db, $maskconstticket, $maskticket, 'chaine', 0, '', $conf->entity); } @@ -484,7 +484,7 @@ foreach ($dirmodels as $reldir) { // Preview print ''; print ''; print ''; print ''; print ''; print '"; print ''; print ''; print ''; print '"; print ''; print ''; } diff --git a/htdocs/admin/workstation.php b/htdocs/admin/workstation.php index bdd7ba662cd..314e6d13a91 100644 --- a/htdocs/admin/workstation.php +++ b/htdocs/admin/workstation.php @@ -63,11 +63,11 @@ if (!$user->admin) { include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstorder = GETPOST('maskconstWorkstation', 'alpha'); + $maskconst = GETPOST('maskconstWorkstation', 'aZ09'); $maskorder = GETPOST('maskWorkstation', 'alpha'); - if ($maskconstorder) { - $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity); + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { + $res = dolibarr_set_const($db, $maskconst, $maskorder, 'chaine', 0, '', $conf->entity); } if (!($res > 0)) { diff --git a/htdocs/api/admin/index.php b/htdocs/api/admin/index.php index b9548c7f69e..d618c65836b 100644 --- a/htdocs/api/admin/index.php +++ b/htdocs/api/admin/index.php @@ -71,7 +71,7 @@ if ($action == 'setproductionmode') { } // Disable compression mode -if ($action == 'setdisablecomprssion') { +if ($action == 'setdisablecompression') { $status = GETPOST('status', 'alpha'); if (dolibarr_set_const($db, 'API_DISABLE_COMPRESSION', $status, 'chaine', 0, '', 0) > 0) { @@ -118,11 +118,11 @@ print ''; print ''; $production_mode = (empty($conf->global->API_PRODUCTION_MODE) ?false:true); if ($production_mode) { - print ''; } else { - print ''; } @@ -133,11 +133,11 @@ print ''; print ''; $disable_compression = (empty($conf->global->API_DISABLE_COMPRESSION) ?false:true); if ($disable_compression) { - print ''; } else { - print ''; } diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 9dcd168f344..e06cdeb0312 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -319,8 +319,8 @@ class Setup extends DolibarrApi /** * Get state by ID. * - * @param int $id ID of state - * @return array Array of cleaned object properties + * @param int $id ID of state + * @return Object Object with cleaned properties * * @url GET dictionary/states/{id} * @@ -334,8 +334,8 @@ class Setup extends DolibarrApi /** * Get state by Code. * - * @param string $code Code of state - * @return array Array of cleaned object properties + * @param string $code Code of state + * @return Object Object with cleaned properties * * @url GET dictionary/states/byCode/{code} * @@ -424,10 +424,9 @@ class Setup extends DolibarrApi /** * Get country by ID. * - * @param int $id ID of country - * @param string $lang Code of the language the name of the - * country must be translated to - * @return array Array of cleaned object properties + * @param int $id ID of country + * @param string $lang Code of the language the name of the country must be translated to + * @return Object Object with cleaned properties * * @url GET dictionary/countries/{id} * @@ -441,10 +440,9 @@ class Setup extends DolibarrApi /** * Get country by Code. * - * @param string $code Code of country (2 characters) - * @param string $lang Code of the language the name of the - * country must be translated to - * @return array Array of cleaned object properties + * @param string $code Code of country (2 characters) + * @param string $lang Code of the language the name of the country must be translated to + * @return Object Object with cleaned properties * * @url GET dictionary/countries/byCode/{code} * @@ -458,10 +456,9 @@ class Setup extends DolibarrApi /** * Get country by Iso. * - * @param string $iso ISO of country (3 characters) - * @param string $lang Code of the language the name of the - * country must be translated to - * @return array Array of cleaned object properties + * @param string $iso ISO of country (3 characters) + * @param string $lang Code of the language the name of the country must be translated to + * @return Object Object with cleaned properties * * @url GET dictionary/countries/byISO/{iso} * @@ -475,9 +472,9 @@ class Setup extends DolibarrApi /** * Get state. * - * @param int $id ID of state - * @param string $code Code of state - * @return array Array of cleaned object properties + * @param int $id ID of state + * @param string $code Code of state + * @return Object Object with cleaned properties * * @throws RestException */ @@ -498,12 +495,11 @@ class Setup extends DolibarrApi /** * Get country. * - * @param int $id ID of country - * @param string $code Code of country (2 characters) - * @param string $iso ISO of country (3 characters) - * @param string $lang Code of the language the name of the - * country must be translated to - * @return array Array of cleaned object properties + * @param int $id ID of country + * @param string $code Code of country (2 characters) + * @param string $iso ISO of country (3 characters) + * @param string $lang Code of the language the name of the country must be translated to + * @return Object Object with cleaned properties * * @throws RestException */ @@ -527,12 +523,12 @@ class Setup extends DolibarrApi /** * Get the list of delivery times. * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Number of items per page - * @param int $page Page number {@min 0} - * @param int $active Delivery times is active or not {@min 0} {@max 1} - * @param string $sqlfilters SQL criteria to filter with. + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Number of items per page + * @param int $page Page number {@min 0} + * @param int $active Delivery times is active or not {@min 0} {@max 1} + * @param string $sqlfilters SQL criteria to filter with. * * @url GET dictionary/availability * @@ -592,8 +588,8 @@ class Setup extends DolibarrApi /** * Clean sensible object datas * - * @param Object $object Object to clean - * @return Object Object with cleaned properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { @@ -1786,8 +1782,8 @@ class Setup extends DolibarrApi /** * Get establishment by ID. * - * @param int $id ID of establishment - * @return array Array of cleaned object properties + * @param int $id ID of establishment + * @return Object Object with cleaned properties * * @url GET establishments/{id} * @@ -1813,7 +1809,7 @@ class Setup extends DolibarrApi * Note that conf variables that stores security key or password hashes can't be loaded with API. * * @param string $constantname Name of conf variable to get - * @return array|mixed Data without useless information + * @return string Data without useless information * * @url GET conf/{constantname} * @@ -1825,7 +1821,7 @@ class Setup extends DolibarrApi global $conf; if (!DolibarrApiAccess::$user->admin - && (empty($conf->global->API_LOGINS_ALLOWED_FOR_CONST_READ) || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_CONST_READ)) { + && (!getDolGlobalString('API_LOGINS_ALLOWED_FOR_CONST_READ') || DolibarrApiAccess::$user->login != getDolGlobalString('API_LOGINS_ALLOWED_FOR_CONST_READ'))) { throw new RestException(403, 'Error API open to admin users only or to the users with logins defined into constant API_LOGINS_ALLOWED_FOR_CONST_READ'); } @@ -1836,7 +1832,7 @@ class Setup extends DolibarrApi throw new RestException(403, 'Forbidden. This parameter cant be read with APIs'); } - return $conf->global->$constantname; + return getDolGlobalString($constantname); } /** diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 085dd338e69..ba195b82c08 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -413,9 +413,9 @@ $result = $api->r->handle(); if (Luracast\Restler\Defaults::$returnResponse) { // We try to compress the data received data - if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'br') !== false && is_callable('brotli_compress')) { + if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'br') !== false && is_callable('brotli_compress') && defined('BROTLI_TEXT')) { header('Content-Encoding: br'); - $result = brotli_compress($result, 11, BROTLI_TEXT); + $result = brotli_compress($result, 11, constant('BROTLI_TEXT')); } elseif (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'bz') !== false && is_callable('bzcompress')) { header('Content-Encoding: bz'); $result = bzcompress($result, 9); diff --git a/htdocs/asset/admin/setup.php b/htdocs/asset/admin/setup.php index 67448b0e304..1b107746319 100644 --- a/htdocs/asset/admin/setup.php +++ b/htdocs/asset/admin/setup.php @@ -68,16 +68,14 @@ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); * Actions */ -if ((float) DOL_VERSION >= 6) { - include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -} +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstorder = GETPOST('maskconstorder', 'alpha'); - $maskorder = GETPOST('maskorder', 'alpha'); + $maskconst = GETPOST('maskconst', 'alpha'); + $mask = GETPOST('mask', 'alpha'); - if ($maskconstorder) { - $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity); + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { + $res = dolibarr_set_const($db, $maskconst, $mask, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; } @@ -206,7 +204,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { } if ($myTmpObjectArray['includerefgeneration']) { /* - * Orders Numbering model + * Assets Numbering model */ $setupnotempty++; @@ -475,14 +473,14 @@ if ($action == 'edit') { if ($val['type'] == 'textarea') { print '\n"; } elseif ($val['type']== 'html') { require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); $doleditor->Create(); } elseif ($val['type'] == 'yesno') { - print $form->selectyesno($constname, $conf->global->{$constname}, 1); + print $form->selectyesno($constname, getDolGlobalString($constname), 1); } elseif (preg_match('/emailtemplate:/', $val['type'])) { include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($db); @@ -502,7 +500,7 @@ if ($action == 'edit') { $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)) . $moreonlabel; } } - print $form->selectarray($constname, $arrayofmessagename, $conf->global->{$constname}, 'None', 0, 0, '', 0, 0, 0, '', '', 1); + print $form->selectarray($constname, $arrayofmessagename, getDolGlobalString($constname), 'None', 0, 0, '', 0, 0, 0, '', '', 1); } elseif (preg_match('/category:/', $val['type'])) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; @@ -510,11 +508,11 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); print img_picto('', 'category', 'class="pictofixedwidth"'); - print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort')); + print $formother->select_categories($tmp[1], getDolGlobalString($constname), $constname, 0, $langs->trans('CustomersProspectsCategoriesShort')); } elseif (preg_match('/thirdparty_type/', $val['type'])) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $formcompany = new FormCompany($db); - print $formcompany->selectProspectCustomerType($conf->global->{$constname}, $constname); + print $formcompany->selectProspectCustomerType(getDolGlobalString($constname), $constname); } elseif ($val['type'] == 'securekey') { print ''; if (!empty($conf->use_javascript_ajax)) { @@ -526,11 +524,11 @@ if ($action == 'edit') { print dolJSToSetRandomPassword($constname, 'generate_token'.$constname); } elseif ($val['type'] == 'product') { if (isModEnabled("product") || isModEnabled("service")) { - $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); + $selected = getDolGlobalString($constname); $form->select_produits($selected, $constname, '', 0); } } elseif ($val['type'] == 'accountancy_code') { - $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); + $selected = getDolGlobalString($constname); if (isModEnabled('accounting')) { require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; $formaccounting = new FormAccounting($db); @@ -539,7 +537,7 @@ if ($action == 'edit') { print ''; } } elseif ($val['type'] == 'accountancy_category') { - $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); + $selected = getDolGlobalString($constname); if (isModEnabled('accounting')) { print ''; // autosuggest from existing account types if found @@ -589,9 +587,9 @@ if ($action == 'edit') { print ''; - echo ''; + echo ''; echo ''; echo ''; echo ''; // Status print ''; // Status note @@ -530,7 +533,7 @@ if (is_array($blocks)) { print ''; // Date - print ''; + print ''; // User print ''."\n"; diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 24604388af1..84b051d24f3 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -74,7 +74,7 @@ if ($action == 'presend') { $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang($newlang); // Load traductions files required by page - $outputlangs->loadLangs(array('commercial', 'bills', 'orders', 'contracts', 'members', 'propal', 'products', 'supplier_proposal', 'interventions', 'receptions')); + $outputlangs->loadLangs(array('commercial', 'bills', 'orders', 'contracts', 'members', 'propal', 'products', 'supplier_proposal', 'interventions', 'receptions', 'sendings')); } $topicmail = ''; diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 9d9bd226fd6..25e0f914807 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -280,9 +280,6 @@ print ''; print '
'."\n"; print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("Parameters").''.$langs->trans("Value").'
'; print $langs->trans("RECEPTION_PDF_HIDE_ORDERED"); diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index ef20ab6e205..42c766d1a22 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -227,7 +227,7 @@ if ($result) { // Tick if ($obj->bydefault == 1) { print ''; - print ''; + print ''; //print img_edit_remove(); print img_picto('', 'switch_on'); print ''; diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 7883cc7da20..10044e33b5b 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -58,9 +58,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; $error = 0; if ($action == 'updateMask') { - $maskconstpropal = GETPOST('maskconstpropal', 'alpha'); + $maskconstpropal = GETPOST('maskconstpropal', 'aZ09'); $maskpropal = GETPOST('maskpropal', 'alpha'); - if ($maskconstpropal) { + if ($maskconstpropal && preg_match('/_MASK$/', $maskconstpropal)) { $res = dolibarr_set_const($db, $maskconstpropal, $maskpropal, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/reception_setup.php b/htdocs/admin/reception_setup.php index c86db66e464..32f6c5b226e 100644 --- a/htdocs/admin/reception_setup.php +++ b/htdocs/admin/reception_setup.php @@ -65,9 +65,9 @@ if (empty($conf->global->RECEPTION_ADDON_NUMBER)) { include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconstreception', 'alpha'); + $maskconst = GETPOST('maskconstreception', 'aZ09'); $maskvalue = GETPOST('maskreception', 'alpha'); - if (!empty($maskconst)) { + if (!empty($maskconst) && preg_match('/_MASK$/', $maskconst)) { $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 33344363cf7..e30e50769bb 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -56,8 +56,8 @@ if ($action == 'activate_encrypt') { $db->begin(); - // On old version a bug created the constant into user entity, so we delete it to be sure, such entry won't exists. We want it in entity 0 or nowhere. - dolibarr_del_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity); + // On old version, a bug created the constant into user entity, so we delete it to be sure such entry won't exists. We want it in entity 0 or nowhere. + dolibarr_del_const($db, "DATABASE_PWD_ENCRYPTED", $conf->entity); // We set entity=0 (all) because DATABASE_PWD_ENCRYPTED is a setup into conf file, so always shared for everybody $entityforall = 0; dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $entityforall); diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 8aaf76d310b..7a7e49a3129 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -211,7 +211,11 @@ print ''.$langs->trans("DeStockOnBill").''; if (isModEnabled('facture')) { if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_BILL', array(), null, 0, 0, 0, 2, 1); + if ($disabled) { + print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"'); + } else { + print ajax_constantonoff('STOCK_CALCULATE_ON_BILL', array(), null, 0, 0, 0, 2, 1, 0, '', '', 'reposition'); + } } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STOCK_CALCULATE_ON_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_BILL); @@ -228,7 +232,11 @@ print ''.$langs->trans("DeStockOnValidateOrder").''; if (isModEnabled('commande')) { if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1); + if ($disabled) { + print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"'); + } else { + print ajax_constantonoff('STOCK_CALCULATE_ON_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition'); + } } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STOCK_CALCULATE_ON_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER); @@ -239,7 +247,7 @@ if (isModEnabled('commande')) { print "
'.$langs->trans("DeStockOnShipment").''; if (isModEnabled("expedition")) { if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT', array(), null, 0, 0, 0, 2, 1); + print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT); @@ -264,7 +272,7 @@ print ''.$langs->trans("DeStockOnShipmentOnClosing").''; if (isModEnabled("expedition")) { if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT_CLOSE', array(), null, 0, 0, 0, 2, 1); + print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT_CLOSE', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE); @@ -295,7 +303,11 @@ print ''.$langs->trans("ReStockOnBill").''; if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL', array(), null, 0, 0, 0, 2, 1); + if ($disabled) { + print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"'); + } else { + print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition'); + } } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL); @@ -313,7 +325,11 @@ print ''.$langs->trans("ReStockOnValidateOrder").''; if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1); + if ($disabled) { + print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"'); + } else { + print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition'); + } } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER); @@ -330,7 +346,7 @@ if (isModEnabled("reception")) { print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION', array(), null, 0, 0, 0, 2, 1); + print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION); @@ -345,7 +361,7 @@ if (isModEnabled("reception")) { print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION_CLOSE', array(), null, 0, 0, 0, 2, 1); + print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION_CLOSE', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE); @@ -358,7 +374,7 @@ if (isModEnabled("reception")) { print ''; if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', array(), null, 0, 0, 0, 2, 1); + print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER); diff --git a/htdocs/admin/stocktransfer.php b/htdocs/admin/stocktransfer.php index 3bcd00c1fe8..02c73bb2a76 100644 --- a/htdocs/admin/stocktransfer.php +++ b/htdocs/admin/stocktransfer.php @@ -64,10 +64,10 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconststocktransfer = GETPOST('maskconststocktransfer', 'alpha'); + $maskconststocktransfer = GETPOST('maskconststocktransfer', 'aZ09'); $maskstocktransfer = GETPOST('maskStockTransfer', 'alpha'); - if ($maskconststocktransfer) { + if ($maskconststocktransfer && preg_match('/_MASK$/', $maskconststocktransfer)) { $res = dolibarr_set_const($db, $maskconststocktransfer, $maskstocktransfer, 'chaine', 0, '', $conf->entity); if ($res <= 0) $error++; } diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index 3524111c96e..bbb97e293fe 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -38,10 +38,6 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "other", "orders")); -if (!$user->admin) { - accessforbidden(); -} - $type = GETPOST('type', 'alpha'); $value = GETPOST('value', 'alpha'); $action = GETPOST('action', 'aZ09'); @@ -52,26 +48,34 @@ $scandir = GETPOST('scan_dir', 'alpha'); $specimenthirdparty = new Societe($db); $specimenthirdparty->initAsSpecimen(); +$error = 0; + +if (!$user->admin) { + accessforbidden(); +} + /* * Actions */ +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + if ($action == 'updateMask') { - $maskconstinvoice = GETPOST('maskconstinvoice', 'alpha'); - $maskconstcredit = GETPOST('maskconstcredit', 'alpha'); - $maskconstdeposit = GETPOST('maskconstdeposit', 'alpha'); + $maskconstinvoice = GETPOST('maskconstinvoice', 'aZ09'); + $maskconstcredit = GETPOST('maskconstcredit', 'aZ09'); + $maskconstdeposit = GETPOST('maskconstdeposit', 'aZ09'); $maskinvoice = GETPOST('maskinvoice', 'alpha'); $maskcredit = GETPOST('maskcredit', 'alpha'); $maskdeposit = GETPOST('maskdeposit', 'alpha'); - if ($maskconstinvoice) { + if ($maskconstinvoice && preg_match('/_MASK$/', $maskconstinvoice)) { $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity); } - if ($maskconstcredit) { + if ($maskconstcredit && preg_match('/_MASK$/', $maskconstcredit)) { $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity); } - if ($maskconstdeposit) { + if ($maskconstdeposit && preg_match('/_MASK$/', $maskconstdeposit)) { $res = dolibarr_set_const($db, $maskconstdeposit, $maskdeposit, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index bb1b94d4385..abee8200cef 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -61,10 +61,10 @@ $specimenthirdparty->initAsSpecimen(); include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstorder = GETPOST('maskconstorder', 'alpha'); + $maskconstorder = GETPOST('maskconstorder', 'aZ09'); $maskvalue = GETPOST('maskorder', 'alpha'); - if ($maskconstorder) { + if ($maskconstorder && preg_match('/_MASK$/', $maskconstorder)) { $res = dolibarr_set_const($db, $maskconstorder, $maskvalue, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php index 86fcccfb8f2..ac00e4846ac 100644 --- a/htdocs/admin/supplier_payment.php +++ b/htdocs/admin/supplier_payment.php @@ -52,9 +52,9 @@ $type = 'supplier_payment'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstsupplierpayment = GETPOST('maskconstsupplierpayment', 'alpha'); + $maskconstsupplierpayment = GETPOST('maskconstsupplierpayment', 'aZ09'); $masksupplierpayment = GETPOST('masksupplierpayment', 'alpha'); - if ($maskconstsupplierpayment) { + if ($maskconstsupplierpayment && preg_match('/_MASK$/', $maskconstsupplierpayment)) { $res = dolibarr_set_const($db, $maskconstsupplierpayment, $masksupplierpayment, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 993e19fc796..62be111449d 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -55,9 +55,9 @@ $error = 0; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstsupplier_proposal = GETPOST('maskconstsupplier_proposal', 'alpha'); + $maskconstsupplier_proposal = GETPOST('maskconstsupplier_proposal', 'aZ09'); $masksupplier_proposal = GETPOST('masksupplier_proposal', 'alpha'); - if ($maskconstsupplier_proposal) { + if ($maskconstsupplier_proposal && preg_match('/_MASK$/', $maskconstsupplier_proposal)) { $res = dolibarr_set_const($db, $maskconstsupplier_proposal, $masksupplier_proposal, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 71f7fd7f875..cf07dd49539 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -115,9 +115,6 @@ if ($action == 'set') { // Check configuration foreach ($activeModules as $modulename) { - /** - * @var LogHandler - */ $module = new $modulename; $error = $module->checkConfiguration(); } diff --git a/htdocs/admin/system/database.php b/htdocs/admin/system/database.php index 8cd1ad3d597..fd983a10924 100644 --- a/htdocs/admin/system/database.php +++ b/htdocs/admin/system/database.php @@ -113,7 +113,8 @@ if (!count($listofvars) && !count($listofstatus)) { if ($key != $param) { continue; } - $val2 = ${$val['var']}; + $tmpvar = $val['var']; + $val2 = ${$tmpvar}; $text = 'Should be in line with value of param '.$val['var'].' thas is '.($val2 ? $val2 : "'' (=".$val['valifempty'].")").''; $show = 1; } diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 4a55c1a1160..afe5d4d3520 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -264,7 +264,7 @@ $daylight = round($c - $b); $val = ($a >= 0 ? '+' : '').$a; $val .= ' ('.($a == 'unknown' ? 'unknown' : ($a >= 0 ? '+' : '').($a * 3600)).')'; $val .= '       '.getServerTimeZoneString(); -$val .= '       '.$langs->trans("DaylingSavingTime").': '.($daylight === 'unknown' ? 'unknown' : ($a == $c ?yn($daylight) : yn(0).($daylight ? '     ('.$langs->trans('YesInSummer').')' : ''))); +$val .= '       '.$langs->trans("DaylingSavingTime").': '.(is_null($daylight) ? 'unknown' : ($a == $c ?yn($daylight) : yn(0).($daylight ? '     ('.$langs->trans('YesInSummer').')' : ''))); print $form->textwithtooltip($val, $txt, 2, 1, img_info('')); print '
  => '.$langs->trans("CurrentHour").''.dol_print_date(dol_now('gmt'), 'dayhour', 'tzserver').'
'; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'pdf').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } @@ -526,7 +526,7 @@ if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $formcategory->selectarray("TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND", $arrval, $conf->global->TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND); + print $formcategory->selectarray("TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND", $arrval, getDolGlobalString('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND')); } print ''; @@ -542,7 +542,7 @@ if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_AUTO_ASSIGN_USER_CREATE'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $formcategory->selectarray("TICKET_AUTO_ASSIGN_USER_CREATE", $arrval, $conf->global->TICKET_AUTO_ASSIGN_USER_CREATE); + print $formcategory->selectarray("TICKET_AUTO_ASSIGN_USER_CREATE", $arrval, getDolGlobalString('TICKET_AUTO_ASSIGN_USER_CREATE')); } print ''; @@ -557,7 +557,7 @@ if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_NOTIFY_AT_CLOSING'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $formcategory->selectarray("TICKET_NOTIFY_AT_CLOSING", $arrval, $conf->global->TICKET_NOTIFY_AT_CLOSING); + print $formcategory->selectarray("TICKET_NOTIFY_AT_CLOSING", $arrval, getDolGlobalString('TICKET_NOTIFY_AT_CLOSING')); } print ''; @@ -569,7 +569,7 @@ if (isModEnabled('product')) { $htmlname = "product_category_id"; print '
'.$langs->trans("TicketChooseProductCategory").''; - $formcategory->selectProductCategory($conf->global->TICKET_PRODUCT_CATEGORY, $htmlname); + $formcategory->selectProductCategory(getDolGlobalString('TICKET_PRODUCT_CATEGORY'), $htmlname); if ($conf->use_javascript_ajax) { print ajax_combobox('select_'.$htmlname); } @@ -583,7 +583,7 @@ if (isModEnabled('product')) { print '
'.$langs->trans("TicketsDelayBeforeFirstAnswer")." - + '; print $formcategory->textwithpicto('', $langs->trans("TicketsDelayBeforeFirstAnswerHelp"), 1, 'help'); @@ -593,7 +593,7 @@ print '
'.$langs->trans("TicketsDelayBetweenAnswers")." - + '; print $formcategory->textwithpicto('', $langs->trans("TicketsDelayBetweenAnswersHelp"), 1, 'help'); diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index abb5ebfd6ba..fcbc01abef1 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -427,7 +427,7 @@ if ($mode == 'overwrite') { print '   '; print ''; } else { - print ''.img_edit().''; + print ''.img_edit().''; print '   '; print ''.img_delete().''; } diff --git a/htdocs/admin/webhook.php b/htdocs/admin/webhook.php index b589eac4079..91d3358a92d 100644 --- a/htdocs/admin/webhook.php +++ b/htdocs/admin/webhook.php @@ -150,10 +150,10 @@ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconst', 'alpha'); + $maskconst = GETPOST('maskconst', 'aZ09'); $maskvalue = GETPOST('maskvalue', 'alpha'); - if ($maskconst) { + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; @@ -293,14 +293,14 @@ if ($action == 'edit') { if ($val['type'] == 'textarea') { print '\n"; } elseif ($val['type']== 'html') { require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); $doleditor->Create(); } elseif ($val['type'] == 'yesno') { - print $form->selectyesno($constname, $conf->global->{$constname}, 1); + print $form->selectyesno($constname, getDolGlobalString($constname), 1); } elseif (preg_match('/emailtemplate:/', $val['type'])) { include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($db); @@ -382,9 +382,9 @@ if ($action == 'edit') { print ''; if ($val['type'] == 'textarea') { - print dol_nl2br($conf->global->{$constname}); + print dol_nl2br(getDolGlobalString($constname)); } elseif ($val['type']== 'html') { - print $conf->global->{$constname}; + print getDolGlobalString($constname); } elseif ($val['type'] == 'yesno') { print ajax_constantonoff($constname); } elseif (preg_match('/emailtemplate:/', $val['type'])) { @@ -393,14 +393,14 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); - $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname}); + $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname)); if ($template<0) { setEventMessages(null, $formmail->errors, 'errors'); } print $langs->trans($template->label); } elseif (preg_match('/category:/', $val['type'])) { $c = new Categorie($db); - $result = $c->fetch($conf->global->{$constname}); + $result = $c->fetch(getDolGlobalString($constname)); if ($result < 0) { setEventMessages(null, $c->errors, 'errors'); } elseif ($result > 0 ) { @@ -412,25 +412,25 @@ if ($action == 'edit') { print '
    ' . implode(' ', $toprint) . '
'; } } elseif (preg_match('/thirdparty_type/', $val['type'])) { - if ($conf->global->{$constname}==2) { + if (getDolGlobalInt($constname)==2) { print $langs->trans("Prospect"); - } elseif ($conf->global->{$constname}==3) { + } elseif (getDolGlobalInt($constname)==3) { print $langs->trans("ProspectCustomer"); - } elseif ($conf->global->{$constname}==1) { + } elseif (getDolGlobalInt($constname)==1) { print $langs->trans("Customer"); - } elseif ($conf->global->{$constname}==0) { + } elseif (getDolGlobalInt($constname)==0) { print $langs->trans("NorProspectNorCustomer"); } } elseif ($val['type'] == 'product') { $product = new Product($db); - $resprod = $product->fetch($conf->global->{$constname}); + $resprod = $product->fetch(getDolGlobalInt($constname)); if ($resprod > 0) { print $product->ref; } elseif ($resprod < 0) { setEventMessages(null, $object->errors, "errors"); } } else { - print $conf->global->{$constname}; + print getDolGlobalString($constname); } print '
'.$langs->trans("ApiProductionMode").''; + print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print '
'.$langs->trans("API_DISABLE_COMPRESSION").''; + print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print ''; if ($val['type'] == 'textarea') { - print dol_nl2br($conf->global->{$constname}); + print dol_nl2br(getDolGlobalString($constname)); } elseif ($val['type']== 'html') { - print $conf->global->{$constname}; + print getDolGlobalString($constname); } elseif ($val['type'] == 'yesno') { print ajax_constantonoff($constname); } elseif (preg_match('/emailtemplate:/', $val['type'])) { @@ -600,14 +598,14 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); - $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname}); + $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname)); if ($template<0) { setEventMessages(null, $formmail->errors, 'errors'); } print $langs->trans($template->label); } elseif (preg_match('/category:/', $val['type'])) { $c = new Categorie($db); - $result = $c->fetch($conf->global->{$constname}); + $result = $c->fetch(getDolGlobalInt($constname)); if ($result < 0) { setEventMessages(null, $c->errors, 'errors'); } elseif ($result > 0 ) { @@ -619,18 +617,18 @@ if ($action == 'edit') { print '
    ' . implode(' ', $toprint) . '
'; } } elseif (preg_match('/thirdparty_type/', $val['type'])) { - if ($conf->global->{$constname}==2) { + if (getDolGlobalInt($constname)==2) { print $langs->trans("Prospect"); - } elseif ($conf->global->{$constname}==3) { + } elseif (getDolGlobalInt($constname)==3) { print $langs->trans("ProspectCustomer"); - } elseif ($conf->global->{$constname}==1) { + } elseif (getDolGlobalInt($constname)==1) { print $langs->trans("Customer"); - } elseif ($conf->global->{$constname}==0) { + } elseif (getDolGlobalInt($constname)==0) { print $langs->trans("NorProspectNorCustomer"); } } elseif ($val['type'] == 'product') { $product = new Product($db); - $resprod = $product->fetch($conf->global->{$constname}); + $resprod = $product->fetch(getDolGlobalInt($constname)); if ($resprod > 0) { print $product->ref; } elseif ($resprod < 0) { @@ -640,11 +638,11 @@ if ($action == 'edit') { if (isModEnabled('accounting')) { require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch('', $conf->global->{$constname}, 1); + $accountingaccount->fetch('', getDolGlobalString($constname), 1); print $accountingaccount->getNomUrl(0, 1, 1, '', 1); } else { - print $conf->global->{$constname}; + print getDolGlobalString($constname); } } else { print $conf->global->{$constname}; diff --git a/htdocs/asset/agenda.php b/htdocs/asset/agenda.php index b40ed122ec6..c86697b207d 100644 --- a/htdocs/asset/agenda.php +++ b/htdocs/asset/agenda.php @@ -46,7 +46,7 @@ if (GETPOST('actioncode', 'array')) { $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)); + $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -171,7 +171,7 @@ if ($object->id > 0) { if (get_class($objthirdparty) == 'Societe') { $out .= '&socid=' . urlencode($objthirdparty->id); } - $out .= (!empty($objcon->id) ? '&contactid=' . urlencode($objcon->id) : '') . '&percentage=-1'; + $out .= (!empty($objcon->id) ? '&contactid=' . urlencode($objcon->id) : ''); //$out.=$langs->trans("AddAnAction").' '; //$out.=img_picto($langs->trans("AddAnAction"),'filenew'); //$out.=""; @@ -181,7 +181,7 @@ if ($object->id > 0) { print '
'; if (isModEnabled('agenda')) { - if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { + if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { print '' . $langs->trans("AddAction") . ''; } else { print '' . $langs->trans("AddAction") . ''; diff --git a/htdocs/asset/model/agenda.php b/htdocs/asset/model/agenda.php index 17fb19fe565..8758d22879c 100644 --- a/htdocs/asset/model/agenda.php +++ b/htdocs/asset/model/agenda.php @@ -46,7 +46,7 @@ if (GETPOST('actioncode', 'array')) { $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)); + $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -173,7 +173,7 @@ if ($object->id > 0) { if (get_class($objthirdparty) == 'Societe') { $out .= '&socid=' . urlencode($objthirdparty->id); } - $out .= (!empty($objcon->id) ? '&contactid=' . urlencode($objcon->id) : '') . '&percentage=-1'; + $out .= (!empty($objcon->id) ? '&contactid=' . urlencode($objcon->id) : ''); //$out.=$langs->trans("AddAnAction").' '; //$out.=img_picto($langs->trans("AddAnAction"),'filenew'); //$out.=""; @@ -183,7 +183,7 @@ if ($object->id > 0) { print '
'; // if (isModEnabled('agenda')) { - // if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { + // if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { // print '' . $langs->trans("AddAction") . ''; // } else { // print '' . $langs->trans("AddAction") . ''; diff --git a/htdocs/asset/tpl/linkedobjectblock.tpl.php b/htdocs/asset/tpl/linkedobjectblock.tpl.php index aef30995432..11d94714db8 100644 --- a/htdocs/asset/tpl/linkedobjectblock.tpl.php +++ b/htdocs/asset/tpl/linkedobjectblock.tpl.php @@ -46,12 +46,12 @@ foreach ($linkedObjectBlock as $key => $objectlink) { $trclass .= ' liste_sub_total'; } echo '
'.$langs->trans("Asset"); + echo ''.$langs->trans("Asset"); if (!empty($showImportButton) && !empty($conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES)) { print ' '; - echo ''.$objectlink->getNomUrl(1).''.$objectlink->getNomUrl(1).''.$objectlink->label.''.dol_print_date($objectlink->date_start, 'day').''; diff --git a/htdocs/barcode/codeinit.php b/htdocs/barcode/codeinit.php index 8ce559031a1..9c45d29cf79 100644 --- a/htdocs/barcode/codeinit.php +++ b/htdocs/barcode/codeinit.php @@ -48,7 +48,7 @@ $thirdpartytmp = new Societe($db); $modBarCodeProduct = ''; $modBarCodeThirdparty = ''; -$maxperinit = 1000; +$maxperinit = empty($conf->global->BARCODE_INIT_MAX) ? 1000 : $conf->global->BARCODE_INIT_MAX; // Security check (enable the most restrictive one) //if ($user->socid > 0) accessforbidden(); @@ -179,14 +179,16 @@ if (!empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) { if (preg_match('/^mod_barcode_product_.*php$/', $file)) { $file = substr($file, 0, dol_strlen($file) - 4); - try { - dol_include_once($dirroot.$file.'.php'); - } catch (Exception $e) { - dol_syslog($e->getMessage(), LOG_ERR); - } + if ($file == $conf->global->BARCODE_PRODUCT_ADDON_NUM) { + try { + dol_include_once($dirroot.$file.'.php'); + } catch (Exception $e) { + dol_syslog($e->getMessage(), LOG_ERR); + } - $modBarCodeProduct = new $file(); - break; + $modBarCodeProduct = new $file(); + break; + } } } closedir($handle); diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index 9bb4456e840..b3b2a1d36f4 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -176,9 +176,9 @@ if ($action === 'downloadblockchain') { if (!$error) { // Now restart request with all data = no limit(1) in sql request - $sql = "SELECT rowid,date_creation,tms,user_fullname,action,amounts,element,fk_object,date_object,ref_object,signature,fk_user,object_data"; + $sql = "SELECT rowid, date_creation, tms, user_fullname, action, amounts, element, fk_object, date_object, ref_object, signature, fk_user, object_data, object_version"; $sql .= " FROM ".MAIN_DB_PREFIX."blockedlog"; - $sql .= " WHERE entity = ".$conf->entity; + $sql .= " WHERE entity = ".((int) $conf->entity); if (GETPOST('monthtoexport', 'int') > 0 || GETPOST('yeartoexport', 'int') > 0) { $dates = dol_get_first_day(GETPOST('yeartoexport', 'int'), GETPOST('monthtoexport', 'int') ?GETPOST('monthtoexport', 'int') : 1); $datee = dol_get_last_day(GETPOST('yeartoexport', 'int'), GETPOST('monthtoexport', 'int') ?GETPOST('monthtoexport', 'int') : 12); @@ -204,6 +204,7 @@ if ($action === 'downloadblockchain') { .';'.$langs->transnoentities('Fingerprint') .';'.$langs->transnoentities('Status') .';'.$langs->transnoentities('Note') + .';'.$langs->transnoentities('Version') .';'.$langs->transnoentities('FullData') ."\n"; @@ -226,6 +227,7 @@ if ($action === 'downloadblockchain') { $block_static->fk_user = $obj->fk_user; $block_static->signature = $obj->signature; $block_static->object_data = $block_static->dolDecodeBlockedData($obj->object_data); + $block_static->object_version = $obj->object_version; $checksignature = $block_static->checkSignature($previoushash); // If $previoushash is not defined, checkSignature will search it @@ -257,6 +259,7 @@ if ($action === 'downloadblockchain') { print ';'.$obj->signature; print ';'.$statusofrecord; print ';'.$statusofrecordnote; + print ';'.$obj->object_version; print ';"'.str_replace('"', '""', $obj->object_data).'"'; print "\n"; @@ -448,8 +451,8 @@ print ''; -$array = array("1"=>$langs->trans("OnlyNonValid")); -print $form->selectarray('search_showonlyerrors', $array, $search_showonlyerrors, 1); +$array = array("1" => "OnlyNonValid"); +print $form->selectarray('search_showonlyerrors', $array, $search_showonlyerrors, 1, 0, 0, '', 1, 0, 0, 'ASC', 'search_status maxwidth200 onrightofpage', 1); print ''.dol_escape_htmltag($block->id).''.dol_print_date($block->date_creation, 'dayhour').''.dol_print_date($block->date_creation, 'dayhour').''; diff --git a/htdocs/blockedlog/ajax/block-info.php b/htdocs/blockedlog/ajax/block-info.php index 9c2850608af..db0faa50cc1 100644 --- a/htdocs/blockedlog/ajax/block-info.php +++ b/htdocs/blockedlog/ajax/block-info.php @@ -57,7 +57,7 @@ $langs->loadLangs(array("admin")); top_httphead(); -print '
'; +print '
'.$langs->trans('Field').''.$langs->trans('Value').'
'; print ''; if ($block->fetch($id) > 0) { diff --git a/htdocs/blockedlog/class/authority.class.php b/htdocs/blockedlog/class/authority.class.php index 7240aaf0151..b3dd9b45f47 100644 --- a/htdocs/blockedlog/class/authority.class.php +++ b/htdocs/blockedlog/class/authority.class.php @@ -304,8 +304,8 @@ class BlockedLogAuthority $url = $conf->global->BLOCKEDLOG_AUTHORITY_URL.'/blockedlog/ajax/authority.php?s='.$signature.'&b='.$block->signature; $res = getURLContent($url); - echo $block->signature.' '.$url.' '.$res.'
'; - if ($res === 'blockalreadyadded' || $res === 'blockadded') { + echo $block->signature.' '.$url.' '.$res['content'].'
'; + if ($res['content'] === 'blockalreadyadded' || $res['content'] === 'blockadded') { $block->setCertified(); } else { $this->error = $langs->trans('ImpossibleToContactAuthority ', $url); diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 70ba9a2b531..3b6905fcc25 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -718,6 +718,10 @@ class BlockedLog } } + // A trick to be sure all the object_data is an associative array + // json_encode and json_decode are not able to manage mixed object (with array/object, only full arrays or full objects) + $this->object_data = json_decode(json_encode($this->object_data, JSON_FORCE_OBJECT), false); + return 1; } @@ -785,21 +789,42 @@ class BlockedLog } + /** + * Encode data + * + * @param string $data Data to serialize + * @param string $mode 0=serialize, 1=json_encode + * @return string Value serialized, an object (stdClass) + */ + public function dolEncodeBlockedData($data, $mode = 0) + { + try { + $aaa = json_encode($data); + } catch (Exception $e) { + //print $e->getErrs); + } + //var_dump($aaa); + + return $aaa; + } + + /** * Decode data * * @param string $data Data to unserialize * @param string $mode 0=unserialize, 1=json_decode - * @return string Value unserialized + * @return object Value unserialized, an object (stdClass) */ public function dolDecodeBlockedData($data, $mode = 0) { try { - //include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $aaa = unserialize($data); + $aaa = (object) jsonOrUnserialize($data); } catch (Exception $e) { //print $e->getErrs); } + //var_dump($aaa); + return $aaa; } @@ -864,6 +889,9 @@ class BlockedLog $this->date_creation = dol_now(); + $this->object_version = ((float) DOL_VERSION); + + $this->db->begin(); $previoushash = $this->getPreviousHash(1, 0); // This get last record and lock database until insert is done @@ -905,7 +933,7 @@ class BlockedLog $sql .= $this->fk_object.","; $sql .= "'".$this->db->idate($this->date_object)."',"; $sql .= "'".$this->db->escape($this->ref_object)."',"; - $sql .= "'".$this->db->escape(serialize($this->object_data))."',"; + $sql .= "'".$this->db->escape($this->dolEncodeBlockedData($this->object_data))."',"; $sql .= "'".$this->db->escape($this->object_version)."',"; $sql .= "0,"; $sql .= $this->fk_user.","; @@ -913,6 +941,14 @@ class BlockedLog $sql .= ($this->entity ? $this->entity : $conf->entity); $sql .= ")"; + /* + $a = serialize($this->object_data); $a2 = unserialize($a); $a4 = print_r($a2, true); + $b = json_encode($this->object_data); $b2 = json_decode($b); $b4 = print_r($b2, true); + var_dump($a4 == print_r($this->object_data, true) ? 'a=a' : 'a not = a'); + var_dump($b4 == print_r($this->object_data, true) ? 'b=b' : 'b not = b'); + exit; + */ + $res = $this->db->query($sql); if ($res) { $id = $this->db->last_insert_id(MAIN_DB_PREFIX."blockedlog"); @@ -952,7 +988,7 @@ class BlockedLog $keyforsignature = $this->buildKeyForSignature(); //$signature_line = dol_hash($keyforsignature, '5'); // Not really usefull - $signature = dol_hash($previoushash.$keyforsignature, '5'); + $signature = dol_hash($previoushash.$keyforsignature, 'sha256'); //var_dump($previoushash); var_dump($keyforsignature); var_dump($signature_line); var_dump($signature); $res = ($signature === $this->signature); @@ -984,8 +1020,8 @@ class BlockedLog private function buildKeyForSignature() { //print_r($this->object_data); - if (((int) $this->object_version) > 12) { - return $this->date_creation.'|'.$this->action.'|'.$this->amounts.'|'.$this->ref_object.'|'.$this->date_object.'|'.$this->user_fullname.'|'.print_r($this->object_data, true); + if (((int) $this->object_version) >= 18) { + return $this->date_creation.'|'.$this->action.'|'.$this->amounts.'|'.$this->ref_object.'|'.$this->date_object.'|'.$this->user_fullname.'|'.json_encode($this->object_data, JSON_FORCE_OBJECT); } else { return $this->date_creation.'|'.$this->action.'|'.$this->amounts.'|'.$this->ref_object.'|'.$this->date_object.'|'.$this->user_fullname.'|'.print_r($this->object_data, true); } @@ -1006,7 +1042,7 @@ class BlockedLog $previoussignature = ''; $sql = "SELECT rowid, signature FROM ".MAIN_DB_PREFIX."blockedlog"; - $sql .= " WHERE entity=".$conf->entity; + $sql .= " WHERE entity = ".((int) $conf->entity); if ($beforeid) { $sql .= " AND rowid < ".(int) $beforeid; } @@ -1067,7 +1103,7 @@ class BlockedLog WHERE entity=".$conf->entity." AND certified = 1"; } else { $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog - WHERE entity=".$conf->entity." AND element='".$this->db->escape($element)."'"; + WHERE entity=".$conf->entity." AND element = '".$this->db->escape($element)."'"; } if ($fk_object) { diff --git a/htdocs/bom/bom_agenda.php b/htdocs/bom/bom_agenda.php index f133d1bbd4b..c7fcf64fb47 100644 --- a/htdocs/bom/bom_agenda.php +++ b/htdocs/bom/bom_agenda.php @@ -49,7 +49,7 @@ if (GETPOST('actioncode', 'array')) { $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)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -215,7 +215,7 @@ if ($object->id > 0) { if (get_class($objthirdparty) == 'Societe') { $out .= '&socid='.$objthirdparty->id; } - $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&backtopage=1&percentage=-1'; + $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&backtopage=1'; //$out.=$langs->trans("AddAnAction").' '; //$out.=img_picto($langs->trans("AddAnAction"),'filenew'); //$out.=""; @@ -225,7 +225,7 @@ if ($object->id > 0) { print '
'; if (isModEnabled('agenda')) { - if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { + if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { print ''.$langs->trans("AddAction").''; } else { print ''.$langs->trans("AddAction").''; diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index 337ff51c3ef..1cb4946715a 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -42,6 +42,8 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bomlist'; // 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', 'alpha'); // mode view (kanban or common) + // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -433,6 +435,9 @@ llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', ''); $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); } @@ -483,8 +488,12 @@ print ''; print ''; print ''; print ''; +print ''; -$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/bom/bom_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->rights->bom->write); +$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 .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/bom/bom_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->rights->bom->write); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -553,9 +562,9 @@ foreach ($object->fields as $key => $val) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if (!empty($arrayfields['t.'.$key]['checked'])) { - print '
'; - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - 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'; + // mode view kanban + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + } + } else { + // Show here line of result + print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; - if (!$i) { - $totalarray['nbfield']++; + } + 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 (!empty($val['isameasure']) && $val['isameasure'] == 1) { + + 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 (!empty($arrayfields['t.'.$key]['checked'])) { + 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['pos'][$totalarray['nbfield']] = 't.'.$key; + $totalarray['nbfield']++; } - if (!isset($totalarray['val'])) { - $totalarray['val'] = array(); + 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; } - 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; - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; + } + if (!$i) { + $totalarray['nbfield']++; } - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - print ''."\n"; + print ''."\n"; - $i++; + $i++; + } } // Show total line diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php index fb7d175a229..e199650be30 100644 --- a/htdocs/bom/class/api_boms.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -205,6 +205,9 @@ class Boms extends DolibarrApi foreach ($request_data as $field => $value) { $this->bom->$field = $value; } + + $this->checkRefNumbering(); + if (!$this->bom->create(DolibarrApiAccess::$user)) { throw new RestException(500, "Error creating BOM", array_merge(array($this->bom->error), $this->bom->errors)); } @@ -241,6 +244,8 @@ class Boms extends DolibarrApi $this->bom->$field = $value; } + $this->checkRefNumbering(); + if ($this->bom->update(DolibarrApiAccess::$user) > 0) { return $this->get($id); } else { @@ -536,4 +541,27 @@ class Boms extends DolibarrApi } return $myobject; } + + /** + * Validate the ref field and get the next Number if it's necessary. + * + * @return void + */ + private function checkRefNumbering(): void + { + $ref = substr($this->bom->ref, 1, 4); + if ($this->bom->status > 0 && $ref == 'PROV') { + throw new RestException(400, "Wrong naming scheme '(PROV%)' is only allowed on 'DRAFT' status. For automatic increment use 'auto' on the 'ref' field."); + } + + if (strtolower($this->bom->ref) == 'auto') { + if (empty($this->bom->id) && $this->bom->status == 0) { + $this->bom->ref = ''; // 'ref' will auto incremented with '(PROV' + newID + ')' + } else { + $this->bom->fetch_product(); + $numref = $this->bom->getNextNumRef($this->bom->product); + $this->bom->ref = $numref; + } + } + } } diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index cd5b119cabf..79d2b57ebc8 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1329,7 +1329,7 @@ class BOM extends CommonObject * BOM costs calculation based on cost_price or pmp of each BOM line. * Set the property ->total_cost and ->unit_cost of BOM. * - * @return void + * @return int <0 if KO, >0 if OK */ public function calculateCosts() { @@ -1414,6 +1414,8 @@ class BOM extends CommonObject $this->unit_cost = price2num($this->total_cost * $this->qty, 'MU'); } } + + return 1; } /** @@ -1515,6 +1517,46 @@ class BOM extends CommonObject } } } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $db,$langs; + $prod = new Product($db); + $prod->fetch($this->fk_product); + + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : '').''; + if (property_exists($this, 'fields') && !empty($this->fields['bomtype']['arrayofkeyval'])) { + $return .= '
'.$langs->trans("Type").' : '; + if ($this->bomtype == 0) { + $return .= ''.$this->fields['bomtype']['arrayofkeyval'][0].''; + } else { + $return .= ''.$this->fields['bomtype']['arrayofkeyval'][1].''; + } + } + if (property_exists($this, 'fk_product') && !is_null($this->fk_product)) { + $return .= '
'.$prod->getNomUrl(1).''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/bom/tpl/linkedobjectblock.tpl.php b/htdocs/bom/tpl/linkedobjectblock.tpl.php index 8a98c078bc5..1765e9a84c1 100644 --- a/htdocs/bom/tpl/linkedobjectblock.tpl.php +++ b/htdocs/bom/tpl/linkedobjectblock.tpl.php @@ -47,12 +47,12 @@ foreach ($linkedObjectBlock as $key => $objectlink) { $trclass .= ' liste_sub_total'; } echo ''; - echo ''; + echo ''; echo ''; if ($filtertype != 1) { - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''; diff --git a/htdocs/bom/tpl/objectline_edit.tpl.php b/htdocs/bom/tpl/objectline_edit.tpl.php index 88463996ebc..969b210e89b 100644 --- a/htdocs/bom/tpl/objectline_edit.tpl.php +++ b/htdocs/bom/tpl/objectline_edit.tpl.php @@ -126,7 +126,7 @@ if (($line->info_bits & 2) != 2) { print ''; if ($filtertype != 1) { - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $coldisplay++; print ''; diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php index 5252baf61ca..0ede4190279 100644 --- a/htdocs/bom/tpl/objectline_title.tpl.php +++ b/htdocs/bom/tpl/objectline_title.tpl.php @@ -67,7 +67,7 @@ print ''; print ''; if ($filtertype != 1) { - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''; } diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index b7087b27288..d20692ac99a 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -119,7 +119,7 @@ echo price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but print ''; if ($filtertype != 1) { - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print '
'.$langs->trans('Field').''.$langs->trans('Value').'
'; + 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); + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status onrightofpage' : ''), 1); } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) { print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1); } elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) { @@ -648,90 +657,106 @@ while ($i < ($limit ? min($num, $limit) : $num)) { // Store properties in $object $object->setVarsFromFetchObj($obj); - // Show here line of result - 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 '
'; + print '
'; } - if (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif ($key == 'ref') { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } + print $object->getKanbanView(''); - 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 (!empty($arrayfields['t.'.$key]['checked'])) { - 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, ''); + if ($i == min($num, $limit)-1) { + print '
'; + 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 ($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; + // 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; + // Action column + if (!getDolGlobalString('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 ''; + print '
'.$langs->trans("Bom"); + echo ''.$langs->trans("Bom"); if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { print ' '; - echo ''.$objectlink->getNomUrl(1).''.$objectlink->getNomUrl(1).''; $result = $product_static->fetch($objectlink->fk_product); diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index e644c7813e7..96a179b93f3 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -73,7 +73,7 @@ if ($nolinesbefore) { print ''.$langs->trans('Qty').''; print ''; print $langs->trans('Unit'); @@ -145,7 +145,7 @@ print ''; print ''; print ''.$form->textwithpicto($langs->trans('Qty'), ($filtertype != 1) ? $langs->trans("QtyRequiredIfNoLoss") : '').'' . $langs->trans('Unit') . ''; $label = $tmpproduct->getLabelOfUnit('long'); if ($label !== '') { diff --git a/htdocs/bookcal/admin/about.php b/htdocs/bookcal/admin/about.php index 85f0efcdebb..2ff4e874450 100644 --- a/htdocs/bookcal/admin/about.php +++ b/htdocs/bookcal/admin/about.php @@ -23,32 +23,7 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../../main.inc.php'; // Libraries require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/bookcal/admin/availabilities_extrafields.php b/htdocs/bookcal/admin/availabilities_extrafields.php index 9d16d7b5395..ba7dca39570 100644 --- a/htdocs/bookcal/admin/availabilities_extrafields.php +++ b/htdocs/bookcal/admin/availabilities_extrafields.php @@ -27,32 +27,7 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once '../lib/bookcal.lib.php'; diff --git a/htdocs/bookcal/admin/booking_extrafields.php b/htdocs/bookcal/admin/booking_extrafields.php index 30122d95048..2e9163af158 100644 --- a/htdocs/bookcal/admin/booking_extrafields.php +++ b/htdocs/bookcal/admin/booking_extrafields.php @@ -27,32 +27,7 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once '../lib/bookcal.lib.php'; diff --git a/htdocs/bookcal/admin/setup.php b/htdocs/bookcal/admin/setup.php index c4fd74404eb..9772ffbbbf0 100644 --- a/htdocs/bookcal/admin/setup.php +++ b/htdocs/bookcal/admin/setup.php @@ -23,32 +23,7 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../../main.inc.php'; global $langs, $user; @@ -178,10 +153,10 @@ if ( versioncompare(explode('.', DOL_VERSION), array(15)) < 0 && $action == 'upd include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconst', 'alpha'); + $maskconst = GETPOST('maskconst', 'aZ09'); $maskvalue = GETPOST('maskvalue', 'alpha'); - if ($maskconst) { + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; diff --git a/htdocs/bookcal/availabilities_agenda.php b/htdocs/bookcal/availabilities_agenda.php index c3e66a17257..0d34fa992c1 100644 --- a/htdocs/bookcal/availabilities_agenda.php +++ b/htdocs/bookcal/availabilities_agenda.php @@ -22,63 +22,14 @@ * \brief Tab of events on Availabilities */ -//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('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//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("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('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 - // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +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'; -dol_include_once('/bookcal/class/availabilities.class.php'); -dol_include_once('/bookcal/lib/bookcal_availabilities.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/bookcal/class/availabilities.class.php'; +require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_availabilities.lib.php'; // Load translation files required by the page @@ -270,7 +221,7 @@ if ($object->id > 0) { if (get_class($objthirdparty) == 'Societe') { $out .= '&socid='.urlencode($objthirdparty->id); } - $out .= (!empty($objcon->id) ? '&contactid='.urlencode($objcon->id) : '').'&percentage=-1'; + $out .= (!empty($objcon->id) ? '&contactid='.urlencode($objcon->id) : ''); //$out.=$langs->trans("AddAnAction").' '; //$out.=img_picto($langs->trans("AddAnAction"),'filenew'); //$out.=""; @@ -280,7 +231,7 @@ if ($object->id > 0) { print '
'; if (isModEnabled('agenda')) { - if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { + if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { print ''.$langs->trans("AddAction").''; } else { print ''.$langs->trans("AddAction").''; diff --git a/htdocs/bookcal/availabilities_card.php b/htdocs/bookcal/availabilities_card.php index b9f5277d4ae..fd3c310958b 100644 --- a/htdocs/bookcal/availabilities_card.php +++ b/htdocs/bookcal/availabilities_card.php @@ -22,64 +22,14 @@ * \brief Page to create/edit/view availabilities */ -//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('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token). -//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("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('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 - // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +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'; -dol_include_once('/bookcal/class/availabilities.class.php'); -dol_include_once('/bookcal/lib/bookcal_availabilities.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/bookcal/class/availabilities.class.php'; +require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_availabilities.lib.php'; // Load translation files required by the page $langs->loadLangs(array("bookcal@bookcal", "other")); diff --git a/htdocs/bookcal/availabilities_contact.php b/htdocs/bookcal/availabilities_contact.php index dd01e8bf046..41508aaa46a 100644 --- a/htdocs/bookcal/availabilities_contact.php +++ b/htdocs/bookcal/availabilities_contact.php @@ -23,40 +23,12 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +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'; -dol_include_once('/bookcal/class/availabilities.class.php'); -dol_include_once('/bookcal/lib/bookcal_availabilities.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/bookcal/class/availabilities.class.php'; +require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_availabilities.lib.php'; // Load translation files required by the page $langs->loadLangs(array("bookcal@bookcal", "companies", "other", "mails")); diff --git a/htdocs/bookcal/availabilities_document.php b/htdocs/bookcal/availabilities_document.php index 5bab9356ee1..e7335bff74c 100644 --- a/htdocs/bookcal/availabilities_document.php +++ b/htdocs/bookcal/availabilities_document.php @@ -22,64 +22,15 @@ * \brief Tab for documents linked to Availabilities */ -//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('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//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("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('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 - // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +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'; -dol_include_once('/bookcal/class/availabilities.class.php'); -dol_include_once('/bookcal/lib/bookcal_availabilities.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/bookcal/class/availabilities.class.php'; +require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_availabilities.lib.php'; // Load translation files required by the page $langs->loadLangs(array("bookcal@bookcal", "companies", "other", "mails")); diff --git a/htdocs/bookcal/availabilities_list.php b/htdocs/bookcal/availabilities_list.php index 6c5b4c2ed64..9af4b65a022 100644 --- a/htdocs/bookcal/availabilities_list.php +++ b/htdocs/bookcal/availabilities_list.php @@ -22,58 +22,8 @@ * \brief List page for availabilities */ -//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('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//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("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('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 - // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +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'; diff --git a/htdocs/bookcal/availabilities_note.php b/htdocs/bookcal/availabilities_note.php index faae7a08834..44ced158e03 100644 --- a/htdocs/bookcal/availabilities_note.php +++ b/htdocs/bookcal/availabilities_note.php @@ -22,60 +22,11 @@ * \brief Tab for notes on Availabilities */ -//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('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//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("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('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 - // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../main.inc.php'; -dol_include_once('/bookcal/class/availabilities.class.php'); -dol_include_once('/bookcal/lib/bookcal_availabilities.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/bookcal/class/availabilities.class.php'; +require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_availabilities.lib.php'; // Load translation files required by the page $langs->loadLangs(array("bookcal@bookcal", "companies")); diff --git a/htdocs/bookcal/bookcalindex.php b/htdocs/bookcal/bookcalindex.php index 1b4e360e4ce..6ec6ae6fb3e 100644 --- a/htdocs/bookcal/bookcalindex.php +++ b/htdocs/bookcal/bookcalindex.php @@ -25,35 +25,7 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; diff --git a/htdocs/bookcal/booking_agenda.php b/htdocs/bookcal/booking_agenda.php index dec1ebee921..a9163d7f70d 100644 --- a/htdocs/bookcal/booking_agenda.php +++ b/htdocs/bookcal/booking_agenda.php @@ -22,63 +22,14 @@ * \brief Tab of events on Booking */ -//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('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//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("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('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 - // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +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'; -dol_include_once('/bookcal/class/booking.class.php'); -dol_include_once('/bookcal/lib/bookcal_booking.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 @@ -270,7 +221,7 @@ if ($object->id > 0) { if (get_class($objthirdparty) == 'Societe') { $out .= '&socid='.urlencode($objthirdparty->id); } - $out .= (!empty($objcon->id) ? '&contactid='.urlencode($objcon->id) : '').'&percentage=-1'; + $out .= (!empty($objcon->id) ? '&contactid='.urlencode($objcon->id) : ''); //$out.=$langs->trans("AddAnAction").' '; //$out.=img_picto($langs->trans("AddAnAction"),'filenew'); //$out.=""; @@ -280,7 +231,7 @@ if ($object->id > 0) { print '
'; if (isModEnabled('agenda')) { - if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { + if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { print ''.$langs->trans("AddAction").''; } else { print ''.$langs->trans("AddAction").''; diff --git a/htdocs/bookcal/booking_card.php b/htdocs/bookcal/booking_card.php index 0240ab2dccc..3f041f0d79d 100644 --- a/htdocs/bookcal/booking_card.php +++ b/htdocs/bookcal/booking_card.php @@ -22,64 +22,14 @@ * \brief Page to create/edit/view booking */ -//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('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token). -//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("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('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 - // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +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'; -dol_include_once('/bookcal/class/booking.class.php'); -dol_include_once('/bookcal/lib/bookcal_booking.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("bookcal@bookcal", "other")); diff --git a/htdocs/bookcal/booking_contact.php b/htdocs/bookcal/booking_contact.php index 923976adb47..bb73368b770 100644 --- a/htdocs/bookcal/booking_contact.php +++ b/htdocs/bookcal/booking_contact.php @@ -23,40 +23,12 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +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'; -dol_include_once('/bookcal/class/booking.class.php'); -dol_include_once('/bookcal/lib/bookcal_booking.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("bookcal@bookcal", "companies", "other", "mails")); diff --git a/htdocs/bookcal/booking_document.php b/htdocs/bookcal/booking_document.php index 81342e1a7b6..c102597e189 100644 --- a/htdocs/bookcal/booking_document.php +++ b/htdocs/bookcal/booking_document.php @@ -22,64 +22,15 @@ * \brief Tab for documents linked to Booking */ -//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('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//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("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('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 - // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +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'; -dol_include_once('/bookcal/class/booking.class.php'); -dol_include_once('/bookcal/lib/bookcal_booking.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("bookcal@bookcal", "companies", "other", "mails")); diff --git a/htdocs/bookcal/booking_list.php b/htdocs/bookcal/booking_list.php index f4aac1e5ed8..c7ebdd6f378 100644 --- a/htdocs/bookcal/booking_list.php +++ b/htdocs/bookcal/booking_list.php @@ -22,58 +22,8 @@ * \brief List page for booking */ -//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('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//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("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('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 - // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +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'; diff --git a/htdocs/bookcal/booking_note.php b/htdocs/bookcal/booking_note.php index f68ffcbd72b..c8b2de4e6ff 100644 --- a/htdocs/bookcal/booking_note.php +++ b/htdocs/bookcal/booking_note.php @@ -22,60 +22,11 @@ * \brief Tab for notes on Booking */ -//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('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//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("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('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 - // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../main.inc.php'; -dol_include_once('/bookcal/class/booking.class.php'); -dol_include_once('/bookcal/lib/bookcal_booking.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("bookcal@bookcal", "companies")); diff --git a/htdocs/bookcal/class/availabilities.class.php b/htdocs/bookcal/class/availabilities.class.php index cfbfc8eed88..3ccc4542670 100644 --- a/htdocs/bookcal/class/availabilities.class.php +++ b/htdocs/bookcal/class/availabilities.class.php @@ -74,7 +74,7 @@ class Availabilities extends CommonObject * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" * 'label' the translation key. * 'picto' is code of a picto to show before value in forms - * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM' or '!empty($conf->multicurrency->enabled)' ...) + * '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) diff --git a/htdocs/bookcal/class/booking.class.php b/htdocs/bookcal/class/booking.class.php index a74cb87a43d..98cb5077844 100644 --- a/htdocs/bookcal/class/booking.class.php +++ b/htdocs/bookcal/class/booking.class.php @@ -74,7 +74,7 @@ class Booking extends CommonObject * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" * 'label' the translation key. * 'picto' is code of a picto to show before value in forms - * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM' or '!empty($conf->multicurrency->enabled)' ...) + * '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) diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index d5258ba26f1..c13b810a4bc 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -203,11 +203,11 @@ function printDropdownBookmarksList() $html .= ' '."\n"; @@ -2104,7 +2104,7 @@ if ($id > 0) { $("#select_actioncommsendmodel_mail").closest("tr").show(); } else { $("#select_actioncommsendmodel_mail").closest("tr").hide(); - }; + } }); })'; @@ -2466,14 +2466,14 @@ if ($id > 0) { $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { if ($action != 'edit') { - if ($user->rights->agenda->allactions->create || + if ($user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) { print ''; } else { print ''; } - if ($user->rights->agenda->allactions->create || + if ($user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) { print ''; } else { diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 64d01817c85..f71c75192ef 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -225,22 +225,22 @@ class ActionComm extends CommonObject public $transparency; /** - * @var int (0 By default) + * @var int (0 By default) */ public $priority; /** - * @var int[] Array of user ids + * @var int[] Array of user ids */ public $userassigned = array(); /** - * @var int Id of user owner = fk_user_action into table + * @var int Id of user owner = fk_user_action into table */ public $userownerid; /** - * @var int Id of user that has done the event. Used only if AGENDA_ENABLE_DONEBY is set. + * @var int Id of user that has done the event. Used only if AGENDA_ENABLE_DONEBY is set. */ public $userdoneid; @@ -429,7 +429,7 @@ class ActionComm extends CommonObject $now = dol_now(); // Check parameters - if (!isset($this->userownerid) || $this->userownerid === '') { // $this->userownerid may be 0 (anonymous event) of > 0 + if (!isset($this->userownerid) || (string) $this->userownerid === '') { // $this->userownerid may be 0 (anonymous event) or > 0 dol_syslog("You tried to create an event but mandatory property ownerid was not defined", LOG_WARNING); $this->errors[] = 'ErrorActionCommPropertyUserowneridNotDefined'; return -1; @@ -477,8 +477,8 @@ class ActionComm extends CommonObject $this->elementtype = 'contract'; } - if (!is_array($this->userassigned) && !empty($this->userassigned)) { // For backward compatibility when userassigned was an int instead fo array - $tmpid = $this->userassigned; + if (!is_array($this->userassigned) && !empty($this->userassigned)) { // For backward compatibility when userassigned was an int instead of an array + $tmpid = (int) $this->userassigned; $this->userassigned = array(); $this->userassigned[$tmpid] = array('id'=>$tmpid, 'transparency'=>$this->transparency); } @@ -1800,8 +1800,8 @@ class ActionComm extends CommonObject * Adds it to non existing supplied categories. * Existing categories are left untouch. * - * @param int[]|int $categories Category or categories IDs - * @return void + * @param int[]|int $categories Category or categories IDs + * @return int <0 if KO, >0 if OK */ public function setCategories($categories) { @@ -1835,7 +1835,7 @@ class ActionComm extends CommonObject $c->add_type($this, Categorie::TYPE_ACTIONCOMM); } } - return; + return 1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2261,18 +2261,18 @@ class ActionComm extends CommonObject /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'actioncomm' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 8c13709b250..c0accf82866 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -210,7 +210,7 @@ class AgendaEvents extends DolibarrApi if (!DolibarrApiAccess::$user->rights->agenda->myactions->create) { throw new RestException(401, "Insufficient rights to create your Agenda Event"); } - if (!DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { + if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'create') && DolibarrApiAccess::$user->id != $request_data['userownerid']) { throw new RestException(401, "Insufficient rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } @@ -249,7 +249,7 @@ class AgendaEvents extends DolibarrApi if (!DolibarrApiAccess::$user->rights->agenda->myactions->create) { throw new RestException(401, "Insufficient rights to create your Agenda Event"); } - if (!DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { + if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'create') && DolibarrApiAccess::$user->id != $request_data['userownerid']) { throw new RestException(401, "Insufficient rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php index 049b70737e8..c7ab296a2a9 100644 --- a/htdocs/comm/action/class/cactioncomm.class.php +++ b/htdocs/comm/action/class/cactioncomm.class.php @@ -217,7 +217,7 @@ class CActionComm $qualified = 1; } // For case module = 'myobject@eventorganization' - $tmparray = preg_split("/@/", $obj->module, -1); + $tmparray = explode("@", $obj->module); if (count($tmparray) > 1 && $tmparray[1] == 'eventorganization' && isModEnabled('eventorganization')) { $qualified = 1; } diff --git a/htdocs/comm/action/class/ical.class.php b/htdocs/comm/action/class/ical.class.php index 7ab09e8d891..badd5db5c98 100644 --- a/htdocs/comm/action/class/ical.class.php +++ b/htdocs/comm/action/class/ical.class.php @@ -402,7 +402,7 @@ class ICal public function get_event_list() { // phpcs:enable - return (empty($this->cal['VEVENT']) ? '' : $this->cal['VEVENT']); + return (empty($this->cal['VEVENT']) ? array() : $this->cal['VEVENT']); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -414,7 +414,7 @@ class ICal public function get_freebusy_list() { // phpcs:enable - return (empty($this->cal['VFREEBUSY']) ? '' : $this->cal['VFREEBUSY']); + return (empty($this->cal['VFREEBUSY']) ? array() : $this->cal['VFREEBUSY']); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index 82cc7584c07..c37920f0d99 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -92,7 +92,7 @@ if ($user->socid && $socid) { $result = restrictedArea($user, 'societe', $socid); } -$usercancreate = $user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create); +$usercancreate = $user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create); $permissiontoadd = $usercancreate; @@ -305,7 +305,7 @@ if ($object->id > 0) { $modulepart = 'actions'; - $permissiontoadd = $user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create; + $permissiontoadd = $user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allactions', 'create'); $param = '&id='.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index ab814957e5b..5b51d48392b 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -540,7 +540,7 @@ $viewmode .= ''; // To add a space before t $newcardbutton = ''; $newparam = ''; -if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { +if ($user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allactions', 'create')) { $tmpforcreatebutton = dol_getdate(dol_now(), true); $newparam .= '&month='.((int) $month).'&year='.((int) $tmpforcreatebutton['year']).'&mode='.urlencode($mode); @@ -1703,7 +1703,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $curtime = dol_mktime(0, 0, 0, $month, $day, $year); $urltoshow = DOL_URL_ROOT.'/comm/action/index.php?mode=show_day&day='.str_pad($day, 2, "0", STR_PAD_LEFT).'&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year.$newparam; $urltocreate = ''; - if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { + if ($user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allactions', 'create')) { $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year; $hourminsec = '100000'; $urltocreate = DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $year, $month, $day).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')); @@ -1722,7 +1722,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa } print ''; print '
'; - if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { + if ($user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allactions', 'create')) { print ''; // Explicit link, usefull for nojs interfaces print img_picto($langs->trans("NewAction"), 'edit_add.png'); print ''; @@ -1849,7 +1849,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $cssclass .= ' movable cursormove'; } } else { - if ($user->rights->agenda->allactions->create || + if ($user->hasRight('agenda', 'allactions', 'create') || (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->rights->agenda->myactions->create)) { $cssclass .= " movable cursormove"; } else { diff --git a/htdocs/comm/action/info.php b/htdocs/comm/action/info.php index d4588223b26..21651bb7446 100644 --- a/htdocs/comm/action/info.php +++ b/htdocs/comm/action/info.php @@ -53,7 +53,7 @@ if ($user->socid && $socid) { $result = restrictedArea($user, 'societe', $socid); } -$usercancreate = $user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create); +$usercancreate = $user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create); /* diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 5eb538d4e62..4be3195561e 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -700,7 +700,7 @@ $url = DOL_URL_ROOT.'/comm/action/card.php?action=create'; $url .= '&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec; $url .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')); -$newcardbutton = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, '', $user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create); +$newcardbutton = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, '', $user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allactions', 'create')); $param .= '&mode='.$mode; diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 61092df5665..ce33d0f40b2 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -479,7 +479,7 @@ if (empty($reshook)) { $newcardbutton = ''; -if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { +if ($user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allactions', 'create')) { $tmpforcreatebutton = dol_getdate(dol_now(), true); $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year']; diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 5c5ef948c30..bd35fc16e7d 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -475,7 +475,7 @@ if (empty($reshook)) { $newparam = ''; $newcardbutton = ''; -if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { +if ($user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allactions', 'create')) { $tmpforcreatebutton = dol_getdate(dol_now(), true); $newparam .= '&month='.urlencode(str_pad($month, 2, "0", STR_PAD_LEFT)).'&year='.urlencode($tmpforcreatebutton['year']); diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index f578aa75cf5..e6162b45b52 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -642,16 +642,16 @@ if ($object->id > 0) { print "
"; + print '
'; + // Prospection level and status if ($object->client == 2 || $object->client == 3) { - print '
'; - print '
'; print ''; // Level of prospection print ''; - // Year NP - print ''; @@ -339,13 +339,19 @@ if ($modecompta == 'CREANCES-DETTES') { } $result = strtr($formula, $vars); + $result = str_replace('--', '+', $result); - //var_dump($result); - //$r = $AccCat->calculate($result); - $r = dol_eval($result, 1, 1, '1'); - //var_dump($r); + if (preg_match('/[a-z]/i', $result)) { + $r = 'Error bad formula: '.$result; + $rshort = 'Err'; + print ''; + } else { + //var_dump($result); + //$r = $AccCat->calculate($result); + $r = dol_eval($result, 1, 1, '1'); - print ''; + print ''; + } // Year N $code = $cat['code']; // code of categorie ('VTE', 'MAR', ...) @@ -359,11 +365,12 @@ if ($modecompta == 'CREANCES-DETTES') { } $result = strtr($formula, $vars); + $result = str_replace('--', '+', $result); //$r = $AccCat->calculate($result); - $r = dol_eval($result, 1, 1, 1); + $r = dol_eval($result, 1, 1, '1'); - print ''; + print ''; $sommes[$code]['N'] += $r; // Detail by month @@ -373,23 +380,26 @@ if ($modecompta == 'CREANCES-DETTES') { $vars[$code] = $det['M'][$k]; } $result = strtr($formula, $vars); + $result = str_replace('--', '+', $result); //$r = $AccCat->calculate($result); - $r = dol_eval($result, 1, 1, 1); + $r = dol_eval($result, 1, 1, '1'); print ''; $sommes[$code]['M'][$k] += $r; } } + foreach ($months as $k => $v) { if (($k + 1) < $date_startmonth) { foreach ($sommes as $code => $det) { $vars[$code] = $det['M'][$k]; } $result = strtr($formula, $vars); + $result = str_replace('--', '+', $result); //$r = $AccCat->calculate($result); - $r = dol_eval($result, 1, 1, 1); + $r = dol_eval($result, 1, 1, '1'); print ''; $sommes[$code]['M'][$k] += $r; @@ -399,8 +409,7 @@ if ($modecompta == 'CREANCES-DETTES') { print "\n"; //var_dump($sommes); - } else // normal category - { + } else { // normal category $code = $cat['code']; // Category code we process $totCat = array(); @@ -414,23 +423,25 @@ if ($modecompta == 'CREANCES-DETTES') { // Set $cpts with array of accounts in the category/group $cpts = $AccCat->getCptsCat($cat['rowid']); // We should loop over empty $cpts array, else the category _code_ is used in the formula, which leads to wrong result if the code is a number. - if (empty($cpts)) $cpts[] = array(); - + if (empty($cpts)) { + $cpts[] = array(); + } $arrayofaccountforfilter = array(); foreach ($cpts as $i => $cpt) { // Loop on each account. - $arrayofaccountforfilter[] = $cpt['account_number']; + if (!is_null($cpt['account_number'])) { + $arrayofaccountforfilter[] = $cpt['account_number']; + } } // N-1 if (!empty($arrayofaccountforfilter)) { $return = $AccCat->getSumDebitCredit($arrayofaccountforfilter, $date_start_previous, $date_end_previous, $cat['dc'] ? $cat['dc'] : 0); - if ($return < 0) { setEventMessages(null, $AccCat->errors, 'errors'); $resultNP = 0; } else { - foreach ($cpts as $i => $cpt) { // Loop on each account. + foreach ($cpts as $i => $cpt) { // Loop on each account found $resultNP = empty($AccCat->sdcperaccount[$cpt['account_number']]) ? 0 : $AccCat->sdcperaccount[$cpt['account_number']]; $totCat['NP'] += $resultNP; @@ -478,41 +489,42 @@ if ($modecompta == 'CREANCES-DETTES') { // Now output columns for row $code ('VTE', 'MAR', ...) - print ""; + print ''; // Column group - print ''; // Label of group - print ''; print ''; - print ''; + print ''; // Each month foreach ($totCat['M'] as $k => $v) { @@ -537,13 +549,13 @@ if ($modecompta == 'CREANCES-DETTES') { if ($showaccountdetail == 'all' || $resultN != 0) { print ''; print ''; - print ''; print ''; - print ''; + print ''; // Make one call for each month foreach ($months as $k => $v) { diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 0bf402c6c21..73d101d7ae6 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -365,20 +365,17 @@ class PaymentSocialContribution extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."paiementcharge SET"; - - $sql .= " fk_charge=".(isset($this->fk_charge) ? $this->fk_charge : "null").","; + $sql .= " fk_charge=".(isset($this->fk_charge) ? ((int) $this->fk_charge) : "null").","; $sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; $sql .= " datep=".(dol_strlen($this->datep) != 0 ? "'".$this->db->idate($this->datep)."'" : 'null').","; - $sql .= " amount=".(isset($this->amount) ? $this->amount : "null").","; - $sql .= " fk_typepaiement=".(isset($this->fk_typepaiement) ? $this->fk_typepaiement : "null").","; + $sql .= " amount=".(isset($this->amount) ? price2num($this->amount) : "null").","; + $sql .= " fk_typepaiement=".(isset($this->fk_typepaiement) ? ((int) $this->fk_typepaiement) : "null").","; $sql .= " num_paiement=".(isset($this->num_payment) ? "'".$this->db->escape($this->num_payment)."'" : "null").","; $sql .= " note=".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : "null").","; - $sql .= " fk_bank=".(isset($this->fk_bank) ? $this->fk_bank : "null").","; - $sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").","; - $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? $this->fk_user_modif : "null").""; - - + $sql .= " fk_bank=".(isset($this->fk_bank) ? ((int) $this->fk_bank) : "null").","; + $sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? ((int) $this->fk_user_creat) : "null").","; + $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? ((int) $this->fk_user_modif) : "null"); $sql .= " WHERE rowid=".((int) $this->id); $this->db->begin(); diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index f70ed44de0c..83690816801 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -501,9 +501,9 @@ if (!empty($arrayfields['cs.amount']['checked'])) { // Filter: Status if (!empty($arrayfields['cs.paye']['checked'])) { - print ''; } diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index dc0fa94030c..e747c4380a4 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -324,7 +324,7 @@ if ($modecompta == 'CREANCES-DETTES') { } if ($selected_cat === -2) { // Without any category $sql .= " AND cp.fk_product is null"; - } elseif ($selected_cat) { // Into a specific category + } elseif ($selected_cat > 0) { // Into a specific category if ($subcat) { $TListOfCats = $categorie->get_full_arbo('product', $selected_cat, 1); diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index e7c7678b818..c78b41ba274 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -333,6 +333,10 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char $object->id = $object->ref = null; $object->paye = 0; + if (GETPOST('amount', 'alphanohtml')) { + $object->amount = price2num(GETPOST('amount', 'alphanohtml'), 'MT', 2); + } + if (GETPOST('clone_label', 'alphanohtml')) { $object->label = GETPOST('clone_label', 'alphanohtml'); } else { @@ -405,7 +409,7 @@ if ($action == 'create') { $("#label_type_payment").removeClass("fieldrequired"); $(".hide_if_no_auto_create_payment").hide(); } - }; + } $("#radiopayment").click(function() { $("#label").val($(this).data("label")); }); @@ -540,6 +544,7 @@ if ($id > 0) { //$formquestion[] = array('type' => 'date', 'name' => 'clone_date_ech', 'label' => $langs->trans("Date"), 'value' => -1); $formquestion[] = array('type' => 'date', 'name' => 'clone_period', 'label' => $langs->trans("PeriodEndDate"), 'value' => -1); + $formquestion[] = array('type' => 'text', 'name' => 'amount', 'label' => $langs->trans("Amount"), 'value' => price($object->amount), 'morecss' => 'width100'); print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneVAT', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 240); } diff --git a/htdocs/compta/tva/class/paymentvat.class.php b/htdocs/compta/tva/class/paymentvat.class.php index ec951d8d72d..fcc241c728d 100644 --- a/htdocs/compta/tva/class/paymentvat.class.php +++ b/htdocs/compta/tva/class/paymentvat.class.php @@ -366,27 +366,22 @@ class PaymentVAT extends CommonObject $this->fk_user_modif = (int) $this->fk_user_modif; } - - // Check parameters // Put here code to add control on parameters values // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."payment_vat SET"; - - $sql .= " fk_tva=".(isset($this->fk_tva) ? $this->fk_tva : "null").","; + $sql .= " fk_tva=".(isset($this->fk_tva) ? ((int) $this->fk_tva) : "null").","; $sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; $sql .= " datep=".(dol_strlen($this->datep) != 0 ? "'".$this->db->idate($this->datep)."'" : 'null').","; - $sql .= " amount=".(isset($this->amount) ? $this->amount : "null").","; - $sql .= " fk_typepaiement=".(isset($this->fk_typepaiement) ? $this->fk_typepaiement : "null").","; - $sql .= " num_paiement=".(isset($this->num_paiement) ? "'".$this->db->escape($this->num_paiement)."'" : "null").","; + $sql .= " amount=".(isset($this->amount) ? (float) price2num($this->amount) : "null").","; + $sql .= " fk_typepaiement=".(isset($this->fk_typepaiement) ? ((int) $this->fk_typepaiement) : "null").","; + $sql .= " num_paiement=".(isset($this->num_payment) ? "'".$this->db->escape($this->num_payment)."'" : "null").","; $sql .= " note=".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : "null").","; - $sql .= " fk_bank=".(isset($this->fk_bank) ? $this->fk_bank : "null").","; - $sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").","; - $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? $this->fk_user_modif : "null").""; - - + $sql .= " fk_bank=".(isset($this->fk_bank) ? ((int) $this->fk_bank) : "null").","; + $sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? ((int) $this->fk_user_creat) : "null").","; + $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? ((int) $this->fk_user_modif) : "null"); $sql .= " WHERE rowid=".((int) $this->id); $this->db->begin(); diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index d6efb35ef2f..dffba34d59b 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -226,7 +226,7 @@ class Tva extends CommonObject $sql .= " label='".$this->db->escape($this->label)."',"; $sql .= " note='".$this->db->escape($this->note)."',"; $sql .= " fk_user_creat=".((int) $this->fk_user_creat).","; - $sql .= " fk_user_modif=".($this->fk_user_modif > 0 ? $this->fk_user_modif : $user->id).""; + $sql .= " fk_user_modif=".((int) ($this->fk_user_modif > 0 ? $this->fk_user_modif : $user->id)); $sql .= " WHERE rowid=".((int) $this->id); dol_syslog(get_class($this)."::update", LOG_DEBUG); diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index f0efe305d8c..37e7f75b306 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -229,6 +229,9 @@ llxHeader('', $name); //$textnextyear=" ".img_next($langs->trans("Next"), 'class="valignbottom"').""; //print load_fiche_titre($langs->transcountry("VAT", $mysoc->country_code), $textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, 'bill'); +$periodlink = ''; +$exportlink = ''; + report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode); //report_header($name,'',$textprevyear.$langs->trans("Year")." ".$year_start.$textnextyear,'',$description,$builddate,$exportlink,array(),$calcmode); @@ -242,7 +245,7 @@ if ($refresh === true) { print '
'; - print ''; - echo ''; + echo ''; echo ''; echo ''; echo ''; } // Bordereau diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index a923f3a0829..15cb5123e0f 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -515,6 +515,7 @@ if ($action == 'create') { // Show fields of bank account $sizecss = ''; foreach ($object->getFieldsToShow() as $val) { + $content = ''; if ($val == 'BankCode') { $name = 'code_banque'; $sizecss = 'minwidth100'; @@ -534,7 +535,7 @@ if ($action == 'create') { } print ''; - print ''; + print ''; print ''; } $ibankey = FormBank::getIBANLabel($object); @@ -545,10 +546,10 @@ if ($action == 'create') { // IBAN print ''; - print ''; + print ''; print ''; - print ''; + print ''; if (isModEnabled('paymentbybanktransfer')) { print ''; @@ -559,7 +560,7 @@ if ($action == 'create') { print '"; print ''; @@ -730,6 +731,7 @@ if ($action == 'create') { // Show fields of bank account foreach ($object->getFieldsToShow() as $val) { + $content = ''; if ($val == 'BankCode') { $content = $object->code_banque; } elseif ($val == 'DeskCode') { @@ -1034,31 +1036,32 @@ if ($action == 'create') { // If bank account print ''; - print ''; + print ''; print ''; // Show fields of bank account foreach ($object->getFieldsToShow() as $val) { + $content = ''; if ($val == 'BankCode') { $name = 'code_banque'; - $size = 8; + $css = 'with100'; $content = $object->code_banque; } elseif ($val == 'DeskCode') { $name = 'code_guichet'; - $size = 8; + $css = 'with100'; $content = $object->code_guichet; } elseif ($val == 'BankAccountNumber') { $name = 'number'; - $size = 18; + $css = 'with200'; $content = $object->number; } elseif ($val == 'BankAccountNumberKey') { $name = 'cle_rib'; - $size = 3; + $css = 'with50'; $content = $object->cle_rib; } print ''; - print ''; + print ''; print ''; } diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index a73fd2b5f2c..4aea92a510e 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1060,8 +1060,8 @@ class Account extends CommonObject * Adds it to non existing supplied categories. * Existing categories are left untouch. * - * @param int[]|int $categories Category or categories IDs - * @return void + * @param int[]|int $categories Category or categories IDs + * @return int <0 if KO, >0 if OK */ public function setCategories($categories) { diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index c9886a176f0..537c7c9acb6 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -122,8 +122,8 @@ class BankAccounts extends DolibarrApi /** * Get account by ID. * - * @param int $id ID of account - * @return array Account object + * @param int $id ID of account + * @return Object Object with cleaned properties * * @throws RestException */ @@ -313,9 +313,9 @@ class BankAccounts extends DolibarrApi /** * Update account * - * @param int $id ID of account - * @param array $request_data data - * @return int + * @param int $id ID of account + * @param array $request_data data + * @return Object Object with cleaned properties */ public function put($id, $request_data = null) { diff --git a/htdocs/compta/bank/class/bankcateg.class.php b/htdocs/compta/bank/class/bankcateg.class.php index 1795704d4ff..581bc5fd1da 100644 --- a/htdocs/compta/bank/class/bankcateg.class.php +++ b/htdocs/compta/bank/class/bankcateg.class.php @@ -80,7 +80,7 @@ class BankCateg // extends CommonObject $sql .= "label"; $sql .= ", entity"; $sql .= ") VALUES ("; - $sql .= " ".(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").""; + $sql .= " ".(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'"); $sql .= ", ".((int) $conf->entity); $sql .= ")"; @@ -169,7 +169,7 @@ class BankCateg // extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."bank_categ SET"; - $sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").""; + $sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); $sql .= " WHERE rowid=".((int) $this->id); $sql .= " AND entity = ".$conf->entity; diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index c11e13f1e71..490107e4893 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -458,7 +458,7 @@ if ($result < 0) { if ($day > ($max + 86400)) { $datas[$i] = ''; // Valeur speciale permettant de ne pas tracer le graph } else { - $datas[$i] = 0 + $solde + $subtotal; + $datas[$i] = $solde + $subtotal; } $datamin[$i] = $object->min_desired; $dataall[$i] = $object->min_allowed; diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 0014245ee48..098489e6f7b 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -483,12 +483,12 @@ if (!empty($arrayfields['b.tms']['checked'])) { } // Status if (!empty($arrayfields['b.clos']['checked'])) { - print ''; } // Balance diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index d3e573f21bf..e75402ba429 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -353,10 +353,10 @@ if (GETPOST("account") || GETPOST("ref")) { print ""; if ($tmpobj->total_ttc < 0) { print '"; - }; + } if ($tmpobj->total_ttc >= 0) { print '"; - }; + } print ''; print ""; } diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index c1d6e9f3ec4..5adde527f34 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -29,6 +29,7 @@ require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; @@ -466,7 +467,7 @@ if ($resql) { } // Accounting account - if ($arrayfields['account']['checked']) { + if (!empty($arrayfields['account']['checked'])) { print ''; @@ -535,10 +536,10 @@ if ($resql) { if ($arrayfields['entry']['checked']) { print_liste_field_titre($arrayfields['entry']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder); } - if ($arrayfields['account']['checked']) { + if (!empty($arrayfields['account']['checked'])) { print_liste_field_titre($arrayfields['account']['label'], $_SERVER["PHP_SELF"], 'v.accountancy_code', '', $param, '', $sortfield, $sortorder, 'left '); } - if ($arrayfields['subledger']['checked']) { + if (!empty($arrayfields['subledger']['checked'])) { print_liste_field_titre($arrayfields['subledger']['label'], $_SERVER["PHP_SELF"], 'v.subledger_account', '', $param, '', $sortfield, $sortorder, 'left '); } if ($arrayfields['debit']['checked']) { @@ -671,7 +672,7 @@ if ($resql) { } // Accounting account - if ($arrayfields['account']['checked']) { + if (!empty($arrayfields['account']['checked'])) { $accountingaccount->fetch('', $obj->accountancy_code, 1); print ''; @@ -681,7 +682,7 @@ if ($resql) { } // Accounting subledger account - if ($arrayfields['subledger']['checked']) { + if (!empty($arrayfields['subledger']['checked'])) { print ''; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index 5b764cfb730..7d433282367 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -17,7 +17,7 @@ */ /** - * \file cashcontrol_list.php + * \file htdocs/compta/cashcontrol/cashcontrol_list.php * \ingroup cashdesk|takepos * \brief List page for cashcontrol */ @@ -50,8 +50,9 @@ $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') || (empty($toselect) && $massaction === '0')) { + // If $page is not defined, or '' or -1 or if we click on clear filters $page = 0; -} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +} $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -105,11 +106,11 @@ $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, 1, '1'); + $visible = (int) dol_eval($val['visible'], 1); $arrayfields['t.'.$key] = array( 'label'=>$val['label'], 'checked'=>(($visible < 0) ? 0 : 1), - 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')), + 'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)), 'position'=>$val['position'], 'help'=> isset($val['help']) ? $val['help'] : '' ); @@ -194,7 +195,8 @@ $now = dol_now(); //$help_url="EN:Module_pos_cash_fence|FR:Module_pos_cash_fence_FR|ES:Módulo_pos_cash_fence"; $help_url = ''; $title = $langs->trans('CashControl'); - +$morejs = array(); +$morecss = array(); // Build and execute select // -------------------------------------------------------------------- @@ -211,6 +213,9 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); + +$sqlfields = $sql; // $sql fields to remove for count total + $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; 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)"; @@ -237,17 +242,17 @@ foreach ($search as $key => $val) { $mode_search = 2; } if ($search[$key] != '') { - $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + $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." . $columnName . " >= '" . $db->idate($search[$key]) . "'"; + $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'"; } if (preg_match('/_dtend$/', $key)) { - $sql .= " AND t." . $columnName . " <= '" . $db->idate($search[$key]) . "'"; + $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'"; } } } @@ -267,11 +272,13 @@ $sql .= $hookmanager->resPrint; /* If a group by is required $sql.= " GROUP BY "; foreach($object->fields as $key => $val) { - $sql .= "t.".$key.", "; + $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.', ' : ''); + 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(); @@ -280,35 +287,43 @@ $sql.=$hookmanager->resPrint; $sql=preg_replace('/,\s*$/','', $sql); */ -$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $resql = $db->query($sql); - $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 + /* The fast and low memory method to get and count full list converts the sql into a sql count */ + $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); + $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); + $resql = $db->query($sqlforcount); + if ($resql) { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + } else { + dol_print_error($db); + } + + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } + $db->free($resql); } -// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { - $num = $nbtotalofrecords; -} else { - if ($limit) { - $sql .= $db->plimit($limit + 1, $offset); - } - $resql = $db->query($sql); - if (!$resql) { - dol_print_error($db); - exit; - } - - $num = $db->num_rows($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); @@ -326,6 +341,9 @@ llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'classforhorizontalscroll $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); } @@ -333,11 +351,17 @@ if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.urlencode($limit); } foreach ($search as $key => $val) { - if (is_array($search[$key]) && count($search[$key])) { + if (is_array($search[$key])) { foreach ($search[$key] as $skey) { - $param .= '&search_'.$key.'[]='.urlencode($skey); + if ($skey != '') { + $param .= '&search_'.$key.'[]='.urlencode($skey); + } } - } else { + } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) { + $param .= '&search_'.$key.'month='.((int) GETPOST('search_'.$key.'month', 'int')); + $param .= '&search_'.$key.'day='.((int) GETPOST('search_'.$key.'day', 'int')); + $param .= '&search_'.$key.'year='.((int) GETPOST('search_'.$key.'year', 'int')); + } elseif ($search[$key] != '') { $param .= '&search_'.$key.'='.urlencode($search[$key]); } } @@ -373,6 +397,7 @@ print ''; print ''; print ''; +print ''; print ''; $permforcashfence = 1; @@ -389,10 +414,13 @@ $trackid = 'cashfence'.$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 '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; + print ''."\n"; + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'."\n"; } $moreforfilter = ''; @@ -433,13 +461,13 @@ foreach ($object->fields as $key => $val) { $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')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'rowid' && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; + $j = 0; + 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'))) { @@ -546,7 +575,11 @@ while ($i < ($limit ? min($num, $limit) : $num)) { //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; + print ''; if ($key == 'status') { print $object->getLibStatut(5); } elseif ($key == 'rowid') { @@ -609,13 +642,13 @@ if ($num == 0) { $colspan++; } } - print ''; + print ''; } $db->free($resql); $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; + print ''; print "
'; print $langs->trans('ProspectLevel'); print ''; if ($action != 'editlevel' && $user->rights->societe->creer) { @@ -683,10 +683,11 @@ if ($object->id > 0) { } print '
"; - } - print '
'; - print '
'; + print '
'; + } else { + print '

'; + } $boxstat = ''; @@ -695,7 +696,7 @@ if ($object->id > 0) { // Lien recap $boxstat .= '
'; - $boxstat .= ''; + $boxstat .= '
'; $boxstat .= ''; } @@ -2776,7 +2804,7 @@ if ($action == 'create') { } if (!empty($object->lines)) { - $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); + $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 1); } // Form to add new line diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index cf675e01b62..5e0e2c31e19 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -49,7 +49,7 @@ class Proposals extends DolibarrApi */ public function __construct() { - global $db, $conf; + global $db; $this->db = $db; $this->propal = new Propal($this->db); } @@ -59,9 +59,9 @@ class Proposals extends DolibarrApi * * Return an array with commercial proposal informations * - * @param int $id ID of commercial proposal - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id - * @return array|mixed data without useless information + * @param int $id ID of commercial proposal + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return Object Object with cleaned properties * * @throws RestException */ @@ -76,8 +76,8 @@ class Proposals extends DolibarrApi * Return an array with proposal informations * * @param string $ref Ref of object - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id - * @return array|mixed data without useless information + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return Object Object with cleaned properties * * @url GET ref/{ref} * @@ -93,9 +93,9 @@ class Proposals extends DolibarrApi * * Return an array with proposal informations * - * @param string $ref_ext External reference of object - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id - * @return array|mixed data without useless information + * @param string $ref_ext External reference of object + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return Object Object with cleaned properties * * @url GET ref_ext/{ref_ext} * @@ -111,11 +111,11 @@ class Proposals extends DolibarrApi * * Return an array with proposal informations * - * @param int $id ID of order - * @param string $ref Ref of object - * @param string $ref_ext External reference of object - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id - * @return array|mixed data without useless information + * @param int $id ID of order + * @param string $ref Ref of object + * @param string $ref_ext External reference of object + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return Object Object with cleaned properties * * @throws RestException */ @@ -289,7 +289,7 @@ class Proposals extends DolibarrApi * * @url GET {id}/lines * - * @return int + * @return array */ public function getLines($id, $sqlfilters = '') { @@ -461,7 +461,7 @@ class Proposals extends DolibarrApi } if (empty($errors)) { $this->db->commit(); - return count($request_data); + return $updateRes; } else { $this->db->rollback(); throw new RestException(400, implode(", ", $errors)); @@ -471,13 +471,12 @@ class Proposals extends DolibarrApi /** * Update a line of given commercial proposal * - * @param int $id Id of commercial proposal to update - * @param int $lineid Id of line to update - * @param array $request_data Commercial proposal line data + * @param int $id Id of commercial proposal to update + * @param int $lineid Id of line to update + * @param array $request_data Commercial proposal line data + * @return Object|false Object with cleaned properties * * @url PUT {id}/lines/{lineid} - * - * @return object */ public function putLine($id, $lineid, $request_data = null) { @@ -548,13 +547,12 @@ class Proposals extends DolibarrApi * Delete a line of given commercial proposal * * - * @param int $id Id of commercial proposal to update - * @param int $lineid Id of line to delete + * @param int $id Id of commercial proposal to update + * @param int $lineid Id of line to delete + * @return Object|false Object with cleaned properties * * @url DELETE {id}/lines/{lineid} * - * @return int - * * @throws RestException 401 * @throws RestException 404 */ @@ -573,9 +571,7 @@ class Proposals extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - // TODO Check the lineid $lineid is a line of ojbect - - $updateRes = $this->propal->deleteline($lineid); + $updateRes = $this->propal->deleteline($lineid, $id); if ($updateRes > 0) { return $this->get($id); } else { @@ -589,11 +585,10 @@ class Proposals extends DolibarrApi * @param int $id Id of commercial proposal to update * @param int $contactid Id of contact to add * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER) + * @return array * * @url POST {id}/contact/{contactid}/{type} * - * @return int - * * @throws RestException 401 * @throws RestException 404 */ @@ -623,20 +618,24 @@ class Proposals extends DolibarrApi throw new RestException(500, 'Error when added the contact'); } - return $this->propal; + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Contact linked to the proposal' + ) + ); } /** * Delete a contact type of given commercial proposal * - * @param int $id Id of commercial proposal to update - * @param int $contactid Row key of the contact in the array contact_ids. - * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER). + * @param int $id Id of commercial proposal to update + * @param int $contactid Row key of the contact in the array contact_ids. + * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER). + * @return Object Object with cleaned properties * * @url DELETE {id}/contact/{contactid}/{type} * - * @return int - * * @throws RestException 401 * @throws RestException 404 * @throws RestException 500 System error @@ -675,10 +674,9 @@ class Proposals extends DolibarrApi /** * Update commercial proposal general fields (won't touch lines of commercial proposal) * - * @param int $id Id of commercial proposal to update - * @param array $request_data Datas - * - * @return int + * @param int $id Id of commercial proposal to update + * @param array $request_data Datas + * @return Object Object with cleaned properties */ public function put($id, $request_data = null) { @@ -722,7 +720,6 @@ class Proposals extends DolibarrApi * Delete commercial proposal * * @param int $id Commercial proposal ID - * * @return array */ public function delete($id) @@ -755,10 +752,9 @@ class Proposals extends DolibarrApi * Set a proposal to draft * * @param int $id Order ID + * @return Object Object with cleaned properties * * @url POST {id}/settodraft - * - * @return array */ public function settodraft($id) { @@ -807,6 +803,7 @@ class Proposals extends DolibarrApi * * @param int $id Commercial proposal ID * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return Object Object with cleaned properties * * @url POST {id}/validate * @@ -814,8 +811,6 @@ class Proposals extends DolibarrApi * @throws RestException 401 * @throws RestException 404 * @throws RestException 500 System error - * - * @return array */ public function validate($id, $notrigger = 0) { @@ -860,10 +855,9 @@ class Proposals extends DolibarrApi * @param int $status Must be 2 (accepted) or 3 (refused) {@min 2}{@max 3} * @param string $note_private Add this mention at end of private note * @param int $notrigger Disabled triggers + * @return Object Object with cleaned properties * * @url POST {id}/close - * - * @return array */ public function close($id, $status, $note_private = '', $notrigger = 0) { @@ -905,10 +899,9 @@ class Proposals extends DolibarrApi * Set a commercial proposal billed. Could be also called setbilled * * @param int $id Commercial proposal ID + * @return Object Object with cleaned properties * * @url POST {id}/setinvoiced - * - * @return array */ public function setinvoiced($id) { @@ -949,6 +942,7 @@ class Proposals extends DolibarrApi * * @param array $data Array with data to verify * @return array + * * @throws RestException */ private function _validate($data) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 1b3df25c7d2..2b429d0e8d1 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -454,6 +454,8 @@ class Propal extends CommonObject $this->lines[] = $line; } + + return 1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -981,9 +983,10 @@ class Propal extends CommonObject * Delete detail line * * @param int $lineid Id of line to delete + * @param int $id Id of object (for a check) * @return int >0 if OK, <0 if KO */ - public function deleteline($lineid) + public function deleteline($lineid, $id = 0) { global $user; @@ -992,9 +995,20 @@ class Propal extends CommonObject $line = new PropaleLigne($this->db); - // For triggers + $line->context = $this->context; + + // Load data $line->fetch($lineid); + if ($id > 0 && $line->fk_propal != $id) { + $this->error = 'ErrorLineIDDoesNotMatchWithObjectID'; + return -1; + } + + // Memorize previous line for triggers + $staticline = clone $line; + $line->oldline = $staticline; + if ($line->delete($user) > 0) { $this->update_price(1); @@ -1752,7 +1766,7 @@ class Propal extends CommonObject $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; $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 .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null").""; + $sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); $sql .= " WHERE rowid=".((int) $this->id); $this->db->begin(); @@ -2108,6 +2122,8 @@ class Propal extends CommonObject return -1 * $error; } } + + return -1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2164,6 +2180,8 @@ class Propal extends CommonObject return -1 * $error; } } + + return -1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2235,6 +2253,8 @@ class Propal extends CommonObject return -1 * $error; } } + + return -1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2417,9 +2437,9 @@ class Propal extends CommonObject $this->db->rollback(); return -1 * $error; } - } else { - return -1; } + + return -1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2480,6 +2500,8 @@ class Propal extends CommonObject return -1 * $error; } } + + return -1; } @@ -2542,6 +2564,8 @@ class Propal extends CommonObject return -1 * $error; } } + + return -1; } @@ -3860,18 +3884,18 @@ class Propal extends CommonObject /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'propal' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** @@ -4444,17 +4468,17 @@ class PropaleLigne extends CommonObjectLine $sql .= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'"; $sql .= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'"; $sql .= ", qty='".price2num($this->qty)."'"; - $sql .= ", subprice=".price2num($this->subprice).""; - $sql .= ", remise_percent=".price2num($this->remise_percent).""; - $sql .= ", price=".(float) price2num($this->price).""; // TODO A virer - $sql .= ", remise=".(float) price2num($this->remise).""; // TODO A virer + $sql .= ", subprice=".price2num($this->subprice); + $sql .= ", remise_percent=".price2num($this->remise_percent); + $sql .= ", price=".(float) price2num($this->price); // TODO A virer + $sql .= ", remise=".(float) price2num($this->remise); // TODO A virer $sql .= ", info_bits='".$this->db->escape($this->info_bits)."'"; if (empty($this->skip_update_total)) { - $sql .= ", total_ht=".price2num($this->total_ht).""; - $sql .= ", total_tva=".price2num($this->total_tva).""; - $sql .= ", total_ttc=".price2num($this->total_ttc).""; - $sql .= ", total_localtax1=".price2num($this->total_localtax1).""; - $sql .= ", total_localtax2=".price2num($this->total_localtax2).""; + $sql .= ", total_ht=".price2num($this->total_ht); + $sql .= ", total_tva=".price2num($this->total_tva); + $sql .= ", total_ttc=".price2num($this->total_ttc); + $sql .= ", total_localtax1=".price2num($this->total_localtax1); + $sql .= ", total_localtax2=".price2num($this->total_localtax2); } $sql .= ", fk_product_fournisseur_price=".(!empty($this->fk_fournprice) ? "'".$this->db->escape($this->fk_fournprice)."'" : "null"); $sql .= ", buy_price_ht=".price2num($this->pa_ht); @@ -4470,10 +4494,10 @@ class PropaleLigne extends CommonObjectLine $sql .= ", fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit); // Multicurrency - $sql .= ", multicurrency_subprice=".price2num($this->multicurrency_subprice).""; - $sql .= ", multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; - $sql .= ", multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; - $sql .= ", multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; + $sql .= ", multicurrency_subprice=".price2num($this->multicurrency_subprice); + $sql .= ", multicurrency_total_ht=".price2num($this->multicurrency_total_ht); + $sql .= ", multicurrency_total_tva=".price2num($this->multicurrency_total_tva); + $sql .= ", multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc); $sql .= " WHERE rowid = ".((int) $this->id); @@ -4520,9 +4544,9 @@ class PropaleLigne extends CommonObjectLine // Mise a jour ligne en base $sql = "UPDATE ".MAIN_DB_PREFIX."propaldet SET"; - $sql .= " total_ht=".price2num($this->total_ht, 'MT').""; - $sql .= ",total_tva=".price2num($this->total_tva, 'MT').""; - $sql .= ",total_ttc=".price2num($this->total_ttc, 'MT').""; + $sql .= " total_ht=".price2num($this->total_ht, 'MT'); + $sql .= ",total_tva=".price2num($this->total_tva, 'MT'); + $sql .= ",total_ttc=".price2num($this->total_ttc, 'MT'); $sql .= " WHERE rowid = ".((int) $this->rowid); dol_syslog("PropaleLigne::update_total", LOG_DEBUG); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index ed86a61d7bd..0acc2ae4bd9 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -16,6 +16,7 @@ * Copyright (C) 2019-2021 Alexandre Spangaro * Copyright (C) 2021 Anthony Berton * Copyright (C) 2021 Frédéric France + * Copyright (C) 2022 Josep Lluís Amador * * 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 @@ -305,7 +306,7 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa $massaction = ''; } -$parameters = array('socid'=>$socid); +$parameters = array('socid'=>$socid, 'arrayfields'=>&$arrayfields); $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'); @@ -610,7 +611,9 @@ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid'; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr ON pr.rowid = p.fk_projet"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_availability as ava on (ava.rowid = p.fk_availability)"; // We'll need this table joined to the select in order to filter by sale -if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) { +if ($search_sale == -2) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON (sc.fk_soc = p.fk_soc)"; +} elseif ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } if ($search_user > 0) { @@ -746,7 +749,9 @@ if ($search_date_delivery_start) { if ($search_date_delivery_end) { $sql .= " AND p.date_livraison <= '".$db->idate($search_date_delivery_end)."'"; } -if ($search_sale > 0) { +if ($search_sale == -2) { + $sql .= " AND sc.fk_user IS NULL"; +} elseif ($search_sale > 0) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale); } if ($search_user > 0) { @@ -1117,7 +1122,7 @@ if ($resql) { $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, 'maxwidth250 widthcentpercentminusx', 1); $moreforfilter .= '
'; } // If the user can view prospects other than his' @@ -1381,8 +1386,8 @@ if ($resql) { } if (!empty($arrayfields['u.login']['checked'])) { // Author - print '
'; } if (!empty($arrayfields['sale_representative']['checked'])) { @@ -1438,8 +1443,8 @@ if ($resql) { } // Status if (!empty($arrayfields['p.fk_statut']['checked'])) { - print ''; } // Action column diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php index 37c0f8d5e58..8aa72d9c43f 100644 --- a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php @@ -52,13 +52,13 @@ foreach ($linkedObjectBlock as $key => $objectlink) { $trclass .= ' liste_sub_total'; } print ''; - print ''; - print ''; + print ''; print ''; print ''; print ''; } @@ -1868,7 +1899,7 @@ if ($action == 'create' && $usercancreate) { // Incoterms if (isModEnabled('incoterm')) { print ''; - print ''; + print ''; print ''; } // Action column @@ -1969,6 +1980,9 @@ if ($resql) { $generic_commande->note_public = $obj->note_public; $generic_commande->note_private = $obj->note_private; + $generic_commande->thirdparty = $companystatic; + + $projectstatic->id = $obj->project_id; $projectstatic->ref = $obj->project_ref; $projectstatic->title = $obj->project_label; @@ -1981,655 +1995,669 @@ if ($resql) { $total_margin += $marginInfo['total_margin']; } - print ''; - - // Action column - if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; } - print ''; - } + } else { + print ''; - // Ref - if (!empty($arrayfields['c.ref']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Ref customer - if (!empty($arrayfields['c.ref_client']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Project ref - if (!empty($arrayfields['p.ref']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Project label - if (!empty($arrayfields['p.title']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Third party - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; + } + + // Ref + if (!empty($arrayfields['c.ref']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; } } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Alias name - if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Parent company - if (!empty($arrayfields['s2.nom']['checked'])) { - print ''; + if (!$i) { + $totalarray['nbfield']++; } } - print ""; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Town - if (!empty($arrayfields['s.town']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Zip - if (!empty($arrayfields['s.zip']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // State - if (!empty($arrayfields['state.nom']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Type ent - if (!empty($arrayfields['typent.code']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Order date - if (!empty($arrayfields['c.date_commande']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Plannned date of delivery - if (!empty($arrayfields['c.date_delivery']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Shipping Method - if (!empty($arrayfields['c.fk_shipping_method']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Payment terms - if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Payment mode - if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Channel - if (!empty($arrayfields['c.fk_input_reason']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Amount HT/net - if (!empty($arrayfields['c.total_ht']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ht'; - } - if (isset($totalarray['val']['c.total_ht'])) { - $totalarray['val']['c.total_ht'] += $obj->total_ht; - } else { - $totalarray['val']['c.total_ht'] = $obj->total_ht; - } - } - - // Amount VAT - if (!empty($arrayfields['c.total_vat']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'c.total_tva'; - } - if (isset($totalarray['val']['c.total_tva'])) { - $totalarray['val']['c.total_tva'] += $obj->total_tva; - } else { - $totalarray['val']['c.total_tva'] = $obj->total_tva; - } - } - - // Amount TTC / gross - if (!empty($arrayfields['c.total_ttc']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ttc'; - } - if (isset($totalarray['val']['c.total_ttc'])) { - $totalarray['val']['c.total_ttc'] += $obj->total_ttc; - } else { - $totalarray['val']['c.total_ttc'] = $obj->total_ttc; - } - } - - // Currency - if (!empty($arrayfields['c.multicurrency_code']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Currency rate - if (!empty($arrayfields['c.multicurrency_tx']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Amount HT/net in foreign currency - if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount VAT in foreign currency - if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount TTC / gross in foreign currency - if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - $userstatic->id = $obj->fk_user_author; - $userstatic->login = $obj->login; - $userstatic->lastname = $obj->lastname; - $userstatic->firstname = $obj->firstname; - $userstatic->email = $obj->user_email; - $userstatic->statut = $obj->user_statut; - $userstatic->entity = $obj->entity; - $userstatic->photo = $obj->photo; - $userstatic->office_phone = $obj->office_phone; - $userstatic->office_fax = $obj->office_fax; - $userstatic->user_mobile = $obj->user_mobile; - $userstatic->job = $obj->job; - $userstatic->gender = $obj->gender; - - // Author - if (!empty($arrayfields['u.login']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Sales representatives - if (!empty($arrayfields['sale_representative']['checked'])) { - print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Project label + if (!empty($arrayfields['p.title']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Third party + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Total buying or cost price - if (!empty($arrayfields['total_pa']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Alias name + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Total margin - if (!empty($arrayfields['total_margin']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Parent company + if (!empty($arrayfields['s2.nom']['checked'])) { + print '"; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'total_margin'; - } - $totalarray['val']['total_margin'] += $marginInfo['total_margin']; - } - // Total margin rate - if (!empty($arrayfields['total_margin_rate']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Town + if (!empty($arrayfields['s.town']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Total mark rate - if (!empty($arrayfields['total_mark_rate']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Zip + if (!empty($arrayfields['s.zip']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate'; + + // State + if (!empty($arrayfields['state.nom']['checked'])) { + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } } - if ($i >= $imaxinloop - 1) { - if (!empty($total_ht)) { - $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT'); + + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Type ent + if (!empty($arrayfields['typent.code']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Order date + if (!empty($arrayfields['c.date_commande']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Plannned date of delivery + if (!empty($arrayfields['c.date_delivery']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Shipping Method + if (!empty($arrayfields['c.fk_shipping_method']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Payment terms + if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Payment mode + if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Channel + if (!empty($arrayfields['c.fk_input_reason']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Amount HT/net + if (!empty($arrayfields['c.total_ht']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ht'; + } + if (isset($totalarray['val']['c.total_ht'])) { + $totalarray['val']['c.total_ht'] += $obj->total_ht; } else { - $totalarray['val']['total_mark_rate'] = ''; + $totalarray['val']['c.total_ht'] = $obj->total_ht; } } - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Date creation - if (!empty($arrayfields['c.datec']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Amount VAT + if (!empty($arrayfields['c.total_vat']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'c.total_tva'; + } + if (isset($totalarray['val']['c.total_tva'])) { + $totalarray['val']['c.total_tva'] += $obj->total_tva; + } else { + $totalarray['val']['c.total_tva'] = $obj->total_tva; + } } - } - // Date modification - if (!empty($arrayfields['c.tms']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Amount TTC / gross + if (!empty($arrayfields['c.total_ttc']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ttc'; + } + if (isset($totalarray['val']['c.total_ttc'])) { + $totalarray['val']['c.total_ttc'] += $obj->total_ttc; + } else { + $totalarray['val']['c.total_ttc'] = $obj->total_ttc; + } } - } - // Date cloture - if (!empty($arrayfields['c.date_cloture']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Currency + if (!empty($arrayfields['c.multicurrency_code']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Note public - if (!empty($arrayfields['c.note_public']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Currency rate + if (!empty($arrayfields['c.multicurrency_tx']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Note private - if (!empty($arrayfields['c.note_private']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Amount HT/net in foreign currency + if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount VAT in foreign currency + if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount TTC / gross in foreign currency + if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Show shippable Icon (this creates subloops, so may be slow) - if (!empty($arrayfields['shippable']['checked'])) { - print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Sales representatives + if (!empty($arrayfields['sale_representative']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } - // Get local and virtual stock and store it into cache - if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product])) { - $generic_product->load_stock('nobatch,warehouseopen'); // ->load_virtual_stock() is already included into load_stock() - $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_reel; - $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique; + // Total buying or cost price + if (!empty($arrayfields['total_pa']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Total margin + if (!empty($arrayfields['total_margin']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'total_margin'; + } + $totalarray['val']['total_margin'] += $marginInfo['total_margin']; + } + + // Total margin rate + if (!empty($arrayfields['total_margin_rate']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Total mark rate + if (!empty($arrayfields['total_mark_rate']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate'; + } + if ($i >= $imaxinloop - 1) { + if (!empty($total_ht)) { + $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT'); + } else { + $totalarray['val']['total_mark_rate'] = ''; + } + } + } + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Date creation + if (!empty($arrayfields['c.datec']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date modification + if (!empty($arrayfields['c.tms']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date cloture + if (!empty($arrayfields['c.date_cloture']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Note public + if (!empty($arrayfields['c.note_public']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Note private + if (!empty($arrayfields['c.note_private']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Show shippable Icon (this creates subloops, so may be slow) + if (!empty($arrayfields['shippable']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; } } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Billed - if (!empty($arrayfields['c.facture']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Import key - if (!empty($arrayfields['c.import_key']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Status - if (!empty($arrayfields['c.fk_statut']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Action column - if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; + if (!$i) { + $totalarray['nbfield']++; } - print ''; } - print ''; - if (!$i) { - $totalarray['nbfield']++; + + // Import key + if (!empty($arrayfields['c.import_key']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } + + // Status + if (!empty($arrayfields['c.fk_statut']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Action column + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + print "\n"; + + $total += $obj->total_ht; + $subtotal += $obj->total_ht; } - - print "\n"; - - $total += $obj->total_ht; - $subtotal += $obj->total_ht; $i++; } diff --git a/htdocs/commande/list_det.php b/htdocs/commande/list_det.php new file mode 100644 index 00000000000..fd36f229e5c --- /dev/null +++ b/htdocs/commande/list_det.php @@ -0,0 +1,2168 @@ + + * Copyright (C) 2004-2019 Laurent Destailleur + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2013 Christophe Battarel + * Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2015-2018 Frédéric France + * Copyright (C) 2015 Marcos García + * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2016-2021 Ferran Marcet + * Copyright (C) 2018 Charlene Benke + * Copyright (C) 2021-2022 Anthony Berton + * + * 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/commande/list.php + * \ingroup commande + * \brief Page to list orders + */ + +require '../main.inc.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/class/discount.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.formcompany.class.php'; +if (!empty($conf->margin->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; +} +require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array("orders", 'sendings', 'deliveries', 'companies', 'compta', 'bills', 'stocks', 'products')); + +$action = GETPOST('action', 'aZ09'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); +$toselect = GETPOST('toselect', 'array'); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'orderlistdet'; +$productobuy = GETPOST('productobuy', 'alpha'); +$productonly = GETPOST('productonly', 'alpha'); +$disablelinefree = GETPOST('disablelinefree', 'alpha'); + +$search_datecloture_start = GETPOST('search_datecloture_start', 'int'); +if (empty($search_datecloture_start)) { + $search_datecloture_start = dol_mktime(0, 0, 0, GETPOST('search_datecloture_startmonth', 'int'), GETPOST('search_datecloture_startday', 'int'), GETPOST('search_datecloture_startyear', 'int')); +} +$search_datecloture_end = GETPOST('search_datecloture_end', 'int'); +if (empty($search_datecloture_end)) { + $search_datecloture_end = dol_mktime(23, 59, 59, GETPOST('search_datecloture_endmonth', 'int'), GETPOST('search_datecloture_endday', 'int'), GETPOST('search_datecloture_endyear', 'int')); +} +$search_dateorder_start = dol_mktime(0, 0, 0, GETPOST('search_dateorder_start_month', 'int'), GETPOST('search_dateorder_start_day', 'int'), GETPOST('search_dateorder_start_year', 'int')); +$search_dateorder_end = dol_mktime(23, 59, 59, GETPOST('search_dateorder_end_month', 'int'), GETPOST('search_dateorder_end_day', 'int'), GETPOST('search_dateorder_end_year', 'int')); +$search_datedelivery_start = dol_mktime(0, 0, 0, GETPOST('search_datedelivery_start_month', 'int'), GETPOST('search_datedelivery_start_day', 'int'), GETPOST('search_datedelivery_start_year', 'int')); +$search_datedelivery_end = dol_mktime(23, 59, 59, GETPOST('search_datedelivery_end_month', 'int'), GETPOST('search_datedelivery_end_day', 'int'), GETPOST('search_datedelivery_end_year', 'int')); +$search_product_category = GETPOST('search_product_category', 'int'); + +// Détail commande +$search_refProduct = GETPOST('search_refProduct', 'alpha'); +$search_descProduct = GETPOST('search_descProduct', 'alpha'); + +$search_ref = GETPOST('search_ref', 'alpha') != '' ?GETPOST('search_ref', 'alpha') : GETPOST('sref', 'alpha'); +$search_ref_customer = GETPOST('search_ref_customer', 'alpha'); +$search_company = GETPOST('search_company', 'alpha'); +$search_company_alias = GETPOST('search_company_alias', 'alpha'); +$search_town = GETPOST('search_town', 'alpha'); +$search_zip = GETPOST('search_zip', 'alpha'); +$search_state = GETPOST("search_state", 'alpha'); +$search_country = GETPOST("search_country", 'int'); +$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$socid = GETPOST('socid', 'int'); +$search_user = GETPOST('search_user', 'int'); +$search_sale = GETPOST('search_sale', 'int'); +$search_total_ht = GETPOST('search_total_ht', 'alpha'); +$search_total_vat = GETPOST('search_total_vat', 'alpha'); +$search_total_ttc = GETPOST('search_total_ttc', 'alpha'); +$search_warehouse = GETPOST('search_warehouse', 'int'); +$search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha'); +$search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha'); +$search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha'); +$search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha'); +$search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha'); +$search_login = GETPOST('search_login', 'alpha'); +$search_categ_cus = GETPOST("search_categ_cus", 'int'); +$optioncss = GETPOST('optioncss', 'alpha'); +$search_billed = GETPOSTISSET('search_billed') ? GETPOST('search_billed', 'int') : GETPOST('billed', 'int'); +$search_status = GETPOST('search_status', 'int'); +$search_btn = GETPOST('button_search', 'alpha'); +$search_remove_btn = GETPOST('button_removefilter', 'alpha'); +$search_project_ref = GETPOST('search_project_ref', 'alpha'); +$search_project = GETPOST('search_project', 'alpha'); +$search_shippable = GETPOST('search_shippable', 'aZ09'); +$search_fk_cond_reglement = GETPOST("search_fk_cond_reglement", 'int'); +$search_fk_shipping_method = GETPOST("search_fk_shipping_method", 'int'); +$search_fk_mode_reglement = GETPOST("search_fk_mode_reglement", 'int'); +$search_fk_input_reason = GETPOST("search_fk_input_reason", 'int'); + +// Security check +$id = (GETPOST('orderid') ?GETPOST('orderid', 'int') : GETPOST('id', 'int')); +if ($user->socid) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'commande', $id, ''); + +$diroutputmassaction = $conf->commande->multidir_output[$conf->entity].'/temp/massgeneration/'.$user->id; + +// 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 (!$sortfield) { + $sortfield = 'c.ref'; +} +if (!$sortorder) { + $sortorder = 'DESC'; +} + +$show_shippable_command = GETPOST('show_shippable_command', 'aZ09'); + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$object = new Commande($db); +$hookmanager->initHooks(array('orderlistdetail')); +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array( + 'c.ref'=>'Ref', + 'c.ref_client'=>'RefCustomerOrder', + 'pd.description'=>'Description', + 's.nom'=>"ThirdParty", + 's.name_alias'=>"AliasNameShort", + 's.zip'=>"Zip", + 's.town'=>"Town", + 'c.note_public'=>'NotePublic', +); +if (empty($user->socid)) { + $fieldstosearchall["c.note_private"] = "NotePrivate"; +} + +$checkedtypetiers = 0; +$arrayfields = array( + // Détail commande + 'pr.ref'=> array('label'=>'ProductRef', 'checked'=>1, 'position'=>1), + 'pr.desc'=> array('label'=>'ProductDescription', 'checked'=>1, 'position'=>1), + 'cdet.qty'=> array('label'=>'QtyOrdered', 'checked'=>1, 'position'=>1), + 'c.ref'=>array('label'=>"Ref", 'checked'=>1, 'position'=>5), + 'c.ref_client'=>array('label'=>"RefCustomerOrder", 'checked'=>-1, 'position'=>10), + 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>-1, 'enabled'=>(empty($conf->project->enabled) ? 0 : 1), 'position'=>20), + 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->project->enabled) ? 0 : 1), 'position'=>25), + 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30), + 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>-1, 'position'=>31), + 's.town'=>array('label'=>"Town", 'checked'=>-1, 'position'=>35), + 's.zip'=>array('label'=>"Zip", 'checked'=>-1, 'position'=>40), + 'state.nom'=>array('label'=>"StateShort", 'checked'=>0, 'position'=>45), + 'country.code_iso'=>array('label'=>"Country", 'checked'=>0, 'position'=>50), + 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers, 'position'=>55), + 'c.date_commande'=>array('label'=>"OrderDateShort", 'checked'=>1, 'position'=>60), + 'c.date_delivery'=>array('label'=>"DateDeliveryPlanned", 'checked'=>1, 'enabled'=>empty($conf->global->ORDER_DISABLE_DELIVERY_DATE), 'position'=>65), + 'c.fk_shipping_method'=>array('label'=>"SendingMethod", 'checked'=>-1, 'position'=>66 , 'enabled'=>!empty($conf->expedition->enabled)), + 'c.fk_cond_reglement'=>array('label'=>"PaymentConditionsShort", 'checked'=>-1, 'position'=>67), + 'c.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>-1, 'position'=>68), + 'c.fk_input_reason'=>array('label'=>"Channel", 'checked'=>-1, 'position'=>69), + 'cdet.total_ht'=>array('label'=>"AmountHT", 'checked'=>1, 'position'=>75), + 'c.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0, 'position'=>80), + 'cdet.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0, 'position'=>85), + 'c.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>90), + 'c.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>95), + 'c.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>100), + 'c.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>105), + 'c.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>110), + 'c.fk_warehouse'=>array('label'=>'Warehouse', 'checked'=>0, 'enabled'=>(empty($conf->stock->enabled) && empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER) ? 0 : 1), 'position'=>110), + 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>115), + 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>0, 'position'=>116), + 'total_pa' => array('label' => (getDolGlobalString('MARGIN_TYPE') == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)), + 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)), + 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARGIN_RATES) ? 0 : 1)), + 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)), + 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>120), + 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>125), + 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>130), + 'c.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES)), 'position'=>135), + 'c.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES)), 'position'=>140), + 'shippable'=>array('label'=>"Shippable", 'checked'=>1,'enabled'=>(!empty($conf->expedition->enabled)), 'position'=>990), + 'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)), 'position'=>995), + 'c.import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>999), + 'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000) +); + +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; + +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); + + + +/* + * Actions + */ + +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { + $massaction = ''; +} + +$parameters = array('socid'=>$socid); +$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 + $productobuy = ''; + $productonly = ''; + $disablelinefree = ''; + $search_categ = ''; + $search_user = ''; + $search_sale = ''; + $search_product_category = ''; + $search_refProduct = ''; + $search_descProduct = ''; + $search_ref = ''; + $search_ref_customer = ''; + $search_company = ''; + $search_company_alias = ''; + $search_town = ''; + $search_zip = ""; + $search_state = ""; + $search_type = ''; + $search_country = ''; + $search_type_thirdparty = ''; + $search_total_ht = ''; + $search_total_vat = ''; + $search_total_ttc = ''; + $search_warehouse = ''; + $search_multicurrency_code = ''; + $search_multicurrency_tx = ''; + $search_multicurrency_montant_ht = ''; + $search_multicurrency_montant_vat = ''; + $search_multicurrency_montant_ttc = ''; + $search_login = ''; + $search_dateorder_start = ''; + $search_dateorder_end = ''; + $search_datedelivery_start = ''; + $search_datedelivery_end = ''; + $search_project_ref = ''; + $search_project = ''; + $search_status = ''; + $search_billed = ''; + $toselect = array(); + $search_array_options = array(); + $search_categ_cus = 0; + $search_datecloture_start = ''; + $search_datecloture_end = ''; + $search_fk_cond_reglement = ''; + $search_fk_shipping_method = ''; + $search_fk_mode_reglement = ''; + $search_fk_input_reason = ''; + } + 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 = 'Commande'; + $objectlabel = 'Orders'; + $permissiontoread = $user->rights->commande->lire; + $permissiontoadd = $user->rights->commande->creer; + $permissiontodelete = $user->rights->commande->supprimer; + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { + $permissiontovalidate = $user->rights->commande->order_advance->validate; + $permissiontoclose = $user->rights->commande->order_advance->close; + $permissiontocancel = $user->rights->commande->order_advance->annuler; + $permissiontosendbymail = $user->rights->commande->order_advance->send; + } else { + $permissiontovalidate = $user->rights->commande->creer; + $permissiontoclose = $user->rights->commande->creer; + $permissiontocancel = $user->rights->commande->creer; + $permissiontosendbymail = $user->rights->commande->creer; + } + $uploaddir = $conf->commande->multidir_output[$conf->entity]; + $triggersendname = 'ORDER_SENTBYMAIL'; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; +} + +// Closed records +// if (!$error && $massaction === 'setbilled' && $permissiontoclose) { + +// } + +/* + * View + */ + +$now = dol_now(); + +$form = new Form($db); +$formother = new FormOther($db); +$formfile = new FormFile($db); +$formmargin = null; +if (!empty($conf->margin->enabled)) { + $formmargin = new FormMargin($db); +} +$companystatic = new Societe($db); +$formcompany = new FormCompany($db); +$projectstatic = new Project($db); + +$title = $langs->trans("Orders"); +$help_url = "EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes"; +// llxHeader('',$title,$help_url); + +$sql = 'SELECT'; +if ($sall || $search_product_category > 0 || $search_user > 0) { + $sql = 'SELECT DISTINCT'; +} +$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; +$sql .= " typent.code as typent_code,"; +$sql .= " state.code_departement as state_code, state.nom as state_name,"; +$sql .= " country.code as country_code,"; +$sql .= ' c.rowid as c_rowid, c.ref, c.ref_client, c.fk_user_author,'; +$sql .= ' c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva as multicurrency_total_vat, c.multicurrency_total_ttc,'; +$sql .= ' c.total_ht as c_total_ht, c.total_tva as c_total_tva, c.total_ttc as c_total_ttc, c.fk_warehouse as warehouse,'; +$sql .= ' c.date_valid, c.date_commande, c.note_public, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed,'; +$sql .= ' c.date_creation as date_creation, c.tms as date_update, c.date_cloture as date_cloture,'; +$sql .= ' p.rowid as project_id, p.ref as project_ref, p.title as project_label,'; +$sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender,'; +$sql .= ' c.fk_cond_reglement,c.deposit_percent,c.fk_mode_reglement,c.fk_shipping_method,'; +$sql .= ' c.fk_input_reason, c.import_key'; + +// Détail commande +$sql .= ', cdet.rowid, cdet.description, cdet.qty, cdet.product_type, cdet.fk_product, cdet.total_ht, cdet.total_tva, cdet.total_ttc, '; +$sql .= ' pr.rowid as product_rowid, pr.ref as product_ref, pr.label as product_label, pr.barcode as product_barcode, pr.tobatch as product_batch, pr.tosell as product_status, pr.tobuy as product_status_buy'; + +if (($search_categ_cus > 0) || ($search_categ_cus == -2)) { + $sql .= ", cc.fk_categorie, cc.fk_soc"; +} +// 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); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s'; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +if (($search_categ_cus > 0) || ($search_categ_cus == -2)) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ +} + +// Détail commande +$sql .= ', '.MAIN_DB_PREFIX.'commandedet as cdet'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande as c ON cdet.fk_commande=c.rowid'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as pr ON pr.rowid=cdet.fk_product'; + +if (!empty($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."commande_extrafields as ef on (c.rowid = ef.fk_object)"; +} +if ($sall || $search_product_category > 0) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON c.rowid=pd.fk_commande'; +} +if ($search_product_category > 0) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; +} +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = c.fk_projet"; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON c.fk_user_author = u.rowid'; + +// We'll need this table joined to the select in order to filter by sale +if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} +if ($search_user > 0) { + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; +} + +// 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 c.fk_soc = s.rowid'; +$sql .= ' AND c.entity IN ('.getEntity('commande').')'; +$sql .= ' AND cdet.product_type <> 9'; + +if (!empty($productobuy)) { + $sql .= " AND pr.tobuy = 1"; +} +if (!empty($productonly)) { + $sql .= " AND (cdet.product_type = 0 OR cdet.product_type = 1)"; +} +if (!empty($disablelinefree)) { + $sql .= " AND cdet.fk_product IS NOT NULL"; +} +if ($search_product_category > 0) { + $sql .= " AND cp.fk_categorie = ".((int) $search_product_category); +} +if ($socid > 0) { + $sql .= ' AND s.rowid = '.((int) $socid); +} +if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); +} +if ($search_refProduct) { + $sql .= natural_search('pr.ref', $search_refProduct); +} +if ($search_descProduct) { + $sql .= natural_search('pr.label', $search_descProduct); + $sql .= natural_search('cdet.description', $search_descProduct); +} +if ($search_ref) { + $sql .= natural_search('c.ref', $search_ref); +} +if ($search_ref_customer) { + $sql .= natural_search('c.ref_client', $search_ref_customer); +} +if ($sall) { + $sql .= natural_search(array_keys($fieldstosearchall), $sall); +} +if ($search_billed != '' && $search_billed >= 0) { + $sql .= ' AND c.facture = '.((int) $search_billed); +} +if ($search_status <> '') { + if ($search_status <= 3 && $search_status >= -1) { // status from -1 to 3 are real status (other are virtual combination) + if ($search_status == 1 && empty($conf->expedition->enabled)) { + $sql .= ' AND c.fk_statut IN (1,2)'; // If module expedition disabled, we include order with status 'sending in process' into 'validated' + } else { + $sql .= ' AND c.fk_statut = '.((int) $search_status); // brouillon, validee, en cours, annulee + } + } + if ($search_status == -2) { // To process + //$sql.= ' AND c.fk_statut IN (1,2,3) AND c.facture = 0'; + $sql .= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected + } + if ($search_status == -3) { // To bill + //$sql.= ' AND c.fk_statut in (1,2,3)'; + //$sql.= ' AND c.facture = 0'; // invoice not created + $sql .= ' AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))'; // validated, in process or closed but not billed + } + if ($search_status == -4) { // "validate and in progress" + $sql .= ' AND (c.fk_statut IN (1,2))'; // validated, in process + } +} + +if ($search_datecloture_start) { + $sql .= " AND c.date_cloture >= '".$db->idate($search_datecloture_start)."'"; +} +if ($search_datecloture_end) { + $sql .= " AND c.date_cloture <= '".$db->idate($search_datecloture_end)."'"; +} +if ($search_dateorder_start) { + $sql .= " AND c.date_commande >= '".$db->idate($search_dateorder_start)."'"; +} +if ($search_dateorder_end) { + $sql .= " AND c.date_commande <= '".$db->idate($search_dateorder_end)."'"; +} +if ($search_datedelivery_start) { + $sql .= " AND c.date_livraison >= '".$db->idate($search_datedelivery_start)."'"; +} +if ($search_datedelivery_end) { + $sql .= " AND c.date_livraison <= '".$db->idate($search_datedelivery_end)."'"; +} +if ($search_town) { + $sql .= natural_search('s.town', $search_town); +} +if ($search_zip) { + $sql .= natural_search("s.zip", $search_zip); +} +if ($search_state) { + $sql .= natural_search("state.nom", $search_state); +} +if ($search_country) { + $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')'; +} +if ($search_type_thirdparty && $search_type_thirdparty != '-1') { + $sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')'; +} +if ($search_company) { + $sql .= natural_search('s.nom', $search_company); +} +if ($search_company_alias) { + $sql .= natural_search('s.name_alias', $search_company_alias); +} +if ($search_sale > 0) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale); +} +if ($search_user > 0) { + $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".((int) $search_user); +} +if ($search_total_ht != '') { + $sql .= natural_search('cdet.total_ht', $search_total_ht, 1); +} +if ($search_total_vat != '') { + $sql .= natural_search('cdet.total_tva', $search_total_vat, 1); +} +if ($search_total_ttc != '') { + $sql .= natural_search('cdet.total_ttc', $search_total_ttc, 1); +} +if ($search_warehouse != '' && $search_warehouse > 0) { + $sql .= natural_search('c.fk_warehouse', $search_warehouse, 1); +} +if ($search_multicurrency_code != '') { + $sql .= " AND c.multicurrency_code = '".$db->escape($search_multicurrency_code)."'"; +} +if ($search_multicurrency_tx != '') { + $sql .= natural_search('c.multicurrency_tx', $search_multicurrency_tx, 1); +} +if ($search_multicurrency_montant_ht != '') { + $sql .= natural_search('c.multicurrency_total_ht', $search_multicurrency_montant_ht, 1); +} +if ($search_multicurrency_montant_vat != '') { + $sql .= natural_search('c.multicurrency_total_tva', $search_multicurrency_montant_vat, 1); +} +if ($search_multicurrency_montant_ttc != '') { + $sql .= natural_search('c.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); +} +if ($search_login) { + $sql .= natural_search(array("u.login", "u.firstname", "u.lastname"), $search_login); +} +if ($search_project_ref != '') { + $sql .= natural_search("p.ref", $search_project_ref); +} +if ($search_project != '') { + $sql .= natural_search("p.title", $search_project); +} +if ($search_categ_cus > 0) { + $sql .= " AND cc.fk_categorie = ".((int) $search_categ_cus); +} +if ($search_categ_cus == -2) { + $sql .= " AND cc.fk_categorie IS NULL"; +} +if ($search_fk_cond_reglement > 0) { + $sql .= " AND c.fk_cond_reglement = ".((int) $search_fk_cond_reglement); +} +if ($search_fk_shipping_method > 0) { + $sql .= " AND c.fk_shipping_method = ".((int) $search_fk_shipping_method); +} +if ($search_fk_mode_reglement > 0) { + $sql .= " AND c.fk_mode_reglement = ".((int) $search_fk_mode_reglement); +} +if ($search_fk_input_reason > 0) { + $sql .= " AND c.fk_input_reason = ".((int) $search_fk_input_reason); +} + +// 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); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; + +// 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; + +$sql .= $db->order($sortfield, $sortorder); + +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + $page = 0; + $offset = 0; + } +} + +$sql .= $db->plimit($limit + 1, $offset); +//print $sql; + +$resql = $db->query($sql); +if ($resql) { + if ($socid > 0) { + $soc = new Societe($db); + $soc->fetch($socid); + $title = $langs->trans('ListOrderLigne').' - '.$soc->name; + if (empty($search_company)) { + $search_company = $soc->name; + } + } else { + $title = $langs->trans('ListOrderLigne'); + } + if (strval($search_status) == '0') { + $title .= ' - '.$langs->trans('StatusOrderDraftShort'); + } + if ($search_status == 1) { + $title .= ' - '.$langs->trans('StatusOrderValidatedShort'); + } + if ($search_status == 2) { + $title .= ' - '.$langs->trans('StatusOrderSentShort'); + } + if ($search_status == 3) { + $title .= ' - '.$langs->trans('StatusOrderToBillShort'); + } + if ($search_status == -1) { + $title .= ' - '.$langs->trans('StatusOrderCanceledShort'); + } + if ($search_status == -2) { + $title .= ' - '.$langs->trans('StatusOrderToProcessShort'); + } + if ($search_status == -3) { + $title .= ' - '.$langs->trans('StatusOrderValidated').', '.(empty($conf->expedition->enabled) ? '' : $langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill'); + } + if ($search_status == -4) { + $title .= ' - '.$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort"); + } + + $num = $db->num_rows($resql); + + $arrayofselected = is_array($toselect) ? $toselect : array(); + + if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".DOL_URL_ROOT.'/commande/card.php?id='.$id); + exit; + } + + llxHeader('', $title, $help_url); + + $param = ''; + + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($sall) { + $param .= '&sall='.urlencode($sall); + } + if ($socid > 0) { + $param .= '&socid='.urlencode($socid); + } + if ($search_status != '') { + $param .= '&search_status='.urlencode($search_status); + } + if ($search_datecloture_start) { + $param .= '&search_datecloture_startday='.dol_print_date($search_datecloture_start, '%d').'&search_datecloture_startmonth='.dol_print_date($search_datecloture_start, '%m').'&search_datecloture_startyear='.dol_print_date($search_datecloture_start, '%Y'); + } + if ($search_datecloture_end) { + $param .= '&search_datecloture_endday='.dol_print_date($search_datecloture_end, '%d').'&search_datecloture_endmonth='.dol_print_date($search_datecloture_end, '%m').'&search_datecloture_endyear='.dol_print_date($search_datecloture_end, '%Y'); + } + if ($search_dateorder_start) { + $param .= '&search_dateorder_start_day='.dol_print_date($search_dateorder_start, '%d').'&search_dateorder_start_month='.dol_print_date($search_dateorder_start, '%m').'&search_dateorder_start_year='.dol_print_date($search_dateorder_start, '%Y'); + } + if ($search_dateorder_end) { + $param .= '&search_dateorder_end_day='.dol_print_date($search_dateorder_end, '%d').'&search_dateorder_end_month='.dol_print_date($search_dateorder_end, '%m').'&search_dateorder_end_year='.dol_print_date($search_dateorder_end, '%Y'); + } + if ($search_datedelivery_start) { + $param .= '&search_datedelivery_start_day='.dol_print_date($search_datedelivery_start, '%d').'&search_datedelivery_start_month='.dol_print_date($search_datedelivery_start, '%m').'&search_datedelivery_start_year='.dol_print_date($search_datedelivery_start, '%Y'); + } + if ($search_datedelivery_end) { + $param .= '&search_datedelivery_end_day='.dol_print_date($search_datedelivery_end, '%d').'&search_datedelivery_end_month='.dol_print_date($search_datedelivery_end, '%m').'&search_datedelivery_end_year='.dol_print_date($search_datedelivery_end, '%Y'); + } + if ($search_ref) { + $param .= '&search_ref='.urlencode($search_ref); + } + if ($search_company) { + $param .= '&search_company='.urlencode($search_company); + } + if ($search_company_alias) { + $param .= '&search_company_alias='.urlencode($search_company_alias); + } + if ($search_ref_customer) { + $param .= '&search_ref_customer='.urlencode($search_ref_customer); + } + if ($search_user > 0) { + $param .= '&search_user='.urlencode($search_user); + } + if ($search_sale > 0) { + $param .= '&search_sale='.urlencode($search_sale); + } + if ($search_total_ht != '') { + $param .= '&search_total_ht='.urlencode($search_total_ht); + } + if ($search_total_vat != '') { + $param .= '&search_total_vat='.urlencode($search_total_vat); + } + if ($search_total_ttc != '') { + $param .= '&search_total_ttc='.urlencode($search_total_ttc); + } + if ($search_warehouse != '') { + $param .= '&search_warehouse='.urlencode($search_warehouse); + } + if ($search_login) { + $param .= '&search_login='.urlencode($search_login); + } + if ($search_multicurrency_code != '') { + $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code); + } + if ($search_multicurrency_tx != '') { + $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx); + } + if ($search_multicurrency_montant_ht != '') { + $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht); + } + if ($search_multicurrency_montant_vat != '') { + $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat); + } + if ($search_multicurrency_montant_ttc != '') { + $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc); + } + if ($search_project_ref >= 0) { + $param .= "&search_project_ref=".urlencode($search_project_ref); + } + if ($search_town != '') { + $param .= '&search_town='.urlencode($search_town); + } + if ($search_zip != '') { + $param .= '&search_zip='.urlencode($search_zip); + } + if ($search_state != '') { + $param .= '&search_state='.urlencode($search_state); + } + if ($search_country != '') { + $param .= '&search_country='.urlencode($search_country); + } + if ($search_type_thirdparty && $search_type_thirdparty != '-1') { + $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); + } + if ($search_product_category != '') { + $param .= '&search_product_category='.urlencode($search_product_category); + } + if (($search_categ_cus > 0) || ($search_categ_cus == -2)) { + $param .= '&search_categ_cus='.urlencode($search_categ_cus); + } + if ($show_files) { + $param .= '&show_files='.urlencode($show_files); + } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } + if ($search_billed != '') { + $param .= '&search_billed='.urlencode($search_billed); + } + if ($search_fk_cond_reglement > 0) { + $param .= '&search_fk_cond_reglement='.urlencode($search_fk_cond_reglement); + } + if ($search_fk_shipping_method > 0) { + $param .= '&search_fk_shipping_method='.urlencode($search_fk_shipping_method); + } + if ($search_fk_mode_reglement > 0) { + $param .= '&search_fk_mode_reglement='.urlencode($search_fk_mode_reglement); + } + if ($search_fk_input_reason > 0) { + $param .= '&search_fk_input_reason='.urlencode($search_fk_input_reason); + } + + // 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( + 'GenerateOrdersSuppliers'=>img_picto('', 'doc', 'class="pictofixedwidth"').$langs->trans("GenerateOrdersSupplie"), + ); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); + + $url = DOL_URL_ROOT.'/commande/card.php?action=create'; + if (!empty($socid)) { + $url .= '&socid='.$socid; + } + $newcardbutton = '';//dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', $url, '', $contextpage == 'orderlistdet' && $permissiontoadd); + + // Lines of title fields + print ''; + if ($optioncss != '') { + print ''; + } + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'order', 0, $newcardbutton, '', $limit, 0, 0, 1); + + print ''; + print ''; + print ''; + + $topicmail = "SendOrderRef"; + $modelmail = "order_send"; + $objecttmp = new Commande($db); + $trackid = 'ord'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + + if ($sall) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; + } + + $moreforfilter = ''; + + // If the user can view prospects other than his' + 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 .= '
'; + } + // If the user can view other users + if ($user->rights->user->user->lire) { + $moreforfilter .= '
'; + $tmptitle = $langs->trans('LinkedToSpecificUsers'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx'); + $moreforfilter .= '
'; + } + // If the user can view prospects other than his' + if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { + include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '
'; + $tmptitle = $langs->trans('IncludingProductWithTag'); + $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300 widthcentpercentminusx', 1); + $moreforfilter .= '
'; + } + if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '
'; + $tmptitle = $langs->trans('CustomersProspectsCategoriesShort'); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $tmptitle, 'maxwidth300 widthcentpercentminusx'); + $moreforfilter .= '
'; + } + if (!empty($conf->stock->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; + $formproduct = new FormProduct($db); + $moreforfilter .= '
'; + $tmptitle = $langs->trans('Warehouse'); + $moreforfilter .= img_picto($tmptitle, 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses($search_warehouse, 'search_warehouse', '', 1, 0, 0, $tmptitle, 0, 0, array(), 'maxwidth250 widthcentpercentminusx'); + $moreforfilter .= '
'; + } + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // 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 .= $form->showCheckAddButtons('checkforselect', 1); + + if (GETPOST('autoselectall', 'int')) { + $selectedfields .= ''; + } + + print '
'; + print '
'; if (isModEnabled("propal") && $user->rights->propal->lire) { diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 2560e3bef05..67af97cfe12 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -134,7 +134,7 @@ if ($tmp) { * Draft customer proposals */ -if (isModEnabled("propal") && $user->rights->propal->lire) { +if (isModEnabled("propal") && $user->hasRight("propal", "lire")) { $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.total_tva, p.total_ttc, p.fk_statut as status"; $sql .= ", s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; @@ -232,7 +232,7 @@ if (isModEnabled("propal") && $user->rights->propal->lire) { * Draft supplier proposals */ -if (isModEnabled('supplier_proposal') && $user->rights->supplier_proposal->lire) { +if (isModEnabled('supplier_proposal') && $user->hasRight("supplier_proposal", "lire")) { $sql = "SELECT p.rowid, p.ref, p.total_ht, p.total_tva, p.total_ttc, p.fk_statut as status"; $sql .= ", s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; @@ -427,7 +427,7 @@ if (isModEnabled('commande') && $user->rights->commande->lire) { * Draft purchase orders */ -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->lire) || (isModEnabled("supplier_order") && $user->rights->supplier_order->lire)) { +if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "commande", "lire")) || (isModEnabled("supplier_order") && $user->hasRight("supplier_order", "lire"))) { $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ht, cf.total_tva, cf.total_ttc, cf.fk_statut as status"; $sql .= ", s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; @@ -819,7 +819,7 @@ if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERM /* * Latest contracts */ -if (isModEnabled('contrat') && $user->rights->contrat->lire && 0) { // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT +if (isModEnabled('contrat') && $user->hasRight("contrat", "lire") && 0) { // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT $staticcontrat = new Contrat($db); $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; @@ -897,7 +897,7 @@ if (isModEnabled('contrat') && $user->rights->contrat->lire && 0) { // TODO A RE /* * Opened (validated) proposals */ -if (isModEnabled("propal") && $user->rights->propal->lire) { +if (isModEnabled("propal") && $user->hasRight("propal", "lire")) { $sql = "SELECT p.rowid as propalid, p.entity, p.total_ttc, p.total_ht, p.total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; $sql .= ", s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 4ea794bfbd4..75cf669d3c8 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -217,9 +217,10 @@ class Mailing extends CommonObject * Create an EMailing * * @param User $user Object of user making creation - * @return int -1 if error, Id of created object if OK + * @param int $notrigger Disable triggers + * @return int <0 if KO, Id of created object if OK */ - public function create($user) + public function create($user, $notrigger = 0) { global $conf, $langs; @@ -229,8 +230,6 @@ class Mailing extends CommonObject return -1; } - $this->db->begin(); - $this->title = trim($this->title); $this->email_from = trim($this->email_from); @@ -239,7 +238,9 @@ class Mailing extends CommonObject return -1; } + $error = 0; $now = dol_now(); + $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing"; $sql .= " (date_creat, fk_user_creat, entity)"; @@ -249,20 +250,33 @@ class Mailing extends CommonObject $this->title = $langs->trans("NoTitle"); } - dol_syslog("Mailing::Create", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { + dol_syslog(__METHOD__, LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."mailing"); - if ($this->update($user) > 0) { - $this->db->commit(); - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return -1; + $result = $this->update($user, 1); + if ($result < 0) { + $error++; } - return $this->id; + if (!$error && !$notrigger) { + // Call trigger + $result = $this->call_trigger('MAILING_CREATE', $user); + if ($result < 0) { + $error++; + } + // End call triggers + } + + if (!$error) { + $this->db->commit(); + return $this->id; + } else { + $this->db->rollback(); + dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR); + return -2; + } } else { $this->error = $this->db->lasterror(); $this->db->rollback(); @@ -274,9 +288,10 @@ class Mailing extends CommonObject * Update emailing record * * @param User $user Object of user making change + * @param int $notrigger Disable triggers * @return int < 0 if KO, > 0 if OK */ - public function update($user) + public function update($user, $notrigger = 0) { // Check properties if ($this->body === 'InvalidHTMLString') { @@ -284,6 +299,9 @@ class Mailing extends CommonObject return -1; } + $error = 0; + $this->db->begin(); + $sql = "UPDATE ".MAIN_DB_PREFIX."mailing "; $sql .= " SET titre = '".$this->db->escape($this->title)."'"; $sql .= ", sujet = '".$this->db->escape($this->sujet)."'"; @@ -295,12 +313,30 @@ class Mailing extends CommonObject $sql .= ", bgimage = '".($this->bgimage ? $this->db->escape($this->bgimage) : null)."'"; $sql .= " WHERE rowid = ".(int) $this->id; - dol_syslog("Mailing::Update", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - return 1; + dol_syslog(__METHOD__, LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + if (!$error && !$notrigger) { + // Call trigger + $result = $this->call_trigger('MAILING_MODIFY', $user); + if ($result < 0) { + $error++; + } + // End call triggers + } + + if (!$error) { + dol_syslog(__METHOD__ . ' success'); + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR); + return -2; + } } else { $this->error = $this->db->lasterror(); + $this->db->rollback(); return -1; } } @@ -528,36 +564,46 @@ class Mailing extends CommonObject { global $user; + $error = 0; $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing"; - $sql .= " WHERE rowid = ".((int) $rowid); + if (!$notrigger) { + $result = $this->call_trigger('MAILING_DELETE', $user); + if ($result < 0) { + $error++; + } + } - dol_syslog("Mailing::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - $res = $this->delete_targets(); - if ($res <= 0) { + if (!$error) { + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "mailing"; + $sql .= " WHERE rowid = " . ((int) $rowid); + + dol_syslog(__METHOD__, LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $res = $this->delete_targets(); + if ($res <= 0) { + $error++; + } + + if (!$error) { + dol_syslog(__METHOD__ . ' success'); + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR); + return -2; + } + } else { $this->db->rollback(); $this->error = $this->db->lasterror(); return -1; } } else { $this->db->rollback(); - $this->error = $this->db->lasterror(); return -1; } - - if (!$notrigger) { - $result = $this->call_trigger('MAILING_DELETE', $user); - if ($result < 0) { - $this->db->rollback(); - return -1; - } - } - - $this->db->commit(); - return 1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index 13a7e63d364..6916a2dfe5d 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -33,6 +33,7 @@ $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $optioncss = GETPOST('optioncss', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; @@ -187,7 +188,7 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - $title = $langs->trans("ListOfEMailings"); + $title = $langs->trans("EMailings"); if ($filteremail) { $title .= ' ('.$langs->trans("SentTo", $filteremail).')'; } diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 07729fd55de..5fb464a6e8e 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1233,6 +1233,20 @@ if (empty($reshook)) { $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); + // Prepare a price equivalent for minimum price check + $pu_equivalent = $pu_ht; + $pu_equivalent_ttc = $pu_ttc; + $currency_tx = $object->multicurrency_tx; + + // Check if we have a foreing currency + // If so, we update the pu_equiv as the equivalent price in base currency + if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { + $pu_equivalent = $pu_ht_devise * $currency_tx; + } + if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { + $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; + } + // Local Taxes $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $tva_npr); @@ -1246,11 +1260,11 @@ if (empty($reshook)) { //var_dump(price2num($price_min_ttc)); var_dump(price2num($pu_ttc)); var_dump($remise_percent);exit; if ($usermustrespectpricemin) { - if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) { + if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; - } elseif ($pu_ttc && $price_min_ttc && ((price2num($pu_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) { + } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; @@ -1349,6 +1363,20 @@ if (empty($reshook)) { $remise_percent = price2num(GETPOST('remise_percent'), '', 2); + // Prepare a price equivalent for minimum price check + $pu_equivalent = $pu_ht; + $pu_equivalent_ttc = $pu_ttc; + $currency_tx = $object->multicurrency_tx; + + // Check if we have a foreing currency + // If so, we update the pu_equiv as the equivalent price in base currency + if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { + $pu_equivalent = $pu_ht_devise * $currency_tx; + } + if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { + $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; + } + // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); $array_options = $extrafields->getOptionalsFromPost($object->table_element_line); @@ -1388,12 +1416,12 @@ if (empty($reshook)) { //var_dump(price2num($price_min_ttc)); var_dump(price2num($pu_ttc)); var_dump($remise_percent);exit; if ($usermustrespectpricemin) { - if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) { + if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; $action = 'editline'; - } elseif ($pu_ttc && $price_min_ttc && ((price2num($pu_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) { + } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; @@ -1830,7 +1858,7 @@ if ($action == 'create') { } print '
'.$langs->trans('SendingMethod').''; print img_picto('', 'object_dollyrevert', 'class="pictofixedwidth"'); - print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); + $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); print '
'; - print ''; + print ''; + print ''; print ''; - $formpropal->selectProposalStatus($search_status, 1, 0, 1, 'customer', 'search_statut', 'search_status maxwidth125 onrightofpage'); + print ''; + $formpropal->selectProposalStatus($search_status, 1, 0, 1, 'customer', 'search_statut', 'search_status width100 onrightofpage'); print '
'.$langs->trans("Proposal"); + print ''.$langs->trans("Proposal"); if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { $url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$objectlink->id; print ' '; } print ''.$objectlink->getNomUrl(1).''.$objectlink->getNomUrl(1).''.$objectlink->ref_client.''.dol_print_date($objectlink->date, 'day').''; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 786fb1a2ad2..ccf706c9ac7 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -682,7 +682,23 @@ if (empty($reshook)) { $tva_tx = ''; } + + // Prepare a price equivalent for minimum price check + $pu_equivalent = $pu_ht; + $pu_equivalent_ttc = $pu_ttc; + $currency_tx = $object->multicurrency_tx; + + // Check if we have a foreing currency + // If so, we update the pu_equiv as the equivalent price in base currency + if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { + $pu_equivalent = $pu_ht_devise * $currency_tx; + } + if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { + $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; + } + $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2); + $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha'), '', 2) : 0); if (empty($remise_percent)) { $remise_percent = 0; @@ -985,11 +1001,11 @@ if (empty($reshook)) { $desc = dol_htmlcleanlastbr($desc); if ($usermustrespectpricemin) { - if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) { + if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; - } elseif ($pu_ttc && $price_min_ttc && ((price2num($pu_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) { + } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; @@ -1075,6 +1091,20 @@ if (empty($reshook)) { $qty = price2num(GETPOST('qty', 'alpha'), 'MS'); + // Prepare a price equivalent for minimum price check + $pu_equivalent = $pu_ht; + $pu_equivalent_ttc = $pu_ttc; + $currency_tx = $object->multicurrency_tx; + + // Check if we have a foreing currency + // If so, we update the pu_equiv as the equivalent price in base currency + if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { + $pu_equivalent = $pu_ht_devise * $currency_tx; + } + if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { + $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; + } + // Define info_bits $info_bits = 0; if (preg_match('/\*/', $vat_rate)) { @@ -1106,7 +1136,7 @@ if (empty($reshook)) { $special_code = 3; } - $remise_percent = price2num(GETPOST('remise_percent'), '', 2); + $remise_percent = GETPOST('remise_percent') != '' ? price2num(GETPOST('remise_percent'), '', 2) : 0; // Check minimum price $productid = GETPOST('productid', 'int'); @@ -1128,12 +1158,12 @@ if (empty($reshook)) { $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); if ($usermustrespectpricemin) { - if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) { + if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; $action = 'editline'; - } elseif ($pu_ttc && $price_min_ttc && ((price2num($pu_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) { + } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; @@ -1833,7 +1863,8 @@ if ($action == 'create' && $usercancreate) { // Shipping Method if (isModEnabled('expedition')) { print '
'.$langs->trans('SendingMethod').''; - print img_picto('', 'object_dolly', 'class="pictofixedwidth"').$form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); + print img_picto('', 'object_dolly', 'class="pictofixedwidth"'); + $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); print '
'; $incoterm_id = GETPOST('incoterm_id'); $incoterm_location = GETPOST('location_incoterms'); @@ -1898,7 +1929,7 @@ if ($action == 'create' && $usercancreate) { if ($soc->fetch_optionals() > 0) { $object->array_options = array_merge($object->array_options, $soc->array_options); } - }; + } print $object->showOptionals($extrafields, 'create', $parameters); } @@ -2736,7 +2767,7 @@ if ($action == 'create' && $usercancreate) { // Show object lines if (!empty($object->lines)) { - $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); + $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); } $numlines = count($object->lines); @@ -2840,7 +2871,7 @@ if ($action == 'create' && $usercancreate) { // Ship $numshipping = 0; if (isModEnabled('expedition')) { - $numshipping = $object->nb_expedition(); + $numshipping = $object->countNbOfShipments(); if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && ($object->getNbOfProductsLines() > 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) { if ((isModEnabled('expedition_bon') && $user->rights->expedition->creer) || ($conf->delivery_note->enabled && $user->rights->expedition->delivery->creer)) { diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 2c916abda9a..1a879173684 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -28,7 +28,6 @@ require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; */ class Orders extends DolibarrApi { - /** * @var array $FIELDS Mandatory fields, checked when create and update object */ @@ -109,11 +108,11 @@ class Orders extends DolibarrApi * * Return an array with order informations * - * @param int $id ID of order + * @param int $id ID of order * @param string $ref Ref of object * @param string $ref_ext External reference of object - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id - * @return array|mixed data without useless information + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return Object Object with cleaned properties * * @throws RestException */ @@ -299,7 +298,7 @@ class Orders extends DolibarrApi * * @url GET {id}/lines * - * @return int + * @return array */ public function getLines($id) { @@ -393,13 +392,12 @@ class Orders extends DolibarrApi /** * Update a line to given order * - * @param int $id Id of order to update - * @param int $lineid Id of line to update - * @param array $request_data OrderLine data + * @param int $id Id of order to update + * @param int $lineid Id of line to update + * @param array $request_data OrderLine data + * @return Object|false Object with cleaned properties * * @url PUT {id}/lines/{lineid} - * - * @return array|bool */ public function putLine($id, $lineid, $request_data = null) { @@ -458,16 +456,14 @@ class Orders extends DolibarrApi } /** - * Delete a line to given order + * Delete a line of a given order * - * - * @param int $id Id of order to update - * @param int $lineid Id of line to delete + * @param int $id Id of order to update + * @param int $lineid Id of line to delete + * @return Object Object with cleaned properties * * @url DELETE {id}/lines/{lineid} * - * @return int - * * @throws RestException 401 * @throws RestException 404 */ @@ -486,9 +482,7 @@ class Orders extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - // TODO Check the lineid $lineid is a line of ojbect - - $updateRes = $this->commande->deleteline(DolibarrApiAccess::$user, $lineid); + $updateRes = $this->commande->deleteline(DolibarrApiAccess::$user, $lineid, $id); if ($updateRes > 0) { return $this->get($id); } else { @@ -501,13 +495,12 @@ class Orders extends DolibarrApi * * Return an array with contact informations * - * @param int $id ID of order - * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER) + * @param int $id ID of order + * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER) + * @return Object Object with cleaned properties * * @url GET {id}/contacts * - * @return array data without useless information - * * @throws RestException */ public function getContacts($id, $type = '') @@ -536,11 +529,10 @@ class Orders extends DolibarrApi * @param int $id Id of order to update * @param int $contactid Id of contact to add * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER) + * @return array * * @url POST {id}/contact/{contactid}/{type} * - * @return int - * * @throws RestException 401 * @throws RestException 404 */ @@ -586,7 +578,7 @@ class Orders extends DolibarrApi * * @url DELETE {id}/contact/{contactid}/{type} * - * @return int + * @return array * * @throws RestException 401 * @throws RestException 404 @@ -630,10 +622,9 @@ class Orders extends DolibarrApi /** * Update order general fields (won't touch lines of order) * - * @param int $id Id of order to update - * @param array $request_data Datas - * - * @return int + * @param int $id Id of order to update + * @param array $request_data Datas + * @return Object Object with cleaned properties */ public function put($id, $request_data = null) { @@ -777,7 +768,6 @@ class Orders extends DolibarrApi */ public function reopen($id) { - if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } @@ -802,12 +792,11 @@ class Orders extends DolibarrApi /** * Classify the order as invoiced. Could be also called setbilled * - * @param int $id Id of the order + * @param int $id Id of the order + * @return Object Object with cleaned properties * * @url POST {id}/setinvoiced * - * @return int - * * @throws RestException 400 * @throws RestException 401 * @throws RestException 404 @@ -851,10 +840,9 @@ class Orders extends DolibarrApi * * @param int $id Order ID * @param int $notrigger Disabled triggers + * @return Object Object with cleaned properties * * @url POST {id}/close - * - * @return int */ public function close($id, $notrigger = 0) { @@ -897,10 +885,9 @@ class Orders extends DolibarrApi * * @param int $id Order ID * @param int $idwarehouse Warehouse ID to use for stock change (Used only if option STOCK_CALCULATE_ON_VALIDATE_ORDER is on) + * @return Object Object with cleaned properties * * @url POST {id}/settodraft - * - * @return array */ public function settodraft($id, $idwarehouse = -1) { @@ -942,12 +929,11 @@ class Orders extends DolibarrApi /** * Create an order using an existing proposal. * - * * @param int $proposalid Id of the proposal + * @return Object Object with cleaned properties * * @url POST /createfromproposal/{proposalid} * - * @return int * @throws RestException 400 * @throws RestException 401 * @throws RestException 404 diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 73988594e6f..29f990476ed 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1173,6 +1173,8 @@ class Commande extends CommonOrder return -1; } } + + return 0; } else { dol_print_error($this->db); $this->db->rollback(); @@ -1301,6 +1303,7 @@ class Commande extends CommonOrder { global $conf, $hookmanager; + dol_include_once('/multicurrency/class/multicurrency.class.php'); dol_include_once('/core/class/extrafields.class.php'); $error = 0; @@ -1376,6 +1379,29 @@ class Commande extends CommonOrder $this->origin = $object->element; $this->origin_id = $object->id; + // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) + if (!empty($conf->multicurrency->enabled)) { + if (!empty($object->multicurrency_code)) { + $this->multicurrency_code = $object->multicurrency_code; + } + if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($object->multicurrency_tx)) { + $this->multicurrency_tx = $object->multicurrency_tx; + } + + if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) { + $tmparray = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $this->date_commande); + $this->fk_multicurrency = $tmparray[0]; + $this->multicurrency_tx = $tmparray[1]; + } else { + $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); + } + if (empty($this->fk_multicurrency)) { + $this->multicurrency_code = $conf->currency; + $this->fk_multicurrency = 0; + $this->multicurrency_tx = 1; + } + } + // get extrafields from original line $object->fetch_optionals(); @@ -2283,17 +2309,13 @@ class Commande extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Returns a array with expeditions lines number + * Returns an array with expeditions lines number * * @return int Nb of shipments - * - * TODO deprecate, move to Shipping class */ - public function nb_expedition() + public function countNbOfShipments() { - // phpcs:enable $sql = 'SELECT count(*)'; $sql .= ' FROM '.MAIN_DB_PREFIX.'expedition as e'; $sql .= ', '.MAIN_DB_PREFIX.'element_element as el'; @@ -2309,6 +2331,8 @@ class Commande extends CommonOrder } else { dol_print_error($this->db); } + + return 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2355,58 +2379,45 @@ class Commande extends CommonOrder * * @param User $user User object * @param int $lineid Id of line to delete + * @param int $id Id of object (for a check) * @return int >0 if OK, 0 if nothing to do, <0 if KO */ - public function deleteline($user = null, $lineid = 0) + public function deleteline($user = null, $lineid = 0, $id = 0) { if ($this->statut == self::STATUS_DRAFT) { $this->db->begin(); - $sql = "SELECT fk_product, qty"; - $sql .= " FROM ".MAIN_DB_PREFIX."commandedet"; - $sql .= " WHERE rowid = ".((int) $lineid); + // Delete line + $line = new OrderLine($this->db); - $result = $this->db->query($sql); - if ($result) { - $obj = $this->db->fetch_object($result); + $line->context = $this->context; - if ($obj) { - $product = new Product($this->db); - $product->id = $obj->fk_product; + // Load data + $line->fetch($lineid); - // Delete line - $line = new OrderLine($this->db); + if ($id > 0 && $line->fk_commande != $id) { + $this->error = 'ErrorLineIDDoesNotMatchWithObjectID'; + return -1; + } - // For triggers - $line->fetch($lineid); + // Memorize previous line for triggers + $staticline = clone $line; + $line->oldline = $staticline; - // Memorize previous line for triggers - $staticline = clone $line; - $line->oldline = $staticline; + if ($line->delete($user) > 0) { + $result = $this->update_price(1); - if ($line->delete($user) > 0) { - $result = $this->update_price(1); - - if ($result > 0) { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - $this->error = $this->db->lasterror(); - return -1; - } - } else { - $this->db->rollback(); - $this->error = $line->error; - return -1; - } + if ($result > 0) { + $this->db->commit(); + return 1; } else { $this->db->rollback(); - return 0; + $this->error = $this->db->lasterror(); + return -1; } } else { $this->db->rollback(); - $this->error = $this->db->lasterror(); + $this->error = $line->error; return -1; } } else { @@ -2490,6 +2501,8 @@ class Commande extends CommonOrder return -1 * $error; } } + + return 0; } @@ -2554,6 +2567,8 @@ class Commande extends CommonOrder return -1 * $error; } } + + return 0; } @@ -3352,7 +3367,7 @@ class Commande extends CommonOrder $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; $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 .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null").""; + $sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); $sql .= " WHERE rowid=".((int) $this->id); @@ -3422,7 +3437,7 @@ class Commande extends CommonOrder } // Test we can delete - if ($this->nb_expedition() != 0) { + if ($this->countNbOfShipments() != 0) { $this->errors[] = $langs->trans('SomeShipmentExists'); $error++; } @@ -4043,18 +4058,18 @@ class Commande extends CommonOrder /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'commande' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** @@ -4331,16 +4346,6 @@ class OrderLine extends CommonOrderLine dol_syslog("OrderLine::delete", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - // Remove extrafields - if (!$error) { - $this->id = $this->rowid; - $result = $this->deleteExtraFields(); - if ($result < 0) { - $error++; - dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); - } - } - if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('LINEORDER_DELETE', $user); @@ -4350,6 +4355,15 @@ class OrderLine extends CommonOrderLine // End call triggers } + // Remove extrafields + if (!$error) { + $result = $this->deleteExtraFields(); + if ($result < 0) { + $error++; + dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); + } + } + if (!$error) { $this->db->commit(); return 1; @@ -4626,14 +4640,14 @@ class OrderLine extends CommonOrderLine $sql .= " , localtax2_type='".$this->db->escape($this->localtax2_type)."'"; $sql .= " , qty=".price2num($this->qty); $sql .= " , ref_ext='".$this->db->escape($this->ref_ext)."'"; - $sql .= " , subprice=".price2num($this->subprice).""; - $sql .= " , remise_percent=".price2num($this->remise_percent).""; - $sql .= " , price=".price2num($this->price).""; // TODO A virer - $sql .= " , remise=".price2num($this->remise).""; // TODO A virer + $sql .= " , subprice=".price2num($this->subprice); + $sql .= " , remise_percent=".price2num($this->remise_percent); + $sql .= " , price=".price2num($this->price); // TODO A virer + $sql .= " , remise=".price2num($this->remise); // TODO A virer if (empty($this->skip_update_total)) { - $sql .= " , total_ht=".price2num($this->total_ht).""; - $sql .= " , total_tva=".price2num($this->total_tva).""; - $sql .= " , total_ttc=".price2num($this->total_ttc).""; + $sql .= " , total_ht=".price2num($this->total_ht); + $sql .= " , total_tva=".price2num($this->total_tva); + $sql .= " , total_ttc=".price2num($this->total_ttc); $sql .= " , total_localtax1=".price2num($this->total_localtax1); $sql .= " , total_localtax2=".price2num($this->total_localtax2); } @@ -4651,10 +4665,10 @@ class OrderLine extends CommonOrderLine $sql .= " , fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit); // Multicurrency - $sql .= " , multicurrency_subprice=".price2num($this->multicurrency_subprice).""; - $sql .= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; - $sql .= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; - $sql .= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; + $sql .= " , multicurrency_subprice=".price2num($this->multicurrency_subprice); + $sql .= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht); + $sql .= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva); + $sql .= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc); $sql .= " WHERE rowid = ".((int) $this->rowid); diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 4257d1414b1..98d2b59d6a3 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -60,6 +60,7 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'orderlist'; +$mode = GETPOST('mode', 'alpha'); // Search Parameters $search_datecloture_start = GETPOST('search_datecloture_start', 'int'); @@ -201,10 +202,10 @@ $arrayfields = array( 'c.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1), 'position'=>110), 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>115), 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>0, 'position'=>116), - 'total_pa' => array('label' => (getDolGlobalString('MARGIN_TYPE') == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (!isModEnabled('margin') || !$user->rights->margins->liretous ? 0 : 1)), - 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (!isModEnabled('margin') || !$user->rights->margins->liretous ? 0 : 1)), - 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (!isModEnabled('margin') || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARGIN_RATES) ? 0 : 1)), - 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (!isModEnabled('margin') || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)), + 'total_pa' => array('label' => (getDolGlobalString('MARGIN_TYPE') == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (!isModEnabled('margin') || !$user->hasRight("margins", "liretous") ? 0 : 1)), + 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (!isModEnabled('margin') || !$user->hasRight("margins", "liretous") ? 0 : 1)), + 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (!isModEnabled('margin') || !$user->hasRight("margins", "liretous") || empty($conf->global->DISPLAY_MARGIN_RATES) ? 0 : 1)), + 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (!isModEnabled('margin') || !$user->hasRight("margins", "liretous") || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)), 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>120), 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>125), 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>130), @@ -235,7 +236,7 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa $massaction = ''; } -$parameters = array('socid'=>$socid); +$parameters = array('socid'=>$socid, 'arrayfields'=>&$arrayfields); $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'); @@ -298,19 +299,19 @@ if (empty($reshook)) { // Mass actions $objectclass = 'Commande'; $objectlabel = 'Orders'; - $permissiontoread = $user->rights->commande->lire; - $permissiontoadd = $user->rights->commande->creer; - $permissiontodelete = $user->rights->commande->supprimer; + $permissiontoread = $user->hasRight("commande", "lire"); + $permissiontoadd = $user->hasRight("commande", "creer"); + $permissiontodelete = $user->hasRight("commande", "supprimer"); if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { - $permissiontovalidate = $user->rights->commande->order_advance->validate; - $permissiontoclose = $user->rights->commande->order_advance->close; - $permissiontocancel = $user->rights->commande->order_advance->annuler; - $permissiontosendbymail = $user->rights->commande->order_advance->send; + $permissiontovalidate = $user->hasRight("commande", "order_advance", "validate"); + $permissiontoclose = $user->hasRight("commande", "order_advance", "close"); + $permissiontocancel = $user->hasRight("commande", "order_advance", "annuler"); + $permissiontosendbymail = $user->hasRight("commande", "order_advance", "send"); } else { - $permissiontovalidate = $user->rights->commande->creer; - $permissiontoclose = $user->rights->commande->creer; - $permissiontocancel = $user->rights->commande->creer; - $permissiontosendbymail = $user->rights->commande->creer; + $permissiontovalidate = $user->hasRight("commande", "creer"); + $permissiontoclose = $user->hasRight("commande", "creer"); + $permissiontocancel = $user->hasRight("commande", "creer"); + $permissiontosendbymail = $user->hasRight("commande", "creer"); } $uploaddir = $conf->commande->multidir_output[$conf->entity]; $triggersendname = 'ORDER_SENTBYMAIL'; @@ -578,6 +579,9 @@ if (empty($reshook)) { // Make a redirect to avoid to bill twice if we make a refresh or back $param = ''; + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -679,14 +683,14 @@ if ($action == 'validate' && $permissiontoadd) { $idwarehouse = 0; } if ($objecttmp->valid($user, $idwarehouse)) { - setEventMessage($langs->trans('hasBeenValidated', $objecttmp->ref), 'mesgs'); + setEventMessages($langs->trans('hasBeenValidated', $objecttmp->ref), null, 'mesgs'); } else { - setEventMessage($objecttmp->error, $objecttmp->errors, 'errors'); + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; } } else { $langs->load("errors"); - setEventMessage($langs->trans('ErrorIsNotADraft', $objecttmp->ref), 'errors'); + setEventMessages($langs->trans('ErrorIsNotADraft', $objecttmp->ref), null, 'errors'); $error++; } } else { @@ -710,14 +714,14 @@ if ($action == 'shipped' && $permissiontoadd) { if ($objecttmp->fetch($checked)) { if ($objecttmp->statut == 1 || $objecttmp->statut == 2) { if ($objecttmp->cloture($user)) { - setEventMessage($langs->trans('PassedInClosedStatus', $objecttmp->ref), 'mesgs'); + setEventMessages($langs->trans('PassedInClosedStatus', $objecttmp->ref), null, 'mesgs'); } else { - setEventMessage($langs->trans('CantBeClosed'), 'errors'); + setEventMessages($langs->trans('CantBeClosed'), null, 'errors'); $error++; } } else { $langs->load("errors"); - setEventMessage($langs->trans('ErrorIsNotADraft', $objecttmp->ref), 'errors'); + setEventMessages($langs->trans('ErrorIsNotADraft', $objecttmp->ref), null, 'errors'); $error++; } } else { @@ -1131,7 +1135,9 @@ if ($resql) { llxHeader('', $title, $help_url); $param = ''; - + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -1287,7 +1293,7 @@ if ($resql) { if ($permissiontocancel) { $arrayofmassactions['cancelorders'] = img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Cancel"); } - if (isModEnabled('facture') && $user->rights->facture->creer) { + if (isModEnabled('facture') && $user->hasRight("facture", "creer")) { $arrayofmassactions['createbills'] = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("CreateInvoiceForThisCustomer"); } if ($permissiontoclose) { @@ -1305,7 +1311,10 @@ if ($resql) { if (!empty($socid)) { $url .= '&socid='.$socid; } - $newcardbutton = dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', $url, '', $contextpage == 'orderlist' && $permissiontoadd); + $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 .= dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', $url, '', $contextpage == 'orderlist' && $permissiontoadd); // Lines of title fields print '
'; @@ -1320,6 +1329,8 @@ if ($resql) { print ''; print ''; print ''; + print ''; + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'order', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -1394,7 +1405,7 @@ if ($resql) { $moreforfilter = ''; // If the user can view prospects? sales other than his own - if ($user->rights->user->user->lire) { + if ($user->hasRight("user", "user", "lire")) { $langs->load("commercial"); $moreforfilter .= '
'; $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); @@ -1402,7 +1413,7 @@ if ($resql) { $moreforfilter .= '
'; } // If the user can view other users - if ($user->rights->user->user->lire) { + if ($user->hasRight("user", "user", "lire")) { $moreforfilter .= '
'; $tmptitle = $langs->trans('LinkedToSpecificUsers'); $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx'); @@ -1410,7 +1421,7 @@ if ($resql) { } // If the user can view other products/services than his own - if (isModEnabled('categorie') && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { + if (isModEnabled('categorie') && $user->hasRight("categorie", "lire") && ($user->hasRight("produit", "lire") || $user->hasRight("service", "lire"))) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; $tmptitle = $langs->trans('IncludingProductWithTag'); @@ -1419,7 +1430,7 @@ if ($resql) { $moreforfilter .= '
'; } // If Categories are enabled & user has rights to see - if (isModEnabled('categorie') && $user->rights->categorie->lire) { + if (isModEnabled('categorie') && $user->hasRight("categorie", "lire")) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; $tmptitle = $langs->trans('CustomersProspectsCategoriesShort'); @@ -1723,7 +1734,7 @@ if ($resql) { } // Status if (!empty($arrayfields['c.fk_statut']['checked'])) { - print '
'; + print ''; $liststatus = array( Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraftShort"), Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), @@ -1733,7 +1744,7 @@ if ($resql) { -2=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort"), Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceledShort") ); - print $form->selectarray('search_status', $liststatus, $search_status, -5, 0, 0, '', 0, 0, 0, '', 'maxwidth125 onrightofpage', 1); + print $form->selectarray('search_status', $liststatus, $search_status, -5, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1); 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($obj->rowid, $arrayofselected)) { - $selected = 1; - } - print ''; + if ($mode == 'kanban') { + if ($i == 0) { + print '
'; + print '
'; } - if (!$i) { - $totalarray['nbfield']++; + + print $generic_commande->getKanbanView(''); + + if ($i == ($imaxinloop - 1)) { + print '
'; + print '
'; - print $generic_commande->getNomUrl(1, ($search_status != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1, 1); - - $filename = dol_sanitizeFileName($obj->ref); - $filedir = $conf->commande->multidir_output[$conf->entity].'/'.dol_sanitizeFileName($obj->ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; - print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); - - print ''.$obj->ref_client.''; - if ($obj->project_id > 0) { - print $projectstatic->getNomUrl(1); - } - print ''; - if ($obj->project_id > 0) { - print $projectstatic->title; - } - print ''; - print $getNomUrl_cache[$obj->socid]; - - // If module invoices enabled and user with invoice creation permissions - if (isModEnabled('facture') && !empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) { - if ($user->rights->facture->creer) { - if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) { - print ' '; - print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').''; + // 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($obj->rowid, $arrayofselected)) { + $selected = 1; } + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + print ''; + print $generic_commande->getNomUrl(1, ($search_status != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1, 1); + + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->commande->multidir_output[$conf->entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; + print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); + + print ''; - print $obj->alias; - print ''; - if ($obj->fk_parent > 0) { - if (!isset($company_url_list[$obj->fk_parent])) { - $companyparent = new Societe($db); - $res = $companyparent->fetch($obj->fk_parent); - if ($res > 0) { - $company_url_list[$obj->fk_parent] = $companyparent->getNomUrl(1); - } - } - if (isset($company_url_list[$obj->fk_parent])) { - print $company_url_list[$obj->fk_parent]; + // Ref customer + if (!empty($arrayfields['c.ref_client']['checked'])) { + print ''.$obj->ref_client.''; - print $obj->town; - print ''; - print $obj->zip; - print '".$obj->state_name."'; - $tmparray = getCountry($obj->fk_pays, 'all'); - print $tmparray['label']; - print ''; - if (empty($typenArray)) { - $typenArray = $formcompany->typent_array(1); - } - print $typenArray[$obj->typent_code]; - print ''; - print dol_print_date($db->jdate($obj->date_commande), 'day'); - // Warning late icon and note - if ($generic_commande->hasDelay()) { - print img_picto($langs->trans("Late").' : '.$generic_commande->showDelay(), "warning"); - } - print ''; - print dol_print_date($db->jdate($obj->date_delivery), 'dayhour'); - print ''; - $form->formSelectShippingMethod('', $obj->fk_shipping_method, 'none', 1); - print ''; - $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', 1, $obj->deposit_percent); - print ''; - $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1); - print ''; - $form->formInputReason($_SERVER['PHP_SELF'], $obj->fk_input_reason, 'none', ''); - print ''.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_ttc)."'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."'; - $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); - print "'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_vat)."'.price($obj->multicurrency_total_ttc)."'; - if ($userstatic->id) { - print $userstatic->getNomUrl(-1); - } else { - print ' '; - } - print "'; - if ($obj->socid > 0) { - $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user); - if ($listsalesrepresentatives < 0) { - dol_print_error($db); + // Project ref + if (!empty($arrayfields['p.ref']['checked'])) { + print ''; + if ($obj->project_id > 0) { + print $projectstatic->getNomUrl(1); } - $nbofsalesrepresentative = count($listsalesrepresentatives); - if ($nbofsalesrepresentative > 6) { - // We print only number - print $nbofsalesrepresentative; - } elseif ($nbofsalesrepresentative > 0) { - $j = 0; - foreach ($listsalesrepresentatives as $val) { - $userstatic->id = $val['id']; - $userstatic->lastname = $val['lastname']; - $userstatic->firstname = $val['firstname']; - $userstatic->email = $val['email']; - $userstatic->statut = $val['statut']; - $userstatic->entity = $val['entity']; - $userstatic->photo = $val['photo']; - $userstatic->login = $val['login']; - $userstatic->office_phone = $val['office_phone']; - $userstatic->office_fax = $val['office_fax']; - $userstatic->user_mobile = $val['user_mobile']; - $userstatic->job = $val['job']; - $userstatic->gender = $val['gender']; - //print '
': - print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); - $j++; - if ($j < $nbofsalesrepresentative) { - print ' '; + print '
'; + if ($obj->project_id > 0) { + print $projectstatic->title; + } + print ''; + print $getNomUrl_cache[$obj->socid]; + + // If module invoices enabled and user with invoice creation permissions + if (isModEnabled('facture') && !empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) { + if ($user->rights->facture->creer) { + if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) { + print ' '; + print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').''; } - //print ''; } } - //else print $langs->trans("NoSalesRepresentativeAffected"); - } else { - print ' '; + print ''.price($marginInfo['pa_total']).''; + print $obj->alias; + print ''.price($marginInfo['total_margin']).''; + if ($obj->fk_parent > 0) { + if (!isset($company_url_list[$obj->fk_parent])) { + $companyparent = new Societe($db); + $res = $companyparent->fetch($obj->fk_parent); + if ($res > 0) { + $company_url_list[$obj->fk_parent] = $companyparent->getNomUrl(1); + } + } + if (isset($company_url_list[$obj->fk_parent])) { + print $company_url_list[$obj->fk_parent]; + } + } + print "'.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').''; + print $obj->town; + print ''.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').''; + print $obj->zip; + print '".$obj->state_name."'; + $tmparray = getCountry($obj->fk_pays, 'all'); + print $tmparray['label']; + print ''; + if (empty($typenArray)) { + $typenArray = $formcompany->typent_array(1); + } + print $typenArray[$obj->typent_code]; + print ''; + print dol_print_date($db->jdate($obj->date_commande), 'day'); + // Warning late icon and note + if ($generic_commande->hasDelay()) { + print img_picto($langs->trans("Late").' : '.$generic_commande->showDelay(), "warning"); + } + print ''; + print dol_print_date($db->jdate($obj->date_delivery), 'dayhour'); + print ''; + $form->formSelectShippingMethod('', $obj->fk_shipping_method, 'none', 1); + print ''; + $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', 1, $obj->deposit_percent); + print ''; + $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1); + print ''; + $form->formInputReason($_SERVER['PHP_SELF'], $obj->fk_input_reason, 'none', ''); + print ''.price($obj->total_ht)."'; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''.price($obj->total_tva)."'; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''.price($obj->total_ttc)."'; - print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser'); - print ''.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."'; - print dol_string_nohtmltag($obj->note_public); - print ''; + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); + print "'; - print dol_string_nohtmltag($obj->note_private); - print ''.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_vat)."'.price($obj->multicurrency_total_ttc)."'; - if (!empty($show_shippable_command) && isModEnabled('stock')) { - if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) { - $generic_commande->getLinesArray(); // Load array ->lines - $generic_commande->loadExpeditions(); // Load array ->expeditions + $userstatic->id = $obj->fk_user_author; + $userstatic->login = $obj->login; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + $userstatic->email = $obj->user_email; + $userstatic->statut = $obj->user_statut; + $userstatic->entity = $obj->entity; + $userstatic->photo = $obj->photo; + $userstatic->office_phone = $obj->office_phone; + $userstatic->office_fax = $obj->office_fax; + $userstatic->user_mobile = $obj->user_mobile; + $userstatic->job = $obj->job; + $userstatic->gender = $obj->gender; - $numlines = count($generic_commande->lines); // Loop on each line of order - for ($lig = 0; $lig < $numlines; $lig++) { - if (isset($generic_commande->expeditions[$generic_commande->lines[$lig]->id])) { - $reliquat = $generic_commande->lines[$lig]->qty - $generic_commande->expeditions[$generic_commande->lines[$lig]->id]; - } else { - $reliquat = $generic_commande->lines[$lig]->qty; + // Author + if (!empty($arrayfields['u.login']['checked'])) { + print ''; + if ($userstatic->id) { + print $userstatic->getNomUrl(-1); + } else { + print ' '; + } + print "'; + if ($obj->socid > 0) { + $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user); + if ($listsalesrepresentatives < 0) { + dol_print_error($db); + } + $nbofsalesrepresentative = count($listsalesrepresentatives); + if ($nbofsalesrepresentative > 6) { + // We print only number + print $nbofsalesrepresentative; + } elseif ($nbofsalesrepresentative > 0) { + $j = 0; + foreach ($listsalesrepresentatives as $val) { + $userstatic->id = $val['id']; + $userstatic->lastname = $val['lastname']; + $userstatic->firstname = $val['firstname']; + $userstatic->email = $val['email']; + $userstatic->statut = $val['statut']; + $userstatic->entity = $val['entity']; + $userstatic->photo = $val['photo']; + $userstatic->login = $val['login']; + $userstatic->office_phone = $val['office_phone']; + $userstatic->office_fax = $val['office_fax']; + $userstatic->user_mobile = $val['user_mobile']; + $userstatic->job = $val['job']; + $userstatic->gender = $val['gender']; + //print '
': + print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); + $j++; + if ($j < $nbofsalesrepresentative) { + print ' '; + } + //print '
'; } - if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) { // If line is a product and not a service - $nbprod++; // order contains real products - $generic_product->id = $generic_commande->lines[$lig]->fk_product; + } + //else print $langs->trans("NoSalesRepresentativeAffected"); + } else { + print ' '; + } + print '
'.price($marginInfo['pa_total']).''.price($marginInfo['total_margin']).''.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').''.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser'); + print ''; + print dol_string_nohtmltag($obj->note_public); + print ''; + print dol_string_nohtmltag($obj->note_private); + print ''; + if (!empty($show_shippable_command) && isModEnabled('stock')) { + if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) { + $generic_commande->getLinesArray(); // Load array ->lines + $generic_commande->loadExpeditions(); // Load array ->expeditions + + $numlines = count($generic_commande->lines); // Loop on each line of order + for ($lig = 0; $lig < $numlines; $lig++) { + if (isset($generic_commande->expeditions[$generic_commande->lines[$lig]->id])) { + $reliquat = $generic_commande->lines[$lig]->qty - $generic_commande->expeditions[$generic_commande->lines[$lig]->id]; } else { - $generic_product->stock_reel = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel']; - $generic_product->stock_theorique = $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique; + $reliquat = $generic_commande->lines[$lig]->qty; } + if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) { // If line is a product and not a service + $nbprod++; // order contains real products + $generic_product->id = $generic_commande->lines[$lig]->fk_product; - if ($reliquat > $generic_product->stock_reel) { - $notshippable++; - } - if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) { // Default code. Default should be this case. - $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->product_ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 20); - $text_info .= ' - '.$langs->trans("Stock").': '.$generic_product->stock_reel.''; - $text_info .= ' - '.$langs->trans("VirtualStock").': '.$generic_product->stock_theorique.''; - $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')' : ''); - $text_info .= '
'; - } else { // BUGGED CODE. - // DOES NOT TAKE INTO ACCOUNT MANUFACTURING. THIS CODE SHOULD BE USELESS. PREVIOUS CODE SEEMS COMPLETE. - // COUNT STOCK WHEN WE SHOULD ALREADY HAVE VALUE - // Detailed virtual stock, looks bugged, uncomplete and need heavy load. - // stock order and stock order_supplier - $stock_order = 0; - $stock_order_supplier = 0; - if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { // What about other options ? - if (isModEnabled('commande')) { - if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'])) { - $generic_product->load_stats_commande(0, '1,2'); - $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'] = $generic_product->stats_commande['qty']; - } else { - $generic_product->stats_commande['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer']; + // Get local and virtual stock and store it into cache + if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product])) { + $generic_product->load_stock('nobatch,warehouseopen'); // ->load_virtual_stock() is already included into load_stock() + $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_reel; + $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique; + } else { + $generic_product->stock_reel = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel']; + $generic_product->stock_theorique = $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique; + } + + if ($reliquat > $generic_product->stock_reel) { + $notshippable++; + } + if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) { // Default code. Default should be this case. + $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->product_ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 20); + $text_info .= ' - '.$langs->trans("Stock").': '.$generic_product->stock_reel.''; + $text_info .= ' - '.$langs->trans("VirtualStock").': '.$generic_product->stock_theorique.''; + $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')' : ''); + $text_info .= '
'; + } else { // BUGGED CODE. + // DOES NOT TAKE INTO ACCOUNT MANUFACTURING. THIS CODE SHOULD BE USELESS. PREVIOUS CODE SEEMS COMPLETE. + // COUNT STOCK WHEN WE SHOULD ALREADY HAVE VALUE + // Detailed virtual stock, looks bugged, uncomplete and need heavy load. + // stock order and stock order_supplier + $stock_order = 0; + $stock_order_supplier = 0; + if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { // What about other options ? + if (isModEnabled('commande')) { + if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'])) { + $generic_product->load_stats_commande(0, '1,2'); + $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'] = $generic_product->stats_commande['qty']; + } else { + $generic_product->stats_commande['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer']; + } + $stock_order = $generic_product->stats_commande['qty']; } - $stock_order = $generic_product->stats_commande['qty']; + if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { + if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'])) { + $generic_product->load_stats_commande_fournisseur(0, '3'); + $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty']; + } else { + $generic_product->stats_commande_fournisseur['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier']; + } + $stock_order_supplier = $generic_product->stats_commande_fournisseur['qty']; + } + } + $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 20); + $text_stock_reel = $generic_product->stock_reel.'/'.$stock_order; + if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $generic_commande->lines[$lig]->qty)) { + $warning++; + $text_warning .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; + } + if ($reliquat > $generic_product->stock_reel) { + $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; + } else { + $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; } if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { - if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'])) { - $generic_product->load_stats_commande_fournisseur(0, '3'); - $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty']; - } else { - $generic_product->stats_commande_fournisseur['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier']; - } - $stock_order_supplier = $generic_product->stats_commande_fournisseur['qty']; + $text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier; } + $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')' : ''); + $text_info .= '
'; } - $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 20); - $text_stock_reel = $generic_product->stock_reel.'/'.$stock_order; - if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $generic_commande->lines[$lig]->qty)) { - $warning++; - $text_warning .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; - } - if ($reliquat > $generic_product->stock_reel) { - $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; - } else { - $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; - } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { - $text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier; - } - $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')' : ''); - $text_info .= '
'; } } + if ($notshippable == 0) { + $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'green paddingleft'); + $text_info = $text_icon.' '.$langs->trans('Shippable').'
'.$text_info; + } else { + $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'error paddingleft'); + $text_info = $text_icon.' '.$langs->trans('NonShippable').'
'.$text_info; + } } - if ($notshippable == 0) { - $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'green paddingleft'); - $text_info = $text_icon.' '.$langs->trans('Shippable').'
'.$text_info; - } else { - $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'error paddingleft'); - $text_info = $text_icon.' '.$langs->trans('NonShippable').'
'.$text_info; + + if ($nbprod) { + print $form->textwithtooltip('', $text_info, 2, 1, $text_icon, '', 2); + } + if ($warning) { // Always false in default mode + print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders').'
'.$text_warning, 2, 1, img_picto('', 'error'), '', 2); } } - - if ($nbprod) { - print $form->textwithtooltip('', $text_info, 2, 1, $text_icon, '', 2); - } - if ($warning) { // Always false in default mode - print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders').'
'.$text_warning, 2, 1, img_picto('', 'error'), '', 2); + print '
'.yn($obj->billed).''.$obj->import_key.''.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).''; - 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($obj->rowid, $arrayofselected)) { - $selected = 1; + // Billed + if (!empty($arrayfields['c.facture']['checked'])) { + print ''.yn($obj->billed).''.$obj->import_key.''.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).''; + 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($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print '
'."\n"; + + print ''; + + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } + + // Détail commande + if (!empty($arrayfields['pr.ref']['checked'])) { + print ''; + } + // Product Description + if (!empty($arrayfields['pr.desc']['checked'])) { + print ''; + } + // Product QtyOrdered + if (!empty($arrayfields['cdet.qty']['checked'])) { + print ''; + } + + // Ref + if (!empty($arrayfields['c.ref']['checked'])) { + print ''; + } + // Ref customer + if (!empty($arrayfields['c.ref_client']['checked'])) { + print ''; + } + // Project ref + if (!empty($arrayfields['p.ref']['checked'])) { + print ''; + } + // Project title + if (!empty($arrayfields['p.title']['checked'])) { + print ''; + } + // Thirpdarty + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + } + // Alias + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + } + // Town + if (!empty($arrayfields['s.town']['checked'])) { + print ''; + } + // Zip + if (!empty($arrayfields['s.zip']['checked'])) { + print ''; + } + // State + if (!empty($arrayfields['state.nom']['checked'])) { + print ''; + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; + } + // Company type + if (!empty($arrayfields['typent.code']['checked'])) { + print ''; + } + // Date order + if (!empty($arrayfields['c.date_commande']['checked'])) { + print ''; + } + if (!empty($arrayfields['c.date_delivery']['checked'])) { + print ''; + } + // Shipping Method + if (!empty($arrayfields['c.fk_shipping_method']['checked'])) { + print ''; + } + // Payment term + if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) { + print ''; + } + // Payment mode + if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) { + print ''; + } + // Channel + if (!empty($arrayfields['c.fk_input_reason']['checked'])) { + print ''; + } + if (!empty($arrayfields['cdet.total_ht']['checked'])) { + // Amount + print ''; + } + if (!empty($arrayfields['c.total_vat']['checked'])) { + // Amount + print ''; + } + if (!empty($arrayfields['cdet.total_ttc']['checked'])) { + // Amount + print ''; + } + if (!empty($arrayfields['c.fk_warehouse']['checked'])) { + // Warehouse + print ''; + } + if (!empty($arrayfields['c.multicurrency_code']['checked'])) { + // Currency + print ''; + } + if (!empty($arrayfields['c.multicurrency_tx']['checked'])) { + // Currency rate + print ''; + } + if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) { + // Amount + print ''; + } + if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) { + // Amount VAT + print ''; + } + if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) { + // Amount + print ''; + } + if (!empty($arrayfields['u.login']['checked'])) { + // Author + print ''; + } + if (!empty($arrayfields['sale_representative']['checked'])) { + print ''; + } + if (!empty($arrayfields['total_pa']['checked'])) { + print ''; + } + if (!empty($arrayfields['total_margin']['checked'])) { + print ''; + } + if (!empty($arrayfields['total_margin_rate']['checked'])) { + print ''; + } + if (!empty($arrayfields['total_mark_rate']['checked'])) { + 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); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['c.datec']['checked'])) { + print ''; + } + // Date modification + if (!empty($arrayfields['c.tms']['checked'])) { + print ''; + } + // Date cloture + if (!empty($arrayfields['c.date_cloture']['checked'])) { + print ''; + } + // Note public + if (!empty($arrayfields['c.note_public']['checked'])) { + print ''; + } + // Note private + if (!empty($arrayfields['c.note_private']['checked'])) { + print ''; + } + // Shippable + if (!empty($arrayfields['shippable']['checked'])) { + print ''; + } + // Status billed + if (!empty($arrayfields['c.facture']['checked'])) { + print ''; + } + // Import key + if (!empty($arrayfields['c.import_key']['checked'])) { + print ''; + } + // Status + if (!empty($arrayfields['c.fk_statut']['checked'])) { + print ''; + } + // Action column + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } + print "\n"; + + // Fields title + print ''; + + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center '); + } + + // Détail commande + if (!empty($arrayfields['pr.ref']['checked'])) { + print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], 'pr.ref', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['pr.desc']['checked'])) { + print_liste_field_titre($arrayfields['pr.desc']['label'], $_SERVER["PHP_SELF"], 'pr.desc', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['cdet.qty']['checked'])) { + print_liste_field_titre($arrayfields['cdet.qty']['label'], $_SERVER["PHP_SELF"], 'cdet.qty', '', $param, '', $sortfield, $sortorder); + } + + if (!empty($arrayfields['c.ref']['checked'])) { + print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], 'c.ref', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['c.ref_client']['checked'])) { + print_liste_field_titre($arrayfields['c.ref_client']['label'], $_SERVER["PHP_SELF"], 'c.ref_client', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['p.ref']['checked'])) { + print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['p.title']['checked'])) { + print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['s.nom']['checked'])) { + print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['s.name_alias']['checked'])) { + print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], 's.name_alias', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['s.town']['checked'])) { + print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['s.zip']['checked'])) { + print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['state.nom']['checked'])) { + print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['country.code_iso']['checked'])) { + print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['typent.code']['checked'])) { + print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['c.date_commande']['checked'])) { + print_liste_field_titre($arrayfields['c.date_commande']['label'], $_SERVER["PHP_SELF"], 'c.date_commande', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['c.date_delivery']['checked'])) { + print_liste_field_titre($arrayfields['c.date_delivery']['label'], $_SERVER["PHP_SELF"], 'c.date_livraison', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['c.fk_shipping_method']['checked'])) { + print_liste_field_titre($arrayfields['c.fk_shipping_method']['label'], $_SERVER["PHP_SELF"], "c.fk_shipping_method", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) { + print_liste_field_titre($arrayfields['c.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "c.fk_cond_reglement", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) { + print_liste_field_titre($arrayfields['c.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "c.fk_mode_reglement", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['c.fk_input_reason']['checked'])) { + print_liste_field_titre($arrayfields['c.fk_input_reason']['label'], $_SERVER["PHP_SELF"], "c.fk_input_reason", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['cdet.total_ht']['checked'])) { + print_liste_field_titre($arrayfields['cdet.total_ht']['label'], $_SERVER["PHP_SELF"], 'cdet.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['c.total_vat']['checked'])) { + print_liste_field_titre($arrayfields['c.total_vat']['label'], $_SERVER["PHP_SELF"], 'cdet.total_tva', '', $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['cdet.total_ttc']['checked'])) { + print_liste_field_titre($arrayfields['cdet.total_ttc']['label'], $_SERVER["PHP_SELF"], 'cdet.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['c.fk_warehouse']['checked'])) { + print_liste_field_titre($arrayfields['c.fk_warehouse']['label'], "", '', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['c.multicurrency_code']['checked'])) { + print_liste_field_titre($arrayfields['c.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_code', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['c.multicurrency_tx']['checked'])) { + print_liste_field_titre($arrayfields['c.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_tx', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) { + print_liste_field_titre($arrayfields['c.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) { + print_liste_field_titre($arrayfields['c.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) { + print_liste_field_titre($arrayfields['c.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['u.login']['checked'])) { + print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder); + } + if (!empty($arrayfields['sale_representative']['checked'])) { + print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder); + } + if (!empty($arrayfields['total_pa']['checked'])) { + print_liste_field_titre($arrayfields['total_pa']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['total_margin']['checked'])) { + print_liste_field_titre($arrayfields['total_margin']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['total_margin_rate']['checked'])) { + print_liste_field_titre($arrayfields['total_margin_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['total_mark_rate']['checked'])) { + print_liste_field_titre($arrayfields['total_mark_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + } + + $totalarray = array( + 'nbfield' => 0, + 'val' => array( + 'cdet.total_ht' => 0, + 'cdet.total_tva' => 0, + 'cdet.total_ttc' => 0, + ), + 'pos' => array(), + ); + // 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); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (!empty($arrayfields['c.datec']['checked'])) { + print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } + if (!empty($arrayfields['c.tms']['checked'])) { + print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } + if (!empty($arrayfields['c.date_cloture']['checked'])) { + print_liste_field_titre($arrayfields['c.date_cloture']['label'], $_SERVER["PHP_SELF"], "c.date_cloture", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } + if (!empty($arrayfields['c.note_public']['checked'])) { + print_liste_field_titre($arrayfields['c.note_public']['label'], $_SERVER["PHP_SELF"], "c.note_public", "", $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['c.note_private']['checked'])) { + print_liste_field_titre($arrayfields['c.note_private']['label'], $_SERVER["PHP_SELF"], "c.note_private", "", $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['shippable']['checked'])) { + print_liste_field_titre($arrayfields['shippable']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['c.facture']['checked'])) { + print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['c.import_key']['checked'])) { + print_liste_field_titre($arrayfields['c.import_key']['label'], $_SERVER["PHP_SELF"], "c.import_key", "", $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['c.fk_statut']['checked'])) { + print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'center '); + } + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center '); + } + print ''."\n"; + + $total = 0; + $subtotal = 0; + $productstat_cache = array(); + $productstat_cachevirtual = array(); + $getNomUrl_cache = array(); + + $generic_commande = new Commande($db); + $generic_product = new Product($db); + $userstatic = new User($db); + $i = 0; + + $with_margin_info = false; + if (!empty($conf->margin->enabled) && ( + !empty($arrayfields['total_pa']['checked']) + || !empty($arrayfields['total_margin']['checked']) + || !empty($arrayfields['total_margin_rate']['checked']) + || !empty($arrayfields['total_mark_rate']['checked']) + ) + ) { + $with_margin_info = true; + } + $total_ht = 0; + $total_margin = 0; + + // Détail commande + $totalqty = 0; + + $totalarray = array(); + $totalarray['nbfield'] = 0; + $totalarray['val']['cdet.total_tva'] = 0; + $totalarray['val']['cdet.total_ttc'] = 0; + $imaxinloop = ($limit ? min($num, $limit) : $num); + while ($i < $imaxinloop) { + $obj = $db->fetch_object($resql); + + $notshippable = 0; + $warning = 0; + $text_info = ''; + $text_warning = ''; + $nbprod = 0; + + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->name_alias = $obj->alias; + $companystatic->client = $obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->email = $obj->email; + $companystatic->phone = $obj->phone; + $companystatic->address = $obj->address; + $companystatic->zip = $obj->zip; + $companystatic->town = $obj->town; + $companystatic->country_code = $obj->country_code; + if (!isset($getNomUrl_cache[$obj->socid])) { + $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer'); + } + + $generic_commande->id = $obj->c_rowid; + $generic_commande->ref = $obj->ref; + $generic_commande->statut = $obj->fk_statut; + $generic_commande->billed = $obj->billed; + $generic_commande->date = $db->jdate($obj->date_commande); + $generic_commande->date_livraison = $db->jdate($obj->date_delivery); // deprecated + $generic_commande->delivery_date = $db->jdate($obj->date_delivery); + $generic_commande->ref_client = $obj->ref_client; + $generic_commande->total_ht = $obj->c_total_ht; + $generic_commande->total_tva = $obj->c_total_tva; + $generic_commande->total_ttc = $obj->c_total_ttc; + $generic_commande->note_public = $obj->note_public; + $generic_commande->note_private = $obj->note_private; + + $projectstatic->id = $obj->project_id; + $projectstatic->ref = $obj->project_ref; + $projectstatic->title = $obj->project_label; + + $marginInfo = array(); + if ($with_margin_info === true) { + $generic_commande->fetch_lines(); + $marginInfo = $formmargin->getMarginInfosArray($generic_commande); + $total_ht += $obj->total_ht; + $total_margin += $marginInfo['total_margin']; + } + + print ''; + + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Détail commande + // Product Ref + if (!empty($arrayfields['pr.ref']['checked'])) { + if (!empty($obj->product_rowid)) { + $generic_product->id = $obj->product_rowid; + $generic_product->ref = $obj->product_ref; + $generic_product->label = $obj->product_label; + $generic_product->status = $obj->product_status; + $generic_product->status_buy = $obj->product_status_buy; + $generic_product->status_batch = $obj->product_batch; + $generic_product->barcode = $obj->product_barcode; + print ''; + } else { + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + } + // Product Description + if (!empty($arrayfields['pr.desc']['checked'])) { + // print ''; + !empty($obj->product_label) ? $labelproduct = $obj->product_label : $labelproduct = $obj->description; + print ''; + + if (!$i) { + $totalarray['nbfield']++; + } + } + // Product QtyOrdered + if (!empty($arrayfields['cdet.qty']['checked'])) { + print ''; + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'cdet.qty'; + } + if (isset($totalarray['val']['cdet.qty'])) { + $totalarray['val']['cdet.qty'] += $obj->qty; + } else { + $totalarray['val']['cdet.qty'] = $obj->qty; + } + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Ref + if (!empty($arrayfields['c.ref']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Ref customer + if (!empty($arrayfields['c.ref_client']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Project ref + if (!empty($arrayfields['p.ref']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Project label + if (!empty($arrayfields['p.title']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Third party + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Alias name + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Town + if (!empty($arrayfields['s.town']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Zip + if (!empty($arrayfields['s.zip']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // State + if (!empty($arrayfields['state.nom']['checked'])) { + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Type ent + if (!empty($arrayfields['typent.code']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Order date + if (!empty($arrayfields['c.date_commande']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Plannned date of delivery + if (!empty($arrayfields['c.date_delivery']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Shipping Method + if (!empty($arrayfields['c.fk_shipping_method']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Payment terms + if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Payment mode + if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Channel + if (!empty($arrayfields['c.fk_input_reason']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount HT + if (!empty($arrayfields['cdet.total_ht']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'cdet.total_ht'; + } + if (isset($totalarray['val']['cdet.total_ht'])) { + $totalarray['val']['cdet.total_ht'] += $obj->total_ht; + } else { + $totalarray['val']['cdet.total_ht'] = $obj->total_ht; + } + } + // Amount VAT + if (!empty($arrayfields['c.total_vat']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'cdet.total_tva'; + } + $totalarray['val']['cdet.total_tva'] += $obj->total_tva; + } + // Amount TTC + if (!empty($arrayfields['cdet.total_ttc']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'cdet.total_ttc'; + } + $totalarray['val']['cdet.total_ttc'] += $obj->total_ttc; + } + // Warehouse + if (!empty($arrayfields['c.fk_warehouse']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Currency + if (!empty($arrayfields['c.multicurrency_code']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Currency rate + if (!empty($arrayfields['c.multicurrency_tx']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount HT + if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount VAT + if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount TTC + if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + $userstatic->id = $obj->fk_user_author; + $userstatic->login = $obj->login; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + $userstatic->email = $obj->user_email; + $userstatic->statut = $obj->user_statut; + $userstatic->entity = $obj->entity; + $userstatic->photo = $obj->photo; + $userstatic->office_phone = $obj->office_phone; + $userstatic->office_fax = $obj->office_fax; + $userstatic->user_mobile = $obj->user_mobile; + $userstatic->job = $obj->job; + $userstatic->gender = $obj->gender; + + // Author + if (!empty($arrayfields['u.login']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + if (!empty($arrayfields['sale_representative']['checked'])) { + // Sales representatives + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Total buying or cost price + if (!empty($arrayfields['total_pa']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Total margin + if (!empty($arrayfields['total_margin']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'total_margin'; + } + $totalarray['val']['total_margin'] += $marginInfo['total_margin']; + } + // Total margin rate + if (!empty($arrayfields['total_margin_rate']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Total mark rate + if (!empty($arrayfields['total_mark_rate']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate'; + } + if ($i >= $imaxinloop - 1) { + if (!empty($total_ht)) { + $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT'); + } else { + $totalarray['val']['total_mark_rate'] = ''; + } + } + } + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Date creation + if (!empty($arrayfields['c.datec']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date modification + if (!empty($arrayfields['c.tms']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date cloture + if (!empty($arrayfields['c.date_cloture']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Note public + if (!empty($arrayfields['c.note_public']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Note private + if (!empty($arrayfields['c.note_private']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Show shippable Icon (this creates subloops, so may be slow) + if (!empty($arrayfields['shippable']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Billed + if (!empty($arrayfields['c.facture']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Import key + if (!empty($arrayfields['c.import_key']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['c.fk_statut']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Action column + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // $totalarray['nbfield']--; + // $totalarray['nbfield']--; + print "\n"; + + $total += $obj->total_ht; + $subtotal += $obj->total_ht; + $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 ''; + } + + $db->free($resql); + + $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; + + print '
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); + print ''; + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1); + print ''; + print '
'; + print $form->selectDate($search_dateorder_start ? $search_dateorder_start : -1, 'search_dateorder_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_dateorder_end ? $search_dateorder_end : -1, 'search_dateorder_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + print '
'; + print '
'; + print $form->selectDate($search_datedelivery_start ? $search_datedelivery_start : -1, 'search_datedelivery_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_datedelivery_end ? $search_datedelivery_end : -1, 'search_datedelivery_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + print '
'; + $form->selectShippingMethod($search_fk_shipping_method, 'search_fk_shipping_method', '', 1, '', 1); + print ''; + $form->select_conditions_paiements($search_fk_cond_reglement, 'search_fk_cond_reglement', 1, 1, 1); + print ''; + $form->select_types_paiements($search_fk_mode_reglement, 'search_fk_mode_reglement', '', 0, 1, 1, 0, -1); + print ''; + $form->selectInputReason($search_fk_input_reason, 'search_fk_input_reason', '', 1, '', 1); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $form->selectDate($search_datecloture_start ? $search_datecloture_start : -1, 'search_datecloture_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_datecloture_end ? $search_datecloture_end : -1, 'search_datecloture_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + print '
'; + print ''; + print ''; + //print $form->selectyesno('search_shippable', $search_shippable, 1, 0, 1, 1); + if (!empty($conf->global->ORDER_SHIPABLE_STATUS_DISABLED_BY_DEFAULT)) { + print ''; + print $langs->trans('ShowShippableStatus'); + } else { + $show_shippable_command = 1; + } + print ''; + print $form->selectyesno('search_billed', $search_billed, 1, 0, 1, 1); + print ''; + print ''; + $liststatus = array( + Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraftShort"), + Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), + Commande::STATUS_SHIPMENTONPROCESS=>$langs->trans("StatusOrderSentShort"), + Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), + -3=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort").'+'.$langs->trans("StatusOrderDelivered"), + -2=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort"), + Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceledShort") + ); + print $form->selectarray('search_status', $liststatus, $search_status, -5, 0, 0, '', 0, 0, 0, '', 'maxwidth125', 1); + print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + 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($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''.$generic_product->getNomUrl(1).'Ligne libre'.$obj->description.''.dol_escape_htmltag($labelproduct).''.$obj->qty.''; + print $generic_commande->getNomUrl(1, ($search_status != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1, 1); + + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->commande->multidir_output[$conf->entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; + print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); + + print ''.$obj->ref_client.''; + if ($obj->project_id > 0) { + print $projectstatic->getNomUrl(1); + } + print ''; + if ($obj->project_id > 0) { + print $projectstatic->title; + } + print ''; + print $getNomUrl_cache[$obj->socid]; + + // If module invoices enabled and user with invoice creation permissions + if (isModEnabled('facture') && !empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) { + if ($user->rights->facture->creer) { + if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) { + print ' '; + print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').''; + } + } + } + print ''; + print $obj->alias; + print ''; + print $obj->town; + print ''; + print $obj->zip; + print '".$obj->state_name."'; + $tmparray = getCountry($obj->fk_pays, 'all'); + print $tmparray['label']; + print ''; + if (empty($typenArray)) { + $typenArray = $formcompany->typent_array(1); + } + print $typenArray[$obj->typent_code]; + print ''; + print dol_print_date($db->jdate($obj->date_commande), 'day'); + // Warning late icon and note + if ($generic_commande->hasDelay()) { + print img_picto($langs->trans("Late").' : '.$generic_commande->showDelay(), "warning"); + } + print ''; + print dol_print_date($db->jdate($obj->date_delivery), 'dayhour'); + print ''; + $form->formSelectShippingMethod('', $obj->fk_shipping_method, 'none', 1); + print ''; + $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', 1, $obj->deposit_percent); + print ''; + $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1); + print ''; + $form->formInputReason($_SERVER['PHP_SELF'], $obj->fk_input_reason, 'none', ''); + print ''.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_ttc)."'; + if ($obj->warehouse > 0) { + print img_picto('', 'stock', 'class="paddingrightonly"'); + } + $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'], $obj->warehouse, 'none'); + print "'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."'; + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); + print "'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_vat)."'.price($obj->multicurrency_total_ttc)."'; + if ($userstatic->id) { + print $userstatic->getNomUrl(-1); + } else { + print ' '; + } + print "'; + if ($obj->socid > 0) { + $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user); + if ($listsalesrepresentatives < 0) { + dol_print_error($db); + } + $nbofsalesrepresentative = count($listsalesrepresentatives); + if ($nbofsalesrepresentative > 6) { + // We print only number + print $nbofsalesrepresentative; + } elseif ($nbofsalesrepresentative > 0) { + $j = 0; + foreach ($listsalesrepresentatives as $val) { + $userstatic->id = $val['id']; + $userstatic->lastname = $val['lastname']; + $userstatic->firstname = $val['firstname']; + $userstatic->email = $val['email']; + $userstatic->statut = $val['statut']; + $userstatic->entity = $val['entity']; + $userstatic->photo = $val['photo']; + $userstatic->login = $val['login']; + $userstatic->office_phone = $val['office_phone']; + $userstatic->office_fax = $val['office_fax']; + $userstatic->user_mobile = $val['user_mobile']; + $userstatic->job = $val['job']; + $userstatic->gender = $val['gender']; + //print '
': + print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); + $j++; + if ($j < $nbofsalesrepresentative) { + print ' '; + } + //print '
'; + } + } + //else print $langs->trans("NoSalesRepresentativeAffected"); + } else { + print ' '; + } + print '
'.price($marginInfo['pa_total']).''.price($marginInfo['total_margin']).''.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').''.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser'); + print ''; + print dol_string_nohtmltag($obj->note_public); + print ''; + print dol_string_nohtmltag($obj->note_private); + print ''; + if (!empty($show_shippable_command) && !empty($conf->stock->enabled)) { + if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) { + $generic_commande->getLinesArray(); // Load array ->lines + $generic_commande->loadExpeditions(); // Load array ->expeditions + + $numlines = count($generic_commande->lines); // Loop on each line of order + for ($lig = 0; $lig < $numlines; $lig++) { + if (isset($generic_commande->expeditions[$generic_commande->lines[$lig]->id])) { + $reliquat = $generic_commande->lines[$lig]->qty - $generic_commande->expeditions[$generic_commande->lines[$lig]->id]; + } else { + $reliquat = $generic_commande->lines[$lig]->qty; + } + if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) { // If line is a product and not a service + $nbprod++; // order contains real products + $generic_product->id = $generic_commande->lines[$lig]->fk_product; + + // Get local and virtual stock and store it into cache + if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product])) { + $generic_product->load_stock('nobatch'); // ->load_virtual_stock() is already included into load_stock() + $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_reel; + $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique; + } else { + $generic_product->stock_reel = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel']; + $generic_product->stock_theorique = $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique; + } + + if ($reliquat > $generic_product->stock_reel) { + $notshippable++; + } + if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) { // Default code. Default should be this case. + $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->product_ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 20); + $text_info .= ' - '.$langs->trans("Stock").': '.$generic_product->stock_reel.''; + $text_info .= ' - '.$langs->trans("VirtualStock").': '.$generic_product->stock_theorique.''; + $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')' : ''); + $text_info .= '
'; + } else { // BUGGED CODE. + // DOES NOT TAKE INTO ACCOUNT MANUFACTURING. THIS CODE SHOULD BE USELESS. PREVIOUS CODE SEEMS COMPLETE. + // COUNT STOCK WHEN WE SHOULD ALREADY HAVE VALUE + // Detailed virtual stock, looks bugged, uncomplete and need heavy load. + // stock order and stock order_supplier + $stock_order = 0; + $stock_order_supplier = 0; + if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { // What about other options ? + if (!empty($conf->commande->enabled)) { + if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'])) { + $generic_product->load_stats_commande(0, '1,2'); + $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'] = $generic_product->stats_commande['qty']; + } else { + $generic_product->stats_commande['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer']; + } + $stock_order = $generic_product->stats_commande['qty']; + } + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) { + if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'])) { + $generic_product->load_stats_commande_fournisseur(0, '3'); + $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty']; + } else { + $generic_product->stats_commande_fournisseur['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier']; + } + $stock_order_supplier = $generic_product->stats_commande_fournisseur['qty']; + } + } + $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 20); + $text_stock_reel = $generic_product->stock_reel.'/'.$stock_order; + if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $generic_commande->lines[$lig]->qty)) { + $warning++; + $text_warning .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; + } + if ($reliquat > $generic_product->stock_reel) { + $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; + } else { + $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; + } + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) { + $text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier; + } + $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')' : ''); + $text_info .= '
'; + } + } + } + if ($notshippable == 0) { + $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'green paddingleft'); + $text_info = $text_icon.' '.$langs->trans('Shippable').'
'.$text_info; + } else { + $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'error paddingleft'); + $text_info = $text_icon.' '.$langs->trans('NonShippable').'
'.$text_info; + } + } + + if ($nbprod) { + print $form->textwithtooltip('', $text_info, 2, 1, $text_icon, '', 2); + } + if ($warning) { // Always false in default mode + print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders').'
'.$text_warning, 2, 1, img_picto('', 'error'), '', 2); + } + } + print '
'.yn($obj->billed).''.$obj->import_key.''.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).''; + 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($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print '
'.$langs->trans("NoRecordFound").'
'."\n"; + print '
'; + + print ''."\n"; + + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } + + // 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_orders', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); +} else { + dol_print_error($db); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php index 819a6ecb74f..a6a1fde3851 100644 --- a/htdocs/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php @@ -46,12 +46,12 @@ foreach ($linkedObjectBlock as $key => $objectlink) { $trclass .= ' liste_sub_total'; } echo '
'.$langs->trans("CustomerOrder"); + echo ''.$langs->trans("CustomerOrder"); if (!empty($showImportButton) && !empty($conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES)) { print ' '; - echo ''.$objectlink->getNomUrl(1).''.$objectlink->getNomUrl(1).''.$objectlink->ref_client.''.dol_print_date($objectlink->date, 'day').''; diff --git a/htdocs/compta/ajaxpayment.php b/htdocs/compta/ajaxpayment.php index aeb8d164928..b566f77bcde 100644 --- a/htdocs/compta/ajaxpayment.php +++ b/htdocs/compta/ajaxpayment.php @@ -109,7 +109,7 @@ if ($currentInvId) { // Here to breakdown $result -= $amountToBreakdown; // And canceled substraction has been replaced by breakdown } // else there's no need to calc anything, just reset the field (result is still < 0) } - $toJsonArray['amount_'.$currentInvId] = price2num($currentAmount).""; // Param will exist only if an img has been clicked + $toJsonArray['amount_'.$currentInvId] = price2num($currentAmount); // Param will exist only if an img has been clicked } $toJsonArray['makeRed'] = ($totalRemaining < price2num($result) || price2num($result) < 0) ? true : false; diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index b0514c71ee6..6c961e85af9 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -1134,8 +1134,8 @@ if ($resql) { } // Conciliated if (!empty($arrayfields['b.conciliated']['checked'])) { - print ''; - print $form->selectyesno('search_conciliated', $search_conciliated, 1, false, 1, 1); + print ''; + print $form->selectyesno('search_conciliated', $search_conciliated, 1, false, 1, 1, 'search_status onrightofpage maxwidth75'); print ''.$langs->trans($val).'
'.$langs->trans($ibankey).'
'.$langs->trans($bickey).'
'.$langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation").'
'.$langs->trans("BankAccountDomiciliation").''; print '
'.$langs->trans("BankAccountOwner").'
'.$langs->trans("BankName").'
'.$langs->trans($val).'
'; + print ''; $array = array( 'opened'=>$langs->trans("Opened"), 'closed'=>$langs->trans("Closed") ); - print $form->selectarray("search_status", $array, $search_status, 1, 0, 0, '', 0, 0, 0, '', '', 1); + print $form->selectarray("search_status", $array, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status maxwidth125 onrightofpage', 1); print '".$refcomp."'.price(abs($total_ttc))."  '.price($total_ttc)."'.price($solde).'
'; print '
'; print $formaccounting->select_account($search_accountancy_account, 'search_accountancy_account', 1, array(), 1, 1, 'maxwidth200'); @@ -475,7 +476,7 @@ if ($resql) { } // Subledger account - if ($arrayfields['subledger']['checked']) { + if (!empty($arrayfields['subledger']['checked'])) { print '
'; print '
'; print $formaccounting->select_auxaccount($search_accountancy_subledger, 'search_accountancy_subledger', 1, 'maxwidth200'); @@ -484,7 +485,7 @@ if ($resql) { } // Debit - if ($arrayfields['debit']['checked']) { + if (!empty($arrayfields['debit']['checked'])) { print '
'; print ''; print ''.$accountingaccount->getNomUrl(0, 1, 1, '', 1).''.length_accounta($obj->subledger_account).''; 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); + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status onrightofpage' : ''), 1); } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:')=== 0)) { print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1); } elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) { @@ -525,7 +553,8 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $object->setVarsFromFetchObj($obj); // Show here line of result - print '
'.$langs->trans("NoRecordFound").'
'.$langs->trans("NoRecordFound").'
'."\n"; diff --git a/htdocs/compta/clients.php b/htdocs/compta/clients.php index cd472c270e3..8db4516d3dd 100644 --- a/htdocs/compta/clients.php +++ b/htdocs/compta/clients.php @@ -133,7 +133,7 @@ if ($resql) { $langs->load('commercial'); - print_barre_liste($langs->trans("ListOfCustomers"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num); + print_barre_liste($langs->trans("Customers"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num); print '
'; diff --git a/htdocs/compta/deplacement/index.php b/htdocs/compta/deplacement/index.php index a4a782de603..6f4613097d9 100644 --- a/htdocs/compta/deplacement/index.php +++ b/htdocs/compta/deplacement/index.php @@ -68,7 +68,7 @@ $childids[] = $user->id; //$help_url='EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones'; $help_url = ''; -llxHeader('', $langs->trans("ListOfFees"), $help_url); +llxHeader('', $langs->trans("TripsAndExpenses"), $help_url); diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php index cae06774332..c1c5e5cb851 100644 --- a/htdocs/compta/deplacement/list.php +++ b/htdocs/compta/deplacement/list.php @@ -131,7 +131,7 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - print_barre_liste($langs->trans("ListOfFees"), $page, $_SERVER["PHP_SELF"], "&socid=$socid", $sortfield, $sortorder, '', $num); + print_barre_liste($langs->trans("TripsAndExpenses"), $page, $_SERVER["PHP_SELF"], "&socid=$socid", $sortfield, $sortorder, '', $num); $i = 0; print ''."\n"; diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 64a37dcbed4..7896b26e8b0 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -271,7 +271,7 @@ if (empty($reshook)) { } // Delete - if ($action == 'confirm_deleteinvoice' && $confirm == 'yes' && $user->rights->facture->supprimer) { + if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->supprimer) { $object->delete($user); header("Location: ".DOL_URL_ROOT.'/compta/facture/invoicetemplate_list.php'); @@ -1175,8 +1175,8 @@ if ($action == 'create') { } // Confirm delete of repeatable invoice - if ($action == 'ask_deleteinvoice') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteRepeatableInvoice'), $langs->trans('ConfirmDeleteRepeatableInvoice'), 'confirm_deleteinvoice', '', 'no', 1); + if ($action == 'delete') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteRepeatableInvoice'), $langs->trans('ConfirmDeleteRepeatableInvoice'), 'confirm_delete', '', 'no', 1); } // Call Hook formConfirm @@ -1635,7 +1635,7 @@ if ($action == 'create') { // Show object lines if (!empty($object->lines)) { $canchangeproduct = 1; - $ret = $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice + $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice } // Form to add new line diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 36c98a495ec..cc6b92f72cb 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2763,7 +2763,7 @@ if (empty($reshook)) { } if (!$errors) { - setEventMessages($langs->trans('Updated'), '', 'mesgs'); + setEventMessages($langs->trans('Updated'), null, 'mesgs'); header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); } else { setEventMessages($langs->trans('ErrorOutingSituationInvoiceCreditNote'), array(), 'errors'); @@ -3066,9 +3066,9 @@ if ($action == 'create') { $remise_percent = (!empty($expesrc->remise_percent) ? $expesrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0)); $remise_absolue = (!empty($expesrc->remise_absolue) ? $expesrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); - if (!empty($conf->multicurrency->enabled)) { - $currency_code = (!empty($expesrc->currency_code) ? $expesrc->currency_code : (!empty($soc->currency_code) ? $soc->currency_code : $objectsrc->multicurrency_code)); - $currency_tx = (!empty($expesrc->currency_tx) ? $expesrc->currency_tx : (!empty($soc->currency_tx) ? $soc->currency_tx : $objectsrc->currency_tx)); + if (isModEnabled('multicurrency')) { + $currency_code = (!empty($expesrc->multicurrency_code) ? $expesrc->multicurrency_code : (!empty($soc->multicurrency_code) ? $soc->multicurrency_code : $objectsrc->multicurrency_code)); + $currency_tx = (!empty($expesrc->multicurrency_tx) ? $expesrc->multicurrency_tx : (!empty($soc->multicurrency_tx) ? $soc->multicurrency_tx : $objectsrc->multicurrency_tx)); } //Replicate extrafields @@ -3357,7 +3357,7 @@ if ($action == 'create') { jQuery(".checkforselect").prop("disabled", false); jQuery(".checkforselect").prop("checked", true); } - }; + } }); '; @@ -3780,7 +3780,7 @@ if ($action == 'create') { if ($soc->fetch_optionals() > 0) { $object->array_options = array_merge($object->array_options, $soc->array_options); } - }; + } print $object->showOptionals($extrafields, 'create', $parameters); } @@ -4678,16 +4678,16 @@ if ($action == 'create') { if ($displayWarranty) { // Retained Warranty print '
'; - print ''; + print ''; $oldpcgtype = $objp->pcg_type; } } @@ -330,17 +330,17 @@ if ($modecompta == 'BOOKKEEPING') { print ''; print ''; print '\n"; - print '\n"; + print '\n"; print "\n"; } else { print ''; print '\n"; - print '\n"; + print '\n"; print "\n"; } @@ -367,7 +367,7 @@ if ($modecompta == 'BOOKKEEPING') { $cpts = $AccCat->getCptsCat(0, $tmppredefinedgroupwhere); foreach ($cpts as $j => $cpt) { - $return = $AccCat->getSumDebitCredit($cpt['account_number'], $date_start, $date_end, $cpt['dc']); + $return = $AccCat->getSumDebitCredit($cpt['account_number'], $date_start, $date_end, (empty($cpt['dc']) ? 0 : $cpt['dc'])); if ($return < 0) { setEventMessages(null, $AccCat->errors, 'errors'); $resultN = 0; @@ -380,7 +380,7 @@ if ($modecompta == 'BOOKKEEPING') { print ''; print ''; print ''; - print ''; + print ''; print "\n"; } } @@ -1539,27 +1539,27 @@ print ''; print ''; if ($modecompta == 'CREANCES-DETTES') { - print ''; + print ''; } elseif ($modecompta == 'RECETTES-DEPENSES') { print ''; } -print ''; +print ''; print ''; print ''; if ($modecompta == 'CREANCES-DETTES') { - print ''; + print ''; } elseif ($modecompta == 'RECETTES-DEPENSES') { print ''; } -print ''; +print ''; print ''; print ''; if ($modecompta == 'CREANCES-DETTES') { - print ''; + print ''; } elseif ($modecompta == 'RECETTES-DEPENSES') { print ''; } -print ''; +print ''; print ''; print "
'; + print ''; - if ($action != 'editretainedwarranty' && $user->rights->facture->creer) { + if ($action != 'editretainedwarranty' && $user->rights->facture->creer && $object->statut == Facture::STATUS_DRAFT) { print ''; } print '
'; print $langs->trans('RetainedWarranty'); print 'id.'">'.img_edit($langs->trans('setretainedwarranty'), 1).'
'; print '
'; - if ($action == 'editretainedwarranty') { + if ($action == 'editretainedwarranty' && $object->statut == Facture::STATUS_DRAFT) { print ''; print ''; print ''; @@ -4704,7 +4704,7 @@ if ($action == 'create') { print ''; - if ($action != 'editretainedwarrantypaymentterms' && $user->rights->facture->creer) { + if ($action != 'editretainedwarrantypaymentterms' && $user->rights->facture->creer && $object->statut == Facture::STATUS_DRAFT) { print ''; } @@ -4715,7 +4715,7 @@ if ($action == 'create') { $defaultDate = $object->date; } - if ($action == 'editretainedwarrantypaymentterms') { + if ($action == 'editretainedwarrantypaymentterms' && $object->statut == Facture::STATUS_DRAFT) { //date('Y-m-d',$object->date_lim_reglement) print ''; print ''; @@ -4739,7 +4739,7 @@ if ($action == 'create') { print '
'; print $langs->trans('PaymentConditionsShortRetainedWarranty'); print 'id.'">'.img_edit($langs->trans('setPaymentConditionsShortRetainedWarranty'), 1).'
'; - if ($action != 'editretainedwarrantydatelimit' && $user->rights->facture->creer) { + if ($action != 'editretainedwarrantydatelimit' && $user->rights->facture->creer && $object->statut == Facture::STATUS_DRAFT) { print ''; } @@ -4750,7 +4750,7 @@ if ($action == 'create') { $defaultDate = $object->date; } - if ($action == 'editretainedwarrantydatelimit') { + if ($action == 'editretainedwarrantydatelimit' && $object->statut == Facture::STATUS_DRAFT) { //date('Y-m-d',$object->date_lim_reglement) print ''; print ''; @@ -5423,7 +5423,7 @@ if ($action == 'create') { // Show object lines if (!empty($object->lines)) { - $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); + $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); } // Form to add new line diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 4c1392e28eb..bae53bce6a8 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -65,9 +65,9 @@ class Invoices extends DolibarrApi * * Return an array with invoice informations * - * @param int $id ID of invoice - * @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id, -1: Do not return contacts/adddesses - * @return array|mixed data without useless information + * @param int $id ID of invoice + * @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id, -1: Do not return contacts/adddesses + * @return Object Object with cleaned properties * * @throws RestException */ @@ -81,9 +81,9 @@ class Invoices extends DolibarrApi * * Return an array with invoice informations * - * @param string $ref Ref of object - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses - * @return array|mixed data without useless information + * @param string $ref Ref of object + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses + * @return Object Object with cleaned properties * * @url GET ref/{ref} * @@ -99,9 +99,9 @@ class Invoices extends DolibarrApi * * Return an array with invoice informations * - * @param string $ref_ext External reference of object - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses - * @return array|mixed data without useless information + * @param string $ref_ext External reference of object + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses + * @return Object Object with cleaned properties * * @url GET ref_ext/{ref_ext} * @@ -117,11 +117,11 @@ class Invoices extends DolibarrApi * * Return an array with invoice informations * - * @param int $id ID of order - * @param string $ref Ref of object - * @param string $ref_ext External reference of object - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses - * @return array|mixed data without useless information + * @param int $id ID of order + * @param string $ref Ref of object + * @param string $ref_ext External reference of object + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses + * @return Object Object with cleaned properties * * @throws RestException */ @@ -325,12 +325,11 @@ class Invoices extends DolibarrApi /** * Create an invoice using an existing order. * - * * @param int $orderid Id of the order + * @return Object Object with cleaned properties * * @url POST /createfromorder/{orderid} * - * @return int * @throws RestException 400 * @throws RestException 401 * @throws RestException 404 @@ -338,7 +337,6 @@ class Invoices extends DolibarrApi */ public function createInvoiceFromOrder($orderid) { - require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; if (!DolibarrApiAccess::$user->rights->commande->lire) { @@ -368,11 +366,10 @@ class Invoices extends DolibarrApi /** * Get lines of an invoice * - * @param int $id Id of invoice + * @param int $id Id of invoice + * @return array Array of lines * * @url GET {id}/lines - * - * @return int */ public function getLines($id) { @@ -399,14 +396,13 @@ class Invoices extends DolibarrApi /** * Update a line to a given invoice * - * @param int $id Id of invoice to update - * @param int $lineid Id of line to update - * @param array $request_data InvoiceLine data + * @param int $id Id of invoice to update + * @param int $lineid Id of line to update + * @param array $request_data InvoiceLine data + * @return Object Object with cleaned properties * * @url PUT {id}/lines/{lineid} * - * @return array - * * @throws RestException 304 * @throws RestException 401 * @throws RestException 404 Invoice not found @@ -472,14 +468,13 @@ class Invoices extends DolibarrApi /** * Add a contact type of given invoice * - * @param int $id Id of invoice to update - * @param int $contactid Id of contact to add - * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER) + * @param int $id Id of invoice to update + * @param int $contactid Id of contact to add + * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER) + * @return array * * @url POST {id}/contact/{contactid}/{type} * - * @return int - * * @throws RestException 401 * @throws RestException 404 */ @@ -509,20 +504,24 @@ class Invoices extends DolibarrApi throw new RestException(500, 'Error when added the contact'); } - return $this->_cleanObjectDatas($this->invoice); + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Contact linked to the invoice' + ) + ); } /** * Delete a contact type of given invoice * - * @param int $id Id of invoice to update - * @param int $contactid Row key of the contact in the array contact_ids. - * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER). + * @param int $id Id of invoice to update + * @param int $contactid Row key of the contact in the array contact_ids. + * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER). + * @return Object Object with cleaned properties * * @url DELETE {id}/contact/{contactid}/{type} * - * @return array - * * @throws RestException 401 * @throws RestException 404 * @throws RestException 500 System error @@ -561,13 +560,12 @@ class Invoices extends DolibarrApi /** * Deletes a line of a given invoice * - * @param int $id Id of invoice - * @param int $lineid Id of the line to delete + * @param int $id Id of invoice + * @param int $lineid Id of the line to delete + * @return Object Object with cleaned properties * * @url DELETE {id}/lines/{lineid} * - * @return array - * * @throws RestException 400 * @throws RestException 401 * @throws RestException 404 @@ -575,7 +573,6 @@ class Invoices extends DolibarrApi */ public function deleteLine($id, $lineid) { - if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } @@ -592,9 +589,7 @@ class Invoices extends DolibarrApi throw new RestException(404, 'Invoice not found'); } - // TODO Check the lineid $lineid is a line of ojbect - - $updateRes = $this->invoice->deleteline($lineid); + $updateRes = $this->invoice->deleteline($lineid, $id); if ($updateRes > 0) { return $this->get($id); } else { @@ -605,9 +600,9 @@ class Invoices extends DolibarrApi /** * Update invoice * - * @param int $id Id of invoice to update - * @param array $request_data Datas - * @return int + * @param int $id Id of invoice to update + * @param array $request_data Datas + * @return Object|false Object with cleaned properties */ public function put($id, $request_data = null) { @@ -648,8 +643,8 @@ class Invoices extends DolibarrApi /** * Delete invoice * - * @param int $id Invoice ID - * @return array + * @param int $id Invoice ID + * @return array */ public function delete($id) { @@ -829,11 +824,10 @@ class Invoices extends DolibarrApi * * @param int $id Order ID * @param int $idwarehouse Warehouse ID + * @return Object Object with cleaned properties * * @url POST {id}/settodraft * - * @return array - * * @throws RestException 304 * @throws RestException 401 * @throws RestException 404 @@ -887,10 +881,9 @@ class Invoices extends DolibarrApi * @param int $id Invoice ID * @param int $idwarehouse Warehouse ID * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return Object|false Object with cleaned properties * * @url POST {id}/validate - * - * @return array */ public function validate($id, $idwarehouse = 0, $notrigger = 0) { @@ -932,11 +925,10 @@ class Invoices extends DolibarrApi * @param int $id Order ID * @param string $close_code Code filled if we classify to 'Paid completely' when payment is not complete (for escompte for example) * @param string $close_note Comment defined if we classify to 'Paid' when payment is not complete (for escompte for example) + * @return Object Object with cleaned properties * * @url POST {id}/settopaid * - * @return array An invoice object - * * @throws RestException 304 * @throws RestException 401 * @throws RestException 404 @@ -981,12 +973,11 @@ class Invoices extends DolibarrApi /** * Sets an invoice as unpaid * - * @param int $id Order ID + * @param int $id Order ID + * @return Object Object with cleaned properties * * @url POST {id}/settounpaid * - * @return array An invoice object - * * @throws RestException 304 * @throws RestException 401 * @throws RestException 404 @@ -1031,10 +1022,9 @@ class Invoices extends DolibarrApi * Get discount from invoice * * @param int $id Id of invoice + * @return Object Object with cleaned properties * * @url GET {id}/discount - * - * @return mixed */ public function getDiscount($id) { @@ -1069,10 +1059,10 @@ class Invoices extends DolibarrApi /** * Create a discount (credit available) for a credit note or a deposit. * - * @param int $id Invoice ID - * @url POST {id}/markAsCreditAvailable + * @param int $id Invoice ID + * @return Object Object with cleaned properties * - * @return array An invoice object + * @url POST {id}/markAsCreditAvailable * * @throws RestException 304 * @throws RestException 401 @@ -1241,11 +1231,10 @@ class Invoices extends DolibarrApi * * @param int $id Id of invoice * @param int $discountid Id of discount + * @return int * * @url POST {id}/usediscount/{discountid} * - * @return int - * * @throws RestException 400 * @throws RestException 401 * @throws RestException 404 @@ -1253,7 +1242,6 @@ class Invoices extends DolibarrApi */ public function useDiscount($id, $discountid) { - if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } @@ -1288,11 +1276,10 @@ class Invoices extends DolibarrApi * * @param int $id Id of invoice * @param int $discountid Id of a discount coming from a credit note + * @return int * * @url POST {id}/usecreditnote/{discountid} * - * @return int - * * @throws RestException 400 * @throws RestException 401 * @throws RestException 404 @@ -1300,7 +1287,6 @@ class Invoices extends DolibarrApi */ public function useCreditNote($id, $discountid) { - require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; if (!DolibarrApiAccess::$user->rights->facture->creer) { @@ -1333,12 +1319,11 @@ class Invoices extends DolibarrApi /** * Get list of payments of a given invoice * - * @param int $id Id of invoice + * @param int $id Id of invoice + * @return array * * @url GET {id}/payments * - * @return array - * * @throws RestException 400 * @throws RestException 401 * @throws RestException 404 @@ -1395,8 +1380,6 @@ class Invoices extends DolibarrApi */ public function addPayment($id, $datepaye, $paymentid, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '') { - global $conf; - require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; if (!DolibarrApiAccess::$user->rights->facture->creer) { @@ -1509,6 +1492,7 @@ class Invoices extends DolibarrApi * @url POST /paymentsdistributed * * @return int Payment ID + * * @throws RestException 400 * @throws RestException 401 * @throws RestException 403 @@ -1516,8 +1500,6 @@ class Invoices extends DolibarrApi */ public function addPaymentDistributed($arrayofamounts, $datepaye, $paymentid, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '', $ref_ext = '', $accepthigherpayment = false) { - global $conf; - require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; if (!DolibarrApiAccess::$user->rights->facture->creer) { @@ -1645,6 +1627,7 @@ class Invoices extends DolibarrApi * @url PUT payments/{id} * * @return array + * * @throws RestException 400 Bad parameters * @throws RestException 401 Not allowed * @throws RestException 404 Not found @@ -1708,8 +1691,8 @@ class Invoices extends DolibarrApi /** * Validate fields before create or update object * - * @param array|null $data Datas to validate - * @return array + * @param array|null $data Datas to validate + * @return array * * @throws RestException */ @@ -1733,7 +1716,7 @@ class Invoices extends DolibarrApi * * @param int $id ID of template invoice * @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id, -1: Do not return contacts/adddesses - * @return array|mixed data without useless information + * @return Object Object with cleaned properties * * @url GET templates/{id} * @@ -1749,11 +1732,11 @@ class Invoices extends DolibarrApi * * Return an array with invoice informations * - * @param int $id ID of order - * @param string $ref Ref of object - * @param string $ref_ext External reference of object - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses - * @return array|mixed data without useless information + * @param int $id ID of order + * @param string $ref Ref of object + * @param string $ref_ext External reference of object + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses + * @return Object Object with cleaned properties * * @throws RestException */ diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 3a586dfc3e5..46262ab84b8 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -188,13 +188,12 @@ class FactureRec extends CommonInvoice 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>105), 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>110), 'modelpdf' =>array('type'=>'varchar(255)', 'label'=>'Modelpdf', 'enabled'=>1, 'visible'=>-1, 'position'=>115), - 'date_last_gen' =>array('type'=>'varchar(7)', 'label'=>'Last gen', 'enabled'=>1, 'visible'=>-1, 'position'=>120), - 'unit_frequency' =>array('type'=>'varchar(2)', 'label'=>'Unit frequency', 'enabled'=>1, 'visible'=>-1, 'position'=>125), 'date_when' =>array('type'=>'datetime', 'label'=>'Date when', 'enabled'=>1, 'visible'=>-1, 'position'=>130), 'date_last_gen' =>array('type'=>'datetime', 'label'=>'Date last gen', 'enabled'=>1, 'visible'=>-1, 'position'=>135), 'nb_gen_done' =>array('type'=>'integer', 'label'=>'Nb gen done', 'enabled'=>1, 'visible'=>-1, 'position'=>140), 'nb_gen_max' =>array('type'=>'integer', 'label'=>'Nb gen max', 'enabled'=>1, 'visible'=>-1, 'position'=>145), 'frequency' =>array('type'=>'integer', 'label'=>'Frequency', 'enabled'=>1, 'visible'=>-1, 'position'=>150), + 'unit_frequency' =>array('type'=>'varchar(2)', 'label'=>'UnitFrequency', 'enabled'=>1, 'visible'=>-1, 'position'=>152), 'usenewprice' =>array('type'=>'integer', 'label'=>'UseNewPrice', 'enabled'=>1, 'visible'=>0, 'position'=>155), 'revenuestamp' =>array('type'=>'double(24,8)', 'label'=>'RevenueStamp', 'enabled'=>1, 'visible'=>-1, 'position'=>160, 'isameasure'=>1), 'auto_validate' =>array('type'=>'integer', 'label'=>'Auto validate', 'enabled'=>1, 'visible'=>-1, 'position'=>165), @@ -1771,35 +1770,35 @@ class FactureRec extends CommonInvoice /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'facture_rec' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** * Function used to replace a product id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old product id - * @param int $dest_id New product id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old product id + * @param int $dest_id New product id + * @return bool */ - public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) + public static function replaceProduct(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'facturedet_rec' ); - return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceProduct($dbs, $origin_id, $dest_id, $tables); } /** diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 87d28de8756..0a9b0dcfe16 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1956,14 +1956,14 @@ class Facture extends CommonInvoice $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid'; if ($rowid) { - $sql .= " WHERE f.rowid=".((int) $rowid); + $sql .= " WHERE f.rowid = ".((int) $rowid); } else { $sql .= ' WHERE f.entity IN ('.getEntity('invoice').')'; // Don't use entity if you use rowid if ($ref) { - $sql .= " AND f.ref='".$this->db->escape($ref)."'"; + $sql .= " AND f.ref = '".$this->db->escape($ref)."'"; } if ($ref_ext) { - $sql .= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; + $sql .= " AND f.ref_ext = '".$this->db->escape($ref_ext)."'"; } } @@ -4078,7 +4078,7 @@ class Facture extends CommonInvoice * * @param int $idline id of line to check * @param float $situation_percent progress percentage need to be test - * @return false if KO, true if OK + * @return bool false if KO, true if OK */ public function checkProgressLine($idline, $situation_percent) { @@ -4097,7 +4097,7 @@ class Facture extends CommonInvoice if ($obj === null) { return true; } else { - return $situation_percent < $obj->situation_percent; + return ($situation_percent < $obj->situation_percent); } } @@ -4148,9 +4148,10 @@ class Facture extends CommonInvoice * Delete line in database * * @param int $rowid Id of line to delete + * @param int $id Id of object (for a check) * @return int <0 if KO, >0 if OK */ - public function deleteline($rowid) + public function deleteline($rowid, $id = 0) { global $user; @@ -4161,6 +4162,22 @@ class Facture extends CommonInvoice return -1; } + $line = new FactureLigne($this->db); + + $line->context = $this->context; + + // Load line + $result = $line->fetch($rowid); + if (!($result > 0)) { + dol_print_error($this->db, $line->error, $line->errors); + return -1; + } + + if ($id > 0 && $line->fk_facture != $id) { + $this->error = 'ErrorLineIDDoesNotMatchWithObjectID'; + return -1; + } + $this->db->begin(); // Free discount linked to invoice line @@ -4176,15 +4193,9 @@ class Facture extends CommonInvoice return -1; } - $line = new FactureLigne($this->db); - - $line->context = $this->context; - - // For triggers - $result = $line->fetch($rowid); - if (!($result > 0)) { - dol_print_error($this->db, $line->error, $line->errors); - } + // Memorize previous line for triggers + $staticline = clone $line; + $line->oldline = $staticline; if ($line->delete($user) > 0) { $result = $this->update_price(1); @@ -4213,7 +4224,7 @@ class Facture extends CommonInvoice * @param User $user User that set discount * @param double $remise Discount * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int <0 if ko, >0 if ok + * @return int <0 if KO, >0 if OK */ public function set_remise($user, $remise, $notrigger = 0) { @@ -4228,7 +4239,7 @@ class Facture extends CommonInvoice * @param User $user User that set discount * @param double $remise Discount * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int <0 if ko, >0 if ok + * @return int <0 if KO, >0 if OK */ public function setDiscount($user, $remise, $notrigger = 0) { @@ -4280,6 +4291,8 @@ class Facture extends CommonInvoice return -1 * $error; } } + + return 0; } @@ -4345,6 +4358,8 @@ class Facture extends CommonInvoice return -1 * $error; } } + + return 0; } /** @@ -4636,8 +4651,8 @@ class Facture extends CommonInvoice * Invoices matching the following rules are returned: * (validated + payment on process) or classified (payed completely or payed partiely) + not already replaced + not already a credit note * - * @param int $socid Id thirdparty - * @return array Array of invoices ($id => array('ref'=>,'paymentornot'=>,'status'=>,'paye'=>) + * @param int $socid Id thirdparty + * @return array|int Array of invoices ($id => array('ref'=>,'paymentornot'=>,'status'=>,'paye'=>) */ public function list_qualified_avoir_invoices($socid = 0) { @@ -4711,8 +4726,8 @@ class Facture extends CommonInvoice /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * - * @param User $user Object user - * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK + * @param User $user Object user + * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ public function load_board($user) { @@ -5190,18 +5205,18 @@ class Facture extends CommonInvoice /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old third-party id - * @param int $dest_id New third-party id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'facture' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** @@ -5731,6 +5746,8 @@ class Facture extends CommonInvoice } else { dol_print_error($this->db); } + + return array(); } } @@ -6264,7 +6281,7 @@ class FactureLigne extends CommonInvoiceLine $sql .= ", total_localtax2=".price2num($this->total_localtax2); } $sql .= ", fk_product_fournisseur_price=".(!empty($this->fk_fournprice) ? "'".$this->db->escape($this->fk_fournprice)."'" : "null"); - $sql .= ", buy_price_ht=".(($this->pa_ht || $this->pa_ht === 0 || $this->pa_ht === '0') ? price2num($this->pa_ht) : "null"); // $this->pa_ht should always be defined (set to 0 or to sell price depending on option) + $sql .= ", buy_price_ht=".(($this->pa_ht || (string) $this->pa_ht === '0') ? price2num($this->pa_ht) : "null"); // $this->pa_ht should always be defined (set to 0 or to sell price depending on option) $sql .= ", fk_parent_line=".($this->fk_parent_line > 0 ? $this->fk_parent_line : "null"); if (!empty($this->rang)) { $sql .= ", rang=".((int) $this->rang); @@ -6375,11 +6392,11 @@ class FactureLigne extends CommonInvoiceLine // Update line in database $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; - $sql .= " total_ht=".price2num($this->total_ht).""; - $sql .= ",total_tva=".price2num($this->total_tva).""; - $sql .= ",total_localtax1=".price2num($this->total_localtax1).""; - $sql .= ",total_localtax2=".price2num($this->total_localtax2).""; - $sql .= ",total_ttc=".price2num($this->total_ttc).""; + $sql .= " total_ht=".price2num($this->total_ht); + $sql .= ",total_tva=".price2num($this->total_tva); + $sql .= ",total_localtax1=".price2num($this->total_localtax1); + $sql .= ",total_localtax2=".price2num($this->total_localtax2); + $sql .= ",total_ttc=".price2num($this->total_ttc); $sql .= " WHERE rowid = ".((int) $this->rowid); dol_syslog(get_class($this)."::update_total", LOG_DEBUG); diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index 3ad533b6d3b..4da9dbb1559 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -137,7 +137,7 @@ class PaymentTerm // extends CommonObject $sql .= " ".(!isset($this->libelle_facture) ? 'NULL' : "'".$this->db->escape($this->libelle_facture)."'").","; $sql .= " ".(!isset($this->type_cdr) ? 'NULL' : "'".$this->db->escape($this->type_cdr)."'").","; $sql .= " ".(!isset($this->nbjour) ? 'NULL' : "'".$this->db->escape($this->nbjour)."'").","; - $sql .= " ".(!isset($this->decalage) ? 'NULL' : "'".$this->db->escape($this->decalage)."'").""; + $sql .= " ".(!isset($this->decalage) ? 'NULL' : "'".$this->db->escape($this->decalage)."'"); $sql .= ")"; $this->db->begin(); @@ -316,7 +316,7 @@ class PaymentTerm // extends CommonObject $sql .= " libelle_facture=".(isset($this->libelle_facture) ? "'".$this->db->escape($this->libelle_facture)."'" : "null").","; $sql .= " type_cdr=".(isset($this->type_cdr) ? $this->type_cdr : "null").","; $sql .= " nbjour=".(isset($this->nbjour) ? $this->nbjour : "null").","; - $sql .= " decalage=".(isset($this->decalage) ? $this->decalage : "null").""; + $sql .= " decalage=".(isset($this->decalage) ? $this->decalage : "null"); $sql .= " WHERE rowid = ".((int) $this->id); $this->db->begin(); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 348897369ee..4f87cf8bc69 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -299,7 +299,7 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa $massaction = ''; } -$parameters = array('socid'=>$socid); +$parameters = array('socid'=>$socid, 'arrayfields'=>&$arrayfields); $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'); @@ -376,9 +376,9 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', if (empty($reshook)) { $objectclass = 'Facture'; $objectlabel = 'Invoices'; - $permissiontoread = $user->rights->facture->lire; - $permissiontoadd = $user->rights->facture->creer; - $permissiontodelete = $user->rights->facture->supprimer; + $permissiontoread = $user->hasRight("facture", "lire"); + $permissiontoadd = $user->hasRight("facture", "creer"); + $permissiontodelete = $user->hasRight("facture", "supprimer"); $uploaddir = $conf->facture->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -843,7 +843,7 @@ if (!empty($searchCategoryProductList)) { } } } -$searchCategoryCustomerList = $search_categ_cus ? array($search_categ_cus) : array();; +$searchCategoryCustomerList = $search_categ_cus ? array($search_categ_cus) : array(); $searchCategoryCustomerOperator = 0; // Search for tag/category ($searchCategoryCustomerList is an array of ID) if (!empty($searchCategoryCustomerList)) { @@ -1185,7 +1185,7 @@ if ($resql) { if (!empty($socid)) { $url .= '&socid='.$socid; } - $newcardbutton = dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', $url, '', $user->rights->facture->creer); + $newcardbutton = dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', $url, '', $user->hasRight("facture", "creer")); } $i = 0; @@ -1237,7 +1237,7 @@ if ($resql) { // If the user can view prospects other than his' $moreforfilter = ''; - if ($user->rights->user->user->lire) { + if ($user->hasRight("user", "user", "lire")) { $langs->load("commercial"); $moreforfilter .= '
'; $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); @@ -1245,14 +1245,14 @@ if ($resql) { $moreforfilter .= '
'; } // If the user can view prospects other than his' - if ($user->rights->user->user->lire) { + if ($user->hasRight("user", "user", "lire")) { $moreforfilter .= '
'; $tmptitle = $langs->trans('LinkedToSpecificUsers'); $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250'); $moreforfilter .= '
'; } // Filter on product tags - if (isModEnabled('categorie') && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { + if (isModEnabled('categorie') && $user->hasRight("categorie", "lire") && ($user->hasRight("produit", "lire") || $user->hasRight("service", "lire"))) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; $tmptitle = $langs->trans('IncludingProductWithTag'); @@ -1260,7 +1260,7 @@ if ($resql) { $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth250', 1); $moreforfilter .= '
'; } - if (isModEnabled('categorie') && $user->rights->categorie->lire) { + if (isModEnabled('categorie') && $user->hasRight("categorie", "lire")) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; $tmptitle = $langs->trans('CustomersProspectsCategoriesShort'); @@ -1590,9 +1590,9 @@ if ($resql) { } // Status if (!empty($arrayfields['f.fk_statut']['checked'])) { - print '
'; } // Action column @@ -2574,8 +2574,8 @@ if ($resql) { $urlsource .= str_replace('&', '&', $param); $filedir = $diroutputmassaction; - $genallowed = $user->rights->facture->lire; - $delallowed = $user->rights->facture->creer; + $genallowed = $user->hasRight("facture", "lire"); + $delallowed = $user->hasRight("facture", "creer"); $title = ''; print $formfile->showdocuments('massfilesarea_invoices', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php index 6a16f4fa641..ca782052ff4 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php @@ -67,7 +67,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { break; } print ''; - print ''; + print ''; print ''; print ''; print ' - +
'; print $langs->trans('RetainedWarrantyDateLimit'); print 'id.'">'.img_edit($langs->trans('setretainedwarrantyDateLimit'), 1).''; + print ''; $liststatus = array('0'=>$langs->trans("BillShortStatusDraft"), '0,1'=>$langs->trans("BillShortStatusDraft").'+'.$langs->trans("BillShortStatusNotPaid"), '1'=>$langs->trans("BillShortStatusNotPaid"), '1,2'=>$langs->trans("BillShortStatusNotPaid").'+'.$langs->trans("BillShortStatusPaid"), '2'=>$langs->trans("BillShortStatusPaid"), '3'=>$langs->trans("BillShortStatusCanceled")); - print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'width100 onrightofpage', 1); + print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1); print ''.$objectlink->getNomUrl(1).''.$objectlink->getNomUrl(1).''.dol_escape_htmltag($objectlink->ref_client).''.dol_print_date($objectlink->date, 'day').''; diff --git a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php index 1bca663e1ef..c3c774b79e7 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php @@ -47,7 +47,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { ?>
trans("RepeatableInvoice"); ?>getNomUrl(1); ?>getNomUrl(1); ?> date_when, 'day'); ?> rights->facture->lire)) { // Last modified supplier invoices -if ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) { +if ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire")) || (isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) { $langs->load("boxes"); $facstatic = new FactureFournisseur($db); @@ -459,7 +459,7 @@ if (isModEnabled('don') && !empty($user->rights->don->lire)) { $donationstatic->ref = $obj->rowid; $donationstatic->lastname = $obj->lastname; $donationstatic->firstname = $obj->firstname; - $donationstatic->date = $obj->date; + $donationstatic->date = $db->jdate($obj->date); $donationstatic->statut = $obj->status; $donationstatic->status = $obj->status; @@ -590,7 +590,7 @@ if (isModEnabled('tax') && !empty($user->rights->tax->charges->lire)) { /* * Customers orders to be billed */ -if (isModEnabled('facture') && isModEnabled('commande') && $user->rights->commande->lire && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) { +if (isModEnabled('facture') && isModEnabled('commande') && $user->hasRight("commande", "lire") && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) { $commandestatic = new Commande($db); $langs->load("orders"); @@ -742,21 +742,25 @@ if (isModEnabled('facture') && isModEnabled('commande') && $user->rights->comman // TODO Mettre ici recup des actions en rapport avec la compta -$resql = ''; -if ($resql) { +$sql = ''; +if ($sql) { print '
'; print ''; print ''.$langs->trans("TasksToDo").''; print "\n"; $i = 0; - while ($i < $db->num_rows($resql)) { - $obj = $db->fetch_object($resql); + $resql = $db->query($sql); + if ($resql) { + $num_rows = $db->num_rows($resql); + while ($i < $num_rows) { + $obj = $db->fetch_object($resql); - print ''; - print ''; - $i++; + print ''; + print ''; + $i++; + } + $db->free($resql); } - $db->free($resql); print "
'.dol_print_date($db->jdate($obj->da), "day").''.$obj->label.'
'.dol_print_date($db->jdate($obj->da), "day").''.$obj->label.'

"; } diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index ad0b86a161d..f25b476fa94 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -18,11 +18,13 @@ * along with this program. If not, see . */ + /** * \file htdocs/compta/localtax/index.php * \ingroup tax - * \brief Index page of IRPF reports + * \brief Index page of localtax reports */ + require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; @@ -257,6 +259,9 @@ llxHeader('', $name); //$textnextyear=" ".img_next().""; //print load_fiche_titre($langs->transcountry($LT,$mysoc->country_code),"$textprevyear ".$langs->trans("Year")." $year_start $textnextyear", 'bill'); +$periodlink = ''; +$exportlink = ''; + report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode); //report_header($name,'',$textprevyear.$langs->trans("Year")." ".$year_start.$textnextyear,'',$description,$builddate,$exportlink,array(),$calcmode); @@ -269,7 +274,7 @@ print load_fiche_titre($langs->transcountry($LTSummary, $mysoc->country_code), ' print ''; print ''; -print '"; +print '"; if ($CalcLT == 0) { print ''; print ''; @@ -441,16 +446,6 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $ $hookmanager->initHooks(array('externalbalance')); $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!is_array($x_coll) && $coll_listbuy == -1) { - $langs->load("errors"); - print ''; - break; - } - if (!is_array($x_paye) && $coll_listbuy == -2) { - print ''; - break; - } - print ''; print ''; diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index 4930ce9e53c..073365fa876 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -84,7 +84,7 @@ if ($action == 'setnote' && $user->hasRight('facture', 'paiement')) { } } -if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->paiement) { +if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('facture', 'paiement')) { $db->begin(); $result = $object->delete(); @@ -105,7 +105,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture-> } } -if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->facture->paiement) { +if ($action == 'confirm_validate' && $confirm == 'yes' && $user->hasRight('facture', 'paiement')) { $db->begin(); if ($object->validate($user) > 0) { @@ -175,7 +175,7 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->facture } } -if ($action == 'setnum_paiement' && GETPOST('num_paiement')) { +if ($action == 'setnum_paiement' && GETPOST('num_paiement') && $user->hasRight('facture', 'paiement')) { $res = $object->update_num(GETPOST('num_paiement')); if ($res === 0) { setEventMessages($langs->trans('PaymentNumberUpdateSucceeded'), null, 'mesgs'); @@ -184,7 +184,7 @@ if ($action == 'setnum_paiement' && GETPOST('num_paiement')) { } } -if ($action == 'setdatep' && GETPOST('datepday')) { +if ($action == 'setdatep' && GETPOST('datepday') && $user->hasRight('facture', 'paiement')) { $datepaye = dol_mktime(GETPOST('datephour', 'int'), GETPOST('datepmin', 'int'), GETPOST('datepsec', 'int'), GETPOST('datepmonth', 'int'), GETPOST('datepday', 'int'), GETPOST('datepyear', 'int')); $res = $object->update_date($datepaye); if ($res === 0) { @@ -193,7 +193,8 @@ if ($action == 'setdatep' && GETPOST('datepday')) { setEventMessages($langs->trans('PaymentDateUpdateFailed'), null, 'errors'); } } -if ($action == 'createbankpayment' && !empty($user->rights->facture->paiement)) { + +if ($action == 'createbankpayment' && $user->hasRight('facture', 'paiement')) { $db->begin(); // Create the record into bank for the amount of payment $object @@ -415,8 +416,6 @@ if ($resql) { $i = 0; $total = 0; - $moreforfilter = ''; - print '
'; print '
'; @@ -511,9 +510,9 @@ if ($resql) { print '
'; if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) { - if ($user->socid == 0 && $object->statut == 0 && $_GET['action'] == '') { + if ($user->socid == 0 && $object->statut == 0 && $action == '') { if ($user->rights->facture->paiement) { - print ''.$langs->trans('Valid').''; + print ''.$langs->trans('Valid').''; } } } diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index f28ebf2ebcf..1aebdace757 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -385,14 +385,15 @@ if ($action == 'new') { print dol_get_fiche_end(); print '
'; - print ''; + print ''; if ($search_date_start || $search_date_end || $filteraccountid > 0) { print '   '; - print ''; + print ''; } print '
'; print ''; print '
'; + print '
'; $sql = "SELECT ba.rowid as bid, ba.label,"; $sql .= " b.rowid as transactionid, b.label as transactionlabel, b.datec as datec, b.dateo as date, "; @@ -484,13 +485,6 @@ if ($action == 'new') { if (count($lines[$bid])) { foreach ($lines[$bid] as $lid => $value) { - //$account_id = $bid; FIXME not used - - // FIXME $accounts[$bid] is a label ! - /*if (! isset($accounts[$bid])) - $accounts[$bid]=0; - $accounts[$bid] += 1;*/ - print '
'; print ''; print '\n"; @@ -524,8 +518,6 @@ if ($action == 'new') { print ''; print ''; print ''; - - $i++; } } print "
'.$langs->trans("Year")." ".$y."'.$langs->trans("Year")."'.$langs->transcountry($LTCustomer, $mysoc->country_code).''.$langs->transcountry($LTSupplier, $mysoc->country_code).'
'.$langs->trans("ErrorNoAccountancyModuleLoaded").'
'.$langs->trans("FeatureNotYetAvailable").'
'.dol_print_date(dol_mktime(0, 0, 0, $m, 1, $y), "%b %Y").'
'.dol_print_date($value["date"], 'day').''.$value["numero"]."
"; diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 3fb82f05cb9..e193939cdd6 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -190,8 +190,8 @@ class RemiseCheque extends CommonObject if ($this->id > 0 && $this->errno == 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque"; - $sql .= " SET ref='(PROV".$this->id.")'"; - $sql .= " WHERE rowid=".((int) $this->id).""; + $sql .= " SET ref = '(PROV".$this->id.")'"; + $sql .= " WHERE rowid=".((int) $this->id); $resql = $this->db->query($sql); if (!$resql) { diff --git a/htdocs/compta/paiement/cheque/index.php b/htdocs/compta/paiement/cheque/index.php index 92faa94dcee..394de095104 100644 --- a/htdocs/compta/paiement/cheque/index.php +++ b/htdocs/compta/paiement/cheque/index.php @@ -32,15 +32,23 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories', 'compta', 'bills')); +$checkdepositstatic = new RemiseCheque($db); +$accountstatic = new Account($db); + // Security check if ($user->socid) { $socid = $user->socid; } $result = restrictedArea($user, 'banque', '', ''); +$usercancreate = $user->hasRight('banque', 'cheque'); -$checkdepositstatic = new RemiseCheque($db); -$accountstatic = new Account($db); + +/* + * Actions + */ + +// None /* @@ -49,7 +57,12 @@ $accountstatic = new Account($db); llxHeader('', $langs->trans("ChequesArea")); -print load_fiche_titre($langs->trans("ChequesArea"), '', $checkdepositstatic->picto); +$newcardbutton = ''; +if ($usercancreate) { + $newcardbutton .= dolGetButtonTitle($langs->trans('NewDeposit'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/paiement/cheque/card.php?action=new'); +} + +print load_fiche_titre($langs->trans("ChequesArea"), $newcardbutton, $checkdepositstatic->picto); print '
'; @@ -64,6 +77,7 @@ $sql .= " AND b.amount > 0"; $resql = $db->query($sql); +print '
'; print ''; print ''; print '\n"; @@ -79,10 +93,10 @@ if ($resql) { print ''; - print "
'.$langs->trans("BankChecks")."'; print ''.$num.''; print '
\n"; } else { dol_print_error($db); } +print "
\n"; print '
'; diff --git a/htdocs/compta/payment_sc/card.php b/htdocs/compta/payment_sc/card.php index 39bac75ba0c..11f7f1e454f 100644 --- a/htdocs/compta/payment_sc/card.php +++ b/htdocs/compta/payment_sc/card.php @@ -46,8 +46,6 @@ $confirm = GETPOST('confirm', 'aZ09'); if ($user->socid) { $socid = $user->socid; } -// TODO ajouter regle pour restreindre acces paiement -//$result = restrictedArea($user, 'facture', $id,''); $object = new PaymentSocialContribution($db); if ($id > 0) { @@ -57,13 +55,15 @@ if ($id > 0) { } } +$result = restrictedArea($user, 'payment_sc', $id, ''); + /* * Actions */ // Delete payment -if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->tax->charges->supprimer) { +if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('tax', 'charges', 'supprimer')) { $db->begin(); $result = $object->delete($user); @@ -77,6 +77,16 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->tax->char } } +/*if ($action == 'setdatep' && GETPOST('datepday') && $user->hasRight('tax', 'charges', 'creer')) { + $datepaye = dol_mktime(GETPOST('datephour', 'int'), GETPOST('datepmin', 'int'), GETPOST('datepsec', 'int'), GETPOST('datepmonth', 'int'), GETPOST('datepday', 'int'), GETPOST('datepyear', 'int')); + $res = $object->update_date($datepaye); + if ($res === 0) { + setEventMessages($langs->trans('PaymentDateUpdateSucceeded'), null, 'mesgs'); + } else { + setEventMessages($langs->trans('PaymentDateUpdateFailed'), null, 'errors'); + } +}*/ + /* * View diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 959630a5538..554933a2137 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -72,6 +72,7 @@ class BonPrelevement extends CommonObject public $date_trans; public $user_trans; + public $method_trans; public $total; public $fetched; @@ -83,6 +84,15 @@ class BonPrelevement extends CommonObject public $invoice_in_error = array(); public $thirdparty_in_error = array(); + public $amount; + public $note; + public $datec; + + public $date_credit; + public $user_credit; + + public $type; + const STATUS_DRAFT = 0; const STATUS_TRANSFERED = 1; const STATUS_CREDITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type @@ -1856,7 +1866,7 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$row_country_code.''.$CrLf; $addressline1 = strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")); - $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => "")); + $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : (string) $row_town), array(CHR(13) => ", ", CHR(10) => "")); if (trim($addressline1)) { $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline1), ' '), 70, 'right', 'UTF-8', 1)).''.$CrLf; } @@ -1925,7 +1935,7 @@ class BonPrelevement extends CommonObject $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$row_country_code.''.$CrLf; $addressline1 = strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")); - $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => "")); + $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : (string) $row_town), array(CHR(13) => ", ", CHR(10) => "")); if (trim($addressline1)) { $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline1), ' '), 70, 'right', 'UTF-8', 1)).''.$CrLf; } diff --git a/htdocs/compta/prelevement/class/ligneprelevement.class.php b/htdocs/compta/prelevement/class/ligneprelevement.class.php index 0093db77c32..6ed518f7f2f 100644 --- a/htdocs/compta/prelevement/class/ligneprelevement.class.php +++ b/htdocs/compta/prelevement/class/ligneprelevement.class.php @@ -167,17 +167,17 @@ class LignePrelevement /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'prelevement_lignes' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } } diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 5fdf7220662..54f242edb7c 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -321,7 +321,7 @@ if ($modecompta == 'BOOKKEEPING') { if ($showaccountdetail == 'no') { if ($objp->pcg_type != $oldpcgtype) { - print '
'.$objp->pcg_type.'
'.dol_escape_htmltag($objp->pcg_type).'
'; - print $objp->pcg_type; - print ($objp->name ? ' ('.$objp->name.')' : ' ('.$langs->trans("Unknown").')'); + print dol_escape_htmltag($objp->pcg_type); + print ($objp->name ? ' ('.dol_escape_htmltag($objp->name).')' : ' ('.$langs->trans("Unknown").')'); print "'.price($objp->amount)."'.price($objp->amount)."
'; - print $objp->pcg_type; + print dol_escape_htmltag($objp->pcg_type); print "'.price($objp->amount)."'.price($objp->amount)."
    '.length_accountg($cpt['account_number']).' - '.$cpt['account_label'].''.price($resultN).''.price($resultN).'
'.$langs->trans("Income").''.price(price2num($total_ht_income, 'MT')).''.price(price2num($total_ht_income, 'MT')).''.price(price2num($total_ttc_income, 'MT')).''.price(price2num($total_ttc_income, 'MT')).'
'.$langs->trans("Outcome").''.price(price2num(-$total_ht_outcome, 'MT')).''.price(price2num(-$total_ht_outcome, 'MT')).''.price(price2num(-$total_ttc_outcome, 'MT')).''.price(price2num(-$total_ttc_outcome, 'MT')).'
'.$langs->trans("Profit").''.price(price2num($total_ht, 'MT')).''.price(price2num($total_ht, 'MT')).''.price(price2num($total_ttc, 'MT')).''.price(price2num($total_ttc, 'MT')).'
"; diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php index 3f3e14e2d61..743fd4c0506 100644 --- a/htdocs/compta/resultat/result.php +++ b/htdocs/compta/resultat/result.php @@ -184,8 +184,8 @@ llxheader('', $langs->trans('ReportInOut')); $formaccounting = new FormAccounting($db); $form = new Form($db); -$textprevyear = ''.img_previous().''; -$textnextyear = ' '.img_next().''; +$textprevyear = ''.img_previous().''; +$textnextyear = '   '.img_next().''; @@ -309,8 +309,8 @@ if ($modecompta == 'CREANCES-DETTES') { if (!is_array($cats) && $cats < 0) { setEventMessages(null, $AccCat->errors, 'errors'); } elseif (is_array($cats) && count($cats) > 0) { + // Loop on each custom group of accounts foreach ($cats as $cat) { - // Loop on each group if (!empty($cat['category_type'])) { // category calculed // When we enter here, $sommes was filled by group of accounts @@ -319,10 +319,10 @@ if ($modecompta == 'CREANCES-DETTES') { print '
'; + // Code and Label + print ''; print dol_escape_htmltag($cat['code']); - print ''; + print ''; print dol_escape_htmltag($cat['label']); print ''.$rshort.''.price($r).''.price($r).''.price($r).''.price($r).''.price($r).''.price($r).'
'; + print ''; print dol_escape_htmltag($cat['code']); print ''; - print dol_escape_htmltag($cat['label']); + $labeltoshow = dol_escape_htmltag($cat['label']); if (count($cpts) > 0 && !empty($cpts[0])) { // Show example of 5 first accounting accounts $i = 0; foreach ($cpts as $cpt) { if ($i > 5) { - print '...)'; + $labeltoshow .= '...)'; break; } if ($i > 0) { - print ', '; + $labeltoshow .= ', '; } else { - print ' ('; + $labeltoshow .= ' ('; } - print dol_escape_htmltag($cpt['account_number']); + $labeltoshow .= dol_escape_htmltag($cpt['account_number']); $i++; } if ($i <= 5) { - print ')'; + $labeltoshow .= ')'; } } else { - print ' - '.$langs->trans("GroupIsEmptyCheckSetup").''; + $labeltoshow .= ' - '.$langs->trans("GroupIsEmptyCheckSetup").''; } + print ''; + print $labeltoshow; print ''.price($totCat['NP']).''.price($totCat['N']).''.price($totCat['N']).'
'; + print ''; print '     '.length_accountg($cpt['account_number']); print ' - '; print $cpt['account_label']; print ''.price($resultNP).''.price($resultN).''.price($resultN).''; + print ''; $liststatus = array('0'=>$langs->trans("Unpaid"), '1'=>$langs->trans("Paid")); - print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100 onrightofpage', 1); + print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1); print '
'; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -389,16 +392,6 @@ if ($refresh === true) { $hookmanager->initHooks(array('externalbalance')); $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!is_array($x_coll) && $coll_listbuy == -1) { - $langs->load("errors"); - print ''; - break; - } - if (!is_array($x_paye) && $coll_listbuy == -2) { - print ''; - break; - } - print ''; print ''; diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 1c70cf93c22..001ef1e7b38 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -398,9 +398,9 @@ if (!empty($arrayfields['t.amount']['checked'])) { // Status if (!empty($arrayfields['t.status']['checked'])) { - print ''; } diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 29706f48b49..d0d2211c21c 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -81,7 +81,7 @@ if (GETPOST('actioncode', 'array')) { $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)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -262,11 +262,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') { $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : ''); } - $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&origin=contact&originid='.$object->id.'&percentage=-1&backtopage='.urlencode($_SERVER['PHP_SELF'].($objcon->id > 0 ? '?id='.$objcon->id : '')); + $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&origin=contact&originid='.$object->id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].($objcon->id > 0 ? '?id='.$objcon->id : '')); $out .= '&datep='.urlencode(dol_print_date(dol_now(), 'dayhourlog')); } - if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { + if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out); } } diff --git a/htdocs/contact/canvas/default/actions_contactcard_default.class.php b/htdocs/contact/canvas/default/actions_contactcard_default.class.php index 846f7440f97..f126b8c32a0 100644 --- a/htdocs/contact/canvas/default/actions_contactcard_default.class.php +++ b/htdocs/contact/canvas/default/actions_contactcard_default.class.php @@ -115,30 +115,5 @@ class ActionsContactCardDefault extends ActionsContactCardCommon $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); } } - - if ($action == 'list') { - $this->LoadListDatas($limit, $offset, $sortfield, $sortorder); - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Fetch datas list and save into ->list_datas - * - * @param int $limit Limit number of responses - * @param int $offset Offset for first response - * @param string $sortfield Sort field - * @param string $sortorder Sort order ('ASC' or 'DESC') - * @return void - */ - public function LoadListDatas($limit, $offset, $sortfield, $sortorder) - { - // phpcs:enable - global $conf, $langs; - - //$this->getFieldList(); - - $this->list_datas = array(); } } diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index c5184a18454..6cf7d3051f3 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -362,7 +362,7 @@ if (empty($reshook)) { if (!$error) { $contactid = GETPOST("contactid", 'int'); $object->fetch($contactid); - $object->fetchRoles($contactid); + $object->fetchRoles(); // Photo save $dir = $conf->societe->multidir_output[$object->entity]."/contact/".$object->id."/photos"; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index d535da76199..e2094402ced 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -353,9 +353,9 @@ class Contact extends CommonObject $this->fields['fk_soc']['searchall'] = 0; } - if (empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) { // Default behaviour - $this->field['fk_stcommcontact']['enabled'] = 0; - $this->field['fk_prospectcontactlevel']['enabled'] = 0; + if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) { // Default behaviour + $this->fields['fk_stcommcontact']['enabled'] = 0; + $this->fields['fk_prospectlevel']['enabled'] = 0; } // Unset fields that are disabled @@ -608,7 +608,7 @@ class Contact extends CommonObject $sql .= ", phone_perso = ".(isset($this->phone_perso) ? "'".$this->db->escape($this->phone_perso)."'" : "NULL"); $sql .= ", phone_mobile = ".(isset($this->phone_mobile) ? "'".$this->db->escape($this->phone_mobile)."'" : "NULL"); $sql .= ", priv = '".$this->db->escape($this->priv)."'"; - $sql .= ", fk_prospectcontactlevel = '".$this->db->escape($this->fk_prospectlevel)."'"; + $sql .= ", fk_prospectlevel = '".$this->db->escape($this->fk_prospectlevel)."'"; if (isset($this->stcomm_id)) { $sql .= ", fk_stcommcontact = ".($this->stcomm_id > 0 || $this->stcomm_id == -1 ? $this->stcomm_id : "0"); } @@ -987,7 +987,7 @@ class Contact extends CommonObject $sql .= " c.socialnetworks,"; $sql .= " c.photo,"; $sql .= " c.priv, c.note_private, c.note_public, c.default_lang, c.canvas,"; - $sql .= " c.fk_prospectcontactlevel, c.fk_stcommcontact, st.libelle as stcomm, st.picto as stcomm_picto,"; + $sql .= " c.fk_prospectlevel, c.fk_stcommcontact, st.libelle as stcomm, st.picto as stcomm_picto,"; $sql .= " c.import_key,"; $sql .= " c.datec as date_creation, c.tms as date_modification,"; $sql .= " co.label as country, co.code as country_code,"; @@ -1054,7 +1054,7 @@ class Contact extends CommonObject $this->poste = $obj->poste; $this->statut = $obj->statut; - $this->fk_prospectlevel = $obj->fk_prospectcontactlevel; + $this->fk_prospectlevel = $obj->fk_prospectlevel; $transcode = $langs->trans('StatusProspect'.$obj->fk_stcommcontact); $libelle = ($transcode != 'StatusProspect'.$obj->fk_stcommcontact ? $transcode : $obj->stcomm); @@ -1700,8 +1700,8 @@ class Contact extends CommonObject * Adds it to non existing supplied categories. * Existing categories are left untouch. * - * @param int[]|int $categories Category or categories IDs - * @return void + * @param int[]|int $categories Category or categories IDs + * @return int <0 if KO, >0 if OK */ public function setCategories($categories) { @@ -1712,18 +1712,18 @@ class Contact extends CommonObject /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'socpeople', 'societe_contacts' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** @@ -2115,4 +2115,47 @@ class Contact extends CommonObject } return 0; } + + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + //var_dump($this->photo);exit; + if (property_exists($this, 'photo') && !is_null($this->photo)) { + $return.= Form::showphoto('contact', $this, 0, 60, 0, 'photokanban photoref photowithmargin photologintooltip', 'small', 0, 1); + } else { + $return .= img_picto('', $this->picto); + } + $return .= ''; + $return .= '
'; + $return .= '
'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).'
'; + + if (property_exists($this, 'thirdparty') && is_object($this->thirdparty)) { + $return .= '
'.$this->thirdparty->getNomUrl(1).'
'; + } + /*if (property_exists($this, 'phone_pro') && !empty($this->phone_pro)) { + $return .= '
'.img_picto($langs->trans("Phone"), 'phone'); + $return .= ' '.$this->phone_pro.''; + }*/ + /*if (method_exists($this, 'LibPubPriv')) { + $return .= '
'.$langs->trans("Visibility").''; + $return .= ' : '.$this->LibPubPriv($this->priv).''; + }*/ + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index e8c4174af71..da07a2b699b 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -53,6 +53,7 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'contactlist'; +$mode = GETPOST('mode', 'alpha'); // Security check $id = GETPOST('id', 'int'); @@ -72,6 +73,7 @@ $search_firstlast_only = GETPOST("search_firstlast_only", 'alpha'); $search_lastname = GETPOST("search_lastname", 'alpha'); $search_firstname = GETPOST("search_firstname", 'alpha'); $search_societe = GETPOST("search_societe", 'alpha'); +$search_societe_alias = GETPOST("search_societe_alias", 'alpha'); $search_poste = GETPOST("search_poste", 'alpha'); $search_phone_perso = GETPOST("search_phone_perso", 'alpha'); $search_phone_pro = GETPOST("search_phone_pro", 'alpha'); @@ -192,6 +194,7 @@ foreach ($object->fields as $key => $val) { // Add none object fields for "search in all" if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { $fieldstosearchall['s.nom'] = "ThirdParty"; + $fieldstosearchall['s.name_alias'] = "AliasNames"; } // Definition of fields for list @@ -213,6 +216,7 @@ foreach ($object->fields as $key => $val) { $arrayfields['country.code_iso'] = array('label'=>"Country", 'position'=>66, 'checked'=>0); if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { $arrayfields['s.nom'] = array('label'=>"ThirdParty", 'position'=>113, 'checked'=> 1); + $arrayfields['s.name_alias'] = array('label'=>"AliasNameShort", 'position'=>114, 'checked'=> 1); } $arrayfields['unsubscribed'] = array( @@ -277,6 +281,7 @@ if (empty($reshook)) { $search_lastname = ""; $search_firstname = ""; $search_societe = ""; + $search_societe_alias = ""; $search_town = ""; $search_address = ""; $search_zip = ""; @@ -372,12 +377,12 @@ if ($resql) { dol_print_error($db); } -$sql = "SELECT s.rowid as socid, s.nom as name,"; +$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias as alias,"; $sql .= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.address, p.zip, p.town, p.poste, p.email,"; $sql .= " p.socialnetworks, p.photo,"; $sql .= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,"; $sql .= " p.import_key,"; -$sql .= " st.libelle as stcomm, st.picto as stcomm_picto, p.fk_stcommcontact as stcomm_id, p.fk_prospectcontactlevel,"; +$sql .= " st.libelle as stcomm, st.picto as stcomm_picto, p.fk_stcommcontact as stcomm_id, p.fk_prospectlevel,"; $sql .= " co.label as country, co.code as country_code"; // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { @@ -405,6 +410,10 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_stcommcontact as st ON st.id = p.fk_stco if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; } +// Add fields from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; $sql .= ' WHERE p.entity IN ('.getEntity('contact').')'; if (empty($user->rights->societe->client->voir) && !$socid) { //restriction $sql .= " AND (sc.fk_user = ".((int) $user->id)." OR p.fk_soc IS NULL)"; @@ -413,7 +422,7 @@ if (!empty($userid)) { // propre au commercial $sql .= " AND p.fk_user_creat=".((int) $userid); } if ($search_level) { - $sql .= natural_search("p.fk_prospectcontactlevel", join(',', $search_level), 3); + $sql .= natural_search("p.fk_prospectlevel", join(',', $search_level), 3); } if ($search_stcomm != '' && $search_stcomm != -2) { $sql .= natural_search("p.fk_stcommcontact", $search_stcomm, 2); @@ -544,8 +553,15 @@ if ($search_lastname) { if ($search_firstname) { $sql .= natural_search('p.firstname', $search_firstname); } -if ($search_societe) { - $sql .= natural_search(empty($conf->global->SOCIETE_DISABLE_CONTACTS) ? 's.nom' : 'p.fk_soc', $search_societe); +if (empty($arrayfields['s.name_alias']['checked']) && $search_societe) { + $sql .= natural_search(array("s.nom", "s.name_alias"), $search_societe); +} else { + if ($search_societe) { + $sql .= natural_search('s.nom', $search_societe); + } + if ($search_societe_alias) { + $sql .= natural_search('s.name_alias', $search_societe_alias); + } } if ($search_country) { $sql .= " AND p.fk_pays IN (".$db->sanitize($search_country).')'; @@ -676,10 +692,16 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ( exit; } +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'; llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -712,6 +734,9 @@ if ($search_firstname != '') { if ($search_societe != '') { $param .= '&search_societe='.urlencode($search_societe); } +if ($search_societe_alias != '') { + $param .= '&search_societe_alias='.urlencode($search_societe_alias); +} if ($search_address != '') { $param .= '&search_address='.urlencode($search_address); } @@ -774,7 +799,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available $arrayofmassactions = array( -// 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), + 'presend' => img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), // 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); @@ -789,7 +814,10 @@ if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) { } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); -$newcardbutton = dolGetButtonTitle($langs->trans('NewContactAddress'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create', '', $user->rights->societe->contact->creer); +$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 .= dolGetButtonTitle($langs->trans('NewContactAddress'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create', '', $user->rights->societe->contact->creer); print ''; if ($optioncss != '') { @@ -802,6 +830,8 @@ print ''; //print ''; print ''; print ''; +print ''; + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'address', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -984,6 +1014,12 @@ if (!empty($arrayfields['p.fk_soc']['checked']) || !empty($arrayfields['s.nom'][ print ''; print ''; } +// Alias +if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; +} if (!empty($arrayfields['p.priv']['checked'])) { print ''; } // Prospect level -if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) { +if (!empty($arrayfields['p.fk_prospectlevel']['checked'])) { print ''; @@ -1025,8 +1061,8 @@ if (!empty($arrayfields['p.tms']['checked'])) { } // Status if (!empty($arrayfields['p.statut']['checked'])) { - print ''; } if (!empty($arrayfields['p.import_key']['checked'])) { @@ -1105,11 +1141,14 @@ if (!empty($arrayfields['p.fk_soc']['checked'])) { if (!empty($arrayfields['s.nom']['checked'])) { print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $begin, $param, '', $sortfield, $sortorder); } +if (!empty($arrayfields['s.name_alias']['checked'])) { + print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", $begin, $param, '', $sortfield, $sortorder); +} if (!empty($arrayfields['p.priv']['checked'])) { print_liste_field_titre($arrayfields['p.priv']['label'], $_SERVER["PHP_SELF"], "p.priv", $begin, $param, '', $sortfield, $sortorder, 'center '); } -if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) { - print_liste_field_titre($arrayfields['p.fk_prospectcontactlevel']['label'], $_SERVER["PHP_SELF"], "p.fk_prospectcontactlevel", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['p.fk_prospectlevel']['checked'])) { + print_liste_field_titre($arrayfields['p.fk_prospectlevel']['label'], $_SERVER["PHP_SELF"], "p.fk_prospectlevel", "", $param, '', $sortfield, $sortorder, 'center '); } if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) { print_liste_field_titre($arrayfields['p.fk_stcommcontact']['label'], $_SERVER["PHP_SELF"], "p.fk_stcommcontact", "", $param, '', $sortfield, $sortorder, 'center '); @@ -1168,267 +1207,293 @@ while ($i < min($num, $limit)) { $contactstatic->photo = $obj->photo; $contactstatic->import_key = $obj->import_key; - $contactstatic->fk_prospectlevel = $obj->fk_prospectcontactlevel; + $contactstatic->fk_prospectlevel = $obj->fk_prospectlevel; - print ''; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + } + } else { + print ''; - // Action column - if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; } - print ''; - } - // ID - if (!empty($arrayfields['p.rowid']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; + // ID + if (!empty($arrayfields['p.rowid']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Name - if (!empty($arrayfields['p.lastname']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Name + if (!empty($arrayfields['p.lastname']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Firstname - if (!empty($arrayfields['p.firstname']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Firstname + if (!empty($arrayfields['p.firstname']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Job position - if (!empty($arrayfields['p.poste']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Job position + if (!empty($arrayfields['p.poste']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Address - if (!empty($arrayfields['p.address']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Address + if (!empty($arrayfields['p.address']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Zip - if (!empty($arrayfields['p.zip']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Zip + if (!empty($arrayfields['p.zip']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Town - if (!empty($arrayfields['p.town']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Town + if (!empty($arrayfields['p.town']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // State - /*if (!empty($arrayfields['state.nom']['checked'])) - { - print "\n"; - if (! $i) $totalarray['nbfield']++; - } - // Region - if (!empty($arrayfields['region.nom']['checked'])) - { - print "\n"; - if (! $i) $totalarray['nbfield']++; - }*/ - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // State + /*if (!empty($arrayfields['state.nom']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; } - } - // Phone - if (!empty($arrayfields['p.phone']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Region + if (!empty($arrayfields['region.nom']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + }*/ + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Phone perso - if (!empty($arrayfields['p.phone_perso']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Phone + if (!empty($arrayfields['p.phone']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Phone mobile - if (!empty($arrayfields['p.phone_mobile']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Phone perso + if (!empty($arrayfields['p.phone_perso']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Fax - if (!empty($arrayfields['p.fax']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Phone mobile + if (!empty($arrayfields['p.phone_mobile']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // EMail - if (!empty($arrayfields['p.email']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Fax + if (!empty($arrayfields['p.fax']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // No EMail - if (!empty($arrayfields['unsubscribed']['checked'])) { - print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - print ''; - if (!$i) { - $totalarray['nbfield']++; + // No EMail + if (!empty($arrayfields['unsubscribed']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - if (isModEnabled('socialnetworks')) { - foreach ($socialnetworks as $key => $value) { - if ($value['active'] && !empty($arrayfields['p.'.$key]['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + if (isModEnabled('socialnetworks')) { + foreach ($socialnetworks as $key => $value) { + if ($value['active'] && !empty($arrayfields['p.'.$key]['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } } } - } - // Company - if (!empty($arrayfields['p.fk_soc']['checked']) || !empty($arrayfields['s.nom']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Private/Public - if (!empty($arrayfields['p.priv']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) { - // Prospect level - print '"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) { - // Prospect status - print ''; + if (!$i) { + $totalarray['nbfield']++; } } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['p.datec']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['p.tms']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['p.statut']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Import key - if (!empty($arrayfields['p.import_key']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Action column - if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; + if (!$i) { + $totalarray['nbfield']++; } - print ''; } - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - print "\n"; + // Private/Public + if (!empty($arrayfields['p.priv']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + if (!empty($arrayfields['p.fk_prospectlevel']['checked'])) { + // Prospect level + print '"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) { + // Prospect status + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['p.datec']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['p.tms']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['p.statut']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Import key + if (!empty($arrayfields['p.import_key']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Action column + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + + print "\n"; + } $i++; } diff --git a/htdocs/contact/vcard.php b/htdocs/contact/vcard.php index fe11c90c0b9..d366d1c2b17 100644 --- a/htdocs/contact/vcard.php +++ b/htdocs/contact/vcard.php @@ -92,18 +92,23 @@ if ($company->id) { } elseif (empty(trim($contact->email))) { // when contact e-mail is empty, use only company e-mail $v->setEmail($company->email); - } elseif (strtolower(end(explode("@", $contact->email))) == strtolower(end(explode("@", $company->email)))) { - // when e-mail domain of contact and company are the same, use contact e-mail at first (and company e-mail at second) - $v->setEmail($contact->email); - - // support by Microsoft Outlook (2019 and possible earlier) - $v->setEmail($company->email, 'INTERNET'); } else { - // when e-mail of contact and company complete different use company e-mail at first (and contact e-mail at second) - $v->setEmail($company->email); + $tmpcontact = explode("@", trim($contact->email)); + $tmpcompany = explode("@", trim($company->email)); - // support by Microsoft Outlook (2019 and possible earlier) - $v->setEmail($contact->email, 'INTERNET'); + if (strtolower(end($tmpcontact)) == strtolower(end($tmpcompany))) { + // when e-mail domain of contact and company are the same, use contact e-mail at first (and company e-mail at second) + $v->setEmail($contact->email); + + // support by Microsoft Outlook (2019 and possible earlier) + $v->setEmail($company->email, 'INTERNET'); + } else { + // when e-mail of contact and company complete different use company e-mail at first (and contact e-mail at second) + $v->setEmail($company->email); + + // support by Microsoft Outlook (2019 and possible earlier) + $v->setEmail($contact->email, 'INTERNET'); + } } // Si contact lie a un tiers non de type "particulier" diff --git a/htdocs/contrat/agenda.php b/htdocs/contrat/agenda.php index 3a3c5440b30..f9dc7d44097 100644 --- a/htdocs/contrat/agenda.php +++ b/htdocs/contrat/agenda.php @@ -41,7 +41,7 @@ if (GETPOST('actioncode', 'array')) { $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)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -221,7 +221,7 @@ if ($id > 0) { { //$out.='trans("AddAnAction"),'filenew'); //$out.=""; @@ -234,7 +234,7 @@ if ($id > 0) { $newcardbutton = ''; if (isModEnabled('agenda')) { - if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { + if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { $backtopage = $_SERVER['PHP_SELF'].'?id='.$object->id; $out = '&origin='.$object->element.'&originid='.$object->id.'&backtopage='.urlencode($backtopage); $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 7aad6ca9c54..79897cdc16d 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1513,7 +1513,7 @@ if ($action == 'create') { // print ''; //} print ''; - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''; } print ''; @@ -1594,7 +1594,7 @@ if ($action == 'create') { // Quantity print ''; // Unit - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''; } // Discount @@ -1701,7 +1701,7 @@ if ($action == 'create') { if (empty($senderissupplier)) { print $form->select_produits((!empty($object->lines[$cursorline - 1]->fk_product) ? $object->lines[$cursorline - 1]->fk_product : 0), 'idprod'); } else { - print $form->select_produits_fournisseurs((!empty($object->lines[$cursorline - 1]->fk_product) ? $object->lines[$cursorline - 1]->fk_product : 0), 'idprod'); + $form->select_produits_fournisseurs((!empty($object->lines[$cursorline - 1]->fk_product) ? $object->lines[$cursorline - 1]->fk_product : 0), 'idprod'); } } print '
'; @@ -1739,7 +1739,7 @@ if ($action == 'create') { print ''; // Unit - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''; @@ -1765,7 +1765,7 @@ if ($action == 'create') { if (isModEnabled('margin') && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) { $colspan++; } - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $colspan++; } @@ -2025,7 +2025,7 @@ if ($action == 'create') { print ''; print ''; - print ''; + print ''; print '
' . $langs->trans("Year") . " " . $y . '' . $langs->trans("Year") . '' . $langs->trans("VATToPay") . '' . $langs->trans("VATToCollect") . '' . $langs->trans("Balance") . '
' . $langs->trans("ErrorNoAccountancyModuleLoaded") . '
' . $langs->trans("FeatureNotYetAvailable") . '
' . dol_print_date(dol_mktime(0, 0, 0, $m, 1, $y), "%b %Y") . ''; + print ''; $liststatus = array('0' => $langs->trans("Unpaid"), '1' => $langs->trans("Paid")); - print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'onrightofpage'); + print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage'); print '
'; + print ''; + print ''; $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); @@ -991,7 +1027,7 @@ if (!empty($arrayfields['p.priv']['checked'])) { print ''; print $form->multiselectarray('search_level', $tab_level, $search_level, 0, 0, 'width75', 0, 0, '', '', '', 2); print ''; - print $form->selectarray('search_status', array('-1'=>'', '0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $search_status, 0, 0, 0, '', 0, 0, 0, '', 'minwidth75 onrightofpage'); + print ''; + print $form->selectarray('search_status', array('-1'=>'', '0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $search_status, 0, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage'); print '
'; + print '
'; + } + $contactstatic->photo = $obj->photo; + if ($obj->socid > 0) { + $contactstatic->fetch_thirdparty($obj->socid); + } + print $contactstatic->getKanbanView(''); + if ($i == min($num, $limit) - 1) { + print '
'; + 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($obj->rowid, $arrayofselected)) { - $selected = 1; + // 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($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; } - print ''; + print ''; - print dol_escape_htmltag($obj->rowid); - print "'; + print dol_escape_htmltag($obj->rowid); + print "'; - print $contactstatic->getNomUrl(1); - print ''; + print $contactstatic->getNomUrl(1); + print ''.dol_escape_htmltag($obj->firstname).''.dol_escape_htmltag($obj->firstname).''.dol_escape_htmltag($obj->poste).''.dol_escape_htmltag($obj->poste).''.dol_escape_htmltag($obj->address).''.dol_escape_htmltag($obj->address).''.dol_escape_htmltag($obj->zip).''.dol_escape_htmltag($obj->zip).''.dol_escape_htmltag($obj->town).''.dol_escape_htmltag($obj->town).'".$obj->state_name."".$obj->region_name."'; - $tmparray = getCountry($obj->fk_pays, 'all'); - print dol_escape_htmltag($tmparray['label']); - print '".$obj->state_name."'.dol_print_phone($obj->phone_pro, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').'".$obj->region_name."'; + $tmparray = getCountry($obj->fk_pays, 'all'); + print dol_escape_htmltag($tmparray['label']); + print ''.dol_print_phone($obj->phone_perso, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').''.dol_print_phone($obj->phone_pro, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').''.dol_print_phone($obj->phone_mobile, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'mobile').''.dol_print_phone($obj->phone_perso, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').''.dol_print_phone($obj->fax, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'fax').''.dol_print_phone($obj->phone_mobile, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'mobile').''.dol_print_email($obj->email, $obj->rowid, $obj->socid, 'AC_EMAIL', 18, 0, 1).''.dol_print_phone($obj->fax, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'fax').''; - if (empty($obj->email)) { - //print ''.$langs->trans("NoEmail").''; - } else { - print yn(($obj->unsubscribed > 0) ? 1 : 0); + // EMail + if (!empty($arrayfields['p.email']['checked'])) { + print ''.dol_print_email($obj->email, $obj->rowid, $obj->socid, 'AC_EMAIL', 18, 0, 1).''; + if (empty($obj->email)) { + //print ''.$langs->trans("NoEmail").''; + } else { + print yn(($obj->unsubscribed > 0) ? 1 : 0); + } + print ''.(empty($arraysocialnetworks[$key]) ? '' : dol_print_socialnetworks($arraysocialnetworks[$key], $obj->rowid, $obj->socid, $key, $socialnetworks)).''.(empty($arraysocialnetworks[$key]) ? '' : dol_print_socialnetworks($arraysocialnetworks[$key], $obj->rowid, $obj->socid, $key, $socialnetworks)).''; - if ($obj->socid) { - $objsoc = new Societe($db); - $objsoc->fetch($obj->socid); - print $objsoc->getNomUrl(1); - } else { - print ' '; - } - print ''.$contactstatic->LibPubPriv($obj->priv).''; - print $contactstatic->getLibProspLevel(); - print "
'; - print '
'.$contactstatic->libProspCommStatut($obj->stcomm_id, 2, $contactstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto); - print '
-
'; - foreach ($contactstatic->cacheprospectstatus as $key => $val) { - $titlealt = 'default'; - if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) { - $titlealt = $val['label']; + // Company + if (!empty($arrayfields['p.fk_soc']['checked']) || !empty($arrayfields['s.nom']['checked'])) { + print '
'; + if ($obj->socid) { + $objsoc = new Societe($db); + $objsoc->fetch($obj->socid); + print $objsoc->getNomUrl(1); + } else { + print ' '; } - if ($obj->stcomm_id != $val['id']) { - print ''.img_action($titlealt, $val['code'], $val['picto']).''; + print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''.$contactstatic->getLibStatut(5).''; - print dol_escape_htmltag($obj->import_key); - 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($obj->rowid, $arrayofselected)) { - $selected = 1; + // Alias name + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + print dol_escape_htmltag($obj->alias); + print '
'.$contactstatic->LibPubPriv($obj->priv).''; + print $contactstatic->getLibProspLevel(); + print "
'; + print '
'.$contactstatic->libProspCommStatut($obj->stcomm_id, 2, $contactstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto); + print '
-
'; + foreach ($contactstatic->cacheprospectstatus as $key => $val) { + $titlealt = 'default'; + if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) { + $titlealt = $val['label']; + } + if ($obj->stcomm_id != $val['id']) { + print ''.img_action($titlealt, $val['code'], $val['picto']).''; + } + } + print '
'; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''.$contactstatic->getLibStatut(5).''; + print dol_escape_htmltag($obj->import_key); + 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($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print '
'.$langs->trans("PriceUHTCurrency").''.$langs->trans("Qty").''.$langs->trans("Unit").''.$langs->trans("ReductionShort").''.$objp->qty.''.$langs->trans($object->lines[$cursorline - 1]->getLabelOfUnit()).''; print $form->selectUnits($objp->fk_unit, "unit"); print '
'.$langs->trans("Comment").''.$langs->trans("Comment").''; print '   '; print ''; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 4352364452b..1846d911cef 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1368,8 +1368,8 @@ class Contrat extends CommonObject $sql .= " fk_commercial_suivi=".(isset($this->fk_commercial_suivi) ? $this->fk_commercial_suivi : "null").","; $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; $sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; - $sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null").""; - //$sql.= " extraparams=".(isset($this->extraparams)?"'".$this->db->escape($this->extraparams)."'":"null").""; + $sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); + //$sql.= " extraparams=".(isset($this->extraparams)?"'".$this->db->escape($this->extraparams)."'":"null"); $sql .= " WHERE rowid=".((int) $this->id); $this->db->begin(); @@ -2474,18 +2474,18 @@ class Contrat extends CommonObject /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'contrat' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** @@ -3434,11 +3434,11 @@ class ContratLigne extends CommonObjectLine // Mise a jour ligne en base $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET"; - $sql .= " total_ht=".price2num($this->total_ht, 'MT').""; - $sql .= ",total_tva=".price2num($this->total_tva, 'MT').""; - $sql .= ",total_localtax1=".price2num($this->total_localtax1, 'MT').""; - $sql .= ",total_localtax2=".price2num($this->total_localtax2, 'MT').""; - $sql .= ",total_ttc=".price2num($this->total_ttc, 'MT').""; + $sql .= " total_ht=".price2num($this->total_ht, 'MT'); + $sql .= ",total_tva=".price2num($this->total_tva, 'MT'); + $sql .= ",total_localtax1=".price2num($this->total_localtax1, 'MT'); + $sql .= ",total_localtax2=".price2num($this->total_localtax2, 'MT'); + $sql .= ",total_ttc=".price2num($this->total_ttc, 'MT'); $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::update_total", LOG_DEBUG); diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 07cf120f4cc..4b49840f681 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -619,7 +619,7 @@ print ''; print ''; print ''; -print_barre_liste($langs->trans("ListOfContracts"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contract', 0, $newcardbutton, '', $limit, 0, 0, 1); +print_barre_liste($langs->trans("Contracts"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contract', 0, $newcardbutton, '', $limit, 0, 0, 1); $topicmail = "SendContractRef"; $modelmail = "contract"; diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 74852da84f7..23c2159bc8f 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -93,11 +93,11 @@ if (!$error && $massaction == 'confirm_presend') { $objecttmp = new $objectclass($db); if ($objecttmp->element == 'expensereport') { $thirdparty = new User($db); - } - if ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { + } elseif ($objecttmp->element == 'contact') { + $thirdparty = new Contact($db); + } elseif ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { $thirdparty = new Adherent($db); - } - if ($objecttmp->element == 'holiday') { + } elseif ($objecttmp->element == 'holiday') { $thirdparty = new User($db); } @@ -110,14 +110,13 @@ if (!$error && $massaction == 'confirm_presend') { $thirdpartyid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid); if ($objecttmp->element == 'societe') { $thirdpartyid = $objecttmp->id; - } - if ($objecttmp->element == 'expensereport') { + } elseif ($objecttmp->element == 'contact') { + $thirdpartyid = $objecttmp->id; + } elseif ($objecttmp->element == 'expensereport') { $thirdpartyid = $objecttmp->fk_user_author; - } - if ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { + } elseif ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { $thirdpartyid = $objecttmp->fk_member; - } - if ($objecttmp->element == 'holiday') { + } elseif ($objecttmp->element == 'holiday') { $thirdpartyid = $objecttmp->fk_user; } if (empty($thirdpartyid)) { @@ -268,6 +267,10 @@ if (!$error && $massaction == 'confirm_presend') { $fuser = new User($db); $fuser->fetch($objectobj->fk_user_author); $sendto = $fuser->email; + } elseif ($objectobj->element == 'contact') { + $fcontact = new Contact($db); + $fcontact->fetch($objectobj->id); + $sendto = $fcontact->email; } elseif ($objectobj->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { $fadherent = new Adherent($db); $fadherent->fetch($objectobj->fk_member); @@ -510,31 +513,28 @@ if (!$error && $massaction == 'confirm_presend') { $trackid = 'thi'.$thirdparty->id; if ($objecttmp->element == 'expensereport') { $trackid = 'use'.$thirdparty->id; - } - if ($objecttmp->element == 'holiday') { + } elseif ($objecttmp->element == 'contact') { + $trackid = 'ctc'.$thirdparty->id; + } elseif ($objecttmp->element == 'holiday') { $trackid = 'use'.$thirdparty->id; } } else { $trackid = strtolower(get_class($objecttmp)); - if (get_class($objecttmp) == 'Contrat') { + if (get_class($objecttmp) == 'Contact') { + $trackid = 'ctc'; + } elseif (get_class($objecttmp) == 'Contrat') { $trackid = 'con'; - } - if (get_class($objecttmp) == 'Propal') { + } elseif (get_class($objecttmp) == 'Propal') { $trackid = 'pro'; - } - if (get_class($objecttmp) == 'Commande') { + } elseif (get_class($objecttmp) == 'Commande') { $trackid = 'ord'; - } - if (get_class($objecttmp) == 'Facture') { + } elseif (get_class($objecttmp) == 'Facture') { $trackid = 'inv'; - } - if (get_class($objecttmp) == 'Supplier_Proposal') { + } elseif (get_class($objecttmp) == 'Supplier_Proposal') { $trackid = 'spr'; - } - if (get_class($objecttmp) == 'CommandeFournisseur') { + } elseif (get_class($objecttmp) == 'CommandeFournisseur') { $trackid = 'sor'; - } - if (get_class($objecttmp) == 'FactureFournisseur') { + } elseif (get_class($objecttmp) == 'FactureFournisseur') { $trackid = 'sin'; } diff --git a/htdocs/core/actions_setmoduleoptions.inc.php b/htdocs/core/actions_setmoduleoptions.inc.php index fbf526fd58e..deca9588444 100644 --- a/htdocs/core/actions_setmoduleoptions.inc.php +++ b/htdocs/core/actions_setmoduleoptions.inc.php @@ -127,6 +127,7 @@ if ($action == 'setModuleOptions' && !empty($user->admin)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $keyforuploaddir = GETPOST('keyforuploaddir', 'aZ09'); $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim(getDolGlobalString($keyforuploaddir)))); + foreach ($listofdir as $key => $tmpdir) { $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT\/*/', '', $tmpdir); // Clean string if we found a hardcoded DOL_DATA_ROOT @@ -144,6 +145,8 @@ if ($action == 'setModuleOptions' && !empty($user->admin)) { break; // So we take the first directory found into setup $conf->global->$keyforuploaddir } } + + if ($upload_dir) { $result = dol_add_file_process($upload_dir, 1, 1, 'uploadfile', ''); if ($result <= 0) { diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index e4bf213c4eb..76531832776 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -362,31 +362,31 @@ if ($type == 'directory') { if ($module == 'medias') { $useinecm = 6; $modulepart = 'medias'; - $perm = ($user->rights->website->write || $user->rights->emailing->creer); + $perm = ($user->hasRight("website", "write") || $user->hasRight("emailing", "creer")); $title = 'none'; } elseif ($module == 'ecm') { // DMS/ECM -> manual structure - if ($user->rights->ecm->read) { + if ($user->hasRight("ecm", "read")) { // Buttons: Preview $useinecm = 2; } - if ($user->rights->ecm->upload) { + if ($user->hasRight("ecm", "upload")) { // Buttons: Preview + Delete $useinecm = 4; } - if ($user->rights->ecm->setup) { + if ($user->hasRight("ecm", "setup")) { // Buttons: Preview + Delete + Edit $useinecm = 5; } - $perm = $user->rights->ecm->upload; + $perm = $user->hasRight("ecm", "upload"); $modulepart = 'ecm'; $title = ''; // Use default } else { $useinecm = 5; $modulepart = 'ecm'; - $perm = $user->rights->ecm->upload; + $perm = $user->hasRight("ecm", "upload"); $title = ''; // Use default } diff --git a/htdocs/core/ajax/onlineSign.php b/htdocs/core/ajax/onlineSign.php index c2823407ac6..47a7a2b6f13 100644 --- a/htdocs/core/ajax/onlineSign.php +++ b/htdocs/core/ajax/onlineSign.php @@ -219,6 +219,10 @@ if ($action == "importSignature") { if ($result < 0) { $error++; } + $result = $object->call_trigger('PROPAL_CLOSE_SIGNED_WEB', $user); + if ($result < 0) { + $error++; + } } } else { $db->rollback(); diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php index fb0f93086d2..ac0df03184a 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -220,7 +220,9 @@ class box_actions extends ModeleBoxes if (!empty($conf->global->SHOW_DIALOG_HOMEPAGE)) { $actioncejour = false; $contents = $this->info_box_contents; - $nblines = count($contents); + if (is_countable($contents) && count($contents) > 0) { + $nblines = count($contents); + } if ($contents[0][0]['text'] != $langs->trans("NoActionsToDo")) { $out .= '
trans("ActionsToDo").'">'; $out .= ''; diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 56fa8172bcb..ea45580e163 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -84,7 +84,7 @@ class box_activity extends ModeleBoxes $totalnb = 0; $line = 0; $cachetime = 3600; - $fileid = '-e'.$conf->entity.'-u'.$user->id.'-s'.$user->socid.'-r'.($user->rights->societe->client->voir ? '1' : '0').'.cache'; + $fileid = '-e'.$conf->entity.'-u'.$user->id.'-s'.$user->socid.'-r'.($user->hasRight("societe", "client", "voir") ? '1' : '0').'.cache'; $now = dol_now(); $nbofperiod = 3; @@ -102,7 +102,7 @@ class box_activity extends ModeleBoxes // list the summary of the propals - if (isModEnabled("propal") && $user->rights->propal->lire) { + if (isModEnabled("propal") && $user->hasRight("propal", "lire")) { include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $propalstatic = new Propal($this->db); @@ -155,7 +155,7 @@ class box_activity extends ModeleBoxes while ($j < count($data)) { $this->info_box_contents[$line][0] = array( 'td' => 'class="left" width="16"', - 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".$data[$j]->fk_statut, + 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".((int) $data[$j]->fk_statut), 'tooltip' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut, 0), 'logo' => 'object_propal' ); @@ -169,7 +169,7 @@ class box_activity extends ModeleBoxes 'td' => 'class="right"', 'text' => $data[$j]->nb, 'tooltip' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut, 0), - 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".$data[$j]->fk_statut, + 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".((int) $data[$j]->fk_statut), ); $totalnb += $data[$j]->nb; @@ -185,11 +185,18 @@ class box_activity extends ModeleBoxes $line++; $j++; } + if (count($data) == 0) { + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedProposals"), + ); + $line++; + } } } // list the summary of the orders - if (isModEnabled('commande') && $user->rights->commande->lire) { + if (isModEnabled('commande') && $user->hasRight("commande", "lire")) { include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $commandestatic = new Commande($this->db); @@ -273,12 +280,19 @@ class box_activity extends ModeleBoxes $line++; $j++; } + if (count($data) == 0) { + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedOrders"), + ); + $line++; + } } } // list the summary of the bills - if (isModEnabled('facture') && $user->rights->facture->lire) { + if (isModEnabled('facture') && $user->hasRight("facture", "lire")) { include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $facturestatic = new Facture($this->db); @@ -329,11 +343,11 @@ class box_activity extends ModeleBoxes if (!empty($data)) { $j = 0; while ($j < count($data)) { - $billurl = "search_status=2&paye=1"; + $billurl = "search_status=2&paye=1"; $this->info_box_contents[$line][0] = array( 'td' => 'class="left" width="16"', 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0), - 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", + 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", 'logo' => 'bill', ); @@ -346,7 +360,7 @@ class box_activity extends ModeleBoxes 'td' => 'class="right"', 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0), 'text' => $data[$j]->nb, - 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", + 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", ); $this->info_box_contents[$line][3] = array( @@ -369,6 +383,7 @@ class box_activity extends ModeleBoxes 'td' => 'class="center"', 'text'=>$langs->trans("NoRecordedInvoices"), ); + $line++; } } @@ -412,11 +427,11 @@ class box_activity extends ModeleBoxes $j = 0; while ($j < count($data)) { - $billurl = "search_status=".$data[$j]->fk_statut."&paye=0"; + $billurl = "search_status=".$data[$j]->fk_statut."&paye=0"; $this->info_box_contents[$line][0] = array( 'td' => 'class="left" width="16"', 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0), - 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", + 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", 'logo' => 'bill', ); @@ -446,8 +461,9 @@ class box_activity extends ModeleBoxes if (count($data) == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedInvoices"), + 'text'=>$langs->trans("NoRecordedUnpaidInvoices"), ); + $line++; } } } diff --git a/htdocs/core/boxes/box_dolibarr_state_board.php b/htdocs/core/boxes/box_dolibarr_state_board.php index 9a2e94b8a1d..6152b167863 100644 --- a/htdocs/core/boxes/box_dolibarr_state_board.php +++ b/htdocs/core/boxes/box_dolibarr_state_board.php @@ -20,7 +20,7 @@ /** * \file htdocs/core/boxes/box_dolibarr_state_board.php - * \ingroup + * \ingroup core * \brief Module Dolibarr state base */ diff --git a/htdocs/core/boxes/box_graph_invoices_peryear.php b/htdocs/core/boxes/box_graph_invoices_peryear.php index 5a9b84829f2..9ea2fe5a130 100644 --- a/htdocs/core/boxes/box_graph_invoices_peryear.php +++ b/htdocs/core/boxes/box_graph_invoices_peryear.php @@ -142,7 +142,7 @@ class box_graph_invoices_peryear extends ModeleBoxes $px2->SetData($data2); unset($data2); $i = $startyear; - $legend = array(); + /*$legend = array(); while ($i <= $endyear) { if ($startmonth != 1) { $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); @@ -150,7 +150,7 @@ class box_graph_invoices_peryear extends ModeleBoxes $legend[] = $i; } $i++; - } + }*/ $px2->SetLegend([$langs->trans("AmountOfBillsHT")]); $px2->SetMaxValue($px2->GetCeilMaxValue()); $px2->SetWidth($WIDTH); diff --git a/htdocs/core/boxes/box_members_by_type.php b/htdocs/core/boxes/box_members_by_type.php index 2e25da59564..b3f3504cee8 100644 --- a/htdocs/core/boxes/box_members_by_type.php +++ b/htdocs/core/boxes/box_members_by_type.php @@ -92,13 +92,15 @@ class box_members_by_type extends ModeleBoxes if ($user->rights->adherent->lire) { $MembersToValidate = array(); + $MembersPending = array(); $MembersValidated = array(); $MembersUpToDate = array(); $MembersExcluded = array(); $MembersResiliated = array(); $SumToValidate = 0; - $SumValidated = 0; + $SumPending = 0; + $SumExpired = 0; $SumUpToDate = 0; $SumResiliated = 0; $SumExcluded = 0; @@ -169,43 +171,74 @@ class box_members_by_type extends ModeleBoxes } $this->db->free($result); } + // Members pendding (Waiting for first subscription) + $sql = "SELECT count(*) as somme , d.fk_adherent_type"; + $sql .= " FROM " . MAIN_DB_PREFIX . "adherent as d, " . MAIN_DB_PREFIX . "adherent_type as t"; + $sql .= " WHERE d.entity IN (" . getEntity('adherent') . ")"; + $sql .= " AND d.statut = 1 AND (d.datefin IS NULL AND t.subscription = 1)"; + $sql .= " AND t.rowid = d.fk_adherent_type"; + $sql .= " GROUP BY d.fk_adherent_type"; + + dol_syslog("index.php::select nb of uptodate members by type", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + $num2 = $this->db->num_rows($result); + $i = 0; + while ($i < $num2) { + $objp = $this->db->fetch_object($result); + $MembersPending[$objp->fk_adherent_type] = $objp->somme; + $i++; + } + $this->db->free($result); + } $line = 0; $this->info_box_contents[$line][] = array( 'td' => 'class=""', 'text' => '', ); + // Draft $labelstatus = $staticmember->LibStatut($staticmember::STATUS_DRAFT, 0, 0, 1); $this->info_box_contents[$line][] = array( 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus ); - $labelstatus = $langs->trans("UpToDate"); + // Pending (Waiting for first subscription) + $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, 0, 1); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', + 'text' => $labelstatus + ); + // Up to date $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, dol_now() + 86400, 1); $this->info_box_contents[$line][] = array( 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus, ); - $labelstatus = $langs->trans("OutOfDate"); + // Expired $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, dol_now() - 86400, 1); $this->info_box_contents[$line][] = array( 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus ); + // Excluded $labelstatus = $staticmember->LibStatut($staticmember::STATUS_EXCLUDED, 0, 0, 1); $this->info_box_contents[$line][] = array( 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus ); + // Resiliated $labelstatus = $staticmember->LibStatut($staticmember::STATUS_RESILIATED, 0, 0, 1); $this->info_box_contents[$line][] = array( 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus ); $line++; + foreach ($AdherentType as $key => $adhtype) { $SumToValidate += isset($MembersToValidate[$key]) ? $MembersToValidate[$key] : 0; - $SumValidated += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) : 0; + $SumPending += isset($MembersPending[$key]) ? $MembersPending[$key] : 0; + $SumExpired += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) - (isset($MembersPending[$key]) ? $MembersPending[$key] : 0): 0; $SumUpToDate += isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0; $SumExcluded += isset($MembersExcluded[$key]) ? $MembersExcluded [$key] : 0; $SumResiliated += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0; @@ -220,6 +253,11 @@ class box_members_by_type extends ModeleBoxes 'text' => (isset($MembersToValidate[$key]) && $MembersToValidate[$key] > 0 ? $MembersToValidate[$key] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_DRAFT, 1, 0, 3), 'asis' => 1, ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($MembersPending[$key]) && $MembersPending[$key] > 0 ? $MembersPending[$key] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 0, 3), + 'asis' => 1, + ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', 'text' => (isset($MembersUpToDate[$key]) && $MembersUpToDate[$key] > 0 ? $MembersUpToDate[$key] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now, 3), @@ -260,6 +298,11 @@ class box_members_by_type extends ModeleBoxes 'text' => $SumToValidate.' '.$staticmember->LibStatut(Adherent::STATUS_DRAFT, 1, 0, 3), 'asis' => 1 ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $SumPending.' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 0, 3), + 'asis' => 1 + ); $this->info_box_contents[$line][] = array( 'td' => 'class="liste_total right"', 'text' => $SumUpToDate.' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now, 3), @@ -267,7 +310,7 @@ class box_members_by_type extends ModeleBoxes ); $this->info_box_contents[$line][] = array( 'td' => 'class="liste_total right"', - 'text' => $SumValidated.' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 1, 3), + 'text' => $SumExpired.' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 1, 3), 'asis' => 1 ); $this->info_box_contents[$line][] = array( diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index 80d465f0f87..6c3db843523 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -175,7 +175,6 @@ class box_project extends ModeleBoxes $this->info_box_contents[$i][] = array( 'td' => 'class="liste_total"', 'text' => $langs->trans("Total")." ".$textHead, - 'text' => " ", ); $this->info_box_contents[$i][] = array( 'td' => 'class="right liste_total" ', diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index a7a87e1ce6e..cf0bfa6ed3b 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -1123,7 +1123,7 @@ class CMailFile return 'Bad value for sendmode'; } - $parameters = array(); + $parameters = array('sent' => $res); $action = ''; $reshook = $hookmanager->executeHooks('sendMailAfter', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 67443a7bdb8..1ed16b2e1ce 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -157,13 +157,14 @@ class Canvas } /** - * Return the template to display canvas (if it exists) + * Return if a template exists to display as canvas (if it exists) * * @param string $action Action code * @return int 0=Canvas template file does not exist, 1=Canvas template file exists */ public function displayCanvasExists($action) { + // template_dir should be '/'.$this->dirmodule.'/canvas/'.$this->canvas.'/tpl/', for example '/mymodule/canvas/product/tpl' if (empty($this->template_dir)) { return 0; } diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php index 7b46b0a08b0..cbf4574ec48 100644 --- a/htdocs/core/class/ccountry.class.php +++ b/htdocs/core/class/ccountry.class.php @@ -122,7 +122,7 @@ class Ccountry // extends CommonObject $sql .= " ".(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").","; $sql .= " ".(!isset($this->code_iso) ? 'NULL' : "'".$this->db->escape($this->code_iso)."'").","; $sql .= " ".(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").","; - $sql .= " ".(!isset($this->active) ? 'NULL' : "'".$this->db->escape($this->active)."'").""; + $sql .= " ".(!isset($this->active) ? 'NULL' : "'".$this->db->escape($this->active)."'"); $sql .= ")"; $this->db->begin(); @@ -239,7 +239,7 @@ class Ccountry // extends CommonObject $sql .= " code=".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").","; $sql .= " code_iso=".(isset($this->code_iso) ? "'".$this->db->escape($this->code_iso)."'" : "null").","; $sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; - $sql .= " active=".(isset($this->active) ? $this->active : "null").""; + $sql .= " active=".(isset($this->active) ? $this->active : "null"); $sql .= " WHERE rowid=".((int) $this->id); $this->db->begin(); diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index 960d2ac4744..4a743e5b070 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -351,16 +351,18 @@ class Comment extends CommonObject /** - * Load comments linked with current task + * Load comments linked with current task into ->comments * * @param string $element_type Element type * @param int $fk_element Id of element - * @return array Comment array + * @return int Result */ public function fetchAllFor($element_type, $fk_element) { global $db, $conf; + $this->comments = array(); + if (!empty($element_type) && !empty($fk_element)) { $sql = "SELECT"; $sql .= " c.rowid"; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 82012400f68..abf30f2f3ee 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -651,7 +651,7 @@ abstract class CommonDocGenerator ); // Units - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $resarray['line_unit'] = $outputlangs->trans($line->getLabelOfUnit('long')); $resarray['line_unit_short'] = $outputlangs->trans($line->getLabelOfUnit('short')); } @@ -687,7 +687,7 @@ abstract class CommonDocGenerator $resql = $this->db->fetch_object($resql); foreach ($extralabels as $key => $label) { - $resarray['line_product_supplier_'.$key] = $resql->{$key}; + $resarray['line_product_supplier_'.$key] = $resql->$key; } } } @@ -1016,12 +1016,10 @@ abstract class CommonDocGenerator * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @return null + * @return void */ public function prepareArrayColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { - global $conf; - $this->defineColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -1110,10 +1108,10 @@ abstract class CommonDocGenerator } /** - * get column position rank from column key + * get column position rank from column key * - * @param string $colKey the column key - * @return int rank on success and -1 on error + * @param string $colKey the column key + * @return int rank on success and -1 on error */ public function getColumnRank($colKey) { @@ -1126,11 +1124,11 @@ abstract class CommonDocGenerator /** * get column position rank from column key * - * @param string $newColKey the new column key - * @param array $defArray a single column definition array - * @param string $targetCol target column used to place the new column beside - * @param bool $insertAfterTarget insert before or after target column ? - * @return int new rank on success and -1 on error + * @param string $newColKey the new column key + * @param array $defArray a single column definition array + * @param string $targetCol target column used to place the new column beside + * @param bool $insertAfterTarget insert before or after target column ? + * @return int new rank on success and -1 on error */ public function insertNewColumnDef($newColKey, $defArray, $targetCol = false, $insertAfterTarget = false) { @@ -1171,11 +1169,11 @@ abstract class CommonDocGenerator /** * print standard column content * - * @param TCPDF $pdf pdf object - * @param float $curY curent Y position - * @param string $colKey the column key - * @param string $columnText column text - * @return null + * @param TCPDF $pdf pdf object + * @param float $curY curent Y position + * @param string $colKey the column key + * @param string $columnText column text + * @return int <0 if KO, >= if OK */ public function printStdColumnContent($pdf, &$curY, $colKey, $columnText = '') { @@ -1193,7 +1191,7 @@ abstract class CommonDocGenerator } if (!$reshook) { if (empty($columnText)) { - return; + return 0; } $pdf->SetXY($this->getColumnContentXStart($colKey), $curY); // Set curent position $colDef = $this->cols[$colKey]; @@ -1206,22 +1204,24 @@ abstract class CommonDocGenerator // restore cell padding $pdf->setCellPaddings($curentCellPaddinds['L'], $curentCellPaddinds['T'], $curentCellPaddinds['R'], $curentCellPaddinds['B']); } + + return 0; } /** * print description column content * - * @param TCPDF $pdf pdf object - * @param float $curY curent Y position - * @param string $colKey the column key - * @param object $object CommonObject - * @param int $i the $object->lines array key - * @param Translate $outputlangs Output language - * @param int $hideref hide ref - * @param int $hidedesc hide desc - * @param int $issupplierline if object need supplier product - * @return null + * @param TCPDF $pdf pdf object + * @param float $curY curent Y position + * @param string $colKey the column key + * @param object $object CommonObject + * @param int $i the $object->lines array key + * @param Translate $outputlangs Output language + * @param int $hideref hide ref + * @param int $hidedesc hide desc + * @param int $issupplierline if object need supplier product + * @return void */ public function printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0) { @@ -1265,7 +1265,7 @@ abstract class CommonDocGenerator global $hookmanager; if (empty($object->table_element)) { - return; + return ''; } $extrafieldsKeyPrefix = "options_"; @@ -1317,10 +1317,10 @@ abstract class CommonDocGenerator /** * display extrafields columns content * - * @param object $object line of common object - * @param Translate $outputlangs Output language - * @param array $params array of additionals parameters - * @return double max y value + * @param object $object line of common object + * @param Translate $outputlangs Output language + * @param array $params array of additionals parameters + * @return string Html string */ public function getExtrafieldsInHtml($object, $outputlangs, $params = array()) { @@ -1330,7 +1330,7 @@ abstract class CommonDocGenerator return; } - // Load extrafiels if not allready does + // Load extrafields if not allready done if (empty($this->extrafieldsCache)) { $this->extrafieldsCache = new ExtraFields($this->db); } @@ -1366,7 +1366,6 @@ abstract class CommonDocGenerator $params = $params + $defaultParams; - /** * @var $extrafields ExtraFields */ @@ -1593,18 +1592,16 @@ abstract class CommonDocGenerator * @param object $object common object det * @param Translate $outputlangs langs * @param int $hidedetails Do not show line details - * @return null + * @return int <0 if KO, >=0 if OK */ public function defineColumnExtrafield($object, $outputlangs, $hidedetails = 0) { - global $conf; - if (!empty($hidedetails)) { - return; + return 0; } if (empty($object->table_element)) { - return; + return 0; } // Load extrafiels if not allready does @@ -1674,5 +1671,7 @@ abstract class CommonDocGenerator $this->insertNewColumnDef("options_".$key, $def); } } + + return 1; } } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 37f250bf92f..a23c0611589 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2072,7 +2072,7 @@ abstract class CommonObject $sql .= " WHERE ".$id_field." = ".((int) $id); - dol_syslog(__METHOD__."", LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { if ($trigkey) { @@ -3338,6 +3338,8 @@ abstract class CommonObject $row = $this->db->fetch_row($resql); return $row[0]; } + + return 0; } /** @@ -3361,6 +3363,8 @@ abstract class CommonObject $row = $this->db->fetch_row($resql); return $row[0]; } + + return 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -3406,6 +3410,8 @@ abstract class CommonObject return $row[0]; } } + + return 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -3796,7 +3802,7 @@ abstract class CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Add objects linked in llx_element_element. + * Add an object link into llx_element_element. * * @param string $origin Linked element type * @param int $origin_id Linked element id @@ -4118,6 +4124,21 @@ abstract class CommonObject } } + /** + * Clear the cache saying that all linked object were already loaded. So next fetchObjectLinked will reload all links. + * + * @return int <0 if KO, >0 if OK + * @see fetchObjectLinked() + */ + public function clearObjectLinkedCache() + { + if ($this->id > 0 && !empty($this->linkedObjectsFullLoaded[$this->id])) { + unset($this->linkedObjectsFullLoaded[$this->id]); + } + + return 1; + } + /** * Update object linked of a current object * @@ -4518,6 +4539,8 @@ abstract class CommonObject $row = $this->db->fetch_row($resql); return $row[0]; } + + return 0; } /** @@ -5100,7 +5123,7 @@ abstract class CommonObject print ''; } print ''; - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''; } print ''; @@ -5238,7 +5261,7 @@ abstract class CommonObject $this->tpl['total_ht'] = price($line->total_ht); $this->tpl['multicurrency_price'] = price($line->multicurrency_subprice); $this->tpl['qty'] = (($line->info_bits & 2) != 2) ? $line->qty : ' '; - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $this->tpl['unit'] = $langs->transnoentities($line->getLabelOfUnit('long')); } $this->tpl['remise_percent'] = (($line->info_bits & 2) != 2) ? vatrate($line->remise_percent, true) : ' '; @@ -5751,6 +5774,9 @@ abstract class CommonObject } // TODO Ad here a scan into table llx_overwrite_default with a filter on $this->element and $fieldname + // store content into $conf->cache['overwrite_default'] + + return ''; } @@ -6442,9 +6468,9 @@ abstract class CommonObject return -1; } elseif ($value == '') { $new_array_languages[$key] = null; + } else { + $new_array_languages[$key] = $value; } - //dol_syslog("double value"." sur ".$attributeLabel."(".$value." is '".$attributeType."')", LOG_DEBUG); - $new_array_languages[$key] = $value; break; /*case 'select': // Not required, we chosed value='0' for undefined values if ($value=='-1') @@ -7807,7 +7833,7 @@ abstract class CommonObject * clear validation message result for a field * * @param string $fieldKey Key of attribute to clear - * @return null + * @return void */ public function clearFieldError($fieldKey) { @@ -7820,12 +7846,14 @@ abstract class CommonObject * * @param string $fieldKey Key of attribute * @param string $msg the field error message - * @return null + * @return void */ public function setFieldError($fieldKey, $msg = '') { global $langs; - if (empty($msg)) { $msg = $langs->trans("UnknowError"); } + if (empty($msg)) { + $msg = $langs->trans("UnknowError"); + } $this->error = $this->validateFieldsErrors[$fieldKey] = $msg; } @@ -8431,19 +8459,19 @@ abstract class CommonObject * This function is meant to be called from replaceThirdparty with the appropriate tables * Column name fk_soc MUST be used to identify thirdparties * - * @param DoliDB $db Database handler + * @param DoliDB $dbs Database handler * @param int $origin_id Old thirdparty id (the thirdparty to delete) * @param int $dest_id New thirdparty id (the thirdparty that will received element of the other) * @param string[] $tables Tables that need to be changed * @param int $ignoreerrors Ignore errors. Return true even if errors. We need this when replacement can fails like for categories (categorie of old thirdparty may already exists on new one) * @return bool True if success, False if error */ - public static function commonReplaceThirdparty(DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors = 0) + public static function commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors = 0) { foreach ($tables as $table) { - $sql = 'UPDATE '.$db->prefix().$table.' SET fk_soc = '.((int) $dest_id).' WHERE fk_soc = '.((int) $origin_id); + $sql = 'UPDATE '.$dbs->prefix().$table.' SET fk_soc = '.((int) $dest_id).' WHERE fk_soc = '.((int) $origin_id); - if (!$db->query($sql)) { + if (!$dbs->query($sql)) { if ($ignoreerrors) { return true; // TODO Not enough. If there is A-B on kept thirdparty and B-C on old one, we must get A-B-C after merge. Not A-B. } @@ -8460,19 +8488,19 @@ abstract class CommonObject * This function is meant to be called from replaceProduct with the appropriate tables * Column name fk_product MUST be used to identify products * - * @param DoliDB $db Database handler + * @param DoliDB $dbs Database handler * @param int $origin_id Old product id (the product to delete) * @param int $dest_id New product id (the product that will received element of the other) * @param string[] $tables Tables that need to be changed * @param int $ignoreerrors Ignore errors. Return true even if errors. We need this when replacement can fails like for categories (categorie of old product may already exists on new one) * @return bool True if success, False if error */ - public static function commonReplaceProduct(DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors = 0) + public static function commonReplaceProduct(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors = 0) { foreach ($tables as $table) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$table.' SET fk_product = '.((int) $dest_id).' WHERE fk_product = '.((int) $origin_id); - if (!$db->query($sql)) { + if (!$dbs->query($sql)) { if ($ignoreerrors) { return true; // TODO Not enough. If there is A-B on kept product and B-C on old one, we must get A-B-C after merge. Not A-B. } @@ -9600,6 +9628,12 @@ abstract class CommonObject } } + // Delete linked object + $res = $this->deleteObjectLinked(); + if ($res < 0) { + $error++; + } + if (!$error && !empty($this->isextrafieldmanaged)) { $result = $this->deleteExtraFields(); if ($result < 0) { @@ -9723,23 +9757,24 @@ abstract class CommonObject $tmpforobjectclass = get_class($this); $tmpforobjectlineclass = ucfirst($tmpforobjectclass).'Line'; + $this->db->begin(); + // Call trigger $result = $this->call_trigger('LINE'.strtoupper($tmpforobjectclass).'_DELETE', $user); if ($result < 0) { - return -1; + $error++; } // End call triggers - $this->db->begin(); + if (empty($error)) { + $sql = "DELETE FROM ".$this->db->prefix().$this->table_element_line; + $sql .= " WHERE rowid = ".((int) $idline); - $sql = "DELETE FROM ".$this->db->prefix().$this->table_element_line; - $sql .= " WHERE rowid = ".((int) $idline); - - dol_syslog(get_class($this)."::deleteLineCommon", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { - $this->error = "Error ".$this->db->lasterror(); - $error++; + $resql = $this->db->query($sql); + if (!$resql) { + $this->error = "Error ".$this->db->lasterror(); + $error++; + } } if (empty($error)) { @@ -9935,7 +9970,7 @@ abstract class CommonObject * @param int[]|int $categories Category ID or array of Categories IDs * @param string $type_categ Category type ('customer', 'supplier', 'website_page', ...) definied into const class Categorie type * @param boolean $remove_existing True: Remove existings categories from Object if not supplies by $categories, False: let them - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ public function setCategoriesCommon($categories, $type_categ = '', $remove_existing = true) { diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index 972ab7e4476..b116519ad53 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -166,4 +166,37 @@ abstract class CommonObjectLine extends CommonObject { return 0; } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + //$return .= ''; // Can be image + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : '').''; + if (property_exists($this, 'date_delivery')) { + $return .= '
'.dol_print_date($this->db->jdate($this->date_delivery), "dayhour").''; + } + if (property_exists($this, 'town') && !empty($this->town)) { + $return .= '
'.$langs->trans("Town").''; + $return .= ' : '.$this->town.''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/core/class/commonorder.class.php b/htdocs/core/class/commonorder.class.php index 966d7963d7c..9002d50ed39 100644 --- a/htdocs/core/class/commonorder.class.php +++ b/htdocs/core/class/commonorder.class.php @@ -32,6 +32,40 @@ abstract class CommonOrder extends CommonObject { use CommonIncoterm; + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $langs, $conf; + + $return = '
'; + $return .= '
'; + $return .= '
'; + $return .= img_picto('', 'order'); + $return .= '
'; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + + if (property_exists($this, 'thirdparty') && is_object($this->thirdparty)) { + $return .= '
'.$this->thirdparty->getNomUrl(1).'
'; + } + if (property_exists($this, 'total_ht')) { + $return .= '
'.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency).' '.$langs->trans('HT').'
'; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } + /** * @var string code */ diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 279ccded71c..74d8b089223 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -133,6 +133,7 @@ class Conf 'barcode' => array(), 'models' => array(), 'societe' => array(), + 'member' => array(), 'hooks' => array(), 'dir' => array(), 'syslog' => array() @@ -145,22 +146,22 @@ class Conf $this->expedition_bon = new stdClass(); $this->delivery_note = new stdClass(); $this->fournisseur = new stdClass(); - $this->product = new stdClass(); - $this->service = new stdClass(); - $this->contrat = new stdClass(); - $this->actions = new stdClass(); - $this->agenda = new stdClass(); + $this->product = new stdClass(); + $this->service = new stdClass(); + $this->contrat = new stdClass(); + $this->actions = new stdClass(); + $this->agenda = new stdClass(); $this->commande = new stdClass(); $this->propal = new stdClass(); - $this->facture = new stdClass(); - $this->contrat = new stdClass(); + $this->facture = new stdClass(); + $this->contrat = new stdClass(); $this->user = new stdClass(); - $this->adherent = new stdClass(); + $this->adherent = new stdClass(); $this->bank = new stdClass(); - $this->notification = new stdClass(); + $this->notification = new stdClass(); $this->mailing = new stdClass(); - $this->expensereport = new stdClass(); - $this->productbatch = new stdClass(); + $this->expensereport = new stdClass(); + $this->productbatch = new stdClass(); } /** @@ -215,26 +216,26 @@ class Conf $this->expedition_bon = new stdClass(); $this->delivery_note = new stdClass(); $this->fournisseur = new stdClass(); - $this->product = new stdClass(); - $this->service = new stdClass(); - $this->contrat = new stdClass(); - $this->actions = new stdClass(); - $this->agenda = new stdClass(); + $this->product = new stdClass(); + $this->service = new stdClass(); + $this->contrat = new stdClass(); + $this->actions = new stdClass(); + $this->agenda = new stdClass(); $this->commande = new stdClass(); $this->propal = new stdClass(); - $this->facture = new stdClass(); - $this->contrat = new stdClass(); + $this->facture = new stdClass(); + $this->contrat = new stdClass(); $this->user = new stdClass(); - $this->adherent = new stdClass(); + $this->adherent = new stdClass(); $this->bank = new stdClass(); - $this->notification = new stdClass(); + $this->notification = new stdClass(); $this->mailing = new stdClass(); - $this->expensereport = new stdClass(); - $this->productbatch = new stdClass(); + $this->expensereport = new stdClass(); + $this->productbatch = new stdClass(); // Common arrays $this->cache = array(); - $this->modules = array();; + $this->modules = array(); $this->modules_parts = array( 'css' => array(), 'js' => array(), @@ -249,6 +250,7 @@ class Conf 'barcode' => array(), 'models' => array(), 'societe' => array(), + 'member' => array(), 'hooks' => array(), 'dir' => array(), 'syslog' => array(), @@ -497,9 +499,9 @@ class Conf // Exception: Some dir are not the name of module. So we keep exception here for backward compatibility. // Sous module bons d'expedition - $this->expedition_bon->enabled = (!empty($this->global->MAIN_SUBMODULE_EXPEDITION) ? $this->global->MAIN_SUBMODULE_EXPEDITION : 0); + $this->expedition_bon->enabled = (empty($this->global->MAIN_SUBMODULE_EXPEDITION) ? 0 : $this->global->MAIN_SUBMODULE_EXPEDITION); // Sub module delivery note Sous module bons de livraison - $this->delivery_note->enabled = (!empty($this->global->MAIN_SUBMODULE_DELIVERY) ? $this->global->MAIN_SUBMODULE_DELIVERY : 0); + $this->delivery_note->enabled = (empty($this->global->MAIN_SUBMODULE_DELIVERY) ? 0 : $this->global->MAIN_SUBMODULE_DELIVERY); // Module fournisseur if (!empty($this->fournisseur)) { diff --git a/htdocs/core/class/cstate.class.php b/htdocs/core/class/cstate.class.php index d67b0c25f66..e098de93bd4 100644 --- a/htdocs/core/class/cstate.class.php +++ b/htdocs/core/class/cstate.class.php @@ -117,7 +117,7 @@ class Cstate // extends CommonObject $sql .= " ".(!isset($this->rowid) ? 'NULL' : "'".$this->db->escape($this->rowid)."'").","; $sql .= " ".(!isset($this->code_departement) ? 'NULL' : "'".$this->db->escape($this->code_departement)."'").","; $sql .= " ".(!isset($this->nom) ? 'NULL' : "'".$this->db->escape($this->nom)."'").","; - $sql .= " ".(!isset($this->active) ? 'NULL' : "'".$this->db->escape($this->active)."'").""; + $sql .= " ".(!isset($this->active) ? 'NULL' : "'".$this->db->escape($this->active)."'"); $sql .= ")"; $this->db->begin(); @@ -208,22 +208,23 @@ class Cstate // extends CommonObject if (isset($this->code_departement)) { $this->code_departement = trim($this->code_departement); } - if (isset($this->nom)) { - $this->nom = trim($this->nom); + if (isset($this->name)) { + $this->name = trim($this->name); } if (isset($this->active)) { $this->active = trim($this->active); } - // Check parameters - // Put here code to add control on parameters values + if (empty($this->name) && !empty($this->nom)) { + $this->name = $this->nom; + } // Update request $sql = "UPDATE ".$this->db->prefix()."c_departements SET"; $sql .= " code_departement=".(isset($this->code_departement) ? "'".$this->db->escape($this->code_departement)."'" : "null").","; - $sql .= " nom=".(isset($this->nom) ? "'".$this->db->escape($this->nom)."'" : "null").","; - $sql .= " active=".(isset($this->active) ? $this->active : "null").""; + $sql .= " nom=".(isset($this->name) ? "'".$this->db->escape($this->name)."'" : "null").","; + $sql .= " active=".(isset($this->active) ? ((int) $this->active) : "null"); $sql .= " WHERE rowid=".((int) $this->id); $this->db->begin(); diff --git a/htdocs/core/class/ctypent.class.php b/htdocs/core/class/ctypent.class.php index 324bfcb36a0..3bfae75d7de 100644 --- a/htdocs/core/class/ctypent.class.php +++ b/htdocs/core/class/ctypent.class.php @@ -114,7 +114,7 @@ class Ctypent // extends CommonObject $sql .= " ".(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").","; $sql .= " ".(!isset($this->libelle) ? 'NULL' : "'".$this->db->escape($this->libelle)."'").","; $sql .= " ".(!isset($this->active) ? 'NULL' : "'".$this->db->escape($this->active)."'").","; - $sql .= " ".(!isset($this->module) ? 'NULL' : "'".$this->db->escape($this->module)."'").""; + $sql .= " ".(!isset($this->module) ? 'NULL' : "'".$this->db->escape($this->module)."'"); $sql .= ")"; $this->db->begin(); @@ -227,8 +227,8 @@ class Ctypent // extends CommonObject $sql = "UPDATE ".$this->db->prefix()."c_typent SET"; $sql .= " code=".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").","; $sql .= " libelle=".(isset($this->libelle) ? "'".$this->db->escape($this->libelle)."'" : "null").","; - $sql .= " active=".(isset($this->active) ? $this->active : "null").","; - $sql .= " module=".(isset($this->module) ? "'".$this->db->escape($this->module)."'" : "null").""; + $sql .= " active=".(isset($this->active) ? ((int) $this->active) : "null").","; + $sql .= " module=".(isset($this->module) ? "'".$this->db->escape($this->module)."'" : "null"); $sql .= " WHERE id=".$this->id; $this->db->begin(); diff --git a/htdocs/core/class/ctyperesource.class.php b/htdocs/core/class/ctyperesource.class.php index be83877098c..88f6960a9f9 100644 --- a/htdocs/core/class/ctyperesource.class.php +++ b/htdocs/core/class/ctyperesource.class.php @@ -468,8 +468,4 @@ class CtyperesourceLine public $label; public $active; - - /** - * @var mixed Sample line property 2 - */ } diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 052d5ae7e1c..9f5ea960c9a 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -419,7 +419,7 @@ class DiscountAbsolute * When discount is from a credit note used to reduce payment of an invoice, we link using rowidinvoice * * @param int $rowidline Invoice line id (To use discount into invoice lines) - * @param int $rowidinvoice Invoice id (To use discount as a credit note to reduc payment of invoice) + * @param int $rowidinvoice Invoice id (To use discount as a credit note to reduce payment of invoice) * @return int <0 if KO, >0 if OK */ public function link_to_invoice($rowidline, $rowidinvoice) diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 67f9cbcbf89..f53498fafe8 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -157,11 +157,7 @@ class DolEditor define('REQUIRE_CKEDITOR', '1'); } - if (!empty($conf->global->FCKEDITOR_SKIN)) { - $skin = $conf->global->FCKEDITOR_SKIN; - } else { - $skin = 'moono-lisa'; // default with ckeditor 4.6 : moono-lisa - } + $skin = getDolGlobalString('FCKEDITOR_SKIN', 'moono-lisa'); // default with ckeditor 4.6 : moono-lisa $pluginstodisable = 'elementspath,save,flash,div,specialchar,anchor'; if (!empty($conf->dol_optimize_smallscreen)) { @@ -183,31 +179,31 @@ class DolEditor $htmlencode_force = preg_match('/_encoded$/', $this->toolbarname) ? 'true' : 'false'; - $out .= ''."\n"; + $out .= ''."\n"; $out .= ''; } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index bc06d1517dc..7f5c2887e8b 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -837,7 +837,7 @@ class FormFile } // Show file name with link to download - $imgpreview = $this->showPreview($file, $modulepart, $relativepath, 0, $param);; + $imgpreview = $this->showPreview($file, $modulepart, $relativepath, 0, $param); $out .= ''; + + // Note + print ''; + + // Warning + print ''; + + print "\n"; + } + //} + //else + //{ + //$level--; + //} + } + + return $totalforeachline; +} + + /** * Output a task line into a pertime intput mode * @@ -1391,8 +1624,10 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr // Duration print ''; diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index 9d1401ea47a..3d380a3904a 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -42,7 +42,7 @@ function propal_prepare_head($object) $head[$h][2] = 'comm'; $h++; - if ((empty($conf->commande->enabled) && ((isModEnabled("expedition") && !empty($conf->expedition_bon->enabled) && $user->rights->expedition->lire) + if ((empty($conf->commande->enabled) && ((isModEnabled("expedition") && isModEnabled('expedition_bon') && $user->rights->expedition->lire) || (isModEnabled("expedition") && !empty($conf->delivery_note->enabled) && $user->rights->expedition->delivery->lire)))) { $langs->load("sendings"); $text = ''; diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index deff1af567c..7d88253cef2 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -367,7 +367,7 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', if ($features == 'subscription') { $features = 'adherent'; $feature2 = 'cotisation'; - }; + } if ($features == 'websitepage') { $features = 'website'; $tableandshare = 'website_page'; @@ -466,6 +466,11 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', $readok = 0; $nbko++; } + } elseif ($feature == 'payment_sc') { + if (empty($user->rights->tax->charges->lire)) { + $readok = 0; + $nbko++; + } } elseif (!empty($feature2)) { // This is for permissions on 2 levels $tmpreadok = 1; foreach ($feature2 as $subfeature) { @@ -648,6 +653,10 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', if (!$user->rights->facture->paiement) { $deleteok = 0; } + } elseif ($feature == 'payment_sc') { + if (!$user->rights->tax->charges->creer) { + $deleteok = 0; + } } elseif ($feature == 'banque') { if (empty($user->rights->banque->modifier)) { $deleteok = 0; @@ -723,7 +732,11 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', if ($mode) { return $ok ? 1 : 0; } else { - return $ok ? 1 : accessforbidden('', 1, 1, 0, $params); + if ($ok) { + return 1; + } else { + accessforbidden('', 1, 1, 0, $params); + } } } diff --git a/htdocs/core/login/functions_ldap.php b/htdocs/core/login/functions_ldap.php index faf0024d801..0db325736a6 100644 --- a/htdocs/core/login/functions_ldap.php +++ b/htdocs/core/login/functions_ldap.php @@ -61,7 +61,7 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest) $langs->loadLangs(array('main', 'other')); $_SESSION["dol_loginmesg"] = $langs->transnoentitiesnoconv("ErrorLDAPFunctionsAreDisabledOnThisPHP").' '.$langs->transnoentitiesnoconv("TryAnotherConnectionMode"); - return; + return ''; } if ($usertotest) { diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index e6fc16a62d6..267f4f8e370 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -178,6 +178,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->commande->enabled && $leftmenu=="orders"', __HANDLER__, 'left', 1207__+MAX_llx_menu__, 'commercial', '', 1202__+MAX_llx_menu__, '/commande/list.php?mainmenu=commercial&leftmenu=orders&search_status=4', 'StatusOrderProcessed', 1, 'orders', '$user->rights->commande->lire', '', 2, 6, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->commande->enabled && $leftmenu=="orders"', __HANDLER__, 'left', 1208__+MAX_llx_menu__, 'commercial', '', 1202__+MAX_llx_menu__, '/commande/list.php?mainmenu=commercial&leftmenu=orders&search_status=-1', 'StatusOrderCanceledShort', 1, 'orders', '$user->rights->commande->lire', '', 2, 7, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->commande->enabled', __HANDLER__, 'left', 1209__+MAX_llx_menu__, 'commercial', '', 1200__+MAX_llx_menu__, '/commande/stats/index.php?mainmenu=commercial&leftmenu=orders', 'Statistics', 1, 'orders', '$user->rights->commande->lire', '', 2, 4, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->commande->enabled && $conf->global->MAIN_FEATURES_LEVEL >= 2 && empty($user->socid)', __HANDLER__, 'left', 1210__+MAX_llx_menu__, 'commercial', '', 1200__+MAX_llx_menu__, '/commande/list_det.php?mainmenu=commercial&leftmenu=orders', 'ListOrderLigne', 1, 'orders', '$user->rights->commande->lire', '', 2, 1, __ENTITY__); -- Commercial - Supplier's proposals insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->supplier_proposal->enabled', __HANDLER__, 'left', 1650__+MAX_llx_menu__, 'commercial', 'propals_supplier', 3__+MAX_llx_menu__, '/supplier_proposal/index.php?leftmenu=propals_supplier', 'SupplierProposalsShort', 0, 'supplier_proposal', '$user->rights->supplier_proposal->lire', '', 2, 4, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 398aa6421a7..a671ea31756 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1337,6 +1337,9 @@ function get_left_menu_commercial($mainmenu, &$newmenu, $usemenuhider = 1, $left //$newmenu->add("/commande/list.php?leftmenu=orders&search_status=4", $langs->trans("StatusOrderProcessed"), 2, $user->hasRight('commande', 'lire')); $newmenu->add("/commande/list.php?leftmenu=orders&search_status=-1", $langs->trans("StatusOrderCanceledShort"), 2, $user->hasRight('commande', 'lire')); } + if ($conf->global->MAIN_FEATURES_LEVEL >= 2 && empty($user->socid)) { + $newmenu->add("/commande/list_det.php?leftmenu=orders", $langs->trans("ListOrderLigne"), 1, $user->hasRight('commande', 'lire')); + } $newmenu->add("/commande/stats/index.php?leftmenu=orders", $langs->trans("Statistics"), 1, $user->hasRight('commande', 'lire')); } @@ -1622,7 +1625,6 @@ function get_left_menu_accountancy($mainmenu, &$newmenu, $usemenuhider = 1, $lef $newmenu->add("/accountancy/admin/accountmodel.php?id=31&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Pcg_version"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_chartmodel', 40); $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_chart', 41); $newmenu->add("/accountancy/admin/subaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("ChartOfSubaccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_chart', 41); - $newmenu->add("/accountancy/admin/categories_list.php?id=32&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingCategory"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_chart', 50); $newmenu->add("/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDefaultAccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_default', 60); if (isModEnabled('banque')) { $newmenu->add("/compta/bank/list.php?mainmenu=accountancy&leftmenu=accountancy_admin&search_status=-1", $langs->trans("MenuBankAccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_bank', 70); @@ -1640,6 +1642,7 @@ function get_left_menu_accountancy($mainmenu, &$newmenu, $usemenuhider = 1, $lef if ($conf->global->MAIN_FEATURES_LEVEL > 1) { $newmenu->add("/accountancy/admin/closure.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuClosureAccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_closure', 120); } + $newmenu->add("/accountancy/admin/categories_list.php?id=32&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingCategory"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_chart', 125); $newmenu->add("/accountancy/admin/export.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("ExportOptions"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_export', 130); } @@ -2061,7 +2064,7 @@ function get_left_menu_products($mainmenu, &$newmenu, $usemenuhider = 1, $leftme if (isModEnabled('supplier_order')) { $newmenu->add("/product/stock/replenish.php", $langs->trans("Replenishment"), 1, $user->hasRight('stock', 'mouvement', 'creer') && $user->hasRight('fournisseur', 'lire')); } - $newmenu->add("/product/stock/stockatdate.php", $langs->trans("StockAtDate"), 1, $user->hasRight('product', 'read', '', 1) && $user->hasRight('stock', 'lire')); + $newmenu->add("/product/stock/stockatdate.php", $langs->trans("StockAtDate"), 1, $user->hasRight('product', 'read') && $user->hasRight('stock', 'lire')); // Categories for warehouses if (isModEnabled('categorie')) { diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index f6ee9da7d60..afc19a12e92 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -232,10 +232,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it */ public $export_label; + public $export_icon; + public $export_permission; public $export_fields_array; public $export_TypeFields_array; // Array of key=>type where type can be 'Numeric', 'Date', 'Text', 'Boolean', 'Status', 'List:xxx:login:rowid' public $export_entities_array; + public $export_help_array; public $export_special_array; // special or computed field public $export_dependencies_array; public $export_sql_start; @@ -255,6 +258,17 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it */ public $import_label; + public $import_icon; + + public $import_entities_array; + public $import_tables_array; + public $import_fields_array; + public $import_fieldshidden_array; + public $import_convertvalue_array; + public $import_regex_array; + public $import_examplevalues_array; + public $import_updatekeys_array; + /** * @var string Module constant name @@ -285,10 +299,10 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it public $picto; /** - * @var string[] List of config pages + * @var string[]|string List of config pages (Old modules uses a string. New one must use an array) * * Name of php pages stored into module/admin directory, used to setup module. - * e.g.: "admin.php@module" + * e.g.: array("setup.php@mymodule") */ public $config_page_url; @@ -447,7 +461,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it // Add current entity id $sql = str_replace('__ENTITY__', $conf->entity, $sql); - dol_syslog(get_class($this)."::_init ignoreerror=".$ignoreerror."", LOG_DEBUG); + dol_syslog(get_class($this)."::_init ignoreerror=".$ignoreerror, LOG_DEBUG); $result = $this->db->query($sql, $ignoreerror); if (!$result) { if (!$ignoreerror) { @@ -1313,7 +1327,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (box_id, position, box_order, fk_user, entity)"; $sql .= " VALUES (".((int) $lastid).", ".((int) $key2).", '0', 0, ".((int) $conf->entity).")"; - dol_syslog(get_class($this)."::insert_boxes onto page ".$key2."=".$val2."", LOG_DEBUG); + dol_syslog(get_class($this)."::insert_boxes onto page ".$key2."=".$val2, LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { $err++; diff --git a/htdocs/core/modules/action/modules_action.php b/htdocs/core/modules/action/modules_action.php index b496e32f5e1..1681d1f5100 100644 --- a/htdocs/core/modules/action/modules_action.php +++ b/htdocs/core/modules/action/modules_action.php @@ -44,8 +44,6 @@ abstract class ModeleAction extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'action'; $list = array(); diff --git a/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php b/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php index 8be86dda944..ba4f39919bf 100644 --- a/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php +++ b/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php @@ -262,7 +262,7 @@ class doc_generic_asset_odt extends ModelePDFAsset if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile = basename($srctemplatepath); - $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile); $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); $newfiletmp = $objectref.'_'.$newfiletmp; diff --git a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php index f3bb6f57867..8ebd1051a06 100644 --- a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php +++ b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php @@ -945,13 +945,13 @@ class pdf_standard_asset extends ModelePDFAsset $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (empty($conf->global->PDF_DISABLE_MYCOMPANY_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 (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { + if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { $logo = $logodir.'/logos/'.$this->emetteur->logo; @@ -1319,7 +1319,7 @@ class pdf_standard_asset extends ModelePDFAsset ), 'border-left' => true, // add left line separator ); - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $this->cols['unit']['status'] = true; } diff --git a/htdocs/core/modules/asset/mod_asset_advanced.php b/htdocs/core/modules/asset/mod_asset_advanced.php index 34780c3423f..4c27609ff59 100644 --- a/htdocs/core/modules/asset/mod_asset_advanced.php +++ b/htdocs/core/modules/asset/mod_asset_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-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 @@ -53,7 +53,7 @@ class mod_asset_advanced extends ModeleNumRefAsset /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { @@ -63,12 +63,12 @@ class mod_asset_advanced extends ModeleNumRefAsset $form = new Form($db); - $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; - $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= '
'.$langs->trans('PriceUHTCurrency').''.$langs->trans('Qty').''.$langs->trans('Unit').''.$langs->trans('ReductionShort').''; if ($imgpreview) { diff --git a/htdocs/core/class/html.formmailing.class.php b/htdocs/core/class/html.formmailing.class.php index 9c74cb1203a..7ae13608e6a 100644 --- a/htdocs/core/class/html.formmailing.class.php +++ b/htdocs/core/class/html.formmailing.class.php @@ -32,18 +32,19 @@ class FormMailing extends Form */ public $errors = array(); + /** * Output a select with destinaries status * - * @param string $selectedid The selected id - * @param string $htmlname Name of controm - * @param integer $show_empty Show empty option - * @return string HTML select + * @param string $selectedid The selected id + * @param string $htmlname Name of controm + * @param integer $show_empty Show empty option + * @return string HTML select */ public function selectDestinariesStatus($selectedid = '', $htmlname = 'dest_status', $show_empty = 0) { - global $langs; + $langs->load("mails"); require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; @@ -51,12 +52,9 @@ class FormMailing extends Form $options = array(); - if ($show_empty) { - $options[-2] = ''; // Note -1 is used for error - } - $options = $options + $mailing->statut_dest; - return Form::selectarray($htmlname, $options, $selectedid, 0, 0, 0, '', 1); + // Note -1 is used for error, so we use -2 for tempty value + return Form::selectarray($htmlname, $options, $selectedid, ($show_empty ? -2 : 0), 0, 0, '', 1); } } diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index a0e74c5cdd5..e9d38796589 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -267,7 +267,7 @@ class FormProjets 'value' => $obj->ref, 'ref' => $obj->ref, 'labelx' => $labeltoshow, - 'label' => ((bool) $disabled) ? ''.$labeltoshow.'' : $labeltoshow, + 'label' => ($disabled ? ''.$labeltoshow.'' : $labeltoshow), 'disabled' => (bool) $disabled ); } diff --git a/htdocs/core/class/html.formpropal.class.php b/htdocs/core/class/html.formpropal.class.php index e23e71a8124..894bedebe00 100644 --- a/htdocs/core/class/html.formpropal.class.php +++ b/htdocs/core/class/html.formpropal.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2022 Josep Lluís Amador * * 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 @@ -132,6 +133,16 @@ class FormPropal print ''; $i++; } + // Option for Signed+Billed + if ($mode == 'customer') { + if ($selected != '' && $selected == "2,4") { + print ''; + } print ''; print ajax_combobox($htmlname, array(), 0, 0, 'resolve', ($showempty < 0 ? (string) $showempty : '-1'), $morecss); diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index c57ee0c5106..60499845de0 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -339,8 +339,8 @@ class FormSetup /** * Method used to test module builder convertion to this form usage * - * @param array $params an array of arrays of params from old modulBuilder params - * @return null + * @param array $params an array of arrays of params from old modulBuilder params + * @return void */ public function addItemsFromParamsArray($params) { @@ -662,7 +662,7 @@ class FormSetupItem { global $conf; if (isset($conf->global->{$this->confKey})) { - $this->fieldValue = $conf->global->{$this->confKey}; + $this->fieldValue = getDolGlobalString($this->confKey); return true; } else { $this->fieldValue = null; @@ -683,7 +683,8 @@ class FormSetupItem /** * Save const value based on htdocs/core/actions_setmoduleoptions.inc.php - * @return int -1 if KO, 1 if OK + * + * @return int -1 if KO, 1 if OK */ public function saveConfValue() { @@ -714,10 +715,13 @@ class FormSetupItem return 1; } } + + return 0; } /** * Set an override function for saving data + * * @param callable $callBack a callable function * @return void */ @@ -1005,6 +1009,7 @@ class FormSetupItem * set the type from string : used for old module builder setup conf style conversion and tests * because this two class will quickly evolve it's important to not set directly $this->type (will be protected) so this method exist * to be sure we can manage evolution easily + * * @param string $type possible values based on old module builder setup : 'string', 'textarea', 'category:'.Categorie::TYPE_CUSTOMER', 'emailtemplate', 'thirdparty_type' * @deprecated yes this setTypeFromTypeString came deprecated because it exists only for manage setup convertion * @return bool @@ -1012,11 +1017,13 @@ class FormSetupItem public function setTypeFromTypeString($type) { $this->type = $type; + return true; } /** * Add error + * * @param array|string $errors the error text * @return null */ @@ -1034,7 +1041,9 @@ class FormSetupItem } /** - * @return bool|string Generate the output html for this item + * generateOutputField + * + * @return bool|string Generate the output html for this item */ public function generateOutputField() { diff --git a/htdocs/core/class/html.formsms.class.php b/htdocs/core/class/html.formsms.class.php index f08640c6e55..28092a72da6 100644 --- a/htdocs/core/class/html.formsms.class.php +++ b/htdocs/core/class/html.formsms.class.php @@ -250,7 +250,7 @@ function limitChars(textarea, limit, infodiv) if ($this->withtoreadonly) { print (!is_array($this->withto) && !is_numeric($this->withto)) ? $this->withto : ""; } else { - print "withto) && $this->withto != '1' ? (isset($_REQUEST["sendto"]) ?GETPOST("sendto") : $this->withto) : "+")."\">"; + print 'withto) : "+").'">'; if (!empty($this->withtosocid) && $this->withtosocid > 0) { $liste = array(); foreach ($soc->thirdparty_and_contact_phone_array() as $key => $value) { diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 3dc618c36ab..a34861e17d6 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -146,9 +146,10 @@ class FormTicket * @param string $mode Mode ('create' or 'edit') * @param int $public 1=If we show the form for the public interface * @param Contact|null $with_contact [=NULL] Contact to link to this ticket if exists + * @param string $action [=''] Action in card * @return void */ - public function showForm($withdolfichehead = 0, $mode = 'edit', $public = 0, Contact $with_contact = null) + public function showForm($withdolfichehead = 0, $mode = 'edit', $public = 0, Contact $with_contact = null, $action = '') { global $conf, $langs, $user, $hookmanager; @@ -346,7 +347,7 @@ class FormTicket print $langs->trans('SubjectAnswerToTicket').' '.$this->topic_title; } else { if (isset($this->withreadid) && $this->withreadid > 0) { - $subject = $langs->trans('SubjectAnswerToTicket').' '.$this->withreadid.' : '.$this->topic_title.''; + $subject = $langs->trans('SubjectAnswerToTicket').' '.$this->withreadid.' : '.$this->topic_title; } else { $subject = GETPOST('subject', 'alpha'); } @@ -361,7 +362,7 @@ class FormTicket print ' '; } diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index f3f28abe149..606a6640995 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -118,7 +118,7 @@ class InfoBox $sql .= " WHERE d.entity IN (0, ".$conf->entity.")"; } - dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user) ? $user->id : '')."", LOG_DEBUG); + dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user) ? $user->id : ''), LOG_DEBUG); $resql = $dbs->query($sql); if ($resql) { $num = $dbs->num_rows($resql); diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 011d8a380ef..9ad06ba137c 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -982,7 +982,7 @@ class Ldap * * @param string $filterrecord Record * @param string $attribute Attributes - * @return void + * @return array|boolean */ public function getAttributeValues($filterrecord, $attribute) { @@ -1025,7 +1025,7 @@ class Ldap * @param array $attributeArray Array of fields required. Note this array must also contains field $useridentifier (Ex: sn,userPassword) * @param int $activefilter '1' or 'user'=use field this->filter as filter instead of parameter $search, 'group'=use field this->filtergroup as filter, 'member'=use field this->filtermember as filter * @param array $attributeAsArray Array of fields wanted as an array not a string - * @return array Array of [id_record][ldap_field]=value + * @return array|int Array of [id_record][ldap_field]=value */ public function getRecords($search, $userDn, $useridentifier, $attributeArray, $activefilter = 0, $attributeAsArray = array()) { @@ -1239,10 +1239,10 @@ class Ldap /** * Load all attribute of a LDAP user * - * @param User $user User to search for. Not used if a filter is provided. - * @param string $filter Filter for search. Must start with &. - * Examples: &(objectClass=inetOrgPerson) &(objectClass=user)(objectCategory=person) &(isMemberOf=cn=Sales,ou=Groups,dc=opencsi,dc=com) - * @return int >0 if OK, <0 if KO + * @param User|string $user Not used. + * @param string $filter Filter for search. Must start with &. + * Examples: &(objectClass=inetOrgPerson) &(objectClass=user)(objectCategory=person) &(isMemberOf=cn=Sales,ou=Groups,dc=opencsi,dc=com) + * @return int >0 if OK, <0 if KO */ public function fetch($user, $filter) { @@ -1342,7 +1342,7 @@ class Ldap * UserAccountControl Flgs to more human understandable form... * * @param string $uacf UACF - * @return void + * @return array */ public function parseUACF($uacf) { @@ -1382,7 +1382,7 @@ class Ldap } //Return human friendly flags - return($retval); + return $retval; } /** @@ -1414,7 +1414,7 @@ class Ldap $retval = "UNKNOWN_TYPE_".$samtype; } - return($retval); + return $retval; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/class/lessc.class.php b/htdocs/core/class/lessc.class.php index bd2d6d020cd..0452cab45aa 100644 --- a/htdocs/core/class/lessc.class.php +++ b/htdocs/core/class/lessc.class.php @@ -703,8 +703,8 @@ class Lessc // has default value $value = $a[2]; } else { - $this->throwError("Failed to assign arg ".$a[1]); $value = null; // :( + $this->throwError("Failed to assign arg ".$a[1]); // This end function by throwing an exception } $value = $this->reduce($value); @@ -1011,6 +1011,7 @@ class Lessc if ($list[0] == "list" && isset($list[2][$idx - 1])) { return $list[2][$idx - 1]; } + return ''; } protected function lib_isnumber($value) @@ -1118,8 +1119,7 @@ class Lessc if (isset($items[0])) { return $this->lib_e($items[0]); } - $this->throwError("unrecognised input"); - return null; + $this->throwError("unrecognised input"); // This end function by throwing an exception case "string": $arg[1] = ""; return $arg; @@ -1306,6 +1306,7 @@ class Lessc if (!is_null($color = $this->coerceColor($value))) { return isset($color[4]) ? $color[4] : 1; } + return ''; } // set the alpha of the color @@ -1836,6 +1837,7 @@ class Lessc } return null; } + return null; } // make something string like into a string @@ -1931,6 +1933,8 @@ class Lessc array_unshift($strRight[2], $left); return $strRight; } + + return ''; } @@ -1954,6 +1958,8 @@ class Lessc if ($op == '+' || $op == '*') { return $this->op_color_number($op, $rgt, $lft); } + + return array(); } protected function op_color_number($op, $lft, $rgt) @@ -2756,7 +2762,7 @@ class lessc_parser // media if ($this->literal('@media')) { - if (($this->mediaQueryList($mediaQueries) || true) + if ($this->mediaQueryList($mediaQueries) && $this->literal('{') ) { $media = $this->pushSpecialBlock("media"); @@ -2770,7 +2776,7 @@ class lessc_parser if ($this->literal("@", false) && $this->keyword($dirName)) { if ($this->isDirective($dirName, $this->blockDirectives)) { - if (($this->openString("{", $dirValue, null, array(";")) || true) && + if ($this->openString("{", $dirValue, null, array(";")) && $this->literal("{") ) { $dir = $this->pushSpecialBlock("directive"); @@ -2808,7 +2814,7 @@ class lessc_parser // opening parametric mixin if ($this->tag($tag, true) && $this->argumentDef($args, $isVararg) && - ($this->guards($guards) || true) && + $this->guards($guards) && $this->literal('{') ) { $block = $this->pushBlock($this->fixTags(array($tag))); @@ -2871,8 +2877,8 @@ class lessc_parser // mixin if ($this->mixinTags($tags) && - ($this->argumentDef($argv, $isVararg) || true) && - ($this->keyword($suffix) || true) && $this->end() + $this->argumentDef($argv, $isVararg) && + $this->keyword($suffix) && $this->end() ) { $tags = $this->fixTags($tags); $this->append(array('mixin', $tags, $argv, $suffix), $s); @@ -3134,7 +3140,7 @@ class lessc_parser } // an import statement - protected function import(&$out) + protected function import(&$out, $value = '') { if (!$this->literal('@import')) { return false; @@ -3148,6 +3154,8 @@ class lessc_parser $out = array("import", $value); return true; } + + return false; } protected function mediaQueryList(&$out) @@ -3166,7 +3174,7 @@ class lessc_parser $expressions = null; $parts = array(); - if (($this->literal("only") && ($only = true) || $this->literal("not") && ($not = true) || true) && $this->keyword($mediaType)) { + if ((($this->literal("only") && ($only = true)) || ($this->literal("not") && ($not = true))) && $this->keyword($mediaType)) { $prop = array("mediaType"); if (isset($only)) { $prop[] = "only"; @@ -3205,7 +3213,7 @@ class lessc_parser $value = null; if ($this->literal("(") && $this->keyword($feature) && - ($this->literal(":") && $this->expression($value) || true) && + ($this->literal(":") && $this->expression($value)) && $this->literal(")") ) { $out = array("mediaExp", $feature); diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index caeece975f2..9544e11e075 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -647,7 +647,7 @@ class Menubase $sql .= " ORDER BY m.position, m.rowid"; //print $sql; - //dol_syslog(get_class($this)."::menuLoad mymainmenu=".$mymainmenu." myleftmenu=".$myleftmenu." type_user=".$type_user." menu_handler=".$menu_handler." tabMenu size=".count($tabMenu)."", LOG_DEBUG); + //dol_syslog(get_class($this)."::menuLoad mymainmenu=".$mymainmenu." myleftmenu=".$myleftmenu." type_user=".$type_user." menu_handler=".$menu_handler." tabMenu size=".count($tabMenu), LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $numa = $this->db->num_rows($resql); diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 2a6fdf8def7..fc562913c08 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -71,6 +71,9 @@ class Notify 'ORDER_VALIDATE', 'PROPAL_VALIDATE', 'PROPAL_CLOSE_SIGNED', + 'PROPAL_CLOSE_SIGNED_WEB', + 'PROPAL_CLOSE_REFUSED', + 'PROPAL_CLOSE_REFUSED_WEB', 'FICHINTER_VALIDATE', 'FICHINTER_ADD_CONTACT', 'ORDER_SUPPLIER_VALIDATE', @@ -222,7 +225,7 @@ class Notify $sql .= " AND s.rowid = ".((int) $socid); } - dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG); + dol_syslog(__METHOD__." ".$notifcode.", ".$socid, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -260,7 +263,7 @@ class Notify $sql .= " AND c.rowid = ".((int) $userid); } - dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG); + dol_syslog(__METHOD__." ".$notifcode.", ".$socid, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -502,6 +505,20 @@ class Notify $labeltouse = $conf->global->PROPAL_VALIDATE_TEMPLATE; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextProposalValidated", $link); break; + case 'PROPAL_CLOSE_REFUSED': + $link = ''.$newref.''; + $dir_output = $conf->propal->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object, 'propal'); + $object_type = 'propal'; + $labeltouse = $conf->global->PROPAL_CLOSE_REFUSED_TEMPLATE; + $mesg = $outputlangs->transnoentitiesnoconv("EMailTextProposalClosedRefused", $link); + break; + case 'PROPAL_CLOSE_REFUSED_WEB': + $link = ''.$newref.''; + $dir_output = $conf->propal->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object, 'propal'); + $object_type = 'propal'; + $labeltouse = $conf->global->PROPAL_CLOSE_REFUSED_TEMPLATE; + $mesg = $outputlangs->transnoentitiesnoconv("EMailTextProposalClosedRefusedWeb", $link); + break; case 'PROPAL_CLOSE_SIGNED': $link = ''.$newref.''; $dir_output = $conf->propal->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object, 'propal'); @@ -509,6 +526,13 @@ class Notify $labeltouse = $conf->global->PROPAL_CLOSE_SIGNED_TEMPLATE; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextProposalClosedSigned", $link); break; + case 'PROPAL_CLOSE_SIGNED_WEB': + $link = ''.$newref.''; + $dir_output = $conf->propal->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object, 'propal'); + $object_type = 'propal'; + $labeltouse = $conf->global->PROPAL_CLOSE_SIGNED_TEMPLATE; + $mesg = $outputlangs->transnoentitiesnoconv("EMailTextProposalClosedSigned", $link); + break; case 'FICHINTER_ADD_CONTACT': $link = ''.$newref.''; $dir_output = $conf->ficheinter->dir_output; @@ -634,6 +658,11 @@ class Notify $reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { + if (!empty($hookmanager->resArray['files'])) { + $filename_list = $hookmanager->resArray['files']['file']; + $mimetype_list = $hookmanager->resArray['files']['mimefile']; + $mimefilename_list = $hookmanager->resArray['files']['filename']; + } if (!empty($hookmanager->resArray['subject'])) { $subject .= $hookmanager->resArray['subject']; } @@ -877,6 +906,11 @@ class Notify $parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list); $reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { + if (!empty($hookmanager->resArray['files'])) { + $filename_list = $hookmanager->resArray['files']['file']; + $mimetype_list = $hookmanager->resArray['files']['mimefile']; + $mimefilename_list = $hookmanager->resArray['files']['filename']; + } if (!empty($hookmanager->resArray['subject'])) { $subject .= $hookmanager->resArray['subject']; } diff --git a/htdocs/core/class/openid.class.php b/htdocs/core/class/openid.class.php index 79cf9137a99..7198f532358 100644 --- a/htdocs/core/class/openid.class.php +++ b/htdocs/core/class/openid.class.php @@ -178,7 +178,7 @@ class SimpleOpenID /** * SetOpenIDServer * - * @return void + * @return array */ public function GetError() { @@ -225,7 +225,7 @@ class SimpleOpenID * splitResponse * * @param string $response Server - * @return void + * @return array */ public function splitResponse($response) { diff --git a/htdocs/core/class/rssparser.class.php b/htdocs/core/class/rssparser.class.php index 66e9241d9f5..da3257b09c9 100644 --- a/htdocs/core/class/rssparser.class.php +++ b/htdocs/core/class/rssparser.class.php @@ -175,7 +175,7 @@ class RssParser /** * getItems * - * @return string + * @return array */ public function getItems() { @@ -801,8 +801,8 @@ class RssParser /** * Function to convert an XML object into an array * - * @param SimpleXMLElement $xml Xml - * @return void + * @param SimpleXMLElement $xml Xml + * @return array|string */ function xml2php($xml) { diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index 990bdaf107e..c8dbca747b9 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -55,7 +55,7 @@ abstract class Stats global $conf, $user, $langs; if ($startyear > $endyear) { - return -1; + return array(); } $datay = array(); @@ -156,7 +156,7 @@ abstract class Stats global $conf, $user, $langs; if ($startyear > $endyear) { - return -1; + return array(); } $datay = array(); @@ -251,7 +251,7 @@ abstract class Stats public function getAverageByMonthWithPrevYear($endyear, $startyear) { if ($startyear > $endyear) { - return -1; + return array(); } $datay = array(); @@ -359,7 +359,7 @@ abstract class Stats // phpcs:enable $result = array(); - dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG); + dol_syslog(get_class($this).'::'.__FUNCTION__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -388,7 +388,7 @@ abstract class Stats // phpcs:enable $result = array(); - dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG); + dol_syslog(get_class($this).'::'.__FUNCTION__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -442,7 +442,7 @@ abstract class Stats $result = array(); $res = array(); - dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG); + dol_syslog(get_class($this).'::'.__FUNCTION__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -499,7 +499,7 @@ abstract class Stats $result = array(); $res = array(); - dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG); + dol_syslog(get_class($this).'::'.__FUNCTION__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -557,7 +557,7 @@ abstract class Stats $result = array(); $res = array(); - dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG); + dol_syslog(get_class($this).'::'.__FUNCTION__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -613,7 +613,7 @@ abstract class Stats $result = array(); - dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG); + dol_syslog(get_class($this).'::'.__FUNCTION__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 568ef7b4ace..3f2f756977d 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -834,7 +834,6 @@ class Translate 'ja'=>'ja_JP', 'lo'=>'lo_LA', 'nb'=>'nb_NO', - 'fa'=>'fa_IR', 'sq'=>'sq_AL', 'sr'=>'sr_RS', 'sv'=>'sv_SE', diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index f8096ed84e9..d58854ed9d0 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -646,12 +646,14 @@ class Utils if (!$errormsg && $keeplastnfiles > 0) { $tmpfiles = dol_dir_list($conf->admin->dir_output.'/backup', 'files', 0, '', '(\.err|\.old|\.sav)$', 'date', SORT_DESC); $i = 0; - foreach ($tmpfiles as $key => $val) { - $i++; - if ($i <= $keeplastnfiles) { - continue; + if (is_array($tmpfiles)) { + foreach ($tmpfiles as $key => $val) { + $i++; + if ($i <= $keeplastnfiles) { + continue; + } + dol_delete_file($val['fullname'], 0, 0, 0, null, false, 0); } - dol_delete_file($val['fullname'], 0, 0, 0, null, false, 0); } } @@ -1290,6 +1292,7 @@ class Utils $message = dol_escape_htmltag($langs->trans('MakeSendLocalDatabaseDumpShort')); } + $tmpfiles = array(); require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; if ($filename) { if (dol_is_file($conf->admin->dir_output.'/backup/'.$filename)) { @@ -1298,7 +1301,7 @@ class Utils } else { $tmpfiles = dol_most_recent_file($conf->admin->dir_output.'/backup', $filter); } - if ($tmpfiles) { + if ($tmpfiles && is_array($tmpfiles)) { foreach ($tmpfiles as $key => $val) { if ($key == 'fullname') { $filepath = array($val); diff --git a/htdocs/core/class/validate.class.php b/htdocs/core/class/validate.class.php index 9d8832c36ce..31cf6300aff 100644 --- a/htdocs/core/class/validate.class.php +++ b/htdocs/core/class/validate.class.php @@ -191,7 +191,7 @@ class Validate */ public function isMinLength($string, $length) { - if (!strlen($string) < $length) { + if (strlen($string) < $length) { $this->error = $this->outputLang->trans('RequireMinLength', $length); return false; } diff --git a/htdocs/core/class/vcard.class.php b/htdocs/core/class/vcard.class.php index dbe505a894b..8a62c0aea5e 100644 --- a/htdocs/core/class/vcard.class.php +++ b/htdocs/core/class/vcard.class.php @@ -100,14 +100,14 @@ class vCard /** * @var string encoding */ - public $encoding = "ISO-8859-1;ENCODING=QUOTED-PRINTABLE"; + public $encoding = "ENCODING=QUOTED-PRINTABLE"; /** * mise en forme du numero de telephone * * @param int $number numero de telephone - * @param string $type Type + * @param string $type Type ('cell') * @return void */ public function setPhoneNumber($number, $type = "") @@ -117,22 +117,22 @@ class vCard if ($type != "") { $key .= ";".$type; } - $key .= ";CHARSET=".$this->encoding; - $this->properties[$key] = encode($number); + $key .= ";".$this->encoding; + $this->properties[$key] = 'VALUE=uri:tel:'.encode($number); } /** * mise en forme de la photo * warning NON TESTE ! * - * @param string $type Type + * @param string $type Type 'image/gif' * @param string $photo Photo * @return void */ public function setPhoto($type, $photo) { // $type = "GIF" | "JPEG" - $this->properties["PHOTO;TYPE=$type;ENCODING=BASE64"] = base64_encode($photo); + $this->properties["PHOTO;MEDIATYPE=$type;ENCODING=BASE64"] = base64_encode($photo); } /** @@ -143,7 +143,7 @@ class vCard */ public function setFormattedName($name) { - $this->properties["FN;CHARSET=".$this->encoding] = encode($name); + $this->properties["FN;".$this->encoding] = encode($name); } /** @@ -158,7 +158,7 @@ class vCard */ public function setName($family = "", $first = "", $additional = "", $prefix = "", $suffix = "") { - $this->properties["N;CHARSET=".$this->encoding] = encode($family).";".encode($first).";".encode($additional).";".encode($prefix).";".encode($suffix); + $this->properties["N;".$this->encoding] = encode($family).";".encode($first).";".encode($additional).";".encode($prefix).";".encode($suffix); $this->filename = "$first%20$family.vcf"; if (empty($this->properties["FN"])) { $this->setFormattedName(trim("$prefix $first $additional $family $suffix")); @@ -188,19 +188,23 @@ class vCard * @param string $zip Zip * @param string $country Country * @param string $type Type + * @param string $label Label * @return void */ - public function setAddress($postoffice = "", $extended = "", $street = "", $city = "", $region = "", $zip = "", $country = "", $type = "HOME;POSTAL") + public function setAddress($postoffice = "", $extended = "", $street = "", $city = "", $region = "", $zip = "", $country = "", $type = "HOME", $label = '') { // $type may be DOM | INTL | POSTAL | PARCEL | HOME | WORK or any combination of these: e.g. "WORK;PARCEL;POSTAL" $key = "ADR"; if ($type != "") { $key .= ";".$type; } - $key .= ";CHARSET=".$this->encoding; + if ($label != "") { + $key .= ';LABEL="'.encode($label).'"'; + } + $key .= ";".$this->encoding; $this->properties[$key] = ";".encode($extended).";".encode($street).";".encode($city).";".encode($region).";".encode($zip).";".encode($country); - //if ($this->properties["LABEL;".$type.";CHARSET=".$this->encoding] == '') { + //if ($this->properties["LABEL;".$type.";".$this->encoding] == '') { //$this->setLabel($postoffice, $extended, $street, $city, $region, $zip, $country, $type); //} } @@ -218,7 +222,7 @@ class vCard * @param string $type Type * @return void */ - public function setLabel($postoffice = "", $extended = "", $street = "", $city = "", $region = "", $zip = "", $country = "", $type = "HOME;POSTAL") + public function setLabel($postoffice = "", $extended = "", $street = "", $city = "", $region = "", $zip = "", $country = "", $type = "HOME") { $label = ""; if ($postoffice != "") { @@ -243,7 +247,7 @@ class vCard $country .= "$country\r\n"; } - $this->properties["LABEL;$type;CHARSET=".$this->encoding] = encode($label); + $this->properties["LABEL;$type;".$this->encoding] = encode($label); } /** @@ -253,7 +257,7 @@ class vCard * @param string $type (optional) The type of the e-mail (typical "PREF;INTERNET" or "INTERNET") * @return void */ - public function setEmail($address, $type = "TYPE=INTERNET;PREF") + public function setEmail($address, $type = "") { $key = "EMAIL"; if ($type != "") { @@ -270,7 +274,7 @@ class vCard */ public function setNote($note) { - $this->properties["NOTE;CHARSET=".$this->encoding] = encode($note); + $this->properties["NOTE;".$this->encoding] = encode($note); } /** @@ -281,7 +285,7 @@ class vCard */ public function setTitle($title) { - $this->properties["TITLE;CHARSET=".$this->encoding] = encode($title); + $this->properties["TITLE;".$this->encoding] = encode($title); } @@ -293,7 +297,7 @@ class vCard */ public function setOrg($org) { - $this->properties["ORG;CHARSET=".$this->encoding] = encode($org); + $this->properties["ORG;".$this->encoding] = encode($org); } @@ -305,7 +309,7 @@ class vCard */ public function setProdId($prodid) { - $this->properties["PRODID;CHARSET=".$this->encoding] = encode($prodid); + $this->properties["PRODID;".$this->encoding] = encode($prodid); } @@ -317,7 +321,7 @@ class vCard */ public function setUID($uid) { - $this->properties["UID;CHARSET=".$this->encoding] = encode($uid); + $this->properties["UID;".$this->encoding] = encode($uid); } @@ -346,13 +350,13 @@ class vCard public function getVCard() { $text = "BEGIN:VCARD\r\n"; - $text .= "VERSION:3.0\r\n"; + $text .= "VERSION:4.0\r\n"; // With V4, all encoding are UTF-8 //$text.= "VERSION:2.1\r\n"; foreach ($this->properties as $key => $value) { - $text .= "$key:$value\r\n"; + $text .= $key.":".$value."\r\n"; } $text .= "REV:".date("Y-m-d")."T".date("H:i:s")."Z\r\n"; - $text .= "MAILER: Dolibarr\r\n"; + //$text .= "MAILER: Dolibarr\r\n"; $text .= "END:VCARD\r\n"; return $text; } @@ -367,6 +371,97 @@ class vCard return $this->filename; } + /** + * Return a VCARD string + * + * @param Object $object Object (User, Contact) + * @param Societe $company Company + * @param Translate $langs Lang object + * @return string String + */ + public function buildVCardString($object, $company, $langs) + { + global $dolibarr_main_instance_unique_id; + + $this->setProdId('Dolibarr '.DOL_VERSION); + + $this->setUid('DOLIBARR-USERID-'.dol_trunc(md5('vcard'.$dolibarr_main_instance_unique_id), 8, 'right', 'UTF-8', 1).'-'.$object->id); + $this->setName($object->lastname, $object->firstname, "", $object->civility_code, ""); + $this->setFormattedName($object->getFullName($langs, 1)); + + $this->setPhoneNumber($object->office_phone, "TYPE=WORK,VOICE"); + $this->setPhoneNumber($object->personal_mobile, "TYPE=HOME,VOICE"); + $this->setPhoneNumber($object->user_mobile, "TYPE=CELL,VOICE"); + $this->setPhoneNumber($object->office_fax, "TYPE=WORK,FAX"); + + $country = $object->country_code ? $object->country : ''; + + $this->setAddress("", "", $object->address, $object->town, $object->state, $object->zip, $country, "TYPE=WORK"); + //$this->setLabel("", "", $object->address, $object->town, $object->state, $object->zip, $country, "TYPE=WORK"); + + $this->setEmail($object->email, "TYPE=WORK"); + $this->setNote($object->note_public); + $this->setTitle($object->job); + + // For user, type=home + // For contact, this is not defined + $this->setURL($object->url, "TYPE=HOME"); + + if (is_object($company)) { + $this->setURL($company->url, "TYPE=WORK"); + + if (!$object->office_phone) { + $this->setPhoneNumber($company->phone, "TYPE=WORK,VOICE"); + } + if (!$object->office_fax) { + $this->setPhoneNumber($company->fax, "TYPE=WORK,FAX"); + } + if (!$object->zip) { + $this->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK"); + } + + // when company e-mail is empty, use only user e-mail + if (empty(trim($company->email))) { + // was set before, don't set twice + } elseif (empty(trim($object->email))) { + // when user e-mail is empty, use only company e-mail + $this->setEmail($company->email, "TYPE=WORK"); + } else { + $tmpuser2 = explode("@", trim($object->email)); + $tmpcompany = explode("@", trim($company->email)); + + if (strtolower(end($tmpuser2)) == strtolower(end($tmpcompany))) { + // when e-mail domain of user and company are the same, use user e-mail at first (and company e-mail at second) + $this->setEmail($object->email, "TYPE=WORK"); + + // support by Microsoft Outlook (2019 and possible earlier) + $this->setEmail($company->email, ''); + } else { + // when e-mail of user and company complete different use company e-mail at first (and user e-mail at second) + $this->setEmail($company->email, "TYPE=WORK"); + + // support by Microsoft Outlook (2019 and possible earlier) + $this->setEmail($object->email, ''); + } + } + + // Si user lie a un tiers non de type "particulier" + if ($company->typent_code != 'TE_PRIVATE') { + $this->setOrg($company->name); + } + } + + // Personal informations + $this->setPhoneNumber($object->personal_mobile, "TYPE=HOME,VOICE"); + if ($object->birth) { + $this->setBirthday($object->birth); + } + + // Return VCard string + return $this->getVCard(); + } + + /* Example from Microsoft Outlook 2019 BEGIN:VCARD diff --git a/htdocs/core/db/Database.interface.php b/htdocs/core/db/Database.interface.php index eda21d3cd95..180f928eac0 100644 --- a/htdocs/core/db/Database.interface.php +++ b/htdocs/core/db/Database.interface.php @@ -173,20 +173,11 @@ interface Database /** * Escape a string to insert data * - * @param string $stringtoencode String to escape - * @return string String escaped + * @param string $stringtoencode String to escape + * @return string String escaped */ public function escape($stringtoencode); - /** - * Escape a string to insert data - * - * @param string $stringtoencode String to escape - * @return string String escaped - * @deprecated - */ - public function escapeunderscore($stringtoencode); - /** * Escape a string to insert data into a like * diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index e2659e224a4..30b3ea76975 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/db/Database.interface.php'; */ abstract class DoliDB implements Database { - /** @var bool|resource|SQLite3|PgSql\connection Database handler */ + /** @var bool|resource|mysqli|SQLite3|PgSql\connection Database handler */ public $db; /** @var string Database type */ public $type; @@ -37,8 +37,10 @@ abstract class DoliDB implements Database public $forcecharset = 'utf8'; /** @var string Collate used to force collate when creating database */ public $forcecollate = 'utf8_unicode_ci'; + /** @var resource Resultset of last query */ private $_results; + /** @var bool true if connected, else false */ public $connected; /** @var bool true if database selected, else false */ @@ -73,7 +75,8 @@ abstract class DoliDB implements Database /** - * Return the DB prefix + * Return the DB prefix found into prefix_db (if it was set manually by doing $dbhandler->prefix_db=...). + * Otherwise return MAIN_DB_PREFIX (common use). * * @return string The DB prefix */ diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 9393f10489f..d34aca48ed9 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -36,10 +36,12 @@ class DoliDBMysqli extends DoliDB public $db; //! Database type public $type = 'mysqli'; + //! Database label const LABEL = 'MySQL or MariaDB'; //! Version min database const VERSIONMIN = '5.0.3'; + /** @var bool|mysqli_result Resultset of last query */ private $_results; @@ -474,18 +476,6 @@ class DoliDBMysqli extends DoliDB return $this->db->real_escape_string((string) $stringtoencode); } - /** - * Escape a string to insert data - * - * @param string $stringtoencode String to escape - * @return string String escaped - * @deprecated - */ - public function escapeunderscore($stringtoencode) - { - return str_replace('_', '\_', (string) $stringtoencode); - } - /** * Escape a string to insert data into a like * diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 28ac15a43ff..069afeca4ff 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -721,18 +721,6 @@ class DoliDBPgsql extends DoliDB return pg_escape_string($stringtoencode); } - /** - * Escape a string to insert data - * - * @param string $stringtoencode String to escape - * @return string String escaped - * @deprecated - */ - public function escapeunderscore($stringtoencode) - { - return str_replace('_', '\_', (string) $stringtoencode); - } - /** * Escape a string to insert data into a like * diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php index e31eeffe457..8c10c26d464 100644 --- a/htdocs/core/db/sqlite3.class.php +++ b/htdocs/core/db/sqlite3.class.php @@ -649,18 +649,6 @@ class DoliDBSqlite3 extends DoliDB return Sqlite3::escapeString($stringtoencode); } - /** - * Escape a string to insert data - * - * @param string $stringtoencode String to escape - * @return string String escaped - * @deprecated - */ - public function escapeunderscore($stringtoencode) - { - return str_replace('_', '\_', (string) $stringtoencode); - } - /** * Escape a string to insert data into a like * diff --git a/htdocs/core/doxygen.php b/htdocs/core/doxygen.php index ac66362a89f..1e66b348ef8 100644 --- a/htdocs/core/doxygen.php +++ b/htdocs/core/doxygen.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2008-2022 Laurent Destailleur * Copyright (C) 2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -20,10 +20,10 @@ /** * \file htdocs/core/doxygen.php * \ingroup core - * \mainpage Dolibarr project + * \mainpage Dolibarr documentation of source code * * This is source documentation for Dolibarr ERP/CRM.
- * This documentation can be built or updated running the script dolibarr-doxygen-build.pl or from Eclipse with Doxygen plugin.
+ * This documentation can be built or updated running the script build/doxygen/dolibarr-doxygen-build.pl or from Eclipse with Doxygen plugin.
*
* Dolibarr official web site: www.dolibarr.org
*
diff --git a/htdocs/core/filemanagerdol/browser/default/frmfolders.php b/htdocs/core/filemanagerdol/browser/default/frmfolders.php index d8d1fae179a..a1b03693324 100644 --- a/htdocs/core/filemanagerdol/browser/default/frmfolders.php +++ b/htdocs/core/filemanagerdol/browser/default/frmfolders.php @@ -53,7 +53,7 @@ top_httphead(); --> diff --git a/htdocs/core/filemanagerdol/connectors/php/connector.lib.php b/htdocs/core/filemanagerdol/connectors/php/connector.lib.php index 608c2ba4cd6..75c4d1e3e08 100644 --- a/htdocs/core/filemanagerdol/connectors/php/connector.lib.php +++ b/htdocs/core/filemanagerdol/connectors/php/connector.lib.php @@ -343,7 +343,8 @@ function FileUpload($resourceType, $currentFolder, $sCommand, $CKEcallback = '') include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; //var_dump($sFileName); var_dump(image_format_supported($sFileName));exit; - $isImageValid = (image_format_supported($sFileName) >= 0 ? true : false); + $imgsupported = image_format_supported($sFileName); + $isImageValid = ($imgsupported >= 0 ? true : false); if (!$isImageValid) { $sErrorNumber = '202'; } @@ -387,7 +388,7 @@ function FileUpload($resourceType, $currentFolder, $sCommand, $CKEcallback = '') if (file_exists($sFilePath)) { //previous checks failed, try once again - if (isset($isImageValid) && $isImageValid === -1 && IsImageValid($sFilePath, $sExtension) === false) { + if (isset($isImageValid) && $imgsupported === -1 && IsImageValid($sFilePath, $sExtension) === false) { dol_syslog("connector.lib.php IsImageValid is ko"); @unlink($sFilePath); $sErrorNumber = '202'; diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php index 3310554e530..c037b86a7b9 100644 --- a/htdocs/core/js/lib_foot.js.php +++ b/htdocs/core/js/lib_foot.js.php @@ -110,6 +110,7 @@ if (!defined('JS_JQUERY_DISABLE_DROPDOWN')) { console.log("toggle dropdown dt a"); //$(this).parent().parent().find(\'dd ul\').slideToggle(\'fast\'); + $(".ulselectedfields").removeClass("open"); $(this).parent().parent().find(\'dd ul\').toggleClass("open"); if ($(this).parent().parent().find(\'dd ul\').hasClass("open")) { diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index cc871de9709..cacd22269ad 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -194,9 +194,10 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen $("#'.$htmlnamejquery.'").attr("data-tvatx", ui.item.tva_tx); $("#'.$htmlnamejquery.'").attr("data-default-vat-code", ui.item.default_vat_code); '; - if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { $script .= ' // For customer price when PRODUIT_CUSTOMER_PRICES_BY_QTY is on + console.log("PRODUIT_CUSTOMER_PRICES_BY_QTY is on, propagate also prices by quantity into data-pbqxxx properties"); $("#'.$htmlnamejquery.'").attr("data-pbq", ui.item.pbq); $("#'.$htmlnamejquery.'").attr("data-pbqup", ui.item.price_ht); $("#'.$htmlnamejquery.'").attr("data-pbqbase", ui.item.pricebasetype); @@ -479,8 +480,11 @@ function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete = ';*/ + + print '
'; + print ''; + print ''; + /*if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); + elseif ($disabledtask) + { + $titleassigntask = $langs->trans("AssignTaskToMe"); + if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...'); + + print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); + }*/ + print '
'; - $dayWorkLoad = !empty($projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]) ? $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id] : 0; - if (!isset($totalforeachday[$preselectedday])) $totalforeachday[$preselectedday] = 0; + $dayWorkLoad = empty($projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]) ? 0 : $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]; + if (!isset($totalforeachday[$preselectedday])) { + $totalforeachday[$preselectedday] = 0; + } $totalforeachday[$preselectedday] += $dayWorkLoad; $alreadyspent = ''; @@ -2363,7 +2598,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print ''; print $projectstatic->getNomUrl(1, '', 0, '', '-', 0, -1, 'nowraponall'); if (!in_array('projectlabel', $hiddenfields)) { - print '
'.dol_trunc($objp->title, 24).''; + print '
'.dol_escape_htmltag($objp->title).''; } print '
'; + $text = $langs->trans('GenericNumRefModelDesc')."
\n"; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= '
'; $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Asset"), $langs->transnoentities("Asset")); $tooltip .= $langs->trans("GenericMaskCodes2"); @@ -77,17 +77,17 @@ class mod_asset_advanced extends ModeleNumRefAsset $tooltip .= $langs->trans("GenericMaskCodes5"); // Parametrage du prefix - $texte .= ''; - $texte .= ''; + $text .= ''; + $text .= ''; - $texte .= ''; + $text .= ''; - $texte .= ''; + $text .= ''; - $texte .= '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'   
'; - $texte .= ''; + $text .= '
'; + $text .= ''; - return $texte; + return $text; } /** @@ -102,16 +102,8 @@ class mod_asset_advanced extends ModeleNumRefAsset $object = new Asset($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'); } @@ -121,7 +113,7 @@ class mod_asset_advanced extends ModeleNumRefAsset /** * Return next free value * - * @param Object $object Object we need next value for + * @param Asset $object Object we need next value for * @return string Value if KO, <0 if KO */ public function getNextValue($object) @@ -131,7 +123,7 @@ class mod_asset_advanced extends ModeleNumRefAsset require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // We get cursor rule - $mask = getDolGlobalString('ASSET_ASSET_ADVANCED_MASK'); + $mask = getDolGlobalString('ASSET_ADVANCED_MASK'); if (!$mask) { $this->error = 'NotConfigured'; @@ -140,7 +132,7 @@ class mod_asset_advanced extends ModeleNumRefAsset $date = $object->date; - $numFinal = get_next_value($db, $mask, 'asset_asset', 'ref', '', null, $date); + $numFinal = get_next_value($db, $mask, 'asset', 'ref', '', null, $date); return $numFinal; } diff --git a/htdocs/core/modules/asset/mod_asset_standard.php b/htdocs/core/modules/asset/mod_asset_standard.php index 2e3ee3938e1..4fbf889fc9b 100644 --- a/htdocs/core/modules/asset/mod_asset_standard.php +++ b/htdocs/core/modules/asset/mod_asset_standard.php @@ -1,6 +1,7 @@ - * Copyright (C) 2005-2009 Regis Houssin +/* Copyright (C) 2005-2010 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 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 @@ -83,7 +84,8 @@ class mod_asset_standard extends ModeleNumRefAsset { global $conf, $langs, $db; - $coyymm = ''; $max = ''; + $coyymm = ''; + $max = ''; $posindice = strlen($this->prefix) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; @@ -124,7 +126,7 @@ class mod_asset_standard extends ModeleNumRefAsset // 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."asset_asset"; + $sql .= " FROM ".MAIN_DB_PREFIX."asset"; $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; if ($object->ismultientitymanaged == 1) { $sql .= " AND entity = ".$conf->entity; diff --git a/htdocs/core/modules/asset/modules_asset.php b/htdocs/core/modules/asset/modules_asset.php index f7f361a10cc..c9b64e0180f 100644 --- a/htdocs/core/modules/asset/modules_asset.php +++ b/htdocs/core/modules/asset/modules_asset.php @@ -84,8 +84,6 @@ abstract class ModelePDFAsset extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'asset'; $list = array(); @@ -121,7 +119,7 @@ abstract class ModeleNumRefAsset /** * Returns the default description of the numbering template * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index 2995321eeb5..e296663f39a 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -526,7 +526,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc $tab_hl = 4; $posx = $this->marge_gauche; - $pdf->SetXY($posx, $tab_top + 0); + $pdf->SetXY($posx, $tab_top); $pdf->SetFont('', '', $default_font_size - 2); @@ -540,7 +540,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc $index = 0; // Total HT $pdf->SetFillColor(255, 255, 255); - $pdf->SetXY($posx, $tab_top + 0); + $pdf->SetXY($posx, $tab_top); $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentitiesnoconv("Signature"), 0, 'L', 1); $pdf->SetXY($posx, $tab_top + $tab_hl); diff --git a/htdocs/core/modules/bank/modules_bank.php b/htdocs/core/modules/bank/modules_bank.php index 70f6717d0c7..cfe7d406248 100644 --- a/htdocs/core/modules/bank/modules_bank.php +++ b/htdocs/core/modules/bank/modules_bank.php @@ -48,8 +48,6 @@ abstract class ModeleBankAccountDoc extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'bankaccount'; $list = array(); diff --git a/htdocs/core/modules/barcode/doc/phpbarcode.modules.php b/htdocs/core/modules/barcode/doc/phpbarcode.modules.php index 4add94ffafb..d11d052cc02 100644 --- a/htdocs/core/modules/barcode/doc/phpbarcode.modules.php +++ b/htdocs/core/modules/barcode/doc/phpbarcode.modules.php @@ -58,7 +58,7 @@ class modPhpbarcode extends ModeleBarCode /** * Return description * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { 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 bec28b941aa..ea877432c17 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 @@ -273,7 +273,7 @@ class doc_generic_bom_odt extends ModelePDFBom if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile = basename($srctemplatepath); - $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile); $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); $newfiletmp = $objectref . '_' . $newfiletmp; diff --git a/htdocs/core/modules/bom/mod_bom_advanced.php b/htdocs/core/modules/bom/mod_bom_advanced.php index 2228d643434..81c4792630f 100644 --- a/htdocs/core/modules/bom/mod_bom_advanced.php +++ b/htdocs/core/modules/bom/mod_bom_advanced.php @@ -54,7 +54,7 @@ class mod_bom_advanced extends ModeleNumRefboms /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/bom/modules_bom.php b/htdocs/core/modules/bom/modules_bom.php index 84182993756..64fc9502d26 100644 --- a/htdocs/core/modules/bom/modules_bom.php +++ b/htdocs/core/modules/bom/modules_bom.php @@ -50,8 +50,6 @@ abstract class ModelePDFBom extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'bom'; $list = array(); @@ -87,7 +85,7 @@ abstract class ModeleNumRefBoms /** * Returns the default description of the numbering template * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php b/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php index 40d63e63143..5534bf38698 100644 --- a/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php +++ b/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php @@ -48,7 +48,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/cheque/modules_chequereceipts.php b/htdocs/core/modules/cheque/modules_chequereceipts.php index e50a6877848..45e18a12734 100644 --- a/htdocs/core/modules/cheque/modules_chequereceipts.php +++ b/htdocs/core/modules/cheque/modules_chequereceipts.php @@ -54,7 +54,7 @@ abstract class ModeleNumRefChequeReceipts /** * Return the default description of numbering module * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { @@ -146,8 +146,6 @@ abstract class ModeleChequeReceipts extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'chequereceipt'; $list = array(); 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 5e94397bc91..bbace838183 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 @@ -279,7 +279,7 @@ class doc_generic_order_odt extends ModelePDFCommandes if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile = basename($srctemplatepath); - $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile); $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); $newfiletmp = $objectref . '_' . $newfiletmp; diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index e0dff278f96..6fe07506958 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -173,7 +173,7 @@ class pdf_einstein extends ModelePDFCommandes // Define position of columns $this->posxdesc = $this->marge_gauche + 1; - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $this->posxtva = 101; $this->posxup = 118; $this->posxqty = 135; @@ -237,8 +237,8 @@ class pdf_einstein extends ModelePDFCommandes $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries")); // Show Draft Watermark - if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK))) { - $this->watermark = $conf->global->COMMANDE_DRAFT_WATERMARK; + if ($object->statut == $object::STATUS_DRAFT && getDolGlobalString('COMMANDE_DRAFT_WATERMARK')) { + $this->watermark = getDolGlobalString('COMMANDE_DRAFT_WATERMARK'); } global $outputlangsbis; @@ -509,7 +509,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); // Enough for 6 chars // Unit - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); $pdf->SetXY($this->posxunit, $curY); $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L'); @@ -935,11 +935,11 @@ class pdf_einstein extends ModelePDFCommandes // Total HT $pdf->SetFillColor(255, 255, 255); - $pdf->SetXY($col1x, $tab2_top + 0); + $pdf->SetXY($col1x, $tab2_top); $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->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 + 0); + $pdf->SetXY($col2x, $tab2_top); $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1); // Show VAT by rates and total @@ -1238,7 +1238,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); } - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxunit - 1, $tab_top + 1); @@ -1304,13 +1304,13 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (empty($conf->global->PDF_DISABLE_MYCOMPANY_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 (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { + if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { $logo = $logodir.'/logos/'.$this->emetteur->logo; diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index c8196d41a63..8614238c2c7 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -221,8 +221,8 @@ class pdf_eratosthene extends ModelePDFCommandes $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries")); // Show Draft Watermark - if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK))) { - $this->watermark = $conf->global->COMMANDE_DRAFT_WATERMARK; + if ($object->statut == $object::STATUS_DRAFT && getDolGlobalString('COMMANDE_DRAFT_WATERMARK')) { + $this->watermark = getDolGlobalString('COMMANDE_DRAFT_WATERMARK'); } global $outputlangsbis; @@ -1150,10 +1150,10 @@ class pdf_eratosthene extends ModelePDFCommandes // Total HT $pdf->SetFillColor(255, 255, 255); - $pdf->SetXY($col1x, $tab2_top + 0); + $pdf->SetXY($col1x, $tab2_top); $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->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 + 0); + $pdf->SetXY($col2x, $tab2_top); $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1); // Show VAT by rates and total @@ -1471,13 +1471,13 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (empty($conf->global->PDF_DISABLE_MYCOMPANY_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 (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { + if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { $logo = $logodir.'/logos/'.$this->emetteur->logo; @@ -1866,7 +1866,7 @@ class pdf_eratosthene extends ModelePDFCommandes ), 'border-left' => true, // add left line separator ); - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $this->cols['unit']['status'] = true; } diff --git a/htdocs/core/modules/commande/mod_commande_saphir.php b/htdocs/core/modules/commande/mod_commande_saphir.php index 07dcfdced9e..b62124f7652 100644 --- a/htdocs/core/modules/commande/mod_commande_saphir.php +++ b/htdocs/core/modules/commande/mod_commande_saphir.php @@ -54,7 +54,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/commande/modules_commande.php b/htdocs/core/modules/commande/modules_commande.php index 4f3378a0683..d6ecda2b2e7 100644 --- a/htdocs/core/modules/commande/modules_commande.php +++ b/htdocs/core/modules/commande/modules_commande.php @@ -51,8 +51,6 @@ abstract class ModelePDFCommandes extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'order'; $list = array(); @@ -86,9 +84,9 @@ abstract class ModeleNumRefCommandes } /** - * Renvoie la description par defaut du modele de numerotation + * Returns the default description of the numbering pattern * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { 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 dad1ebc9122..83e8f2551f7 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 @@ -276,7 +276,7 @@ class doc_generic_contract_odt extends ModelePDFContract if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile = basename($srctemplatepath); - $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile); $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); diff --git a/htdocs/core/modules/contract/modules_contract.php b/htdocs/core/modules/contract/modules_contract.php index 8e296f626fb..577ec4be5d9 100644 --- a/htdocs/core/modules/contract/modules_contract.php +++ b/htdocs/core/modules/contract/modules_contract.php @@ -54,8 +54,6 @@ abstract class ModelePDFContract extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'contract'; $list = array(); diff --git a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php index 46a70464583..3db75e6ca9b 100644 --- a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php @@ -752,8 +752,8 @@ class pdf_storm extends ModelePDFDeliveryOrder pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); // Show Draft Watermark - if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK))) { - pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_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')); } $pdf->SetTextColor(0, 0, 60); diff --git a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php index 5936f874a1b..281dbf65026 100644 --- a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php @@ -751,8 +751,8 @@ class pdf_typhon extends ModelePDFDeliveryOrder pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); // Show Draft Watermark - if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK))) { - pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_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')); } $pdf->SetTextColor(0, 0, 60); diff --git a/htdocs/core/modules/delivery/mod_delivery_jade.php b/htdocs/core/modules/delivery/mod_delivery_jade.php index 605265fde00..d348957afd3 100644 --- a/htdocs/core/modules/delivery/mod_delivery_jade.php +++ b/htdocs/core/modules/delivery/mod_delivery_jade.php @@ -63,7 +63,7 @@ class mod_delivery_jade extends ModeleNumRefDeliveryOrder /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { @@ -174,7 +174,7 @@ class mod_delivery_jade extends ModeleNumRefDeliveryOrder * * @param Societe $objsoc Object thirdparty * @param Object $object Object livraison - * @return string Texte descriptif + * @return string Descriptive text */ public function delivery_get_num($objsoc = 0, $object = '') { diff --git a/htdocs/core/modules/delivery/mod_delivery_saphir.php b/htdocs/core/modules/delivery/mod_delivery_saphir.php index 7fc9b2e6e52..68da925e62b 100644 --- a/htdocs/core/modules/delivery/mod_delivery_saphir.php +++ b/htdocs/core/modules/delivery/mod_delivery_saphir.php @@ -58,7 +58,7 @@ class mod_delivery_saphir extends ModeleNumRefDeliveryOrder /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { @@ -162,7 +162,7 @@ class mod_delivery_saphir extends ModeleNumRefDeliveryOrder * * @param Societe $objsoc Object thirdparty * @param Object $object Objet livraison - * @return string Texte descripif + * @return string Descriptive text */ public function delivery_get_num($objsoc = 0, $object = '') { diff --git a/htdocs/core/modules/delivery/modules_delivery.php b/htdocs/core/modules/delivery/modules_delivery.php index 5bd3bd33866..9f7b6805f73 100644 --- a/htdocs/core/modules/delivery/modules_delivery.php +++ b/htdocs/core/modules/delivery/modules_delivery.php @@ -52,8 +52,6 @@ abstract class ModelePDFDeliveryOrder extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'delivery'; $list = array(); @@ -88,9 +86,9 @@ abstract class ModeleNumRefDeliveryOrder } /** - * Renvoi la description par defaut du modele de numerotation + * Returns the default description of the numbering pattern * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/dons/modules_don.php b/htdocs/core/modules/dons/modules_don.php index cd332c48fcb..ca982c61a53 100644 --- a/htdocs/core/modules/dons/modules_don.php +++ b/htdocs/core/modules/dons/modules_don.php @@ -50,8 +50,6 @@ abstract class ModeleDon extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'donation'; $list = array(); @@ -84,9 +82,9 @@ abstract class ModeleNumRefDons } /** - * Renvoi la description par defaut du modele de numerotation + * Returns the default description of the numbering pattern * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { 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 73793c5a757..f8280aab301 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 @@ -277,7 +277,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile = basename($srctemplatepath); - $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile); $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); $newfiletmp = $objectref . '_' . $newfiletmp; diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index b87298d3dd8..b2b6424f5ed 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -945,7 +945,7 @@ class pdf_espadon extends ModelePdfExpedition * @param Expedition $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output - * @return void + * @return int <0 if KO, > if OK */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { @@ -974,7 +974,7 @@ class pdf_espadon extends ModelePdfExpedition if (!empty($conf->mycompany->multidir_output[$object->entity])) { $logodir = $conf->mycompany->multidir_output[$object->entity]; } - if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { + if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { $logo = $logodir.'/logos/'.$this->emetteur->logo; @@ -1078,6 +1078,14 @@ class pdf_espadon extends ModelePdfExpedition } } + $top_shift = 0; + // Show list of linked objects + /*$current_y = $pdf->getY(); + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size); + if ($current_y < $pdf->getY()) { + $top_shift = $pdf->getY() - $current_y; + }*/ + if ($showaddress) { // Sender properties $carac_emetteur = ''; @@ -1183,6 +1191,7 @@ class pdf_espadon extends ModelePdfExpedition } $pdf->SetTextColor(0, 0, 0); + return $top_shift; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index e847dc26fec..db10c37e7e8 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -520,7 +520,7 @@ class pdf_merou extends ModelePdfExpedition * @param Expedition $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output - * @return void + * @return int <0 if KO, > if OK */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { @@ -553,7 +553,7 @@ class pdf_merou extends ModelePdfExpedition if (!empty($conf->mycompany->multidir_output[$object->entity])) { $logodir = $conf->mycompany->multidir_output[$object->entity]; } - if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { + if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { $logo = $logodir.'/logos/'.$this->emetteur->logo; @@ -700,6 +700,16 @@ class pdf_merou extends ModelePdfExpedition $widthrecbox = $blW; + $top_shift = 0; + // Show list of linked objects + /* + $current_y = $pdf->getY(); + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size); + if ($current_y < $pdf->getY()) { + $top_shift = $pdf->getY() - $current_y; + } + */ + // Show Recipient frame $pdf->SetFont('', 'B', $default_font_size - 3); $pdf->SetXY($blDestX, $Yoff - 4); @@ -717,5 +727,7 @@ class pdf_merou extends ModelePdfExpedition $pdf->SetFont('', '', $default_font_size - 3); $pdf->SetXY($blDestX, $posy); $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); + + return $top_shift; } } diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 71fb4c4c194..87dd02096e8 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -890,7 +890,7 @@ class pdf_rouget extends ModelePdfExpedition * @param Expedition $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output - * @return void + * @return int <0 if KO, > if OK */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { @@ -919,7 +919,7 @@ class pdf_rouget extends ModelePdfExpedition if (!empty($conf->mycompany->multidir_output[$object->entity])) { $logodir = $conf->mycompany->multidir_output[$object->entity]; } - if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { + if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { $logo = $logodir.'/logos/'.$this->emetteur->logo; @@ -1023,6 +1023,16 @@ class pdf_rouget extends ModelePdfExpedition } } + $top_shift = 0; + // Show list of linked objects + /* + $current_y = $pdf->getY(); + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size); + if ($current_y < $pdf->getY()) { + $top_shift = $pdf->getY() - $current_y; + } + */ + if ($showaddress) { // Sender properties $carac_emetteur = ''; @@ -1128,6 +1138,7 @@ class pdf_rouget extends ModelePdfExpedition } $pdf->SetTextColor(0, 0, 0); + return $top_shift; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore diff --git a/htdocs/core/modules/expedition/modules_expedition.php b/htdocs/core/modules/expedition/modules_expedition.php index ce210d6a958..2ca5613af48 100644 --- a/htdocs/core/modules/expedition/modules_expedition.php +++ b/htdocs/core/modules/expedition/modules_expedition.php @@ -53,8 +53,6 @@ abstract class ModelePdfExpedition extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'shipping'; $list = array(); diff --git a/htdocs/core/modules/expensereport/mod_expensereport_sand.php b/htdocs/core/modules/expensereport/mod_expensereport_sand.php index d14f17de067..920861f2b3e 100644 --- a/htdocs/core/modules/expensereport/mod_expensereport_sand.php +++ b/htdocs/core/modules/expensereport/mod_expensereport_sand.php @@ -57,7 +57,7 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/expensereport/modules_expensereport.php b/htdocs/core/modules/expensereport/modules_expensereport.php index eee2190033e..8e7718ee0d5 100644 --- a/htdocs/core/modules/expensereport/modules_expensereport.php +++ b/htdocs/core/modules/expensereport/modules_expensereport.php @@ -75,8 +75,6 @@ abstract class ModeleExpenseReport extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'expensereport'; $list = array(); diff --git a/htdocs/core/modules/export/modules_export.php b/htdocs/core/modules/export/modules_export.php index 685a4bda430..31b137f6465 100644 --- a/htdocs/core/modules/export/modules_export.php +++ b/htdocs/core/modules/export/modules_export.php @@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; /** * Parent class for export modules */ -class ModeleExports extends CommonDocGenerator // This class can't be abstract as there is instance propreties loaded by liste_modeles +class ModeleExports extends CommonDocGenerator // This class can't be abstract as there is instance propreties loaded by listOfAvailableExportFormat { /** * @var string Error code (or message) @@ -44,7 +44,6 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac public $libversion = array(); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load into memory list of available export format * @@ -52,10 +51,9 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac * @param integer $maxfilenamelength Max length of value to show * @return array List of templates (same content than array this->driverlabel) */ - public function liste_modeles($db, $maxfilenamelength = 0) + public function listOfAvailableExportFormat($db, $maxfilenamelength = 0) { - // phpcs:enable - dol_syslog(get_class($this)."::liste_modeles"); + dol_syslog(get_class($this)."::listOfAvailableExportFormat"); $dir = DOL_DOCUMENT_ROOT."/core/modules/export/"; $handle = opendir($dir); 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 0b8fa2d4621..f5dcfb86936 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 @@ -276,7 +276,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile = basename($srctemplatepath); - $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile); $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index ee4cc9b5d0d..dcbcb133729 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -132,6 +132,11 @@ class pdf_crabe extends ModelePDFFactures */ public $posxprogress; + /** + * @var int Category of operation + */ + public $categoryOfOperation = -1; // unknown by default + /** * Constructor @@ -180,7 +185,7 @@ class pdf_crabe extends ModelePDFFactures // Define position of columns $this->posxdesc = $this->marge_gauche + 1; - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $this->posxtva = 101; $this->posxup = 118; $this->posxqty = 135; @@ -402,11 +407,37 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right // Set $this->atleastonediscount if you have at least one discount + // and determine category of operation + $categoryOfOperation = 0; + $nbProduct = 0; + $nbService = 0; for ($i = 0; $i < $nblines; $i++) { if ($object->lines[$i]->remise_percent) { $this->atleastonediscount++; } + + // determine category of operation + if ($categoryOfOperation < 2) { + $lineProductType = $object->lines[$i]->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; + } + } + $this->categoryOfOperation = $categoryOfOperation; if (empty($this->atleastonediscount)) { // retrieve space not used by discount $delta = ($this->posxprogress - $this->posxdiscount); $this->posxpicture += $delta; @@ -677,7 +708,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); // Enough for 6 chars // Unit - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); $pdf->SetXY($this->posxunit, $curY); $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L'); @@ -1128,6 +1159,10 @@ class pdf_crabe extends ModelePDFFactures } $posxval = 52; + $posxend = 110; // End of x for text on left side + if ($this->page_largeur < 210) { // To work with US executive format + $posxend -= 10; + } // Show payments conditions if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) { @@ -1145,6 +1180,21 @@ class pdf_crabe extends ModelePDFFactures $posy = $pdf->GetY() + 3; // We need spaces for 2 lines payment conditions } + // Show category of operations + if (getDolGlobalInt('INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) { + $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetXY($this->marge_gauche, $posy); + $categoryOfOperationTitle = $outputlangs->transnoentities("MentionCategoryOfOperations").' : '; + $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0, 'L'); + + $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetXY($posxval, $posy); + $categoryOfOperationLabel = $outputlangs->transnoentities("MentionCategoryOfOperations" . $this->categoryOfOperation); + $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0, 'L'); + + $posy = $pdf->GetY() + 3; // for 2 lines + } + if ($object->type != 2) { // Check a payment mode is defined if (empty($object->mode_reglement_code) @@ -1347,11 +1397,11 @@ class pdf_crabe extends ModelePDFFactures // Total HT $pdf->SetFillColor(255, 255, 255); - $pdf->SetXY($col1x, $tab2_top + 0); + $pdf->SetXY($col1x, $tab2_top); $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) ? "TotalHT" : "Total").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities(empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) ? "TotalHT" : "Total") : ''), 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 + 0); + $pdf->SetXY($col2x, $tab2_top); $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0, 'R', 1); // Show VAT by rates and total @@ -1659,6 +1709,13 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFont('', '', $default_font_size - 2); if (empty($hidetop)) { + // Show category of operations + if (getDolGlobalInt('INVOICE_CATEGORY_OF_OPERATION') == 1 && $this->categoryOfOperation >= 0) { + $categoryOfOperations = $outputlangs->transnoentities("MentionCategoryOfOperations") . ' : ' . $outputlangs->transnoentities("MentionCategoryOfOperations" . $this->categoryOfOperation); + $pdf->SetXY($this->marge_gauche, $tab_top - 4); + $pdf->MultiCell(($pdf->GetStringWidth($categoryOfOperations)) + 4, 2, $categoryOfOperations); + } + $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); @@ -1710,7 +1767,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); } - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxunit - 1, $tab_top + 1); @@ -1777,13 +1834,13 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (empty($conf->global->PDF_DISABLE_MYCOMPANY_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 (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { + if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { $logo = $logodir.'/logos/'.$this->emetteur->logo; @@ -2083,7 +2140,7 @@ class pdf_crabe extends ModelePDFFactures $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, $usecontact, 'target', $object); } else { $carac_client_name_shipping=pdfBuildThirdpartyName($object->thirdparty, $outputlangs); - $carac_client_shipping=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object);; + $carac_client_shipping=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object); } if (!empty($carac_client_shipping) && (isset($object->contact->socid) && $object->contact->socid != $object->socid)) { $posy += $hautcadre; diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 1bea6b0db67..f24517d0667 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -10,6 +10,7 @@ * Copyright (C) 2017 Ferran Marcet * Copyright (C) 2018 Frédéric France * Copyright (C) 2022 Anthony Berton + * Copyright (C) 2022 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 @@ -159,6 +160,11 @@ class pdf_sponge extends ModelePDFFactures */ public $cols; + /** + * @var int Category of operation + */ + public $categoryOfOperation = -1; // unknown by default + /** * Constructor @@ -429,12 +435,37 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right // Set $this->atleastonediscount if you have at least one discount + // and determine category of operation + $categoryOfOperation = 0; + $nbProduct = 0; + $nbService = 0; for ($i = 0; $i < $nblines; $i++) { if ($object->lines[$i]->remise_percent) { $this->atleastonediscount++; } - } + // determine category of operation + if ($categoryOfOperation < 2) { + $lineProductType = $object->lines[$i]->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; + } + } + $this->categoryOfOperation = $categoryOfOperation; // Situation invoice handling if ($object->situation_cycle_ref) { @@ -1241,6 +1272,21 @@ class pdf_sponge extends ModelePDFFactures $posy = $pdf->GetY() + 3; // We need spaces for 2 lines payment conditions } + // Show category of operations + if (getDolGlobalInt('INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) { + $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetXY($this->marge_gauche, $posy); + $categoryOfOperationTitle = $outputlangs->transnoentities("MentionCategoryOfOperations").' : '; + $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0, 'L'); + + $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetXY($posxval, $posy); + $categoryOfOperationLabel = $outputlangs->transnoentities("MentionCategoryOfOperations" . $this->categoryOfOperation); + $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0, 'L'); + + $posy = $pdf->GetY() + 3; // for 2 lines + } + if ($object->type != 2) { // Check a payment mode is defined if (empty($object->mode_reglement_code) @@ -1596,9 +1642,9 @@ class pdf_sponge extends ModelePDFFactures // Show total NET before discount if (!empty($conf->global->MAIN_SHOW_AMOUNT_BEFORE_DISCOUNT)) { $pdf->SetFillColor(255, 255, 255); - $pdf->SetXY($col1x, $tab2_top + 0); + $pdf->SetXY($col1x, $tab2_top); $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHTBeforeDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHTBeforeDiscount") : ''), 0, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + 0); + $pdf->SetXY($col2x, $tab2_top); $pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise + $total_ht, 0, $outputlangs), 0, 'R', 1); $index++; @@ -1967,6 +2013,13 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetFont('', '', $default_font_size - 2); if (empty($hidetop)) { + // Show category of operations + if (getDolGlobalInt('INVOICE_CATEGORY_OF_OPERATION') == 1 && $this->categoryOfOperation >= 0) { + $categoryOfOperations = $outputlangs->transnoentities("MentionCategoryOfOperations") . ' : ' . $outputlangs->transnoentities("MentionCategoryOfOperations" . $this->categoryOfOperation); + $pdf->SetXY($this->marge_gauche, $tab_top - 4); + $pdf->MultiCell(($pdf->GetStringWidth($categoryOfOperations)) + 4, 2, $categoryOfOperations); + } + $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) { $titre .= ' - '.$outputlangsbis->transnoentities("AmountInCurrency", $outputlangsbis->transnoentitiesnoconv("Currency".$currency)); @@ -2031,13 +2084,13 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (empty($conf->global->PDF_DISABLE_MYCOMPANY_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 (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { + if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { $logo = $logodir.'/logos/'.$this->emetteur->logo; @@ -2337,7 +2390,7 @@ class pdf_sponge extends ModelePDFFactures $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, $usecontact, 'target', $object); } else { $carac_client_name_shipping=pdfBuildThirdpartyName($object->thirdparty, $outputlangs); - $carac_client_shipping=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object);; + $carac_client_shipping=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object); } if (!empty($carac_client_shipping) && (isset($object->contact->socid) && $object->contact->socid != $object->socid)) { $posy += $hautcadre; @@ -2542,7 +2595,7 @@ class pdf_sponge extends ModelePDFFactures ), 'border-left' => true, // add left line separator ); - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $this->cols['unit']['status'] = true; } diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index 9e0ff0d5b4e..fb4ba06b9ce 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -72,7 +72,7 @@ class mod_facture_mars extends ModeleNumRefFactures /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php index 321741ea8a0..e67cb252a17 100644 --- a/htdocs/core/modules/facture/mod_facture_mercure.php +++ b/htdocs/core/modules/facture/mod_facture_mercure.php @@ -49,7 +49,7 @@ class mod_facture_mercure extends ModeleNumRefFactures /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php index 2b11ee3976f..0e6ce61093b 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -88,7 +88,7 @@ class mod_facture_terre extends ModeleNumRefFactures /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php index 480c532cc1f..ff541550d4e 100644 --- a/htdocs/core/modules/facture/modules_facture.php +++ b/htdocs/core/modules/facture/modules_facture.php @@ -61,8 +61,6 @@ abstract class ModelePDFFactures extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'invoice'; $list = array(); @@ -94,9 +92,9 @@ abstract class ModeleNumRefFactures } /** - * Renvoi la description par defaut du modele de numerotation + * Returns the default description of the numbering pattern * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/fichinter/mod_arctic.php b/htdocs/core/modules/fichinter/mod_arctic.php index 8efd936601b..d1f313e1bd5 100644 --- a/htdocs/core/modules/fichinter/mod_arctic.php +++ b/htdocs/core/modules/fichinter/mod_arctic.php @@ -59,7 +59,7 @@ class mod_arctic extends ModeleNumRefFicheinter /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/fichinter/modules_fichinter.php b/htdocs/core/modules/fichinter/modules_fichinter.php index 185ef4cf73b..28b3fd265ce 100644 --- a/htdocs/core/modules/fichinter/modules_fichinter.php +++ b/htdocs/core/modules/fichinter/modules_fichinter.php @@ -51,8 +51,6 @@ abstract class ModelePDFFicheinter extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'ficheinter'; $list = array(); diff --git a/htdocs/core/modules/holiday/modules_holiday.php b/htdocs/core/modules/holiday/modules_holiday.php index 7b6e13ea992..e38801a052e 100644 --- a/htdocs/core/modules/holiday/modules_holiday.php +++ b/htdocs/core/modules/holiday/modules_holiday.php @@ -55,8 +55,6 @@ abstract class ModelePDFHoliday extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'holiday'; $list = array(); diff --git a/htdocs/core/modules/hrm/mod_evaluation_advanced.php b/htdocs/core/modules/hrm/mod_evaluation_advanced.php index cdb1cc20109..7369032e165 100644 --- a/htdocs/core/modules/hrm/mod_evaluation_advanced.php +++ b/htdocs/core/modules/hrm/mod_evaluation_advanced.php @@ -54,7 +54,7 @@ class mod_evaluation_advanced extends ModeleNumRefEvaluation /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { @@ -68,7 +68,7 @@ class mod_evaluation_advanced extends ModeleNumRefEvaluation $texte .= '
'; $texte .= ''; $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= ''; $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Evaluation"), $langs->transnoentities("Evaluation")); diff --git a/htdocs/core/modules/hrm/modules_evaluation.php b/htdocs/core/modules/hrm/modules_evaluation.php index 36fc7e26d81..06276ca8474 100644 --- a/htdocs/core/modules/hrm/modules_evaluation.php +++ b/htdocs/core/modules/hrm/modules_evaluation.php @@ -49,8 +49,6 @@ abstract class ModelePDFEvaluation extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'evaluation'; $list = array(); @@ -86,7 +84,7 @@ abstract class ModeleNumRefEvaluation /** * Returns the default description of the numbering template * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 22c12024c2b..a9a82e7cb00 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -579,7 +579,7 @@ class ImportCsv extends ModeleImports } } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsuppliercodeifauto') { if (strtolower($newval) == 'auto') { - $newval = $this->thirdpartyobject->get_codefournisseur(0, 1); + $this->thirdpartyobject->get_codefournisseur(0, 1); $newval = $this->thirdpartyobject->code_fournisseur; //print 'code_fournisseur='.$newval; } @@ -994,7 +994,9 @@ class ImportCsv extends ModeleImports if ($sql) { $resql = $this->db->query($sql); if ($resql) { - $last_insert_id_array[$tablename] = $this->db->last_insert_id($tablename); // store the last inserted auto_increment id for each table, so that child tables can be inserted with the appropriate id. This must be done just after the INSERT request, else we risk losing the id (because another sql query will be issued somewhere in Dolibarr). + if (!$is_table_category_link) { + $last_insert_id_array[$tablename] = $this->db->last_insert_id($tablename); // store the last inserted auto_increment id for each table, so that child tables can be inserted with the appropriate id. This must be done just after the INSERT request, else we risk losing the id (because another sql query will be issued somewhere in Dolibarr). + } $insertdone = true; } else { //print 'E'; @@ -1037,4 +1039,4 @@ class ImportCsv extends ModeleImports function cleansep($value) { return str_replace(array(',', ';'), '/', $value); -}; +} diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 35adc4476a0..0854a0f56c5 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -624,7 +624,7 @@ class ImportXlsx extends ModeleImports } } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsuppliercodeifauto') { if (strtolower($newval) == 'auto') { - $newval = $this->thirdpartyobject->get_codefournisseur(0, 1); + $this->thirdpartyobject->get_codefournisseur(0, 1); $newval = $this->thirdpartyobject->code_fournisseur; //print 'code_fournisseur='.$newval; } @@ -1041,7 +1041,9 @@ class ImportXlsx extends ModeleImports if ($sql) { $resql = $this->db->query($sql); if ($resql) { - $last_insert_id_array[$tablename] = $this->db->last_insert_id($tablename); // store the last inserted auto_increment id for each table, so that child tables can be inserted with the appropriate id. This must be done just after the INSERT request, else we risk losing the id (because another sql query will be issued somewhere in Dolibarr). + if (!$is_table_category_link) { + $last_insert_id_array[$tablename] = $this->db->last_insert_id($tablename); // store the last inserted auto_increment id for each table, so that child tables can be inserted with the appropriate id. This must be done just after the INSERT request, else we risk losing the id (because another sql query will be issued somewhere in Dolibarr). + } $insertdone = true; } else { //print 'E'; diff --git a/htdocs/core/modules/import/modules_import.php b/htdocs/core/modules/import/modules_import.php index d875afc5c4f..fa4a5ad3692 100644 --- a/htdocs/core/modules/import/modules_import.php +++ b/htdocs/core/modules/import/modules_import.php @@ -155,18 +155,16 @@ class ModeleImports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Charge en memoire et renvoie la liste des modeles actifs + * Load into memory list of available import format * * @param DoliDB $db Database handler * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - public function liste_modeles($db, $maxfilenamelength = 0) + public function listOfAvailableImportFormat($db, $maxfilenamelength = 0) { - // phpcs:enable - dol_syslog(get_class($this)."::liste_modeles"); + dol_syslog(get_class($this)."::listOfAvailableImportFormat"); $dir = DOL_DOCUMENT_ROOT."/core/modules/import/"; $handle = opendir($dir); diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index 64097078147..3787874bdad 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -99,8 +99,6 @@ class mailing_contacts1 extends MailingTargets */ public function getNbOfRecipients($sql = '') { - global $conf; - $sql = "SELECT count(distinct(c.email)) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = c.fk_soc"; @@ -122,7 +120,7 @@ class mailing_contacts1 extends MailingTargets */ public function formFilter() { - global $langs; + global $conf,$langs; // Load translation files required by the page $langs->loadLangs(array("commercial", "companies", "suppliers", "categories")); @@ -307,11 +305,13 @@ class mailing_contacts1 extends MailingTargets $s .= ajax_combobox("filter_category_supplier_contact"); - // Choose language - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; - $formadmin = new FormAdmin($this->db); - $s .= ''.$langs->trans("DefaultLang").': '; - $s .= $formadmin->select_language($langs->getDefaultLang(1), 'filter_lang', 0, 0, 1, 0, 0, '', 0, 0, 0, null, 1); + if (getDolGlobalInt('MAIN_MULTILANGS')) { + // Choose language + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; + $formadmin = new FormAdmin($this->db); + $s .= ''.$langs->trans("DefaultLang").': '; + $s .= $formadmin->select_language($langs->getDefaultLang(1), 'filter_lang', 0, null, 1, 0, 0, '', 0, 0, 0, null, 1); + } return $s; } @@ -409,7 +409,7 @@ class mailing_contacts1 extends MailingTargets } // Filter on language - if ($filter_lang != '') { + if (!empty($filter_lang)) { $sql .= " AND sp.default_lang LIKE '".$this->db->escape($filter_lang)."%'"; } @@ -418,7 +418,7 @@ class mailing_contacts1 extends MailingTargets //print "xx".$key; if ($key == 'prospects') { - $sql .= " AND s.client=2"; + $sql .= " AND s.client = 2"; } foreach ($prospectlevel as $codelevel => $valuelevel) { if ($key == 'prospectslevel'.$codelevel) { @@ -426,10 +426,10 @@ class mailing_contacts1 extends MailingTargets } } if ($key == 'customers') { - $sql .= " AND s.client=1"; + $sql .= " AND s.client = 1"; } if ($key == 'suppliers') { - $sql .= " AND s.fournisseur=1"; + $sql .= " AND s.fournisseur = 1"; } // Filter on job position @@ -440,7 +440,6 @@ class mailing_contacts1 extends MailingTargets $sql .= " ORDER BY sp.email"; // print "wwwwwwx".$sql; - // Stocke destinataires dans cibles $result = $this->db->query($sql); if ($result) { diff --git a/htdocs/core/modules/mailings/eventorganization.modules.php b/htdocs/core/modules/mailings/eventorganization.modules.php index 84c27c5f673..0d0ffb63c3a 100644 --- a/htdocs/core/modules/mailings/eventorganization.modules.php +++ b/htdocs/core/modules/mailings/eventorganization.modules.php @@ -188,7 +188,7 @@ class mailing_eventorganization extends MailingTargets include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; $formproject = new FormProjets($this->db); - $s .= $formproject->select_projects(-1, 0, "filter_eventorganization", 0, 0, 1, 1, 0, 0, 0, '', 1, 0, '', '', 'usage_organize_event=1'); + $s = $formproject->select_projects(-1, 0, "filter_eventorganization", 0, 0, 1, 1, 0, 0, 0, '', 1, 0, '', '', 'usage_organize_event=1'); return $s; } 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 ed48c93c4de..2d125d2743a 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 @@ -266,7 +266,7 @@ class doc_generic_member_odt extends ModelePDFMember if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile = basename($srctemplatepath); - $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile); $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); diff --git a/htdocs/core/modules/member/mod_member_advanced.php b/htdocs/core/modules/member/mod_member_advanced.php new file mode 100644 index 00000000000..3edb86030e8 --- /dev/null +++ b/htdocs/core/modules/member/mod_member_advanced.php @@ -0,0 +1,165 @@ + + * Copyright (C) 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/member/mod_member_advanced.php + * \ingroup member + * \brief File with class to manage the numbering module Advanced for member references + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/member/modules_member.class.php'; + + +/** + * Class to manage the numbering module Advanced for member references + */ +class mod_member_advanced extends ModeleNumRefMembers +{ + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; + + /** + * prefix + * + * @var string + */ + public $prefix = 'MEM'; + + /** + * @var string Error code (or message) + */ + public $error = ''; + + /** + * @var string model name + */ + public $name = 'Advanced'; + + /** + * @var int Automatic numbering + */ + public $code_auto = 1; + + /** + * Return description of numbering module + * + * @return string Text with description + */ + public function info() + { + global $langs; + return $langs->trans("AdvancedNumRefModelDesc", $this->prefix); + } + + + /** + * Return an example of numbering module values + * + * @return string Example + */ + public function getExample() + { + return $this->prefix."2301-0001"; + } + + + /** + * Checks if the numbers already in the database do not + * cause conflicts that would prevent this numbering working. + * + * @return boolean false if conflict, true if ok + */ + public function canBeActivated() + { + 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."adherent"; + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql .= " AND entity = ".$conf->entity; + $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)) { + return true; + } else { + $langs->load("errors"); + $this->error = $langs->trans('ErrorNumRefModel', $max); + return false; + } + } + + + /** + * Return next value + * + * @param Societe $objsoc Object third party + * @param Member $object Object we need next value for + * @return string Value if OK, 0 if KO + */ + public function getNextValue($objsoc, $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."adherent"; + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql .= " AND entity = ".$conf->entity; + + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + if ($obj) { + $max = intval($obj->max); + } else { + $max = 0; + } + } else { + dol_syslog("mod_member_advanced::getNextValue", LOG_DEBUG); + return -1; + } + + $date = empty($object->datec) ? dol_now() : $object->datec; + + $yymm = dol_print_date($date, '%y%m', 'gmt'); + + 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_member_advanced::getNextValue return ".$this->prefix.$yymm."-".$num, LOG_INFO); + return $this->prefix.$yymm."-".$num; + } +} diff --git a/htdocs/core/modules/member/mod_member_simple.php b/htdocs/core/modules/member/mod_member_simple.php index 50eccd0f244..c45738c85cb 100644 --- a/htdocs/core/modules/member/mod_member_simple.php +++ b/htdocs/core/modules/member/mod_member_simple.php @@ -1,5 +1,6 @@ + * Copyright (C) 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 @@ -34,27 +35,29 @@ class mod_member_simple extends ModeleNumRefMembers * Dolibarr version of the loaded document * @var string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; - public $prefix = 'MEM'; + /** + * prefix + * + * @var string + */ + public $prefix = ''; /** * @var string Error code (or message) */ public $error = ''; - /** - * @var string Nom du modele - * @deprecated - * @see $name - */ - public $nom = 'Simple'; - /** * @var string model name */ public $name = 'Simple'; + /** + * @var int Automatic numbering + */ + public $code_auto = 1; /** * Return description of numbering module @@ -64,7 +67,7 @@ class mod_member_simple extends ModeleNumRefMembers public function info() { global $langs; - return $langs->trans("SimpleNumRefModelDesc", $this->prefix); + return $langs->trans("SimpleRefNumRefModelDesc"); } @@ -75,7 +78,7 @@ class mod_member_simple extends ModeleNumRefMembers */ public function getExample() { - return $this->prefix."0501-0001"; + return "1"; } @@ -92,11 +95,9 @@ class mod_member_simple extends ModeleNumRefMembers $coyymm = ''; $max = ''; - $posindice = strlen($this->prefix) + 6; - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql = "SELECT MAX(CAST(ref AS SIGNED)) as max"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent"; - $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; - $sql .= " AND entity = ".$conf->entity; + $sql .= " WHERE entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) { $row = $db->fetch_row($resql); @@ -105,7 +106,7 @@ class mod_member_simple extends ModeleNumRefMembers $max = $row[0]; } } - if (!$coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) { + if (!$coyymm || preg_match('/[0-9][0-9][0-9][0-9]/i', $coyymm)) { return true; } else { $langs->load("errors"); @@ -119,65 +120,31 @@ class mod_member_simple extends ModeleNumRefMembers * Return next value * * @param Societe $objsoc Object third party - * @param Object $object Object we need next value for + * @param Member $object Object we need next value for * @return string Value if OK, 0 if KO */ public function getNextValue($objsoc, $object) { - global $db, $conf; + global $conf, $db; - /* - // First, we get the max value - $posindice = strlen($this->prefix) + 6; - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + // the ref of a member is the rowid + $sql = "SELECT MAX(CAST(ref AS SIGNED)) as max"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent"; - $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; - $sql .= " AND entity = ".$conf->entity; + $sql .= " WHERE entity = ".(int) $conf->entity; $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); if ($obj) { - $max = intval($obj->max); + $max = intval($obj->max) + 1; } else { - $max = 0; + $max = 1; } } else { dol_syslog("mod_member_simple::getNextValue", LOG_DEBUG); return -1; } - - $date = empty($object->date_c) ? dol_now() : $object->date_c; - - //$yymm = strftime("%y%m",time()); - $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_member_simple::getNextValue return ".$this->prefix.$yymm."-".$num); - return $this->prefix.$yymm."-".$num; - */ - - // For the moment, the ref of a member is the rowid - $sql = "SELECT MAX(rowid) as max"; - $sql .= " FROM ".MAIN_DB_PREFIX."adherent"; - - $resql = $db->query($sql); - if ($resql) { - $obj = $db->fetch_object($resql); - if ($obj) { - $max = intval($obj->max); - } else { - $max = 0; - } - } else { - dol_syslog("mod_member_simple::getNextValue", LOG_DEBUG); - return -1; - } - return ($max + 1); + $max = str_pad((string) $max, getDolGlobalInt('MEMBER_MOD_SIMPLE_LPAD'), "0", STR_PAD_LEFT); + return $max; } } diff --git a/htdocs/core/modules/member/modules_cards.php b/htdocs/core/modules/member/modules_cards.php index b37b9144d3e..0147f42f6c7 100644 --- a/htdocs/core/modules/member/modules_cards.php +++ b/htdocs/core/modules/member/modules_cards.php @@ -51,8 +51,6 @@ class ModelePDFCards public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'member'; $list = array(); diff --git a/htdocs/core/modules/member/modules_member.class.php b/htdocs/core/modules/member/modules_member.class.php index cdc37231901..77ab5621915 100644 --- a/htdocs/core/modules/member/modules_member.class.php +++ b/htdocs/core/modules/member/modules_member.class.php @@ -51,7 +51,6 @@ abstract class ModelePDFMember extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - $type = 'member'; $list = array(); @@ -84,9 +83,9 @@ abstract class ModeleNumRefMembers } /** - * Renvoi la description par defaut du modele de numerotation + * Returns the default description of the numbering pattern * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { @@ -95,6 +94,16 @@ abstract class ModeleNumRefMembers return $langs->trans("NoDescription"); } + /** + * Return name of module + * + * @return string Module name + */ + public function getName() + { + return $this->name; + } + /** * Return an example of numbering * @@ -153,4 +162,50 @@ abstract class ModeleNumRefMembers return $langs->trans("NotAvailable"); } } + + /** + * Return description of module parameters + * + * @param Translate $langs Output language + * @param Societe $soc Third party object + * @return string HTML translated description + */ + public function getToolTip($langs, $soc) + { + global $conf; + + $langs->loadLangs(array("admin", "companies")); + + $strikestart = ''; + $strikeend = ''; + if (!empty($conf->global->MAIN_MEMBER_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) { + $strikestart = ''; + $strikeend = ' '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')'; + } + + $s = ''; + $s .= $langs->trans("Name").': '.$this->getName().'
'; + $s .= $langs->trans("Version").': '.$this->getVersion().'
'; + $s .= $langs->trans("MemberCodeDesc").'
'; + $s .= $langs->trans("ValidityControledByModule").': '.$this->getName().'
'; + $s .= '
'; + $s .= ''.$langs->trans("ThisIsModuleRules").':
'; + + $s .= $langs->trans("Required").': '.$strikestart; + $s .= yn(!$this->code_null, 1, 2).$strikeend; + $s .= '
'; + $s .= $langs->trans("CanBeModifiedIfOk").': '; + $s .= yn($this->code_modifiable, 1, 2); + $s .= '
'; + $s .= $langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'
'; + $s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'
'; + $s .= '
'; + $nextval = $this->getNextValue($soc, 0); + if (empty($nextval)) { + $nextval = $langs->trans("Undefined"); + } + $s .= $langs->trans("NextValue").' ('.$langs->trans("Member").'): '.$nextval.'
'; + + return $s; + } } diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index d9858a017e0..38debb8633a 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -241,7 +241,7 @@ class modAgenda extends DolibarrModules 'url'=>'/comm/action/card.php?mainmenu=agenda&leftmenu=agenda&action=create', 'langs'=>'commercial', 'position'=>101, - 'perms'=>'($user->rights->agenda->myactions->create||$user->rights->agenda->allactions->create)', + 'perms'=>'($user->hasRight("agenda", "myactions", "create")||$user->hasRight("agenda", "allactions", "create"))', 'enabled'=>'$conf->agenda->enabled', 'target'=>'', 'user'=>2 diff --git a/htdocs/core/modules/modAsset.class.php b/htdocs/core/modules/modAsset.class.php index 3a7caa1cb57..a0fb405887e 100644 --- a/htdocs/core/modules/modAsset.class.php +++ b/htdocs/core/modules/modAsset.class.php @@ -63,7 +63,7 @@ class modAsset extends DolibarrModules $this->descriptionlong = "Asset module to manage assets module and depreciation charge on Dolibarr"; // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' - $this->version = 'experimental'; + $this->version = 'development'; // Key used in llx_const table to save module status enabled/disabled (where ASSETS is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Name of image file used for this module. diff --git a/htdocs/core/modules/modBookCal.class.php b/htdocs/core/modules/modBookCal.class.php index 2703099cf77..c3066dbd2e0 100644 --- a/htdocs/core/modules/modBookCal.class.php +++ b/htdocs/core/modules/modBookCal.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2018-2019 Nicolas ZABOURI - * Copyright (C) 2019-2020 Frédéric France + * Copyright (C) 2019-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 @@ -51,7 +51,7 @@ class modBookCal extends DolibarrModules // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' // It is used to group modules by family in module setup page - $this->family = "other"; + $this->family = "projects"; // Module position in the family on 2 digits ('01', '10', '20', ...) $this->module_position = '50'; @@ -68,8 +68,6 @@ class modBookCal extends DolibarrModules // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' $this->version = 'development'; - // Url to the file with your last numberversion of this module - //$this->url_last_version = 'http://www.example.com/versionmodule.txt'; // Key used in llx_const table to save module status enabled/disabled (where BOOKCAL is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); @@ -140,7 +138,6 @@ class modBookCal extends DolibarrModules // Prerequisites $this->phpmin = array(7, 0); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(17, -3); // Minimum version of Dolibarr required by module // Messages at activation $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','MX'='textmx'...) diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php index f0486b5cb58..38b81cdb4fb 100644 --- a/htdocs/core/modules/modCommande.class.php +++ b/htdocs/core/modules/modCommande.class.php @@ -204,7 +204,7 @@ class modCommande extends DolibarrModules 'co.code'=>"CountryCode", 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 'c.rowid'=>"Id", 'c.ref'=>"Ref", 'c.ref_client'=>"RefCustomer", 'c.fk_soc'=>"IdCompany", 'c.date_creation'=>"DateCreation", 'c.date_commande'=>"OrderDate", 'c.date_livraison'=>"DateDeliveryPlanned", 'c.amount_ht'=>"Amount", 'c.total_ht'=>"TotalHT", - 'c.total_ttc'=>"TotalTTC", 'c.facture'=>"Billed", 'c.fk_statut'=>'Status', 'c.note_public'=>"Note", 'c.date_livraison'=>'DeliveryDate', + 'c.total_ttc'=>"TotalTTC", 'c.facture'=>"Billed", 'c.fk_statut'=>'Status', 'c.note_public'=>"Note", 'c.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin', 'c.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin', 'pj.ref'=>'ProjectRef', 'cd.rowid'=>'LineId', 'cd.description'=>"LineDescription", 'cd.product_type'=>'TypeOfLineServiceOrProduct', 'cd.tva_tx'=>"LineVATRate", 'cd.qty'=>"LineQty", 'cd.total_ht'=>"LineTotalHT", 'cd.total_tva'=>"LineTotalVAT", 'cd.total_ttc'=>"LineTotalTTC", @@ -236,7 +236,7 @@ class modCommande extends DolibarrModules 's.nom'=>'Text', 'ps.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'co.label'=>'List:c_country:label:label', 'co.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 'c.ref'=>"Text", 'c.ref_client'=>"Text", 'c.date_creation'=>"Date", 'c.date_commande'=>"Date", 'c.date_livraison'=>"Date", 'c.amount_ht'=>"Numeric", 'c.total_ht'=>"Numeric", - 'c.total_ttc'=>"Numeric", 'c.facture'=>"Boolean", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text", 'c.date_livraison'=>'Date', 'pj.ref'=>'Text', + 'c.total_ttc'=>"Numeric", 'c.facture'=>"Boolean", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text", 'pj.ref'=>'Text', 'cd.description'=>"Text", 'cd.product_type'=>'Boolean', 'cd.tva_tx'=>"Numeric", 'cd.qty'=>"Numeric", 'cd.total_ht'=>"Numeric", 'cd.total_tva'=>"Numeric", 'cd.total_ttc'=>"Numeric", 'p.rowid'=>'List:product:ref::product', 'p.ref'=>'Text', 'p.label'=>'Text', 'd.nom'=>'Text', 'c.entity'=>'List:entity:label:rowid', diff --git a/htdocs/core/modules/modECM.class.php b/htdocs/core/modules/modECM.class.php index 1ea7530be53..09556b43cd8 100644 --- a/htdocs/core/modules/modECM.class.php +++ b/htdocs/core/modules/modECM.class.php @@ -74,12 +74,6 @@ class modECM extends DolibarrModules $this->const = array(); // List of parameters $r = 0; - $this->const[$r][0] = "ECM_AUTO_TREE_ENABLED"; - $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "1"; - $this->const[$r][3] = 'Auto tree is enabled by default'; - $this->const[$r][4] = 0; - // Boxes $this->boxes = array(); // List of boxes $r = 0; @@ -182,7 +176,7 @@ class modECM extends DolibarrModules 'langs'=>'ecm', 'position'=>103, 'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload', - 'enabled'=>'($user->rights->ecm->read || $user->rights->ecm->upload) && getDolGlobalInt("ECM_AUTO_TREE_ENABLED")', + 'enabled'=>'($user->rights->ecm->read || $user->rights->ecm->upload) && !getDolGlobalInt("ECM_AUTO_TREE_HIDEN")', 'target'=>'', 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both ); diff --git a/htdocs/core/modules/modExport.class.php b/htdocs/core/modules/modExport.class.php index 357e280f9f6..df996a312bf 100644 --- a/htdocs/core/modules/modExport.class.php +++ b/htdocs/core/modules/modExport.class.php @@ -64,6 +64,7 @@ class modExport extends DolibarrModules $this->requiredby = array(); $this->phpmin = array(7, 0); $this->phpmax = array(); + $this->enabled_bydefault = true; // Will be enabled during install // Constants $this->const = array(); diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 85072c90cee..a7089037abe 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -88,7 +88,7 @@ class modFacture extends DolibarrModules $this->const[$r][0] = "FACTURE_ADDON_PDF"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "crabe"; + $this->const[$r][2] = "sponge"; $this->const[$r][3] = 'Name of PDF model of invoice'; $this->const[$r][4] = 0; $r++; diff --git a/htdocs/core/modules/modFckeditor.class.php b/htdocs/core/modules/modFckeditor.class.php index fa3a66c37cc..9dd3fce7fcd 100644 --- a/htdocs/core/modules/modFckeditor.class.php +++ b/htdocs/core/modules/modFckeditor.class.php @@ -66,6 +66,7 @@ class modFckeditor extends DolibarrModules $this->disabled = in_array(constant('JS_CKEDITOR'), array('disabled', 'disabled/')); $this->depends = array(); $this->requiredby = array('modWebsites'); + $this->enabled_bydefault = true; // Will be enabled during install // Constants $this->const = array(); @@ -74,7 +75,6 @@ class modFckeditor extends DolibarrModules $this->const[3] = array("FCKEDITOR_ENABLE_USERSIGN", "yesno", "1", "WYSIWIG for user signature"); $this->const[4] = array("FCKEDITOR_ENABLE_MAILING", "yesno", "1", "WYSIWIG for mass emailings"); $this->const[5] = array("FCKEDITOR_ENABLE_MAIL", "yesno", "1", "WYSIWIG for products details lines for all entities"); - $this->const[6] = array("FCKEDITOR_SKIN", "string", "moono-lisa", "Skin by default for fckeditor"); // Boxes $this->boxes = array(); diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index e05d7964094..b6286c35162 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -111,6 +111,7 @@ class modFournisseur extends DolibarrModules $this->const[$r][4] = 0; $r++; + // Add ability ODT for Supplier orders $this->const[$r][0] = "SUPPLIER_ORDER_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/supplier_orders"; @@ -118,6 +119,14 @@ class modFournisseur extends DolibarrModules $this->const[$r][4] = 0; $r++; + // Add ability ODT for Supplier Invoices + $this->const[$r][0] = "SUPPLIER_INVOICE_ADDON_PDF_ODT_PATH"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = ""; + $this->const[$r][3] = ""; + $this->const[$r][4] = 0; + $r++; + // Boxes $this->boxes = array( 0=>array('file'=>'box_graph_invoices_supplier_permonth.php', 'enabledbydefaulton'=>'Home'), @@ -578,6 +587,9 @@ class modFournisseur extends DolibarrModules } // End add extra fields $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'facture_fourn'); + if (empty($conf->multicurrency->enabled)) { + $this->import_fieldshidden_array[$r]['f.multicurrency_code'] = 'const-'.$conf->currency; + } $this->import_regex_array[$r] = array('f.ref' => '(SI\d{4}-\d{4}|PROV.{1,32}$)', 'f.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency'); $import_sample = array( 'f.ref' => '(PROV001)', @@ -872,7 +884,7 @@ class modFournisseur extends DolibarrModules $this->remove($options); - //ODT template + //ODT template for Supplier Orders $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/supplier_orders/template_supplier_order.odt'; $dirodt = DOL_DATA_ROOT.'/doctemplates/supplier_orders'; $dest = $dirodt.'/template_supplier_order.odt'; @@ -888,11 +900,38 @@ class modFournisseur extends DolibarrModules } } - $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'order_supplier' AND entity = ".((int) $conf->entity), - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."', 'order_supplier', ".((int) $conf->entity).")", + $sql_order = array( + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'order_supplier' AND entity = ".((int) $conf->entity), + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."', 'order_supplier', ".((int) $conf->entity).")", ); + //ODT template for Supplier Invoice + $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/supplier_invoices/template_supplier_invoices.odt'; + $dirodt = DOL_DATA_ROOT.'/doctemplates/supplier_invoices'; + $dest = $dirodt.'/template_supplier_invoices.odt'; + + if (file_exists($src) && !file_exists($dest)) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + dol_mkdir($dirodt); + $result = dol_copy($src, $dest, 0, 0); + if ($result < 0) { + $langs->load("errors"); + $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest); + return 0; + } + } + + /* + $sql_invoice = array( + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[2][2])."' AND type = 'invoice_supplier' AND entity = ".((int) $conf->entity), + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[2][2])."', 'invoice_supplier', ".((int) $conf->entity).")", + ); + + $sql = array_merge($sql_order, $sql_invoice); + */ + + $sql = $sql_order; + return $this->_init($sql, $options); } } diff --git a/htdocs/core/modules/modHRM.class.php b/htdocs/core/modules/modHRM.class.php index 3f3dd4b97a1..78c0bde14f6 100644 --- a/htdocs/core/modules/modHRM.class.php +++ b/htdocs/core/modules/modHRM.class.php @@ -265,6 +265,14 @@ class modHRM extends DolibarrModules $this->rights[$r][4] = 'write_personal_information'; $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->write_personal_information->write) $r++; + + // Evaluation + $this->rights[$r][0] = 4033; // Permission id (must not be already used) + $this->rights[$r][1] = 'Read all evaluations'; // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'evaluation'; + $this->rights[$r][5] = 'readall'; // In php code, permission will be checked by test if ($user->rights->hrm->evaluation->read) + $r++; } /** diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index 61bdc0e8f98..57ffe62e005 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -78,10 +78,6 @@ class modHoliday extends DolibarrModules // Config pages $this->config_page_url = array("holiday.php"); - - // Config pages. Put here list of php page names stored in admmin directory used to setup module. - // $this->config_page_url = array("holiday.php?leftmenu=setup@holiday"); - // 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 diff --git a/htdocs/core/modules/modImport.class.php b/htdocs/core/modules/modImport.class.php index ad0f33c8da2..63f0ca5189f 100644 --- a/htdocs/core/modules/modImport.class.php +++ b/htdocs/core/modules/modImport.class.php @@ -67,7 +67,7 @@ class modImport extends DolibarrModules $this->phpmin = array(7, 0); // Minimum version of PHP required by module - Need auto_detect_line_endings php option to solve MAC pbs. $this->phpmax = array(); $this->need_dolibarr_version = array(2, 7, -1); // Minimum version of Dolibarr required by module - $this->need_javascript_ajax = 1; + $this->enabled_bydefault = true; // Will be enabled during install // Constants $this->const = array(); diff --git a/htdocs/core/modules/modLoan.class.php b/htdocs/core/modules/modLoan.class.php index 7f2850b075a..36919bc38af 100644 --- a/htdocs/core/modules/modLoan.class.php +++ b/htdocs/core/modules/modLoan.class.php @@ -82,7 +82,7 @@ class modLoan extends DolibarrModules "chaine", "6611" ); - $this->const[1] = array( + $this->const[2] = array( "LOAN_ACCOUNTING_ACCOUNT_INSURANCE", "chaine", "6162" diff --git a/htdocs/core/modules/modModuleBuilder.class.php b/htdocs/core/modules/modModuleBuilder.class.php index 2d6cafa9c2e..8e1fa8bac06 100644 --- a/htdocs/core/modules/modModuleBuilder.class.php +++ b/htdocs/core/modules/modModuleBuilder.class.php @@ -48,7 +48,7 @@ class modModuleBuilder extends DolibarrModules $this->module_position = '90'; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i', '', get_class($this)); - $this->description = "A RAD (Rapid Application Development) tool to help developers to build their own module."; + $this->description = "A RAD (Rapid Application Development - low-code and no-code) tool to help developers or advanced users to build their own module/application."; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) diff --git a/htdocs/core/modules/modMrp.class.php b/htdocs/core/modules/modMrp.class.php index fb836c8393b..58e7791845a 100644 --- a/htdocs/core/modules/modMrp.class.php +++ b/htdocs/core/modules/modMrp.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) 2018-2019 Nicolas ZABOURI * Copyright (C) 2019 Frédéric France - * Copyright (C) 2019 Alicealalalamdskfldmjgdfgdfhfghgfh Adminson + * Copyright (C) 2019 Destailleur Laurent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 5224f82a2f5..16906c95f86 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -233,7 +233,7 @@ class modProduct extends DolibarrModules if (getDolGlobalInt('MAIN_MULTILANGS')) { $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription', 'l.note'=>'TranslatedNote')); } - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $this->export_fields_array[$r]['p.fk_unit'] = 'Unit'; } $this->export_TypeFields_array[$r] = array( @@ -640,7 +640,7 @@ class modProduct extends DolibarrModules if (isModEnabled('barcode')) { $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode')); } - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; } @@ -724,7 +724,7 @@ class modProduct extends DolibarrModules if (isModEnabled('barcode')) { $import_sample = array_merge($import_sample, array('p.barcode'=>'')); } - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $import_sample = array_merge( $import_sample, array( diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index 68900bfa993..c3ca77e9a0c 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -78,7 +78,7 @@ class modPropale extends DolibarrModules $this->const[$r][0] = "PROPALE_ADDON_PDF"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "azur"; + $this->const[$r][2] = "cyan"; $this->const[$r][3] = 'Name of the proposal generation manager in PDF format'; $this->const[$r][4] = 0; $r++; diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 868303c231b..a316c746acb 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -198,7 +198,7 @@ class modService extends DolibarrModules if (getDolGlobalInt('MAIN_MULTILANGS')) { $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription', 'l.note'=>'TranslatedNote')); } - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $this->export_fields_array[$r]['p.fk_unit'] = 'Unit'; } $this->export_TypeFields_array[$r] = array( @@ -587,7 +587,7 @@ class modService extends DolibarrModules if (isModEnabled('barcode')) { $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode')); } - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; } // Add extra fields @@ -678,7 +678,7 @@ class modService extends DolibarrModules if (isModEnabled('barcode')) { $import_sample = array_merge($import_sample, array('p.barcode'=>'')); } - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $import_sample = array_merge( $import_sample, array( diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 70729f5c9dc..d63084ac5b5 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -571,7 +571,6 @@ class modSociete extends DolibarrModules 'dict' => 'DictionaryCompanyType' ), 's.capital' => array('rule' => 'numeric'), - 's.fk_stcomm' => array('rule' => 'zeroifnull'), 's.parent' => array( 'rule' => 'fetchidfromref', 'file' => '/societe/class/societe.class.php', diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php index c8d2d8d5a4f..37e6552af2f 100644 --- a/htdocs/core/modules/modTicket.class.php +++ b/htdocs/core/modules/modTicket.class.php @@ -118,7 +118,8 @@ class modTicket extends DolibarrModules 10 => array('TICKET_MESSAGE_MAIL_INTRO', 'chaine', $langs->trans('TicketMessageMailIntroText'), 'Introduction text of ticket replies sent from Dolibarr', 0), 11 => array('TICKET_MESSAGE_MAIL_SIGNATURE', 'chaine', $default_footer, 'Signature to use by default for messages sent from Dolibarr', 0), 12 => array('MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER', 'chaine', "1", 'Disable the rendering of headers in tickets', 0), - 13 => array('MAIN_SECURITY_ENABLECAPTCHA_TICKET', 'chaine', getDolGlobalInt('MAIN_SECURITY_ENABLECAPTCHA_TICKET'), 'Enable captcha code by default', 0) + 13 => array('MAIN_SECURITY_ENABLECAPTCHA_TICKET', 'chaine', getDolGlobalInt('MAIN_SECURITY_ENABLECAPTCHA_TICKET'), 'Enable captcha code by default', 0), + 14 => array('TICKET_SHOW_COMPANY_LOGO', 'chaine', getDolGlobalInt('TICKET_SHOW_COMPANY_LOGO'), 'Enable logo header on ticket public page', 0) ); diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index 6b14d797f15..de7bb6feecf 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -337,7 +337,7 @@ class modUser extends DolibarrModules $this->import_examplevalues_array[$r] = array( 'u.lastname'=>"Doe", 'u.firstname'=>'John', 'u.login'=>'jdoe', 'u.employee'=>'0 or 1', 'u.job'=>'CTO', 'u.gender'=>'man or woman', 'u.pass_crypted'=>'Encrypted password', - 'u.fk_soc'=>'0 (internal user) or company name (external user)', 'u.datec'=>dol_print_date(dol_now(), '%Y-%m-%d'), 'u.address'=>"61 jump street", + 'u.fk_soc'=>'0 (internal user) or company name (external user)', 'u.address'=>"61 jump street", 'u.zip'=>"123456", 'u.town'=>"Big town", 'u.fk_country'=>'US, FR, DE...', 'u.office_phone'=>"0101010101", 'u.office_fax'=>"0101010102", 'u.email'=>"test@mycompany.com", 'u.salary'=>"10000", 'u.note_public'=>"This is an example of public note for record", 'u.note_private'=>"This is an example of private note for record", 'u.datec'=>"2015-01-01 or 2015-01-01 12:30:00", 'u.statut'=>"0 (closed) or 1 (active)", diff --git a/htdocs/core/modules/modWorkflow.class.php b/htdocs/core/modules/modWorkflow.class.php index 58da4876d32..1fd6a89e66a 100644 --- a/htdocs/core/modules/modWorkflow.class.php +++ b/htdocs/core/modules/modWorkflow.class.php @@ -95,7 +95,7 @@ class modWorkflow extends DolibarrModules 8=>array('WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER', 'chaine', '1', 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER', 0, 'current', 0), 10=>array('WORKFLOW_TICKET_LINK_CONTRACT', 'chaine', '0', 'Automatically link a ticket to available contracts', 0, 'current', 0), 11=>array('WORKFLOW_TICKET_USE_PARENT_COMPANY_CONTRACTS', 'chaine', '0', 'Search among parent companies contracts when automatically linking a ticket to available contracts', 0, 'current', 0), - 11=>array('WORKFLOW_TICKET_CREATE_INTERVENTION', 'chaine', '1', 'WORKFLOW_TICKET_CREATE_INTERVENTION', 0, 'current', 0) + 12=>array('WORKFLOW_TICKET_CREATE_INTERVENTION', 'chaine', '0', 'WORKFLOW_TICKET_CREATE_INTERVENTION', 0, 'current', 0) ); // Boxes diff --git a/htdocs/core/modules/movement/doc/pdf_standard.modules.php b/htdocs/core/modules/movement/doc/pdf_standard.modules.php index 094e19a280a..d42dbaa0666 100644 --- a/htdocs/core/modules/movement/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/movement/doc/pdf_standard.modules.php @@ -941,7 +941,7 @@ class pdf_standard extends ModelePDFMovement * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output * @param string $titlekey Translation key to show as title of document - * @return void + * @return int Return topshift value */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "") { @@ -961,8 +961,8 @@ class pdf_standard extends ModelePDFMovement pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); // Show Draft Watermark - if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK))) { - pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_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')); } $pdf->SetTextColor(0, 0, 60); @@ -1108,8 +1108,13 @@ class pdf_standard extends ModelePDFMovement $posy += 2; + $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) { /* @@ -1146,6 +1151,7 @@ class pdf_standard extends ModelePDFMovement } $pdf->SetTextColor(0, 0, 0); + return $top_shift; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore diff --git a/htdocs/core/modules/movement/modules_movement.php b/htdocs/core/modules/movement/modules_movement.php index 1af966faf22..a058d685114 100644 --- a/htdocs/core/modules/movement/modules_movement.php +++ b/htdocs/core/modules/movement/modules_movement.php @@ -85,8 +85,6 @@ abstract class ModelePDFMovement extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'movement'; $list = array(); 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 b89c4eab2cd..90d1f2f8d6b 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 @@ -266,7 +266,7 @@ class doc_generic_mo_odt extends ModelePDFMo if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile = basename($srctemplatepath); - $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile); $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); $newfiletmp = $objectref . '_' . $newfiletmp; diff --git a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php index c5dc9dd8b19..8e3eeeafa33 100644 --- a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php +++ b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php @@ -816,11 +816,11 @@ class pdf_vinci extends ModelePDFMo // Total HT $pdf->SetFillColor(255, 255, 255); - $pdf->SetXY($col1x, $tab2_top + 0); + $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 + 0); + $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 @@ -1085,9 +1085,9 @@ class pdf_vinci extends ModelePDFMo //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); //Affiche le filigrane brouillon - Print Draft Watermark - /*if($object->statut==0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK)) ) + /*if($object->statut==0 && getDolGlobalString('COMMANDE_DRAFT_WATERMARK')) { - pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK); + pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',getDolGlobalString('COMMANDE_DRAFT_WATERMARK')); }*/ //Print content @@ -1405,14 +1405,13 @@ class pdf_vinci extends ModelePDFMo $rank = 0; $this->cols['code'] = array( 'rank' => $rank, - 'status' => false, + 'status' => true, 'width' => 35, // in mm 'title' => array( 'textkey' => 'Ref' ), 'border-left' => true, // add left line separator ); - $this->cols['code']['status'] = true; $rank = 1; // do not use negative rank $this->cols['desc'] = array( @@ -1455,14 +1454,13 @@ class pdf_vinci extends ModelePDFMo $rank = $rank + 10; $this->cols['dim'] = array( 'rank' => $rank, - 'status' => false, + 'status' => true, 'width' => 25, // in mm 'title' => array( 'textkey' => 'Size' ), 'border-left' => true, // add left line separator ); - $this->cols['dim']['status'] = true; $rank = $rank + 10; $this->cols['qty'] = array( @@ -1474,7 +1472,6 @@ class pdf_vinci extends ModelePDFMo ), 'border-left' => true, // add left line separator ); - $this->cols['qty']['status'] = true; $rank = $rank + 10; $this->cols['qtytot'] = array( @@ -1486,7 +1483,6 @@ class pdf_vinci extends ModelePDFMo ), 'border-left' => true, // add left line separator ); - $this->cols['qtytot']['status'] = true; // Add extrafields cols if (!empty($object->lines)) { diff --git a/htdocs/core/modules/mrp/mod_mo_advanced.php b/htdocs/core/modules/mrp/mod_mo_advanced.php index 5588d1cae16..cd134537ea2 100644 --- a/htdocs/core/modules/mrp/mod_mo_advanced.php +++ b/htdocs/core/modules/mrp/mod_mo_advanced.php @@ -55,7 +55,7 @@ class mod_mo_advanced extends ModeleNumRefMos /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/mrp/modules_mo.php b/htdocs/core/modules/mrp/modules_mo.php index 454df89bcde..c178a5d3eaf 100644 --- a/htdocs/core/modules/mrp/modules_mo.php +++ b/htdocs/core/modules/mrp/modules_mo.php @@ -50,8 +50,6 @@ abstract class ModelePDFMo extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'mrp'; $list = array(); @@ -87,7 +85,7 @@ abstract class ModeleNumRefMos /** * Returns the default description of the numbering template * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/oauth/google_oauthcallback.php b/htdocs/core/modules/oauth/google_oauthcallback.php index b993cbdd81e..ed0caa1a4ff 100644 --- a/htdocs/core/modules/oauth/google_oauthcallback.php +++ b/htdocs/core/modules/oauth/google_oauthcallback.php @@ -42,7 +42,7 @@ $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domai $action = GETPOST('action', 'aZ09'); $backtourl = GETPOST('backtourl', 'alpha'); $keyforprovider = GETPOST('keyforprovider', 'aZ09'); -if (empty($keyforprovider) && !empty($_SESSION["oauthkeyforproviderbeforeoauthjump"]) && (GETPOST('code') || $action == 'delete')) { +if (!GETPOSTISSET('keyforprovider') && !empty($_SESSION["oauthkeyforproviderbeforeoauthjump"]) && (GETPOST('code') || $action == 'delete')) { // If we are coming from the Oauth page $keyforprovider = $_SESSION["oauthkeyforproviderbeforeoauthjump"]; } diff --git a/htdocs/core/modules/payment/mod_payment_ant.php b/htdocs/core/modules/payment/mod_payment_ant.php index 958074202fe..03a6109bd67 100644 --- a/htdocs/core/modules/payment/mod_payment_ant.php +++ b/htdocs/core/modules/payment/mod_payment_ant.php @@ -57,7 +57,7 @@ class mod_payment_ant extends ModeleNumRefPayments /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/payment/modules_payment.php b/htdocs/core/modules/payment/modules_payment.php index f19e80dd3d2..68b864fe94d 100644 --- a/htdocs/core/modules/payment/modules_payment.php +++ b/htdocs/core/modules/payment/modules_payment.php @@ -41,7 +41,7 @@ abstract class ModeleNumRefPayments /** * Return the default description of numbering module * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/printsheet/modules_labels.php b/htdocs/core/modules/printsheet/modules_labels.php index ae4c6888a6c..b80710dc1f6 100644 --- a/htdocs/core/modules/printsheet/modules_labels.php +++ b/htdocs/core/modules/printsheet/modules_labels.php @@ -51,8 +51,6 @@ class ModelePDFLabels public function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'members_labels'; $list = array(); 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 821b6a24e10..6fde0ce16c4 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 @@ -153,7 +153,7 @@ class doc_generic_product_odt extends ModelePDFProduct $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); $texte .= '
'; $texte .= ''; $texte .= '
'; $texte .= ''; @@ -274,7 +274,7 @@ class doc_generic_product_odt extends ModelePDFProduct if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile = basename($srctemplatepath); - $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile); $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php index 89df34f8f73..8baef2ffa75 100644 --- a/htdocs/core/modules/product/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php @@ -687,8 +687,8 @@ class pdf_standard extends ModelePDFProduct pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); // Show Draft Watermark - if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK))) { - pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_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')); } $pdf->SetTextColor(0, 0, 60); diff --git a/htdocs/core/modules/product/modules_product.class.php b/htdocs/core/modules/product/modules_product.class.php index 6c47847ef60..3a856763144 100644 --- a/htdocs/core/modules/product/modules_product.class.php +++ b/htdocs/core/modules/product/modules_product.class.php @@ -104,10 +104,10 @@ abstract class ModeleProductCode */ public $error = ''; - /** Renvoi la description par defaut du modele de numerotation + /** Returns the default description of the numbering pattern * * @param Translate $langs Object langs - * @return string Texte descripif + * @return string Descriptive text */ public function info($langs) { diff --git a/htdocs/core/modules/product_batch/mod_lot_advanced.php b/htdocs/core/modules/product_batch/mod_lot_advanced.php index d6128573f97..27cc509ea02 100644 --- a/htdocs/core/modules/product_batch/mod_lot_advanced.php +++ b/htdocs/core/modules/product_batch/mod_lot_advanced.php @@ -55,7 +55,7 @@ class mod_lot_advanced extends ModeleNumRefBatch /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/product_batch/mod_sn_advanced.php b/htdocs/core/modules/product_batch/mod_sn_advanced.php index 6c796f06c3b..91fc99a1363 100644 --- a/htdocs/core/modules/product_batch/mod_sn_advanced.php +++ b/htdocs/core/modules/product_batch/mod_sn_advanced.php @@ -55,7 +55,7 @@ class mod_sn_advanced extends ModeleNumRefBatch /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/product_batch/modules_product_batch.class.php b/htdocs/core/modules/product_batch/modules_product_batch.class.php index ea64bd98609..d596ffeb111 100644 --- a/htdocs/core/modules/product_batch/modules_product_batch.class.php +++ b/htdocs/core/modules/product_batch/modules_product_batch.class.php @@ -55,8 +55,6 @@ abstract class ModelePDFProductBatch extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'product_batch'; $list = array(); @@ -89,7 +87,7 @@ abstract class ModeleNumRefBatch /** * Returns the default description of the numbering template * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { 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 2015da21f61..f08a93b4339 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 @@ -557,7 +557,7 @@ class doc_generic_project_odt extends ModelePDFProjects if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile = basename($srctemplatepath); - $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile); $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); $newfiletmp = $objectref . '_' . $newfiletmp; diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 9947bb49b0b..7cf7c96aef2 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -130,7 +130,7 @@ class pdf_beluga extends ModelePDFProjects * Page orientation * @var string 'P' or 'Portait' (default), 'L' or 'Landscape' */ - private $orientation = ''; + private $orientation; /** * Issuer diff --git a/htdocs/core/modules/project/mod_project_universal.php b/htdocs/core/modules/project/mod_project_universal.php index 1020c42ebf6..889164fbfe5 100644 --- a/htdocs/core/modules/project/mod_project_universal.php +++ b/htdocs/core/modules/project/mod_project_universal.php @@ -62,7 +62,7 @@ class mod_project_universal extends ModeleNumRefProjects /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/project/modules_project.php b/htdocs/core/modules/project/modules_project.php index 894df4bf8f3..9f8e0e977c7 100644 --- a/htdocs/core/modules/project/modules_project.php +++ b/htdocs/core/modules/project/modules_project.php @@ -103,8 +103,6 @@ abstract class ModelePDFProjects extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'project'; $list = array(); @@ -143,9 +141,9 @@ abstract class ModeleNumRefProjects } /** - * Renvoi la description par defaut du modele de numerotation + * Returns the default description of the numbering pattern * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/project/task/mod_task_universal.php b/htdocs/core/modules/project/task/mod_task_universal.php index 6de02dcaf99..55c1a3ff89d 100644 --- a/htdocs/core/modules/project/task/mod_task_universal.php +++ b/htdocs/core/modules/project/task/mod_task_universal.php @@ -57,7 +57,7 @@ class mod_task_universal extends ModeleNumRefTask /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/project/task/modules_task.php b/htdocs/core/modules/project/task/modules_task.php index 09ba33332f1..97e31d5d24c 100644 --- a/htdocs/core/modules/project/task/modules_task.php +++ b/htdocs/core/modules/project/task/modules_task.php @@ -49,8 +49,6 @@ abstract class ModelePDFTask extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'project_task'; $list = array(); @@ -84,9 +82,9 @@ abstract class ModeleNumRefTask } /** - * Renvoi la description par defaut du modele de numerotation + * Returns the default description of the numbering pattern * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { 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 6715b2e39a5..ac95786cdd2 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 @@ -190,21 +190,21 @@ class doc_generic_proposal_odt extends ModelePDFPropales if (getDolGlobalInt("MAIN_PROPAL_CHOOSE_ODT_DOCUMENT") > 0) { // Model for creation $list = ModelePDFPropales::liste_modeles($this->db); - $texte .= '
'; + $texte .= '
'; $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= '"; $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= '"; $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= '"; @@ -307,7 +307,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile = basename($srctemplatepath); - $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile); $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index e1afcc0c7a0..eac6e0261ee 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -169,7 +169,7 @@ class pdf_azur extends ModelePDFPropales // Define position of columns $this->posxdesc = $this->marge_gauche + 1; - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $this->posxtva = 101; $this->posxup = 118; $this->posxqty = 135; @@ -620,7 +620,7 @@ class pdf_azur extends ModelePDFPropales $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); // Enough for 6 chars // Unit - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); $pdf->SetXY($this->posxunit, $curY); $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L'); @@ -907,7 +907,7 @@ class pdf_azur extends ModelePDFPropales * @param Propal $object Object to show * @param int $posy Y * @param Translate $outputlangs Langs object - * @return void + * @return int */ protected function _tableau_info(&$pdf, $object, $posy, $outputlangs) { @@ -1119,11 +1119,11 @@ class pdf_azur extends ModelePDFPropales // Total HT $pdf->SetFillColor(255, 255, 255); - $pdf->SetXY($col1x, $tab2_top + 0); + $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 + 0); + $pdf->SetXY($col2x, $tab2_top); $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1); // Show VAT by rates and total @@ -1437,7 +1437,7 @@ class pdf_azur extends ModelePDFPropales $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); } - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxunit - 1, $tab_top + 1); @@ -1501,13 +1501,13 @@ class pdf_azur extends ModelePDFPropales $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (empty($conf->global->PDF_DISABLE_MYCOMPANY_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 (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { + if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { $logo = $logodir.'/logos/'.$this->emetteur->logo; @@ -1769,7 +1769,7 @@ class pdf_azur extends ModelePDFPropales $index = 0; // Total HT $pdf->SetFillColor(255, 255, 255); - $pdf->SetXY($posx, $tab_top + 0); + $pdf->SetXY($posx, $tab_top); $pdf->SetFont('', '', $default_font_size - 2); $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentities("ProposalCustomerSignature"), 0, 'L', 1); diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 3444664effa..88b56eb8fa6 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -1244,11 +1244,11 @@ class pdf_cyan extends ModelePDFPropales // Total HT $pdf->SetFillColor(255, 255, 255); - $pdf->SetXY($col1x, $tab2_top + 0); + $pdf->SetXY($col1x, $tab2_top); $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->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 + 0); + $pdf->SetXY($col2x, $tab2_top); $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1); // Show VAT by rates and total @@ -1574,13 +1574,13 @@ class pdf_cyan extends ModelePDFPropales $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (empty($conf->global->PDF_DISABLE_MYCOMPANY_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 (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { + if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { $logo = $logodir.'/logos/'.$this->emetteur->logo; @@ -1854,7 +1854,7 @@ class pdf_cyan extends ModelePDFPropales $index = 0; // Total HT $pdf->SetFillColor(255, 255, 255); - $pdf->SetXY($posx, $tab_top + 0); + $pdf->SetXY($posx, $tab_top); $pdf->SetFont('', '', $default_font_size - 2); $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentities("ProposalCustomerSignature"), 0, 'L', 1); @@ -1948,6 +1948,7 @@ class pdf_cyan extends ModelePDFPropales if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE) && !empty($this->atleastonephoto)) { $this->cols['photo']['status'] = true; + $this->cols['photo']['border-left'] = true; } @@ -2009,7 +2010,7 @@ class pdf_cyan extends ModelePDFPropales ), 'border-left' => true, // add left line separator ); - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $this->cols['unit']['status'] = true; } diff --git a/htdocs/core/modules/propale/mod_propale_saphir.php b/htdocs/core/modules/propale/mod_propale_saphir.php index 98c9803d55c..74395dcc599 100644 --- a/htdocs/core/modules/propale/mod_propale_saphir.php +++ b/htdocs/core/modules/propale/mod_propale_saphir.php @@ -60,7 +60,7 @@ class mod_propale_saphir extends ModeleNumRefPropales /** * Return description of module * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/propale/modules_propale.php b/htdocs/core/modules/propale/modules_propale.php index dcb386947a3..f69fd5e763e 100644 --- a/htdocs/core/modules/propale/modules_propale.php +++ b/htdocs/core/modules/propale/modules_propale.php @@ -53,8 +53,6 @@ abstract class ModelePDFPropales extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'propal'; $list = array(); @@ -87,9 +85,9 @@ abstract class ModeleNumRefPropales } /** - * Renvoi la description par defaut du modele de numerotation + * Returns the default description of the numbering pattern * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { 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 4ebc742b4bb..84d95a5036c 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 @@ -270,7 +270,7 @@ class doc_generic_reception_odt extends ModelePdfReception if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile = basename($srctemplatepath); - $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile); $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); $newfiletmp = $objectref . '_' . $newfiletmp; diff --git a/htdocs/core/modules/reception/modules_reception.php b/htdocs/core/modules/reception/modules_reception.php index f519974382b..0dba62ee646 100644 --- a/htdocs/core/modules/reception/modules_reception.php +++ b/htdocs/core/modules/reception/modules_reception.php @@ -43,8 +43,6 @@ abstract class ModelePdfReception extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'reception'; $list = array(); diff --git a/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php b/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php index e0dd2046020..491ab9757e8 100644 --- a/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php +++ b/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php @@ -212,7 +212,7 @@ class modGeneratePassPerso extends ModeleGenPassword $password_a = preg_split('//u', $password, null, PREG_SPLIT_NO_EMPTY); $maj = preg_split('//u', $this->Maj, null, PREG_SPLIT_NO_EMPTY); - $num = preg_split('//u', $this->Nb, null, PREG_SPLIT_NO_EMPTY);; + $num = preg_split('//u', $this->Nb, null, PREG_SPLIT_NO_EMPTY); $spe = preg_split('//u', $this->Spe, null, PREG_SPLIT_NO_EMPTY); /* $password_a = str_split($password); diff --git a/htdocs/core/modules/societe/modules_societe.class.php b/htdocs/core/modules/societe/modules_societe.class.php index e8b0fbe9193..105333d815b 100644 --- a/htdocs/core/modules/societe/modules_societe.class.php +++ b/htdocs/core/modules/societe/modules_societe.class.php @@ -48,7 +48,6 @@ abstract class ModeleThirdPartyDoc extends CommonDocGenerator public static function liste_modeles($dbs, $maxfilenamelength = 0) { // phpcs:enable - $type = 'company'; $list = array(); @@ -75,10 +74,10 @@ abstract class ModeleThirdPartyCode public $errors; - /** Renvoi la description par defaut du modele de numerotation + /** Returns the default description of the numbering pattern * * @param Translate $langs Object langs - * @return string Texte descripif + * @return string Descriptive text */ public function info($langs) { 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 eb6ba838d7a..358369d1f43 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 @@ -277,7 +277,7 @@ class doc_generic_stock_odt extends ModelePDFStock if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile = basename($srctemplatepath); - $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile); $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index ed1877ec8f7..ac0bf98b0f3 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -402,7 +402,7 @@ class pdf_standard extends ModelePDFStock // Label $pdf->SetXY($this->posxlabel + 0.8, $curY); - $pdf->MultiCell($this->posxqty - $this->posxlabel - 0.8, 3, dol_trunc($objp->produit, 24), 0, 'L'); + $pdf->MultiCell($this->posxqty - $this->posxlabel - 0.8, 3, dol_trunc($productstatic->label, 24), 0, 'L'); // Quantity $valtoshow = price2num($objp->value, 'MS'); diff --git a/htdocs/core/modules/stock/modules_stock.php b/htdocs/core/modules/stock/modules_stock.php index 73092bb0bf6..d1dc684d1d2 100644 --- a/htdocs/core/modules/stock/modules_stock.php +++ b/htdocs/core/modules/stock/modules_stock.php @@ -75,8 +75,6 @@ abstract class ModelePDFStock extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'stock'; $list = array(); diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php index 22601d93dae..35a52f35bd8 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php @@ -895,7 +895,7 @@ class pdf_eagle extends ModelePdfStockTransfer /** * Show top header of page. * - * @param PDF $pdf Object PDF + * @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 diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php index 2ab70767205..ed8b46c7746 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php @@ -1035,10 +1035,10 @@ class pdf_eagle_proforma extends ModelePDFCommandes // Total HT /*$pdf->SetFillColor(255, 255, 255); - $pdf->SetXY($col1x, $tab2_top + 0); + $pdf->SetXY($col1x, $tab2_top); $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->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 + 0); + $pdf->SetXY($col2x, $tab2_top); $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1);*/ // Show VAT by rates and total @@ -1173,8 +1173,8 @@ class pdf_eagle_proforma extends ModelePDFCommandes pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); // Show Draft Watermark - if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK))) { - pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_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')); } $pdf->SetTextColor(0, 0, 60); @@ -1186,11 +1186,11 @@ class pdf_eagle_proforma extends ModelePDFCommandes $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (empty($conf->global->PDF_DISABLE_MYCOMPANY_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 (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { + if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { $logo = $logodir.'/logos/'.$this->emetteur->logo; diff --git a/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php b/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php index dd29e48d0b8..c19067c019d 100644 --- a/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php +++ b/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php @@ -55,7 +55,7 @@ class mod_stocktransfer_advanced extends ModeleNumRefStockTransfer /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/stocktransfer/modules_stocktransfer.php b/htdocs/core/modules/stocktransfer/modules_stocktransfer.php index 3da0a0ae644..2a7218543e7 100644 --- a/htdocs/core/modules/stocktransfer/modules_stocktransfer.php +++ b/htdocs/core/modules/stocktransfer/modules_stocktransfer.php @@ -50,8 +50,6 @@ abstract class ModelePDFStockTransfer extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'stocktransfer'; $list = array(); @@ -87,7 +85,7 @@ abstract class ModeleNumRefStockTransfer /** * Returns the default description of the numbering template * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { 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 new file mode 100644 index 00000000000..c9e18e7c4ab --- /dev/null +++ b/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php @@ -0,0 +1,503 @@ + + * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2014 Marcos García + * Copyright (C) 2016 Charlie Benke + * Copyright (C) 2018-2019 Philippe Grand + * Copyright (C) 2018-2019 Frédéric France + * Copyright (C) 2019 Tim Otte + * + * 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/supplier_invoce/doc/doc_generic_supplier_invoice_odt.modules.php + * \ingroup facture + * \brief File of class to build ODT documents for supplier invoices + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_invoice/modules_facturefournisseur.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/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; + + +/** + * Class to build documents using ODF templates generator + */ +class doc_generic_supplier_invoice_odt extends ModelePDFSuppliersInvoices +{ + /** + * Issuer + * @var Societe + */ + public $issuer; + + /** + * @var array Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.6 = array(5, 6) + */ + public $phpmin = array(5, 6); + + /** + * @var string Dolibarr version of the loaded document + */ + 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", "companies")); + + $this->db = $db; + $this->name = "ODT templates"; + $this->description = $langs->trans("DocumentModelOdt"); + $this->scandir = 'SUPPLIER_INVOICE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + // Page size for A4 format + $this->type = 'odt'; + $this->page_largeur = 0; + $this->page_hauteur = 0; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = 0; + $this->marge_droite = 0; + $this->marge_haute = 0; + $this->marge_basse = 0; + + $this->option_logo = 1; // Display logo + $this->option_tva = 0; // Manage the vat option FACTURE_TVAOPTION + $this->option_modereg = 0; // Display payment mode + $this->option_condreg = 0; // Display payment terms + $this->option_codeproduitservice = 0; // Display product-service code + $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 = 0; // Support add of a watermark on drafts + + // Recupere issuer + $this->issuer = $mysoc; + if (!$this->issuer->country_code) { + $this->issuer->country_code = substr($langs->defaultlang, -2); // By default if not defined + } + } + + + /** + * Return description of a module + * + * @param Translate $langs Lang object to use for output + * @return string Description + */ + public function info($langs) + { + global $conf, $langs; + + // Load translation files required by the page + $langs->loadLangs(array("errors", "companies")); + + $form = new Form($this->db); + + $texte = $this->description.".
\n"; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'.$langs->trans("DefaultModelPropalCreate").''.$langs->trans("DefaultModelPropalCreate").''; $texte .= $form->selectarray('value2', $list, $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT); $texte .= "
'.$langs->trans("DefaultModelPropalToBill").''.$langs->trans("DefaultModelPropalToBill").''; $texte .= $form->selectarray('value3', $list, $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL); $texte .= "
'.$langs->trans("DefaultModelPropalClosed").''.$langs->trans("DefaultModelPropalClosed").''; $texte .= $form->selectarray('value4', $list, $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED); $texte .= "
'; + + // List of directories area + $texte .= ''; + + + $texte .= ''; + $texte .= ''; + + $texte .= '
'; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->SUPPLIER_INVOICE_ADDON_PDF_ODT_PATH))); + + + $listoffiles = array(); + foreach ($listofdir as $key => $tmpdir) { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { + unset($listofdir[$key]); + continue; + } + if (!is_dir($tmpdir)) { + $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + } else { + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) { + $listoffiles = array_merge($listoffiles, $tmpfiles); + } + } + } + + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); + // 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 .= '
'; + $texte .= ''; + $texte .= '
'; + $texte .= ''; + $texte .= '
'; + + // Scan directories + $nbofiles = count($listoffiles); + if (!empty($conf->global->SUPPLIER_INVOICE_ADDON_PDF_ODT_PATH)) { + $texte .= $langs->trans("NumberOfModelFilesFound").': '; + //$texte.=$nbofiles?'':''; + $texte .= count($listoffiles); + //$texte.=$nbofiles?'':''; + $texte .= ''; + } + + if ($nbofiles) { + $texte .= '
'; + // Show list of found files + foreach ($listoffiles as $file) { + $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').'
'; + } + $texte .= '
'; + } + // Add input to upload a new template file. + $texte .= '
'.$langs->trans("UploadNewTemplate").' '; + $texte .= ''; + $texte .= ''; + $texte .= '
'; + $texte .= '
'; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= '
'; + $texte .= '
'; + + return $texte; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Function to build a document on disk using the generic odt module. + * + * @param Commande $object Object source to build document + * @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 if OK, <=0 if KO + */ + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + { + // phpcs:enable + global $user, $langs, $conf, $mysoc, $hookmanager; + + if (empty($srctemplatepath)) { + dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING); + return -1; + } + + // Add odtgeneration hook + if (!is_object($hookmanager)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($this->db); + } + $hookmanager->initHooks(array('odtgeneration')); + global $action; + + if (!is_object($outputlangs)) { + $outputlangs = $langs; + } + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; + + $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); + + if ($conf->fournisseur->facture->dir_output) { + $object->fetch_thirdparty(); + + if ($object->specimen) { + $dir = $conf->fournisseur->facture->dir_output; + $file = $dir."/SPECIMEN.pdf"; + } else { + $objectref = dol_sanitizeFileName($object->ref); + $objectrefsupplier = dol_sanitizeFileName($object->ref_supplier); + //$dir = $conf->fournisseur->facture->dir_output.'/'.$objectref; + $dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$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 -1; + } + } + + if (file_exists($dir)) { + //print "srctemplatepath=".$srctemplatepath; // Src filename + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); + $newfiletmp = $objectref.'_'.$newfiletmp; + //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; + // Get extension (ods or odt) + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); + if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') { + $format = '%Y%m%d%H%M%S'; + } + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + } else { + $filename = $newfiletmp.'.'.$newfileformat; + } + $file = $dir.'/'.$filename; + //print "newdir=".$dir; + //print "newfile=".$newfile; + //print "file=".$file; + //print "conf->societe->dir_temp=".$conf->societe->dir_temp; + + dol_mkdir($conf->fournisseur->facture->dir_temp); + if (!is_writable($conf->fournisseur->facture->dir_temp)) { + $this->error = "Failed to write in temp directory ".$conf->fournisseur->facture->dir_temp; + dol_syslog('Error in write_file: '.$this->error, LOG_ERR); + return -1; + } + + // If CUSTOMER contact defined on invoice, we use it + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); + if (count($arrayidcontact) > 0) { + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); + } + + // Recipient name + $contactobject = null; + if (!empty($usecontact)) { + // We can use the company of contact instead of thirdparty company + 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))) { + $object->contact->fetch_thirdparty(); + $socobject = $object->contact->thirdparty; + $contactobject = $object->contact; + } else { + $socobject = $object->thirdparty; + // if we have a CUSTOMER contact and we dont use it as thirdparty recipient we store the contact object for later use + $contactobject = $object->contact; + } + } else { + $socobject = $object->thirdparty; + } + + // Make substitution + $substitutionarray = array( + '__FROM_NAME__' => $this->issuer->name, + '__FROM_EMAIL__' => $this->issuer->email, + '__TOTAL_TTC__' => $object->total_ttc, + '__TOTAL_HT__' => $object->total_ht, + '__TOTAL_VAT__' => $object->total_tva + ); + complete_substitutions_array($substitutionarray, $langs, $object); + // Call the ODTSubstitution hook + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + // Line of free text + $newfreetext = ''; + $paramfreetext = 'INVOICE_FREE_TEXT'; + if (!empty($conf->global->$paramfreetext)) { + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); + } + + // Open and load template + require_once ODTPHP_PATH.'odf.php'; + try { + $odfHandler = new odf( + $srctemplatepath, + array( + 'PATH_TO_TMP' => $conf->fournisseur->dir_temp, + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'DELIMITER_LEFT' => '{', + 'DELIMITER_RIGHT' => '}' + ) + ); + } catch (Exception $e) { + $this->error = $e->getMessage(); + dol_syslog($e->getMessage(), LOG_INFO); + return -1; + } + // After construction $odfHandler->contentXml contains content and + // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by + // [!-- BEGIN lines --]*[!-- END lines --] + //print html_entity_decode($odfHandler->__toString()); + //print exit; + + + // Make substitutions into odt of freetext + try { + $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); + } catch (OdfException $e) { + dol_syslog($e->getMessage(), LOG_INFO); + } + + // Define substitution array + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs); + $array_objet = $this->get_substitutionarray_object($object, $outputlangs); + $array_user = $this->get_substitutionarray_user($user, $outputlangs); + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $array_other = $this->get_substitutionarray_other($outputlangs); + // retrieve contact information for use in object as contact_xxx tags + $array_thirdparty_contact = array(); + if ($usecontact && is_object($contactobject)) { + $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); + } + + $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact); + complete_substitutions_array($tmparray, $outputlangs, $object); + + // Call the ODTSubstitution hook + $parameters = array('odfHandler'=>&$odfHandler, '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 + + foreach ($tmparray as $key => $value) { + try { + if (preg_match('/logo$/', $key)) { // Image + if (file_exists($value)) { + $odfHandler->setImage($key, $value); + } else { + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); + } + } else // Text + { + $odfHandler->setVars($key, $value, true, 'UTF-8'); + } + } catch (OdfException $e) { + dol_syslog($e->getMessage(), LOG_INFO); + } + } + // Replace tags of lines + try { + $foundtagforlines = 1; + try { + $listlines = $odfHandler->setSegment('lines'); + } catch (OdfException $e) { + // We may arrive here if tags for lines not present into template + $foundtagforlines = 0; + dol_syslog($e->getMessage(), LOG_INFO); + } + if ($foundtagforlines) { + $linenumber = 0; + foreach ($object->lines as $line) { + $linenumber++; + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber); + complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); + // Call the ODTSubstitutionLine hook + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); + $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + foreach ($tmparray as $key => $val) { + try { + $listlines->setVars($key, $val, true, 'UTF-8'); + } catch (OdfException $e) { + dol_syslog($e->getMessage(), LOG_INFO); + } catch (SegmentException $e) { + dol_syslog($e->getMessage(), LOG_INFO); + } + } + $listlines->merge(); + } + $odfHandler->mergeSegment($listlines); + } + } catch (OdfException $e) { + $this->error = $e->getMessage(); + dol_syslog($this->error, LOG_WARNING); + return -1; + } + + // Replace labels translated + $tmparray = $outputlangs->get_translations_for_substitutions(); + foreach ($tmparray as $key => $value) { + try { + $odfHandler->setVars($key, $value, true, 'UTF-8'); + } catch (OdfException $e) { + dol_syslog($e->getMessage(), LOG_INFO); + } + } + + // Call the beforeODTSave hook + + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + // Write new file + if (!empty($conf->global->MAIN_ODT_AS_PDF)) { + try { + $odfHandler->exportAsAttachedPDF($file); + } catch (Exception $e) { + $this->error = $e->getMessage(); + dol_syslog($e->getMessage(), LOG_INFO); + return -1; + } + } else { + try { + $odfHandler->saveToDisk($file); + } catch (Exception $e) { + $this->error = $e->getMessage(); + dol_syslog($e->getMessage(), LOG_INFO); + return -1; + } + } + + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + if (!empty($conf->global->MAIN_UMASK)) { + @chmod($file, octdec($conf->global->MAIN_UMASK)); + } + + $odfHandler = null; // Destroy object + + $this->result = array('fullpath'=>$file); + + return 1; // Success + } else { + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); + return -1; + } + } + + return -1; + } +} 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 29231e62966..802abd6a184 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -161,7 +161,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $this->posxdiscount = 162; $this->postotalht = 174; - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $this->posxtva = 99; $this->posxup = 114; $this->posxqty = 130; @@ -480,7 +480,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); // Enough for 6 chars // Unit - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); $pdf->SetXY($this->posxunit, $curY); $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L'); @@ -680,11 +680,11 @@ class pdf_canelle extends ModelePDFSuppliersInvoices // Total HT $pdf->SetFillColor(255, 255, 255); - $pdf->SetXY($col1x, $tab2_top + 0); + $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 + 0); + $pdf->SetXY($col2x, $tab2_top); $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0, 'R', 1); // Show VAT by rates and total @@ -932,7 +932,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); } - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxunit - 1, $tab_top + 1); diff --git a/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php b/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php index 546596ab640..de56773eae2 100644 --- a/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php +++ b/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php @@ -51,8 +51,6 @@ abstract class ModelePDFSuppliersInvoices extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'invoice_supplier'; $list = array(); 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 12bbcc12edc..ca7d1b3d61b 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 @@ -261,7 +261,7 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile = basename($srctemplatepath); - $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile); $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); $newfiletmp = $objectref . '_' . $newfiletmp; 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 df584684f62..186ea465568 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -972,11 +972,11 @@ class pdf_cornas extends ModelePDFSuppliersOrders // Total HT $pdf->SetFillColor(255, 255, 255); - $pdf->SetXY($col1x, $tab2_top + 0); + $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 + 0); + $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 @@ -1241,9 +1241,9 @@ class pdf_cornas extends ModelePDFSuppliersOrders //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); //Affiche le filigrane brouillon - Print Draft Watermark - /*if($object->statut==0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK)) ) + /*if($object->statut==0 && getDolGlobalString('COMMANDE_DRAFT_WATERMARK')) { - pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK); + pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',getDolGlobalString('COMMANDE_DRAFT_WATERMARK')); }*/ //Print content @@ -1256,13 +1256,13 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (empty($conf->global->PDF_DISABLE_MYCOMPANY_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 (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { + if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { $logo = $logodir.'/logos/'.$this->emetteur->logo; @@ -1623,7 +1623,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders ), 'border-left' => true, // add left line separator ); - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $this->cols['unit']['status'] = true; } diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index 5082c14a144..226c9dc6efa 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -169,7 +169,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $this->posxdiscount = 162; $this->postotalht = 174; - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $this->posxtva = 95; $this->posxup = 114; $this->posxqty = 132; @@ -552,7 +552,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); // Enough for 6 chars // Unit - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); $pdf->SetXY($this->posxunit, $curY); $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L'); @@ -853,11 +853,11 @@ class pdf_muscadet extends ModelePDFSuppliersOrders // Total HT $pdf->SetFillColor(255, 255, 255); - $pdf->SetXY($col1x, $tab2_top + 0); + $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 + 0); + $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 @@ -1097,7 +1097,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); } - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxunit - 1, $tab_top + 1); @@ -1150,9 +1150,9 @@ class pdf_muscadet extends ModelePDFSuppliersOrders //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); //Affiche le filigrane brouillon - Print Draft Watermark - /*if($object->statut==0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK)) ) + /*if($object->statut==0 && getDolGlobalString('COMMANDE_DRAFT_WATERMARK')) { - pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK); + pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',getDolGlobalString('COMMANDE_DRAFT_WATERMARK')); }*/ //Print content @@ -1165,13 +1165,13 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (empty($conf->global->PDF_DISABLE_MYCOMPANY_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 (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { + if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { $logo = $logodir.'/logos/'.$this->emetteur->logo; diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php index 5aa92995c4c..7ebc035ef61 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php @@ -178,7 +178,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders * * @param Societe $objsoc Object third party * @param Object $object Object - * @return string Texte descripif + * @return string Descriptive text */ public function commande_get_num($objsoc = 0, $object = '') { 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 8f67f28b42d..f829048e623 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php @@ -59,7 +59,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { @@ -150,7 +150,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders * * @param Societe $objsoc Object third party * @param Object $object Object - * @return string Texte descripif + * @return string Descriptive text */ public function commande_get_num($objsoc = 0, $object = '') { diff --git a/htdocs/core/modules/supplier_order/modules_commandefournisseur.php b/htdocs/core/modules/supplier_order/modules_commandefournisseur.php index 51c4e5f07d3..e8b66bb84cf 100644 --- a/htdocs/core/modules/supplier_order/modules_commandefournisseur.php +++ b/htdocs/core/modules/supplier_order/modules_commandefournisseur.php @@ -54,8 +54,6 @@ abstract class ModelePDFSuppliersOrders extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'order_supplier'; $list = array(); 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 292662a14ad..a3e938a38ac 100644 --- a/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php +++ b/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php @@ -57,7 +57,7 @@ class mod_supplier_payment_brodator extends ModeleNumRefSupplierPayments /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/supplier_payment/modules_supplier_payment.php b/htdocs/core/modules/supplier_payment/modules_supplier_payment.php index c5db770bdb4..93195edec24 100644 --- a/htdocs/core/modules/supplier_payment/modules_supplier_payment.php +++ b/htdocs/core/modules/supplier_payment/modules_supplier_payment.php @@ -17,6 +17,8 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; + + /** * Parent class for supplier invoices models */ @@ -74,8 +76,6 @@ abstract class ModelePDFSuppliersPayments extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'supplier_payment'; $list = array(); @@ -87,8 +87,9 @@ abstract class ModelePDFSuppliersPayments extends CommonDocGenerator } /** - * \class ModeleNumRefSupplierPayments - * \brief Payment numbering references mother class + * ModeleNumRefSupplierPayments + * + * Payment numbering references mother class */ abstract class ModeleNumRefSupplierPayments @@ -111,7 +112,7 @@ abstract class ModeleNumRefSupplierPayments /** * Return the default description of numbering module * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { 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 55a7710c5a4..8fca5110896 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 @@ -295,7 +295,7 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile = basename($srctemplatepath); - $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile); $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 6cb651b49fd..ff90b500969 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -22,9 +22,9 @@ */ /** - * \file htdocs/core/modules/propale/doc/pdf_azur.modules.php + * \file htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php * \ingroup propale - * \brief File of the class allowing to generate the supplier propals to the Aurore model + * \brief File of the class allowing to generate the supplier proposals to the Aurore model */ require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_proposal/modules_supplier_proposal.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -167,7 +167,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $this->posxdiscount = 162; $this->postotalht = 174; - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $this->posxup = 112; $this->posxqty = 135; $this->posxunit = 151; @@ -527,7 +527,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); // Enough for 6 chars // Unit - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); $pdf->SetXY($this->posxunit, $curY); $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L'); @@ -744,7 +744,7 @@ class pdf_aurore extends ModelePDFSupplierProposal * @param Object $object Object to show * @param int $posy Y * @param Translate $outputlangs Langs object - * @return void + * @return int */ protected function _tableau_info(&$pdf, $object, $posy, $outputlangs) { @@ -925,11 +925,12 @@ class pdf_aurore extends ModelePDFSupplierProposal // Total HT $pdf->SetFillColor(255, 255, 255); - $pdf->SetXY($col1x, $tab2_top + 0); + $pdf->SetXY($col1x, $tab2_top); $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + 0); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 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, $outputlangs), 0, 'R', 1); // Show VAT by rates and total $pdf->SetFillColor(248, 248, 248); @@ -1199,7 +1200,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); } - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxunit - 1, $tab_top + 1); @@ -1253,13 +1254,13 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (empty($conf->global->PDF_DISABLE_MYCOMPANY_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 (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { + if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { $logo = $logodir.'/logos/'.$this->emetteur->logo; 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 c73a8a16db6..d4282eb80ec 100644 --- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php +++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php @@ -60,7 +60,7 @@ class mod_supplier_proposal_saphir extends ModeleNumRefSupplierProposal /** * Return description of module * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php b/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php index 5a3d9e2280a..f1fbf2f9890 100644 --- a/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php +++ b/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php @@ -53,8 +53,6 @@ abstract class ModelePDFSupplierProposal extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'supplier_proposal'; $list = array(); @@ -87,9 +85,9 @@ abstract class ModeleNumRefSupplierProposal } /** - * Renvoi la description par defaut du modele de numerotation + * Returns the default description of the numbering pattern * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/takepos/mod_takepos_ref_universal.php b/htdocs/core/modules/takepos/mod_takepos_ref_universal.php index 7b515ca6b3b..3ebc5858ae4 100644 --- a/htdocs/core/modules/takepos/mod_takepos_ref_universal.php +++ b/htdocs/core/modules/takepos/mod_takepos_ref_universal.php @@ -54,7 +54,7 @@ class mod_takepos_ref_universal extends ModeleNumRefTakepos /** * return description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/takepos/modules_takepos.php b/htdocs/core/modules/takepos/modules_takepos.php index 89b3dbde5bc..bd554a85a65 100644 --- a/htdocs/core/modules/takepos/modules_takepos.php +++ b/htdocs/core/modules/takepos/modules_takepos.php @@ -52,9 +52,9 @@ abstract class ModeleNumRefTakepos } /** - * Renvoi la description par defaut du modele de numerotation + * Returns the default description of the numbering pattern * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { 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 1a2d1e537cc..e175115ac28 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 @@ -122,7 +122,7 @@ class doc_generic_ticket_odt extends ModelePDFTicket // List of directories area $texte .= '
'; $texttitle = $langs->trans("ListOfDirectories"); - $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->TICKET_ADDON_PDF_ODT_PATH))); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim(getDolGlobalString('TICKET_ADDON_PDF_ODT_PATH')))); $listoffiles = array(); foreach ($listofdir as $key => $tmpdir) { $tmpdir = trim($tmpdir); @@ -148,7 +148,7 @@ class doc_generic_ticket_odt extends ModelePDFTicket $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); $texte .= '
'; $texte .= ''; $texte .= '
'; $texte .= ''; @@ -264,7 +264,7 @@ class doc_generic_ticket_odt extends ModelePDFTicket if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile = basename($srctemplatepath); - $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile); $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); diff --git a/htdocs/core/modules/ticket/mod_ticket_universal.php b/htdocs/core/modules/ticket/mod_ticket_universal.php index 8efc2f6a4e5..8cd2cd6f614 100644 --- a/htdocs/core/modules/ticket/mod_ticket_universal.php +++ b/htdocs/core/modules/ticket/mod_ticket_universal.php @@ -55,7 +55,7 @@ class mod_ticket_universal extends ModeleNumRefTicket /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/ticket/modules_ticket.php b/htdocs/core/modules/ticket/modules_ticket.php index c8561382436..aaf9fb2e11b 100644 --- a/htdocs/core/modules/ticket/modules_ticket.php +++ b/htdocs/core/modules/ticket/modules_ticket.php @@ -44,8 +44,6 @@ abstract class ModelePDFTicket extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'ticket'; $list = array(); @@ -78,9 +76,9 @@ abstract class ModeleNumRefTicket } /** - * Renvoi la description par defaut du modele de numerotation + * Returns the default description of the numbering pattern * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { 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 1c3e346203b..00edf04fac0 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 @@ -295,7 +295,7 @@ class doc_generic_user_odt extends ModelePDFUser if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile = basename($srctemplatepath); - $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile); $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); diff --git a/htdocs/core/modules/user/modules_user.class.php b/htdocs/core/modules/user/modules_user.class.php index b0142687ce5..d20e5e95eb8 100644 --- a/htdocs/core/modules/user/modules_user.class.php +++ b/htdocs/core/modules/user/modules_user.class.php @@ -55,8 +55,6 @@ abstract class ModelePDFUser extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'user'; $list = array(); 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 4bbb39c0086..a5447260a2f 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 @@ -277,7 +277,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile = basename($srctemplatepath); - $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile); $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); diff --git a/htdocs/core/modules/usergroup/modules_usergroup.class.php b/htdocs/core/modules/usergroup/modules_usergroup.class.php index 99ee232fdf2..2c4aebe1e6f 100644 --- a/htdocs/core/modules/usergroup/modules_usergroup.class.php +++ b/htdocs/core/modules/usergroup/modules_usergroup.class.php @@ -55,8 +55,6 @@ abstract class ModelePDFUserGroup extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'group'; $list = array(); diff --git a/htdocs/core/modules/workstation/mod_workstation_advanced.php b/htdocs/core/modules/workstation/mod_workstation_advanced.php index 125aa0f7c53..253e4224b64 100644 --- a/htdocs/core/modules/workstation/mod_workstation_advanced.php +++ b/htdocs/core/modules/workstation/mod_workstation_advanced.php @@ -55,7 +55,7 @@ class mod_workstation_advanced extends ModeleNumRefWorkstation /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/modules/workstation/modules_workstation.php b/htdocs/core/modules/workstation/modules_workstation.php index c8052ed4ff8..b72d34f5812 100644 --- a/htdocs/core/modules/workstation/modules_workstation.php +++ b/htdocs/core/modules/workstation/modules_workstation.php @@ -50,8 +50,6 @@ abstract class ModelePDFWorkstation extends CommonDocGenerator public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable - global $conf; - $type = 'workstation'; $list = array(); @@ -87,7 +85,7 @@ abstract class ModeleNumRefWorkstation /** * Returns the default description of the numbering template * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/core/search.php b/htdocs/core/search.php index 321fc94a925..333cb218e58 100644 --- a/htdocs/core/search.php +++ b/htdocs/core/search.php @@ -50,6 +50,7 @@ if (!defined('NOREQUIREMENU')) { require_once '../main.inc.php'; + /* * Actions */ @@ -128,11 +129,11 @@ if (GETPOST('search_task') != '') { } if (GETPOST('search_user') != '') { - header("Location: ".DOL_URL_ROOT.'/user/list.php?mode=search&sall='.urlencode(GETPOST('search_user'))); + header("Location: ".DOL_URL_ROOT.'/user/list.php?search_all='.urlencode(GETPOST('search_user'))); exit; } if (GETPOST('search_group') != '') { - header("Location: ".DOL_URL_ROOT.'/user/group/list.php?mode=search&sall='.urlencode(GETPOST('search_group'))); + header("Location: ".DOL_URL_ROOT.'/user/group/list.php?search_all='.urlencode(GETPOST('search_group'))); exit; } diff --git a/htdocs/core/tpl/advtarget.tpl.php b/htdocs/core/tpl/advtarget.tpl.php index 8f27d747fab..55d5c5ed24a 100644 --- a/htdocs/core/tpl/advtarget.tpl.php +++ b/htdocs/core/tpl/advtarget.tpl.php @@ -198,7 +198,7 @@ if (!empty($array_query['cust_prospect_status'])) { print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); } print '
'; -print $formadvtargetemaling->multiselectProspectionStatus($array_query['cust_prospect_status'], 'cust_prospect_status', 1); +print $formadvtargetemaling->multiselectProspectionStatus($array_query['cust_prospect_status'], 'cust_prospect_status'); print ''."\n"; print '
'; -//print ''; -//print ''; - print ''; print_liste_field_titre($arrayfields['thirdparty']['label'], $_SERVER["PHP_SELF"], "thirdparty_name", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($arrayfields['contact']['label'], $_SERVER["PHP_SELF"], "contact_name", "", $param, "", $sortfield, $sortorder); @@ -316,7 +313,17 @@ foreach ($list as $entry) { print ""; } - +if (empty($list)) { + $colspan = 5 + ($permission ? 1 : 0); + print ''; +} print "
'; + if (is_object($object) && !empty($object->thirdparty)) { + print $form->textwithpicto($langs->trans("NoSpecificContactAddress"), $langs->trans("NoSpecificContactAddressBis")); + } else { + print $langs->trans("NoSpecificContactAddress"); + } + print ''; + print '
"; print '
'; diff --git a/htdocs/core/tpl/filemanager.tpl.php b/htdocs/core/tpl/filemanager.tpl.php index 29506584e61..b3edcb7984f 100644 --- a/htdocs/core/tpl/filemanager.tpl.php +++ b/htdocs/core/tpl/filemanager.tpl.php @@ -44,13 +44,13 @@ $permtoadd = 0; $permtoupload = 0; $showroot = 0; if ($module == 'ecm') { - $permtoadd = $user->rights->ecm->setup; - $permtoupload = $user->rights->ecm->upload; + $permtoadd = $user->hasRight("ecm", "setup"); + $permtoupload = $user->hasRight("ecm", "upload"); $showroot = 0; } if ($module == 'medias') { - $permtoadd = ($user->rights->mailing->creer || $user->rights->website->write); - $permtoupload = ($user->rights->mailing->creer || $user->rights->website->write); + $permtoadd = ($user->hasRight("mailing", "creer") || $user->hasRight("website", "write")); + $permtoupload = ($user->hasRight("mailing", "creer") || $user->hasRight("website", "write")); $showroot = 1; } diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index eaf2d602571..7f97e751ded 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -98,7 +98,7 @@ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $disablenofollow = 0; } -print top_htmlhead('', $titleofloginpage, 0, 0, $arrayofjs, array(), 1, $disablenofollow); +top_htmlhead('', $titleofloginpage, 0, 0, $arrayofjs, array(), 1, $disablenofollow); $colorbackhmenu1 = '60,70,100'; // topmenu diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index 5124a1dce35..ad46d605f33 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -167,8 +167,9 @@ if ($massaction == 'presend') { $thirdpartyid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid); // For proposal, order, invoice, conferenceorbooth, ... if (in_array($objecttmp->element, array('societe', 'conferenceorboothattendee'))) { $thirdpartyid = $objecttmp->id; - } - if ($objecttmp->element == 'expensereport') { + } elseif ($objecttmp->element == 'contact') { + $thirdpartyid = $objecttmp->id; + } elseif ($objecttmp->element == 'expensereport') { $thirdpartyid = $objecttmp->fk_user_author; } if (empty($thirdpartyid)) { @@ -205,6 +206,10 @@ if ($massaction == 'presend') { $fuser = new User($db); $fuser->fetch($thirdpartyid); $liste['thirdparty'] = $fuser->getFullName($langs)." <".$fuser->email.">"; + } elseif ($objecttmp->element == 'contact') { + $fcontact = new Contact($db); + $fcontact->fetch($thirdpartyid); + $liste['contact'] = $fcontact->getFullName($langs)." <".$fcontact->email.">"; } elseif ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { $fadherent = new Adherent($db); $fadherent->fetch($objecttmp->fk_member); @@ -236,17 +241,23 @@ if ($massaction == 'presend') { } else { $formmail->withtopic = 1; } - $formmail->withfile = 1; // $formmail->withfile = 2 to allow to upload files is not yet supported in mass action - // Add a checkbox "Attach also main document" - if (isset($withmaindocfilemail)) { - $formmail->withmaindocfile = $withmaindocfilemail; - } else { // Do an automatic definition of $formmail->withmaindocfile - $formmail->withmaindocfile = 1; - if ($objecttmp->element != 'societe') { - $formmail->withfile = ''.$langs->trans("OnlyPDFattachmentSupported").''; - $formmail->withmaindocfile = -1; // Add a checkbox "Attach also main document" but not checked by default + if ($objecttmp->element == 'contact') { + $formmail->withfile = 0; + $formmail->withmaindocfile = 0; // Add a checkbox "Attach also main document" + } else { + $formmail->withfile = 1; // $formmail->withfile = 2 to allow to upload files is not yet supported in mass action + // Add a checkbox "Attach also main document" + if (isset($withmaindocfilemail)) { + $formmail->withmaindocfile = $withmaindocfilemail; + } else { // Do an automatic definition of $formmail->withmaindocfile + $formmail->withmaindocfile = 1; + if ($objecttmp->element != 'societe') { + $formmail->withfile = '' . $langs->trans("OnlyPDFattachmentSupported") . ''; + $formmail->withmaindocfile = -1; // Add a checkbox "Attach also main document" but not checked by default + } } } + $formmail->withbody = 1; $formmail->withdeliveryreceipt = 1; $formmail->withcancel = 1; diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index c0382a39de4..32a9f1cdaae 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -127,7 +127,7 @@ if ($nolinesbefore) {
trans('Qty'); ?> '; print ''; print $langs->trans('Unit'); @@ -214,7 +214,7 @@ if ($nolinesbefore) { echo ' '; } } - echo $form->select_type_of_lines(GETPOSTISSET("type") ? GETPOST("type", 'alpha', 2) : -1, 'type', 1, 1, $forceall); + $form->select_type_of_lines(GETPOSTISSET("type") ? GETPOST("type", 'alpha', 2) : -1, 'type', 1, 1, $forceall); echo ''; } // Predefined product/service @@ -424,7 +424,7 @@ if ($nolinesbefore) { "> '; print $form->selectUnits(empty($line->fk_unit) ? $conf->global->PRODUCT_USE_UNITS : $line->fk_unit, "units"); @@ -511,7 +511,7 @@ if ((isModEnabled("service") || ($object->element == 'contrat')) && $dateSelecto print $form->selectDate($date_start, 'date_start', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, 1, "addproduct", 1, 0); print ' '.$langs->trans('to').' '; print $form->selectDate($date_end, 'date_end', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, 1, "addproduct", 1, 0); - }; + } if ($prefillDates) { echo ' '.$langs->trans('FillWithLastServiceDates').''; @@ -774,7 +774,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) { // Now set the VAT var stringforvatrateselection = tva_tx; - if (typeof default_vat_code != 'undefined' && default_vat_code != null) { + if (typeof default_vat_code != 'undefined' && default_vat_code != null && default_vat_code != '') { stringforvatrateselection = stringforvatrateselection+' ('+default_vat_code+')'; } // Set vat rate if field is an input box @@ -937,7 +937,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) { ?> global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { ?> /* To process customer price per quantity (PRODUIT_CUSTOMER_PRICES_BY_QTY works only if combo product is not an ajax after x key pressed) */ var pbq = parseInt($('option:selected', this).attr('data-pbq')); // When select is done from HTML select @@ -971,10 +971,11 @@ if (!empty($usemargins) && $user->rights->margins->creer) { } ?> - // Deal with supplier ref price + + // Deal with supplier ref price (idprodfournprice = int) if (jQuery('#idprodfournprice').val() > 0) { - console.log("objectline_create.tpl #idprodfournprice is > 0, so we set some properties into page"); + console.log("objectline_create.tpl #idprodfournprice is is an ID > 0, so we set some properties into page"); var up = parseFloat($('option:selected', this).attr('data-up')); // When select is done from HTML select if (isNaN(up)) { up = parseFloat(jQuery('#idprodfournprice').attr('data-up'));} // When select is done from HTML input with ajax autocomplete @@ -995,7 +996,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) { if (typeof default_vat_code === 'undefined') { default_vat_code = jQuery('#idprodfournprice').attr('data-default-vat-code');} // When select is done from HTML input with ajax autocomplete var stringforvatrateselection = tva_tx; - if (typeof default_vat_code != 'undefined' && default_vat_code != null) { + if (typeof default_vat_code != 'undefined' && default_vat_code != null && default_vat_code != '') { stringforvatrateselection = stringforvatrateselection+' ('+default_vat_code+')'; } @@ -1023,14 +1024,15 @@ if (!empty($usemargins) && $user->rights->margins->creer) { } global->PRODUIT_AUTOFILL_DESC) && $conf->global->PRODUIT_AUTOFILL_DESC == 1) { + if (getDolGlobalInt('PRODUIT_AUTOFILL_DESC') == 1) { ?> var description = $('option:selected', this).attr('data-description'); if (typeof description == 'undefined') { description = jQuery('#idprodfournprice').attr('data-description'); } console.log("Load desciption into text area : "+description); global->FCKEDITOR_ENABLE_DETAILS)) { ?> + if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) { + ?> if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined") { var editor = CKEDITOR.instances['dp_desc']; @@ -1039,15 +1041,41 @@ if (!empty($usemargins) && $user->rights->margins->creer) { } } + } else { + ?> jQuery('#dp_desc').text(description); + } + ?> } else if (jQuery('#idprodfournprice').length > 0) { + console.log("objectline_create.tpl #idprodfournprice is not an int but is a string so we set only few properties into page"); + + var tva_tx = parseFloat($('option:selected', this).attr('data-tvatx')); // When select is done from HTML select + if (isNaN(tva_tx)) { tva_tx = parseFloat(jQuery('#idprodfournprice').attr('data-tvatx'));} // When select is done from HTML input with ajax autocomplete + + var default_vat_code = $('option:selected', this).attr('data-default-vat-code'); // When select is done from HTML select + if (typeof default_vat_code === 'undefined') { default_vat_code = jQuery('#idprodfournprice').attr('data-default-vat-code');} // When select is done from HTML input with ajax autocomplete + + var stringforvatrateselection = tva_tx; + if (typeof default_vat_code != 'undefined' && default_vat_code != null && default_vat_code != '') { + stringforvatrateselection = stringforvatrateselection+' ('+default_vat_code+')'; + } + + console.log("objectline_create.tpl We find data for price : tva_tx = "+tva_tx+", default_vat_code = "+default_vat_code+", stringforvatrateselection="+stringforvatrateselection+" for product id = "+jQuery('#idprodfournprice').val()); + + // Set vat rate if field is an input box + $('#tva_tx').val(tva_tx); + // Set vat rate by selecting the combo + //$('#tva_tx option').val(tva_tx); // This is bugged, it replaces the vat key of all options + $('#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->PRODUIT_AUTOFILL_DESC) && $conf->global->PRODUIT_AUTOFILL_DESC == 1) { - if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) { ?> + if (getDolGlobalInt('PRODUIT_AUTOFILL_DESC') == 1) { + if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) { + ?> if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined") { var editor = CKEDITOR.instances['dp_desc']; @@ -1056,11 +1084,13 @@ if (!empty($usemargins) && $user->rights->margins->creer) { } } + } else { + ?> jQuery('#dp_desc').text(''); + } + ?> } @@ -1118,7 +1148,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) { jQuery("#multicurrency_price_ttc").val('').hide(); jQuery("#title_up_ttc, #title_up_ttc_currency").hide(); - jQuery("#fourn_ref, #tva_tx, #title_vat").hide(); + jQuery("#tva_tx, #title_vat").hide(); /* jQuery("#title_fourn_ref").hide(); */ jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").hide(); jQuery("#buying_price").show(); diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 5520215d89a..dbc8b407fa5 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -120,7 +120,7 @@ $coldisplay++; print ''; } else { if ($senderissupplier) { - print $form->select_produits_fournisseurs(!empty($line->fk_product) ? $line->fk_product : 0, 'productid'); + $form->select_produits_fournisseurs(!empty($line->fk_product) ? $line->fk_product : 0, 'productid'); } else { print $form->select_produits(!empty($line->fk_product) ? $line->fk_product : 0, 'productid'); } diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 14197b6d052..be24a555a3c 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -255,11 +255,48 @@ if (isModEnabled('accounting') && $line->fk_accounting_account > 0) { } print ''; print ($line->ref_fourn ? $line->ref_fourn : $line->ref_supplier); print ''; $coldisplay++; @@ -276,8 +313,9 @@ if (price2num($line->total_localtax2)) { if (empty($positiverates)) { $positiverates = '0'; } +print $tooltiponprice; print vatrate($positiverates.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''), '%', $line->info_bits); -//print vatrate($line->tva_tx.($line->vat_src_code?(' ('.$line->vat_src_code.')'):''), '%', $line->info_bits); +print $tooltiponpriceend; ?> subprice); ?>marque_tx, 'MT')).'%'; ?> trans('Option'); ?> '.price($sign * $line->multicurrency_total_ht).''.price($sign * $line->total_ttc).''; $coldisplay++; @@ -434,6 +444,7 @@ if ($this->statut == 0 && !empty($object_rights->creer) && $action != 'selectlin print ''; $coldisplay++; if (($line->info_bits & 2) == 2 || !empty($disableedit)) { @@ -443,6 +454,7 @@ if ($this->statut == 0 && !empty($object_rights->creer) && $action != 'selectlin } print ''; $coldisplay++; if (!$situationinvoicelinewithparent && empty($disableremove)) { // For situation invoice, deletion is not possible if there is a parent company. @@ -452,6 +464,7 @@ if ($this->statut == 0 && !empty($object_rights->creer) && $action != 'selectlin } print ''; $coldisplay++; diff --git a/htdocs/core/tpl/passwordforgotten.tpl.php b/htdocs/core/tpl/passwordforgotten.tpl.php index 3fdbcd14ef3..e9d7de9a1bf 100644 --- a/htdocs/core/tpl/passwordforgotten.tpl.php +++ b/htdocs/core/tpl/passwordforgotten.tpl.php @@ -76,7 +76,7 @@ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $disablenofollow = 0; } -print top_htmlhead('', $titleofpage, 0, 0, $arrayofjs, array(), 1, $disablenofollow); +top_htmlhead('', $titleofpage, 0, 0, $arrayofjs, array(), 1, $disablenofollow); $colorbackhmenu1 = '60,70,100'; // topmenu @@ -253,7 +253,7 @@ if ($mode == 'dolibarr' || !$disabled) { diff --git a/htdocs/core/tpl/passwordreset.tpl.php b/htdocs/core/tpl/passwordreset.tpl.php index 1f35b1a251a..e9d518dba64 100644 --- a/htdocs/core/tpl/passwordreset.tpl.php +++ b/htdocs/core/tpl/passwordreset.tpl.php @@ -77,7 +77,7 @@ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $disablenofollow = 0; } -print top_htmlhead('', $titleofpage, 0, 0, $arrayofjs, array(), 1, $disablenofollow); +top_htmlhead('', $titleofpage, 0, 0, $arrayofjs, array(), 1, $disablenofollow); $colorbackhmenu1 = '60,70,100'; // topmenu @@ -292,7 +292,7 @@ if ($mode == 'dolibarr' || !$disabled) { diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index abaadfc85a8..b6bd9bb73a8 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -90,6 +90,9 @@ class InterfaceWorkflowManager extends DolibarrTriggers $this->error = $newobject->error; $this->errors[] = $newobject->error; } + + $object->clearObjectLinkedCache(); + return $ret; } } @@ -111,6 +114,9 @@ class InterfaceWorkflowManager extends DolibarrTriggers $this->error = $newobject->error; $this->errors[] = $newobject->error; } + + $object->clearObjectLinkedCache(); + return $ret; } } diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index e3f798dec62..be78b6ecc18 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -5,6 +5,7 @@ * Copyright (C) 2013 Cedric GROSS * Copyright (C) 2014 Marcos García * Copyright (C) 2015 Bahfir Abbes + * Copyright (C) 2022 Ferran Marcet * * 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 @@ -861,6 +862,16 @@ class InterfaceActionsAuto extends DolibarrTriggers // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; + } elseif ($action == 'PROJECT_CLOSE') { + // Load translation files required by the page + $langs->loadLangs(array("agenda", "other", "projects")); + + if (empty($object->actionmsg2)) { + $object->actionmsg2 = $langs->transnoentities("ProjectClosedInDolibarr", $object->ref); + } + $object->actionmsg = $langs->transnoentities("ProjectClosedInDolibarr", $object->ref); + + $object->sendtoid = 0; } elseif ($action == 'TASK_CREATE') { // Project tasks // Load translation files required by the page diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index d26c83f4772..b12a2b909cf 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -368,15 +368,15 @@ class Cronjob extends CommonObject $sql .= " ".(!isset($this->datelastresult) || dol_strlen($this->datelastresult) == 0 ? 'NULL' : "'".$this->db->idate($this->datelastresult)."'").","; $sql .= " ".(!isset($this->lastoutput) ? 'NULL' : "'".$this->db->escape($this->lastoutput)."'").","; $sql .= " ".(!isset($this->unitfrequency) ? 'NULL' : "'".$this->db->escape($this->unitfrequency)."'").","; - $sql .= " ".(!isset($this->frequency) ? '0' : $this->frequency).","; - $sql .= " ".(!isset($this->status) ? '0' : $this->status).","; - $sql .= " ".$user->id.","; - $sql .= " ".$user->id.","; + $sql .= " ".(!isset($this->frequency) ? '0' : ((int) $this->frequency)).","; + $sql .= " ".(!isset($this->status) ? '0' : ((int) $this->status)).","; + $sql .= " ".((int) $user->id).","; + $sql .= " ".((int) $user->id).","; $sql .= " ".(!isset($this->note_private) ? 'NULL' : "'".$this->db->escape($this->note_private)."'").","; - $sql .= " ".(!isset($this->nbrun) ? '0' : $this->db->escape($this->nbrun)).","; - $sql .= " ".(empty($this->maxrun) ? '0' : $this->db->escape($this->maxrun)).","; + $sql .= " ".(!isset($this->nbrun) ? '0' : ((int) $this->nbrun)).","; + $sql .= " ".(empty($this->maxrun) ? '0' : ((int) $this->maxrun)).","; $sql .= " ".(!isset($this->libname) ? 'NULL' : "'".$this->db->escape($this->libname)."'").","; - $sql .= " ".(!isset($this->test) ? 'NULL' : "'".$this->db->escape($this->test)."'").""; + $sql .= " ".(!isset($this->test) ? 'NULL' : "'".$this->db->escape($this->test)."'"); $sql .= ")"; $this->db->begin(); diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 30f195b550b..aaccb39e68e 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -448,7 +448,7 @@ print '  '; -print $form->selectarray('search_status', array('0'=>$langs->trans("Disabled"), '1'=>$langs->trans("Scheduled")), $search_status, 1, 0, 0, '', 0, 0, 0, '', 'onrightofpage'); +print $form->selectarray('search_status', array('0'=>$langs->trans("Disabled"), '1'=>$langs->trans("Scheduled")), $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage'); print ''; $searchpicto = $form->showFilterButtons(); print $searchpicto; diff --git a/htdocs/dav/dav.class.php b/htdocs/dav/dav.class.php index a4c98eba8a7..a0375210271 100644 --- a/htdocs/dav/dav.class.php +++ b/htdocs/dav/dav.class.php @@ -143,12 +143,14 @@ class CdavLib $location = trim($location.', '.$obj->soc_country_label); } + /* $address = explode("\n", $obj->address, 2); foreach ($address as $kAddr => $vAddr) { $address[$kAddr] = trim(str_replace(array("\r", "\t"), ' ', str_replace("\n", ' | ', trim($vAddr)))); } $address[] = ''; $address[] = ''; + */ if ($obj->percent == -1 && trim($obj->datep) != '') { $type = 'VEVENT'; @@ -249,7 +251,7 @@ class CdavLib */ public function getFullCalendarObjects($calendarId, $bCalendarData) { - $calid = ($calendarId * 1); + $calid = (int) $calendarId; $calevents = array(); if (!$this->user->rights->agenda->myactions->read) { diff --git a/htdocs/debugbar/class/DebugBar.php b/htdocs/debugbar/class/DebugBar.php index b2ec0f17bf0..bf797e638f7 100644 --- a/htdocs/debugbar/class/DebugBar.php +++ b/htdocs/debugbar/class/DebugBar.php @@ -55,9 +55,10 @@ class DolibarrDebugBar extends DebugBar public function getRenderer() { $renderer = parent::getJavascriptRenderer(DOL_URL_ROOT.'/includes/maximebf/debugbar/src/DebugBar/Resources'); - //$renderer->disableVendor('jquery'); - $renderer->disableVendor('fontawesome'); - $renderer->disableVendor('highlightjs'); + $renderer->disableVendor('jquery'); // We already have jquery loaded globally by the main.inc.php + $renderer->disableVendor('fontawesome'); // We already have fontawesome loaded globally by the main.inc.php + $renderer->disableVendor('highlightjs'); // We don't need this + $renderer->setEnableJqueryNoConflict(false); // We don't need no conflict return $renderer; } } diff --git a/htdocs/debugbar/class/TraceableDB.php b/htdocs/debugbar/class/TraceableDB.php index 0b862f4df70..9f0a83fae3c 100644 --- a/htdocs/debugbar/class/TraceableDB.php +++ b/htdocs/debugbar/class/TraceableDB.php @@ -251,18 +251,6 @@ class TraceableDB extends DoliDB return $this->db->escape($stringtoencode); } - /** - * Escape a string to insert data - * - * @param string $stringtoencode String to escape - * @return string String escaped - * @deprecated - */ - public function escapeunderscore($stringtoencode) - { - return $this->db->escapeunderscore($stringtoencode); - } - /** * Escape a string to insert data into a like * @@ -661,7 +649,7 @@ class TraceableDB extends DoliDB */ public function free($resultset = null) { - return $this->db->free($resultset); + $this->db->free($resultset); } /** diff --git a/htdocs/delivery/card.php b/htdocs/delivery/card.php index b98b75015ab..3a269cc89bb 100644 --- a/htdocs/delivery/card.php +++ b/htdocs/delivery/card.php @@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; if (isModEnabled("product") || isModEnabled("service")) { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; } -if (!empty($conf->expedition_bon->enabled)) { +if (isModEnabled('expedition_bon')) { require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; } if (isModEnabled('stock')) { diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index 73fc15e6911..3b560ce1026 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -1085,18 +1085,18 @@ class Delivery extends CommonObject /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'delivery' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index b52e0974b9a..158c96cb441 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -206,7 +206,7 @@ class Don extends CommonObject */ public function initAsSpecimen() { - global $conf, $user, $langs; + global $conf; $now = dol_now(); @@ -224,10 +224,10 @@ class Don extends CommonObject $num_socs = $this->db->num_rows($resql); $i = 0; while ($i < $num_socs) { - $i++; - $row = $this->db->fetch_row($resql); $socids[$i] = $row[0]; + + $i++; } } @@ -237,7 +237,7 @@ class Don extends CommonObject $this->specimen = 1; $this->lastname = 'Doe'; $this->firstname = 'John'; - $this->socid = 1; + $this->socid = empty($socids[0]) ? 0 : $socids[0]; $this->date = $now; $this->date_valid = $now; $this->amount = 100.90; @@ -1101,18 +1101,18 @@ class Don extends CommonObject /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old third-party id - * @param int $dest_id New third-party id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'don' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** diff --git a/htdocs/don/class/donstats.class.php b/htdocs/don/class/donstats.class.php index 07eb6d6588e..bd52f10dbc4 100644 --- a/htdocs/don/class/donstats.class.php +++ b/htdocs/don/class/donstats.class.php @@ -68,10 +68,11 @@ class DonationStats extends Stats */ public function __construct($db, $socid, $mode, $userid = 0) { - global $user, $conf; + global $conf; $this->db = $db; + $this->field = 'amount'; $this->socid = ($socid > 0 ? $socid : 0); $this->userid = $userid; $this->cachefilesuffix = $mode; @@ -98,8 +99,6 @@ class DonationStats extends Stats */ public function getNbByMonth($year, $format = 0) { - global $user; - $sql = "SELECT date_format(d.datedon,'%m') as dm, COUNT(*) as nb"; $sql .= " FROM ".$this->from; $sql .= " WHERE d.datedon BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; @@ -119,8 +118,6 @@ class DonationStats extends Stats */ public function getNbByYear() { - global $user; - $sql = "SELECT date_format(d.datedon,'%Y') as dm, COUNT(*) as nb, SUM(d.".$this->field.")"; $sql .= " FROM ".$this->from; $sql .= " WHERE ".$this->where; @@ -130,6 +127,45 @@ class DonationStats extends Stats return $this->_getNbByYear($sql); } + /** + * Return the number of subscriptions by month for a given year + * + * @param int $year Year + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @return array Array of amount each month + */ + public function getAmountByMonth($year, $format = 0) + { + $sql = "SELECT date_format(d.datedon,'%m') as dm, sum(d.".$this->field.")"; + $sql .= " FROM ".$this->from; + //if (empty($user->rights->societe->client->voir) && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".dolSqlDateFilter('d.datedon', 0, 0, (int) $year, 1); + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); + + return $this->_getAmountByMonth($year, $sql, $format); + } + + /** + * Return average amount each month + * + * @param int $year Year + * @return array Array of average each month + */ + public function getAverageByMonth($year) + { + $sql = "SELECT date_format(d.datedon,'%m') as dm, avg(d.".$this->field.")"; + $sql .= " FROM ".$this->from; + //if (empty($user->rights->societe->client->voir) && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".dolSqlDateFilter('d.datedon', 0, 0, (int) $year, 1); + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); + + return $this->_getAverageByMonth($year, $sql); + } + /** * Return nb, total and average * @@ -137,8 +173,6 @@ class DonationStats extends Stats */ public function getAllByYear() { - global $user; - $sql = "SELECT date_format(d.datedon,'%Y') as year, COUNT(*) as nb, SUM(d.".$this->field.") as total, AVG(".$this->field.") as avg"; $sql .= " FROM ".$this->from; $sql .= " WHERE ".$this->where; diff --git a/htdocs/don/class/paymentdonation.class.php b/htdocs/don/class/paymentdonation.class.php index b42f5fb4e4d..657a1d32d1a 100644 --- a/htdocs/don/class/paymentdonation.class.php +++ b/htdocs/don/class/paymentdonation.class.php @@ -347,7 +347,7 @@ class PaymentDonation extends CommonObject $sql .= " note=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; $sql .= " fk_bank=".(isset($this->fk_bank) ? $this->fk_bank : "null").","; $sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").","; - $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? $this->fk_user_modif : "null").""; + $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? $this->fk_user_modif : "null"); $sql .= " WHERE rowid=".(int) $this->id; $this->db->begin(); diff --git a/htdocs/don/list.php b/htdocs/don/list.php index ac704571daa..386a4bc2f6b 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -232,14 +232,14 @@ if ($resql) { print ''; + print ''; $liststatus = array( Don::STATUS_DRAFT=>$langs->trans("DonationStatusPromiseNotValidated"), Don::STATUS_VALIDATED=>$langs->trans("DonationStatusPromiseValidated"), Don::STATUS_PAID=>$langs->trans("DonationStatusPaid"), Don::STATUS_CANCELED=>$langs->trans("Canceled") ); - print $form->selectarray('search_status', $liststatus, $search_status, -4, 0, 0, '', 0, 0, 0, '', 'maxwidth100 onrightofpage'); + print $form->selectarray('search_status', $liststatus, $search_status, -4, 0, 0, '', 0, 0, 0, '', 'search_status maxwidth100 onrightofpage'); print ''; $searchpicto = $form->showFilterAndCheckAddButtons(0); diff --git a/htdocs/don/payment/card.php b/htdocs/don/payment/card.php index 19f40bc984e..416e848d271 100644 --- a/htdocs/don/payment/card.php +++ b/htdocs/don/payment/card.php @@ -181,7 +181,7 @@ if ($resql) { // Expected to pay print ''.price($objp->d_amount).''.$don->getLibStatut(4, $objp->amount).''.$don->getLibStatut(4).''.price($objp->amount).'
'; print ''; print ''; -print ''; +print ''; /*print ''; print '';*/ print ''; @@ -334,7 +334,7 @@ print '
'.$langs->trans("Year").''.$langs->trans("NbOfSendings").''.$langs->trans("NbOfDonations").''.$langs->trans("AmountTotal").''.$langs->trans("AmountAverage").'
'; */ print '
'; -print ''.$langs->trans("StatsOnShipmentsOnlyValidated").''; +print ''.$langs->trans("StatsOnDonationsOnlyValidated").''; llxFooter(); diff --git a/htdocs/ecm/dir_card.php b/htdocs/ecm/dir_card.php index 8be2511a0d7..e45175bb5c7 100644 --- a/htdocs/ecm/dir_card.php +++ b/htdocs/ecm/dir_card.php @@ -94,14 +94,14 @@ $permissiontoread = 0; $permissiontoadd = 0; $permissiontoupload = 0; if ($module == 'ecm') { - $permissiontoread = $user->rights->ecm->read; - $permissiontoadd = $user->rights->ecm->setup; - $permissiontoupload = $user->rights->ecm->upload; + $permissiontoread = $user->hasRight("ecm", "read"); + $permissiontoadd = $user->hasRight("ecm", "setup"); + $permissiontoupload = $user->hasRight("ecm", "upload"); } if ($module == 'medias') { - $permissiontoread = ($user->rights->mailing->lire || $user->rights->website->read); - $permissiontoadd = ($user->rights->mailing->creer || $user->rights->website->write); - $permissiontoupload = ($user->rights->mailing->creer || $user->rights->website->write); + $permissiontoread = ($user->hasRight("mailing", "lire") || $user->hasRight("website", "read")); + $permissiontoadd = ($user->hasRight("mailing", "creer") || $user->hasRight("website", "write")); + $permissiontoupload = ($user->hasRight("mailing", "creer") || $user->hasRight("website", "write")); } if (!$permissiontoread) { diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index 9eb512bc96d..6edf59dcbed 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -322,7 +322,7 @@ $moreheadjs .= ''."\n"; llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', '', '', $morejs, '', 0, 0); -$head = ecm_prepare_dasboard_head(''); +$head = ecm_prepare_dasboard_head(null); print dol_get_fiche_head($head, 'index', '', -1, ''); diff --git a/htdocs/ecm/index_auto.php b/htdocs/ecm/index_auto.php index 342d7d74129..3944e869da0 100644 --- a/htdocs/ecm/index_auto.php +++ b/htdocs/ecm/index_auto.php @@ -309,7 +309,7 @@ llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', '', '', $m // Add sections to manage $rowspan = 0; $sectionauto = array(); -if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) { +if (empty($conf->global->ECM_AUTO_TREE_HIDEN)) { if (isModEnabled("product") || isModEnabled("service")) { $langs->load("products"); $rowspan++; $sectionauto[] = array('position'=>10, 'level'=>1, 'module'=>'product', 'test'=>(isModEnabled("product") || isModEnabled("service")), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); @@ -387,7 +387,7 @@ if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) { } } -$head = ecm_prepare_dasboard_head(''); +$head = ecm_prepare_dasboard_head(null); print dol_get_fiche_head($head, 'index_auto', '', -1, ''); diff --git a/htdocs/ecm/index_medias.php b/htdocs/ecm/index_medias.php index 99a0ac4bc09..39118774430 100644 --- a/htdocs/ecm/index_medias.php +++ b/htdocs/ecm/index_medias.php @@ -37,6 +37,7 @@ $langs->loadLangs(array('ecm', 'companies', 'other', 'users', 'orders', 'propal' // Get parameters $action = GETPOST('action', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); $socid = GETPOST('socid', 'int'); $file_manager = GETPOST('file_manager', 'alpha'); @@ -50,6 +51,7 @@ $overwritefile = GETPOST('overwritefile', 'int'); if (empty($action) && $file_manager) { $action = 'file_manager'; } +$pageid = GETPOST('pageid', 'int'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -293,7 +295,7 @@ $moreheadjs .= ''."\n"; llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', '', '', $morejs, '', 0, 0); -$head = ecm_prepare_dasboard_head(''); +$head = ecm_prepare_dasboard_head(null); print dol_get_fiche_head($head, 'index_medias', '', -1, ''); diff --git a/htdocs/ecm/search.php b/htdocs/ecm/search.php index e37a1ce88f3..c43428fae8e 100644 --- a/htdocs/ecm/search.php +++ b/htdocs/ecm/search.php @@ -175,7 +175,7 @@ print load_fiche_titre($langs->trans("ECMArea").' - '.$langs->trans("Search")); print $langs->trans("FeatureNotYetAvailable").'.

'; // Tool bar -$head = ecm_prepare_head_fm($ecmdir, $module, $section); +$head = ecm_prepare_head_fm($ecmdir); //print dol_get_fiche_head($head, 'search_form', '', 1); diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 8d72666ad53..7dae5bbb6e5 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -881,8 +881,24 @@ class EmailCollector extends CommonObject */ private function overwritePropertiesOfObject(&$object, $actionparam, $messagetext, $subject, $header, &$operationslog) { + global $conf, $langs; + $errorforthisaction = 0; + // set output lang + $outputlangs = $langs; + $newlang = ''; + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } + if (!empty($newlang)) { + $outputlangs = new Translate('', $conf); + $outputlangs->setDefaultLang($newlang); + } + // Overwrite values with values extracted from source email // $this->actionparam = 'opportunity_status=123;abc=EXTRACT:BODY:....' $arrayvaluetouse = dolExplodeIntoArray($actionparam, ';', '='); @@ -978,7 +994,8 @@ class EmailCollector extends CommonObject if ($regforregex[1] == 'SET' || empty($valuecurrent)) { $valuetouse = $regforregex[2]; - $substitutionarray = array(); + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); $matcharray = array(); preg_match_all('/__([a-z0-9]+(?:_[a-z0-9]+)?)__/i', $valuetouse, $matcharray); //var_dump($tmpproperty.' - '.$object->$tmpproperty.' - '.$valuetouse); var_dump($matcharray); @@ -1501,7 +1518,7 @@ class EmailCollector extends CommonObject $trackidfoundintorecipientid = 0; $reg = array(); // See also later list of all supported tags... - if (preg_match('/\+(thi|ctc|use|mem|sub|proj|tas|con|tic|job|pro|ord|inv|spro|sor|sin|leav|stockinv|job|surv|salary)([0-9]+)@/', $emailto, $reg)) { + if (preg_match('/\+(thi|ctc|use|mem|sub|proj|tas|con|tic|pro|ord|inv|spro|sor|sin|leav|stockinv|job|surv|salary)([0-9]+)@/', $emailto, $reg)) { $trackidfoundintorecipienttype = $reg[1]; $trackidfoundintorecipientid = $reg[2]; } elseif (preg_match('/\+emailing-(\w+)@/', $emailto, $reg)) { // Can be 'emailing-test' or 'emailing-IdMailing-IdRecipient' @@ -2260,7 +2277,7 @@ class EmailCollector extends CommonObject 'fields' => array('ref'), 'class' => 'recruitment/class/recruitmentjobposition.class.php', 'object' => 'RecruitmentJobPosition'), - 'recruitment/recruitmentjobposition' => array('table' => 'recruitment_recruitmentcandidature', + 'recruitment/recruitmentcandidature' => array('table' => 'recruitment_recruitmentcandidature', 'fields' => array('ref'), 'class' => 'recruitment/class/recruitmentcandidature.class.php', 'object' => ' RecruitmentCandidature'), @@ -2305,7 +2322,7 @@ class EmailCollector extends CommonObject 'class' => 'compta/facture/class/facture.class.php', 'object' => 'Facture'), 'fournisseur/facture' => array('table' => 'facture_fourn', - 'fields' => array('ref', ref_client), + 'fields' => array('ref', 'ref_client'), 'class' => 'fourn/class/fournisseur.facture.class.php', 'object' => 'FactureFournisseur'), 'produit' => array('table' => 'product', @@ -3008,13 +3025,14 @@ class EmailCollector extends CommonObject * Check if the same file name already exists in the upload folder, * append increment number to the original filename */ - while (file_exists($destdir."/" . $file_name . "." . $extension)) { - $file_name = (string) $file_name_original . ' (' . $num . ')'; + while (file_exists($destdir."/".$file_name.".".$extension)) { + $file_name = $file_name_original . ' (' . $num . ')'; $file_name_complete = $file_name . "." . $extension; $destination = $destdir.'/'.$file_name_complete; $num++; } + $destination = dol_sanitizePathName($destination); file_put_contents($destination, $data); } diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index cdb67a2c37b..556443a25e8 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -217,7 +217,6 @@ class ConferenceOrBooth extends ActionComm $this->socid = $this->fk_soc; $this->datef = $this->datep2; $this->note_private = $this->note; - $this->fk_user_author = $this->fk_user_author; } /** @@ -716,8 +715,8 @@ class ConferenceOrBooth extends ActionComm $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_conferenceorbooth = '.((int) $this->id))); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php index 595eaf67eeb..abb0046606c 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -1102,18 +1102,18 @@ class ConferenceOrBoothAttendee extends CommonObject /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'eventorganization_conferenceorboothattendee' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } } diff --git a/htdocs/eventorganization/conferenceorbooth_card.php b/htdocs/eventorganization/conferenceorbooth_card.php index b6932c2cf09..9928b8af33b 100644 --- a/htdocs/eventorganization/conferenceorbooth_card.php +++ b/htdocs/eventorganization/conferenceorbooth_card.php @@ -568,13 +568,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.$withProjectUrl.'&action=presend&token='.newToken().'&mode=init#formmailbeforetitle'); } - print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.$withProjectUrl.'&action=edit&token='.newToken().'', '', $permissiontoadd); + print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.$withProjectUrl.'&action=edit&token='.newToken(), '', $permissiontoadd); // Clone print dolGetButtonAction('', $langs->trans('ToClone'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.$withProjectUrl.'&socid='.$object->socid.'&action=clone&token='.newToken().'&object=scrumsprint', '', $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.$withProjectUrl.'&action=delete&token='.newToken().'', '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)); + print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.$withProjectUrl.'&action=delete&token='.newToken(), '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)); } print '
'."\n"; } diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index f69d86c62e7..dd7bfd93a47 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -257,7 +257,7 @@ if ($projectid > 0 || $projectref) { } $help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; - $title = $langs->trans("Project") . ' - ' . $langs->trans("ListOfConferencesOrBooths") . ' - ' . $project->ref . ' ' . $project->name; + $title = $langs->trans("Project") . ' - ' . $langs->trans("EventOrganizationConfOrBoothes") . ' - ' . $project->ref . ' ' . $project->name; if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $project->name) { $title = $project->ref . ' ' . $project->name . ' - ' . $langs->trans("ListOfConferencesOrBooths"); } @@ -675,7 +675,7 @@ print ''; print ''; print ''; -$title = $langs->trans("ListOfConferencesOrBooths"); +$title = $langs->trans("EventOrganizationConfOrBoothes"); $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorbooth_card.php?action=create'.(!empty($project->id)?'&withproject=1&fk_project='.$project->id:'').(!empty($project->socid)?'&fk_soc='.$project->socid:'').'&backtopage='.urlencode($_SERVER['PHP_SELF']).(!empty($project->id)?'?projectid='.$project->id:''), '', $permissiontoadd); diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index ab8c4a28cbc..3e096bcc55d 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1647,7 +1647,7 @@ if ($action == 'create') { dol_print_error($db); } } -} elseif ($id || $ref) { +} elseif ($object->id > 0) { /* *************************************************************************** */ /* */ /* Edit and view mode */ @@ -1657,828 +1657,826 @@ if ($action == 'create') { $num_prod = count($lines); - if ($object->id > 0) { - if (!empty($object->origin) && $object->origin_id > 0) { - $typeobject = $object->origin; - $origin = $object->origin; - $origin_id = $object->origin_id; - $object->fetch_origin(); // Load property $object->commande, $object->propal, ... + if (!empty($object->origin) && $object->origin_id > 0) { + $typeobject = $object->origin; + $origin = $object->origin; + $origin_id = $object->origin_id; + $object->fetch_origin(); // Load property $object->commande, $object->propal, ... + } + + $soc = new Societe($db); + $soc->fetch($object->socid); + + $res = $object->fetch_optionals(); + + $head = shipping_prepare_head($object); + print dol_get_fiche_head($head, 'shipping', $langs->trans("Shipment"), -1, $object->picto); + + $formconfirm = ''; + + // Confirm deleteion + if ($action == 'delete') { + $formquestion = array(); + if ($object->statut == Expedition::STATUS_CLOSED && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { + $formquestion = array( + array( + 'label' => $langs->trans('ShipmentIncrementStockOnDelete'), + 'name' => 'alsoUpdateStock', + 'type' => 'checkbox', + 'value' => 0 + ), + ); + } + $formconfirm = $form->formconfirm( + $_SERVER['PHP_SELF'].'?id='.$object->id, + $langs->trans('DeleteSending'), + $langs->trans("ConfirmDeleteSending", $object->ref), + 'confirm_delete', + $formquestion, + 0, + 1 + ); + } + + // Confirmation validation + if ($action == 'valid') { + $objectref = substr($object->ref, 1, 4); + if ($objectref == 'PROV') { + $numref = $object->getNextNumRef($soc); + } else { + $numref = $object->ref; } - $soc = new Societe($db); - $soc->fetch($object->socid); + $text = $langs->trans("ConfirmValidateSending", $numref); - $res = $object->fetch_optionals(); + if (isModEnabled('notification')) { + require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; + $notify = new Notify($db); + $text .= '
'; + $text .= $notify->confirmMessage('SHIPPING_VALIDATE', $object->socid, $object); + } - $head = shipping_prepare_head($object); - print dol_get_fiche_head($head, 'shipping', $langs->trans("Shipment"), -1, $object->picto); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('ValidateSending'), $text, 'confirm_valid', '', 0, 1); + } + // Confirm cancelation + if ($action == 'cancel') { + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('CancelSending'), $langs->trans("ConfirmCancelSending", $object->ref), 'confirm_cancel', '', 0, 1); + } - $formconfirm = ''; + // 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 + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } - // Confirm deleteion - if ($action == 'delete') { - $formquestion = array(); - if ($object->statut == Expedition::STATUS_CLOSED && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { - $formquestion = array( - array( - 'label' => $langs->trans('ShipmentIncrementStockOnDelete'), - 'name' => 'alsoUpdateStock', - 'type' => 'checkbox', - 'value' => 0 - ), - ); + // Print form confirm + print $formconfirm; + + // Calculate totalWeight and totalVolume for all products + // by adding weight and volume of each product line. + $tmparray = $object->getTotalWeightVolume(); + $totalWeight = $tmparray['weight']; + $totalVolume = $tmparray['volume']; + + + if ($typeobject == 'commande' && $object->$typeobject->id && isModEnabled('commande')) { + $objectsrc = new Commande($db); + $objectsrc->fetch($object->$typeobject->id); + } + if ($typeobject == 'propal' && $object->$typeobject->id && isModEnabled("propal")) { + $objectsrc = new Propal($db); + $objectsrc->fetch($object->$typeobject->id); + } + + // Shipment card + $linkback = ''.$langs->trans("BackToList").''; + $morehtmlref = '
'; + // Ref customer shipment + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->expedition->creer, 'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ? ':'.$conf->global->THIRDPARTY_REF_INPUT_SIZE : ''), '', null, null, '', 1); + // Thirdparty + $morehtmlref .= '
'.$object->thirdparty->getNomUrl(1); + // Project + if (isModEnabled('project')) { + $langs->load("projects"); + $morehtmlref .= '
'; + if (0) { // Do not change on shipment + $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); + if ($action != 'classify') { + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $formconfirm = $form->formconfirm( - $_SERVER['PHP_SELF'].'?id='.$object->id, - $langs->trans('DeleteSending'), - $langs->trans("ConfirmDeleteSending", $object->ref), - 'confirm_delete', - $formquestion, - 0, - 1 - ); - } - - // Confirmation validation - if ($action == 'valid') { - $objectref = substr($object->ref, 1, 4); - if ($objectref == 'PROV') { - $numref = $object->getNextNumRef($soc); - } else { - $numref = $object->ref; - } - - $text = $langs->trans("ConfirmValidateSending", $numref); - - if (isModEnabled('notification')) { - require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; - $notify = new Notify($db); - $text .= '
'; - $text .= $notify->confirmMessage('SHIPPING_VALIDATE', $object->socid, $object); - } - - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('ValidateSending'), $text, 'confirm_valid', '', 0, 1); - } - // Confirm cancelation - if ($action == 'cancel') { - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('CancelSending'), $langs->trans("ConfirmCancelSending", $object->ref), 'confirm_cancel', '', 0, 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 - if (empty($reshook)) { - $formconfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formconfirm = $hookmanager->resPrint; - } - - // Print form confirm - print $formconfirm; - - // Calculate totalWeight and totalVolume for all products - // by adding weight and volume of each product line. - $tmparray = $object->getTotalWeightVolume(); - $totalWeight = $tmparray['weight']; - $totalVolume = $tmparray['volume']; - - - if ($typeobject == 'commande' && $object->$typeobject->id && isModEnabled('commande')) { - $objectsrc = new Commande($db); - $objectsrc->fetch($object->$typeobject->id); - } - if ($typeobject == 'propal' && $object->$typeobject->id && isModEnabled("propal")) { - $objectsrc = new Propal($db); - $objectsrc->fetch($object->$typeobject->id); - } - - // Shipment card - $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
'; - // Ref customer shipment - $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', 0, 1); - $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->expedition->creer, 'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ? ':'.$conf->global->THIRDPARTY_REF_INPUT_SIZE : ''), '', null, null, '', 1); - // Thirdparty - $morehtmlref .= '
'.$object->thirdparty->getNomUrl(1); - // Project - if (isModEnabled('project')) { - $langs->load("projects"); - $morehtmlref .= '
'; - if (0) { // Do not change on shipment - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); - if ($action != 'classify') { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; - } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $objectsrc->socid, $objectsrc->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); - } else { - if (!empty($objectsrc) && !empty($objectsrc->fk_project)) { - $proj = new Project($db); - $proj->fetch($objectsrc->fk_project); - $morehtmlref .= $proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $objectsrc->socid, $objectsrc->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + } else { + if (!empty($objectsrc) && !empty($objectsrc->fk_project)) { + $proj = new Project($db); + $proj->fetch($objectsrc->fk_project); + $morehtmlref .= $proj->getNomUrl(1); + if ($proj->title) { + $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; } } } - $morehtmlref .= '
'; + } + $morehtmlref .= '
'; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - print '
'; - print '
'; - print '
'; + print '
'; + print '
'; + print '
'; - print ''; + print '
'; - // Linked documents - if ($typeobject == 'commande' && $object->$typeobject->id && isModEnabled('commande')) { - print ''; - print '\n"; - print ''; - } - if ($typeobject == 'propal' && $object->$typeobject->id && isModEnabled("propal")) { - print ''; - print '\n"; - print ''; - } - - // Date creation - print ''; - print '\n"; - print ''; - - // Delivery date planned - print ''; - print ''; - - // Weight + // Linked documents + if ($typeobject == 'commande' && $object->$typeobject->id && isModEnabled('commande')) { print ''; - - // Width - print ''; - - // Height - print ''; - - // Depth - print ''; - - // Volume - print ''; + print $langs->trans("RefOrder").''; print '\n"; print ''; - - // Other attributes - $cols = 2; - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - - print '
'; - print $langs->trans("RefOrder").''; - print $objectsrc->getNomUrl(1, 'commande'); - print "
'; - print $langs->trans("RefProposal").''; - print $objectsrc->getNomUrl(1, 'expedition'); - print "
'.$langs->trans("DateCreation").''.dol_print_date($object->date_creation, "dayhour")."
'; - print ''; - - if ($action != 'editdate_livraison') { - print ''; - } - print '
'; - print $langs->trans('DateDeliveryPlanned'); - print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'), 1).'
'; - print '
'; - if ($action == 'editdate_livraison') { - print '
'; - print ''; - print ''; - print $form->selectDate($object->date_delivery ? $object->date_delivery : -1, 'liv_', 1, 1, '', "setdate_livraison", 1, 0); - print ''; - print '
'; - } else { - print $object->date_delivery ? dol_print_date($object->date_delivery, 'dayhour') : ' '; - } - print '
'; - print $form->editfieldkey("Weight", 'trueWeight', $object->trueWeight, $object, $user->rights->expedition->creer); - print ''; - - if ($action == 'edittrueWeight') { - print '
'; - print ''; - print ''; - print ''; - print ''; - print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units, 0, 2); - print ' '; - print ' '; - print '
'; - } else { - print $object->trueWeight; - print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", $object->weight_units) : ''; - } - - // Calculated - if ($totalWeight > 0) { - if (!empty($object->trueWeight)) { - print ' ('.$langs->trans("SumOfProductWeights").': '; - } - print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); - if (!empty($object->trueWeight)) { - print ')'; - } - } - print '
'.$form->editfieldkey("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer).''; - print $form->editfieldval("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer); - print ($object->trueWidth && $object->width_units != '') ? ' '.measuringUnitString(0, "size", $object->width_units) : ''; - print '
'.$form->editfieldkey("Height", 'trueHeight', $object->trueHeight, $object, $user->rights->expedition->creer).''; - if ($action == 'edittrueHeight') { - print '
'; - print ''; - print ''; - print ''; - print ''; - print $formproduct->selectMeasuringUnits("size_units", "size", $object->size_units, 0, 2); - print ' '; - print ' '; - print '
'; - } else { - print $object->trueHeight; - print ($object->trueHeight && $object->height_units != '') ? ' '.measuringUnitString(0, "size", $object->height_units) : ''; - } - - print '
'.$form->editfieldkey("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer).''; - print $form->editfieldval("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer); - print ($object->trueDepth && $object->depth_units != '') ? ' '.measuringUnitString(0, "size", $object->depth_units) : ''; - print '
'; - print $langs->trans("Volume"); - print ''; - $calculatedVolume = 0; - $volumeUnit = 0; - if ($object->trueWidth && $object->trueHeight && $object->trueDepth) { - $calculatedVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth); - $volumeUnit = $object->size_units * 3; - } - // If sending volume not defined we use sum of products - if ($calculatedVolume > 0) { - if ($volumeUnit < 50) { - print showDimensionInBestUnit($calculatedVolume, $volumeUnit, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); - } else { - print $calculatedVolume.' '.measuringUnitString(0, "volume", $volumeUnit); - } - } - if ($totalVolume > 0) { - if ($calculatedVolume) { - print ' ('.$langs->trans("SumOfProductVolumes").': '; - } - print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); - //if (empty($calculatedVolume)) print ' ('.$langs->trans("Calculated").')'; - if ($calculatedVolume) { - print ')'; - } - } + print $objectsrc->getNomUrl(1, 'commande'); print "
'; - - print '
'; - print '
'; - print '
'; - - print ''; - - // Sending method - print ''; + } + if ($typeobject == 'propal' && $object->$typeobject->id && isModEnabled("propal")) { + print ''; + print '\n"; print ''; + } - // Tracking Number - print ''; + // Date creation + print ''; + print '\n"; + print ''; - // Incoterms - if (isModEnabled('incoterm')) { - print ''; - print ''; + // Delivery date planned + print ''; + print ''; + + // Weight + print '
'; - print ''; - - if ($action != 'editshipping_method_id') { - print ''; - } - print '
'; - print $langs->trans('SendingMethod'); - print 'id.'">'.img_edit($langs->trans('SetSendingMethod'), 1).'
'; - print '
'; - if ($action == 'editshipping_method_id') { - print '
'; - print ''; - print ''; - $object->fetch_delivery_methods(); - print $form->selectarray("shipping_method_id", $object->meths, $object->shipping_method_id, 1, 0, 0, "", 1); - if ($user->admin) { - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - } - print ''; - print '
'; - } else { - if ($object->shipping_method_id > 0) { - // Get code using getLabelFromKey - $code = $langs->getLabelFromKey($db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); - print $langs->trans("SendingMethod".strtoupper($code)); - } - } - print '
'; + print $langs->trans("RefProposal").''; + print $objectsrc->getNomUrl(1, 'expedition'); + print "
'.$form->editfieldkey("TrackingNumber", 'tracking_number', $object->tracking_number, $object, $user->rights->expedition->creer).''; - print $form->editfieldval("TrackingNumber", 'tracking_number', $object->tracking_url, $object, $user->rights->expedition->creer, 'safehtmlstring', $object->tracking_number); - print '
'.$langs->trans("DateCreation").''.dol_print_date($object->date_creation, "dayhour")."
'; - print '
'; - print $langs->trans('IncotermLabel'); - print ''; - if ($user->rights->expedition->creer) { - print ''.img_edit().''; - } else { - print ' '; - } - print '
'; - print '
'; - if ($action != 'editincoterm') { - print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); - } else { - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); - } - print '
'; + print ''; + + if ($action != 'editdate_livraison') { + print ''; + } + print '
'; + print $langs->trans('DateDeliveryPlanned'); + print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'), 1).'
'; + print '
'; + if ($action == 'editdate_livraison') { + print '
'; + print ''; + print ''; + print $form->selectDate($object->date_delivery ? $object->date_delivery : -1, 'liv_', 1, 1, '', "setdate_livraison", 1, 0); + print ''; + print '
'; + } else { + print $object->date_delivery ? dol_print_date($object->date_delivery, 'dayhour') : ' '; + } + print '
'; + print $form->editfieldkey("Weight", 'trueWeight', $object->trueWeight, $object, $user->rights->expedition->creer); + print ''; + + if ($action == 'edittrueWeight') { + print '
'; + print ''; + print ''; + print ''; + print ''; + print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units, 0, 2); + print ' '; + print ' '; + print '
'; + } else { + print $object->trueWeight; + print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", $object->weight_units) : ''; + } + + // Calculated + if ($totalWeight > 0) { + if (!empty($object->trueWeight)) { + print ' ('.$langs->trans("SumOfProductWeights").': '; } - - // Other attributes - $parameters = array('colspan' => ' colspan="3"', 'cols' => '3'); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - print "
"; - - print '
'; - print '
'; - - print '
'; - - - // Lines of products - - if ($action == 'editline') { - print '
- - - - - '; + print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); + if (!empty($object->trueWeight)) { + print ')'; } - print '
'; + } + print ''; - print '
'; - print ''; - print ''; - print ''; - // Adds a line numbering column - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - print ''; - } - // Product/Service - print ''; - // Qty - print ''; - if ($origin && $origin_id > 0) { - print ''; - } - if ($action == 'editline') { - $editColspan = 3; - if (!isModEnabled('stock')) { - $editColspan--; - } - if (empty($conf->productbatch->enabled)) { - $editColspan--; - } - print ''; + // Width + print ''; + + // Height + print ''; + + // Depth + print ''; + + // Volume + print ''; + print ''; - } else { - print ''; - } - if (isModEnabled('stock')) { - print ''; - } - - if (isModEnabled('productbatch')) { - print ''; - } + print $calculatedVolume.' '.measuringUnitString(0, "volume", $volumeUnit); } - print ''; - print ''; - //print ''; - if ($object->statut == 0) { - print ''; - print ''; + } + if ($totalVolume > 0) { + if ($calculatedVolume) { + print ' ('.$langs->trans("SumOfProductVolumes").': '; } - print "\n"; - print ''; + print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); + //if (empty($calculatedVolume)) print ' ('.$langs->trans("Calculated").')'; + if ($calculatedVolume) { + print ')'; + } + } + print "\n"; + print ''; - $outputlangs = $langs; + // Other attributes + $cols = 2; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { - $object->fetch_thirdparty(); - $newlang = ''; - if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { - $newlang = GETPOST('lang_id', 'aZ09'); - } - if (empty($newlang)) { - $newlang = $object->thirdparty->default_lang; - } - if (!empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } + print '
 '.$langs->trans("Products").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyInOtherShipments").''; - if ($object->statut <= 1) { - print $langs->trans("QtyToShip").' - '; - } else { - print $langs->trans("QtyShipped").' - '; - } - if (isModEnabled('stock')) { - print $langs->trans("WarehouseSource").' - '; - } - if (isModEnabled('productbatch')) { - print $langs->trans("Batch"); - } - print '
'.$form->editfieldkey("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer).''; + print $form->editfieldval("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer); + print ($object->trueWidth && $object->width_units != '') ? ' '.measuringUnitString(0, "size", $object->width_units) : ''; + print '
'.$form->editfieldkey("Height", 'trueHeight', $object->trueHeight, $object, $user->rights->expedition->creer).''; + if ($action == 'edittrueHeight') { + print ''; + print ''; + print ''; + print ''; + print ''; + print $formproduct->selectMeasuringUnits("size_units", "size", $object->size_units, 0, 2); + print ' '; + print ' '; + print ''; + } else { + print $object->trueHeight; + print ($object->trueHeight && $object->height_units != '') ? ' '.measuringUnitString(0, "size", $object->height_units) : ''; + } + + print '
'.$form->editfieldkey("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer).''; + print $form->editfieldval("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer); + print ($object->trueDepth && $object->depth_units != '') ? ' '.measuringUnitString(0, "size", $object->depth_units) : ''; + print '
'; + print $langs->trans("Volume"); + print ''; + $calculatedVolume = 0; + $volumeUnit = 0; + if ($object->trueWidth && $object->trueHeight && $object->trueDepth) { + $calculatedVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth); + $volumeUnit = $object->size_units * 3; + } + // If sending volume not defined we use sum of products + if ($calculatedVolume > 0) { + if ($volumeUnit < 50) { + print showDimensionInBestUnit($calculatedVolume, $volumeUnit, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); } else { - if ($object->statut <= 1) { - print ''.$langs->trans("QtyToShip").''.$langs->trans("QtyShipped").''.$langs->trans("WarehouseSource").''.$langs->trans("Batch").''.$langs->trans("CalculatedWeight").''.$langs->trans("CalculatedVolume").''.$langs->trans("Size").'
'; + + print '
'; + print '
'; + print '
'; + + print ''; + + // Sending method + print ''; + print ''; + + // Tracking Number + print ''; + + // Incoterms + if (isModEnabled('incoterm')) { + print ''; + print ''; + } + + // Other attributes + $parameters = array('colspan' => ' colspan="3"', 'cols' => '3'); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + print "
'; + print ''; + + if ($action != 'editshipping_method_id') { + print ''; + } + print '
'; + print $langs->trans('SendingMethod'); + print 'id.'">'.img_edit($langs->trans('SetSendingMethod'), 1).'
'; + print '
'; + if ($action == 'editshipping_method_id') { + print '
'; + print ''; + print ''; + $object->fetch_delivery_methods(); + print $form->selectarray("shipping_method_id", $object->meths, $object->shipping_method_id, 1, 0, 0, "", 1); + if ($user->admin) { + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } + print ''; + print '
'; + } else { + if ($object->shipping_method_id > 0) { + // Get code using getLabelFromKey + $code = $langs->getLabelFromKey($db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); + print $langs->trans("SendingMethod".strtoupper($code)); + } + } + print '
'.$form->editfieldkey("TrackingNumber", 'tracking_number', $object->tracking_number, $object, $user->rights->expedition->creer).''; + print $form->editfieldval("TrackingNumber", 'tracking_number', $object->tracking_url, $object, $user->rights->expedition->creer, 'safehtmlstring', $object->tracking_number); + print '
'; + print '
'; + print $langs->trans('IncotermLabel'); + print ''; + if ($user->rights->expedition->creer) { + print ''.img_edit().''; + } else { + print ' '; + } + print '
'; + print '
'; + if ($action != 'editincoterm') { + print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); + } else { + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); + } + print '
"; + + print '
'; + print '
'; + + print '
'; + + + // Lines of products + + if ($action == 'editline') { + print '
+ + + + + '; + } + print '
'; + + print '
'; + print ''; + print ''; + print ''; + // Adds a line numbering column + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + print ''; + } + // Product/Service + print ''; + // Qty + print ''; + if ($origin && $origin_id > 0) { + print ''; + } + if ($action == 'editline') { + $editColspan = 3; + if (!isModEnabled('stock')) { + $editColspan--; + } + if (empty($conf->productbatch->enabled)) { + $editColspan--; + } + print ''; + } else { + if ($object->statut <= 1) { + print ''; + } else { + print ''; + } + if (isModEnabled('stock')) { + print ''; } - // Get list of products already sent for same source object into $alreadysent - $alreadysent = array(); - if ($origin && $origin_id > 0) { - $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.fk_unit, obj.date_start, obj.date_end"; - $sql .= ", ed.rowid as shipmentline_id, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot"; - $sql .= ", e.rowid as shipment_id, e.ref as shipment_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_expedition"; - //if ($conf->delivery_note->enabled) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received"; - $sql .= ', p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tosell as product_tosell, p.tobuy as product_tobuy, p.tobatch as product_tobatch'; - $sql .= ', p.description as product_desc'; - $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; - $sql .= ", ".MAIN_DB_PREFIX."expedition as e"; - $sql .= ", ".MAIN_DB_PREFIX.$origin."det as obj"; - //if ($conf->delivery_note->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."deliverydet as ld ON ld.fk_delivery = l.rowid AND obj.rowid = ld.fk_origin_line"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; - $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; - $sql .= " AND obj.fk_".$origin." = ".((int) $origin_id); - $sql .= " AND obj.rowid = ed.fk_origin_line"; - $sql .= " AND ed.fk_expedition = e.rowid"; - //if ($filter) $sql.= $filter; - $sql .= " ORDER BY obj.fk_product"; + if (isModEnabled('productbatch')) { + print ''; + } + } + print ''; + print ''; + //print ''; + if ($object->statut == 0) { + print ''; + print ''; + } + print "\n"; + print ''; - dol_syslog("expedition/card.php get list of shipment lines", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - $i = 0; + $outputlangs = $langs; - while ($i < $num) { - $obj = $db->fetch_object($resql); - if ($obj) { - // $obj->rowid is rowid in $origin."det" table - $alreadysent[$obj->rowid][$obj->shipmentline_id] = array( - 'shipment_ref'=>$obj->shipment_ref, 'shipment_id'=>$obj->shipment_id, 'warehouse'=>$obj->fk_entrepot, 'qty_shipped'=>$obj->qty_shipped, - 'product_tosell'=>$obj->product_tosell, 'product_tobuy'=>$obj->product_tobuy, 'product_tobatch'=>$obj->product_tobatch, - 'date_valid'=>$db->jdate($obj->date_valid), 'date_delivery'=>$db->jdate($obj->date_delivery)); - } - $i++; + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + $object->fetch_thirdparty(); + $newlang = ''; + if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if (empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + } + + // Get list of products already sent for same source object into $alreadysent + $alreadysent = array(); + if ($origin && $origin_id > 0) { + $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.fk_unit, obj.date_start, obj.date_end"; + $sql .= ", ed.rowid as shipmentline_id, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot"; + $sql .= ", e.rowid as shipment_id, e.ref as shipment_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_expedition"; + //if ($conf->delivery_note->enabled) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received"; + $sql .= ', p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tosell as product_tosell, p.tobuy as product_tobuy, p.tobatch as product_tobatch'; + $sql .= ', p.description as product_desc'; + $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; + $sql .= ", ".MAIN_DB_PREFIX."expedition as e"; + $sql .= ", ".MAIN_DB_PREFIX.$origin."det as obj"; + //if ($conf->delivery_note->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."deliverydet as ld ON ld.fk_delivery = l.rowid AND obj.rowid = ld.fk_origin_line"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; + $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; + $sql .= " AND obj.fk_".$origin." = ".((int) $origin_id); + $sql .= " AND obj.rowid = ed.fk_origin_line"; + $sql .= " AND ed.fk_expedition = e.rowid"; + //if ($filter) $sql.= $filter; + $sql .= " ORDER BY obj.fk_product"; + + dol_syslog("expedition/card.php get list of shipment lines", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + + while ($i < $num) { + $obj = $db->fetch_object($resql); + if ($obj) { + // $obj->rowid is rowid in $origin."det" table + $alreadysent[$obj->rowid][$obj->shipmentline_id] = array( + 'shipment_ref'=>$obj->shipment_ref, 'shipment_id'=>$obj->shipment_id, 'warehouse'=>$obj->fk_entrepot, 'qty_shipped'=>$obj->qty_shipped, + 'product_tosell'=>$obj->product_tosell, 'product_tobuy'=>$obj->product_tobuy, 'product_tobatch'=>$obj->product_tobatch, + 'date_valid'=>$db->jdate($obj->date_valid), 'date_delivery'=>$db->jdate($obj->date_delivery)); } + $i++; } - //var_dump($alreadysent); + } + //var_dump($alreadysent); + } + + print ''; + + // Loop on each product to send/sent + for ($i = 0; $i < $num_prod; $i++) { + $parameters = array('i' => $i, 'line' => $lines[$i], 'line_id' => $line_id, 'num' => $num_prod, 'alreadysent' => $alreadysent, 'editColspan' => !empty($editColspan) ? $editColspan : 0, 'outputlangs' => $outputlangs); + $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } - print ''; + if (empty($reshook)) { + print ''; // id of order line + print ''; - // Loop on each product to send/sent - for ($i = 0; $i < $num_prod; $i++) { - $parameters = array('i' => $i, 'line' => $lines[$i], 'line_id' => $line_id, 'num' => $num_prod, 'alreadysent' => $alreadysent, 'editColspan' => !empty($editColspan) ? $editColspan : 0, 'outputlangs' => $outputlangs); - $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + // # + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + print ''; } - if (empty($reshook)) { - print ''; // id of order line - print ''; - - // # - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - print ''; - } - - // Predefined product or service - if ($lines[$i]->fk_product > 0) { - // Define output language - if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { - $prod = new Product($db); - $prod->fetch($lines[$i]->fk_product); - $label = (!empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $lines[$i]->product_label; - } else { - $label = (!empty($lines[$i]->label) ? $lines[$i]->label : $lines[$i]->product_label); - } - - print '\n"; + // Predefined product or service + if ($lines[$i]->fk_product > 0) { + // Define output language + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + $prod = new Product($db); + $prod->fetch($lines[$i]->fk_product); + $label = (!empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $lines[$i]->product_label; } else { - print '\n"; + $label = (!empty($lines[$i]->label) ? $lines[$i]->label : $lines[$i]->product_label); } - $unit_order = ''; - if (!empty($conf->global->PRODUCT_USE_UNITS)) { - $unit_order = measuringUnitString($lines[$i]->fk_unit); + print '\n"; + } else { + print ''; + if (!empty($lines[$i]->label)) { + $text .= ' '.$lines[$i]->label.''; + print $form->textwithtooltip($text, $lines[$i]->description, 3, '', '', $i); + } else { + print $text.' '.nl2br($lines[$i]->description); + } - // Qty in other shipments (with shipment and warehouse used) - if ($origin && $origin_id > 0) { - print '\n"; + } - $j++; - if ($j > 1) { - print '
'; - } - $shipment_static->fetch($shipmentline_var['shipment_id']); - print $shipment_static->getNomUrl(1); - print ' - '.$shipmentline_var['qty_shipped']; - $htmltext = $langs->trans("DateValidation").' : '.(empty($shipmentline_var['date_valid']) ? $langs->trans("Draft") : dol_print_date($shipmentline_var['date_valid'], 'dayhour')); - if (isModEnabled('stock') && $shipmentline_var['warehouse'] > 0) { - $warehousestatic->fetch($shipmentline_var['warehouse']); - $htmltext .= '
'.$langs->trans("FromLocation").' : '.$warehousestatic->getNomUrl(1, '', 0, 1); - } - print ' '.$form->textwithpicto('', $htmltext, 1); + $unit_order = ''; + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + $unit_order = measuringUnitString($lines[$i]->fk_unit); + } + + // Qty ordered + print ''; + + // Qty in other shipments (with shipment and warehouse used) + if ($origin && $origin_id > 0) { + print ''; } + print ''; + } - if ($action == 'editline' && $lines[$i]->id == $line_id) { - // edit mode - print ''; + } else { + // Qty to ship or shipped + print ''; + + // Warehouse source + if (isModEnabled('stock')) { + print ''; + } + + // Batch number managment + if (isModEnabled('productbatch')) { + if (isset($lines[$i]->detail_batch)) { + print ''; + print ''; - } - - // Batch number managment - if (isModEnabled('productbatch')) { - if (isset($lines[$i]->detail_batch)) { - print ''; - print ''; - } else { - print ''; - } - } - } - - // Weight - print ''; - - // Volume - print ''; - - // Size - //print ''; - - if ($action == 'editline' && $lines[$i]->id == $line_id) { - print ''; - } elseif ($object->statut == Expedition::STATUS_DRAFT) { - // edit-delete buttons - print ''; - print ''; - - // Display lines extrafields - if (!empty($rowExtrafieldsStart)) { - print $rowExtrafieldsStart; - print $rowExtrafieldsView; - print $rowEnd; - } - } - print ""; - - // Display lines extrafields. - // $line is a line of shipment - if (!empty($extrafields)) { - $colspan = 6; - if ($origin && $origin_id > 0) { - $colspan++; - } - if (isModEnabled('productbatch')) { - $colspan++; - } - if (isModEnabled('stock')) { - $colspan++; - } - - $line = $lines[$i]; - $line->fetch_optionals(); - - // TODO Show all in same line by setting $display_type = 'line' - if ($action == 'editline' && $line->id == $line_id) { - print $lines[$i]->showOptionals($extrafields, 'edit', array('colspan'=>$colspan), !empty($indiceAsked) ? $indiceAsked : '', '', 0, 'card'); } else { - print $lines[$i]->showOptionals($extrafields, 'view', array('colspan'=>$colspan), !empty($indiceAsked) ? $indiceAsked : '', '', 0, 'card'); + print ''; } } } + + // Weight + print ''; + + // Volume + print ''; + + // Size + //print ''; + + if ($action == 'editline' && $lines[$i]->id == $line_id) { + print ''; + } elseif ($object->statut == Expedition::STATUS_DRAFT) { + // edit-delete buttons + print ''; + print ''; + + // Display lines extrafields + if (!empty($rowExtrafieldsStart)) { + print $rowExtrafieldsStart; + print $rowExtrafieldsView; + print $rowEnd; + } + } + print ""; + + // Display lines extrafields. + // $line is a line of shipment + if (!empty($extrafields)) { + $colspan = 6; + if ($origin && $origin_id > 0) { + $colspan++; + } + if (isModEnabled('productbatch')) { + $colspan++; + } + if (isModEnabled('stock')) { + $colspan++; + } + + $line = $lines[$i]; + $line->fetch_optionals(); + + // TODO Show all in same line by setting $display_type = 'line' + if ($action == 'editline' && $line->id == $line_id) { + print $lines[$i]->showOptionals($extrafields, 'edit', array('colspan'=>$colspan), !empty($indiceAsked) ? $indiceAsked : '', '', 0, 'card'); + } else { + print $lines[$i]->showOptionals($extrafields, 'view', array('colspan'=>$colspan), !empty($indiceAsked) ? $indiceAsked : '', '', 0, 'card'); + } + } } - - // TODO Show also lines ordered but not delivered - - print "
 '.$langs->trans("Products").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyInOtherShipments").''; + if ($object->statut <= 1) { + print $langs->trans("QtyToShip").' - '; + } else { + print $langs->trans("QtyShipped").' - '; + } + if (isModEnabled('stock')) { + print $langs->trans("WarehouseSource").' - '; + } + if (isModEnabled('productbatch')) { + print $langs->trans("Batch"); + } + print ''.$langs->trans("QtyToShip").''.$langs->trans("QtyShipped").''.$langs->trans("WarehouseSource").''.$langs->trans("Batch").''.$langs->trans("CalculatedWeight").''.$langs->trans("CalculatedVolume").''.$langs->trans("Size").'
'.($i + 1).'
'.($i + 1).''; - - // Show product and description - $product_static->type = $lines[$i]->fk_product_type; - $product_static->id = $lines[$i]->fk_product; - $product_static->ref = $lines[$i]->ref; - $product_static->status = $lines[$i]->product_tosell; - $product_static->status_buy = $lines[$i]->product_tobuy; - $product_static->status_batch = $lines[$i]->product_tobatch; - - $product_static->weight = $lines[$i]->weight; - $product_static->weight_units = $lines[$i]->weight_units; - $product_static->length = $lines[$i]->length; - $product_static->length_units = $lines[$i]->length_units; - $product_static->width = !empty($lines[$i]->width) ? $lines[$i]->width : 0; - $product_static->width_units = !empty($lines[$i]->width_units) ? $lines[$i]->width_units : 0; - $product_static->height = !empty($lines[$i]->height) ? $lines[$i]->height : 0; - $product_static->height_units = !empty($lines[$i]->height_units) ? $lines[$i]->height_units : 0; - $product_static->surface = $lines[$i]->surface; - $product_static->surface_units = $lines[$i]->surface_units; - $product_static->volume = $lines[$i]->volume; - $product_static->volume_units = $lines[$i]->volume_units; - - $text = $product_static->getNomUrl(1); - $text .= ' - '.$label; - $description = (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE') ? '' : dol_htmlentitiesbr($lines[$i]->description)); - print $form->textwithtooltip($text, $description, 3, '', '', $i); - print_date_range(!empty($lines[$i]->date_start) ? $lines[$i]->date_start : '', !empty($lines[$i]->date_end) ? $lines[$i]->date_end : ''); - if (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE')) { - print (!empty($lines[$i]->description) && $lines[$i]->description != $lines[$i]->product) ? '
'.dol_htmlentitiesbr($lines[$i]->description) : ''; - } - print "
'; - if ($lines[$i]->product_type == Product::TYPE_SERVICE) { - $text = img_object($langs->trans('Service'), 'service'); - } else { - $text = img_object($langs->trans('Product'), 'product'); - } - - if (!empty($lines[$i]->label)) { - $text .= ' '.$lines[$i]->label.''; - print $form->textwithtooltip($text, $lines[$i]->description, 3, '', '', $i); - } else { - print $text.' '.nl2br($lines[$i]->description); - } - - print_date_range($lines[$i]->date_start, $lines[$i]->date_end); - print "'; + + // Show product and description + $product_static->type = $lines[$i]->fk_product_type; + $product_static->id = $lines[$i]->fk_product; + $product_static->ref = $lines[$i]->ref; + $product_static->status = $lines[$i]->product_tosell; + $product_static->status_buy = $lines[$i]->product_tobuy; + $product_static->status_batch = $lines[$i]->product_tobatch; + + $product_static->weight = $lines[$i]->weight; + $product_static->weight_units = $lines[$i]->weight_units; + $product_static->length = $lines[$i]->length; + $product_static->length_units = $lines[$i]->length_units; + $product_static->width = !empty($lines[$i]->width) ? $lines[$i]->width : 0; + $product_static->width_units = !empty($lines[$i]->width_units) ? $lines[$i]->width_units : 0; + $product_static->height = !empty($lines[$i]->height) ? $lines[$i]->height : 0; + $product_static->height_units = !empty($lines[$i]->height_units) ? $lines[$i]->height_units : 0; + $product_static->surface = $lines[$i]->surface; + $product_static->surface_units = $lines[$i]->surface_units; + $product_static->volume = $lines[$i]->volume; + $product_static->volume_units = $lines[$i]->volume_units; + + $text = $product_static->getNomUrl(1); + $text .= ' - '.$label; + $description = (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE') ? '' : dol_htmlentitiesbr($lines[$i]->description)); + print $form->textwithtooltip($text, $description, 3, '', '', $i); + print_date_range(!empty($lines[$i]->date_start) ? $lines[$i]->date_start : '', !empty($lines[$i]->date_end) ? $lines[$i]->date_end : ''); + if (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE')) { + print (!empty($lines[$i]->description) && $lines[$i]->description != $lines[$i]->product) ? '
'.dol_htmlentitiesbr($lines[$i]->description) : ''; + } + print "
'; + if ($lines[$i]->product_type == Product::TYPE_SERVICE) { + $text = img_object($langs->trans('Service'), 'service'); + } else { + $text = img_object($langs->trans('Product'), 'product'); } - // Qty ordered - print ''.$lines[$i]->qty_asked.' '.$unit_order.''; - foreach ($alreadysent as $key => $val) { - if ($lines[$i]->fk_origin_line == $key) { - $j = 0; - foreach ($val as $shipmentline_id => $shipmentline_var) { - if ($shipmentline_var['shipment_id'] == $lines[$i]->fk_expedition) { - continue; // We want to show only "other shipments" - } + print_date_range($lines[$i]->date_start, $lines[$i]->date_end); + print "'.$lines[$i]->qty_asked.' '.$unit_order.''; + foreach ($alreadysent as $key => $val) { + if ($lines[$i]->fk_origin_line == $key) { + $j = 0; + foreach ($val as $shipmentline_id => $shipmentline_var) { + if ($shipmentline_var['shipment_id'] == $lines[$i]->fk_expedition) { + continue; // We want to show only "other shipments" } + + $j++; + if ($j > 1) { + print '
'; + } + $shipment_static->fetch($shipmentline_var['shipment_id']); + print $shipment_static->getNomUrl(1); + print ' - '.$shipmentline_var['qty_shipped']; + $htmltext = $langs->trans("DateValidation").' : '.(empty($shipmentline_var['date_valid']) ? $langs->trans("Draft") : dol_print_date($shipmentline_var['date_valid'], 'dayhour')); + if (isModEnabled('stock') && $shipmentline_var['warehouse'] > 0) { + $warehousestatic->fetch($shipmentline_var['warehouse']); + $htmltext .= '
'.$langs->trans("FromLocation").' : '.$warehousestatic->getNomUrl(1, '', 0, 1); + } + print ' '.$form->textwithpicto('', $htmltext, 1); } } - print '
'; - if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) { - print ''; - $line = new ExpeditionLigne($db); - foreach ($lines[$i]->detail_batch as $detail_batch) { - print ''; - // Qty to ship or shipped - print ''; - // Batch number managment - if ($lines[$i]->entrepot_id == 0) { - // only show lot numbers from src warehouse when shipping from multiple warehouses - $line->fetch($detail_batch->fk_expeditiondet); - } - $entrepot_id = !empty($detail_batch->entrepot_id)?$detail_batch->entrepot_id:$lines[$i]->entrepot_id; - print ''; - print ''; - } - // add a 0 qty lot row to be able to add a lot + if ($action == 'editline' && $lines[$i]->id == $line_id) { + // edit mode + print ''; - } else { + } elseif (!isModEnabled('stock') && empty($conf->productbatch->enabled)) { // both product batch and stock are not activated. + print ''; + print ''; // Qty to ship or shipped - print ''; - + print ''; // Warehouse source - if (isModEnabled('stock')) { - print ''; + // Batch number managment + print ''; + print ''; + } + + print '
'.$formproduct->selectLotStock($detail_batch->fk_origin_stock, 'batchl'.$detail_batch->fk_expeditiondet.'_'.$detail_batch->fk_origin_stock, '', 1, 0, $lines[$i]->fk_product, $entrepot_id).'
'; + if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) { + print ''; + $line = new ExpeditionLigne($db); + foreach ($lines[$i]->detail_batch as $detail_batch) { print ''; // Qty to ship or shipped - print ''; + print ''; // Batch number managment - print ''; + if ($lines[$i]->entrepot_id == 0) { + // only show lot numbers from src warehouse when shipping from multiple warehouses + $line->fetch($detail_batch->fk_expeditiondet); + } + $entrepot_id = !empty($detail_batch->entrepot_id)?$detail_batch->entrepot_id:$lines[$i]->entrepot_id; + print ''; print ''; - } elseif (isModEnabled('stock')) { - if ($lines[$i]->fk_product > 0) { - if ($lines[$i]->entrepot_id > 0) { - print ''; - print ''; - // Qty to ship or shipped - print ''; - // Warehouse source - print ''; - // Batch number managment - print ''; - print ''; - } elseif (count($lines[$i]->details_entrepot) > 1) { - print ''; - foreach ($lines[$i]->details_entrepot as $detail_entrepot) { - print ''; - // Qty to ship or shipped - print ''; - // Warehouse source - print ''; - // Batch number managment - print ''; - print ''; - } - } else { - print ''; - print ''; - } - } else { - print ''; + } + // add a 0 qty lot row to be able to add a lot + print ''; + // Qty to ship or shipped + print ''; + // Batch number managment + print ''; + print ''; + } elseif (isModEnabled('stock')) { + if ($lines[$i]->fk_product > 0) { + if ($lines[$i]->entrepot_id > 0) { + print ''; print ''; // Qty to ship or shipped print ''; // Warehouse source - print ''; + print ''; // Batch number managment - print ''; + print ''; print ''; + } elseif (count($lines[$i]->details_entrepot) > 1) { + print ''; + foreach ($lines[$i]->details_entrepot as $detail_entrepot) { + print ''; + // Qty to ship or shipped + print ''; + // Warehouse source + print ''; + // Batch number managment + print ''; + print ''; + } + } else { + print ''; + print ''; } - } elseif (!isModEnabled('stock') && empty($conf->productbatch->enabled)) { // both product batch and stock are not activated. - print ''; + } else { + print ''; print ''; // Qty to ship or shipped - print ''; + print ''; // Warehouse source print ''; // Batch number managment print ''; print ''; } - - print '
'.$formproduct->selectLotStock('', 'batchl'.$line_id.'_0', '', 1, 0, $lines[$i]->fk_product).''.$formproduct->selectLotStock($detail_batch->fk_origin_stock, 'batchl'.$detail_batch->fk_expeditiondet.'_'.$detail_batch->fk_origin_stock, '', 1, 0, $lines[$i]->fk_product, $entrepot_id).'
'.$unit_order.''.$formproduct->selectWarehouses($lines[$i]->entrepot_id, 'entl'.$line_id, '', 1, 0, $lines[$i]->fk_product, '', 1).' - '.$langs->trans("NA").'
'.$unit_order.''.$formproduct->selectWarehouses($detail_entrepot->entrepot_id, 'entl'.$detail_entrepot->line_id, '', 1, 0, $lines[$i]->fk_product, '', 1).' - '.$langs->trans("NA").'
'.$langs->trans("NotEnoughStock").'
'.$formproduct->selectLotStock('', 'batchl'.$line_id.'_0', '', 1, 0, $lines[$i]->fk_product).'
'.$unit_order.''.$formproduct->selectWarehouses($lines[$i]->entrepot_id, 'entl'.$line_id, '', 1, 0, $lines[$i]->fk_product, '', 1).' - '.$langs->trans("NA").'
'.$unit_order.''.$formproduct->selectWarehouses($detail_entrepot->entrepot_id, 'entl'.$detail_entrepot->line_id, '', 1, 0, $lines[$i]->fk_product, '', 1).' - '.$langs->trans("NA").'
'.$langs->trans("NotEnoughStock").'
'.$unit_order.'
'.$lines[$i]->qty_shipped.' '.$unit_order.''; - if ($lines[$i]->entrepot_id > 0) { - $entrepot = new Entrepot($db); - $entrepot->fetch($lines[$i]->entrepot_id); - print $entrepot->getNomUrl(1); - } elseif (count($lines[$i]->details_entrepot) > 1) { - $detail = ''; - foreach ($lines[$i]->details_entrepot as $detail_entrepot) { - if ($detail_entrepot->entrepot_id > 0) { - $entrepot = new Entrepot($db); - $entrepot->fetch($detail_entrepot->entrepot_id); - $detail .= $langs->trans("DetailWarehouseFormat", $entrepot->libelle, $detail_entrepot->qty_shipped).'
'; - } + print '
'.$lines[$i]->qty_shipped.' '.$unit_order.''; + if ($lines[$i]->entrepot_id > 0) { + $entrepot = new Entrepot($db); + $entrepot->fetch($lines[$i]->entrepot_id); + print $entrepot->getNomUrl(1); + } elseif (count($lines[$i]->details_entrepot) > 1) { + $detail = ''; + foreach ($lines[$i]->details_entrepot as $detail_entrepot) { + if ($detail_entrepot->entrepot_id > 0) { + $entrepot = new Entrepot($db); + $entrepot->fetch($detail_entrepot->entrepot_id); + $detail .= $langs->trans("DetailWarehouseFormat", $entrepot->libelle, $detail_entrepot->qty_shipped).'
'; } - print $form->textwithtooltip(img_picto('', 'object_stock').' '.$langs->trans("DetailWarehouseNumber"), $detail); + } + print $form->textwithtooltip(img_picto('', 'object_stock').' '.$langs->trans("DetailWarehouseNumber"), $detail); + } + print '
'; + if ($lines[$i]->product_tobatch) { + $detail = ''; + foreach ($lines[$i]->detail_batch as $dbatch) { // $dbatch is instance of ExpeditionLineBatch + $detail .= $langs->trans("Batch").': '.$dbatch->batch; + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + $detail .= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby, "day"); + } + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + $detail .= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby, "day"); + } + $detail .= ' - '.$langs->trans("Qty").': '.$dbatch->qty; + $detail .= '
'; + } + print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"), $detail); + } else { + print $langs->trans("NA"); } print '
'; - if ($lines[$i]->product_tobatch) { - $detail = ''; - foreach ($lines[$i]->detail_batch as $dbatch) { // $dbatch is instance of ExpeditionLineBatch - $detail .= $langs->trans("Batch").': '.$dbatch->batch; - if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { - $detail .= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby, "day"); - } - if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { - $detail .= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby, "day"); - } - $detail .= ' - '.$langs->trans("Qty").': '.$dbatch->qty; - $detail .= '
'; - } - print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"), $detail); - } else { - print $langs->trans("NA"); - } - print '
'; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { - print $lines[$i]->weight * $lines[$i]->qty_shipped.' '.measuringUnitString(0, "weight", $lines[$i]->weight_units); - } else { - print ' '; - } - print ''; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { - print $lines[$i]->volume * $lines[$i]->qty_shipped.' '.measuringUnitString(0, "volume", $lines[$i]->volume_units); - } else { - print ' '; - } - print ''.$lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuringUnitString(0, "volume", $lines[$i]->volume_units).''; - print '
'; - print '
'; - print '
'; - print 'id.'">'.img_edit().''; - print ''; - print 'id.'">'.img_delete().''; - print '
'; + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { + print $lines[$i]->weight * $lines[$i]->qty_shipped.' '.measuringUnitString(0, "weight", $lines[$i]->weight_units); + } else { + print ' '; + } + print ''; + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { + print $lines[$i]->volume * $lines[$i]->qty_shipped.' '.measuringUnitString(0, "volume", $lines[$i]->volume_units); + } else { + print ' '; + } + print ''.$lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuringUnitString(0, "volume", $lines[$i]->volume_units).''; + print '
'; + print '
'; + print '
'; + print 'id.'">'.img_edit().''; + print ''; + print 'id.'">'.img_delete().''; + print '
\n"; - print ''; - print '
'; } + // TODO Show also lines ordered but not delivered + + print "\n"; + print ''; + print '
'; + print dol_get_fiche_end(); diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php index 357683ef35a..450fe943d7e 100644 --- a/htdocs/expedition/class/api_shipments.class.php +++ b/htdocs/expedition/class/api_shipments.class.php @@ -686,6 +686,11 @@ class Shipments extends DolibarrApi if (!empty($object->lines) && is_array($object->lines)) { foreach ($object->lines as $line) { + if (is_array($line->detail_batch)) { + foreach ($line->detail_batch as $keytmp2 => $valtmp2) { + unset($line->detail_batch[$keytmp2]->db); + } + } unset($line->tva_tx); unset($line->vat_src_code); unset($line->total_ht); diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 0b8668a6c1a..dd6dfee55b1 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1911,23 +1911,6 @@ class Expedition extends CommonObject dol_syslog(get_class($this)."::initAsSpecimen"); - // Load array of products prodids - $num_prods = 0; - $prodids = array(); - $sql = "SELECT rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."product"; - $sql .= " WHERE entity IN (".getEntity('product').")"; - $resql = $this->db->query($sql); - if ($resql) { - $num_prods = $this->db->num_rows($resql); - $i = 0; - while ($i < $num_prods) { - $i++; - $row = $this->db->fetch_row($resql); - $prodids[$i] = $row[0]; - } - } - $order = new Commande($this->db); $order->initAsSpecimen(); @@ -1940,7 +1923,7 @@ class Expedition extends CommonObject $this->date = $now; $this->date_creation = $now; $this->date_valid = $now; - $this->date_delivery = $now; + $this->date_delivery = $now + 24 * 3600; $this->date_expedition = $now + 24 * 3600; $this->entrepot_id = 0; @@ -2450,18 +2433,18 @@ class Expedition extends CommonObject /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'expedition' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } } diff --git a/htdocs/expedition/class/expeditionlinebatch.class.php b/htdocs/expedition/class/expeditionlinebatch.class.php index 5d99d1c7a74..ab1d9123830 100644 --- a/htdocs/expedition/class/expeditionlinebatch.class.php +++ b/htdocs/expedition/class/expeditionlinebatch.class.php @@ -194,7 +194,7 @@ class ExpeditionLineBatch extends CommonObject } $sql .= " WHERE fk_expeditiondet=".(int) $id_line_expdet; - dol_syslog(__METHOD__."", LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 14544087647..26cafe14b5d 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -78,6 +78,7 @@ $search_sale = GETPOST('search_sale', 'int'); $search_categ_cus = GETPOST("search_categ_cus", 'int'); $search_product_category = GETPOST('search_product_category', 'int'); $optioncss = GETPOST('optioncss', 'alpha'); +$mode = GETPOST('mode', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -489,6 +490,9 @@ $arrayofselected = is_array($toselect) ? $toselect : array(); $expedition = new Expedition($db); $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -577,7 +581,10 @@ $massactionbutton = $form->selectMassAction('', $arrayofmassactions); // $url = DOL_URL_ROOT.'/expedition/card.php?action=create'; // if (!empty($socid)) $url .= '&socid='.$socid; // $newcardbutton = dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', $url, '', $user->rights->expedition->creer); -$newcardbutton = dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/expedition/card.php?action=create2', '', $user->rights->expedition->creer); +$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 .= dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/expedition/card.php?action=create2', '', $user->rights->expedition->creer); $i = 0; print ''."\n"; @@ -589,6 +596,7 @@ print ''; print ''; print ''; +print ''; print_barre_liste($langs->trans('ListOfSendings'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'dolly', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -786,8 +794,8 @@ if (!empty($arrayfields['e.tms']['checked'])) { } // Status if (!empty($arrayfields['e.fk_statut']['checked'])) { - print ''; - print $form->selectarray('search_status', array('0'=>$langs->trans('StatusSendingDraftShort'), '1'=>$langs->trans('StatusSendingValidatedShort'), '2'=>$langs->trans('StatusSendingProcessedShort')), $search_status, 1, 0, 0, '', 0, 0, 0, '', 'onrightofpage'); + print ''; + print $form->selectarray('search_status', array('0'=>$langs->trans('StatusSendingDraftShort'), '1'=>$langs->trans('StatusSendingValidatedShort'), '2'=>$langs->trans('StatusSendingProcessedShort')), $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage'); print ''; } // Status billed @@ -892,213 +900,227 @@ while ($i < min($num, $limit)) { $object = new Expedition($db); $object->fetch($obj->rowid); - print ''; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + print '
'; + } + $object->socid = $companystatic->getNomUrl(1); + $object->date_delivery = $obj->delivery_date; + $object->town = $obj->town; + print $object->getKanbanView(''); + if ($i == min($num, $limit) - 1) { + print '
'; + print ''; + } + } else { + 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($obj->rowid, $arrayofselected)) { - $selected = 1; + // 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($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; } - print ''; - } - print ''; - } - // Ref - if (!empty($arrayfields['e.ref']['checked'])) { - print ''; - print $shipment->getNomUrl(1); - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Ref customer - if (!empty($arrayfields['e.ref_customer']['checked'])) { - print ""; - print $obj->ref_customer; - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Third party - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - print $companystatic->getNomUrl(1); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Town - if (!empty($arrayfields['s.town']['checked'])) { - print ''; - print $obj->town; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Zip - if (!empty($arrayfields['s.zip']['checked'])) { - print ''; - print $obj->zip; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // State - if (!empty($arrayfields['state.nom']['checked'])) { - print ''.$obj->state_name."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; - $tmparray = getCountry($obj->fk_pays, 'all'); - print $tmparray['label']; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Type ent - if (!empty($arrayfields['typent.code']['checked'])) { - print ''; - if (isset($typenArray[$obj->typent_code])) { - print $typenArray[$obj->typent_code]; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Weight - if (!empty($arrayfields['e.weight']['checked'])) { - print ''; - if (empty($object->trueWeight)) { - $tmparray = $object->getTotalWeightVolume(); - print showDimensionInBestUnit($tmparray['weight'], 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); - print $form->textwithpicto('', $langs->trans('EstimatedWeight'), 1); - } else { - print $object->trueWeight; - print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", $object->weight_units) : ''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date delivery planed - if (!empty($arrayfields['e.date_delivery']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->delivery_date), "dayhour"); - print "\n"; - } - if (!empty($arrayfields['e.fk_shipping_method']['checked'])) { - // Get code using getLabelFromKey - $code=$langs->getLabelFromKey($db, $shipment->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); - print ''; - if ($shipment->shipping_method_id > 0) print $langs->trans("SendingMethod".strtoupper($code)); - print ''; - } - // Tracking number - if (!empty($arrayfields['e.tracking_number']['checked'])) { - $shipment->getUrlTrackingStatus($obj->tracking_number); - print ''.$shipment->tracking_url."\n"; - //print $form->editfieldval("TrackingNumber", 'tracking_number', $obj->tracking_url, $obj, $user->rights->expedition->creer, 'string', $obj->tracking_number); - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked'])) { - $shipment->fetchObjectLinked($shipment->id, $shipment->element); - $receiving = ''; - if (is_array($shipment->linkedObjects['delivery']) && count($shipment->linkedObjects['delivery']) > 0) { - $receiving = reset($shipment->linkedObjects['delivery']); - } - - if (!empty($arrayfields['l.ref']['checked'])) { - // Ref - print ''; - print !empty($receiving) ? $receiving->getNomUrl($db) : ''; print ''; } - - if (!empty($arrayfields['l.date_delivery']['checked'])) { - // Date received - print ''; - print dol_print_date($db->jdate($obj->date_reception), "day"); - print ''."\n"; - } - } - - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['e.datec']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['e.tms']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['e.fk_statut']['checked'])) { - print ''.$shipment->LibStatut($obj->fk_statut, 5).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Billed - if (!empty($arrayfields['e.billed']['checked'])) { - print ''.yn($obj->billed).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // 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($obj->rowid, $arrayofselected)) { - $selected = 1; + // Ref + if (!empty($arrayfields['e.ref']['checked'])) { + print ''; + print $shipment->getNomUrl(1); + print "\n"; + if (!$i) { + $totalarray['nbfield']++; } - print ''; } - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - print "\n"; + // Ref customer + if (!empty($arrayfields['e.ref_customer']['checked'])) { + print ""; + print $obj->ref_customer; + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Third party + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + print $companystatic->getNomUrl(1); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Town + if (!empty($arrayfields['s.town']['checked'])) { + print ''; + print $obj->town; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Zip + if (!empty($arrayfields['s.zip']['checked'])) { + print ''; + print $obj->zip; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // State + if (!empty($arrayfields['state.nom']['checked'])) { + print ''.$obj->state_name."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; + $tmparray = getCountry($obj->fk_pays, 'all'); + print $tmparray['label']; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Type ent + if (!empty($arrayfields['typent.code']['checked'])) { + print ''; + if (isset($typenArray[$obj->typent_code])) { + print $typenArray[$obj->typent_code]; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Weight + if (!empty($arrayfields['e.weight']['checked'])) { + print ''; + if (empty($object->trueWeight)) { + $tmparray = $object->getTotalWeightVolume(); + print showDimensionInBestUnit($tmparray['weight'], 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); + print $form->textwithpicto('', $langs->trans('EstimatedWeight'), 1); + } else { + print $object->trueWeight; + print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", $object->weight_units) : ''; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date delivery planed + if (!empty($arrayfields['e.date_delivery']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->delivery_date), "dayhour"); + print "\n"; + } + if (!empty($arrayfields['e.fk_shipping_method']['checked'])) { + // Get code using getLabelFromKey + $code=$langs->getLabelFromKey($db, $shipment->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); + print ''; + if ($shipment->shipping_method_id > 0) print $langs->trans("SendingMethod".strtoupper($code)); + print ''; + } + // Tracking number + if (!empty($arrayfields['e.tracking_number']['checked'])) { + $shipment->getUrlTrackingStatus($obj->tracking_number); + print ''.$shipment->tracking_url."\n"; + //print $form->editfieldval("TrackingNumber", 'tracking_number', $obj->tracking_url, $obj, $user->rights->expedition->creer, 'string', $obj->tracking_number); + if (!$i) { + $totalarray['nbfield']++; + } + } + + if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked'])) { + $shipment->fetchObjectLinked($shipment->id, $shipment->element); + $receiving = ''; + if (is_array($shipment->linkedObjects['delivery']) && count($shipment->linkedObjects['delivery']) > 0) { + $receiving = reset($shipment->linkedObjects['delivery']); + } + + if (!empty($arrayfields['l.ref']['checked'])) { + // Ref + print ''; + print !empty($receiving) ? $receiving->getNomUrl($db) : ''; + print ''; + } + + if (!empty($arrayfields['l.date_delivery']['checked'])) { + // Date received + print ''; + print dol_print_date($db->jdate($obj->date_reception), "day"); + print ''."\n"; + } + } + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['e.datec']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['e.tms']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['e.fk_statut']['checked'])) { + print ''.$shipment->LibStatut($obj->fk_statut, 5).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Billed + if (!empty($arrayfields['e.billed']['checked'])) { + print ''.yn($obj->billed).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // 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($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + + print "\n"; + } $i++; } diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 9394269a03a..2adf16e4c35 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -329,7 +329,7 @@ if ($id > 0 || !empty($ref)) { $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')"; } - print ''.$langs->trans('Discounts').''; + print ''.$langs->trans('Discounts').''; $absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount); $absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote); @@ -393,7 +393,7 @@ if ($id > 0 || !empty($ref)) { print 'id.'">'.img_edit($langs->trans('SetAvailability'), 1).''; } print ''; - print ''; + print ''; if ($action == 'editavailability') { $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'availability_id', 1); } else { @@ -450,7 +450,7 @@ if ($id > 0 || !empty($ref)) { print 'id.'">'.img_edit($langs->trans('SetDemandReason'), 1).''; } print ''; - print ''; + print ''; if ($action == 'editdemandreason') { $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'demand_reason_id', 1); } else { @@ -500,11 +500,11 @@ if ($id > 0 || !empty($ref)) { $totalVolume = $tmparray['volume']; if ($totalWeight || $totalVolume) { print ''.$langs->trans("CalculatedWeight").''; - print ''; + print ''; print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); print ''; print ''.$langs->trans("CalculatedVolume").''; - print ''; + print ''; print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); print ''; } @@ -524,7 +524,7 @@ if ($id > 0 || !empty($ref)) { } print ''; print ''; - print ''; + print ''; if ($action != 'editincoterm') { print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); } else { diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index f6aa14865ec..75c5b02de10 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -295,7 +295,7 @@ if (empty($reshook)) { } if (!$error && empty($conf->global->EXPENSEREPORT_ALLOW_OVERLAPPING_PERIODS)) { - $overlappingExpenseReportID = $object->periode_existe($fuser, $object->date_debut, $object->date_fin, true); + $overlappingExpenseReportID = $object->periode_existe($fuser, $object->date_debut, $object->date_fin); if ($overlappingExpenseReportID > 0) { $error++; @@ -971,7 +971,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } } else { - setEventMessages("NOT_AUTHOR", '', 'errors'); + setEventMessages("NOT_AUTHOR", null, 'errors'); } } @@ -2427,12 +2427,14 @@ if ($action == 'create') { } else { jQuery("input[name=\"senditdisabled\"]").prop("name", "sendit"); } + // TODO Switch css fa-chevron-dow and add fa-chevron-up return false; }); $( ".aattachtodoc" ).click(function() { console.log("We click on toggle of aattachtodoc"); jQuery(".trattachnewfilenow").toggle(); jQuery(".truploadnewfilenow").hide(); + // TODO Switch css fa-chevron-dow and add fa-chevron-up return false; });'."\n"; if (is_array(GETPOST('attachfile', 'array')) && count(GETPOST('attachfile', 'array')) && $action != 'updateline') { diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index ecb1cf3d65b..63cbeaad67b 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -985,6 +985,8 @@ class ExpenseReport extends CommonObject return -1; } } + + return 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -1328,8 +1330,6 @@ class ExpenseReport extends CommonObject public function set_save_from_refuse($fuser) { // phpcs:enable - global $conf, $langs; - // Sélection de la date de début de la NDF $sql = 'SELECT date_debut'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element; @@ -1357,6 +1357,8 @@ class ExpenseReport extends CommonObject } else { dol_syslog(get_class($this)."::set_save_from_refuse expensereport already with save status", LOG_WARNING); } + + return 0; } /** @@ -1465,6 +1467,8 @@ class ExpenseReport extends CommonObject } else { dol_syslog(get_class($this)."::setDeny expensereport already with refuse status", LOG_WARNING); } + + return 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -1531,6 +1535,8 @@ class ExpenseReport extends CommonObject } else { dol_syslog(get_class($this)."::set_unpaid expensereport already with unpaid status", LOG_WARNING); } + + return 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -1553,7 +1559,7 @@ class ExpenseReport extends CommonObject $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql .= " SET fk_statut = ".self::STATUS_CANCELED.", fk_user_cancel = ".((int) $fuser->id); $sql .= ", date_cancel='".$this->db->idate($this->date_cancel)."'"; - $sql .= " ,detail_cancel='".$this->db->escape($detail)."'"; + $sql .= ", detail_cancel='".$this->db->escape($detail)."'"; $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::set_cancel", LOG_DEBUG); @@ -1585,6 +1591,7 @@ class ExpenseReport extends CommonObject } else { dol_syslog(get_class($this)."::set_cancel expensereport already with cancel status", LOG_WARNING); } + return 0; } /** @@ -1733,9 +1740,9 @@ class ExpenseReport extends CommonObject /** * Update total of an expense report when you add a line. * - * @param string $ligne_total_ht Amount without taxes + * @param string $ligne_total_ht Amount without taxes * @param string $ligne_total_tva Amount of all taxes - * @return void + * @return int */ public function update_totaux_add($ligne_total_ht, $ligne_total_tva) { @@ -1884,7 +1891,7 @@ class ExpenseReport extends CommonObject * * @param int $type Type of line * @param string $seller Seller, but actually he is unknown - * @return true or false + * @return boolean true or false */ public function checkRules($type = 0, $seller = '') { @@ -2179,6 +2186,8 @@ class ExpenseReport extends CommonObject return -2; } } + + return 0; } /** @@ -2572,14 +2581,13 @@ class ExpenseReport extends CommonObject * \brief Compute the cost of the kilometers expense based on the number of kilometers and the vehicule category * * @param int $fk_cat Category of the vehicule used - * @param real $qty Number of kilometers - * @param real $tva VAT rate + * @param float $qty Number of kilometers + * @param float $tva VAT rate * @return int <0 if KO, total ttc if OK */ public function computeTotalKm($fk_cat, $qty, $tva) { - global $langs,$user,$db,$conf; - + global $langs, $db, $conf; $cumulYearQty = 0; $ranges = array(); @@ -2814,8 +2822,11 @@ class ExpenseReportLine extends CommonObjectLine $this->rule_warning_message = $objp->rule_warning_message; $this->db->free($result); + + return $this->id; } else { dol_print_error($this->db); + return -1; } } @@ -2828,7 +2839,7 @@ class ExpenseReportLine extends CommonObjectLine */ public function insert($notrigger = 0, $fromaddline = false) { - global $langs, $user, $conf; + global $user, $conf; $error = 0; diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index e871cba86b3..c0ba86d55ff 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -317,7 +317,7 @@ class PaymentExpenseReport extends CommonObject $sql .= " note=".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : "null").","; $sql .= " fk_bank=".(isset($this->fk_bank) ? $this->fk_bank : "null").","; $sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").","; - $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? $this->fk_user_modif : "null").""; + $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? $this->fk_user_modif : "null"); $sql .= " WHERE rowid=".((int) $this->id); diff --git a/htdocs/expensereport/index.php b/htdocs/expensereport/index.php index fced8a58e14..c8048e78621 100644 --- a/htdocs/expensereport/index.php +++ b/htdocs/expensereport/index.php @@ -78,7 +78,7 @@ $childids[] = $user->id; $help_url = "EN:Module_Expense_Reports|FR:Module_Notes_de_frais"; -llxHeader('', $langs->trans("ListOfFees"), $help_url); +llxHeader('', $langs->trans("TripsAndExpenses"), $help_url); $label = $somme = $nb = array(); diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index bded18fa597..ad16d5fb09f 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -254,7 +254,7 @@ $formexpensereport = new FormExpenseReport($db); $fuser = new User($db); -$title = $langs->trans("ListOfTrips"); +$title = $langs->trans("TripsAndExpenses"); llxHeader('', $title); $max_year = 5; diff --git a/htdocs/expensereport/payment/card.php b/htdocs/expensereport/payment/card.php index db6c21e202f..bdc7b51312a 100644 --- a/htdocs/expensereport/payment/card.php +++ b/htdocs/expensereport/payment/card.php @@ -209,7 +209,7 @@ if ($resql) { print ''.price($objp->total_ttc - $objp->amount).''; // Status - print ''.$expensereport->getLibStatut(4, $objp->amount).''; + print ''.$expensereport->getLibStatut(4).''; print "\n"; diff --git a/htdocs/expensereport/payment/info.php b/htdocs/expensereport/payment/info.php index b5d87b81a51..c1e00ffa0fb 100644 --- a/htdocs/expensereport/payment/info.php +++ b/htdocs/expensereport/payment/info.php @@ -52,7 +52,7 @@ $confirm = GETPOST('confirm', 'alpha'); llxHeader('', $langs->trans("Payment")); $object = new PaymentExpenseReport($db); -$object->fetch($id, $ref); +$object->fetch($id); $object->info($object->id); $head = payment_expensereport_prepare_head($object); diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 4591ccd0bf3..f35ae3a3121 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -1187,7 +1187,7 @@ if ($step == 5 && $datatoexport) { $htmltabloflibs .= ''.$langs->trans("LibraryVersion").''; $htmltabloflibs .= ''."\n"; - $liste = $objmodelexport->liste_modeles($db); + $liste = $objmodelexport->listOfAvailableExportFormat($db); $listeall = $liste; foreach ($listeall as $key => $val) { if (preg_match('/__\(Disabled\)__/', $listeall[$key])) { diff --git a/htdocs/exports/index.php b/htdocs/exports/index.php index 41d6cd18ed0..6039a9c447a 100644 --- a/htdocs/exports/index.php +++ b/htdocs/exports/index.php @@ -72,7 +72,7 @@ print ''; include_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php'; $model = new ModeleExports($db); -$liste = $model->liste_modeles($db); // This is not a static method for exports because method load non static properties +$liste = $model->listOfAvailableExportFormat($db); // This is not a static method for exports because method load non static properties foreach ($liste as $key => $val) { if (preg_match('/__\(Disabled\)__/', $liste[$key])) { diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php index 45779950ea6..22f77546090 100644 --- a/htdocs/fichinter/card-rec.php +++ b/htdocs/fichinter/card-rec.php @@ -234,7 +234,7 @@ if ($action == 'add') { } elseif ($action == 'delete' && $user->rights->ficheinter->supprimer) { // delete modele $object->fetch($id); - $object->delete(); + $object->delete($user); $id = 0; header('Location: '.$_SERVER["PHP_SELF"]); exit; @@ -761,7 +761,7 @@ if ($action == 'create') { if ($user->rights->ficheinter->creer) { print ''; } diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index e36598d04bc..b072f4c756d 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -501,6 +501,8 @@ class Fichinter extends CommonObject $this->db->free($resql); return 1; } + + return 0; } else { $this->error = $this->db->lasterror(); return -1; @@ -515,8 +517,6 @@ class Fichinter extends CommonObject */ public function setDraft($user) { - global $langs, $conf; - $error = 0; // Protection @@ -664,6 +664,8 @@ class Fichinter extends CommonObject return -1; } } + + return 0; } /** @@ -904,8 +906,6 @@ class Fichinter extends CommonObject */ public function info($id) { - global $conf; - $sql = "SELECT f.rowid,"; $sql .= " f.datec,"; $sql .= " f.tms as date_modification,"; @@ -955,7 +955,7 @@ class Fichinter extends CommonObject * @param int $notrigger Disable trigger * @return int <0 if KO, >0 if OK */ - public function delete($user, $notrigger = 0) + public function delete(User $user, $notrigger = 0) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -1074,13 +1074,11 @@ class Fichinter extends CommonObject * * @param User $user Object user who define * @param integer $date_delivery date of delivery - * @return int <0 if ko, >0 if ok + * @return int <0 if KO, >0 if OK */ public function set_date_delivery($user, $date_delivery) { // phpcs:enable - global $conf; - if ($user->rights->ficheinter->creer) { $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter "; $sql .= " SET datei = '".$this->db->idate($date_delivery)."'"; @@ -1096,6 +1094,8 @@ class Fichinter extends CommonObject return -1; } } + + return 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -1109,8 +1109,6 @@ class Fichinter extends CommonObject public function set_description($user, $description) { // phpcs:enable - global $conf; - if ($user->rights->ficheinter->creer) { $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter "; $sql .= " SET description = '".$this->db->escape($description)."',"; @@ -1126,6 +1124,8 @@ class Fichinter extends CommonObject return -1; } } + + return 0; } @@ -1135,13 +1135,11 @@ class Fichinter extends CommonObject * * @param User $user Object user who modify * @param int $contractid Description - * @return int <0 if ko, >0 if ok + * @return int <0 if KO, >0 if OK */ public function set_contrat($user, $contractid) { // phpcs:enable - global $conf; - if ($user->rights->ficheinter->creer) { $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter "; $sql .= " SET fk_contrat = ".((int) $contractid); @@ -1155,6 +1153,7 @@ class Fichinter extends CommonObject return -1; } } + return -2; } @@ -1261,7 +1260,7 @@ class Fichinter extends CommonObject { dol_syslog(get_class($this)."::addline $fichinterid, $desc, $date_intervention, $duration"); - if ($this->statut == 0) { + if ($this->statut == self::STATUS_DRAFT) { $this->db->begin(); // Insertion ligne @@ -1288,6 +1287,8 @@ class Fichinter extends CommonObject return -1; } } + + return 0; } @@ -1300,7 +1301,7 @@ class Fichinter extends CommonObject */ public function initAsSpecimen() { - global $user, $langs, $conf; + global $langs; $now = dol_now(); @@ -1383,18 +1384,18 @@ class Fichinter extends CommonObject /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'fichinter' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php index 6f9beb5d051..44dd63abcd2 100644 --- a/htdocs/fichinter/class/fichinterrec.class.php +++ b/htdocs/fichinter/class/fichinterrec.class.php @@ -150,7 +150,7 @@ class FichinterRec extends Fichinter $fichintsrc = new Fichinter($this->db); $result = $fichintsrc->fetch($this->id_origin); - $result = $fichintsrc->fetch_lines(1); // to get all lines + $result = $fichintsrc->fetch_lines(); // to get all lines if ($result > 0) { @@ -411,16 +411,13 @@ class FichinterRec extends Fichinter /** * Delete template fichinter rec * - * @param int $rowid Id of fichinter rec to delete. If empty, we delete current instance of fichinter rec - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @param int $idwarehouse Id warehouse to use for stock change. + * @param User $user Object user who delete + * @param int $notrigger Disable trigger * @return int <0 if KO, >0 if OK */ - public function delete($rowid = 0, $notrigger = 0, $idwarehouse = -1) + public function delete(User $user, $notrigger = 0) { - if (empty($rowid)) { - $rowid = $this->id; - } + $rowid = $this->id; dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG); @@ -664,18 +661,15 @@ class FichinterRec extends Fichinter * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @param string $option ''=Create a specimen fichinter with lines, 'nolines'=No lines * @return void */ - public function initAsSpecimen($option = '') + public function initAsSpecimen() { - global $user, $langs, $conf; + //$now = dol_now(); + //$arraynow = dol_getdate($now); + //$nownotime = dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); - $now = dol_now(); - $arraynow = dol_getdate($now); - $nownotime = dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); - - parent::initAsSpecimen($option); + parent::initAsSpecimen(); $this->usenewprice = 1; } @@ -683,16 +677,16 @@ class FichinterRec extends Fichinter /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array('fichinter_rec'); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index a3b69d6e26c..89be444d4af 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -213,7 +213,7 @@ if (isModEnabled('contrat')) { $now = dol_now(); $help_url = ''; -$title = $langs->trans("ListOfInterventions"); +$title = $langs->trans("Interventions"); $morejs = array(); $morecss = array(); @@ -249,7 +249,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { } // Add fields from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sqlfields = $sql; // $sql fields to remove for count total @@ -498,7 +498,7 @@ $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfi $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; -print ''."\n"; +print '
'."\n"; // Fields title search // -------------------------------------------------------------------- @@ -569,13 +569,13 @@ if (!empty($arrayfields['f.note_private']['checked'])) { } // Status if (!empty($arrayfields['f.fk_statut']['checked'])) { - print ''; } // Fields of detail line @@ -865,6 +865,9 @@ while ($i < $imaxinloop) { if (!$i) { $totalarray['type'][$totalarray['nbfield']] = 'duration'; } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'fd.duree'; + } $totalarray['val']['fd.duree'] += $obj->duree; } // Action column diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 910b56ddae4..aca15e9d7a3 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -34,7 +34,7 @@ if (!defined('DOL_APPLICATION_TITLE')) { define('DOL_APPLICATION_TITLE', 'Dolibarr'); } if (!defined('DOL_VERSION')) { - define('DOL_VERSION', '17.0.0-beta'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c + define('DOL_VERSION', '18.0.0-alpha'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c } if (!defined('EURO')) { diff --git a/htdocs/fourn/ajax/getSupplierPrices.php b/htdocs/fourn/ajax/getSupplierPrices.php index 29cf421059e..66001ccc5a6 100644 --- a/htdocs/fourn/ajax/getSupplierPrices.php +++ b/htdocs/fourn/ajax/getSupplierPrices.php @@ -88,7 +88,7 @@ if ($idprod > 0) { $label .= ' ('.$productSupplier->fourn_ref.')'; } - $prices[] = array("id" => $productSupplier->product_fourn_price_id, "price" => price2num($price, 0, '', 0), "label" => $label, "title" => $title); // For price field, we must use price2num(), for label or title, price() + $prices[] = array("id" => $productSupplier->product_fourn_price_id, "price" => price2num($price, '', 0), "label" => $label, "title" => $title); // For price field, we must use price2num(), for label or title, price() } } diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 90a760e14a1..19335656f51 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -98,7 +98,8 @@ if (empty($reshook)) { $action = ""; } - if ($action == 'setsupplieraccountancycode') { + // Set supplier accounting account + if ($action == 'setsupplieraccountancycode' && $user->hasRight('societe', 'creer')) { $result = $object->fetch($id); $object->code_compta_fournisseur = GETPOST("supplieraccountancycode"); $result = $object->update($object->id, $user, 1, 0, 1); @@ -106,8 +107,17 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } } + // Set vat number accounting account + if ($action == 'settva_intra' && $user->hasRight('societe', 'creer')) { + $result = $object->fetch($id); + $object->tva_intra = GETPOST("tva_intra"); + $result = $object->update($object->id, $user, 1, 0, 0); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } // Set payment terms of the settlement - if ($action == 'setconditions' && $user->rights->societe->creer) { + if ($action == 'setconditions' && $user->hasRight('societe', 'creer')) { $object->fetch($id); $result = $object->setPaymentTerms(GETPOST('cond_reglement_supplier_id', 'int')); if ($result < 0) { @@ -115,7 +125,7 @@ if (empty($reshook)) { } } // Payment mode - if ($action == 'setmode' && $user->rights->societe->creer) { + if ($action == 'setmode' && $user->hasRight('societe', 'creer')) { $object->fetch($id); $result = $object->setPaymentMethods(GETPOST('mode_reglement_supplier_id', 'int')); if ($result < 0) { @@ -124,7 +134,7 @@ if (empty($reshook)) { } // Bank account - if ($action == 'setbankaccount' && $user->rights->societe->creer) { + if ($action == 'setbankaccount' && $user->hasRight('societe', 'creer')) { $object->fetch($id); $result = $object->setBankAccount(GETPOST('fk_account', 'int')); if ($result < 0) { @@ -133,7 +143,7 @@ if (empty($reshook)) { } // update supplier order min amount - if ($action == 'setsupplier_order_min_amount') { + if ($action == 'setsupplier_order_min_amount' && $user->hasRight('societe', 'creer')) { $object->fetch($id); $object->supplier_order_min_amount = price2num(GETPOST('supplier_order_min_amount', 'alpha')); $result = $object->update($object->id, $user); @@ -142,7 +152,7 @@ if (empty($reshook)) { } } - if ($action == 'update_extras') { + if ($action == 'update_extras' && $user->hasRight('societe', 'creer')) { $object->fetch($id); $object->oldcopy = dol_clone($object); @@ -261,8 +271,12 @@ if ($object->id > 0) { } // TVA Intra - print ''; // Default terms of the settlement diff --git a/htdocs/fourn/class/fournisseur.class.php b/htdocs/fourn/class/fournisseur.class.php index baed7051ef8..30dc5c17425 100644 --- a/htdocs/fourn/class/fournisseur.class.php +++ b/htdocs/fourn/class/fournisseur.class.php @@ -209,17 +209,17 @@ class Fournisseur extends Societe /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old third-party id - * @param int $dest_id New third-party id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'facture_fourn' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 4fc242bdbcc..1ae5ffd04ce 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1594,7 +1594,7 @@ class CommandeFournisseur extends CommonOrder $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; $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 .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null").""; + $sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); $sql .= " WHERE rowid=".((int) $this->id); @@ -3265,18 +3265,18 @@ class CommandeFournisseur extends CommonOrder /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'commande_fournisseur' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** @@ -3901,8 +3901,8 @@ class CommandeFournisseurLigne extends CommonOrderLine $sql .= ", vat_src_code = '".(empty($this->vat_src_code) ? '' : $this->vat_src_code)."'"; $sql .= ", tva_tx='".price2num($this->tva_tx)."'"; - $sql .= ", localtax1_tx='".price2num($this->total_localtax1)."'"; - $sql .= ", localtax2_tx='".price2num($this->total_localtax2)."'"; + $sql .= ", localtax1_tx='".price2num($this->localtax1_tx)."'"; + $sql .= ", localtax2_tx='".price2num($this->localtax2_tx)."'"; $sql .= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'"; $sql .= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'"; $sql .= ", qty='".price2num($this->qty)."'"; @@ -3919,10 +3919,10 @@ class CommandeFournisseurLigne extends CommonOrderLine $sql .= ($this->fk_unit ? ", fk_unit='".$this->db->escape($this->fk_unit)."'" : ", fk_unit=null"); // Multicurrency - $sql .= ", multicurrency_subprice=".price2num($this->multicurrency_subprice).""; - $sql .= ", multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; - $sql .= ", multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; - $sql .= ", multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; + $sql .= ", multicurrency_subprice=".price2num($this->multicurrency_subprice); + $sql .= ", multicurrency_total_ht=".price2num($this->multicurrency_total_ht); + $sql .= ", multicurrency_total_tva=".price2num($this->multicurrency_total_tva); + $sql .= ", multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc); $sql .= " WHERE rowid = ".((int) $this->id); diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php index 7c8e4acb25f..02fbff5b363 100644 --- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php +++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php @@ -218,7 +218,7 @@ class CommandeFournisseurDispatch extends CommonObjectLine $sql .= " ".(!isset($this->eatby) || dol_strlen($this->eatby) == 0 ? 'NULL' : "'".$this->db->idate($this->eatby)."'").","; $sql .= " ".(!isset($this->sellby) || dol_strlen($this->sellby) == 0 ? 'NULL' : "'".$this->db->idate($this->sellby)."'").","; $sql .= " ".(!isset($this->fk_reception) ? 'NULL' : "'".$this->db->escape($this->fk_reception)."'").","; - $sql .= " ".(!isset($this->cost_price) ? '0' : "'".$this->db->escape($this->cost_price)."'").""; + $sql .= " ".(!isset($this->cost_price) ? '0' : "'".$this->db->escape($this->cost_price)."'"); $sql .= ")"; $this->db->begin(); @@ -396,7 +396,7 @@ class CommandeFournisseurDispatch extends CommonObjectLine $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; $sql .= " batch=".(isset($this->batch) ? "'".$this->db->escape($this->batch)."'" : "null").","; $sql .= " eatby=".(dol_strlen($this->eatby) != 0 ? "'".$this->db->idate($this->eatby)."'" : 'null').","; - $sql .= " sellby=".(dol_strlen($this->sellby) != 0 ? "'".$this->db->idate($this->sellby)."'" : 'null').""; + $sql .= " sellby=".(dol_strlen($this->sellby) != 0 ? "'".$this->db->idate($this->sellby)."'" : 'null'); $sql .= " WHERE rowid=".((int) $this->id); $this->db->begin(); diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php index 738e27a84e9..1570f161582 100644 --- a/htdocs/fourn/class/fournisseur.facture-rec.class.php +++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php @@ -1737,18 +1737,18 @@ class FactureFournisseurRec extends CommonInvoice /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'facture_rec' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index adf9fac3bde..4906ae21a09 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -852,15 +852,18 @@ class FactureFournisseur extends CommonInvoice } /** - * Load object in memory from database + * Load object in memory from database * - * @param int $id Id supplier invoice - * @param string $ref Ref supplier invoice - * @return int <0 if KO, >0 if OK, 0 if not found + * @param int $id Id supplier invoice + * @param string $ref Ref supplier invoice + * @param string $ref_ext External reference of invoice + * @return int <0 if KO, >0 if OK, 0 if not found */ - public function fetch($id = '', $ref = '') + public function fetch($id = '', $ref = '', $ref_ext = '') { - global $langs; + if (empty($id) && empty($ref) && empty($ref_ext)) { + return -1; + } $sql = "SELECT"; $sql .= " t.rowid,"; @@ -911,10 +914,15 @@ class FactureFournisseur extends CommonInvoice $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON t.fk_mode_reglement = p.id"; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON t.fk_incoterms = i.rowid'; if ($id) { - $sql .= " WHERE t.rowid=".((int) $id); - } - if ($ref) { - $sql .= " WHERE t.ref='".$this->db->escape($ref)."' AND t.entity IN (".getEntity('supplier_invoice').")"; + $sql .= " WHERE t.rowid = ".((int) $id); + } else { + $sql .= ' WHERE t.entity IN ('.getEntity('supplier_invoice').')'; // Don't use entity if you use rowid + if ($ref) { + $sql .= " AND t.ref = '".$this->db->escape($ref)."'"; + } + if ($ref_ext) { + $sql .= " AND t.ref_ext = '".$this->db->escape($ref_ext)."'"; + } } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); @@ -1259,7 +1267,7 @@ class FactureFournisseur extends CommonInvoice $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; $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 .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null").""; + $sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); $sql .= " WHERE rowid=".((int) $this->id); $this->db->begin(); @@ -1383,7 +1391,7 @@ class FactureFournisseur extends CommonInvoice $result = $this->update_price(1); if ($result > 0) { // Create link between discount and invoice line - $result = $remise->link_to_invoice($lineid, 0, 'supplier'); + $result = $remise->link_to_invoice($lineid, 0); if ($result < 0) { $this->error = $remise->error; $this->db->rollback(); @@ -3154,18 +3162,18 @@ class FactureFournisseur extends CommonInvoice /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'facture_fourn' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** @@ -3692,10 +3700,10 @@ class SupplierInvoiceLine extends CommonObjectLine } // Multicurrency - $sql .= " , multicurrency_subprice=".price2num($this->multicurrency_subprice).""; - $sql .= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; - $sql .= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; - $sql .= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; + $sql .= " , multicurrency_subprice=".price2num($this->multicurrency_subprice); + $sql .= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht); + $sql .= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva); + $sql .= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc); $sql .= " WHERE rowid = ".((int) $this->id); diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index fa1706a523a..a01c8ec00d3 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1003,35 +1003,35 @@ class ProductFournisseur extends Product /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'product_fournisseur_price' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** * Function used to replace a product id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old product id - * @param int $dest_id New product id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) + public static function replaceProduct(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'product_fournisseur_price' ); - return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceProduct($dbs, $origin_id, $dest_id, $tables); } /** diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index f559c31a89f..644469a257d 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -76,7 +76,6 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'purchaseordercard'; // To manage different context of search - $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); @@ -125,12 +124,7 @@ if ($id > 0 || !empty($ref)) { dol_print_error($db, $object->error); } } elseif (!empty($socid) && $socid > 0) { - $fourn = new Fournisseur($db); - $ret = $fourn->fetch($socid); - if ($ret < 0) { - dol_print_error($db, $object->error); - } - $object->socid = $fourn->id; + $object->socid = $socid; $ret = $object->fetch_thirdparty(); if ($ret < 0) { dol_print_error($db, $object->error); @@ -1701,16 +1695,16 @@ if ($action == 'create') { print img_picto('', 'company').$form->select_company((empty($socid) ? '' : $socid), 'socid', '(s.fournisseur=1 AND s.status=1)', 'SelectThirdParty', 1, 0, null, 0, 'minwidth175 maxwidth500 widthcentpercentminusxx'); // reload page to retrieve customer informations if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) { - print ''; + '; } print ' '; } @@ -1874,19 +1868,13 @@ if ($action == 'create') { print "\n"; } elseif (!empty($object->id)) { $result = $object->fetch($id, $ref); + $object->fetch_thirdparty(); - $societe = new Fournisseur($db); - $result = $societe->fetch($object->socid); - if ($result < 0) { - dol_print_error($db); - } + $societe = $object->thirdparty; $author = new User($db); $author->fetch($object->user_author_id); - $res = $object->fetch_optionals(); - - $head = ordersupplier_prepare_head($object); $title = $langs->trans("SupplierOrder"); @@ -2415,7 +2403,7 @@ if ($action == 'create') { // Show object lines if (!empty($object->lines)) { - $ret = $object->printObjectLines($action, $societe, $mysoc, $lineid, 1); + $object->printObjectLines($action, $object->thirdparty, $mysoc, $lineid, 1); } $num = count($object->lines); @@ -2665,7 +2653,8 @@ if ($action == 'create') { $formorder->selectInputMethod(GETPOST('methodecommande'), "methodecommande", 1); print ''; - print ''; + print ''; + print ''; - print ''; + print ''; print ''; //Remote User - print ''; + print ''; //Remote Password - print ''; + print ''; //Submit button print ''; if (empty($conf->cache['product'][$objp->fk_product])) { @@ -860,7 +861,7 @@ if ($id > 0 || !empty($ref)) { print ''; // Already dispatched - print ''; + print ''; if (isModEnabled('productbatch') && $objp->tobatch > 0) { $type = 'batch'; diff --git a/htdocs/fourn/commande/info.php b/htdocs/fourn/commande/info.php index fc3918a32f3..2ec9450bcfa 100644 --- a/htdocs/fourn/commande/info.php +++ b/htdocs/fourn/commande/info.php @@ -196,7 +196,7 @@ if ($permok) { print '
'; if (isModEnabled('agenda')) { - if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { + if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { print ''.$langs->trans("AddAction").''; } else { print ''.$langs->trans("AddAction").''; diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 4a6c5795602..1b8dbed46e2 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -67,7 +67,7 @@ $search_date_order_endyear = GETPOST('search_date_order_endyear', 'int'); $search_date_order_start = dol_mktime(0, 0, 0, $search_date_order_startmonth, $search_date_order_startday, $search_date_order_startyear); // Use tzserver $search_date_order_end = dol_mktime(23, 59, 59, $search_date_order_endmonth, $search_date_order_endday, $search_date_order_endyear); -$search_date_delivery_starvtday = GETPOST('search_date_delivery_startday', 'int'); +$search_date_delivery_startday = GETPOST('search_date_delivery_startday', 'int'); $search_date_delivery_startmonth = GETPOST('search_date_delivery_startmonth', 'int'); $search_date_delivery_startyear = GETPOST('search_date_delivery_startyear', 'int'); $search_date_delivery_endday = GETPOST('search_date_delivery_endday', 'int'); @@ -1203,12 +1203,12 @@ if ($resql) { $topicmail = "SendOrderRef"; $modelmail = "order_supplier_send"; - $objecttmp = new CommandeFournisseur($db); + $objecttmp = new CommandeFournisseur($db); // in case $object is not the good object $trackid = 'sord'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($massaction == 'prevalidate') { - print $form->formconfirm($_SERVER["PHP_SELF"].$fieldstosearchall, $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1); + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1); } if ($massaction == 'createbills') { @@ -1469,8 +1469,8 @@ if ($resql) { } // Status billed if (!empty($arrayfields['cf.billed']['checked'])) { - print '
'; } // Date valid diff --git a/htdocs/fourn/facture/card-rec.php b/htdocs/fourn/facture/card-rec.php index ead5a5f8ea8..fcfaaf2d3d6 100644 --- a/htdocs/fourn/facture/card-rec.php +++ b/htdocs/fourn/facture/card-rec.php @@ -107,8 +107,8 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); $permissionnote = $user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer;; // Used by the include of actions_dellink.inc.php -$permissiontoedit = $user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer;; // Used by the include of actions_lineupdonw.inc.php +$permissiondellink = $user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer; // Used by the include of actions_dellink.inc.php +$permissiontoedit = $user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer; // Used by the include of actions_lineupdonw.inc.php $usercanread = $user->rights->fournisseur->facture->lire || $user->rights->supplier_invoice->lire; $usercancreate = $user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 6bc9ae679bb..cdd07fa99ab 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1172,7 +1172,28 @@ if (empty($reshook)) { if (!empty($conf->global->MAIN_DEPOSIT_MULTI_TVA) && $diff != 0) { $object->fetch_lines(); $subprice_diff = $object->lines[0]->subprice - $diff / (1 + $object->lines[0]->tva_tx / 100); - $object->updateline($object->lines[0]->id, $object->lines[0]->desc, $subprice_diff, $object->lines[0]->qty, $object->lines[0]->remise_percent, $object->lines[0]->date_start, $object->lines[0]->date_end, $object->lines[0]->tva_tx, 0, 0, 'HT', $object->lines[0]->info_bits, $object->lines[0]->product_type, 0, 0, 0, $object->lines[0]->pa_ht, $object->lines[0]->label, 0, array(), 100); + $object->updateline( + $object->lines[0]->id, + $object->lines[0]->desc, + $subprice_diff, + $object->lines[0]->tva_tx, + $object->lines[0]->localtax1_tx, + $object->lines[0]->localtax2_tx, + $object->lines[0]->qty, + $object->lines[0]->fk_product, + 'HT', + $object->lines[0]->info_bits, + $object->lines[0]->product_type, + $object->lines[0]->remise_percent, + 0, + $object->lines[0]->date_start, + $object->lines[0]->date_end, + 0, + 0, + 0, + '', + 100 + ); } } elseif ($result > 0) { $lines = $srcobject->lines; @@ -1627,7 +1648,7 @@ if (empty($reshook)) { $productsupplier->fk_unit, 0, $pu_devise, - $ref_supplier, + GETPOST('fourn_ref', 'alpha'), '' ); } @@ -2080,14 +2101,15 @@ if ($action == 'create') { // reload page to retrieve supplier informations if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) { print ''; + '; } if ($fac_recid <= 0) { print ' '; @@ -2212,7 +2234,7 @@ if ($action == 'create') { jQuery(".checkforselect").prop("disabled", false); jQuery(".checkforselect").prop("checked", true); } - }; + } }); '; @@ -2649,6 +2671,7 @@ if ($action == 'create') { $resteapayer = price2num($object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT'); // Multicurrency + $multicurrency_resteapayer = 0; if (isModEnabled("multicurrency")) { $multicurrency_totalpaid = $object->getSommePaiement(1); $multicurrency_totalcreditnotes = $object->getSumCreditNotesUsed(1); @@ -2694,6 +2717,7 @@ if ($action == 'create') { // Confirmation de la conversion de l'avoir en reduc if ($action == 'converttoreduc') { + $type_fac = ''; if ($object->type == FactureFournisseur::TYPE_STANDARD) { $type_fac = 'ExcessPaid'; } elseif ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) { @@ -3628,7 +3652,7 @@ if ($action == 'create') { // Show object lines if (!empty($object->lines)) { - $ret = $object->printObjectLines($action, $societe, $mysoc, $lineid, 1); + $object->printObjectLines($action, $societe, $mysoc, $lineid, 1); } $num = count($object->lines); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index be215e891eb..126883f6202 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -1226,9 +1226,9 @@ if (!empty($arrayfields['f.tms']['checked'])) { } // Status if (!empty($arrayfields['f.fk_statut']['checked'])) { - print ''; } // Action column diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php index 6222d3db8bd..e6c1aac1372 100644 --- a/htdocs/ftp/index.php +++ b/htdocs/ftp/index.php @@ -98,41 +98,6 @@ $mesg = ''; * ACTIONS */ -// Submit file -if (GETPOST("sendit") && !empty($conf->global->MAIN_UPLOAD_DOC)) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - $result = $ecmdir->fetch(GETPOST("section", 'int')); - if (!($result > 0)) { - dol_print_error($db, $ecmdir->error); - exit; - } - $relativepath = $ecmdir->getRelativePath(); - $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; - - if (dol_mkdir($upload_dir) >= 0) { - $resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir."/".dol_unescapefile($_FILES['userfile']['name']), 0); - if (is_numeric($resupload) && $resupload > 0) { - $result = $ecmdir->changeNbOfFiles('+'); - } else { - $langs->load("errors"); - if ($resupload < 0) { // Unknown error - setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors'); - } elseif (preg_match('/ErrorFileIsInfectedWithAVirus/', $resupload)) { - // Files infected by a virus - setEventMessages($langs->trans("ErrorFileIsInfectedWithAVirus"), null, 'errors'); - } else // Known error - { - setEventMessages($langs->trans($resupload), null, 'errors'); - } - } - } else { - // Transfer failure (file exceeding the limit ?) - $langs->load("errors"); - setEventMessages($langs->trans("ErrorFailToCreateDir", $upload_dir), null, 'errors'); - } -} - if ($action == 'uploadfile') { // set up a connection or die if (!$conn_id) { @@ -189,6 +154,7 @@ if ($action == 'addfolder') { // Action ajout d'un rep if ($action == 'add' && $user->rights->ftp->setup) { + $ecmdir = new EcmDirectory($db); $ecmdir->ref = GETPOST("ref"); $ecmdir->label = GETPOST("label"); $ecmdir->description = GETPOST("desc"); @@ -317,7 +283,7 @@ if ($action == 'download') { $newsection = $section; - $result = dol_ftp_get($connect_id, $localfile, $file, $newsection); + $result = dol_ftp_get($conn_id, $localfile, $file, $newsection); if ($result) { @@ -341,9 +307,9 @@ if ($action == 'download') { header('Content-Type: '.$type); } if ($attachment) { - header('Content-Disposition: attachment; filename="'.$filename.'"'); + header('Content-Disposition: attachment; filename="'.$file.'"'); } else { - header('Content-Disposition: inline; filename="'.$filename.'"'); + header('Content-Disposition: inline; filename="'.$file.'"'); } // Ajout directives pour resoudre bug IE @@ -354,7 +320,7 @@ if ($action == 'download') { exit; } else { - setEventMessages($langs->transnoentitiesnoconv('FailedToGetFile', $remotefile), null, 'errors'); + setEventMessages($langs->transnoentitiesnoconv('FailedToGetFile', $file), null, 'errors'); } } else { dol_print_error('', $mesg); @@ -661,6 +627,7 @@ if (!function_exists('ftp_connect')) { print ''; print ""; + if ($user->hasRight('ftp', 'write')) { print load_fiche_titre($langs->trans("AttachANewFile"), null, null); print ''; @@ -672,6 +639,9 @@ if (!function_exists('ftp_connect')) { print ''; print ''; print ''; + + print '

'; + print load_fiche_titre($langs->trans("AddFolder"), null, null); print ''; print ''; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 0125becd21c..9b3f0a1ce16 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1470,7 +1470,7 @@ class Holiday extends CommonObject $sql .= " value = '".$this->db->escape($value)."'"; $sql .= " WHERE name = '".$this->db->escape($name)."'"; - dol_syslog(get_class($this).'::updateConfCP name='.$name.'', LOG_DEBUG); + dol_syslog(get_class($this).'::updateConfCP name='.$name, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { return true; @@ -1580,7 +1580,7 @@ class Holiday extends CommonObject // We add a log for each user $this->addLogCP($user->id, $userCounter['rowid'], $langs->trans('HolidaysMonthlyUpdate'), $newSolde, $userCounter['type']); - $result = $this->updateSoldeCP($userCounter['rowid'], $newSolde, $userCounter['type'], $langs->trans('HolidaysMonthlyUpdate')); + $result = $this->updateSoldeCP($userCounter['rowid'], $newSolde, $userCounter['type']); if ($result < 0) { $error++; diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index 2d47467319d..2eb69145254 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -188,7 +188,7 @@ if (empty($reshook)) { $db->commit(); if ($nbok > 0) { - setEventMessages('UpdateConfCPOK', '', 'mesgs'); + setEventMessages('UpdateConfCPOK', null, 'mesgs'); } } else { $db->rollback(); diff --git a/htdocs/hrm/admin/admin_establishment.php b/htdocs/hrm/admin/admin_establishment.php index 99212988488..59192bc5ca5 100644 --- a/htdocs/hrm/admin/admin_establishment.php +++ b/htdocs/hrm/admin/admin_establishment.php @@ -145,13 +145,12 @@ if ($result) { $establishmentstatic->label = $obj->label; $establishmentstatic->status = $obj->status; - print ''; print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print ''; @@ -160,7 +159,7 @@ if ($result) { $i++; } } else { - print ''; + print ''; } print '
'; + print ''; $tmp = $objectstatic->LibStatut(0); // To load $this->statuts_short $liststatus = $objectstatic->statuts_short; if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) { unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1 } - print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 1, 0, 0, '', 'onrightofpage'); + print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 1, 0, 0, '', 'search_status width100 onrightofpage'); print '
'.$langs->trans('VATIntra').''; - print showValueWithClipboardCPButton(dol_escape_htmltag($object->tva_intra)); + print '
'; + //print $langs->trans('VATIntra').''; + $vattoshow = ($object->tva_intra ? showValueWithClipboardCPButton(dol_escape_htmltag($object->tva_intra)) : ''); + print $form->editfieldkey("VATIntra", 'tva_intra', $object->tva_intra, $object, $user->hasRight('societe', 'creer')); + print ''; + print $form->editfieldval("VATIntra", 'tva_intra', $vattoshow, $object, $user->hasRight('societe', 'creer'), 'string', $object->tva_intra, null, null, '', 1, '', 'id', 'auto', array('valuealreadyhtmlescaped'=>1)); print '
'.$langs->trans("Comment").'
'.$langs->trans("Comment").'
'; print ''; print '     '; @@ -2731,7 +2720,7 @@ if ($action == 'create') { print $form->selectarray("type", $liv); print '
'.$langs->trans("Comment").'
'.$langs->trans("Comment").'
'; print ''; print '     '; @@ -2795,13 +2784,12 @@ if ($action == 'create') { print "
".$langs->trans("ErrorOccurredReviseAndRetry")."
"; print ''; } else { - $textinput_size = "50"; // Webservice url print '
'.$langs->trans("WebServiceURL").''.dol_print_url($ws_url).'
'.$langs->trans("User").'
'.$langs->trans("User").'
'.$langs->trans("Password").'
'.$langs->trans("Password").'
'; print ''; diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 9e3a9ba7808..504336f0a6e 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -68,7 +68,7 @@ $hookmanager->initHooks(array('ordersupplierdispatch')); // Recuperation de l'id de projet $projectid = 0; -if ($_GET["projectid"]) { +if (GETPOSTISSET("projectid")) { $projectid = GETPOST("projectid", 'int'); } @@ -782,7 +782,8 @@ if ($id > 0 || !empty($ref)) { if (!$objp->fk_product > 0) { $nbfreeproduct++; } else { - $remaintodispatch = price2num($objp->qty - ((float) $products_dispatched[$objp->rowid]), 5); // Calculation of dispatched + $alreadydispatched = isset($products_dispatched[$objp->rowid])?$products_dispatched[$objp->rowid]:0; + $remaintodispatch = price2num($objp->qty - ((float) $alreadydispatched), 5); // Calculation of dispatched if ($remaintodispatch < 0 && empty($conf->global->SUPPLIER_ORDER_ALLOW_NEGATIVE_QTY_FOR_SUPPLIER_ORDER_RETURN)) { $remaintodispatch = 0; } @@ -799,7 +800,7 @@ if ($id > 0 || !empty($ref)) { print ''."\n"; // hidden fields for js function print ''; - print ''; + print ''; print '
'.$objp->qty.''.$products_dispatched[$objp->rowid].''.$alreadydispatched.''; - print $form->selectyesno('search_billed', $search_billed, 1, false, 1, 1, 'maxwidth100 onrightofpage'); + print ''; + print $form->selectyesno('search_billed', $search_billed, 1, false, 1, 1, 'search_status width100 onrightofpage'); print ''; + print ''; $liststatus = array('0'=>$langs->trans("Draft"), '1'=>$langs->trans("Unpaid"), '2'=>$langs->trans("Paid")); - print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'onrightofpage', 1); + print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1); print '
'.$establishmentstatic->getNomUrl(1).''.$obj->label.''.$obj->address.''.$obj->zip.''.$obj->town.''.dol_escape_htmltag($obj->label).''.dol_escape_htmltag($obj->address).''.dol_escape_htmltag($obj->zip).''.dol_escape_htmltag($obj->town).''; print $establishmentstatic->getLibStatut(5); print '
'.$langs->trans("None").'
'.$langs->trans("None").'
'; diff --git a/htdocs/hrm/class/evaluation.class.php b/htdocs/hrm/class/evaluation.class.php index b35a23a6389..4a41f1c8e0e 100644 --- a/htdocs/hrm/class/evaluation.class.php +++ b/htdocs/hrm/class/evaluation.class.php @@ -118,7 +118,7 @@ class Evaluation extends CommonObject 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,), 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'default'=>0, 'visible'=>5, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '6' => 'Closed'),), 'date_eval' => array('type'=>'date', 'label'=>'DateEval', 'enabled'=>'1', 'position'=>502, 'notnull'=>1, 'visible'=>1,), - 'fk_user' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'User', 'enabled'=>'1', 'position'=>504, 'notnull'=>1, 'visible'=>1,), + 'fk_user' => array('type'=>'integer:User:user/class/user.class.php:0', 'label'=>'User', 'enabled'=>'1', 'position'=>504, 'notnull'=>1, 'visible'=>1,), 'fk_job' => array('type'=>'integer:Job:/hrm/class/job.class.php', 'label'=>'JobPosition', 'enabled'=>'1', 'position'=>505, 'notnull'=>1, 'visible'=>1,), ); public $rowid; @@ -182,7 +182,7 @@ class Evaluation extends CommonObject */ public function __construct(DoliDB $db) { - global $conf, $langs; + global $conf, $langs, $user; $this->db = $db; @@ -193,6 +193,10 @@ class Evaluation extends CommonObject $this->fields['entity']['enabled'] = 0; } + if (empty($user->rights->hrm->evaluation->readall)) { + $this->fields['fk_user']['type'].= ':rowid IN('.$this->db->sanitize(implode(", ", $user->getAllChildIds(1))).')'; + } + $this->date_eval = dol_now(); // Unset fields that are disabled @@ -849,7 +853,7 @@ class Evaluation extends CommonObject $this->labelStatus[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv('Closed'); $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated'); - $this->labelStatus[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv('Closed'); + $this->labelStatusShort[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv('Closed'); } $statusType = 'status'.$status; @@ -919,8 +923,8 @@ class Evaluation extends CommonObject $result = $objectline->fetchAll('ASC', '', 0, 0, array('customsql'=>'fk_evaluation = '.$this->id)); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; diff --git a/htdocs/hrm/class/evaluationdet.class.php b/htdocs/hrm/class/evaluationdet.class.php index f9bbde51912..5489065e52d 100644 --- a/htdocs/hrm/class/evaluationdet.class.php +++ b/htdocs/hrm/class/evaluationdet.class.php @@ -561,7 +561,8 @@ class Evaluationline extends CommonObject $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'evaluationline/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->error = $this->db->lasterror(); + $error++; + $this->error = $this->db->lasterror(); } // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments @@ -891,8 +892,8 @@ class Evaluationline extends CommonObject $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_evaluationdet = '.$this->id)); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; diff --git a/htdocs/hrm/class/job.class.php b/htdocs/hrm/class/job.class.php index 117878c10c9..93950979a1a 100644 --- a/htdocs/hrm/class/job.class.php +++ b/htdocs/hrm/class/job.class.php @@ -600,30 +600,27 @@ class Job extends CommonObject } /** - * Get last job for user + * Get the last occupied position for a user * - * @param int $fk_user id of user we need to get last job - * @return mixed|string|null + * @param int $fk_user Id of user we need to get last job + * @return Position|string Last occupied position */ public function getLastJobForUser($fk_user) { - global $db; - - $j = new Job($db); - $Tab = $j->getForUser($fk_user); + $Tab = $this->getForUser($fk_user); if (empty($Tab)) return ''; - $job = array_shift($Tab); + $lastpos = array_shift($Tab); - return $job; + return $lastpos; } /** - * Get jobs for user + * Get array of occupied positions for a user * - * @param int $userid id of user we need to get job list - * @return array of jobs + * @param int $userid Id of user we need to get job list + * @return Position[] Array of occupied positions */ public function getForUser($userid) { @@ -925,8 +922,8 @@ class Job extends CommonObject $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_job = '.$this->id)); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; diff --git a/htdocs/hrm/class/position.class.php b/htdocs/hrm/class/position.class.php index 5d0c04a4f47..98b5fd89be9 100644 --- a/htdocs/hrm/class/position.class.php +++ b/htdocs/hrm/class/position.class.php @@ -971,8 +971,8 @@ class Position extends CommonObject $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql' => 'fk_position = ' . $this->id)); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; @@ -1036,6 +1036,8 @@ class Position extends CommonObject } /** + * getForUser + * * @param int $userid id of user we need to get position list * @return array|int of positions of user with for each of them the job fetched into that array */ @@ -1049,7 +1051,7 @@ class Position extends CommonObject } /** - * Create a document onto disk according to template module. + * 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 diff --git a/htdocs/hrm/class/skill.class.php b/htdocs/hrm/class/skill.class.php index 2c86c5dca56..3f56294a7b2 100644 --- a/htdocs/hrm/class/skill.class.php +++ b/htdocs/hrm/class/skill.class.php @@ -521,7 +521,7 @@ class Skill extends CommonObject */ public function delete(User $user, $notrigger = false) { - return $this->deleteCommon($user, $notrigger);; + return $this->deleteCommon($user, $notrigger); } /** @@ -965,8 +965,8 @@ class Skill extends CommonObject $result = $objectline->fetchAll('ASC', 'rankorder', 0, 0, array('customsql'=>'fk_skill = '.$this->id)); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; diff --git a/htdocs/hrm/class/skillrank.class.php b/htdocs/hrm/class/skillrank.class.php index 6db80642bab..2d75425823e 100644 --- a/htdocs/hrm/class/skillrank.class.php +++ b/htdocs/hrm/class/skillrank.class.php @@ -919,8 +919,8 @@ class SkillRank extends CommonObject $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_skillrank = '.((int) $this->id))); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; diff --git a/htdocs/hrm/compare.php b/htdocs/hrm/compare.php index 686d5820695..6365dd51d25 100644 --- a/htdocs/hrm/compare.php +++ b/htdocs/hrm/compare.php @@ -28,9 +28,6 @@ * 2- the central part displays the skills. display of the maximum score for this group and the number of occurrences. * * 3- the right part displays the members of group 2 or the job to be compared - * - * - * */ @@ -48,6 +45,7 @@ require_once DOL_DOCUMENT_ROOT . '/hrm/lib/hrm.lib.php'; // Load translation files required by the page $langs->load('hrm'); +$job = new Job($db); // Permissions $permissiontoread = $user->rights->hrm->evaluation->read || $user->rights->hrm->compare_advance->read; @@ -61,8 +59,8 @@ if (!$permissiontoread || ($action === 'create' && !$permissiontoadd)) accessfor * View */ -$css = array(); -$css[] = '/hrm/css/style.css'; +$css = array('/hrm/css/style.css'); + llxHeader('', $langs->trans('SkillComparison'), '', '', 0, 0, '', $css); $head = array(); @@ -74,8 +72,6 @@ $head[$h][2] = 'compare'; print dol_get_fiche_head($head, 'compare', '', 1); -//$PDOdb = new TPDOdb; -$form = new Form($db); ?> '; print '
'; } if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print ' '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print ''; + print ''; print '
'; } if (isModEnabled('eventorganization')) { @@ -660,7 +699,7 @@ if ($action == 'create' && $user->rights->projet->creer) { // TODO @LDR Implement this if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { $tmpbacktopagejsfields = 'addthirdparty:socid,search_socid'; - print dolButtonToOpenUrlInDialogPopup('addthirdparty', $langs->transnoentitiesnoconv('AddThirdParty'), $newbutton, $url, '', '', $tmpbacktopagejsfields); + print dolButtonToOpenUrlInDialogPopup('addthirdparty', $langs->transnoentitiesnoconv('AddThirdParty'), $newbutton, $url, '', '', '', $tmpbacktopagejsfields); } else { print ' '.$newbutton.''; } @@ -706,24 +745,26 @@ if ($action == 'create' && $user->rights->projet->creer) { print ''.$langs->trans("OpportunityStatus").''; print ''; print $formproject->selectOpportunityStatus('opp_status', GETPOSTISSET('opp_status') ? GETPOST('opp_status') : $object->opp_status, 1, 0, 0, 0, '', 0, 1); - print ''; // Opportunity probability - print ''.$langs->trans("OpportunityProbability").''; - print ' %'; + print ' %'; print ''; print ''; print ''; // Opportunity amount print ''.$langs->trans("OpportunityAmount").''; - print ''; + print ''; + print ' '.$langs->getCurrencySymbol($conf->currency); + print ''; print ''; } // Budget - print ''.$langs->trans("Budget").''; - print ''; + print ''.$langs->trans("Budget").''; + print ''; + print ' '.$langs->getCurrencySymbol($conf->currency); + print ''; print ''; // Date project @@ -780,6 +821,7 @@ if ($action == 'create' && $user->rights->projet->creer) { print ''; // Change probability from status or role of project + // Set also dependencies between use taks and bill time print ''; print '
'; @@ -930,12 +977,52 @@ if ($action == 'create' && $user->rights->projet->creer) { print 'usage_task ? ' checked="checked"' : '')) . '"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print ''; + print ''; print '
'; } if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print 'usage_bill_time ? ' checked="checked"' : '')) . '"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print ''; + print ''; print '
'; } if (isModEnabled('eventorganization')) { @@ -944,7 +1031,14 @@ if ($action == 'create' && $user->rights->projet->creer) { print ''; print ''; } @@ -1013,32 +1105,34 @@ if ($action == 'create' && $user->rights->projet->creer) { // Opportunity status print ''.$langs->trans("OpportunityStatus").''; print ''; - print $formproject->selectOpportunityStatus('opp_status', $object->opp_status, 1, 0, 0, 0, 'inline-block valignmiddle', 0, 1); - print ''; - print ''; - print ''; + print '
'; + print $formproject->selectOpportunityStatus('opp_status', $object->opp_status, 1, 0, 0, 0, 'inline-block valignmiddle', 1, 1); // Opportunity probability - print ''.$langs->trans("OpportunityProbability").''; - print ' %'; - print ''; + print ' %'; + print ''; + print '
'; + + print ''; + print ''; print ''; // Opportunity amount print ''.$langs->trans("OpportunityAmount").''; - print ''; + print ''; print $langs->getCurrencySymbol($conf->currency); print ''; print ''; } // Budget - print ''.$langs->trans("Budget").''; - print ''; + print ''.$langs->trans("Budget").''; + print ''; print $langs->getCurrencySymbol($conf->currency); print ''; print ''; @@ -1180,14 +1274,13 @@ if ($action == 'create' && $user->rights->projet->creer) { if ($code) { print $langs->trans("OppStatus".$code); } - print ''; // Opportunity percent - print ''.$langs->trans("OpportunityProbability").''; + print ' / '; if (strcmp($object->opp_percent, '')) { print price($object->opp_percent, 0, $langs, 1, 0).' %'; } - print ''; + print ''; // Opportunity Amount print ''.$langs->trans("OpportunityAmount").''; @@ -1268,6 +1361,25 @@ if ($action == 'create' && $user->rights->projet->creer) { print ''; + // Set also dependencies between use taks and bill time + print ''; + // Change probability from status if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { // Default value to close or not when we set opp to 'WON'. @@ -1308,19 +1420,23 @@ if ($action == 'create' && $user->rights->projet->creer) { } /* Change percent with default percent (defaultpercent) if new status (defaultpercent) is higher than current (jQuery("#opp_percent").val()) */ - console.log("oldpercent="+oldpercent); if (oldpercent != \'\' && (parseFloat(defaultpercent) < parseFloat(oldpercent))) { - if (jQuery("#opp_percent").val() != \'\' && oldpercent != \'\') jQuery("#oldopppercent").text(\' - '.dol_escape_js($langs->transnoentities("PreviousValue")).': \'+oldpercent+\' %\'); - if (parseFloat(oldpercent) != 100) { jQuery("#opp_percent").val(oldpercent); } - else { jQuery("#opp_percent").val(defaultpercent); } + console.log("oldpercent="+oldpercent+" defaultpercent="+defaultpercent+" def < old"); + if (jQuery("#opp_percent").val() != \'\' && oldpercent != \'\') { + jQuery("#oldopppercent").text(\' - '.dol_escape_js($langs->transnoentities("PreviousValue")).': \'+price2numjs(oldpercent)+\' %\'); + } + + if (parseFloat(oldpercent) != 100 && elemcode != \'LOST\') { jQuery("#opp_percent").val(oldpercent); } + else { jQuery("#opp_percent").val(price2numjs(defaultpercent)); } } else { + console.log("oldpercent="+oldpercent+" defaultpercent="+defaultpercent); if ((parseFloat(jQuery("#opp_percent").val()) < parseFloat(defaultpercent))); { - if (jQuery("#opp_percent").val() != \'\' && oldpercent != \'\') jQuery("#oldopppercent").text(\' - '.dol_escape_js($langs->transnoentities("PreviousValue")).': \'+oldpercent+\' %\'); - jQuery("#opp_percent").val(defaultpercent); + if (jQuery("#opp_percent").val() != \'\' && oldpercent != \'\') jQuery("#oldopppercent").text(\' - '.dol_escape_js($langs->transnoentities("PreviousValue")).': \'+price2numjs(oldpercent)+\' %\'); + jQuery("#opp_percent").val(price2numjs(defaultpercent)); } } } diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index 6a522346210..8cbb3949cd5 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -29,7 +29,6 @@ */ class Projects extends DolibarrApi { - /** * @var array $FIELDS Mandatory fields, checked when create and update object */ @@ -267,10 +266,9 @@ class Projects extends DolibarrApi * * @param int $id Id of project * @param int $userid Id of user (0 = connected user) + * @return array * * @url GET {id}/roles - * - * @return int */ public function getRoles($id, $userid = 0) { @@ -296,11 +294,12 @@ class Projects extends DolibarrApi $userp = new User($this->db); $userp->fetch($userid); } - $this->project->roles = $taskstatic->getUserRolesForProjectsOrTasks($userp, 0, $id, 0); + $this->project->roles = $taskstatic->getUserRolesForProjectsOrTasks($userp, null, $id, 0); $result = array(); foreach ($this->project->roles as $line) { array_push($result, $this->_cleanObjectDatas($line)); } + return $result; } diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index cd232061bc4..eb7e1579261 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -296,7 +296,7 @@ class Tasks extends DolibarrApi $usert = new User($this->db); $usert->fetch($userid); } - $this->task->roles = $this->task->getUserRolesForProjectsOrTasks(0, $usert, 0, $id); + $this->task->roles = $this->task->getUserRolesForProjectsOrTasks(null, $usert, 0, $id); $result = array(); foreach ($this->task->roles as $line) { array_push($result, $this->_cleanObjectDatas($line)); diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 9213fc1470d..79ea13dcd40 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1480,7 +1480,7 @@ class Project extends CommonObject * @param int $list 0=Return array, 1=Return string list * @param int $socid 0=No filter on third party, id of third party * @param string $filter additionnal filter on project (statut, ref, ...) - * @return array or string Array of projects id, or string with projects id separated with "," if list is 1 + * @return array|string Array of projects id, or string with projects id separated with "," if list is 1 */ public function getProjectsAuthorizedForUser($user, $mode = 0, $list = 0, $socid = 0, $filter = '') { @@ -2167,18 +2167,18 @@ class Project extends CommonObject /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id + * @param DoliDB $dbs Database handler + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'projet' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } @@ -2265,7 +2265,7 @@ class Project extends CommonObject $this->user_creation = $cuser; } - if ($obj->fk_user_cloture) { + if (!empty($obj->fk_user_cloture)) { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); $this->user_cloture = $cluser; @@ -2289,8 +2289,8 @@ class Project extends CommonObject * Adds it to non existing supplied categories. * Existing categories are left untouch. * - * @param int[]|int $categories Category or categories IDs - * @return void + * @param int[]|int $categories Category or categories IDs + * @return int <0 if KO, >0 if OK */ public function setCategories($categories) { diff --git a/htdocs/projet/class/projectstats.class.php b/htdocs/projet/class/projectstats.class.php index 322277187f7..65d673a9ad2 100644 --- a/htdocs/projet/class/projectstats.class.php +++ b/htdocs/projet/class/projectstats.class.php @@ -98,7 +98,7 @@ class ProjectStats extends Stats $result = array(); - dol_syslog(get_class($this).'::'.__METHOD__."", LOG_DEBUG); + dol_syslog(get_class($this).'::'.__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index ff1bdbc07f9..d836c1ef319 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -812,7 +812,7 @@ class Task extends CommonObjectLine * @param array $search_array_options Array of search * @param int $loadextras Fetch all Extrafields on each task * @param int $loadRoleMode 1= will test Roles on task; 0 used in delete project action - * @return array Array of tasks + * @return array|string Array of tasks */ public function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0, $extrafields = array(), $includebilltime = 0, $search_array_options = array(), $loadextras = 0, $loadRoleMode = 1) { @@ -971,12 +971,12 @@ class Task extends CommonObjectLine if ($loadRoleMode) { if ((!$obj->public) && (is_object($userp))) { // If not public project and we ask a filter on project owned by a user - if (!$this->getUserRolesForProjectsOrTasks($userp, 0, $obj->projectid, 0)) { + if (!$this->getUserRolesForProjectsOrTasks($userp, null, $obj->projectid, 0)) { $error++; } } if (is_object($usert)) { // If we ask a filter on a user affected to a task - if (!$this->getUserRolesForProjectsOrTasks(0, $usert, $obj->projectid, $obj->taskid)) { + if (!$this->getUserRolesForProjectsOrTasks(null, $usert, $obj->projectid, $obj->taskid)) { $error++; } } @@ -1025,7 +1025,8 @@ class Task extends CommonObjectLine if (!empty($extrafields->attributes['projet']['label'])) { foreach ($extrafields->attributes['projet']['label'] as $key => $val) { if ($extrafields->attributes['projet']['type'][$key] != 'separate') { - $tasks[$i]->{'options_'.$key} = $obj->{'options_'.$key}; + $tmpvar = 'options_'.$key; + $tasks[$i]->{'options_'.$key} = $obj->$tmpvar; } } } @@ -1033,7 +1034,8 @@ class Task extends CommonObjectLine if (!empty($extrafields->attributes['projet_task']['label'])) { foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) { if ($extrafields->attributes['projet_task']['type'][$key] != 'separate') { - $tasks[$i]->{'options_'.$key} = $obj->{'options_'.$key}; + $tmpvar = 'options_'.$key; + $tasks[$i]->{'options_'.$key} = $obj->$tmpvar; } } } @@ -1056,12 +1058,12 @@ class Task extends CommonObjectLine /** * Return list of roles for a user for each projects or each tasks (or a particular project or a particular task). * - * @param User $userp Return roles on project for this internal user. If set, usert and taskid must not be defined. - * @param User $usert Return roles on task for this internal user. If set userp must NOT be defined. -1 means no filter. - * @param int $projectid Project id list separated with , to filter on project - * @param int $taskid Task id to filter on a task - * @param integer $filteronprojstatus Filter on project status if userp is set. Not used if userp not defined. - * @return array Array (projectid => 'list of roles for project' or taskid => 'list of roles for task') + * @param User|null $userp Return roles on project for this internal user. If set, usert and taskid must not be defined. + * @param User|null $usert Return roles on task for this internal user. If set userp must NOT be defined. -1 means no filter. + * @param int $projectid Project id list separated with , to filter on project + * @param int $taskid Task id to filter on a task + * @param integer $filteronprojstatus Filter on project status if userp is set. Not used if userp not defined. + * @return array|int Array (projectid => 'list of roles for project' or taskid => 'list of roles for task') */ public function getUserRolesForProjectsOrTasks($userp, $usert, $projectid = '', $taskid = 0, $filteronprojstatus = -1) { @@ -1396,12 +1398,10 @@ class Task extends CommonObjectLine * * @param User|int $userobj Filter on user. null or 0=No filter * @param string $morewherefilter Add more filter into where SQL request (must start with ' AND ...') - * @return array Array of info for task array('min_date', 'max_date', 'total_duration', 'total_amount', 'nblines', 'nblinesnull') + * @return array|int Array of info for task array('min_date', 'max_date', 'total_duration', 'total_amount', 'nblines', 'nblinesnull') */ public function getSummaryOfTimeSpent($userobj = null, $morewherefilter = '') { - global $langs; - if (is_object($userobj)) { $userid = $userobj->id; } else { @@ -1565,14 +1565,12 @@ class Task extends CommonObjectLine /** * Load all records of time spent * - * @param User $userobj User object - * @param string $morewherefilter Add more filter into where SQL request (must start with ' AND ...') - * @return int <0 if KO, array of time spent if OK + * @param User $userobj User object + * @param string $morewherefilter Add more filter into where SQL request (must start with ' AND ...') + * @return array|int <0 if KO, array of time spent if OK */ public function fetchAllTimeSpent(User $userobj, $morewherefilter = '') { - global $langs; - $arrayres = array(); $sql = "SELECT"; diff --git a/htdocs/projet/class/taskstats.class.php b/htdocs/projet/class/taskstats.class.php index 5794d585101..ce7c6c4f4c5 100644 --- a/htdocs/projet/class/taskstats.class.php +++ b/htdocs/projet/class/taskstats.class.php @@ -15,6 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -69,7 +70,7 @@ class TaskStats extends Stats $result = array(); $res = array(); - dol_syslog(get_class($this).'::'.__METHOD__."", LOG_DEBUG); + dol_syslog(get_class($this).'::'.__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -195,7 +196,7 @@ class TaskStats extends Stats } - /** + /** * Return the Task amount by month for a year * * @param int $year Year to scan @@ -208,7 +209,7 @@ class TaskStats extends Stats return array(); } - /** + /** * Return average of entity by month * @param int $year year number * @return int value diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index f96f5737cf4..7bad7fd493d 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -376,8 +376,8 @@ $listofreferent = array( 'lang'=>'entrepot', 'buttonnew'=>'AddWarehouse', 'project_field'=>'fk_project', - 'testnew'=>$user->rights->stock->creer, - 'test'=>$conf->stock->enabled && $user->rights->stock->lire && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROJECT)), + 'testnew'=>$user->hasRight('stock', 'creer'), + 'test'=>!empty($conf->stock->enabled) && $user->hasRight('stock', 'lire') && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROJECT)), 'propal'=>array( 'name'=>"Proposals", 'title'=>"ListProposalsAssociatedProject", @@ -387,8 +387,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/comm/propal/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'propal', 'buttonnew'=>'AddProp', - 'testnew'=>$user->rights->propal->creer, - 'test'=>$conf->propal->enabled && $user->rights->propal->lire), + 'testnew'=>$user->hasRight('propal', 'creer'), + 'test'=>!empty($conf->propal->enabled) && $user->hasRight('propal', 'lire')), 'order'=>array( 'name'=>"CustomersOrders", 'title'=>"ListOrdersAssociatedProject", @@ -398,8 +398,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/commande/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'orders', 'buttonnew'=>'CreateOrder', - 'testnew'=>$user->rights->commande->creer, - 'test'=>$conf->commande->enabled && $user->rights->commande->lire), + 'testnew'=>$user->hasRight('commande', 'creer'), + 'test'=>!empty($conf->commande->enabled) && $user->hasRight('commande', 'lire')), 'invoice'=>array( 'name'=>"CustomersInvoices", 'title'=>"ListInvoicesAssociatedProject", @@ -410,8 +410,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/compta/facture/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'bills', 'buttonnew'=>'CreateBill', - 'testnew'=>$user->rights->facture->creer, - 'test'=>$conf->facture->enabled && $user->rights->facture->lire), + 'testnew'=>$user->hasRight('facture', 'creer'), + 'test'=>!empty($conf->facture->enabled) && $user->hasRight('facture', 'lire')), 'invoice_predefined'=>array( 'name'=>"PredefinedInvoices", 'title'=>"ListPredefinedInvoicesAssociatedProject", @@ -421,8 +421,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/compta/facture/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'bills', 'buttonnew'=>'CreateBill', - 'testnew'=>$user->rights->facture->creer, - 'test'=>$conf->facture->enabled && $user->rights->facture->lire), + 'testnew'=>$user->hasRight('facture', 'creer'), + 'test'=>!empty($conf->facture->enabled) && $user->hasRight('facture', 'lire')), 'proposal_supplier'=>array( 'name'=>"SuppliersProposals", 'title'=>"ListSupplierProposalsAssociatedProject", @@ -432,8 +432,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/supplier_proposal/card.php?action=create&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), // No socid parameter here, the socid is often the customer and we create a supplier object 'lang'=>'supplier_proposal', 'buttonnew'=>'AddSupplierProposal', - 'testnew'=>$user->rights->supplier_proposal->creer, - 'test'=>$conf->supplier_proposal->enabled && $user->rights->supplier_proposal->lire), + 'testnew'=>$user->hasRight('supplier_proposal', 'creer'), + 'test'=>!empty($conf->supplier_proposal->enabled) && $user->hasRight('supplier_proposal', 'lire')), 'order_supplier'=>array( 'name'=>"SuppliersOrders", 'title'=>"ListSupplierOrdersAssociatedProject", @@ -443,8 +443,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/fourn/commande/card.php?action=create&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), // No socid parameter here, the socid is often the customer and we create a supplier object 'lang'=>'suppliers', 'buttonnew'=>'AddSupplierOrder', - 'testnew'=>($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer), - 'test'=>$conf->supplier_order->enabled && ($user->rights->fournisseur->commande->lire || $user->rights->supplier_order->lire)), + 'testnew'=>$user->hasRight('fournisseur', 'commande', 'creer') || $user->hasRight('supplier_order', 'creer'), + 'test'=>!empty($conf->supplier_order->enabled) && $user->hasRight('fournisseur', 'commande', 'lire') || $user->hasRight('supplier_order', 'lire')), 'invoice_supplier'=>array( 'name'=>"BillsSuppliers", 'title'=>"ListSupplierInvoicesAssociatedProject", @@ -455,8 +455,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/fourn/facture/card.php?action=create&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), // No socid parameter here, the socid is often the customer and we create a supplier object 'lang'=>'suppliers', 'buttonnew'=>'AddSupplierInvoice', - 'testnew'=>($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer), - 'test'=>$conf->supplier_invoice->enabled && ($user->rights->fournisseur->facture->lire || $user->rights->supplier_invoice->lire)), + 'testnew'=>$user->hasRight('fournisseur', 'facture', 'creer') || $user->hasRight('supplier_invoice', 'creer'), + 'test'=>!empty($conf->supplier_invoice->enabled) && $user->hasRight('fournisseur', 'facture', 'lire') || $user->hasRight('supplier_invoice', 'lire')), 'contract'=>array( 'name'=>"Contracts", 'title'=>"ListContractAssociatedProject", @@ -466,8 +466,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/contrat/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'contracts', 'buttonnew'=>'AddContract', - 'testnew'=>$user->rights->contrat->creer, - 'test'=>$conf->contrat->enabled && $user->rights->contrat->lire), + 'testnew'=>$user->hasRight('contrat', 'creer'), + 'test'=>!empty($conf->contrat->enabled) && $user->hasRight('contrat', 'lire')), 'intervention'=>array( 'name'=>"Interventions", 'title'=>"ListFichinterAssociatedProject", @@ -479,8 +479,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/fichinter/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'interventions', 'buttonnew'=>'AddIntervention', - 'testnew'=>$user->rights->ficheinter->creer, - 'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire), + 'testnew'=>$user->hasRight('ficheinter', 'creer'), + 'test'=>!empty($conf->ficheinter->enabled) && $user->hasRight('ficheinter', 'lire')), 'shipping'=>array( 'name'=>"Shippings", 'title'=>"ListShippingAssociatedProject", @@ -501,9 +501,9 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/mrp/mo_card.php?action=create&origin=project&originid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'mrp', 'buttonnew'=>'CreateMO', - 'testnew'=>'$user->rights->mrp->write', + 'testnew'=>$user->hasRight('mrp', 'write'), 'project_field'=>'fk_project', - 'test'=>$conf->mrp->enabled && $user->rights->mrp->read), + 'test'=>!empty($conf->mrp->enabled) && $user->hasRight('mrp', 'read')), 'trip'=>array( 'name'=>"TripsAndExpenses", 'title'=>"ListExpenseReportsAssociatedProject", @@ -515,8 +515,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/deplacement/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'trips', 'buttonnew'=>'AddTrip', - 'testnew'=>$user->rights->deplacement->creer, - 'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire), + 'testnew'=>$user->hasRight('deplacement', 'creer'), + 'test'=>!empty($conf->deplacement->enabled) && $user->hasRight('deplacement', 'lire')), 'expensereport'=>array( 'name'=>"ExpenseReports", 'title'=>"ListExpenseReportsAssociatedProject", @@ -528,8 +528,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/expensereport/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'trips', 'buttonnew'=>'AddTrip', - 'testnew'=>$user->rights->expensereport->creer, - 'test'=>$conf->expensereport->enabled && $user->rights->expensereport->lire), + 'testnew'=>$user->hasRight('expensereport', 'creer'), + 'test'=>!empty($conf->expensereport->enabled) && $user->hasRight('expensereport', 'lire')), 'donation'=>array( 'name'=>"Donation", 'title'=>"ListDonationsAssociatedProject", @@ -541,8 +541,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/don/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'donations', 'buttonnew'=>'AddDonation', - 'testnew'=>$user->rights->don->creer, - 'test'=>$conf->don->enabled && $user->rights->don->lire), + 'testnew'=>$user->hasRight('don', 'creer'), + 'test'=>!empty($conf->don->enabled) && $user->hasRight('don', 'lire')), 'loan'=>array( 'name'=>"Loan", 'title'=>"ListLoanAssociatedProject", @@ -554,8 +554,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/loan/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'loan', 'buttonnew'=>'AddLoan', - 'testnew'=>$user->rights->loan->write, - 'test'=>$conf->loan->enabled && $user->rights->loan->read), + 'testnew'=>$user->hasRight('loan', 'write'), + 'test'=>!empty($conf->loan->enabled) && $user->hasRight('loan', 'read')), 'chargesociales'=>array( 'name'=>"SocialContribution", 'title'=>"ListSocialContributionAssociatedProject", @@ -567,8 +567,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/compta/sociales/card.php?action=create&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'compta', 'buttonnew'=>'AddSocialContribution', - 'testnew'=>$user->rights->tax->charges->lire, - 'test'=>$conf->tax->enabled && $user->rights->tax->charges->lire), + 'testnew'=>$user->hasRight('tax', 'charges', 'lire'), + 'test'=>!empty($conf->tax->enabled) && $user->hasRight('tax', 'charges', 'lire')), 'project_task'=>array( 'name'=>"TaskTimeSpent", 'title'=>"ListTaskTimeUserProject", @@ -579,8 +579,8 @@ $listofreferent = array( 'disableamount'=>0, 'urlnew'=>DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&action=createtime&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'buttonnew'=>'AddTimeSpent', - 'testnew'=>$user->rights->projet->creer, - 'test'=>($conf->project->enabled && $user->rights->projet->lire && empty($conf->global->PROJECT_HIDE_TASKS))), + 'testnew'=>$user->hasRight('project', 'creer'), + 'test'=>!empty($conf->project->enabled) && $user->hasRight('projet', 'lire') && !empty($conf->global->PROJECT_HIDE_TASKS)), 'stock_mouvement'=>array( 'name'=>"MouvementStockAssociated", 'title'=>"ListMouvementStockProject", @@ -589,7 +589,7 @@ $listofreferent = array( 'table'=>'stock_mouvement', 'datefieldname'=>'datem', 'disableamount'=>0, - 'test'=>($conf->stock->enabled && $user->rights->stock->mouvement->lire && !empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW))), + 'test'=>!empty($conf->stock->enabled) && $user->hasRight('stock', 'mouvement', 'lire') && !empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW)), 'salaries'=>array( 'name'=>"Salaries", 'title'=>"ListSalariesAssociatedProject", @@ -601,8 +601,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/salaries/card.php?action=create&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'salaries', 'buttonnew'=>'AddSalary', - 'testnew'=>$user->rights->salaries->write, - 'test'=>$conf->salaries->enabled && $user->rights->salaries->read), + 'testnew'=>$user->hasRight('salaries', 'write'), + 'test'=>!empty($conf->salaries->enabled) && $user->hasRight('salaries', 'read')), 'variouspayment'=>array( 'name'=>"VariousPayments", 'title'=>"ListVariousPaymentsAssociatedProject", @@ -614,8 +614,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/compta/bank/various_payment/card.php?action=create&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'banks', 'buttonnew'=>'AddVariousPayment', - 'testnew'=>$user->rights->banque->modifier, - 'test'=>$conf->banque->enabled && $user->rights->banque->lire && empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)), + 'testnew'=>$user->hasRight('banque', 'modifier'), + 'test'=>!empty($conf->banque->enabled) && $user->hasRight('banque', 'lire') && !empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)), /* No need for this, available on dedicated tab "Agenda/Events" 'agenda'=>array( 'name'=>"Agenda", diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index f2889d7c469..07ff2bd38c9 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -259,7 +259,7 @@ print load_fiche_titre($title, $linktotasks.'   '.$linktocreatetask, 'proje // can have a parent that is not affected to him). $tasksarray = $task->getTasksArray(0, 0, ($object->id ? $object->id : $id), $socid, 0); // We load also tasks limited to a particular user -//$tasksrole=($_REQUEST["mode"]=='mine' ? $task->getUserRolesForProjectsOrTasks(0,$user,$object->id,0) : ''); +//$tasksrole=($_REQUEST["mode"]=='mine' ? $task->getUserRolesForProjectsOrTasks(null, $user, $object->id, 0) : ''); //var_dump($tasksarray); //var_dump($tasksrole); diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index 2698a4b1a21..044728227cf 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -310,7 +310,7 @@ if ($resql) { $companystatic = new Societe($db); // We need a clean new object for next loop because current one has some properties set. - +// List of open projects per thirdparty $sql = "SELECT COUNT(p.rowid) as nb, SUM(p.opp_amount)"; $sql .= ", s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; diff --git a/htdocs/projet/jsgantt_language.js.php b/htdocs/projet/jsgantt_language.js.php index 35ab1132ae7..93b9ee5505f 100644 --- a/htdocs/projet/jsgantt_language.js.php +++ b/htdocs/projet/jsgantt_language.js.php @@ -67,7 +67,7 @@ var vLangs={'getDefaultLang(1); ?>': 'sunday':'transnoentities('Sunday'); ?>','monday':'transnoentities('Monday'); ?>','tuesday':'transnoentities('Tuesday'); ?>','wednesday':'transnoentities('Wednesday'); ?>','thursday':'transnoentities('Thursday'); ?>','friday':'transnoentities('Friday'); ?>','saturday':'transnoentities('Saturday'); ?>', 'sun':'transnoentities('SundayMin'); ?>','mon':'transnoentities('MondayMin'); ?>','tue':'transnoentities('TuesdayMin'); ?>','wed':'transnoentities('WednesdayMin'); ?>','thu':'transnoentities('ThursdayMin'); ?>','fri':'transnoentities('FridayMin'); ?>','sat':'transnoentities('SaturdayMin'); ?>' } -}; +} var vLang='getDefaultLang(1); ?>'; $langs->trans("ThirdParty"), 'checked'=>1 $arrayfields['s.name_alias'] = array('label'=>"AliasNameShort", 'checked'=>0, 'position'=>22); $arrayfields['commercial'] = array('label'=>$langs->trans("SaleRepresentativesOfThirdParty"), 'checked'=>0, 'position'=>23); $arrayfields['c.assigned'] = array('label'=>$langs->trans("AssignedTo"), 'checked'=>-1, 'position'=>120); -$arrayfields['opp_weighted_amount'] = array('label'=>$langs->trans('OpportunityWeightedAmountShort'), 'checked'=>0, 'position'=> 116, 'enabled'=>(empty($conf->global->PROJECT_USE_OPPORTUNITIES) ? 0 : 1), 'position'=>106); +$arrayfields['opp_weighted_amount'] = array('label'=>$langs->trans('OpportunityWeightedAmountShort'), 'checked'=>0, 'enabled'=>(empty($conf->global->PROJECT_USE_OPPORTUNITIES) ? 0 : 1), 'position'=>106); $arrayfields['u.login'] = array('label'=>"Author", 'checked'=>1, 'position'=>165); // Force some fields according to search_usage filter... if (GETPOST('search_usage_opportunity')) { @@ -1187,14 +1187,13 @@ if (!empty($arrayfields['p.import_key']['checked'])) { print ''; } if (!empty($arrayfields['p.fk_statut']['checked'])) { - print ''; + print ''; $arrayofstatus = array(); foreach ($object->statuts_short as $key => $val) { $arrayofstatus[$key] = $langs->trans($val); } $arrayofstatus['99'] = $langs->trans("NotClosed").' ('.$langs->trans('Draft').' + '.$langs->trans('Opened').')'; - print $form->selectarray('search_status', $arrayofstatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'minwidth75imp maxwidth125 selectarrowonleft onrightofpage'); - print ajax_combobox('search_status'); + print $form->selectarray('search_status', $arrayofstatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1); print ''; } // Action column @@ -1298,7 +1297,7 @@ if (!empty($arrayfields['p.import_key']['checked'])) { print_liste_field_titre($arrayfields['p.import_key']['label'], $_SERVER["PHP_SELF"], "p.import_key", "", $param, '', $sortfield, $sortorder, ''); } if (!empty($arrayfields['p.fk_statut']['checked'])) { - print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'center '); } if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); @@ -1542,7 +1541,11 @@ while ($i < $imaxinloop) { //if ($obj->opp_status_code) if (strcmp($obj->opp_amount, '')) { print ''.price($obj->opp_amount, 1, $langs, 1, -1, -1, '').''; - $totalarray['val']['p.opp_amount'] += $obj->opp_amount; + if (empty($totalarray['val']['p.opp_amount'])) { + $totalarray['val']['p.opp_amount'] = $obj->opp_amount; + } else { + $totalarray['val']['p.opp_amount'] += $obj->opp_amount; + } } print ''; if (!$i) { @@ -1571,7 +1574,11 @@ while ($i < $imaxinloop) { print ''; if ($obj->opp_weighted_amount) { print ''.price($obj->opp_weighted_amount, 1, $langs, 1, -1, -1, '').''; - $totalarray['val']['opp_weighted_amount'] += $obj->opp_weighted_amount; + if (empty($totalarray['val']['opp_weighted_amount'])) { + $totalarray['val']['opp_weighted_amount'] = $obj->opp_weighted_amount; + } else { + $totalarray['val']['opp_weighted_amount'] += $obj->opp_weighted_amount; + } } print ''; if (!$i) { @@ -1586,7 +1593,11 @@ while ($i < $imaxinloop) { print ''; if ($obj->budget_amount != '') { print ''.price($obj->budget_amount, 1, $langs, 1, -1, -1).''; - $totalarray['val']['p.budget_amount'] += $obj->budget_amount; + if (empty($totalarray['val']['p.budget_amount'])) { + $totalarray['val']['p.budget_amount'] = $obj->budget_amount; + } else { + $totalarray['val']['p.budget_amount'] += $obj->budget_amount; + } } print ''; if (!$i) { @@ -1759,7 +1770,7 @@ while ($i < $imaxinloop) { } // Status if (!empty($arrayfields['p.fk_statut']['checked'])) { - print ''.$object->getLibStatut(5).''; + print ''.$object->getLibStatut(5).''; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/projet/messaging.php b/htdocs/projet/messaging.php index 7fe5b4a0b9d..b266b87700d 100644 --- a/htdocs/projet/messaging.php +++ b/htdocs/projet/messaging.php @@ -59,7 +59,7 @@ if (GETPOST('actioncode', 'array')) { $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)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -196,7 +196,7 @@ if (!empty($object->id)) { // Show link to add event if (isModEnabled('agenda')) { - $addActionBtnRight = !empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create); + $addActionBtnRight = !empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create'); $morehtmlcenter .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'&socid='.$object->socid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $addActionBtnRight); } diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 3322b63b171..c966a34ea0b 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -357,7 +357,7 @@ if ($action == 'createtask' && $user->rights->projet->creer) { } else { if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("projects"); - setEventMessages($langs->trans('NewTaskRefSuggested'), '', 'warnings'); + setEventMessages($langs->trans('NewTaskRefSuggested'), null, 'warnings'); $duplicate_code_error = true; } else { setEventMessages($task->error, $task->errors, 'errors'); @@ -862,7 +862,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third $tmpuser->fetch($search_user_id); } - $tasksrole = ($tmpuser->id > 0 ? $taskstatic->getUserRolesForProjectsOrTasks(0, $tmpuser, $object->id, 0) : ''); + $tasksrole = ($tmpuser->id > 0 ? $taskstatic->getUserRolesForProjectsOrTasks(null, $tmpuser, $object->id, 0) : ''); //var_dump($tasksarray); //var_dump($tasksrole); diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 8b19c8c0519..fccf9d2ffe1 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -467,7 +467,7 @@ if ($id > 0 || !empty($ref)) { // Task parent print ''.$langs->trans("ChildOfProjectTask").''; - print $formother->selectProjectTasks($object->fk_task_parent, $projectstatic->id, 'task_parent', ($user->admin ? 0 : 1), 0, 0, 0, $object->id); + $formother->selectProjectTasks($object->fk_task_parent, $projectstatic->id, 'task_parent', ($user->admin ? 0 : 1), 0, 0, 0, $object->id); print ''; // Date start diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 27ccb40b4ed..3c8597cd862 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -88,6 +88,10 @@ $search_company = GETPOST('$search_company', 'alpha'); $search_company_alias = GETPOST('$search_company_alias', 'alpha'); $search_project_ref = GETPOST('$search_project_ref', 'alpha'); $search_project_label = GETPOST('$search_project_label', 'alpha'); +$search_timespent_starthour = GETPOSTINT("search_timespent_duration_starthour"); +$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; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -191,11 +195,15 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_project_ref = ''; $search_project_label = ''; $search_task_label = ''; - $search_user = 0; + $search_user = -1; $search_valuebilled = ''; $search_product_ref = ''; $toselect = array(); $search_array_options = array(); + $search_timespent_starthour = ''; + $search_timespent_startmin = ''; + $search_timespent_endhour = ''; + $search_timespent_endmin = ''; $action = ''; } @@ -1239,7 +1247,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } // Call Hook formConfirm - $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid, "projectstatic" => $projectstatic, "withproject" => $withproject); + $parameters = array('formConfirm' => $formconfirm, "projectstatic" => $projectstatic, "withproject" => $withproject); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { $formconfirm .= $hookmanager->resPrint; @@ -1265,7 +1273,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } $arrayfields['author'] = array('label'=>$langs->trans("By"), 'checked'=>1); $arrayfields['t.note'] = array('label'=>$langs->trans("Note"), 'checked'=>1); - if ($conf->service->enabled && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) { + 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.task_duration'] = array('label'=>$langs->trans("Duration"), 'checked'=>1); @@ -1337,6 +1345,18 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if ($search_date_endyear) { $param .= '&search_date_endyear='.urlencode($search_date_endyear); } + if ($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); + } + if ($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); + } /* // Add $param from extra fields @@ -1446,7 +1466,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print $langs->trans('InvoiceToUse'); print ''; print ''; - $form->selectInvoice('invoice', '', 'invoiceid', 24, 0, $langs->trans('NewInvoice'), 1, 0, 0, 'maxwidth500', '', 'all'); + $form->selectInvoice($projectstatic->thirdparty->id, '', 'invoiceid', 24, 0, $langs->trans('NewInvoice'), 1, 0, 0, 'maxwidth500', '', 'all'); print ''; print ''; /*print ''; @@ -1561,7 +1581,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if (empty($search_user)) { $search_user = $user->id; } - $sql .= " AND t.fk_user = ".((int) $search_user); + if ($search_user > 0) $sql .= " AND t.fk_user = ".((int) $search_user); } if ($search_note) { @@ -1609,6 +1629,20 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $sql .= " AND t.task_date <= '".$db->idate($search_date_end)."'"; } + if (!empty($arrayfields['t.task_duration']['checked'])) { + if ($search_timespent_starthour || $search_timespent_startmin) { + $timespent_duration_start = $search_timespent_starthour * 60 * 60; // We store duration in seconds + $timespent_duration_start += ($search_timespent_startmin ? $search_timespent_startmin : 0) * 60; // We store duration in seconds + $sql .= " AND t.task_duration >= " . $timespent_duration_start; + } + + if ($search_timespent_endhour || $search_timespent_endmin) { + $timespent_duration_end = $search_timespent_endhour * 60 * 60; // We store duration in seconds + $timespent_duration_end += ($search_timespent_endmin ? $search_timespent_endmin : 0) * 60; // We store duration in seconds + $sql .= " AND t.task_duration <= " . $timespent_duration_end; + } + } + $sql .= dolSqlDateFilter('t.task_datehour', $search_day, $search_month, $search_year); // Add where from hooks @@ -1877,7 +1911,26 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } // Duration if (!empty($arrayfields['t.task_duration']['checked'])) { - print ''; + // Duration - Time spent + print ''; + + $durationtouse_start = 0; + if ($search_timespent_starthour || $search_timespent_startmin) { + $durationtouse_start = ($search_timespent_starthour * 3600 + $search_timespent_startmin * 60); + } + print '
'.$langs->trans('from').' '; + $form->select_duration('search_timespent_duration_start', $durationtouse_start, 0, 'text'); + print '
'; + + $durationtouse_end = 0; + if ($search_timespent_endhour || $search_timespent_endmin) { + $durationtouse_end = ($search_timespent_endhour * 3600 + $search_timespent_endmin * 60); + } + print '
'.$langs->trans('at').' '; + $form->select_duration('search_timespent_duration_end', $durationtouse_end, 0, 'text'); + print '
'; + + print ''; } // Product if (!empty($arrayfields['t.fk_product']['checked'])) { @@ -1971,7 +2024,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $total = 0; $totalvalue = 0; - $totalarray = array(); + $totalarray = array('nbfield'=>0); foreach ($tasks as $task_time) { if ($i >= $limit) { break; @@ -2168,11 +2221,19 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if (!$i) { $totalarray['pos'][$totalarray['nbfield']] = 't.task_duration'; } - $totalarray['val']['t.task_duration'] += $task_time->task_duration; + if (empty($totalarray['val']['t.task_duration'])) { + $totalarray['val']['t.task_duration'] = $task_time->task_duration; + } else { + $totalarray['val']['t.task_duration'] += $task_time->task_duration; + } if (!$i) { $totalarray['totaldurationfield'] = $totalarray['nbfield']; } - $totalarray['totalduration'] += $task_time->task_duration; + if (empty($totalarray['totalduration'])) { + $totalarray['totalduration'] = $task_time->task_duration; + } else { + $totalarray['totalduration'] += $task_time->task_duration; + } } //Product @@ -2208,11 +2269,19 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if (!$i) { $totalarray['pos'][$totalarray['nbfield']] = 'value'; } - $totalarray['val']['value'] += $value; + if (empty($totalarray['val']['value'])) { + $totalarray['val']['value'] = $value; + } else { + $totalarray['val']['value'] += $value; + } if (!$i) { $totalarray['totalvaluefield'] = $totalarray['nbfield']; } - $totalarray['totalvalue'] += $value; + if (empty($totalarray['totalvalue'])) { + $totalarray['totalvalue'] = $value; + } else { + $totalarray['totalvalue'] += $value; + } } // Invoiced diff --git a/htdocs/public/emailing/mailing-read.php b/htdocs/public/emailing/mailing-read.php index 1c2bd6cea98..5829c62dbd7 100644 --- a/htdocs/public/emailing/mailing-read.php +++ b/htdocs/public/emailing/mailing-read.php @@ -46,8 +46,8 @@ if (!defined('NOREQUIREMENU')) { if (!defined('NOIPCHECK')) { define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip } -if (!defined("NOSESSION")) { - define("NOSESSION", '1'); +if (!defined('NOSESSION')) { + define('NOSESSION', '1'); } /** @@ -58,6 +58,8 @@ if (!defined("NOSESSION")) { function llxHeader() { } + + /** * Footer empty * @@ -121,19 +123,19 @@ if (!empty($tag)) { } */ - //Update status of target + // Update status of target $statut = '2'; $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles SET statut=".((int) $statut)." WHERE rowid = ".((int) $obj->rowid); $resql = $db->query($sql); if (!$resql) dol_print_error($db); - //Update status communication of thirdparty prospect + // Update status communication of thirdparty prospect if ($obj->source_id > 0 && $obj->source_type == 'thirdparty' && $obj->entity) { $sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.((int) $obj->entity).' AND rowid = '.((int) $obj->source_id); $resql = $db->query($sql); } - //Update status communication of contact prospect + // Update status communication of contact prospect if ($obj->source_id > 0 && $obj->source_type == 'contact' && $obj->entity) { $sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.((int) $obj->entity).' AND rowid IN (SELECT sc.fk_soc FROM '.MAIN_DB_PREFIX.'socpeople AS sc WHERE sc.rowid = '.((int) $obj->source_id).')'; $resql = $db->query($sql); diff --git a/htdocs/public/error-401.php b/htdocs/public/error-401.php index 3d453cd30e5..a160535ff10 100644 --- a/htdocs/public/error-401.php +++ b/htdocs/public/error-401.php @@ -20,6 +20,11 @@
Sorry. You are not allowed to access this resource. +
+
+ + No esta autorizado para acceder a este recurso. +
diff --git a/htdocs/public/error-404.php b/htdocs/public/error-404.php index c964e49cd85..84832100026 100644 --- a/htdocs/public/error-404.php +++ b/htdocs/public/error-404.php @@ -20,6 +20,10 @@
You requested a website or a page that does not exists. +
+
+ la pagina o el recurso solicitado no existe. +
diff --git a/htdocs/public/eventorganization/attendee_new.php b/htdocs/public/eventorganization/attendee_new.php index cb4ba38e628..7e02fda5e13 100644 --- a/htdocs/public/eventorganization/attendee_new.php +++ b/htdocs/public/eventorganization/attendee_new.php @@ -33,9 +33,7 @@ if (!defined('NOIPCHECK')) { if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } -if (!defined('NOIPCHECK')) { - define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -} + // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index b37cb15d9c0..7931c6a37c1 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -52,9 +52,7 @@ if (!defined('NOIPCHECK')) { if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } -if (!defined('NOIPCHECK')) { - define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -} + // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php @@ -83,7 +81,7 @@ $backtopage = GETPOST('backtopage', 'alpha'); $action = GETPOST('action', 'aZ09'); // Load translation files -$langs->loadLangs(array("main", "members", "companies", "install", "other")); +$langs->loadLangs(array("main", "members", "companies", "install", "other", "errors")); // Security check if (empty($conf->adherent->enabled)) { @@ -257,6 +255,17 @@ if (empty($reshook) && $action == 'add') { } } + // 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 = ''; + } + } + $public = GETPOSTISSET('public') ? 1 : 0; if (!$error) { @@ -393,7 +402,7 @@ if (empty($reshook) && $action == 'add') { } $to = $adh->makeSubstitution($conf->global->MAIN_INFO_SOCIETE_MAIL); - $from = $conf->global->ADHERENT_MAIL_FROM; + $from = getDolGlobalString('ADHERENT_MAIL_FROM'); $mailfile = new CMailFile( '['.$appli.'] '.$conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT, $to, @@ -552,7 +561,7 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW if (jQuery("#morphy").val() == \'mor\') { jQuery("#trcompany").show(); } - }; + } initmorphy(); jQuery("#morphy").change(function() { initmorphy(); @@ -789,6 +798,20 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW print ''; } + // Display Captcha code if is enabled + if (!empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + print ''; + 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(); diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index f0738f0e420..de6b27cba90 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -188,6 +188,10 @@ if ($action == 'confirm_refusepropal' && $confirm == 'yes') { if ($result < 0) { $error++; } + $result = $object->call_trigger('PROPAL_CLOSE_REFUSED_WEB', $user); + if ($result < 0) { + $error++; + } } } else { $db->rollback(); diff --git a/htdocs/public/partnership/new.php b/htdocs/public/partnership/new.php index b6444753eb7..af2583abece 100644 --- a/htdocs/public/partnership/new.php +++ b/htdocs/public/partnership/new.php @@ -40,9 +40,7 @@ if (!defined('NOIPCHECK')) { if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } -if (!defined('NOIPCHECK')) { - define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -} + // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 79104817e77..c4b2d502d3d 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -281,15 +281,9 @@ if ((empty($paymentmethod) || $paymentmethod == 'stripe') && isModEnabled('strip } // Initialize $validpaymentmethod +// The list can be complete by the hook 'doValidatePayment' executed inside getValidOnlinePaymentMethods() $validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod); -// This hook is used to push to $validpaymentmethod by external payment modules (ie Payzen, ...) -$parameters = [ - 'paymentmethod' => $paymentmethod, - 'validpaymentmethod' => &$validpaymentmethod -]; -$reshook = $hookmanager->executeHooks('doValidatePayment', $parameters, $object, $action); - // Check security token $tmpsource = $source; if ($tmpsource == 'membersubscription') { @@ -2395,7 +2389,7 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme color: '#fa755a', iconColor: '#fa755a' } - }; + } var cardElement = elements.create('card', {style: style}); @@ -2435,7 +2429,7 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme ?> var cardButton = document.getElementById('buttontopay'); var clientSecret = cardButton.dataset.secret; - var options = { clientSecret: clientSecret,}; + var options = { clientSecret: clientSecret }; // Create an instance of Elements var elements = stripe.elements(options); @@ -2465,7 +2459,7 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme color: '#fa755a', iconColor: '#fa755a' } - }; + } initHooks(array('newpayment')); $langs->loadLangs(array("main", "other", "dict", "bills", "companies", "paybox", "paypal")); @@ -337,6 +338,16 @@ if (isModEnabled('stripe')) { } } +// Check status of the object to verify if it is paid by external payment modules +$action = ''; +$parameters = [ + 'paymentmethod' => $paymentmethod, +]; +$reshook = $hookmanager->executeHooks('isPaymentOK', $parameters, $object, $action); +if ($reshook >= 0) { + $ispaymentok = $hookmanager->resArray['ispaymentok']; +} + // If data not provided from back url, search them into the session env if (empty($ipaddress)) { @@ -1142,6 +1153,8 @@ if ($ispaymentok) { // (we need first that the donation module is able to generate a pdf document for the cerfa with pre filled content) } elseif (array_key_exists('ATT', $tmptag) && $tmptag['ATT'] > 0) { // Record payment for registration to an event for an attendee + require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; + require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $object = new Facture($db); $result = $object->fetch($ref); @@ -1355,6 +1368,8 @@ if ($ispaymentok) { } } elseif (array_key_exists('BOO', $tmptag) && $tmptag['BOO'] > 0) { // Record payment for booth or conference + require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; + require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $object = new Facture($db); $result = $object->fetch($ref); @@ -1461,6 +1476,8 @@ if ($ispaymentok) { if (!$error) { // Putting the booth to "suggested" state + require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; + require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; $booth = new ConferenceOrBooth($db); $resultbooth = $booth->fetch((int) $tmptag['BOO']); if ($resultbooth < 0) { diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php index 7603c046006..c44002340d6 100644 --- a/htdocs/public/project/new.php +++ b/htdocs/public/project/new.php @@ -39,9 +39,7 @@ if (!defined('NOIPCHECK')) { if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } -if (!defined('NOIPCHECK')) { - define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -} + // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php @@ -289,7 +287,6 @@ if (empty($reshook) && $action == 'add') { $proj->ref = $defaultref; $proj->statut = $proj::STATUS_DRAFT; $proj->status = $proj::STATUS_DRAFT; - $proj->email = GETPOST("email"); $proj->public = 1; $proj->usage_opportunity = 1; $proj->title = $langs->trans("LeadFromPublicForm"); diff --git a/htdocs/public/project/suggestbooth.php b/htdocs/public/project/suggestbooth.php index 68e469b6a00..7005265053e 100644 --- a/htdocs/public/project/suggestbooth.php +++ b/htdocs/public/project/suggestbooth.php @@ -33,9 +33,7 @@ if (!defined('NOIPCHECK')) { if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } -if (!defined('NOIPCHECK')) { - define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -} + // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php diff --git a/htdocs/public/project/suggestconference.php b/htdocs/public/project/suggestconference.php index 5590b0bf94c..9f0dd6638db 100644 --- a/htdocs/public/project/suggestconference.php +++ b/htdocs/public/project/suggestconference.php @@ -33,9 +33,7 @@ if (!defined('NOIPCHECK')) { if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } -if (!defined('NOIPCHECK')) { - define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -} + // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php diff --git a/htdocs/public/recruitment/index.php b/htdocs/public/recruitment/index.php index 23a180b9a7b..8724e65ca4f 100644 --- a/htdocs/public/recruitment/index.php +++ b/htdocs/public/recruitment/index.php @@ -252,7 +252,7 @@ if (is_array($results)) { } } print ''; - print $tmpuser->getFullName(-1); + print $tmpuser->getFullName(); print '   '.dol_print_email($emailforcontact, 0, 0, 1, 0, 0, 'envelope'); print ''; print '
'; diff --git a/htdocs/public/recruitment/view.php b/htdocs/public/recruitment/view.php index 57cb82d9b08..3626693ce89 100644 --- a/htdocs/public/recruitment/view.php +++ b/htdocs/public/recruitment/view.php @@ -159,6 +159,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; * View */ +$now = dol_now(); + $head = ''; if (!empty($conf->global->MAIN_RECRUITMENT_CSS_URL)) { $head = ''."\n"; @@ -201,7 +203,7 @@ $paramlogo = 'ONLINE_RECRUITMENT_LOGO_'.$suffix; if (!empty($conf->global->$paramlogo)) { $logosmall = $conf->global->$paramlogo; } elseif (!empty($conf->global->ONLINE_RECRUITMENT_LOGO)) { - $logosmall = $conf->global->ONLINE_RECRUITMENT_LOGO_; + $logosmall = $conf->global->ONLINE_RECRUITMENT_LOGO; } //print ''."\n"; // Define urllogo @@ -221,7 +223,7 @@ if ($urllogo) { if (!empty($mysoc->url)) { print ''; } - print ''; + print ''; if (!empty($mysoc->url)) { print ''; } @@ -234,7 +236,7 @@ if ($urllogo) { if (!empty($conf->global->RECRUITMENT_IMAGE_PUBLIC_INTERFACE)) { print '
'; - print ''; + print ''; print '
'; } diff --git a/htdocs/public/users/view.php b/htdocs/public/users/view.php new file mode 100644 index 00000000000..ba1a6dd0908 --- /dev/null +++ b/htdocs/public/users/view.php @@ -0,0 +1,419 @@ + + * + * 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/users/view.php + * \ingroup user + * \brief Public file to user profile + */ + +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.'/core/lib/security.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/vcard.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array("companies", "other", "recruitment")); + +// Get parameters +$action = GETPOST('action', 'aZ09'); +$mode = GETPOST('mode', 'aZ09'); +$cancel = GETPOST('cancel', 'alpha'); +$backtopage = ''; + +$id = GETPOST('id', 'int'); +$securekey = GETPOST('securekey', 'alpha'); +$suffix = GETPOST('suffix'); + +$object = new User($db); +$object->fetch($id, '', '', 1); + +// 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 +global $dolibarr_main_instance_unique_id; +$encodedsecurekey = dol_hash($dolibarr_main_instance_unique_id.'uservirtualcard'.$object->id.'-'.$object->login, 'md5'); +if ($encodedsecurekey != $securekey) { + httponly_accessforbidden('Bad value for securitykey or public profile not enabled'); +} + +if (!getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) { + httponly_accessforbidden('Bad value for securitykey or public profile not enabled'); +} + + +/* + * Actions + */ + +if ($cancel) { + if (!empty($backtopage)) { + header("Location: ".$backtopage); + exit; + } + $action = 'view'; +} + + +/* + * View + */ + +$form = new Form($db); +$company = $mysoc; + +if ($mode == 'vcard') { + // We create VCard + $v = new vCard(); + + $output = $v->buildVCardString($object, $company, $langs); + + $filename = trim(urldecode($v->getFileName())); // "Nom prenom.vcf" + $filenameurlencoded = dol_sanitizeFileName(urlencode($filename)); + //$filename = dol_sanitizeFileName($filename); + + top_httphead('text/x-vcard; name="'.$filename.'"'); + + header("Content-Disposition: attachment; filename=\"".$filename."\""); + header("Content-Length: ".dol_strlen($output)); + header("Connection: close"); + + print $output; + + $db->close(); + + exit; +} + +$head = ''; +if (!empty($conf->global->MAIN_USER_PROFILE_CSS_URL)) { + $head = ''."\n"; +} + +$conf->dol_hide_topmenu = 1; +$conf->dol_hide_leftmenu = 1; + +if (!getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) { + $langs->load("errors"); + print '
'.$langs->trans('ErrorPublicInterfaceNotEnabled').'
'; + $db->close(); + exit(); +} + +$arrayofjs = array(); +$arrayofcss = array(); + +$replacemainarea = (empty($conf->dol_hide_leftmenu) ? '
' : '').'
'; +llxHeader($head, $langs->trans("UserProfile").' '.$object->getFullName($langs), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea, 1, 1); + +print ''."\n"; +print '
'."\n"; +print '
'."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''; +print "\n"; +print ''."\n"; + +$modulepart = 'userphotopublic'; +$imagesize = 'small'; +$dir = $conf->user->dir_output; +$email = $object->email; + +// 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 +$logo = ''; +$logosmall = ''; +if (!empty($object->photo)) { + if (dolIsAllowedForPreview($object->photo)) { + $logosmall = get_exdir(0, 0, 0, 0, $object, 'user').'photos/'.getImageFileNameForSize($object->photo, '_small'); + $logo = get_exdir(0, 0, 0, 0, $object, 'user').'photos/'.$object->photo; + //$originalfile = get_exdir(0, 0, 0, 0, $object, 'user').'photos/'.$object->photo; + } +} +//print ''."\n"; +// Define urllogo +$urllogo = ''; +$urllogofull = ''; +if (!empty($logosmall) && is_readable($conf->user->dir_output.'/'.$logosmall)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$conf->entity.'&securekey='.urlencode($securekey).'&file='.urlencode($logosmall); + $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart='.$modulepart.'&entity='.$conf->entity.'&securekey='.urlencode($securekey).'&file='.urlencode($logosmall); +} elseif (!empty($logo) && is_readable($conf->user->dir_output.'/'.$logo)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$conf->entity.'&securekey='.urlencode($securekey).'&file='.urlencode($logo); + $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart='.$modulepart.'&entity='.$conf->entity.'&securekey='.urlencode($securekey).'&file='.urlencode($logo); +} + +// Output html code for logo +print '
'; +print '
'; + +// Name +print '
'.$object->getFullName($langs).'
'; +// User position +if ($object->job && !getDolUserInt('USER_PUBLIC_HIDE_JOBPOSITION', 0, $object)) { + print '
'; + print dol_escape_htmltag($object->job); + print '
'; +} + + +print '
'; +/*if (empty($conf->global->MAIN_HIDE_POWERED_BY)) { + print ''; +}*/ +print '
'; + + +if (!empty($conf->global->USER_IMAGE_PUBLIC_INTERFACE)) { + print '
'; + print ''; + print '
'; +} + +$urlforqrcode = $object->getOnlineVirtualCardUrl('vcard'); + +$socialnetworksdict = getArrayOfSocialNetworks(); + + + +// Show barcode +$showbarcode = GETPOST('nobarcode') ? 0 : 1; +if ($showbarcode) { + print '
'; + print '
'; + print ''; + print '
'; + print '
'; +} + + +// Me +// Show photo +if ($urllogo) { + print ''; +} + + +$usersection = ''; + +// User email +if ($object->email && !getDolUserInt('USER_PUBLIC_HIDE_EMAIL', 0, $object)) { + $usersection .= '
'; + $usersection .= dol_print_email($object->email, 0, 0, 1, 0, 1, 1); + $usersection .= '
'; +} + +// User url +if ($object->url && !getDolUserInt('USER_PUBLIC_HIDE_URL', 0, $object)) { + $usersection .= '
'; + $usersection .= img_picto('', 'globe', 'class="pictofixedwidth"'); + $usersection .= dol_print_url($object->url, '_blank', 0, 0, ''); + $usersection .= '
'; +} + +// User phone +if ($object->office_phone && !getDolUserInt('USER_PUBLIC_HIDE_OFFICE_PHONE', 0, $object)) { + $usersection .= '
'; + $usersection .= img_picto('', 'phone', 'class="pictofixedwidth"'); + $usersection .= dol_print_phone($object->office_phone, $object->country_code, 0, $mysoc->id, 'tel', ' ', 0, ''); + $usersection .= '
'; +} +if ($object->office_fax && !getDolUserInt('USER_PUBLIC_HIDE_OFFICE_FAX', 0, $object)) { + $usersection .= '
'; + $usersection .= img_picto('', 'phoning_fax', 'class="pictofixedwidth"'); + $usersection .= dol_print_phone($object->office_fax, $object->country_code, 0, $mysoc->id, 'fax', ' ', 0, ''); + $usersection .= '
'; +} +if ($object->user_mobile && !getDolUserInt('USER_PUBLIC_HIDE_USER_MOBILE', 0, $object)) { + $usersection .= '
'; + $usersection .= img_picto('', 'phone', 'class="pictofixedwidth"'); + $usersection .= dol_print_phone($object->user_mobile, $object->country_code, 0, $mysoc->id, 'tel', ' ', 0, ''); + $usersection .= '
'; +} + +// Social networks +if (!empty($object->socialnetworks) && is_array($object->socialnetworks) && count($object->socialnetworks) > 0) { + if (!getDolUserInt('USER_PUBLIC_HIDE_SOCIALNETWORKS', 0, $object)) { + foreach ($object->socialnetworks as $key => $value) { + if ($value) { + $usersection .= '
'.dol_print_socialnetworks($value, 0, $mysoc->id, $key, $socialnetworksdict).'
'; + } + } + } +} + +if ($usersection) { + print ''."\n"; + + // Output payment summary form + print ''."\n"; + + print '
'; + + print '
'; + + print $usersection; + + print '
'."\n"; + print "\n"; + + print '
'."\n"; +} + + +if (!getDolUserInt('USER_PUBLIC_HIDE_COMPANY', 0, $object)) { + $companysection = ''; + + if ($mysoc->email) { + $companysection .= '
'; + $companysection .= img_picto('', 'email', 'class="pictofixedwidth"'); + $companysection .= dol_print_email($mysoc->email, 0, 0, 1); + $companysection .= '
'; + } + + if ($mysoc->url) { + $companysection .= '
'; + $companysection .= img_picto('', 'globe', 'class="pictofixedwidth"'); + $companysection .= dol_print_url($mysoc->url, '_blank', 0, 0, ''); + $companysection .= '
'; + } + + if ($mysoc->phone) { + $companysection .= '
'; + $companysection .= img_picto('', 'phone', 'class="pictofixedwidth"'); + $companysection .= dol_print_phone($mysoc->phone, $mysoc->country_code, 0, $mysoc->id, 'tel', ' ', 0, ''); + $companysection .= '
'; + } + if ($mysoc->fax) { + $companysection .= '
'; + $companysection .= img_picto('', 'phoning_fax', 'class="pictofixedwidth"'); + $companysection .= dol_print_phone($mysoc->fax, $mysoc->country_code, 0, $mysoc->id, 'fax', ' ', 0, ''); + $companysection .= '
'; + } + + // Social networks + if (!empty($mysoc->socialnetworks) && is_array($mysoc->socialnetworks) && count($mysoc->socialnetworks) > 0) { + foreach ($mysoc->socialnetworks as $key => $value) { + if ($value) { + $companysection .= '
'.dol_print_socialnetworks($value, 0, $mysoc->id, $key, $socialnetworksdict).'
'; + } + } + } + + // 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_squarred_small ? $mysoc->logo_squarred_small : $mysoc->logo_small; + $logo = $mysoc->logo_squarred ? $mysoc->logo_squarred : $mysoc->logo; + $paramlogo = 'ONLINE_USER_LOGO_'.$suffix; + if (!empty($conf->global->$paramlogo)) { + $logosmall = $conf->global->$paramlogo; + } elseif (!empty($conf->global->ONLINE_USER_LOGO)) { + $logosmall = $conf->global->ONLINE_USER_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 '
'; + if (!empty($mysoc->url)) { + print ''; + } + print ''; + if (!empty($mysoc->url)) { + print ''; + } + print '
'; + } + print ''."\n"; + + // Output payment summary form + print ''."\n"; + + print '
'; + + print '
'; + + // Add company info + if ($mysoc->name) { + print '
'; + print $mysoc->name; + print '
'; + print '
'; + } + + print $companysection; + + print '
'."\n"; + print "\n"; + + print '
'."\n"; +} + + +// Description +$text = getDolUserString('USER_PUBLIC_MORE', '', $object); +print $text; + + +print ''."\n"; +print '
'."\n"; +print '
'; + + +//htmlPrintOnlinePaymentFooter($mysoc, $langs); + +print ''; + +llxFooter('', 'public'); + +$db->close(); diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 3e99bc1194c..e20cd531565 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -1951,23 +1951,27 @@ if ($action == 'create') { if (isModEnabled('productbatch')) { if (isset($lines[$i]->batch)) { print ''; - print ''; - $detail = ''; - if ($lines[$i]->product->status_batch) { - $detail .= $langs->trans("Batch").': '.$lines[$i]->batch; - if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { - $detail .= ' - '.$langs->trans("SellByDate").': '.dol_print_date($lines[$i]->sellby, "day"); + print ''; + $detail = $langs->trans("NA"); + if ($lines[$i]->product->status_batch && $lines[$i]->fk_product > 0) { + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; + $productlot = new Productlot($db); + $reslot = $productlot->fetch(0, $lines[$i]->fk_product, $lines[$i]->batch); + if ($reslot > 0) { + $detail = $productlot->getNomUrl(1); + } else { + // lot is not created and info is only in reception lines + $batchinfo = $langs->trans("Batch").': '.$lines[$i]->batch; + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + $batchinfo .= ' - '.$langs->trans("SellByDate").': '.dol_print_date($lines[$i]->sellby, "day"); + } + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + $batchinfo .= ' - '.$langs->trans("EatByDate").': '.dol_print_date($lines[$i]->eatby, "day"); + } + $detail = $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"), $batchinfo); } - if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { - $detail .= ' - '.$langs->trans("EatByDate").': '.dol_print_date($lines[$i]->eatby, "day"); - } - $detail .= '
'; - - print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"), $detail); - } else { - print $langs->trans("NA"); } - print ''; + print $detail . ''; } else { print ''; } diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 8ae9744a8dd..03ed28a2200 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -1348,25 +1348,6 @@ class Reception extends CommonObject dol_syslog(get_class($this)."::initAsSpecimen"); - // Load array of products prodids - $num_prods = 0; - $prodids = array(); - $sql = "SELECT rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."product"; - $sql .= " WHERE entity IN (".getEntity('product').")"; - $sql .= $this->db->plimit(100); - - $resql = $this->db->query($sql); - if ($resql) { - $num_prods = $this->db->num_rows($resql); - $i = 0; - while ($i < $num_prods) { - $i++; - $row = $this->db->fetch_row($resql); - $prodids[$i] = $row[0]; - } - } - $order = new CommandeFournisseur($this->db); $order->initAsSpecimen(); @@ -2006,32 +1987,32 @@ class Reception extends CommonObject /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array('reception'); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** * Function used to replace a product id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old product id - * @param int $dest_id New product id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) + public static function replaceProduct(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'commande_fournisseur_dispatch' ); - return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceProduct($dbs, $origin_id, $dest_id, $tables); } } diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index cac761023ef..42deedd5419 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -927,7 +927,7 @@ if (!empty($arrayfields['e.date_delivery']['checked'])) { if (!empty($arrayfields['l.ref']['checked'])) { // Delivery ref print ''; - print ''; } if (!empty($arrayfields['l.date_delivery']['checked'])) { @@ -959,8 +959,8 @@ if (!empty($arrayfields['e.tms']['checked'])) { } // Status if (!empty($arrayfields['e.fk_statut']['checked'])) { - print ''; - print $form->selectarray('search_status', array('0'=>$langs->trans('StatusReceptionDraftShort'), '1'=>$langs->trans('StatusReceptionValidatedShort'), '2'=>$langs->trans('StatusReceptionProcessedShort')), $search_status, 1); + print ''; + print $form->selectarray('search_status', array('0'=>$langs->trans('StatusReceptionDraftShort'), '1'=>$langs->trans('StatusReceptionValidatedShort'), '2'=>$langs->trans('StatusReceptionProcessedShort')), $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage'); print ''; } // Status billed diff --git a/htdocs/reception/tpl/linkedobjectblock.tpl.php b/htdocs/reception/tpl/linkedobjectblock.tpl.php index 009534b91b5..341e30e3784 100644 --- a/htdocs/reception/tpl/linkedobjectblock.tpl.php +++ b/htdocs/reception/tpl/linkedobjectblock.tpl.php @@ -50,12 +50,12 @@ foreach ($linkedObjectBlock as $key => $objectlink) { } ?> - trans("Reception"); ?> + trans("Reception"); ?> global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { print ' - getNomUrl(1); ?> + getNomUrl(1); ?> ref_supplier); ?> date_delivery, 'day'); ?> - * Copyright (C) 2020 Adminson Alicealalalamdskfldmjgdfgdfhfghgfh +/* Copyright (C) 2004-2020 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 @@ -88,16 +87,14 @@ $setupnotempty = 0; * Actions */ -if ((float) DOL_VERSION >= 6) { - include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -} +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstjob = GETPOST('maskconstjob', 'alpha'); - $maskjob = GETPOST('maskjob', 'alpha'); + $maskconst = GETPOST('maskconstjob', 'alpha'); + $maskvalue = GETPOST('maskjob', 'alpha'); - if ($maskconstjob) { - $res = dolibarr_set_const($db, $maskconstjob, $maskjob, 'chaine', 0, '', $conf->entity); + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { + $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); } if (!($res > 0)) { diff --git a/htdocs/recruitment/admin/setup_candidatures.php b/htdocs/recruitment/admin/setup_candidatures.php index adc12a656f4..1da5d698645 100644 --- a/htdocs/recruitment/admin/setup_candidatures.php +++ b/htdocs/recruitment/admin/setup_candidatures.php @@ -1,6 +1,5 @@ - * Copyright (C) 2020 Adminson Alicealalalamdskfldmjgdfgdfhfghgfh +/* Copyright (C) 2004-2020 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 @@ -88,16 +87,14 @@ $setupnotempty = 0; * Actions */ -if ((float) DOL_VERSION >= 6) { - include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -} +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstcand = GETPOST('maskconstcand', 'alpha'); - $maskcand = GETPOST('maskcand', 'alpha'); + $maskconst = GETPOST('maskconstcand', 'aZ09'); + $maskvalue = GETPOST('maskcand', 'alpha'); - if ($maskconstcand) { - $res = dolibarr_set_const($db, $maskconstcand, $maskcand, 'chaine', 0, '', $conf->entity); + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { + $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); } if (!($res > 0)) { diff --git a/htdocs/recruitment/class/recruitmentcandidature.class.php b/htdocs/recruitment/class/recruitmentcandidature.class.php index 2ece5dbe217..1690f13da56 100644 --- a/htdocs/recruitment/class/recruitmentcandidature.class.php +++ b/htdocs/recruitment/class/recruitmentcandidature.class.php @@ -894,8 +894,8 @@ class RecruitmentCandidature extends CommonObject $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_recruitmentcandidature = '.((int) $this->id))); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; diff --git a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php index cfbf91463e8..147e8ec3519 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php @@ -264,7 +264,7 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile = basename($srctemplatepath); - $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile); $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); $newfiletmp = $objectref.'_'.$newfiletmp; 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 94e93c87baa..61c2eb3ff20 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 @@ -798,7 +798,7 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio /** * Show top header of page. * - * @param Tcpdf $pdf Object PDF + * @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 @@ -832,13 +832,13 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (empty($conf->global->PDF_DISABLE_MYCOMPANY_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 (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { + if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { $logo = $logodir.'/logos/'.$this->emetteur->logo; diff --git a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php index 9635eba3e58..415ac3357eb 100644 --- a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php +++ b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php @@ -54,7 +54,7 @@ class mod_recruitmentcandidature_advanced extends ModeleNumRefRecruitmentCandida /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { @@ -69,7 +69,7 @@ class mod_recruitmentcandidature_advanced extends ModeleNumRefRecruitmentCandida $texte .= ''; $texte .= ''; $texte .= ''; - $texte .= ''; + $texte .= '
'; $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("RecruitmentCandidature"), $langs->transnoentities("RecruitmentCandidature")); $tooltip .= $langs->trans("GenericMaskCodes2"); diff --git a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php index 4f781a18214..be565486c3a 100644 --- a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php +++ b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php @@ -54,7 +54,7 @@ class mod_recruitmentjobposition_advanced extends ModeleNumRefRecruitmentJobPosi /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { @@ -69,7 +69,7 @@ class mod_recruitmentjobposition_advanced extends ModeleNumRefRecruitmentJobPosi $texte .= ''; $texte .= ''; $texte .= ''; - $texte .= '
'; + $texte .= '
'; $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("RecruitmentJobPosition"), $langs->transnoentities("RecruitmentJobPosition")); $tooltip .= $langs->trans("GenericMaskCodes2"); diff --git a/htdocs/recruitment/core/modules/recruitment/modules_recruitmentcandidature.php b/htdocs/recruitment/core/modules/recruitment/modules_recruitmentcandidature.php index 089aa720fa7..362e890c6ef 100644 --- a/htdocs/recruitment/core/modules/recruitment/modules_recruitmentcandidature.php +++ b/htdocs/recruitment/core/modules/recruitment/modules_recruitmentcandidature.php @@ -86,7 +86,7 @@ abstract class ModeleNumRefRecruitmentCandidature /** * Returns the default description of the numbering template * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/recruitment/core/modules/recruitment/modules_recruitmentjobposition.php b/htdocs/recruitment/core/modules/recruitment/modules_recruitmentjobposition.php index 9efabac2d37..aaf8bed6c53 100644 --- a/htdocs/recruitment/core/modules/recruitment/modules_recruitmentjobposition.php +++ b/htdocs/recruitment/core/modules/recruitment/modules_recruitmentjobposition.php @@ -122,7 +122,7 @@ abstract class ModeleNumRefRecruitmentJobPosition /** * Returns the default description of the numbering template * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/recruitment/lib/recruitment.lib.php b/htdocs/recruitment/lib/recruitment.lib.php index acc7160f282..911c6abdb03 100644 --- a/htdocs/recruitment/lib/recruitment.lib.php +++ b/htdocs/recruitment/lib/recruitment.lib.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2019 Laurent Destailleur + * Copyright (C) 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 @@ -28,7 +29,11 @@ */ function recruitmentAdminPrepareHead() { - global $langs, $conf; + global $langs, $conf, $db; + + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label('recruitment_recruitmentjobposition'); + $extrafields->fetch_name_optionals_label('recruitment_recruitmentcandidature'); $langs->load("recruitment"); @@ -52,11 +57,19 @@ function recruitmentAdminPrepareHead() $head[$h][0] = dol_buildpath("/recruitment/admin/jobposition_extrafields.php", 1); $head[$h][1] = $langs->trans("ExtrafieldsJobPosition"); + $nbExtrafields = $extrafields->attributes['recruitment_recruitmentjobposition']['count']; + if ($nbExtrafields > 0) { + $head[$h][1] .= ''.$nbExtrafields.''; + } $head[$h][2] = 'jobposition_extrafields'; $h++; $head[$h][0] = dol_buildpath("/recruitment/admin/candidature_extrafields.php", 1); $head[$h][1] = $langs->trans("ExtrafieldsApplication"); + $nbExtrafields = $extrafields->attributes['recruitment_recruitmentcandidature']['count']; + if ($nbExtrafields > 0) { + $head[$h][1] .= ''.$nbExtrafields.''; + } $head[$h][2] = 'candidature_extrafields'; $h++; diff --git a/htdocs/recruitment/recruitmentcandidature_agenda.php b/htdocs/recruitment/recruitmentcandidature_agenda.php index 04118f55572..8a6c11caf1f 100644 --- a/htdocs/recruitment/recruitmentcandidature_agenda.php +++ b/htdocs/recruitment/recruitmentcandidature_agenda.php @@ -48,7 +48,7 @@ if (GETPOST('actioncode', 'array')) { $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)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -143,6 +143,7 @@ if ($object->id > 0) { $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; + $morehtmlref.= $object->getFullName('', 1); /* // Ref customer $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); @@ -211,7 +212,7 @@ if ($object->id > 0) { $out .= '&socid='.$objthirdparty->id; } $backtopageurl = urlencode($_SERVER['PHP_SELF'].'?id='.$objthirdparty->id); - $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&backtopage='.$backtopageurl.'&percentage=-1'; + $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&backtopage='.$backtopageurl; //$out.=$langs->trans("AddAnAction").' '; //$out.=img_picto($langs->trans("AddAnAction"),'filenew'); //$out.=""; @@ -221,7 +222,7 @@ if ($object->id > 0) { print '
'; if (isModEnabled('agenda')) { - if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { + if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { print ''.$langs->trans("AddAction").''; } else { print ''.$langs->trans("AddAction").''; diff --git a/htdocs/recruitment/recruitmentcandidature_card.php b/htdocs/recruitment/recruitmentcandidature_card.php index 2452c9e530b..7cf9fb47b56 100644 --- a/htdocs/recruitment/recruitmentcandidature_card.php +++ b/htdocs/recruitment/recruitmentcandidature_card.php @@ -426,6 +426,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; + $morehtmlref.= $object->getFullName('', 1); /* // Ref customer $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); diff --git a/htdocs/recruitment/recruitmentcandidature_document.php b/htdocs/recruitment/recruitmentcandidature_document.php index 3f08c770111..ed0cb115ea7 100644 --- a/htdocs/recruitment/recruitmentcandidature_document.php +++ b/htdocs/recruitment/recruitmentcandidature_document.php @@ -121,6 +121,7 @@ if ($object->id) { $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; + $morehtmlref.= $object->getFullName('', 1); /* // Ref customer $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); diff --git a/htdocs/recruitment/recruitmentcandidature_note.php b/htdocs/recruitment/recruitmentcandidature_note.php index 1649ab5ee5e..f04a22aaf1b 100644 --- a/htdocs/recruitment/recruitmentcandidature_note.php +++ b/htdocs/recruitment/recruitmentcandidature_note.php @@ -96,6 +96,7 @@ if ($id > 0 || !empty($ref)) { $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; + $morehtmlref.= $object->getFullName('', 1); /* // Ref customer $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); diff --git a/htdocs/recruitment/recruitmentjobposition_agenda.php b/htdocs/recruitment/recruitmentjobposition_agenda.php index f2f4d37484b..cd6476ec068 100644 --- a/htdocs/recruitment/recruitmentjobposition_agenda.php +++ b/htdocs/recruitment/recruitmentjobposition_agenda.php @@ -47,7 +47,7 @@ if (GETPOST('actioncode', 'array')) { $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)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -208,7 +208,7 @@ if ($object->id > 0) { if (get_class($objthirdparty) == 'Societe') { $out .= '&socid='.$objthirdparty->id; } - $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&backtopage=1&percentage=-1'; + $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&backtopage=1'; //$out.=$langs->trans("AddAnAction").' '; //$out.=img_picto($langs->trans("AddAnAction"),'filenew'); //$out.=""; @@ -218,7 +218,7 @@ if ($object->id > 0) { print '
'; if (isModEnabled('agenda')) { - if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { + if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { print ''.$langs->trans("AddAction").''; } else { print ''.$langs->trans("AddAction").''; diff --git a/htdocs/resource/agenda.php b/htdocs/resource/agenda.php index 8fddadcce11..b5a0c099cff 100644 --- a/htdocs/resource/agenda.php +++ b/htdocs/resource/agenda.php @@ -51,7 +51,7 @@ if (GETPOST('actioncode', 'array')) { $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)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -166,7 +166,7 @@ if ($object->id > 0) { print dol_get_fiche_end(); if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - $param = '&id='.$object->id.'&socid='.$socid; + $param = '&id='.$object->id; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -174,7 +174,7 @@ if ($object->id > 0) { $param .= '&limit='.urlencode($limit); } - print_barre_liste($langs->trans("ActionsOnResource"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1); + print_barre_liste($langs->trans("ActionsOnResource"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', '', '', '', 0, 1, 1); // List of all actions $filters = array(); diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 5c588b59c6b..3ee118d06c7 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -225,7 +225,7 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) { // Type print '
'; print ''; // Description diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 515a766263b..99cc586cbb9 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -292,7 +292,7 @@ class Dolresource extends CommonObject $sql .= " description=".(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "null").","; $sql .= " fk_country=".($this->country_id > 0 ? $this->country_id : "null").","; $sql .= " fk_code_type_resource=".(isset($this->fk_code_type_resource) ? "'".$this->db->escape($this->fk_code_type_resource)."'" : "null").","; - $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').""; + $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null'); $sql .= " WHERE rowid=".((int) $this->id); $this->db->begin(); @@ -619,7 +619,7 @@ class Dolresource extends CommonObject $sql .= " element_type=".(isset($this->element_type) ? "'".$this->db->escape($this->element_type)."'" : "null").","; $sql .= " busy=".(isset($this->busy) ? $this->busy : "null").","; $sql .= " mandatory=".(isset($this->mandatory) ? $this->mandatory : "null").","; - $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').""; + $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null'); $sql .= " WHERE rowid=".((int) $this->id); diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 0b961648115..975d4d16200 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -308,7 +308,7 @@ if ($action == 'add' && empty($cancel)) { $db->commit(); if (GETPOST('saveandnew', 'alpha')) { - setEventMessages($langs->trans("RecordSaved"), '', 'mesgs'); + setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); header("Location: card.php?action=create&fk_project=" . urlencode($projectid) . "&accountid=" . urlencode($accountid) . '&paymenttype=' . urlencode(GETPOST('paymenttype', 'az09')) . '&datepday=' . GETPOST("datepday", 'int') . '&datepmonth=' . GETPOST("datepmonth", 'int') . '&datepyear=' . GETPOST("datepyear", 'int')); exit; } else { @@ -381,6 +381,10 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->salaries- $object->paye = 0; $object->id = $object->ref = null; + if (GETPOST('amount', 'alphanohtml')) { + $object->amount = price2num(GETPOST('amount', 'alphanohtml'), 'MT', 2); + } + if (GETPOST('clone_label', 'alphanohtml')) { $object->label = GETPOST('clone_label', 'alphanohtml'); } else { @@ -658,18 +662,25 @@ if ($action == 'create' && $permissiontoadd) { print ''; print "Transaction status registered, you can close this"; diff --git a/htdocs/theme/eldy/badges.inc.php b/htdocs/theme/eldy/badges.inc.php index 1e6dfb54dbc..aae4e50fb29 100644 --- a/htdocs/theme/eldy/badges.inc.php +++ b/htdocs/theme/eldy/badges.inc.php @@ -246,7 +246,7 @@ function _createStatusBadgeCss($statusName, $statusVarNamePrefix = '', $commentL if (in_array((string) $statusName, $TBadgeBorderOnly)) { $thisBadgeTextColor = '#212529'; - $thisBadgeBackgroundColor = "#fff"; + $thisBadgeBackgroundColor = ""; } if (in_array((string) $statusName, array('0', '5', '9'))) { diff --git a/htdocs/theme/eldy/btn.inc.php b/htdocs/theme/eldy/btn.inc.php index b29c55bd02d..28ae22e9696 100644 --- a/htdocs/theme/eldy/btn.inc.php +++ b/htdocs/theme/eldy/btn.inc.php @@ -18,7 +18,9 @@ if (!defined('ISLOADEDBYSTEELSHEET')) { if (!empty($conf->global->THEME_DARKMODEENABLED)) { print "/* For dark mode */\n"; if ($conf->global->THEME_DARKMODEENABLED != 2) { - print "@media (prefers-color-scheme: dark) {"; + print "@media (prefers-color-scheme: dark) {"; // To test, click on the 3 dots menu, then Other options then Display then emulate prefer-color-schemes + } else { + print "@media not print {"; } print " :root { @@ -32,9 +34,7 @@ if (!empty($conf->global->THEME_DARKMODEENABLED)) { --textbutaction: rgb(255,255,255); }\n"; - if ($conf->global->THEME_DARKMODEENABLED != 2) { - print "}"; - } + print "}"; } ?> diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 6102e8584e8..289f44333cc 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1,6 +1,9 @@ - +} + +?> /*
'.$langs->trans("ResourceType").''; - $ret = $formresource->select_types_resource($object->fk_code_type_resource, 'fk_code_type_resource', '', 2); + $formresource->select_types_resource($object->fk_code_type_resource, 'fk_code_type_resource', '', 2); print '