diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index d7463d62172..280dc3a83cc 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -67,9 +67,12 @@ where In uppercase if you want to have the log comment appears into the generated ChangeLog file. The keyword can be ommitted if your commit does not fit in any of the following categories: + - Fix/FIX: for a bug fix - New/NEW: for an unreferenced new feature (Opening a feature request and using close is prefered) - Close/CLOSE: for closing a referenced feature request +- Perf/PERF: for performance enhancement +- Qual/QUAL: for quality code enhancement or re-engeneering #### Issuenum If your commit fixes a referenced bug or feature request. @@ -96,10 +99,10 @@ Try to keep lines under 120 characters.
 FIX|Fix #456 Short description (where #456 is number of bug fix, if it exists. In upper case to appear into ChangeLog)
 or
-NEW|New Short description (In upper case to appear into ChangeLog, use this if you add a feature not tracked, otherwise use CLOSE #456)
-or
 CLOSE|Close #456 Short description (where #456 is number of feature request, if it exists. In upper case to appear into ChangeLog)
 or
+NEW|New|QUAL|Qual|PERF|Perf Short description (In upper case to appear into ChangeLog, use this if you add a feature not tracked, otherwise use CLOSE #456)
+or
 Short description (when the commit is not introducing feature nor closing a bug)
 
 Long description (Can span accross multiple lines).
@@ -119,7 +122,7 @@ Also, some code changes need a prior approbation:
 
 * if you want to include a new external library (into htdocs/includes directory), please ask before to the core project manager (mention @dolibarr-jedi in your issue) to see if such a library can be accepted.
 
-* if you add a new tables or fields, you MUST first submit a standalone PR with the data structure changes you plan to add/modify (and only data structure changes). Start development only once this data structure has been accepted.
+* if you add new tables or fields, you MUST first submit a standalone PR with the data structure changes you plan to add/modify (and only data structure changes). Start development only once this data structure has been accepted.
 
 Once a PR has been submitted, you may need to wait for its integration. It is common that the project leader let the PR open for a long delay to allow every developer discuss about the PR (A label is added in such a case).
 
diff --git a/.github/workflows/code_quality_qodana.yml b/.github/workflows/code_quality_qodana.yml.disabled
similarity index 90%
rename from .github/workflows/code_quality_qodana.yml
rename to .github/workflows/code_quality_qodana.yml.disabled
index cb08ea9b4cd..f9296bf377e 100644
--- a/.github/workflows/code_quality_qodana.yml
+++ b/.github/workflows/code_quality_qodana.yml.disabled
@@ -21,7 +21,7 @@ jobs:
           fetch-depth: 1
           #php-version: '7.1'
       - name: 'Qodana Scan'
-        uses: JetBrains/qodana-action@v2023.1.5
+        uses: JetBrains/qodana-action@v2023.2.1
         #with:
         #  php-version: '7.1'
         env:
diff --git a/.github/workflows/exakat.yml.disabled b/.github/workflows/exakat.yml
similarity index 63%
rename from .github/workflows/exakat.yml.disabled
rename to .github/workflows/exakat.yml
index 1e9121a0e00..0b33ede5f4f 100644
--- a/.github/workflows/exakat.yml.disabled
+++ b/.github/workflows/exakat.yml
@@ -2,8 +2,9 @@
 name: "Exakat analysis"
 
 on:
+  # execute once a month, the 1st
   schedule:
-  - cron: "0 20 * * *"
+  - cron: "0 20 1 * *"
   workflow_dispatch:
     branches:
       - develop
@@ -15,11 +16,13 @@ jobs:
   exakat:
     runs-on: ubuntu-latest
     steps:
-    - uses: actions/checkout@v3
+    - uses: actions/checkout@v4
       with:
         fetch-depth: 1
     - name: Exakat
       uses: docker://exakat/exakat-ga
       with:
-        ignore_rules: 'Classes/UseInstanceof,Performances/PrePostIncrement,Functions/UndefinedFunctions,Functions/WrongNumberOfArguments,Functions/WrongTypeWithCall,Variables/UndefinedVariable,Classes/DontUnsetProperties,Classes/NonPpp,Classes/StaticMethodsCalledFromObject,Classes/UseClassOperator,Functions/UsesDefaultArguments,Php/NoClassInGlobal,Php/ShouldUseCoalesce,Php/WrongTypeForNativeFunction,Structures/AddZero,Structures/DropElseAfterReturn,Structures/IfWithSameConditions,Structures/MergeIfThen,Structures/ElseIfElseif,Structures/ExitUsage,Structures/RepeatedPrint,Structures/RepeatedRegex,Structures/SameConditions,Structures/SwitchWithoutDefault,Structures/ShouldMakeTernary,Structures/UselessParenthesis,Structures/UseConstant' 
-        ignore_dirs: '/htdocs/includes,/build,/dev,/doc,/scripts,/test'        
\ No newline at end of file
+        ignore_rules: 'Classes/UseInstanceof,Performances/PrePostIncrement,Functions/UndefinedFunctions,Functions/WrongNumberOfArguments,Functions/WrongTypeWithCall,Variables/UndefinedVariable,Classes/DontUnsetProperties,Classes/NonPpp,Classes/StaticMethodsCalledFromObject,Classes/UseClassOperator,Functions/UsesDefaultArguments,Php/NoClassInGlobal,Php/ShouldUseCoalesce,Php/WrongTypeForNativeFunction,Structures/AddZero,Structures/DropElseAfterReturn,Structures/IfWithSameConditions,Structures/MergeIfThen,Structures/NestedTernary,Structures/ElseIfElseif,Structures/ExitUsage,Structures/RepeatedPrint,Structures/RepeatedRegex,Structures/SameConditions,Structures/SwitchWithoutDefault,Structures/ShouldMakeTernary,Structures/UselessParenthesis,Structures/UseConstant' 
+        ignore_dirs: '/htdocs/includes/,/htdocs/install/doctemplates/,/build/,/dev/,/doc/,/scripts/,/test/'
+        file_extensions: php   
+        project_reports: Perfile     
\ No newline at end of file
diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml
index 560891f1ef1..1bb1184586f 100644
--- a/.github/workflows/phpcs.yml
+++ b/.github/workflows/phpcs.yml
@@ -11,7 +11,7 @@ jobs:
   phpcs:
     runs-on: ubuntu-latest
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
         with:
           fetch-depth: 50 # important!
 
diff --git a/.github/workflows/phpcsfixer.yml.disabled b/.github/workflows/phpcsfixer.yml.disabled
index 5c74397ecfc..959ba5ad801 100644
--- a/.github/workflows/phpcsfixer.yml.disabled
+++ b/.github/workflows/phpcsfixer.yml.disabled
@@ -1,6 +1,8 @@
 name: GitHub CI PHPCS and PHPCBF
 
-on: push
+on: 
+  pull_request:
+    types: [opened]
 #on: 
 #  push:
 #    paths:
@@ -11,7 +13,7 @@ jobs:
   #  uses: ./.github/workflows/files_changed.yaml
   #  with:
   #    folder_path: .*
-      
+
   linter_name:
     name: Run & fix PHP Code Sniffer
     runs-on: ubuntu-latest
@@ -19,7 +21,9 @@ jobs:
     steps:
       - uses: actions/checkout@v3
         with:
-          fetch-depth: 10
+          repository: ${{ github.event.pull_request.head.repo.full_name }}
+          ref: ${{ github.event.pull_request.head.ref }}      
+          #  fetch-depth: 10
 
       - name: echo Get list of all changed files
         run: |
@@ -39,6 +43,21 @@ jobs:
           phpcs_ref_name: ${{github.ref_name}}
           phpcs_github_event_name: ${{github.event_name}}
           phpcs_files: ${{ needs.filesChanged.outputs.all_changed_files }}
-      - uses: stefanzweifel/git-auto-commit-action@v4 # auto commit the fixes action for GitHub
+
+      #- uses: stefanzweifel/git-auto-commit-action@v4 # auto commit the fixes action for GitHub
+      #  with:
+      #    commit_message: Fix PHPCS errors by GitHub PHPCSfixer action
+
+      - name: Commit changes
+        uses: EndBug/add-and-commit@v9.1.3
         with:
-          commit_message: Fix PHPCS errors by GitHub PHPCSfixer action
+          default_author: github_actions
+          committer_name: GitHub Actions
+          committer_email: actions@github.com
+          #author_name: PHP CS fixer
+          #author_email: eldy@destailleur.fr
+          #committer_name: PHP CS fixer
+          #committer_email: eldy@destailleur.fr
+          message: 'PHP CS fixer github action'
+          add: '*.php'
+
diff --git a/.gitignore b/.gitignore
index 8c639a26540..cc8b27dae67 100644
--- a/.gitignore
+++ b/.gitignore
@@ -59,11 +59,6 @@ package-lock.json
 doc/install.lock
 /.asciidoctorconfig.adoc
 
-# Qodana
-.idea/vcs.xml
-.idea/modules.xml
-.idea/workspace.xml
-.idea/inspectionProfiles/Project_Default.xml
-.idea/jsLinters/jshint.xml
+.idea
 /composer.json
 /composer.lock
diff --git a/.idea/php.xml b/.idea/php.xml
deleted file mode 100644
index f324872a8ba..00000000000
--- a/.idea/php.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-  
-    
-  
-    
-  
-    
-  
-    
-  
-    
-
\ No newline at end of file
diff --git a/.scrutinizer.yml b/.scrutinizer.yml
deleted file mode 100644
index 058a0ba8b48..00000000000
--- a/.scrutinizer.yml
+++ /dev/null
@@ -1,236 +0,0 @@
-# .scrutinizer.yml
-#build:
-#    - php-scrutinizer-run
-build:
-    nodes:
-        analysis:
-            tests:
-                override:
-                    - command: php-scrutinizer-run
-                      idle_timeout: 8000
-                    #- php-scrutinizer-run --sub-project-dir=htdocs/admin
-
-imports:
-    - php
-
-filter:
-    excluded_paths:
-        - build/
-        - dev/
-        - doc/
-        - documents/
-        - node_modules/
-        - test/
-        - htdocs/custom/
-        - htdocs/includes/
-        - htdocs/install/doctemplates/
-    #dependency_paths:
-    #    - htdocs/includes/
-    paths: 
-        - htdocs/*
-        - scripts/*
-    
-tools:
-    # php_analyzer. Doc on https://scrutinizer-ci.com/docs/tools/php/php-analyzer/
-    php_analyzer:
-        enabled: true
-        extensions:
-            - php
-        #dependency_paths: 
-        #    - htdocs/includes/
-        filter:
-            excluded_paths:
-                - build/
-                - dev/
-                - doc/
-                - documents/
-                - htdocs/custom/
-                - htdocs/includes/
-                - htdocs/install/doctemplates/
-                - htdocs/core/class/lessc.class.php
-                - node_modules/
-                - test/
-            paths:
-                - htdocs/*
-                - scripts/*
-        config:
-            parameter_reference_check:
-                enabled:              true
-            checkstyle:
-                enabled:              false
-                no_trailing_whitespace:  true
-                naming:
-                    enabled:              true
-                    local_variable:       ^[a-z][a-zA-Z0-9]*$
-                    abstract_class_name:  ^Abstract|Factory$
-                    utility_class_name:   Utils?$
-                    constant_name:        ^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$
-                    property_name:        ^[a-z][a-zA-Z0-9]*$
-                    method_name:          ^(?:[a-z]|__)[a-zA-Z0-9]*$
-                    parameter_name:       ^[a-z][a-zA-Z0-9]*$
-                    interface_name:       ^[A-Z][a-zA-Z0-9]*Interface$
-                    type_name:            ^[A-Z][a-zA-Z0-9]*$
-                    exception_name:       ^[A-Z][a-zA-Z0-9]*Exception$
-                    isser_method_name:    ^(?:is|has|should|may|supports)
-            unreachable_code:
-                enabled:              true
-            check_access_control:
-                enabled:              true
-            typo_checks:
-                enabled:              true
-            check_variables:
-                enabled:              true
-            check_calls:
-                enabled:              true
-                too_many_arguments:   true
-                missing_argument:     true
-                argument_type_checks:  lenient # Allowed Values: "disabled", "lenient", "strict"
-            suspicious_code:
-                enabled:              true
-                overriding_parameter:  false
-                overriding_closure_use:  true
-                parameter_closure_use_conflict:  true
-                parameter_multiple_times:  true
-                non_existent_class_in_instanceof_check:  true
-                non_existent_class_in_catch_clause:  true
-                assignment_of_null_return:  true
-                non_commented_switch_fallthrough:  true
-                non_commented_empty_catch_block:  true
-                overriding_private_members:  true
-                use_statement_alias_conflict:  true
-                precedence_in_condition_assignment:  true
-            dead_assignments:
-                enabled:              true
-            verify_php_doc_comments:
-                enabled:              false
-                parameters:           true
-                return:               true
-                suggest_more_specific_types:  true
-                ask_for_return_if_not_inferrable:  true
-                ask_for_param_type_annotation:  true
-            loops_must_use_braces:
-                enabled:              true
-            check_usage_context:
-                enabled:              true
-            simplify_boolean_return:
-                enabled:              false
-            phpunit_checks:
-                enabled:              false
-            reflection_checks:
-                enabled:              true
-
-            # Checks Common Precedence Mistakes
-            precedence_checks:
-                enabled:              true
-                assignment_in_condition:  true
-                comparison_of_bit_result:  true
-            basic_semantic_checks:
-                enabled:              true
-            # Disabled unused code. In most cases, we want to keep it.
-            unused_code:
-                enabled:              false		
-            deprecation_checks:
-                enabled:              true
-            useless_function_calls:
-                enabled:              true
-            metrics_lack_of_cohesion_methods:
-                enabled:              true
-            metrics_coupling:
-                enabled:              true
-                stable_code:
-                    namespace_prefixes:   []
-                    classes:              []
-            doctrine_parameter_binding:
-                enabled:              false
-            doctrine_entity_manager_injection:
-                enabled:              false
-            symfony_request_injection:
-                enabled:              false
-            doc_comment_fixes:
-                enabled:              true
-            reflection_fixes:
-                enabled:              false
-            use_statement_fixes:
-                enabled:              true
-                remove_unused:        true
-                # Whether you would like multiple imports in one USE statement to be preserved, e.g. ``use A, B;``.
-                preserve_multiple:    false
-                # Whether you would like to preserve blank lines between use statements.
-                preserve_blanklines:  false
-                order_alphabetically:  false
-         # To use specific config for a specific path, use path_configs: (see example on page https://scrutinizer-ci.com/docs/configuration/tool_config_structure)
-                        
-    # php_depend
-    #php_pdepend:
-    #    enabled: false
-    #    configuration_file: null
-    #    suffixes:
-    #        - php
-    #    excluded_dirs: {  }
-    #    filter:
-    #        excluded_paths:
-    #            - 'build/*'
-    #            - 'dev/*'
-    #            - 'doc/*'
-    #            - 'test/*'
-    #            - 'htdocs/includes/*'
-    #        paths: {  }
-
-    # change tracking
-    #php_changetracking:
-    #    enabled: false
-    #    bug_patterns:
-    #        - '\bfix(?:es|ed)?\b'
-    #    feature_patterns:
-    #        - '\badd(?:s|ed)?\b'
-    #        - '\bimplement(?:s|ed)?\b'
-    #    filter:
-    #        excluded_paths:
-    #            - 'build/*'
-    #            - 'dev/*'
-    #            - 'doc/*'
-    #            - 'documents/*'
-    #            - 'htdocs/includes/*'
-    #            - 'node_modules/*'
-    #            - 'test/*'
-    #        paths: {  }
-
-    # Similar code detection
-    #php_sim:
-    #    enabled: false
-    #    min_mass: 30
-    #    filter:
-    #        excluded_paths:
-    #            - 'build/*'
-    #            - 'dev/*'
-    #            - 'doc/*'
-    #            - 'documents/*'
-    #            - 'htdocs/includes/*'
-    #            - 'node_modules/*'
-    #            - 'test/*'
-    #        paths: {  }
-            
-    # Coding-Style / Bug Detection
-    #js_hint:
-    #    enabled: false
-    #    use_native_config: true
-    #    extensions:
-    #        - js
-    #    filter:
-    #        excluded_paths:
-    #            - 'build/*'
-    #            - 'dev/*'
-    #            - 'doc/*'
-    #            - 'documents/*'
-    #            - 'htdocs/includes/*'
-    #            - 'node_modules/*'
-    #            - 'test/*'
-    #        paths: {  }
-    #    config: {  }
-    #    path_configs: {  }
-
-
-before_commands: {  }
-after_commands: {  }
-artifacts: {  }
-build_failure_conditions: {  }
diff --git a/.stickler.yml b/.stickler.yml
deleted file mode 100644
index 642dec27412..00000000000
--- a/.stickler.yml
+++ /dev/null
@@ -1,14 +0,0 @@
----
-linters:
-  phpcs:
-      standard: 'dev/setup/codesniffer/ruleset.xml'
-      extensions: 'php'
-      tab_width: 4
-      fixer: true
-
-fixers:
-    enable: true
-
-files:
-    ignore:
-        - 'htdocs/includes/*'
diff --git a/.travis.yml b/.travis.yml
index a5e26790005..19fb70cbc93 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,7 +8,7 @@ dist: focal
 
 language: generic
 
-scan_logs: false
+#scan_logs: false
 
 git:
   depth: 1
@@ -325,22 +325,24 @@ script:
     echo
 
   - |
-    echo "Checking coding style (only for Pull Requests builds and 1 version to not overload travis and avoid duplicate tests)"
+    echo "Checking coding style (only for 1 version to not overload travis and avoid duplicate tests)"
     # Ensure we catch errors
     set -e
     # Exclusions are defined in the ruleset.xml file
-    if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "8.1" ]; then
+    #if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "8.1" ]; then
+    if [ "$TRAVIS_PHP_VERSION" = "8.1" ]; then
       phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true .;
     fi
     set +e
     echo
 
   - |
-    echo "Checking missing debug"
+    echo "Checking missing debug (only for 1 version to not overload travis and avoid duplicate tests)"
     # Ensure we catch errors
     set -e
     # Exclusions are defined in the ruleset.xml file
-    if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "8.1" ]; then
+    #if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "8.1" ]; then
+    if [ "$TRAVIS_PHP_VERSION" = "8.1" ]; then
        var-dump-check --extensions php --tracy --exclude htdocs/includes --exclude test/ --exclude htdocs/public/test/ --exclude htdocs/core/lib/functions.lib.php .
     fi
     set +e
@@ -371,6 +373,7 @@ script:
     echo '$'force_install_mainforcehttps=false';' >> $INSTALL_FORCED_FILE
     echo '$'force_install_main_data_root=\'$TRAVIS_BUILD_DIR/htdocs\'';' >> $INSTALL_FORCED_FILE
     #cat $INSTALL_FORCED_FILE
+    echo
   
   - |
     echo "Upgrading Dolibarr"
@@ -436,15 +439,22 @@ script:
     php upgrade.php 17.0.0 18.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade17001800.log
     php upgrade2.php 17.0.0 18.0.0 > $TRAVIS_BUILD_DIR/upgrade17001800-2.log
     php step5.php 17.0.0 18.0.0 > $TRAVIS_BUILD_DIR/upgrade17001800-3.log
+    php upgrade.php 18.0.0 19.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade18001900.log || cat $TRAVIS_BUILD_DIR/upgrade18001900.log
+    php upgrade2.php 18.0.0 19.0.0 > $TRAVIS_BUILD_DIR/upgrade18001900-2.log || cat $TRAVIS_BUILD_DIR/upgrade18001900-2.log
+    php step5.php 18.0.0 19.0.0 > $TRAVIS_BUILD_DIR/upgrade18001900-3.log || cat $TRAVIS_BUILD_DIR/upgrade18001900-3.log
+    set +e
+    echo
 
-    #show table content and log
+  - |
+    echo Show some debug info like table content or log
     #echo '\d llx_adherent' | psql 'postgresql://postgres:postgres@127.0.0.1:5432/travis'
-    #cat $TRAVIS_BUILD_DIR/upgrade500600.log
+    cat $TRAVIS_BUILD_DIR/upgrade18001900.log
+    echo
 
   - |
     echo Result of migration scripts
     ls -alrt $TRAVIS_BUILD_DIR/
-        
+
     echo Show content of last file
     cat $TRAVIS_BUILD_DIR/"$(ls -rt $TRAVIS_BUILD_DIR/ | tail -n1)"
 
@@ -463,6 +473,7 @@ script:
     echo
     #cat /tmp/dolibarr_install.log
     cat $TRAVIS_BUILD_DIR/enablemodule.log
+    echo
 
   - |
     echo "Unit testing"
@@ -472,6 +483,7 @@ script:
     phpunitresult=$?
     echo "Phpunit return code = $phpunitresult"
     set +e
+    echo
 
 after_script:
   - |
diff --git a/COPYRIGHT b/COPYRIGHT
index 2485625914a..96c39a39650 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -52,7 +52,7 @@ bacon, dasprid, swiss-qr-bill, kmukku, symfony/validator
 JS libraries:
 Ace                    1.4.14        BSD                         Yes             JS library to get code syntaxique coloration in a textarea.
 ChartJS                3.7.1         MIT License                 Yes             JS library for graph
-CKEditor               4.18          LGPL-2.1+                   Yes             Editor WYSIWYG
+CKEditor               4.22.1        LGPL-2.1+                   Yes             Editor WYSIWYG
 jQuery                 3.6.4         MIT License                 Yes             JS library
 jQuery UI              1.13.2        GPL and MIT License         Yes             JS library plugin UI
 jQuery select2         4.0.13        GPL and Apache License      Yes             JS library plugin for sexier multiselect. Warning: 4.0.6+ create troubles without patching css
diff --git a/ChangeLog b/ChangeLog
index 33335d77545..1c7e4933f98 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,27 @@ English Dolibarr ChangeLog
 --------------------------------------------------------------
 
 
+***** ChangeLog for 19.0.0 compared to 18.0.0 *****
+
+For users:
+----------
+...
+
+For developers or integrators:
+------------------------------
+...
+
+
+WARNING:
+
+Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
+* The property ->brouillon has been removed from all classes. It was not reliable and was a duplicate of ->status == self::STATUS_DRAFT.
+* The method get_substitutionarray_shipment_lines() has been removed. Use the generic get_substitutionarray_lines() instead.
+* Recheck setup of your module workflow to see if you need to enable the new setting to have shipment set to billed automatically 
+  when an invoice from a shipment is validated (and if your process is to make invoice on shipment and not on order).
+* It was possible to use a variable $soc or $right inside a php code condition of some extrafields properties, this is no more true (this vars are no more defined globaly).
+
+
 ***** ChangeLog for 18.0.1 compared to 18.0.0 *****
 FIX: Adding a product in recurring invoice does not use the correct VAT
 FIX: API /product/getAttributes
@@ -39,8 +60,8 @@ FIX: when adding new times on a survey, all hours would be erased.
 
 ***** ChangeLog for 18.0.0 compared to 17.0.0 *****
 
-For uses:
----------
+For users:
+----------
 
 NEW: PHP 8.2 compatibility (not yet complete).
 NEW: Module Workstations Management upgraded to stable status.
@@ -53,66 +74,56 @@ NEW: Accountancy - Manage intra-community VAT on supplier invoices - FPC22
 NEW: Accountancy - iSuiteExpert export model
 NEW: Accountancy - Quadratus export with attachments in accountancy export
 NEW: Accountancy - Can filter on a custom group of accounts. Perf or ledger list.
+NEW: Accountancy - Can select the export format during export of journals
+NEW: Accountancy - sort of column of custom group of account
 NEW: Can upload a file with drag and drop on purchase invoice, vats, salaries and social contributions 
 NEW: Authentication: #22740 add OpenID Connect impl
 NEW: Authentication: add experimental support for Google OAuth2 connexion
 NEW: Authentication: can now edit service name for OAuth token
-NEW: Add a public virtual card page for each user
-NEW: Add a status on supplier price ref (WIP to close a supplier ref)
 NEW: add bookmarks in selectable landing pages for users
 NEW: Add column ext_payment_site into societe_rib to allow multiple payment mode
 NEW: add convertion of images to webp for a single image in website media editor
 NEW: Add CRC for currency symbol before amount
-NEW: add customer code to invoices listing
 NEW: Add filter on nb of generation done in list of recurring invoices
 NEW: Add filters and sort on product unit column
 NEW: Add link to edit VAT list from error message of missing VAT
 NEW: add margins in paiement/card.php
 NEW: Add mass action delete on VAT
-NEW: Add origin info when create a product batch when created from a movement stock
 NEW: Add possibility to choose format #21426
-NEW: Add SQL contraint on product_stock table to allow only exsting product and warehouse #23543
-NEW: Add STRIPE_DEBUG, a way to log Stripe IPN
 NEW: An external module can modify the quick search fields
-NEW: Auto activate some modules on install (Export/Import/Wysiwyg editor)
-NEW: Autofill email form with the email template with status "Default" on
-NEW: Bank name no more mandatory on creation. Can be generated if empty.
-NEW: Bank: Add fields zip, town, country for owner of a bank account
+NEW: Bank:  Bank name no more mandatory on creation. Can be generated if empty.
+NEW: Bank:  Add fields zip, town, country for owner of a bank account
 NEW: batch referential objets
 NEW: Can add the add now link on date into addfieldvalue()
+NEW: Can add an array of several links in date selector
 NEW: Can bin accounting line for a given month
-NEW: Can edit account on miscellaneous payment (if not transfered)
 NEW: Can edit inline the VAT number from supplier tab
-NEW: Can fill date of salary payment with date of start of salary
 NEW: Can go back to draft on shipment when stock change not on validate
 NEW: Can modify bank account of sepa payment (if file not sent yet)
-NEW: Customers: add date due and labels into customer comm card
-NEW: Can select the export format during export of journals
 NEW: Can set a checkbox in formconfirm by clicking on the label
-NEW: Can set flag default value on email templates
 NEW: Can set the page "List of opportunities" as landing page
-NEW: Can show the sql request used on emailing selection
+NEW: Can show the SQL request used on emailing selection
 NEW: can stay on edit field when errors occurs
 NEW: comment in api_mymodule for seperate methods
-NEW: constant PROPALE_ADDON_NOTE_PUBLIC_DEFAULT
 NEW: create email substitution variable for intervention signature URL
+NEW: Contacts: presend mass action in contact list
+NEW: Contacts: hook printFieldListFrom in contact list
+NEW: Customers: add date due and labels into customer comm card
 NEW: Debug the custom CSS feature to avoid a directory search/scan at
 NEW: dev name
 NEW: Disable bad reputation product price
-NEW: dolExplodeIntoArray can accept regex
-NEW: dol_sort_array can sort on alphabetical order even if val is num
-NEW: element time integration code + SQL
+NEW: Email: autofill email form with the email template with status "Default" on
 NEW: Email: don't have closed contact proposed as receiver for the mails
+NEW: Email: can set flag default value on email templates
 NEW: Email-Collector: add field reply-to in email collector as possible filter
 NEW: Email-Collector: substitute date now in email collector
 NEW: Email-Collector: operation type in email collector to load or create contact
 NEW: Email-Collector: easier setup - can also use ! for negative search
+NEW: Email-Templates: show module into list of email templates
 NEW: Events: can add any contact on events if global MAIN_ACTIONCOM_CAN_ADD_ANY_CONTACT is set at 1
 NEW: Events: list with color
-NEW: expend/collapse list of social networks
-NEW: Filter on amount and qty on list of service's contracts
+NEW: Events: remove default percentage for event creation url
 NEW: formconfirm can support field with format datetime
-NEW: getCommonSubstitutionArray to have more substitute keys
 NEW: GeoIP: Can test a geoip conversion from the geoip setup page
 NEW: GUI: add a CSS editor into the admin GUI
 NEW: GUI: add dropdown button actions (example on Create button on project)
@@ -123,16 +134,17 @@ NEW: GUI: can set background style with MAIN_LOGIN_BACKGROUND_STYLE
 NEW: Help: Tooltip to explain how to add a photo on a product
 NEW: Help: Possibility to link to German pages in help
 NEW: helper functions for dates + small demo case
-NEW: hook printFieldListFrom in contact list
+NEW: HR - Salary: can fill date of salary payment with date of start of salary
 NEW: HR - Salary: can modify the date of payment of a salary (if not reconciled)
 NEW: HR - Salary: date for salary payment includes the hour/min
 NEW: HR - Salary: adding button Send Email on the salary file
 NEW: Import: filter on entity in import
 NEW: Import: map table to element for get entity in import
 NEW: inc.php: handle parameters from argv
-NEW: Invoice - show category of operations
+NEW: Installation: Auto activate some modules on install (Export/Import/Wysiwyg editor)
+NEW: Invoice: show category of operations
+NEW: Invoice: add customer code to invoices listing
 NEW: Keep a link between user created from recruitment and application
-NEW: List product in orders
 NEW: Mass Actions: Better responsive for mass actions
 NEW: Members: add numbering modules for members
 NEW: Members: add widget box_members_by_tags.php
@@ -146,75 +158,75 @@ NEW: No overwrite of optionals during put() contact
 NEW: Notifications: add Customer Order delivered (ORDER_NEW) in module Notification
 NEW: Notifications: for Sign or Refused Propal from Online Page
 NEW: Now we can edit amount on VAT and salaries clone action
-NEW: only get openned contact from liste_contact function, to not have acces to closed contact as mail receiver
+NEW: only get opened contact from liste_contact function, to not have access to closed contact as mail receiver
+NEW: Option: MAIN_SECURITY_MAXFILESIZE_DOWNLOADED #yogosha10660
 NEW: Option to manage deposit slips for more payment modes (not only
 NEW: Option to show column for field and line selection on the left
 NEW: Orders: add sub total in order list det
+NEW: Orders: list product in orders
 NEW: Orders export: allow to export field 'shipment method'
 NEW: payment default values when supplier order created from reception
-NEW: Payment : manage contracts
-NEW: presend mass action in contact list
+NEW: Payment: manage contracts
+NEW: Payment: sepaStripe now creates the payment mode with type pm_ using new API
+NEW: Payment: add partial payment reason "withholding tax"
+NEW: Payment: Can edit account on miscellaneous payment (if not transfered)
 NEW: Print PDF: category of operation for crabe PDF model
 NEW: Print PDF: Name and date to print on PDF Sign
 NEW: Print PDF: Use the more recent PDF templates for documents by default on a fresh install
+NEW: Print PDF: Option PDF_SHOW_PHONE_AFTER_USER_CONTACT to show phone after specific assigned contact on PDF
+NEW: Print PDF: Option PDF_SHOW_EMAIL_AFTER_USER_CONTACT to show email after specific assigned contact on PDF
 NEW: product images on popup are cached
+NEW: Products: Add origin info when create a product batch when created from a movement stock
 NEW: Products: Add statistics by amount on statistics of products.
+NEW: Products: Add SQL contraint on product_stock table to allow only existing product and warehouse #23543
 NEW: Proposals: filter for Signed+Billed in proposals
 NEW: Proposals: can modify margin rates in offers like VAT rates
 NEW: Proposals: option filter for NoSalesRepresentativeAffected in proposals list
-NEW: Provide the oldcopy value when calling setValueFrom() function with a trigger key
+NEW: Proposals: constant PROPALE_ADDON_NOTE_PUBLIC_DEFAULT
 NEW: Reception: can receive more than qty ordered on reception
 NEW: referential objects of batch
-NEW: remove default percentage for event creation url
 NEW: remove keys whose table element is the same as element in map list
 NEW: repair script skip views
+NEW: search on time spent duration range
 NEW: Security: Save date to invalidate other session into user table
 NEW: Security: Invalidate all sessions of a user when password is modified.
-NEW: search on time spent duration range
-NEW: sepaStripe now creates the payment mode with type pm_ using new API
-NEW: set payment default values when supplier order created from reception
+NEW: Service Contracts: Filter on amount and qty on list of service's contracts
 NEW: set today start time at beginning
-NEW: Show counter of access of website in website list
 NEW: Show main currency in company info user tooltip
-NEW: Show module into list of emails templates
-NEW: Show picto into the combobox of widgets
 NEW: Show supplier invoice ref of direct debit transfer tab invoices
-NEW: show supplier name in getNomUrl of supplier order
-NEW: sort of column of custom group of account
-NEW: Supplier Invoices: add ability of ODT support to supplier invoices
+NEW: Social Networks: expend/collapse list of social networks
 NEW: Stock limit for alert and desired optimal stock by product and warehouse import
 NEW: Stock: Add warehouse create and modify triggers.
 NEW: Stock: Can select several warehouses into the view stock at date in past
+NEW: Stripe: add STRIPE_DEBUG, a way to log Stripe IPN
+NEW: Supplier Invoices: add ability of ODT support to supplier invoices
+NEW: Supplier Order:  show supplier name in getNomUrl of supplier order
+NEW: Supplier Order:  set payment default values when supplier order created from reception
+NEW: Supplier Price:  Add a status on supplier price ref (WIP to close a supplier ref)
 NEW: Support different bank account for several direct debit payments
 NEW: Support multiselect in the warehouse selection combo box
-NEW: Option: MAIN_SECURITY_MAXFILESIZE_DOWNLOADED #yogosha10660
 NEW: Survey: Comment on survey is possible only after vote.
-NEW: tables: llx_element_time to store time spent on several elements (mo, ticket...)
 NEW: TakePOS: adapt category and product pictures sizes on TakePOS
 NEW: TakePOS: limit load products in TakePOS
 NEW: The batch for remind on due date can be setup for using validation date
-NEW: The refresh link for imap collector is always visible
-NEW: The upgrade process can be done by creating a file upgrade.unlock
-NEW: Tickets: --Send an email when ticket assigned--
+NEW: The refresh link for IMAP collector is always visible
+NEW: Third-Party: use an ajax component to switch prospection status on thirdparty list
 NEW: Tickets: Send a notification email when ticket assigned
 NEW: Tickets: set ticket status to answered if the client has answered from the public interface
 NEW: Tickets: added an option to display the progress of tickets on the public interface
 NEW: Tickets: add link to thirdparty tickets history
 NEW: Tickets: notify also the contributor affected to a ticket if a new message public is post (add global TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_ALSO_CONTRIBUTOR)
+NEW: Upgrades: The upgrade process can be done by creating a file upgrade.unlock
 NEW: Use a cache file for external RSS in calendar
 NEW: Use by default the domain $dolibarr_main_url_root for SMTP HELO
-NEW: use more recent model by default
+NEW: Users: add a public virtual card page for each user
 NEW: VAT can be modified during add of line
 NEW: Website Module: Increment website counter on each page access in website module
-NEW: write all fields and their properties in asciidoc format
-NEW: Can add an array of several links in date selector
-NEW: Option PDF_SHOW_PHONE_AFTER_USER_CONTACT to show phone after specific assigned contact on PDF
-NEW: Option PDF_SHOW_EMAIL_AFTER_USER_CONTACT to show email after specific assigned contact on PDF
+NEW: Website Module: Show counter of access of website in website list
+NEW: Widgets: Show picto into the combobox of widgets
 NEW: Widgets: Implement MAIN_ACTIVATE_FILECACHE on birthday widget
 NEW: Widgets: Add widget "The next upcoming events"
 NEW: Widgets: Add widget of open opportunities
-NEW: use an ajax component to switch prospection status on thirdparty list
-NEW: Add partial payment reason "withholding tax"
 
 
 
@@ -224,18 +236,28 @@ For developers or integrators:
 NEW: Make it possible to select hours and minutes in form_confirm
 NEW: add triggers on mailing
 NEW: Add a trigger when create a shipping line batch and fix propagate missing errors
-NEW: add function for listiong objects from directory
+NEW: add function for listing objects from directory
 NEW: add helplist property to describe fields of objects
-NEW: add hook in loadLotStock() in html.formproduct.class.php file, add hook 'llxFooter', Add hook online sign
-NEW: Update lib parsedownto 1.7.4, phpspreadsheet lib to v1.12, ESCPOS v3.0, jquery, Stripe.
-NEW: Support contact in post() document API
-NEW: More APIs (update currency rate, upload of supplier documents, ...)
+NEW: API: Support contact in post() document API
+NEW: API: more APIs (update currency rate, upload of supplier documents, ...)
+NEW: Hooks: printFieldListFrom in contact list
+NEW: Hooks: add hook in loadLotStock() in html.formproduct.class.php file
+NEW: Hooks: add hook 'llxFooter'
+NEW: Hooks: add hook online sign
+NEW: Hooks: add sent info in the parameters provided to the hook sendMailAfter
+NEW: Libraries: Update libs parsedownto 1.7.4, phpspreadsheet lib to v1.12, ESCPOS v3.0, jquery, Stripe.
 NEW: ModuleBuilder: updating in modulbuilder on tab Menu when adding object
 NEW: ModuleBuilder: add/edit permissions
 NEW: ModuleBuilder: better generated documentation
-NEW: add sent info in the parameters provided to the hook sendMailAfter
 NEW: add setAsSelectUser into factory for generic setup page
 NEW: add option keepspace into dol_string_nospecialchar()
+NEW: dol_sort_array can sort on alphabetical order even if val is num
+NEW: dolExplodeIntoArray can accept regex
+NEW: element time integration code + SQL
+NEW: tables: llx_element_time to store time spent on several elements (mo, ticket...)
+NEW: Provide the oldcopy value when calling setValueFrom() function with a trigger key
+NEW: getCommonSubstitutionArray to have more substitute keys
+NEW: write all fields and their properties in asciidoc format
 
 
 WARNING:
diff --git a/SECURITY.md b/SECURITY.md
index 2c93a201151..a64518800a4 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -48,7 +48,7 @@ Reports are processed around once a month.
 
 ONLY vulnerabilities discovered, when the following setup on test platform is used, are "valid":
 
-* The version to analyze must be the last version available into "develop" branch or into last stable "vX.Y" released version.  
+* The version to analyze must be the last version available into "develop" branch or into last stable "vX.Y" released version. Reports on vulnerabilities already fixed (so already reported) into the develop branch will not be validated.   
 * $dolibarr_main_prod must be set to 1 into conf.php
 * $dolibarr_nocsrfcheck must be kept to the value 0 into conf.php (this is the default value)
 * $dolibarr_main_force_https must be set to something else than 0.
diff --git a/build/exe/doliwamp/Makefile b/build/exe/doliwamp/Makefile
index 8e446931c74..3344232b177 100644
--- a/build/exe/doliwamp/Makefile
+++ b/build/exe/doliwamp/Makefile
@@ -1,5 +1,5 @@
 #-------------------------------------------------------------------#
-# Makefile
+# Makefile to build UsedPort exe
 #-------------------------------------------------------------------#
 # 1.0     Laurent Destailleur     Creation 
 #-------------------------------------------------------------------#
diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl
index b7586e3909f..5862f3f2970 100755
--- a/build/makepack-dolibarr.pl
+++ b/build/makepack-dolibarr.pl
@@ -2,7 +2,7 @@
 #----------------------------------------------------------------------------
 # \file         build/makepack-dolibarr.pl
 # \brief        Dolibarr package builder (tgz, zip, rpm, deb, exe, aps)
-# \author       (c)2004-2020 Laurent Destailleur  
+# \author       (c)2004-2023 Laurent Destailleur  
 #
 # This is list of constant you can set to have generated packages moved into a specific dir: 
 #DESTIBETARC='/media/HDDATA1_LD/Mes Sites/Web/Dolibarr/dolibarr.org/files/lastbuild'
@@ -369,12 +369,12 @@ if ($nboftargetok) {
 		}
 		if (! $BUILD || $BUILD eq '0-rc')	# For a major version
 		{
-			print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log `git rev-list --boundary '.$MAJOR.'.'.$MINOR.'..origin/develop | grep ^- | cut -c2- | head -n 1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\|CLOSE\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/CLOSE/NEW/g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
+			print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log `git rev-list --boundary '.$MAJOR.'.'.$MINOR.'..origin/develop | grep ^- | cut -c2- | head -n 1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\|PERF\|SEC\|QUAL\|CLOSE\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/CLOSE/NEW/g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
 		}
 		else			# For a maintenance release
 		{
-			#print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/CLOSE/NEW/g\'| sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
-			print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. | grep -v "Merge branch" | grep -v "Merge pull" | grep "^ " | sed -e "s/^[0-9a-z]* *//" | grep -e \'^FIX\|NEW\|CLOSE\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/CLOSE/NEW/g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
+			#print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\|PERF\|SEC\|QUAL\|CLOSE\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/CLOSE/NEW/g\'| sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
+			print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. | grep -v "Merge branch" | grep -v "Merge pull" | grep "^ " | sed -e "s/^[0-9a-z]* *//" | grep -e \'^FIX\|NEW\|PERF\|SEC\|QUAL\|CLOSE\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/CLOSE/NEW/g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
 		}
 		print "\n";
 		if (! $ret)
@@ -627,11 +627,11 @@ if ($nboftargetok) {
         $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/sabre/sabre/*/tests`;
         $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/stripe/tests`;
         $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/stripe/LICENSE`;
-        $ret=`rm -f  $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/examples`;
         $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-*`;
         $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/freefont-*`;
         $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/ae_fonts_*`;
         $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/utils`;
+        $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/examples`;
         $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/tools`;
         $ret=`rm -f  $BUILDROOT/$PROJECT/htdocs/includes/vendor`;
         $ret=`rm -f  $BUILDROOT/$PROJECT/htdocs/includes/webmozart`;
diff --git a/build/phpstan/README b/build/phpstan/README
index 4ecde9baca5..097aac0d3c4 100644
--- a/build/phpstan/README
+++ b/build/phpstan/README
@@ -1,9 +1,21 @@
-PHPStan 
-
-https://phpstan.org 
+PHPStan (https://phpstan.org) 
+-----------------------------
 
 PHPStan requires PHP >= 7.1
 
-Install:  composer require --dev phpstan/phpstan
+Config File is: ./phpstan.neon
 
-Config File:  phpstan.neon
+Install phpstan:  
+cd git; mkdir phpstan
+cd phpstan
+composer require --dev phpstan/phpstan
+
+Build report from CLI:
+cd git/dolibarr; mv htdocs/custom /tmp/
+php ../phpstan/htdocs/includes/bin/phpstan -v analyze -a build/phpstan/bootstrap.php --memory-limit 4G --error-format=table htdocs/commande/class 
+php ../phpstan/htdocs/includes/bin/phpstan -v analyze -a build/phpstan/bootstrap.php --memory-limit 4G --error-format=table 
+mv /tmp/custom htdocs
+
+Build HTML report from Cron:
+Example of line to add into a cron to generate a HTML report:
+0 1 5 * * cd /home/dolibarr/preview.dolibarr.org/dolibarr; chmod -R u+w /home/dolibarr/preview.dolibarr.org/dolibarr; git pull; /home/dolibarr/phpstan/vendor/bin/phpstan -v analyze -a build/phpstan/bootstrap.php --memory-limit 4G --error-format=github | awk ' BEGIN{ print "Date "strftime("%Y-%m-%d")"
" } { print $0"
" } END{ print NR } ' > /home/dolibarr/doxygen.dolibarr.org/phpstan/index.html diff --git a/build/rector/README b/build/rector/README new file mode 100644 index 00000000000..7e8bd115682 --- /dev/null +++ b/build/rector/README @@ -0,0 +1,8 @@ +How to use Rector to fix code +----------------------------- + +First, move rector.php file into htdocs + +Then install rector. + +Then ... \ No newline at end of file diff --git a/htdocs/rector.php b/build/rector/rector.php similarity index 100% rename from htdocs/rector.php rename to build/rector/rector.php diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index dd2ef0023de..89d87a4ab14 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -185,6 +185,23 @@ with: return strval($number); } +* Add this at begin of tcpdf_autoconfig.php + + // @CHANGE LDR DOCUMENT_ROOT fix for IIS Webserver + if ((!isset($_SERVER['DOCUMENT_ROOT'])) OR (empty($_SERVER['DOCUMENT_ROOT']))) { + if (isset($_SERVER['SCRIPT_FILENAME']) && isset($_SERVER['PHP_SELF'])) { + $_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr($_SERVER['SCRIPT_FILENAME'], 0, 0-strlen($_SERVER['PHP_SELF']))); + } elseif(isset($_SERVER['PATH_TRANSLATED'])) { + $_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0-strlen($_SERVER['PHP_SELF']))); + } else { + // define here your DOCUMENT_ROOT path if the previous fails (e.g. '/var/www') + $_SERVER['DOCUMENT_ROOT'] = '/'; + } + } + $_SERVER['DOCUMENT_ROOT'] = str_replace('//', '/', $_SERVER['DOCUMENT_ROOT']); + if (substr($_SERVER['DOCUMENT_ROOT'], -1) != '/') { + $_SERVER['DOCUMENT_ROOT'] .= '/'; + } TCPDI: diff --git a/dev/examples/code/create_invoice.php b/dev/examples/code/create_invoice.php index 1d231a7fd7a..0278f0c3bef 100755 --- a/dev/examples/code/create_invoice.php +++ b/dev/examples/code/create_invoice.php @@ -40,7 +40,7 @@ $error=0; // -------------------- START OF YOUR CODE HERE -------------------- // Include Dolibarr environment -require_once $path."../../htdocs/master.inc.php"; +require_once $path."../../../htdocs/master.inc.php"; // After this $db, $mysoc, $langs and $conf->entity are defined. Opened handler to database will be closed at end of file. //$langs->setDefaultLang('en_US'); // To change default language of $langs diff --git a/dev/examples/code/create_order.php b/dev/examples/code/create_order.php index a851ac3cbc5..6d43e323191 100755 --- a/dev/examples/code/create_order.php +++ b/dev/examples/code/create_order.php @@ -40,7 +40,7 @@ $error=0; // -------------------- START OF YOUR CODE HERE -------------------- // Include Dolibarr environment -require_once $path."../../htdocs/master.inc.php"; +require_once $path."../../../htdocs/master.inc.php"; // After this $db, $mysoc, $langs and $conf->entity are defined. Opened handler to database will be closed at end of file. //$langs->setDefaultLang('en_US'); // To change default language of $langs diff --git a/dev/examples/code/create_product.php b/dev/examples/code/create_product.php index 8f742065f2f..e3c8c3c9d76 100755 --- a/dev/examples/code/create_product.php +++ b/dev/examples/code/create_product.php @@ -40,7 +40,7 @@ $error=0; // -------------------- START OF YOUR CODE HERE -------------------- // Include Dolibarr environment -require_once $path."../../htdocs/master.inc.php"; +require_once $path."../../../htdocs/master.inc.php"; // After this $db, $mysoc, $langs and $conf->entity are defined. Opened handler to database will be closed at end of file. //$langs->setDefaultLang('en_US'); // To change default language of $langs diff --git a/dev/examples/code/create_user.php b/dev/examples/code/create_user.php index e374fec531d..fb24c6aa39a 100755 --- a/dev/examples/code/create_user.php +++ b/dev/examples/code/create_user.php @@ -40,7 +40,7 @@ $error=0; // -------------------- START OF YOUR CODE HERE -------------------- // Include Dolibarr environment -require_once $path."../../htdocs/master.inc.php"; +require_once $path."../../../htdocs/master.inc.php"; // After this $db, $mysoc, $langs and $conf->entity are defined. Opened handler to database will be closed at end of file. //$langs->setDefaultLang('en_US'); // To change default language of $langs diff --git a/dev/examples/code/get_contracts.php b/dev/examples/code/get_contracts.php index 40bee133d11..1b30e6b2e17 100755 --- a/dev/examples/code/get_contracts.php +++ b/dev/examples/code/get_contracts.php @@ -40,7 +40,7 @@ $error=0; // -------------------- START OF YOUR CODE HERE -------------------- // Include Dolibarr environment -require_once $path."../../htdocs/master.inc.php"; +require_once $path."../../../htdocs/master.inc.php"; // After this $db, $mysoc, $langs and $conf->entity are defined. Opened handler to database will be closed at end of file. //$langs->setDefaultLang('en_US'); // To change default language of $langs diff --git a/dev/examples/zapier/package.json b/dev/examples/zapier/package.json index 8852928771f..ef70b2af8fd 100644 --- a/dev/examples/zapier/package.json +++ b/dev/examples/zapier/package.json @@ -15,7 +15,7 @@ "npm": ">=5.6.0" }, "dependencies": { - "zapier-platform-core": "11.3.1" + "zapier-platform-core": "15.0.1" }, "devDependencies": { "mocha": "^5.2.0", diff --git a/dev/initdemo/mysqldump_dolibarr_3.5.0.sql b/dev/initdemo/mysqldump_dolibarr_3.5.0.sql index 64eead005ed..c6d16c22e45 100644 --- a/dev/initdemo/mysqldump_dolibarr_3.5.0.sql +++ b/dev/initdemo/mysqldump_dolibarr_3.5.0.sql @@ -4655,75 +4655,6 @@ INSERT INTO `llx_menu` VALUES (19289,'all',1,'cashdesk','top','cashdesk',0,NULL, /*!40000 ALTER TABLE `llx_menu` ENABLE KEYS */; UNLOCK TABLES; --- --- Table structure for table `llx_milestone` --- - -DROP TABLE IF EXISTS `llx_milestone`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `llx_milestone` ( - `rowid` int(11) NOT NULL AUTO_INCREMENT, - `fk_element` int(11) NOT NULL, - `elementtype` varchar(16) NOT NULL, - `label` varchar(255) NOT NULL, - `options` varchar(255) DEFAULT NULL, - `priority` int(11) DEFAULT '0', - `tms` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `fk_user_modif` int(11) DEFAULT NULL, - PRIMARY KEY (`rowid`), - UNIQUE KEY `uk_milestone_fk_element` (`fk_element`,`elementtype`), - KEY `idx_milestone_fk_user_modif` (`fk_user_modif`), - CONSTRAINT `fk_milestone_fk_user_modif` FOREIGN KEY (`fk_user_modif`) REFERENCES `llx_user` (`rowid`) -) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `llx_milestone` --- - -LOCK TABLES `llx_milestone` WRITE; -/*!40000 ALTER TABLE `llx_milestone` DISABLE KEYS */; -INSERT INTO `llx_milestone` VALUES (2,779,'facture','azerty',NULL,0,'2013-03-09 12:19:30',NULL),(3,780,'facture','fsdf',NULL,0,'2013-03-09 13:01:08',NULL),(4,781,'facture','hhh',NULL,0,'2013-03-09 14:06:37',NULL); -/*!40000 ALTER TABLE `llx_milestone` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `llx_monitoring_probes` --- - -DROP TABLE IF EXISTS `llx_monitoring_probes`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `llx_monitoring_probes` ( - `rowid` int(11) NOT NULL AUTO_INCREMENT, - `title` varchar(64) NOT NULL, - `groupname` varchar(64) DEFAULT NULL, - `url` varchar(250) NOT NULL, - `useproxy` int(11) DEFAULT '0', - `checkkey` varchar(250) DEFAULT NULL, - `maxval` int(11) DEFAULT NULL, - `frequency` int(11) DEFAULT '60', - `active` int(11) DEFAULT '1', - `status` int(11) DEFAULT '0', - `lastreset` datetime DEFAULT NULL, - `oldesterrortext` text, - `oldesterrordate` datetime DEFAULT NULL, - PRIMARY KEY (`rowid`), - UNIQUE KEY `uk_monitoring_probes` (`title`) -) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `llx_monitoring_probes` --- - -LOCK TABLES `llx_monitoring_probes` WRITE; -/*!40000 ALTER TABLE `llx_monitoring_probes` DISABLE KEYS */; -INSERT INTO `llx_monitoring_probes` VALUES (1,'aaa',NULL,'http://www.chiensderace.com',0,'chiens',1000,10,1,1,'2011-04-20 23:46:41',NULL,NULL),(2,'ChatsDeRace',NULL,'http://www.chatsderace.com',0,'chats',1000,5,1,1,'2011-04-20 23:46:41',NULL,NULL); -/*!40000 ALTER TABLE `llx_monitoring_probes` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `llx_notify` -- diff --git a/dev/setup/fail2ban/filter.d/web-accesslog-limit403.conf b/dev/setup/fail2ban/filter.d/web-accesslog-limit403.conf index 1356df80115..43163cf5d9a 100644 --- a/dev/setup/fail2ban/filter.d/web-accesslog-limit403.conf +++ b/dev/setup/fail2ban/filter.d/web-accesslog-limit403.conf @@ -13,7 +13,7 @@ # 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 +# fail2ban-regex /var/log/apache2/access.log /etc/fail2ban/filter.d/web-accesslog-limit403.conf --print-all-matched failregex = - - .*HTTP/[0-9]+(.[0-9]+)?" 403 ignoreregex = diff --git a/dev/setup/fail2ban/filter.d/web-dolibarr-limitpublic.conf b/dev/setup/fail2ban/filter.d/web-dolibarr-limitpublic.conf index 2eedad18821..13d2b99d095 100644 --- a/dev/setup/fail2ban/filter.d/web-dolibarr-limitpublic.conf +++ b/dev/setup/fail2ban/filter.d/web-dolibarr-limitpublic.conf @@ -13,7 +13,7 @@ # fail2ban-client status web-dolibarr-limitpublic # # To test rule file on a existing log file -# fail2ban-regex /mypath/documents/dolibarr.log /etc/fail2ban/filter.d/web-dolibarr-limitpublic.conf +# fail2ban-regex /mypath/documents/dolibarr.log /etc/fail2ban/filter.d/web-dolibarr-limitpublic.conf --print-all-matched failregex = ^ [A-Z\s]+ \s+--- Access to .*/public/ ignoreregex = diff --git a/dev/setup/fail2ban/filter.d/web-dolibarr-rulesbruteforce.conf b/dev/setup/fail2ban/filter.d/web-dolibarr-rulesbruteforce.conf index dd6694c1a6f..79ca5c2fb95 100644 --- a/dev/setup/fail2ban/filter.d/web-dolibarr-rulesbruteforce.conf +++ b/dev/setup/fail2ban/filter.d/web-dolibarr-rulesbruteforce.conf @@ -13,7 +13,7 @@ # fail2ban-client status web-dolibarr-rulesbruteforce # # To test rule file on a existing log file -# fail2ban-regex /mypath/documents/dolibarr.log /etc/fail2ban/filter.d/web-dolibarr-rulesbruteforce.conf +# fail2ban-regex /mypath/documents/dolibarr.log /etc/fail2ban/filter.d/web-dolibarr-rulesbruteforce.conf --print-all-matched failregex = ^ [A-Z\s]+ \s+functions_.*::check_user_.* Authentication KO ignoreregex = diff --git a/dev/setup/fail2ban/filter.d/web-dolibarr-rulespassforgotten.conf b/dev/setup/fail2ban/filter.d/web-dolibarr-rulespassforgotten.conf index 8cc20dd4be4..0316a7e7774 100644 --- a/dev/setup/fail2ban/filter.d/web-dolibarr-rulespassforgotten.conf +++ b/dev/setup/fail2ban/filter.d/web-dolibarr-rulespassforgotten.conf @@ -13,7 +13,7 @@ # fail2ban-client status web-dolibarr-rulespassforgotten # # To test rule file on a existing log file -# fail2ban-regex /mypath/documents/dolibarr.log /etc/fail2ban/filter.d/web-dolibarr-rulespassforgotten.conf +# fail2ban-regex /mypath/documents/dolibarr.log /etc/fail2ban/filter.d/web-dolibarr-rulespassforgotten.conf --print-all-matched failregex = ^ [A-Z\s]+ \s+--- Access to .*/passwordforgotten.php - action=buildnewpassword ignoreregex = diff --git a/dev/setup/qodana/README.md b/dev/setup/qodana/README.md index 37b465cabc9..aa7ce3013d5 100644 --- a/dev/setup/qodana/README.md +++ b/dev/setup/qodana/README.md @@ -3,10 +3,10 @@ QODANA TUTO This README explains how to use qodana to generate static analytics reports on the code Install docker + apt install docker - -Install qodana - +Install qodana into ~/.loca/bin/qodana + curl -fsSL https://jb.gg/qodana-cli/install | bash To run inspection on CLI cd ~/git/dirtoscan diff --git a/dev/setup/sonarqube/README.md b/dev/setup/sonarqube/README.md new file mode 100644 index 00000000000..efb98f337a3 --- /dev/null +++ b/dev/setup/sonarqube/README.md @@ -0,0 +1,15 @@ += Install SonarQube locally + +Check you are using Install Java SDK 17 +java --version must show 61 + +To install java sdk 17 on ubuntu: +sudo apt update +sudo apt install -y openjdk-17-jdk + +Unzip the sonar package into a directory + +Edit the file conf/sonar.properties to modify port 9000 and 9001 (already used by Eclipse or xdebug) into 9080 and 9081 + +Launch sonar with +bin/linux*/sonar.sh console diff --git a/dev/tools/apstats.php b/dev/tools/apstats.php new file mode 100755 index 00000000000..0f0895a3ecc --- /dev/null +++ b/dev/tools/apstats.php @@ -0,0 +1,426 @@ +#!/usr/bin/env php + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file dev/tools/apstats.php + * \brief Script to report Advanced Statistics on a coding project + */ + + +$sapi_type = php_sapi_name(); +$script_file = basename(__FILE__); +$path = dirname(__FILE__) . '/'; + +// Test si mode batch +$sapi_type = php_sapi_name(); +if (substr($sapi_type, 0, 3) == 'cgi') { + echo "Error: You are using PHP for CGI. To execute " . $script_file . " from command line, you must use PHP for CLI mode.\n"; + exit(); +} + +error_reporting(E_ALL & ~ E_DEPRECATED); +define('PRODUCT', "apstats"); +define('VERSION', "1.0"); + + +print '***** '.constant('PRODUCT').' - '.constant('VERSION').' *****'."\n"; +if (empty($argv[1])) { + print 'You must run this tool being into the root of the project.'."\n"; + print 'Usage: '.constant('PRODUCT').'.php pathto/outputfile.html [--dir-scc=pathtoscc] [--dir-phpstan=pathtophpstan]'."\n"; + print 'Example: '.constant('PRODUCT').'.php documents/apstats/index.html --dir-scc=/snap/bin --dir-phpstan=~/git/phpstan/htdocs/includes/bin'; + exit(0); +} + +$outputpath = $argv[1]; +$outputdir = dirname($outputpath); +$outputfile = basename($outputpath); + +if (! is_dir($outputdir)) { + print 'Error: dir '.$outputdir.' does not exists or is not writable'."\n"; + exit(1); +} + +$dirscc = ''; +$dirphpstan = ''; + +$i = 0; +while ($i < $argc) { + $reg = array(); + if (preg_match('/--dir-scc=(.*)$/', $argv[$i], $reg)) { + $dirscc = $reg[1]; + } + if (preg_match('/--dir-phpstan=(.*)$/', $argv[$i], $reg)) { + $dirphpstan = $reg[1]; + } + $i++; +} + + +// Count lines of code of Dolibarr itself +/* +$commandcheck = 'cloc . --exclude-dir=includes --exclude-dir=custom --ignore-whitespace --vcs=git'; +$resexec = shell_exec($commandcheck); +$resexec = (int) (empty($resexec) ? 0 : trim($resexec)); + + +// Count lines of code of external dependencies +$commandcheck = 'cloc htdocs/includes --ignore-whitespace --vcs=git'; +$resexec = shell_exec($commandcheck); +$resexec = (int) (empty($resexec) ? 0 : trim($resexec)); +*/ + +// Count lines of code of application +$commandcheck = ($dirscc ? $dirscc.'/' : '').'scc . --exclude-dir=includes,custom'; +print 'Execute SCC to count lines of code in project: '.$commandcheck."\n"; +$output_arrproj = array(); +$resexecproj = 0; +exec($commandcheck, $output_arrproj, $resexecproj); + + +// Count lines of code of dependencies +$commandcheck = ($dirscc ? $dirscc.'/' : '').'scc htdocs/includes'; +print 'Execute SCC to count lines of code in dependencies: '.$commandcheck."\n"; +$output_arrdep = array(); +$resexecdep = 0; +exec($commandcheck, $output_arrdep, $resexecdep); + + +// Get technical debt +$commandcheck = ($dirphpstan ? $dirphpstan.'/' : '').'phpstan -v analyze -a build/phpstan/bootstrap.php --memory-limit 5G --error-format=github'; +print 'Execute PHPStan to get the technical debt: '.$commandcheck."\n"; +$output_arrtd = array(); +$resexectd = 0; +exec($commandcheck, $output_arrtd, $resexectd); + +$arrayoflineofcode = array(); +$arraycocomo = array(); +$arrayofmetrics = array( + 'proj'=>array('Bytes'=>0, 'Files'=>0, 'Lines'=>0, 'Blanks'=>0, 'Comments'=>0, 'Code'=>0, 'Complexity'=>0), + 'dep'=>array('Bytes'=>0, 'Files'=>0, 'Lines'=>0, 'Blanks'=>0, 'Comments'=>0, 'Code'=>0, 'Complexity'=>0) +); + +// Analyse $output_arrproj +foreach (array('proj', 'dep') as $source) { + print 'Analyze SCC result for lines of code for '.$source."\n"; + if ($source == 'proj') { + $output_arr = &$output_arrproj; + } elseif ($source == 'dep') { + $output_arr = &$output_arrdep; + } else { + print 'Bad value for $source'; + die(); + } + + foreach ($output_arr as $line) { + if (preg_match('/^(───|Language|Total)/', $line)) { + continue; + } + + //print $line."
\n"; + + if (preg_match('/^Estimated Cost.*\$(.*)/i', $line, $reg)) { + $arraycocomo[$source]['currency'] = preg_replace('/[^\d\.]/', '', str_replace(array(',', ' '), array('', ''), $reg[1])); + } + if (preg_match('/^Estimated Schedule Effort.*\s([\d\s,]+)/i', $line, $reg)) { + $arraycocomo[$source]['effort'] = str_replace(array(',', ' '), array('.', ''), $reg[1]); + } + if (preg_match('/^Estimated People.*\s([\d\s,]+)/i', $line, $reg)) { + $arraycocomo[$source]['people'] = str_replace(array(',', ' '), array('.', ''), $reg[1]); + } + if (preg_match('/^Processed\s(\d+)\s/i', $line, $reg)) { + $arrayofmetrics[$source]['Bytes'] = $reg[1]; + } + + if (preg_match('/^(.*)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)$/', $line, $reg)) { + $arrayoflineofcode[$source][$reg[1]]['Files'] = $reg[2]; + $arrayoflineofcode[$source][$reg[1]]['Lines'] = $reg[3]; + $arrayoflineofcode[$source][$reg[1]]['Blanks'] = $reg[4]; + $arrayoflineofcode[$source][$reg[1]]['Comments'] = $reg[5]; + $arrayoflineofcode[$source][$reg[1]]['Code'] = $reg[6]; + $arrayoflineofcode[$source][$reg[1]]['Complexity'] = $reg[7]; + } + } + + if (!empty($arrayoflineofcode[$source])) { + foreach ($arrayoflineofcode[$source] as $key => $val) { + $arrayofmetrics[$source]['Files'] += $val['Files']; + $arrayofmetrics[$source]['Lines'] += $val['Lines']; + $arrayofmetrics[$source]['Blanks'] += $val['Blanks']; + $arrayofmetrics[$source]['Comments'] += $val['Comments']; + $arrayofmetrics[$source]['Code'] += $val['Code']; + $arrayofmetrics[$source]['Complexity'] += $val['Complexity']; + } + } +} + + +/* + * View + */ + +$html = ''."\n"; +$html .= ''."\n"; +$html .= ''."\n"; +$html .= ''."\n"; +$html .= ''."\n"; +$html .= ' +'."\n"; + +$html .= ''."\n"; + +$html .= '
'."\n"; +$html .= '

Advanced Project Statistics

'."\n"; +$currentDate = date("Y-m-d H:i:s"); // Format: Year-Month-Day Hour:Minute:Second +$html .= 'Generated on '.$currentDate.''."\n"; +$html .= '
'."\n"; + +$html .= '
'."\n"; +$html .= '

Lines of code

'."\n"; + +$html .= '
'."\n"; +$html .= ''; +$html .= ''; +$html .= ''; +$html .= ''; +$html .= ''; +$html .= ''; +$html .= ''; +$html .= ''; +//$html .= ''; +$html .= ''; +foreach (array('proj', 'dep') as $source) { + $html .= ''; + if ($source == 'proj') { + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + if (!empty($arrayoflineofcode[$source])) { + foreach ($arrayoflineofcode[$source] as $key => $val) { + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + //$html .= ''; + $html .= ''; + $html .= ''; + } + } +} + +$html .= ''; +$html .= ''; +$html .= ''; +$html .= ''; +$html .= ''; +$html .= ''; +$html .= ''; +$html .= ''; +//$html .= ''; +$html .= ''; +$html .= ''; +$html .= '
Language'; +$html .= 'BytesFilesLinesBlanksCommentsCode'.$val['Complexity'].'
All files from project only'; + } elseif ($source == 'dep') { + $html .= 'All files from dependencies'; + } + $html .= '     (See detail per file type...)'; + $html .= ''.formatNumber($arrayofmetrics[$source]['Bytes']).''.formatNumber($arrayofmetrics[$source]['Files']).''.formatNumber($arrayofmetrics[$source]['Lines']).''.formatNumber($arrayofmetrics[$source]['Blanks']).''.formatNumber($arrayofmetrics[$source]['Comments']).''.formatNumber($arrayofmetrics[$source]['Code']).'
Total'.formatNumber($arrayofmetrics['proj']['Bytes'] + $arrayofmetrics['dep']['Bytes']).''.formatNumber($arrayofmetrics['proj']['Files'] + $arrayofmetrics['dep']['Files']).''.formatNumber($arrayofmetrics['proj']['Lines'] + $arrayofmetrics['dep']['Lines']).''.formatNumber($arrayofmetrics['proj']['Blanks'] + $arrayofmetrics['dep']['Blanks']).''.formatNumber($arrayofmetrics['proj']['Comments'] + $arrayofmetrics['dep']['Comments']).''.formatNumber($arrayofmetrics['proj']['Code'] + $arrayofmetrics['dep']['Code']).''.$arrayofmetrics['Complexity'].'
'; +$html .= '
'; + +$html .= '
'."\n"; + +$html .= '
'."\n"; +$html .= '

Project value


'."\n"; +$html .= '
'; +$html .= 'COCOMO (Basic organic model) value:
'; +$html .= '$'.formatNumber((empty($arraycocomo['proj']['currency']) ? 0 : $arraycocomo['proj']['currency']) + (empty($arraycocomo['dep']['currency']) ? 0 : $arraycocomo['dep']['currency']), 2).''; +$html .= '
'; +$html .= '
'; +$html .= 'COCOMO (Basic organic model) effort
'; +$html .= ''.formatNumber($arraycocomo['proj']['people'] * $arraycocomo['proj']['effort'] + $arraycocomo['dep']['people'] * $arraycocomo['dep']['effort']); +$html .= ' monthes people
'; +$html .= '
'."\n"; + +$html .= '
'."\n"; +$html .= '

Technical debt ('.count($output_arrtd).')


'."\n"; +$html .= '
'."\n"; +$html .= ''."\n"; +$html .= ''."\n"; +foreach ($output_arrtd as $line) { + $reg = array(); + //print $line."\n"; + preg_match('/^::error file=(.*),line=(\d+),col=(\d+)::(.*)$/', $line, $reg); + if (!empty($reg[1])) { + $html .= ''."\n"; + } +} +$html .= '
FileLineType
'.$reg[1].''.$reg[2].''.$reg[4].'
'; +$html .= '
'; +$html .= '
'."\n"; + +$html .= ' + +'; +$html .= ''; +$html .= ''; + +$fh = fopen($outputpath, 'w'); +if ($fh) { + fwrite($fh, $html); + fclose($fh); + + print 'Generation of output file '.$outputfile.' done.'."\n"; +} else { + print 'Failed to open '.$outputfile.' for ouput.'."\n"; +} + + +/** + * function to format a number + * + * @param string|int $number Number to format + * @param int $nbdec Number of decimal digits + * @return string Formated string + */ +function formatNumber($number, $nbdec = 0) +{ + return number_format($number, 0, '.', ' '); +} diff --git a/dev/tools/fixdosfiles.sh b/dev/tools/fixdosfiles.sh index e5e5d97b554..52db065db03 100755 --- a/dev/tools/fixdosfiles.sh +++ b/dev/tools/fixdosfiles.sh @@ -10,21 +10,21 @@ # Syntax if [ "x$1" != "xlist" -a "x$1" != "xfix" ] then - echo "This script detect or clean files with CR+LF into files with LF only. All source files are included, also files into includes." + echo "This script detect or clean files with CR+LF into files with LF only. All source files are included, including files into includes." echo "Usage: fixdosfiles.sh [list|fix]" fi # To detec if [ "x$1" = "xlist" ] then - find . \( -iname "functions" -o -iname "*.md" -o -iname "*.html" -o -iname "*.htm" -o -iname "*.php" -o -iname "*.sh" -o -iname "*.cml" -o -iname "*.css" -o -iname "*.js" -o -iname "*.lang" -o -iname "*.pl" -o -iname "*.sql" -o -iname "*.txt" -o -iname "*.xml" -o -iname "*.pml" \) -exec file "{}" + | grep -v "CRLF" | grep -v 'custom\/' | grep -v 'documents\/website' | grep -v 'documents\/medias' | grep -v 'documents\/sellyoursaas' | grep CRLF + find . \( -iname "functions" -o -iname "*.md" -o -iname "*.html" -o -iname "*.htm" -o -iname "*.php" -o -iname "*.sh" -o -iname "*.cml" -o -iname "*.css" -o -iname "*.js" -o -iname "*.lang" -o -iname "*.pl" -o -iname "*.sql" -o -iname "*.txt" -o -iname "*.xml" -o -iname "*.pml" \) -exec file "{}" + | grep -v 'custom\/' | grep -v 'documents\/website' | grep -v 'documents\/medias' | grep -v 'documents\/sellyoursaas' | grep CRLF # find . \( -iname "*.md" -o -iname "*.html" -o -iname "*.htm" -o -iname "*.php" -o -iname "*.sh" -o -iname "*.cml" -o -iname "*.css" -o -iname "*.js" -o -iname "*.lang" -o -iname "*.pl" -o -iname "*.sql" -o -iname "*.txt" -o -iname "*.xml" \) -exec file "{}" + | grep -v "CRLF" | grep -v 'custom\/' | grep -v 'documents\/website' | grep -v 'documents\/medias' | grep -v 'documents\/sellyoursaas' | grep -v 'htdocs\/includes' | grep CRLF fi # To convert if [ "x$1" = "xfix" ] then - for fic in `find . \( -iname "functions" -o -iname "*.md" -o -iname "*.html" -o -iname "*.htm" -o -iname "*.php" -o -iname "*.sh" -o -iname "*.cml" -o -iname "*.css" -o -iname "*.js" -o -iname "*.lang" -o -iname "*.pl" -o -iname "*.sql" -o -iname "*.txt" -o -iname "*.xml" -o -iname "*.pml" \) -exec file "{}" + | grep -v "CRLF" | grep -v 'custom\/' | grep -v 'documents\/website' | grep -v 'documents\/medias' | grep -v 'documents\/sellyoursaas' | grep CRLF | awk -F':' '{ print $1 }' ` + for fic in `find . \( -iname "functions" -o -iname "*.md" -o -iname "*.html" -o -iname "*.htm" -o -iname "*.php" -o -iname "*.sh" -o -iname "*.cml" -o -iname "*.css" -o -iname "*.js" -o -iname "*.lang" -o -iname "*.pl" -o -iname "*.sql" -o -iname "*.txt" -o -iname "*.xml" -o -iname "*.pml" \) -exec file "{}" + | grep -v 'custom\/' | grep -v 'documents\/website' | grep -v 'documents\/medias' | grep -v 'documents\/sellyoursaas' | grep CRLF | awk -F':' '{ print $1 }' ` do echo "Fix file $fic" dos2unix "$fic" diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 9c15535d0c8..9bb31534dca 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2020 Alexandre Spangaro + * Copyright (C) 2013-2023 Alexandre Spangaro * Copyright (C) 2016-2018 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify @@ -142,10 +142,13 @@ if (empty($reshook)) { $search_labelshort = ""; $search_accountparent = ""; $search_pcgtype = ""; + $search_import_key = ""; $search_array_options = array(); } if ((GETPOST('valid_change_chart', 'alpha') && GETPOST('chartofaccounts', 'int') > 0) // explicit click on button 'Change and load' with js on || (GETPOST('chartofaccounts', 'int') > 0 && GETPOST('chartofaccounts', 'int') != getDolGlobalInt('CHARTOFACCOUNTS'))) { // a submit of form is done and chartofaccounts combo has been modified + $error = 0; + if ($chartofaccounts > 0 && $permissiontoadd) { // Get language code for this $chartofaccounts $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_country as c, '.MAIN_DB_PREFIX.'accounting_system as a'; @@ -153,7 +156,9 @@ if (empty($reshook)) { $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); - $country_code = $obj->code; + if ($obj) { + $country_code = $obj->code; + } } else { dol_print_error($db); } @@ -216,14 +221,13 @@ if (empty($reshook)) { /* * View */ - $form = new Form($db); $formaccounting = new FormAccounting($db); llxHeader('', $langs->trans("ListAccounts")); if ($action == 'delete') { - $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1); print $formconfirm; } @@ -232,11 +236,24 @@ $pcgver = getDolGlobalInt('CHARTOFACCOUNTS'); $sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.account_number, aa.account_parent, aa.label, aa.labelshort, aa.fk_accounting_category,"; $sql .= " aa.reconcilable, aa.active, aa.import_key,"; $sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2"; + +// Add fields from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/,\s*$/', '', $sql); + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = ".((int) $conf->entity); $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".((int) $conf->entity); + +// Add table from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; + $sql .= " WHERE asy.rowid = ".((int) $pcgver); -//print $sql; + if (strlen(trim($search_account))) { $lengthpaddingaccount = 0; if (getDolGlobalInt('ACCOUNTING_LENGTH_GACCOUNT') || getDolGlobalInt('ACCOUNTING_LENGTH_AACCOUNT')) { @@ -259,7 +276,7 @@ if (strlen(trim($search_account))) { $search_account_tmp_clean = $search_account_tmp; $search_account_clean = $search_account; $startchar = '%'; - if (strpos($search_account_tmp, '^') === 0) { + if (substr($search_account_tmp, 0, 1) === '^') { $startchar = ''; $search_account_tmp_clean = preg_replace('/^\^/', '', $search_account_tmp); $search_account_clean = preg_replace('/^\^/', '', $search_account); @@ -283,6 +300,15 @@ if (strlen(trim($search_accountparent)) && $search_accountparent != '-1') { if (strlen(trim($search_pcgtype))) { $sql .= natural_search("aa.pcg_type", $search_pcgtype); } +if (strlen(trim($search_import_key))) { + $sql .= natural_search("aa.import_key", $search_import_key); +} + +// Add where from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; + $sql .= $db->order($sortfield, $sortorder); //print $sql; @@ -297,16 +323,6 @@ if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { } } -// List of mass actions available -if ($user->hasRight('accounting', 'chartofaccount')) { - $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); -} -if (in_array($massaction, array('presend', 'predelete', 'closed'))) { - $arrayofmassactions = array(); -} - -$massactionbutton = $form->selectMassAction('', $arrayofmassactions); -$arrayofselected = is_array($toselect) ? $toselect : array(); $sql .= $db->plimit($limit + 1, $offset); dol_syslog('accountancy/admin/account.php:: $sql='.$sql); @@ -315,6 +331,8 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); + $arrayofselected = is_array($toselect) ? $toselect : array(); + $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); @@ -337,13 +355,18 @@ if ($resql) { if ($search_pcgtype) { $param .= '&search_pcgtype='.urlencode($search_pcgtype); } - if ($optioncss != '') { + if ($search_import_key) { $param .= '&search_import_key='.urlencode($search_import_key); } if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } + // Add $param from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $param .= $hookmanager->resPrint; + if (!empty($conf->use_javascript_ajax)) { print ' '; } + // List of mass actions available + if ($user->hasRight('accounting', 'chartofaccount')) { + $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); + } + if (in_array($massaction, array('presend', 'predelete', 'closed'))) { + $arrayofmassactions = array(); + } + + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); + $newcardbutton = ''; + $newcardbutton = dolGetButtonTitle($langs->trans('Addanaccount'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/accountancy/admin/card.php?action=create', '', $permissiontoadd); + print '
'; if ($optioncss != '') { @@ -370,10 +405,10 @@ if ($resql) { print ''; print ''; - $newcardbutton .= dolGetButtonTitle($langs->trans("New"), $langs->trans("Addanaccount"), 'fa fa-plus-circle', './card.php?action=create'); - include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'accounting_account', 0, $newcardbutton, '', $limit, 0, 0, 1); + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + // Box to select active chart of account print $langs->trans("Selectchartofaccounts")." : "; print ''; } - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { + if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { if (!empty($arrayfields['aa.reconcilable']['checked'])) { print ' '; } @@ -471,52 +519,77 @@ if ($resql) { } // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; + print ''; $searchpicto = $form->showFilterButtons(); print $searchpicto; print ''; } - print ''; + print ''."\n"; + + $totalarray = array(); + $totalarray['nbfield'] = 0; + + // Fields title label + // -------------------------------------------------------------------- print ''; // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn '); + $totalarray['nbfield']++; } if (!empty($arrayfields['aa.account_number']['checked'])) { print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['aa.label']['checked'])) { print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"], "aa.label", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['aa.labelshort']['checked'])) { print_liste_field_titre($arrayfields['aa.labelshort']['label'], $_SERVER["PHP_SELF"], "aa.labelshort", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['aa.account_parent']['checked'])) { print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, '', $sortfield, $sortorder, 'left '); + $totalarray['nbfield']++; } 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); + $totalarray['nbfield']++; } if (!empty($arrayfields['categories']['checked'])) { print_liste_field_titre($arrayfields['categories']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, '', $arrayfields['categories']['help'], 1); + $totalarray['nbfield']++; } + + // Hook fields + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + 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); + $totalarray['nbfield']++; } - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { + if (getDolGlobalInt('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); + $totalarray['nbfield']++; } } if (!empty($arrayfields['aa.active']['checked'])) { print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; } // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); + $totalarray['nbfield']++; } print "\n"; + // Loop on record + // -------------------------------------------------------------------- $i = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -630,6 +703,11 @@ if ($resql) { } } + // 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; + // Import id if (!empty($arrayfields['aa.import_key']['checked'])) { print ""; @@ -640,8 +718,8 @@ if ($resql) { } } - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - // Activated or not reconciliation on accounting account + if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { + // Activated or not reconciliation on an accounting account if (!empty($arrayfields['aa.reconcilable']['checked'])) { print ''; if (empty($obj->reconcilable)) { @@ -718,9 +796,16 @@ if ($resql) { print ''.$langs->trans("None").''; } - print ""; - print ""; - print '
'; + $db->free($resql); + + $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); + $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + print ''."\n"; + print ''."\n"; + + print ''."\n"; } else { dol_print_error($db); } diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index f2a7842dbbb..f88d48961a5 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -296,11 +296,6 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { setEventMessages($db->error(), null, 'errors'); } } - //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition -} - -if (GETPOST('actioncancel', 'alpha')) { - //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition } if ($action == 'confirm_delete' && $confirm == 'yes') { // delete diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index f9ad413feb2..3a7f743059d 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -88,14 +88,14 @@ $list_account[] = 'ACCOUNTING_VAT_BUY_ACCOUNT'; $list_account[] = 'ACCOUNTING_VAT_PAY_ACCOUNT'; -if (!empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) { +if (getDolGlobalString('ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) { $list_account[] = 'ACCOUNTING_VAT_BUY_REVERSE_CHARGES_CREDIT'; $list_account[] = 'ACCOUNTING_VAT_BUY_REVERSE_CHARGES_DEBIT'; } if (isModEnabled('banque')) { $list_account[] = 'ACCOUNTING_ACCOUNT_TRANSFER_CASH'; } -if (!empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) { +if (getDolGlobalString('INVOICE_USE_RETAINED_WARRANTY')) { $list_account[] = 'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY'; } if (isModEnabled('don')) { diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index 30cc0144a1f..70dd216b7c9 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -152,7 +152,7 @@ foreach ($listparam as $key => $param) { print ' {'."\n"; print ' //console.log("'.$param['label'].'");'."\n"; if (empty($param['ACCOUNTING_EXPORT_FORMAT'])) { - print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$conf->global->ACCOUNTING_EXPORT_FORMAT.'");'."\n"; + print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.getDolGlobalString('ACCOUNTING_EXPORT_FORMAT').'");'."\n"; print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").prop("disabled", true);'."\n"; } else { print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$param['ACCOUNTING_EXPORT_FORMAT'].'");'."\n"; @@ -162,7 +162,7 @@ foreach ($listparam as $key => $param) { print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("");'."\n"; print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").prop("disabled", true);'."\n"; } else { - print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("'.$conf->global->ACCOUNTING_EXPORT_SEPARATORCSV.'");'."\n"; + print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("'.getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV').'");'."\n"; print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").removeAttr("disabled");'."\n"; } if (empty($param['ACCOUNTING_EXPORT_ENDLINE'])) { @@ -174,7 +174,7 @@ foreach ($listparam as $key => $param) { print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("");'."\n"; print ' jQuery("#ACCOUNTING_EXPORT_DATE").prop("disabled", true);'."\n"; } else { - print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("'.$conf->global->ACCOUNTING_EXPORT_DATE.'");'."\n"; + print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("'.getDolGlobalString('ACCOUNTING_EXPORT_DATE').'");'."\n"; print ' jQuery("#ACCOUNTING_EXPORT_DATE").removeAttr("disabled");'."\n"; } print ' }'."\n"; diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 3b6f12566fe..508a4167195 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -45,6 +45,8 @@ if (!$user->hasRight('accounting', 'chartofaccount')) { $action = GETPOST('action', 'aZ09'); +$nbletter = GETPOST('ACCOUNTING_LETTERING_NBLETTERS', 'int'); + // Parameters ACCOUNTING_* and others $list = array( 'ACCOUNTING_LENGTH_GACCOUNT', @@ -56,7 +58,8 @@ $list = array( $list_binding = array( 'ACCOUNTING_DATE_START_BINDING', - 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER' + 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER', + 'ACCOUNTING_LETTERING_NBLETTERS' ); $error = 0; @@ -271,19 +274,19 @@ print load_fiche_titre($title, $linkback, 'accountancy'); // Show message if accountancy hidden options are activated to help to resolve some problems if (!$user->admin) { - if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) { print '
' . $langs->trans("ConstantIsOn", "FACTURE_DEPOSITS_ARE_JUST_PAYMENTS") . '
'; } - if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) { + if (getDolGlobalString('FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS')) { print '
' . $langs->trans("ConstantIsOn", "FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS") . '
'; } - if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) { + if (getDolGlobalString('ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY')) { print '
' . $langs->trans("ConstantIsOn", "ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY") . '
'; } - if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { + if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) { print '
' . $langs->trans("ConstantIsOn", "MAIN_COMPANY_PERENTITY_SHARED") . '
'; } - if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) { print '
' . $langs->trans("ConstantIsOn", "MAIN_PRODUCT_PERENTITY_SHARED") . '
'; } } @@ -303,7 +306,7 @@ print "\n"; /* Set this option as a hidden option but keep it for some needs. print ''; print ''.$langs->trans("ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL").''; -if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) { +if (getDolGlobalString('ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL')) { print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; @@ -317,7 +320,7 @@ print ''; print ''; print ''.$langs->trans("BANK_DISABLE_DIRECT_INPUT").''; -if (!empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { +if (getDolGlobalString('BANK_DISABLE_DIRECT_INPUT')) { print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; @@ -333,7 +336,7 @@ print ''.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX"); print ' - '.$langs->trans("NotRecommended").''; print ''; -if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { +if (getDolGlobalString('ACCOUNTANCY_COMBO_FOR_AUX')) { print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; @@ -346,7 +349,7 @@ print ''; print ''; print ''.$langs->trans("ACCOUNTING_MANAGE_ZERO").''; -if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO)) { +if (getDolGlobalInt('ACCOUNTING_MANAGE_ZERO')) { print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; @@ -408,7 +411,7 @@ foreach ($list_binding as $key) { print ''; print ''.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_SALES").''; -if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)) { +if (getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_SALES')) { print ''; print img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', 'warning'); print ''; @@ -421,7 +424,7 @@ print ''; print ''; print ''.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_PURCHASES").''; -if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)) { +if (getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_PURCHASES')) { print ''; print img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', 'warning'); print ''; @@ -434,7 +437,7 @@ print ''; print ''; print ''.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS").''; -if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) { +if (getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS')) { print ''; print img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', 'warning'); print ''; @@ -462,7 +465,7 @@ print "\n"; print ''; print ''; print $form->textwithpicto($langs->trans("ACCOUNTING_ENABLE_LETTERING"), $langs->trans("ACCOUNTING_ENABLE_LETTERING_DESC", $langs->transnoentitiesnoconv("NumMvts")).'
'.$langs->trans("EnablingThisFeatureIsNotNecessary")).''; -if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { +if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) { print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; @@ -473,11 +476,29 @@ if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { } print ''; -if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { +if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) { + // Number of letters for lettering (3 by default (AAA), min 2 (AA)) + print ''; + print ''; + print $form->textwithpicto($langs->trans("ACCOUNTING_LETTERING_NBLETTERS"), $langs->trans("ACCOUNTING_LETTERING_NBLETTERS_DESC")) . ''; + print ''; + + if (empty($letter)) { + if (getDolGlobalInt('ACCOUNTING_LETTERING_NBLETTERS')) { + $nbletter = getDolGlobalInt('ACCOUNTING_LETTERING_NBLETTERS'); + } else { + $nbletter = 3; + } + } + + print '' . "\n"; + print ''; + + // Auto Lettering when transfer in accountancy is realized print ''; print ''; print $form->textwithpicto($langs->trans("ACCOUNTING_ENABLE_AUTOLETTERING"), $langs->trans("ACCOUNTING_ENABLE_AUTOLETTERING_DESC")) . ''; - if (!empty($conf->global->ACCOUNTING_ENABLE_AUTOLETTERING)) { + if (getDolGlobalInt('ACCOUNTING_ENABLE_AUTOLETTERING')) { print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; @@ -492,7 +513,7 @@ if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { print ''; print ''; print $form->textwithpicto($langs->trans("ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE"), $langs->trans("ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE_DESC", $langs->transnoentities("MenuDefaultAccounts"))).''; -if (!empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) { +if (getDolGlobalString('ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) { print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index a524f29b840..18a85ca923c 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -85,7 +85,7 @@ if (empty($accounting_product_mode)) { $accounting_product_mode = 'ACCOUNTANCY_SELL'; } -$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : getDolGlobalInt('ACCOUNTING_LIMIT_LIST_VENTILATION', $conf->liste_limit); $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); @@ -199,7 +199,7 @@ if ($action == 'update') { $ko++; } else { $sql = ''; - if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) { $sql_exists = "SELECT rowid FROM " . MAIN_DB_PREFIX . "product_perentity"; $sql_exists .= " WHERE fk_product = " . ((int) $productid) . " AND entity = " . ((int) $conf->entity); $resql_exists = $db->query($sql_exists); @@ -309,7 +309,7 @@ if (empty($pcgvercode)) { } $sql = "SELECT p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy, p.tva_tx,"; -if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { +if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) { $sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export,"; $sql .= " ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export,"; } else { @@ -319,7 +319,7 @@ if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " p.tms, p.fk_product_type as product_type,"; $sql .= " aa.rowid as aaid"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; -if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { +if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = ppe." . $accountancy_field_name . " AND aa.fk_pcg_version = '" . $db->escape($pcgvercode) . "'"; } else { @@ -386,7 +386,7 @@ $sql .= " GROUP BY p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy, p. $sql .= " p.fk_product_type,"; $sql .= ' p.tms,'; $sql .= ' aa.rowid,'; -if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { +if (!getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) { $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export"; } else { $sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export, ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export"; @@ -534,7 +534,7 @@ if ($resql) { } // Show/hide child products. Hidden by default - if (isModEnabled('variants') && !empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) { + if (isModEnabled('variants') && getDolGlobalInt('PRODUIT_ATTRIBUTES_HIDECHILD')) { $moreforfilter .= '
'; $moreforfilter .= ''; $moreforfilter .= ' '; @@ -570,7 +570,7 @@ if ($resql) { print ''; print ''; - if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) { + if (getDolGlobalInt('ACCOUNTANCY_SHOW_PROD_DESC')) { print ''; } // On sell @@ -604,7 +604,7 @@ if ($resql) { } print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); - if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) { + if (getDolGlobalInt('ACCOUNTANCY_SHOW_PROD_DESC')) { print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder); } print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "p.tva_tx", "", $param, '', $sortfield, $sortorder, 'right '); @@ -641,30 +641,31 @@ if ($resql) { // Sales if ($obj->product_type == 0) { if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { - $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_ACCOUNT', $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_prodsell; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT', $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_prodsell_intra; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { - $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT', $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_prodsell_export; } else { - $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_ACCOUNT', $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_prodsell; } } else { if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { - $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell = getDolGlobalString('ACCOUNTING_SERVICE_SOLD_ACCOUNT', $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_servsell; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell = getDolGlobalString('ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT', $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_servsell_intra; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { - $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell = getDolGlobalString('ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT', $langs->trans("CodeNotDef")); + $compta_prodsell_id = $aarowid_servsell_export; } else { - $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell = getDolGlobalString('ACCOUNTING_SERVICE_SOLD_ACCOUNT', $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_servsell; } } @@ -672,30 +673,30 @@ if ($resql) { // Purchases if ($obj->product_type == 0) { if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy = getDolGlobalString('ACCOUNTING_PRODUCT_BUY_ACCOUNT', $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_prodbuy; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { - $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy = getDolGlobalString('ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT', $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_prodbuy_intra; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { - $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy = getDolGlobalString('ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT', $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_prodbuy_export; } else { - $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy = getDolGlobalString('ACCOUNTING_PRODUCT_BUY_ACCOUNT', $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_prodbuy; } } else { if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy = getDolGlobalString('ACCOUNTING_SERVICE_BUY_ACCOUNT', $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_servbuy; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { - $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy = getDolGlobalString('ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT', $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_servbuy_intra; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { - $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy = getDolGlobalString('ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT', $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_servbuy_export; } else { - $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy = getDolGlobalString('ACCOUNTING_SERVICE_BUY_ACCOUNT', $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_servbuy; } } @@ -722,11 +723,11 @@ if ($resql) { print ''.$obj->label.''; - if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) { + if (getDolGlobalInt('ACCOUNTANCY_SHOW_PROD_DESC')) { // TODO ADJUST DESCRIPTION SIZE // print '' . $obj->description . ''; // TODO: we should set a user defined value to adjust user square / wide screen size - $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; + $trunclength = getDolGlobalInt('ACCOUNTING_LENGTH_DESCRIPTION', 32); print ''.nl2br(dol_trunc($obj->description, $trunclength)).''; } diff --git a/htdocs/accountancy/admin/subaccount.php b/htdocs/accountancy/admin/subaccount.php index 568ce9f04ab..8c660feb769 100644 --- a/htdocs/accountancy/admin/subaccount.php +++ b/htdocs/accountancy/admin/subaccount.php @@ -355,7 +355,7 @@ if ($resql) { if (!empty($arrayfields['type']['checked'])) { print ''.$form->selectarray('search_type', array('1'=>$langs->trans('Customer'), '2'=>$langs->trans('Supplier'), '3'=>$langs->trans('Employee')), $search_type, 1).''; } - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { + if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { if (!empty($arrayfields['reconcilable']['checked'])) { print ' '; } @@ -383,7 +383,7 @@ if ($resql) { if (!empty($arrayfields['type']['checked'])) { print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "type", "", $param, '', $sortfield, $sortorder, 'center '); } - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { + if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { if (!empty($arrayfields['reconcilable']['checked'])) { print_liste_field_titre($arrayfields['reconcilable']['label'], $_SERVER["PHP_SELF"], 'reconcilable', '', $param, '', $sortfield, $sortorder, 'center '); } @@ -469,7 +469,7 @@ if ($resql) { } } - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { + if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { // Activated or not reconciliation on accounting account if (!empty($arrayfields['reconcilable']['checked'])) { print ''; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 53650a3cd28..994e7c7d15e 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -29,26 +29,30 @@ // Load Dolibarr environment require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php'; // Load translation files required by the page $langs->loadLangs(array("accountancy", "compta")); +// Get Parameters $socid = GETPOST('socid', 'int'); +// action+display Parameters $action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'bookkeepinglist'; + +// Search Parameters $search_mvt_num = GETPOST('search_mvt_num', 'int'); $search_doc_type = GETPOST("search_doc_type", 'alpha'); $search_doc_ref = GETPOST("search_doc_ref", 'alpha'); diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 80b74c41fdf..0010120d560 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2016-2017 Alexandre Spangaro - * Copyright (C) 2018-2019 Frédéric France + * Copyright (C) 2018-2023 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -123,11 +123,19 @@ class AccountancyCategory // extends CommonObject public $lines_display; /** - * @var mixed Sample property 1 + * @var mixed Sum debit credit */ public $sdc; + /** + * @var array Sum debit credit per month + */ + public $sdcpermonth; + /** + * @var array Sum debit credit per account + */ + public $sdcperaccount; /** * Constructor diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index c515b7230b2..318fc26c662 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -2477,7 +2477,7 @@ class AccountancyExport { $retVal = dol_string_nohtmltag($str, 1, 'Windows-1251'); if ($retVal >= 0 && $size >= 0) { - $retVal = mb_substr($retVal, 0, $size, 'Windows-1251'); + $retVal = dol_substr($retVal, 0, $size, 'Windows-1251'); } return $retVal; } diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php index 99f908e70e3..ddfa39c6309 100644 --- a/htdocs/accountancy/class/accountancysystem.class.php +++ b/htdocs/accountancy/class/accountancysystem.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2013-2014 Olivier Geffroy * Copyright (C) 2013-2014 Alexandre Spangaro * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2023 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -46,6 +47,13 @@ class AccountancySystem /** * @var int ID */ + public $id; + + /** + * @var int ID + * @deprecated + * @see $id + */ public $rowid; /** @@ -53,6 +61,21 @@ class AccountancySystem */ public $fk_pcg_version; + /** + * @var int pcg version + */ + public $pcg_version; + + /** + * @var string ref + */ + public $ref; + + /** + * @var int active + */ + public $active; + /** * @var string pcg type */ @@ -156,6 +179,7 @@ class AccountancySystem $id = $this->db->last_insert_id(MAIN_DB_PREFIX."accounting_system"); if ($id > 0) { + $this->id = $id; $this->rowid = $id; $result = $this->rowid; } else { diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index c541f28411e..a0cd11c3ec1 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -508,7 +508,7 @@ class AccountingAccount extends CommonObject // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { @@ -734,7 +734,7 @@ class AccountingAccount extends CommonObject * @param FactureLigne|SupplierInvoiceLine $factureDet Facture Det * @param array $accountingAccount Array of Accounting account * @param string $type Customer / Supplier - * @return array|int Accounting accounts suggested or < 0 if technical error. + * @return array|int Array of accounting accounts suggested or < 0 if technical error. * 'suggestedaccountingaccountbydefaultfor'=>Will be used for the label to show on tooltip for account by default on any product * 'suggestedaccountingaccountfor'=>Is the account suggested for this product */ @@ -770,39 +770,39 @@ class AccountingAccount extends CommonObject $suggestedaccountingaccountbydefaultfor = ''; if ($factureDet->product_type == 1) { if ($buyer->country_code == $seller->country_code || empty($buyer->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) - $code_l = (!empty($conf->global->{'ACCOUNTING_SERVICE_' . $const_name . '_ACCOUNT'}) ? $conf->global->{'ACCOUNTING_SERVICE_' . $const_name . '_ACCOUNT'} : ''); + $code_l = getDolGlobalString('ACCOUNTING_SERVICE_' . $const_name . '_ACCOUNT'); $suggestedaccountingaccountbydefaultfor = ''; } else { if ($isSellerInEEC && $isBuyerInEEC && $factureDet->tva_tx != 0) { // European intravat sale, but with a VAT - $code_l = (!empty($conf->global->{'ACCOUNTING_SERVICE_' . $const_name . '_ACCOUNT'}) ? $conf->global->{'ACCOUNTING_SERVICE_' . $const_name . '_ACCOUNT'} : ''); + $code_l = getDolGlobalString('ACCOUNTING_SERVICE_' . $const_name . '_ACCOUNT'); $suggestedaccountingaccountbydefaultfor = 'eecwithvat'; } elseif ($isSellerInEEC && $isBuyerInEEC && empty($buyer->tva_intra)) { // European intravat sale, without VAT intra community number - $code_l = (!empty($conf->global->{'ACCOUNTING_SERVICE_' . $const_name . '_ACCOUNT'}) ? $conf->global->{'ACCOUNTING_SERVICE_' . $const_name . '_ACCOUNT'} : ''); + $code_l = getDolGlobalString('ACCOUNTING_SERVICE_' . $const_name . '_ACCOUNT'); $suggestedaccountingaccountbydefaultfor = 'eecwithoutvatnumber'; } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale - $code_l = (!empty($conf->global->{'ACCOUNTING_SERVICE_' . $const_name . '_INTRA_ACCOUNT'}) ? $conf->global->{'ACCOUNTING_SERVICE_' . $const_name . '_INTRA_ACCOUNT'} : ''); + $code_l = getDolGlobalString('ACCOUNTING_SERVICE_' . $const_name . '_INTRA_ACCOUNT'); $suggestedaccountingaccountbydefaultfor = 'eec'; } else { // Foreign sale - $code_l = (!empty($conf->global->{'ACCOUNTING_SERVICE_' . $const_name . '_EXPORT_ACCOUNT'}) ? $conf->global->{'ACCOUNTING_SERVICE_' . $const_name . '_EXPORT_ACCOUNT'} : ''); + $code_l = getDolGlobalString('ACCOUNTING_SERVICE_' . $const_name . '_EXPORT_ACCOUNT'); $suggestedaccountingaccountbydefaultfor = 'export'; } } } elseif ($factureDet->product_type == 0) { if ($buyer->country_code == $seller->country_code || empty($buyer->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) - $code_l = (!empty($conf->global->{'ACCOUNTING_PRODUCT_' . $const_name . '_ACCOUNT'}) ? $conf->global->{'ACCOUNTING_PRODUCT_' . $const_name . '_ACCOUNT'} : ''); + $code_l = getDolGlobalString('ACCOUNTING_PRODUCT_' . $const_name . '_ACCOUNT'); $suggestedaccountingaccountbydefaultfor = ''; } else { if ($isSellerInEEC && $isBuyerInEEC && $factureDet->tva_tx != 0) { // European intravat sale, but with a VAT - $code_l = (!empty($conf->global->{'ACCOUNTING_PRODUCT_' . $const_name . '_ACCOUNT'}) ? $conf->global->{'ACCOUNTING_PRODUCT_' . $const_name . '_ACCOUNT'} : ''); + $code_l = getDolGlobalString('ACCOUNTING_PRODUCT_' . $const_name . '_ACCOUNT'); $suggestedaccountingaccountbydefaultfor = 'eecwithvat'; } elseif ($isSellerInEEC && $isBuyerInEEC && empty($buyer->tva_intra)) { // European intravat sale, without VAT intra community number - $code_l = (!empty($conf->global->{'ACCOUNTING_PRODUCT_' . $const_name . '_ACCOUNT'}) ? $conf->global->{'ACCOUNTING_PRODUCT_' . $const_name . '_ACCOUNT'} : ''); + $code_l = getDolGlobalString('ACCOUNTING_PRODUCT_' . $const_name . '_ACCOUNT'); $suggestedaccountingaccountbydefaultfor = 'eecwithoutvatnumber'; } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale - $code_l = (!empty($conf->global->{'ACCOUNTING_PRODUCT_' . $const_name . '_INTRA_ACCOUNT'}) ? $conf->global->{'ACCOUNTING_PRODUCT_' . $const_name . '_INTRA_ACCOUNT'} : ''); + $code_l = getDolGlobalString('ACCOUNTING_PRODUCT_' . $const_name . '_INTRA_ACCOUNT'); $suggestedaccountingaccountbydefaultfor = 'eec'; } else { - $code_l = (!empty($conf->global->{'ACCOUNTING_PRODUCT_' . $const_name . '_EXPORT_ACCOUNT'}) ? $conf->global->{'ACCOUNTING_PRODUCT_' . $const_name . '_EXPORT_ACCOUNT'} : ''); + $code_l = getDolGlobalString('ACCOUNTING_PRODUCT_' . $const_name . '_EXPORT_ACCOUNT'); $suggestedaccountingaccountbydefaultfor = 'export'; } } @@ -941,5 +941,7 @@ class AccountingAccount extends CommonObject return $hookmanager->resArray; } } + + return -1; } } diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index c20682c8e17..ccf5d67dcfd 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -22,7 +22,7 @@ */ /** - * Class to manage accounting accounts + * Class to manage accounting journals */ class AccountingJournal extends CommonObject { @@ -42,7 +42,7 @@ class AccountingJournal extends CommonObject public $fk_element = ''; /** - * @var int 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + * @var int Does object support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe */ public $ismultientitymanaged = 0; diff --git a/htdocs/accountancy/class/api_accountancy.class.php b/htdocs/accountancy/class/api_accountancy.class.php index f1870d7b8b2..815c7b69f05 100644 --- a/htdocs/accountancy/class/api_accountancy.class.php +++ b/htdocs/accountancy/class/api_accountancy.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2019 Cedric Ancelin - * Copyright (C) 2023 Lionel Vessiller + * Copyright (C) 2023 Lionel Vessiller * * 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 @@ -64,18 +64,18 @@ class Accountancy extends DolibarrApi /** * Accountancy export data * - * @param string $period Period : 'lastmonth', 'currentmonth', 'last3months', 'last6months', 'currentyear', 'lastyear', 'fiscalyear', 'lastfiscalyear', 'actualandlastfiscalyear' or 'custom' (see above) - * @param string $date_min [=''] Start date of period if 'custom' is set in period parameter - * Date format is 'YYYY-MM-DD' - * @param string $date_max [=''] End date of period if 'custom' is set in period parameter - * Date format is 'YYYY-MM-DD' - * @param string $format [=''] by default uses '1' for 'Configurable (CSV)' for format number + * @param string $period Period : 'lastmonth', 'currentmonth', 'last3months', 'last6months', 'currentyear', 'lastyear', 'fiscalyear', 'lastfiscalyear', 'actualandlastfiscalyear' or 'custom' (see above) + * @param string $date_min [=''] Start date of period if 'custom' is set in period parameter + * Date format is 'YYYY-MM-DD' + * @param string $date_max [=''] End date of period if 'custom' is set in period parameter + * Date format is 'YYYY-MM-DD' + * @param string $format [=''] by default uses '1' for 'Configurable (CSV)' for format number * or '1000' for FEC - * or '1010' for FEC2 - * (see AccountancyExport class) + * or '1010' for FEC2 + * (see AccountancyExport class) * @param int $lettering [=0] by default don't export or 1 to export lettering data (columns 'letterring_code' and 'date_lettering' returns empty or not) - * @param int $alreadyexport [=0] by default export data only if it's not yet exported or 1 already exported (always export data even if 'date_export" is set) - * @param int $notnotifiedasexport [=0] by default notified as exported or 1 not notified as exported (when the export is done, notified or not the column 'date_export') + * @param int $alreadyexport [=0] by default export data only if it's not yet exported or 1 already exported (always export data even if 'date_export" is set) + * @param int $notnotifiedasexport [=0] by default notified as exported or 1 not notified as exported (when the export is done, notified or not the column 'date_export') * * @return string * diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 81229ca39da..b687310193a 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -488,7 +488,7 @@ class BookKeeping extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { @@ -716,11 +716,10 @@ class BookKeeping extends CommonObject /** * Load object in memory from the database * - * @param int $id Id object - * @param string $ref Ref - * @param string $mode Mode - * - * @return int <0 if KO, 0 if not found, >0 if OK + * @param int $id Id object + * @param string $ref Ref (Not used. Does not exists on this table, same as rowid) + * @param string $mode Mode + * @return int Int <0 if KO, 0 if not found, >0 if OK */ public function fetch($id, $ref = null, $mode = '') { @@ -761,7 +760,7 @@ class BookKeeping extends CommonObject $sql .= ' WHERE 1 = 1'; $sql .= " AND entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features if (null !== $ref) { - $sql .= " AND t.ref = '".$this->db->escape($ref)."'"; + $sql .= " AND t.rowid = ".((int) $ref); } else { $sql .= ' AND t.rowid = '.((int) $id); } @@ -1480,15 +1479,16 @@ class BookKeeping extends CommonObject * Delete bookkeeping by importkey * * @param string $importkey Import key + * @param string $mode Mode * @return int Result */ - public function deleteByImportkey($importkey) + public function deleteByImportkey($importkey, $mode = '') { $this->db->begin(); // first check if line not yet in bookkeeping $sql = "DELETE"; - $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode; $sql .= " WHERE import_key = '".$this->db->escape($importkey)."'"; $resql = $this->db->query($sql); @@ -1562,9 +1562,10 @@ class BookKeeping extends CommonObject * Delete bookkeeping by piece number * * @param int $piecenum Piecenum to delete + * @param string $mode Mode * @return int Result */ - public function deleteMvtNum($piecenum) + public function deleteMvtNum($piecenum, $mode = '') { global $conf; @@ -1572,7 +1573,7 @@ class BookKeeping extends CommonObject // first check if line not yet in bookkeeping $sql = "DELETE"; - $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode; $sql .= " WHERE piece_num = ".(int) $piecenum; $sql .= " AND date_validated IS NULL"; // For security, exclusion of validated entries at the time of deletion $sql .= " AND entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index 67eee9022b5..5cda6cad5b4 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2013 Olivier Geffroy - * Copyright (C) 2013-2019 Alexandre Spangaro + * Copyright (C) 2013-2023 Alexandre Spangaro * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -97,8 +97,8 @@ class Lettering extends BookKeeping $object->fetch($socid); - if ($object->code_compta == '411CUSTCODE') { - $object->code_compta = ''; + if ($object->code_compta_client == '411CUSTCODE') { + $object->code_compta_client = ''; } if ($object->code_compta_fournisseur == '401SUPPCODE') { @@ -106,7 +106,7 @@ class Lettering extends BookKeeping } /** - * Prise en charge des lettering complexe avec prelevment , virement + * Support for complex lettering with debit, credit transfer */ $sql = "SELECT DISTINCT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.subledger_account, "; $sql .= " bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant "; @@ -114,10 +114,10 @@ class Lettering extends BookKeeping $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON(bk.fk_doc = bu.fk_bank AND bu.type IN ('payment', 'payment_supplier') ) "; $sql .= " WHERE ( "; - if ($object->code_compta != "") { - $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta)."' "; + if ($object->code_compta_client != "") { + $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta_client)."' "; } - if ($object->code_compta != "" && $object->code_compta_fournisseur != "") { + if ($object->code_compta_client != "" && $object->code_compta_fournisseur != "") { $sql .= " OR "; } if ($object->code_compta_fournisseur != "") { @@ -149,10 +149,10 @@ class Lettering extends BookKeeping $sql .= " AND facf.entity = ".$conf->entity; $sql .= " AND code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=4 AND entity=".$conf->entity.") "; $sql .= " AND ( "; - if ($object->code_compta != "") { - $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta)."' "; + if ($object->code_compta_client != "") { + $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta_client)."' "; } - if ($object->code_compta != "" && $object->code_compta_fournisseur != "") { + if ($object->code_compta_client != "" && $object->code_compta_fournisseur != "") { $sql .= " OR "; } if ($object->code_compta_fournisseur != "") { @@ -178,10 +178,10 @@ class Lettering extends BookKeeping $sql .= " WHERE bk.code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=3 AND entity=".$conf->entity.") "; $sql .= " AND facf.entity = ".$conf->entity; $sql .= " AND ( "; - if ($object->code_compta != "") { - $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta)."' "; + if ($object->code_compta_client != "") { + $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta_client)."' "; } - if ($object->code_compta != "" && $object->code_compta_fournisseur != "") { + if ($object->code_compta_client != "" && $object->code_compta_fournisseur != "") { $sql .= " OR "; } if ($object->code_compta_fournisseur != "") { @@ -210,10 +210,10 @@ class Lettering extends BookKeeping $sql .= " AND bk.code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=4 AND entity=".$conf->entity.") "; $sql .= " AND fac.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy $sql .= " AND ( "; - if ($object->code_compta != "") { - $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta)."' "; + if ($object->code_compta_client != "") { + $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta_client)."' "; } - if ($object->code_compta != "" && $object->code_compta_fournisseur != "") { + if ($object->code_compta_client != "" && $object->code_compta_fournisseur != "") { $sql .= " OR "; } if ($object->code_compta_fournisseur != "") { @@ -238,10 +238,10 @@ class Lettering extends BookKeeping $sql .= " WHERE code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=2 AND entity=".$conf->entity.") "; $sql .= " AND fac.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy $sql .= " AND ( "; - if ($object->code_compta != "") { - $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta)."' "; + if ($object->code_compta_client != "") { + $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta_client)."' "; } - if ($object->code_compta != "" && $object->code_compta_fournisseur != "") { + if ($object->code_compta_client != "" && $object->code_compta_fournisseur != "") { $sql .= " OR "; } if ($object->code_compta_fournisseur != "") { @@ -288,7 +288,9 @@ class Lettering extends BookKeeping public function updateLettering($ids = array(), $notrigger = false) { $error = 0; - $lettre = 'AAA'; + + // Generate a string with n char A where n is ACCOUNTING_LETTERING_NBLETTERS (So 'AA', 'AAA', ...) + $lettre = str_pad("", getDolGlobalInt('ACCOUNTING_LETTERING_NBLETTERS', 3), "A"); $sql = "SELECT DISTINCT ab2.lettering_code"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab"; @@ -327,7 +329,6 @@ class Lettering extends BookKeeping } // Update request - $now = dol_now(); $affected_rows = 0; diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index d3dfcd3cdb6..2e8e68526db 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -57,6 +57,9 @@ if ($in_bookkeeping == '') { $now = dol_now(); +$hookmanager->initHooks(array('expensereportsjournal')); +$parameters = array(); + // Security check if (!isModEnabled('accounting')) { accessforbidden(); @@ -102,11 +105,17 @@ $sql = "SELECT er.rowid, er.ref, er.date_debut as de,"; $sql .= " erd.rowid as erdid, erd.comments, erd.total_ht, erd.total_tva, erd.total_localtax1, erd.total_localtax2, erd.tva_tx, erd.total_ttc, erd.fk_code_ventilation, erd.vat_src_code, "; $sql .= " u.rowid as uid, u.firstname, u.lastname, u.accountancy_code as user_accountancy_account,"; $sql .= " f.accountancy_code, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; +$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."expensereport_det as erd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as f ON f.id = erd.fk_c_type_fees"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; $sql .= " JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport"; $sql .= " JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = er.fk_user_author"; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; $sql .= " WHERE er.fk_statut > 0"; $sql .= " AND erd.fk_code_ventilation > 0"; $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy @@ -124,6 +133,9 @@ if ($in_bookkeeping == 'already') { if ($in_bookkeeping == 'notyet') { $sql .= " AND er.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')"; } +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; $sql .= " ORDER BY er.date_debut"; dol_syslog('accountancy/journal/expensereportsjournal.php', LOG_DEBUG); diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 5dd30d6c602..1fd982f3567 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -72,6 +72,8 @@ if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } +$error = 0; + /* * Actions @@ -122,6 +124,9 @@ if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) { $sql .= " p.accountancy_code_buy,"; } $sql .= " aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; +$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."facture_fourn_det as fd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product"; if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) { @@ -134,6 +139,9 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity); } +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; $sql .= " WHERE f.fk_statut > 0"; $sql .= " AND fd.fk_code_ventilation > 0"; $sql .= " AND f.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy @@ -156,6 +164,9 @@ if ($in_bookkeeping == 'already') { if ($in_bookkeeping == 'notyet') { $sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')"; } +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; $sql .= " ORDER BY f.datef"; dol_syslog('accountancy/journal/purchasesjournal.php', LOG_DEBUG); @@ -173,6 +184,7 @@ if ($result) { $tabrctva = array(); $tabrclocaltax1 = array(); $tabrclocaltax2 = array(); + $vatdata_cache = array(); $num = $db->num_rows($result); @@ -199,7 +211,13 @@ if ($result) { } } - $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), $mysoc, $mysoc, 0); + $tax_id = $obj->tva_tx . ($obj->vat_src_code ? ' (' . $obj->vat_src_code . ')' : ''); + if (array_key_exists($tax_id, $vatdata_cache)) { + $vatdata = $vatdata_cache[$tax_id]; + } else { + $vatdata = getTaxesFromId($tax_id, $mysoc, $mysoc, 0); + $vatdata_cache[$tax_id] = $vatdata; + } $compta_tva = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva); $compta_localtax1 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva); $compta_localtax2 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva); @@ -309,8 +327,16 @@ if ($result) { dol_print_error($db); } +// Check for too many invoices first. +if (count($tabfac) > 10000) { // Global config in htdocs/admin/const.php??? + $error++; + setEventMessages("TooManyInvoicesToProcessPleaseUseAMoreSelectiveFilter", null, 'errors'); +} + $errorforinvoice = array(); +/* +// Old way, 1 query for each invoice // Loop in invoices to detect lines with not binding lines foreach ($tabfac as $key => $val) { // Loop on each invoice $sql = "SELECT COUNT(fd.rowid) as nb"; @@ -327,12 +353,38 @@ foreach ($tabfac as $key => $val) { // Loop on each invoice dol_print_error($db); } } +*/ +// New way, single query, load all unbound lines +$sql = " +SELECT + fk_facture_fourn, + COUNT(fd.rowid) as nb +FROM + llx_facture_fourn_det as fd +WHERE + fd.product_type <= 2 + AND fd.fk_code_ventilation <= 0 + AND fd.total_ttc <> 0 + AND fk_facture_fourn IN (".$db->sanitize(join(",", array_keys($tabfac))).") +GROUP BY fk_facture_fourn +"; +$resql = $db->query($sql); + +$num = $db->num_rows($resql); +$i = 0; +while ($i < $num) { + $obj = $db->fetch_object($resql); + if ($obj->nb > 0) { + $errorforinvoice[$obj->fk_facture_fourn] = 'somelinesarenotbound'; + } + $i++; +} //var_dump($errorforinvoice);exit; // Bookkeeping Write -if ($action == 'writebookkeeping') { +if ($action == 'writebookkeeping' && !$error) { $now = dol_now(); $error = 0; @@ -703,7 +755,7 @@ if ($action == 'writebookkeeping') { $form = new Form($db); // Export -if ($action == 'exportcsv') { // ISO and not UTF8 ! +if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 ! $sep = getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV'); $filename = 'journal'; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 05067ad6a7b..f87c020ce3b 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -74,6 +74,8 @@ if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } +$error = 0; + /* * Actions @@ -100,6 +102,9 @@ if (empty($date_startmonth) || empty($date_endmonth)) { $pastmonthyear = $dates['pastmonthyear']; $pastmonth = $dates['pastmonth']; } +if (getDolGlobalString('ACCOUNTANCY_JOURNAL_USE_CURRENT_MONTH')) { + $pastmonth+=1; +} if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) { // We define date_start and date_end, only if we did not submit the form $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); @@ -122,6 +127,9 @@ if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) { } else { $sql .= " p.accountancy_code_sell"; } +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product"; if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) { @@ -133,6 +141,9 @@ $sql .= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity); } +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; $sql .= " WHERE fd.fk_code_ventilation > 0"; $sql .= " AND f.entity IN (".getEntity('invoice', 0).')'; // We don't share object for accountancy, we use source object sharing $sql .= " AND f.fk_statut > 0"; @@ -158,6 +169,9 @@ if ($in_bookkeeping == 'notyet') { $sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; // $sql .= " AND fd.rowid NOT IN (SELECT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; // Useless, we save one line for all products with same account } +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; $sql .= " ORDER BY f.datef, f.ref"; //print $sql; @@ -174,6 +188,7 @@ if ($result) { $tablocaltax1 = array(); $tablocaltax2 = array(); $tabcompany = array(); + $vatdata_cache = array(); $num = $db->num_rows($result); @@ -199,7 +214,13 @@ if ($result) { //$compta_revenuestamp = getDolGlobalString('ACCOUNTING_REVENUESTAMP_SOLD_ACCOUNT', 'NotDefined'); - $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), $mysoc, $mysoc, 0); + $tax_id = $obj->tva_tx . ($obj->vat_src_code ? ' (' . $obj->vat_src_code . ')' : ''); + if (array_key_exists($tax_id, $vatdata_cache)) { + $vatdata = $vatdata_cache[$tax_id]; + } else { + $vatdata = getTaxesFromId($tax_id, $mysoc, $mysoc, 0); + $vatdata_cache[$tax_id] = $vatdata; + } $compta_tva = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); $compta_localtax1 = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); $compta_localtax2 = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); @@ -326,8 +347,16 @@ if ($result) { dol_print_error($db); } +// Check for too many invoices first. +if (count($tabfac) > 10000) { + $error++; + setEventMessages("TooManyInvoicesToProcessPleaseUseAMoreSelectiveFilter", null, 'errors'); +} + $errorforinvoice = array(); +/* +// Old way, 1 query for each invoice // Loop on all invoices to detect lines without binded code (fk_code_ventilation <= 0) foreach ($tabfac as $key => $val) { // Loop on each invoice $sql = "SELECT COUNT(fd.rowid) as nb"; @@ -344,11 +373,37 @@ foreach ($tabfac as $key => $val) { // Loop on each invoice dol_print_error($db); } } +*/ +// New way, single query, load all unbound lines + +$sql = " +SELECT + fk_facture, + COUNT(fd.rowid) as nb +FROM + ".MAIN_DB_PREFIX."facturedet as fd +WHERE + fd.product_type <= 2 + AND fd.fk_code_ventilation <= 0 + AND fd.total_ttc <> 0 + AND fk_facture IN (".$db->sanitize(join(",", array_keys($tabfac))).") +GROUP BY fk_facture +"; +$resql = $db->query($sql); + +$num = $db->num_rows($resql); +$i = 0; +while ($i < $num) { + $obj = $db->fetch_object($resql); + if ($obj->nb > 0) { + $errorforinvoice[$obj->fk_facture_fourn] = 'somelinesarenotbound'; + } + $i++; +} //var_dump($errorforinvoice);exit; - // Bookkeeping Write -if ($action == 'writebookkeeping') { +if ($action == 'writebookkeeping' && !$error) { $now = dol_now(); $error = 0; @@ -752,7 +807,7 @@ if ($action == 'writebookkeeping') { $form = new Form($db); // Export -if ($action == 'exportcsv') { // ISO and not UTF8 ! +if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 ! // Note that to have the button to get this feature enabled, you must enable ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL $sep = getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV'); diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php index f463a5af4f6..42dbd4fcbb9 100644 --- a/htdocs/adherents/admin/member.php +++ b/htdocs/adherents/admin/member.php @@ -51,6 +51,7 @@ $scandir = GETPOST('scandir', 'alpha'); $type = 'member'; $action = GETPOST('action', 'aZ09'); +$modulepart = GETPOST('modulepart', 'aZ09'); /* diff --git a/htdocs/adherents/canvas/actions_adherentcard_common.class.php b/htdocs/adherents/canvas/actions_adherentcard_common.class.php index 84ae98ac3c5..66e53b58109 100644 --- a/htdocs/adherents/canvas/actions_adherentcard_common.class.php +++ b/htdocs/adherents/canvas/actions_adherentcard_common.class.php @@ -275,7 +275,7 @@ abstract class ActionsAdherentCardCommon $obj = $this->db->fetch_object($resql); $this->object->country_code = $obj->code; - $this->object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->libelle; + $this->object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label; } else { dol_print_error($this->db); } diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 0bc4aeed29c..a750fd2bba6 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -463,10 +463,6 @@ if (empty($reshook)) { $phone = GETPOST("phone", 'alpha'); $phone_perso = GETPOST("phone_perso", 'alpha'); $phone_mobile = GETPOST("phone_mobile", 'alpha'); - // $skype=GETPOST("member_skype", 'alpha'); - // $twitter=GETPOST("member_twitter", 'alpha'); - // $facebook=GETPOST("member_facebook", 'alpha'); - // $linkedin=GETPOST("member_linkedin", 'alpha'); $email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha')); $url = trim(GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL)); $login = GETPOST("member_login", 'alphanohtml'); diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 8717ecd010a..9b6dd8b9468 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -133,79 +133,11 @@ class Adherent extends CommonObject */ public $socid; - /** - * @var string Address - */ - public $address; - - /** - * @var string zipcode - */ - public $zip; - - /** - * @var string town - */ - public $town; - - /** - * @var int Id of state - */ - public $state_id; - - /** - * @var string Code of state - */ - public $state_code; - - /** - * @var string Label of state - */ - public $state; - - /** - * @var string email - */ - public $email; - - /** - * @var string url - */ - public $url; - /** * @var array array of socialnetworks */ public $socialnetworks; - /** - * @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; - /** * @var string Phone number */ @@ -337,16 +269,11 @@ class Adherent extends CommonObject public $partnerships = array(); - /** - * @var Adherent To contains a clone of this when we need to save old properties of object + * @var Facture To store the created invoice into subscriptionComplementaryActions() */ - public $oldcopy; + public $invoice; - /** - * @var int Entity - */ - public $entity; /** * @var array fields @@ -2387,7 +2314,7 @@ class Adherent extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { @@ -2823,11 +2750,11 @@ class Adherent extends CommonObject // Member foreach ($ldapkey as $constname => $varname) { - if (!empty($this->$varname) && !empty($conf->global->$constname)) { - $info[$conf->global->$constname] = $this->$varname; + if (!empty($this->$varname) && getDolGlobalString($constname)) { + $info[getDolGlobalString($constname)] = $this->$varname; // Check if it is the LDAP key and if its value has been changed - if (!empty($conf->global->LDAP_KEY_MEMBERS) && $conf->global->LDAP_KEY_MEMBERS == $conf->global->$constname) { + if (!empty($conf->global->LDAP_KEY_MEMBERS) && $conf->global->LDAP_KEY_MEMBERS == getDolGlobalString($constname)) { if (!empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) { $keymodified = true; // For check if LDAP key has been modified } @@ -2856,8 +2783,8 @@ class Adherent extends CommonObject $info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code; } foreach ($socialnetworks as $key => $value) { - if ($this->socialnetworks[$value['label']] && !empty($conf->global->{'LDAP_MEMBER_FIELD_'.strtoupper($value['label'])})) { - $info[$conf->global->{'LDAP_MEMBER_FIELD_'.strtoupper($value['label'])}] = $this->socialnetworks[$value['label']]; + if ($this->socialnetworks[$value['label']] && getDolGlobalString('LDAP_MEMBER_FIELD_'.strtoupper($value['label']))) { + $info[getDolGlobalString('LDAP_MEMBER_FIELD_'.strtoupper($value['label']))] = $this->socialnetworks[$value['label']]; } } if ($this->phone && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE)) { diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 44b2fb349d6..7d7adaa2d93 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -759,7 +759,7 @@ class AdherentType extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 8a26cd5d070..f430e59f68d 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -55,8 +55,8 @@ class Members extends DolibarrApi * * Return an array with member informations * - * @param int $id ID of member - * @return Object Object with cleaned properties + * @param int $id ID of member + * @return Object Object with cleaned properties * * @throws RestException */ @@ -88,9 +88,9 @@ class Members extends DolibarrApi * * Return an array with member informations * - * @param int $thirdparty ID of third party + * @param int $thirdparty ID of third party * - * @return Object Data without useless information + * @return Object Data without useless information * * @url GET thirdparty/{thirdparty} * @@ -123,7 +123,7 @@ class Members extends DolibarrApi * * @param string $email Email of third party * - * @return Object Data without useless information + * @return Object Data without useless information * * @url GET thirdparty/email/{email} * @@ -160,9 +160,9 @@ class Members extends DolibarrApi * * Return an array with member informations * - * @param string $barcode Barcode of third party + * @param string $barcode Barcode of third party * - * @return Object Data without useless information + * @return Object Data without useless information * * @url GET thirdparty/barcode/{barcode} * @@ -204,14 +204,15 @@ class Members extends DolibarrApi * @param int $limit Limit for list * @param int $page Page number * @param string $typeid ID of the type of member - * @param int $category Use this param to filter list by category + * @param int $category Use this param to filter list by category * @param string $sqlfilters Other criteria to filter answers separated by a comma. * Example: "(t.ref:like:'SO-%') and ((t.date_creation:<:'20160101') or (t.nature:is:NULL))" + * @param string $properties Restrict the data returned to theses properties. Ignored if empty. Comma separated list of properties names * @return array Array of member objects * * @throws RestException */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $typeid = '', $category = 0, $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $typeid = '', $category = 0, $sqlfilters = '', $properties = '') { global $db, $conf; @@ -263,7 +264,7 @@ class Members extends DolibarrApi $obj = $this->db->fetch_object($result); $member = new Adherent($this->db); if ($member->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($member); + $obj_ret[] = $this->_filterObjectProperties($this->_cleanObjectDatas($member), $properties); } $i++; } @@ -483,11 +484,11 @@ class Members extends DolibarrApi /** * Add a subscription for a member * - * @param int $id ID of member - * @param string $start_date Start date {@from body} {@type timestamp} - * @param string $end_date End date {@from body} {@type timestamp} - * @param float $amount Amount (may be 0) {@from body} - * @param string $label Label {@from body} + * @param int $id ID of member + * @param string $start_date Start date {@from body} {@type timestamp} + * @param string $end_date End date {@from body} {@type timestamp} + * @param float $amount Amount (may be 0) {@from body} + * @param string $label Label {@from body} * @return int ID of subscription * * @url POST {id}/subscriptions diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index da43514a1d0..2ba5ce8fadf 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -48,8 +48,8 @@ class MembersTypes extends DolibarrApi * * Return an array with member type informations * - * @param int $id ID of member type - * @return Object Object with cleaned properties + * @param int $id ID of member type + * @return Object Object with cleaned properties * * @throws RestException */ @@ -82,11 +82,12 @@ class MembersTypes extends DolibarrApi * @param int $limit Limit for list * @param int $page Page number * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.libelle:like:'SO-%') and (t.subscription:=:'1')" + * @param string $properties Restrict the data returned to theses properties. Ignored if empty. Comma separated list of properties names * @return array Array of member type objects * * @throws RestException */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '') { global $db, $conf; @@ -128,7 +129,7 @@ class MembersTypes extends DolibarrApi $obj = $this->db->fetch_object($result); $membertype = new AdherentType($this->db); if ($membertype->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($membertype); + $obj_ret[] = $this->_filterObjectProperties($this->_cleanObjectDatas($membertype), $properties); } $i++; } diff --git a/htdocs/adherents/class/api_subscriptions.class.php b/htdocs/adherents/class/api_subscriptions.class.php index a60078769a0..174de6d5fe9 100644 --- a/htdocs/adherents/class/api_subscriptions.class.php +++ b/htdocs/adherents/class/api_subscriptions.class.php @@ -51,8 +51,8 @@ class Subscriptions extends DolibarrApi * * Return an array with subscription informations * - * @param int $id ID of subscription - * @return Object Object with cleaned properties + * @param int $id ID of subscription + * @return Object Object with cleaned properties * * @throws RestException */ @@ -81,11 +81,12 @@ class Subscriptions extends DolibarrApi * @param int $limit Limit for list * @param int $page Page number * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.import_key:<:'20160101')" + * @param string $properties Restrict the data returned to theses properties. Ignored if empty. Comma separated list of properties names * @return array Array of subscription objects * * @throws RestException */ - public function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + public function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '') { global $conf; @@ -125,7 +126,7 @@ class Subscriptions extends DolibarrApi $obj = $this->db->fetch_object($result); $subscription = new Subscription($this->db); if ($subscription->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($subscription); + $obj_ret[] = $this->_filterObjectProperties($this->_cleanObjectDatas($subscription), $properties); } $i++; } diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 7f130d70b62..5bf3e4cc51d 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -429,7 +429,7 @@ class Subscription extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { @@ -531,15 +531,15 @@ class Subscription extends CommonObject $return .= '
'; $return .= ''; $return .= $this->getNomUrl(-1); - - //.(property_exists($this, 'fk_adherent') ? $this->fk_adherent: $this->ref).''; + $return .= ''; $return .= ''; + if (property_exists($this, 'dateh') || property_exists($this, 'datef')) { $return .= '
'.dol_print_date($this->dateh, 'day').' - '.dol_print_date($this->datef, 'day').''; } if (!empty($arraydata['member']) && is_object($arraydata['member'])) { - $return .= '
'.$arraydata['member']->getNomUrl(-4).''; + $return .= '
'.$arraydata['member']->getNomUrl(-4).''; } if (property_exists($this, 'amount')) { diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 52ef9109f9c..014448a5a95 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -143,9 +143,6 @@ $fieldstosearchall = array( 'd.note_public'=>'NotePublic', 'd.note_private'=>'NotePrivate', ); -if ($db->type == 'pgsql') { - unset($fieldstosearchall['d.rowid']); -} $arrayfields = array( 'd.ref'=>array('label'=>"Ref", 'checked'=>1), diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index c8857748294..7d201cd2625 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -252,7 +252,7 @@ $arrayofselected = is_array($toselect) ? $toselect : array(); if (!$rowid && $action != 'create' && $action != 'edit') { //print dol_get_fiche_head(''); - $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.amount, d.caneditamount, d.vote, d.statut as status, d.morphy"; + $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.amount, d.caneditamount, d.vote, d.statut as status, d.morphy, d.duration"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $sql .= " WHERE d.entity IN (".getEntity('member_type').")"; @@ -309,6 +309,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') { print ''.$langs->trans("Ref").''; print ''.$langs->trans("Label").''; print ''.$langs->trans("MembersNature").''; + print ''.$langs->trans("MembershipDuration").''; print ''.$langs->trans("SubscriptionRequired").''; print ''.$langs->trans("Amount").''; print ''.$langs->trans("CanEditAmountShort").''; @@ -372,6 +373,18 @@ if (!$rowid && $action != 'create' && $action != 'edit') { print $langs->trans("MorAndPhy"); } print ''; + print ''; + if ($objp->duration) { + $duration_value = intval($objp->duration); + if ($duration_value > 1) { + $dur = array("i"=>$langs->trans("Minutes"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); + } else { + $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); + } + $unit = preg_replace("/[^a-zA-Z]+/", "", $objp->duration); + print max(1, $duration_value).' '.$dur[$unit]; + } + print ''; print ''.yn($objp->subscription).''; print ''.(is_null($objp->amount) || $objp->amount === '' ? '' : price($objp->amount)).''; print ''.yn($objp->caneditamount).''; diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index ef365881feb..afd0540cca3 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -243,7 +243,7 @@ while ($i < $nbofbank) { } print "\n"; - if ($conf->global->BANK_SHOW_ORDER_OPTION == $i) { + if (getDolGlobalInt('BANK_SHOW_ORDER_OPTION') == $i) { print ''; print img_picto($langs->trans("Activated"), 'on'); print ''; @@ -415,7 +415,7 @@ print ''; print $langs->trans('BankColorizeMovementDesc'); print ""; // Active -if ($conf->global->BANK_COLORIZE_MOVEMENT) { +if (getDolGlobalInt('BANK_COLORIZE_MOVEMENT')) { print ''."\n"; print ''; print img_picto($langs->trans("Enabled"), 'switch_on'); @@ -429,7 +429,7 @@ if ($conf->global->BANK_COLORIZE_MOVEMENT) { print "\n"; -if (!empty($conf->global->BANK_COLORIZE_MOVEMENT)) { +if (getDolGlobalInt('BANK_COLORIZE_MOVEMENT')) { $i = 1; while ($i <= 2) { $key = $i; @@ -471,7 +471,7 @@ print "\n"; print $langs->trans('AutoReportLastAccountStatement'); print ''; // Active -if ($conf->global->BANK_REPORT_LAST_NUM_RELEVE) { +if (getDolGlobalString('BANK_REPORT_LAST_NUM_RELEVE')) { print ''."\n"; print ''; print img_picto($langs->trans("Enabled"), 'switch_on'); @@ -482,8 +482,18 @@ if ($conf->global->BANK_REPORT_LAST_NUM_RELEVE) { print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; print ""; } - print "\n"; + +// Allow SEPA Mandate OnLine Sign +if (!getDolGlobalInt('SOCIETE_DISABLE_BANKACCOUNT')) { + print ''; + print ''.$langs->trans("AllowOnLineSign").''.$langs->trans("BankAccountModelModule").''; + print ''; + print ajax_constantonoff('SOCIETE_RIB_ALLOW_ONLINESIGN', array(), null, 0, 0, 0, 2, 0, 1); + print ''; +} + + print ''; print dol_get_fiche_end(); diff --git a/htdocs/admin/bom.php b/htdocs/admin/bom.php index 57b4b5aad06..994db340687 100644 --- a/htdocs/admin/bom.php +++ b/htdocs/admin/bom.php @@ -219,7 +219,7 @@ foreach ($dirmodels as $reldir) { if ($module->isEnabled()) { print ''.$module->name."\n"; - print $module->info(); + print $module->info($langs); print ''; // Show example of numbering module diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index 77994debadb..98d2c80579c 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -164,7 +164,7 @@ foreach ($dirmodels as $reldir) { print (empty($module->name) ? $name : $module->name); print "\n"; - print $module->info(); + print $module->info($langs); print ''; diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 93db0398687..fba421f6ccb 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -303,7 +303,7 @@ foreach ($dirmodels as $reldir) { if ($module->isEnabled()) { print ''.$module->name."\n"; - print $module->info(); + print $module->info($langs); print ''; // Show example of numbering model diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index a0c935413f3..0a7770bcc3d 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -6,6 +6,7 @@ * Copyright (C) 2011-2017 Philippe Grand * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2017 Rui Strecht + * Copyright (C) 2023 Nick Fragoulis * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -233,6 +234,14 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC2", GETPOST("clt2", 'aZ09'), 'chaine', 0, '', $conf->entity); } + // Credentials for AADE webservices, applicable only for Greece + if ($mysoc->country_code == 'GR') { + dolibarr_set_const($db, "MYDATA_AADE_USER", GETPOST("MYDATA_AADE_USER", 'alpha'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MYDATA_AADE_KEY", GETPOST("MYDATA_AADE_KEY", 'alpha'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "AADE_WEBSERVICE_USER", GETPOST("AADE_WEBSERVICE_USER", 'alpha'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "AADE_WEBSERVICE_KEY", GETPOST("AADE_WEBSERVICE_KEY", 'alpha'), 'chaine', 0, '', $conf->entity); + } + // Remove constant MAIN_INFO_SOCIETE_SETUP_TODO_WARNING dolibarr_del_const($db, "MAIN_INFO_SOCIETE_SETUP_TODO_WARNING", $conf->entity); @@ -847,6 +856,41 @@ if ($mysoc->useRevenueStamp()) { print ""; +// AADE webservices credentials, applicable only for Greece +if ($mysoc->country_code == 'GR') { + print load_fiche_titre($langs->trans("AADEWebserviceCredentials"), '', ''); + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + print ''; + + print ''; + + print ''; + + print ''; + + print '
'; + + print "
'.$langs->trans("AccountParameter").''.$langs->trans("Value").'
'; + print ''.$langs->trans("MYDATA_AADE_USER").''; + print '
'; + print ''.$langs->trans("MYDATA_AADE_KEY").''; + print '
'; + print ''.$langs->trans("AADE_WEBSERVICE_USER").''; + print '
'; + print ''.$langs->trans("AADE_WEBSERVICE_KEY").''; + print '
"; +} + print $form->buttonsSaveCancel("Save", ''); print ''; diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index 919a32b4c0e..7223a7d5c57 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -254,7 +254,7 @@ foreach ($dirmodels as $reldir) { if ($module->isEnabled()) { print ''.$module->nom."\n"; - print $module->info(); + print $module->info($langs); print ''; // Show example of numbering model @@ -475,7 +475,7 @@ print '
'; print ''; print ''; print ''; -print ''; +print ''; print "\n"; $substitutionarray = pdf_getSubstitutionArray($langs, array('objectamount'), null, 2); @@ -503,13 +503,13 @@ print ''."\n"; print ''."\n"; print ''; print ''; -print ''; print ''; @@ -517,7 +517,7 @@ print ''; // Allow online signing print ''; print ''; -print ''; // Allow external download print ''; print ''; -print ''; print ''; diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index bc584f8a479..5a1e07d32ac 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -224,7 +224,7 @@ if ($action == 'edit') { foreach ($modules as $module => $delays) { if (isModEnabled($module)) { foreach ($delays as $delay) { - $value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']} : 0); + $value = getDolGlobalInt($delay['code']); print ''; print ''; print ''; print ''; print ''; diff --git a/htdocs/admin/delivery.php b/htdocs/admin/delivery.php index a901b0790b5..ff3f54ff4b0 100644 --- a/htdocs/admin/delivery.php +++ b/htdocs/admin/delivery.php @@ -266,7 +266,7 @@ if (!empty($conf->global->MAIN_SUBMODULE_DELIVERY)) { } print ''; // Show example of numbering module diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 9d265d0240d..91b7c3a00d0 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -8,7 +8,7 @@ * Copyright (C) 2011 Remy Younes * Copyright (C) 2012-2015 Marcos García * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2011-2022 Alexandre Spangaro + * Copyright (C) 2011-2023 Alexandre Spangaro * Copyright (C) 2015 Ferran Marcet * Copyright (C) 2016 Raphaël Doursenaud * Copyright (C) 2019-2022 Frédéric France @@ -54,6 +54,38 @@ $rowid = GETPOST('rowid', 'alpha'); $entity = GETPOST('entity', 'int'); $code = GETPOST('code', 'alpha'); +$acts = array(); $actl = array(); +$acts[0] = "activate"; +$acts[1] = "disable"; +$actl[0] = img_picto($langs->trans("Disabled"), 'switch_off', 'class="size15x"'); +$actl[1] = img_picto($langs->trans("Activated"), 'switch_on', 'class="size15x"'); + +// Load variable for pagination +$listoffset = GETPOST('listoffset'); +$listlimit = GETPOST('listlimit') > 0 ?GETPOST('listlimit') : 1000; // To avoid too long dictionaries +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + // If $page is not defined, or '' or -1 or if we click on clear filters + $page = 0; +} +$offset = $listlimit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; + +$search_country_id = GETPOST('search_country_id', 'int'); +$search_code = GETPOST('search_code', 'alpha'); +$search_active = GETPOST('search_active', 'alpha'); + +// Special case to set a default value for country according to dictionary +if (!GETPOSTISSET('search_country_id') && $search_country_id == '' && ($id == 2 || $id == 3 || $id == 10)) { // Not a so good idea to force on current country for all dictionaries. Some tables have entries that are for all countries, we must be able to see them, so this is done for dedicated dictionaries only. + $search_country_id = $mysoc->country_id; +} + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('admin', 'dictionaryadmin')); + $allowed = $user->admin; if ($id == 7 && $user->hasRight('accounting', 'chartofaccount')) { $allowed = 1; // Tax page allowed to manager of chart account @@ -68,34 +100,8 @@ if (!$allowed) { accessforbidden(); } -$acts = array(); $actl = array(); -$acts[0] = "activate"; -$acts[1] = "disable"; -$actl[0] = img_picto($langs->trans("Disabled"), 'switch_off', 'class="size15x"'); -$actl[1] = img_picto($langs->trans("Activated"), 'switch_on', 'class="size15x"'); +$permissiontoadd = $allowed; -$listoffset = GETPOST('listoffset'); -$listlimit = GETPOST('listlimit') > 0 ?GETPOST('listlimit') : 1000; // To avoid too long dictionaries -$active = 1; - -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 -$offset = $listlimit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; - -$search_country_id = GETPOST('search_country_id', 'int'); -if (!GETPOSTISSET('search_country_id') && $search_country_id == '' && ($id == 2 || $id == 3 || $id == 10)) { // Not a so good idea to force on current country for all dictionaries. Some tables have entries that are for all countries, we must be able to see them, so this is done for dedicated dictionaries only. - $search_country_id = $mysoc->country_id; -} -$search_code = GETPOST('search_code', 'alpha'); - -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('admin', 'dictionaryadmin')); // This page is a generic page to edit dictionaries // Put here declaration of dictionaries properties @@ -208,7 +214,7 @@ $tabsql[6] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.t $tabsql[7] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.accountancy_code as accountancy_code, c.code as country_code, c.label as country, a.fk_pays as country_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_pays = c.rowid and c.active = 1"; $tabsql[8] = "SELECT t.id as rowid, t.code as code, t.libelle, t.fk_country as country_id, c.code as country_code, c.label as country, t.position, t.active FROM ".MAIN_DB_PREFIX."c_typent as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON t.fk_country=c.rowid"; $tabsql[9] = "SELECT c.code_iso as code, c.label, c.unicode, c.active FROM ".MAIN_DB_PREFIX."c_currencies AS c"; -$tabsql[10] = "SELECT t.rowid, t.code, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, c.label as country, c.code as country_code, t.fk_pays as country_id, t.recuperableonly, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays = c.rowid"; +$tabsql[10] = "SELECT t.rowid, t.entity, t.code, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, c.label as country, c.code as country_code, t.fk_pays as country_id, t.recuperableonly, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays = c.rowid AND t.entity = ".getEntity($tabname[10]); $tabsql[11] = "SELECT t.rowid as rowid, t.element, t.source, t.code, t.libelle, t.position, t.active FROM ".MAIN_DB_PREFIX."c_type_contact AS t"; $tabsql[12] = "SELECT c.rowid as rowid, c.code, c.libelle, c.libelle_facture, c.deposit_percent, c.nbjour, c.type_cdr, c.decalage, c.active, c.sortorder, c.entity FROM ".MAIN_DB_PREFIX."c_payment_term AS c WHERE c.entity IN (".getEntity($tabname[12]).")"; $tabsql[13] = "SELECT c.id as rowid, c.code, c.libelle, c.type, c.active, c.entity FROM ".MAIN_DB_PREFIX."c_paiement AS c WHERE c.entity IN (".getEntity($tabname[13]).")"; @@ -396,7 +402,7 @@ $tabfieldinsert[6] = "code,libelle,type,color,position"; $tabfieldinsert[7] = "code,libelle,fk_pays,accountancy_code"; $tabfieldinsert[8] = "code,libelle,fk_country".(!empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? ',position' : ''); $tabfieldinsert[9] = "code_iso,label,unicode"; -$tabfieldinsert[10] = "fk_pays,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note"; +$tabfieldinsert[10] = "fk_pays,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note,entity"; $tabfieldinsert[11] = "element,source,code,libelle,position"; $tabfieldinsert[12] = "code,libelle,libelle_facture,deposit_percent,nbjour,type_cdr,decalage,sortorder,entity"; $tabfieldinsert[13] = "code,libelle,type,entity"; @@ -670,6 +676,7 @@ $localtax_typeList = array( ); + /* * Actions */ @@ -702,6 +709,7 @@ if ($reshook < 0) { if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) { $search_country_id = ''; $search_code = ''; + $search_active = ''; } if (empty($reshook)) { @@ -746,9 +754,9 @@ if (empty($reshook)) { && ($id != 10 || ($value != 'code' && $value != 'note')) // Field code and note is not mandatory for dictionary table 10 ) ) { - $ok = 0; - $fieldnamekey = $value; - // We take translate key of field + $ok = 0; + $fieldnamekey = $value; + // We take translate key of field if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) { $fieldnamekey = 'Label'; } @@ -998,6 +1006,13 @@ if (empty($reshook)) { setEventMessages($db->error(), null, 'errors'); } } + + if (!$ok && GETPOST('actionadd')) { + $action = 'create'; + } + if (!$ok && GETPOST('actionmodify')) { + $action = 'edit'; + } } if ($action == 'confirm_delete' && $confirm == 'yes') { // delete @@ -1168,7 +1183,6 @@ if (empty($reshook)) { */ $form = new Form($db); -$formadmin = new FormAdmin($db); $title = $langs->trans("DictionarySetup"); @@ -1189,22 +1203,16 @@ if ($id == 7 && GETPOST('from') == 'accountancy') { $titlepicto = 'accountancy'; } -print load_fiche_titre($title, $linkback, $titlepicto); - -if (empty($id)) { - print ''.$langs->trans("DictionaryDesc"); - print " ".$langs->trans("OnlyActiveElementsAreShown")."
\n"; - print '

'; -} - - $param = '&id='.urlencode($id); if ($search_country_id || GETPOSTISSET('page') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) { - $param .= '&search_country_id='.urlencode($search_country_id); + $param .= '&search_country_id='.urlencode($search_country_id ? $search_country_id : -1); } if ($search_code != '') { $param .= '&search_code='.urlencode($search_code); } +if ($search_active != '') { + $param .= '&search_active='.urlencode($search_active); +} if ($entity != '') { $param .= '&entity='.(int) $entity; } @@ -1225,37 +1233,55 @@ if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'rowid='.urlencode($rowid).'&code='.urlencode($code).$paramwithsearch, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); } -/* - * Show a dictionary - */ +// Show a dictionary if ($id > 0) { // Complete search values request with sort criteria - $sql = $tabsql[$id]; + $sqlfields = $tabsql[$id]; + $tablecode = ''; + $tableprefix = ''; + $tableprefixarray = array(9 => 'code_iso', 28 => 'h.code', 7 => 'a.code', 32 => 'a.code', 3 => 'r.code_region', 8 => 't.code', 10 => 't.code', 1 => 'f.code', 2 => 'd.code_departement', 14 => 'e.code'); + if (!empty($tableprefixarray[$id])) { + $tablecode = $tableprefixarray[$id]; + $tableprefix = preg_replace('/\..*$/', '.', $tablecode); + } + + $sql = $sqlfields; if (!preg_match('/ WHERE /', $sql)) { $sql .= " WHERE 1 = 1"; } if ($search_country_id > 0) { $sql .= " AND c.rowid = ".((int) $search_country_id); } - if ($search_code != '' && $id == 9) { - $sql .= natural_search("code_iso", $search_code); - } elseif ($search_code != '' && $id == 28) { - $sql .= natural_search("h.code", $search_code); - } elseif ($search_code != '' && ($id == 7 || $id == 32)) { - $sql .= natural_search("a.code", $search_code); - } elseif ($search_code != '' && $id == 3) { - $sql .= natural_search("r.code_region", $search_code); - } elseif ($search_code != '' && ($id == 8 || $id == 10)) { - $sql .= natural_search("t.code", $search_code); - } elseif ($search_code != '' && $id == 1) { - $sql .= natural_search("f.code", $search_code); - } elseif ($search_code != '' && $id == 2) { - $sql .= natural_search("d.code_departement", $search_code); - } elseif ($search_code != '' && $id == 14) { - $sql .= natural_search("e.code", $search_code); - } elseif ($search_code != '' && $id != 9) { - $sql .= natural_search("code", $search_code); + if ($search_code != '') { + $sql .= natural_search($tablecode, $search_code); + } + if ($search_active == 'yes') { + $sql .= " AND ".$tableprefix."active = 1"; + } elseif ($search_active == 'no') { + $sql .= " AND ".$tableprefix."active = 0"; + } + //print $sql; + + // Count total nb of records + $nbtotalofrecords = ''; + if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { + /* The fast and low memory method to get and count full list converts the sql into a sql count */ + $sqlforcount = preg_replace('/^.*\sFROM\s/', 'SELECT COUNT(*) as nbtotalofrecords FROM ', $sql); + $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); + $resql = $db->query($sqlforcount); + if ($resql) { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + } else { + dol_print_error($db); + } + + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0 + $page = 0; + $offset = 0; + } + $db->free($resql); } if ($sortfield) { @@ -1272,7 +1298,16 @@ if ($id > 0) { $sql .= " ORDER BY "; } $sql .= $tabsqlsort[$id]; + $sql .= $db->plimit($listlimit + 1, $offset); + + $resql = $db->query($sql); + if (!$resql) { + dol_print_error($db); + exit; + } + $num = $db->num_rows($resql); + //print $sql; if (empty($tabfield[$id])) { @@ -1285,328 +1320,12 @@ if ($id > 0) { print ''; print ''; + // Special warning for VAT dictionary if ($id == 10 && empty($conf->global->FACTURE_TVAOPTION)) { print info_admin($langs->trans("VATIsUsedIsOff", $langs->transnoentities("Setup"), $langs->transnoentities("CompanyFoundation"))); print "
\n"; } - // Form to add a new line - if ($tabname[$id]) { - $withentity = null; - - $fieldlist = explode(',', $tabfield[$id]); - - print '
'; - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").''.$langs->trans("Value").'
'; print $form->textwithpicto($langs->trans("WatermarkOnDraftContractCards"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
'; -print '
'; +print ''; print ''; print '
'.$langs->trans("HideClosedServiceByDefault").''; +print ''; print $form->selectyesno("activate_hideClosedServiceByDefault", (!empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) ? $conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT : 0), 1); print '
'.$langs->trans("AllowOnlineSign").''; +print ''; if (getDolGlobalString('CONTRACT_ALLOW_ONLINESIGN')) { print ''; print img_picto($langs->trans("Activited"), 'switch_on'); @@ -533,7 +533,7 @@ print '
'.$langs->trans("AllowExternalDownload").''; +print ''; print ajax_constantonoff('CONTRACT_ALLOW_EXTERNAL_DOWNLOAD', array(), null, 0, 0, 0, 2, 0, 1); print '
' . img_object('', $delay['img']) . '' . $langs->trans('Delays_' . $delay['code']) . ''; @@ -258,7 +258,7 @@ if ($action == 'edit') { foreach ($modules as $module => $delays) { if (isModEnabled($module)) { foreach ($delays as $delay) { - $value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']} : 0); + $value = getDolGlobalInt($delay['code']); print '
' . img_object('', $delay['img']) . '' . $langs->trans('Delays_' . $delay['code']) . '
'.$module->name."\n"; - print $module->info(); + print $module->info($langs); print '
'; - - // Line for title - print ''; - $tdsoffields = ''; - foreach ($fieldlist as $field => $value) { - if ($value == 'entity') { - $withentity = getEntity($tabname[$id]); - continue; - } - - // Define field friendly name from its technical name - $valuetoshow = ucfirst($value); // Par defaut - $valuetoshow = $langs->trans($valuetoshow); // try to translate - $class = ''; - - if ($value == 'pos') { - $valuetoshow = $langs->trans("Position"); $class = 'right'; - } - if ($value == 'source') { - $valuetoshow = $langs->trans("Contact"); - } - if ($value == 'price') { - $valuetoshow = $langs->trans("PriceUHT"); - } - if ($value == 'taux') { - if ($tabname[$id] != "c_revenuestamp") { - $valuetoshow = $langs->trans("Rate"); - } else { - $valuetoshow = $langs->trans("Amount"); - } - $class = 'center'; - } - if ($value == 'localtax1_type') { - $valuetoshow = $langs->trans("UseLocalTax")." 2"; $class = "center"; $sortable = 0; - } - if ($value == 'localtax1') { - $valuetoshow = $langs->trans("RateOfTaxN", '2'); $class = "center"; - } - if ($value == 'localtax2_type') { - $valuetoshow = $langs->trans("UseLocalTax")." 3"; $class = "center"; $sortable = 0; - } - if ($value == 'localtax2') { - $valuetoshow = $langs->trans("RateOfTaxN", '3'); $class = "center"; - } - if ($value == 'organization') { - $valuetoshow = $langs->trans("Organization"); - } - if ($value == 'lang') { - $valuetoshow = $langs->trans("Language"); - } - if ($value == 'type') { - if ($tabname[$id] == "c_paiement") { - $valuetoshow = $form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, '')); - } else { - $valuetoshow = $langs->trans("Type"); - } - } - if ($value == 'code') { - $valuetoshow = $langs->trans("Code"); $class = 'maxwidth100'; - } - if ($value == 'libelle' || $value == 'label') { - $valuetoshow = $form->textwithtooltip($langs->trans("Label"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, '')); - } - if ($value == 'libelle_facture') { - $valuetoshow = $form->textwithtooltip($langs->trans("LabelOnDocuments"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, '')); - } - if ($value == 'deposit_percent') { - $valuetoshow = $langs->trans('DepositPercent'); - $class = 'right'; - } - if ($value == 'country') { - if (in_array('region_id', $fieldlist)) { - //print ''; - continue; - } // For region page, we do not show the country input - $valuetoshow = $langs->trans("Country"); - } - if ($value == 'recuperableonly') { - $valuetoshow = $langs->trans("NPR"); $class = "center"; - } - if ($value == 'nbjour') { - $valuetoshow = $langs->trans("NbOfDays"); - $class = 'right'; - } - if ($value == 'type_cdr') { - $valuetoshow = $langs->trans("AtEndOfMonth"); $class = "center"; - } - if ($value == 'decalage') { - $valuetoshow = $langs->trans("Offset"); - $class = 'right'; - } - if ($value == 'width' || $value == 'nx') { - $valuetoshow = $langs->trans("Width"); - } - if ($value == 'height' || $value == 'ny') { - $valuetoshow = $langs->trans("Height"); - } - if ($value == 'unit' || $value == 'metric') { - $valuetoshow = $langs->trans("MeasuringUnit"); - } - if ($value == 'region_id' || $value == 'country_id') { - $valuetoshow = ''; - } - if ($value == 'accountancy_code') { - $valuetoshow = $langs->trans("AccountancyCode"); - } - if ($value == 'accountancy_code_sell') { - $valuetoshow = $langs->trans("AccountancyCodeSell"); - } - if ($value == 'accountancy_code_buy') { - $valuetoshow = $langs->trans("AccountancyCodeBuy"); - } - if ($value == 'pcg_version' || $value == 'fk_pcg_version') { - $valuetoshow = $langs->trans("Pcg_version"); - } - if ($value == 'account_parent') { - $valuetoshow = $langs->trans("Accountparent"); - } - if ($value == 'pcg_type') { - $valuetoshow = $langs->trans("Pcg_type"); - } - if ($value == 'pcg_subtype') { - $valuetoshow = $langs->trans("Pcg_subtype"); - } - if ($value == 'sortorder') { - $valuetoshow = $langs->trans("SortOrder"); - $class = 'center'; - } - if ($value == 'short_label') { - $valuetoshow = $langs->trans("ShortLabel"); - } - if ($value == 'fk_parent') { - $valuetoshow = $langs->trans("ParentID"); $class = 'center'; - } - if ($value == 'range_account') { - $valuetoshow = $langs->trans("Range"); - } - if ($value == 'sens') { - $valuetoshow = $langs->trans("Sens"); - } - if ($value == 'category_type') { - $valuetoshow = $langs->trans("Calculated"); - } - if ($value == 'formula') { - $valuetoshow = $langs->trans("Formula"); - } - if ($value == 'paper_size') { - $valuetoshow = $langs->trans("PaperSize"); - } - if ($value == 'orientation') { - $valuetoshow = $langs->trans("Orientation"); - } - if ($value == 'leftmargin') { - $valuetoshow = $langs->trans("LeftMargin"); - } - if ($value == 'topmargin') { - $valuetoshow = $langs->trans("TopMargin"); - } - if ($value == 'spacex') { - $valuetoshow = $langs->trans("SpaceX"); - } - if ($value == 'spacey') { - $valuetoshow = $langs->trans("SpaceY"); - } - if ($value == 'font_size') { - $valuetoshow = $langs->trans("FontSize"); - } - if ($value == 'custom_x') { - $valuetoshow = $langs->trans("CustomX"); - } - if ($value == 'custom_y') { - $valuetoshow = $langs->trans("CustomY"); - } - if ($value == 'percent') { - $valuetoshow = $langs->trans("Percentage"); - } - if ($value == 'affect') { - $valuetoshow = $langs->trans("WithCounter"); - } - if ($value == 'delay') { - $valuetoshow = $langs->trans("NoticePeriod"); - } - if ($value == 'newbymonth') { - $valuetoshow = $langs->trans("NewByMonth"); - } - if ($value == 'fk_tva') { - $valuetoshow = $langs->trans("VAT"); - } - if ($value == 'range_ik') { - $valuetoshow = $langs->trans("RangeIk"); - } - if ($value == 'fk_c_exp_tax_cat') { - $valuetoshow = $langs->trans("CarCategory"); - } - if ($value == 'revenuestamp_type') { - $valuetoshow = $langs->trans('TypeOfRevenueStamp'); - } - if ($value == 'use_default') { - $valuetoshow = $langs->trans('Default'); $class = 'center'; - } - if ($value == 'unit_type') { - $valuetoshow = $langs->trans('TypeOfUnit'); - } - if ($value == 'public' && $tablib[$id] == 'TicketDictCategory') { - $valuetoshow = $langs->trans('TicketGroupIsPublic'); $class = 'center'; - } - if ($value == 'block_if_negative') { - $valuetoshow = $langs->trans('BlockHolidayIfNegative'); - } - if ($value == 'type_duration') { - $valuetoshow = $langs->trans('Unit'); - } - - if ($id == 2) { // Special case for state page - if ($value == 'region_id') { - $valuetoshow = ' '; $showfield = 1; - } - if ($value == 'region') { - $valuetoshow = $langs->trans("Country").'/'.$langs->trans("Region"); $showfield = 1; - } - } - - if ($valuetoshow != '') { - $tooltiphelp = (isset($tabcomplete[$tabname[$id]]['help'][$value]) ? $tabcomplete[$tabname[$id]]['help'][$value] : ''); - - $tdsoffields .= ''; - if ($tooltiphelp && preg_match('/^http(s*):/i', $tooltiphelp)) { - $tdsoffields .= ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; - } elseif ($tooltiphelp) { - $tdsoffields .= $form->textwithpicto($valuetoshow, $tooltiphelp); - } else { - $tdsoffields .= $valuetoshow; - } - $tdsoffields .= ''; - } - } - - if ($id == 4) { - $tdsoffields .= ''; - $tdsoffields .= ''; - } - $tdsoffields .= ''; - $tdsoffields .= ''; - $tdsoffields .= ''; - $tdsoffields .= ''; - - print $tdsoffields; - - - // Line to enter new values - print ''; - print ''; - - $obj = new stdClass(); - // If data was already input, we define them in obj to populate input fields. - if (GETPOST('actionadd')) { - foreach ($fieldlist as $key => $val) { - if (GETPOST($val) != '') { - $obj->$val = GETPOST($val); - } - } - } - - $tmpaction = 'create'; - $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks - $error = $hookmanager->error; $errors = $hookmanager->errors; - - if ($id == 3) { - unset($fieldlist[2]); // Remove field ??? if dictionary Regions - } - - if (empty($reshook)) { - fieldList($fieldlist, $obj, $tabname[$id], 'add'); - } - - if ($id == 4) { - print ''; - print ''; - } - print ''; - - print ""; - - print '
 '; - $tdsoffields .= ''; - if (!is_null($withentity)) { - $tdsoffields .= ''; - } - $tdsoffields .= '
'; - if ($action != 'edit') { - print ''; - } else { - print ''; - } - print '
'; - print '
'; - } - - print ''; - - - print '
'; - - - print '
'; - print ''; - print ''; - // List of available record in database dol_syslog("htdocs/admin/dict", LOG_DEBUG); @@ -1615,12 +1334,336 @@ if ($id > 0) { $num = $db->num_rows($resql); $i = 0; - // There is several pages - if (($num > $listlimit) || $page) { - print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), ''); - print '
'; + $massactionbutton = $linkback; + + $newcardbutton = ''; + /*$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitleSeparator(); + */ + $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/admin/dict.php?action=create'.$param.'&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); + + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'tools', 0, $newcardbutton, '', $listlimit, 1, 0, 1); + + + if ($action == 'create') { + // Form to add a new line + if ($tabname[$id]) { + $withentity = null; + + $fieldlist = explode(',', $tabfield[$id]); + + print '
'; + print ''; + + // Line for title + print ''; + $tdsoffields = ''; + foreach ($fieldlist as $field => $value) { + if ($value == 'entity') { + $withentity = getEntity($tabname[$id]); + continue; + } + + // Define field friendly name from its technical name + $valuetoshow = ucfirst($value); // Par defaut + $valuetoshow = $langs->trans($valuetoshow); // try to translate + $class = ''; + + if ($value == 'pos') { + $valuetoshow = $langs->trans("Position"); $class = 'right'; + } + if ($value == 'source') { + $valuetoshow = $langs->trans("Contact"); + } + if ($value == 'price') { + $valuetoshow = $langs->trans("PriceUHT"); + } + if ($value == 'taux') { + if ($tabname[$id] != "c_revenuestamp") { + $valuetoshow = $langs->trans("Rate"); + } else { + $valuetoshow = $langs->trans("Amount"); + } + $class = 'center'; + } + if ($value == 'localtax1_type') { + $valuetoshow = $langs->trans("UseLocalTax")." 2"; $class = "center"; $sortable = 0; + } + if ($value == 'localtax1') { + $valuetoshow = $langs->trans("RateOfTaxN", '2'); $class = "center"; + } + if ($value == 'localtax2_type') { + $valuetoshow = $langs->trans("UseLocalTax")." 3"; $class = "center"; $sortable = 0; + } + if ($value == 'localtax2') { + $valuetoshow = $langs->trans("RateOfTaxN", '3'); $class = "center"; + } + if ($value == 'organization') { + $valuetoshow = $langs->trans("Organization"); + } + if ($value == 'lang') { + $valuetoshow = $langs->trans("Language"); + } + if ($value == 'type') { + if ($tabname[$id] == "c_paiement") { + $valuetoshow = $form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, '')); + } else { + $valuetoshow = $langs->trans("Type"); + } + } + if ($value == 'code') { + $valuetoshow = $langs->trans("Code"); $class = 'maxwidth100'; + } + if ($value == 'libelle' || $value == 'label') { + $valuetoshow = $form->textwithtooltip($langs->trans("Label"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, '')); + } + if ($value == 'libelle_facture') { + $valuetoshow = $form->textwithtooltip($langs->trans("LabelOnDocuments"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, '')); + } + if ($value == 'deposit_percent') { + $valuetoshow = $langs->trans('DepositPercent'); + $class = 'right'; + } + if ($value == 'country') { + if (in_array('region_id', $fieldlist)) { + //print ''; + continue; + } // For region page, we do not show the country input + $valuetoshow = $langs->trans("Country"); + } + if ($value == 'recuperableonly') { + $valuetoshow = $langs->trans("NPR"); $class = "center"; + } + if ($value == 'nbjour') { + $valuetoshow = $langs->trans("NbOfDays"); + $class = 'right'; + } + if ($value == 'type_cdr') { + $valuetoshow = $langs->trans("AtEndOfMonth"); $class = "center"; + } + if ($value == 'decalage') { + $valuetoshow = $langs->trans("Offset"); + $class = 'right'; + } + if ($value == 'width' || $value == 'nx') { + $valuetoshow = $langs->trans("Width"); + } + if ($value == 'height' || $value == 'ny') { + $valuetoshow = $langs->trans("Height"); + } + if ($value == 'unit' || $value == 'metric') { + $valuetoshow = $langs->trans("MeasuringUnit"); + } + if ($value == 'region_id' || $value == 'country_id') { + $valuetoshow = ''; + } + if ($value == 'accountancy_code') { + $valuetoshow = $langs->trans("AccountancyCode"); + } + if ($value == 'accountancy_code_sell') { + $valuetoshow = $langs->trans("AccountancyCodeSell"); + } + if ($value == 'accountancy_code_buy') { + $valuetoshow = $langs->trans("AccountancyCodeBuy"); + } + if ($value == 'pcg_version' || $value == 'fk_pcg_version') { + $valuetoshow = $langs->trans("Pcg_version"); + } + if ($value == 'account_parent') { + $valuetoshow = $langs->trans("Accountparent"); + } + if ($value == 'pcg_type') { + $valuetoshow = $langs->trans("Pcg_type"); + } + if ($value == 'pcg_subtype') { + $valuetoshow = $langs->trans("Pcg_subtype"); + } + if ($value == 'sortorder') { + $valuetoshow = $langs->trans("SortOrder"); + $class = 'center'; + } + if ($value == 'short_label') { + $valuetoshow = $langs->trans("ShortLabel"); + } + if ($value == 'fk_parent') { + $valuetoshow = $langs->trans("ParentID"); $class = 'center'; + } + if ($value == 'range_account') { + $valuetoshow = $langs->trans("Range"); + } + if ($value == 'sens') { + $valuetoshow = $langs->trans("Sens"); + } + if ($value == 'category_type') { + $valuetoshow = $langs->trans("Calculated"); + } + if ($value == 'formula') { + $valuetoshow = $langs->trans("Formula"); + } + if ($value == 'paper_size') { + $valuetoshow = $langs->trans("PaperSize"); + } + if ($value == 'orientation') { + $valuetoshow = $langs->trans("Orientation"); + } + if ($value == 'leftmargin') { + $valuetoshow = $langs->trans("LeftMargin"); + } + if ($value == 'topmargin') { + $valuetoshow = $langs->trans("TopMargin"); + } + if ($value == 'spacex') { + $valuetoshow = $langs->trans("SpaceX"); + } + if ($value == 'spacey') { + $valuetoshow = $langs->trans("SpaceY"); + } + if ($value == 'font_size') { + $valuetoshow = $langs->trans("FontSize"); + } + if ($value == 'custom_x') { + $valuetoshow = $langs->trans("CustomX"); + } + if ($value == 'custom_y') { + $valuetoshow = $langs->trans("CustomY"); + } + if ($value == 'percent') { + $valuetoshow = $langs->trans("Percentage"); + } + if ($value == 'affect') { + $valuetoshow = $langs->trans("WithCounter"); + } + if ($value == 'delay') { + $valuetoshow = $langs->trans("NoticePeriod"); + } + if ($value == 'newbymonth') { + $valuetoshow = $langs->trans("NewByMonth"); + } + if ($value == 'fk_tva') { + $valuetoshow = $langs->trans("VAT"); + } + if ($value == 'range_ik') { + $valuetoshow = $langs->trans("RangeIk"); + } + if ($value == 'fk_c_exp_tax_cat') { + $valuetoshow = $langs->trans("CarCategory"); + } + if ($value == 'revenuestamp_type') { + $valuetoshow = $langs->trans('TypeOfRevenueStamp'); + } + if ($value == 'use_default') { + $valuetoshow = $langs->trans('Default'); $class = 'center'; + } + if ($value == 'unit_type') { + $valuetoshow = $langs->trans('TypeOfUnit'); + } + if ($value == 'public' && $tablib[$id] == 'TicketDictCategory') { + $valuetoshow = $langs->trans('TicketGroupIsPublic'); $class = 'center'; + } + if ($value == 'block_if_negative') { + $valuetoshow = $langs->trans('BlockHolidayIfNegative'); + } + if ($value == 'type_duration') { + $valuetoshow = $langs->trans('Unit'); + } + + if ($id == 2) { // Special case for state page + if ($value == 'region_id') { + $valuetoshow = ' '; + $showfield = 1; + } + if ($value == 'region') { + $valuetoshow = $langs->trans("Country").'/'.$langs->trans("Region"); + $showfield = 1; + } + } + + if ($valuetoshow != '') { + $tooltiphelp = (isset($tabcomplete[$tabname[$id]]['help'][$value]) ? $tabcomplete[$tabname[$id]]['help'][$value] : ''); + + $tdsoffields .= ''; + if ($tooltiphelp && preg_match('/^http(s*):/i', $tooltiphelp)) { + $tdsoffields .= ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; + } elseif ($tooltiphelp) { + $tdsoffields .= $form->textwithpicto($valuetoshow, $tooltiphelp); + } else { + $tdsoffields .= $valuetoshow; + } + $tdsoffields .= ''; + } + } + + if ($id == 4) { + $tdsoffields .= ''; + $tdsoffields .= ''; + } + $tdsoffields .= ''; + $tdsoffields .= ''; + $tdsoffields .= ''; + $tdsoffields .= ''; + + print $tdsoffields; + + + // Line to enter new values + print ''; + print ''; + + $obj = new stdClass(); + // If data was already input, we define them in obj to populate input fields. + if (GETPOST('actionadd')) { + foreach ($fieldlist as $key => $val) { + if (GETPOST($val) != '') { + $obj->$val = GETPOST($val); + } + } + } + + $tmpaction = 'create'; + $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $error = $hookmanager->error; $errors = $hookmanager->errors; + + if ($id == 3) { + unset($fieldlist[2]); // Remove field ??? if dictionary Regions + } + + if (empty($reshook)) { + fieldList($fieldlist, $obj, $tabname[$id], 'add'); + } + + if ($id == 4) { + print ''; + print ''; + } + print ''; + + print ""; + + print '
 '; + $tdsoffields .= ''; + if (!is_null($withentity)) { + $tdsoffields .= ''; + } + $tdsoffields .= '
'; + if ($action != 'edit') { + print ''; + } else { + print ''; + } + print '
'; + print '
'; + } + + print '
'; + + print '
'; + print ''; + print ''; } + $filterfound = 0; foreach ($fieldlist as $field => $value) { if ($value == 'entity') { @@ -1674,7 +1717,7 @@ if ($id > 0) { if ($showfield) { if ($value == 'country') { print ''; - print $form->select_country($search_country_id, 'search_country_id', '', 28, 'minwidth100 maxwidth150 maxwidthonsmartphone'); + print $form->select_country($search_country_id, 'search_country_id', '', 28, 'minwidth100 maxwidth150 maxwidthonsmartphone', '', ' '); print ''; $colspan++; } elseif ($value == 'code') { @@ -1696,7 +1739,10 @@ if ($id > 0) { $colspan++; } - print ''; + // Active + print ''; + print $form->selectyesno('search_active', $search_active, 0, false, 1); + print ''; $colspan++; // Action button @@ -2233,8 +2279,6 @@ if ($id > 0) { $langs->load('other'); $key = $langs->trans($obj->label); $valuetoshow = ($obj->label && $key != strtoupper($obj->label) ? $key : $obj->{$value}); - /*} elseif ($value == 'code' && $id == 3) { - $valuetoshow = $obj->state_code; */ } elseif ($value == 'label' && $tabname[$id] == 'c_product_nature') { $langs->load("products"); $valuetoshow = $langs->trans($obj->{$value}); @@ -2350,6 +2394,11 @@ if ($id > 0) { /* * Show list of dictionary to show */ + print load_fiche_titre($title, $linkback, $titlepicto); + + print ''.$langs->trans("DictionaryDesc"); + print " ".$langs->trans("OnlyActiveElementsAreShown")."
\n"; + print '

'; $lastlineisempty = false; diff --git a/htdocs/admin/dolistore/class/dolistore.class.php b/htdocs/admin/dolistore/class/dolistore.class.php index 37cfb53d493..1563f7364f0 100644 --- a/htdocs/admin/dolistore/class/dolistore.class.php +++ b/htdocs/admin/dolistore/class/dolistore.class.php @@ -41,6 +41,7 @@ class Dolistore public $per_page; // pagination: display per page public $categorie; // the current categorie + public $categories; // an array of categories public $search; // the search keywords // setups @@ -49,6 +50,8 @@ class Dolistore public $lang; // the integer representing the lang in the store public $debug_api; // usefull if no dialog + public $api; + public $products; /** * Constructor @@ -57,7 +60,7 @@ class Dolistore */ public function __construct($debug = false) { - global $conf, $langs; + global $langs; $this->url = DOL_URL_ROOT.'/admin/modules.php?mode=marketplace'; $this->shop_url = 'https://www.dolistore.com/index.php?controller=product&id_product='; diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index 2ffb966828b..41d5d56162b 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -437,7 +437,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php'); print ''.$module->name."\n"; - print $module->info(); + print $module->info($langs); print ''; // Show example of numbering model diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 1db6a9cc9d6..31ed39baab3 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -212,7 +212,7 @@ foreach ($dirmodels as $reldir) { print ''.$module->name."\n"; print ''; - print $module->info(); + print $module->info($langs); print ''; // Show example of numbering module diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index 25bef9fde22..288c717c28e 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -232,7 +232,7 @@ foreach ($dirmodels as $reldir) { if ($module->isEnabled()) { print ''.$module->nom."\n"; - print $module->info(); + print $module->info($langs); print ''; // Show example of numbering model diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index a7173f31855..1dbd4cee9b1 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -342,7 +342,7 @@ foreach ($dirmodels as $reldir) { echo preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file))); print "\n"; - print $module->info(); + print $module->info($langs); print ''; @@ -635,7 +635,7 @@ if (!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) { // Hidden conf foreach ($listtype as $type => $trans) { $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type; - $current = !empty($conf->global->{$thisTypeConfName}) ? $conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF; + $current = getDolGlobalString($thisTypeConfName, getDolGlobalString('FACTURE_ADDON_PDF')); print ''; print ''.$trans.''; print ''.$form->selectarray('invoicetypemodels['.$type.']', ModelePDFFactures::liste_modeles($db), $current, 0, 0, 0).''; diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php index ff7178a9ed3..2b5644a0642 100644 --- a/htdocs/admin/fckeditor.php +++ b/htdocs/admin/fckeditor.php @@ -57,6 +57,7 @@ $modules = array( 'MAILING' => 'FCKeditorForMailing', 'MAIL' => 'FCKeditorForMail', 'TICKET' => 'FCKeditorForTicket', + 'SPECIALCHAR' => 'SpecialChar activation', ); // Conditions for the option to be offered $conditions = array( @@ -69,6 +70,7 @@ $conditions = array( 'MAILING' => isModEnabled('mailing'), 'MAIL' => (isModEnabled('facture') || isModEnabled("propal") || isModEnabled('commande')), 'TICKET' => isModEnabled('ticket'), + 'SPECIALCHAR' => 1, ); // Picto $picto = array( @@ -81,6 +83,7 @@ $picto = array( 'MAILING' => 'email', 'MAIL' => 'email', 'TICKET' => 'ticket', + 'SPECIALCHAR' => 'generic' ); @@ -92,6 +95,7 @@ $picto = array( foreach ($modules as $const => $desc) { if ($action == 'enable_'.strtolower($const)) { dolibarr_set_const($db, "FCKEDITOR_ENABLE_".$const, "1", 'chaine', 0, '', $conf->entity); + // If fckeditor is active in the product/service description, it is activated in the forms if ($const == 'PRODUCTDESC' && getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE')) { dolibarr_set_const($db, "FCKEDITOR_ENABLE_DETAILS", "1", 'chaine', 0, '', $conf->entity); @@ -221,6 +225,7 @@ if (empty($conf->use_javascript_ajax)) { $editor = new DolEditor('formtestfield', isset($conf->global->FCKEDITOR_TEST) ? $conf->global->FCKEDITOR_TEST : 'Test', '', 200, $mode, 'In', true, $uselocalbrowser, 1, 120, 8, $readonly); $editor->Create(); } else { + // CKEditor inline enabled with the contenteditable="true" print '
'; print $conf->global->FCKEDITOR_TEST; print '
'; diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 2e331b3cc80..3df2f7b8c52 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -303,7 +303,7 @@ foreach ($dirmodels as $reldir) { print ''.$module->nom."\n"; - print $module->info(); + print $module->info($langs); print ''; // Show example of numbering model diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php index b85e257c69e..3b6149f3745 100644 --- a/htdocs/admin/holiday.php +++ b/htdocs/admin/holiday.php @@ -213,7 +213,7 @@ foreach ($dirmodels as $reldir) { if ($module->isEnabled()) { print ''.$module->nom."\n"; - print $module->info(); + print $module->info($langs); print ''; // Show example of numbering model diff --git a/htdocs/admin/hrm.php b/htdocs/admin/hrm.php index 076917dcbbe..06cab9b0249 100644 --- a/htdocs/admin/hrm.php +++ b/htdocs/admin/hrm.php @@ -259,7 +259,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php'); print ''.$module->name."\n"; - print $module->info(); + print $module->info($langs); print ''; // Show example of numbering model @@ -521,7 +521,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'; @@ -529,13 +529,13 @@ 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 ''; + print ''; if (!empty($conf->use_javascript_ajax)) { print ' ' . img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token' . $constname . '" class="linkobject"'); } @@ -549,7 +549,7 @@ if ($action == 'edit') { $form->select_produits($selected, $constname, '', 0); } } else { - print ''; + print ''; } print ''; } @@ -605,18 +605,18 @@ 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 (getDolGlobalString($constname) == 1) { print $langs->trans("Customer"); - } elseif ($conf->global->{$constname}==0) { + } elseif (getDolGlobalString($constname) == 0) { print $langs->trans("NorProspectNorCustomer"); } } elseif ($val['type'] == 'product') { $product = new Product($db); - $resprod = $product->fetch($conf->global->{$constname}); + $resprod = $product->fetch(getDolGlobalString($constname)); if ($resprod > 0) { print $product->ref; } elseif ($resprod < 0) { diff --git a/htdocs/admin/knowledgemanagement.php b/htdocs/admin/knowledgemanagement.php index 3fc8ebb3724..3cccf92a781 100644 --- a/htdocs/admin/knowledgemanagement.php +++ b/htdocs/admin/knowledgemanagement.php @@ -236,7 +236,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'; @@ -244,13 +244,13 @@ 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); } else { - print ''; + print ''; } print ''; } @@ -293,7 +293,7 @@ if ($action == 'edit') { 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'); } @@ -385,7 +385,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php'); print ''.$module->name."\n"; - print $module->info(); + print $module->info($langs); print ''; // Show example of numbering model diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php index f5096960b8b..647f1688ddf 100644 --- a/htdocs/admin/ldap.php +++ b/htdocs/admin/ldap.php @@ -65,6 +65,9 @@ if (empty($reshook)) { if (!dolibarr_set_const($db, 'LDAP_SERVER_TYPE', GETPOST("type", 'aZ09'), 'chaine', 0, '', $conf->entity)) { $error++; } + if (!dolibarr_set_const($db, 'LDAP_USERACCOUNTCONTROL', GETPOST("userAccountControl", 'int'), 'chaine', 0, '', $conf->entity)) { + $error++; + } if (!dolibarr_set_const($db, 'LDAP_SERVER_PROTOCOLVERSION', GETPOST("LDAP_SERVER_PROTOCOLVERSION", 'aZ09'), 'chaine', 0, '', $conf->entity)) { $error++; } @@ -195,6 +198,11 @@ print ''.$langs->trans("Type").''; print $formldap->selectLdapServerType(getDolGlobalString('LDAP_SERVER_TYPE'), 'type'); print ' '; +// userAccountControl +print ''.$langs->trans("LDAPUserAccountControl").''; +print ''; +print ''.$langs->trans("LDAPUserAccountControlExample").''; + // Version print ''.$langs->trans("Version").''; print $formldap->selectLdapServerProtocolVersion(getDolGlobalString('LDAP_SERVER_PROTOCOLVERSION'), 'LDAP_SERVER_PROTOCOLVERSION'); diff --git a/htdocs/admin/ldap_contacts.php b/htdocs/admin/ldap_contacts.php index 6ee7b38e0b8..3f0742bd186 100644 --- a/htdocs/admin/ldap_contacts.php +++ b/htdocs/admin/ldap_contacts.php @@ -82,9 +82,6 @@ if ($action == 'setvalue' && $user->admin) { if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) { $error++; } - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) { - $error++; - } if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) { $error++; } @@ -237,13 +234,6 @@ print ''.$langs->trans("LDAPFieldMobileExample").''; print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_MOBILE ? ' checked' : '').">"; print ''; -// Skype -print ''.$langs->trans("LDAPFieldSkype").''; -print ''; -print ''.$langs->trans("LDAPFieldSkypeExample").''; -print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_SKYPE ? ' checked' : '').">"; -print ''; - // Fax print ''.$langs->trans("LDAPFieldFax").''; print ''; diff --git a/htdocs/admin/ldap_members.php b/htdocs/admin/ldap_members.php index b9461430bf9..dc30f971c09 100644 --- a/htdocs/admin/ldap_members.php +++ b/htdocs/admin/ldap_members.php @@ -95,9 +95,6 @@ if ($action == 'setvalue' && $user->admin) { if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) { $error++; } - if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) { - $error++; - } if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) { $error++; } @@ -314,13 +311,6 @@ print ''.$langs->trans("LDAPFieldMobileExample").''; print ' '; print ''; -// Skype -print ''.$langs->trans("LDAPFieldSkype").''; -print ''; -print ''.$langs->trans("LDAPFieldSkypeExample").''; -print ' '; -print ''; - // Fax print ''.$langs->trans("LDAPFieldFax").''; print ''; diff --git a/htdocs/admin/ldap_users.php b/htdocs/admin/ldap_users.php index ad84a5889ed..d2c287aef78 100644 --- a/htdocs/admin/ldap_users.php +++ b/htdocs/admin/ldap_users.php @@ -91,9 +91,6 @@ if ($action == 'setvalue' && $user->admin) { if (!dolibarr_set_const($db, 'LDAP_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) { $error++; } - if (!dolibarr_set_const($db, 'LDAP_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) { - $error++; - } if (!dolibarr_set_const($db, 'LDAP_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) { $error++; } @@ -294,13 +291,6 @@ print ''.$langs->trans("LDAPFieldMobileExample").''; print '"; print ''; -// Skype -print ''.$langs->trans("LDAPFieldSkype").''; -print ''; -print ''.$langs->trans("LDAPFieldSkypeExample").''; -print '"; -print ''; - // Fax print ''.$langs->trans("LDAPFieldFax").''; print ''; diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php index 03efcf7aea5..06dfa06ce1a 100644 --- a/htdocs/admin/limits.php +++ b/htdocs/admin/limits.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007-2022 Laurent Destailleur * Copyright (C) 2009-2018 Regis Houssin * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2023 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -262,6 +263,7 @@ if (empty($mysoc->country_code)) { $sql = "SELECT taux as vat_rate, t.code as vat_code, t.localtax1 as localtax_rate1, t.localtax2 as localtax_rate2"; $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; $sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$db->escape($mysoc->country_code)."' AND (t.taux <> 0 OR t.localtax1 <> '0' OR t.localtax2 <> '0')"; + $sql .= " AND t.entity IN (".getEntity('c_tva').")"; $sql .= " ORDER BY t.taux ASC"; $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index 82d05113b8b..8a276d68e27 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -598,7 +598,7 @@ if ($action == 'edit') { print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } } else { - print yn(0).' ('.$langs->trans("NotSupported").')'; + print ''.yn(0).' ('.$langs->trans("NotSupported").')'; } print ''; @@ -611,7 +611,7 @@ if ($action == 'edit') { print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } } else { - print yn(0).' ('.$langs->trans("NotSupported").')'; + print ''.yn(0).' ('.$langs->trans("NotSupported").')'; } print ''; } diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 6d0267f802a..4a7c644df19 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -116,14 +116,14 @@ if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { // Nom des champs d'edition pour modification d'un enregistrement $tabfieldvalue = array(); -$tabfieldvalue[25] = "label,lang,type_template,fk_user,private,position,topic,joinfiles,defaultfortype,content"; +$tabfieldvalue[25] = "label,lang,type_template,fk_user,private,position,topic,email_from,joinfiles,defaultfortype,content"; if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { $tabfieldvalue[25] .= ',content_lines'; } // Nom des champs dans la table pour insertion d'un enregistrement $tabfieldinsert = array(); -$tabfieldinsert[25] = "label,lang,type_template,fk_user,private,position,topic,joinfiles,defaultfortype,content"; +$tabfieldinsert[25] = "label,lang,type_template,fk_user,private,position,topic,email_from,joinfiles,defaultfortype,content"; if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { $tabfieldinsert[25] .= ',content_lines'; } @@ -168,6 +168,7 @@ $tabhelp[25] = array( 'private'=>$langs->trans("TemplateIsVisibleByOwnerOnly"), 'position'=>$langs->trans("PositionIntoComboList"), 'topic'=>''.$helpsubstit.'', + 'email_from'=>$langs->trans('ForceEmailFrom'), 'joinfiles'=>$langs->trans('AttachMainDocByDefault'), 'defaultfortype'=>$langs->trans("DefaultForTypeDesc"), 'content'=>''.$helpsubstit.'', @@ -575,7 +576,7 @@ if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu $morejs = array(); $morecss = array(); -$sql = "SELECT rowid as rowid, module, label, type_template, lang, fk_user, private, position, topic, joinfiles, defaultfortype, content_lines, content, enabled, active"; +$sql = "SELECT rowid as rowid, module, label, type_template, lang, fk_user, private, position, topic, email_from,joinfiles, defaultfortype, content_lines, content, enabled, active"; $sql .= " FROM ".MAIN_DB_PREFIX."c_email_templates"; $sql .= " WHERE entity IN (".getEntity('email_template').")"; if (!$user->admin) { @@ -805,15 +806,18 @@ if ($action == 'create') { print ''; // Show fields for topic, join files and body - $fieldsforcontent = array('topic', 'joinfiles', 'content'); + $fieldsforcontent = array('topic', 'email_from', 'joinfiles', 'content'); if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { - $fieldsforcontent = array('topic', 'joinfiles', 'content', 'content_lines'); + $fieldsforcontent = array('topic', 'email_from', 'joinfiles', 'content', 'content_lines'); } foreach ($fieldsforcontent as $tmpfieldlist) { // Topic of email if ($tmpfieldlist == 'topic') { print ''.$form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' '; } + if ($tmpfieldlist == 'email_from') { + print $form->textwithpicto($langs->trans("MailFrom"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist); + } if ($tmpfieldlist == 'joinfiles') { print ''.$form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' '; } @@ -827,6 +831,8 @@ if ($action == 'create') { // Input field if ($tmpfieldlist == 'topic') { print ''; + } elseif ($tmpfieldlist == 'email_from') { + print ''; } elseif ($tmpfieldlist == 'joinfiles') { print $form->selectyesno($tmpfieldlist, (isset($obj->$tmpfieldlist) ? $obj->$tmpfieldlist : '0'), 1, false, 0, 1); } else { @@ -1088,7 +1094,7 @@ if ($num) { print ''; print ''; - $fieldsforcontent = array('topic', 'joinfiles', 'content'); + $fieldsforcontent = array('topic', 'email_from','joinfiles', 'content'); if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { $fieldsforcontent[] = 'content_lines'; } @@ -1106,6 +1112,11 @@ if ($num) { print ''; print '
'."\n"; } + if ($tmpfieldlist == 'email_from') { + print ''.$form->textwithpicto($langs->trans("MailFrom"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' '; + print ''; + print '
'."\n"; + } if ($tmpfieldlist == 'joinfiles') { print ''.$form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' '; print $form->selectyesno($tmpfieldlist.'-'.$rowid, (isset($obj->$tmpfieldlist) ? $obj->$tmpfieldlist : '0'), 1, false, 0, 1); diff --git a/htdocs/admin/menus/index.php b/htdocs/admin/menus/index.php index 0396c31eb96..6d630ed6b6d 100644 --- a/htdocs/admin/menus/index.php +++ b/htdocs/admin/menus/index.php @@ -32,10 +32,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; // Load translation files required by the page $langs->loadLangs(array("other", "admin")); -if (!$user->admin) { - accessforbidden(); -} - $dirstandard = array(); $dirsmartphone = array(); $dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']); @@ -47,12 +43,10 @@ foreach ($dirmenus as $dirmenu) { $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); -$menu_handler_top = $conf->global->MAIN_MENU_STANDARD; -$menu_handler_smartphone = $conf->global->MAIN_MENU_SMARTPHONE; +//$menu_handler_top = getDolGlobalString('MAIN_MENU_STANDARD'); +$menu_handler_top = 'all'; $menu_handler_top = preg_replace('/(_backoffice\.php|_menu\.php)/i', '', $menu_handler_top); $menu_handler_top = preg_replace('/(_frontoffice\.php|_menu\.php)/i', '', $menu_handler_top); -$menu_handler_smartphone = preg_replace('/(_backoffice\.php|_menu\.php)/i', '', $menu_handler_smartphone); -$menu_handler_smartphone = preg_replace('/(_frontoffice\.php|_menu\.php)/i', '', $menu_handler_smartphone); $menu_handler = $menu_handler_top; @@ -65,6 +59,10 @@ if (GETPOST("menu_handler")) { $menu_handler_to_search = preg_replace('/(_backoffice|_frontoffice|_menu)?(\.php)?/i', '', $menu_handler); +if (empty($user->admin)) { + accessforbidden(); +} + /* * Actions @@ -211,6 +209,7 @@ print load_fiche_titre($langs->trans("Menus"), '', 'title_setup'); $h = 0; +$head = array(); $head[$h][0] = DOL_URL_ROOT."/admin/menus.php"; $head[$h][1] = $langs->trans("MenuHandlers"); @@ -224,7 +223,7 @@ $h++; print dol_get_fiche_head($head, 'editor', '', -1); -print ''.$langs->trans("MenusEditorDesc")."
\n"; +print ''.$langs->trans("MenusEditorDesc")."
\n"; print "
\n"; @@ -248,7 +247,7 @@ print ''; print $langs->trans("MenuHandler").': '; $formadmin->select_menu_families($menu_handler.(preg_match('/_menu/', $menu_handler) ? '' : '_menu'), 'menu_handler', array_merge($dirstandard, $dirsmartphone)); -print '   '; +print '   '; print '
'; print $newcardbutton; @@ -258,6 +257,84 @@ print ''; print '
'; + +// ARBORESCENCE + + +/*-------------------- MAIN ----------------------- +tableau des elements de l'arbre: +c'est un tableau a 2 dimensions. +Une ligne represente un element : data[$x] +chaque ligne est decomposee en 3 donnees: + - l'index de l'élément + - l'index de l'élément parent + - la chaine a afficher +ie: data[]= array (index, index parent, chaine ) +*/ + +//il faut d'abord declarer un element racine de l'arbre + +$data[] = array('rowid'=>0, 'fk_menu'=>-1, 'title'=>"racine", 'mainmenu'=>'', 'leftmenu'=>'', 'fk_mainmenu'=>'', 'fk_leftmenu'=>''); + +//puis tous les elements enfants + +$sql = "SELECT m.rowid, m.titre, m.langs, m.mainmenu, m.leftmenu, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu, m.position, m.module"; +$sql .= " FROM ".MAIN_DB_PREFIX."menu as m"; +$sql .= " WHERE menu_handler = '".$db->escape($menu_handler_to_search)."'"; +$sql .= " AND entity = ".$conf->entity; +//$sql.= " AND fk_menu >= 0"; +$sql .= " ORDER BY m.position, m.rowid"; // Order is position then rowid (because we need a sort criteria when position is same) + +$res = $db->query($sql); +if ($res) { + $num = $db->num_rows($res); + + $i = 1; + while ($menu = $db->fetch_array($res)) { + if (!empty($menu['langs'])) { + $langs->load($menu['langs']); + } + $titre = $langs->trans($menu['titre']); + + $entry = ''; + $entry .= '
'; + $entry .= ''.$titre.''; + $entry .= ''; + $entry .= ''.img_edit('default', 0, 'class="menuEdit" id="edit'.$menu['rowid'].'"').' '; + $entry .= ''.img_edit_add('default').' '; + $entry .= ''.img_delete('default').' '; + $entry .= '  '; + $entry .= ''.img_picto("Up", "1uparrow").''.img_picto("Down", "1downarrow").''; + $entry .= '
'; + + $buttons = ''.img_edit('default', 0, 'class="menuEdit" id="edit'.$menu['rowid'].'"').' '; + $buttons .= ''.img_edit_add('default').' '; + $buttons .= ''.img_delete('default').' '; + $buttons .= '  '; + $buttons .= ''.img_picto("Up", "1uparrow").''.img_picto("Down", "1downarrow").''; + + $data[] = array( + 'rowid'=>$menu['rowid'], + 'module'=>$menu['module'], + 'fk_menu'=>$menu['fk_menu'], + 'title'=>$titre, + 'mainmenu'=>$menu['mainmenu'], + 'leftmenu'=>$menu['leftmenu'], + 'fk_mainmenu'=>$menu['fk_mainmenu'], + 'fk_leftmenu'=>$menu['fk_leftmenu'], + 'position'=>$menu['position'], + 'entry'=>$entry, + 'buttons'=>$buttons + ); + $i++; + } +} + +global $tree_recur_alreadyadded; // This var was def into tree_recur + +//var_dump($data); + +print '
'; print ''; print ''; @@ -269,131 +346,49 @@ print ''; print ''; print ''; +print ''; - //puis tous les elements enfants +print '
'; -// ARBORESCENCE -$rangLast = 0; -$idLast = -1; -if ($conf->use_javascript_ajax) { - /*-------------------- MAIN ----------------------- - tableau des elements de l'arbre: - c'est un tableau a 2 dimensions. - Une ligne represente un element : data[$x] - chaque ligne est decomposee en 3 donnees: - - l'index de l'élément - - l'index de l'élément parent - - la chaine a afficher - ie: data[]= array (index, index parent, chaine ) - */ +//tree_recur($data, $data[0], 0, 'iddivjstree', 0, 1); // use this to get info on name and foreign keys of menu entry +tree_recur($data, $data[0], 0, 'iddivjstree', 0, 0); // $data[0] is virtual record 'racine' - //il faut d'abord declarer un element racine de l'arbre - $data[] = array('rowid'=>0, 'fk_menu'=>-1, 'title'=>"racine", 'mainmenu'=>'', 'leftmenu'=>'', 'fk_mainmenu'=>'', 'fk_leftmenu'=>''); +print '
'; +print '
'; - $sql = "SELECT m.rowid, m.titre, m.langs, m.mainmenu, m.leftmenu, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu, m.position, m.module"; - $sql .= " FROM ".MAIN_DB_PREFIX."menu as m"; - $sql .= " WHERE menu_handler = '".$db->escape($menu_handler_to_search)."'"; - $sql .= " AND entity = ".$conf->entity; - //$sql.= " AND fk_menu >= 0"; - $sql .= " ORDER BY m.position, m.rowid"; // Order is position then rowid (because we need a sort criteria when position is same) - - $res = $db->query($sql); - if ($res) { - $num = $db->num_rows($res); - - $i = 1; - while ($menu = $db->fetch_array($res)) { - if (!empty($menu['langs'])) { - $langs->load($menu['langs']); - } - $titre = $langs->trans($menu['titre']); - - $entry = '
'; - $entry .= '   '.$titre.''; - $entry .= ''; - $entry .= ''.img_edit('default', 0, 'class="menuEdit" id="edit'.$menu['rowid'].'"').' '; - $entry .= ''.img_edit_add('default').' '; - $entry .= ''.img_delete('default').' '; - $entry .= '  '; - $entry .= ''.img_picto("Up", "1uparrow").''.img_picto("Down", "1downarrow").''; - $entry .= '
'; - - $buttons = ''.img_edit('default', 0, 'class="menuEdit" id="edit'.$menu['rowid'].'"').' '; - $buttons .= ''.img_edit_add('default').' '; - $buttons .= ''.img_delete('default').' '; - $buttons .= '  '; - $buttons .= ''.img_picto("Up", "1uparrow").''.img_picto("Down", "1downarrow").''; - - $data[] = array( - 'rowid'=>$menu['rowid'], - 'module'=>$menu['module'], - 'fk_menu'=>$menu['fk_menu'], - 'title'=>$titre, - 'mainmenu'=>$menu['mainmenu'], - 'leftmenu'=>$menu['leftmenu'], - 'fk_mainmenu'=>$menu['fk_mainmenu'], - 'fk_leftmenu'=>$menu['fk_leftmenu'], - 'position'=>$menu['position'], - 'entry'=>$entry, - 'buttons'=>$buttons - ); - $i++; - } +// Process remaining records (records that are not linked to root by any path) +$remainingdata = array(); +foreach ($data as $datar) { + if (empty($datar['rowid']) || !empty($tree_recur_alreadyadded[$datar['rowid']])) { + continue; } + $remainingdata[] = $datar; +} - global $tree_recur_alreadyadded; // This var was def into tree_recur +if (count($remainingdata)) { + print '
'; + print ''; - //var_dump($data); - - // Appelle de la fonction recursive (ammorce) avec recherche depuis la racine. - //tree_recur($data, $data[0], 0, 'iddivjstree', 0, 1); // use this to get info on name and foreign keys of menu entry - tree_recur($data, $data[0], 0, 'iddivjstree', 0, 0); // $data[0] is virtual record 'racine' + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; print '
'.$langs->trans("NotTopTreeMenuPersonalized").'
'; + foreach ($remainingdata as $datar) { + $father = array('rowid'=>$datar['rowid'], 'title'=>"???", 'mainmenu'=>$datar['fk_mainmenu'], 'leftmenu'=>$datar['fk_leftmenu'], 'fk_mainmenu'=>'', 'fk_leftmenu'=>''); + //print 'Start with rowid='.$datar['rowid'].' mainmenu='.$father ['mainmenu'].' leftmenu='.$father ['leftmenu'].'
'."\n"; + tree_recur($data, $father, 0, 'iddivjstree'.$datar['rowid'], 1, 1); + } print '
'; - - - // Process remaining records (records that are not linked to root by any path) - $remainingdata = array(); - foreach ($data as $datar) { - if (empty($datar['rowid']) || !empty($tree_recur_alreadyadded[$datar['rowid']])) { - continue; - } - $remainingdata[] = $datar; - } - - if (count($remainingdata)) { - print ''; - - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - - print ''; - - print '
'.$langs->trans("NotTopTreeMenuPersonalized").'
'; - foreach ($remainingdata as $datar) { - $father = array('rowid'=>$datar['rowid'], 'title'=>"???", 'mainmenu'=>$datar['fk_mainmenu'], 'leftmenu'=>$datar['fk_leftmenu'], 'fk_mainmenu'=>'', 'fk_leftmenu'=>''); - //print 'Start with rowid='.$datar['rowid'].' mainmenu='.$father ['mainmenu'].' leftmenu='.$father ['leftmenu'].'
'."\n"; - tree_recur($data, $father, 0, 'iddivjstree'.$datar['rowid'], 1, 1); - } - - print '
'; - } - print '
'; -} else { - $langs->load("errors"); - setEventMessages($langs->trans("ErrorFeatureNeedJavascript"), null, 'errors'); } print '
'; diff --git a/htdocs/admin/mrp.php b/htdocs/admin/mrp.php index e24abdbfa94..67f48a6d075 100644 --- a/htdocs/admin/mrp.php +++ b/htdocs/admin/mrp.php @@ -218,7 +218,7 @@ foreach ($dirmodels as $reldir) { if ($module->isEnabled()) { print ''.$module->name."\n"; - print $module->info(); + print $module->info($langs); print ''; // Show example of numbering model diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index 5e06ba4011f..42b33307dd1 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -168,7 +168,7 @@ foreach ($dirmodels as $reldir) { echo preg_replace('/\-.*$/', '', preg_replace('/mod_payment_/', '', preg_replace('/\.php$/', '', $file))); print "\n"; - print $module->info(); + print $module->info($langs); print ''; diff --git a/htdocs/admin/pdf_other.php b/htdocs/admin/pdf_other.php index 58f3eff765c..31c4013901a 100644 --- a/htdocs/admin/pdf_other.php +++ b/htdocs/admin/pdf_other.php @@ -62,6 +62,18 @@ if ($action == 'update') { if (GETPOSTISSET('MAIN_GENERATE_PROPOSALS_WITH_PICTURE')) { dolibarr_set_const($db, "MAIN_GENERATE_PROPOSALS_WITH_PICTURE", GETPOST("MAIN_GENERATE_PROPOSALS_WITH_PICTURE"), 'chaine', 0, '', $conf->entity); } + if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_SUPPLIER_PROPOSAL_WITHOUT_UNIT_PRICE')) { + dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_SUPPLIER_PROPOSAL_WITHOUT_UNIT_PRICE", GETPOST("MAIN_GENERATE_DOCUMENTS_SUPPLIER_PROPOSAL_WITHOUT_UNIT_PRICE"), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_SUPPLIER_PROPOSAL_WITHOUT_TOTAL_COLUMN')) { + dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_SUPPLIER_PROPOSAL_WITHOUT_TOTAL_COLUMN", GETPOST("MAIN_GENERATE_DOCUMENTS_SUPPLIER_PROPOSAL_WITHOUT_TOTAL_COLUMN"), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_UNIT_PRICE')) { + dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_UNIT_PRICE", GETPOST("MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_UNIT_PRICE"), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_TOTAL_COLUMN')) { + dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_TOTAL_COLUMN", GETPOST("MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_TOTAL_COLUMN"), 'chaine', 0, '', $conf->entity); + } if (GETPOSTISSET('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH')) { dolibarr_set_const($db, "MAIN_DOCUMENTS_WITH_PICTURE_WIDTH", GETPOST("MAIN_DOCUMENTS_WITH_PICTURE_WIDTH", 'int'), 'chaine', 0, '', $conf->entity); } @@ -149,6 +161,75 @@ if (isModEnabled('propal')) { } +if (isModEnabled('supplier_proposal')) { + $langs->load("supplier_proposal"); + print load_fiche_titre($langs->trans("SupplierProposal"), '', 'supplier_proposal'); + + print '
'; + print ''; + print ''; + + print ''; + + print ''; + + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + print $form->textwithpicto($langs->trans("MAIN_GENERATE_DOCUMENTS_SUPPLIER_PROPOSAL_WITHOUT_UNIT_PRICE"), ''); + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_GENERATE_DOCUMENTS_SUPPLIER_PROPOSAL_WITHOUT_UNIT_PRICE'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("MAIN_GENERATE_DOCUMENTS_SUPPLIER_PROPOSAL_WITHOUT_UNIT_PRICE", $arrval, $conf->global->MAIN_GENERATE_DOCUMENTS_SUPPLIER_PROPOSAL_WITHOUT_UNIT_PRICE); + } + print '
'; + print $form->textwithpicto($langs->trans("MAIN_GENERATE_DOCUMENTS_SUPPLIER_PROPOSAL_WITHOUT_TOTAL_COLUMN"), ''); + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_GENERATE_DOCUMENTS_SUPPLIER_PROPOSAL_WITHOUT_TOTAL_COLUMN'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("MAIN_GENERATE_DOCUMENTS_SUPPLIER_PROPOSAL_WITHOUT_TOTAL_COLUMN", $arrval, $conf->global->MAIN_GENERATE_DOCUMENTS_SUPPLIER_PROPOSAL_WITHOUT_TOTAL_COLUMN); + } + print '
'; + print '
'; +} + + +if (isModEnabled('supplier_order')) { + $langs->load("supplier_order"); + print load_fiche_titre($langs->trans("SupplierOrder"), '', 'supplier_proposal'); + + print '
'; + print ''; + print ''; + + print ''; + + print ''; + + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + print $form->textwithpicto($langs->trans("MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_UNIT_PRICE"), ''); + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_UNIT_PRICE'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_UNIT_PRICE", $arrval, $conf->global->MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_UNIT_PRICE); + } + print '
'; + print $form->textwithpicto($langs->trans("MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_TOTAL_COLUMN"), ''); + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_TOTAL_COLUMN'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_TOTAL_COLUMN", $arrval, $conf->global->MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_TOTAL_COLUMN); + } + print '
'; + print '
'; +} + if (isModEnabled('facture')) { print load_fiche_titre($langs->trans("Invoices"), '', 'bill'); diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 10044e33b5b..66c0bbec2a6 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -292,7 +292,7 @@ foreach ($dirmodels as $reldir) { if ($module->isEnabled()) { print ''.$module->nom."\n"; - print $module->info(); + print $module->info($langs); print ''; // Show example of numbering module @@ -632,7 +632,12 @@ print ''; print ajax_constantonoff('PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD', array(), null, 0, 0, 0, 2, 0, 1); print ''; - +// Allow OnLine Sign +print ''; +print ''.$langs->trans("AllowOnLineSign").''; +print ''; +print ajax_constantonoff('PROPOSAL_ALLOW_ONLINESIGN', array(), null, 0, 0, 0, 2, 0, 1); +print ''; // default update prices on cloning a proposal /* diff --git a/htdocs/admin/reception_setup.php b/htdocs/admin/reception_setup.php index 32f6c5b226e..a44ea8fa6da 100644 --- a/htdocs/admin/reception_setup.php +++ b/htdocs/admin/reception_setup.php @@ -218,7 +218,7 @@ foreach ($dirmodels as $reldir) { print ''.$module->nom."\n"; print ''; - print $module->info(); + print $module->info($langs); print ''; // Show example of numbering module diff --git a/htdocs/admin/security_other.php b/htdocs/admin/security_other.php index 07ddb48dba4..e149544b634 100644 --- a/htdocs/admin/security_other.php +++ b/htdocs/admin/security_other.php @@ -208,6 +208,14 @@ print ''; +print ''.$langs->trans("MaxNumberOfFailedAuth").''; +print ''; +print ''; +print ' '.$langs->trans("FailedAuth"); +print ''; +print ''; + /* if (empty($conf->global->MAIN_APPLICATION_TITLE)) { $conf->global->MAIN_APPLICATION_TITLE = ""; diff --git a/htdocs/admin/sms.php b/htdocs/admin/sms.php index 3c18cf775f1..6158ad38286 100644 --- a/htdocs/admin/sms.php +++ b/htdocs/admin/sms.php @@ -185,7 +185,7 @@ if ($action == 'edit') { // Method print ''.$langs->trans("MAIN_SMS_SENDMODE").''; if (count($listofmethods)) { - print $form->selectarray('MAIN_SMS_SENDMODE', $listofmethods, $conf->global->MAIN_SMS_SENDMODE, 1); + print $form->selectarray('MAIN_SMS_SENDMODE', $listofmethods, getDolGlobalString('MAIN_SMS_SENDMODE'), 1); } else { print ''.$langs->trans("None").''; } @@ -256,19 +256,7 @@ if ($action == 'edit') { print ''.$langs->trans("Modify").''; - /*if ($conf->global->MAIN_SMS_SENDMODE != 'mail' || ! $linuxlike) - { - if (function_exists('fsockopen') && $port && $server) - { - print ''.$langs->trans("DoTestServerAvailability").''; - } - } - else - { - print ''.$langs->trans("DoTestServerAvailability").''; - }*/ - - if (count($listofmethods) && !empty($conf->global->MAIN_SMS_SENDMODE)) { + if (count($listofmethods) && getDolGlobalString('MAIN_SMS_SENDMODE')) { print ''.$langs->trans("DoTestSend").''; } else { print ''.$langs->trans("DoTestSend").''; diff --git a/htdocs/admin/stocktransfer.php b/htdocs/admin/stocktransfer.php index c62e286adfd..11a5cc37b9e 100644 --- a/htdocs/admin/stocktransfer.php +++ b/htdocs/admin/stocktransfer.php @@ -272,7 +272,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php'); print ''.$module->name."\n"; - print $module->info(); + print $module->info($langs); print ''; // Show example of numbering model diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index 99bbb6d9cb1..c80640b2fcc 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -246,7 +246,7 @@ foreach ($dirmodels as $reldir) { print ''.$module->nom."\n"; - print $module->info(); + print $module->info($langs); print ''; // Show example of numbering module diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index 171ad4035a9..17df663cda8 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -262,7 +262,7 @@ foreach ($dirmodels as $reldir) { print ''.$module->nom."\n"; - print $module->info(); + print $module->info($langs); print ''; // Show example of numbering module diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php index ac00e4846ac..4a830373393 100644 --- a/htdocs/admin/supplier_payment.php +++ b/htdocs/admin/supplier_payment.php @@ -241,7 +241,7 @@ foreach ($dirmodels as $reldir) { echo preg_replace('/\-.*$/', '', preg_replace('/mod_supplier_payment_/', '', preg_replace('/\.php$/', '', $file))); print "\n"; - print $module->info(); + print $module->info($langs); print ''; diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 62be111449d..92ceb356668 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -271,7 +271,7 @@ foreach ($dirmodels as $reldir) { if ($module->isEnabled()) { print ''.$module->nom."\n"; - print $module->info(); + print $module->info($langs); print ''; // Show example of numbering module diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index afe5d4d3520..925076b1ee7 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -429,10 +429,12 @@ foreach ($configfileparameters as $key => $value) { global $dolibarr_main_cookie_cryptkey, $dolibarr_main_instance_unique_id; $valuetoshow = $dolibarr_main_instance_unique_id ? $dolibarr_main_instance_unique_id : $dolibarr_main_cookie_cryptkey; // Use $dolibarr_main_instance_unique_id first then $dolibarr_main_cookie_cryptkey if (empty($dolibarr_main_prod)) { - print ''; + print ''; print showValueWithClipboardCPButton($valuetoshow, 0, '********'); + print '     '.$langs->trans("ThisValueCanBeReadBecauseInstanceIsNotInProductionMode").''; } else { print '**********'; + print '     '.$langs->trans("SeeConfFile").''; } if (empty($valuetoshow)) { print img_warning("EditConfigFileToAddEntry", 'dolibarr_main_instance_unique_id'); diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 36904cba63d..f42dd45b016 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -92,8 +92,8 @@ if (empty($xmlremote) && !empty($conf->global->MAIN_FILECHECK_URL)) { $xmlremote = $conf->global->MAIN_FILECHECK_URL; } $param = 'MAIN_FILECHECK_URL_'.DOL_VERSION; -if (empty($xmlremote) && !empty($conf->global->$param)) { - $xmlremote = $conf->global->$param; +if (empty($xmlremote) && getDolGlobalString($param)) { + $xmlremote = getDolGlobalString($param); } if (empty($xmlremote)) { $xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml'; diff --git a/htdocs/admin/system/os.php b/htdocs/admin/system/os.php index c60e1610054..739291d8e89 100644 --- a/htdocs/admin/system/os.php +++ b/htdocs/admin/system/os.php @@ -9,16 +9,16 @@ * * 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. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** - * \file htdocs/admin/system/os.php - * \brief Page des infos systeme de l'OS + * \file htdocs/admin/system/os.php + * \brief Page about System OS (Operating System) */ // Load Dolibarr environment @@ -43,10 +43,10 @@ print ''; print ''; print "\n"; -// Recupere l'OS au sens PHP +// Recovers the OS in the PHP sense print '\n"; -// Recupere la version de l'OS +// Recovers the OS version $osversion = version_os(); print '\n"; print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("PHP_OS")."".PHP_OS."
'.$langs->trans("Version")."".$osversion."
'; diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index 89161dffb3c..cf07784e436 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -115,6 +115,8 @@ print "PHP allow_url_include = ".(ini_get('allow_url_include') print "PHP disable_functions = "; $arrayoffunctionsdisabled = explode(',', ini_get('disable_functions')); $arrayoffunctionstodisable = explode(',', 'pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals'); +//$arrayoffunctionstodisable[] = 'stream_wrapper_restore'; +//$arrayoffunctionstodisable[] = 'stream_wrapper_register'; if ($execmethod == 1) { $arrayoffunctionstodisable2 = explode(',', 'passthru,shell_exec,system,proc_open,popen'); $functiontokeep = 'exec'; @@ -321,7 +323,7 @@ if (empty($dolibarr_main_restrict_os_commands)) { } else { print $dolibarr_main_restrict_os_commands; } -print ' ('.$langs->trans("RecommendedValueIs", 'mysqldump, mysql, pg_dump, pgrestore, clamdscan').')'; +print ' ('.$langs->trans("RecommendedValueIs", 'mysqldump, mysql, pg_dump, pgrestore, mariadb, mariadb-dump, clamdscan').')'; print '
'; if (empty($conf->global->SECURITY_DISABLE_TEST_ON_OBFUSCATED_CONF)) { @@ -359,7 +361,7 @@ if (empty($conf->global->MAIN_SESSION_TIMEOUT)) { $conf->global->MAIN_SESSION_TIMEOUT = $sessiontimeout; } print ''.$langs->trans("SessionTimeOut").''; -if (ini_get("session.gc_probability") == 0) { +if (!ini_get("session.gc_probability")) { print $form->textwithpicto('', $langs->trans("SessionsPurgedByExternalSystem", ini_get("session.gc_maxlifetime"))); } else { print $form->textwithpicto('', $langs->trans("SessionExplanation", ini_get("session.gc_probability"), ini_get("session.gc_divisor"), ini_get("session.gc_maxlifetime"))); @@ -459,7 +461,7 @@ if (!empty($eventstolog) && is_array($eventstolog)) { foreach ($eventstolog as $key => $arr) { if ($arr['id']) { $key = 'MAIN_LOGEVENTS_'.$arr['id']; - $value = empty($conf->global->$key) ? '' : $conf->global->$key; + $value = getDolGlobalString($key); if ($value) { if ($i > 0) { $out .= ', '; diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index 6a6201642ee..0576cd3ccc7 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -1,6 +1,8 @@ - * Copyright (C) 2016 Christophe Battarel +/* Copyright (C) 2013-2018 Jean-François FERRY + * Copyright (C) 2016 Christophe Battarel + * Copyright (C) 2022-2023 Udo Tamm + * Copyright (C) 2023 Alexandre Spangaro * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,17 +19,17 @@ */ /** - * \file admin/ticket.php + * \file htdocs/admin/ticket.php * \ingroup ticket * \brief Page to setup module ticket */ // Load Dolibarr environment require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; -require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"; -require_once DOL_DOCUMENT_ROOT."/core/lib/ticket.lib.php"; require_once DOL_DOCUMENT_ROOT."/core/class/html.formcategory.class.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/ticket.lib.php"; +require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"; // Load translation files required by the page $langs->loadLangs(array("admin", "ticket")); @@ -111,14 +113,14 @@ if ($action == 'updateMask') { $conf->global->TICKET_ADDON_PDF = $value; } - // On active le modele + // Activate the model $ret = delDocumentModel($value, $type); if ($ret > 0) { $ret = addDocumentModel($value, $type, $label, $scandir); } } elseif ($action == 'setmod') { - // TODO Verifier si module numerotation choisi peut etre active - // par appel methode canBeActivated + // TODO check if the chosen numbering module can be activated + // by calling the canBeActivated method dolibarr_set_const($db, "TICKET_ADDON", $value, 'chaine', 0, '', $conf->entity); } elseif ($action == 'setvarworkflow') { @@ -235,8 +237,9 @@ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $formcategory = new FormCategory($db); -$help_url = "FR:Module_Ticket"; -$page_name = "TicketSetup"; +// Page Header +$help_url = 'EN:Module_Ticket|FR:Module_Ticket_FR'; +$page_name = 'TicketSetup'; llxHeader('', $langs->trans($page_name), $help_url); // Subheader @@ -267,7 +270,7 @@ print ''.$langs->trans("Name").''; print ''.$langs->trans("Description").''; print ''.$langs->trans("Example").''; print ''.$langs->trans("Activated").''; -print ''.$langs->trans("ShortInfo").''; +print ''.$langs->trans("ShortInfo").''; print "\n"; clearstatcache(); @@ -298,7 +301,7 @@ foreach ($dirmodels as $reldir) { if ($module->isEnabled()) { print ''.$module->name."\n"; - print $module->info(); + print $module->info($langs); print ''; // Show example of numbering model @@ -391,8 +394,8 @@ print ''.$langs->trans("Name").''; print ''.$langs->trans("Description").''; print ''.$langs->trans("Status")."\n"; print ''.$langs->trans("Default")."\n"; -print ''.$langs->trans("ShortInfo").''; -print ''.$langs->trans("Preview").''; +print ''.$langs->trans("Preview").''; +print ''.$langs->trans("ShortInfo").''; print "\n"; clearstatcache(); @@ -439,7 +442,7 @@ foreach ($dirmodels as $reldir) { } print ''; - // Active + // Active / Status if (in_array($name, $def)) { print ''."\n"; print ''; @@ -452,7 +455,7 @@ foreach ($dirmodels as $reldir) { print ""; } - // Default + // Default Template print ''; if (getDolGlobalString("TICKET_ADDON_PDF") == $name) { print img_picto($langs->trans("Default"), 'on'); @@ -461,6 +464,17 @@ foreach ($dirmodels as $reldir) { } print ''; + // Preview + print ''; + if ($module->type == 'pdf') { + print ''.img_object($langs->trans("Preview"), 'pdf').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; + + print "\n"; + // Info $htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); @@ -480,17 +494,6 @@ foreach ($dirmodels as $reldir) { print ''; print $formcategory->textwithpicto('', $htmltooltip, 1, 0); print ''; - - // Preview - print ''; - if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'pdf').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; - - print "\n"; } } } @@ -509,17 +512,21 @@ print ''; print ''; print ''; +/* + * Other Parameters + */ + print load_fiche_titre($langs->trans("Other"), '', ''); print '
'; print ''; print ''; print ''; -print ''; -print ''; +print '\n"; +print ''; print "\n"; -// Auto mark ticket read when created from backoffice +// Auto mark ticket as read when created from backoffice print ''; print ''; print ''; -// Auto assign ticket at user who created it +// Auto assign ticket to user who created it print ''; print ''; print ''; print ''; +// Allow classification modification even if the ticket is closed +print ''; +print ''; +print ''; +print ''; + print '
'.$langs->trans("Parameter").''.$langs->trans("Status")."'.$langs->trans("ShortInfo").'
'.$langs->trans("TicketsAutoReadTicket").''; if ($conf->use_javascript_ajax) { @@ -534,7 +541,7 @@ print $formcategory->textwithpicto('', $langs->trans("TicketsAutoReadTicketHelp" print '
'.$langs->trans("TicketsAutoAssignTicket").''; @@ -600,13 +607,30 @@ print $formcategory->textwithpicto('', $langs->trans("TicketsDelayBetweenAnswers print '
'.$langs->trans("TicketsAllowClassificationModificationIfClosed").''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_ALLOW_CLASSIFICATION_MODIFICATION_EVEN_IF_CLOSED'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $formcategory->selectarray("TICKET_ALLOW_CLASSIFICATION_MODIFICATION_EVEN_IF_CLOSED", $arrval, getDolGlobalString('TICKET_ALLOW_CLASSIFICATION_MODIFICATION_EVEN_IF_CLOSED')); +} +print ''; +print $formcategory->textwithpicto('', $langs->trans("TicketsAllowClassificationModificationIfClosedHelp"), 1, 'help'); +print '

'; print $formcategory->buttonsSaveCancel("Save", '', array(), 0, 'reposition'); print ''; - +/* + * Notification + */ // Admin var of module print load_fiche_titre($langs->trans("Notification"), '', ''); @@ -618,18 +642,20 @@ print ''; print ''; print ''; -print ''.$langs->trans("Email").''; +print ''.$langs->trans("Email").''; +print ''.$langs->trans("ShortInfo").''; print "\n"; if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { print ''; - print '
'.$langs->trans("TicketCkEditorEmailNotActivated").'
'; + print '
'.$langs->trans("TicketCkEditorEmailNotActivated").'
'; + print ''.$langs->trans("ShortInfo").''; print "\n"; } -// @todo Use module notification instead... +// TODO Use module notification instead... -// Email d'envoi des notifications +// Email to send notifications print ''.$langs->trans("TicketEmailNotificationFrom").''; print ''; print ''; @@ -641,7 +667,7 @@ print ''; // Email for notification of TICKET_CREATE print ''.$langs->trans("TicketEmailNotificationTo").''; print ''; -print ''; +print ''; print ''; print $formcategory->textwithpicto('', $langs->trans("TicketEmailNotificationToHelp"), 1, 'help'); print ''; diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php index a640370dc7b..c141bf47860 100644 --- a/htdocs/admin/ticket_public.php +++ b/htdocs/admin/ticket_public.php @@ -379,6 +379,21 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { print ''; print ''; + // show footer for company + print ''.$langs->trans("TicketsShowCompanyFooter").''; + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_SHOW_COMPANY_FOOTER'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_SHOW_COMPANY_FOOTER", $arrval, $conf->global->TICKET_SHOW_COMPANY_FOOTER); + } + print ''; + print ''; + print $form->textwithpicto('', $langs->trans("TicketsShowCompanyFooterHelp"), 1, 'help'); + print ''; + print ''; + // Show progression print ''.$langs->trans("TicketsShowProgression").''; print ''; diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 856113eef4d..bac6558369f 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -203,7 +203,7 @@ print ''; print ''; print '
'; -print img_picto('', 'setup', 'class="pictofixedwidth"').''.$langs->trans("ShowAdvancedOptions").'...'; +print img_picto('', 'setup', 'class="pictofixedwidth"').''.$langs->trans("ShowAdvancedOptions").'...'; print '
'; print ''; print ''; } - print ''; + print ''; print ' '; print ''; + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } print ''; } } @@ -1388,6 +1410,21 @@ if ($resql) { print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + 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']++; + } + } + // Ref if (!empty($arrayfields['b.rowid']['checked'])) { print ''; @@ -1405,6 +1442,7 @@ if ($resql) { $reg = array(); preg_match('/\((.+)\)/i', $objp->label, $reg); // Si texte entoure de parenthee on tente recherche de traduction if (!empty($reg[1]) && $langs->trans($reg[1]) != $reg[1]) { + // Example: $reg[1] = 'CustomerInvoicePayment', 'SupplierInvoicePayment', ... (or on old version: 'WithdrawalPayment', 'BankTransferPayment') $labeltoshow = $langs->trans($reg[1]); } else { if ($objp->label == '(payment_salary)') { @@ -1779,16 +1817,18 @@ if ($resql) { } // Action column - 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; + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + 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 ''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; } print "\n"; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index c01b56207f8..916a12d0564 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -701,7 +701,7 @@ class Account extends CommonObject return -1; } - // Chargement librairie pour acces fonction controle RIB + // Load librairies to check BAN require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; $now = dol_now(); @@ -778,13 +778,13 @@ class Account extends CommonObject $result = $this->update($user, 1); if ($result > 0) { $accline = new AccountLine($this->db); - $accline->datec = $this->db->idate($now); + $accline->datec = $now; $accline->label = '('.$langs->trans("InitialBankBalance").')'; $accline->amount = price2num($this->solde); $accline->fk_user_author = $user->id; $accline->fk_account = $this->id; - $accline->datev = $this->db->idate($this->date_solde); - $accline->dateo = $this->db->idate($this->date_solde); + $accline->datev = $this->date_solde; + $accline->dateo = $this->date_solde; $accline->fk_type = 'SOLD'; if ($accline->insert() < 0) { @@ -1505,7 +1505,7 @@ class Account extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { @@ -1563,25 +1563,19 @@ class Account extends CommonObject { require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; - $this->error_number = 0; - - // Call function to check BAN + $error = 0; + // Call functions to check BAN if (!checkIbanForAccount($this)) { - $this->error_number = 12; + $error++; $this->error_message = 'IBANNotValid'; } if (!checkSwiftForAccount($this)) { - $this->error_number = 12; + $error++; $this->error_message = 'SwiftNotValid'; } - /*if (! checkBanForAccount($this)) - { - $this->error_number = 12; - $this->error_message = 'BANControlError'; - }*/ - if ($this->error_number == 0) { + if (! $error) { return 1; } else { return 0; @@ -2041,8 +2035,6 @@ class AccountLine extends CommonObjectLine */ public function fetch($rowid, $ref = '', $num = '') { - global $conf; - // Check parameters if (empty($rowid) && empty($ref) && empty($num)) { return -1; @@ -2058,9 +2050,9 @@ class AccountLine extends CommonObjectLine $sql .= " WHERE b.fk_account = ba.rowid"; $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; if ($num) { - $sql .= " AND b.num_chq='".$this->db->escape($num)."'"; + $sql .= " AND b.num_chq = '".$this->db->escape($num)."'"; } elseif ($ref) { - $sql .= " AND b.rowid='".$this->db->escape($ref)."'"; + $sql .= " AND b.rowid = '".$this->db->escape($ref)."'"; } else { $sql .= " AND b.rowid = ".((int) $rowid); } @@ -2076,9 +2068,9 @@ class AccountLine extends CommonObjectLine $this->rowid = $obj->rowid; $this->ref = $obj->rowid; - $this->datec = $obj->datec; - $this->datev = $obj->datev; - $this->dateo = $obj->dateo; + $this->datec = $this->db->jdate($obj->datec); + $this->datev = $this->db->jdate($obj->datev); + $this->dateo = $this->db->jdate($obj->dateo); $this->amount = $obj->amount; $this->label = $obj->label; $this->note = $obj->note; @@ -2155,6 +2147,7 @@ class AccountLine extends CommonObjectLine $sql .= ", ".($this->num_releve ? "'".$this->db->escape($this->num_releve)."'" : "null"); $sql .= ")"; + dol_syslog(get_class($this)."::insert", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -2182,10 +2175,11 @@ class AccountLine extends CommonObjectLine /** * Delete bank transaction record * - * @param User|null $user User object that delete - * @return int <0 if KO, >0 if OK + * @param User|null $user User object that delete + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <0 if KO, >0 if OK */ - public function delete(User $user = null) + public function delete(User $user = null, $notrigger = 0) { global $conf; @@ -2199,6 +2193,16 @@ class AccountLine extends CommonObjectLine $this->db->begin(); + if (!$notrigger) { + // Call trigger + $result = $this->call_trigger('BANKACCOUNTLINE_DELETE', $user); + if ($result < 0) { + $this->db->rollback(); + return -1; + } + // End call triggers + } + // Protection to avoid any delete of accounted lines. Protection on by default if (empty($conf->global->BANK_ALLOW_TRANSACTION_DELETION_EVEN_IF_IN_ACCOUNTING)) { $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE doc_type = 'bank' AND fk_doc = ".((int) $this->id); diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index e81981a7490..e05a911ffee 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -56,13 +56,14 @@ class BankAccounts extends DolibarrApi * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number - * @param int $category Use this param to filter list by category + * @param int $category Use this param to filter list by category * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.import_key:<:'20160101')" + * @param string $properties Restrict the data returned to theses properties. Ignored if empty. Comma separated list of properties names * @return array List of account objects * * @throws RestException */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $category = 0, $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $category = 0, $sqlfilters = '', $properties = '') { $list = array(); @@ -108,7 +109,7 @@ class BankAccounts extends DolibarrApi $obj = $this->db->fetch_object($result); $account = new Account($this->db); if ($account->fetch($obj->rowid) > 0) { - $list[] = $this->_cleanObjectDatas($account); + $list[] = $this->_filterObjectProperties($this->_cleanObjectDatas($account), $properties); } } } else { @@ -121,8 +122,8 @@ class BankAccounts extends DolibarrApi /** * Get account by ID. * - * @param int $id ID of account - * @return Object Object with cleaned properties + * @param int $id ID of account + * @return Object Object with cleaned properties * * @throws RestException */ @@ -144,8 +145,8 @@ class BankAccounts extends DolibarrApi /** * Create account object * - * @param array $request_data Request data - * @return int ID of account + * @param array $request_data Request data + * @return int ID of account */ public function post($request_data = null) { @@ -312,9 +313,9 @@ class BankAccounts extends DolibarrApi /** * Update account * - * @param int $id ID of account - * @param array $request_data data - * @return Object Object with cleaned properties + * @param int $id ID of account + * @param array $request_data data + * @return Object Object with cleaned properties */ public function put($id, $request_data = null) { @@ -480,7 +481,7 @@ class BankAccounts extends DolibarrApi * @param string $accountancycode Accountancy code {@from body} * @param string $datev Payment date value (timestamp) {@from body} {@type timestamp} * @param string $num_releve Bank statement numero {@from body} - * @return int ID of line + * @return int ID of line * * @url POST {id}/lines */ @@ -527,7 +528,7 @@ class BankAccounts extends DolibarrApi /** * Add a link to an account line * - * @param int $id ID of account + * @param int $id ID of account * @param int $line_id ID of account line * @param int $url_id ID to set in the URL {@from body} * @param string $url URL of the link {@from body} diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index f967ee8ef0c..9a42dd11773 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -679,7 +679,7 @@ class PaymentVarious extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index d8517391e17..fcf7b3c23f9 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -434,7 +434,7 @@ if ($result) { print img_object($langs->trans('Donation'), 'payment').' '; print $langs->trans("DonationPayment"); print ''; - } elseif ($links[$key]['type'] == 'banktransfert') { + } elseif ($links[$key]['type'] == 'banktransfert') { // transfert between 1 local account and another local account print ''; print img_object($langs->trans('Transaction'), 'payment').' '; print $langs->trans("TransactionOnTheOtherAccount"); @@ -450,6 +450,7 @@ if ($result) { print $langs->trans("VariousPayment"); print ''; } else { + // Example type = 'direct-debit', or 'credit-transfer', .... print ''; print img_object('', 'generic').' '; print $links[$key]['label']; diff --git a/htdocs/compta/cashcontrol/class/cashcontrol.class.php b/htdocs/compta/cashcontrol/class/cashcontrol.class.php index fd4b38b5f66..7f18558307f 100644 --- a/htdocs/compta/cashcontrol/class/cashcontrol.class.php +++ b/htdocs/compta/cashcontrol/class/cashcontrol.class.php @@ -429,7 +429,7 @@ class CashControl extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index c0254f6c316..d5d2cc191e2 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -58,6 +58,11 @@ class Deplacement extends CommonObject */ public $ismultientitymanaged = 0; + + public $fk_soc; + public $date; + public $type; + /** * Date creation record (datec) * @@ -98,10 +103,6 @@ class Deplacement extends CommonObject public $statut; public $extraparams = array(); - public $statuts = array(); - public $statuts_short = array(); - public $statuts_logo = array(); - /** * Draft status @@ -126,10 +127,6 @@ class Deplacement extends CommonObject public function __construct(DoliDB $db) { $this->db = $db; - - $this->statuts_short = array(0 => 'Draft', 1 => 'Validated', 2 => 'Refunded'); - $this->statuts = array(0 => 'Draft', 1 => 'Validated', 2 => 'Refunded'); - $this->statuts_logo = array(0 => 'status0', 1=>'status4', 2 => 'status1', 4 => 'status6', 5 => 'status4', 6 => 'status6', 99 => 'status5'); } /** @@ -217,8 +214,6 @@ class Deplacement extends CommonObject */ public function update($user) { - global $langs; - // Clean parameters $this->km = price2num($this->km); @@ -361,12 +356,21 @@ class Deplacement extends CommonObject // phpcs:enable global $langs; - $labelStatus = $langs->transnoentitiesnoconv($this->statuts[$status]); - $labelStatusShort = $langs->transnoentitiesnoconv($this->statuts_short[$status]); + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { + global $langs; + //$langs->load("mymodule@mymodule"); + $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated'); + $this->labelStatus[self::STATUS_REFUNDED] = $langs->transnoentitiesnoconv('Refunded'); + $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); + $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated'); + $this->labelStatusShort[self::STATUS_REFUNDED] = $langs->transnoentitiesnoconv('Refunded'); + } - $statusType = $this->statuts_logo[$status]; + $status_logo = array(0 => 'status0', 1=>'status4', 2 => 'status1', 4 => 'status6', 5 => 'status4', 6 => 'status6', 99 => 'status5'); + $statusType = $status_logo[$status]; - return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode); + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } /** diff --git a/htdocs/compta/facture/agenda-rec.php b/htdocs/compta/facture/agenda-rec.php new file mode 100644 index 00000000000..0810704bb4a --- /dev/null +++ b/htdocs/compta/facture/agenda-rec.php @@ -0,0 +1,263 @@ + + * + * 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/compta/facture/agenda-rec.php + * \ingroup facture + * \brief Tab of events on Invoices + */ +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + +// Load translation files required by the page +$langs->loadLangs(array("bills", "other")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel', 'aZ09'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); + +if (GETPOST('actioncode', 'array')) { + $actioncode = GETPOST('actioncode', 'array', 3); + if (!count($actioncode)) { + $actioncode = '0'; + } +} else { + $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); +} +$search_rowid = GETPOST('search_rowid'); +$search_agenda_label = GETPOST('search_agenda_label'); + +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (!$sortfield) { + $sortfield = 'a.datep,a.id'; +} +if (!$sortorder) { + $sortorder = 'DESC,DESC'; +} + +// Initialize technical objects +$object = new FactureRec($db); +$extrafields = new ExtraFields($db); +$hookmanager->initHooks(array('invoicerecagenda', 'globalcard')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +if ($id > 0 || !empty($ref)) { + $upload_dir = $conf->facture->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id; +} + +$permissiontoread = $user->hasRight("facture", "lire"); +$permissiontoadd = $user->hasRight("facture", "creer"); + +// Security check +if (!empty($user->socid)) { + $socid = $user->socid; +} +$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); +restrictedArea($user, 'facture', $object->id, 'facture_rec', '', 'fk_soc', 'rowid', $isdraft); + + +/* + * Actions + */ + +$parameters = array('id'=>$id); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} + +if (empty($reshook)) { + // Cancel + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { + header("Location: ".$backtopage); + exit; + } + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers + $actioncode = ''; + $search_agenda_label = ''; + } +} + + + +/* + * View + */ + +$form = new Form($db); + +if ($object->id > 0) { + $title = $object->ref." - ".$langs->trans('Agenda'); + $help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung'; + + llxHeader('', $title, $help_url); + + if (isModEnabled('notification')) { + $langs->load("mails"); + } + $head = invoice_rec_prepare_head($object); + + + print dol_get_fiche_head($head, 'agenda', $langs->trans("RepeatableInvoice"), -1, $object->picto); + + // Object card + // ------------------------------------------------------------ + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = ''; + if ($action != 'editref') { + $morehtmlref .= $form->editfieldkey($object->ref, 'ref', $object->ref, $object, 0, '', '', 0, 2); + } else { + $morehtmlref .= $form->editfieldval('', 'ref', $object->ref, $object, 0, 'string'); + } + + $morehtmlref .= '
'; + // Thirdparty + $morehtmlref .= $object->thirdparty->getNomUrl(1); + // Project + if (isModEnabled('project')) { + $langs->load("projects"); + $morehtmlref .= '
'; + if (0) { + $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, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= $proj->getNomUrl(1); + if ($proj->title) { + $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; + } + } + } + } + $morehtmlref .= '
'; + + $morehtmlright = ''; + + dol_banner_tab($object, 'ref', $linkback, 1, 'title', 'none', $morehtmlref, '', 0, '', $morehtmlright); + + print '
'; + print '
'; + + $object->info($object->id); + dol_print_object_info($object, 1); + + print '
'; + + print dol_get_fiche_end(); + + + + // Actions buttons + + $objthirdparty = $object; + $objcon = new stdClass(); + + $out = '&origin='.urlencode($object->element.(property_exists($object, 'module') ? '@'.$object->module : '')).'&originid='.urlencode($object->id); + $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id; + $out .= '&backtopage='.urlencode($urlbacktopage); + $permok = $user->hasRight('paymentbagendaybanktransfer', 'myactions', 'create'); + if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { + //$out.='trans("AddAnAction"),'filenew'); + //$out.=""; + } + + $morehtmlright = ''; + + //$messagingUrl = DOL_URL_ROOT.'/societe/messaging.php?socid='.$object->id; + //$morehtmlright .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 1); + //$messagingUrl = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id; + //$morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 2); + + if (isModEnabled('agenda')) { + /* + if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { + $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out); + } else { + $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out, '', 0); + } + */ + } + + + if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { + print '
'; + + $param = '&id='.$object->id.(!empty($socid) ? '&socid='.$socid : ''); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.((int) $limit); + } + + // Try to know count of actioncomm from cache + require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; + $cachekey = 'count_events_facture_'.$object->id; + $nbEvent = dol_getcache($cachekey); + + print_barre_liste($langs->trans("ActionsOnBillRec").(is_numeric($nbEvent) ? '('.$nbEvent.')': ''), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1); + //print_barre_liste($langs->trans("ActionsOnBill"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1); + + // List of all actions + $filters = array(); + $filters['search_agenda_label'] = $search_agenda_label; + $filters['search_rowid'] = $search_rowid; + + // TODO Replace this with same code than into list.php + show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, property_exists($object, 'module') ? $object->module : ''); + } +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 0b1b78baffd..5181608fd50 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2004-2023 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2013 Florian Henry * Copyright (C) 2013-2023 Juanjo Menent @@ -70,6 +70,7 @@ $projectid = GETPOST('projectid', 'int'); $year_date_when = GETPOST('year_date_when'); $month_date_when = GETPOST('month_date_when'); +$selectedLines = GETPOST('toselect', 'array'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -202,7 +203,6 @@ if (empty($reshook)) { } if (!$error) { - $object->titre = GETPOST('title', 'alphanohtml'); // deprecated $object->title = GETPOST('title', 'alphanohtml'); $object->note_private = GETPOST('note_private', 'restricthtml'); $object->note_public = GETPOST('note_public', 'restricthtml'); @@ -243,7 +243,9 @@ if (empty($reshook)) { $oldinvoice = new Facture($db); $oldinvoice->fetch(GETPOST('facid', 'int')); - $result = $object->create($user, $oldinvoice->id); + $onlylines = GETPOST('toselect', 'array'); + + $result = $object->create($user, $oldinvoice->id, 0, $onlylines); if ($result > 0) { $result = $oldinvoice->delete($user, 1); if ($result < 0) { @@ -280,21 +282,23 @@ if (empty($reshook)) { // Update field - // Set condition if ($action == 'setconditions' && $user->hasRight('facture', 'creer')) { + // Set condition + $object->context['actionmsg'] = $langs->trans("FieldXModified", $langs->transnoentitiesnoconv("PaymentTerm")); $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); } elseif ($action == 'setmode' && $user->hasRight('facture', 'creer')) { // Set mode + $object->context['actionmsg'] = $langs->trans("FieldXModified", $langs->transnoentitiesnoconv("PaymentMode")); $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); } elseif ($action == 'classin' && $user->hasRight('facture', 'creer')) { // Set project + $object->context['actionmsg'] = $langs->trans("FieldXModified", $langs->transnoentitiesnoconv("Project")); $object->setProject(GETPOST('projectid', 'int')); } elseif ($action == 'setref' && $user->hasRight('facture', 'creer')) { // Set bank account - //var_dump(GETPOST('ref', 'alpha'));exit; + $object->context['actionmsg'] = $langs->trans("FieldXModifiedFromYToZ", $langs->transnoentitiesnoconv("Title"), $object->title, $ref); $result = $object->setValueFrom('titre', $ref, '', null, 'text', '', $user, 'BILLREC_MODIFY'); if ($result > 0) { - $object->titre = $ref; // deprecated $object->title = $ref; $object->ref = $object->title; } else { @@ -308,9 +312,11 @@ if (empty($reshook)) { } } elseif ($action == 'setbankaccount' && $user->hasRight('facture', 'creer')) { // Set bank account + $object->context['actionmsg'] = $langs->trans("FieldXModified", $langs->transnoentitiesnoconv("Bank")); $result = $object->setBankAccount(GETPOST('fk_account', 'int')); } elseif ($action == 'setfrequency' && $user->hasRight('facture', 'creer')) { // Set frequency and unit frequency + $object->context['actionmsg'] = $langs->trans("FieldXModified", $langs->transnoentitiesnoconv("Frequency")); $object->setFrequencyAndUnit(GETPOST('frequency', 'int'), GETPOST('unit_frequency', 'alpha')); } elseif ($action == 'setdate_when' && $user->hasRight('facture', 'creer')) { // Set next date of execution @@ -334,9 +340,9 @@ if (empty($reshook)) { // Set status disabled $db->begin(); - $object->fetch($id); + $object->context['actionmsg'] = $langs->trans("RecordDisabled"); - $res = $object->setValueFrom('suspended', 1); + $res = $object->setValueFrom('suspended', 1, '', null, 'text', '', $user, 'BILLREC_MODIFY'); if ($res <= 0) { $error++; } @@ -351,9 +357,9 @@ if (empty($reshook)) { // Set status enabled $db->begin(); - $object->fetch($id); + $object->context['actionmsg'] = $langs->trans("RecordEnabled"); - $res = $object->setValueFrom('suspended', 0); + $res = $object->setValueFrom('suspended', 0, '', null, 'text', '', $user, 'BILLREC_MODIFY'); if ($res <= 0) { $error++; } @@ -933,8 +939,10 @@ if (empty($reshook)) { * View */ +$title = $object->ref." - ".$langs->trans('Card'); $help_url = ''; -llxHeader('', $langs->trans("RepeatableInvoices"), $help_url); + +llxHeader('', $title, $help_url); $form = new Form($db); $formother = new FormOther($db); @@ -1143,13 +1151,11 @@ if ($action == 'create') { * Invoice lines */ print '
'; - print ''; + print '
'; + // Show object lines if (!empty($object->lines)) { - $disableedit = 1; - $disablemove = 1; - $disableremove = 1; - $object->printObjectLines('', $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice + $object->printOriginLinesList('', $selectedLines); } print "
\n"; @@ -1157,7 +1163,7 @@ if ($action == 'create') { print ''; - if ($flag_price_may_change) { + if (!empty($flag_price_may_change)) { print ''; print ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= ''; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); @@ -1340,7 +1337,7 @@ if ($action == 'create') { print ''; - if ($usercancreate && $action != 'editmulticurrencycode' && !empty($object->brouillon)) { + if ($usercancreate && $action != 'editmulticurrencycode' && $object->suspended == $object::STATUS_SUSPENDED) { print ''; } print '
'; print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'
'; @@ -1356,7 +1353,7 @@ if ($action == 'create') { print ''; - if ($usercancreate && $action != 'editmulticurrencyrate' && !empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { + if ($usercancreate && $action != 'editmulticurrencyrate' && $object->suspended == $object::STATUS_SUSPENDED && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { print ''; } print '
'; print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'
'; @@ -1482,7 +1479,6 @@ if ($action == 'create') { * Recurrence */ $title = $langs->trans("Recurrence"); - //print load_fiche_titre($title, '', 'calendar'); print ''; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 4d7a8110f0e..ce0664c1f79 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1657,7 +1657,7 @@ if (empty($reshook)) { } $label = (!empty($lines[$i]->label) ? $lines[$i]->label : ''); - $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->label); + $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc : ''); if ($object->situation_counter == 1) { $lines[$i]->situation_percent = 0; } @@ -3167,6 +3167,7 @@ if ($action == 'create') { print ''; print ''; print ''; + print ''; // will be set to 1 by javascript so we know post is done after a company change if ($soc->id > 0) { print ''."\n"; } @@ -3236,6 +3237,7 @@ if ($action == 'create') { // For company change, we must submit page with action=create instead of action=add console.log("We have changed the company - Resubmit page"); + jQuery("input[name=changecompany]").val("1"); jQuery("#formtocreateaction").val("create"); jQuery("#formtocreate").submit(); }); @@ -3561,9 +3563,15 @@ if ($action == 'create') { $tmp .= ' disabled'; } $tmp .= '> '; - // Show credit note options only if we checked credit note + // Show credit note options only if we checked credit note and disable standard invoice if "create credit note" button is pressed print ''.$this->select_state($selected, $country_codeid, $htmlname, $morecss).''; + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** @@ -1169,7 +1195,7 @@ class FormCompany extends Form url: \'' . DOL_URL_ROOT . '/core/ajax/ajaxstatusprospect.php\', data: { id: statusid, prospectid: prospectid, token: \''. newToken() .'\', action: \'updatestatusprospect\' }, success: function(response) { -console.log(response.img); + console.log(response.img); image.replaceWith(response.img); }, error: function() { diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index 56187336532..33694e798e6 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -59,9 +59,11 @@ class FormContract * @param int $maxlength Maximum length of label * @param int $showempty Show empty line * @param int $showRef Show customer and supplier reference on each contract (when found) - * @return int Nbr of project if OK, <0 if KO + * @param int $noouput 1=Return the output instead of display + * @param string $morecss More CSS + * @return int Nbr of contract if OK, <0 if KO */ - public function select_contract($socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1, $showRef = 0) + public function select_contract($socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1, $showRef = 0, $noouput = 0, $morecss = 'minwidth150') { // phpcs:enable global $user, $conf, $langs; @@ -71,6 +73,8 @@ class FormContract $hideunselectables = true; } + $ret = ''; + // Search all contacts $sql = "SELECT c.rowid, c.ref, c.fk_soc, c.statut,"; $sql .= " c.ref_customer, c.ref_supplier"; @@ -94,9 +98,9 @@ class FormContract dol_syslog(get_class($this)."::select_contract", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - print ''; if ($showempty) { - print ''; + $ret .= ''; } $num = $this->db->num_rows($resql); $i = 0; @@ -121,7 +125,7 @@ class FormContract //if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')'; //else $labeltoshow.=' ('.$langs->trans("Private").')'; if (!empty($selected) && $selected == $obj->rowid && $obj->statut > 0) { - print ''; + $ret .= ''; } else { $disabled = 0; if ($obj->statut == 0) { @@ -145,21 +149,27 @@ class FormContract $resultat .= '>'.$labeltoshow; $resultat .= ''; } - print $resultat; + $ret .= $resultat; } } $i++; } } - print ''; + $ret .= ''; $this->db->free($resql); if (!empty($conf->use_javascript_ajax)) { // Make select dynamic include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; - print ajax_combobox($htmlname); + $ret .= ajax_combobox($htmlname); } + if ($noouput) { + return $ret; + } + + print $ret; + return $num; } else { dol_print_error($this->db); @@ -177,19 +187,24 @@ class FormContract * @param int $maxlength Maximum length of label * @param int $showempty Show empty line * @param int $showRef Show customer and supplier reference on each contract (when found) - * @return int Nbr of project if OK, <0 if KO + * @param int $noouput 1=Return the output instead of display + * @return string|void html string */ - public function formSelectContract($page, $socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1, $showRef = 0) + public function formSelectContract($page, $socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1, $showRef = 0, $noouput = 0) { global $langs; - print "\n"; - print ''; - print ''; - print ''; - $result = $this->select_contract($socid, $selected, $htmlname, $maxlength, $showempty, $showRef); - print ''; - print ''; - return $result; + $ret = ''; + $ret .= ''; + $ret .= ''; + $ret .= $this->select_contract($socid, $selected, $htmlname, $maxlength, $showempty, $showRef, 1); + $ret .= ''; + $ret .= ''; + + if ($noouput) { + return $ret; + } + + print $ret; } } diff --git a/htdocs/core/class/html.formexpensereport.class.php b/htdocs/core/class/html.formexpensereport.class.php index 8b6d45be1c5..c08431b534e 100644 --- a/htdocs/core/class/html.formexpensereport.class.php +++ b/htdocs/core/class/html.formexpensereport.class.php @@ -75,7 +75,7 @@ class FormExpenseReport } foreach ($arrayoflabels as $key => $val) { if ($selected != '' && $selected == $key) { - $html .= '
'; $out .= ''; + $addcolumforpicto = ($delallowed || $printer || $morepicto); + $colspan = (4 + ($addcolumforpicto ? 1 : 0)); + $colspanmore = 0; $out .= ''; print '\n"; @@ -1088,11 +1109,26 @@ class FormMail extends Form if (!empty($this->withtofree)) { $out .= " ".$langs->trans("and")."/".$langs->trans("or")." "; } - // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time + $tmparray = $this->withto; foreach ($tmparray as $key => $val) { - $tmparray[$key] = str_replace(array('<', '>'), array('(', ')'), $tmparray[$key]); - $tmparray[$key] = dol_htmlentities($tmparray[$key], ENT_QUOTES|ENT_SUBSTITUTE, 'UTF-8', true); + if (is_array($val)) { + $label = $val['label']; + } else { + $label = $val; + } + + $tmparray[$key] = array(); + $tmparray[$key]['id'] = $key; + + $tmparray[$key]['label'] = $label; + $tmparray[$key]['label'] = str_replace(array('<', '>'), array('(', ')'), $tmparray[$key]['label']); + // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time + $tmparray[$key]['label'] = dol_htmlentities($tmparray[$key]['label'], ENT_QUOTES|ENT_SUBSTITUTE, 'UTF-8', true); + + $tmparray[$key]['labelhtml'] = $label; + $tmparray[$key]['labelhtml'] = str_replace(array('<', '<', '>', '>'), array('__LTCHAR__', '__LTCHAR__', '__GTCHAR__', '__GTCHAR__'), $tmparray[$key]['labelhtml']); + $tmparray[$key]['labelhtml'] = str_replace(array('__LTCHAR__', '__GTCHAR__'), array('(', ')'), $tmparray[$key]['labelhtml']); } $withtoselected = GETPOST("receiver", 'array'); // Array of selected value @@ -1102,7 +1138,7 @@ class FormMail extends Form } } - $out .= $form->multiselectarray("receiver", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, ""); + $out .= $form->multiselectarray("receiver", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', 0, 0); } } $out .= "\n"; @@ -1126,14 +1162,31 @@ class FormMail extends Form $out .= 'withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : '')).'" />'; if (!empty($this->withtocc) && is_array($this->withtocc)) { $out .= " ".$langs->trans("and")."/".$langs->trans("or")." "; - // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time + $tmparray = $this->withtocc; foreach ($tmparray as $key => $val) { - $tmparray[$key] = str_replace(array('<', '>'), array('(', ')'), $tmparray[$key]); - $tmparray[$key] = dol_htmlentities($tmparray[$key], ENT_QUOTES|ENT_SUBSTITUTE, 'UTF-8', true); + if (is_array($val)) { + $label = $val['label']; + } else { + $label = $val; + } + + $tmparray[$key] = array(); + $tmparray[$key]['id'] = $key; + + $tmparray[$key]['label'] = $label; + $tmparray[$key]['label'] = str_replace(array('<', '>'), array('(', ')'), $tmparray[$key]['label']); + // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time + $tmparray[$key]['label'] = dol_htmlentities($tmparray[$key]['label'], ENT_QUOTES|ENT_SUBSTITUTE, 'UTF-8', true); + + $tmparray[$key]['labelhtml'] = $label; + $tmparray[$key]['labelhtml'] = str_replace(array('<', '<', '>', '>'), array('__LTCHAR__', '__LTCHAR__', '__GTCHAR__', '__GTCHAR__'), $tmparray[$key]['labelhtml']); + $tmparray[$key]['labelhtml'] = str_replace(array('__LTCHAR__', '__GTCHAR__'), array('(', ')'), $tmparray[$key]['labelhtml']); } + $withtoccselected = GETPOST("receivercc", 'array'); // Array of selected value - $out .= $form->multiselectarray("receivercc", $tmparray, $withtoccselected, null, null, 'inline-block minwidth500', null, ""); + + $out .= $form->multiselectarray("receivercc", $tmparray, $withtoccselected, null, null, 'inline-block minwidth500', 0, 0); } } $out .= "\n"; @@ -1157,13 +1210,30 @@ class FormMail extends Form $out .= 'withtoccc) && !is_numeric($this->withtoccc)) ? $this->withtoccc : '')).'" />'; if (!empty($this->withtoccc) && is_array($this->withtoccc)) { $out .= " ".$langs->trans("and")."/".$langs->trans("or")." "; - // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time + $tmparray = $this->withtoccc; foreach ($tmparray as $key => $val) { - $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true); + if (is_array($val)) { + $label = $val['label']; + } else { + $label = $val; + } + $tmparray[$key] = array(); + $tmparray[$key]['id'] = $key; + + $tmparray[$key]['label'] = $label; + $tmparray[$key]['label'] = str_replace(array('<', '>'), array('(', ')'), $tmparray[$key]['label']); + // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time + $tmparray[$key]['label'] = dol_htmlentities($tmparray[$key]['label'], ENT_QUOTES|ENT_SUBSTITUTE, 'UTF-8', true); + + $tmparray[$key]['labelhtml'] = $label; + $tmparray[$key]['labelhtml'] = str_replace(array('<', '<', '>', '>'), array('__LTCHAR__', '__LTCHAR__', '__GTCHAR__', '__GTCHAR__'), $tmparray[$key]['labelhtml']); + $tmparray[$key]['labelhtml'] = str_replace(array('__LTCHAR__', '__GTCHAR__'), array('(', ')'), $tmparray[$key]['labelhtml']); } + $withtocccselected = GETPOST("receiverccc", 'array'); // Array of selected value - $out .= $form->multiselectarray("receiverccc", $tmparray, $withtocccselected, null, null, null, null, "90%"); + + $out .= $form->multiselectarray("receiverccc", $tmparray, $withtocccselected, null, null, 'inline-block minwidth500', 0, 0); } } @@ -1329,7 +1399,7 @@ class FormMail extends Form $languagetosearchmain = ''; } - $sql = "SELECT rowid, module, label, type_template, topic, joinfiles, content, content_lines, lang, email_from, email_to, email_tocc, email_tobcc"; + $sql = "SELECT rowid, module, label, type_template, topic, email_from, joinfiles, content, content_lines, lang, email_from, email_to, email_tocc, email_tobcc"; $sql .= " FROM ".$dbs->prefix().'c_email_templates'; $sql .= " WHERE (type_template = '".$dbs->escape($type_template)."' OR type_template = 'all')"; $sql .= " AND entity IN (".getEntity('c_email_templates').")"; @@ -1388,6 +1458,7 @@ class FormMail extends Form $ret->content = $obj->content; $ret->content_lines = $obj->content_lines; $ret->joinfiles = $obj->joinfiles; + $ret->email_from = $obj->email_from; break; } else { diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php index 021c82d5c00..64d279cf1e3 100644 --- a/htdocs/core/class/html.formmargin.class.php +++ b/htdocs/core/class/html.formmargin.class.php @@ -208,6 +208,7 @@ class FormMargin public function displayMarginInfos($object, $force_price = false) { global $langs, $conf, $user, $hookmanager; + global $action; if (!empty($user->socid)) { return; diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 084fce1f955..17fea5741ce 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -331,7 +331,6 @@ class FormOther $out .= ''; @@ -472,6 +471,7 @@ class FormOther { // phpcs:enable global $conf, $langs, $hookmanager; + global $action; $langs->load('users'); @@ -825,17 +825,18 @@ class FormOther /** * Output a HTML code to select a color. Field will return an hexa color like '334455'. * - * @param string $set_color Pre-selected color - * @param string $prefix Name of HTML field - * @param string $form_name Deprecated. Not used. - * @param int $showcolorbox 1=Show color code and color box, 0=Show only color code - * @param array $arrayofcolors Array of colors. Example: array('29527A','5229A3','A32929','7A367A','B1365F','0D7813') - * @param string $morecss Add css style into input field + * @param string $set_color Pre-selected color with format '#......' + * @param string $prefix Name of HTML field + * @param string $form_name Deprecated. Not used. + * @param int $showcolorbox 1=Show color code and color box, 0=Show only color code + * @param array $arrayofcolors Array of possible colors to choose in the selector. All colors are possible if empty. Example: array('29527A','5229A3','A32929','7A367A','B1365F','0D7813') + * @param string $morecss Add css style into input field * @param string $setpropertyonselect Set this property after selecting a color + * @param string $default Default color * @return string * @see showColor() */ - public static function selectColor($set_color = '', $prefix = 'f_color', $form_name = '', $showcolorbox = 1, $arrayofcolors = '', $morecss = '', $setpropertyonselect = '') + public static function selectColor($set_color = '', $prefix = 'f_color', $form_name = '', $showcolorbox = 1, $arrayofcolors = '', $morecss = '', $setpropertyonselect = '', $default = '') { // Deprecation warning if ($form_name) { @@ -847,8 +848,9 @@ class FormOther $out = ''; if (!is_array($arrayofcolors) || count($arrayofcolors) < 1) { + // Case of selection of any color $langs->load("other"); - if (empty($conf->dol_use_jmobile) && !empty($conf->use_javascript_ajax)) { + if (empty($conf->dol_use_jmobile) && !empty($conf->use_javascript_ajax) && !getDolGlobalInt('MAIN_USE_HTML5_COLOR_SELECTOR')) { $out .= ''; $out .= ''; $out .= ''; + $out .= ''; + } else { + $color = ($set_color !== '' ? $set_color : ($default !== '' ? $default : 'FFFFFF')); + $out .= ''; + $out .= ''; } - $out .= ''; - } else { // In most cases, this is not used. We used instead function with no specific list of colors + } else { + // In most cases, this is not used. We used instead function with no specific list of colors if (empty($conf->dol_use_jmobile) && !empty($conf->use_javascript_ajax)) { $out .= ''; $out .= ''; @@ -1206,7 +1231,7 @@ class FormOther $label = $langs->transnoentitiesnoconv($box->boxlabel); //if (preg_match('/graph/',$box->class)) $label.=' ('.$langs->trans("Graph").')'; if (preg_match('/graph/', $box->class) && $conf->browser->layout != 'phone') { - $label = $label.' '; + $label = $label.' '; } $arrayboxtoactivatelabel[$box->id] = array('label'=>$label, 'data-html'=>img_picto('', $box->boximg, 'class="pictofixedwidth"').$langs->trans($label)); // We keep only boxes not shown for user, to show into combo list } diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index ad1299c91c1..39cb3590db5 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -23,11 +23,12 @@ * \brief Class file for html component project */ +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; /** * Class to manage building of HTML components */ -class FormProjets +class FormProjets extends Form { /** * @var DoliDB Database handler. @@ -756,6 +757,43 @@ class FormProjets } } + /** + * Return combo list of differents status of a orders + * + * @param string $selected Preselected value + * @param int $short Use short labels + * @param string $hmlname Name of HTML select element + * @return void + */ + public function selectProjectsStatus($selected = '', $short = 0, $hmlname = 'order_status') + { + $options = array(); + + // 7 is same label than 6. 8 does not exists (billed is another field) + $statustohow = array( + '0' => '0', + '1' => '1', + '2' => '2', + ); + + $tmpproject = new Project($this->db); + + foreach ($statustohow as $key => $value) { + $tmpproject->statut = $key; + $options[$value] = $tmpproject->getLibStatut($short); + } + + if (is_array($selected)) { + $selectedarray = $selected; + } elseif ($selected == 99) { + $selectedarray = array(0,1); + } else { + $selectedarray = explode(',', $selected); + } + + print Form::multiselectarray($hmlname, $options, $selectedarray, 0, 0, 'minwidth100'); + } + /** * Output a combo list with invoices and lines qualified for a project * diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index ac6bbc42e0d..5cee5607497 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -77,6 +77,10 @@ class FormSetup */ public $formHiddenInputs = array(); + /** + * @var string[] $errors + */ + public $errors = array(); /** * Constructor @@ -248,7 +252,7 @@ class FormSetup $parameters = array(); $reshook = $hookmanager->executeHooks('formSetupBeforeSaveConfFromPost', $parameters, $this); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->setErrors($hookmanager->errors); + $this->errors = $hookmanager->errors; return -1; } @@ -619,7 +623,7 @@ class FormSetupItem public $setValueFromPostCallBack; /** - * @var string $errors + * @var string[] $errors */ public $errors = array(); diff --git a/htdocs/core/class/html.formsms.class.php b/htdocs/core/class/html.formsms.class.php index cb393bf8738..8e20cb8d33c 100644 --- a/htdocs/core/class/html.formsms.class.php +++ b/htdocs/core/class/html.formsms.class.php @@ -62,6 +62,7 @@ class FormSms public $withreplytoreadonly; public $withtoreadonly; public $withtopicreadonly; + public $withbodyreadonly; public $withcancel; public $substit = array(); @@ -110,7 +111,7 @@ class FormSms public function show_form($morecss = 'titlefield', $showform = 1) { // phpcs:enable - global $conf, $langs, $user, $form; + global $conf, $langs, $form; if (!is_object($form)) { $form = new Form($this->db); @@ -185,21 +186,14 @@ function limitChars(textarea, limit, infodiv) print "\n"; } else { print ''; + } + } + // Other attributes $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $ticketstat, $action); // Note that $action and $object may have been modified by hook @@ -1477,10 +1488,20 @@ class FormTicket print ''; print ''; } - - // Subject + // Subject/topic + $topic = ""; + foreach ($formmail->lines_model as $line) { + if ($this->param['models_id'] == $line->id) { + $topic = $line->topic; + break; + } + } print ''; - print ''; // Recipients / adressed-to diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 35148729295..deee8874f29 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -53,6 +53,11 @@ class Ldap */ public $connectedServer; + /** + * @var int server port + */ + public $serverPort; + /** * Base DN (e.g. "dc=foo,dc=com") */ @@ -72,6 +77,11 @@ class Ldap public $domainFQDN; + /** + * @var int bind + */ + public $bind; + /** * User administrateur Ldap * Active Directory ne supporte pas les connexions anonymes @@ -99,13 +109,74 @@ class Ldap */ public $ldapErrorText; + /** + * @var string + */ + public $filter; + /** + * @var string + */ + public $filtergroup; + /** + * @var string + */ + public $filtermember; + + /** + * @var string attr_login + */ + public $attr_login; + + /** + * @var string attr_sambalogin + */ + public $attr_sambalogin; + + /** + * @var string attr_name + */ + public $attr_name; + + /** + * @var string attr_firstname + */ + public $attr_firstname; + + /** + * @var string attr_mail + */ + public $attr_mail; + + /** + * @var string attr_phone + */ + public $attr_phone; + + /** + * @var string attr_fax + */ + public $attr_fax; + + /** + * @var string attr_mobile + */ + public $attr_mobile; + + /** + * @var int badpwdtime + */ + public $badpwdtime; + + /** + * @var string ladpUserDN + */ + public $ldapUserDN; //Fetch user public $name; public $firstname; public $login; public $phone; - public $skype; public $fax; public $mail; public $mobile; @@ -177,7 +248,6 @@ class Ldap $this->attr_firstname = getDolGlobalString('LDAP_FIELD_FIRSTNAME'); $this->attr_mail = getDolGlobalString('LDAP_FIELD_MAIL'); $this->attr_phone = getDolGlobalString('LDAP_FIELD_PHONE'); - $this->attr_skype = getDolGlobalString('LDAP_FIELD_SKYPE'); $this->attr_fax = getDolGlobalString('LDAP_FIELD_FAX'); $this->attr_mobile = getDolGlobalString('LDAP_FIELD_MOBILE'); } @@ -1389,13 +1459,13 @@ class Ldap public function parseSAT($samtype) { $stypes = array( - 805306368 => "NORMAL_ACCOUNT", - 805306369 => "WORKSTATION_TRUST", - 805306370 => "INTERDOMAIN_TRUST", - 268435456 => "SECURITY_GLOBAL_GROUP", - 268435457 => "DISTRIBUTION_GROUP", - 536870912 => "SECURITY_LOCAL_GROUP", - 536870913 => "DISTRIBUTION_LOCAL_GROUP" + 805306368 => "NORMAL_ACCOUNT", + 805306369 => "WORKSTATION_TRUST", + 805306370 => "INTERDOMAIN_TRUST", + 268435456 => "SECURITY_GLOBAL_GROUP", + 268435457 => "DISTRIBUTION_GROUP", + 536870912 => "SECURITY_LOCAL_GROUP", + 536870913 => "DISTRIBUTION_LOCAL_GROUP" ); $retval = ""; diff --git a/htdocs/core/class/lessc.class.php b/htdocs/core/class/lessc.class.php index f1620898028..29feea57f29 100644 --- a/htdocs/core/class/lessc.class.php +++ b/htdocs/core/class/lessc.class.php @@ -56,8 +56,12 @@ class Lessc public $scope; public $formatter; + public $formatterName; + public $parser; + public $_parseFile; public $env; public $count; + public $inExp; protected $numberPrecision = null; @@ -2640,7 +2644,15 @@ class lessc_parser protected static $literalCache = array(); public $env; + public $buffer; public $count; + public $line; + public $eatWhiteDefault; + public $lessc; + public $sourceName; + public $writeComments; + public $seenComments; + public $currentProperty; public function __construct($lessc, $sourceName = null) @@ -4245,6 +4257,7 @@ class lessc_formatter_classic public $breakSelectors = false; public $compressColors = false; + public $indentLevel; public function __construct() { diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index f289e2c8cf9..2be8cab1fc4 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2009-2012 Regis Houssin - * Copyright (C) 2018-2019 Frédéric France + * Copyright (C) 2018-2023 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -333,7 +333,6 @@ class Menubase //global $conf, $langs; // Clean parameters - $this->rowid = trim($this->rowid); $this->menu_handler = trim($this->menu_handler); $this->module = trim($this->module); $this->type = trim($this->type); diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 74287b1bd0b..0a67f0450d7 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -77,6 +77,7 @@ class Notify 'FICHINTER_ADD_CONTACT', 'ORDER_SUPPLIER_VALIDATE', 'ORDER_SUPPLIER_APPROVE', + 'ORDER_SUPPLIER_SUBMIT', 'ORDER_SUPPLIER_REFUSE', 'SHIPPING_VALIDATE', 'EXPENSE_REPORT_VALIDATE', @@ -480,7 +481,9 @@ class Notify $outputlangs->loadLangs(array("main", "other")); } - $subject = '['.$mysoc->name.'] '.$outputlangs->transnoentitiesnoconv("DolibarrNotification").($projtitle ? ' '.$projtitle : ''); + $appli = $mysoc->name; + + $subject = '['.$appli.'] '.$outputlangs->transnoentitiesnoconv("DolibarrNotification").($projtitle ? ' '.$projtitle : ''); switch ($notifcode) { case 'BILL_VALIDATE': @@ -561,6 +564,14 @@ class Notify $mesg .= $outputlangs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $link, $user->getFullName($outputlangs)); $mesg .= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n"; break; + case 'ORDER_SUPPLIER_SUBMIT': + $link = ''.$newref.''; + $dir_output = $conf->fournisseur->commande->dir_output; + $object_type = 'order_supplier'; + $mesg = $outputlangs->transnoentitiesnoconv("Hello").",\n\n"; + $mesg .= $outputlangs->transnoentitiesnoconv("EMailTextSupplierOrderSubmittedBy", $link, $user->getFullName($outputlangs)); + $mesg .= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n"; + break; case 'ORDER_SUPPLIER_REFUSE': $link = ''.$newref.''; $dir_output = $conf->fournisseur->commande->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object); @@ -743,15 +754,14 @@ class Notify continue; } + $sendto = $val; + $threshold = (float) $reg[1]; if (!empty($object->total_ht) && $object->total_ht <= $threshold) { dol_syslog("A notification is requested for notifcode = ".$notifcode." but amount = ".$object->total_ht." so lower than threshold = ".$threshold.". We discard this notification"); continue; } - $param = 'NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_'.$reg[1]; - - $sendto = $conf->global->$param; $notifcodedefid = dol_getIdFromCode($this->db, $notifcode, 'c_action_trigger', 'code', 'rowid'); if ($notifcodedefid <= 0) { dol_print_error($this->db, 'Failed to get id from code'); @@ -762,7 +772,9 @@ class Notify $link = ''; $num++; - $subject = '['.$mysoc->name.'] '.$langs->transnoentitiesnoconv("DolibarrNotification").($projtitle ? ' '.$projtitle : ''); + $appli = $mysoc->name; + + $subject = '['.$appli.'] '.$langs->transnoentitiesnoconv("DolibarrNotification").($projtitle ? ' '.$projtitle : ''); switch ($notifcode) { case 'BILL_VALIDATE': @@ -829,12 +841,12 @@ class Notify $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $link, $user->getFullName($langs)); $mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; break; - case 'ORDER_SUPPLIER_APPROVE2': + case 'ORDER_SUPPLIER_SUBMIT': $link = ''.$newref.''; $dir_output = $conf->fournisseur->commande->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object); $object_type = 'order_supplier'; $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; - $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $link, $user->getFullName($langs)); + $mesg .= $langs->transnoentitiesnoconv("EMailTextSupplierOrderSubmittedBy", $link, $user->getFullName($langs)); $mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; break; case 'ORDER_SUPPLIER_REFUSE': @@ -960,7 +972,7 @@ class Notify if ($mailfile->sendfile()) { $sql = "INSERT INTO ".$this->db->prefix()."notify (daten, fk_action, fk_soc, fk_contact, type, type_target, objet_type, objet_id, email)"; - $sql .= " VALUES ('".$this->db->idate(dol_now())."', ".((int) $notifcodedefid).", ".($object->socid > 0 ? ((int) $object->socid) : 'null').", null, 'email', 'tofixedemail', '".$this->db->escape($object_type)."', ".((int) $object->id).", '".$this->db->escape($conf->global->$param)."')"; + $sql .= " VALUES ('".$this->db->idate(dol_now())."', ".((int) $notifcodedefid).", ".($object->socid > 0 ? ((int) $object->socid) : 'null').", null, 'email', 'tofixedemail', '".$this->db->escape($object_type)."', ".((int) $object->id).", '".$this->db->escape($sendto)."')"; if (!$this->db->query($sql)) { dol_print_error($this->db); } diff --git a/htdocs/core/class/rssparser.class.php b/htdocs/core/class/rssparser.class.php index fc3a8753a59..28da9f9a72d 100644 --- a/htdocs/core/class/rssparser.class.php +++ b/htdocs/core/class/rssparser.class.php @@ -52,6 +52,11 @@ class RssParser private $_rssarray = array(); private $current_namespace; + public $items = array(); + public $current_item = array(); + public $channel = array(); + public $textinput = array(); + public $image = array(); private $initem; private $intextinput; diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index 3636c9335bd..c2222504d6b 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -33,6 +33,47 @@ abstract class Stats protected $lastfetchdate = array(); // Dates of cache file read by methods public $cachefilesuffix = ''; // Suffix to add to name of cache file (to avoid file name conflicts) + /** + * @var string To store the FROM part of the main table of the SQL request + */ + public $from; + + /** + * @var string To store the WHERE part of the main table of the SQL request + */ + public $where; + /** + * @var string To store the FROM part of the line table of the SQL request + */ + public $from_line; + /** + * @var string To store the field of the date + */ + public $field_date; + /** + * @var string To store the field for total HT + */ + public $field; + /** + * @var string To store the FROM part of the line table of the SQL request + */ + public $field_line; + + /** + * @var string error message + */ + public $error; + + /** + * @var int year + */ + public $year; + + /** + * @var int month + */ + public $month; + /** * @param int $year number * @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 diff --git a/htdocs/core/class/timespent.class.php b/htdocs/core/class/timespent.class.php index 2c98c9747ec..6958742207d 100755 --- a/htdocs/core/class/timespent.class.php +++ b/htdocs/core/class/timespent.class.php @@ -153,43 +153,6 @@ class TimeSpent extends CommonObject public $note; // END MODULEBUILDER PROPERTIES - - // If this object has a subtable with lines - - // /** - // * @var string Name of subtable line - // */ - // public $table_element_line = 'timespent_timespentline'; - - // /** - // * @var string Field with ID of parent key if this object has a parent - // */ - // public $fk_element = 'fk_timespent'; - - // /** - // * @var string Name of subtable class that manage subtable lines - // */ - // public $class_element_line = 'TimeSpentline'; - - // /** - // * @var array List of child tables. To test if we can delete object. - // */ - // protected $childtables = array(); - - // /** - // * @var array List of child tables. To know object to delete on cascade. - // * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will - // * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object - // */ - // protected $childtablesoncascade = array('timespent_timespentdet'); - - // /** - // * @var TimeSpentLine[] Array of subtable lines - // */ - // public $lines = array(); - - - /** * Constructor * @@ -269,13 +232,6 @@ class TimeSpent extends CommonObject // Load source object $result = $object->fetchCommon($fromid); - if ($result > 0 && !empty($object->table_element_line)) { - $object->fetchLines(); - } - - // get lines so they will be clone - //foreach($this->lines as $line) - // $line->fetch_optionals(); // Reset some properties unset($object->id); @@ -359,26 +315,10 @@ class TimeSpent extends CommonObject public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - if ($result > 0 && !empty($this->table_element_line)) { - $this->fetchLines(); - } + return $result; } - /** - * Load object lines in memory from the database - * - * @return int <0 if KO, 0 if not found, >0 if OK - */ - public function fetchLines() - { - $this->lines = array(); - - $result = $this->fetchLinesCommon(); - return $result; - } - - /** * Load list of objects in memory from the database. * @@ -763,7 +703,7 @@ class TimeSpent extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($url && $add_save_lastsearch_values) { @@ -813,7 +753,7 @@ class TimeSpent extends CommonObject $pospoint = strpos($filearray[0]['name'], '.'); $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint); - if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) { + if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) { $result .= '
No photo
'; } else { $result .= '
No photo
'; @@ -992,28 +932,6 @@ class TimeSpent extends CommonObject $this->initAsSpecimenCommon(); } - /** - * Create an array of lines - * - * @return array|int array of lines if OK, <0 if KO - */ - public function getLinesArray() - { - $this->lines = array(); - - $objectline = new TimeSpentLine($this->db); - $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_timespent = '.((int) $this->id))); - - if (is_numeric($result)) { - $this->error = $objectline->error; - $this->errors = $objectline->errors; - return $result; - } else { - $this->lines = $result; - return $this->lines; - } - } - /** * Returns the reference to the following non used object depending on the active numbering module. * @@ -1107,34 +1025,4 @@ class TimeSpent extends CommonObject return $result; } - - /** - * Action executed by scheduler - * CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters' - * Use public function doScheduledJob($param1, $param2, ...) to get parameters - * - * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) - */ - public function doScheduledJob() - { - //global $conf, $langs; - - //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log'; - - $error = 0; - $this->output = ''; - $this->error = ''; - - dol_syslog(__METHOD__, LOG_DEBUG); - - $now = dol_now(); - - $this->db->begin(); - - // ... - - $this->db->commit(); - - return $error; - } } diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 1f6eace6163..b512b8c660b 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -61,7 +61,8 @@ class Utils */ public function purgeFiles($choices = 'tempfilesold+logfiles', $nbsecondsold = 86400) { - global $conf, $langs, $dolibarr_main_data_root; + global $conf, $langs, $user; + global $dolibarr_main_data_root; $langs->load("admin"); @@ -76,6 +77,14 @@ class Utils dol_syslog("Utils::purgeFiles choice=".$choices, LOG_DEBUG); + // For dangerous action, we check the user is admin + if (in_array($choices, array('allfiles', 'allfilesold'))) { + if (empty($user->admin)) { + $this->output = 'Error: to erase data files, user running the batch (currently '.$user->login.') must be an admin user'; + return 1; + } + } + $count = 0; $countdeleted = 0; $counterror = 0; diff --git a/htdocs/core/db/Database.interface.php b/htdocs/core/db/Database.interface.php index f689df2a70d..6df4e6d11a1 100644 --- a/htdocs/core/db/Database.interface.php +++ b/htdocs/core/db/Database.interface.php @@ -98,7 +98,7 @@ interface Database * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) * @return string SQL request line converted */ - public static function convertSQLFromMysql($line, $type = 'ddl'); + public function convertSQLFromMysql($line, $type = 'ddl'); // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 9211cd3f875..77b339f4fc2 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -51,9 +51,9 @@ class DoliDBMysqli extends DoliDB * * @param string $type Type of database (mysql, pgsql...) * @param string $host Address of database server - * @param string $user Nom de l'utilisateur autorise - * @param string $pass Mot de passe - * @param string $name Nom de la database + * @param string $user Name of database user + * @param string $pass Password of database user + * @param string $name Name of database * @param int $port Port of database server */ public function __construct($type, $host, $user, $pass, $name = '', $port = 0) @@ -117,10 +117,23 @@ class DoliDBMysqli extends DoliDB $clientmustbe = 'utf8'; } - if ($this->db->character_set_name() != $clientmustbe) { - $this->db->set_charset($clientmustbe); // This set charset, but with a bad collation + $disableforcecharset = 0; // Set to 1 to test without charset forcing + if (empty($disableforcecharset) && $this->db->character_set_name() != $clientmustbe) { + try { + //print "You should set the \$dolibarr_main_db_character_set and \$dolibarr_main_db_collation for the PHP to the one of the database ".$this->db->character_set_name(); + dol_syslog(get_class($this)."::DoliDBMysqli You should set the \$dolibarr_main_db_character_set and \$dolibarr_main_db_collation for the PHP to the one of the database ".$this->db->character_set_name(), LOG_WARNING); + $this->db->set_charset($clientmustbe); // This set charset, but with a bad collation + } catch (Exception $e) { + print 'Failed to force character set to '.$clientmustbe." according to setup to match the one of the server database.
\n"; + print $e->getMessage(); + print "
\n"; + if ($clientmustbe != 'utf8') { + print 'Edit conf/conf.php file to set a charset "utf8" instead of "'.$clientmustbe.'".'."\n"; + } + exit; + } - $collation = $conf->db->dolibarr_main_db_collation; + $collation = (empty($conf) ? 'utf8_unicode_ci' : $conf->db->dolibarr_main_db_collation); if (preg_match('/latin1/', $collation)) { $collation = 'utf8_unicode_ci'; } @@ -137,7 +150,7 @@ class DoliDBMysqli extends DoliDB dol_syslog(get_class($this)."::DoliDBMysqli : Select_db error ".$this->error, LOG_ERR); } } else { - // Pas de selection de base demandee, ok ou ko + // No selection of database done. We may only be connected or not (ok or ko) to the server. $this->database_selected = false; if ($this->connected) { @@ -189,7 +202,7 @@ class DoliDBMysqli extends DoliDB * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) * @return string SQL request line converted */ - public static function convertSQLFromMysql($line, $type = 'ddl') + public function convertSQLFromMysql($line, $type = 'ddl') { return $line; } @@ -233,15 +246,16 @@ class DoliDBMysqli extends DoliDB //mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); - // Can also be - // mysqli::init(); mysql::options(MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT = 0'); mysqli::options(MYSQLI_OPT_CONNECT_TIMEOUT, 5); - // return mysqli::real_connect($host, $user, $pass, $db, $port); $tmp = false; try { if (!class_exists('mysqli')) { dol_print_error('', 'Driver mysqli for PHP not available'); } - $tmp = new mysqli($host, $login, $passwd, $name, $port); + if (strpos($host, 'ssl://') === 0) { + $tmp = new mysqliDoli($host, $login, $passwd, $name, $port); + } else { + $tmp = new mysqli($host, $login, $passwd, $name, $port); + } } catch (Exception $e) { dol_syslog(get_class($this)."::connect failed", LOG_DEBUG); } @@ -503,35 +517,35 @@ class DoliDBMysqli extends DoliDB } else { // Constants to convert a MySql error code to a generic Dolibarr error code $errorcode_map = array( - 1004 => 'DB_ERROR_CANNOT_CREATE', - 1005 => 'DB_ERROR_CANNOT_CREATE', - 1006 => 'DB_ERROR_CANNOT_CREATE', - 1007 => 'DB_ERROR_ALREADY_EXISTS', - 1008 => 'DB_ERROR_CANNOT_DROP', - 1022 => 'DB_ERROR_KEY_NAME_ALREADY_EXISTS', - 1025 => 'DB_ERROR_NO_FOREIGN_KEY_TO_DROP', - 1044 => 'DB_ERROR_ACCESSDENIED', - 1046 => 'DB_ERROR_NODBSELECTED', - 1048 => 'DB_ERROR_CONSTRAINT', - 1050 => 'DB_ERROR_TABLE_ALREADY_EXISTS', - 1051 => 'DB_ERROR_NOSUCHTABLE', - 1054 => 'DB_ERROR_NOSUCHFIELD', - 1060 => 'DB_ERROR_COLUMN_ALREADY_EXISTS', - 1061 => 'DB_ERROR_KEY_NAME_ALREADY_EXISTS', - 1062 => 'DB_ERROR_RECORD_ALREADY_EXISTS', - 1064 => 'DB_ERROR_SYNTAX', - 1068 => 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS', - 1075 => 'DB_ERROR_CANT_DROP_PRIMARY_KEY', - 1091 => 'DB_ERROR_NOSUCHFIELD', - 1100 => 'DB_ERROR_NOT_LOCKED', - 1136 => 'DB_ERROR_VALUE_COUNT_ON_ROW', - 1146 => 'DB_ERROR_NOSUCHTABLE', - 1215 => 'DB_ERROR_CANNOT_ADD_FOREIGN_KEY_CONSTRAINT', - 1216 => 'DB_ERROR_NO_PARENT', - 1217 => 'DB_ERROR_CHILD_EXISTS', - 1396 => 'DB_ERROR_USER_ALREADY_EXISTS', // When creating a user that already existing - 1451 => 'DB_ERROR_CHILD_EXISTS', - 1826 => 'DB_ERROR_KEY_NAME_ALREADY_EXISTS' + 1004 => 'DB_ERROR_CANNOT_CREATE', + 1005 => 'DB_ERROR_CANNOT_CREATE', + 1006 => 'DB_ERROR_CANNOT_CREATE', + 1007 => 'DB_ERROR_ALREADY_EXISTS', + 1008 => 'DB_ERROR_CANNOT_DROP', + 1022 => 'DB_ERROR_KEY_NAME_ALREADY_EXISTS', + 1025 => 'DB_ERROR_NO_FOREIGN_KEY_TO_DROP', + 1044 => 'DB_ERROR_ACCESSDENIED', + 1046 => 'DB_ERROR_NODBSELECTED', + 1048 => 'DB_ERROR_CONSTRAINT', + 1050 => 'DB_ERROR_TABLE_ALREADY_EXISTS', + 1051 => 'DB_ERROR_NOSUCHTABLE', + 1054 => 'DB_ERROR_NOSUCHFIELD', + 1060 => 'DB_ERROR_COLUMN_ALREADY_EXISTS', + 1061 => 'DB_ERROR_KEY_NAME_ALREADY_EXISTS', + 1062 => 'DB_ERROR_RECORD_ALREADY_EXISTS', + 1064 => 'DB_ERROR_SYNTAX', + 1068 => 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS', + 1075 => 'DB_ERROR_CANT_DROP_PRIMARY_KEY', + 1091 => 'DB_ERROR_NOSUCHFIELD', + 1100 => 'DB_ERROR_NOT_LOCKED', + 1136 => 'DB_ERROR_VALUE_COUNT_ON_ROW', + 1146 => 'DB_ERROR_NOSUCHTABLE', + 1215 => 'DB_ERROR_CANNOT_ADD_FOREIGN_KEY_CONSTRAINT', + 1216 => 'DB_ERROR_NO_PARENT', + 1217 => 'DB_ERROR_CHILD_EXISTS', + 1396 => 'DB_ERROR_USER_ALREADY_EXISTS', // When creating a user that already existing + 1451 => 'DB_ERROR_CHILD_EXISTS', + 1826 => 'DB_ERROR_KEY_NAME_ALREADY_EXISTS' ); if (isset($errorcode_map[$this->db->errno])) { @@ -1075,7 +1089,7 @@ class DoliDBMysqli extends DoliDB */ public function getDefaultCharacterSetDatabase() { - $resql = $this->query('SHOW VARIABLES LIKE \'character_set_database\''); + $resql = $this->query("SHOW VARIABLES LIKE 'character_set_database'"); if (!$resql) { // version Mysql < 4.1.1 return $this->forcecharset; @@ -1118,7 +1132,7 @@ class DoliDBMysqli extends DoliDB */ public function getDefaultCollationDatabase() { - $resql = $this->query('SHOW VARIABLES LIKE \'collation_database\''); + $resql = $this->query("SHOW VARIABLES LIKE 'collation_database'"); if (!$resql) { // version Mysql < 4.1.1 return $this->forcecollate; @@ -1161,7 +1175,7 @@ class DoliDBMysqli extends DoliDB { $fullpathofdump = '/pathtomysqldump/mysqldump'; - $resql = $this->query('SHOW VARIABLES LIKE \'basedir\''); + $resql = $this->query("SHOW VARIABLES LIKE 'basedir'"); if ($resql) { $liste = $this->fetch_array($resql); $basedir = $liste['Value']; @@ -1179,7 +1193,7 @@ class DoliDBMysqli extends DoliDB { $fullpathofimport = '/pathtomysql/mysql'; - $resql = $this->query('SHOW VARIABLES LIKE \'basedir\''); + $resql = $this->query("SHOW VARIABLES LIKE 'basedir'"); if ($resql) { $liste = $this->fetch_array($resql); $basedir = $liste['Value']; @@ -1236,3 +1250,33 @@ class DoliDBMysqli extends DoliDB return $result; } } + +/** + * Class to make SSL connection + */ +class mysqliDoli extends mysqli +{ + /** + * Constructor. + * This create an opened connexion to a database server and eventually to a database + * + * @param string $host Address of database server + * @param string $user Name of database user + * @param string $pass Password of database user + * @param string $name Name of database + * @param int $port Port of database server + * @param string $socket Socket + */ + public function __construct($host, $user, $pass, $name, $port = 0, $socket = "") + { + $flags = 0; + parent::init(); + if (strpos($host, 'ssl://') === 0) { + $host = substr($host, 6); + parent::options(MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, false); + parent::ssl_set(null, null, "", null, null); + $flags = MYSQLI_CLIENT_SSL; + } + parent::real_connect($host, $user, $pass, $name, $port, $socket, $flags); + } +} diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 2923992e345..2db5a1a8d04 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -50,11 +50,19 @@ class DoliDBPgsql extends DoliDB //! Version min database const VERSIONMIN = '9.0.0'; // Version min database + /** + * @var boolean $unescapeslashquot Set this to 1 when calling SQL queries, to say that SQL is not standard but already escaped for Mysql. Used by Postgresql driver + */ + public $unescapeslashquot = false; + /** + * @var boolean $standard_conforming_string Set this to true if postgres accept only standard encoding of sting using '' and not \' + */ + public $standard_conforming_strings = false; + + /** @var resource|boolean Resultset of last query */ private $_results; - public $unescapeslashquot; - public $standard_conforming_strings; /** @@ -146,10 +154,10 @@ class DoliDBPgsql extends DoliDB * * @param string $line SQL request line to convert * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) - * @param bool $unescapeslashquot Unescape slash quote with quote quote + * @param bool $unescapeslashquot Unescape "slash quote" with "quote quote" * @return string SQL request line converted */ - public static function convertSQLFromMysql($line, $type = 'auto', $unescapeslashquot = false) + public function convertSQLFromMysql($line, $type = 'auto', $unescapeslashquot = false) { global $conf; diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php index 7255990fa64..5d2502cf935 100644 --- a/htdocs/core/db/sqlite3.class.php +++ b/htdocs/core/db/sqlite3.class.php @@ -138,7 +138,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) * @return string SQL request line converted */ - public static function convertSQLFromMysql($line, $type = 'ddl') + public function convertSQLFromMysql($line, $type = 'ddl') { // Removed empty line if this is a comment line for SVN tagging if (preg_match('/^--\s\$Id/i', $line)) { diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 37c0bfc6744..5afdab071a1 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -1048,9 +1048,11 @@ function document_preview(file, type, title) optionsbuttons = {} if (mode == 'image' && showOriginalSizeButton) - { + { + var curRot = 0; optionsbuttons = { "transnoentitiesnoconv("OriginalSize")); ?>": function() { console.log("Click on original size"); jQuery(".ui-dialog-content.ui-widget-content > object").css({ "max-height": "none" }); }, + "transnoentitiesnoconv("RotateImage")); ?>": function() { curRot += 90; jQuery(".ui-dialog-content.ui-widget-content > object").css("transform","rotate(" + curRot + "deg)"); }, "transnoentitiesnoconv("CloseWindow")); ?>": function() { $( this ).dialog( "close" ); } }; } diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 34ca110dd1e..7f42be9b30b 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -627,7 +627,7 @@ function ajax_event($htmlname, $events) * @param string $morecss More CSS * @return string */ -function ajax_constantonoff($code, $input = array(), $entity = null, $revertonoff = 0, $strict = 0, $forcereload = 0, $marginleftonlyshort = 2, $forcenoajax = 0, $setzeroinsteadofdel = 0, $suffix = '', $mode = '', $morecss = '') +function ajax_constantonoff($code, $input = array(), $entity = null, $revertonoff = 0, $strict = 0, $forcereload = 0, $marginleftonlyshort = 2, $forcenoajax = 0, $setzeroinsteadofdel = 0, $suffix = '', $mode = '', $morecss = 'inline-block') { global $conf, $langs, $user; @@ -685,8 +685,8 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof '."\n"; $out .= ''; - $out .= ''.($revertonoff ?img_picto($langs->trans("Enabled"), 'switch_on', '', false, 0, 0, '', '', $marginleftonlyshort) : img_picto($langs->trans("Disabled"), 'switch_off', '', false, 0, 0, '', '', $marginleftonlyshort)).''; - $out .= ''.($revertonoff ?img_picto($langs->trans("Disabled"), 'switch_off'.$suffix, '', false, 0, 0, '', '', $marginleftonlyshort) : img_picto($langs->trans("Enabled"), 'switch_on'.$suffix, '', false, 0, 0, '', '', $marginleftonlyshort)).''; + $out .= ''.($revertonoff ?img_picto($langs->trans("Enabled"), 'switch_on', '', false, 0, 0, '', '', $marginleftonlyshort) : img_picto($langs->trans("Disabled"), 'switch_off', '', false, 0, 0, '', '', $marginleftonlyshort)).''; + $out .= ''.($revertonoff ?img_picto($langs->trans("Disabled"), 'switch_off'.$suffix, '', false, 0, 0, '', '', $marginleftonlyshort) : img_picto($langs->trans("Enabled"), 'switch_on'.$suffix, '', false, 0, 0, '', '', $marginleftonlyshort)).''; $out .= "\n"; } diff --git a/htdocs/core/lib/asset.lib.php b/htdocs/core/lib/asset.lib.php index be31f995657..bfa95ce9c0a 100644 --- a/htdocs/core/lib/asset.lib.php +++ b/htdocs/core/lib/asset.lib.php @@ -88,7 +88,7 @@ function assetPrepareHead(Asset $object) { global $db, $langs, $conf; - $langs->load("assets", "admin"); + $langs->loadLangs(array("assets", "admin")); $h = 0; $head = array(); @@ -184,7 +184,7 @@ function assetModelPrepareHead($object) { global $langs, $conf; - $langs->load("assets", "admin"); + $langs->loadLangs(array("assets", "admin")); $h = 0; $head = array(); diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php index 72f015197ba..56476cef4be 100644 --- a/htdocs/core/lib/bank.lib.php +++ b/htdocs/core/lib/bank.lib.php @@ -273,12 +273,17 @@ function various_payment_prepare_head($object) /** * Check SWIFT informations for a bank account * - * @param Account $account A bank account + * @param Account $account A bank account (used to get BIC/SWIFT) + * @param string $swift Swift value (used to get BIC/SWIFT, param $account non used if provided) * @return boolean True if informations are valid, false otherwise */ -function checkSwiftForAccount($account) +function checkSwiftForAccount(Account $account = null, $swift = null) { - $swift = $account->bic; + if ($account == null && $swift == null) { + return false; + } elseif ($swift == null) { + $swift = $account->bic; + } if (preg_match("/^([a-zA-Z]){4}([a-zA-Z]){2}([0-9a-zA-Z]){2}([0-9a-zA-Z]{3})?$/", $swift)) { return true; } else { @@ -289,15 +294,19 @@ function checkSwiftForAccount($account) /** * Check IBAN number informations for a bank account. * - * @param Account $account A bank account - * @return boolean True if informations are valid, false otherwise + * @param Account $account A bank account + * @param string $ibantocheck Bank account number (used to get BAN, $account not used if provided) + * @return boolean True if informations are valid, false otherwise */ -function checkIbanForAccount(Account $account) +function checkIbanForAccount(Account $account = null, $ibantocheck = null) { + if ($account == null && $ibantocheck == null) { + return false; + } elseif ($ibantocheck == null) { + $ibantocheck = ($account->iban ? $account->iban : $account->iban_prefix); // iban or iban_prefix for backward compatibility + } require_once DOL_DOCUMENT_ROOT.'/includes/php-iban/oophp-iban.php'; - $ibantocheck = ($account->iban ? $account->iban : $account->iban_prefix); // iban or iban_prefix for backward compatibility - $iban = new PHP_IBAN\IBAN($ibantocheck); $check = $iban->Verify(); diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index a2ae0e8f7a2..aa72026f563 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -188,7 +188,7 @@ function societe_prepare_head(Societe $object) } // Bank accounts - if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT)) { + if (!getDolGlobalInt('SOCIETE_DISABLE_BANKACCOUNT')) { $nbBankAccount = 0; $foundonexternalonlinesystem = 0; $langs->load("bills"); @@ -242,13 +242,28 @@ function societe_prepare_head(Societe $object) $h++; } - if (isModEnabled('website') && (!empty($conf->global->WEBSITE_USE_WEBSITE_ACCOUNTS)) && ($user->hasRight('societe', 'lire'))) { + if ( + ((isModEnabled('website') && !empty($conf->global->WEBSITE_USE_WEBSITE_ACCOUNTS)) || isModEnabled('webportal')) + && $user->hasRight('societe', 'lire') + ) { + $site_filter_list = array(); + if (isModEnabled('website')) { + $site_filter_list[] = 'dolibarr_website'; + } + if (isModEnabled('webportal')) { + $site_filter_list[] = 'dolibarr_portal'; + } + $head[$h][0] = DOL_URL_ROOT.'/societe/website.php?id='.urlencode($object->id); $head[$h][1] = $langs->trans("WebSiteAccounts"); $nbNote = 0; $sql = "SELECT COUNT(n.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_account as n"; - $sql .= " WHERE fk_soc = ".((int) $object->id).' AND fk_website > 0'; + $sql .= " WHERE fk_soc = ".((int) $object->id); + $sql .= " AND entity IN (".getEntity('thirdpartyaccount').")"; + if (!empty($site_filter_list)) { + $sql .= " AND n.site IN (".$db->sanitize("'".implode("','", $site_filter_list)."'", 1).")"; + } $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); @@ -273,6 +288,7 @@ function societe_prepare_head(Societe $object) $sql = "SELECT COUNT(n.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."partnership as n"; $sql .= " WHERE fk_soc = ".((int) $object->id); + $sql .= " AND entity IN (".getEntity('partnership').")"; $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); @@ -387,6 +403,7 @@ function societe_prepare_head(Societe $object) $sql = "SELECT COUNT(id) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm"; $sql .= " WHERE fk_soc = ".((int) $object->id); + $sql .= " AND entity IN (".getEntity('agenda').")"; $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); @@ -716,7 +733,7 @@ function getFormeJuridiqueLabel($code) return ''; } - $sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."c_forme_juridique"; + $sql = "SELECT libelle as label FROM ".MAIN_DB_PREFIX."c_forme_juridique"; $sql .= " WHERE code = '".$db->escape($code)."'"; dol_syslog("Company.lib::getFormeJuridiqueLabel", LOG_DEBUG); @@ -727,7 +744,7 @@ function getFormeJuridiqueLabel($code) if ($num) { $obj = $db->fetch_object($resql); - $label = ($obj->libelle != '-' ? $obj->libelle : ''); + $label = ($obj->label != '-' ? $obj->label : ''); return $langs->trans($label); } else { @@ -809,7 +826,7 @@ function isInEEC($object) */ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatelink = 0, $morehtmlright = '') { - global $user, $action, $hookmanager; + global $user, $action, $hookmanager, $form, $massactionbutton, $massaction, $arrayofselected, $arrayofmassactions; $i = -1; @@ -848,6 +865,10 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel print '
'; print ''; print ''; + print ''; print ''; if ($num > 0) { @@ -899,6 +920,18 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel // Status print ''; + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } print ''; } $i++; @@ -1672,8 +1705,12 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $sql .= ", ".MAIN_DB_PREFIX."bom_bom as o"; } elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') { $sql .= ", ".MAIN_DB_PREFIX."contrat as o"; - } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && (!empty($filterobj->fields['ref']) && is_array($filterobj->fields['ref']) || $filterobj->fields['label'] && is_array($filterobj->fields['label'])) && $filterobj->table_element && $filterobj->element) { + } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) + && ((!empty($filterobj->fields['ref']) && is_array($filterobj->fields['ref'])) || (!empty($filterobj->fields['label']) && is_array($filterobj->fields['label'])) || (!empty($filterobj->fields['titre']) && is_array($filterobj->fields['titre']))) + && $filterobj->table_element && $filterobj->element) { $sql .= ", ".MAIN_DB_PREFIX.$filterobj->table_element." as o"; + } elseif (is_object($filterobj)) { + return 'Bad value for $filterobj'; } $sql .= " WHERE a.entity IN (".getEntity('agenda').")"; @@ -1724,12 +1761,16 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin if ($filterobj->id) { $sql .= " AND a.fk_element = ".((int) $filterobj->id); } - } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && (!empty($filterobj->fields['ref']) && is_array($filterobj->fields['ref']) || $filterobj->fields['label'] && is_array($filterobj->fields['label'])) && $filterobj->table_element && $filterobj->element) { - // Generic case + } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) + && ((!empty($filterobj->fields['ref']) && is_array($filterobj->fields['ref'])) || (!empty($filterobj->fields['label']) && is_array($filterobj->fields['label'])) || (!empty($filterobj->fields['titre']) && is_array($filterobj->fields['titre']))) + && $filterobj->table_element && $filterobj->element) { + // Generic case (if there is a $filterobj and a field rowid and (ref or label) exists. $sql .= " AND a.fk_element = o.rowid AND a.elementtype = '".$db->escape($filterobj->element).($module ? "@".$module : "")."'"; if ($filterobj->id) { $sql .= " AND a.fk_element = ".((int) $filterobj->id); } + } elseif (is_object($filterobj)) { + return 'Bad value for $filterobj'; } } @@ -2008,10 +2049,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $out .= ''; // Author of event - $out .= ''; // Title/Label of event $out .= '\n"; - // Title of event - //$out.=''; - // Linked object $out .= ''; diff --git a/htdocs/core/lib/contact.lib.php b/htdocs/core/lib/contact.lib.php index 088504fbde4..4efa35556e6 100644 --- a/htdocs/core/lib/contact.lib.php +++ b/htdocs/core/lib/contact.lib.php @@ -187,7 +187,7 @@ function show_contacts_projects($conf, $langs, $db, $object, $backtopage = '', $ print "\n".'
'; @@ -718,7 +722,40 @@ class FormFile if ($conf->browser->layout == 'phone') { $morecss = 'maxwidth100'; } - $out .= $form->selectarray('model', $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss); + $out .= $form->selectarray('model', $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1, '', 0, 0); + // script for select the separator + /* TODO This must appear on export feature only + $out .= ''; + $out .= ''; + $out .= ''; + + $out .= ''; + */ if ($conf->use_javascript_ajax) { $out .= ajax_combobox('model'); } @@ -976,6 +1013,18 @@ class FormFile } } $out .= ''."\n"; + + $out .= ''; //return ($i?$i:$headershown); return $out; } @@ -1593,7 +1642,7 @@ class FormFile public function list_of_autoecmfiles($upload_dir, $filearray, $modulepart, $param, $forcedownload = 0, $relativepath = '', $permissiontodelete = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $url = '', $addfilterfields = 0) { // phpcs:enable - global $user, $conf, $langs, $hookmanager, $form; + global $conf, $langs, $hookmanager, $form; global $sortfield, $sortorder; global $search_doc_ref; global $dolibarr_main_url_root; @@ -1814,7 +1863,7 @@ class FormFile } $found = 0; - if (!empty($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) { + if (!empty($conf->cache['modulepartobject'][$modulepart.'_'.$id.'_'.$ref])) { $found = 1; } else { //print 'Fetch '.$id." - ".$ref.' class='.get_class($object_instance).'
'; @@ -1839,24 +1888,24 @@ class FormFile if ($result > 0) { // Save object loaded into a cache $found = 1; - $this->cache_objects[$modulepart.'_'.$id.'_'.$ref] = clone $object_instance; + $conf->cache['modulepartobject'][$modulepart.'_'.$id.'_'.$ref] = clone $object_instance; } if ($result == 0) { $found = 1; - $this->cache_objects[$modulepart.'_'.$id.'_'.$ref] = 'notfound'; + $conf->cache['modulepartobject'][$modulepart.'_'.$id.'_'.$ref] = 'notfound'; unset($filearray[$key]); } } - if ($found <= 0 || !is_object($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) { + if ($found <= 0 || !is_object($conf->cache['modulepartobject'][$modulepart.'_'.$id.'_'.$ref])) { continue; // We do not show orphelins files } print ''."\n"; print '
'; - if ($found > 0 && is_object($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) { - $tmpobject = $this->cache_objects[$modulepart.'_'.$id.'_'.$ref]; + if ($found > 0 && is_object($conf->cache['modulepartobject'][$modulepart.'_'.$id.'_'.$ref])) { + $tmpobject = $conf->cache['modulepartobject'][$modulepart.'_'.$id.'_'.$ref]; //if (! in_array($tmpobject->element, array('expensereport'))) { print $tmpobject->getNomUrl(1, 'document'); //} else { diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 9c9cbdafc41..b32eafcd79c 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -134,6 +134,7 @@ class FormMail extends Form public $withtocc; public $withtoccc; public $withtopic; + public $witherrorsto; /** * @var int 0=No attaches files, 1=Show attached files, 2=Can add new attached files @@ -150,13 +151,21 @@ class FormMail extends Form public $withreplytoreadonly; public $withtoreadonly; public $withtoccreadonly; + public $witherrorstoreadonly; public $withtocccreadonly; public $withtopicreadonly; + public $withbodyreadonly; public $withfilereadonly; public $withdeliveryreceipt; public $withcancel; + public $withdeliveryreceiptreadonly; public $withfckeditor; + /** + * @var string ckeditortoolbar + */ + public $ckeditortoolbar; + public $substit = array(); public $substit_lines = array(); public $param = array(); @@ -277,7 +286,7 @@ class FormMail extends Form /** * Remove a file from the list of attached files (stored in SECTION array) * - * @param string $keytodelete Key index in file array (0, 1, 2, ...) + * @param int $keytodelete Key index in file array (0, 1, 2, ...) * @return void */ public function remove_attached_files($keytodelete) @@ -614,6 +623,11 @@ class FormMail extends Form 'global_aliases' => getDolGlobalString('MAIN_INFO_SOCIETE_MAIL_ALIASES'), ); + if (!empty($arraydefaultmessage->email_from)) { + $templatemailfrom = ' <'.$arraydefaultmessage->email_from.'>'; + $liste['from_template_'.GETPOST('modelmailselected')] = array('label' => $templatemailfrom, 'data-html' => $templatemailfrom); + } + // Also add robot email if (!empty($this->fromalsorobot)) { if (!empty($conf->global->MAIN_MAIL_EMAIL_FROM) && getDolGlobalString('MAIN_MAIL_EMAIL_FROM') != getDolGlobalString('MAIN_INFO_SOCIETE_MAIL')) { @@ -661,9 +675,16 @@ class FormMail extends Form } } - // Using combo here make the '' no more visible on list. - //$out.= ' '.$form->selectarray('fromtype', $liste, $this->fromtype, 0, 0, 0, '', 0, 0, 0, '', 'fromforsendingprofile maxwidth200onsmartphone', 1, '', $disablebademails); - $out .= ' '.$form->selectarray('fromtype', $liste, $this->fromtype, 0, 0, 0, '', 0, 0, 0, '', 'fromforsendingprofile maxwidth200onsmartphone', 0, '', $disablebademails); + // Using ajaxcombo here make the '' no more visible on list because is not a valid html tag, + // so we transform before each record into $liste to be printable with ajaxcombo by replacing <> into () + // $liste['senderprofile_0_0'] = array('label'=>'rrr', 'data-html'=>'rrr <aaaa>'); + foreach ($liste as $key => $val) { + if (!empty($liste[$key]['data-html'])) { + $liste[$key]['data-html'] = str_replace(array('<', '<', '>', '>'), array('__LTCHAR__', '__LTCHAR__', '__GTCHAR__', '__GTCHAR__'), $liste[$key]['data-html']); + $liste[$key]['data-html'] = str_replace(array('__LTCHAR__', '__GTCHAR__'), array('(', ')'), $liste[$key]['data-html']); + } + } + $out .= ' '.$form->selectarray('fromtype', $liste, empty($arraydefaultmessage->email_from) ? $this->fromtype : 'from_template_'.GETPOST('modelmailselected'), 0, 0, 0, '', 0, 0, 0, '', 'fromforsendingprofile maxwidth200onsmartphone', 1, '', $disablebademails); } $out .= "
'.$langs->trans("SmsFrom").""; - //print ''; - if ($conf->global->MAIN_SMS_SENDMODE == 'ovh') { // For backward compatibility @deprecated - dol_include_once('/ovh/class/ovhsms.class.php'); - try { - $sms = new OvhSms($this->db); - if (empty($conf->global->OVHSMS_ACCOUNT)) { - $resultsender = 'ErrorOVHSMS_ACCOUNT not defined'; - } else { - $resultsender = $sms->SmsSenderList(); - } - } catch (Exception $e) { - dol_print_error('', 'Error to get list of senders: '.$e->getMessage()); + if (getDolGlobalString('MAIN_SMS_SENDMODE')) { + $sendmode = getDolGlobalString('MAIN_SMS_SENDMODE'); // $conf->global->MAIN_SMS_SENDMODE looks like a value 'module' + $classmoduleofsender = getDolGlobalString('MAIN_MODULE_'.strtoupper($sendmode).'_SMS', $sendmode); // $conf->global->MAIN_MODULE_XXX_SMS looks like a value 'class@module' + if ($classmoduleofsender == 'ovh') { + $classmoduleofsender = 'ovhsms@ovh'; // For backward compatibility } - } elseif (!empty($conf->global->MAIN_SMS_SENDMODE)) { // $conf->global->MAIN_SMS_SENDMODE looks like a value 'class@module' - $tmp = explode('@', $conf->global->MAIN_SMS_SENDMODE); + + $tmp = explode('@', $classmoduleofsender); $classfile = $tmp[0]; $module = (empty($tmp[1]) ? $tmp[0] : $tmp[1]); dol_include_once('/'.$module.'/class/'.$classfile.'.class.php'); @@ -210,7 +204,7 @@ function limitChars(textarea, limit, infodiv) $resultsender = $sms->SmsSenderList(); } else { $sms = new stdClass(); - $sms->error = 'The SMS manager "'.$classfile.'" defined into SMS setup MAIN_SMS_SENDMODE is not found'; + $sms->error = 'The SMS manager "'.$classfile.'" defined into SMS setup MAIN_MODULE_'.strtoupper($sendmode).'_SMS is not found'; } } catch (Exception $e) { dol_print_error('', 'Error to get list of senders: '.$e->getMessage()); diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 47f9c6d0778..5a1823c03c0 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2019-2022 Frédéric France * Copyright (C) 2021 Juanjo Menent * Copyright (C) 2021 Alexandre Spangaro + * Copyright (C) 2023 Charlene Benke * * 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 @@ -651,6 +652,16 @@ class FormTicket } } + if ($subelement != 'contract') { + if (isModEnabled('contract') && !$this->ispublic) { + $formcontract = new FormContract($this->db); + print '
'; + print img_picto('', 'contract'); + print $formcontract->select_contract(-1, GETPOST('contactid', 'int'), 'contractid', 0, 1, 1); + print '
'.$langs->trans("OpportunityStatusShort").''.$langs->trans("OpportunityProbabilityShort").''.$langs->trans("Status").''; + $selectedfields = (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + print $selectedfields; + print '
'.$projecttmp->getLibStatut(5).''; + if ($massactionbutton || $massaction) { + $selected = 0; + if (in_array($obj->id, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print '
'; - //$userstatic->id=$histo[$key]['userid']; - //$userstatic->login=$histo[$key]['login']; - //$out.=$userstatic->getLoginUrl(1); + $out .= ''; if ($histo[$key]['userid'] > 0) { if (isset($userlinkcache[$histo[$key]['userid']])) { $link = $userlinkcache[$histo[$key]['userid']]; @@ -2039,17 +2077,18 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $labeltype .= ' - '.$arraylist[$actionstatic->code]; // Use code in priority on type_code } } - $out .= ''; + $out .= ''; $out .= $actionstatic->getTypePicto(); - $out .= $labeltype; + //if (empty($conf->dol_optimize_smallscreen)) { + $out .= $labeltype; + //} $out .= 'trans("Action".$histo[$key]['acode']); - $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : $histo[$key]['alabel']); - //$actionstatic->libelle=$libelle; + //$libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : $histo[$key]['alabel']); $libelle = $histo[$key]['note']; $actionstatic->id = $histo[$key]['id']; $out .= ' title="'.dol_escape_htmltag($libelle).'">'; @@ -2094,9 +2133,6 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin } $out .= "'.dol_trunc($histo[$key]['note'], 40).''; if (isset($histo[$key]['elementtype']) && !empty($histo[$key]['fk_element'])) { @@ -2110,8 +2146,6 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $elementlinkcache[$histo[$key]['elementtype']][$histo[$key]['fk_element']] = $link; } $out .= $link; - } else { - $out .= ' '; } $out .= '
'; $sql = 'SELECT p.rowid as id, p.entity, p.title, p.ref, p.public, p.dateo as do, p.datee as de, p.fk_statut as status, p.fk_opp_status, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount'; - $sql .= ', cls.code as opp_status_code, ctc.libelle'; + $sql .= ', cls.code as opp_status_code, ctc.libelle as type_label'; $sql .= ' FROM '.MAIN_DB_PREFIX.'projet as p'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls on p.fk_opp_status = cls.rowid'; $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact as cc ON (p.rowid = cc.element_id)'; @@ -236,8 +236,8 @@ function show_contacts_projects($conf, $langs, $db, $object, $backtopage = '', $ print ''; // Label - print ''; - print ''; + print ''; + print ''; // Date start print ''; // Date end diff --git a/htdocs/core/lib/contract.lib.php b/htdocs/core/lib/contract.lib.php index 75ffdbf9a7c..f5bc76625cb 100644 --- a/htdocs/core/lib/contract.lib.php +++ b/htdocs/core/lib/contract.lib.php @@ -1,6 +1,7 @@ * Copyright (C) 2009-2012 Regis Houssin + * Copyright (C) 2023 Charlene BENKE * * 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,6 +52,14 @@ function contract_prepare_head(Contrat $object) $h++; } + /* deprecated. Contracts and tickets are already linked with the generic "Link to" feature */ + if (isModEnabled('ticket') && getDolGlobalString('TICKET_LINK_TO_CONTRACT_WITH_HARDLINK')) { + $head[$h][0] = DOL_URL_ROOT.'/contrat/ticket.php?id='.$object->id; + $head[$h][1] = $langs->trans("Tickets"); + $head[$h][2] = 'ticket'; + $h++; + } + // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 40d42b0c399..140de247d2a 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1333,7 +1333,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable */ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, $object = null, $allowdotdot = false, $indexdatabase = 1, $nolog = 0) { - global $db, $conf, $user, $langs; + global $db, $user, $langs; global $hookmanager; // Load translation files required by the page @@ -1351,7 +1351,7 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, } $reshook = 0; - if (empty($nohook)) { + if (empty($nohook) && !empty($hookmanager)) { $hookmanager->initHooks(array('fileslib')); $parameters = array( @@ -1885,7 +1885,7 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess $linkObject->objectid = GETPOST('objectid', 'int'); $linkObject->label = GETPOST('label', 'alpha'); $res = $linkObject->create($user); - $langs->load('link'); + if ($res > 0) { setEventMessages($langs->trans("LinkComplete"), null, 'mesgs'); } else { @@ -2638,7 +2638,8 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } $original_file = $conf->user->dir_output.'/'.$original_file; } elseif ($modulepart == 'userphotopublic' && !empty($conf->user->dir_output)) { - // Wrapping for users photos that were set to public by their owner (public user photos can be read with the public link and securekey) + // Wrapping for users photos that were set to public (for virtual credit card) by their owner (public user photos can be read + // with the public link and securekey) $accessok = false; $reg = array(); if (preg_match('/^(\d+)\/photos\//', $original_file, $reg)) { @@ -2884,7 +2885,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, if (empty($entity) || empty($conf->societe->multidir_output[$entity])) { return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); } - if ($fuser->rights->societe->{$lire} || preg_match('/^specimen/i', $original_file)) { + if ($fuser->hasRight('societe', $lire) || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->societe->multidir_output[$entity].'/'.$original_file; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 2a89b730be4..52728245c6d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -123,12 +123,18 @@ if (!function_exists('str_contains')) { function getMultidirOutput($object, $module = '') { global $conf; + if (!is_object($object) && empty($module)) { return null; } if (empty($module) && !empty($object->element)) { $module = $object->element; } + // Special case for backward compatibility + if ($module == 'fichinter') { + $module = 'ficheinter'; + } + return $conf->$module->multidir_output[(!empty($object->entity) ? $object->entity : $conf->entity)]; } @@ -490,14 +496,14 @@ function getBrowserInfo($user_agent) */ function dol_shutdown() { - global $user, $langs, $db; + global $db; $disconnectdone = false; $depth = 0; if (is_object($db) && !empty($db->connected)) { $depth = $db->transaction_opened; $disconnectdone = $db->close(); } - dol_syslog("--- End access to ".$_SERVER["PHP_SELF"].(($disconnectdone && $depth) ? ' (Warn: db disconnection forced, transaction depth was '.$depth.')' : ''), (($disconnectdone && $depth) ? LOG_WARNING : LOG_INFO)); + dol_syslog("--- End access to ".(empty($_SERVER["PHP_SELF"]) ? 'unknown' : $_SERVER["PHP_SELF"]).(($disconnectdone && $depth) ? ' (Warn: db disconnection forced, transaction depth was '.$depth.')' : ''), (($disconnectdone && $depth) ? LOG_WARNING : LOG_INFO)); } /** @@ -635,7 +641,7 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null } if (empty($method) || $method == 3 || $method == 4) { - $relativepathstring = $_SERVER["PHP_SELF"]; + $relativepathstring = (empty($_SERVER["PHP_SELF"]) ? '' : $_SERVER["PHP_SELF"]); // Clean $relativepathstring if (constant('DOL_URL_ROOT')) { $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'), '/').'/', '', $relativepathstring); @@ -1589,9 +1595,9 @@ function dol_escape_json($stringtoescape) /** * Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input fields. * When we output string on pages, we use - * - dol_string_onlythesehtmltags(dol_htmlentitiesbr()) for notes, - * - dol_escape_htmltag() for simple labels. - * - htmlspecialchars( , ENT_COMPAT, 'UTF-8') for passwords + * - dol_escape_htmltag(dol_htmlwithnojs(dol_string_onlythesehtmltags(dol_htmlentitiesbr(), 1, 1, 1), 1, 1) for notes or descriptions, + * - dol_escape_htmltag(dol_htmlentitiesbr()) for simple labels. + * - htmlspecialchars( , ENT_COMPAT, 'UTF-8') for passwords * * @param string $stringtoescape String to escape * @param int $keepb 1=Keep b tags, 0=remove them completely @@ -2795,11 +2801,11 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = // Analyze date $reg = array(); if (preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i', $time, $reg)) { // Deprecated. Ex: 1970-01-01, 1970-01-01 01:00:00, 19700101010000 - dol_print_error('', "Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER["PHP_SELF"]); + dol_print_error('', "Functions.lib::dol_print_date function called with a bad value from page ".(empty($_SERVER["PHP_SELF"]) ? 'unknown' : $_SERVER["PHP_SELF"])); return ''; } elseif (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $time, $reg)) { // Still available to solve problems in extrafields of type date // This part of code should not be used anymore. - dol_syslog("Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER["PHP_SELF"], LOG_WARNING); + dol_syslog("Functions.lib::dol_print_date function called with a bad value from page ".(empty($_SERVER["PHP_SELF"]) ? 'unknown' : $_SERVER["PHP_SELF"]), LOG_WARNING); //if (function_exists('debug_print_backtrace')) debug_print_backtrace(); // Date has format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' $syear = (!empty($reg[1]) ? $reg[1] : ''); @@ -3136,7 +3142,7 @@ function dol_print_size($size, $shortvalue = 0, $shortunit = 0) * @param string $morecss More CSS * @return string HTML Link */ -function dol_print_url($url, $target = '_blank', $max = 32, $withpicto = 0, $morecss = 'float') +function dol_print_url($url, $target = '_blank', $max = 32, $withpicto = 0, $morecss = '') { global $langs; @@ -3144,26 +3150,30 @@ function dol_print_url($url, $target = '_blank', $max = 32, $withpicto = 0, $mor return ''; } - $link = 'trans("URL").': '.$url.'"'; + $linkstart .= '>'; + + $link = ''; if (!preg_match('/^http/i', $url)) { $link .= 'http://'; } $link .= dol_trunc($url, $max); - $link .= ''; - if ($morecss == 'float') { + $linkend = ''; + + if ($morecss == 'float') { // deprecated return '
'.($withpicto ?img_picto($langs->trans("Url"), 'globe').' ' : '').$link.'
'; } else { - return ''.($withpicto ?img_picto($langs->trans("Url"), 'globe').' ' : '').$link.''; + return $linkstart.''.($withpicto ?img_picto('', 'globe').' ' : '').$link.''.$linkend; } } @@ -3280,11 +3290,11 @@ function getArrayOfSocialNetworks() /** * Show social network link * - * @param string $value Skype to show (only skype, without 'Name of recipient' before) + * @param string $value Social network ID to show (only skype, without 'Name of recipient' before) * @param int $cid Id of contact if known * @param int $socid Id of third party if known * @param string $type 'skype','facebook',... - * @param array $dictsocialnetworks socialnetworks availables + * @param array $dictsocialnetworks List of socialnetworks availables * @return string HTML Link */ function dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetworks = array()) @@ -3397,7 +3407,7 @@ function dol_print_profids($profID, $profIDtype, $countrycode = '', $addcpButton * @param int $cid Id of contact if known * @param int $socid Id of third party if known * @param string $addlink ''=no link to create action, 'AC_TEL'=add link to clicktodial (if module enabled) and add link to create event (if conf->global->AGENDA_ADDACTIONFORPHONE set), 'tel'=Force "tel:..." link - * @param string $separ Separation between numbers for a better visibility example : xx.xx.xx.xx.xx + * @param string $separ Separation between numbers for a better visibility example : xx.xx.xx.xx.xx. You can also use 'hidenum' to hide the number, keep only the picto. * @param string $withpicto Show picto ('fax', 'phone', 'mobile') * @param string $titlealt Text to show on alt * @param int $adddivfloat Add div float around phone. @@ -3603,21 +3613,19 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2); } } + + $newphoneastart = $newphoneaend = ''; if (!empty($addlink)) { // Link on phone number (+ link to add action if conf->global->AGENDA_ADDACTIONFORPHONE set) if ($addlink == 'tel' || $conf->browser->layout == 'phone' || (isModEnabled('clicktodial') && !empty($conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS))) { // If phone or option for, we use link of phone - $newphoneform = $newphone; - $newphone = ''; + $newphoneastart = ''; + $newphoneaend .= ''; } elseif (isModEnabled('clicktodial') && $addlink == 'AC_TEL') { // If click to dial, we use click to dial url if (empty($user->clicktodial_loaded)) { $user->fetch_clicktodial(); } // Define urlmask - $urlmask = 'ErrorClickToDialModuleNotConfigured'; - if (!empty($conf->global->CLICKTODIAL_URL)) { - $urlmask = $conf->global->CLICKTODIAL_URL; - } + $urlmask = getDolGlobalString('CLICKTODIAL_URL', 'ErrorClickToDialModuleNotConfigured'); if (!empty($user->clicktodial_url)) { $urlmask = $user->clicktodial_url; } @@ -3633,33 +3641,33 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli '__LOGIN__'=>$clicktodial_login, '__PASS__'=>$clicktodial_password); $url = make_substitutions($url, $substitarray); - $newphonesav = $newphone; if (empty($conf->global->CLICKTODIAL_DO_NOT_USE_AJAX_CALL)) { // Default and recommended: New method using ajax without submiting a page making a javascript history.go(-1) back - $newphone = ''; + $newphoneastart = ''; // Call of ajax is handled by the lib_foot.js.php on class 'cssforclicktodial' + $newphoneaend = ''; } else { // Old method - $newphone = 'global->CLICKTODIAL_FORCENEWTARGET)) { - $newphone .= ' target="_blank" rel="noopener noreferrer"'; + $newphoneastart .= ' target="_blank" rel="noopener noreferrer"'; } - $newphone .= '>'.$newphonesav.''; + $newphoneastart .= '>'; + $newphoneaend .= ''; } } //if (($cid || $socid) && isModEnabled('agenda') && $user->hasRight('agenda', 'myactions', 'create')) if (isModEnabled('agenda') && $user->hasRight("agenda", "myactions", "create")) { $type = 'AC_TEL'; - $link = ''; + $addlinktoagenda = ''; if ($addlink == 'AC_FAX') { $type = 'AC_FAX'; } if (!empty($conf->global->AGENDA_ADDACTIONFORPHONE)) { - $link = ''.img_object($langs->trans("AddAction"), "calendar").''; + $addlinktoagenda = ''.img_object($langs->trans("AddAction"), "calendar").''; } - if ($link) { - $newphone = '
'.$newphone.' '.$link.'
'; + if ($addlinktoagenda) { + $newphone = ''.$newphone.' '.$addlinktoagenda.''; } } } @@ -3692,7 +3700,14 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli } elseif (empty($adddivfloat)) { $rep .= ''; } - $rep .= ($withpicto ?img_picto($titlealt, 'object_'.$picto.'.png').' ' : '').$newphone; + + $rep .= $newphoneastart; + $rep .= ($withpicto ? img_picto($titlealt, 'object_'.$picto.'.png') : ''); + if ($separ != 'hidenum') { + $rep .= ($withpicto ? ' ' : '').$newphone; + } + $rep .= $newphoneaend; + if ($adddivfloat == 1) { $rep .= ''; } elseif (empty($adddivfloat)) { @@ -3712,7 +3727,7 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli */ function dol_print_ip($ip, $mode = 0) { - global $conf, $langs; + global $langs; $ret = ''; @@ -4116,6 +4131,48 @@ function dol_trunc($string, $size = 40, $trunc = 'right', $stringencoding = 'UTF } } +/** + * Return the picto for a data type + * + * @param string $key Key + * @return string Pïcto for the key + */ +function getPictoForType($key) +{ + // Set array with type -> picto + $type2picto = array( + 'varchar'=>'font', + 'text'=>'font', + 'html'=>'code', + 'int'=>'sort-numeric-down', + 'double'=>'sort-numeric-down', + 'price'=>'currency', + 'pricecy'=>'multicurrency', + 'password' => 'key', + 'boolean'=>'check-square', + 'date'=>'calendar', + 'datetime'=>'calendar', + 'phone'=> 'phone', + 'mail'=> 'email', + 'url'=> 'url', + 'ip'=> 'country', + 'select' => 'list', + 'sellist' => 'list', + 'radio' => 'check-circle', + 'checkbox' => 'check-square', + 'chkbxlst' => 'check-square', + 'link' => 'link', + 'separate'=> 'minus' + ); + + if (!empty($type2picto[$key])) { + return img_picto('', $type2picto[$key], 'class="pictofixedwidth"'); + } + + return img_picto('', 'generic', 'class="pictofixedwidth"'); +} + + /** * Show picto whatever it's its name (generic function) * @@ -4162,23 +4219,28 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $pictowithouttext = str_replace('object_', '', $pictowithouttext); $pictowithouttext = str_replace('_nocolor', '', $pictowithouttext); - if (strpos($pictowithouttext, 'fontawesome_') !== false || preg_match('/^fa-/', $pictowithouttext)) { - // This is a font awesome image 'fonwtawesome_xxx' or 'fa-xxx' + if (strpos($pictowithouttext, 'fontawesome_') === 0 || strpos($pictowithouttext, 'fa-') === 0) { + // This is a font awesome image 'fontawesome_xxx' or 'fa-xxx' $pictowithouttext = str_replace('fontawesome_', '', $pictowithouttext); $pictowithouttext = str_replace('fa-', '', $pictowithouttext); + // Compatibility with old fontawesome versions + if ($pictowithouttext == 'file-o') { + $pictowithouttext = 'file'; + } + $pictowithouttextarray = explode('_', $pictowithouttext); $marginleftonlyshort = 0; if (!empty($pictowithouttextarray[1])) { // Syntax is 'fontawesome_fakey_faprefix_facolor_fasize' or 'fa-fakey_faprefix_facolor_fasize' $fakey = 'fa-'.$pictowithouttextarray[0]; - $fa = empty($pictowithouttextarray[1]) ? 'fa' : $pictowithouttextarray[1]; + $faprefix = empty($pictowithouttextarray[1]) ? 'fas' : $pictowithouttextarray[1]; $facolor = empty($pictowithouttextarray[2]) ? '' : $pictowithouttextarray[2]; $fasize = empty($pictowithouttextarray[3]) ? '' : $pictowithouttextarray[3]; } else { $fakey = 'fa-'.$pictowithouttext; - $fa = 'fa'; + $faprefix = 'fas'; $facolor = ''; $fasize = ''; } @@ -4197,7 +4259,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ } $moreatt = trim($moreatt); - $enabledisablehtml = ''; /*if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $enabledisablehtml .= $titlealt; @@ -4212,30 +4274,30 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'accountancy', 'accounting_account', 'account', 'accountline', 'action', 'add', 'address', 'angle-double-down', 'angle-double-up', 'asset', 'bank_account', 'barcode', 'bank', 'bell', 'bill', 'billa', 'billr', 'billd', 'birthday-cake', 'bookmark', 'bom', 'briefcase-medical', 'bug', 'building', 'card', 'calendarlist', 'calendar', 'calendarmonth', 'calendarweek', 'calendarday', 'calendarperuser', 'calendarpertype', - 'cash-register', 'category', 'chart', 'check', 'clock', 'clone', 'close_title', 'cog', 'collab', 'company', 'contact', 'country', 'contract', 'conversation', 'cron', 'cross', 'cubes', - 'currency', 'multicurrency', + 'cash-register', 'category', 'chart', 'check', 'clock', 'clone', 'close_title', 'code', 'cog', 'collab', 'company', 'contact', 'country', 'contract', 'conversation', 'cron', 'cross', 'cubes', + 'check-circle', 'check-square', 'currency', 'multicurrency', + 'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top', 'commercial', 'companies', 'delete', 'dolly', 'dollyrevert', 'donation', 'download', 'dynamicprice', 'edit', 'ellipsis-h', 'email', 'entity', 'envelope', 'eraser', 'establishment', 'expensereport', 'external-link-alt', 'external-link-square-alt', 'eye', - 'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'autofill', 'folder', 'folder-open', 'folder-plus', + 'filter', 'file', 'file-o', 'file-code', 'file-export', 'file-import', 'file-upload', 'autofill', 'folder', 'folder-open', 'folder-plus', 'font', 'gears', 'generate', 'generic', 'globe', 'globe-americas', 'graph', 'grip', 'grip_title', 'group', 'hands-helping', 'help', 'holiday', 'id-card', 'images', 'incoterm', 'info', 'intervention', 'inventory', 'intracommreport', 'jobprofile', - 'knowledgemanagement', + 'key', 'knowledgemanagement', 'label', 'language', 'line', 'link', 'list', 'list-alt', 'listlight', 'loan', 'lock', 'lot', 'long-arrow-alt-right', - 'margin', 'map-marker-alt', 'member', 'meeting', 'money-bill-alt', 'movement', 'mrp', 'note', 'next', + 'margin', 'map-marker-alt', 'member', 'meeting', 'minus', 'money-bill-alt', 'movement', 'mrp', 'note', 'next', 'off', 'on', 'order', 'paiment', 'paragraph', 'play', 'pdf', 'phone', 'phoning', 'phoning_mobile', 'phoning_fax', 'playdisabled', 'previous', 'poll', 'pos', 'printer', 'product', 'propal', 'proposal', 'puce', 'stock', 'resize', 'service', 'stats', 'trip', 'security', 'setup', 'share-alt', 'sign-out', 'split', 'stripe', 'stripe-s', 'switch_off', 'switch_on', 'switch_on_warning', 'switch_on_red', 'tools', 'unlink', 'uparrow', 'user', 'user-tie', 'vcard', 'wrench', 'github', 'google', 'jabber', 'microsoft', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp', - 'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top', 'commercial', 'companies', 'generic', 'home', 'hrm', 'members', 'products', 'invoicing', 'partnership', 'payment', 'payment_vat', 'pencil-ruler', 'pictoconfirm', 'preview', 'project', 'projectpub', 'projecttask', 'question', 'refresh', 'region', 'salary', 'shipment', 'state', 'supplier_invoice', 'supplier_invoicea', 'supplier_invoicer', 'supplier_invoiced', 'technic', 'ticket', 'error', 'warning', 'recent', 'reception', 'recruitmentcandidature', 'recruitmentjobposition', 'replacement', 'resource', 'recurring','rss', - 'shapes', 'skill', 'square', 'stop-circle', 'supplier', 'supplier_proposal', 'supplier_order', 'supplier_invoice', + 'shapes', 'skill', 'square', 'sort-numeric-down', 'stop-circle', 'supplier', 'supplier_proposal', 'supplier_order', 'supplier_invoice', 'timespent', 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda', 'uncheck', 'url', 'user-cog', 'user-injured', 'user-md', 'vat', 'website', 'workstation', 'webhook', 'world', 'private', 'conferenceorbooth', 'eventorganization', @@ -4244,8 +4306,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $fakey = $pictowithouttext; $facolor = ''; $fasize = ''; - $fa = 'fas'; - if (in_array($pictowithouttext, array('card', 'bell', 'clock', 'establishment', 'generic', 'minus-square', 'object_generic', 'pdf', 'plus-square', 'timespent', 'note', 'off', 'on', 'object_bookmark', 'bookmark', 'vcard'))) { + $fa = getDolGlobalString('MAIN_FONTAWESOME_ICON_STYLE', 'fas'); + if (in_array($pictowithouttext, array('card', 'bell', 'clock', 'establishment', 'file', 'file-o', 'generic', 'minus-square', 'object_generic', 'pdf', 'plus-square', 'timespent', 'note', 'off', 'on', 'object_bookmark', 'bookmark', 'vcard'))) { $fa = 'far'; } if (in_array($pictowithouttext, array('black-tie', 'github', 'google', 'microsoft', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'stripe', 'stripe-s', 'youtube', 'google-plus-g', 'whatsapp'))) { @@ -4262,7 +4324,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'donation'=>'file-alt', 'dynamicprice'=>'hand-holding-usd', 'setup'=>'cog', 'companies'=>'building', 'products'=>'cube', 'commercial'=>'suitcase', 'invoicing'=>'coins', 'accounting'=>'search-dollar', 'category'=>'tag', 'dollyrevert'=>'dolly', - 'generate'=>'plus-square', 'hrm'=>'user-tie', 'incoterm'=>'truck-loading', + 'file-o'=>'file', 'generate'=>'plus-square', 'hrm'=>'user-tie', 'incoterm'=>'truck-loading', 'margin'=>'calculator', 'members'=>'user-friends', 'ticket'=>'ticket-alt', 'globe'=>'external-link-alt', 'lot'=>'barcode', 'email'=>'at', 'establishment'=>'building', 'edit'=>'pencil-alt', 'entity'=>'globe', 'graph'=>'chart-line', 'grip_title'=>'arrows-alt', 'grip'=>'arrows-alt', 'help'=>'question-circle', @@ -4275,10 +4337,10 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'switch_off'=>'toggle-off', 'switch_on'=>'toggle-on', 'switch_on_warning'=>'toggle-on', 'switch_on_red'=>'toggle-on', 'check'=>'check', 'bookmark'=>'star', 'bank'=>'university', 'close_title'=>'times', 'delete'=>'trash', 'filter'=>'filter', 'list-alt'=>'list-alt', 'calendarlist'=>'bars', 'calendar'=>'calendar-alt', 'calendarmonth'=>'calendar-alt', 'calendarweek'=>'calendar-week', 'calendarday'=>'calendar-day', 'calendarperuser'=>'table', - 'intervention'=>'ambulance', 'invoice'=>'file-invoice-dollar', 'currency'=>'dollar-sign', 'multicurrency'=>'dollar-sign', 'order'=>'file-invoice', + 'intervention'=>'ambulance', 'invoice'=>'file-invoice-dollar', 'order'=>'file-invoice', 'error'=>'exclamation-triangle', 'warning'=>'exclamation-triangle', 'other'=>'square', - 'playdisabled'=>'play', 'pdf'=>'file-pdf', 'poll'=>'check-double', 'pos'=>'cash-register', 'preview'=>'binoculars', 'project'=>'project-diagram', 'projectpub'=>'project-diagram', 'projecttask'=>'tasks', 'propal'=>'file-signature', 'proposal'=>'file-signature', + 'playdisabled'=>'play', 'pdf'=>'file-pdf', 'poll'=>'check-double', 'pos'=>'cash-register', 'preview'=>'binoculars', 'project'=>'project-diagram', 'projectpub'=>'project-diagram', 'projecttask'=>'tasks', 'propal'=>'file-signature', 'proposal'=>'file-signature', 'partnership'=>'handshake', 'payment'=>'money-check-alt', 'payment_vat'=>'money-check-alt', 'pictoconfirm'=>'check-square', 'phoning'=>'phone', 'phoning_mobile'=>'mobile-alt', 'phoning_fax'=>'fax', 'previous'=>'arrow-alt-circle-left', 'printer'=>'print', 'product'=>'cube', 'puce'=>'angle-right', 'recent' => 'check-square', 'reception'=>'dolly', 'recruitmentjobposition'=>'id-card-alt', 'recruitmentcandidature'=>'id-badge', 'resize'=>'crop', 'supplier_order'=>'dol-order_supplier', 'supplier_proposal'=>'file-signature', @@ -4293,6 +4355,13 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'website'=>'globe-americas', 'workstation'=>'pallet', 'webhook'=>'bullseye', 'world'=>'globe', 'private'=>'user-lock', 'conferenceorbooth'=>'chalkboard-teacher', 'eventorganization'=>'project-diagram' ); + if ($conf->currency == 'EUR') { + $arrayconvpictotofa['currency'] = 'euro-sign'; + $arrayconvpictotofa['multicurrency'] = 'dollar-sign'; + } else { + $arrayconvpictotofa['currency'] = 'dollar-sign'; + $arrayconvpictotofa['multicurrency'] = 'euro-sign'; + } if ($pictowithouttext == 'off') { $fakey = 'fa-square'; $fasize = '1.3em'; @@ -4363,7 +4432,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'propal'=>'infobox-propal', 'proposal'=>'infobox-propal','private'=>'infobox-project', 'reception'=>'flip', 'recruitmentjobposition'=>'infobox-adherent', 'recruitmentcandidature'=>'infobox-adherent', 'resource'=>'infobox-action', - 'salary'=>'infobox-bank_account', 'shipment'=>'infobox-commande', 'supplier_invoice'=>'infobox-order_supplier', 'supplier_invoicea'=>'infobox-order_supplier', 'supplier_invoiced'=>'infobox-order_supplier', + 'salary'=>'infobox-bank_account', 'shapes'=>'infobox-adherent', 'shipment'=>'infobox-commande', 'supplier_invoice'=>'infobox-order_supplier', 'supplier_invoicea'=>'infobox-order_supplier', 'supplier_invoiced'=>'infobox-order_supplier', 'supplier'=>'infobox-order_supplier', 'supplier_order'=>'infobox-order_supplier', 'supplier_proposal'=>'infobox-supplier_proposal', 'ticket'=>'infobox-contrat', 'title_accountancy'=>'infobox-bank_account', 'title_hrm'=>'infobox-holiday', 'expensereport'=>'infobox-expensereport', 'trip'=>'infobox-expensereport', 'title_agenda'=>'infobox-action', 'vat'=>'infobox-bank_account', @@ -5534,7 +5603,7 @@ function load_fiche_titre($titre, $morehtmlright = '', $picto = 'generic', $pict */ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '', $sortorder = '', $morehtmlcenter = '', $num = -1, $totalnboflines = '', $picto = 'generic', $pictoisfullpath = 0, $morehtmlright = '', $morecss = '', $limit = -1, $hideselectlimit = 0, $hidenavigation = 0, $pagenavastextinput = 0, $morehtmlrightbeforearrow = '') { - global $conf, $langs; + global $conf; $savlimit = $limit; $savtotalnboflines = $totalnboflines; @@ -6240,6 +6309,7 @@ function get_localtax($vatrate, $local, $thirdparty_buyer = "", $thirdparty_sell $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($thirdparty_seller->country_code)."'"; $sql .= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1"; + $sql .= " AND t.entity IN (".getEntity('c_tva').")"; if (!empty($vatratecode)) { $sql .= " AND t.code ='".$db->escape($vatratecode)."'"; // If we have the code, we use it in priority } else { @@ -6296,9 +6366,9 @@ function get_localtax_by_third($local) $sql = " SELECT t.localtax".$local." as localtax"; $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t INNER JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_pays"; - $sql .= " WHERE c.code = '".$db->escape($mysoc->country_code)."' AND t.active = 1 AND t.taux = ("; + $sql .= " WHERE c.code = '".$db->escape($mysoc->country_code)."' AND t.active = 1 AND t.entity IN (".getEntity('c_tva').") AND t.taux = ("; $sql .= "SELECT MAX(tt.taux) FROM ".MAIN_DB_PREFIX."c_tva as tt INNER JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = tt.fk_pays"; - $sql .= " WHERE c.code = '".$db->escape($mysoc->country_code)."' AND tt.active = 1)"; + $sql .= " WHERE c.code = '".$db->escape($mysoc->country_code)."' AND t.entity IN (".getEntity('c_tva').") AND tt.active = 1)"; $sql .= " AND t.localtax".$local."_type <> '0'"; $sql .= " ORDER BY t.rowid DESC"; @@ -6353,6 +6423,7 @@ function getTaxesFromId($vatrate, $buyer = null, $seller = null, $firstparamisid else $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($seller->country_code)."'";*/ $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($seller->country_code)."'"; $sql .= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1"; + $sql .= " AND t.entity IN (".getEntity('c_tva').")"; if ($vatratecode) { $sql .= " AND t.code = '".$db->escape($vatratecode)."'"; } @@ -6509,6 +6580,7 @@ function get_product_vat_for_country($idprod, $thirdpartytouse, $idprodfournpric $sql = "SELECT t.taux as vat_rate, t.code as default_vat_code"; $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; $sql .= " WHERE t.active = 1 AND t.fk_pays = c.rowid AND c.code = '".$db->escape($thirdpartytouse->country_code)."'"; + $sql .= " AND t.entity IN (".getEntity('c_tva').")"; $sql .= " ORDER BY t.use_default DESC, t.taux DESC, t.code ASC, t.recuperableonly ASC"; $sql .= $db->plimit(1); @@ -6588,6 +6660,7 @@ function get_product_localtax_for_country($idprod, $local, $thirdpartytouse) $sql = "SELECT taux as vat_rate, localtax1, localtax2"; $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; $sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$db->escape($thirdpartytouse->country_code)."'"; + $sql .= " AND t.entity IN (".getEntity('c_tva').")"; $sql .= " ORDER BY t.taux DESC, t.recuperableonly ASC"; $sql .= $db->plimit(1); @@ -7340,7 +7413,7 @@ function dolGetFirstLineOfText($text, $nboflines = 1, $charset = 'UTF-8') * @param int $nl2brmode 0=Adding br before \n, 1=Replacing \n by br * @param bool $forxml false=Use
, true=Use
* @return string String encoded - * @see dol_nboflines(), dolGetFirstLineOfText() + * @see dol_htmlentitiesbr(), dol_nboflines(), dolGetFirstLineOfText() */ function dol_nl2br($stringtoencode, $nl2brmode = 0, $forxml = false) { @@ -7463,15 +7536,15 @@ function dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox = 0, $check = ' * Because writeHTMLCell convert also \n into
, if function * is used to build PDF, nl2brmode must be 1. * Note: When we output string on pages, we should use - * - dol_htmlwithnojs(dol_string_onlythesehtmltags(dol_htmlentitiesbr(), 1, 1, 1)) for notes, - * - dol_escape_htmltag() for simple labels. + * - dol_escape_htmltag(dol_htmlwithnojs(dol_string_onlythesehtmltags(dol_htmlentitiesbr(), 1, 1, 1), 1, 1) for notes or descriptions, + * - dol_escape_htmltag(dol_htmlentitiesbr()) for simple labels. * * @param string $stringtoencode String to encode * @param int $nl2brmode 0=Adding br before \n, 1=Replacing \n by br (for use with FPDF writeHTMLCell function for example) * @param string $pagecodefrom Pagecode stringtoencode is encoded * @param int $removelasteolbr 1=Remove last br or lasts \n (default), 0=Do nothing * @return string String encoded - * @see dol_escape_htmltag(), dolGetFirstLineOfText() + * @see dol_escape_htmltag(), dolGetFirstLineOfText(), dol_string_onlythesehtmltags() */ function dol_htmlentitiesbr($stringtoencode, $nl2brmode = 0, $pagecodefrom = 'UTF-8', $removelasteolbr = 1) { @@ -7560,6 +7633,7 @@ function dol_html_entity_decode($a, $b, $c = 'UTF-8', $keepsomeentities = 0) * @param string $encoding Encoding page code * @param bool $double_encode When double_encode is turned off, PHP will not encode existing html entities * @return string $ret Encoded string + * @see dol_htmlentitiesbr() */ function dol_htmlentities($string, $flags = ENT_QUOTES|ENT_SUBSTITUTE, $encoding = 'UTF-8', $double_encode = false) { @@ -7923,6 +7997,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, if (isModEnabled("expedition") && (!is_object($object) || $object->element == 'shipping')) { $substitutionarray['__SHIPPINGTRACKNUM__'] = 'Shipping tracking number'; $substitutionarray['__SHIPPINGTRACKNUMURL__'] = 'Shipping tracking url'; + $substitutionarray['__SHIPPINGMETHOD__'] = 'Shipping method'; } if (isModEnabled("reception") && (!is_object($object) || $object->element == 'reception')) { $substitutionarray['__RECEPTIONTRACKNUM__'] = 'Shippin tracking number of shipment'; @@ -8068,6 +8143,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, if (is_object($object) && $object->element == 'shipping') { $substitutionarray['__SHIPPINGTRACKNUM__'] = $object->tracking_number; $substitutionarray['__SHIPPINGTRACKNUMURL__'] = $object->tracking_url; + $substitutionarray['__SHIPPINGMETHOD__'] = $object->shipping_method; } if (is_object($object) && $object->element == 'reception') { $substitutionarray['__RECEPTIONTRACKNUM__'] = $object->tracking_number; @@ -8981,6 +9057,7 @@ function dol_sort_array(&$array, $index, $order = 'asc', $natsort = 0, $case_sen * * @param string $str String to check * @return boolean True if string is UTF8 or ISO compatible with UTF8, False if not (ISO with special char or Binary) + * @see utf8_valid() */ function utf8_check($str) { @@ -9018,6 +9095,7 @@ function utf8_check($str) * * @param string $str String to check * @return boolean True if string is valid UTF8 string, false if corrupted + * @see utf8_check() */ function utf8_valid($str) { @@ -9136,6 +9214,33 @@ function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = } } +/** + * Check if a variable with name $var start with $text. + * Can be used to forge dol_eval() conditions. + * + * @param $var string Variable + * @param $regextext string Text that must be a valid regex string + * @param $matchrule int 1=Test if start with, 0=Test if equal + * @return boolean|string True or False, text if bad use. + */ +function isStringVarMatching($var, $regextext, $matchrule = 1) +{ + if ($matchrule == 1) { + if ($var == 'mainmenu') { + global $mainmenu; + return (preg_match('/^'.$regextext.'/', $mainmenu)); + } elseif ($var == 'leftmenu') { + global $leftmenu; + return (preg_match('/^'.$regextext.'/', $leftmenu)); + } else { + return 'This variable is not accessible with dol_eval'; + } + } else { + return 'This value for matchrule is not implemented'; + } +} + + /** * Verify if condition in string is ok or not * @@ -9144,15 +9249,15 @@ function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = */ function verifCond($strToEvaluate) { - global $user, $conf, $langs; + global $conf; // Read of const is done with getDolGlobalString() but we need $conf->currency for example + global $user, $langs; global $leftmenu; - global $rights; // To export to dol_eval function //print $strToEvaluate."
\n"; $rights = true; if (isset($strToEvaluate) && $strToEvaluate !== '') { //var_dump($strToEvaluate); - $rep = dol_eval($strToEvaluate, 1, 1, '1'); // The dol_eval must contains all the global $xxx for all variables $xxx found into the string condition + $rep = dol_eval($strToEvaluate, 1, 1, '1'); // The dol_eval() must contains all the "global $xxx;" for all variables $xxx found into the string condition $rights = $rep && (!is_string($rep) || strpos($rep, 'Bad string syntax to evaluate') === false); //var_dump($rights); } @@ -9166,29 +9271,36 @@ function verifCond($strToEvaluate) * @param string $s String to evaluate * @param int $returnvalue 0=No return (used to execute eval($a=something)). 1=Value of eval is returned (used to eval($something)). * @param int $hideerrors 1=Hide errors - * @param string $onlysimplestring '0' (used for computed property of extrafields)=Accept all chars, '1' (most common use)=Accept only simple string with char 'a-z0-9\s^$_+-.*>&|=!?():"\',/@';', '2' (rarely used)=Accept also '[]' + * @param string $onlysimplestring '0' (deprecated, used for computed property of extrafields)=Accept all chars, + * '1' (most common use)=Accept only simple string with char 'a-z0-9\s^$_+-.*>&|=!?():"\',/@';', + * '2' (rarely used)=Accept also '[]' * @return mixed Nothing or return result of eval + * @see verifCond() */ function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring = '1') { - // Only global variables can be changed by eval function and returned to caller - global $db, $langs, $user, $conf, $website, $websitepage; + // Only this global variables can be read by eval function and returned to caller + global $conf; // Read of const is done with getDolGlobalString() but we need $conf->currency for example + global $db, $langs, $user, $website, $websitepage; global $action, $mainmenu, $leftmenu; global $mysoc; - global $objectoffield; + global $objectoffield; // To allow the use of $objectoffield in computed fields // Old variables used - global $rights; global $object; - global $obj; // To get $obj used into list when dol_eval is used for computed fields and $obj is not yet $object - global $soc; // For backward compatibility + global $obj; // To get $obj used into list when dol_eval() is used for computed fields and $obj is not yet $object + //global $rights; + //global $soc; // For backward compatibility + + if (!in_array($onlysimplestring, array('0', '1', '2'))) { + return "Bad call of dol_eval. Parameter onlysimplestring must be '0' (deprecated), '1' or '2'"; + } try { // Test on dangerous char (used for RCE), we allow only characters to make PHP variable testing if ($onlysimplestring == '1') { - // We must accept: '1 && getDolGlobalInt("doesnotexist1") && $conf->global->MAIN_FEATURES_LEVEL' - // We must accept: '$conf->barcode->enabled || preg_match(\'/^AAA/\',$leftmenu)' - // We must accept: '$user->rights->cabinetmed->read && !$object->canvas=="patient@cabinetmed"' + // We must accept: '1 && getDolGlobalInt("doesnotexist1") && getDolGlobalString("MAIN_FEATURES_LEVEL")' + // We must accept: '$user->hasRight("cabinetmed", "read") && !$object->canvas=="patient@cabinetmed"' if (preg_match('/[^a-z0-9\s'.preg_quote('^$_+-.*>&|=!?():"\',/@', '/').']/i', $s)) { if ($returnvalue) { return 'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s; @@ -9196,10 +9308,24 @@ function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring = '1' dol_syslog('Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s); return ''; } - // TODO - // We can exclude all parenthesis ( that are not '($db' and 'getDolGlobalInt(' and 'getDolGlobalString(' and 'preg_match(' and 'isModEnabled(' - // ... } + $scheck = preg_replace('/->[a-zA-Z0-9_]+\(/', '->__METHOD__', $s); // accept parenthesis in '...->method(...' + $scheck = preg_replace('/^\(/', '__PARENTHESIS__', $scheck); // accept parenthesis in '(...' + $scheck = preg_replace('/\s\(/', '__PARENTHESIS__', $scheck); // accept parenthesis in '... (' + $scheck = preg_replace('/^[a-zA-Z0-9_]+\(/', '$1__FUNCTION__', $scheck); // accept parenthesis in 'function(' + $scheck = preg_replace('/\s[a-zA-Z0-9_]+\(/', '$1__FUNCTION__', $scheck); // accept parenthesis in '... function(' + $scheck = preg_replace('/(\^|\')\(/', '__REGEXSTART__', $scheck); // To allow preg_match('/^(aaa|bbb)/'... or isStringVarMatching('leftmenu', '(aaa|bbb)') + //print 'scheck='.$scheck." : ".strpos($scheck, '(')."\n"; + if (strpos($scheck, '(') !== false) { + if ($returnvalue) { + return 'Bad string syntax to evaluate (found call of a function or method without using direct name): '.$s; + } else { + dol_syslog('Bad string syntax to evaluate (found call of a function or method without using direct name): '.$s); + return ''; + } + } + // TODO + // We can exclude $ char that are not: $db, $langs, $leftmenu, $topmenu, $user, $langs, $objectoffield, $object..., } elseif ($onlysimplestring == '2') { // We must accept: (($reloadedobj = new Task($db)) && ($reloadedobj->fetchNoCompute($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetchNoCompute($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref : "Parent project not found" if (preg_match('/[^a-z0-9\s'.preg_quote('^$_+-.*>&|=!?():"\',/@[]', '/').']/i', $s)) { @@ -9209,10 +9335,24 @@ function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring = '1' dol_syslog('Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s); return ''; } - // TODO - // We can exclude all parenthesis ( that are not '($db' and 'getDolGlobalInt(' and 'getDolGlobalString(' and 'preg_match(' and 'isModEnabled(' - // ... } + $scheck = preg_replace('/->[a-zA-Z0-9_]+\(/', '->__METHOD__', $s); // accept parenthesis in '...->method(...' + $scheck = preg_replace('/^\(/', '__PARENTHESIS__', $scheck); // accept parenthesis in '(...' + $scheck = preg_replace('/\s\(/', '__PARENTHESIS__', $scheck); // accept parenthesis in '... (' + $scheck = preg_replace('/^[a-zA-Z0-9_]+\(/', '$1__FUNCTION__', $scheck); // accept parenthesis in 'function(' + $scheck = preg_replace('/\s[a-zA-Z0-9_]+\(/', '$1__FUNCTION__', $scheck); // accept parenthesis in '... function(' + $scheck = preg_replace('/(\^|\')\(/', '__REGEXSTART__', $scheck); // To allow preg_match('/^(aaa|bbb)/'... or isStringVarMatching('leftmenu', '(aaa|bbb)') + //print 'scheck='.$scheck." : ".strpos($scheck, '(')."\n"; + if (strpos($scheck, '(') !== false) { + if ($returnvalue) { + return 'Bad string syntax to evaluate (found call of a function or method without using direct name): '.$s; + } else { + dol_syslog('Bad string syntax to evaluate (found call of a function or method without using direct name): '.$s); + return ''; + } + } + // TODO + // We can exclude $ char that are not: $db, $leftmenu, $topmenu, $user, $langs, $object..., } if (is_array($s) || $s === 'Array') { return 'Bad string syntax to evaluate (value is Array) '.var_export($s, true); @@ -9290,7 +9430,7 @@ function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring = '1' } catch (Error $e) { $error = 'dol_eval try/catch error : '; $error .= $e->getMessage(); - dol_syslog($error); + dol_syslog($error, LOG_WARNING); } } @@ -9299,6 +9439,7 @@ function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring = '1' * * @param string $element Variable to check * @return boolean Return true of variable is not empty + * @see getElementProperties() */ function dol_validElement($element) { @@ -9727,7 +9868,7 @@ function complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, // No need to make a return $head. Var is modified as a reference if (!empty($hookmanager)) { $parameters = array('object' => $object, 'mode' => $mode, 'head' => &$head, 'filterorigmodule' => $filterorigmodule); - $reshook = $hookmanager->executeHooks('completeTabsHead', $parameters); + $reshook = $hookmanager->executeHooks('completeTabsHead', $parameters, $object); if ($reshook > 0) { // Hook ask to replace completely the array $head = $hookmanager->resArray; } else { // Hook @@ -9863,6 +10004,11 @@ function printCommonFooter($zone = 'private') // Add 'field required' class on closest td for all input elements : input, textarea and select print 'jQuery(":input[name=\'' . $paramkey . '\']").closest("tr").find("td:first").addClass("fieldrequired");' . "\n"; } + // If we submit the cancel button we remove the required attributes + print 'jQuery("input[name=\'cancel\']").click(function() { + console.log("We click on cancel button so removed all required attribute"); + jQuery("input, textarea, select").each(function(){this.removeAttribute(\'required\');}); + });'."\n"; } } } @@ -10794,7 +10940,7 @@ function getDictionaryValue($tablename, $field, $id, $checkentity = false, $rowi $resql = $db->query($sql); if ($resql) { while ($obj = $db->fetch_object($resql)) { - $dictvalues[$obj->{$rowidfield}] = $obj; // $obj is stdClass + $dictvalues[$obj->$rowidfield] = $obj; // $obj is stdClass } } else { dol_print_error($db); @@ -11062,10 +11208,10 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st /** * Function dolGetButtonAction * - * @param string $label Label or tooltip of button. Also used as tooltip in title attribute. Can be escaped HTML content or full simple text. + * @param string $label Label or tooltip of button if $tet is provided. Also used as tooltip in title attribute. Can be escaped HTML content or full simple text. * @param string $text Optional : short label on button. Can be escaped HTML content or full simple text. - * @param string $actionType 'default', 'delete', 'danger', 'email', ... - * @param string|array $url Url for link or array of subbutton description + * @param string $actionType 'default', 'danger', 'email', 'clone', 'cancel', 'delete', ... + * @param string|array $url Url for link or array of subbutton description ('label'=>, 'url'=>, 'lang'=>, 'perm'=> ) * Example when an array is used: $arrayforbutaction = array( * 10 => array('lang'=>'propal', 'enabled'=>isModEnabled("propal"), 'perm'=>$user->hasRight('propal', 'creer'), 'label' => 'AddProp', 'url'=>'/comm/propal/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid), * 20 => array('lang'=>'orders', 'enabled'=>isModEnabled("commande"), 'perm'=>$user->hasRight('commande', 'creer'), 'label' => 'CreateOrder', 'url'=>'/commande/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid), @@ -11099,31 +11245,43 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url = // If $url is an array, we must build a dropdown button if (is_array($url)) { - $out = '"; return $out; } - // If $url is a simple link + // Here, $url is a simple link + if (!empty($params['isDropdown'])) $class = "dropdown-item"; else { $class = 'butAction'; if ($actionType == 'danger' || $actionType == 'delete') { $class = 'butActionDelete'; - if (!empty($url) && strpos($url, 'token=') === false) $url .= '&token='.newToken(); + if (!empty($url) && strpos($url, 'token=') === false) { + $url .= '&token='.newToken(); + } } } $attr = array( @@ -11392,6 +11550,7 @@ function getElementProperties($element_type) $module = $element_type; $element = $element_type; $subelement = $element_type; + $table_element = $element_type; // If we ask a resource form external module (instead of default path) if (preg_match('/^([^@]+)@([^@]+)$/i', $element_type, $regs)) { // 'myobject@mymodule' @@ -11411,15 +11570,18 @@ function getElementProperties($element_type) $classpath = 'comm/action/class'; $subelement = 'Actioncomm'; $module = 'agenda'; + $table_element = 'actioncomm'; } elseif ($element_type == 'cronjob') { $classpath = 'cron/class'; $module = 'cron'; + $table_element = 'cron'; } elseif ($element_type == 'adherent_type') { $classpath = 'adherents/class'; $classfile = 'adherent_type'; $module = 'adherent'; $subelement = 'adherent_type'; $classname = 'AdherentType'; + $table_element = 'adherent_type'; } elseif ($element_type == 'bank_account') { $classpath = 'compta/bank/class'; $module = 'bank'; // We need $conf->bank->dir_output and not $conf->banque->dir_output @@ -11429,37 +11591,46 @@ function getElementProperties($element_type) $classpath = 'categories/class'; $module = 'categorie'; $subelement = 'categorie'; + $table_element = 'categorie'; } elseif ($element_type == 'contact') { $classpath = 'contact/class'; $classfile = 'contact'; $module = 'societe'; $subelement = 'contact'; + $table_element = 'socpeople'; } elseif ($element_type == 'stock') { $classpath = 'product/stock/class'; $classfile = 'entrepot'; $classname = 'Entrepot'; + $table_element = 'entrepot'; } elseif ($element_type == 'project') { $classpath = 'projet/class'; $module = 'projet'; + $table_element = 'projet'; } elseif ($element_type == 'project_task') { $classpath = 'projet/class'; $module = 'projet'; $subelement = 'task'; + $table_element = 'projet_task'; } elseif ($element_type == 'facture' || $element_type == 'invoice') { $classpath = 'compta/facture/class'; $module = 'facture'; $subelement = 'facture'; + $table_element = 'facture'; } elseif ($element_type == 'commande' || $element_type == 'order') { $classpath = 'commande/class'; $module = 'commande'; $subelement = 'commande'; + $table_element = 'commande'; } elseif ($element_type == 'propal') { $classpath = 'comm/propal/class'; + $table_element = 'propal'; } elseif ($element_type == 'shipping') { $classpath = 'expedition/class'; $classfile = 'expedition'; $classname = 'Expedition'; $module = 'expedition'; + $table_element = 'expedition'; } elseif ($element_type == 'supplier_proposal') { $classpath = 'supplier_proposal/class'; $module = 'supplier_proposal'; @@ -11478,6 +11649,7 @@ function getElementProperties($element_type) $classpath = 'contrat/class'; $module = 'contrat'; $subelement = 'contrat'; + $table_element = 'contract'; } elseif ($element_type == 'mailing') { $classpath = 'comm/mailing/class'; $module = 'mailing'; @@ -11488,6 +11660,7 @@ function getElementProperties($element_type) $classpath = 'adherents/class'; $module = 'adherent'; $subelement = 'adherent'; + $table_element = 'adherent'; } elseif ($element_type == 'usergroup') { $classpath = 'user/class'; $module = 'user'; @@ -11497,18 +11670,22 @@ function getElementProperties($element_type) $classname = 'Mo'; $module = 'mrp'; $subelement = ''; + $table_element = 'mrp_mo'; } elseif ($element_type == 'cabinetmed_cons') { $classpath = 'cabinetmed/class'; $module = 'cabinetmed'; $subelement = 'cabinetmedcons'; + $table_element = 'cabinetmedcons'; } elseif ($element_type == 'fichinter') { $classpath = 'fichinter/class'; $module = 'ficheinter'; $subelement = 'fichinter'; + $table_element = 'fichinter'; } elseif ($element_type == 'dolresource' || $element_type == 'resource') { $classpath = 'resource/class'; $module = 'resource'; $subelement = 'dolresource'; + $table_element = 'resource'; } elseif ($element_type == 'propaldet') { $classpath = 'comm/propal/class'; $module = 'propal'; @@ -11524,6 +11701,7 @@ function getElementProperties($element_type) $element = 'order_supplier'; $subelement = ''; $classname = 'CommandeFournisseur'; + $table_element = 'commande_fournisseur'; } elseif ($element_type == 'invoice_supplier') { $classpath = 'fourn/class'; $module = 'fournisseur'; @@ -11531,9 +11709,11 @@ function getElementProperties($element_type) $element = 'invoice_supplier'; $subelement = ''; $classname = 'FactureFournisseur'; + $table_element = 'facture_fourn'; } elseif ($element_type == "service") { $classpath = 'product/class'; $subelement = 'product'; + $table_element = 'product'; } elseif ($element_type == 'salary') { $classpath = 'salaries/class'; $module = 'salaries'; @@ -11544,12 +11724,14 @@ function getElementProperties($element_type) $classname = 'Productlot'; $element = 'productlot'; $subelement = ''; + $table_element = 'product_lot'; } elseif ($element_type == 'websitepage') { $classpath = 'website/class'; $classfile = 'websitepage'; $classname = 'Websitepage'; $module = 'website'; $subelement = 'websitepage'; + $table_element = 'website_page'; } elseif ($element_type == 'fiscalyear') { $classpath = 'core/class'; $module = 'accounting'; @@ -11557,10 +11739,12 @@ function getElementProperties($element_type) } elseif ($element_type == 'chargesociales') { $classpath = 'compta/sociales/class'; $module = 'tax'; + $table_element = 'chargesociales'; } elseif ($element_type == 'tva') { $classpath = 'compta/tva/class'; $module = 'tax'; $subdir = '/vat'; + $table_element = 'tva'; } if (empty($classfile)) { @@ -11597,6 +11781,7 @@ function getElementProperties($element_type) $element_properties = array( 'module' => $module, 'element' => $element, + 'table_element' => $table_element, 'subelement' => $subelement, 'classpath' => $classpath, 'classfile' => $classfile, @@ -11614,6 +11799,7 @@ function getElementProperties($element_type) * @param string $element_type Element type ('module' or 'myobject@mymodule' or 'mymodule_myobject') * @param string $element_ref Element ref (Use this or element_id but not both) * @return int|object object || 0 || <0 if error + * @see getElementProperties() */ function fetchObjectByElement($element_id, $element_type, $element_ref = '') { @@ -12099,14 +12285,16 @@ function dolForgeCriteriaCallback($matches) /** * Get timeline icon * - * @param ActionComm $actionstatic actioncomm - * @param array $histo histo - * @param int $key key - * @return string + * @param ActionComm $actionstatic actioncomm + * @param array $histo histo + * @param int $key key + * @return string String with timeline icon + * @deprecated Use actioncomm->getPictoType() instead */ function getTimelineIcon($actionstatic, &$histo, $key) { global $conf, $langs; + $out = ''."\n"; $iconClass = 'fa fa-comments'; $img_picto = ''; @@ -12594,10 +12782,9 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n $out .= getTitleFieldOfList($tmp); } - - //require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; - //$caction=new CActionComm($db); - //$arraylist=$caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:0), '', 1); + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; + $caction = new CActionComm($db); + $arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1); $actualCycleDate = false; @@ -12608,6 +12795,21 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n $actionstatic->type_picto = $histo[$key]['apicto']; $actionstatic->type_code = $histo[$key]['acode']; + $labeltype = $actionstatic->type_code; + if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) { + $labeltype = 'AC_OTH'; + } + if (!empty($actionstatic->code) && preg_match('/^TICKET_MSG/', $actionstatic->code)) { + $labeltype = $langs->trans("Message"); + } else { + if (!empty($arraylist[$labeltype])) { + $labeltype = $arraylist[$labeltype]; + } + if ($actionstatic->type_code == 'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) { + $labeltype .= ' - '.$arraylist[$actionstatic->code]; // Use code in priority on type_code + } + } + $url = DOL_URL_ROOT.'/comm/action/card.php?id='.$histo[$key]['id']; $tmpa = dol_getdate($histo[$key]['datestart'], false); @@ -12626,7 +12828,11 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n $out .= ''."\n"; $out .= '
  • '; - $out .= getTimelineIcon($actionstatic, $histo, $key); + //$timelineicon = getTimelineIcon($actionstatic, $histo, $key); + $typeicon = $actionstatic->getTypePicto('pictofixedwidth timeline-icon-not-applicble', $labeltype); + //$out .= $timelineicon; + //var_dump($timelineicon); + $out .= $typeicon; $out .= '
    '."\n"; @@ -12646,6 +12852,7 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n } $out .= ''; + // Date $out .= ' '; $out .= dol_print_date($histo[$key]['datestart'], 'dayhour', 'tzuserrel'); @@ -12700,9 +12907,13 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n $out .= '
    '; // Title - $libelle = ''; $out .= '
    '; + //$out .= $actionstatic->getTypePicto(); + if (empty($conf->dol_optimize_smallscreen) && $actionstatic->type_code != 'AC_OTH_AUTO') { + $out .= $labeltype.' - '; + } + $libelle = ''; if (preg_match('/^TICKET_MSG/', $actionstatic->code)) { $out .= $langs->trans('TicketNewMessage'); } elseif (preg_match('/^TICKET_MSG_PRIVATE/', $actionstatic->code)) { @@ -12725,16 +12936,32 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n } } + if (isset($histo[$key]['elementtype']) && !empty($histo[$key]['fk_element'])) { + if (isset($conf->cache['elementlinkcache'][$histo[$key]['elementtype']]) && isset($conf->cache['elementlinkcache'][$histo[$key]['elementtype']][$histo[$key]['fk_element']])) { + $link = $conf->cache['elementlinkcache'][$histo[$key]['elementtype']][$histo[$key]['fk_element']]; + } else { + if (!isset($conf->cache['elementlinkcache'][$histo[$key]['elementtype']])) { + $conf->cache['elementlinkcache'][$histo[$key]['elementtype']] = array(); + } + $link = dolGetElementUrl($histo[$key]['fk_element'], $histo[$key]['elementtype'], 1); + $conf->cache['elementlinkcache'][$histo[$key]['elementtype']][$histo[$key]['fk_element']] = $link; + } + if ($link) { + $out .= ' - '.$link; + } + } + $out .= '
    '; $out .= ''; + // Message if (!empty($histo[$key]['message'] && $histo[$key]['message'] != $libelle) && $actionstatic->code != 'AC_TICKET_CREATE' && $actionstatic->code != 'AC_TICKET_MODIFY' ) { - $out .= '
    '; - $out .= $histo[$key]['message']; + $out .= '
    '; + $out .= dolGetFirstLineOfText($histo[$key]['message'], 3); $out .= '
    '; } @@ -12745,14 +12972,15 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n if (isset($histo[$key]['socpeopleassigned']) && is_array($histo[$key]['socpeopleassigned']) && count($histo[$key]['socpeopleassigned']) > 0) { $contactList = ''; foreach ($histo[$key]['socpeopleassigned'] as $cid => $Tab) { - $contact = new Contact($db); - $result = $contact->fetch($cid); - - if ($result < 0) { - dol_print_error($db, $contact->error); + if (empty($conf->cache['contact'][$histo[$key]['contact_id']])) { + $contact = new Contact($db); + $contact->fetch($cid); + $conf->cache['contact'][$histo[$key]['contact_id']] = $contact; + } else { + $contact = $conf->cache['contact'][$histo[$key]['contact_id']]; } - if ($result > 0) { + if ($contact) { $contactList .= !empty($contactList) ? ', ' : ''; $contactList .= $contact->getNomUrl(1); if (isset($histo[$key]['acode']) && $histo[$key]['acode'] == 'AC_TEL') { @@ -12765,11 +12993,12 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n $footer .= $langs->trans('ActionOnContact').' : '.$contactList; } elseif (empty($objcon->id) && isset($histo[$key]['contact_id']) && $histo[$key]['contact_id'] > 0) { - $contact = new Contact($db); - $result = $contact->fetch($histo[$key]['contact_id']); - - if ($result < 0) { - dol_print_error($db, $contact->error); + if (empty($conf->cache['contact'][$histo[$key]['contact_id']])) { + $contact = new Contact($db); + $result = $contact->fetch($histo[$key]['contact_id']); + $conf->cache['contact'][$histo[$key]['contact_id']] = $contact; + } else { + $contact = $conf->cache['contact'][$histo[$key]['contact_id']]; } if ($result > 0) { diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 67b9f7e15b2..6acb7bdfdae 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -621,7 +621,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', } // Before PHP8, img was a resource, With PHP8, it is a GdImage - if (!is_resource($img) && !($img instanceof GdImage)) { + if (!is_resource($img) && class_exists('GdImage') && !($img instanceof GdImage)) { dol_syslog('Failed to detect type of image. We found infoImg[2]='.$infoImg[2], LOG_WARNING); return 0; } diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index c9cd52bce73..b2935e867bf 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -250,7 +250,7 @@ function invoice_admin_prepare_head() */ function invoice_rec_prepare_head($object) { - global $db, $langs, $conf; + global $db, $langs, $conf, $user; $h = 0; $head = array(); @@ -260,6 +260,40 @@ function invoice_rec_prepare_head($object) $head[$h][2] = 'card'; $h++; + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/agenda-rec.php?id='.$object->id; + $head[$h][1] = $langs->trans("Events"); + if (isModEnabled('agenda')&& ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { + $nbEvent = 0; + // Enable caching of thirdparty count actioncomm + require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; + $cachekey = 'count_events_facturerec_'.$object->id; + $dataretrieved = dol_getcache($cachekey); + if (!is_null($dataretrieved)) { + $nbEvent = $dataretrieved; + } else { + $sql = "SELECT COUNT(id) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm"; + $sql .= " WHERE fk_element = ".((int) $object->id); + $sql .= " AND elementtype = 'invoicerec'"; + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + $nbEvent = $obj->nb; + } else { + dol_syslog('Failed to count actioncomm '.$db->lasterror(), LOG_ERR); + } + dol_setcache($cachekey, $nbEvent, 120); // If setting cache fails, this is not a problem, so we do not test result. + } + + $head[$h][1] .= '/'; + $head[$h][1] .= $langs->trans("Agenda"); + if ($nbEvent > 0) { + $head[$h][1] .= ''.$nbEvent.''; + } + } + $head[$h][2] = 'agenda'; + $h++; + // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab @@ -313,6 +347,7 @@ function getNumberInvoicesPieChart($mode) if (($mode == 'customers' && isModEnabled('facture') && $user->hasRight('facture', 'lire')) || ($mode == 'suppliers' && (isModEnabled('fournisseur') || isModEnabled('supplier_invoice')) && $user->hasRight('fournisseur', 'facture', 'lire')) ) { + global $badgeStatus1, $badgeStatus3, $badgeStatus4, $badgeStatus8, $badgeStatus11; include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; $now = date_create(date('Y-m-d', dol_now())); diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index de26ad0462d..0742ad15368 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -448,7 +448,34 @@ function dolGetListOfObjectClasses($destdir) return -1; } +/** + * function for check if comment begin an end exist in modMyModule class + * @param string $file filename or path + * @param int $number 0 = For Menus,1 = For permissions, 2 = For Dictionaries + * @return int 1 if OK , -1 if KO + */ +function checkExistComment($file, $number) +{ + if (!file_exists($file)) { + return -1; + } + $content = file_get_contents($file); + if ($number === 0) { + if (strpos($content, '/* BEGIN MODULEBUILDER LEFTMENU MYOBJECT */') !== false && strpos($content, '/* END MODULEBUILDER LEFTMENU MYOBJECT */') !== false) { + return 1; + } + } elseif ($number === 1) { + if (strpos($content, '/* BEGIN MODULEBUILDER PERMISSIONS */') !== false && strpos($content, '/* END MODULEBUILDER PERMISSIONS */') !== false) { + return 1; + } + } elseif ($number == 2) { + if (strpos($content, '/* BEGIN MODULEBUILDER DICTIONARIES */') !== false && strpos($content, '/* END MODULEBUILDER DICTIONARIES */') !== false) { + return 1; + } + } + return -1; +} /** * Delete all permissions * @@ -615,6 +642,52 @@ function reWriteAllPermissions($file, $permissions, $key, $right, $objectname, $ } } +/** + * Converts a formatted properties string into an associative array. + * + * @param string $string The formatted properties string. + * @return array The resulting associative array. + */ +function parsePropertyString($string) +{ + + $string = str_replace("'", '', $string); + + // Uses a regular expression to capture keys and values + preg_match_all('/\s*([^\s=>]+)\s*=>\s*([^,]+),?/', $string, $matches, PREG_SET_ORDER); + $propertyArray = []; + + foreach ($matches as $match) { + $key = trim($match[1]); + $value = trim($match[2]); + + if (strpos($value, 'array(') === 0) { + $nestedArray = substr($value, 6); + $nestedArray = parsePropertyString($nestedArray); + $value = $nestedArray; + } elseif (strpos($value, '"Id")') !== false) { + $value = str_replace(')', '', $value); + } else { + if (is_numeric($value)) { + if (strpos($value, '.') !== false) { + $value = (float) $value; + } else { + $value = (int) $value; + } + } else { + if ($value === 'true') { + $value = true; + } elseif ($value === 'false') { + $value = false; + } + } + } + $propertyArray[$key] = $value; + } + + return $propertyArray; +} + /** * Write all properties of the object in AsciiDoc format * @param string $file path of the class @@ -626,7 +699,7 @@ function writePropsInAsciiDoc($file, $objectname, $destfile) { // stock all properties in array - $attributesUnique = array ('label', 'type', 'arrayofkeyval', 'notnull', 'default', 'index', 'foreignkey', 'position', 'enabled', 'visible', 'noteditable', 'alwayseditable', 'searchall', 'isameasure', 'css','cssview','csslist', 'help', 'showoncombobox', 'validate','comment','picto' ); + $attributesUnique = array ('type','label', 'enabled', 'position', 'notnull', 'visible', 'noteditable', 'index', 'default' , 'foreignkey', 'arrayofkeyval', 'alwayseditable','validate', 'searchall','comment', 'isameasure', 'css', 'cssview','csslist', 'help', 'showoncombobox','picto' ); $start = "public \$fields=array("; $end = ");"; @@ -657,32 +730,53 @@ function writePropsInAsciiDoc($file, $objectname, $destfile) $table .= "|".$attUnique; } $table .="\n"; + $valuesModif = array(); foreach ($keys as $string) { $string = trim($string, "'"); $string = rtrim($string, ","); - $array = eval("return [$string];"); - // check if is array after cleaning string + $array = parsePropertyString($string); + + // Iterate through the array to merge all key to one array + $code = ''; + foreach ($array as $key => $value) { + if (is_array($value)) { + $code = $key; + continue; + } else { + $array[$code][$key] = $value; + unset($array[$key]); + } + } + // check if is array after parsing the string if (!is_array($array)) { return -1; } - $field = array_keys($array); + if ($field[0] === '') { + $field[0] = 'label'; + } $values = array_values($array)[0]; // check each field has all properties and add it if missed foreach ($attributesUnique as $attUnique) { + if ($attUnique == 'type' && $field[0] === 'label') { + $values[$attUnique] = 'varchar(255)'; + } if (!array_key_exists($attUnique, $values)) { - $values[$attUnique] = ''; + $valuesModif[$attUnique] = ''; + } else { + $valuesModif[$attUnique] = $values[$attUnique]; } } - $table .= "|*" . $field[0] . "*|"; - $table .= implode("|", $values) . "\n"; + $table .= implode("|", $valuesModif) . "\n"; } + // end table $table .= "|===\n"; $table .= "__ end table for object $objectname\n"; + //write in file $writeInFile = dolReplaceInFile($destfile, array('== DATA SPECIFICATIONS' => $table)); if ($writeInFile<0) { @@ -691,13 +785,14 @@ function writePropsInAsciiDoc($file, $objectname, $destfile) return 1; } + /** - * Delete property from documentation if we delete object + * Delete property and permissions from documentation if we delete object * @param string $file file or path * @param string $objectname name of object wants to deleted * @return void */ -function deletePropsFromDoc($file, $objectname) +function deletePropsAndPermsFromDoc($file, $objectname) { $start = "== Table of fields and their properties for object *".ucfirst($objectname)."* : "; @@ -706,8 +801,16 @@ function deletePropsFromDoc($file, $objectname) $search = '/' . preg_quote($start, '/') . '(.*?)' . preg_quote($end, '/') . '/s'; $new_contents = preg_replace($search, '', $str); file_put_contents($file, $new_contents); + + //perms If Exist + $perms = "|*".strtolower($objectname)."*|"; + $search_pattern_perms = '/' . preg_quote($perms, '/') . '.*?\n/'; + $new_contents = preg_replace($search_pattern_perms, '', $new_contents); + file_put_contents($file, $new_contents); } + + /** * Search a string and return all lines needed from file * @param string $file file for searching @@ -949,7 +1052,7 @@ function reWriteAllMenus($file, $menus, $menuWantTo, $key, $action) array_push($menus, $menuWantTo); } elseif ($action == 2 && !empty($key) && !empty($menuWantTo)) { // update right from permissions array - + $urlCounter=0; // check if the values already exists foreach ($menus as $index => $menu) { if ($index !== $key) { @@ -958,12 +1061,12 @@ function reWriteAllMenus($file, $menus, $menuWantTo, $key, $action) $counter++; } if (strcasecmp(str_replace(' ', '', $menu['url']), str_replace(' ', '', $menuWantTo['url'])) === 0) { - $counter++; + $urlCounter++; } } } } - if (!$counter) { + if (!$counter && $urlCounter < 2) { $menus[$key] = $menuWantTo; } else { $errors++; @@ -1020,3 +1123,226 @@ function reWriteAllMenus($file, $menus, $menuWantTo, $key, $action) return 1; }return -1; } + +/** + * Updates a dictionary in a module descriptor file. + * + * @param string $module The name of the module. + * @param string $file The path to the module descriptor file. + * @param array $dicts The dictionary data to be updated. + * @return int Returns the number of replacements made in the file. + */ +function updateDictionaryInFile($module, $file, $dicts) +{ + + $isEmpty = false; + $dicData = "\t\t\$this->dictionaries=array(\n"; + $module = strtolower($module); + foreach ($dicts as $key => $value) { + if (empty($value)) { + $isEmpty = true; + $dicData = "\t\t\$this->dictionaries=array();"; + break; + } + + $dicData .= "\t\t\t'$key'=>"; + + if ($key === 'tabcond') { + $conditions = array_map(function ($val) use ($module) { + return ($val === true || $val === false) ? "isModEnabled('$module')" : $val; + }, $value); + $dicData .= "array(" . implode(",", $conditions) . ")"; + } elseif ($key === 'tabhelp') { + $helpItems = array(); + foreach ($value as $key => $helpValue) { + $helpItems[] = "array('code'=>\$langs->trans('".$helpValue['code']."'), 'field2' => 'field2tooltip')"; + } + $dicData .= "array(" . implode(",", $helpItems) . ")"; + } else { + if (is_array($value)) { + $dicData .= "array(" . implode(",", array_map(function ($val) { + return "'$val'"; + }, $value)) . ")"; + } else { + $dicData .= "'$value'"; + } + } + $dicData .= ",\n"; + } + $dicData .= (!$isEmpty ? "\t\t);" : ''); + + $stringDic = getFromFile($file, '/* BEGIN MODULEBUILDER DICTIONARIES */', '/* END MODULEBUILDER DICTIONARIES */'); + $writeInfile = dolReplaceInFile($file, array($stringDic => $dicData."\n")); + + return $writeInfile; +} + +/** + * Creates a new dictionary table. + * + * for creating a new dictionary table in Dolibarr. It generates the necessary SQL code to define the table structure, + * including columns such as 'rowid', 'code', 'label', 'position', 'use_default', 'active', etc. The table name is constructed based on the provided $namedic parameter. + * + * @param string $modulename The lowercase name of the module for which the dictionary table is being created. + * @param string $file The file path to the Dolibarr module builder file where the dictionaries are defined. + * @param string $namedic The name of the dictionary, which will also be used as the base for the table name. + * @param array|null $dictionnaires An optional array containing pre-existing dictionary data, including 'tabname', 'tablib', 'tabsql', etc. + * @return void + */ +function createNewDictionnary($modulename, $file, $namedic, $dictionnaires = null) +{ + global $db, $langs; + + if (empty($namedic)) { + setEventMessages($langs->trans("ErrorEmptyNameDic"), null, 'errors'); + return; + } + if (!file_exists($file)) { + return -1; + } + $modulename = strtolower($modulename); + + if (empty($dictionnaires)) { + $dictionnaires = array('langs' => '', 'tabname' => array(), 'tablib' => array(), 'tabsql' => array(), 'tabsqlsort' => array(), 'tabfield' => array(), 'tabfieldvalue' => array(), 'tabfieldinsert' => array(), 'tabrowid' => array(), 'tabcond' => array(), 'tabhelp' => array()); + } + + $columns = array( + 'rowid' => array('type' => 'integer(11)'), + 'code' => array('type' => 'varchar(255) NOT NULL'), + 'label' => array('type' => 'varchar(255) NOT NULL'), + 'position' => array('type' => 'integer(11) NULL'), + 'use_default' => array('type' => 'varchar(255) DEFAULT 1'), + 'active' => array('type' => 'integer') + ); + + + $primaryKey = 'rowid'; + foreach ($columns as $key => $value) { + if ($key === 'rowid') { + $primaryKey = 'rowid'; + break; + } + if (!array_key_exists('rowid', $columns)) { + $primaryKey = array_key_first($columns); + break; + } + } + // check if tablename exist in Database and create it if not + $query = "SHOW TABLES LIKE '" . MAIN_DB_PREFIX.strtolower($namedic) . "'"; + $checkTable = $db->query($query); + if ($checkTable && $db->num_rows($checkTable) > 0) { + setEventMessages($langs->trans("ErrorTableExist", $namedic), null, 'errors'); + return; + } else { + $_results = $db->DDLCreateTable(MAIN_DB_PREFIX.strtolower($namedic), $columns, $primaryKey, "InnoDB"); + if ($_results < 0) { + dol_print_error($db); + $langs->load("errors"); + setEventMessages($langs->trans("ErrorTableNotFound", $namedic), null, 'errors'); + } + } + + // rewrite dictionnary if + $dictionnaires['langs'] = $modulename.'@'.$modulename; + $dictionnaires['tabname'][] = strtolower($namedic); + $dictionnaires['tablib'][] = ucfirst(substr($namedic, 2)); + $dictionnaires['tabsql'][] = 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.strtolower($namedic).' as f'; + $dictionnaires['tabsqlsort'][] = (array_key_exists('label', $columns) ? 'label ASC' : ''); + $dictionnaires['tabfield'][] = (array_key_exists('code', $columns) && array_key_exists('label', $columns) ? 'code,label' : ''); + $dictionnaires['tabfieldvalue'][] = (array_key_exists('code', $columns) && array_key_exists('label', $columns) ? 'code,label' : ''); + $dictionnaires['tabfieldinsert'][] = (array_key_exists('code', $columns) && array_key_exists('label', $columns) ? 'code,label' : ''); + $dictionnaires['tabrowid'][] = $primaryKey; + $dictionnaires['tabcond'][] = isModEnabled('$modulename'); + $dictionnaires['tabhelp'][] = (array_key_exists('code', $columns) ? array('code'=>$langs->trans('CodeTooltipHelp'), 'field2' => 'field2tooltip') : ''); + + // Build the dictionary string + $writeInfile = updateDictionaryInFile($modulename, $file, $dictionnaires); + if ($writeInfile > 0) { + setEventMessages($langs->trans("DictionariesCreated", ucfirst(substr($namedic, 2))), null); + } +} + +/** + * Generate Urls and add them to documentaion module + * + * @param string $file_api filename or path of api + * @param string $file_doc filename or path of documentation + * @return int -1 if KO, 1 if OK, 0 if nothing change + */ +function writeApiUrlsInDoc($file_api, $file_doc) +{ + $error = 0; + if (!dol_is_file($file_api) || !dol_is_file($file_doc)) { + $error++; + } + $string = getFromFile($file_api, '/*begin methods CRUD*/', '/*end methods CRUD*/'); + $extractUrls = explode("\n", $string); + + // extract urls from file + $urlValues = []; + foreach ($extractUrls as $key => $line) { + $lineWithoutTabsSpaces = preg_replace('/^[\t\s]+/', '', $line); + if (strpos($lineWithoutTabsSpaces, '* @url') === 0) { + $urlValue = trim(substr($lineWithoutTabsSpaces, strlen('* @url'))); + $urlValues[] = $urlValue; + } + } + + // get urls by object + $str = $_SERVER['HTTP_HOST'].'/api/index.php/'; + $groupedUrls = []; + foreach ($urlValues as $url) { + if (preg_match('/(?:GET|POST|PUT|DELETE) (\w+)s/', $url, $matches)) { + $objectName = $matches[1]; + $url = $str.trim(strstr($url, ' ')); + $groupedUrls[$objectName][] = $url; + } + } + if (empty($groupedUrls)) { + $error++; + } + + // buil format asciidoc for urls in table + if (!$error) { + $asciiDocTable = "[options=\"header\"]\n|===\n|Objet | URLs\n"; + foreach ($groupedUrls as $objectName => $urls) { + $urlsList = implode(" +\n*", $urls); + $asciiDocTable .= "|$objectName | \n*$urlsList +\n"; + } + $asciiDocTable .= "|===\n"; + $file_write = dolReplaceInFile($file_doc, array('__API_DOC__' => '__API_DOC__'."\n".$asciiDocTable)); + if ($file_write < 0) { + return -1; + } + return 1; + } + return -1; +} + + +/** + * count directories or files in modulebuilder folder + * @param string $path path of directory + * @param int $type type of file 1= file,2=directory + * @return int|bool + */ +function countItemsInDirectory($path, $type = 1) +{ + if (!is_dir($path)) { + return false; + } + + $allFilesAndDirs = scandir($path); + $count = 0; + + foreach ($allFilesAndDirs as $item) { + if ($item != '.' && $item != '..') { + if ($type == 1 && is_file($path . DIRECTORY_SEPARATOR . $item) && strpos($item, '.back') === false) { + $count++; + } elseif ($type == 2 && is_dir($path . DIRECTORY_SEPARATOR . $item)) { + $count++; + } + } + } + return $count; +} diff --git a/htdocs/core/lib/oauth.lib.php b/htdocs/core/lib/oauth.lib.php index 1d3cb983e3e..055acf9256a 100644 --- a/htdocs/core/lib/oauth.lib.php +++ b/htdocs/core/lib/oauth.lib.php @@ -25,18 +25,66 @@ // Supported OAUTH (a provider is supported when a file xxx_oauthcallback.php is available into htdocs/core/modules/oauth) $supportedoauth2array = array( - 'OAUTH_GOOGLE_NAME'=>array('callbackfile' => 'google', 'picto' => 'google', 'urlforapp' => 'OAUTH_GOOGLE_DESC', 'name'=>'Google', 'urlforcredentials'=>'https://console.developers.google.com/', - 'availablescopes'=> 'userinfo_email,userinfo_profile,openid,email,profile,cloud_print,admin_directory_user,gmail_full,contact,https://www.googleapis.com/auth/contacts,https://www.googleapis.com/auth/calendar', 'returnurl'=>'/core/modules/oauth/google_oauthcallback.php'), + 'OAUTH_GOOGLE_NAME' => array( + 'callbackfile' => 'google', + 'picto' => 'google', + 'urlforapp' => 'OAUTH_GOOGLE_DESC', + 'name' => 'Google', + 'urlforcredentials' => 'https://console.developers.google.com/', + 'availablescopes' => 'userinfo_email,userinfo_profile,openid,email,profile,cloud_print,admin_directory_user,gmail_full,contact,https://www.googleapis.com/auth/contacts,https://www.googleapis.com/auth/calendar', + 'returnurl' => '/core/modules/oauth/google_oauthcallback.php' + ), ); if (isModEnabled('stripe')) { - $supportedoauth2array['OAUTH_STRIPE_TEST_NAME'] = array('callbackfile' => 'stripetest', 'picto' => 'stripe', 'urlforapp' => '', 'name'=>'StripeTest', 'urlforcredentials'=>'', 'availablescopes'=>'read_write', 'returnurl'=>'/core/modules/oauth/stripetest_oauthcallback.php'); - $supportedoauth2array['OAUTH_STRIPE_LIVE_NAME'] = array('callbackfile' => 'stripelive', 'picto' => 'stripe', 'urlforapp' => '', 'name'=>'StripeLive', 'urlforcredentials'=>'', 'availablescopes'=>'read_write', 'returnurl'=>'/core/modules/oauth/stripelive_oauthcallback.php'); + $supportedoauth2array['OAUTH_STRIPE_TEST_NAME'] = array( + 'callbackfile' => 'stripetest', + 'picto' => 'stripe', + 'urlforapp' => '', + 'name' => 'StripeTest', + 'urlforcredentials' => '', + 'availablescopes' => 'read_write', + 'returnurl' => '/core/modules/oauth/stripetest_oauthcallback.php' + ); + $supportedoauth2array['OAUTH_STRIPE_LIVE_NAME'] = array( + 'callbackfile' => 'stripelive', + 'picto' => 'stripe', + 'urlforapp' => '', + 'name' => 'StripeLive', + 'urlforcredentials' => '', + 'availablescopes' => 'read_write', + 'returnurl' => '/core/modules/oauth/stripelive_oauthcallback.php' + ); } -$supportedoauth2array['OAUTH_GITHUB_NAME'] = array('callbackfile' => 'github', 'picto' => 'github', 'urlforapp' => 'OAUTH_GITHUB_DESC', 'name'=>'GitHub', 'urlforcredentials'=>'https://github.com/settings/developers', 'availablescopes'=>'user,public_repo', 'returnurl'=>'/core/modules/oauth/github_oauthcallback.php'); -$supportedoauth2array['OAUTH_MICROSOFT_NAME'] = array('callbackfile' => 'microsoft', 'picto' => 'microsoft', 'urlforapp' => 'OAUTH_MICROSOFT_DESC', 'name'=>'Microsoft', 'urlforcredentials'=>'https://portal.azure.com/', 'availablescopes'=>'openid,offline_access,profile,email,User.Read,https://outlook.office365.com/IMAP.AccessAsUser.All,https://outlook.office365.com/SMTP.Send', 'returnurl'=>'/core/modules/oauth/microsoft_oauthcallback.php'); +$supportedoauth2array['OAUTH_GITHUB_NAME'] = array( + 'callbackfile' => 'github', + 'picto' => 'github', + 'urlforapp' => 'OAUTH_GITHUB_DESC', + 'name' => 'GitHub', + 'urlforcredentials' => 'https://github.com/settings/developers', + 'availablescopes' => 'user,public_repo', + 'returnurl' => '/core/modules/oauth/github_oauthcallback.php' +); +// See https://learn.microsoft.com/fr-fr/azure/active-directory/develop/quickstart-register-app#register-an-application +$supportedoauth2array['OAUTH_MICROSOFT_NAME'] = array( + 'callbackfile' => 'microsoft', + 'picto' => 'microsoft', + 'urlforapp' => 'OAUTH_MICROSOFT_DESC', + 'name' => 'Microsoft', + 'urlforcredentials' => 'https://portal.azure.com/', + // User.Read is a microsoftgraph scope, if it's not working, do not select it + 'availablescopes' => 'openid,offline_access,profile,email,User.Read,https://outlook.office365.com/IMAP.AccessAsUser.All,https://outlook.office365.com/SMTP.Send', + 'returnurl' => '/core/modules/oauth/microsoft_oauthcallback.php' +); if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { - $supportedoauth2array['OAUTH_OTHER_NAME'] = array('callbackfile' => 'generic', 'picto' => 'generic', 'urlforapp' => 'OAUTH_OTHER_DESC', 'name'=>'Other', 'urlforcredentials'=>'', 'availablescopes'=>'Standard', 'returnurl'=>'/core/modules/oauth/generic_oauthcallback.php'); - // See https://learn.microsoft.com/fr-fr/azure/active-directory/develop/quickstart-register-app#register-an-application + $supportedoauth2array['OAUTH_OTHER_NAME'] = array( + 'callbackfile' => 'generic', + 'picto' => 'generic', + 'urlforapp' => 'OAUTH_OTHER_DESC', + 'name' => 'Other', + 'urlforcredentials' => '', + 'availablescopes' => 'Standard', + 'returnurl' => '/core/modules/oauth/generic_oauthcallback.php' + ); } diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php index 349e3179f93..95ca76954fe 100644 --- a/htdocs/core/lib/order.lib.php +++ b/htdocs/core/lib/order.lib.php @@ -281,6 +281,7 @@ function getCustomerOrderPieChart($socid = 0) } $db->free($resql); + global $badgeStatus0, $badgeStatus1, $badgeStatus4, $badgeStatus6, $badgeStatus9; include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; $result = '
    '; @@ -298,10 +299,7 @@ function getCustomerOrderPieChart($socid = 0) if ($status == Commande::STATUS_SHIPMENTONPROCESS) { $colorseries[$status] = $badgeStatus4; } - if ($status == Commande::STATUS_CLOSED && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { - $colorseries[$status] = $badgeStatus6; - } - if ($status == Commande::STATUS_CLOSED && (!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) { + if ($status == Commande::STATUS_CLOSED) { $colorseries[$status] = $badgeStatus6; } if ($status == Commande::STATUS_CANCELED) { diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 67c661dbd93..158aa9d4596 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1586,7 +1586,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $ref_prodserv = $prodser->ref; // Show local ref only if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { - $productCustomerPriceStatic = new Productcustomerprice($db); + $productCustomerPriceStatic = new ProductCustomerPrice($db); $filter = array('fk_product' => $idprod, 'fk_soc' => $object->socid); $nbCustomerPrices = $productCustomerPriceStatic->fetchAll('', '', 1, 0, $filter); diff --git a/htdocs/core/lib/phpsessionindb.lib.php b/htdocs/core/lib/phpsessionindb.lib.php index f38123e2a7c..9dd806d86fc 100644 --- a/htdocs/core/lib/phpsessionindb.lib.php +++ b/htdocs/core/lib/phpsessionindb.lib.php @@ -22,9 +22,14 @@ * \brief Set function handlers for PHP session management in DB. */ -// The session handler file must be included just after the call of the master.inc.php into main.inc.php +// This session handler file must be included just after the call of the master.inc.php into main.inc.php // The $conf is already defined from conf.php file. -// To use it set in your PHP.ini: session.save_handler = user +// To use it set +// - create table ll_session from the llx_session-disabled.sql file +// - uncomment the include DOL_DOCUMENT_ROOT.'/core/lib/phpsessionindb.inc.php into main.inc.php +// - in your PHP.ini, set: session.save_handler = user +// The session_set_save_handler() at end of this fille will replace default session management. + /** * The session open handler called by PHP whenever a session is initialized. diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index 0376b70ecd8..bdf0117ae3c 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -153,6 +153,7 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as cv"; $sql .= " WHERE cv.taux = ".((float) $txtva); $sql .= " AND cv.fk_pays = ".((int) $countryid); + $sql .= " AND cv.entity IN (".getEntity('c_tva').")"; $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index ab2f18abe1a..de8a8af47db 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -214,7 +214,7 @@ function project_prepare_head(Project $project, $moreparam = '') if (isModEnabled('ticket') && $user->hasRight('ticket', 'read')) { require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php'; $Tickettatic = new Ticket($db); - $nbTicket = count($Tickettatic->getAllItemsLinkedByObjectID($project->id, '*', 'fk_project', 'ticket')); + $nbTicket = $Tickettatic->getCountOfItemsLinkedByObjectID($project->id, 'fk_project', 'ticket'); $head[$h][0] = DOL_URL_ROOT.'/ticket/list.php?projectid='.((int) $project->id); $head[$h][1] = $langs->trans("Ticket"); if ($nbTicket > 0) { @@ -1111,13 +1111,15 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } // Check if Extrafields is totalizable - foreach ($extrafields->attributes['projet_task']['totalizable'] as $key => $value) { - if (!empty($arrayfields['ef.'.$key]['checked']) && $arrayfields['ef.'.$key]['checked'] == 1) { - print '
  • '; } - print ''; } } diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index 626a89a9bea..598f8432a1c 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -260,6 +260,7 @@ function getCustomerProposalPieChart($socid = 0) } $db->free($resql); + global $badgeStatus0, $badgeStatus1, $badgeStatus4, $badgeStatus6, $badgeStatus9; include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; $result = '
    '; diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 58142de1f5b..f19046c0599 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -111,8 +111,8 @@ function dolGetRandomBytes($length) * Note: If a backup is restored onto another instance with a different $conf->file->instance_unique_id, then decoded value will differ. * This function is called for example by dol_set_const() when saving a sensible data into database configuration table llx_const. * - * @param string $chain string to encode - * @param string $key If '', we use $conf->file->instance_unique_id + * @param string $chain String to encode + * @param string $key If '', we use $conf->file->instance_unique_id (so $dolibarr_main_instance_unique_id in conf.php) * @param string $ciphering Default ciphering algorithm * @param string $forceseed To force the seed * @return string encoded string @@ -187,15 +187,21 @@ function dolDecrypt($chain, $key = '') } if (empty($key)) { - $key = $conf->file->instance_unique_id; + if (!empty($conf->file->dolcrypt_key)) { + $key = $conf->file->dolcrypt_key; + } else { + $key = $conf->file->instance_unique_id; + } } + //var_dump('key='.$key); $reg = array(); if (preg_match('/^dolcrypt:([^:]+):(.+)$/', $chain, $reg)) { $ciphering = $reg[1]; if (function_exists('openssl_decrypt')) { if (empty($key)) { - return 'Error dolDecrypt decrypt key is empty'; + dol_syslog("Error dolDecrypt decrypt key is empty", LOG_WARNING); + return $chain; } $tmpexplode = explode(':', $reg[2]); if (!empty($tmpexplode[1]) && is_string($tmpexplode[0])) { @@ -204,7 +210,8 @@ function dolDecrypt($chain, $key = '') $newchain = openssl_decrypt($tmpexplode[0], $ciphering, $key, 0, null); } } else { - $newchain = 'Error dolDecrypt function openssl_decrypt() not available'; + dol_syslog("Error dolDecrypt openssl_decrypt is not available", LOG_ERR); + return $chain; } return $newchain; } else { @@ -375,7 +382,7 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', //dol_syslog("functions.lib:restrictedArea $feature, $objectid, $dbtablename, $feature2, $dbt_socfield, $dbt_select, $isdraft"); /*print "user_id=".$user->id.", features=".$features.", feature2=".$feature2.", objectid=".$objectid; print ", dbtablename=".$tableandshare.", dbt_socfield=".$dbt_keyfield.", dbt_select=".$dbt_select; - print ", perm: user->right->".$features.($feature2 ? "->".$feature2 : "")."=".($user->hasRight($features, $feature2, 'lire'))."
    "; + print ", perm: user->hasRight(".$features.($feature2 ? ",".$feature2 : "").", lire) = ".($feature2 ? $user->hasRight($features, $feature2, 'lire') : $user->hasRight($features, 'lire'))."
    "; */ $parentfortableentity = ''; @@ -442,19 +449,21 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', // Get more permissions checks from hooks $parameters = array('features'=>$features, 'originalfeatures'=>$originalfeatures, 'objectid'=>$objectid, 'dbt_select'=>$dbt_select, 'idtype'=>$dbt_select, 'isdraft'=>$isdraft); - $reshook = $hookmanager->executeHooks('restrictedArea', $parameters); + if (!empty($hookmanager)) { + $reshook = $hookmanager->executeHooks('restrictedArea', $parameters); - if (isset($hookmanager->resArray['result'])) { - if ($hookmanager->resArray['result'] == 0) { - if ($mode) { - return 0; - } else { - accessforbidden(); // Module returns 0, so access forbidden + if (isset($hookmanager->resArray['result'])) { + if ($hookmanager->resArray['result'] == 0) { + if ($mode) { + return 0; + } else { + accessforbidden(); // Module returns 0, so access forbidden + } } } - } - if ($reshook > 0) { // No other test done. - return 1; + if ($reshook > 0) { // No other test done. + return 1; + } } // Features/modules to check @@ -630,6 +639,11 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', $createok = 0; $nbko++; } + } elseif ($feature == 'modulebuilder') { + if (!$user->hasRight('modulebuilder', 'run')) { + $createok = 0; + $nbko++; + } } elseif (!empty($feature2)) { // This is for permissions on 2 levels (module->object->write) foreach ($feature2 as $subfeature) { if ($subfeature == 'user' && $user->id == $objectid && $user->hasRight('user', 'self', 'creer')) { @@ -1183,7 +1197,7 @@ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $sho $langs->setDefaultLang(); } - $langs->load("errors"); + $langs->loadLangs(array("main", "errors")); if ($printheader) { if (function_exists("llxHeader")) { @@ -1191,6 +1205,7 @@ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $sho } elseif (function_exists("llxHeaderVierge")) { llxHeaderVierge(''); } + print '
    '; } print '
    '; if (empty($message)) { @@ -1223,6 +1238,7 @@ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $sho } } if ($printfooter && function_exists("llxFooter")) { + print '
    '; llxFooter(); } diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index 030e6ed3e35..3677851a613 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -242,7 +242,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end,"; $sql .= " ed.rowid as edrowid, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot as warehouse_id,"; - $sql .= " e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition,"; + $sql .= " e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition, e.billed, e.fk_statut as status,"; //if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) $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.tobatch as product_tobatch,'; $sql .= ' p.description as product_desc'; @@ -302,11 +302,18 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') while ($i < $num) { $objp = $db->fetch_object($resql); + $expedition->id = $objp->expedition_id; + $expedition->ref = $objp->exp_ref; + $expedition->billed = $objp->billed; + $expedition->statut = $objp->status; + $expedition->status = $objp->status; + print '
    '; // Sending id print ''; // Description @@ -346,6 +353,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') $product_static->id = $objp->fk_product; $product_static->ref = $objp->ref; $product_static->status_batch = $objp->product_tobatch; + $text = $product_static->getNomUrl(1); $text .= ' - '.$label; $description = (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE') ? '' : dol_htmlentitiesbr($objp->description)); @@ -436,7 +444,6 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') // Informations on receipt if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) { include_once DOL_DOCUMENT_ROOT.'/delivery/class/delivery.class.php'; - $expedition->id = $objp->sendingid; $expedition->fetchObjectLinked($expedition->id, $expedition->element); //var_dump($expedition->linkedObjects); diff --git a/htdocs/core/lib/signature.lib.php b/htdocs/core/lib/signature.lib.php index 38f11f0da1f..82f0b5be54d 100644 --- a/htdocs/core/lib/signature.lib.php +++ b/htdocs/core/lib/signature.lib.php @@ -130,7 +130,7 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1, $o } }*/ } elseif ($type == 'contract') { - $securekeyseed = isset($conf->global->CONTRACT_ONLINE_SIGNATURE_SECURITY_TOKEN) ? $conf->global->CONTRACT_ONLINE_SIGNATURE_SECURITY_TOKEN : ''; + $securekeyseed = getDolGlobalString('CONTRACT_ONLINE_SIGNATURE_SECURITY_TOKEN'); $out = $urltouse.'/public/onlinesign/newonlinesign.php?source=contract&ref='.($mode ? '' : ''); if ($mode == 1) { $out .= 'contract_ref'; @@ -145,7 +145,7 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1, $o $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? (empty($obj->entity) ? '' : (int) $obj->entity) : ''), '0'); } } elseif ($type == 'fichinter') { - $securekeyseed = isset($conf->global->FICHINTER_ONLINE_SIGNATURE_SECURITY_TOKEN) ? $conf->global->FICHINTER_ONLINE_SIGNATURE_SECURITY_TOKEN : ''; + $securekeyseed = getDolGlobalString('FICHINTER_ONLINE_SIGNATURE_SECURITY_TOKEN'); $out = $urltouse.'/public/onlinesign/newonlinesign.php?source=fichinter&ref='.($mode ? '' : ''); if ($mode == 1) { $out .= 'fichinter_ref'; @@ -159,6 +159,21 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1, $o } else { $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? (empty($obj->entity) ? '' : (int) $obj->entity) : ''), '0'); } + } else { + $securekeyseed = getDolGlobalString(dol_strtoupper($type).'ONLINE_SIGNATURE_SECURITY_TOKEN'); + $out = $urltouse.'/public/onlinesign/newonlinesign.php?source='.$type.'&ref='.($mode ? '' : ''); + if ($mode == 1) { + $out .= $type.'_ref'; + } + if ($mode == 0) { + $out .= urlencode($ref); + } + $out .= ($mode ? '' : ''); + if ($mode == 1) { + $out .= "hash('".$securekeyseed."' + '".$type."' + $type + '_ref)"; + } else { + $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(!isModEnabled('multicompany') ? '' : $object->entity), '0'); + } } // For multicompany diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 0e6ddfba0b5..8eef224ae25 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -82,7 +82,7 @@ function ticketAdminPrepareHead() */ function ticket_prepare_head($object) { - global $db, $langs, $conf, $user; + global $langs, $conf, $user; $h = 0; $head = array(); diff --git a/htdocs/core/lib/treeview.lib.php b/htdocs/core/lib/treeview.lib.php index 8e8cfc453d1..f34048fed3b 100644 --- a/htdocs/core/lib/treeview.lib.php +++ b/htdocs/core/lib/treeview.lib.php @@ -156,15 +156,17 @@ function tree_recur($tab, $pere, $rang, $iddivjstree = 'iddivjstree', $donoreset continue; } - print ''; + print "\n".''; $ulprinted++; } print "\n".'
  • '; if ($showfk) { - print '
  • '.$obj->title.''.$obj->libelle.''.dol_escape_htmltag($obj->title).''.dol_escape_htmltag($obj->type_label).''.dol_print_date($db->jdate($obj->do), "day").''; - if ($value == 1) { - print empty($totalarray['totalizable'][$key]['total']) ? '' : $totalarray['totalizable'][$key]['total']; + if (!empty($extrafields->attributes['projet_task']['totalizable'])) { + foreach ($extrafields->attributes['projet_task']['totalizable'] as $key => $value) { + if (!empty($arrayfields['ef.'.$key]['checked']) && $arrayfields['ef.'.$key]['checked'] == 1) { + print ''; + if ($value == 1) { + print empty($totalarray['totalizable'][$key]['total']) ? '' : $totalarray['totalizable'][$key]['total']; + } + print '
    '; - print ''.img_object($langs->trans("ShowSending"), 'sending').' '.$objp->exp_ref.''; + print $expedition->getNomUrl(1); + //print ''.img_object($langs->trans("ShowSending"), 'sending').' '.$objp->exp_ref.''; print '
    '; $text .= ''; - $text .= ''; + $text .= ''; $text .= ''; diff --git a/htdocs/core/modules/asset/mod_asset_standard.php b/htdocs/core/modules/asset/mod_asset_standard.php index 4fbf889fc9b..5269dd2c24c 100644 --- a/htdocs/core/modules/asset/mod_asset_standard.php +++ b/htdocs/core/modules/asset/mod_asset_standard.php @@ -53,9 +53,10 @@ class mod_asset_standard extends ModeleNumRefAsset /** * Return description of numbering module * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); diff --git a/htdocs/core/modules/asset/modules_asset.php b/htdocs/core/modules/asset/modules_asset.php index c9b64e0180f..87ac7c723dd 100644 --- a/htdocs/core/modules/asset/modules_asset.php +++ b/htdocs/core/modules/asset/modules_asset.php @@ -29,6 +29,7 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit @@ -37,42 +38,6 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // requir */ abstract class ModelePDFAsset extends CommonDocGenerator { - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules @@ -99,93 +64,7 @@ abstract class ModelePDFAsset extends CommonDocGenerator /** * Parent class to manage numbering of Asset */ -abstract class ModeleNumRefAsset +abstract class ModeleNumRefAsset extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Returns the default description of the numbering template - * - * @return string Descriptive text - */ - public function info() - { - global $langs; - $langs->load("asset@asset"); - return $langs->trans("NoDescription"); - } - - /** - * Returns an example of numbering - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("asset@asset"); - return $langs->trans("NoExample"); - } - - /** - * Checks if the numbers already in the database do not - * cause conflicts that would prevent this numbering working. - * - * @param Object $object Object we need next value for - * @return boolean false if conflict, true if ok - */ - public function canBeActivated($object) - { - return true; - } - - /** - * Returns next assigned value - * - * @param Object $object Object we need next value for - * @return string Valeur - */ - public function getNextValue($object) - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Returns version of numbering module - * - * @return string Valeur - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } - if ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } - if ($this->version == 'dolibarr') { - return DOL_VERSION; - } - if ($this->version) { - return $this->version; - } - return $langs->trans("NotAvailable"); - } + // No overload code } diff --git a/htdocs/core/modules/bank/doc/pdf_ban.modules.php b/htdocs/core/modules/bank/doc/pdf_ban.modules.php index 5996b3d50c0..9e200690dc7 100644 --- a/htdocs/core/modules/bank/doc/pdf_ban.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_ban.modules.php @@ -35,11 +35,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; class pdf_ban extends ModeleBankAccountDoc { - /** - * @var Societe Issuer - */ - public $emetteur; - /** * @var string Dolibarr version of the loaded document */ @@ -52,7 +47,7 @@ class pdf_ban extends ModeleBankAccountDoc */ public function __construct($db) { - global $conf, $langs, $mysoc; + global $langs, $mysoc; // Load translation files required by the page $langs->loadLangs(array("main", "bank", "withdrawals", "companies")); diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index 37bdd72fde0..7ebad740724 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -36,18 +36,31 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; class pdf_sepamandate extends ModeleBankAccountDoc { - /** - * Issuer - * @var Societe - */ - public $emetteur; - /** * Dolibarr version of the loaded document * @var string */ public $version = 'dolibarr'; + /** + * @var int Height reserved to output the info and total part + */ + public $heightforinfotot; + + /** + * @var int Height reserved to output the free text on last page + */ + public $heightforfreetext; + + /** + * @var int Height reserved to output the footer (value include bottom margin) + */ + public $heightforfooter; + + /** + * @var int x coordinate reserved to output the Signature area + */ + public $xPosSignArea; /** * Constructor * @@ -86,8 +99,17 @@ class pdf_sepamandate extends ModeleBankAccountDoc // Define column position $this->posxref = $this->marge_gauche; - } + $this->update_main_doc_field=1; + + $this->heightforinfotot=50; + + $this->xPosSignArea=120; + + $this->heightforfreetext = (getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT') > 0 ? getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT') : 5); + + $this->heightforfooter = $this->marge_basse + 8; + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** @@ -159,11 +181,9 @@ class pdf_sepamandate extends ModeleBankAccountDoc $pdf = pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance - $heightforinfotot = 50; // Height reserved to output the info and total part - $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) { - $heightforfooter += 6; + $this->heightforfooter += 6; } $pdf->SetAutoPageBreak(1, 0); @@ -199,7 +219,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc $tab_top = 50; $tab_top_newpage = 40; - $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; + $tab_height = $this->page_hauteur - $tab_top - $this->heightforfooter - $this->heightforfreetext ; // Show notes if (!empty($object->note_public)) { @@ -357,7 +377,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); $pdf->Rect(80, $posY, 5, 5); $pdf->SetXY(80, $posY); - if ($object->frstrecur == 'RECUR') { + if ($object->frstrecur == 'RCUR') { $pdf->MultiCell(5, 3, 'X', 0, 'L'); } $pdf->SetXY(86, $posY); @@ -387,17 +407,17 @@ class pdf_sepamandate extends ModeleBankAccountDoc // Show square if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); - $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter, 0, $outputlangs, 0, 0); + $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1; } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); - $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter, 0, $outputlangs, 1, 0); + $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1; } //var_dump($tab_top); - //var_dump($heightforinfotot); - //var_dump($heightforfreetext); - //var_dump($heightforfooter); + //var_dump($this->heightforinfotot ); + //var_dump($this->heightforfreetext ); + //var_dump($this->heightforfooter ); //var_dump($bottomlasttab); // Affiche zone infos @@ -531,7 +551,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc $pdf->MultiCell(100, 3, ' '); $pdf->MultiCell(100, 3, '______________________', 0, 'L', 0); - $posx = 120; + $posx = $this->xPosSignArea; $largcol = ($this->page_largeur - $this->marge_droite - $posx); $useborder = 0; $index = 0; diff --git a/htdocs/core/modules/bank/modules_bank.php b/htdocs/core/modules/bank/modules_bank.php index cfe7d406248..682c9fe4de9 100644 --- a/htdocs/core/modules/bank/modules_bank.php +++ b/htdocs/core/modules/bank/modules_bank.php @@ -31,12 +31,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; */ abstract class ModeleBankAccountDoc extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules diff --git a/htdocs/core/modules/barcode/doc/phpbarcode.modules.php b/htdocs/core/modules/barcode/doc/phpbarcode.modules.php index d11d052cc02..b38b660faf6 100644 --- a/htdocs/core/modules/barcode/doc/phpbarcode.modules.php +++ b/htdocs/core/modules/barcode/doc/phpbarcode.modules.php @@ -58,9 +58,10 @@ class modPhpbarcode extends ModeleBarCode /** * Return description * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; @@ -74,9 +75,10 @@ class modPhpbarcode extends ModeleBarCode * 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 + * @param Object $object Object we need next value for + * @return boolean false if KO (there is a conflict), true if OK */ - public function canBeActivated() + public function canBeActivated($object) { global $langs; diff --git a/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php b/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php index 9536251c36a..4cd98150c8a 100644 --- a/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php +++ b/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php @@ -47,12 +47,11 @@ class modTcpdfbarcode extends ModeleBarCode /** * Return description of numbering model * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { - global $langs; - return 'TCPDF-barcode'; } @@ -70,12 +69,11 @@ class modTcpdfbarcode extends ModeleBarCode * 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 + * @param Object $object Object we need next value for + * @return boolean false if KO (there is a conflict), true if OK */ - public function canBeActivated() + public function canBeActivated($object) { - global $langs; - return true; } diff --git a/htdocs/core/modules/barcode/mod_barcode_product_standard.php b/htdocs/core/modules/barcode/mod_barcode_product_standard.php index b1775a1e95f..99176dd00f2 100644 --- a/htdocs/core/modules/barcode/mod_barcode_product_standard.php +++ b/htdocs/core/modules/barcode/mod_barcode_product_standard.php @@ -109,7 +109,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode //$texte.= ''; $texte .= ''; $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= ''; $texte .= '
    '; - print ''.$tab[$x]['title'].''; - print '  (fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')'; - print ''; + print ''; + print ''; + print '
    '; + print ''.$tab[$x]['title'].''; + print '(fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')'; + print ''; print $tab[$x]['buttons']; print '
    '; } else { @@ -184,17 +186,19 @@ function tree_recur($tab, $pere, $rang, $iddivjstree = 'iddivjstree', $donoreset continue; } - print ''; + print "\n".''; $ulprinted++; } print "\n".'
  • '; if ($showfk) { - print ''; + print ''; print ''; /* @@ -562,14 +563,14 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { print ''; print ''; - print ''; print ''; } @@ -597,12 +598,13 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) if ($edit) print '
    ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; print '';*/ } else { + $default = 'ffffff'; print ''; print ''; print ''; print ''; @@ -646,7 +648,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; - $texte .= ''; $texte .= ''; $texte .= '
    '; - print '   '; + print ''; + print ''; + print '
    '; + print ''; print $tab[$x]['title']; print ''; - print '  (mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' - fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')'; - print ''; + print '(mainmenu='.$tab[$x]['mainmenu'].' - leftmenu='.$tab[$x]['leftmenu'].', fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')'; + print ''; print $tab[$x]['buttons']; print '
    '; } else { diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 07768bcd53f..cda3fd7ccfa 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -542,14 +542,15 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) // Nothing } else { // Show logo - print '
    '.$langs->trans("EnableShowLogo").''; + print '
    '.$langs->trans("EnableShowLogo").''; if ($edit) { print ajax_constantonoff('MAIN_SHOW_LOGO', array(), null, 0, 0, 1); //print $form->selectyesno('MAIN_SHOW_LOGO', $conf->global->MAIN_SHOW_LOGO, 1); } else { - print yn($conf->global->MAIN_SHOW_LOGO); + print yn($conf->global->MAIN_SHOW_LOGO); } - print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes")); + print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes"), 1, 'help', 'inline-block'); print '
    '.$langs->trans("UseBorderOnTable").''; + print ''; if ($edit) { print ajax_constantonoff('THEME_ELDY_USEBORDERONTABLE', array(), null, 0, 0, 1); //print $form->selectyesno('THEME_ELDY_USEBORDERONTABLE', $conf->global->THEME_ELDY_USEBORDERONTABLE, 1); } else { print yn($conf->global->THEME_ELDY_USEBORDERONTABLE); } - print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes")); + print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes"), 1, 'help', 'inline-block'); print '
    '.$langs->trans("BackgroundColor").''; //var_dump($conf->global->THEME_ELDY_BACKBODY); if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_BACKBODY) ? $conf->global->THEME_ELDY_BACKBODY : ''), array()), ''), 'THEME_ELDY_BACKBODY', '', 1, '', '', 'colorbackbody').' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_BACKBODY) ? $conf->global->THEME_ELDY_BACKBODY : ''), array()), ''), 'THEME_ELDY_BACKBODY', '', 1, '', '', 'colorbackbody', $default).' '; } else { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BACKBODY, array()), ''); if ($color) { @@ -611,7 +613,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print $langs->trans("Default"); } } - print '   '.$langs->trans("Default").': ffffff '; + print '   '.$langs->trans("Default").': '.$default.' '; print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); print '
    '.$langs->trans("TopMenuBackgroundColor").''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_TOPMENU_BACK1) ? $conf->global->THEME_ELDY_TOPMENU_BACK1 : ''), array()), ''), 'THEME_ELDY_TOPMENU_BACK1', '', 1, '', '', 'colorbackhmenu1').' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_TOPMENU_BACK1) ? $conf->global->THEME_ELDY_TOPMENU_BACK1 : ''), array()), ''), 'THEME_ELDY_TOPMENU_BACK1', '', 1, '', '', 'colorbackhmenu1', $default).' '; } else { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1, array()), ''); if ($color) { @@ -690,7 +692,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''.$langs->trans("LeftMenuBackgroundColor").''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_VERMENU_BACK1) ? $conf->global->THEME_ELDY_VERMENU_BACK1 : ''), array()), ''), 'THEME_ELDY_VERMENU_BACK1', '', 1, '', '', 'colorbackvmenu1').' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_VERMENU_BACK1) ? $conf->global->THEME_ELDY_VERMENU_BACK1 : ''), array()), ''), 'THEME_ELDY_VERMENU_BACK1', '', 1, '', '', 'colorbackvmenu1', $default).' '; } else { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_VERMENU_BACK1, array()), ''); if ($color) { @@ -714,7 +716,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''.$langs->trans("TextTitleColor").''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_TEXTTITLENOTAB) ? $conf->global->THEME_ELDY_TEXTTITLENOTAB : ''), array()), ''), 'THEME_ELDY_TEXTTITLENOTAB', '', 1, '', '', 'colortexttitlenotab').' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_TEXTTITLENOTAB) ? $conf->global->THEME_ELDY_TEXTTITLENOTAB : ''), array()), ''), 'THEME_ELDY_TEXTTITLENOTAB', '', 1, '', '', 'colortexttitlenotab', $default).' '; } else { print $formother->showColor($conf->global->THEME_ELDY_TEXTTITLENOTAB, $langs->trans("Default")); } @@ -734,7 +736,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''.$langs->trans("BackgroundTableTitleColor").''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_BACKTITLE1) ? $conf->global->THEME_ELDY_BACKTITLE1 : ''), array()), ''), 'THEME_ELDY_BACKTITLE1', '', 1, '', '', 'colorbacktitle1').' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_BACKTITLE1) ? $conf->global->THEME_ELDY_BACKTITLE1 : ''), array()), ''), 'THEME_ELDY_BACKTITLE1', '', 1, '', '', 'colorbacktitle1', $default).' '; } else { print $formother->showColor($conf->global->THEME_ELDY_BACKTITLE1, $langs->trans("Default")); } @@ -754,7 +756,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''.$langs->trans("BackgroundTableTitleTextColor").''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_TEXTTITLE) ? $conf->global->THEME_ELDY_TEXTTITLE : ''), array()), ''), 'THEME_ELDY_TEXTTITLE', '', 1, '', '', 'colortexttitle').' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_TEXTTITLE) ? $conf->global->THEME_ELDY_TEXTTITLE : ''), array()), ''), 'THEME_ELDY_TEXTTITLE', '', 1, '', '', 'colortexttitle', $default).' '; } else { print $formother->showColor($conf->global->THEME_ELDY_TEXTTITLE, $langs->trans("Default")); } @@ -774,7 +776,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''.$langs->trans("BackgroundTableTitleTextlinkColor").''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_TEXTTITLELINK) ? $conf->global->THEME_ELDY_TEXTTITLELINK : ''), array()), ''), 'THEME_ELDY_TEXTTITLELINK', '', 1, '', '', 'colortexttitlelink').' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_TEXTTITLELINK) ? $conf->global->THEME_ELDY_TEXTTITLELINK : ''), array()), ''), 'THEME_ELDY_TEXTTITLELINK', '', 1, '', '', 'colortexttitlelink', $default).' '; } else { print $formother->showColor($conf->global->THEME_ELDY_TEXTTITLELINK, $langs->trans("Default")); } @@ -795,7 +797,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''.$langs->trans("BackgroundTableLineOddColor").''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_LINEIMPAIR1) ? $conf->global->THEME_ELDY_LINEIMPAIR1 : ''), array()), ''), 'THEME_ELDY_LINEIMPAIR1', '', 1, '', '', 'colorbacklineimpair2').' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_LINEIMPAIR1) ? $conf->global->THEME_ELDY_LINEIMPAIR1 : ''), array()), ''), 'THEME_ELDY_LINEIMPAIR1', '', 1, '', '', 'colorbacklineimpair2', $default).' '; } else { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEIMPAIR1, array()), ''); if ($color) { @@ -819,7 +821,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''.$langs->trans("BackgroundTableLineEvenColor").''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_LINEPAIR1) ? $conf->global->THEME_ELDY_LINEPAIR1 : ''), array()), ''), 'THEME_ELDY_LINEPAIR1', '', 1, '', '', 'colorbacklinepair2').' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_LINEPAIR1) ? $conf->global->THEME_ELDY_LINEPAIR1 : ''), array()), ''), 'THEME_ELDY_LINEPAIR1', '', 1, '', '', 'colorbacklinepair2', $default).' '; } else { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEPAIR1, array()), ''); if ($color) { @@ -863,7 +865,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''.$langs->trans("LinkColor").''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_TEXTLINK) ? $conf->global->THEME_ELDY_TEXTLINK : ''), array()), ''), 'THEME_ELDY_TEXTLINK', '', 1, '', '', 'colortextlink').' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_TEXTLINK) ? $conf->global->THEME_ELDY_TEXTLINK : ''), array()), ''), 'THEME_ELDY_TEXTLINK', '', 1, '', '', 'colortextlink', $default).' '; } else { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTLINK, array()), ''); if ($color) { @@ -906,7 +908,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { $color = colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_USE_HOVER) ? $conf->global->THEME_ELDY_USE_HOVER : ''), array()), ''); } - print $formother->selectColor($color, 'THEME_ELDY_USE_HOVER', '', 1, '', '', 'colorbacklinepairhover').' '; + print $formother->selectColor($color, 'THEME_ELDY_USE_HOVER', '', 1, '', '', 'colorbacklinepairhover', $default).' '; } else { if ($conf->global->THEME_ELDY_USE_HOVER == '1') { $color = colorArrayToHex(colorStringToArray($colorbacklinepairhover)); @@ -954,7 +956,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { $color = colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_USE_CHECKED) ? $conf->global->THEME_ELDY_USE_CHECKED : ''), array()), ''); } - print $formother->selectColor($color, 'THEME_ELDY_USE_CHECKED', '', 1, '', '', 'colorbacklinepairchecked').' '; + print $formother->selectColor($color, 'THEME_ELDY_USE_CHECKED', '', 1, '', '', 'colorbacklinepairchecked', $default).' '; } else { if ($conf->global->THEME_ELDY_USE_CHECKED == '1') { $color = 'e6edf0'; @@ -1006,7 +1008,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''.$langs->trans("BtnActionColor").''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_BTNACTION) ? $conf->global->THEME_ELDY_BTNACTION : ''), array()), ''), 'THEME_ELDY_BTNACTION', '', 1, '', '', 'butactionbg').' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_BTNACTION) ? $conf->global->THEME_ELDY_BTNACTION : ''), array()), ''), 'THEME_ELDY_BTNACTION', '', 1, '', '', 'butactionbg', $default).' '; } else { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BTNACTION, array()), ''); if ($color) { @@ -1052,7 +1054,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''.$langs->trans("TextBtnActionColor").''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_TEXTBTNACTION) ? $conf->global->THEME_ELDY_TEXTBTNACTION : ''), array()), ''), 'THEME_ELDY_TEXTBTNACTION', '', 1, '', '', 'textbutaction').' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_TEXTBTNACTION) ? $conf->global->THEME_ELDY_TEXTBTNACTION : ''), array()), ''), 'THEME_ELDY_TEXTBTNACTION', '', 1, '', '', 'textbutaction', $default).' '; } else { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTBTNACTION, array()), ''); if ($color) { diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 30edeac0d32..ee77e7dd316 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -166,12 +166,14 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0, $c if (preg_last_error() == PREG_JIT_STACKLIMIT_ERROR) $content = 'preg_replace error (when removing php tags) PREG_JIT_STACKLIMIT_ERROR'; }*/ $content = dolStripPhpCode($content, $replacewith); - //var_dump($content); // Protect the link styles.css.php to any replacement that we make after. $content = str_replace('href="styles.css.php', 'href="!~!~!~styles.css.php', $content); + $content = str_replace('src="javascript.js.php', 'src="!~!~!~javascript.js.php', $content); $content = str_replace('href="http', 'href="!~!~!~http', $content); + $content = str_replace('xlink:href="', 'xlink:href="!~!~!~', $content); $content = str_replace('href="//', 'href="!~!~!~//', $content); + $content = str_replace('src="//', 'src="!~!~!~//', $content); $content = str_replace('src="viewimage.php', 'src="!~!~!~/viewimage.php', $content); $content = str_replace('src="/viewimage.php', 'src="!~!~!~/viewimage.php', $content); $content = str_replace('src="'.DOL_URL_ROOT.'/viewimage.php', 'src="!~!~!~'.DOL_URL_ROOT.'/viewimage.php', $content); @@ -304,11 +306,15 @@ function dolWebsiteOutput($content, $contenttype = 'html', $containerid = '') } } elseif (defined('USEDOLIBARRSERVER')) { // REPLACEMENT OF LINKS When page called from Dolibarr server $content = str_replace('virtualhost) { $content = preg_replace('/^(]*rel="canonical" href=")\//m', '\1'.$website->virtualhost.'/', $content, -1, $nbrep); diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index 87a964c9419..1668d640f02 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -248,7 +248,7 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage, // Add js $tplcontent .= ''."\n"; $tplcontent .= ''."\n"; - $tplcontent .= ''."\n"; + $tplcontent .= ''."\n"; // Add headers $tplcontent .= ''."\n"; $tplcontent .= ''."\n"; diff --git a/htdocs/core/lib/xcal.lib.php b/htdocs/core/lib/xcal.lib.php index c0c762a3152..6fbddd99474 100644 --- a/htdocs/core/lib/xcal.lib.php +++ b/htdocs/core/lib/xcal.lib.php @@ -497,7 +497,7 @@ function calEncode($line) for ($j = 0; $j < $strlength; $j++) { // Take char at position $j - $char = mb_substr($line, $j, 1, "UTF-8"); + $char = dol_substr($line, $j, 1, "UTF-8"); if ((mb_strlen($newpara, "UTF-8") + mb_strlen($char, "UTF-8")) >= 75) { // CRLF + Space for cal diff --git a/htdocs/core/login/functions_dolibarr.php b/htdocs/core/login/functions_dolibarr.php index 25967efe057..05eec06ccd6 100644 --- a/htdocs/core/login/functions_dolibarr.php +++ b/htdocs/core/login/functions_dolibarr.php @@ -51,109 +51,134 @@ function check_user_password_dolibarr($usertotest, $passwordtotest, $entitytotes require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; dol_syslog("functions_dolibarr::check_user_password_dolibarr usertotest=".$usertotest." passwordtotest=".preg_replace('/./', '*', $passwordtotest)." entitytotest=".$entitytotest); - // If test username/password asked, we define $test=false if ko and $login var to login if ok, set also $_SESSION["dol_loginmesg"] if ko - $table = MAIN_DB_PREFIX."user"; - $usernamecol1 = 'login'; - $usernamecol2 = 'email'; - $entitycol = 'entity'; - - $sql = "SELECT rowid, login, entity, pass, pass_crypted, datestartvalidity, dateendvalidity, flagdelsessionsbefore"; - $sql .= " FROM ".$table; - $sql .= " WHERE (".$usernamecol1." = '".$db->escape($usertotest)."'"; - if (preg_match('/@/', $usertotest)) { - $sql .= " OR ".$usernamecol2." = '".$db->escape($usertotest)."'"; - } - $sql .= ") AND ".$entitycol." IN (0,".($entity ? ((int) $entity) : 1).")"; - $sql .= " AND statut = 1"; - // Order is required to firstly found the user into entity, then the superadmin. - // For the case (TODO: we must avoid that) a user has renamed its login with same value than a user in entity 0. - $sql .= " ORDER BY entity DESC"; - - // Note: Test on validity is done later natively with isNotIntoValidityDateRange() by core after calling checkLoginPassEntity() that call this method + // Verification number of USER_LOGIN_FAILED + $dateverificationauth = dol_time_plus_duree(dol_now(), -1, 'd'); + $userremoteip = getUserRemoteIP(); + $nbevents = 0; + $sql = "SELECT COUNT(e.rowid) as nbevent"; + $sql .= " FROM ".MAIN_DB_PREFIX."events as e"; + $sql .= " WHERE e.type = 'USER_LOGIN_FAILED'"; + $sql .= " AND e.ip = '".$db->escape($userremoteip)."'"; + $sql .= " AND e.dateevent > '".$db->idate($dateverificationauth)."'"; $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); if ($obj) { - $passclear = $obj->pass; - $passcrypted = $obj->pass_crypted; - $passtyped = $passwordtotest; + $nbevents = $obj->nbevent; + } + } - $passok = false; + if ($nbevents <= getDolGlobalInt("MAIN_SECURITY_MAX_NUMBER_FAILED_AUTH", 100)) { + // If test username/password asked, we define $test=false if ko and $login var to login if ok, set also $_SESSION["dol_loginmesg"] if ko + $table = MAIN_DB_PREFIX."user"; + $usernamecol1 = 'login'; + $usernamecol2 = 'email'; + $entitycol = 'entity'; - // Check crypted password - $cryptType = ''; - if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) { - $cryptType = $conf->global->DATABASE_PWD_ENCRYPTED; - } + $sql = "SELECT rowid, login, entity, pass, pass_crypted, datestartvalidity, dateendvalidity, flagdelsessionsbefore"; + $sql .= " FROM ".$table; + $sql .= " WHERE (".$usernamecol1." = '".$db->escape($usertotest)."'"; + if (preg_match('/@/', $usertotest)) { + $sql .= " OR ".$usernamecol2." = '".$db->escape($usertotest)."'"; + } + $sql .= ") AND ".$entitycol." IN (0,".($entity ? ((int) $entity) : 1).")"; + $sql .= " AND statut = 1"; + // Order is required to firstly found the user into entity, then the superadmin. + // For the case (TODO: we must avoid that) a user has renamed its login with same value than a user in entity 0. + $sql .= " ORDER BY entity DESC"; - // By default, we use default setup for encryption rule - if (!in_array($cryptType, array('auto'))) { - $cryptType = 'auto'; - } - // Check crypted password according to crypt algorithm - if ($cryptType == 'auto') { - if ($passcrypted && dol_verifyHash($passtyped, $passcrypted, '0')) { - $passok = true; - dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ok - hash ".$cryptType." of pass is ok"); + // Note: Test on validity is done later natively with isNotIntoValidityDateRange() by core after calling checkLoginPassEntity() that call this method + + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + if ($obj) { + $passclear = $obj->pass; + $passcrypted = $obj->pass_crypted; + $passtyped = $passwordtotest; + + $passok = false; + + // Check crypted password + $cryptType = ''; + if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) { + $cryptType = $conf->global->DATABASE_PWD_ENCRYPTED; } - } - // For compatibility with very old versions - if (!$passok) { - if ((!$passcrypted || $passtyped) - && ($passclear && ($passtyped == $passclear))) { - $passok = true; - dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ok - found old pass in database", LOG_WARNING); + // By default, we use default setup for encryption rule + if (!in_array($cryptType, array('auto'))) { + $cryptType = 'auto'; + } + // Check crypted password according to crypt algorithm + if ($cryptType == 'auto') { + if ($passcrypted && dol_verifyHash($passtyped, $passcrypted, '0')) { + $passok = true; + dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ok - hash ".$cryptType." of pass is ok"); + } } - } - // Password ok ? - if ($passok) { - $login = $obj->login; + // For compatibility with very old versions + if (!$passok) { + if ((!$passcrypted || $passtyped) + && ($passclear && ($passtyped == $passclear))) { + $passok = true; + dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ok - found old pass in database", LOG_WARNING); + } + } + + // Password ok ? + if ($passok) { + $login = $obj->login; + } else { + dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentication KO bad password for '".$usertotest."', cryptType=".$cryptType, LOG_NOTICE); + sleep(1); // Anti brut force protection. Must be same delay when login is not valid + + // Load translation files required by the page + $langs->loadLangs(array('main', 'errors')); + + $_SESSION["dol_loginmesg"] = $langs->transnoentitiesnoconv("ErrorBadLoginPassword"); + } + + // We must check entity + if ($passok && isModEnabled('multicompany')) { // We must check entity + global $mc; + + if (!isset($mc)) { + !isModEnabled('multicompany'); // Global not available, disable $conf->multicompany->enabled for safety + } else { + $ret = $mc->checkRight($obj->rowid, $entitytotest); + if ($ret < 0) { + dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentication KO entity '".$entitytotest."' not allowed for user '".$obj->rowid."'", LOG_NOTICE); + + $login = ''; // force authentication failure + if ($mc->db->lasterror()) { + $_SESSION["dol_loginmesg"] = $mc->db->lasterror(); + } + } + } + } } else { - dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentication KO bad password for '".$usertotest."', cryptType=".$cryptType, LOG_NOTICE); - sleep(1); // Anti brut force protection. Must be same delay when login is not valid + dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentication KO user not found for '".$usertotest."'", LOG_NOTICE); + sleep(1); // Anti brut force protection. Must be same delay when password is not valid // Load translation files required by the page $langs->loadLangs(array('main', 'errors')); $_SESSION["dol_loginmesg"] = $langs->transnoentitiesnoconv("ErrorBadLoginPassword"); } - - // We must check entity - if ($passok && isModEnabled('multicompany')) { // We must check entity - global $mc; - - if (!isset($mc)) { - !isModEnabled('multicompany'); // Global not available, disable $conf->multicompany->enabled for safety - } else { - $ret = $mc->checkRight($obj->rowid, $entitytotest); - if ($ret < 0) { - dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentication KO entity '".$entitytotest."' not allowed for user '".$obj->rowid."'", LOG_NOTICE); - - $login = ''; // force authentication failure - if ($mc->db->lasterror()) { - $_SESSION["dol_loginmesg"] = $mc->db->lasterror(); - } - } - } - } } else { - dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentication KO user not found for '".$usertotest."'", LOG_NOTICE); - sleep(1); // Anti brut force protection. Must be same delay when password is not valid - - // Load translation files required by the page - $langs->loadLangs(array('main', 'errors')); - - $_SESSION["dol_loginmesg"] = $langs->transnoentitiesnoconv("ErrorBadLoginPassword"); + dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentication KO db error for '".$usertotest."' error=".$db->lasterror(), LOG_ERR); + sleep(1); + $_SESSION["dol_loginmesg"] = $db->lasterror(); } } else { - dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentication KO db error for '".$usertotest."' error=".$db->lasterror(), LOG_ERR); - sleep(1); - $_SESSION["dol_loginmesg"] = $db->lasterror(); + dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentication KO Too many attempts", LOG_NOTICE); + sleep(1); // Anti brut force protection. Must be same delay when password is not valid + // Load translation files required by the page + $langs->loadLangs(array('main', 'errors')); + $_SESSION["dol_loginmesg"] = $langs->transnoentitiesnoconv("ErrorTooManyAttempts"); } } - return $login; } diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index a4b493359d5..75240881129 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1094,7 +1094,7 @@ function get_left_menu_home($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = $langs->load("users"); // Home - dashboard - $newmenu->add("/index.php?mainmenu=home&leftmenu=home", $langs->trans("MyDashboard"), 0, 1, '', $mainmenu, 'home', 0, '', '', '', ''); + $newmenu->add("/index.php?mainmenu=home&leftmenu=home", $langs->trans("MyDashboard"), 0, 1, '', $mainmenu, 'home', 0, '', '', '', ''); // Setup $newmenu->add("/admin/index.php?mainmenu=home&leftmenu=setup", $langs->trans("Setup"), 0, $user->admin, '', $mainmenu, 'setup', 0, '', '', '', ''); @@ -2064,6 +2064,13 @@ function get_left_menu_products($mainmenu, &$newmenu, $usemenuhider = 1, $leftme $newmenu->add("/product/index.php?leftmenu=service&type=1", $langs->trans("Services"), 0, $user->hasRight('service', 'read'), '', $mainmenu, 'service', 0, '', '', '', img_picto('', 'service', 'class="pictofixedwidth"')); $newmenu->add("/product/card.php?leftmenu=service&action=create&type=1", $langs->trans("NewService"), 1, $user->hasRight('service', 'creer')); $newmenu->add("/product/list.php?leftmenu=service&type=1", $langs->trans("List"), 1, $user->hasRight('service', 'read')); + + if (isModEnabled('Stock') && getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { + $newmenu->add("/product/reassort.php?type=1", $langs->trans("MenuStocks"), 1, $user->hasRight('service', 'read') && $user->hasRight('stock', 'lire')); + } + if (isModEnabled('variants')) { + $newmenu->add("/variants/list.php", $langs->trans("VariantAttributes"), 1, $user->hasRight('service', 'read')); + } if (isModEnabled('propal') || isModEnabled('commande') || isModEnabled('facture') || isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) { $newmenu->add("/product/stats/card.php?id=all&leftmenu=stats&type=1", $langs->trans("Statistics"), 1, $user->hasRight('service', 'read')); } diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 466469423d8..f1b3c63e31e 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -2179,7 +2179,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } // Define the constant in database if requested (not the default mode) - if (!empty($addtodatabase)) { + if (!empty($addtodatabase) && !empty($name)) { $result = $this->insert_dirs($name, $dir); if ($result) { $err++; 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 15d95bde92e..b6ec5c85be6 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 @@ -40,12 +40,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; */ class doc_generic_asset_odt extends ModelePDFAsset { - /** - * Issuer - * @var Societe - */ - public $emetteur; - /** * @var string Dolibarr version of the loaded document */ @@ -140,17 +134,18 @@ class doc_generic_asset_odt extends ModelePDFAsset } } $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp .= '

    '.$langs->trans("ExampleOfDirectoriesForModelGen").''; // Add list of substitution keys $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); $texte .= '
    '; $texte .= ''; $texte .= '
    '; - $texte .= ''; + $texte .= ''; $texte .= '
    '; // Scan directories @@ -175,9 +170,6 @@ class doc_generic_asset_odt extends ModelePDFAsset $texte .= '
    '; - $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte .= '
    '; 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 56057582d11..525a1a7eccc 100644 --- a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php +++ b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php @@ -74,53 +74,11 @@ class pdf_standard_asset extends ModelePDFAsset */ public $version = 'dolibarr'; - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - /** - * Issuer - * @var Societe Object that emits - */ - public $emetteur; - /** * @var bool Situation invoice type */ public $situationinvoice; - /** * @var array of document table columns */ diff --git a/htdocs/core/modules/asset/mod_asset_advanced.php b/htdocs/core/modules/asset/mod_asset_advanced.php index 4c27609ff59..ff39d1e2613 100644 --- a/htdocs/core/modules/asset/mod_asset_advanced.php +++ b/htdocs/core/modules/asset/mod_asset_advanced.php @@ -53,11 +53,12 @@ class mod_asset_advanced extends ModeleNumRefAsset /** * Returns the description of the numbering model * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { - global $conf, $langs, $db; + global $langs, $db; $langs->load("bills"); @@ -80,7 +81,7 @@ class mod_asset_advanced extends ModeleNumRefAsset $text .= '
  • '.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'   
    '.$langs->trans("Mask").' ('.$langs->trans("BarCodeModel").'):
    '.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'   
    '; diff --git a/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php b/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php index 6eae8da2c1f..c2e73d2d78f 100644 --- a/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php +++ b/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php @@ -110,7 +110,7 @@ class mod_barcode_thirdparty_standard extends ModeleNumRefBarCode //$texte.= ''.$langs->trans("Mask").' ('.$langs->trans("BarCodeModel").'):'; $texte .= ''.$langs->trans("Mask").':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/barcode/modules_barcode.class.php b/htdocs/core/modules/barcode/modules_barcode.class.php index dac575cbb17..1a61ead4131 100644 --- a/htdocs/core/modules/barcode/modules_barcode.class.php +++ b/htdocs/core/modules/barcode/modules_barcode.class.php @@ -22,6 +22,7 @@ * \brief File with parent classes for barcode document modules and numbering modules */ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; /** @@ -50,45 +51,8 @@ abstract class ModeleBarCode /** * Parent class for barcode numbering models */ -abstract class ModeleNumRefBarCode +abstract class ModeleNumRefBarCode extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - /** Return default description of numbering model - * - * @param Translate $langs Object langs - * @return string Descriptive text - */ - public function info($langs) - { - $langs->load("bills"); - return $langs->trans("NoDescription"); - } - - /** Return model name - * - * @param Translate $langs Object langs - * @return string Model name - */ - public function getNom($langs) - { - return empty($this->name) ? get_class($this) : $this->name; - } - - /** Return a numbering example - * - * @param Translate $langs Object langs - * @return string Example - */ - public function getExample($langs) - { - $langs->load("bills"); - return $langs->trans("NoExample"); - } - /** * Return next value available * @@ -102,30 +66,6 @@ abstract class ModeleNumRefBarCode return $langs->trans("Function_getNextValue_InModuleNotWorking"); } - /** Return version of module - * - * @return string Version - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } - if ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } - if ($this->version == 'dolibarr') { - return DOL_VERSION; - } - if ($this->version) { - return $this->version; - } - return $langs->trans("NotAvailable"); - } - /** * Return description of module parameters * 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 1fcc55446a8..219c1fd0873 100644 --- a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php +++ b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php @@ -40,12 +40,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; */ class doc_generic_bom_odt extends ModelePDFBom { - /** - * Issuer - * @var Societe - */ - public $emetteur; - /** * @var string Dolibarr version of the loaded document */ @@ -136,17 +130,18 @@ class doc_generic_bom_odt extends ModelePDFBom } } $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp .= '

    '.$langs->trans("ExampleOfDirectoriesForModelGen").''; // Add list of substitution keys $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); $texte .= '
    '; $texte .= ''; $texte .= '
    '; - $texte .= ''; + $texte .= ''; $texte .= '
    '; // Scan directories @@ -178,16 +173,11 @@ class doc_generic_bom_odt extends ModelePDFBom } $texte .= ' '; $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= '
    '; $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte .= ''; - $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/bom/mod_bom_advanced.php b/htdocs/core/modules/bom/mod_bom_advanced.php index 28e326ef824..b8933a32504 100644 --- a/htdocs/core/modules/bom/mod_bom_advanced.php +++ b/htdocs/core/modules/bom/mod_bom_advanced.php @@ -54,11 +54,12 @@ class mod_bom_advanced extends ModeleNumRefBoms /** * Returns the description of the numbering model * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { - global $conf, $langs, $db; + global $langs, $db; $langs->load("bills"); @@ -81,7 +82,7 @@ class mod_bom_advanced extends ModeleNumRefBoms $texte .= ''.$langs->trans("Mask").':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; diff --git a/htdocs/core/modules/bom/mod_bom_standard.php b/htdocs/core/modules/bom/mod_bom_standard.php index 859ffbf6aee..49c1bec0948 100644 --- a/htdocs/core/modules/bom/mod_bom_standard.php +++ b/htdocs/core/modules/bom/mod_bom_standard.php @@ -51,9 +51,10 @@ class mod_bom_standard extends ModeleNumRefBoms /** * Return description of numbering module * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -75,9 +76,10 @@ class mod_bom_standard extends ModeleNumRefBoms * 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 + * @param Object $object Object we need next value for + * @return boolean false if conflict, true if ok */ - public function canBeActivated() + public function canBeActivated($object) { global $conf, $langs, $db; diff --git a/htdocs/core/modules/bom/modules_bom.php b/htdocs/core/modules/bom/modules_bom.php index 64fc9502d26..5e639f02554 100644 --- a/htdocs/core/modules/bom/modules_bom.php +++ b/htdocs/core/modules/bom/modules_bom.php @@ -30,6 +30,7 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit @@ -38,7 +39,6 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // requir */ abstract class ModelePDFBom extends CommonDocGenerator { - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules @@ -65,93 +65,7 @@ abstract class ModelePDFBom extends CommonDocGenerator /** * Parent class to manage numbering of BOMs */ -abstract class ModeleNumRefBoms +abstract class ModeleNumRefBoms extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Returns the default description of the numbering template - * - * @return string Descriptive text - */ - public function info() - { - global $langs; - $langs->load("mrp"); - return $langs->trans("NoDescription"); - } - - /** - * Returns an example of numbering - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("mrp"); - return $langs->trans("NoExample"); - } - - /** - * 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() - { - return true; - } - - /** - * Returns next assigned value - * - * @param Societe $objsoc Object thirdparty - * @param Object $object Object we need next value for - * @return string Valeur - */ - public function getNextValue($objsoc, $object) - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Returns version of numbering module - * - * @return string Valeur - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } - if ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } - if ($this->version == 'dolibarr') { - return DOL_VERSION; - } - if ($this->version) { - return $this->version; - } - return $langs->trans("NotAvailable"); - } + // No overload code } diff --git a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php index 6d257de6306..f963adccf70 100644 --- a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php @@ -35,10 +35,34 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/cheque/modules_chequereceipts.php' class BordereauChequeBlochet extends ModeleChequeReceipts { /** - * Issuer - * @var Societe + * @var int tab_top */ - public $emetteur; + public $tab_top; + + /** + * @var int tab_height + */ + public $tab_height; + + /** + * @var int line_height + */ + public $line_height; + + /** + * @var int line per page + */ + public $line_per_page; + + /** + * @var Account bank account + */ + public $account; + + /** + * @var array lines + */ + public $lines; /** * Constructor @@ -47,7 +71,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts */ public function __construct($db) { - global $conf, $langs, $mysoc; + global $langs, $mysoc; // Load traductions files required by page $langs->loadLangs(array("main", "bills")); diff --git a/htdocs/core/modules/cheque/mod_chequereceipt_mint.php b/htdocs/core/modules/cheque/mod_chequereceipt_mint.php index a882c1e0068..034fa63437e 100644 --- a/htdocs/core/modules/cheque/mod_chequereceipt_mint.php +++ b/htdocs/core/modules/cheque/mod_chequereceipt_mint.php @@ -48,9 +48,10 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts /** * Return description of numbering module * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -72,9 +73,10 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts * 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 + * @param Object $object Object we need next value for + * @return boolean false if conflict, true if ok */ - public function canBeActivated() + public function canBeActivated($object) { global $conf, $langs, $db; diff --git a/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php b/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php index 5534bf38698..25100994aeb 100644 --- a/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php +++ b/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php @@ -48,9 +48,10 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts /** * Returns the description of the numbering model * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $conf, $langs, $db; @@ -75,7 +76,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts $texte .= ''.$langs->trans("Mask").':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= ' '; + $texte .= ' '; $texte .= ''; diff --git a/htdocs/core/modules/cheque/modules_chequereceipts.php b/htdocs/core/modules/cheque/modules_chequereceipts.php index 45e18a12734..b367361a60e 100644 --- a/htdocs/core/modules/cheque/modules_chequereceipts.php +++ b/htdocs/core/modules/cheque/modules_chequereceipts.php @@ -27,102 +27,16 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Requis car utilise dans les classes qui heritent /** - * \class ModeleNumRefChequeReceipts - * \brief Cheque Receipts numbering references mother class + * Class parent for cheque Receipts numbering references mother class */ -abstract class ModeleNumRefChequeReceipts +abstract class ModeleNumRefChequeReceipts extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Return the default description of numbering module - * - * @return string Descriptive text - */ - public function info() - { - global $langs; - $langs->load("bills"); - return $langs->trans("NoDescription"); - } - - /** - * Return numbering example - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("bills"); - return $langs->trans("NoExample"); - } - - /** - * 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() - { - return true; - } - - /** - * Returns the next value - * - * @param Societe $objsoc Object thirdparty - * @param Object $object Object we need next value for - * @return string Valeur - */ - public function getNextValue($objsoc, $object) - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Returns the module numbering version - * - * @return string Value - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } - if ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } - if ($this->version == 'dolibarr') { - return DOL_VERSION; - } - if ($this->version) { - return $this->version; - } - return $langs->trans("NotAvailable"); - } + // No overload code } /** diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index e8d7abfe0d7..476f649c5fb 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -40,12 +40,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; */ class doc_generic_order_odt extends ModelePDFCommandes { - /** - * Issuer - * @var Societe - */ - public $emetteur; - /** * Dolibarr version of the loaded document * @var string @@ -143,17 +137,18 @@ class doc_generic_order_odt extends ModelePDFCommandes } } $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp .= '

    '.$langs->trans("ExampleOfDirectoriesForModelGen").''; // Add list of substitution keys $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); $texte .= '
    '; $texte .= ''; $texte .= '
    '; - $texte .= ''; + $texte .= ''; $texte .= '
    '; // Scan directories @@ -185,16 +180,11 @@ class doc_generic_order_odt extends ModelePDFCommandes } $texte .= ' '; $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= '
    '; $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte .= ''; - $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 3f1a62c1b2b..adb695487d9 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -78,47 +78,6 @@ class pdf_einstein extends ModelePDFCommandes */ public $version = 'dolibarr'; - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - /** - * Issuer - * @var Societe Object that emits - */ - public $emetteur; - /** * Constructor diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index f6f9cf79bfa..eb1f9c29f84 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -78,47 +78,6 @@ class pdf_eratosthene extends ModelePDFCommandes */ public $version = 'dolibarr'; - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - /** - * Issuer - * @var Societe Object that emits - */ - public $emetteur; - /** * @var array of document table columns */ @@ -203,11 +162,13 @@ class pdf_eratosthene extends ModelePDFCommandes // phpcs:enable global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines; + dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null')); + if (!is_object($outputlangs)) { $outputlangs = $langs; } // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!empty($conf->global->MAIN_USE_FPDF)) { + if (getDolGlobalInt('MAIN_USE_FPDF')) { $outputlangs->charset_output = 'ISO-8859-1'; } @@ -221,23 +182,23 @@ class pdf_eratosthene extends ModelePDFCommandes global $outputlangsbis; $outputlangsbis = null; - if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { + if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) { $outputlangsbis = new Translate('', $conf); - $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); + $outputlangsbis->setDefaultLang(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')); $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries")); } - $nblines = count($object->lines); + $nblines = (is_array($object->lines) ? count($object->lines) : 0); $hidetop = 0; - if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) { - $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE; + if (getDolGlobalString('MAIN_PDF_DISABLE_COL_HEAD_TITLE')) { + $hidetop = getDolGlobalString('MAIN_PDF_DISABLE_COL_HEAD_TITLE'); } // Loop on each lines to detect if there is at least one image to show $realpatharray = array(); $this->atleastonephoto = false; - if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE)) { + if (getDolGlobalInt('MAIN_GENERATE_ORDERS_WITH_PICTURE')) { $objphoto = new Product($this->db); for ($i = 0; $i < $nblines; $i++) { @@ -323,8 +284,8 @@ class pdf_eratosthene extends ModelePDFCommandes global $action; $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - // Set nblines with the new command lines content after hook - $nblines = count($object->lines); + // Set nblines with the new lines content after hook + $nblines = (is_array($object->lines) ? count($object->lines) : 0); // Create pdf instance $pdf = pdf_getInstance($this->format); @@ -341,12 +302,12 @@ class pdf_eratosthene extends ModelePDFCommandes } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { + if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) { $logodir = $conf->mycompany->dir_output; if (!empty($conf->mycompany->multidir_output[$object->entity])) { $logodir = $conf->mycompany->multidir_output[$object->entity]; } - $pagecount = $pdf->setSourceFile($logodir.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); + $pagecount = $pdf->setSourceFile($logodir.'/'.getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')); $tplidx = $pdf->importPage(1); } @@ -390,6 +351,8 @@ class pdf_eratosthene extends ModelePDFCommandes $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; + $nexY = $tab_top - 1; + // Incoterm $height_incoterms = 0; if (isModEnabled('incoterm')) { @@ -410,7 +373,7 @@ class pdf_eratosthene extends ModelePDFCommandes } } - // Displays notes + // Display notes $notetoshow = empty($object->note_public) ? '' : $object->note_public; if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) { // Get first sale rep @@ -423,7 +386,6 @@ class pdf_eratosthene extends ModelePDFCommandes } } } - // Extrafields in note $extranote = $this->getExtrafieldsInHtml($object, $outputlangs); if (!empty($extranote)) { @@ -600,7 +562,7 @@ class pdf_eratosthene extends ModelePDFCommandes $curY = $tab_top_newpage; // Allows data in the first page if description is long enough to break in multiples pages - if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) { + if (getDolGlobalInt('MAIN_PDF_DATA_ON_FIRST_PAGE')) { $showpricebeforepagebreak = 1; } else { $showpricebeforepagebreak = 0; @@ -636,20 +598,18 @@ class pdf_eratosthene extends ModelePDFCommandes if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } - //if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) $this->_pagehead($pdf, $object, 0, $outputlangs); $pdf->setPage($pageposafter + 1); } } else { // We found a page break // Allows data in the first page if description is long enough to break in multiples pages - if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) { + if (getDolGlobalInt('MAIN_PDF_DATA_ON_FIRST_PAGE')) { $showpricebeforepagebreak = 1; } else { $showpricebeforepagebreak = 0; } } - } else // No pagebreak - { + } else { // No pagebreak $pdf->commitTransaction(); } $posYAfterDescription = $pdf->GetY(); @@ -761,17 +721,6 @@ class pdf_eratosthene extends ModelePDFCommandes $localtax1_type = $object->lines[$i]->localtax1_type; $localtax2_type = $object->lines[$i]->localtax2_type; - // TODO remise_percent is an obsolete field for object parent - /*if ($object->remise_percent) { - $tvaligne -= ($tvaligne * $object->remise_percent) / 100; - } - if ($object->remise_percent) { - $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100; - } - if ($object->remise_percent) { - $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100; - }*/ - $vatrate = (string) $object->lines[$i]->tva_tx; // Retrieve type from database for backward compatibility with old records @@ -814,7 +763,7 @@ class pdf_eratosthene extends ModelePDFCommandes $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); // Add line - if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { + if (getDolGlobalInt('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) { $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); @@ -827,9 +776,9 @@ class pdf_eratosthene extends ModelePDFCommandes while ($pagenb < $pageposafter) { $pdf->setPage($pagenb); if ($pagenb == $pageposbeforeprintlines) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code); + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis); } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis); } $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; @@ -844,9 +793,9 @@ class pdf_eratosthene extends ModelePDFCommandes } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == $pageposafter) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code); + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis); } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis); } $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page @@ -863,9 +812,9 @@ class pdf_eratosthene extends ModelePDFCommandes // Show square if ($pagenb == $pageposbeforeprintlines) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code); + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis); } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis); } $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; @@ -875,7 +824,7 @@ class pdf_eratosthene extends ModelePDFCommandes // Display total zone $posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); - // Affiche zone versements + // Display payment area /* if ($deja_regle) { @@ -883,7 +832,7 @@ class pdf_eratosthene extends ModelePDFCommandes } */ - // Pied de page + // Pagefoot $this->_pagefoot($pdf, $object, $outputlangs); if (method_exists($pdf, 'AliasNbPages')) { $pdf->AliasNbPages(); @@ -1409,7 +1358,7 @@ class pdf_eratosthene extends ModelePDFCommandes if (empty($hidetop)) { $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); - if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) { + if (getDolGlobalInt('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) { $titre .= ' - '.$outputlangsbis->transnoentities("AmountInCurrency", $outputlangsbis->transnoentitiesnoconv("Currency".$currency)); } @@ -1417,7 +1366,7 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; - if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { + if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); } } @@ -1447,7 +1396,7 @@ class pdf_eratosthene extends ModelePDFCommandes * @param Translate $outputlangs Object lang for output * @param Translate $outputlangsbis Object lang for output bis * @param string $titlekey Translation key to show as title of document - * @return int Return topshift value + * @return float|int Return topshift value */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null, $titlekey = "PdfOrderTitle") { @@ -1505,7 +1454,7 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $title = $outputlangs->transnoentities($titlekey); - if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) { + if (getDolGlobalInt('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) { $title .= ' - '; $title .= $outputlangsbis->transnoentities($titlekey); } @@ -1541,7 +1490,7 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65), '', 'R'); } - if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { + if (getDolGlobalInt('PDF_SHOW_PROJECT_TITLE')) { $object->fetch_projet(); if (!empty($object->project->ref)) { $posy += 3; @@ -1551,7 +1500,7 @@ class pdf_eratosthene extends ModelePDFCommandes } } - if (!empty($conf->global->PDF_SHOW_PROJECT)) { + if (getDolGlobalInt('PDF_SHOW_PROJECT')) { $object->fetch_projet(); if (!empty($object->project->ref)) { $outputlangs->load("projects"); @@ -1567,7 +1516,7 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $title = $outputlangs->transnoentities("OrderDate"); - if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) { + if (getDolGlobalInt('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) { $title .= ' - '.$outputlangsbis->transnoentities("DateInvoice"); } $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R'); @@ -1580,7 +1529,7 @@ class pdf_eratosthene extends ModelePDFCommandes } // Get contact - if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) { + if (getDolGlobalInt('DOC_SHOW_FIRST_SALES_REP')) { $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { $usertmp = new User($this->db); @@ -1622,15 +1571,15 @@ class pdf_eratosthene extends ModelePDFCommandes $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender - $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; + $posy = getDolGlobalInt('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42; $posy += $top_shift; $posx = $this->marge_gauche; - if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { + if (getDolGlobalInt('MAIN_INVERT_SENDER_RECIPIENT')) { $posx = $this->page_largeur - $this->marge_droite - 80; } - $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; - $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; + $hautcadre = getDolGlobalInt('MAIN_PDF_USE_ISO_LOCATION') ? 38 : 40; + $widthrecbox = getDolGlobalInt('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82; // Show sender frame @@ -1667,26 +1616,28 @@ class pdf_eratosthene extends ModelePDFCommandes } //Recipient name - if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { + if ($usecontact && $object->contact->socid != $object->thirdparty->id && getDolGlobalInt('MAIN_USE_COMPANY_NAME_OF_CONTACT')) { $thirdparty = $object->contact; } else { $thirdparty = $object->thirdparty; } - $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); + if (is_object($thirdparty)) { + $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); + } $mode = 'target'; $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object); // Show recipient - $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; + $widthrecbox = getDolGlobalInt('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100; if ($this->page_largeur < 210) { $widthrecbox = 84; // To work with US executive format } - $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; + $posy = getDolGlobalInt('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42; $posy += $top_shift; $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; - if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { + if (getDolGlobalInt('MAIN_INVERT_SENDER_RECIPIENT')) { $posx = $this->marge_gauche; } @@ -1802,7 +1753,7 @@ class pdf_eratosthene extends ModelePDFCommandes $rank = $rank + 10; $this->cols['photo'] = array( 'rank' => $rank, - 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm + 'width' => (!getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH') ? 20 : getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH')), // in mm 'status' => false, 'title' => array( 'textkey' => 'Photo', @@ -1814,7 +1765,7 @@ class pdf_eratosthene extends ModelePDFCommandes 'border-left' => false, // remove left line separator ); - if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE) && !empty($this->atleastonephoto)) { + if (getDolGlobalInt('MAIN_GENERATE_ORDERS_WITH_PICTURE') && !empty($this->atleastonephoto)) { $this->cols['photo']['status'] = true; } @@ -1829,7 +1780,7 @@ class pdf_eratosthene extends ModelePDFCommandes 'border-left' => true, // add left line separator ); - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) { + if (!getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) { $this->cols['vat']['status'] = true; } @@ -1898,7 +1849,7 @@ class pdf_eratosthene extends ModelePDFCommandes $this->cols['totalexcltax'] = array( 'rank' => $rank, 'width' => 26, // in mm - 'status' => empty($conf->global->PDF_PROPAL_HIDE_PRICE_EXCL_TAX) ? true : false, + 'status' => empty($conf->global->PDF_ORDER_HIDE_PRICE_EXCL_TAX) ? true : false, 'title' => array( 'textkey' => 'TotalHTShort' ), @@ -1909,7 +1860,7 @@ class pdf_eratosthene extends ModelePDFCommandes $this->cols['totalincltax'] = array( 'rank' => $rank, 'width' => 26, // in mm - 'status' => empty($conf->global->PDF_PROPAL_SHOW_PRICE_INCL_TAX) ? false : true, + 'status' => empty($conf->global->PDF_ORDER_SHOW_PRICE_INCL_TAX) ? false : true, 'title' => array( 'textkey' => 'TotalTTCShort' ), diff --git a/htdocs/core/modules/commande/mod_commande_marbre.php b/htdocs/core/modules/commande/mod_commande_marbre.php index 71a41d0b3c4..ddb1b689ddb 100644 --- a/htdocs/core/modules/commande/mod_commande_marbre.php +++ b/htdocs/core/modules/commande/mod_commande_marbre.php @@ -63,9 +63,10 @@ class mod_commande_marbre extends ModeleNumRefCommandes /** * Return description of numbering module * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -87,9 +88,10 @@ class mod_commande_marbre extends ModeleNumRefCommandes * 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 + * @param Object $object Object we need next value for + * @return boolean false if conflict, true if ok */ - public function canBeActivated() + public function canBeActivated($object) { global $conf, $langs, $db; diff --git a/htdocs/core/modules/commande/mod_commande_saphir.php b/htdocs/core/modules/commande/mod_commande_saphir.php index b62124f7652..65c48a657cc 100644 --- a/htdocs/core/modules/commande/mod_commande_saphir.php +++ b/htdocs/core/modules/commande/mod_commande_saphir.php @@ -54,11 +54,12 @@ class mod_commande_saphir extends ModeleNumRefCommandes /** * Returns the description of the numbering model * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { - global $conf, $langs, $db; + global $langs, $db; $langs->load("bills"); @@ -81,7 +82,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes $texte .= ''.$langs->trans("Mask").':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; diff --git a/htdocs/core/modules/commande/modules_commande.php b/htdocs/core/modules/commande/modules_commande.php index 839be6c9627..4d438407a76 100644 --- a/htdocs/core/modules/commande/modules_commande.php +++ b/htdocs/core/modules/commande/modules_commande.php @@ -30,6 +30,7 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; @@ -83,93 +84,7 @@ abstract class ModelePDFCommandes extends CommonDocGenerator /** * Parent class to manage numbering of Sale Orders */ -abstract class ModeleNumRefCommandes +abstract class ModeleNumRefCommandes extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Returns the default description of the numbering pattern - * - * @return string Descriptive text - */ - public function info() - { - global $langs; - $langs->load("orders"); - return $langs->trans("NoDescription"); - } - - /** - * Renvoie un exemple de numerotation - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("orders"); - return $langs->trans("NoExample"); - } - - /** - * 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() - { - return true; - } - - /** - * Returns next assigned value - * - * @param Societe $objsoc Object thirdparty - * @param Object $object Object we need next value for - * @return string Valeur - */ - public function getNextValue($objsoc, $object) - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Returns version of numbering module - * - * @return string Valeur - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } - if ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } - if ($this->version == 'dolibarr') { - return DOL_VERSION; - } - if ($this->version) { - return $this->version; - } - return $langs->trans("NotAvailable"); - } + // No overload code } diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index 515109c4f20..f1d10c1ce6b 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -38,12 +38,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; */ class doc_generic_contract_odt extends ModelePDFContract { - /** - * Issuer - * @var Societe - */ - public $emetteur; - /** * @var string Dolibarr version of the loaded document */ @@ -140,17 +134,18 @@ class doc_generic_contract_odt extends ModelePDFContract } } $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp .= '

    '.$langs->trans("ExampleOfDirectoriesForModelGen").''; // Add list of substitution keys $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); $texte .= '
    '; $texte .= ''; $texte .= '
    '; - $texte .= ''; + $texte .= ''; $texte .= '
    '; // Scan directories @@ -182,16 +177,11 @@ class doc_generic_contract_odt extends ModelePDFContract } $texte .= ' '; $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= '
    '; $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte .= ''; - $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index fe6f77b9b9a..2709278b7b1 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -76,47 +76,6 @@ class pdf_strato extends ModelePDFContract */ public $version = 'dolibarr'; - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - /** - * Issuer - * @var Societe Object that emits - */ - public $emetteur; - /** * Recipient * @var Societe diff --git a/htdocs/core/modules/contract/mod_contract_magre.php b/htdocs/core/modules/contract/mod_contract_magre.php index e88d2c46b32..4a3f97e7214 100644 --- a/htdocs/core/modules/contract/mod_contract_magre.php +++ b/htdocs/core/modules/contract/mod_contract_magre.php @@ -61,11 +61,12 @@ class mod_contract_magre extends ModelNumRefContracts /** * Return default description of numbering model * - * @return string text description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { - global $conf, $langs, $db; + global $langs, $db; $langs->load("bills"); @@ -86,7 +87,7 @@ class mod_contract_magre extends ModelNumRefContracts $texte .= ''.$langs->trans("Mask").':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; $texte .= ''; $texte .= ''; @@ -101,7 +102,7 @@ class mod_contract_magre extends ModelNumRefContracts */ public function getExample() { - global $conf, $langs, $mysoc; + global $langs, $mysoc; $old_code_client = $mysoc->code_client; $mysoc->code_client = 'CCCCCCCCCC'; @@ -123,7 +124,7 @@ class mod_contract_magre extends ModelNumRefContracts */ public function getNextValue($objsoc, $contract) { - global $db, $conf; + global $db; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/core/modules/contract/mod_contract_olive.php b/htdocs/core/modules/contract/mod_contract_olive.php index 9d9551bfa96..2737899a65c 100644 --- a/htdocs/core/modules/contract/mod_contract_olive.php +++ b/htdocs/core/modules/contract/mod_contract_olive.php @@ -67,9 +67,10 @@ class mod_contract_olive extends ModelNumRefContracts /** * Return description of module * - * @return string Description of module + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; @@ -77,6 +78,16 @@ class mod_contract_olive extends ModelNumRefContracts return $langs->trans("LeopardNumRefModelDesc"); } + /** + * Return numbering example + * + * @return string Example + */ + public function getExample() + { + return ''; + } + /** * Return an example of result returned by getNextValue * @@ -86,7 +97,6 @@ class mod_contract_olive extends ModelNumRefContracts */ public function getNextValue($objsoc, $contract) { - global $langs; return ''; } @@ -111,9 +121,9 @@ class mod_contract_olive extends ModelNumRefContracts $result = 0; $code = strtoupper(trim($code)); - if (empty($code) && $this->code_null && empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED)) { + if (empty($code) && $this->code_null && empty($conf->global->MAIN_CONTRACT_CODE_ALWAYS_REQUIRED)) { $result = 0; - } elseif (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED))) { + } elseif (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_CONTRACT_CODE_ALWAYS_REQUIRED))) { $result = -2; } diff --git a/htdocs/core/modules/contract/mod_contract_serpis.php b/htdocs/core/modules/contract/mod_contract_serpis.php index 6bc09464dba..37b357ddc63 100644 --- a/htdocs/core/modules/contract/mod_contract_serpis.php +++ b/htdocs/core/modules/contract/mod_contract_serpis.php @@ -62,9 +62,10 @@ class mod_contract_serpis extends ModelNumRefContracts /** * Return default description of numbering model * - * @return string text description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -85,9 +86,10 @@ class mod_contract_serpis extends ModelNumRefContracts /** * Test if existing numbers make problems with numbering * - * @return boolean false if conflit, true if ok + * @param Object $object Object we need next value for + * @return boolean false if conflict, true if ok */ - public function canBeActivated() + public function canBeActivated($object) { global $conf, $langs, $db; diff --git a/htdocs/core/modules/contract/modules_contract.php b/htdocs/core/modules/contract/modules_contract.php index 577ec4be5d9..818e9519198 100644 --- a/htdocs/core/modules/contract/modules_contract.php +++ b/htdocs/core/modules/contract/modules_contract.php @@ -29,7 +29,8 @@ * \brief File with parent class for generating contracts to PDF and File of class to manage contract numbering */ - require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; /** @@ -37,12 +38,6 @@ */ abstract class ModelePDFContract extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules @@ -68,92 +63,7 @@ abstract class ModelePDFContract extends CommonDocGenerator /** * Parent class for all contract numbering modules */ -class ModelNumRefContracts +class ModelNumRefContracts extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Return default description of numbering model - * - * @return string text description - */ - public function info() - { - global $langs; - $langs->load("contracts"); - return $langs->trans("NoDescription"); - } - - /** - * Return numbering example - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("contracts"); - return $langs->trans("NoExample"); - } - - /** - * Test if existing numbers make problems with numbering - * - * @return boolean false if conflict, true if ok - */ - public function canBeActivated() - { - return true; - } - - /** - * Return next value - * - * @param Societe $objsoc third party object - * @param Object $contract contract object - * @return string Value - */ - public function getNextValue($objsoc, $contract) - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Return numbering version module - * - * @return string Value - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } - if ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } - if ($this->version == 'dolibarr') { - return DOL_VERSION; - } - if ($this->version) { - return $this->version; - } - return $langs->trans("NotAvailable"); - } + // No overload code } diff --git a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php index fc55f6fe0f3..03b40ecfeec 100644 --- a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php @@ -70,46 +70,6 @@ class pdf_storm extends ModelePDFDeliveryOrder */ public $version = 'dolibarr'; - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - /** - * Issuer - * @var Societe Object that emits - */ - public $emetteur; /** * Constructor @@ -118,7 +78,7 @@ class pdf_storm extends ModelePDFDeliveryOrder */ public function __construct($db) { - global $conf, $langs, $mysoc; + global $langs, $mysoc; // Translations $langs->loadLangs(array("main", "bills", "sendings", "companies")); @@ -147,13 +107,6 @@ class pdf_storm extends ModelePDFDeliveryOrder if (empty($this->emetteur->country_code)) { $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined } - - $this->tva = array(); - $this->tva_array = array(); - $this->localtax1 = array(); - $this->localtax2 = array(); - $this->atleastoneratenotnull = 0; - $this->atleastonediscount = 0; } diff --git a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php index 31c46438992..0fcf8381438 100644 --- a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php @@ -69,46 +69,10 @@ class pdf_typhon extends ModelePDFDeliveryOrder */ public $version = 'dolibarr'; - /** - * @var int page_largeur - */ - public $page_largeur; + public $posxcomm; // For customer comment column + public $posxweightvol; // For weight or volume + public $posxremainingqty; - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - /** - * Issuer - * @var Societe Object that emits - */ - public $emetteur; /** * Constructor @@ -149,7 +113,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder // Define position of columns $this->posxdesc = $this->marge_gauche + 1; - $this->posxcomm = 112; + $this->posxcomm = 112; // customer comment //$this->posxtva=112; //$this->posxup=126; $this->posxqty = 165; @@ -164,13 +128,6 @@ class pdf_typhon extends ModelePDFDeliveryOrder //$this->posxdiscount-=20; //$this->postotalht-=20; } - - $this->tva = array(); - $this->tva_array = array(); - $this->localtax1 = array(); - $this->localtax2 = array(); - $this->atleastoneratenotnull = 0; - $this->atleastonediscount = 0; } diff --git a/htdocs/core/modules/delivery/mod_delivery_jade.php b/htdocs/core/modules/delivery/mod_delivery_jade.php index d348957afd3..1d5b7edda29 100644 --- a/htdocs/core/modules/delivery/mod_delivery_jade.php +++ b/htdocs/core/modules/delivery/mod_delivery_jade.php @@ -63,9 +63,10 @@ class mod_delivery_jade extends ModeleNumRefDeliveryOrder /** * Returns the description of the numbering model * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -85,9 +86,10 @@ class mod_delivery_jade extends ModeleNumRefDeliveryOrder * 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 + * @param Object $object Object we need next value for + * @return boolean false if conflict, true if ok */ - public function canBeActivated() + public function canBeActivated($object) { global $langs, $conf, $db; diff --git a/htdocs/core/modules/delivery/mod_delivery_saphir.php b/htdocs/core/modules/delivery/mod_delivery_saphir.php index 89cdafa9fe7..d25df47624d 100644 --- a/htdocs/core/modules/delivery/mod_delivery_saphir.php +++ b/htdocs/core/modules/delivery/mod_delivery_saphir.php @@ -58,11 +58,12 @@ class mod_delivery_saphir extends ModeleNumRefDeliveryOrder /** * Returns the description of the numbering model * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { - global $conf, $langs, $db; + global $langs, $db; $langs->load("bills"); @@ -85,7 +86,7 @@ class mod_delivery_saphir extends ModeleNumRefDeliveryOrder $texte .= ''.$langs->trans("Mask").':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; diff --git a/htdocs/core/modules/delivery/modules_delivery.php b/htdocs/core/modules/delivery/modules_delivery.php index 9f7b6805f73..eab3918dace 100644 --- a/htdocs/core/modules/delivery/modules_delivery.php +++ b/htdocs/core/modules/delivery/modules_delivery.php @@ -29,6 +29,7 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; /** @@ -36,11 +37,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; */ abstract class ModelePDFDeliveryOrder extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules @@ -63,96 +59,10 @@ abstract class ModelePDFDeliveryOrder extends CommonDocGenerator } - /** - * \class ModeleNumRefDeliveryOrder - * \brief Classe mere des modeles de numerotation des references de bon de livraison + * Classe mere des modeles de numerotation des references de bon de livraison */ -abstract class ModeleNumRefDeliveryOrder +abstract class ModeleNumRefDeliveryOrder extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Returns the default description of the numbering pattern - * - * @return string Descriptive text - */ - public function info() - { - global $langs; - $langs->load("deliveries"); - return $langs->trans("NoDescription"); - } - - /** - * Return an example of numbering - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("deliveries"); - return $langs->trans("NoExample"); - } - - /** - * 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() - { - return true; - } - - /** - * Renvoi prochaine valeur attribuee - * - * @param Societe $objsoc Object third party - * @param Object $object Object delivery - * @return string Valeur - */ - public function getNextValue($objsoc, $object) - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Renvoi version du module numerotation - * - * @return string Valeur - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } elseif ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } elseif ($this->version == 'dolibarr') { - return DOL_VERSION; - } elseif ($this->version) { - return $this->version; - } else { - return $langs->trans("NotAvailable"); - } - } + // No overload code } diff --git a/htdocs/core/modules/dons/modules_don.php b/htdocs/core/modules/dons/modules_don.php index ca982c61a53..a6c9d4f3e65 100644 --- a/htdocs/core/modules/dons/modules_don.php +++ b/htdocs/core/modules/dons/modules_don.php @@ -25,6 +25,7 @@ * \brief File of class to manage donation document generation */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; @@ -34,11 +35,6 @@ require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; */ abstract class ModeleDon extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules @@ -64,91 +60,7 @@ abstract class ModeleDon extends CommonDocGenerator /** * Parent class of donation numbering templates */ -abstract class ModeleNumRefDons +abstract class ModeleNumRefDons extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Returns the default description of the numbering pattern - * - * @return string Descriptive text - */ - public function info() - { - global $langs; - $langs->load("bills"); - return $langs->trans("NoDescription"); - } - - /** - * Return an example of numbering - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("bills"); - return $langs->trans("NoExample"); - } - - /** - * 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() - { - return true; - } - - /** - * Renvoi prochaine valeur attribuee - * - * @return string Valeur - */ - public function getNextValue() - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Renvoi version du module numerotation - * - * @return string Valeur - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } - if ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } - if ($this->version == 'dolibarr') { - return DOL_VERSION; - } - if ($this->version) { - return $this->version; - } - return $langs->trans("NotAvailable"); - } + // No overload code } diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php index 219c0f47029..80ba1439342 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -40,12 +40,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; */ class doc_generic_shipment_odt extends ModelePdfExpedition { - /** - * Issuer - * @var Societe - */ - public $emetteur; - /** * Dolibarr version of the loaded document * @var string @@ -143,17 +137,18 @@ class doc_generic_shipment_odt extends ModelePdfExpedition } } $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp .= '

    '.$langs->trans("ExampleOfDirectoriesForModelGen").''; // Add list of substitution keys $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); $texte .= '
    '; $texte .= ''; $texte .= '
    '; - $texte .= ''; + $texte .= ''; $texte .= '
    '; // Scan directories @@ -184,15 +179,10 @@ class doc_generic_shipment_odt extends ModelePdfExpedition } $texte .= ' '; $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= '
    '; $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte .= ''; - $texte .= ''; $texte .= ''; $texte .= ''; @@ -461,6 +451,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition // Replace tags of object + external modules $tmparray = array_merge($tmparray, $this->get_substitutionarray_shipment($object, $outputlangs)); + $tmparray = array_merge($tmparray, $this->get_substitutionarray_other($outputlangs)); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook @@ -494,7 +485,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition } if ($foundtagforlines) { foreach ($object->lines as $line) { - $tmparray = $this->get_substitutionarray_shipment_lines($line, $outputlangs); + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); 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); diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 297013ed8ac..668666b24d3 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2018-2020 Frédéric France + * Copyright (C) 2023 Charlene Benke * * 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 @@ -67,47 +68,6 @@ class pdf_espadon extends ModelePdfExpedition */ public $version = 'dolibarr'; - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - /** - * Issuer - * @var Societe object that emits - */ - public $emetteur; - /** * Constructor @@ -116,7 +76,7 @@ class pdf_espadon extends ModelePdfExpedition */ public function __construct(DoliDB $db) { - global $conf, $langs, $mysoc; + global $langs, $mysoc; $this->db = $db; $this->name = "espadon"; @@ -1325,7 +1285,7 @@ class pdf_espadon extends ModelePdfExpedition $this->cols['subprice'] = array( 'rank' => $rank, 'width' => 19, // in mm - 'status' => !empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT) ? 1 : 0, + 'status' => !empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT) ? 1 : 0, 'title' => array( 'textkey' => 'PriceUHT' ), @@ -1336,7 +1296,7 @@ class pdf_espadon extends ModelePdfExpedition $this->cols['totalexcltax'] = array( 'rank' => $rank, 'width' => 26, // in mm - 'status' => !empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT) ? 1 : 0, + 'status' => !empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT) ? 1 : 0, 'title' => array( 'textkey' => 'TotalHT' ), diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index 1d8e0c3f19e..7dfa66c3bf7 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -68,47 +68,6 @@ class pdf_merou extends ModelePdfExpedition */ public $version = 'dolibarr'; - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - /** - * Issuer - * @var Societe - */ - public $emetteur; - /** * Constructor @@ -117,7 +76,7 @@ class pdf_merou extends ModelePdfExpedition */ public function __construct(DoliDB $db) { - global $conf, $langs, $mysoc; + global $langs, $mysoc; $this->db = $db; $this->name = "merou"; diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 11635c6511b..477c1280a49 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -3,7 +3,7 @@ * Copyright (C) 2005-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014-2015 Marcos García - * Copyright (C) 2018-2020 Frédéric France + * Copyright (C) 2018-2023 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -68,46 +68,9 @@ class pdf_rouget extends ModelePdfExpedition */ public $version = 'dolibarr'; - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - /** - * Issuer - * @var Societe object that emits - */ - public $emetteur; + public $posxweightvol; + public $posxqtytoship; + public $posxqtyordered; /** diff --git a/htdocs/core/modules/expedition/mod_expedition_ribera.php b/htdocs/core/modules/expedition/mod_expedition_ribera.php index aae32f0f459..a90fc7c6653 100644 --- a/htdocs/core/modules/expedition/mod_expedition_ribera.php +++ b/htdocs/core/modules/expedition/mod_expedition_ribera.php @@ -56,11 +56,12 @@ class mod_expedition_ribera extends ModelNumRefExpedition /** * Return default description of numbering model * - * @return string text description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { - global $conf, $langs, $db; + global $langs, $db; $langs->load("bills"); @@ -81,7 +82,7 @@ class mod_expedition_ribera extends ModelNumRefExpedition $texte .= ''.$langs->trans("Mask").':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/expedition/mod_expedition_safor.php b/htdocs/core/modules/expedition/mod_expedition_safor.php index aa1628e7482..29c9299fb73 100644 --- a/htdocs/core/modules/expedition/mod_expedition_safor.php +++ b/htdocs/core/modules/expedition/mod_expedition_safor.php @@ -57,9 +57,10 @@ class mod_expedition_safor extends ModelNumRefExpedition /** * Return default description of numbering model * - * @return string text description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -80,9 +81,10 @@ class mod_expedition_safor extends ModelNumRefExpedition /** * Test if existing numbers make problems with numbering * - * @return boolean false if conflit, true if ok + * @param Object $object Object we need next value for + * @return boolean false if conflict, true if ok */ - public function canBeActivated() + public function canBeActivated($object) { global $conf, $langs, $db; @@ -142,7 +144,7 @@ class mod_expedition_safor extends ModelNumRefExpedition return -1; } - $date = time(); + $date = $shipment->date_creation; $yymm = strftime("%y%m", $date); if ($max >= (pow(10, 4) - 1)) { diff --git a/htdocs/core/modules/expedition/modules_expedition.php b/htdocs/core/modules/expedition/modules_expedition.php index 5c638e71425..249a2bc46e3 100644 --- a/htdocs/core/modules/expedition/modules_expedition.php +++ b/htdocs/core/modules/expedition/modules_expedition.php @@ -29,19 +29,16 @@ * \brief File that contains parent class for sending receipts models * and parent class for sending receipts numbering models */ - require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; + +require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; + /** * Parent class of sending receipts models */ abstract class ModelePdfExpedition extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation models @@ -67,94 +64,7 @@ abstract class ModelePdfExpedition extends CommonDocGenerator /** * Parent Class of numbering models of sending receipts references */ -abstract class ModelNumRefExpedition +abstract class ModelNumRefExpedition extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - public $version; - - - /** Return if a model can be used or not - * - * @return boolean true if model can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Return default description of numbering model - * - * @return string text description - */ - public function info() - { - global $langs; - $langs->load("sendings"); - return $langs->trans("NoDescription"); - } - - /** - * Returns numbering example - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("sendings"); - return $langs->trans("NoExample"); - } - - /** - * Test if existing numbers make problems with numbering - * - * @return boolean false if conflict, true if ok - */ - public function canBeActivated() - { - return true; - } - - /** - * Returns next value assigned - * - * @param Societe $objsoc Third party object - * @param Object $shipment Shipment object - * @return string Value - */ - public function getNextValue($objsoc, $shipment) - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Returns version of the numbering model - * - * @return string Value - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } - if ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } - if ($this->version == 'dolibarr') { - return DOL_VERSION; - } - if ($this->version) { - return $this->version; - } - return $langs->trans("NotAvailable"); - } + // No overload code } diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index ec409109d2d..c2d4799f75a 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -75,12 +75,6 @@ class pdf_standard extends ModeleExpenseReport */ public $version = 'dolibarr'; - /** - * Issuer - * @var Societe - */ - public $emetteur; - public $posxpiece; public $posxcomment; public $posxtva; diff --git a/htdocs/core/modules/expensereport/mod_expensereport_jade.php b/htdocs/core/modules/expensereport/mod_expensereport_jade.php index b25ac15345b..1a5e05a03fa 100644 --- a/htdocs/core/modules/expensereport/mod_expensereport_jade.php +++ b/htdocs/core/modules/expensereport/mod_expensereport_jade.php @@ -57,9 +57,10 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport /** * Return description of numbering model * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -81,9 +82,10 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport * 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 + * @param Object $object Object we need next value for + * @return boolean false if conflict, true if ok */ - public function canBeActivated() + public function canBeActivated($object) { global $conf, $langs, $db; diff --git a/htdocs/core/modules/expensereport/mod_expensereport_sand.php b/htdocs/core/modules/expensereport/mod_expensereport_sand.php index 920861f2b3e..b0aa791e228 100644 --- a/htdocs/core/modules/expensereport/mod_expensereport_sand.php +++ b/htdocs/core/modules/expensereport/mod_expensereport_sand.php @@ -57,9 +57,10 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport /** * Returns the description of the numbering model * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $db, $conf, $langs; @@ -85,7 +86,7 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport $mask = empty($conf->global->EXPENSEREPORT_SAND_MASK) ? '' : $conf->global->EXPENSEREPORT_SAND_MASK; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; diff --git a/htdocs/core/modules/expensereport/modules_expensereport.php b/htdocs/core/modules/expensereport/modules_expensereport.php index e3e8f6f67d3..b7222eb725c 100644 --- a/htdocs/core/modules/expensereport/modules_expensereport.php +++ b/htdocs/core/modules/expensereport/modules_expensereport.php @@ -16,6 +16,7 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; /** @@ -23,47 +24,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; */ abstract class ModeleExpenseReport extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active models generation @@ -104,96 +64,9 @@ function expensereport_pdf_create(DoliDB $db, ExpenseReport $object, $message, $ } /** - * \class ModeleNumRefExpenseReport - * \brief Parent class for numbering masks of expense reports + * Parent class for numbering masks of expense reports */ - -abstract class ModeleNumRefExpenseReport +abstract class ModeleNumRefExpenseReport extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - public $version; - - - /** - * Return if a model can be used or not - * - * @return boolean true if model can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Returns the default description of the numbering model - * - * @return string Descriptive text - */ - public function info() - { - global $langs; - $langs->load("orders"); - return $langs->trans("NoDescription"); - } - - /** - * Returns an example of numbering - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("trips"); - return $langs->trans("NoExample"); - } - - /** - * Test whether the numbers already in force in the base do not cause conflicts that would prevent this numbering working. - * - * @return boolean false if conflict, true if ok - */ - public function canBeActivated() - { - return true; - } - - /** - * Returns next assigned value - * - * @param Object $object Object we need next value for - * @return string Value - */ - public function getNextValue($object) - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Returns the version of the numbering module - * - * @return string Value - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } elseif ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } elseif ($this->version == 'dolibarr') { - return DOL_VERSION; - } elseif ($this->version) { - return $this->version; - } else { - return $langs->trans("NotAvailable"); - } - } + // No overload code } diff --git a/htdocs/core/modules/export/export_excel2007.modules.php b/htdocs/core/modules/export/export_excel2007.modules.php index ea7480cf15c..2d04c63d175 100644 --- a/htdocs/core/modules/export/export_excel2007.modules.php +++ b/htdocs/core/modules/export/export_excel2007.modules.php @@ -361,7 +361,10 @@ class ExportExcel2007 extends ModeleExports $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd h:mm:ss'); } else { if ($typefield == 'Text' || $typefield == 'TextAuto') { - $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row + 1, (string) $newvalue); + // If $newvalue start with an equal sign we don't want it to be interpreted as a formula, so we add a '. Such transformation should be + // done by SetCellValueByColumnAndRow but it is not, so we do it ourself. + $newvalue = (dol_substr($newvalue, 0, 1) === '=' ? '\'' : '') . $newvalue; + $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row + 1, $newvalue); $coord = $this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row + 1)->getCoordinate(); $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('@'); $this->workbook->getActiveSheet()->getStyle($coord)->getAlignment()->setHorizontal(PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT); diff --git a/htdocs/core/modules/export/export_tsv.modules.php b/htdocs/core/modules/export/export_tsv.modules.php index 40ee75a1749..956639f0135 100644 --- a/htdocs/core/modules/export/export_tsv.modules.php +++ b/htdocs/core/modules/export/export_tsv.modules.php @@ -230,7 +230,7 @@ class ExportTsv extends ModeleExports * Output record line into file * * @param array $array_selected_sorted Array with list of field to export - * @param resource $objp A record from a fetch with all fields from select + * @param Resource $objp A record from a fetch with all fields from select * @param Translate $outputlangs Object lang to translate values * @param array $array_types Array with types of fields * @return int <0 if KO, >0 if OK diff --git a/htdocs/core/modules/export/exportcsv.class.php b/htdocs/core/modules/export/exportcsv.class.php index 674bbe71a9c..0e8c0a602ba 100644 --- a/htdocs/core/modules/export/exportcsv.class.php +++ b/htdocs/core/modules/export/exportcsv.class.php @@ -213,7 +213,7 @@ class ExportCsv extends ModeleExports * Output record line into file * * @param array $array_selected_sorted Array with list of field to export - * @param resource $objp A record from a fetch with all fields from select + * @param Resource $objp A record from a fetch with all fields from select * @param Translate $outputlangs Object lang to translate values * @param array $array_types Array with types of fields * @return int <0 if KO, >0 if OK diff --git a/htdocs/core/modules/export/modules_export.php b/htdocs/core/modules/export/modules_export.php index dc96e526130..c55fa7d2a61 100644 --- a/htdocs/core/modules/export/modules_export.php +++ b/htdocs/core/modules/export/modules_export.php @@ -37,12 +37,43 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac public $driverlabel = array(); + public $driverdesc = array(); + public $driverversion = array(); public $liblabel = array(); public $libversion = array(); + /** + * @var string picto + */ + public $picto; + + /** + * @var string description + */ + public $desc; + + /** + * @var string escape + */ + public $escape; + + /** + * @var string enclosure + */ + public $enclosure; + + /** + * @var int col + */ + public $col; + + /** + * @var int disabled + */ + public $disabled; /** * Load into memory list of available export format @@ -76,6 +107,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac require_once $file; if (class_exists($classname)) { $module = new $classname($db); + // var_dump($classname); // Picto $this->picto[$module->id] = $module->picto; diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index b74934d96a4..679548c3d72 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -39,12 +39,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; */ class doc_generic_invoice_odt extends ModelePDFFactures { - /** - * Issuer - * @var Societe Object that emits - */ - public $emetteur; - /** * Dolibarr version of the loaded document * @var string @@ -59,7 +53,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures */ public function __construct($db) { - global $conf, $langs, $mysoc; + global $langs, $mysoc; // Load translation files required by the page $langs->loadLangs(array("main", "companies")); @@ -142,17 +136,18 @@ class doc_generic_invoice_odt extends ModelePDFFactures } } $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp .= '

    '.$langs->trans("ExampleOfDirectoriesForModelGen").''; // Add list of substitution keys $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); $texte .= '
    '; $texte .= ''; $texte .= '
    '; - $texte .= ''; + $texte .= ''; $texte .= '
    '; // Scan directories @@ -183,15 +178,10 @@ class doc_generic_invoice_odt extends ModelePDFFactures } $texte .= ' '; $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= '
    '; $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte .= ''; - $texte .= ''; $texte .= ''; $texte .= ''; @@ -339,6 +329,34 @@ class doc_generic_invoice_odt extends ModelePDFFactures } } + // and determine category of operation + $categoryOfOperation = 0; + $nbProduct = 0; + $nbService = 0; + foreach ($object->lines as $line) { + // determine category of operation + if ($categoryOfOperation < 2) { + $lineProductType = $line->product_type; + if ($lineProductType == Product::TYPE_PRODUCT) { + $nbProduct++; + } elseif ($lineProductType == Product::TYPE_SERVICE) { + $nbService++; + } + if ($nbProduct > 0 && $nbService > 0) { + // mixed products and services + $categoryOfOperation = 2; + } + } + } + + // determine category of operation + if ($categoryOfOperation <= 0) { + // only services + if ($nbProduct == 0 && $nbService > 0) { + $categoryOfOperation = 1; + } + } + // Make substitution $substitutionarray = array( '__FROM_NAME__' => $this->emetteur->name, @@ -412,6 +430,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures // TODO Search all tags {object_...:xxxx} into template then loop on this found tags to analyze them and the the corresponding // property of object and use the xxxx to know how to format it. // Before that, we hard code this substitution as if we have found them into the template. + $tmparray['object_PREVIOUS_MONTH'] = dol_print_date(dol_time_plus_duree($object->date, -1, 'm'), '%m'); $tmparray['object_MONTH'] = dol_print_date($object->date, '%m'); $tmparray['object_NEXT_MONTH'] = dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%m'); @@ -421,6 +440,8 @@ class doc_generic_invoice_odt extends ModelePDFFactures $tmparray['object_PREVIOUS_YEAR'] = dol_print_date(dol_time_plus_duree($object->date, -1, 'y'), '%Y'); $tmparray['object_YEAR'] = dol_print_date($object->date, '%Y'); $tmparray['object_NEXT_YEAR'] = dol_print_date(dol_time_plus_duree($object->date, 1, 'y'), '%Y'); + $tmparray['object_productorservice_operation'] = $outputlangs->transnoentities("MentionCategoryOfOperations" . $categoryOfOperation); + // Call the ODTSubstitution hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 262571c2270..5e3b3b24a7c 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -75,47 +75,6 @@ class pdf_crabe extends ModelePDFFactures */ public $version = 'dolibarr'; - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - /** - * Issuer - * @var Societe Object that emits - */ - public $emetteur; - /** * @var bool Situation invoice type */ diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 8d283756653..7a7d76cac3c 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -76,42 +76,6 @@ class pdf_sponge extends ModelePDFFactures */ public $version = 'dolibarr'; - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - /** * @var int heightforinfotot */ @@ -137,12 +101,6 @@ class pdf_sponge extends ModelePDFFactures */ public $tab_top_newpage; - /** - * Issuer - * @var Societe Object that emits - */ - public $emetteur; - /** * @var bool Situation invoice type */ diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index 91f60af5ad0..fe801d59ef2 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -72,9 +72,10 @@ class mod_facture_mars extends ModeleNumRefFactures /** * Returns the description of the numbering model * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; $langs->load("bills"); @@ -95,9 +96,10 @@ class mod_facture_mars extends ModeleNumRefFactures * 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 + * @param Object $object Object we need next value for + * @return boolean false if conflict, true if ok */ - public function canBeActivated() + public function canBeActivated($object) { global $langs, $conf, $db; diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php index 27d84246a2d..fb00fd6246f 100644 --- a/htdocs/core/modules/facture/mod_facture_mercure.php +++ b/htdocs/core/modules/facture/mod_facture_mercure.php @@ -49,9 +49,10 @@ class mod_facture_mercure extends ModeleNumRefFactures /** * Returns the description of the numbering model * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $db, $langs; @@ -79,7 +80,7 @@ class mod_facture_mercure extends ModeleNumRefFactures $texte .= ''.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").'):'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; @@ -111,7 +112,7 @@ class mod_facture_mercure extends ModeleNumRefFactures */ public function getExample() { - global $conf, $langs, $mysoc; + global $mysoc; $old_code_client = $mysoc->code_client; $old_code_type = $mysoc->typent_code; diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php index 0e6ce61093b..67a0d0d6662 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -88,9 +88,10 @@ class mod_facture_terre extends ModeleNumRefFactures /** * Returns the description of the numbering model * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; $langs->load("bills"); @@ -111,9 +112,10 @@ class mod_facture_terre extends ModeleNumRefFactures * 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 + * @param Object $object Object we need next value for + * @return boolean false if conflict, true if ok */ - public function canBeActivated() + public function canBeActivated($object) { global $langs, $conf, $db; diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php index 8467868cd4a..d57d604f11c 100644 --- a/htdocs/core/modules/facture/modules_facture.php +++ b/htdocs/core/modules/facture/modules_facture.php @@ -28,6 +28,7 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Required because used in classes that inherit @@ -39,11 +40,6 @@ use Sprain\SwissQrBill; */ abstract class ModelePDFFactures extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - public $posxpicture; public $posxtva; public $posxup; @@ -61,6 +57,7 @@ abstract class ModelePDFFactures extends CommonDocGenerator public $atleastonediscount = 0; public $atleastoneratenotnull = 0; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules @@ -251,95 +248,7 @@ abstract class ModelePDFFactures extends CommonDocGenerator /** * Parent class of invoice reference numbering templates */ -abstract class ModeleNumRefFactures +abstract class ModeleNumRefFactures extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - public $version; - - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Returns the default description of the numbering pattern - * - * @return string Descriptive text - */ - public function info() - { - global $langs; - $langs->load("bills"); - return $langs->trans("NoDescription"); - } - - /** - * Return an example of numbering - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("bills"); - return $langs->trans("NoExample"); - } - - /** - * 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() - { - return true; - } - - /** - * Renvoi prochaine valeur attribuee - * - * @param Societe $objsoc Objet societe - * @param Facture $invoice Objet facture - * @param string $mode 'next' for next value or 'last' for last value - * @return string Value - */ - public function getNextValue($objsoc, $invoice, $mode = 'next') - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Renvoi version du modele de numerotation - * - * @return string Valeur - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } elseif ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } elseif ($this->version == 'dolibarr') { - return DOL_VERSION; - } elseif ($this->version) { - return $this->version; - } else { - return $langs->trans("NotAvailable"); - } - } + // No overload code } diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index d42f85cb3cf..f6b0ed7ea9b 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -70,46 +70,6 @@ class pdf_soleil extends ModelePDFFicheinter */ public $version = 'dolibarr'; - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - /** - * Issuer - * @var Societe Object that emits - */ - public $emetteur; /** * Constructor @@ -118,7 +78,7 @@ class pdf_soleil extends ModelePDFFicheinter */ public function __construct($db) { - global $conf, $langs, $mysoc; + global $langs, $mysoc; $this->db = $db; $this->name = 'soleil'; diff --git a/htdocs/core/modules/fichinter/mod_arctic.php b/htdocs/core/modules/fichinter/mod_arctic.php index d1f313e1bd5..8f014e68111 100644 --- a/htdocs/core/modules/fichinter/mod_arctic.php +++ b/htdocs/core/modules/fichinter/mod_arctic.php @@ -59,11 +59,12 @@ class mod_arctic extends ModeleNumRefFicheinter /** * Returns the description of the numbering model * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { - global $db, $conf, $langs; + global $db, $langs; $langs->load("bills"); @@ -86,7 +87,7 @@ class mod_arctic extends ModeleNumRefFicheinter $texte .= ''.$langs->trans("Mask").':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; diff --git a/htdocs/core/modules/fichinter/mod_pacific.php b/htdocs/core/modules/fichinter/mod_pacific.php index b2ffe3a7e98..85411d143b9 100644 --- a/htdocs/core/modules/fichinter/mod_pacific.php +++ b/htdocs/core/modules/fichinter/mod_pacific.php @@ -59,9 +59,10 @@ class mod_pacific extends ModeleNumRefFicheinter /** * Return description of numbering module * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -81,9 +82,10 @@ class mod_pacific extends ModeleNumRefFicheinter * 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 + * @param Object $object Object we need next value for + * @return boolean false if conflict, true if ok */ - public function canBeActivated() + public function canBeActivated($object) { global $langs, $conf, $db; diff --git a/htdocs/core/modules/fichinter/modules_fichinter.php b/htdocs/core/modules/fichinter/modules_fichinter.php index 8cf126fc4af..ba39c364c1d 100644 --- a/htdocs/core/modules/fichinter/modules_fichinter.php +++ b/htdocs/core/modules/fichinter/modules_fichinter.php @@ -27,6 +27,7 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; /** @@ -34,12 +35,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; */ abstract class ModelePDFFicheinter extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules @@ -65,96 +60,9 @@ abstract class ModelePDFFicheinter extends CommonDocGenerator /** * Parent class numbering models of intervention sheet references */ -abstract class ModeleNumRefFicheinter +abstract class ModeleNumRefFicheinter extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - public $version; - - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Returns the default description of the numbering template - * - * @return string Descriptive text - */ - public function info() - { - global $langs; - $langs->load("ficheinter"); - return $langs->trans("NoDescription"); - } - - /** - * Return a numbering example - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("ficheinter"); - return $langs->trans("NoExample"); - } - - /** - * 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() - { - return true; - } - - /** - * Return the next assigned value - * - * @param Societe $objsoc Object thirdparty - * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO - */ - public function getNextValue($objsoc = 0, $object = '') - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Return the version of the numbering module - * - * @return string Value - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } elseif ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } elseif ($this->version == 'dolibarr') { - return DOL_VERSION; - } elseif ($this->version) { - return $this->version; - } else { - return $langs->trans("NotAvailable"); - } - } + // No overload code } @@ -174,7 +82,7 @@ abstract class ModeleNumRefFicheinter function fichinter_create($db, $object, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $conf, $langs, $user; + global $conf, $langs; $langs->load("ficheinter"); $error = 0; diff --git a/htdocs/core/modules/holiday/mod_holiday_immaculate.php b/htdocs/core/modules/holiday/mod_holiday_immaculate.php index ce780a0ba58..954f33d8f2a 100644 --- a/htdocs/core/modules/holiday/mod_holiday_immaculate.php +++ b/htdocs/core/modules/holiday/mod_holiday_immaculate.php @@ -61,11 +61,12 @@ class mod_holiday_immaculate extends ModelNumRefHolidays /** * Return default description of numbering model * - * @return string text description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { - global $db, $conf, $langs; + global $db, $langs; $langs->load("bills"); @@ -86,7 +87,7 @@ class mod_holiday_immaculate extends ModelNumRefHolidays $texte .= ''.$langs->trans("Mask").':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/holiday/mod_holiday_madonna.php b/htdocs/core/modules/holiday/mod_holiday_madonna.php index fd2271198bc..110e27b755e 100644 --- a/htdocs/core/modules/holiday/mod_holiday_madonna.php +++ b/htdocs/core/modules/holiday/mod_holiday_madonna.php @@ -63,9 +63,10 @@ class mod_holiday_madonna extends ModelNumRefHolidays /** * Return default description of numbering model * - * @return string text description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -86,9 +87,10 @@ class mod_holiday_madonna extends ModelNumRefHolidays /** * Test if existing numbers make problems with numbering * - * @return boolean false if conflit, true if ok + * @param Object $object Object we need next value for + * @return boolean false if conflict, true if ok */ - public function canBeActivated() + public function canBeActivated($object) { global $conf, $langs, $db; diff --git a/htdocs/core/modules/holiday/modules_holiday.php b/htdocs/core/modules/holiday/modules_holiday.php index e38801a052e..ef57eff7aa4 100644 --- a/htdocs/core/modules/holiday/modules_holiday.php +++ b/htdocs/core/modules/holiday/modules_holiday.php @@ -30,7 +30,8 @@ * \brief File with parent class for generating holiday to PDF and File of class to manage contract numbering */ - require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; /** @@ -38,12 +39,6 @@ */ abstract class ModelePDFHoliday extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules @@ -69,90 +64,7 @@ abstract class ModelePDFHoliday extends CommonDocGenerator /** * Parent class for all holidays numbering modules */ -class ModelNumRefHolidays +class ModelNumRefHolidays extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Return default description of numbering model - * - * @return string text description - */ - public function info() - { - global $langs; - $langs->load("holiday"); - return $langs->trans("NoDescription"); - } - - /** - * Return numbering example - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("holiday"); - return $langs->trans("NoExample"); - } - - /** - * Test if existing numbers make problems with numbering - * - * @return boolean false if conflict, true if ok - */ - public function canBeActivated() - { - return true; - } - - /** - * Return next value - * - * @param Societe $objsoc third party object - * @param Object $holiday Holiday object - * @return string Value if OK, 0 if KO - */ - public function getNextValue($objsoc, $holiday) - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Return numbering version module - * - * @return string Value - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } elseif ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } elseif ($this->version == 'dolibarr') { - return DOL_VERSION; - } elseif ($this->version) { - return $this->version; - } else { - return $langs->trans("NotAvailable"); - } - } + // No overload code } diff --git a/htdocs/core/modules/hrm/mod_evaluation_advanced.php b/htdocs/core/modules/hrm/mod_evaluation_advanced.php index 7369032e165..71fb0024d93 100644 --- a/htdocs/core/modules/hrm/mod_evaluation_advanced.php +++ b/htdocs/core/modules/hrm/mod_evaluation_advanced.php @@ -54,11 +54,12 @@ class mod_evaluation_advanced extends ModeleNumRefEvaluation /** * Returns the description of the numbering model * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { - global $conf, $langs, $db; + global $langs, $db; $langs->load("bills"); @@ -81,7 +82,7 @@ class mod_evaluation_advanced extends ModeleNumRefEvaluation $texte .= ''.$langs->trans("Mask").':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; diff --git a/htdocs/core/modules/hrm/mod_evaluation_standard.php b/htdocs/core/modules/hrm/mod_evaluation_standard.php index b6b517b8fb9..17fab7a3bc0 100644 --- a/htdocs/core/modules/hrm/mod_evaluation_standard.php +++ b/htdocs/core/modules/hrm/mod_evaluation_standard.php @@ -52,9 +52,10 @@ class mod_evaluation_standard extends ModeleNumRefEvaluation /** * Return description of numbering module * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); diff --git a/htdocs/core/modules/hrm/modules_evaluation.php b/htdocs/core/modules/hrm/modules_evaluation.php index adde109f60b..1e10efcd599 100644 --- a/htdocs/core/modules/hrm/modules_evaluation.php +++ b/htdocs/core/modules/hrm/modules_evaluation.php @@ -29,6 +29,7 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit @@ -37,7 +38,6 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // requir */ abstract class ModelePDFEvaluation extends CommonDocGenerator { - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules @@ -64,96 +64,7 @@ abstract class ModelePDFEvaluation extends CommonDocGenerator /** * Parent class to manage numbering of Evaluation */ -abstract class ModeleNumRefEvaluation +abstract class ModeleNumRefEvaluation extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - public $version; - - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Returns the default description of the numbering template - * - * @return string Descriptive text - */ - public function info() - { - global $langs; - $langs->load("hrm"); - return $langs->trans("NoDescription"); - } - - /** - * Returns an example of numbering - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("hrm"); - return $langs->trans("NoExample"); - } - - /** - * Checks if the numbers already in the database do not - * cause conflicts that would prevent this numbering working. - * - * @param Object $object Object we need next value for - * @return boolean false if conflict, true if ok - */ - public function canBeActivated($object) - { - return true; - } - - /** - * Returns next assigned value - * - * @param Object $object Object we need next value for - * @return string Valeur - */ - public function getNextValue($object) - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Returns version of numbering module - * - * @return string Valeur - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } - if ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } - if ($this->version == 'dolibarr') { - return DOL_VERSION; - } - if ($this->version) { - return $this->version; - } - return $langs->trans("NotAvailable"); - } + // No overload code } diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 29cd8ca5a21..70371759c26 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -38,18 +38,6 @@ class ImportCsv extends ModeleImports */ public $db; - public $datatoimport; - - /** - * @var string Error code (or message) - */ - public $error = ''; - - /** - * @var string[] Error codes (or messages) - */ - public $errors = array(); - /** * @var string Code of driver */ diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index c05fabc5968..2cc901bdda1 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -42,18 +42,6 @@ class ImportXlsx extends ModeleImports */ public $db; - public $datatoimport; - - /** - * @var string Error code (or message) - */ - public $error = ''; - - /** - * @var string[] Error codes (or messages) - */ - public $errors = array(); - /** * @var string Code of driver */ diff --git a/htdocs/core/modules/import/modules_import.php b/htdocs/core/modules/import/modules_import.php index 5b665c8e2cf..8e24e1e3093 100644 --- a/htdocs/core/modules/import/modules_import.php +++ b/htdocs/core/modules/import/modules_import.php @@ -42,6 +42,16 @@ class ModeleImports */ public $error = ''; + /** + * @var string[] Error codes (or messages) + */ + public $errors = array(); + + /** + * @var string[] warnings codes (or messages) + */ + public $warnings = array(); + /** * @var string Code of driver */ @@ -75,8 +85,35 @@ class ModeleImports public $libversion = array(); + /** + * @var string charset + */ public $charset; + /** + * @var string picto + */ + public $picto; + + /** + * @var string description + */ + public $desc; + + /** + * @var string escape + */ + public $escape; + + /** + * @var string enclosure + */ + public $enclosure; + + /** + * @var Societe thirdparty + */ + public $thirdpartyobject; /** * @var array Element mapping from table name diff --git a/htdocs/core/modules/mailings/advthirdparties.modules.php b/htdocs/core/modules/mailings/advthirdparties.modules.php index 111943e99e0..7a40e1cdbda 100644 --- a/htdocs/core/modules/mailings/advthirdparties.modules.php +++ b/htdocs/core/modules/mailings/advthirdparties.modules.php @@ -37,11 +37,6 @@ class mailing_advthirdparties extends MailingTargets */ public $picto = 'company'; - /** - * @var DoliDB Database handler. - */ - public $db; - public $enabled = 'isModEnabled("societe")'; diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index 772c9900573..8452dacce1e 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -45,11 +45,6 @@ class mailing_contacts1 extends MailingTargets */ public $picto = 'contact'; - /** - * @var DoliDB Database handler. - */ - public $db; - /** * Constructor diff --git a/htdocs/core/modules/mailings/eventorganization.modules.php b/htdocs/core/modules/mailings/eventorganization.modules.php index 2a8e06693b9..73eea96f8c5 100644 --- a/htdocs/core/modules/mailings/eventorganization.modules.php +++ b/htdocs/core/modules/mailings/eventorganization.modules.php @@ -39,11 +39,6 @@ class mailing_eventorganization extends MailingTargets */ public $picto = 'conferenceorbooth'; - /** - * @var DoliDB Database handler. - */ - public $db; - public $enabled = 'isModEnabled("eventorganization")'; diff --git a/htdocs/core/modules/mailings/fraise.modules.php b/htdocs/core/modules/mailings/fraise.modules.php index 2096aeff135..aa8f0f5859a 100644 --- a/htdocs/core/modules/mailings/fraise.modules.php +++ b/htdocs/core/modules/mailings/fraise.modules.php @@ -48,10 +48,6 @@ class mailing_fraise extends MailingTargets */ public $picto = 'user'; - /** - * @var DoliDB Database handler. - */ - public $db; /** * Constructor diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index 28c9e6cc034..632e228ad69 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -32,30 +32,45 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; class MailingTargets // This can't be abstract as it is used for some method { /** - * @var DoliDB Database handler. + * @var DoliDb Database handler (result of a new DoliDB) */ public $db; + /** + * @var string Error code (or message) + */ + public $error = ''; + + /** + * @var array of errors + */ + public $errors; + /** * @var string Condition to be enabled */ public $enabled; /** - * @var string Error code (or message) + * @var string Name of the module */ - public $error = ''; + public $name; + /** + * @var string Description of the module + */ + public $desc; + + /** + * @var string Tooltip to show after description of the module + */ public $tooltip = ''; /** - * @var string The SQL string used to find the recipients + * @var string To store the SQL string used to find the recipients */ public $sql; - public $desc; - - public $name; public $evenunsubscribe = 0; // Set this to 1 if you want to flag you also want to include email in target that has opt-out. diff --git a/htdocs/core/modules/mailings/partnership.modules.php b/htdocs/core/modules/mailings/partnership.modules.php index 3e947b6ed93..48fabd3b0fe 100644 --- a/htdocs/core/modules/mailings/partnership.modules.php +++ b/htdocs/core/modules/mailings/partnership.modules.php @@ -39,11 +39,6 @@ class mailing_partnership extends MailingTargets */ public $picto = 'partnership'; - /** - * @var DoliDB Database handler. - */ - public $db; - public $enabled = 'isModEnabled("partnership")'; @@ -86,6 +81,9 @@ class mailing_partnership extends MailingTargets if (GETPOST('filter', 'int') > 0) { $sql .= " AND pt.rowid=".((int) GETPOST('filter', 'int')); } + if (GETPOSTISSET('filter_status_partnership') && GETPOSTINT('filter_status_partnership') >= 0) { + $sql .= " AND p.status = ".GETPOSTINT('filter_status_partnership'); + } if (empty($this->evenunsubscribe)) { $sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = s.email and mu.entity = ".((int) $conf->entity).")"; } @@ -102,6 +100,9 @@ class mailing_partnership extends MailingTargets if (GETPOST('filter', 'int') > 0) { $sql .= " AND pt.rowid=".((int) GETPOST('filter', 'int')); } + if (GETPOSTISSET('filter_status_partnership') && GETPOSTINT('filter_status_partnership') >= 0) { + $sql .= " AND p.status = ".GETPOSTINT('filter_status_partnership'); + } if (empty($this->evenunsubscribe)) { $sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = s.email and mu.entity = ".((int) $conf->entity).")"; } @@ -214,13 +215,13 @@ class mailing_partnership extends MailingTargets */ public function formFilter() { - global $conf, $langs; + global $conf, $langs, $form; $langs->load("companies"); $s = ' '; + // filter_status_thirdparties + include_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php'; + $tmppartnership = new Partnership($this->db); + $dummy = $tmppartnership->getLibStatut(0); // We call this only to have $tmppartnership->labelStatus loaded + + $s .= $form->selectarray('filter_status_partnership', $tmppartnership->labelStatus, GETPOST('filter_status_partnership'), $langs->trans("Status")); + return $s; } diff --git a/htdocs/core/modules/mailings/pomme.modules.php b/htdocs/core/modules/mailings/pomme.modules.php index 2d2dd7e1809..cd93813cf68 100644 --- a/htdocs/core/modules/mailings/pomme.modules.php +++ b/htdocs/core/modules/mailings/pomme.modules.php @@ -41,11 +41,6 @@ class mailing_pomme extends MailingTargets */ public $picto = 'user'; - /** - * @var DoliDB Database handler. - */ - public $db; - /** * Constructor diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php index e678dab33ed..16194db6862 100644 --- a/htdocs/core/modules/mailings/thirdparties.modules.php +++ b/htdocs/core/modules/mailings/thirdparties.modules.php @@ -38,11 +38,6 @@ class mailing_thirdparties extends MailingTargets */ public $picto = 'company'; - /** - * @var DoliDB Database handler. - */ - public $db; - /** * Constructor diff --git a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php index 6c6812759d7..0cf133df273 100644 --- a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php +++ b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php @@ -36,11 +36,6 @@ class mailing_thirdparties_services_expired extends MailingTargets */ public $picto = 'company'; - /** - * @var DoliDB Database handler. - */ - public $db; - public $arrayofproducts = array(); diff --git a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php index 2076e156bac..9823db229c1 100644 --- a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php +++ b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php @@ -36,11 +36,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; */ class doc_generic_member_odt extends ModelePDFMember { - /** - * @var Societe Issuer - */ - public $emetteur; - /** * Dolibarr version of the loaded document * @var string @@ -101,7 +96,7 @@ class doc_generic_member_odt extends ModelePDFMember */ public function info($langs) { - global $conf, $langs; + global $langs; // Load translation files required by the page $langs->loadLangs(array('companies', 'errors')); @@ -138,17 +133,18 @@ class doc_generic_member_odt extends ModelePDFMember } } $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp .= '

    '.$langs->trans("ExampleOfDirectoriesForModelGen").''; // Add list of substitution keys $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); $texte .= '
    '; $texte .= ''; $texte .= '
    '; - $texte .= ''; + $texte .= ''; $texte .= '
    '; // Scan directories @@ -173,15 +169,10 @@ class doc_generic_member_odt extends ModelePDFMember } $texte .= ' '; $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= ''; $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte .= ''; - $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/member/mod_member_advanced.php b/htdocs/core/modules/member/mod_member_advanced.php index d33b3d405e3..221b55fa24e 100644 --- a/htdocs/core/modules/member/mod_member_advanced.php +++ b/htdocs/core/modules/member/mod_member_advanced.php @@ -62,9 +62,10 @@ class mod_member_advanced extends ModeleNumRefMembers /** * Return description of numbering module * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("AdvancedNumRefModelDesc", $this->prefix); @@ -86,9 +87,10 @@ class mod_member_advanced extends ModeleNumRefMembers * 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 + * @param Object $object Object we need next value for + * @return boolean false if conflict, true if ok */ - public function canBeActivated() + public function canBeActivated($object) { global $conf, $langs, $db; diff --git a/htdocs/core/modules/member/mod_member_simple.php b/htdocs/core/modules/member/mod_member_simple.php index 92f374cd01d..bc52459f79c 100644 --- a/htdocs/core/modules/member/mod_member_simple.php +++ b/htdocs/core/modules/member/mod_member_simple.php @@ -62,9 +62,10 @@ class mod_member_simple extends ModeleNumRefMembers /** * Return description of numbering module * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("SimpleRefNumRefModelDesc"); @@ -86,9 +87,10 @@ class mod_member_simple extends ModeleNumRefMembers * 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 + * @param Object $object Object we need next value for + * @return boolean false if KO (there is a conflict), true if OK */ - public function canBeActivated() + public function canBeActivated($object) { global $conf, $langs, $db; diff --git a/htdocs/core/modules/member/modules_member.class.php b/htdocs/core/modules/member/modules_member.class.php index 41fbbacf2b3..476b9d848aa 100644 --- a/htdocs/core/modules/member/modules_member.class.php +++ b/htdocs/core/modules/member/modules_member.class.php @@ -27,19 +27,15 @@ * \brief File with parent class for generating members to PDF */ - require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; + /** * Parent class to manage intervention document templates */ abstract class ModelePDFMember extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules @@ -65,9 +61,8 @@ abstract class ModelePDFMember extends CommonDocGenerator /** * Classe mere des modeles de numerotation des references de members */ -abstract class ModeleNumRefMembers +abstract class ModeleNumRefMembers extends CommonNumRefGenerator { - public $code_modifiable; // Editable code public $code_modifiable_invalide; // Modified code if it is invalid @@ -76,101 +71,6 @@ abstract class ModeleNumRefMembers public $code_null; // - /** - * @var string Error code (or message) - */ - public $error = ''; - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Returns the default description of the numbering pattern - * - * @return string Descriptive text - */ - public function info() - { - global $langs; - $langs->load("members"); - return $langs->trans("NoDescription"); - } - - /** - * Return name of module - * - * @return string Module name - */ - public function getName() - { - return $this->name; - } - - /** - * Return an example of numbering - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("members"); - return $langs->trans("NoExample"); - } - - /** - * 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() - { - return true; - } - - /** - * Renvoi prochaine valeur attribuee - * - * @param Societe $objsoc Object third party - * @param Object $object Object we need next value for - * @return string Valeur - */ - public function getNextValue($objsoc, $object) - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Renvoi version du module numerotation - * - * @return string Valeur - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } elseif ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } elseif ($this->version == 'dolibarr') { - return DOL_VERSION; - } elseif ($this->version) { - return $this->version; - } else { - return $langs->trans("NotAvailable"); - } - } /** * Return description of module parameters @@ -193,10 +93,10 @@ abstract class ModeleNumRefMembers } $s = ''; - $s .= $langs->trans("Name").': '.$this->getName().'
    '; + $s .= $langs->trans("Name").': '.$this->getName($langs).'
    '; $s .= $langs->trans("Version").': '.$this->getVersion().'
    '; $s .= $langs->trans("MemberCodeDesc").'
    '; - $s .= $langs->trans("ValidityControledByModule").': '.$this->getName().'
    '; + $s .= $langs->trans("ValidityControledByModule").': '.$this->getName($langs).'
    '; $s .= '
    '; $s .= ''.$langs->trans("ThisIsModuleRules").':
    '; diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index 43a7128b1d0..3d451bd93d6 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -214,7 +214,7 @@ class modAgenda extends DolibarrModules 'url'=>'/comm/action/index.php', 'langs'=>'agenda', 'position'=>86, - 'perms'=>'$user->rights->agenda->myactions->read || $user->rights->resource->read', + 'perms'=>'$user->hasRight("agenda", "myactions", "read") || $user->hasRight("resource", "read")', 'enabled'=>'isModEnabled("agenda") || isModEnabled("resource")', 'target'=>'', 'user'=>2, @@ -230,7 +230,7 @@ class modAgenda extends DolibarrModules 'url'=>'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda', 'langs'=>'agenda', 'position'=>100, - 'perms'=>'$user->rights->agenda->myactions->read', + 'perms'=>'$user->hasRight("agenda", "myactions", "read")', 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2, @@ -244,7 +244,7 @@ class modAgenda extends DolibarrModules 'url'=>'/comm/action/card.php?mainmenu=agenda&leftmenu=agenda&action=create', 'langs'=>'commercial', 'position'=>101, - 'perms'=>'($user->hasRight("agenda", "myactions", "create")||$user->hasRight("agenda", "allactions", "create"))', + 'perms'=>'($user->hasRight("agenda", "myactions", "create") || $user->hasRight("agenda", "allactions", "create"))', 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 @@ -259,7 +259,7 @@ class modAgenda extends DolibarrModules 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda', 'langs'=>'agenda', 'position'=>140, - 'perms'=>'$user->rights->agenda->myactions->read', + 'perms'=>'$user->hasRight("agenda", "myactions", "read")', 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 @@ -273,7 +273,7 @@ class modAgenda extends DolibarrModules 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine', 'langs'=>'agenda', 'position'=>141, - 'perms'=>'$user->rights->agenda->myactions->read', + 'perms'=>'$user->hasRight("agenda", "myactions", "read")', 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 @@ -287,7 +287,7 @@ class modAgenda extends DolibarrModules 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=done&filter=mine', 'langs'=>'agenda', 'position'=>142, - 'perms'=>'$user->rights->agenda->myactions->read', + 'perms'=>'$user->hasRight("agenda", "myactions", "read")', 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 @@ -301,8 +301,8 @@ class modAgenda extends DolibarrModules 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1', 'langs'=>'agenda', 'position'=>143, - 'perms'=>'$user->rights->agenda->allactions->read', - 'enabled'=>'$user->rights->agenda->allactions->read', + 'perms'=>'$user->hasRight("agenda", "allactions", "read")', + 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 ); @@ -315,8 +315,8 @@ class modAgenda extends DolibarrModules 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1', 'langs'=>'agenda', 'position'=>144, - 'perms'=>'$user->rights->agenda->allactions->read', - 'enabled'=>'$user->rights->agenda->allactions->read', + 'perms'=>'$user->hasRight("agenda", "allactions", "read")', + 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 ); @@ -331,7 +331,7 @@ class modAgenda extends DolibarrModules 'url'=>'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda', 'langs'=>'agenda', 'position'=>110, - 'perms'=>'$user->rights->agenda->myactions->read', + 'perms'=>'$user->hasRight("agenda", "myactions", "read")', 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 @@ -345,7 +345,7 @@ class modAgenda extends DolibarrModules 'url'=>'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine', 'langs'=>'agenda', 'position'=>111, - 'perms'=>'$user->rights->agenda->myactions->read', + 'perms'=>'$user->hasRight("agenda", "myactions", "read")', 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 @@ -359,7 +359,7 @@ class modAgenda extends DolibarrModules 'url'=>'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=done&filter=mine', 'langs'=>'agenda', 'position'=>112, - 'perms'=>'$user->rights->agenda->myactions->read', + 'perms'=>'$user->hasRight("agenda", "myactions", "read")', 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 @@ -373,8 +373,8 @@ class modAgenda extends DolibarrModules 'url'=>'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1', 'langs'=>'agenda', 'position'=>113, - 'perms'=>'$user->rights->agenda->allactions->read', - 'enabled'=>'$user->rights->agenda->allactions->read', + 'perms'=>'$user->hasRight("agenda", "allactions", "read")', + 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 ); @@ -387,8 +387,8 @@ class modAgenda extends DolibarrModules 'url'=>'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1', 'langs'=>'agenda', 'position'=>114, - 'perms'=>'$user->rights->agenda->allactions->read', - 'enabled'=>'$user->rights->agenda->allactions->read', + 'perms'=>'$user->hasRight("agenda", "allactions", "read")', + 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 ); @@ -402,7 +402,7 @@ class modAgenda extends DolibarrModules 'url'=>'/comm/action/rapport/index.php?mainmenu=agenda&leftmenu=agenda', 'langs'=>'agenda', 'position'=>160, - 'perms'=>'$user->rights->agenda->allactions->read', + 'perms'=>'$user->hasRight("agenda", "allactions", "read")', 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 @@ -417,8 +417,8 @@ class modAgenda extends DolibarrModules 'url'=>'/categories/index.php?mainmenu=agenda&leftmenu=agenda&type=10', 'langs' => 'agenda', 'position' => 170, - 'perms' => '$user->rights->agenda->allactions->read', - 'enabled' => '$conf->categorie->enabled', + 'perms' => '$user->hasRight("agenda", "allactions", "read")', + 'enabled' => 'isModEnabled("categorie")', 'target' => '', 'user' => 2 ); diff --git a/htdocs/core/modules/modApi.class.php b/htdocs/core/modules/modApi.class.php index 4ac93f87c9a..9621904ebe6 100644 --- a/htdocs/core/modules/modApi.class.php +++ b/htdocs/core/modules/modApi.class.php @@ -20,7 +20,8 @@ /** * \defgroup api Module Api - * \brief Descriptor file for Api modulee + * \brief Module for API (REST) management + * * \file htdocs/core/modules/modApi.class.php * \ingroup api * \brief Description and activation file for the module Api @@ -162,7 +163,6 @@ class modApi extends DolibarrModules 'langs'=>'modulebuilder', 'position'=>100, 'perms'=>'1', - //'enabled'=>'isModEnabled("api") && preg_match(\'/^(devtools)/\',$leftmenu)', 'enabled'=>'isModEnabled("api")', 'target'=>'_apiexplorer', 'user'=>0); diff --git a/htdocs/core/modules/modBarcode.class.php b/htdocs/core/modules/modBarcode.class.php index ef0f1b7166a..861bca9c1d2 100644 --- a/htdocs/core/modules/modBarcode.class.php +++ b/htdocs/core/modules/modBarcode.class.php @@ -82,14 +82,14 @@ class modBarcode extends DolibarrModules $this->rights[$r][0] = 301; // id de la permission $this->rights[$r][1] = 'Generate PDF sheets of barcodes'; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) - $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'read'; $r++; $this->rights[$r][0] = 304; // id de la permission $this->rights[$r][1] = 'Read barcodes'; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) - $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'lire_advance'; $r++; diff --git a/htdocs/core/modules/modBom.class.php b/htdocs/core/modules/modBom.class.php index d8c95c3c26b..c3b642626a9 100644 --- a/htdocs/core/modules/modBom.class.php +++ b/htdocs/core/modules/modBom.class.php @@ -89,8 +89,8 @@ class modBom extends DolibarrModules 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) - 'css' => array('/bom/css/bom.css.php'), // Set this to relative path of css file if module has its own css file - 'js' => array('/bom/js/bom.js.php'), // Set this to relative path of js file if module must load a js on all pages + 'css' => array('/bom/css/bom.css.php'), // Set this to relative path of css file if module has its own css file + 'js' => array('/bom/js/bom.js.php'), // Set this to relative path of js file if module must load a js on all pages 'hooks' => array('data'=>array('hookcontext1','hookcontext2'), 'entity'=>'0'), // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all' 'moduleforexternal' => 0 // Set this to 1 if feature of module are opened to external users */ diff --git a/htdocs/core/modules/modBookCal.class.php b/htdocs/core/modules/modBookCal.class.php index 935293fedc4..07237b63d45 100644 --- a/htdocs/core/modules/modBookCal.class.php +++ b/htdocs/core/modules/modBookCal.class.php @@ -135,7 +135,7 @@ class modBookCal extends DolibarrModules $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) // The language file dedicated to your module - $this->langfiles = array("bookcal@bookcal"); + $this->langfiles = array("bookcal"); // Prerequisites $this->phpmin = array(7, 0); // Minimum version of PHP required by module @@ -259,21 +259,37 @@ class modBookCal extends DolibarrModules $r = 0; // Add here entries to declare new permissions /* BEGIN MODULEBUILDER PERMISSIONS */ - $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used) - $this->rights[$r][1] = 'Read objects of BookCal'; // Permission label + $this->rights[$r][0] = $this->numero . sprintf('%02d', (0 * 10) + 1); + $this->rights[$r][1] = 'Read objects of BookCal'; $this->rights[$r][4] = 'availabilities'; - $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->bookcal->availabilities->read) + $this->rights[$r][5] = 'read'; $r++; - $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used) - $this->rights[$r][1] = 'Create/Update objects of BookCal'; // Permission label + $this->rights[$r][0] = $this->numero . sprintf('%02d', (0 * 10) + 2); + $this->rights[$r][1] = 'Create/Update objects of BookCal'; $this->rights[$r][4] = 'availabilities'; - $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->bookcal->availabilities->write) + $this->rights[$r][5] = 'write'; $r++; - $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used) - $this->rights[$r][1] = 'Delete objects of BookCal'; // Permission label + $this->rights[$r][0] = $this->numero . sprintf('%02d', (0 * 10) + 3); + $this->rights[$r][1] = 'Delete objects of BookCal'; $this->rights[$r][4] = 'availabilities'; - $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->bookcal->availabilities->delete) + $this->rights[$r][5] = 'delete'; $r++; + $this->rights[$r][0] = $this->numero . sprintf('%02d', (1 * 10) + 1); + $this->rights[$r][1] = 'Read Calendar object of BookCal'; + $this->rights[$r][4] = 'calendar'; + $this->rights[$r][5] = 'read'; + $r++; + $this->rights[$r][0] = $this->numero . sprintf('%02d', (1 * 10) + 2); + $this->rights[$r][1] = 'Create/Update Calendar object of BookCal'; + $this->rights[$r][4] = 'calendar'; + $this->rights[$r][5] = 'write'; + $r++; + $this->rights[$r][0] = $this->numero . sprintf('%02d', (1 * 10) + 3); + $this->rights[$r][1] = 'Delete Calendar object of BookCal'; + $this->rights[$r][4] = 'calendar'; + $this->rights[$r][5] = 'delete'; + $r++; + /* END MODULEBUILDER PERMISSIONS */ // Main menu entries to add @@ -281,7 +297,7 @@ class modBookCal extends DolibarrModules $r = 0; // Add here entries to declare new menus /* BEGIN MODULEBUILDER TOPMENU */ - $this->menu[$r++] = array( + /*$this->menu[$r++] = array( 'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'top', // This is a Top menu entry 'titre'=>'ModuleBookCalName', @@ -289,14 +305,73 @@ class modBookCal extends DolibarrModules 'mainmenu'=>'bookcal', 'leftmenu'=>'', 'url'=>'/bookcal/bookcalindex.php', - 'langs'=>'bookcal@bookcal', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'langs'=>'bookcal', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>1000 + $r, 'enabled'=>'$conf->bookcal->enabled', // Define condition to show or hide menu entry. Use '$conf->bookcal->enabled' if entry must be visible if module is enabled. - 'perms'=>'1', // Use 'perms'=>'$user->rights->bookcal->availabilities->read' if you want your menu with a permission rules + 'perms'=>'$user->rights->bookcal->availabilities->read', // Use 'perms'=>'$user->rights->bookcal->availabilities->read' if you want your menu with a permission rules 'target'=>'', 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both - ); + );*/ /* END MODULEBUILDER TOPMENU */ + + /* BEGIN MODULEBUILDER LEFTMENU CALENDAR */ + $this->menu[$r++] = array( + 'fk_menu'=>'fk_mainmenu=agenda', + 'type'=>'left', + 'titre'=> 'MenuBookcalIndex', + 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth em92"'), + 'mainmenu'=>'agenda', + 'leftmenu'=> 'bookcal', + 'url'=> '/bookcal/bookcalindex.php', + 'langs'=> 'bookcal', + 'position'=> 1100+$r, + 'enabled'=> '1', + 'perms'=> '$user->rights->bookcal->calendar->read', + 'user'=> 0 + ); + + $this->menu[$r++]=array( + // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'fk_menu'=>'fk_mainmenu=agenda,fk_leftmenu=bookcal', + // This is a Left menu entry + 'type'=>'left', + 'titre'=>'Calendar', + 'mainmenu'=>'agenda', + 'leftmenu'=>'bookcal_calendar_list', + 'url'=>'/bookcal/calendar_list.php', + // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'langs'=>'bookcal', + 'position'=>1100+$r, + // Define condition to show or hide menu entry. Use '$conf->bookcal->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'enabled'=>'$conf->bookcal->enabled', + // Use 'perms'=>'$user->rights->bookcal->level1->level2' if you want your menu with a permission rules + 'perms'=>'$user->rights->bookcal->calendar->read', + 'target'=>'', + // 0=Menu for internal users, 1=external users, 2=both + 'user'=>2, + ); + $this->menu[$r++]=array( + // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'fk_menu'=>'fk_mainmenu=agenda,fk_leftmenu=bookcal_calendar_list', + // This is a Left menu entry + 'type'=>'left', + 'titre'=>'NewCalendar', + 'mainmenu'=>'agenda', + 'leftmenu'=>'bookcal_new', + 'url'=>'/bookcal/calendar_card.php?action=create', + // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'langs'=>'bookcal', + 'position'=>1100+$r, + // Define condition to show or hide menu entry. Use '$conf->bookcal->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'enabled'=>'$conf->bookcal->enabled', + // Use 'perms'=>'$user->rights->bookcal->level1->level2' if you want your menu with a permission rules + 'perms'=>'$user->rights->bookcal->calendar->read', + 'target'=>'', + // 0=Menu for internal users, 1=external users, 2=both + 'user'=>2 + ); + /* END MODULEBUILDER LEFTMENU CALENDAR */ + /* BEGIN MODULEBUILDER LEFTMENU AVAILABILITIES $this->menu[$r++]=array( 'fk_menu'=>'fk_mainmenu=bookcal', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode @@ -345,40 +420,40 @@ class modBookCal extends DolibarrModules $this->menu[$r++]=array( // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'fk_menu'=>'fk_mainmenu=bookcal', + 'fk_menu'=>'fk_mainmenu=agenda,fk_leftmenu=bookcal', // This is a Left menu entry 'type'=>'left', - 'titre'=>'List Availabilities', - 'mainmenu'=>'bookcal', + 'titre'=>'Availabilities', + 'mainmenu'=>'agenda', 'leftmenu'=>'bookcal_availabilities', 'url'=>'/bookcal/availabilities_list.php', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'langs'=>'bookcal@bookcal', - 'position'=>1100+$r, + 'langs'=>'bookcal', + 'position'=>1200+$r, // Define condition to show or hide menu entry. Use '$conf->bookcal->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 'enabled'=>'$conf->bookcal->enabled', // Use 'perms'=>'$user->rights->bookcal->level1->level2' if you want your menu with a permission rules - 'perms'=>'1', + 'perms'=>'$user->rights->bookcal->availabilities->read', 'target'=>'', // 0=Menu for internal users, 1=external users, 2=both 'user'=>2, ); $this->menu[$r++]=array( // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'fk_menu'=>'fk_mainmenu=bookcal,fk_leftmenu=bookcal_availabilities', + 'fk_menu'=>'fk_mainmenu=agenda,fk_leftmenu=bookcal_availabilities', // This is a Left menu entry 'type'=>'left', - 'titre'=>'New Availabilities', - 'mainmenu'=>'bookcal', + 'titre'=>'NewAvailabilities', + 'mainmenu'=>'agenda', 'leftmenu'=>'bookcal_availabilities', 'url'=>'/bookcal/availabilities_card.php?action=create', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'langs'=>'bookcal@bookcal', - 'position'=>1100+$r, + 'langs'=>'bookcal', + 'position'=>1200+$r, // Define condition to show or hide menu entry. Use '$conf->bookcal->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 'enabled'=>'$conf->bookcal->enabled', // Use 'perms'=>'$user->rights->bookcal->level1->level2' if you want your menu with a permission rules - 'perms'=>'1', + 'perms'=>'$user->rights->bookcal->availabilities->read', 'target'=>'', // 0=Menu for internal users, 1=external users, 2=both 'user'=>2 diff --git a/htdocs/core/modules/modComptabilite.class.php b/htdocs/core/modules/modComptabilite.class.php index be8f1954959..6c485f912f9 100644 --- a/htdocs/core/modules/modComptabilite.class.php +++ b/htdocs/core/modules/modComptabilite.class.php @@ -19,11 +19,12 @@ */ /** - * \defgroup comptabilite Module comptabilite - * \brief Module pour inclure des fonctions de comptabilite (gestion de comptes comptables et rapports) - * \file htdocs/core/modules/modComptabilite.class.php - * \ingroup comptabilite - * \brief Description and activation file for the module simple accountancy + * \defgroup comptabilite Module Comptabilite + * \brief Module to include accounting functions (account management and reporting) + * + * \file htdocs/core/modules/modComptabilite.class.php + * \ingroup comptabilite + * \brief Description and activation file for the module simple accountancy */ include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; diff --git a/htdocs/core/modules/modDebugBar.class.php b/htdocs/core/modules/modDebugBar.class.php index ae2bdcfffc8..ed76bb32672 100644 --- a/htdocs/core/modules/modDebugBar.class.php +++ b/htdocs/core/modules/modDebugBar.class.php @@ -82,7 +82,7 @@ class modDebugBar extends DolibarrModules $this->rights[1][0] = 431; // id de la permission $this->rights[1][1] = 'Use Debug Bar'; // libelle de la permission $this->rights[1][2] = 'u'; // type de la permission (deprecie a ce jour) - $this->rights[1][3] = 1; // La permission est-elle une permission par defaut + $this->rights[1][3] = 0; // La permission est-elle une permission par defaut $this->rights[1][4] = 'read'; } diff --git a/htdocs/core/modules/modDeplacement.class.php b/htdocs/core/modules/modDeplacement.class.php index 88b239917f6..6c4488dfbb7 100644 --- a/htdocs/core/modules/modDeplacement.class.php +++ b/htdocs/core/modules/modDeplacement.class.php @@ -80,7 +80,7 @@ class modDeplacement extends DolibarrModules $this->rights[1][0] = 171; $this->rights[1][1] = 'Lire ses notes de frais et deplacements et celles de sa hierarchy'; $this->rights[1][2] = 'r'; - $this->rights[1][3] = 1; + $this->rights[1][3] = 0; $this->rights[1][4] = 'lire'; $this->rights[2][0] = 172; diff --git a/htdocs/core/modules/modDon.class.php b/htdocs/core/modules/modDon.class.php index c5c790ca28c..3af26350325 100644 --- a/htdocs/core/modules/modDon.class.php +++ b/htdocs/core/modules/modDon.class.php @@ -121,7 +121,7 @@ class modDon extends DolibarrModules $this->rights[1][0] = 701; $this->rights[1][1] = 'Lire les dons'; $this->rights[1][2] = 'r'; - $this->rights[1][3] = 1; + $this->rights[1][3] = 0; $this->rights[1][4] = 'lire'; $this->rights[2][0] = 702; diff --git a/htdocs/core/modules/modDynamicPrices.class.php b/htdocs/core/modules/modDynamicPrices.class.php index 23a0f892014..bfaf11dbf4c 100644 --- a/htdocs/core/modules/modDynamicPrices.class.php +++ b/htdocs/core/modules/modDynamicPrices.class.php @@ -84,4 +84,27 @@ class modDynamicPrices extends DolibarrModules $this->rights_class = 'dynamicprices'; $r = 0; } + + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories. + * + * @param string $options Options + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + $result = $this->_load_tables('/install/mysql/', 'dynamicprices'); + if ($result < 0) { + return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default') + } + + // Remove permissions and default values + $this->remove($options); + + $sql = array(); + + return $this->_init($sql, $options); + } } diff --git a/htdocs/core/modules/modECM.class.php b/htdocs/core/modules/modECM.class.php index 719468c076b..b99e2c5b00b 100644 --- a/htdocs/core/modules/modECM.class.php +++ b/htdocs/core/modules/modECM.class.php @@ -16,11 +16,13 @@ * along with this program. If not, see . */ -/** \defgroup ecm Module ecm - * \brief Module for ECM (Electronic Content Management) - * \file htdocs/core/modules/modECM.class.php - * \ingroup ecm - * \brief Description and activation file for the module ECM +/** + * \defgroup ecm Module ECM + * \brief Module ECM (Electronic Content Management) to manage Documents + * + * \file htdocs/core/modules/modECM.class.php + * \ingroup ecm + * \brief Description and activation file for the module ECM */ include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; diff --git a/htdocs/core/modules/modEmailCollector.class.php b/htdocs/core/modules/modEmailCollector.class.php index 0a8f67016e1..cf9f0dbc5f1 100644 --- a/htdocs/core/modules/modEmailCollector.class.php +++ b/htdocs/core/modules/modEmailCollector.class.php @@ -16,8 +16,8 @@ */ /** - * \defgroup emailcollector Module emailcollector - * \brief emailcollector module descriptor. + * \defgroup emailcollector Module Emailcollector + * \brief Module to collect emails * * \file htdocs/core/modules/modEmailCollector.class.php * \ingroup emailcollector @@ -91,8 +91,6 @@ class modEmailCollector extends DolibarrModules $this->requiredby = array(); // List of module ids to disable if this one is disabled $this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->langfiles = array("admin"); - $this->phpmin = array(7, 0); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(7, 0); // Minimum version of Dolibarr required by module $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) //$this->automatic_activation = array('FR'=>'davWasAutomaticallyActivatedBecauseOfYourCountryChoice'); @@ -159,7 +157,7 @@ class modEmailCollector extends DolibarrModules // Cronjobs (List of cron jobs entries to add when module is enabled) // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week $this->cronjobs = array( - 0=>array('label'=>'Email collector', 'priority'=>50, 'jobtype'=>'method', 'class'=>'/emailcollector/class/emailcollector.class.php', 'objectname'=>'EmailCollector', 'method'=>'doCollect', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>5, 'unitfrequency'=>60, 'status'=>1, 'test'=>'$conf->emailcollector->enabled') + 0=>array('label'=>'Email collector', 'priority'=>50, 'jobtype'=>'method', 'class'=>'/emailcollector/class/emailcollector.class.php', 'objectname'=>'EmailCollector', 'method'=>'doCollect', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>5, 'unitfrequency'=>60, 'status'=>1, 'test'=>'isModEnabled("emailcollector")') ); diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php index 3b6b4e10c82..9fdef7671c3 100644 --- a/htdocs/core/modules/modExpedition.class.php +++ b/htdocs/core/modules/modExpedition.class.php @@ -20,11 +20,12 @@ */ /** - * \defgroup expedition Module shipping - * \brief Module pour gerer les expeditions de produits - * \file htdocs/core/modules/modExpedition.class.php - * \ingroup expedition - * \brief Description and activation file for the module Expedition + * \defgroup expedition Module Shipping + * \brief Module to manage product shipments + * + * \file htdocs/core/modules/modExpedition.class.php + * \ingroup expedition + * \brief Description and activation file for the module Expedition */ include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; @@ -245,7 +246,7 @@ class modExpedition extends DolibarrModules $this->export_fields_array[$r] = array( 's.rowid'=>"IdCompany", 's.nom'=>'ThirdParty', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'd.nom'=>'State', 'co.label'=>'Country', 'co.code'=>'CountryCode', 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5', - 's.idprof6'=>'ProfId6', 'c.rowid'=>"Id", 'c.ref'=>"Ref", 'c.ref_customer'=>"RefCustomer", 'c.fk_soc'=>"IdCompany", 'c.date_creation'=>"DateCreation", + 's.idprof6'=>'ProfId6', 'c.rowid'=>"Id", 'c.ref'=>"Ref", 'c.ref_customer'=>"RefCustomer", 'c.fk_soc'=>"IdCompany", 'c.date_creation'=>"DateCreation", 'c.date_valid'=>"DateValidation", 'c.date_delivery'=>"DateDeliveryPlanned", 'c.tracking_number'=>"TrackingNumber", 'c.height'=>"Height", 'c.width'=>"Width", 'c.size'=>"Depth", 'c.size_units'=>'SizeUnits', 'c.weight'=>"Weight", 'c.weight_units'=>"WeightUnits", 'c.fk_statut'=>'Status', 'c.note_public'=>"NotePublic", 'ed.rowid'=>'LineId', 'cd.description'=>'Description', 'ed.qty'=>"Qty", 'p.rowid'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel', @@ -262,7 +263,7 @@ class modExpedition extends DolibarrModules //); $this->export_TypeFields_array[$r] = array( 's.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_customer'=>"Text", 'c.date_creation'=>"Date", + 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 'c.ref'=>"Text", 'c.ref_customer'=>"Text", 'c.date_creation'=>"Date", 'c.date_valid'=>"Date", 'c.date_delivery'=>"Date", 'c.tracking_number'=>"Numeric", 'c.height'=>"Numeric", 'c.width'=>"Numeric", 'c.weight'=>"Numeric", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text", 'ed.qty'=>"Numeric", 'd.nom'=>'Text' ); @@ -270,7 +271,7 @@ class modExpedition extends DolibarrModules 's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'd.nom'=>'company', 'co.label'=>'company', 'co.code'=>'company', 's.fk_pays'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.ape'=>'company', 's.siret'=>'company', 's.idprof4'=>'company', 's.idprof5'=>'company', 's.idprof6'=>'company', 'c.rowid'=>"shipment", 'c.ref'=>"shipment", 'c.ref_customer'=>"shipment", 'c.fk_soc'=>"shipment", - 'c.date_creation'=>"shipment", 'c.date_delivery'=>"shipment", 'c.tracking_number'=>'shipment', 'c.height'=>"shipment", 'c.width'=>"shipment", + 'c.date_creation'=>"shipment", 'c.date_valid'=>"shipment", 'c.date_delivery'=>"shipment", 'c.tracking_number'=>'shipment', 'c.height'=>"shipment", 'c.width'=>"shipment", 'c.size'=>'shipment', 'c.size_units'=>'shipment', 'c.weight'=>"shipment", 'c.weight_units'=>'shipment', 'c.fk_statut'=>"shipment", 'c.note_public'=>"shipment", 'ed.rowid'=>'shipment_line', 'cd.description'=>'shipment_line', 'ed.qty'=>"shipment_line", 'p.rowid'=>'product', 'p.ref'=>'product', 'p.label'=>'product', 'p.weight'=>'product', 'p.weight_units'=>'product', 'p.volume'=>'product', 'p.volume_units'=>'product' diff --git a/htdocs/core/modules/modExpenseReport.class.php b/htdocs/core/modules/modExpenseReport.class.php index 536aabd086c..a1ab6b43026 100644 --- a/htdocs/core/modules/modExpenseReport.class.php +++ b/htdocs/core/modules/modExpenseReport.class.php @@ -245,6 +245,11 @@ class modExpenseReport extends DolibarrModules { global $conf; + $result = $this->_load_tables('/install/mysql/', 'expensereport'); + if ($result < 0) { + return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default') + } + // Remove permissions and default values $this->remove($options); diff --git a/htdocs/core/modules/modExport.class.php b/htdocs/core/modules/modExport.class.php index df996a312bf..7f36c78273b 100644 --- a/htdocs/core/modules/modExport.class.php +++ b/htdocs/core/modules/modExport.class.php @@ -17,11 +17,12 @@ */ /** - * \defgroup export Module export - * \brief Module generique pour realiser des exports de donnees en base - * \file htdocs/core/modules/modExport.class.php - * \ingroup export - * \brief Description and activation file for the module export + * \defgroup export Module Export + * \brief Module to manage data exports from Dolibarr database + * + * \file htdocs/core/modules/modExport.class.php + * \ingroup export + * \brief Description and activation file for the module export */ include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 81a8e6224cf..3127a0d76bb 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -21,10 +21,12 @@ */ /** - * \defgroup fournisseur Module suppliers - * \file htdocs/core/modules/modFournisseur.class.php - * \ingroup fournisseur - * \brief Description and activation file for the module Supplier + * \defgroup fournisseur Module suppliers + * \brief Module to manage suppliers relations and activities + * + * \file htdocs/core/modules/modFournisseur.class.php + * \ingroup fournisseur + * \brief Description and activation file for the module Supplier */ include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; diff --git a/htdocs/core/modules/modHRM.class.php b/htdocs/core/modules/modHRM.class.php index f4295f53193..cd625811860 100644 --- a/htdocs/core/modules/modHRM.class.php +++ b/htdocs/core/modules/modHRM.class.php @@ -17,10 +17,12 @@ */ /** - * \defgroup HRM Module hrm - * \file htdocs/core/modules/modHRM.class.php - * \ingroup HRM - * \brief Description and activation file for the module HRM + * \defgroup HRM Module hrm + * \brief Module for Human Resource Management (HRM) + * + * \file htdocs/core/modules/modHRM.class.php + * \ingroup HRM + * \brief Description and activation file for the module HRM */ include_once DOL_DOCUMENT_ROOT."/core/modules/DolibarrModules.class.php"; diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index 630320adaaf..ad4d135f491 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -23,7 +23,8 @@ /** * \defgroup holiday Module holiday - * \brief Module de gestion des congés + * \brief Module for leave/vacation management + * * \file htdocs/core/modules/modHoliday.class.php * \ingroup holiday * \brief Description and activation file for the module holiday diff --git a/htdocs/core/modules/modLabel.class.php b/htdocs/core/modules/modLabel.class.php index dff42653c3c..693f0764e08 100644 --- a/htdocs/core/modules/modLabel.class.php +++ b/htdocs/core/modules/modLabel.class.php @@ -78,7 +78,7 @@ class modLabel extends DolibarrModules $this->rights[1][0] = 601; // id de la permission $this->rights[1][1] = 'Read stickers'; - $this->rights[1][3] = 1; // La permission est-elle une permission par defaut + $this->rights[1][3] = 0; // La permission est-elle une permission par defaut $this->rights[1][4] = 'lire'; $this->rights[2][0] = 602; // id de la permission diff --git a/htdocs/core/modules/modLdap.class.php b/htdocs/core/modules/modLdap.class.php index 2b02a1b58c1..9eb9ce60c7b 100644 --- a/htdocs/core/modules/modLdap.class.php +++ b/htdocs/core/modules/modLdap.class.php @@ -86,6 +86,7 @@ class modLdap extends DolibarrModules 12=>array('LDAP_FIELD_FAX', 'chaine', 'facsimiletelephonenumber', '', 0), 13=>array('LDAP_FIELD_MOBILE', 'chaine', 'mobile', '', 0), 14=>array('LDAP_GROUP_FILTER', 'chaine', '&(objectClass=groupOfNames)', '', 0), + 15=>array('LDAP_USERACCOUNTCONTROL', 'int', 512, '', 0), ); // Boxes diff --git a/htdocs/core/modules/modMrp.class.php b/htdocs/core/modules/modMrp.class.php index f315a4594c4..caf221bfd83 100644 --- a/htdocs/core/modules/modMrp.class.php +++ b/htdocs/core/modules/modMrp.class.php @@ -20,7 +20,7 @@ /** * \defgroup mrp Module Mrp - * \brief Mrp module descriptor. + * \brief Module to manage Manufacturing Orders (MO) * * \file htdocs/core/modules/modMrp.class.php * \ingroup mrp diff --git a/htdocs/core/modules/modNotification.class.php b/htdocs/core/modules/modNotification.class.php index 63086fd9112..0e59169bda3 100644 --- a/htdocs/core/modules/modNotification.class.php +++ b/htdocs/core/modules/modNotification.class.php @@ -17,11 +17,12 @@ */ /** - * \defgroup notification Module email notification - * \brief Module pour gerer les notifications (par mail ou autre) - * \file htdocs/core/modules/modNotification.class.php - * \ingroup notification - * \brief Description and activation file for the module Notification + * \defgroup notification Module notification + * \brief Module for managing notifications (by e-mail or other means) + * + * \file htdocs/core/modules/modNotification.class.php + * \ingroup notification + * \brief Description and activation file for the module Notification */ include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; diff --git a/htdocs/core/modules/modPartnership.class.php b/htdocs/core/modules/modPartnership.class.php index b8aafc853fb..48244ae0455 100644 --- a/htdocs/core/modules/modPartnership.class.php +++ b/htdocs/core/modules/modPartnership.class.php @@ -253,8 +253,8 @@ class modPartnership extends DolibarrModules $datestart=dol_mktime(21, 15, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']); $this->cronjobs = array( - 0 => array('priority'=>60, 'label'=>'CancelPartnershipForExpiredMembers', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doCancelStatusOfMemberPartnership', 'parameters'=>'', 'comment'=>'Cancel status of partnership when subscription is expired + x days.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>1, 'test'=>'$conf->partnership->enabled', 'datestart'=>$datestart), - 1 => array('priority'=>61, 'label'=>'PartnershipCheckBacklink', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doWarningOfPartnershipIfDolibarrBacklinkNotfound', 'parameters'=>'', 'comment'=>'Warning of partnership if Dolibarr backlink not found on partner website.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>0, 'test'=>'$conf->partnership->enabled', 'datestart'=>$datestart), + 0 => array('priority'=>60, 'label'=>'CancelPartnershipForExpiredMembers', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doCancelStatusOfMemberPartnership', 'parameters'=>'', 'comment'=>'Cancel status of partnership when subscription is expired + x days.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>1, 'test'=>'isModEnabled("partnership")', 'datestart'=>$datestart), + 1 => array('priority'=>61, 'label'=>'PartnershipCheckBacklink', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doWarningOfPartnershipIfDolibarrBacklinkNotfound', 'parameters'=>'', 'comment'=>'Add a warning on partnership record if the backlink keyword is not found on the partner website.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>0, 'test'=>'isModEnabled("partnership")', 'datestart'=>$datestart), ); // Permissions provided by this module diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index d8192a37df4..560fd286c2b 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -68,7 +68,7 @@ class modProduct extends DolibarrModules // Dependencies $this->hidden = false; // A condition to hide module $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled - $this->requiredby = array("modStock", "modBarcode", "modProductBatch", "modVariants"); // List of module ids to disable if this one is disabled + $this->requiredby = array("modStock", "modBarcode", "modProductBatch", "modVariants", "modBom"); // List of module ids to disable if this one is disabled $this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->phpmin = array(7, 0); // Minimum version of PHP required by module @@ -356,7 +356,7 @@ class modProduct extends DolibarrModules $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile - $this->export_sql_end[$r] .= ' AND pr.date_price = (SELECT MAX(pr2.date_price) FROM '.MAIN_DB_PREFIX.'product_price as pr2 WHERE pr2.fk_product = pr.fk_product AND pr2.entity IN ('.getEntity('product').'))'; // export only latest prices not full history + $this->export_sql_end[$r] .= ' AND pr.date_price = (SELECT MAX(pr2.date_price) FROM '.MAIN_DB_PREFIX.'product_price as pr2 WHERE pr2.fk_product = pr.fk_product AND pr2.price_level = pr.price_level AND pr2.entity IN ('.getEntity('product').'))'; // export only latest prices not full history $this->export_sql_end[$r] .= ' ORDER BY p.ref, pr.price_level'; } @@ -368,6 +368,7 @@ class modProduct extends DolibarrModules $this->export_permission[$r] = array(array("produit", "export")); $this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", 's.nom'=>'ThirdParty', + 's.code_client'=>'CodeClient', 'pr.price_base_type'=>"PriceBase", 'pr.price'=>"PriceUnitPriceHT", 'pr.price_ttc'=>"PriceUnitPriceTTC", 'pr.price_min'=>"MinPriceUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceUnitPriceTTC", @@ -379,6 +380,7 @@ class modProduct extends DolibarrModules } $this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product", 'p.label'=>"Label", 's.nom'=>'company', + 's.code_client'=>'company', 'pr.price_base_type'=>"product", 'pr.price'=>"product", 'pr.price_ttc'=>"product", 'pr.price_min'=>"product", 'pr.price_min_ttc'=>"product", diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index 2461118572a..b7beb1f4d92 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -104,6 +104,13 @@ class modPropale extends DolibarrModules $this->const[$r][4] = 0; $r++; + $this->const[$r][0] = "PROPOSAL_ALLOW_ONLINESIGN"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "1"; + $this->const[$r][3] = ""; + $this->const[$r][4] = 0; + $r++; + /*$this->const[$r][0] = "PROPALE_DRAFT_WATERMARK"; $this->const[$r][2] = "__(Draft)__"; $this->const[$r][3] = 'Watermark to show on draft proposals'; diff --git a/htdocs/core/modules/modReception.class.php b/htdocs/core/modules/modReception.class.php index d6341e6279d..7a606b9c0a8 100644 --- a/htdocs/core/modules/modReception.class.php +++ b/htdocs/core/modules/modReception.class.php @@ -16,11 +16,12 @@ */ /** - * \defgroup reception Module reception - * \brief Module pour gerer les réceptions de produits - * \file htdocs/core/modules/modReception.class.php - * \ingroup reception - * \brief Description and activation file for the module Reception + * \defgroup reception Module Reception + * \brief Module to manage receptions of products + * + * \file htdocs/core/modules/modReception.class.php + * \ingroup reception + * \brief Description and activation file for the module Reception */ include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index 2d17038f43e..16da9c88def 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -235,23 +235,32 @@ class modStock extends DolibarrModules 'p.rowid'=>"ProductId", 'p.ref'=>"Ref", 'p.fk_product_type'=>"Type", 'p.label'=>"Label", 'p.description'=>"Description", 'p.note'=>"Note", 'p.price'=>"Price", 'p.tva_tx'=>'VAT', 'p.tosell'=>"OnSell", 'p.tobuy'=>'OnBuy', 'p.duration'=>"Duration", 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification', 'p.pmp'=>'PMPValue', 'p.cost_price'=>'CostPrice', - 'p.seuil_stock_alerte'=>'StockLimit', + 'p.seuil_stock_alerte'=>'StockLimit', 'p.barcode'=>'BarCode', 'bt.libelle'=>'BarcodeType', ); + if (isModEnabled('barcode')) { + $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); + } $this->export_TypeFields_array[$r] = array( 'e.rowid'=>'List:entrepot:ref::stock', 'e.ref'=>'Text', 'e.lieu'=>'Text', 'e.address'=>'Text', 'e.zip'=>'Text', 'e.town'=>'Text', 'p.rowid'=>"Numeric", 'p.ref'=>"Text", 'p.fk_product_type'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.note'=>"Text", 'p.price'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", 'p.duration'=>"Duree", 'p.datec'=>'Date', 'p.tms'=>'Date', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric', 'ps.reel'=>'Numeric', - 'p.seuil_stock_alerte'=>'Numeric', + 'p.seuil_stock_alerte'=>'Numeric', 'p.barcode'=>'Text', 'bt.libelle'=>'List:c_barcode_type:libelle', ); + if (isModEnabled('barcode')) { + $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); + } $this->export_entities_array[$r] = array( 'p.rowid'=>"product", 'p.ref'=>"product", 'p.fk_product_type'=>"product", 'p.label'=>"product", 'p.description'=>"product", 'p.note'=>"product", 'p.price'=>"product", 'p.tva_tx'=>'product', 'p.tosell'=>"product", 'p.tobuy'=>"product", 'p.duration'=>"product", 'p.datec'=>'product', 'p.tms'=>'product', 'p.pmp'=>'product', 'p.cost_price'=>'product', 'ps.reel'=>'stock', - 'p.seuil_stock_alerte'=>'product', + 'p.seuil_stock_alerte'=>'product', 'p.barcode'=>'product', 'bt.libelle'=>'c_barcode_type', ); // We define here only fields that use another icon that the one defined into export_icon + if (isModEnabled('barcode')) { + $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); + } $this->export_aggregate_array[$r] = array('ps.reel'=>'SUM'); // TODO Not used yet $this->export_dependencies_array[$r] = array('stock'=>array('p.rowid', 'e.rowid')); // We must keep this until the aggregate_array is used. To have a unique key, if we ask a field of a child, to avoid the DISTINCT to discard them. $keyforselect = 'product'; @@ -261,7 +270,10 @@ class modStock extends DolibarrModules $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('ps.reel'=>'Stock')); $this->export_sql_start[$r] = 'SELECT DISTINCT '; - $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON extra.fk_object = p.rowid, '.MAIN_DB_PREFIX.'product_stock as ps, '.MAIN_DB_PREFIX.'entrepot as e'; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON extra.fk_object = p.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_barcode_type as bt ON bt.rowid = p.fk_barcode_type'; + $this->export_sql_end[$r] .= ', '.MAIN_DB_PREFIX.'product_stock as ps, '.MAIN_DB_PREFIX.'entrepot as e'; $this->export_sql_end[$r] .= ' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid'; $this->export_sql_end[$r] .= ' AND e.entity IN ('.getEntity('stock').')'; @@ -284,6 +296,9 @@ class modStock extends DolibarrModules 'pb.rowid'=>'Id', 'pb.batch'=>'Batch', 'pb.qty'=>'Qty', 'pl.eatby'=>'EatByDate', 'pl.sellby'=>'SellByDate' ); + if (isModEnabled('barcode')) { + $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); + } $this->export_TypeFields_array[$r] = array( 'e.rowid'=>'List:entrepot:ref::stock', 'e.ref'=>'Text', 'e.lieu'=>'Text', 'e.description'=>'Text', 'e.address'=>'Text', 'e.zip'=>'Text', 'e.town'=>'Text', 'p.rowid'=>"Numeric", 'p.ref'=>"Text", 'p.fk_product_type'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.note'=>"Text", @@ -292,6 +307,9 @@ class modStock extends DolibarrModules 'pb.batch'=>'Text', 'pb.qty'=>'Numeric', 'pl.eatby'=>'Date', 'pl.sellby'=>'Date' ); + if (isModEnabled('barcode')) { + $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); + } $this->export_entities_array[$r] = array( 'p.rowid'=>"product", 'p.ref'=>"product", 'p.fk_product_type'=>"product", 'p.label'=>"product", 'p.description'=>"product", 'p.note'=>"product", 'p.price'=>"product", 'p.tva_tx'=>'product', 'p.tosell'=>"product", 'p.tobuy'=>"product", 'p.duration'=>"product", @@ -299,6 +317,9 @@ class modStock extends DolibarrModules 'pb.rowid'=>'batch', 'pb.batch'=>'batch', 'pb.qty'=>'batch', 'pl.eatby'=>'batch', 'pl.sellby'=>'batch' ); // We define here only fields that use another icon that the one defined into export_icon + if (isModEnabled('barcode')) { + $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); + } $this->export_aggregate_array[$r] = array('ps.reel'=>'SUM'); // TODO Not used yet $this->export_dependencies_array[$r] = array('stockbatch'=>array('pb.rowid'), 'batch'=>array('pb.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them. $keyforselect = 'product_lot'; @@ -329,12 +350,18 @@ class modStock extends DolibarrModules 'p.rowid'=>"ProductId", 'p.ref'=>"Ref", 'p.fk_product_type'=>"Type", 'p.label'=>"Label", 'p.description'=>"Description", 'p.note'=>"Note", 'p.price'=>"Price", 'p.tva_tx'=>'VAT', 'p.tosell'=>"OnSell", 'p.tobuy'=>'OnBuy', 'p.duration'=>"Duration", 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification' ); + if (isModEnabled('barcode')) { + $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); + } $this->export_TypeFields_array[$r] = array( 'sm.rowid'=>'Numeric', 'sm.value'=>'Numeric', 'sm.datem'=>'Date', 'sm.batch'=>'Text', 'sm.label'=>'Text', 'sm.inventorycode'=>'Text', 'e.rowid'=>'List:entrepot:ref::stock', 'e.ref'=>'Text', 'e.description'=>'Text', 'e.lieu'=>'Text', 'e.address'=>'Text', 'e.zip'=>'Text', 'e.town'=>'Text', 'p.rowid'=>"Numeric", 'p.ref'=>"Text", 'p.fk_product_type'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.note'=>"Text", 'p.price'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", 'p.duration'=>"Duree", 'p.datec'=>'Date', 'p.tms'=>'Date' ); + if (isModEnabled('barcode')) { + $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); + } $this->export_entities_array[$r] = array( 'e.rowid'=>'warehouse', 'e.ref'=>'warehouse', 'e.description'=>'warehouse', 'e.lieu'=>'warehouse', 'e.address'=>'warehouse', 'e.zip'=>'warehouse', 'e.town'=>'warehouse', 'p.rowid'=>"product", 'p.ref'=>"product", 'p.fk_product_type'=>"product", 'p.label'=>"product", 'p.description'=>"product", 'p.note'=>"product", @@ -345,6 +372,9 @@ class modStock extends DolibarrModules $this->export_TypeFields_array[$r]['sm.batch'] = 'Text'; $this->export_entities_array[$r]['sm.batch'] = 'movement'; } + if (isModEnabled('barcode')) { + $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); + } $this->export_aggregate_array[$r] = array('sm.value'=>'SUM'); // TODO Not used yet $this->export_dependencies_array[$r] = array('movement'=>array('sm.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them. diff --git a/htdocs/core/modules/modSyslog.class.php b/htdocs/core/modules/modSyslog.class.php index 0fa0da9dcdb..8a2cbf68bab 100644 --- a/htdocs/core/modules/modSyslog.class.php +++ b/htdocs/core/modules/modSyslog.class.php @@ -17,11 +17,12 @@ */ /** - * \defgroup syslog Module syslog - * \brief Module pour gerer les messages d'erreur dans syslog - * \file htdocs/core/modules/modSyslog.class.php - * \ingroup syslog - * \brief Description and activation file for the module syslog + * \defgroup syslog Module Syslog + * \brief Module to manage error messages in syslog + * + * \file htdocs/core/modules/modSyslog.class.php + * \ingroup syslog + * \brief Description and activation file for the module syslog */ include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php index f0380fb6410..de56f544a30 100644 --- a/htdocs/core/modules/modTicket.class.php +++ b/htdocs/core/modules/modTicket.class.php @@ -119,7 +119,8 @@ class modTicket extends DolibarrModules 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), - 14 => array('TICKET_SHOW_COMPANY_LOGO', 'chaine', getDolGlobalInt('TICKET_SHOW_COMPANY_LOGO'), 'Enable logo header on ticket public page', 0) + 14 => array('TICKET_SHOW_COMPANY_LOGO', 'chaine', getDolGlobalInt('TICKET_SHOW_COMPANY_LOGO'), 'Enable logo header on ticket public page', 0), + 15 => array('TICKET_SHOW_COMPANY_FOOTER', 'chaine', getDolGlobalInt('TICKET_SHOW_COMPANY_FOOTER'), 'Enable footer on ticket public page', 0) ); diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index df5cfba961f..4fce2b8021f 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -18,11 +18,12 @@ */ /** - * \defgroup user Module user management - * \brief Module pour gerer les utilisateurs - * \file htdocs/core/modules/modUser.class.php - * \ingroup user - * \brief Description and activation file for the module users + * \defgroup user Module user management + * \brief Module to manage users and usergroups + * + * \file htdocs/core/modules/modUser.class.php + * \ingroup user + * \brief Description and activation file for the module users */ include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; diff --git a/htdocs/core/modules/modZapier.class.php b/htdocs/core/modules/modZapier.class.php index f3d187cf3bb..c89a9603365 100644 --- a/htdocs/core/modules/modZapier.class.php +++ b/htdocs/core/modules/modZapier.class.php @@ -229,7 +229,7 @@ class modZapier extends DolibarrModules // Permission label $this->rights[$r][1] = 'Read myobject of Zapier'; // Permission by default for new user (0/1) - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; // In php code, permission will be checked by test if ($user->rights->zapier->level1->level2) $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->zapier->level1->level2) @@ -237,13 +237,13 @@ class modZapier extends DolibarrModules $r++; $this->rights[$r][0] = $this->numero + $r; $this->rights[$r][1] = 'Create/Update myobject of Zapier'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'write'; $this->rights[$r][5] = ''; $r++; $this->rights[$r][0] = $this->numero + $r; $this->rights[$r][1] = 'Delete myobject of Zapier'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'delete'; $this->rights[$r][5] = ''; diff --git a/htdocs/core/modules/movement/doc/pdf_standard.modules.php b/htdocs/core/modules/movement/doc/pdf_standard.modules.php index d15ae20170b..ac53946bb06 100644 --- a/htdocs/core/modules/movement/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/movement/doc/pdf_standard.modules.php @@ -37,44 +37,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; */ class pdf_standard extends ModelePDFMovement { - /** - * @var DoliDb Database handler - */ - public $db; - - /** - * @var string model name - */ - public $name; - - /** - * @var string model description (short text) - */ - public $description; - /** * @var int Save the name of generated file as the main doc when generating a doc with this template */ public $update_main_doc_field; - /** - * @var string document type - */ - public $type; - - /** - * Dolibarr version of the loaded document - * @var string - */ - public $version = 'dolibarr'; - - /** - * Issuer - * @var Societe Object that emits - */ - public $emetteur; - - public $wref; public $posxidref; public $posxdatemouv; @@ -116,7 +83,6 @@ class pdf_standard extends ModelePDFMovement $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); $this->option_logo = 1; // Display logo - $this->option_codestockservice = 0; // Display stock-service code $this->option_multilang = 1; // Available in several languages $this->option_freetext = 0; // Support add of a personalised text @@ -719,6 +685,14 @@ class pdf_standard extends ModelePDFMovement dol_print_error($this->db); } + // Display notes + $notetoshow = empty($object->note_public) ? '' : $object->note_public; + // Extrafields in note + $extranote = $this->getExtrafieldsInHtml($object, $outputlangs); + if (!empty($extranote)) { + $notetoshow = dol_concatdesc($notetoshow, $extranote); + } + if ($notetoshow) { $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); diff --git a/htdocs/core/modules/movement/modules_movement.php b/htdocs/core/modules/movement/modules_movement.php index a058d685114..0525793a715 100644 --- a/htdocs/core/modules/movement/modules_movement.php +++ b/htdocs/core/modules/movement/modules_movement.php @@ -31,47 +31,25 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; abstract class ModelePDFMovement extends CommonDocGenerator { /** - * @var string Error code (or message) + * @var DoliDb Database handler */ - public $error = ''; + public $db; /** - * @var int page_largeur + * @var string model description (short text) */ - public $page_largeur; + public $description; /** - * @var int page_hauteur + * @var string document type */ - public $page_hauteur; + public $type; /** - * @var array format + * Dolibarr version of the loaded document + * @var string */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - - public $option_codestockservice; + public $version = 'dolibarr'; // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php index fe18e6eb6ea..f24f77cb946 100644 --- a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php +++ b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php @@ -40,12 +40,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; */ class doc_generic_mo_odt extends ModelePDFMo { - /** - * Issuer - * @var Societe - */ - public $emetteur; - /** * @var string Dolibarr version of the loaded document */ @@ -142,17 +136,18 @@ class doc_generic_mo_odt extends ModelePDFMo } } $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp .= '

    '.$langs->trans("ExampleOfDirectoriesForModelGen").''; // Add list of substitution keys $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); $texte .= '
    '; $texte .= ''; $texte .= '
    '; - $texte .= ''; + $texte .= ''; $texte .= '
    '; // Scan directories @@ -178,11 +173,6 @@ class doc_generic_mo_odt extends ModelePDFMo $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte .= ''; - $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php index 62e5f062514..7be587e7c0e 100644 --- a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php +++ b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php @@ -5,7 +5,7 @@ * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2015 Marcos García * Copyright (C) 2017 Ferran Marcet - * Copyright (C) 2018-2021 Frédéric France + * Copyright (C) 2018-2023 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -73,47 +73,6 @@ class pdf_vinci extends ModelePDFMo */ public $version = 'dolibarr'; - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - /** - * Issuer - * @var Societe object that emits - */ - public $emetteur; - /** * Constructor @@ -122,7 +81,7 @@ class pdf_vinci extends ModelePDFMo */ public function __construct($db) { - global $conf, $langs, $mysoc; + global $langs, $mysoc; // Load translation files required by the page $langs->loadLangs(array("main", "bills")); @@ -1010,9 +969,10 @@ class pdf_vinci extends ModelePDFMo $pdf->SetFont('', '', $default_font_size - 2); if (empty($hidetop)) { - //$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); - $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); + // $title = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); + $title = ''; + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($title) + 3), $tab_top - 4); + $pdf->MultiCell(($pdf->GetStringWidth($title) + 3), 2, $title); //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { diff --git a/htdocs/core/modules/mrp/mod_mo_advanced.php b/htdocs/core/modules/mrp/mod_mo_advanced.php index cd134537ea2..2fc5985cc84 100644 --- a/htdocs/core/modules/mrp/mod_mo_advanced.php +++ b/htdocs/core/modules/mrp/mod_mo_advanced.php @@ -55,9 +55,10 @@ class mod_mo_advanced extends ModeleNumRefMos /** * Returns the description of the numbering model * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $conf, $langs, $db; @@ -82,7 +83,7 @@ class mod_mo_advanced extends ModeleNumRefMos $texte .= ''.$langs->trans("Mask").':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; diff --git a/htdocs/core/modules/mrp/mod_mo_standard.php b/htdocs/core/modules/mrp/mod_mo_standard.php index d47b4eb708e..c27c36c8849 100644 --- a/htdocs/core/modules/mrp/mod_mo_standard.php +++ b/htdocs/core/modules/mrp/mod_mo_standard.php @@ -51,9 +51,10 @@ class mod_mo_standard extends ModeleNumRefMos /** * Return description of numbering module * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -75,9 +76,10 @@ class mod_mo_standard extends ModeleNumRefMos * 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 + * @param Object $object Object we need next value for + * @return boolean false if conflict, true if ok */ - public function canBeActivated() + public function canBeActivated($object) { global $conf, $langs, $db; diff --git a/htdocs/core/modules/mrp/modules_mo.php b/htdocs/core/modules/mrp/modules_mo.php index 5c741f28d47..9d542be1208 100644 --- a/htdocs/core/modules/mrp/modules_mo.php +++ b/htdocs/core/modules/mrp/modules_mo.php @@ -30,6 +30,7 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit @@ -38,7 +39,6 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // requir */ abstract class ModelePDFMo extends CommonDocGenerator { - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules @@ -61,100 +61,10 @@ abstract class ModelePDFMo extends CommonDocGenerator } - /** * Parent class to manage numbering of MOs */ -abstract class ModeleNumRefMos +abstract class ModeleNumRefMos extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - public $version; - - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Returns the default description of the numbering template - * - * @return string Descriptive text - */ - public function info() - { - global $langs; - $langs->load("mrp"); - return $langs->trans("NoDescription"); - } - - /** - * Returns an example of numbering - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("mrp"); - return $langs->trans("NoExample"); - } - - /** - * 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() - { - return true; - } - - /** - * Returns next assigned value - * - * @param Societe $objsoc Object thirdparty - * @param Object $object Object we need next value for - * @return string Valeur - */ - public function getNextValue($objsoc, $object) - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Returns version of numbering module - * - * @return string Valeur - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } - if ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } - if ($this->version == 'dolibarr') { - return DOL_VERSION; - } - if ($this->version) { - return $this->version; - } - return $langs->trans("NotAvailable"); - } + // No overload code } diff --git a/htdocs/core/modules/oauth/google_oauthcallback.php b/htdocs/core/modules/oauth/google_oauthcallback.php index 7f654222044..abaf5921cdc 100644 --- a/htdocs/core/modules/oauth/google_oauthcallback.php +++ b/htdocs/core/modules/oauth/google_oauthcallback.php @@ -263,6 +263,7 @@ if (!GETPOST('code')) { dol_syslog("userinfo=".var_export($userinfo, true)); $useremail = $userinfo['email']; + /* $useremailverified = $userinfo['email_verified']; $useremailuniq = $userinfo['sub']; @@ -280,6 +281,12 @@ if (!GETPOST('code')) { // Verify that the ID token is properly signed by the issuer. Google-issued tokens are signed using one of the certificates found at the URI specified in the jwks_uri metadata value of the Discovery document. // TODO + // Verify that email is a verified email + /*if (empty($userinfo['email_verified'])) { + setEventMessages($langs->trans('Bad value for email, emai lwas not verified by Google'), null, 'errors'); + $errorincheck++; + }*/ + // Verify that the value of the iss claim in the ID token is equal to https://accounts.google.com or accounts.google.com. if ($userinfo['iss'] != 'accounts.google.com' && $userinfo['iss'] != 'https://accounts.google.com') { setEventMessages($langs->trans('Bad value for returned userinfo[iss]'), null, 'errors'); diff --git a/htdocs/core/modules/payment/mod_payment_ant.php b/htdocs/core/modules/payment/mod_payment_ant.php index 6125053cbb4..6fe019dde3b 100644 --- a/htdocs/core/modules/payment/mod_payment_ant.php +++ b/htdocs/core/modules/payment/mod_payment_ant.php @@ -57,9 +57,10 @@ class mod_payment_ant extends ModeleNumRefPayments /** * Returns the description of the numbering model * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $db, $langs; @@ -84,7 +85,7 @@ class mod_payment_ant extends ModeleNumRefPayments $texte .= ''.$langs->trans("Mask").':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; diff --git a/htdocs/core/modules/payment/mod_payment_cicada.php b/htdocs/core/modules/payment/mod_payment_cicada.php index d3259db513c..466bb81ea09 100644 --- a/htdocs/core/modules/payment/mod_payment_cicada.php +++ b/htdocs/core/modules/payment/mod_payment_cicada.php @@ -58,9 +58,10 @@ class mod_payment_cicada extends ModeleNumRefPayments /** * Return description of numbering module * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -82,9 +83,10 @@ class mod_payment_cicada extends ModeleNumRefPayments * 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 + * @param Object $object Object we need next value for + * @return boolean false if conflict, true if ok */ - public function canBeActivated() + public function canBeActivated($object) { global $conf, $langs, $db; diff --git a/htdocs/core/modules/payment/modules_payment.php b/htdocs/core/modules/payment/modules_payment.php index 68b864fe94d..d0913c71e23 100644 --- a/htdocs/core/modules/payment/modules_payment.php +++ b/htdocs/core/modules/payment/modules_payment.php @@ -16,96 +16,12 @@ * or see https://www.gnu.org/ */ +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; + /** - * \class ModeleNumRefPayments - * \brief Payment numbering references mother class + * Payment numbering references mother class */ - -abstract class ModeleNumRefPayments +abstract class ModeleNumRefPayments extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Return the default description of numbering module - * - * @return string Descriptive text - */ - public function info() - { - global $langs; - $langs->load("bills"); - return $langs->trans("NoDescription"); - } - - /** - * Return numbering example - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("bills"); - return $langs->trans("NoExample"); - } - - /** - * 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() - { - return true; - } - - /** - * Returns the next value - * - * @param Societe $objsoc Object thirdparty - * @param Object $object Object we need next value for - * @return string Valeur - */ - public function getNextValue($objsoc, $object) - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Returns the module numbering version - * - * @return string Value - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } elseif ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } elseif ($this->version == 'dolibarr') { - return DOL_VERSION; - } elseif ($this->version) { - return $this->version; - } else { - return $langs->trans("NotAvailable"); - } - } + // No overload code } diff --git a/htdocs/core/modules/printing/modules_printing.php b/htdocs/core/modules/printing/modules_printing.php index 26268e7c183..6eb74a2e93d 100644 --- a/htdocs/core/modules/printing/modules_printing.php +++ b/htdocs/core/modules/printing/modules_printing.php @@ -1,6 +1,6 @@ + * Copyright (C) 2014-2023 Frederic 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 @@ -41,6 +41,20 @@ class PrintingDriver */ public $error = ''; + /** + * @var string Name + */ + public $name; + + /** + * @var string Description + */ + public $desc; + + /** + * @var string Html string returned for print + */ + public $resprint; /** * Constructor 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 2728bf266c2..821aa6d8836 100644 --- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php +++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php @@ -37,12 +37,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; */ class doc_generic_product_odt extends ModelePDFProduct { - /** - * Issuer - * @var Societe - */ - public $emetteur; - /** * Dolibarr version of the loaded document * @var string @@ -140,17 +134,18 @@ class doc_generic_product_odt extends ModelePDFProduct } } $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp .= '

    '.$langs->trans("ExampleOfDirectoriesForModelGen").''; // Add list of substitution keys $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); $texte .= '
    '; $texte .= ''; $texte .= '
    '; - $texte .= ''; + $texte .= ''; $texte .= '
    '; // Scan directories @@ -179,16 +174,11 @@ class doc_generic_product_odt extends ModelePDFProduct } $texte .= ' '; $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= ''; $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte .= ''; - $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php index 3cd29891550..6bfd01c2f1b 100644 --- a/htdocs/core/modules/product/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php @@ -63,12 +63,6 @@ class pdf_standard extends ModelePDFProduct */ public $version = 'dolibarr'; - /** - * Issuer - * @var Societe - */ - public $emetteur; - /** * Constructor @@ -77,7 +71,7 @@ class pdf_standard extends ModelePDFProduct */ public function __construct($db) { - global $conf, $langs, $mysoc; + global $langs, $mysoc; // Load traductions files required by page $langs->loadLangs(array("main", "companies")); diff --git a/htdocs/core/modules/product/mod_codeproduct_elephant.php b/htdocs/core/modules/product/mod_codeproduct_elephant.php index c883de79c5e..a77ee4de156 100644 --- a/htdocs/core/modules/product/mod_codeproduct_elephant.php +++ b/htdocs/core/modules/product/mod_codeproduct_elephant.php @@ -119,7 +119,7 @@ class mod_codeproduct_elephant extends ModeleProductCode $texte .= ''.$langs->trans("Mask").' ('.$langs->trans("ProductCodeModel").'):'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; diff --git a/htdocs/core/modules/product/modules_product.class.php b/htdocs/core/modules/product/modules_product.class.php index e5f5e7e09eb..934b7c3a5c0 100644 --- a/htdocs/core/modules/product/modules_product.class.php +++ b/htdocs/core/modules/product/modules_product.class.php @@ -26,54 +26,15 @@ * \brief File with parent class for generating products to PDF and File of class to manage product numbering */ - require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; + /** * Parent class to manage intervention document templates */ abstract class ModelePDFProduct extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules @@ -97,56 +58,8 @@ abstract class ModelePDFProduct extends CommonDocGenerator /** * Class template for classes of numbering product */ -abstract class ModeleProductCode +abstract class ModeleProductCode extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - /** Returns the default description of the numbering pattern - * - * @param Translate $langs Object langs - * @return string Descriptive text - */ - public function info($langs) - { - $langs->load("bills"); - return $langs->trans("NoDescription"); - } - - /** Renvoi nom module - * - * @param Translate $langs Object langs - * @return string Nom du module - */ - public function getNom($langs) - { - return empty($this->name) ? $this->nom : $this->name; - } - - - /** Return an example of numbering - * - * @param Translate $langs Object langs - * @return string Example - */ - public function getExample($langs) - { - return $langs->trans("NoExample"); - } - - /** - * 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() - { - return true; - } - /** * Return next value available * @@ -160,31 +73,6 @@ abstract class ModeleProductCode return $langs->trans("Function_getNextValue_InModuleNotWorking"); } - - /** Return version of module - * - * @return string Version - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } - if ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } - if ($this->version == 'dolibarr') { - return DOL_VERSION; - } - if ($this->version) { - return $this->version; - } - return $langs->trans("NotAvailable"); - } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi la liste des modeles de numérotation diff --git a/htdocs/core/modules/product_batch/mod_lot_advanced.php b/htdocs/core/modules/product_batch/mod_lot_advanced.php index 27cc509ea02..18c5cba5b46 100644 --- a/htdocs/core/modules/product_batch/mod_lot_advanced.php +++ b/htdocs/core/modules/product_batch/mod_lot_advanced.php @@ -55,9 +55,10 @@ class mod_lot_advanced extends ModeleNumRefBatch /** * Returns the description of the numbering model * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $conf, $langs, $db; @@ -85,7 +86,7 @@ class mod_lot_advanced extends ModeleNumRefBatch $texte .= ''.$langs->trans("Mask").':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; // Option to enable custom masks per product $texte .= ''; diff --git a/htdocs/core/modules/product_batch/mod_lot_free.php b/htdocs/core/modules/product_batch/mod_lot_free.php index 8d14a25374f..bcba82c0ad5 100644 --- a/htdocs/core/modules/product_batch/mod_lot_free.php +++ b/htdocs/core/modules/product_batch/mod_lot_free.php @@ -1,7 +1,7 @@ * Copyright (C) 2006-2009 Laurent Destailleur - * Copyright (C) 2022 Frédéric France + * Copyright (C) 2022-2023 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -83,15 +83,25 @@ class mod_lot_free extends ModeleNumRefBatch /** * Return description of module * - * @return string Description of module + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; $langs->load("companies"); return $langs->trans("LeopardNumRefModelDesc"); } + /** + * Return an example of numbering + * + * @return string Example + */ + public function getExample() + { + return $this->getNextValue(null, null); + } /** * Return an example of result returned by getNextValue diff --git a/htdocs/core/modules/product_batch/mod_lot_standard.php b/htdocs/core/modules/product_batch/mod_lot_standard.php index ef3918fd167..843aa1dd78b 100644 --- a/htdocs/core/modules/product_batch/mod_lot_standard.php +++ b/htdocs/core/modules/product_batch/mod_lot_standard.php @@ -52,9 +52,10 @@ class mod_lot_standard extends ModeleNumRefBatch /** * Return description of numbering module * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -76,9 +77,10 @@ class mod_lot_standard extends ModeleNumRefBatch * 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 + * @param Object $object Object we need next value for + * @return boolean false if KO (there is a conflict), true if OK */ - public function canBeActivated() + public function canBeActivated($object) { global $conf, $langs, $db; diff --git a/htdocs/core/modules/product_batch/mod_sn_advanced.php b/htdocs/core/modules/product_batch/mod_sn_advanced.php index 91fc99a1363..fb6866742ff 100644 --- a/htdocs/core/modules/product_batch/mod_sn_advanced.php +++ b/htdocs/core/modules/product_batch/mod_sn_advanced.php @@ -55,9 +55,10 @@ class mod_sn_advanced extends ModeleNumRefBatch /** * Returns the description of the numbering model * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $conf, $langs, $db; @@ -85,7 +86,7 @@ class mod_sn_advanced extends ModeleNumRefBatch $texte .= ''.$langs->trans("Mask").':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; // Option to enable custom masks per product $texte .= ''; diff --git a/htdocs/core/modules/product_batch/mod_sn_free.php b/htdocs/core/modules/product_batch/mod_sn_free.php index 8ada51fb93b..c663833b8d4 100644 --- a/htdocs/core/modules/product_batch/mod_sn_free.php +++ b/htdocs/core/modules/product_batch/mod_sn_free.php @@ -79,15 +79,25 @@ class mod_sn_free extends ModeleNumRefBatch /** * Return description of module * - * @return string Description of module + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; $langs->load("companies"); return $langs->trans("LeopardNumRefModelDesc"); } + /** + * Return an example of numbering + * + * @return string Example + */ + public function getExample() + { + return $this->getNextValue(null, null); + } /** * Return an example of result returned by getNextValue @@ -98,7 +108,6 @@ class mod_sn_free extends ModeleNumRefBatch */ public function getNextValue($objsoc, $object) { - global $langs; return ''; } } diff --git a/htdocs/core/modules/product_batch/mod_sn_standard.php b/htdocs/core/modules/product_batch/mod_sn_standard.php index ccd49d03b8f..e1fdb0febb8 100644 --- a/htdocs/core/modules/product_batch/mod_sn_standard.php +++ b/htdocs/core/modules/product_batch/mod_sn_standard.php @@ -52,9 +52,10 @@ class mod_sn_standard extends ModeleNumRefBatch /** * Return description of numbering module * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -76,9 +77,10 @@ class mod_sn_standard extends ModeleNumRefBatch * 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 + * @param Object $object Object we need next value for + * @return boolean false if KO (there is a conflict), true if OK */ - public function canBeActivated() + public function canBeActivated($object) { global $conf, $langs, $db; 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 d596ffeb111..d38e5eef379 100644 --- a/htdocs/core/modules/product_batch/modules_product_batch.class.php +++ b/htdocs/core/modules/product_batch/modules_product_batch.class.php @@ -31,19 +31,15 @@ * \brief File with parent class for generating contracts to PDF and File of class to manage contract numbering */ - require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; + /** * Parent class to manage intervention document templates */ abstract class ModelePDFProductBatch extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules @@ -67,85 +63,7 @@ abstract class ModelePDFProductBatch extends CommonDocGenerator /** * Parent class to manage numbering of batch products */ -abstract class ModeleNumRefBatch +abstract class ModeleNumRefBatch extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Returns the default description of the numbering template - * - * @return string Descriptive text - */ - public function info() - { - global $langs; - $langs->load("productbatch"); - return $langs->trans("NoDescription"); - } - - /** - * Returns an example of numbering - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("productbatch"); - return $langs->trans("NoExample"); - } - - /** - * 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() - { - return true; - } - - /** - * Returns next assigned value - * - * @param Societe $objsoc Object thirdparty - * @param Productlot $object Object we need next value for - * @return string Valeur - */ - public function getNextValue($objsoc, $object) - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Returns version of numbering module - * - * @return string Valeur - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); - if ($this->version == 'dolibarr') return DOL_VERSION; - if ($this->version) return $this->version; - return $langs->trans("NotAvailable"); - } + // No overload code } diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index e8c1357e7a2..7259a2859a0 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 @@ -77,12 +77,6 @@ if (isModEnabled('expedition')) { */ class doc_generic_project_odt extends ModelePDFProjects { - /** - * Issuer - * @var Societe - */ - public $emetteur; - /** * Dolibarr version of the loaded document * @var string @@ -97,7 +91,7 @@ class doc_generic_project_odt extends ModelePDFProjects */ public function __construct($db) { - global $conf, $langs, $mysoc; + global $langs, $mysoc; // Load traductions files required by page $langs->loadLangs(array("companies", "main")); @@ -407,12 +401,12 @@ class doc_generic_project_odt extends ModelePDFProjects $form = new Form($this->db); $texte = $this->description.".
    \n"; - $texte .= '
    '; + $texte .= ''; $texte .= ''; $texte .= ''; $texte .= ''; $texte .= ''; - $texte .= ''; + $texte .= '
    '; // List of directories area $texte .= ''; - $texte .= ''; $texte .= ''; $texte .= '
    '; @@ -436,17 +430,18 @@ class doc_generic_project_odt extends ModelePDFProjects } } $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp .= '

    '.$langs->trans("ExampleOfDirectoriesForModelGen").''; // Add list of substitution keys $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); $texte .= '
    '; $texte .= ''; $texte .= '
    '; - $texte .= ''; + $texte .= ''; $texte .= '
    '; // Scan directories @@ -469,14 +464,19 @@ class doc_generic_project_odt extends ModelePDFProjects } $texte .= ''; } - + // Add input to upload a new template file. + $texte .= '
    '.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; + $texte .= ''; + $texte .= ''; + $texte .= '
    '; $texte .= '
    '; - $texte .= ''; - $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte .= ''; - $texte .= '
    '; @@ -1046,7 +1046,7 @@ class doc_generic_project_odt extends ModelePDFProjects ), ); - //Insert reference + // Insert list of objects into the project try { $listlines = $odfHandler->setSegment('projectrefs'); @@ -1122,6 +1122,8 @@ class doc_generic_project_odt extends ModelePDFProjects } $odfHandler->mergeSegment($listlines); } + } catch (OdfExceptionSegmentNotFound $e) { + // Do nothing } catch (OdfException $e) { $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php index 0a048837d7a..f4f413758a3 100644 --- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php @@ -63,52 +63,22 @@ class pdf_baleine extends ModelePDFProjects */ public $type; + /** + * @var int posxdatestart + */ + public $posxdatestart; + + /** + * @var int posxdateend + */ + public $posxdateend; + /** * Dolibarr version of the loaded document * @var string */ public $version = 'dolibarr'; - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - /** - * Issuer - * @var Societe Object that emits - */ - public $emetteur; /** * Constructor @@ -117,7 +87,7 @@ class pdf_baleine extends ModelePDFProjects */ public function __construct($db) { - global $conf, $langs, $mysoc; + global $langs, $mysoc; // Translations $langs->loadLangs(array("main", "projects", "companies")); diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 1823f68b835..a7cf4c50b96 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -59,11 +59,6 @@ class pdf_beluga extends ModelePDFProjects */ public $db; - /** - * @var string model name - */ - public $name; - /** * @var string model description (short text) */ @@ -85,59 +80,18 @@ class pdf_beluga extends ModelePDFProjects */ public $version = 'dolibarr'; - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - /** * Page orientation * @var string 'P' or 'Portait' (default), 'L' or 'Landscape' */ private $orientation; - /** - * Issuer - * @var Societe - */ - public $emetteur; - public $posxref; public $posxdate; - public $posxsociete; + public $posxsociety; public $posxamountht; public $posxamountttc; - public $posstatut; + public $posxstatut; /** @@ -202,10 +156,10 @@ class pdf_beluga extends ModelePDFProjects if ($this->page_largeur < 210) { // To work with US executive format $this->posxref -= 20; $this->posxdate -= 20; - $this->posxsociete -= 20; + $this->posxsociety -= 20; $this->posxamountht -= 20; $this->posxamountttc -= 20; - $this->posstatut -= 20; + $this->posxstatut -= 20; } } diff --git a/htdocs/core/modules/project/doc/pdf_timespent.modules.php b/htdocs/core/modules/project/doc/pdf_timespent.modules.php index c00ae37ab22..60e03823f22 100644 --- a/htdocs/core/modules/project/doc/pdf_timespent.modules.php +++ b/htdocs/core/modules/project/doc/pdf_timespent.modules.php @@ -68,46 +68,6 @@ class pdf_timespent extends ModelePDFProjects */ public $version = 'dolibarr'; - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - /** - * Issuer - * @var Societe Object that emits - */ - public $emetteur; /** * Constructor @@ -116,7 +76,7 @@ class pdf_timespent extends ModelePDFProjects */ public function __construct($db) { - global $conf, $langs, $mysoc; + global $langs, $mysoc; // Translations $langs->loadLangs(array("main", "projects", "companies")); diff --git a/htdocs/core/modules/project/mod_project_simple.php b/htdocs/core/modules/project/mod_project_simple.php index ba1d04023f3..959cc86adbe 100644 --- a/htdocs/core/modules/project/mod_project_simple.php +++ b/htdocs/core/modules/project/mod_project_simple.php @@ -60,9 +60,10 @@ class mod_project_simple extends ModeleNumRefProjects /** * Return description of numbering module * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -84,9 +85,10 @@ class mod_project_simple extends ModeleNumRefProjects * 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 + * @param Object $object Object we need next value for + * @return boolean false if KO (there is a conflict), true if OK */ - public function canBeActivated() + public function canBeActivated($object) { global $conf, $langs, $db; diff --git a/htdocs/core/modules/project/mod_project_universal.php b/htdocs/core/modules/project/mod_project_universal.php index 93530cc793c..4f2f5a421ae 100644 --- a/htdocs/core/modules/project/mod_project_universal.php +++ b/htdocs/core/modules/project/mod_project_universal.php @@ -17,16 +17,16 @@ */ /** - * \file htdocs/core/modules/project/mod_project_universal.php - * \ingroup project - * \brief Fichier contenant la classe du modele de numerotation de reference de projet Universal + * \file htdocs/core/modules/project/mod_project_universal.php + * \ingroup project + * \brief File containing the Universal project reference numbering model class */ require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php'; /** - * Classe du modele de numerotation de reference de projet Universal + * Class to manage the numbering module Universal for project references */ class mod_project_universal extends ModeleNumRefProjects { @@ -62,11 +62,12 @@ class mod_project_universal extends ModeleNumRefProjects /** * Returns the description of the numbering model * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { - global $conf, $langs; + global $langs; // Load translation files required by the page $langs->loadLangs(array("projects", "admin")); @@ -86,11 +87,11 @@ class mod_project_universal extends ModeleNumRefProjects $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Project"), $langs->transnoentities("Project")); $tooltip .= $langs->trans("GenericMaskCodes5"); - // Parametrage du prefix + // Prefix settings $texte .= ''.$langs->trans("Mask").':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; @@ -123,9 +124,9 @@ class mod_project_universal extends ModeleNumRefProjects /** * Return next value * - * @param Societe $objsoc Object third party + * @param Societe $objsoc Object third party * @param Project $project Object project - * @return string Value if OK, 0 if KO + * @return string Value if OK, 0 if KO */ public function getNextValue($objsoc, $project) { @@ -133,7 +134,7 @@ class mod_project_universal extends ModeleNumRefProjects require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - // On defini critere recherche compteur + // We define criterion search counter $mask = getDolGlobalString('PROJECT_UNIVERSAL_MASK'); if (!$mask) { diff --git a/htdocs/core/modules/project/modules_project.php b/htdocs/core/modules/project/modules_project.php index 9f8e0e977c7..11a60bc4a4e 100644 --- a/htdocs/core/modules/project/modules_project.php +++ b/htdocs/core/modules/project/modules_project.php @@ -24,6 +24,7 @@ * and parent class for projects numbering models */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; /** @@ -36,61 +37,11 @@ abstract class ModelePDFProjects extends CommonDocGenerator */ public $db; - /** - * @var string model name - */ - public $name; - /** * @var string model description (short text) */ public $description; - /** - * @var string document type - */ - public $type; - - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - /** - * @var string Error code (or message) - */ - public $error = ''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** @@ -118,96 +69,7 @@ abstract class ModelePDFProjects extends CommonDocGenerator /** * Classe mere des modeles de numerotation des references de projets */ -abstract class ModeleNumRefProjects +abstract class ModeleNumRefProjects extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - /** - * @var string $version - */ - public $version; - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Returns the default description of the numbering pattern - * - * @return string Descriptive text - */ - public function info() - { - global $langs; - $langs->load("projects"); - return $langs->trans("NoDescription"); - } - - /** - * Return an example of numbering - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("projects"); - return $langs->trans("NoExample"); - } - - /** - * 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() - { - return true; - } - - /** - * Renvoi prochaine valeur attribuee - * - * @param Societe $objsoc Object third party - * @param Project $project Object project - * @return string Valeur - */ - public function getNextValue($objsoc, $project) - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Renvoi version du module numerotation - * - * @return string Valeur - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } elseif ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } elseif ($this->version == 'dolibarr') { - return DOL_VERSION; - } elseif ($this->version) { - return $this->version; - } else { - return $langs->trans("NotAvailable"); - } - } + // No overload code } diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index 51e53e21d3f..59fdcc36ab2 100644 --- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -76,12 +76,6 @@ if (isModEnabled('agenda')) { */ class doc_generic_task_odt extends ModelePDFTask { - /** - * Issuer - * @var Societe Object that emits - */ - public $emetteur; - /** * Dolibarr version of the loaded document * @var string @@ -96,7 +90,7 @@ class doc_generic_task_odt extends ModelePDFTask */ public function __construct($db) { - global $conf, $langs, $mysoc; + global $langs, $mysoc; // Load translation files required by the page $langs->loadLangs(array("main", "companies")); @@ -372,12 +366,12 @@ class doc_generic_task_odt extends ModelePDFTask $form = new Form($this->db); $texte = $this->description.".
    \n"; - $texte .= ''; + $texte .= ''; $texte .= ''; $texte .= ''; $texte .= ''; $texte .= ''; - $texte .= ''; + $texte .= '
    '; // List of directories area $texte .= ''; - $texte .= ''; $texte .= ''; $texte .= '
    '; @@ -401,17 +395,18 @@ class doc_generic_task_odt extends ModelePDFTask } } $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp .= '

    '.$langs->trans("ExampleOfDirectoriesForModelGen").''; // Add list of substitution keys $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); $texte .= '
    '; $texte .= ''; $texte .= '
    '; - $texte .= ''; + $texte .= ''; $texte .= '
    '; // Scan directories @@ -434,14 +429,19 @@ class doc_generic_task_odt extends ModelePDFTask } $texte .= ''; } - + // Add input to upload a new template file. + $texte .= '
    '.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; + $texte .= ''; + $texte .= ''; + $texte .= '
    '; $texte .= '
    '; - $texte .= ''; - $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte .= ''; - $texte .= '
    '; @@ -538,6 +538,8 @@ class doc_generic_task_odt extends ModelePDFTask ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook + $tmparray = array(); + $action = ''; $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks diff --git a/htdocs/core/modules/project/task/mod_task_simple.php b/htdocs/core/modules/project/task/mod_task_simple.php index f0cdddfbc88..94bb215be1e 100644 --- a/htdocs/core/modules/project/task/mod_task_simple.php +++ b/htdocs/core/modules/project/task/mod_task_simple.php @@ -60,9 +60,10 @@ class mod_task_simple extends ModeleNumRefTask /** * Return description of numbering module * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -84,9 +85,10 @@ class mod_task_simple extends ModeleNumRefTask * 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 + * @param Object $object Object we need next value for + * @return boolean false if KO (there is a conflict), true if OK */ - public function canBeActivated() + public function canBeActivated($object) { global $conf, $langs, $db; diff --git a/htdocs/core/modules/project/task/mod_task_universal.php b/htdocs/core/modules/project/task/mod_task_universal.php index 4084f3d9298..add0de5d9e4 100644 --- a/htdocs/core/modules/project/task/mod_task_universal.php +++ b/htdocs/core/modules/project/task/mod_task_universal.php @@ -57,11 +57,12 @@ class mod_task_universal extends ModeleNumRefTask /** * Returns the description of the numbering model * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { - global $conf, $langs, $db; + global $langs, $db; // Load translation files required by the page $langs->loadLangs(array("projects", "admin")); @@ -85,7 +86,7 @@ class mod_task_universal extends ModeleNumRefTask $texte .= ''.$langs->trans("Mask").':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; diff --git a/htdocs/core/modules/project/task/modules_task.php b/htdocs/core/modules/project/task/modules_task.php index 97e31d5d24c..5752b03dec3 100644 --- a/htdocs/core/modules/project/task/modules_task.php +++ b/htdocs/core/modules/project/task/modules_task.php @@ -24,7 +24,9 @@ * \brief File that contain parent class for task models * and parent class for task numbering models */ + require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; /** @@ -32,12 +34,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; */ abstract class ModelePDFTask extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules @@ -64,90 +60,7 @@ abstract class ModelePDFTask extends CommonDocGenerator /** * Classe mere des modeles de numerotation des references de projets */ -abstract class ModeleNumRefTask +abstract class ModeleNumRefTask extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Returns the default description of the numbering pattern - * - * @return string Descriptive text - */ - public function info() - { - global $langs; - $langs->load("projects"); - return $langs->trans("NoDescription"); - } - - /** - * Return an example of numbering - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("projects"); - return $langs->trans("NoExample"); - } - - /** - * 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() - { - return true; - } - - /** - * Renvoi prochaine valeur attribuee - * - * @param Societe $objsoc Object third party - * @param Project $project Object project - * @return string Valeur - */ - public function getNextValue($objsoc, $project) - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Renvoi version du module numerotation - * - * @return string Valeur - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } - if ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } - if ($this->version == 'dolibarr') { - return DOL_VERSION; - } - return $langs->trans("NotAvailable"); - } + // No overload code } 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 734ebdc5137..5a10e24333f 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -39,11 +39,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php'; */ class doc_generic_proposal_odt extends ModelePDFPropales { - /** - * @var Societe Issuer object that emits - */ - public $emetteur; - /** * @var string Dolibarr version of the loaded document */ @@ -57,7 +52,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales */ public function __construct($db) { - global $conf, $langs, $mysoc; + global $langs, $mysoc; // Load translation files required by the page $langs->loadLangs(array("main", "companies")); @@ -104,7 +99,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales */ public function info($langs) { - global $conf, $langs; + global $langs; // Load translation files required by the page $langs->loadLangs(array("errors", "companies")); @@ -149,17 +144,18 @@ class doc_generic_proposal_odt extends ModelePDFPropales } } $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp .= '

    '.$langs->trans("ExampleOfDirectoriesForModelGen").''; // Add list of substitution keys $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); $texte .= '
    '; $texte .= ''; $texte .= '
    '; - $texte .= ''; + $texte .= ''; $texte .= '
    '; // Scan directories @@ -217,15 +213,10 @@ class doc_generic_proposal_odt extends ModelePDFPropales } $texte .= ' '; $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= ''; $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte .= ''; - $texte .= ''; $texte .= ''; $texte .= ''; @@ -418,6 +409,13 @@ class doc_generic_proposal_odt extends ModelePDFPropales $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); $array_other = $this->get_substitutionarray_other($outputlangs); + + include_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; + $companybankaccount = new CompanyBankAccount($this->db); + $companybankaccount->fetch(0, $object->thirdparty->id); + $array_objet['company_default_bank_iban']=$companybankaccount->iban; + $array_objet['company_default_bank_bic']=$companybankaccount->bic; + // retrieve contact information for use in object as contact_xxx tags $array_thirdparty_contact = array(); if ($usecontact && is_object($contactobject)) { diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 85576e467ec..27caa33087f 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -79,47 +79,6 @@ class pdf_azur extends ModelePDFPropales */ public $version = 'dolibarr'; - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - /** - * Issuer - * @var Societe Object that emits - */ - public $emetteur; - /** * Constructor diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 153a0460d84..0d1bb192820 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -72,47 +72,6 @@ class pdf_cyan extends ModelePDFPropales */ public $version = 'dolibarr'; - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - /** - * Issuer - * @var Societe Object that emits - */ - public $emetteur; - /** * @var array of document table columns */ @@ -126,7 +85,7 @@ class pdf_cyan extends ModelePDFPropales */ public function __construct($db) { - global $conf, $langs, $mysoc; + global $langs, $mysoc; // Translations $langs->loadLangs(array("main", "bills")); @@ -1533,8 +1492,17 @@ class pdf_cyan extends ModelePDFPropales // Output Rect $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + if (!empty($conf->global->MAIN_PDF_TITLE_TEXT_COLOR)) { + $arrayColorTextTitle = explode(',', $conf->global->MAIN_PDF_TITLE_TEXT_COLOR); + $pdf->SetTextColor($arrayColorTextTitle[0], $arrayColorTextTitle[1], $arrayColorTextTitle[2]); + } + $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); + if (!empty($conf->global->MAIN_PDF_TITLE_TEXT_COLOR)) { + $pdf->SetTextColor(0, 0, 0); + } + if (empty($hidetop)) { $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter } diff --git a/htdocs/core/modules/propale/mod_propale_marbre.php b/htdocs/core/modules/propale/mod_propale_marbre.php index 54dd0096b2e..b9638dc904b 100644 --- a/htdocs/core/modules/propale/mod_propale_marbre.php +++ b/htdocs/core/modules/propale/mod_propale_marbre.php @@ -60,9 +60,10 @@ class mod_propale_marbre extends ModeleNumRefPropales /** * Return description of numbering module * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -84,9 +85,10 @@ class mod_propale_marbre extends ModeleNumRefPropales * 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 + * @param Object $object Object we need next value for + * @return boolean false if KO (there is a conflict), true if OK */ - public function canBeActivated() + public function canBeActivated($object) { global $conf, $langs, $db; diff --git a/htdocs/core/modules/propale/mod_propale_saphir.php b/htdocs/core/modules/propale/mod_propale_saphir.php index 74395dcc599..cfa06eb5f01 100644 --- a/htdocs/core/modules/propale/mod_propale_saphir.php +++ b/htdocs/core/modules/propale/mod_propale_saphir.php @@ -60,9 +60,10 @@ class mod_propale_saphir extends ModeleNumRefPropales /** * Return description of module * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $conf, $langs, $db; @@ -88,7 +89,7 @@ class mod_propale_saphir extends ModeleNumRefPropales $mask = empty($conf->global->PROPALE_SAPHIR_MASK) ? '' : $conf->global->PROPALE_SAPHIR_MASK; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; diff --git a/htdocs/core/modules/propale/modules_propale.php b/htdocs/core/modules/propale/modules_propale.php index be4c32ab6a5..b897e029969 100644 --- a/htdocs/core/modules/propale/modules_propale.php +++ b/htdocs/core/modules/propale/modules_propale.php @@ -28,6 +28,7 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Requis car utilise dans les classes qui heritent @@ -36,11 +37,6 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Requis */ abstract class ModelePDFPropales extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - public $posxpicture; public $posxtva; public $posxup; @@ -84,96 +80,7 @@ abstract class ModelePDFPropales extends CommonDocGenerator /** * Parent class for numbering rules of proposals */ -abstract class ModeleNumRefPropales +abstract class ModeleNumRefPropales extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - public $version; - - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Returns the default description of the numbering pattern - * - * @return string Descriptive text - */ - public function info() - { - global $langs; - $langs->load("propale"); - return $langs->trans("NoDescription"); - } - - /** - * Return an example of numbering - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("propale"); - return $langs->trans("NoExample"); - } - - /** - * 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() - { - return true; - } - - /** - * Renvoi prochaine valeur attribuee - * - * @param Societe $objsoc Object third party - * @param Propal $propal Object commercial proposal - * @return string Valeur - */ - public function getNextValue($objsoc, $propal) - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Renvoi version du module numerotation - * - * @return string Valeur - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } - if ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } - if ($this->version == 'dolibarr') { - return DOL_VERSION; - } - if ($this->version) { - return $this->version; - } - return $langs->trans("NotAvailable"); - } + // No overload code } diff --git a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php index 2bc493eb580..12b5e9094e6 100644 --- a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php +++ b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php @@ -36,11 +36,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; */ class doc_generic_reception_odt extends ModelePdfReception { - /** - * @var Societe Issuer object that emits - */ - public $emetteur; // Objet societe qui emet - /** * @var string Dolibarr version of the loaded document */ @@ -136,17 +131,18 @@ class doc_generic_reception_odt extends ModelePdfReception } } $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp .= '

    '.$langs->trans("ExampleOfDirectoriesForModelGen").''; // Add list of substitution keys $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); $texte .= '
    '; $texte .= ''; $texte .= '
    '; - $texte .= ''; + $texte .= ''; $texte .= '
    '; // Scan directories @@ -177,16 +173,11 @@ class doc_generic_reception_odt extends ModelePdfReception } $texte .= ' '; $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= ''; $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte .= ''; - $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 8c1f571aa0c..3d6d282bf8e 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2018 Quentin Vial-Gouteyron + * Copyright (C) 2023 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,10 +34,29 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; class pdf_squille extends ModelePdfReception { /** - * Issuer - * @var Societe object that emits + * @var string Dolibarr version of the loaded document */ - public $emetteur; + public $version = 'dolibarr'; + + /** + * @var int posx weight vol + */ + public $posxweightvol; + + /** + * @var int posx qty ordered + */ + public $posxqtyordered; + + /** + * @var int posx qty to ship + */ + public $posxqtytoship; + + /** + * @var int posx totalht + */ + public $posxtotalht; /** @@ -618,7 +638,7 @@ class pdf_squille extends ModelePdfReception * Show total to pay * * @param TCPDF $pdf Object PDF - * @param Facture $object Object invoice + * @param Reception $object Object reception * @param int $deja_regle Montant deja regle * @param int $posy Position depart * @param Translate $outputlangs Objet langs @@ -830,7 +850,7 @@ class pdf_squille extends ModelePdfReception * Show top header of page. * * @param TCPDF $pdf Object PDF - * @param Object $object Object to show + * @param Reception $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output * @return void diff --git a/htdocs/core/modules/reception/mod_reception_beryl.php b/htdocs/core/modules/reception/mod_reception_beryl.php index 6570f2c864a..816946651e8 100644 --- a/htdocs/core/modules/reception/mod_reception_beryl.php +++ b/htdocs/core/modules/reception/mod_reception_beryl.php @@ -37,9 +37,10 @@ class mod_reception_beryl extends ModelNumRefReception /** * Return default description of numbering model * - * @return string text description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -60,9 +61,10 @@ class mod_reception_beryl extends ModelNumRefReception /** * Test if existing numbers make problems with numbering * - * @return boolean false if conflit, true if ok + * @param Object $object Object we need next value for + * @return boolean false if KO (there is a conflict), true if OK */ - public function canBeActivated() + public function canBeActivated($object) { global $conf, $langs, $db; diff --git a/htdocs/core/modules/reception/mod_reception_moonstone.php b/htdocs/core/modules/reception/mod_reception_moonstone.php index c9e52d8d10f..b7ab238caec 100644 --- a/htdocs/core/modules/reception/mod_reception_moonstone.php +++ b/htdocs/core/modules/reception/mod_reception_moonstone.php @@ -37,11 +37,12 @@ class mod_reception_moonstone extends ModelNumRefReception /** * Return default description of numbering model * - * @return string text description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { - global $conf, $langs, $db; + global $langs, $db; $langs->load("bills"); @@ -62,7 +63,7 @@ class mod_reception_moonstone extends ModelNumRefReception $texte .= ''.$langs->trans("Mask").':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/reception/modules_reception.php b/htdocs/core/modules/reception/modules_reception.php index 1536b550fff..75f6d309cd7 100644 --- a/htdocs/core/modules/reception/modules_reception.php +++ b/htdocs/core/modules/reception/modules_reception.php @@ -22,16 +22,15 @@ * \brief File that contains parent class for sending receipts models * and parent class for sending receipts numbering models */ - require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; + +require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; /** * Parent class of sending receipts models */ abstract class ModelePdfReception extends CommonDocGenerator { - public $error = ''; - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules @@ -57,89 +56,7 @@ abstract class ModelePdfReception extends CommonDocGenerator /** * Parent Class of numbering models of sending receipts references */ -abstract class ModelNumRefReception +abstract class ModelNumRefReception extends CommonNumRefGenerator { - public $error = ''; - - public $version; - - - /** - * Return if a model can be used or not - * - * @return boolean true if model can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Return default description of numbering model - * - * @return string text description - */ - public function info() - { - global $langs; - $langs->load("reception"); - return $langs->trans("NoDescription"); - } - - /** - * Returns numbering example - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("reception"); - return $langs->trans("NoExample"); - } - - /** - * Test if existing numbers make problems with numbering - * - * @return boolean false if conflit, true if ok - */ - public function canBeActivated() - { - return true; - } - - /** - * Returns next value assigned - * - * @param Societe $objsoc Third party object - * @param Object $reception Reception object - * @return string Value - */ - public function getNextValue($objsoc, $reception) - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Returns version of the numbering model - * - * @return string Value - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } elseif ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } elseif ($this->version == 'dolibarr') { - return DOL_VERSION; - } elseif ($this->version) { - return $this->version; - } - return $langs->trans("NotAvailable"); - } + // No overload code } diff --git a/htdocs/core/modules/security/generate/modGeneratePassNone.class.php b/htdocs/core/modules/security/generate/modGeneratePassNone.class.php index 3ec764c6ab2..66621512b54 100644 --- a/htdocs/core/modules/security/generate/modGeneratePassNone.class.php +++ b/htdocs/core/modules/security/generate/modGeneratePassNone.class.php @@ -51,16 +51,6 @@ class modGeneratePassNone extends ModeleGenPassword */ public $length2; - /** - * @var DoliDB Database handler. - */ - public $db; - - public $conf; - public $lang; - public $user; - - /** * Constructor * diff --git a/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php b/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php index 491ab9757e8..b708404956b 100644 --- a/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php +++ b/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php @@ -65,15 +65,6 @@ class modGeneratePassPerso extends ModeleGenPassword */ public $WithoutAmbi = 0; - /** - * @var DoliDB Database handler. - */ - public $db; - - public $conf; - public $lang; - public $user; - public $Maj; public $Min; public $Nb; diff --git a/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php b/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php index b2d0b260ccb..0bab8e8b32b 100644 --- a/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php +++ b/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php @@ -51,16 +51,6 @@ class modGeneratePassStandard extends ModeleGenPassword */ public $length2; - /** - * @var DoliDB Database handler. - */ - public $db; - - public $conf; - public $lang; - public $user; - - /** * Constructor * diff --git a/htdocs/core/modules/security/generate/modules_genpassword.php b/htdocs/core/modules/security/generate/modules_genpassword.php index bb1e02774c6..4f5aedc7684 100644 --- a/htdocs/core/modules/security/generate/modules_genpassword.php +++ b/htdocs/core/modules/security/generate/modules_genpassword.php @@ -43,6 +43,26 @@ abstract class ModeleGenPassword */ public $error = ''; + /** + * @var DoliDB Database handler. + */ + public $db; + + /** + * @var Conf dolibarr conf + */ + public $conf; + + /** + * @var Translate Translate Object + */ + public $langs; + + /** + * @var User user + */ + public $user; + /** * Return if a module can be used or not * diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index 261aeef9ad5..abcbb90877e 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -37,10 +37,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; class doc_generic_odt extends ModeleThirdPartyDoc { /** - * Issuer - * @var Societe + * @var string Dolibarr version of the loaded document */ - public $emetteur; + public $version = 'dolibarr'; + /** * Constructor @@ -125,18 +125,19 @@ class doc_generic_odt extends ModeleThirdPartyDoc } } $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp .= '

    '.$langs->trans("ExampleOfDirectoriesForModelGen").''; // Add list of substitution keys $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); $texte .= ''; $texte .= ''; $texte .= ''; $texte .= '
    '; $texte .= ''; $texte .= '  '; - $texte .= ''; + $texte .= ''; $texte .= '
    '; @@ -170,15 +171,10 @@ class doc_generic_odt extends ModeleThirdPartyDoc } $texte .= ' '; $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= ''; $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte .= ''; - $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php index 100799dff95..c094086e46d 100644 --- a/htdocs/core/modules/societe/mod_codeclient_elephant.php +++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php @@ -135,7 +135,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode $texte .= ''.$langs->trans("Mask").' ('.$langs->trans("CustomerCodeModel").'):'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; diff --git a/htdocs/core/modules/societe/mod_codeclient_leopard.php b/htdocs/core/modules/societe/mod_codeclient_leopard.php index aff13d41536..133ba8a470e 100644 --- a/htdocs/core/modules/societe/mod_codeclient_leopard.php +++ b/htdocs/core/modules/societe/mod_codeclient_leopard.php @@ -88,6 +88,18 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode return $langs->trans("LeopardNumRefModelDesc"); } + /** + * Return an example of result returned by getNextValue + * + * @param Translate $langs Object langs + * @param societe $objsoc Object thirdparty + * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) + * @return string Return string example + */ + public function getExample($langs, $objsoc = 0, $type = -1) + { + return ''; + } /** * Return an example of result returned by getNextValue diff --git a/htdocs/core/modules/societe/mod_codecompta_aquarium.php b/htdocs/core/modules/societe/mod_codecompta_aquarium.php index 3805feee4ce..f6eb46fa1b5 100644 --- a/htdocs/core/modules/societe/mod_codecompta_aquarium.php +++ b/htdocs/core/modules/societe/mod_codecompta_aquarium.php @@ -113,7 +113,7 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode $texte .= $langs->trans('COMPANY_AQUARIUM_NO_PREFIX').' = '.$conf->global->COMPANY_AQUARIUM_NO_PREFIX."
    \n"; } $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/societe/mod_codecompta_digitaria.php b/htdocs/core/modules/societe/mod_codecompta_digitaria.php index 2ff2313c998..8590f4d95a4 100644 --- a/htdocs/core/modules/societe/mod_codecompta_digitaria.php +++ b/htdocs/core/modules/societe/mod_codecompta_digitaria.php @@ -127,7 +127,7 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode $texte .= $langs->trans('COMPANY_DIGITARIA_UNIQUE_CODE').' = '.yn(1)."
    \n"; } $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/societe/modules_societe.class.php b/htdocs/core/modules/societe/modules_societe.class.php index 105333d815b..867760432c3 100644 --- a/htdocs/core/modules/societe/modules_societe.class.php +++ b/htdocs/core/modules/societe/modules_societe.class.php @@ -25,6 +25,7 @@ * \brief File with parent class of submodules to manage numbering and document generation */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; /** @@ -32,11 +33,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; */ abstract class ModeleThirdPartyDoc extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules @@ -61,63 +57,8 @@ abstract class ModeleThirdPartyDoc extends CommonDocGenerator /** * Parent class for third parties code generators */ -abstract class ModeleThirdPartyCode +abstract class ModeleThirdPartyCode extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - /** - * @var array Error code (or message) array - */ - public $errors; - - - /** Returns the default description of the numbering pattern - * - * @param Translate $langs Object langs - * @return string Descriptive text - */ - public function info($langs) - { - $langs->load("bills"); - return $langs->trans("NoDescription"); - } - - /** Return name of module - * - * @param Translate $langs Object langs - * @return string Nom du module - */ - public function getNom($langs) - { - return $this->name; - } - - - /** Return an example of numbering - * - * @param Translate $langs Object langs - * @return string Example - */ - public function getExample($langs) - { - $langs->load("bills"); - return $langs->trans("NoExample"); - } - - /** - * 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() - { - return true; - } - /** * Return next value available * @@ -131,30 +72,6 @@ abstract class ModeleThirdPartyCode return $langs->trans("Function_getNextValue_InModuleNotWorking"); } - - /** - * Return version of module - * - * @return string Version - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } elseif ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } elseif ($this->version == 'dolibarr') { - return DOL_VERSION; - } elseif ($this->version) { - return $this->version; - } else { - return $langs->trans("NotAvailable"); - } - } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie la liste des modeles de numérotation @@ -273,74 +190,8 @@ abstract class ModeleThirdPartyCode /** * Parent class for third parties accountancy code generators */ -abstract class ModeleAccountancyCode +abstract class ModeleAccountancyCode extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - - /** - * Return description of module - * - * @param Translate $langs Object langs - * @return string Description of module - */ - public function info($langs) - { - $langs->load("bills"); - return $langs->trans("NoDescription"); - } - - /** - * Return an example of result returned by getNextValue - * - * @param Translate $langs Object langs - * @param societe $objsoc Object thirdparty - * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) - * @return string Example - */ - public function getExample($langs, $objsoc = 0, $type = -1) - { - $langs->load("bills"); - return $langs->trans("NoExample"); - } - - /** - * 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() - { - return true; - } - - /** - * Return version of module - * - * @return string Version - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } elseif ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } elseif ($this->version == 'dolibarr') { - return DOL_VERSION; - } elseif ($this->version) { - return $this->version; - } else { - return $langs->trans("NotAvailable"); - } - } - /** * Return description of module parameters * @@ -351,7 +202,7 @@ abstract class ModeleAccountancyCode */ public function getToolTip($langs, $soc, $type) { - global $conf, $db; + global $db; $langs->load("admin"); diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php index 5aae143fc2b..fa7c0160eba 100644 --- a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php +++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php @@ -37,17 +37,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; */ class doc_generic_stock_odt extends ModelePDFStock { - /** - * Issuer - * @var Societe - */ - public $emetteur; - /** * @var string Dolibarr version of the loaded document */ public $version = 'dolibarr'; + /** * Constructor * @@ -138,17 +133,18 @@ class doc_generic_stock_odt extends ModelePDFStock } } $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp .= '

    '.$langs->trans("ExampleOfDirectoriesForModelGen").''; // Add list of substitution keys $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); $texte .= '
    '; $texte .= ''; $texte .= '
    '; - $texte .= ''; + $texte .= ''; $texte .= '
    '; // Scan directories @@ -180,16 +176,11 @@ class doc_generic_stock_odt extends ModelePDFStock } $texte .= ' '; $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= ''; $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte .= ''; - $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index 23e8deb4aee..35cf7c8e560 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -38,38 +38,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; */ class pdf_standard extends ModelePDFStock { - /** - * @var DoliDb Database handler - */ - public $db; - - /** - * @var string model name - */ - public $name; - - /** - * @var string model description (short text) - */ - public $description; - - /** - * @var string document type - */ - public $type; - - /** - * Dolibarr version of the loaded document - * @var string - */ - public $version = 'dolibarr'; - - /** - * Issuer - * @var Societe - */ - public $emetteur; - public $wref; public $posxdesc; public $posxlabel; @@ -111,7 +79,6 @@ class pdf_standard extends ModelePDFStock $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); $this->option_logo = 1; // Display logo - $this->option_codestockservice = 0; // Display product-service code $this->option_multilang = 1; // Available in several languages $this->option_freetext = 0; // Support add of a personalised text diff --git a/htdocs/core/modules/stock/modules_stock.php b/htdocs/core/modules/stock/modules_stock.php index d1dc684d1d2..e0acbea66e5 100644 --- a/htdocs/core/modules/stock/modules_stock.php +++ b/htdocs/core/modules/stock/modules_stock.php @@ -24,44 +24,29 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; abstract class ModelePDFStock extends CommonDocGenerator { /** - * @var string Error code (or message) + * @var DoliDb Database handler */ - public $error = ''; + public $db; /** - * @var int page_largeur + * @var string model name */ - public $page_largeur; + public $name; /** - * @var int page_hauteur + * @var string model description (short text) */ - public $page_hauteur; + public $description; /** - * @var array format + * @var string document type */ - public $format; + public $type; /** - * @var int marge_gauche + * @var string Dolibarr version of the loaded document */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; + public $version = 'dolibarr'; // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php index 14ee86bccf0..2774358e2e3 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php @@ -66,46 +66,17 @@ class pdf_eagle extends ModelePDFStockTransfer public $version = 'dolibarr'; /** - * @var int page_largeur + * @var int posx lot */ - public $page_largeur; + public $posxlot; /** - * @var int page_hauteur + * @var int posx weightvol */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - /** - * Issuer - * @var Societe object that emits - */ - public $emetteur; - + public $posxweightvol; + public $posxwarehousesource; + public $posxwarehousedestination; + public $atLeastOneBatch; /** * Constructor @@ -177,13 +148,13 @@ class pdf_eagle extends ModelePDFStockTransfer /** * Function to build pdf onto disk * - * @param Object $object Object StockTransfer to generate (or id if old method) - * @param Translate $outputlangs Lang output object - * @param string $srctemplatepath Full path of source filename for generator using a template file - * @param int $hidedetails Do not show line details - * @param int $hidedesc Do not show desc - * @param int $hideref Do not show ref - * @return int 1=OK, 0=KO + * @param StockTransfer $object Object StockTransfer to generate (or id if old method) + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @return int 1=OK, 0=KO */ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { @@ -461,14 +432,14 @@ class pdf_eagle extends ModelePDFStockTransfer $object->lines[$i]->fetch_product(); $object->lines[$i]->label = $object->lines[$i]->product->label; $object->lines[$i]->description = $object->lines[$i]->product->description; - $object->lines[$i]->weight = $object->lines[$i]->product->weight; - $object->lines[$i]->weight_units = $object->lines[$i]->product->weight_units; - $object->lines[$i]->length = $object->lines[$i]->product->length; - $object->lines[$i]->length_units = $object->lines[$i]->product->length_units; - $object->lines[$i]->surface = $object->lines[$i]->product->surface; + $object->lines[$i]->weight = $object->lines[$i]->product->weight; + $object->lines[$i]->weight_units = $object->lines[$i]->product->weight_units; + $object->lines[$i]->length = $object->lines[$i]->product->length; + $object->lines[$i]->length_units = $object->lines[$i]->product->length_units; + $object->lines[$i]->surface = $object->lines[$i]->product->surface; $object->lines[$i]->surface_units = $object->lines[$i]->product->surface_units; - $object->lines[$i]->volume = $object->lines[$i]->product->volume; - $object->lines[$i]->volume_units = $object->lines[$i]->product->volume_units; + $object->lines[$i]->volume = $object->lines[$i]->product->volume; + $object->lines[$i]->volume_units = $object->lines[$i]->product->volume_units; $object->lines[$i]->fk_unit = $object->lines[$i]->product->fk_unit; //var_dump($object->lines[$i]);exit; } @@ -673,12 +644,12 @@ class pdf_eagle extends ModelePDFStockTransfer /** * Show total to pay * - * @param PDF $pdf Object PDF - * @param Facture $object Object invoice - * @param int $deja_regle Montant deja regle - * @param int $posy Position depart - * @param Translate $outputlangs Objet langs - * @return int Position pour suite + * @param PDF $pdf Object PDF + * @param StockTransfer $object Object invoice + * @param int $deja_regle Montant deja regle + * @param int $posy Position depart + * @param Translate $outputlangs Objet langs + * @return int Position pour suite */ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { @@ -861,10 +832,10 @@ class pdf_eagle extends ModelePDFStockTransfer } /** - * Used to know if at least one line of Stock Transfer object has a batch set - * - * @param Object $object Stock Transfer object - * @return boolean true if at least one line has batch set, false if not + * Used to know if at least one line of Stock Transfer object has a batch set + * + * @param StockTransfer $object Stock Transfer object + * @return boolean true if at least one line has batch set, false if not  */ public function atLeastOneBatch($object) { @@ -873,7 +844,9 @@ class pdf_eagle extends ModelePDFStockTransfer $atLeastOneBatch = false; - if (empty($conf->productbatch->enabled)) return false; + if (!isModEnabled('productbatch')) { + return false; + } foreach ($object->lines as $line) { if (!empty($line->batch)) { @@ -888,10 +861,10 @@ class pdf_eagle extends ModelePDFStockTransfer /** * Show top header of page. * - * @param TCPDF $pdf Object PDF - * @param Object $object Object to show - * @param int $showaddress 0=no, 1=yes - * @param Translate $outputlangs Object lang for output + * @param TCPDF $pdf Object PDF + * @param StockTransfer $object Object to show + * @param int $showaddress 0=no, 1=yes + * @param Translate $outputlangs Object lang for output * @return void */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) @@ -1147,11 +1120,11 @@ class pdf_eagle extends ModelePDFStockTransfer /** * Show footer of page. Need this->emetteur object * - * @param PDF $pdf PDF - * @param Object $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return int Return height of bottom margin including footer text + * @param PDF $pdf PDF + * @param StockTransfer $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text */ protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php index 83f0cb802e9..101ee0f43f6 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php @@ -74,47 +74,6 @@ class pdf_eagle_proforma extends ModelePDFCommandes */ public $version = 'dolibarr'; - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - /** - * Issuer - * @var Societe Object that emits - */ - public $emetteur; - /** * Constructor @@ -123,7 +82,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes */ public function __construct($db) { - global $conf, $langs, $mysoc; + global $langs, $mysoc; // Translations $langs->loadLangs(array("main", "bills", "products")); diff --git a/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php b/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php index c19067c019d..8eac5b14f4b 100644 --- a/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php +++ b/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php @@ -55,11 +55,12 @@ class mod_stocktransfer_advanced extends ModeleNumRefStockTransfer /** * Returns the description of the numbering model * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { - global $conf, $langs, $db; + global $langs, $db; $langs->load("bills"); @@ -82,7 +83,7 @@ class mod_stocktransfer_advanced extends ModeleNumRefStockTransfer $texte .= ''.$langs->trans("Mask").':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; diff --git a/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php b/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php index fc647d3135c..301bee244c0 100644 --- a/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php +++ b/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php @@ -53,9 +53,10 @@ class mod_stocktransfer_standard extends ModeleNumRefStockTransfer /** * Return description of numbering module * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); diff --git a/htdocs/core/modules/stocktransfer/modules_stocktransfer.php b/htdocs/core/modules/stocktransfer/modules_stocktransfer.php index 2a7218543e7..c68ae5d3d7a 100644 --- a/htdocs/core/modules/stocktransfer/modules_stocktransfer.php +++ b/htdocs/core/modules/stocktransfer/modules_stocktransfer.php @@ -30,6 +30,7 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit @@ -38,7 +39,6 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // requir */ abstract class ModelePDFStockTransfer extends CommonDocGenerator { - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules @@ -65,85 +65,7 @@ abstract class ModelePDFStockTransfer extends CommonDocGenerator /** * Parent class to manage numbering of StockTransfer */ -abstract class ModeleNumRefStockTransfer +abstract class ModeleNumRefStockTransfer extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Returns the default description of the numbering template - * - * @return string Descriptive text - */ - public function info() - { - global $langs; - $langs->load("stocktransfer@stocktransfer"); - return $langs->trans("NoDescription"); - } - - /** - * Returns an example of numbering - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("stocktransfer@stocktransfer"); - return $langs->trans("NoExample"); - } - - /** - * Checks if the numbers already in the database do not - * cause conflicts that would prevent this numbering working. - * - * @param Object $object Object we need next value for - * @return boolean false if conflict, true if ok - */ - public function canBeActivated($object) - { - return true; - } - - /** - * Returns next assigned value - * - * @param Object $object Object we need next value for - * @return string Valeur - */ - public function getNextValue($object) - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Returns version of numbering module - * - * @return string Valeur - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); - if ($this->version == 'dolibarr') return DOL_VERSION; - if ($this->version) return $this->version; - return $langs->trans("NotAvailable"); - } + // No overload code } diff --git a/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php b/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php index 6031907b305..56175353538 100644 --- a/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php @@ -146,17 +146,18 @@ class doc_generic_supplier_invoice_odt extends ModelePDFSuppliersInvoices } $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp .= '

    '.$langs->trans("ExampleOfDirectoriesForModelGen").''; // Add list of substitution keys $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); $texte .= '
    '; $texte .= ''; $texte .= '
    '; - $texte .= ''; + $texte .= ''; $texte .= '
    '; // Scan directories @@ -182,15 +183,10 @@ class doc_generic_supplier_invoice_odt extends ModelePDFSuppliersInvoices // Add input to upload a new template file. $texte .= '
    '.$langs->trans("UploadNewTemplate").' '; $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= '
    '; $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte .= ''; - $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php index 3dfb6bfd4d2..3172a54711c 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -69,48 +69,6 @@ class pdf_canelle extends ModelePDFSuppliersInvoices */ public $version = 'dolibarr'; - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - /** - * Issuer - * @var Societe object that emits - */ - public $emetteur; - - /** * Constructor @@ -649,12 +607,12 @@ class pdf_canelle extends ModelePDFSuppliersInvoices /** * Show total to pay * - * @param TCPDF $pdf Object PDF - * @param Object $object Object invoice - * @param int $deja_regle Amount already paid (in the currency of invoice) - * @param int $posy Position depart - * @param Translate $outputlangs Objet langs - * @return int Position pour suite + * @param TCPDF $pdf Object PDF + * @param FactureFournisseur $object Object invoice + * @param int $deja_regle Amount already paid (in the currency of invoice) + * @param int $posy Position depart + * @param Translate $outputlangs Objet langs + * @return int Position of cursor after output */ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php index 253faa62882..bfb1d006106 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php @@ -66,9 +66,10 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices /** * Return description of numbering model * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; $langs->load("bills"); @@ -90,9 +91,10 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices /** * Tests if the numbers already in the database do not cause conflicts that would prevent this numbering. * - * @return boolean false if conflict, true if ok + * @param Object $object Object we need next value for + * @return boolean false if KO (there is a conflict), true if OK */ - public function canBeActivated() + public function canBeActivated($object) { global $conf, $langs, $db; diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php index 1a86dfbe611..f14a5df4605 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php @@ -63,9 +63,10 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices /** * Returns the description of the model numbering * - * @return string Description Text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs, $db; @@ -95,7 +96,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices $texte .= ':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; diff --git a/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php b/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php index f32ae09ae6d..c42cfc88c8c 100644 --- a/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php +++ b/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php @@ -26,6 +26,7 @@ * and parent class for supplier invoices numbering models */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit @@ -34,12 +35,6 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // requir */ abstract class ModelePDFSuppliersInvoices extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation models @@ -64,90 +59,7 @@ abstract class ModelePDFSuppliersInvoices extends CommonDocGenerator /** * Parent Class of numbering models of suppliers invoices references */ -abstract class ModeleNumRefSuppliersInvoices +abstract class ModeleNumRefSuppliersInvoices extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - public $version; - - - /** Return if a model can be used or not - * - * @return boolean true if model can be used - */ - public function isEnabled() - { - return true; - } - - /** Returns the default description of the model numbering - * - * @return string Description Text - */ - public function info() - { - global $langs; - $langs->load("invoices"); - return $langs->trans("NoDescription"); - } - - /** Returns a numbering example - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("invoices"); - return $langs->trans("NoExample"); - } - - /** Tests if the numbers already in force in the database do not cause conflicts that would prevent this numbering. - * - * @return boolean false if conflict, true if ok - */ - public function canBeActivated() - { - return true; - } - - /** Returns next value assigned - * - * @param Societe $objsoc Object third party - * @param Object $object Object - * @param string $mode 'next' for next value or 'last' for last value - * @return string Value if OK, 0 if KO - */ - public function getNextValue($objsoc, $object, $mode = 'next') - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** Returns version of the model numbering - * - * @return string Value - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } - if ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } - if ($this->version == 'dolibarr') { - return DOL_VERSION; - } - if ($this->version) { - return $this->version; - } - return $langs->trans("NotAvailable"); - } + // No overload code } diff --git a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php index 285be7c2799..1d5f194e9ab 100644 --- a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php +++ b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php @@ -142,17 +142,18 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders } } $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp .= '

    '.$langs->trans("ExampleOfDirectoriesForModelGen").''; // Add list of substitution keys $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); $texte .= '
    '; $texte .= ''; $texte .= '
    '; - $texte .= ''; + $texte .= ''; $texte .= '
    '; // Scan directories @@ -178,15 +179,10 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders // Add input to upload a new template file. $texte .= '
    '.$langs->trans("UploadNewTemplate").' '; $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= '
    '; $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte .= ''; - $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index d787a1d8dfe..cbddbf76c9b 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -72,47 +72,6 @@ class pdf_cornas extends ModelePDFSuppliersOrders */ public $version = 'dolibarr'; - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - /** - * Issuer - * @var Societe object that emits - */ - public $emetteur; - /** * Constructor @@ -161,6 +120,8 @@ class pdf_cornas extends ModelePDFSuppliersOrders // Define position of columns $this->posxdesc = $this->marge_gauche + 1; // For module retrocompatibility support durring PDF transition: TODO remove this at the end + $this->tabTitleHeight = 5; // default height + $this->tva = array(); $this->tva_array = array(); $this->localtax1 = array(); @@ -511,11 +472,11 @@ class pdf_cornas extends ModelePDFSuppliersOrders $height_note = 0; } - $nexY = $tab_top + 5; - // Use new auto collum system $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref); + $nexY = $tab_top + $this->tabTitleHeight; + // Loop on each lines $pageposbeforeprintlines = $pdf->getPage(); $pagenb = $pageposbeforeprintlines; @@ -1193,29 +1154,10 @@ class pdf_cornas extends ModelePDFSuppliersOrders // Output Rect $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter - foreach ($this->cols as $colKey => $colDef) { - if (!$this->getColumnStatus($colKey)) { - continue; - } - - // get title label - $colDef['title']['label'] = !empty($colDef['title']['label']) ? $colDef['title']['label'] : $outputlangs->transnoentities($colDef['title']['textkey']); - - // Add column separator - if (!empty($colDef['border-left'])) { - $pdf->line($colDef['xStartPos'], $tab_top, $colDef['xStartPos'], $tab_top + $tab_height); - } - - if (empty($hidetop)) { - $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0]); - - $textWidth = $colDef['width'] - $colDef['title']['padding'][3] - $colDef['title']['padding'][1]; - $pdf->MultiCell($textWidth, 2, $colDef['title']['label'], '', $colDef['title']['align']); - } - } + $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); if (empty($hidetop)) { - $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line takes a position y in 2nd parameter and 4th parameter + $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter } } @@ -1555,7 +1497,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders 'align' => 'L', // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label // 'label' => ' ', // the final label - 'padding' => array(0.5, 1, 0.5, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), 'content' => array( 'align' => 'L', @@ -1656,7 +1598,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders $this->cols['totalexcltax'] = array( 'rank' => $rank, 'width' => 26, // in mm - 'status' => true, + 'status' => false, 'title' => array( 'textkey' => 'TotalHT' ), diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index 1b90c123e99..c62a26cb9dc 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -72,47 +72,6 @@ class pdf_muscadet extends ModelePDFSuppliersOrders */ public $version = 'dolibarr'; - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - /** - * Issuer - * @var Societe object that emits - */ - public $emetteur; - /** * Constructor 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 7ebc035ef61..f0e6c879e02 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php @@ -72,9 +72,10 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders /** * Return description of numbering module * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -96,9 +97,10 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders * 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 + * @param Object $object Object we need next value for + * @return boolean false if KO (there is a conflict), true if OK */ - public function canBeActivated() + public function canBeActivated($object) { global $conf, $langs, $db; 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 f829048e623..9132d35c8a2 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php @@ -59,11 +59,12 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders /** * Returns the description of the numbering model * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { - global $db, $conf, $langs; + global $db, $langs; // Load translation files required by the page $langs->loadLangs(array("bills", "admin")); @@ -87,7 +88,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders $texte .= ''.$langs->trans("Mask").':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; diff --git a/htdocs/core/modules/supplier_order/modules_commandefournisseur.php b/htdocs/core/modules/supplier_order/modules_commandefournisseur.php index 5325fdf8ca5..c59db0ada98 100644 --- a/htdocs/core/modules/supplier_order/modules_commandefournisseur.php +++ b/htdocs/core/modules/supplier_order/modules_commandefournisseur.php @@ -29,6 +29,7 @@ * and parent class for supplier orders numbering models */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit @@ -54,12 +55,6 @@ abstract class ModelePDFSuppliersOrders extends CommonDocGenerator public $atleastoneratenotnull = 0; public $atleastonediscount = 0; - /** - * @var string Error code (or message) - */ - public $error = ''; - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation models @@ -86,89 +81,7 @@ abstract class ModelePDFSuppliersOrders extends CommonDocGenerator /** * Parent Class of numbering models of suppliers orders references */ -abstract class ModeleNumRefSuppliersOrders +abstract class ModeleNumRefSuppliersOrders extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - public $version; - - - /** Return if a model can be used or not - * - * @return boolean true if model can be used - */ - public function isEnabled() - { - return true; - } - - /** Returns default description of numbering model - * - * @return string Description Text - */ - public function info() - { - global $langs; - $langs->load("orders"); - return $langs->trans("NoDescription"); - } - - /** Returns a numbering example - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("orders"); - return $langs->trans("NoExample"); - } - - /** Tests if existing numbers make problems with numbering - * - * @return boolean false if conflict, true if ok - */ - public function canBeActivated() - { - return true; - } - - /** Returns next value assigned - * - * @param Societe $objsoc Object third party - * @param Object $object Object - * @return string Valeur - */ - public function getNextValue($objsoc = 0, $object = '') - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** Returns version of the numbering model - * - * @return string Value - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } - if ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } - if ($this->version == 'dolibarr') { - return DOL_VERSION; - } - if ($this->version) { - return $this->version; - } - return $langs->trans("NotAvailable"); - } + // No overload code } diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index 31d5afbfcd1..35d74ec432a 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -70,12 +70,6 @@ class pdf_standard extends ModelePDFSuppliersPayments */ public $version = 'dolibarr'; - /** - * Issuer - * @var Societe - */ - public $emetteur; - public $posxdate; public $posxreffacturefourn; public $posxreffacture; 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 a3e938a38ac..7da2543ab00 100644 --- a/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php +++ b/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php @@ -57,11 +57,12 @@ class mod_supplier_payment_brodator extends ModeleNumRefSupplierPayments /** * Returns the description of the numbering model * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { - global $conf, $langs, $db; + global $langs, $db; $langs->load("bills"); @@ -84,7 +85,7 @@ class mod_supplier_payment_brodator extends ModeleNumRefSupplierPayments $texte .= ''.$langs->trans("Mask").':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; diff --git a/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php b/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php index f86950c24d6..d436d96fde0 100644 --- a/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php +++ b/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php @@ -58,9 +58,10 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments /** * Return description of numbering module * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -82,9 +83,10 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments * 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 + * @param Object $object Object we need next value for + * @return boolean false if KO (there is a conflict), true if OK */ - public function canBeActivated() + public function canBeActivated($object) { global $conf, $langs, $db; diff --git a/htdocs/core/modules/supplier_payment/modules_supplier_payment.php b/htdocs/core/modules/supplier_payment/modules_supplier_payment.php index 9e6358fe437..a748d734d51 100644 --- a/htdocs/core/modules/supplier_payment/modules_supplier_payment.php +++ b/htdocs/core/modules/supplier_payment/modules_supplier_payment.php @@ -17,6 +17,7 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; /** @@ -24,47 +25,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; */ abstract class ModelePDFSuppliersPayments extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation models @@ -91,94 +51,7 @@ abstract class ModelePDFSuppliersPayments extends CommonDocGenerator * * Payment numbering references mother class */ - -abstract class ModeleNumRefSupplierPayments +abstract class ModeleNumRefSupplierPayments extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - public $version; - - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Return the default description of numbering module - * - * @return string Descriptive text - */ - public function info() - { - global $langs; - $langs->load("bills"); - return $langs->trans("NoDescription"); - } - - /** - * Return numbering example - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("bills"); - return $langs->trans("NoExample"); - } - - /** - * 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() - { - return true; - } - - /** - * Returns the next value - * - * @param Societe $objsoc Object thirdparty - * @param Object $object Object we need next value for - * @return string Valeur - */ - public function getNextValue($objsoc, $object) - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Returns the module numbering version - * - * @return string Value - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } elseif ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } elseif ($this->version == 'dolibarr') { - return DOL_VERSION; - } elseif ($this->version) { - return $this->version; - } - return $langs->trans("NotAvailable"); - } + // No overload code } 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 bbc0fdb583a..32b6b64694a 100644 --- a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php @@ -38,12 +38,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; */ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal { - /** - * Issuer - * @var Societe - */ - public $emetteur; - /** * Dolibarr version of the loaded document * @var string @@ -104,7 +98,7 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal */ public function info($langs) { - global $conf, $langs; + global $langs; // Load translation files required by the page $langs->loadLangs(array('companies', 'errors')); @@ -149,17 +143,18 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal } } $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp .= '

    '.$langs->trans("ExampleOfDirectoriesForModelGen").''; // Add list of substitution keys $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); $texte .= '
    '; $texte .= ''; $texte .= '
    '; - $texte .= ''; + $texte .= ''; $texte .= '
    '; // Scan directories @@ -209,11 +204,6 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte .= ''; - $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 84c13dc0ee6..b2739678701 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -69,47 +69,6 @@ class pdf_aurore extends ModelePDFSupplierProposal */ public $version = 'dolibarr'; - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - /** - * Issuer - * @var Societe - */ - public $emetteur; - /** * Constructor diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php new file mode 100644 index 00000000000..d876d5a6b12 --- /dev/null +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php @@ -0,0 +1,1617 @@ + + * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2007 Franky Van Liedekerke + * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2015 Marcos García + * Copyright (C) 2017 Ferran Marcet + * Copyright (C) 2018-2022 Frédéric France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/supplir_proposal/doc/pdf_zenith.modules.php + * \ingroup fournisseur + * \brief File of class to generate suppliers proposals from zenith model + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_proposal/modules_supplier_proposal.php'; +require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; + + +/** + * Class to generate the supplier proposals with the zenith model + */ +class pdf_zenith extends ModelePDFSupplierProposal +{ + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model name + */ + public $name; + + /** + * @var string model description (short text) + */ + public $description; + + /** + * @var int Save the name of generated file as the main doc when generating a doc with this template + */ + public $update_main_doc_field; + + /** + * @var string document type + */ + public $type; + + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $conf, $langs, $mysoc; + + // Load translation files required by the page + $langs->loadLangs(array("main", "bills")); + + $this->db = $db; + $this->name = "zenith"; + $this->description = $langs->trans('DocModelZenithDescription'); + $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template + + // Page size for A4 format + $this->type = 'pdf'; + $formatarray = pdf_getFormat(); + $this->page_largeur = $formatarray['width']; + $this->page_hauteur = $formatarray['height']; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10); + $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); + $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); + $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); + + $this->option_logo = 1; // Display logo + $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION + $this->option_modereg = 1; // Display payment mode + $this->option_condreg = 1; // Display payment terms + $this->option_multilang = 1; //Available in several languages + $this->option_escompte = 0; // Displays if there has been a discount + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 1; // Support add of a watermark on drafts + + // Get source company + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined + } + + // Define position of columns + $this->posxdesc = $this->marge_gauche + 1; // For module retrocompatibility support durring PDF transition: TODO remove this at the end + + $this->tabTitleHeight = 5; // default height + + $this->tva = array(); + $this->tva_array = array(); + $this->localtax1 = array(); + $this->localtax2 = array(); + $this->atleastoneratenotnull = 0; + $this->atleastonediscount = 0; + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Function to build pdf onto disk + * + * @param SupplierProposal $object Id of object to generate + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @return int 1=OK, 0=KO + */ + public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + { + // phpcs:enable + global $user, $langs, $conf, $hookmanager, $mysoc, $nblines; + + if (!is_object($outputlangs)) { + $outputlangs = $langs; + } + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO + if (!empty($conf->global->MAIN_USE_FPDF)) { + $outputlangs->charset_output = 'ISO-8859-1'; + } + + // Load translation files required by the page + $outputlangs->loadLangs(array("main", "supplier_proposal", "companies", "bills", "dict", "products")); + + global $outputlangsbis; + $outputlangsbis = null; + if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { + $outputlangsbis = new Translate('', $conf); + $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); + $outputlangsbis->loadLangs(array("main", "supplier_proposal", "companies", "bills", "dict", "products")); + } + + $nblines = count($object->lines); + + $hidetop = 0; + if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) { + $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE; + } + + // Loop on each lines to detect if there is at least one image to show + $realpatharray = array(); + if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_PROPOSAL_WITH_PICTURE)) { + for ($i = 0; $i < $nblines; $i++) { + if (empty($object->lines[$i]->fk_product)) { + continue; + } + + $objphoto = new Product($this->db); + $objphoto->fetch($object->lines[$i]->fk_product); + + if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) { + $pdir = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/"; + $dir = $conf->product->dir_output.'/'.$pdir; + } else { + $pdir = get_exdir($objphoto->id, 0, 0, 0, $objphoto, 'product'); + $dir = $conf->product->dir_output.'/'.$pdir; + } + + $realpath = ''; + foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) { + if (!getDolGlobalInt('CAT_HIGH_QUALITY_IMAGES')) { // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo + if ($obj['photo_vignette']) { + $filename = $obj['photo_vignette']; + } else { + $filename = $obj['photo']; + } + } else { + $filename = $obj['photo']; + } + $realpath = $dir.$filename; + break; + } + + if ($realpath) { + $realpatharray[$i] = $realpath; + } + } + } + if (count($realpatharray) == 0) { + $this->posxpicture = $this->posxtva; + } + + if ($conf->supplier_proposal->dir_output) { + $object->fetch_thirdparty(); + + $deja_regle = 0; + $amount_credit_notes_included = 0; + $amount_deposits_included = 0; + //$amount_credit_notes_included = $object->getSumCreditNotesUsed(); + //$amount_deposits_included = $object->getSumDepositsUsed(); + + // Definition of $dir and $file + if ($object->specimen) { + $dir = $conf->supplier_proposal->dir_output; + $file = $dir."/SPECIMEN.pdf"; + } else { + $objectref = dol_sanitizeFileName($object->ref); + $objectrefsupplier = dol_sanitizeFileName($object->ref_supplier); + $dir = $conf->supplier_proposal->dir_output.'/'.$objectref; + $file = $dir."/".$objectref.".pdf"; + if (!empty($conf->global->SUPPLIER_REF_IN_NAME)) { + $file = $dir."/".$objectref.($objectrefsupplier ? "_".$objectrefsupplier : "").".pdf"; + } + } + + if (!file_exists($dir)) { + if (dol_mkdir($dir) < 0) { + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); + return 0; + } + } + + if (file_exists($dir)) { + // Add pdfgeneration hook + if (!is_object($hookmanager)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($this->db); + } + $hookmanager->initHooks(array('pdfgeneration')); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); + global $action; + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + + $nblines = count($object->lines); + + $pdf = pdf_getInstance($this->format); + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance + $heightforinfotot = 50; // Height reserved to output the info and total part + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) { + $heightforfooter += 6; + } + $pdf->SetAutoPageBreak(1, 0); + + if (class_exists('TCPDF')) { + $pdf->setPrintHeader(false); + $pdf->setPrintFooter(false); + } + $pdf->SetFont(pdf_getPDFFont($outputlangs)); + // Set path to the background PDF File + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { + $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); + $tplidx = $pdf->importPage(1); + } + + $pdf->Open(); + $pagenb = 0; + $pdf->SetDrawColor(128, 128, 128); + + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); + $pdf->SetSubject($outputlangs->transnoentities("SupplierProposal")); + $pdf->SetCreator("Dolibarr ".DOL_VERSION); + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("SupplierProposal")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); + if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) { + $pdf->SetCompression(false); + } + + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + + // Does we have at least one line with discount $this->atleastonediscount + foreach ($object->lines as $line) { + if ($line->remise_percent) { + $this->atleastonediscount = true; + break; + } + } + + // New page + $pdf->AddPage(); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + $pagenb++; + $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->SetTextColor(0, 0, 0); + + $tab_top = 90 + $top_shift; + $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10); + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; + + // Incoterm + if (isModEnabled('incoterm')) { + $desc_incoterms = $object->getIncotermsForPDF(); + if ($desc_incoterms) { + $tab_top -= 2; + + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); + $nexY = $pdf->GetY(); + $height_incoterms = $nexY - $tab_top; + + // Rect takes a length in 3rd parameter + $pdf->SetDrawColor(192, 192, 192); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); + + $tab_top = $nexY + 6; + } + } + + // Affiche notes + $notetoshow = empty($object->note_public) ? '' : $object->note_public; + + // Extrafields in note + $extranote = $this->getExtrafieldsInHtml($object, $outputlangs); + if (!empty($extranote)) { + $notetoshow = dol_concatdesc($notetoshow, $extranote); + } + + $pagenb = $pdf->getPage(); + if ($notetoshow) { + $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite; + $pageposbeforenote = $pagenb; + + $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); + $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow); + + $tab_top -= 2; + + $pdf->startTransaction(); + + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); + // Description + $pageposafternote = $pdf->getPage(); + $posyafter = $pdf->GetY(); + + if ($pageposafternote > $pageposbeforenote) { + $pdf->rollbackTransaction(true); + + // prepar pages to receive notes + while ($pagenb < $pageposafternote) { + $pdf->AddPage(); + $pagenb++; + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { + $this->_pagehead($pdf, $object, 0, $outputlangs); + } + // $this->_pagefoot($pdf,$object,$outputlangs,1); + $pdf->setTopMargin($tab_top_newpage); + // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); + } + + // back to start + $pdf->setPage($pageposbeforenote); + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); + $pageposafternote = $pdf->getPage(); + + $posyafter = $pdf->GetY(); + + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // There is no space left for total+free text + $pdf->AddPage('', '', true); + $pagenb++; + $pageposafternote++; + $pdf->setPage($pageposafternote); + $pdf->setTopMargin($tab_top_newpage); + // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); + //$posyafter = $tab_top_newpage; + } + + + // apply note frame to previus pages + $i = $pageposbeforenote; + while ($i < $pageposafternote) { + $pdf->setPage($i); + + + $pdf->SetDrawColor(128, 128, 128); + // Draw note frame + if ($i > $pageposbeforenote) { + $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter); + $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); + } else { + $height_note = $this->page_hauteur - ($tab_top + $heightforfooter); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); + } + + // Add footer + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $this->_pagefoot($pdf, $object, $outputlangs, 1); + + $i++; + } + + // apply note frame to last page + $pdf->setPage($pageposafternote); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { + $this->_pagehead($pdf, $object, 0, $outputlangs); + } + $height_note = $posyafter - $tab_top_newpage; + $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); + } else { + // No pagebreak + $pdf->commitTransaction(); + $posyafter = $pdf->GetY(); + $height_note = $posyafter - $tab_top; + $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); + + + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { + // not enough space, need to add page + $pdf->AddPage('', '', true); + $pagenb++; + $pageposafternote++; + $pdf->setPage($pageposafternote); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { + $this->_pagehead($pdf, $object, 0, $outputlangs); + } + + $posyafter = $tab_top_newpage; + } + } + + $tab_height = $tab_height - $height_note; + $tab_top = $posyafter + 6; + } else { + $height_note = 0; + } + + // Use new auto collum system + $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref); + + $nexY = $tab_top + $this->tabTitleHeight; + + // Loop on each lines + $pageposbeforeprintlines = $pdf->getPage(); + $pagenb = $pageposbeforeprintlines; + for ($i = 0; $i < $nblines; $i++) { + $curY = $nexY; + $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetTextColor(0, 0, 0); + + // Define size of image if we need it + $imglinesize = array(); + if (!empty($realpatharray[$i])) { + $imglinesize = pdf_getSizeForImage($realpatharray[$i]); + } + + $pdf->setTopMargin($tab_top_newpage); + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore = $pdf->getPage(); + + $showpricebeforepagebreak = 1; + $posYAfterImage = 0; + $posYAfterDescription = 0; + + // We start with Photo of product line + if ($this->getColumnStatus('photo')) { + // We start with Photo of product line + if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page + $pdf->AddPage('', '', true); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + $pdf->setPage($pageposbefore + 1); + + $curY = $tab_top_newpage; + + // Allows data in the first page if description is long enough to break in multiples pages + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) { + $showpricebeforepagebreak = 1; + } else { + $showpricebeforepagebreak = 0; + } + } + + if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) { + $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi + // $pdf->Image does not increase value return by getY, so we save it manually + $posYAfterImage = $curY + $imglinesize['height']; + } + } + // Description of product line + $curX = $this->posxdesc - 1; + $showpricebeforepagebreak = 1; + + if ($this->getColumnStatus('desc')) { + $pdf->startTransaction(); + $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc, 1); + + $pageposafter = $pdf->getPage(); + if ($pageposafter > $pageposbefore) { // There is a pagebreak + $pdf->rollbackTransaction(true); + + $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc, 1); + + $pageposafter = $pdf->getPage(); + $posyafter = $pdf->GetY(); + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text + if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page + $pdf->AddPage('', '', true); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + //if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($pageposafter + 1); + } + } else { + // We found a page break + // Allows data in the first page if description is long enough to break in multiples pages + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) { + $showpricebeforepagebreak = 1; + } else { + $showpricebeforepagebreak = 0; + } + } + } else // No pagebreak + { + $pdf->commitTransaction(); + } + $posYAfterDescription = $pdf->GetY(); + } + + $nexY = $pdf->GetY(); + $pageposafter = $pdf->getPage(); + $pdf->setPage($pageposbefore); + $pdf->setTopMargin($this->marge_haute); + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + + // We suppose that a too long description is moved completely on next page + if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; + } + + $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut + + // VAT Rate + if ($this->getColumnStatus('vat')) { + $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); + $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate); + $nexY = max($pdf->GetY(), $nexY); + } + + // Unit price before discount + if ($this->getColumnStatus('subprice')) { + $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); + $this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax); + $nexY = max($pdf->GetY(), $nexY); + } + + // Quantity + // Enough for 6 chars + if ($this->getColumnStatus('qty')) { + $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); + $this->printStdColumnContent($pdf, $curY, 'qty', $qty); + $nexY = max($pdf->GetY(), $nexY); + } + + + // Unit + if ($this->getColumnStatus('unit')) { + $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); + $this->printStdColumnContent($pdf, $curY, 'unit', $unit); + $nexY = max($pdf->GetY(), $nexY); + } + + // Discount on line + if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent) { + $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); + $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent); + $nexY = max($pdf->GetY(), $nexY); + } + + // Total HT line + if ($this->getColumnStatus('totalexcltax')) { + $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); + $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax); + $nexY = max($pdf->GetY(), $nexY); + } + + // Extrafields + if (!empty($object->lines[$i]->array_options)) { + foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) { + if ($this->getColumnStatus($extrafieldColKey)) { + $extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs); + $this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue); + $nexY = max($pdf->GetY(), $nexY); + } + } + } + + $parameters = array( + 'object' => $object, + 'i' => $i, + 'pdf' =>& $pdf, + 'curY' =>& $curY, + 'nexY' =>& $nexY, + 'outputlangs' => $outputlangs, + 'hidedetails' => $hidedetails + ); + $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook + + + // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva + if (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) { + $tvaligne = $object->lines[$i]->multicurrency_total_tva; + } else { + $tvaligne = $object->lines[$i]->total_tva; + } + + $localtax1ligne = $object->lines[$i]->total_localtax1; + $localtax2ligne = $object->lines[$i]->total_localtax2; + $localtax1_rate = $object->lines[$i]->localtax1_tx; + $localtax2_rate = $object->lines[$i]->localtax2_tx; + $localtax1_type = $object->lines[$i]->localtax1_type; + $localtax2_type = $object->lines[$i]->localtax2_type; + + // TODO remise_percent is an obsolete field for object parent + /*if (!empty($object->remise_percent)) { + $tvaligne -= ($tvaligne * $object->remise_percent) / 100; + } + if (!empty($object->remise_percent)) { + $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100; + } + if (!empty($object->remise_percent)) { + $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100; + }*/ + + $vatrate = (string) $object->lines[$i]->tva_tx; + + // Retrieve type from database for backward compatibility with old records + if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined + && (!empty($localtax1_rate) || !empty($localtax2_rate))) { // and there is local tax + $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $mysoc, $object->thirdparty); + $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] : ''; + $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] : ''; + } + + // retrieve global local tax + if ($localtax1_type && $localtax1ligne != 0) { + if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) { + $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne; + } else { + $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; + } + } + if ($localtax2_type && $localtax2ligne != 0) { + if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) { + $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne; + } else { + $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; + } + } + + if (($object->lines[$i]->info_bits & 0x01) == 0x01) { + $vatrate .= '*'; + } + + // Fill $this->tva and $this->tva_array + if (!isset($this->tva[$vatrate])) { + $this->tva[$vatrate] = 0; + } + $this->tva[$vatrate] += $tvaligne; + $vatcode = $object->lines[$i]->vat_src_code; + if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'])) { + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] = 0; + } + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); + + if ($posYAfterImage > $posYAfterDescription) { + $nexY = $posYAfterImage; + } + + // Add line + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { + $pdf->setPage($pageposafter); + $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); + //$pdf->SetDrawColor(190,190,200); + $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY); + $pdf->SetLineStyle(array('dash'=>0)); + } + + // Detect if some page were added automatically and output _tableau for past pages + while ($pagenb < $pageposafter) { + $pdf->setPage($pagenb); + if ($pagenb == $pageposbeforeprintlines) { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code); + } else { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); + } + $this->_pagefoot($pdf, $object, $outputlangs, 1); + $pagenb++; + $pdf->setPage($pagenb); + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { + $this->_pagehead($pdf, $object, 0, $outputlangs); + } + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + } + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { + if ($pagenb == $pageposafter) { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code); + } else { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); + } + $this->_pagefoot($pdf, $object, $outputlangs, 1); + // New page + $pdf->AddPage(); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + $pagenb++; + if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { + $this->_pagehead($pdf, $object, 0, $outputlangs); + } + } + } + + // Show square + if ($pagenb == $pageposbeforeprintlines) { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code); + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + } else { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + } + + // Affiche zone infos + $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); + + // Affiche zone totaux + $posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); + + // Affiche zone versements + if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) { + $posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs); + } + + // Pied de page + $this->_pagefoot($pdf, $object, $outputlangs); + if (method_exists($pdf, 'AliasNbPages')) { + $pdf->AliasNbPages(); + } + + $pdf->Close(); + + $pdf->Output($file, 'F'); + + // Add pdfgeneration hook + $hookmanager->initHooks(array('pdfgeneration')); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); + global $action; + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + $this->error = $hookmanager->error; + $this->errors = $hookmanager->errors; + } + + dolChmod($file); + + $this->result = array('fullpath'=>$file); + + return 1; // No error + } else { + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); + return 0; + } + } else { + $this->error = $langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR"); + return 0; + } + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Show payments table + * + * @param TCPDF $pdf Object PDF + * @param SupplierProposal $object Object supplier propsal + * @param int $posy Position y in PDF + * @param Translate $outputlangs Object langs for output + * @return int <0 if KO, >0 if OK + */ + protected function _tableau_versements(&$pdf, $object, $posy, $outputlangs) + { + // phpcs:enable + return 1; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Show miscellaneous information (payment mode, payment term, ...) + * + * @param TCPDF $pdf Object PDF + * @param SupplierProposal $object Object to show + * @param int $posy Y + * @param Translate $outputlangs Langs object + * @return integer + */ + protected function _tableau_info(&$pdf, $object, $posy, $outputlangs) + { + // phpcs:enable + global $conf, $mysoc; + $default_font_size = pdf_getPDFFontSize($outputlangs); + + $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE); + + // If France, show VAT mention if not applicable + if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) { + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); + + $posy = $pdf->GetY() + 4; + } + + $posxval = 52; + + // Show payments conditions + if (!empty($object->cond_reglement_code) || $object->cond_reglement) { + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); + $pdf->SetXY($this->marge_gauche, $posy); + $titre = $outputlangs->transnoentities("PaymentConditions").':'; + $pdf->MultiCell(80, 4, $titre, 0, 'L'); + + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); + $pdf->SetXY($posxval, $posy); + $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); + $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); + $pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L'); + + $posy = $pdf->GetY() + 3; + } + + // Show payment mode + if (!empty($object->mode_reglement_code)) { + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); + $pdf->SetXY($this->marge_gauche, $posy); + $titre = $outputlangs->transnoentities("PaymentMode").':'; + $pdf->MultiCell(80, 5, $titre, 0, 'L'); + + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); + $pdf->SetXY($posxval, $posy); + $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); + $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); + + $posy = $pdf->GetY() + 2; + } + + + return $posy; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Show total to pay + * + * @param TCPDF $pdf Object PDF + * @param Facture $object Object invoice + * @param int $deja_regle Montant deja regle + * @param int $posy Position depart + * @param Translate $outputlangs Objet langs + * @return int Position pour suite + */ + protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) + { + // phpcs:enable + global $conf, $mysoc; + + $default_font_size = pdf_getPDFFontSize($outputlangs); + + $tab2_top = $posy; + $tab2_hl = 4; + $pdf->SetFont('', '', $default_font_size - 1); + + // Tableau total + $col1x = 120; + $col2x = 170; + if ($this->page_largeur < 210) { // To work with US executive format + $col2x -= 20; + } + $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); + + $useborder = 0; + $index = 0; + + // Total HT + $pdf->SetFillColor(255, 255, 255); + $pdf->SetXY($col1x, $tab2_top); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); + + $total_ht = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht); + $pdf->SetXY($col2x, $tab2_top); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, 'R', 1); + + // Show VAT by rates and total + $pdf->SetFillColor(248, 248, 248); + + $this->atleastoneratenotnull = 0; + foreach ($this->tva as $tvakey => $tvaval) { + if ($tvakey > 0) { // On affiche pas taux 0 + $this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl = ''; + + if (preg_match('/\*/', $tvakey)) { + $tvakey = str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + + $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; + $totalvat .= vatrate($tvakey, 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); + } + } + if (!$this->atleastoneratenotnull) { // If no vat at all + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1); + + // Total LocalTax1 + if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION == 'localtax1on' && $object->total_localtax1 > 0) { + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code), 0, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1); + } + + // Total LocalTax2 + if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION == 'localtax2on' && $object->total_localtax2 > 0) { + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code), 0, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1); + } + } else { + //if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') + //{ + //Local tax 1 + foreach ($this->localtax1 as $localtax_type => $localtax_rate) { + if (in_array((string) $localtax_type, array('2', '4', '6'))) { + continue; + } + + foreach ($localtax_rate as $tvakey => $tvaval) { + if ($tvakey != 0) { // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl = ''; + if (preg_match('/\*/', $tvakey)) { + $tvakey = str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + } + } + } + + //if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') + //{ + //Local tax 2 + foreach ($this->localtax2 as $localtax_type => $localtax_rate) { + if (in_array((string) $localtax_type, array('2', '4', '6'))) { + continue; + } + + foreach ($localtax_rate as $tvakey => $tvaval) { + if ($tvakey != 0) { // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl = ''; + if (preg_match('/\*/', $tvakey)) { + $tvakey = str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); + } + } + } + } + + // Total TTC + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->SetTextColor(0, 0, 60); + $pdf->SetFillColor(224, 224, 224); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); + + $total_ttc = (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1); + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->SetTextColor(0, 0, 0); + + $creditnoteamount = 0; + $depositsamount = 0; + //$creditnoteamount=$object->getSumCreditNotesUsed(); + //$depositsamount=$object->getSumDepositsUsed(); + //print "x".$creditnoteamount."-".$depositsamount;exit; + $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); + if (!empty($object->paye)) { + $resteapayer = 0; + } + + if ($deja_regle > 0) { + // Already paid + Deposits + $index++; + + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0); + + $index++; + $pdf->SetTextColor(0, 0, 60); + $pdf->SetFillColor(224, 224, 224); + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1); + + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->SetTextColor(0, 0, 0); + } + + $index++; + return ($tab2_top + ($tab2_hl * $index)); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Show table for lines + * + * @param TCPDF $pdf Object PDF + * @param string $tab_top Top position of table + * @param string $tab_height Height of table (rectangle) + * @param int $nexY Y (not used) + * @param Translate $outputlangs Langs object + * @param int $hidetop Hide top bar of array + * @param int $hidebottom Hide bottom bar of array + * @param string $currency Currency code + * @return void + */ + protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + { + global $conf; + + // Force to disable hidetop and hidebottom + $hidebottom = 0; + if ($hidetop) { + $hidetop = -1; + } + + $currency = !empty($currency) ? $currency : $conf->currency; + $default_font_size = pdf_getPDFFontSize($outputlangs); + + // Amount in (at tab_top - 1) + $pdf->SetTextColor(0, 0, 0); + $pdf->SetFont('', '', $default_font_size - 2); + + if (empty($hidetop)) { + $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); + $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); + + //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; + if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { + $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); + } + } + + $pdf->SetDrawColor(128, 128, 128); + $pdf->SetFont('', '', $default_font_size - 1); + + // Output Rect + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + + $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); + + if (empty($hidetop)) { + $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter + } + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Show top header of page. + * + * @param TCPDF $pdf Object PDF + * @param CommandeFournisseur $object Object to show + * @param int $showaddress 0=no, 1=yes + * @param Translate $outputlangs Object lang for output + * @return float|int + */ + protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + { + global $langs, $conf, $mysoc; + + $ltrdirection = 'L'; + if ($outputlangs->trans("DIRECTION") == 'rtl') $ltrdirection = 'R'; + + // Load translation files required by the page + $outputlangs->loadLangs(array("main", "supplier_proposal", "companies", "bills", "sendings")); + + $default_font_size = pdf_getPDFFontSize($outputlangs); + + // Do not add the BACKGROUND as this is for suppliers + //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); + + //Affiche le filigrane brouillon - Print Draft Watermark + /*if($object->statut==0 && getDolGlobalString('COMMANDE_DRAFT_WATERMARK')) + { + pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',getDolGlobalString('COMMANDE_DRAFT_WATERMARK')); + }*/ + //Print content + + $pdf->SetTextColor(0, 0, 60); + $pdf->SetFont('', 'B', $default_font_size + 3); + + $posx = $this->page_largeur - $this->marge_droite - 100; + $posy = $this->marge_haute; + + $pdf->SetXY($this->marge_gauche, $posy); + + // Logo + if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) { + if ($this->emetteur->logo) { + $logodir = $conf->mycompany->dir_output; + if (!empty($conf->mycompany->multidir_output[$object->entity])) { + $logodir = $conf->mycompany->multidir_output[$object->entity]; + } + if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { + $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; + } else { + $logo = $logodir.'/logos/'.$this->emetteur->logo; + } + if (is_readable($logo)) { + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + } else { + $pdf->SetTextColor(200, 0, 0); + $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); + } + } else { + $text = $this->emetteur->name; + $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection); + } + } + + $pdf->SetFont('', 'B', $default_font_size + 3); + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $title = $outputlangs->transnoentities("SupplierProposal")." ".$outputlangs->convToOutputCharset($object->ref); + $pdf->MultiCell(100, 3, $title, '', 'R'); + $posy += 1; + + if ($object->ref_supplier) { + $posy += 4; + $pdf->SetFont('', 'B', $default_font_size); + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier")." : ".$outputlangs->convToOutputCharset($object->ref_supplier), '', 'R'); + $posy += 1; + } + + $pdf->SetFont('', '', $default_font_size - 1); + + if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { + $object->fetch_projet(); + if (!empty($object->project->ref)) { + $posy += 3; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); + } + } + + if (!empty($conf->global->PDF_SHOW_PROJECT)) { + $object->fetch_projet(); + if (!empty($object->project->ref)) { + $outputlangs->load("projects"); + $posy += 4; + $pdf->SetXY($posx, $posy); + $langs->load("projects"); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); + } + } + + if (!empty($object->date)) { + $posy += 5; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R'); + } else { + $posy += 5; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(255, 0, 0); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Draft"), '', 'R'); + } + + $pdf->SetTextColor(0, 0, 60); + $usehourmin = 'day'; + if (!empty($conf->global->SUPPLIER_PROPOSAL_USE_HOUR_FOR_DELIVERY_DATE)) { + $usehourmin = 'dayhour'; + } + if (!empty($object->delivery_date)) { + $posy += 4; + $pdf->SetXY($posx - 90, $posy); + $pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->delivery_date, $usehourmin, false, $outputlangs, true), '', 'R'); + } + + if ($object->thirdparty->code_fournisseur) { + $posy += 4; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); + } + + // Get contact + if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) { + $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); + if (count($arrayidcontact) > 0) { + $usertmp = new User($this->db); + $usertmp->fetch($arrayidcontact[0]); + $posy += 4; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R'); + } + } + + $posy += 1; + $pdf->SetTextColor(0, 0, 60); + + $top_shift = 0; + // Show list of linked objects + $current_y = $pdf->getY(); + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); + if ($current_y < $pdf->getY()) { + $top_shift = $pdf->getY() - $current_y; + } + + if ($showaddress) { + // Sender properties + $carac_emetteur = ''; + // Add internal contact of object if defined + $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); + if (count($arrayidcontact) > 0) { + $object->fetch_user($arrayidcontact[0]); + $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name")); + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)); + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : ''; + $carac_emetteur .= "\n"; + } + + $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); + + // Show sender + $posy = 42 + $top_shift; + $posx = $this->marge_gauche; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { + $posx = $this->page_largeur - $this->marge_droite - 80; + } + $hautcadre = 40; + + // Show sender frame + $pdf->SetTextColor(0, 0, 0); + $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetXY($posx, $posy - 5); + $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection); + $pdf->SetXY($posx, $posy); + $pdf->SetFillColor(230, 230, 230); + $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + $pdf->SetTextColor(0, 0, 60); + + // Show sender name + $pdf->SetXY($posx + 2, $posy + 3); + $pdf->SetFont('', 'B', $default_font_size); + $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection); + $posy = $pdf->getY(); + + // Show sender information + $pdf->SetXY($posx + 2, $posy); + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection); + + + + // If CUSTOMER contact defined on proposal, we use it. Note: Even if this is a supplier object, the code for external contat that follow order is 'CUSTOMER' + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); + if (count($arrayidcontact) > 0) { + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); + } + + // Recipient name + if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { + $thirdparty = $object->contact; + } else { + $thirdparty = $object->thirdparty; + } + + $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); + + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); + + // Show recipient + $widthrecbox = 100; + if ($this->page_largeur < 210) { + $widthrecbox = 84; // To work with US executive format + } + $posy = 42 + $top_shift; + $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { + $posx = $this->marge_gauche; + } + + // Show recipient frame + $pdf->SetTextColor(0, 0, 0); + $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetXY($posx + 2, $posy - 5); + $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection); + $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + + // Show recipient name + $pdf->SetXY($posx + 2, $posy + 3); + $pdf->SetFont('', 'B', $default_font_size); + $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection); + + $posy = $pdf->getY(); + + // Show recipient information + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->SetXY($posx + 2, $posy); + $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection); + } + + return $top_shift; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Show footer of page. Need this->emetteur object + * + * @param TCPDF $pdf PDF + * @param CommandeFournisseur $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text + */ + protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + { + $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0); + return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); + } + + + + /** + * Define Array Column Field + * + * @param Object $object common object + * @param Translate $outputlangs langs + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @return void + */ + public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + { + global $conf, $hookmanager; + + // Default field style for content + $this->defaultContentsFieldsStyle = array( + 'align' => 'R', // R,C,L + 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ); + + // Default field style for content + $this->defaultTitlesFieldsStyle = array( + 'align' => 'C', // R,C,L + 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ); + + $rank = 0; // do not use negative rank + $this->cols['desc'] = array( + 'rank' => $rank, + 'width' => false, // only for desc + 'status' => true, + 'title' => array( + 'textkey' => 'Designation', // use lang key is usefull in somme case with module + 'align' => 'L', + // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label + // 'label' => ' ', // the final label + 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ), + 'content' => array( + 'align' => 'L', + 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ), + ); + + $rank = $rank + 10; + $this->cols['photo'] = array( + 'rank' => $rank, + 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm + 'status' => false, + 'title' => array( + 'textkey' => 'Photo', + 'label' => ' ' + ), + 'content' => array( + 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ), + 'border-left' => false, // remove left line separator + ); + + if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_PROPOSAL_WITH_PICTURE)) { + $this->cols['photo']['status'] = true; + } + + + $rank = $rank + 10; + $this->cols['vat'] = array( + 'rank' => $rank, + 'status' => false, + 'width' => 16, // in mm + 'title' => array( + 'textkey' => 'VAT' + ), + 'border-left' => true, // add left line separator + ); + + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) { + $this->cols['vat']['status'] = true; + } + + $rank = $rank + 10; + $this->cols['subprice'] = array( + 'rank' => $rank, + 'width' => 19, // in mm + 'status' => false, + 'title' => array( + 'textkey' => 'PriceUHT' + ), + 'border-left' => true, // add left line separator + ); + + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SUPPLIER_PROPOSAL_WITHOUT_UNIT_PRICE)) { + $this->cols['subprice']['status'] = true; + } + + $rank = $rank + 10; + $this->cols['qty'] = array( + 'rank' => $rank, + 'width' => 16, // in mm + 'status' => true, + 'title' => array( + 'textkey' => 'Qty' + ), + 'border-left' => true, // add left line separator + ); + + $rank = $rank + 10; + $this->cols['unit'] = array( + 'rank' => $rank, + 'width' => 11, // in mm + 'status' => false, + 'title' => array( + 'textkey' => 'Unit' + ), + 'border-left' => true, // add left line separator + ); + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { + $this->cols['unit']['status'] = true; + } + + $rank = $rank + 10; + $this->cols['discount'] = array( + 'rank' => $rank, + 'width' => 13, // in mm + 'status' => false, + 'title' => array( + 'textkey' => 'ReductionShort' + ), + 'border-left' => true, // add left line separator + ); + if ($this->atleastonediscount) { + $this->cols['discount']['status'] = true; + } + + $rank = $rank + 1000; // add a big offset to be sure is the last col because default extrafield rank is 100 + $this->cols['totalexcltax'] = array( + 'rank' => $rank, + 'width' => 26, // in mm + 'status' => false, + 'title' => array( + 'textkey' => 'TotalHT' + ), + 'border-left' => true, // add left line separator + ); + + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SUPPLIER_PROPOSAL_WITHOUT_TOTAL_COLUMN)) { + $this->cols['totalexcltax']['status'] = true; + } + + // Add extrafields cols + if (!empty($object->lines)) { + $line = reset($object->lines); + $this->defineColumnExtrafield($line, $outputlangs, $hidedetails); + } + + $parameters = array( + 'object' => $object, + 'outputlangs' => $outputlangs, + 'hidedetails' => $hidedetails, + 'hidedesc' => $hidedesc, + 'hideref' => $hideref + ); + + $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } elseif (empty($reshook)) { + $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys + } else { + $this->cols = $hookmanager->resArray; + } + } +} diff --git a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php index cb4f76fa727..f9b91800153 100644 --- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php +++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php @@ -60,9 +60,10 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal /** * Return description of numbering module * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -84,9 +85,10 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal * 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 + * @param Object $object Object we need next value for + * @return boolean false if KO (there is a conflict), true if OK */ - public function canBeActivated() + public function canBeActivated($object) { global $conf, $langs, $db; 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 e4eecb4fa7b..4601d24c03a 100644 --- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php +++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php @@ -60,9 +60,10 @@ class mod_supplier_proposal_saphir extends ModeleNumRefSupplierProposal /** * Return description of module * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs, $db; @@ -89,7 +90,7 @@ class mod_supplier_proposal_saphir extends ModeleNumRefSupplierProposal $texte .= ''.$langs->trans("Mask").':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; diff --git a/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php b/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php index 18655535be3..d54b9629178 100644 --- a/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php +++ b/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php @@ -28,6 +28,7 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Requis car utilise dans les classes qui heritent @@ -36,12 +37,6 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Requis */ abstract class ModelePDFSupplierProposal extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules @@ -67,96 +62,7 @@ abstract class ModelePDFSupplierProposal extends CommonDocGenerator /** * Classe mere des modeles de numerotation des references de propales */ -abstract class ModeleNumRefSupplierProposal +abstract class ModeleNumRefSupplierProposal extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - public $version; - - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Returns the default description of the numbering pattern - * - * @return string Descriptive text - */ - public function info() - { - global $langs; - $langs->load("supplier_proposal"); - return $langs->trans("NoDescription"); - } - - /** - * Return an example of numbering - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("supplier_proposal"); - return $langs->trans("NoExample"); - } - - /** - * 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() - { - return true; - } - - /** - * Renvoi prochaine valeur attribuee - * - * @param Societe $objsoc Object third party - * @param SupplierProposal $supplier_proposal Object commercial proposal - * @return string Valeur - */ - public function getNextValue($objsoc, $supplier_proposal) - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Renvoi version du module numerotation - * - * @return string Valeur - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } - if ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } - if ($this->version == 'dolibarr') { - return DOL_VERSION; - } - if ($this->version) { - return $this->version; - } - return $langs->trans("NotAvailable"); - } + // No overload code } diff --git a/htdocs/core/modules/takepos/mod_takepos_ref_simple.php b/htdocs/core/modules/takepos/mod_takepos_ref_simple.php index 2295209bb82..85398f67c31 100644 --- a/htdocs/core/modules/takepos/mod_takepos_ref_simple.php +++ b/htdocs/core/modules/takepos/mod_takepos_ref_simple.php @@ -58,9 +58,10 @@ class mod_takepos_ref_simple extends ModeleNumRefTakepos /** * Return description of numbering module * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; @@ -84,9 +85,10 @@ class mod_takepos_ref_simple extends ModeleNumRefTakepos * Test if the numbers already in the database do not cause any conflicts that will prevent this * of conflicts that will prevent this numbering from working. * - * @return boolean false if KO (there is a conflict), true if OK + * @param Object $object Object we need next value for + * @return boolean false if KO (there is a conflict), true if OK */ - public function canBeActivated() + public function canBeActivated($object) { global $conf, $langs, $db; diff --git a/htdocs/core/modules/takepos/mod_takepos_ref_universal.php b/htdocs/core/modules/takepos/mod_takepos_ref_universal.php index 3ebc5858ae4..35c7242368f 100644 --- a/htdocs/core/modules/takepos/mod_takepos_ref_universal.php +++ b/htdocs/core/modules/takepos/mod_takepos_ref_universal.php @@ -54,9 +54,10 @@ class mod_takepos_ref_universal extends ModeleNumRefTakepos /** * return description of the numbering model * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $db, $langs; @@ -82,7 +83,7 @@ class mod_takepos_ref_universal extends ModeleNumRefTakepos $texte .= ''.$langs->trans("Mask").':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; diff --git a/htdocs/core/modules/takepos/modules_takepos.php b/htdocs/core/modules/takepos/modules_takepos.php index bd554a85a65..7a296d85f15 100644 --- a/htdocs/core/modules/takepos/modules_takepos.php +++ b/htdocs/core/modules/takepos/modules_takepos.php @@ -26,102 +26,13 @@ * \brief File containing the parent class for the numbering of cash register receipts */ +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; + /** - * \class ModeleNumRefTakepos - * \brief Classe mere des modeles de numerotation des tickets de caisse + * Classe mere des modeles de numerotation des tickets de caisse */ -abstract class ModeleNumRefTakepos +abstract class ModeleNumRefTakepos extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - - public $version = ''; - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Returns the default description of the numbering pattern - * - * @return string Descriptive text - */ - public function info() - { - global $langs; - $langs->load("cashdesk@cashdesk"); - return $langs->trans("NoDescription"); - } - - /** - * Return an example of numbering - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load('cashdesk@cashdesk'); - return $langs->trans('NoExample'); - } - - /** - * 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() - { - return true; - } - - /** - * Renvoi prochaine valeur attribuee - * - * @param Societe $objsoc Object thirdparty - * @param Facture $invoice Object invoice - * @param string $mode 'next' for next value or 'last' for last value - * @return string Value if KO, <0 if KO - */ - public function getNextValue($objsoc = null, $invoice = null, $mode = 'next') - { - global $langs; - return $langs->trans('NotAvailable'); - } - - /** - * Renvoi version du modele de numerotation - * - * @return string Valeur - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans('VersionDevelopment'); - } - if ($this->version == 'experimental') { - return $langs->trans('VersionExperimental'); - } - if ($this->version == 'dolibarr') { - return DOL_VERSION; - } - if ($this->version) { - return $this->version; - } - return $langs->trans('NotAvailable'); - } + // No overload code } diff --git a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php index 7aa6b4a07e4..709085d544b 100644 --- a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php +++ b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php @@ -36,11 +36,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; */ class doc_generic_ticket_odt extends ModelePDFTicket { - /** - * @var Societe Issuer - */ - public $emetteur; - /** * Dolibarr version of the loaded document * @var string @@ -55,7 +50,7 @@ class doc_generic_ticket_odt extends ModelePDFTicket */ public function __construct($db) { - global $conf, $langs, $mysoc; + global $langs, $mysoc; // Load translation files required by the page $langs->loadLangs(array("main", "companies")); @@ -97,7 +92,7 @@ class doc_generic_ticket_odt extends ModelePDFTicket */ public function info($langs) { - global $conf, $langs; + global $langs; // Load translation files required by the page $langs->loadLangs(array('companies', 'errors')); @@ -135,17 +130,18 @@ class doc_generic_ticket_odt extends ModelePDFTicket } } $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp .= '

    '.$langs->trans("ExampleOfDirectoriesForModelGen").''; // Add list of substitution keys $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); $texte .= '
    '; $texte .= ''; $texte .= '
    '; - $texte .= ''; + $texte .= ''; $texte .= '
    '; // Scan directories @@ -163,23 +159,18 @@ class doc_generic_ticket_odt extends ModelePDFTicket } // Add input to upload a new template file. $texte .= '
    '.$langs->trans("UploadNewTemplate"); - $texte .= ' '; $maxfilesizearray = getMaxFileSizeArray(); $maxmin = $maxfilesizearray['maxmin']; if ($maxmin > 0) { $texte .= ''; // MAX_FILE_SIZE must precede the field type=file } + $texte .= ' '; $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= '
    '; $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte .= ''; - $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/ticket/mod_ticket_simple.php b/htdocs/core/modules/ticket/mod_ticket_simple.php index fdd3cbab86b..00bd01289fa 100644 --- a/htdocs/core/modules/ticket/mod_ticket_simple.php +++ b/htdocs/core/modules/ticket/mod_ticket_simple.php @@ -58,9 +58,10 @@ class mod_ticket_simple extends ModeleNumRefTicket /** * Return description of numbering module * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -80,9 +81,10 @@ class mod_ticket_simple extends ModeleNumRefTicket * 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 + * @param Object $object Object we need next value for + * @return boolean false if conflict, true if ok */ - public function canBeActivated() + public function canBeActivated($object) { global $conf, $langs, $db; @@ -121,7 +123,7 @@ class mod_ticket_simple extends ModeleNumRefTicket */ public function getNextValue($objsoc, $ticket) { - global $db, $conf; + global $db; // First, we get the max value $posindice = strlen($this->prefix) + 6; diff --git a/htdocs/core/modules/ticket/mod_ticket_universal.php b/htdocs/core/modules/ticket/mod_ticket_universal.php index 8cd2cd6f614..15398b43f30 100644 --- a/htdocs/core/modules/ticket/mod_ticket_universal.php +++ b/htdocs/core/modules/ticket/mod_ticket_universal.php @@ -19,47 +19,48 @@ /** * \file htdocs/core/modules/ticket/mod_ticket_universal.php * \ingroup ticket - * \brief Fichier contenant la classe du modele de numerotation de reference de projet Universal + * \brief File with class to manage the numbering module Universal for Ticket references */ require_once DOL_DOCUMENT_ROOT.'/core/modules/ticket/modules_ticket.php'; /** - * Classe du modele de numerotation de reference de projet Universal + * Class to manage the numbering module Universal for Ticket references */ class mod_ticket_universal extends ModeleNumRefTicket { /** - * Dolibarr version of the loaded document - * @var string + * Dolibarr version of the loaded document + * @var string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** - * @var string Error code (or message) + * @var string Error code (or message) */ public $error = ''; /** - * @var string Nom du modele - * @deprecated - * @see $name + * @var string Nom du modele + * @deprecated + * @see $name */ public $nom = 'Universal'; /** - * @var string model name + * @var string model name */ public $name = 'Universal'; /** * Returns the description of the numbering model * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { - global $db, $conf, $langs; + global $db, $langs; // Load translation files required by the page $langs->loadLangs(array("ticket", "admin")); @@ -79,11 +80,11 @@ class mod_ticket_universal extends ModeleNumRefTicket $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Ticket"), $langs->transnoentities("Ticket")); $tooltip .= $langs->trans("GenericMaskCodes5"); - // Parametrage du prefix + // Prefix settings $texte .= ''.$langs->trans("Mask").':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; @@ -126,7 +127,7 @@ class mod_ticket_universal extends ModeleNumRefTicket include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - // On defini critere recherche compteur + // We define criterion search counter $mask = getDolGlobalString("TICKET_UNIVERSAL_MASK"); if (!$mask) { diff --git a/htdocs/core/modules/ticket/modules_ticket.php b/htdocs/core/modules/ticket/modules_ticket.php index e5f91264f09..b8c2754ad12 100644 --- a/htdocs/core/modules/ticket/modules_ticket.php +++ b/htdocs/core/modules/ticket/modules_ticket.php @@ -26,13 +26,14 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; + /** * Parent class for documents models */ abstract class ModelePDFTicket extends CommonDocGenerator { - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules @@ -58,100 +59,7 @@ abstract class ModelePDFTicket extends CommonDocGenerator /** * Classe mere des modeles de numerotation des references de projets */ -abstract class ModeleNumRefTicket +abstract class ModeleNumRefTicket extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - public $version; - - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Returns the default description of the numbering pattern - * - * @return string Descriptive text - */ - public function info() - { - global $langs; - $langs->load("ticket"); - return $langs->trans("NoDescription"); - } - - /** - * Return an example of numbering - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("ticket"); - return $langs->trans("NoExample"); - } - - /** - * 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() - { - return true; - } - - /** - * Renvoi prochaine valeur attribuee - * - * @param Societe $objsoc Object third party - * @param Ticket $ticket Object ticket - * @return string Valeur - */ - public function getNextValue($objsoc, $ticket) - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Renvoi version du module numerotation - * - * @return string Valeur - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } - - if ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } - - if ($this->version == 'dolibarr') { - return DOL_VERSION; - } - - if ($this->version) { - return $this->version; - } - - return $langs->trans("NotAvailable"); - } + // No overload code } diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php index d6e52e2f21e..cb1e28666e6 100644 --- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php +++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php @@ -36,11 +36,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; */ class doc_generic_user_odt extends ModelePDFUser { - /** - * @var Societe Issuer - */ - public $emetteur; - /** * Dolibarr version of the loaded document * @var string @@ -55,7 +50,7 @@ class doc_generic_user_odt extends ModelePDFUser */ public function __construct($db) { - global $conf, $langs, $mysoc; + global $langs, $mysoc; // Load translation files required by the page $langs->loadLangs(array("main", "companies")); @@ -146,17 +141,18 @@ class doc_generic_user_odt extends ModelePDFUser } } $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp .= '

    '.$langs->trans("ExampleOfDirectoriesForModelGen").''; // Add list of substitution keys $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); $texte .= '
    '; $texte .= ''; $texte .= '
    '; - $texte .= ''; + $texte .= ''; $texte .= '
    '; // Scan directories @@ -204,16 +200,11 @@ class doc_generic_user_odt extends ModelePDFUser } $texte .= ' '; $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= ''; $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte .= ''; - $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php index 74ad5902966..7c1b4484fd0 100644 --- a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php +++ b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php @@ -38,12 +38,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; */ class doc_generic_usergroup_odt extends ModelePDFUserGroup { - /** - * Issuer - * @var Societe - */ - public $emetteur; - /** * Dolibarr version of the loaded document * @var string @@ -58,7 +52,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup */ public function __construct($db) { - global $conf, $langs, $mysoc; + global $langs, $mysoc; // Load translation files required by the page $langs->loadLangs(array("main", "companies")); @@ -115,7 +109,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup $odtPath = trim(getDolGlobalString('USERGROUP_ADDON_PDF_ODT_PATH')); $texte = $this->description.".
    \n"; - $texte .= '
    '; + $texte .= ''; $texte .= ''; $texte .= ''; $texte .= ''; @@ -149,17 +143,18 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup } } $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp .= '

    '.$langs->trans("ExampleOfDirectoriesForModelGen").''; // Add list of substitution keys $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); $texte .= '
    '; $texte .= ''; $texte .= '
    '; - $texte .= ''; + $texte .= ''; $texte .= '
    '; // Scan directories @@ -189,15 +184,29 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup $texte .= ""; $texte .= ''; } + $texte .= '
    '; + // Show list of found files + foreach ($listoffiles as $file) { + $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').''; + $texte .= '   '.img_picto('', 'delete').''; + $texte .= '
    '; + } + $texte .= '
    '; } + // Add input to upload a new template file. + $texte .= '
    '.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; + $texte .= ''; + $texte .= ''; + $texte .= '
    '; $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte .= ''; - $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/usergroup/modules_usergroup.class.php b/htdocs/core/modules/usergroup/modules_usergroup.class.php index 2c4aebe1e6f..0e31611b3db 100644 --- a/htdocs/core/modules/usergroup/modules_usergroup.class.php +++ b/htdocs/core/modules/usergroup/modules_usergroup.class.php @@ -19,31 +19,20 @@ * or see https://www.gnu.org/ */ - -/** - * \class ModeleProductCode - * \brief Parent class for product code generators - */ - /** * \file htdocs/core/modules/contract/modules_contract.php * \ingroup contract * \brief File with parent class for generating contracts to PDF and File of class to manage contract numbering */ - require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; + /** * Parent class to manage intervention document templates */ abstract class ModelePDFUserGroup extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules diff --git a/htdocs/core/modules/workstation/mod_workstation_advanced.php b/htdocs/core/modules/workstation/mod_workstation_advanced.php index 253e4224b64..6695d26e64c 100644 --- a/htdocs/core/modules/workstation/mod_workstation_advanced.php +++ b/htdocs/core/modules/workstation/mod_workstation_advanced.php @@ -55,11 +55,12 @@ class mod_workstation_advanced extends ModeleNumRefWorkstation /** * Returns the description of the numbering model * - * @return string Descriptive text + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { - global $conf, $langs, $db; + global $langs, $db; $langs->load("bills"); @@ -82,7 +83,7 @@ class mod_workstation_advanced extends ModeleNumRefWorkstation $texte .= ''.$langs->trans("Mask").':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= '  '; + $texte .= '  '; $texte .= ''; diff --git a/htdocs/core/modules/workstation/mod_workstation_standard.php b/htdocs/core/modules/workstation/mod_workstation_standard.php index 758783316e4..2ad954e5f2e 100644 --- a/htdocs/core/modules/workstation/mod_workstation_standard.php +++ b/htdocs/core/modules/workstation/mod_workstation_standard.php @@ -52,9 +52,10 @@ class mod_workstation_standard extends ModeleNumRefWorkstation /** * Return description of numbering module * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Descriptive text */ - public function info() + public function info($langs) { global $langs; return $langs->trans("SimpleNumRefNoDateModelDesc", $this->prefix); diff --git a/htdocs/core/modules/workstation/modules_workstation.php b/htdocs/core/modules/workstation/modules_workstation.php index cca24834d28..afa884c27d7 100644 --- a/htdocs/core/modules/workstation/modules_workstation.php +++ b/htdocs/core/modules/workstation/modules_workstation.php @@ -30,6 +30,7 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit @@ -38,7 +39,6 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // requir */ abstract class ModelePDFWorkstation extends CommonDocGenerator { - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules @@ -61,100 +61,10 @@ abstract class ModelePDFWorkstation extends CommonDocGenerator } - /** * Parent class to manage numbering of Workstation */ -abstract class ModeleNumRefWorkstation +abstract class ModeleNumRefWorkstation extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - public $version; - - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Returns the default description of the numbering template - * - * @return string Descriptive text - */ - public function info() - { - global $langs; - $langs->load("workstation@workstation"); - return $langs->trans("NoDescription"); - } - - /** - * Returns an example of numbering - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("workstation@workstation"); - return $langs->trans("NoExample"); - } - - /** - * Checks if the numbers already in the database do not - * cause conflicts that would prevent this numbering working. - * - * @param Object $object Object we need next value for - * @return boolean false if conflict, true if ok - */ - public function canBeActivated($object) - { - return true; - } - - /** - * Returns next assigned value - * - * @param Object $object Object we need next value for - * @return string Valeur - */ - public function getNextValue($object) - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Returns version of numbering module - * - * @return string Valeur - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } - if ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } - if ($this->version == 'dolibarr') { - return DOL_VERSION; - } - if ($this->version) { - return $this->version; - } - return $langs->trans("NotAvailable"); - } + // No overload code } diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php index 68899012433..d4e46dc7789 100644 --- a/htdocs/core/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -554,7 +554,7 @@ if (!empty($conf->use_javascript_ajax)) { print ''."\n"; print '
    '; - print ''.$langs->trans("Recenter").''; + print ''.$langs->trans("Crop").''; print $langs->trans("DefineNewAreaToPick").'...
    '; print '
    '; @@ -589,7 +589,7 @@ if (!empty($conf->use_javascript_ajax)) {
    - +   '."\n"; diff --git a/htdocs/core/search_page.php b/htdocs/core/search_page.php index 2e5cad17c58..b558aa32062 100644 --- a/htdocs/core/search_page.php +++ b/htdocs/core/search_page.php @@ -45,10 +45,42 @@ if (GETPOST('lang', 'aZ09')) { $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php } -$langs->load("main"); +$langs->loadLangs(array("main", "other")); -$right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right'); -$left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); +$action = GETPOST('action', 'aZ09'); + +/*$right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right'); +$left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left');*/ + + +/* + * Actions + */ + +if ($action == 'redirect') { + global $dolibarr_main_url_root; + + $url = GETPOST('url'); + $url = dol_sanitizeUrl($url); + //$url = preg_replace('/^http(s?):\/\//i', '', $url); + + //var_dump($url); + + $tmpurlrootwithouthttp = preg_replace('/^http(s?):\/\//i', '', DOL_MAIN_URL_ROOT); + //var_dump($dolibarr_main_url_root); + //var_dump(DOL_MAIN_URL_ROOT); + //var_dump($tmpurlrootwithouthttp); + $url = preg_replace('/'.preg_quote($dolibarr_main_url_root, '/').'/', '', $url); + $url = preg_replace('/'.preg_quote(DOL_MAIN_URL_ROOT, '/').'/', '', $url); + $url = preg_replace('/'.preg_quote($tmpurlrootwithouthttp, '/').'/', '', $url); + $urlrelativeforredirect = (DOL_URL_ROOT.(preg_match('/\//', $url) ? '' : '/').$url); + //$urlrelativeforredirectwithoutparam = preg_replace('/\?.*$/', '', $urlrelativeforredirect); + //var_dump($urlrelativeforredirect); + + dol_syslog("Ask search form to redirect on URL: ".$urlrelativeforredirect); + header("Location: ".$urlrelativeforredirect); + exit; +} /* @@ -120,6 +152,7 @@ if ($conf->use_javascript_ajax && 1 == 2) { // select2 is not best with smartp } } + // Execute hook printSearchForm $parameters = array('searchform'=>$searchform); $reshook = $hookmanager->executeHooks('printSearchForm', $parameters); // Note that $action and $object may have been modified by some hooks @@ -129,7 +162,30 @@ if (empty($reshook)) { $searchform = $hookmanager->resPrint; } +$searchform .= '
    '; +// Add search on URL +$ret = ''; +$ret .= '
    '; +$ret .= ''; +$ret .= ''; +$ret .= ''; +$ret .= '
    '; +$ret .= img_picto('', 'url', '', false, 0, 0, '', 'paddingright width20'); +$ret .= 'trans("OrPasteAnURL")).'"'; +$ret .= ' name="url" id="url" />'; +$ret .= ''; +$ret .= '
    '; +$ret .= "
    \n"; + +$searchform .= $ret; + + +// Show all forms print "\n"; print "\n"; print '
    '; @@ -140,6 +196,7 @@ print '
    '."\n"; print '
    '; print "\n\n"; + print ''; print ''."\n"; diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 5404f831a65..7930551e376 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -157,7 +157,22 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php
    Contact:con trans("AttributeCode"); ?> (trans("AlphaNumOnlyLowerCharsAndNoSpace"); ?>) trans("Type"); ?> -selectarray('type', $type2label, GETPOST('type', 'alpha'), 0, 0, 0, '', 0, 0, 0, '', '', 1); ?> +'; +foreach ($type2label as $key => $val) { + $selected = ''; + if ($key == GETPOST('type', 'alpha')) { + $selected = ' selected="selected"'; + } + + // Set $valhtml with the picto for the type + $valhtml = ($key ? getPictoForType($key) : '').$val; + + print ''; +} +print ''; +print ajax_combobox('type'); +?> trans("Size"); ?> diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 294aea5e8e7..d94d58a1659 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -172,9 +172,9 @@ $css = $extrafields->attributes[$elementtype]['css'][$attrname]; $cssview = $extrafields->attributes[$elementtype]['cssview'][$attrname]; $csslist = $extrafields->attributes[$elementtype]['csslist'][$attrname]; +$param_chain = ''; if (is_array($param)) { if (($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) { - $param_chain = ''; foreach ($param['options'] as $key => $value) { if (strlen($key)) { $param_chain .= $key.','.$value."\n"; @@ -216,23 +216,26 @@ if ($size <= 255 && in_array($type, array('text', 'html'))) { }*/ if (in_array($type, array_keys($typewecanchangeinto))) { - $newarray = array(); print ''; print ajax_combobox('type'); } else { - print $type2label[$type]; + print getPictoForType($type).$type2label[$type]; print ''; } ?> diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index 145ece3f7e6..f8dade2db27 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -1,7 +1,7 @@ * Copyright (C) 2012-2021 Regis Houssin - * Copyright (C) 2018-2019 Frédéric France + * Copyright (C) 2018-2023 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -59,6 +59,9 @@ print '
    '; print ''; print ''; +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; +} print ''; } -print ''; +// Action column +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; +} print "\n"; if (isset($extrafields->attributes[$elementtype]['type']) && is_array($extrafields->attributes[$elementtype]['type']) && count($extrafields->attributes[$elementtype]['type'])) { @@ -98,6 +104,16 @@ if (isset($extrafields->attributes[$elementtype]['type']) && is_array($extrafiel } print ''; + // Actions + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''."\n"; + } // Position print "\n"; // Label @@ -109,6 +125,7 @@ if (isset($extrafields->attributes[$elementtype]['type']) && is_array($extrafiel // Type $typetoshow = $type2label[$extrafields->attributes[$elementtype]['type'][$key]]; print '\n"; // Size @@ -145,18 +162,25 @@ if (isset($extrafields->attributes[$elementtype]['type']) && is_array($extrafiel } if (empty($multicompanylabel_cache[$extrafields->attributes[$elementtype]['entityid'][$key]])) { global $mc; - $mc->getInfo($extrafields->attributes[$elementtype]['entityid'][$key]); - $multicompanylabel_cache[$extrafields->attributes[$elementtype]['entityid'][$key]] = $mc->label ? $mc->label : $extrafields->attributes[$elementtype]['entityid'][$key]; + if (is_object($mc) && method_exists($mc, 'getInfo')) { + $mc->getInfo($extrafields->attributes[$elementtype]['entityid'][$key]); + $multicompanylabel_cache[$extrafields->attributes[$elementtype]['entityid'][$key]] = $mc->label ? $mc->label : $extrafields->attributes[$elementtype]['entityid'][$key]; + } } print $multicompanylabel_cache[$extrafields->attributes[$elementtype]['entityid'][$key]]; } print ''; } // Actions - print ''."\n"; + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''."\n"; + } print ""; } } else { diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 50efa0e9612..59c7529c520 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -208,6 +208,7 @@ if ($action == 'presend') { $fuser->fetch($object->fk_user); $liste['thirdparty'] = $fuser->getFullName($outputlangs)." <".$fuser->email.">"; } else { + // For exemple if element is project if (!empty($object->socid) && $object->socid > 0 && !is_object($object->thirdparty) && method_exists($object, 'fetch_thirdparty')) { $object->fetch_thirdparty(); } diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 7f4b3971205..228862ce463 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -40,36 +40,37 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $module = $object->element; // Special cases +// TODO Set $permission from the $permissiontoadd var defined on calling page if ($module == 'propal') { - $permission = $user->rights->propal->creer; + $permission = $user->hasRight('propal', 'creer'); } elseif ($module == 'fichinter') { - $permission = $user->rights->ficheinter->creer; + $permission = $user->hasRight('ficheinter', 'creer'); } elseif ($module == 'order_supplier') { if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) { - $permission = $user->rights->fournisseur->commande->creer; + $permission = $user->hasRight('fournisseur', 'commande', 'creer'); } else { - $permission = $user->rights->supplier_order->creer; + $permission = $user->hasRight('supplier_order', 'creer'); } } elseif ($module == 'invoice_supplier' && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) { if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) { - $permission = $user->rights->fournisseur->facture->creer; + $permission = $user->hasRight('fournisseur', 'facture', 'creer'); } else { - $permission = $user->rights->supplier_invoice->creer; + $permission = $user->hasRight('supplier_invoice', 'creer'); } } elseif ($module == 'project') { - $permission = $user->rights->projet->creer; + $permission = $user->hasRight('projet', 'creer'); } elseif ($module == 'action') { $permission = $user->hasRight('agenda', 'myactions', 'create'); } elseif ($module == 'shipping') { - $permission = $user->rights->expedition->creer; + $permission = $user->hasRight('expedition', 'creer'); } elseif ($module == 'reception') { - $permission = $user->rights->reception->creer; + $permission = $user->hasRight('reception', 'creer'); } elseif ($module == 'project_task') { - $permission = $user->rights->projet->creer; + $permission = $user->hasRight('projet', 'creer'); } elseif (!isset($permission) && isset($user->rights->$module->creer)) { - $permission = $user->rights->$module->creer; + $permission = $user->hasRight($module, 'creer'); } elseif (!isset($permission) && isset($user->rights->$module->write)) { - $permission = $user->rights->$module->write; + $permission = $user->hasRight($module, 'write'); } $formcompany = new FormCompany($db); diff --git a/htdocs/core/tpl/document_actions_post_headers.tpl.php b/htdocs/core/tpl/document_actions_post_headers.tpl.php index 8b48a63e34d..3a14cb566e7 100644 --- a/htdocs/core/tpl/document_actions_post_headers.tpl.php +++ b/htdocs/core/tpl/document_actions_post_headers.tpl.php @@ -41,6 +41,7 @@ if (empty($relativepathwithnofile)) { $relativepathwithnofile = ''; } +// Set $permission from the $permissiontoadd var defined on calling page if (!isset($permission)) { $permission = $permissiontoadd; } diff --git a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php index 267ca6803c9..0f0add8e9ae 100644 --- a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php +++ b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php @@ -34,11 +34,8 @@ if (!empty($extrafieldsobjectkey) && !empty($extrafields->attributes[$extrafield } // If field is a computed field, we make computation to get value if ($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]) { - //global $obj, $object; - //var_dump($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]); - //var_dump($obj); - //var_dump($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]); - $value = dol_eval($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key], 1, 1, '0'); + $objectoffield = $object; //For compatibily with the computed formula + $value = dol_eval($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key], 1, 1, '2'); if (is_numeric(price2num($value)) && $extrafields->attributes[$extrafieldsobjectkey]['totalizable'][$key]) { $obj->$tmpkey = price2num($value); } diff --git a/htdocs/core/triggers/interface_20_all_Logevents.class.php b/htdocs/core/triggers/interface_20_all_Logevents.class.php index e6ae9972190..bd25fe4efad 100644 --- a/htdocs/core/triggers/interface_20_all_Logevents.class.php +++ b/htdocs/core/triggers/interface_20_all_Logevents.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2009 Laurent Destailleur * Copyright (C) 2009-2017 Regis Houssin * Copyright (C) 2014 Marcos García + * Copyright (C) 2023 Udo Tamm * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,7 +21,7 @@ /** * \file htdocs/core/triggers/interface_20_all_Logevents.class.php * \ingroup core - * \brief Trigger file for + * \brief Trigger file for log events */ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; @@ -40,12 +41,11 @@ class InterfaceLogevents extends DolibarrTriggers { $this->db = $db; - $this->name = preg_replace('/^Interface/i', '', get_class($this)); - $this->family = "core"; - $this->description = "Triggers of this module allows to add security event records inside Dolibarr."; - // 'development', 'experimental', 'dolibarr' or version - $this->version = self::VERSION_DOLIBARR; - $this->picto = 'technic'; + $this->name = preg_replace('/^Interface/i', '', get_class($this)); + $this->family = "core"; + $this->description = "Triggers of this module allows to add security event records inside Dolibarr."; + $this->version = self::VERSION_DOLIBARR; // VERSION_ 'DEVELOPMENT' or 'EXPERMENTAL' or 'DOLIBARR' + $this->picto = 'technic'; } /** @@ -77,51 +77,55 @@ class InterfaceLogevents extends DolibarrTriggers $date = dol_now(); + /* Actions */ + $text = ''; $desc = ''; + $langs->load("users"); // Actions if ($action == 'USER_LOGIN') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - - $langs->load("users"); - // Initialisation donnees (date,duree,texte,desc) + // Initialize data (date,duree,text,desc) $text = "(UserLogged,".$object->login.")"; $desc = "(UserLogged,".$object->login.")"; + + // USER_LOGIN_FAILED } elseif ($action == 'USER_LOGIN_FAILED') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + + // USER_LOGOUT } elseif ($action == 'USER_LOGOUT') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - - $langs->load("users"); - // Initialisation donnees (date,duree,texte,desc) + // Initialize data (date,duree,text,desc) $text = "(UserLogoff,".$object->login.")"; $desc = "(UserLogoff,".$object->login.")"; + + // USER_CREATE } elseif ($action == 'USER_CREATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - $langs->load("users"); - - // Initialisation donnees (date,duree,texte,desc) + // Initialize data (date,duree,text,desc) $text = $langs->transnoentities("NewUserCreated", $object->login); $desc = $langs->transnoentities("NewUserCreated", $object->login); + + // USER_MODIFY } elseif ($action == 'USER_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - $langs->load("users"); - - // Initialisation donnees (date,duree,texte,desc) + // Initialize data (date,duree,text,desc) $text = $langs->transnoentities("EventUserModified", $object->login); $desc = $langs->transnoentities("EventUserModified", $object->login); + + // USER_NEW_PASSWORD } elseif ($action == 'USER_NEW_PASSWORD') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - $langs->load("users"); - - // Initialisation donnees (date,duree,texte,desc) + // Initialize data (date,duree,text,desc) $text = $langs->transnoentities("NewUserPassword", $object->login); $desc = $langs->transnoentities("NewUserPassword", $object->login); + + // USER ENABLED/DISABLED } elseif ($action == 'USER_ENABLEDISABLE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - $langs->load("users"); - // Initialisation donnees (date,duree,texte,desc) + // Initialize data (date,duree,text,desc) if ($object->statut == 0) { $text = $langs->transnoentities("UserEnabled", $object->login); $desc = $langs->transnoentities("UserEnabled", $object->login); @@ -130,42 +134,36 @@ class InterfaceLogevents extends DolibarrTriggers $text = $langs->transnoentities("UserDisabled", $object->login); $desc = $langs->transnoentities("UserDisabled", $object->login); } + + // USER_DELETE } elseif ($action == 'USER_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - $langs->load("users"); - // Initialisation donnees (date,duree,texte,desc) + // Initialize data (date,duree,text,desc) $text = $langs->transnoentities("UserDeleted", $object->login); $desc = $langs->transnoentities("UserDeleted", $object->login); + + // USERGROUP_CREATE } elseif ($action == 'USERGROUP_CREATE') { - // Groups dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - $langs->load("users"); - // Initialisation donnees (date,duree,texte,desc) + // Initialize data (date,duree,text,desc) $text = $langs->transnoentities("NewGroupCreated", $object->name); $desc = $langs->transnoentities("NewGroupCreated", $object->name); + + // USERGROUP_MODIFY } elseif ($action == 'USERGROUP_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - $langs->load("users"); - // Initialisation donnees (date,duree,texte,desc) + // Initialize data (date,duree,text,desc) $text = $langs->transnoentities("GroupModified", $object->name); $desc = $langs->transnoentities("GroupModified", $object->name); + + // USERGROUP_DELETE } elseif ($action == 'USERGROUP_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - $langs->load("users"); - // Initialisation donnees (date,duree,texte,desc) + // Initialize data (date,duree,text,desc) $text = $langs->transnoentities("GroupDeleted", $object->name); $desc = $langs->transnoentities("GroupDeleted", $object->name); } - // If not found - /* - else - { - dol_syslog("Trigger '".$this->name."' for action '$action' was ran by ".__FILE__." but no handler found for this action."); - return 0; - } - */ - // Add more information into desc from the context property if (!empty($object->context['audit'])) { $desc .= (empty($desc) ? '' : ' - ').$object->context['audit']; diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index 993cbc8206d..03449f96f2a 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -189,6 +189,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers } } + // Set shipment to "Closed" if WORKFLOW_SHIPPING_CLASSIFY_CLOSED_INVOICE is set (deprecated, WORKFLOW_SHIPPING_CLASSIFY_BILLED_INVOICE instead)) if (isModEnabled("expedition") && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_SHIPPING_CLASSIFY_CLOSED_INVOICE)) { $object->fetchObjectLinked('', 'shipping', $object->id, $object->element); if (!empty($object->linkedObjects)) { @@ -210,6 +211,27 @@ class InterfaceWorkflowManager extends DolibarrTriggers } } + if (isModEnabled("expedition") && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_SHIPPING_CLASSIFY_BILLED_INVOICE)) { + $object->fetchObjectLinked('', 'shipping', $object->id, $object->element); + if (!empty($object->linkedObjects)) { + $totalonlinkedelements = 0; + foreach ($object->linkedObjects['shipping'] as $element) { + if ($element->statut == Expedition::STATUS_VALIDATED || $element->statut == Expedition::STATUS_CLOSED) { + $totalonlinkedelements += $element->total_ht; + } + } + dol_syslog("Amount of linked shipment = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht), LOG_DEBUG); + if ($totalonlinkedelements == $object->total_ht) { + foreach ($object->linkedObjects['shipping'] as $element) { + $ret = $element->setBilled(); + if ($ret < 0) { + return $ret; + } + } + } + } + } + return $ret; } @@ -246,7 +268,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers if (!empty($object->linkedObjects)) { $totalonlinkedelements = 0; foreach ($object->linkedObjects['supplier_proposal'] as $element) { - if ($element->statut == SupplierProposal::STATUS_SIGNED || $element->statut == SupplierProposal::STATUS_BILLED) { + if ($element->statut == SupplierProposal::STATUS_SIGNED || $element->statut == SupplierProposal::STATUS_CLOSE) { $totalonlinkedelements += $element->total_ht; } } @@ -262,8 +284,32 @@ class InterfaceWorkflowManager extends DolibarrTriggers } } - // Then set reception to "Billed" if WORKFLOW_RECEPTION_CLASSIFY_CLOSED_INVOICE is set + // Set reception to "Closed" if WORKFLOW_RECEPTION_CLASSIFY_CLOSED_INVOICE is set (deprecated, WORKFLOW_RECEPTION_CLASSIFY_BILLED_INVOICE instead)) + /* if (isModEnabled("reception") && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_RECEPTION_CLASSIFY_CLOSED_INVOICE)) { + $object->fetchObjectLinked('', 'reception', $object->id, $object->element); + if (!empty($object->linkedObjects)) { + $totalonlinkedelements = 0; + foreach ($object->linkedObjects['reception'] as $element) { + if ($element->statut == Reception::STATUS_VALIDATED || $element->statut == Reception::STATUS_CLOSED) { + $totalonlinkedelements += $element->total_ht; + } + } + dol_syslog("Amount of linked reception = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht), LOG_DEBUG); + if ($totalonlinkedelements == $object->total_ht) { + foreach ($object->linkedObjects['reception'] as $element) { + $ret = $element->setClosed(); + if ($ret < 0) { + return $ret; + } + } + } + } + } + */ + + // Then set reception to "Billed" if WORKFLOW_RECEPTION_CLASSIFY_BILLED_INVOICE is set + if (isModEnabled("reception") && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_RECEPTION_CLASSIFY_BILLED_INVOICE)) { $object->fetchObjectLinked('', 'reception', $object->id, $object->element); if (!empty($object->linkedObjects)) { $totalonlinkedelements = 0; @@ -343,7 +389,11 @@ class InterfaceWorkflowManager extends DolibarrTriggers if (is_array($order->linkedObjects) && count($order->linkedObjects) > 0) { foreach ($order->linkedObjects as $type => $shipping_array) { if ($type == 'shipping' && is_array($shipping_array) && count($shipping_array) > 0) { + /** @var Expedition[] $shipping_array */ foreach ($shipping_array as $shipping) { + if ($shipping->status <= 0) { + continue; + } if (is_array($shipping->lines) && count($shipping->lines) > 0) { foreach ($shipping->lines as $shippingline) { $qtyshipped[$shippingline->fk_product] += $shippingline->qty; diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 8235be12fb3..abd120ce573 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -106,9 +106,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "companies")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("NewCompanyToDolibarr", $object->name); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("NewCompanyToDolibarr", $object->name); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("NewCompanyToDolibarr", $object->name); } - $object->actionmsg = $langs->transnoentities("NewCompanyToDolibarr", $object->name); $object->sendtoid = 0; $object->socid = $object->id; @@ -117,9 +123,16 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "companies")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("COMPANY_MODIFYInDolibarr", $object->name); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("COMPANY_MODIFYInDolibarr", $object->name); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } } - $object->actionmsg = $langs->transnoentities("COMPANY_MODIFYInDolibarr", $object->name); + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("COMPANY_MODIFYInDolibarr", $object->name); + } + // For merge event, we add a mention if (!empty($object->context['mergefromname'])) { $object->actionmsg = dol_concatdesc($object->actionmsg, $langs->trans("DataFromWasMerged", $object->context['mergefromname'])); @@ -132,7 +145,11 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "orders")); if (empty($object->actionmsg2)) { - dol_syslog('Trigger called with property actionmsg2 on object not defined', LOG_ERR); + if (empty($object->context['actionmsg2'])) { + dol_syslog('Trigger called with property actionmsg2 and context[actionmsg2] on object not defined', LOG_ERR); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } } // Parameters $object->sendtoid defined by caller @@ -142,9 +159,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "companies")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("CONTACT_CREATEInDolibarr", $object->getFullName($langs)); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("CONTACT_CREATEInDolibarr", $object->getFullName($langs)); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("CONTACT_CREATEInDolibarr", $object->getFullName($langs)); } - $object->actionmsg = $langs->transnoentities("CONTACT_CREATEInDolibarr", $object->getFullName($langs)); $object->sendtoid = array($object->id => $object->id); $object->socid = $object->socid; @@ -153,9 +176,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "companies")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("CONTACT_MODIFYInDolibarr", $object->name); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("CONTACT_MODIFYInDolibarr", $object->name); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("CONTACT_MODIFYInDolibarr", $object->name); } - $object->actionmsg = $langs->transnoentities("CONTACT_MODIFYInDolibarr", $object->name); $object->sendtoid = array($object->id => $object->id); $object->socid = $object->socid; @@ -164,9 +193,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "contracts")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("ContractValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("ContractValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("ContractValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); } - $object->actionmsg = $langs->transnoentities("ContractValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); $object->sendtoid = 0; } elseif ($action == 'CONTRACT_SENTBYMAIL') { @@ -174,7 +209,11 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "contracts")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("ContractSentByEMail", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("ContractSentByEMail", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("ContractSentByEMail", $object->ref); @@ -187,17 +226,31 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "propal")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); } - $object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); $object->sendtoid = 0; } elseif ($action == 'PROPAL_MODIFY') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "propal")); - if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalBackToDraftInDolibarr", ($object->newref ? $object->newref : $object->ref)); - $object->actionmsg = $langs->transnoentities("PropalBackToDraftInDolibarr", ($object->newref ? $object->newref : $object->ref)); + if (empty($object->actionmsg2)) { + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("PropalBackToDraftInDolibarr", ($object->newref ? $object->newref : $object->ref)); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("PropalBackToDraftInDolibarr", ($object->newref ? $object->newref : $object->ref)); + } $object->sendtoid = 0; } elseif ($action == 'PROPAL_SENTBYMAIL') { @@ -205,7 +258,11 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "propal")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("ProposalSentByEMail", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("ProposalSentByEMail", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("ProposalSentByEMail", $object->ref); @@ -218,9 +275,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "propal")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); } - $object->actionmsg = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); $object->sendtoid = 0; } elseif ($action == 'PROPAL_CLASSIFY_BILLED') { @@ -228,9 +291,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "propal")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref); } - $object->actionmsg = $langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref); $object->sendtoid = 0; } elseif ($action == 'PROPAL_CLOSE_REFUSED') { @@ -238,9 +307,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "propal")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); } - $object->actionmsg = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); $object->sendtoid = 0; } elseif ($action == 'ORDER_VALIDATE') { @@ -248,9 +323,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "orders")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); } - $object->actionmsg = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); $object->sendtoid = 0; } elseif ($action == 'ORDER_CLOSE') { @@ -258,9 +339,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "orders")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("OrderDeliveredInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("OrderDeliveredInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("OrderDeliveredInDolibarr", $object->ref); } - $object->actionmsg = $langs->transnoentities("OrderDeliveredInDolibarr", $object->ref); $object->sendtoid = 0; } elseif ($action == 'ORDER_CLASSIFY_BILLED') { @@ -268,9 +355,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "orders")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("OrderBilledInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("OrderBilledInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("OrderBilledInDolibarr", $object->ref); } - $object->actionmsg = $langs->transnoentities("OrderBilledInDolibarr", $object->ref); $object->sendtoid = 0; } elseif ($action == 'ORDER_CANCEL') { @@ -278,9 +371,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "orders")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref); } - $object->actionmsg = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref); $object->sendtoid = 0; } elseif ($action == 'ORDER_SENTBYMAIL') { @@ -288,7 +387,11 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "orders")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("OrderSentByEMail", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("OrderSentByEMail", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("OrderSentByEMail", $object->ref); @@ -301,9 +404,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "bills")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); } - $object->actionmsg = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); $object->sendtoid = 0; } elseif ($action == 'BILL_UNVALIDATE') { @@ -311,9 +420,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "bills")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); } - $object->actionmsg = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); $object->sendtoid = 0; } elseif ($action == 'BILL_SENTBYMAIL') { @@ -321,7 +436,11 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "bills")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("InvoiceSentByEMail", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("InvoiceSentByEMail", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("InvoiceSentByEMail", $object->ref); @@ -334,8 +453,16 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "bills")); // Values for this action can't be defined by caller. - $object->actionmsg2 = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); - $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); + if (empty($object->actionmsg2)) { + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); + } $object->sendtoid = 0; } elseif ($action == 'BILL_CANCEL') { @@ -343,9 +470,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "bills")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); } - $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); $object->sendtoid = 0; } elseif ($action == 'FICHINTER_CREATE') { @@ -353,9 +486,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "interventions")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("InterventionCreatedInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("InterventionCreatedInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("InterventionCreatedInDolibarr", $object->ref); } - $object->actionmsg = $langs->transnoentities("InterventionCreatedInDolibarr", $object->ref); $object->sendtoid = 0; $object->fk_element = 0; @@ -365,9 +504,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "interventions")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("InterventionValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("InterventionValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("InterventionValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); } - $object->actionmsg = $langs->transnoentities("InterventionValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); $object->sendtoid = 0; $object->fk_element = 0; @@ -377,9 +522,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "interventions")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("InterventionModifiedInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("InterventionModifiedInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("InterventionModifiedInDolibarr", $object->ref); } - $object->actionmsg = $langs->transnoentities("InterventionModifiedInDolibarr", $object->ref); $object->sendtoid = 0; $object->fk_element = 0; @@ -389,7 +540,11 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "interventions")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("InterventionSentByEMail", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("InterventionSentByEMail", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("InterventionSentByEMail", $object->ref); @@ -402,9 +557,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "interventions")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref); } - $object->actionmsg = $langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref); $object->sendtoid = 0; } elseif ($action == 'FICHINTER_CLASSIFY_UNBILLED') { @@ -412,9 +573,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "interventions")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref); } - $object->actionmsg = $langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref); $object->sendtoid = 0; } elseif ($action == 'FICHINTER_DELETE') { @@ -422,9 +589,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "interventions")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("InterventionDeletedInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("InterventionDeletedInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("InterventionDeletedInDolibarr", $object->ref); } - $object->actionmsg = $langs->transnoentities("InterventionDeletedInDolibarr", $object->ref); $object->sendtoid = 0; $object->fk_element = 0; @@ -434,7 +607,11 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "sendings")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("ShippingValidated", ($object->newref ? $object->newref : $object->ref)); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("ShippingValidated", ($object->newref ? $object->newref : $object->ref)); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("ShippingValidated", ($object->newref ? $object->newref : $object->ref)); @@ -447,7 +624,11 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "sendings")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("ShippingSentByEMail", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("ShippingSentByEMail", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("ShippingSentByEMail", $object->ref); @@ -461,7 +642,11 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("receptions"); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("ReceptionValidated", ($object->newref ? $object->newref : $object->ref)); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("ReceptionValidated", ($object->newref ? $object->newref : $object->ref)); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("ReceptionValidated", ($object->newref ? $object->newref : $object->ref)); @@ -475,7 +660,11 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("receptions"); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("ReceptionSentByEMail", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("ReceptionSentByEMail", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("ReceptionSentByEMail", $object->ref); @@ -488,9 +677,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "propal")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); } - $object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); $object->sendtoid = 0; } elseif ($action == 'PROPOSAL_SUPPLIER_SENTBYMAIL') { @@ -498,7 +693,11 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "propal")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("ProposalSentByEMail", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("ProposalSentByEMail", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("ProposalSentByEMail", $object->ref); @@ -511,9 +710,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "propal")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); } - $object->actionmsg = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); $object->sendtoid = 0; } elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_REFUSED') { @@ -521,9 +726,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "propal")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); } - $object->actionmsg = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); $object->sendtoid = 0; } elseif ($action == 'ORDER_SUPPLIER_CREATE') { @@ -531,9 +742,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "orders")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("OrderCreatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("OrderCreatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("OrderCreatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); } - $object->actionmsg = $langs->transnoentities("OrderCreatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); $object->sendtoid = 0; } elseif ($action == 'ORDER_SUPPLIER_VALIDATE') { @@ -541,9 +758,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "orders")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); } - $object->actionmsg = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); $object->sendtoid = 0; } elseif ($action == 'ORDER_SUPPLIER_APPROVE') { @@ -551,9 +774,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "orders")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("OrderApprovedInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("OrderApprovedInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("OrderApprovedInDolibarr", $object->ref); } - $object->actionmsg = $langs->transnoentities("OrderApprovedInDolibarr", $object->ref); $object->sendtoid = 0; } elseif ($action == 'ORDER_SUPPLIER_REFUSE') { @@ -561,9 +790,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "orders", "main")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("OrderRefusedInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("OrderRefusedInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("OrderRefusedInDolibarr", $object->ref); } - $object->actionmsg = $langs->transnoentities("OrderRefusedInDolibarr", $object->ref); if (!empty($object->refuse_note)) { $object->actionmsg .= '
    '; @@ -576,9 +811,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "orders", "main")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref); } - $object->actionmsg = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref); if (!empty($object->cancel_note)) { $object->actionmsg .= '
    '; @@ -591,9 +832,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "orders")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref ? $object->newref : $object->ref)); } - $object->actionmsg = $langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref ? $object->newref : $object->ref)); if (!empty($object->context['comments'])) { $object->actionmsg .= '
    '; @@ -606,9 +853,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "orders")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref ? $object->newref : $object->ref)); } - $object->actionmsg = $langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref ? $object->newref : $object->ref)); $object->sendtoid = 0; } elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') { @@ -616,7 +869,11 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "bills", "orders")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("SupplierOrderSentByEMail", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("SupplierOrderSentByEMail", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("SupplierOrderSentByEMail", $object->ref); @@ -629,7 +886,11 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "bills", "orders")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("SupplierOrderClassifiedBilled", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("SupplierOrderClassifiedBilled", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("SupplierOrderClassifiedBilled", $object->ref); @@ -641,9 +902,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "bills")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); } - $object->actionmsg = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); $object->sendtoid = 0; } elseif ($action == 'BILL_SUPPLIER_UNVALIDATE') { @@ -651,9 +918,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "bills")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); } - $object->actionmsg = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); $object->sendtoid = 0; } elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL') { @@ -661,7 +934,11 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "bills", "orders")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref); @@ -674,9 +951,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "bills")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); } - $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); $object->sendtoid = 0; } elseif ($action == 'BILL_SUPPLIER_CANCELED') { @@ -684,9 +967,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "bills")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); } - $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); $object->sendtoid = 0; } elseif ($action == 'MEMBER_VALIDATE') { @@ -695,11 +984,17 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "members")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("MemberValidatedInDolibarr", $object->getFullName($langs)); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("MemberValidatedInDolibarr", $object->getFullName($langs)); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("MemberValidatedInDolibarr", $object->getFullName($langs)); + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; } - $object->actionmsg = $langs->transnoentities("MemberValidatedInDolibarr", $object->getFullName($langs)); - $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); - $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; $object->sendtoid = 0; } elseif ($action == 'MEMBER_MODIFY') { @@ -707,11 +1002,17 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "members")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("MemberModifiedInDolibarr", $object->getFullName($langs)); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("MemberModifiedInDolibarr", $object->getFullName($langs)); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("MemberModifiedInDolibarr", $object->getFullName($langs)); + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; } - $object->actionmsg = $langs->transnoentities("MemberModifiedInDolibarr", $object->getFullName($langs)); - $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); - $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; $object->sendtoid = 0; } elseif ($action == 'MEMBER_SUBSCRIPTION_CREATE') { @@ -727,13 +1028,19 @@ class InterfaceActionsAuto extends DolibarrTriggers } if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs)); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs)); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs)); + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$member->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->fk_type; + $object->actionmsg .= "\n".$langs->transnoentities("Amount").': '.$object->amount; + $object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day'); } - $object->actionmsg = $langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs)); - $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$member->getFullName($langs); - $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->fk_type; - $object->actionmsg .= "\n".$langs->transnoentities("Amount").': '.$object->amount; - $object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day'); $object->sendtoid = 0; if (isset($object->fk_soc) && $object->fk_soc > 0) { @@ -751,13 +1058,19 @@ class InterfaceActionsAuto extends DolibarrTriggers } if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs)); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs)); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs)); + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$member->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->fk_type; + $object->actionmsg .= "\n".$langs->transnoentities("Amount").': '.$object->amount; + $object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day'); } - $object->actionmsg = $langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs)); - $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$member->getFullName($langs); - $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->fk_type; - $object->actionmsg .= "\n".$langs->transnoentities("Amount").': '.$object->amount; - $object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day'); $object->sendtoid = 0; if ($object->fk_soc > 0) { @@ -775,13 +1088,19 @@ class InterfaceActionsAuto extends DolibarrTriggers $member->fetch($object->fk_adherent); } - $object->actionmsg = $langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $member->getFullName($langs)); - $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$member->getFullName($langs); - $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->fk_type; - $object->actionmsg .= "\n".$langs->transnoentities("Amount").': '.$object->amount; - $object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day'); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $member->getFullName($langs)); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $member->getFullName($langs)); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $member->getFullName($langs)); + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$member->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->fk_type; + $object->actionmsg .= "\n".$langs->transnoentities("Amount").': '.$object->amount; + $object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day'); } $object->sendtoid = 0; @@ -793,11 +1112,17 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "members")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("MemberResiliatedInDolibarr", $object->getFullName($langs)); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("MemberResiliatedInDolibarr", $object->getFullName($langs)); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("MemberResiliatedInDolibarr", $object->getFullName($langs)); + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; } - $object->actionmsg = $langs->transnoentities("MemberResiliatedInDolibarr", $object->getFullName($langs)); - $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); - $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; $object->sendtoid = 0; } elseif ($action == 'MEMBER_DELETE') { @@ -805,11 +1130,17 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "members")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("MemberDeletedInDolibarr", $object->getFullName($langs)); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("MemberDeletedInDolibarr", $object->getFullName($langs)); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("MemberDeletedInDolibarr", $object->getFullName($langs)); + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; } - $object->actionmsg = $langs->transnoentities("MemberDeletedInDolibarr", $object->getFullName($langs)); - $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); - $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; $object->sendtoid = 0; } elseif ($action == 'MEMBER_EXCLUDE') { @@ -817,11 +1148,17 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "members")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("MemberExcludedInDolibarr", $object->getFullName($langs)); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("MemberExcludedInDolibarr", $object->getFullName($langs)); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("MemberExcludedInDolibarr", $object->getFullName($langs)); + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; } - $object->actionmsg = $langs->transnoentities("MemberExcludedInDolibarr", $object->getFullName($langs)); - $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); - $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; $object->sendtoid = 0; } elseif ($action == 'PROJECT_CREATE') { @@ -830,10 +1167,16 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "projects")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("ProjectCreatedInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("ProjectCreatedInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("ProjectCreatedInDolibarr", $object->ref); + $object->actionmsg .= "\n".$langs->transnoentities("Project").': '.$object->ref; } - $object->actionmsg = $langs->transnoentities("ProjectCreatedInDolibarr", $object->ref); - $object->actionmsg .= "\n".$langs->transnoentities("Project").': '.$object->ref; $object->sendtoid = 0; } elseif ($action == 'PROJECT_VALIDATE') { @@ -841,10 +1184,16 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "projects")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("ProjectValidatedInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("ProjectValidatedInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("ProjectValidatedInDolibarr", $object->ref); + $object->actionmsg .= "\n".$langs->transnoentities("Project").': '.$object->ref; } - $object->actionmsg = $langs->transnoentities("ProjectValidatedInDolibarr", $object->ref); - $object->actionmsg .= "\n".$langs->transnoentities("Project").': '.$object->ref; $object->sendtoid = 0; } elseif ($action == 'PROJECT_MODIFY') { @@ -852,9 +1201,16 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "projects")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("ProjectModifiedInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("ProjectModifiedInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } } - $object->actionmsg = $langs->transnoentities("ProjectModifiedInDolibarr", $object->ref); + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("ProjectModifiedInDolibarr", $object->ref); + } + //$object->actionmsg .= "\n".$langs->transnoentities("Task").': ???'; if (!empty($object->usage_opportunity) && is_object($object->oldcopy) && $object->opp_status != $object->oldcopy->opp_status) { $object->actionmsg .= "\n".$langs->transnoentitiesnoconv("OpportunityStatus").': '.$object->oldcopy->opp_status.' -> '.$object->opp_status; @@ -866,7 +1222,11 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "projects")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("ProjectSentByEMail", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("ProjectSentByEMail", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("ProjectSentByEMail", $object->ref); @@ -879,9 +1239,15 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "projects")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("ProjectClosedInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("ProjectClosedInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("ProjectClosedInDolibarr", $object->ref); } - $object->actionmsg = $langs->transnoentities("ProjectClosedInDolibarr", $object->ref); $object->sendtoid = 0; } elseif ($action == 'TASK_CREATE') { @@ -890,10 +1256,16 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "projects")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("TaskCreatedInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("TaskCreatedInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("TaskCreatedInDolibarr", $object->ref); + $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref; } - $object->actionmsg = $langs->transnoentities("TaskCreatedInDolibarr", $object->ref); - $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref; $object->sendtoid = 0; } elseif ($action == 'TASK_MODIFY') { @@ -901,10 +1273,16 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "projects")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("TaskModifiedInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("TaskModifiedInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("TaskModifieddInDolibarr", $object->ref); + $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref; } - $object->actionmsg = $langs->transnoentities("TaskModifieddInDolibarr", $object->ref); - $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref; $object->sendtoid = 0; } elseif ($action == 'TASK_DELETE') { @@ -912,10 +1290,16 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "projects")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("TaskDeletedInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("TaskDeletedInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } + } + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("TaskDeletedInDolibarr", $object->ref); + $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref; } - $object->actionmsg = $langs->transnoentities("TaskDeletedInDolibarr", $object->ref); - $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref; $object->sendtoid = 0; } elseif ($action == 'TICKET_ASSIGNED') { @@ -923,9 +1307,16 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->loadLangs(array("agenda", "other", "projects")); if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref); + if (empty($object->context['actionmsg2'])) { + $object->actionmsg2 = $langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref); + } else { + $object->actionmsg2 = $object->context['actionmsg2']; + } } - $object->actionmsg = $langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref); + if (empty($object->actionmsg)) { + $object->actionmsg = $langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref); + } + if ($object->oldcopy->fk_user_assign > 0) { $tmpuser = new User($this->db); $tmpuser->fetch($object->oldcopy->fk_user_assign); @@ -940,6 +1331,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } else { $object->actionmsg .= "\n".$langs->transnoentities("NewUser").': '.$langs->trans("None"); } + $object->sendtoid = 0; } else { // TODO Merge all previous cases into this generic one @@ -947,8 +1339,15 @@ class InterfaceActionsAuto extends DolibarrTriggers // Can also be a value defined by an external module like SENTBYSMS, COMPANY_SENTBYSMS, MEMBER_SENTBYSMS, ... // Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function). // Note that these key can be set in agenda setup, only if defined into llx_c_action_trigger - // Load translation files required by the page + if (!empty($object->context['actionmsg']) && empty($object->actionmsg)) { // For description + $object->actionmsg = $object->context['actionmsg']; + } + if (!empty($object->context['actionmsg2']) && empty($object->actionmsg2)) { // For label + $object->actionmsg2 = $object->context['actionmsg2']; + } + if (empty($object->actionmsg2)) { + // Load translation files required by the page $langs->loadLangs(array("agenda", "other")); if ($langs->transnoentities($action."InDolibarr", (empty($object->newref) ? $object->ref : $object->newref)) != $action."InDolibarr") { // specific translation key $object->actionmsg2 = $langs->transnoentities($action."InDolibarr", (empty($object->newref) ? $object->ref : $object->newref)); @@ -958,6 +1357,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } } if (empty($object->actionmsg)) { + // Load translation files required by the page $langs->loadLangs(array("agenda", "other")); if ($langs->transnoentities($action."InDolibarr", (empty($object->newref) ? $object->ref : $object->newref)) != $action."InDolibarr") { // specific translation key $object->actionmsg = $langs->transnoentities($action."InDolibarr", (empty($object->newref) ? $object->ref : $object->newref)); @@ -1022,14 +1422,6 @@ class InterfaceActionsAuto extends DolibarrTriggers } } - /* Seems no more required: We have the data in dedicated field now. - if (!empty($user->login)) { - $object->actionmsg = dol_concatdesc($langs->transnoentities("Author").': '.$user->login, $object->actionmsg); - } elseif (isset($object->origin_email)) { - $object->actionmsg = dol_concatdesc($langs->transnoentities("Author").': '.$object->origin_email, $object->actionmsg); - } - */ - dol_syslog("Trigger '".$this->name."' for action '".$action."' launched by ".__FILE__.". id=".$object->id); // Add entry in event table @@ -1041,28 +1433,27 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = dol_concatdesc($object->actionmsg, "\n".$langs->transnoentities("AttachedFiles").': '.$attachs); } } - require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; - require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $contactforaction = new Contact($this->db); - $societeforaction = new Societe($this->db); - // Set contactforaction if there is only 1 contact. + $societeforactionid = 0; + $contactforactionid = 0; + + // Set $contactforactionid if (is_array($object->sendtoid)) { if (count($object->sendtoid) == 1) { - $contactforaction->fetch(reset($object->sendtoid)); + $contactforactionid = reset($object->sendtoid); } } else { if ($object->sendtoid > 0) { - $contactforaction->fetch($object->sendtoid); + $contactforactionid = $object->sendtoid; } } - // Set societeforaction. + // Set $societeforactionid if (isset($object->socid) && $object->socid > 0) { - $societeforaction->fetch($object->socid); + $societeforactionid = $object->socid; } elseif (isset($object->fk_soc) && $object->fk_soc > 0) { - $societeforaction->fetch($object->fk_soc); + $societeforactionid = $object->fk_soc; } elseif (isset($object->thirdparty) && isset($object->thirdparty->id) && $object->thirdparty->id > 0) { - $societeforaction = $object->thirdparty; + $societeforactionid = $object->thirdparty->id; } $projectid = isset($object->fk_project) ? $object->fk_project : 0; @@ -1091,8 +1482,8 @@ class InterfaceActionsAuto extends DolibarrTriggers $actioncomm->datef = $now; $actioncomm->durationp = 0; $actioncomm->percentage = -1; // Not applicable - $actioncomm->socid = $societeforaction->id; - $actioncomm->contact_id = $contactforaction->id; // deprecated, use ->socpeopleassigned instead + $actioncomm->socid = $societeforactionid; + $actioncomm->contact_id = $contactforactionid; // deprecated, now managed by setting $actioncomm->socpeopleassigned later $actioncomm->authorid = $user->id; // User saving action $actioncomm->userownerid = $user->id; // Owner of action // Fields defined when action is an email (content should be into object->actionmsg to be added into event note, subject should be into object->actionms2 to be added into event label) @@ -1142,6 +1533,9 @@ class InterfaceActionsAuto extends DolibarrTriggers } } + // Reset value set by caller + unset($object->context['actionmsg']); + unset($object->context['actionmsg2']); unset($object->actionmsg); unset($object->actionmsg2); unset($object->actiontypecode); // When several action are called on same object, we must be sure to not reuse value of first action. diff --git a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php index d7d70244e01..b922e5a10af 100644 --- a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php @@ -89,6 +89,11 @@ class InterfaceLdapsynchro extends DolibarrTriggers $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info); + //For compatibility with Samba 4 AD + if ($ldap->serverType == "activedirectory") { + $info['userAccountControl'] = $conf->global->LDAP_USERACCOUNTCONTROL; + } + $result = $ldap->add($dn, $info, $user); } @@ -210,6 +215,33 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'USER_ENABLEDISABLE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + if (intval($conf->global->LDAP_SYNCHRO_ACTIVE) === Ldap::SYNCHRO_DOLIBARR_TO_LDAP && $conf->global->LDAP_SERVER_TYPE == "activedirectory") { + $ldap = new Ldap(); + $result = $ldap->connect_bind(); + if ($result > 0) { + $info = $object->_load_ldap_info(); + $dn = $object->_load_ldap_dn($info); + $search = "(" . $object->_load_ldap_dn($info, 2) . ")"; + $uAC = $ldap->getAttributeValues($search, "userAccountControl"); + if ($uAC["count"] == 1) { + $userAccountControl = intval($uAC[0]); + $enabledBitMask = 0x2; + $isEnabled = ($userAccountControl & $enabledBitMask) === 0; + if ($isEnabled && intval($object->statut) === 1) { + $userAccountControl += 2; + } elseif (!$isEnabled && intval($object->statut) === 0) { + $userAccountControl -= 2; + } + $info['userAccountControl'] = $userAccountControl; + $resUpdate = $ldap->update($dn, $info, $user, $dn); + if ($resUpdate < 0) { + $this->error = "ErrorLDAP " . $ldap->error; + } + } + } else { + $this->error = "ErrorLDAP " . $ldap->error; + } + } } elseif ($action == 'USER_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { @@ -227,74 +259,6 @@ class InterfaceLdapsynchro extends DolibarrTriggers $this->error = "ErrorLDAP ".$ldap->error; } } - /*} elseif ($action == 'USER_SETINGROUP') { - dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { - $ldap = new Ldap(); - $result = $ldap->connect_bind(); - - if ($result > 0) { - // Must edit $object->newgroupid - $usergroup = new UserGroup($this->db); - if ($object->newgroupid > 0) { - $usergroup->fetch($object->newgroupid); - - $oldinfo = $usergroup->_load_ldap_info(); - $olddn = $usergroup->_load_ldap_dn($oldinfo); - - // Verify if entry exist - $container = $usergroup->_load_ldap_dn($oldinfo, 1); - $search = "(".$usergroup->_load_ldap_dn($oldinfo, 2).")"; - $records = $ldap->search($container, $search); - if (count($records) && $records['count'] == 0) { - $olddn = ''; - } - - $info = $usergroup->_load_ldap_info(); // Contains all members, included the new one (insert already done before trigger call) - $dn = $usergroup->_load_ldap_dn($info); - - $result = $ldap->update($dn, $info, $user, $olddn); - } - } - - if ($result < 0) { - $this->error = "ErrorLDAP ".$ldap->error; - } - } - } elseif ($action == 'USER_REMOVEFROMGROUP') { - dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { - $ldap = new Ldap(); - $result = $ldap->connect_bind(); - - if ($result > 0) { - // Must edit $object->newgroupid - $usergroup = new UserGroup($this->db); - if ($object->oldgroupid > 0) { - $usergroup->fetch($object->oldgroupid); - - $oldinfo = $usergroup->_load_ldap_info(); - $olddn = $usergroup->_load_ldap_dn($oldinfo); - - // Verify if entry exist - $container = $usergroup->_load_ldap_dn($oldinfo, 1); - $search = "(".$usergroup->_load_ldap_dn($oldinfo, 2).")"; - $records = $ldap->search($container, $search); - if (count($records) && $records['count'] == 0) { - $olddn = ''; - } - - $info = $usergroup->_load_ldap_info(); // Contains all members, included the new one (insert already done before trigger call) - $dn = $usergroup->_load_ldap_dn($info); - - $result = $ldap->update($dn, $info, $user, $olddn); - } - } - - if ($result < 0) { - $this->error = "ErrorLDAP ".$ldap->error; - } - } */ } elseif ($action == 'USERGROUP_CREATE') { // Groupes dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); @@ -311,9 +275,18 @@ class InterfaceLdapsynchro extends DolibarrTriggers $info['gidNumber'] = $ldap->getNextGroupGid('LDAP_KEY_GROUPS'); } + // Avoid Ldap error due to empty member + if (isset($info['member']) && empty($info['member'])) { + unset($info['member']); + } + $result = $ldap->add($dn, $info, $user); } + if ($ldap->serverType == "activedirectory") { + $info['sAMAccountName'] = $object->name; + } + if ($result < 0) { $this->error = "ErrorLDAP ".$ldap->error; } diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php index 1aa21dbd1ba..ee78895f99b 100644 --- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php +++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php @@ -66,10 +66,26 @@ class InterfaceNotification extends DolibarrTriggers */ public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { + global $hookmanager; + if (empty($conf->notification) || !isModEnabled('notification')) { return 0; // Module not active, we do nothing } + if (!is_object($hookmanager)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($this->db); + } + $hookmanager->initHooks(array('notification')); + + $parameters = array(); + $reshook = $hookmanager->executeHooks('notifsupported', $parameters, $object, $action); + if (empty($reshook)) { + if (!empty($hookmanager->resArray['arrayofnotifsupported'])) { + $this->listofmanagedevents = array_merge($this->listofmanagedevents, $hookmanager->resArray['arrayofnotifsupported']); + } + } + // If the trigger code is not managed by the Notification module if (!in_array($action, $this->listofmanagedevents)) { return 0; @@ -83,7 +99,6 @@ class InterfaceNotification extends DolibarrTriggers return 1; } - /** * Return list of events managed by notification module * diff --git a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php index f18526a9d19..f2d13ffbbd9 100644 --- a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php +++ b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php @@ -60,6 +60,8 @@ class InterfaceTicketEmail extends DolibarrTriggers */ public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { + global $mysoc; + $ok = 0; if (empty($conf->ticket) || !isModEnabled('ticket')) { @@ -82,8 +84,10 @@ class InterfaceTicketEmail extends DolibarrTriggers $filename = array(); $mimetype = array(); + $appli = $mysoc->name; + // Send email to assigned user - $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketAssignedToYou'); + $subject = '['.$appli.'] '.$langs->transnoentities('TicketAssignedToYou'); $message = '

    '.$langs->transnoentities('TicketAssignedEmailBody', $object->track_id, dolGetFirstLastname($user->firstname, $user->lastname))."

    "; $message .= '
    • '.$langs->trans('Title').' : '.$object->subject.'
    • '; $message .= '
    • '.$langs->trans('Type').' : '.$object->type_label.'
    • '; @@ -307,8 +311,10 @@ class InterfaceTicketEmail extends DolibarrTriggers $filename = array(); $mimetype = array(); + $appli = $mysoc->name; + /* Send email to admin */ - $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities($base_subject, $object->ref, $object->track_id); + $subject = '['.$appli.'] '.$langs->transnoentities($base_subject, $object->ref, $object->track_id); $message_admin = $langs->transnoentities($body, $object->track_id).'
      '; $message_admin .= '
      • '.$langs->trans('Title').' : '.$object->subject.'
      • '; $message_admin .= '
      • '.$langs->trans('Type').' : '.$langs->getLabelFromKey($this->db, 'TicketTypeShort'.$object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code).'
      • '; @@ -377,7 +383,7 @@ class InterfaceTicketEmail extends DolibarrTriggers $filename = array(); $mimetype = array(); - $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities($base_subject); + $subject = '['.$appli.'] '.$langs->transnoentities($base_subject); $message_customer = $langs->transnoentities($body, $object->track_id).'
        '; $message_customer .= '
        • '.$langs->trans('Title').' : '.$object->subject.'
        • '; $message_customer .= '
        • '.$langs->trans('Type').' : '.$langs->getLabelFromKey($this->db, 'TicketTypeShort'.$object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code).'
        • '; diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index ff6a536a8c5..bcc70dd15d2 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -1057,7 +1057,7 @@ class Cronjob extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { @@ -1270,7 +1270,7 @@ class Cronjob extends CommonObject } if (!$error) { - dol_syslog(get_class($this)."::run_jobs START ".$this->objectname."->".$this->methodename."(".$this->params.");", LOG_DEBUG); + dol_syslog(get_class($this)."::run_jobs START ".$this->objectname."->".$this->methodename."(".$this->params."); !!! Log for job may be into a different log file...", LOG_DEBUG); // Create Object for the called module $nameofclass = $this->objectname; diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index f50816414c7..5cb492710ba 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -53,10 +53,10 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (!$sortfield) { - $sortfield = 't.status,t.priority'; + $sortfield = 't.priority,t.status'; } if (!$sortorder) { - $sortorder = 'DESC,ASC'; + $sortorder = 'ASC,DESC'; } $optioncss = GETPOST('optioncss', 'alpha'); $mode = GETPOST('mode', 'aZ09'); @@ -754,7 +754,7 @@ if ($num > 0) { $i++; } } else { - print '
    '; + print ''; } print '
     '.$langs->trans("Position"); print ''; print img_picto('A-Z', '1downarrow.png'); @@ -82,7 +85,10 @@ print ''.$form->textwithpicto($langs->trans("CssOnList"), $la if (isModEnabled('multicompany')) { print ''.$langs->trans("Entity").'  
    '; + print ''.img_edit().''; + print '  '.img_delete().''; + if ($extrafields->attributes[$elementtype]['type'][$key] == 'password' && !empty($extrafields->attributes[$elementtype]['param'][$key]['options']) && array_key_exists('dolcrypt', $extrafields->attributes[$elementtype]['param'][$key]['options'])) { + print '  '.img_picto('', 'refresh').''; + } + print '".dol_escape_htmltag($extrafields->attributes[$elementtype]['pos'][$key])."'; + print getPictoForType($extrafields->attributes[$elementtype]['type'][$key]); print dol_escape_htmltag($typetoshow); print "'; - print ''.img_edit().''; - print '  '.img_delete().''; - print ''; + print ''.img_edit().''; + print '  '.img_delete().''; + if ($extrafields->attributes[$elementtype]['type'][$key] == 'password' && !empty($extrafields->attributes[$elementtype]['param'][$key]['options']) && array_key_exists('dolcrypt', $extrafields->attributes[$elementtype]['param'][$key]['options'])) { + print '  '.img_picto('', 'refresh').''; + } + print '
    '.$langs->trans('CronNoJobs').'
    '.$langs->trans('CronNoJobs').'
    '; diff --git a/htdocs/datapolicy/admin/mailing.php b/htdocs/datapolicy/admin/mailing.php deleted file mode 100644 index 80597987df1..00000000000 --- a/htdocs/datapolicy/admin/mailing.php +++ /dev/null @@ -1,73 +0,0 @@ - - * Copyright (C) 2019 Frédéric France - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/datapolicy/admin/mailing.php - * \ingroup datapolicy - * \brief Page called by the setupmail.php page to send agreements by email. - */ - -// Load Dolibarr environment -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; -require_once DOL_DOCUMENT_ROOT.'/datapolicy/class/datapolicy.class.php'; - -$idcontact = GETPOST('idc', 'int'); -$idcompany = GETPOST('ids', 'int'); -$idmember = GETPOST('ida', 'int'); - -// Security -if (!isModEnabled("datapolicy")) { - accessforbidden(); -} -if (!$user->admin) { - accessforbidden(); -} - - -/* - * Actions - */ - -if (!empty($idcontact)) { - $contact = new Contact($db); - $contact->fetch($idcontact); - DataPolicy::sendMailDataPolicyContact($contact); -} elseif (!empty($idcompany)) { - $company = new Societe($db); - $company->fetch($idcompany); - DataPolicy::sendMailDataPolicyCompany($company); -} elseif (!empty($idmember)) { - $member = new Adherent($db); - $member->fetch($idmember); - DataPolicy::sendMailDataPolicyAdherent($member); -} else { - $contacts = new DataPolicy($db); - - // Send email to all contacts where email was not already sent - $contacts->getAllContactNotInformed(); - $contacts->getAllCompaniesNotInformed(); - $contacts->getAllAdherentsNotInformed(); -} - - -/* - * View - */ - -echo $langs->trans('AllAgreementSend'); diff --git a/htdocs/datapolicy/admin/setupmail.php b/htdocs/datapolicy/admin/setupmail.php index 2ceaa3332e0..94549975871 100644 --- a/htdocs/datapolicy/admin/setupmail.php +++ b/htdocs/datapolicy/admin/setupmail.php @@ -155,14 +155,14 @@ print ''; print $langs->trans('DATAPOLICYACCEPT').''; -$doleditor = new DolEditor($acc, $conf->global->$acc, '', 250, 'Full', '', false, true, 1, 200, 70); +$doleditor = new DolEditor($acc, getDolGlobalString($acc), '', 250, 'Full', '', false, true, 1, 200, 70); $doleditor->Create(); print ''; print ''; print $langs->trans('DATAPOLICYREFUSE').''; print $langs->trans(''); -$doleditor = new DolEditor($ref, $conf->global->$ref, '', 250, 'Full', '', false, true, 1, 200, 70); +$doleditor = new DolEditor($ref, getDolGlobalString($ref), '', 250, 'Full', '', false, true, 1, 200, 70); $doleditor->Create(); print ''; print ''; @@ -173,10 +173,5 @@ print ''; print dol_get_fiche_end(); -print '

    '; - -print $langs->trans('SendAgreementText'); -print ''.$langs->trans('SendAgreementRequestByEmail').''; - llxFooter(); $db->close(); diff --git a/htdocs/datapolicy/class/actions_datapolicy.class.php b/htdocs/datapolicy/class/actions_datapolicy.class.php index 80864f78d6f..a99613097c9 100644 --- a/htdocs/datapolicy/class/actions_datapolicy.class.php +++ b/htdocs/datapolicy/class/actions_datapolicy.class.php @@ -22,10 +22,12 @@ * \brief Example hook overload. */ +require_once DOL_DOCUMENT_ROOT.'/core/class/commonhookactions.class.php'; + /** * Class ActionsDatapolicy */ -class ActionsDatapolicy +class ActionsDatapolicy extends CommonHookActions { /** * @var DoliDB Database handler. @@ -157,7 +159,7 @@ class ActionsDatapolicy } /** - * Overloading the doActions function : replacing the parent's function with the one below + * Overloading the doMassActions function : replacing the parent's function with the one below * * @param array $parameters Hook metadatas (context, etc...) * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) diff --git a/htdocs/datapolicy/class/datapolicy.class.php b/htdocs/datapolicy/class/datapolicy.class.php index e83730c89e2..92580fbb785 100644 --- a/htdocs/datapolicy/class/datapolicy.class.php +++ b/htdocs/datapolicy/class/datapolicy.class.php @@ -31,6 +31,14 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; */ class DataPolicy { + /** + * @var DoliDB Database handler. + */ + public $db; + + public $error; + + /** * Constructor * @@ -214,11 +222,13 @@ class DataPolicy require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1); + $resultmasssend = ''; if ($mailfile->error) { $resultmasssend .= '
    '.$mailfile->error.'
    '; } else { - $result4 = $mailfile->sendfile(); - if (!$error) { + $resultmail = $mailfile->sendfile(); + + if ($resultmail) { $resultmasssend .= $langs->trans("MailSent").': '.$sendto."
    "; $contact->array_options['options_datapolicy_send'] = date('Y-m-d', time()); $contact->update($contact->id); @@ -286,12 +296,14 @@ class DataPolicy // Send mail require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1); + + $resultmasssend = ''; if ($mailfile->error) { $resultmasssend .= '
    '.$mailfile->error.'
    '; } else { - $result4 = $mailfile->sendfile(); + $resultmail = $mailfile->sendfile(); - if (!$error) { + if ($resultmail) { $resultmasssend .= $langs->trans("MailSent").': '.$sendto."
    "; $societe->array_options['options_datapolicy_send'] = date('Y-m-d', time()); $societe->update($societe->id); @@ -363,9 +375,9 @@ class DataPolicy if ($mailfile->error) { $resultmasssend .= '
    '.$mailfile->error.'
    '; } else { - $result4 = $mailfile->sendfile(); + $resultmail = $mailfile->sendfile(); - if (!$error) { + if ($resultmail) { $resultmasssend .= $langs->trans("MailSent").': '.$sendto."
    "; $adherent->array_options['options_datapolicy_send'] = date('Y-m-d', time()); $adherent->update($user); diff --git a/htdocs/datapolicy/class/datapolicycron.class.php b/htdocs/datapolicy/class/datapolicycron.class.php index 7383d303a7c..464572b52dd 100644 --- a/htdocs/datapolicy/class/datapolicycron.class.php +++ b/htdocs/datapolicy/class/datapolicycron.class.php @@ -32,6 +32,11 @@ class DataPolicyCron */ public $db; + public $error; + + public $output; + + /** * Constructor * diff --git a/htdocs/debugbar/class/TraceableDB.php b/htdocs/debugbar/class/TraceableDB.php index 3622558731f..093790c5a45 100644 --- a/htdocs/debugbar/class/TraceableDB.php +++ b/htdocs/debugbar/class/TraceableDB.php @@ -164,9 +164,9 @@ class TraceableDB extends DoliDB * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) * @return string SQL request line converted */ - public static function convertSQLFromMysql($line, $type = 'ddl') + public function convertSQLFromMysql($line, $type = 'ddl') { - return self::$db->convertSQLFromMysql($line); + return $this->db->convertSQLFromMysql($line); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index 7d528f0d051..fb92c912aff 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -349,7 +349,6 @@ class Delivery extends CommonObject $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; // deprecated $this->origin = $obj->origin; // May be 'shipping' $this->origin_id = $obj->origin_id; // May be id of shipping @@ -786,7 +785,7 @@ class Delivery extends CommonObject //{ // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { @@ -851,17 +850,16 @@ class Delivery extends CommonObject $line->id = $obj->rowid; $line->label = $obj->custom_label; - $line->description = $obj->description; - $line->fk_product = $obj->fk_product; - $line->qty_asked = $obj->qty_asked; - $line->qty_shipped = $obj->qty_shipped; + $line->description = $obj->description; + $line->fk_product = $obj->fk_product; + $line->qty_asked = $obj->qty_asked; + $line->qty_shipped = $obj->qty_shipped; - $line->ref = $obj->product_ref; // deprecated - $line->libelle = $obj->product_label; // deprecated $line->product_label = $obj->product_label; // Product label - $line->product_ref = $obj->product_ref; // Product ref + $line->product_ref = $obj->product_ref; // Product ref $line->product_desc = $obj->product_desc; // Product description $line->product_type = $obj->fk_product_type; + $line->fk_origin_line = $obj->fk_origin_line; $line->price = $obj->subprice; diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 1b5634e49e6..247a03563c6 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -78,7 +78,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('doncard', 'globalcard')); +$hookmanager->initHooks(array($object->element.'card', 'globalcard')); $upload_dir = $conf->don->dir_output; @@ -912,7 +912,7 @@ if (!empty($id) && $action != 'edit') { if ($object->statut == $object::STATUS_CANCELED || $object->statut == $object::STATUS_DRAFT) { print '"; } else { - print '"; + print '"; } } else { print '"; diff --git a/htdocs/don/class/api_donations.class.php b/htdocs/don/class/api_donations.class.php index 7c78275e913..8dc5bf4add6 100644 --- a/htdocs/don/class/api_donations.class.php +++ b/htdocs/don/class/api_donations.class.php @@ -57,9 +57,9 @@ class Donations extends DolibarrApi * Return an array with donation informations * * @param int $id ID of order - * @return Object Object with cleaned properties + * @return Object Object with cleaned properties * - * @throws RestException + * @throws RestException */ public function get($id) { @@ -95,11 +95,12 @@ class Donations extends DolibarrApi * @param int $page Page number * @param string $thirdparty_ids Thirdparty ids to filter orders of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @param string $properties Restrict the data returned to theses properties. Ignored if empty. Comma separated list of properties names * @return array Array of order objects * * @throws RestException */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '', $properties = '') { global $db, $conf; @@ -158,7 +159,7 @@ class Donations extends DolibarrApi if ($don_static->fetch($obj->rowid)) { // Add external contacts ids //$don_static->contacts_ids = $don_static->liste_contact(-1, 'external', 1); - $obj_ret[] = $this->_cleanObjectDatas($don_static); + $obj_ret[] = $this->_filterObjectProperties($this->_cleanObjectDatas($don_static), $properties); } $i++; } diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index c730c7d0b08..5f6a699915d 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -443,7 +443,6 @@ class Don extends CommonObject } } else { $this->error = $this->db->lasterror(); - $this->errno = $this->db->lasterrno(); $error++; } @@ -688,7 +687,6 @@ class Don extends CommonObject $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; // deprecated // Retrieve all extrafield // fetch optionals attributes and labels @@ -931,7 +929,7 @@ class Don extends CommonObject $url = DOL_URL_ROOT.'/don/card.php?id='.$this->id; $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index f808caf4e1d..f241a7ef5b5 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -580,7 +580,7 @@ class EmailCollector extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { @@ -1131,6 +1131,8 @@ class EmailCollector extends CommonObject if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { if ($this->acces_type == 1) { // Mode OAUth2 with PHP-IMAP + $supportedoauth2array = array(); + require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // define $supportedoauth2array $keyforsupportedoauth2array = $this->oauth_service; if (preg_match('/^.*-/', $keyforsupportedoauth2array)) { @@ -1630,8 +1632,15 @@ class EmailCollector extends CommonObject $emailto = $this->decodeSMTPSubject($overview[0]->to); - $operationslog .= '
    ** Process email #'.dol_escape_htmltag($iforemailloop)." - ".dol_escape_htmltag((string) $imapemail)." - References: ".dol_escape_htmltag($headers['References'])." - Subject: ".dol_escape_htmltag($headers['Subject']); - dol_syslog("** Process email ".$iforemailloop." References: ".$headers['References']." Subject: ".$headers['Subject']); + $operationslog .= '
    ** Process email #'.dol_escape_htmltag($iforemailloop); + if (getDolGlobalInt('MAIN_IMAP_USE_PHPIMAP')) { + /** @var Webklex\PHPIMAP\Message $imapemail */ + // $operationslog .= " - ".dol_escape_htmltag((string) $imapemail); + } else { + $operationslog .= " - ".dol_escape_htmltag((string) $imapemail); + } + $operationslog .= " - References: ".dol_escape_htmltag($headers['References']??'')." - Subject: ".dol_escape_htmltag($headers['Subject']); + dol_syslog("** Process email ".$iforemailloop." References: ".($headers['References']??'')." Subject: ".$headers['Subject']); $trackidfoundintorecipienttype = ''; @@ -1737,7 +1746,8 @@ class EmailCollector extends CommonObject // GET IMAP email structure/content global $htmlmsg, $plainmsg, $charset, $attachments; - if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { + if (getDolGlobalInt('MAIN_IMAP_USE_PHPIMAP')) { + /** @var Webklex\PHPIMAP\Message $imapemail */ if ($imapemail->hasHTMLBody()) { $htmlmsg = $imapemail->getHTMLBody(); } @@ -2893,7 +2903,11 @@ class EmailCollector extends CommonObject } if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { foreach ($attachments as $attachment) { - $attachment->save($destdir.'/'); + // $attachment->save($destdir.'/'); + $typeattachment = (string) $attachment->getDisposition(); + $filename = $attachment->getFilename(); + $content = $attachment->getContent(); + $this->saveAttachment($destdir, $filename, $content); } } else { $this->getmsg($connection, $imapemail, $destdir); @@ -2952,7 +2966,7 @@ class EmailCollector extends CommonObject $tickettocreate->fk_user_create = $user->id; $tickettocreate->datec = dol_now(); $tickettocreate->fk_project = $projectstatic->id; - $tickettocreate->notify_tiers_at_create = 0; + $tickettocreate->notify_tiers_at_create = getDolGlobalInt('TICKET_CHECK_NOTIFY_THIRDPARTY_AT_CREATION'); $tickettocreate->note_private = $descriptionfull; $tickettocreate->entity = $conf->entity; $tickettocreate->email_msgid = $msgid; @@ -3023,7 +3037,11 @@ class EmailCollector extends CommonObject } if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { foreach ($attachments as $attachment) { - $attachment->save($destdir.'/'); + // $attachment->save($destdir.'/'); + $typeattachment = (string) $attachment->getDisposition(); + $filename = $attachment->getFilename(); + $content = $attachment->getContent(); + $this->saveAttachment($destdir, $filename, $content); } } else { $this->getmsg($connection, $imapemail, $destdir); @@ -3135,6 +3153,7 @@ class EmailCollector extends CommonObject if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager = new HookManager($this->db); + $hookmanager->initHooks(['emailcolector']); } $parameters = array( @@ -3238,6 +3257,7 @@ class EmailCollector extends CommonObject } else { $langs->load("admin"); $output = $langs->trans('NoNewEmailToProcess'); + $output .= ' (defaultlang='.$langs->defaultlang.')'; } // Disconnect @@ -3309,7 +3329,7 @@ class EmailCollector extends CommonObject * * @param Object $mbox Structure * @param string $mid UID email - * @param string $destdir Target dir for attachments + * @param string $destdir Target dir for attachments. Leave blank to parse without writing to disk. * @return void */ private function getmsg($mbox, $mid, $destdir = '') @@ -3362,7 +3382,7 @@ class EmailCollector extends CommonObject * @param string $mid Part no * @param Object $p Object p * @param string $partno Partno - * @param string $destdir Target dir for attachments + * @param string $destdir Target dir for attachments. Leave blank to parse without writing to disk. * @return void */ private function getpart($mbox, $mid, $p, $partno, $destdir = '') @@ -3389,7 +3409,7 @@ class EmailCollector extends CommonObject $params[strtolower($x->attribute)] = $x->value; } } - if ($p->dparameters) { + if (!empty($p->dparameters)) { foreach ($p->dparameters as $x) { $params[strtolower($x->attribute)] = $x->value; } @@ -3398,44 +3418,46 @@ class EmailCollector extends CommonObject // ATTACHMENT // Any part with a filename is an attachment, // so an attached text file (type 0) is not mistaken as the message. - if ($params['filename'] || $params['name']) { + if (!empty($params['filename']) || !empty($params['name'])) { // filename may be given as 'Filename' or 'Name' or both - $filename = ($params['filename']) ? $params['filename'] : $params['name']; + $filename = $params['filename'] ?? $params['name']; // filename may be encoded, so see imap_mime_header_decode() $attachments[$filename] = $data; // this is a problem if two files have same name - // Get file name (with extension) - $file_name_complete = $params['filename']; + if (strlen($destdir)) { + if (substr($destdir, -1) != '/') $destdir .= '/'; + // Get file name (with extension) + $file_name_complete = $params['filename']; + $destination = $destdir.$file_name_complete; - $destination = $destdir.'/'.$file_name_complete; + // Extract file extension + $extension = pathinfo($file_name_complete, PATHINFO_EXTENSION); - // Extract file extension - $extension = pathinfo($file_name_complete, PATHINFO_EXTENSION); + // Extract file name without extension + $file_name = pathinfo($file_name_complete, PATHINFO_FILENAME); - // Extract file name without extension - $file_name = pathinfo($file_name_complete, PATHINFO_FILENAME); + // Save an original file name variable to track while renaming if file already exists + $file_name_original = $file_name; - // Save an original file name variable to track while renaming if file already exists - $file_name_original = $file_name; + // Increment file name by 1 + $num = 1; - // Increment file name by 1 - $num = 1; + /** + * 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 = $file_name_original . ' (' . $num . ')'; + $file_name_complete = $file_name . "." . $extension; + $destination = $destdir.$file_name_complete; + $num++; + } - /** - * 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 = $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); } - - $destination = dol_sanitizePathName($destination); - - file_put_contents($destination, $data); } // TEXT @@ -3464,9 +3486,9 @@ class EmailCollector extends CommonObject } // SUBPART RECURSION - if ($p->parts) { + if (!empty($p->parts)) { foreach ($p->parts as $partno0 => $p2) { - $this->getpart($mbox, $mid, $p2, $partno.'.'.($partno0 + 1)); // 1.2, 1.2.1, etc. + $this->getpart($mbox, $mid, $p2, $partno.'.'.($partno0 + 1), $destdir); // 1.2, 1.2.1, etc. } } } @@ -3550,4 +3572,33 @@ class EmailCollector extends CommonObject return $text; } + + /** + * saveAttachment + * + * @param string $destdir destination + * @param string $filename filename + * @param string $content content + * @return void + */ + private function saveAttachment($destdir, $filename, $content) + { + require_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; + + $tmparraysize = getDefaultImageSizes(); + $maxwidthsmall = $tmparraysize['maxwidthsmall']; + $maxheightsmall = $tmparraysize['maxheightsmall']; + $maxwidthmini = $tmparraysize['maxwidthmini']; + $maxheightmini = $tmparraysize['maxheightmini']; + $quality = $tmparraysize['quality']; + + file_put_contents($destdir.'/'.$filename, $content); + if (image_format_supported($filename) == 1) { + // Create thumbs + vignette($destdir.'/'.$filename, $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs"); + // Create mini thumbs for image (Ratio is near 16/9) + vignette($destdir.'/'.$filename, $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs"); + } + addFileIntoDatabaseIndex($destdir, $filename); + } } diff --git a/htdocs/emailcollector/class/emailcollectoraction.class.php b/htdocs/emailcollector/class/emailcollectoraction.class.php index ec985238b82..07aea7feda8 100644 --- a/htdocs/emailcollector/class/emailcollectoraction.class.php +++ b/htdocs/emailcollector/class/emailcollectoraction.class.php @@ -295,7 +295,7 @@ class EmailCollectorAction extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { diff --git a/htdocs/emailcollector/class/emailcollectorfilter.class.php b/htdocs/emailcollector/class/emailcollectorfilter.class.php index 807b16c951b..0bdb0294a27 100644 --- a/htdocs/emailcollector/class/emailcollectorfilter.class.php +++ b/htdocs/emailcollector/class/emailcollectorfilter.class.php @@ -309,7 +309,7 @@ class EmailCollectorFilter extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index a7b173acc6c..ffd3b7d1604 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -536,7 +536,7 @@ class ConferenceOrBooth extends ActionComm if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php index db41d03c328..f45066d3d11 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -780,7 +780,7 @@ class ConferenceOrBoothAttendee extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { @@ -842,7 +842,7 @@ class ConferenceOrBoothAttendee extends CommonObject $pospoint = strpos($filearray[0]['name'], '.'); $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint); - if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) { + if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) { $result .= '
    No photo
    '; } else { $result .= '
    No photo
    '; diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index 1f575c28a12..8fa96f1e9c4 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -223,6 +223,42 @@ if (empty($reshook)) { $uploaddir = $conf->eventorganization->dir_output; include DOL_DOCUMENT_ROOT.'/eventorganization/core/actions_massactions_mail.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + + if ($permissiontoadd && (($action == 'setstatus' && $confirm == "yes") || $massaction == 'setstatus')) { + $db->begin(); + $error = 0;$nbok = 0; + $objecttmp = new $objectclass($db); + foreach ($toselect as $key => $idselect) { + $result = $objecttmp->fetch($idselect); + if ($result > 0) { + $objecttmp->status = GETPOST("statusmassaction", 'int'); + $result = $objecttmp->update($user); + if ($result <= 0) { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } else { + $nbok++; + } + } else { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error ++; + break; + } + } + if (empty($error)) { + if ($nbok > 1) { + setEventMessages($langs->trans("RecordsUpdated", $nbok), null, 'mesgs'); + } elseif ($nbok > 0) { + setEventMessages($langs->trans("RecordUpdated", $nbok), null, 'mesgs'); + } else { + setEventMessages($langs->trans("NoRecordUpdated"), null, 'mesgs'); + } + $db->commit(); + } else { + $db->rollback(); + } + } } @@ -680,6 +716,9 @@ $arrayofmassactions = array( if (!empty($permissiontodelete)) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } +if (!empty($permissiontoadd)) { + $arrayofmassactions['presetstatus'] = img_picto('', 'edit', 'class="pictofixedwidth"').$langs->trans("ModifyStatus"); +} if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { $arrayofmassactions = array(); } @@ -717,6 +756,20 @@ $trackid = 'conferenceorbooth_'.$object->id; $withmaindocfilemail = 0; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; +if ($massaction == 'presetstatus') { + $formquestion = array(); + $statuslist[$objecttmp::STATUS_DRAFT] = $objecttmp->LibStatutEvent($objecttmp::STATUS_DRAFT); + $statuslist[$objecttmp::STATUS_SUGGESTED] = $objecttmp->LibStatutEvent($objecttmp::STATUS_SUGGESTED); + $statuslist[$objecttmp::STATUS_CONFIRMED] = $objecttmp->LibStatutEvent($objecttmp::STATUS_CONFIRMED); + $statuslist[$objecttmp::STATUS_NOT_QUALIFIED] = $objecttmp->LibStatutEvent($objecttmp::STATUS_NOT_QUALIFIED); + $statuslist[$objecttmp::STATUS_DONE] = $objecttmp->LibStatutEvent($objecttmp::STATUS_DONE); + $statuslist[$objecttmp::STATUS_CANCELED] = $objecttmp->LibStatutEvent($objecttmp::STATUS_CANCELED); + $formquestion[] = array('type' => 'other', + 'name' => 'affectedcommercial', + 'label' => $form->editfieldkey('ModifyStatus', 'status_id', '', $object, 0), + 'value' => $form->selectarray('statusmassaction', $statuslist, GETPOST('statusmassaction'))); + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmModifyStatus"), $langs->trans("ConfirmModifyStatusQuestion", count($toselect)), "setstatus", $formquestion, 1, 0, 200, 500, 1); +} if ($search_all) { $setupstring = ''; diff --git a/htdocs/eventorganization/conferenceorboothattendee_list.php b/htdocs/eventorganization/conferenceorboothattendee_list.php index 7404550cdba..d13d51ee655 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_list.php +++ b/htdocs/eventorganization/conferenceorboothattendee_list.php @@ -751,8 +751,10 @@ print ''; $params = array('morecss'=>'reposition'); +$urlnew = DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?action=create'.(!empty($confOrBooth->id)?'&conforboothid='.$confOrBooth->id:'').(!empty($projectstatic->id)?'&fk_project='.$projectstatic->id:'').$withProjectUrl.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?projectid='.$projectstatic->id.(empty($confOrBooth->id) ? '' : '&conforboothid='.$confOrBooth->id).$withProjectUrl); + $newcardbutton = ''; -$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?action=create'.(!empty($confOrBooth->id)?'&conforboothid='.$confOrBooth->id:'').(!empty($projectstatic->id)?'&fk_project='.$projectstatic->id:'').$withProjectUrl.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?projectid='.$projectstatic->id.(empty($confOrBooth->id) ? '' : '&conforboothid='.$confOrBooth->id).$withProjectUrl), '', $permissiontoadd, $params); +$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', $urlnew, '', $permissiontoadd, $params); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 318d66635ec..58e61c2d537 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -334,6 +334,7 @@ if (empty($reshook)) { $stockLine[$i][$j]['ix_l'] = GETPOST($idl, 'int'); $totalqty += price2num(GETPOST($qty, 'alpha'), 'MS'); + $subtotalqty += price2num(GETPOST($qty, 'alpha'), 'MS'); $j++; $stockLocation = "ent1".$i."_".$j; @@ -343,9 +344,17 @@ if (empty($reshook)) { //shipment line for product with no batch management and no multiple stock location if (GETPOST($qty, 'int') > 0) { $totalqty += price2num(GETPOST($qty, 'alpha'), 'MS'); + $subtotalqty = price2num(GETPOST($qty, 'alpha'), 'MS'); } } + // check qty shipped not greater than ordered + if (getDolGlobalInt("MAIN_DONT_SHIP_MORE_THAN_ORDERED") && $subtotalqty > $objectsrc->lines[$i]->qty) { + setEventMessages($langs->trans("ErrorTooMuchShipped", $i+1), null, 'errors'); + $error++; + continue; + } + // Extrafields $array_options[$i] = $extrafields->getOptionalsFromPost($object->table_element_line, $i); // Unset extrafield @@ -1841,7 +1850,7 @@ if ($action == 'create') { print '
    '; print '
    '; - print ''; + print '
    '; // Linked documents if ($typeobject == 'commande' && $object->$typeobject->id && isModEnabled('commande')) { @@ -1868,7 +1877,7 @@ if ($action == 'create') { // Delivery date planned print '
    '; - print '
    '; + print ''; @@ -1999,7 +2008,7 @@ if ($action == 'create') { // Sending method print '
    '; print $langs->trans('DateDeliveryPlanned'); print '
    '; - print ''; } +if (!empty($arrayfields['f.nb_docs']['checked'])) { + // Nb of attached documents + print ''; +} if (!empty($arrayfields['u.login']['checked'])) { // Author print ''; + } + // Author if (!empty($arrayfields['u.login']['checked'])) { print ''."\n"; // National Registration Number - print ''; - print ''; + print ''; print ''."\n"; } diff --git a/htdocs/imports/class/import.class.php b/htdocs/imports/class/import.class.php index b5dff8e94c7..97988a1a475 100644 --- a/htdocs/imports/class/import.class.php +++ b/htdocs/imports/class/import.class.php @@ -61,6 +61,7 @@ class Import public $array_import_entities; public $array_import_regex; public $array_import_updatekeys; + public $array_import_preselected_updatekeys; public $array_import_examplevalues; public $array_import_convertvalue; public $array_import_run_sql_after; @@ -191,6 +192,8 @@ class Import $this->array_import_regex[$i] = (isset($module->import_regex_array[$r]) ? $module->import_regex_array[$r] : ''); // Array of columns allowed as UPDATE options $this->array_import_updatekeys[$i] = (isset($module->import_updatekeys_array[$r]) ? $module->import_updatekeys_array[$r] : ''); + // Array of columns preselected as UPDATE options + $this->array_import_preselected_updatekeys[$i] = (isset($module->import_preselected_updatekeys_array[$r]) ? $module->import_preselected_updatekeys_array[$r] : ''); // Array of examples $this->array_import_examplevalues[$i] = (isset($module->import_examplevalues_array[$r]) ? $module->import_examplevalues_array[$r] : ''); // Tableau des regles de conversion d'une valeur depuis une autre source (cle=champ, valeur=tableau des regles) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 77346fd195e..9d5045ecefb 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -145,9 +145,18 @@ $enclosure = (GETPOST('enclosure', 'nohtml') ? GETPOST('enclosure', 'nohtml') $charset = GETPOST('charset', 'aZ09'); $separator_used = str_replace('\t', "\t", $separator); + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('imports')); + + $objimport = new Import($db); $objimport->load_arrays($user, ($step == 1 ? '' : $datatoimport)); +if (empty($updatekeys) && !empty($objimport->array_import_preselected_updatekeys[0])) { + $updatekeys = array_keys($objimport->array_import_preselected_updatekeys[0]); +} + $objmodelimport = new ModeleImports(); $form = new Form($db); @@ -1878,17 +1887,41 @@ if ($step == 5 && $datatoimport) { break; } - // Run import - $result = $obj->import_insert($arrayrecord, $array_match_file_to_database, $objimport, count($fieldssource), $importid, $updatekeys); + $parameters = array( + 'step' => $step, + 'datatoimport' => $datatoimport, + 'obj' => &$obj, + 'arrayrecord' => $arrayrecord, + 'array_match_file_to_database' => $array_match_file_to_database, + 'objimport' => $objimport, + 'fieldssource' => $fieldssource, + 'importid' => $importid, + 'updatekeys' => $updatekeys, + 'arrayoferrors' => &$arrayoferrors, + 'arrayofwarnings' => &$arrayofwarnings, + 'nbok' => &$nbok, + ); - if (count($obj->errors)) { - $arrayoferrors[$sourcelinenb] = $obj->errors; + $reshook = $hookmanager->executeHooks('ImportInsert', $parameters); + if ($reshook < 0) { + $arrayoferrors[$sourcelinenb][] = [ + 'lib' => implode("
    ", array_merge([$hookmanager->error], $hookmanager->errors)) + ]; } - if (count($obj->warnings)) { - $arrayofwarnings[$sourcelinenb] = $obj->warnings; - } - if (!count($obj->errors) && !count($obj->warnings)) { - $nbok++; + + if (empty($reshook)) { + // Run import + $result = $obj->import_insert($arrayrecord, $array_match_file_to_database, $objimport, count($fieldssource), $importid, $updatekeys); + + if (count($obj->errors)) { + $arrayoferrors[$sourcelinenb] = $obj->errors; + } + if (count($obj->warnings)) { + $arrayofwarnings[$sourcelinenb] = $obj->warnings; + } + if (!count($obj->errors) && !count($obj->warnings)) { + $nbok++; + } } } // Close file @@ -2263,17 +2296,49 @@ if ($step == 6 && $datatoimport) { break; } - // Run import - $result = $obj->import_insert($arrayrecord, $array_match_file_to_database, $objimport, count($fieldssource), $importid, $updatekeys); + $parameters = array( + 'step' => $step, + 'datatoimport' => $datatoimport, + 'obj' => &$obj, + 'arrayrecord' => $arrayrecord, + 'array_match_file_to_database' => $array_match_file_to_database, + 'objimport' => $objimport, + 'fieldssource' => $fieldssource, + 'importid' => $importid, + 'updatekeys' => $updatekeys, + 'arrayoferrors' => &$arrayoferrors, + 'arrayofwarnings' => &$arrayofwarnings, + 'nbok' => &$nbok, + ); - if (count($obj->errors)) { - $arrayoferrors[$sourcelinenb] = $obj->errors; + $reshook = $hookmanager->executeHooks('ImportInsert', $parameters); + if ($reshook < 0) { + $arrayoferrors[$sourcelinenb][] = [ + 'lib' => implode("
    ", array_merge([$hookmanager->error], $hookmanager->errors)) + ]; } - if (count($obj->warnings)) { - $arrayofwarnings[$sourcelinenb] = $obj->warnings; + + if (empty($reshook)) { + // Run import + $result = $obj->import_insert($arrayrecord, $array_match_file_to_database, $objimport, count($fieldssource), $importid, $updatekeys); + + if (count($obj->errors)) { + $arrayoferrors[$sourcelinenb] = $obj->errors; + } + if (count($obj->warnings)) { + $arrayofwarnings[$sourcelinenb] = $obj->warnings; + } + + if (!count($obj->errors) && !count($obj->warnings)) { + $nbok++; + } } - if (!count($obj->errors) && !count($obj->warnings)) { - $nbok++; + + $reshook = $hookmanager->executeHooks('AfterImportInsert', $parameters); + if ($reshook < 0) { + $arrayoferrors[$sourcelinenb][] = [ + 'lib' => implode("
    ", array_merge([$hookmanager->error], $hookmanager->errors)) + ]; } } // Close file diff --git a/htdocs/includes/ckeditor/UPGRADE.md b/htdocs/includes/ckeditor/UPGRADE.md index 73d46f6eb74..d0ebe558c47 100644 --- a/htdocs/includes/ckeditor/UPGRADE.md +++ b/htdocs/includes/ckeditor/UPGRADE.md @@ -1,7 +1,7 @@ To upgrade ckeditor: - Go on web site. - Choose profile "Online builder" -- Choose Full package +- Choose Custom - Full package - Add plugin SourceDialog (for "source" button on edit inline) - Choose skin mona-lisa - Choose all languages diff --git a/htdocs/includes/ckeditor/ckeditor/CHANGES.md b/htdocs/includes/ckeditor/ckeditor/CHANGES.md index 94ecf8517b9..0cfec356a8c 100644 --- a/htdocs/includes/ckeditor/ckeditor/CHANGES.md +++ b/htdocs/includes/ckeditor/ckeditor/CHANGES.md @@ -1,5 +1,162 @@ -CKEditor 4 Changelog -==================== +⚠️️️ **CKEditor 4 (the open source edition) is no longer maintained.** ⚠️ + +If you would like to keep access to future CKEditor 4 security patches, check the [Extended Support Model](https://ckeditor.com/ckeditor-4-support/), which guarantees **security updates and critical bug fixes until December 2026**. Alternatively, [upgrade to CKEditor 5](https://ckeditor.com/docs/ckeditor5/latest/updating/ckeditor4/migration-from-ckeditor-4.html). + +## CKEditor 4.22.0 / 4.22.1 + +⚠️ This is the last open source release of CKEditor 4. As announced in 2018, CKEditor 4 has reached its End of Life in June 2023. + + +New Features: + +* [#5316](https://github.com/ckeditor/ckeditor4/issues/5316): Added vertical margins support for list elements in the [Paste from Word](https://ckeditor.com/cke4/addon/pastefromword) plugin. +* [#5410](https://github.com/ckeditor/ckeditor4/issues/5410): Added the ability to indicate the language of styles in the [Styles Combo](https://ckeditor.com/cke4/addon/stylescombo) plugin via the [`config.styleSet`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-stylesSet) configuration option. +* [#5510](https://github.com/ckeditor/ckeditor4/issues/5510): Added notification system to the editor informing users that the editor version is up-to-date and secure. See [`config.versionCheck`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-versionCheck) configuration option to learn more. + +Fixed Issues: + +* [#5437](https://github.com/ckeditor/ckeditor4/issues/5437): Fixed: Incorrect indication of selected items in combo boxes. The selected item was unmarked upon each opening of the combo box. +* [#5495](https://github.com/ckeditor/ckeditor4/issues/5495): Fixed: Insufficient color ratio for links inside [Notifications](https://ckeditor.com/cke4/addon/notification). + +Other Changes: + +* [#5412](https://github.com/ckeditor/ckeditor4/issues/5412): Prevent using `document.domain` in Firefox in the [Preview](https://ckeditor.com/cke4/addon/preview) plugin. + +Note: CKEditor 4.22.1 has been released immediately after 4.22.0 to fix the README issues on [npm](https://www.npmjs.com/) and contains no changes vs 4.22.0. + +## CKEditor 4.21.0 + +**Security Updates:** + +A cross-site scripting vulnerability has been discovered affecting [Iframe Dialog](https://ckeditor.com/cke4/addon/iframe) and [Media Embed](https://ckeditor.com/cke4/addon/embed) plugins. + +This vulnerability might affect a small percentage of integrators that depend on dynamic editor initialization/destroy mechanism. See [GitHub advisory](https://github.com/ckeditor/ckeditor4/security/advisories/GHSA-vh5c-xwqv-cv9g) for more details. + +**Potential breaking changes** + +In some rare cases, a security release may introduce a breaking change to your application. We have provided configuration options that will help you mitigate any potential issues with the upgrade: + +- Starting from version 4.21, the [Iframe Dialog](https://ckeditor.com/cke4/addon/iframe) plugin applies the `sandbox` attribute by default, which restricts JavaScript code execution in the iframe element. To change this behavior, configure the [`config.iframe_attributes`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-iframe_attributes) option. +- Starting from version 4.21, the [Media Embed](https://ckeditor.com/cke4/addon/embed) plugin regenerates the entire content of the embed widget by default. To change this behavior, configure the [`config.embed_keepOriginalContent`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-embed_keepOriginalContent) option. + +If you choose to change either of the above options, make sure to properly configure [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) to avoid any potential security issues that may arise from embedding iframe elements on your web page. + +You can read more details in the relevant security advisory and [contact us](security@cksource.com) if you have more questions. + +**An upgrade is highly recommended!** + +New Features: + +* [#4400](https://github.com/ckeditor/ckeditor4/issues/4400): Added the [`config.uploadImage_supportedTypes`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-uploadImage_supportedTypes) configuration option allowing to change the image formats accepted by the [Upload Image](https://ckeditor.com/cke4/addon/uploadimage) plugin. Thanks to [SilverYoCha](https://github.com/SilverYoCha)! + +Fixed Issues: + +* [#5431](https://github.com/ckeditor/ckeditor4/issues/5431): Fixed: No notification is shown when pasting or dropping unsupported image types into the editor. + +## CKEditor 4.20.2 + +Fixed Issues: + +* [#439](https://github.com/ckeditor/ckeditor4/issues/439): Fixed: Incorrect Tab and Shift+Tab navigation for radio buttons inside the dialog. +* [#4829](https://github.com/ckeditor/ckeditor4/issues/4829): Fixed: Undo reversed entire table content instead of a single cell. Thanks to that fix, multiple changes in a table can be undone one by one. +* [#5396](https://github.com/ckeditor/ckeditor4/issues/5396): Fixed: Event listeners for `popstate` and `hashchange` events on the `window`, added by the [Maximize](https://ckeditor.com/cke4/addon/maximize) plugin, were not removed when destroying the editor instance. +* [#5414](https://github.com/ckeditor/ckeditor4/issues/5414): Fixed: File and image uploaders based on the [Upload Widget plugin](https://ckeditor.com/cke4/addon/uploadwidget) and [Easy Image plugin ](https://ckeditor.com/cke4/addon/easyimage) didn't fire the [`change` event](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#event-change) upon finishing upload, resulting in passing incorrect data in form controls for integration frameworks, like [Reactive forms in Angular](https://angular.io/guide/reactive-forms). +* [#698](https://github.com/ckeditor/ckeditor4/issues/698): Fixed: An error was thrown after applying formatting to the widget with inline editable and switching to the source mode. Thanks to [Glen](https://github.com/glen-84)! + +API changes: + +* [#3540](https://github.com/ckeditor/ckeditor4/issues/3540): The [startup data](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_plugins_widget.html) passed to the widget's command is now used to also populate the widget's template. +* [#5352](https://github.com/ckeditor/ckeditor4/issues/5352): Added the [`colorButton_contentsCss`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-colorButton_contentsCss) configuration option allowing to add custom CSS to the [Color Button](https://ckeditor.com/cke4/addon/colorbutton) menu content. Thanks to [mihilion](https://github.com/mihilion)! + +## CKEditor 4.20.1 + +Fixed Issues: + +* [#5333](https://github.com/ckeditor/ckeditor4/issues/5333): Fixed: The original name of the uploaded image is not preserved by the [Upload Image](https://ckeditor.com/cke4/addon/uploadimage) plugin if the [Clipboard](https://ckeditor.com/cke4/addon/clipboard) plugin has enabled image handling. +* [#2881](https://github.com/ckeditor/ckeditor4/issues/2881): Fixed: Changing table headers from "Both" to "First column" in the [Table](https://ckeditor.com/cke4/addon/table) dialog does not change the first column cell correctly. +* [#2996](https://github.com/ckeditor/ckeditor4/issues/2996): Fixed: Table header "scope" attribute is incorrect for the "Headers: both" option in the [Table](https://ckeditor.com/cke4/addon/table) dialog. +* [#4802](https://github.com/ckeditor/ckeditor4/issues/4802): Fixed: [Tableselection](https://ckeditor.com/cke4/addon/tableselection) caret moves to the previous cell after tabbing into the next cell and then removing its content. +* [#5365](https://github.com/ckeditor/ckeditor4/issues/5365): Fixed: The value of the [`config.baseFloatZIndex`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-baseFloatZIndex) config variable is incorrectly applied to parent dialog when the child dialog is closed resulting in the dialog overlay covering up the dialog. Thanks to [JenoDK](https://github.com/JenoDK)! +* [#5305](https://github.com/ckeditor/ckeditor4/issues/5305): Fixed: Anchor name can invalidly include spaces. + +## CKEditor 4.20 + +New Features: + +* [#5084](https://github.com/ckeditor/ckeditor4/issues/5084): Added the [`config.tabletools_scopedHeaders`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-tabletools_scopedHeaders) configuration option controlling the behaviour of table headers with and without the `[scope]` attribute. +* [#5219](https://github.com/ckeditor/ckeditor4/issues/5219): Added the [`config.image2_defaultLockRatio`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-image2_defaultLockRatio) configuration option allowing to set the default value of the "Lock ratio" option in the [Enhanced Image](https://ckeditor.com/cke4/addon/image2) dialog. +* [#2008](https://github.com/ckeditor/ckeditor-dev/pull/2008): Extended the [Mentions](https://ckeditor.com/cke4/addon/mentions) and [Emoji](https://ckeditor.com/cke4/addon/emoji) plugins with a feature option that adds a space after an accepted autocompletion match. See: + * [`configDefinition.followingSpace`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_plugins_mentions_configDefinition.html#property-followingSpace) option for the mentions plugin, and + * [`config.emoji_followingSpace`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-emoji_followingSpace) option for the emoji plugin. +* [#5215](https://github.com/ckeditor/ckeditor4/issues/5215): Added the [`config.coreStyles_toggleSubSup`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-coreStyles_toggleSubSup) configuration option which disallows setting the subscript and superscript on the same element simultaneously using UI buttons. This option is turned off by default. + +Fixed Issues: + +* [#4889](https://github.com/ckeditor/ckeditor4/issues/4889): Fixed: Incorrect position of the [Table Resize](https://ckeditor.com/cke4/addon/tableresize) cursor after scrolling the editor horizontally. +* [#5319](https://github.com/ckeditor/ckeditor4/issues/5319): Fixed: [Autolink](https://ckeditor.com/cke4/addon/autolink) [`config.autolink_urlRegex`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-autolink_urlRegex) option produced invalid links when configured directly using the editor instance config. Thanks to [Aigars Zeiza](https://github.com/Zuzon)! +* [#4941](https://github.com/ckeditor/ckeditor4/issues/4941): Fixed: Some entities got wrongly encoded when using [`entities_processNumerical = true`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-entities_processNumerical) configuration option. +* [#4931](https://github.com/ckeditor/ckeditor4/issues/4931): Fixed: Selecting the whole editor content when there is only a list with an empty element at the end inside and deleting it did not delete all list items. + + +API changes: + +* [#5122](https://github.com/ckeditor/ckeditor4/issues/5122): Added the ability to provide a list of buttons as an array to the [`config.removeButtons`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-removeButtons) config variable. +* [#2008](https://github.com/ckeditor/ckeditor-dev/pull/2008): Added [Autocomplete](https://ckeditor.com/cke4/addon/autocomplete) [`followingSpace`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_plugins_autocomplete_configDefinition.html#property-followingSpace) option that finishes an accepted match with a space. + +## CKEditor 4.19.1 + +Fixed Issues: + +* [#5125](https://github.com/ckeditor/ckeditor4/issues/5125): Fixed: Deleting a widget with disabled [autoParagraph](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-autoParagraph) by the keyboard `backspace` key removes the editor editable area and crashes the editor. +* [#5135](https://github.com/ckeditor/ckeditor4/issues/5135): Fixed: The [`checkbox.setValue`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_ui_dialog_checkbox.html#method-setValue) and [`radio.setValue`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_ui_dialog_radio.html#method-setValue) methods are not chainable as stated in the documentation. Thanks to [Jordan Bradford](https://github.com/LordPachelbel)! +* [#5085](https://github.com/ckeditor/ckeditor4/issues/5085): Fixed: The [Language](https://ckeditor.com/cke4/addon/language) plugin removes the element marking the text in foreign language if said element does not have an information about the text direction. +* [#4284](https://github.com/ckeditor/ckeditor4/issues/4284): Fixed: [Tableselection](https://ckeditor.com/cke4/addon/tableselection) Merging cells with a rowspan throws an unexpected error and does not create an undo step. +* [#5184](https://github.com/ckeditor/ckeditor4/issues/5184): Fixed: The [Editor Placeholder](https://ckeditor.com/cke4/addon/wysiwygarea) plugin degrades typing performance. +* [#5158](https://github.com/ckeditor/ckeditor4/issues/5158): Fixed: [`CKEDITOR.tools#convertToPx()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools.html#method-convertToPx) gives invalid results if the helper calculator element was deleted from the DOM. +* [#5234](https://github.com/ckeditor/ckeditor4/issues/5234): Fixed: [Easy Image](https://ckeditor.com/cke4/addon/easyimage) doesn't allow to upload images files using toolbar button. +* [#438](https://github.com/ckeditor/ckeditor4/issues/438): Fixed: It is impossible to navigate to the [elementspath](https://ckeditor.com/cke4/addon/elementspath) from the [toolbar](https://ckeditor.com/cke4/addon/toolbar) by keyboard and vice versa. +* [#4449](https://github.com/ckeditor/ckeditor4/issues/4449): Fixed: [`dialog.validate#functions`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dialog_validate.html#method-functions) incorrectly composes functions that return an optional error message, like e.g. [`dialog.validate.number`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dialog_validate.html#method-number) due to unnecessary return type coercion. +* [#4473](https://github.com/ckeditor/ckeditor4/issues/4473): Fixed: The [dialog.validate](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dialog_validate.html) method does not accept parameter value. The issue originated in [dialog.validate.functions](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dialog_validate.html#method-functions) method that did not properly propagate parameter value to validator. Affected validators: + * [`functions`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dialog_validate.html#method-functions) + * [`equals`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dialog_validate.html#method-equals) + * [`notEqual`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dialog_validate.html#method-notEqual) + * [`cssLength`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dialog_validate.html#method-cssLength) + * [`htmlLength`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dialog_validate.html#method-htmlLength) + * [`inlineStyle`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dialog_validate.html#method-inlineStyle) +* [#5147](https://github.com/ckeditor/ckeditor4/issues/5147): Fixed: The [Accessibility Help](https://ckeditor.com/cke4/addon/a11yhelp) dialog does not contain info about focus being moved back to the editing area upon leaving dialogs. +* [#5144](https://github.com/ckeditor/ckeditor4/issues/5144): Fixed: [Menu buttons](https://ckeditor.com/cke4/addon/menubutton) and [panel buttons](https://ckeditor.com/cke4/addon/panelbutton) incorrectly indicate the open status of their associated pop-up menus in the browser's accessibility tree. +* [#5022](https://github.com/ckeditor/ckeditor4/issues/5022): Fixed: [Find and Replace](https://ckeditor.com/cke4/addon/find) does not respond to the `Enter` key. + +API changes: + +* [#5184](https://github.com/ckeditor/ckeditor4/issues/5184): Added the [`config.editorplaceholder_delay`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-editorplaceholder_delay) configuration option allowing to delay placeholder before it is toggled when changing editor content. +* [#5184](https://github.com/ckeditor/ckeditor4/issues/5184): Added the [`CKEDITOR.tools#debounce()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools.html#method-debounce) function allowing to postpone a passed function execution until the given milliseconds have elapsed since the last time it was invoked. + +## CKEditor 4.19.0 + +New features: + +* [#2444](https://github.com/ckeditor/ckeditor4/issues/2444): Togglable toolbar buttons are now exposed as toggle buttons in the browser's accessibility tree. +* [#4641](https://github.com/ckeditor/ckeditor4/issues/4641): Added an option allowing to cancel the [Delayed Editor Creation](https://ckeditor.com/docs/ckeditor4/latest/features/delayed_creation.html) feature as a function handle for editor creators ([`CKEDITOR.replace`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR.html#method-replace), [`CKEDITOR.inline`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR.html#method-inline), [`CKEDITOR.appendTo`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR.html#method-appendTo)). +* [#4986](https://github.com/ckeditor/ckeditor4/issues/4986): Added [`config.shiftLineBreaks`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-shiftLineBreaks) allowing to preserve inline elements formatting when the `shift`+`enter` keystroke is used. +* [#2445](https://github.com/ckeditor/ckeditor4/issues/2445): Added [`config.applicationTitle`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-applicationTitle) configuration option allowing to customize or disable the editor's application region label. This option, combined with [`config.title`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-title), gives much better control over the editor's labels read by screen readers. + +Fixed Issues: + +* [#4543](https://github.com/ckeditor/ckeditor4/issues/4543): Fixed: Toolbar buttons toggle state is not correctly announced by screen readers lacking the information whether the feature is on or off. +* [#4052](https://github.com/ckeditor/ckeditor4/issues/4052): Fixed: Editor labels are read incorrectly by screen readers due to invalid editor control type for the [Iframe Editing Area](https://ckeditor.com/cke4/addon/wysiwygarea) editors. +* [#1904](https://github.com/ckeditor/ckeditor4/issues/1904): Fixed: Screen readers are not announcing the read-only editor state. +* [#4904](https://github.com/ckeditor/ckeditor4/issues/4904): Fixed: Table cell selection and navigation with the `tab` key behavior is inconsistent after adding a new row. +* [#3394](https://github.com/ckeditor/ckeditor4/issues/3394): Fixed: [Enhanced image](https://ckeditor.com/cke4/addon/image2) plugin dialog is not supporting URL with query string parameters. Thanks to [Simon Urli](https://github.com/surli)! +* [#5049](https://github.com/ckeditor/ckeditor4/issues/5049): Fixed: The editor fails in strict mode due to not following the `use strict` directives in a core editor module. +* [#5095](https://github.com/ckeditor/ckeditor4/issues/5095): Fixed: The [clipboard](https://ckeditor.com/cke4/addon/clipboard) plugin shows notification about unsupported file format when the file type is different than `jpg`, `gif`, `png`, not respecting [supported types](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_fileTools_uploadWidgetDefinition.html#property-supportedTypes) by the [Upload Widget](https://ckeditor.com/cke4/addon/uploadwidget) plugin. +* [#4855](https://github.com/ckeditor/ckeditor4/issues/4855): [iOS] Fixed: Focusing toolbar buttons with an enabled VoiceOver screen reader moves the browser focus into an editable area and interrupts button functionality. + +API changes: + +* [#4641](https://github.com/ckeditor/ckeditor4/issues/4641): The [`CKEDITOR.replace`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR.html#method-replace), [`CKEDITOR.inline`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR.html#method-inline), [`CKEDITOR.appendTo`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR.html#method-appendTo) functions are now returning a handle function allowing to cancel the [Delayed Editor Creation](https://ckeditor.com/docs/ckeditor4/latest/features/delayed_creation.html) feature. +* [#5095](https://github.com/ckeditor/ckeditor4/issues/5095): Added the [CKEDITOR.plugins.clipboard.addFileMatcher](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_plugins_clipboard.html#method-addFileMatcher) function allowing to define file formats supported by the [clipboard](https://ckeditor.com/cke4/addon/clipboard) plugin. Trying to paste unsupported files will result in a notification that a file cannot be dropped or pasted into the editor. +* [#2445](https://github.com/ckeditor/ckeditor4/issues/2445): Added [`config.applicationTitle`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-applicationTitle) alongside [`CKEDITOR.editor#applicationTitle`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#property-applicationTitle) to allow customizing editor's application region label. ## CKEditor 4.18.0 diff --git a/htdocs/includes/ckeditor/ckeditor/LICENSE.md b/htdocs/includes/ckeditor/ckeditor/LICENSE.md index 4056b1f214e..54616f01086 100644 --- a/htdocs/includes/ckeditor/ckeditor/LICENSE.md +++ b/htdocs/includes/ckeditor/ckeditor/LICENSE.md @@ -1,8 +1,16 @@ -Software License Agreement -========================== +Software License Agreement for CKEditor 4 LTS (4.23.0 and above) +================================================================ -CKEditor - The text editor for Internet - https://ckeditor.com/ -Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved. +CKEditor - The text editor for Internet - https://ckeditor.com/
    +Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. + +CKEditor 4 LTS ("Long Term Support") is available under exclusive terms of the [Extended Support Model](https://ckeditor.com/ckeditor-4-support/). [Contact us](https://ckeditor.com/contact/) to obtain a commercial license. + +Software License Agreement for CKEditor 4.22.* and below +======================================================== + +CKEditor - The text editor for Internet - https://ckeditor.com/
    +Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. Licensed under the terms of any of the following licenses at your choice: @@ -37,7 +45,7 @@ done by developers outside of CKSource with their express permission. The following libraries are included in CKEditor under the MIT license (see Appendix D): -* CKSource Samples Framework (included in the samples) - Copyright (c) 2014-2022, CKSource Holding sp. z o.o. +* CKSource Samples Framework (included in the samples) - Copyright (c) 2014-2023, CKSource Holding sp. z o.o. * PicoModal (included in `samples/js/sf.js`) - Copyright (c) 2012 James Frasca. * CodeMirror (included in the samples) - Copyright (C) 2014 by Marijn Haverbeke and others. * ES6Promise - Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors. diff --git a/htdocs/includes/ckeditor/ckeditor/README.md b/htdocs/includes/ckeditor/ckeditor/README.md index 25a1e604b62..79828f34f31 100644 --- a/htdocs/includes/ckeditor/ckeditor/README.md +++ b/htdocs/includes/ckeditor/ckeditor/README.md @@ -1,8 +1,8 @@ CKEditor 4 ========== -Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved. -https://ckeditor.com - See LICENSE.md for license information. +Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. +https://ckeditor.com - See https://ckeditor.com/legal/ckeditor-oss-license for license information. CKEditor 4 is a text editor to be used inside web pages. It's not a replacement for desktop text editors like Word or OpenOffice, but a component to be used as diff --git a/htdocs/includes/ckeditor/ckeditor/build-config.js b/htdocs/includes/ckeditor/ckeditor/build-config.js index 2053f41ac96..f38a7581efd 100644 --- a/htdocs/includes/ckeditor/ckeditor/build-config.js +++ b/htdocs/includes/ckeditor/ckeditor/build-config.js @@ -1,5 +1,5 @@ /** - * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved. + * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license/ */ @@ -13,10 +13,10 @@ * (1) https://ckeditor.com/cke4/builder * Visit online builder to build CKEditor from scratch. * - * (2) https://ckeditor.com/cke4/builder/6490967e78ab135a44d8c0998d90e841 + * (2) https://ckeditor.com/cke4/builder/8b396e2e83e08da2ad0c51afee1a2118 * Visit online builder to build CKEditor, starting with the same setup as before. * - * (3) https://ckeditor.com/cke4/builder/download/6490967e78ab135a44d8c0998d90e841 + * (3) https://ckeditor.com/cke4/builder/download/8b396e2e83e08da2ad0c51afee1a2118 * Straight download link to the latest version of CKEditor (Optimized) with the same setup as before. * * NOTE: @@ -107,6 +107,7 @@ var CKBUILDER_CONFIG = { 'showborders' : 1, 'smiley' : 1, 'sourcearea' : 1, + 'sourcedialog' : 1, 'specialchar' : 1, 'stylescombo' : 1, 'tab' : 1, diff --git a/htdocs/includes/ckeditor/ckeditor/ckeditor.js b/htdocs/includes/ckeditor/ckeditor/ckeditor.js index 5edc17d91a8..0e787fb4848 100644 --- a/htdocs/includes/ckeditor/ckeditor/ckeditor.js +++ b/htdocs/includes/ckeditor/ckeditor/ckeditor.js @@ -1,15 +1,15 @@ /* -Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved. +Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license/ */ -(function(){if(window.CKEDITOR&&window.CKEDITOR.dom)return;window.CKEDITOR||(window.CKEDITOR=function(){var a=/(^|.*[\\\/])ckeditor\.js(?:\?.*|;.*)?$/i,d={timestamp:"M2G9",version:"4.18.0",revision:"5fe059002f3",rnd:Math.floor(900*Math.random())+100,_:{pending:[],basePathSrcPattern:a},status:"unloaded",basePath:function(){var b=window.CKEDITOR_BASEPATH||"";if(!b)for(var c=document.getElementsByTagName("script"),d=0;dy.getListenerIndex(c)){y=y.listeners;k||(k=this);isNaN(l)&&(l=10);r.fn=c;r.priority=l;for(var z=y.length-1;0<=z;z--)if(y[z].priority<=l)return y.splice(z+1,0,r),{removeListener:g}; -y.unshift(r)}return{removeListener:g}},once:function(){var a=Array.prototype.slice.call(arguments),b=a[1];a[1]=function(a){a.removeListener();return b.apply(this,arguments)};return this.on.apply(this,a)},capture:function(){CKEDITOR.event.useCapture=1;var a=this.on.apply(this,arguments);CKEDITOR.event.useCapture=0;return a},fire:function(){var c=0,e=function(){c=1},d=0,h=function(){d=1};return function(l,r,g){var w=b(this)[l];l=c;var y=d;c=d=0;if(w){var z=w.listeners;if(z.length)for(var z=z.slice(0), -A,t=0;ty.getListenerIndex(c)){y=y.listeners;k||(k=this);isNaN(n)&&(n=10);l.fn=c;l.priority=n;for(var z=y.length-1;0<=z;z--)if(y[z].priority<=n)return y.splice(z+1,0,l),{removeListener:g}; +y.unshift(l)}return{removeListener:g}},once:function(){var a=Array.prototype.slice.call(arguments),b=a[1];a[1]=function(a){a.removeListener();return b.apply(this,arguments)};return this.on.apply(this,a)},capture:function(){CKEDITOR.event.useCapture=1;var a=this.on.apply(this,arguments);CKEDITOR.event.useCapture=0;return a},fire:function(){var c=0,e=function(){c=1},d=0,h=function(){d=1};return function(n,l,g){var x=b(this)[n];n=c;var y=d;c=d=0;if(x){var z=x.listeners;if(z.length)for(var z=z.slice(0), +G,v=0;vdocument.documentMode),mobile:-1c||b.quirks);b.gecko&&(d=a.match(/rv:([\d\.]+)/))&&(d=d[1].split("."),c=1E4*d[0]+100*(d[1]||0)+1*(d[2]||0));b.air&&(c=parseFloat(a.match(/ adobeair\/(\d+)/)[1])); @@ -19,46 +19,46 @@ b.iOS&&(b.cssClass+=" cke_browser_ios");b.hidpi&&(b.cssClass+=" cke_hidpi");retu CKEDITOR.loadFullCore,d=CKEDITOR.loadFullCoreTimeout;a&&(CKEDITOR.status="basic_ready",a&&a._load?a():d&&setTimeout(function(){CKEDITOR.loadFullCore&&CKEDITOR.loadFullCore()},1E3*d))})})();CKEDITOR.status="basic_loaded"}();"use strict";CKEDITOR.VERBOSITY_WARN=1;CKEDITOR.VERBOSITY_ERROR=2;CKEDITOR.verbosity=CKEDITOR.VERBOSITY_WARN|CKEDITOR.VERBOSITY_ERROR;CKEDITOR.warn=function(a,d){CKEDITOR.verbosity&CKEDITOR.VERBOSITY_WARN&&CKEDITOR.fire("log",{type:"warn",errorCode:a,additionalData:d})}; CKEDITOR.error=function(a,d){CKEDITOR.verbosity&CKEDITOR.VERBOSITY_ERROR&&CKEDITOR.fire("log",{type:"error",errorCode:a,additionalData:d})}; CKEDITOR.on("log",function(a){if(window.console&&window.console.log){var d=console[a.data.type]?a.data.type:"log",b=a.data.errorCode;if(a=a.data.additionalData)console[d]("[CKEDITOR] Error code: "+b+".",a);else console[d]("[CKEDITOR] Error code: "+b+".");console[d]("[CKEDITOR] For more information about this error go to https://ckeditor.com/docs/ckeditor4/latest/guide/dev_errors.html#"+b)}},null,null,999);CKEDITOR.dom={}; -(function(){function a(a,y,b){this._minInterval=a;this._context=b;this._lastOutput=this._scheduledTimer=0;this._output=CKEDITOR.tools.bind(y,b||{});var c=this;this.input=function(){function a(){c._lastOutput=(new Date).getTime();c._scheduledTimer=0;c._call()}if(!c._scheduledTimer||!1!==c._reschedule()){var w=(new Date).getTime()-c._lastOutput;w/g,k=//g,k=/|\s) /g,function(a,b){return b+"\x26nbsp;"}).replace(/ (?=<)/g,"\x26nbsp;")},getNextNumber:function(){var a=0;return function(){return++a}}(),getNextId:function(){return"cke_"+this.getNextNumber()},getUniqueId:function(){for(var a="e",b=0;8>b;b++)a+=Math.floor(65536*(1+Math.random())).toString(16).substring(1); -return a},override:function(a,b){var c=b(a);c.prototype=a.prototype;return c},setTimeout:function(a,b,c,g,h){h||(h=window);c||(c=h);return h.setTimeout(function(){g?a.apply(c,[].concat(g)):a.apply(c)},b||0)},throttle:function(a,b,c){return new this.buffers.throttle(a,b,c)},trim:function(){var a=/(?:^[ \t\n\r]+)|(?:[ \t\n\r]+$)/g;return function(b){return b.replace(a,"")}}(),ltrim:function(){var a=/^[ \t\n\r]+/g;return function(b){return b.replace(a,"")}}(),rtrim:function(){var a=/[ \t\n\r]+$/g;return function(b){return b.replace(a, -"")}}(),indexOf:function(a,b){if("function"==typeof b)for(var c=0,g=a.length;cparseFloat(c);g&&(c=c.replace("-",""));a.setStyle("width",c);b=a.getClientRect();c=Math.round(b.width);return g?-c:c}return c}}(),repeat:function(a,b){return Array(b+1).join(a)},tryThese:function(){for(var a,b=0,c=arguments.length;bb;b++)a[b]=("0"+parseInt(a[b],10).toString(16)).slice(-2);return"#"+a.join("")})},normalizeHex:function(a){return a.replace(/#(([0-9a-f]{3}){1,2})($|;|\s+)/gi, -function(a,b,c,g){a=b.toLowerCase();3==a.length&&(a=a.split(""),a=[a[0],a[0],a[1],a[1],a[2],a[2]].join(""));return"#"+a+g})},_isValidColorFormat:function(a){if(!a)return!1;a=a.replace(/\s+/g,"");return/^[a-z0-9()#%,./]+$/i.test(a)},parseCssText:function(a,b,c){var g={};c&&(a=(new CKEDITOR.dom.element("span")).setAttribute("style",a).getAttribute("style")||"");a&&(a=CKEDITOR.tools.normalizeHex(CKEDITOR.tools.convertRgbToHex(a)));if(!a||";"==a)return g;a.replace(/"/g,'"').replace(/\s*([^:;\s]+)\s*:\s*([^;]+)\s*(?=;|$)/g, -function(a,c,w){b&&(c=c.toLowerCase(),"font-family"==c&&(w=w.replace(/\s*,\s*/g,",")),w=CKEDITOR.tools.trim(w));g[c]=w});return g},writeCssText:function(a,b){var c,g=[];for(c in a)g.push(c+":"+a[c]);b&&g.sort();return g.join("; ")},objectCompare:function(a,b,c){var g;if(!a&&!b)return!0;if(!a||!b)return!1;for(g in a)if(a[g]!=b[g])return!1;if(!c)for(g in b)if(a[g]!=b[g])return!1;return!0},objectKeys:function(a){return CKEDITOR.tools.object.keys(a)},convertArrayToObject:function(a,b){var c={};1==arguments.length&& -(b=!0);for(var g=0,h=a.length;gc;c++)a.push(Math.floor(256*Math.random()));for(c=0;c=g||0==c&&48<= -g&&57>=g||1==c&&48<=g&&57>=g&&45==m?h+("\\"+g.toString(16)+" "):0==c&&1==b&&45==g?h+("\\"+a.charAt(c)):128<=g||45==g||95==g||48<=g&&57>=g||65<=g&&90>=g||97<=g&&122>=g?h+a.charAt(c):h+("\\"+a.charAt(c));a=h}else a="";return a},getMouseButton:function(a){return(a=a&&a.data?a.data.$:a)?CKEDITOR.tools.normalizeMouseButton(a.button):!1},normalizeMouseButton:function(a,b){if(!CKEDITOR.env.ie||9<=CKEDITOR.env.version&&!CKEDITOR.env.ie6Compat)return a;for(var c=[[CKEDITOR.MOUSE_BUTTON_LEFT,1],[CKEDITOR.MOUSE_BUTTON_MIDDLE, -4],[CKEDITOR.MOUSE_BUTTON_RIGHT,2]],g=0;gm)for(d=m;3>d;d++)h[d]=0;e[0]=(h[0]&252)>>2;e[1]=(h[0]&3)<<4|h[1]>>4;e[2]=(h[1]&15)<<2|(h[2]&192)>>6;e[3]=h[2]&63;for(d=0;4>d;d++)b=d<=m? -b+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e[d]):b+"\x3d"}return b},style:{parse:{_borderStyle:"none hidden dotted dashed solid double groove ridge inset outset".split(" "),_widthRegExp:/^(thin|medium|thick|[\+-]?\d+(\.\d+)?[a-z%]+|[\+-]?0+(\.0+)?|\.\d+[a-z%]+)$/,_rgbaRegExp:/rgba?\(\s*\d+%?\s*,\s*\d+%?\s*,\s*\d+%?\s*(?:,\s*[0-9.]+\s*)?\)/gi,_hslaRegExp:/hsla?\(\s*[0-9.]+\s*,\s*\d+%\s*,\s*\d+%\s*(?:,\s*[0-9.]+\s*)?\)/gi,background:function(a){var b={},c=this._findColor(a); -c.length&&(b.color=c[0],CKEDITOR.tools.array.forEach(c,function(b){a=a.replace(b,"")}));if(a=CKEDITOR.tools.trim(a))b.unprocessed=a;return b},margin:function(a){return CKEDITOR.tools.style.parse.sideShorthand(a,function(a){return a.match(/(?:\-?[\.\d]+(?:%|\w*)|auto|inherit|initial|unset|revert)/g)||["0px"]})},sideShorthand:function(a,b){function c(a){g.top=h[a[0]];g.right=h[a[1]];g.bottom=h[a[2]];g.left=h[a[3]]}var g={},h=b?b(a):a.split(/\s+/);switch(h.length){case 1:c([0,0,0,0]);break;case 2:c([0, -1,0,1]);break;case 3:c([0,1,2,1]);break;case 4:c([0,1,2,3])}return g},border:function(a){return CKEDITOR.tools.style.border.fromCssRule(a)},_findColor:function(a){var b=[],c=CKEDITOR.tools.array,b=b.concat(a.match(this._rgbaRegExp)||[]),b=b.concat(a.match(this._hslaRegExp)||[]);return b=b.concat(c.filter(a.split(/\s+/),function(a){return a.match(/^\#[a-f0-9]{3}(?:[a-f0-9]{3})?$/gi)?!0:a.toLowerCase()in CKEDITOR.tools.style.parse._colors}))}}},array:{filter:function(a,b,c){var g=[];this.forEach(a, -function(h,m){b.call(c,h,m,a)&&g.push(h)});return g},find:function(a,b,c){for(var g=a.length,h=0;hCKEDITOR.env.version&&(!a||"object"!==typeof a)){b=[];if("string"===typeof a)for(c=0;cCKEDITOR.env.version)for(h=0;hparseFloat(c);g&&(c=c.replace("-",""));a.setStyle("width",c);b=a.getClientRect();c=Math.round(b.width);return g?-c:c}return c}}(),repeat:function(a,b){return Array(b+1).join(a)},tryThese:function(){for(var a, +b=0,c=arguments.length;bb;b++)a[b]=("0"+parseInt(a[b],10).toString(16)).slice(-2);return"#"+a.join("")})},normalizeHex:function(a){return a.replace(/#(([0-9a-f]{3}){1,2})($|;|\s+)/gi,function(a,b,c,g){a=b.toLowerCase();3==a.length&&(a=a.split(""),a=[a[0],a[0],a[1],a[1],a[2],a[2]].join(""));return"#"+a+g})},_isValidColorFormat:function(a){if(!a)return!1;a=a.replace(/\s+/g,"");return/^[a-z0-9()#%,./]+$/i.test(a)},parseCssText:function(a,b,c){var g={};c&&(a=(new CKEDITOR.dom.element("span")).setAttribute("style", +a).getAttribute("style")||"");a&&(a=CKEDITOR.tools.normalizeHex(CKEDITOR.tools.convertRgbToHex(a)));if(!a||";"==a)return g;a.replace(/"/g,'"').replace(/\s*([^:;\s]+)\s*:\s*([^;]+)\s*(?=;|$)/g,function(a,c,x){b&&(c=c.toLowerCase(),"font-family"==c&&(x=x.replace(/\s*,\s*/g,",")),x=CKEDITOR.tools.trim(x));g[c]=x});return g},writeCssText:function(a,b){var c,g=[];for(c in a)g.push(c+":"+a[c]);b&&g.sort();return g.join("; ")},objectCompare:function(a,b,c){var g;if(!a&&!b)return!0;if(!a||!b)return!1; +for(g in a)if(a[g]!=b[g])return!1;if(!c)for(g in b)if(a[g]!=b[g])return!1;return!0},objectKeys:function(a){return CKEDITOR.tools.object.keys(a)},convertArrayToObject:function(a,b){var c={};1==arguments.length&&(b=!0);for(var g=0,h=a.length;gc;c++)a.push(Math.floor(256*Math.random()));for(c=0;c=g||0==c&&48<=g&&57>=g||1==c&&48<=g&&57>=g&&45==m?h+("\\"+g.toString(16)+" "):0==c&&1==b&&45==g?h+("\\"+a.charAt(c)):128<=g||45==g||95==g||48<=g&&57>=g||65<=g&&90>=g||97<=g&&122>=g?h+a.charAt(c):h+("\\"+a.charAt(c));a=h}else a="";return a}, +getMouseButton:function(a){return(a=a&&a.data?a.data.$:a)?CKEDITOR.tools.normalizeMouseButton(a.button):!1},normalizeMouseButton:function(a,b){if(!CKEDITOR.env.ie||9<=CKEDITOR.env.version&&!CKEDITOR.env.ie6Compat)return a;for(var c=[[CKEDITOR.MOUSE_BUTTON_LEFT,1],[CKEDITOR.MOUSE_BUTTON_MIDDLE,4],[CKEDITOR.MOUSE_BUTTON_RIGHT,2]],g=0;gm)for(d=m;3>d;d++)h[d]=0;e[0]=(h[0]&252)>>2;e[1]=(h[0]&3)<<4|h[1]>>4;e[2]=(h[1]&15)<<2|(h[2]&192)>>6;e[3]=h[2]&63;for(d=0;4>d;d++)b=d<=m?b+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e[d]):b+"\x3d"}return b},style:{parse:{_borderStyle:"none hidden dotted dashed solid double groove ridge inset outset".split(" "),_widthRegExp:/^(thin|medium|thick|[\+-]?\d+(\.\d+)?[a-z%]+|[\+-]?0+(\.0+)?|\.\d+[a-z%]+)$/, +_rgbaRegExp:/rgba?\(\s*\d+%?\s*,\s*\d+%?\s*,\s*\d+%?\s*(?:,\s*[0-9.]+\s*)?\)/gi,_hslaRegExp:/hsla?\(\s*[0-9.]+\s*,\s*\d+%\s*,\s*\d+%\s*(?:,\s*[0-9.]+\s*)?\)/gi,background:function(a){var b={},c=this._findColor(a);c.length&&(b.color=c[0],CKEDITOR.tools.array.forEach(c,function(b){a=a.replace(b,"")}));if(a=CKEDITOR.tools.trim(a))b.unprocessed=a;return b},margin:function(a){return CKEDITOR.tools.style.parse.sideShorthand(a,function(a){return a.match(/(?:\-?[\.\d]+(?:%|\w*)|auto|inherit|initial|unset|revert)/g)|| +["0px"]})},sideShorthand:function(a,b){function c(a){g.top=h[a[0]];g.right=h[a[1]];g.bottom=h[a[2]];g.left=h[a[3]]}var g={},h=b?b(a):a.split(/\s+/);switch(h.length){case 1:c([0,0,0,0]);break;case 2:c([0,1,0,1]);break;case 3:c([0,1,2,1]);break;case 4:c([0,1,2,3])}return g},border:function(a){return CKEDITOR.tools.style.border.fromCssRule(a)},_findColor:function(a){var b=[],c=CKEDITOR.tools.array,b=b.concat(a.match(this._rgbaRegExp)||[]),b=b.concat(a.match(this._hslaRegExp)||[]);return b=b.concat(c.filter(a.split(/\s+/), +function(a){return a.match(/^\#[a-f0-9]{3}(?:[a-f0-9]{3})?$/gi)?!0:a.toLowerCase()in CKEDITOR.tools.style.parse._colors}))}}},array:{filter:function(a,b,c){var g=[];this.forEach(a,function(h,e){b.call(c,h,e,a)&&g.push(h)});return g},find:function(a,b,c){for(var g=a.length,h=0;hCKEDITOR.env.version&&(!a||"object"!==typeof a)){b=[];if("string"===typeof a)for(c=0;cCKEDITOR.env.version)for(h=0;hCKEDITOR.env.version?this.$.text+=a:this.append(new CKEDITOR.dom.text(a))},appendBogus:function(a){if(a||CKEDITOR.env.needsBrFiller){for(a=this.getLast();a&&a.type==CKEDITOR.NODE_TEXT&&!CKEDITOR.tools.rtrim(a.getText());)a=a.getPrevious();a&&a.is&&a.is("br")||(a=this.getDocument().createElement("br"),CKEDITOR.env.gecko&&a.setAttribute("type","_moz"),this.append(a))}},breakParent:function(a,b){var c=new CKEDITOR.dom.range(this.getDocument());c.setStartAfter(this);c.setEndAfter(a); -var g=c.extractContents(!1,b||!1),d;c.insertNode(this.remove());if(CKEDITOR.env.ie&&!CKEDITOR.env.edge){for(c=new CKEDITOR.dom.element("div");d=g.getFirst();)d.$.style.backgroundColor&&(d.$.style.backgroundColor=d.$.style.backgroundColor),c.append(d);c.insertAfter(this);c.remove(!0)}else g.insertAfterNode(this)},contains:document.compareDocumentPosition?function(a){return!!(this.$.compareDocumentPosition(a.$)&16)}:function(a){var b=this.$;return a.type!=CKEDITOR.NODE_ELEMENT?b.contains(a.getParent().$): +var g=c.extractContents(!1,b||!1),e;c.insertNode(this.remove());if(CKEDITOR.env.ie&&!CKEDITOR.env.edge){for(c=new CKEDITOR.dom.element("div");e=g.getFirst();)e.$.style.backgroundColor&&(e.$.style.backgroundColor=e.$.style.backgroundColor),c.append(e);c.insertAfter(this);c.remove(!0)}else g.insertAfterNode(this)},contains:document.compareDocumentPosition?function(a){return!!(this.$.compareDocumentPosition(a.$)&16)}:function(a){var b=this.$;return a.type!=CKEDITOR.NODE_ELEMENT?b.contains(a.getParent().$): b!=a.$&&b.contains(a.$)},focus:function(){function a(){try{this.$.focus()}catch(b){}}return function(b){b?CKEDITOR.tools.setTimeout(a,100,this):a.call(this)}}(),getHtml:function(){var a=this.$.innerHTML;return CKEDITOR.env.ie?a.replace(/<\?[^>]*>/g,""):a},getOuterHtml:function(){if(this.$.outerHTML)return this.$.outerHTML.replace(/<\?[^>]*>/,"");var a=this.$.ownerDocument.createElement("div");a.appendChild(this.$.cloneNode(!0));return a.innerHTML},getClientRect:function(a){var b=CKEDITOR.tools.extend({}, this.$.getBoundingClientRect());!b.width&&(b.width=b.right-b.left);!b.height&&(b.height=b.bottom-b.top);return a?CKEDITOR.tools.getAbsoluteRectPosition(this.getWindow(),b):b},setHtml:CKEDITOR.env.ie&&9>CKEDITOR.env.version?function(a){try{var b=this.$;if(this.getParent())return b.innerHTML=a;var c=this.getDocument()._getHtml5ShivFrag();c.appendChild(b);b.innerHTML=a;c.removeChild(b);return a}catch(g){this.$.innerHTML="";b=new CKEDITOR.dom.element("body",this.getDocument());b.$.innerHTML=a;for(b=b.getChildren();b.count();)this.append(b.getItem(0)); return a}}:function(a){return this.$.innerHTML=a},setText:function(){var a=document.createElement("p");a.innerHTML="x";a=a.textContent;return function(b){this.$[a?"textContent":"innerText"]=b}}(),getAttribute:function(){var a=function(a){return this.$.getAttribute(a,2)};return CKEDITOR.env.ie&&(CKEDITOR.env.ie7Compat||CKEDITOR.env.quirks)?function(a){switch(a){case "class":a="className";break;case "http-equiv":a="httpEquiv";break;case "name":return this.$.name;case "tabindex":return a=this.$.getAttribute(a, @@ -113,144 +113,144 @@ CKEDITOR.dtd.span,!(!a||!a["#"])):!0},isIdentical:function(a){var b=this.clone(0 a.getOuterHtml();if(CKEDITOR.env.ie&&9>CKEDITOR.env.version&&this.is("a")){var c=this.getParent();c.type==CKEDITOR.NODE_ELEMENT&&(c=c.clone(),c.setHtml(b),b=c.getHtml(),c.setHtml(a),a=c.getHtml())}return b==a},isVisible:function(){var a=(this.$.offsetHeight||this.$.offsetWidth)&&"hidden"!=this.getComputedStyle("visibility"),b,c;a&&CKEDITOR.env.webkit&&(b=this.getWindow(),!b.equals(CKEDITOR.document.getWindow())&&(c=b.$.frameElement)&&(a=(new CKEDITOR.dom.element(c)).isVisible()));return!!a},isEmptyInlineRemoveable:function(){if(!CKEDITOR.dtd.$removeEmpty[this.getName()])return!1; for(var a=this.getChildren(),b=0,c=a.count();bCKEDITOR.env.version?function(b){return"name"==b?!!this.$.name:a.call(this,b)}:a:function(a){return!!this.$.attributes.getNamedItem(a)}}(),hide:function(){this.setStyle("display","none")},moveChildren:function(a,b){var c=this.$;a=a.$;if(c!=a){var g;if(b)for(;g=c.lastChild;)a.insertBefore(c.removeChild(g),a.firstChild);else for(;g=c.firstChild;)a.appendChild(c.removeChild(g))}},mergeSiblings:function(){function a(b,c,g){if(c&&c.type==CKEDITOR.NODE_ELEMENT){for(var d= -[];c.data("cke-bookmark")||c.isEmptyInlineRemoveable();)if(d.push(c),c=g?c.getNext():c.getPrevious(),!c||c.type!=CKEDITOR.NODE_ELEMENT)return;if(b.isIdentical(c)){for(var e=g?b.getLast():b.getFirst();d.length;)d.shift().move(b,!g);c.moveChildren(b,!g);c.remove();e&&e.type==CKEDITOR.NODE_ELEMENT&&e.mergeSiblings()}}}return function(b){if(!1===b||CKEDITOR.dtd.$removeEmpty[this.getName()]||this.is("a"))a(this,this.getNext(),!0),a(this,this.getPrevious())}}(),show:function(){this.setStyles({display:"", +c.specified:!1}return CKEDITOR.env.ie?8>CKEDITOR.env.version?function(b){return"name"==b?!!this.$.name:a.call(this,b)}:a:function(a){return!!this.$.attributes.getNamedItem(a)}}(),hide:function(){this.setStyle("display","none")},moveChildren:function(a,b){var c=this.$;a=a.$;if(c!=a){var g;if(b)for(;g=c.lastChild;)a.insertBefore(c.removeChild(g),a.firstChild);else for(;g=c.firstChild;)a.appendChild(c.removeChild(g))}},mergeSiblings:function(){function a(b,c,g){if(c&&c.type==CKEDITOR.NODE_ELEMENT){for(var e= +[];c.data("cke-bookmark")||c.isEmptyInlineRemoveable();)if(e.push(c),c=g?c.getNext():c.getPrevious(),!c||c.type!=CKEDITOR.NODE_ELEMENT)return;if(b.isIdentical(c)){for(var h=g?b.getLast():b.getFirst();e.length;)e.shift().move(b,!g);c.moveChildren(b,!g);c.remove();h&&h.type==CKEDITOR.NODE_ELEMENT&&h.mergeSiblings()}}}return function(b){if(!1===b||CKEDITOR.dtd.$removeEmpty[this.getName()]||this.is("a"))a(this,this.getNext(),!0),a(this,this.getPrevious())}}(),show:function(){this.setStyles({display:"", visibility:""})},setAttribute:function(){var a=function(a,b){this.$.setAttribute(a,b);return this};return CKEDITOR.env.ie&&(CKEDITOR.env.ie7Compat||CKEDITOR.env.quirks)?function(b,c){"class"==b?this.$.className=c:"style"==b?this.$.style.cssText=c:"tabindex"==b?this.$.tabIndex=c:"checked"==b?this.$.checked=c:"contenteditable"==b?a.call(this,"contentEditable",c):a.apply(this,arguments);return this}:CKEDITOR.env.ie8Compat&&CKEDITOR.env.secure?function(b,c){if("src"==b&&c.match(/^http:\/\//))try{a.apply(this, arguments)}catch(g){}else a.apply(this,arguments);return this}:a}(),setAttributes:function(a){for(var b in a)this.setAttribute(b,a[b]);return this},setValue:function(a){this.$.value=a;return this},removeAttribute:function(){var a=function(a){this.$.removeAttribute(a)};return CKEDITOR.env.ie&&(CKEDITOR.env.ie7Compat||CKEDITOR.env.quirks)?function(a){"class"==a?a="className":"tabindex"==a?a="tabIndex":"contenteditable"==a&&(a="contentEditable");this.$.removeAttribute(a)}:a}(),removeAttributes:function(a){if(CKEDITOR.tools.isArray(a))for(var b= -0;bCKEDITOR.env.version?(a=Math.round(100*a),this.setStyle("filter",100<=a?"":"progid:DXImageTransform.Microsoft.Alpha(opacity\x3d"+a+")")):this.setStyle("opacity",a)},unselectable:function(){this.setStyles(CKEDITOR.tools.cssVendorPrefix("user-select", -"none"));if(CKEDITOR.env.ie){this.setAttribute("unselectable","on");for(var a,b=this.getElementsByTag("*"),c=0,g=b.count();cf||0f?f:d);c&&(0>e||0e?e:g,0)},setState:function(a,b,c){b=b||"cke";switch(a){case CKEDITOR.TRISTATE_ON:this.addClass(b+"_on");this.removeClass(b+ +0;bCKEDITOR.env.version?(a=Math.round(100*a),this.setStyle("filter",100<=a?"":"progid:DXImageTransform.Microsoft.Alpha(opacity\x3d"+a+")")):this.setStyle("opacity",a)},unselectable:function(){this.setStyles(CKEDITOR.tools.cssVendorPrefix("user-select", +"none"));if(CKEDITOR.env.ie){this.setAttribute("unselectable","on");for(var a,b=this.getElementsByTag("*"),c=0,g=b.count();cf||0f?f:e);c&&(0>d||0d?d:g,0)},setState:function(a,b,c){b=b||"cke";switch(a){case CKEDITOR.TRISTATE_ON:this.addClass(b+"_on");this.removeClass(b+ "_off");this.removeClass(b+"_disabled");c&&this.setAttribute("aria-pressed",!0);c&&this.removeAttribute("aria-disabled");break;case CKEDITOR.TRISTATE_DISABLED:this.addClass(b+"_disabled");this.removeClass(b+"_off");this.removeClass(b+"_on");c&&this.setAttribute("aria-disabled",!0);c&&this.removeAttribute("aria-pressed");break;default:this.addClass(b+"_off"),this.removeClass(b+"_on"),this.removeClass(b+"_disabled"),c&&this.removeAttribute("aria-pressed"),c&&this.removeAttribute("aria-disabled")}}, -getFrameDocument:function(){var a=this.$;try{a.contentWindow.document}catch(b){a.src=a.src}return a&&new CKEDITOR.dom.document(a.contentWindow.document)},copyAttributes:function(a,b){var c=this.$.attributes;b=b||{};for(var g=0;gCKEDITOR.env.version){var d=g.ownerDocument.createEventObject(),e;for(e in b)d[e]=b[e];g.fireEvent(c, -d)}else g[g[a]?a:c](b)},isDetached:function(){var a=this.getDocument(),b=a.getDocumentElement();return b.equals(this)||b.contains(this)?!CKEDITOR.env.ie||8CKEDITOR.env.version){var e=g.ownerDocument.createEventObject(),d;for(d in b)e[d]=b[d];g.fireEvent(c, +e)}else g[g[a]?a:c](b)},isDetached:function(){var a=this.getDocument(),b=a.getDocumentElement();return b.equals(this)||b.contains(this)?!CKEDITOR.env.ie||8=F.getChildCount()?(F=F.getChild(x-1),p=!0):F=F.getChild(x):B=p=!0;u.type==CKEDITOR.NODE_TEXT?l?G=!0:u.split(H):0ea)for(;X;)X=f(X,C,!0);C=L}l|| -h()}}function b(){var a=!1,b=CKEDITOR.dom.walker.whitespaces(),c=CKEDITOR.dom.walker.bookmark(!0),d=CKEDITOR.dom.walker.bogus();return function(f){return c(f)||b(f)?!0:d(f)&&!a?a=!0:f.type==CKEDITOR.NODE_TEXT&&(f.hasAscendant("pre")||CKEDITOR.tools.trim(f.getText()).length)||f.type==CKEDITOR.NODE_ELEMENT&&!f.is(e)?!1:!0}}function c(a){var b=CKEDITOR.dom.walker.whitespaces(),c=CKEDITOR.dom.walker.bookmark(1);return function(d){return c(d)||b(d)?!0:!a&&k(d)||d.type==CKEDITOR.NODE_ELEMENT&&d.is(CKEDITOR.dtd.$removeEmpty)}} -function f(a){return function(){var b;return this[a?"getPreviousNode":"getNextNode"](function(a){!b&&r(a)&&(b=a);return l(a)&&!(k(a)&&a.equals(b))})}}var e={abbr:1,acronym:1,b:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,q:1,samp:1,small:1,span:1,strike:1,strong:1,sub:1,sup:1,tt:1,u:1,"var":1},k=CKEDITOR.dom.walker.bogus(),h=/^[\t\r\n ]*(?: |\xa0)$/,l=CKEDITOR.dom.walker.editable(),r=CKEDITOR.dom.walker.ignored(!0);CKEDITOR.dom.range.prototype={clone:function(){var a= +(function(){function a(a){a.collapsed=a.startContainer&&a.endContainer&&a.startContainer.equals(a.endContainer)&&a.startOffset==a.endOffset}function d(a,b,c,e,d){function f(a,b,c,g){var Y=c?a.getPrevious():a.getNext();if(g&&k)return Y;n||g?b.append(a.clone(!0,d),c):(a.remove(),l&&b.append(a,c));return Y}function m(){var a,b,c,g=Math.min(L.length,r.length);for(a=0;a=u.getChildCount()?(u=u.getChild(D-1),t=!0):u=u.getChild(D):A=t=!0;q.type==CKEDITOR.NODE_TEXT?n?I=!0:q.split(K):0ea)for(;W;)W=f(W,C,!0);C=Y}n|| +h()}}function b(){var a=!1,b=CKEDITOR.dom.walker.whitespaces(),c=CKEDITOR.dom.walker.bookmark(!0),d=CKEDITOR.dom.walker.bogus();return function(f){return c(f)||b(f)?!0:d(f)&&!a?a=!0:f.type==CKEDITOR.NODE_TEXT&&(f.hasAscendant("pre")||CKEDITOR.tools.trim(f.getText()).length)||f.type==CKEDITOR.NODE_ELEMENT&&!f.is(e)?!1:!0}}function c(a){var b=CKEDITOR.dom.walker.whitespaces(),c=CKEDITOR.dom.walker.bookmark(1);return function(e){return c(e)||b(e)?!0:!a&&k(e)||e.type==CKEDITOR.NODE_ELEMENT&&e.is(CKEDITOR.dtd.$removeEmpty)}} +function f(a){return function(){var b;return this[a?"getPreviousNode":"getNextNode"](function(a){!b&&l(a)&&(b=a);return n(a)&&!(k(a)&&a.equals(b))})}}var e={abbr:1,acronym:1,b:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,q:1,samp:1,small:1,span:1,strike:1,strong:1,sub:1,sup:1,tt:1,u:1,"var":1},k=CKEDITOR.dom.walker.bogus(),h=/^[\t\r\n ]*(?: |\xa0)$/,n=CKEDITOR.dom.walker.editable(),l=CKEDITOR.dom.walker.ignored(!0);CKEDITOR.dom.range.prototype={clone:function(){var a= new CKEDITOR.dom.range(this.root);a._setStartContainer(this.startContainer);a.startOffset=this.startOffset;a._setEndContainer(this.endContainer);a.endOffset=this.endOffset;a.collapsed=this.collapsed;return a},collapse:function(a){a?(this._setEndContainer(this.startContainer),this.endOffset=this.startOffset):(this._setStartContainer(this.endContainer),this.startOffset=this.endOffset);this.collapsed=!0},cloneContents:function(a){var b=new CKEDITOR.dom.documentFragment(this.document);this.collapsed|| d(this,2,b,!1,"undefined"==typeof a?!0:a);return b},deleteContents:function(a){this.collapsed||d(this,0,null,a)},extractContents:function(a,b){var c=new CKEDITOR.dom.documentFragment(this.document);this.collapsed||d(this,1,c,a,"undefined"==typeof b?!0:b);return c},equals:function(a){return this.startOffset===a.startOffset&&this.endOffset===a.endOffset&&this.startContainer.equals(a.startContainer)&&this.endContainer.equals(a.endContainer)},createBookmark:function(a){function b(a){return a.getAscendant(function(a){var b; -if(b=a.data&&a.data("cke-temp"))b=-1===CKEDITOR.tools.array.indexOf(["cke_copybin","cke_pastebin"],a.getAttribute("id"));return b},!0)}var c=this.startContainer,d=this.endContainer,e=this.collapsed,f,m,h,k;f=this.document.createElement("span");f.data("cke-bookmark",1);f.setStyle("display","none");f.setHtml("\x26nbsp;");a&&(h="cke_bm_"+CKEDITOR.tools.getNextNumber(),f.setAttribute("id",h+(e?"C":"S")));e||(m=f.clone(),m.setHtml("\x26nbsp;"),a&&m.setAttribute("id",h+"E"),k=this.clone(),b(d)&&(d=b(d), -k.moveToPosition(d,CKEDITOR.POSITION_AFTER_END)),k.collapse(),k.insertNode(m));k=this.clone();b(c)&&(d=b(c),k.moveToPosition(d,CKEDITOR.POSITION_BEFORE_START));k.collapse(!0);k.insertNode(f);m?(this.setStartAfter(f),this.setEndBefore(m)):this.moveToPosition(f,CKEDITOR.POSITION_AFTER_END);return{startNode:a?h+(e?"C":"S"):f,endNode:a?h+"E":m,serializable:a,collapsed:e}},createBookmark2:function(){function a(b){var g=b.container,d=b.offset,e;e=g;var f=d;e=e.type!=CKEDITOR.NODE_ELEMENT||0===f||f==e.getChildCount()? -0:e.getChild(f-1).type==CKEDITOR.NODE_TEXT&&e.getChild(f).type==CKEDITOR.NODE_TEXT;e&&(g=g.getChild(d-1),d=g.getLength());if(g.type==CKEDITOR.NODE_ELEMENT&&0=a.offset&&(a.offset=d.getIndex(),a.container=d.getParent()))}}var c=CKEDITOR.dom.walker.nodeType(CKEDITOR.NODE_TEXT,!0);return function(c){var d=this.collapsed,e={container:this.startContainer,offset:this.startOffset},m={container:this.endContainer,offset:this.endOffset};c&&(a(e),b(e,this.root), -d||(a(m),b(m,this.root)));return{start:e.container.getAddress(c),end:d?null:m.container.getAddress(c),startOffset:e.offset,endOffset:m.offset,normalized:c,collapsed:d,is2:!0}}}(),moveToBookmark:function(a){if(a.is2){var b=this.document.getByAddress(a.start,a.normalized),c=a.startOffset,d=a.end&&this.document.getByAddress(a.end,a.normalized);a=a.endOffset;this.setStart(b,c);d?this.setEnd(d,a):this.collapse(!0)}else b=(c=a.serializable)?this.document.getById(a.startNode):a.startNode,a=c?this.document.getById(a.endNode): -a.endNode,this.setStartBefore(b),b.remove(),a?(this.setEndBefore(a),a.remove()):this.collapse(!0)},getBoundaryNodes:function(){var a=this.startContainer,b=this.endContainer,c=this.startOffset,d=this.endOffset,e;if(a.type==CKEDITOR.NODE_ELEMENT)if(e=a.getChildCount(),e>c)a=a.getChild(c);else if(1>e)a=a.getPreviousSourceNode();else{for(a=a.$;a.lastChild;)a=a.lastChild;a=new CKEDITOR.dom.node(a);a=a.getNextSourceNode()||a}if(b.type==CKEDITOR.NODE_ELEMENT)if(e=b.getChildCount(),e>d)b=b.getChild(d).getPreviousSourceNode(!0); -else if(1>e)b=b.getPreviousSourceNode();else{for(b=b.$;b.lastChild;)b=b.lastChild;b=new CKEDITOR.dom.node(b)}a.getPosition(b)&CKEDITOR.POSITION_FOLLOWING&&(a=b);return{startNode:a,endNode:b}},getCommonAncestor:function(a,b){var c=this.startContainer,d=this.endContainer,c=c.equals(d)?a&&c.type==CKEDITOR.NODE_ELEMENT&&this.startOffset==this.endOffset-1?c.getChild(this.startOffset):c:c.getCommonAncestor(d);return b&&!c.is?c.getParent():c},optimize:function(){var a=this.startContainer,b=this.startOffset; +if(b=a.data&&a.data("cke-temp"))b=-1===CKEDITOR.tools.array.indexOf(["cke_copybin","cke_pastebin"],a.getAttribute("id"));return b},!0)}var c=this.startContainer,e=this.endContainer,d=this.collapsed,f,m,h,k;f=this.document.createElement("span");f.data("cke-bookmark",1);f.setStyle("display","none");f.setHtml("\x26nbsp;");a&&(h="cke_bm_"+CKEDITOR.tools.getNextNumber(),f.setAttribute("id",h+(d?"C":"S")));d||(m=f.clone(),m.setHtml("\x26nbsp;"),a&&m.setAttribute("id",h+"E"),k=this.clone(),b(e)&&(e=b(e), +k.moveToPosition(e,CKEDITOR.POSITION_AFTER_END)),k.collapse(),k.insertNode(m));k=this.clone();b(c)&&(e=b(c),k.moveToPosition(e,CKEDITOR.POSITION_BEFORE_START));k.collapse(!0);k.insertNode(f);m?(this.setStartAfter(f),this.setEndBefore(m)):this.moveToPosition(f,CKEDITOR.POSITION_AFTER_END);return{startNode:a?h+(d?"C":"S"):f,endNode:a?h+"E":m,serializable:a,collapsed:d}},createBookmark2:function(){function a(b){var g=b.container,e=b.offset,d;d=g;var f=e;d=d.type!=CKEDITOR.NODE_ELEMENT||0===f||f==d.getChildCount()? +0:d.getChild(f-1).type==CKEDITOR.NODE_TEXT&&d.getChild(f).type==CKEDITOR.NODE_TEXT;d&&(g=g.getChild(e-1),e=g.getLength());if(g.type==CKEDITOR.NODE_ELEMENT&&0=a.offset&&(a.offset=e.getIndex(),a.container=e.getParent()))}}var c=CKEDITOR.dom.walker.nodeType(CKEDITOR.NODE_TEXT,!0);return function(c){var e=this.collapsed,d={container:this.startContainer,offset:this.startOffset},m={container:this.endContainer,offset:this.endOffset};c&&(a(d),b(d,this.root), +e||(a(m),b(m,this.root)));return{start:d.container.getAddress(c),end:e?null:m.container.getAddress(c),startOffset:d.offset,endOffset:m.offset,normalized:c,collapsed:e,is2:!0}}}(),moveToBookmark:function(a){if(a.is2){var b=this.document.getByAddress(a.start,a.normalized),c=a.startOffset,e=a.end&&this.document.getByAddress(a.end,a.normalized);a=a.endOffset;this.setStart(b,c);e?this.setEnd(e,a):this.collapse(!0)}else b=(c=a.serializable)?this.document.getById(a.startNode):a.startNode,a=c?this.document.getById(a.endNode): +a.endNode,this.setStartBefore(b),b.remove(),a?(this.setEndBefore(a),a.remove()):this.collapse(!0)},getBoundaryNodes:function(){var a=this.startContainer,b=this.endContainer,c=this.startOffset,e=this.endOffset,d;if(a.type==CKEDITOR.NODE_ELEMENT)if(d=a.getChildCount(),d>c)a=a.getChild(c);else if(1>d)a=a.getPreviousSourceNode();else{for(a=a.$;a.lastChild;)a=a.lastChild;a=new CKEDITOR.dom.node(a);a=a.getNextSourceNode()||a}if(b.type==CKEDITOR.NODE_ELEMENT)if(d=b.getChildCount(),d>e)b=b.getChild(e).getPreviousSourceNode(!0); +else if(1>d)b=b.getPreviousSourceNode();else{for(b=b.$;b.lastChild;)b=b.lastChild;b=new CKEDITOR.dom.node(b)}a.getPosition(b)&CKEDITOR.POSITION_FOLLOWING&&(a=b);return{startNode:a,endNode:b}},getCommonAncestor:function(a,b){var c=this.startContainer,e=this.endContainer,c=c.equals(e)?a&&c.type==CKEDITOR.NODE_ELEMENT&&this.startOffset==this.endOffset-1?c.getChild(this.startOffset):c:c.getCommonAncestor(e);return b&&!c.is?c.getParent():c},optimize:function(){var a=this.startContainer,b=this.startOffset; a.type!=CKEDITOR.NODE_ELEMENT&&(b?b>=a.getLength()&&this.setStartAfter(a):this.setStartBefore(a));a=this.endContainer;b=this.endOffset;a.type!=CKEDITOR.NODE_ELEMENT&&(b?b>=a.getLength()&&this.setEndAfter(a):this.setEndBefore(a))},optimizeBookmark:function(){var a=this.startContainer,b=this.endContainer;a.is&&a.is("span")&&a.data("cke-bookmark")&&this.setStartAt(a,CKEDITOR.POSITION_BEFORE_START);b&&b.is&&b.is("span")&&b.data("cke-bookmark")&&this.setEndAt(b,CKEDITOR.POSITION_AFTER_END)},trim:function(a, -b){var c=this.startContainer,d=this.startOffset,e=this.collapsed;if((!a||e)&&c&&c.type==CKEDITOR.NODE_TEXT){if(d)if(d>=c.getLength())d=c.getIndex()+1,c=c.getParent();else{var f=c.split(d),d=c.getIndex()+1,c=c.getParent();this.startContainer.equals(this.endContainer)?this.setEnd(f,this.endOffset-this.startOffset):c.equals(this.endContainer)&&(this.endOffset+=1)}else d=c.getIndex(),c=c.getParent();this.setStart(c,d);if(e){this.collapse(!0);return}}c=this.endContainer;d=this.endOffset;b||e||!c||c.type!= -CKEDITOR.NODE_TEXT||(d?(d>=c.getLength()||c.split(d),d=c.getIndex()+1):d=c.getIndex(),c=c.getParent(),this.setEnd(c,d))},enlarge:function(a,b){function c(a){return a&&a.type==CKEDITOR.NODE_ELEMENT&&a.hasAttribute("contenteditable")?null:a}var d=new RegExp(/[^\s\ufeff]/);switch(a){case CKEDITOR.ENLARGE_INLINE:var e=1;case CKEDITOR.ENLARGE_ELEMENT:var f=function(a,b){var c=new CKEDITOR.dom.range(h);c.setStart(a,b);c.setEndAt(h,CKEDITOR.POSITION_BEFORE_END);var c=new CKEDITOR.dom.walker(c),g;for(c.guard= -function(a){return!(a.type==CKEDITOR.NODE_ELEMENT&&a.isBlockBoundary())};g=c.next();){if(g.type!=CKEDITOR.NODE_TEXT)return!1;K=g!=a?g.getText():g.substring(b);if(d.test(K))return!1}return!0};if(this.collapsed)break;var m=this.getCommonAncestor(),h=this.root,k,r,l,u,F,H=!1,x,K;x=this.startContainer;var p=this.startOffset;x.type==CKEDITOR.NODE_TEXT?(p&&(x=!CKEDITOR.tools.trim(x.substring(0,p)).length&&x,H=!!x),x&&((u=x.getPrevious())||(l=x.getParent()))):(p&&(u=x.getChild(p-1)||x.getLast()),u||(l=x)); -for(l=c(l);l||u;){if(l&&!u){!F&&l.equals(m)&&(F=!0);if(e?l.isBlockBoundary():!h.contains(l))break;H&&"inline"==l.getComputedStyle("display")||(H=!1,F?k=l:this.setStartBefore(l));u=l.getPrevious()}for(;u;)if(x=!1,u.type==CKEDITOR.NODE_COMMENT)u=u.getPrevious();else{if(u.type==CKEDITOR.NODE_TEXT)K=u.getText(),d.test(K)&&(u=null),x=/[\s\ufeff]$/.test(K);else if((u.$.offsetWidth>(CKEDITOR.env.webkit?1:0)||b&&u.is("br"))&&!u.data("cke-bookmark"))if(H&&CKEDITOR.dtd.$removeEmpty[u.getName()]){K=u.getText(); -if(d.test(K))u=null;else for(var p=u.$.getElementsByTagName("*"),D=0,B;B=p[D++];)if(!CKEDITOR.dtd.$removeEmpty[B.nodeName.toLowerCase()]){u=null;break}u&&(x=!!K.length)}else u=null;x&&(H?F?k=l:l&&this.setStartBefore(l):H=!0);if(u){x=u.getPrevious();if(!l&&!x){l=u;u=null;break}u=x}else l=null}l&&(l=c(l.getParent()))}x=this.endContainer;p=this.endOffset;l=u=null;F=H=!1;x.type==CKEDITOR.NODE_TEXT?CKEDITOR.tools.trim(x.substring(p)).length?H=!0:(H=!x.getLength(),p==x.getLength()?(u=x.getNext())||(l=x.getParent()): -f(x,p)&&(l=x.getParent())):(u=x.getChild(p))||(l=x);for(;l||u;){if(l&&!u){!F&&l.equals(m)&&(F=!0);if(e?l.isBlockBoundary():!h.contains(l))break;H&&"inline"==l.getComputedStyle("display")||(H=!1,F?r=l:l&&this.setEndAfter(l));u=l.getNext()}for(;u;){x=!1;if(u.type==CKEDITOR.NODE_TEXT)K=u.getText(),f(u,0)||(u=null),x=/^[\s\ufeff]/.test(K);else if(u.type==CKEDITOR.NODE_ELEMENT){if((0=m.getLength()?f.setStartAfter(m):(f.setStartBefore(m),c=0):f.setStartBefore(m));h&&h.type==CKEDITOR.NODE_TEXT&&(l?l>=h.getLength()?f.setEndAfter(h):(f.setEndAfter(h),r=0):f.setEndBefore(h));var f=new CKEDITOR.dom.walker(f),u=CKEDITOR.dom.walker.bookmark(),F=CKEDITOR.dom.walker.bogus();f.evaluator=function(b){return b.type==(a==CKEDITOR.SHRINK_ELEMENT?CKEDITOR.NODE_ELEMENT:CKEDITOR.NODE_TEXT)};var H;f.guard=function(b,c){if(e&&F(b)||u(b))return!0;if(a==CKEDITOR.SHRINK_ELEMENT&& -b.type==CKEDITOR.NODE_TEXT||c&&b.equals(H)||!1===d&&b.type==CKEDITOR.NODE_ELEMENT&&b.isBlockBoundary()||b.type==CKEDITOR.NODE_ELEMENT&&b.hasAttribute("contenteditable"))return!1;c||b.type!=CKEDITOR.NODE_ELEMENT||(H=b);return!0};c&&(m=f[a==CKEDITOR.SHRINK_ELEMENT?"lastForward":"next"]())&&this.setStartAt(m,b?CKEDITOR.POSITION_AFTER_START:CKEDITOR.POSITION_BEFORE_START);r&&(f.reset(),(f=f[a==CKEDITOR.SHRINK_ELEMENT?"lastBackward":"previous"]())&&this.setEndAt(f,b?CKEDITOR.POSITION_BEFORE_END:CKEDITOR.POSITION_AFTER_END)); -return!(!c&&!r)}},insertNode:function(a){this.optimizeBookmark();this.trim(!1,!0);var b=this.startContainer,c=b.getChild(this.startOffset);c?a.insertBefore(c):b.append(a);a.getParent()&&a.getParent().equals(this.endContainer)&&this.endOffset++;this.setStartBefore(a)},moveToPosition:function(a,b){this.setStartAt(a,b);this.collapse(!0)},moveToRange:function(a){this.setStart(a.startContainer,a.startOffset);this.setEnd(a.endContainer,a.endOffset)},selectNodeContents:function(a){this.setStart(a,0);this.setEnd(a, +b){var c=this.startContainer,e=this.startOffset,d=this.collapsed;if((!a||d)&&c&&c.type==CKEDITOR.NODE_TEXT){if(e)if(e>=c.getLength())e=c.getIndex()+1,c=c.getParent();else{var f=c.split(e),e=c.getIndex()+1,c=c.getParent();this.startContainer.equals(this.endContainer)?this.setEnd(f,this.endOffset-this.startOffset):c.equals(this.endContainer)&&(this.endOffset+=1)}else e=c.getIndex(),c=c.getParent();this.setStart(c,e);if(d){this.collapse(!0);return}}c=this.endContainer;e=this.endOffset;b||d||!c||c.type!= +CKEDITOR.NODE_TEXT||(e?(e>=c.getLength()||c.split(e),e=c.getIndex()+1):e=c.getIndex(),c=c.getParent(),this.setEnd(c,e))},enlarge:function(a,b){function c(a){return a&&a.type==CKEDITOR.NODE_ELEMENT&&a.hasAttribute("contenteditable")?null:a}function e(a,b,c){var g=new CKEDITOR.dom.range(c);g.setStart(a,b);g.setEndAt(c,CKEDITOR.POSITION_BEFORE_END);c=new CKEDITOR.dom.walker(g);for(c.guard=function(a){return!(a.type==CKEDITOR.NODE_ELEMENT&&a.isBlockBoundary())};g=c.next();){if(g.type!=CKEDITOR.NODE_TEXT)return!1; +f=g!=a?g.getText():g.substring(b);if(d.test(f))return!1}return!0}var d=new RegExp(/[^\s\ufeff]/),f,m;switch(a){case CKEDITOR.ENLARGE_INLINE:var h=1;case CKEDITOR.ENLARGE_ELEMENT:if(this.collapsed)break;var k=this.getCommonAncestor();m=this.root;var l,n,q,u,K,D=!1,B;B=this.startContainer;var t=this.startOffset;B.type==CKEDITOR.NODE_TEXT?(t&&(B=!CKEDITOR.tools.trim(B.substring(0,t)).length&&B,D=!!B),B&&((u=B.getPrevious())||(q=B.getParent()))):(t&&(u=B.getChild(t-1)||B.getLast()),u||(q=B));for(q=c(q);q|| +u;){if(q&&!u){!K&&q.equals(k)&&(K=!0);if(h?q.isBlockBoundary():!m.contains(q))break;D&&"inline"==q.getComputedStyle("display")||(D=!1,K?l=q:this.setStartBefore(q));u=q.getPrevious()}for(;u;)if(B=!1,u.type==CKEDITOR.NODE_COMMENT)u=u.getPrevious();else{if(u.type==CKEDITOR.NODE_TEXT)f=u.getText(),d.test(f)&&(u=null),B=/[\s\ufeff]$/.test(f);else if((u.$.offsetWidth>(CKEDITOR.env.webkit?1:0)||b&&u.is("br"))&&!u.data("cke-bookmark"))if(D&&CKEDITOR.dtd.$removeEmpty[u.getName()]){f=u.getText();if(d.test(f))u= +null;else for(var t=u.$.getElementsByTagName("*"),H=0,A;A=t[H++];)if(!CKEDITOR.dtd.$removeEmpty[A.nodeName.toLowerCase()]){u=null;break}u&&(B=!!f.length)}else u=null;B&&(D?K?l=q:q&&this.setStartBefore(q):D=!0);if(u){B=u.getPrevious();if(!q&&!B){q=u;u=null;break}u=B}else q=null}q&&(q=c(q.getParent()))}B=this.endContainer;t=this.endOffset;q=u=null;K=D=!1;B.type==CKEDITOR.NODE_TEXT?CKEDITOR.tools.trim(B.substring(t)).length?D=!0:(D=!B.getLength(),t==B.getLength()?(u=B.getNext())||(q=B.getParent()):e(B, +t,m)&&(q=B.getParent())):(u=B.getChild(t))||(q=B);for(;q||u;){if(q&&!u){!K&&q.equals(k)&&(K=!0);if(h?q.isBlockBoundary():!m.contains(q))break;D&&"inline"==q.getComputedStyle("display")||(D=!1,K?n=q:q&&this.setEndAfter(q));u=q.getNext()}for(;u;){B=!1;if(u.type==CKEDITOR.NODE_TEXT)f=u.getText(),e(u,0,m)||(u=null),B=/^[\s\ufeff]/.test(f);else if(u.type==CKEDITOR.NODE_ELEMENT){if((0=m.getLength()?f.setStartAfter(m):(f.setStartBefore(m),c=0):f.setStartBefore(m));h&&h.type==CKEDITOR.NODE_TEXT&&(l?l>=h.getLength()?f.setEndAfter(h):(f.setEndAfter(h),n=0):f.setEndBefore(h));var f=new CKEDITOR.dom.walker(f),q=CKEDITOR.dom.walker.bookmark(),u=CKEDITOR.dom.walker.bogus();f.evaluator=function(b){return b.type==(a==CKEDITOR.SHRINK_ELEMENT?CKEDITOR.NODE_ELEMENT:CKEDITOR.NODE_TEXT)};var K;f.guard=function(b,c){if(d&&u(b)||q(b))return!0;if(a==CKEDITOR.SHRINK_ELEMENT&& +b.type==CKEDITOR.NODE_TEXT||c&&b.equals(K)||!1===e&&b.type==CKEDITOR.NODE_ELEMENT&&b.isBlockBoundary()||b.type==CKEDITOR.NODE_ELEMENT&&b.hasAttribute("contenteditable"))return!1;c||b.type!=CKEDITOR.NODE_ELEMENT||(K=b);return!0};c&&(m=f[a==CKEDITOR.SHRINK_ELEMENT?"lastForward":"next"]())&&this.setStartAt(m,b?CKEDITOR.POSITION_AFTER_START:CKEDITOR.POSITION_BEFORE_START);n&&(f.reset(),(f=f[a==CKEDITOR.SHRINK_ELEMENT?"lastBackward":"previous"]())&&this.setEndAt(f,b?CKEDITOR.POSITION_BEFORE_END:CKEDITOR.POSITION_AFTER_END)); +return!(!c&&!n)}},insertNode:function(a){this.optimizeBookmark();this.trim(!1,!0);var b=this.startContainer,c=b.getChild(this.startOffset);c?a.insertBefore(c):b.append(a);a.getParent()&&a.getParent().equals(this.endContainer)&&this.endOffset++;this.setStartBefore(a)},moveToPosition:function(a,b){this.setStartAt(a,b);this.collapse(!0)},moveToRange:function(a){this.setStart(a.startContainer,a.startOffset);this.setEnd(a.endContainer,a.endOffset)},selectNodeContents:function(a){this.setStart(a,0);this.setEnd(a, a.type==CKEDITOR.NODE_TEXT?a.getLength():a.getChildCount())},setStart:function(b,c){b.type==CKEDITOR.NODE_ELEMENT&&CKEDITOR.dtd.$empty[b.getName()]&&(c=b.getIndex(),b=b.getParent());this._setStartContainer(b);this.startOffset=c;this.endContainer||(this._setEndContainer(b),this.endOffset=c);a(this)},setEnd:function(b,c){b.type==CKEDITOR.NODE_ELEMENT&&CKEDITOR.dtd.$empty[b.getName()]&&(c=b.getIndex()+1,b=b.getParent());this._setEndContainer(b);this.endOffset=c;this.startContainer||(this._setStartContainer(b), this.startOffset=c);a(this)},setStartAfter:function(a){this.setStart(a.getParent(),a.getIndex()+1)},setStartBefore:function(a){this.setStart(a.getParent(),a.getIndex())},setEndAfter:function(a){this.setEnd(a.getParent(),a.getIndex()+1)},setEndBefore:function(a){this.setEnd(a.getParent(),a.getIndex())},setStartAt:function(b,c){switch(c){case CKEDITOR.POSITION_AFTER_START:this.setStart(b,0);break;case CKEDITOR.POSITION_BEFORE_END:b.type==CKEDITOR.NODE_TEXT?this.setStart(b,b.getLength()):this.setStart(b, b.getChildCount());break;case CKEDITOR.POSITION_BEFORE_START:this.setStartBefore(b);break;case CKEDITOR.POSITION_AFTER_END:this.setStartAfter(b)}a(this)},setEndAt:function(b,c){switch(c){case CKEDITOR.POSITION_AFTER_START:this.setEnd(b,0);break;case CKEDITOR.POSITION_BEFORE_END:b.type==CKEDITOR.NODE_TEXT?this.setEnd(b,b.getLength()):this.setEnd(b,b.getChildCount());break;case CKEDITOR.POSITION_BEFORE_START:this.setEndBefore(b);break;case CKEDITOR.POSITION_AFTER_END:this.setEndAfter(b)}a(this)},fixBlock:function(a, -b){var c=this.createBookmark(),d=this.document.createElement(b);this.collapse(a);this.enlarge(CKEDITOR.ENLARGE_BLOCK_CONTENTS);this.extractContents().appendTo(d);d.trim();this.insertNode(d);var e=d.getBogus();e&&e.remove();d.appendBogus();this.moveToBookmark(c);return d},splitBlock:function(a,b){var c=new CKEDITOR.dom.elementPath(this.startContainer,this.root),d=new CKEDITOR.dom.elementPath(this.endContainer,this.root),e=c.block,f=d.block,m=null;if(!c.blockLimit.equals(d.blockLimit))return null;"br"!= -a&&(e||(e=this.fixBlock(!0,a),f=(new CKEDITOR.dom.elementPath(this.endContainer,this.root)).block),f||(f=this.fixBlock(!1,a)));c=e&&this.checkStartOfBlock();d=f&&this.checkEndOfBlock();this.deleteContents();e&&e.equals(f)&&(d?(m=new CKEDITOR.dom.elementPath(this.startContainer,this.root),this.moveToPosition(f,CKEDITOR.POSITION_AFTER_END),f=null):c?(m=new CKEDITOR.dom.elementPath(this.startContainer,this.root),this.moveToPosition(e,CKEDITOR.POSITION_BEFORE_START),e=null):(f=this.splitElement(e,b|| -!1),e.is("ul","ol")||e.appendBogus()));return{previousBlock:e,nextBlock:f,wasStartOfBlock:c,wasEndOfBlock:d,elementPath:m}},splitElement:function(a,b){if(!this.collapsed)return null;this.setEndAt(a,CKEDITOR.POSITION_BEFORE_END);var c=this.extractContents(!1,b||!1),d=a.clone(!1,b||!1);c.appendTo(d);d.insertAfter(a);this.moveToPosition(a,CKEDITOR.POSITION_AFTER_END);return d},removeEmptyBlocksAtEnd:function(){function a(d){return function(a){return b(a)||c(a)||a.type==CKEDITOR.NODE_ELEMENT&&a.isEmptyInlineRemoveable()|| -d.is("table")&&a.is("caption")?!1:!0}}var b=CKEDITOR.dom.walker.whitespaces(),c=CKEDITOR.dom.walker.bookmark(!1);return function(b){for(var c=this.createBookmark(),d=this[b?"endPath":"startPath"](),e=d.block||d.blockLimit,f;e&&!e.equals(d.root)&&!e.getFirst(a(e));)f=e.getParent(),this[b?"setEndAt":"setStartAt"](e,CKEDITOR.POSITION_AFTER_END),e.remove(1),e=f;this.moveToBookmark(c)}}(),startPath:function(){return new CKEDITOR.dom.elementPath(this.startContainer,this.root)},endPath:function(){return new CKEDITOR.dom.elementPath(this.endContainer, -this.root)},checkBoundaryOfElement:function(a,b){var d=b==CKEDITOR.START,e=this.clone();e.collapse(d);e[d?"setStartAt":"setEndAt"](a,d?CKEDITOR.POSITION_AFTER_START:CKEDITOR.POSITION_BEFORE_END);e=new CKEDITOR.dom.walker(e);e.evaluator=c(d);return e[d?"checkBackward":"checkForward"]()},checkStartOfBlock:function(a){var c=this.startContainer,d=this.startOffset;CKEDITOR.env.ie&&d&&c.type==CKEDITOR.NODE_TEXT&&(c=CKEDITOR.tools.ltrim(c.substring(0,d)),h.test(c)&&this.trim(0,1));a||this.trim();a=new CKEDITOR.dom.elementPath(this.startContainer, -this.root);c=this.clone();c.collapse(!0);c.setStartAt(a.block||a.blockLimit,CKEDITOR.POSITION_AFTER_START);a=new CKEDITOR.dom.walker(c);a.evaluator=b();return a.checkBackward()},checkEndOfBlock:function(a){var c=this.endContainer,d=this.endOffset;CKEDITOR.env.ie&&c.type==CKEDITOR.NODE_TEXT&&(c=CKEDITOR.tools.rtrim(c.substring(d)),h.test(c)&&this.trim(1,0));a||this.trim();a=new CKEDITOR.dom.elementPath(this.endContainer,this.root);c=this.clone();c.collapse(!1);c.setEndAt(a.block||a.blockLimit,CKEDITOR.POSITION_BEFORE_END); -a=new CKEDITOR.dom.walker(c);a.evaluator=b();return a.checkForward()},getPreviousNode:function(a,b,c){var d=this.clone();d.collapse(1);d.setStartAt(c||this.root,CKEDITOR.POSITION_AFTER_START);c=new CKEDITOR.dom.walker(d);c.evaluator=a;c.guard=b;return c.previous()},getNextNode:function(a,b,c){var d=this.clone();d.collapse();d.setEndAt(c||this.root,CKEDITOR.POSITION_BEFORE_END);c=new CKEDITOR.dom.walker(d);c.evaluator=a;c.guard=b;return c.next()},checkReadOnly:function(){function a(b,c){for(;b;){if(b.type== +b){var c=this.createBookmark(),e=this.document.createElement(b);this.collapse(a);this.enlarge(CKEDITOR.ENLARGE_BLOCK_CONTENTS);this.extractContents().appendTo(e);e.trim();this.insertNode(e);var d=e.getBogus();d&&d.remove();e.appendBogus();this.moveToBookmark(c);return e},splitBlock:function(a,b){var c=new CKEDITOR.dom.elementPath(this.startContainer,this.root),e=new CKEDITOR.dom.elementPath(this.endContainer,this.root),d=c.block,f=e.block,m=null;if(!c.blockLimit.equals(e.blockLimit))return null;"br"!= +a&&(d||(d=this.fixBlock(!0,a),f=(new CKEDITOR.dom.elementPath(this.endContainer,this.root)).block),f||(f=this.fixBlock(!1,a)));c=d&&this.checkStartOfBlock();e=f&&this.checkEndOfBlock();this.deleteContents();d&&d.equals(f)&&(e?(m=new CKEDITOR.dom.elementPath(this.startContainer,this.root),this.moveToPosition(f,CKEDITOR.POSITION_AFTER_END),f=null):c?(m=new CKEDITOR.dom.elementPath(this.startContainer,this.root),this.moveToPosition(d,CKEDITOR.POSITION_BEFORE_START),d=null):(f=this.splitElement(d,b|| +!1),d.is("ul","ol")||d.appendBogus()));return{previousBlock:d,nextBlock:f,wasStartOfBlock:c,wasEndOfBlock:e,elementPath:m}},splitElement:function(a,b){if(!this.collapsed)return null;this.setEndAt(a,CKEDITOR.POSITION_BEFORE_END);var c=this.extractContents(!1,b||!1),e=a.clone(!1,b||!1);c.appendTo(e);e.insertAfter(a);this.moveToPosition(a,CKEDITOR.POSITION_AFTER_END);return e},removeEmptyBlocksAtEnd:function(){function a(e){return function(a){return b(a)||c(a)||a.type==CKEDITOR.NODE_ELEMENT&&a.isEmptyInlineRemoveable()|| +e.is("table")&&a.is("caption")?!1:!0}}var b=CKEDITOR.dom.walker.whitespaces(),c=CKEDITOR.dom.walker.bookmark(!1);return function(b){for(var c=this.createBookmark(),e=this[b?"endPath":"startPath"](),d=e.block||e.blockLimit,f;d&&!d.equals(e.root)&&!d.getFirst(a(d));)f=d.getParent(),this[b?"setEndAt":"setStartAt"](d,CKEDITOR.POSITION_AFTER_END),d.remove(1),d=f;this.moveToBookmark(c)}}(),startPath:function(){return new CKEDITOR.dom.elementPath(this.startContainer,this.root)},endPath:function(){return new CKEDITOR.dom.elementPath(this.endContainer, +this.root)},checkBoundaryOfElement:function(a,b){var e=b==CKEDITOR.START,d=this.clone();d.collapse(e);d[e?"setStartAt":"setEndAt"](a,e?CKEDITOR.POSITION_AFTER_START:CKEDITOR.POSITION_BEFORE_END);d=new CKEDITOR.dom.walker(d);d.evaluator=c(e);return d[e?"checkBackward":"checkForward"]()},checkStartOfBlock:function(a){var c=this.startContainer,e=this.startOffset;CKEDITOR.env.ie&&e&&c.type==CKEDITOR.NODE_TEXT&&(c=CKEDITOR.tools.ltrim(c.substring(0,e)),h.test(c)&&this.trim(0,1));a||this.trim();a=new CKEDITOR.dom.elementPath(this.startContainer, +this.root);c=this.clone();c.collapse(!0);c.setStartAt(a.block||a.blockLimit,CKEDITOR.POSITION_AFTER_START);a=new CKEDITOR.dom.walker(c);a.evaluator=b();return a.checkBackward()},checkEndOfBlock:function(a){var c=this.endContainer,e=this.endOffset;CKEDITOR.env.ie&&c.type==CKEDITOR.NODE_TEXT&&(c=CKEDITOR.tools.rtrim(c.substring(e)),h.test(c)&&this.trim(1,0));a||this.trim();a=new CKEDITOR.dom.elementPath(this.endContainer,this.root);c=this.clone();c.collapse(!1);c.setEndAt(a.block||a.blockLimit,CKEDITOR.POSITION_BEFORE_END); +a=new CKEDITOR.dom.walker(c);a.evaluator=b();return a.checkForward()},getPreviousNode:function(a,b,c){var e=this.clone();e.collapse(1);e.setStartAt(c||this.root,CKEDITOR.POSITION_AFTER_START);c=new CKEDITOR.dom.walker(e);c.evaluator=a;c.guard=b;return c.previous()},getNextNode:function(a,b,c){var e=this.clone();e.collapse();e.setEndAt(c||this.root,CKEDITOR.POSITION_BEFORE_END);c=new CKEDITOR.dom.walker(e);c.evaluator=a;c.guard=b;return c.next()},checkReadOnly:function(){function a(b,c){for(;b;){if(b.type== CKEDITOR.NODE_ELEMENT){if("false"==b.getAttribute("contentEditable")&&!b.data("cke-editable"))return 0;if(b.is("html")||"true"==b.getAttribute("contentEditable")&&(b.contains(c)||b.equals(c)))break}b=b.getParent()}return 1}return function(){var b=this.startContainer,c=this.endContainer;return!(a(b,c)&&a(c,b))}}(),moveToElementEditablePosition:function(a,b){if(a.type==CKEDITOR.NODE_ELEMENT&&!a.isEditable(!1))return this.moveToPosition(a,b?CKEDITOR.POSITION_AFTER_END:CKEDITOR.POSITION_BEFORE_START), !0;for(var c=0;a;){if(a.type==CKEDITOR.NODE_TEXT){b&&this.endContainer&&this.checkEndOfBlock()&&h.test(a.getText())?this.moveToPosition(a,CKEDITOR.POSITION_BEFORE_START):this.moveToPosition(a,b?CKEDITOR.POSITION_AFTER_END:CKEDITOR.POSITION_BEFORE_START);c=1;break}if(a.type==CKEDITOR.NODE_ELEMENT)if(a.isEditable())this.moveToPosition(a,b?CKEDITOR.POSITION_BEFORE_END:CKEDITOR.POSITION_AFTER_START),c=1;else if(b&&a.is("br")&&this.endContainer&&this.checkEndOfBlock())this.moveToPosition(a,CKEDITOR.POSITION_BEFORE_START); -else if("false"==a.getAttribute("contenteditable")&&a.is(CKEDITOR.dtd.$block))return this.setStartBefore(a),this.setEndAfter(a),!0;var d=a,e=c,f=void 0;d.type==CKEDITOR.NODE_ELEMENT&&d.isEditable(!1)&&(f=d[b?"getLast":"getFirst"](r));e||f||(f=d[b?"getPrevious":"getNext"](r));a=f}return!!c},moveToClosestEditablePosition:function(a,b){var c,d=0,e,f,m=[CKEDITOR.POSITION_AFTER_END,CKEDITOR.POSITION_BEFORE_START];a?(c=new CKEDITOR.dom.range(this.root),c.moveToPosition(a,m[b?0:1])):c=this.clone();if(a&& -!a.is(CKEDITOR.dtd.$block))d=1;else if(e=c[b?"getNextEditableNode":"getPreviousEditableNode"]())d=1,(f=e.type==CKEDITOR.NODE_ELEMENT)&&e.is(CKEDITOR.dtd.$block)&&"false"==e.getAttribute("contenteditable")?(c.setStartAt(e,CKEDITOR.POSITION_BEFORE_START),c.setEndAt(e,CKEDITOR.POSITION_AFTER_END)):!CKEDITOR.env.needsBrFiller&&f&&e.is(CKEDITOR.dom.walker.validEmptyBlockContainers)?(c.setEnd(e,0),c.collapse()):c.moveToPosition(e,m[b?1:0]);d&&this.moveToRange(c);return!!d},moveToElementEditStart:function(a){return this.moveToElementEditablePosition(a)}, -moveToElementEditEnd:function(a){return this.moveToElementEditablePosition(a,!0)},getEnclosedNode:function(){var a=this.clone();a.optimize();if(a.startContainer.type!=CKEDITOR.NODE_ELEMENT||a.endContainer.type!=CKEDITOR.NODE_ELEMENT)return null;var a=new CKEDITOR.dom.walker(a),b=CKEDITOR.dom.walker.bookmark(!1,!0),c=CKEDITOR.dom.walker.whitespaces(!0);a.evaluator=function(a){return c(a)&&b(a)};var d=a.next();a.reset();return d&&d.equals(a.previous())?d:null},getTouchedStartNode:function(){var a=this.startContainer; -return this.collapsed||a.type!=CKEDITOR.NODE_ELEMENT?a:a.getChild(this.startOffset)||a},getTouchedEndNode:function(){var a=this.endContainer;return this.collapsed||a.type!=CKEDITOR.NODE_ELEMENT?a:a.getChild(this.endOffset-1)||a},getNextEditableNode:f(),getPreviousEditableNode:f(1),_getTableElement:function(a){a=a||{td:1,th:1,tr:1,tbody:1,thead:1,tfoot:1,table:1};var b=this.getTouchedStartNode(),c=this.getTouchedEndNode(),d=b.getAscendant("table",!0),c=c.getAscendant("table",!0);return d&&!this.root.contains(d)? -null:this.getEnclosedNode()?this.getEnclosedNode().getAscendant(a,!0):d&&c&&(d.equals(c)||d.contains(c)||c.contains(d))?b.getAscendant(a,!0):null},scrollIntoView:function(){var a=new CKEDITOR.dom.element.createFromHtml("\x3cspan\x3e\x26nbsp;\x3c/span\x3e",this.document),b,c,d,e=this.clone();e.optimize();(d=e.startContainer.type==CKEDITOR.NODE_TEXT)?(c=e.startContainer.getText(),b=e.startContainer.split(e.startOffset),a.insertAfter(e.startContainer)):e.insertNode(a);a.scrollIntoView();d&&(e.startContainer.setText(c), -b.remove());a.remove()},getClientRects:function(){function a(b,c){var d=CKEDITOR.tools.array.map(b,function(a){return a}),e=new CKEDITOR.dom.range(c.root),g,f,h;c.startContainer instanceof CKEDITOR.dom.element&&(f=0===c.startOffset&&c.startContainer.hasAttribute("data-widget"));c.endContainer instanceof CKEDITOR.dom.element&&(h=(h=c.endOffset===(c.endContainer.getChildCount?c.endContainer.getChildCount():c.endContainer.length))&&c.endContainer.hasAttribute("data-widget"));f&&e.setStart(c.startContainer.getParent(), -c.startContainer.getIndex());h&&e.setEnd(c.endContainer.getParent(),c.endContainer.getIndex()+1);if(f||h)c=e;e=c.cloneContents().find("[data-cke-widget-id]").toArray();if(e=CKEDITOR.tools.array.map(e,function(a){var b=c.root.editor;a=a.getAttribute("data-cke-widget-id");return b.widgets.instances[a].element}))return e=CKEDITOR.tools.array.map(e,function(a){var b;b=a.getParent().hasClass("cke_widget_wrapper")?a.getParent():a;g=this.root.getDocument().$.createRange();g.setStart(b.getParent().$,b.getIndex()); -g.setEnd(b.getParent().$,b.getIndex()+1);b=g.getClientRects();b.widgetRect=a.getClientRect();return b},c),CKEDITOR.tools.array.forEach(e,function(a){function b(e){CKEDITOR.tools.array.forEach(d,function(b,g){var f=CKEDITOR.tools.objectCompare(a[e],b);f||(f=CKEDITOR.tools.objectCompare(a.widgetRect,b));f&&(Array.prototype.splice.call(d,g,a.length-e,a.widgetRect),c=!0)});c||(earguments.length||(this.range=a,this.forceBrBreak=0,this.enlargeBr=1,this.enforceRealBlocks=0,this._||(this._={}))}function d(a){var b=[];a.forEach(function(a){if("true"==a.getAttribute("contenteditable"))return b.push(a),!1},CKEDITOR.NODE_ELEMENT,!0);return b}function b(a,c,e,f){a:{null==f&&(f=d(e));for(var h;h=f.shift();)if(h.getDtd().p){f={element:h,remaining:f};break a}f=null}if(!f)return 0;if((h=CKEDITOR.filter.instances[f.element.data("cke-filter")])&&!h.check(c))return b(a, c,e,f.remaining);c=new CKEDITOR.dom.range(f.element);c.selectNodeContents(f.element);c=c.createIterator();c.enlargeBr=a.enlargeBr;c.enforceRealBlocks=a.enforceRealBlocks;c.activeFilter=c.filter=h;a._.nestedEditable={element:f.element,container:e,remaining:f.remaining,iterator:c};return 1}function c(a,b,c){if(!b)return!1;a=a.clone();a.collapse(!c);return a.checkBoundaryOfElement(b,c?CKEDITOR.START:CKEDITOR.END)}var f=/^[\r\n\t ]+$/,e=CKEDITOR.dom.walker.bookmark(!1,!0),k=CKEDITOR.dom.walker.whitespaces(!0), -h=function(a){return e(a)&&k(a)},l={dd:1,dt:1,li:1};a.prototype={getNextParagraph:function(a){var d,k,y,z,A;a=a||"p";if(this._.nestedEditable){if(d=this._.nestedEditable.iterator.getNextParagraph(a))return this.activeFilter=this._.nestedEditable.iterator.activeFilter,d;this.activeFilter=this.filter;if(b(this,a,this._.nestedEditable.container,this._.nestedEditable.remaining))return this.activeFilter=this._.nestedEditable.iterator.activeFilter,this._.nestedEditable.iterator.getNextParagraph(a);this._.nestedEditable= -null}if(!this.range.root.getDtd()[a])return null;if(!this._.started){var t=this.range.clone();k=t.startPath();var m=t.endPath(),M=!t.collapsed&&c(t,k.block),v=!t.collapsed&&c(t,m.block,1);t.shrink(CKEDITOR.SHRINK_ELEMENT,!0);M&&t.setStartAt(k.block,CKEDITOR.POSITION_BEFORE_END);v&&t.setEndAt(m.block,CKEDITOR.POSITION_AFTER_START);k=t.endContainer.hasAscendant("pre",!0)||t.startContainer.hasAscendant("pre",!0);t.enlarge(this.forceBrBreak&&!k||!this.enlargeBr?CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS:CKEDITOR.ENLARGE_BLOCK_CONTENTS); -t.collapsed||(k=new CKEDITOR.dom.walker(t.clone()),m=CKEDITOR.dom.walker.bookmark(!0,!0),k.evaluator=m,this._.nextNode=k.next(),k=new CKEDITOR.dom.walker(t.clone()),k.evaluator=m,k=k.previous(),this._.lastNode=k.getNextSourceNode(!0,null,t.root),this._.lastNode&&this._.lastNode.type==CKEDITOR.NODE_TEXT&&!CKEDITOR.tools.trim(this._.lastNode.getText())&&this._.lastNode.getParent().isBlockBoundary()&&(m=this.range.clone(),m.moveToPosition(this._.lastNode,CKEDITOR.POSITION_AFTER_END),m.checkEndOfBlock()&& -(m=new CKEDITOR.dom.elementPath(m.endContainer,m.root),this._.lastNode=(m.block||m.blockLimit).getNextSourceNode(!0))),this._.lastNode&&t.root.contains(this._.lastNode)||(this._.lastNode=this._.docEndMarker=t.document.createText(""),this._.lastNode.insertAfter(k)),t=null);this._.started=1;k=t}m=this._.nextNode;t=this._.lastNode;for(this._.nextNode=null;m;){var M=0,v=m.hasAscendant("pre"),J=m.type!=CKEDITOR.NODE_ELEMENT,E=0;if(J)m.type==CKEDITOR.NODE_TEXT&&f.test(m.getText())&&(J=0);else{var u=m.getName(); -if(CKEDITOR.dtd.$block[u]&&"false"==m.getAttribute("contenteditable")){d=m;b(this,a,d);break}else if(m.isBlockBoundary(this.forceBrBreak&&!v&&{br:1})){if("br"==u)J=1;else if(!k&&!m.getChildCount()&&"hr"!=u){d=m;y=m.equals(t);break}k&&(k.setEndAt(m,CKEDITOR.POSITION_BEFORE_START),"br"!=u&&(this._.nextNode=m));M=1}else{if(m.getFirst()){k||(k=this.range.clone(),k.setStartAt(m,CKEDITOR.POSITION_BEFORE_START));m=m.getFirst();continue}J=1}}J&&!k&&(k=this.range.clone(),k.setStartAt(m,CKEDITOR.POSITION_BEFORE_START)); -y=(!M||J)&&m.equals(t);if(k&&!M)for(;!m.getNext(h)&&!y;){u=m.getParent();if(u.isBlockBoundary(this.forceBrBreak&&!v&&{br:1})){M=1;J=0;y||u.equals(t);k.setEndAt(u,CKEDITOR.POSITION_BEFORE_END);break}m=u;J=1;y=m.equals(t);E=1}J&&k.setEndAt(m,CKEDITOR.POSITION_AFTER_END);m=this._getNextSourceNode(m,E,t);if((y=!m)||M&&k)break}if(!d){if(!k)return this._.docEndMarker&&this._.docEndMarker.remove(),this._.nextNode=null;d=new CKEDITOR.dom.elementPath(k.startContainer,k.root);m=d.blockLimit;M={div:1,th:1,td:1}; -d=d.block;!d&&m&&!this.enforceRealBlocks&&M[m.getName()]&&k.checkStartOfBlock()&&k.checkEndOfBlock()&&!m.equals(k.root)?d=m:!d||this.enforceRealBlocks&&d.is(l)?(d=this.range.document.createElement(a),k.extractContents().appendTo(d),d.trim(),k.insertNode(d),z=A=!0):"li"!=d.getName()?k.checkStartOfBlock()&&k.checkEndOfBlock()||(d=d.clone(!1),k.extractContents().appendTo(d),d.trim(),A=k.splitBlock(),z=!A.wasStartOfBlock,A=!A.wasEndOfBlock,k.insertNode(d)):y||(this._.nextNode=d.equals(t)?null:this._getNextSourceNode(k.getBoundaryNodes().endNode, -1,t))}z&&(z=d.getPrevious())&&z.type==CKEDITOR.NODE_ELEMENT&&("br"==z.getName()?z.remove():z.getLast()&&"br"==z.getLast().$.nodeName.toLowerCase()&&z.getLast().remove());A&&(z=d.getLast())&&z.type==CKEDITOR.NODE_ELEMENT&&"br"==z.getName()&&(!CKEDITOR.env.needsBrFiller||z.getPrevious(e)||z.getNext(e))&&z.remove();this._.nextNode||(this._.nextNode=y||d.equals(t)||!t?null:this._getNextSourceNode(d,1,t));return d},_getNextSourceNode:function(a,b,c){function d(a){return!(a.equals(c)||a.equals(f))}var f= +h=function(a){return e(a)&&k(a)},n={dd:1,dt:1,li:1};a.prototype={getNextParagraph:function(a){var d,k,y,z,G;a=a||"p";if(this._.nestedEditable){if(d=this._.nestedEditable.iterator.getNextParagraph(a))return this.activeFilter=this._.nestedEditable.iterator.activeFilter,d;this.activeFilter=this.filter;if(b(this,a,this._.nestedEditable.container,this._.nestedEditable.remaining))return this.activeFilter=this._.nestedEditable.iterator.activeFilter,this._.nestedEditable.iterator.getNextParagraph(a);this._.nestedEditable= +null}if(!this.range.root.getDtd()[a])return null;if(!this._.started){var v=this.range.clone();k=v.startPath();var m=v.endPath(),M=!v.collapsed&&c(v,k.block),w=!v.collapsed&&c(v,m.block,1);v.shrink(CKEDITOR.SHRINK_ELEMENT,!0);M&&v.setStartAt(k.block,CKEDITOR.POSITION_BEFORE_END);w&&v.setEndAt(m.block,CKEDITOR.POSITION_AFTER_START);k=v.endContainer.hasAscendant("pre",!0)||v.startContainer.hasAscendant("pre",!0);v.enlarge(this.forceBrBreak&&!k||!this.enlargeBr?CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS:CKEDITOR.ENLARGE_BLOCK_CONTENTS); +v.collapsed||(k=new CKEDITOR.dom.walker(v.clone()),m=CKEDITOR.dom.walker.bookmark(!0,!0),k.evaluator=m,this._.nextNode=k.next(),k=new CKEDITOR.dom.walker(v.clone()),k.evaluator=m,k=k.previous(),this._.lastNode=k.getNextSourceNode(!0,null,v.root),this._.lastNode&&this._.lastNode.type==CKEDITOR.NODE_TEXT&&!CKEDITOR.tools.trim(this._.lastNode.getText())&&this._.lastNode.getParent().isBlockBoundary()&&(m=this.range.clone(),m.moveToPosition(this._.lastNode,CKEDITOR.POSITION_AFTER_END),m.checkEndOfBlock()&& +(m=new CKEDITOR.dom.elementPath(m.endContainer,m.root),this._.lastNode=(m.block||m.blockLimit).getNextSourceNode(!0))),this._.lastNode&&v.root.contains(this._.lastNode)||(this._.lastNode=this._.docEndMarker=v.document.createText(""),this._.lastNode.insertAfter(k)),v=null);this._.started=1;k=v}m=this._.nextNode;v=this._.lastNode;for(this._.nextNode=null;m;){var M=0,w=m.hasAscendant("pre"),J=m.type!=CKEDITOR.NODE_ELEMENT,F=0;if(J)m.type==CKEDITOR.NODE_TEXT&&f.test(m.getText())&&(J=0);else{var q=m.getName(); +if(CKEDITOR.dtd.$block[q]&&"false"==m.getAttribute("contenteditable")){d=m;b(this,a,d);break}else if(m.isBlockBoundary(this.forceBrBreak&&!w&&{br:1})){if("br"==q)J=1;else if(!k&&!m.getChildCount()&&"hr"!=q){d=m;y=m.equals(v);break}k&&(k.setEndAt(m,CKEDITOR.POSITION_BEFORE_START),"br"!=q&&(this._.nextNode=m));M=1}else{if(m.getFirst()){k||(k=this.range.clone(),k.setStartAt(m,CKEDITOR.POSITION_BEFORE_START));m=m.getFirst();continue}J=1}}J&&!k&&(k=this.range.clone(),k.setStartAt(m,CKEDITOR.POSITION_BEFORE_START)); +y=(!M||J)&&m.equals(v);if(k&&!M)for(;!m.getNext(h)&&!y;){q=m.getParent();if(q.isBlockBoundary(this.forceBrBreak&&!w&&{br:1})){M=1;J=0;y||q.equals(v);k.setEndAt(q,CKEDITOR.POSITION_BEFORE_END);break}m=q;J=1;y=m.equals(v);F=1}J&&k.setEndAt(m,CKEDITOR.POSITION_AFTER_END);m=this._getNextSourceNode(m,F,v);if((y=!m)||M&&k)break}if(!d){if(!k)return this._.docEndMarker&&this._.docEndMarker.remove(),this._.nextNode=null;d=new CKEDITOR.dom.elementPath(k.startContainer,k.root);m=d.blockLimit;M={div:1,th:1,td:1}; +d=d.block;!d&&m&&!this.enforceRealBlocks&&M[m.getName()]&&k.checkStartOfBlock()&&k.checkEndOfBlock()&&!m.equals(k.root)?d=m:!d||this.enforceRealBlocks&&d.is(n)?(d=this.range.document.createElement(a),k.extractContents().appendTo(d),d.trim(),k.insertNode(d),z=G=!0):"li"!=d.getName()?k.checkStartOfBlock()&&k.checkEndOfBlock()||(d=d.clone(!1),k.extractContents().appendTo(d),d.trim(),G=k.splitBlock(),z=!G.wasStartOfBlock,G=!G.wasEndOfBlock,k.insertNode(d)):y||(this._.nextNode=d.equals(v)?null:this._getNextSourceNode(k.getBoundaryNodes().endNode, +1,v))}z&&(z=d.getPrevious())&&z.type==CKEDITOR.NODE_ELEMENT&&("br"==z.getName()?z.remove():z.getLast()&&"br"==z.getLast().$.nodeName.toLowerCase()&&z.getLast().remove());G&&(z=d.getLast())&&z.type==CKEDITOR.NODE_ELEMENT&&"br"==z.getName()&&(!CKEDITOR.env.needsBrFiller||z.getPrevious(e)||z.getNext(e))&&z.remove();this._.nextNode||(this._.nextNode=y||d.equals(v)||!v?null:this._getNextSourceNode(d,1,v));return d},_getNextSourceNode:function(a,b,c){function d(a){return!(a.equals(c)||a.equals(f))}var f= this.range.root;for(a=a.getNextSourceNode(b,null,d);!e(a);)a=a.getNextSourceNode(b,null,d);return a}};CKEDITOR.dom.range.prototype.createIterator=function(){return new a(this)}})(); CKEDITOR.command=function(a,d){this.uiItems=[];this.exec=function(b){if(this.state==CKEDITOR.TRISTATE_DISABLED||!this.checkAllowed())return!1;this.editorFocus&&a.focus();return!1===this.fire("exec")?!0:!1!==d.exec.call(this,a,b)};this.refresh=function(a,b){if(!this.readOnly&&a.readOnly)return!0;if(this.context&&!b.isContextFor(this.context)||!this.checkAllowed(!0))return this.disable(),!0;this.startDisabled||this.enable();this.modes&&!this.modes[a.mode]&&this.disable();return!1===this.fire("refresh", {editor:a,path:b})?!0:d.refresh&&!1!==d.refresh.apply(this,arguments)};var b;this.checkAllowed=function(c){return c||"boolean"!=typeof b?b=a.activeFilter.checkFeature(this):b};CKEDITOR.tools.extend(this,d,{modes:{wysiwyg:1},editorFocus:1,contextSensitive:!!d.context,state:CKEDITOR.TRISTATE_DISABLED});CKEDITOR.event.call(this)}; CKEDITOR.command.prototype={enable:function(){this.state==CKEDITOR.TRISTATE_DISABLED&&this.checkAllowed()&&this.setState(this.preserveState&&"undefined"!=typeof this.previousState?this.previousState:CKEDITOR.TRISTATE_OFF)},disable:function(){this.setState(CKEDITOR.TRISTATE_DISABLED)},setState:function(a){if(this.state==a||a!=CKEDITOR.TRISTATE_DISABLED&&!this.checkAllowed())return!1;this.previousState=this.state;this.state=a;this.fire("state");return!0},toggleState:function(){this.state==CKEDITOR.TRISTATE_OFF? this.setState(CKEDITOR.TRISTATE_ON):this.state==CKEDITOR.TRISTATE_ON&&this.setState(CKEDITOR.TRISTATE_OFF)}};CKEDITOR.event.implementOn(CKEDITOR.command.prototype);CKEDITOR.ENTER_P=1;CKEDITOR.ENTER_BR=2;CKEDITOR.ENTER_DIV=3; CKEDITOR.config={customConfig:"config.js",autoUpdateElement:!0,language:"",defaultLanguage:"en",contentsLangDirection:"",enterMode:CKEDITOR.ENTER_P,forceEnterMode:!1,shiftEnterMode:CKEDITOR.ENTER_BR,docType:"\x3c!DOCTYPE html\x3e",bodyId:"",bodyClass:"",fullPage:!1,height:200,contentsCss:CKEDITOR.getUrl("contents.css"),extraPlugins:"",removePlugins:"",protectedSource:[],tabIndex:0,useComputedState:!0,width:"",baseFloatZIndex:1E4,blockedKeystrokes:[CKEDITOR.CTRL+66,CKEDITOR.CTRL+73,CKEDITOR.CTRL+85]}; -(function(){function a(a,b,c,d,e){var f,g;a=[];for(f in b){g=b[f];g="boolean"==typeof g?{}:"function"==typeof g?{match:g}:D(g);"$"!=f.charAt(0)&&(g.elements=f);c&&(g.featureName=c.toLowerCase());var n=g;n.elements=k(n.elements,/\s+/)||null;n.propertiesOnly=n.propertiesOnly||!0===n.elements;var p=/\s*,\s*/,q=void 0;for(q in T){n[q]=k(n[q],p)||null;var B=n,m=O[q],x=k(n[O[q]],p),h=n[q],C=[],G=!0,I=void 0;x?G=!1:x={};for(I in h)"!"==I.charAt(0)&&(I=I.slice(1),C.push(I),x[I]=!0,G=!1);for(;I=C.pop();)h[I]= -h["!"+I],delete h["!"+I];B[m]=(G?!1:x)||null}n.match=n.match||null;d.push(g);a.push(g)}b=e.elements;e=e.generic;var l;c=0;for(d=a.length;c=--l&&(e&&CKEDITOR.document.getDocumentElement().removeStyle("cursor"),w(b))},z=function(b,c){a[b]=1;var e=d[b];delete d[b];for(var f=0;f=--n&&(e&&CKEDITOR.document.getDocumentElement().removeStyle("cursor"),x(b))},z=function(b,c){a[b]=1;var e=d[b];delete d[b];for(var f=0;f=CKEDITOR.env.version||CKEDITOR.env.ie9Compat)?f.$.onreadystatechange=function(){if("loaded"==f.$.readyState||"complete"==f.$.readyState)f.$.onreadystatechange=null,z(b,!0)}:(f.$.onload=function(){setTimeout(function(){f.$.onload=null;f.$.onerror=null;z(b,!0)},0)},f.$.onerror=function(){f.$.onload=null;f.$.onerror=null;z(b,!1)}));f.appendTo(CKEDITOR.document.getHead())}}};e&&CKEDITOR.document.getDocumentElement().setStyle("cursor", -"wait");for(var t=0;t]+)>)|(?:!--([\S|\s]*?)--!?>)|(?:([^\/\s>]+)((?:\s+[\w\-:.]+(?:\s*=\s*?(?:(?:"[^"]*")|(?:'[^']*')|[^\s"'\/>]+))?)*)[\S\s]*?(\/?)>))/g}}; +!1;a.tabIndex=c.tabIndex||a.element&&a.element.getAttribute("tabindex")||0;a.activeEnterMode=a.enterMode=a.blockless?CKEDITOR.ENTER_BR:c.enterMode;a.activeShiftEnterMode=a.shiftEnterMode=a.blockless?CKEDITOR.ENTER_BR:c.shiftEnterMode;c.skin&&(CKEDITOR.skinName=c.skin);a.fireOnce("configLoaded");a.dataProcessor=new CKEDITOR.htmlDataProcessor(a);a.filter=a.activeFilter=new CKEDITOR.filter(a);n(a)});b&&null!=b.customConfig&&(a.config.customConfig=b.customConfig);k(a)||a.fireOnce("customConfigLoaded")} +function n(a){CKEDITOR.skin.loadPart("editor",function(){l(a)})}function l(a){CKEDITOR.lang.load(a.config.language,a.config.defaultLanguage,function(b,c){var e=a.config.title,d=a.config.applicationTitle;a.langCode=b;a.lang=CKEDITOR.tools.prototypedCopy(c);a.title="string"==typeof e||!1===e?e:[a.lang.editor,a.name].join(", ");a.applicationTitle="string"==typeof d||!1===d?d:[a.lang.application,a.name].join(", ");a.config.contentsLangDirection||(a.config.contentsLangDirection=a.elementMode==CKEDITOR.ELEMENT_MODE_INLINE? +a.element.getDirection(1):a.lang.dir);a.fire("langLoaded");g(a)})}function g(a){a.getStylesSet(function(b){a.once("loaded",function(){a.fire("stylesSet",{styles:b})},null,null,1);x(a)})}function x(a){function b(a){if(!a)return"";CKEDITOR.tools.isArray(a)&&(a=a.join(","));return a.replace(/\s/g,"")}var c=a.config,e=b(c.plugins),d=b(c.extraPlugins),f=b(c.removePlugins);if(d)var g=new RegExp("(?:^|,)(?:"+d.replace(/,/g,"|")+")(?\x3d,|$)","g"),e=e.replace(g,""),e=e+(","+d);if(f)var h=new RegExp("(?:^|,)(?:"+ +f.replace(/,/g,"|")+")(?\x3d,|$)","g"),e=e.replace(h,"");CKEDITOR.env.air&&(e+=",adobeair");CKEDITOR.plugins.load(e.split(","),function(b){var e=[],d=[],f=[];a.plugins=CKEDITOR.tools.extend({},a.plugins,b);for(var g in b){var k=b[g],N=k.lang,L=null,r=k.requires,E;CKEDITOR.tools.isArray(r)&&(r=r.join(","));if(r&&(E=r.match(h)))for(;r=E.pop();)CKEDITOR.error("editor-plugin-required",{plugin:r.replace(",",""),requiredBy:g});N&&!a.lang[g]&&(N.split&&(N=N.split(",")),0<=CKEDITOR.tools.indexOf(N,a.langCode)? +L=a.langCode:(L=a.langCode.replace(/-.*/,""),L=L!=a.langCode&&0<=CKEDITOR.tools.indexOf(N,L)?L:0<=CKEDITOR.tools.indexOf(N,"en")?"en":N[0]),k.langEntries&&k.langEntries[L]?(a.lang[g]=k.langEntries[L],L=null):f.push(CKEDITOR.getUrl(k.path+"lang/"+L+".js")));d.push(L);e.push(k)}CKEDITOR.scriptLoader.load(f,function(){if(!a.isDestroyed()&&!a.isDetached()){for(var b=["beforeInit","init","afterInit"],f=0;f]+)>)|(?:!--([\S|\s]*?)--!?>)|(?:([^\/\s>]+)((?:\s+[\w\-:.]+(?:\s*=\s*?(?:(?:"[^"]*")|(?:'[^']*')|[^\s"'\/>]+))?)*)[\S\s]*?(\/?)>))/g}}; (function(){var a=/([\w\-:.]+)(?:(?:\s*=\s*(?:(?:"([^"]*)")|(?:'([^']*)')|([^\s>]+)))|(?=\s|$))/g,d={checked:1,compact:1,declare:1,defer:1,disabled:1,ismap:1,multiple:1,nohref:1,noresize:1,noshade:1,nowrap:1,readonly:1,selected:1};CKEDITOR.htmlParser.prototype={onTagOpen:function(){},onTagClose:function(){},onText:function(){},onCDATA:function(){},onComment:function(){},parse:function(b){for(var c,f,e=0,k;c=this._.htmlPartsRegex.exec(b);){f=c.index;if(f>e)if(e=b.substring(e,f),k)k.push(e);else this.onText(e); -e=this._.htmlPartsRegex.lastIndex;if(f=c[1])if(f=f.toLowerCase(),k&&CKEDITOR.dtd.$cdata[f]&&(this.onCDATA(k.join("")),k=null),!k){this.onTagClose(f);continue}if(k)k.push(c[0]);else if(f=c[3]){if(f=f.toLowerCase(),!/="/.test(f)){var h={},l,r=c[4];c=!!c[5];if(r)for(;l=a.exec(r);){var g=l[1].toLowerCase();l=l[2]||l[3]||l[4]||"";h[g]=!l&&d[g]?g:CKEDITOR.tools.htmlDecodeAttr(l)}this.onTagOpen(f,h,c);!k&&CKEDITOR.dtd.$cdata[f]&&(k=[])}}else if(f=c[2])this.onComment(f)}if(b.length>e)this.onText(b.substring(e, +e=this._.htmlPartsRegex.lastIndex;if(f=c[1])if(f=f.toLowerCase(),k&&CKEDITOR.dtd.$cdata[f]&&(this.onCDATA(k.join("")),k=null),!k){this.onTagClose(f);continue}if(k)k.push(c[0]);else if(f=c[3]){if(f=f.toLowerCase(),!/="/.test(f)){var h={},n,l=c[4];c=!!c[5];if(l)for(;n=a.exec(l);){var g=n[1].toLowerCase();n=n[2]||n[3]||n[4]||"";h[g]=!n&&d[g]?g:CKEDITOR.tools.htmlDecodeAttr(n)}this.onTagOpen(f,h,c);!k&&CKEDITOR.dtd.$cdata[f]&&(k=[])}}else if(f=c[2])this.onComment(f)}if(b.length>e)this.onText(b.substring(e, b.length))}}})(); CKEDITOR.htmlParser.basicWriter=CKEDITOR.tools.createClass({$:function(){this._={output:[]}},proto:{openTag:function(a){this._.output.push("\x3c",a)},openTagClose:function(a,d){d?this._.output.push(" /\x3e"):this._.output.push("\x3e")},attribute:function(a,d){"string"==typeof d&&(d=CKEDITOR.tools.htmlEncodeAttr(d));this._.output.push(" ",a,'\x3d"',d,'"')},closeTag:function(a){this._.output.push("\x3c/",a,"\x3e")},text:function(a){this._.output.push(a)},comment:function(a){this._.output.push("\x3c!--",a, "--\x3e")},write:function(a){this._.output.push(a)},reset:function(){this._.output=[];this._.indent=!1},getHtml:function(a){var d=this._.output.join("");a&&this.reset();return d}}});"use strict"; @@ -309,228 +310,232 @@ CKEDITOR.htmlParser.comment.prototype=CKEDITOR.tools.extend(new CKEDITOR.htmlPar (function(){CKEDITOR.htmlParser.cdata=function(a){this.value=a};CKEDITOR.htmlParser.cdata.prototype=CKEDITOR.tools.extend(new CKEDITOR.htmlParser.node,{type:CKEDITOR.NODE_TEXT,filter:function(a){var d=this.getAscendant("style");if(d&&d.getAscendant({math:1,svg:1})){var d=CKEDITOR.htmlParser.fragment.fromHtml(this.value),b=new CKEDITOR.htmlParser.basicWriter;a.applyTo(d);d.writeHtml(b);this.value=b.getHtml()}},writeHtml:function(a){a.write(this.value)}})})();"use strict"; CKEDITOR.htmlParser.fragment=function(){this.children=[];this.parent=null;this._={isBlockLike:!0,hasInlineStarted:!1}}; (function(){function a(a){return a.attributes["data-cke-survive"]?!1:"a"==a.name&&a.attributes.href||CKEDITOR.dtd.$removeEmpty[a.name]}var d=CKEDITOR.tools.extend({table:1,ul:1,ol:1,dl:1},CKEDITOR.dtd.table,CKEDITOR.dtd.ul,CKEDITOR.dtd.ol,CKEDITOR.dtd.dl),b={ol:1,ul:1},c=CKEDITOR.tools.extend({},{html:1},CKEDITOR.dtd.html,CKEDITOR.dtd.body,CKEDITOR.dtd.head,{style:1,script:1}),f={ul:"li",ol:"li",dl:"dd",table:"tbody",tbody:"tr",thead:"tr",tfoot:"tr",tr:"td"};CKEDITOR.htmlParser.fragment.fromHtml= -function(e,k,h){function l(a){var b;if(0k;k++)if(e=d[k]){e=e.exec(a,c,this);if(!1===e)return null;if(e&&e!=c)return this.onNode(a,e);if(c.parent&&!c.name)break}return c}, onNode:function(a,c){var d=c.type;return d==CKEDITOR.NODE_ELEMENT?this.onElement(a,c):d==CKEDITOR.NODE_TEXT?new CKEDITOR.htmlParser.text(this.onText(a,c.value,c)):d==CKEDITOR.NODE_COMMENT?new CKEDITOR.htmlParser.comment(this.onComment(a,c.value,c)):null},onAttribute:function(a,c,d,e){return(d=this.attributesRules[d])?d.exec(a,e,c,this):e}}});CKEDITOR.htmlParser.filterRulesGroup=a;a.prototype={add:function(a,c,d){this.rules.splice(this.findIndex(c),0,{value:a,priority:c,options:d})},addMany:function(a, -c,d){for(var e=[this.findIndex(c),0],k=0,h=a.length;k/g,"\x26gt;")+"\x3c/textarea\x3e");return"\x3ccke:encoded\x3e"+encodeURIComponent(a)+"\x3c/cke:encoded\x3e"})}function w(a){return a.replace(O,function(a,b){return decodeURIComponent(b)})}function y(a){return a.replace(/\x3c!--(?!{cke_protected})[\s\S]+?--\x3e/g, -function(a){return"\x3c!--"+v+"{C}"+encodeURIComponent(a).replace(/--/g,"%2D%2D")+"--\x3e"})}function z(a){return a.replace(/\x3c!--\{cke_protected\}\{C\}([\s\S]+?)--\x3e/g,function(a,b){return decodeURIComponent(b)})}function A(a,b){var c=b._.dataStore;return a.replace(/\x3c!--\{cke_protected\}([\s\S]+?)--\x3e/g,function(a,b){return decodeURIComponent(b)}).replace(/\{cke_protected_(\d+)\}/g,function(a,b){return c&&c[b]||""})}function t(a,b,c){var d=[],e=b.config.protectedSource,f=b._.dataStore|| -(b._.dataStore={id:1}),g=new RegExp("\x3c\\!--\\{cke_temp_"+c+"(comment)?\\}(\\d*?)--\x3e","g"),e=[/|$)/gi,//gi,//gi].concat(e);a=a.replace(/\x3c!--[\s\S]*?--\x3e/g,function(a){return"\x3c!--{cke_temp_"+c+"comment}"+(d.push(a)-1)+"--\x3e"});for(var p=0;p]+\s*=\s*(?:[^'"\s>]+|'[^']*'|"[^"]*"))|[^\s=\/>]+))+\s*\/?>/g,function(a){return a.replace(/\x3c!--\{cke_protected\}([^>]*)--\x3e/g,function(a,b){f[f.id]=decodeURIComponent(b);return"{cke_protected_"+f.id++ +"}"})});return a=a.replace(/<(title|iframe|textarea)([^>]*)>([\s\S]*?)<\/\1>/g,function(a,c,d,e){return"\x3c"+c+d+"\x3e"+A(z(e),b)+"\x3c/"+c+"\x3e"})}var m;CKEDITOR.htmlDataProcessor= -function(b){var c,e,f=this;this.editor=b;this.dataFilter=c=new CKEDITOR.htmlParser.filter;this.htmlFilter=e=new CKEDITOR.htmlParser.filter;this.writer=new CKEDITOR.htmlParser.basicWriter;c.addRules(F);c.addRules(H,{applyToAll:!0});c.addRules(a(b,"data"),{applyToAll:!0});e.addRules(x);e.addRules(K,{applyToAll:!0});e.addRules(a(b,"html"),{applyToAll:!0});b.on("toHtml",function(a){var c;var e=window.crypto||window.msCrypto;c=e?e.getRandomValues(new Uint32Array(1))[0]:Math.floor(9E9*Math.random()+1E9); -a=a.data;var e=a.dataValue,e=m(e),e=t(e,b,c),e=g(e,T),e=r(e,c),e=g(e,G),e=e.replace(q,"$1cke:$2"),e=e.replace(N,"\x3ccke:$1$2\x3e\x3c/cke:$1\x3e"),e=e.replace(/(]*>)(\r\n|\n)/g,"$1$2$2"),e=e.replace(/([^a-z0-9<\-])(on\w{3,})(?!>)/gi,"$1data-cke-"+c+"-$2"),f=a.context||b.editable().getName(),p;CKEDITOR.env.ie&&9>CKEDITOR.env.version&&"pre"==f&&(f="div",e="\x3cpre\x3e"+e+"\x3c/pre\x3e",p=1);f=b.document.createElement(f);f.setHtml("a"+e);e=f.getHtml().substr(1);e=e.replace(new RegExp("data-cke-"+ -c+"-","ig"),"");p&&(e=e.replace(/^
    |<\/pre>$/gi,""));e=e.replace(I,"$1$2");e=w(e);e=z(e);c=!1===a.fixForBody?!1:d(a.enterMode,b.config.autoParagraph);e=CKEDITOR.htmlParser.fragment.fromHtml(e,a.context,c);c&&(p=e,!p.children.length&&CKEDITOR.dtd[p.name][c]&&(c=new CKEDITOR.htmlParser.element(c),p.add(c)));a.dataValue=e},null,null,5);b.on("toHtml",function(a){a.data.filter.applyTo(a.data.dataValue,!0,a.data.dontFilter,a.data.enterMode)&&b.fire("dataFiltered")},null,null,6);b.on("toHtml",function(a){a.data.dataValue.filterChildren(f.dataFilter,
    +c,d){for(var e=[this.findIndex(c),0],k=0,h=a.length;k/g,"\x26gt;")+"\x3c/textarea\x3e");return"\x3ccke:encoded\x3e"+encodeURIComponent(a)+"\x3c/cke:encoded\x3e"})}function x(a){return a.replace(L,function(a,b){return decodeURIComponent(b)})}function y(a){return a.replace(/\x3c!--(?!{cke_protected})[\s\S]+?--\x3e/g,
    +function(a){return"\x3c!--"+w+"{C}"+encodeURIComponent(a).replace(/--/g,"%2D%2D")+"--\x3e"})}function z(a){return a.replace(/\x3c!--\{cke_protected\}\{C\}([\s\S]+?)--\x3e/g,function(a,b){return decodeURIComponent(b)})}function G(a,b){var c=b._.dataStore;return a.replace(/\x3c!--\{cke_protected\}([\s\S]+?)--\x3e/g,function(a,b){return decodeURIComponent(b)}).replace(/\{cke_protected_(\d+)\}/g,function(a,b){return c&&c[b]||""})}function v(a,b,c){var d=[],e=b.config.protectedSource,f=b._.dataStore||
    +(b._.dataStore={id:1}),g=new RegExp("\x3c\\!--\\{cke_temp_"+c+"(comment)?\\}(\\d*?)--\x3e","g"),e=[/|$)/gi,//gi,//gi].concat(e);a=a.replace(/\x3c!--[\s\S]*?--\x3e/g,function(a){return"\x3c!--{cke_temp_"+c+"comment}"+(d.push(a)-1)+"--\x3e"});for(var t=0;t]+\s*=\s*(?:[^'"\s>]+|'[^']*'|"[^"]*"))|[^\s=\/>]+))+\s*\/?>/g,function(a){return a.replace(/\x3c!--\{cke_protected\}([^>]*)--\x3e/g,function(a,b){f[f.id]=decodeURIComponent(b);return"{cke_protected_"+f.id++ +"}"})});return a=a.replace(/<(title|iframe|textarea)([^>]*)>([\s\S]*?)<\/\1>/g,function(a,c,d,e){return"\x3c"+c+d+"\x3e"+G(z(e),b)+"\x3c/"+c+"\x3e"})}var m;CKEDITOR.htmlDataProcessor=
    +function(b){var c,e,f=this;this.editor=b;this.dataFilter=c=new CKEDITOR.htmlParser.filter;this.htmlFilter=e=new CKEDITOR.htmlParser.filter;this.writer=new CKEDITOR.htmlParser.basicWriter;c.addRules(u);c.addRules(K,{applyToAll:!0});c.addRules(a(b,"data"),{applyToAll:!0});e.addRules(D);e.addRules(B,{applyToAll:!0});e.addRules(a(b,"html"),{applyToAll:!0});b.on("toHtml",function(a){var c;var e=window.crypto||window.msCrypto;c=e?e.getRandomValues(new Uint32Array(1))[0]:Math.floor(9E9*Math.random()+1E9);
    +a=a.data;var e=a.dataValue,e=m(e),e=v(e,b,c),e=g(e,N),e=l(e,c),e=g(e,I),e=e.replace(r,"$1cke:$2"),e=e.replace(S,"\x3ccke:$1$2\x3e\x3c/cke:$1\x3e"),e=e.replace(/(]*>)(\r\n|\n)/g,"$1$2$2"),e=e.replace(/([^a-z0-9<\-])(on\w{3,})(?!>)/gi,"$1data-cke-"+c+"-$2"),f=a.context||b.editable().getName(),t;CKEDITOR.env.ie&&9>CKEDITOR.env.version&&"pre"==f&&(f="div",e="\x3cpre\x3e"+e+"\x3c/pre\x3e",t=1);f=b.document.createElement(f);f.setHtml("a"+e);e=f.getHtml().substr(1);e=e.replace(new RegExp("data-cke-"+
    +c+"-","ig"),"");t&&(e=e.replace(/^
    |<\/pre>$/gi,""));e=e.replace(E,"$1$2");e=x(e);e=z(e);c=!1===a.fixForBody?!1:d(a.enterMode,b.config.autoParagraph);e=CKEDITOR.htmlParser.fragment.fromHtml(e,a.context,c);c&&(t=e,!t.children.length&&CKEDITOR.dtd[t.name][c]&&(c=new CKEDITOR.htmlParser.element(c),t.add(c)));a.dataValue=e},null,null,5);b.on("toHtml",function(a){a.data.filter.applyTo(a.data.dataValue,!0,a.data.dontFilter,a.data.enterMode)&&b.fire("dataFiltered")},null,null,6);b.on("toHtml",function(a){a.data.dataValue.filterChildren(f.dataFilter,
     !0)},null,null,10);b.on("toHtml",function(a){a=a.data;var b=a.dataValue,c=new CKEDITOR.htmlParser.basicWriter;b.writeChildrenHtml(c);b=c.getHtml(!0);a.dataValue=y(b)},null,null,15);b.on("toDataFormat",function(a){var c=a.data.dataValue;a.data.enterMode!=CKEDITOR.ENTER_BR&&(c=c.replace(/^
    /i,""));a.data.dataValue=CKEDITOR.htmlParser.fragment.fromHtml(c,a.data.context,d(a.data.enterMode,b.config.autoParagraph))},null,null,5);b.on("toDataFormat",function(a){a.data.dataValue.filterChildren(f.htmlFilter, -!0)},null,null,10);b.on("toDataFormat",function(a){a.data.filter.applyTo(a.data.dataValue,!1,!0)},null,null,11);b.on("toDataFormat",function(a){var c=a.data.dataValue,d=f.writer;d.reset();c.writeChildrenHtml(d);c=d.getHtml(!0);c=z(c);c=A(c,b);a.data.dataValue=c},null,null,15)};CKEDITOR.htmlDataProcessor.prototype={toHtml:function(a,b,c,d){var e=this.editor,f,g,p,q;b&&"object"==typeof b?(f=b.context,c=b.fixForBody,d=b.dontFilter,g=b.filter,p=b.enterMode,q=b.protectedWhitespaces):f=b;f||null===f||(f= -e.editable().getName());return e.fire("toHtml",{dataValue:a,context:f,fixForBody:c,dontFilter:d,filter:g||e.filter,enterMode:p||e.enterMode,protectedWhitespaces:q}).dataValue},toDataFormat:function(a,b){var c,d,e;b&&(c=b.context,d=b.filter,e=b.enterMode);c||null===c||(c=this.editor.editable().getName());return this.editor.fire("toDataFormat",{dataValue:a,filter:d||this.editor.filter,context:c,enterMode:e||this.editor.enterMode}).dataValue},protectSource:function(a){return t(a,this.editor)},unprotectSource:function(a){return A(a, -this.editor)},unprotectRealComments:function(a){return z(a)}};var M=/(?: |\xa0)$/,v="{cke_protected}",J=CKEDITOR.dtd,E="caption colgroup col thead tfoot tbody".split(" "),u=CKEDITOR.tools.extend({},J.$blockLimit,J.$block),F={elements:{input:h,textarea:h}},H={attributeNames:[[/^on/,"data-cke-pa-on"],[/^srcdoc/,"data-cke-pa-srcdoc"],[/^data-cke-expando$/,""]],elements:{iframe:function(a){if(a.attributes&&a.attributes.src){var b=a.attributes.src.toLowerCase().replace(/[^a-z]/gi,"");if(0===b.indexOf("javascript")|| -0===b.indexOf("data"))a.attributes["data-cke-pa-src"]=a.attributes.src,delete a.attributes.src}}}},x={elements:{embed:function(a){var b=a.parent;if(b&&"object"==b.name){var c=b.attributes.width,b=b.attributes.height;c&&(a.attributes.width=c);b&&(a.attributes.height=b)}},a:function(a){var b=a.attributes;if(!(a.children.length||b.name||b.id||a.attributes["data-cke-saved-name"]))return!1}}},K={elementNames:[[/^cke:/,""],[/^\?xml:namespace$/,""]],attributeNames:[[/^data-cke-(saved|pa)-/,""],[/^data-cke-.*/, -""],["hidefocus",""]],elements:{$:function(a){var b=a.attributes;if(b){if(b["data-cke-temp"])return!1;for(var c=["name","href","src"],d,e=0;ed?1:-1})},param:function(a){a.children= +!0)},null,null,10);b.on("toDataFormat",function(a){a.data.filter.applyTo(a.data.dataValue,!1,!0)},null,null,11);b.on("toDataFormat",function(a){var c=a.data.dataValue,e=f.writer;e.reset();c.writeChildrenHtml(e);c=e.getHtml(!0);c=z(c);c=G(c,b);a.data.dataValue=c},null,null,15)};CKEDITOR.htmlDataProcessor.prototype={toHtml:function(a,b,c,e){var d=this.editor,f,g,t,r;b&&"object"==typeof b?(f=b.context,c=b.fixForBody,e=b.dontFilter,g=b.filter,t=b.enterMode,r=b.protectedWhitespaces):f=b;f||null===f||(f= +d.editable().getName());return d.fire("toHtml",{dataValue:a,context:f,fixForBody:c,dontFilter:e,filter:g||d.filter,enterMode:t||d.enterMode,protectedWhitespaces:r}).dataValue},toDataFormat:function(a,b){var c,e,d;b&&(c=b.context,e=b.filter,d=b.enterMode);c||null===c||(c=this.editor.editable().getName());return this.editor.fire("toDataFormat",{dataValue:a,filter:e||this.editor.filter,context:c,enterMode:d||this.editor.enterMode}).dataValue},protectSource:function(a){return v(a,this.editor)},unprotectSource:function(a){return G(a, +this.editor)},unprotectRealComments:function(a){return z(a)}};var M=/(?: |\xa0)$/,w="{cke_protected}",J=CKEDITOR.dtd,F="caption colgroup col thead tfoot tbody".split(" "),q=CKEDITOR.tools.extend({},J.$blockLimit,J.$block),u={elements:{input:h,textarea:h}},K={attributeNames:[[/^on/,"data-cke-pa-on"],[/^srcdoc/,"data-cke-pa-srcdoc"],[/^data-cke-expando$/,""]],elements:{iframe:function(a){if(a.attributes&&a.attributes.src){var b=a.attributes.src.toLowerCase().replace(/[^a-z]/gi,"");if(0===b.indexOf("javascript")|| +0===b.indexOf("data"))a.attributes["data-cke-pa-src"]=a.attributes.src,delete a.attributes.src}}}},D={elements:{embed:function(a){var b=a.parent;if(b&&"object"==b.name){var c=b.attributes.width,b=b.attributes.height;c&&(a.attributes.width=c);b&&(a.attributes.height=b)}},a:function(a){var b=a.attributes;if(!(a.children.length||b.name||b.id||a.attributes["data-cke-saved-name"]))return!1}}},B={elementNames:[[/^cke:/,""],[/^\?xml:namespace$/,""]],attributeNames:[[/^data-cke-(saved|pa)-/,""],[/^data-cke-.*/, +""],["hidefocus",""]],elements:{$:function(a){var b=a.attributes;if(b){if(b["data-cke-temp"])return!1;for(var c=["name","href","src"],e,d=0;de?1:-1})},param:function(a){a.children= [];a.isEmpty=!0;return a},span:function(a){"Apple-style-span"==a.attributes["class"]&&delete a.name},html:function(a){delete a.attributes.contenteditable;delete a.attributes["class"]},body:function(a){delete a.attributes.spellcheck;delete a.attributes.contenteditable},style:function(a){var b=a.children[0];b&&b.value&&(b.value=CKEDITOR.tools.trim(b.value));a.attributes.type||(a.attributes.type="text/css")},title:function(a){var b=a.children[0];!b&&k(a,b=new CKEDITOR.htmlParser.text);b.value=a.attributes["data-cke-title"]|| -""},input:l,textarea:l},attributes:{"class":function(a){return CKEDITOR.tools.ltrim(a.replace(/(?:^|\s+)cke_[^\s]*/g,""))||!1}}};CKEDITOR.env.ie&&(K.attributes.style=function(a){return a.replace(/(^|;)([^\:]+)/g,function(a){return a.toLowerCase()})});var p=/<(a|area|img|input|source)\b([^>]*)>/gi,D=/([\w-:]+)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+))/gi,B=/^(href|src|name)$/i,G=/(?:])[^>]*>[\s\S]*?<\/style>)|(?:<(:?link|meta|base)[^>]*>)/gi,T=/(])[^>]*>)([\s\S]*?)(?:<\/textarea>)/gi, -O=/([^<]*)<\/cke:encoded>/gi,q=/(<\/?)((?:object|embed|param|html|body|head|title)([\s][^>]*)?>)/gi,I=/(<\/?)cke:((?:html|body|head|title)[^>]*>)/gi,N=/]*?)\/?>(?!\s*<\/cke:\1)/gi;m=function(){function a(b,c){for(var d=0;d/g];return function(b){for(;a(d,b);)for(var c=d,e=0;e]*)>/gi,H=/([\w-:]+)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+))/gi,A=/^(href|src|name)$/i,I=/(?:])[^>]*>[\s\S]*?<\/style>)|(?:<(:?link|meta|base)[^>]*>)/gi,N=/(])[^>]*>)([\s\S]*?)(?:<\/textarea>)/gi, +L=/([^<]*)<\/cke:encoded>/gi,r=/(<\/?)((?:object|embed|param|html|body|head|title)([\s][^>]*)?>)/gi,E=/(<\/?)cke:((?:html|body|head|title)[^>]*>)/gi,S=/]*?)\/?>(?!\s*<\/cke:\1)/gi;m=function(){function a(b,c){for(var e=0;e/g];return function(b){for(;a(e,b);)for(var c=e,d=0;db?1:0},b=CKEDITOR.htmlParser.fragment.prototype;CKEDITOR.htmlParser.element.prototype=CKEDITOR.tools.extend(new CKEDITOR.htmlParser.node,{type:CKEDITOR.NODE_ELEMENT,add:b.add,clone:function(){return new CKEDITOR.htmlParser.element(this.name,this.attributes)},filter:function(a,b){var d=this,k,h;b=d.getFilterContext(b);if(!d.parent)a.onRoot(b, -d);for(;;){k=d.name;if(!(h=a.onElementName(b,k)))return this.remove(),!1;d.name=h;if(!(d=a.onElement(b,d)))return this.remove(),!1;if(d!==this)return this.replaceWith(d),!1;if(d.name==k)break;if(d.type!=CKEDITOR.NODE_ELEMENT)return this.replaceWith(d),!1;if(!d.name)return this.replaceWithChildren(),!1}k=d.attributes;var l,r;for(l in k){for(h=k[l];;)if(r=a.onAttributeName(b,l))if(r!=l)delete k[l],l=r;else break;else{delete k[l];break}r&&(!1===(h=a.onAttribute(b,d,r,h))?delete k[r]:k[r]=h)}d.isEmpty|| -this.filterChildren(a,!1,b);return!0},filterChildren:b.filterChildren,writeHtml:function(a,b){b&&this.filter(b);var e=this.name,k=[],h=this.attributes,l,r;a.openTag(e,h);for(l in h)k.push([l,h[l]]);a.sortAttributes&&k.sort(d);l=0;for(r=k.length;lb?1:0},b=CKEDITOR.htmlParser.fragment.prototype;CKEDITOR.htmlParser.element.prototype=CKEDITOR.tools.extend(new CKEDITOR.htmlParser.node,{type:CKEDITOR.NODE_ELEMENT,add:b.add,clone:function(){return new CKEDITOR.htmlParser.element(this.name,this.attributes)},filter:function(a,b){var e=this,d,h;b=e.getFilterContext(b);if(!e.parent)a.onRoot(b, +e);for(;;){d=e.name;if(!(h=a.onElementName(b,d)))return this.remove(),!1;e.name=h;if(!(e=a.onElement(b,e)))return this.remove(),!1;if(e!==this)return this.replaceWith(e),!1;if(e.name==d)break;if(e.type!=CKEDITOR.NODE_ELEMENT)return this.replaceWith(e),!1;if(!e.name)return this.replaceWithChildren(),!1}d=e.attributes;var n,l;for(n in d){for(h=d[n];;)if(l=a.onAttributeName(b,n))if(l!=n)delete d[n],n=l;else break;else{delete d[n];break}l&&(!1===(h=a.onAttribute(b,e,l,h))?delete d[l]:d[l]=h)}e.isEmpty|| +this.filterChildren(a,!1,b);return!0},filterChildren:b.filterChildren,writeHtml:function(a,b){b&&this.filter(b);var e=this.name,k=[],h=this.attributes,n,l;a.openTag(e,h);for(n in h)k.push([n,h[n]]);a.sortAttributes&&k.sort(d);n=0;for(l=k.length;ne.secure.minor||e.current.minor===e.secure.minor&& +e.current.patch>=e.secure.patch?!0:!1;a()}};b.open("GET",c);b.responseType="text";b.send()}catch(f){}}function d(a){var c=a.match(b);return c?{original:a,major:4,minor:Number(c[1]),patch:Number(c[2]),isLts:!!c[3]}:null}var b=/^4\.(\d+)\.(\d+)(-lts)?(?: \(?.+?\)?)?$/,c="Drupal"in window,f=!1,e={current:d(CKEDITOR.version)};!c&&e.current&&(CKEDITOR.config.versionCheck=e.current.isLts?!1:!0,CKEDITOR.on("instanceReady",function(b){var c=b.editor;c.config.versionCheck&&(c.on("dialogShow",function(b){var d= +b.data;"about"===d._.name&&a(function(){var a=d.getElement().findOne(".cke_about_version-check"),b;b=c.lang.versionCheck;var f="";e.isLatest||(f=b.aboutDialogUpgradeMessage);e.isSecure||(f=b.aboutDialogInsecureMessage);b=f.replace("%current",e.current.original).replace("%latest",e.latest.original).replace(/%link/g,"https://ckeditor.com/ckeditor-4-support/");a.setHtml("");c.config.versionCheck&&(a.setStyle("color",e.isSecure?"":"#C83939"),a.setHtml(b))})}),a(function(){if(!e.isSecure){var a=c.lang.versionCheck.notificationMessage.replace("%current", +e.current.original).replace("%latest",e.latest.original).replace(/%link/g,"https://ckeditor.com/ckeditor-4-support/"),b="notification"in c.plugins;if(window.console&&window.console.error&&!f){f=!0;var d=c.lang.versionCheck.consoleMessage.replace("%current",e.current.original).replace("%latest",e.latest.original).replace(/%link/g,"https://ckeditor.com/ckeditor-4-support/");console.error(d)}b&&c.showNotification(a,"warning")}}))}))})();delete CKEDITOR.loadFullCore;CKEDITOR.instances={}; +CKEDITOR.document=new CKEDITOR.dom.document(document);CKEDITOR.add=function(a){function d(){CKEDITOR.currentInstance==a&&(CKEDITOR.currentInstance=null,CKEDITOR.fire("currentInstance"))}CKEDITOR.instances[a.name]=a;a.on("focus",function(){CKEDITOR.currentInstance!=a&&(CKEDITOR.currentInstance=a,CKEDITOR.fire("currentInstance"))});a.on("blur",d);a.on("destroy",d);CKEDITOR.fire("instance",null,a)};CKEDITOR.remove=function(a){delete CKEDITOR.instances[a.name]}; (function(){var a={};CKEDITOR.addTemplate=function(d,b){var c=a[d];if(c)return c;c={name:d,source:b};CKEDITOR.fire("template",c);return a[d]=new CKEDITOR.template(c.source)};CKEDITOR.getTemplate=function(d){return a[d]}})();(function(){var a=[];CKEDITOR.addCss=function(d){a.push(d)};CKEDITOR.getCss=function(){return a.join("\n")}})();CKEDITOR.on("instanceDestroyed",function(){CKEDITOR.tools.isEmpty(this.instances)&&CKEDITOR.fire("reset")});CKEDITOR.TRISTATE_ON=1;CKEDITOR.TRISTATE_OFF=2; CKEDITOR.TRISTATE_DISABLED=0; -(function(){CKEDITOR.inline=function(a,d){a=CKEDITOR.editor._getEditorElement(a);if(!a)return null;if(CKEDITOR.editor.shouldDelayEditorCreation(a,d))return CKEDITOR.editor.initializeDelayedEditorCreation(a,d,"inline"),null;var b=a.is("textarea")?a:null,c=b?b.getValue():a.getHtml(),f=new CKEDITOR.editor(d,a,CKEDITOR.ELEMENT_MODE_INLINE);b?(f.setData(c,null,!0),a=CKEDITOR.dom.element.createFromHtml('\x3cdiv contenteditable\x3d"'+!!f.readOnly+'" class\x3d"cke_textarea_inline"\x3e'+b.getValue()+"\x3c/div\x3e", +(function(){CKEDITOR.inline=function(a,d){a=CKEDITOR.editor._getEditorElement(a);if(!a)return null;if(CKEDITOR.editor.shouldDelayEditorCreation(a,d))return CKEDITOR.editor.initializeDelayedEditorCreation(a,d,"inline");var b=a.is("textarea")?a:null,c=b?b.getValue():a.getHtml(),f=new CKEDITOR.editor(d,a,CKEDITOR.ELEMENT_MODE_INLINE);b?(f.setData(c,null,!0),a=CKEDITOR.dom.element.createFromHtml('\x3cdiv contenteditable\x3d"'+!!f.readOnly+'" class\x3d"cke_textarea_inline"\x3e'+b.getValue()+"\x3c/div\x3e", CKEDITOR.document),a.insertAfter(b),b.hide(),b.$.form&&f._attachToForm()):(d&&"undefined"!==typeof d.readOnly&&!d.readOnly&&a.setAttribute("contenteditable","true"),f.setData(c,null,!0));f.on("loaded",function(){f.fire("uiReady");f.editable(a);f.container=a;f.ui.contentsElement=a;f.setData(f.getData(1));f.resetDirty();f.fire("contentDom");f.mode="wysiwyg";f.fire("mode");f.status="ready";f.fireOnce("instanceReady");CKEDITOR.fire("instanceReady",null,f)},null,null,1E4);f.on("destroy",function(){var a= f.container;b&&a&&(a.clearCustomData(),a.remove());b&&b.show();f.element.clearCustomData();delete f.element});return f};CKEDITOR.inlineAll=function(){var a,d,b;for(b in CKEDITOR.dtd.$editable)for(var c=CKEDITOR.document.getElementsByTag(b),f=0,e=c.count();fCKEDITOR.env.version||CKEDITOR.env.quirks))this.hasFocus&&(this.focus(),b());else if(this.hasFocus)this.focus(),a();else this.once("focus", -function(){a()},null,null,-999)},getHtmlFromRange:function(a){if(a.collapsed)return new CKEDITOR.dom.documentFragment(a.document);a={doc:this.getDocument(),range:a.clone()};u.eol.detect(a,this);u.bogus.exclude(a);u.cell.shrink(a);a.fragment=a.range.cloneContents();u.tree.rebuild(a,this);u.eol.fix(a,this);return new CKEDITOR.dom.documentFragment(a.fragment.$)},extractHtmlFromRange:function(a,b){var c=F,d={range:a,doc:a.document},e=this.getHtmlFromRange(a);if(a.collapsed)return a.optimize(),e;a.enlarge(CKEDITOR.ENLARGE_INLINE, -1);c.table.detectPurge(d);d.bookmark=a.createBookmark();delete d.range;var g=this.editor.createRange();g.moveToPosition(d.bookmark.startNode,CKEDITOR.POSITION_BEFORE_START);d.targetBookmark=g.createBookmark();c.list.detectMerge(d,this);c.table.detectRanges(d,this);c.block.detectMerge(d,this);d.tableContentsRanges?(c.table.deleteRanges(d),a.moveToBookmark(d.bookmark),d.range=a):(a.moveToBookmark(d.bookmark),d.range=a,a.extractContents(c.detectExtractMerge(d)));a.moveToBookmark(d.targetBookmark);a.optimize(); -c.fixUneditableRangePosition(a);c.list.merge(d,this);c.table.purge(d,this);c.block.merge(d,this);if(b){c=a.startPath();if(d=a.checkStartOfBlock()&&a.checkEndOfBlock()&&c.block&&!a.root.equals(c.block)){a:{var d=c.block.getElementsByTag("span"),g=0,f;if(d)for(;f=d.getItem(g++);)if(!A(f)){d=!0;break a}d=!1}d=!d}d&&(a.moveToPosition(c.block,CKEDITOR.POSITION_BEFORE_START),c.block.remove())}else c.autoParagraph(this.editor,a),t(a.startContainer)&&a.startContainer.appendBogus();a.startContainer.mergeSiblings(); +g||e==CKEDITOR.ENTER_BR||(g=b.fixBlock(!0,e==CKEDITOR.ENTER_DIV?"div":"p"),b.moveToElementEditStart(g))));d.selectRanges([b]);x(this)},insertElementIntoSelection:function(a){this.insertElement(a)},insertElementIntoRange:function(a,b){var c=this.editor,d=c.config.enterMode,e=a.getName(),f=CKEDITOR.dtd.$block[e];if(b.checkReadOnly())return!1;b.deleteContents(1);b.startContainer.type==CKEDITOR.NODE_ELEMENT&&(b.startContainer.is({tr:1,table:1,tbody:1,thead:1,tfoot:1})?J(b):b.startContainer.is(CKEDITOR.dtd.$list)&& +F(b));var h,k;if(f)for(;(h=b.getCommonAncestor(0,1))&&(k=CKEDITOR.dtd[h.getName()])&&(!k||!k[e]);)if(h.getName()in CKEDITOR.dtd.span){var f=b.splitElement(h),r=b.createBookmark();g(h);g(f);b.moveToBookmark(r)}else b.checkStartOfBlock()&&b.checkEndOfBlock()?(b.setStartBefore(h),b.collapse(!0),h.remove()):b.splitBlock(d==CKEDITOR.ENTER_DIV?"div":"p",c.editable());b.insertNode(a);return!0},setData:function(a,b){b||(a=this.editor.dataProcessor.toHtml(a));this.setHtml(a);this.fixInitialSelection();"unloaded"== +this.status&&(this.status="ready");this.editor.fire("dataReady")},getData:function(a){var b=this.getHtml();a||(b=this.editor.dataProcessor.toDataFormat(b));return b},setReadOnly:function(a){this.setAttribute("contenteditable",String(!a));this.setAttribute("aria-readonly",String(a))},detach:function(){this.status="detached";this.editor.setData(this.editor.getData(),{internal:!0});this.clearListeners();try{this._.cleanCustomData()}catch(a){if(!CKEDITOR.env.ie||-2146828218!==a.number)throw a;}this.editor.fire("contentDomUnload"); +delete this.editor.document;delete this.editor.window;delete this.editor},isInline:function(){return this.getDocument().equals(CKEDITOR.document)},fixInitialSelection:function(){function a(){var b=c.getDocument().$,d=b.getSelection(),e;a:if(d.anchorNode&&d.anchorNode==c.$)e=!0;else{if(CKEDITOR.env.webkit&&(e=c.getDocument().getActive())&&e.equals(c)&&!d.anchorNode){e=!0;break a}e=void 0}e&&(e=new CKEDITOR.dom.range(c),e.moveToElementEditStart(c),b=b.createRange(),b.setStart(e.startContainer.$,e.startOffset), +b.collapse(!0),d.removeAllRanges(),d.addRange(b))}function b(){var a=c.getDocument().$,d=a.selection,e=c.getDocument().getActive();"None"==d.type&&e.equals(c)&&(d=new CKEDITOR.dom.range(c),a=a.body.createTextRange(),d.moveToElementEditStart(c),d=d.startContainer,d.type!=CKEDITOR.NODE_ELEMENT&&(d=d.getParent()),a.moveToElementText(d.$),a.collapse(!0),a.select())}var c=this;if(CKEDITOR.env.ie&&(9>CKEDITOR.env.version||CKEDITOR.env.quirks))this.hasFocus&&(this.focus(),b());else if(this.hasFocus)this.focus(), +a();else this.once("focus",function(){a()},null,null,-999)},getHtmlFromRange:function(a){if(a.collapsed)return new CKEDITOR.dom.documentFragment(a.document);a={doc:this.getDocument(),range:a.clone()};q.eol.detect(a,this);q.bogus.exclude(a);q.cell.shrink(a);a.fragment=a.range.cloneContents();q.tree.rebuild(a,this);q.eol.fix(a,this);return new CKEDITOR.dom.documentFragment(a.fragment.$)},extractHtmlFromRange:function(a,b){var c=u,d={range:a,doc:a.document},e=this.getHtmlFromRange(a);if(a.collapsed)return a.optimize(), +e;a.enlarge(CKEDITOR.ENLARGE_INLINE,1);c.table.detectPurge(d);d.bookmark=a.createBookmark();delete d.range;var g=this.editor.createRange();g.moveToPosition(d.bookmark.startNode,CKEDITOR.POSITION_BEFORE_START);d.targetBookmark=g.createBookmark();c.list.detectMerge(d,this);c.table.detectRanges(d,this);c.block.detectMerge(d,this);d.tableContentsRanges?(c.table.deleteRanges(d),a.moveToBookmark(d.bookmark),d.range=a):(a.moveToBookmark(d.bookmark),d.range=a,a.extractContents(c.detectExtractMerge(d)));a.moveToBookmark(d.targetBookmark); +a.optimize();c.fixUneditableRangePosition(a);c.list.merge(d,this);c.table.purge(d,this);c.block.merge(d,this);if(b){c=a.startPath();if(d=a.checkStartOfBlock()&&a.checkEndOfBlock()&&c.block&&!a.root.equals(c.block)){a:{var d=c.block.getElementsByTag("span"),g=0,f;if(d)for(;f=d.getItem(g++);)if(!G(f)){d=!0;break a}d=!1}d=!d}d&&(a.moveToPosition(c.block,CKEDITOR.POSITION_BEFORE_START),c.block.remove())}else c.autoParagraph(this.editor,a),v(a.startContainer)&&a.startContainer.appendBogus();a.startContainer.mergeSiblings(); return e},setup:function(){var a=this.editor;this.attachListener(a,"beforeGetData",function(){var b=this.getData();this.is("textarea")||!1!==a.config.ignoreEmptyParagraph&&(b=b.replace(M,function(a,b){return b}));a.setData(b,null,1)},this);this.attachListener(a,"getSnapshot",function(a){a.data=this.getData(1)},this);this.attachListener(a,"afterSetData",function(){this.setData(a.getData(1))},this);this.attachListener(a,"loadSnapshot",function(a){this.setData(a.data,1)},this);this.attachListener(a, "beforeFocus",function(){var b=a.getSelection();(b=b&&b.getNative())&&"Control"==b.type||this.focus()},this);this.attachListener(a,"insertHtml",function(a){this.insertHtml(a.data.dataValue,a.data.mode,a.data.range)},this);this.attachListener(a,"insertElement",function(a){this.insertElement(a.data)},this);this.attachListener(a,"insertText",function(a){this.insertText(a.data)},this);this.setReadOnly(a.readOnly);this.attachClass("cke_editable");a.elementMode==CKEDITOR.ELEMENT_MODE_INLINE?this.attachClass("cke_editable_inline"): a.elementMode!=CKEDITOR.ELEMENT_MODE_REPLACE&&a.elementMode!=CKEDITOR.ELEMENT_MODE_APPENDTO||this.attachClass("cke_editable_themed");this.attachClass("cke_contents_"+a.config.contentsLangDirection);a.keystrokeHandler.blockedKeystrokes[8]=+a.readOnly;a.keystrokeHandler.attach(this);this.on("blur",function(){this.hasFocus=!1},null,null,-1);this.on("focus",function(){this.hasFocus=!0},null,null,-1);if(CKEDITOR.env.webkit)this.on("scroll",function(){a._.previousScrollTop=a.editable().$.scrollTop},null, null,-1);if(CKEDITOR.env.edge&&14CKEDITOR.env.version?G.$.styleSheet.cssText=B:G.setText(B)):(B=g.appendStyleText(B),B=new CKEDITOR.dom.element(B.ownerNode||B.owningElement),f.setCustomData("stylesheet", -B),B.data("cke-temp",1))}f=g.getCustomData("stylesheet_ref")||0;g.setCustomData("stylesheet_ref",f+1);this.setCustomData("cke_includeReadonly",!a.config.disableReadonlyStyling);this.attachListener(this,"click",function(a){a=a.data;var b=(new CKEDITOR.dom.elementPath(a.getTarget(),this)).contains("a");b&&2!=a.$.button&&b.isReadOnly()&&a.preventDefault()});var l={8:1,46:1};this.attachListener(a,"key",function(b){if(a.readOnly)return!0;var c=b.data.domEvent.getKey(),d,g=a.getSelection();if(0!==g.getRanges().length){if(c in -l){var f;b=g.getRanges()[0];var p=b.startPath(),B,D,G,c=8==c,r=!1;if(CKEDITOR.env.ie&&11>CKEDITOR.env.version&&g.getSelectedElement())f=g.getSelectedElement();else if(e(g)){var m=new CKEDITOR.dom.walker(b),w=b.collapsed?b.startContainer:m.next(),r=!1,K;if(b.checkStartOfBlock()){K=b.startPath().block||b.startPath().blockLimit;var t=K.getName();K=-1!==CKEDITOR.tools.array.indexOf(["dd","dt","li"],t)&&null===K.getPrevious()}else K=!1;if(K){for(;w&&!r;)r=w.$.nodeName.toLowerCase(),r=!!H[r],w=m.next(); -m=h(b.startPath());w=h(b.endPath());r=r||m!==w}else r=void 0;r||(f=k(g))}f||r?(a.fire("saveSnapshot"),r?((d=b.startContainer.getAscendant(H,!0))?(b.setStart(d,0),b.enlarge(CKEDITOR.ENLARGE_ELEMENT),f=b):f=null,f.deleteContents()):(b.moveToPosition(f,CKEDITOR.POSITION_BEFORE_START),f.remove()),b.select(),a.fire("saveSnapshot"),d=1):b.collapsed&&((B=p.block)&&(G=B[c?"getPrevious":"getNext"](z))&&G.type==CKEDITOR.NODE_ELEMENT&&G.is("table")&&b[c?"checkStartOfBlock":"checkEndOfBlock"]()?(a.fire("saveSnapshot"), -b[c?"checkEndOfBlock":"checkStartOfBlock"]()&&B.remove(),b["moveToElementEdit"+(c?"End":"Start")](G),b.select(),a.fire("saveSnapshot"),d=1):p.blockLimit&&p.blockLimit.is("td")&&(D=p.blockLimit.getAscendant("table"))&&b.checkBoundaryOfElement(D,c?CKEDITOR.START:CKEDITOR.END)&&(G=D[c?"getPrevious":"getNext"](z))?(a.fire("saveSnapshot"),b["moveToElementEdit"+(c?"End":"Start")](G),b.checkStartOfBlock()&&b.checkEndOfBlock()?G.remove():b.select(),a.fire("saveSnapshot"),d=1):(D=p.contains(["td","th","caption"]))&& -b.checkBoundaryOfElement(D,c?CKEDITOR.START:CKEDITOR.END)&&(d=1))}return!d}});a.blockless&&CKEDITOR.env.ie&&CKEDITOR.env.needsBrFiller&&this.attachListener(this,"keyup",function(b){b.data.getKeystroke()in l&&!this.getFirst(c)&&(this.appendBogus(),b=a.createRange(),b.moveToPosition(this,CKEDITOR.POSITION_AFTER_START),b.select())});this.attachListener(this,"dblclick",function(b){if(a.readOnly)return!1;b={element:b.data.getTarget()};a.fire("doubleclick",b)});CKEDITOR.env.ie&&this.attachListener(this, +this.getDocument();a.window=this.getWindow();var g=a.document;this.changeAttr("spellcheck",!a.config.disableNativeSpellChecker);var f=a.config.contentsLangDirection;this.getDirection(1)!=f&&this.changeAttr("dir",f);var A=CKEDITOR.getCss();if(A){var f=g.getHead(),I=f.getCustomData("stylesheet");I?A!=I.getText()&&(CKEDITOR.env.ie&&9>CKEDITOR.env.version?I.$.styleSheet.cssText=A:I.setText(A)):(A=g.appendStyleText(A),A=new CKEDITOR.dom.element(A.ownerNode||A.owningElement),f.setCustomData("stylesheet", +A),A.data("cke-temp",1))}f=g.getCustomData("stylesheet_ref")||0;g.setCustomData("stylesheet_ref",f+1);this.setCustomData("cke_includeReadonly",!a.config.disableReadonlyStyling);this.attachListener(this,"click",function(a){a=a.data;var b=(new CKEDITOR.dom.elementPath(a.getTarget(),this)).contains("a");b&&2!=a.$.button&&b.isReadOnly()&&a.preventDefault()});var N={8:1,46:1};this.attachListener(a,"key",function(b){if(a.readOnly)return!0;var c=b.data.domEvent.getKey(),d,g=a.getSelection();if(0!==g.getRanges().length){if(c in +N){var f;b=g.getRanges()[0];var t=b.startPath(),A,H,I,c=8==c,l=!1;if(CKEDITOR.env.ie&&11>CKEDITOR.env.version&&g.getSelectedElement())f=g.getSelectedElement();else if(e(g)){var n=new CKEDITOR.dom.walker(b),m=b.collapsed?b.startContainer:n.next(),l=!1,B;if(b.checkStartOfBlock()){B=b.startPath().block||b.startPath().blockLimit;var q=B.getName();B=-1!==CKEDITOR.tools.array.indexOf(["dd","dt","li"],q)&&null===B.getPrevious()}else B=!1;if(B){for(;m&&!l;)l=m.$.nodeName.toLowerCase(),l=!!K[l],m=n.next(); +n=h(b.startPath());m=h(b.endPath());l=l||n!==m}else l=void 0;l||(f=k(g))}f||l?(a.fire("saveSnapshot"),l?((d=b.startContainer.getAscendant(K,!0))?(b.setStart(d,0),b.enlarge(CKEDITOR.ENLARGE_ELEMENT),f=b):f=null,f.deleteContents()):(b.moveToPosition(f,CKEDITOR.POSITION_BEFORE_START),f.remove()),b.select(),a.fire("saveSnapshot"),d=1):b.collapsed&&((A=t.block)&&(I=A[c?"getPrevious":"getNext"](z))&&I.type==CKEDITOR.NODE_ELEMENT&&I.is("table")&&b[c?"checkStartOfBlock":"checkEndOfBlock"]()?(a.fire("saveSnapshot"), +b[c?"checkEndOfBlock":"checkStartOfBlock"]()&&A.remove(),b["moveToElementEdit"+(c?"End":"Start")](I),b.select(),a.fire("saveSnapshot"),d=1):t.blockLimit&&t.blockLimit.is("td")&&(H=t.blockLimit.getAscendant("table"))&&b.checkBoundaryOfElement(H,c?CKEDITOR.START:CKEDITOR.END)&&(I=H[c?"getPrevious":"getNext"](z))?(a.fire("saveSnapshot"),b["moveToElementEdit"+(c?"End":"Start")](I),b.checkStartOfBlock()&&b.checkEndOfBlock()?I.remove():b.select(),a.fire("saveSnapshot"),d=1):(H=t.contains(["td","th","caption"]))&& +b.checkBoundaryOfElement(H,c?CKEDITOR.START:CKEDITOR.END)&&(d=1))}return!d}});a.blockless&&CKEDITOR.env.ie&&CKEDITOR.env.needsBrFiller&&this.attachListener(this,"keyup",function(b){b.data.getKeystroke()in N&&!this.getFirst(c)&&(this.appendBogus(),b=a.createRange(),b.moveToPosition(this,CKEDITOR.POSITION_AFTER_START),b.select())});this.attachListener(this,"dblclick",function(b){if(a.readOnly)return!1;b={element:b.data.getTarget()};a.fire("doubleclick",b)});CKEDITOR.env.ie&&this.attachListener(this, "click",b);CKEDITOR.env.ie&&!CKEDITOR.env.edge||this.attachListener(this,"mousedown",function(b){var c=b.data.getTarget();c.is("img","hr","input","textarea","select")&&!c.isReadOnly()&&(a.getSelection().selectElement(c),c.is("input","textarea","select")&&b.data.preventDefault())});CKEDITOR.env.edge&&this.attachListener(this,"mouseup",function(b){(b=b.data.getTarget())&&b.is("img")&&!b.isReadOnly()&&a.getSelection().selectElement(b)});CKEDITOR.env.gecko&&this.attachListener(this,"mouseup",function(b){if(2== b.data.$.button&&(b=b.data.getTarget(),!b.getAscendant("table")&&!b.getOuterHtml().replace(M,""))){var c=a.createRange();c.moveToElementEditStart(b);c.select(!0)}});CKEDITOR.env.webkit&&(this.attachListener(this,"click",function(a){a.data.getTarget().is("input","select")&&a.data.preventDefault()}),this.attachListener(this,"mouseup",function(a){a.data.getTarget().is("input","textarea")&&a.data.preventDefault()}));CKEDITOR.env.webkit&&this.attachListener(a,"key",function(b){if(a.readOnly)return!0;var c= -b.data.domEvent.getKey();if(c in l&&(b=a.getSelection(),0!==b.getRanges().length)){var c=8==c,d=b.getRanges()[0];b=d.startPath();if(d.collapsed)a:{var e=b.block;if(e&&d[c?"checkStartOfBlock":"checkEndOfBlock"](!0)&&d.moveToClosestEditablePosition(e,!c)&&d.collapsed){if(d.startContainer.type==CKEDITOR.NODE_ELEMENT){var g=d.startContainer.getChild(d.startOffset-(c?1:0));if(g&&g.type==CKEDITOR.NODE_ELEMENT&&g.is("hr")){a.fire("saveSnapshot");g.remove();b=!0;break a}}d=d.startPath().block;if(!d||d&&d.contains(e))b= +b.data.domEvent.getKey();if(c in N&&(b=a.getSelection(),0!==b.getRanges().length)){var c=8==c,d=b.getRanges()[0];b=d.startPath();if(d.collapsed)a:{var e=b.block;if(e&&d[c?"checkStartOfBlock":"checkEndOfBlock"](!0)&&d.moveToClosestEditablePosition(e,!c)&&d.collapsed){if(d.startContainer.type==CKEDITOR.NODE_ELEMENT){var g=d.startContainer.getChild(d.startOffset-(c?1:0));if(g&&g.type==CKEDITOR.NODE_ELEMENT&&g.is("hr")){a.fire("saveSnapshot");g.remove();b=!0;break a}}d=d.startPath().block;if(!d||d&&d.contains(e))b= void 0;else{a.fire("saveSnapshot");var f;(f=(c?d:e).getBogus())&&f.remove();f=a.getSelection();g=f.createBookmarks();(c?e:d).moveChildren(c?d:e,!1);b.lastElement.mergeSiblings();y(e,d,!c);f.selectBookmarks(g);b=!0}}else b=!1}else c=d,f=b.block,d=c.endPath().block,f&&d&&!f.equals(d)?(a.fire("saveSnapshot"),(e=f.getBogus())&&e.remove(),c.enlarge(CKEDITOR.ENLARGE_INLINE),c.deleteContents(),d.getParent()&&(d.moveChildren(f,!1),b.lastElement.mergeSiblings(),y(f,d,!0)),c=a.getSelection().getRanges()[0], c.collapse(1),c.optimize(),""===c.startContainer.getHtml()&&c.startContainer.appendBogus(),c.select(),b=!0):b=!1;if(!b)return;a.getSelection().scrollIntoView();a.fire("saveSnapshot");return!1}},this,null,100)}},getUniqueId:function(){var a;try{this._.expandoNumber=a=CKEDITOR.dom.domObject.prototype.getUniqueId.call(this)}catch(b){a=this._&&this._.expandoNumber}return a}},_:{cleanCustomData:function(){this.removeClass("cke_editable");this.restoreAttrs();for(var a=this.removeCustomData("classes");a&& a.length;)this.removeClass(a.pop());if(!this.is("textarea")){var a=this.getDocument(),b=a.getHead();if(b.getCustomData("stylesheet")){var c=a.getCustomData("stylesheet_ref");--c?a.setCustomData("stylesheet_ref",c):(a.removeCustomData("stylesheet_ref"),b.removeCustomData("stylesheet").remove())}}}}});CKEDITOR.editor.prototype.editable=function(a){var b=this._.editable;if(b&&a)return 0;if(!arguments.length)return b;a?b=a instanceof CKEDITOR.editable?a:new CKEDITOR.editable(this,a):(b&&b.detach(),b= null);return this._.editable=b};CKEDITOR.on("instanceLoaded",function(b){var c=b.editor;c.on("insertElement",function(a){a=a.data;a.type==CKEDITOR.NODE_ELEMENT&&(a.is("input")||a.is("textarea"))&&("false"!=a.getAttribute("contentEditable")&&a.data("cke-editable",a.hasAttribute("contenteditable")?"true":"1"),a.setAttribute("contentEditable",!1))});c.on("selectionChange",function(b){if(!c.readOnly){var d=c.getSelection();d&&!d.isLocked&&(d=c.checkDirty(),c.fire("lockSnapshot"),a(b),c.fire("unlockSnapshot"), -!d&&c.resetDirty())}})});CKEDITOR.on("instanceCreated",function(a){var b=a.editor;b.on("mode",function(){var a=b.editable();if(a&&a.isInline()){var c=b.title;a.changeAttr("role","textbox");a.changeAttr("aria-multiline","true");a.changeAttr("aria-label",c);c&&a.changeAttr("title",c);var d=b.fire("ariaEditorHelpLabel",{}).label;if(d&&(c=this.ui.space(this.elementMode==CKEDITOR.ELEMENT_MODE_INLINE?"top":"contents"))){var e=CKEDITOR.tools.getNextId(),d=CKEDITOR.dom.element.createFromHtml('\x3cspan id\x3d"'+ -e+'" class\x3d"cke_voice_label"\x3e'+d+"\x3c/span\x3e");c.append(d);a.changeAttr("aria-describedby",e)}}})});CKEDITOR.addCss(".cke_editable{cursor:text}.cke_editable img,.cke_editable input,.cke_editable textarea{cursor:default}");z=CKEDITOR.dom.walker.whitespaces(!0);A=CKEDITOR.dom.walker.bookmark(!1,!0);t=CKEDITOR.dom.walker.empty();m=CKEDITOR.dom.walker.bogus();M=/(^|]*>)\s*<(p|div|address|h\d|center|pre)[^>]*>\s*(?:]*>| |\u00A0| )?\s*(:?<\/\2>)?\s*(?=$|<\/body>)/gi;v= -function(){function a(b){return b.type==CKEDITOR.NODE_ELEMENT}function b(c,d){var e,g,f,q,h=[],p=d.range.startContainer;e=d.range.startPath();for(var p=m[p.getName()],k=0,B=c.getChildren(),D=B.count(),G=-1,l=-1,I=0,N=e.contains(m.$list);k]*>)\s*<(p|div|address|h\d|center|pre)[^>]*>\s*(?:]*>| |\u00A0| )?\s*(:?<\/\2>)?\s*(?=$|<\/body>)/gi;w= +function(){function a(b){return b.type==CKEDITOR.NODE_ELEMENT}function b(c,d){var e,g,f,r,h=[],t=d.range.startContainer;e=d.range.startPath();for(var t=L[t.getName()],k=0,A=c.getChildren(),H=A.count(),I=-1,E=-1,S=0,N=e.contains(L.$list);kCKEDITOR.env.version&&d.getChildCount()&&d.getFirst().remove())}return function(d){var e=d.startContainer,g=e.getAscendant("table",1),f=!1;c(g.getElementsByTag("td"));c(g.getElementsByTag("th"));g=d.clone();g.setStart(e,0);g=a(g).lastBackward();g||(g=d.clone(),g.setEndAt(e, -CKEDITOR.POSITION_BEFORE_END),g=a(g).lastForward(),f=!0);g||(g=e);g.is("table")?(d.setStartAt(g,CKEDITOR.POSITION_BEFORE_START),d.collapse(!0),g.remove()):(g.is({tbody:1,thead:1,tfoot:1})&&(g=b(g,"tr",f)),g.is("tr")&&(g=b(g,g.getParent().is("thead")?"th":"td",f)),(e=g.getBogus())&&e.remove(),d.moveToPosition(g,f?CKEDITOR.POSITION_AFTER_START:CKEDITOR.POSITION_BEFORE_END))}}();E=function(){function a(b){b=new CKEDITOR.dom.walker(b);b.guard=function(a,b){if(b)return!1;if(a.type==CKEDITOR.NODE_ELEMENT)return a.is(CKEDITOR.dtd.$list)|| +CKEDITOR.POSITION_BEFORE_END),g=a(g).lastForward(),f=!0);g||(g=e);g.is("table")?(d.setStartAt(g,CKEDITOR.POSITION_BEFORE_START),d.collapse(!0),g.remove()):(g.is({tbody:1,thead:1,tfoot:1})&&(g=b(g,"tr",f)),g.is("tr")&&(g=b(g,g.getParent().is("thead")?"th":"td",f)),(e=g.getBogus())&&e.remove(),d.moveToPosition(g,f?CKEDITOR.POSITION_AFTER_START:CKEDITOR.POSITION_BEFORE_END))}}();F=function(){function a(b){b=new CKEDITOR.dom.walker(b);b.guard=function(a,b){if(b)return!1;if(a.type==CKEDITOR.NODE_ELEMENT)return a.is(CKEDITOR.dtd.$list)|| a.is(CKEDITOR.dtd.$listItem)};b.evaluator=function(a){return a.type==CKEDITOR.NODE_ELEMENT&&a.is(CKEDITOR.dtd.$listItem)};return b}return function(b){var c=b.startContainer,d=!1,e;e=b.clone();e.setStart(c,0);e=a(e).lastBackward();e||(e=b.clone(),e.setEndAt(c,CKEDITOR.POSITION_BEFORE_END),e=a(e).lastForward(),d=!0);e||(e=c);e.is(CKEDITOR.dtd.$list)?(b.setStartAt(e,CKEDITOR.POSITION_BEFORE_START),b.collapse(!0),e.remove()):((c=e.getBogus())&&c.remove(),b.moveToPosition(e,d?CKEDITOR.POSITION_AFTER_START: -CKEDITOR.POSITION_BEFORE_END),b.select())}}();u={eol:{detect:function(a,b){var c=a.range,d=c.clone(),e=c.clone(),g=new CKEDITOR.dom.elementPath(c.startContainer,b),f=new CKEDITOR.dom.elementPath(c.endContainer,b);d.collapse(1);e.collapse();g.block&&d.checkBoundaryOfElement(g.block,CKEDITOR.END)&&(c.setStartAfter(g.block),a.prependEolBr=1);f.block&&e.checkBoundaryOfElement(f.block,CKEDITOR.START)&&(c.setEndBefore(f.block),a.appendEolBr=1)},fix:function(a,b){var c=b.getDocument(),d;a.appendEolBr&&(d= +CKEDITOR.POSITION_BEFORE_END),b.select())}}();q={eol:{detect:function(a,b){var c=a.range,d=c.clone(),e=c.clone(),g=new CKEDITOR.dom.elementPath(c.startContainer,b),f=new CKEDITOR.dom.elementPath(c.endContainer,b);d.collapse(1);e.collapse();g.block&&d.checkBoundaryOfElement(g.block,CKEDITOR.END)&&(c.setStartAfter(g.block),a.prependEolBr=1);f.block&&e.checkBoundaryOfElement(f.block,CKEDITOR.START)&&(c.setEndBefore(f.block),a.appendEolBr=1)},fix:function(a,b){var c=b.getDocument(),d;a.appendEolBr&&(d= this.createEolBr(c),a.fragment.append(d));!a.prependEolBr||d&&!d.getPrevious()||a.fragment.append(this.createEolBr(c),1)},createEolBr:function(a){return a.createElement("br",{attributes:{"data-cke-eol":1}})}},bogus:{exclude:function(a){var b=a.range.getBoundaryNodes(),c=b.startNode,b=b.endNode;!b||!m(b)||c&&c.equals(b)||a.range.setEndBefore(b)}},tree:{rebuild:function(a,b){var c=a.range,d=c.getCommonAncestor(),e=new CKEDITOR.dom.elementPath(d,b),g=new CKEDITOR.dom.elementPath(c.startContainer,b), -c=new CKEDITOR.dom.elementPath(c.endContainer,b),f;d.type==CKEDITOR.NODE_TEXT&&(d=d.getParent());if(e.blockLimit.is({tr:1,table:1})){var h=e.contains("table").getParent();f=function(a){return!a.equals(h)}}else if(e.block&&e.block.is(CKEDITOR.dtd.$listItem)&&(g=g.contains(CKEDITOR.dtd.$list),c=c.contains(CKEDITOR.dtd.$list),!g.equals(c))){var q=e.contains(CKEDITOR.dtd.$list).getParent();f=function(a){return!a.equals(q)}}f||(f=function(a){return!a.equals(e.block)&&!a.equals(e.blockLimit)});this.rebuildFragment(a, -b,d,f)},rebuildFragment:function(a,b,c,d){for(var e;c&&!c.equals(b)&&d(c);)e=c.clone(0,1),a.fragment.appendTo(e),a.fragment=e,c=c.getParent()}},cell:{shrink:function(a){a=a.range;var b=a.startContainer,c=a.endContainer,d=a.startOffset,e=a.endOffset;b.type==CKEDITOR.NODE_ELEMENT&&b.equals(c)&&b.is("tr")&&++d==e&&a.shrink(CKEDITOR.SHRINK_TEXT)}}};F=function(){function a(b,c){var d=b.getParent();if(d.is(CKEDITOR.dtd.$inline))b[c?"insertBefore":"insertAfter"](d)}function b(c,d,e){a(d);a(e,1);for(var g;g= -e.getNext();)g.insertAfter(d),d=g;t(c)&&c.remove()}function c(a,b){var d=new CKEDITOR.dom.range(a);d.setStartAfter(b.startNode);d.setEndBefore(b.endNode);return d}return{list:{detectMerge:function(a,b){var d=c(b,a.bookmark),e=d.startPath(),g=d.endPath(),f=e.contains(CKEDITOR.dtd.$list),h=g.contains(CKEDITOR.dtd.$list);a.mergeList=f&&h&&f.getParent().equals(h.getParent())&&!f.equals(h);a.mergeListItems=e.block&&g.block&&e.block.is(CKEDITOR.dtd.$listItem)&&g.block.is(CKEDITOR.dtd.$listItem);if(a.mergeList|| +c=new CKEDITOR.dom.elementPath(c.endContainer,b),f;d.type==CKEDITOR.NODE_TEXT&&(d=d.getParent());if(e.blockLimit.is({tr:1,table:1})){var h=e.contains("table").getParent();f=function(a){return!a.equals(h)}}else if(e.block&&e.block.is(CKEDITOR.dtd.$listItem)&&(g=g.contains(CKEDITOR.dtd.$list),c=c.contains(CKEDITOR.dtd.$list),!g.equals(c))){var r=e.contains(CKEDITOR.dtd.$list).getParent();f=function(a){return!a.equals(r)}}f||(f=function(a){return!a.equals(e.block)&&!a.equals(e.blockLimit)});this.rebuildFragment(a, +b,d,f)},rebuildFragment:function(a,b,c,d){for(var e;c&&!c.equals(b)&&d(c);)e=c.clone(0,1),a.fragment.appendTo(e),a.fragment=e,c=c.getParent()}},cell:{shrink:function(a){a=a.range;var b=a.startContainer,c=a.endContainer,d=a.startOffset,e=a.endOffset;b.type==CKEDITOR.NODE_ELEMENT&&b.equals(c)&&b.is("tr")&&++d==e&&a.shrink(CKEDITOR.SHRINK_TEXT)}}};u=function(){function a(b,c){var d=b.getParent();if(d.is(CKEDITOR.dtd.$inline))b[c?"insertBefore":"insertAfter"](d)}function b(c,d,e){a(d);a(e,1);for(var g;g= +e.getNext();)g.insertAfter(d),d=g;v(c)&&c.remove()}function c(a,b){var d=new CKEDITOR.dom.range(a);d.setStartAfter(b.startNode);d.setEndBefore(b.endNode);return d}return{list:{detectMerge:function(a,b){var d=c(b,a.bookmark),e=d.startPath(),g=d.endPath(),f=e.contains(CKEDITOR.dtd.$list),h=g.contains(CKEDITOR.dtd.$list);a.mergeList=f&&h&&f.getParent().equals(h.getParent())&&!f.equals(h);a.mergeListItems=e.block&&g.block&&e.block.is(CKEDITOR.dtd.$listItem)&&g.block.is(CKEDITOR.dtd.$listItem);if(a.mergeList|| a.mergeListItems)d=d.clone(),d.setStartBefore(a.bookmark.startNode),d.setEndAfter(a.bookmark.endNode),a.mergeListBookmark=d.createBookmark()},merge:function(a,c){if(a.mergeListBookmark){var d=a.mergeListBookmark.startNode,e=a.mergeListBookmark.endNode,g=new CKEDITOR.dom.elementPath(d,c),f=new CKEDITOR.dom.elementPath(e,c);if(a.mergeList){var h=g.contains(CKEDITOR.dtd.$list),k=f.contains(CKEDITOR.dtd.$list);h.equals(k)||(k.moveChildren(h),k.remove())}a.mergeListItems&&(g=g.contains(CKEDITOR.dtd.$listItem), f=f.contains(CKEDITOR.dtd.$listItem),g.equals(f)||b(f,d,e));d.remove();e.remove()}}},block:{detectMerge:function(a,b){if(!a.tableContentsRanges&&!a.mergeListBookmark){var c=new CKEDITOR.dom.range(b);c.setStartBefore(a.bookmark.startNode);c.setEndAfter(a.bookmark.endNode);a.mergeBlockBookmark=c.createBookmark()}},merge:function(a,c){if(a.mergeBlockBookmark&&!a.purgeTableBookmark){var d=a.mergeBlockBookmark.startNode,e=a.mergeBlockBookmark.endNode,g=new CKEDITOR.dom.elementPath(d,c),f=new CKEDITOR.dom.elementPath(e, -c),g=g.block,f=f.block;g&&f&&!g.equals(f)&&b(f,d,e);d.remove();e.remove()}}},table:function(){function a(c){var e=[],g,f=new CKEDITOR.dom.walker(c),h=c.startPath().contains(d),k=c.endPath().contains(d),p={};f.guard=function(a,f){if(a.type==CKEDITOR.NODE_ELEMENT){var l="visited_"+(f?"out":"in");if(a.getCustomData(l))return;CKEDITOR.dom.element.setMarker(p,a,l,1)}if(f&&h&&a.equals(h))g=c.clone(),g.setEndAt(h,CKEDITOR.POSITION_BEFORE_END),e.push(g);else if(!f&&k&&a.equals(k))g=c.clone(),g.setStartAt(k, -CKEDITOR.POSITION_AFTER_START),e.push(g);else{if(l=!f)l=a.type==CKEDITOR.NODE_ELEMENT&&a.is(d)&&(!h||b(a,h))&&(!k||b(a,k));if(!l&&(l=f))if(a.is(d))var l=h&&h.getAscendant("table",!0),D=k&&k.getAscendant("table",!0),I=a.getAscendant("table",!0),l=l&&l.contains(I)||D&&D.contains(I);else l=void 0;l&&(g=c.clone(),g.selectNodeContents(a),e.push(g))}};f.lastForward();CKEDITOR.dom.element.clearAllMarkers(p);return e}function b(a,c){var d=CKEDITOR.POSITION_CONTAINS+CKEDITOR.POSITION_IS_CONTAINED,e=a.getPosition(c); +c),g=g.block,f=f.block;g&&f&&!g.equals(f)&&b(f,d,e);d.remove();e.remove()}}},table:function(){function a(c){var e=[],g,f=new CKEDITOR.dom.walker(c),h=c.startPath().contains(d),k=c.endPath().contains(d),t={};f.guard=function(a,f){if(a.type==CKEDITOR.NODE_ELEMENT){var E="visited_"+(f?"out":"in");if(a.getCustomData(E))return;CKEDITOR.dom.element.setMarker(t,a,E,1)}if(f&&h&&a.equals(h))g=c.clone(),g.setEndAt(h,CKEDITOR.POSITION_BEFORE_END),e.push(g);else if(!f&&k&&a.equals(k))g=c.clone(),g.setStartAt(k, +CKEDITOR.POSITION_AFTER_START),e.push(g);else{if(E=!f)E=a.type==CKEDITOR.NODE_ELEMENT&&a.is(d)&&(!h||b(a,h))&&(!k||b(a,k));if(!E&&(E=f))if(a.is(d))var E=h&&h.getAscendant("table",!0),H=k&&k.getAscendant("table",!0),l=a.getAscendant("table",!0),E=E&&E.contains(l)||H&&H.contains(l);else E=void 0;E&&(g=c.clone(),g.selectNodeContents(a),e.push(g))}};f.lastForward();CKEDITOR.dom.element.clearAllMarkers(t);return e}function b(a,c){var d=CKEDITOR.POSITION_CONTAINS+CKEDITOR.POSITION_IS_CONTAINED,e=a.getPosition(c); return e===CKEDITOR.POSITION_IDENTICAL?!1:0===(e&d)}var d={td:1,th:1,caption:1};return{detectPurge:function(a){var b=a.range,c=b.clone();c.enlarge(CKEDITOR.ENLARGE_ELEMENT);var c=new CKEDITOR.dom.walker(c),e=0;c.evaluator=function(a){a.type==CKEDITOR.NODE_ELEMENT&&a.is(d)&&++e};c.checkForward();if(1g&&e&&e.intersectsNode(c.$)){var f=[{node:d.anchorNode,offset:d.anchorOffset}, -{node:d.focusNode,offset:d.focusOffset}];d.anchorNode==c.$&&d.anchorOffset>g&&(f[0].offset-=g);d.focusNode==c.$&&d.focusOffset>g&&(f[1].offset-=g)}}c.setText(y(c.getText(),1));f&&(c=a.getDocument().$,d=c.getSelection(),c=c.createRange(),c.setStart(f[0].node,f[0].offset),c.collapse(!0),d.removeAllRanges(),d.addRange(c),d.extend(f[1].node,f[1].offset))}}function y(a,b){return b?a.replace(J,function(a,b){return b?" ":""}):a.replace(v,"")}function z(a,b){var c=b&&CKEDITOR.tools.htmlEncode(b)||"\x26nbsp;", +return c+=d.join("\t")}function f(a){var b=this.root.editor,d=b.getSelection(1);this.reset();F=!0;d.root.once("selectionchange",function(a){a.cancel()},null,null,0);d.selectRanges([a[0]]);d=this._.cache;d.ranges=new CKEDITOR.dom.rangeList(a);d.type=CKEDITOR.SELECTION_TEXT;d.selectedElement=a[0]._getTableElement();d.selectedText=c(a);d.nativeSel=null;this.isFake=1;this.rev=M++;b._.fakeSelection=this;F=!1;this.root.fire("selectionchange")}function e(){var b=this._.fakeSelection,c;if(b){c=this.getSelection(1); +var e;if(!(e=!c)&&(e=!c.isHidden())){e=b;var g=c.getRanges(),f=e.getRanges(),h=g.length&&g[0]._getTableElement()&&g[0]._getTableElement().getAscendant("table",!0),k=f.length&&f[0]._getTableElement()&&f[0]._getTableElement().getAscendant("table",!0),E=1===g.length&&g[0]._getTableElement()&&g[0]._getTableElement().is("table"),l=1===f.length&&f[0]._getTableElement()&&f[0]._getTableElement().is("table");if(a(e.getSelectedElement()))e=!1;else{var p=1===g.length&&g[0].collapsed,f=d(g,!!CKEDITOR.env.webkit)&& +d(f);h=h&&k?h.equals(k)||k.contains(h):!1;h&&(p||f)?(E&&!l&&e.selectRanges(g),e=!0):e=!1}e=!e}e&&(b.reset(),b=0)}if(!b&&(b=c||this.getSelection(1),!b||b.getType()==CKEDITOR.SELECTION_NONE))return;this.fire("selectionCheck",b);c=this.elementPath();c.compare(this._.selectionPreviousPath)||(e=this._.selectionPreviousPath&&this._.selectionPreviousPath.blockLimit.equals(c.blockLimit),!CKEDITOR.env.webkit&&!CKEDITOR.env.gecko||e||(this._.previousActive=this.document.getActive()),this._.selectionPreviousPath= +c,this.fire("selectionChange",{selection:b,path:c}))}function k(){u=!0;q||(h.call(this),q=CKEDITOR.tools.setTimeout(h,200,this))}function h(){q=null;u&&(CKEDITOR.tools.setTimeout(e,0,this),u=!1)}function n(a){return K(a)||a.type==CKEDITOR.NODE_ELEMENT&&!a.is(CKEDITOR.dtd.$empty)?!0:!1}function l(a){function b(c,d){return c&&c.type!=CKEDITOR.NODE_TEXT?a.clone()["moveToElementEdit"+(d?"End":"Start")](c):!1}if(!(a.root instanceof CKEDITOR.editable))return!1;var c=a.startContainer,d=a.getPreviousNode(n, +null,c),e=a.getNextNode(n,null,c);return b(d)||b(e,1)||!(d||e||c.type==CKEDITOR.NODE_ELEMENT&&c.isBlockBoundary()&&c.getBogus())?!0:!1}function g(a){x(a,!1);var b=a.getDocument().createText(w);a.setCustomData("cke-fillingChar",b);return b}function x(a,b){var c=a&&a.removeCustomData("cke-fillingChar");if(c){if(!1!==b){var d=a.getDocument().getSelection().getNative(),e=d&&"None"!=d.type&&d.getRangeAt(0),g=w.length;if(c.getLength()>g&&e&&e.intersectsNode(c.$)){var f=[{node:d.anchorNode,offset:d.anchorOffset}, +{node:d.focusNode,offset:d.focusOffset}];d.anchorNode==c.$&&d.anchorOffset>g&&(f[0].offset-=g);d.focusNode==c.$&&d.focusOffset>g&&(f[1].offset-=g)}}c.setText(y(c.getText(),1));f&&(c=a.getDocument().$,d=c.getSelection(),c=c.createRange(),c.setStart(f[0].node,f[0].offset),c.collapse(!0),d.removeAllRanges(),d.addRange(c),d.extend(f[1].node,f[1].offset))}}function y(a,b){return b?a.replace(J,function(a,b){return b?" ":""}):a.replace(w,"")}function z(a,b){var c=b&&CKEDITOR.tools.htmlEncode(b)||"\x26nbsp;", c=CKEDITOR.dom.element.createFromHtml('\x3cdiv data-cke-hidden-sel\x3d"1" data-cke-temp\x3d"1" style\x3d"'+(CKEDITOR.env.ie&&14>CKEDITOR.env.version?"display:none":"position:fixed;top:0;left:-1000px;width:0;height:0;overflow:hidden;")+'"\x3e'+c+"\x3c/div\x3e",a.document);a.fire("lockSnapshot");a.editable().append(c);var d=a.getSelection(1),e=a.createRange(),g=d.root.on("selectionchange",function(a){a.cancel()},null,null,0);e.setStartAt(c,CKEDITOR.POSITION_AFTER_START);e.setEndAt(c,CKEDITOR.POSITION_BEFORE_END); -d.selectRanges([e]);g.removeListener();a.fire("unlockSnapshot");a._.hiddenSelectionContainer=c}function A(a){var b={37:1,39:1,8:1,46:1};return function(c){var d=c.data.getKeystroke();if(b[d]){var e=a.getSelection(),g=e.getRanges()[0];e.isCollapsed()&&(g=g[38>d?"getPreviousEditableNode":"getNextEditableNode"]())&&g.type==CKEDITOR.NODE_ELEMENT&&"false"==g.getAttribute("contenteditable")&&(e=e.getStartElement(),!e.isBlockBoundary()||""!==(void 0===e.$.textContent?e.$.innerText:e.$.textContent)||8!== -d&&46!==d||(e.remove(),a.fire("saveSnapshot")),a.getSelection().fake(g),c.data.preventDefault(),c.cancel())}}}function t(a){for(var b=0;be?"getPreviousEditableNode":"getNextEditableNode"]())&&f.type==CKEDITOR.NODE_ELEMENT&&"false"==f.getAttribute("contenteditable")&&(g=g.getStartElement(),!g.isBlockBoundary()||""!==(void 0===g.$.textContent?g.$.innerText:g.$.textContent)||a(g.getFirst())|| +8!==e&&46!==e||(g.remove(),b.fire("saveSnapshot")),b.getSelection().fake(f),d.data.preventDefault(),d.cancel())}}}function v(a){for(var b=0;b=d.getLength()?h.setStartAfter(d):h.setStartBefore(d));e&&e.type==CKEDITOR.NODE_TEXT&&(f?h.setEndAfter(e):h.setEndBefore(e));d=new CKEDITOR.dom.walker(h);d.evaluator=function(d){if(d.type==CKEDITOR.NODE_ELEMENT&&d.isReadOnly()){var e=c.clone();c.setEndBefore(d);c.collapsed&&a.splice(b--,1);d.getPosition(h.endContainer)&CKEDITOR.POSITION_CONTAINS||(e.setStartAfter(d),e.collapsed||a.splice(b+1,0,e));return!0}return!1};d.next()}}return a}var m= -"function"!=typeof window.getSelection,M=1,v=CKEDITOR.tools.repeat("​",7),J=new RegExp(v+"( )?","g"),E,u,F,H=CKEDITOR.dom.walker.invisible(1),x=function(){function a(b){return function(a){var c=a.editor.createRange();c.moveToClosestEditablePosition(a.selected,b)&&a.editor.getSelection().selectRanges([c]);return!1}}function b(a){return function(b){var c=b.editor,d=c.createRange(),e;if(!c.readOnly)return(e=d.moveToClosestEditablePosition(b.selected,a))||(e=d.moveToClosestEditablePosition(b.selected, -!a)),e&&c.getSelection().selectRanges([d]),c.fire("saveSnapshot"),b.selected.remove(),e||(d.moveToElementEditablePosition(c.editable()),c.getSelection().selectRanges([d])),c.fire("saveSnapshot"),!1}}var c=a(),d=a(1);return{37:c,38:c,39:d,40:d,8:b(),46:b(1)}}();CKEDITOR.on("instanceCreated",function(a){function b(){var a=c.getSelection();a&&a.removeAllRanges()}var c=a.editor;c.on("contentDom",function(){function a(){u=new CKEDITOR.dom.selection(c.getSelection());u.lock()}function b(){h.removeListener("mouseup", -b);p.removeListener("mouseup",b);var a=CKEDITOR.document.$.selection,c=a.createRange();"None"!=a.type&&c.parentElement()&&c.parentElement().ownerDocument==f.$&&c.select()}function d(a){var b,c;b=(b=this.document.getActive())?"input"===b.getName()||"textarea"===b.getName():!1;b||(b=this.getSelection(1),(c=g(b))&&!c.equals(n)&&(b.selectElement(c),a.data.preventDefault()))}function g(a){a=a.getRanges()[0];return a?(a=a.startContainer.getAscendant(function(a){return a.type==CKEDITOR.NODE_ELEMENT&&a.hasAttribute("contenteditable")}, -!0))&&"false"===a.getAttribute("contenteditable")?a:null:null}var f=c.document,h=CKEDITOR.document,n=c.editable(),l=f.getBody(),p=f.getDocumentElement(),r=n.isInline(),D,u;CKEDITOR.env.gecko&&n.attachListener(n,"focus",function(a){a.removeListener();0!==D&&(a=c.getSelection().getNative())&&a.isCollapsed&&a.anchorNode==n.$&&(a=c.createRange(),a.moveToElementEditStart(n),a.select())},null,null,-2);n.attachListener(n,CKEDITOR.env.webkit||CKEDITOR.env.gecko?"focusin":"focus",function(){if(D&&(CKEDITOR.env.webkit|| -CKEDITOR.env.gecko)){D=c._.previousActive&&c._.previousActive.equals(f.getActive());var a=null!=c._.previousScrollTop&&c._.previousScrollTop!=n.$.scrollTop;CKEDITOR.env.webkit&&D&&a&&(n.$.scrollTop=c._.previousScrollTop)}c.unlockSelection(D);D=0},null,null,-1);n.attachListener(n,"mousedown",function(){D=0});if(CKEDITOR.env.ie||CKEDITOR.env.gecko||r)m?n.attachListener(n,"beforedeactivate",a,null,null,-1):n.attachListener(c,"selectionCheck",a,null,null,-1),n.attachListener(n,CKEDITOR.env.webkit||CKEDITOR.env.gecko? -"focusout":"blur",function(){var a=u&&(u.isFake||2>u.getRanges().length);CKEDITOR.env.gecko&&!r&&a||(c.lockSelection(u),D=1)},null,null,-1),n.attachListener(n,"mousedown",function(){D=0});if(CKEDITOR.env.ie&&!r){var t;n.attachListener(n,"mousedown",function(a){2==a.data.$.button&&((a=c.document.getSelection())&&a.getType()!=CKEDITOR.SELECTION_NONE||(t=c.window.getScrollPosition()))});n.attachListener(n,"mouseup",function(a){2==a.data.$.button&&t&&(c.document.$.documentElement.scrollLeft=t.x,c.document.$.documentElement.scrollTop= -t.y);t=null});if("BackCompat"!=f.$.compatMode){if(CKEDITOR.env.ie7Compat||CKEDITOR.env.ie6Compat){var y,v;p.on("mousedown",function(a){function b(a){a=a.data.$;if(y){var c=l.$.createTextRange();try{c.moveToPoint(a.clientX,a.clientY)}catch(d){}y.setEndPoint(0>v.compareEndPoints("StartToStart",c)?"EndToEnd":"StartToStart",c);y.select()}}function c(){p.removeListener("mousemove",b);h.removeListener("mouseup",c);p.removeListener("mouseup",c);y.select()}a=a.data;if(a.getTarget().is("html")&&a.$.yCKEDITOR.env.version)p.on("mousedown",function(a){a.data.getTarget().is("html")&&(h.on("mouseup",b),p.on("mouseup",b))})}}n.attachListener(n,"selectionchange",e,c);n.attachListener(n,"keyup",k,c);n.attachListener(n,"touchstart",k,c);n.attachListener(n,"touchend",k,c);CKEDITOR.env.ie&&n.attachListener(n, -"keydown",d,c);n.attachListener(n,CKEDITOR.env.webkit||CKEDITOR.env.gecko?"focusin":"focus",function(){c.forceNextSelectionCheck();c.selectionChange(1)});if(r&&(CKEDITOR.env.webkit||CKEDITOR.env.gecko)){var z;n.attachListener(n,"mousedown",function(){z=1});n.attachListener(f.getDocumentElement(),"mouseup",function(){z&&k.call(c);z=0})}else n.attachListener(CKEDITOR.env.ie?n:f.getDocumentElement(),"mouseup",k,c);CKEDITOR.env.webkit&&n.attachListener(f,"keydown",function(a){switch(a.data.getKey()){case 13:case 33:case 34:case 35:case 36:case 37:case 39:case 8:case 45:case 46:n.hasFocus&& -w(n)}},null,null,-1);n.attachListener(n,"keydown",A(c),null,null,-1)});c.on("setData",function(){c.unlockSelection();CKEDITOR.env.webkit&&b()});c.on("contentDomUnload",function(){c.unlockSelection()});if(CKEDITOR.env.ie9Compat)c.on("beforeDestroy",b,null,null,9);c.on("dataReady",function(){delete c._.fakeSelection;delete c._.hiddenSelectionContainer;c.selectionChange(1)});c.on("loadSnapshot",function(){var a=CKEDITOR.dom.walker.nodeType(CKEDITOR.NODE_ELEMENT),b=c.editable().getLast(a);b&&b.hasAttribute("data-cke-hidden-sel")&& -(b.remove(),CKEDITOR.env.gecko&&(a=c.editable().getFirst(a))&&a.is("br")&&a.getAttribute("_moz_editor_bogus_node")&&a.remove())},null,null,100);c.on("key",function(a){if("wysiwyg"==c.mode){var b=c.getSelection();if(b.isFake){var d=x[a.data.keyCode];if(d)return d({editor:c,selected:b.getSelectedElement(),selection:b,keyEvent:a})}}})});if(CKEDITOR.env.webkit)CKEDITOR.on("instanceReady",function(a){var b=a.editor;b.on("selectionChange",function(){var a=b.editable(),c=a.getCustomData("cke-fillingChar"); -c&&(c.getCustomData("ready")?(w(a),a.editor.fire("selectionCheck")):c.setCustomData("ready",1))},null,null,-1);b.on("beforeSetMode",function(){w(b.editable())},null,null,-1);b.on("getSnapshot",function(a){a.data&&(a.data=y(a.data))},b,null,20);b.on("toDataFormat",function(a){a.data.dataValue=y(a.data.dataValue)},null,null,0)});CKEDITOR.editor.prototype.selectionChange=function(a){(a?e:k).call(this)};CKEDITOR.editor.prototype.getSelection=function(a){return!this._.savedSelection&&!this._.fakeSelection|| +"function"!=typeof window.getSelection,M=1,w=CKEDITOR.tools.repeat("​",7),J=new RegExp(w+"( )?","g"),F,q,u,K=CKEDITOR.dom.walker.invisible(1),D=function(){function a(b){return function(a){var c=a.editor.createRange();c.moveToClosestEditablePosition(a.selected,b)&&a.editor.getSelection().selectRanges([c]);return!1}}function b(a){return function(b){var c=b.editor,d=c.createRange(),e;if(!c.readOnly)return(e=d.moveToClosestEditablePosition(b.selected,a))||(e=d.moveToClosestEditablePosition(b.selected, +!a)),e&&c.getSelection().selectRanges([d]),c.fire("saveSnapshot"),b.selected.remove(),e||(d.moveToElementEditablePosition(c.editable()),c.getSelection().selectRanges([d])),c.fire("saveSnapshot"),!1}}var c=a(),d=a(1);return{37:c,38:c,39:d,40:d,8:b(),46:b(1)}}();CKEDITOR.on("instanceCreated",function(a){function b(){var a=c.getSelection();a&&a.removeAllRanges()}var c=a.editor;c.on("contentDom",function(){function a(){q=new CKEDITOR.dom.selection(c.getSelection());q.lock()}function b(){h.removeListener("mouseup", +b);l.removeListener("mouseup",b);var a=CKEDITOR.document.$.selection,c=a.createRange();"None"!=a.type&&c.parentElement()&&c.parentElement().ownerDocument==f.$&&c.select()}function d(a){var b,c;b=(b=this.document.getActive())?"input"===b.getName()||"textarea"===b.getName():!1;b||(b=this.getSelection(1),(c=g(b))&&!c.equals(p)&&(b.selectElement(c),a.data.preventDefault()))}function g(a){a=a.getRanges()[0];return a?(a=a.startContainer.getAscendant(function(a){return a.type==CKEDITOR.NODE_ELEMENT&&a.hasAttribute("contenteditable")}, +!0))&&"false"===a.getAttribute("contenteditable")?a:null:null}var f=c.document,h=CKEDITOR.document,p=c.editable(),t=f.getBody(),l=f.getDocumentElement(),H=p.isInline(),n,q;CKEDITOR.env.gecko&&p.attachListener(p,"focus",function(a){a.removeListener();0!==n&&(a=c.getSelection().getNative())&&a.isCollapsed&&a.anchorNode==p.$&&(a=c.createRange(),a.moveToElementEditStart(p),a.select())},null,null,-2);p.attachListener(p,CKEDITOR.env.webkit||CKEDITOR.env.gecko?"focusin":"focus",function(){if(n&&(CKEDITOR.env.webkit|| +CKEDITOR.env.gecko)){n=c._.previousActive&&c._.previousActive.equals(f.getActive());var a=null!=c._.previousScrollTop&&c._.previousScrollTop!=p.$.scrollTop;CKEDITOR.env.webkit&&n&&a&&(p.$.scrollTop=c._.previousScrollTop)}c.unlockSelection(n);n=0},null,null,-1);p.attachListener(p,"mousedown",function(){n=0});if(CKEDITOR.env.ie||CKEDITOR.env.gecko||H)m?p.attachListener(p,"beforedeactivate",a,null,null,-1):p.attachListener(c,"selectionCheck",a,null,null,-1),p.attachListener(p,CKEDITOR.env.webkit||CKEDITOR.env.gecko? +"focusout":"blur",function(){var a=q&&(q.isFake||2>q.getRanges().length);CKEDITOR.env.gecko&&!H&&a||(c.lockSelection(q),n=1)},null,null,-1),p.attachListener(p,"mousedown",function(){n=0});if(CKEDITOR.env.ie&&!H){var v;p.attachListener(p,"mousedown",function(a){2==a.data.$.button&&((a=c.document.getSelection())&&a.getType()!=CKEDITOR.SELECTION_NONE||(v=c.window.getScrollPosition()))});p.attachListener(p,"mouseup",function(a){2==a.data.$.button&&v&&(c.document.$.documentElement.scrollLeft=v.x,c.document.$.documentElement.scrollTop= +v.y);v=null});if("BackCompat"!=f.$.compatMode){if(CKEDITOR.env.ie7Compat||CKEDITOR.env.ie6Compat){var u,y;l.on("mousedown",function(a){function b(a){a=a.data.$;if(u){var c=t.$.createTextRange();try{c.moveToPoint(a.clientX,a.clientY)}catch(d){}u.setEndPoint(0>y.compareEndPoints("StartToStart",c)?"EndToEnd":"StartToStart",c);u.select()}}function c(){l.removeListener("mousemove",b);h.removeListener("mouseup",c);l.removeListener("mouseup",c);u.select()}a=a.data;if(a.getTarget().is("html")&&a.$.yCKEDITOR.env.version)l.on("mousedown",function(a){a.data.getTarget().is("html")&&(h.on("mouseup",b),l.on("mouseup",b))})}}p.attachListener(p,"selectionchange",e,c);p.attachListener(p,"keyup",k,c);p.attachListener(p,"touchstart",k,c);p.attachListener(p,"touchend",k,c);CKEDITOR.env.ie&&p.attachListener(p, +"keydown",d,c);p.attachListener(p,CKEDITOR.env.webkit||CKEDITOR.env.gecko?"focusin":"focus",function(){c.forceNextSelectionCheck();c.selectionChange(1)});if(H&&(CKEDITOR.env.webkit||CKEDITOR.env.gecko)){var w;p.attachListener(p,"mousedown",function(){w=1});p.attachListener(f.getDocumentElement(),"mouseup",function(){w&&k.call(c);w=0})}else p.attachListener(CKEDITOR.env.ie?p:f.getDocumentElement(),"mouseup",k,c);CKEDITOR.env.webkit&&p.attachListener(f,"keydown",function(a){switch(a.data.getKey()){case 13:case 33:case 34:case 35:case 36:case 37:case 39:case 8:case 45:case 46:p.hasFocus&& +x(p)}},null,null,-1);p.attachListener(p,"keydown",G(c),null,null,-1)});c.on("setData",function(){c.unlockSelection();CKEDITOR.env.webkit&&b()});c.on("contentDomUnload",function(){c.unlockSelection()});if(CKEDITOR.env.ie9Compat)c.on("beforeDestroy",b,null,null,9);c.on("dataReady",function(){delete c._.fakeSelection;delete c._.hiddenSelectionContainer;c.selectionChange(1)});c.on("loadSnapshot",function(){var a=CKEDITOR.dom.walker.nodeType(CKEDITOR.NODE_ELEMENT),b=c.editable().getLast(a);b&&b.hasAttribute("data-cke-hidden-sel")&& +(b.remove(),CKEDITOR.env.gecko&&(a=c.editable().getFirst(a))&&a.is("br")&&a.getAttribute("_moz_editor_bogus_node")&&a.remove())},null,null,100);c.on("key",function(a){if("wysiwyg"==c.mode){var b=c.getSelection();if(b.isFake){var d=D[a.data.keyCode];if(d)return d({editor:c,selected:b.getSelectedElement(),selection:b,keyEvent:a})}}})});if(CKEDITOR.env.webkit)CKEDITOR.on("instanceReady",function(a){var b=a.editor;b.on("selectionChange",function(){var a=b.editable(),c=a.getCustomData("cke-fillingChar"); +c&&(c.getCustomData("ready")?(x(a),a.editor.fire("selectionCheck")):c.setCustomData("ready",1))},null,null,-1);b.on("beforeSetMode",function(){x(b.editable())},null,null,-1);b.on("getSnapshot",function(a){a.data&&(a.data=y(a.data))},b,null,20);b.on("toDataFormat",function(a){a.data.dataValue=y(a.data.dataValue)},null,null,0)});CKEDITOR.editor.prototype.selectionChange=function(a){(a?e:k).call(this)};CKEDITOR.editor.prototype.getSelection=function(a){return!this._.savedSelection&&!this._.fakeSelection|| a?(a=this.editable())&&"wysiwyg"==this.mode&&"recreating"!==this.status?new CKEDITOR.dom.selection(a):null:this._.savedSelection||this._.fakeSelection};CKEDITOR.editor.prototype.getSelectedRanges=function(a){var b=this.getSelection();return b&&b.getRanges(a)||[]};CKEDITOR.editor.prototype.lockSelection=function(a){a=a||this.getSelection(1);return a.getType()!=CKEDITOR.SELECTION_NONE?(!a.isLocked&&a.lock(),this._.savedSelection=a,!0):!1};CKEDITOR.editor.prototype.unlockSelection=function(a){var b= this._.savedSelection;return b?(b.unlock(a),delete this._.savedSelection,!0):!1};CKEDITOR.editor.prototype.forceNextSelectionCheck=function(){delete this._.selectionPreviousPath};CKEDITOR.dom.document.prototype.getSelection=function(){return new CKEDITOR.dom.selection(this)};CKEDITOR.dom.range.prototype.select=function(){var a=this.root instanceof CKEDITOR.editable?this.root.editor.getSelection():new CKEDITOR.dom.selection(this.root);a.selectRanges([this]);return a};CKEDITOR.SELECTION_NONE=1;CKEDITOR.SELECTION_TEXT= 2;CKEDITOR.SELECTION_ELEMENT=3;CKEDITOR.dom.selection=function(a){if(a instanceof CKEDITOR.dom.selection){var b=a;a=a.root}var c=a instanceof CKEDITOR.dom.element;this.rev=b?b.rev:M++;this.document=a instanceof CKEDITOR.dom.document?a:a.getDocument();this.root=c?a:this.document.getBody();this.isLocked=0;this._={cache:{}};if(b)return CKEDITOR.tools.extend(this._.cache,b._.cache),this.isFake=b.isFake,this.isLocked=b.isLocked,this;a=this.getNative();var d,e;if(a)if(a.getRangeAt)d=(e=a.rangeCount&&a.getRangeAt(0))&& -new CKEDITOR.dom.node(e.commonAncestorContainer);else{try{e=a.createRange()}catch(g){}d=e&&CKEDITOR.dom.element.get(e.item&&e.item(0)||e.parentElement())}if(!d||d.type!=CKEDITOR.NODE_ELEMENT&&d.type!=CKEDITOR.NODE_TEXT||!this.root.equals(d)&&!this.root.contains(d))this._.cache.type=CKEDITOR.SELECTION_NONE,this._.cache.startElement=null,this._.cache.selectedElement=null,this._.cache.selectedText="",this._.cache.ranges=new CKEDITOR.dom.rangeList;return this};var K={img:1,hr:1,li:1,table:1,tr:1,td:1, -th:1,embed:1,object:1,ol:1,ul:1,a:1,input:1,form:1,select:1,textarea:1,button:1,fieldset:1,thead:1,tfoot:1};CKEDITOR.tools.extend(CKEDITOR.dom.selection,{_removeFillingCharSequenceString:y,_createFillingCharSequenceNode:g,FILLING_CHAR_SEQUENCE:v});CKEDITOR.dom.selection.prototype={getNative:function(){return void 0!==this._.cache.nativeSel?this._.cache.nativeSel:this._.cache.nativeSel=m?this.document.$.selection:this.document.getWindow().$.getSelection()},getType:m?function(){var a=this._.cache;if(a.type)return a.type; +new CKEDITOR.dom.node(e.commonAncestorContainer);else{try{e=a.createRange()}catch(g){}d=e&&CKEDITOR.dom.element.get(e.item&&e.item(0)||e.parentElement())}if(!d||d.type!=CKEDITOR.NODE_ELEMENT&&d.type!=CKEDITOR.NODE_TEXT||!this.root.equals(d)&&!this.root.contains(d))this._.cache.type=CKEDITOR.SELECTION_NONE,this._.cache.startElement=null,this._.cache.selectedElement=null,this._.cache.selectedText="",this._.cache.ranges=new CKEDITOR.dom.rangeList;return this};var B={img:1,hr:1,li:1,table:1,tr:1,td:1, +th:1,embed:1,object:1,ol:1,ul:1,a:1,input:1,form:1,select:1,textarea:1,button:1,fieldset:1,thead:1,tfoot:1};CKEDITOR.tools.extend(CKEDITOR.dom.selection,{_removeFillingCharSequenceString:y,_createFillingCharSequenceNode:g,FILLING_CHAR_SEQUENCE:w});CKEDITOR.dom.selection.prototype={getNative:function(){return void 0!==this._.cache.nativeSel?this._.cache.nativeSel:this._.cache.nativeSel=m?this.document.$.selection:this.document.getWindow().$.getSelection()},getType:m?function(){var a=this._.cache;if(a.type)return a.type; var b=CKEDITOR.SELECTION_NONE;try{var c=this.getNative(),d=c.type;"Text"==d&&(b=CKEDITOR.SELECTION_TEXT);"Control"==d&&(b=CKEDITOR.SELECTION_ELEMENT);c.createRange().parentElement()&&(b=CKEDITOR.SELECTION_TEXT)}catch(e){}return a.type=b}:function(){var a=this._.cache;if(a.type)return a.type;var b=CKEDITOR.SELECTION_TEXT,c=this.getNative();if(!c||!c.rangeCount)b=CKEDITOR.SELECTION_NONE;else if(1==c.rangeCount){var c=c.getRangeAt(0),d=c.startContainer;d==c.endContainer&&1==d.nodeType&&1==c.endOffset- -c.startOffset&&K[d.childNodes[c.startOffset].nodeName.toLowerCase()]&&(b=CKEDITOR.SELECTION_ELEMENT)}return a.type=b},getRanges:function(){var a=m?function(){function a(b){return(new CKEDITOR.dom.node(b)).getIndex()}var b=function(b,c){b=b.duplicate();b.collapse(c);var d=b.parentElement();if(!d.hasChildNodes())return{container:d,offset:0};for(var e=d.children,g,f,h=b.duplicate(),k=0,l=e.length-1,p=-1,r,m;k<=l;)if(p=Math.floor((k+l)/2),g=e[p],h.moveToElementText(g),r=h.compareEndPoints("StartToStart", -b),0r)k=p+1;else return{container:d,offset:a(g)};if(-1==p||p==e.length-1&&0>r){h.moveToElementText(d);h.setEndPoint("StartToStart",b);h=h.text.replace(/(\r\n|\r)/g,"\n").length;e=d.childNodes;if(!h)return g=e[e.length-1],g.nodeType!=CKEDITOR.NODE_TEXT?{container:d,offset:e.length}:{container:g,offset:g.nodeValue.length};for(d=e.length;0m)k=t+1;else return{container:d,offset:a(g)};if(-1==t||t==e.length-1&&0>m){h.moveToElementText(d);h.setEndPoint("StartToStart",b);h=h.text.replace(/(\r\n|\r)/g,"\n").length;e=d.childNodes;if(!h)return g=e[e.length-1],g.nodeType!=CKEDITOR.NODE_TEXT?{container:d,offset:e.length}:{container:g,offset:g.nodeValue.length};for(d=e.length;0c.length?this.selectElement(b):this.selectRanges(c))}},reset:function(){this._.cache={};this.isFake=0;var a=this.root.editor;if(a&&a._.fakeSelection)if(this.rev== a._.fakeSelection.rev){delete a._.fakeSelection;var b=a._.hiddenSelectionContainer;if(b){var c=a.checkDirty();a.fire("lockSnapshot");b.remove();a.fire("unlockSnapshot");!c&&a.resetDirty()}delete a._.hiddenSelectionContainer}else CKEDITOR.warn("selection-fake-reset");this.rev=M++},selectElement:function(a){var b=new CKEDITOR.dom.range(this.root);b.setStartBefore(a);b.setEndAfter(a);this.selectRanges([b])},selectRanges:function(a){var b=this.root.editor,c=b&&b._.hiddenSelectionContainer;this.reset(); -if(c)for(var c=this.root,e,h=0;h]*>)[ \t\r\n]*/gi,"$1");f=f.replace(/([ \t\n\r]+| )/g," ");f=f.replace(/]*>/gi,"\n");if(CKEDITOR.env.ie){var h=a.getDocument().createElement("div");h.append(e);e.$.outerHTML="\x3cpre\x3e"+f+"\x3c/pre\x3e";e.copyAttributes(h.getFirst());e=h.getFirst().remove()}else e.setHtml(f);b=e}else f?b=y(c?[a.getHtml()]:g(a),b):a.moveChildren(b);b.replace(a);if(d){var c=b,k;(k=c.getPrevious(G))&& -k.type==CKEDITOR.NODE_ELEMENT&&k.is("pre")&&(d=w(k.getHtml(),/\n$/,"")+"\n\n"+w(c.getHtml(),/^\n/,""),CKEDITOR.env.ie?c.$.outerHTML="\x3cpre\x3e"+d+"\x3c/pre\x3e":c.setHtml(d),k.remove())}else c&&m(b)}function g(a){var b=[];w(a.getOuterHtml(),/(\S\s*)\n(?:\s|(]+data-cke-bookmark.*?\/span>))*\n(?!$)/gi,function(a,b,c){return b+"\x3c/pre\x3e"+c+"\x3cpre\x3e"}).replace(/([\s\S]*?)<\/pre>/gi,function(a,c){b.push(c)});return b}function w(a,b,c){var d="",e="";a=a.replace(/(^]+data-cke-bookmark.*?\/span>)|(]+data-cke-bookmark.*?\/span>$)/gi, -function(a,b,c){b&&(d=b);c&&(e=c);return""});return d+a.replace(b,c)+e}function y(a,b){var c;1]*>)[ \t\r\n]*/gi,"$1");f=f.replace(/([ \t\n\r]+| )/g," ");f=f.replace(/]*>/gi,"\n");if(CKEDITOR.env.ie){var h=a.getDocument().createElement("div");h.append(e);e.$.outerHTML="\x3cpre\x3e"+f+"\x3c/pre\x3e";e.copyAttributes(h.getFirst());e=h.getFirst().remove()}else e.setHtml(f);b=e}else f?b=y(c?[a.getHtml()]:g(a),b):a.moveChildren(b);b.replace(a);if(d){var c=b,k;(k=c.getPrevious(I))&& +k.type==CKEDITOR.NODE_ELEMENT&&k.is("pre")&&(d=x(k.getHtml(),/\n$/,"")+"\n\n"+x(c.getHtml(),/^\n/,""),CKEDITOR.env.ie?c.$.outerHTML="\x3cpre\x3e"+d+"\x3c/pre\x3e":c.setHtml(d),k.remove())}else c&&m(b)}function g(a){var b=[];x(a.getOuterHtml(),/(\S\s*)\n(?:\s|(]+data-cke-bookmark.*?\/span>))*\n(?!$)/gi,function(a,b,c){return b+"\x3c/pre\x3e"+c+"\x3cpre\x3e"}).replace(/([\s\S]*?)<\/pre>/gi,function(a,c){b.push(c)});return b}function x(a,b,c){var d="",e="";a=a.replace(/(^]+data-cke-bookmark.*?\/span>)|(]+data-cke-bookmark.*?\/span>$)/gi, +function(a,b,c){b&&(d=b);c&&(e=c);return""});return d+a.replace(b,c)+e}function y(a,b){var c;1=b&&a<=c}function f(a){a=a.toString(16);return 1==a.length?"0"+a:a}CKEDITOR.tools.color= CKEDITOR.tools.createClass({$:function(a,b){this._.initialColorCode=a;this._.defaultValue=b;this._.parseInput(a)},proto:{getHex:function(){if(!this._.isValidColor)return this._.defaultValue;var a=this._.blendAlphaColor(this._.red,this._.green,this._.blue,this._.alpha);return this._.formatHexString(a[0],a[1],a[2])},getHexWithAlpha:function(){if(!this._.isValidColor)return this._.defaultValue;var a=Math.round(this._.alpha*CKEDITOR.tools.color.MAX_RGB_CHANNEL_VALUE);return this._.formatHexString(this._.red, this._.green,this._.blue,a)},getRgb:function(){if(!this._.isValidColor)return this._.defaultValue;var a=this._.blendAlphaColor(this._.red,this._.green,this._.blue,this._.alpha);return this._.formatRgbString("rgb",a[0],a[1],a[2])},getRgba:function(){return this._.isValidColor?this._.formatRgbString("rgba",this._.red,this._.green,this._.blue,this._.alpha):this._.defaultValue},getHsl:function(){var a=0===this._.alpha||1===this._.alpha;if(!this._.isValidColor)return this._.defaultValue;this._.type=== @@ -539,11 +544,11 @@ a[0],a[1],a[2],this._.alpha)},getInitialValue:function(){return this._.initialCo b,c,d,f){b=[b,c,d];void 0!==f&&b.push(f);return a+"("+b.join(",")+")"},formatHslString:function(a,b,c,d,f){return a+"("+b+","+c+"%,"+d+"%"+(void 0!==f?","+f:"")+")"},parseInput:function(a){if("string"!==typeof a)this._.isValidColor=!1;else{a=CKEDITOR.tools.trim(a);var b=this._.matchStringToNamedColor(a);b&&(a=b);var b=this._.extractColorChannelsFromHex(a),c=this._.extractColorChannelsFromRgba(a);a=this._.extractColorChannelsFromHsla(a);(a=b||c||a)?(this._.type=a.type,this._.red=a.red,this._.green= a.green,this._.blue=a.blue,this._.alpha=a.alpha,a.type===CKEDITOR.tools.color.TYPE_HSL&&(this._.hue=a.hue,this._.saturation=a.saturation,this._.lightness=a.lightness)):this._.isValidColor=!1}},matchStringToNamedColor:function(a){return CKEDITOR.tools.color.namedColors[a.toLowerCase()]||null},extractColorChannelsFromHex:function(a){-1===a.indexOf("#")&&(a="#"+a);a.match(CKEDITOR.tools.color.hex3CharsRegExp)&&(a=this._.hex3ToHex6(a));a.match(CKEDITOR.tools.color.hex4CharsRegExp)&&(a=this._.hex4ToHex8(a)); if(!a.match(CKEDITOR.tools.color.hex6CharsRegExp)&&!a.match(CKEDITOR.tools.color.hex8CharsRegExp))return null;a=a.split("");var b=1;a[7]&&a[8]&&(b=parseInt(a[7]+a[8],16),b/=CKEDITOR.tools.color.MAX_RGB_CHANNEL_VALUE,b=Number(b.toFixed(1)));return{type:CKEDITOR.tools.color.TYPE_RGB,red:parseInt(a[1]+a[2],16),green:parseInt(a[3]+a[4],16),blue:parseInt(a[5]+a[6],16),alpha:b}},extractColorChannelsFromRgba:function(b){var c=this._.extractColorChannelsByPattern(b,CKEDITOR.tools.color.rgbRegExp);if(!c|| -3>c.length||4c.length||4c.length||4c.length||4=c?(e=f.createText(""),e.insertAfter(this)):(a=f.createText(""),a.insertAfter(e),a.remove()));return e},substring:function(a,d){return"number"!=typeof d?this.$.nodeValue.substr(a):this.$.nodeValue.substring(a,d)}}); -(function(){function a(a,c,d){var e=a.serializable,k=c[d?"endContainer":"startContainer"],h=d?"endOffset":"startOffset",l=e?c.document.getById(a.startNode):a.startNode;a=e?c.document.getById(a.endNode):a.endNode;k.equals(l.getPrevious())?(c.startOffset=c.startOffset-k.getLength()-a.getPrevious().getLength(),k=a.getNext()):k.equals(a.getPrevious())&&(c.startOffset-=k.getLength(),k=a.getNext());k.equals(l.getParent())&&c[h]++;k.equals(a.getParent())&&c[h]++;c[d?"endContainer":"startContainer"]=k;return c} -CKEDITOR.dom.rangeList=function(a){if(a instanceof CKEDITOR.dom.rangeList)return a;a?a instanceof CKEDITOR.dom.range&&(a=[a]):a=[];return CKEDITOR.tools.extend(a,d)};var d={createIterator:function(){var a=this,c=CKEDITOR.dom.walker.bookmark(),d=[],e;return{getNextRange:function(k){e=void 0===e?0:e+1;var h=a[e];if(h&&1b?-1:1}),e=0,f;eCKEDITOR.env.version? a[h].$.styleSheet.cssText+=f:a[h].$.innerHTML+=f}}var e={};CKEDITOR.skin={path:a,loadPart:function(c,d){CKEDITOR.skin.name!=CKEDITOR.skinName.split(",")[0]?CKEDITOR.scriptLoader.load(CKEDITOR.getUrl(a()+"skin.js"),function(){b(c,d)}):b(c,d)},getPath:function(a){return CKEDITOR.getUrl(d(a))},icons:{},addIcon:function(a,b,c,d){a=a.toLowerCase();this.icons[a]||(this.icons[a]={path:b,offset:c||0,bgsize:d||"16px"})},getIconStyle:function(a,b,c,d,e){var f;a&&(a=a.toLowerCase(),b&&(f=this.icons[a+"-rtl"]), f||(f=this.icons[a]));a=c||f&&f.path||"";d=d||f&&f.offset;e=e||f&&f.bgsize||"16px";a&&(a=a.replace(/'/g,"\\'"));return a&&"background-image:url('"+CKEDITOR.getUrl(a)+"');background-position:0 "+d+"px;background-size:"+e+";"}};CKEDITOR.tools.extend(CKEDITOR.editor.prototype,{getUiColor:function(){return this.uiColor},setUiColor:function(a){var b=c(CKEDITOR.document);return(this.setUiColor=function(a){this.uiColor=a;var c=CKEDITOR.skin.chameleon,d="",e="";"function"==typeof c&&(d=c(this,"editor"),e= -c(this,"panel"));a=[[l,a]];f([b],d,a);f(h,e,a)}).call(this,a)}});var k="cke_ui_color",h=[],l=/\$color/g;CKEDITOR.on("instanceLoaded",function(a){if(!CKEDITOR.env.ie||!CKEDITOR.env.quirks){var b=a.editor;a=function(a){a=(a.data[0]||a.data).element.getElementsByTag("iframe").getItem(0).getFrameDocument();if(!a.getById("cke_ui_color")){var d=c(a);h.push(d);b.on("destroy",function(){h=CKEDITOR.tools.array.filter(h,function(a){return d!==a})});(a=b.getUiColor())&&f([d],CKEDITOR.skin.chameleon(b,"panel"), -[[l,a]])}};b.on("panelShow",a);b.on("menuShow",a);b.config.uiColor&&b.setUiColor(b.config.uiColor)}})})(); +c(this,"panel"));a=[[n,a]];f([b],d,a);f(h,e,a)}).call(this,a)}});var k="cke_ui_color",h=[],n=/\$color/g;CKEDITOR.on("instanceLoaded",function(a){if(!CKEDITOR.env.ie||!CKEDITOR.env.quirks){var b=a.editor;a=function(a){a=(a.data[0]||a.data).element.getElementsByTag("iframe").getItem(0).getFrameDocument();if(!a.getById("cke_ui_color")){var d=c(a);h.push(d);b.on("destroy",function(){h=CKEDITOR.tools.array.filter(h,function(a){return d!==a})});(a=b.getUiColor())&&f([d],CKEDITOR.skin.chameleon(b,"panel"), +[[n,a]])}};b.on("panelShow",a);b.on("menuShow",a);b.config.uiColor&&b.setUiColor(b.config.uiColor)}})})(); (function(){var a=CKEDITOR.dom.element.createFromHtml('\x3cdiv style\x3d"width:0;height:0;position:absolute;left:-10000px;border:1px solid;border-color:red blue"\x3e\x3c/div\x3e',CKEDITOR.document);a.appendTo(CKEDITOR.document.getHead());try{var d=a.getComputedStyle("border-top-color"),b=a.getComputedStyle("border-right-color");CKEDITOR.env.hc=!(!d||d!=b)}catch(c){CKEDITOR.env.hc=!1}a.remove();CKEDITOR.env.hc&&(CKEDITOR.env.cssClass+=" cke_hc");CKEDITOR.document.appendStyleText(".cke{visibility:hidden;}"); CKEDITOR.status="loaded";CKEDITOR.fireOnce("loaded");if(a=CKEDITOR._.pending)for(delete CKEDITOR._.pending,d=0;de;e++){var f=e,c;c=parseInt(a[e],16);c=("0"+(0>d?0|c*(1+d):0|c+(255-c)*d).toString(16)).slice(-2);a[f]=c}return"#"+a.join("")}}(),f={editor:new CKEDITOR.template("{id}.cke_chrome [border-color:{defaultBorder};] {id} .cke_top [ background-color:{defaultBackground};border-bottom-color:{defaultBorder};] {id} .cke_bottom [background-color:{defaultBackground};border-top-color:{defaultBorder};] {id} .cke_resizer [border-right-color:{ckeResizer}] {id} .cke_dialog_title [background-color:{defaultBackground};border-bottom-color:{defaultBorder};] {id} .cke_dialog_footer [background-color:{defaultBackground};outline-color:{defaultBorder};] {id} .cke_dialog_tab [background-color:{dialogTab};border-color:{defaultBorder};] {id} .cke_dialog_tab:hover [background-color:{lightBackground};] {id} .cke_dialog_contents [border-top-color:{defaultBorder};] {id} .cke_dialog_tab_selected, {id} .cke_dialog_tab_selected:hover [background:{dialogTabSelected};border-bottom-color:{dialogTabSelectedBorder};] {id} .cke_dialog_body [background:{dialogBody};border-color:{defaultBorder};] {id} a.cke_button_off:hover,{id} a.cke_button_off:focus,{id} a.cke_button_off:active [background-color:{darkBackground};border-color:{toolbarElementsBorder};] {id} .cke_button_on [background-color:{ckeButtonOn};border-color:{toolbarElementsBorder};] {id} .cke_toolbar_separator,{id} .cke_toolgroup a.cke_button:last-child:after,{id} .cke_toolgroup a.cke_button.cke_button_disabled:hover:last-child:after [background-color: {toolbarElementsBorder};border-color: {toolbarElementsBorder};] {id} a.cke_combo_button:hover,{id} a.cke_combo_button:focus,{id} .cke_combo_on a.cke_combo_button [border-color:{toolbarElementsBorder};background-color:{darkBackground};] {id} .cke_combo:after [border-color:{toolbarElementsBorder};] {id} .cke_path_item [color:{elementsPathColor};] {id} a.cke_path_item:hover,{id} a.cke_path_item:focus,{id} a.cke_path_item:active [background-color:{darkBackground};] {id}.cke_panel [border-color:{defaultBorder};] "),panel:new CKEDITOR.template(".cke_panel_grouptitle [background-color:{lightBackground};border-color:{defaultBorder};] .cke_menubutton_icon [background-color:{menubuttonIcon};] .cke_menubutton:hover,.cke_menubutton:focus,.cke_menubutton:active [background-color:{menubuttonHover};] .cke_menubutton:hover .cke_menubutton_icon, .cke_menubutton:focus .cke_menubutton_icon, .cke_menubutton:active .cke_menubutton_icon [background-color:{menubuttonIconHover};] .cke_menubutton_disabled:hover .cke_menubutton_icon,.cke_menubutton_disabled:focus .cke_menubutton_icon,.cke_menubutton_disabled:active .cke_menubutton_icon [background-color:{menubuttonIcon};] .cke_menuseparator [background-color:{menubuttonIcon};] a:hover.cke_colorbox, a:active.cke_colorbox [border-color:{defaultBorder};] a:hover.cke_colorauto, a:hover.cke_colormore, a:active.cke_colorauto, a:active.cke_colormore [background-color:{ckeColorauto};border-color:{defaultBorder};] ")}; -return function(g,d){var a=b(g.uiColor,.4),a={id:"."+g.id,defaultBorder:b(a,-.2),toolbarElementsBorder:b(a,-.25),defaultBackground:a,lightBackground:b(a,.8),darkBackground:b(a,-.15),ckeButtonOn:b(a,.4),ckeResizer:b(a,-.4),ckeColorauto:b(a,.8),dialogBody:b(a,.7),dialogTab:b(a,.65),dialogTabSelected:"#FFF",dialogTabSelectedBorder:"#FFF",elementsPathColor:b(a,-.6),menubuttonHover:b(a,.1),menubuttonIcon:b(a,.5),menubuttonIconHover:b(a,.3)};return f[d].output(a).replace(/\[/g,"{").replace(/\]/g,"}")}}();CKEDITOR.plugins.add("dialogui",{onLoad:function(){var h=function(b){this._||(this._={});this._["default"]=this._.initValue=b["default"]||"";this._.required=b.required||!1;for(var a=[this._],d=1;darguments.length)){var c=h.call(this,a);c.labelId=CKEDITOR.tools.getNextId()+ -"_label";this._.children=[];var e={role:a.role||"presentation"};a.includeLabel&&(e["aria-labelledby"]=c.labelId);CKEDITOR.ui.dialog.uiElement.call(this,b,a,d,"div",null,e,function(){var e=[],g=a.required?" cke_required":"";"horizontal"!=a.labelLayout?e.push('\x3clabel class\x3d"cke_dialog_ui_labeled_label'+g+'" ',' id\x3d"'+c.labelId+'"',c.inputId?' for\x3d"'+c.inputId+'"':"",(a.labelStyle?' style\x3d"'+a.labelStyle+'"':"")+"\x3e",a.required?a.label+'\x3cspan class\x3d"cke_dialog_ui_labeled_required" aria-hidden\x3d"true"\x3e*\x3c/span\x3e': -a.label,"\x3c/label\x3e",'\x3cdiv class\x3d"cke_dialog_ui_labeled_content"',a.controlStyle?' style\x3d"'+a.controlStyle+'"':"",' role\x3d"presentation"\x3e',f.call(this,b,a),"\x3c/div\x3e"):(g={type:"hbox",widths:a.widths,padding:0,children:[{type:"html",html:'\x3clabel class\x3d"cke_dialog_ui_labeled_label'+g+'" id\x3d"'+c.labelId+'" for\x3d"'+c.inputId+'"'+(a.labelStyle?' style\x3d"'+a.labelStyle+'"':"")+"\x3e"+CKEDITOR.tools.htmlEncode(a.label)+"\x3c/label\x3e"},{type:"html",html:'\x3cspan class\x3d"cke_dialog_ui_labeled_content"'+ -(a.controlStyle?' style\x3d"'+a.controlStyle+'"':"")+"\x3e"+f.call(this,b,a)+"\x3c/span\x3e"}]},CKEDITOR.dialog._.uiElementBuilders.hbox.build(b,g,e));return e.join("")})}},textInput:function(b,a,d){if(!(3>arguments.length)){h.call(this,a);var f=this._.inputId=CKEDITOR.tools.getNextId()+"_textInput",c={"class":"cke_dialog_ui_input_"+a.type,id:f,type:a.type};a.validate&&(this.validate=a.validate);a.maxLength&&(c.maxlength=a.maxLength);a.size&&(c.size=a.size);a.inputStyle&&(c.style=a.inputStyle);var e= -this,m=!1;b.on("load",function(){e.getInputElement().on("keydown",function(a){13==a.data.getKeystroke()&&(m=!0)});e.getInputElement().on("keyup",function(a){13==a.data.getKeystroke()&&m&&(b.getButton("ok")&&setTimeout(function(){b.getButton("ok").click()},0),m=!1);e.bidi&&w.call(e,a)},null,null,1E3)});CKEDITOR.ui.dialog.labeledElement.call(this,b,a,d,function(){var b=['\x3cdiv class\x3d"cke_dialog_ui_input_',a.type,'" role\x3d"presentation"'];a.width&&b.push('style\x3d"width:'+a.width+'" ');b.push("\x3e\x3cinput "); -c["aria-labelledby"]=this._.labelId;this._.required&&(c["aria-required"]=this._.required);for(var e in c)b.push(e+'\x3d"'+c[e]+'" ');b.push(" /\x3e\x3c/div\x3e");return b.join("")})}},textarea:function(b,a,d){if(!(3>arguments.length)){h.call(this,a);var f=this,c=this._.inputId=CKEDITOR.tools.getNextId()+"_textarea",e={};a.validate&&(this.validate=a.validate);e.rows=a.rows||5;e.cols=a.cols||20;e["class"]="cke_dialog_ui_input_textarea "+(a["class"]||"");"undefined"!=typeof a.inputStyle&&(e.style=a.inputStyle); -a.dir&&(e.dir=a.dir);if(f.bidi)b.on("load",function(){f.getInputElement().on("keyup",w)},f);CKEDITOR.ui.dialog.labeledElement.call(this,b,a,d,function(){e["aria-labelledby"]=this._.labelId;this._.required&&(e["aria-required"]=this._.required);var a=['\x3cdiv class\x3d"cke_dialog_ui_input_textarea" role\x3d"presentation"\x3e\x3ctextarea id\x3d"',c,'" '],b;for(b in e)a.push(b+'\x3d"'+CKEDITOR.tools.htmlEncode(e[b])+'" ');a.push("\x3e",CKEDITOR.tools.htmlEncode(f._["default"]),"\x3c/textarea\x3e\x3c/div\x3e"); -return a.join("")})}},checkbox:function(b,a,d){if(!(3>arguments.length)){var f=h.call(this,a,{"default":!!a["default"]});a.validate&&(this.validate=a.validate);CKEDITOR.ui.dialog.uiElement.call(this,b,a,d,"span",null,null,function(){var c=CKEDITOR.tools.extend({},a,{id:a.id?a.id+"_checkbox":CKEDITOR.tools.getNextId()+"_checkbox"},!0),e=[],d=CKEDITOR.tools.getNextId()+"_label",g={"class":"cke_dialog_ui_checkbox_input",type:"checkbox","aria-labelledby":d};t(c);a["default"]&&(g.checked="checked");"undefined"!= -typeof c.inputStyle&&(c.style=c.inputStyle);f.checkbox=new CKEDITOR.ui.dialog.uiElement(b,c,e,"input",null,g);e.push(' \x3clabel id\x3d"',d,'" for\x3d"',g.id,'"'+(a.labelStyle?' style\x3d"'+a.labelStyle+'"':"")+"\x3e",CKEDITOR.tools.htmlEncode(a.label),"\x3c/label\x3e");return e.join("")})}},radio:function(b,a,d){if(!(3>arguments.length)){h.call(this,a);this._["default"]||(this._["default"]=this._.initValue=a.items[0][1]);a.validate&&(this.validate=a.validate);var f=[],c=this;a.role="radiogroup"; -a.includeLabel=!0;CKEDITOR.ui.dialog.labeledElement.call(this,b,a,d,function(){for(var e=[],d=[],g=(a.id?a.id:CKEDITOR.tools.getNextId())+"_radio",k=0;karguments.length)){var f=h.call(this,a);a.validate&&(this.validate=a.validate);f.inputId=CKEDITOR.tools.getNextId()+"_select";CKEDITOR.ui.dialog.labeledElement.call(this,b,a,d,function(){var c=CKEDITOR.tools.extend({},a,{id:a.id?a.id+"_select":CKEDITOR.tools.getNextId()+"_select"},!0),e=[],d=[],g={id:f.inputId,"class":"cke_dialog_ui_input_select", -"aria-labelledby":this._.labelId};e.push('\x3cdiv class\x3d"cke_dialog_ui_input_',a.type,'" role\x3d"presentation"');a.width&&e.push('style\x3d"width:'+a.width+'" ');e.push("\x3e");void 0!==a.size&&(g.size=a.size);void 0!==a.multiple&&(g.multiple=a.multiple);t(c);for(var k=0,l;karguments.length)){void 0===a["default"]&&(a["default"]="");var f=CKEDITOR.tools.extend(h.call(this,a),{definition:a,buttons:[]});a.validate&&(this.validate=a.validate);b.on("load",function(){CKEDITOR.document.getById(f.frameId).getParent().addClass("cke_dialog_ui_input_file")});CKEDITOR.ui.dialog.labeledElement.call(this,b,a,d, -function(){f.frameId=CKEDITOR.tools.getNextId()+"_fileInput";var b=['\x3ciframe frameborder\x3d"0" allowtransparency\x3d"0" class\x3d"cke_dialog_ui_input_file" role\x3d"presentation" id\x3d"',f.frameId,'" title\x3d"',a.label,'" src\x3d"javascript:void('];b.push(CKEDITOR.env.ie?"(function(){"+encodeURIComponent("document.open();("+CKEDITOR.tools.fixDomain+")();document.close();")+"})()":"0");b.push(')"\x3e\x3c/iframe\x3e');return b.join("")})}},fileButton:function(b,a,d){var f=this;if(!(3>arguments.length)){h.call(this, -a);a.validate&&(this.validate=a.validate);var c=CKEDITOR.tools.extend({},a),e=c.onClick;c.className=(c.className?c.className+" ":"")+"cke_dialog_ui_button";c.onClick=function(c){var d=a["for"];c=e?e.call(this,c):!1;!1!==c&&("xhr"!==c&&b.getContentElement(d[0],d[1]).submit(),this.disable())};b.on("load",function(){b.getContentElement(a["for"][0],a["for"][1])._.buttons.push(f)});CKEDITOR.ui.dialog.button.call(this,b,c,d)}},html:function(){var b=/^\s*<[\w:]+\s+([^>]*)?>/,a=/^(\s*<[\w:]+(?:\s+[^>]*)?)((?:.|\r|\n)+)$/, -d=/\/$/;return function(f,c,e){if(!(3>arguments.length)){var m=[],g=c.html;"\x3c"!=g.charAt(0)&&(g="\x3cspan\x3e"+g+"\x3c/span\x3e");var k=c.focus;if(k){var l=this.focus;this.focus=function(){("function"==typeof k?k:l).call(this);this.fire("focus")};c.isFocusable&&(this.isFocusable=this.isFocusable);this.keyboardFocusable=!0}CKEDITOR.ui.dialog.uiElement.call(this,f,c,m,"span",null,null,"");m=m.join("").match(b);g=g.match(a)||["","",""];d.test(g[1])&&(g[1]=g[1].slice(0,-1),g[2]="/"+g[2]);e.push([g[1], -" ",m[1]||"",g[2]].join(""))}}}(),fieldset:function(b,a,d,f,c){var e=c.label;this._={children:a};CKEDITOR.ui.dialog.uiElement.call(this,b,c,f,"fieldset",null,null,function(){var a=[];e&&a.push("\x3clegend"+(c.labelStyle?' style\x3d"'+c.labelStyle+'"':"")+"\x3e"+e+"\x3c/legend\x3e");for(var b=0;barguments.length)){var c=k.call(this,a);c.labelId=CKEDITOR.tools.getNextId()+ +"_label";this._.children=[];var f={role:a.role||"presentation"};a.includeLabel&&(f["aria-labelledby"]=c.labelId);CKEDITOR.ui.dialog.uiElement.call(this,b,a,d,"div",null,f,function(){var d=[],g=a.required?" cke_required":"";"horizontal"!=a.labelLayout?d.push('\x3clabel class\x3d"cke_dialog_ui_labeled_label'+g+'" ',' id\x3d"'+c.labelId+'"',c.inputId?' for\x3d"'+c.inputId+'"':"",(a.labelStyle?' style\x3d"'+a.labelStyle+'"':"")+"\x3e",a.required?a.label+'\x3cspan class\x3d"cke_dialog_ui_labeled_required" aria-hidden\x3d"true"\x3e*\x3c/span\x3e': +a.label,"\x3c/label\x3e",'\x3cdiv class\x3d"cke_dialog_ui_labeled_content"',a.controlStyle?' style\x3d"'+a.controlStyle+'"':"",' role\x3d"presentation"\x3e',e.call(this,b,a),"\x3c/div\x3e"):(g={type:"hbox",widths:a.widths,padding:0,children:[{type:"html",html:'\x3clabel class\x3d"cke_dialog_ui_labeled_label'+g+'" id\x3d"'+c.labelId+'" for\x3d"'+c.inputId+'"'+(a.labelStyle?' style\x3d"'+a.labelStyle+'"':"")+"\x3e"+CKEDITOR.tools.htmlEncode(a.label)+"\x3c/label\x3e"},{type:"html",html:'\x3cspan class\x3d"cke_dialog_ui_labeled_content"'+ +(a.controlStyle?' style\x3d"'+a.controlStyle+'"':"")+"\x3e"+e.call(this,b,a)+"\x3c/span\x3e"}]},CKEDITOR.dialog._.uiElementBuilders.hbox.build(b,g,d));return d.join("")})}},textInput:function(b,a,d){if(!(3>arguments.length)){k.call(this,a);var e=this._.inputId=CKEDITOR.tools.getNextId()+"_textInput",c={"class":"cke_dialog_ui_input_"+a.type,id:e,type:a.type};a.validate&&(this.validate=a.validate);a.maxLength&&(c.maxlength=a.maxLength);a.size&&(c.size=a.size);a.inputStyle&&(c.style=a.inputStyle);var f= +this,h=!1;b.on("load",function(){f.getInputElement().on("keydown",function(a){13==a.data.getKeystroke()&&(h=!0)});f.getInputElement().on("keyup",function(a){13==a.data.getKeystroke()&&h&&(b.getButton("ok")&&setTimeout(function(){b.getButton("ok").click()},0),h=!1);f.bidi&&w.call(f,a)},null,null,1E3)});CKEDITOR.ui.dialog.labeledElement.call(this,b,a,d,function(){var b=['\x3cdiv class\x3d"cke_dialog_ui_input_',a.type,'" role\x3d"presentation"'];a.width&&b.push('style\x3d"width:'+a.width+'" ');b.push("\x3e\x3cinput "); +c["aria-labelledby"]=this._.labelId;this._.required&&(c["aria-required"]=this._.required);for(var e in c)b.push(e+'\x3d"'+c[e]+'" ');b.push(" /\x3e\x3c/div\x3e");return b.join("")})}},textarea:function(b,a,d){if(!(3>arguments.length)){k.call(this,a);var e=this,c=this._.inputId=CKEDITOR.tools.getNextId()+"_textarea",f={};a.validate&&(this.validate=a.validate);f.rows=a.rows||5;f.cols=a.cols||20;f["class"]="cke_dialog_ui_input_textarea "+(a["class"]||"");"undefined"!=typeof a.inputStyle&&(f.style=a.inputStyle); +a.dir&&(f.dir=a.dir);if(e.bidi)b.on("load",function(){e.getInputElement().on("keyup",w)},e);CKEDITOR.ui.dialog.labeledElement.call(this,b,a,d,function(){f["aria-labelledby"]=this._.labelId;this._.required&&(f["aria-required"]=this._.required);var a=['\x3cdiv class\x3d"cke_dialog_ui_input_textarea" role\x3d"presentation"\x3e\x3ctextarea id\x3d"',c,'" '],b;for(b in f)a.push(b+'\x3d"'+CKEDITOR.tools.htmlEncode(f[b])+'" ');a.push("\x3e",CKEDITOR.tools.htmlEncode(e._["default"]),"\x3c/textarea\x3e\x3c/div\x3e"); +return a.join("")})}},checkbox:function(b,a,d){if(!(3>arguments.length)){var e=k.call(this,a,{"default":!!a["default"]});a.validate&&(this.validate=a.validate);CKEDITOR.ui.dialog.uiElement.call(this,b,a,d,"span",null,null,function(){var c=CKEDITOR.tools.extend({},a,{id:a.id?a.id+"_checkbox":CKEDITOR.tools.getNextId()+"_checkbox"},!0),d=[],h=CKEDITOR.tools.getNextId()+"_label",g={"class":"cke_dialog_ui_checkbox_input",type:"checkbox","aria-labelledby":h};t(c);a["default"]&&(g.checked="checked");"undefined"!= +typeof c.inputStyle&&(c.style=c.inputStyle);e.checkbox=new CKEDITOR.ui.dialog.uiElement(b,c,d,"input",null,g);d.push(' \x3clabel id\x3d"',h,'" for\x3d"',g.id,'"'+(a.labelStyle?' style\x3d"'+a.labelStyle+'"':"")+"\x3e",CKEDITOR.tools.htmlEncode(a.label),"\x3c/label\x3e");return d.join("")})}},radio:function(b,a,d){if(!(3>arguments.length)){k.call(this,a);this._["default"]||(this._["default"]=this._.initValue=a.items[0][1]);a.validate&&(this.validate=a.validate);var e=[],c=this;a.role="radiogroup"; +a.includeLabel=!0;CKEDITOR.ui.dialog.labeledElement.call(this,b,a,d,function(){for(var d=[],h=[],g=(a.id?a.id:CKEDITOR.tools.getNextId())+"_radio",n=0;narguments.length)){var e=k.call(this,a);a.validate&&(this.validate=a.validate);e.inputId=CKEDITOR.tools.getNextId()+"_select";CKEDITOR.ui.dialog.labeledElement.call(this,b,a,d,function(){var c=CKEDITOR.tools.extend({},a,{id:a.id?a.id+"_select":CKEDITOR.tools.getNextId()+"_select"},!0),d=[],h=[],g={id:e.inputId, +"class":"cke_dialog_ui_input_select","aria-labelledby":this._.labelId};d.push('\x3cdiv class\x3d"cke_dialog_ui_input_',a.type,'" role\x3d"presentation"');a.width&&d.push('style\x3d"width:'+a.width+'" ');d.push("\x3e");void 0!==a.size&&(g.size=a.size);void 0!==a.multiple&&(g.multiple=a.multiple);t(c);for(var n=0,l;narguments.length)){void 0===a["default"]&&(a["default"]="");var e=CKEDITOR.tools.extend(k.call(this,a),{definition:a,buttons:[]});a.validate&&(this.validate=a.validate);b.on("load",function(){CKEDITOR.document.getById(e.frameId).getParent().addClass("cke_dialog_ui_input_file")});CKEDITOR.ui.dialog.labeledElement.call(this, +b,a,d,function(){e.frameId=CKEDITOR.tools.getNextId()+"_fileInput";var b=['\x3ciframe frameborder\x3d"0" allowtransparency\x3d"0" class\x3d"cke_dialog_ui_input_file" role\x3d"presentation" id\x3d"',e.frameId,'" title\x3d"',a.label,'" src\x3d"javascript:void('];b.push(CKEDITOR.env.ie?"(function(){"+encodeURIComponent("document.open();("+CKEDITOR.tools.fixDomain+")();document.close();")+"})()":"0");b.push(')"\x3e\x3c/iframe\x3e');return b.join("")})}},fileButton:function(b,a,d){var e=this;if(!(3>arguments.length)){k.call(this, +a);a.validate&&(this.validate=a.validate);var c=CKEDITOR.tools.extend({},a),f=c.onClick;c.className=(c.className?c.className+" ":"")+"cke_dialog_ui_button";c.onClick=function(c){var d=a["for"];c=f?f.call(this,c):!1;!1!==c&&("xhr"!==c&&b.getContentElement(d[0],d[1]).submit(),this.disable())};b.on("load",function(){b.getContentElement(a["for"][0],a["for"][1])._.buttons.push(e)});CKEDITOR.ui.dialog.button.call(this,b,c,d)}},html:function(){var b=/^\s*<[\w:]+\s+([^>]*)?>/,a=/^(\s*<[\w:]+(?:\s+[^>]*)?)((?:.|\r|\n)+)$/, +d=/\/$/;return function(e,c,f){if(!(3>arguments.length)){var h=[],g=c.html;"\x3c"!=g.charAt(0)&&(g="\x3cspan\x3e"+g+"\x3c/span\x3e");var n=c.focus;if(n){var l=this.focus;this.focus=function(){("function"==typeof n?n:l).call(this);this.fire("focus")};c.isFocusable&&(this.isFocusable=this.isFocusable);this.keyboardFocusable=!0}CKEDITOR.ui.dialog.uiElement.call(this,e,c,h,"span",null,null,"");h=h.join("").match(b);g=g.match(a)||["","",""];d.test(g[1])&&(g[1]=g[1].slice(0,-1),g[2]="/"+g[2]);f.push([g[1], +" ",h[1]||"",g[2]].join(""))}}}(),fieldset:function(b,a,d,e,c){var f=c.label;this._={children:a};CKEDITOR.ui.dialog.uiElement.call(this,b,c,e,"fieldset",null,null,function(){var a=[];f&&a.push("\x3clegend"+(c.labelStyle?' style\x3d"'+c.labelStyle+'"':"")+"\x3e"+f+"\x3c/legend\x3e");for(var b=0;ba.getChildCount()?(new CKEDITOR.dom.text(b,CKEDITOR.document)).appendTo(a):a.getChild(0).$.nodeValue=b;return this},getLabel:function(){var b=CKEDITOR.document.getById(this._.labelId);return!b||1>b.getChildCount()?"":b.getChild(0).getText()},eventProcessors:v},!0);CKEDITOR.ui.dialog.button.prototype=CKEDITOR.tools.extend(new CKEDITOR.ui.dialog.uiElement,{click:function(){return this._.disabled?!1:this.fire("click",{dialog:this._.dialog})}, enable:function(){this._.disabled=!1;var b=this.getElement();b&&b.removeClass("cke_disabled")},disable:function(){this._.disabled=!0;this.getElement().addClass("cke_disabled")},isVisible:function(){return this.getElement().getFirst().isVisible()},isEnabled:function(){return!this._.disabled},eventProcessors:CKEDITOR.tools.extend({},CKEDITOR.ui.dialog.uiElement.prototype.eventProcessors,{onClick:function(b,a){this.on("click",function(){a.apply(this,arguments)})}},!0),accessKeyUp:function(){this.click()}, accessKeyDown:function(){this.focus()},keyboardFocusable:!0},!0);CKEDITOR.ui.dialog.textInput.prototype=CKEDITOR.tools.extend(new CKEDITOR.ui.dialog.labeledElement,{getInputElement:function(){return CKEDITOR.document.getById(this._.inputId)},focus:function(){var b=this.selectParentTab();setTimeout(function(){var a=b.getInputElement();a&&a.$.focus()},0)},select:function(){var b=this.selectParentTab();setTimeout(function(){var a=b.getInputElement();a&&(a.$.focus(),a.$.select())},0)},accessKeyUp:function(){this.select()}, setValue:function(b){if(this.bidi){var a=b&&b.charAt(0);(a="‪"==a?"ltr":"‫"==a?"rtl":null)&&(b=b.slice(1));this.setDirectionMarker(a)}b||(b="");return CKEDITOR.ui.dialog.uiElement.prototype.setValue.apply(this,arguments)},getValue:function(){var b=CKEDITOR.ui.dialog.uiElement.prototype.getValue.call(this);if(this.bidi&&b){var a=this.getDirectionMarker();a&&(b=("ltr"==a?"‪":"‫")+b)}return b},setDirectionMarker:function(b){var a=this.getInputElement();b?a.setAttributes({dir:b,"data-cke-dir-marker":b}): -this.getDirectionMarker()&&a.removeAttributes(["dir","data-cke-dir-marker"])},getDirectionMarker:function(){return this.getInputElement().data("cke-dir-marker")},keyboardFocusable:!0},q,!0);CKEDITOR.ui.dialog.textarea.prototype=new CKEDITOR.ui.dialog.textInput;CKEDITOR.ui.dialog.select.prototype=CKEDITOR.tools.extend(new CKEDITOR.ui.dialog.labeledElement,{getInputElement:function(){return this._.select.getElement()},add:function(b,a,d){var f=new CKEDITOR.dom.element("option",this.getDialog().getParentEditor().document), -c=this.getInputElement().$;f.$.text=b;f.$.value=void 0===a||null===a?b:a;void 0===d||null===d?CKEDITOR.env.ie?c.add(f.$):c.add(f.$,null):c.add(f.$,d);return this},remove:function(b){this.getInputElement().$.remove(b);return this},clear:function(){for(var b=this.getInputElement().$;0this.focusIndex&&!c&&(a=b[b.length-1]);d.currentFocusIndex=this.focusIndex;for(d=0;db-a;c--)if(this._.tabs[this._.tabIdList[c%a]][0].$.offsetHeight)return this._.tabIdList[c%a];return null}function W(){for(var a=this._.tabIdList.length,b=CKEDITOR.tools.indexOf(this._.tabIdList,this._.currentTabId),c=b+1;ch.width-c.width-g?h.width-c.width+("rtl"==f.lang.dir?0:k[1]):d.x;c=d.y+k[0]h.height-c.height-g?h.height-c.height+k[2]:d.y;q=Math.floor(q);c=Math.floor(c);a.move(q,c,1);b.data.preventDefault()}function c(){CKEDITOR.document.removeListener("mousemove",b);CKEDITOR.document.removeListener("mouseup",c);if(CKEDITOR.env.ie6Compat){var a=u.getChild(0).getFrameDocument();a.removeListener("mousemove",b);a.removeListener("mouseup", +b.on("blur",function(){this.fire("mouseout")})}function ba(a){function b(){a.layout()}var c=CKEDITOR.document.getWindow();c.on("resize",b);a.on("hide",function(){c.removeListener("resize",b)})}function M(a,b){this.dialog=a;for(var c=b.contents,e=0,d;d=c[e];e++)c[e]=d&&new N(a,d);CKEDITOR.tools.extend(this,b)}function N(a,b){this._={dialog:a};CKEDITOR.tools.extend(this,b)}function ca(a){function b(b){var c=a.getSize(),h=a.parts.dialog.getParent().getClientSize(),q=b.data.$.screenX,m=b.data.$.screenY, +r=q-e.x,n=m-e.y;e={x:q,y:m};d.x+=r;d.y+=n;q=d.x+k[3]h.width-c.width-g?h.width-c.width+("rtl"==f.lang.dir?0:k[1]):d.x;c=d.y+k[0]h.height-c.height-g?h.height-c.height+k[2]:d.y;q=Math.floor(q);c=Math.floor(c);a.move(q,c,1);b.data.preventDefault()}function c(){CKEDITOR.document.removeListener("mousemove",b);CKEDITOR.document.removeListener("mouseup",c);if(CKEDITOR.env.ie6Compat){var a=u.getChild(0).getFrameDocument();a.removeListener("mousemove",b);a.removeListener("mouseup", c)}}var e=null,d=null,f=a.getParentEditor(),g=f.config.dialog_magnetDistance,k=CKEDITOR.skin.margins||[0,0,0,0];"undefined"==typeof g&&(g=20);a.parts.title.on("mousedown",function(f){if(!a._.moved){var g=a._.element;g.getFirst().setStyle("position","absolute");g.removeStyle("display");a._.moved=!0;a.layout()}e={x:f.data.$.screenX,y:f.data.$.screenY};CKEDITOR.document.on("mousemove",b);CKEDITOR.document.on("mouseup",c);d=a.getPosition();CKEDITOR.env.ie6Compat&&(g=u.getChild(0).getFrameDocument(),g.on("mousemove", -b),g.on("mouseup",c));f.data.preventDefault()},a)}function da(a){function b(b){var c="rtl"==f.lang.dir,n=h.width,q=h.height,w=n+(b.data.$.screenX-l.x)*(c?-1:1)*(a._.moved?1:2),A=q+(b.data.$.screenY-l.y)*(a._.moved?1:2),C=a._.element.getFirst(),C=c&&parseInt(C.getComputedStyle("right"),10),v=a.getPosition();v.x=v.x||0;v.y=v.y||0;v.y+A>p.height&&(A=p.height-v.y);(c?C:v.x)+w>p.width&&(w=p.width-(c?C:v.x));A=Math.floor(A);w=Math.floor(w);if(d==CKEDITOR.DIALOG_RESIZE_WIDTH||d==CKEDITOR.DIALOG_RESIZE_BOTH)n= -Math.max(e.minWidth||0,w-g);if(d==CKEDITOR.DIALOG_RESIZE_HEIGHT||d==CKEDITOR.DIALOG_RESIZE_BOTH)q=Math.max(e.minHeight||0,A-k);a.resize(n,q);a._.moved&&O(a,a._.position.x,a._.position.y);a._.moved||a.layout();b.data.preventDefault()}function c(){CKEDITOR.document.removeListener("mouseup",c);CKEDITOR.document.removeListener("mousemove",b);q&&(q.remove(),q=null);if(CKEDITOR.env.ie6Compat){var a=u.getChild(0).getFrameDocument();a.removeListener("mouseup",c);a.removeListener("mousemove",b)}}var e=a.definition, -d=e.resizable;if(d!=CKEDITOR.DIALOG_RESIZE_NONE){var f=a.getParentEditor(),g,k,p,l,h,q,n=CKEDITOR.tools.addFunction(function(d){function e(a){return a.isVisible()}h=a.getSize();var f=a.parts.contents,n=f.$.getElementsByTagName("iframe").length,w=!(CKEDITOR.env.gecko||CKEDITOR.env.ie&&CKEDITOR.env.quirks);n&&(q=CKEDITOR.dom.element.createFromHtml('\x3cdiv class\x3d"cke_dialog_resize_cover" style\x3d"height: 100%; position: absolute; width: 100%; left:0; top:0;"\x3e\x3c/div\x3e'),f.append(q));k=h.height- +b),g.on("mouseup",c));f.data.preventDefault()},a)}function da(a){function b(b){var c="rtl"==f.lang.dir,m=h.width,q=h.height,w=m+(b.data.$.screenX-l.x)*(c?-1:1)*(a._.moved?1:2),A=q+(b.data.$.screenY-l.y)*(a._.moved?1:2),C=a._.element.getFirst(),C=c&&parseInt(C.getComputedStyle("right"),10),v=a.getPosition();v.x=v.x||0;v.y=v.y||0;v.y+A>p.height&&(A=p.height-v.y);(c?C:v.x)+w>p.width&&(w=p.width-(c?C:v.x));A=Math.floor(A);w=Math.floor(w);if(d==CKEDITOR.DIALOG_RESIZE_WIDTH||d==CKEDITOR.DIALOG_RESIZE_BOTH)m= +Math.max(e.minWidth||0,w-g);if(d==CKEDITOR.DIALOG_RESIZE_HEIGHT||d==CKEDITOR.DIALOG_RESIZE_BOTH)q=Math.max(e.minHeight||0,A-k);a.resize(m,q);a._.moved&&O(a,a._.position.x,a._.position.y);a._.moved||a.layout();b.data.preventDefault()}function c(){CKEDITOR.document.removeListener("mouseup",c);CKEDITOR.document.removeListener("mousemove",b);q&&(q.remove(),q=null);if(CKEDITOR.env.ie6Compat){var a=u.getChild(0).getFrameDocument();a.removeListener("mouseup",c);a.removeListener("mousemove",b)}}var e=a.definition, +d=e.resizable;if(d!=CKEDITOR.DIALOG_RESIZE_NONE){var f=a.getParentEditor(),g,k,p,l,h,q,m=CKEDITOR.tools.addFunction(function(d){function e(a){return a.isVisible()}h=a.getSize();var f=a.parts.contents,m=f.$.getElementsByTagName("iframe").length,w=!(CKEDITOR.env.gecko||CKEDITOR.env.ie&&CKEDITOR.env.quirks);m&&(q=CKEDITOR.dom.element.createFromHtml('\x3cdiv class\x3d"cke_dialog_resize_cover" style\x3d"height: 100%; position: absolute; width: 100%; left:0; top:0;"\x3e\x3c/div\x3e'),f.append(q));k=h.height- a.parts.contents.getFirst(e).getSize("height",w);g=h.width-a.parts.contents.getFirst(e).getSize("width",1);l={x:d.screenX,y:d.screenY};p=CKEDITOR.document.getWindow().getViewPaneSize();CKEDITOR.document.on("mousemove",b);CKEDITOR.document.on("mouseup",c);CKEDITOR.env.ie6Compat&&(f=u.getChild(0).getFrameDocument(),f.on("mousemove",b),f.on("mouseup",c));d.preventDefault&&d.preventDefault()});a.on("load",function(){var b="";d==CKEDITOR.DIALOG_RESIZE_WIDTH?b=" cke_resizer_horizontal":d==CKEDITOR.DIALOG_RESIZE_HEIGHT&& -(b=" cke_resizer_vertical");b=CKEDITOR.dom.element.createFromHtml('\x3cdiv class\x3d"cke_resizer'+b+" cke_resizer_"+f.lang.dir+'" title\x3d"'+CKEDITOR.tools.htmlEncode(f.lang.common.resize)+'" onmousedown\x3d"CKEDITOR.tools.callFunction('+n+', event )"\x3e'+("ltr"==f.lang.dir?"◢":"◣")+"\x3c/div\x3e");a.parts.footer.append(b,1)});f.on("destroy",function(){CKEDITOR.tools.removeFunction(n)})}}function O(a,b,c){var e=a.parts.dialog.getParent().getClientSize(),d=a.getSize(),f=a._.viewportRatio,g=Math.max(e.width- +(b=" cke_resizer_vertical");b=CKEDITOR.dom.element.createFromHtml('\x3cdiv class\x3d"cke_resizer'+b+" cke_resizer_"+f.lang.dir+'" title\x3d"'+CKEDITOR.tools.htmlEncode(f.lang.common.resize)+'" onmousedown\x3d"CKEDITOR.tools.callFunction('+m+', event )"\x3e'+("ltr"==f.lang.dir?"◢":"◣")+"\x3c/div\x3e");a.parts.footer.append(b,1)});f.on("destroy",function(){CKEDITOR.tools.removeFunction(m)})}}function O(a,b,c){var e=a.parts.dialog.getParent().getClientSize(),d=a.getSize(),f=a._.viewportRatio,g=Math.max(e.width- d.width,0),e=Math.max(e.height-d.height,0);f.width=g?b/g:f.width;f.height=e?c/e:f.height;a._.viewportRatio=f}function H(a){a.data.preventDefault(1)}function P(a){var b=a.config,c=CKEDITOR.skinName||a.config.skin,e=b.dialog_backgroundCoverColor||("moono-lisa"==c?"black":"white"),c=b.dialog_backgroundCoverOpacity,d=b.baseFloatZIndex,b=CKEDITOR.tools.genKey(e,c,d),f=B[b];CKEDITOR.document.getBody().addClass("cke_dialog_open");f?f.show():(d=['\x3cdiv tabIndex\x3d"-1" style\x3d"position: ',CKEDITOR.env.ie6Compat? "absolute":"fixed","; z-index: ",d,"; top: 0px; left: 0px; ","; width: 100%; height: 100%;",CKEDITOR.env.ie6Compat?"":"background-color: "+e,'" class\x3d"cke_dialog_background_cover"\x3e'],CKEDITOR.env.ie6Compat&&(e="\x3chtml\x3e\x3cbody style\x3d\\'background-color:"+e+";\\'\x3e\x3c/body\x3e\x3c/html\x3e",d.push('\x3ciframe hidefocus\x3d"true" frameborder\x3d"0" id\x3d"cke_dialog_background_iframe" src\x3d"javascript:'),d.push("void((function(){"+encodeURIComponent("document.open();("+CKEDITOR.tools.fixDomain+ ")();document.write( '"+e+"' );document.close();")+"})())"),d.push('" style\x3d"position:absolute;left:0;top:0;width:100%;height: 100%;filter: progid:DXImageTransform.Microsoft.Alpha(opacity\x3d0)"\x3e\x3c/iframe\x3e')),d.push("\x3c/div\x3e"),f=CKEDITOR.dom.element.createFromHtml(d.join("")),f.setOpacity(void 0!==c?c:.5),f.on("keydown",H),f.on("keypress",H),f.on("keyup",H),f.appendTo(CKEDITOR.document.getBody()),B[b]=f);a.focusManager.add(f);u=f;CKEDITOR.env.mac&&CKEDITOR.env.webkit||f.focus()}function Q(a){CKEDITOR.document.getBody().removeClass("cke_dialog_open"); u&&(a.focusManager.remove(u),u.hide())}function R(a){var b=a.data.$.ctrlKey||a.data.$.metaKey,c=a.data.$.altKey,e=a.data.$.shiftKey,d=String.fromCharCode(a.data.$.keyCode);(b=x[(b?"CTRL+":"")+(c?"ALT+":"")+(e?"SHIFT+":"")+d])&&b.length&&(b=b[b.length-1],b.keydown&&b.keydown.call(b.uiElement,b.dialog,b.key),a.data.preventDefault())}function S(a){var b=a.data.$.ctrlKey||a.data.$.metaKey,c=a.data.$.altKey,e=a.data.$.shiftKey,d=String.fromCharCode(a.data.$.keyCode);(b=x[(b?"CTRL+":"")+(c?"ALT+":"")+(e? "SHIFT+":"")+d])&&b.length&&(b=b[b.length-1],b.keyup&&(b.keyup.call(b.uiElement,b.dialog,b.key),a.data.preventDefault()))}function T(a,b,c,e,d){(x[c]||(x[c]=[])).push({uiElement:a,dialog:b,key:c,keyup:d||a.accessKeyUp,keydown:e||a.accessKeyDown})}function ea(a){for(var b in x){for(var c=x[b],e=c.length-1;0<=e;e--)c[e].dialog!=a&&c[e].uiElement!=a||c.splice(e,1);0===c.length&&delete x[b]}}function fa(a,b){a._.accessKeyMap[b]&&a.selectPage(a._.accessKeyMap[b])}function ga(){}var y=CKEDITOR.tools.cssLength, U,u,V=!1,D=!CKEDITOR.env.ie||CKEDITOR.env.edge,aa='\x3cdiv class\x3d"cke_reset_all cke_dialog_container {editorId} {editorDialogClass} {hidpi}" dir\x3d"{langDir}" style\x3d"'+(D?"display:flex":"")+'" lang\x3d"{langCode}" role\x3d"dialog" aria-labelledby\x3d"cke_dialog_title_{id}"\x3e\x3ctable class\x3d"cke_dialog '+CKEDITOR.env.cssClass+' cke_{langDir}" style\x3d"'+(D?"margin:auto":"position:absolute")+'" role\x3d"presentation"\x3e\x3ctr\x3e\x3ctd role\x3d"presentation"\x3e\x3cdiv class\x3d"cke_dialog_body" role\x3d"presentation"\x3e\x3cdiv id\x3d"cke_dialog_title_{id}" class\x3d"cke_dialog_title" role\x3d"presentation"\x3e\x3c/div\x3e\x3ca id\x3d"cke_dialog_close_button_{id}" class\x3d"cke_dialog_close_button" href\x3d"javascript:void(0)" title\x3d"{closeTitle}" role\x3d"button"\x3e\x3cspan class\x3d"cke_label"\x3eX\x3c/span\x3e\x3c/a\x3e\x3cdiv id\x3d"cke_dialog_tabs_{id}" class\x3d"cke_dialog_tabs" role\x3d"tablist"\x3e\x3c/div\x3e\x3ctable class\x3d"cke_dialog_contents" role\x3d"presentation"\x3e\x3ctr\x3e\x3ctd id\x3d"cke_dialog_contents_{id}" class\x3d"cke_dialog_contents_body" role\x3d"presentation"\x3e\x3c/td\x3e\x3c/tr\x3e\x3ctr\x3e\x3ctd id\x3d"cke_dialog_footer_{id}" class\x3d"cke_dialog_footer" role\x3d"presentation"\x3e\x3c/td\x3e\x3c/tr\x3e\x3c/table\x3e\x3c/div\x3e\x3c/td\x3e\x3c/tr\x3e\x3c/table\x3e\x3c/div\x3e'; -CKEDITOR.dialog=function(a,b){function c(){var a=m._.focusList;a.sort(function(a,b){return a.tabIndex!=b.tabIndex?b.tabIndex-a.tabIndex:a.focusIndex-b.focusIndex});for(var b=a.length,c=0;cb.length)){var c=m._.currentFocusIndex;m._.tabBarMode&&0>a&&(c=0);try{b[c].getInputElement().$.blur()}catch(d){}var e=c,f=1b.length)){var c=n._.currentFocusIndex;n._.tabBarMode&&0>a&&(c=0);try{b[c].getInputElement().$.blur()}catch(d){}var e=c,f=1arguments.length)){var k=(e.call?e(b):e)||"div",p=["\x3c",k," "],l=(d&&d.call?d(b):d)||{},h=(f&&f.call?f(b):f)||{},q=(g&&g.call?g.call(this,a,b):g)||"",n=this.domId=h.id||CKEDITOR.tools.getNextId()+"_uiElement";b.requiredContent&&!a.getParentEditor().filter.check(b.requiredContent)&&(l.display="none",this.notAllowed= -!0);h.id=n;var r={};b.type&&(r["cke_dialog_ui_"+b.type]=1);b.className&&(r[b.className]=1);b.disabled&&(r.cke_disabled=1);for(var m=h["class"]&&h["class"].split?h["class"].split(" "):[],n=0;narguments.length)){var k=(e.call?e(b):e)||"div",p=["\x3c",k," "],l=(d&&d.call?d(b):d)||{},h=(f&&f.call?f(b):f)||{},q=(g&&g.call?g.call(this,a,b):g)||"",m=this.domId=h.id||CKEDITOR.tools.getNextId()+"_uiElement";b.requiredContent&&!a.getParentEditor().filter.check(b.requiredContent)&&(l.display="none",this.notAllowed= +!0);h.id=m;var r={};b.type&&(r["cke_dialog_ui_"+b.type]=1);b.className&&(r[b.className]=1);b.disabled&&(r.cke_disabled=1);for(var n=h["class"]&&h["class"].split?h["class"].split(" "):[],m=0;mCKEDITOR.env.version?"cke_dialog_ui_focused":"";b.on("focus", function(){a._.tabBarMode=!1;a._.hasFocus=!0;t.fire("focus");c&&this.addClass(c)});b.on("blur",function(){t.fire("blur");c&&this.removeClass(c)})}});CKEDITOR.tools.extend(this,b);this.keyboardFocusable&&(this.tabIndex=b.tabIndex||0,this.focusIndex=a._.focusList.push(this)-1,this.on("focus",function(){a._.currentFocusIndex=t.focusIndex}))}},hbox:function(a,b,c,e,d){if(!(4>arguments.length)){this._||(this._={});var f=this._.children=b,g=d&&d.widths||null,k=d&&d.height||null,p,l={role:"presentation"}; d&&d.align&&(l.align=d.align);CKEDITOR.ui.dialog.uiElement.call(this,a,d||{type:"hbox"},e,"table",{},l,function(){var a=['\x3ctbody\x3e\x3ctr class\x3d"cke_dialog_ui_hbox"\x3e'];for(p=0;parguments.length)return this._.children.concat();a.splice||(a=[a]);return 2>a.length?this._.children[a[0]]:this._.children[a[0]]&&this._.children[a[0]].getChild?this._.children[a[0]].getChild(a.slice(1,a.length)):null}},!0);CKEDITOR.ui.dialog.vbox.prototype=new CKEDITOR.ui.dialog.hbox;(function(){var a={build:function(a, c,e){for(var d=c.children,f,g=[],k=[],p=0;pe.length&&(a=g.document.createElement(g.config.enterMode==CKEDITOR.ENTER_P?"p":"div"),b=h.shift(),c.insertNode(a),a.append(new CKEDITOR.dom.text("",g.document)),c.moveToBookmark(b),c.selectNodeContents(a),c.collapse(!0),b=c.createBookmark(),e.push(a),h.unshift(b));d=e[0].getParent();c=[];for(b=0;ba||(this.notifications.splice(a,1),b.element.remove(),this.element.getChild a.on("change",this._changeBuffer.input);a.on("floatingSpaceLayout",this._layout,this,null,20);a.on("blur",this._layout,this,null,20)},_removeListeners:function(){var b=CKEDITOR.document.getWindow(),a=this.editor;b.removeListener("scroll",this._uiBuffer.input);b.removeListener("resize",this._uiBuffer.input);a.removeListener("change",this._changeBuffer.input);a.removeListener("floatingSpaceLayout",this._layout);a.removeListener("blur",this._layout)},_layout:function(){function b(){a.setStyle("left", k(n+d.width-g-h))}var a=this.element,c=this.editor,d=c.ui.contentsElement.getClientRect(),e=c.ui.contentsElement.getDocumentPosition(),f,l,u=a.getClientRect(),m,g=this._notificationWidth,h=this._notificationMargin;m=CKEDITOR.document.getWindow();var p=m.getScrollPosition(),t=m.getViewPaneSize(),q=CKEDITOR.document.getBody(),r=q.getDocumentPosition(),k=CKEDITOR.tools.cssLength;g&&h||(m=this.element.getChild(0),g=this._notificationWidth=m.getClientRect().width,h=this._notificationMargin=parseInt(m.getComputedStyle("margin-left"), 10)+parseInt(m.getComputedStyle("margin-right"),10));c.toolbar&&(f=c.ui.space(c.config.toolbarLocation),l=f.getClientRect());f&&f.isVisible()&&l.bottom>d.top&&l.bottomp.y?a.setStyles({position:"fixed",top:0}):a.setStyles({position:"absolute",top:k(e.y+d.height-u.height)});var n="fixed"==a.getStyle("position")?d.left:"static"!=q.getComputedStyle("position")? -e.x-r.x:e.x;d.widthp.x+t.width?b():a.setStyle("left",k(n)):e.x+g+h>p.x+t.width?a.setStyle("left",k(n)):e.x+d.width/2+g/2+h>p.x+t.width?a.setStyle("left",k(n-e.x+p.x+t.width-g-h)):0>d.left+d.width-g-h?b():0>d.left+d.width/2-g/2?a.setStyle("left",k(n-e.x+p.x)):a.setStyle("left",k(n+d.width/2-g/2-h/2))}};CKEDITOR.plugins.notification=q})();(function(){var c='\x3ca id\x3d"{id}" class\x3d"cke_button cke_button__{name} cke_button_{state} {cls}"'+(CKEDITOR.env.gecko&&!CKEDITOR.env.hc?"":" href\x3d\"javascript:void('{titleJs}')\"")+' title\x3d"{title}" tabindex\x3d"-1" hidefocus\x3d"true" role\x3d"button" aria-labelledby\x3d"{id}_label" aria-describedby\x3d"{id}_description" aria-haspopup\x3d"{hasArrow}" aria-disabled\x3d"{ariaDisabled}"';CKEDITOR.env.gecko&&CKEDITOR.env.mac&&(c+=' onkeypress\x3d"return false;"');CKEDITOR.env.gecko&&(c+= -' onblur\x3d"this.style.cssText \x3d this.style.cssText;"');var l="";CKEDITOR.env.ie&&(l='return false;" onmouseup\x3d"CKEDITOR.tools.getMouseButton(event)\x3d\x3dCKEDITOR.MOUSE_BUTTON_LEFT\x26\x26');var c=c+(' onkeydown\x3d"return CKEDITOR.tools.callFunction({keydownFn},event);" onfocus\x3d"return CKEDITOR.tools.callFunction({focusFn},event);" onclick\x3d"'+l+'CKEDITOR.tools.callFunction({clickFn},this);return false;"\x3e\x3cspan class\x3d"cke_button_icon cke_button__{iconName}_icon" style\x3d"{style}"')+ +e.x-r.x:e.x;d.widthp.x+t.width?b():a.setStyle("left",k(n)):e.x+g+h>p.x+t.width?a.setStyle("left",k(n)):e.x+d.width/2+g/2+h>p.x+t.width?a.setStyle("left",k(n-e.x+p.x+t.width-g-h)):0>d.left+d.width-g-h?b():0>d.left+d.width/2-g/2?a.setStyle("left",k(n-e.x+p.x)):a.setStyle("left",k(n+d.width/2-g/2-h/2))}};CKEDITOR.plugins.notification=q})();(function(){var c='\x3ca id\x3d"{id}" class\x3d"cke_button cke_button__{name} cke_button_{state} {cls}"'+(CKEDITOR.env.gecko&&!CKEDITOR.env.hc?"":" href\x3d\"javascript:void('{titleJs}')\"")+' title\x3d"{title}" tabindex\x3d"-1" hidefocus\x3d"true" role\x3d"button" aria-labelledby\x3d"{id}_label" aria-describedby\x3d"{id}_description" aria-haspopup\x3d"{hasArrow}" aria-disabled\x3d"{ariaDisabled}"{hasArrowAriaHtml}{toggleAriaHtml}';CKEDITOR.env.gecko&&CKEDITOR.env.mac&&(c+=' onkeypress\x3d"return false;"'); +CKEDITOR.env.gecko&&(c+=' onblur\x3d"this.style.cssText \x3d this.style.cssText;"');var l="";CKEDITOR.env.ie&&(l='return false;" onmouseup\x3d"CKEDITOR.tools.getMouseButton(event)\x3d\x3dCKEDITOR.MOUSE_BUTTON_LEFT\x26\x26');var c=c+(' onkeydown\x3d"return CKEDITOR.tools.callFunction({keydownFn},event);" onfocus\x3d"return CKEDITOR.tools.callFunction({focusFn},event);" onclick\x3d"'+l+'CKEDITOR.tools.callFunction({clickFn},this);return false;"\x3e\x3cspan class\x3d"cke_button_icon cke_button__{iconName}_icon" style\x3d"{style}"')+ '\x3e\x26nbsp;\x3c/span\x3e\x3cspan id\x3d"{id}_label" class\x3d"cke_button_label cke_button__{name}_label" aria-hidden\x3d"false"\x3e{label}\x3c/span\x3e\x3cspan id\x3d"{id}_description" class\x3d"cke_button_label" aria-hidden\x3d"false"\x3e{ariaShortcutSpace}{ariaShortcut}\x3c/span\x3e{arrowHtml}\x3c/a\x3e',v=CKEDITOR.addTemplate("buttonArrow",'\x3cspan class\x3d"cke_button_arrow"\x3e'+(CKEDITOR.env.hc?"\x26#9660;":"")+"\x3c/span\x3e"),w=CKEDITOR.addTemplate("button",c);CKEDITOR.plugins.add("button", -{beforeInit:function(a){a.ui.addHandler(CKEDITOR.UI_BUTTON,CKEDITOR.ui.button.handler)}});CKEDITOR.UI_BUTTON="button";CKEDITOR.ui.button=function(a){CKEDITOR.tools.extend(this,a,{title:a.label,click:a.click||function(b){b.execCommand(a.command)}});this._={}};CKEDITOR.ui.button.handler={create:function(a){return new CKEDITOR.ui.button(a)}};CKEDITOR.ui.button.prototype={render:function(a,b){function c(){var f=a.mode;f&&(f=this.modes[f]?void 0!==p[f]?p[f]:CKEDITOR.TRISTATE_OFF:CKEDITOR.TRISTATE_DISABLED, -f=a.readOnly&&!this.readOnly?CKEDITOR.TRISTATE_DISABLED:f,this.setState(f),this.refresh&&this.refresh())}var p=null,q=CKEDITOR.env,r=this._.id=CKEDITOR.tools.getNextId(),g="",d=this.command,l,m,k;this._.editor=a;var e={id:r,button:this,editor:a,focus:function(){CKEDITOR.document.getById(r).focus()},execute:function(){this.button.click(a)},attach:function(a){this.button.attach(a)}},x=CKEDITOR.tools.addFunction(function(a){if(e.onkey)return a=new CKEDITOR.dom.event(a),!1!==e.onkey(e,a.getKeystroke())}), -y=CKEDITOR.tools.addFunction(function(a){var b;e.onfocus&&(b=!1!==e.onfocus(e,new CKEDITOR.dom.event(a)));return b}),u=0;e.clickFn=l=CKEDITOR.tools.addFunction(function(){u&&(a.unlockSelection(1),u=0);e.execute();q.iOS&&a.focus()});this.modes?(p={},a.on("beforeModeUnload",function(){a.mode&&this._.state!=CKEDITOR.TRISTATE_DISABLED&&(p[a.mode]=this._.state)},this),a.on("activeFilterChange",c,this),a.on("mode",c,this),!this.readOnly&&a.on("readOnly",c,this)):d&&(d=a.getCommand(d))&&(d.on("state",function(){this.setState(d.state)}, -this),g+=d.state==CKEDITOR.TRISTATE_ON?"on":d.state==CKEDITOR.TRISTATE_DISABLED?"disabled":"off");var n;if(this.directional)a.on("contentDirChanged",function(b){var c=CKEDITOR.document.getById(this._.id),d=c.getFirst();b=b.data;b!=a.lang.dir?c.addClass("cke_"+b):c.removeClass("cke_ltr").removeClass("cke_rtl");d.setAttribute("style",CKEDITOR.skin.getIconStyle(n,"rtl"==b,this.icon,this.iconOffset))},this);d?(m=a.getCommandKeystroke(d))&&(k=CKEDITOR.tools.keystrokeToString(a.lang.common.keyboard,m)): -g+="off";m=this.name||this.command;var h=null,t=this.icon;n=m;this.icon&&!/\./.test(this.icon)?(n=this.icon,t=null):(this.icon&&(h=this.icon),CKEDITOR.env.hidpi&&this.iconHiDpi&&(h=this.iconHiDpi));h?(CKEDITOR.skin.addIcon(h,h),t=null):h=n;g={id:r,name:m,iconName:n,label:this.label,cls:(this.hasArrow?"cke_button_expandable ":"")+(this.className||""),state:g,ariaDisabled:"disabled"==g?"true":"false",title:this.title+(k?" ("+k.display+")":""),ariaShortcutSpace:k?"\x26nbsp;":"",ariaShortcut:k?a.lang.common.keyboardShortcut+ -" "+k.aria:"",titleJs:q.gecko&&!q.hc?"":(this.title||"").replace("'",""),hasArrow:"string"===typeof this.hasArrow&&this.hasArrow||(this.hasArrow?"true":"false"),keydownFn:x,focusFn:y,clickFn:l,style:CKEDITOR.skin.getIconStyle(h,"rtl"==a.lang.dir,t,this.iconOffset),arrowHtml:this.hasArrow?v.output():""};w.output(g,b);if(this.onRender)this.onRender();return e},setState:function(a){if(this._.state==a)return!1;this._.state=a;var b=CKEDITOR.document.getById(this._.id);return b?(b.setState(a,"cke_button"), -b.setAttribute("aria-disabled",a==CKEDITOR.TRISTATE_DISABLED),this.hasArrow?b.setAttribute("aria-expanded",a==CKEDITOR.TRISTATE_ON):a===CKEDITOR.TRISTATE_ON?b.setAttribute("aria-pressed",!0):b.removeAttribute("aria-pressed"),!0):!1},getState:function(){return this._.state},toFeature:function(a){if(this._.feature)return this._.feature;var b=this;this.allowedContent||this.requiredContent||!this.command||(b=a.getCommand(this.command)||b);return this._.feature=b}};CKEDITOR.ui.prototype.addButton=function(a, -b){this.add(a,CKEDITOR.UI_BUTTON,b)}})();(function(){function D(a){function d(){for(var b=f(),e=CKEDITOR.tools.clone(a.config.toolbarGroups)||v(a),n=0;na.order?-1:0>b.order?1:b.order]+data-cke-bookmark[^<]*?<\/span>/ig, -"");d&&u(a,c)})}function q(){if("wysiwyg"==a.mode){var b=t("paste");a.getCommand("cut").setState(t("cut"));a.getCommand("copy").setState(t("copy"));a.getCommand("paste").setState(b);a.fire("pasteState",b)}}function t(b){var c=a.getSelection(),c=c&&c.getRanges()[0];if((a.readOnly||c&&c.checkReadOnly())&&b in{paste:1,cut:1})return CKEDITOR.TRISTATE_DISABLED;if("paste"==b)return CKEDITOR.TRISTATE_OFF;b=a.getSelection();c=b.getRanges();return b.getType()==CKEDITOR.SELECTION_NONE||1==c.length&&c[0].collapsed? -CKEDITOR.TRISTATE_DISABLED:CKEDITOR.TRISTATE_OFF}var n=CKEDITOR.plugins.clipboard,v=0,p=0;(function(){a.on("key",h);a.on("contentDom",b);a.on("selectionChange",q);if(a.contextMenu){a.contextMenu.addListener(function(){return{cut:t("cut"),copy:t("copy"),paste:t("paste")}});var c=null;a.on("menuShow",function(){c&&(c.removeListener(),c=null);var b=a.contextMenu.findItemByCommandName("paste");b&&b.element&&(c=b.element.on("touchend",function(){a._.forcePasteDialog=!0}))})}if(a.ui.addButton)a.once("instanceReady", -function(){a._.pasteButtons&&CKEDITOR.tools.array.forEach(a._.pasteButtons,function(b){if(b=a.ui.get(b))if(b=CKEDITOR.document.getById(b._.id))b.on("touchend",function(){a._.forcePasteDialog=!0})})})})();(function(){function b(c,d,h,k,f){var m=a.lang.clipboard[d];a.addCommand(d,h);a.ui.addButton&&a.ui.addButton(c,{label:m,command:d,toolbar:"clipboard,"+k});a.addMenuItems&&a.addMenuItem(d,{label:m,command:d,group:"clipboard",order:f})}b("Cut","cut",c("cut"),10,1);b("Copy","copy",c("copy"),20,4);b("Paste", -"paste",d(),30,8);a._.pasteButtons||(a._.pasteButtons=[]);a._.pasteButtons.push("Paste")})();a.getClipboardData=function(b,c){function d(a){a.removeListener();a.cancel();c(a.data)}function h(a){a.removeListener();a.cancel();c({type:f,dataValue:a.data.dataValue,dataTransfer:a.data.dataTransfer,method:"paste"})}var k=!1,f="auto";c||(c=b,b=null);a.on("beforePaste",function(a){a.removeListener();k=!0;f=a.data.type},null,null,1E3);a.on("paste",d,null,null,0);!1===r()&&(a.removeListener("paste",d),a._.forcePasteDialog&& -k&&a.fire("pasteDialog")?(a.on("pasteDialogCommit",h),a.on("dialogHide",function(a){a.removeListener();a.data.removeListener("pasteDialogCommit",h);a.data._.committed||c(null)})):c(null))}}function y(a){if(CKEDITOR.env.webkit){if(!a.match(/^[^<]*$/g)&&!a.match(/^(
    <\/div>|
    [^<]*<\/div>)*$/gi))return"html"}else if(CKEDITOR.env.ie){if(!a.match(/^([^<]|)*$/gi)&&!a.match(/^(

    ([^<]|)*<\/p>|(\r\n))*$/gi))return"html"}else if(CKEDITOR.env.gecko){if(!a.match(/^([^<]|)*$/gi))return"html"}else return"html"; -return"htmlifiedtext"}function z(a,b){function c(a){return CKEDITOR.tools.repeat("\x3c/p\x3e\x3cp\x3e",~~(a/2))+(1==a%2?"\x3cbr\x3e":"")}b=b.replace(/(?!\u3000)\s+/g," ").replace(/> +/gi,"\x3cbr\x3e");b=b.replace(/<\/?[A-Z]+>/g,function(a){return a.toLowerCase()});if(b.match(/^[^<]$/))return b;CKEDITOR.env.webkit&&-1(
    |)<\/div>)(?!$|(

    (
    |)<\/div>))/g,"\x3cbr\x3e").replace(/^(
    (
    |)<\/div>){2}(?!$)/g,"\x3cdiv\x3e\x3c/div\x3e"), -b.match(/
    (
    |)<\/div>/)&&(b="\x3cp\x3e"+b.replace(/(
    (
    |)<\/div>)+/g,function(a){return c(a.split("\x3c/div\x3e\x3cdiv\x3e").length+1)})+"\x3c/p\x3e"),b=b.replace(/<\/div>
    /g,"\x3cbr\x3e"),b=b.replace(/<\/?div>/g,""));CKEDITOR.env.gecko&&a.enterMode!=CKEDITOR.ENTER_BR&&(CKEDITOR.env.gecko&&(b=b.replace(/^

    $/,"\x3cbr\x3e")),-1){2,}/g,function(a){return c(a.length/4)})+"\x3c/p\x3e"));return A(a,b)}function B(a){function b(){var a= -{},b;for(b in CKEDITOR.dtd)"$"!=b.charAt(0)&&"div"!=b&&"span"!=b&&(a[b]=1);return a}var c={};return{get:function(d){return"plain-text"==d?c.plainText||(c.plainText=new CKEDITOR.filter(a,"br")):"semantic-content"==d?((d=c.semanticContent)||(d=new CKEDITOR.filter(a,{}),d.allow({$1:{elements:b(),attributes:!0,styles:!1,classes:!1}}),d=c.semanticContent=d),d):d?new CKEDITOR.filter(a,d):null}}}function w(a,b,c){b=CKEDITOR.htmlParser.fragment.fromHtml(b);var d=new CKEDITOR.htmlParser.basicWriter;c.applyTo(b, -!0,!1,a.activeEnterMode);b.writeHtml(d);return d.getHtml()}function A(a,b){a.enterMode==CKEDITOR.ENTER_BR?b=b.replace(/(<\/p>

    )+/g,function(a){return CKEDITOR.tools.repeat("\x3cbr\x3e",a.length/7*2)}).replace(/<\/?p>/g,""):a.enterMode==CKEDITOR.ENTER_DIV&&(b=b.replace(/<(\/)?p>/g,"\x3c$1div\x3e"));return b}function C(a){a.data.preventDefault();a.data.$.dataTransfer.dropEffect="none"}function D(a){var b=CKEDITOR.plugins.clipboard;a.on("contentDom",function(){function c(b,c,d){c.select();u(a,{dataTransfer:d, -method:"drop"},1);d.sourceEditor.fire("saveSnapshot");d.sourceEditor.editable().extractHtmlFromRange(b);d.sourceEditor.getSelection().selectRanges([b]);d.sourceEditor.fire("saveSnapshot")}function d(c,d){c.select();u(a,{dataTransfer:d,method:"drop"},1);b.resetDragDataTransfer()}function e(b,c,d){var k={$:b.data.$,target:b.data.getTarget()};c&&(k.dragRange=c);d&&(k.dropRange=d);!1===a.fire(b.name,k)&&b.data.preventDefault()}function g(a){a.type!=CKEDITOR.NODE_ELEMENT&&(a=a.getParent());return a.getChildCount()} -var f=a.editable(),l=CKEDITOR.plugins.clipboard.getDropTarget(a),k=a.ui.space("top"),r=a.ui.space("bottom");b.preventDefaultDropOnElement(k);b.preventDefaultDropOnElement(r);f.attachListener(l,"dragstart",e);f.attachListener(a,"dragstart",b.resetDragDataTransfer,b,null,1);f.attachListener(a,"dragstart",function(c){b.initDragDataTransfer(c,a)},null,null,2);f.attachListener(a,"dragstart",function(){var c=b.dragRange=a.getSelection().getRanges()[0];CKEDITOR.env.ie&&10>CKEDITOR.env.version&&(b.dragStartContainerChildCount= -c?g(c.startContainer):null,b.dragEndContainerChildCount=c?g(c.endContainer):null)},null,null,100);f.attachListener(l,"dragend",e);f.attachListener(a,"dragend",b.initDragDataTransfer,b,null,1);f.attachListener(a,"dragend",b.resetDragDataTransfer,b,null,100);f.attachListener(l,"dragover",function(a){if(CKEDITOR.env.edge)a.data.preventDefault();else{var b=a.data.getTarget();b&&b.is&&b.is("html")?a.data.preventDefault():CKEDITOR.env.ie&&CKEDITOR.plugins.clipboard.isFileApiSupported&&a.data.$.dataTransfer.types.contains("Files")&& -a.data.preventDefault()}});f.attachListener(l,"drop",function(c){if(!c.data.$.defaultPrevented&&(c.data.preventDefault(),!a.readOnly)){var d=c.data.getTarget();if(!d.isReadOnly()||d.type==CKEDITOR.NODE_ELEMENT&&d.is("html")){var d=b.getRangeAtDropPosition(c,a),k=b.dragRange;d&&e(c,k,d)}}},null,null,9999);f.attachListener(a,"drop",b.initDragDataTransfer,b,null,1);f.attachListener(a,"drop",function(k){if(k=k.data){var f=k.dropRange,r=k.dragRange,e=k.dataTransfer;e.getTransferType(a)==CKEDITOR.DATA_TRANSFER_INTERNAL? -setTimeout(function(){b.internalDrop(r,f,e,a)},0):e.getTransferType(a)==CKEDITOR.DATA_TRANSFER_CROSS_EDITORS?c(r,f,e):d(f,e)}},null,null,9999)})}var p;CKEDITOR.plugins.add("clipboard",{requires:"dialog,notification,toolbar",init:function(a){function b(b){b=CKEDITOR.tools.array.map(b,function(a){return a.split("/")[1].toUpperCase()}).join(", ");return a.lang.clipboard.fileFormatNotSupportedNotification.replace(/\${formats\}/g,b)}function c(a,b){return CKEDITOR.env.ie&&a.data.fileTransferCancel||!(CKEDITOR.env.ie|| -b&&l!==b.id)?!1:b.isFileTransfer()&&1===b.getFilesCount()}var d,e=B(a);a.config.forcePasteAsPlainText?d="plain-text":a.config.pasteFilter?d=a.config.pasteFilter:!CKEDITOR.env.webkit||"pasteFilter"in a.config||(d="semantic-content");a.pasteFilter=e.get(d);x(a);D(a);CKEDITOR.dialog.add("paste",CKEDITOR.getUrl(this.path+"dialogs/paste.js"));if((CKEDITOR.plugins.clipboard.isCustomDataTypesSupported||CKEDITOR.plugins.clipboard.isFileApiSupported)&&a.config.clipboard_handleImages){var g=["image/png","image/jpeg", -"image/gif"],f=b(g),l;a.on("paste",function(b){var d=b.data,h=d.dataTransfer;if(!d.dataValue&&c(b,h))if(h=h.getFile(0),-1===CKEDITOR.tools.indexOf(g,h.type))a.showNotification(f,"info",a.config.clipboard_notificationDuration);else{var e=new FileReader;e.addEventListener("load",function(){b.data.dataValue='\x3cimg src\x3d"'+e.result+'" /\x3e';a.fire("paste",b.data)},!1);e.addEventListener("abort",function(){CKEDITOR.env.ie&&(b.data.fileTransferCancel=!0);a.fire("paste",b.data)},!1);e.addEventListener("error", -function(){CKEDITOR.env.ie&&(b.data.fileTransferCancel=!0);a.fire("paste",b.data)},!1);e.readAsDataURL(h);l=d.dataTransfer.id;b.stop()}},null,null,1)}a.on("paste",function(b){b.data.dataTransfer||(b.data.dataTransfer=new CKEDITOR.plugins.clipboard.dataTransfer);if(!b.data.dataValue){var c=b.data.dataTransfer,d=c.getData("text/html");if(d)b.data.dataValue=d,b.data.type="html";else if(d=c.getData("text/plain"))b.data.dataValue=a.editable().transformPlainTextToHtml(d),b.data.type="text"}},null,null, -1);a.on("paste",function(a){var b=a.data.dataValue,c=CKEDITOR.dtd.$block;-1 <\/span>/gi," "),"html"!=a.data.type&&(b=b.replace(/]*>([^<]*)<\/span>/gi,function(a,b){return b.replace(/\t/g,"\x26nbsp;\x26nbsp; \x26nbsp;")})),-1/,"")), -b=b.replace(/(<[^>]+) class="Apple-[^"]*"/gi,"$1"));if(b.match(/^<[^<]+cke_(editable|contents)/i)){var d,f,e=new CKEDITOR.dom.element("div");for(e.setHtml(b);1==e.getChildCount()&&(d=e.getFirst())&&d.type==CKEDITOR.NODE_ELEMENT&&(d.hasClass("cke_editable")||d.hasClass("cke_contents"));)e=f=d;f&&(b=f.getHtml().replace(/
    $/i,""))}CKEDITOR.env.ie?b=b.replace(/^ (?: |\r\n)?<(\w+)/g,function(b,d){return d.toLowerCase()in c?(a.data.preSniffing="html","\x3c"+d):b}):CKEDITOR.env.webkit?b=b.replace(/<\/(\w+)>


    <\/div>$/, -function(b,d){return d in c?(a.data.endsWithEOL=1,"\x3c/"+d+"\x3e"):b}):CKEDITOR.env.gecko&&(b=b.replace(/(\s)
    $/,"$1"));a.data.dataValue=b},null,null,3);a.on("paste",function(b){b=b.data;var c=a._.nextPasteType||b.type,d=b.dataValue,f,g=a.config.clipboard_defaultContentType||"html",l=b.dataTransfer.getTransferType(a)==CKEDITOR.DATA_TRANSFER_EXTERNAL,n=!0===a.config.forcePasteAsPlainText;f="html"==c||"html"==b.preSniffing?"html":y(d);delete a._.nextPasteType;"htmlifiedtext"==f&&(d=z(a.config,d)); -if("text"==c&&"html"==f)d=w(a,d,e.get("plain-text"));else if(l&&a.pasteFilter&&!b.dontFilter||n)d=w(a,d,a.pasteFilter);b.startsWithEOL&&(d='\x3cbr data-cke-eol\x3d"1"\x3e'+d);b.endsWithEOL&&(d+='\x3cbr data-cke-eol\x3d"1"\x3e');"auto"==c&&(c="html"==f||"html"==g?"html":"text");b.type=c;b.dataValue=d;delete b.preSniffing;delete b.startsWithEOL;delete b.endsWithEOL},null,null,6);a.on("paste",function(b){b=b.data;b.dataValue&&(a.insertHtml(b.dataValue,b.type,b.range),setTimeout(function(){a.fire("afterPaste")}, -0))},null,null,1E3);a.on("pasteDialog",function(b){setTimeout(function(){a.openDialog("paste",b.data)},0)})}});CKEDITOR.plugins.clipboard={isCustomCopyCutSupported:CKEDITOR.env.ie&&16>CKEDITOR.env.version||CKEDITOR.env.iOS&&605>CKEDITOR.env.version?!1:!0,isCustomDataTypesSupported:!CKEDITOR.env.ie||16<=CKEDITOR.env.version,isFileApiSupported:!CKEDITOR.env.ie||9CKEDITOR.env.version||b.isInline()?b:a.document},fixSplitNodesAfterDrop:function(a,b,c,d){function e(a,c,d){var e=a;e.type==CKEDITOR.NODE_TEXT&&(e=a.getParent());if(e.equals(c)&&d!=c.getChildCount())return a=b.startContainer.getChild(b.startOffset-1),c=b.startContainer.getChild(b.startOffset),a&&a.type==CKEDITOR.NODE_TEXT&&c&&c.type==CKEDITOR.NODE_TEXT&&(d=a.getLength(),a.setText(a.getText()+c.getText()),c.remove(),b.setStart(a,d),b.collapse(!0)),!0}var g=b.startContainer;"number"==typeof d&&"number"== -typeof c&&g.type==CKEDITOR.NODE_ELEMENT&&(e(a.startContainer,g,c)||e(a.endContainer,g,d))},isDropRangeAffectedByDragRange:function(a,b){var c=b.startContainer,d=b.endOffset;return a.endContainer.equals(c)&&a.endOffset<=d||a.startContainer.getParent().equals(c)&&a.startContainer.getIndex()CKEDITOR.env.version&&this.fixSplitNodesAfterDrop(a,b,e.dragStartContainerChildCount,e.dragEndContainerChildCount);(l=this.isDropRangeAffectedByDragRange(a,b))||(f=a.createBookmark(!1));e=b.clone().createBookmark(!1);l&&(f=a.createBookmark(!1));a=f.startNode;b=f.endNode;l=e.startNode;b&&a.getPosition(l)&CKEDITOR.POSITION_PRECEDING&&b.getPosition(l)&CKEDITOR.POSITION_FOLLOWING&&l.insertBefore(a);a=d.createRange();a.moveToBookmark(f);g.extractHtmlFromRange(a,1);b=d.createRange(); -e.startNode.getCommonAncestor(g)||(e=d.getSelection().createBookmarks()[0]);b.moveToBookmark(e);u(d,{dataTransfer:c,method:"drop",range:b},1);d.fire("unlockSnapshot")},getRangeAtDropPosition:function(a,b){var c=a.data.$,d=c.clientX,e=c.clientY,g=b.getSelection(!0).getRanges()[0],f=b.createRange();if(a.data.testRange)return a.data.testRange;if(document.caretRangeFromPoint&&b.document.$.caretRangeFromPoint(d,e))c=b.document.$.caretRangeFromPoint(d,e),f.setStart(CKEDITOR.dom.node(c.startContainer),c.startOffset), -f.collapse(!0);else if(c.rangeParent)f.setStart(CKEDITOR.dom.node(c.rangeParent),c.rangeOffset),f.collapse(!0);else{if(CKEDITOR.env.ie&&8k&&!l;k++){if(!l)try{c.moveToPoint(d,e-k),l=!0}catch(p){}if(!l)try{c.moveToPoint(d,e+k),l=!0}catch(h){}}if(l){var m="cke-temp-"+(new Date).getTime();c.pasteHTML('\x3cspan id\x3d"'+m+'"\x3e​\x3c/span\x3e'); -var q=b.document.getById(m);f.moveToPosition(q,CKEDITOR.POSITION_BEFORE_START);q.remove()}else{var t=b.document.$.elementFromPoint(d,e),n=new CKEDITOR.dom.element(t),v;if(n.equals(b.editable())||"html"==n.getName())return g&&g.startContainer&&!g.startContainer.equals(b.editable())?g:null;v=n.getClientRect();d/i,fragmentRegExp:/\s*\x3c!--StartFragment--\x3e|\x3c!--EndFragment--\x3e\s*/g, -types:[],data:{},files:[],nativeHtmlCache:"",normalizeType:function(a){a=a.toLowerCase();return"text"==a||"text/plain"==a?"Text":"url"==a?"URL":"files"===a?"Files":a}};this._.fallbackDataTransfer=new CKEDITOR.plugins.clipboard.fallbackDataTransfer(this);this.id=this.getData(p);this.id||(this.id="Text"==p?"":"cke-"+CKEDITOR.tools.getUniqueId());b&&(this.sourceEditor=b,this.setData("text/html",b.getSelectedHtml(1)),"Text"==p||this.getData("text/plain")||this.setData("text/plain",b.getSelection().getSelectedText()))}; -CKEDITOR.DATA_TRANSFER_INTERNAL=1;CKEDITOR.DATA_TRANSFER_CROSS_EDITORS=2;CKEDITOR.DATA_TRANSFER_EXTERNAL=3;CKEDITOR.plugins.clipboard.dataTransfer.prototype={getData:function(a,b){a=this._.normalizeType(a);var c="text/html"==a&&b?this._.nativeHtmlCache:this._.data[a];if(void 0===c||null===c||""===c){if(this._.fallbackDataTransfer.isRequired())c=this._.fallbackDataTransfer.getData(a,b);else try{c=this.$.getData(a)||""}catch(d){c=""}"text/html"!=a||b||(c=this._stripHtml(c))}"Text"==a&&CKEDITOR.env.gecko&& -this.getFilesCount()&&"file://"==c.substring(0,7)&&(c="");if("string"===typeof c)var e=c.indexOf("\x3c/html\x3e"),c=-1!==e?c.substring(0,e+7):c;return c},setData:function(a,b){a=this._.normalizeType(a);"text/html"==a?(this._.data[a]=this._stripHtml(b),this._.nativeHtmlCache=b):this._.data[a]=b;if(CKEDITOR.plugins.clipboard.isCustomDataTypesSupported||"URL"==a||"Text"==a)if("Text"==p&&"Text"==a&&(this.id=b),this._.fallbackDataTransfer.isRequired())this._.fallbackDataTransfer.setData(a,b);else try{this.$.setData(a, -b)}catch(c){}},storeId:function(){"Text"!==p&&this.setData(p,this.id)},getTransferType:function(a){return this.sourceEditor?this.sourceEditor==a?CKEDITOR.DATA_TRANSFER_INTERNAL:CKEDITOR.DATA_TRANSFER_CROSS_EDITORS:CKEDITOR.DATA_TRANSFER_EXTERNAL},cacheData:function(){function a(a){a=b._.normalizeType(a);var c=b.getData(a);"text/html"==a&&(b._.nativeHtmlCache=b.getData(a,!0),c=b._stripHtml(c));c&&(b._.data[a]=c);b._.types.push(a)}if(this.$){var b=this,c,d,e;if(CKEDITOR.plugins.clipboard.isCustomDataTypesSupported){if(this.$.types)for(c= -0;c$/gi,"")}a&&a.length&&(a=b(a),a=a.replace(this._.metaRegExp,""),a=a.replace(this._.fragmentRegExp,""));return a}};CKEDITOR.plugins.clipboard.fallbackDataTransfer=function(a){this._dataTransfer=a;this._customDataFallbackType="text/html"};CKEDITOR.plugins.clipboard.fallbackDataTransfer._isCustomMimeTypeSupported= -null;CKEDITOR.plugins.clipboard.fallbackDataTransfer._customTypes=[];CKEDITOR.plugins.clipboard.fallbackDataTransfer.prototype={isRequired:function(){var a=CKEDITOR.plugins.clipboard.fallbackDataTransfer,b=this._dataTransfer.$;if(null===a._isCustomMimeTypeSupported)if(b){a._isCustomMimeTypeSupported=!1;if(CKEDITOR.env.edge&&17<=CKEDITOR.env.version)return!0;try{b.setData("cke/mimetypetest","cke test value"),a._isCustomMimeTypeSupported="cke test value"===b.getData("cke/mimetypetest"),b.clearData("cke/mimetypetest")}catch(c){}}else return!1; -return!a._isCustomMimeTypeSupported},getData:function(a,b){var c=this._getData(this._customDataFallbackType,!0);if(b)return c;var c=this._extractDataComment(c),d=null,d=a===this._customDataFallbackType?c.content:c.data&&c.data[a]?c.data[a]:this._getData(a,!0);return null!==d?d:""},setData:function(a,b){var c=a===this._customDataFallbackType;c&&(b=this._applyDataComment(b,this._getFallbackTypeData()));var d=b,e=this._dataTransfer.$;try{e.setData(a,d),c&&(this._dataTransfer._.nativeHtmlCache=d)}catch(g){if(this._isUnsupportedMimeTypeError(g)){c= -CKEDITOR.plugins.clipboard.fallbackDataTransfer;-1===CKEDITOR.tools.indexOf(c._customTypes,a)&&c._customTypes.push(a);var c=this._getFallbackTypeContent(),f=this._getFallbackTypeData();f[a]=d;try{d=this._applyDataComment(c,f),e.setData(this._customDataFallbackType,d),this._dataTransfer._.nativeHtmlCache=d}catch(l){d=""}}}return d},_getData:function(a,b){var c=this._dataTransfer._.data;if(!b&&c[a])return c[a];try{return this._dataTransfer.$.getData(a)}catch(d){return null}},_getFallbackTypeContent:function(){var a= -this._dataTransfer._.data[this._customDataFallbackType];a||(a=this._extractDataComment(this._getData(this._customDataFallbackType,!0)).content);return a},_getFallbackTypeData:function(){var a=CKEDITOR.plugins.clipboard.fallbackDataTransfer._customTypes,b=this._extractDataComment(this._getData(this._customDataFallbackType,!0)).data||{},c=this._dataTransfer._.data;CKEDITOR.tools.array.forEach(a,function(a){void 0!==c[a]?b[a]=c[a]:void 0!==b[a]&&(b[a]=b[a])},this);return b},_isUnsupportedMimeTypeError:function(a){return a.message&& --1!==a.message.search(/element not found/gi)},_extractDataComment:function(a){var b={data:null,content:a||""};if(a&&16b.order?-1:0>a.order?1:a.order]+data-cke-bookmark[^<]*?<\/span>/ig, +"");h&&t(a,c)})}function p(){if("wysiwyg"==a.mode){var b=k("paste");a.getCommand("cut").setState(k("cut"));a.getCommand("copy").setState(k("copy"));a.getCommand("paste").setState(b);a.fire("pasteState",b)}}function k(b){var c=a.getSelection(),c=c&&c.getRanges()[0];if((a.readOnly||c&&c.checkReadOnly())&&b in{paste:1,cut:1})return CKEDITOR.TRISTATE_DISABLED;if("paste"==b)return CKEDITOR.TRISTATE_OFF;b=a.getSelection();c=b.getRanges();return b.getType()==CKEDITOR.SELECTION_NONE||1==c.length&&c[0].collapsed? +CKEDITOR.TRISTATE_DISABLED:CKEDITOR.TRISTATE_OFF}var n=CKEDITOR.plugins.clipboard,u=0,w=0;(function(){a.on("key",h);a.on("contentDom",b);a.on("selectionChange",p);if(a.contextMenu){a.contextMenu.addListener(function(){return{cut:k("cut"),copy:k("copy"),paste:k("paste")}});var c=null;a.on("menuShow",function(){c&&(c.removeListener(),c=null);var b=a.contextMenu.findItemByCommandName("paste");b&&b.element&&(c=b.element.on("touchend",function(){a._.forcePasteDialog=!0}))})}if(a.ui.addButton)a.once("instanceReady", +function(){a._.pasteButtons&&CKEDITOR.tools.array.forEach(a._.pasteButtons,function(b){if(b=a.ui.get(b))if(b=CKEDITOR.document.getById(b._.id))b.on("touchend",function(){a._.forcePasteDialog=!0})})})})();(function(){function b(c,h,d,m,e){var p=a.lang.clipboard[h];a.addCommand(h,d);a.ui.addButton&&a.ui.addButton(c,{label:p,command:h,toolbar:"clipboard,"+m});a.addMenuItems&&a.addMenuItem(h,{label:p,command:h,group:"clipboard",order:e})}b("Cut","cut",c("cut"),10,1);b("Copy","copy",c("copy"),20,4);b("Paste", +"paste",d(),30,8);a._.pasteButtons||(a._.pasteButtons=[]);a._.pasteButtons.push("Paste")})();a.getClipboardData=function(b,c){function h(a){a.removeListener();a.cancel();c(a.data)}function d(a){a.removeListener();a.cancel();c({type:e,dataValue:a.data.dataValue,dataTransfer:a.data.dataTransfer,method:"paste"})}var m=!1,e="auto";c||(c=b,b=null);a.on("beforePaste",function(a){a.removeListener();m=!0;e=a.data.type},null,null,1E3);a.on("paste",h,null,null,0);!1===v()&&(a.removeListener("paste",h),a._.forcePasteDialog&& +m&&a.fire("pasteDialog")?(a.on("pasteDialogCommit",d),a.on("dialogHide",function(a){a.removeListener();a.data.removeListener("pasteDialogCommit",d);a.data._.committed||c(null)})):c(null))}}function z(a){if(CKEDITOR.env.webkit){if(!a.match(/^[^<]*$/g)&&!a.match(/^(
    <\/div>|
    [^<]*<\/div>)*$/gi))return"html"}else if(CKEDITOR.env.ie){if(!a.match(/^([^<]|)*$/gi)&&!a.match(/^(

    ([^<]|)*<\/p>|(\r\n))*$/gi))return"html"}else if(CKEDITOR.env.gecko){if(!a.match(/^([^<]|)*$/gi))return"html"}else return"html"; +return"htmlifiedtext"}function A(a,b){function c(a){return CKEDITOR.tools.repeat("\x3c/p\x3e\x3cp\x3e",~~(a/2))+(1==a%2?"\x3cbr\x3e":"")}b=b.replace(/(?!\u3000)\s+/g," ").replace(/> +/gi,"\x3cbr\x3e");b=b.replace(/<\/?[A-Z]+>/g,function(a){return a.toLowerCase()});if(b.match(/^[^<]$/))return b;CKEDITOR.env.webkit&&-1(
    |)<\/div>)(?!$|(

    (
    |)<\/div>))/g,"\x3cbr\x3e").replace(/^(
    (
    |)<\/div>){2}(?!$)/g,"\x3cdiv\x3e\x3c/div\x3e"), +b.match(/
    (
    |)<\/div>/)&&(b="\x3cp\x3e"+b.replace(/(
    (
    |)<\/div>)+/g,function(a){return c(a.split("\x3c/div\x3e\x3cdiv\x3e").length+1)})+"\x3c/p\x3e"),b=b.replace(/<\/div>
    /g,"\x3cbr\x3e"),b=b.replace(/<\/?div>/g,""));CKEDITOR.env.gecko&&a.enterMode!=CKEDITOR.ENTER_BR&&(CKEDITOR.env.gecko&&(b=b.replace(/^

    $/,"\x3cbr\x3e")),-1){2,}/g,function(a){return c(a.length/4)})+"\x3c/p\x3e"));return B(a,b)}function C(a){function b(){var a= +{},b;for(b in CKEDITOR.dtd)"$"!=b.charAt(0)&&"div"!=b&&"span"!=b&&(a[b]=1);return a}var c={};return{get:function(d){return"plain-text"==d?c.plainText||(c.plainText=new CKEDITOR.filter(a,"br")):"semantic-content"==d?((d=c.semanticContent)||(d=new CKEDITOR.filter(a,{}),d.allow({$1:{elements:b(),attributes:!0,styles:!1,classes:!1}}),d=c.semanticContent=d),d):d?new CKEDITOR.filter(a,d):null}}}function x(a,b,c){b=CKEDITOR.htmlParser.fragment.fromHtml(b);var d=new CKEDITOR.htmlParser.basicWriter;c.applyTo(b, +!0,!1,a.activeEnterMode);b.writeHtml(d);return d.getHtml()}function B(a,b){a.enterMode==CKEDITOR.ENTER_BR?b=b.replace(/(<\/p>

    )+/g,function(a){return CKEDITOR.tools.repeat("\x3cbr\x3e",a.length/7*2)}).replace(/<\/?p>/g,""):a.enterMode==CKEDITOR.ENTER_DIV&&(b=b.replace(/<(\/)?p>/g,"\x3c$1div\x3e"));return b}function D(a){a.data.preventDefault();a.data.$.dataTransfer.dropEffect="none"}function E(a){var b=CKEDITOR.plugins.clipboard;a.on("contentDom",function(){function c(b,c,d){c.select();t(a,{dataTransfer:d, +method:"drop"},1);d.sourceEditor.fire("saveSnapshot");d.sourceEditor.editable().extractHtmlFromRange(b);d.sourceEditor.getSelection().selectRanges([b]);d.sourceEditor.fire("saveSnapshot")}function d(c,d){c.select();t(a,{dataTransfer:d,method:"drop"},1);b.resetDragDataTransfer()}function g(b,c,d){var e={$:b.data.$,target:b.data.getTarget()};c&&(e.dragRange=c);d&&(e.dropRange=d);!1===a.fire(b.name,e)&&b.data.preventDefault()}function f(a){a.type!=CKEDITOR.NODE_ELEMENT&&(a=a.getParent());return a.getChildCount()} +var e=a.editable(),l=CKEDITOR.plugins.clipboard.getDropTarget(a),q=a.ui.space("top"),v=a.ui.space("bottom");b.preventDefaultDropOnElement(q);b.preventDefaultDropOnElement(v);e.attachListener(l,"dragstart",g);e.attachListener(a,"dragstart",b.resetDragDataTransfer,b,null,1);e.attachListener(a,"dragstart",function(c){b.initDragDataTransfer(c,a)},null,null,2);e.attachListener(a,"dragstart",function(){var c=b.dragRange=a.getSelection().getRanges()[0];CKEDITOR.env.ie&&10>CKEDITOR.env.version&&(b.dragStartContainerChildCount= +c?f(c.startContainer):null,b.dragEndContainerChildCount=c?f(c.endContainer):null)},null,null,100);e.attachListener(l,"dragend",g);e.attachListener(a,"dragend",b.initDragDataTransfer,b,null,1);e.attachListener(a,"dragend",b.resetDragDataTransfer,b,null,100);e.attachListener(l,"dragover",function(a){if(CKEDITOR.env.edge)a.data.preventDefault();else{var b=a.data.getTarget();b&&b.is&&b.is("html")?a.data.preventDefault():CKEDITOR.env.ie&&CKEDITOR.plugins.clipboard.isFileApiSupported&&a.data.$.dataTransfer.types.contains("Files")&& +a.data.preventDefault()}});e.attachListener(l,"drop",function(c){if(!c.data.$.defaultPrevented&&(c.data.preventDefault(),!a.readOnly)){var d=c.data.getTarget();if(!d.isReadOnly()||d.type==CKEDITOR.NODE_ELEMENT&&d.is("html")){var d=b.getRangeAtDropPosition(c,a),e=b.dragRange;d&&g(c,e,d)}}},null,null,9999);e.attachListener(a,"drop",b.initDragDataTransfer,b,null,1);e.attachListener(a,"drop",function(h){if(h=h.data){var e=h.dropRange,p=h.dragRange,k=h.dataTransfer;k.getTransferType(a)==CKEDITOR.DATA_TRANSFER_INTERNAL? +setTimeout(function(){b.internalDrop(p,e,k,a)},0):k.getTransferType(a)==CKEDITOR.DATA_TRANSFER_CROSS_EDITORS?c(p,e,k):d(e,k)}},null,null,9999)})}var r;CKEDITOR.plugins.add("clipboard",{requires:"dialog,notification,toolbar",_supportedFileMatchers:[],init:function(a){function b(b){return a.config.clipboard_handleImages?-1!==CKEDITOR.tools.indexOf(["image/png","image/jpeg","image/gif"],b.type):!1}function c(b){return CKEDITOR.tools.array.some(a.plugins.clipboard._supportedFileMatchers,function(a){return a(b)})} +function d(b){b.length&&(b=CKEDITOR.tools.array.unique(b),b=CKEDITOR.tools.array.filter(b,function(a){return!!CKEDITOR.tools.trim(a)}),b=g(b.join(", ")),a.showNotification(b,"info",a.config.clipboard_notificationDuration))}function g(b){return b?a.lang.clipboard.fileFormatNotSupportedNotification.replace(/\${formats\}/g,"\x3cem\x3e"+b+"\x3c/em\x3e"):a.lang.clipboard.fileWithoutFormatNotSupportedNotification}function f(a,b){return CKEDITOR.env.ie&&a.data.fileTransferCancel||!(CKEDITOR.env.ie||b&&v!== +b.id)?!1:b.isFileTransfer()&&1===b.getFilesCount()}var e,l=C(a);a.config.forcePasteAsPlainText?e="plain-text":a.config.pasteFilter?e=a.config.pasteFilter:!CKEDITOR.env.webkit||"pasteFilter"in a.config||(e="semantic-content");a.pasteFilter=l.get(e);y(a);E(a);CKEDITOR.dialog.add("paste",CKEDITOR.getUrl(this.path+"dialogs/paste.js"));var q=CKEDITOR.plugins.clipboard.isCustomDataTypesSupported||CKEDITOR.plugins.clipboard.isFileApiSupported,v;CKEDITOR.plugins.clipboard.addFileMatcher(a,b);a.on("paste", +function(a){if(q){var b=a.data;a=b.dataTransfer;if(!b.dataValue){for(var b=[],e=0;e <\/span>/gi," "),"html"!=a.data.type&&(b=b.replace(/]*>([^<]*)<\/span>/gi,function(a,b){return b.replace(/\t/g,"\x26nbsp;\x26nbsp; \x26nbsp;")})),-1/,"")),b=b.replace(/(<[^>]+) class="Apple-[^"]*"/gi,"$1"));if(b.match(/^<[^<]+cke_(editable|contents)/i)){var d,e,f=new CKEDITOR.dom.element("div");for(f.setHtml(b);1==f.getChildCount()&&(d=f.getFirst())&&d.type==CKEDITOR.NODE_ELEMENT&&(d.hasClass("cke_editable")||d.hasClass("cke_contents"));)f=e=d;e&&(b=e.getHtml().replace(/
    $/i,""))}CKEDITOR.env.ie?b=b.replace(/^ (?: |\r\n)?<(\w+)/g,function(b,d){return d.toLowerCase()in c?(a.data.preSniffing= +"html","\x3c"+d):b}):CKEDITOR.env.webkit?b=b.replace(/<\/(\w+)>


    <\/div>$/,function(b,d){return d in c?(a.data.endsWithEOL=1,"\x3c/"+d+"\x3e"):b}):CKEDITOR.env.gecko&&(b=b.replace(/(\s)
    $/,"$1"));a.data.dataValue=b},null,null,3);a.on("paste",function(b){b=b.data;var c=a._.nextPasteType||b.type,d=b.dataValue,e,f=a.config.clipboard_defaultContentType||"html",g=b.dataTransfer.getTransferType(a)==CKEDITOR.DATA_TRANSFER_EXTERNAL,q=!0===a.config.forcePasteAsPlainText;e="html"==c||"html"==b.preSniffing? +"html":z(d);delete a._.nextPasteType;"htmlifiedtext"==e&&(d=A(a.config,d));if("text"==c&&"html"==e)d=x(a,d,l.get("plain-text"));else if(g&&a.pasteFilter&&!b.dontFilter||q)d=x(a,d,a.pasteFilter);b.startsWithEOL&&(d='\x3cbr data-cke-eol\x3d"1"\x3e'+d);b.endsWithEOL&&(d+='\x3cbr data-cke-eol\x3d"1"\x3e');"auto"==c&&(c="html"==e||"html"==f?"html":"text");b.type=c;b.dataValue=d;delete b.preSniffing;delete b.startsWithEOL;delete b.endsWithEOL},null,null,6);a.on("paste",function(b){b=b.data;b.dataValue&& +(a.insertHtml(b.dataValue,b.type,b.range),setTimeout(function(){a.fire("afterPaste")},0))},null,null,1E3);a.on("pasteDialog",function(b){setTimeout(function(){a.openDialog("paste",b.data)},0)})}});CKEDITOR.plugins.clipboard={addFileMatcher:function(a,b){a.plugins.clipboard._supportedFileMatchers.push(b)},isCustomCopyCutSupported:CKEDITOR.env.ie&&16>CKEDITOR.env.version||CKEDITOR.env.iOS&&605>CKEDITOR.env.version?!1:!0,isCustomDataTypesSupported:!CKEDITOR.env.ie||16<=CKEDITOR.env.version,isFileApiSupported:!CKEDITOR.env.ie|| +9CKEDITOR.env.version||b.isInline()?b:a.document},fixSplitNodesAfterDrop:function(a,b,c,d){function g(a,c,d){var f=a;f.type==CKEDITOR.NODE_TEXT&&(f=a.getParent());if(f.equals(c)&&d!=c.getChildCount())return a=b.startContainer.getChild(b.startOffset-1),c=b.startContainer.getChild(b.startOffset),a&&a.type==CKEDITOR.NODE_TEXT&&c&&c.type==CKEDITOR.NODE_TEXT&& +(d=a.getLength(),a.setText(a.getText()+c.getText()),c.remove(),b.setStart(a,d),b.collapse(!0)),!0}var f=b.startContainer;"number"==typeof d&&"number"==typeof c&&f.type==CKEDITOR.NODE_ELEMENT&&(g(a.startContainer,f,c)||g(a.endContainer,f,d))},isDropRangeAffectedByDragRange:function(a,b){var c=b.startContainer,d=b.endOffset;return a.endContainer.equals(c)&&a.endOffset<=d||a.startContainer.getParent().equals(c)&&a.startContainer.getIndex()CKEDITOR.env.version&&this.fixSplitNodesAfterDrop(a,b,g.dragStartContainerChildCount,g.dragEndContainerChildCount);(l=this.isDropRangeAffectedByDragRange(a,b))||(e=a.createBookmark(!1));g=b.clone().createBookmark(!1);l&&(e=a.createBookmark(!1));a=e.startNode;b=e.endNode;l=g.startNode;b&&a.getPosition(l)&CKEDITOR.POSITION_PRECEDING&& +b.getPosition(l)&CKEDITOR.POSITION_FOLLOWING&&l.insertBefore(a);a=d.createRange();a.moveToBookmark(e);f.extractHtmlFromRange(a,1);b=d.createRange();g.startNode.getCommonAncestor(f)||(g=d.getSelection().createBookmarks()[0]);b.moveToBookmark(g);t(d,{dataTransfer:c,method:"drop",range:b},1);d.fire("unlockSnapshot")},getRangeAtDropPosition:function(a,b){var c=a.data.$,d=c.clientX,g=c.clientY,f=b.getSelection(!0).getRanges()[0],e=b.createRange();if(a.data.testRange)return a.data.testRange;if(document.caretRangeFromPoint&& +b.document.$.caretRangeFromPoint(d,g))c=b.document.$.caretRangeFromPoint(d,g),e.setStart(CKEDITOR.dom.node(c.startContainer),c.startOffset),e.collapse(!0);else if(c.rangeParent)e.setStart(CKEDITOR.dom.node(c.rangeParent),c.rangeOffset),e.collapse(!0);else{if(CKEDITOR.env.ie&&8q&&!l;q++){if(!l)try{c.moveToPoint(d,g-q),l=!0}catch(r){}if(!l)try{c.moveToPoint(d, +g+q),l=!0}catch(h){}}if(l){var m="cke-temp-"+(new Date).getTime();c.pasteHTML('\x3cspan id\x3d"'+m+'"\x3e​\x3c/span\x3e');var p=b.document.getById(m);e.moveToPosition(p,CKEDITOR.POSITION_BEFORE_START);p.remove()}else{var k=b.document.$.elementFromPoint(d,g),n=new CKEDITOR.dom.element(k),u;if(n.equals(b.editable())||"html"==n.getName())return f&&f.startContainer&&!f.startContainer.equals(b.editable())?f:null;u=n.getClientRect();d/i,fragmentRegExp:/\s*\x3c!--StartFragment--\x3e|\x3c!--EndFragment--\x3e\s*/g,types:[],data:{},files:[],nativeHtmlCache:"",normalizeType:function(a){a=a.toLowerCase();return"text"==a||"text/plain"==a?"Text":"url"==a?"URL":"files"===a?"Files":a}};this._.fallbackDataTransfer=new CKEDITOR.plugins.clipboard.fallbackDataTransfer(this);this.id=this.getData(r);this.id||(this.id="Text"==r?"":"cke-"+CKEDITOR.tools.getUniqueId());b&&(this.sourceEditor= +b,this.setData("text/html",b.getSelectedHtml(1)),"Text"==r||this.getData("text/plain")||this.setData("text/plain",b.getSelection().getSelectedText()))};CKEDITOR.DATA_TRANSFER_INTERNAL=1;CKEDITOR.DATA_TRANSFER_CROSS_EDITORS=2;CKEDITOR.DATA_TRANSFER_EXTERNAL=3;CKEDITOR.plugins.clipboard.dataTransfer.prototype={getData:function(a,b){a=this._.normalizeType(a);var c="text/html"==a&&b?this._.nativeHtmlCache:this._.data[a];if(void 0===c||null===c||""===c){if(this._.fallbackDataTransfer.isRequired())c=this._.fallbackDataTransfer.getData(a, +b);else try{c=this.$.getData(a)||""}catch(d){c=""}"text/html"!=a||b||(c=this._stripHtml(c))}"Text"==a&&CKEDITOR.env.gecko&&this.getFilesCount()&&"file://"==c.substring(0,7)&&(c="");if("string"===typeof c)var g=c.indexOf("\x3c/html\x3e"),c=-1!==g?c.substring(0,g+7):c;return c},setData:function(a,b){a=this._.normalizeType(a);"text/html"==a?(this._.data[a]=this._stripHtml(b),this._.nativeHtmlCache=b):this._.data[a]=b;if(CKEDITOR.plugins.clipboard.isCustomDataTypesSupported||"URL"==a||"Text"==a)if("Text"== +r&&"Text"==a&&(this.id=b),this._.fallbackDataTransfer.isRequired())this._.fallbackDataTransfer.setData(a,b);else try{this.$.setData(a,b)}catch(c){}},storeId:function(){"Text"!==r&&this.setData(r,this.id)},getTransferType:function(a){return this.sourceEditor?this.sourceEditor==a?CKEDITOR.DATA_TRANSFER_INTERNAL:CKEDITOR.DATA_TRANSFER_CROSS_EDITORS:CKEDITOR.DATA_TRANSFER_EXTERNAL},cacheData:function(){function a(a){a=b._.normalizeType(a);var c=b.getData(a);"text/html"==a&&(b._.nativeHtmlCache=b.getData(a, +!0),c=b._stripHtml(c));c&&(b._.data[a]=c);b._.types.push(a)}if(this.$){var b=this,c,d,g;if(CKEDITOR.plugins.clipboard.isCustomDataTypesSupported){if(this.$.types)for(c=0;c$/gi,"")}a&&a.length&&(a=b(a),a=a.replace(this._.metaRegExp,""),a=a.replace(this._.fragmentRegExp,"")); +return a}};CKEDITOR.plugins.clipboard.fallbackDataTransfer=function(a){this._dataTransfer=a;this._customDataFallbackType="text/html"};CKEDITOR.plugins.clipboard.fallbackDataTransfer._isCustomMimeTypeSupported=null;CKEDITOR.plugins.clipboard.fallbackDataTransfer._customTypes=[];CKEDITOR.plugins.clipboard.fallbackDataTransfer.prototype={isRequired:function(){var a=CKEDITOR.plugins.clipboard.fallbackDataTransfer,b=this._dataTransfer.$;if(null===a._isCustomMimeTypeSupported)if(b){a._isCustomMimeTypeSupported= +!1;if(CKEDITOR.env.edge&&17<=CKEDITOR.env.version)return!0;try{b.setData("cke/mimetypetest","cke test value"),a._isCustomMimeTypeSupported="cke test value"===b.getData("cke/mimetypetest"),b.clearData("cke/mimetypetest")}catch(c){}}else return!1;return!a._isCustomMimeTypeSupported},getData:function(a,b){var c=this._getData(this._customDataFallbackType,!0);if(b)return c;var c=this._extractDataComment(c),d=null,d=a===this._customDataFallbackType?c.content:c.data&&c.data[a]?c.data[a]:this._getData(a, +!0);return null!==d?d:""},setData:function(a,b){var c=a===this._customDataFallbackType;c&&(b=this._applyDataComment(b,this._getFallbackTypeData()));var d=b,g=this._dataTransfer.$;try{g.setData(a,d),c&&(this._dataTransfer._.nativeHtmlCache=d)}catch(f){if(this._isUnsupportedMimeTypeError(f)){c=CKEDITOR.plugins.clipboard.fallbackDataTransfer;-1===CKEDITOR.tools.indexOf(c._customTypes,a)&&c._customTypes.push(a);var c=this._getFallbackTypeContent(),e=this._getFallbackTypeData();e[a]=d;try{d=this._applyDataComment(c, +e),g.setData(this._customDataFallbackType,d),this._dataTransfer._.nativeHtmlCache=d}catch(l){d=""}}}return d},_getData:function(a,b){var c=this._dataTransfer._.data;if(!b&&c[a])return c[a];try{return this._dataTransfer.$.getData(a)}catch(d){return null}},_getFallbackTypeContent:function(){var a=this._dataTransfer._.data[this._customDataFallbackType];a||(a=this._extractDataComment(this._getData(this._customDataFallbackType,!0)).content);return a},_getFallbackTypeData:function(){var a=CKEDITOR.plugins.clipboard.fallbackDataTransfer._customTypes, +b=this._extractDataComment(this._getData(this._customDataFallbackType,!0)).data||{},c=this._dataTransfer._.data;CKEDITOR.tools.array.forEach(a,function(a){void 0!==c[a]?b[a]=c[a]:void 0!==b[a]&&(b[a]=b[a])},this);return b},_isUnsupportedMimeTypeError:function(a){return a.message&&-1!==a.message.search(/element not found/gi)},_extractDataComment:function(a){var b={data:null,content:a||""};if(a&&16((?:.|[\n\r])*?)<\/body>/i,f=a.config.fullPage,a=a.getData();f&&(d=a.match(d))&&1((?:.|[\n\r])*?)<\/body>/i,g=b.config.fullPage,b=b.getData();g&&(f=b.match(f))&&1c.width&&(a.resize_minWidth=c.width);a.resize_minHeight>c.height&&(a.resize_minHeight=c.height);CKEDITOR.document.on("mousemove",f);CKEDITOR.document.on("mouseup",k);b.document&&(b.document.on("mousemove",f),b.document.on("mouseup",k));d.preventDefault&&d.preventDefault()});b.on("destroy", function(){CKEDITOR.tools.removeFunction(q)});b.on("uiSpace",function(a){if("bottom"==a.data.space){var e="";h&&!p&&(e=" cke_resizer_horizontal");!h&&p&&(e=" cke_resizer_vertical");var c='\x3cspan id\x3d"'+r+'" class\x3d"cke_resizer'+e+" cke_resizer_"+g+'" title\x3d"'+CKEDITOR.tools.htmlEncode(b.lang.common.resize)+'" onmousedown\x3d"CKEDITOR.tools.callFunction('+q+', event)"\x3e'+("ltr"==g?"◢":"◣")+"\x3c/span\x3e";"ltr"==g&&"ltr"==e?a.data.html+=c:a.data.html=c+a.data.html}},b,null,100);b.on("maximize", function(a){b.ui.space("resizer")[a.data==CKEDITOR.TRISTATE_ON?"hide":"show"]()})}}});(function(){function q(a,c){function k(b){b=h.list[b];var e;b.equals(a.editable())||"true"==b.getAttribute("contenteditable")?(e=a.createRange(),e.selectNodeContents(b),e=e.select()):(e=a.getSelection(),e.selectElement(b));CKEDITOR.env.ie&&a.fire("selectionChange",{selection:e,path:new CKEDITOR.dom.elementPath(b)});a.focus()}function l(){m&&m.setHtml('\x3cspan class\x3d"cke_path_empty"\x3e\x26nbsp;\x3c/span\x3e');delete h.list}var n=a.ui.spaceId("path"),m,h=a._.elementsPath,q=h.idBase;c.html+='\x3cspan id\x3d"'+ n+'_label" class\x3d"cke_voice_label"\x3e'+a.lang.elementspath.eleLabel+'\x3c/span\x3e\x3cspan id\x3d"'+n+'" class\x3d"cke_path" role\x3d"group" aria-labelledby\x3d"'+n+'_label"\x3e\x3cspan class\x3d"cke_path_empty"\x3e\x26nbsp;\x3c/span\x3e\x3c/span\x3e';a.on("uiReady",function(){var b=a.ui.space("path");b&&a.focusManager.add(b,1)});h.onClick=k;var v=CKEDITOR.tools.addFunction(k),w=CKEDITOR.tools.addFunction(function(b,e){var g=h.idBase,d;e=new CKEDITOR.dom.event(e);d="rtl"==a.lang.dir;switch(e.getKeystroke()){case d? -39:37:case 9:return(d=CKEDITOR.document.getById(g+(b+1)))||(d=CKEDITOR.document.getById(g+"0")),d.focus(),!1;case d?37:39:case CKEDITOR.SHIFT+9:return(d=CKEDITOR.document.getById(g+(b-1)))||(d=CKEDITOR.document.getById(g+(h.list.length-1))),d.focus(),!1;case 27:return a.focus(),!1;case 13:case 32:return k(b),!1}return!0});a.on("selectionChange",function(b){for(var e=[],g=h.list=[],d=[],c=h.filters,p=!0,k=b.data.path.elements,u=k.length;u--;){var f=k[u],r=0;b=f.data("cke-display-name")?f.data("cke-display-name"): -f.data("cke-real-element-type")?f.data("cke-real-element-type"):f.getName();(p=f.hasAttribute("contenteditable")?"true"==f.getAttribute("contenteditable"):p)||f.hasAttribute("contenteditable")||(r=1);for(var t=0;tCKEDITOR.env.version?n.createText("\r"):n.createElement("br"),b.deleteContents(),b.insertNode(a),CKEDITOR.env.needsBrFiller?(n.createText("").insertAfter(a),g&&(k||f.blockLimit).appendBogus(),a.getNext().$.nodeValue="",b.setStartAt(a.getNext(), CKEDITOR.POSITION_AFTER_START)):b.setStartAt(a,CKEDITOR.POSITION_AFTER_END)),b.collapse(!0),b.select(),b.scrollIntoView()):r(a,e,b,l)}}};v=CKEDITOR.plugins.enterkey;u=v.enterBr;r=v.enterBlock;w=/^h[1-6]$/})();(function(){function k(a,f){var g={},c=[],e={nbsp:" ",shy:"­",gt:"\x3e",lt:"\x3c",amp:"\x26",apos:"'",quot:'"'};a=a.replace(/\b(nbsp|shy|gt|lt|amp|apos|quot)(?:,|$)/g,function(a,b){var d=f?"\x26"+b+";":e[b];g[d]=f?e[b]:"\x26"+b+";";c.push(d);return""});a=a.replace(/,$/,"");if(!f&&a){a=a.split(",");var b=document.createElement("div"),d;b.innerHTML="\x26"+a.join(";\x26")+";";d=b.innerHTML;b=null;for(b=0;bh.height-c.bottom?e("pin"):e("bottom"),d=h.width/2,d=l.floatSpacePreferRight?"right":0n.width?"rtl"==l.contentsLangDirection? "right":"left":d-c.left>c.right-d?"left":"right",n.width>h.width?(d="left",f=0):(f="left"==d?0h.width&&(d="left"==d?"right":"left",f=0)),b.setStyle(d,w(("pin"==m?u:p)+f+("pin"==m?0:"left"==d?v:-v)))):(m="pin",e("pin"),t(d))}}}();if(p){var k=new CKEDITOR.template('\x3cdiv id\x3d"cke_{name}" class\x3d"cke {id} cke_reset_all cke_chrome cke_editor_{name} cke_float cke_{langDir} '+CKEDITOR.env.cssClass+'" dir\x3d"{langDir}" title\x3d"'+(CKEDITOR.env.gecko? -" ":"")+'" lang\x3d"{langCode}" role\x3d"application" style\x3d"{style}"'+(a.title?' aria-labelledby\x3d"cke_{name}_arialbl"':" ")+"\x3e"+(a.title?'\x3cspan id\x3d"cke_{name}_arialbl" class\x3d"cke_voice_label"\x3e{voiceLabel}\x3c/span\x3e':" ")+'\x3cdiv class\x3d"cke_inner"\x3e\x3cdiv id\x3d"{topId}" class\x3d"cke_top" role\x3d"presentation"\x3e{content}\x3c/div\x3e\x3c/div\x3e\x3c/div\x3e'),b=CKEDITOR.document.getBody().append(CKEDITOR.dom.element.createFromHtml(k.output({content:p,id:a.id,langDir:a.lang.dir, -langCode:a.langCode,name:a.name,style:"display:none;z-index:"+(l.baseFloatZIndex-1),topId:a.ui.spaceId("top"),voiceLabel:a.title}))),u=CKEDITOR.tools.eventsBuffer(500,t),e=CKEDITOR.tools.eventsBuffer(100,t);b.unselectable();b.on("mousedown",function(a){a=a.data;a.getTarget().hasAscendant("a",1)||a.preventDefault()});a.on("focus",function(b){t(b);a.on("change",u.input);g.on("scroll",e.input);g.on("resize",e.input)});a.on("blur",function(){b.hide();a.removeListener("change",u.input);g.removeListener("scroll", -e.input);g.removeListener("resize",e.input)});a.on("destroy",function(){g.removeListener("scroll",e.input);g.removeListener("resize",e.input);b.clearCustomData();b.remove()});a.focusManager.hasFocus&&b.show();a.focusManager.add(b,1)}}var g=CKEDITOR.document.getWindow(),w=CKEDITOR.tools.cssLength;CKEDITOR.plugins.add("floatingspace",{init:function(a){a.on("loaded",function(){k(this)},null,null,20)}})})();CKEDITOR.plugins.add("listblock",{requires:"panel",onLoad:function(){var f=CKEDITOR.addTemplate("panel-list",'\x3cul role\x3d"presentation" class\x3d"cke_panel_list"\x3e{items}\x3c/ul\x3e'),g=CKEDITOR.addTemplate("panel-list-item",'\x3cli id\x3d"{id}" class\x3d"cke_panel_listItem" role\x3dpresentation\x3e\x3ca id\x3d"{id}_option" _cke_focus\x3d1 hidefocus\x3dtrue title\x3d"{title}" draggable\x3d"false" ondragstart\x3d"return false;" href\x3d"javascript:void(\'{val}\')" onclick\x3d"{onclick}CKEDITOR.tools.callFunction({clickFn},\'{val}\'); return false;" role\x3d"option"\x3e{text}\x3c/a\x3e\x3c/li\x3e'), -h=CKEDITOR.addTemplate("panel-list-group",'\x3ch1 id\x3d"{id}" draggable\x3d"false" ondragstart\x3d"return false;" class\x3d"cke_panel_grouptitle" role\x3d"presentation" \x3e{label}\x3c/h1\x3e'),k=/\'/g;CKEDITOR.ui.panel.prototype.addListBlock=function(a,b){return this.addBlock(a,new CKEDITOR.ui.listBlock(this.getHolderElement(),b))};CKEDITOR.ui.listBlock=CKEDITOR.tools.createClass({base:CKEDITOR.ui.panel.block,$:function(a,b){b=b||{};var c=b.attributes||(b.attributes={});(this.multiSelect=!!b.multiSelect)&& -(c["aria-multiselectable"]=!0);!c.role&&(c.role="listbox");this.base.apply(this,arguments);this.element.setAttribute("role",c.role);c=this.keys;c[40]="next";c[9]="next";c[38]="prev";c[CKEDITOR.SHIFT+9]="prev";c[32]=CKEDITOR.env.ie?"mouseup":"click";CKEDITOR.env.ie&&(c[13]="mouseup");this._.pendingHtml=[];this._.pendingList=[];this._.items={};this._.groups={}},_:{close:function(){if(this._.started){var a=f.output({items:this._.pendingList.join("")});this._.pendingList=[];this._.pendingHtml.push(a); -delete this._.started}},getClick:function(){this._.click||(this._.click=CKEDITOR.tools.addFunction(function(a){var b=this.toggle(a);if(this.onClick)this.onClick(a,b)},this));return this._.click}},proto:{add:function(a,b,c){var d=CKEDITOR.tools.getNextId();this._.started||(this._.started=1,this._.size=this._.size||0);this._.items[a]=d;var e;e=CKEDITOR.tools.htmlEncodeAttr(a).replace(k,"\\'");a={id:d,val:e,onclick:CKEDITOR.env.ie?'return false;" onmouseup\x3d"CKEDITOR.tools.getMouseButton(event)\x3d\x3d\x3dCKEDITOR.MOUSE_BUTTON_LEFT\x26\x26': -"",clickFn:this._.getClick(),title:CKEDITOR.tools.htmlEncodeAttr(c||a),text:b||a};this._.pendingList.push(g.output(a))},startGroup:function(a){this._.close();var b=CKEDITOR.tools.getNextId();this._.groups[a]=b;this._.pendingHtml.push(h.output({id:b,label:a}))},commit:function(){this._.close();this.element.appendHtml(this._.pendingHtml.join(""));delete this._.size;this._.pendingHtml=[]},toggle:function(a){var b=this.isMarked(a);b?this.unmark(a):this.mark(a);return!b},hideGroup:function(a){var b=(a= -this.element.getDocument().getById(this._.groups[a]))&&a.getNext();a&&(a.setStyle("display","none"),b&&"ul"==b.getName()&&b.setStyle("display","none"))},hideItem:function(a){this.element.getDocument().getById(this._.items[a]).setStyle("display","none")},showAll:function(){var a=this._.items,b=this._.groups,c=this.element.getDocument(),d;for(d in a)c.getById(a[d]).setStyle("display","");for(var e in b)a=c.getById(b[e]),d=a.getNext(),a.setStyle("display",""),d&&"ul"==d.getName()&&d.setStyle("display", -"")},mark:function(a){this.multiSelect||this.unmarkAll();a=this._.items[a];var b=this.element.getDocument().getById(a);b.addClass("cke_selected");this.element.getDocument().getById(a+"_option").setAttribute("aria-selected",!0);this.onMark&&this.onMark(b)},markFirstDisplayed:function(){var a=this;this._.markFirstDisplayed(function(){a.multiSelect||a.unmarkAll()})},unmark:function(a){var b=this.element.getDocument();a=this._.items[a];var c=b.getById(a);c.removeClass("cke_selected");b.getById(a+"_option").removeAttribute("aria-selected"); -this.onUnmark&&this.onUnmark(c)},unmarkAll:function(){var a=this._.items,b=this.element.getDocument(),c;for(c in a){var d=a[c];b.getById(d).removeClass("cke_selected");b.getById(d+"_option").removeAttribute("aria-selected")}this.onUnmark&&this.onUnmark()},isMarked:function(a){return this.element.getDocument().getById(this._.items[a]).hasClass("cke_selected")},focus:function(a){this._.focusIndex=-1;var b=this.element.getElementsByTag("a"),c,d=-1;if(a)for(c=this.element.getDocument().getById(this._.items[a]).getFirst();a= -b.getItem(++d);){if(a.equals(c)){this._.focusIndex=d;break}}else this.element.focus();c&&setTimeout(function(){c.focus()},0)}}})}});CKEDITOR.plugins.add("richcombo",{requires:"floatpanel,listblock,button",beforeInit:function(e){e.ui.addHandler(CKEDITOR.UI_RICHCOMBO,CKEDITOR.ui.richCombo.handler)}}); +" ":"")+'" lang\x3d"{langCode}" role\x3d"application" style\x3d"{style}"'+(a.applicationTitle?' aria-labelledby\x3d"cke_{name}_arialbl"':" ")+"\x3e"+(a.applicationTitle?'\x3cspan id\x3d"cke_{name}_arialbl" class\x3d"cke_voice_label"\x3e{voiceLabel}\x3c/span\x3e':" ")+'\x3cdiv class\x3d"cke_inner"\x3e\x3cdiv id\x3d"{topId}" class\x3d"cke_top" role\x3d"presentation"\x3e{content}\x3c/div\x3e\x3c/div\x3e\x3c/div\x3e'),b=CKEDITOR.document.getBody().append(CKEDITOR.dom.element.createFromHtml(k.output({content:p, +id:a.id,langDir:a.lang.dir,langCode:a.langCode,name:a.name,style:"display:none;z-index:"+(l.baseFloatZIndex-1),topId:a.ui.spaceId("top"),voiceLabel:a.applicationTitle}))),u=CKEDITOR.tools.eventsBuffer(500,t),e=CKEDITOR.tools.eventsBuffer(100,t);b.unselectable();b.on("mousedown",function(a){a=a.data;a.getTarget().hasAscendant("a",1)||a.preventDefault()});a.on("focus",function(b){t(b);a.on("change",u.input);g.on("scroll",e.input);g.on("resize",e.input)});a.on("blur",function(){b.hide();a.removeListener("change", +u.input);g.removeListener("scroll",e.input);g.removeListener("resize",e.input)});a.on("destroy",function(){g.removeListener("scroll",e.input);g.removeListener("resize",e.input);b.clearCustomData();b.remove()});a.focusManager.hasFocus&&b.show();a.focusManager.add(b,1)}}var g=CKEDITOR.document.getWindow(),w=CKEDITOR.tools.cssLength;CKEDITOR.plugins.add("floatingspace",{init:function(a){a.on("loaded",function(){k(this)},null,null,20)}})})();CKEDITOR.plugins.add("listblock",{requires:"panel",onLoad:function(){var g=CKEDITOR.addTemplate("panel-list",'\x3cul role\x3d"presentation" class\x3d"cke_panel_list"\x3e{items}\x3c/ul\x3e'),h=CKEDITOR.addTemplate("panel-list-item",'\x3cli id\x3d"{id}" class\x3d"cke_panel_listItem" role\x3dpresentation\x3e\x3ca id\x3d"{id}_option" _cke_focus\x3d1 hidefocus\x3dtrue title\x3d"{title}" draggable\x3d"false" ondragstart\x3d"return false;" href\x3d"javascript:void(\'{val}\')" {language} onclick\x3d"{onclick}CKEDITOR.tools.callFunction({clickFn},\'{val}\'); return false;" role\x3d"option"\x3e{text}\x3c/a\x3e\x3c/li\x3e'), +k=CKEDITOR.addTemplate("panel-list-group",'\x3ch1 id\x3d"{id}" draggable\x3d"false" ondragstart\x3d"return false;" class\x3d"cke_panel_grouptitle" role\x3d"presentation" \x3e{label}\x3c/h1\x3e'),l=/\'/g;CKEDITOR.ui.panel.prototype.addListBlock=function(a,b){return this.addBlock(a,new CKEDITOR.ui.listBlock(this.getHolderElement(),b))};CKEDITOR.ui.listBlock=CKEDITOR.tools.createClass({base:CKEDITOR.ui.panel.block,$:function(a,b){b=b||{};var c=b.attributes||(b.attributes={});(this.multiSelect=!!b.multiSelect)&& +(c["aria-multiselectable"]=!0);!c.role&&(c.role="listbox");this.base.apply(this,arguments);this.element.setAttribute("role",c.role);c=this.keys;c[40]="next";c[9]="next";c[38]="prev";c[CKEDITOR.SHIFT+9]="prev";c[32]=CKEDITOR.env.ie?"mouseup":"click";CKEDITOR.env.ie&&(c[13]="mouseup");this._.pendingHtml=[];this._.pendingList=[];this._.items={};this._.groups={}},_:{close:function(){if(this._.started){var a=g.output({items:this._.pendingList.join("")});this._.pendingList=[];this._.pendingHtml.push(a); +delete this._.started}},getClick:function(){this._.click||(this._.click=CKEDITOR.tools.addFunction(function(a){var b=this.toggle(a);if(this.onClick)this.onClick(a,b)},this));return this._.click}},proto:{add:function(a,b,c,d){var e=CKEDITOR.tools.getNextId();this._.started||(this._.started=1,this._.size=this._.size||0);this._.items[a]=e;var f;f=CKEDITOR.tools.htmlEncodeAttr(a).replace(l,"\\'");a={id:e,val:f,onclick:CKEDITOR.env.ie?'return false;" onmouseup\x3d"CKEDITOR.tools.getMouseButton(event)\x3d\x3d\x3dCKEDITOR.MOUSE_BUTTON_LEFT\x26\x26': +"",clickFn:this._.getClick(),title:CKEDITOR.tools.htmlEncodeAttr(c||a),text:b||a,language:d?'lang\x3d"'+d+'"':""};this._.pendingList.push(h.output(a))},startGroup:function(a){this._.close();var b=CKEDITOR.tools.getNextId();this._.groups[a]=b;this._.pendingHtml.push(k.output({id:b,label:a}))},commit:function(){this._.close();this.element.appendHtml(this._.pendingHtml.join(""));delete this._.size;this._.pendingHtml=[]},toggle:function(a){var b=this.isMarked(a);b?this.unmark(a):this.mark(a);return!b}, +hideGroup:function(a){var b=(a=this.element.getDocument().getById(this._.groups[a]))&&a.getNext();a&&(a.setStyle("display","none"),b&&"ul"==b.getName()&&b.setStyle("display","none"))},hideItem:function(a){this.element.getDocument().getById(this._.items[a]).setStyle("display","none")},showAll:function(){var a=this._.items,b=this._.groups,c=this.element.getDocument(),d;for(d in a)c.getById(a[d]).setStyle("display","");for(var e in b)a=c.getById(b[e]),d=a.getNext(),a.setStyle("display",""),d&&"ul"== +d.getName()&&d.setStyle("display","")},mark:function(a){this.multiSelect||this.unmarkAll();a=this._.items[a];var b=this.element.getDocument().getById(a);b.addClass("cke_selected");this.element.getDocument().getById(a+"_option").setAttribute("aria-selected",!0);this.onMark&&this.onMark(b)},unmark:function(a){var b=this.element.getDocument();a=this._.items[a];var c=b.getById(a);c.removeClass("cke_selected");b.getById(a+"_option").removeAttribute("aria-selected");this.onUnmark&&this.onUnmark(c)},unmarkAll:function(){var a= +this._.items,b=this.element.getDocument(),c;for(c in a){var d=a[c];b.getById(d).removeClass("cke_selected");b.getById(d+"_option").removeAttribute("aria-selected")}this.onUnmark&&this.onUnmark()},isMarked:function(a){return this.element.getDocument().getById(this._.items[a]).hasClass("cke_selected")},focus:function(a){this._.focusIndex=-1;var b=this.element.getElementsByTag("a"),c,d=-1;if(a)for(c=this.element.getDocument().getById(this._.items[a]).getFirst();a=b.getItem(++d);){if(a.equals(c)){this._.focusIndex= +d;break}}else this.element.focus();c&&setTimeout(function(){c.focus()},0)}}})}});CKEDITOR.plugins.add("richcombo",{requires:"floatpanel,listblock,button",beforeInit:function(e){e.ui.addHandler(CKEDITOR.UI_RICHCOMBO,CKEDITOR.ui.richCombo.handler)}}); (function(){var e='\x3cspan id\x3d"{id}" class\x3d"cke_combo cke_combo__{name} {cls}" role\x3d"presentation"\x3e\x3cspan id\x3d"{id}_label" class\x3d"cke_combo_label"\x3e{label}\x3c/span\x3e\x3ca class\x3d"cke_combo_button" title\x3d"{title}" tabindex\x3d"-1"'+(CKEDITOR.env.gecko&&!CKEDITOR.env.hc?"":" href\x3d\"javascript:void('{titleJs}')\"")+' hidefocus\x3d"true" role\x3d"button" aria-labelledby\x3d"{id}_label" aria-haspopup\x3d"listbox"',h="";CKEDITOR.env.gecko&&CKEDITOR.env.mac&&(e+=' onkeypress\x3d"return false;"'); CKEDITOR.env.gecko&&(e+=' onblur\x3d"this.style.cssText \x3d this.style.cssText;"');CKEDITOR.env.ie&&(h='return false;" onmouseup\x3d"CKEDITOR.tools.getMouseButton(event)\x3d\x3dCKEDITOR.MOUSE_BUTTON_LEFT\x26\x26');var e=e+(' onkeydown\x3d"return CKEDITOR.tools.callFunction({keydownFn},event,this);" onfocus\x3d"return CKEDITOR.tools.callFunction({focusFn},event);" onclick\x3d"'+h+'CKEDITOR.tools.callFunction({clickFn},this);return false;"\x3e\x3cspan id\x3d"{id}_text" class\x3d"cke_combo_text cke_combo_inlinelabel"\x3e{label}\x3c/span\x3e\x3cspan class\x3d"cke_combo_open"\x3e\x3cspan class\x3d"cke_combo_arrow"\x3e'+ (CKEDITOR.env.hc?"\x26#9660;":CKEDITOR.env.air?"\x26nbsp;":"")+"\x3c/span\x3e\x3c/span\x3e\x3c/a\x3e\x3c/span\x3e"),m=CKEDITOR.addTemplate("combo",e);CKEDITOR.UI_RICHCOMBO="richcombo";CKEDITOR.ui.richCombo=CKEDITOR.tools.createClass({$:function(a){CKEDITOR.tools.extend(this,a,{canGroup:!1,title:a.label,modes:{wysiwyg:1},editorFocus:1});a=this.panel||{};delete this.panel;this.id=CKEDITOR.tools.getNextNumber();this.document=a.parent&&a.parent.getDocument()||CKEDITOR.document;a.className="cke_combopanel"; @@ -982,7 +989,7 @@ c,this));this._.listeners.push(a.on("mode",c,this));this._.listeners.push(a.on(" label:this.label,title:this.title,cls:this.className||"",titleJs:l.gecko&&!l.hc?"":(this.title||"").replace("'",""),keydownFn:h,focusFn:n,clickFn:e};m.output(l,b);if(this.onRender)this.onRender();return g},createPanel:function(a){if(!this._.panel){var b=this._.panelDefinition,c=this._.panelDefinition.block,e=b.parent||CKEDITOR.document.getBody(),g="cke_combopanel__"+this.name,f=new CKEDITOR.ui.floatPanel(a,e,b),b=f.addListBlock(this.id,c),d=this;f.onShow=function(){this.element.addClass(g);d.setState(CKEDITOR.TRISTATE_ON); d._.on=1;d.editorFocus&&!a.focusManager.hasFocus&&a.focus();if(d.onOpen)d.onOpen()};f.onHide=function(b){this.element.removeClass(g);d.setState(d.modes&&d.modes[a.mode]?CKEDITOR.TRISTATE_OFF:CKEDITOR.TRISTATE_DISABLED);d._.on=0;if(!b&&d.onClose)d.onClose()};f.onEscape=function(){f.hide(1)};b.onClick=function(a,b){d.onClick&&d.onClick.call(d,a,b);f.hide()};this._.panel=f;this._.list=b;f.getBlock(this.id).onHide=function(){d._.on=0;d.setState(CKEDITOR.TRISTATE_OFF)};this.init&&this.init()}},setValue:function(a, b){this._.value=a;var c=this.document.getById("cke_"+this.id+"_text");c&&(a||b?c.removeClass("cke_combo_inlinelabel"):(b=this.label,c.addClass("cke_combo_inlinelabel")),c.setText("undefined"!=typeof b?b:a));var c="undefined"!=typeof b?b:a,e=this.label,c=c===e?c:c+", "+e;(e=this.document.getById("cke_"+this.id+"_label"))&&e.setText(c)},getValue:function(){return this._.value||""},unmarkAll:function(){this._.list.unmarkAll()},mark:function(a){this._.list.mark(a)},hideItem:function(a){this._.list.hideItem(a)}, -hideGroup:function(a){this._.list.hideGroup(a)},showAll:function(){this._.list.showAll()},add:function(a,b,c){this._.items[a]=c||a;this._.list.add(a,b,c)},startGroup:function(a){this._.list.startGroup(a)},commit:function(){this._.committed||(this._.list.commit(),this._.committed=1,CKEDITOR.ui.fire("ready",this));this._.committed=1},setState:function(a){if(this._.state!=a){var b=this.document.getById("cke_"+this.id),c=b.getElementsByTag("a").getItem(0);b.setState(a,"cke_combo");a==CKEDITOR.TRISTATE_DISABLED? +hideGroup:function(a){this._.list.hideGroup(a)},showAll:function(){this._.list.showAll()},add:function(a,b,c,e){this._.items[a]=c||a;this._.list.add(a,b,c,e)},startGroup:function(a){this._.list.startGroup(a)},commit:function(){this._.committed||(this._.list.commit(),this._.committed=1,CKEDITOR.ui.fire("ready",this));this._.committed=1},setState:function(a){if(this._.state!=a){var b=this.document.getById("cke_"+this.id),c=b.getElementsByTag("a").getItem(0);b.setState(a,"cke_combo");a==CKEDITOR.TRISTATE_DISABLED? b.setAttribute("aria-disabled",!0):b.removeAttribute("aria-disabled");c&&c.setAttribute("aria-expanded",a==CKEDITOR.TRISTATE_ON);this._.state=a}},getState:function(){return this._.state},enable:function(){this._.state==CKEDITOR.TRISTATE_DISABLED&&this.setState(this._.lastState)},disable:function(){this._.state!=CKEDITOR.TRISTATE_DISABLED&&(this._.lastState=this._.state,this.setState(CKEDITOR.TRISTATE_DISABLED))},destroy:function(){CKEDITOR.tools.array.forEach(this._.listeners,function(a){a.removeListener()}); this._.listeners=[]},select:function(a){if(!CKEDITOR.tools.isEmpty(this._.items))for(var b in this._.items)if(a({value:b,text:this._.items[b]})){this.setValue(b);break}}},statics:{handler:{create:function(a){return new CKEDITOR.ui.richCombo(a)}}}});CKEDITOR.ui.prototype.addRichCombo=function(a,b){this.add(a,CKEDITOR.UI_RICHCOMBO,b)}})();(function(){function k(a,b){var c=a.config,e=b.lang,d=new CKEDITOR.style(b.styleDefinition),f=new l({entries:b.entries,styleVariable:b.styleVariable,styleDefinition:b.styleDefinition}),g;a.addCommand(b.commandName,{exec:function(a,b){var c=b.newStyle,d=b.oldStyle,e=a.getSelection().getRanges()[0],f=void 0===c;if(d||c)d&&e.collapsed&&m({editor:a,range:e,style:d}),f?a.removeStyle(d):(d&&!n(d,c)&&a.removeStyle(d),a.applyStyle(c))},refresh:function(a,b){d.checkApplicable(b,a,a.activeFilter)||this.setState(CKEDITOR.TRISTATE_DISABLED)}}); g=a.getCommand(b.commandName);a.ui.addRichCombo(b.comboName,{label:e.label,title:e.panelTitle,command:b.commandName,toolbar:"styles,"+b.order,defaultValue:"cke-default",allowedContent:d,requiredContent:d,contentTransformations:"span"===b.styleDefinition.element?[[{element:"font",check:"span",left:function(a){return!!a.attributes.size||!!a.attributes.align||!!a.attributes.face},right:function(a){var b=" x-small small medium large x-large xx-large 48px".split(" ");a.name="span";a.attributes.size&&(a.styles["font-size"]= @@ -1015,27 +1022,29 @@ b.$block&&!(a in{li:1,dt:1,dd:1})});this.setRules("br",{breakAfterOpen:1});this. openTagClose:function(b,a){var c=this._.rules[b];a?(this._.output.push(this.selfClosingEnd),c&&c.breakAfterClose&&(this._.needsSpace=c.needsSpace)):(this._.output.push("\x3e"),c&&c.indent&&(this._.indentation+=this.indentationChars));c&&c.breakAfterOpen&&this.lineBreak();"pre"==b&&(this._.inPre=1)},attribute:function(b,a){"string"==typeof a&&(a=CKEDITOR.tools.htmlEncodeAttr(a),this.forceSimpleAmpersand&&(a=a.replace(/&/g,"\x26")));this._.output.push(" ",b,'\x3d"',a,'"')},closeTag:function(b){var a= this._.rules[b];a&&a.indent&&(this._.indentation=this._.indentation.substr(this.indentationChars.length));this._.indent?this.indentation():a&&a.breakBeforeClose&&(this.lineBreak(),this.indentation());this._.output.push("\x3c/",b,"\x3e");"pre"==b&&(this._.inPre=0);a&&a.breakAfterClose&&(this.lineBreak(),this._.needsSpace=a.needsSpace);this._.afterCloser=1},text:function(b){this._.indent&&(this.indentation(),!this._.inPre&&(b=CKEDITOR.tools.ltrim(b)));this._.output.push(b)},comment:function(b){this._.indent&& this.indentation();this._.output.push("\x3c!--",b,"--\x3e")},lineBreak:function(){!this._.inPre&&0CKEDITOR.env.version&&b.enterMode!=CKEDITOR.ENTER_DIV&&d("div");if(CKEDITOR.env.webkit||CKEDITOR.env.ie&&10this.$.offsetHeight){var d=b.createRange();d[33==c?"moveToElementEditStart":"moveToElementEditEnd"](this);d.select();a.data.preventDefault()}});CKEDITOR.env.ie&&this.attachListener(c,"blur",function(){try{c.$.selection.empty()}catch(a){}});CKEDITOR.env.iOS&&this.attachListener(c,"touchend",function(){a.focus()});e=b.document.getElementsByTag("title").getItem(0); -e.data("cke-title",e.getText());CKEDITOR.env.ie&&(b.document.$.title=this._.docTitle);CKEDITOR.tools.setTimeout(function(){"unloaded"==this.status&&(this.status="ready");b.fire("contentDom");this._.isPendingFocus&&(b.focus(),this._.isPendingFocus=!1);setTimeout(function(){b.fire("dataReady")},0)},0,this)}}function w(a){function d(){var c;a.editable().attachListener(a,"selectionChange",function(){var d=a.getSelection().getSelectedElement();d&&(c&&(c.detachEvent("onresizestart",b),c=null),d.$.attachEvent("onresizestart", -b),c=d.$)})}function b(a){a.returnValue=!1}if(CKEDITOR.env.gecko)try{var c=a.document.$;c.execCommand("enableObjectResizing",!1,!a.config.disableObjectResizing);c.execCommand("enableInlineTableEditing",!1,!a.config.disableNativeTableHandles)}catch(e){}else CKEDITOR.env.ie&&11>CKEDITOR.env.version&&a.config.disableObjectResizing&&d()}function x(){var a=[];if(8<=CKEDITOR.document.$.documentMode){a.push("html.CSS1Compat [contenteditable\x3dfalse]{min-height:0 !important}");var d=[],b;for(b in CKEDITOR.dtd.$removeEmpty)d.push("html.CSS1Compat "+ -b+"[contenteditable\x3dfalse]");a.push(d.join(",")+"{display:inline-block}")}else CKEDITOR.env.gecko&&(a.push("html{height:100% !important}"),a.push("img:-moz-broken{-moz-force-broken-image-icon:1;min-width:24px;min-height:24px}"));a.push("html{cursor:text;*cursor:auto}");a.push("img,input,textarea{cursor:default}");return a.join("\n")}var l;CKEDITOR.plugins.add("wysiwygarea",{init:function(a){a.config.fullPage&&a.addFeature({allowedContent:"html head title; style [media,type]; body (*)[id]; meta link [*]", -requiredContent:"body"});a.addMode("wysiwyg",function(d){function b(b){b&&b.removeListener();if(!a.isDestroyed()&&!a.isDetached()&&(a.editable(new l(a,g.getFrameDocument().getBody())),a.setData(a.getData(1),d),t)){if(u)a.on("mode",c,{iframe:g,editor:a,callback:d});a.on("mode",function(){a.status="ready"});e()}}function c(a){a&&a.removeListener();g.on("load",function(){p&&(p=!1,f())})}function e(){m=new MutationObserver(function(b){for(var c=0;cCKEDITOR.env.version&&b.enterMode!=CKEDITOR.ENTER_DIV&&e("div");if(CKEDITOR.env.webkit||CKEDITOR.env.ie&&10this.$.offsetHeight){var c=b.createRange();c[33==d?"moveToElementEditStart":"moveToElementEditEnd"](this);c.select();a.data.preventDefault()}});CKEDITOR.env.ie&&this.attachListener(c,"blur",function(){try{c.$.selection.empty()}catch(a){}});CKEDITOR.env.iOS&&this.attachListener(c,"touchend",function(){a.focus()});f=b.document.getElementsByTag("title").getItem(0); +f.data("cke-title",f.getText());CKEDITOR.env.ie&&(b.document.$.title=this._.docTitle);CKEDITOR.tools.setTimeout(function(){"unloaded"==this.status&&(this.status="ready");b.fire("contentDom");this._.isPendingFocus&&(b.focus(),this._.isPendingFocus=!1);setTimeout(function(){b.fire("dataReady")},0)},0,this)}}function w(a){function e(){var d;a.editable().attachListener(a,"selectionChange",function(){var c=a.getSelection().getSelectedElement();c&&(d&&(d.detachEvent("onresizestart",b),d=null),c.$.attachEvent("onresizestart", +b),d=c.$)})}function b(a){a.returnValue=!1}if(CKEDITOR.env.gecko)try{var c=a.document.$;c.execCommand("enableObjectResizing",!1,!a.config.disableObjectResizing);c.execCommand("enableInlineTableEditing",!1,!a.config.disableNativeTableHandles)}catch(f){}else CKEDITOR.env.ie&&11>CKEDITOR.env.version&&a.config.disableObjectResizing&&e()}function x(){var a=[];if(8<=CKEDITOR.document.$.documentMode){a.push("html.CSS1Compat [contenteditable\x3dfalse]{min-height:0 !important}");var e=[],b;for(b in CKEDITOR.dtd.$removeEmpty)e.push("html.CSS1Compat "+ +b+"[contenteditable\x3dfalse]");a.push(e.join(",")+"{display:inline-block}")}else CKEDITOR.env.gecko&&(a.push("html{height:100% !important}"),a.push("img:-moz-broken{-moz-force-broken-image-icon:1;min-width:24px;min-height:24px}"));a.push("html{cursor:text;*cursor:auto}");a.push("img,input,textarea{cursor:default}");return a.join("\n")}var l;CKEDITOR.plugins.add("wysiwygarea",{init:function(a){a.config.fullPage&&a.addFeature({allowedContent:"html head title; style [media,type]; body (*)[id]; meta link [*]", +requiredContent:"body"});a.addMode("wysiwyg",function(e){function b(b){b&&b.removeListener();if(!a.isDestroyed()&&!a.isDetached()&&(a.editable(new l(a,g.getFrameDocument().getBody())),a.setData(a.getData(1),e),t)){if(u)a.on("mode",c,{iframe:g,editor:a,callback:e});a.on("mode",function(){a.status="ready"});f()}}function c(a){a&&a.removeListener();g.on("load",function(){p&&(p=!1,d())})}function f(){m=new MutationObserver(function(b){for(var c=0;c/,'\x3cstyle data-cke-temp\x3d"1"\x3e');e||(h+=CKEDITOR.tools.buildStyleHtml(b.config.contentsCss));var g=c.baseHref?'\x3cbase href\x3d"'+c.baseHref+'" data-cke-temp\x3d"1" /\x3e':"";e&&(a=a.replace(/]*>/i,function(a){b.docType=f=a;return""}).replace(/<\?xml\s[^\?]*\?>/i, -function(a){b.xmlDeclaration=a;return""}));a=b.dataProcessor.toHtml(a);e?(/]/.test(a)||(a="\x3cbody\x3e"+a),/]/.test(a)||(a="\x3chtml\x3e"+a+"\x3c/html\x3e"),/]/.test(a)?/]/.test(a)||(a=a.replace(/]*>/,"$\x26\x3ctitle\x3e\x3c/title\x3e")):a=a.replace(/]*>/,"$\x26\x3chead\x3e\x3ctitle\x3e\x3c/title\x3e\x3c/head\x3e"),g&&(a=a.replace(/]*?>/,"$\x26"+g)),a=a.replace(/<\/head\s*>/,h+"$\x26"),a=f+a):a=c.docType+'\x3chtml dir\x3d"'+c.contentsLangDirection+ -'" lang\x3d"'+(c.contentsLanguage||b.langCode)+'"\x3e\x3chead\x3e\x3ctitle\x3e'+this._.docTitle+"\x3c/title\x3e"+g+h+"\x3c/head\x3e\x3cbody"+(c.bodyId?' id\x3d"'+c.bodyId+'"':"")+(c.bodyClass?' class\x3d"'+c.bodyClass+'"':"")+"\x3e"+a+"\x3c/body\x3e\x3c/html\x3e";CKEDITOR.env.gecko&&(a=a.replace(/CKEDITOR.env.version&&(a=a.replace(/]*>/,"$\x26\x3c!-- cke-content-start --\x3e")));c='\x3cscript id\x3d"cke_actscrpt" type\x3d"text/javascript"'+ -(CKEDITOR.env.ie?' defer\x3d"defer" ':"")+"\x3evar wasLoaded\x3d0;function onload(){if(!wasLoaded)window.parent.CKEDITOR \x26\x26 window.parent.CKEDITOR.tools.callFunction("+this._.frameLoadedHandler+",window);wasLoaded\x3d1;}"+(CKEDITOR.env.ie?"onload();":'document.addEventListener("DOMContentLoaded", onload, false );')+"\x3c/script\x3e";CKEDITOR.env.ie&&9>CKEDITOR.env.version&&(c+='\x3cscript id\x3d"cke_shimscrpt"\x3ewindow.parent.CKEDITOR.tools.enableHtml5Elements(document)\x3c/script\x3e');g&& -CKEDITOR.env.ie&&10>CKEDITOR.env.version&&(c+='\x3cscript id\x3d"cke_basetagscrpt"\x3evar baseTag \x3d document.querySelector( "base" );baseTag.href \x3d baseTag.href;\x3c/script\x3e');a=a.replace(/(?=\s*<\/(:?head)>)/,c);this.clearCustomData();this.clearListeners();b.fire("contentDomUnload");var l=this.getDocument();try{l.write(a)}catch(k){setTimeout(function(){l.write(a)},0)}}},getData:function(a){if(a)return this.getHtml();a=this.editor;var d=a.config,b=d.fullPage,c=b&&a.docType,e=b&&a.xmlDeclaration, -f=this.getDocument(),b=b?f.getDocumentElement().getOuterHtml():f.getBody().getHtml();CKEDITOR.env.gecko&&d.enterMode!=CKEDITOR.ENTER_BR&&(b=b.replace(/
    (?=\s*(:?$|<\/body>))/,""));b=a.dataProcessor.toDataFormat(b);e&&(b=e+"\n"+b);c&&(b=c+"\n"+b);return b},focus:function(){this._.isLoadingData?this._.isPendingFocus=!0:l.baseProto.focus.call(this)},detach:function(){if(!this.preserveIframe){var a=this.editor,d=a.document,a=a.container.findOne("iframe.cke_wysiwyg_frame");l.baseProto.detach.call(this); -this.clearCustomData(this._.expandoNumber);d.getDocumentElement().clearCustomData();CKEDITOR.tools.removeFunction(this._.frameLoadedHandler);a&&(a.clearCustomData(),(d=a.removeCustomData("onResize"))&&d.removeListener(),a.isDetached()||a.remove())}}}})})();CKEDITOR.config.disableObjectResizing=!1;CKEDITOR.config.disableNativeTableHandles=!0;CKEDITOR.config.disableNativeSpellChecker=!0;CKEDITOR.config.observableParent=CKEDITOR.document.$;(function(){function e(b,a){a||(a=b.getSelection().getSelectedElement());if(a&&a.is("img")&&!a.data("cke-realelement")&&!a.isReadOnly())return a}function f(b){var a=b.getStyle("float");if("inherit"==a||"none"==a)a=0;a||(a=b.getAttribute("align"));return a}CKEDITOR.plugins.add("image",{requires:"dialog",init:function(b){if(!b.plugins.detectConflict("image",["easyimage","image2"])){CKEDITOR.dialog.add("image",this.path+"dialogs/image.js");var a="img[alt,!src]{border-style,border-width,float,height,margin,margin-bottom,margin-left,margin-right,margin-top,width}"; +allowTransparency:"true"});!r&&b();a.fire("ariaWidget",g)})}});CKEDITOR.editor.prototype.addContentsCss=function(a){var e=this.config,b=e.contentsCss;CKEDITOR.tools.isArray(b)||(e.contentsCss=b?[b]:[]);e.contentsCss.push(a)};l=CKEDITOR.tools.createClass({$:function(){this.base.apply(this,arguments);this._.frameLoadedHandler=CKEDITOR.tools.addFunction(function(a){CKEDITOR.tools.setTimeout(v,0,this,a)},this);this._.docTitle=this.getWindow().getFrame().getAttribute("title")||" "},base:CKEDITOR.editable, +proto:{preserveIframe:!1,setData:function(a,e){var b=this.editor;if(e)this.setHtml(a),this.fixInitialSelection(),b.fire("dataReady");else{this._.isLoadingData=!0;b._.dataStore={id:1};var c=b.config,f=c.fullPage,d=c.docType,h=CKEDITOR.tools.buildStyleHtml(x()).replace(/
    '; + print ''; @@ -2411,7 +2420,7 @@ if ($action == 'create') { // Warehouse source if (isModEnabled('stock')) { - print ''; } // Qty to dispatch - print '\n"; if (!$i) { diff --git a/htdocs/expensereport/class/api_expensereports.class.php b/htdocs/expensereport/class/api_expensereports.class.php index 1a3955f11d6..710a07e7cf0 100644 --- a/htdocs/expensereport/class/api_expensereports.class.php +++ b/htdocs/expensereport/class/api_expensereports.class.php @@ -59,9 +59,9 @@ class ExpenseReports extends DolibarrApi * Return an array with Expense Report informations * * @param int $id ID of Expense Report - * @return Object Object with cleaned properties + * @return Object Object with cleaned properties * - * @throws RestException + * @throws RestException */ public function get($id) { @@ -91,11 +91,12 @@ class ExpenseReports extends DolibarrApi * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number - * @param string $user_ids User ids filter field. Example: '1' or '1,2,3' {@pattern /^[0-9,]*$/i} + * @param string $user_ids User ids filter field. Example: '1' or '1,2,3' {@pattern /^[0-9,]*$/i} * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @param string $properties Restrict the data returned to theses properties. Ignored if empty. Comma separated list of properties names * @return array Array of Expense Report objects */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '', $properties = '') { global $db, $conf; @@ -144,7 +145,7 @@ class ExpenseReports extends DolibarrApi $obj = $this->db->fetch_object($result); $expensereport_static = new ExpenseReport($this->db); if ($expensereport_static->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($expensereport_static); + $obj_ret[] = $this->_filterObjectProperties($this->_cleanObjectDatas($expensereport_static), $properties); } $i++; } diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index e07ca8bb6cc..1947470adf9 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1062,7 +1062,7 @@ class ExpenseReport extends CommonObject $sql .= ' de.fk_ecm_files,'; $sql .= ' de.total_ht, de.total_tva, de.total_ttc,'; $sql .= ' de.total_localtax1, de.total_localtax2, de.rule_warning_message,'; - $sql .= ' ctf.code as code_type_fees, ctf.label as libelle_type_fees, ctf.accountancy_code as accountancy_code_type_fees,'; + $sql .= ' ctf.code as code_type_fees, ctf.label as label_type_fees, ctf.accountancy_code as accountancy_code_type_fees,'; $sql .= ' p.ref as ref_projet, p.title as title_projet'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as de'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_fees as ctf ON de.fk_c_type_fees = ctf.id'; @@ -1105,7 +1105,7 @@ class ExpenseReport extends CommonObject $deplig->total_localtax2 = $objp->total_localtax2; $deplig->type_fees_code = empty($objp->code_type_fees) ? 'TF_OTHER' : $objp->code_type_fees; - $deplig->type_fees_libelle = $objp->libelle_type_fees; + $deplig->type_fees_libelle = $objp->label_type_fees; $deplig->type_fees_accountancy_code = $objp->accountancy_code_type_fees; $deplig->tva_tx = $objp->tva_tx; @@ -1778,7 +1778,7 @@ class ExpenseReport extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { @@ -2226,14 +2226,14 @@ class ExpenseReport extends CommonObject $this->line->id = ((int) $rowid); // Select des infos sur le type fees - $sql = "SELECT c.code as code_type_fees, c.label as libelle_type_fees"; + $sql = "SELECT c.code as code_type_fees, c.label as label_type_fees"; $sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees as c"; $sql .= " WHERE c.id = ".((int) $type_fees_id); $resql = $this->db->query($sql); if ($resql) { $objp_fees = $this->db->fetch_object($resql); $this->line->type_fees_code = $objp_fees->code_type_fees; - $this->line->type_fees_libelle = $objp_fees->libelle_type_fees; + $this->line->type_fees_libelle = $objp_fees->label_type_fees; $this->db->free($resql); } @@ -2431,8 +2431,6 @@ class ExpenseReport extends CommonObject if (!dol_strlen($modele)) { if (!empty($this->model_pdf)) { $modele = $this->model_pdf; - } elseif (!empty($this->modelpdf)) { // deprecated - $modele = $this->modelpdf; } elseif (!empty($conf->global->EXPENSEREPORT_ADDON_PDF)) { $modele = $conf->global->EXPENSEREPORT_ADDON_PDF; } diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index ce232ee8c3b..991e71e8635 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -586,9 +586,10 @@ class Export * @param array $array_selected Filter on array of fields to export * @param array $array_filterValue Filter on array of fields with a filter * @param string $sqlquery If set, transmit the sql request for select (otherwise, sql request is generated from arrays) + * @param string $separator separator to fill $objmodel->separator with the new separator * @return int <0 if KO, >0 if OK */ - public function build_file($user, $model, $datatoexport, $array_selected, $array_filterValue, $sqlquery = '') + public function build_file($user, $model, $datatoexport, $array_selected, $array_filterValue, $sqlquery = '', $separator = '') { // phpcs:enable global $conf, $langs, $mysoc; @@ -612,6 +613,10 @@ class Export require_once $dir.$file; $objmodel = new $classname($this->db); + if (in_array($model, array('csvutf8', 'csviso')) && !empty($separator)) { + $objmodel->separator = $separator; + } + if (!empty($sqlquery)) { $sql = $sqlquery; } else { @@ -706,6 +711,44 @@ class Export $remaintopay = $tmpobjforcomputecall->getRemainToPay(); } $obj->$alias = $remaintopay; + } elseif (is_array($this->array_export_special[$indice][$key]) && + !empty($this->array_export_special[$indice][$key]['rule']) && + $this->array_export_special[$indice][$key]['rule'] == 'compute' + ) { + // Custom compute + $alias = str_replace(array('.', '-', '(', ')'), '_', $key); + $value = ''; + if (!empty($this->array_export_special[$indice][$key]['class']) && + !empty($this->array_export_special[$indice][$key]['classfile']) && + !empty($this->array_export_special[$indice][$key]['method']) + ) { + if (!dol_include_once($this->array_export_special[$indice][$key]['classfile'])) { + $this->error = "Computed field bad configuration: {$this->array_export_special[$indice][$key]['classfile']} not found"; + return -1; + } + + if (!class_exists($this->array_export_special[$indice][$key]['class'])) { + $this->error = "Computed field bad configuration: {$this->array_export_special[$indice][$key]['class']} class doesn't exist"; + return -1; + } + + $className = $this->array_export_special[$indice][$key]['class']; + $tmpObject = new $className($this->db); + if (!method_exists($tmpObject, $this->array_export_special[$indice][$key]['method'])) { + $this->error = "Computed field bad configuration: {$this->array_export_special[$indice][$key]['method']} method doesn't exist"; + return -1; + } + + $methodName = $this->array_export_special[$indice][$key]['method']; + $params = []; + if (!empty($this->array_export_special[$indice][$key]['method_params'])) { + foreach ($this->array_export_special[$indice][$key]['method_params'] as $paramName) { + $params[] = $obj->$paramName ?? null; + } + } + $value = $tmpObject->$methodName(...$params); + } + $obj->$alias = $value; } else { // TODO FIXME // Export of compute field does not work. $obj contains $obj->alias_field and formula may contains $obj->field diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 8fc16e43963..5b6116d153c 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -269,6 +269,7 @@ if ($step == 1 || $action == 'cleanselect') { } if ($action == 'builddoc') { + $separator = GETPOST('delimiter', 'alpha'); $max_execution_time_for_importexport = (empty($conf->global->EXPORT_MAX_EXECUTION_TIME) ? 300 : $conf->global->EXPORT_MAX_EXECUTION_TIME); // 5mn if not defined $max_time = @ini_get("max_execution_time"); if ($max_time && $max_time < $max_execution_time_for_importexport) { @@ -277,7 +278,7 @@ if ($action == 'builddoc') { } // Build export file - $result = $objexport->build_file($user, GETPOST('model', 'alpha'), $datatoexport, $array_selected, $array_filtervalue); + $result = $objexport->build_file($user, GETPOST('model', 'alpha'), $datatoexport, $array_selected, $array_filtervalue, '', $separator); if ($result < 0) { setEventMessages($objexport->error, $objexport->errors, 'errors'); $sqlusedforexport = $objexport->sqlusedforexport; diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php index 79f8991dc09..e90bb20aae3 100644 --- a/htdocs/fichinter/class/api_interventions.class.php +++ b/htdocs/fichinter/class/api_interventions.class.php @@ -73,9 +73,9 @@ class Interventions extends DolibarrApi * Return an array with Expense Report information * * @param int $id ID of Expense Report - * @return Object Object with cleaned properties + * @return Object Object with cleaned properties * - * @throws RestException + * @throws RestException */ public function get($id) { @@ -100,17 +100,18 @@ class Interventions extends DolibarrApi * List of interventions * Return a list of interventions * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param string $thirdparty_ids Thirdparty ids to filter orders of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $thirdparty_ids Thirdparty ids to filter orders of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @param string $properties Restrict the data returned to theses properties. Ignored if empty. Comma separated list of properties names * @return array Array of order objects * * @throws RestException */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '', $properties = '') { global $db, $conf; @@ -183,7 +184,7 @@ class Interventions extends DolibarrApi $obj = $this->db->fetch_object($result); $fichinter_static = new Fichinter($this->db); if ($fichinter_static->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($fichinter_static); + $obj_ret[] = $this->_filterObjectProperties($this->_cleanObjectDatas($fichinter_static), $properties); } $i++; } @@ -257,7 +258,7 @@ class Interventions extends DolibarrApi /** * Add a line to given intervention * - * @param int $id Id of intervention to update + * @param int $id Id of intervention to update * @param array $request_data Request data * * @url POST {id}/lines @@ -339,8 +340,8 @@ class Interventions extends DolibarrApi * "notrigger": 0 * } * - * @param int $id Intervention ID - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @param int $id Intervention ID + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * * @url POST {id}/validate * @@ -376,7 +377,7 @@ class Interventions extends DolibarrApi /** * Close an intervention * - * @param int $id Intervention ID + * @param int $id Intervention ID * * @url POST {id}/close * diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 35a9d37443c..d0b1f4295da 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -438,7 +438,7 @@ class Fichinter extends CommonObject */ public function fetch($rowid, $ref = '') { - $sql = "SELECT f.rowid, f.ref, f.ref_client, f.description, f.fk_soc, f.fk_statut,"; + $sql = "SELECT f.rowid, f.ref, f.ref_client, f.description, f.fk_soc, f.fk_statut as status,"; $sql .= " f.datec, f.dateo, f.datee, f.datet, f.fk_user_author,"; $sql .= " f.date_valid as datev,"; $sql .= " f.tms as datem,"; @@ -462,7 +462,8 @@ class Fichinter extends CommonObject $this->ref_client = $obj->ref_client; $this->description = $obj->description; $this->socid = $obj->fk_soc; - $this->statut = $obj->fk_statut; + $this->status = $obj->status; + $this->statut = $obj->status; // deprecated $this->duration = $obj->duree; $this->datec = $this->db->jdate($obj->datec); $this->dateo = $this->db->jdate($obj->dateo); @@ -474,7 +475,6 @@ class Fichinter extends CommonObject $this->note_public = $obj->note_public; $this->note_private = $obj->note_private; $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; // deprecated $this->fk_contrat = $obj->fk_contrat; $this->entity = $obj->entity; @@ -484,10 +484,6 @@ class Fichinter extends CommonObject $this->last_main_doc = $obj->last_main_doc; - if ($this->statut == 0) { - $this->brouillon = 1; - } - // Retrieve extrafields $this->fetch_optionals(); @@ -573,7 +569,7 @@ class Fichinter extends CommonObject $error = 0; - if ($this->statut != 1) { + if ($this->status != self::STATUS_VALIDATED) { $this->db->begin(); $now = dol_now(); @@ -653,8 +649,8 @@ class Fichinter extends CommonObject // Set new ref and define current statut if (!$error) { $this->ref = $num; - $this->statut = 1; - $this->brouillon = 0; + $this->status = self::STATUS_VALIDATED; + $this->statut = self::STATUS_VALIDATED; // deprecated $this->date_validation = $now; $this->db->commit(); return 1; @@ -714,8 +710,6 @@ class Fichinter extends CommonObject if (!empty($this->model_pdf)) { $modele = $this->model_pdf; - } elseif (!empty($this->modelpdf)) { // deprecated - $modele = $this->modelpdf; } elseif (!empty($conf->global->FICHEINTER_ADDON_PDF)) { $modele = $conf->global->FICHEINTER_ADDON_PDF; } @@ -832,7 +826,7 @@ class Fichinter extends CommonObject if ($option !== 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { @@ -1240,7 +1234,8 @@ class Fichinter extends CommonObject $this->id = 0; $this->ref = ''; - $this->statut = 0; + $this->status = self::STATUS_DRAFT; + $this->statut = self::STATUS_DRAFT; // deprecated // Clear fields $this->user_author_id = $user->id; @@ -1302,7 +1297,7 @@ class Fichinter extends CommonObject { dol_syslog(get_class($this)."::addline $fichinterid, $desc, $date_intervention, $duration"); - if ($this->statut == self::STATUS_DRAFT) { + if ($this->status == self::STATUS_DRAFT) { $this->db->begin(); // Insertion ligne @@ -1846,49 +1841,44 @@ class FichinterLigne extends CommonObjectLine */ public function deleteline($user, $notrigger = 0) { - global $langs, $conf; - $error = 0; - if ($this->statut == 0) { - dol_syslog(get_class($this)."::deleteline lineid=".$this->id); - $this->db->begin(); + dol_syslog(get_class($this)."::deleteline lineid=".$this->id); - $result = $this->deleteExtraFields(); - if ($result < 0) { - $error++; - $this->db->rollback(); - return -1; - } + $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet WHERE rowid = ".((int) $this->id); - $resql = $this->db->query($sql); + $result = $this->deleteExtraFields(); + if ($result < 0) { + $error++; + $this->db->rollback(); + return -1; + } - if ($resql) { - $result = $this->update_total(); - if ($result > 0) { - if (!$notrigger) { - // Call trigger - $result = $this->call_trigger('LINEFICHINTER_DELETE', $user); - if ($result < 0) { - $error++; $this->db->rollback(); return -1; - } - // End call triggers + $sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet WHERE rowid = ".((int) $this->id); + $resql = $this->db->query($sql); + + if ($resql) { + $result = $this->update_total(); + if ($result > 0) { + if (!$notrigger) { + // Call trigger + $result = $this->call_trigger('LINEFICHINTER_DELETE', $user); + if ($result < 0) { + $error++; $this->db->rollback(); return -1; } - - $this->db->commit(); - return $result; - } else { - $this->db->rollback(); - return -1; + // End call triggers } + + $this->db->commit(); + return $result; } else { - $this->error = $this->db->error()." sql=".$sql; $this->db->rollback(); return -1; } } else { - return -2; + $this->error = $this->db->error()." sql=".$sql; + $this->db->rollback(); + return -1; } } } diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php index a1df7940142..8d6b65b5c6b 100644 --- a/htdocs/fichinter/class/fichinterrec.class.php +++ b/htdocs/fichinter/class/fichinterrec.class.php @@ -121,7 +121,7 @@ class FichinterRec extends Fichinter */ public function getLibStatut($mode = 0) { - return $this->LibStatut($this->statut, $mode); + return $this->LibStatut($this->status, $mode); } @@ -150,13 +150,11 @@ class FichinterRec extends Fichinter $fichintsrc = new Fichinter($this->db); $result = $fichintsrc->fetch($this->id_origin); - $result = $fichintsrc->fetch_lines(); // to get all lines - + if ($result > 0) { + $result = $fichintsrc->fetch_lines(); // to get all lines + } if ($result > 0) { - // On positionne en mode brouillon la facture - $this->brouillon = 1; - $sql = "INSERT INTO ".MAIN_DB_PREFIX."fichinter_rec ("; $sql .= "titre"; $sql .= ", fk_soc"; @@ -170,7 +168,6 @@ class FichinterRec extends Fichinter $sql .= ", fk_projet"; $sql .= ", fk_contrat"; $sql .= ", modelpdf"; - $sql .= ", frequency"; $sql .= ", unit_frequency"; $sql .= ", date_when"; @@ -178,7 +175,6 @@ class FichinterRec extends Fichinter $sql .= ", nb_gen_done"; $sql .= ", nb_gen_max"; // $sql.= ", auto_validate"; - $sql .= ") VALUES ("; $sql .= "'".$this->db->escape($this->title)."'"; $sql .= ", ".($this->socid > 0 ? ((int) $this->socid) : 'null'); @@ -199,12 +195,12 @@ class FichinterRec extends Fichinter $sql .= ", ".(!empty($fichintsrc->model_pdf) ? "'".$this->db->escape($fichintsrc->model_pdf)."'" : "''"); - // récurrence + // Frequency $sql .= ", ".(!empty($this->frequency) ? ((int) $this->frequency) : "null"); $sql .= ", '".$this->db->escape($this->unit_frequency)."'"; $sql .= ", ".(!empty($this->date_when) ? "'".$this->db->idate($this->date_when)."'" : 'null'); $sql .= ", ".(!empty($this->date_last_gen) ? "'".$this->db->idate($this->date_last_gen)."'" : 'null'); - $sql .= ", 0"; // we start à 0 + $sql .= ", 0"; // we start at 0 $sql .= ", ".((int) $this->nb_gen_max); // $sql.= ", ".$this->auto_validate; $sql .= ")"; @@ -299,14 +295,14 @@ class FichinterRec extends Fichinter $this->datec = $obj->datec; $this->duration = $obj->duree; $this->socid = $obj->fk_soc; - $this->statut = 0; + $this->status = 0; + $this->statut = 0; // deprecated $this->fk_project = $obj->fk_projet; $this->fk_contrat = $obj->fk_contrat; $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->user_author = $obj->fk_user_author; - $this->model_pdf = !empty($obj->model_pdf) ? $obj->model_pdf : ""; - $this->modelpdf = !empty($obj->model_pdf) ? $obj->model_pdf : ""; // deprecated + $this->model_pdf = empty($obj->model_pdf) ? "" : $obj->model_pdf; $this->rang = !empty($obj->rang) ? $obj->rang : ""; $this->special_code = !empty($obj->special_code) ? $obj->special_code : ""; $this->frequency = $obj->frequency; @@ -317,8 +313,6 @@ class FichinterRec extends Fichinter $this->nb_gen_max = $obj->nb_gen_max; $this->auto_validate = $obj->auto_validate; - $this->brouillon = 1; - // Lines $result = $this->fetch_lines(); if ($result < 0) { @@ -483,7 +477,7 @@ class FichinterRec extends Fichinter return -1; } - if ($this->brouillon) { + if ($this->status == self::STATUS_DRAFT) { // Clean parameters $remise_percent = price2num($remise_percent); $qty = price2num($qty); diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php index 32495a8b9ad..51e97cb7bfe 100644 --- a/htdocs/fichinter/document.php +++ b/htdocs/fichinter/document.php @@ -129,7 +129,7 @@ if ($object->id) { if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref .= '
    '; - if ($usercancreate && 0) { + if ($permissiontoadd && 0) { $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; @@ -164,7 +164,6 @@ if ($object->id) { print dol_get_fiche_end(); $modulepart = 'ficheinter'; - $permissiontoadd = $user->rights->ficheinter->creer; $permtoedit = $user->rights->ficheinter->creer; $param = '&id='.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 9979cf8923b..17a3a16485f 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -720,7 +720,7 @@ while ($i < $imaxinloop) { $objectstatic->id = $obj->rowid; $objectstatic->ref = $obj->ref; $objectstatic->ref_client = $obj->ref_client; - $objectstatic->statut = $obj->status; + $objectstatic->statut = $obj->status; // deprecated $objectstatic->status = $obj->status; $companystatic->name = $obj->name; diff --git a/htdocs/fichinter/note.php b/htdocs/fichinter/note.php index aa2f452bbd0..471c5c64485 100644 --- a/htdocs/fichinter/note.php +++ b/htdocs/fichinter/note.php @@ -94,7 +94,7 @@ if ($id > 0 || !empty($ref)) { if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref .= '
    '; - if ($usercancreate && 0) { + if ($permissionnote && 0) { $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 0070d587f01..cfad9f838b1 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', '18.0.1'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c + define('DOL_VERSION', '19.0.0-dev'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c } if (!defined('EURO')) { @@ -61,7 +61,6 @@ if (defined('DOL_INC_FOR_VERSION_ERROR')) { return; } - // Define vars $conffiletoshowshort = "conf.php"; // Define localization of conf file @@ -76,10 +75,22 @@ $conffiletoshow = "htdocs/conf/conf.php"; // Include configuration // --- End of part replaced by Dolibarr packager makepack-dolibarr - // Include configuration $result = @include_once $conffile; // Keep @ because with some error reporting this break the redirect done when file not found +// Disable some not used PHP stream +$listofwrappers = stream_get_wrappers(); +// We need '.phar' for geoip2. TODO Replace phar in geoip with exploded files so we can disable phar. +$arrayofstreamtodisable = array('compress.zlib', 'compress.bzip2', 'ftps', 'glob', 'data', 'expect', 'ftp', 'ogg', 'rar', 'zip', 'zlib'); +foreach ($arrayofstreamtodisable as $streamtodisable) { + if (!empty($listofwrappers) && in_array($streamtodisable, $listofwrappers)) { + if (!empty($dolibarr_main_stream_enabled) && is_array($dolibarr_main_stream_enabled) && in_array($streamtodisable, $dolibarr_main_stream_enabled)) { + continue; // We do not disable this stream + } + stream_wrapper_unregister($streamtodisable); + } +} + if (!$result && !empty($_SERVER["GATEWAY_INTERFACE"])) { // If install not done and we are in a web session if (!empty($_SERVER["CONTEXT_PREFIX"])) { // CONTEXT_PREFIX and CONTEXT_DOCUMENT_ROOT are not defined on all apache versions $path = $_SERVER["CONTEXT_PREFIX"]; // example '/dolibarr/' when using an apache alias. diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index dfd7d20248e..a5185f50acc 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -108,6 +108,7 @@ if (empty($reshook)) { $result = $object->update($object->id, $user, 1, 0, 1); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); + $action = 'editsupplieraccountancycode'; } } // Set vat number accounting account diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index a531667d0e5..a09b8d4fbf6 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -18,8 +18,8 @@ use Luracast\Restler\RestException; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; +require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT . '/fourn/class/paiementfourn.class.php'; /** * API class for supplier invoices @@ -58,10 +58,10 @@ class SupplierInvoices extends DolibarrApi * * Return an array with supplier invoice information * - * @param int $id ID of supplier invoice - * @return Object Object with cleaned properties + * @param int $id ID of supplier invoice + * @return Object Object with cleaned properties * - * @throws RestException + * @throws RestException */ public function get($id) { @@ -75,7 +75,7 @@ class SupplierInvoices extends DolibarrApi } if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } $this->invoice->fetchObjectLinked(); @@ -87,18 +87,19 @@ class SupplierInvoices extends DolibarrApi * * Get a list of supplier invoices * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param string $thirdparty_ids Thirdparty ids to filter invoices of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} - * @param string $status Filter by invoice status : draft | unpaid | paid | cancelled + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $thirdparty_ids Thirdparty ids to filter invoices of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} + * @param string $status Filter by invoice status : draft | unpaid | paid | cancelled * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')" + * @param string $properties Restrict the data returned to theses properties. Ignored if empty. Comma separated list of properties names * @return array Array of invoice objects * * @throws RestException */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '', $properties = '') { global $db; @@ -122,19 +123,19 @@ class SupplierInvoices extends DolibarrApi if (!DolibarrApiAccess::$user->hasRight("societe", "client", "voir") || $search_sale > 0) { $sql .= ", sc.fk_soc, sc.fk_user"; } - $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn AS t LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields + $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn AS t LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields // We need this table joined to the select in order to filter by sale if (!DolibarrApiAccess::$user->hasRight("societe", "client", "voir") || $search_sale > 0) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } - $sql .= ' WHERE t.entity IN ('.getEntity('supplier_invoice').')'; + $sql .= ' WHERE t.entity IN (' . getEntity('supplier_invoice') . ')'; if (!DolibarrApiAccess::$user->hasRight("societe", "client", "voir") || $search_sale > 0) { $sql .= " AND t.fk_soc = sc.fk_soc"; } if ($socids) { - $sql .= " AND t.fk_soc IN (".$this->db->sanitize($socids).")"; + $sql .= " AND t.fk_soc IN (" . $this->db->sanitize($socids) . ")"; } if ($search_sale > 0) { $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale @@ -155,14 +156,14 @@ class SupplierInvoices extends DolibarrApi } // Insert sale filter if ($search_sale > 0) { - $sql .= " AND sc.fk_user = ".((int) $search_sale); + $sql .= " AND sc.fk_user = " . ((int) $search_sale); } // Add sql filters if ($sqlfilters) { $errormessage = ''; $sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage); if ($errormessage) { - throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage); + throw new RestException(400, 'Error when validating parameter sqlfilters -> ' . $errormessage); } } @@ -185,12 +186,12 @@ class SupplierInvoices extends DolibarrApi $obj = $this->db->fetch_object($result); $invoice_static = new FactureFournisseur($this->db); if ($invoice_static->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($invoice_static); + $obj_ret[] = $this->_filterObjectProperties($this->_cleanObjectDatas($invoice_static), $properties); } $i++; } } else { - throw new RestException(503, 'Error when retrieve supplier invoice list : '.$this->db->lasterror()); + throw new RestException(503, 'Error when retrieve supplier invoice list : ' . $this->db->lasterror()); } if (!count($obj_ret)) { throw new RestException(404, 'No supplier invoice found'); @@ -256,7 +257,7 @@ class SupplierInvoices extends DolibarrApi } if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } foreach ($request_data as $field => $value) { @@ -295,7 +296,7 @@ class SupplierInvoices extends DolibarrApi } if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } if ($this->invoice->delete(DolibarrApiAccess::$user) < 0) { @@ -338,7 +339,7 @@ class SupplierInvoices extends DolibarrApi } if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } $result = $this->invoice->validate(DolibarrApiAccess::$user, '', $idwarehouse, $notrigger); @@ -346,13 +347,13 @@ class SupplierInvoices extends DolibarrApi throw new RestException(304, 'Error nothing done. The invoice is already validated'); } if ($result < 0) { - throw new RestException(500, 'Error when validating Invoice: '.$this->invoice->error); + throw new RestException(500, 'Error when validating Invoice: ' . $this->invoice->error); } return array( 'success' => array( 'code' => 200, - 'message' => 'Invoice validated (Ref='.$this->invoice->ref.')' + 'message' => 'Invoice validated (Ref=' . $this->invoice->ref . ')' ) ); } @@ -380,7 +381,7 @@ class SupplierInvoices extends DolibarrApi } if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } $result = $this->invoice->fetch($id); @@ -409,6 +410,7 @@ class SupplierInvoices extends DolibarrApi * @param string $comment {@from body} Note (optional) * @param string $chqemetteur {@from body} Payment issuer (mandatory if payment_mode_id corresponds to 'CHQ'-payment type) * @param string $chqbank {@from body} Issuer bank name (optional) + * @param float $amount {@from body} Amount of payment if we don't want to use the remain to pay * * @url POST {id}/payments * @@ -417,7 +419,7 @@ class SupplierInvoices extends DolibarrApi * @throws RestException 401 * @throws RestException 404 */ - public function addPayment($id, $datepaye, $payment_mode_id, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '') + public function addPayment($id, $datepaye, $payment_mode_id, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '', $amount = null) { global $conf; @@ -429,7 +431,7 @@ class SupplierInvoices extends DolibarrApi } if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } if (isModEnabled("banque")) { @@ -448,18 +450,24 @@ class SupplierInvoices extends DolibarrApi throw new RestException(404, 'Invoice not found'); } - // Calculate amount to pay - $totalpaid = $this->invoice->getSommePaiement(); - $totaldeposits = $this->invoice->getSumDepositsUsed(); - $resteapayer = price2num($this->invoice->total_ttc - $totalpaid - $totaldeposits, 'MT'); + if (null !== $amount && $amount > 0) { + // We use the amount given in parameter + $paymentamount = $amount; + } else { + // We calculate the remain to pay, and use it as amount + $totalpaid = $this->invoice->getSommePaiement(); + $totaldeposits = $this->invoice->getSumDepositsUsed(); + $paymentamount = price2num($this->invoice->total_ttc - $totalpaid - $totaldeposits, 'MT'); + } $this->db->begin(); $amounts = array(); $multicurrency_amounts = array(); - $resteapayer = price2num($resteapayer, 'MT'); - $amounts[$id] = $resteapayer; + $paymentamount = price2num($paymentamount, 'MT'); + + $amounts[$id] = $paymentamount; // Multicurrency $newvalue = price2num($this->invoice->multicurrency_total_ttc, 'MT'); @@ -478,14 +486,14 @@ class SupplierInvoices extends DolibarrApi $paiement_id = $paiement->create(DolibarrApiAccess::$user, ($closepaidinvoices == 'yes' ? 1 : 0)); // This include closing invoices if ($paiement_id < 0) { $this->db->rollback(); - throw new RestException(400, 'Payment error : '.$paiement->error); + throw new RestException(400, 'Payment error : ' . $paiement->error); } if (isModEnabled("banque")) { $result = $paiement->addPaymentToBank(DolibarrApiAccess::$user, 'payment_supplier', '(SupplierInvoicePayment)', $accountid, $chqemetteur, $chqbank); if ($result < 0) { $this->db->rollback(); - throw new RestException(400, 'Add payment to bank error : '.$paiement->error); + throw new RestException(400, 'Add payment to bank error : ' . $paiement->error); } } @@ -515,7 +523,7 @@ class SupplierInvoices extends DolibarrApi } if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } $this->invoice->fetch_lines(); $result = array(); @@ -551,7 +559,7 @@ class SupplierInvoices extends DolibarrApi } if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } $request_data = (object) $request_data; @@ -585,7 +593,7 @@ class SupplierInvoices extends DolibarrApi ); if ($updateRes < 0) { - throw new RestException(400, 'Unable to insert the new line. Check your inputs. '.$this->invoice->error); + throw new RestException(400, 'Unable to insert the new line. Check your inputs. ' . $this->invoice->error); } return $updateRes; @@ -618,7 +626,7 @@ class SupplierInvoices extends DolibarrApi } if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } $request_data = (object) $request_data; @@ -662,7 +670,7 @@ class SupplierInvoices extends DolibarrApi * Deletes a line of a given supplier invoice * * @param int $id Id of supplier invoice - * @param int $lineid Id of the line to delete + * @param int $lineid Id of the line to delete * * @url DELETE {id}/lines/{lineid} * @@ -689,7 +697,7 @@ class SupplierInvoices extends DolibarrApi } if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } // TODO Check the lineid $lineid is a line of ojbect diff --git a/htdocs/fourn/class/api_supplier_orders.class.php b/htdocs/fourn/class/api_supplier_orders.class.php index 503bd908a2d..3dad6ca8a9e 100644 --- a/htdocs/fourn/class/api_supplier_orders.class.php +++ b/htdocs/fourn/class/api_supplier_orders.class.php @@ -56,10 +56,10 @@ class SupplierOrders extends DolibarrApi * * Return an array with supplier order information * - * @param int $id ID of supplier order - * @return array|mixed data without useless information + * @param int $id ID of supplier order + * @return array|mixed data without useless information * - * @throws RestException + * @throws RestException */ public function get($id) { @@ -85,19 +85,20 @@ class SupplierOrders extends DolibarrApi * * Get a list of supplier orders * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param string $thirdparty_ids Thirdparty ids to filter orders of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} - * @param string $product_ids Product ids to filter orders of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} - * @param string $status Filter by order status : draft | validated | approved | running | received_start | received_end | cancelled | refused + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $thirdparty_ids Thirdparty ids to filter orders of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} + * @param string $product_ids Product ids to filter orders of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} + * @param string $status Filter by order status : draft | validated | approved | running | received_start | received_end | cancelled | refused * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')" + * @param string $properties Restrict the data returned to theses properties. Ignored if empty. Comma separated list of properties names * @return array Array of order objects * * @throws RestException */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $product_ids = '', $status = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $product_ids = '', $status = '', $sqlfilters = '', $properties = '') { global $db, $conf; @@ -112,17 +113,17 @@ class SupplierOrders extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (!DolibarrApiAccess::$user->hasRight("societe", "client", "voir") && !$socids) { + if (!DolibarrApiAccess::$user->hasRight("societe", "client", "voir") && !empty($socids)) { $search_sale = DolibarrApiAccess::$user->id; } $sql = "SELECT t.rowid"; - if ((!DolibarrApiAccess::$user->hasRight("societe", "client", "voir") && !$socids) || $search_sale > 0) { + if ((!DolibarrApiAccess::$user->hasRight("societe", "client", "voir")) || $search_sale > 0) { $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) } $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur AS t LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields - if ((!DolibarrApiAccess::$user->hasRight("societe", "client", "voir") && !$socids) || $search_sale > 0) { + if ((!DolibarrApiAccess::$user->hasRight("societe", "client", "voir")) || $search_sale > 0) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale } @@ -131,7 +132,7 @@ class SupplierOrders extends DolibarrApi } $sql .= ' WHERE t.entity IN ('.getEntity('supplier_order').')'; - if ((!DolibarrApiAccess::$user->hasRight("societe", "client", "voir") && !$socids) || $search_sale > 0) { + if ((!DolibarrApiAccess::$user->hasRight("societe", "client", "voir")) || $search_sale > 0) { $sql .= " AND t.fk_soc = sc.fk_soc"; } if (!empty($product_ids)) { @@ -140,9 +141,6 @@ class SupplierOrders extends DolibarrApi if ($socids) { $sql .= " AND t.fk_soc IN (".$this->db->sanitize($socids).")"; } - if ($search_sale > 0) { - $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale - } // Filter by status if ($status == 'draft') { @@ -201,7 +199,7 @@ class SupplierOrders extends DolibarrApi $obj = $this->db->fetch_object($result); $order_static = new CommandeFournisseur($this->db); if ($order_static->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($order_static); + $obj_ret[] = $this->_filterObjectProperties($this->_cleanObjectDatas($order_static), $properties); } $i++; } @@ -292,14 +290,14 @@ class SupplierOrders extends DolibarrApi * * Return an array with contact informations * - * @param int $id ID of supplier order - * @param string $source Source of the contact (internal, external, all). - * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER, SALESREPFOLL, ...) + * @param int $id ID of supplier order + * @param string $source Source of the contact (internal, external, all). + * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER, SALESREPFOLL, ...) * @return Object Object with cleaned properties * * @url GET {id}/contacts * - * @throws RestException + * @throws RestException */ public function getContacts($id, $source, $type = '') { @@ -333,10 +331,10 @@ class SupplierOrders extends DolibarrApi /** * Add a contact type of given supplier order * - * @param int $id Id of supplier order to update - * @param int $contactid Id of contact/user to add - * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER, SALESREPFOLL, ...) - * @param string $source Source of the contact (external, internal) + * @param int $id Id of supplier order to update + * @param int $contactid Id of contact/user to add + * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER, SALESREPFOLL, ...) + * @param string $source Source of the contact (external, internal) * @return array * * @url POST {id}/contact/{contactid}/{type}/{source} @@ -380,10 +378,10 @@ class SupplierOrders extends DolibarrApi /** * Unlink a contact type of given supplier order * - * @param int $id Id of supplier order to update - * @param int $contactid Id of contact/user to add - * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER, SALESREPFOLL, ...). - * @param string $source Source of the contact (internal, external). + * @param int $id Id of supplier order to update + * @param int $contactid Id of contact/user to add + * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER, SALESREPFOLL, ...). + * @param string $source Source of the contact (internal, external). * * @url DELETE {id}/contact/{contactid}/{type}/{source} * @@ -439,7 +437,7 @@ class SupplierOrders extends DolibarrApi /** * Delete supplier order * - * @param int $id Supplier order ID + * @param int $id Supplier order ID * @return array Array of result */ public function delete($id) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 7f59a6076ea..6f251175786 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -112,7 +112,6 @@ class CommandeFournisseur extends CommonOrder */ public $ref_fourn; - public $brouillon; /** * @var int */ @@ -226,7 +225,6 @@ class CommandeFournisseur extends CommonOrder public $multicurrency_total_tva; public $multicurrency_total_ttc; - /** * 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter[:Sortfield]]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" @@ -376,14 +374,12 @@ class CommandeFournisseur extends CommonOrder */ public function fetch($id, $ref = '') { - global $conf; - // Check parameters if (empty($id) && empty($ref)) { return -1; } - $sql = "SELECT c.rowid, c.entity, c.ref, ref_supplier, c.fk_soc, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.total_tva,"; + $sql = "SELECT c.rowid, c.entity, c.ref, ref_supplier, c.fk_soc, c.fk_statut as status, c.amount_ht, c.total_ht, c.total_ttc, c.total_tva,"; $sql .= " c.localtax1, c.localtax2, "; $sql .= " c.date_creation, c.date_valid, c.date_approve, c.date_approve2,"; $sql .= " c.fk_user_author, c.fk_user_valid, c.fk_user_approve, c.fk_user_approve2,"; @@ -429,8 +425,8 @@ class CommandeFournisseur extends CommonOrder $this->ref_supplier = $obj->ref_supplier; $this->socid = $obj->fk_soc; $this->fourn_id = $obj->fk_soc; - $this->statut = $obj->fk_statut; - $this->status = $obj->fk_statut; + $this->statut = $obj->status; // deprecated + $this->status = $obj->status; $this->billed = $obj->billed; $this->user_author_id = $obj->fk_user_author; $this->user_valid_id = $obj->fk_user_valid; @@ -472,7 +468,6 @@ class CommandeFournisseur extends CommonOrder $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; // deprecated //Incoterms $this->fk_incoterms = $obj->fk_incoterms; @@ -495,13 +490,7 @@ class CommandeFournisseur extends CommonOrder // fetch optionals attributes and labels $this->fetch_optionals(); - if ($this->statut == 0) { - $this->brouillon = 1; - } - - /* - * Lines - */ + // Lines $result = $this->fetch_lines(); if ($result < 0) { @@ -690,11 +679,11 @@ class CommandeFournisseur extends CommonOrder $sql = 'UPDATE '.MAIN_DB_PREFIX."commande_fournisseur"; $sql .= " SET ref='".$this->db->escape($num)."',"; - $sql .= " fk_statut = ".self::STATUS_VALIDATED.","; + $sql .= " fk_statut = ".((int) self::STATUS_VALIDATED).","; $sql .= " date_valid='".$this->db->idate(dol_now())."',"; $sql .= " fk_user_valid = ".((int) $user->id); $sql .= " WHERE rowid = ".((int) $this->id); - $sql .= " AND fk_statut = ".self::STATUS_DRAFT; + $sql .= " AND fk_statut = ".((int) self::STATUS_DRAFT); $resql = $this->db->query($sql); if (!$resql) { @@ -750,7 +739,8 @@ class CommandeFournisseur extends CommonOrder if (!$error) { $result = 1; - $this->statut = self::STATUS_VALIDATED; + $this->status = self::STATUS_VALIDATED; + $this->statut = self::STATUS_VALIDATED; // deprecated $this->ref = $num; } @@ -948,7 +938,7 @@ class CommandeFournisseur extends CommonOrder if ($option !== 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { @@ -1446,8 +1436,8 @@ class CommandeFournisseur extends CommonOrder $this->multicurrency_tx = 1; } - // We set order into draft status - $this->brouillon = 1; + $this->statut = self::STATUS_DRAFT; // deprecated + $this->status = self::STATUS_DRAFT; $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseur ("; $sql .= "ref"; @@ -1473,7 +1463,7 @@ class CommandeFournisseur extends CommonOrder $sql .= ") "; $sql .= " VALUES ("; $sql .= "'(PROV)'"; - $sql .= ", '".$this->db->escape($this->ref_supplier)."'"; + $sql .= ", ".(isset($this->ref_supplier) ? "'".$this->db->escape($this->ref_supplier)."'" : "NULL"); $sql .= ", '".$this->db->escape($this->note_private)."'"; $sql .= ", '".$this->db->escape($this->note_public)."'"; $sql .= ", ".setEntity($this); @@ -1504,12 +1494,11 @@ class CommandeFournisseur extends CommonOrder // insert products details into database for ($i = 0; $i < $num; $i++) { - $line = $this->lines[$i]; + $line = $this->lines[$i]; if (!is_object($line)) { $line = (object) $line; } - //$this->special_code = $line->special_code; // TODO : remove this in 9.0 and add special_code param to addline() // This include test on qty if option SUPPLIER_ORDER_WITH_NOPRICEDEFINED is not set @@ -1545,6 +1534,7 @@ class CommandeFournisseur extends CommonOrder $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur"; $sql .= " SET ref='(PROV".$this->id.")'"; $sql .= " WHERE rowid=".((int) $this->id); + dol_syslog(get_class($this)."::create", LOG_DEBUG); if ($this->db->query($sql)) { // Add link with price request and supplier order @@ -1768,7 +1758,7 @@ class CommandeFournisseur extends CommonOrder $this->user_valid = 0; $this->date_creation = ''; $this->date_validation = ''; - $this->ref_supplier = ''; + $this->ref_supplier = null; $this->user_approve_id = ''; $this->user_approve_id2 = ''; $this->date_approve = ''; @@ -2543,7 +2533,7 @@ class CommandeFournisseur extends CommonOrder $result = 1; $old_statut = $this->statut; $this->statut = $statut; - $this->actionmsg2 = $comment; + $this->context['actionmsg2'] = $comment; // Call trigger $result_trigger = $this->call_trigger('ORDER_SUPPLIER_RECEIVE', $user); @@ -2834,7 +2824,7 @@ class CommandeFournisseur extends CommonOrder $error = 0; - if ($this->brouillon) { + if ($this->statut == self::STATUS_DRAFT) { // Clean parameters if (empty($qty)) { $qty = 0; diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php index 6e7b5d60505..3ded6e8fc61 100644 --- a/htdocs/fourn/class/fournisseur.facture-rec.class.php +++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php @@ -71,14 +71,28 @@ class FactureFournisseurRec extends CommonInvoice protected $table_ref_field = 'titre'; /** - * @var string The label of recurring invoice + * @var string The label of recurring invoice + * @deprecated Use $title */ public $titre; + /** + * @var string The label of recurring invoice + */ + public $title; + public $ref_supplier; public $socid; - public $suspended; + public $suspended; // status + + /** + * @var string Label of invoice + * @deprecated Use $label + */ public $libelle; + /** + * @var string Label of invoice + */ public $label; /** @@ -111,6 +125,7 @@ class FactureFournisseurRec extends CommonInvoice public $fk_multicurrency; public $multicurrency_code; public $multicurrency_tx; + public $multicurrency_subprice; public $multicurrency_total_ht; public $multicurrency_total_tva; public $multicurrency_total_ttc; @@ -478,8 +493,6 @@ class FactureFournisseurRec extends CommonInvoice */ public function update(User $user, $notrigger = 0) { - global $conf; - $error = 0; $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_rec SET"; @@ -568,7 +581,7 @@ class FactureFournisseurRec extends CommonInvoice $sql .= ', f.fk_mode_reglement, p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql .= ', f.fk_cond_reglement, c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; $sql .= ', f.date_lim_reglement'; - $sql .= ', f.note_private, f.note_public, f.modelpdf'; + $sql .= ', f.note_private, f.note_public, f.modelpdf as model_pdf'; $sql .= ', f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc'; $sql .= ', f.usenewprice, f.frequency, f.unit_frequency, f.date_when, f.date_last_gen, f.nb_gen_done, f.nb_gen_max, f.auto_validate'; $sql .= ', f.generate_pdf'; @@ -622,7 +635,7 @@ class FactureFournisseurRec extends CommonInvoice $this->date_lim_reglement = $this->db->jdate($obj->date_lim_reglement); $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; - $this->model_pdf = $obj->modelpdf; + $this->model_pdf = $obj->model_pdf; // Multicurrency $this->fk_multicurrency = $obj->fk_multicurrency; @@ -642,11 +655,6 @@ class FactureFournisseurRec extends CommonInvoice $this->auto_validate = $obj->auto_validate; $this->generate_pdf = $obj->generate_pdf; - - if ($this->statut == self::STATUS_DRAFT) { - $this->brouillon = 1; - } - // Retrieve all extrafield // fetch optionals attributes and labels $this->fetch_optionals(); @@ -1078,7 +1086,7 @@ class FactureFournisseurRec extends CommonInvoice return -1; } - if ($this->brouillon) { + if ($this->status == self::STATUS_SUSPENDED) { // Clean parameters $fk_product = empty($fk_product) ? 0 : $fk_product; $label = empty($label) ? '' : $label; @@ -1188,6 +1196,19 @@ class FactureFournisseurRec extends CommonInvoice } + /** + * Return next reference of invoice not already used (or last reference) + * + * @param Societe $soc Thirdparty object + * @param string $mode 'next' for next value or 'last' for last value + * @return string free ref or last ref + */ + public function getNextNumRef($soc, $mode = 'next') + { + // Not used for recurring invoices + return ''; + } + /** * Return the next date of * @@ -1305,8 +1326,7 @@ class FactureFournisseurRec extends CommonInvoice $new_fac_fourn->fk_fac_rec_source = $facturerec->id; // We will create $facture from this recurring invoice $new_fac_fourn->type = self::TYPE_STANDARD; - $new_fac_fourn->brouillon = 1; - $new_fac_fourn->statut = self::STATUS_DRAFT; + $new_fac_fourn->statut = self::STATUS_DRAFT; // deprecated $new_fac_fourn->status = self::STATUS_DRAFT; $new_fac_fourn->date = empty($facturerec->date_when) ? $now : $facturerec->date_when; // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later. $new_fac_fourn->socid = $facturerec->socid; @@ -1314,7 +1334,8 @@ class FactureFournisseurRec extends CommonInvoice $new_fac_fourn->ref_supplier = $facturerec->ref_supplier; $new_fac_fourn->model_pdf = $facturerec->model_pdf; $new_fac_fourn->fk_project = $facturerec->fk_project; - $new_fac_fourn->libelle = $facturerec->libelle; + $new_fac_fourn->label = $facturerec->label; + $new_fac_fourn->libelle = $facturerec->label; // deprecated $invoiceidgenerated = $new_fac_fourn->create($user); if ($invoiceidgenerated <= 0) { @@ -1992,23 +2013,6 @@ class FactureFournisseurLigneRec extends CommonObjectLine public $fk_user_author; public $fk_user_modif; public $fk_multicurrency; - public $multicurrency_subprice; - - - /* Overrides fields in CommonObject - public $total_ht; - public $total_tva; - public $total_localtax1; - public $total_localtax2; - public $total_ttc; - - public $fk_unit; - public $import_key; - public $multicurrency_code; - public $multicurrency_total_ht; - public $multicurrency_total_tva; - public $multicurrency_total_ttc; - */ /** diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index c55832a6f83..0ee31784a16 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -107,13 +107,16 @@ class FactureFournisseur extends CommonInvoice */ public $ref_supplier; + /** + * @var string Label of invoice + * @deprecated Use $label + */ + public $libelle; /** * @var string Label of invoice */ public $label; - public $socid; - //Check constants for types public $type = self::TYPE_STANDARD; @@ -131,19 +134,6 @@ class FactureFournisseur extends CommonInvoice */ public $status; - /** - * ! Closing after partial payment: discount_vat, badsupplier, abandon - * ! Closing when no payment: replaced, abandoned - * @var string Close code - */ - public $close_code; - - /** - * ! Comment if paid without full payment - * @var string Close note - */ - public $close_note; - /** * Set to 1 if the invoice is completely paid, otherwise is 0 * @var int @@ -166,13 +156,6 @@ class FactureFournisseur extends CommonInvoice */ public $tms; - /** - * Invoice date (date) - * - * @var integer - */ - public $date; - /** * Max payment date (date_echeance) * @@ -217,19 +200,11 @@ class FactureFournisseur extends CommonInvoice public $note_public; public $propalid; - public $cond_reglement_id; - public $cond_reglement_code; - public $cond_reglement_label; - public $cond_reglement_doc; - /** * @var int ID */ public $fk_account; // default bank account - public $mode_reglement_id; - public $mode_reglement_code; - /** * @var int transport mode id */ @@ -481,9 +456,8 @@ class FactureFournisseur extends CommonInvoice if (! $this->mode_reglement_id) { $this->mode_reglement_id = 0; } - $this->brouillon = 1; $this->status = self::STATUS_DRAFT; - $this->statut = self::STATUS_DRAFT; + $this->statut = self::STATUS_DRAFT; // deprecated $this->linked_objects = $_facrec->linkedObjectsIds; // We do not add link to template invoice or next invoice will be linked to all generated invoices @@ -986,7 +960,6 @@ class FactureFournisseur extends CommonInvoice $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; // deprecated $this->import_key = $obj->import_key; //Incoterms @@ -1012,10 +985,6 @@ class FactureFournisseur extends CommonInvoice // fetch optionals attributes and labels $this->fetch_optionals(); - if ($this->statut == self::STATUS_DRAFT) { - $this->brouillon = 1; - } - $result = $this->fetch_lines(); if ($result < 0) { $this->error = $this->db->lasterror(); @@ -1770,7 +1739,7 @@ class FactureFournisseur extends CommonInvoice */ public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger = 0) { - global $conf, $langs; + global $mysoc, $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -1799,6 +1768,53 @@ class FactureFournisseur extends CommonInvoice return -1; } + // Check for mandatory fields in thirdparty (defined into setup) + if (!empty($this->thirdparty) && is_object($this->thirdparty)) { + $array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL', 'ACCOUNTANCY_CODE_SUPPLIER'); + foreach ($array_to_check as $key) { + $keymin = strtolower($key); + if ($keymin == 'accountancy_code_supplier') $keymin = 'code_compta_fournisseur'; + if (!property_exists($this->thirdparty, $keymin)) { + continue; + } + $vallabel = $this->thirdparty->$keymin; + + $i = (int) preg_replace('/[^0-9]/', '', $key); + if ($i > 0) { + if ($this->thirdparty->isACompany()) { + // Check for mandatory prof id (but only if country is other than ours) + if ($mysoc->country_id > 0 && $this->thirdparty->country_id == $mysoc->country_id) { + $idprof_mandatory = 'SOCIETE_'.$key.'_INVOICE_MANDATORY'; + if (!$vallabel && !empty($conf->global->$idprof_mandatory)) { + $langs->load("errors"); + $this->error = $langs->trans('ErrorProdIdIsMandatory', $langs->transcountry('ProfId'.$i, $this->thirdparty->country_code)).' ('.$langs->trans("ForbiddenBySetupRules").') ['.$langs->trans('Company').' : '.$this->thirdparty->name.']'; + dol_syslog(__METHOD__.' '.$this->error, LOG_ERR); + return -1; + } + } + } + } else { + if ($key == 'EMAIL') { + // Check for mandatory + if (!empty($conf->global->SOCIETE_EMAIL_INVOICE_MANDATORY) && !isValidEMail($this->thirdparty->email)) { + $langs->load("errors"); + $this->error = $langs->trans("ErrorBadEMail", $this->thirdparty->email).' ('.$langs->trans("ForbiddenBySetupRules").') ['.$langs->trans('Company').' : '.$this->thirdparty->name.']'; + dol_syslog(__METHOD__.' '.$this->error, LOG_ERR); + return -1; + } + } elseif ($key == 'ACCOUNTANCY_CODE_SUPPLIER') { + // Check for mandatory + if (!empty($conf->global->SOCIETE_ACCOUNTANCY_CODE_SUPPLIER_INVOICE_MANDATORY) && empty($this->thirdparty->code_compta_fournisseur)) { + $langs->load("errors"); + $this->error = $langs->trans("ErrorAccountancyCodeSupplierIsMandatory", $this->thirdparty->name).' ('.$langs->trans("ForbiddenBySetupRules").')'; + dol_syslog(__METHOD__.' '.$this->error, LOG_ERR); + return -1; + } + } + } + } + } + $this->db->begin(); // Define new ref @@ -2817,7 +2833,7 @@ class FactureFournisseur extends CommonInvoice if ($option !== 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 9c83f79e812..ba7508964dc 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1264,7 +1264,7 @@ class ProductFournisseur extends Product if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 5a31e6737b0..7920b21cdd7 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2015,6 +2015,12 @@ if ($action == 'create') { // Confirmation de l'envoi de la commande if ($action == 'commande') { $date_com = dol_mktime(GETPOST('rehour'), GETPOST('remin'), GETPOST('resec'), GETPOST("remonth"), GETPOST("reday"), GETPOST("reyear")); + if (!empty($conf->notification->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; + $notify = new Notify($db); + $text .= '
    '; + $text .= $notify->confirmMessage('ORDER_SUPPLIER_SUBMIT', $object->socid, $object); + } $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id."&datecommande=".$date_com."&methode=".GETPOST("methodecommande")."&comment=".urlencode(GETPOST("comment")), $langs->trans("MakeOrder"), $langs->trans("ConfirmMakeOrder", dol_print_date($date_com, 'day')), "confirm_commande", '', 0, 2); } diff --git a/htdocs/fourn/facture/card-rec.php b/htdocs/fourn/facture/card-rec.php index 24abf113c9b..3d8bdf23d36 100644 --- a/htdocs/fourn/facture/card-rec.php +++ b/htdocs/fourn/facture/card-rec.php @@ -192,6 +192,7 @@ if (empty($reshook)) { $object->titre = GETPOST('title', 'alphanohtml'); // deprecated $object->title = GETPOST('title', 'alphanohtml'); $object->libelle = GETPOST('libelle', 'alpha'); + $object->label = GETPOST('libelle', 'alpha'); $object->fk_project = GETPOST('projectid', 'int'); $object->ref_supplier = GETPOST('ref_supplier', 'alphanohtml'); @@ -366,6 +367,7 @@ if (empty($reshook)) { // Set label $object->fetch($id); $object->libelle = GETPOST('libelle'); + $object->label = GETPOST('libelle'); $result = $object->update($user); if ($result < 0) { @@ -1256,7 +1258,7 @@ if ($action == 'create') { print '
    '; print $langs->trans('SendingMethod'); print ''; + print ''; if ($lines[$i]->entrepot_id > 0) { $entrepot = new Entrepot($db); $entrepot->fetch($lines[$i]->entrepot_id); @@ -2568,7 +2577,6 @@ if ($action == 'create') { } // 0=draft, 1=validated/delivered, 2=closed/delivered - // If WORKFLOW_BILL_ON_SHIPMENT: 0=draft, 1=validated, 2=billed (no status delivered) if ($object->statut == Expedition::STATUS_VALIDATED && !getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT')) { if ($user->hasRight('expedition', 'creer')) { print dolGetButtonAction('', $langs->trans('SetToDraft'), 'default', $_SERVER["PHP_SELF"].'?action=setdraft&token='.newToken().'&id='.$object->id, ''); @@ -2576,11 +2584,7 @@ if ($action == 'create') { } if ($object->statut == Expedition::STATUS_CLOSED) { if ($user->hasRight('expedition', 'creer')) { - if (isModEnabled('facture') && !empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ? - print dolGetButtonAction('', $langs->trans('ClassifyUnbilled'), 'default', $_SERVER["PHP_SELF"].'?action=reopen&token='.newToken().'&id='.$object->id, ''); - } else { - print dolGetButtonAction('', $langs->trans('ReOpen'), 'default', $_SERVER["PHP_SELF"].'?action=reopen&token='.newToken().'&id='.$object->id, ''); - } + print dolGetButtonAction('', $langs->trans('ReOpen'), 'default', $_SERVER["PHP_SELF"].'?action=reopen&token='.newToken().'&id='.$object->id, ''); } } @@ -2598,9 +2602,9 @@ if ($action == 'create') { // Create bill if (isModEnabled('facture') && ($object->statut == Expedition::STATUS_VALIDATED || $object->statut == Expedition::STATUS_CLOSED)) { if ($user->hasRight('facture', 'creer')) { - // TODO show button only if (!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) - // If we do that, we must also make this option official. - print dolGetButtonAction('', $langs->trans('CreateBill'), 'default', DOL_URL_ROOT.'/compta/facture/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, ''); + if (getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT') !== '0') { + print dolGetButtonAction('', $langs->trans('CreateBill'), 'default', DOL_URL_ROOT.'/compta/facture/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, ''); + } } } @@ -2609,28 +2613,26 @@ if ($action == 'create') { if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY') && ($object->statut == Expedition::STATUS_VALIDATED || $object->statut == Expedition::STATUS_CLOSED) && $user->rights->expedition->delivery->creer && empty($object->linkedObjectsIds['delivery'])) { print dolGetButtonAction('', $langs->trans('CreateDeliveryOrder'), 'default', $_SERVER["PHP_SELF"].'?action=create_delivery&token='.newToken().'&id='.$object->id, ''); } - // Close + + // Set Billed and Closed if ($object->statut == Expedition::STATUS_VALIDATED) { - if ($user->rights->expedition->creer && $object->statut > 0 && !$object->billed) { - $label = "Close"; $paramaction = 'classifyclosed'; // = Transferred/Received - // Label here should be "Close" or "ClassifyBilled" if we decided to make bill on shipments instead of orders - if (isModEnabled('facture') && !empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ? - $label = "ClassifyBilled"; - $paramaction = 'classifybilled'; + if ($user->hasRight('expedition', 'creer') && $object->statut > 0) { + if (!$object->billed && getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT') !== '0') { + print dolGetButtonAction('', $langs->trans('ClassifyBilled'), 'default', $_SERVER["PHP_SELF"].'?action=classifybilled&token='.newToken().'&id='.$object->id, ''); } - print dolGetButtonAction('', $langs->trans($label), 'default', $_SERVER["PHP_SELF"].'?action='. $paramaction .'&token='.newToken().'&id='.$object->id, ''); + print dolGetButtonAction('', $langs->trans("Close"), 'default', $_SERVER["PHP_SELF"].'?action='. $paramaction .'&token='.newToken().'&id='.$object->id, ''); } } // Cancel if ($object->statut == Expedition::STATUS_VALIDATED) { - if ($user->rights->expedition->supprimer) { + if ($user->hasRight('expedition', 'creer')) { print dolGetButtonAction('', $langs->trans('Cancel'), 'danger', $_SERVER["PHP_SELF"].'?action=cancel&token='.newToken().'&id='.$object->id.'&mode=init#formmailbeforetitle', ''); } } // Delete - if ($user->rights->expedition->supprimer) { + if ($user->hasRight('expedition', 'supprimer')) { print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id, ''); } } diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php index 3297b70cd93..ca8ec43ca84 100644 --- a/htdocs/expedition/class/api_shipments.class.php +++ b/htdocs/expedition/class/api_shipments.class.php @@ -59,9 +59,9 @@ class Shipments extends DolibarrApi * Return an array with shipment informations * * @param int $id ID of shipment - * @return Object Object with cleaned properties + * @return Object Object with cleaned properties * - * @throws RestException + * @throws RestException */ public function get($id) { @@ -89,17 +89,18 @@ class Shipments extends DolibarrApi * * Get a list of shipments * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param string $thirdparty_ids Thirdparty ids to filter shipments of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $thirdparty_ids Thirdparty ids to filter shipments of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @param string $properties Restrict the data returned to theses properties. Ignored if empty. Comma separated list of properties names * @return array Array of shipment objects * * @throws RestException */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '', $properties = '') { global $db, $conf; @@ -172,7 +173,7 @@ class Shipments extends DolibarrApi $obj = $this->db->fetch_object($result); $shipment_static = new Expedition($this->db); if ($shipment_static->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($shipment_static); + $obj_ret[] = $this->_filterObjectProperties($this->_cleanObjectDatas($shipment_static), $properties); } $i++; } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index df4b92fe76f..18761de10b6 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -79,6 +79,11 @@ class Expedition extends CommonObject */ public $ismultientitymanaged = 1; + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; + /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ @@ -114,8 +119,6 @@ class Expedition extends CommonObject */ public $ref_customer; - public $brouillon; - /** * @var int warehouse id */ @@ -326,7 +329,6 @@ class Expedition extends CommonObject $error = 0; // Clean parameters - $this->brouillon = 1; $this->tracking_number = dol_sanitizeFileName($this->tracking_number); if (empty($this->fk_project)) { $this->fk_project = 0; @@ -334,7 +336,6 @@ class Expedition extends CommonObject $this->user = $user; - $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition ("; @@ -615,7 +616,6 @@ class Expedition extends CommonObject $this->date_delivery = $this->db->jdate($obj->date_delivery); // Date planed $this->fk_delivery_address = $obj->fk_address; $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; // deprecated $this->shipping_method_id = $obj->fk_shipping_method; $this->shipping_method = $obj->shipping_method; $this->tracking_number = $obj->tracking_number; @@ -648,10 +648,6 @@ class Expedition extends CommonObject $this->db->free($result); - if ($this->statut == self::STATUS_DRAFT) { - $this->brouillon = 1; - } - // Tracking url $this->getUrlTrackingStatus($obj->tracking_number); @@ -700,14 +696,14 @@ class Expedition extends CommonObject */ public function valid($user, $notrigger = 0) { - global $conf, $langs; + global $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; dol_syslog(get_class($this)."::valid"); // Protection - if ($this->statut) { + if ($this->status) { dol_syslog(get_class($this)."::valid not in draft status", LOG_WARNING); return 0; } @@ -728,7 +724,7 @@ class Expedition extends CommonObject $soc->fetch($this->socid); // Class of company linked to order - $result = $soc->set_as_client(); + $result = $soc->setAsCustomer(); // Define new ref if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life @@ -1831,7 +1827,7 @@ class Expedition extends CommonObject if ($option !== 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { @@ -1961,9 +1957,8 @@ class Expedition extends CommonObject $xnbp = 0; while ($xnbp < $nbp) { $line = new ExpeditionLigne($this->db); - $line->desc = $langs->trans("Description")." ".$xnbp; - $line->libelle = $langs->trans("Description")." ".$xnbp; // deprecated - $line->label = $langs->trans("Description")." ".$xnbp; + $line->product_desc = $langs->trans("Description")." ".$xnbp; + $line->product_label = $langs->trans("Description")." ".$xnbp; $line->qty = 10; $line->qty_asked = 5; $line->qty_shipped = 4; @@ -2109,13 +2104,13 @@ class Expedition extends CommonObject } /** - * Classify the shipping as closed. + * Classify the shipping as closed (this record also the stock movement) * * @return int <0 if KO, >0 if OK */ public function setClosed() { - global $conf, $langs, $user; + global $conf, $user; $error = 0; @@ -2283,7 +2278,7 @@ class Expedition extends CommonObject } /** - * Classify the shipping as invoiced (used when WORKFLOW_BILL_ON_SHIPMENT is on) + * Classify the shipping as invoiced (used for exemple by trigger when WORKFLOW_SHIPPING_CLASSIFY_BILLED_INVOICE is on) * * @return int <0 if ko, >0 if ok */ @@ -2294,17 +2289,17 @@ class Expedition extends CommonObject $this->db->begin(); - $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2, billed=1'; // TODO Update only billed + $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET billed = 1'; $sql .= " WHERE rowid = ".((int) $this->id).' AND fk_statut > 0'; $resql = $this->db->query($sql); if ($resql) { - $this->statut = self::STATUS_CLOSED; $this->billed = 1; // Call trigger $result = $this->call_trigger('SHIPPING_BILLED', $user); if ($result < 0) { + $this->billed = 0; $error++; } } else { @@ -2316,8 +2311,6 @@ class Expedition extends CommonObject $this->db->commit(); return 1; } else { - $this->statut = self::STATUS_VALIDATED; - $this->billed = 0; $this->db->rollback(); return -1; } @@ -2481,8 +2474,6 @@ class Expedition extends CommonObject if (!empty($this->model_pdf)) { $modele = $this->model_pdf; - } elseif (!empty($this->modelpdf)) { // deprecated - $modele = $this->modelpdf; } elseif (!empty($conf->global->EXPEDITION_ADDON_PDF)) { $modele = $conf->global->EXPEDITION_ADDON_PDF; } @@ -2750,8 +2741,6 @@ class ExpeditionLigne extends CommonObjectLine */ public function insert($user, $notrigger = 0) { - global $langs, $conf; - $error = 0; // Check parameters diff --git a/htdocs/expedition/class/expeditionlinebatch.class.php b/htdocs/expedition/class/expeditionlinebatch.class.php index 73f352ac21a..fbf6564616f 100644 --- a/htdocs/expedition/class/expeditionlinebatch.class.php +++ b/htdocs/expedition/class/expeditionlinebatch.class.php @@ -44,8 +44,8 @@ class ExpeditionLineBatch extends CommonObject public $qty; public $dluo_qty; // deprecated, use qty public $entrepot_id; - public $fk_origin_stock; // rowid in llx_product_batch table - public $fk_warehouse; // for future use in v19 + public $fk_origin_stock; // rowid in llx_product_batch table (not usefull) + public $fk_warehouse; // warehouse ID public $fk_expeditiondet; @@ -63,7 +63,7 @@ class ExpeditionLineBatch extends CommonObject * Fill object based on a product-warehouse-batch's record * * @param int $id_stockdluo Rowid in product_batch table - * @return int -1 if KO, 1 if OK + * @return int -1 if KO, 1 if OK */ public function fetchFromStock($id_stockdluo) { @@ -72,7 +72,6 @@ class ExpeditionLineBatch extends CommonObject $sql .= " pl.sellby,"; $sql .= " pl.eatby,"; $sql .= " ps.fk_entrepot"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_batch as pb"; $sql .= " JOIN ".MAIN_DB_PREFIX."product_stock as ps on pb.fk_product_stock=ps.rowid"; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."product_lot as pl on pl.batch = pb.batch AND pl.fk_product = ps.fk_product"; @@ -124,14 +123,15 @@ class ExpeditionLineBatch extends CommonObject $sql .= ", batch"; $sql .= ", qty"; $sql .= ", fk_origin_stock"; - // TODO Add fk_warehouse here + $sql .= ", fk_warehouse"; $sql .= ") VALUES ("; - $sql .= $id_line_expdet.","; - $sql .= " ".(!isset($this->sellby) || dol_strlen($this->sellby) == 0 ? 'NULL' : ("'".$this->db->idate($this->sellby))."'").","; - $sql .= " ".(!isset($this->eatby) || dol_strlen($this->eatby) == 0 ? 'NULL' : ("'".$this->db->idate($this->eatby))."'").","; - $sql .= " ".(!isset($this->batch) ? 'NULL' : ("'".$this->db->escape($this->batch)."'")).","; - $sql .= " ".(!isset($this->qty) ? ((!isset($this->dluo_qty)) ? 'NULL' : $this->dluo_qty) : $this->qty).","; // dluo_qty deprecated, use qty - $sql .= " ".(!isset($this->fk_origin_stock) ? 'NULL' : $this->fk_origin_stock); + $sql .= $id_line_expdet; + $sql .= ", ".(!isset($this->sellby) || dol_strlen($this->sellby) == 0 ? 'NULL' : ("'".$this->db->idate($this->sellby))."'"); + $sql .= ", ".(!isset($this->eatby) || dol_strlen($this->eatby) == 0 ? 'NULL' : ("'".$this->db->idate($this->eatby))."'"); + $sql .= ", ".(!isset($this->batch) ? 'NULL' : ("'".$this->db->escape($this->batch)."'")); + $sql .= ", ".(!isset($this->qty) ? ((!isset($this->dluo_qty)) ? 'NULL' : $this->dluo_qty) : $this->qty); // dluo_qty deprecated, use qty + $sql .= ", ".(!isset($this->fk_origin_stock) ? 'NULL' : $this->fk_origin_stock); + $sql .= ", ".(!isset($this->fk_warehouse) ? 'NULL' : $this->fk_warehouse); $sql .= ")"; dol_syslog(__METHOD__, LOG_DEBUG); @@ -201,7 +201,8 @@ class ExpeditionLineBatch extends CommonObject $sql .= " eb.eatby as oldeatby,"; // deprecated $sql .= " eb.batch,"; $sql .= " eb.qty,"; - $sql .= " eb.fk_origin_stock"; + $sql .= " eb.fk_origin_stock,"; + $sql .= " eb.fk_warehouse"; if ($fk_product > 0) { $sql .= ", pl.sellby"; $sql .= ", pl.eatby"; @@ -228,6 +229,7 @@ class ExpeditionLineBatch extends CommonObject $tmp->id = $obj->rowid; $tmp->fk_origin_stock = $obj->fk_origin_stock; $tmp->fk_expeditiondet = $obj->fk_expeditiondet; + $tmp->fk_warehouse = $obj->fk_warehouse; $tmp->dluo_qty = $obj->qty; // dluo_qty deprecated, use qty $tmp->qty = $obj->qty; diff --git a/htdocs/expedition/dispatch.php b/htdocs/expedition/dispatch.php index bf7b23b21d3..b64908d02e3 100644 --- a/htdocs/expedition/dispatch.php +++ b/htdocs/expedition/dispatch.php @@ -148,6 +148,7 @@ if ($action == 'updatelines' && $usercancreate) { $ent = "entrepot_".$reg[1].'_'.$reg[2]; $fk_commandedet = "fk_commandedet_".$reg[1].'_'.$reg[2]; $idline = GETPOST("idline_".$reg[1].'_'.$reg[2]); + $warehouse_id = GETPOSTINT($ent); $pu = "pu_".$reg[1].'_'.$reg[2]; // This is unit price including discount $lot = ''; $dDLUO = ''; @@ -164,7 +165,7 @@ if ($action == 'updatelines' && $usercancreate) { // We ask to move a qty if (($modebatch == "batch" && $newqty >= 0) || ($modebatch == "barcode" && $newqty != 0)) { if ($newqty > 0) { // If we want a qty, we make test on input data - if (!(GETPOST($ent, 'int') > 0)) { + if (!($warehouse_id > 0)) { dol_syslog('No dispatch for line '.$key.' as no warehouse was chosen.'); $text = $langs->transnoentities('Warehouse').', '.$langs->transnoentities('Line').' '.($numline); setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors'); @@ -242,14 +243,13 @@ if ($action == 'updatelines' && $usercancreate) { $sql .= " eatby = ".($eatby ? "'".$db->idate($eatby)."'" : "null"); $sql .= " , sellby = ".($sellby ? "'".$db->idate($sellby)."'" : "null"); $sql .= " , qty = ".((float) $newqty); - // TODO Add a column fk_warehouse + $sql .= " , fk_warehouse = ".((int) $warehouse_id); $sql .= " WHERE rowid = ".((int) $objsearchdet->rowid); } else { $sql = "INSERT INTO ".MAIN_DB_PREFIX.$expeditionlinebatch->table_element." ("; - $sql .= "fk_expeditiondet, eatby, sellby, batch, qty, fk_origin_stock)"; - // TODO Add a column fk_warehouse + $sql .= "fk_expeditiondet, eatby, sellby, batch, qty, fk_origin_stock, fk_warehouse)"; $sql .= " VALUES (".((int) $idline).", ".($eatby ? "'".$db->idate($eatby)."'" : "null").", ".($sellby ? "'".$db->idate($sellby)."'" : "null").", "; - $sql .= " '".$db->escape($lot)."', ".((float) $newqty).", 0)"; + $sql .= " '".$db->escape($lot)."', ".((float) $newqty).", 0, ".((int) $warehouse_id).")"; } } else { $sql = " DELETE FROM ".MAIN_DB_PREFIX.$expeditionlinebatch->table_element; @@ -877,7 +877,7 @@ if ($object->id > 0 || !empty($object->ref)) { print ''; + print ''; print ''.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').''; $suggestedvalue = (GETPOSTISSET('qty'.$suffix) ? GETPOST('qty'.$suffix, 'int') : $objd->qty); //var_dump($suggestedvalue);exit; diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 40c8191043a..61d3d5acd68 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -144,7 +144,7 @@ $arrayfields = array( 'e.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), 'l.ref'=>array('label'=>$langs->trans("DeliveryRef"), 'checked'=>1, 'enabled'=>(getDolGlobalInt('MAIN_SUBMODULE_DELIVERY') ? 1 : 0)), 'l.date_delivery'=>array('label'=>$langs->trans("DateReceived"), 'checked'=>1, 'enabled'=>(getDolGlobalInt('MAIN_SUBMODULE_DELIVERY') ? 1 : 0)), - 'e.billed'=>array('label'=>$langs->trans("Billed"), 'checked'=>1, 'position'=>1000, 'enabled'=>(!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) + 'e.billed'=>array('label'=>$langs->trans("Billed"), 'checked'=>1, 'position'=>1000, 'enabled'=>'getDolGlobalConst("WORKFLOW_BILL_ON_SHIPMENT") !== "0"') ); // Extra fields @@ -1021,7 +1021,7 @@ while ($i < min($num, $limit)) { } // Date delivery planed if (!empty($arrayfields['e.date_delivery']['checked'])) { - print ''; + print ''; print dol_print_date($db->jdate($obj->delivery_date), "dayhour"); print "
    '; - if ($usercancreate && $action != 'editmulticurrencycode' && !empty($object->brouillon)) { + if ($usercancreate && $action != 'editmulticurrencycode' && $object->suspended == $object::STATUS_SUSPENDED) { print ''; } print '
    '; print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); print '' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
    '; @@ -1272,7 +1274,7 @@ if ($action == 'create') { print ''; - if ($usercancreate && $action != 'editmulticurrencyrate' && !empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { + if ($usercancreate && $action != 'editmulticurrencyrate' && $object->suspended == $object::STATUS_SUSPENDED && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { print ''; } print '
    '; print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); print '' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
    '; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index c882e3cff4a..7a17f161383 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -758,7 +758,8 @@ if (empty($reshook)) { $object->ref = GETPOST('ref', 'alphanohtml'); $object->ref_supplier = GETPOST('ref_supplier', 'alpha'); $object->socid = GETPOST('socid', 'int'); - $object->libelle = GETPOST('label', 'alphanohtml'); + $object->libelle = GETPOST('label', 'alphanohtml'); // deprecated + $object->label = GETPOST('label', 'alphanohtml'); $object->date = $dateinvoice; $object->date_echeance = $datedue; $object->note_public = GETPOST('note_public', 'restricthtml'); @@ -3094,8 +3095,8 @@ if ($action == 'create') { print ' '.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).''; } if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) { - $facusing = new FactureFournisseur($db); if ($object->fk_facture_source > 0) { + $facusing = new FactureFournisseur($db); $facusing->fetch($object->fk_facture_source); print ' '.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).''; } else { diff --git a/htdocs/fourn/facture/list-rec.php b/htdocs/fourn/facture/list-rec.php index e90aca5a576..2b8d3c17db9 100644 --- a/htdocs/fourn/facture/list-rec.php +++ b/htdocs/fourn/facture/list-rec.php @@ -24,7 +24,7 @@ */ /** - * \file htdocs/compta/facture/invoicetemplate_list.php + * \file htdocs/fourn/facture/list-rec.php * \ingroup facture * \brief Page to show list of template/recurring invoices */ @@ -50,12 +50,12 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'invoicetemplatelist'; // To manage different context of search -$optioncss = GETPOST('optioncss', 'alpha'); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'supplierinvoicestemplatelist'; // To manage different context of search +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...) $socid = GETPOST('socid', 'int'); -// Security check $id = (GETPOST('facid', 'int') ?GETPOST('facid', 'int') : GETPOST('id', 'int')); $lineid = GETPOST('lineid', 'int'); $ref = GETPOST('ref', 'alpha'); @@ -93,26 +93,25 @@ $search_date_when_end = dol_mktime(23, 59, 59, $search_date_when_endmonth, $sear $search_recurring = GETPOST('search_recurring', 'int'); $search_frequency = GETPOST('search_frequency', 'alpha'); $search_unit_frequency = GETPOST('search_unit_frequency', 'alpha'); +$search_nb_gen_done = GETPOST('search_nb_gen_done', 'aplha'); $search_status = GETPOST('search_status', 'int'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'alpha'); -$sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST('page', 'int'); -if (empty($page) || $page == -1) { +$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; -} // If $page is not defined, or '' or -1 +} $offset = $limit * $page; -if (!$sortorder) { - $sortorder = 'DESC'; -} -if (!$sortfield) { - $sortfield = 'f.titre'; -} $pageprev = $page - 1; $pagenext = $page + 1; +// Initialize technical objects $object = new FactureFournisseurRec($db); +$extrafields = new ExtraFields($db); + if (($id > 0 || $ref) && $action != 'create' && $action != 'add') { $ret = $object->fetch($id, $ref); if (!$ret) { @@ -122,17 +121,19 @@ if (($id > 0 || $ref) && $action != 'create' && $action != 'add') { // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('supplierinvoicereclist')); -$extrafields = new ExtraFields($db); -// fetch optionals attributes and labels +// Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); -$permissionnote = $user->hasRight('facture', 'creer'); // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->hasRight('facture', 'creer'); // Used by the include of actions_dellink.inc.php -$permissiontoedit = $user->hasRight('facture', 'creer'); // Used by the include of actions_lineupdonw.inc.php - +// Default sort order (if not yet defined by previous GETPOST) +if (!$sortorder) { + $sortorder = 'DESC'; +} +if (!$sortfield) { + $sortfield = 'f.titre'; +} $arrayfields = array( 'f.titre'=>array('label'=>'Ref', 'checked'=>1), 's.nom'=>array('label'=>'ThirdParty', 'checked'=>1), @@ -151,7 +152,7 @@ $arrayfields = array( 'f.fk_user_modif'=>array('label'=>'UserModification', 'checked'=>0, 'position'=>505), 'f.datec'=>array('label'=>'DateCreation', 'checked'=>0, 'position'=>520), 'f.tms'=>array('label'=>'DateModificationShort', 'checked'=>0, 'position'=>525), - 'suspended '=>array('label'=>'Status', 'checked'=>1, 'position'=>1000), + 'status'=>array('label'=>'Status', 'checked'=>1, 'position'=>1000), ); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; @@ -168,6 +169,10 @@ if ($socid > 0) { } $objecttype = 'facture_fourn_rec'; +$permissionnote = $user->hasRight('facture', 'creer'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('facture', 'creer'); // Used by the include of actions_dellink.inc.php +$permissiontoedit = $user->hasRight('facture', 'creer'); // Used by the include of actions_lineupdonw.inc.php + $result = restrictedArea($user, 'supplier_invoicerec', $object->id, $objecttype); @@ -190,15 +195,15 @@ if ($reshook < 0) { } if (empty($reshook)) { - if (GETPOST('cancel', 'alpha')) { + /*if (GETPOST('cancel', 'alpha')) { $action = ''; - } + }*/ // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - // Do we click on purge search criteria ? - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers + // 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 $search_ref = ''; $search_societe = ''; $search_montant_ht = ''; @@ -225,9 +230,15 @@ if (empty($reshook)) { $search_recurring = ''; $search_frequency = ''; $search_unit_frequency = ''; + $search_nb_gen_done = ''; $search_status = ''; + $toselect = array(); $search_array_options = array(); } + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } // Mass actions /*$objectclass='MyObject'; @@ -243,9 +254,6 @@ if (empty($reshook)) { * View */ -$help_url = ''; -llxHeader('', $langs->trans("RepeatableSupplierInvoices"), $help_url); - $form = new Form($db); $formother = new FormOther($db); if (isModEnabled('project')) { @@ -256,13 +264,18 @@ $supplierinvoicerectmp = new FactureFournisseurRec($db); $tmpuser = new User($db); $now = dol_now(); + +$help_url = ''; +$title = $langs->trans("RepeatableSupplierInvoices"); +$morejs = array(); +$morecss = array(); + $tmparray = dol_getdate($now); $today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); // Today is last second of current day -/* - * List mode - */ +// Build and execute select +// -------------------------------------------------------------------- $sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre as title, f.total_ht, f.total_tva, f.total_ttc, f.frequency, f.unit_frequency,"; $sql .= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,"; @@ -280,15 +293,22 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje $sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); +$sqlfields = $sql; // $sql fields to remove for count total + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'facture_fourn_rec as f'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_rec_extrafields as ef ON ef.fk_object = f.rowid'; if (!$user->hasRight("societe", "client", "voir") && !$socid) { $sql .= ', '.MAIN_DB_PREFIX.'societe_commerciaux as sc'; } -$sql .= ' WHERE f.fk_soc = s.rowid'; +// 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 f.fk_soc = s.rowid"; $sql .= ' AND f.entity IN ('.getEntity('invoice').')'; if (!$user->hasRight("societe", "client", "voir") && !$socid) { - $sql .= ' AND s.rowid = sc.fk_soc AND sc.fk_user = '. (int) $user->id; + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($search_ref) { $sql .= natural_search('f.titre', $search_ref); @@ -324,7 +344,11 @@ if ($search_frequency != '') { $sql .= natural_search('f.frequency', $search_frequency, 1); } if ($search_unit_frequency != '') { - $sql .= ' AND f.frequency > 0'.natural_search('f.unit_frequency', $search_unit_frequency); + $sql .= ' AND f.frequency > 0'; + $sql .= natural_search('f.unit_frequency', $search_unit_frequency); +} +if ($search_nb_gen_done != '') { + $sql .= natural_search("f.nb_gen_done", $search_nb_gen_done, 1); } if ($search_status != '' && $search_status >= -1) { if ($search_status == 0) { @@ -350,573 +374,727 @@ if ($search_date_when_end) { $sql .= " AND f.date_when <= '".$db->idate($search_date_when_end)."'"; } -$tmpsortfield = $sortfield; -if ($tmpsortfield == 'recurring') { - $tmpsortfield = 'f.frequency'; -} -$sql .= $db->order($tmpsortfield, $sortorder); - +// Count total nb of records $nbtotalofrecords = ''; if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); + /* 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); } -$sql .= $db->plimit($limit + 1, $offset); +$tmpsortfield = $sortfield; +if ($tmpsortfield == 'recurring') { + $tmpsortfield = 'f.frequency'; +} + +// Complete request and execute it with limit +$sql .= $db->order($tmpsortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); +} $resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); +if (!$resql) { + dol_print_error($db); + exit; +} - $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); - } - if ($socid > 0) { - $param .= '&socid='.urlencode($socid); - } - if ($search_date_startday) { - $param .= '&search_date_startday='.urlencode($search_date_startday); - } - if ($search_date_startmonth) { - $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); - } - if ($search_date_startyear) { - $param .= '&search_date_startyear='.urlencode($search_date_startyear); - } - if ($search_date_endday) { - $param .= '&search_date_endday='.urlencode($search_date_endday); - } - if ($search_date_endmonth) { - $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); - } - if ($search_date_endyear) { - $param .= '&search_date_endyear='.urlencode($search_date_endyear); - } - if ($search_date_when_startday) { - $param .= '&search_date_when_startday='.urlencode($search_date_when_startday); - } - if ($search_date_when_startmonth) { - $param .= '&search_date_when_startmonth='.urlencode($search_date_when_startmonth); - } - if ($search_date_when_startyear) { - $param .= '&search_date_when_startyear='.urlencode($search_date_when_startyear); - } - if ($search_date_when_endday) { - $param .= '&search_date_when_endday='.urlencode($search_date_when_endday); - } - if ($search_date_when_endmonth) { - $param .= '&search_date_when_endmonth='.urlencode($search_date_when_endmonth); - } - if ($search_date_when_endyear) { - $param .= '&search_date_when_endyear='.urlencode($search_date_when_endyear); - } - if ($search_ref) { - $param .= '&search_ref='.urlencode($search_ref); - } - if ($search_societe) { - $param .= '&search_societe='.urlencode($search_societe); - } - if ($search_montant_ht != '') { - $param .= '&search_montant_ht='.urlencode($search_montant_ht); - } - if ($search_montant_vat != '') { - $param .= '&search_montant_vat='.urlencode($search_montant_vat); - } - if ($search_montant_ttc != '') { - $param .= '&search_montant_ttc='.urlencode($search_montant_ttc); - } - if ($search_payment_mode != '') { - $param .= '&search_payment_mode='.urlencode($search_payment_mode); - } - if ($search_payment_term != '') { - $param .= '&search_payment_term='.urlencode($search_payment_term); - } - if ($search_recurring != '' && $search_recurring != '-1') { - $param .= '&search_recurring='.urlencode($search_recurring); - } - if ($search_frequency > 0) { - $param .= '&search_frequency='.urlencode($search_frequency); - } - if ($search_unit_frequency != '') { - $param .= '&search_unit_frequency='.urlencode($search_unit_frequency); - } - if ($search_status != '') { - $param .= '&search_status='.urlencode($search_status); - } - if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); - } - // Add $param from extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; +$num = $db->num_rows($resql); - $massactionbutton = $form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); +// Output page +// -------------------------------------------------------------------- - $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - //$selectedfields.=$form->showCheckAddButtons('checkforselect', 1); +llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); - print '
    '; - if ($optioncss != '') { - print ''; - } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; +$arrayofselected = is_array($toselect) ? $toselect : array(); - $title = $langs->trans("RepeatableSupplierInvoices"); +$param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.((int) $limit); +} +if ($socid > 0) { + $param .= '&socid='.urlencode($socid); +} +if ($search_date_startday) { + $param .= '&search_date_startday='.urlencode($search_date_startday); +} +if ($search_date_startmonth) { + $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); +} +if ($search_date_startyear) { + $param .= '&search_date_startyear='.urlencode($search_date_startyear); +} +if ($search_date_endday) { + $param .= '&search_date_endday='.urlencode($search_date_endday); +} +if ($search_date_endmonth) { + $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); +} +if ($search_date_endyear) { + $param .= '&search_date_endyear='.urlencode($search_date_endyear); +} +if ($search_date_when_startday) { + $param .= '&search_date_when_startday='.urlencode($search_date_when_startday); +} +if ($search_date_when_startmonth) { + $param .= '&search_date_when_startmonth='.urlencode($search_date_when_startmonth); +} +if ($search_date_when_startyear) { + $param .= '&search_date_when_startyear='.urlencode($search_date_when_startyear); +} +if ($search_date_when_endday) { + $param .= '&search_date_when_endday='.urlencode($search_date_when_endday); +} +if ($search_date_when_endmonth) { + $param .= '&search_date_when_endmonth='.urlencode($search_date_when_endmonth); +} +if ($search_date_when_endyear) { + $param .= '&search_date_when_endyear='.urlencode($search_date_when_endyear); +} +if ($search_ref) { + $param .= '&search_ref='.urlencode($search_ref); +} +if ($search_societe) { + $param .= '&search_societe='.urlencode($search_societe); +} +if ($search_montant_ht != '') { + $param .= '&search_montant_ht='.urlencode($search_montant_ht); +} +if ($search_montant_vat != '') { + $param .= '&search_montant_vat='.urlencode($search_montant_vat); +} +if ($search_montant_ttc != '') { + $param .= '&search_montant_ttc='.urlencode($search_montant_ttc); +} +if ($search_payment_mode != '') { + $param .= '&search_payment_mode='.urlencode($search_payment_mode); +} +if ($search_payment_term != '') { + $param .= '&search_payment_term='.urlencode($search_payment_term); +} +if ($search_recurring != '' && $search_recurring != '-1') { + $param .= '&search_recurring='.urlencode($search_recurring); +} +if ($search_frequency > 0) { + $param .= '&search_frequency='.urlencode($search_frequency); +} +if ($search_unit_frequency != '') { + $param .= '&search_unit_frequency='.urlencode($search_unit_frequency); +} +if ($search_nb_gen_done != '') { + $param .= '&search_nb_gen_done='.urlencode($search_nb_gen_done); +} +if ($search_status != '') { + $param .= '&search_status='.urlencode($search_status); +} +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; +// Add $param from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook +$param .= $hookmanager->resPrint; - print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1); +// List of mass actions available +$arrayofmassactions = array( + //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"), + //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), + //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), + //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), +); - print ''.$langs->trans("ToCreateAPredefinedSupplierInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'

    '; +$massactionbutton = $form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); - $i = 0; +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields +//$selectedfields.=$form->showCheckAddButtons('checkforselect', 1); - $moreforfilter = ''; +print ''."\n"; +if ($optioncss != '') { + print ''; +} +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; - print '
    '; - print ''."\n"; - // Filters lines - print ''; - // Ref - if (!empty($arrayfields['f.titre']['checked'])) { - print ''; - } - // Thirdparty - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - } - if (!empty($arrayfields['f.total_ht']['checked'])) { - // Amount net - print ''; - } - if (!empty($arrayfields['f.total_tva']['checked'])) { - // Amount Vat - print ''; - } - if (!empty($arrayfields['f.total_ttc']['checked'])) { - // Amount - print ''; - } - if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { - // Payment term - print '"; - } - if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { - // Payment mode - print ''; - } - if (!empty($arrayfields['recurring']['checked'])) { - // Recurring or not - print ''; - } - if (!empty($arrayfields['f.frequency']['checked'])) { - // Recurring or not - print ''; - } - if (!empty($arrayfields['f.unit_frequency']['checked'])) { - // Frequency unit - print ''; - } - if (!empty($arrayfields['f.nb_gen_done']['checked'])) { - // Nb generation - print ''; - } - // Date invoice - if (!empty($arrayfields['f.date_last_gen']['checked'])) { - print ''; - } - // Date next generation - if (!empty($arrayfields['f.date_when']['checked'])) { - print ''; - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; +print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1); - // 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; - // User creation - if (!empty($arrayfields['f.fk_user_author']['checked'])) { - print ''; - } - // User modification - if (!empty($arrayfields['f.fk_user_modif']['checked'])) { - print ''; - } - // Date creation - if (!empty($arrayfields['f.datec']['checked'])) { - print ''; - } - // Date modification - if (!empty($arrayfields['f.tms']['checked'])) { - print ''; - } - // Action column - print ''; +} + +$db->free($resql); + + +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print '
    '; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print $form->getSelectConditionsPaiements($search_payment_term, 'search_payment_term', -1, 1, 1, 'maxwidth100'); - print "'; - print $form->select_types_paiements($search_payment_mode, 'search_payment_mode', '', 0, 1, 1, 0, 1, 'maxwidth100', 1); - print ''; - print $form->selectyesno('search_recurring', $search_recurring, 1, false, 1); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
    '; - print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
    '; - print '
    '; - print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
    '; - print '
    '; - print '
    '; - print $form->selectDate($search_date_when_start ? $search_date_when_start : -1, 'search_date_when_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
    '; - print '
    '; - print $form->selectDate($search_date_when_end ? $search_date_when_end : -1, 'search_date_when_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
    '; - print '
    '; - print ''; - print ''; - print ''; - print ''; +print ''.$langs->trans("ToCreateAPredefinedSupplierInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'

    '; + +$i = 0; + +$moreforfilter = ''; + +$parameters = array(); +$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; +} + +if (!empty($moreforfilter)) { + print '
    '; + print $moreforfilter; + print '
    '; +} + +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields +$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + +print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print ''."\n"; + +// Fields title search +// -------------------------------------------------------------------- +print ''; +// Action column +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; +} +// Ref +if (!empty($arrayfields['f.titre']['checked'])) { + print ''; +} +// Thirdparty +if (!empty($arrayfields['s.nom']['checked'])) { + print ''; +} +if (!empty($arrayfields['f.total_ht']['checked'])) { + // Amount net + print ''; +} +if (!empty($arrayfields['f.total_tva']['checked'])) { + // Amount Vat + print ''; +} +if (!empty($arrayfields['f.total_ttc']['checked'])) { + // Amount + print ''; +} +if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { + // Payment term + print '"; +} +if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { + // Payment mode + print ''; +} +if (!empty($arrayfields['recurring']['checked'])) { + // Recurring or not + print ''; +} +if (!empty($arrayfields['f.frequency']['checked'])) { + // Recurring or not + print ''; +} +if (!empty($arrayfields['f.unit_frequency']['checked'])) { + // Frequency unit + print ''; +} +if (!empty($arrayfields['f.nb_gen_done']['checked'])) { + // Nb generation + print ''; +} +// Date invoice +if (!empty($arrayfields['f.date_last_gen']['checked'])) { + print ''; +} +// Date next generation +if (!empty($arrayfields['f.date_when']['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, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// User creation +if (!empty($arrayfields['f.fk_user_author']['checked'])) { + print ''; +} +// User modification +if (!empty($arrayfields['f.fk_user_modif']['checked'])) { + print ''; +} +// Date creation +if (!empty($arrayfields['f.datec']['checked'])) { + print ''; +} +// Date modification +if (!empty($arrayfields['f.tms']['checked'])) { + print ''; +} +// Status +if (!empty($arrayfields['status']['checked'])) { + print ''; +} +// Action column +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; - print "\n"; +} +print ''."\n"; + +$totalarray = array(); +$totalarray['nbfield'] = 0; + +// Fields title label +// -------------------------------------------------------------------- +print ''; +// Action column +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.titre']['checked'])) { + print_liste_field_titre($arrayfields['f.titre']['label'], $_SERVER['PHP_SELF'], "f.titre", "", $param, "", $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['s.nom']['checked'])) { + print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], "s.nom", "", $param, "", $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.total_ht']['checked'])) { + print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], "f.total_ht", "", $param, '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.total_tva']['checked'])) { + print_liste_field_titre($arrayfields['f.total_tva']['label'], $_SERVER['PHP_SELF'], "f.total_tva", "", $param, '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.total_ttc']['checked'])) { + print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], "f.total_ttc", "", $param, '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { + print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_cond_reglement", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { + print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_mode_reglement", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['recurring']['checked'])) { + print_liste_field_titre($arrayfields['recurring']['label'], $_SERVER['PHP_SELF'], "recurring", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.frequency']['checked'])) { + print_liste_field_titre($arrayfields['f.frequency']['label'], $_SERVER['PHP_SELF'], "f.frequency", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.unit_frequency']['checked'])) { + print_liste_field_titre($arrayfields['f.unit_frequency']['label'], $_SERVER['PHP_SELF'], "f.unit_frequency", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.nb_gen_done']['checked'])) { + print_liste_field_titre($arrayfields['f.nb_gen_done']['label'], $_SERVER['PHP_SELF'], "f.nb_gen_done", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.date_last_gen']['checked'])) { + print_liste_field_titre($arrayfields['f.date_last_gen']['label'], $_SERVER['PHP_SELF'], "f.date_last_gen", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.date_when']['checked'])) { + print_liste_field_titre($arrayfields['f.date_when']['label'], $_SERVER['PHP_SELF'], "f.date_when", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.fk_user_author']['checked'])) { + print_liste_field_titre($arrayfields['f.fk_user_author']['label'], $_SERVER['PHP_SELF'], "f.fk_user_author", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.fk_user_modif']['checked'])) { + print_liste_field_titre($arrayfields['f.fk_user_modif']['label'], $_SERVER['PHP_SELF'], "f.fk_user_modif", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.datec']['checked'])) { + print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER['PHP_SELF'], "f.datec", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.tms']['checked'])) { + print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER['PHP_SELF'], "f.tms", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; +if (!empty($arrayfields['status']['checked'])) { + print_liste_field_titre($arrayfields['status']['label'], $_SERVER['PHP_SELF'], "f.suspended,f.frequency", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +// Action column +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + $totalarray['nbfield']++; +} +print ''."\n"; + +$i = 0; +$savnbfield = $totalarray['nbfield']; +$totalarray = array(); +$totalarray['nbfield'] = 0; +$totalarray['val']['f.total_ht'] = 0; +$totalarray['val']['f.total_tva'] = 0; +$totalarray['val']['f.total_ttc'] = 0; +$imaxinloop = ($limit ? min($num, $limit) : $num); + +while ($i < $imaxinloop) { + $objp = $db->fetch_object($resql); + if (empty($objp)) { + break; + } + + $companystatic->id = $objp->socid; + $companystatic->name = $objp->name; + + $supplierinvoicerectmp->id = !empty($objp->id) ? $objp->id : $objp->facid; + $supplierinvoicerectmp->frequency = $objp->frequency; + $supplierinvoicerectmp->suspended = $objp->suspended; + $supplierinvoicerectmp->unit_frequency = $objp->unit_frequency; + $supplierinvoicerectmp->nb_gen_max = $objp->nb_gen_max; + $supplierinvoicerectmp->nb_gen_done = $objp->nb_gen_done; + $supplierinvoicerectmp->ref = $objp->title; + $supplierinvoicerectmp->total_ht = $objp->total_ht; + $supplierinvoicerectmp->total_tva = $objp->total_tva; + $supplierinvoicerectmp->total_ttc = $objp->total_ttc; + + // Show here line of result + $j = 0; + print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print '"; + if (!$i) { + $totalarray['nbfield']++; + } + } - print ''; if (!empty($arrayfields['f.titre']['checked'])) { - print_liste_field_titre($arrayfields['f.titre']['label'], $_SERVER['PHP_SELF'], "f.titre", "", $param, "", $sortfield, $sortorder); + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } } if (!empty($arrayfields['s.nom']['checked'])) { - print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], "s.nom", "", $param, "", $sortfield, $sortorder); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } if (!empty($arrayfields['f.total_ht']['checked'])) { - print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], "f.total_ht", "", $param, 'class="right"', $sortfield, $sortorder); + print ''."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht'; + } + $totalarray['val']['f.total_ht'] += $objp->total_ht; } if (!empty($arrayfields['f.total_tva']['checked'])) { - print_liste_field_titre($arrayfields['f.total_tva']['label'], $_SERVER['PHP_SELF'], "f.total_tva", "", $param, 'class="right"', $sortfield, $sortorder); + print ''."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_tva'; + } + $totalarray['val']['f.total_tva'] += $objp->total_tva; } if (!empty($arrayfields['f.total_ttc']['checked'])) { - print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], "f.total_ttc", "", $param, 'class="right"', $sortfield, $sortorder); + print ''."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc'; + } + $totalarray['val']['f.total_ttc'] += $objp->total_ttc; } + // Payment term if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { - print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_cond_reglement", "", $param, '', $sortfield, $sortorder); + print ''."\n"; + if (!$i) { + $totalarray['nbfield']++; + } } + // Payment mode if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { - print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_mode_reglement", "", $param, '', $sortfield, $sortorder); + print ''."\n"; + if (!$i) { + $totalarray['nbfield']++; + } } + // Is it a recurring invoice if (!empty($arrayfields['recurring']['checked'])) { - print_liste_field_titre($arrayfields['recurring']['label'], $_SERVER['PHP_SELF'], "recurring", "", $param, 'class="center"', $sortfield, $sortorder); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } if (!empty($arrayfields['f.frequency']['checked'])) { - print_liste_field_titre($arrayfields['f.frequency']['label'], $_SERVER['PHP_SELF'], "f.frequency", "", $param, 'align="center"', $sortfield, $sortorder); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } if (!empty($arrayfields['f.unit_frequency']['checked'])) { - print_liste_field_titre($arrayfields['f.unit_frequency']['label'], $_SERVER['PHP_SELF'], "f.unit_frequency", "", $param, 'align="center"', $sortfield, $sortorder); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } if (!empty($arrayfields['f.nb_gen_done']['checked'])) { - print_liste_field_titre($arrayfields['f.nb_gen_done']['label'], $_SERVER['PHP_SELF'], "f.nb_gen_done", "", $param, 'align="center"', $sortfield, $sortorder); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } + // Date last generation if (!empty($arrayfields['f.date_last_gen']['checked'])) { - print_liste_field_titre($arrayfields['f.date_last_gen']['label'], $_SERVER['PHP_SELF'], "f.date_last_gen", "", $param, 'align="center"', $sortfield, $sortorder); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } + // Date next generation if (!empty($arrayfields['f.date_when']['checked'])) { - print_liste_field_titre($arrayfields['f.date_when']['label'], $_SERVER['PHP_SELF'], "f.date_when", "", $param, 'align="center"', $sortfield, $sortorder); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } if (!empty($arrayfields['f.fk_user_author']['checked'])) { - print_liste_field_titre($arrayfields['f.fk_user_author']['label'], $_SERVER['PHP_SELF'], "f.fk_user_author", "", $param, 'align="center"', $sortfield, $sortorder); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } if (!empty($arrayfields['f.fk_user_modif']['checked'])) { - print_liste_field_titre($arrayfields['f.fk_user_modif']['label'], $_SERVER['PHP_SELF'], "f.fk_user_modif", "", $param, 'align="center"', $sortfield, $sortorder); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } if (!empty($arrayfields['f.datec']['checked'])) { - print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER['PHP_SELF'], "f.datec", "", $param, 'align="center"', $sortfield, $sortorder); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } if (!empty($arrayfields['f.tms']['checked'])) { - print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER['PHP_SELF'], "f.tms", "", $param, 'align="center"', $sortfield, $sortorder); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } + + $obj = $objp; // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + 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); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Status if (!empty($arrayfields['status']['checked'])) { - print_liste_field_titre($arrayfields['status']['label'], $_SERVER['PHP_SELF'], "f.suspended,f.frequency", "", $param, 'align="center"', $sortfield, $sortorder); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'center maxwidthsearch '); - print "\n"; - - if ($num > 0) { - $i = 0; - $totalarray = array(); - $totalarray['nbfield'] = 0; - $totalarray['val']['f.total_ht'] = 0; - $totalarray['val']['f.total_tva'] = 0; - $totalarray['val']['f.total_ttc'] = 0; - while ($i < min($num, $limit)) { - $objp = $db->fetch_object($resql); - if (empty($objp)) { - break; - } - - $companystatic->id = $objp->socid; - $companystatic->name = $objp->name; - - $supplierinvoicerectmp->id = !empty($objp->id) ? $objp->id : $objp->facid; - $supplierinvoicerectmp->frequency = $objp->frequency; - $supplierinvoicerectmp->suspended = $objp->suspended; - $supplierinvoicerectmp->unit_frequency = $objp->unit_frequency; - $supplierinvoicerectmp->nb_gen_max = $objp->nb_gen_max; - $supplierinvoicerectmp->nb_gen_done = $objp->nb_gen_done; - $supplierinvoicerectmp->ref = $objp->title; - $supplierinvoicerectmp->total_ht = $objp->total_ht; - $supplierinvoicerectmp->total_tva = $objp->total_tva; - $supplierinvoicerectmp->total_ttc = $objp->total_ttc; - - print ''; - - if (!empty($arrayfields['f.titre']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['f.total_ht']['checked'])) { - print ''."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht'; - } - $totalarray['val']['f.total_ht'] += $objp->total_ht; - } - if (!empty($arrayfields['f.total_tva']['checked'])) { - print ''."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'f.total_tva'; - } - $totalarray['val']['f.total_tva'] += $objp->total_tva; - } - if (!empty($arrayfields['f.total_ttc']['checked'])) { - print ''."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc'; - } - $totalarray['val']['f.total_ttc'] += $objp->total_ttc; - } - // Payment term - if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { - print ''."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Payment mode - if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { - print ''."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Is it a recurring invoice - if (!empty($arrayfields['recurring']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['f.frequency']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['f.unit_frequency']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['f.nb_gen_done']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date last generation - if (!empty($arrayfields['f.date_last_gen']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date next generation - if (!empty($arrayfields['f.date_when']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['f.fk_user_author']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['f.fk_user_modif']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['f.datec']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['f.tms']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - $obj = $objp; - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$objp, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Status - if (!empty($arrayfields['status']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Action column - print '"; - - print "\n"; - - $i++; - } - } else { - $colspan = 1; - foreach ($arrayfields as $key => $val) { - if (!empty($val['checked'])) { - $colspan++; + print $form->textwithpicto('', $langs->trans("DateIsNotEnough")); } } - print ''; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - // Show total line - include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + print ''."\n"; - - print "
    '; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print $form->getSelectConditionsPaiements($search_payment_term, 'search_payment_term', -1, 1, 1, 'maxwidth100'); + print "'; + print $form->select_types_paiements($search_payment_mode, 'search_payment_mode', '', 0, 1, 1, 0, 1, 'maxwidth100', 1); + print ''; + print $form->selectyesno('search_recurring', $search_recurring, 1, false, 1); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
    '; + print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
    '; + print '
    '; + print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
    '; + print '
    '; + print '
    '; + print $form->selectDate($search_date_when_start ? $search_date_when_start : -1, 'search_date_when_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
    '; + print '
    '; + print $form->selectDate($search_date_when_end ? $search_date_when_end : -1, 'search_date_when_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
    '; + print '
    '; + print ''; + print ''; + print ''; + print ''; + $liststatus = array( + 0=>$langs->trans("Draft"), + 1=>$langs->trans("Active"), + -1=>$langs->trans("Disabled"), + ); + print $form->selectarray('search_status', $liststatus, $search_status, -2, 0, 0, '', 0, 0, 0, '', 'width100 onrightofpage'); + print ''; $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
    '; + if ($user->hasRight('facture', 'creer') && empty($supplierinvoicerectmp->suspended)) { + if ($supplierinvoicerectmp->isMaxNbGenReached()) { + print $langs->trans("MaxNumberOfGenerationReached"); + } elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) { + print ''; + print img_picto($langs->trans("CreateBill"), 'add', 'class="paddingrightonly"'); + print $langs->trans("CreateBill").''; + } else { + print $form->textwithpicto('', $langs->trans("DateIsNotEnough")); + } + } + print "
    '; + print $supplierinvoicerectmp->getNomUrl(1); + print "'.$companystatic->getNomUrl(1, 'supplier').''.price($objp->total_ht).''.price($objp->total_tva).''.price($objp->total_ttc).''; + $form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none'); + print ''; + $form->form_modes_reglement('', $objp->fk_mode_reglement, 'none'); + print ''.($objp->frequency ? img_picto($langs->trans("Frequency").': '.$objp->frequency.' '.$objp->unit_frequency, 'recurring', 'class="opacitymedium"').' ' : '').yn($objp->frequency ? 1 : 0).''; + print ($objp->frequency > 0 ? $objp->frequency : ''); + print ''; + if ($objp->frequency > 1) { + $dur = array("i"=>$langs->trans("Minutes"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); + } else { + $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); + } + print ($objp->frequency > 0 ? $dur[$objp->unit_frequency] : ''); + print ''; + print ($objp->frequency > 0 ? $objp->nb_gen_done.($objp->nb_gen_max > 0 ? ' / '.$objp->nb_gen_max : '') : ''.$langs->trans('NA').''); + print ''; + print ($objp->frequency > 0 ? dol_print_date($db->jdate($objp->date_last_gen), 'day') : ''.$langs->trans('NA').''); + print ''; + print '
    '; + print ($objp->frequency ? ($supplierinvoicerectmp->isMaxNbGenReached() ? '' : '').dol_print_date($db->jdate($objp->date_when), 'day').($supplierinvoicerectmp->isMaxNbGenReached() ? '' : '') : ''.$langs->trans('NA').''); + if (!$supplierinvoicerectmp->isMaxNbGenReached()) { + if (!$objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) { + print img_warning($langs->trans("Late")); + } + } else { + print img_info($langs->trans("MaxNumberOfGenerationReached")); + } + print '
    '; + print '
    '; + if ($objp->fk_user_author > 0) { + $tmpuser->fetch($objp->fk_user_author); + print $tmpuser->getNomUrl(1); + } + print ''; + if ($objp->fk_user_author > 0) { + $tmpuser->fetch($objp->fk_user_author); + print $tmpuser->getNomUrl(1); + } + print ''; + print dol_print_date($db->jdate($objp->datec), 'dayhour'); + print ''; + print dol_print_date($db->jdate($objp->tms), 'dayhour'); + print ''; + print $supplierinvoicerectmp->getLibStatut(5, 0); + print '
    '; - print $supplierinvoicerectmp->getNomUrl(1); - print ""; - print "'.$companystatic->getNomUrl(1, 'supplier').''.price($objp->total_ht).''.price($objp->total_tva).''.price($objp->total_ttc).''; - $form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none'); - print ''; - $form->form_modes_reglement('', $objp->fk_mode_reglement, 'none'); - print ''.($objp->frequency ? img_picto($langs->trans("Frequency").': '.$objp->frequency.' '.$objp->unit_frequency, 'recurring', 'class="opacitymedium"').' ' : '').yn($objp->frequency ? 1 : 0).''.($objp->frequency > 0 ? $objp->frequency : '').''.($objp->frequency > 0 ? $objp->unit_frequency : '').''; - print ($objp->frequency > 0 ? $objp->nb_gen_done.($objp->nb_gen_max > 0 ? ' / '.$objp->nb_gen_max : '') : ''.$langs->trans('NA').''); - print ''; - print ($objp->frequency > 0 ? dol_print_date($db->jdate($objp->date_last_gen), 'day') : ''.$langs->trans('NA').''); - print ''; - print '
    '; - print ($objp->frequency ? ($supplierinvoicerectmp->isMaxNbGenReached() ? '' : '').dol_print_date($db->jdate($objp->date_when), 'day').($supplierinvoicerectmp->isMaxNbGenReached() ? '' : '') : ''.$langs->trans('NA').''); - if (!$supplierinvoicerectmp->isMaxNbGenReached()) { - if (!$objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) { - print img_warning($langs->trans("Late")); - } - } else { - print img_info($langs->trans("MaxNumberOfGenerationReached")); - } - print '
    '; - print '
    '; - if ($objp->fk_user_author > 0) { - $tmpuser->fetch($objp->fk_user_author); - print $tmpuser->getNomUrl(1); - } - print ''; - if ($objp->fk_user_author > 0) { - $tmpuser->fetch($objp->fk_user_author); - print $tmpuser->getNomUrl(1); - } - print ''; - print dol_print_date($db->jdate($objp->datec), 'dayhour'); - print ''; - print dol_print_date($db->jdate($objp->tms), 'dayhour'); - print ''; - print $supplierinvoicerectmp->getLibStatut(3, 0); - print ''; - if ($user->hasRight('facture', 'creer') && empty($supplierinvoicerectmp->suspended)) { - if ($supplierinvoicerectmp->isMaxNbGenReached()) { - print $langs->trans("MaxNumberOfGenerationReached"); - } elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) { - print ''; - print img_picto($langs->trans("CreateBill"), 'add', 'class="paddingrightonly"'); - print $langs->trans("CreateBill").''; - } else { - print $form->textwithpicto('', $langs->trans("DateIsNotEnough")); - } + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + if ($user->hasRight('facture', 'creer') && empty($supplierinvoicerectmp->suspended)) { + if ($supplierinvoicerectmp->isMaxNbGenReached()) { + print $langs->trans("MaxNumberOfGenerationReached"); + } elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) { + print ''; + print img_picto($langs->trans("CreateBill"), 'add', 'class="paddingrightonly"'); + print $langs->trans("CreateBill").''; } else { - print " "; - } - if (!$i) { - $totalarray['nbfield']++; - } - print "
    '.$langs->trans("NoRecordFound").'
    "; - print "
    "; - print ""; - - $db->free($resql); -} else { - dol_print_error($db); + $i++; } + +// Show total line +include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + +// If no record found +if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print '
    '.$langs->trans("NoRecordFound").'
    '."\n"; +print '
    '."\n"; + +print ''."\n"; + + // End of page llxFooter(); $db->close(); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 303ad09369a..89db6a75f13 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -200,6 +200,7 @@ $arrayfields = array( 'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>501), 'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>502), 'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), + 'f.nb_docs'=>array('label'=>"Documents", 'checked'=>1, 'position'=>510), ); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; @@ -650,9 +651,6 @@ if (!empty($searchCategoryProductList)) { } } } -if ($search_status != '' && $search_status >= 0) { - $sql .= " AND f.fk_statut = ".((int) $search_status); -} if ($filter && $filter != -1) { $aFilter = explode(',', $filter); foreach ($aFilter as $fil) { @@ -1157,6 +1155,11 @@ if (!empty($arrayfields['f.total_ttc']['checked'])) { print ''; print '
    '; + print ''; @@ -1341,6 +1344,9 @@ if (!empty($arrayfields['f.total_ttc']['checked'])) { print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); $totalarray['nbfield']++; } +if (!empty($arrayfields['f.nb_docs']['checked'])) { + print_liste_field_titre($arrayfields['f.nb_docs']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); +} if (!empty($arrayfields['u.login']['checked'])) { print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder); $totalarray['nbfield']++; @@ -1770,6 +1776,17 @@ while ($i < $imaxinloop) { $totalarray['val']['f.total_ttc'] += $obj->total_ttc; } + // Number of attached documents + if (!empty($arrayfields['f.nb_docs']['checked'])) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; + $upload_dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($facturestatic->id, 2, 0, 0, $facturestatic, 'invoice_supplier').$facturestatic->ref; + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); + $nbLinks = Link::count($db, $facturestatic->element, $facturestatic->id); + $nbTotal = $nbFiles + $nbLinks; + echo ''.(empty($nbTotal)? '':$nbTotal).''; diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 2f101b1bdf6..c06467d1d24 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -523,11 +523,29 @@ if (empty($reshook)) { } } + $typeleaves = $object->getTypes(1, -1); + $labeltoshow = (($typeleaves[$object->fk_type]['code'] && $langs->trans($typeleaves[$object->fk_type]['code']) != $typeleaves[$object->fk_type]['code']) ? $langs->trans($typeleaves[$object->fk_type]['code']) : $typeleaves[$object->fk_type]['label']); + + if ($object->halfday == 2) { + $starthalfdaykey = "Afternoon"; + $endhalfdaykey = "Morning"; + } elseif ($object->halfday == -1) { + $starthalfdaykey = "Afternoon"; + $endhalfdaykey = "Afternoon"; + } elseif ($object->halfday == 1) { + $starthalfdaykey = "Morning"; + $endhalfdaykey = "Morning"; + } elseif ($object->halfday == 0 || $object->halfday == 2) { + $starthalfdaykey = "Morning"; + $endhalfdaykey = "Afternoon"; + } + $link = dol_buildpath("/holiday/card.php", 3) . '?id='.$object->id; $message .= "
      "; $message .= "
    • ".$langs->transnoentitiesnoconv("Name")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."
    • \n"; - $message .= "
    • ".$langs->transnoentitiesnoconv("Period")." : ".dol_print_date($object->date_debut, 'day')." ".$langs->transnoentitiesnoconv("To")." ".dol_print_date($object->date_fin, 'day')."
    • \n"; + $message .= "
    • ".$langs->transnoentitiesnoconv("Type")." : ".(empty($labeltoshow) ? $langs->trans("TypeWasDisabledOrRemoved", $object->fk_type) : $labeltoshow)."
    • \n"; + $message .= "
    • ".$langs->transnoentitiesnoconv("Period")." : ".dol_print_date($object->date_debut, 'day')." ".$langs->transnoentitiesnoconv($starthalfdaykey)." ".$langs->transnoentitiesnoconv("To")." ".dol_print_date($object->date_fin, 'day')." ".$langs->transnoentitiesnoconv($endhalfdaykey)."
    • \n"; $message .= "
    • ".$langs->transnoentitiesnoconv("Link").' : '.$link."
    • \n"; $message .= "
    \n"; @@ -640,7 +658,7 @@ if (empty($reshook)) { $societeName = $conf->global->MAIN_APPLICATION_TITLE; } - $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysValidated"); + $subject = '['.$societeName."] ".$langs->transnoentitiesnoconv("HolidaysValidated"); // Content $message = "

    ".$langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",

    \n"; diff --git a/htdocs/holiday/card_group.php b/htdocs/holiday/card_group.php index 7d90661fa69..c67d055a7e2 100644 --- a/htdocs/holiday/card_group.php +++ b/htdocs/holiday/card_group.php @@ -745,11 +745,29 @@ function sendMail($id, $cancreate, $now, $autoValidation) } } + $typeleaves = $object->getTypes(1, -1); + $labeltoshow = (($typeleaves[$object->fk_type]['code'] && $langs->trans($typeleaves[$object->fk_type]['code']) != $typeleaves[$object->fk_type]['code']) ? $langs->trans($typeleaves[$object->fk_type]['code']) : $typeleaves[$object->fk_type]['label']); + + if ($object->halfday == 2) { + $starthalfdaykey = "Afternoon"; + $endhalfdaykey = "Morning"; + } elseif ($object->halfday == -1) { + $starthalfdaykey = "Afternoon"; + $endhalfdaykey = "Afternoon"; + } elseif ($object->halfday == 1) { + $starthalfdaykey = "Morning"; + $endhalfdaykey = "Morning"; + } elseif ($object->halfday == 0 || $object->halfday == 2) { + $starthalfdaykey = "Morning"; + $endhalfdaykey = "Afternoon"; + } + $link = dol_buildpath("/holiday/card.php", 3) . '?id='.$object->id; $message .= "
      "; $message .= "
    • ".$langs->transnoentitiesnoconv("Name")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."
    • \n"; - $message .= "
    • ".$langs->transnoentitiesnoconv("Period")." : ".dol_print_date($object->date_debut, 'day')." ".$langs->transnoentitiesnoconv("To")." ".dol_print_date($object->date_fin, 'day')."
    • \n"; + $message .= "
    • ".$langs->transnoentitiesnoconv("Type")." : ".(empty($labeltoshow) ? $langs->trans("TypeWasDisabledOrRemoved", $object->fk_type) : $labeltoshow)."
    • \n"; + $message .= "
    • ".$langs->transnoentitiesnoconv("Period")." : ".dol_print_date($object->date_debut, 'day')." ".$langs->transnoentitiesnoconv($starthalfdaykey)." ".$langs->transnoentitiesnoconv("To")." ".dol_print_date($object->date_fin, 'day')." ".$langs->transnoentitiesnoconv($endhalfdaykey)."
    • \n"; $message .= "
    • ".$langs->transnoentitiesnoconv("Link").' : '.$link."
    • \n"; $message .= "
    \n"; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index c01feb32d6c..8410a6175a3 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1379,7 +1379,7 @@ class Holiday extends CommonObject //{ // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index 6ff31497a57..92b1c2eed2e 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -38,6 +38,7 @@ $action = GETPOST('action', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'defineholidaylist'; $massaction = GETPOST('massaction', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); +$mode = GETPOST('optioncss', 'aZ'); $search_name = GETPOST('search_name', 'alpha'); $search_supervisor = GETPOST('search_supervisor', 'int'); @@ -85,6 +86,13 @@ if (empty($user->rights->holiday->read)) { accessforbidden(); } +$arrayfields = array( + 'cp.rowid'=>array('label'=>$langs->trans("Employee"), 'checked'=>1, 'position'=>20), + 'cp.fk_user'=>array('label'=>$langs->trans("Supervisor"), 'checked'=>1, 'position'=>30), + 'cp.nbHoliday'=>array('label'=>$langs->trans("MenuConfCP"), 'checked'=>1, 'position'=>40), + 'cp.note_public'=>array('label'=>$langs->trans("Note"), 'checked'=>1, 'position'=>50), +); + /* * Actions @@ -157,8 +165,6 @@ if (empty($reshook)) { if ($result < 0) { setEventMessages($holiday->error, $holiday->errors, 'errors'); $error++; - } elseif ($result == 0) { - setEventMessages($langs->trans("HolidayQtyNotModified", $user->login), null, 'warnings'); } // Update of the days of the employee @@ -184,6 +190,10 @@ if (empty($reshook)) { } } + if (!$error && !$nbok) { + setEventMessages($langs->trans("HolidayQtyNotModified", $user->login), null, 'warnings'); + } + if (!$error) { $db->commit(); @@ -302,6 +312,7 @@ if (is_numeric($listUsers) && $listUsers < 0) { $i = 0; + if (count($typeleaves) == 0) { //print '
    '; print $langs->trans("NoLeaveWithCounterDefined")."
    \n"; @@ -315,62 +326,93 @@ if (count($typeleaves) == 0) { $moreforfilter = ''; + $selectedfields = ''; + if ($massactionbutton) { + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields .= ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); + } + print '
    '; print ''."\n"; print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } + // User - print ''; - + if (!empty($arrayfields['cp.rowid']['checked'])) { + print ''; + } // Supervisor - print ''; - + if (!empty($arrayfields['cp.fk_user']['checked'])) { + print ''; + } // Type of leave request - if (count($typeleaves)) { - foreach ($typeleaves as $key => $val) { - print ''; + if (!empty($arrayfields['cp.nbHoliday']['checked'])) { + if (count($typeleaves)) { + foreach ($typeleaves as $key => $val) { + print ''; + } + } else { + print ''; } - } else { + } + if (!empty($arrayfields['cp.note_public']['checked'])) { print ''; } print ''; - print ''; // Action column - print ''; + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } print ''; print ''; - print_liste_field_titre('Employee', $_SERVER["PHP_SELF"]); - print_liste_field_titre('Supervisor', $_SERVER["PHP_SELF"]); - if (count($typeleaves)) { - foreach ($typeleaves as $key => $val) { - $labeltype = ($langs->trans($val['code']) != $val['code']) ? $langs->trans($val['code']) : $langs->trans($val['label']); - print_liste_field_titre($labeltype, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'center '); + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + } + if (!empty($arrayfields['cp.rowid']['checked'])) { + print_liste_field_titre('Employee', $_SERVER["PHP_SELF"]); + } + if (!empty($arrayfields['cp.fk_user']['checked'])) { + print_liste_field_titre('Supervisor', $_SERVER["PHP_SELF"]); + } + if (!empty($arrayfields['cp.nbHoliday']['checked'])) { + if (count($typeleaves)) { + foreach ($typeleaves as $key => $val) { + $labeltype = ($langs->trans($val['code']) != $val['code']) ? $langs->trans($val['code']) : $langs->trans($val['label']); + print_liste_field_titre($labeltype, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'center '); + } + } else { + print_liste_field_titre('NoLeaveWithCounterDefined', $_SERVER["PHP_SELF"], '', '', '', ''); } - } else { - print_liste_field_titre('NoLeaveWithCounterDefined', $_SERVER["PHP_SELF"], '', '', '', ''); } - print_liste_field_titre((empty($user->rights->holiday->define_holiday) ? '' : 'Note'), $_SERVER["PHP_SELF"]); + if (!empty($arrayfields['cp.note_public']['checked'])) { + print_liste_field_titre((empty($user->rights->holiday->define_holiday) ? '' : 'Note'), $_SERVER["PHP_SELF"]); + } print_liste_field_titre(''); - - $selectedfields = ''; - if ($massactionbutton) { - $selectedfields = $form->showCheckAddButtons('checkforselect', 1); + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; } - - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print ''; - $usersupervisor = new User($db); foreach ($listUsers as $users) { @@ -398,46 +440,67 @@ if (count($typeleaves) == 0) { print ''; - // User - print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } + + // User + if (!empty($arrayfields['cp.rowid']['checked'])) { + print ''; + } + // Supervisor + if (!empty($arrayfields['cp.fk_user']['checked'])) { + print ''; } - print ''; // Amount for each type - if (count($typeleaves)) { - foreach ($typeleaves as $key => $val) { - $nbtoshow = ''; - if ($holiday->getCPforUser($users['rowid'], $val['rowid']) != '') { - $nbtoshow = price2num($holiday->getCPforUser($users['rowid'], $val['rowid']), 5); - } + if (!empty($arrayfields['cp.nbHoliday']['checked'])) { + if (count($typeleaves)) { + foreach ($typeleaves as $key => $val) { + $nbtoshow = ''; + if ($holiday->getCPforUser($users['rowid'], $val['rowid']) != '') { + $nbtoshow = price2num($holiday->getCPforUser($users['rowid'], $val['rowid']), 5); + } - //var_dump($users['rowid'].' - '.$val['rowid']); - print ''."\n"; } - //print ' '.$langs->trans('days'); - print ''."\n"; + } else { + print ''; } - } else { - print ''; } // Note - print ''; } - print ''; // Button modify print ''."\n"; - print ''; } - print ''; + print ''; $i++; } + if (count($listUsers) <= 0) { + $colspan = 2; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + if ($key == 'cp.nbHoliday') { + foreach ($typeleaves as $key => $val) { + $colspan++; + } + } else { + $colspan++; + } + } + } + print ''; + } + print '
    '; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print ''; - print ''; - print ''; + print ''; + print ''; - print $form->select_dolusers($search_supervisor, 'search_supervisor', 1, null, 0, null, null, 0, 0, 0, '', 0, '', 'maxwidth150'); - print ''; + print $form->select_dolusers($search_supervisor, 'search_supervisor', 1, null, 0, null, null, 0, 0, 0, '', 0, '', 'maxwidth150'); + print ''; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
    '; - print $userstatic->getNomUrl(-1); - print ''; - // Supervisor - print ''; - if ($userstatic->fk_user > 0) { - print $usersupervisor->getNomUrl(-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($userstatic->id, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; + print $userstatic->getNomUrl(-1); + print ''; + if ($userstatic->fk_user > 0) { + print $usersupervisor->getNomUrl(-1); + } + print ''; - if ($canedit) { - print ''; - } else { - print $nbtoshow; + //var_dump($users['rowid'].' - '.$val['rowid']); + print ''; + if ($canedit) { + print ''; + } else { + print $nbtoshow; + } + //print ' '.$langs->trans('days'); + print ''; - if ($canedit) { - print ''; + if (!empty($arrayfields['cp.note_public']['checked'])) { + print ''; + if ($canedit) { + print ''; + } + print ''; @@ -445,21 +508,42 @@ if (count($typeleaves) == 0) { 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($userstatic->id, $arrayofselected)) { - $selected = 1; + // 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($userstatic->id, $arrayofselected)) { + $selected = 1; + } + print ''; } - print ''; + print '
    '.$langs->trans("NoRecordFound").'
    '; print '
    '; } diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index e73e83861c8..962ebc48a19 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -317,7 +317,7 @@ if (!empty($arrayfields['cp.fk_type']['checked'])) { print_liste_field_titre($arrayfields['cp.fk_type']['label'], $_SERVER["PHP_SELF"], 'cp.fk_type', '', '', '', $sortfield, $sortorder); } if (!empty($arrayfields['cp.fk_user']['checked'])) { - print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], 'cp.fk_user', '', '', '', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], 'u.lastname', '', '', '', $sortfield, $sortorder); } if (!empty($arrayfields['ct.label']['checked'])) { print_liste_field_titre($arrayfields['ct.label']['label'], $_SERVER["PHP_SELF"], 'ct.label', '', '', '', $sortfield, $sortorder); diff --git a/htdocs/hrm/class/establishment.class.php b/htdocs/hrm/class/establishment.class.php index 0801f510f10..0c70b3b5014 100644 --- a/htdocs/hrm/class/establishment.class.php +++ b/htdocs/hrm/class/establishment.class.php @@ -456,7 +456,7 @@ class Establishment extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { diff --git a/htdocs/hrm/class/evaluation.class.php b/htdocs/hrm/class/evaluation.class.php index 29880e41cf6..b8f60a606e9 100644 --- a/htdocs/hrm/class/evaluation.class.php +++ b/htdocs/hrm/class/evaluation.class.php @@ -154,7 +154,7 @@ class Evaluation extends CommonObject /** * @var string Name of subtable class that manage subtable lines */ - public $class_element_line = 'Evaluationline'; + public $class_element_line = 'EvaluationLine'; // /** // * @var array List of child tables. To test if we can delete object. @@ -166,10 +166,10 @@ class Evaluation extends CommonObject // * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will // * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object // */ - protected $childtablesoncascade = array('@Evaluationline:hrm/class/evaluationdet.class.php:fk_evaluation'); + protected $childtablesoncascade = array('@EvaluationLine:hrm/class/evaluationdet.class.php:fk_evaluation'); /** - * @var Evaluationline[] Array of subtable lines + * @var EvaluationLine[] Array of subtable lines */ public $lines = array(); @@ -237,7 +237,7 @@ class Evaluation extends CommonObject if (is_array($TRequiredRanks) && !empty($TRequiredRanks)) { $this->lines = array(); foreach ($TRequiredRanks as $required) { - $line = new Evaluationline($this->db); + $line = new EvaluationLine($this->db); $line->fk_evaluation = $resultcreate; $line->fk_skill = $required->fk_skill; $line->required_rank = $required->rankorder; @@ -740,7 +740,7 @@ class Evaluation extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { @@ -790,7 +790,7 @@ class Evaluation extends CommonObject $pospoint = strpos($filearray[0]['name'], '.'); $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint); - if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) { + if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) { $result .= '
    No photo
    '; } else { $result .= '
    No photo
    '; @@ -919,7 +919,7 @@ class Evaluation extends CommonObject { $this->lines = array(); - $objectline = new Evaluationline($this->db); + $objectline = new EvaluationLine($this->db); $result = $objectline->fetchAll('ASC', '', 0, 0, array('customsql'=>'fk_evaluation = '.$this->id)); if (is_numeric($result)) { diff --git a/htdocs/hrm/class/evaluationdet.class.php b/htdocs/hrm/class/evaluationdet.class.php index 1cac3e179ca..acffaaa38c6 100644 --- a/htdocs/hrm/class/evaluationdet.class.php +++ b/htdocs/hrm/class/evaluationdet.class.php @@ -26,15 +26,15 @@ */ // Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; require_once DOL_DOCUMENT_ROOT . '/hrm/class/skillrank.class.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; /** - * Class for Evaluationline + * Class for EvaluationLine */ -class Evaluationline extends CommonObject +class EvaluationLine extends CommonObjectLine { /** * @var string ID of module. @@ -143,7 +143,7 @@ class Evaluationline extends CommonObject // /** // * @var string Name of subtable class that manage subtable lines // */ - // public $class_element_line = 'Evaluationline'; + // public $class_element_line = 'EvaluationLine'; // /** // * @var array List of child tables. To test if we can delete object. @@ -708,7 +708,7 @@ class Evaluationline extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { @@ -758,7 +758,7 @@ class Evaluationline extends CommonObject $pospoint = strpos($filearray[0]['name'], '.'); $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint); - if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) { + if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) { $result .= '
    No photo
    '; } else { $result .= '
    No photo
    '; @@ -887,7 +887,7 @@ class Evaluationline extends CommonObject { $this->lines = array(); - $objectline = new Evaluationline($this->db); + $objectline = new EvaluationLine($this->db); $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_evaluationdet = '.$this->id)); if (is_numeric($result)) { diff --git a/htdocs/hrm/class/job.class.php b/htdocs/hrm/class/job.class.php index 8915780d95a..c001c1cc002 100644 --- a/htdocs/hrm/class/job.class.php +++ b/htdocs/hrm/class/job.class.php @@ -740,7 +740,7 @@ class Job extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { @@ -790,7 +790,7 @@ class Job extends CommonObject $pospoint = strpos($filearray[0]['name'], '.'); $pathtophoto = $class.'/'.$this->label.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint); - if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) { + if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) { $result .= '
    No photo
    '; } else { $result .= '
    No photo
    '; diff --git a/htdocs/hrm/class/position.class.php b/htdocs/hrm/class/position.class.php index fff3ada9d13..9a9abf1216e 100644 --- a/htdocs/hrm/class/position.class.php +++ b/htdocs/hrm/class/position.class.php @@ -716,7 +716,7 @@ class Position extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { @@ -766,7 +766,7 @@ class Position extends CommonObject $pospoint = strpos($filearray[0]['name'], '.'); $pathtophoto = $class . '/' . $this->ref . '/thumbs/' . substr($filename, 0, $pospoint) . '_mini' . substr($filename, $pospoint); - if (empty($conf->global->{strtoupper($module . '_' . $class) . '_FORMATLISTPHOTOSASUSERS'})) { + if (!getDolGlobalString(strtoupper($module . '_' . $class) . '_FORMATLISTPHOTOSASUSERS')) { $result .= '
    No photo
    '; } else { $result .= '
    No photo
    '; diff --git a/htdocs/hrm/class/skill.class.php b/htdocs/hrm/class/skill.class.php index 46f7b3bb5ef..0a2ee71a972 100644 --- a/htdocs/hrm/class/skill.class.php +++ b/htdocs/hrm/class/skill.class.php @@ -783,7 +783,7 @@ class Skill extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { @@ -833,7 +833,7 @@ class Skill extends CommonObject $pospoint = strpos($filearray[0]['name'], '.'); $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint); - if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) { + if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) { $result .= '
    No photo
    '; } else { $result .= '
    No photo
    '; diff --git a/htdocs/hrm/class/skilldet.class.php b/htdocs/hrm/class/skilldet.class.php index 3db74d26da1..ad6b88ee0e0 100644 --- a/htdocs/hrm/class/skilldet.class.php +++ b/htdocs/hrm/class/skilldet.class.php @@ -26,14 +26,14 @@ */ // Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; /** * Class for Skilldet */ -class Skilldet extends CommonObject +class Skilldet extends CommonObjectLine { /** * @var string ID of module. @@ -696,7 +696,7 @@ class Skilldet extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { @@ -746,7 +746,7 @@ class Skilldet extends CommonObject $pospoint = strpos($filearray[0]['name'], '.'); $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint); - if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) { + if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) { $result .= '
    No photo
    '; } else { $result .= '
    No photo
    '; diff --git a/htdocs/hrm/class/skillrank.class.php b/htdocs/hrm/class/skillrank.class.php index 0462055f63e..e2b0706422e 100644 --- a/htdocs/hrm/class/skillrank.class.php +++ b/htdocs/hrm/class/skillrank.class.php @@ -735,7 +735,7 @@ class SkillRank extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { @@ -785,7 +785,7 @@ class SkillRank extends CommonObject $pospoint = strpos($filearray[0]['name'], '.'); $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint); - if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) { + if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) { $result .= '
    No photo
    '; } else { $result .= '
    No photo
    '; diff --git a/htdocs/hrm/skill_tab.php b/htdocs/hrm/skill_tab.php index 738bee72fe2..83841b6258d 100644 --- a/htdocs/hrm/skill_tab.php +++ b/htdocs/hrm/skill_tab.php @@ -113,6 +113,15 @@ if (empty($reshook)) { } } + // update national_registration_number + if ($action == 'setnational_registration_number') { + $object->national_registration_number = (string) GETPOST('national_registration_number', 'alphanohtml'); + $result = $object->update($user); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + if ($action == 'addSkill') { $error = 0; @@ -314,9 +323,21 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
    '.$langs->trans("NationalRegistrationNumber").''; - print showValueWithClipboardCPButton(!empty($object->national_registration_number) ? $object->national_registration_number : ''); + print '
    '.$langs->trans("NationalRegistrationNumber").' '.img_picto($langs->trans("Edit"), 'edit').''; + if ($action == 'editnational_registration_number') { + $ret = '
    '; + $ret .= ''; + $ret .= ''; + $ret .= ''; + $ret .= ''; + $ret .= ' '; + $ret .= ''; + $ret .= '
    '; + print $ret; + } else { + print showValueWithClipboardCPButton(!empty($object->national_registration_number) ? $object->national_registration_number : ''); + } print '